aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_els.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_els.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c679
1 files changed, 315 insertions, 364 deletions
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 33fbc1666946..8085900635d4 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -63,10 +63,10 @@ lpfc_els_chk_latt(struct lpfc_vport *vport)
63 return 0; 63 return 0;
64 64
65 /* Pending Link Event during Discovery */ 65 /* Pending Link Event during Discovery */
66 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 66 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
67 "%d (%d):0237 Pending Link Event during " 67 "0237 Pending Link Event during "
68 "Discovery: State x%x\n", 68 "Discovery: State x%x\n",
69 phba->brd_no, vport->vpi, phba->pport->port_state); 69 phba->pport->port_state);
70 70
71 /* CLEAR_LA should re-enable link attention events and 71 /* CLEAR_LA should re-enable link attention events and
72 * we should then imediately take a LATT event. The 72 * we should then imediately take a LATT event. The
@@ -196,9 +196,7 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp,
196 bpl->tus.w = le32_to_cpu(bpl->tus.w); 196 bpl->tus.w = le32_to_cpu(bpl->tus.w);
197 } 197 }
198 198
199 /* Save for completion so we can release these resources */ 199 elsiocb->context1 = lpfc_nlp_get(ndlp);
200 if (elscmd != ELS_CMD_LS_RJT)
201 elsiocb->context1 = lpfc_nlp_get(ndlp);
202 elsiocb->context2 = pcmd; 200 elsiocb->context2 = pcmd;
203 elsiocb->context3 = pbuflist; 201 elsiocb->context3 = pbuflist;
204 elsiocb->retry = retry; 202 elsiocb->retry = retry;
@@ -208,23 +206,21 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp,
208 if (prsp) { 206 if (prsp) {
209 list_add(&prsp->list, &pcmd->list); 207 list_add(&prsp->list, &pcmd->list);
210 } 208 }
211
212 if (expectRsp) { 209 if (expectRsp) {
213 /* Xmit ELS command <elsCmd> to remote NPORT <did> */ 210 /* Xmit ELS command <elsCmd> to remote NPORT <did> */
214 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 211 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
215 "%d (%d):0116 Xmit ELS command x%x to remote " 212 "0116 Xmit ELS command x%x to remote "
216 "NPORT x%x I/O tag: x%x, port state: x%x\n", 213 "NPORT x%x I/O tag: x%x, port state: x%x\n",
217 phba->brd_no, vport->vpi, elscmd, did, 214 elscmd, did, elsiocb->iotag,
218 elsiocb->iotag, vport->port_state); 215 vport->port_state);
219 } else { 216 } else {
220 /* Xmit ELS response <elsCmd> to remote NPORT <did> */ 217 /* Xmit ELS response <elsCmd> to remote NPORT <did> */
221 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 218 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
222 "%d (%d):0117 Xmit ELS response x%x to remote " 219 "0117 Xmit ELS response x%x to remote "
223 "NPORT x%x I/O tag: x%x, size: x%x\n", 220 "NPORT x%x I/O tag: x%x, size: x%x\n",
224 phba->brd_no, vport->vpi, elscmd, 221 elscmd, ndlp->nlp_DID, elsiocb->iotag,
225 ndlp->nlp_DID, elsiocb->iotag, cmdSize); 222 cmdSize);
226 } 223 }
227
228 return elsiocb; 224 return elsiocb;
229} 225}
230 226
@@ -285,9 +281,8 @@ fail_free_mbox:
285 281
286fail: 282fail:
287 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 283 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
288 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 284 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
289 "%d (%d):0249 Cannot issue Register Fabric login\n", 285 "0249 Cannot issue Register Fabric login\n");
290 phba->brd_no, vport->vpi);
291 return -ENXIO; 286 return -ENXIO;
292} 287}
293 288
@@ -340,20 +335,19 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
340 335
341 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { 336 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
342 if (sp->cmn.response_multiple_NPort) { 337 if (sp->cmn.response_multiple_NPort) {
343 lpfc_printf_log(phba, KERN_WARNING, LOG_ELS | LOG_VPORT, 338 lpfc_printf_vlog(vport, KERN_WARNING,
344 "%d:1816 FLOGI NPIV supported, " 339 LOG_ELS | LOG_VPORT,
345 "response data 0x%x\n", 340 "1816 FLOGI NPIV supported, "
346 phba->brd_no, 341 "response data 0x%x\n",
347 sp->cmn.response_multiple_NPort); 342 sp->cmn.response_multiple_NPort);
348 phba->link_flag |= LS_NPIV_FAB_SUPPORTED; 343 phba->link_flag |= LS_NPIV_FAB_SUPPORTED;
349
350 } else { 344 } else {
351 /* Because we asked f/w for NPIV it still expects us 345 /* Because we asked f/w for NPIV it still expects us
352 to call reg_vnpid atleast for the physcial host */ 346 to call reg_vnpid atleast for the physcial host */
353 lpfc_printf_log(phba, KERN_WARNING, LOG_ELS | LOG_VPORT, 347 lpfc_printf_vlog(vport, KERN_WARNING,
354 "%d:1817 Fabric does not support NPIV " 348 LOG_ELS | LOG_VPORT,
355 "- configuring single port mode.\n", 349 "1817 Fabric does not support NPIV "
356 phba->brd_no); 350 "- configuring single port mode.\n");
357 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED; 351 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED;
358 } 352 }
359 } 353 }
@@ -518,16 +512,15 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
518 * alpa map would take too long otherwise. 512 * alpa map would take too long otherwise.
519 */ 513 */
520 if (phba->alpa_map[0] == 0) { 514 if (phba->alpa_map[0] == 0) {
521 phba->cfg_discovery_threads = LPFC_MAX_DISC_THREADS; 515 vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS;
522 } 516 }
523 517
524 /* FLOGI failure */ 518 /* FLOGI failure */
525 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 519 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
526 "%d (%d):0100 FLOGI failure Data: x%x x%x " 520 "0100 FLOGI failure Data: x%x x%x "
527 "x%x\n", 521 "x%x\n",
528 phba->brd_no, vport->vpi, 522 irsp->ulpStatus, irsp->un.ulpWord[4],
529 irsp->ulpStatus, irsp->un.ulpWord[4], 523 irsp->ulpTimeout);
530 irsp->ulpTimeout);
531 goto flogifail; 524 goto flogifail;
532 } 525 }
533 526
@@ -540,12 +533,11 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
540 sp = prsp->virt + sizeof(uint32_t); 533 sp = prsp->virt + sizeof(uint32_t);
541 534
542 /* FLOGI completes successfully */ 535 /* FLOGI completes successfully */
543 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 536 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
544 "%d (%d):0101 FLOGI completes sucessfully " 537 "0101 FLOGI completes sucessfully "
545 "Data: x%x x%x x%x x%x\n", 538 "Data: x%x x%x x%x x%x\n",
546 phba->brd_no, vport->vpi, 539 irsp->un.ulpWord[4], sp->cmn.e_d_tov,
547 irsp->un.ulpWord[4], sp->cmn.e_d_tov, 540 sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution);
548 sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution);
549 541
550 if (vport->port_state == LPFC_FLOGI) { 542 if (vport->port_state == LPFC_FLOGI) {
551 /* 543 /*
@@ -662,8 +654,8 @@ lpfc_els_abort_flogi(struct lpfc_hba *phba)
662 654
663 /* Abort outstanding I/O on NPort <nlp_DID> */ 655 /* Abort outstanding I/O on NPort <nlp_DID> */
664 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 656 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
665 "%d:0201 Abort outstanding I/O on NPort x%x\n", 657 "0201 Abort outstanding I/O on NPort x%x\n",
666 phba->brd_no, Fabric_DID); 658 Fabric_DID);
667 659
668 pring = &phba->sli.ring[LPFC_ELS_RING]; 660 pring = &phba->sli.ring[LPFC_ELS_RING];
669 661
@@ -736,18 +728,16 @@ static void
736lpfc_more_plogi(struct lpfc_vport *vport) 728lpfc_more_plogi(struct lpfc_vport *vport)
737{ 729{
738 int sentplogi; 730 int sentplogi;
739 struct lpfc_hba *phba = vport->phba;
740 731
741 if (vport->num_disc_nodes) 732 if (vport->num_disc_nodes)
742 vport->num_disc_nodes--; 733 vport->num_disc_nodes--;
743 734
744 /* Continue discovery with <num_disc_nodes> PLOGIs to go */ 735 /* Continue discovery with <num_disc_nodes> PLOGIs to go */
745 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 736 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
746 "%d (%d):0232 Continue discovery with %d PLOGIs to go " 737 "0232 Continue discovery with %d PLOGIs to go "
747 "Data: x%x x%x x%x\n", 738 "Data: x%x x%x x%x\n",
748 phba->brd_no, vport->vpi, vport->num_disc_nodes, 739 vport->num_disc_nodes, vport->fc_plogi_cnt,
749 vport->fc_plogi_cnt, vport->fc_flag, vport->port_state); 740 vport->fc_flag, vport->port_state);
750
751 /* Check to see if there are more PLOGIs to be sent */ 741 /* Check to see if there are more PLOGIs to be sent */
752 if (vport->fc_flag & FC_NLP_MORE) 742 if (vport->fc_flag & FC_NLP_MORE)
753 /* go thru NPR nodes and issue any remaining ELS PLOGIs */ 743 /* go thru NPR nodes and issue any remaining ELS PLOGIs */
@@ -833,11 +823,12 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
833 823
834 ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); 824 ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID);
835 if (!ndlp) { 825 if (!ndlp) {
836 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 826 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
837 "%d (%d):0136 PLOGI completes to NPort x%x " 827 "0136 PLOGI completes to NPort x%x "
838 "with no ndlp. Data: x%x x%x x%x\n", 828 "with no ndlp. Data: x%x x%x x%x\n",
839 phba->brd_no, vport->vpi, irsp->un.elsreq64.remoteID, 829 irsp->un.elsreq64.remoteID,
840 irsp->ulpStatus, irsp->un.ulpWord[4], irsp->ulpIoTag); 830 irsp->ulpStatus, irsp->un.ulpWord[4],
831 irsp->ulpIoTag);
841 goto out; 832 goto out;
842 } 833 }
843 834
@@ -851,13 +842,11 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
851 rc = 0; 842 rc = 0;
852 843
853 /* PLOGI completes to NPort <nlp_DID> */ 844 /* PLOGI completes to NPort <nlp_DID> */
854 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 845 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
855 "%d (%d):0102 PLOGI completes to NPort x%x " 846 "0102 PLOGI completes to NPort x%x "
856 "Data: x%x x%x x%x x%x x%x\n", 847 "Data: x%x x%x x%x x%x x%x\n",
857 phba->brd_no, vport->vpi, ndlp->nlp_DID, 848 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
858 irsp->ulpStatus, irsp->un.ulpWord[4], 849 irsp->ulpTimeout, disc, vport->num_disc_nodes);
859 irsp->ulpTimeout, disc, vport->num_disc_nodes);
860
861 /* Check to see if link went down during discovery */ 850 /* Check to see if link went down during discovery */
862 if (lpfc_els_chk_latt(vport)) { 851 if (lpfc_els_chk_latt(vport)) {
863 spin_lock_irq(shost->host_lock); 852 spin_lock_irq(shost->host_lock);
@@ -881,17 +870,14 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
881 } 870 }
882 goto out; 871 goto out;
883 } 872 }
884
885 /* PLOGI failed */ 873 /* PLOGI failed */
886 if (ndlp->nlp_DID == NameServer_DID) { 874 if (ndlp->nlp_DID == NameServer_DID) {
887 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 875 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
888 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 876 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
889 "%d (%d):0250 Nameserver login error: " 877 "0250 Nameserver login error: "
890 "0x%x / 0x%x\n", 878 "0x%x / 0x%x\n",
891 phba->brd_no, vport->vpi, 879 irsp->ulpStatus, irsp->un.ulpWord[4]);
892 irsp->ulpStatus, irsp->un.ulpWord[4]);
893 } 880 }
894
895 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 881 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
896 if (lpfc_error_lost_link(irsp)) { 882 if (lpfc_error_lost_link(irsp)) {
897 rc = NLP_STE_FREED_NODE; 883 rc = NLP_STE_FREED_NODE;
@@ -1017,14 +1003,12 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1017 "PRLI cmpl: status:x%x/x%x did:x%x", 1003 "PRLI cmpl: status:x%x/x%x did:x%x",
1018 irsp->ulpStatus, irsp->un.ulpWord[4], 1004 irsp->ulpStatus, irsp->un.ulpWord[4],
1019 ndlp->nlp_DID); 1005 ndlp->nlp_DID);
1020
1021 /* PRLI completes to NPort <nlp_DID> */ 1006 /* PRLI completes to NPort <nlp_DID> */
1022 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1007 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1023 "%d (%d):0103 PRLI completes to NPort x%x " 1008 "0103 PRLI completes to NPort x%x "
1024 "Data: x%x x%x x%x x%x\n", 1009 "Data: x%x x%x x%x x%x\n",
1025 phba->brd_no, vport->vpi, ndlp->nlp_DID, 1010 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
1026 irsp->ulpStatus, irsp->un.ulpWord[4], irsp->ulpTimeout, 1011 irsp->ulpTimeout, vport->num_disc_nodes);
1027 vport->num_disc_nodes);
1028 1012
1029 vport->fc_prli_sent--; 1013 vport->fc_prli_sent--;
1030 /* Check to see if link went down during discovery */ 1014 /* Check to see if link went down during discovery */
@@ -1129,18 +1113,15 @@ static void
1129lpfc_more_adisc(struct lpfc_vport *vport) 1113lpfc_more_adisc(struct lpfc_vport *vport)
1130{ 1114{
1131 int sentadisc; 1115 int sentadisc;
1132 struct lpfc_hba *phba = vport->phba;
1133 1116
1134 if (vport->num_disc_nodes) 1117 if (vport->num_disc_nodes)
1135 vport->num_disc_nodes--; 1118 vport->num_disc_nodes--;
1136
1137 /* Continue discovery with <num_disc_nodes> ADISCs to go */ 1119 /* Continue discovery with <num_disc_nodes> ADISCs to go */
1138 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1120 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1139 "%d (%d):0210 Continue discovery with %d ADISCs to go " 1121 "0210 Continue discovery with %d ADISCs to go "
1140 "Data: x%x x%x x%x\n", 1122 "Data: x%x x%x x%x\n",
1141 phba->brd_no, vport->vpi, vport->num_disc_nodes, 1123 vport->num_disc_nodes, vport->fc_adisc_cnt,
1142 vport->fc_adisc_cnt, vport->fc_flag, vport->port_state); 1124 vport->fc_flag, vport->port_state);
1143
1144 /* Check to see if there are more ADISCs to be sent */ 1125 /* Check to see if there are more ADISCs to be sent */
1145 if (vport->fc_flag & FC_NLP_MORE) { 1126 if (vport->fc_flag & FC_NLP_MORE) {
1146 lpfc_set_disctmo(vport); 1127 lpfc_set_disctmo(vport);
@@ -1206,15 +1187,12 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1206 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); 1187 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC);
1207 ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC); 1188 ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC);
1208 spin_unlock_irq(shost->host_lock); 1189 spin_unlock_irq(shost->host_lock);
1209
1210 /* ADISC completes to NPort <nlp_DID> */ 1190 /* ADISC completes to NPort <nlp_DID> */
1211 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1191 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1212 "%d (%d):0104 ADISC completes to NPort x%x " 1192 "0104 ADISC completes to NPort x%x "
1213 "Data: x%x x%x x%x x%x x%x\n", 1193 "Data: x%x x%x x%x x%x x%x\n",
1214 phba->brd_no, vport->vpi, ndlp->nlp_DID, 1194 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
1215 irsp->ulpStatus, irsp->un.ulpWord[4], irsp->ulpTimeout, 1195 irsp->ulpTimeout, disc, vport->num_disc_nodes);
1216 disc, vport->num_disc_nodes);
1217
1218 /* Check to see if link went down during discovery */ 1196 /* Check to see if link went down during discovery */
1219 if (lpfc_els_chk_latt(vport)) { 1197 if (lpfc_els_chk_latt(vport)) {
1220 spin_lock_irq(shost->host_lock); 1198 spin_lock_irq(shost->host_lock);
@@ -1374,15 +1352,12 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1374 "LOGO cmpl: status:x%x/x%x did:x%x", 1352 "LOGO cmpl: status:x%x/x%x did:x%x",
1375 irsp->ulpStatus, irsp->un.ulpWord[4], 1353 irsp->ulpStatus, irsp->un.ulpWord[4],
1376 ndlp->nlp_DID); 1354 ndlp->nlp_DID);
1377
1378 /* LOGO completes to NPort <nlp_DID> */ 1355 /* LOGO completes to NPort <nlp_DID> */
1379 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1356 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1380 "%d (%d):0105 LOGO completes to NPort x%x " 1357 "0105 LOGO completes to NPort x%x "
1381 "Data: x%x x%x x%x x%x\n", 1358 "Data: x%x x%x x%x x%x\n",
1382 phba->brd_no, vport->vpi, ndlp->nlp_DID, 1359 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
1383 irsp->ulpStatus, irsp->un.ulpWord[4], irsp->ulpTimeout, 1360 irsp->ulpTimeout, vport->num_disc_nodes);
1384 vport->num_disc_nodes);
1385
1386 /* Check to see if link went down during discovery */ 1361 /* Check to see if link went down during discovery */
1387 if (lpfc_els_chk_latt(vport)) 1362 if (lpfc_els_chk_latt(vport))
1388 goto out; 1363 goto out;
@@ -1488,15 +1463,11 @@ lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1488 "ELS cmd cmpl: status:x%x/x%x did:x%x", 1463 "ELS cmd cmpl: status:x%x/x%x did:x%x",
1489 irsp->ulpStatus, irsp->un.ulpWord[4], 1464 irsp->ulpStatus, irsp->un.ulpWord[4],
1490 irsp->un.elsreq64.remoteID); 1465 irsp->un.elsreq64.remoteID);
1491
1492 /* ELS cmd tag <ulpIoTag> completes */ 1466 /* ELS cmd tag <ulpIoTag> completes */
1493 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1467 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1494 "%d (%d):0106 ELS cmd tag x%x completes Data: x%x x%x " 1468 "0106 ELS cmd tag x%x completes Data: x%x x%x x%x\n",
1495 "x%x\n", 1469 irsp->ulpIoTag, irsp->ulpStatus,
1496 phba->brd_no, vport->vpi, 1470 irsp->un.ulpWord[4], irsp->ulpTimeout);
1497 irsp->ulpIoTag, irsp->ulpStatus,
1498 irsp->un.ulpWord[4], irsp->ulpTimeout);
1499
1500 /* Check to see if link went down during discovery */ 1471 /* Check to see if link went down during discovery */
1501 lpfc_els_chk_latt(vport); 1472 lpfc_els_chk_latt(vport);
1502 lpfc_els_free_iocb(phba, cmdiocb); 1473 lpfc_els_free_iocb(phba, cmdiocb);
@@ -1831,13 +1802,15 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1831 case IOERR_ILLEGAL_COMMAND: 1802 case IOERR_ILLEGAL_COMMAND:
1832 if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) && 1803 if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) &&
1833 (cmd == ELS_CMD_FDISC)) { 1804 (cmd == ELS_CMD_FDISC)) {
1834 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1805 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1835 "%d (%d):0124 FDISC failed (3/6) retrying...\n", 1806 "0124 FDISC failed (3/6) "
1836 phba->brd_no, vport->vpi); 1807 "retrying...\n");
1837 lpfc_mbx_unreg_vpi(vport); 1808 lpfc_mbx_unreg_vpi(vport);
1838 retry = 1; 1809 retry = 1;
1839 /* Always retry for this case */ 1810 /* FDISC retry policy */
1840 cmdiocb->retry = 0; 1811 maxretry = 48;
1812 if (cmdiocb->retry >= 32)
1813 delay = 1000;
1841 } 1814 }
1842 break; 1815 break;
1843 1816
@@ -1898,10 +1871,10 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1898 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && 1871 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) &&
1899 (cmd == ELS_CMD_FDISC) && 1872 (cmd == ELS_CMD_FDISC) &&
1900 (stat.un.b.lsRjtRsnCodeExp == LSEXP_OUT_OF_RESOURCE)){ 1873 (stat.un.b.lsRjtRsnCodeExp == LSEXP_OUT_OF_RESOURCE)){
1901 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1874 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1902 "%d (%d):0125 FDISC Failed (x%x)." 1875 "0125 FDISC Failed (x%x). "
1903 " Fabric out of resources\n", 1876 "Fabric out of resources\n",
1904 phba->brd_no, vport->vpi, stat.un.lsRjtError); 1877 stat.un.lsRjtError);
1905 lpfc_vport_set_state(vport, 1878 lpfc_vport_set_state(vport,
1906 FC_VPORT_NO_FABRIC_RSCS); 1879 FC_VPORT_NO_FABRIC_RSCS);
1907 } 1880 }
@@ -1913,8 +1886,10 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1913 delay = 1000; 1886 delay = 1000;
1914 maxretry = 48; 1887 maxretry = 48;
1915 } else if (cmd == ELS_CMD_FDISC) { 1888 } else if (cmd == ELS_CMD_FDISC) {
1916 /* Always retry for this case */ 1889 /* FDISC retry policy */
1917 cmdiocb->retry = 0; 1890 maxretry = 48;
1891 if (cmdiocb->retry >= 32)
1892 delay = 1000;
1918 } 1893 }
1919 retry = 1; 1894 retry = 1;
1920 break; 1895 break;
@@ -1926,10 +1901,10 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1926 ((stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_PNAME) || 1901 ((stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_PNAME) ||
1927 (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID)) 1902 (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID))
1928 ) { 1903 ) {
1929 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1904 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1930 "%d (%d):0123 FDISC Failed (x%x)." 1905 "0123 FDISC Failed (x%x). "
1931 " Fabric Detected Bad WWN\n", 1906 "Fabric Detected Bad WWN\n",
1932 phba->brd_no, vport->vpi, stat.un.lsRjtError); 1907 stat.un.lsRjtError);
1933 lpfc_vport_set_state(vport, 1908 lpfc_vport_set_state(vport,
1934 FC_VPORT_FABRIC_REJ_WWN); 1909 FC_VPORT_FABRIC_REJ_WWN);
1935 } 1910 }
@@ -1959,11 +1934,10 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1959 if (retry) { 1934 if (retry) {
1960 1935
1961 /* Retry ELS command <elsCmd> to remote NPORT <did> */ 1936 /* Retry ELS command <elsCmd> to remote NPORT <did> */
1962 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1937 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1963 "%d (%d):0107 Retry ELS command x%x to remote " 1938 "0107 Retry ELS command x%x to remote "
1964 "NPORT x%x Data: x%x x%x\n", 1939 "NPORT x%x Data: x%x x%x\n",
1965 phba->brd_no, vport->vpi, 1940 cmd, did, cmdiocb->retry, delay);
1966 cmd, did, cmdiocb->retry, delay);
1967 1941
1968 if (((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) && 1942 if (((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) &&
1969 ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || 1943 ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) ||
@@ -2031,14 +2005,12 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2031 return 1; 2005 return 1;
2032 } 2006 }
2033 } 2007 }
2034
2035 /* No retry ELS command <elsCmd> to remote NPORT <did> */ 2008 /* No retry ELS command <elsCmd> to remote NPORT <did> */
2036 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2009 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2037 "%d (%d):0108 No retry ELS command x%x to remote " 2010 "0108 No retry ELS command x%x to remote "
2038 "NPORT x%x Data: x%x\n", 2011 "NPORT x%x Retried:%d Error:x%x/%x\n",
2039 phba->brd_no, vport->vpi, 2012 cmd, did, cmdiocb->retry, irsp->ulpStatus,
2040 cmd, did, cmdiocb->retry); 2013 irsp->un.ulpWord[4]);
2041
2042 return 0; 2014 return 0;
2043} 2015}
2044 2016
@@ -2087,14 +2059,12 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2087 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2059 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
2088 "ACC LOGO cmpl: status:x%x/x%x did:x%x", 2060 "ACC LOGO cmpl: status:x%x/x%x did:x%x",
2089 irsp->ulpStatus, irsp->un.ulpWord[4], ndlp->nlp_DID); 2061 irsp->ulpStatus, irsp->un.ulpWord[4], ndlp->nlp_DID);
2090
2091 /* ACC to LOGO completes to NPort <nlp_DID> */ 2062 /* ACC to LOGO completes to NPort <nlp_DID> */
2092 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2063 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2093 "%d (%d):0109 ACC to LOGO completes to NPort x%x " 2064 "0109 ACC to LOGO completes to NPort x%x "
2094 "Data: x%x x%x x%x\n", 2065 "Data: x%x x%x x%x\n",
2095 phba->brd_no, vport->vpi, ndlp->nlp_DID, 2066 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2096 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2067 ndlp->nlp_rpi);
2097
2098 switch (ndlp->nlp_state) { 2068 switch (ndlp->nlp_state) {
2099 case NLP_STE_UNUSED_NODE: /* node is just allocated */ 2069 case NLP_STE_UNUSED_NODE: /* node is just allocated */
2100 lpfc_drop_node(vport, ndlp); 2070 lpfc_drop_node(vport, ndlp);
@@ -2153,20 +2123,17 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2153 } 2123 }
2154 2124
2155 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2125 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
2156 "ACC cmpl: status:x%x/x%x did:x%x", 2126 "ELS rsp cmpl: status:x%x/x%x did:x%x",
2157 irsp->ulpStatus, irsp->un.ulpWord[4], 2127 irsp->ulpStatus, irsp->un.ulpWord[4],
2158 irsp->un.rcvels.remoteID); 2128 cmdiocb->iocb.un.elsreq64.remoteID);
2159
2160 /* ELS response tag <ulpIoTag> completes */ 2129 /* ELS response tag <ulpIoTag> completes */
2161 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2130 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2162 "%d (%d):0110 ELS response tag x%x completes " 2131 "0110 ELS response tag x%x completes "
2163 "Data: x%x x%x x%x x%x x%x x%x x%x\n", 2132 "Data: x%x x%x x%x x%x x%x x%x x%x\n",
2164 phba->brd_no, vport->vpi, 2133 cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus,
2165 cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus, 2134 rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout,
2166 rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout, 2135 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2167 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, 2136 ndlp->nlp_rpi);
2168 ndlp->nlp_rpi);
2169
2170 if (mbox) { 2137 if (mbox) {
2171 if ((rspiocb->iocb.ulpStatus == 0) 2138 if ((rspiocb->iocb.ulpStatus == 0)
2172 && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { 2139 && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) {
@@ -2219,7 +2186,7 @@ out:
2219int 2186int
2220lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, 2187lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
2221 struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, 2188 struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp,
2222 LPFC_MBOXQ_t *mbox, uint8_t newnode) 2189 LPFC_MBOXQ_t *mbox)
2223{ 2190{
2224 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2191 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2225 struct lpfc_hba *phba = vport->phba; 2192 struct lpfc_hba *phba = vport->phba;
@@ -2305,20 +2272,13 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
2305 default: 2272 default:
2306 return 1; 2273 return 1;
2307 } 2274 }
2308
2309 if (newnode) {
2310 lpfc_nlp_put(ndlp);
2311 elsiocb->context1 = NULL;
2312 }
2313
2314 /* Xmit ELS ACC response tag <ulpIoTag> */ 2275 /* Xmit ELS ACC response tag <ulpIoTag> */
2315 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2276 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2316 "%d (%d):0128 Xmit ELS ACC response tag x%x, XRI: x%x, " 2277 "0128 Xmit ELS ACC response tag x%x, XRI: x%x, "
2317 "DID: x%x, nlp_flag: x%x nlp_state: x%x RPI: x%x\n", 2278 "DID: x%x, nlp_flag: x%x nlp_state: x%x RPI: x%x\n",
2318 phba->brd_no, vport->vpi, elsiocb->iotag, 2279 elsiocb->iotag, elsiocb->iocb.ulpContext,
2319 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2280 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2320 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2281 ndlp->nlp_rpi);
2321
2322 if (ndlp->nlp_flag & NLP_LOGO_ACC) { 2282 if (ndlp->nlp_flag & NLP_LOGO_ACC) {
2323 spin_lock_irq(shost->host_lock); 2283 spin_lock_irq(shost->host_lock);
2324 ndlp->nlp_flag &= ~NLP_LOGO_ACC; 2284 ndlp->nlp_flag &= ~NLP_LOGO_ACC;
@@ -2370,20 +2330,17 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError,
2370 pcmd += sizeof(uint32_t); 2330 pcmd += sizeof(uint32_t);
2371 *((uint32_t *) (pcmd)) = rejectError; 2331 *((uint32_t *) (pcmd)) = rejectError;
2372 2332
2373 if (mbox) { 2333 if (mbox)
2374 elsiocb->context_un.mbox = mbox; 2334 elsiocb->context_un.mbox = mbox;
2375 elsiocb->context1 = lpfc_nlp_get(ndlp);
2376 }
2377 2335
2378 /* Xmit ELS RJT <err> response tag <ulpIoTag> */ 2336 /* Xmit ELS RJT <err> response tag <ulpIoTag> */
2379 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2337 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2380 "%d (%d):0129 Xmit ELS RJT x%x response tag x%x " 2338 "0129 Xmit ELS RJT x%x response tag x%x "
2381 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " 2339 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, "
2382 "rpi x%x\n", 2340 "rpi x%x\n",
2383 phba->brd_no, vport->vpi, rejectError, elsiocb->iotag, 2341 rejectError, elsiocb->iotag,
2384 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2342 elsiocb->iocb.ulpContext, ndlp->nlp_DID,
2385 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2343 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
2386
2387 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2344 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
2388 "Issue LS_RJT: did:x%x flg:x%x err:x%x", 2345 "Issue LS_RJT: did:x%x flg:x%x err:x%x",
2389 ndlp->nlp_DID, ndlp->nlp_flag, rejectError); 2346 ndlp->nlp_DID, ndlp->nlp_flag, rejectError);
@@ -2391,6 +2348,15 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError,
2391 phba->fc_stat.elsXmitLSRJT++; 2348 phba->fc_stat.elsXmitLSRJT++;
2392 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 2349 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
2393 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0); 2350 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0);
2351
2352 /* If the node is in the UNUSED state, and we are sending
2353 * a reject, we are done with it. Release driver reference
2354 * count here. The outstanding els will release its reference on
2355 * completion and the node can be freed then.
2356 */
2357 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
2358 lpfc_nlp_put(ndlp);
2359
2394 if (rc == IOCB_ERROR) { 2360 if (rc == IOCB_ERROR) {
2395 lpfc_els_free_iocb(phba, elsiocb); 2361 lpfc_els_free_iocb(phba, elsiocb);
2396 return 1; 2362 return 1;
@@ -2423,13 +2389,12 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
2423 icmd->ulpContext = oldcmd->ulpContext; /* Xri */ 2389 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2424 2390
2425 /* Xmit ADISC ACC response tag <ulpIoTag> */ 2391 /* Xmit ADISC ACC response tag <ulpIoTag> */
2426 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2392 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2427 "%d (%d):0130 Xmit ADISC ACC response iotag x%x xri: " 2393 "0130 Xmit ADISC ACC response iotag x%x xri: "
2428 "x%x, did x%x, nlp_flag x%x, nlp_state x%x rpi x%x\n", 2394 "x%x, did x%x, nlp_flag x%x, nlp_state x%x rpi x%x\n",
2429 phba->brd_no, vport->vpi, elsiocb->iotag, 2395 elsiocb->iotag, elsiocb->iocb.ulpContext,
2430 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2396 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2431 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2397 ndlp->nlp_rpi);
2432
2433 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2398 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2434 2399
2435 *((uint32_t *) (pcmd)) = ELS_CMD_ACC; 2400 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
@@ -2483,15 +2448,13 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
2483 icmd = &elsiocb->iocb; 2448 icmd = &elsiocb->iocb;
2484 oldcmd = &oldiocb->iocb; 2449 oldcmd = &oldiocb->iocb;
2485 icmd->ulpContext = oldcmd->ulpContext; /* Xri */ 2450 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2486
2487 /* Xmit PRLI ACC response tag <ulpIoTag> */ 2451 /* Xmit PRLI ACC response tag <ulpIoTag> */
2488 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2452 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2489 "%d (%d):0131 Xmit PRLI ACC response tag x%x xri x%x, " 2453 "0131 Xmit PRLI ACC response tag x%x xri x%x, "
2490 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", 2454 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n",
2491 phba->brd_no, vport->vpi, elsiocb->iotag, 2455 elsiocb->iotag, elsiocb->iocb.ulpContext,
2492 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2456 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2493 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2457 ndlp->nlp_rpi);
2494
2495 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2458 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2496 2459
2497 *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK)); 2460 *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK));
@@ -2565,16 +2528,11 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format,
2565 icmd = &elsiocb->iocb; 2528 icmd = &elsiocb->iocb;
2566 oldcmd = &oldiocb->iocb; 2529 oldcmd = &oldiocb->iocb;
2567 icmd->ulpContext = oldcmd->ulpContext; /* Xri */ 2530 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2568
2569 /* Xmit RNID ACC response tag <ulpIoTag> */ 2531 /* Xmit RNID ACC response tag <ulpIoTag> */
2570 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2532 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2571 "%d (%d):0132 Xmit RNID ACC response tag x%x " 2533 "0132 Xmit RNID ACC response tag x%x xri x%x\n",
2572 "xri x%x\n", 2534 elsiocb->iotag, elsiocb->iocb.ulpContext);
2573 phba->brd_no, vport->vpi, elsiocb->iotag,
2574 elsiocb->iocb.ulpContext);
2575
2576 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2535 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2577
2578 *((uint32_t *) (pcmd)) = ELS_CMD_ACC; 2536 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
2579 pcmd += sizeof(uint32_t); 2537 pcmd += sizeof(uint32_t);
2580 2538
@@ -2641,7 +2599,7 @@ lpfc_els_disc_adisc(struct lpfc_vport *vport)
2641 sentadisc++; 2599 sentadisc++;
2642 vport->num_disc_nodes++; 2600 vport->num_disc_nodes++;
2643 if (vport->num_disc_nodes >= 2601 if (vport->num_disc_nodes >=
2644 vport->phba->cfg_discovery_threads) { 2602 vport->cfg_discovery_threads) {
2645 spin_lock_irq(shost->host_lock); 2603 spin_lock_irq(shost->host_lock);
2646 vport->fc_flag |= FC_NLP_MORE; 2604 vport->fc_flag |= FC_NLP_MORE;
2647 spin_unlock_irq(shost->host_lock); 2605 spin_unlock_irq(shost->host_lock);
@@ -2676,7 +2634,7 @@ lpfc_els_disc_plogi(struct lpfc_vport *vport)
2676 sentplogi++; 2634 sentplogi++;
2677 vport->num_disc_nodes++; 2635 vport->num_disc_nodes++;
2678 if (vport->num_disc_nodes >= 2636 if (vport->num_disc_nodes >=
2679 vport->phba->cfg_discovery_threads) { 2637 vport->cfg_discovery_threads) {
2680 spin_lock_irq(shost->host_lock); 2638 spin_lock_irq(shost->host_lock);
2681 vport->fc_flag |= FC_NLP_MORE; 2639 vport->fc_flag |= FC_NLP_MORE;
2682 spin_unlock_irq(shost->host_lock); 2640 spin_unlock_irq(shost->host_lock);
@@ -2717,7 +2675,6 @@ lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did)
2717 D_ID rscn_did; 2675 D_ID rscn_did;
2718 uint32_t *lp; 2676 uint32_t *lp;
2719 uint32_t payload_len, i; 2677 uint32_t payload_len, i;
2720 struct lpfc_hba *phba = vport->phba;
2721 2678
2722 ns_did.un.word = did; 2679 ns_did.un.word = did;
2723 2680
@@ -2752,12 +2709,10 @@ lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did)
2752 break; 2709 break;
2753 default: 2710 default:
2754 /* Unknown Identifier in RSCN node */ 2711 /* Unknown Identifier in RSCN node */
2755 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2712 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2756 "%d (%d):0217 Unknown " 2713 "0217 Unknown Identifier in "
2757 "Identifier in RSCN payload " 2714 "RSCN payload Data: x%x\n",
2758 "Data: x%x\n", 2715 rscn_did.un.word);
2759 phba->brd_no, vport->vpi,
2760 rscn_did.un.word);
2761 case 3: /* Whole Fabric effected */ 2716 case 3: /* Whole Fabric effected */
2762 return did; 2717 return did;
2763 } 2718 }
@@ -2796,12 +2751,11 @@ lpfc_rscn_recovery_check(struct lpfc_vport *vport)
2796 2751
2797static int 2752static int
2798lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, 2753lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2799 struct lpfc_nodelist *ndlp, uint8_t newnode) 2754 struct lpfc_nodelist *ndlp)
2800{ 2755{
2801 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2756 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2802 struct lpfc_hba *phba = vport->phba; 2757 struct lpfc_hba *phba = vport->phba;
2803 struct lpfc_dmabuf *pcmd; 2758 struct lpfc_dmabuf *pcmd;
2804 struct lpfc_vport *next_vport;
2805 uint32_t *lp, *datap; 2759 uint32_t *lp, *datap;
2806 IOCB_t *icmd; 2760 IOCB_t *icmd;
2807 uint32_t payload_len, length, nportid, *cmd; 2761 uint32_t payload_len, length, nportid, *cmd;
@@ -2815,13 +2769,10 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2815 2769
2816 payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); 2770 payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK);
2817 payload_len -= sizeof(uint32_t); /* take off word 0 */ 2771 payload_len -= sizeof(uint32_t); /* take off word 0 */
2818
2819 /* RSCN received */ 2772 /* RSCN received */
2820 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2773 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2821 "%d (%d):0214 RSCN received Data: x%x x%x x%x x%x\n", 2774 "0214 RSCN received Data: x%x x%x x%x x%x\n",
2822 phba->brd_no, vport->vpi, vport->fc_flag, payload_len, 2775 vport->fc_flag, payload_len, *lp, rscn_cnt);
2823 *lp, rscn_cnt);
2824
2825 for (i = 0; i < payload_len/sizeof(uint32_t); i++) 2776 for (i = 0; i < payload_len/sizeof(uint32_t); i++)
2826 fc_host_post_event(shost, fc_get_event_number(), 2777 fc_host_post_event(shost, fc_get_event_number(),
2827 FCH_EVT_RSCN, lp[i]); 2778 FCH_EVT_RSCN, lp[i]);
@@ -2834,8 +2785,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2834 "RCV RSCN ignore: did:x%x/ste:x%x flg:x%x", 2785 "RCV RSCN ignore: did:x%x/ste:x%x flg:x%x",
2835 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); 2786 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
2836 2787
2837 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 2788 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2838 newnode);
2839 return 0; 2789 return 0;
2840 } 2790 }
2841 2791
@@ -2843,7 +2793,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2843 * just ACC and ignore it. 2793 * just ACC and ignore it.
2844 */ 2794 */
2845 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && 2795 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) &&
2846 !(phba->cfg_peer_port_login)) { 2796 !(vport->cfg_peer_port_login)) {
2847 i = payload_len; 2797 i = payload_len;
2848 datap = lp; 2798 datap = lp;
2849 while (i > 0) { 2799 while (i > 0) {
@@ -2851,28 +2801,23 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2851 nportid = ((be32_to_cpu(nportid)) & Mask_DID); 2801 nportid = ((be32_to_cpu(nportid)) & Mask_DID);
2852 i -= sizeof(uint32_t); 2802 i -= sizeof(uint32_t);
2853 rscn_id++; 2803 rscn_id++;
2854 list_for_each_entry(next_vport, &phba->port_list, 2804 if (lpfc_find_vport_by_did(phba, nportid))
2855 listentry) { 2805 hba_id++;
2856 if (nportid == next_vport->fc_myDID) {
2857 hba_id++;
2858 break;
2859 }
2860 }
2861 } 2806 }
2862 if (rscn_id == hba_id) { 2807 if (rscn_id == hba_id) {
2863 /* ALL NPortIDs in RSCN are on HBA */ 2808 /* ALL NPortIDs in RSCN are on HBA */
2864 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2809 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2865 "%d (%d):0214 Ignore RSCN Data: x%x x%x x%x x%x\n", 2810 "0214 Ignore RSCN "
2866 phba->brd_no, vport->vpi, vport->fc_flag, payload_len, 2811 "Data: x%x x%x x%x x%x\n",
2867 *lp, rscn_cnt); 2812 vport->fc_flag, payload_len,
2868 2813 *lp, rscn_cnt);
2869 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 2814 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
2870 "RCV RSCN vport: did:x%x/ste:x%x flg:x%x", 2815 "RCV RSCN vport: did:x%x/ste:x%x flg:x%x",
2871 ndlp->nlp_DID, vport->port_state, 2816 ndlp->nlp_DID, vport->port_state,
2872 ndlp->nlp_flag); 2817 ndlp->nlp_flag);
2873 2818
2874 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, 2819 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb,
2875 ndlp, NULL, newnode); 2820 ndlp, NULL);
2876 return 0; 2821 return 0;
2877 } 2822 }
2878 } 2823 }
@@ -2911,27 +2856,24 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2911 } 2856 }
2912 2857
2913 /* Deferred RSCN */ 2858 /* Deferred RSCN */
2914 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2859 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2915 "%d (%d):0235 Deferred RSCN " 2860 "0235 Deferred RSCN "
2916 "Data: x%x x%x x%x\n", 2861 "Data: x%x x%x x%x\n",
2917 phba->brd_no, vport->vpi, 2862 vport->fc_rscn_id_cnt, vport->fc_flag,
2918 vport->fc_rscn_id_cnt, vport->fc_flag, 2863 vport->port_state);
2919 vport->port_state);
2920 } else { 2864 } else {
2921 spin_lock_irq(shost->host_lock); 2865 spin_lock_irq(shost->host_lock);
2922 vport->fc_flag |= FC_RSCN_DISCOVERY; 2866 vport->fc_flag |= FC_RSCN_DISCOVERY;
2923 spin_unlock_irq(shost->host_lock); 2867 spin_unlock_irq(shost->host_lock);
2924 /* ReDiscovery RSCN */ 2868 /* ReDiscovery RSCN */
2925 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2869 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2926 "%d (%d):0234 ReDiscovery RSCN " 2870 "0234 ReDiscovery RSCN "
2927 "Data: x%x x%x x%x\n", 2871 "Data: x%x x%x x%x\n",
2928 phba->brd_no, vport->vpi, 2872 vport->fc_rscn_id_cnt, vport->fc_flag,
2929 vport->fc_rscn_id_cnt, vport->fc_flag, 2873 vport->port_state);
2930 vport->port_state);
2931 } 2874 }
2932 /* Send back ACC */ 2875 /* Send back ACC */
2933 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 2876 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2934 newnode);
2935 2877
2936 /* send RECOVERY event for ALL nodes that match RSCN payload */ 2878 /* send RECOVERY event for ALL nodes that match RSCN payload */
2937 lpfc_rscn_recovery_check(vport); 2879 lpfc_rscn_recovery_check(vport);
@@ -2956,7 +2898,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2956 lpfc_set_disctmo(vport); 2898 lpfc_set_disctmo(vport);
2957 2899
2958 /* Send back ACC */ 2900 /* Send back ACC */
2959 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, newnode); 2901 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2960 2902
2961 /* send RECOVERY event for ALL nodes that match RSCN payload */ 2903 /* send RECOVERY event for ALL nodes that match RSCN payload */
2962 lpfc_rscn_recovery_check(vport); 2904 lpfc_rscn_recovery_check(vport);
@@ -2980,11 +2922,10 @@ lpfc_els_handle_rscn(struct lpfc_vport *vport)
2980 lpfc_set_disctmo(vport); 2922 lpfc_set_disctmo(vport);
2981 2923
2982 /* RSCN processed */ 2924 /* RSCN processed */
2983 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2925 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2984 "%d (%d):0215 RSCN processed Data: x%x x%x x%x x%x\n", 2926 "0215 RSCN processed Data: x%x x%x x%x x%x\n",
2985 phba->brd_no, vport->vpi, 2927 vport->fc_flag, 0, vport->fc_rscn_id_cnt,
2986 vport->fc_flag, 0, vport->fc_rscn_id_cnt, 2928 vport->port_state);
2987 vport->port_state);
2988 2929
2989 /* To process RSCN, first compare RSCN data with NameServer */ 2930 /* To process RSCN, first compare RSCN data with NameServer */
2990 vport->fc_ns_retry = 0; 2931 vport->fc_ns_retry = 0;
@@ -3026,7 +2967,7 @@ lpfc_els_handle_rscn(struct lpfc_vport *vport)
3026 2967
3027static int 2968static int
3028lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, 2969lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3029 struct lpfc_nodelist *ndlp, uint8_t newnode) 2970 struct lpfc_nodelist *ndlp)
3030{ 2971{
3031 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2972 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3032 struct lpfc_hba *phba = vport->phba; 2973 struct lpfc_hba *phba = vport->phba;
@@ -3052,10 +2993,10 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3052 2993
3053 /* An FLOGI ELS command <elsCmd> was received from DID <did> in 2994 /* An FLOGI ELS command <elsCmd> was received from DID <did> in
3054 Loop Mode */ 2995 Loop Mode */
3055 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 2996 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3056 "%d (%d):0113 An FLOGI ELS command x%x was " 2997 "0113 An FLOGI ELS command x%x was "
3057 "received from DID x%x in Loop Mode\n", 2998 "received from DID x%x in Loop Mode\n",
3058 phba->brd_no, vport->vpi, cmd, did); 2999 cmd, did);
3059 return 1; 3000 return 1;
3060 } 3001 }
3061 3002
@@ -3109,7 +3050,7 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3109 } 3050 }
3110 3051
3111 /* Send back ACC */ 3052 /* Send back ACC */
3112 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, newnode); 3053 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL);
3113 3054
3114 return 0; 3055 return 0;
3115} 3056}
@@ -3226,16 +3167,13 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3226 rps_rsp->primSeqErrCnt = be32_to_cpu(mb->un.varRdLnk.primSeqErrCnt); 3167 rps_rsp->primSeqErrCnt = be32_to_cpu(mb->un.varRdLnk.primSeqErrCnt);
3227 rps_rsp->invalidXmitWord = be32_to_cpu(mb->un.varRdLnk.invalidXmitWord); 3168 rps_rsp->invalidXmitWord = be32_to_cpu(mb->un.varRdLnk.invalidXmitWord);
3228 rps_rsp->crcCnt = be32_to_cpu(mb->un.varRdLnk.crcCnt); 3169 rps_rsp->crcCnt = be32_to_cpu(mb->un.varRdLnk.crcCnt);
3229
3230 /* Xmit ELS RPS ACC response tag <ulpIoTag> */ 3170 /* Xmit ELS RPS ACC response tag <ulpIoTag> */
3231 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3171 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
3232 "%d (%d):0118 Xmit ELS RPS ACC response tag x%x " 3172 "0118 Xmit ELS RPS ACC response tag x%x xri x%x, "
3233 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " 3173 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n",
3234 "rpi x%x\n", 3174 elsiocb->iotag, elsiocb->iocb.ulpContext,
3235 phba->brd_no, ndlp->vport->vpi, elsiocb->iotag, 3175 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
3236 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 3176 ndlp->nlp_rpi);
3237 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
3238
3239 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 3177 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
3240 phba->fc_stat.elsXmitACC++; 3178 phba->fc_stat.elsXmitACC++;
3241 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) 3179 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR)
@@ -3337,21 +3275,16 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize,
3337 rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID); 3275 rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID);
3338 memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname, 3276 memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname,
3339 sizeof(struct lpfc_name)); 3277 sizeof(struct lpfc_name));
3340
3341 memcpy(pcmd, &rpl_rsp, cmdsize - sizeof(uint32_t)); 3278 memcpy(pcmd, &rpl_rsp, cmdsize - sizeof(uint32_t));
3342
3343
3344 /* Xmit ELS RPL ACC response tag <ulpIoTag> */ 3279 /* Xmit ELS RPL ACC response tag <ulpIoTag> */
3345 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3280 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3346 "%d (%d):0120 Xmit ELS RPL ACC response tag x%x " 3281 "0120 Xmit ELS RPL ACC response tag x%x "
3347 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " 3282 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, "
3348 "rpi x%x\n", 3283 "rpi x%x\n",
3349 phba->brd_no, vport->vpi, elsiocb->iotag, 3284 elsiocb->iotag, elsiocb->iocb.ulpContext,
3350 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 3285 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
3351 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 3286 ndlp->nlp_rpi);
3352
3353 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 3287 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
3354
3355 phba->fc_stat.elsXmitACC++; 3288 phba->fc_stat.elsXmitACC++;
3356 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) { 3289 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
3357 lpfc_els_free_iocb(phba, elsiocb); 3290 lpfc_els_free_iocb(phba, elsiocb);
@@ -3404,7 +3337,6 @@ static int
3404lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, 3337lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3405 struct lpfc_nodelist *ndlp) 3338 struct lpfc_nodelist *ndlp)
3406{ 3339{
3407 struct lpfc_hba *phba = vport->phba;
3408 struct lpfc_dmabuf *pcmd; 3340 struct lpfc_dmabuf *pcmd;
3409 uint32_t *lp; 3341 uint32_t *lp;
3410 IOCB_t *icmd; 3342 IOCB_t *icmd;
@@ -3418,12 +3350,9 @@ lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3418 3350
3419 cmd = *lp++; 3351 cmd = *lp++;
3420 fp = (FARP *) lp; 3352 fp = (FARP *) lp;
3421
3422 /* FARP-REQ received from DID <did> */ 3353 /* FARP-REQ received from DID <did> */
3423 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3354 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3424 "%d (%d):0601 FARP-REQ received from DID x%x\n", 3355 "0601 FARP-REQ received from DID x%x\n", did);
3425 phba->brd_no, vport->vpi, did);
3426
3427 /* We will only support match on WWPN or WWNN */ 3356 /* We will only support match on WWPN or WWNN */
3428 if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) { 3357 if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) {
3429 return 0; 3358 return 0;
@@ -3471,7 +3400,6 @@ lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3471 uint32_t *lp; 3400 uint32_t *lp;
3472 IOCB_t *icmd; 3401 IOCB_t *icmd;
3473 uint32_t cmd, did; 3402 uint32_t cmd, did;
3474 struct lpfc_hba *phba = vport->phba;
3475 3403
3476 icmd = &cmdiocb->iocb; 3404 icmd = &cmdiocb->iocb;
3477 did = icmd->un.elsreq64.remoteID; 3405 did = icmd->un.elsreq64.remoteID;
@@ -3480,11 +3408,10 @@ lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3480 3408
3481 cmd = *lp++; 3409 cmd = *lp++;
3482 /* FARP-RSP received from DID <did> */ 3410 /* FARP-RSP received from DID <did> */
3483 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3411 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3484 "%d (%d):0600 FARP-RSP received from DID x%x\n", 3412 "0600 FARP-RSP received from DID x%x\n", did);
3485 phba->brd_no, vport->vpi, did);
3486 /* ACCEPT the Farp resp request */ 3413 /* ACCEPT the Farp resp request */
3487 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 3414 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
3488 3415
3489 return 0; 3416 return 0;
3490} 3417}
@@ -3502,10 +3429,8 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3502 struct lpfc_hba *phba = vport->phba; 3429 struct lpfc_hba *phba = vport->phba;
3503 3430
3504 /* FAN received */ 3431 /* FAN received */
3505 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3432 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3506 "%d (%d):0265 FAN received\n", 3433 "0265 FAN received\n");
3507 phba->brd_no, vport->vpi);
3508
3509 icmd = &cmdiocb->iocb; 3434 icmd = &cmdiocb->iocb;
3510 did = icmd->un.elsreq64.remoteID; 3435 did = icmd->un.elsreq64.remoteID;
3511 pcmd = (struct lpfc_dmabuf *)cmdiocb->context2; 3436 pcmd = (struct lpfc_dmabuf *)cmdiocb->context2;
@@ -3664,13 +3589,10 @@ lpfc_els_timeout_handler(struct lpfc_vport *vport)
3664 if (ndlp) 3589 if (ndlp)
3665 remote_ID = ndlp->nlp_DID; 3590 remote_ID = ndlp->nlp_DID;
3666 } 3591 }
3667 3592 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3668 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 3593 "0127 ELS timeout Data: x%x x%x x%x "
3669 "%d (%d):0127 ELS timeout Data: x%x x%x x%x " 3594 "x%x\n", els_command,
3670 "x%x\n", 3595 remote_ID, cmd->ulpCommand, cmd->ulpIoTag);
3671 phba->brd_no, vport->vpi, els_command,
3672 remote_ID, cmd->ulpCommand, cmd->ulpIoTag);
3673
3674 lpfc_sli_issue_abort_iotag(phba, pring, piocb); 3596 lpfc_sli_issue_abort_iotag(phba, pring, piocb);
3675 } 3597 }
3676 spin_unlock_irq(&phba->hbalock); 3598 spin_unlock_irq(&phba->hbalock);
@@ -3741,6 +3663,50 @@ lpfc_els_flush_cmd(struct lpfc_vport *vport)
3741 return; 3663 return;
3742} 3664}
3743 3665
3666void
3667lpfc_els_flush_all_cmd(struct lpfc_hba *phba)
3668{
3669 LIST_HEAD(completions);
3670 struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING];
3671 struct lpfc_iocbq *tmp_iocb, *piocb;
3672 IOCB_t *cmd = NULL;
3673
3674 lpfc_fabric_abort_hba(phba);
3675 spin_lock_irq(&phba->hbalock);
3676 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) {
3677 cmd = &piocb->iocb;
3678 if (piocb->iocb_flag & LPFC_IO_LIBDFC)
3679 continue;
3680 /* Do not flush out the QUE_RING and ABORT/CLOSE iocbs */
3681 if (cmd->ulpCommand == CMD_QUE_RING_BUF_CN ||
3682 cmd->ulpCommand == CMD_QUE_RING_BUF64_CN ||
3683 cmd->ulpCommand == CMD_CLOSE_XRI_CN ||
3684 cmd->ulpCommand == CMD_ABORT_XRI_CN)
3685 continue;
3686 list_move_tail(&piocb->list, &completions);
3687 pring->txq_cnt--;
3688 }
3689 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) {
3690 if (piocb->iocb_flag & LPFC_IO_LIBDFC)
3691 continue;
3692 lpfc_sli_issue_abort_iotag(phba, pring, piocb);
3693 }
3694 spin_unlock_irq(&phba->hbalock);
3695 while (!list_empty(&completions)) {
3696 piocb = list_get_first(&completions, struct lpfc_iocbq, list);
3697 cmd = &piocb->iocb;
3698 list_del_init(&piocb->list);
3699 if (!piocb->iocb_cmpl)
3700 lpfc_sli_release_iocbq(phba, piocb);
3701 else {
3702 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
3703 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
3704 (piocb->iocb_cmpl) (phba, piocb, piocb);
3705 }
3706 }
3707 return;
3708}
3709
3744static void 3710static void
3745lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, 3711lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3746 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb) 3712 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb)
@@ -3801,11 +3767,9 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3801 cmd &= ELS_CMD_MASK; 3767 cmd &= ELS_CMD_MASK;
3802 } 3768 }
3803 /* ELS command <elsCmd> received from NPORT <did> */ 3769 /* ELS command <elsCmd> received from NPORT <did> */
3804 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3770 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3805 "%d (%d):0112 ELS command x%x received from NPORT x%x " 3771 "0112 ELS command x%x received from NPORT x%x "
3806 "Data: x%x\n", phba->brd_no, vport->vpi, cmd, did, 3772 "Data: x%x\n", cmd, did, vport->port_state);
3807 vport->port_state);
3808
3809 switch (cmd) { 3773 switch (cmd) {
3810 case ELS_CMD_PLOGI: 3774 case ELS_CMD_PLOGI:
3811 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3775 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3829,7 +3793,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3829 did, vport->port_state, ndlp->nlp_flag); 3793 did, vport->port_state, ndlp->nlp_flag);
3830 3794
3831 phba->fc_stat.elsRcvFLOGI++; 3795 phba->fc_stat.elsRcvFLOGI++;
3832 lpfc_els_rcv_flogi(vport, elsiocb, ndlp, newnode); 3796 lpfc_els_rcv_flogi(vport, elsiocb, ndlp);
3833 if (newnode) 3797 if (newnode)
3834 lpfc_drop_node(vport, ndlp); 3798 lpfc_drop_node(vport, ndlp);
3835 break; 3799 break;
@@ -3859,7 +3823,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3859 break; 3823 break;
3860 case ELS_CMD_RSCN: 3824 case ELS_CMD_RSCN:
3861 phba->fc_stat.elsRcvRSCN++; 3825 phba->fc_stat.elsRcvRSCN++;
3862 lpfc_els_rcv_rscn(vport, elsiocb, ndlp, newnode); 3826 lpfc_els_rcv_rscn(vport, elsiocb, ndlp);
3863 if (newnode) 3827 if (newnode)
3864 lpfc_drop_node(vport, ndlp); 3828 lpfc_drop_node(vport, ndlp);
3865 break; 3829 break;
@@ -3974,10 +3938,9 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3974 rjt_err = LSRJT_INVALID_CMD; 3938 rjt_err = LSRJT_INVALID_CMD;
3975 3939
3976 /* Unknown ELS command <elsCmd> received from NPORT <did> */ 3940 /* Unknown ELS command <elsCmd> received from NPORT <did> */
3977 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 3941 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3978 "%d (%d):0115 Unknown ELS command x%x " 3942 "0115 Unknown ELS command x%x "
3979 "received from NPORT x%x\n", 3943 "received from NPORT x%x\n", cmd, did);
3980 phba->brd_no, vport->vpi, cmd, did);
3981 if (newnode) 3944 if (newnode)
3982 lpfc_drop_node(vport, ndlp); 3945 lpfc_drop_node(vport, ndlp);
3983 break; 3946 break;
@@ -3990,19 +3953,16 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3990 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; 3953 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
3991 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp, 3954 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp,
3992 NULL); 3955 NULL);
3993 if (newnode)
3994 lpfc_drop_node(vport, ndlp);
3995 } 3956 }
3996 3957
3997 return; 3958 return;
3998 3959
3999dropit: 3960dropit:
4000 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 3961 lpfc_printf_log(phba, KERN_ERR, LOG_ELS,
4001 "%d (%d):0111 Dropping received ELS cmd " 3962 "(%d):0111 Dropping received ELS cmd "
4002 "Data: x%x x%x x%x\n", 3963 "Data: x%x x%x x%x\n",
4003 phba->brd_no, vport ? vport->vpi : 0xffff, 3964 vport ? vport->vpi : 0xffff, icmd->ulpStatus,
4004 icmd->ulpStatus, icmd->un.ulpWord[4], 3965 icmd->un.ulpWord[4], icmd->ulpTimeout);
4005 icmd->ulpTimeout);
4006 phba->fc_stat.elsRcvDrop++; 3966 phba->fc_stat.elsRcvDrop++;
4007} 3967}
4008 3968
@@ -4010,11 +3970,16 @@ static struct lpfc_vport *
4010lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi) 3970lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi)
4011{ 3971{
4012 struct lpfc_vport *vport; 3972 struct lpfc_vport *vport;
3973 unsigned long flags;
4013 3974
3975 spin_lock_irqsave(&phba->hbalock, flags);
4014 list_for_each_entry(vport, &phba->port_list, listentry) { 3976 list_for_each_entry(vport, &phba->port_list, listentry) {
4015 if (vport->vpi == vpi) 3977 if (vport->vpi == vpi) {
3978 spin_unlock_irqrestore(&phba->hbalock, flags);
4016 return vport; 3979 return vport;
3980 }
4017 } 3981 }
3982 spin_unlock_irqrestore(&phba->hbalock, flags);
4018 return NULL; 3983 return NULL;
4019} 3984}
4020 3985
@@ -4109,9 +4074,8 @@ lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport)
4109 return; 4074 return;
4110 } 4075 }
4111 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4076 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4112 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4077 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4113 "%d (%d):0251 NameServer login: no memory\n", 4078 "0251 NameServer login: no memory\n");
4114 phba->brd_no, vport->vpi);
4115 return; 4079 return;
4116 } 4080 }
4117 lpfc_nlp_init(vport, ndlp, NameServer_DID); 4081 lpfc_nlp_init(vport, ndlp, NameServer_DID);
@@ -4122,13 +4086,12 @@ lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport)
4122 4086
4123 if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) { 4087 if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) {
4124 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4088 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4125 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4089 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4126 "%d (%d):0252 Cannot issue NameServer login\n", 4090 "0252 Cannot issue NameServer login\n");
4127 phba->brd_no, vport->vpi);
4128 return; 4091 return;
4129 } 4092 }
4130 4093
4131 if (phba->cfg_fdmi_on) { 4094 if (vport->cfg_fdmi_on) {
4132 ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool, 4095 ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool,
4133 GFP_KERNEL); 4096 GFP_KERNEL);
4134 if (ndlp_fdmi) { 4097 if (ndlp_fdmi) {
@@ -4155,9 +4118,9 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
4155 lpfc_nlp_put(ndlp); 4118 lpfc_nlp_put(ndlp);
4156 4119
4157 if (mb->mbxStatus) { 4120 if (mb->mbxStatus) {
4158 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 4121 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
4159 "%d (%d):0915 Register VPI failed: 0x%x\n", 4122 "0915 Register VPI failed: 0x%x\n",
4160 phba->brd_no, vport->vpi, mb->mbxStatus); 4123 mb->mbxStatus);
4161 4124
4162 switch (mb->mbxStatus) { 4125 switch (mb->mbxStatus) {
4163 case 0x11: /* unsupported feature */ 4126 case 0x11: /* unsupported feature */
@@ -4206,17 +4169,14 @@ lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport,
4206 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 4169 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4207 4170
4208 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4171 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4209 4172 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
4210 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 4173 "0253 Register VPI: Can't send mbox\n");
4211 "%d (%d):0253 Register VPI: Cannot send mbox\n",
4212 phba->brd_no, vport->vpi);
4213 } 4174 }
4214 } else { 4175 } else {
4215 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4176 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4216 4177
4217 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 4178 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
4218 "%d (%d):0254 Register VPI: no memory\n", 4179 "0254 Register VPI: no memory\n");
4219 phba->brd_no, vport->vpi);
4220 4180
4221 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 4181 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4222 lpfc_nlp_put(ndlp); 4182 lpfc_nlp_put(ndlp);
@@ -4235,11 +4195,10 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
4235 IOCB_t *irsp = &rspiocb->iocb; 4195 IOCB_t *irsp = &rspiocb->iocb;
4236 struct lpfc_iocbq *piocb; 4196 struct lpfc_iocbq *piocb;
4237 4197
4238 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 4198 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4239 "%d (%d):0123 FDISC completes. x%x/x%x prevDID: x%x\n", 4199 "0123 FDISC completes. x%x/x%x prevDID: x%x\n",
4240 phba->brd_no, vport->vpi, 4200 irsp->ulpStatus, irsp->un.ulpWord[4],
4241 irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_prevDID); 4201 vport->fc_prevDID);
4242
4243 /* Since all FDISCs are being single threaded, we 4202 /* Since all FDISCs are being single threaded, we
4244 * must reset the discovery timer for ALL vports 4203 * must reset the discovery timer for ALL vports
4245 * waiting to send FDISC when one completes. 4204 * waiting to send FDISC when one completes.
@@ -4256,13 +4215,10 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
4256 /* Check for retry */ 4215 /* Check for retry */
4257 if (lpfc_els_retry(phba, cmdiocb, rspiocb)) 4216 if (lpfc_els_retry(phba, cmdiocb, rspiocb))
4258 goto out; 4217 goto out;
4259
4260 /* FDISC failed */ 4218 /* FDISC failed */
4261 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4219 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4262 "%d (%d):0124 FDISC failed. (%d/%d)\n", 4220 "0124 FDISC failed. (%d/%d)\n",
4263 phba->brd_no, vport->vpi, 4221 irsp->ulpStatus, irsp->un.ulpWord[4]);
4264 irsp->ulpStatus, irsp->un.ulpWord[4]);
4265
4266 if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING) 4222 if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING)
4267 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4223 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4268 4224
@@ -4328,10 +4284,8 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
4328 ELS_CMD_FDISC); 4284 ELS_CMD_FDISC);
4329 if (!elsiocb) { 4285 if (!elsiocb) {
4330 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4286 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4331 4287 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4332 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4288 "0255 Issue FDISC: no IOCB\n");
4333 "%d (%d):0255 Issue FDISC: no IOCB\n",
4334 phba->brd_no, vport->vpi);
4335 return 1; 4289 return 1;
4336 } 4290 }
4337 4291
@@ -4377,11 +4331,8 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
4377 if (rc == IOCB_ERROR) { 4331 if (rc == IOCB_ERROR) {
4378 lpfc_els_free_iocb(phba, elsiocb); 4332 lpfc_els_free_iocb(phba, elsiocb);
4379 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4333 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4380 4334 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4381 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4335 "0256 Issue FDISC: Cannot send IOCB\n");
4382 "%d (%d):0256 Issue FDISC: Cannot send IOCB\n",
4383 phba->brd_no, vport->vpi);
4384
4385 return 1; 4336 return 1;
4386 } 4337 }
4387 lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING); 4338 lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING);