1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Limited and/or its subsidiaries. *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *
9 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
11 * This program is free software; you can redistribute it and/or *
12 * modify it under the terms of version 2 of the GNU General *
13 * Public License as published by the Free Software Foundation. *
14 * This program is distributed in the hope that it will be useful. *
15 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
16 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
17 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
18 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
19 * TO BE LEGALLY INVALID. See the GNU General Public License for *
20 * more details, a copy of which can be found in the file COPYING *
21 * included with this package. *
22 *******************************************************************/
24 #include <linux/blkdev.h>
25 #include <linux/pci.h>
26 #include <linux/slab.h>
27 #include <linux/interrupt.h>
29 #include <scsi/scsi.h>
30 #include <scsi/scsi_device.h>
31 #include <scsi/scsi_host.h>
32 #include <scsi/scsi_transport_fc.h>
33 #include <scsi/fc/fc_fs.h>
35 #include <linux/nvme-fc-driver.h>
40 #include "lpfc_sli4.h"
42 #include "lpfc_disc.h"
44 #include "lpfc_scsi.h"
45 #include "lpfc_nvme.h"
46 #include "lpfc_logmsg.h"
47 #include "lpfc_crtn.h"
48 #include "lpfc_vport.h"
49 #include "lpfc_debugfs.h"
52 /* Called to verify a rcv'ed ADISC was intended for us. */
54 lpfc_check_adisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
55 struct lpfc_name
*nn
, struct lpfc_name
*pn
)
57 /* First, we MUST have a RPI registered */
58 if (!(ndlp
->nlp_flag
& NLP_RPI_REGISTERED
))
61 /* Compare the ADISC rsp WWNN / WWPN matches our internal node
62 * table entry for that node.
64 if (memcmp(nn
, &ndlp
->nlp_nodename
, sizeof (struct lpfc_name
)))
67 if (memcmp(pn
, &ndlp
->nlp_portname
, sizeof (struct lpfc_name
)))
70 /* we match, return success */
75 lpfc_check_sparm(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
76 struct serv_parm
*sp
, uint32_t class, int flogi
)
78 volatile struct serv_parm
*hsp
= &vport
->fc_sparam
;
79 uint16_t hsp_value
, ssp_value
= 0;
82 * The receive data field size and buffer-to-buffer receive data field
83 * size entries are 16 bits but are represented as two 8-bit fields in
84 * the driver data structure to account for rsvd bits and other control
85 * bits. Reconstruct and compare the fields as a 16-bit values before
86 * correcting the byte values.
88 if (sp
->cls1
.classValid
) {
90 hsp_value
= ((hsp
->cls1
.rcvDataSizeMsb
<< 8) |
91 hsp
->cls1
.rcvDataSizeLsb
);
92 ssp_value
= ((sp
->cls1
.rcvDataSizeMsb
<< 8) |
93 sp
->cls1
.rcvDataSizeLsb
);
95 goto bad_service_param
;
96 if (ssp_value
> hsp_value
) {
97 sp
->cls1
.rcvDataSizeLsb
=
98 hsp
->cls1
.rcvDataSizeLsb
;
99 sp
->cls1
.rcvDataSizeMsb
=
100 hsp
->cls1
.rcvDataSizeMsb
;
103 } else if (class == CLASS1
)
104 goto bad_service_param
;
105 if (sp
->cls2
.classValid
) {
107 hsp_value
= ((hsp
->cls2
.rcvDataSizeMsb
<< 8) |
108 hsp
->cls2
.rcvDataSizeLsb
);
109 ssp_value
= ((sp
->cls2
.rcvDataSizeMsb
<< 8) |
110 sp
->cls2
.rcvDataSizeLsb
);
112 goto bad_service_param
;
113 if (ssp_value
> hsp_value
) {
114 sp
->cls2
.rcvDataSizeLsb
=
115 hsp
->cls2
.rcvDataSizeLsb
;
116 sp
->cls2
.rcvDataSizeMsb
=
117 hsp
->cls2
.rcvDataSizeMsb
;
120 } else if (class == CLASS2
)
121 goto bad_service_param
;
122 if (sp
->cls3
.classValid
) {
124 hsp_value
= ((hsp
->cls3
.rcvDataSizeMsb
<< 8) |
125 hsp
->cls3
.rcvDataSizeLsb
);
126 ssp_value
= ((sp
->cls3
.rcvDataSizeMsb
<< 8) |
127 sp
->cls3
.rcvDataSizeLsb
);
129 goto bad_service_param
;
130 if (ssp_value
> hsp_value
) {
131 sp
->cls3
.rcvDataSizeLsb
=
132 hsp
->cls3
.rcvDataSizeLsb
;
133 sp
->cls3
.rcvDataSizeMsb
=
134 hsp
->cls3
.rcvDataSizeMsb
;
137 } else if (class == CLASS3
)
138 goto bad_service_param
;
141 * Preserve the upper four bits of the MSB from the PLOGI response.
142 * These bits contain the Buffer-to-Buffer State Change Number
143 * from the target and need to be passed to the FW.
145 hsp_value
= (hsp
->cmn
.bbRcvSizeMsb
<< 8) | hsp
->cmn
.bbRcvSizeLsb
;
146 ssp_value
= (sp
->cmn
.bbRcvSizeMsb
<< 8) | sp
->cmn
.bbRcvSizeLsb
;
147 if (ssp_value
> hsp_value
) {
148 sp
->cmn
.bbRcvSizeLsb
= hsp
->cmn
.bbRcvSizeLsb
;
149 sp
->cmn
.bbRcvSizeMsb
= (sp
->cmn
.bbRcvSizeMsb
& 0xF0) |
150 (hsp
->cmn
.bbRcvSizeMsb
& 0x0F);
153 memcpy(&ndlp
->nlp_nodename
, &sp
->nodeName
, sizeof (struct lpfc_name
));
154 memcpy(&ndlp
->nlp_portname
, &sp
->portName
, sizeof (struct lpfc_name
));
157 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
159 "(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x) sent "
160 "invalid service parameters. Ignoring device.\n",
162 sp
->nodeName
.u
.wwn
[0], sp
->nodeName
.u
.wwn
[1],
163 sp
->nodeName
.u
.wwn
[2], sp
->nodeName
.u
.wwn
[3],
164 sp
->nodeName
.u
.wwn
[4], sp
->nodeName
.u
.wwn
[5],
165 sp
->nodeName
.u
.wwn
[6], sp
->nodeName
.u
.wwn
[7]);
170 lpfc_check_elscmpl_iocb(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
171 struct lpfc_iocbq
*rspiocb
)
173 struct lpfc_dmabuf
*pcmd
, *prsp
;
178 irsp
= &rspiocb
->iocb
;
179 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
181 /* For lpfc_els_abort, context2 could be zero'ed to delay
182 * freeing associated memory till after ABTS completes.
185 prsp
= list_get_first(&pcmd
->list
, struct lpfc_dmabuf
,
188 lp
= (uint32_t *) prsp
->virt
;
189 ptr
= (void *)((uint8_t *)lp
+ sizeof(uint32_t));
192 /* Force ulpStatus error since we are returning NULL ptr */
193 if (!(irsp
->ulpStatus
)) {
194 irsp
->ulpStatus
= IOSTAT_LOCAL_REJECT
;
195 irsp
->un
.ulpWord
[4] = IOERR_SLI_ABORTED
;
205 * Free resources / clean up outstanding I/Os
206 * associated with a LPFC_NODELIST entry. This
207 * routine effectively results in a "software abort".
210 lpfc_els_abort(struct lpfc_hba
*phba
, struct lpfc_nodelist
*ndlp
)
212 LIST_HEAD(abort_list
);
213 struct lpfc_sli_ring
*pring
;
214 struct lpfc_iocbq
*iocb
, *next_iocb
;
216 pring
= lpfc_phba_elsring(phba
);
218 /* Abort outstanding I/O on NPort <nlp_DID> */
219 lpfc_printf_vlog(ndlp
->vport
, KERN_INFO
, LOG_DISCOVERY
,
220 "2819 Abort outstanding I/O on NPort x%x "
221 "Data: x%x x%x x%x\n",
222 ndlp
->nlp_DID
, ndlp
->nlp_flag
, ndlp
->nlp_state
,
224 /* Clean up all fabric IOs first.*/
225 lpfc_fabric_abort_nport(ndlp
);
228 * Lock the ELS ring txcmplq for SLI3/SLI4 and build a local list
229 * of all ELS IOs that need an ABTS. The IOs need to stay on the
230 * txcmplq so that the abort operation completes them successfully.
232 spin_lock_irq(&phba
->hbalock
);
233 if (phba
->sli_rev
== LPFC_SLI_REV4
)
234 spin_lock(&pring
->ring_lock
);
235 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txcmplq
, list
) {
236 /* Add to abort_list on on NDLP match. */
237 if (lpfc_check_sli_ndlp(phba
, pring
, iocb
, ndlp
))
238 list_add_tail(&iocb
->dlist
, &abort_list
);
240 if (phba
->sli_rev
== LPFC_SLI_REV4
)
241 spin_unlock(&pring
->ring_lock
);
242 spin_unlock_irq(&phba
->hbalock
);
244 /* Abort the targeted IOs and remove them from the abort list. */
245 list_for_each_entry_safe(iocb
, next_iocb
, &abort_list
, dlist
) {
246 spin_lock_irq(&phba
->hbalock
);
247 list_del_init(&iocb
->dlist
);
248 lpfc_sli_issue_abort_iotag(phba
, pring
, iocb
);
249 spin_unlock_irq(&phba
->hbalock
);
252 INIT_LIST_HEAD(&abort_list
);
254 /* Now process the txq */
255 spin_lock_irq(&phba
->hbalock
);
256 if (phba
->sli_rev
== LPFC_SLI_REV4
)
257 spin_lock(&pring
->ring_lock
);
259 list_for_each_entry_safe(iocb
, next_iocb
, &pring
->txq
, list
) {
260 /* Check to see if iocb matches the nport we are looking for */
261 if (lpfc_check_sli_ndlp(phba
, pring
, iocb
, ndlp
)) {
262 list_del_init(&iocb
->list
);
263 list_add_tail(&iocb
->list
, &abort_list
);
267 if (phba
->sli_rev
== LPFC_SLI_REV4
)
268 spin_unlock(&pring
->ring_lock
);
269 spin_unlock_irq(&phba
->hbalock
);
271 /* Cancel all the IOCBs from the completions list */
272 lpfc_sli_cancel_iocbs(phba
, &abort_list
,
273 IOSTAT_LOCAL_REJECT
, IOERR_SLI_ABORTED
);
275 lpfc_cancel_retry_delay_tmo(phba
->pport
, ndlp
);
280 lpfc_rcv_plogi(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
281 struct lpfc_iocbq
*cmdiocb
)
283 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
284 struct lpfc_hba
*phba
= vport
->phba
;
285 struct lpfc_dmabuf
*pcmd
;
286 uint64_t nlp_portwwn
= 0;
289 struct serv_parm
*sp
;
296 memset(&stat
, 0, sizeof (struct ls_rjt
));
297 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
298 lp
= (uint32_t *) pcmd
->virt
;
299 sp
= (struct serv_parm
*) ((uint8_t *) lp
+ sizeof (uint32_t));
300 if (wwn_to_u64(sp
->portName
.u
.wwn
) == 0) {
301 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
302 "0140 PLOGI Reject: invalid nname\n");
303 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
304 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_INVALID_PNAME
;
305 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
309 if (wwn_to_u64(sp
->nodeName
.u
.wwn
) == 0) {
310 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
311 "0141 PLOGI Reject: invalid pname\n");
312 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
313 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_INVALID_NNAME
;
314 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
319 nlp_portwwn
= wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
);
320 if ((lpfc_check_sparm(vport
, ndlp
, sp
, CLASS3
, 0) == 0)) {
321 /* Reject this request because invalid parameters */
322 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
323 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_SPARM_OPTIONS
;
324 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
328 icmd
= &cmdiocb
->iocb
;
330 /* PLOGI chkparm OK */
331 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
332 "0114 PLOGI chkparm OK Data: x%x x%x x%x "
334 ndlp
->nlp_DID
, ndlp
->nlp_state
, ndlp
->nlp_flag
,
335 ndlp
->nlp_rpi
, vport
->port_state
,
338 if (vport
->cfg_fcp_class
== 2 && sp
->cls2
.classValid
)
339 ndlp
->nlp_fcp_info
|= CLASS2
;
341 ndlp
->nlp_fcp_info
|= CLASS3
;
343 ndlp
->nlp_class_sup
= 0;
344 if (sp
->cls1
.classValid
)
345 ndlp
->nlp_class_sup
|= FC_COS_CLASS1
;
346 if (sp
->cls2
.classValid
)
347 ndlp
->nlp_class_sup
|= FC_COS_CLASS2
;
348 if (sp
->cls3
.classValid
)
349 ndlp
->nlp_class_sup
|= FC_COS_CLASS3
;
350 if (sp
->cls4
.classValid
)
351 ndlp
->nlp_class_sup
|= FC_COS_CLASS4
;
353 ((sp
->cmn
.bbRcvSizeMsb
& 0x0F) << 8) | sp
->cmn
.bbRcvSizeLsb
;
355 /* if already logged in, do implicit logout */
356 switch (ndlp
->nlp_state
) {
357 case NLP_STE_NPR_NODE
:
358 if (!(ndlp
->nlp_flag
& NLP_NPR_ADISC
))
360 case NLP_STE_REG_LOGIN_ISSUE
:
361 case NLP_STE_PRLI_ISSUE
:
362 case NLP_STE_UNMAPPED_NODE
:
363 case NLP_STE_MAPPED_NODE
:
364 /* For initiators, lpfc_plogi_confirm_nport skips fabric did.
365 * For target mode, execute implicit logo.
366 * Fabric nodes go into NPR.
368 if (!(ndlp
->nlp_type
& NLP_FABRIC
) &&
369 !(phba
->nvmet_support
)) {
370 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
,
374 if (nlp_portwwn
!= 0 &&
375 nlp_portwwn
!= wwn_to_u64(sp
->portName
.u
.wwn
))
376 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
377 "0143 PLOGI recv'd from DID: x%x "
378 "WWPN changed: old %llx new %llx\n",
380 (unsigned long long)nlp_portwwn
,
382 wwn_to_u64(sp
->portName
.u
.wwn
));
384 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
385 /* rport needs to be unregistered first */
386 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
390 /* Check for Nport to NPort pt2pt protocol */
391 if ((vport
->fc_flag
& FC_PT2PT
) &&
392 !(vport
->fc_flag
& FC_PT2PT_PLOGI
)) {
393 /* rcv'ed PLOGI decides what our NPortId will be */
394 vport
->fc_myDID
= icmd
->un
.rcvels
.parmRo
;
396 ed_tov
= be32_to_cpu(sp
->cmn
.e_d_tov
);
397 if (sp
->cmn
.edtovResolution
) {
398 /* E_D_TOV ticks are in nanoseconds */
399 ed_tov
= (phba
->fc_edtov
+ 999999) / 1000000;
403 * For pt-to-pt, use the larger EDTOV
406 if (ed_tov
> phba
->fc_edtov
)
407 phba
->fc_edtov
= ed_tov
;
408 phba
->fc_ratov
= (2 * phba
->fc_edtov
) / 1000;
410 memcpy(&phba
->fc_fabparam
, sp
, sizeof(struct serv_parm
));
412 /* Issue config_link / reg_vfi to account for updated TOV's */
414 if (phba
->sli_rev
== LPFC_SLI_REV4
)
415 lpfc_issue_reg_vfi(vport
);
417 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
420 lpfc_config_link(phba
, mbox
);
421 mbox
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
423 rc
= lpfc_sli_issue_mbox(phba
, mbox
, MBX_NOWAIT
);
424 if (rc
== MBX_NOT_FINISHED
) {
425 mempool_free(mbox
, phba
->mbox_mem_pool
);
430 lpfc_can_disctmo(vport
);
433 ndlp
->nlp_flag
&= ~NLP_SUPPRESS_RSP
;
434 if ((phba
->sli
.sli_flag
& LPFC_SLI_SUPPRESS_RSP
) &&
435 sp
->cmn
.valid_vendor_ver_level
) {
436 vid
= be32_to_cpu(sp
->un
.vv
.vid
);
437 flag
= be32_to_cpu(sp
->un
.vv
.flags
);
438 if ((vid
== LPFC_VV_EMLX_ID
) && (flag
& LPFC_VV_SUPPRESS_RSP
))
439 ndlp
->nlp_flag
|= NLP_SUPPRESS_RSP
;
442 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
446 /* Registering an existing RPI behaves differently for SLI3 vs SLI4 */
447 if (phba
->sli_rev
== LPFC_SLI_REV4
)
448 lpfc_unreg_rpi(vport
, ndlp
);
450 rc
= lpfc_reg_rpi(phba
, vport
->vpi
, icmd
->un
.rcvels
.remoteID
,
451 (uint8_t *) sp
, mbox
, ndlp
->nlp_rpi
);
453 mempool_free(mbox
, phba
->mbox_mem_pool
);
457 /* ACC PLOGI rsp command needs to execute first,
458 * queue this mbox command to be processed later.
460 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_reg_login
;
462 * mbox->context2 = lpfc_nlp_get(ndlp) deferred until mailbox
463 * command issued in lpfc_cmpl_els_acc().
466 spin_lock_irq(shost
->host_lock
);
467 ndlp
->nlp_flag
|= (NLP_ACC_REGLOGIN
| NLP_RCV_PLOGI
);
468 spin_unlock_irq(shost
->host_lock
);
471 * If there is an outstanding PLOGI issued, abort it before
472 * sending ACC rsp for received PLOGI. If pending plogi
473 * is not canceled here, the plogi will be rejected by
474 * remote port and will be retried. On a configuration with
475 * single discovery thread, this will cause a huge delay in
476 * discovery. Also this will cause multiple state machines
477 * running in parallel for this node.
479 if (ndlp
->nlp_state
== NLP_STE_PLOGI_ISSUE
) {
480 /* software abort outstanding PLOGI */
481 lpfc_els_abort(phba
, ndlp
);
484 if ((vport
->port_type
== LPFC_NPIV_PORT
&&
485 vport
->cfg_restrict_login
)) {
487 /* In order to preserve RPIs, we want to cleanup
488 * the default RPI the firmware created to rcv
489 * this ELS request. The only way to do this is
490 * to register, then unregister the RPI.
492 spin_lock_irq(shost
->host_lock
);
493 ndlp
->nlp_flag
|= NLP_RM_DFLT_RPI
;
494 spin_unlock_irq(shost
->host_lock
);
495 stat
.un
.b
.lsRjtRsnCode
= LSRJT_INVALID_CMD
;
496 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
497 rc
= lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
,
500 mempool_free(mbox
, phba
->mbox_mem_pool
);
503 rc
= lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
, ndlp
, mbox
);
505 mempool_free(mbox
, phba
->mbox_mem_pool
);
508 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
509 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_OUT_OF_RESOURCE
;
510 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
515 * lpfc_mbx_cmpl_resume_rpi - Resume RPI completion routine
516 * @phba: pointer to lpfc hba data structure.
517 * @mboxq: pointer to mailbox object
519 * This routine is invoked to issue a completion to a rcv'ed
520 * ADISC or PDISC after the paused RPI has been resumed.
523 lpfc_mbx_cmpl_resume_rpi(struct lpfc_hba
*phba
, LPFC_MBOXQ_t
*mboxq
)
525 struct lpfc_vport
*vport
;
526 struct lpfc_iocbq
*elsiocb
;
527 struct lpfc_nodelist
*ndlp
;
530 elsiocb
= (struct lpfc_iocbq
*)mboxq
->context1
;
531 ndlp
= (struct lpfc_nodelist
*) mboxq
->context2
;
532 vport
= mboxq
->vport
;
533 cmd
= elsiocb
->drvrTimeout
;
535 if (cmd
== ELS_CMD_ADISC
) {
536 lpfc_els_rsp_adisc_acc(vport
, elsiocb
, ndlp
);
538 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, elsiocb
,
542 mempool_free(mboxq
, phba
->mbox_mem_pool
);
546 lpfc_rcv_padisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
547 struct lpfc_iocbq
*cmdiocb
)
549 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
550 struct lpfc_iocbq
*elsiocb
;
551 struct lpfc_dmabuf
*pcmd
;
552 struct serv_parm
*sp
;
553 struct lpfc_name
*pnn
, *ppn
;
560 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
561 lp
= (uint32_t *) pcmd
->virt
;
564 if (cmd
== ELS_CMD_ADISC
) {
566 pnn
= (struct lpfc_name
*) & ap
->nodeName
;
567 ppn
= (struct lpfc_name
*) & ap
->portName
;
569 sp
= (struct serv_parm
*) lp
;
570 pnn
= (struct lpfc_name
*) & sp
->nodeName
;
571 ppn
= (struct lpfc_name
*) & sp
->portName
;
574 icmd
= &cmdiocb
->iocb
;
575 if (icmd
->ulpStatus
== 0 && lpfc_check_adisc(vport
, ndlp
, pnn
, ppn
)) {
578 * As soon as we send ACC, the remote NPort can
579 * start sending us data. Thus, for SLI4 we must
580 * resume the RPI before the ACC goes out.
582 if (vport
->phba
->sli_rev
== LPFC_SLI_REV4
) {
583 elsiocb
= kmalloc(sizeof(struct lpfc_iocbq
),
587 /* Save info from cmd IOCB used in rsp */
588 memcpy((uint8_t *)elsiocb
, (uint8_t *)cmdiocb
,
589 sizeof(struct lpfc_iocbq
));
591 /* Save the ELS cmd */
592 elsiocb
->drvrTimeout
= cmd
;
594 lpfc_sli4_resume_rpi(ndlp
,
595 lpfc_mbx_cmpl_resume_rpi
, elsiocb
);
600 if (cmd
== ELS_CMD_ADISC
) {
601 lpfc_els_rsp_adisc_acc(vport
, cmdiocb
, ndlp
);
603 lpfc_els_rsp_acc(vport
, ELS_CMD_PLOGI
, cmdiocb
,
607 /* If we are authenticated, move to the proper state */
608 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
609 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_MAPPED_NODE
);
611 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
615 /* Reject this request because invalid parameters */
616 stat
.un
.b
.lsRjtRsvd0
= 0;
617 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
618 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_SPARM_OPTIONS
;
619 stat
.un
.b
.vendorUnique
= 0;
620 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
623 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ msecs_to_jiffies(1000));
625 spin_lock_irq(shost
->host_lock
);
626 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
627 spin_unlock_irq(shost
->host_lock
);
628 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
629 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
630 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
635 lpfc_rcv_logo(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
636 struct lpfc_iocbq
*cmdiocb
, uint32_t els_cmd
)
638 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
639 struct lpfc_hba
*phba
= vport
->phba
;
640 struct lpfc_vport
**vports
;
641 int i
, active_vlink_present
= 0 ;
643 /* Put ndlp in NPR state with 1 sec timeout for plogi, ACC logo */
644 /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary
645 * PLOGIs during LOGO storms from a device.
647 spin_lock_irq(shost
->host_lock
);
648 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
649 spin_unlock_irq(shost
->host_lock
);
650 if (els_cmd
== ELS_CMD_PRLO
)
651 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
653 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
654 if (ndlp
->nlp_DID
== Fabric_DID
) {
655 if (vport
->port_state
<= LPFC_FDISC
)
657 lpfc_linkdown_port(vport
);
658 spin_lock_irq(shost
->host_lock
);
659 vport
->fc_flag
|= FC_VPORT_LOGO_RCVD
;
660 spin_unlock_irq(shost
->host_lock
);
661 vports
= lpfc_create_vport_work_array(phba
);
663 for (i
= 0; i
<= phba
->max_vports
&& vports
[i
] != NULL
;
665 if ((!(vports
[i
]->fc_flag
&
666 FC_VPORT_LOGO_RCVD
)) &&
667 (vports
[i
]->port_state
> LPFC_FDISC
)) {
668 active_vlink_present
= 1;
672 lpfc_destroy_vport_work_array(phba
, vports
);
676 * Don't re-instantiate if vport is marked for deletion.
677 * If we are here first then vport_delete is going to wait
678 * for discovery to complete.
680 if (!(vport
->load_flag
& FC_UNLOADING
) &&
681 active_vlink_present
) {
683 * If there are other active VLinks present,
684 * re-instantiate the Vlink using FDISC.
686 mod_timer(&ndlp
->nlp_delayfunc
,
687 jiffies
+ msecs_to_jiffies(1000));
688 spin_lock_irq(shost
->host_lock
);
689 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
690 spin_unlock_irq(shost
->host_lock
);
691 ndlp
->nlp_last_elscmd
= ELS_CMD_FDISC
;
692 vport
->port_state
= LPFC_FDISC
;
694 spin_lock_irq(shost
->host_lock
);
695 phba
->pport
->fc_flag
&= ~FC_LOGO_RCVD_DID_CHNG
;
696 spin_unlock_irq(shost
->host_lock
);
697 lpfc_retry_pport_discovery(phba
);
699 } else if ((!(ndlp
->nlp_type
& NLP_FABRIC
) &&
700 ((ndlp
->nlp_type
& NLP_FCP_TARGET
) ||
701 !(ndlp
->nlp_type
& NLP_FCP_INITIATOR
))) ||
702 (ndlp
->nlp_state
== NLP_STE_ADISC_ISSUE
)) {
703 /* Only try to re-login if this is NOT a Fabric Node */
704 mod_timer(&ndlp
->nlp_delayfunc
,
705 jiffies
+ msecs_to_jiffies(1000 * 1));
706 spin_lock_irq(shost
->host_lock
);
707 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
708 spin_unlock_irq(shost
->host_lock
);
710 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
713 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
714 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
716 spin_lock_irq(shost
->host_lock
);
717 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
718 spin_unlock_irq(shost
->host_lock
);
719 /* The driver has to wait until the ACC completes before it continues
720 * processing the LOGO. The action will resume in
721 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
722 * unreg_login, the driver waits so the ACC does not get aborted.
728 lpfc_rcv_prli(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
729 struct lpfc_iocbq
*cmdiocb
)
731 struct lpfc_hba
*phba
= vport
->phba
;
732 struct lpfc_dmabuf
*pcmd
;
735 struct fc_rport
*rport
= ndlp
->rport
;
738 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
739 lp
= (uint32_t *) pcmd
->virt
;
740 npr
= (PRLI
*) ((uint8_t *) lp
+ sizeof (uint32_t));
742 ndlp
->nlp_type
&= ~(NLP_FCP_TARGET
| NLP_FCP_INITIATOR
);
743 ndlp
->nlp_fcp_info
&= ~NLP_FCP_2_DEVICE
;
744 ndlp
->nlp_flag
&= ~NLP_FIRSTBURST
;
745 if ((npr
->prliType
== PRLI_FCP_TYPE
) ||
746 (npr
->prliType
== PRLI_NVME_TYPE
)) {
747 if (npr
->initiatorFunc
) {
748 if (npr
->prliType
== PRLI_FCP_TYPE
)
749 ndlp
->nlp_type
|= NLP_FCP_INITIATOR
;
750 if (npr
->prliType
== PRLI_NVME_TYPE
)
751 ndlp
->nlp_type
|= NLP_NVME_INITIATOR
;
753 if (npr
->targetFunc
) {
754 if (npr
->prliType
== PRLI_FCP_TYPE
)
755 ndlp
->nlp_type
|= NLP_FCP_TARGET
;
756 if (npr
->prliType
== PRLI_NVME_TYPE
)
757 ndlp
->nlp_type
|= NLP_NVME_TARGET
;
758 if (npr
->writeXferRdyDis
)
759 ndlp
->nlp_flag
|= NLP_FIRSTBURST
;
762 ndlp
->nlp_fcp_info
|= NLP_FCP_2_DEVICE
;
764 /* If this driver is in nvme target mode, set the ndlp's fc4
765 * type to NVME provided the PRLI response claims NVME FC4
766 * type. Target mode does not issue gft_id so doesn't get
767 * the fc4 type set until now.
769 if ((phba
->nvmet_support
) && (npr
->prliType
== PRLI_NVME_TYPE
))
770 ndlp
->nlp_fc4_type
|= NLP_FC4_NVME
;
773 /* We need to update the rport role values */
774 roles
= FC_RPORT_ROLE_UNKNOWN
;
775 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
776 roles
|= FC_RPORT_ROLE_FCP_INITIATOR
;
777 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
778 roles
|= FC_RPORT_ROLE_FCP_TARGET
;
780 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_RPORT
,
781 "rport rolechg: role:x%x did:x%x flg:x%x",
782 roles
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
784 if (phba
->cfg_enable_fc4_type
!= LPFC_ENABLE_NVME
)
785 fc_remote_port_rolechg(rport
, roles
);
790 lpfc_disc_set_adisc(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
)
792 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
794 if (!(ndlp
->nlp_flag
& NLP_RPI_REGISTERED
)) {
795 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
799 if (!(vport
->fc_flag
& FC_PT2PT
)) {
800 /* Check config parameter use-adisc or FCP-2 */
801 if ((vport
->cfg_use_adisc
&& (vport
->fc_flag
& FC_RSCN_MODE
)) ||
802 ((ndlp
->nlp_fcp_info
& NLP_FCP_2_DEVICE
) &&
803 (ndlp
->nlp_type
& NLP_FCP_TARGET
))) {
804 spin_lock_irq(shost
->host_lock
);
805 ndlp
->nlp_flag
|= NLP_NPR_ADISC
;
806 spin_unlock_irq(shost
->host_lock
);
810 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
811 lpfc_unreg_rpi(vport
, ndlp
);
816 * lpfc_release_rpi - Release a RPI by issuing unreg_login mailbox cmd.
817 * @phba : Pointer to lpfc_hba structure.
818 * @vport: Pointer to lpfc_vport structure.
819 * @rpi : rpi to be release.
821 * This function will send a unreg_login mailbox command to the firmware
825 lpfc_release_rpi(struct lpfc_hba
*phba
,
826 struct lpfc_vport
*vport
,
832 pmb
= (LPFC_MBOXQ_t
*) mempool_alloc(phba
->mbox_mem_pool
,
835 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_MBOX
,
836 "2796 mailbox memory allocation failed \n");
838 lpfc_unreg_login(phba
, vport
->vpi
, rpi
, pmb
);
839 pmb
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
840 rc
= lpfc_sli_issue_mbox(phba
, pmb
, MBX_NOWAIT
);
841 if (rc
== MBX_NOT_FINISHED
)
842 mempool_free(pmb
, phba
->mbox_mem_pool
);
847 lpfc_disc_illegal(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
848 void *arg
, uint32_t evt
)
850 struct lpfc_hba
*phba
;
851 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
855 /* Release the RPI if reglogin completing */
856 if (!(phba
->pport
->load_flag
& FC_UNLOADING
) &&
857 (evt
== NLP_EVT_CMPL_REG_LOGIN
) &&
858 (!pmb
->u
.mb
.mbxStatus
)) {
859 rpi
= pmb
->u
.mb
.un
.varWords
[0];
860 lpfc_release_rpi(phba
, vport
, rpi
);
862 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
863 "0271 Illegal State Transition: node x%x "
864 "event x%x, state x%x Data: x%x x%x\n",
865 ndlp
->nlp_DID
, evt
, ndlp
->nlp_state
, ndlp
->nlp_rpi
,
867 return ndlp
->nlp_state
;
871 lpfc_cmpl_plogi_illegal(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
872 void *arg
, uint32_t evt
)
874 /* This transition is only legal if we previously
875 * rcv'ed a PLOGI. Since we don't want 2 discovery threads
876 * working on the same NPortID, do nothing for this thread
879 if (!(ndlp
->nlp_flag
& NLP_RCV_PLOGI
)) {
880 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
881 "0272 Illegal State Transition: node x%x "
882 "event x%x, state x%x Data: x%x x%x\n",
883 ndlp
->nlp_DID
, evt
, ndlp
->nlp_state
, ndlp
->nlp_rpi
,
886 return ndlp
->nlp_state
;
889 /* Start of Discovery State Machine routines */
892 lpfc_rcv_plogi_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
893 void *arg
, uint32_t evt
)
895 struct lpfc_iocbq
*cmdiocb
;
897 cmdiocb
= (struct lpfc_iocbq
*) arg
;
899 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
900 return ndlp
->nlp_state
;
902 return NLP_STE_FREED_NODE
;
906 lpfc_rcv_els_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
907 void *arg
, uint32_t evt
)
909 lpfc_issue_els_logo(vport
, ndlp
, 0);
910 return ndlp
->nlp_state
;
914 lpfc_rcv_logo_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
915 void *arg
, uint32_t evt
)
917 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
918 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
920 spin_lock_irq(shost
->host_lock
);
921 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
922 spin_unlock_irq(shost
->host_lock
);
923 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
925 return ndlp
->nlp_state
;
929 lpfc_cmpl_logo_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
930 void *arg
, uint32_t evt
)
932 return NLP_STE_FREED_NODE
;
936 lpfc_device_rm_unused_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
937 void *arg
, uint32_t evt
)
939 return NLP_STE_FREED_NODE
;
943 lpfc_device_recov_unused_node(struct lpfc_vport
*vport
,
944 struct lpfc_nodelist
*ndlp
,
945 void *arg
, uint32_t evt
)
947 return ndlp
->nlp_state
;
951 lpfc_rcv_plogi_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
952 void *arg
, uint32_t evt
)
954 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
955 struct lpfc_hba
*phba
= vport
->phba
;
956 struct lpfc_iocbq
*cmdiocb
= arg
;
957 struct lpfc_dmabuf
*pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
958 uint32_t *lp
= (uint32_t *) pcmd
->virt
;
959 struct serv_parm
*sp
= (struct serv_parm
*) (lp
+ 1);
963 memset(&stat
, 0, sizeof (struct ls_rjt
));
965 /* For a PLOGI, we only accept if our portname is less
966 * than the remote portname.
968 phba
->fc_stat
.elsLogiCol
++;
969 port_cmp
= memcmp(&vport
->fc_portname
, &sp
->portName
,
970 sizeof(struct lpfc_name
));
973 /* Reject this request because the remote node will accept
975 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
976 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_CMD_IN_PROGRESS
;
977 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
,
980 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
) &&
981 (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) &&
982 (vport
->num_disc_nodes
)) {
983 spin_lock_irq(shost
->host_lock
);
984 ndlp
->nlp_flag
&= ~NLP_NPR_2B_DISC
;
985 spin_unlock_irq(shost
->host_lock
);
986 /* Check if there are more PLOGIs to be sent */
987 lpfc_more_plogi(vport
);
988 if (vport
->num_disc_nodes
== 0) {
989 spin_lock_irq(shost
->host_lock
);
990 vport
->fc_flag
&= ~FC_NDISC_ACTIVE
;
991 spin_unlock_irq(shost
->host_lock
);
992 lpfc_can_disctmo(vport
);
993 lpfc_end_rscn(vport
);
996 } /* If our portname was less */
998 return ndlp
->nlp_state
;
1002 lpfc_rcv_prli_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1003 void *arg
, uint32_t evt
)
1005 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1008 memset(&stat
, 0, sizeof (struct ls_rjt
));
1009 stat
.un
.b
.lsRjtRsnCode
= LSRJT_LOGICAL_BSY
;
1010 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
1011 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
1012 return ndlp
->nlp_state
;
1016 lpfc_rcv_logo_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1017 void *arg
, uint32_t evt
)
1019 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1021 /* software abort outstanding PLOGI */
1022 lpfc_els_abort(vport
->phba
, ndlp
);
1024 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1025 return ndlp
->nlp_state
;
1029 lpfc_rcv_els_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1030 void *arg
, uint32_t evt
)
1032 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1033 struct lpfc_hba
*phba
= vport
->phba
;
1034 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1036 /* software abort outstanding PLOGI */
1037 lpfc_els_abort(phba
, ndlp
);
1039 if (evt
== NLP_EVT_RCV_LOGO
) {
1040 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
1042 lpfc_issue_els_logo(vport
, ndlp
, 0);
1045 /* Put ndlp in npr state set plogi timer for 1 sec */
1046 mod_timer(&ndlp
->nlp_delayfunc
, jiffies
+ msecs_to_jiffies(1000 * 1));
1047 spin_lock_irq(shost
->host_lock
);
1048 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1049 spin_unlock_irq(shost
->host_lock
);
1050 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1051 ndlp
->nlp_prev_state
= NLP_STE_PLOGI_ISSUE
;
1052 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1054 return ndlp
->nlp_state
;
1058 lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport
*vport
,
1059 struct lpfc_nodelist
*ndlp
,
1063 struct lpfc_hba
*phba
= vport
->phba
;
1064 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1065 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1066 struct lpfc_dmabuf
*pcmd
, *prsp
, *mp
;
1070 struct serv_parm
*sp
;
1075 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1076 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1078 if (ndlp
->nlp_flag
& NLP_ACC_REGLOGIN
) {
1079 /* Recovery from PLOGI collision logic */
1080 return ndlp
->nlp_state
;
1083 irsp
= &rspiocb
->iocb
;
1085 if (irsp
->ulpStatus
)
1088 pcmd
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1090 prsp
= list_get_first(&pcmd
->list
, struct lpfc_dmabuf
, list
);
1094 lp
= (uint32_t *) prsp
->virt
;
1095 sp
= (struct serv_parm
*) ((uint8_t *) lp
+ sizeof (uint32_t));
1097 /* Some switches have FDMI servers returning 0 for WWN */
1098 if ((ndlp
->nlp_DID
!= FDMI_DID
) &&
1099 (wwn_to_u64(sp
->portName
.u
.wwn
) == 0 ||
1100 wwn_to_u64(sp
->nodeName
.u
.wwn
) == 0)) {
1101 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
1102 "0142 PLOGI RSP: Invalid WWN.\n");
1105 if (!lpfc_check_sparm(vport
, ndlp
, sp
, CLASS3
, 0))
1107 /* PLOGI chkparm OK */
1108 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
1109 "0121 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
1110 ndlp
->nlp_DID
, ndlp
->nlp_state
,
1111 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
1112 if (vport
->cfg_fcp_class
== 2 && (sp
->cls2
.classValid
))
1113 ndlp
->nlp_fcp_info
|= CLASS2
;
1115 ndlp
->nlp_fcp_info
|= CLASS3
;
1117 ndlp
->nlp_class_sup
= 0;
1118 if (sp
->cls1
.classValid
)
1119 ndlp
->nlp_class_sup
|= FC_COS_CLASS1
;
1120 if (sp
->cls2
.classValid
)
1121 ndlp
->nlp_class_sup
|= FC_COS_CLASS2
;
1122 if (sp
->cls3
.classValid
)
1123 ndlp
->nlp_class_sup
|= FC_COS_CLASS3
;
1124 if (sp
->cls4
.classValid
)
1125 ndlp
->nlp_class_sup
|= FC_COS_CLASS4
;
1126 ndlp
->nlp_maxframe
=
1127 ((sp
->cmn
.bbRcvSizeMsb
& 0x0F) << 8) | sp
->cmn
.bbRcvSizeLsb
;
1129 if ((vport
->fc_flag
& FC_PT2PT
) &&
1130 (vport
->fc_flag
& FC_PT2PT_PLOGI
)) {
1131 ed_tov
= be32_to_cpu(sp
->cmn
.e_d_tov
);
1132 if (sp
->cmn
.edtovResolution
) {
1133 /* E_D_TOV ticks are in nanoseconds */
1134 ed_tov
= (phba
->fc_edtov
+ 999999) / 1000000;
1137 ndlp
->nlp_flag
&= ~NLP_SUPPRESS_RSP
;
1138 if ((phba
->sli
.sli_flag
& LPFC_SLI_SUPPRESS_RSP
) &&
1139 sp
->cmn
.valid_vendor_ver_level
) {
1140 vid
= be32_to_cpu(sp
->un
.vv
.vid
);
1141 flag
= be32_to_cpu(sp
->un
.vv
.flags
);
1142 if ((vid
== LPFC_VV_EMLX_ID
) &&
1143 (flag
& LPFC_VV_SUPPRESS_RSP
))
1144 ndlp
->nlp_flag
|= NLP_SUPPRESS_RSP
;
1148 * Use the larger EDTOV
1149 * RATOV = 2 * EDTOV for pt-to-pt
1151 if (ed_tov
> phba
->fc_edtov
)
1152 phba
->fc_edtov
= ed_tov
;
1153 phba
->fc_ratov
= (2 * phba
->fc_edtov
) / 1000;
1155 memcpy(&phba
->fc_fabparam
, sp
, sizeof(struct serv_parm
));
1157 /* Issue config_link / reg_vfi to account for updated TOV's */
1158 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1159 lpfc_issue_reg_vfi(vport
);
1161 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1163 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
1164 "0133 PLOGI: no memory "
1166 "Data: x%x x%x x%x x%x\n",
1167 ndlp
->nlp_DID
, ndlp
->nlp_state
,
1168 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
1172 lpfc_config_link(phba
, mbox
);
1174 mbox
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
1175 mbox
->vport
= vport
;
1176 rc
= lpfc_sli_issue_mbox(phba
, mbox
, MBX_NOWAIT
);
1177 if (rc
== MBX_NOT_FINISHED
) {
1178 mempool_free(mbox
, phba
->mbox_mem_pool
);
1184 lpfc_unreg_rpi(vport
, ndlp
);
1186 mbox
= mempool_alloc(phba
->mbox_mem_pool
, GFP_KERNEL
);
1188 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
1189 "0018 PLOGI: no memory for reg_login "
1190 "Data: x%x x%x x%x x%x\n",
1191 ndlp
->nlp_DID
, ndlp
->nlp_state
,
1192 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
1196 if (lpfc_reg_rpi(phba
, vport
->vpi
, irsp
->un
.elsreq64
.remoteID
,
1197 (uint8_t *) sp
, mbox
, ndlp
->nlp_rpi
) == 0) {
1198 switch (ndlp
->nlp_DID
) {
1199 case NameServer_DID
:
1200 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_ns_reg_login
;
1203 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_fdmi_reg_login
;
1206 ndlp
->nlp_flag
|= NLP_REG_LOGIN_SEND
;
1207 mbox
->mbox_cmpl
= lpfc_mbx_cmpl_reg_login
;
1209 mbox
->context2
= lpfc_nlp_get(ndlp
);
1210 mbox
->vport
= vport
;
1211 if (lpfc_sli_issue_mbox(phba
, mbox
, MBX_NOWAIT
)
1212 != MBX_NOT_FINISHED
) {
1213 lpfc_nlp_set_state(vport
, ndlp
,
1214 NLP_STE_REG_LOGIN_ISSUE
);
1215 return ndlp
->nlp_state
;
1217 if (ndlp
->nlp_flag
& NLP_REG_LOGIN_SEND
)
1218 ndlp
->nlp_flag
&= ~NLP_REG_LOGIN_SEND
;
1219 /* decrement node reference count to the failed mbox
1223 mp
= (struct lpfc_dmabuf
*) mbox
->context1
;
1224 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1226 mempool_free(mbox
, phba
->mbox_mem_pool
);
1228 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
1229 "0134 PLOGI: cannot issue reg_login "
1230 "Data: x%x x%x x%x x%x\n",
1231 ndlp
->nlp_DID
, ndlp
->nlp_state
,
1232 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
1234 mempool_free(mbox
, phba
->mbox_mem_pool
);
1236 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
1237 "0135 PLOGI: cannot format reg_login "
1238 "Data: x%x x%x x%x x%x\n",
1239 ndlp
->nlp_DID
, ndlp
->nlp_state
,
1240 ndlp
->nlp_flag
, ndlp
->nlp_rpi
);
1245 if (ndlp
->nlp_DID
== NameServer_DID
) {
1246 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
1247 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
1248 "0261 Cannot Register NameServer login\n");
1252 ** In case the node reference counter does not go to zero, ensure that
1253 ** the stale state for the node is not processed.
1256 ndlp
->nlp_prev_state
= ndlp
->nlp_state
;
1257 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1258 spin_lock_irq(shost
->host_lock
);
1259 ndlp
->nlp_flag
|= NLP_DEFER_RM
;
1260 spin_unlock_irq(shost
->host_lock
);
1261 return NLP_STE_FREED_NODE
;
1265 lpfc_cmpl_logo_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1266 void *arg
, uint32_t evt
)
1268 return ndlp
->nlp_state
;
1272 lpfc_cmpl_reglogin_plogi_issue(struct lpfc_vport
*vport
,
1273 struct lpfc_nodelist
*ndlp
, void *arg
, uint32_t evt
)
1275 struct lpfc_hba
*phba
;
1276 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
1277 MAILBOX_t
*mb
= &pmb
->u
.mb
;
1281 /* Release the RPI */
1282 if (!(phba
->pport
->load_flag
& FC_UNLOADING
) &&
1284 rpi
= pmb
->u
.mb
.un
.varWords
[0];
1285 lpfc_release_rpi(phba
, vport
, rpi
);
1287 return ndlp
->nlp_state
;
1291 lpfc_device_rm_plogi_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1292 void *arg
, uint32_t evt
)
1294 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1296 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1297 spin_lock_irq(shost
->host_lock
);
1298 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1299 spin_unlock_irq(shost
->host_lock
);
1300 return ndlp
->nlp_state
;
1302 /* software abort outstanding PLOGI */
1303 lpfc_els_abort(vport
->phba
, ndlp
);
1305 lpfc_drop_node(vport
, ndlp
);
1306 return NLP_STE_FREED_NODE
;
1311 lpfc_device_recov_plogi_issue(struct lpfc_vport
*vport
,
1312 struct lpfc_nodelist
*ndlp
,
1316 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1317 struct lpfc_hba
*phba
= vport
->phba
;
1319 /* Don't do anything that will mess up processing of the
1322 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1323 return ndlp
->nlp_state
;
1325 /* software abort outstanding PLOGI */
1326 lpfc_els_abort(phba
, ndlp
);
1328 ndlp
->nlp_prev_state
= NLP_STE_PLOGI_ISSUE
;
1329 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1330 spin_lock_irq(shost
->host_lock
);
1331 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1332 spin_unlock_irq(shost
->host_lock
);
1334 return ndlp
->nlp_state
;
1338 lpfc_rcv_plogi_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1339 void *arg
, uint32_t evt
)
1341 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1342 struct lpfc_hba
*phba
= vport
->phba
;
1343 struct lpfc_iocbq
*cmdiocb
;
1345 /* software abort outstanding ADISC */
1346 lpfc_els_abort(phba
, ndlp
);
1348 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1350 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
1351 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1352 spin_lock_irq(shost
->host_lock
);
1353 ndlp
->nlp_flag
&= ~NLP_NPR_2B_DISC
;
1354 spin_unlock_irq(shost
->host_lock
);
1355 if (vport
->num_disc_nodes
)
1356 lpfc_more_adisc(vport
);
1358 return ndlp
->nlp_state
;
1360 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1361 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
1362 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
1364 return ndlp
->nlp_state
;
1368 lpfc_rcv_prli_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1369 void *arg
, uint32_t evt
)
1371 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1373 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1374 return ndlp
->nlp_state
;
1378 lpfc_rcv_logo_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1379 void *arg
, uint32_t evt
)
1381 struct lpfc_hba
*phba
= vport
->phba
;
1382 struct lpfc_iocbq
*cmdiocb
;
1384 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1386 /* software abort outstanding ADISC */
1387 lpfc_els_abort(phba
, ndlp
);
1389 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1390 return ndlp
->nlp_state
;
1394 lpfc_rcv_padisc_adisc_issue(struct lpfc_vport
*vport
,
1395 struct lpfc_nodelist
*ndlp
,
1396 void *arg
, uint32_t evt
)
1398 struct lpfc_iocbq
*cmdiocb
;
1400 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1402 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1403 return ndlp
->nlp_state
;
1407 lpfc_rcv_prlo_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1408 void *arg
, uint32_t evt
)
1410 struct lpfc_iocbq
*cmdiocb
;
1412 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1414 /* Treat like rcv logo */
1415 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_PRLO
);
1416 return ndlp
->nlp_state
;
1420 lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport
*vport
,
1421 struct lpfc_nodelist
*ndlp
,
1422 void *arg
, uint32_t evt
)
1424 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1425 struct lpfc_hba
*phba
= vport
->phba
;
1426 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1431 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1432 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1434 ap
= (ADISC
*)lpfc_check_elscmpl_iocb(phba
, cmdiocb
, rspiocb
);
1435 irsp
= &rspiocb
->iocb
;
1437 if ((irsp
->ulpStatus
) ||
1438 (!lpfc_check_adisc(vport
, ndlp
, &ap
->nodeName
, &ap
->portName
))) {
1440 mod_timer(&ndlp
->nlp_delayfunc
,
1441 jiffies
+ msecs_to_jiffies(1000));
1442 spin_lock_irq(shost
->host_lock
);
1443 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1444 spin_unlock_irq(shost
->host_lock
);
1445 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1447 memset(&ndlp
->nlp_nodename
, 0, sizeof(struct lpfc_name
));
1448 memset(&ndlp
->nlp_portname
, 0, sizeof(struct lpfc_name
));
1450 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1451 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1452 lpfc_unreg_rpi(vport
, ndlp
);
1453 return ndlp
->nlp_state
;
1456 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
1457 rc
= lpfc_sli4_resume_rpi(ndlp
, NULL
, NULL
);
1459 /* Stay in state and retry. */
1460 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1461 return ndlp
->nlp_state
;
1465 if (ndlp
->nlp_type
& NLP_FCP_TARGET
) {
1466 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1467 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_MAPPED_NODE
);
1469 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1470 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1473 return ndlp
->nlp_state
;
1477 lpfc_device_rm_adisc_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1478 void *arg
, uint32_t evt
)
1480 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1482 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1483 spin_lock_irq(shost
->host_lock
);
1484 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1485 spin_unlock_irq(shost
->host_lock
);
1486 return ndlp
->nlp_state
;
1488 /* software abort outstanding ADISC */
1489 lpfc_els_abort(vport
->phba
, ndlp
);
1491 lpfc_drop_node(vport
, ndlp
);
1492 return NLP_STE_FREED_NODE
;
1497 lpfc_device_recov_adisc_issue(struct lpfc_vport
*vport
,
1498 struct lpfc_nodelist
*ndlp
,
1502 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1503 struct lpfc_hba
*phba
= vport
->phba
;
1505 /* Don't do anything that will mess up processing of the
1508 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1509 return ndlp
->nlp_state
;
1511 /* software abort outstanding ADISC */
1512 lpfc_els_abort(phba
, ndlp
);
1514 ndlp
->nlp_prev_state
= NLP_STE_ADISC_ISSUE
;
1515 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1516 spin_lock_irq(shost
->host_lock
);
1517 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1518 spin_unlock_irq(shost
->host_lock
);
1519 lpfc_disc_set_adisc(vport
, ndlp
);
1520 return ndlp
->nlp_state
;
1524 lpfc_rcv_plogi_reglogin_issue(struct lpfc_vport
*vport
,
1525 struct lpfc_nodelist
*ndlp
,
1529 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1531 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1532 return ndlp
->nlp_state
;
1536 lpfc_rcv_prli_reglogin_issue(struct lpfc_vport
*vport
,
1537 struct lpfc_nodelist
*ndlp
,
1541 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1544 if (vport
->phba
->nvmet_support
) {
1545 /* NVME Target mode. Handle and respond to the PRLI and
1546 * transition to UNMAPPED provided the RPI has completed
1549 if (ndlp
->nlp_flag
& NLP_RPI_REGISTERED
) {
1550 lpfc_rcv_prli(vport
, ndlp
, cmdiocb
);
1551 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1552 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1554 /* RPI registration has not completed. Reject the PRLI
1555 * to prevent an illegal state transition when the
1556 * rpi registration does complete.
1558 lpfc_printf_vlog(vport
, KERN_WARNING
, LOG_NVME_DISC
,
1559 "6115 NVMET ndlp rpi %d state "
1560 "unknown, state x%x flags x%08x\n",
1561 ndlp
->nlp_rpi
, ndlp
->nlp_state
,
1563 memset(&stat
, 0, sizeof(struct ls_rjt
));
1564 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
1565 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_CMD_IN_PROGRESS
;
1566 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
,
1570 /* Initiator mode. */
1571 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1574 return ndlp
->nlp_state
;
1578 lpfc_rcv_logo_reglogin_issue(struct lpfc_vport
*vport
,
1579 struct lpfc_nodelist
*ndlp
,
1583 struct lpfc_hba
*phba
= vport
->phba
;
1584 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1586 LPFC_MBOXQ_t
*nextmb
;
1587 struct lpfc_dmabuf
*mp
;
1589 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1591 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1592 if ((mb
= phba
->sli
.mbox_active
)) {
1593 if ((mb
->u
.mb
.mbxCommand
== MBX_REG_LOGIN64
) &&
1594 (ndlp
== (struct lpfc_nodelist
*) mb
->context2
)) {
1595 ndlp
->nlp_flag
&= ~NLP_REG_LOGIN_SEND
;
1597 mb
->context2
= NULL
;
1598 mb
->mbox_cmpl
= lpfc_sli_def_mbox_cmpl
;
1602 spin_lock_irq(&phba
->hbalock
);
1603 list_for_each_entry_safe(mb
, nextmb
, &phba
->sli
.mboxq
, list
) {
1604 if ((mb
->u
.mb
.mbxCommand
== MBX_REG_LOGIN64
) &&
1605 (ndlp
== (struct lpfc_nodelist
*) mb
->context2
)) {
1606 mp
= (struct lpfc_dmabuf
*) (mb
->context1
);
1608 __lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1611 ndlp
->nlp_flag
&= ~NLP_REG_LOGIN_SEND
;
1613 list_del(&mb
->list
);
1614 phba
->sli
.mboxq_cnt
--;
1615 mempool_free(mb
, phba
->mbox_mem_pool
);
1618 spin_unlock_irq(&phba
->hbalock
);
1620 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1621 return ndlp
->nlp_state
;
1625 lpfc_rcv_padisc_reglogin_issue(struct lpfc_vport
*vport
,
1626 struct lpfc_nodelist
*ndlp
,
1630 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1632 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1633 return ndlp
->nlp_state
;
1637 lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport
*vport
,
1638 struct lpfc_nodelist
*ndlp
,
1642 struct lpfc_iocbq
*cmdiocb
;
1644 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1645 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1646 return ndlp
->nlp_state
;
1650 lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport
*vport
,
1651 struct lpfc_nodelist
*ndlp
,
1655 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1656 struct lpfc_hba
*phba
= vport
->phba
;
1657 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
1658 MAILBOX_t
*mb
= &pmb
->u
.mb
;
1659 uint32_t did
= mb
->un
.varWords
[1];
1662 if (mb
->mbxStatus
) {
1663 /* RegLogin failed */
1664 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
1665 "0246 RegLogin failed Data: x%x x%x x%x x%x "
1667 did
, mb
->mbxStatus
, vport
->port_state
,
1668 mb
->un
.varRegLogin
.vpi
,
1669 mb
->un
.varRegLogin
.rpi
);
1671 * If RegLogin failed due to lack of HBA resources do not
1674 if (mb
->mbxStatus
== MBXERR_RPI_FULL
) {
1675 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1676 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1677 return ndlp
->nlp_state
;
1680 /* Put ndlp in npr state set plogi timer for 1 sec */
1681 mod_timer(&ndlp
->nlp_delayfunc
,
1682 jiffies
+ msecs_to_jiffies(1000 * 1));
1683 spin_lock_irq(shost
->host_lock
);
1684 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
1685 spin_unlock_irq(shost
->host_lock
);
1686 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
1688 lpfc_issue_els_logo(vport
, ndlp
, 0);
1689 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1690 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1691 return ndlp
->nlp_state
;
1694 /* SLI4 ports have preallocated logical rpis. */
1695 if (phba
->sli_rev
< LPFC_SLI_REV4
)
1696 ndlp
->nlp_rpi
= mb
->un
.varWords
[0];
1698 ndlp
->nlp_flag
|= NLP_RPI_REGISTERED
;
1700 /* Only if we are not a fabric nport do we issue PRLI */
1701 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1702 "3066 RegLogin Complete on x%x x%x x%x\n",
1703 did
, ndlp
->nlp_type
, ndlp
->nlp_fc4_type
);
1704 if (!(ndlp
->nlp_type
& NLP_FABRIC
) &&
1705 (phba
->nvmet_support
== 0)) {
1706 /* The driver supports FCP and NVME concurrently. If the
1707 * ndlp's nlp_fc4_type is still zero, the driver doesn't
1708 * know what PRLI to send yet. Figure that out now and
1709 * call PRLI depending on the outcome.
1711 if (vport
->fc_flag
& FC_PT2PT
) {
1712 /* If we are pt2pt, there is no Fabric to determine
1713 * the FC4 type of the remote nport. So if NVME
1714 * is configured try it.
1716 ndlp
->nlp_fc4_type
|= NLP_FC4_FCP
;
1717 if ((phba
->cfg_enable_fc4_type
== LPFC_ENABLE_BOTH
) ||
1718 (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_NVME
)) {
1719 ndlp
->nlp_fc4_type
|= NLP_FC4_NVME
;
1720 /* We need to update the localport also */
1721 lpfc_nvme_update_localport(vport
);
1724 } else if (ndlp
->nlp_fc4_type
== 0) {
1725 rc
= lpfc_ns_cmd(vport
, SLI_CTNS_GFT_ID
,
1727 return ndlp
->nlp_state
;
1730 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1731 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PRLI_ISSUE
);
1732 lpfc_issue_els_prli(vport
, ndlp
, 0);
1734 if ((vport
->fc_flag
& FC_PT2PT
) && phba
->nvmet_support
)
1735 phba
->targetport
->port_id
= vport
->fc_myDID
;
1737 /* Only Fabric ports should transition. NVME target
1738 * must complete PRLI.
1740 if (ndlp
->nlp_type
& NLP_FABRIC
) {
1741 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1742 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1745 return ndlp
->nlp_state
;
1749 lpfc_device_rm_reglogin_issue(struct lpfc_vport
*vport
,
1750 struct lpfc_nodelist
*ndlp
,
1754 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1756 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
1757 spin_lock_irq(shost
->host_lock
);
1758 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
1759 spin_unlock_irq(shost
->host_lock
);
1760 return ndlp
->nlp_state
;
1762 lpfc_drop_node(vport
, ndlp
);
1763 return NLP_STE_FREED_NODE
;
1768 lpfc_device_recov_reglogin_issue(struct lpfc_vport
*vport
,
1769 struct lpfc_nodelist
*ndlp
,
1773 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1775 /* Don't do anything that will mess up processing of the
1778 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
1779 return ndlp
->nlp_state
;
1781 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
1782 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1783 spin_lock_irq(shost
->host_lock
);
1785 /* If we are a target we won't immediately transition into PRLI,
1786 * so if REG_LOGIN already completed we don't need to ignore it.
1788 if (!(ndlp
->nlp_flag
& NLP_RPI_REGISTERED
) ||
1789 !vport
->phba
->nvmet_support
)
1790 ndlp
->nlp_flag
|= NLP_IGNR_REG_CMPL
;
1792 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
1793 spin_unlock_irq(shost
->host_lock
);
1794 lpfc_disc_set_adisc(vport
, ndlp
);
1795 return ndlp
->nlp_state
;
1799 lpfc_rcv_plogi_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1800 void *arg
, uint32_t evt
)
1802 struct lpfc_iocbq
*cmdiocb
;
1804 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1806 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
1807 return ndlp
->nlp_state
;
1811 lpfc_rcv_prli_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1812 void *arg
, uint32_t evt
)
1814 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1816 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
1817 return ndlp
->nlp_state
;
1821 lpfc_rcv_logo_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1822 void *arg
, uint32_t evt
)
1824 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1826 /* Software abort outstanding PRLI before sending acc */
1827 lpfc_els_abort(vport
->phba
, ndlp
);
1829 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
1830 return ndlp
->nlp_state
;
1834 lpfc_rcv_padisc_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1835 void *arg
, uint32_t evt
)
1837 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1839 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
1840 return ndlp
->nlp_state
;
1843 /* This routine is envoked when we rcv a PRLO request from a nport
1844 * we are logged into. We should send back a PRLO rsp setting the
1846 * NEXT STATE = PRLI_ISSUE
1849 lpfc_rcv_prlo_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1850 void *arg
, uint32_t evt
)
1852 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
1854 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
1855 return ndlp
->nlp_state
;
1859 lpfc_cmpl_prli_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
1860 void *arg
, uint32_t evt
)
1862 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1863 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
1864 struct lpfc_hba
*phba
= vport
->phba
;
1867 struct lpfc_nvme_prli
*nvpr
;
1870 cmdiocb
= (struct lpfc_iocbq
*) arg
;
1871 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
1873 /* A solicited PRLI is either FCP or NVME. The PRLI cmd/rsp
1874 * format is different so NULL the two PRLI types so that the
1875 * driver correctly gets the correct context.
1879 temp_ptr
= lpfc_check_elscmpl_iocb(phba
, cmdiocb
, rspiocb
);
1880 if (cmdiocb
->iocb_flag
& LPFC_PRLI_FCP_REQ
)
1881 npr
= (PRLI
*) temp_ptr
;
1882 else if (cmdiocb
->iocb_flag
& LPFC_PRLI_NVME_REQ
)
1883 nvpr
= (struct lpfc_nvme_prli
*) temp_ptr
;
1885 irsp
= &rspiocb
->iocb
;
1886 if (irsp
->ulpStatus
) {
1887 if ((vport
->port_type
== LPFC_NPIV_PORT
) &&
1888 vport
->cfg_restrict_login
) {
1892 /* The LS Req had some error. Don't let this be a
1895 if ((ndlp
->fc4_prli_sent
== 1) &&
1896 (ndlp
->nlp_state
== NLP_STE_PRLI_ISSUE
) &&
1897 (ndlp
->nlp_type
& (NLP_FCP_TARGET
| NLP_FCP_INITIATOR
)))
1898 /* The FCP PRLI completed successfully but
1899 * the NVME PRLI failed. Since they are sent in
1900 * succession, allow the FCP to complete.
1904 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1905 ndlp
->nlp_type
|= NLP_FCP_INITIATOR
;
1906 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
1907 return ndlp
->nlp_state
;
1910 /* Check out PRLI rsp */
1911 ndlp
->nlp_type
&= ~(NLP_FCP_TARGET
| NLP_FCP_INITIATOR
);
1912 ndlp
->nlp_fcp_info
&= ~NLP_FCP_2_DEVICE
;
1914 /* NVME or FCP first burst must be negotiated for each PRLI. */
1915 ndlp
->nlp_flag
&= ~NLP_FIRSTBURST
;
1916 ndlp
->nvme_fb_size
= 0;
1917 if (npr
&& (npr
->acceptRspCode
== PRLI_REQ_EXECUTED
) &&
1918 (npr
->prliType
== PRLI_FCP_TYPE
)) {
1919 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_NVME_DISC
,
1920 "6028 FCP NPR PRLI Cmpl Init %d Target %d\n",
1923 if (npr
->initiatorFunc
)
1924 ndlp
->nlp_type
|= NLP_FCP_INITIATOR
;
1925 if (npr
->targetFunc
) {
1926 ndlp
->nlp_type
|= NLP_FCP_TARGET
;
1927 if (npr
->writeXferRdyDis
)
1928 ndlp
->nlp_flag
|= NLP_FIRSTBURST
;
1931 ndlp
->nlp_fcp_info
|= NLP_FCP_2_DEVICE
;
1933 /* PRLI completed. Decrement count. */
1934 ndlp
->fc4_prli_sent
--;
1936 (bf_get_be32(prli_acc_rsp_code
, nvpr
) ==
1937 PRLI_REQ_EXECUTED
) &&
1938 (bf_get_be32(prli_type_code
, nvpr
) ==
1941 /* Complete setting up the remote ndlp personality. */
1942 if (bf_get_be32(prli_init
, nvpr
))
1943 ndlp
->nlp_type
|= NLP_NVME_INITIATOR
;
1945 /* Target driver cannot solicit NVME FB. */
1946 if (bf_get_be32(prli_tgt
, nvpr
)) {
1947 ndlp
->nlp_type
|= NLP_NVME_TARGET
;
1948 if ((bf_get_be32(prli_fba
, nvpr
) == 1) &&
1949 (bf_get_be32(prli_fb_sz
, nvpr
) > 0) &&
1950 (phba
->cfg_nvme_enable_fb
) &&
1951 (!phba
->nvmet_support
)) {
1952 /* Both sides support FB. The target's first
1953 * burst size is a 512 byte encoded value.
1955 ndlp
->nlp_flag
|= NLP_FIRSTBURST
;
1956 ndlp
->nvme_fb_size
= bf_get_be32(prli_fb_sz
,
1961 if (bf_get_be32(prli_recov
, nvpr
))
1962 ndlp
->nlp_fcp_info
|= NLP_FCP_2_DEVICE
;
1964 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_NVME_DISC
,
1965 "6029 NVME PRLI Cmpl w1 x%08x "
1966 "w4 x%08x w5 x%08x flag x%x, "
1967 "fcp_info x%x nlp_type x%x\n",
1968 be32_to_cpu(nvpr
->word1
),
1969 be32_to_cpu(nvpr
->word4
),
1970 be32_to_cpu(nvpr
->word5
),
1971 ndlp
->nlp_flag
, ndlp
->nlp_fcp_info
,
1973 /* PRLI completed. Decrement count. */
1974 ndlp
->fc4_prli_sent
--;
1976 if (!(ndlp
->nlp_type
& NLP_FCP_TARGET
) &&
1977 (vport
->port_type
== LPFC_NPIV_PORT
) &&
1978 vport
->cfg_restrict_login
) {
1980 spin_lock_irq(shost
->host_lock
);
1981 ndlp
->nlp_flag
|= NLP_TARGET_REMOVE
;
1982 spin_unlock_irq(shost
->host_lock
);
1983 lpfc_issue_els_logo(vport
, ndlp
, 0);
1985 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1986 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
1987 return ndlp
->nlp_state
;
1991 /* The ndlp state cannot move to MAPPED or UNMAPPED before all PRLIs
1994 if (ndlp
->fc4_prli_sent
== 0) {
1995 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
1996 if (ndlp
->nlp_type
& (NLP_FCP_TARGET
| NLP_NVME_TARGET
))
1997 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_MAPPED_NODE
);
1999 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_UNMAPPED_NODE
);
2001 lpfc_printf_vlog(vport
,
2003 "3067 PRLI's still outstanding "
2004 "on x%06x - count %d, Pend Node Mode "
2006 ndlp
->nlp_DID
, ndlp
->fc4_prli_sent
);
2008 return ndlp
->nlp_state
;
2011 /*! lpfc_device_rm_prli_issue
2022 * This routine is envoked when we a request to remove a nport we are in the
2023 * process of PRLIing. We should software abort outstanding prli, unreg
2024 * login, send a logout. We will change node state to UNUSED_NODE, put it
2025 * on plogi list so it can be freed when LOGO completes.
2030 lpfc_device_rm_prli_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2031 void *arg
, uint32_t evt
)
2033 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2035 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
2036 spin_lock_irq(shost
->host_lock
);
2037 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
2038 spin_unlock_irq(shost
->host_lock
);
2039 return ndlp
->nlp_state
;
2041 /* software abort outstanding PLOGI */
2042 lpfc_els_abort(vport
->phba
, ndlp
);
2044 lpfc_drop_node(vport
, ndlp
);
2045 return NLP_STE_FREED_NODE
;
2050 /*! lpfc_device_recov_prli_issue
2061 * The routine is envoked when the state of a device is unknown, like
2062 * during a link down. We should remove the nodelist entry from the
2063 * unmapped list, issue a UNREG_LOGIN, do a software abort of the
2064 * outstanding PRLI command, then free the node entry.
2067 lpfc_device_recov_prli_issue(struct lpfc_vport
*vport
,
2068 struct lpfc_nodelist
*ndlp
,
2072 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2073 struct lpfc_hba
*phba
= vport
->phba
;
2075 /* Don't do anything that will mess up processing of the
2078 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
2079 return ndlp
->nlp_state
;
2081 /* software abort outstanding PRLI */
2082 lpfc_els_abort(phba
, ndlp
);
2084 ndlp
->nlp_prev_state
= NLP_STE_PRLI_ISSUE
;
2085 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
2086 spin_lock_irq(shost
->host_lock
);
2087 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
2088 spin_unlock_irq(shost
->host_lock
);
2089 lpfc_disc_set_adisc(vport
, ndlp
);
2090 return ndlp
->nlp_state
;
2094 lpfc_rcv_plogi_logo_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2095 void *arg
, uint32_t evt
)
2097 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*)arg
;
2100 memset(&stat
, 0, sizeof(struct ls_rjt
));
2101 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
2102 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
2103 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
2104 return ndlp
->nlp_state
;
2108 lpfc_rcv_prli_logo_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2109 void *arg
, uint32_t evt
)
2111 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*)arg
;
2114 memset(&stat
, 0, sizeof(struct ls_rjt
));
2115 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
2116 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
2117 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
2118 return ndlp
->nlp_state
;
2122 lpfc_rcv_logo_logo_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2123 void *arg
, uint32_t evt
)
2125 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2126 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*)arg
;
2128 spin_lock_irq(shost
->host_lock
);
2129 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
2130 spin_unlock_irq(shost
->host_lock
);
2131 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
2132 return ndlp
->nlp_state
;
2136 lpfc_rcv_padisc_logo_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2137 void *arg
, uint32_t evt
)
2139 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*)arg
;
2142 memset(&stat
, 0, sizeof(struct ls_rjt
));
2143 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
2144 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
2145 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
2146 return ndlp
->nlp_state
;
2150 lpfc_rcv_prlo_logo_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2151 void *arg
, uint32_t evt
)
2153 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*)arg
;
2156 memset(&stat
, 0, sizeof(struct ls_rjt
));
2157 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
2158 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
2159 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
2160 return ndlp
->nlp_state
;
2164 lpfc_cmpl_logo_logo_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2165 void *arg
, uint32_t evt
)
2167 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2169 ndlp
->nlp_prev_state
= NLP_STE_LOGO_ISSUE
;
2170 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
2171 spin_lock_irq(shost
->host_lock
);
2172 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
2173 spin_unlock_irq(shost
->host_lock
);
2174 lpfc_disc_set_adisc(vport
, ndlp
);
2175 return ndlp
->nlp_state
;
2179 lpfc_device_rm_logo_issue(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2180 void *arg
, uint32_t evt
)
2183 * Take no action. If a LOGO is outstanding, then possibly DevLoss has
2184 * timed out and is calling for Device Remove. In this case, the LOGO
2185 * must be allowed to complete in state LOGO_ISSUE so that the rpi
2186 * and other NLP flags are correctly cleaned up.
2188 return ndlp
->nlp_state
;
2192 lpfc_device_recov_logo_issue(struct lpfc_vport
*vport
,
2193 struct lpfc_nodelist
*ndlp
,
2194 void *arg
, uint32_t evt
)
2197 * Device Recovery events have no meaning for a node with a LOGO
2198 * outstanding. The LOGO has to complete first and handle the
2199 * node from that point.
2201 return ndlp
->nlp_state
;
2205 lpfc_rcv_plogi_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2206 void *arg
, uint32_t evt
)
2208 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2210 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
2211 return ndlp
->nlp_state
;
2215 lpfc_rcv_prli_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2216 void *arg
, uint32_t evt
)
2218 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2220 lpfc_rcv_prli(vport
, ndlp
, cmdiocb
);
2221 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
2222 return ndlp
->nlp_state
;
2226 lpfc_rcv_logo_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2227 void *arg
, uint32_t evt
)
2229 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2231 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
2232 return ndlp
->nlp_state
;
2236 lpfc_rcv_padisc_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2237 void *arg
, uint32_t evt
)
2239 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2241 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
2242 return ndlp
->nlp_state
;
2246 lpfc_rcv_prlo_unmap_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2247 void *arg
, uint32_t evt
)
2249 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2251 lpfc_els_rsp_acc(vport
, ELS_CMD_PRLO
, cmdiocb
, ndlp
, NULL
);
2252 return ndlp
->nlp_state
;
2256 lpfc_device_recov_unmap_node(struct lpfc_vport
*vport
,
2257 struct lpfc_nodelist
*ndlp
,
2261 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2263 ndlp
->nlp_prev_state
= NLP_STE_UNMAPPED_NODE
;
2264 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
2265 spin_lock_irq(shost
->host_lock
);
2266 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
2267 spin_unlock_irq(shost
->host_lock
);
2268 lpfc_disc_set_adisc(vport
, ndlp
);
2270 return ndlp
->nlp_state
;
2274 lpfc_rcv_plogi_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2275 void *arg
, uint32_t evt
)
2277 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2279 lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
);
2280 return ndlp
->nlp_state
;
2284 lpfc_rcv_prli_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2285 void *arg
, uint32_t evt
)
2287 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2289 lpfc_els_rsp_prli_acc(vport
, cmdiocb
, ndlp
);
2290 return ndlp
->nlp_state
;
2294 lpfc_rcv_logo_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2295 void *arg
, uint32_t evt
)
2297 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2299 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
2300 return ndlp
->nlp_state
;
2304 lpfc_rcv_padisc_mapped_node(struct lpfc_vport
*vport
,
2305 struct lpfc_nodelist
*ndlp
,
2306 void *arg
, uint32_t evt
)
2308 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2310 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
2311 return ndlp
->nlp_state
;
2315 lpfc_rcv_prlo_mapped_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2316 void *arg
, uint32_t evt
)
2318 struct lpfc_hba
*phba
= vport
->phba
;
2319 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2321 /* flush the target */
2322 lpfc_sli_abort_iocb(vport
, &phba
->sli
.sli3_ring
[LPFC_FCP_RING
],
2323 ndlp
->nlp_sid
, 0, LPFC_CTX_TGT
);
2325 /* Treat like rcv logo */
2326 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_PRLO
);
2327 return ndlp
->nlp_state
;
2331 lpfc_device_recov_mapped_node(struct lpfc_vport
*vport
,
2332 struct lpfc_nodelist
*ndlp
,
2336 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2338 ndlp
->nlp_prev_state
= NLP_STE_MAPPED_NODE
;
2339 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_NPR_NODE
);
2340 spin_lock_irq(shost
->host_lock
);
2341 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
2342 spin_unlock_irq(shost
->host_lock
);
2343 lpfc_disc_set_adisc(vport
, ndlp
);
2344 return ndlp
->nlp_state
;
2348 lpfc_rcv_plogi_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2349 void *arg
, uint32_t evt
)
2351 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2352 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2354 /* Ignore PLOGI if we have an outstanding LOGO */
2355 if (ndlp
->nlp_flag
& (NLP_LOGO_SND
| NLP_LOGO_ACC
))
2356 return ndlp
->nlp_state
;
2357 if (lpfc_rcv_plogi(vport
, ndlp
, cmdiocb
)) {
2358 lpfc_cancel_retry_delay_tmo(vport
, ndlp
);
2359 spin_lock_irq(shost
->host_lock
);
2360 ndlp
->nlp_flag
&= ~(NLP_NPR_ADISC
| NLP_NPR_2B_DISC
);
2361 spin_unlock_irq(shost
->host_lock
);
2362 } else if (!(ndlp
->nlp_flag
& NLP_NPR_2B_DISC
)) {
2363 /* send PLOGI immediately, move to PLOGI issue state */
2364 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
)) {
2365 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
2366 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
2367 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
2370 return ndlp
->nlp_state
;
2374 lpfc_rcv_prli_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2375 void *arg
, uint32_t evt
)
2377 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2378 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2381 memset(&stat
, 0, sizeof (struct ls_rjt
));
2382 stat
.un
.b
.lsRjtRsnCode
= LSRJT_UNABLE_TPC
;
2383 stat
.un
.b
.lsRjtRsnCodeExp
= LSEXP_NOTHING_MORE
;
2384 lpfc_els_rsp_reject(vport
, stat
.un
.lsRjtError
, cmdiocb
, ndlp
, NULL
);
2386 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
)) {
2387 if (ndlp
->nlp_flag
& NLP_NPR_ADISC
) {
2388 spin_lock_irq(shost
->host_lock
);
2389 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
2390 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
2391 spin_unlock_irq(shost
->host_lock
);
2392 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_ADISC_ISSUE
);
2393 lpfc_issue_els_adisc(vport
, ndlp
, 0);
2395 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
2396 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
2397 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
2400 return ndlp
->nlp_state
;
2404 lpfc_rcv_logo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2405 void *arg
, uint32_t evt
)
2407 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2409 lpfc_rcv_logo(vport
, ndlp
, cmdiocb
, ELS_CMD_LOGO
);
2410 return ndlp
->nlp_state
;
2414 lpfc_rcv_padisc_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2415 void *arg
, uint32_t evt
)
2417 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2419 lpfc_rcv_padisc(vport
, ndlp
, cmdiocb
);
2421 * Do not start discovery if discovery is about to start
2422 * or discovery in progress for this node. Starting discovery
2423 * here will affect the counting of discovery threads.
2425 if (!(ndlp
->nlp_flag
& NLP_DELAY_TMO
) &&
2426 !(ndlp
->nlp_flag
& NLP_NPR_2B_DISC
)) {
2427 if (ndlp
->nlp_flag
& NLP_NPR_ADISC
) {
2428 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
2429 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
2430 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_ADISC_ISSUE
);
2431 lpfc_issue_els_adisc(vport
, ndlp
, 0);
2433 ndlp
->nlp_prev_state
= NLP_STE_NPR_NODE
;
2434 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PLOGI_ISSUE
);
2435 lpfc_issue_els_plogi(vport
, ndlp
->nlp_DID
, 0);
2438 return ndlp
->nlp_state
;
2442 lpfc_rcv_prlo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2443 void *arg
, uint32_t evt
)
2445 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2446 struct lpfc_iocbq
*cmdiocb
= (struct lpfc_iocbq
*) arg
;
2448 spin_lock_irq(shost
->host_lock
);
2449 ndlp
->nlp_flag
|= NLP_LOGO_ACC
;
2450 spin_unlock_irq(shost
->host_lock
);
2452 lpfc_els_rsp_acc(vport
, ELS_CMD_ACC
, cmdiocb
, ndlp
, NULL
);
2454 if ((ndlp
->nlp_flag
& NLP_DELAY_TMO
) == 0) {
2455 mod_timer(&ndlp
->nlp_delayfunc
,
2456 jiffies
+ msecs_to_jiffies(1000 * 1));
2457 spin_lock_irq(shost
->host_lock
);
2458 ndlp
->nlp_flag
|= NLP_DELAY_TMO
;
2459 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
2460 spin_unlock_irq(shost
->host_lock
);
2461 ndlp
->nlp_last_elscmd
= ELS_CMD_PLOGI
;
2463 spin_lock_irq(shost
->host_lock
);
2464 ndlp
->nlp_flag
&= ~NLP_NPR_ADISC
;
2465 spin_unlock_irq(shost
->host_lock
);
2467 return ndlp
->nlp_state
;
2471 lpfc_cmpl_plogi_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2472 void *arg
, uint32_t evt
)
2474 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
2476 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2478 cmdiocb
= (struct lpfc_iocbq
*) arg
;
2479 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
2481 irsp
= &rspiocb
->iocb
;
2482 if (irsp
->ulpStatus
) {
2483 spin_lock_irq(shost
->host_lock
);
2484 ndlp
->nlp_flag
|= NLP_DEFER_RM
;
2485 spin_unlock_irq(shost
->host_lock
);
2486 return NLP_STE_FREED_NODE
;
2488 return ndlp
->nlp_state
;
2492 lpfc_cmpl_prli_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2493 void *arg
, uint32_t evt
)
2495 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
2498 cmdiocb
= (struct lpfc_iocbq
*) arg
;
2499 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
2501 irsp
= &rspiocb
->iocb
;
2502 if (irsp
->ulpStatus
&& (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
)) {
2503 lpfc_drop_node(vport
, ndlp
);
2504 return NLP_STE_FREED_NODE
;
2506 return ndlp
->nlp_state
;
2510 lpfc_cmpl_logo_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2511 void *arg
, uint32_t evt
)
2513 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2515 /* For the fabric port just clear the fc flags. */
2516 if (ndlp
->nlp_DID
== Fabric_DID
) {
2517 spin_lock_irq(shost
->host_lock
);
2518 vport
->fc_flag
&= ~(FC_FABRIC
| FC_PUBLIC_LOOP
);
2519 spin_unlock_irq(shost
->host_lock
);
2521 lpfc_unreg_rpi(vport
, ndlp
);
2522 return ndlp
->nlp_state
;
2526 lpfc_cmpl_adisc_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2527 void *arg
, uint32_t evt
)
2529 struct lpfc_iocbq
*cmdiocb
, *rspiocb
;
2532 cmdiocb
= (struct lpfc_iocbq
*) arg
;
2533 rspiocb
= cmdiocb
->context_un
.rsp_iocb
;
2535 irsp
= &rspiocb
->iocb
;
2536 if (irsp
->ulpStatus
&& (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
)) {
2537 lpfc_drop_node(vport
, ndlp
);
2538 return NLP_STE_FREED_NODE
;
2540 return ndlp
->nlp_state
;
2544 lpfc_cmpl_reglogin_npr_node(struct lpfc_vport
*vport
,
2545 struct lpfc_nodelist
*ndlp
,
2546 void *arg
, uint32_t evt
)
2548 LPFC_MBOXQ_t
*pmb
= (LPFC_MBOXQ_t
*) arg
;
2549 MAILBOX_t
*mb
= &pmb
->u
.mb
;
2551 if (!mb
->mbxStatus
) {
2552 /* SLI4 ports have preallocated logical rpis. */
2553 if (vport
->phba
->sli_rev
< LPFC_SLI_REV4
)
2554 ndlp
->nlp_rpi
= mb
->un
.varWords
[0];
2555 ndlp
->nlp_flag
|= NLP_RPI_REGISTERED
;
2556 if (ndlp
->nlp_flag
& NLP_LOGO_ACC
) {
2557 lpfc_unreg_rpi(vport
, ndlp
);
2560 if (ndlp
->nlp_flag
& NLP_NODEV_REMOVE
) {
2561 lpfc_drop_node(vport
, ndlp
);
2562 return NLP_STE_FREED_NODE
;
2565 return ndlp
->nlp_state
;
2569 lpfc_device_rm_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2570 void *arg
, uint32_t evt
)
2572 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2574 if (ndlp
->nlp_flag
& NLP_NPR_2B_DISC
) {
2575 spin_lock_irq(shost
->host_lock
);
2576 ndlp
->nlp_flag
|= NLP_NODEV_REMOVE
;
2577 spin_unlock_irq(shost
->host_lock
);
2578 return ndlp
->nlp_state
;
2580 lpfc_drop_node(vport
, ndlp
);
2581 return NLP_STE_FREED_NODE
;
2585 lpfc_device_recov_npr_node(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2586 void *arg
, uint32_t evt
)
2588 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2590 /* Don't do anything that will mess up processing of the
2593 if (vport
->fc_flag
& FC_RSCN_DEFERRED
)
2594 return ndlp
->nlp_state
;
2596 lpfc_cancel_retry_delay_tmo(vport
, ndlp
);
2597 spin_lock_irq(shost
->host_lock
);
2598 ndlp
->nlp_flag
&= ~(NLP_NODEV_REMOVE
| NLP_NPR_2B_DISC
);
2599 spin_unlock_irq(shost
->host_lock
);
2600 return ndlp
->nlp_state
;
2604 /* This next section defines the NPort Discovery State Machine */
2606 /* There are 4 different double linked lists nodelist entries can reside on.
2607 * The plogi list and adisc list are used when Link Up discovery or RSCN
2608 * processing is needed. Each list holds the nodes that we will send PLOGI
2609 * or ADISC on. These lists will keep track of what nodes will be effected
2610 * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
2611 * The unmapped_list will contain all nodes that we have successfully logged
2612 * into at the Fibre Channel level. The mapped_list will contain all nodes
2613 * that are mapped FCP targets.
2616 * The bind list is a list of undiscovered (potentially non-existent) nodes
2617 * that we have saved binding information on. This information is used when
2618 * nodes transition from the unmapped to the mapped list.
2620 /* For UNUSED_NODE state, the node has just been allocated .
2621 * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
2622 * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
2623 * and put on the unmapped list. For ADISC processing, the node is taken off
2624 * the ADISC list and placed on either the mapped or unmapped list (depending
2625 * on its previous state). Once on the unmapped list, a PRLI is issued and the
2626 * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
2627 * changed to UNMAPPED_NODE. If the completion indicates a mapped
2628 * node, the node is taken off the unmapped list. The binding list is checked
2629 * for a valid binding, or a binding is automatically assigned. If binding
2630 * assignment is unsuccessful, the node is left on the unmapped list. If
2631 * binding assignment is successful, the associated binding list entry (if
2632 * any) is removed, and the node is placed on the mapped list.
2635 * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
2636 * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
2637 * expire, all effected nodes will receive a DEVICE_RM event.
2640 * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
2641 * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
2642 * check, additional nodes may be added or removed (via DEVICE_RM) to / from
2643 * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
2644 * we will first process the ADISC list. 32 entries are processed initially and
2645 * ADISC is initited for each one. Completions / Events for each node are
2646 * funnelled thru the state machine. As each node finishes ADISC processing, it
2647 * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
2648 * waiting, and the ADISC list count is identically 0, then we are done. For
2649 * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
2650 * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
2651 * list. 32 entries are processed initially and PLOGI is initited for each one.
2652 * Completions / Events for each node are funnelled thru the state machine. As
2653 * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
2654 * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
2655 * indentically 0, then we are done. We have now completed discovery / RSCN
2656 * handling. Upon completion, ALL nodes should be on either the mapped or
2660 static uint32_t (*lpfc_disc_action
[NLP_STE_MAX_STATE
* NLP_EVT_MAX_EVENT
])
2661 (struct lpfc_vport
*, struct lpfc_nodelist
*, void *, uint32_t) = {
2662 /* Action routine Event Current State */
2663 lpfc_rcv_plogi_unused_node
, /* RCV_PLOGI UNUSED_NODE */
2664 lpfc_rcv_els_unused_node
, /* RCV_PRLI */
2665 lpfc_rcv_logo_unused_node
, /* RCV_LOGO */
2666 lpfc_rcv_els_unused_node
, /* RCV_ADISC */
2667 lpfc_rcv_els_unused_node
, /* RCV_PDISC */
2668 lpfc_rcv_els_unused_node
, /* RCV_PRLO */
2669 lpfc_disc_illegal
, /* CMPL_PLOGI */
2670 lpfc_disc_illegal
, /* CMPL_PRLI */
2671 lpfc_cmpl_logo_unused_node
, /* CMPL_LOGO */
2672 lpfc_disc_illegal
, /* CMPL_ADISC */
2673 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2674 lpfc_device_rm_unused_node
, /* DEVICE_RM */
2675 lpfc_device_recov_unused_node
, /* DEVICE_RECOVERY */
2677 lpfc_rcv_plogi_plogi_issue
, /* RCV_PLOGI PLOGI_ISSUE */
2678 lpfc_rcv_prli_plogi_issue
, /* RCV_PRLI */
2679 lpfc_rcv_logo_plogi_issue
, /* RCV_LOGO */
2680 lpfc_rcv_els_plogi_issue
, /* RCV_ADISC */
2681 lpfc_rcv_els_plogi_issue
, /* RCV_PDISC */
2682 lpfc_rcv_els_plogi_issue
, /* RCV_PRLO */
2683 lpfc_cmpl_plogi_plogi_issue
, /* CMPL_PLOGI */
2684 lpfc_disc_illegal
, /* CMPL_PRLI */
2685 lpfc_cmpl_logo_plogi_issue
, /* CMPL_LOGO */
2686 lpfc_disc_illegal
, /* CMPL_ADISC */
2687 lpfc_cmpl_reglogin_plogi_issue
,/* CMPL_REG_LOGIN */
2688 lpfc_device_rm_plogi_issue
, /* DEVICE_RM */
2689 lpfc_device_recov_plogi_issue
, /* DEVICE_RECOVERY */
2691 lpfc_rcv_plogi_adisc_issue
, /* RCV_PLOGI ADISC_ISSUE */
2692 lpfc_rcv_prli_adisc_issue
, /* RCV_PRLI */
2693 lpfc_rcv_logo_adisc_issue
, /* RCV_LOGO */
2694 lpfc_rcv_padisc_adisc_issue
, /* RCV_ADISC */
2695 lpfc_rcv_padisc_adisc_issue
, /* RCV_PDISC */
2696 lpfc_rcv_prlo_adisc_issue
, /* RCV_PRLO */
2697 lpfc_disc_illegal
, /* CMPL_PLOGI */
2698 lpfc_disc_illegal
, /* CMPL_PRLI */
2699 lpfc_disc_illegal
, /* CMPL_LOGO */
2700 lpfc_cmpl_adisc_adisc_issue
, /* CMPL_ADISC */
2701 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2702 lpfc_device_rm_adisc_issue
, /* DEVICE_RM */
2703 lpfc_device_recov_adisc_issue
, /* DEVICE_RECOVERY */
2705 lpfc_rcv_plogi_reglogin_issue
, /* RCV_PLOGI REG_LOGIN_ISSUE */
2706 lpfc_rcv_prli_reglogin_issue
, /* RCV_PLOGI */
2707 lpfc_rcv_logo_reglogin_issue
, /* RCV_LOGO */
2708 lpfc_rcv_padisc_reglogin_issue
, /* RCV_ADISC */
2709 lpfc_rcv_padisc_reglogin_issue
, /* RCV_PDISC */
2710 lpfc_rcv_prlo_reglogin_issue
, /* RCV_PRLO */
2711 lpfc_cmpl_plogi_illegal
, /* CMPL_PLOGI */
2712 lpfc_disc_illegal
, /* CMPL_PRLI */
2713 lpfc_disc_illegal
, /* CMPL_LOGO */
2714 lpfc_disc_illegal
, /* CMPL_ADISC */
2715 lpfc_cmpl_reglogin_reglogin_issue
,/* CMPL_REG_LOGIN */
2716 lpfc_device_rm_reglogin_issue
, /* DEVICE_RM */
2717 lpfc_device_recov_reglogin_issue
,/* DEVICE_RECOVERY */
2719 lpfc_rcv_plogi_prli_issue
, /* RCV_PLOGI PRLI_ISSUE */
2720 lpfc_rcv_prli_prli_issue
, /* RCV_PRLI */
2721 lpfc_rcv_logo_prli_issue
, /* RCV_LOGO */
2722 lpfc_rcv_padisc_prli_issue
, /* RCV_ADISC */
2723 lpfc_rcv_padisc_prli_issue
, /* RCV_PDISC */
2724 lpfc_rcv_prlo_prli_issue
, /* RCV_PRLO */
2725 lpfc_cmpl_plogi_illegal
, /* CMPL_PLOGI */
2726 lpfc_cmpl_prli_prli_issue
, /* CMPL_PRLI */
2727 lpfc_disc_illegal
, /* CMPL_LOGO */
2728 lpfc_disc_illegal
, /* CMPL_ADISC */
2729 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2730 lpfc_device_rm_prli_issue
, /* DEVICE_RM */
2731 lpfc_device_recov_prli_issue
, /* DEVICE_RECOVERY */
2733 lpfc_rcv_plogi_logo_issue
, /* RCV_PLOGI LOGO_ISSUE */
2734 lpfc_rcv_prli_logo_issue
, /* RCV_PRLI */
2735 lpfc_rcv_logo_logo_issue
, /* RCV_LOGO */
2736 lpfc_rcv_padisc_logo_issue
, /* RCV_ADISC */
2737 lpfc_rcv_padisc_logo_issue
, /* RCV_PDISC */
2738 lpfc_rcv_prlo_logo_issue
, /* RCV_PRLO */
2739 lpfc_cmpl_plogi_illegal
, /* CMPL_PLOGI */
2740 lpfc_disc_illegal
, /* CMPL_PRLI */
2741 lpfc_cmpl_logo_logo_issue
, /* CMPL_LOGO */
2742 lpfc_disc_illegal
, /* CMPL_ADISC */
2743 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2744 lpfc_device_rm_logo_issue
, /* DEVICE_RM */
2745 lpfc_device_recov_logo_issue
, /* DEVICE_RECOVERY */
2747 lpfc_rcv_plogi_unmap_node
, /* RCV_PLOGI UNMAPPED_NODE */
2748 lpfc_rcv_prli_unmap_node
, /* RCV_PRLI */
2749 lpfc_rcv_logo_unmap_node
, /* RCV_LOGO */
2750 lpfc_rcv_padisc_unmap_node
, /* RCV_ADISC */
2751 lpfc_rcv_padisc_unmap_node
, /* RCV_PDISC */
2752 lpfc_rcv_prlo_unmap_node
, /* RCV_PRLO */
2753 lpfc_disc_illegal
, /* CMPL_PLOGI */
2754 lpfc_disc_illegal
, /* CMPL_PRLI */
2755 lpfc_disc_illegal
, /* CMPL_LOGO */
2756 lpfc_disc_illegal
, /* CMPL_ADISC */
2757 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2758 lpfc_disc_illegal
, /* DEVICE_RM */
2759 lpfc_device_recov_unmap_node
, /* DEVICE_RECOVERY */
2761 lpfc_rcv_plogi_mapped_node
, /* RCV_PLOGI MAPPED_NODE */
2762 lpfc_rcv_prli_mapped_node
, /* RCV_PRLI */
2763 lpfc_rcv_logo_mapped_node
, /* RCV_LOGO */
2764 lpfc_rcv_padisc_mapped_node
, /* RCV_ADISC */
2765 lpfc_rcv_padisc_mapped_node
, /* RCV_PDISC */
2766 lpfc_rcv_prlo_mapped_node
, /* RCV_PRLO */
2767 lpfc_disc_illegal
, /* CMPL_PLOGI */
2768 lpfc_disc_illegal
, /* CMPL_PRLI */
2769 lpfc_disc_illegal
, /* CMPL_LOGO */
2770 lpfc_disc_illegal
, /* CMPL_ADISC */
2771 lpfc_disc_illegal
, /* CMPL_REG_LOGIN */
2772 lpfc_disc_illegal
, /* DEVICE_RM */
2773 lpfc_device_recov_mapped_node
, /* DEVICE_RECOVERY */
2775 lpfc_rcv_plogi_npr_node
, /* RCV_PLOGI NPR_NODE */
2776 lpfc_rcv_prli_npr_node
, /* RCV_PRLI */
2777 lpfc_rcv_logo_npr_node
, /* RCV_LOGO */
2778 lpfc_rcv_padisc_npr_node
, /* RCV_ADISC */
2779 lpfc_rcv_padisc_npr_node
, /* RCV_PDISC */
2780 lpfc_rcv_prlo_npr_node
, /* RCV_PRLO */
2781 lpfc_cmpl_plogi_npr_node
, /* CMPL_PLOGI */
2782 lpfc_cmpl_prli_npr_node
, /* CMPL_PRLI */
2783 lpfc_cmpl_logo_npr_node
, /* CMPL_LOGO */
2784 lpfc_cmpl_adisc_npr_node
, /* CMPL_ADISC */
2785 lpfc_cmpl_reglogin_npr_node
, /* CMPL_REG_LOGIN */
2786 lpfc_device_rm_npr_node
, /* DEVICE_RM */
2787 lpfc_device_recov_npr_node
, /* DEVICE_RECOVERY */
2791 lpfc_disc_state_machine(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2792 void *arg
, uint32_t evt
)
2794 uint32_t cur_state
, rc
;
2795 uint32_t(*func
) (struct lpfc_vport
*, struct lpfc_nodelist
*, void *,
2797 uint32_t got_ndlp
= 0;
2799 if (lpfc_nlp_get(ndlp
))
2802 cur_state
= ndlp
->nlp_state
;
2804 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
2805 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2806 "0211 DSM in event x%x on NPort x%x in "
2807 "state %d Data: x%x\n",
2808 evt
, ndlp
->nlp_DID
, cur_state
, ndlp
->nlp_flag
);
2810 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2811 "DSM in: evt:%d ste:%d did:x%x",
2812 evt
, cur_state
, ndlp
->nlp_DID
);
2814 func
= lpfc_disc_action
[(cur_state
* NLP_EVT_MAX_EVENT
) + evt
];
2815 rc
= (func
) (vport
, ndlp
, arg
, evt
);
2817 /* DSM out state <rc> on NPort <nlp_DID> */
2819 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2820 "0212 DSM out state %d on NPort x%x Data: x%x\n",
2821 rc
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
2823 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2824 "DSM out: ste:%d did:x%x flg:x%x",
2825 rc
, ndlp
->nlp_DID
, ndlp
->nlp_flag
);
2826 /* Decrement the ndlp reference count held for this function */
2829 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2830 "0213 DSM out state %d on NPort free\n", rc
);
2832 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_DSM
,
2833 "DSM out: ste:%d did:x%x flg:x%x",