1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. 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 /* In case of error recovery path, we might have a NULL pring here */
219 if (unlikely(!pring))
222 /* Abort outstanding I/O on NPort <nlp_DID> */
223 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_DISCOVERY,
224 "2819 Abort outstanding I/O on NPort x%x "
225 "Data: x%x x%x x%x\n",
226 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
228 /* Clean up all fabric IOs first.*/
229 lpfc_fabric_abort_nport(ndlp);
232 * Lock the ELS ring txcmplq for SLI3/SLI4 and build a local list
233 * of all ELS IOs that need an ABTS. The IOs need to stay on the
234 * txcmplq so that the abort operation completes them successfully.
236 spin_lock_irq(&phba->hbalock);
237 if (phba->sli_rev == LPFC_SLI_REV4)
238 spin_lock(&pring->ring_lock);
239 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
240 /* Add to abort_list on on NDLP match. */
241 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp))
242 list_add_tail(&iocb->dlist, &abort_list);
244 if (phba->sli_rev == LPFC_SLI_REV4)
245 spin_unlock(&pring->ring_lock);
246 spin_unlock_irq(&phba->hbalock);
248 /* Abort the targeted IOs and remove them from the abort list. */
249 list_for_each_entry_safe(iocb, next_iocb, &abort_list, dlist) {
250 spin_lock_irq(&phba->hbalock);
251 list_del_init(&iocb->dlist);
252 lpfc_sli_issue_abort_iotag(phba, pring, iocb);
253 spin_unlock_irq(&phba->hbalock);
256 INIT_LIST_HEAD(&abort_list);
258 /* Now process the txq */
259 spin_lock_irq(&phba->hbalock);
260 if (phba->sli_rev == LPFC_SLI_REV4)
261 spin_lock(&pring->ring_lock);
263 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
264 /* Check to see if iocb matches the nport we are looking for */
265 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp)) {
266 list_del_init(&iocb->list);
267 list_add_tail(&iocb->list, &abort_list);
271 if (phba->sli_rev == LPFC_SLI_REV4)
272 spin_unlock(&pring->ring_lock);
273 spin_unlock_irq(&phba->hbalock);
275 /* Cancel all the IOCBs from the completions list */
276 lpfc_sli_cancel_iocbs(phba, &abort_list,
277 IOSTAT_LOCAL_REJECT, IOERR_SLI_ABORTED);
279 lpfc_cancel_retry_delay_tmo(phba->pport, ndlp);
283 lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
284 struct lpfc_iocbq *cmdiocb)
286 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
287 struct lpfc_hba *phba = vport->phba;
288 struct lpfc_dmabuf *pcmd;
289 uint64_t nlp_portwwn = 0;
292 struct serv_parm *sp;
299 memset(&stat, 0, sizeof (struct ls_rjt));
300 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
301 lp = (uint32_t *) pcmd->virt;
302 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
303 if (wwn_to_u64(sp->portName.u.wwn) == 0) {
304 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
305 "0140 PLOGI Reject: invalid nname\n");
306 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
307 stat.un.b.lsRjtRsnCodeExp = LSEXP_INVALID_PNAME;
308 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
312 if (wwn_to_u64(sp->nodeName.u.wwn) == 0) {
313 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
314 "0141 PLOGI Reject: invalid pname\n");
315 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
316 stat.un.b.lsRjtRsnCodeExp = LSEXP_INVALID_NNAME;
317 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
322 nlp_portwwn = wwn_to_u64(ndlp->nlp_portname.u.wwn);
323 if ((lpfc_check_sparm(vport, ndlp, sp, CLASS3, 0) == 0)) {
324 /* Reject this request because invalid parameters */
325 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
326 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
327 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
331 icmd = &cmdiocb->iocb;
333 /* PLOGI chkparm OK */
334 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
335 "0114 PLOGI chkparm OK Data: x%x x%x x%x "
337 ndlp->nlp_DID, ndlp->nlp_state, ndlp->nlp_flag,
338 ndlp->nlp_rpi, vport->port_state,
341 if (vport->cfg_fcp_class == 2 && sp->cls2.classValid)
342 ndlp->nlp_fcp_info |= CLASS2;
344 ndlp->nlp_fcp_info |= CLASS3;
346 ndlp->nlp_class_sup = 0;
347 if (sp->cls1.classValid)
348 ndlp->nlp_class_sup |= FC_COS_CLASS1;
349 if (sp->cls2.classValid)
350 ndlp->nlp_class_sup |= FC_COS_CLASS2;
351 if (sp->cls3.classValid)
352 ndlp->nlp_class_sup |= FC_COS_CLASS3;
353 if (sp->cls4.classValid)
354 ndlp->nlp_class_sup |= FC_COS_CLASS4;
356 ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb;
358 /* if already logged in, do implicit logout */
359 switch (ndlp->nlp_state) {
360 case NLP_STE_NPR_NODE:
361 if (!(ndlp->nlp_flag & NLP_NPR_ADISC))
363 case NLP_STE_REG_LOGIN_ISSUE:
364 case NLP_STE_PRLI_ISSUE:
365 case NLP_STE_UNMAPPED_NODE:
366 case NLP_STE_MAPPED_NODE:
367 /* For initiators, lpfc_plogi_confirm_nport skips fabric did.
368 * For target mode, execute implicit logo.
369 * Fabric nodes go into NPR.
371 if (!(ndlp->nlp_type & NLP_FABRIC) &&
372 !(phba->nvmet_support)) {
373 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb,
377 if (nlp_portwwn != 0 &&
378 nlp_portwwn != wwn_to_u64(sp->portName.u.wwn))
379 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
380 "0143 PLOGI recv'd from DID: x%x "
381 "WWPN changed: old %llx new %llx\n",
383 (unsigned long long)nlp_portwwn,
385 wwn_to_u64(sp->portName.u.wwn));
387 ndlp->nlp_prev_state = ndlp->nlp_state;
388 /* rport needs to be unregistered first */
389 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
393 ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
394 ndlp->nlp_type &= ~(NLP_NVME_TARGET | NLP_NVME_INITIATOR);
395 ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
396 ndlp->nlp_flag &= ~NLP_FIRSTBURST;
398 /* Check for Nport to NPort pt2pt protocol */
399 if ((vport->fc_flag & FC_PT2PT) &&
400 !(vport->fc_flag & FC_PT2PT_PLOGI)) {
401 /* rcv'ed PLOGI decides what our NPortId will be */
402 vport->fc_myDID = icmd->un.rcvels.parmRo;
404 ed_tov = be32_to_cpu(sp->cmn.e_d_tov);
405 if (sp->cmn.edtovResolution) {
406 /* E_D_TOV ticks are in nanoseconds */
407 ed_tov = (phba->fc_edtov + 999999) / 1000000;
411 * For pt-to-pt, use the larger EDTOV
414 if (ed_tov > phba->fc_edtov)
415 phba->fc_edtov = ed_tov;
416 phba->fc_ratov = (2 * phba->fc_edtov) / 1000;
418 memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm));
420 /* Issue config_link / reg_vfi to account for updated TOV's */
422 if (phba->sli_rev == LPFC_SLI_REV4)
423 lpfc_issue_reg_vfi(vport);
425 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
428 lpfc_config_link(phba, mbox);
429 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
431 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
432 if (rc == MBX_NOT_FINISHED) {
433 mempool_free(mbox, phba->mbox_mem_pool);
438 lpfc_can_disctmo(vport);
441 ndlp->nlp_flag &= ~NLP_SUPPRESS_RSP;
442 if ((phba->sli.sli_flag & LPFC_SLI_SUPPRESS_RSP) &&
443 sp->cmn.valid_vendor_ver_level) {
444 vid = be32_to_cpu(sp->un.vv.vid);
445 flag = be32_to_cpu(sp->un.vv.flags);
446 if ((vid == LPFC_VV_EMLX_ID) && (flag & LPFC_VV_SUPPRESS_RSP))
447 ndlp->nlp_flag |= NLP_SUPPRESS_RSP;
450 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
454 /* Registering an existing RPI behaves differently for SLI3 vs SLI4 */
455 if (phba->sli_rev == LPFC_SLI_REV4)
456 lpfc_unreg_rpi(vport, ndlp);
458 rc = lpfc_reg_rpi(phba, vport->vpi, icmd->un.rcvels.remoteID,
459 (uint8_t *) sp, mbox, ndlp->nlp_rpi);
461 mempool_free(mbox, phba->mbox_mem_pool);
465 /* ACC PLOGI rsp command needs to execute first,
466 * queue this mbox command to be processed later.
468 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
470 * mbox->context2 = lpfc_nlp_get(ndlp) deferred until mailbox
471 * command issued in lpfc_cmpl_els_acc().
474 spin_lock_irq(shost->host_lock);
475 ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI);
476 spin_unlock_irq(shost->host_lock);
479 * If there is an outstanding PLOGI issued, abort it before
480 * sending ACC rsp for received PLOGI. If pending plogi
481 * is not canceled here, the plogi will be rejected by
482 * remote port and will be retried. On a configuration with
483 * single discovery thread, this will cause a huge delay in
484 * discovery. Also this will cause multiple state machines
485 * running in parallel for this node.
486 * This only applies to a fabric environment.
488 if ((ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) &&
489 (vport->fc_flag & FC_FABRIC)) {
490 /* software abort outstanding PLOGI */
491 lpfc_els_abort(phba, ndlp);
494 if ((vport->port_type == LPFC_NPIV_PORT &&
495 vport->cfg_restrict_login)) {
497 /* In order to preserve RPIs, we want to cleanup
498 * the default RPI the firmware created to rcv
499 * this ELS request. The only way to do this is
500 * to register, then unregister the RPI.
502 spin_lock_irq(shost->host_lock);
503 ndlp->nlp_flag |= NLP_RM_DFLT_RPI;
504 spin_unlock_irq(shost->host_lock);
505 stat.un.b.lsRjtRsnCode = LSRJT_INVALID_CMD;
506 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
507 rc = lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
510 mempool_free(mbox, phba->mbox_mem_pool);
513 rc = lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox);
515 mempool_free(mbox, phba->mbox_mem_pool);
518 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
519 stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE;
520 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
525 * lpfc_mbx_cmpl_resume_rpi - Resume RPI completion routine
526 * @phba: pointer to lpfc hba data structure.
527 * @mboxq: pointer to mailbox object
529 * This routine is invoked to issue a completion to a rcv'ed
530 * ADISC or PDISC after the paused RPI has been resumed.
533 lpfc_mbx_cmpl_resume_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
535 struct lpfc_vport *vport;
536 struct lpfc_iocbq *elsiocb;
537 struct lpfc_nodelist *ndlp;
540 elsiocb = (struct lpfc_iocbq *)mboxq->context1;
541 ndlp = (struct lpfc_nodelist *) mboxq->context2;
542 vport = mboxq->vport;
543 cmd = elsiocb->drvrTimeout;
545 if (cmd == ELS_CMD_ADISC) {
546 lpfc_els_rsp_adisc_acc(vport, elsiocb, ndlp);
548 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, elsiocb,
552 mempool_free(mboxq, phba->mbox_mem_pool);
556 lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
557 struct lpfc_iocbq *cmdiocb)
559 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
560 struct lpfc_iocbq *elsiocb;
561 struct lpfc_dmabuf *pcmd;
562 struct serv_parm *sp;
563 struct lpfc_name *pnn, *ppn;
570 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
571 lp = (uint32_t *) pcmd->virt;
574 if (cmd == ELS_CMD_ADISC) {
576 pnn = (struct lpfc_name *) & ap->nodeName;
577 ppn = (struct lpfc_name *) & ap->portName;
579 sp = (struct serv_parm *) lp;
580 pnn = (struct lpfc_name *) & sp->nodeName;
581 ppn = (struct lpfc_name *) & sp->portName;
584 icmd = &cmdiocb->iocb;
585 if (icmd->ulpStatus == 0 && lpfc_check_adisc(vport, ndlp, pnn, ppn)) {
588 * As soon as we send ACC, the remote NPort can
589 * start sending us data. Thus, for SLI4 we must
590 * resume the RPI before the ACC goes out.
592 if (vport->phba->sli_rev == LPFC_SLI_REV4) {
593 elsiocb = kmalloc(sizeof(struct lpfc_iocbq),
597 /* Save info from cmd IOCB used in rsp */
598 memcpy((uint8_t *)elsiocb, (uint8_t *)cmdiocb,
599 sizeof(struct lpfc_iocbq));
601 /* Save the ELS cmd */
602 elsiocb->drvrTimeout = cmd;
604 lpfc_sli4_resume_rpi(ndlp,
605 lpfc_mbx_cmpl_resume_rpi, elsiocb);
610 if (cmd == ELS_CMD_ADISC) {
611 lpfc_els_rsp_adisc_acc(vport, cmdiocb, ndlp);
613 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb,
617 /* If we are authenticated, move to the proper state */
618 if (ndlp->nlp_type & NLP_FCP_TARGET)
619 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
621 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
625 /* Reject this request because invalid parameters */
626 stat.un.b.lsRjtRsvd0 = 0;
627 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
628 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
629 stat.un.b.vendorUnique = 0;
630 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
633 mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000));
635 spin_lock_irq(shost->host_lock);
636 ndlp->nlp_flag |= NLP_DELAY_TMO;
637 spin_unlock_irq(shost->host_lock);
638 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
639 ndlp->nlp_prev_state = ndlp->nlp_state;
640 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
645 lpfc_rcv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
646 struct lpfc_iocbq *cmdiocb, uint32_t els_cmd)
648 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
649 struct lpfc_hba *phba = vport->phba;
650 struct lpfc_vport **vports;
651 int i, active_vlink_present = 0 ;
653 /* Put ndlp in NPR state with 1 sec timeout for plogi, ACC logo */
654 /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary
655 * PLOGIs during LOGO storms from a device.
657 spin_lock_irq(shost->host_lock);
658 ndlp->nlp_flag |= NLP_LOGO_ACC;
659 spin_unlock_irq(shost->host_lock);
660 if (els_cmd == ELS_CMD_PRLO)
661 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
663 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
664 if (ndlp->nlp_DID == Fabric_DID) {
665 if (vport->port_state <= LPFC_FDISC)
667 lpfc_linkdown_port(vport);
668 spin_lock_irq(shost->host_lock);
669 vport->fc_flag |= FC_VPORT_LOGO_RCVD;
670 spin_unlock_irq(shost->host_lock);
671 vports = lpfc_create_vport_work_array(phba);
673 for (i = 0; i <= phba->max_vports && vports[i] != NULL;
675 if ((!(vports[i]->fc_flag &
676 FC_VPORT_LOGO_RCVD)) &&
677 (vports[i]->port_state > LPFC_FDISC)) {
678 active_vlink_present = 1;
682 lpfc_destroy_vport_work_array(phba, vports);
686 * Don't re-instantiate if vport is marked for deletion.
687 * If we are here first then vport_delete is going to wait
688 * for discovery to complete.
690 if (!(vport->load_flag & FC_UNLOADING) &&
691 active_vlink_present) {
693 * If there are other active VLinks present,
694 * re-instantiate the Vlink using FDISC.
696 mod_timer(&ndlp->nlp_delayfunc,
697 jiffies + msecs_to_jiffies(1000));
698 spin_lock_irq(shost->host_lock);
699 ndlp->nlp_flag |= NLP_DELAY_TMO;
700 spin_unlock_irq(shost->host_lock);
701 ndlp->nlp_last_elscmd = ELS_CMD_FDISC;
702 vport->port_state = LPFC_FDISC;
704 spin_lock_irq(shost->host_lock);
705 phba->pport->fc_flag &= ~FC_LOGO_RCVD_DID_CHNG;
706 spin_unlock_irq(shost->host_lock);
707 lpfc_retry_pport_discovery(phba);
709 } else if ((!(ndlp->nlp_type & NLP_FABRIC) &&
710 ((ndlp->nlp_type & NLP_FCP_TARGET) ||
711 !(ndlp->nlp_type & NLP_FCP_INITIATOR))) ||
712 (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
713 /* Only try to re-login if this is NOT a Fabric Node */
714 mod_timer(&ndlp->nlp_delayfunc,
715 jiffies + msecs_to_jiffies(1000 * 1));
716 spin_lock_irq(shost->host_lock);
717 ndlp->nlp_flag |= NLP_DELAY_TMO;
718 spin_unlock_irq(shost->host_lock);
720 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
723 ndlp->nlp_prev_state = ndlp->nlp_state;
724 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
726 spin_lock_irq(shost->host_lock);
727 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
728 spin_unlock_irq(shost->host_lock);
729 /* The driver has to wait until the ACC completes before it continues
730 * processing the LOGO. The action will resume in
731 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
732 * unreg_login, the driver waits so the ACC does not get aborted.
738 lpfc_rcv_prli_support_check(struct lpfc_vport *vport,
739 struct lpfc_nodelist *ndlp,
740 struct lpfc_iocbq *cmdiocb)
746 payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt;
748 if (vport->phba->nvmet_support) {
749 /* Must be a NVME PRLI */
750 if (cmd == ELS_CMD_PRLI)
753 /* Initiator mode. */
754 if (!vport->nvmei_support && (cmd == ELS_CMD_NVMEPRLI))
759 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NVME_DISC,
760 "6115 Rcv PRLI (%x) check failed: ndlp rpi %d "
761 "state x%x flags x%x\n",
762 cmd, ndlp->nlp_rpi, ndlp->nlp_state,
764 memset(&stat, 0, sizeof(struct ls_rjt));
765 stat.un.b.lsRjtRsnCode = LSRJT_CMD_UNSUPPORTED;
766 stat.un.b.lsRjtRsnCodeExp = LSEXP_REQ_UNSUPPORTED;
767 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
773 lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
774 struct lpfc_iocbq *cmdiocb)
776 struct lpfc_hba *phba = vport->phba;
777 struct lpfc_dmabuf *pcmd;
780 struct fc_rport *rport = ndlp->rport;
783 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
784 lp = (uint32_t *) pcmd->virt;
785 npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t));
787 if ((npr->prliType == PRLI_FCP_TYPE) ||
788 (npr->prliType == PRLI_NVME_TYPE)) {
789 if (npr->initiatorFunc) {
790 if (npr->prliType == PRLI_FCP_TYPE)
791 ndlp->nlp_type |= NLP_FCP_INITIATOR;
792 if (npr->prliType == PRLI_NVME_TYPE)
793 ndlp->nlp_type |= NLP_NVME_INITIATOR;
795 if (npr->targetFunc) {
796 if (npr->prliType == PRLI_FCP_TYPE)
797 ndlp->nlp_type |= NLP_FCP_TARGET;
798 if (npr->prliType == PRLI_NVME_TYPE)
799 ndlp->nlp_type |= NLP_NVME_TARGET;
800 if (npr->writeXferRdyDis)
801 ndlp->nlp_flag |= NLP_FIRSTBURST;
804 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
806 /* If this driver is in nvme target mode, set the ndlp's fc4
807 * type to NVME provided the PRLI response claims NVME FC4
808 * type. Target mode does not issue gft_id so doesn't get
809 * the fc4 type set until now.
811 if (phba->nvmet_support && (npr->prliType == PRLI_NVME_TYPE)) {
812 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
813 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
815 if (npr->prliType == PRLI_FCP_TYPE)
816 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
819 /* We need to update the rport role values */
820 roles = FC_RPORT_ROLE_UNKNOWN;
821 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
822 roles |= FC_RPORT_ROLE_FCP_INITIATOR;
823 if (ndlp->nlp_type & NLP_FCP_TARGET)
824 roles |= FC_RPORT_ROLE_FCP_TARGET;
826 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT,
827 "rport rolechg: role:x%x did:x%x flg:x%x",
828 roles, ndlp->nlp_DID, ndlp->nlp_flag);
830 if (phba->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
831 fc_remote_port_rolechg(rport, roles);
836 lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
838 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
840 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED)) {
841 spin_lock_irq(shost->host_lock);
842 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
843 spin_unlock_irq(shost->host_lock);
847 if (!(vport->fc_flag & FC_PT2PT)) {
848 /* Check config parameter use-adisc or FCP-2 */
849 if (vport->cfg_use_adisc && ((vport->fc_flag & FC_RSCN_MODE) ||
850 ((ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) &&
851 (ndlp->nlp_type & NLP_FCP_TARGET)))) {
852 spin_lock_irq(shost->host_lock);
853 ndlp->nlp_flag |= NLP_NPR_ADISC;
854 spin_unlock_irq(shost->host_lock);
859 spin_lock_irq(shost->host_lock);
860 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
861 spin_unlock_irq(shost->host_lock);
862 lpfc_unreg_rpi(vport, ndlp);
867 * lpfc_release_rpi - Release a RPI by issuing unreg_login mailbox cmd.
868 * @phba : Pointer to lpfc_hba structure.
869 * @vport: Pointer to lpfc_vport structure.
870 * @rpi : rpi to be release.
872 * This function will send a unreg_login mailbox command to the firmware
876 lpfc_release_rpi(struct lpfc_hba *phba,
877 struct lpfc_vport *vport,
883 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
886 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
887 "2796 mailbox memory allocation failed \n");
889 lpfc_unreg_login(phba, vport->vpi, rpi, pmb);
890 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
891 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
892 if (rc == MBX_NOT_FINISHED)
893 mempool_free(pmb, phba->mbox_mem_pool);
898 lpfc_disc_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
899 void *arg, uint32_t evt)
901 struct lpfc_hba *phba;
902 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
906 /* Release the RPI if reglogin completing */
907 if (!(phba->pport->load_flag & FC_UNLOADING) &&
908 (evt == NLP_EVT_CMPL_REG_LOGIN) &&
909 (!pmb->u.mb.mbxStatus)) {
910 rpi = pmb->u.mb.un.varWords[0];
911 lpfc_release_rpi(phba, vport, rpi);
913 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
914 "0271 Illegal State Transition: node x%x "
915 "event x%x, state x%x Data: x%x x%x\n",
916 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
918 return ndlp->nlp_state;
922 lpfc_cmpl_plogi_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
923 void *arg, uint32_t evt)
925 /* This transition is only legal if we previously
926 * rcv'ed a PLOGI. Since we don't want 2 discovery threads
927 * working on the same NPortID, do nothing for this thread
930 if (!(ndlp->nlp_flag & NLP_RCV_PLOGI)) {
931 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
932 "0272 Illegal State Transition: node x%x "
933 "event x%x, state x%x Data: x%x x%x\n",
934 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
937 return ndlp->nlp_state;
940 /* Start of Discovery State Machine routines */
943 lpfc_rcv_plogi_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
944 void *arg, uint32_t evt)
946 struct lpfc_iocbq *cmdiocb;
948 cmdiocb = (struct lpfc_iocbq *) arg;
950 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
951 return ndlp->nlp_state;
953 return NLP_STE_FREED_NODE;
957 lpfc_rcv_els_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
958 void *arg, uint32_t evt)
960 lpfc_issue_els_logo(vport, ndlp, 0);
961 return ndlp->nlp_state;
965 lpfc_rcv_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
966 void *arg, uint32_t evt)
968 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
969 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
971 spin_lock_irq(shost->host_lock);
972 ndlp->nlp_flag |= NLP_LOGO_ACC;
973 spin_unlock_irq(shost->host_lock);
974 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
976 return ndlp->nlp_state;
980 lpfc_cmpl_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
981 void *arg, uint32_t evt)
983 return NLP_STE_FREED_NODE;
987 lpfc_device_rm_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
988 void *arg, uint32_t evt)
990 return NLP_STE_FREED_NODE;
994 lpfc_device_recov_unused_node(struct lpfc_vport *vport,
995 struct lpfc_nodelist *ndlp,
996 void *arg, uint32_t evt)
998 return ndlp->nlp_state;
1002 lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1003 void *arg, uint32_t evt)
1005 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1006 struct lpfc_hba *phba = vport->phba;
1007 struct lpfc_iocbq *cmdiocb = arg;
1008 struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1009 uint32_t *lp = (uint32_t *) pcmd->virt;
1010 struct serv_parm *sp = (struct serv_parm *) (lp + 1);
1014 memset(&stat, 0, sizeof (struct ls_rjt));
1016 /* For a PLOGI, we only accept if our portname is less
1017 * than the remote portname.
1019 phba->fc_stat.elsLogiCol++;
1020 port_cmp = memcmp(&vport->fc_portname, &sp->portName,
1021 sizeof(struct lpfc_name));
1023 if (port_cmp >= 0) {
1024 /* Reject this request because the remote node will accept
1026 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
1027 stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS;
1028 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
1031 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb) &&
1032 (ndlp->nlp_flag & NLP_NPR_2B_DISC) &&
1033 (vport->num_disc_nodes)) {
1034 spin_lock_irq(shost->host_lock);
1035 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1036 spin_unlock_irq(shost->host_lock);
1037 /* Check if there are more PLOGIs to be sent */
1038 lpfc_more_plogi(vport);
1039 if (vport->num_disc_nodes == 0) {
1040 spin_lock_irq(shost->host_lock);
1041 vport->fc_flag &= ~FC_NDISC_ACTIVE;
1042 spin_unlock_irq(shost->host_lock);
1043 lpfc_can_disctmo(vport);
1044 lpfc_end_rscn(vport);
1047 } /* If our portname was less */
1049 return ndlp->nlp_state;
1053 lpfc_rcv_prli_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1054 void *arg, uint32_t evt)
1056 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1059 memset(&stat, 0, sizeof (struct ls_rjt));
1060 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
1061 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
1062 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
1063 return ndlp->nlp_state;
1067 lpfc_rcv_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1068 void *arg, uint32_t evt)
1070 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1072 /* Retrieve RPI from LOGO IOCB. RPI is used for CMD_ABORT_XRI_CN */
1073 if (vport->phba->sli_rev == LPFC_SLI_REV3)
1074 ndlp->nlp_rpi = cmdiocb->iocb.ulpIoTag;
1075 /* software abort outstanding PLOGI */
1076 lpfc_els_abort(vport->phba, ndlp);
1078 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1079 return ndlp->nlp_state;
1083 lpfc_rcv_els_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1084 void *arg, uint32_t evt)
1086 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1087 struct lpfc_hba *phba = vport->phba;
1088 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1090 /* software abort outstanding PLOGI */
1091 lpfc_els_abort(phba, ndlp);
1093 if (evt == NLP_EVT_RCV_LOGO) {
1094 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
1096 lpfc_issue_els_logo(vport, ndlp, 0);
1099 /* Put ndlp in npr state set plogi timer for 1 sec */
1100 mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000 * 1));
1101 spin_lock_irq(shost->host_lock);
1102 ndlp->nlp_flag |= NLP_DELAY_TMO;
1103 spin_unlock_irq(shost->host_lock);
1104 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1105 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
1106 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1108 return ndlp->nlp_state;
1112 lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport,
1113 struct lpfc_nodelist *ndlp,
1117 struct lpfc_hba *phba = vport->phba;
1118 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1119 struct lpfc_iocbq *cmdiocb, *rspiocb;
1120 struct lpfc_dmabuf *pcmd, *prsp, *mp;
1124 struct serv_parm *sp;
1129 cmdiocb = (struct lpfc_iocbq *) arg;
1130 rspiocb = cmdiocb->context_un.rsp_iocb;
1132 if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
1133 /* Recovery from PLOGI collision logic */
1134 return ndlp->nlp_state;
1137 irsp = &rspiocb->iocb;
1139 if (irsp->ulpStatus)
1142 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1144 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list);
1148 lp = (uint32_t *) prsp->virt;
1149 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
1151 /* Some switches have FDMI servers returning 0 for WWN */
1152 if ((ndlp->nlp_DID != FDMI_DID) &&
1153 (wwn_to_u64(sp->portName.u.wwn) == 0 ||
1154 wwn_to_u64(sp->nodeName.u.wwn) == 0)) {
1155 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1156 "0142 PLOGI RSP: Invalid WWN.\n");
1159 if (!lpfc_check_sparm(vport, ndlp, sp, CLASS3, 0))
1161 /* PLOGI chkparm OK */
1162 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1163 "0121 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
1164 ndlp->nlp_DID, ndlp->nlp_state,
1165 ndlp->nlp_flag, ndlp->nlp_rpi);
1166 if (vport->cfg_fcp_class == 2 && (sp->cls2.classValid))
1167 ndlp->nlp_fcp_info |= CLASS2;
1169 ndlp->nlp_fcp_info |= CLASS3;
1171 ndlp->nlp_class_sup = 0;
1172 if (sp->cls1.classValid)
1173 ndlp->nlp_class_sup |= FC_COS_CLASS1;
1174 if (sp->cls2.classValid)
1175 ndlp->nlp_class_sup |= FC_COS_CLASS2;
1176 if (sp->cls3.classValid)
1177 ndlp->nlp_class_sup |= FC_COS_CLASS3;
1178 if (sp->cls4.classValid)
1179 ndlp->nlp_class_sup |= FC_COS_CLASS4;
1180 ndlp->nlp_maxframe =
1181 ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb;
1183 if ((vport->fc_flag & FC_PT2PT) &&
1184 (vport->fc_flag & FC_PT2PT_PLOGI)) {
1185 ed_tov = be32_to_cpu(sp->cmn.e_d_tov);
1186 if (sp->cmn.edtovResolution) {
1187 /* E_D_TOV ticks are in nanoseconds */
1188 ed_tov = (phba->fc_edtov + 999999) / 1000000;
1191 ndlp->nlp_flag &= ~NLP_SUPPRESS_RSP;
1192 if ((phba->sli.sli_flag & LPFC_SLI_SUPPRESS_RSP) &&
1193 sp->cmn.valid_vendor_ver_level) {
1194 vid = be32_to_cpu(sp->un.vv.vid);
1195 flag = be32_to_cpu(sp->un.vv.flags);
1196 if ((vid == LPFC_VV_EMLX_ID) &&
1197 (flag & LPFC_VV_SUPPRESS_RSP))
1198 ndlp->nlp_flag |= NLP_SUPPRESS_RSP;
1202 * Use the larger EDTOV
1203 * RATOV = 2 * EDTOV for pt-to-pt
1205 if (ed_tov > phba->fc_edtov)
1206 phba->fc_edtov = ed_tov;
1207 phba->fc_ratov = (2 * phba->fc_edtov) / 1000;
1209 memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm));
1211 /* Issue config_link / reg_vfi to account for updated TOV's */
1212 if (phba->sli_rev == LPFC_SLI_REV4) {
1213 lpfc_issue_reg_vfi(vport);
1215 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1217 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1218 "0133 PLOGI: no memory "
1220 "Data: x%x x%x x%x x%x\n",
1221 ndlp->nlp_DID, ndlp->nlp_state,
1222 ndlp->nlp_flag, ndlp->nlp_rpi);
1226 lpfc_config_link(phba, mbox);
1228 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1229 mbox->vport = vport;
1230 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
1231 if (rc == MBX_NOT_FINISHED) {
1232 mempool_free(mbox, phba->mbox_mem_pool);
1238 lpfc_unreg_rpi(vport, ndlp);
1240 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1242 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1243 "0018 PLOGI: no memory for reg_login "
1244 "Data: x%x x%x x%x x%x\n",
1245 ndlp->nlp_DID, ndlp->nlp_state,
1246 ndlp->nlp_flag, ndlp->nlp_rpi);
1250 if (lpfc_reg_rpi(phba, vport->vpi, irsp->un.elsreq64.remoteID,
1251 (uint8_t *) sp, mbox, ndlp->nlp_rpi) == 0) {
1252 switch (ndlp->nlp_DID) {
1253 case NameServer_DID:
1254 mbox->mbox_cmpl = lpfc_mbx_cmpl_ns_reg_login;
1257 mbox->mbox_cmpl = lpfc_mbx_cmpl_fdmi_reg_login;
1260 ndlp->nlp_flag |= NLP_REG_LOGIN_SEND;
1261 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
1263 mbox->context2 = lpfc_nlp_get(ndlp);
1264 mbox->vport = vport;
1265 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
1266 != MBX_NOT_FINISHED) {
1267 lpfc_nlp_set_state(vport, ndlp,
1268 NLP_STE_REG_LOGIN_ISSUE);
1269 return ndlp->nlp_state;
1271 if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND)
1272 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1273 /* decrement node reference count to the failed mbox
1277 mp = (struct lpfc_dmabuf *) mbox->context1;
1278 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1280 mempool_free(mbox, phba->mbox_mem_pool);
1282 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1283 "0134 PLOGI: cannot issue reg_login "
1284 "Data: x%x x%x x%x x%x\n",
1285 ndlp->nlp_DID, ndlp->nlp_state,
1286 ndlp->nlp_flag, ndlp->nlp_rpi);
1288 mempool_free(mbox, phba->mbox_mem_pool);
1290 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1291 "0135 PLOGI: cannot format reg_login "
1292 "Data: x%x x%x x%x x%x\n",
1293 ndlp->nlp_DID, ndlp->nlp_state,
1294 ndlp->nlp_flag, ndlp->nlp_rpi);
1299 if (ndlp->nlp_DID == NameServer_DID) {
1300 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1301 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1302 "0261 Cannot Register NameServer login\n");
1306 ** In case the node reference counter does not go to zero, ensure that
1307 ** the stale state for the node is not processed.
1310 ndlp->nlp_prev_state = ndlp->nlp_state;
1311 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1312 spin_lock_irq(shost->host_lock);
1313 ndlp->nlp_flag |= NLP_DEFER_RM;
1314 spin_unlock_irq(shost->host_lock);
1315 return NLP_STE_FREED_NODE;
1319 lpfc_cmpl_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1320 void *arg, uint32_t evt)
1322 return ndlp->nlp_state;
1326 lpfc_cmpl_reglogin_plogi_issue(struct lpfc_vport *vport,
1327 struct lpfc_nodelist *ndlp, void *arg, uint32_t evt)
1329 struct lpfc_hba *phba;
1330 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
1331 MAILBOX_t *mb = &pmb->u.mb;
1335 /* Release the RPI */
1336 if (!(phba->pport->load_flag & FC_UNLOADING) &&
1338 rpi = pmb->u.mb.un.varWords[0];
1339 lpfc_release_rpi(phba, vport, rpi);
1341 return ndlp->nlp_state;
1345 lpfc_device_rm_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1346 void *arg, uint32_t evt)
1348 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1350 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1351 spin_lock_irq(shost->host_lock);
1352 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1353 spin_unlock_irq(shost->host_lock);
1354 return ndlp->nlp_state;
1356 /* software abort outstanding PLOGI */
1357 lpfc_els_abort(vport->phba, ndlp);
1359 lpfc_drop_node(vport, ndlp);
1360 return NLP_STE_FREED_NODE;
1365 lpfc_device_recov_plogi_issue(struct lpfc_vport *vport,
1366 struct lpfc_nodelist *ndlp,
1370 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1371 struct lpfc_hba *phba = vport->phba;
1373 /* Don't do anything that will mess up processing of the
1376 if (vport->fc_flag & FC_RSCN_DEFERRED)
1377 return ndlp->nlp_state;
1379 /* software abort outstanding PLOGI */
1380 lpfc_els_abort(phba, ndlp);
1382 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
1383 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1384 spin_lock_irq(shost->host_lock);
1385 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1386 spin_unlock_irq(shost->host_lock);
1388 return ndlp->nlp_state;
1392 lpfc_rcv_plogi_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1393 void *arg, uint32_t evt)
1395 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1396 struct lpfc_hba *phba = vport->phba;
1397 struct lpfc_iocbq *cmdiocb;
1399 /* software abort outstanding ADISC */
1400 lpfc_els_abort(phba, ndlp);
1402 cmdiocb = (struct lpfc_iocbq *) arg;
1404 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
1405 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1406 spin_lock_irq(shost->host_lock);
1407 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1408 spin_unlock_irq(shost->host_lock);
1409 if (vport->num_disc_nodes)
1410 lpfc_more_adisc(vport);
1412 return ndlp->nlp_state;
1414 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1415 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
1416 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
1418 return ndlp->nlp_state;
1422 lpfc_rcv_prli_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1423 void *arg, uint32_t evt)
1425 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1427 if (lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
1428 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1429 return ndlp->nlp_state;
1433 lpfc_rcv_logo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1434 void *arg, uint32_t evt)
1436 struct lpfc_hba *phba = vport->phba;
1437 struct lpfc_iocbq *cmdiocb;
1439 cmdiocb = (struct lpfc_iocbq *) arg;
1441 /* software abort outstanding ADISC */
1442 lpfc_els_abort(phba, ndlp);
1444 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1445 return ndlp->nlp_state;
1449 lpfc_rcv_padisc_adisc_issue(struct lpfc_vport *vport,
1450 struct lpfc_nodelist *ndlp,
1451 void *arg, uint32_t evt)
1453 struct lpfc_iocbq *cmdiocb;
1455 cmdiocb = (struct lpfc_iocbq *) arg;
1457 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1458 return ndlp->nlp_state;
1462 lpfc_rcv_prlo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1463 void *arg, uint32_t evt)
1465 struct lpfc_iocbq *cmdiocb;
1467 cmdiocb = (struct lpfc_iocbq *) arg;
1469 /* Treat like rcv logo */
1470 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
1471 return ndlp->nlp_state;
1475 lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport *vport,
1476 struct lpfc_nodelist *ndlp,
1477 void *arg, uint32_t evt)
1479 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1480 struct lpfc_hba *phba = vport->phba;
1481 struct lpfc_iocbq *cmdiocb, *rspiocb;
1486 cmdiocb = (struct lpfc_iocbq *) arg;
1487 rspiocb = cmdiocb->context_un.rsp_iocb;
1489 ap = (ADISC *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
1490 irsp = &rspiocb->iocb;
1492 if ((irsp->ulpStatus) ||
1493 (!lpfc_check_adisc(vport, ndlp, &ap->nodeName, &ap->portName))) {
1495 mod_timer(&ndlp->nlp_delayfunc,
1496 jiffies + msecs_to_jiffies(1000));
1497 spin_lock_irq(shost->host_lock);
1498 ndlp->nlp_flag |= NLP_DELAY_TMO;
1499 spin_unlock_irq(shost->host_lock);
1500 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1502 memset(&ndlp->nlp_nodename, 0, sizeof(struct lpfc_name));
1503 memset(&ndlp->nlp_portname, 0, sizeof(struct lpfc_name));
1505 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1506 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1507 lpfc_unreg_rpi(vport, ndlp);
1508 return ndlp->nlp_state;
1511 if (phba->sli_rev == LPFC_SLI_REV4) {
1512 rc = lpfc_sli4_resume_rpi(ndlp, NULL, NULL);
1514 /* Stay in state and retry. */
1515 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1516 return ndlp->nlp_state;
1520 if (ndlp->nlp_type & NLP_FCP_TARGET) {
1521 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1522 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
1524 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1525 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
1528 return ndlp->nlp_state;
1532 lpfc_device_rm_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1533 void *arg, uint32_t evt)
1535 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1537 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1538 spin_lock_irq(shost->host_lock);
1539 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1540 spin_unlock_irq(shost->host_lock);
1541 return ndlp->nlp_state;
1543 /* software abort outstanding ADISC */
1544 lpfc_els_abort(vport->phba, ndlp);
1546 lpfc_drop_node(vport, ndlp);
1547 return NLP_STE_FREED_NODE;
1552 lpfc_device_recov_adisc_issue(struct lpfc_vport *vport,
1553 struct lpfc_nodelist *ndlp,
1557 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1558 struct lpfc_hba *phba = vport->phba;
1560 /* Don't do anything that will mess up processing of the
1563 if (vport->fc_flag & FC_RSCN_DEFERRED)
1564 return ndlp->nlp_state;
1566 /* software abort outstanding ADISC */
1567 lpfc_els_abort(phba, ndlp);
1569 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1570 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1571 spin_lock_irq(shost->host_lock);
1572 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1573 spin_unlock_irq(shost->host_lock);
1574 lpfc_disc_set_adisc(vport, ndlp);
1575 return ndlp->nlp_state;
1579 lpfc_rcv_plogi_reglogin_issue(struct lpfc_vport *vport,
1580 struct lpfc_nodelist *ndlp,
1584 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1586 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
1587 return ndlp->nlp_state;
1591 lpfc_rcv_prli_reglogin_issue(struct lpfc_vport *vport,
1592 struct lpfc_nodelist *ndlp,
1596 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1599 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb)) {
1600 return ndlp->nlp_state;
1602 if (vport->phba->nvmet_support) {
1603 /* NVME Target mode. Handle and respond to the PRLI and
1604 * transition to UNMAPPED provided the RPI has completed
1607 if (ndlp->nlp_flag & NLP_RPI_REGISTERED) {
1608 lpfc_rcv_prli(vport, ndlp, cmdiocb);
1609 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1611 /* RPI registration has not completed. Reject the PRLI
1612 * to prevent an illegal state transition when the
1613 * rpi registration does complete.
1615 memset(&stat, 0, sizeof(struct ls_rjt));
1616 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
1617 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
1618 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
1620 return ndlp->nlp_state;
1623 /* Initiator mode. */
1624 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1626 return ndlp->nlp_state;
1630 lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport,
1631 struct lpfc_nodelist *ndlp,
1635 struct lpfc_hba *phba = vport->phba;
1636 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1638 LPFC_MBOXQ_t *nextmb;
1639 struct lpfc_dmabuf *mp;
1641 cmdiocb = (struct lpfc_iocbq *) arg;
1643 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1644 if ((mb = phba->sli.mbox_active)) {
1645 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1646 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1647 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1649 mb->context2 = NULL;
1650 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1654 spin_lock_irq(&phba->hbalock);
1655 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
1656 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1657 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1658 mp = (struct lpfc_dmabuf *) (mb->context1);
1660 __lpfc_mbuf_free(phba, mp->virt, mp->phys);
1663 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1665 list_del(&mb->list);
1666 phba->sli.mboxq_cnt--;
1667 mempool_free(mb, phba->mbox_mem_pool);
1670 spin_unlock_irq(&phba->hbalock);
1672 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1673 return ndlp->nlp_state;
1677 lpfc_rcv_padisc_reglogin_issue(struct lpfc_vport *vport,
1678 struct lpfc_nodelist *ndlp,
1682 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1684 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1685 return ndlp->nlp_state;
1689 lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport *vport,
1690 struct lpfc_nodelist *ndlp,
1694 struct lpfc_iocbq *cmdiocb;
1696 cmdiocb = (struct lpfc_iocbq *) arg;
1697 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1698 return ndlp->nlp_state;
1702 lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
1703 struct lpfc_nodelist *ndlp,
1707 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1708 struct lpfc_hba *phba = vport->phba;
1709 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
1710 MAILBOX_t *mb = &pmb->u.mb;
1711 uint32_t did = mb->un.varWords[1];
1714 if (mb->mbxStatus) {
1715 /* RegLogin failed */
1716 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1717 "0246 RegLogin failed Data: x%x x%x x%x x%x "
1719 did, mb->mbxStatus, vport->port_state,
1720 mb->un.varRegLogin.vpi,
1721 mb->un.varRegLogin.rpi);
1723 * If RegLogin failed due to lack of HBA resources do not
1726 if (mb->mbxStatus == MBXERR_RPI_FULL) {
1727 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1728 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1729 return ndlp->nlp_state;
1732 /* Put ndlp in npr state set plogi timer for 1 sec */
1733 mod_timer(&ndlp->nlp_delayfunc,
1734 jiffies + msecs_to_jiffies(1000 * 1));
1735 spin_lock_irq(shost->host_lock);
1736 ndlp->nlp_flag |= NLP_DELAY_TMO;
1737 spin_unlock_irq(shost->host_lock);
1738 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1740 lpfc_issue_els_logo(vport, ndlp, 0);
1741 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1742 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1743 return ndlp->nlp_state;
1746 /* SLI4 ports have preallocated logical rpis. */
1747 if (phba->sli_rev < LPFC_SLI_REV4)
1748 ndlp->nlp_rpi = mb->un.varWords[0];
1750 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
1752 /* Only if we are not a fabric nport do we issue PRLI */
1753 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1754 "3066 RegLogin Complete on x%x x%x x%x\n",
1755 did, ndlp->nlp_type, ndlp->nlp_fc4_type);
1756 if (!(ndlp->nlp_type & NLP_FABRIC) &&
1757 (phba->nvmet_support == 0)) {
1758 /* The driver supports FCP and NVME concurrently. If the
1759 * ndlp's nlp_fc4_type is still zero, the driver doesn't
1760 * know what PRLI to send yet. Figure that out now and
1761 * call PRLI depending on the outcome.
1763 if (vport->fc_flag & FC_PT2PT) {
1764 /* If we are pt2pt, there is no Fabric to determine
1765 * the FC4 type of the remote nport. So if NVME
1766 * is configured try it.
1768 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1769 if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1770 (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
1771 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
1772 /* We need to update the localport also */
1773 lpfc_nvme_update_localport(vport);
1776 } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
1777 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1779 } else if (ndlp->nlp_fc4_type == 0) {
1780 rc = lpfc_ns_cmd(vport, SLI_CTNS_GFT_ID,
1782 return ndlp->nlp_state;
1785 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1786 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
1787 lpfc_issue_els_prli(vport, ndlp, 0);
1789 if ((vport->fc_flag & FC_PT2PT) && phba->nvmet_support)
1790 phba->targetport->port_id = vport->fc_myDID;
1792 /* Only Fabric ports should transition. NVME target
1793 * must complete PRLI.
1795 if (ndlp->nlp_type & NLP_FABRIC) {
1796 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1797 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
1800 return ndlp->nlp_state;
1804 lpfc_device_rm_reglogin_issue(struct lpfc_vport *vport,
1805 struct lpfc_nodelist *ndlp,
1809 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1811 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1812 spin_lock_irq(shost->host_lock);
1813 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1814 spin_unlock_irq(shost->host_lock);
1815 return ndlp->nlp_state;
1817 lpfc_drop_node(vport, ndlp);
1818 return NLP_STE_FREED_NODE;
1823 lpfc_device_recov_reglogin_issue(struct lpfc_vport *vport,
1824 struct lpfc_nodelist *ndlp,
1828 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1830 /* Don't do anything that will mess up processing of the
1833 if (vport->fc_flag & FC_RSCN_DEFERRED)
1834 return ndlp->nlp_state;
1836 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1837 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1838 spin_lock_irq(shost->host_lock);
1840 /* If we are a target we won't immediately transition into PRLI,
1841 * so if REG_LOGIN already completed we don't need to ignore it.
1843 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED) ||
1844 !vport->phba->nvmet_support)
1845 ndlp->nlp_flag |= NLP_IGNR_REG_CMPL;
1847 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1848 spin_unlock_irq(shost->host_lock);
1849 lpfc_disc_set_adisc(vport, ndlp);
1850 return ndlp->nlp_state;
1854 lpfc_rcv_plogi_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1855 void *arg, uint32_t evt)
1857 struct lpfc_iocbq *cmdiocb;
1859 cmdiocb = (struct lpfc_iocbq *) arg;
1861 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
1862 return ndlp->nlp_state;
1866 lpfc_rcv_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1867 void *arg, uint32_t evt)
1869 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1871 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
1872 return ndlp->nlp_state;
1873 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1874 return ndlp->nlp_state;
1878 lpfc_rcv_logo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1879 void *arg, uint32_t evt)
1881 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1883 /* Software abort outstanding PRLI before sending acc */
1884 lpfc_els_abort(vport->phba, ndlp);
1886 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1887 return ndlp->nlp_state;
1891 lpfc_rcv_padisc_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1892 void *arg, uint32_t evt)
1894 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1896 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1897 return ndlp->nlp_state;
1900 /* This routine is envoked when we rcv a PRLO request from a nport
1901 * we are logged into. We should send back a PRLO rsp setting the
1903 * NEXT STATE = PRLI_ISSUE
1906 lpfc_rcv_prlo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1907 void *arg, uint32_t evt)
1909 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1911 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1912 return ndlp->nlp_state;
1916 lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1917 void *arg, uint32_t evt)
1919 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1920 struct lpfc_iocbq *cmdiocb, *rspiocb;
1921 struct lpfc_hba *phba = vport->phba;
1924 struct lpfc_nvme_prli *nvpr;
1927 cmdiocb = (struct lpfc_iocbq *) arg;
1928 rspiocb = cmdiocb->context_un.rsp_iocb;
1930 /* A solicited PRLI is either FCP or NVME. The PRLI cmd/rsp
1931 * format is different so NULL the two PRLI types so that the
1932 * driver correctly gets the correct context.
1936 temp_ptr = lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
1937 if (cmdiocb->iocb_flag & LPFC_PRLI_FCP_REQ)
1938 npr = (PRLI *) temp_ptr;
1939 else if (cmdiocb->iocb_flag & LPFC_PRLI_NVME_REQ)
1940 nvpr = (struct lpfc_nvme_prli *) temp_ptr;
1942 irsp = &rspiocb->iocb;
1943 if (irsp->ulpStatus) {
1944 if ((vport->port_type == LPFC_NPIV_PORT) &&
1945 vport->cfg_restrict_login) {
1949 /* Adjust the nlp_type accordingly if the PRLI failed */
1951 ndlp->nlp_fc4_type &= ~NLP_FC4_FCP;
1953 ndlp->nlp_fc4_type &= ~NLP_FC4_NVME;
1955 /* We can't set the DSM state till BOTH PRLIs complete */
1959 if (npr && (npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
1960 (npr->prliType == PRLI_FCP_TYPE)) {
1961 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
1962 "6028 FCP NPR PRLI Cmpl Init %d Target %d\n",
1965 if (npr->initiatorFunc)
1966 ndlp->nlp_type |= NLP_FCP_INITIATOR;
1967 if (npr->targetFunc) {
1968 ndlp->nlp_type |= NLP_FCP_TARGET;
1969 if (npr->writeXferRdyDis)
1970 ndlp->nlp_flag |= NLP_FIRSTBURST;
1973 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
1976 (bf_get_be32(prli_acc_rsp_code, nvpr) ==
1977 PRLI_REQ_EXECUTED) &&
1978 (bf_get_be32(prli_type_code, nvpr) ==
1981 /* Complete setting up the remote ndlp personality. */
1982 if (bf_get_be32(prli_init, nvpr))
1983 ndlp->nlp_type |= NLP_NVME_INITIATOR;
1985 /* Target driver cannot solicit NVME FB. */
1986 if (bf_get_be32(prli_tgt, nvpr)) {
1987 /* Complete the nvme target roles. The transport
1988 * needs to know if the rport is capable of
1989 * discovery in addition to its role.
1991 ndlp->nlp_type |= NLP_NVME_TARGET;
1992 if (bf_get_be32(prli_disc, nvpr))
1993 ndlp->nlp_type |= NLP_NVME_DISCOVERY;
1996 * If prli_fba is set, the Target supports FirstBurst.
1997 * If prli_fb_sz is 0, the FirstBurst size is unlimited,
1998 * otherwise it defines the actual size supported by
2001 if ((bf_get_be32(prli_fba, nvpr) == 1) &&
2002 (phba->cfg_nvme_enable_fb) &&
2003 (!phba->nvmet_support)) {
2004 /* Both sides support FB. The target's first
2005 * burst size is a 512 byte encoded value.
2007 ndlp->nlp_flag |= NLP_FIRSTBURST;
2008 ndlp->nvme_fb_size = bf_get_be32(prli_fb_sz,
2011 /* Expressed in units of 512 bytes */
2012 if (ndlp->nvme_fb_size)
2013 ndlp->nvme_fb_size <<=
2016 ndlp->nvme_fb_size = LPFC_NVME_MAX_FB;
2020 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
2021 "6029 NVME PRLI Cmpl w1 x%08x "
2022 "w4 x%08x w5 x%08x flag x%x, "
2023 "fcp_info x%x nlp_type x%x\n",
2024 be32_to_cpu(nvpr->word1),
2025 be32_to_cpu(nvpr->word4),
2026 be32_to_cpu(nvpr->word5),
2027 ndlp->nlp_flag, ndlp->nlp_fcp_info,
2030 if (!(ndlp->nlp_type & NLP_FCP_TARGET) &&
2031 (vport->port_type == LPFC_NPIV_PORT) &&
2032 vport->cfg_restrict_login) {
2034 spin_lock_irq(shost->host_lock);
2035 ndlp->nlp_flag |= NLP_TARGET_REMOVE;
2036 spin_unlock_irq(shost->host_lock);
2037 lpfc_issue_els_logo(vport, ndlp, 0);
2039 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2040 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2041 return ndlp->nlp_state;
2045 /* The ndlp state cannot move to MAPPED or UNMAPPED before all PRLIs
2048 if (ndlp->fc4_prli_sent == 0) {
2049 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2050 if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET))
2051 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
2052 else if (ndlp->nlp_type &
2053 (NLP_FCP_INITIATOR | NLP_NVME_INITIATOR))
2054 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
2056 lpfc_printf_vlog(vport,
2058 "3067 PRLI's still outstanding "
2059 "on x%06x - count %d, Pend Node Mode "
2061 ndlp->nlp_DID, ndlp->fc4_prli_sent);
2063 return ndlp->nlp_state;
2066 /*! lpfc_device_rm_prli_issue
2077 * This routine is envoked when we a request to remove a nport we are in the
2078 * process of PRLIing. We should software abort outstanding prli, unreg
2079 * login, send a logout. We will change node state to UNUSED_NODE, put it
2080 * on plogi list so it can be freed when LOGO completes.
2085 lpfc_device_rm_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2086 void *arg, uint32_t evt)
2088 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2090 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
2091 spin_lock_irq(shost->host_lock);
2092 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
2093 spin_unlock_irq(shost->host_lock);
2094 return ndlp->nlp_state;
2096 /* software abort outstanding PLOGI */
2097 lpfc_els_abort(vport->phba, ndlp);
2099 lpfc_drop_node(vport, ndlp);
2100 return NLP_STE_FREED_NODE;
2105 /*! lpfc_device_recov_prli_issue
2116 * The routine is envoked when the state of a device is unknown, like
2117 * during a link down. We should remove the nodelist entry from the
2118 * unmapped list, issue a UNREG_LOGIN, do a software abort of the
2119 * outstanding PRLI command, then free the node entry.
2122 lpfc_device_recov_prli_issue(struct lpfc_vport *vport,
2123 struct lpfc_nodelist *ndlp,
2127 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2128 struct lpfc_hba *phba = vport->phba;
2130 /* Don't do anything that will mess up processing of the
2133 if (vport->fc_flag & FC_RSCN_DEFERRED)
2134 return ndlp->nlp_state;
2136 /* software abort outstanding PRLI */
2137 lpfc_els_abort(phba, ndlp);
2139 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2140 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2141 spin_lock_irq(shost->host_lock);
2142 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2143 spin_unlock_irq(shost->host_lock);
2144 lpfc_disc_set_adisc(vport, ndlp);
2145 return ndlp->nlp_state;
2149 lpfc_rcv_plogi_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2150 void *arg, uint32_t evt)
2152 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2155 memset(&stat, 0, sizeof(struct ls_rjt));
2156 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2157 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2158 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2159 return ndlp->nlp_state;
2163 lpfc_rcv_prli_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2164 void *arg, uint32_t evt)
2166 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2169 memset(&stat, 0, sizeof(struct ls_rjt));
2170 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2171 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2172 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2173 return ndlp->nlp_state;
2177 lpfc_rcv_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2178 void *arg, uint32_t evt)
2180 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2181 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2183 spin_lock_irq(shost->host_lock);
2184 ndlp->nlp_flag |= NLP_LOGO_ACC;
2185 spin_unlock_irq(shost->host_lock);
2186 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2187 return ndlp->nlp_state;
2191 lpfc_rcv_padisc_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2192 void *arg, uint32_t evt)
2194 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2197 memset(&stat, 0, sizeof(struct ls_rjt));
2198 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2199 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2200 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2201 return ndlp->nlp_state;
2205 lpfc_rcv_prlo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2206 void *arg, uint32_t evt)
2208 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2211 memset(&stat, 0, sizeof(struct ls_rjt));
2212 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2213 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2214 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2215 return ndlp->nlp_state;
2219 lpfc_cmpl_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2220 void *arg, uint32_t evt)
2222 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2224 ndlp->nlp_prev_state = NLP_STE_LOGO_ISSUE;
2225 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2226 spin_lock_irq(shost->host_lock);
2227 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2228 spin_unlock_irq(shost->host_lock);
2229 lpfc_disc_set_adisc(vport, ndlp);
2230 return ndlp->nlp_state;
2234 lpfc_device_rm_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2235 void *arg, uint32_t evt)
2238 * DevLoss has timed out and is calling for Device Remove.
2239 * In this case, abort the LOGO and cleanup the ndlp
2242 lpfc_unreg_rpi(vport, ndlp);
2243 /* software abort outstanding PLOGI */
2244 lpfc_els_abort(vport->phba, ndlp);
2245 lpfc_drop_node(vport, ndlp);
2246 return NLP_STE_FREED_NODE;
2250 lpfc_device_recov_logo_issue(struct lpfc_vport *vport,
2251 struct lpfc_nodelist *ndlp,
2252 void *arg, uint32_t evt)
2255 * Device Recovery events have no meaning for a node with a LOGO
2256 * outstanding. The LOGO has to complete first and handle the
2257 * node from that point.
2259 return ndlp->nlp_state;
2263 lpfc_rcv_plogi_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2264 void *arg, uint32_t evt)
2266 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2268 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
2269 return ndlp->nlp_state;
2273 lpfc_rcv_prli_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2274 void *arg, uint32_t evt)
2276 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2278 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
2279 return ndlp->nlp_state;
2281 lpfc_rcv_prli(vport, ndlp, cmdiocb);
2282 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
2283 return ndlp->nlp_state;
2287 lpfc_rcv_logo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2288 void *arg, uint32_t evt)
2290 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2292 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2293 return ndlp->nlp_state;
2297 lpfc_rcv_padisc_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2298 void *arg, uint32_t evt)
2300 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2302 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2303 return ndlp->nlp_state;
2307 lpfc_rcv_prlo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2308 void *arg, uint32_t evt)
2310 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2312 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
2313 return ndlp->nlp_state;
2317 lpfc_device_recov_unmap_node(struct lpfc_vport *vport,
2318 struct lpfc_nodelist *ndlp,
2322 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2324 ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
2325 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2326 spin_lock_irq(shost->host_lock);
2327 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2328 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2329 spin_unlock_irq(shost->host_lock);
2330 lpfc_disc_set_adisc(vport, ndlp);
2332 return ndlp->nlp_state;
2336 lpfc_rcv_plogi_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2337 void *arg, uint32_t evt)
2339 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2341 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
2342 return ndlp->nlp_state;
2346 lpfc_rcv_prli_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2347 void *arg, uint32_t evt)
2349 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2351 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
2352 return ndlp->nlp_state;
2353 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
2354 return ndlp->nlp_state;
2358 lpfc_rcv_logo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2359 void *arg, uint32_t evt)
2361 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2363 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2364 return ndlp->nlp_state;
2368 lpfc_rcv_padisc_mapped_node(struct lpfc_vport *vport,
2369 struct lpfc_nodelist *ndlp,
2370 void *arg, uint32_t evt)
2372 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2374 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2375 return ndlp->nlp_state;
2379 lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2380 void *arg, uint32_t evt)
2382 struct lpfc_hba *phba = vport->phba;
2383 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2385 /* flush the target */
2386 lpfc_sli_abort_iocb(vport, &phba->sli.sli3_ring[LPFC_FCP_RING],
2387 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
2389 /* Treat like rcv logo */
2390 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
2391 return ndlp->nlp_state;
2395 lpfc_device_recov_mapped_node(struct lpfc_vport *vport,
2396 struct lpfc_nodelist *ndlp,
2400 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2402 ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
2403 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2404 spin_lock_irq(shost->host_lock);
2405 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2406 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2407 spin_unlock_irq(shost->host_lock);
2408 lpfc_disc_set_adisc(vport, ndlp);
2409 return ndlp->nlp_state;
2413 lpfc_rcv_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2414 void *arg, uint32_t evt)
2416 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2417 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2419 /* Ignore PLOGI if we have an outstanding LOGO */
2420 if (ndlp->nlp_flag & (NLP_LOGO_SND | NLP_LOGO_ACC))
2421 return ndlp->nlp_state;
2422 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
2423 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2424 spin_lock_irq(shost->host_lock);
2425 ndlp->nlp_flag &= ~(NLP_NPR_ADISC | NLP_NPR_2B_DISC);
2426 spin_unlock_irq(shost->host_lock);
2427 } else if (!(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
2428 /* send PLOGI immediately, move to PLOGI issue state */
2429 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
2430 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2431 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2432 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2435 return ndlp->nlp_state;
2439 lpfc_rcv_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2440 void *arg, uint32_t evt)
2442 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2443 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2446 memset(&stat, 0, sizeof (struct ls_rjt));
2447 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2448 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2449 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2451 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
2452 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
2453 spin_lock_irq(shost->host_lock);
2454 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2455 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2456 spin_unlock_irq(shost->host_lock);
2457 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2458 lpfc_issue_els_adisc(vport, ndlp, 0);
2460 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2461 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2462 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2465 return ndlp->nlp_state;
2469 lpfc_rcv_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2470 void *arg, uint32_t evt)
2472 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2474 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2475 return ndlp->nlp_state;
2479 lpfc_rcv_padisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2480 void *arg, uint32_t evt)
2482 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2484 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2486 * Do not start discovery if discovery is about to start
2487 * or discovery in progress for this node. Starting discovery
2488 * here will affect the counting of discovery threads.
2490 if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
2491 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
2492 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
2493 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2494 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2495 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2496 lpfc_issue_els_adisc(vport, ndlp, 0);
2498 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2499 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2500 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2503 return ndlp->nlp_state;
2507 lpfc_rcv_prlo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2508 void *arg, uint32_t evt)
2510 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2511 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2513 spin_lock_irq(shost->host_lock);
2514 ndlp->nlp_flag |= NLP_LOGO_ACC;
2515 spin_unlock_irq(shost->host_lock);
2517 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2519 if ((ndlp->nlp_flag & NLP_DELAY_TMO) == 0) {
2520 mod_timer(&ndlp->nlp_delayfunc,
2521 jiffies + msecs_to_jiffies(1000 * 1));
2522 spin_lock_irq(shost->host_lock);
2523 ndlp->nlp_flag |= NLP_DELAY_TMO;
2524 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2525 spin_unlock_irq(shost->host_lock);
2526 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
2528 spin_lock_irq(shost->host_lock);
2529 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2530 spin_unlock_irq(shost->host_lock);
2532 return ndlp->nlp_state;
2536 lpfc_cmpl_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2537 void *arg, uint32_t evt)
2539 struct lpfc_iocbq *cmdiocb, *rspiocb;
2541 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2543 cmdiocb = (struct lpfc_iocbq *) arg;
2544 rspiocb = cmdiocb->context_un.rsp_iocb;
2546 irsp = &rspiocb->iocb;
2547 if (irsp->ulpStatus) {
2548 spin_lock_irq(shost->host_lock);
2549 ndlp->nlp_flag |= NLP_DEFER_RM;
2550 spin_unlock_irq(shost->host_lock);
2551 return NLP_STE_FREED_NODE;
2553 return ndlp->nlp_state;
2557 lpfc_cmpl_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2558 void *arg, uint32_t evt)
2560 struct lpfc_iocbq *cmdiocb, *rspiocb;
2563 cmdiocb = (struct lpfc_iocbq *) arg;
2564 rspiocb = cmdiocb->context_un.rsp_iocb;
2566 irsp = &rspiocb->iocb;
2567 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
2568 lpfc_drop_node(vport, ndlp);
2569 return NLP_STE_FREED_NODE;
2571 return ndlp->nlp_state;
2575 lpfc_cmpl_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2576 void *arg, uint32_t evt)
2578 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2580 /* For the fabric port just clear the fc flags. */
2581 if (ndlp->nlp_DID == Fabric_DID) {
2582 spin_lock_irq(shost->host_lock);
2583 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
2584 spin_unlock_irq(shost->host_lock);
2586 lpfc_unreg_rpi(vport, ndlp);
2587 return ndlp->nlp_state;
2591 lpfc_cmpl_adisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2592 void *arg, uint32_t evt)
2594 struct lpfc_iocbq *cmdiocb, *rspiocb;
2597 cmdiocb = (struct lpfc_iocbq *) arg;
2598 rspiocb = cmdiocb->context_un.rsp_iocb;
2600 irsp = &rspiocb->iocb;
2601 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
2602 lpfc_drop_node(vport, ndlp);
2603 return NLP_STE_FREED_NODE;
2605 return ndlp->nlp_state;
2609 lpfc_cmpl_reglogin_npr_node(struct lpfc_vport *vport,
2610 struct lpfc_nodelist *ndlp,
2611 void *arg, uint32_t evt)
2613 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
2614 MAILBOX_t *mb = &pmb->u.mb;
2616 if (!mb->mbxStatus) {
2617 /* SLI4 ports have preallocated logical rpis. */
2618 if (vport->phba->sli_rev < LPFC_SLI_REV4)
2619 ndlp->nlp_rpi = mb->un.varWords[0];
2620 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
2621 if (ndlp->nlp_flag & NLP_LOGO_ACC) {
2622 lpfc_unreg_rpi(vport, ndlp);
2625 if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
2626 lpfc_drop_node(vport, ndlp);
2627 return NLP_STE_FREED_NODE;
2630 return ndlp->nlp_state;
2634 lpfc_device_rm_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2635 void *arg, uint32_t evt)
2637 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2639 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
2640 spin_lock_irq(shost->host_lock);
2641 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
2642 spin_unlock_irq(shost->host_lock);
2643 return ndlp->nlp_state;
2645 lpfc_drop_node(vport, ndlp);
2646 return NLP_STE_FREED_NODE;
2650 lpfc_device_recov_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2651 void *arg, uint32_t evt)
2653 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2655 /* Don't do anything that will mess up processing of the
2658 if (vport->fc_flag & FC_RSCN_DEFERRED)
2659 return ndlp->nlp_state;
2661 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2662 spin_lock_irq(shost->host_lock);
2663 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2664 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2665 spin_unlock_irq(shost->host_lock);
2666 return ndlp->nlp_state;
2670 /* This next section defines the NPort Discovery State Machine */
2672 /* There are 4 different double linked lists nodelist entries can reside on.
2673 * The plogi list and adisc list are used when Link Up discovery or RSCN
2674 * processing is needed. Each list holds the nodes that we will send PLOGI
2675 * or ADISC on. These lists will keep track of what nodes will be effected
2676 * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
2677 * The unmapped_list will contain all nodes that we have successfully logged
2678 * into at the Fibre Channel level. The mapped_list will contain all nodes
2679 * that are mapped FCP targets.
2682 * The bind list is a list of undiscovered (potentially non-existent) nodes
2683 * that we have saved binding information on. This information is used when
2684 * nodes transition from the unmapped to the mapped list.
2686 /* For UNUSED_NODE state, the node has just been allocated .
2687 * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
2688 * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
2689 * and put on the unmapped list. For ADISC processing, the node is taken off
2690 * the ADISC list and placed on either the mapped or unmapped list (depending
2691 * on its previous state). Once on the unmapped list, a PRLI is issued and the
2692 * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
2693 * changed to UNMAPPED_NODE. If the completion indicates a mapped
2694 * node, the node is taken off the unmapped list. The binding list is checked
2695 * for a valid binding, or a binding is automatically assigned. If binding
2696 * assignment is unsuccessful, the node is left on the unmapped list. If
2697 * binding assignment is successful, the associated binding list entry (if
2698 * any) is removed, and the node is placed on the mapped list.
2701 * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
2702 * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
2703 * expire, all effected nodes will receive a DEVICE_RM event.
2706 * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
2707 * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
2708 * check, additional nodes may be added or removed (via DEVICE_RM) to / from
2709 * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
2710 * we will first process the ADISC list. 32 entries are processed initially and
2711 * ADISC is initited for each one. Completions / Events for each node are
2712 * funnelled thru the state machine. As each node finishes ADISC processing, it
2713 * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
2714 * waiting, and the ADISC list count is identically 0, then we are done. For
2715 * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
2716 * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
2717 * list. 32 entries are processed initially and PLOGI is initited for each one.
2718 * Completions / Events for each node are funnelled thru the state machine. As
2719 * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
2720 * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
2721 * indentically 0, then we are done. We have now completed discovery / RSCN
2722 * handling. Upon completion, ALL nodes should be on either the mapped or
2726 static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
2727 (struct lpfc_vport *, struct lpfc_nodelist *, void *, uint32_t) = {
2728 /* Action routine Event Current State */
2729 lpfc_rcv_plogi_unused_node, /* RCV_PLOGI UNUSED_NODE */
2730 lpfc_rcv_els_unused_node, /* RCV_PRLI */
2731 lpfc_rcv_logo_unused_node, /* RCV_LOGO */
2732 lpfc_rcv_els_unused_node, /* RCV_ADISC */
2733 lpfc_rcv_els_unused_node, /* RCV_PDISC */
2734 lpfc_rcv_els_unused_node, /* RCV_PRLO */
2735 lpfc_disc_illegal, /* CMPL_PLOGI */
2736 lpfc_disc_illegal, /* CMPL_PRLI */
2737 lpfc_cmpl_logo_unused_node, /* CMPL_LOGO */
2738 lpfc_disc_illegal, /* CMPL_ADISC */
2739 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2740 lpfc_device_rm_unused_node, /* DEVICE_RM */
2741 lpfc_device_recov_unused_node, /* DEVICE_RECOVERY */
2743 lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */
2744 lpfc_rcv_prli_plogi_issue, /* RCV_PRLI */
2745 lpfc_rcv_logo_plogi_issue, /* RCV_LOGO */
2746 lpfc_rcv_els_plogi_issue, /* RCV_ADISC */
2747 lpfc_rcv_els_plogi_issue, /* RCV_PDISC */
2748 lpfc_rcv_els_plogi_issue, /* RCV_PRLO */
2749 lpfc_cmpl_plogi_plogi_issue, /* CMPL_PLOGI */
2750 lpfc_disc_illegal, /* CMPL_PRLI */
2751 lpfc_cmpl_logo_plogi_issue, /* CMPL_LOGO */
2752 lpfc_disc_illegal, /* CMPL_ADISC */
2753 lpfc_cmpl_reglogin_plogi_issue,/* CMPL_REG_LOGIN */
2754 lpfc_device_rm_plogi_issue, /* DEVICE_RM */
2755 lpfc_device_recov_plogi_issue, /* DEVICE_RECOVERY */
2757 lpfc_rcv_plogi_adisc_issue, /* RCV_PLOGI ADISC_ISSUE */
2758 lpfc_rcv_prli_adisc_issue, /* RCV_PRLI */
2759 lpfc_rcv_logo_adisc_issue, /* RCV_LOGO */
2760 lpfc_rcv_padisc_adisc_issue, /* RCV_ADISC */
2761 lpfc_rcv_padisc_adisc_issue, /* RCV_PDISC */
2762 lpfc_rcv_prlo_adisc_issue, /* RCV_PRLO */
2763 lpfc_disc_illegal, /* CMPL_PLOGI */
2764 lpfc_disc_illegal, /* CMPL_PRLI */
2765 lpfc_disc_illegal, /* CMPL_LOGO */
2766 lpfc_cmpl_adisc_adisc_issue, /* CMPL_ADISC */
2767 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2768 lpfc_device_rm_adisc_issue, /* DEVICE_RM */
2769 lpfc_device_recov_adisc_issue, /* DEVICE_RECOVERY */
2771 lpfc_rcv_plogi_reglogin_issue, /* RCV_PLOGI REG_LOGIN_ISSUE */
2772 lpfc_rcv_prli_reglogin_issue, /* RCV_PLOGI */
2773 lpfc_rcv_logo_reglogin_issue, /* RCV_LOGO */
2774 lpfc_rcv_padisc_reglogin_issue, /* RCV_ADISC */
2775 lpfc_rcv_padisc_reglogin_issue, /* RCV_PDISC */
2776 lpfc_rcv_prlo_reglogin_issue, /* RCV_PRLO */
2777 lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */
2778 lpfc_disc_illegal, /* CMPL_PRLI */
2779 lpfc_disc_illegal, /* CMPL_LOGO */
2780 lpfc_disc_illegal, /* CMPL_ADISC */
2781 lpfc_cmpl_reglogin_reglogin_issue,/* CMPL_REG_LOGIN */
2782 lpfc_device_rm_reglogin_issue, /* DEVICE_RM */
2783 lpfc_device_recov_reglogin_issue,/* DEVICE_RECOVERY */
2785 lpfc_rcv_plogi_prli_issue, /* RCV_PLOGI PRLI_ISSUE */
2786 lpfc_rcv_prli_prli_issue, /* RCV_PRLI */
2787 lpfc_rcv_logo_prli_issue, /* RCV_LOGO */
2788 lpfc_rcv_padisc_prli_issue, /* RCV_ADISC */
2789 lpfc_rcv_padisc_prli_issue, /* RCV_PDISC */
2790 lpfc_rcv_prlo_prli_issue, /* RCV_PRLO */
2791 lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */
2792 lpfc_cmpl_prli_prli_issue, /* CMPL_PRLI */
2793 lpfc_disc_illegal, /* CMPL_LOGO */
2794 lpfc_disc_illegal, /* CMPL_ADISC */
2795 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2796 lpfc_device_rm_prli_issue, /* DEVICE_RM */
2797 lpfc_device_recov_prli_issue, /* DEVICE_RECOVERY */
2799 lpfc_rcv_plogi_logo_issue, /* RCV_PLOGI LOGO_ISSUE */
2800 lpfc_rcv_prli_logo_issue, /* RCV_PRLI */
2801 lpfc_rcv_logo_logo_issue, /* RCV_LOGO */
2802 lpfc_rcv_padisc_logo_issue, /* RCV_ADISC */
2803 lpfc_rcv_padisc_logo_issue, /* RCV_PDISC */
2804 lpfc_rcv_prlo_logo_issue, /* RCV_PRLO */
2805 lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */
2806 lpfc_disc_illegal, /* CMPL_PRLI */
2807 lpfc_cmpl_logo_logo_issue, /* CMPL_LOGO */
2808 lpfc_disc_illegal, /* CMPL_ADISC */
2809 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2810 lpfc_device_rm_logo_issue, /* DEVICE_RM */
2811 lpfc_device_recov_logo_issue, /* DEVICE_RECOVERY */
2813 lpfc_rcv_plogi_unmap_node, /* RCV_PLOGI UNMAPPED_NODE */
2814 lpfc_rcv_prli_unmap_node, /* RCV_PRLI */
2815 lpfc_rcv_logo_unmap_node, /* RCV_LOGO */
2816 lpfc_rcv_padisc_unmap_node, /* RCV_ADISC */
2817 lpfc_rcv_padisc_unmap_node, /* RCV_PDISC */
2818 lpfc_rcv_prlo_unmap_node, /* RCV_PRLO */
2819 lpfc_disc_illegal, /* CMPL_PLOGI */
2820 lpfc_disc_illegal, /* CMPL_PRLI */
2821 lpfc_disc_illegal, /* CMPL_LOGO */
2822 lpfc_disc_illegal, /* CMPL_ADISC */
2823 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2824 lpfc_disc_illegal, /* DEVICE_RM */
2825 lpfc_device_recov_unmap_node, /* DEVICE_RECOVERY */
2827 lpfc_rcv_plogi_mapped_node, /* RCV_PLOGI MAPPED_NODE */
2828 lpfc_rcv_prli_mapped_node, /* RCV_PRLI */
2829 lpfc_rcv_logo_mapped_node, /* RCV_LOGO */
2830 lpfc_rcv_padisc_mapped_node, /* RCV_ADISC */
2831 lpfc_rcv_padisc_mapped_node, /* RCV_PDISC */
2832 lpfc_rcv_prlo_mapped_node, /* RCV_PRLO */
2833 lpfc_disc_illegal, /* CMPL_PLOGI */
2834 lpfc_disc_illegal, /* CMPL_PRLI */
2835 lpfc_disc_illegal, /* CMPL_LOGO */
2836 lpfc_disc_illegal, /* CMPL_ADISC */
2837 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2838 lpfc_disc_illegal, /* DEVICE_RM */
2839 lpfc_device_recov_mapped_node, /* DEVICE_RECOVERY */
2841 lpfc_rcv_plogi_npr_node, /* RCV_PLOGI NPR_NODE */
2842 lpfc_rcv_prli_npr_node, /* RCV_PRLI */
2843 lpfc_rcv_logo_npr_node, /* RCV_LOGO */
2844 lpfc_rcv_padisc_npr_node, /* RCV_ADISC */
2845 lpfc_rcv_padisc_npr_node, /* RCV_PDISC */
2846 lpfc_rcv_prlo_npr_node, /* RCV_PRLO */
2847 lpfc_cmpl_plogi_npr_node, /* CMPL_PLOGI */
2848 lpfc_cmpl_prli_npr_node, /* CMPL_PRLI */
2849 lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */
2850 lpfc_cmpl_adisc_npr_node, /* CMPL_ADISC */
2851 lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */
2852 lpfc_device_rm_npr_node, /* DEVICE_RM */
2853 lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */
2857 lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2858 void *arg, uint32_t evt)
2860 uint32_t cur_state, rc;
2861 uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *,
2863 uint32_t got_ndlp = 0;
2865 if (lpfc_nlp_get(ndlp))
2868 cur_state = ndlp->nlp_state;
2870 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
2871 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2872 "0211 DSM in event x%x on NPort x%x in "
2873 "state %d Data: x%x x%x\n",
2874 evt, ndlp->nlp_DID, cur_state,
2875 ndlp->nlp_flag, ndlp->nlp_fc4_type);
2877 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2878 "DSM in: evt:%d ste:%d did:x%x",
2879 evt, cur_state, ndlp->nlp_DID);
2881 func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt];
2882 rc = (func) (vport, ndlp, arg, evt);
2884 /* DSM out state <rc> on NPort <nlp_DID> */
2886 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2887 "0212 DSM out state %d on NPort x%x Data: x%x\n",
2888 rc, ndlp->nlp_DID, ndlp->nlp_flag);
2890 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2891 "DSM out: ste:%d did:x%x flg:x%x",
2892 rc, ndlp->nlp_DID, ndlp->nlp_flag);
2893 /* Decrement the ndlp reference count held for this function */
2896 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2897 "0213 DSM out state %d on NPort free\n", rc);
2899 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2900 "DSM out: ste:%d did:x%x flg:x%x",