1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2008 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>
34 #include "lpfc_sli4.h"
36 #include "lpfc_disc.h"
37 #include "lpfc_scsi.h"
39 #include "lpfc_logmsg.h"
40 #include "lpfc_crtn.h"
41 #include "lpfc_vport.h"
42 #include "lpfc_debugfs.h"
45 /* Called to verify a rcv'ed ADISC was intended for us. */
47 lpfc_check_adisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
48 struct lpfc_name
*nn
, struct lpfc_name
*pn
)
50 /* Compare the ADISC rsp WWNN / WWPN matches our internal node
51 * table entry for that node.
53 if (memcmp(nn
, &ndlp
->nlp_nodename
, sizeof (struct lpfc_name
)))
56 if (memcmp(pn
, &ndlp
->nlp_portname
, sizeof (struct lpfc_name
)))
59 /* we match, return success */
64 lpfc_check_sparm(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
65 struct serv_parm
* sp
, uint32_t class)
67 volatile struct serv_parm
*hsp
= &vport
->fc_sparam
;
68 uint16_t hsp_value
, ssp_value
= 0;
71 * The receive data field size and buffer-to-buffer receive data field
72 * size entries are 16 bits but are represented as two 8-bit fields in
73 * the driver data structure to account for rsvd bits and other control
74 * bits. Reconstruct and compare the fields as a 16-bit values before
75 * correcting the byte values.
77 if (sp
->cls1
.classValid
) {
78 hsp_value
= (hsp
->cls1
.rcvDataSizeMsb
<< 8) |
79 hsp
->cls1
.rcvDataSizeLsb
;
80 ssp_value
= (sp
->cls1
.rcvDataSizeMsb
<< 8) |
81 sp
->cls1
.rcvDataSizeLsb
;
83 goto bad_service_param
;
84 if (ssp_value
> hsp_value
) {
85 sp
->cls1
.rcvDataSizeLsb
= hsp
->cls1
.rcvDataSizeLsb
;
86 sp
->cls1
.rcvDataSizeMsb
= hsp
->cls1
.rcvDataSizeMsb
;
88 } else if (class == CLASS1
) {
89 goto bad_service_param
;
92 if (sp
->cls2
.classValid
) {
93 hsp_value
= (hsp
->cls2
.rcvDataSizeMsb
<< 8) |
94 hsp
->cls2
.rcvDataSizeLsb
;
95 ssp_value
= (sp
->cls2
.rcvDataSizeMsb
<< 8) |
96 sp
->cls2
.rcvDataSizeLsb
;
98 goto bad_service_param
;
99 if (ssp_value
> hsp_value
) {
100 sp
->cls2
.rcvDataSizeLsb
= hsp
->cls2
.rcvDataSizeLsb
;
101 sp
->cls2
.rcvDataSizeMsb
= hsp
->cls2
.rcvDataSizeMsb
;
103 } else if (class == CLASS2
) {
104 goto bad_service_param
;
107 if (sp
->cls3
.classValid
) {
108 hsp_value
= (hsp
->cls3
.rcvDataSizeMsb
<< 8) |
109 hsp
->cls3
.rcvDataSizeLsb
;
110 ssp_value
= (sp
->cls3
.rcvDataSizeMsb
<< 8) |
111 sp
->cls3
.rcvDataSizeLsb
;
113 goto bad_service_param
;
114 if (ssp_value
> hsp_value
) {
115 sp
->cls3
.rcvDataSizeLsb
= hsp
->cls3
.rcvDataSizeLsb
;
116 sp
->cls3
.rcvDataSizeMsb
= hsp
->cls3
.rcvDataSizeMsb
;
118 } else if (class == CLASS3
) {
119 goto bad_service_param
;
123 * Preserve the upper four bits of the MSB from the PLOGI response.
124 * These bits contain the Buffer-to-Buffer State Change Number
125 * from the target and need to be passed to the FW.
127 hsp_value
= (hsp
->cmn
.bbRcvSizeMsb
<< 8) | hsp
->cmn
.bbRcvSizeLsb
;
128 ssp_value
= (sp
->cmn
.bbRcvSizeMsb
<< 8) | sp
->cmn
.bbRcvSizeLsb
;
129 if (ssp_value
> hsp_value
) {
130 sp
->cmn
.bbRcvSizeLsb
= hsp
->cmn
.bbRcvSizeLsb
;
131 sp
->cmn
.bbRcvSizeMsb
= (sp
->cmn
.bbRcvSizeMsb
& 0xF0) |
132 (hsp
->cmn
.bbRcvSizeMsb
& 0x0F);
135 memcpy(&ndlp
->nlp_nodename
, &sp
->nodeName
, sizeof (struct lpfc_name
));
136 memcpy(&ndlp
->nlp_portname
, &sp
->portName
, sizeof (struct lpfc_name
));
139 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
141 "(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x) sent "
142 "invalid service parameters. Ignoring device.\n",
144 sp
->nodeName
.u
.wwn
[0], sp
->nodeName
.u
.wwn
[1],
145 sp
->nodeName
.u
.wwn
[2], sp
->nodeName
.u
.wwn
[3],
146 sp
->nodeName
.u
.wwn
[4], sp
->nodeName
.u
.wwn
[5],
147 sp
->nodeName
.u
.wwn
[6], sp
->nodeName
.u
.wwn
[7]);
152 lpfc_check_elscmpl_iocb(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
153 struct lpfc_iocbq
*rspiocb
)
155 struct lpfc_dmabuf
*pcmd
, *prsp
;
160 irsp
= &rspiocb
->iocb
;
161 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
163 /* For lpfc_els_abort, context2 could be zero'ed to delay
164 * freeing associated memory till after ABTS completes.
167 prsp
= list_get_first(&pcmd
->list
, struct lpfc_dmabuf
,
170 lp
= (uint32_t *) prsp
->virt
;
171 ptr
= (void *)((uint8_t *)lp
+ sizeof(uint32_t));
174 /* Force ulpStatus error since we are returning NULL ptr */
175 if (!(irsp
->ulpStatus
)) {
176 irsp
->ulpStatus
= IOSTAT_LOCAL_REJECT
;
177 irsp
->un
.ulpWord
[4] = IOERR_SLI_ABORTED
;
186 * Free resources / clean up outstanding I/Os
187 * associated with a LPFC_NODELIST entry. This
188 * routine effectively results in a "software abort".
191 lpfc_els_abort(struct lpfc_hba
*phba
, struct lpfc_nodelist
*ndlp
)
193 LIST_HEAD(completions
);
194 struct lpfc_sli
*psli
= &phba
->sli
;
195 struct lpfc_sli_ring
*pring
= &psli
->ring
[LPFC_ELS_RING
];
196 struct lpfc_iocbq
*iocb
, *next_iocb
;
198 /* Abort outstanding I/O on NPort <nlp_DID> */
199 lpfc_printf_vlog(ndlp
->vport
, KERN_INFO
, LOG_DISCOVERY
,
200 "0205 Abort outstanding I/O on NPort x%x "
201 "Data: x%x x%x x%x\n",
202 ndlp
->nlp_DID
, ndlp
->nlp_flag
, ndlp
->nlp_state
,
205 lpfc_fabric_abort_nport(ndlp
);
207 /* First check the txq */
208 spin_lock_irq(&phba
->hbalock
);
209 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txq
, list
) {
210 /* Check to see if iocb matches the nport we are looking for */
211 if (lpfc_check_sli_ndlp(phba
, pring
, iocb
, ndlp
)) {
212 /* It matches, so deque and call compl with anp error */
213 list_move_tail(&iocb
->list
, &completions
);
218 /* Next check the txcmplq */
219 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txcmplq
, list
) {
220 /* Check to see if iocb matches the nport we are looking for */
221 if (lpfc_check_sli_ndlp(phba
, pring
, iocb
, ndlp
)) {
222 lpfc_sli_issue_abort_iotag(phba
, pring
, iocb
);
225 spin_unlock_irq(&phba
->hbalock
);
227 /* Cancel all the IOCBs from the completions list */
228 lpfc_sli_cancel_iocbs(phba
, &completions
, IOSTAT_LOCAL_REJECT
,
231 lpfc_cancel_retry_delay_tmo(phba
->pport
, ndlp
);
236 lpfc_rcv_plogi(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
237 struct lpfc_iocbq
*cmdiocb
)
239 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
240 struct lpfc_hba
*phba
= vport
->phba
;
241 struct lpfc_dmabuf
*pcmd
;
244 struct serv_parm
*sp
;
249 memset(&stat
, 0, sizeof (struct ls_rjt
));
250 if (vport
->port_state
<= LPFC_FLOGI
) {
251 /* Before responding to PLOGI, check for pt2pt mode.
252 * If we are pt2pt, with an outstanding FLOGI, abort
253 * the FLOGI and resend it first.
255 if (vport
->fc_flag
& FC_PT2PT
) {
256 lpfc_els_abort_flogi(phba
);
257 if (!(vport
->fc_flag
& FC_PT2PT_PLOGI
)) {
258 /* If the other side is supposed to initiate
259 * the PLOGI anyway, just ACC it now and
260 * move on with discovery.
262 phba
->fc_edtov
= FF_DEF_EDTOV
;
263 phba
->fc_ratov
= FF_DEF_RATOV
;
264 /* Start discovery - this should just do
266 lpfc_disc_start(vport
);
268 lpfc_initial_flogi(vport
);
270 stat
.un
.b
.lsRjtRsnCode
= LSRJT_LOGICAL_BSY
;
271 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
272 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
,
277 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
278 lp
= (uint32_t *) pcmd
->virt
;
279 sp
= (struct serv_parm
*) ((uint8_t *) lp
+ sizeof (uint32_t));
280 if (wwn_to_u64(sp
->portName
.u
.wwn
) == 0) {
281 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
282 "0140 PLOGI Reject: invalid nname\n");
283 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
284 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_INVALID_PNAME
;
285 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
289 if (wwn_to_u64(sp
->nodeName
.u
.wwn
) == 0) {
290 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
291 "0141 PLOGI Reject: invalid pname\n");
292 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
293 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_INVALID_NNAME
;
294 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
298 if ((lpfc_check_sparm(vport
, ndlp
, sp
, CLASS3
) == 0)) {
299 /* Reject this request because invalid parameters */
300 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
301 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_SPARM_OPTIONS
;
302 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
306 icmd
= &cmdiocb
->iocb
;
308 /* PLOGI chkparm OK */
309 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
310 "0114 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
311 ndlp
->nlp_DID
, ndlp
->nlp_state
, ndlp
->nlp_flag
,
314 if (vport
->cfg_fcp_class
== 2 && sp
->cls2
.classValid
)
315 ndlp
->nlp_fcp_info
|= CLASS2
;
317 ndlp
->nlp_fcp_info
|= CLASS3
;
319 ndlp
->nlp_class_sup
= 0;
320 if (sp
->cls1
.classValid
)
321 ndlp
->nlp_class_sup
|= FC_COS_CLASS1
;
322 if (sp
->cls2
.classValid
)
323 ndlp
->nlp_class_sup
|= FC_COS_CLASS2
;
324 if (sp
->cls3
.classValid
)
325 ndlp
->nlp_class_sup
|= FC_COS_CLASS3
;
326 if (sp
->cls4
.classValid
)
327 ndlp
->nlp_class_sup
|= FC_COS_CLASS4
;
329 ((sp
->cmn
.bbRcvSizeMsb
& 0x0F) << 8) | sp
->cmn
.bbRcvSizeLsb
;
331 /* no need to reg_login if we are already in one of these states */
332 switch (ndlp
->nlp_state
) {
333 case NLP_STE_NPR_NODE
:
334 if (!(ndlp
->nlp_flag
& NLP_NPR_ADISC
))
336 case NLP_STE_REG_LOGIN_ISSUE
:
337 case NLP_STE_PRLI_ISSUE
:
338 case NLP_STE_UNMAPPED_NODE
:
339 case NLP_STE_MAPPED_NODE
:
340 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
, NULL
);
344 if ((vport
->fc_flag
& FC_PT2PT
) &&
345 !(vport
->fc_flag
& FC_PT2PT_PLOGI
)) {
346 /* rcv'ed PLOGI decides what our NPortId will be */
347 vport
->fc_myDID
= icmd
->un
.rcvels
.parmRo
;
348 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
351 lpfc_config_link(phba
, mbox
);
352 mbox
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
354 rc
= lpfc_sli_issue_mbox(phba
, mbox
, MBX_NOWAIT
);
355 if (rc
== MBX_NOT_FINISHED
) {
356 mempool_free(mbox
, phba
->mbox_mem_pool
);
360 lpfc_can_disctmo(vport
);
362 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
366 rc
= lpfc_reg_login(phba
, vport
->vpi
, icmd
->un
.rcvels
.remoteID
,
367 (uint8_t *) sp
, mbox
, 0);
369 mempool_free(mbox
, phba
->mbox_mem_pool
);
373 /* ACC PLOGI rsp command needs to execute first,
374 * queue this mbox command to be processed later.
376 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_reg_login
;
378 * mbox->context2 = lpfc_nlp_get(ndlp) deferred until mailbox
379 * command issued in lpfc_cmpl_els_acc().
382 spin_lock_irq(shost
->host_lock
);
383 ndlp
->nlp_flag
|= (NLP_ACC_REGLOGIN
| NLP_RCV_PLOGI
);
384 spin_unlock_irq(shost
->host_lock
);
387 * If there is an outstanding PLOGI issued, abort it before
388 * sending ACC rsp for received PLOGI. If pending plogi
389 * is not canceled here, the plogi will be rejected by
390 * remote port and will be retried. On a configuration with
391 * single discovery thread, this will cause a huge delay in
392 * discovery. Also this will cause multiple state machines
393 * running in parallel for this node.
395 if (ndlp
->nlp_state
== NLP_STE_PLOGI_ISSUE
) {
396 /* software abort outstanding PLOGI */
397 lpfc_els_abort(phba
, ndlp
);
400 if ((vport
->port_type
== LPFC_NPIV_PORT
&&
401 vport
->cfg_restrict_login
)) {
403 /* In order to preserve RPIs, we want to cleanup
404 * the default RPI the firmware created to rcv
405 * this ELS request. The only way to do this is
406 * to register, then unregister the RPI.
408 spin_lock_irq(shost
->host_lock
);
409 ndlp
->nlp_flag
|= NLP_RM_DFLT_RPI
;
410 spin_unlock_irq(shost
->host_lock
);
411 stat
.un
.b
.lsRjtRsnCode
= LSRJT_INVALID_CMD
;
412 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
413 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
,
417 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
, mbox
);
420 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
421 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_OUT_OF_RESOURCE
;
422 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
427 lpfc_rcv_padisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
428 struct lpfc_iocbq
*cmdiocb
)
430 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
431 struct lpfc_dmabuf
*pcmd
;
432 struct serv_parm
*sp
;
433 struct lpfc_name
*pnn
, *ppn
;
440 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
441 lp
= (uint32_t *) pcmd
->virt
;
444 if (cmd
== ELS_CMD_ADISC
) {
446 pnn
= (struct lpfc_name
*) & ap
->nodeName
;
447 ppn
= (struct lpfc_name
*) & ap
->portName
;
449 sp
= (struct serv_parm
*) lp
;
450 pnn
= (struct lpfc_name
*) & sp
->nodeName
;
451 ppn
= (struct lpfc_name
*) & sp
->portName
;
454 icmd
= &cmdiocb
->iocb
;
455 if (icmd
->ulpStatus
== 0 && lpfc_check_adisc(vport
, ndlp
, pnn
, ppn
)) {
456 if (cmd
== ELS_CMD_ADISC
) {
457 lpfc_els_rsp_adisc_acc(vport
, cmdiocb
, ndlp
);
459 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
,
464 /* Reject this request because invalid parameters */
465 stat
.un
.b
.lsRjtRsvd0
= 0;
466 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
467 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_SPARM_OPTIONS
;
468 stat
.un
.b
.vendorUnique
= 0;
469 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
472 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
);
474 spin_lock_irq(shost
->host_lock
);
475 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
476 spin_unlock_irq(shost
->host_lock
);
477 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
478 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
479 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
484 lpfc_rcv_logo(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
485 struct lpfc_iocbq
*cmdiocb
, uint32_t els_cmd
)
487 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
489 /* Put ndlp in NPR state with 1 sec timeout for plogi, ACC logo */
490 /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary
491 * PLOGIs during LOGO storms from a device.
493 spin_lock_irq(shost
->host_lock
);
494 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
495 spin_unlock_irq(shost
->host_lock
);
496 if (els_cmd
== ELS_CMD_PRLO
)
497 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
499 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
501 if ((!(ndlp
->nlp_type
& NLP_FABRIC
) &&
502 ((ndlp
->nlp_type
& NLP_FCP_TARGET
) ||
503 !(ndlp
->nlp_type
& NLP_FCP_INITIATOR
))) ||
504 (ndlp
->nlp_state
== NLP_STE_ADISC_ISSUE
)) {
505 /* Only try to re-login if this is NOT a Fabric Node */
506 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
507 spin_lock_irq(shost
->host_lock
);
508 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
509 spin_unlock_irq(shost
->host_lock
);
511 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
513 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
514 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
516 spin_lock_irq(shost
->host_lock
);
517 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
518 spin_unlock_irq(shost
->host_lock
);
519 /* The driver has to wait until the ACC completes before it continues
520 * processing the LOGO. The action will resume in
521 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
522 * unreg_login, the driver waits so the ACC does not get aborted.
528 lpfc_rcv_prli(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
529 struct lpfc_iocbq
*cmdiocb
)
531 struct lpfc_dmabuf
*pcmd
;
534 struct fc_rport
*rport
= ndlp
->rport
;
537 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
538 lp
= (uint32_t *) pcmd
->virt
;
539 npr
= (PRLI
*) ((uint8_t *) lp
+ sizeof (uint32_t));
541 ndlp
->nlp_type
&= ~(NLP_FCP_TARGET
| NLP_FCP_INITIATOR
);
542 ndlp
->nlp_fcp_info
&= ~NLP_FCP_2_DEVICE
;
543 if (npr
->prliType
== PRLI_FCP_TYPE
) {
544 if (npr
->initiatorFunc
)
545 ndlp
->nlp_type
|= NLP_FCP_INITIATOR
;
547 ndlp
->nlp_type
|= NLP_FCP_TARGET
;
549 ndlp
->nlp_fcp_info
|= NLP_FCP_2_DEVICE
;
552 /* We need to update the rport role values */
553 roles
= FC_RPORT_ROLE_UNKNOWN
;
554 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
555 roles
|= FC_RPORT_ROLE_FCP_INITIATOR
;
556 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
557 roles
|= FC_RPORT_ROLE_FCP_TARGET
;
559 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_RPORT
,
560 "rport rolechg: role:x%x did:x%x flg:x%x",
561 roles
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
563 fc_remote_port_rolechg(rport
, roles
);
568 lpfc_disc_set_adisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
)
570 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
572 if (!ndlp
->nlp_rpi
) {
573 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
577 if (!(vport
->fc_flag
& FC_PT2PT
)) {
578 /* Check config parameter use-adisc or FCP-2 */
579 if ((vport
->cfg_use_adisc
&& (vport
->fc_flag
& FC_RSCN_MODE
)) ||
580 ndlp
->nlp_fcp_info
& NLP_FCP_2_DEVICE
) {
581 spin_lock_irq(shost
->host_lock
);
582 ndlp
->nlp_flag
|= NLP_NPR_ADISC
;
583 spin_unlock_irq(shost
->host_lock
);
587 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
588 lpfc_unreg_rpi(vport
, ndlp
);
593 lpfc_disc_illegal(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
594 void *arg
, uint32_t evt
)
596 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
597 "0271 Illegal State Transition: node x%x "
598 "event x%x, state x%x Data: x%x x%x\n",
599 ndlp
->nlp_DID
, evt
, ndlp
->nlp_state
, ndlp
->nlp_rpi
,
601 return ndlp
->nlp_state
;
605 lpfc_cmpl_plogi_illegal(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
606 void *arg
, uint32_t evt
)
608 /* This transition is only legal if we previously
609 * rcv'ed a PLOGI. Since we don't want 2 discovery threads
610 * working on the same NPortID, do nothing for this thread
613 if (!(ndlp
->nlp_flag
& NLP_RCV_PLOGI
)) {
614 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
615 "0272 Illegal State Transition: node x%x "
616 "event x%x, state x%x Data: x%x x%x\n",
617 ndlp
->nlp_DID
, evt
, ndlp
->nlp_state
, ndlp
->nlp_rpi
,
620 return ndlp
->nlp_state
;
623 /* Start of Discovery State Machine routines */
626 lpfc_rcv_plogi_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
627 void *arg
, uint32_t evt
)
629 struct lpfc_iocbq
*cmdiocb
;
631 cmdiocb
= (struct lpfc_iocbq
*) arg
;
633 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
634 return ndlp
->nlp_state
;
636 return NLP_STE_FREED_NODE
;
640 lpfc_rcv_els_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
641 void *arg
, uint32_t evt
)
643 lpfc_issue_els_logo(vport
, ndlp
, 0);
644 return ndlp
->nlp_state
;
648 lpfc_rcv_logo_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
649 void *arg
, uint32_t evt
)
651 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
652 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
654 spin_lock_irq(shost
->host_lock
);
655 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
656 spin_unlock_irq(shost
->host_lock
);
657 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
659 return ndlp
->nlp_state
;
663 lpfc_cmpl_logo_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
664 void *arg
, uint32_t evt
)
666 return NLP_STE_FREED_NODE
;
670 lpfc_device_rm_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
671 void *arg
, uint32_t evt
)
673 return NLP_STE_FREED_NODE
;
677 lpfc_rcv_plogi_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
678 void *arg
, uint32_t evt
)
680 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
681 struct lpfc_hba
*phba
= vport
->phba
;
682 struct lpfc_iocbq
*cmdiocb
= arg
;
683 struct lpfc_dmabuf
*pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
684 uint32_t *lp
= (uint32_t *) pcmd
->virt
;
685 struct serv_parm
*sp
= (struct serv_parm
*) (lp
+ 1);
689 memset(&stat
, 0, sizeof (struct ls_rjt
));
691 /* For a PLOGI, we only accept if our portname is less
692 * than the remote portname.
694 phba
->fc_stat
.elsLogiCol
++;
695 port_cmp
= memcmp(&vport
->fc_portname
, &sp
->portName
,
696 sizeof(struct lpfc_name
));
699 /* Reject this request because the remote node will accept
701 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
702 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_CMD_IN_PROGRESS
;
703 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
706 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
) &&
707 (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) &&
708 (vport
->num_disc_nodes
)) {
709 spin_lock_irq(shost
->host_lock
);
710 ndlp
->nlp_flag
&= ~NLP_NPR_2B_DISC
;
711 spin_unlock_irq(shost
->host_lock
);
712 /* Check if there are more PLOGIs to be sent */
713 lpfc_more_plogi(vport
);
714 if (vport
->num_disc_nodes
== 0) {
715 spin_lock_irq(shost
->host_lock
);
716 vport
->fc_flag
&= ~FC_NDISC_ACTIVE
;
717 spin_unlock_irq(shost
->host_lock
);
718 lpfc_can_disctmo(vport
);
719 lpfc_end_rscn(vport
);
722 } /* If our portname was less */
724 return ndlp
->nlp_state
;
728 lpfc_rcv_prli_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
729 void *arg
, uint32_t evt
)
731 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
734 memset(&stat
, 0, sizeof (struct ls_rjt
));
735 stat
.un
.b
.lsRjtRsnCode
= LSRJT_LOGICAL_BSY
;
736 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
737 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
738 return ndlp
->nlp_state
;
742 lpfc_rcv_logo_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
743 void *arg
, uint32_t evt
)
745 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
747 /* software abort outstanding PLOGI */
748 lpfc_els_abort(vport
->phba
, ndlp
);
750 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
751 return ndlp
->nlp_state
;
755 lpfc_rcv_els_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
756 void *arg
, uint32_t evt
)
758 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
759 struct lpfc_hba
*phba
= vport
->phba
;
760 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
762 /* software abort outstanding PLOGI */
763 lpfc_els_abort(phba
, ndlp
);
765 if (evt
== NLP_EVT_RCV_LOGO
) {
766 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
768 lpfc_issue_els_logo(vport
, ndlp
, 0);
771 /* Put ndlp in npr state set plogi timer for 1 sec */
772 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
773 spin_lock_irq(shost
->host_lock
);
774 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
775 spin_unlock_irq(shost
->host_lock
);
776 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
777 ndlp
->nlp_prev_state
= NLP_STE_PLOGI_ISSUE
;
778 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
780 return ndlp
->nlp_state
;
784 lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport
*vport
,
785 struct lpfc_nodelist
*ndlp
,
789 struct lpfc_hba
*phba
= vport
->phba
;
790 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
791 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
792 struct lpfc_dmabuf
*pcmd
, *prsp
, *mp
;
795 struct serv_parm
*sp
;
798 cmdiocb
= (struct lpfc_iocbq
*) arg
;
799 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
801 if (ndlp
->nlp_flag
& NLP_ACC_REGLOGIN
) {
802 /* Recovery from PLOGI collision logic */
803 return ndlp
->nlp_state
;
806 irsp
= &rspiocb
->iocb
;
811 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
813 prsp
= list_get_first(&pcmd
->list
, struct lpfc_dmabuf
, list
);
815 lp
= (uint32_t *) prsp
->virt
;
816 sp
= (struct serv_parm
*) ((uint8_t *) lp
+ sizeof (uint32_t));
818 /* Some switches have FDMI servers returning 0 for WWN */
819 if ((ndlp
->nlp_DID
!= FDMI_DID
) &&
820 (wwn_to_u64(sp
->portName
.u
.wwn
) == 0 ||
821 wwn_to_u64(sp
->nodeName
.u
.wwn
) == 0)) {
822 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
823 "0142 PLOGI RSP: Invalid WWN.\n");
826 if (!lpfc_check_sparm(vport
, ndlp
, sp
, CLASS3
))
828 /* PLOGI chkparm OK */
829 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
830 "0121 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
831 ndlp
->nlp_DID
, ndlp
->nlp_state
,
832 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
833 if (vport
->cfg_fcp_class
== 2 && (sp
->cls2
.classValid
))
834 ndlp
->nlp_fcp_info
|= CLASS2
;
836 ndlp
->nlp_fcp_info
|= CLASS3
;
838 ndlp
->nlp_class_sup
= 0;
839 if (sp
->cls1
.classValid
)
840 ndlp
->nlp_class_sup
|= FC_COS_CLASS1
;
841 if (sp
->cls2
.classValid
)
842 ndlp
->nlp_class_sup
|= FC_COS_CLASS2
;
843 if (sp
->cls3
.classValid
)
844 ndlp
->nlp_class_sup
|= FC_COS_CLASS3
;
845 if (sp
->cls4
.classValid
)
846 ndlp
->nlp_class_sup
|= FC_COS_CLASS4
;
848 ((sp
->cmn
.bbRcvSizeMsb
& 0x0F) << 8) | sp
->cmn
.bbRcvSizeLsb
;
850 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
852 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
853 "0133 PLOGI: no memory for reg_login "
854 "Data: x%x x%x x%x x%x\n",
855 ndlp
->nlp_DID
, ndlp
->nlp_state
,
856 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
860 lpfc_unreg_rpi(vport
, ndlp
);
862 if (lpfc_reg_login(phba
, vport
->vpi
, irsp
->un
.elsreq64
.remoteID
,
863 (uint8_t *) sp
, mbox
, 0) == 0) {
864 switch (ndlp
->nlp_DID
) {
866 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_ns_reg_login
;
869 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_fdmi_reg_login
;
872 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_reg_login
;
874 mbox
->context2
= lpfc_nlp_get(ndlp
);
876 if (lpfc_sli_issue_mbox(phba
, mbox
, MBX_NOWAIT
)
877 != MBX_NOT_FINISHED
) {
878 lpfc_nlp_set_state(vport
, ndlp
,
879 NLP_STE_REG_LOGIN_ISSUE
);
880 return ndlp
->nlp_state
;
882 /* decrement node reference count to the failed mbox
886 mp
= (struct lpfc_dmabuf
*) mbox
->context1
;
887 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
889 mempool_free(mbox
, phba
->mbox_mem_pool
);
891 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
892 "0134 PLOGI: cannot issue reg_login "
893 "Data: x%x x%x x%x x%x\n",
894 ndlp
->nlp_DID
, ndlp
->nlp_state
,
895 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
897 mempool_free(mbox
, phba
->mbox_mem_pool
);
899 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
900 "0135 PLOGI: cannot format reg_login "
901 "Data: x%x x%x x%x x%x\n",
902 ndlp
->nlp_DID
, ndlp
->nlp_state
,
903 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
908 if (ndlp
->nlp_DID
== NameServer_DID
) {
909 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
910 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
911 "0261 Cannot Register NameServer login\n");
914 spin_lock_irq(shost
->host_lock
);
915 ndlp
->nlp_flag
|= NLP_DEFER_RM
;
916 spin_unlock_irq(shost
->host_lock
);
917 return NLP_STE_FREED_NODE
;
921 lpfc_cmpl_logo_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
922 void *arg
, uint32_t evt
)
924 return ndlp
->nlp_state
;
928 lpfc_cmpl_reglogin_plogi_issue(struct lpfc_vport
*vport
,
929 struct lpfc_nodelist
*ndlp
, void *arg
, uint32_t evt
)
931 return ndlp
->nlp_state
;
935 lpfc_device_rm_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
936 void *arg
, uint32_t evt
)
938 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
940 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
941 spin_lock_irq(shost
->host_lock
);
942 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
943 spin_unlock_irq(shost
->host_lock
);
944 return ndlp
->nlp_state
;
946 /* software abort outstanding PLOGI */
947 lpfc_els_abort(vport
->phba
, ndlp
);
949 lpfc_drop_node(vport
, ndlp
);
950 return NLP_STE_FREED_NODE
;
955 lpfc_device_recov_plogi_issue(struct lpfc_vport
*vport
,
956 struct lpfc_nodelist
*ndlp
,
960 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
961 struct lpfc_hba
*phba
= vport
->phba
;
963 /* Don't do anything that will mess up processing of the
966 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
967 return ndlp
->nlp_state
;
969 /* software abort outstanding PLOGI */
970 lpfc_els_abort(phba
, ndlp
);
972 ndlp
->nlp_prev_state
= NLP_STE_PLOGI_ISSUE
;
973 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
974 spin_lock_irq(shost
->host_lock
);
975 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
976 spin_unlock_irq(shost
->host_lock
);
978 return ndlp
->nlp_state
;
982 lpfc_rcv_plogi_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
983 void *arg
, uint32_t evt
)
985 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
986 struct lpfc_hba
*phba
= vport
->phba
;
987 struct lpfc_iocbq
*cmdiocb
;
989 /* software abort outstanding ADISC */
990 lpfc_els_abort(phba
, ndlp
);
992 cmdiocb
= (struct lpfc_iocbq
*) arg
;
994 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
995 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
996 spin_lock_irq(shost
->host_lock
);
997 ndlp
->nlp_flag
&= ~NLP_NPR_2B_DISC
;
998 spin_unlock_irq(shost
->host_lock
);
999 if (vport
->num_disc_nodes
)
1000 lpfc_more_adisc(vport
);
1002 return ndlp
->nlp_state
;
1004 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1005 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1006 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1008 return ndlp
->nlp_state
;
1012 lpfc_rcv_prli_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1013 void *arg
, uint32_t evt
)
1015 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1017 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1018 return ndlp
->nlp_state
;
1022 lpfc_rcv_logo_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1023 void *arg
, uint32_t evt
)
1025 struct lpfc_hba
*phba
= vport
->phba
;
1026 struct lpfc_iocbq
*cmdiocb
;
1028 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1030 /* software abort outstanding ADISC */
1031 lpfc_els_abort(phba
, ndlp
);
1033 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1034 return ndlp
->nlp_state
;
1038 lpfc_rcv_padisc_adisc_issue(struct lpfc_vport
*vport
,
1039 struct lpfc_nodelist
*ndlp
,
1040 void *arg
, uint32_t evt
)
1042 struct lpfc_iocbq
*cmdiocb
;
1044 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1046 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1047 return ndlp
->nlp_state
;
1051 lpfc_rcv_prlo_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1052 void *arg
, uint32_t evt
)
1054 struct lpfc_iocbq
*cmdiocb
;
1056 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1058 /* Treat like rcv logo */
1059 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_PRLO
);
1060 return ndlp
->nlp_state
;
1064 lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport
*vport
,
1065 struct lpfc_nodelist
*ndlp
,
1066 void *arg
, uint32_t evt
)
1068 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1069 struct lpfc_hba
*phba
= vport
->phba
;
1070 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1074 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1075 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1077 ap
= (ADISC
*)lpfc_check_elscmpl_iocb(phba
, cmdiocb
, rspiocb
);
1078 irsp
= &rspiocb
->iocb
;
1080 if ((irsp
->ulpStatus
) ||
1081 (!lpfc_check_adisc(vport
, ndlp
, &ap
->nodeName
, &ap
->portName
))) {
1083 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
);
1084 spin_lock_irq(shost
->host_lock
);
1085 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1086 spin_unlock_irq(shost
->host_lock
);
1087 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1089 memset(&ndlp
->nlp_nodename
, 0, sizeof(struct lpfc_name
));
1090 memset(&ndlp
->nlp_portname
, 0, sizeof(struct lpfc_name
));
1092 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1093 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1094 lpfc_unreg_rpi(vport
, ndlp
);
1095 return ndlp
->nlp_state
;
1098 if (ndlp
->nlp_type
& NLP_FCP_TARGET
) {
1099 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1100 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_MAPPED_NODE
);
1102 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1103 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1105 return ndlp
->nlp_state
;
1109 lpfc_device_rm_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1110 void *arg
, uint32_t evt
)
1112 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1114 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1115 spin_lock_irq(shost
->host_lock
);
1116 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1117 spin_unlock_irq(shost
->host_lock
);
1118 return ndlp
->nlp_state
;
1120 /* software abort outstanding ADISC */
1121 lpfc_els_abort(vport
->phba
, ndlp
);
1123 lpfc_drop_node(vport
, ndlp
);
1124 return NLP_STE_FREED_NODE
;
1129 lpfc_device_recov_adisc_issue(struct lpfc_vport
*vport
,
1130 struct lpfc_nodelist
*ndlp
,
1134 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1135 struct lpfc_hba
*phba
= vport
->phba
;
1137 /* Don't do anything that will mess up processing of the
1140 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1141 return ndlp
->nlp_state
;
1143 /* software abort outstanding ADISC */
1144 lpfc_els_abort(phba
, ndlp
);
1146 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1147 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1148 spin_lock_irq(shost
->host_lock
);
1149 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1150 spin_unlock_irq(shost
->host_lock
);
1151 lpfc_disc_set_adisc(vport
, ndlp
);
1152 return ndlp
->nlp_state
;
1156 lpfc_rcv_plogi_reglogin_issue(struct lpfc_vport
*vport
,
1157 struct lpfc_nodelist
*ndlp
,
1161 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1163 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1164 return ndlp
->nlp_state
;
1168 lpfc_rcv_prli_reglogin_issue(struct lpfc_vport
*vport
,
1169 struct lpfc_nodelist
*ndlp
,
1173 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1175 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1176 return ndlp
->nlp_state
;
1180 lpfc_rcv_logo_reglogin_issue(struct lpfc_vport
*vport
,
1181 struct lpfc_nodelist
*ndlp
,
1185 struct lpfc_hba
*phba
= vport
->phba
;
1186 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1188 LPFC_MBOXQ_t
*nextmb
;
1189 struct lpfc_dmabuf
*mp
;
1191 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1193 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1194 if ((mb
= phba
->sli
.mbox_active
)) {
1195 if ((mb
->mb
.mbxCommand
== MBX_REG_LOGIN64
) &&
1196 (ndlp
== (struct lpfc_nodelist
*) mb
->context2
)) {
1198 mb
->context2
= NULL
;
1199 mb
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
1203 spin_lock_irq(&phba
->hbalock
);
1204 list_for_each_entry_safe(mb
, nextmb
, &phba
->sli
.mboxq
, list
) {
1205 if ((mb
->mb
.mbxCommand
== MBX_REG_LOGIN64
) &&
1206 (ndlp
== (struct lpfc_nodelist
*) mb
->context2
)) {
1207 mp
= (struct lpfc_dmabuf
*) (mb
->context1
);
1209 __lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1213 list_del(&mb
->list
);
1214 mempool_free(mb
, phba
->mbox_mem_pool
);
1217 spin_unlock_irq(&phba
->hbalock
);
1219 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1220 return ndlp
->nlp_state
;
1224 lpfc_rcv_padisc_reglogin_issue(struct lpfc_vport
*vport
,
1225 struct lpfc_nodelist
*ndlp
,
1229 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1231 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1232 return ndlp
->nlp_state
;
1236 lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport
*vport
,
1237 struct lpfc_nodelist
*ndlp
,
1241 struct lpfc_iocbq
*cmdiocb
;
1243 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1244 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1245 return ndlp
->nlp_state
;
1249 lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport
*vport
,
1250 struct lpfc_nodelist
*ndlp
,
1254 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1255 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
1256 MAILBOX_t
*mb
= &pmb
->mb
;
1257 uint32_t did
= mb
->un
.varWords
[1];
1259 if (mb
->mbxStatus
) {
1260 /* RegLogin failed */
1261 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
1262 "0246 RegLogin failed Data: x%x x%x x%x\n",
1263 did
, mb
->mbxStatus
, vport
->port_state
);
1265 * If RegLogin failed due to lack of HBA resources do not
1268 if (mb
->mbxStatus
== MBXERR_RPI_FULL
) {
1269 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1270 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1271 return ndlp
->nlp_state
;
1274 /* Put ndlp in npr state set plogi timer for 1 sec */
1275 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
1276 spin_lock_irq(shost
->host_lock
);
1277 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1278 spin_unlock_irq(shost
->host_lock
);
1279 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1281 lpfc_issue_els_logo(vport
, ndlp
, 0);
1282 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1283 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1284 return ndlp
->nlp_state
;
1287 ndlp
->nlp_rpi
= mb
->un
.varWords
[0];
1289 /* Only if we are not a fabric nport do we issue PRLI */
1290 if (!(ndlp
->nlp_type
& NLP_FABRIC
)) {
1291 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1292 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PRLI_ISSUE
);
1293 lpfc_issue_els_prli(vport
, ndlp
, 0);
1295 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1296 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1298 return ndlp
->nlp_state
;
1302 lpfc_device_rm_reglogin_issue(struct lpfc_vport
*vport
,
1303 struct lpfc_nodelist
*ndlp
,
1307 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1309 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1310 spin_lock_irq(shost
->host_lock
);
1311 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1312 spin_unlock_irq(shost
->host_lock
);
1313 return ndlp
->nlp_state
;
1315 lpfc_drop_node(vport
, ndlp
);
1316 return NLP_STE_FREED_NODE
;
1321 lpfc_device_recov_reglogin_issue(struct lpfc_vport
*vport
,
1322 struct lpfc_nodelist
*ndlp
,
1326 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1328 /* Don't do anything that will mess up processing of the
1331 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1332 return ndlp
->nlp_state
;
1334 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1335 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1336 spin_lock_irq(shost
->host_lock
);
1337 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1338 spin_unlock_irq(shost
->host_lock
);
1339 lpfc_disc_set_adisc(vport
, ndlp
);
1340 return ndlp
->nlp_state
;
1344 lpfc_rcv_plogi_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1345 void *arg
, uint32_t evt
)
1347 struct lpfc_iocbq
*cmdiocb
;
1349 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1351 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1352 return ndlp
->nlp_state
;
1356 lpfc_rcv_prli_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1357 void *arg
, uint32_t evt
)
1359 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1361 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1362 return ndlp
->nlp_state
;
1366 lpfc_rcv_logo_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1367 void *arg
, uint32_t evt
)
1369 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1371 /* Software abort outstanding PRLI before sending acc */
1372 lpfc_els_abort(vport
->phba
, ndlp
);
1374 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1375 return ndlp
->nlp_state
;
1379 lpfc_rcv_padisc_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1380 void *arg
, uint32_t evt
)
1382 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1384 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1385 return ndlp
->nlp_state
;
1388 /* This routine is envoked when we rcv a PRLO request from a nport
1389 * we are logged into. We should send back a PRLO rsp setting the
1391 * NEXT STATE = PRLI_ISSUE
1394 lpfc_rcv_prlo_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1395 void *arg
, uint32_t evt
)
1397 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1399 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1400 return ndlp
->nlp_state
;
1404 lpfc_cmpl_prli_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1405 void *arg
, uint32_t evt
)
1407 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1408 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1409 struct lpfc_hba
*phba
= vport
->phba
;
1413 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1414 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1415 npr
= (PRLI
*)lpfc_check_elscmpl_iocb(phba
, cmdiocb
, rspiocb
);
1417 irsp
= &rspiocb
->iocb
;
1418 if (irsp
->ulpStatus
) {
1419 if ((vport
->port_type
== LPFC_NPIV_PORT
) &&
1420 vport
->cfg_restrict_login
) {
1423 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1424 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1425 return ndlp
->nlp_state
;
1428 /* Check out PRLI rsp */
1429 ndlp
->nlp_type
&= ~(NLP_FCP_TARGET
| NLP_FCP_INITIATOR
);
1430 ndlp
->nlp_fcp_info
&= ~NLP_FCP_2_DEVICE
;
1431 if ((npr
->acceptRspCode
== PRLI_REQ_EXECUTED
) &&
1432 (npr
->prliType
== PRLI_FCP_TYPE
)) {
1433 if (npr
->initiatorFunc
)
1434 ndlp
->nlp_type
|= NLP_FCP_INITIATOR
;
1435 if (npr
->targetFunc
)
1436 ndlp
->nlp_type
|= NLP_FCP_TARGET
;
1438 ndlp
->nlp_fcp_info
|= NLP_FCP_2_DEVICE
;
1440 if (!(ndlp
->nlp_type
& NLP_FCP_TARGET
) &&
1441 (vport
->port_type
== LPFC_NPIV_PORT
) &&
1442 vport
->cfg_restrict_login
) {
1444 spin_lock_irq(shost
->host_lock
);
1445 ndlp
->nlp_flag
|= NLP_TARGET_REMOVE
;
1446 spin_unlock_irq(shost
->host_lock
);
1447 lpfc_issue_els_logo(vport
, ndlp
, 0);
1449 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1450 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1451 return ndlp
->nlp_state
;
1454 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1455 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
1456 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_MAPPED_NODE
);
1458 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1459 return ndlp
->nlp_state
;
1462 /*! lpfc_device_rm_prli_issue
1473 * This routine is envoked when we a request to remove a nport we are in the
1474 * process of PRLIing. We should software abort outstanding prli, unreg
1475 * login, send a logout. We will change node state to UNUSED_NODE, put it
1476 * on plogi list so it can be freed when LOGO completes.
1481 lpfc_device_rm_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1482 void *arg
, uint32_t evt
)
1484 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1486 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1487 spin_lock_irq(shost
->host_lock
);
1488 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1489 spin_unlock_irq(shost
->host_lock
);
1490 return ndlp
->nlp_state
;
1492 /* software abort outstanding PLOGI */
1493 lpfc_els_abort(vport
->phba
, ndlp
);
1495 lpfc_drop_node(vport
, ndlp
);
1496 return NLP_STE_FREED_NODE
;
1501 /*! lpfc_device_recov_prli_issue
1512 * The routine is envoked when the state of a device is unknown, like
1513 * during a link down. We should remove the nodelist entry from the
1514 * unmapped list, issue a UNREG_LOGIN, do a software abort of the
1515 * outstanding PRLI command, then free the node entry.
1518 lpfc_device_recov_prli_issue(struct lpfc_vport
*vport
,
1519 struct lpfc_nodelist
*ndlp
,
1523 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1524 struct lpfc_hba
*phba
= vport
->phba
;
1526 /* Don't do anything that will mess up processing of the
1529 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1530 return ndlp
->nlp_state
;
1532 /* software abort outstanding PRLI */
1533 lpfc_els_abort(phba
, ndlp
);
1535 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1536 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1537 spin_lock_irq(shost
->host_lock
);
1538 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1539 spin_unlock_irq(shost
->host_lock
);
1540 lpfc_disc_set_adisc(vport
, ndlp
);
1541 return ndlp
->nlp_state
;
1545 lpfc_rcv_plogi_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1546 void *arg
, uint32_t evt
)
1548 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1550 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1551 return ndlp
->nlp_state
;
1555 lpfc_rcv_prli_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1556 void *arg
, uint32_t evt
)
1558 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1560 lpfc_rcv_prli(vport
, ndlp
, cmdiocb
);
1561 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1562 return ndlp
->nlp_state
;
1566 lpfc_rcv_logo_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1567 void *arg
, uint32_t evt
)
1569 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1571 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1572 return ndlp
->nlp_state
;
1576 lpfc_rcv_padisc_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1577 void *arg
, uint32_t evt
)
1579 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1581 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1582 return ndlp
->nlp_state
;
1586 lpfc_rcv_prlo_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1587 void *arg
, uint32_t evt
)
1589 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1591 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1592 return ndlp
->nlp_state
;
1596 lpfc_device_recov_unmap_node(struct lpfc_vport
*vport
,
1597 struct lpfc_nodelist
*ndlp
,
1601 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1603 ndlp
->nlp_prev_state
= NLP_STE_UNMAPPED_NODE
;
1604 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1605 spin_lock_irq(shost
->host_lock
);
1606 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1607 spin_unlock_irq(shost
->host_lock
);
1608 lpfc_disc_set_adisc(vport
, ndlp
);
1610 return ndlp
->nlp_state
;
1614 lpfc_rcv_plogi_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1615 void *arg
, uint32_t evt
)
1617 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1619 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1620 return ndlp
->nlp_state
;
1624 lpfc_rcv_prli_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1625 void *arg
, uint32_t evt
)
1627 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1629 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1630 return ndlp
->nlp_state
;
1634 lpfc_rcv_logo_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1635 void *arg
, uint32_t evt
)
1637 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1639 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1640 return ndlp
->nlp_state
;
1644 lpfc_rcv_padisc_mapped_node(struct lpfc_vport
*vport
,
1645 struct lpfc_nodelist
*ndlp
,
1646 void *arg
, uint32_t evt
)
1648 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1650 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1651 return ndlp
->nlp_state
;
1655 lpfc_rcv_prlo_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1656 void *arg
, uint32_t evt
)
1658 struct lpfc_hba
*phba
= vport
->phba
;
1659 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1661 /* flush the target */
1662 lpfc_sli_abort_iocb(vport
, &phba
->sli
.ring
[phba
->sli
.fcp_ring
],
1663 ndlp
->nlp_sid
, 0, LPFC_CTX_TGT
);
1665 /* Treat like rcv logo */
1666 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_PRLO
);
1667 return ndlp
->nlp_state
;
1671 lpfc_device_recov_mapped_node(struct lpfc_vport
*vport
,
1672 struct lpfc_nodelist
*ndlp
,
1676 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1678 ndlp
->nlp_prev_state
= NLP_STE_MAPPED_NODE
;
1679 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1680 spin_lock_irq(shost
->host_lock
);
1681 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1682 spin_unlock_irq(shost
->host_lock
);
1683 lpfc_disc_set_adisc(vport
, ndlp
);
1684 return ndlp
->nlp_state
;
1688 lpfc_rcv_plogi_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1689 void *arg
, uint32_t evt
)
1691 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1692 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1694 /* Ignore PLOGI if we have an outstanding LOGO */
1695 if (ndlp
->nlp_flag
& (NLP_LOGO_SND
| NLP_LOGO_ACC
))
1696 return ndlp
->nlp_state
;
1697 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
1698 lpfc_cancel_retry_delay_tmo(vport
, ndlp
);
1699 spin_lock_irq(shost
->host_lock
);
1700 ndlp
->nlp_flag
&= ~(NLP_NPR_ADISC
| NLP_NPR_2B_DISC
);
1701 spin_unlock_irq(shost
->host_lock
);
1702 } else if (!(ndlp
->nlp_flag
& NLP_NPR_2B_DISC
)) {
1703 /* send PLOGI immediately, move to PLOGI issue state */
1704 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
)) {
1705 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1706 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1707 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1710 return ndlp
->nlp_state
;
1714 lpfc_rcv_prli_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1715 void *arg
, uint32_t evt
)
1717 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1718 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1721 memset(&stat
, 0, sizeof (struct ls_rjt
));
1722 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
1723 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
1724 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
1726 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
)) {
1727 if (ndlp
->nlp_flag
& NLP_NPR_ADISC
) {
1728 spin_lock_irq(shost
->host_lock
);
1729 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1730 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1731 spin_unlock_irq(shost
->host_lock
);
1732 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_ADISC_ISSUE
);
1733 lpfc_issue_els_adisc(vport
, ndlp
, 0);
1735 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
1736 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1737 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1740 return ndlp
->nlp_state
;
1744 lpfc_rcv_logo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1745 void *arg
, uint32_t evt
)
1747 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1749 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1750 return ndlp
->nlp_state
;
1754 lpfc_rcv_padisc_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1755 void *arg
, uint32_t evt
)
1757 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1759 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1761 * Do not start discovery if discovery is about to start
1762 * or discovery in progress for this node. Starting discovery
1763 * here will affect the counting of discovery threads.
1765 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
) &&
1766 !(ndlp
->nlp_flag
& NLP_NPR_2B_DISC
)) {
1767 if (ndlp
->nlp_flag
& NLP_NPR_ADISC
) {
1768 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1769 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
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_prlo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1783 void *arg
, uint32_t evt
)
1785 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1786 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1788 spin_lock_irq(shost
->host_lock
);
1789 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
1790 spin_unlock_irq(shost
->host_lock
);
1792 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
1794 if ((ndlp
->nlp_flag
& NLP_DELAY_TMO
) == 0) {
1795 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ HZ
* 1);
1796 spin_lock_irq(shost
->host_lock
);
1797 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1798 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1799 spin_unlock_irq(shost
->host_lock
);
1800 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1802 spin_lock_irq(shost
->host_lock
);
1803 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
1804 spin_unlock_irq(shost
->host_lock
);
1806 return ndlp
->nlp_state
;
1810 lpfc_cmpl_plogi_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1811 void *arg
, uint32_t evt
)
1813 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1816 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1817 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1819 irsp
= &rspiocb
->iocb
;
1820 if (irsp
->ulpStatus
) {
1821 ndlp
->nlp_flag
|= NLP_DEFER_RM
;
1822 return NLP_STE_FREED_NODE
;
1824 return ndlp
->nlp_state
;
1828 lpfc_cmpl_prli_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1829 void *arg
, uint32_t evt
)
1831 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1834 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1835 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1837 irsp
= &rspiocb
->iocb
;
1838 if (irsp
->ulpStatus
&& (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
)) {
1839 lpfc_drop_node(vport
, ndlp
);
1840 return NLP_STE_FREED_NODE
;
1842 return ndlp
->nlp_state
;
1846 lpfc_cmpl_logo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1847 void *arg
, uint32_t evt
)
1849 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1850 if (ndlp
->nlp_DID
== Fabric_DID
) {
1851 spin_lock_irq(shost
->host_lock
);
1852 vport
->fc_flag
&= ~(FC_FABRIC
| FC_PUBLIC_LOOP
);
1853 spin_unlock_irq(shost
->host_lock
);
1855 lpfc_unreg_rpi(vport
, ndlp
);
1856 return ndlp
->nlp_state
;
1860 lpfc_cmpl_adisc_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1861 void *arg
, uint32_t evt
)
1863 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1866 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1867 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1869 irsp
= &rspiocb
->iocb
;
1870 if (irsp
->ulpStatus
&& (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
)) {
1871 lpfc_drop_node(vport
, ndlp
);
1872 return NLP_STE_FREED_NODE
;
1874 return ndlp
->nlp_state
;
1878 lpfc_cmpl_reglogin_npr_node(struct lpfc_vport
*vport
,
1879 struct lpfc_nodelist
*ndlp
,
1880 void *arg
, uint32_t evt
)
1882 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
1883 MAILBOX_t
*mb
= &pmb
->mb
;
1886 ndlp
->nlp_rpi
= mb
->un
.varWords
[0];
1888 if (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
) {
1889 lpfc_drop_node(vport
, ndlp
);
1890 return NLP_STE_FREED_NODE
;
1893 return ndlp
->nlp_state
;
1897 lpfc_device_rm_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1898 void *arg
, uint32_t evt
)
1900 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1902 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1903 spin_lock_irq(shost
->host_lock
);
1904 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1905 spin_unlock_irq(shost
->host_lock
);
1906 return ndlp
->nlp_state
;
1908 lpfc_drop_node(vport
, ndlp
);
1909 return NLP_STE_FREED_NODE
;
1913 lpfc_device_recov_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1914 void *arg
, uint32_t evt
)
1916 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1918 /* Don't do anything that will mess up processing of the
1921 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1922 return ndlp
->nlp_state
;
1924 lpfc_cancel_retry_delay_tmo(vport
, ndlp
);
1925 spin_lock_irq(shost
->host_lock
);
1926 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1927 spin_unlock_irq(shost
->host_lock
);
1928 return ndlp
->nlp_state
;
1932 /* This next section defines the NPort Discovery State Machine */
1934 /* There are 4 different double linked lists nodelist entries can reside on.
1935 * The plogi list and adisc list are used when Link Up discovery or RSCN
1936 * processing is needed. Each list holds the nodes that we will send PLOGI
1937 * or ADISC on. These lists will keep track of what nodes will be effected
1938 * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
1939 * The unmapped_list will contain all nodes that we have successfully logged
1940 * into at the Fibre Channel level. The mapped_list will contain all nodes
1941 * that are mapped FCP targets.
1944 * The bind list is a list of undiscovered (potentially non-existent) nodes
1945 * that we have saved binding information on. This information is used when
1946 * nodes transition from the unmapped to the mapped list.
1948 /* For UNUSED_NODE state, the node has just been allocated .
1949 * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
1950 * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
1951 * and put on the unmapped list. For ADISC processing, the node is taken off
1952 * the ADISC list and placed on either the mapped or unmapped list (depending
1953 * on its previous state). Once on the unmapped list, a PRLI is issued and the
1954 * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
1955 * changed to UNMAPPED_NODE. If the completion indicates a mapped
1956 * node, the node is taken off the unmapped list. The binding list is checked
1957 * for a valid binding, or a binding is automatically assigned. If binding
1958 * assignment is unsuccessful, the node is left on the unmapped list. If
1959 * binding assignment is successful, the associated binding list entry (if
1960 * any) is removed, and the node is placed on the mapped list.
1963 * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
1964 * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
1965 * expire, all effected nodes will receive a DEVICE_RM event.
1968 * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
1969 * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
1970 * check, additional nodes may be added or removed (via DEVICE_RM) to / from
1971 * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
1972 * we will first process the ADISC list. 32 entries are processed initially and
1973 * ADISC is initited for each one. Completions / Events for each node are
1974 * funnelled thru the state machine. As each node finishes ADISC processing, it
1975 * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
1976 * waiting, and the ADISC list count is identically 0, then we are done. For
1977 * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
1978 * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
1979 * list. 32 entries are processed initially and PLOGI is initited for each one.
1980 * Completions / Events for each node are funnelled thru the state machine. As
1981 * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
1982 * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
1983 * indentically 0, then we are done. We have now completed discovery / RSCN
1984 * handling. Upon completion, ALL nodes should be on either the mapped or
1988 static uint32_t (*lpfc_disc_action
[NLP_STE_MAX_STATE
* NLP_EVT_MAX_EVENT
])
1989 (struct lpfc_vport
*, struct lpfc_nodelist
*, void *, uint32_t) = {
1990 /* Action routine Event Current State */
1991 lpfc_rcv_plogi_unused_node
, /* RCV_PLOGI UNUSED_NODE */
1992 lpfc_rcv_els_unused_node
, /* RCV_PRLI */
1993 lpfc_rcv_logo_unused_node
, /* RCV_LOGO */
1994 lpfc_rcv_els_unused_node
, /* RCV_ADISC */
1995 lpfc_rcv_els_unused_node
, /* RCV_PDISC */
1996 lpfc_rcv_els_unused_node
, /* RCV_PRLO */
1997 lpfc_disc_illegal
, /* CMPL_PLOGI */
1998 lpfc_disc_illegal
, /* CMPL_PRLI */
1999 lpfc_cmpl_logo_unused_node
, /* CMPL_LOGO */
2000 lpfc_disc_illegal
, /* CMPL_ADISC */
2001 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2002 lpfc_device_rm_unused_node
, /* DEVICE_RM */
2003 lpfc_disc_illegal
, /* DEVICE_RECOVERY */
2005 lpfc_rcv_plogi_plogi_issue
, /* RCV_PLOGI PLOGI_ISSUE */
2006 lpfc_rcv_prli_plogi_issue
, /* RCV_PRLI */
2007 lpfc_rcv_logo_plogi_issue
, /* RCV_LOGO */
2008 lpfc_rcv_els_plogi_issue
, /* RCV_ADISC */
2009 lpfc_rcv_els_plogi_issue
, /* RCV_PDISC */
2010 lpfc_rcv_els_plogi_issue
, /* RCV_PRLO */
2011 lpfc_cmpl_plogi_plogi_issue
, /* CMPL_PLOGI */
2012 lpfc_disc_illegal
, /* CMPL_PRLI */
2013 lpfc_cmpl_logo_plogi_issue
, /* CMPL_LOGO */
2014 lpfc_disc_illegal
, /* CMPL_ADISC */
2015 lpfc_cmpl_reglogin_plogi_issue
,/* CMPL_REG_LOGIN */
2016 lpfc_device_rm_plogi_issue
, /* DEVICE_RM */
2017 lpfc_device_recov_plogi_issue
, /* DEVICE_RECOVERY */
2019 lpfc_rcv_plogi_adisc_issue
, /* RCV_PLOGI ADISC_ISSUE */
2020 lpfc_rcv_prli_adisc_issue
, /* RCV_PRLI */
2021 lpfc_rcv_logo_adisc_issue
, /* RCV_LOGO */
2022 lpfc_rcv_padisc_adisc_issue
, /* RCV_ADISC */
2023 lpfc_rcv_padisc_adisc_issue
, /* RCV_PDISC */
2024 lpfc_rcv_prlo_adisc_issue
, /* RCV_PRLO */
2025 lpfc_disc_illegal
, /* CMPL_PLOGI */
2026 lpfc_disc_illegal
, /* CMPL_PRLI */
2027 lpfc_disc_illegal
, /* CMPL_LOGO */
2028 lpfc_cmpl_adisc_adisc_issue
, /* CMPL_ADISC */
2029 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2030 lpfc_device_rm_adisc_issue
, /* DEVICE_RM */
2031 lpfc_device_recov_adisc_issue
, /* DEVICE_RECOVERY */
2033 lpfc_rcv_plogi_reglogin_issue
, /* RCV_PLOGI REG_LOGIN_ISSUE */
2034 lpfc_rcv_prli_reglogin_issue
, /* RCV_PLOGI */
2035 lpfc_rcv_logo_reglogin_issue
, /* RCV_LOGO */
2036 lpfc_rcv_padisc_reglogin_issue
, /* RCV_ADISC */
2037 lpfc_rcv_padisc_reglogin_issue
, /* RCV_PDISC */
2038 lpfc_rcv_prlo_reglogin_issue
, /* RCV_PRLO */
2039 lpfc_cmpl_plogi_illegal
, /* CMPL_PLOGI */
2040 lpfc_disc_illegal
, /* CMPL_PRLI */
2041 lpfc_disc_illegal
, /* CMPL_LOGO */
2042 lpfc_disc_illegal
, /* CMPL_ADISC */
2043 lpfc_cmpl_reglogin_reglogin_issue
,/* CMPL_REG_LOGIN */
2044 lpfc_device_rm_reglogin_issue
, /* DEVICE_RM */
2045 lpfc_device_recov_reglogin_issue
,/* DEVICE_RECOVERY */
2047 lpfc_rcv_plogi_prli_issue
, /* RCV_PLOGI PRLI_ISSUE */
2048 lpfc_rcv_prli_prli_issue
, /* RCV_PRLI */
2049 lpfc_rcv_logo_prli_issue
, /* RCV_LOGO */
2050 lpfc_rcv_padisc_prli_issue
, /* RCV_ADISC */
2051 lpfc_rcv_padisc_prli_issue
, /* RCV_PDISC */
2052 lpfc_rcv_prlo_prli_issue
, /* RCV_PRLO */
2053 lpfc_cmpl_plogi_illegal
, /* CMPL_PLOGI */
2054 lpfc_cmpl_prli_prli_issue
, /* CMPL_PRLI */
2055 lpfc_disc_illegal
, /* CMPL_LOGO */
2056 lpfc_disc_illegal
, /* CMPL_ADISC */
2057 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2058 lpfc_device_rm_prli_issue
, /* DEVICE_RM */
2059 lpfc_device_recov_prli_issue
, /* DEVICE_RECOVERY */
2061 lpfc_rcv_plogi_unmap_node
, /* RCV_PLOGI UNMAPPED_NODE */
2062 lpfc_rcv_prli_unmap_node
, /* RCV_PRLI */
2063 lpfc_rcv_logo_unmap_node
, /* RCV_LOGO */
2064 lpfc_rcv_padisc_unmap_node
, /* RCV_ADISC */
2065 lpfc_rcv_padisc_unmap_node
, /* RCV_PDISC */
2066 lpfc_rcv_prlo_unmap_node
, /* RCV_PRLO */
2067 lpfc_disc_illegal
, /* CMPL_PLOGI */
2068 lpfc_disc_illegal
, /* CMPL_PRLI */
2069 lpfc_disc_illegal
, /* CMPL_LOGO */
2070 lpfc_disc_illegal
, /* CMPL_ADISC */
2071 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2072 lpfc_disc_illegal
, /* DEVICE_RM */
2073 lpfc_device_recov_unmap_node
, /* DEVICE_RECOVERY */
2075 lpfc_rcv_plogi_mapped_node
, /* RCV_PLOGI MAPPED_NODE */
2076 lpfc_rcv_prli_mapped_node
, /* RCV_PRLI */
2077 lpfc_rcv_logo_mapped_node
, /* RCV_LOGO */
2078 lpfc_rcv_padisc_mapped_node
, /* RCV_ADISC */
2079 lpfc_rcv_padisc_mapped_node
, /* RCV_PDISC */
2080 lpfc_rcv_prlo_mapped_node
, /* RCV_PRLO */
2081 lpfc_disc_illegal
, /* CMPL_PLOGI */
2082 lpfc_disc_illegal
, /* CMPL_PRLI */
2083 lpfc_disc_illegal
, /* CMPL_LOGO */
2084 lpfc_disc_illegal
, /* CMPL_ADISC */
2085 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2086 lpfc_disc_illegal
, /* DEVICE_RM */
2087 lpfc_device_recov_mapped_node
, /* DEVICE_RECOVERY */
2089 lpfc_rcv_plogi_npr_node
, /* RCV_PLOGI NPR_NODE */
2090 lpfc_rcv_prli_npr_node
, /* RCV_PRLI */
2091 lpfc_rcv_logo_npr_node
, /* RCV_LOGO */
2092 lpfc_rcv_padisc_npr_node
, /* RCV_ADISC */
2093 lpfc_rcv_padisc_npr_node
, /* RCV_PDISC */
2094 lpfc_rcv_prlo_npr_node
, /* RCV_PRLO */
2095 lpfc_cmpl_plogi_npr_node
, /* CMPL_PLOGI */
2096 lpfc_cmpl_prli_npr_node
, /* CMPL_PRLI */
2097 lpfc_cmpl_logo_npr_node
, /* CMPL_LOGO */
2098 lpfc_cmpl_adisc_npr_node
, /* CMPL_ADISC */
2099 lpfc_cmpl_reglogin_npr_node
, /* CMPL_REG_LOGIN */
2100 lpfc_device_rm_npr_node
, /* DEVICE_RM */
2101 lpfc_device_recov_npr_node
, /* DEVICE_RECOVERY */
2105 lpfc_disc_state_machine(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2106 void *arg
, uint32_t evt
)
2108 uint32_t cur_state
, rc
;
2109 uint32_t(*func
) (struct lpfc_vport
*, struct lpfc_nodelist
*, void *,
2111 uint32_t got_ndlp
= 0;
2113 if (lpfc_nlp_get(ndlp
))
2116 cur_state
= ndlp
->nlp_state
;
2118 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
2119 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2120 "0211 DSM in event x%x on NPort x%x in "
2121 "state %d Data: x%x\n",
2122 evt
, ndlp
->nlp_DID
, cur_state
, ndlp
->nlp_flag
);
2124 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2125 "DSM in: evt:%d ste:%d did:x%x",
2126 evt
, cur_state
, ndlp
->nlp_DID
);
2128 func
= lpfc_disc_action
[(cur_state
* NLP_EVT_MAX_EVENT
) + evt
];
2129 rc
= (func
) (vport
, ndlp
, arg
, evt
);
2131 /* DSM out state <rc> on NPort <nlp_DID> */
2133 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2134 "0212 DSM out state %d on NPort x%x Data: x%x\n",
2135 rc
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
2137 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2138 "DSM out: ste:%d did:x%x flg:x%x",
2139 rc
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
2140 /* Decrement the ndlp reference count held for this function */
2143 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2144 "0213 DSM out state %d on NPort free\n", rc
);
2146 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2147 "DSM out: ste:%d did:x%x flg:x%x",