1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
9 * This program is free software; you can redistribute it and/or *
10 * modify it under the terms of version 2 of the GNU General *
11 * Public License as published by the Free Software Foundation. *
12 * This program is distributed in the hope that it will be useful. *
13 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
14 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
15 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
16 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
17 * TO BE LEGALLY INVALID. See the GNU General Public License for *
18 * more details, a copy of which can be found in the file COPYING *
19 * included with this package. *
20 *******************************************************************/
22 #include <linux/blkdev.h>
23 #include <linux/pci.h>
24 #include <linux/interrupt.h>
26 #include <scsi/scsi.h>
27 #include <scsi/scsi_device.h>
28 #include <scsi/scsi_host.h>
29 #include <scsi/scsi_transport_fc.h>
33 #include "lpfc_disc.h"
34 #include "lpfc_scsi.h"
36 #include "lpfc_logmsg.h"
37 #include "lpfc_crtn.h"
40 /* Called to verify a rcv'ed ADISC was intended for us. */
42 lpfc_check_adisc(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
43 struct lpfc_name * nn, struct lpfc_name * pn)
45 /* Compare the ADISC rsp WWNN / WWPN matches our internal node
46 * table entry for that node.
48 if (memcmp(nn, &ndlp->nlp_nodename, sizeof (struct lpfc_name)) != 0)
51 if (memcmp(pn, &ndlp->nlp_portname, sizeof (struct lpfc_name)) != 0)
54 /* we match, return success */
59 lpfc_check_sparm(struct lpfc_hba * phba,
60 struct lpfc_nodelist * ndlp, struct serv_parm * sp,
63 volatile struct serv_parm *hsp = &phba->fc_sparam;
64 uint16_t hsp_value, ssp_value = 0;
67 * The receive data field size and buffer-to-buffer receive data field
68 * size entries are 16 bits but are represented as two 8-bit fields in
69 * the driver data structure to account for rsvd bits and other control
70 * bits. Reconstruct and compare the fields as a 16-bit values before
71 * correcting the byte values.
73 if (sp->cls1.classValid) {
74 hsp_value = (hsp->cls1.rcvDataSizeMsb << 8) |
75 hsp->cls1.rcvDataSizeLsb;
76 ssp_value = (sp->cls1.rcvDataSizeMsb << 8) |
77 sp->cls1.rcvDataSizeLsb;
78 if (ssp_value > hsp_value) {
79 sp->cls1.rcvDataSizeLsb = hsp->cls1.rcvDataSizeLsb;
80 sp->cls1.rcvDataSizeMsb = hsp->cls1.rcvDataSizeMsb;
82 } else if (class == CLASS1) {
86 if (sp->cls2.classValid) {
87 hsp_value = (hsp->cls2.rcvDataSizeMsb << 8) |
88 hsp->cls2.rcvDataSizeLsb;
89 ssp_value = (sp->cls2.rcvDataSizeMsb << 8) |
90 sp->cls2.rcvDataSizeLsb;
91 if (ssp_value > hsp_value) {
92 sp->cls2.rcvDataSizeLsb = hsp->cls2.rcvDataSizeLsb;
93 sp->cls2.rcvDataSizeMsb = hsp->cls2.rcvDataSizeMsb;
95 } else if (class == CLASS2) {
99 if (sp->cls3.classValid) {
100 hsp_value = (hsp->cls3.rcvDataSizeMsb << 8) |
101 hsp->cls3.rcvDataSizeLsb;
102 ssp_value = (sp->cls3.rcvDataSizeMsb << 8) |
103 sp->cls3.rcvDataSizeLsb;
104 if (ssp_value > hsp_value) {
105 sp->cls3.rcvDataSizeLsb = hsp->cls3.rcvDataSizeLsb;
106 sp->cls3.rcvDataSizeMsb = hsp->cls3.rcvDataSizeMsb;
108 } else if (class == CLASS3) {
113 * Preserve the upper four bits of the MSB from the PLOGI response.
114 * These bits contain the Buffer-to-Buffer State Change Number
115 * from the target and need to be passed to the FW.
117 hsp_value = (hsp->cmn.bbRcvSizeMsb << 8) | hsp->cmn.bbRcvSizeLsb;
118 ssp_value = (sp->cmn.bbRcvSizeMsb << 8) | sp->cmn.bbRcvSizeLsb;
119 if (ssp_value > hsp_value) {
120 sp->cmn.bbRcvSizeLsb = hsp->cmn.bbRcvSizeLsb;
121 sp->cmn.bbRcvSizeMsb = (sp->cmn.bbRcvSizeMsb & 0xF0) |
122 (hsp->cmn.bbRcvSizeMsb & 0x0F);
125 memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof (struct lpfc_name));
126 memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name));
131 lpfc_check_elscmpl_iocb(struct lpfc_hba * phba,
132 struct lpfc_iocbq *cmdiocb,
133 struct lpfc_iocbq *rspiocb)
135 struct lpfc_dmabuf *pcmd, *prsp;
140 irsp = &rspiocb->iocb;
141 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
143 /* For lpfc_els_abort, context2 could be zero'ed to delay
144 * freeing associated memory till after ABTS completes.
147 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf,
150 lp = (uint32_t *) prsp->virt;
151 ptr = (void *)((uint8_t *)lp + sizeof(uint32_t));
154 /* Force ulpStatus error since we are returning NULL ptr */
155 if (!(irsp->ulpStatus)) {
156 irsp->ulpStatus = IOSTAT_LOCAL_REJECT;
157 irsp->un.ulpWord[4] = IOERR_SLI_ABORTED;
166 * Free resources / clean up outstanding I/Os
167 * associated with a LPFC_NODELIST entry. This
168 * routine effectively results in a "software abort".
171 lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
173 LIST_HEAD(completions);
174 struct lpfc_sli *psli;
175 struct lpfc_sli_ring *pring;
176 struct lpfc_iocbq *iocb, *next_iocb;
179 /* Abort outstanding I/O on NPort <nlp_DID> */
180 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
181 "%d:0205 Abort outstanding I/O on NPort x%x "
182 "Data: x%x x%x x%x\n",
183 phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag,
184 ndlp->nlp_state, ndlp->nlp_rpi);
187 pring = &psli->ring[LPFC_ELS_RING];
189 /* First check the txq */
190 spin_lock_irq(phba->host->host_lock);
191 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
192 /* Check to see if iocb matches the nport we are looking
194 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp)) {
195 /* It matches, so deque and call compl with an
197 list_move_tail(&iocb->list, &completions);
202 /* Next check the txcmplq */
203 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
204 /* Check to see if iocb matches the nport we are looking
206 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp))
207 lpfc_sli_issue_abort_iotag(phba, pring, iocb);
209 spin_unlock_irq(phba->host->host_lock);
211 while (!list_empty(&completions)) {
212 iocb = list_get_first(&completions, struct lpfc_iocbq, list);
214 list_del(&iocb->list);
216 if (iocb->iocb_cmpl) {
217 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
218 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
219 (iocb->iocb_cmpl) (phba, iocb, iocb);
221 lpfc_sli_release_iocbq(phba, iocb);
224 /* If we are delaying issuing an ELS command, cancel it */
225 if (ndlp->nlp_flag & NLP_DELAY_TMO)
226 lpfc_cancel_retry_delay_tmo(phba, ndlp);
231 lpfc_rcv_plogi(struct lpfc_hba * phba,
232 struct lpfc_nodelist * ndlp,
233 struct lpfc_iocbq *cmdiocb)
235 struct lpfc_dmabuf *pcmd;
238 struct serv_parm *sp;
243 memset(&stat, 0, sizeof (struct ls_rjt));
244 if (phba->hba_state <= LPFC_FLOGI) {
245 /* Before responding to PLOGI, check for pt2pt mode.
246 * If we are pt2pt, with an outstanding FLOGI, abort
247 * the FLOGI and resend it first.
249 if (phba->fc_flag & FC_PT2PT) {
250 lpfc_els_abort_flogi(phba);
251 if (!(phba->fc_flag & FC_PT2PT_PLOGI)) {
252 /* If the other side is supposed to initiate
253 * the PLOGI anyway, just ACC it now and
254 * move on with discovery.
256 phba->fc_edtov = FF_DEF_EDTOV;
257 phba->fc_ratov = FF_DEF_RATOV;
258 /* Start discovery - this should just do
260 lpfc_disc_start(phba);
262 lpfc_initial_flogi(phba);
265 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
266 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
267 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb,
272 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
273 lp = (uint32_t *) pcmd->virt;
274 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
275 if ((lpfc_check_sparm(phba, ndlp, sp, CLASS3) == 0)) {
276 /* Reject this request because invalid parameters */
277 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
278 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
279 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
282 icmd = &cmdiocb->iocb;
284 /* PLOGI chkparm OK */
285 lpfc_printf_log(phba,
288 "%d:0114 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
290 ndlp->nlp_DID, ndlp->nlp_state, ndlp->nlp_flag,
293 if ((phba->cfg_fcp_class == 2) &&
294 (sp->cls2.classValid)) {
295 ndlp->nlp_fcp_info |= CLASS2;
297 ndlp->nlp_fcp_info |= CLASS3;
299 ndlp->nlp_class_sup = 0;
300 if (sp->cls1.classValid)
301 ndlp->nlp_class_sup |= FC_COS_CLASS1;
302 if (sp->cls2.classValid)
303 ndlp->nlp_class_sup |= FC_COS_CLASS2;
304 if (sp->cls3.classValid)
305 ndlp->nlp_class_sup |= FC_COS_CLASS3;
306 if (sp->cls4.classValid)
307 ndlp->nlp_class_sup |= FC_COS_CLASS4;
309 ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb;
311 /* no need to reg_login if we are already in one of these states */
312 switch (ndlp->nlp_state) {
313 case NLP_STE_NPR_NODE:
314 if (!(ndlp->nlp_flag & NLP_NPR_ADISC))
316 case NLP_STE_REG_LOGIN_ISSUE:
317 case NLP_STE_PRLI_ISSUE:
318 case NLP_STE_UNMAPPED_NODE:
319 case NLP_STE_MAPPED_NODE:
320 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, 0);
324 if ((phba->fc_flag & FC_PT2PT)
325 && !(phba->fc_flag & FC_PT2PT_PLOGI)) {
326 /* rcv'ed PLOGI decides what our NPortId will be */
327 phba->fc_myDID = icmd->un.rcvels.parmRo;
328 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
331 lpfc_config_link(phba, mbox);
332 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
333 rc = lpfc_sli_issue_mbox
334 (phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));
335 if (rc == MBX_NOT_FINISHED) {
336 mempool_free( mbox, phba->mbox_mem_pool);
340 lpfc_can_disctmo(phba);
342 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
346 if (lpfc_reg_login(phba, icmd->un.rcvels.remoteID,
347 (uint8_t *) sp, mbox, 0)) {
348 mempool_free( mbox, phba->mbox_mem_pool);
352 /* ACC PLOGI rsp command needs to execute first,
353 * queue this mbox command to be processed later.
355 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
357 * mbox->context2 = lpfc_nlp_get(ndlp) deferred until mailbox
358 * command issued in lpfc_cmpl_els_acc().
360 ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI);
363 * If there is an outstanding PLOGI issued, abort it before
364 * sending ACC rsp for received PLOGI. If pending plogi
365 * is not canceled here, the plogi will be rejected by
366 * remote port and will be retried. On a configuration with
367 * single discovery thread, this will cause a huge delay in
368 * discovery. Also this will cause multiple state machines
369 * running in parallel for this node.
371 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) {
372 /* software abort outstanding PLOGI */
373 lpfc_els_abort(phba, ndlp);
376 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0);
380 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
381 stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE;
382 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
387 lpfc_rcv_padisc(struct lpfc_hba * phba,
388 struct lpfc_nodelist * ndlp,
389 struct lpfc_iocbq *cmdiocb)
391 struct lpfc_dmabuf *pcmd;
392 struct serv_parm *sp;
393 struct lpfc_name *pnn, *ppn;
400 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
401 lp = (uint32_t *) pcmd->virt;
404 if (cmd == ELS_CMD_ADISC) {
406 pnn = (struct lpfc_name *) & ap->nodeName;
407 ppn = (struct lpfc_name *) & ap->portName;
409 sp = (struct serv_parm *) lp;
410 pnn = (struct lpfc_name *) & sp->nodeName;
411 ppn = (struct lpfc_name *) & sp->portName;
414 icmd = &cmdiocb->iocb;
415 if ((icmd->ulpStatus == 0) &&
416 (lpfc_check_adisc(phba, ndlp, pnn, ppn))) {
417 if (cmd == ELS_CMD_ADISC) {
418 lpfc_els_rsp_adisc_acc(phba, cmdiocb, ndlp);
420 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp,
425 /* Reject this request because invalid parameters */
426 stat.un.b.lsRjtRsvd0 = 0;
427 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
428 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
429 stat.un.b.vendorUnique = 0;
430 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
433 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ);
435 spin_lock_irq(phba->host->host_lock);
436 ndlp->nlp_flag |= NLP_DELAY_TMO;
437 spin_unlock_irq(phba->host->host_lock);
438 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
439 ndlp->nlp_prev_state = ndlp->nlp_state;
440 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
445 lpfc_rcv_logo(struct lpfc_hba * phba,
446 struct lpfc_nodelist * ndlp,
447 struct lpfc_iocbq *cmdiocb,
450 /* Put ndlp on NPR list with 1 sec timeout for plogi, ACC logo */
451 /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary
452 * PLOGIs during LOGO storms from a device.
454 ndlp->nlp_flag |= NLP_LOGO_ACC;
455 if (els_cmd == ELS_CMD_PRLO)
456 lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
458 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
460 if (!(ndlp->nlp_type & NLP_FABRIC) ||
461 (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
462 /* Only try to re-login if this is NOT a Fabric Node */
463 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
464 spin_lock_irq(phba->host->host_lock);
465 ndlp->nlp_flag |= NLP_DELAY_TMO;
466 spin_unlock_irq(phba->host->host_lock);
468 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
469 ndlp->nlp_prev_state = ndlp->nlp_state;
470 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
472 ndlp->nlp_prev_state = ndlp->nlp_state;
473 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
476 spin_lock_irq(phba->host->host_lock);
477 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
478 spin_unlock_irq(phba->host->host_lock);
479 /* The driver has to wait until the ACC completes before it continues
480 * processing the LOGO. The action will resume in
481 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
482 * unreg_login, the driver waits so the ACC does not get aborted.
488 lpfc_rcv_prli(struct lpfc_hba * phba,
489 struct lpfc_nodelist * ndlp,
490 struct lpfc_iocbq *cmdiocb)
492 struct lpfc_dmabuf *pcmd;
495 struct fc_rport *rport = ndlp->rport;
498 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
499 lp = (uint32_t *) pcmd->virt;
500 npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t));
502 ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
503 ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
504 if ((npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
505 (npr->prliType == PRLI_FCP_TYPE)) {
506 if (npr->initiatorFunc)
507 ndlp->nlp_type |= NLP_FCP_INITIATOR;
509 ndlp->nlp_type |= NLP_FCP_TARGET;
511 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
514 /* We need to update the rport role values */
515 roles = FC_RPORT_ROLE_UNKNOWN;
516 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
517 roles |= FC_RPORT_ROLE_FCP_INITIATOR;
518 if (ndlp->nlp_type & NLP_FCP_TARGET)
519 roles |= FC_RPORT_ROLE_FCP_TARGET;
520 fc_remote_port_rolechg(rport, roles);
525 lpfc_disc_set_adisc(struct lpfc_hba * phba,
526 struct lpfc_nodelist * ndlp)
528 /* Check config parameter use-adisc or FCP-2 */
529 if ((phba->cfg_use_adisc == 0) &&
530 !(phba->fc_flag & FC_RSCN_MODE)) {
531 if (!(ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE))
534 spin_lock_irq(phba->host->host_lock);
535 ndlp->nlp_flag |= NLP_NPR_ADISC;
536 spin_unlock_irq(phba->host->host_lock);
541 lpfc_disc_illegal(struct lpfc_hba * phba,
542 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
544 lpfc_printf_log(phba,
547 "%d:0253 Illegal State Transition: node x%x event x%x, "
548 "state x%x Data: x%x x%x\n",
550 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
552 return ndlp->nlp_state;
555 /* Start of Discovery State Machine routines */
558 lpfc_rcv_plogi_unused_node(struct lpfc_hba * phba,
559 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
561 struct lpfc_iocbq *cmdiocb;
563 cmdiocb = (struct lpfc_iocbq *) arg;
565 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
566 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
567 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
568 return ndlp->nlp_state;
570 lpfc_drop_node(phba, ndlp);
571 return NLP_STE_FREED_NODE;
575 lpfc_rcv_els_unused_node(struct lpfc_hba * phba,
576 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
578 lpfc_issue_els_logo(phba, ndlp, 0);
579 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
580 return ndlp->nlp_state;
584 lpfc_rcv_logo_unused_node(struct lpfc_hba * phba,
585 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
587 struct lpfc_iocbq *cmdiocb;
589 cmdiocb = (struct lpfc_iocbq *) arg;
591 spin_lock_irq(phba->host->host_lock);
592 ndlp->nlp_flag |= NLP_LOGO_ACC;
593 spin_unlock_irq(phba->host->host_lock);
594 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
595 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
597 return ndlp->nlp_state;
601 lpfc_cmpl_logo_unused_node(struct lpfc_hba * phba,
602 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
604 lpfc_drop_node(phba, ndlp);
605 return NLP_STE_FREED_NODE;
609 lpfc_device_rm_unused_node(struct lpfc_hba * phba,
610 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
612 lpfc_drop_node(phba, ndlp);
613 return NLP_STE_FREED_NODE;
617 lpfc_rcv_plogi_plogi_issue(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
618 void *arg, uint32_t evt)
620 struct lpfc_iocbq *cmdiocb = arg;
621 struct lpfc_dmabuf *pcmd;
622 struct serv_parm *sp;
627 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
628 lp = (uint32_t *) pcmd->virt;
629 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
631 memset(&stat, 0, sizeof (struct ls_rjt));
633 /* For a PLOGI, we only accept if our portname is less
634 * than the remote portname.
636 phba->fc_stat.elsLogiCol++;
637 port_cmp = memcmp(&phba->fc_portname, &sp->portName,
638 sizeof (struct lpfc_name));
641 /* Reject this request because the remote node will accept
643 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
644 stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS;
645 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
647 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
648 } /* if our portname was less */
650 return ndlp->nlp_state;
654 lpfc_rcv_logo_plogi_issue(struct lpfc_hba * phba,
655 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
657 struct lpfc_iocbq *cmdiocb;
659 cmdiocb = (struct lpfc_iocbq *) arg;
661 /* software abort outstanding PLOGI */
662 lpfc_els_abort(phba, ndlp);
664 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
665 return ndlp->nlp_state;
669 lpfc_rcv_els_plogi_issue(struct lpfc_hba * phba,
670 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
672 struct lpfc_iocbq *cmdiocb;
674 cmdiocb = (struct lpfc_iocbq *) arg;
676 /* software abort outstanding PLOGI */
677 lpfc_els_abort(phba, ndlp);
679 if (evt == NLP_EVT_RCV_LOGO) {
680 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
682 lpfc_issue_els_logo(phba, ndlp, 0);
685 /* Put ndlp in npr list set plogi timer for 1 sec */
686 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
687 spin_lock_irq(phba->host->host_lock);
688 ndlp->nlp_flag |= NLP_DELAY_TMO;
689 spin_unlock_irq(phba->host->host_lock);
690 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
691 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
692 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
694 return ndlp->nlp_state;
698 lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
699 struct lpfc_nodelist * ndlp, void *arg,
702 struct lpfc_iocbq *cmdiocb, *rspiocb;
703 struct lpfc_dmabuf *pcmd, *prsp, *mp;
706 struct serv_parm *sp;
709 cmdiocb = (struct lpfc_iocbq *) arg;
710 rspiocb = cmdiocb->context_un.rsp_iocb;
712 if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
713 /* Recovery from PLOGI collision logic */
714 return ndlp->nlp_state;
717 irsp = &rspiocb->iocb;
722 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
724 prsp = list_get_first(&pcmd->list,
727 lp = (uint32_t *) prsp->virt;
729 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
730 if (!lpfc_check_sparm(phba, ndlp, sp, CLASS3))
733 /* PLOGI chkparm OK */
734 lpfc_printf_log(phba,
737 "%d:0121 PLOGI chkparm OK "
738 "Data: x%x x%x x%x x%x\n",
740 ndlp->nlp_DID, ndlp->nlp_state,
741 ndlp->nlp_flag, ndlp->nlp_rpi);
743 if ((phba->cfg_fcp_class == 2) &&
744 (sp->cls2.classValid)) {
745 ndlp->nlp_fcp_info |= CLASS2;
747 ndlp->nlp_fcp_info |= CLASS3;
749 ndlp->nlp_class_sup = 0;
750 if (sp->cls1.classValid)
751 ndlp->nlp_class_sup |= FC_COS_CLASS1;
752 if (sp->cls2.classValid)
753 ndlp->nlp_class_sup |= FC_COS_CLASS2;
754 if (sp->cls3.classValid)
755 ndlp->nlp_class_sup |= FC_COS_CLASS3;
756 if (sp->cls4.classValid)
757 ndlp->nlp_class_sup |= FC_COS_CLASS4;
759 ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) |
760 sp->cmn.bbRcvSizeLsb;
762 if (!(mbox = mempool_alloc(phba->mbox_mem_pool,
766 lpfc_unreg_rpi(phba, ndlp);
767 if (lpfc_reg_login(phba, irsp->un.elsreq64.remoteID, (uint8_t *) sp,
769 switch (ndlp->nlp_DID) {
771 mbox->mbox_cmpl = lpfc_mbx_cmpl_ns_reg_login;
774 mbox->mbox_cmpl = lpfc_mbx_cmpl_fdmi_reg_login;
777 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
779 mbox->context2 = lpfc_nlp_get(ndlp);
780 if (lpfc_sli_issue_mbox(phba, mbox,
781 (MBX_NOWAIT | MBX_STOP_IOCB))
782 != MBX_NOT_FINISHED) {
783 lpfc_nlp_set_state(phba, ndlp, NLP_STE_REG_LOGIN_ISSUE);
784 return ndlp->nlp_state;
787 mp = (struct lpfc_dmabuf *)mbox->context1;
788 lpfc_mbuf_free(phba, mp->virt, mp->phys);
790 mempool_free(mbox, phba->mbox_mem_pool);
792 mempool_free(mbox, phba->mbox_mem_pool);
797 /* Free this node since the driver cannot login or has the wrong
799 lpfc_drop_node(phba, ndlp);
800 return NLP_STE_FREED_NODE;
804 lpfc_device_rm_plogi_issue(struct lpfc_hba * phba,
805 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
807 if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
808 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
809 return ndlp->nlp_state;
812 /* software abort outstanding PLOGI */
813 lpfc_els_abort(phba, ndlp);
815 lpfc_drop_node(phba, ndlp);
816 return NLP_STE_FREED_NODE;
821 lpfc_device_recov_plogi_issue(struct lpfc_hba * phba,
822 struct lpfc_nodelist * ndlp, void *arg,
825 /* software abort outstanding PLOGI */
826 lpfc_els_abort(phba, ndlp);
828 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
829 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
830 spin_lock_irq(phba->host->host_lock);
831 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
832 spin_unlock_irq(phba->host->host_lock);
834 return ndlp->nlp_state;
838 lpfc_rcv_plogi_adisc_issue(struct lpfc_hba * phba,
839 struct lpfc_nodelist * ndlp, void *arg,
842 struct lpfc_iocbq *cmdiocb;
844 /* software abort outstanding ADISC */
845 lpfc_els_abort(phba, ndlp);
847 cmdiocb = (struct lpfc_iocbq *) arg;
849 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
850 return ndlp->nlp_state;
852 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
853 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
854 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
856 return ndlp->nlp_state;
860 lpfc_rcv_prli_adisc_issue(struct lpfc_hba * phba,
861 struct lpfc_nodelist * ndlp, void *arg,
864 struct lpfc_iocbq *cmdiocb;
866 cmdiocb = (struct lpfc_iocbq *) arg;
868 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
869 return ndlp->nlp_state;
873 lpfc_rcv_logo_adisc_issue(struct lpfc_hba * phba,
874 struct lpfc_nodelist * ndlp, void *arg,
877 struct lpfc_iocbq *cmdiocb;
879 cmdiocb = (struct lpfc_iocbq *) arg;
881 /* software abort outstanding ADISC */
882 lpfc_els_abort(phba, ndlp);
884 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
885 return ndlp->nlp_state;
889 lpfc_rcv_padisc_adisc_issue(struct lpfc_hba * phba,
890 struct lpfc_nodelist * ndlp, void *arg,
893 struct lpfc_iocbq *cmdiocb;
895 cmdiocb = (struct lpfc_iocbq *) arg;
897 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
898 return ndlp->nlp_state;
902 lpfc_rcv_prlo_adisc_issue(struct lpfc_hba * phba,
903 struct lpfc_nodelist * ndlp, void *arg,
906 struct lpfc_iocbq *cmdiocb;
908 cmdiocb = (struct lpfc_iocbq *) arg;
910 /* Treat like rcv logo */
911 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_PRLO);
912 return ndlp->nlp_state;
916 lpfc_cmpl_adisc_adisc_issue(struct lpfc_hba * phba,
917 struct lpfc_nodelist * ndlp, void *arg,
920 struct lpfc_iocbq *cmdiocb, *rspiocb;
924 cmdiocb = (struct lpfc_iocbq *) arg;
925 rspiocb = cmdiocb->context_un.rsp_iocb;
927 ap = (ADISC *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
928 irsp = &rspiocb->iocb;
930 if ((irsp->ulpStatus) ||
931 (!lpfc_check_adisc(phba, ndlp, &ap->nodeName, &ap->portName))) {
933 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ);
934 spin_lock_irq(phba->host->host_lock);
935 ndlp->nlp_flag |= NLP_DELAY_TMO;
936 spin_unlock_irq(phba->host->host_lock);
937 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
939 memset(&ndlp->nlp_nodename, 0, sizeof (struct lpfc_name));
940 memset(&ndlp->nlp_portname, 0, sizeof (struct lpfc_name));
942 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
943 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
944 lpfc_unreg_rpi(phba, ndlp);
945 return ndlp->nlp_state;
948 if (ndlp->nlp_type & NLP_FCP_TARGET) {
949 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
950 lpfc_nlp_set_state(phba, ndlp, NLP_STE_MAPPED_NODE);
952 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
953 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
955 return ndlp->nlp_state;
959 lpfc_device_rm_adisc_issue(struct lpfc_hba * phba,
960 struct lpfc_nodelist * ndlp, void *arg,
963 if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
964 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
965 return ndlp->nlp_state;
968 /* software abort outstanding ADISC */
969 lpfc_els_abort(phba, ndlp);
971 lpfc_drop_node(phba, ndlp);
972 return NLP_STE_FREED_NODE;
977 lpfc_device_recov_adisc_issue(struct lpfc_hba * phba,
978 struct lpfc_nodelist * ndlp, void *arg,
981 /* software abort outstanding ADISC */
982 lpfc_els_abort(phba, ndlp);
984 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
985 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
986 spin_lock_irq(phba->host->host_lock);
987 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
988 ndlp->nlp_flag |= NLP_NPR_ADISC;
989 spin_unlock_irq(phba->host->host_lock);
991 return ndlp->nlp_state;
995 lpfc_rcv_plogi_reglogin_issue(struct lpfc_hba * phba,
996 struct lpfc_nodelist * ndlp, void *arg,
999 struct lpfc_iocbq *cmdiocb;
1001 cmdiocb = (struct lpfc_iocbq *) arg;
1003 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
1004 return ndlp->nlp_state;
1008 lpfc_rcv_prli_reglogin_issue(struct lpfc_hba * phba,
1009 struct lpfc_nodelist * ndlp, void *arg,
1012 struct lpfc_iocbq *cmdiocb;
1014 cmdiocb = (struct lpfc_iocbq *) arg;
1016 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
1017 return ndlp->nlp_state;
1021 lpfc_rcv_logo_reglogin_issue(struct lpfc_hba * phba,
1022 struct lpfc_nodelist * ndlp, void *arg,
1025 struct lpfc_iocbq *cmdiocb;
1027 LPFC_MBOXQ_t *nextmb;
1028 struct lpfc_dmabuf *mp;
1030 cmdiocb = (struct lpfc_iocbq *) arg;
1032 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1033 if ((mb = phba->sli.mbox_active)) {
1034 if ((mb->mb.mbxCommand == MBX_REG_LOGIN64) &&
1035 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1036 mb->context2 = NULL;
1037 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1041 spin_lock_irq(phba->host->host_lock);
1042 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
1043 if ((mb->mb.mbxCommand == MBX_REG_LOGIN64) &&
1044 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1045 mp = (struct lpfc_dmabuf *) (mb->context1);
1047 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1050 list_del(&mb->list);
1051 mempool_free(mb, phba->mbox_mem_pool);
1054 spin_unlock_irq(phba->host->host_lock);
1056 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1057 return ndlp->nlp_state;
1061 lpfc_rcv_padisc_reglogin_issue(struct lpfc_hba * phba,
1062 struct lpfc_nodelist * ndlp, void *arg,
1065 struct lpfc_iocbq *cmdiocb;
1067 cmdiocb = (struct lpfc_iocbq *) arg;
1069 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
1070 return ndlp->nlp_state;
1074 lpfc_rcv_prlo_reglogin_issue(struct lpfc_hba * phba,
1075 struct lpfc_nodelist * ndlp, void *arg,
1078 struct lpfc_iocbq *cmdiocb;
1080 cmdiocb = (struct lpfc_iocbq *) arg;
1081 lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
1082 return ndlp->nlp_state;
1086 lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
1087 struct lpfc_nodelist * ndlp,
1088 void *arg, uint32_t evt)
1094 pmb = (LPFC_MBOXQ_t *) arg;
1096 did = mb->un.varWords[1];
1097 if (mb->mbxStatus) {
1098 /* RegLogin failed */
1099 lpfc_printf_log(phba,
1102 "%d:0246 RegLogin failed Data: x%x x%x x%x\n",
1104 did, mb->mbxStatus, phba->hba_state);
1107 * If RegLogin failed due to lack of HBA resources do not
1110 if (mb->mbxStatus == MBXERR_RPI_FULL) {
1111 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
1112 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
1113 return ndlp->nlp_state;
1116 /* Put ndlp in npr list set plogi timer for 1 sec */
1117 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
1118 spin_lock_irq(phba->host->host_lock);
1119 ndlp->nlp_flag |= NLP_DELAY_TMO;
1120 spin_unlock_irq(phba->host->host_lock);
1121 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1123 lpfc_issue_els_logo(phba, ndlp, 0);
1124 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1125 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1126 return ndlp->nlp_state;
1129 ndlp->nlp_rpi = mb->un.varWords[0];
1131 /* Only if we are not a fabric nport do we issue PRLI */
1132 if (!(ndlp->nlp_type & NLP_FABRIC)) {
1133 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1134 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PRLI_ISSUE);
1135 lpfc_issue_els_prli(phba, ndlp, 0);
1137 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1138 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1140 return ndlp->nlp_state;
1144 lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba,
1145 struct lpfc_nodelist * ndlp, void *arg,
1148 if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1149 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1150 return ndlp->nlp_state;
1153 lpfc_drop_node(phba, ndlp);
1154 return NLP_STE_FREED_NODE;
1159 lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba,
1160 struct lpfc_nodelist * ndlp, void *arg,
1163 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1164 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1165 spin_lock_irq(phba->host->host_lock);
1166 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1167 spin_unlock_irq(phba->host->host_lock);
1168 return ndlp->nlp_state;
1172 lpfc_rcv_plogi_prli_issue(struct lpfc_hba * phba,
1173 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1175 struct lpfc_iocbq *cmdiocb;
1177 cmdiocb = (struct lpfc_iocbq *) arg;
1179 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
1180 return ndlp->nlp_state;
1184 lpfc_rcv_prli_prli_issue(struct lpfc_hba * phba,
1185 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1187 struct lpfc_iocbq *cmdiocb;
1189 cmdiocb = (struct lpfc_iocbq *) arg;
1191 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
1192 return ndlp->nlp_state;
1196 lpfc_rcv_logo_prli_issue(struct lpfc_hba * phba,
1197 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1199 struct lpfc_iocbq *cmdiocb;
1201 cmdiocb = (struct lpfc_iocbq *) arg;
1203 /* Software abort outstanding PRLI before sending acc */
1204 lpfc_els_abort(phba, ndlp);
1206 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1207 return ndlp->nlp_state;
1211 lpfc_rcv_padisc_prli_issue(struct lpfc_hba * phba,
1212 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1214 struct lpfc_iocbq *cmdiocb;
1216 cmdiocb = (struct lpfc_iocbq *) arg;
1218 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
1219 return ndlp->nlp_state;
1222 /* This routine is envoked when we rcv a PRLO request from a nport
1223 * we are logged into. We should send back a PRLO rsp setting the
1225 * NEXT STATE = PRLI_ISSUE
1228 lpfc_rcv_prlo_prli_issue(struct lpfc_hba * phba,
1229 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1231 struct lpfc_iocbq *cmdiocb;
1233 cmdiocb = (struct lpfc_iocbq *) arg;
1234 lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
1235 return ndlp->nlp_state;
1239 lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
1240 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1242 struct lpfc_iocbq *cmdiocb, *rspiocb;
1246 cmdiocb = (struct lpfc_iocbq *) arg;
1247 rspiocb = cmdiocb->context_un.rsp_iocb;
1248 npr = (PRLI *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
1250 irsp = &rspiocb->iocb;
1251 if (irsp->ulpStatus) {
1252 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
1253 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1254 return ndlp->nlp_state;
1257 /* Check out PRLI rsp */
1258 ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
1259 ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
1260 if ((npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
1261 (npr->prliType == PRLI_FCP_TYPE)) {
1262 if (npr->initiatorFunc)
1263 ndlp->nlp_type |= NLP_FCP_INITIATOR;
1264 if (npr->targetFunc)
1265 ndlp->nlp_type |= NLP_FCP_TARGET;
1267 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
1270 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
1271 lpfc_nlp_set_state(phba, ndlp, NLP_STE_MAPPED_NODE);
1272 return ndlp->nlp_state;
1275 /*! lpfc_device_rm_prli_issue
1286 * This routine is envoked when we a request to remove a nport we are in the
1287 * process of PRLIing. We should software abort outstanding prli, unreg
1288 * login, send a logout. We will change node state to UNUSED_NODE, put it
1289 * on plogi list so it can be freed when LOGO completes.
1293 lpfc_device_rm_prli_issue(struct lpfc_hba * phba,
1294 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1296 if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1297 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1298 return ndlp->nlp_state;
1301 /* software abort outstanding PLOGI */
1302 lpfc_els_abort(phba, ndlp);
1304 lpfc_drop_node(phba, ndlp);
1305 return NLP_STE_FREED_NODE;
1310 /*! lpfc_device_recov_prli_issue
1321 * The routine is envoked when the state of a device is unknown, like
1322 * during a link down. We should remove the nodelist entry from the
1323 * unmapped list, issue a UNREG_LOGIN, do a software abort of the
1324 * outstanding PRLI command, then free the node entry.
1327 lpfc_device_recov_prli_issue(struct lpfc_hba * phba,
1328 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1330 /* software abort outstanding PRLI */
1331 lpfc_els_abort(phba, ndlp);
1333 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
1334 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1335 spin_lock_irq(phba->host->host_lock);
1336 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1337 spin_unlock_irq(phba->host->host_lock);
1338 return ndlp->nlp_state;
1342 lpfc_rcv_plogi_unmap_node(struct lpfc_hba * phba,
1343 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1345 struct lpfc_iocbq *cmdiocb;
1347 cmdiocb = (struct lpfc_iocbq *) arg;
1349 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
1350 return ndlp->nlp_state;
1354 lpfc_rcv_prli_unmap_node(struct lpfc_hba * phba,
1355 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1357 struct lpfc_iocbq *cmdiocb;
1359 cmdiocb = (struct lpfc_iocbq *) arg;
1361 lpfc_rcv_prli(phba, ndlp, cmdiocb);
1362 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
1363 return ndlp->nlp_state;
1367 lpfc_rcv_logo_unmap_node(struct lpfc_hba * phba,
1368 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1370 struct lpfc_iocbq *cmdiocb;
1372 cmdiocb = (struct lpfc_iocbq *) arg;
1374 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1375 return ndlp->nlp_state;
1379 lpfc_rcv_padisc_unmap_node(struct lpfc_hba * phba,
1380 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1382 struct lpfc_iocbq *cmdiocb;
1384 cmdiocb = (struct lpfc_iocbq *) arg;
1386 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
1387 return ndlp->nlp_state;
1391 lpfc_rcv_prlo_unmap_node(struct lpfc_hba * phba,
1392 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1394 struct lpfc_iocbq *cmdiocb;
1396 cmdiocb = (struct lpfc_iocbq *) arg;
1398 lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
1399 return ndlp->nlp_state;
1403 lpfc_device_recov_unmap_node(struct lpfc_hba * phba,
1404 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1406 ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
1407 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1408 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1409 lpfc_disc_set_adisc(phba, ndlp);
1411 return ndlp->nlp_state;
1415 lpfc_rcv_plogi_mapped_node(struct lpfc_hba * phba,
1416 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1418 struct lpfc_iocbq *cmdiocb;
1420 cmdiocb = (struct lpfc_iocbq *) arg;
1422 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
1423 return ndlp->nlp_state;
1427 lpfc_rcv_prli_mapped_node(struct lpfc_hba * phba,
1428 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1430 struct lpfc_iocbq *cmdiocb;
1432 cmdiocb = (struct lpfc_iocbq *) arg;
1434 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
1435 return ndlp->nlp_state;
1439 lpfc_rcv_logo_mapped_node(struct lpfc_hba * phba,
1440 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1442 struct lpfc_iocbq *cmdiocb;
1444 cmdiocb = (struct lpfc_iocbq *) arg;
1446 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1447 return ndlp->nlp_state;
1451 lpfc_rcv_padisc_mapped_node(struct lpfc_hba * phba,
1452 struct lpfc_nodelist * ndlp, void *arg,
1455 struct lpfc_iocbq *cmdiocb;
1457 cmdiocb = (struct lpfc_iocbq *) arg;
1459 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
1460 return ndlp->nlp_state;
1464 lpfc_rcv_prlo_mapped_node(struct lpfc_hba * phba,
1465 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1467 struct lpfc_iocbq *cmdiocb;
1469 cmdiocb = (struct lpfc_iocbq *) arg;
1471 /* flush the target */
1472 spin_lock_irq(phba->host->host_lock);
1473 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
1474 ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT);
1475 spin_unlock_irq(phba->host->host_lock);
1477 /* Treat like rcv logo */
1478 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_PRLO);
1479 return ndlp->nlp_state;
1483 lpfc_device_recov_mapped_node(struct lpfc_hba * phba,
1484 struct lpfc_nodelist * ndlp, void *arg,
1487 ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
1488 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1489 spin_lock_irq(phba->host->host_lock);
1490 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1491 spin_unlock_irq(phba->host->host_lock);
1492 lpfc_disc_set_adisc(phba, ndlp);
1493 return ndlp->nlp_state;
1497 lpfc_rcv_plogi_npr_node(struct lpfc_hba * phba,
1498 struct lpfc_nodelist * ndlp, void *arg,
1501 struct lpfc_iocbq *cmdiocb;
1503 cmdiocb = (struct lpfc_iocbq *) arg;
1505 /* Ignore PLOGI if we have an outstanding LOGO */
1506 if (ndlp->nlp_flag & NLP_LOGO_SND) {
1507 return ndlp->nlp_state;
1510 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
1511 spin_lock_irq(phba->host->host_lock);
1512 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1513 spin_unlock_irq(phba->host->host_lock);
1514 return ndlp->nlp_state;
1517 /* send PLOGI immediately, move to PLOGI issue state */
1518 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
1519 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1520 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1521 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
1524 return ndlp->nlp_state;
1528 lpfc_rcv_prli_npr_node(struct lpfc_hba * phba,
1529 struct lpfc_nodelist * ndlp, void *arg,
1532 struct lpfc_iocbq *cmdiocb;
1535 cmdiocb = (struct lpfc_iocbq *) arg;
1537 memset(&stat, 0, sizeof (struct ls_rjt));
1538 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
1539 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
1540 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
1542 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
1543 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
1544 spin_lock_irq(phba->host->host_lock);
1545 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1546 spin_unlock_irq(phba->host->host_lock);
1547 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1548 lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
1549 lpfc_issue_els_adisc(phba, ndlp, 0);
1551 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1552 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1553 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
1556 return ndlp->nlp_state;
1560 lpfc_rcv_logo_npr_node(struct lpfc_hba * phba,
1561 struct lpfc_nodelist * ndlp, void *arg,
1564 struct lpfc_iocbq *cmdiocb;
1566 cmdiocb = (struct lpfc_iocbq *) arg;
1568 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1569 return ndlp->nlp_state;
1573 lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba,
1574 struct lpfc_nodelist * ndlp, void *arg,
1577 struct lpfc_iocbq *cmdiocb;
1579 cmdiocb = (struct lpfc_iocbq *) arg;
1581 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
1584 * Do not start discovery if discovery is about to start
1585 * or discovery in progress for this node. Starting discovery
1586 * here will affect the counting of discovery threads.
1588 if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
1589 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)){
1590 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
1591 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1592 lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
1593 lpfc_issue_els_adisc(phba, ndlp, 0);
1595 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1596 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1597 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
1600 return ndlp->nlp_state;
1604 lpfc_rcv_prlo_npr_node(struct lpfc_hba * phba,
1605 struct lpfc_nodelist * ndlp, void *arg,
1608 struct lpfc_iocbq *cmdiocb;
1610 cmdiocb = (struct lpfc_iocbq *) arg;
1612 spin_lock_irq(phba->host->host_lock);
1613 ndlp->nlp_flag |= NLP_LOGO_ACC;
1614 spin_unlock_irq(phba->host->host_lock);
1616 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
1618 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
1619 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
1620 spin_lock_irq(phba->host->host_lock);
1621 ndlp->nlp_flag |= NLP_DELAY_TMO;
1622 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1623 spin_unlock_irq(phba->host->host_lock);
1624 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1626 spin_lock_irq(phba->host->host_lock);
1627 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1628 spin_unlock_irq(phba->host->host_lock);
1630 return ndlp->nlp_state;
1634 lpfc_cmpl_plogi_npr_node(struct lpfc_hba * phba,
1635 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1637 struct lpfc_iocbq *cmdiocb, *rspiocb;
1640 cmdiocb = (struct lpfc_iocbq *) arg;
1641 rspiocb = cmdiocb->context_un.rsp_iocb;
1643 irsp = &rspiocb->iocb;
1644 if (irsp->ulpStatus) {
1645 lpfc_drop_node(phba, ndlp);
1646 return NLP_STE_FREED_NODE;
1648 return ndlp->nlp_state;
1652 lpfc_cmpl_prli_npr_node(struct lpfc_hba * phba,
1653 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1655 struct lpfc_iocbq *cmdiocb, *rspiocb;
1658 cmdiocb = (struct lpfc_iocbq *) arg;
1659 rspiocb = cmdiocb->context_un.rsp_iocb;
1661 irsp = &rspiocb->iocb;
1662 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
1663 lpfc_drop_node(phba, ndlp);
1664 return NLP_STE_FREED_NODE;
1666 return ndlp->nlp_state;
1670 lpfc_cmpl_logo_npr_node(struct lpfc_hba * phba,
1671 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1673 lpfc_unreg_rpi(phba, ndlp);
1674 /* This routine does nothing, just return the current state */
1675 return ndlp->nlp_state;
1679 lpfc_cmpl_adisc_npr_node(struct lpfc_hba * phba,
1680 struct lpfc_nodelist * ndlp, void *arg,
1683 struct lpfc_iocbq *cmdiocb, *rspiocb;
1686 cmdiocb = (struct lpfc_iocbq *) arg;
1687 rspiocb = cmdiocb->context_un.rsp_iocb;
1689 irsp = &rspiocb->iocb;
1690 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
1691 lpfc_drop_node(phba, ndlp);
1692 return NLP_STE_FREED_NODE;
1694 return ndlp->nlp_state;
1698 lpfc_cmpl_reglogin_npr_node(struct lpfc_hba * phba,
1699 struct lpfc_nodelist * ndlp, void *arg,
1705 pmb = (LPFC_MBOXQ_t *) arg;
1709 ndlp->nlp_rpi = mb->un.varWords[0];
1711 if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
1712 lpfc_drop_node(phba, ndlp);
1713 return NLP_STE_FREED_NODE;
1716 return ndlp->nlp_state;
1720 lpfc_device_rm_npr_node(struct lpfc_hba * phba,
1721 struct lpfc_nodelist * ndlp, void *arg,
1724 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1725 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1726 return ndlp->nlp_state;
1728 lpfc_drop_node(phba, ndlp);
1729 return NLP_STE_FREED_NODE;
1733 lpfc_device_recov_npr_node(struct lpfc_hba * phba,
1734 struct lpfc_nodelist * ndlp, void *arg,
1737 spin_lock_irq(phba->host->host_lock);
1738 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1739 spin_unlock_irq(phba->host->host_lock);
1740 if (ndlp->nlp_flag & NLP_DELAY_TMO) {
1741 lpfc_cancel_retry_delay_tmo(phba, ndlp);
1743 return ndlp->nlp_state;
1747 /* This next section defines the NPort Discovery State Machine */
1749 /* There are 4 different double linked lists nodelist entries can reside on.
1750 * The plogi list and adisc list are used when Link Up discovery or RSCN
1751 * processing is needed. Each list holds the nodes that we will send PLOGI
1752 * or ADISC on. These lists will keep track of what nodes will be effected
1753 * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
1754 * The unmapped_list will contain all nodes that we have successfully logged
1755 * into at the Fibre Channel level. The mapped_list will contain all nodes
1756 * that are mapped FCP targets.
1759 * The bind list is a list of undiscovered (potentially non-existent) nodes
1760 * that we have saved binding information on. This information is used when
1761 * nodes transition from the unmapped to the mapped list.
1763 /* For UNUSED_NODE state, the node has just been allocated .
1764 * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
1765 * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
1766 * and put on the unmapped list. For ADISC processing, the node is taken off
1767 * the ADISC list and placed on either the mapped or unmapped list (depending
1768 * on its previous state). Once on the unmapped list, a PRLI is issued and the
1769 * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
1770 * changed to UNMAPPED_NODE. If the completion indicates a mapped
1771 * node, the node is taken off the unmapped list. The binding list is checked
1772 * for a valid binding, or a binding is automatically assigned. If binding
1773 * assignment is unsuccessful, the node is left on the unmapped list. If
1774 * binding assignment is successful, the associated binding list entry (if
1775 * any) is removed, and the node is placed on the mapped list.
1778 * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
1779 * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
1780 * expire, all effected nodes will receive a DEVICE_RM event.
1783 * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
1784 * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
1785 * check, additional nodes may be added or removed (via DEVICE_RM) to / from
1786 * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
1787 * we will first process the ADISC list. 32 entries are processed initially and
1788 * ADISC is initited for each one. Completions / Events for each node are
1789 * funnelled thru the state machine. As each node finishes ADISC processing, it
1790 * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
1791 * waiting, and the ADISC list count is identically 0, then we are done. For
1792 * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
1793 * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
1794 * list. 32 entries are processed initially and PLOGI is initited for each one.
1795 * Completions / Events for each node are funnelled thru the state machine. As
1796 * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
1797 * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
1798 * indentically 0, then we are done. We have now completed discovery / RSCN
1799 * handling. Upon completion, ALL nodes should be on either the mapped or
1803 static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
1804 (struct lpfc_hba *, struct lpfc_nodelist *, void *, uint32_t) = {
1805 /* Action routine Event Current State */
1806 lpfc_rcv_plogi_unused_node, /* RCV_PLOGI UNUSED_NODE */
1807 lpfc_rcv_els_unused_node, /* RCV_PRLI */
1808 lpfc_rcv_logo_unused_node, /* RCV_LOGO */
1809 lpfc_rcv_els_unused_node, /* RCV_ADISC */
1810 lpfc_rcv_els_unused_node, /* RCV_PDISC */
1811 lpfc_rcv_els_unused_node, /* RCV_PRLO */
1812 lpfc_disc_illegal, /* CMPL_PLOGI */
1813 lpfc_disc_illegal, /* CMPL_PRLI */
1814 lpfc_cmpl_logo_unused_node, /* CMPL_LOGO */
1815 lpfc_disc_illegal, /* CMPL_ADISC */
1816 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
1817 lpfc_device_rm_unused_node, /* DEVICE_RM */
1818 lpfc_disc_illegal, /* DEVICE_RECOVERY */
1820 lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */
1821 lpfc_rcv_els_plogi_issue, /* RCV_PRLI */
1822 lpfc_rcv_logo_plogi_issue, /* RCV_LOGO */
1823 lpfc_rcv_els_plogi_issue, /* RCV_ADISC */
1824 lpfc_rcv_els_plogi_issue, /* RCV_PDISC */
1825 lpfc_rcv_els_plogi_issue, /* RCV_PRLO */
1826 lpfc_cmpl_plogi_plogi_issue, /* CMPL_PLOGI */
1827 lpfc_disc_illegal, /* CMPL_PRLI */
1828 lpfc_disc_illegal, /* CMPL_LOGO */
1829 lpfc_disc_illegal, /* CMPL_ADISC */
1830 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
1831 lpfc_device_rm_plogi_issue, /* DEVICE_RM */
1832 lpfc_device_recov_plogi_issue, /* DEVICE_RECOVERY */
1834 lpfc_rcv_plogi_adisc_issue, /* RCV_PLOGI ADISC_ISSUE */
1835 lpfc_rcv_prli_adisc_issue, /* RCV_PRLI */
1836 lpfc_rcv_logo_adisc_issue, /* RCV_LOGO */
1837 lpfc_rcv_padisc_adisc_issue, /* RCV_ADISC */
1838 lpfc_rcv_padisc_adisc_issue, /* RCV_PDISC */
1839 lpfc_rcv_prlo_adisc_issue, /* RCV_PRLO */
1840 lpfc_disc_illegal, /* CMPL_PLOGI */
1841 lpfc_disc_illegal, /* CMPL_PRLI */
1842 lpfc_disc_illegal, /* CMPL_LOGO */
1843 lpfc_cmpl_adisc_adisc_issue, /* CMPL_ADISC */
1844 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
1845 lpfc_device_rm_adisc_issue, /* DEVICE_RM */
1846 lpfc_device_recov_adisc_issue, /* DEVICE_RECOVERY */
1848 lpfc_rcv_plogi_reglogin_issue, /* RCV_PLOGI REG_LOGIN_ISSUE */
1849 lpfc_rcv_prli_reglogin_issue, /* RCV_PLOGI */
1850 lpfc_rcv_logo_reglogin_issue, /* RCV_LOGO */
1851 lpfc_rcv_padisc_reglogin_issue, /* RCV_ADISC */
1852 lpfc_rcv_padisc_reglogin_issue, /* RCV_PDISC */
1853 lpfc_rcv_prlo_reglogin_issue, /* RCV_PRLO */
1854 lpfc_disc_illegal, /* CMPL_PLOGI */
1855 lpfc_disc_illegal, /* CMPL_PRLI */
1856 lpfc_disc_illegal, /* CMPL_LOGO */
1857 lpfc_disc_illegal, /* CMPL_ADISC */
1858 lpfc_cmpl_reglogin_reglogin_issue,/* CMPL_REG_LOGIN */
1859 lpfc_device_rm_reglogin_issue, /* DEVICE_RM */
1860 lpfc_device_recov_reglogin_issue,/* DEVICE_RECOVERY */
1862 lpfc_rcv_plogi_prli_issue, /* RCV_PLOGI PRLI_ISSUE */
1863 lpfc_rcv_prli_prli_issue, /* RCV_PRLI */
1864 lpfc_rcv_logo_prli_issue, /* RCV_LOGO */
1865 lpfc_rcv_padisc_prli_issue, /* RCV_ADISC */
1866 lpfc_rcv_padisc_prli_issue, /* RCV_PDISC */
1867 lpfc_rcv_prlo_prli_issue, /* RCV_PRLO */
1868 lpfc_disc_illegal, /* CMPL_PLOGI */
1869 lpfc_cmpl_prli_prli_issue, /* CMPL_PRLI */
1870 lpfc_disc_illegal, /* CMPL_LOGO */
1871 lpfc_disc_illegal, /* CMPL_ADISC */
1872 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
1873 lpfc_device_rm_prli_issue, /* DEVICE_RM */
1874 lpfc_device_recov_prli_issue, /* DEVICE_RECOVERY */
1876 lpfc_rcv_plogi_unmap_node, /* RCV_PLOGI UNMAPPED_NODE */
1877 lpfc_rcv_prli_unmap_node, /* RCV_PRLI */
1878 lpfc_rcv_logo_unmap_node, /* RCV_LOGO */
1879 lpfc_rcv_padisc_unmap_node, /* RCV_ADISC */
1880 lpfc_rcv_padisc_unmap_node, /* RCV_PDISC */
1881 lpfc_rcv_prlo_unmap_node, /* RCV_PRLO */
1882 lpfc_disc_illegal, /* CMPL_PLOGI */
1883 lpfc_disc_illegal, /* CMPL_PRLI */
1884 lpfc_disc_illegal, /* CMPL_LOGO */
1885 lpfc_disc_illegal, /* CMPL_ADISC */
1886 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
1887 lpfc_disc_illegal, /* DEVICE_RM */
1888 lpfc_device_recov_unmap_node, /* DEVICE_RECOVERY */
1890 lpfc_rcv_plogi_mapped_node, /* RCV_PLOGI MAPPED_NODE */
1891 lpfc_rcv_prli_mapped_node, /* RCV_PRLI */
1892 lpfc_rcv_logo_mapped_node, /* RCV_LOGO */
1893 lpfc_rcv_padisc_mapped_node, /* RCV_ADISC */
1894 lpfc_rcv_padisc_mapped_node, /* RCV_PDISC */
1895 lpfc_rcv_prlo_mapped_node, /* RCV_PRLO */
1896 lpfc_disc_illegal, /* CMPL_PLOGI */
1897 lpfc_disc_illegal, /* CMPL_PRLI */
1898 lpfc_disc_illegal, /* CMPL_LOGO */
1899 lpfc_disc_illegal, /* CMPL_ADISC */
1900 lpfc_disc_illegal, /* CMPL_REG_LOGIN */
1901 lpfc_disc_illegal, /* DEVICE_RM */
1902 lpfc_device_recov_mapped_node, /* DEVICE_RECOVERY */
1904 lpfc_rcv_plogi_npr_node, /* RCV_PLOGI NPR_NODE */
1905 lpfc_rcv_prli_npr_node, /* RCV_PRLI */
1906 lpfc_rcv_logo_npr_node, /* RCV_LOGO */
1907 lpfc_rcv_padisc_npr_node, /* RCV_ADISC */
1908 lpfc_rcv_padisc_npr_node, /* RCV_PDISC */
1909 lpfc_rcv_prlo_npr_node, /* RCV_PRLO */
1910 lpfc_cmpl_plogi_npr_node, /* CMPL_PLOGI */
1911 lpfc_cmpl_prli_npr_node, /* CMPL_PRLI */
1912 lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */
1913 lpfc_cmpl_adisc_npr_node, /* CMPL_ADISC */
1914 lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */
1915 lpfc_device_rm_npr_node, /* DEVICE_RM */
1916 lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */
1920 lpfc_disc_state_machine(struct lpfc_hba * phba,
1921 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1923 uint32_t cur_state, rc;
1924 uint32_t(*func) (struct lpfc_hba *, struct lpfc_nodelist *, void *,
1928 cur_state = ndlp->nlp_state;
1930 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
1931 lpfc_printf_log(phba,
1934 "%d:0211 DSM in event x%x on NPort x%x in state %d "
1937 evt, ndlp->nlp_DID, cur_state, ndlp->nlp_flag);
1939 func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt];
1940 rc = (func) (phba, ndlp, arg, evt);
1942 /* DSM out state <rc> on NPort <nlp_DID> */
1943 lpfc_printf_log(phba,
1946 "%d:0212 DSM out state %d on NPort x%x Data: x%x\n",
1948 rc, ndlp->nlp_DID, ndlp->nlp_flag);