1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2009 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
9 * This program is free software; you can redistribute it and/or *
10 * modify it under the terms of version 2 of the GNU General *
11 * Public License as published by the Free Software Foundation. *
12 * This program is distributed in the hope that it will be useful. *
13 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
14 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
15 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
16 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
17 * TO BE LEGALLY INVALID. See the GNU General Public License for *
18 * more details, a copy of which can be found in the file COPYING *
19 * included with this package. *
20 *******************************************************************/
22 #include <linux/blkdev.h>
23 #include <linux/pci.h>
24 #include <linux/slab.h>
25 #include <linux/interrupt.h>
27 #include <scsi/scsi.h>
28 #include <scsi/scsi_device.h>
29 #include <scsi/scsi_host.h>
30 #include <scsi/scsi_transport_fc.h>
35 #include "lpfc_sli4.h"
37 #include "lpfc_disc.h"
38 #include "lpfc_scsi.h"
40 #include "lpfc_logmsg.h"
41 #include "lpfc_crtn.h"
42 #include "lpfc_vport.h"
43 #include "lpfc_debugfs.h"
46 /* Called to verify a rcv'ed ADISC was intended for us. */
48 lpfc_check_adisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
49 struct lpfc_name
*nn
, struct lpfc_name
*pn
)
51 /* Compare the ADISC rsp WWNN / WWPN matches our internal node
52 * table entry for that node.
54 if (memcmp(nn
, &ndlp
->nlp_nodename
, sizeof (struct lpfc_name
)))
57 if (memcmp(pn
, &ndlp
->nlp_portname
, sizeof (struct lpfc_name
)))
60 /* we match, return success */
65 lpfc_check_sparm(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
66 struct serv_parm
*sp
, uint32_t class, int flogi
)
68 volatile struct serv_parm
*hsp
= &vport
->fc_sparam
;
69 uint16_t hsp_value
, ssp_value
= 0;
72 * The receive data field size and buffer-to-buffer receive data field
73 * size entries are 16 bits but are represented as two 8-bit fields in
74 * the driver data structure to account for rsvd bits and other control
75 * bits. Reconstruct and compare the fields as a 16-bit values before
76 * correcting the byte values.
78 if (sp
->cls1
.classValid
) {
80 hsp_value
= ((hsp
->cls1
.rcvDataSizeMsb
<< 8) |
81 hsp
->cls1
.rcvDataSizeLsb
);
82 ssp_value
= ((sp
->cls1
.rcvDataSizeMsb
<< 8) |
83 sp
->cls1
.rcvDataSizeLsb
);
85 goto bad_service_param
;
86 if (ssp_value
> hsp_value
) {
87 sp
->cls1
.rcvDataSizeLsb
=
88 hsp
->cls1
.rcvDataSizeLsb
;
89 sp
->cls1
.rcvDataSizeMsb
=
90 hsp
->cls1
.rcvDataSizeMsb
;
93 } else if (class == CLASS1
)
94 goto bad_service_param
;
95 if (sp
->cls2
.classValid
) {
97 hsp_value
= ((hsp
->cls2
.rcvDataSizeMsb
<< 8) |
98 hsp
->cls2
.rcvDataSizeLsb
);
99 ssp_value
= ((sp
->cls2
.rcvDataSizeMsb
<< 8) |
100 sp
->cls2
.rcvDataSizeLsb
);
102 goto bad_service_param
;
103 if (ssp_value
> hsp_value
) {
104 sp
->cls2
.rcvDataSizeLsb
=
105 hsp
->cls2
.rcvDataSizeLsb
;
106 sp
->cls2
.rcvDataSizeMsb
=
107 hsp
->cls2
.rcvDataSizeMsb
;
110 } else if (class == CLASS2
)
111 goto bad_service_param
;
112 if (sp
->cls3
.classValid
) {
114 hsp_value
= ((hsp
->cls3
.rcvDataSizeMsb
<< 8) |
115 hsp
->cls3
.rcvDataSizeLsb
);
116 ssp_value
= ((sp
->cls3
.rcvDataSizeMsb
<< 8) |
117 sp
->cls3
.rcvDataSizeLsb
);
119 goto bad_service_param
;
120 if (ssp_value
> hsp_value
) {
121 sp
->cls3
.rcvDataSizeLsb
=
122 hsp
->cls3
.rcvDataSizeLsb
;
123 sp
->cls3
.rcvDataSizeMsb
=
124 hsp
->cls3
.rcvDataSizeMsb
;
127 } else if (class == CLASS3
)
128 goto bad_service_param
;
131 * Preserve the upper four bits of the MSB from the PLOGI response.
132 * These bits contain the Buffer-to-Buffer State Change Number
133 * from the target and need to be passed to the FW.
135 hsp_value
= (hsp
->cmn
.bbRcvSizeMsb
<< 8) | hsp
->cmn
.bbRcvSizeLsb
;
136 ssp_value
= (sp
->cmn
.bbRcvSizeMsb
<< 8) | sp
->cmn
.bbRcvSizeLsb
;
137 if (ssp_value
> hsp_value
) {
138 sp
->cmn
.bbRcvSizeLsb
= hsp
->cmn
.bbRcvSizeLsb
;
139 sp
->cmn
.bbRcvSizeMsb
= (sp
->cmn
.bbRcvSizeMsb
& 0xF0) |
140 (hsp
->cmn
.bbRcvSizeMsb
& 0x0F);
143 memcpy(&ndlp
->nlp_nodename
, &sp
->nodeName
, sizeof (struct lpfc_name
));
144 memcpy(&ndlp
->nlp_portname
, &sp
->portName
, sizeof (struct lpfc_name
));
147 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
149 "(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x) sent "
150 "invalid service parameters. Ignoring device.\n",
152 sp
->nodeName
.u
.wwn
[0], sp
->nodeName
.u
.wwn
[1],
153 sp
->nodeName
.u
.wwn
[2], sp
->nodeName
.u
.wwn
[3],
154 sp
->nodeName
.u
.wwn
[4], sp
->nodeName
.u
.wwn
[5],
155 sp
->nodeName
.u
.wwn
[6], sp
->nodeName
.u
.wwn
[7]);
160 lpfc_check_elscmpl_iocb(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
161 struct lpfc_iocbq
*rspiocb
)
163 struct lpfc_dmabuf
*pcmd
, *prsp
;
168 irsp
= &rspiocb
->iocb
;
169 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
171 /* For lpfc_els_abort, context2 could be zero'ed to delay
172 * freeing associated memory till after ABTS completes.
175 prsp
= list_get_first(&pcmd
->list
, struct lpfc_dmabuf
,
178 lp
= (uint32_t *) prsp
->virt
;
179 ptr
= (void *)((uint8_t *)lp
+ sizeof(uint32_t));
182 /* Force ulpStatus error since we are returning NULL ptr */
183 if (!(irsp
->ulpStatus
)) {
184 irsp
->ulpStatus
= IOSTAT_LOCAL_REJECT
;
185 irsp
->un
.ulpWord
[4] = IOERR_SLI_ABORTED
;
194 * Free resources / clean up outstanding I/Os
195 * associated with a LPFC_NODELIST entry. This
196 * routine effectively results in a "software abort".
199 lpfc_els_abort(struct lpfc_hba
*phba
, struct lpfc_nodelist
*ndlp
)
201 LIST_HEAD(completions
);
202 struct lpfc_sli
*psli
= &phba
->sli
;
203 struct lpfc_sli_ring
*pring
= &psli
->ring
[LPFC_ELS_RING
];
204 struct lpfc_iocbq
*iocb
, *next_iocb
;
206 /* Abort outstanding I/O on NPort <nlp_DID> */
207 lpfc_printf_vlog(ndlp
->vport
, KERN_INFO
, LOG_DISCOVERY
,
208 "0205 Abort outstanding I/O on NPort x%x "
209 "Data: x%x x%x x%x\n",
210 ndlp
->nlp_DID
, ndlp
->nlp_flag
, ndlp
->nlp_state
,
213 lpfc_fabric_abort_nport(ndlp
);
215 /* First check the txq */
216 spin_lock_irq(&phba
->hbalock
);
217 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txq
, list
) {
218 /* Check to see if iocb matches the nport we are looking for */
219 if (lpfc_check_sli_ndlp(phba
, pring
, iocb
, ndlp
)) {
220 /* It matches, so deque and call compl with anp error */
221 list_move_tail(&iocb
->list
, &completions
);
226 /* Next check the txcmplq */
227 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txcmplq
, list
) {
228 /* Check to see if iocb matches the nport we are looking for */
229 if (lpfc_check_sli_ndlp(phba
, pring
, iocb
, ndlp
)) {
230 lpfc_sli_issue_abort_iotag(phba
, pring
, iocb
);
233 spin_unlock_irq(&phba
->hbalock
);
235 /* Cancel all the IOCBs from the completions list */
236 lpfc_sli_cancel_iocbs(phba
, &completions
, IOSTAT_LOCAL_REJECT
,
239 lpfc_cancel_retry_delay_tmo(phba
->pport
, ndlp
);
244 lpfc_rcv_plogi(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
245 struct lpfc_iocbq
*cmdiocb
)
247 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
248 struct lpfc_hba
*phba
= vport
->phba
;
249 struct lpfc_dmabuf
*pcmd
;
252 struct serv_parm
*sp
;
257 memset(&stat
, 0, sizeof (struct ls_rjt
));
258 if (vport
->port_state
<= LPFC_FDISC
) {
259 /* Before responding to PLOGI, check for pt2pt mode.
260 * If we are pt2pt, with an outstanding FLOGI, abort
261 * the FLOGI and resend it first.
263 if (vport
->fc_flag
& FC_PT2PT
) {
264 lpfc_els_abort_flogi(phba
);
265 if (!(vport
->fc_flag
& FC_PT2PT_PLOGI
)) {
266 /* If the other side is supposed to initiate
267 * the PLOGI anyway, just ACC it now and
268 * move on with discovery.
270 phba
->fc_edtov
= FF_DEF_EDTOV
;
271 phba
->fc_ratov
= FF_DEF_RATOV
;
272 /* Start discovery - this should just do
274 lpfc_disc_start(vport
);
276 lpfc_initial_flogi(vport
);
278 stat
.un
.b
.lsRjtRsnCode
= LSRJT_LOGICAL_BSY
;
279 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
280 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
,
285 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
286 lp
= (uint32_t *) pcmd
->virt
;
287 sp
= (struct serv_parm
*) ((uint8_t *) lp
+ sizeof (uint32_t));
288 if (wwn_to_u64(sp
->portName
.u
.wwn
) == 0) {
289 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
290 "0140 PLOGI Reject: invalid nname\n");
291 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
292 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_INVALID_PNAME
;
293 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
297 if (wwn_to_u64(sp
->nodeName
.u
.wwn
) == 0) {
298 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
299 "0141 PLOGI Reject: invalid pname\n");
300 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
301 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_INVALID_NNAME
;
302 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
306 if ((lpfc_check_sparm(vport
, ndlp
, sp
, CLASS3
, 0) == 0)) {
307 /* Reject this request because invalid parameters */
308 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
309 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_SPARM_OPTIONS
;
310 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
314 icmd
= &cmdiocb
->iocb
;
316 /* PLOGI chkparm OK */
317 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
318 "0114 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
319 ndlp
->nlp_DID
, ndlp
->nlp_state
, ndlp
->nlp_flag
,
322 if (vport
->cfg_fcp_class
== 2 && sp
->cls2
.classValid
)
323 ndlp
->nlp_fcp_info
|= CLASS2
;
325 ndlp
->nlp_fcp_info
|= CLASS3
;
327 ndlp
->nlp_class_sup
= 0;
328 if (sp
->cls1
.classValid
)
329 ndlp
->nlp_class_sup
|= FC_COS_CLASS1
;
330 if (sp
->cls2
.classValid
)
331 ndlp
->nlp_class_sup
|= FC_COS_CLASS2
;
332 if (sp
->cls3
.classValid
)
333 ndlp
->nlp_class_sup
|= FC_COS_CLASS3
;
334 if (sp
->cls4
.classValid
)
335 ndlp
->nlp_class_sup
|= FC_COS_CLASS4
;
337 ((sp
->cmn
.bbRcvSizeMsb
& 0x0F) << 8) | sp
->cmn
.bbRcvSizeLsb
;
339 /* no need to reg_login if we are already in one of these states */
340 switch (ndlp
->nlp_state
) {
341 case NLP_STE_NPR_NODE
:
342 if (!(ndlp
->nlp_flag
& NLP_NPR_ADISC
))
344 case NLP_STE_REG_LOGIN_ISSUE
:
345 case NLP_STE_PRLI_ISSUE
:
346 case NLP_STE_UNMAPPED_NODE
:
347 case NLP_STE_MAPPED_NODE
:
348 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
, NULL
);
352 if ((vport
->fc_flag
& FC_PT2PT
) &&
353 !(vport
->fc_flag
& FC_PT2PT_PLOGI
)) {
354 /* rcv'ed PLOGI decides what our NPortId will be */
355 vport
->fc_myDID
= icmd
->un
.rcvels
.parmRo
;
356 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
359 lpfc_config_link(phba
, mbox
);
360 mbox
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
362 rc
= lpfc_sli_issue_mbox(phba
, mbox
, MBX_NOWAIT
);
363 if (rc
== MBX_NOT_FINISHED
) {
364 mempool_free(mbox
, phba
->mbox_mem_pool
);
368 lpfc_can_disctmo(vport
);
370 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
374 rc
= lpfc_reg_rpi(phba
, vport
->vpi
, icmd
->un
.rcvels
.remoteID
,
375 (uint8_t *) sp
, mbox
, 0);
377 mempool_free(mbox
, phba
->mbox_mem_pool
);
381 /* ACC PLOGI rsp command needs to execute first,
382 * queue this mbox command to be processed later.
384 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_reg_login
;
386 * mbox->context2 = lpfc_nlp_get(ndlp) deferred until mailbox
387 * command issued in lpfc_cmpl_els_acc().
390 spin_lock_irq(shost
->host_lock
);
391 ndlp
->nlp_flag
|= (NLP_ACC_REGLOGIN
| NLP_RCV_PLOGI
);
392 spin_unlock_irq(shost
->host_lock
);
395 * If there is an outstanding PLOGI issued, abort it before
396 * sending ACC rsp for received PLOGI. If pending plogi
397 * is not canceled here, the plogi will be rejected by
398 * remote port and will be retried. On a configuration with
399 * single discovery thread, this will cause a huge delay in
400 * discovery. Also this will cause multiple state machines
401 * running in parallel for this node.
403 if (ndlp
->nlp_state
== NLP_STE_PLOGI_ISSUE
) {
404 /* software abort outstanding PLOGI */
405 lpfc_els_abort(phba
, ndlp
);
408 if ((vport
->port_type
== LPFC_NPIV_PORT
&&
409 vport
->cfg_restrict_login
)) {
411 /* In order to preserve RPIs, we want to cleanup
412 * the default RPI the firmware created to rcv
413 * this ELS request. The only way to do this is
414 * to register, then unregister the RPI.
416 spin_lock_irq(shost
->host_lock
);
417 ndlp
->nlp_flag
|= NLP_RM_DFLT_RPI
;
418 spin_unlock_irq(shost
->host_lock
);
419 stat
.un
.b
.lsRjtRsnCode
= LSRJT_INVALID_CMD
;
420 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
421 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
,
425 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
, mbox
);
428 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
429 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_OUT_OF_RESOURCE
;
430 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
435 lpfc_rcv_padisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
436 struct lpfc_iocbq
*cmdiocb
)
438 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
439 struct lpfc_dmabuf
*pcmd
;
440 struct serv_parm
*sp
;
441 struct lpfc_name
*pnn
, *ppn
;
448 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
449 lp
= (uint32_t *) pcmd
->virt
;
452 if (cmd
== ELS_CMD_ADISC
) {
454 pnn
= (struct lpfc_name
*) & ap
->nodeName
;
455 ppn
= (struct lpfc_name
*) & ap
->portName
;
457 sp
= (struct serv_parm
*) lp
;
458 pnn
= (struct lpfc_name
*) & sp
->nodeName
;
459 ppn
= (struct lpfc_name
*) & sp
->portName
;
462 icmd
= &cmdiocb
->iocb
;
463 if (icmd
->ulpStatus
== 0 && lpfc_check_adisc(vport
, ndlp
, pnn
, ppn
)) {
464 if (cmd
== ELS_CMD_ADISC
) {
465 lpfc_els_rsp_adisc_acc(vport
, cmdiocb
, ndlp
);
467 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
,
472 /* Reject this request because invalid parameters */
473 stat
.un
.b
.lsRjtRsvd0
= 0;
474 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
475 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_SPARM_OPTIONS
;
476 stat
.un
.b
.vendorUnique
= 0;
477 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
480 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
);
482 spin_lock_irq(shost
->host_lock
);
483 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
484 spin_unlock_irq(shost
->host_lock
);
485 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
486 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
487 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
492 lpfc_rcv_logo(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
493 struct lpfc_iocbq
*cmdiocb
, uint32_t els_cmd
)
495 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
496 struct lpfc_hba
*phba
= vport
->phba
;
497 struct lpfc_vport
**vports
;
498 int i
, active_vlink_present
= 0 ;
500 /* Put ndlp in NPR state with 1 sec timeout for plogi, ACC logo */
501 /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary
502 * PLOGIs during LOGO storms from a device.
504 spin_lock_irq(shost
->host_lock
);
505 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
506 spin_unlock_irq(shost
->host_lock
);
507 if (els_cmd
== ELS_CMD_PRLO
)
508 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
510 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
511 if (ndlp
->nlp_DID
== Fabric_DID
) {
512 if (vport
->port_state
<= LPFC_FDISC
)
514 lpfc_linkdown_port(vport
);
515 spin_lock_irq(shost
->host_lock
);
516 vport
->fc_flag
|= FC_VPORT_LOGO_RCVD
;
517 spin_unlock_irq(shost
->host_lock
);
518 vports
= lpfc_create_vport_work_array(phba
);
520 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
;
522 if ((!(vports
[i
]->fc_flag
&
523 FC_VPORT_LOGO_RCVD
)) &&
524 (vports
[i
]->port_state
> LPFC_FDISC
)) {
525 active_vlink_present
= 1;
529 lpfc_destroy_vport_work_array(phba
, vports
);
532 if (active_vlink_present
) {
534 * If there are other active VLinks present,
535 * re-instantiate the Vlink using FDISC.
537 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
);
538 spin_lock_irq(shost
->host_lock
);
539 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
540 spin_unlock_irq(shost
->host_lock
);
541 ndlp
->nlp_last_elscmd
= ELS_CMD_FDISC
;
542 vport
->port_state
= LPFC_FDISC
;
544 spin_lock_irq(shost
->host_lock
);
545 phba
->pport
->fc_flag
&= ~FC_LOGO_RCVD_DID_CHNG
;
546 spin_unlock_irq(shost
->host_lock
);
547 lpfc_retry_pport_discovery(phba
);
549 } else if ((!(ndlp
->nlp_type
& NLP_FABRIC
) &&
550 ((ndlp
->nlp_type
& NLP_FCP_TARGET
) ||
551 !(ndlp
->nlp_type
& NLP_FCP_INITIATOR
))) ||
552 (ndlp
->nlp_state
== NLP_STE_ADISC_ISSUE
)) {
553 /* Only try to re-login if this is NOT a Fabric Node */
554 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
555 spin_lock_irq(shost
->host_lock
);
556 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
557 spin_unlock_irq(shost
->host_lock
);
559 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
562 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
563 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
565 spin_lock_irq(shost
->host_lock
);
566 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
567 spin_unlock_irq(shost
->host_lock
);
568 /* The driver has to wait until the ACC completes before it continues
569 * processing the LOGO. The action will resume in
570 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
571 * unreg_login, the driver waits so the ACC does not get aborted.
577 lpfc_rcv_prli(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
578 struct lpfc_iocbq
*cmdiocb
)
580 struct lpfc_dmabuf
*pcmd
;
583 struct fc_rport
*rport
= ndlp
->rport
;
586 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
587 lp
= (uint32_t *) pcmd
->virt
;
588 npr
= (PRLI
*) ((uint8_t *) lp
+ sizeof (uint32_t));
590 ndlp
->nlp_type
&= ~(NLP_FCP_TARGET
| NLP_FCP_INITIATOR
);
591 ndlp
->nlp_fcp_info
&= ~NLP_FCP_2_DEVICE
;
592 if (npr
->prliType
== PRLI_FCP_TYPE
) {
593 if (npr
->initiatorFunc
)
594 ndlp
->nlp_type
|= NLP_FCP_INITIATOR
;
596 ndlp
->nlp_type
|= NLP_FCP_TARGET
;
598 ndlp
->nlp_fcp_info
|= NLP_FCP_2_DEVICE
;
601 /* We need to update the rport role values */
602 roles
= FC_RPORT_ROLE_UNKNOWN
;
603 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
604 roles
|= FC_RPORT_ROLE_FCP_INITIATOR
;
605 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
606 roles
|= FC_RPORT_ROLE_FCP_TARGET
;
608 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_RPORT
,
609 "rport rolechg: role:x%x did:x%x flg:x%x",
610 roles
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
612 fc_remote_port_rolechg(rport
, roles
);
617 lpfc_disc_set_adisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
)
619 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
621 if (!(ndlp
->nlp_flag
& NLP_RPI_VALID
)) {
622 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
626 if (!(vport
->fc_flag
& FC_PT2PT
)) {
627 /* Check config parameter use-adisc or FCP-2 */
628 if ((vport
->cfg_use_adisc
&& (vport
->fc_flag
& FC_RSCN_MODE
)) ||
629 ((ndlp
->nlp_fcp_info
& NLP_FCP_2_DEVICE
) &&
630 (ndlp
->nlp_type
& NLP_FCP_TARGET
))) {
631 spin_lock_irq(shost
->host_lock
);
632 ndlp
->nlp_flag
|= NLP_NPR_ADISC
;
633 spin_unlock_irq(shost
->host_lock
);
637 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
638 lpfc_unreg_rpi(vport
, ndlp
);
642 * lpfc_release_rpi - Release a RPI by issueing unreg_login mailbox cmd.
643 * @phba : Pointer to lpfc_hba structure.
644 * @vport: Pointer to lpfc_vport structure.
645 * @rpi : rpi to be release.
647 * This function will send a unreg_login mailbox command to the firmware
651 lpfc_release_rpi(struct lpfc_hba
*phba
,
652 struct lpfc_vport
*vport
,
658 pmb
= (LPFC_MBOXQ_t
*) mempool_alloc(phba
->mbox_mem_pool
,
661 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_MBOX
,
662 "2796 mailbox memory allocation failed \n");
664 lpfc_unreg_login(phba
, vport
->vpi
, rpi
, pmb
);
665 pmb
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
666 rc
= lpfc_sli_issue_mbox(phba
, pmb
, MBX_NOWAIT
);
667 if (rc
== MBX_NOT_FINISHED
)
668 mempool_free(pmb
, phba
->mbox_mem_pool
);
673 lpfc_disc_illegal(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
674 void *arg
, uint32_t evt
)
676 struct lpfc_hba
*phba
;
677 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
682 /* Release the RPI if reglogin completing */
683 if (!(phba
->pport
->load_flag
& FC_UNLOADING
) &&
684 (evt
== NLP_EVT_CMPL_REG_LOGIN
) &&
685 (!pmb
->u
.mb
.mbxStatus
)) {
687 rpi
= pmb
->u
.mb
.un
.varWords
[0];
688 lpfc_release_rpi(phba
, vport
, rpi
);
690 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
691 "0271 Illegal State Transition: node x%x "
692 "event x%x, state x%x Data: x%x x%x\n",
693 ndlp
->nlp_DID
, evt
, ndlp
->nlp_state
, ndlp
->nlp_rpi
,
695 return ndlp
->nlp_state
;
699 lpfc_cmpl_plogi_illegal(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
700 void *arg
, uint32_t evt
)
702 /* This transition is only legal if we previously
703 * rcv'ed a PLOGI. Since we don't want 2 discovery threads
704 * working on the same NPortID, do nothing for this thread
707 if (!(ndlp
->nlp_flag
& NLP_RCV_PLOGI
)) {
708 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
709 "0272 Illegal State Transition: node x%x "
710 "event x%x, state x%x Data: x%x x%x\n",
711 ndlp
->nlp_DID
, evt
, ndlp
->nlp_state
, ndlp
->nlp_rpi
,
714 return ndlp
->nlp_state
;
717 /* Start of Discovery State Machine routines */
720 lpfc_rcv_plogi_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
721 void *arg
, uint32_t evt
)
723 struct lpfc_iocbq
*cmdiocb
;
725 cmdiocb
= (struct lpfc_iocbq
*) arg
;
727 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
728 return ndlp
->nlp_state
;
730 return NLP_STE_FREED_NODE
;
734 lpfc_rcv_els_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
735 void *arg
, uint32_t evt
)
737 lpfc_issue_els_logo(vport
, ndlp
, 0);
738 return ndlp
->nlp_state
;
742 lpfc_rcv_logo_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
743 void *arg
, uint32_t evt
)
745 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
746 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
748 spin_lock_irq(shost
->host_lock
);
749 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
750 spin_unlock_irq(shost
->host_lock
);
751 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
753 return ndlp
->nlp_state
;
757 lpfc_cmpl_logo_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
758 void *arg
, uint32_t evt
)
760 return NLP_STE_FREED_NODE
;
764 lpfc_device_rm_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
765 void *arg
, uint32_t evt
)
767 return NLP_STE_FREED_NODE
;
771 lpfc_rcv_plogi_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
772 void *arg
, uint32_t evt
)
774 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
775 struct lpfc_hba
*phba
= vport
->phba
;
776 struct lpfc_iocbq
*cmdiocb
= arg
;
777 struct lpfc_dmabuf
*pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
778 uint32_t *lp
= (uint32_t *) pcmd
->virt
;
779 struct serv_parm
*sp
= (struct serv_parm
*) (lp
+ 1);
783 memset(&stat
, 0, sizeof (struct ls_rjt
));
785 /* For a PLOGI, we only accept if our portname is less
786 * than the remote portname.
788 phba
->fc_stat
.elsLogiCol
++;
789 port_cmp
= memcmp(&vport
->fc_portname
, &sp
->portName
,
790 sizeof(struct lpfc_name
));
793 /* Reject this request because the remote node will accept
795 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
796 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_CMD_IN_PROGRESS
;
797 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
800 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
) &&
801 (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) &&
802 (vport
->num_disc_nodes
)) {
803 spin_lock_irq(shost
->host_lock
);
804 ndlp
->nlp_flag
&= ~NLP_NPR_2B_DISC
;
805 spin_unlock_irq(shost
->host_lock
);
806 /* Check if there are more PLOGIs to be sent */
807 lpfc_more_plogi(vport
);
808 if (vport
->num_disc_nodes
== 0) {
809 spin_lock_irq(shost
->host_lock
);
810 vport
->fc_flag
&= ~FC_NDISC_ACTIVE
;
811 spin_unlock_irq(shost
->host_lock
);
812 lpfc_can_disctmo(vport
);
813 lpfc_end_rscn(vport
);
816 } /* If our portname was less */
818 return ndlp
->nlp_state
;
822 lpfc_rcv_prli_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
823 void *arg
, uint32_t evt
)
825 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
828 memset(&stat
, 0, sizeof (struct ls_rjt
));
829 stat
.un
.b
.lsRjtRsnCode
= LSRJT_LOGICAL_BSY
;
830 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
831 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
832 return ndlp
->nlp_state
;
836 lpfc_rcv_logo_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
837 void *arg
, uint32_t evt
)
839 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
841 /* software abort outstanding PLOGI */
842 lpfc_els_abort(vport
->phba
, ndlp
);
844 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
845 return ndlp
->nlp_state
;
849 lpfc_rcv_els_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
850 void *arg
, uint32_t evt
)
852 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
853 struct lpfc_hba
*phba
= vport
->phba
;
854 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
856 /* software abort outstanding PLOGI */
857 lpfc_els_abort(phba
, ndlp
);
859 if (evt
== NLP_EVT_RCV_LOGO
) {
860 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
862 lpfc_issue_els_logo(vport
, ndlp
, 0);
865 /* Put ndlp in npr state set plogi timer for 1 sec */
866 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
867 spin_lock_irq(shost
->host_lock
);
868 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
869 spin_unlock_irq(shost
->host_lock
);
870 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
871 ndlp
->nlp_prev_state
= NLP_STE_PLOGI_ISSUE
;
872 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
874 return ndlp
->nlp_state
;
878 lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport
*vport
,
879 struct lpfc_nodelist
*ndlp
,
883 struct lpfc_hba
*phba
= vport
->phba
;
884 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
885 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
886 struct lpfc_dmabuf
*pcmd
, *prsp
, *mp
;
889 struct serv_parm
*sp
;
892 cmdiocb
= (struct lpfc_iocbq
*) arg
;
893 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
895 if (ndlp
->nlp_flag
& NLP_ACC_REGLOGIN
) {
896 /* Recovery from PLOGI collision logic */
897 return ndlp
->nlp_state
;
900 irsp
= &rspiocb
->iocb
;
905 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
907 prsp
= list_get_first(&pcmd
->list
, struct lpfc_dmabuf
, list
);
909 lp
= (uint32_t *) prsp
->virt
;
910 sp
= (struct serv_parm
*) ((uint8_t *) lp
+ sizeof (uint32_t));
912 /* Some switches have FDMI servers returning 0 for WWN */
913 if ((ndlp
->nlp_DID
!= FDMI_DID
) &&
914 (wwn_to_u64(sp
->portName
.u
.wwn
) == 0 ||
915 wwn_to_u64(sp
->nodeName
.u
.wwn
) == 0)) {
916 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
917 "0142 PLOGI RSP: Invalid WWN.\n");
920 if (!lpfc_check_sparm(vport
, ndlp
, sp
, CLASS3
, 0))
922 /* PLOGI chkparm OK */
923 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
924 "0121 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
925 ndlp
->nlp_DID
, ndlp
->nlp_state
,
926 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
927 if (vport
->cfg_fcp_class
== 2 && (sp
->cls2
.classValid
))
928 ndlp
->nlp_fcp_info
|= CLASS2
;
930 ndlp
->nlp_fcp_info
|= CLASS3
;
932 ndlp
->nlp_class_sup
= 0;
933 if (sp
->cls1
.classValid
)
934 ndlp
->nlp_class_sup
|= FC_COS_CLASS1
;
935 if (sp
->cls2
.classValid
)
936 ndlp
->nlp_class_sup
|= FC_COS_CLASS2
;
937 if (sp
->cls3
.classValid
)
938 ndlp
->nlp_class_sup
|= FC_COS_CLASS3
;
939 if (sp
->cls4
.classValid
)
940 ndlp
->nlp_class_sup
|= FC_COS_CLASS4
;
942 ((sp
->cmn
.bbRcvSizeMsb
& 0x0F) << 8) | sp
->cmn
.bbRcvSizeLsb
;
944 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
946 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
947 "0133 PLOGI: no memory for reg_login "
948 "Data: x%x x%x x%x x%x\n",
949 ndlp
->nlp_DID
, ndlp
->nlp_state
,
950 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
954 lpfc_unreg_rpi(vport
, ndlp
);
956 if (lpfc_reg_rpi(phba
, vport
->vpi
, irsp
->un
.elsreq64
.remoteID
,
957 (uint8_t *) sp
, mbox
, 0) == 0) {
958 switch (ndlp
->nlp_DID
) {
960 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_ns_reg_login
;
963 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_fdmi_reg_login
;
966 ndlp
->nlp_flag
|= NLP_REG_LOGIN_SEND
;
967 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_reg_login
;
969 mbox
->context2
= lpfc_nlp_get(ndlp
);
971 if (lpfc_sli_issue_mbox(phba
, mbox
, MBX_NOWAIT
)
972 != MBX_NOT_FINISHED
) {
973 lpfc_nlp_set_state(vport
, ndlp
,
974 NLP_STE_REG_LOGIN_ISSUE
);
975 return ndlp
->nlp_state
;
977 if (ndlp
->nlp_flag
& NLP_REG_LOGIN_SEND
)
978 ndlp
->nlp_flag
&= ~NLP_REG_LOGIN_SEND
;
979 /* decrement node reference count to the failed mbox
983 mp
= (struct lpfc_dmabuf
*) mbox
->context1
;
984 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
986 mempool_free(mbox
, phba
->mbox_mem_pool
);
988 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
989 "0134 PLOGI: cannot issue reg_login "
990 "Data: x%x x%x x%x x%x\n",
991 ndlp
->nlp_DID
, ndlp
->nlp_state
,
992 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
994 mempool_free(mbox
, phba
->mbox_mem_pool
);
996 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
997 "0135 PLOGI: cannot format reg_login "
998 "Data: x%x x%x x%x x%x\n",
999 ndlp
->nlp_DID
, ndlp
->nlp_state
,
1000 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
1005 if (ndlp
->nlp_DID
== NameServer_DID
) {
1006 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
1007 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
1008 "0261 Cannot Register NameServer login\n");
1011 spin_lock_irq(shost
->host_lock
);
1012 ndlp
->nlp_flag
|= NLP_DEFER_RM
;
1013 spin_unlock_irq(shost
->host_lock
);
1014 return NLP_STE_FREED_NODE
;
1018 lpfc_cmpl_logo_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1019 void *arg
, uint32_t evt
)
1021 return ndlp
->nlp_state
;
1025 lpfc_cmpl_reglogin_plogi_issue(struct lpfc_vport
*vport
,
1026 struct lpfc_nodelist
*ndlp
, void *arg
, uint32_t evt
)
1028 struct lpfc_hba
*phba
;
1029 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
1030 MAILBOX_t
*mb
= &pmb
->u
.mb
;
1034 /* Release the RPI */
1035 if (!(phba
->pport
->load_flag
& FC_UNLOADING
) &&
1037 rpi
= pmb
->u
.mb
.un
.varWords
[0];
1038 lpfc_release_rpi(phba
, vport
, rpi
);
1040 return ndlp
->nlp_state
;
1044 lpfc_device_rm_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1045 void *arg
, uint32_t evt
)
1047 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1049 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1050 spin_lock_irq(shost
->host_lock
);
1051 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1052 spin_unlock_irq(shost
->host_lock
);
1053 return ndlp
->nlp_state
;
1055 /* software abort outstanding PLOGI */
1056 lpfc_els_abort(vport
->phba
, ndlp
);
1058 lpfc_drop_node(vport
, ndlp
);
1059 return NLP_STE_FREED_NODE
;
1064 lpfc_device_recov_plogi_issue(struct lpfc_vport
*vport
,
1065 struct lpfc_nodelist
*ndlp
,
1069 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1070 struct lpfc_hba
*phba
= vport
->phba
;
1072 /* Don't do anything that will mess up processing of the
1075 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1076 return ndlp
->nlp_state
;
1078 /* software abort outstanding PLOGI */
1079 lpfc_els_abort(phba
, ndlp
);
1081 ndlp
->nlp_prev_state
= NLP_STE_PLOGI_ISSUE
;
1082 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1083 spin_lock_irq(shost
->host_lock
);
1084 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1085 spin_unlock_irq(shost
->host_lock
);
1087 return ndlp
->nlp_state
;
1091 lpfc_rcv_plogi_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1092 void *arg
, uint32_t evt
)
1094 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1095 struct lpfc_hba
*phba
= vport
->phba
;
1096 struct lpfc_iocbq
*cmdiocb
;
1098 /* software abort outstanding ADISC */
1099 lpfc_els_abort(phba
, ndlp
);
1101 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1103 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
1104 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1105 spin_lock_irq(shost
->host_lock
);
1106 ndlp
->nlp_flag
&= ~NLP_NPR_2B_DISC
;
1107 spin_unlock_irq(shost
->host_lock
);
1108 if (vport
->num_disc_nodes
)
1109 lpfc_more_adisc(vport
);
1111 return ndlp
->nlp_state
;
1113 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1114 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1115 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1117 return ndlp
->nlp_state
;
1121 lpfc_rcv_prli_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1122 void *arg
, uint32_t evt
)
1124 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1126 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1127 return ndlp
->nlp_state
;
1131 lpfc_rcv_logo_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1132 void *arg
, uint32_t evt
)
1134 struct lpfc_hba
*phba
= vport
->phba
;
1135 struct lpfc_iocbq
*cmdiocb
;
1137 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1139 /* software abort outstanding ADISC */
1140 lpfc_els_abort(phba
, ndlp
);
1142 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1143 return ndlp
->nlp_state
;
1147 lpfc_rcv_padisc_adisc_issue(struct lpfc_vport
*vport
,
1148 struct lpfc_nodelist
*ndlp
,
1149 void *arg
, uint32_t evt
)
1151 struct lpfc_iocbq
*cmdiocb
;
1153 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1155 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1156 return ndlp
->nlp_state
;
1160 lpfc_rcv_prlo_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1161 void *arg
, uint32_t evt
)
1163 struct lpfc_iocbq
*cmdiocb
;
1165 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1167 /* Treat like rcv logo */
1168 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_PRLO
);
1169 return ndlp
->nlp_state
;
1173 lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport
*vport
,
1174 struct lpfc_nodelist
*ndlp
,
1175 void *arg
, uint32_t evt
)
1177 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1178 struct lpfc_hba
*phba
= vport
->phba
;
1179 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1184 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1185 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1187 ap
= (ADISC
*)lpfc_check_elscmpl_iocb(phba
, cmdiocb
, rspiocb
);
1188 irsp
= &rspiocb
->iocb
;
1190 if ((irsp
->ulpStatus
) ||
1191 (!lpfc_check_adisc(vport
, ndlp
, &ap
->nodeName
, &ap
->portName
))) {
1193 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
);
1194 spin_lock_irq(shost
->host_lock
);
1195 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1196 spin_unlock_irq(shost
->host_lock
);
1197 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1199 memset(&ndlp
->nlp_nodename
, 0, sizeof(struct lpfc_name
));
1200 memset(&ndlp
->nlp_portname
, 0, sizeof(struct lpfc_name
));
1202 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1203 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1204 lpfc_unreg_rpi(vport
, ndlp
);
1205 return ndlp
->nlp_state
;
1208 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1209 rc
= lpfc_sli4_resume_rpi(ndlp
);
1211 /* Stay in state and retry. */
1212 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1213 return ndlp
->nlp_state
;
1217 if (ndlp
->nlp_type
& NLP_FCP_TARGET
) {
1218 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1219 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_MAPPED_NODE
);
1221 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1222 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1225 return ndlp
->nlp_state
;
1229 lpfc_device_rm_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1230 void *arg
, uint32_t evt
)
1232 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1234 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1235 spin_lock_irq(shost
->host_lock
);
1236 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1237 spin_unlock_irq(shost
->host_lock
);
1238 return ndlp
->nlp_state
;
1240 /* software abort outstanding ADISC */
1241 lpfc_els_abort(vport
->phba
, ndlp
);
1243 lpfc_drop_node(vport
, ndlp
);
1244 return NLP_STE_FREED_NODE
;
1249 lpfc_device_recov_adisc_issue(struct lpfc_vport
*vport
,
1250 struct lpfc_nodelist
*ndlp
,
1254 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1255 struct lpfc_hba
*phba
= vport
->phba
;
1257 /* Don't do anything that will mess up processing of the
1260 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1261 return ndlp
->nlp_state
;
1263 /* software abort outstanding ADISC */
1264 lpfc_els_abort(phba
, ndlp
);
1266 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1267 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1268 spin_lock_irq(shost
->host_lock
);
1269 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1270 spin_unlock_irq(shost
->host_lock
);
1271 lpfc_disc_set_adisc(vport
, ndlp
);
1272 return ndlp
->nlp_state
;
1276 lpfc_rcv_plogi_reglogin_issue(struct lpfc_vport
*vport
,
1277 struct lpfc_nodelist
*ndlp
,
1281 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1283 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1284 return ndlp
->nlp_state
;
1288 lpfc_rcv_prli_reglogin_issue(struct lpfc_vport
*vport
,
1289 struct lpfc_nodelist
*ndlp
,
1293 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1295 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1296 return ndlp
->nlp_state
;
1300 lpfc_rcv_logo_reglogin_issue(struct lpfc_vport
*vport
,
1301 struct lpfc_nodelist
*ndlp
,
1305 struct lpfc_hba
*phba
= vport
->phba
;
1306 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1308 LPFC_MBOXQ_t
*nextmb
;
1309 struct lpfc_dmabuf
*mp
;
1311 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1313 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1314 if ((mb
= phba
->sli
.mbox_active
)) {
1315 if ((mb
->u
.mb
.mbxCommand
== MBX_REG_LOGIN64
) &&
1316 (ndlp
== (struct lpfc_nodelist
*) mb
->context2
)) {
1318 mb
->context2
= NULL
;
1319 mb
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
1323 spin_lock_irq(&phba
->hbalock
);
1324 list_for_each_entry_safe(mb
, nextmb
, &phba
->sli
.mboxq
, list
) {
1325 if ((mb
->u
.mb
.mbxCommand
== MBX_REG_LOGIN64
) &&
1326 (ndlp
== (struct lpfc_nodelist
*) mb
->context2
)) {
1327 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1328 spin_unlock_irq(&phba
->hbalock
);
1329 lpfc_sli4_free_rpi(phba
,
1330 mb
->u
.mb
.un
.varRegLogin
.rpi
);
1331 spin_lock_irq(&phba
->hbalock
);
1333 mp
= (struct lpfc_dmabuf
*) (mb
->context1
);
1335 __lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1339 list_del(&mb
->list
);
1340 phba
->sli
.mboxq_cnt
--;
1341 mempool_free(mb
, phba
->mbox_mem_pool
);
1344 spin_unlock_irq(&phba
->hbalock
);
1346 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1347 return ndlp
->nlp_state
;
1351 lpfc_rcv_padisc_reglogin_issue(struct lpfc_vport
*vport
,
1352 struct lpfc_nodelist
*ndlp
,
1356 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1358 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1359 return ndlp
->nlp_state
;
1363 lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport
*vport
,
1364 struct lpfc_nodelist
*ndlp
,
1368 struct lpfc_iocbq
*cmdiocb
;
1370 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1371 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1372 return ndlp
->nlp_state
;
1376 lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport
*vport
,
1377 struct lpfc_nodelist
*ndlp
,
1381 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1382 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
1383 MAILBOX_t
*mb
= &pmb
->u
.mb
;
1384 uint32_t did
= mb
->un
.varWords
[1];
1386 if (mb
->mbxStatus
) {
1387 /* RegLogin failed */
1388 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
1389 "0246 RegLogin failed Data: x%x x%x x%x\n",
1390 did
, mb
->mbxStatus
, vport
->port_state
);
1392 * If RegLogin failed due to lack of HBA resources do not
1395 if (mb
->mbxStatus
== MBXERR_RPI_FULL
) {
1396 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1397 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1398 return ndlp
->nlp_state
;
1401 /* Put ndlp in npr state set plogi timer for 1 sec */
1402 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
1403 spin_lock_irq(shost
->host_lock
);
1404 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1405 spin_unlock_irq(shost
->host_lock
);
1406 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1408 lpfc_issue_els_logo(vport
, ndlp
, 0);
1409 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1410 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1411 return ndlp
->nlp_state
;
1414 ndlp
->nlp_rpi
= mb
->un
.varWords
[0];
1415 ndlp
->nlp_flag
|= NLP_RPI_VALID
;
1417 /* Only if we are not a fabric nport do we issue PRLI */
1418 if (!(ndlp
->nlp_type
& NLP_FABRIC
)) {
1419 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1420 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PRLI_ISSUE
);
1421 lpfc_issue_els_prli(vport
, ndlp
, 0);
1423 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1424 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1426 return ndlp
->nlp_state
;
1430 lpfc_device_rm_reglogin_issue(struct lpfc_vport
*vport
,
1431 struct lpfc_nodelist
*ndlp
,
1435 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1437 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1438 spin_lock_irq(shost
->host_lock
);
1439 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1440 spin_unlock_irq(shost
->host_lock
);
1441 return ndlp
->nlp_state
;
1443 lpfc_drop_node(vport
, ndlp
);
1444 return NLP_STE_FREED_NODE
;
1449 lpfc_device_recov_reglogin_issue(struct lpfc_vport
*vport
,
1450 struct lpfc_nodelist
*ndlp
,
1454 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1456 /* Don't do anything that will mess up processing of the
1459 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1460 return ndlp
->nlp_state
;
1462 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1463 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1464 spin_lock_irq(shost
->host_lock
);
1465 ndlp
->nlp_flag
|= NLP_IGNR_REG_CMPL
;
1466 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1467 spin_unlock_irq(shost
->host_lock
);
1468 lpfc_disc_set_adisc(vport
, ndlp
);
1469 return ndlp
->nlp_state
;
1473 lpfc_rcv_plogi_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1474 void *arg
, uint32_t evt
)
1476 struct lpfc_iocbq
*cmdiocb
;
1478 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1480 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1481 return ndlp
->nlp_state
;
1485 lpfc_rcv_prli_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1486 void *arg
, uint32_t evt
)
1488 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1490 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1491 return ndlp
->nlp_state
;
1495 lpfc_rcv_logo_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1496 void *arg
, uint32_t evt
)
1498 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1500 /* Software abort outstanding PRLI before sending acc */
1501 lpfc_els_abort(vport
->phba
, ndlp
);
1503 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1504 return ndlp
->nlp_state
;
1508 lpfc_rcv_padisc_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1509 void *arg
, uint32_t evt
)
1511 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1513 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1514 return ndlp
->nlp_state
;
1517 /* This routine is envoked when we rcv a PRLO request from a nport
1518 * we are logged into. We should send back a PRLO rsp setting the
1520 * NEXT STATE = PRLI_ISSUE
1523 lpfc_rcv_prlo_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1524 void *arg
, uint32_t evt
)
1526 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1528 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1529 return ndlp
->nlp_state
;
1533 lpfc_cmpl_prli_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1534 void *arg
, uint32_t evt
)
1536 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1537 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1538 struct lpfc_hba
*phba
= vport
->phba
;
1542 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1543 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1544 npr
= (PRLI
*)lpfc_check_elscmpl_iocb(phba
, cmdiocb
, rspiocb
);
1546 irsp
= &rspiocb
->iocb
;
1547 if (irsp
->ulpStatus
) {
1548 if ((vport
->port_type
== LPFC_NPIV_PORT
) &&
1549 vport
->cfg_restrict_login
) {
1552 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1553 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1554 return ndlp
->nlp_state
;
1557 /* Check out PRLI rsp */
1558 ndlp
->nlp_type
&= ~(NLP_FCP_TARGET
| NLP_FCP_INITIATOR
);
1559 ndlp
->nlp_fcp_info
&= ~NLP_FCP_2_DEVICE
;
1560 if ((npr
->acceptRspCode
== PRLI_REQ_EXECUTED
) &&
1561 (npr
->prliType
== PRLI_FCP_TYPE
)) {
1562 if (npr
->initiatorFunc
)
1563 ndlp
->nlp_type
|= NLP_FCP_INITIATOR
;
1564 if (npr
->targetFunc
)
1565 ndlp
->nlp_type
|= NLP_FCP_TARGET
;
1567 ndlp
->nlp_fcp_info
|= NLP_FCP_2_DEVICE
;
1569 if (!(ndlp
->nlp_type
& NLP_FCP_TARGET
) &&
1570 (vport
->port_type
== LPFC_NPIV_PORT
) &&
1571 vport
->cfg_restrict_login
) {
1573 spin_lock_irq(shost
->host_lock
);
1574 ndlp
->nlp_flag
|= NLP_TARGET_REMOVE
;
1575 spin_unlock_irq(shost
->host_lock
);
1576 lpfc_issue_els_logo(vport
, ndlp
, 0);
1578 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1579 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1580 return ndlp
->nlp_state
;
1583 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1584 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
1585 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_MAPPED_NODE
);
1587 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1588 return ndlp
->nlp_state
;
1591 /*! lpfc_device_rm_prli_issue
1602 * This routine is envoked when we a request to remove a nport we are in the
1603 * process of PRLIing. We should software abort outstanding prli, unreg
1604 * login, send a logout. We will change node state to UNUSED_NODE, put it
1605 * on plogi list so it can be freed when LOGO completes.
1610 lpfc_device_rm_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1611 void *arg
, uint32_t evt
)
1613 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1615 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1616 spin_lock_irq(shost
->host_lock
);
1617 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1618 spin_unlock_irq(shost
->host_lock
);
1619 return ndlp
->nlp_state
;
1621 /* software abort outstanding PLOGI */
1622 lpfc_els_abort(vport
->phba
, ndlp
);
1624 lpfc_drop_node(vport
, ndlp
);
1625 return NLP_STE_FREED_NODE
;
1630 /*! lpfc_device_recov_prli_issue
1641 * The routine is envoked when the state of a device is unknown, like
1642 * during a link down. We should remove the nodelist entry from the
1643 * unmapped list, issue a UNREG_LOGIN, do a software abort of the
1644 * outstanding PRLI command, then free the node entry.
1647 lpfc_device_recov_prli_issue(struct lpfc_vport
*vport
,
1648 struct lpfc_nodelist
*ndlp
,
1652 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1653 struct lpfc_hba
*phba
= vport
->phba
;
1655 /* Don't do anything that will mess up processing of the
1658 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1659 return ndlp
->nlp_state
;
1661 /* software abort outstanding PRLI */
1662 lpfc_els_abort(phba
, ndlp
);
1664 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1665 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1666 spin_lock_irq(shost
->host_lock
);
1667 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1668 spin_unlock_irq(shost
->host_lock
);
1669 lpfc_disc_set_adisc(vport
, ndlp
);
1670 return ndlp
->nlp_state
;
1674 lpfc_rcv_plogi_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1675 void *arg
, uint32_t evt
)
1677 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1679 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1680 return ndlp
->nlp_state
;
1684 lpfc_rcv_prli_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1685 void *arg
, uint32_t evt
)
1687 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1689 lpfc_rcv_prli(vport
, ndlp
, cmdiocb
);
1690 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1691 return ndlp
->nlp_state
;
1695 lpfc_rcv_logo_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1696 void *arg
, uint32_t evt
)
1698 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1700 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1701 return ndlp
->nlp_state
;
1705 lpfc_rcv_padisc_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1706 void *arg
, uint32_t evt
)
1708 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1710 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1711 return ndlp
->nlp_state
;
1715 lpfc_rcv_prlo_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1716 void *arg
, uint32_t evt
)
1718 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1720 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1721 return ndlp
->nlp_state
;
1725 lpfc_device_recov_unmap_node(struct lpfc_vport
*vport
,
1726 struct lpfc_nodelist
*ndlp
,
1730 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1732 ndlp
->nlp_prev_state
= NLP_STE_UNMAPPED_NODE
;
1733 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1734 spin_lock_irq(shost
->host_lock
);
1735 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1736 spin_unlock_irq(shost
->host_lock
);
1737 lpfc_disc_set_adisc(vport
, ndlp
);
1739 return ndlp
->nlp_state
;
1743 lpfc_rcv_plogi_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1744 void *arg
, uint32_t evt
)
1746 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1748 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1749 return ndlp
->nlp_state
;
1753 lpfc_rcv_prli_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1754 void *arg
, uint32_t evt
)
1756 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1758 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1759 return ndlp
->nlp_state
;
1763 lpfc_rcv_logo_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1764 void *arg
, uint32_t evt
)
1766 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1768 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1769 return ndlp
->nlp_state
;
1773 lpfc_rcv_padisc_mapped_node(struct lpfc_vport
*vport
,
1774 struct lpfc_nodelist
*ndlp
,
1775 void *arg
, uint32_t evt
)
1777 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1779 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1780 return ndlp
->nlp_state
;
1784 lpfc_rcv_prlo_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1785 void *arg
, uint32_t evt
)
1787 struct lpfc_hba
*phba
= vport
->phba
;
1788 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1790 /* flush the target */
1791 lpfc_sli_abort_iocb(vport
, &phba
->sli
.ring
[phba
->sli
.fcp_ring
],
1792 ndlp
->nlp_sid
, 0, LPFC_CTX_TGT
);
1794 /* Treat like rcv logo */
1795 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_PRLO
);
1796 return ndlp
->nlp_state
;
1800 lpfc_device_recov_mapped_node(struct lpfc_vport
*vport
,
1801 struct lpfc_nodelist
*ndlp
,
1805 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1807 ndlp
->nlp_prev_state
= NLP_STE_MAPPED_NODE
;
1808 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1809 spin_lock_irq(shost
->host_lock
);
1810 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1811 spin_unlock_irq(shost
->host_lock
);
1812 lpfc_disc_set_adisc(vport
, ndlp
);
1813 return ndlp
->nlp_state
;
1817 lpfc_rcv_plogi_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1818 void *arg
, uint32_t evt
)
1820 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1821 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1823 /* Ignore PLOGI if we have an outstanding LOGO */
1824 if (ndlp
->nlp_flag
& (NLP_LOGO_SND
| NLP_LOGO_ACC
))
1825 return ndlp
->nlp_state
;
1826 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
1827 lpfc_cancel_retry_delay_tmo(vport
, ndlp
);
1828 spin_lock_irq(shost
->host_lock
);
1829 ndlp
->nlp_flag
&= ~(NLP_NPR_ADISC
| NLP_NPR_2B_DISC
);
1830 spin_unlock_irq(shost
->host_lock
);
1831 } else if (!(ndlp
->nlp_flag
& NLP_NPR_2B_DISC
)) {
1832 /* send PLOGI immediately, move to PLOGI issue state */
1833 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
)) {
1834 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1835 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1836 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1839 return ndlp
->nlp_state
;
1843 lpfc_rcv_prli_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1844 void *arg
, uint32_t evt
)
1846 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1847 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1850 memset(&stat
, 0, sizeof (struct ls_rjt
));
1851 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
1852 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
1853 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
1855 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
)) {
1856 if (ndlp
->nlp_flag
& NLP_NPR_ADISC
) {
1857 spin_lock_irq(shost
->host_lock
);
1858 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1859 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1860 spin_unlock_irq(shost
->host_lock
);
1861 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_ADISC_ISSUE
);
1862 lpfc_issue_els_adisc(vport
, ndlp
, 0);
1864 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1865 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1866 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1869 return ndlp
->nlp_state
;
1873 lpfc_rcv_logo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1874 void *arg
, uint32_t evt
)
1876 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1878 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1879 return ndlp
->nlp_state
;
1883 lpfc_rcv_padisc_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1884 void *arg
, uint32_t evt
)
1886 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1888 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1890 * Do not start discovery if discovery is about to start
1891 * or discovery in progress for this node. Starting discovery
1892 * here will affect the counting of discovery threads.
1894 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
) &&
1895 !(ndlp
->nlp_flag
& NLP_NPR_2B_DISC
)) {
1896 if (ndlp
->nlp_flag
& NLP_NPR_ADISC
) {
1897 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1898 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1899 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_ADISC_ISSUE
);
1900 lpfc_issue_els_adisc(vport
, ndlp
, 0);
1902 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1903 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1904 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1907 return ndlp
->nlp_state
;
1911 lpfc_rcv_prlo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1912 void *arg
, uint32_t evt
)
1914 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1915 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1917 spin_lock_irq(shost
->host_lock
);
1918 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
1919 spin_unlock_irq(shost
->host_lock
);
1921 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
1923 if ((ndlp
->nlp_flag
& NLP_DELAY_TMO
) == 0) {
1924 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
1925 spin_lock_irq(shost
->host_lock
);
1926 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1927 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1928 spin_unlock_irq(shost
->host_lock
);
1929 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1931 spin_lock_irq(shost
->host_lock
);
1932 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1933 spin_unlock_irq(shost
->host_lock
);
1935 return ndlp
->nlp_state
;
1939 lpfc_cmpl_plogi_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1940 void *arg
, uint32_t evt
)
1942 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1945 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1946 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1948 irsp
= &rspiocb
->iocb
;
1949 if (irsp
->ulpStatus
) {
1950 ndlp
->nlp_flag
|= NLP_DEFER_RM
;
1951 return NLP_STE_FREED_NODE
;
1953 return ndlp
->nlp_state
;
1957 lpfc_cmpl_prli_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1958 void *arg
, uint32_t evt
)
1960 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1963 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1964 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1966 irsp
= &rspiocb
->iocb
;
1967 if (irsp
->ulpStatus
&& (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
)) {
1968 lpfc_drop_node(vport
, ndlp
);
1969 return NLP_STE_FREED_NODE
;
1971 return ndlp
->nlp_state
;
1975 lpfc_cmpl_logo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1976 void *arg
, uint32_t evt
)
1978 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1979 if (ndlp
->nlp_DID
== Fabric_DID
) {
1980 spin_lock_irq(shost
->host_lock
);
1981 vport
->fc_flag
&= ~(FC_FABRIC
| FC_PUBLIC_LOOP
);
1982 spin_unlock_irq(shost
->host_lock
);
1984 lpfc_unreg_rpi(vport
, ndlp
);
1985 return ndlp
->nlp_state
;
1989 lpfc_cmpl_adisc_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1990 void *arg
, uint32_t evt
)
1992 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1995 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1996 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1998 irsp
= &rspiocb
->iocb
;
1999 if (irsp
->ulpStatus
&& (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
)) {
2000 lpfc_drop_node(vport
, ndlp
);
2001 return NLP_STE_FREED_NODE
;
2003 return ndlp
->nlp_state
;
2007 lpfc_cmpl_reglogin_npr_node(struct lpfc_vport
*vport
,
2008 struct lpfc_nodelist
*ndlp
,
2009 void *arg
, uint32_t evt
)
2011 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
2012 MAILBOX_t
*mb
= &pmb
->u
.mb
;
2014 if (!mb
->mbxStatus
) {
2015 ndlp
->nlp_rpi
= mb
->un
.varWords
[0];
2016 ndlp
->nlp_flag
|= NLP_RPI_VALID
;
2018 if (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
) {
2019 lpfc_drop_node(vport
, ndlp
);
2020 return NLP_STE_FREED_NODE
;
2023 return ndlp
->nlp_state
;
2027 lpfc_device_rm_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2028 void *arg
, uint32_t evt
)
2030 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2032 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
2033 spin_lock_irq(shost
->host_lock
);
2034 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
2035 spin_unlock_irq(shost
->host_lock
);
2036 return ndlp
->nlp_state
;
2038 lpfc_drop_node(vport
, ndlp
);
2039 return NLP_STE_FREED_NODE
;
2043 lpfc_device_recov_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2044 void *arg
, uint32_t evt
)
2046 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2048 /* Don't do anything that will mess up processing of the
2051 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
2052 return ndlp
->nlp_state
;
2054 lpfc_cancel_retry_delay_tmo(vport
, ndlp
);
2055 spin_lock_irq(shost
->host_lock
);
2056 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
2057 spin_unlock_irq(shost
->host_lock
);
2058 return ndlp
->nlp_state
;
2062 /* This next section defines the NPort Discovery State Machine */
2064 /* There are 4 different double linked lists nodelist entries can reside on.
2065 * The plogi list and adisc list are used when Link Up discovery or RSCN
2066 * processing is needed. Each list holds the nodes that we will send PLOGI
2067 * or ADISC on. These lists will keep track of what nodes will be effected
2068 * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
2069 * The unmapped_list will contain all nodes that we have successfully logged
2070 * into at the Fibre Channel level. The mapped_list will contain all nodes
2071 * that are mapped FCP targets.
2074 * The bind list is a list of undiscovered (potentially non-existent) nodes
2075 * that we have saved binding information on. This information is used when
2076 * nodes transition from the unmapped to the mapped list.
2078 /* For UNUSED_NODE state, the node has just been allocated .
2079 * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
2080 * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
2081 * and put on the unmapped list. For ADISC processing, the node is taken off
2082 * the ADISC list and placed on either the mapped or unmapped list (depending
2083 * on its previous state). Once on the unmapped list, a PRLI is issued and the
2084 * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
2085 * changed to UNMAPPED_NODE. If the completion indicates a mapped
2086 * node, the node is taken off the unmapped list. The binding list is checked
2087 * for a valid binding, or a binding is automatically assigned. If binding
2088 * assignment is unsuccessful, the node is left on the unmapped list. If
2089 * binding assignment is successful, the associated binding list entry (if
2090 * any) is removed, and the node is placed on the mapped list.
2093 * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
2094 * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
2095 * expire, all effected nodes will receive a DEVICE_RM event.
2098 * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
2099 * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
2100 * check, additional nodes may be added or removed (via DEVICE_RM) to / from
2101 * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
2102 * we will first process the ADISC list. 32 entries are processed initially and
2103 * ADISC is initited for each one. Completions / Events for each node are
2104 * funnelled thru the state machine. As each node finishes ADISC processing, it
2105 * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
2106 * waiting, and the ADISC list count is identically 0, then we are done. For
2107 * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
2108 * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
2109 * list. 32 entries are processed initially and PLOGI is initited for each one.
2110 * Completions / Events for each node are funnelled thru the state machine. As
2111 * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
2112 * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
2113 * indentically 0, then we are done. We have now completed discovery / RSCN
2114 * handling. Upon completion, ALL nodes should be on either the mapped or
2118 static uint32_t (*lpfc_disc_action
[NLP_STE_MAX_STATE
* NLP_EVT_MAX_EVENT
])
2119 (struct lpfc_vport
*, struct lpfc_nodelist
*, void *, uint32_t) = {
2120 /* Action routine Event Current State */
2121 lpfc_rcv_plogi_unused_node
, /* RCV_PLOGI UNUSED_NODE */
2122 lpfc_rcv_els_unused_node
, /* RCV_PRLI */
2123 lpfc_rcv_logo_unused_node
, /* RCV_LOGO */
2124 lpfc_rcv_els_unused_node
, /* RCV_ADISC */
2125 lpfc_rcv_els_unused_node
, /* RCV_PDISC */
2126 lpfc_rcv_els_unused_node
, /* RCV_PRLO */
2127 lpfc_disc_illegal
, /* CMPL_PLOGI */
2128 lpfc_disc_illegal
, /* CMPL_PRLI */
2129 lpfc_cmpl_logo_unused_node
, /* CMPL_LOGO */
2130 lpfc_disc_illegal
, /* CMPL_ADISC */
2131 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2132 lpfc_device_rm_unused_node
, /* DEVICE_RM */
2133 lpfc_disc_illegal
, /* DEVICE_RECOVERY */
2135 lpfc_rcv_plogi_plogi_issue
, /* RCV_PLOGI PLOGI_ISSUE */
2136 lpfc_rcv_prli_plogi_issue
, /* RCV_PRLI */
2137 lpfc_rcv_logo_plogi_issue
, /* RCV_LOGO */
2138 lpfc_rcv_els_plogi_issue
, /* RCV_ADISC */
2139 lpfc_rcv_els_plogi_issue
, /* RCV_PDISC */
2140 lpfc_rcv_els_plogi_issue
, /* RCV_PRLO */
2141 lpfc_cmpl_plogi_plogi_issue
, /* CMPL_PLOGI */
2142 lpfc_disc_illegal
, /* CMPL_PRLI */
2143 lpfc_cmpl_logo_plogi_issue
, /* CMPL_LOGO */
2144 lpfc_disc_illegal
, /* CMPL_ADISC */
2145 lpfc_cmpl_reglogin_plogi_issue
,/* CMPL_REG_LOGIN */
2146 lpfc_device_rm_plogi_issue
, /* DEVICE_RM */
2147 lpfc_device_recov_plogi_issue
, /* DEVICE_RECOVERY */
2149 lpfc_rcv_plogi_adisc_issue
, /* RCV_PLOGI ADISC_ISSUE */
2150 lpfc_rcv_prli_adisc_issue
, /* RCV_PRLI */
2151 lpfc_rcv_logo_adisc_issue
, /* RCV_LOGO */
2152 lpfc_rcv_padisc_adisc_issue
, /* RCV_ADISC */
2153 lpfc_rcv_padisc_adisc_issue
, /* RCV_PDISC */
2154 lpfc_rcv_prlo_adisc_issue
, /* RCV_PRLO */
2155 lpfc_disc_illegal
, /* CMPL_PLOGI */
2156 lpfc_disc_illegal
, /* CMPL_PRLI */
2157 lpfc_disc_illegal
, /* CMPL_LOGO */
2158 lpfc_cmpl_adisc_adisc_issue
, /* CMPL_ADISC */
2159 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2160 lpfc_device_rm_adisc_issue
, /* DEVICE_RM */
2161 lpfc_device_recov_adisc_issue
, /* DEVICE_RECOVERY */
2163 lpfc_rcv_plogi_reglogin_issue
, /* RCV_PLOGI REG_LOGIN_ISSUE */
2164 lpfc_rcv_prli_reglogin_issue
, /* RCV_PLOGI */
2165 lpfc_rcv_logo_reglogin_issue
, /* RCV_LOGO */
2166 lpfc_rcv_padisc_reglogin_issue
, /* RCV_ADISC */
2167 lpfc_rcv_padisc_reglogin_issue
, /* RCV_PDISC */
2168 lpfc_rcv_prlo_reglogin_issue
, /* RCV_PRLO */
2169 lpfc_cmpl_plogi_illegal
, /* CMPL_PLOGI */
2170 lpfc_disc_illegal
, /* CMPL_PRLI */
2171 lpfc_disc_illegal
, /* CMPL_LOGO */
2172 lpfc_disc_illegal
, /* CMPL_ADISC */
2173 lpfc_cmpl_reglogin_reglogin_issue
,/* CMPL_REG_LOGIN */
2174 lpfc_device_rm_reglogin_issue
, /* DEVICE_RM */
2175 lpfc_device_recov_reglogin_issue
,/* DEVICE_RECOVERY */
2177 lpfc_rcv_plogi_prli_issue
, /* RCV_PLOGI PRLI_ISSUE */
2178 lpfc_rcv_prli_prli_issue
, /* RCV_PRLI */
2179 lpfc_rcv_logo_prli_issue
, /* RCV_LOGO */
2180 lpfc_rcv_padisc_prli_issue
, /* RCV_ADISC */
2181 lpfc_rcv_padisc_prli_issue
, /* RCV_PDISC */
2182 lpfc_rcv_prlo_prli_issue
, /* RCV_PRLO */
2183 lpfc_cmpl_plogi_illegal
, /* CMPL_PLOGI */
2184 lpfc_cmpl_prli_prli_issue
, /* CMPL_PRLI */
2185 lpfc_disc_illegal
, /* CMPL_LOGO */
2186 lpfc_disc_illegal
, /* CMPL_ADISC */
2187 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2188 lpfc_device_rm_prli_issue
, /* DEVICE_RM */
2189 lpfc_device_recov_prli_issue
, /* DEVICE_RECOVERY */
2191 lpfc_rcv_plogi_unmap_node
, /* RCV_PLOGI UNMAPPED_NODE */
2192 lpfc_rcv_prli_unmap_node
, /* RCV_PRLI */
2193 lpfc_rcv_logo_unmap_node
, /* RCV_LOGO */
2194 lpfc_rcv_padisc_unmap_node
, /* RCV_ADISC */
2195 lpfc_rcv_padisc_unmap_node
, /* RCV_PDISC */
2196 lpfc_rcv_prlo_unmap_node
, /* RCV_PRLO */
2197 lpfc_disc_illegal
, /* CMPL_PLOGI */
2198 lpfc_disc_illegal
, /* CMPL_PRLI */
2199 lpfc_disc_illegal
, /* CMPL_LOGO */
2200 lpfc_disc_illegal
, /* CMPL_ADISC */
2201 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2202 lpfc_disc_illegal
, /* DEVICE_RM */
2203 lpfc_device_recov_unmap_node
, /* DEVICE_RECOVERY */
2205 lpfc_rcv_plogi_mapped_node
, /* RCV_PLOGI MAPPED_NODE */
2206 lpfc_rcv_prli_mapped_node
, /* RCV_PRLI */
2207 lpfc_rcv_logo_mapped_node
, /* RCV_LOGO */
2208 lpfc_rcv_padisc_mapped_node
, /* RCV_ADISC */
2209 lpfc_rcv_padisc_mapped_node
, /* RCV_PDISC */
2210 lpfc_rcv_prlo_mapped_node
, /* RCV_PRLO */
2211 lpfc_disc_illegal
, /* CMPL_PLOGI */
2212 lpfc_disc_illegal
, /* CMPL_PRLI */
2213 lpfc_disc_illegal
, /* CMPL_LOGO */
2214 lpfc_disc_illegal
, /* CMPL_ADISC */
2215 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2216 lpfc_disc_illegal
, /* DEVICE_RM */
2217 lpfc_device_recov_mapped_node
, /* DEVICE_RECOVERY */
2219 lpfc_rcv_plogi_npr_node
, /* RCV_PLOGI NPR_NODE */
2220 lpfc_rcv_prli_npr_node
, /* RCV_PRLI */
2221 lpfc_rcv_logo_npr_node
, /* RCV_LOGO */
2222 lpfc_rcv_padisc_npr_node
, /* RCV_ADISC */
2223 lpfc_rcv_padisc_npr_node
, /* RCV_PDISC */
2224 lpfc_rcv_prlo_npr_node
, /* RCV_PRLO */
2225 lpfc_cmpl_plogi_npr_node
, /* CMPL_PLOGI */
2226 lpfc_cmpl_prli_npr_node
, /* CMPL_PRLI */
2227 lpfc_cmpl_logo_npr_node
, /* CMPL_LOGO */
2228 lpfc_cmpl_adisc_npr_node
, /* CMPL_ADISC */
2229 lpfc_cmpl_reglogin_npr_node
, /* CMPL_REG_LOGIN */
2230 lpfc_device_rm_npr_node
, /* DEVICE_RM */
2231 lpfc_device_recov_npr_node
, /* DEVICE_RECOVERY */
2235 lpfc_disc_state_machine(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2236 void *arg
, uint32_t evt
)
2238 uint32_t cur_state
, rc
;
2239 uint32_t(*func
) (struct lpfc_vport
*, struct lpfc_nodelist
*, void *,
2241 uint32_t got_ndlp
= 0;
2243 if (lpfc_nlp_get(ndlp
))
2246 cur_state
= ndlp
->nlp_state
;
2248 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
2249 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2250 "0211 DSM in event x%x on NPort x%x in "
2251 "state %d Data: x%x\n",
2252 evt
, ndlp
->nlp_DID
, cur_state
, ndlp
->nlp_flag
);
2254 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2255 "DSM in: evt:%d ste:%d did:x%x",
2256 evt
, cur_state
, ndlp
->nlp_DID
);
2258 func
= lpfc_disc_action
[(cur_state
* NLP_EVT_MAX_EVENT
) + evt
];
2259 rc
= (func
) (vport
, ndlp
, arg
, evt
);
2261 /* DSM out state <rc> on NPort <nlp_DID> */
2263 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2264 "0212 DSM out state %d on NPort x%x Data: x%x\n",
2265 rc
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
2267 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2268 "DSM out: ste:%d did:x%x flg:x%x",
2269 rc
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
2270 /* Decrement the ndlp reference count held for this function */
2273 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2274 "0213 DSM out state %d on NPort free\n", rc
);
2276 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2277 "DSM out: ste:%d did:x%x flg:x%x",