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 ||
666 vport->fc_flag & FC_PT2PT)
668 lpfc_linkdown_port(vport);
669 spin_lock_irq(shost->host_lock);
670 vport->fc_flag |= FC_VPORT_LOGO_RCVD;
671 spin_unlock_irq(shost->host_lock);
672 vports = lpfc_create_vport_work_array(phba);
674 for (i = 0; i <= phba->max_vports && vports[i] != NULL;
676 if ((!(vports[i]->fc_flag &
677 FC_VPORT_LOGO_RCVD)) &&
678 (vports[i]->port_state > LPFC_FDISC)) {
679 active_vlink_present = 1;
683 lpfc_destroy_vport_work_array(phba, vports);
687 * Don't re-instantiate if vport is marked for deletion.
688 * If we are here first then vport_delete is going to wait
689 * for discovery to complete.
691 if (!(vport->load_flag & FC_UNLOADING) &&
692 active_vlink_present) {
694 * If there are other active VLinks present,
695 * re-instantiate the Vlink using FDISC.
697 mod_timer(&ndlp->nlp_delayfunc,
698 jiffies + msecs_to_jiffies(1000));
699 spin_lock_irq(shost->host_lock);
700 ndlp->nlp_flag |= NLP_DELAY_TMO;
701 spin_unlock_irq(shost->host_lock);
702 ndlp->nlp_last_elscmd = ELS_CMD_FDISC;
703 vport->port_state = LPFC_FDISC;
705 spin_lock_irq(shost->host_lock);
706 phba->pport->fc_flag &= ~FC_LOGO_RCVD_DID_CHNG;
707 spin_unlock_irq(shost->host_lock);
708 lpfc_retry_pport_discovery(phba);
710 } else if ((!(ndlp->nlp_type & NLP_FABRIC) &&
711 ((ndlp->nlp_type & NLP_FCP_TARGET) ||
712 (ndlp->nlp_type & NLP_NVME_TARGET) ||
713 (vport->fc_flag & FC_PT2PT))) ||
714 (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
715 /* Only try to re-login if this is NOT a Fabric Node
716 * AND the remote NPORT is a FCP/NVME Target or we
717 * are in pt2pt mode. NLP_STE_ADISC_ISSUE is a special
718 * case for LOGO as a response to ADISC behavior.
720 mod_timer(&ndlp->nlp_delayfunc,
721 jiffies + msecs_to_jiffies(1000 * 1));
722 spin_lock_irq(shost->host_lock);
723 ndlp->nlp_flag |= NLP_DELAY_TMO;
724 spin_unlock_irq(shost->host_lock);
726 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
729 ndlp->nlp_prev_state = ndlp->nlp_state;
730 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
732 spin_lock_irq(shost->host_lock);
733 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
734 spin_unlock_irq(shost->host_lock);
735 /* The driver has to wait until the ACC completes before it continues
736 * processing the LOGO. The action will resume in
737 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
738 * unreg_login, the driver waits so the ACC does not get aborted.
744 lpfc_rcv_prli_support_check(struct lpfc_vport *vport,
745 struct lpfc_nodelist *ndlp,
746 struct lpfc_iocbq *cmdiocb)
752 payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt;
754 if (vport->phba->nvmet_support) {
755 /* Must be a NVME PRLI */
756 if (cmd == ELS_CMD_PRLI)
759 /* Initiator mode. */
760 if (!vport->nvmei_support && (cmd == ELS_CMD_NVMEPRLI))
765 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NVME_DISC,
766 "6115 Rcv PRLI (%x) check failed: ndlp rpi %d "
767 "state x%x flags x%x\n",
768 cmd, ndlp->nlp_rpi, ndlp->nlp_state,
770 memset(&stat, 0, sizeof(struct ls_rjt));
771 stat.un.b.lsRjtRsnCode = LSRJT_CMD_UNSUPPORTED;
772 stat.un.b.lsRjtRsnCodeExp = LSEXP_REQ_UNSUPPORTED;
773 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
779 lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
780 struct lpfc_iocbq *cmdiocb)
782 struct lpfc_hba *phba = vport->phba;
783 struct lpfc_dmabuf *pcmd;
786 struct fc_rport *rport = ndlp->rport;
789 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
790 lp = (uint32_t *) pcmd->virt;
791 npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t));
793 if ((npr->prliType == PRLI_FCP_TYPE) ||
794 (npr->prliType == PRLI_NVME_TYPE)) {
795 if (npr->initiatorFunc) {
796 if (npr->prliType == PRLI_FCP_TYPE)
797 ndlp->nlp_type |= NLP_FCP_INITIATOR;
798 if (npr->prliType == PRLI_NVME_TYPE)
799 ndlp->nlp_type |= NLP_NVME_INITIATOR;
801 if (npr->targetFunc) {
802 if (npr->prliType == PRLI_FCP_TYPE)
803 ndlp->nlp_type |= NLP_FCP_TARGET;
804 if (npr->prliType == PRLI_NVME_TYPE)
805 ndlp->nlp_type |= NLP_NVME_TARGET;
806 if (npr->writeXferRdyDis)
807 ndlp->nlp_flag |= NLP_FIRSTBURST;
810 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
812 /* If this driver is in nvme target mode, set the ndlp's fc4
813 * type to NVME provided the PRLI response claims NVME FC4
814 * type. Target mode does not issue gft_id so doesn't get
815 * the fc4 type set until now.
817 if (phba->nvmet_support && (npr->prliType == PRLI_NVME_TYPE)) {
818 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
819 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
821 if (npr->prliType == PRLI_FCP_TYPE)
822 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
825 /* We need to update the rport role values */
826 roles = FC_RPORT_ROLE_UNKNOWN;
827 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
828 roles |= FC_RPORT_ROLE_FCP_INITIATOR;
829 if (ndlp->nlp_type & NLP_FCP_TARGET)
830 roles |= FC_RPORT_ROLE_FCP_TARGET;
832 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT,
833 "rport rolechg: role:x%x did:x%x flg:x%x",
834 roles, ndlp->nlp_DID, ndlp->nlp_flag);
836 if (phba->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
837 fc_remote_port_rolechg(rport, roles);
842 lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
844 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
846 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED)) {
847 spin_lock_irq(shost->host_lock);
848 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
849 spin_unlock_irq(shost->host_lock);
853 if (!(vport->fc_flag & FC_PT2PT)) {
854 /* Check config parameter use-adisc or FCP-2 */
855 if (vport->cfg_use_adisc && ((vport->fc_flag & FC_RSCN_MODE) ||
856 ((ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) &&
857 (ndlp->nlp_type & NLP_FCP_TARGET)))) {
858 spin_lock_irq(shost->host_lock);
859 ndlp->nlp_flag |= NLP_NPR_ADISC;
860 spin_unlock_irq(shost->host_lock);
865 spin_lock_irq(shost->host_lock);
866 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
867 spin_unlock_irq(shost->host_lock);
868 lpfc_unreg_rpi(vport, ndlp);
873 * lpfc_release_rpi - Release a RPI by issuing unreg_login mailbox cmd.
874 * @phba : Pointer to lpfc_hba structure.
875 * @vport: Pointer to lpfc_vport structure.
876 * @rpi : rpi to be release.
878 * This function will send a unreg_login mailbox command to the firmware
882 lpfc_release_rpi(struct lpfc_hba *phba,
883 struct lpfc_vport *vport,
889 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
892 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
893 "2796 mailbox memory allocation failed \n");
895 lpfc_unreg_login(phba, vport->vpi, rpi, pmb);
896 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
897 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
898 if (rc == MBX_NOT_FINISHED)
899 mempool_free(pmb, phba->mbox_mem_pool);
904 lpfc_disc_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
905 void *arg, uint32_t evt)
907 struct lpfc_hba *phba;
908 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
912 /* Release the RPI if reglogin completing */
913 if (!(phba->pport->load_flag & FC_UNLOADING) &&
914 (evt == NLP_EVT_CMPL_REG_LOGIN) &&
915 (!pmb->u.mb.mbxStatus)) {
916 rpi = pmb->u.mb.un.varWords[0];
917 lpfc_release_rpi(phba, vport, rpi);
919 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
920 "0271 Illegal State Transition: node x%x "
921 "event x%x, state x%x Data: x%x x%x\n",
922 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
924 return ndlp->nlp_state;
928 lpfc_cmpl_plogi_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
929 void *arg, uint32_t evt)
931 /* This transition is only legal if we previously
932 * rcv'ed a PLOGI. Since we don't want 2 discovery threads
933 * working on the same NPortID, do nothing for this thread
936 if (!(ndlp->nlp_flag & NLP_RCV_PLOGI)) {
937 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
938 "0272 Illegal State Transition: node x%x "
939 "event x%x, state x%x Data: x%x x%x\n",
940 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
943 return ndlp->nlp_state;
946 /* Start of Discovery State Machine routines */
949 lpfc_rcv_plogi_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
950 void *arg, uint32_t evt)
952 struct lpfc_iocbq *cmdiocb;
954 cmdiocb = (struct lpfc_iocbq *) arg;
956 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
957 return ndlp->nlp_state;
959 return NLP_STE_FREED_NODE;
963 lpfc_rcv_els_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
964 void *arg, uint32_t evt)
966 lpfc_issue_els_logo(vport, ndlp, 0);
967 return ndlp->nlp_state;
971 lpfc_rcv_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
972 void *arg, uint32_t evt)
974 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
975 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
977 spin_lock_irq(shost->host_lock);
978 ndlp->nlp_flag |= NLP_LOGO_ACC;
979 spin_unlock_irq(shost->host_lock);
980 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
982 return ndlp->nlp_state;
986 lpfc_cmpl_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
987 void *arg, uint32_t evt)
989 return NLP_STE_FREED_NODE;
993 lpfc_device_rm_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
994 void *arg, uint32_t evt)
996 return NLP_STE_FREED_NODE;
1000 lpfc_device_recov_unused_node(struct lpfc_vport *vport,
1001 struct lpfc_nodelist *ndlp,
1002 void *arg, uint32_t evt)
1004 return ndlp->nlp_state;
1008 lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1009 void *arg, uint32_t evt)
1011 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1012 struct lpfc_hba *phba = vport->phba;
1013 struct lpfc_iocbq *cmdiocb = arg;
1014 struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1015 uint32_t *lp = (uint32_t *) pcmd->virt;
1016 struct serv_parm *sp = (struct serv_parm *) (lp + 1);
1020 memset(&stat, 0, sizeof (struct ls_rjt));
1022 /* For a PLOGI, we only accept if our portname is less
1023 * than the remote portname.
1025 phba->fc_stat.elsLogiCol++;
1026 port_cmp = memcmp(&vport->fc_portname, &sp->portName,
1027 sizeof(struct lpfc_name));
1029 if (port_cmp >= 0) {
1030 /* Reject this request because the remote node will accept
1032 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
1033 stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS;
1034 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
1037 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb) &&
1038 (ndlp->nlp_flag & NLP_NPR_2B_DISC) &&
1039 (vport->num_disc_nodes)) {
1040 spin_lock_irq(shost->host_lock);
1041 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1042 spin_unlock_irq(shost->host_lock);
1043 /* Check if there are more PLOGIs to be sent */
1044 lpfc_more_plogi(vport);
1045 if (vport->num_disc_nodes == 0) {
1046 spin_lock_irq(shost->host_lock);
1047 vport->fc_flag &= ~FC_NDISC_ACTIVE;
1048 spin_unlock_irq(shost->host_lock);
1049 lpfc_can_disctmo(vport);
1050 lpfc_end_rscn(vport);
1053 } /* If our portname was less */
1055 return ndlp->nlp_state;
1059 lpfc_rcv_prli_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1060 void *arg, uint32_t evt)
1062 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1065 memset(&stat, 0, sizeof (struct ls_rjt));
1066 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
1067 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
1068 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
1069 return ndlp->nlp_state;
1073 lpfc_rcv_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1074 void *arg, uint32_t evt)
1076 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1078 /* Retrieve RPI from LOGO IOCB. RPI is used for CMD_ABORT_XRI_CN */
1079 if (vport->phba->sli_rev == LPFC_SLI_REV3)
1080 ndlp->nlp_rpi = cmdiocb->iocb.ulpIoTag;
1081 /* software abort outstanding PLOGI */
1082 lpfc_els_abort(vport->phba, ndlp);
1084 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1085 return ndlp->nlp_state;
1089 lpfc_rcv_els_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1090 void *arg, uint32_t evt)
1092 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1093 struct lpfc_hba *phba = vport->phba;
1094 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1096 /* software abort outstanding PLOGI */
1097 lpfc_els_abort(phba, ndlp);
1099 if (evt == NLP_EVT_RCV_LOGO) {
1100 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
1102 lpfc_issue_els_logo(vport, ndlp, 0);
1105 /* Put ndlp in npr state set plogi timer for 1 sec */
1106 mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000 * 1));
1107 spin_lock_irq(shost->host_lock);
1108 ndlp->nlp_flag |= NLP_DELAY_TMO;
1109 spin_unlock_irq(shost->host_lock);
1110 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1111 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
1112 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1114 return ndlp->nlp_state;
1118 lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport,
1119 struct lpfc_nodelist *ndlp,
1123 struct lpfc_hba *phba = vport->phba;
1124 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1125 struct lpfc_iocbq *cmdiocb, *rspiocb;
1126 struct lpfc_dmabuf *pcmd, *prsp, *mp;
1130 struct serv_parm *sp;
1135 cmdiocb = (struct lpfc_iocbq *) arg;
1136 rspiocb = cmdiocb->context_un.rsp_iocb;
1138 if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
1139 /* Recovery from PLOGI collision logic */
1140 return ndlp->nlp_state;
1143 irsp = &rspiocb->iocb;
1145 if (irsp->ulpStatus)
1148 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1150 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list);
1154 lp = (uint32_t *) prsp->virt;
1155 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
1157 /* Some switches have FDMI servers returning 0 for WWN */
1158 if ((ndlp->nlp_DID != FDMI_DID) &&
1159 (wwn_to_u64(sp->portName.u.wwn) == 0 ||
1160 wwn_to_u64(sp->nodeName.u.wwn) == 0)) {
1161 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1162 "0142 PLOGI RSP: Invalid WWN.\n");
1165 if (!lpfc_check_sparm(vport, ndlp, sp, CLASS3, 0))
1167 /* PLOGI chkparm OK */
1168 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1169 "0121 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
1170 ndlp->nlp_DID, ndlp->nlp_state,
1171 ndlp->nlp_flag, ndlp->nlp_rpi);
1172 if (vport->cfg_fcp_class == 2 && (sp->cls2.classValid))
1173 ndlp->nlp_fcp_info |= CLASS2;
1175 ndlp->nlp_fcp_info |= CLASS3;
1177 ndlp->nlp_class_sup = 0;
1178 if (sp->cls1.classValid)
1179 ndlp->nlp_class_sup |= FC_COS_CLASS1;
1180 if (sp->cls2.classValid)
1181 ndlp->nlp_class_sup |= FC_COS_CLASS2;
1182 if (sp->cls3.classValid)
1183 ndlp->nlp_class_sup |= FC_COS_CLASS3;
1184 if (sp->cls4.classValid)
1185 ndlp->nlp_class_sup |= FC_COS_CLASS4;
1186 ndlp->nlp_maxframe =
1187 ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb;
1189 if ((vport->fc_flag & FC_PT2PT) &&
1190 (vport->fc_flag & FC_PT2PT_PLOGI)) {
1191 ed_tov = be32_to_cpu(sp->cmn.e_d_tov);
1192 if (sp->cmn.edtovResolution) {
1193 /* E_D_TOV ticks are in nanoseconds */
1194 ed_tov = (phba->fc_edtov + 999999) / 1000000;
1197 ndlp->nlp_flag &= ~NLP_SUPPRESS_RSP;
1198 if ((phba->sli.sli_flag & LPFC_SLI_SUPPRESS_RSP) &&
1199 sp->cmn.valid_vendor_ver_level) {
1200 vid = be32_to_cpu(sp->un.vv.vid);
1201 flag = be32_to_cpu(sp->un.vv.flags);
1202 if ((vid == LPFC_VV_EMLX_ID) &&
1203 (flag & LPFC_VV_SUPPRESS_RSP))
1204 ndlp->nlp_flag |= NLP_SUPPRESS_RSP;
1208 * Use the larger EDTOV
1209 * RATOV = 2 * EDTOV for pt-to-pt
1211 if (ed_tov > phba->fc_edtov)
1212 phba->fc_edtov = ed_tov;
1213 phba->fc_ratov = (2 * phba->fc_edtov) / 1000;
1215 memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm));
1217 /* Issue config_link / reg_vfi to account for updated TOV's */
1218 if (phba->sli_rev == LPFC_SLI_REV4) {
1219 lpfc_issue_reg_vfi(vport);
1221 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1223 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1224 "0133 PLOGI: no memory "
1226 "Data: x%x x%x x%x x%x\n",
1227 ndlp->nlp_DID, ndlp->nlp_state,
1228 ndlp->nlp_flag, ndlp->nlp_rpi);
1232 lpfc_config_link(phba, mbox);
1234 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1235 mbox->vport = vport;
1236 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
1237 if (rc == MBX_NOT_FINISHED) {
1238 mempool_free(mbox, phba->mbox_mem_pool);
1244 lpfc_unreg_rpi(vport, ndlp);
1246 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1248 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1249 "0018 PLOGI: no memory for reg_login "
1250 "Data: x%x x%x x%x x%x\n",
1251 ndlp->nlp_DID, ndlp->nlp_state,
1252 ndlp->nlp_flag, ndlp->nlp_rpi);
1256 if (lpfc_reg_rpi(phba, vport->vpi, irsp->un.elsreq64.remoteID,
1257 (uint8_t *) sp, mbox, ndlp->nlp_rpi) == 0) {
1258 switch (ndlp->nlp_DID) {
1259 case NameServer_DID:
1260 mbox->mbox_cmpl = lpfc_mbx_cmpl_ns_reg_login;
1263 mbox->mbox_cmpl = lpfc_mbx_cmpl_fdmi_reg_login;
1266 ndlp->nlp_flag |= NLP_REG_LOGIN_SEND;
1267 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
1269 mbox->context2 = lpfc_nlp_get(ndlp);
1270 mbox->vport = vport;
1271 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
1272 != MBX_NOT_FINISHED) {
1273 lpfc_nlp_set_state(vport, ndlp,
1274 NLP_STE_REG_LOGIN_ISSUE);
1275 return ndlp->nlp_state;
1277 if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND)
1278 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1279 /* decrement node reference count to the failed mbox
1283 mp = (struct lpfc_dmabuf *) mbox->context1;
1284 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1286 mempool_free(mbox, phba->mbox_mem_pool);
1288 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1289 "0134 PLOGI: cannot issue reg_login "
1290 "Data: x%x x%x x%x x%x\n",
1291 ndlp->nlp_DID, ndlp->nlp_state,
1292 ndlp->nlp_flag, ndlp->nlp_rpi);
1294 mempool_free(mbox, phba->mbox_mem_pool);
1296 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1297 "0135 PLOGI: cannot format reg_login "
1298 "Data: x%x x%x x%x x%x\n",
1299 ndlp->nlp_DID, ndlp->nlp_state,
1300 ndlp->nlp_flag, ndlp->nlp_rpi);
1305 if (ndlp->nlp_DID == NameServer_DID) {
1306 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1307 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1308 "0261 Cannot Register NameServer login\n");
1312 ** In case the node reference counter does not go to zero, ensure that
1313 ** the stale state for the node is not processed.
1316 ndlp->nlp_prev_state = ndlp->nlp_state;
1317 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1318 spin_lock_irq(shost->host_lock);
1319 ndlp->nlp_flag |= NLP_DEFER_RM;
1320 spin_unlock_irq(shost->host_lock);
1321 return NLP_STE_FREED_NODE;
1325 lpfc_cmpl_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1326 void *arg, uint32_t evt)
1328 return ndlp->nlp_state;
1332 lpfc_cmpl_reglogin_plogi_issue(struct lpfc_vport *vport,
1333 struct lpfc_nodelist *ndlp, void *arg, uint32_t evt)
1335 struct lpfc_hba *phba;
1336 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
1337 MAILBOX_t *mb = &pmb->u.mb;
1341 /* Release the RPI */
1342 if (!(phba->pport->load_flag & FC_UNLOADING) &&
1344 rpi = pmb->u.mb.un.varWords[0];
1345 lpfc_release_rpi(phba, vport, rpi);
1347 return ndlp->nlp_state;
1351 lpfc_device_rm_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1352 void *arg, uint32_t evt)
1354 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1356 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1357 spin_lock_irq(shost->host_lock);
1358 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1359 spin_unlock_irq(shost->host_lock);
1360 return ndlp->nlp_state;
1362 /* software abort outstanding PLOGI */
1363 lpfc_els_abort(vport->phba, ndlp);
1365 lpfc_drop_node(vport, ndlp);
1366 return NLP_STE_FREED_NODE;
1371 lpfc_device_recov_plogi_issue(struct lpfc_vport *vport,
1372 struct lpfc_nodelist *ndlp,
1376 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1377 struct lpfc_hba *phba = vport->phba;
1379 /* Don't do anything that will mess up processing of the
1382 if (vport->fc_flag & FC_RSCN_DEFERRED)
1383 return ndlp->nlp_state;
1385 /* software abort outstanding PLOGI */
1386 lpfc_els_abort(phba, ndlp);
1388 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
1389 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1390 spin_lock_irq(shost->host_lock);
1391 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1392 spin_unlock_irq(shost->host_lock);
1394 return ndlp->nlp_state;
1398 lpfc_rcv_plogi_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1399 void *arg, uint32_t evt)
1401 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1402 struct lpfc_hba *phba = vport->phba;
1403 struct lpfc_iocbq *cmdiocb;
1405 /* software abort outstanding ADISC */
1406 lpfc_els_abort(phba, ndlp);
1408 cmdiocb = (struct lpfc_iocbq *) arg;
1410 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
1411 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1412 spin_lock_irq(shost->host_lock);
1413 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1414 spin_unlock_irq(shost->host_lock);
1415 if (vport->num_disc_nodes)
1416 lpfc_more_adisc(vport);
1418 return ndlp->nlp_state;
1420 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1421 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
1422 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
1424 return ndlp->nlp_state;
1428 lpfc_rcv_prli_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1429 void *arg, uint32_t evt)
1431 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1433 if (lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
1434 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1435 return ndlp->nlp_state;
1439 lpfc_rcv_logo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1440 void *arg, uint32_t evt)
1442 struct lpfc_hba *phba = vport->phba;
1443 struct lpfc_iocbq *cmdiocb;
1445 cmdiocb = (struct lpfc_iocbq *) arg;
1447 /* software abort outstanding ADISC */
1448 lpfc_els_abort(phba, ndlp);
1450 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1451 return ndlp->nlp_state;
1455 lpfc_rcv_padisc_adisc_issue(struct lpfc_vport *vport,
1456 struct lpfc_nodelist *ndlp,
1457 void *arg, uint32_t evt)
1459 struct lpfc_iocbq *cmdiocb;
1461 cmdiocb = (struct lpfc_iocbq *) arg;
1463 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1464 return ndlp->nlp_state;
1468 lpfc_rcv_prlo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1469 void *arg, uint32_t evt)
1471 struct lpfc_iocbq *cmdiocb;
1473 cmdiocb = (struct lpfc_iocbq *) arg;
1475 /* Treat like rcv logo */
1476 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
1477 return ndlp->nlp_state;
1481 lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport *vport,
1482 struct lpfc_nodelist *ndlp,
1483 void *arg, uint32_t evt)
1485 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1486 struct lpfc_hba *phba = vport->phba;
1487 struct lpfc_iocbq *cmdiocb, *rspiocb;
1492 cmdiocb = (struct lpfc_iocbq *) arg;
1493 rspiocb = cmdiocb->context_un.rsp_iocb;
1495 ap = (ADISC *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
1496 irsp = &rspiocb->iocb;
1498 if ((irsp->ulpStatus) ||
1499 (!lpfc_check_adisc(vport, ndlp, &ap->nodeName, &ap->portName))) {
1501 mod_timer(&ndlp->nlp_delayfunc,
1502 jiffies + msecs_to_jiffies(1000));
1503 spin_lock_irq(shost->host_lock);
1504 ndlp->nlp_flag |= NLP_DELAY_TMO;
1505 spin_unlock_irq(shost->host_lock);
1506 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1508 memset(&ndlp->nlp_nodename, 0, sizeof(struct lpfc_name));
1509 memset(&ndlp->nlp_portname, 0, sizeof(struct lpfc_name));
1511 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1512 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1513 lpfc_unreg_rpi(vport, ndlp);
1514 return ndlp->nlp_state;
1517 if (phba->sli_rev == LPFC_SLI_REV4) {
1518 rc = lpfc_sli4_resume_rpi(ndlp, NULL, NULL);
1520 /* Stay in state and retry. */
1521 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1522 return ndlp->nlp_state;
1526 if (ndlp->nlp_type & NLP_FCP_TARGET) {
1527 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1528 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
1530 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1531 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
1534 return ndlp->nlp_state;
1538 lpfc_device_rm_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1539 void *arg, uint32_t evt)
1541 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1543 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1544 spin_lock_irq(shost->host_lock);
1545 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1546 spin_unlock_irq(shost->host_lock);
1547 return ndlp->nlp_state;
1549 /* software abort outstanding ADISC */
1550 lpfc_els_abort(vport->phba, ndlp);
1552 lpfc_drop_node(vport, ndlp);
1553 return NLP_STE_FREED_NODE;
1558 lpfc_device_recov_adisc_issue(struct lpfc_vport *vport,
1559 struct lpfc_nodelist *ndlp,
1563 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1564 struct lpfc_hba *phba = vport->phba;
1566 /* Don't do anything that will mess up processing of the
1569 if (vport->fc_flag & FC_RSCN_DEFERRED)
1570 return ndlp->nlp_state;
1572 /* software abort outstanding ADISC */
1573 lpfc_els_abort(phba, ndlp);
1575 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1576 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1577 spin_lock_irq(shost->host_lock);
1578 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1579 spin_unlock_irq(shost->host_lock);
1580 lpfc_disc_set_adisc(vport, ndlp);
1581 return ndlp->nlp_state;
1585 lpfc_rcv_plogi_reglogin_issue(struct lpfc_vport *vport,
1586 struct lpfc_nodelist *ndlp,
1590 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1592 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
1593 return ndlp->nlp_state;
1597 lpfc_rcv_prli_reglogin_issue(struct lpfc_vport *vport,
1598 struct lpfc_nodelist *ndlp,
1602 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1605 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb)) {
1606 return ndlp->nlp_state;
1608 if (vport->phba->nvmet_support) {
1609 /* NVME Target mode. Handle and respond to the PRLI and
1610 * transition to UNMAPPED provided the RPI has completed
1613 if (ndlp->nlp_flag & NLP_RPI_REGISTERED) {
1614 lpfc_rcv_prli(vport, ndlp, cmdiocb);
1615 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1617 /* RPI registration has not completed. Reject the PRLI
1618 * to prevent an illegal state transition when the
1619 * rpi registration does complete.
1621 memset(&stat, 0, sizeof(struct ls_rjt));
1622 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
1623 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
1624 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
1626 return ndlp->nlp_state;
1629 /* Initiator mode. */
1630 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1632 return ndlp->nlp_state;
1636 lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport,
1637 struct lpfc_nodelist *ndlp,
1641 struct lpfc_hba *phba = vport->phba;
1642 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1644 LPFC_MBOXQ_t *nextmb;
1645 struct lpfc_dmabuf *mp;
1647 cmdiocb = (struct lpfc_iocbq *) arg;
1649 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1650 if ((mb = phba->sli.mbox_active)) {
1651 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1652 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1653 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1655 mb->context2 = NULL;
1656 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1660 spin_lock_irq(&phba->hbalock);
1661 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
1662 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1663 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1664 mp = (struct lpfc_dmabuf *) (mb->context1);
1666 __lpfc_mbuf_free(phba, mp->virt, mp->phys);
1669 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1671 list_del(&mb->list);
1672 phba->sli.mboxq_cnt--;
1673 mempool_free(mb, phba->mbox_mem_pool);
1676 spin_unlock_irq(&phba->hbalock);
1678 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1679 return ndlp->nlp_state;
1683 lpfc_rcv_padisc_reglogin_issue(struct lpfc_vport *vport,
1684 struct lpfc_nodelist *ndlp,
1688 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1690 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1691 return ndlp->nlp_state;
1695 lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport *vport,
1696 struct lpfc_nodelist *ndlp,
1700 struct lpfc_iocbq *cmdiocb;
1702 cmdiocb = (struct lpfc_iocbq *) arg;
1703 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1704 return ndlp->nlp_state;
1708 lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
1709 struct lpfc_nodelist *ndlp,
1713 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1714 struct lpfc_hba *phba = vport->phba;
1715 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
1716 MAILBOX_t *mb = &pmb->u.mb;
1717 uint32_t did = mb->un.varWords[1];
1720 if (mb->mbxStatus) {
1721 /* RegLogin failed */
1722 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1723 "0246 RegLogin failed Data: x%x x%x x%x x%x "
1725 did, mb->mbxStatus, vport->port_state,
1726 mb->un.varRegLogin.vpi,
1727 mb->un.varRegLogin.rpi);
1729 * If RegLogin failed due to lack of HBA resources do not
1732 if (mb->mbxStatus == MBXERR_RPI_FULL) {
1733 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1734 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1735 return ndlp->nlp_state;
1738 /* Put ndlp in npr state set plogi timer for 1 sec */
1739 mod_timer(&ndlp->nlp_delayfunc,
1740 jiffies + msecs_to_jiffies(1000 * 1));
1741 spin_lock_irq(shost->host_lock);
1742 ndlp->nlp_flag |= NLP_DELAY_TMO;
1743 spin_unlock_irq(shost->host_lock);
1744 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1746 lpfc_issue_els_logo(vport, ndlp, 0);
1747 return ndlp->nlp_state;
1750 /* SLI4 ports have preallocated logical rpis. */
1751 if (phba->sli_rev < LPFC_SLI_REV4)
1752 ndlp->nlp_rpi = mb->un.varWords[0];
1754 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
1756 /* Only if we are not a fabric nport do we issue PRLI */
1757 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1758 "3066 RegLogin Complete on x%x x%x x%x\n",
1759 did, ndlp->nlp_type, ndlp->nlp_fc4_type);
1760 if (!(ndlp->nlp_type & NLP_FABRIC) &&
1761 (phba->nvmet_support == 0)) {
1762 /* The driver supports FCP and NVME concurrently. If the
1763 * ndlp's nlp_fc4_type is still zero, the driver doesn't
1764 * know what PRLI to send yet. Figure that out now and
1765 * call PRLI depending on the outcome.
1767 if (vport->fc_flag & FC_PT2PT) {
1768 /* If we are pt2pt, there is no Fabric to determine
1769 * the FC4 type of the remote nport. So if NVME
1770 * is configured try it.
1772 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1773 if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1774 (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
1775 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
1776 /* We need to update the localport also */
1777 lpfc_nvme_update_localport(vport);
1780 } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
1781 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1783 } else if (ndlp->nlp_fc4_type == 0) {
1784 rc = lpfc_ns_cmd(vport, SLI_CTNS_GFT_ID,
1786 return ndlp->nlp_state;
1789 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1790 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
1791 lpfc_issue_els_prli(vport, ndlp, 0);
1793 if ((vport->fc_flag & FC_PT2PT) && phba->nvmet_support)
1794 phba->targetport->port_id = vport->fc_myDID;
1796 /* Only Fabric ports should transition. NVME target
1797 * must complete PRLI.
1799 if (ndlp->nlp_type & NLP_FABRIC) {
1800 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1801 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
1804 return ndlp->nlp_state;
1808 lpfc_device_rm_reglogin_issue(struct lpfc_vport *vport,
1809 struct lpfc_nodelist *ndlp,
1813 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1815 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1816 spin_lock_irq(shost->host_lock);
1817 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1818 spin_unlock_irq(shost->host_lock);
1819 return ndlp->nlp_state;
1821 lpfc_drop_node(vport, ndlp);
1822 return NLP_STE_FREED_NODE;
1827 lpfc_device_recov_reglogin_issue(struct lpfc_vport *vport,
1828 struct lpfc_nodelist *ndlp,
1832 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1834 /* Don't do anything that will mess up processing of the
1837 if (vport->fc_flag & FC_RSCN_DEFERRED)
1838 return ndlp->nlp_state;
1840 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1841 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1842 spin_lock_irq(shost->host_lock);
1844 /* If we are a target we won't immediately transition into PRLI,
1845 * so if REG_LOGIN already completed we don't need to ignore it.
1847 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED) ||
1848 !vport->phba->nvmet_support)
1849 ndlp->nlp_flag |= NLP_IGNR_REG_CMPL;
1851 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1852 spin_unlock_irq(shost->host_lock);
1853 lpfc_disc_set_adisc(vport, ndlp);
1854 return ndlp->nlp_state;
1858 lpfc_rcv_plogi_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1859 void *arg, uint32_t evt)
1861 struct lpfc_iocbq *cmdiocb;
1863 cmdiocb = (struct lpfc_iocbq *) arg;
1865 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
1866 return ndlp->nlp_state;
1870 lpfc_rcv_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1871 void *arg, uint32_t evt)
1873 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1875 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
1876 return ndlp->nlp_state;
1877 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1878 return ndlp->nlp_state;
1882 lpfc_rcv_logo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1883 void *arg, uint32_t evt)
1885 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1887 /* Software abort outstanding PRLI before sending acc */
1888 lpfc_els_abort(vport->phba, ndlp);
1890 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1891 return ndlp->nlp_state;
1895 lpfc_rcv_padisc_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1896 void *arg, uint32_t evt)
1898 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1900 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1901 return ndlp->nlp_state;
1904 /* This routine is envoked when we rcv a PRLO request from a nport
1905 * we are logged into. We should send back a PRLO rsp setting the
1907 * NEXT STATE = PRLI_ISSUE
1910 lpfc_rcv_prlo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1911 void *arg, uint32_t evt)
1913 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1915 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1916 return ndlp->nlp_state;
1920 lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1921 void *arg, uint32_t evt)
1923 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1924 struct lpfc_iocbq *cmdiocb, *rspiocb;
1925 struct lpfc_hba *phba = vport->phba;
1928 struct lpfc_nvme_prli *nvpr;
1931 cmdiocb = (struct lpfc_iocbq *) arg;
1932 rspiocb = cmdiocb->context_un.rsp_iocb;
1934 /* A solicited PRLI is either FCP or NVME. The PRLI cmd/rsp
1935 * format is different so NULL the two PRLI types so that the
1936 * driver correctly gets the correct context.
1940 temp_ptr = lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
1941 if (cmdiocb->iocb_flag & LPFC_PRLI_FCP_REQ)
1942 npr = (PRLI *) temp_ptr;
1943 else if (cmdiocb->iocb_flag & LPFC_PRLI_NVME_REQ)
1944 nvpr = (struct lpfc_nvme_prli *) temp_ptr;
1946 irsp = &rspiocb->iocb;
1947 if (irsp->ulpStatus) {
1948 if ((vport->port_type == LPFC_NPIV_PORT) &&
1949 vport->cfg_restrict_login) {
1953 /* Adjust the nlp_type accordingly if the PRLI failed */
1955 ndlp->nlp_fc4_type &= ~NLP_FC4_FCP;
1957 ndlp->nlp_fc4_type &= ~NLP_FC4_NVME;
1959 /* We can't set the DSM state till BOTH PRLIs complete */
1963 if (npr && (npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
1964 (npr->prliType == PRLI_FCP_TYPE)) {
1965 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
1966 "6028 FCP NPR PRLI Cmpl Init %d Target %d\n",
1969 if (npr->initiatorFunc)
1970 ndlp->nlp_type |= NLP_FCP_INITIATOR;
1971 if (npr->targetFunc) {
1972 ndlp->nlp_type |= NLP_FCP_TARGET;
1973 if (npr->writeXferRdyDis)
1974 ndlp->nlp_flag |= NLP_FIRSTBURST;
1977 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
1980 (bf_get_be32(prli_acc_rsp_code, nvpr) ==
1981 PRLI_REQ_EXECUTED) &&
1982 (bf_get_be32(prli_type_code, nvpr) ==
1985 /* Complete setting up the remote ndlp personality. */
1986 if (bf_get_be32(prli_init, nvpr))
1987 ndlp->nlp_type |= NLP_NVME_INITIATOR;
1989 /* Target driver cannot solicit NVME FB. */
1990 if (bf_get_be32(prli_tgt, nvpr)) {
1991 /* Complete the nvme target roles. The transport
1992 * needs to know if the rport is capable of
1993 * discovery in addition to its role.
1995 ndlp->nlp_type |= NLP_NVME_TARGET;
1996 if (bf_get_be32(prli_disc, nvpr))
1997 ndlp->nlp_type |= NLP_NVME_DISCOVERY;
2000 * If prli_fba is set, the Target supports FirstBurst.
2001 * If prli_fb_sz is 0, the FirstBurst size is unlimited,
2002 * otherwise it defines the actual size supported by
2005 if ((bf_get_be32(prli_fba, nvpr) == 1) &&
2006 (phba->cfg_nvme_enable_fb) &&
2007 (!phba->nvmet_support)) {
2008 /* Both sides support FB. The target's first
2009 * burst size is a 512 byte encoded value.
2011 ndlp->nlp_flag |= NLP_FIRSTBURST;
2012 ndlp->nvme_fb_size = bf_get_be32(prli_fb_sz,
2015 /* Expressed in units of 512 bytes */
2016 if (ndlp->nvme_fb_size)
2017 ndlp->nvme_fb_size <<=
2020 ndlp->nvme_fb_size = LPFC_NVME_MAX_FB;
2024 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
2025 "6029 NVME PRLI Cmpl w1 x%08x "
2026 "w4 x%08x w5 x%08x flag x%x, "
2027 "fcp_info x%x nlp_type x%x\n",
2028 be32_to_cpu(nvpr->word1),
2029 be32_to_cpu(nvpr->word4),
2030 be32_to_cpu(nvpr->word5),
2031 ndlp->nlp_flag, ndlp->nlp_fcp_info,
2034 if (!(ndlp->nlp_type & NLP_FCP_TARGET) &&
2035 (vport->port_type == LPFC_NPIV_PORT) &&
2036 vport->cfg_restrict_login) {
2038 spin_lock_irq(shost->host_lock);
2039 ndlp->nlp_flag |= NLP_TARGET_REMOVE;
2040 spin_unlock_irq(shost->host_lock);
2041 lpfc_issue_els_logo(vport, ndlp, 0);
2043 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2044 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2045 return ndlp->nlp_state;
2049 /* The ndlp state cannot move to MAPPED or UNMAPPED before all PRLIs
2052 if (ndlp->fc4_prli_sent == 0) {
2053 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2054 if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET))
2055 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
2056 else if (ndlp->nlp_type &
2057 (NLP_FCP_INITIATOR | NLP_NVME_INITIATOR))
2058 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
2060 lpfc_printf_vlog(vport,
2062 "3067 PRLI's still outstanding "
2063 "on x%06x - count %d, Pend Node Mode "
2065 ndlp->nlp_DID, ndlp->fc4_prli_sent);
2067 return ndlp->nlp_state;
2070 /*! lpfc_device_rm_prli_issue
2081 * This routine is envoked when we a request to remove a nport we are in the
2082 * process of PRLIing. We should software abort outstanding prli, unreg
2083 * login, send a logout. We will change node state to UNUSED_NODE, put it
2084 * on plogi list so it can be freed when LOGO completes.
2089 lpfc_device_rm_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2090 void *arg, uint32_t evt)
2092 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2094 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
2095 spin_lock_irq(shost->host_lock);
2096 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
2097 spin_unlock_irq(shost->host_lock);
2098 return ndlp->nlp_state;
2100 /* software abort outstanding PLOGI */
2101 lpfc_els_abort(vport->phba, ndlp);
2103 lpfc_drop_node(vport, ndlp);
2104 return NLP_STE_FREED_NODE;
2109 /*! lpfc_device_recov_prli_issue
2120 * The routine is envoked when the state of a device is unknown, like
2121 * during a link down. We should remove the nodelist entry from the
2122 * unmapped list, issue a UNREG_LOGIN, do a software abort of the
2123 * outstanding PRLI command, then free the node entry.
2126 lpfc_device_recov_prli_issue(struct lpfc_vport *vport,
2127 struct lpfc_nodelist *ndlp,
2131 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2132 struct lpfc_hba *phba = vport->phba;
2134 /* Don't do anything that will mess up processing of the
2137 if (vport->fc_flag & FC_RSCN_DEFERRED)
2138 return ndlp->nlp_state;
2140 /* software abort outstanding PRLI */
2141 lpfc_els_abort(phba, ndlp);
2143 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2144 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2145 spin_lock_irq(shost->host_lock);
2146 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2147 spin_unlock_irq(shost->host_lock);
2148 lpfc_disc_set_adisc(vport, ndlp);
2149 return ndlp->nlp_state;
2153 lpfc_rcv_plogi_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2154 void *arg, uint32_t evt)
2156 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2159 memset(&stat, 0, sizeof(struct ls_rjt));
2160 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2161 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2162 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2163 return ndlp->nlp_state;
2167 lpfc_rcv_prli_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2168 void *arg, uint32_t evt)
2170 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2173 memset(&stat, 0, sizeof(struct ls_rjt));
2174 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2175 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2176 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2177 return ndlp->nlp_state;
2181 lpfc_rcv_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2182 void *arg, uint32_t evt)
2184 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2185 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2187 spin_lock_irq(shost->host_lock);
2188 ndlp->nlp_flag |= NLP_LOGO_ACC;
2189 spin_unlock_irq(shost->host_lock);
2190 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2191 return ndlp->nlp_state;
2195 lpfc_rcv_padisc_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2196 void *arg, uint32_t evt)
2198 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2201 memset(&stat, 0, sizeof(struct ls_rjt));
2202 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2203 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2204 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2205 return ndlp->nlp_state;
2209 lpfc_rcv_prlo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2210 void *arg, uint32_t evt)
2212 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2215 memset(&stat, 0, sizeof(struct ls_rjt));
2216 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2217 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2218 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2219 return ndlp->nlp_state;
2223 lpfc_cmpl_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2224 void *arg, uint32_t evt)
2226 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2228 ndlp->nlp_prev_state = NLP_STE_LOGO_ISSUE;
2229 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2230 spin_lock_irq(shost->host_lock);
2231 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2232 spin_unlock_irq(shost->host_lock);
2233 lpfc_disc_set_adisc(vport, ndlp);
2234 return ndlp->nlp_state;
2238 lpfc_device_rm_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2239 void *arg, uint32_t evt)
2242 * DevLoss has timed out and is calling for Device Remove.
2243 * In this case, abort the LOGO and cleanup the ndlp
2246 lpfc_unreg_rpi(vport, ndlp);
2247 /* software abort outstanding PLOGI */
2248 lpfc_els_abort(vport->phba, ndlp);
2249 lpfc_drop_node(vport, ndlp);
2250 return NLP_STE_FREED_NODE;
2254 lpfc_device_recov_logo_issue(struct lpfc_vport *vport,
2255 struct lpfc_nodelist *ndlp,
2256 void *arg, uint32_t evt)
2259 * Device Recovery events have no meaning for a node with a LOGO
2260 * outstanding. The LOGO has to complete first and handle the
2261 * node from that point.
2263 return ndlp->nlp_state;
2267 lpfc_rcv_plogi_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2268 void *arg, uint32_t evt)
2270 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2272 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
2273 return ndlp->nlp_state;
2277 lpfc_rcv_prli_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2278 void *arg, uint32_t evt)
2280 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2282 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
2283 return ndlp->nlp_state;
2285 lpfc_rcv_prli(vport, ndlp, cmdiocb);
2286 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
2287 return ndlp->nlp_state;
2291 lpfc_rcv_logo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2292 void *arg, uint32_t evt)
2294 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2296 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2297 return ndlp->nlp_state;
2301 lpfc_rcv_padisc_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2302 void *arg, uint32_t evt)
2304 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2306 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2307 return ndlp->nlp_state;
2311 lpfc_rcv_prlo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2312 void *arg, uint32_t evt)
2314 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2316 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
2317 return ndlp->nlp_state;
2321 lpfc_device_recov_unmap_node(struct lpfc_vport *vport,
2322 struct lpfc_nodelist *ndlp,
2326 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2328 ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
2329 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2330 spin_lock_irq(shost->host_lock);
2331 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2332 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2333 spin_unlock_irq(shost->host_lock);
2334 lpfc_disc_set_adisc(vport, ndlp);
2336 return ndlp->nlp_state;
2340 lpfc_rcv_plogi_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2341 void *arg, uint32_t evt)
2343 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2345 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
2346 return ndlp->nlp_state;
2350 lpfc_rcv_prli_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2351 void *arg, uint32_t evt)
2353 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2355 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
2356 return ndlp->nlp_state;
2357 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
2358 return ndlp->nlp_state;
2362 lpfc_rcv_logo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2363 void *arg, uint32_t evt)
2365 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2367 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2368 return ndlp->nlp_state;
2372 lpfc_rcv_padisc_mapped_node(struct lpfc_vport *vport,
2373 struct lpfc_nodelist *ndlp,
2374 void *arg, uint32_t evt)
2376 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2378 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2379 return ndlp->nlp_state;
2383 lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2384 void *arg, uint32_t evt)
2386 struct lpfc_hba *phba = vport->phba;
2387 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2389 /* flush the target */
2390 lpfc_sli_abort_iocb(vport, &phba->sli.sli3_ring[LPFC_FCP_RING],
2391 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
2393 /* Treat like rcv logo */
2394 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
2395 return ndlp->nlp_state;
2399 lpfc_device_recov_mapped_node(struct lpfc_vport *vport,
2400 struct lpfc_nodelist *ndlp,
2404 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2406 ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
2407 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2408 spin_lock_irq(shost->host_lock);
2409 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2410 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2411 spin_unlock_irq(shost->host_lock);
2412 lpfc_disc_set_adisc(vport, ndlp);
2413 return ndlp->nlp_state;
2417 lpfc_rcv_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2418 void *arg, uint32_t evt)
2420 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2421 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2423 /* Ignore PLOGI if we have an outstanding LOGO */
2424 if (ndlp->nlp_flag & (NLP_LOGO_SND | NLP_LOGO_ACC))
2425 return ndlp->nlp_state;
2426 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
2427 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2428 spin_lock_irq(shost->host_lock);
2429 ndlp->nlp_flag &= ~(NLP_NPR_ADISC | NLP_NPR_2B_DISC);
2430 spin_unlock_irq(shost->host_lock);
2431 } else if (!(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
2432 /* send PLOGI immediately, move to PLOGI issue state */
2433 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
2434 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2435 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2436 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2439 return ndlp->nlp_state;
2443 lpfc_rcv_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2444 void *arg, uint32_t evt)
2446 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2447 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2450 memset(&stat, 0, sizeof (struct ls_rjt));
2451 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2452 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2453 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2455 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
2456 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
2457 spin_lock_irq(shost->host_lock);
2458 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2459 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2460 spin_unlock_irq(shost->host_lock);
2461 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2462 lpfc_issue_els_adisc(vport, ndlp, 0);
2464 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2465 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2466 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2469 return ndlp->nlp_state;
2473 lpfc_rcv_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2474 void *arg, uint32_t evt)
2476 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2478 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2479 return ndlp->nlp_state;
2483 lpfc_rcv_padisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2484 void *arg, uint32_t evt)
2486 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2488 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2490 * Do not start discovery if discovery is about to start
2491 * or discovery in progress for this node. Starting discovery
2492 * here will affect the counting of discovery threads.
2494 if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
2495 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
2496 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
2497 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2498 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2499 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2500 lpfc_issue_els_adisc(vport, ndlp, 0);
2502 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2503 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2504 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2507 return ndlp->nlp_state;
2511 lpfc_rcv_prlo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2512 void *arg, uint32_t evt)
2514 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2515 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2517 spin_lock_irq(shost->host_lock);
2518 ndlp->nlp_flag |= NLP_LOGO_ACC;
2519 spin_unlock_irq(shost->host_lock);
2521 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2523 if ((ndlp->nlp_flag & NLP_DELAY_TMO) == 0) {
2524 mod_timer(&ndlp->nlp_delayfunc,
2525 jiffies + msecs_to_jiffies(1000 * 1));
2526 spin_lock_irq(shost->host_lock);
2527 ndlp->nlp_flag |= NLP_DELAY_TMO;
2528 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2529 spin_unlock_irq(shost->host_lock);
2530 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
2532 spin_lock_irq(shost->host_lock);
2533 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2534 spin_unlock_irq(shost->host_lock);
2536 return ndlp->nlp_state;
2540 lpfc_cmpl_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2541 void *arg, uint32_t evt)
2543 struct lpfc_iocbq *cmdiocb, *rspiocb;
2545 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2547 cmdiocb = (struct lpfc_iocbq *) arg;
2548 rspiocb = cmdiocb->context_un.rsp_iocb;
2550 irsp = &rspiocb->iocb;
2551 if (irsp->ulpStatus) {
2552 spin_lock_irq(shost->host_lock);
2553 ndlp->nlp_flag |= NLP_DEFER_RM;
2554 spin_unlock_irq(shost->host_lock);
2555 return NLP_STE_FREED_NODE;
2557 return ndlp->nlp_state;
2561 lpfc_cmpl_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2562 void *arg, uint32_t evt)
2564 struct lpfc_iocbq *cmdiocb, *rspiocb;
2567 cmdiocb = (struct lpfc_iocbq *) arg;
2568 rspiocb = cmdiocb->context_un.rsp_iocb;
2570 irsp = &rspiocb->iocb;
2571 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
2572 lpfc_drop_node(vport, ndlp);
2573 return NLP_STE_FREED_NODE;
2575 return ndlp->nlp_state;
2579 lpfc_cmpl_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2580 void *arg, uint32_t evt)
2582 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2584 /* For the fabric port just clear the fc flags. */
2585 if (ndlp->nlp_DID == Fabric_DID) {
2586 spin_lock_irq(shost->host_lock);
2587 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
2588 spin_unlock_irq(shost->host_lock);
2590 lpfc_unreg_rpi(vport, ndlp);
2591 return ndlp->nlp_state;
2595 lpfc_cmpl_adisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2596 void *arg, uint32_t evt)
2598 struct lpfc_iocbq *cmdiocb, *rspiocb;
2601 cmdiocb = (struct lpfc_iocbq *) arg;
2602 rspiocb = cmdiocb->context_un.rsp_iocb;
2604 irsp = &rspiocb->iocb;
2605 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
2606 lpfc_drop_node(vport, ndlp);
2607 return NLP_STE_FREED_NODE;
2609 return ndlp->nlp_state;
2613 lpfc_cmpl_reglogin_npr_node(struct lpfc_vport *vport,
2614 struct lpfc_nodelist *ndlp,
2615 void *arg, uint32_t evt)
2617 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
2618 MAILBOX_t *mb = &pmb->u.mb;
2620 if (!mb->mbxStatus) {
2621 /* SLI4 ports have preallocated logical rpis. */
2622 if (vport->phba->sli_rev < LPFC_SLI_REV4)
2623 ndlp->nlp_rpi = mb->un.varWords[0];
2624 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
2625 if (ndlp->nlp_flag & NLP_LOGO_ACC) {
2626 lpfc_unreg_rpi(vport, ndlp);
2629 if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
2630 lpfc_drop_node(vport, ndlp);
2631 return NLP_STE_FREED_NODE;
2634 return ndlp->nlp_state;
2638 lpfc_device_rm_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2639 void *arg, uint32_t evt)
2641 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2643 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
2644 spin_lock_irq(shost->host_lock);
2645 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
2646 spin_unlock_irq(shost->host_lock);
2647 return ndlp->nlp_state;
2649 lpfc_drop_node(vport, ndlp);
2650 return NLP_STE_FREED_NODE;
2654 lpfc_device_recov_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2655 void *arg, uint32_t evt)
2657 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2659 /* Don't do anything that will mess up processing of the
2662 if (vport->fc_flag & FC_RSCN_DEFERRED)
2663 return ndlp->nlp_state;
2665 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2666 spin_lock_irq(shost->host_lock);
2667 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2668 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2669 spin_unlock_irq(shost->host_lock);
2670 return ndlp->nlp_state;
2674 /* This next section defines the NPort Discovery State Machine */
2676 /* There are 4 different double linked lists nodelist entries can reside on.
2677 * The plogi list and adisc list are used when Link Up discovery or RSCN
2678 * processing is needed. Each list holds the nodes that we will send PLOGI
2679 * or ADISC on. These lists will keep track of what nodes will be effected
2680 * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
2681 * The unmapped_list will contain all nodes that we have successfully logged
2682 * into at the Fibre Channel level. The mapped_list will contain all nodes
2683 * that are mapped FCP targets.
2686 * The bind list is a list of undiscovered (potentially non-existent) nodes
2687 * that we have saved binding information on. This information is used when
2688 * nodes transition from the unmapped to the mapped list.
2690 /* For UNUSED_NODE state, the node has just been allocated .
2691 * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
2692 * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
2693 * and put on the unmapped list. For ADISC processing, the node is taken off
2694 * the ADISC list and placed on either the mapped or unmapped list (depending
2695 * on its previous state). Once on the unmapped list, a PRLI is issued and the
2696 * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
2697 * changed to UNMAPPED_NODE. If the completion indicates a mapped
2698 * node, the node is taken off the unmapped list. The binding list is checked
2699 * for a valid binding, or a binding is automatically assigned. If binding
2700 * assignment is unsuccessful, the node is left on the unmapped list. If
2701 * binding assignment is successful, the associated binding list entry (if
2702 * any) is removed, and the node is placed on the mapped list.
2705 * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
2706 * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
2707 * expire, all effected nodes will receive a DEVICE_RM event.
2710 * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
2711 * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
2712 * check, additional nodes may be added or removed (via DEVICE_RM) to / from
2713 * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
2714 * we will first process the ADISC list. 32 entries are processed initially and
2715 * ADISC is initited for each one. Completions / Events for each node are
2716 * funnelled thru the state machine. As each node finishes ADISC processing, it
2717 * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
2718 * waiting, and the ADISC list count is identically 0, then we are done. For
2719 * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
2720 * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
2721 * list. 32 entries are processed initially and PLOGI is initited for each one.
2722 * Completions / Events for each node are funnelled thru the state machine. As
2723 * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
2724 * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
2725 * indentically 0, then we are done. We have now completed discovery / RSCN
2726 * handling. Upon completion, ALL nodes should be on either the mapped or
2730 static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
2731 (struct lpfc_vport *, struct lpfc_nodelist *, void *, uint32_t) = {
2732 /* Action routine Event Current State */
2733 lpfc_rcv_plogi_unused_node, /* RCV_PLOGI UNUSED_NODE */
2734 lpfc_rcv_els_unused_node, /* RCV_PRLI */
2735 lpfc_rcv_logo_unused_node, /* RCV_LOGO */
2736 lpfc_rcv_els_unused_node, /* RCV_ADISC */
2737 lpfc_rcv_els_unused_node, /* RCV_PDISC */
2738 lpfc_rcv_els_unused_node, /* RCV_PRLO */
2739 lpfc_disc_illegal, /* CMPL_PLOGI */
2740 lpfc_disc_illegal, /* CMPL_PRLI */
2741 lpfc_cmpl_logo_unused_node, /* CMPL_LOGO */
2742 lpfc_disc_illegal, /* CMPL_ADISC */
2743 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2744 lpfc_device_rm_unused_node, /* DEVICE_RM */
2745 lpfc_device_recov_unused_node, /* DEVICE_RECOVERY */
2747 lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */
2748 lpfc_rcv_prli_plogi_issue, /* RCV_PRLI */
2749 lpfc_rcv_logo_plogi_issue, /* RCV_LOGO */
2750 lpfc_rcv_els_plogi_issue, /* RCV_ADISC */
2751 lpfc_rcv_els_plogi_issue, /* RCV_PDISC */
2752 lpfc_rcv_els_plogi_issue, /* RCV_PRLO */
2753 lpfc_cmpl_plogi_plogi_issue, /* CMPL_PLOGI */
2754 lpfc_disc_illegal, /* CMPL_PRLI */
2755 lpfc_cmpl_logo_plogi_issue, /* CMPL_LOGO */
2756 lpfc_disc_illegal, /* CMPL_ADISC */
2757 lpfc_cmpl_reglogin_plogi_issue,/* CMPL_REG_LOGIN */
2758 lpfc_device_rm_plogi_issue, /* DEVICE_RM */
2759 lpfc_device_recov_plogi_issue, /* DEVICE_RECOVERY */
2761 lpfc_rcv_plogi_adisc_issue, /* RCV_PLOGI ADISC_ISSUE */
2762 lpfc_rcv_prli_adisc_issue, /* RCV_PRLI */
2763 lpfc_rcv_logo_adisc_issue, /* RCV_LOGO */
2764 lpfc_rcv_padisc_adisc_issue, /* RCV_ADISC */
2765 lpfc_rcv_padisc_adisc_issue, /* RCV_PDISC */
2766 lpfc_rcv_prlo_adisc_issue, /* RCV_PRLO */
2767 lpfc_disc_illegal, /* CMPL_PLOGI */
2768 lpfc_disc_illegal, /* CMPL_PRLI */
2769 lpfc_disc_illegal, /* CMPL_LOGO */
2770 lpfc_cmpl_adisc_adisc_issue, /* CMPL_ADISC */
2771 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2772 lpfc_device_rm_adisc_issue, /* DEVICE_RM */
2773 lpfc_device_recov_adisc_issue, /* DEVICE_RECOVERY */
2775 lpfc_rcv_plogi_reglogin_issue, /* RCV_PLOGI REG_LOGIN_ISSUE */
2776 lpfc_rcv_prli_reglogin_issue, /* RCV_PLOGI */
2777 lpfc_rcv_logo_reglogin_issue, /* RCV_LOGO */
2778 lpfc_rcv_padisc_reglogin_issue, /* RCV_ADISC */
2779 lpfc_rcv_padisc_reglogin_issue, /* RCV_PDISC */
2780 lpfc_rcv_prlo_reglogin_issue, /* RCV_PRLO */
2781 lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */
2782 lpfc_disc_illegal, /* CMPL_PRLI */
2783 lpfc_disc_illegal, /* CMPL_LOGO */
2784 lpfc_disc_illegal, /* CMPL_ADISC */
2785 lpfc_cmpl_reglogin_reglogin_issue,/* CMPL_REG_LOGIN */
2786 lpfc_device_rm_reglogin_issue, /* DEVICE_RM */
2787 lpfc_device_recov_reglogin_issue,/* DEVICE_RECOVERY */
2789 lpfc_rcv_plogi_prli_issue, /* RCV_PLOGI PRLI_ISSUE */
2790 lpfc_rcv_prli_prli_issue, /* RCV_PRLI */
2791 lpfc_rcv_logo_prli_issue, /* RCV_LOGO */
2792 lpfc_rcv_padisc_prli_issue, /* RCV_ADISC */
2793 lpfc_rcv_padisc_prli_issue, /* RCV_PDISC */
2794 lpfc_rcv_prlo_prli_issue, /* RCV_PRLO */
2795 lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */
2796 lpfc_cmpl_prli_prli_issue, /* CMPL_PRLI */
2797 lpfc_disc_illegal, /* CMPL_LOGO */
2798 lpfc_disc_illegal, /* CMPL_ADISC */
2799 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2800 lpfc_device_rm_prli_issue, /* DEVICE_RM */
2801 lpfc_device_recov_prli_issue, /* DEVICE_RECOVERY */
2803 lpfc_rcv_plogi_logo_issue, /* RCV_PLOGI LOGO_ISSUE */
2804 lpfc_rcv_prli_logo_issue, /* RCV_PRLI */
2805 lpfc_rcv_logo_logo_issue, /* RCV_LOGO */
2806 lpfc_rcv_padisc_logo_issue, /* RCV_ADISC */
2807 lpfc_rcv_padisc_logo_issue, /* RCV_PDISC */
2808 lpfc_rcv_prlo_logo_issue, /* RCV_PRLO */
2809 lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */
2810 lpfc_disc_illegal, /* CMPL_PRLI */
2811 lpfc_cmpl_logo_logo_issue, /* CMPL_LOGO */
2812 lpfc_disc_illegal, /* CMPL_ADISC */
2813 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2814 lpfc_device_rm_logo_issue, /* DEVICE_RM */
2815 lpfc_device_recov_logo_issue, /* DEVICE_RECOVERY */
2817 lpfc_rcv_plogi_unmap_node, /* RCV_PLOGI UNMAPPED_NODE */
2818 lpfc_rcv_prli_unmap_node, /* RCV_PRLI */
2819 lpfc_rcv_logo_unmap_node, /* RCV_LOGO */
2820 lpfc_rcv_padisc_unmap_node, /* RCV_ADISC */
2821 lpfc_rcv_padisc_unmap_node, /* RCV_PDISC */
2822 lpfc_rcv_prlo_unmap_node, /* RCV_PRLO */
2823 lpfc_disc_illegal, /* CMPL_PLOGI */
2824 lpfc_disc_illegal, /* CMPL_PRLI */
2825 lpfc_disc_illegal, /* CMPL_LOGO */
2826 lpfc_disc_illegal, /* CMPL_ADISC */
2827 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2828 lpfc_disc_illegal, /* DEVICE_RM */
2829 lpfc_device_recov_unmap_node, /* DEVICE_RECOVERY */
2831 lpfc_rcv_plogi_mapped_node, /* RCV_PLOGI MAPPED_NODE */
2832 lpfc_rcv_prli_mapped_node, /* RCV_PRLI */
2833 lpfc_rcv_logo_mapped_node, /* RCV_LOGO */
2834 lpfc_rcv_padisc_mapped_node, /* RCV_ADISC */
2835 lpfc_rcv_padisc_mapped_node, /* RCV_PDISC */
2836 lpfc_rcv_prlo_mapped_node, /* RCV_PRLO */
2837 lpfc_disc_illegal, /* CMPL_PLOGI */
2838 lpfc_disc_illegal, /* CMPL_PRLI */
2839 lpfc_disc_illegal, /* CMPL_LOGO */
2840 lpfc_disc_illegal, /* CMPL_ADISC */
2841 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2842 lpfc_disc_illegal, /* DEVICE_RM */
2843 lpfc_device_recov_mapped_node, /* DEVICE_RECOVERY */
2845 lpfc_rcv_plogi_npr_node, /* RCV_PLOGI NPR_NODE */
2846 lpfc_rcv_prli_npr_node, /* RCV_PRLI */
2847 lpfc_rcv_logo_npr_node, /* RCV_LOGO */
2848 lpfc_rcv_padisc_npr_node, /* RCV_ADISC */
2849 lpfc_rcv_padisc_npr_node, /* RCV_PDISC */
2850 lpfc_rcv_prlo_npr_node, /* RCV_PRLO */
2851 lpfc_cmpl_plogi_npr_node, /* CMPL_PLOGI */
2852 lpfc_cmpl_prli_npr_node, /* CMPL_PRLI */
2853 lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */
2854 lpfc_cmpl_adisc_npr_node, /* CMPL_ADISC */
2855 lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */
2856 lpfc_device_rm_npr_node, /* DEVICE_RM */
2857 lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */
2861 lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2862 void *arg, uint32_t evt)
2864 uint32_t cur_state, rc;
2865 uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *,
2867 uint32_t got_ndlp = 0;
2869 if (lpfc_nlp_get(ndlp))
2872 cur_state = ndlp->nlp_state;
2874 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
2875 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2876 "0211 DSM in event x%x on NPort x%x in "
2877 "state %d Data: x%x x%x\n",
2878 evt, ndlp->nlp_DID, cur_state,
2879 ndlp->nlp_flag, ndlp->nlp_fc4_type);
2881 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2882 "DSM in: evt:%d ste:%d did:x%x",
2883 evt, cur_state, ndlp->nlp_DID);
2885 func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt];
2886 rc = (func) (vport, ndlp, arg, evt);
2888 /* DSM out state <rc> on NPort <nlp_DID> */
2890 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2891 "0212 DSM out state %d on NPort x%x Data: x%x\n",
2892 rc, ndlp->nlp_DID, ndlp->nlp_flag);
2894 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2895 "DSM out: ste:%d did:x%x flg:x%x",
2896 rc, ndlp->nlp_DID, ndlp->nlp_flag);
2897 /* Decrement the ndlp reference count held for this function */
2900 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2901 "0213 DSM out state %d on NPort free\n", rc);
2903 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2904 "DSM out: ste:%d did:x%x flg:x%x",