aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_els.c
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/lpfc_els.c
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/lpfc_els.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c330
1 files changed, 144 insertions, 186 deletions
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 056f9157d2c8..70581b9eafaf 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;