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_NVME_TARGET) ||
712 (vport->fc_flag & FC_PT2PT))) ||
713 (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
714 /* Only try to re-login if this is NOT a Fabric Node
715 * AND the remote NPORT is a FCP/NVME Target or we
716 * are in pt2pt mode. NLP_STE_ADISC_ISSUE is a special
717 * case for LOGO as a response to ADISC behavior.
719 mod_timer(&ndlp->nlp_delayfunc,
720 jiffies + msecs_to_jiffies(1000 * 1));
721 spin_lock_irq(shost->host_lock);
722 ndlp->nlp_flag |= NLP_DELAY_TMO;
723 spin_unlock_irq(shost->host_lock);
725 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
728 ndlp->nlp_prev_state = ndlp->nlp_state;
729 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
731 spin_lock_irq(shost->host_lock);
732 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
733 spin_unlock_irq(shost->host_lock);
734 /* The driver has to wait until the ACC completes before it continues
735 * processing the LOGO. The action will resume in
736 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
737 * unreg_login, the driver waits so the ACC does not get aborted.
743 lpfc_rcv_prli_support_check(struct lpfc_vport *vport,
744 struct lpfc_nodelist *ndlp,
745 struct lpfc_iocbq *cmdiocb)
751 payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt;
753 if (vport->phba->nvmet_support) {
754 /* Must be a NVME PRLI */
755 if (cmd == ELS_CMD_PRLI)
758 /* Initiator mode. */
759 if (!vport->nvmei_support && (cmd == ELS_CMD_NVMEPRLI))
764 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NVME_DISC,
765 "6115 Rcv PRLI (%x) check failed: ndlp rpi %d "
766 "state x%x flags x%x\n",
767 cmd, ndlp->nlp_rpi, ndlp->nlp_state,
769 memset(&stat, 0, sizeof(struct ls_rjt));
770 stat.un.b.lsRjtRsnCode = LSRJT_CMD_UNSUPPORTED;
771 stat.un.b.lsRjtRsnCodeExp = LSEXP_REQ_UNSUPPORTED;
772 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
778 lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
779 struct lpfc_iocbq *cmdiocb)
781 struct lpfc_hba *phba = vport->phba;
782 struct lpfc_dmabuf *pcmd;
785 struct fc_rport *rport = ndlp->rport;
788 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
789 lp = (uint32_t *) pcmd->virt;
790 npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t));
792 if ((npr->prliType == PRLI_FCP_TYPE) ||
793 (npr->prliType == PRLI_NVME_TYPE)) {
794 if (npr->initiatorFunc) {
795 if (npr->prliType == PRLI_FCP_TYPE)
796 ndlp->nlp_type |= NLP_FCP_INITIATOR;
797 if (npr->prliType == PRLI_NVME_TYPE)
798 ndlp->nlp_type |= NLP_NVME_INITIATOR;
800 if (npr->targetFunc) {
801 if (npr->prliType == PRLI_FCP_TYPE)
802 ndlp->nlp_type |= NLP_FCP_TARGET;
803 if (npr->prliType == PRLI_NVME_TYPE)
804 ndlp->nlp_type |= NLP_NVME_TARGET;
805 if (npr->writeXferRdyDis)
806 ndlp->nlp_flag |= NLP_FIRSTBURST;
809 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
811 /* If this driver is in nvme target mode, set the ndlp's fc4
812 * type to NVME provided the PRLI response claims NVME FC4
813 * type. Target mode does not issue gft_id so doesn't get
814 * the fc4 type set until now.
816 if (phba->nvmet_support && (npr->prliType == PRLI_NVME_TYPE)) {
817 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
818 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
820 if (npr->prliType == PRLI_FCP_TYPE)
821 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
824 /* We need to update the rport role values */
825 roles = FC_RPORT_ROLE_UNKNOWN;
826 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
827 roles |= FC_RPORT_ROLE_FCP_INITIATOR;
828 if (ndlp->nlp_type & NLP_FCP_TARGET)
829 roles |= FC_RPORT_ROLE_FCP_TARGET;
831 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT,
832 "rport rolechg: role:x%x did:x%x flg:x%x",
833 roles, ndlp->nlp_DID, ndlp->nlp_flag);
835 if (phba->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
836 fc_remote_port_rolechg(rport, roles);
841 lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
843 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
845 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED)) {
846 spin_lock_irq(shost->host_lock);
847 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
848 spin_unlock_irq(shost->host_lock);
852 if (!(vport->fc_flag & FC_PT2PT)) {
853 /* Check config parameter use-adisc or FCP-2 */
854 if (vport->cfg_use_adisc && ((vport->fc_flag & FC_RSCN_MODE) ||
855 ((ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) &&
856 (ndlp->nlp_type & NLP_FCP_TARGET)))) {
857 spin_lock_irq(shost->host_lock);
858 ndlp->nlp_flag |= NLP_NPR_ADISC;
859 spin_unlock_irq(shost->host_lock);
864 spin_lock_irq(shost->host_lock);
865 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
866 spin_unlock_irq(shost->host_lock);
867 lpfc_unreg_rpi(vport, ndlp);
872 * lpfc_release_rpi - Release a RPI by issuing unreg_login mailbox cmd.
873 * @phba : Pointer to lpfc_hba structure.
874 * @vport: Pointer to lpfc_vport structure.
875 * @rpi : rpi to be release.
877 * This function will send a unreg_login mailbox command to the firmware
881 lpfc_release_rpi(struct lpfc_hba *phba,
882 struct lpfc_vport *vport,
888 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
891 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
892 "2796 mailbox memory allocation failed \n");
894 lpfc_unreg_login(phba, vport->vpi, rpi, pmb);
895 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
896 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
897 if (rc == MBX_NOT_FINISHED)
898 mempool_free(pmb, phba->mbox_mem_pool);
903 lpfc_disc_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
904 void *arg, uint32_t evt)
906 struct lpfc_hba *phba;
907 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
911 /* Release the RPI if reglogin completing */
912 if (!(phba->pport->load_flag & FC_UNLOADING) &&
913 (evt == NLP_EVT_CMPL_REG_LOGIN) &&
914 (!pmb->u.mb.mbxStatus)) {
915 rpi = pmb->u.mb.un.varWords[0];
916 lpfc_release_rpi(phba, vport, rpi);
918 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
919 "0271 Illegal State Transition: node x%x "
920 "event x%x, state x%x Data: x%x x%x\n",
921 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
923 return ndlp->nlp_state;
927 lpfc_cmpl_plogi_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
928 void *arg, uint32_t evt)
930 /* This transition is only legal if we previously
931 * rcv'ed a PLOGI. Since we don't want 2 discovery threads
932 * working on the same NPortID, do nothing for this thread
935 if (!(ndlp->nlp_flag & NLP_RCV_PLOGI)) {
936 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
937 "0272 Illegal State Transition: node x%x "
938 "event x%x, state x%x Data: x%x x%x\n",
939 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
942 return ndlp->nlp_state;
945 /* Start of Discovery State Machine routines */
948 lpfc_rcv_plogi_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
949 void *arg, uint32_t evt)
951 struct lpfc_iocbq *cmdiocb;
953 cmdiocb = (struct lpfc_iocbq *) arg;
955 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
956 return ndlp->nlp_state;
958 return NLP_STE_FREED_NODE;
962 lpfc_rcv_els_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
963 void *arg, uint32_t evt)
965 lpfc_issue_els_logo(vport, ndlp, 0);
966 return ndlp->nlp_state;
970 lpfc_rcv_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
971 void *arg, uint32_t evt)
973 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
974 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
976 spin_lock_irq(shost->host_lock);
977 ndlp->nlp_flag |= NLP_LOGO_ACC;
978 spin_unlock_irq(shost->host_lock);
979 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
981 return ndlp->nlp_state;
985 lpfc_cmpl_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
986 void *arg, uint32_t evt)
988 return NLP_STE_FREED_NODE;
992 lpfc_device_rm_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
993 void *arg, uint32_t evt)
995 return NLP_STE_FREED_NODE;
999 lpfc_device_recov_unused_node(struct lpfc_vport *vport,
1000 struct lpfc_nodelist *ndlp,
1001 void *arg, uint32_t evt)
1003 return ndlp->nlp_state;
1007 lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1008 void *arg, uint32_t evt)
1010 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1011 struct lpfc_hba *phba = vport->phba;
1012 struct lpfc_iocbq *cmdiocb = arg;
1013 struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1014 uint32_t *lp = (uint32_t *) pcmd->virt;
1015 struct serv_parm *sp = (struct serv_parm *) (lp + 1);
1019 memset(&stat, 0, sizeof (struct ls_rjt));
1021 /* For a PLOGI, we only accept if our portname is less
1022 * than the remote portname.
1024 phba->fc_stat.elsLogiCol++;
1025 port_cmp = memcmp(&vport->fc_portname, &sp->portName,
1026 sizeof(struct lpfc_name));
1028 if (port_cmp >= 0) {
1029 /* Reject this request because the remote node will accept
1031 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
1032 stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS;
1033 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
1036 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb) &&
1037 (ndlp->nlp_flag & NLP_NPR_2B_DISC) &&
1038 (vport->num_disc_nodes)) {
1039 spin_lock_irq(shost->host_lock);
1040 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1041 spin_unlock_irq(shost->host_lock);
1042 /* Check if there are more PLOGIs to be sent */
1043 lpfc_more_plogi(vport);
1044 if (vport->num_disc_nodes == 0) {
1045 spin_lock_irq(shost->host_lock);
1046 vport->fc_flag &= ~FC_NDISC_ACTIVE;
1047 spin_unlock_irq(shost->host_lock);
1048 lpfc_can_disctmo(vport);
1049 lpfc_end_rscn(vport);
1052 } /* If our portname was less */
1054 return ndlp->nlp_state;
1058 lpfc_rcv_prli_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1059 void *arg, uint32_t evt)
1061 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1064 memset(&stat, 0, sizeof (struct ls_rjt));
1065 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
1066 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
1067 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
1068 return ndlp->nlp_state;
1072 lpfc_rcv_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1073 void *arg, uint32_t evt)
1075 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1077 /* Retrieve RPI from LOGO IOCB. RPI is used for CMD_ABORT_XRI_CN */
1078 if (vport->phba->sli_rev == LPFC_SLI_REV3)
1079 ndlp->nlp_rpi = cmdiocb->iocb.ulpIoTag;
1080 /* software abort outstanding PLOGI */
1081 lpfc_els_abort(vport->phba, ndlp);
1083 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1084 return ndlp->nlp_state;
1088 lpfc_rcv_els_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1089 void *arg, uint32_t evt)
1091 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1092 struct lpfc_hba *phba = vport->phba;
1093 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1095 /* software abort outstanding PLOGI */
1096 lpfc_els_abort(phba, ndlp);
1098 if (evt == NLP_EVT_RCV_LOGO) {
1099 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
1101 lpfc_issue_els_logo(vport, ndlp, 0);
1104 /* Put ndlp in npr state set plogi timer for 1 sec */
1105 mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000 * 1));
1106 spin_lock_irq(shost->host_lock);
1107 ndlp->nlp_flag |= NLP_DELAY_TMO;
1108 spin_unlock_irq(shost->host_lock);
1109 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1110 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
1111 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1113 return ndlp->nlp_state;
1117 lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport,
1118 struct lpfc_nodelist *ndlp,
1122 struct lpfc_hba *phba = vport->phba;
1123 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1124 struct lpfc_iocbq *cmdiocb, *rspiocb;
1125 struct lpfc_dmabuf *pcmd, *prsp, *mp;
1129 struct serv_parm *sp;
1134 cmdiocb = (struct lpfc_iocbq *) arg;
1135 rspiocb = cmdiocb->context_un.rsp_iocb;
1137 if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
1138 /* Recovery from PLOGI collision logic */
1139 return ndlp->nlp_state;
1142 irsp = &rspiocb->iocb;
1144 if (irsp->ulpStatus)
1147 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1149 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list);
1153 lp = (uint32_t *) prsp->virt;
1154 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
1156 /* Some switches have FDMI servers returning 0 for WWN */
1157 if ((ndlp->nlp_DID != FDMI_DID) &&
1158 (wwn_to_u64(sp->portName.u.wwn) == 0 ||
1159 wwn_to_u64(sp->nodeName.u.wwn) == 0)) {
1160 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1161 "0142 PLOGI RSP: Invalid WWN.\n");
1164 if (!lpfc_check_sparm(vport, ndlp, sp, CLASS3, 0))
1166 /* PLOGI chkparm OK */
1167 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1168 "0121 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
1169 ndlp->nlp_DID, ndlp->nlp_state,
1170 ndlp->nlp_flag, ndlp->nlp_rpi);
1171 if (vport->cfg_fcp_class == 2 && (sp->cls2.classValid))
1172 ndlp->nlp_fcp_info |= CLASS2;
1174 ndlp->nlp_fcp_info |= CLASS3;
1176 ndlp->nlp_class_sup = 0;
1177 if (sp->cls1.classValid)
1178 ndlp->nlp_class_sup |= FC_COS_CLASS1;
1179 if (sp->cls2.classValid)
1180 ndlp->nlp_class_sup |= FC_COS_CLASS2;
1181 if (sp->cls3.classValid)
1182 ndlp->nlp_class_sup |= FC_COS_CLASS3;
1183 if (sp->cls4.classValid)
1184 ndlp->nlp_class_sup |= FC_COS_CLASS4;
1185 ndlp->nlp_maxframe =
1186 ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb;
1188 if ((vport->fc_flag & FC_PT2PT) &&
1189 (vport->fc_flag & FC_PT2PT_PLOGI)) {
1190 ed_tov = be32_to_cpu(sp->cmn.e_d_tov);
1191 if (sp->cmn.edtovResolution) {
1192 /* E_D_TOV ticks are in nanoseconds */
1193 ed_tov = (phba->fc_edtov + 999999) / 1000000;
1196 ndlp->nlp_flag &= ~NLP_SUPPRESS_RSP;
1197 if ((phba->sli.sli_flag & LPFC_SLI_SUPPRESS_RSP) &&
1198 sp->cmn.valid_vendor_ver_level) {
1199 vid = be32_to_cpu(sp->un.vv.vid);
1200 flag = be32_to_cpu(sp->un.vv.flags);
1201 if ((vid == LPFC_VV_EMLX_ID) &&
1202 (flag & LPFC_VV_SUPPRESS_RSP))
1203 ndlp->nlp_flag |= NLP_SUPPRESS_RSP;
1207 * Use the larger EDTOV
1208 * RATOV = 2 * EDTOV for pt-to-pt
1210 if (ed_tov > phba->fc_edtov)
1211 phba->fc_edtov = ed_tov;
1212 phba->fc_ratov = (2 * phba->fc_edtov) / 1000;
1214 memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm));
1216 /* Issue config_link / reg_vfi to account for updated TOV's */
1217 if (phba->sli_rev == LPFC_SLI_REV4) {
1218 lpfc_issue_reg_vfi(vport);
1220 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1222 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1223 "0133 PLOGI: no memory "
1225 "Data: x%x x%x x%x x%x\n",
1226 ndlp->nlp_DID, ndlp->nlp_state,
1227 ndlp->nlp_flag, ndlp->nlp_rpi);
1231 lpfc_config_link(phba, mbox);
1233 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1234 mbox->vport = vport;
1235 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
1236 if (rc == MBX_NOT_FINISHED) {
1237 mempool_free(mbox, phba->mbox_mem_pool);
1243 lpfc_unreg_rpi(vport, ndlp);
1245 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1247 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1248 "0018 PLOGI: no memory for reg_login "
1249 "Data: x%x x%x x%x x%x\n",
1250 ndlp->nlp_DID, ndlp->nlp_state,
1251 ndlp->nlp_flag, ndlp->nlp_rpi);
1255 if (lpfc_reg_rpi(phba, vport->vpi, irsp->un.elsreq64.remoteID,
1256 (uint8_t *) sp, mbox, ndlp->nlp_rpi) == 0) {
1257 switch (ndlp->nlp_DID) {
1258 case NameServer_DID:
1259 mbox->mbox_cmpl = lpfc_mbx_cmpl_ns_reg_login;
1262 mbox->mbox_cmpl = lpfc_mbx_cmpl_fdmi_reg_login;
1265 ndlp->nlp_flag |= NLP_REG_LOGIN_SEND;
1266 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
1268 mbox->context2 = lpfc_nlp_get(ndlp);
1269 mbox->vport = vport;
1270 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
1271 != MBX_NOT_FINISHED) {
1272 lpfc_nlp_set_state(vport, ndlp,
1273 NLP_STE_REG_LOGIN_ISSUE);
1274 return ndlp->nlp_state;
1276 if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND)
1277 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1278 /* decrement node reference count to the failed mbox
1282 mp = (struct lpfc_dmabuf *) mbox->context1;
1283 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1285 mempool_free(mbox, phba->mbox_mem_pool);
1287 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1288 "0134 PLOGI: cannot issue reg_login "
1289 "Data: x%x x%x x%x x%x\n",
1290 ndlp->nlp_DID, ndlp->nlp_state,
1291 ndlp->nlp_flag, ndlp->nlp_rpi);
1293 mempool_free(mbox, phba->mbox_mem_pool);
1295 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1296 "0135 PLOGI: cannot format reg_login "
1297 "Data: x%x x%x x%x x%x\n",
1298 ndlp->nlp_DID, ndlp->nlp_state,
1299 ndlp->nlp_flag, ndlp->nlp_rpi);
1304 if (ndlp->nlp_DID == NameServer_DID) {
1305 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1306 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1307 "0261 Cannot Register NameServer login\n");
1311 ** In case the node reference counter does not go to zero, ensure that
1312 ** the stale state for the node is not processed.
1315 ndlp->nlp_prev_state = ndlp->nlp_state;
1316 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1317 spin_lock_irq(shost->host_lock);
1318 ndlp->nlp_flag |= NLP_DEFER_RM;
1319 spin_unlock_irq(shost->host_lock);
1320 return NLP_STE_FREED_NODE;
1324 lpfc_cmpl_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1325 void *arg, uint32_t evt)
1327 return ndlp->nlp_state;
1331 lpfc_cmpl_reglogin_plogi_issue(struct lpfc_vport *vport,
1332 struct lpfc_nodelist *ndlp, void *arg, uint32_t evt)
1334 struct lpfc_hba *phba;
1335 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
1336 MAILBOX_t *mb = &pmb->u.mb;
1340 /* Release the RPI */
1341 if (!(phba->pport->load_flag & FC_UNLOADING) &&
1343 rpi = pmb->u.mb.un.varWords[0];
1344 lpfc_release_rpi(phba, vport, rpi);
1346 return ndlp->nlp_state;
1350 lpfc_device_rm_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1351 void *arg, uint32_t evt)
1353 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1355 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1356 spin_lock_irq(shost->host_lock);
1357 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1358 spin_unlock_irq(shost->host_lock);
1359 return ndlp->nlp_state;
1361 /* software abort outstanding PLOGI */
1362 lpfc_els_abort(vport->phba, ndlp);
1364 lpfc_drop_node(vport, ndlp);
1365 return NLP_STE_FREED_NODE;
1370 lpfc_device_recov_plogi_issue(struct lpfc_vport *vport,
1371 struct lpfc_nodelist *ndlp,
1375 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1376 struct lpfc_hba *phba = vport->phba;
1378 /* Don't do anything that will mess up processing of the
1381 if (vport->fc_flag & FC_RSCN_DEFERRED)
1382 return ndlp->nlp_state;
1384 /* software abort outstanding PLOGI */
1385 lpfc_els_abort(phba, ndlp);
1387 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
1388 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1389 spin_lock_irq(shost->host_lock);
1390 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1391 spin_unlock_irq(shost->host_lock);
1393 return ndlp->nlp_state;
1397 lpfc_rcv_plogi_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1398 void *arg, uint32_t evt)
1400 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1401 struct lpfc_hba *phba = vport->phba;
1402 struct lpfc_iocbq *cmdiocb;
1404 /* software abort outstanding ADISC */
1405 lpfc_els_abort(phba, ndlp);
1407 cmdiocb = (struct lpfc_iocbq *) arg;
1409 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
1410 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1411 spin_lock_irq(shost->host_lock);
1412 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1413 spin_unlock_irq(shost->host_lock);
1414 if (vport->num_disc_nodes)
1415 lpfc_more_adisc(vport);
1417 return ndlp->nlp_state;
1419 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1420 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
1421 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
1423 return ndlp->nlp_state;
1427 lpfc_rcv_prli_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1428 void *arg, uint32_t evt)
1430 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1432 if (lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
1433 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1434 return ndlp->nlp_state;
1438 lpfc_rcv_logo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1439 void *arg, uint32_t evt)
1441 struct lpfc_hba *phba = vport->phba;
1442 struct lpfc_iocbq *cmdiocb;
1444 cmdiocb = (struct lpfc_iocbq *) arg;
1446 /* software abort outstanding ADISC */
1447 lpfc_els_abort(phba, ndlp);
1449 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1450 return ndlp->nlp_state;
1454 lpfc_rcv_padisc_adisc_issue(struct lpfc_vport *vport,
1455 struct lpfc_nodelist *ndlp,
1456 void *arg, uint32_t evt)
1458 struct lpfc_iocbq *cmdiocb;
1460 cmdiocb = (struct lpfc_iocbq *) arg;
1462 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1463 return ndlp->nlp_state;
1467 lpfc_rcv_prlo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1468 void *arg, uint32_t evt)
1470 struct lpfc_iocbq *cmdiocb;
1472 cmdiocb = (struct lpfc_iocbq *) arg;
1474 /* Treat like rcv logo */
1475 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
1476 return ndlp->nlp_state;
1480 lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport *vport,
1481 struct lpfc_nodelist *ndlp,
1482 void *arg, uint32_t evt)
1484 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1485 struct lpfc_hba *phba = vport->phba;
1486 struct lpfc_iocbq *cmdiocb, *rspiocb;
1491 cmdiocb = (struct lpfc_iocbq *) arg;
1492 rspiocb = cmdiocb->context_un.rsp_iocb;
1494 ap = (ADISC *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
1495 irsp = &rspiocb->iocb;
1497 if ((irsp->ulpStatus) ||
1498 (!lpfc_check_adisc(vport, ndlp, &ap->nodeName, &ap->portName))) {
1500 mod_timer(&ndlp->nlp_delayfunc,
1501 jiffies + msecs_to_jiffies(1000));
1502 spin_lock_irq(shost->host_lock);
1503 ndlp->nlp_flag |= NLP_DELAY_TMO;
1504 spin_unlock_irq(shost->host_lock);
1505 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1507 memset(&ndlp->nlp_nodename, 0, sizeof(struct lpfc_name));
1508 memset(&ndlp->nlp_portname, 0, sizeof(struct lpfc_name));
1510 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1511 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1512 lpfc_unreg_rpi(vport, ndlp);
1513 return ndlp->nlp_state;
1516 if (phba->sli_rev == LPFC_SLI_REV4) {
1517 rc = lpfc_sli4_resume_rpi(ndlp, NULL, NULL);
1519 /* Stay in state and retry. */
1520 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1521 return ndlp->nlp_state;
1525 if (ndlp->nlp_type & NLP_FCP_TARGET) {
1526 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1527 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
1529 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1530 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
1533 return ndlp->nlp_state;
1537 lpfc_device_rm_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1538 void *arg, uint32_t evt)
1540 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1542 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1543 spin_lock_irq(shost->host_lock);
1544 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1545 spin_unlock_irq(shost->host_lock);
1546 return ndlp->nlp_state;
1548 /* software abort outstanding ADISC */
1549 lpfc_els_abort(vport->phba, ndlp);
1551 lpfc_drop_node(vport, ndlp);
1552 return NLP_STE_FREED_NODE;
1557 lpfc_device_recov_adisc_issue(struct lpfc_vport *vport,
1558 struct lpfc_nodelist *ndlp,
1562 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1563 struct lpfc_hba *phba = vport->phba;
1565 /* Don't do anything that will mess up processing of the
1568 if (vport->fc_flag & FC_RSCN_DEFERRED)
1569 return ndlp->nlp_state;
1571 /* software abort outstanding ADISC */
1572 lpfc_els_abort(phba, ndlp);
1574 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1575 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1576 spin_lock_irq(shost->host_lock);
1577 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1578 spin_unlock_irq(shost->host_lock);
1579 lpfc_disc_set_adisc(vport, ndlp);
1580 return ndlp->nlp_state;
1584 lpfc_rcv_plogi_reglogin_issue(struct lpfc_vport *vport,
1585 struct lpfc_nodelist *ndlp,
1589 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1591 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
1592 return ndlp->nlp_state;
1596 lpfc_rcv_prli_reglogin_issue(struct lpfc_vport *vport,
1597 struct lpfc_nodelist *ndlp,
1601 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1604 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb)) {
1605 return ndlp->nlp_state;
1607 if (vport->phba->nvmet_support) {
1608 /* NVME Target mode. Handle and respond to the PRLI and
1609 * transition to UNMAPPED provided the RPI has completed
1612 if (ndlp->nlp_flag & NLP_RPI_REGISTERED) {
1613 lpfc_rcv_prli(vport, ndlp, cmdiocb);
1614 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1616 /* RPI registration has not completed. Reject the PRLI
1617 * to prevent an illegal state transition when the
1618 * rpi registration does complete.
1620 memset(&stat, 0, sizeof(struct ls_rjt));
1621 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
1622 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
1623 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
1625 return ndlp->nlp_state;
1628 /* Initiator mode. */
1629 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1631 return ndlp->nlp_state;
1635 lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport,
1636 struct lpfc_nodelist *ndlp,
1640 struct lpfc_hba *phba = vport->phba;
1641 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1643 LPFC_MBOXQ_t *nextmb;
1644 struct lpfc_dmabuf *mp;
1646 cmdiocb = (struct lpfc_iocbq *) arg;
1648 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1649 if ((mb = phba->sli.mbox_active)) {
1650 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1651 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1652 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1654 mb->context2 = NULL;
1655 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1659 spin_lock_irq(&phba->hbalock);
1660 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
1661 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1662 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1663 mp = (struct lpfc_dmabuf *) (mb->context1);
1665 __lpfc_mbuf_free(phba, mp->virt, mp->phys);
1668 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1670 list_del(&mb->list);
1671 phba->sli.mboxq_cnt--;
1672 mempool_free(mb, phba->mbox_mem_pool);
1675 spin_unlock_irq(&phba->hbalock);
1677 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1678 return ndlp->nlp_state;
1682 lpfc_rcv_padisc_reglogin_issue(struct lpfc_vport *vport,
1683 struct lpfc_nodelist *ndlp,
1687 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1689 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1690 return ndlp->nlp_state;
1694 lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport *vport,
1695 struct lpfc_nodelist *ndlp,
1699 struct lpfc_iocbq *cmdiocb;
1701 cmdiocb = (struct lpfc_iocbq *) arg;
1702 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1703 return ndlp->nlp_state;
1707 lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
1708 struct lpfc_nodelist *ndlp,
1712 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1713 struct lpfc_hba *phba = vport->phba;
1714 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
1715 MAILBOX_t *mb = &pmb->u.mb;
1716 uint32_t did = mb->un.varWords[1];
1719 if (mb->mbxStatus) {
1720 /* RegLogin failed */
1721 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1722 "0246 RegLogin failed Data: x%x x%x x%x x%x "
1724 did, mb->mbxStatus, vport->port_state,
1725 mb->un.varRegLogin.vpi,
1726 mb->un.varRegLogin.rpi);
1728 * If RegLogin failed due to lack of HBA resources do not
1731 if (mb->mbxStatus == MBXERR_RPI_FULL) {
1732 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1733 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1734 return ndlp->nlp_state;
1737 /* Put ndlp in npr state set plogi timer for 1 sec */
1738 mod_timer(&ndlp->nlp_delayfunc,
1739 jiffies + msecs_to_jiffies(1000 * 1));
1740 spin_lock_irq(shost->host_lock);
1741 ndlp->nlp_flag |= NLP_DELAY_TMO;
1742 spin_unlock_irq(shost->host_lock);
1743 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1745 lpfc_issue_els_logo(vport, ndlp, 0);
1746 return ndlp->nlp_state;
1749 /* SLI4 ports have preallocated logical rpis. */
1750 if (phba->sli_rev < LPFC_SLI_REV4)
1751 ndlp->nlp_rpi = mb->un.varWords[0];
1753 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
1755 /* Only if we are not a fabric nport do we issue PRLI */
1756 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1757 "3066 RegLogin Complete on x%x x%x x%x\n",
1758 did, ndlp->nlp_type, ndlp->nlp_fc4_type);
1759 if (!(ndlp->nlp_type & NLP_FABRIC) &&
1760 (phba->nvmet_support == 0)) {
1761 /* The driver supports FCP and NVME concurrently. If the
1762 * ndlp's nlp_fc4_type is still zero, the driver doesn't
1763 * know what PRLI to send yet. Figure that out now and
1764 * call PRLI depending on the outcome.
1766 if (vport->fc_flag & FC_PT2PT) {
1767 /* If we are pt2pt, there is no Fabric to determine
1768 * the FC4 type of the remote nport. So if NVME
1769 * is configured try it.
1771 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1772 if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1773 (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
1774 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
1775 /* We need to update the localport also */
1776 lpfc_nvme_update_localport(vport);
1779 } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
1780 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1782 } else if (ndlp->nlp_fc4_type == 0) {
1783 rc = lpfc_ns_cmd(vport, SLI_CTNS_GFT_ID,
1785 return ndlp->nlp_state;
1788 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1789 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
1790 lpfc_issue_els_prli(vport, ndlp, 0);
1792 if ((vport->fc_flag & FC_PT2PT) && phba->nvmet_support)
1793 phba->targetport->port_id = vport->fc_myDID;
1795 /* Only Fabric ports should transition. NVME target
1796 * must complete PRLI.
1798 if (ndlp->nlp_type & NLP_FABRIC) {
1799 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1800 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
1803 return ndlp->nlp_state;
1807 lpfc_device_rm_reglogin_issue(struct lpfc_vport *vport,
1808 struct lpfc_nodelist *ndlp,
1812 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1814 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1815 spin_lock_irq(shost->host_lock);
1816 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1817 spin_unlock_irq(shost->host_lock);
1818 return ndlp->nlp_state;
1820 lpfc_drop_node(vport, ndlp);
1821 return NLP_STE_FREED_NODE;
1826 lpfc_device_recov_reglogin_issue(struct lpfc_vport *vport,
1827 struct lpfc_nodelist *ndlp,
1831 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1833 /* Don't do anything that will mess up processing of the
1836 if (vport->fc_flag & FC_RSCN_DEFERRED)
1837 return ndlp->nlp_state;
1839 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1840 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1841 spin_lock_irq(shost->host_lock);
1843 /* If we are a target we won't immediately transition into PRLI,
1844 * so if REG_LOGIN already completed we don't need to ignore it.
1846 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED) ||
1847 !vport->phba->nvmet_support)
1848 ndlp->nlp_flag |= NLP_IGNR_REG_CMPL;
1850 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1851 spin_unlock_irq(shost->host_lock);
1852 lpfc_disc_set_adisc(vport, ndlp);
1853 return ndlp->nlp_state;
1857 lpfc_rcv_plogi_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1858 void *arg, uint32_t evt)
1860 struct lpfc_iocbq *cmdiocb;
1862 cmdiocb = (struct lpfc_iocbq *) arg;
1864 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
1865 return ndlp->nlp_state;
1869 lpfc_rcv_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1870 void *arg, uint32_t evt)
1872 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1874 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
1875 return ndlp->nlp_state;
1876 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1877 return ndlp->nlp_state;
1881 lpfc_rcv_logo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1882 void *arg, uint32_t evt)
1884 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1886 /* Software abort outstanding PRLI before sending acc */
1887 lpfc_els_abort(vport->phba, ndlp);
1889 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1890 return ndlp->nlp_state;
1894 lpfc_rcv_padisc_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1895 void *arg, uint32_t evt)
1897 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1899 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1900 return ndlp->nlp_state;
1903 /* This routine is envoked when we rcv a PRLO request from a nport
1904 * we are logged into. We should send back a PRLO rsp setting the
1906 * NEXT STATE = PRLI_ISSUE
1909 lpfc_rcv_prlo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1910 void *arg, uint32_t evt)
1912 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1914 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1915 return ndlp->nlp_state;
1919 lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1920 void *arg, uint32_t evt)
1922 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1923 struct lpfc_iocbq *cmdiocb, *rspiocb;
1924 struct lpfc_hba *phba = vport->phba;
1927 struct lpfc_nvme_prli *nvpr;
1930 cmdiocb = (struct lpfc_iocbq *) arg;
1931 rspiocb = cmdiocb->context_un.rsp_iocb;
1933 /* A solicited PRLI is either FCP or NVME. The PRLI cmd/rsp
1934 * format is different so NULL the two PRLI types so that the
1935 * driver correctly gets the correct context.
1939 temp_ptr = lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
1940 if (cmdiocb->iocb_flag & LPFC_PRLI_FCP_REQ)
1941 npr = (PRLI *) temp_ptr;
1942 else if (cmdiocb->iocb_flag & LPFC_PRLI_NVME_REQ)
1943 nvpr = (struct lpfc_nvme_prli *) temp_ptr;
1945 irsp = &rspiocb->iocb;
1946 if (irsp->ulpStatus) {
1947 if ((vport->port_type == LPFC_NPIV_PORT) &&
1948 vport->cfg_restrict_login) {
1952 /* Adjust the nlp_type accordingly if the PRLI failed */
1954 ndlp->nlp_fc4_type &= ~NLP_FC4_FCP;
1956 ndlp->nlp_fc4_type &= ~NLP_FC4_NVME;
1958 /* We can't set the DSM state till BOTH PRLIs complete */
1962 if (npr && (npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
1963 (npr->prliType == PRLI_FCP_TYPE)) {
1964 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
1965 "6028 FCP NPR PRLI Cmpl Init %d Target %d\n",
1968 if (npr->initiatorFunc)
1969 ndlp->nlp_type |= NLP_FCP_INITIATOR;
1970 if (npr->targetFunc) {
1971 ndlp->nlp_type |= NLP_FCP_TARGET;
1972 if (npr->writeXferRdyDis)
1973 ndlp->nlp_flag |= NLP_FIRSTBURST;
1976 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
1979 (bf_get_be32(prli_acc_rsp_code, nvpr) ==
1980 PRLI_REQ_EXECUTED) &&
1981 (bf_get_be32(prli_type_code, nvpr) ==
1984 /* Complete setting up the remote ndlp personality. */
1985 if (bf_get_be32(prli_init, nvpr))
1986 ndlp->nlp_type |= NLP_NVME_INITIATOR;
1988 /* Target driver cannot solicit NVME FB. */
1989 if (bf_get_be32(prli_tgt, nvpr)) {
1990 /* Complete the nvme target roles. The transport
1991 * needs to know if the rport is capable of
1992 * discovery in addition to its role.
1994 ndlp->nlp_type |= NLP_NVME_TARGET;
1995 if (bf_get_be32(prli_disc, nvpr))
1996 ndlp->nlp_type |= NLP_NVME_DISCOVERY;
1999 * If prli_fba is set, the Target supports FirstBurst.
2000 * If prli_fb_sz is 0, the FirstBurst size is unlimited,
2001 * otherwise it defines the actual size supported by
2004 if ((bf_get_be32(prli_fba, nvpr) == 1) &&
2005 (phba->cfg_nvme_enable_fb) &&
2006 (!phba->nvmet_support)) {
2007 /* Both sides support FB. The target's first
2008 * burst size is a 512 byte encoded value.
2010 ndlp->nlp_flag |= NLP_FIRSTBURST;
2011 ndlp->nvme_fb_size = bf_get_be32(prli_fb_sz,
2014 /* Expressed in units of 512 bytes */
2015 if (ndlp->nvme_fb_size)
2016 ndlp->nvme_fb_size <<=
2019 ndlp->nvme_fb_size = LPFC_NVME_MAX_FB;
2023 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
2024 "6029 NVME PRLI Cmpl w1 x%08x "
2025 "w4 x%08x w5 x%08x flag x%x, "
2026 "fcp_info x%x nlp_type x%x\n",
2027 be32_to_cpu(nvpr->word1),
2028 be32_to_cpu(nvpr->word4),
2029 be32_to_cpu(nvpr->word5),
2030 ndlp->nlp_flag, ndlp->nlp_fcp_info,
2033 if (!(ndlp->nlp_type & NLP_FCP_TARGET) &&
2034 (vport->port_type == LPFC_NPIV_PORT) &&
2035 vport->cfg_restrict_login) {
2037 spin_lock_irq(shost->host_lock);
2038 ndlp->nlp_flag |= NLP_TARGET_REMOVE;
2039 spin_unlock_irq(shost->host_lock);
2040 lpfc_issue_els_logo(vport, ndlp, 0);
2042 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2043 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2044 return ndlp->nlp_state;
2048 /* The ndlp state cannot move to MAPPED or UNMAPPED before all PRLIs
2051 if (ndlp->fc4_prli_sent == 0) {
2052 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2053 if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET))
2054 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
2055 else if (ndlp->nlp_type &
2056 (NLP_FCP_INITIATOR | NLP_NVME_INITIATOR))
2057 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
2059 lpfc_printf_vlog(vport,
2061 "3067 PRLI's still outstanding "
2062 "on x%06x - count %d, Pend Node Mode "
2064 ndlp->nlp_DID, ndlp->fc4_prli_sent);
2066 return ndlp->nlp_state;
2069 /*! lpfc_device_rm_prli_issue
2080 * This routine is envoked when we a request to remove a nport we are in the
2081 * process of PRLIing. We should software abort outstanding prli, unreg
2082 * login, send a logout. We will change node state to UNUSED_NODE, put it
2083 * on plogi list so it can be freed when LOGO completes.
2088 lpfc_device_rm_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2089 void *arg, uint32_t evt)
2091 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2093 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
2094 spin_lock_irq(shost->host_lock);
2095 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
2096 spin_unlock_irq(shost->host_lock);
2097 return ndlp->nlp_state;
2099 /* software abort outstanding PLOGI */
2100 lpfc_els_abort(vport->phba, ndlp);
2102 lpfc_drop_node(vport, ndlp);
2103 return NLP_STE_FREED_NODE;
2108 /*! lpfc_device_recov_prli_issue
2119 * The routine is envoked when the state of a device is unknown, like
2120 * during a link down. We should remove the nodelist entry from the
2121 * unmapped list, issue a UNREG_LOGIN, do a software abort of the
2122 * outstanding PRLI command, then free the node entry.
2125 lpfc_device_recov_prli_issue(struct lpfc_vport *vport,
2126 struct lpfc_nodelist *ndlp,
2130 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2131 struct lpfc_hba *phba = vport->phba;
2133 /* Don't do anything that will mess up processing of the
2136 if (vport->fc_flag & FC_RSCN_DEFERRED)
2137 return ndlp->nlp_state;
2139 /* software abort outstanding PRLI */
2140 lpfc_els_abort(phba, ndlp);
2142 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2143 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2144 spin_lock_irq(shost->host_lock);
2145 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2146 spin_unlock_irq(shost->host_lock);
2147 lpfc_disc_set_adisc(vport, ndlp);
2148 return ndlp->nlp_state;
2152 lpfc_rcv_plogi_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2153 void *arg, uint32_t evt)
2155 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2158 memset(&stat, 0, sizeof(struct ls_rjt));
2159 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2160 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2161 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2162 return ndlp->nlp_state;
2166 lpfc_rcv_prli_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2167 void *arg, uint32_t evt)
2169 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2172 memset(&stat, 0, sizeof(struct ls_rjt));
2173 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2174 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2175 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2176 return ndlp->nlp_state;
2180 lpfc_rcv_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2181 void *arg, uint32_t evt)
2183 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2184 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2186 spin_lock_irq(shost->host_lock);
2187 ndlp->nlp_flag |= NLP_LOGO_ACC;
2188 spin_unlock_irq(shost->host_lock);
2189 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2190 return ndlp->nlp_state;
2194 lpfc_rcv_padisc_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2195 void *arg, uint32_t evt)
2197 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2200 memset(&stat, 0, sizeof(struct ls_rjt));
2201 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2202 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2203 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2204 return ndlp->nlp_state;
2208 lpfc_rcv_prlo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2209 void *arg, uint32_t evt)
2211 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2214 memset(&stat, 0, sizeof(struct ls_rjt));
2215 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2216 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2217 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2218 return ndlp->nlp_state;
2222 lpfc_cmpl_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2223 void *arg, uint32_t evt)
2225 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2227 ndlp->nlp_prev_state = NLP_STE_LOGO_ISSUE;
2228 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2229 spin_lock_irq(shost->host_lock);
2230 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2231 spin_unlock_irq(shost->host_lock);
2232 lpfc_disc_set_adisc(vport, ndlp);
2233 return ndlp->nlp_state;
2237 lpfc_device_rm_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2238 void *arg, uint32_t evt)
2241 * DevLoss has timed out and is calling for Device Remove.
2242 * In this case, abort the LOGO and cleanup the ndlp
2245 lpfc_unreg_rpi(vport, ndlp);
2246 /* software abort outstanding PLOGI */
2247 lpfc_els_abort(vport->phba, ndlp);
2248 lpfc_drop_node(vport, ndlp);
2249 return NLP_STE_FREED_NODE;
2253 lpfc_device_recov_logo_issue(struct lpfc_vport *vport,
2254 struct lpfc_nodelist *ndlp,
2255 void *arg, uint32_t evt)
2258 * Device Recovery events have no meaning for a node with a LOGO
2259 * outstanding. The LOGO has to complete first and handle the
2260 * node from that point.
2262 return ndlp->nlp_state;
2266 lpfc_rcv_plogi_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2267 void *arg, uint32_t evt)
2269 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2271 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
2272 return ndlp->nlp_state;
2276 lpfc_rcv_prli_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2277 void *arg, uint32_t evt)
2279 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2281 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
2282 return ndlp->nlp_state;
2284 lpfc_rcv_prli(vport, ndlp, cmdiocb);
2285 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
2286 return ndlp->nlp_state;
2290 lpfc_rcv_logo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2291 void *arg, uint32_t evt)
2293 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2295 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2296 return ndlp->nlp_state;
2300 lpfc_rcv_padisc_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2301 void *arg, uint32_t evt)
2303 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2305 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2306 return ndlp->nlp_state;
2310 lpfc_rcv_prlo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2311 void *arg, uint32_t evt)
2313 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2315 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
2316 return ndlp->nlp_state;
2320 lpfc_device_recov_unmap_node(struct lpfc_vport *vport,
2321 struct lpfc_nodelist *ndlp,
2325 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2327 ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
2328 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2329 spin_lock_irq(shost->host_lock);
2330 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2331 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2332 spin_unlock_irq(shost->host_lock);
2333 lpfc_disc_set_adisc(vport, ndlp);
2335 return ndlp->nlp_state;
2339 lpfc_rcv_plogi_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2340 void *arg, uint32_t evt)
2342 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2344 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
2345 return ndlp->nlp_state;
2349 lpfc_rcv_prli_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2350 void *arg, uint32_t evt)
2352 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2354 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
2355 return ndlp->nlp_state;
2356 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
2357 return ndlp->nlp_state;
2361 lpfc_rcv_logo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2362 void *arg, uint32_t evt)
2364 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2366 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2367 return ndlp->nlp_state;
2371 lpfc_rcv_padisc_mapped_node(struct lpfc_vport *vport,
2372 struct lpfc_nodelist *ndlp,
2373 void *arg, uint32_t evt)
2375 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2377 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2378 return ndlp->nlp_state;
2382 lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2383 void *arg, uint32_t evt)
2385 struct lpfc_hba *phba = vport->phba;
2386 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2388 /* flush the target */
2389 lpfc_sli_abort_iocb(vport, &phba->sli.sli3_ring[LPFC_FCP_RING],
2390 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
2392 /* Treat like rcv logo */
2393 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
2394 return ndlp->nlp_state;
2398 lpfc_device_recov_mapped_node(struct lpfc_vport *vport,
2399 struct lpfc_nodelist *ndlp,
2403 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2405 ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
2406 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2407 spin_lock_irq(shost->host_lock);
2408 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2409 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2410 spin_unlock_irq(shost->host_lock);
2411 lpfc_disc_set_adisc(vport, ndlp);
2412 return ndlp->nlp_state;
2416 lpfc_rcv_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2417 void *arg, uint32_t evt)
2419 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2420 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2422 /* Ignore PLOGI if we have an outstanding LOGO */
2423 if (ndlp->nlp_flag & (NLP_LOGO_SND | NLP_LOGO_ACC))
2424 return ndlp->nlp_state;
2425 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
2426 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2427 spin_lock_irq(shost->host_lock);
2428 ndlp->nlp_flag &= ~(NLP_NPR_ADISC | NLP_NPR_2B_DISC);
2429 spin_unlock_irq(shost->host_lock);
2430 } else if (!(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
2431 /* send PLOGI immediately, move to PLOGI issue state */
2432 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
2433 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2434 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2435 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2438 return ndlp->nlp_state;
2442 lpfc_rcv_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2443 void *arg, uint32_t evt)
2445 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2446 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2449 memset(&stat, 0, sizeof (struct ls_rjt));
2450 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2451 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2452 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2454 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
2455 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
2456 spin_lock_irq(shost->host_lock);
2457 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2458 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2459 spin_unlock_irq(shost->host_lock);
2460 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2461 lpfc_issue_els_adisc(vport, ndlp, 0);
2463 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2464 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2465 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2468 return ndlp->nlp_state;
2472 lpfc_rcv_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2473 void *arg, uint32_t evt)
2475 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2477 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2478 return ndlp->nlp_state;
2482 lpfc_rcv_padisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2483 void *arg, uint32_t evt)
2485 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2487 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2489 * Do not start discovery if discovery is about to start
2490 * or discovery in progress for this node. Starting discovery
2491 * here will affect the counting of discovery threads.
2493 if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
2494 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
2495 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
2496 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2497 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2498 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2499 lpfc_issue_els_adisc(vport, ndlp, 0);
2501 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2502 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2503 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2506 return ndlp->nlp_state;
2510 lpfc_rcv_prlo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2511 void *arg, uint32_t evt)
2513 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2514 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2516 spin_lock_irq(shost->host_lock);
2517 ndlp->nlp_flag |= NLP_LOGO_ACC;
2518 spin_unlock_irq(shost->host_lock);
2520 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2522 if ((ndlp->nlp_flag & NLP_DELAY_TMO) == 0) {
2523 mod_timer(&ndlp->nlp_delayfunc,
2524 jiffies + msecs_to_jiffies(1000 * 1));
2525 spin_lock_irq(shost->host_lock);
2526 ndlp->nlp_flag |= NLP_DELAY_TMO;
2527 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2528 spin_unlock_irq(shost->host_lock);
2529 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
2531 spin_lock_irq(shost->host_lock);
2532 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2533 spin_unlock_irq(shost->host_lock);
2535 return ndlp->nlp_state;
2539 lpfc_cmpl_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2540 void *arg, uint32_t evt)
2542 struct lpfc_iocbq *cmdiocb, *rspiocb;
2544 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2546 cmdiocb = (struct lpfc_iocbq *) arg;
2547 rspiocb = cmdiocb->context_un.rsp_iocb;
2549 irsp = &rspiocb->iocb;
2550 if (irsp->ulpStatus) {
2551 spin_lock_irq(shost->host_lock);
2552 ndlp->nlp_flag |= NLP_DEFER_RM;
2553 spin_unlock_irq(shost->host_lock);
2554 return NLP_STE_FREED_NODE;
2556 return ndlp->nlp_state;
2560 lpfc_cmpl_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2561 void *arg, uint32_t evt)
2563 struct lpfc_iocbq *cmdiocb, *rspiocb;
2566 cmdiocb = (struct lpfc_iocbq *) arg;
2567 rspiocb = cmdiocb->context_un.rsp_iocb;
2569 irsp = &rspiocb->iocb;
2570 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
2571 lpfc_drop_node(vport, ndlp);
2572 return NLP_STE_FREED_NODE;
2574 return ndlp->nlp_state;
2578 lpfc_cmpl_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2579 void *arg, uint32_t evt)
2581 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2583 /* For the fabric port just clear the fc flags. */
2584 if (ndlp->nlp_DID == Fabric_DID) {
2585 spin_lock_irq(shost->host_lock);
2586 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
2587 spin_unlock_irq(shost->host_lock);
2589 lpfc_unreg_rpi(vport, ndlp);
2590 return ndlp->nlp_state;
2594 lpfc_cmpl_adisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2595 void *arg, uint32_t evt)
2597 struct lpfc_iocbq *cmdiocb, *rspiocb;
2600 cmdiocb = (struct lpfc_iocbq *) arg;
2601 rspiocb = cmdiocb->context_un.rsp_iocb;
2603 irsp = &rspiocb->iocb;
2604 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
2605 lpfc_drop_node(vport, ndlp);
2606 return NLP_STE_FREED_NODE;
2608 return ndlp->nlp_state;
2612 lpfc_cmpl_reglogin_npr_node(struct lpfc_vport *vport,
2613 struct lpfc_nodelist *ndlp,
2614 void *arg, uint32_t evt)
2616 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
2617 MAILBOX_t *mb = &pmb->u.mb;
2619 if (!mb->mbxStatus) {
2620 /* SLI4 ports have preallocated logical rpis. */
2621 if (vport->phba->sli_rev < LPFC_SLI_REV4)
2622 ndlp->nlp_rpi = mb->un.varWords[0];
2623 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
2624 if (ndlp->nlp_flag & NLP_LOGO_ACC) {
2625 lpfc_unreg_rpi(vport, ndlp);
2628 if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
2629 lpfc_drop_node(vport, ndlp);
2630 return NLP_STE_FREED_NODE;
2633 return ndlp->nlp_state;
2637 lpfc_device_rm_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2638 void *arg, uint32_t evt)
2640 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2642 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
2643 spin_lock_irq(shost->host_lock);
2644 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
2645 spin_unlock_irq(shost->host_lock);
2646 return ndlp->nlp_state;
2648 lpfc_drop_node(vport, ndlp);
2649 return NLP_STE_FREED_NODE;
2653 lpfc_device_recov_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2654 void *arg, uint32_t evt)
2656 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2658 /* Don't do anything that will mess up processing of the
2661 if (vport->fc_flag & FC_RSCN_DEFERRED)
2662 return ndlp->nlp_state;
2664 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2665 spin_lock_irq(shost->host_lock);
2666 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2667 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2668 spin_unlock_irq(shost->host_lock);
2669 return ndlp->nlp_state;
2673 /* This next section defines the NPort Discovery State Machine */
2675 /* There are 4 different double linked lists nodelist entries can reside on.
2676 * The plogi list and adisc list are used when Link Up discovery or RSCN
2677 * processing is needed. Each list holds the nodes that we will send PLOGI
2678 * or ADISC on. These lists will keep track of what nodes will be effected
2679 * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
2680 * The unmapped_list will contain all nodes that we have successfully logged
2681 * into at the Fibre Channel level. The mapped_list will contain all nodes
2682 * that are mapped FCP targets.
2685 * The bind list is a list of undiscovered (potentially non-existent) nodes
2686 * that we have saved binding information on. This information is used when
2687 * nodes transition from the unmapped to the mapped list.
2689 /* For UNUSED_NODE state, the node has just been allocated .
2690 * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
2691 * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
2692 * and put on the unmapped list. For ADISC processing, the node is taken off
2693 * the ADISC list and placed on either the mapped or unmapped list (depending
2694 * on its previous state). Once on the unmapped list, a PRLI is issued and the
2695 * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
2696 * changed to UNMAPPED_NODE. If the completion indicates a mapped
2697 * node, the node is taken off the unmapped list. The binding list is checked
2698 * for a valid binding, or a binding is automatically assigned. If binding
2699 * assignment is unsuccessful, the node is left on the unmapped list. If
2700 * binding assignment is successful, the associated binding list entry (if
2701 * any) is removed, and the node is placed on the mapped list.
2704 * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
2705 * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
2706 * expire, all effected nodes will receive a DEVICE_RM event.
2709 * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
2710 * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
2711 * check, additional nodes may be added or removed (via DEVICE_RM) to / from
2712 * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
2713 * we will first process the ADISC list. 32 entries are processed initially and
2714 * ADISC is initited for each one. Completions / Events for each node are
2715 * funnelled thru the state machine. As each node finishes ADISC processing, it
2716 * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
2717 * waiting, and the ADISC list count is identically 0, then we are done. For
2718 * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
2719 * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
2720 * list. 32 entries are processed initially and PLOGI is initited for each one.
2721 * Completions / Events for each node are funnelled thru the state machine. As
2722 * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
2723 * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
2724 * indentically 0, then we are done. We have now completed discovery / RSCN
2725 * handling. Upon completion, ALL nodes should be on either the mapped or
2729 static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
2730 (struct lpfc_vport *, struct lpfc_nodelist *, void *, uint32_t) = {
2731 /* Action routine Event Current State */
2732 lpfc_rcv_plogi_unused_node, /* RCV_PLOGI UNUSED_NODE */
2733 lpfc_rcv_els_unused_node, /* RCV_PRLI */
2734 lpfc_rcv_logo_unused_node, /* RCV_LOGO */
2735 lpfc_rcv_els_unused_node, /* RCV_ADISC */
2736 lpfc_rcv_els_unused_node, /* RCV_PDISC */
2737 lpfc_rcv_els_unused_node, /* RCV_PRLO */
2738 lpfc_disc_illegal, /* CMPL_PLOGI */
2739 lpfc_disc_illegal, /* CMPL_PRLI */
2740 lpfc_cmpl_logo_unused_node, /* CMPL_LOGO */
2741 lpfc_disc_illegal, /* CMPL_ADISC */
2742 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2743 lpfc_device_rm_unused_node, /* DEVICE_RM */
2744 lpfc_device_recov_unused_node, /* DEVICE_RECOVERY */
2746 lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */
2747 lpfc_rcv_prli_plogi_issue, /* RCV_PRLI */
2748 lpfc_rcv_logo_plogi_issue, /* RCV_LOGO */
2749 lpfc_rcv_els_plogi_issue, /* RCV_ADISC */
2750 lpfc_rcv_els_plogi_issue, /* RCV_PDISC */
2751 lpfc_rcv_els_plogi_issue, /* RCV_PRLO */
2752 lpfc_cmpl_plogi_plogi_issue, /* CMPL_PLOGI */
2753 lpfc_disc_illegal, /* CMPL_PRLI */
2754 lpfc_cmpl_logo_plogi_issue, /* CMPL_LOGO */
2755 lpfc_disc_illegal, /* CMPL_ADISC */
2756 lpfc_cmpl_reglogin_plogi_issue,/* CMPL_REG_LOGIN */
2757 lpfc_device_rm_plogi_issue, /* DEVICE_RM */
2758 lpfc_device_recov_plogi_issue, /* DEVICE_RECOVERY */
2760 lpfc_rcv_plogi_adisc_issue, /* RCV_PLOGI ADISC_ISSUE */
2761 lpfc_rcv_prli_adisc_issue, /* RCV_PRLI */
2762 lpfc_rcv_logo_adisc_issue, /* RCV_LOGO */
2763 lpfc_rcv_padisc_adisc_issue, /* RCV_ADISC */
2764 lpfc_rcv_padisc_adisc_issue, /* RCV_PDISC */
2765 lpfc_rcv_prlo_adisc_issue, /* RCV_PRLO */
2766 lpfc_disc_illegal, /* CMPL_PLOGI */
2767 lpfc_disc_illegal, /* CMPL_PRLI */
2768 lpfc_disc_illegal, /* CMPL_LOGO */
2769 lpfc_cmpl_adisc_adisc_issue, /* CMPL_ADISC */
2770 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2771 lpfc_device_rm_adisc_issue, /* DEVICE_RM */
2772 lpfc_device_recov_adisc_issue, /* DEVICE_RECOVERY */
2774 lpfc_rcv_plogi_reglogin_issue, /* RCV_PLOGI REG_LOGIN_ISSUE */
2775 lpfc_rcv_prli_reglogin_issue, /* RCV_PLOGI */
2776 lpfc_rcv_logo_reglogin_issue, /* RCV_LOGO */
2777 lpfc_rcv_padisc_reglogin_issue, /* RCV_ADISC */
2778 lpfc_rcv_padisc_reglogin_issue, /* RCV_PDISC */
2779 lpfc_rcv_prlo_reglogin_issue, /* RCV_PRLO */
2780 lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */
2781 lpfc_disc_illegal, /* CMPL_PRLI */
2782 lpfc_disc_illegal, /* CMPL_LOGO */
2783 lpfc_disc_illegal, /* CMPL_ADISC */
2784 lpfc_cmpl_reglogin_reglogin_issue,/* CMPL_REG_LOGIN */
2785 lpfc_device_rm_reglogin_issue, /* DEVICE_RM */
2786 lpfc_device_recov_reglogin_issue,/* DEVICE_RECOVERY */
2788 lpfc_rcv_plogi_prli_issue, /* RCV_PLOGI PRLI_ISSUE */
2789 lpfc_rcv_prli_prli_issue, /* RCV_PRLI */
2790 lpfc_rcv_logo_prli_issue, /* RCV_LOGO */
2791 lpfc_rcv_padisc_prli_issue, /* RCV_ADISC */
2792 lpfc_rcv_padisc_prli_issue, /* RCV_PDISC */
2793 lpfc_rcv_prlo_prli_issue, /* RCV_PRLO */
2794 lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */
2795 lpfc_cmpl_prli_prli_issue, /* CMPL_PRLI */
2796 lpfc_disc_illegal, /* CMPL_LOGO */
2797 lpfc_disc_illegal, /* CMPL_ADISC */
2798 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2799 lpfc_device_rm_prli_issue, /* DEVICE_RM */
2800 lpfc_device_recov_prli_issue, /* DEVICE_RECOVERY */
2802 lpfc_rcv_plogi_logo_issue, /* RCV_PLOGI LOGO_ISSUE */
2803 lpfc_rcv_prli_logo_issue, /* RCV_PRLI */
2804 lpfc_rcv_logo_logo_issue, /* RCV_LOGO */
2805 lpfc_rcv_padisc_logo_issue, /* RCV_ADISC */
2806 lpfc_rcv_padisc_logo_issue, /* RCV_PDISC */
2807 lpfc_rcv_prlo_logo_issue, /* RCV_PRLO */
2808 lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */
2809 lpfc_disc_illegal, /* CMPL_PRLI */
2810 lpfc_cmpl_logo_logo_issue, /* CMPL_LOGO */
2811 lpfc_disc_illegal, /* CMPL_ADISC */
2812 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2813 lpfc_device_rm_logo_issue, /* DEVICE_RM */
2814 lpfc_device_recov_logo_issue, /* DEVICE_RECOVERY */
2816 lpfc_rcv_plogi_unmap_node, /* RCV_PLOGI UNMAPPED_NODE */
2817 lpfc_rcv_prli_unmap_node, /* RCV_PRLI */
2818 lpfc_rcv_logo_unmap_node, /* RCV_LOGO */
2819 lpfc_rcv_padisc_unmap_node, /* RCV_ADISC */
2820 lpfc_rcv_padisc_unmap_node, /* RCV_PDISC */
2821 lpfc_rcv_prlo_unmap_node, /* RCV_PRLO */
2822 lpfc_disc_illegal, /* CMPL_PLOGI */
2823 lpfc_disc_illegal, /* CMPL_PRLI */
2824 lpfc_disc_illegal, /* CMPL_LOGO */
2825 lpfc_disc_illegal, /* CMPL_ADISC */
2826 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2827 lpfc_disc_illegal, /* DEVICE_RM */
2828 lpfc_device_recov_unmap_node, /* DEVICE_RECOVERY */
2830 lpfc_rcv_plogi_mapped_node, /* RCV_PLOGI MAPPED_NODE */
2831 lpfc_rcv_prli_mapped_node, /* RCV_PRLI */
2832 lpfc_rcv_logo_mapped_node, /* RCV_LOGO */
2833 lpfc_rcv_padisc_mapped_node, /* RCV_ADISC */
2834 lpfc_rcv_padisc_mapped_node, /* RCV_PDISC */
2835 lpfc_rcv_prlo_mapped_node, /* RCV_PRLO */
2836 lpfc_disc_illegal, /* CMPL_PLOGI */
2837 lpfc_disc_illegal, /* CMPL_PRLI */
2838 lpfc_disc_illegal, /* CMPL_LOGO */
2839 lpfc_disc_illegal, /* CMPL_ADISC */
2840 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
2841 lpfc_disc_illegal, /* DEVICE_RM */
2842 lpfc_device_recov_mapped_node, /* DEVICE_RECOVERY */
2844 lpfc_rcv_plogi_npr_node, /* RCV_PLOGI NPR_NODE */
2845 lpfc_rcv_prli_npr_node, /* RCV_PRLI */
2846 lpfc_rcv_logo_npr_node, /* RCV_LOGO */
2847 lpfc_rcv_padisc_npr_node, /* RCV_ADISC */
2848 lpfc_rcv_padisc_npr_node, /* RCV_PDISC */
2849 lpfc_rcv_prlo_npr_node, /* RCV_PRLO */
2850 lpfc_cmpl_plogi_npr_node, /* CMPL_PLOGI */
2851 lpfc_cmpl_prli_npr_node, /* CMPL_PRLI */
2852 lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */
2853 lpfc_cmpl_adisc_npr_node, /* CMPL_ADISC */
2854 lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */
2855 lpfc_device_rm_npr_node, /* DEVICE_RM */
2856 lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */
2860 lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2861 void *arg, uint32_t evt)
2863 uint32_t cur_state, rc;
2864 uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *,
2866 uint32_t got_ndlp = 0;
2868 if (lpfc_nlp_get(ndlp))
2871 cur_state = ndlp->nlp_state;
2873 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
2874 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2875 "0211 DSM in event x%x on NPort x%x in "
2876 "state %d Data: x%x x%x\n",
2877 evt, ndlp->nlp_DID, cur_state,
2878 ndlp->nlp_flag, ndlp->nlp_fc4_type);
2880 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2881 "DSM in: evt:%d ste:%d did:x%x",
2882 evt, cur_state, ndlp->nlp_DID);
2884 func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt];
2885 rc = (func) (vport, ndlp, arg, evt);
2887 /* DSM out state <rc> on NPort <nlp_DID> */
2889 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2890 "0212 DSM out state %d on NPort x%x Data: x%x\n",
2891 rc, ndlp->nlp_DID, ndlp->nlp_flag);
2893 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2894 "DSM out: ste:%d did:x%x flg:x%x",
2895 rc, ndlp->nlp_DID, ndlp->nlp_flag);
2896 /* Decrement the ndlp reference count held for this function */
2899 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2900 "0213 DSM out state %d on NPort free\n", rc);
2902 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2903 "DSM out: ste:%d did:x%x flg:x%x",