aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc
diff options
context:
space:
mode:
authorJamie Wellnitz <Jamie.Wellnitz@emulex.com>2006-02-28 19:25:23 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-02-28 19:57:23 -0500
commitc9f8735beadfba403045c4423c91bbcf594b6ef2 (patch)
tree472f7053abdfe1b18fecddf3caacdd2976e7baeb /drivers/scsi/lpfc
parentb28485acb930f67c014024bc3b9c01129124e566 (diff)
[SCSI] lpfc 8.1.2: Misc FC Discovery changes :
Misc FC Discovery changes : - Added FC_BYPASSED_MODE statistic - Corrected some log message data - Fix up Discovery infrastructure to support FAN: Allow Fabric entities to flow thru DSM Fix up linkup/linkdown unregister login processing for Fabric entities Clean up Discovery code Utilize nodev_tmo for Fabric entities - Use of 3 * ratov for CT handling timeouts - Fix up DSM to make more appropriate decisions and clean up code. Signed-off-by: Jamie Wellnitz <Jamie.Wellnitz@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/lpfc')
-rw-r--r--drivers/scsi/lpfc/lpfc.h1
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c11
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c330
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c220
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c283
5 files changed, 452 insertions, 393 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 14151de23fd..d07ab0214af 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -247,6 +247,7 @@ struct lpfc_hba {
247#define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */ 247#define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */
248#define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */ 248#define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */
249#define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */ 249#define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */
250#define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */
250 251
251 uint32_t fc_topology; /* link topology, from LINK INIT */ 252 uint32_t fc_topology; /* link topology, from LINK INIT */
252 253
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 7f427f9c468..98b94c0eb59 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -260,8 +260,10 @@ lpfc_gen_req(struct lpfc_hba *phba, struct lpfc_dmabuf *bmp,
260 icmd->un.genreq64.w5.hcsw.Rctl = FC_UNSOL_CTL; 260 icmd->un.genreq64.w5.hcsw.Rctl = FC_UNSOL_CTL;
261 icmd->un.genreq64.w5.hcsw.Type = FC_COMMON_TRANSPORT_ULP; 261 icmd->un.genreq64.w5.hcsw.Type = FC_COMMON_TRANSPORT_ULP;
262 262
263 if (!tmo) 263 if (!tmo) {
264 tmo = (2 * phba->fc_ratov) + 1; 264 /* FC spec states we need 3 * ratov for CT requests */
265 tmo = (3 * phba->fc_ratov);
266 }
265 icmd->ulpTimeout = tmo; 267 icmd->ulpTimeout = tmo;
266 icmd->ulpBdeCount = 1; 268 icmd->ulpBdeCount = 1;
267 icmd->ulpLe = 1; 269 icmd->ulpLe = 1;
@@ -449,6 +451,11 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
449 CTrsp = (struct lpfc_sli_ct_request *) outp->virt; 451 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
450 if (CTrsp->CommandResponse.bits.CmdRsp == 452 if (CTrsp->CommandResponse.bits.CmdRsp ==
451 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { 453 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) {
454 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
455 "%d:0239 NameServer Rsp "
456 "Data: x%x\n",
457 phba->brd_no,
458 phba->fc_flag);
452 lpfc_ns_rsp(phba, outp, 459 lpfc_ns_rsp(phba, outp,
453 (uint32_t) (irsp->un.genreq64.bdl.bdeSize)); 460 (uint32_t) (irsp->un.genreq64.bdl.bdeSize));
454 } else if (CTrsp->CommandResponse.bits.CmdRsp == 461 } else if (CTrsp->CommandResponse.bits.CmdRsp ==
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 056f9157d2c..70581b9eafa 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -92,7 +92,7 @@ lpfc_els_chk_latt(struct lpfc_hba * phba)
92 } 92 }
93 } 93 }
94 94
95 return (1); 95 return 1;
96 96
97} 97}
98 98
@@ -235,7 +235,7 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba,
235 ndlp->nlp_DID, icmd->ulpIoTag, cmdSize); 235 ndlp->nlp_DID, icmd->ulpIoTag, cmdSize);
236 } 236 }
237 237
238 return (elsiocb); 238 return elsiocb;
239} 239}
240 240
241 241
@@ -446,9 +446,10 @@ lpfc_cmpl_els_flogi(struct lpfc_hba * phba,
446 lpfc_printf_log(phba, 446 lpfc_printf_log(phba,
447 KERN_INFO, 447 KERN_INFO,
448 LOG_ELS, 448 LOG_ELS,
449 "%d:0100 FLOGI failure Data: x%x x%x\n", 449 "%d:0100 FLOGI failure Data: x%x x%x x%x\n",
450 phba->brd_no, 450 phba->brd_no,
451 irsp->ulpStatus, irsp->un.ulpWord[4]); 451 irsp->ulpStatus, irsp->un.ulpWord[4],
452 irsp->ulpTimeout);
452 goto flogifail; 453 goto flogifail;
453 } 454 }
454 455
@@ -517,7 +518,7 @@ lpfc_issue_els_flogi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
517 cmdsize = (sizeof (uint32_t) + sizeof (struct serv_parm)); 518 cmdsize = (sizeof (uint32_t) + sizeof (struct serv_parm));
518 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, 519 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry,
519 ndlp, ELS_CMD_FLOGI)) == 0) { 520 ndlp, ELS_CMD_FLOGI)) == 0) {
520 return (1); 521 return 1;
521 } 522 }
522 523
523 icmd = &elsiocb->iocb; 524 icmd = &elsiocb->iocb;
@@ -552,9 +553,9 @@ lpfc_issue_els_flogi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
552 spin_unlock_irq(phba->host->host_lock); 553 spin_unlock_irq(phba->host->host_lock);
553 if (rc == IOCB_ERROR) { 554 if (rc == IOCB_ERROR) {
554 lpfc_els_free_iocb(phba, elsiocb); 555 lpfc_els_free_iocb(phba, elsiocb);
555 return (1); 556 return 1;
556 } 557 }
557 return (0); 558 return 0;
558} 559}
559 560
560int 561int
@@ -611,29 +612,21 @@ lpfc_initial_flogi(struct lpfc_hba * phba)
611{ 612{
612 struct lpfc_nodelist *ndlp; 613 struct lpfc_nodelist *ndlp;
613 614
614 /* First look for Fabric ndlp on the unmapped list */ 615 /* First look for the Fabric ndlp */
615 616 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, Fabric_DID);
616 if ((ndlp = 617 if (!ndlp) {
617 lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED,
618 Fabric_DID)) == 0) {
619 /* Cannot find existing Fabric ndlp, so allocate a new one */ 618 /* Cannot find existing Fabric ndlp, so allocate a new one */
620 if ((ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL)) 619 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL);
621 == 0) { 620 if (!ndlp)
622 return (0); 621 return 0;
623 }
624 lpfc_nlp_init(phba, ndlp, Fabric_DID); 622 lpfc_nlp_init(phba, ndlp, Fabric_DID);
625 } 623 } else {
626 else { 624 lpfc_nlp_list(phba, ndlp, NLP_JUST_DQ);
627 phba->fc_unmap_cnt--;
628 list_del(&ndlp->nlp_listp);
629 spin_lock_irq(phba->host->host_lock);
630 ndlp->nlp_flag &= ~NLP_LIST_MASK;
631 spin_unlock_irq(phba->host->host_lock);
632 } 625 }
633 if (lpfc_issue_els_flogi(phba, ndlp, 0)) { 626 if (lpfc_issue_els_flogi(phba, ndlp, 0)) {
634 mempool_free( ndlp, phba->nlp_mem_pool); 627 mempool_free( ndlp, phba->nlp_mem_pool);
635 } 628 }
636 return (1); 629 return 1;
637} 630}
638 631
639static void 632static void
@@ -675,22 +668,23 @@ lpfc_cmpl_els_plogi(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
675 668
676 irsp = &rspiocb->iocb; 669 irsp = &rspiocb->iocb;
677 ndlp = (struct lpfc_nodelist *) cmdiocb->context1; 670 ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
678 spin_lock_irq(phba->host->host_lock);
679 ndlp->nlp_flag &= ~NLP_PLOGI_SND;
680 spin_unlock_irq(phba->host->host_lock);
681 671
682 /* Since ndlp can be freed in the disc state machine, note if this node 672 /* Since ndlp can be freed in the disc state machine, note if this node
683 * is being used during discovery. 673 * is being used during discovery.
684 */ 674 */
685 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); 675 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC);
676 spin_lock_irq(phba->host->host_lock);
677 ndlp->nlp_flag &= ~(NLP_PLOGI_SND | NLP_NPR_2B_DISC);
678 spin_unlock_irq(phba->host->host_lock);
686 rc = 0; 679 rc = 0;
687 680
688 /* PLOGI completes to NPort <nlp_DID> */ 681 /* PLOGI completes to NPort <nlp_DID> */
689 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 682 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
690 "%d:0102 PLOGI completes to NPort x%x " 683 "%d:0102 PLOGI completes to NPort x%x "
691 "Data: x%x x%x x%x x%x\n", 684 "Data: x%x x%x x%x x%x x%x\n",
692 phba->brd_no, ndlp->nlp_DID, irsp->ulpStatus, 685 phba->brd_no, ndlp->nlp_DID, irsp->ulpStatus,
693 irsp->un.ulpWord[4], disc, phba->num_disc_nodes); 686 irsp->un.ulpWord[4], irsp->ulpTimeout, disc,
687 phba->num_disc_nodes);
694 688
695 /* Check to see if link went down during discovery */ 689 /* Check to see if link went down during discovery */
696 if (lpfc_els_chk_latt(phba)) { 690 if (lpfc_els_chk_latt(phba)) {
@@ -722,7 +716,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
722 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 716 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) ||
723 (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || 717 (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) ||
724 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { 718 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) {
725 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); 719 rc = NLP_STE_FREED_NODE;
726 } 720 }
727 else { 721 else {
728 rc = lpfc_disc_state_machine(phba, ndlp, cmdiocb, 722 rc = lpfc_disc_state_machine(phba, ndlp, cmdiocb,
@@ -747,18 +741,11 @@ lpfc_cmpl_els_plogi(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
747 lpfc_more_plogi(phba); 741 lpfc_more_plogi(phba);
748 } 742 }
749 743
750 if (rc != NLP_STE_FREED_NODE) { 744 if (phba->num_disc_nodes == 0) {
751 spin_lock_irq(phba->host->host_lock); 745 spin_lock_irq(phba->host->host_lock);
752 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; 746 phba->fc_flag &= ~FC_NDISC_ACTIVE;
753 spin_unlock_irq(phba->host->host_lock); 747 spin_unlock_irq(phba->host->host_lock);
754 }
755 748
756 if (phba->num_disc_nodes == 0) {
757 if(disc) {
758 spin_lock_irq(phba->host->host_lock);
759 phba->fc_flag &= ~FC_NDISC_ACTIVE;
760 spin_unlock_irq(phba->host->host_lock);
761 }
762 lpfc_can_disctmo(phba); 749 lpfc_can_disctmo(phba);
763 if (phba->fc_flag & FC_RSCN_MODE) { 750 if (phba->fc_flag & FC_RSCN_MODE) {
764 /* Check to see if more RSCNs came in while we were 751 /* Check to see if more RSCNs came in while we were
@@ -796,10 +783,10 @@ lpfc_issue_els_plogi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
796 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ 783 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */
797 784
798 cmdsize = (sizeof (uint32_t) + sizeof (struct serv_parm)); 785 cmdsize = (sizeof (uint32_t) + sizeof (struct serv_parm));
799 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, 786 elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, ndlp,
800 ndlp, ELS_CMD_PLOGI)) == 0) { 787 ELS_CMD_PLOGI);
801 return (1); 788 if (!elsiocb)
802 } 789 return 1;
803 790
804 icmd = &elsiocb->iocb; 791 icmd = &elsiocb->iocb;
805 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 792 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
@@ -824,10 +811,10 @@ lpfc_issue_els_plogi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
824 ndlp->nlp_flag &= ~NLP_PLOGI_SND; 811 ndlp->nlp_flag &= ~NLP_PLOGI_SND;
825 spin_unlock_irq(phba->host->host_lock); 812 spin_unlock_irq(phba->host->host_lock);
826 lpfc_els_free_iocb(phba, elsiocb); 813 lpfc_els_free_iocb(phba, elsiocb);
827 return (1); 814 return 1;
828 } 815 }
829 spin_unlock_irq(phba->host->host_lock); 816 spin_unlock_irq(phba->host->host_lock);
830 return (0); 817 return 0;
831} 818}
832 819
833static void 820static void
@@ -851,9 +838,10 @@ lpfc_cmpl_els_prli(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
851 /* PRLI completes to NPort <nlp_DID> */ 838 /* PRLI completes to NPort <nlp_DID> */
852 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 839 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
853 "%d:0103 PRLI completes to NPort x%x " 840 "%d:0103 PRLI completes to NPort x%x "
854 "Data: x%x x%x x%x\n", 841 "Data: x%x x%x x%x x%x\n",
855 phba->brd_no, ndlp->nlp_DID, irsp->ulpStatus, 842 phba->brd_no, ndlp->nlp_DID, irsp->ulpStatus,
856 irsp->un.ulpWord[4], phba->num_disc_nodes); 843 irsp->un.ulpWord[4], irsp->ulpTimeout,
844 phba->num_disc_nodes);
857 845
858 phba->fc_prli_sent--; 846 phba->fc_prli_sent--;
859 /* Check to see if link went down during discovery */ 847 /* Check to see if link went down during discovery */
@@ -906,7 +894,7 @@ lpfc_issue_els_prli(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
906 cmdsize = (sizeof (uint32_t) + sizeof (PRLI)); 894 cmdsize = (sizeof (uint32_t) + sizeof (PRLI));
907 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, 895 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry,
908 ndlp, ELS_CMD_PRLI)) == 0) { 896 ndlp, ELS_CMD_PRLI)) == 0) {
909 return (1); 897 return 1;
910 } 898 }
911 899
912 icmd = &elsiocb->iocb; 900 icmd = &elsiocb->iocb;
@@ -943,11 +931,11 @@ lpfc_issue_els_prli(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
943 ndlp->nlp_flag &= ~NLP_PRLI_SND; 931 ndlp->nlp_flag &= ~NLP_PRLI_SND;
944 spin_unlock_irq(phba->host->host_lock); 932 spin_unlock_irq(phba->host->host_lock);
945 lpfc_els_free_iocb(phba, elsiocb); 933 lpfc_els_free_iocb(phba, elsiocb);
946 return (1); 934 return 1;
947 } 935 }
948 spin_unlock_irq(phba->host->host_lock); 936 spin_unlock_irq(phba->host->host_lock);
949 phba->fc_prli_sent++; 937 phba->fc_prli_sent++;
950 return (0); 938 return 0;
951} 939}
952 940
953static void 941static void
@@ -1016,21 +1004,22 @@ lpfc_cmpl_els_adisc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1016 1004
1017 irsp = &(rspiocb->iocb); 1005 irsp = &(rspiocb->iocb);
1018 ndlp = (struct lpfc_nodelist *) cmdiocb->context1; 1006 ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
1019 spin_lock_irq(phba->host->host_lock);
1020 ndlp->nlp_flag &= ~NLP_ADISC_SND;
1021 spin_unlock_irq(phba->host->host_lock);
1022 1007
1023 /* Since ndlp can be freed in the disc state machine, note if this node 1008 /* Since ndlp can be freed in the disc state machine, note if this node
1024 * is being used during discovery. 1009 * is being used during discovery.
1025 */ 1010 */
1026 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); 1011 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC);
1012 spin_lock_irq(phba->host->host_lock);
1013 ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC);
1014 spin_unlock_irq(phba->host->host_lock);
1027 1015
1028 /* ADISC completes to NPort <nlp_DID> */ 1016 /* ADISC completes to NPort <nlp_DID> */
1029 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1017 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
1030 "%d:0104 ADISC completes to NPort x%x " 1018 "%d:0104 ADISC completes to NPort x%x "
1031 "Data: x%x x%x x%x x%x\n", 1019 "Data: x%x x%x x%x x%x x%x\n",
1032 phba->brd_no, ndlp->nlp_DID, irsp->ulpStatus, 1020 phba->brd_no, ndlp->nlp_DID, irsp->ulpStatus,
1033 irsp->un.ulpWord[4], disc, phba->num_disc_nodes); 1021 irsp->un.ulpWord[4], irsp->ulpTimeout, disc,
1022 phba->num_disc_nodes);
1034 1023
1035 /* Check to see if link went down during discovery */ 1024 /* Check to see if link went down during discovery */
1036 if (lpfc_els_chk_latt(phba)) { 1025 if (lpfc_els_chk_latt(phba)) {
@@ -1054,13 +1043,10 @@ lpfc_cmpl_els_adisc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1054 } 1043 }
1055 /* ADISC failed */ 1044 /* ADISC failed */
1056 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 1045 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
1057 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 1046 if ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) ||
1058 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 1047 ((irsp->un.ulpWord[4] != IOERR_SLI_ABORTED) &&
1059 (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || 1048 (irsp->un.ulpWord[4] != IOERR_LINK_DOWN) &&
1060 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { 1049 (irsp->un.ulpWord[4] != IOERR_SLI_DOWN))) {
1061 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC);
1062 }
1063 else {
1064 lpfc_disc_state_machine(phba, ndlp, cmdiocb, 1050 lpfc_disc_state_machine(phba, ndlp, cmdiocb,
1065 NLP_EVT_CMPL_ADISC); 1051 NLP_EVT_CMPL_ADISC);
1066 } 1052 }
@@ -1112,9 +1098,6 @@ lpfc_cmpl_els_adisc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1112 } 1098 }
1113 } 1099 }
1114 } 1100 }
1115 spin_lock_irq(phba->host->host_lock);
1116 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1117 spin_unlock_irq(phba->host->host_lock);
1118out: 1101out:
1119 lpfc_els_free_iocb(phba, cmdiocb); 1102 lpfc_els_free_iocb(phba, cmdiocb);
1120 return; 1103 return;
@@ -1138,7 +1121,7 @@ lpfc_issue_els_adisc(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
1138 cmdsize = (sizeof (uint32_t) + sizeof (ADISC)); 1121 cmdsize = (sizeof (uint32_t) + sizeof (ADISC));
1139 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, 1122 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry,
1140 ndlp, ELS_CMD_ADISC)) == 0) { 1123 ndlp, ELS_CMD_ADISC)) == 0) {
1141 return (1); 1124 return 1;
1142 } 1125 }
1143 1126
1144 icmd = &elsiocb->iocb; 1127 icmd = &elsiocb->iocb;
@@ -1163,10 +1146,10 @@ lpfc_issue_els_adisc(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
1163 ndlp->nlp_flag &= ~NLP_ADISC_SND; 1146 ndlp->nlp_flag &= ~NLP_ADISC_SND;
1164 spin_unlock_irq(phba->host->host_lock); 1147 spin_unlock_irq(phba->host->host_lock);
1165 lpfc_els_free_iocb(phba, elsiocb); 1148 lpfc_els_free_iocb(phba, elsiocb);
1166 return (1); 1149 return 1;
1167 } 1150 }
1168 spin_unlock_irq(phba->host->host_lock); 1151 spin_unlock_irq(phba->host->host_lock);
1169 return (0); 1152 return 0;
1170} 1153}
1171 1154
1172static void 1155static void
@@ -1190,9 +1173,10 @@ lpfc_cmpl_els_logo(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1190 /* LOGO completes to NPort <nlp_DID> */ 1173 /* LOGO completes to NPort <nlp_DID> */
1191 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1174 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
1192 "%d:0105 LOGO completes to NPort x%x " 1175 "%d:0105 LOGO completes to NPort x%x "
1193 "Data: x%x x%x x%x\n", 1176 "Data: x%x x%x x%x x%x\n",
1194 phba->brd_no, ndlp->nlp_DID, irsp->ulpStatus, 1177 phba->brd_no, ndlp->nlp_DID, irsp->ulpStatus,
1195 irsp->un.ulpWord[4], phba->num_disc_nodes); 1178 irsp->un.ulpWord[4], irsp->ulpTimeout,
1179 phba->num_disc_nodes);
1196 1180
1197 /* Check to see if link went down during discovery */ 1181 /* Check to see if link went down during discovery */
1198 if (lpfc_els_chk_latt(phba)) 1182 if (lpfc_els_chk_latt(phba))
@@ -1247,7 +1231,7 @@ lpfc_issue_els_logo(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
1247 cmdsize = 2 * (sizeof (uint32_t) + sizeof (struct lpfc_name)); 1231 cmdsize = 2 * (sizeof (uint32_t) + sizeof (struct lpfc_name));
1248 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, 1232 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry,
1249 ndlp, ELS_CMD_LOGO)) == 0) { 1233 ndlp, ELS_CMD_LOGO)) == 0) {
1250 return (1); 1234 return 1;
1251 } 1235 }
1252 1236
1253 icmd = &elsiocb->iocb; 1237 icmd = &elsiocb->iocb;
@@ -1268,10 +1252,10 @@ lpfc_issue_els_logo(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
1268 ndlp->nlp_flag &= ~NLP_LOGO_SND; 1252 ndlp->nlp_flag &= ~NLP_LOGO_SND;
1269 spin_unlock_irq(phba->host->host_lock); 1253 spin_unlock_irq(phba->host->host_lock);
1270 lpfc_els_free_iocb(phba, elsiocb); 1254 lpfc_els_free_iocb(phba, elsiocb);
1271 return (1); 1255 return 1;
1272 } 1256 }
1273 spin_unlock_irq(phba->host->host_lock); 1257 spin_unlock_irq(phba->host->host_lock);
1274 return (0); 1258 return 0;
1275} 1259}
1276 1260
1277static void 1261static void
@@ -1286,9 +1270,10 @@ lpfc_cmpl_els_cmd(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1286 lpfc_printf_log(phba, 1270 lpfc_printf_log(phba,
1287 KERN_INFO, 1271 KERN_INFO,
1288 LOG_ELS, 1272 LOG_ELS,
1289 "%d:0106 ELS cmd tag x%x completes Data: x%x x%x\n", 1273 "%d:0106 ELS cmd tag x%x completes Data: x%x x%x x%x\n",
1290 phba->brd_no, 1274 phba->brd_no,
1291 irsp->ulpIoTag, irsp->ulpStatus, irsp->un.ulpWord[4]); 1275 irsp->ulpIoTag, irsp->ulpStatus,
1276 irsp->un.ulpWord[4], irsp->ulpTimeout);
1292 1277
1293 /* Check to see if link went down during discovery */ 1278 /* Check to see if link went down during discovery */
1294 lpfc_els_chk_latt(phba); 1279 lpfc_els_chk_latt(phba);
@@ -1310,16 +1295,16 @@ lpfc_issue_els_scr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
1310 psli = &phba->sli; 1295 psli = &phba->sli;
1311 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ 1296 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */
1312 cmdsize = (sizeof (uint32_t) + sizeof (SCR)); 1297 cmdsize = (sizeof (uint32_t) + sizeof (SCR));
1313 if ((ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL)) == 0) { 1298 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL);
1314 return (1); 1299 if (!ndlp)
1315 } 1300 return 1;
1316 1301
1317 lpfc_nlp_init(phba, ndlp, nportid); 1302 lpfc_nlp_init(phba, ndlp, nportid);
1318 1303
1319 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, 1304 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry,
1320 ndlp, ELS_CMD_SCR)) == 0) { 1305 ndlp, ELS_CMD_SCR)) == 0) {
1321 mempool_free( ndlp, phba->nlp_mem_pool); 1306 mempool_free( ndlp, phba->nlp_mem_pool);
1322 return (1); 1307 return 1;
1323 } 1308 }
1324 1309
1325 icmd = &elsiocb->iocb; 1310 icmd = &elsiocb->iocb;
@@ -1339,11 +1324,11 @@ lpfc_issue_els_scr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
1339 spin_unlock_irq(phba->host->host_lock); 1324 spin_unlock_irq(phba->host->host_lock);
1340 mempool_free( ndlp, phba->nlp_mem_pool); 1325 mempool_free( ndlp, phba->nlp_mem_pool);
1341 lpfc_els_free_iocb(phba, elsiocb); 1326 lpfc_els_free_iocb(phba, elsiocb);
1342 return (1); 1327 return 1;
1343 } 1328 }
1344 spin_unlock_irq(phba->host->host_lock); 1329 spin_unlock_irq(phba->host->host_lock);
1345 mempool_free( ndlp, phba->nlp_mem_pool); 1330 mempool_free( ndlp, phba->nlp_mem_pool);
1346 return (0); 1331 return 0;
1347} 1332}
1348 1333
1349static int 1334static int
@@ -1363,15 +1348,15 @@ lpfc_issue_els_farpr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
1363 psli = &phba->sli; 1348 psli = &phba->sli;
1364 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ 1349 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */
1365 cmdsize = (sizeof (uint32_t) + sizeof (FARP)); 1350 cmdsize = (sizeof (uint32_t) + sizeof (FARP));
1366 if ((ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL)) == 0) { 1351 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL);
1367 return (1); 1352 if (!ndlp)
1368 } 1353 return 1;
1369 lpfc_nlp_init(phba, ndlp, nportid); 1354 lpfc_nlp_init(phba, ndlp, nportid);
1370 1355
1371 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, 1356 if ((elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry,
1372 ndlp, ELS_CMD_RNID)) == 0) { 1357 ndlp, ELS_CMD_RNID)) == 0) {
1373 mempool_free( ndlp, phba->nlp_mem_pool); 1358 mempool_free( ndlp, phba->nlp_mem_pool);
1374 return (1); 1359 return 1;
1375 } 1360 }
1376 1361
1377 icmd = &elsiocb->iocb; 1362 icmd = &elsiocb->iocb;
@@ -1405,11 +1390,11 @@ lpfc_issue_els_farpr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
1405 spin_unlock_irq(phba->host->host_lock); 1390 spin_unlock_irq(phba->host->host_lock);
1406 mempool_free( ndlp, phba->nlp_mem_pool); 1391 mempool_free( ndlp, phba->nlp_mem_pool);
1407 lpfc_els_free_iocb(phba, elsiocb); 1392 lpfc_els_free_iocb(phba, elsiocb);
1408 return (1); 1393 return 1;
1409 } 1394 }
1410 spin_unlock_irq(phba->host->host_lock); 1395 spin_unlock_irq(phba->host->host_lock);
1411 mempool_free( ndlp, phba->nlp_mem_pool); 1396 mempool_free( ndlp, phba->nlp_mem_pool);
1412 return (0); 1397 return 0;
1413} 1398}
1414 1399
1415void 1400void
@@ -1541,11 +1526,6 @@ lpfc_els_retry(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1541 1526
1542 case IOERR_SEQUENCE_TIMEOUT: 1527 case IOERR_SEQUENCE_TIMEOUT:
1543 retry = 1; 1528 retry = 1;
1544 if ((cmd == ELS_CMD_FLOGI)
1545 && (phba->fc_topology != TOPOLOGY_LOOP)) {
1546 delay = 1;
1547 maxretry = 48;
1548 }
1549 break; 1529 break;
1550 1530
1551 case IOERR_NO_RESOURCES: 1531 case IOERR_NO_RESOURCES:
@@ -1654,32 +1634,32 @@ lpfc_els_retry(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1654 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); 1634 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1655 ndlp->nlp_last_elscmd = cmd; 1635 ndlp->nlp_last_elscmd = cmd;
1656 1636
1657 return (1); 1637 return 1;
1658 } 1638 }
1659 switch (cmd) { 1639 switch (cmd) {
1660 case ELS_CMD_FLOGI: 1640 case ELS_CMD_FLOGI:
1661 lpfc_issue_els_flogi(phba, ndlp, cmdiocb->retry); 1641 lpfc_issue_els_flogi(phba, ndlp, cmdiocb->retry);
1662 return (1); 1642 return 1;
1663 case ELS_CMD_PLOGI: 1643 case ELS_CMD_PLOGI:
1664 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1644 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
1665 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); 1645 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1666 lpfc_issue_els_plogi(phba, ndlp, cmdiocb->retry); 1646 lpfc_issue_els_plogi(phba, ndlp, cmdiocb->retry);
1667 return (1); 1647 return 1;
1668 case ELS_CMD_ADISC: 1648 case ELS_CMD_ADISC:
1669 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1649 ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
1670 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST); 1650 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
1671 lpfc_issue_els_adisc(phba, ndlp, cmdiocb->retry); 1651 lpfc_issue_els_adisc(phba, ndlp, cmdiocb->retry);
1672 return (1); 1652 return 1;
1673 case ELS_CMD_PRLI: 1653 case ELS_CMD_PRLI:
1674 ndlp->nlp_state = NLP_STE_PRLI_ISSUE; 1654 ndlp->nlp_state = NLP_STE_PRLI_ISSUE;
1675 lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST); 1655 lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST);
1676 lpfc_issue_els_prli(phba, ndlp, cmdiocb->retry); 1656 lpfc_issue_els_prli(phba, ndlp, cmdiocb->retry);
1677 return (1); 1657 return 1;
1678 case ELS_CMD_LOGO: 1658 case ELS_CMD_LOGO:
1679 ndlp->nlp_state = NLP_STE_NPR_NODE; 1659 ndlp->nlp_state = NLP_STE_NPR_NODE;
1680 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); 1660 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1681 lpfc_issue_els_logo(phba, ndlp, cmdiocb->retry); 1661 lpfc_issue_els_logo(phba, ndlp, cmdiocb->retry);
1682 return (1); 1662 return 1;
1683 } 1663 }
1684 } 1664 }
1685 1665
@@ -1690,7 +1670,7 @@ lpfc_els_retry(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1690 phba->brd_no, 1670 phba->brd_no,
1691 cmd, ndlp->nlp_DID, cmdiocb->retry, ndlp->nlp_flag); 1671 cmd, ndlp->nlp_DID, cmdiocb->retry, ndlp->nlp_flag);
1692 1672
1693 return (0); 1673 return 0;
1694} 1674}
1695 1675
1696int 1676int
@@ -1780,11 +1760,12 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1780 /* ELS response tag <ulpIoTag> completes */ 1760 /* ELS response tag <ulpIoTag> completes */
1781 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1761 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
1782 "%d:0110 ELS response tag x%x completes " 1762 "%d:0110 ELS response tag x%x completes "
1783 "Data: x%x x%x x%x x%x x%x x%x\n", 1763 "Data: x%x x%x x%x x%x x%x x%x x%x\n",
1784 phba->brd_no, 1764 phba->brd_no,
1785 cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus, 1765 cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus,
1786 rspiocb->iocb.un.ulpWord[4], ndlp->nlp_DID, 1766 rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout,
1787 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 1767 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
1768 ndlp->nlp_rpi);
1788 1769
1789 if (mbox) { 1770 if (mbox) {
1790 if ((rspiocb->iocb.ulpStatus == 0) 1771 if ((rspiocb->iocb.ulpStatus == 0)
@@ -1846,7 +1827,7 @@ lpfc_els_rsp_acc(struct lpfc_hba * phba, uint32_t flag,
1846 if ((elsiocb = 1827 if ((elsiocb =
1847 lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry, 1828 lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry,
1848 ndlp, ELS_CMD_ACC)) == 0) { 1829 ndlp, ELS_CMD_ACC)) == 0) {
1849 return (1); 1830 return 1;
1850 } 1831 }
1851 icmd = &elsiocb->iocb; 1832 icmd = &elsiocb->iocb;
1852 icmd->ulpContext = oldcmd->ulpContext; /* Xri */ 1833 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
@@ -1859,7 +1840,7 @@ lpfc_els_rsp_acc(struct lpfc_hba * phba, uint32_t flag,
1859 if ((elsiocb = 1840 if ((elsiocb =
1860 lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry, 1841 lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry,
1861 ndlp, ELS_CMD_ACC)) == 0) { 1842 ndlp, ELS_CMD_ACC)) == 0) {
1862 return (1); 1843 return 1;
1863 } 1844 }
1864 icmd = &elsiocb->iocb; 1845 icmd = &elsiocb->iocb;
1865 icmd->ulpContext = oldcmd->ulpContext; /* Xri */ 1846 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
@@ -1873,7 +1854,7 @@ lpfc_els_rsp_acc(struct lpfc_hba * phba, uint32_t flag,
1873 memcpy(pcmd, &phba->fc_sparam, sizeof (struct serv_parm)); 1854 memcpy(pcmd, &phba->fc_sparam, sizeof (struct serv_parm));
1874 break; 1855 break;
1875 default: 1856 default:
1876 return (1); 1857 return 1;
1877 } 1858 }
1878 1859
1879 if (newnode) 1860 if (newnode)
@@ -1889,6 +1870,9 @@ lpfc_els_rsp_acc(struct lpfc_hba * phba, uint32_t flag,
1889 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 1870 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
1890 1871
1891 if (ndlp->nlp_flag & NLP_LOGO_ACC) { 1872 if (ndlp->nlp_flag & NLP_LOGO_ACC) {
1873 spin_lock_irq(phba->host->host_lock);
1874 ndlp->nlp_flag &= ~NLP_LOGO_ACC;
1875 spin_unlock_irq(phba->host->host_lock);
1892 elsiocb->iocb_cmpl = lpfc_cmpl_els_logo_acc; 1876 elsiocb->iocb_cmpl = lpfc_cmpl_els_logo_acc;
1893 } else { 1877 } else {
1894 elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 1878 elsiocb->iocb_cmpl = lpfc_cmpl_els_acc;
@@ -1900,9 +1884,9 @@ lpfc_els_rsp_acc(struct lpfc_hba * phba, uint32_t flag,
1900 spin_unlock_irq(phba->host->host_lock); 1884 spin_unlock_irq(phba->host->host_lock);
1901 if (rc == IOCB_ERROR) { 1885 if (rc == IOCB_ERROR) {
1902 lpfc_els_free_iocb(phba, elsiocb); 1886 lpfc_els_free_iocb(phba, elsiocb);
1903 return (1); 1887 return 1;
1904 } 1888 }
1905 return (0); 1889 return 0;
1906} 1890}
1907 1891
1908int 1892int
@@ -1924,7 +1908,7 @@ lpfc_els_rsp_reject(struct lpfc_hba * phba, uint32_t rejectError,
1924 cmdsize = 2 * sizeof (uint32_t); 1908 cmdsize = 2 * sizeof (uint32_t);
1925 if ((elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry, 1909 if ((elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry,
1926 ndlp, ELS_CMD_LS_RJT)) == 0) { 1910 ndlp, ELS_CMD_LS_RJT)) == 0) {
1927 return (1); 1911 return 1;
1928 } 1912 }
1929 1913
1930 icmd = &elsiocb->iocb; 1914 icmd = &elsiocb->iocb;
@@ -1952,9 +1936,9 @@ lpfc_els_rsp_reject(struct lpfc_hba * phba, uint32_t rejectError,
1952 spin_unlock_irq(phba->host->host_lock); 1936 spin_unlock_irq(phba->host->host_lock);
1953 if (rc == IOCB_ERROR) { 1937 if (rc == IOCB_ERROR) {
1954 lpfc_els_free_iocb(phba, elsiocb); 1938 lpfc_els_free_iocb(phba, elsiocb);
1955 return (1); 1939 return 1;
1956 } 1940 }
1957 return (0); 1941 return 0;
1958} 1942}
1959 1943
1960int 1944int
@@ -1977,7 +1961,7 @@ lpfc_els_rsp_adisc_acc(struct lpfc_hba * phba,
1977 cmdsize = sizeof (uint32_t) + sizeof (ADISC); 1961 cmdsize = sizeof (uint32_t) + sizeof (ADISC);
1978 if ((elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry, 1962 if ((elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry,
1979 ndlp, ELS_CMD_ACC)) == 0) { 1963 ndlp, ELS_CMD_ACC)) == 0) {
1980 return (1); 1964 return 1;
1981 } 1965 }
1982 1966
1983 /* Xmit ADISC ACC response tag <ulpIoTag> */ 1967 /* Xmit ADISC ACC response tag <ulpIoTag> */
@@ -2010,9 +1994,9 @@ lpfc_els_rsp_adisc_acc(struct lpfc_hba * phba,
2010 spin_unlock_irq(phba->host->host_lock); 1994 spin_unlock_irq(phba->host->host_lock);
2011 if (rc == IOCB_ERROR) { 1995 if (rc == IOCB_ERROR) {
2012 lpfc_els_free_iocb(phba, elsiocb); 1996 lpfc_els_free_iocb(phba, elsiocb);
2013 return (1); 1997 return 1;
2014 } 1998 }
2015 return (0); 1999 return 0;
2016} 2000}
2017 2001
2018int 2002int
@@ -2034,13 +2018,10 @@ lpfc_els_rsp_prli_acc(struct lpfc_hba * phba,
2034 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ 2018 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */
2035 2019
2036 cmdsize = sizeof (uint32_t) + sizeof (PRLI); 2020 cmdsize = sizeof (uint32_t) + sizeof (PRLI);
2037 if ((elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry, 2021 elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry, ndlp,
2038 ndlp, 2022 (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK)));
2039 (ELS_CMD_ACC | 2023 if (!elsiocb)
2040 (ELS_CMD_PRLI & ~ELS_RSP_MASK)))) == 2024 return 1;
2041 0) {
2042 return (1);
2043 }
2044 2025
2045 /* Xmit PRLI ACC response tag <ulpIoTag> */ 2026 /* Xmit PRLI ACC response tag <ulpIoTag> */
2046 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2027 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
@@ -2090,9 +2071,9 @@ lpfc_els_rsp_prli_acc(struct lpfc_hba * phba,
2090 spin_unlock_irq(phba->host->host_lock); 2071 spin_unlock_irq(phba->host->host_lock);
2091 if (rc == IOCB_ERROR) { 2072 if (rc == IOCB_ERROR) {
2092 lpfc_els_free_iocb(phba, elsiocb); 2073 lpfc_els_free_iocb(phba, elsiocb);
2093 return (1); 2074 return 1;
2094 } 2075 }
2095 return (0); 2076 return 0;
2096} 2077}
2097 2078
2098static int 2079static int
@@ -2120,7 +2101,7 @@ lpfc_els_rsp_rnid_acc(struct lpfc_hba * phba,
2120 2101
2121 if ((elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry, 2102 if ((elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry,
2122 ndlp, ELS_CMD_ACC)) == 0) { 2103 ndlp, ELS_CMD_ACC)) == 0) {
2123 return (1); 2104 return 1;
2124 } 2105 }
2125 2106
2126 /* Xmit RNID ACC response tag <ulpIoTag> */ 2107 /* Xmit RNID ACC response tag <ulpIoTag> */
@@ -2173,9 +2154,9 @@ lpfc_els_rsp_rnid_acc(struct lpfc_hba * phba,
2173 spin_unlock_irq(phba->host->host_lock); 2154 spin_unlock_irq(phba->host->host_lock);
2174 if (rc == IOCB_ERROR) { 2155 if (rc == IOCB_ERROR) {
2175 lpfc_els_free_iocb(phba, elsiocb); 2156 lpfc_els_free_iocb(phba, elsiocb);
2176 return (1); 2157 return 1;
2177 } 2158 }
2178 return (0); 2159 return 0;
2179} 2160}
2180 2161
2181int 2162int
@@ -2268,7 +2249,7 @@ lpfc_els_flush_rscn(struct lpfc_hba * phba)
2268 phba->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY); 2249 phba->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY);
2269 spin_unlock_irq(phba->host->host_lock); 2250 spin_unlock_irq(phba->host->host_lock);
2270 lpfc_can_disctmo(phba); 2251 lpfc_can_disctmo(phba);
2271 return (0); 2252 return 0;
2272} 2253}
2273 2254
2274int 2255int
@@ -2289,7 +2270,7 @@ lpfc_rscn_payload_check(struct lpfc_hba * phba, uint32_t did)
2289 2270
2290 /* If we are doing a FULL RSCN rediscovery, match everything */ 2271 /* If we are doing a FULL RSCN rediscovery, match everything */
2291 if (phba->fc_flag & FC_RSCN_DISCOVERY) { 2272 if (phba->fc_flag & FC_RSCN_DISCOVERY) {
2292 return (did); 2273 return did;
2293 } 2274 }
2294 2275
2295 for (i = 0; i < phba->fc_rscn_id_cnt; i++) { 2276 for (i = 0; i < phba->fc_rscn_id_cnt; i++) {
@@ -2337,7 +2318,7 @@ lpfc_rscn_payload_check(struct lpfc_hba * phba, uint32_t did)
2337 } 2318 }
2338 } 2319 }
2339 } 2320 }
2340 return (match); 2321 return match;
2341} 2322}
2342 2323
2343static int 2324static int
@@ -2379,7 +2360,7 @@ lpfc_rscn_recovery_check(struct lpfc_hba * phba)
2379 } 2360 }
2380 } 2361 }
2381 } 2362 }
2382 return (0); 2363 return 0;
2383} 2364}
2384 2365
2385static int 2366static int
@@ -2415,7 +2396,7 @@ lpfc_els_rcv_rscn(struct lpfc_hba * phba,
2415 if (phba->hba_state < LPFC_NS_QRY) { 2396 if (phba->hba_state < LPFC_NS_QRY) {
2416 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 2397 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL,
2417 newnode); 2398 newnode);
2418 return (0); 2399 return 0;
2419 } 2400 }
2420 2401
2421 /* If we are already processing an RSCN, save the received 2402 /* If we are already processing an RSCN, save the received
@@ -2457,7 +2438,7 @@ lpfc_els_rcv_rscn(struct lpfc_hba * phba,
2457 2438
2458 /* send RECOVERY event for ALL nodes that match RSCN payload */ 2439 /* send RECOVERY event for ALL nodes that match RSCN payload */
2459 lpfc_rscn_recovery_check(phba); 2440 lpfc_rscn_recovery_check(phba);
2460 return (0); 2441 return 0;
2461 } 2442 }
2462 2443
2463 phba->fc_flag |= FC_RSCN_MODE; 2444 phba->fc_flag |= FC_RSCN_MODE;
@@ -2476,7 +2457,7 @@ lpfc_els_rcv_rscn(struct lpfc_hba * phba,
2476 /* send RECOVERY event for ALL nodes that match RSCN payload */ 2457 /* send RECOVERY event for ALL nodes that match RSCN payload */
2477 lpfc_rscn_recovery_check(phba); 2458 lpfc_rscn_recovery_check(phba);
2478 2459
2479 return (lpfc_els_handle_rscn(phba)); 2460 return lpfc_els_handle_rscn(phba);
2480} 2461}
2481 2462
2482int 2463int
@@ -2498,27 +2479,27 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba)
2498 2479
2499 /* To process RSCN, first compare RSCN data with NameServer */ 2480 /* To process RSCN, first compare RSCN data with NameServer */
2500 phba->fc_ns_retry = 0; 2481 phba->fc_ns_retry = 0;
2501 if ((ndlp = lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED, 2482 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED, NameServer_DID);
2502 NameServer_DID))) { 2483 if (ndlp) {
2503 /* Good ndlp, issue CT Request to NameServer */ 2484 /* Good ndlp, issue CT Request to NameServer */
2504 if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) == 0) { 2485 if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) == 0) {
2505 /* Wait for NameServer query cmpl before we can 2486 /* Wait for NameServer query cmpl before we can
2506 continue */ 2487 continue */
2507 return (1); 2488 return 1;
2508 } 2489 }
2509 } else { 2490 } else {
2510 /* If login to NameServer does not exist, issue one */ 2491 /* If login to NameServer does not exist, issue one */
2511 /* Good status, issue PLOGI to NameServer */ 2492 /* Good status, issue PLOGI to NameServer */
2512 if ((ndlp = 2493 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, NameServer_DID);
2513 lpfc_findnode_did(phba, NLP_SEARCH_ALL, NameServer_DID))) { 2494 if (ndlp) {
2514 /* Wait for NameServer login cmpl before we can 2495 /* Wait for NameServer login cmpl before we can
2515 continue */ 2496 continue */
2516 return (1); 2497 return 1;
2517 } 2498 }
2518 if ((ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL)) 2499 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL);
2519 == 0) { 2500 if (!ndlp) {
2520 lpfc_els_flush_rscn(phba); 2501 lpfc_els_flush_rscn(phba);
2521 return (0); 2502 return 0;
2522 } else { 2503 } else {
2523 lpfc_nlp_init(phba, ndlp, NameServer_DID); 2504 lpfc_nlp_init(phba, ndlp, NameServer_DID);
2524 ndlp->nlp_type |= NLP_FABRIC; 2505 ndlp->nlp_type |= NLP_FABRIC;
@@ -2526,12 +2507,12 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba)
2526 lpfc_issue_els_plogi(phba, ndlp, 0); 2507 lpfc_issue_els_plogi(phba, ndlp, 0);
2527 /* Wait for NameServer login cmpl before we can 2508 /* Wait for NameServer login cmpl before we can
2528 continue */ 2509 continue */
2529 return (1); 2510 return 1;
2530 } 2511 }
2531 } 2512 }
2532 2513
2533 lpfc_els_flush_rscn(phba); 2514 lpfc_els_flush_rscn(phba);
2534 return (0); 2515 return 0;
2535} 2516}
2536 2517
2537static int 2518static int
@@ -2565,7 +2546,7 @@ lpfc_els_rcv_flogi(struct lpfc_hba * phba,
2565 "%d:0113 An FLOGI ELS command x%x was received " 2546 "%d:0113 An FLOGI ELS command x%x was received "
2566 "from DID x%x in Loop Mode\n", 2547 "from DID x%x in Loop Mode\n",
2567 phba->brd_no, cmd, did); 2548 phba->brd_no, cmd, did);
2568 return (1); 2549 return 1;
2569 } 2550 }
2570 2551
2571 did = Fabric_DID; 2552 did = Fabric_DID;
@@ -2581,7 +2562,7 @@ lpfc_els_rcv_flogi(struct lpfc_hba * phba,
2581 if (!rc) { 2562 if (!rc) {
2582 if ((mbox = mempool_alloc(phba->mbox_mem_pool, 2563 if ((mbox = mempool_alloc(phba->mbox_mem_pool,
2583 GFP_KERNEL)) == 0) { 2564 GFP_KERNEL)) == 0) {
2584 return (1); 2565 return 1;
2585 } 2566 }
2586 lpfc_linkdown(phba); 2567 lpfc_linkdown(phba);
2587 lpfc_init_link(phba, mbox, 2568 lpfc_init_link(phba, mbox,
@@ -2594,7 +2575,7 @@ lpfc_els_rcv_flogi(struct lpfc_hba * phba,
2594 if (rc == MBX_NOT_FINISHED) { 2575 if (rc == MBX_NOT_FINISHED) {
2595 mempool_free( mbox, phba->mbox_mem_pool); 2576 mempool_free( mbox, phba->mbox_mem_pool);
2596 } 2577 }
2597 return (1); 2578 return 1;
2598 } 2579 }
2599 else if (rc > 0) { /* greater than */ 2580 else if (rc > 0) { /* greater than */
2600 spin_lock_irq(phba->host->host_lock); 2581 spin_lock_irq(phba->host->host_lock);
@@ -2610,13 +2591,13 @@ lpfc_els_rcv_flogi(struct lpfc_hba * phba,
2610 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; 2591 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
2611 stat.un.b.vendorUnique = 0; 2592 stat.un.b.vendorUnique = 0;
2612 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp); 2593 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
2613 return (1); 2594 return 1;
2614 } 2595 }
2615 2596
2616 /* Send back ACC */ 2597 /* Send back ACC */
2617 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, newnode); 2598 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, newnode);
2618 2599
2619 return (0); 2600 return 0;
2620} 2601}
2621 2602
2622static int 2603static int
@@ -2654,7 +2635,7 @@ lpfc_els_rcv_rnid(struct lpfc_hba * phba,
2654 stat.un.b.vendorUnique = 0; 2635 stat.un.b.vendorUnique = 0;
2655 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp); 2636 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
2656 } 2637 }
2657 return (0); 2638 return 0;
2658} 2639}
2659 2640
2660static int 2641static int
@@ -2702,10 +2683,10 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
2702 2683
2703 cmdsize = sizeof(RPS_RSP) + sizeof(uint32_t); 2684 cmdsize = sizeof(RPS_RSP) + sizeof(uint32_t);
2704 mempool_free( pmb, phba->mbox_mem_pool); 2685 mempool_free( pmb, phba->mbox_mem_pool);
2705 if ((elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, 3, 2686 elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, lpfc_max_els_tries,
2706 ndlp, ELS_CMD_ACC)) == 0) { 2687 ndlp, ELS_CMD_ACC);
2688 if (!elsiocb)
2707 return; 2689 return;
2708 }
2709 2690
2710 icmd = &elsiocb->iocb; 2691 icmd = &elsiocb->iocb;
2711 icmd->ulpContext = xri; 2692 icmd->ulpContext = xri;
@@ -2926,7 +2907,7 @@ lpfc_els_rcv_farp(struct lpfc_hba * phba,
2926 2907
2927 /* We will only support match on WWPN or WWNN */ 2908 /* We will only support match on WWPN or WWNN */
2928 if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) { 2909 if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) {
2929 return (0); 2910 return 0;
2930 } 2911 }
2931 2912
2932 cnt = 0; 2913 cnt = 0;
@@ -2960,7 +2941,7 @@ lpfc_els_rcv_farp(struct lpfc_hba * phba,
2960 } 2941 }
2961 } 2942 }
2962 } 2943 }
2963 return (0); 2944 return 0;
2964} 2945}
2965 2946
2966static int 2947static int
@@ -3026,14 +3007,14 @@ lpfc_els_rcv_fan(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
3026 /* This node has switched fabrics. An FLOGI is required 3007 /* This node has switched fabrics. An FLOGI is required
3027 * after the timeout 3008 * after the timeout
3028 */ 3009 */
3029 return (0); 3010 return 0;
3030 } 3011 }
3031 3012
3032 /* Start discovery */ 3013 /* Start discovery */
3033 lpfc_disc_start(phba); 3014 lpfc_disc_start(phba);
3034 } 3015 }
3035 3016
3036 return (0); 3017 return 0;
3037} 3018}
3038 3019
3039void 3020void
@@ -3156,7 +3137,6 @@ lpfc_els_flush_cmd(struct lpfc_hba * phba)
3156 struct lpfc_dmabuf *pcmd; 3137 struct lpfc_dmabuf *pcmd;
3157 uint32_t *elscmd; 3138 uint32_t *elscmd;
3158 uint32_t els_command; 3139 uint32_t els_command;
3159 uint32_t remote_ID;
3160 3140
3161 pring = &phba->sli.ring[LPFC_ELS_RING]; 3141 pring = &phba->sli.ring[LPFC_ELS_RING];
3162 spin_lock_irq(phba->host->host_lock); 3142 spin_lock_irq(phba->host->host_lock);
@@ -3179,18 +3159,6 @@ lpfc_els_flush_cmd(struct lpfc_hba * phba)
3179 elscmd = (uint32_t *) (pcmd->virt); 3159 elscmd = (uint32_t *) (pcmd->virt);
3180 els_command = *elscmd; 3160 els_command = *elscmd;
3181 3161
3182 if (cmd->ulpCommand == CMD_GEN_REQUEST64_CR) {
3183 struct lpfc_nodelist *ndlp;
3184
3185 ndlp = lpfc_findnode_rpi(phba, cmd->ulpContext);
3186 remote_ID = ndlp->nlp_DID;
3187 if (phba->hba_state == LPFC_HBA_READY) {
3188 continue;
3189 }
3190 } else {
3191 remote_ID = cmd->un.elsreq64.remoteID;
3192 }
3193
3194 list_del(&piocb->list); 3162 list_del(&piocb->list);
3195 pring->txcmplq_cnt--; 3163 pring->txcmplq_cnt--;
3196 3164
@@ -3216,18 +3184,6 @@ lpfc_els_flush_cmd(struct lpfc_hba * phba)
3216 elscmd = (uint32_t *) (pcmd->virt); 3184 elscmd = (uint32_t *) (pcmd->virt);
3217 els_command = *elscmd; 3185 els_command = *elscmd;
3218 3186
3219 if (cmd->ulpCommand == CMD_GEN_REQUEST64_CR) {
3220 struct lpfc_nodelist *ndlp;
3221
3222 ndlp = lpfc_findnode_rpi(phba, cmd->ulpContext);
3223 remote_ID = ndlp->nlp_DID;
3224 if (phba->hba_state == LPFC_HBA_READY) {
3225 continue;
3226 }
3227 } else {
3228 remote_ID = cmd->un.elsreq64.remoteID;
3229 }
3230
3231 list_del(&piocb->list); 3187 list_del(&piocb->list);
3232 pring->txcmplq_cnt--; 3188 pring->txcmplq_cnt--;
3233 3189
@@ -3311,10 +3267,11 @@ lpfc_els_unsol_event(struct lpfc_hba * phba,
3311 } 3267 }
3312 3268
3313 did = icmd->un.rcvels.remoteID; 3269 did = icmd->un.rcvels.remoteID;
3314 if ((ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did)) == 0) { 3270 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did);
3271 if (!ndlp) {
3315 /* Cannot find existing Fabric ndlp, so allocate a new one */ 3272 /* Cannot find existing Fabric ndlp, so allocate a new one */
3316 if ((ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL)) 3273 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL);
3317 == 0) { 3274 if (!ndlp) {
3318 lpfc_mbuf_free(phba, mp->virt, mp->phys); 3275 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3319 kfree(mp); 3276 kfree(mp);
3320 drop_cmd = 1; 3277 drop_cmd = 1;
@@ -3475,8 +3432,9 @@ dropit:
3475 if (drop_cmd == 1) { 3432 if (drop_cmd == 1) {
3476 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 3433 lpfc_printf_log(phba, KERN_ERR, LOG_ELS,
3477 "%d:0111 Dropping received ELS cmd " 3434 "%d:0111 Dropping received ELS cmd "
3478 "Data: x%x x%x\n", phba->brd_no, 3435 "Data: x%x x%x x%x\n", phba->brd_no,
3479 icmd->ulpStatus, icmd->un.ulpWord[4]); 3436 icmd->ulpStatus, icmd->un.ulpWord[4],
3437 icmd->ulpTimeout);
3480 phba->fc_stat.elsRcvDrop++; 3438 phba->fc_stat.elsRcvDrop++;
3481 } 3439 }
3482 return; 3440 return;
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index a1f751e7940..5c396171ebe 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -283,16 +283,18 @@ lpfc_linkdown(struct lpfc_hba * phba)
283{ 283{
284 struct lpfc_sli *psli; 284 struct lpfc_sli *psli;
285 struct lpfc_nodelist *ndlp, *next_ndlp; 285 struct lpfc_nodelist *ndlp, *next_ndlp;
286 struct list_head *listp; 286 struct list_head *listp, *node_list[7];
287 struct list_head *node_list[7];
288 LPFC_MBOXQ_t *mb; 287 LPFC_MBOXQ_t *mb;
289 int rc, i; 288 int rc, i;
290 289
291 psli = &phba->sli; 290 psli = &phba->sli;
292 291
293 spin_lock_irq(phba->host->host_lock); 292 /* sysfs or selective reset may call this routine to clean up */
294 phba->hba_state = LPFC_LINK_DOWN; 293 if (phba->hba_state > LPFC_LINK_DOWN) {
295 spin_unlock_irq(phba->host->host_lock); 294 spin_lock_irq(phba->host->host_lock);
295 phba->hba_state = LPFC_LINK_DOWN;
296 spin_unlock_irq(phba->host->host_lock);
297 }
296 298
297 /* Clean up any firmware default rpi's */ 299 /* Clean up any firmware default rpi's */
298 if ((mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL))) { 300 if ((mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL))) {
@@ -324,32 +326,20 @@ lpfc_linkdown(struct lpfc_hba * phba)
324 continue; 326 continue;
325 327
326 list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) { 328 list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) {
327 /* Fabric nodes are not handled thru state machine for 329
328 link down */ 330 rc = lpfc_disc_state_machine(phba, ndlp, NULL,
329 if (ndlp->nlp_type & NLP_FABRIC) { 331 NLP_EVT_DEVICE_RECOVERY);
330 /* Remove ALL Fabric nodes except Fabric_DID */ 332
331 if (ndlp->nlp_DID != Fabric_DID) { 333 /* Check config parameter use-adisc or FCP-2 */
332 /* Take it off current list and free */ 334 if ((rc != NLP_STE_FREED_NODE) &&
333 lpfc_nlp_list(phba, ndlp, 335 (phba->cfg_use_adisc == 0) &&
334 NLP_NO_LIST); 336 !(ndlp->nlp_fcp_info &
335 } 337 NLP_FCP_2_DEVICE)) {
336 } 338 /* We know we will have to relogin, so
337 else { 339 * unreglogin the rpi right now to fail
338 340 * any outstanding I/Os quickly.
339 rc = lpfc_disc_state_machine(phba, ndlp, NULL, 341 */
340 NLP_EVT_DEVICE_RECOVERY); 342 lpfc_unreg_rpi(phba, ndlp);
341
342 /* Check config parameter use-adisc or FCP-2 */
343 if ((rc != NLP_STE_FREED_NODE) &&
344 (phba->cfg_use_adisc == 0) &&
345 !(ndlp->nlp_fcp_info &
346 NLP_FCP_2_DEVICE)) {
347 /* We know we will have to relogin, so
348 * unreglogin the rpi right now to fail
349 * any outstanding I/Os quickly.
350 */
351 lpfc_unreg_rpi(phba, ndlp);
352 }
353 } 343 }
354 } 344 }
355 } 345 }
@@ -391,6 +381,8 @@ static int
391lpfc_linkup(struct lpfc_hba * phba) 381lpfc_linkup(struct lpfc_hba * phba)
392{ 382{
393 struct lpfc_nodelist *ndlp, *next_ndlp; 383 struct lpfc_nodelist *ndlp, *next_ndlp;
384 struct list_head *listp, *node_list[7];
385 int i;
394 386
395 spin_lock_irq(phba->host->host_lock); 387 spin_lock_irq(phba->host->host_lock);
396 phba->hba_state = LPFC_LINK_UP; 388 phba->hba_state = LPFC_LINK_UP;
@@ -401,14 +393,33 @@ lpfc_linkup(struct lpfc_hba * phba)
401 spin_unlock_irq(phba->host->host_lock); 393 spin_unlock_irq(phba->host->host_lock);
402 394
403 395
404 /* 396 node_list[0] = &phba->fc_plogi_list;
405 * Clean up old Fabric NLP_FABRIC logins. 397 node_list[1] = &phba->fc_adisc_list;
406 */ 398 node_list[2] = &phba->fc_reglogin_list;
407 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpunmap_list, 399 node_list[3] = &phba->fc_prli_list;
408 nlp_listp) { 400 node_list[4] = &phba->fc_nlpunmap_list;
409 if (ndlp->nlp_DID == Fabric_DID) { 401 node_list[5] = &phba->fc_nlpmap_list;
410 /* Take it off current list and free */ 402 node_list[6] = &phba->fc_npr_list;
411 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 403 for (i = 0; i < 7; i++) {
404 listp = node_list[i];
405 if (list_empty(listp))
406 continue;
407
408 list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) {
409 if (phba->fc_flag & FC_LBIT) {
410 if (ndlp->nlp_type & NLP_FABRIC) {
411 /* On Linkup its safe to clean up the
412 * ndlp from Fabric connections.
413 */
414 lpfc_nlp_list(phba, ndlp,
415 NLP_UNUSED_LIST);
416 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
417 /* Fail outstanding IO now since device
418 * is marked for PLOGI.
419 */
420 lpfc_unreg_rpi(phba, ndlp);
421 }
422 }
412 } 423 }
413 } 424 }
414 425
@@ -784,6 +795,13 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
784 795
785 memcpy(&phba->alpa_map[0], mp->virt, 128); 796 memcpy(&phba->alpa_map[0], mp->virt, 128);
786 797
798 spin_lock_irq(phba->host->host_lock);
799 if (la->pb)
800 phba->fc_flag |= FC_BYPASSED_MODE;
801 else
802 phba->fc_flag &= ~FC_BYPASSED_MODE;
803 spin_unlock_irq(phba->host->host_lock);
804
787 if (((phba->fc_eventTag + 1) < la->eventTag) || 805 if (((phba->fc_eventTag + 1) < la->eventTag) ||
788 (phba->fc_eventTag == la->eventTag)) { 806 (phba->fc_eventTag == la->eventTag)) {
789 phba->fc_stat.LinkMultiEvent++; 807 phba->fc_stat.LinkMultiEvent++;
@@ -904,32 +922,36 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
904 */ 922 */
905 lpfc_issue_els_scr(phba, SCR_DID, 0); 923 lpfc_issue_els_scr(phba, SCR_DID, 0);
906 924
907 /* Allocate a new node instance. If the pool is empty, just 925 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, NameServer_DID);
908 * start the discovery process and skip the Nameserver login 926 if (!ndlp) {
909 * process. This is attempted again later on. Otherwise, issue 927 /* Allocate a new node instance. If the pool is empty,
910 * a Port Login (PLOGI) to the NameServer 928 * start the discovery process and skip the Nameserver
911 */ 929 * login process. This is attempted again later on.
912 if ((ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL)) 930 * Otherwise, issue a Port Login (PLOGI) to NameServer.
913 == 0) { 931 */
914 lpfc_disc_start(phba); 932 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_ATOMIC);
915 } else { 933 if (!ndlp) {
916 lpfc_nlp_init(phba, ndlp, NameServer_DID); 934 lpfc_disc_start(phba);
917 ndlp->nlp_type |= NLP_FABRIC; 935 lpfc_mbuf_free(phba, mp->virt, mp->phys);
918 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 936 kfree(mp);
919 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); 937 mempool_free( pmb, phba->mbox_mem_pool);
920 lpfc_issue_els_plogi(phba, ndlp, 0); 938 return;
921 if (phba->cfg_fdmi_on) { 939 } else {
922 if ((ndlp_fdmi = mempool_alloc( 940 lpfc_nlp_init(phba, ndlp, NameServer_DID);
923 phba->nlp_mem_pool, 941 ndlp->nlp_type |= NLP_FABRIC;
924 GFP_KERNEL))) { 942 }
925 lpfc_nlp_init(phba, ndlp_fdmi, 943 }
926 FDMI_DID); 944 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
927 ndlp_fdmi->nlp_type |= NLP_FABRIC; 945 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
928 ndlp_fdmi->nlp_state = 946 lpfc_issue_els_plogi(phba, ndlp, 0);
929 NLP_STE_PLOGI_ISSUE; 947 if (phba->cfg_fdmi_on) {
930 lpfc_issue_els_plogi(phba, ndlp_fdmi, 948 ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool,
931 0); 949 GFP_KERNEL);
932 } 950 if (ndlp_fdmi) {
951 lpfc_nlp_init(phba, ndlp_fdmi, FDMI_DID);
952 ndlp_fdmi->nlp_type |= NLP_FABRIC;
953 ndlp_fdmi->nlp_state = NLP_STE_PLOGI_ISSUE;
954 lpfc_issue_els_plogi(phba, ndlp_fdmi, 0);
933 } 955 }
934 } 956 }
935 } 957 }
@@ -937,7 +959,6 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
937 lpfc_mbuf_free(phba, mp->virt, mp->phys); 959 lpfc_mbuf_free(phba, mp->virt, mp->phys);
938 kfree(mp); 960 kfree(mp);
939 mempool_free( pmb, phba->mbox_mem_pool); 961 mempool_free( pmb, phba->mbox_mem_pool);
940
941 return; 962 return;
942} 963}
943 964
@@ -1241,16 +1262,9 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
1241 list_add_tail(&nlp->nlp_listp, &phba->fc_npr_list); 1262 list_add_tail(&nlp->nlp_listp, &phba->fc_npr_list);
1242 phba->fc_npr_cnt++; 1263 phba->fc_npr_cnt++;
1243 1264
1244 /* 1265 if (!(nlp->nlp_flag & NLP_NODEV_TMO)) {
1245 * Sanity check for Fabric entity.
1246 * Set nodev_tmo for NPR state, for Fabric use 1 sec.
1247 */
1248 if (nlp->nlp_type & NLP_FABRIC) {
1249 mod_timer(&nlp->nlp_tmofunc, jiffies + HZ);
1250 }
1251 else {
1252 mod_timer(&nlp->nlp_tmofunc, 1266 mod_timer(&nlp->nlp_tmofunc,
1253 jiffies + HZ * phba->cfg_nodev_tmo); 1267 jiffies + HZ * phba->cfg_nodev_tmo);
1254 } 1268 }
1255 spin_lock_irq(phba->host->host_lock); 1269 spin_lock_irq(phba->host->host_lock);
1256 nlp->nlp_flag |= NLP_NODEV_TMO; 1270 nlp->nlp_flag |= NLP_NODEV_TMO;
@@ -1314,7 +1328,15 @@ lpfc_set_disctmo(struct lpfc_hba * phba)
1314{ 1328{
1315 uint32_t tmo; 1329 uint32_t tmo;
1316 1330
1317 tmo = ((phba->fc_ratov * 2) + 1); 1331 if (phba->hba_state == LPFC_LOCAL_CFG_LINK) {
1332 /* For FAN, timeout should be greater then edtov */
1333 tmo = (((phba->fc_edtov + 999) / 1000) + 1);
1334 } else {
1335 /* Normal discovery timeout should be > then ELS/CT timeout
1336 * FC spec states we need 3 * ratov for CT requests
1337 */
1338 tmo = ((phba->fc_ratov * 3) + 3);
1339 }
1318 1340
1319 mod_timer(&phba->fc_disctmo, jiffies + HZ * tmo); 1341 mod_timer(&phba->fc_disctmo, jiffies + HZ * tmo);
1320 spin_lock_irq(phba->host->host_lock); 1342 spin_lock_irq(phba->host->host_lock);
@@ -1846,8 +1868,9 @@ lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did)
1846 struct lpfc_nodelist *ndlp; 1868 struct lpfc_nodelist *ndlp;
1847 uint32_t flg; 1869 uint32_t flg;
1848 1870
1849 if ((ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did)) == 0) { 1871 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did);
1850 if ((phba->hba_state == LPFC_HBA_READY) && 1872 if (!ndlp) {
1873 if ((phba->fc_flag & FC_RSCN_MODE) &&
1851 ((lpfc_rscn_payload_check(phba, did) == 0))) 1874 ((lpfc_rscn_payload_check(phba, did) == 0)))
1852 return NULL; 1875 return NULL;
1853 ndlp = (struct lpfc_nodelist *) 1876 ndlp = (struct lpfc_nodelist *)
@@ -1860,10 +1883,23 @@ lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did)
1860 ndlp->nlp_flag |= NLP_NPR_2B_DISC; 1883 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
1861 return ndlp; 1884 return ndlp;
1862 } 1885 }
1863 if ((phba->hba_state == LPFC_HBA_READY) && 1886 if (phba->fc_flag & FC_RSCN_MODE) {
1864 (phba->fc_flag & FC_RSCN_MODE)) {
1865 if (lpfc_rscn_payload_check(phba, did)) { 1887 if (lpfc_rscn_payload_check(phba, did)) {
1866 ndlp->nlp_flag |= NLP_NPR_2B_DISC; 1888 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
1889
1890 /* Since this node is marked for discovery,
1891 * delay timeout is not needed.
1892 */
1893 if (ndlp->nlp_flag & NLP_DELAY_TMO) {
1894 ndlp->nlp_flag &= ~NLP_DELAY_TMO;
1895 spin_unlock_irq(phba->host->host_lock);
1896 del_timer_sync(&ndlp->nlp_delayfunc);
1897 spin_lock_irq(phba->host->host_lock);
1898 if (!list_empty(&ndlp->els_retry_evt.
1899 evt_listp))
1900 list_del_init(&ndlp->els_retry_evt.
1901 evt_listp);
1902 }
1867 } 1903 }
1868 else { 1904 else {
1869 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; 1905 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
@@ -1872,10 +1908,8 @@ lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did)
1872 } 1908 }
1873 else { 1909 else {
1874 flg = ndlp->nlp_flag & NLP_LIST_MASK; 1910 flg = ndlp->nlp_flag & NLP_LIST_MASK;
1875 if ((flg == NLP_ADISC_LIST) || 1911 if ((flg == NLP_ADISC_LIST) || (flg == NLP_PLOGI_LIST))
1876 (flg == NLP_PLOGI_LIST)) {
1877 return NULL; 1912 return NULL;
1878 }
1879 ndlp->nlp_state = NLP_STE_NPR_NODE; 1913 ndlp->nlp_state = NLP_STE_NPR_NODE;
1880 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); 1914 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1881 ndlp->nlp_flag |= NLP_NPR_2B_DISC; 1915 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
@@ -2174,7 +2208,7 @@ static void
2174lpfc_disc_timeout_handler(struct lpfc_hba *phba) 2208lpfc_disc_timeout_handler(struct lpfc_hba *phba)
2175{ 2209{
2176 struct lpfc_sli *psli; 2210 struct lpfc_sli *psli;
2177 struct lpfc_nodelist *ndlp; 2211 struct lpfc_nodelist *ndlp, *next_ndlp;
2178 LPFC_MBOXQ_t *clearlambox, *initlinkmbox; 2212 LPFC_MBOXQ_t *clearlambox, *initlinkmbox;
2179 int rc, clrlaerr = 0; 2213 int rc, clrlaerr = 0;
2180 2214
@@ -2201,10 +2235,20 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba)
2201 "%d:0221 FAN timeout\n", 2235 "%d:0221 FAN timeout\n",
2202 phba->brd_no); 2236 phba->brd_no);
2203 2237
2204 /* Forget about FAN, Start discovery by sending a FLOGI 2238 /* Start discovery by sending FLOGI, clean up old rpis */
2205 * hba_state is identically LPFC_FLOGI while waiting for FLOGI 2239 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list,
2206 * cmpl 2240 nlp_listp) {
2207 */ 2241 if (ndlp->nlp_type & NLP_FABRIC) {
2242 /* Clean up the ndlp on Fabric connections */
2243 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
2244 }
2245 else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
2246 /* Fail outstanding IO now since device
2247 * is marked for PLOGI.
2248 */
2249 lpfc_unreg_rpi(phba, ndlp);
2250 }
2251 }
2208 phba->hba_state = LPFC_FLOGI; 2252 phba->hba_state = LPFC_FLOGI;
2209 lpfc_set_disctmo(phba); 2253 lpfc_set_disctmo(phba);
2210 lpfc_initial_flogi(phba); 2254 lpfc_initial_flogi(phba);
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 1c04ea353ff..a580e1e5067 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -46,13 +46,13 @@ lpfc_check_adisc(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
46 * table entry for that node. 46 * table entry for that node.
47 */ 47 */
48 if (memcmp(nn, &ndlp->nlp_nodename, sizeof (struct lpfc_name)) != 0) 48 if (memcmp(nn, &ndlp->nlp_nodename, sizeof (struct lpfc_name)) != 0)
49 return (0); 49 return 0;
50 50
51 if (memcmp(pn, &ndlp->nlp_portname, sizeof (struct lpfc_name)) != 0) 51 if (memcmp(pn, &ndlp->nlp_portname, sizeof (struct lpfc_name)) != 0)
52 return (0); 52 return 0;
53 53
54 /* we match, return success */ 54 /* we match, return success */
55 return (1); 55 return 1;
56} 56}
57 57
58int 58int
@@ -159,7 +159,7 @@ lpfc_check_elscmpl_iocb(struct lpfc_hba * phba,
159 } 159 }
160 ptr = NULL; 160 ptr = NULL;
161 } 161 }
162 return (ptr); 162 return ptr;
163} 163}
164 164
165 165
@@ -266,7 +266,7 @@ lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
266 if (!list_empty(&ndlp->els_retry_evt.evt_listp)) 266 if (!list_empty(&ndlp->els_retry_evt.evt_listp))
267 list_del_init(&ndlp->els_retry_evt.evt_listp); 267 list_del_init(&ndlp->els_retry_evt.evt_listp);
268 } 268 }
269 return (0); 269 return 0;
270} 270}
271 271
272static int 272static int
@@ -321,7 +321,7 @@ lpfc_rcv_plogi(struct lpfc_hba * phba,
321 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 321 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
322 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; 322 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
323 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp); 323 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
324 return (0); 324 return 0;
325 } 325 }
326 icmd = &cmdiocb->iocb; 326 icmd = &cmdiocb->iocb;
327 327
@@ -362,7 +362,7 @@ lpfc_rcv_plogi(struct lpfc_hba * phba,
362 case NLP_STE_UNMAPPED_NODE: 362 case NLP_STE_UNMAPPED_NODE:
363 case NLP_STE_MAPPED_NODE: 363 case NLP_STE_MAPPED_NODE:
364 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, 0); 364 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, 0);
365 return (1); 365 return 1;
366 } 366 }
367 367
368 if ((phba->fc_flag & FC_PT2PT) 368 if ((phba->fc_flag & FC_PT2PT)
@@ -409,13 +409,13 @@ lpfc_rcv_plogi(struct lpfc_hba * phba,
409 } 409 }
410 ndlp->nlp_flag |= NLP_RCV_PLOGI; 410 ndlp->nlp_flag |= NLP_RCV_PLOGI;
411 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0); 411 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0);
412 return (1); 412 return 1;
413 413
414out: 414out:
415 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 415 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
416 stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE; 416 stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE;
417 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp); 417 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
418 return (0); 418 return 0;
419} 419}
420 420
421static int 421static int
@@ -456,7 +456,7 @@ lpfc_rcv_padisc(struct lpfc_hba * phba,
456 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, 456 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp,
457 NULL, 0); 457 NULL, 0);
458 } 458 }
459 return (1); 459 return 1;
460 } 460 }
461 /* Reject this request because invalid parameters */ 461 /* Reject this request because invalid parameters */
462 stat.un.b.lsRjtRsvd0 = 0; 462 stat.un.b.lsRjtRsvd0 = 0;
@@ -474,7 +474,7 @@ lpfc_rcv_padisc(struct lpfc_hba * phba,
474 spin_unlock_irq(phba->host->host_lock); 474 spin_unlock_irq(phba->host->host_lock);
475 ndlp->nlp_state = NLP_STE_NPR_NODE; 475 ndlp->nlp_state = NLP_STE_NPR_NODE;
476 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); 476 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
477 return (0); 477 return 0;
478} 478}
479 479
480static int 480static int
@@ -489,25 +489,31 @@ lpfc_rcv_logo(struct lpfc_hba * phba,
489 ndlp->nlp_flag |= NLP_LOGO_ACC; 489 ndlp->nlp_flag |= NLP_LOGO_ACC;
490 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 490 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
491 491
492 if (!(ndlp->nlp_type & NLP_FABRIC)) { 492 if (!(ndlp->nlp_type & NLP_FABRIC) ||
493 (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
493 /* Only try to re-login if this is NOT a Fabric Node */ 494 /* Only try to re-login if this is NOT a Fabric Node */
494 ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI; 495 ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI;
495 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1); 496 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
496 spin_lock_irq(phba->host->host_lock); 497 spin_lock_irq(phba->host->host_lock);
497 ndlp->nlp_flag |= NLP_DELAY_TMO; 498 ndlp->nlp_flag |= NLP_DELAY_TMO;
498 spin_unlock_irq(phba->host->host_lock); 499 spin_unlock_irq(phba->host->host_lock);
499 }
500 500
501 ndlp->nlp_state = NLP_STE_NPR_NODE; 501 ndlp->nlp_state = NLP_STE_NPR_NODE;
502 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); 502 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
503 } else {
504 ndlp->nlp_state = NLP_STE_UNUSED_NODE;
505 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
506 }
503 507
508 spin_lock_irq(phba->host->host_lock);
504 ndlp->nlp_flag &= ~NLP_NPR_ADISC; 509 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
510 spin_unlock_irq(phba->host->host_lock);
505 /* The driver has to wait until the ACC completes before it continues 511 /* The driver has to wait until the ACC completes before it continues
506 * processing the LOGO. The action will resume in 512 * processing the LOGO. The action will resume in
507 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an 513 * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
508 * unreg_login, the driver waits so the ACC does not get aborted. 514 * unreg_login, the driver waits so the ACC does not get aborted.
509 */ 515 */
510 return (0); 516 return 0;
511} 517}
512 518
513static void 519static void
@@ -555,20 +561,12 @@ lpfc_disc_set_adisc(struct lpfc_hba * phba,
555 if ((phba->cfg_use_adisc == 0) && 561 if ((phba->cfg_use_adisc == 0) &&
556 !(phba->fc_flag & FC_RSCN_MODE)) { 562 !(phba->fc_flag & FC_RSCN_MODE)) {
557 if (!(ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE)) 563 if (!(ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE))
558 return (0); 564 return 0;
559 } 565 }
560 spin_lock_irq(phba->host->host_lock); 566 spin_lock_irq(phba->host->host_lock);
561 ndlp->nlp_flag |= NLP_NPR_ADISC; 567 ndlp->nlp_flag |= NLP_NPR_ADISC;
562 spin_unlock_irq(phba->host->host_lock); 568 spin_unlock_irq(phba->host->host_lock);
563 return (1); 569 return 1;
564}
565
566static uint32_t
567lpfc_disc_noop(struct lpfc_hba * phba,
568 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
569{
570 /* This routine does nothing, just return the current state */
571 return (ndlp->nlp_state);
572} 570}
573 571
574static uint32_t 572static uint32_t
@@ -583,7 +581,7 @@ lpfc_disc_illegal(struct lpfc_hba * phba,
583 phba->brd_no, 581 phba->brd_no,
584 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi, 582 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
585 ndlp->nlp_flag); 583 ndlp->nlp_flag);
586 return (ndlp->nlp_state); 584 return ndlp->nlp_state;
587} 585}
588 586
589/* Start of Discovery State Machine routines */ 587/* Start of Discovery State Machine routines */
@@ -599,10 +597,10 @@ lpfc_rcv_plogi_unused_node(struct lpfc_hba * phba,
599 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) { 597 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
600 ndlp->nlp_state = NLP_STE_UNUSED_NODE; 598 ndlp->nlp_state = NLP_STE_UNUSED_NODE;
601 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); 599 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
602 return (ndlp->nlp_state); 600 return ndlp->nlp_state;
603 } 601 }
604 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 602 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
605 return (NLP_STE_FREED_NODE); 603 return NLP_STE_FREED_NODE;
606} 604}
607 605
608static uint32_t 606static uint32_t
@@ -611,7 +609,7 @@ lpfc_rcv_els_unused_node(struct lpfc_hba * phba,
611{ 609{
612 lpfc_issue_els_logo(phba, ndlp, 0); 610 lpfc_issue_els_logo(phba, ndlp, 0);
613 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); 611 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
614 return (ndlp->nlp_state); 612 return ndlp->nlp_state;
615} 613}
616 614
617static uint32_t 615static uint32_t
@@ -628,7 +626,7 @@ lpfc_rcv_logo_unused_node(struct lpfc_hba * phba,
628 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 626 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
629 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); 627 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
630 628
631 return (ndlp->nlp_state); 629 return ndlp->nlp_state;
632} 630}
633 631
634static uint32_t 632static uint32_t
@@ -636,7 +634,7 @@ lpfc_cmpl_logo_unused_node(struct lpfc_hba * phba,
636 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 634 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
637{ 635{
638 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 636 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
639 return (NLP_STE_FREED_NODE); 637 return NLP_STE_FREED_NODE;
640} 638}
641 639
642static uint32_t 640static uint32_t
@@ -644,7 +642,7 @@ lpfc_device_rm_unused_node(struct lpfc_hba * phba,
644 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 642 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
645{ 643{
646 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 644 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
647 return (NLP_STE_FREED_NODE); 645 return NLP_STE_FREED_NODE;
648} 646}
649 647
650static uint32_t 648static uint32_t
@@ -682,7 +680,22 @@ lpfc_rcv_plogi_plogi_issue(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
682 lpfc_rcv_plogi(phba, ndlp, cmdiocb); 680 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
683 } /* if our portname was less */ 681 } /* if our portname was less */
684 682
685 return (ndlp->nlp_state); 683 return ndlp->nlp_state;
684}
685
686static uint32_t
687lpfc_rcv_logo_plogi_issue(struct lpfc_hba * phba,
688 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
689{
690 struct lpfc_iocbq *cmdiocb;
691
692 cmdiocb = (struct lpfc_iocbq *) arg;
693
694 /* software abort outstanding PLOGI */
695 lpfc_els_abort(phba, ndlp, 1);
696
697 lpfc_rcv_logo(phba, ndlp, cmdiocb);
698 return ndlp->nlp_state;
686} 699}
687 700
688static uint32_t 701static uint32_t
@@ -712,7 +725,7 @@ lpfc_rcv_els_plogi_issue(struct lpfc_hba * phba,
712 ndlp->nlp_state = NLP_STE_NPR_NODE; 725 ndlp->nlp_state = NLP_STE_NPR_NODE;
713 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); 726 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
714 727
715 return (ndlp->nlp_state); 728 return ndlp->nlp_state;
716} 729}
717 730
718static uint32_t 731static uint32_t
@@ -731,7 +744,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
731 rspiocb = cmdiocb->context_un.rsp_iocb; 744 rspiocb = cmdiocb->context_un.rsp_iocb;
732 745
733 if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) { 746 if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
734 return (ndlp->nlp_state); 747 return ndlp->nlp_state;
735 } 748 }
736 749
737 irsp = &rspiocb->iocb; 750 irsp = &rspiocb->iocb;
@@ -812,7 +825,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
812 NLP_STE_REG_LOGIN_ISSUE; 825 NLP_STE_REG_LOGIN_ISSUE;
813 lpfc_nlp_list(phba, ndlp, 826 lpfc_nlp_list(phba, ndlp,
814 NLP_REGLOGIN_LIST); 827 NLP_REGLOGIN_LIST);
815 return (ndlp->nlp_state); 828 return ndlp->nlp_state;
816 } 829 }
817 mempool_free(mbox, phba->mbox_mem_pool); 830 mempool_free(mbox, phba->mbox_mem_pool);
818 } else { 831 } else {
@@ -824,7 +837,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
824 /* Free this node since the driver cannot login or has the wrong 837 /* Free this node since the driver cannot login or has the wrong
825 sparm */ 838 sparm */
826 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 839 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
827 return (NLP_STE_FREED_NODE); 840 return NLP_STE_FREED_NODE;
828} 841}
829 842
830static uint32_t 843static uint32_t
@@ -835,7 +848,7 @@ lpfc_device_rm_plogi_issue(struct lpfc_hba * phba,
835 lpfc_els_abort(phba, ndlp, 1); 848 lpfc_els_abort(phba, ndlp, 1);
836 849
837 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 850 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
838 return (NLP_STE_FREED_NODE); 851 return NLP_STE_FREED_NODE;
839} 852}
840 853
841static uint32_t 854static uint32_t
@@ -852,7 +865,7 @@ lpfc_device_recov_plogi_issue(struct lpfc_hba * phba,
852 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; 865 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
853 spin_unlock_irq(phba->host->host_lock); 866 spin_unlock_irq(phba->host->host_lock);
854 867
855 return (ndlp->nlp_state); 868 return ndlp->nlp_state;
856} 869}
857 870
858static uint32_t 871static uint32_t
@@ -868,13 +881,13 @@ lpfc_rcv_plogi_adisc_issue(struct lpfc_hba * phba,
868 cmdiocb = (struct lpfc_iocbq *) arg; 881 cmdiocb = (struct lpfc_iocbq *) arg;
869 882
870 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) { 883 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
871 return (ndlp->nlp_state); 884 return ndlp->nlp_state;
872 } 885 }
873 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 886 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
874 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); 887 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
875 lpfc_issue_els_plogi(phba, ndlp, 0); 888 lpfc_issue_els_plogi(phba, ndlp, 0);
876 889
877 return (ndlp->nlp_state); 890 return ndlp->nlp_state;
878} 891}
879 892
880static uint32_t 893static uint32_t
@@ -887,7 +900,7 @@ lpfc_rcv_prli_adisc_issue(struct lpfc_hba * phba,
887 cmdiocb = (struct lpfc_iocbq *) arg; 900 cmdiocb = (struct lpfc_iocbq *) arg;
888 901
889 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); 902 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
890 return (ndlp->nlp_state); 903 return ndlp->nlp_state;
891} 904}
892 905
893static uint32_t 906static uint32_t
@@ -903,7 +916,7 @@ lpfc_rcv_logo_adisc_issue(struct lpfc_hba * phba,
903 lpfc_els_abort(phba, ndlp, 0); 916 lpfc_els_abort(phba, ndlp, 0);
904 917
905 lpfc_rcv_logo(phba, ndlp, cmdiocb); 918 lpfc_rcv_logo(phba, ndlp, cmdiocb);
906 return (ndlp->nlp_state); 919 return ndlp->nlp_state;
907} 920}
908 921
909static uint32_t 922static uint32_t
@@ -916,7 +929,7 @@ lpfc_rcv_padisc_adisc_issue(struct lpfc_hba * phba,
916 cmdiocb = (struct lpfc_iocbq *) arg; 929 cmdiocb = (struct lpfc_iocbq *) arg;
917 930
918 lpfc_rcv_padisc(phba, ndlp, cmdiocb); 931 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
919 return (ndlp->nlp_state); 932 return ndlp->nlp_state;
920} 933}
921 934
922static uint32_t 935static uint32_t
@@ -930,7 +943,7 @@ lpfc_rcv_prlo_adisc_issue(struct lpfc_hba * phba,
930 943
931 /* Treat like rcv logo */ 944 /* Treat like rcv logo */
932 lpfc_rcv_logo(phba, ndlp, cmdiocb); 945 lpfc_rcv_logo(phba, ndlp, cmdiocb);
933 return (ndlp->nlp_state); 946 return ndlp->nlp_state;
934} 947}
935 948
936static uint32_t 949static uint32_t
@@ -963,7 +976,7 @@ lpfc_cmpl_adisc_adisc_issue(struct lpfc_hba * phba,
963 ndlp->nlp_state = NLP_STE_NPR_NODE; 976 ndlp->nlp_state = NLP_STE_NPR_NODE;
964 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); 977 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
965 lpfc_unreg_rpi(phba, ndlp); 978 lpfc_unreg_rpi(phba, ndlp);
966 return (ndlp->nlp_state); 979 return ndlp->nlp_state;
967 } 980 }
968 if (ndlp->nlp_type & NLP_FCP_TARGET) { 981 if (ndlp->nlp_type & NLP_FCP_TARGET) {
969 ndlp->nlp_state = NLP_STE_MAPPED_NODE; 982 ndlp->nlp_state = NLP_STE_MAPPED_NODE;
@@ -972,7 +985,7 @@ lpfc_cmpl_adisc_adisc_issue(struct lpfc_hba * phba,
972 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 985 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
973 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); 986 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
974 } 987 }
975 return (ndlp->nlp_state); 988 return ndlp->nlp_state;
976} 989}
977 990
978static uint32_t 991static uint32_t
@@ -984,7 +997,7 @@ lpfc_device_rm_adisc_issue(struct lpfc_hba * phba,
984 lpfc_els_abort(phba, ndlp, 1); 997 lpfc_els_abort(phba, ndlp, 1);
985 998
986 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 999 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
987 return (NLP_STE_FREED_NODE); 1000 return NLP_STE_FREED_NODE;
988} 1001}
989 1002
990static uint32_t 1003static uint32_t
@@ -999,10 +1012,10 @@ lpfc_device_recov_adisc_issue(struct lpfc_hba * phba,
999 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); 1012 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1000 spin_lock_irq(phba->host->host_lock); 1013 spin_lock_irq(phba->host->host_lock);
1001 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; 1014 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1015 ndlp->nlp_flag |= NLP_NPR_ADISC;
1002 spin_unlock_irq(phba->host->host_lock); 1016 spin_unlock_irq(phba->host->host_lock);
1003 1017
1004 lpfc_disc_set_adisc(phba, ndlp); 1018 return ndlp->nlp_state;
1005 return (ndlp->nlp_state);
1006} 1019}
1007 1020
1008static uint32_t 1021static uint32_t
@@ -1015,7 +1028,7 @@ lpfc_rcv_plogi_reglogin_issue(struct lpfc_hba * phba,
1015 cmdiocb = (struct lpfc_iocbq *) arg; 1028 cmdiocb = (struct lpfc_iocbq *) arg;
1016 1029
1017 lpfc_rcv_plogi(phba, ndlp, cmdiocb); 1030 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
1018 return (ndlp->nlp_state); 1031 return ndlp->nlp_state;
1019} 1032}
1020 1033
1021static uint32_t 1034static uint32_t
@@ -1028,7 +1041,7 @@ lpfc_rcv_prli_reglogin_issue(struct lpfc_hba * phba,
1028 cmdiocb = (struct lpfc_iocbq *) arg; 1041 cmdiocb = (struct lpfc_iocbq *) arg;
1029 1042
1030 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); 1043 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
1031 return (ndlp->nlp_state); 1044 return ndlp->nlp_state;
1032} 1045}
1033 1046
1034static uint32_t 1047static uint32_t
@@ -1041,7 +1054,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_hba * phba,
1041 cmdiocb = (struct lpfc_iocbq *) arg; 1054 cmdiocb = (struct lpfc_iocbq *) arg;
1042 1055
1043 lpfc_rcv_logo(phba, ndlp, cmdiocb); 1056 lpfc_rcv_logo(phba, ndlp, cmdiocb);
1044 return (ndlp->nlp_state); 1057 return ndlp->nlp_state;
1045} 1058}
1046 1059
1047static uint32_t 1060static uint32_t
@@ -1054,7 +1067,7 @@ lpfc_rcv_padisc_reglogin_issue(struct lpfc_hba * phba,
1054 cmdiocb = (struct lpfc_iocbq *) arg; 1067 cmdiocb = (struct lpfc_iocbq *) arg;
1055 1068
1056 lpfc_rcv_padisc(phba, ndlp, cmdiocb); 1069 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
1057 return (ndlp->nlp_state); 1070 return ndlp->nlp_state;
1058} 1071}
1059 1072
1060static uint32_t 1073static uint32_t
@@ -1066,7 +1079,7 @@ lpfc_rcv_prlo_reglogin_issue(struct lpfc_hba * phba,
1066 1079
1067 cmdiocb = (struct lpfc_iocbq *) arg; 1080 cmdiocb = (struct lpfc_iocbq *) arg;
1068 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 1081 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
1069 return (ndlp->nlp_state); 1082 return ndlp->nlp_state;
1070} 1083}
1071 1084
1072static uint32_t 1085static uint32_t
@@ -1100,7 +1113,7 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
1100 ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI; 1113 ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI;
1101 ndlp->nlp_state = NLP_STE_NPR_NODE; 1114 ndlp->nlp_state = NLP_STE_NPR_NODE;
1102 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); 1115 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1103 return (ndlp->nlp_state); 1116 return ndlp->nlp_state;
1104 } 1117 }
1105 1118
1106 ndlp->nlp_rpi = mb->un.varWords[0]; 1119 ndlp->nlp_rpi = mb->un.varWords[0];
@@ -1114,7 +1127,7 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
1114 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 1127 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
1115 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); 1128 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1116 } 1129 }
1117 return (ndlp->nlp_state); 1130 return ndlp->nlp_state;
1118} 1131}
1119 1132
1120static uint32_t 1133static uint32_t
@@ -1123,7 +1136,7 @@ lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba,
1123 uint32_t evt) 1136 uint32_t evt)
1124{ 1137{
1125 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1138 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
1126 return (NLP_STE_FREED_NODE); 1139 return NLP_STE_FREED_NODE;
1127} 1140}
1128 1141
1129static uint32_t 1142static uint32_t
@@ -1136,7 +1149,7 @@ lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba,
1136 spin_lock_irq(phba->host->host_lock); 1149 spin_lock_irq(phba->host->host_lock);
1137 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; 1150 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1138 spin_unlock_irq(phba->host->host_lock); 1151 spin_unlock_irq(phba->host->host_lock);
1139 return (ndlp->nlp_state); 1152 return ndlp->nlp_state;
1140} 1153}
1141 1154
1142static uint32_t 1155static uint32_t
@@ -1148,7 +1161,7 @@ lpfc_rcv_plogi_prli_issue(struct lpfc_hba * phba,
1148 cmdiocb = (struct lpfc_iocbq *) arg; 1161 cmdiocb = (struct lpfc_iocbq *) arg;
1149 1162
1150 lpfc_rcv_plogi(phba, ndlp, cmdiocb); 1163 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
1151 return (ndlp->nlp_state); 1164 return ndlp->nlp_state;
1152} 1165}
1153 1166
1154static uint32_t 1167static uint32_t
@@ -1160,7 +1173,7 @@ lpfc_rcv_prli_prli_issue(struct lpfc_hba * phba,
1160 cmdiocb = (struct lpfc_iocbq *) arg; 1173 cmdiocb = (struct lpfc_iocbq *) arg;
1161 1174
1162 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); 1175 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
1163 return (ndlp->nlp_state); 1176 return ndlp->nlp_state;
1164} 1177}
1165 1178
1166static uint32_t 1179static uint32_t
@@ -1175,7 +1188,7 @@ lpfc_rcv_logo_prli_issue(struct lpfc_hba * phba,
1175 lpfc_els_abort(phba, ndlp, 1); 1188 lpfc_els_abort(phba, ndlp, 1);
1176 1189
1177 lpfc_rcv_logo(phba, ndlp, cmdiocb); 1190 lpfc_rcv_logo(phba, ndlp, cmdiocb);
1178 return (ndlp->nlp_state); 1191 return ndlp->nlp_state;
1179} 1192}
1180 1193
1181static uint32_t 1194static uint32_t
@@ -1187,7 +1200,7 @@ lpfc_rcv_padisc_prli_issue(struct lpfc_hba * phba,
1187 cmdiocb = (struct lpfc_iocbq *) arg; 1200 cmdiocb = (struct lpfc_iocbq *) arg;
1188 1201
1189 lpfc_rcv_padisc(phba, ndlp, cmdiocb); 1202 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
1190 return (ndlp->nlp_state); 1203 return ndlp->nlp_state;
1191} 1204}
1192 1205
1193/* This routine is envoked when we rcv a PRLO request from a nport 1206/* This routine is envoked when we rcv a PRLO request from a nport
@@ -1203,7 +1216,7 @@ lpfc_rcv_prlo_prli_issue(struct lpfc_hba * phba,
1203 1216
1204 cmdiocb = (struct lpfc_iocbq *) arg; 1217 cmdiocb = (struct lpfc_iocbq *) arg;
1205 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 1218 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
1206 return (ndlp->nlp_state); 1219 return ndlp->nlp_state;
1207} 1220}
1208 1221
1209static uint32_t 1222static uint32_t
@@ -1222,7 +1235,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
1222 if (irsp->ulpStatus) { 1235 if (irsp->ulpStatus) {
1223 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 1236 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
1224 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); 1237 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1225 return (ndlp->nlp_state); 1238 return ndlp->nlp_state;
1226 } 1239 }
1227 1240
1228 /* Check out PRLI rsp */ 1241 /* Check out PRLI rsp */
@@ -1240,7 +1253,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
1240 1253
1241 ndlp->nlp_state = NLP_STE_MAPPED_NODE; 1254 ndlp->nlp_state = NLP_STE_MAPPED_NODE;
1242 lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST); 1255 lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
1243 return (ndlp->nlp_state); 1256 return ndlp->nlp_state;
1244} 1257}
1245 1258
1246/*! lpfc_device_rm_prli_issue 1259/*! lpfc_device_rm_prli_issue
@@ -1268,7 +1281,7 @@ lpfc_device_rm_prli_issue(struct lpfc_hba * phba,
1268 lpfc_els_abort(phba, ndlp, 1); 1281 lpfc_els_abort(phba, ndlp, 1);
1269 1282
1270 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1283 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
1271 return (NLP_STE_FREED_NODE); 1284 return NLP_STE_FREED_NODE;
1272} 1285}
1273 1286
1274 1287
@@ -1300,7 +1313,7 @@ lpfc_device_recov_prli_issue(struct lpfc_hba * phba,
1300 spin_lock_irq(phba->host->host_lock); 1313 spin_lock_irq(phba->host->host_lock);
1301 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; 1314 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1302 spin_unlock_irq(phba->host->host_lock); 1315 spin_unlock_irq(phba->host->host_lock);
1303 return (ndlp->nlp_state); 1316 return ndlp->nlp_state;
1304} 1317}
1305 1318
1306static uint32_t 1319static uint32_t
@@ -1312,7 +1325,7 @@ lpfc_rcv_plogi_unmap_node(struct lpfc_hba * phba,
1312 cmdiocb = (struct lpfc_iocbq *) arg; 1325 cmdiocb = (struct lpfc_iocbq *) arg;
1313 1326
1314 lpfc_rcv_plogi(phba, ndlp, cmdiocb); 1327 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
1315 return (ndlp->nlp_state); 1328 return ndlp->nlp_state;
1316} 1329}
1317 1330
1318static uint32_t 1331static uint32_t
@@ -1325,7 +1338,7 @@ lpfc_rcv_prli_unmap_node(struct lpfc_hba * phba,
1325 1338
1326 lpfc_rcv_prli(phba, ndlp, cmdiocb); 1339 lpfc_rcv_prli(phba, ndlp, cmdiocb);
1327 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); 1340 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
1328 return (ndlp->nlp_state); 1341 return ndlp->nlp_state;
1329} 1342}
1330 1343
1331static uint32_t 1344static uint32_t
@@ -1337,7 +1350,7 @@ lpfc_rcv_logo_unmap_node(struct lpfc_hba * phba,
1337 cmdiocb = (struct lpfc_iocbq *) arg; 1350 cmdiocb = (struct lpfc_iocbq *) arg;
1338 1351
1339 lpfc_rcv_logo(phba, ndlp, cmdiocb); 1352 lpfc_rcv_logo(phba, ndlp, cmdiocb);
1340 return (ndlp->nlp_state); 1353 return ndlp->nlp_state;
1341} 1354}
1342 1355
1343static uint32_t 1356static uint32_t
@@ -1349,7 +1362,7 @@ lpfc_rcv_padisc_unmap_node(struct lpfc_hba * phba,
1349 cmdiocb = (struct lpfc_iocbq *) arg; 1362 cmdiocb = (struct lpfc_iocbq *) arg;
1350 1363
1351 lpfc_rcv_padisc(phba, ndlp, cmdiocb); 1364 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
1352 return (ndlp->nlp_state); 1365 return ndlp->nlp_state;
1353} 1366}
1354 1367
1355static uint32_t 1368static uint32_t
@@ -1360,9 +1373,8 @@ lpfc_rcv_prlo_unmap_node(struct lpfc_hba * phba,
1360 1373
1361 cmdiocb = (struct lpfc_iocbq *) arg; 1374 cmdiocb = (struct lpfc_iocbq *) arg;
1362 1375
1363 /* Treat like rcv logo */ 1376 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
1364 lpfc_rcv_logo(phba, ndlp, cmdiocb); 1377 return ndlp->nlp_state;
1365 return (ndlp->nlp_state);
1366} 1378}
1367 1379
1368static uint32_t 1380static uint32_t
@@ -1374,7 +1386,7 @@ lpfc_device_recov_unmap_node(struct lpfc_hba * phba,
1374 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; 1386 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1375 lpfc_disc_set_adisc(phba, ndlp); 1387 lpfc_disc_set_adisc(phba, ndlp);
1376 1388
1377 return (ndlp->nlp_state); 1389 return ndlp->nlp_state;
1378} 1390}
1379 1391
1380static uint32_t 1392static uint32_t
@@ -1386,7 +1398,7 @@ lpfc_rcv_plogi_mapped_node(struct lpfc_hba * phba,
1386 cmdiocb = (struct lpfc_iocbq *) arg; 1398 cmdiocb = (struct lpfc_iocbq *) arg;
1387 1399
1388 lpfc_rcv_plogi(phba, ndlp, cmdiocb); 1400 lpfc_rcv_plogi(phba, ndlp, cmdiocb);
1389 return (ndlp->nlp_state); 1401 return ndlp->nlp_state;
1390} 1402}
1391 1403
1392static uint32_t 1404static uint32_t
@@ -1398,7 +1410,7 @@ lpfc_rcv_prli_mapped_node(struct lpfc_hba * phba,
1398 cmdiocb = (struct lpfc_iocbq *) arg; 1410 cmdiocb = (struct lpfc_iocbq *) arg;
1399 1411
1400 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp); 1412 lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
1401 return (ndlp->nlp_state); 1413 return ndlp->nlp_state;
1402} 1414}
1403 1415
1404static uint32_t 1416static uint32_t
@@ -1410,7 +1422,7 @@ lpfc_rcv_logo_mapped_node(struct lpfc_hba * phba,
1410 cmdiocb = (struct lpfc_iocbq *) arg; 1422 cmdiocb = (struct lpfc_iocbq *) arg;
1411 1423
1412 lpfc_rcv_logo(phba, ndlp, cmdiocb); 1424 lpfc_rcv_logo(phba, ndlp, cmdiocb);
1413 return (ndlp->nlp_state); 1425 return ndlp->nlp_state;
1414} 1426}
1415 1427
1416static uint32_t 1428static uint32_t
@@ -1423,7 +1435,7 @@ lpfc_rcv_padisc_mapped_node(struct lpfc_hba * phba,
1423 cmdiocb = (struct lpfc_iocbq *) arg; 1435 cmdiocb = (struct lpfc_iocbq *) arg;
1424 1436
1425 lpfc_rcv_padisc(phba, ndlp, cmdiocb); 1437 lpfc_rcv_padisc(phba, ndlp, cmdiocb);
1426 return (ndlp->nlp_state); 1438 return ndlp->nlp_state;
1427} 1439}
1428 1440
1429static uint32_t 1441static uint32_t
@@ -1442,7 +1454,7 @@ lpfc_rcv_prlo_mapped_node(struct lpfc_hba * phba,
1442 1454
1443 /* Treat like rcv logo */ 1455 /* Treat like rcv logo */
1444 lpfc_rcv_logo(phba, ndlp, cmdiocb); 1456 lpfc_rcv_logo(phba, ndlp, cmdiocb);
1445 return (ndlp->nlp_state); 1457 return ndlp->nlp_state;
1446} 1458}
1447 1459
1448static uint32_t 1460static uint32_t
@@ -1456,7 +1468,7 @@ lpfc_device_recov_mapped_node(struct lpfc_hba * phba,
1456 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; 1468 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1457 spin_unlock_irq(phba->host->host_lock); 1469 spin_unlock_irq(phba->host->host_lock);
1458 lpfc_disc_set_adisc(phba, ndlp); 1470 lpfc_disc_set_adisc(phba, ndlp);
1459 return (ndlp->nlp_state); 1471 return ndlp->nlp_state;
1460} 1472}
1461 1473
1462static uint32_t 1474static uint32_t
@@ -1470,14 +1482,14 @@ lpfc_rcv_plogi_npr_node(struct lpfc_hba * phba,
1470 1482
1471 /* Ignore PLOGI if we have an outstanding LOGO */ 1483 /* Ignore PLOGI if we have an outstanding LOGO */
1472 if (ndlp->nlp_flag & NLP_LOGO_SND) { 1484 if (ndlp->nlp_flag & NLP_LOGO_SND) {
1473 return (ndlp->nlp_state); 1485 return ndlp->nlp_state;
1474 } 1486 }
1475 1487
1476 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) { 1488 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
1477 spin_lock_irq(phba->host->host_lock); 1489 spin_lock_irq(phba->host->host_lock);
1478 ndlp->nlp_flag &= ~(NLP_NPR_ADISC | NLP_NPR_2B_DISC); 1490 ndlp->nlp_flag &= ~(NLP_NPR_ADISC | NLP_NPR_2B_DISC);
1479 spin_unlock_irq(phba->host->host_lock); 1491 spin_unlock_irq(phba->host->host_lock);
1480 return (ndlp->nlp_state); 1492 return ndlp->nlp_state;
1481 } 1493 }
1482 1494
1483 /* send PLOGI immediately, move to PLOGI issue state */ 1495 /* send PLOGI immediately, move to PLOGI issue state */
@@ -1486,7 +1498,7 @@ lpfc_rcv_plogi_npr_node(struct lpfc_hba * phba,
1486 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); 1498 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1487 lpfc_issue_els_plogi(phba, ndlp, 0); 1499 lpfc_issue_els_plogi(phba, ndlp, 0);
1488 } 1500 }
1489 return (ndlp->nlp_state); 1501 return ndlp->nlp_state;
1490} 1502}
1491 1503
1492static uint32_t 1504static uint32_t
@@ -1506,6 +1518,9 @@ lpfc_rcv_prli_npr_node(struct lpfc_hba * phba,
1506 1518
1507 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { 1519 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
1508 if (ndlp->nlp_flag & NLP_NPR_ADISC) { 1520 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
1521 spin_lock_irq(phba->host->host_lock);
1522 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1523 spin_unlock_irq(phba->host->host_lock);
1509 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1524 ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
1510 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST); 1525 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
1511 lpfc_issue_els_adisc(phba, ndlp, 0); 1526 lpfc_issue_els_adisc(phba, ndlp, 0);
@@ -1515,7 +1530,7 @@ lpfc_rcv_prli_npr_node(struct lpfc_hba * phba,
1515 lpfc_issue_els_plogi(phba, ndlp, 0); 1530 lpfc_issue_els_plogi(phba, ndlp, 0);
1516 } 1531 }
1517 } 1532 }
1518 return (ndlp->nlp_state); 1533 return ndlp->nlp_state;
1519} 1534}
1520 1535
1521static uint32_t 1536static uint32_t
@@ -1528,7 +1543,7 @@ lpfc_rcv_logo_npr_node(struct lpfc_hba * phba,
1528 cmdiocb = (struct lpfc_iocbq *) arg; 1543 cmdiocb = (struct lpfc_iocbq *) arg;
1529 1544
1530 lpfc_rcv_logo(phba, ndlp, cmdiocb); 1545 lpfc_rcv_logo(phba, ndlp, cmdiocb);
1531 return (ndlp->nlp_state); 1546 return ndlp->nlp_state;
1532} 1547}
1533 1548
1534static uint32_t 1549static uint32_t
@@ -1553,7 +1568,7 @@ lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba,
1553 lpfc_issue_els_plogi(phba, ndlp, 0); 1568 lpfc_issue_els_plogi(phba, ndlp, 0);
1554 } 1569 }
1555 } 1570 }
1556 return (ndlp->nlp_state); 1571 return ndlp->nlp_state;
1557} 1572}
1558 1573
1559static uint32_t 1574static uint32_t
@@ -1565,25 +1580,46 @@ lpfc_rcv_prlo_npr_node(struct lpfc_hba * phba,
1565 1580
1566 cmdiocb = (struct lpfc_iocbq *) arg; 1581 cmdiocb = (struct lpfc_iocbq *) arg;
1567 1582
1583 spin_lock_irq(phba->host->host_lock);
1584 ndlp->nlp_flag |= NLP_LOGO_ACC;
1585 spin_unlock_irq(phba->host->host_lock);
1586
1568 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 1587 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
1569 1588
1570 if (ndlp->nlp_flag & NLP_DELAY_TMO) { 1589 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
1571 if (ndlp->nlp_last_elscmd == (unsigned long)ELS_CMD_PLOGI) { 1590 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
1572 return (ndlp->nlp_state); 1591 spin_lock_irq(phba->host->host_lock);
1573 } else { 1592 ndlp->nlp_flag |= NLP_DELAY_TMO;
1574 spin_lock_irq(phba->host->host_lock); 1593 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1575 ndlp->nlp_flag &= ~NLP_DELAY_TMO; 1594 spin_unlock_irq(phba->host->host_lock);
1576 spin_unlock_irq(phba->host->host_lock); 1595 } else {
1577 del_timer_sync(&ndlp->nlp_delayfunc); 1596 spin_lock_irq(phba->host->host_lock);
1578 if (!list_empty(&ndlp->els_retry_evt.evt_listp)) 1597 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1579 list_del_init(&ndlp->els_retry_evt.evt_listp); 1598 spin_unlock_irq(phba->host->host_lock);
1580 }
1581 } 1599 }
1600 return ndlp->nlp_state;
1601}
1582 1602
1583 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1603static uint32_t
1584 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); 1604lpfc_cmpl_plogi_npr_node(struct lpfc_hba * phba,
1585 lpfc_issue_els_plogi(phba, ndlp, 0); 1605 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1586 return (ndlp->nlp_state); 1606{
1607 struct lpfc_iocbq *cmdiocb, *rspiocb;
1608
1609 cmdiocb = (struct lpfc_iocbq *) arg;
1610 rspiocb = cmdiocb->context_un.rsp_iocb;
1611 return ndlp->nlp_state;
1612}
1613
1614static uint32_t
1615lpfc_cmpl_prli_npr_node(struct lpfc_hba * phba,
1616 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1617{
1618 struct lpfc_iocbq *cmdiocb, *rspiocb;
1619
1620 cmdiocb = (struct lpfc_iocbq *) arg;
1621 rspiocb = cmdiocb->context_un.rsp_iocb;
1622 return ndlp->nlp_state;
1587} 1623}
1588 1624
1589static uint32_t 1625static uint32_t
@@ -1592,7 +1628,19 @@ lpfc_cmpl_logo_npr_node(struct lpfc_hba * phba,
1592{ 1628{
1593 lpfc_unreg_rpi(phba, ndlp); 1629 lpfc_unreg_rpi(phba, ndlp);
1594 /* This routine does nothing, just return the current state */ 1630 /* This routine does nothing, just return the current state */
1595 return (ndlp->nlp_state); 1631 return ndlp->nlp_state;
1632}
1633
1634static uint32_t
1635lpfc_cmpl_adisc_npr_node(struct lpfc_hba * phba,
1636 struct lpfc_nodelist * ndlp, void *arg,
1637 uint32_t evt)
1638{
1639 struct lpfc_iocbq *cmdiocb, *rspiocb;
1640
1641 cmdiocb = (struct lpfc_iocbq *) arg;
1642 rspiocb = cmdiocb->context_un.rsp_iocb;
1643 return ndlp->nlp_state;
1596} 1644}
1597 1645
1598static uint32_t 1646static uint32_t
@@ -1606,9 +1654,10 @@ lpfc_cmpl_reglogin_npr_node(struct lpfc_hba * phba,
1606 pmb = (LPFC_MBOXQ_t *) arg; 1654 pmb = (LPFC_MBOXQ_t *) arg;
1607 mb = &pmb->mb; 1655 mb = &pmb->mb;
1608 1656
1609 ndlp->nlp_rpi = mb->un.varWords[0]; 1657 if (!mb->mbxStatus)
1658 ndlp->nlp_rpi = mb->un.varWords[0];
1610 1659
1611 return (ndlp->nlp_state); 1660 return ndlp->nlp_state;
1612} 1661}
1613 1662
1614static uint32_t 1663static uint32_t
@@ -1617,7 +1666,7 @@ lpfc_device_rm_npr_node(struct lpfc_hba * phba,
1617 uint32_t evt) 1666 uint32_t evt)
1618{ 1667{
1619 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1668 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
1620 return (NLP_STE_FREED_NODE); 1669 return NLP_STE_FREED_NODE;
1621} 1670}
1622 1671
1623static uint32_t 1672static uint32_t
@@ -1633,10 +1682,10 @@ lpfc_device_recov_npr_node(struct lpfc_hba * phba,
1633 list_del_init(&ndlp->els_retry_evt.evt_listp); 1682 list_del_init(&ndlp->els_retry_evt.evt_listp);
1634 spin_unlock_irq(phba->host->host_lock); 1683 spin_unlock_irq(phba->host->host_lock);
1635 del_timer_sync(&ndlp->nlp_delayfunc); 1684 del_timer_sync(&ndlp->nlp_delayfunc);
1636 return (ndlp->nlp_state); 1685 return ndlp->nlp_state;
1637 } 1686 }
1638 spin_unlock_irq(phba->host->host_lock); 1687 spin_unlock_irq(phba->host->host_lock);
1639 return (ndlp->nlp_state); 1688 return ndlp->nlp_state;
1640} 1689}
1641 1690
1642 1691
@@ -1715,7 +1764,7 @@ static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
1715 1764
1716 lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */ 1765 lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */
1717 lpfc_rcv_els_plogi_issue, /* RCV_PRLI */ 1766 lpfc_rcv_els_plogi_issue, /* RCV_PRLI */
1718 lpfc_rcv_els_plogi_issue, /* RCV_LOGO */ 1767 lpfc_rcv_logo_plogi_issue, /* RCV_LOGO */
1719 lpfc_rcv_els_plogi_issue, /* RCV_ADISC */ 1768 lpfc_rcv_els_plogi_issue, /* RCV_ADISC */
1720 lpfc_rcv_els_plogi_issue, /* RCV_PDISC */ 1769 lpfc_rcv_els_plogi_issue, /* RCV_PDISC */
1721 lpfc_rcv_els_plogi_issue, /* RCV_PRLO */ 1770 lpfc_rcv_els_plogi_issue, /* RCV_PRLO */
@@ -1803,10 +1852,10 @@ static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
1803 lpfc_rcv_padisc_npr_node, /* RCV_ADISC */ 1852 lpfc_rcv_padisc_npr_node, /* RCV_ADISC */
1804 lpfc_rcv_padisc_npr_node, /* RCV_PDISC */ 1853 lpfc_rcv_padisc_npr_node, /* RCV_PDISC */
1805 lpfc_rcv_prlo_npr_node, /* RCV_PRLO */ 1854 lpfc_rcv_prlo_npr_node, /* RCV_PRLO */
1806 lpfc_disc_noop, /* CMPL_PLOGI */ 1855 lpfc_cmpl_plogi_npr_node, /* CMPL_PLOGI */
1807 lpfc_disc_noop, /* CMPL_PRLI */ 1856 lpfc_cmpl_prli_npr_node, /* CMPL_PRLI */
1808 lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */ 1857 lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */
1809 lpfc_disc_noop, /* CMPL_ADISC */ 1858 lpfc_cmpl_adisc_npr_node, /* CMPL_ADISC */
1810 lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */ 1859 lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */
1811 lpfc_device_rm_npr_node, /* DEVICE_RM */ 1860 lpfc_device_rm_npr_node, /* DEVICE_RM */
1812 lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */ 1861 lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */
@@ -1852,10 +1901,10 @@ lpfc_disc_state_machine(struct lpfc_hba * phba,
1852 ndlp->nlp_flag &= ~NLP_DELAY_REMOVE; 1901 ndlp->nlp_flag &= ~NLP_DELAY_REMOVE;
1853 spin_unlock_irq(phba->host->host_lock); 1902 spin_unlock_irq(phba->host->host_lock);
1854 lpfc_nlp_remove(phba, ndlp); 1903 lpfc_nlp_remove(phba, ndlp);
1855 return (NLP_STE_FREED_NODE); 1904 return NLP_STE_FREED_NODE;
1856 } 1905 }
1857 if (rc == NLP_STE_FREED_NODE) 1906 if (rc == NLP_STE_FREED_NODE)
1858 return (NLP_STE_FREED_NODE); 1907 return NLP_STE_FREED_NODE;
1859 ndlp->nlp_state = rc; 1908 ndlp->nlp_state = rc;
1860 return (rc); 1909 return rc;
1861} 1910}