1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2007 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/interrupt.h>
26 #include <scsi/scsi.h>
27 #include <scsi/scsi_device.h>
28 #include <scsi/scsi_host.h>
29 #include <scsi/scsi_transport_fc.h>
33 #include "lpfc_disc.h"
34 #include "lpfc_scsi.h"
36 #include "lpfc_logmsg.h"
37 #include "lpfc_crtn.h"
38 #include "lpfc_vport.h"
39 #include "lpfc_debugfs.h"
42 /* Called to verify a rcv'ed ADISC was intended for us. */
44 lpfc_check_adisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
45 struct lpfc_name
*nn
, struct lpfc_name
*pn
)
47 /* Compare the ADISC rsp WWNN / WWPN matches our internal node
48 * table entry for that node.
50 if (memcmp(nn
, &ndlp
->nlp_nodename
, sizeof (struct lpfc_name
)))
53 if (memcmp(pn
, &ndlp
->nlp_portname
, sizeof (struct lpfc_name
)))
56 /* we match, return success */
61 lpfc_check_sparm(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
62 struct serv_parm
* sp
, uint32_t class)
64 volatile struct serv_parm
*hsp
= &vport
->fc_sparam
;
65 uint16_t hsp_value
, ssp_value
= 0;
68 * The receive data field size and buffer-to-buffer receive data field
69 * size entries are 16 bits but are represented as two 8-bit fields in
70 * the driver data structure to account for rsvd bits and other control
71 * bits. Reconstruct and compare the fields as a 16-bit values before
72 * correcting the byte values.
74 if (sp
->cls1
.classValid
) {
75 hsp_value
= (hsp
->cls1
.rcvDataSizeMsb
<< 8) |
76 hsp
->cls1
.rcvDataSizeLsb
;
77 ssp_value
= (sp
->cls1
.rcvDataSizeMsb
<< 8) |
78 sp
->cls1
.rcvDataSizeLsb
;
80 goto bad_service_param
;
81 if (ssp_value
> hsp_value
) {
82 sp
->cls1
.rcvDataSizeLsb
= hsp
->cls1
.rcvDataSizeLsb
;
83 sp
->cls1
.rcvDataSizeMsb
= hsp
->cls1
.rcvDataSizeMsb
;
85 } else if (class == CLASS1
) {
86 goto bad_service_param
;
89 if (sp
->cls2
.classValid
) {
90 hsp_value
= (hsp
->cls2
.rcvDataSizeMsb
<< 8) |
91 hsp
->cls2
.rcvDataSizeLsb
;
92 ssp_value
= (sp
->cls2
.rcvDataSizeMsb
<< 8) |
93 sp
->cls2
.rcvDataSizeLsb
;
95 goto bad_service_param
;
96 if (ssp_value
> hsp_value
) {
97 sp
->cls2
.rcvDataSizeLsb
= hsp
->cls2
.rcvDataSizeLsb
;
98 sp
->cls2
.rcvDataSizeMsb
= hsp
->cls2
.rcvDataSizeMsb
;
100 } else if (class == CLASS2
) {
101 goto bad_service_param
;
104 if (sp
->cls3
.classValid
) {
105 hsp_value
= (hsp
->cls3
.rcvDataSizeMsb
<< 8) |
106 hsp
->cls3
.rcvDataSizeLsb
;
107 ssp_value
= (sp
->cls3
.rcvDataSizeMsb
<< 8) |
108 sp
->cls3
.rcvDataSizeLsb
;
110 goto bad_service_param
;
111 if (ssp_value
> hsp_value
) {
112 sp
->cls3
.rcvDataSizeLsb
= hsp
->cls3
.rcvDataSizeLsb
;
113 sp
->cls3
.rcvDataSizeMsb
= hsp
->cls3
.rcvDataSizeMsb
;
115 } else if (class == CLASS3
) {
116 goto bad_service_param
;
120 * Preserve the upper four bits of the MSB from the PLOGI response.
121 * These bits contain the Buffer-to-Buffer State Change Number
122 * from the target and need to be passed to the FW.
124 hsp_value
= (hsp
->cmn
.bbRcvSizeMsb
<< 8) | hsp
->cmn
.bbRcvSizeLsb
;
125 ssp_value
= (sp
->cmn
.bbRcvSizeMsb
<< 8) | sp
->cmn
.bbRcvSizeLsb
;
126 if (ssp_value
> hsp_value
) {
127 sp
->cmn
.bbRcvSizeLsb
= hsp
->cmn
.bbRcvSizeLsb
;
128 sp
->cmn
.bbRcvSizeMsb
= (sp
->cmn
.bbRcvSizeMsb
& 0xF0) |
129 (hsp
->cmn
.bbRcvSizeMsb
& 0x0F);
132 memcpy(&ndlp
->nlp_nodename
, &sp
->nodeName
, sizeof (struct lpfc_name
));
133 memcpy(&ndlp
->nlp_portname
, &sp
->portName
, sizeof (struct lpfc_name
));
136 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
138 "(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x) sent "
139 "invalid service parameters. Ignoring device.\n",
141 sp
->nodeName
.u
.wwn
[0], sp
->nodeName
.u
.wwn
[1],
142 sp
->nodeName
.u
.wwn
[2], sp
->nodeName
.u
.wwn
[3],
143 sp
->nodeName
.u
.wwn
[4], sp
->nodeName
.u
.wwn
[5],
144 sp
->nodeName
.u
.wwn
[6], sp
->nodeName
.u
.wwn
[7]);
149 lpfc_check_elscmpl_iocb(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
150 struct lpfc_iocbq
*rspiocb
)
152 struct lpfc_dmabuf
*pcmd
, *prsp
;
157 irsp
= &rspiocb
->iocb
;
158 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
160 /* For lpfc_els_abort, context2 could be zero'ed to delay
161 * freeing associated memory till after ABTS completes.
164 prsp
= list_get_first(&pcmd
->list
, struct lpfc_dmabuf
,
167 lp
= (uint32_t *) prsp
->virt
;
168 ptr
= (void *)((uint8_t *)lp
+ sizeof(uint32_t));
171 /* Force ulpStatus error since we are returning NULL ptr */
172 if (!(irsp
->ulpStatus
)) {
173 irsp
->ulpStatus
= IOSTAT_LOCAL_REJECT
;
174 irsp
->un
.ulpWord
[4] = IOERR_SLI_ABORTED
;
183 * Free resources / clean up outstanding I/Os
184 * associated with a LPFC_NODELIST entry. This
185 * routine effectively results in a "software abort".
188 lpfc_els_abort(struct lpfc_hba
*phba
, struct lpfc_nodelist
*ndlp
)
190 LIST_HEAD(completions
);
191 struct lpfc_sli
*psli
= &phba
->sli
;
192 struct lpfc_sli_ring
*pring
= &psli
->ring
[LPFC_ELS_RING
];
193 struct lpfc_iocbq
*iocb
, *next_iocb
;
196 /* Abort outstanding I/O on NPort <nlp_DID> */
197 lpfc_printf_vlog(ndlp
->vport
, KERN_INFO
, LOG_DISCOVERY
,
198 "0205 Abort outstanding I/O on NPort x%x "
199 "Data: x%x x%x x%x\n",
200 ndlp
->nlp_DID
, ndlp
->nlp_flag
, ndlp
->nlp_state
,
203 lpfc_fabric_abort_nport(ndlp
);
205 /* First check the txq */
206 spin_lock_irq(&phba
->hbalock
);
207 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txq
, list
) {
208 /* Check to see if iocb matches the nport we are looking for */
209 if (lpfc_check_sli_ndlp(phba
, pring
, iocb
, ndlp
)) {
210 /* It matches, so deque and call compl with anp error */
211 list_move_tail(&iocb
->list
, &completions
);
216 /* Next check the txcmplq */
217 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txcmplq
, 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 lpfc_sli_issue_abort_iotag(phba
, pring
, iocb
);
223 spin_unlock_irq(&phba
->hbalock
);
225 while (!list_empty(&completions
)) {
226 iocb
= list_get_first(&completions
, struct lpfc_iocbq
, list
);
228 list_del_init(&iocb
->list
);
230 if (!iocb
->iocb_cmpl
)
231 lpfc_sli_release_iocbq(phba
, iocb
);
233 cmd
->ulpStatus
= IOSTAT_LOCAL_REJECT
;
234 cmd
->un
.ulpWord
[4] = IOERR_SLI_ABORTED
;
235 (iocb
->iocb_cmpl
) (phba
, iocb
, iocb
);
239 /* If we are delaying issuing an ELS command, cancel it */
240 if (ndlp
->nlp_flag
& NLP_DELAY_TMO
)
241 lpfc_cancel_retry_delay_tmo(phba
->pport
, ndlp
);
246 lpfc_rcv_plogi(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
247 struct lpfc_iocbq
*cmdiocb
)
249 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
250 struct lpfc_hba
*phba
= vport
->phba
;
251 struct lpfc_dmabuf
*pcmd
;
254 struct serv_parm
*sp
;
259 memset(&stat
, 0, sizeof (struct ls_rjt
));
260 if (vport
->port_state
<= LPFC_FLOGI
) {
261 /* Before responding to PLOGI, check for pt2pt mode.
262 * If we are pt2pt, with an outstanding FLOGI, abort
263 * the FLOGI and resend it first.
265 if (vport
->fc_flag
& FC_PT2PT
) {
266 lpfc_els_abort_flogi(phba
);
267 if (!(vport
->fc_flag
& FC_PT2PT_PLOGI
)) {
268 /* If the other side is supposed to initiate
269 * the PLOGI anyway, just ACC it now and
270 * move on with discovery.
272 phba
->fc_edtov
= FF_DEF_EDTOV
;
273 phba
->fc_ratov
= FF_DEF_RATOV
;
274 /* Start discovery - this should just do
276 lpfc_disc_start(vport
);
278 lpfc_initial_flogi(vport
);
280 stat
.un
.b
.lsRjtRsnCode
= LSRJT_LOGICAL_BSY
;
281 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
282 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
,
287 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
288 lp
= (uint32_t *) pcmd
->virt
;
289 sp
= (struct serv_parm
*) ((uint8_t *) lp
+ sizeof (uint32_t));
290 if (wwn_to_u64(sp
->portName
.u
.wwn
) == 0) {
291 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
292 "0140 PLOGI Reject: invalid nname\n");
293 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
294 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_INVALID_PNAME
;
295 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
299 if (wwn_to_u64(sp
->nodeName
.u
.wwn
) == 0) {
300 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
301 "0141 PLOGI Reject: invalid pname\n");
302 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
303 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_INVALID_NNAME
;
304 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
308 if ((lpfc_check_sparm(vport
, ndlp
, sp
, CLASS3
) == 0)) {
309 /* Reject this request because invalid parameters */
310 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
311 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_SPARM_OPTIONS
;
312 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
316 icmd
= &cmdiocb
->iocb
;
318 /* PLOGI chkparm OK */
319 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
320 "0114 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
321 ndlp
->nlp_DID
, ndlp
->nlp_state
, ndlp
->nlp_flag
,
324 if (vport
->cfg_fcp_class
== 2 && sp
->cls2
.classValid
)
325 ndlp
->nlp_fcp_info
|= CLASS2
;
327 ndlp
->nlp_fcp_info
|= CLASS3
;
329 ndlp
->nlp_class_sup
= 0;
330 if (sp
->cls1
.classValid
)
331 ndlp
->nlp_class_sup
|= FC_COS_CLASS1
;
332 if (sp
->cls2
.classValid
)
333 ndlp
->nlp_class_sup
|= FC_COS_CLASS2
;
334 if (sp
->cls3
.classValid
)
335 ndlp
->nlp_class_sup
|= FC_COS_CLASS3
;
336 if (sp
->cls4
.classValid
)
337 ndlp
->nlp_class_sup
|= FC_COS_CLASS4
;
339 ((sp
->cmn
.bbRcvSizeMsb
& 0x0F) << 8) | sp
->cmn
.bbRcvSizeLsb
;
341 /* no need to reg_login if we are already in one of these states */
342 switch (ndlp
->nlp_state
) {
343 case NLP_STE_NPR_NODE
:
344 if (!(ndlp
->nlp_flag
& NLP_NPR_ADISC
))
346 case NLP_STE_REG_LOGIN_ISSUE
:
347 case NLP_STE_PRLI_ISSUE
:
348 case NLP_STE_UNMAPPED_NODE
:
349 case NLP_STE_MAPPED_NODE
:
350 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
, NULL
);
354 if ((vport
->fc_flag
& FC_PT2PT
) &&
355 !(vport
->fc_flag
& FC_PT2PT_PLOGI
)) {
356 /* rcv'ed PLOGI decides what our NPortId will be */
357 vport
->fc_myDID
= icmd
->un
.rcvels
.parmRo
;
358 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
361 lpfc_config_link(phba
, mbox
);
362 mbox
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
364 rc
= lpfc_sli_issue_mbox(phba
, mbox
, MBX_NOWAIT
);
365 if (rc
== MBX_NOT_FINISHED
) {
366 mempool_free(mbox
, phba
->mbox_mem_pool
);
370 lpfc_can_disctmo(vport
);
372 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
376 rc
= lpfc_reg_login(phba
, vport
->vpi
, icmd
->un
.rcvels
.remoteID
,
377 (uint8_t *) sp
, mbox
, 0);
379 mempool_free(mbox
, phba
->mbox_mem_pool
);
383 /* ACC PLOGI rsp command needs to execute first,
384 * queue this mbox command to be processed later.
386 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_reg_login
;
388 * mbox->context2 = lpfc_nlp_get(ndlp) deferred until mailbox
389 * command issued in lpfc_cmpl_els_acc().
392 spin_lock_irq(shost
->host_lock
);
393 ndlp
->nlp_flag
|= (NLP_ACC_REGLOGIN
| NLP_RCV_PLOGI
);
394 spin_unlock_irq(shost
->host_lock
);
397 * If there is an outstanding PLOGI issued, abort it before
398 * sending ACC rsp for received PLOGI. If pending plogi
399 * is not canceled here, the plogi will be rejected by
400 * remote port and will be retried. On a configuration with
401 * single discovery thread, this will cause a huge delay in
402 * discovery. Also this will cause multiple state machines
403 * running in parallel for this node.
405 if (ndlp
->nlp_state
== NLP_STE_PLOGI_ISSUE
) {
406 /* software abort outstanding PLOGI */
407 lpfc_els_abort(phba
, ndlp
);
410 if ((vport
->port_type
== LPFC_NPIV_PORT
&&
411 vport
->cfg_restrict_login
)) {
413 /* In order to preserve RPIs, we want to cleanup
414 * the default RPI the firmware created to rcv
415 * this ELS request. The only way to do this is
416 * to register, then unregister the RPI.
418 spin_lock_irq(shost
->host_lock
);
419 ndlp
->nlp_flag
|= NLP_RM_DFLT_RPI
;
420 spin_unlock_irq(shost
->host_lock
);
421 stat
.un
.b
.lsRjtRsnCode
= LSRJT_INVALID_CMD
;
422 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
423 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
,
428 /* If the remote NPort logs into us, before we can initiate
429 * discovery to them, cleanup the NPort from discovery accordingly.
431 if (ndlp
->nlp_state
== NLP_STE_NPR_NODE
) {
432 spin_lock_irq(shost
->host_lock
);
433 ndlp
->nlp_flag
&= ~NLP_DELAY_TMO
;
434 spin_unlock_irq(shost
->host_lock
);
435 del_timer_sync(&ndlp
->nlp_delayfunc
);
436 ndlp
->nlp_last_elscmd
= 0;
438 if (!list_empty(&ndlp
->els_retry_evt
.evt_listp
))
439 list_del_init(&ndlp
->els_retry_evt
.evt_listp
);
441 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
442 spin_lock_irq(shost
->host_lock
);
443 ndlp
->nlp_flag
&= ~NLP_NPR_2B_DISC
;
444 spin_unlock_irq(shost
->host_lock
);
446 if ((ndlp
->nlp_flag
& NLP_ADISC_SND
) &&
447 (vport
->num_disc_nodes
)) {
448 /* Check to see if there are more
451 lpfc_more_adisc(vport
);
453 if ((vport
->num_disc_nodes
== 0) &&
455 lpfc_els_disc_plogi(vport
);
457 if (vport
->num_disc_nodes
== 0) {
458 spin_lock_irq(shost
->host_lock
);
459 vport
->fc_flag
&= ~FC_NDISC_ACTIVE
;
460 spin_unlock_irq(shost
->host_lock
);
461 lpfc_can_disctmo(vport
);
462 lpfc_end_rscn(vport
);
465 else if (vport
->num_disc_nodes
) {
466 /* Check to see if there are more
469 lpfc_more_plogi(vport
);
471 if (vport
->num_disc_nodes
== 0) {
472 spin_lock_irq(shost
->host_lock
);
473 vport
->fc_flag
&= ~FC_NDISC_ACTIVE
;
474 spin_unlock_irq(shost
->host_lock
);
475 lpfc_can_disctmo(vport
);
476 lpfc_end_rscn(vport
);
482 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
, mbox
);
486 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
487 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_OUT_OF_RESOURCE
;
488 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
493 lpfc_rcv_padisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
494 struct lpfc_iocbq
*cmdiocb
)
496 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
497 struct lpfc_dmabuf
*pcmd
;
498 struct serv_parm
*sp
;
499 struct lpfc_name
*pnn
, *ppn
;
506 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
507 lp
= (uint32_t *) pcmd
->virt
;
510 if (cmd
== ELS_CMD_ADISC
) {
512 pnn
= (struct lpfc_name
*) & ap
->nodeName
;
513 ppn
= (struct lpfc_name
*) & ap
->portName
;
515 sp
= (struct serv_parm
*) lp
;
516 pnn
= (struct lpfc_name
*) & sp
->nodeName
;
517 ppn
= (struct lpfc_name
*) & sp
->portName
;
520 icmd
= &cmdiocb
->iocb
;
521 if (icmd
->ulpStatus
== 0 && lpfc_check_adisc(vport
, ndlp
, pnn
, ppn
)) {
522 if (cmd
== ELS_CMD_ADISC
) {
523 lpfc_els_rsp_adisc_acc(vport
, cmdiocb
, ndlp
);
525 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
,
530 /* Reject this request because invalid parameters */
531 stat
.un
.b
.lsRjtRsvd0
= 0;
532 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
533 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_SPARM_OPTIONS
;
534 stat
.un
.b
.vendorUnique
= 0;
535 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
538 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
);
540 spin_lock_irq(shost
->host_lock
);
541 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
542 spin_unlock_irq(shost
->host_lock
);
543 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
544 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
545 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
550 lpfc_rcv_logo(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
551 struct lpfc_iocbq
*cmdiocb
, uint32_t els_cmd
)
553 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
555 /* Put ndlp in NPR state with 1 sec timeout for plogi, ACC logo */
556 /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary
557 * PLOGIs during LOGO storms from a device.
559 spin_lock_irq(shost
->host_lock
);
560 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
561 spin_unlock_irq(shost
->host_lock
);
562 if (els_cmd
== ELS_CMD_PRLO
)
563 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
565 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
567 if (!(ndlp
->nlp_type
& NLP_FABRIC
) ||
568 (ndlp
->nlp_state
== NLP_STE_ADISC_ISSUE
)) {
569 /* Only try to re-login if this is NOT a Fabric Node */
570 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
571 spin_lock_irq(shost
->host_lock
);
572 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
573 spin_unlock_irq(shost
->host_lock
);
575 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
577 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
578 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
580 spin_lock_irq(shost
->host_lock
);
581 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
582 spin_unlock_irq(shost
->host_lock
);
583 /* The driver has to wait until the ACC completes before it continues
584 * processing the LOGO. The action will resume in
585 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
586 * unreg_login, the driver waits so the ACC does not get aborted.
592 lpfc_rcv_prli(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
593 struct lpfc_iocbq
*cmdiocb
)
595 struct lpfc_dmabuf
*pcmd
;
598 struct fc_rport
*rport
= ndlp
->rport
;
601 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
602 lp
= (uint32_t *) pcmd
->virt
;
603 npr
= (PRLI
*) ((uint8_t *) lp
+ sizeof (uint32_t));
605 ndlp
->nlp_type
&= ~(NLP_FCP_TARGET
| NLP_FCP_INITIATOR
);
606 ndlp
->nlp_fcp_info
&= ~NLP_FCP_2_DEVICE
;
607 if (npr
->prliType
== PRLI_FCP_TYPE
) {
608 if (npr
->initiatorFunc
)
609 ndlp
->nlp_type
|= NLP_FCP_INITIATOR
;
611 ndlp
->nlp_type
|= NLP_FCP_TARGET
;
613 ndlp
->nlp_fcp_info
|= NLP_FCP_2_DEVICE
;
616 /* We need to update the rport role values */
617 roles
= FC_RPORT_ROLE_UNKNOWN
;
618 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
619 roles
|= FC_RPORT_ROLE_FCP_INITIATOR
;
620 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
621 roles
|= FC_RPORT_ROLE_FCP_TARGET
;
623 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_RPORT
,
624 "rport rolechg: role:x%x did:x%x flg:x%x",
625 roles
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
627 fc_remote_port_rolechg(rport
, roles
);
632 lpfc_disc_set_adisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
)
634 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
636 if (!ndlp
->nlp_rpi
) {
637 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
641 /* Check config parameter use-adisc or FCP-2 */
642 if ((vport
->cfg_use_adisc
&& (vport
->fc_flag
& FC_RSCN_MODE
)) ||
643 ndlp
->nlp_fcp_info
& NLP_FCP_2_DEVICE
) {
644 spin_lock_irq(shost
->host_lock
);
645 ndlp
->nlp_flag
|= NLP_NPR_ADISC
;
646 spin_unlock_irq(shost
->host_lock
);
649 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
650 lpfc_unreg_rpi(vport
, ndlp
);
655 lpfc_disc_illegal(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
656 void *arg
, uint32_t evt
)
658 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
659 "0253 Illegal State Transition: node x%x "
660 "event x%x, state x%x Data: x%x x%x\n",
661 ndlp
->nlp_DID
, evt
, ndlp
->nlp_state
, ndlp
->nlp_rpi
,
663 return ndlp
->nlp_state
;
667 lpfc_cmpl_plogi_illegal(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
668 void *arg
, uint32_t evt
)
670 /* This transition is only legal if we previously
671 * rcv'ed a PLOGI. Since we don't want 2 discovery threads
672 * working on the same NPortID, do nothing for this thread
675 if (!(ndlp
->nlp_flag
& NLP_RCV_PLOGI
)) {
676 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
677 "0253 Illegal State Transition: node x%x "
678 "event x%x, state x%x Data: x%x x%x\n",
679 ndlp
->nlp_DID
, evt
, ndlp
->nlp_state
, ndlp
->nlp_rpi
,
682 return ndlp
->nlp_state
;
685 /* Start of Discovery State Machine routines */
688 lpfc_rcv_plogi_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
689 void *arg
, uint32_t evt
)
691 struct lpfc_iocbq
*cmdiocb
;
693 cmdiocb
= (struct lpfc_iocbq
*) arg
;
695 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
696 return ndlp
->nlp_state
;
698 return NLP_STE_FREED_NODE
;
702 lpfc_rcv_els_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
703 void *arg
, uint32_t evt
)
705 lpfc_issue_els_logo(vport
, ndlp
, 0);
706 return ndlp
->nlp_state
;
710 lpfc_rcv_logo_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
711 void *arg
, uint32_t evt
)
713 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
714 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
716 spin_lock_irq(shost
->host_lock
);
717 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
718 spin_unlock_irq(shost
->host_lock
);
719 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
721 return ndlp
->nlp_state
;
725 lpfc_cmpl_logo_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
726 void *arg
, uint32_t evt
)
728 return NLP_STE_FREED_NODE
;
732 lpfc_device_rm_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
733 void *arg
, uint32_t evt
)
735 return NLP_STE_FREED_NODE
;
739 lpfc_rcv_plogi_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
740 void *arg
, uint32_t evt
)
742 struct lpfc_hba
*phba
= vport
->phba
;
743 struct lpfc_iocbq
*cmdiocb
= arg
;
744 struct lpfc_dmabuf
*pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
745 uint32_t *lp
= (uint32_t *) pcmd
->virt
;
746 struct serv_parm
*sp
= (struct serv_parm
*) (lp
+ 1);
750 memset(&stat
, 0, sizeof (struct ls_rjt
));
752 /* For a PLOGI, we only accept if our portname is less
753 * than the remote portname.
755 phba
->fc_stat
.elsLogiCol
++;
756 port_cmp
= memcmp(&vport
->fc_portname
, &sp
->portName
,
757 sizeof(struct lpfc_name
));
760 /* Reject this request because the remote node will accept
762 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
763 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_CMD_IN_PROGRESS
;
764 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
767 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
768 } /* If our portname was less */
770 return ndlp
->nlp_state
;
774 lpfc_rcv_prli_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
775 void *arg
, uint32_t evt
)
777 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
780 memset(&stat
, 0, sizeof (struct ls_rjt
));
781 stat
.un
.b
.lsRjtRsnCode
= LSRJT_LOGICAL_BSY
;
782 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
783 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
784 return ndlp
->nlp_state
;
788 lpfc_rcv_logo_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
789 void *arg
, uint32_t evt
)
791 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
793 /* software abort outstanding PLOGI */
794 lpfc_els_abort(vport
->phba
, ndlp
);
796 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
797 return ndlp
->nlp_state
;
801 lpfc_rcv_els_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
802 void *arg
, uint32_t evt
)
804 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
805 struct lpfc_hba
*phba
= vport
->phba
;
806 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
808 /* software abort outstanding PLOGI */
809 lpfc_els_abort(phba
, ndlp
);
811 if (evt
== NLP_EVT_RCV_LOGO
) {
812 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
814 lpfc_issue_els_logo(vport
, ndlp
, 0);
817 /* Put ndlp in npr state set plogi timer for 1 sec */
818 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
819 spin_lock_irq(shost
->host_lock
);
820 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
821 spin_unlock_irq(shost
->host_lock
);
822 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
823 ndlp
->nlp_prev_state
= NLP_STE_PLOGI_ISSUE
;
824 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
826 return ndlp
->nlp_state
;
830 lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport
*vport
,
831 struct lpfc_nodelist
*ndlp
,
835 struct lpfc_hba
*phba
= vport
->phba
;
836 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
837 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
838 struct lpfc_dmabuf
*pcmd
, *prsp
, *mp
;
841 struct serv_parm
*sp
;
844 cmdiocb
= (struct lpfc_iocbq
*) arg
;
845 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
847 if (ndlp
->nlp_flag
& NLP_ACC_REGLOGIN
) {
848 /* Recovery from PLOGI collision logic */
849 return ndlp
->nlp_state
;
852 irsp
= &rspiocb
->iocb
;
857 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
859 prsp
= list_get_first(&pcmd
->list
, struct lpfc_dmabuf
, list
);
861 lp
= (uint32_t *) prsp
->virt
;
862 sp
= (struct serv_parm
*) ((uint8_t *) lp
+ sizeof (uint32_t));
863 if (wwn_to_u64(sp
->portName
.u
.wwn
) == 0 ||
864 wwn_to_u64(sp
->nodeName
.u
.wwn
) == 0) {
865 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
866 "0142 PLOGI RSP: Invalid WWN.\n");
869 if (!lpfc_check_sparm(vport
, ndlp
, sp
, CLASS3
))
871 /* PLOGI chkparm OK */
872 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
873 "0121 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
874 ndlp
->nlp_DID
, ndlp
->nlp_state
,
875 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
876 if (vport
->cfg_fcp_class
== 2 && (sp
->cls2
.classValid
))
877 ndlp
->nlp_fcp_info
|= CLASS2
;
879 ndlp
->nlp_fcp_info
|= CLASS3
;
881 ndlp
->nlp_class_sup
= 0;
882 if (sp
->cls1
.classValid
)
883 ndlp
->nlp_class_sup
|= FC_COS_CLASS1
;
884 if (sp
->cls2
.classValid
)
885 ndlp
->nlp_class_sup
|= FC_COS_CLASS2
;
886 if (sp
->cls3
.classValid
)
887 ndlp
->nlp_class_sup
|= FC_COS_CLASS3
;
888 if (sp
->cls4
.classValid
)
889 ndlp
->nlp_class_sup
|= FC_COS_CLASS4
;
891 ((sp
->cmn
.bbRcvSizeMsb
& 0x0F) << 8) | sp
->cmn
.bbRcvSizeLsb
;
893 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
895 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
896 "0133 PLOGI: no memory for reg_login "
897 "Data: x%x x%x x%x x%x\n",
898 ndlp
->nlp_DID
, ndlp
->nlp_state
,
899 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
903 lpfc_unreg_rpi(vport
, ndlp
);
905 if (lpfc_reg_login(phba
, vport
->vpi
, irsp
->un
.elsreq64
.remoteID
,
906 (uint8_t *) sp
, mbox
, 0) == 0) {
907 switch (ndlp
->nlp_DID
) {
909 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_ns_reg_login
;
912 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_fdmi_reg_login
;
915 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_reg_login
;
917 mbox
->context2
= lpfc_nlp_get(ndlp
);
919 if (lpfc_sli_issue_mbox(phba
, mbox
, MBX_NOWAIT
)
920 != MBX_NOT_FINISHED
) {
921 lpfc_nlp_set_state(vport
, ndlp
,
922 NLP_STE_REG_LOGIN_ISSUE
);
923 return ndlp
->nlp_state
;
925 /* decrement node reference count to the failed mbox
929 mp
= (struct lpfc_dmabuf
*) mbox
->context1
;
930 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
932 mempool_free(mbox
, phba
->mbox_mem_pool
);
934 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
935 "0134 PLOGI: cannot issue reg_login "
936 "Data: x%x x%x x%x x%x\n",
937 ndlp
->nlp_DID
, ndlp
->nlp_state
,
938 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
940 mempool_free(mbox
, phba
->mbox_mem_pool
);
942 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
943 "0135 PLOGI: cannot format reg_login "
944 "Data: x%x x%x x%x x%x\n",
945 ndlp
->nlp_DID
, ndlp
->nlp_state
,
946 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
951 if (ndlp
->nlp_DID
== NameServer_DID
) {
952 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
953 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
954 "0261 Cannot Register NameServer login\n");
957 spin_lock_irq(shost
->host_lock
);
958 ndlp
->nlp_flag
|= NLP_DEFER_RM
;
959 spin_unlock_irq(shost
->host_lock
);
960 return NLP_STE_FREED_NODE
;
964 lpfc_cmpl_logo_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
965 void *arg
, uint32_t evt
)
967 return ndlp
->nlp_state
;
971 lpfc_cmpl_reglogin_plogi_issue(struct lpfc_vport
*vport
,
972 struct lpfc_nodelist
*ndlp
, void *arg
, uint32_t evt
)
974 return ndlp
->nlp_state
;
978 lpfc_device_rm_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
979 void *arg
, uint32_t evt
)
981 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
983 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
984 spin_lock_irq(shost
->host_lock
);
985 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
986 spin_unlock_irq(shost
->host_lock
);
987 return ndlp
->nlp_state
;
989 /* software abort outstanding PLOGI */
990 lpfc_els_abort(vport
->phba
, ndlp
);
992 lpfc_drop_node(vport
, ndlp
);
993 return NLP_STE_FREED_NODE
;
998 lpfc_device_recov_plogi_issue(struct lpfc_vport
*vport
,
999 struct lpfc_nodelist
*ndlp
,
1003 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1004 struct lpfc_hba
*phba
= vport
->phba
;
1006 /* Don't do anything that will mess up processing of the
1009 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1010 return ndlp
->nlp_state
;
1012 /* software abort outstanding PLOGI */
1013 lpfc_els_abort(phba
, ndlp
);
1015 ndlp
->nlp_prev_state
= NLP_STE_PLOGI_ISSUE
;
1016 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1017 spin_lock_irq(shost
->host_lock
);
1018 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1019 spin_unlock_irq(shost
->host_lock
);
1021 return ndlp
->nlp_state
;
1025 lpfc_rcv_plogi_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1026 void *arg
, uint32_t evt
)
1028 struct lpfc_hba
*phba
= vport
->phba
;
1029 struct lpfc_iocbq
*cmdiocb
;
1031 /* software abort outstanding ADISC */
1032 lpfc_els_abort(phba
, ndlp
);
1034 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1036 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
))
1037 return ndlp
->nlp_state
;
1039 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1040 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1041 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1043 return ndlp
->nlp_state
;
1047 lpfc_rcv_prli_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1048 void *arg
, uint32_t evt
)
1050 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1052 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1053 return ndlp
->nlp_state
;
1057 lpfc_rcv_logo_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1058 void *arg
, uint32_t evt
)
1060 struct lpfc_hba
*phba
= vport
->phba
;
1061 struct lpfc_iocbq
*cmdiocb
;
1063 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1065 /* software abort outstanding ADISC */
1066 lpfc_els_abort(phba
, ndlp
);
1068 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1069 return ndlp
->nlp_state
;
1073 lpfc_rcv_padisc_adisc_issue(struct lpfc_vport
*vport
,
1074 struct lpfc_nodelist
*ndlp
,
1075 void *arg
, uint32_t evt
)
1077 struct lpfc_iocbq
*cmdiocb
;
1079 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1081 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1082 return ndlp
->nlp_state
;
1086 lpfc_rcv_prlo_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1087 void *arg
, uint32_t evt
)
1089 struct lpfc_iocbq
*cmdiocb
;
1091 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1093 /* Treat like rcv logo */
1094 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_PRLO
);
1095 return ndlp
->nlp_state
;
1099 lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport
*vport
,
1100 struct lpfc_nodelist
*ndlp
,
1101 void *arg
, uint32_t evt
)
1103 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1104 struct lpfc_hba
*phba
= vport
->phba
;
1105 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1109 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1110 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1112 ap
= (ADISC
*)lpfc_check_elscmpl_iocb(phba
, cmdiocb
, rspiocb
);
1113 irsp
= &rspiocb
->iocb
;
1115 if ((irsp
->ulpStatus
) ||
1116 (!lpfc_check_adisc(vport
, ndlp
, &ap
->nodeName
, &ap
->portName
))) {
1118 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
);
1119 spin_lock_irq(shost
->host_lock
);
1120 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1121 spin_unlock_irq(shost
->host_lock
);
1122 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1124 memset(&ndlp
->nlp_nodename
, 0, sizeof(struct lpfc_name
));
1125 memset(&ndlp
->nlp_portname
, 0, sizeof(struct lpfc_name
));
1127 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1128 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1129 lpfc_unreg_rpi(vport
, ndlp
);
1130 return ndlp
->nlp_state
;
1133 if (ndlp
->nlp_type
& NLP_FCP_TARGET
) {
1134 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1135 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_MAPPED_NODE
);
1137 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1138 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1140 return ndlp
->nlp_state
;
1144 lpfc_device_rm_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1145 void *arg
, uint32_t evt
)
1147 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1149 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1150 spin_lock_irq(shost
->host_lock
);
1151 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1152 spin_unlock_irq(shost
->host_lock
);
1153 return ndlp
->nlp_state
;
1155 /* software abort outstanding ADISC */
1156 lpfc_els_abort(vport
->phba
, ndlp
);
1158 lpfc_drop_node(vport
, ndlp
);
1159 return NLP_STE_FREED_NODE
;
1164 lpfc_device_recov_adisc_issue(struct lpfc_vport
*vport
,
1165 struct lpfc_nodelist
*ndlp
,
1169 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1170 struct lpfc_hba
*phba
= vport
->phba
;
1172 /* Don't do anything that will mess up processing of the
1175 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1176 return ndlp
->nlp_state
;
1178 /* software abort outstanding ADISC */
1179 lpfc_els_abort(phba
, ndlp
);
1181 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1182 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1183 spin_lock_irq(shost
->host_lock
);
1184 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1185 spin_unlock_irq(shost
->host_lock
);
1186 lpfc_disc_set_adisc(vport
, ndlp
);
1187 return ndlp
->nlp_state
;
1191 lpfc_rcv_plogi_reglogin_issue(struct lpfc_vport
*vport
,
1192 struct lpfc_nodelist
*ndlp
,
1196 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1198 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1199 return ndlp
->nlp_state
;
1203 lpfc_rcv_prli_reglogin_issue(struct lpfc_vport
*vport
,
1204 struct lpfc_nodelist
*ndlp
,
1208 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1210 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1211 return ndlp
->nlp_state
;
1215 lpfc_rcv_logo_reglogin_issue(struct lpfc_vport
*vport
,
1216 struct lpfc_nodelist
*ndlp
,
1220 struct lpfc_hba
*phba
= vport
->phba
;
1221 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1223 LPFC_MBOXQ_t
*nextmb
;
1224 struct lpfc_dmabuf
*mp
;
1226 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1228 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1229 if ((mb
= phba
->sli
.mbox_active
)) {
1230 if ((mb
->mb
.mbxCommand
== MBX_REG_LOGIN64
) &&
1231 (ndlp
== (struct lpfc_nodelist
*) mb
->context2
)) {
1233 mb
->context2
= NULL
;
1234 mb
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
1238 spin_lock_irq(&phba
->hbalock
);
1239 list_for_each_entry_safe(mb
, nextmb
, &phba
->sli
.mboxq
, list
) {
1240 if ((mb
->mb
.mbxCommand
== MBX_REG_LOGIN64
) &&
1241 (ndlp
== (struct lpfc_nodelist
*) mb
->context2
)) {
1242 mp
= (struct lpfc_dmabuf
*) (mb
->context1
);
1244 __lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1248 list_del(&mb
->list
);
1249 mempool_free(mb
, phba
->mbox_mem_pool
);
1252 spin_unlock_irq(&phba
->hbalock
);
1254 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1255 return ndlp
->nlp_state
;
1259 lpfc_rcv_padisc_reglogin_issue(struct lpfc_vport
*vport
,
1260 struct lpfc_nodelist
*ndlp
,
1264 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1266 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1267 return ndlp
->nlp_state
;
1271 lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport
*vport
,
1272 struct lpfc_nodelist
*ndlp
,
1276 struct lpfc_iocbq
*cmdiocb
;
1278 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1279 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1280 return ndlp
->nlp_state
;
1284 lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport
*vport
,
1285 struct lpfc_nodelist
*ndlp
,
1289 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1290 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
1291 MAILBOX_t
*mb
= &pmb
->mb
;
1292 uint32_t did
= mb
->un
.varWords
[1];
1294 if (mb
->mbxStatus
) {
1295 /* RegLogin failed */
1296 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
1297 "0246 RegLogin failed Data: x%x x%x x%x\n",
1298 did
, mb
->mbxStatus
, vport
->port_state
);
1300 * If RegLogin failed due to lack of HBA resources do not
1303 if (mb
->mbxStatus
== MBXERR_RPI_FULL
) {
1304 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1305 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1306 return ndlp
->nlp_state
;
1309 /* Put ndlp in npr state set plogi timer for 1 sec */
1310 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
1311 spin_lock_irq(shost
->host_lock
);
1312 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1313 spin_unlock_irq(shost
->host_lock
);
1314 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1316 lpfc_issue_els_logo(vport
, ndlp
, 0);
1317 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1318 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1319 return ndlp
->nlp_state
;
1322 ndlp
->nlp_rpi
= mb
->un
.varWords
[0];
1324 /* Only if we are not a fabric nport do we issue PRLI */
1325 if (!(ndlp
->nlp_type
& NLP_FABRIC
)) {
1326 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1327 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PRLI_ISSUE
);
1328 lpfc_issue_els_prli(vport
, ndlp
, 0);
1330 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1331 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1333 return ndlp
->nlp_state
;
1337 lpfc_device_rm_reglogin_issue(struct lpfc_vport
*vport
,
1338 struct lpfc_nodelist
*ndlp
,
1342 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1344 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1345 spin_lock_irq(shost
->host_lock
);
1346 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1347 spin_unlock_irq(shost
->host_lock
);
1348 return ndlp
->nlp_state
;
1350 lpfc_drop_node(vport
, ndlp
);
1351 return NLP_STE_FREED_NODE
;
1356 lpfc_device_recov_reglogin_issue(struct lpfc_vport
*vport
,
1357 struct lpfc_nodelist
*ndlp
,
1361 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1363 /* Don't do anything that will mess up processing of the
1366 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1367 return ndlp
->nlp_state
;
1369 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1370 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1371 spin_lock_irq(shost
->host_lock
);
1372 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1373 spin_unlock_irq(shost
->host_lock
);
1374 lpfc_disc_set_adisc(vport
, ndlp
);
1375 return ndlp
->nlp_state
;
1379 lpfc_rcv_plogi_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1380 void *arg
, uint32_t evt
)
1382 struct lpfc_iocbq
*cmdiocb
;
1384 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1386 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1387 return ndlp
->nlp_state
;
1391 lpfc_rcv_prli_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1392 void *arg
, uint32_t evt
)
1394 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1396 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1397 return ndlp
->nlp_state
;
1401 lpfc_rcv_logo_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1402 void *arg
, uint32_t evt
)
1404 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1406 /* Software abort outstanding PRLI before sending acc */
1407 lpfc_els_abort(vport
->phba
, ndlp
);
1409 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1410 return ndlp
->nlp_state
;
1414 lpfc_rcv_padisc_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1415 void *arg
, uint32_t evt
)
1417 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1419 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1420 return ndlp
->nlp_state
;
1423 /* This routine is envoked when we rcv a PRLO request from a nport
1424 * we are logged into. We should send back a PRLO rsp setting the
1426 * NEXT STATE = PRLI_ISSUE
1429 lpfc_rcv_prlo_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1430 void *arg
, uint32_t evt
)
1432 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1434 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1435 return ndlp
->nlp_state
;
1439 lpfc_cmpl_prli_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1440 void *arg
, uint32_t evt
)
1442 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1443 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1444 struct lpfc_hba
*phba
= vport
->phba
;
1448 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1449 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1450 npr
= (PRLI
*)lpfc_check_elscmpl_iocb(phba
, cmdiocb
, rspiocb
);
1452 irsp
= &rspiocb
->iocb
;
1453 if (irsp
->ulpStatus
) {
1454 if ((vport
->port_type
== LPFC_NPIV_PORT
) &&
1455 vport
->cfg_restrict_login
) {
1458 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1459 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1460 return ndlp
->nlp_state
;
1463 /* Check out PRLI rsp */
1464 ndlp
->nlp_type
&= ~(NLP_FCP_TARGET
| NLP_FCP_INITIATOR
);
1465 ndlp
->nlp_fcp_info
&= ~NLP_FCP_2_DEVICE
;
1466 if ((npr
->acceptRspCode
== PRLI_REQ_EXECUTED
) &&
1467 (npr
->prliType
== PRLI_FCP_TYPE
)) {
1468 if (npr
->initiatorFunc
)
1469 ndlp
->nlp_type
|= NLP_FCP_INITIATOR
;
1470 if (npr
->targetFunc
)
1471 ndlp
->nlp_type
|= NLP_FCP_TARGET
;
1473 ndlp
->nlp_fcp_info
|= NLP_FCP_2_DEVICE
;
1475 if (!(ndlp
->nlp_type
& NLP_FCP_TARGET
) &&
1476 (vport
->port_type
== LPFC_NPIV_PORT
) &&
1477 vport
->cfg_restrict_login
) {
1479 spin_lock_irq(shost
->host_lock
);
1480 ndlp
->nlp_flag
|= NLP_TARGET_REMOVE
;
1481 spin_unlock_irq(shost
->host_lock
);
1482 lpfc_issue_els_logo(vport
, ndlp
, 0);
1484 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1485 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1486 return ndlp
->nlp_state
;
1489 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1490 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
1491 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_MAPPED_NODE
);
1493 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1494 return ndlp
->nlp_state
;
1497 /*! lpfc_device_rm_prli_issue
1508 * This routine is envoked when we a request to remove a nport we are in the
1509 * process of PRLIing. We should software abort outstanding prli, unreg
1510 * login, send a logout. We will change node state to UNUSED_NODE, put it
1511 * on plogi list so it can be freed when LOGO completes.
1516 lpfc_device_rm_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1517 void *arg
, uint32_t evt
)
1519 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1521 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1522 spin_lock_irq(shost
->host_lock
);
1523 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1524 spin_unlock_irq(shost
->host_lock
);
1525 return ndlp
->nlp_state
;
1527 /* software abort outstanding PLOGI */
1528 lpfc_els_abort(vport
->phba
, ndlp
);
1530 lpfc_drop_node(vport
, ndlp
);
1531 return NLP_STE_FREED_NODE
;
1536 /*! lpfc_device_recov_prli_issue
1547 * The routine is envoked when the state of a device is unknown, like
1548 * during a link down. We should remove the nodelist entry from the
1549 * unmapped list, issue a UNREG_LOGIN, do a software abort of the
1550 * outstanding PRLI command, then free the node entry.
1553 lpfc_device_recov_prli_issue(struct lpfc_vport
*vport
,
1554 struct lpfc_nodelist
*ndlp
,
1558 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1559 struct lpfc_hba
*phba
= vport
->phba
;
1561 /* Don't do anything that will mess up processing of the
1564 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1565 return ndlp
->nlp_state
;
1567 /* software abort outstanding PRLI */
1568 lpfc_els_abort(phba
, ndlp
);
1570 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1571 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1572 spin_lock_irq(shost
->host_lock
);
1573 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1574 spin_unlock_irq(shost
->host_lock
);
1575 lpfc_disc_set_adisc(vport
, ndlp
);
1576 return ndlp
->nlp_state
;
1580 lpfc_rcv_plogi_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1581 void *arg
, uint32_t evt
)
1583 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1585 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1586 return ndlp
->nlp_state
;
1590 lpfc_rcv_prli_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1591 void *arg
, uint32_t evt
)
1593 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1595 lpfc_rcv_prli(vport
, ndlp
, cmdiocb
);
1596 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1597 return ndlp
->nlp_state
;
1601 lpfc_rcv_logo_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1602 void *arg
, uint32_t evt
)
1604 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1606 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1607 return ndlp
->nlp_state
;
1611 lpfc_rcv_padisc_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1612 void *arg
, uint32_t evt
)
1614 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1616 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1617 return ndlp
->nlp_state
;
1621 lpfc_rcv_prlo_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1622 void *arg
, uint32_t evt
)
1624 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1626 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1627 return ndlp
->nlp_state
;
1631 lpfc_device_recov_unmap_node(struct lpfc_vport
*vport
,
1632 struct lpfc_nodelist
*ndlp
,
1636 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1638 ndlp
->nlp_prev_state
= NLP_STE_UNMAPPED_NODE
;
1639 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1640 spin_lock_irq(shost
->host_lock
);
1641 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1642 spin_unlock_irq(shost
->host_lock
);
1643 lpfc_disc_set_adisc(vport
, ndlp
);
1645 return ndlp
->nlp_state
;
1649 lpfc_rcv_plogi_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1650 void *arg
, uint32_t evt
)
1652 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1654 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1655 return ndlp
->nlp_state
;
1659 lpfc_rcv_prli_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1660 void *arg
, uint32_t evt
)
1662 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1664 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1665 return ndlp
->nlp_state
;
1669 lpfc_rcv_logo_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1670 void *arg
, uint32_t evt
)
1672 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1674 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1675 return ndlp
->nlp_state
;
1679 lpfc_rcv_padisc_mapped_node(struct lpfc_vport
*vport
,
1680 struct lpfc_nodelist
*ndlp
,
1681 void *arg
, uint32_t evt
)
1683 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1685 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1686 return ndlp
->nlp_state
;
1690 lpfc_rcv_prlo_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1691 void *arg
, uint32_t evt
)
1693 struct lpfc_hba
*phba
= vport
->phba
;
1694 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1696 /* flush the target */
1697 lpfc_sli_abort_iocb(vport
, &phba
->sli
.ring
[phba
->sli
.fcp_ring
],
1698 ndlp
->nlp_sid
, 0, LPFC_CTX_TGT
);
1700 /* Treat like rcv logo */
1701 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_PRLO
);
1702 return ndlp
->nlp_state
;
1706 lpfc_device_recov_mapped_node(struct lpfc_vport
*vport
,
1707 struct lpfc_nodelist
*ndlp
,
1711 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1713 ndlp
->nlp_prev_state
= NLP_STE_MAPPED_NODE
;
1714 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1715 spin_lock_irq(shost
->host_lock
);
1716 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1717 spin_unlock_irq(shost
->host_lock
);
1718 lpfc_disc_set_adisc(vport
, ndlp
);
1719 return ndlp
->nlp_state
;
1723 lpfc_rcv_plogi_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1724 void *arg
, uint32_t evt
)
1726 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1727 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1729 /* Ignore PLOGI if we have an outstanding LOGO */
1730 if (ndlp
->nlp_flag
& (NLP_LOGO_SND
| NLP_LOGO_ACC
)) {
1731 return ndlp
->nlp_state
;
1734 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
1735 spin_lock_irq(shost
->host_lock
);
1736 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1737 spin_unlock_irq(shost
->host_lock
);
1738 return ndlp
->nlp_state
;
1741 /* send PLOGI immediately, move to PLOGI issue state */
1742 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
)) {
1743 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1744 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1745 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1748 return ndlp
->nlp_state
;
1752 lpfc_rcv_prli_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1753 void *arg
, uint32_t evt
)
1755 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1756 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1759 memset(&stat
, 0, sizeof (struct ls_rjt
));
1760 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
1761 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
1762 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
1764 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
)) {
1765 if (ndlp
->nlp_flag
& NLP_NPR_ADISC
) {
1766 spin_lock_irq(shost
->host_lock
);
1767 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1768 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1769 spin_unlock_irq(shost
->host_lock
);
1770 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_ADISC_ISSUE
);
1771 lpfc_issue_els_adisc(vport
, ndlp
, 0);
1773 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1774 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1775 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1778 return ndlp
->nlp_state
;
1782 lpfc_rcv_logo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1783 void *arg
, uint32_t evt
)
1785 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1787 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1788 return ndlp
->nlp_state
;
1792 lpfc_rcv_padisc_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1793 void *arg
, uint32_t evt
)
1795 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1797 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1800 * Do not start discovery if discovery is about to start
1801 * or discovery in progress for this node. Starting discovery
1802 * here will affect the counting of discovery threads.
1804 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
) &&
1805 !(ndlp
->nlp_flag
& NLP_NPR_2B_DISC
)) {
1806 if (ndlp
->nlp_flag
& NLP_NPR_ADISC
) {
1807 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1808 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1809 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_ADISC_ISSUE
);
1810 lpfc_issue_els_adisc(vport
, ndlp
, 0);
1812 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1813 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1814 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1817 return ndlp
->nlp_state
;
1821 lpfc_rcv_prlo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1822 void *arg
, uint32_t evt
)
1824 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1825 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1827 spin_lock_irq(shost
->host_lock
);
1828 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
1829 spin_unlock_irq(shost
->host_lock
);
1831 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
1833 if ((ndlp
->nlp_flag
& NLP_DELAY_TMO
) == 0) {
1834 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
1835 spin_lock_irq(shost
->host_lock
);
1836 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1837 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1838 spin_unlock_irq(shost
->host_lock
);
1839 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1841 spin_lock_irq(shost
->host_lock
);
1842 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1843 spin_unlock_irq(shost
->host_lock
);
1845 return ndlp
->nlp_state
;
1849 lpfc_cmpl_plogi_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1850 void *arg
, uint32_t evt
)
1852 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1855 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1856 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1858 irsp
= &rspiocb
->iocb
;
1859 if (irsp
->ulpStatus
) {
1860 ndlp
->nlp_flag
|= NLP_DEFER_RM
;
1861 return NLP_STE_FREED_NODE
;
1863 return ndlp
->nlp_state
;
1867 lpfc_cmpl_prli_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1868 void *arg
, uint32_t evt
)
1870 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1873 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1874 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1876 irsp
= &rspiocb
->iocb
;
1877 if (irsp
->ulpStatus
&& (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
)) {
1878 lpfc_drop_node(vport
, ndlp
);
1879 return NLP_STE_FREED_NODE
;
1881 return ndlp
->nlp_state
;
1885 lpfc_cmpl_logo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1886 void *arg
, uint32_t evt
)
1888 lpfc_unreg_rpi(vport
, ndlp
);
1889 /* This routine does nothing, just return the current state */
1890 return ndlp
->nlp_state
;
1894 lpfc_cmpl_adisc_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1895 void *arg
, uint32_t evt
)
1897 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1900 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1901 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1903 irsp
= &rspiocb
->iocb
;
1904 if (irsp
->ulpStatus
&& (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
)) {
1905 lpfc_drop_node(vport
, ndlp
);
1906 return NLP_STE_FREED_NODE
;
1908 return ndlp
->nlp_state
;
1912 lpfc_cmpl_reglogin_npr_node(struct lpfc_vport
*vport
,
1913 struct lpfc_nodelist
*ndlp
,
1914 void *arg
, uint32_t evt
)
1916 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
1917 MAILBOX_t
*mb
= &pmb
->mb
;
1920 ndlp
->nlp_rpi
= mb
->un
.varWords
[0];
1922 if (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
) {
1923 lpfc_drop_node(vport
, ndlp
);
1924 return NLP_STE_FREED_NODE
;
1927 return ndlp
->nlp_state
;
1931 lpfc_device_rm_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1932 void *arg
, uint32_t evt
)
1934 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1936 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1937 spin_lock_irq(shost
->host_lock
);
1938 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1939 spin_unlock_irq(shost
->host_lock
);
1940 return ndlp
->nlp_state
;
1942 lpfc_drop_node(vport
, ndlp
);
1943 return NLP_STE_FREED_NODE
;
1947 lpfc_device_recov_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1948 void *arg
, uint32_t evt
)
1950 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1952 /* Don't do anything that will mess up processing of the
1955 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1956 return ndlp
->nlp_state
;
1958 spin_lock_irq(shost
->host_lock
);
1959 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1960 spin_unlock_irq(shost
->host_lock
);
1961 if (ndlp
->nlp_flag
& NLP_DELAY_TMO
) {
1962 lpfc_cancel_retry_delay_tmo(vport
, ndlp
);
1964 return ndlp
->nlp_state
;
1968 /* This next section defines the NPort Discovery State Machine */
1970 /* There are 4 different double linked lists nodelist entries can reside on.
1971 * The plogi list and adisc list are used when Link Up discovery or RSCN
1972 * processing is needed. Each list holds the nodes that we will send PLOGI
1973 * or ADISC on. These lists will keep track of what nodes will be effected
1974 * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
1975 * The unmapped_list will contain all nodes that we have successfully logged
1976 * into at the Fibre Channel level. The mapped_list will contain all nodes
1977 * that are mapped FCP targets.
1980 * The bind list is a list of undiscovered (potentially non-existent) nodes
1981 * that we have saved binding information on. This information is used when
1982 * nodes transition from the unmapped to the mapped list.
1984 /* For UNUSED_NODE state, the node has just been allocated .
1985 * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
1986 * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
1987 * and put on the unmapped list. For ADISC processing, the node is taken off
1988 * the ADISC list and placed on either the mapped or unmapped list (depending
1989 * on its previous state). Once on the unmapped list, a PRLI is issued and the
1990 * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
1991 * changed to UNMAPPED_NODE. If the completion indicates a mapped
1992 * node, the node is taken off the unmapped list. The binding list is checked
1993 * for a valid binding, or a binding is automatically assigned. If binding
1994 * assignment is unsuccessful, the node is left on the unmapped list. If
1995 * binding assignment is successful, the associated binding list entry (if
1996 * any) is removed, and the node is placed on the mapped list.
1999 * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
2000 * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
2001 * expire, all effected nodes will receive a DEVICE_RM event.
2004 * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
2005 * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
2006 * check, additional nodes may be added or removed (via DEVICE_RM) to / from
2007 * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
2008 * we will first process the ADISC list. 32 entries are processed initially and
2009 * ADISC is initited for each one. Completions / Events for each node are
2010 * funnelled thru the state machine. As each node finishes ADISC processing, it
2011 * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
2012 * waiting, and the ADISC list count is identically 0, then we are done. For
2013 * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
2014 * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
2015 * list. 32 entries are processed initially and PLOGI is initited for each one.
2016 * Completions / Events for each node are funnelled thru the state machine. As
2017 * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
2018 * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
2019 * indentically 0, then we are done. We have now completed discovery / RSCN
2020 * handling. Upon completion, ALL nodes should be on either the mapped or
2024 static uint32_t (*lpfc_disc_action
[NLP_STE_MAX_STATE
* NLP_EVT_MAX_EVENT
])
2025 (struct lpfc_vport
*, struct lpfc_nodelist
*, void *, uint32_t) = {
2026 /* Action routine Event Current State */
2027 lpfc_rcv_plogi_unused_node
, /* RCV_PLOGI UNUSED_NODE */
2028 lpfc_rcv_els_unused_node
, /* RCV_PRLI */
2029 lpfc_rcv_logo_unused_node
, /* RCV_LOGO */
2030 lpfc_rcv_els_unused_node
, /* RCV_ADISC */
2031 lpfc_rcv_els_unused_node
, /* RCV_PDISC */
2032 lpfc_rcv_els_unused_node
, /* RCV_PRLO */
2033 lpfc_disc_illegal
, /* CMPL_PLOGI */
2034 lpfc_disc_illegal
, /* CMPL_PRLI */
2035 lpfc_cmpl_logo_unused_node
, /* CMPL_LOGO */
2036 lpfc_disc_illegal
, /* CMPL_ADISC */
2037 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2038 lpfc_device_rm_unused_node
, /* DEVICE_RM */
2039 lpfc_disc_illegal
, /* DEVICE_RECOVERY */
2041 lpfc_rcv_plogi_plogi_issue
, /* RCV_PLOGI PLOGI_ISSUE */
2042 lpfc_rcv_prli_plogi_issue
, /* RCV_PRLI */
2043 lpfc_rcv_logo_plogi_issue
, /* RCV_LOGO */
2044 lpfc_rcv_els_plogi_issue
, /* RCV_ADISC */
2045 lpfc_rcv_els_plogi_issue
, /* RCV_PDISC */
2046 lpfc_rcv_els_plogi_issue
, /* RCV_PRLO */
2047 lpfc_cmpl_plogi_plogi_issue
, /* CMPL_PLOGI */
2048 lpfc_disc_illegal
, /* CMPL_PRLI */
2049 lpfc_cmpl_logo_plogi_issue
, /* CMPL_LOGO */
2050 lpfc_disc_illegal
, /* CMPL_ADISC */
2051 lpfc_cmpl_reglogin_plogi_issue
,/* CMPL_REG_LOGIN */
2052 lpfc_device_rm_plogi_issue
, /* DEVICE_RM */
2053 lpfc_device_recov_plogi_issue
, /* DEVICE_RECOVERY */
2055 lpfc_rcv_plogi_adisc_issue
, /* RCV_PLOGI ADISC_ISSUE */
2056 lpfc_rcv_prli_adisc_issue
, /* RCV_PRLI */
2057 lpfc_rcv_logo_adisc_issue
, /* RCV_LOGO */
2058 lpfc_rcv_padisc_adisc_issue
, /* RCV_ADISC */
2059 lpfc_rcv_padisc_adisc_issue
, /* RCV_PDISC */
2060 lpfc_rcv_prlo_adisc_issue
, /* RCV_PRLO */
2061 lpfc_disc_illegal
, /* CMPL_PLOGI */
2062 lpfc_disc_illegal
, /* CMPL_PRLI */
2063 lpfc_disc_illegal
, /* CMPL_LOGO */
2064 lpfc_cmpl_adisc_adisc_issue
, /* CMPL_ADISC */
2065 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2066 lpfc_device_rm_adisc_issue
, /* DEVICE_RM */
2067 lpfc_device_recov_adisc_issue
, /* DEVICE_RECOVERY */
2069 lpfc_rcv_plogi_reglogin_issue
, /* RCV_PLOGI REG_LOGIN_ISSUE */
2070 lpfc_rcv_prli_reglogin_issue
, /* RCV_PLOGI */
2071 lpfc_rcv_logo_reglogin_issue
, /* RCV_LOGO */
2072 lpfc_rcv_padisc_reglogin_issue
, /* RCV_ADISC */
2073 lpfc_rcv_padisc_reglogin_issue
, /* RCV_PDISC */
2074 lpfc_rcv_prlo_reglogin_issue
, /* RCV_PRLO */
2075 lpfc_cmpl_plogi_illegal
, /* CMPL_PLOGI */
2076 lpfc_disc_illegal
, /* CMPL_PRLI */
2077 lpfc_disc_illegal
, /* CMPL_LOGO */
2078 lpfc_disc_illegal
, /* CMPL_ADISC */
2079 lpfc_cmpl_reglogin_reglogin_issue
,/* CMPL_REG_LOGIN */
2080 lpfc_device_rm_reglogin_issue
, /* DEVICE_RM */
2081 lpfc_device_recov_reglogin_issue
,/* DEVICE_RECOVERY */
2083 lpfc_rcv_plogi_prli_issue
, /* RCV_PLOGI PRLI_ISSUE */
2084 lpfc_rcv_prli_prli_issue
, /* RCV_PRLI */
2085 lpfc_rcv_logo_prli_issue
, /* RCV_LOGO */
2086 lpfc_rcv_padisc_prli_issue
, /* RCV_ADISC */
2087 lpfc_rcv_padisc_prli_issue
, /* RCV_PDISC */
2088 lpfc_rcv_prlo_prli_issue
, /* RCV_PRLO */
2089 lpfc_cmpl_plogi_illegal
, /* CMPL_PLOGI */
2090 lpfc_cmpl_prli_prli_issue
, /* CMPL_PRLI */
2091 lpfc_disc_illegal
, /* CMPL_LOGO */
2092 lpfc_disc_illegal
, /* CMPL_ADISC */
2093 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2094 lpfc_device_rm_prli_issue
, /* DEVICE_RM */
2095 lpfc_device_recov_prli_issue
, /* DEVICE_RECOVERY */
2097 lpfc_rcv_plogi_unmap_node
, /* RCV_PLOGI UNMAPPED_NODE */
2098 lpfc_rcv_prli_unmap_node
, /* RCV_PRLI */
2099 lpfc_rcv_logo_unmap_node
, /* RCV_LOGO */
2100 lpfc_rcv_padisc_unmap_node
, /* RCV_ADISC */
2101 lpfc_rcv_padisc_unmap_node
, /* RCV_PDISC */
2102 lpfc_rcv_prlo_unmap_node
, /* RCV_PRLO */
2103 lpfc_disc_illegal
, /* CMPL_PLOGI */
2104 lpfc_disc_illegal
, /* CMPL_PRLI */
2105 lpfc_disc_illegal
, /* CMPL_LOGO */
2106 lpfc_disc_illegal
, /* CMPL_ADISC */
2107 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2108 lpfc_disc_illegal
, /* DEVICE_RM */
2109 lpfc_device_recov_unmap_node
, /* DEVICE_RECOVERY */
2111 lpfc_rcv_plogi_mapped_node
, /* RCV_PLOGI MAPPED_NODE */
2112 lpfc_rcv_prli_mapped_node
, /* RCV_PRLI */
2113 lpfc_rcv_logo_mapped_node
, /* RCV_LOGO */
2114 lpfc_rcv_padisc_mapped_node
, /* RCV_ADISC */
2115 lpfc_rcv_padisc_mapped_node
, /* RCV_PDISC */
2116 lpfc_rcv_prlo_mapped_node
, /* RCV_PRLO */
2117 lpfc_disc_illegal
, /* CMPL_PLOGI */
2118 lpfc_disc_illegal
, /* CMPL_PRLI */
2119 lpfc_disc_illegal
, /* CMPL_LOGO */
2120 lpfc_disc_illegal
, /* CMPL_ADISC */
2121 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2122 lpfc_disc_illegal
, /* DEVICE_RM */
2123 lpfc_device_recov_mapped_node
, /* DEVICE_RECOVERY */
2125 lpfc_rcv_plogi_npr_node
, /* RCV_PLOGI NPR_NODE */
2126 lpfc_rcv_prli_npr_node
, /* RCV_PRLI */
2127 lpfc_rcv_logo_npr_node
, /* RCV_LOGO */
2128 lpfc_rcv_padisc_npr_node
, /* RCV_ADISC */
2129 lpfc_rcv_padisc_npr_node
, /* RCV_PDISC */
2130 lpfc_rcv_prlo_npr_node
, /* RCV_PRLO */
2131 lpfc_cmpl_plogi_npr_node
, /* CMPL_PLOGI */
2132 lpfc_cmpl_prli_npr_node
, /* CMPL_PRLI */
2133 lpfc_cmpl_logo_npr_node
, /* CMPL_LOGO */
2134 lpfc_cmpl_adisc_npr_node
, /* CMPL_ADISC */
2135 lpfc_cmpl_reglogin_npr_node
, /* CMPL_REG_LOGIN */
2136 lpfc_device_rm_npr_node
, /* DEVICE_RM */
2137 lpfc_device_recov_npr_node
, /* DEVICE_RECOVERY */
2141 lpfc_disc_state_machine(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2142 void *arg
, uint32_t evt
)
2144 uint32_t cur_state
, rc
;
2145 uint32_t(*func
) (struct lpfc_vport
*, struct lpfc_nodelist
*, void *,
2149 cur_state
= ndlp
->nlp_state
;
2151 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
2152 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2153 "0211 DSM in event x%x on NPort x%x in "
2154 "state %d Data: x%x\n",
2155 evt
, ndlp
->nlp_DID
, cur_state
, ndlp
->nlp_flag
);
2157 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2158 "DSM in: evt:%d ste:%d did:x%x",
2159 evt
, cur_state
, ndlp
->nlp_DID
);
2161 func
= lpfc_disc_action
[(cur_state
* NLP_EVT_MAX_EVENT
) + evt
];
2162 rc
= (func
) (vport
, ndlp
, arg
, evt
);
2164 /* DSM out state <rc> on NPort <nlp_DID> */
2165 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2166 "0212 DSM out state %d on NPort x%x Data: x%x\n",
2167 rc
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
2169 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2170 "DSM out: ste:%d did:x%x flg:x%x",
2171 rc
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);