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.c214
1 files changed, 124 insertions, 90 deletions
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 445826a4c98..7afc757338d 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -421,13 +421,13 @@ fail:
421 * @vport: pointer to a host virtual N_Port data structure. 421 * @vport: pointer to a host virtual N_Port data structure.
422 * 422 *
423 * This routine issues a REG_VFI mailbox for the vfi, vpi, fcfi triplet for 423 * This routine issues a REG_VFI mailbox for the vfi, vpi, fcfi triplet for
424 * the @vport. This mailbox command is necessary for FCoE only. 424 * the @vport. This mailbox command is necessary for SLI4 port only.
425 * 425 *
426 * Return code 426 * Return code
427 * 0 - successfully issued REG_VFI for @vport 427 * 0 - successfully issued REG_VFI for @vport
428 * A failure code otherwise. 428 * A failure code otherwise.
429 **/ 429 **/
430static int 430int
431lpfc_issue_reg_vfi(struct lpfc_vport *vport) 431lpfc_issue_reg_vfi(struct lpfc_vport *vport)
432{ 432{
433 struct lpfc_hba *phba = vport->phba; 433 struct lpfc_hba *phba = vport->phba;
@@ -438,10 +438,14 @@ lpfc_issue_reg_vfi(struct lpfc_vport *vport)
438 int rc = 0; 438 int rc = 0;
439 439
440 sp = &phba->fc_fabparam; 440 sp = &phba->fc_fabparam;
441 ndlp = lpfc_findnode_did(vport, Fabric_DID); 441 /* move forward in case of SLI4 FC port loopback test */
442 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { 442 if ((phba->sli_rev == LPFC_SLI_REV4) &&
443 rc = -ENODEV; 443 !(phba->link_flag & LS_LOOPBACK_MODE)) {
444 goto fail; 444 ndlp = lpfc_findnode_did(vport, Fabric_DID);
445 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) {
446 rc = -ENODEV;
447 goto fail;
448 }
445 } 449 }
446 450
447 dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); 451 dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
@@ -487,6 +491,54 @@ fail:
487} 491}
488 492
489/** 493/**
494 * lpfc_issue_unreg_vfi - Unregister VFI for this vport's fabric login
495 * @vport: pointer to a host virtual N_Port data structure.
496 *
497 * This routine issues a UNREG_VFI mailbox with the vfi, vpi, fcfi triplet for
498 * the @vport. This mailbox command is necessary for SLI4 port only.
499 *
500 * Return code
501 * 0 - successfully issued REG_VFI for @vport
502 * A failure code otherwise.
503 **/
504int
505lpfc_issue_unreg_vfi(struct lpfc_vport *vport)
506{
507 struct lpfc_hba *phba = vport->phba;
508 struct Scsi_Host *shost;
509 LPFC_MBOXQ_t *mboxq;
510 int rc;
511
512 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
513 if (!mboxq) {
514 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX,
515 "2556 UNREG_VFI mbox allocation failed"
516 "HBA state x%x\n", phba->pport->port_state);
517 return -ENOMEM;
518 }
519
520 lpfc_unreg_vfi(mboxq, vport);
521 mboxq->vport = vport;
522 mboxq->mbox_cmpl = lpfc_unregister_vfi_cmpl;
523
524 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT);
525 if (rc == MBX_NOT_FINISHED) {
526 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX,
527 "2557 UNREG_VFI issue mbox failed rc x%x "
528 "HBA state x%x\n",
529 rc, phba->pport->port_state);
530 mempool_free(mboxq, phba->mbox_mem_pool);
531 return -EIO;
532 }
533
534 shost = lpfc_shost_from_vport(vport);
535 spin_lock_irq(shost->host_lock);
536 vport->fc_flag &= ~FC_VFI_REGISTERED;
537 spin_unlock_irq(shost->host_lock);
538 return 0;
539}
540
541/**
490 * lpfc_check_clean_addr_bit - Check whether assigned FCID is clean. 542 * lpfc_check_clean_addr_bit - Check whether assigned FCID is clean.
491 * @vport: pointer to a host virtual N_Port data structure. 543 * @vport: pointer to a host virtual N_Port data structure.
492 * @sp: pointer to service parameter data structure. 544 * @sp: pointer to service parameter data structure.
@@ -615,7 +667,9 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
615 "1816 FLOGI NPIV supported, " 667 "1816 FLOGI NPIV supported, "
616 "response data 0x%x\n", 668 "response data 0x%x\n",
617 sp->cmn.response_multiple_NPort); 669 sp->cmn.response_multiple_NPort);
670 spin_lock_irq(&phba->hbalock);
618 phba->link_flag |= LS_NPIV_FAB_SUPPORTED; 671 phba->link_flag |= LS_NPIV_FAB_SUPPORTED;
672 spin_unlock_irq(&phba->hbalock);
619 } else { 673 } else {
620 /* Because we asked f/w for NPIV it still expects us 674 /* Because we asked f/w for NPIV it still expects us
621 to call reg_vnpid atleast for the physcial host */ 675 to call reg_vnpid atleast for the physcial host */
@@ -623,7 +677,9 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
623 LOG_ELS | LOG_VPORT, 677 LOG_ELS | LOG_VPORT,
624 "1817 Fabric does not support NPIV " 678 "1817 Fabric does not support NPIV "
625 "- configuring single port mode.\n"); 679 "- configuring single port mode.\n");
680 spin_lock_irq(&phba->hbalock);
626 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED; 681 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED;
682 spin_unlock_irq(&phba->hbalock);
627 } 683 }
628 } 684 }
629 685
@@ -686,11 +742,16 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
686 lpfc_do_scr_ns_plogi(phba, vport); 742 lpfc_do_scr_ns_plogi(phba, vport);
687 } else if (vport->fc_flag & FC_VFI_REGISTERED) 743 } else if (vport->fc_flag & FC_VFI_REGISTERED)
688 lpfc_issue_init_vpi(vport); 744 lpfc_issue_init_vpi(vport);
689 else 745 else {
746 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
747 "3135 Need register VFI: (x%x/%x)\n",
748 vport->fc_prevDID, vport->fc_myDID);
690 lpfc_issue_reg_vfi(vport); 749 lpfc_issue_reg_vfi(vport);
750 }
691 } 751 }
692 return 0; 752 return 0;
693} 753}
754
694/** 755/**
695 * lpfc_cmpl_els_flogi_nport - Completion function for flogi to an N_Port 756 * lpfc_cmpl_els_flogi_nport - Completion function for flogi to an N_Port
696 * @vport: pointer to a host virtual N_Port data structure. 757 * @vport: pointer to a host virtual N_Port data structure.
@@ -907,17 +968,16 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
907 * LPFC_MAX_DISC_THREADS (32). Scanning in the case of no 968 * LPFC_MAX_DISC_THREADS (32). Scanning in the case of no
908 * alpa map would take too long otherwise. 969 * alpa map would take too long otherwise.
909 */ 970 */
910 if (phba->alpa_map[0] == 0) { 971 if (phba->alpa_map[0] == 0)
911 vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS; 972 vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS;
912 if ((phba->sli_rev == LPFC_SLI_REV4) && 973 if ((phba->sli_rev == LPFC_SLI_REV4) &&
913 (!(vport->fc_flag & FC_VFI_REGISTERED) || 974 (!(vport->fc_flag & FC_VFI_REGISTERED) ||
914 (vport->fc_prevDID != vport->fc_myDID))) { 975 (vport->fc_prevDID != vport->fc_myDID))) {
915 if (vport->fc_flag & FC_VFI_REGISTERED) 976 if (vport->fc_flag & FC_VFI_REGISTERED)
916 lpfc_sli4_unreg_all_rpis(vport); 977 lpfc_sli4_unreg_all_rpis(vport);
917 lpfc_issue_reg_vfi(vport); 978 lpfc_issue_reg_vfi(vport);
918 lpfc_nlp_put(ndlp); 979 lpfc_nlp_put(ndlp);
919 goto out; 980 goto out;
920 }
921 } 981 }
922 goto flogifail; 982 goto flogifail;
923 } 983 }
@@ -1075,6 +1135,7 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1075 /* Setup CSPs accordingly for Fabric */ 1135 /* Setup CSPs accordingly for Fabric */
1076 sp->cmn.e_d_tov = 0; 1136 sp->cmn.e_d_tov = 0;
1077 sp->cmn.w2.r_a_tov = 0; 1137 sp->cmn.w2.r_a_tov = 0;
1138 sp->cmn.virtual_fabric_support = 0;
1078 sp->cls1.classValid = 0; 1139 sp->cls1.classValid = 0;
1079 sp->cls2.seqDelivery = 1; 1140 sp->cls2.seqDelivery = 1;
1080 sp->cls3.seqDelivery = 1; 1141 sp->cls3.seqDelivery = 1;
@@ -1163,8 +1224,7 @@ lpfc_els_abort_flogi(struct lpfc_hba *phba)
1163 spin_lock_irq(&phba->hbalock); 1224 spin_lock_irq(&phba->hbalock);
1164 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { 1225 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
1165 icmd = &iocb->iocb; 1226 icmd = &iocb->iocb;
1166 if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR && 1227 if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) {
1167 icmd->un.elsreq64.bdl.ulpIoTag32) {
1168 ndlp = (struct lpfc_nodelist *)(iocb->context1); 1228 ndlp = (struct lpfc_nodelist *)(iocb->context1);
1169 if (ndlp && NLP_CHK_NODE_ACT(ndlp) && 1229 if (ndlp && NLP_CHK_NODE_ACT(ndlp) &&
1170 (ndlp->nlp_DID == Fabric_DID)) 1230 (ndlp->nlp_DID == Fabric_DID))
@@ -3066,17 +3126,22 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
3066 if (did == FDMI_DID) 3126 if (did == FDMI_DID)
3067 retry = 1; 3127 retry = 1;
3068 3128
3069 if (((cmd == ELS_CMD_FLOGI) || (cmd == ELS_CMD_FDISC)) && 3129 if ((cmd == ELS_CMD_FLOGI) &&
3070 (phba->fc_topology != LPFC_TOPOLOGY_LOOP) && 3130 (phba->fc_topology != LPFC_TOPOLOGY_LOOP) &&
3071 !lpfc_error_lost_link(irsp)) { 3131 !lpfc_error_lost_link(irsp)) {
3072 /* FLOGI retry policy */ 3132 /* FLOGI retry policy */
3073 retry = 1; 3133 retry = 1;
3074 /* retry forever */ 3134 /* retry FLOGI forever */
3075 maxretry = 0; 3135 maxretry = 0;
3076 if (cmdiocb->retry >= 100) 3136 if (cmdiocb->retry >= 100)
3077 delay = 5000; 3137 delay = 5000;
3078 else if (cmdiocb->retry >= 32) 3138 else if (cmdiocb->retry >= 32)
3079 delay = 1000; 3139 delay = 1000;
3140 } else if ((cmd == ELS_CMD_FDISC) && !lpfc_error_lost_link(irsp)) {
3141 /* retry FDISCs every second up to devloss */
3142 retry = 1;
3143 maxretry = vport->cfg_devloss_tmo;
3144 delay = 1000;
3080 } 3145 }
3081 3146
3082 cmdiocb->retry++; 3147 cmdiocb->retry++;
@@ -3389,11 +3454,17 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
3389 3454
3390 /* 3455 /*
3391 * The driver received a LOGO from the rport and has ACK'd it. 3456 * The driver received a LOGO from the rport and has ACK'd it.
3392 * At this point, the driver is done so release the IOCB and 3457 * At this point, the driver is done so release the IOCB
3393 * remove the ndlp reference.
3394 */ 3458 */
3395 lpfc_els_free_iocb(phba, cmdiocb); 3459 lpfc_els_free_iocb(phba, cmdiocb);
3396 lpfc_nlp_put(ndlp); 3460
3461 /*
3462 * Remove the ndlp reference if it's a fabric node that has
3463 * sent us an unsolicted LOGO.
3464 */
3465 if (ndlp->nlp_type & NLP_FABRIC)
3466 lpfc_nlp_put(ndlp);
3467
3397 return; 3468 return;
3398} 3469}
3399 3470
@@ -4867,23 +4938,31 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
4867 sizeof(struct lpfc_name)); 4938 sizeof(struct lpfc_name));
4868 4939
4869 if (!rc) { 4940 if (!rc) {
4870 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 4941 if (phba->sli_rev < LPFC_SLI_REV4) {
4871 if (!mbox) 4942 mbox = mempool_alloc(phba->mbox_mem_pool,
4943 GFP_KERNEL);
4944 if (!mbox)
4945 return 1;
4946 lpfc_linkdown(phba);
4947 lpfc_init_link(phba, mbox,
4948 phba->cfg_topology,
4949 phba->cfg_link_speed);
4950 mbox->u.mb.un.varInitLnk.lipsr_AL_PA = 0;
4951 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
4952 mbox->vport = vport;
4953 rc = lpfc_sli_issue_mbox(phba, mbox,
4954 MBX_NOWAIT);
4955 lpfc_set_loopback_flag(phba);
4956 if (rc == MBX_NOT_FINISHED)
4957 mempool_free(mbox, phba->mbox_mem_pool);
4872 return 1; 4958 return 1;
4873 4959 } else {
4874 lpfc_linkdown(phba); 4960 /* abort the flogi coming back to ourselves
4875 lpfc_init_link(phba, mbox, 4961 * due to external loopback on the port.
4876 phba->cfg_topology, 4962 */
4877 phba->cfg_link_speed); 4963 lpfc_els_abort_flogi(phba);
4878 mbox->u.mb.un.varInitLnk.lipsr_AL_PA = 0; 4964 return 0;
4879 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
4880 mbox->vport = vport;
4881 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
4882 lpfc_set_loopback_flag(phba);
4883 if (rc == MBX_NOT_FINISHED) {
4884 mempool_free(mbox, phba->mbox_mem_pool);
4885 } 4965 }
4886 return 1;
4887 } else if (rc > 0) { /* greater than */ 4966 } else if (rc > 0) { /* greater than */
4888 spin_lock_irq(shost->host_lock); 4967 spin_lock_irq(shost->host_lock);
4889 vport->fc_flag |= FC_PT2PT_PLOGI; 4968 vport->fc_flag |= FC_PT2PT_PLOGI;
@@ -5838,8 +5917,12 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
5838 vport->fc_myDID = vport->fc_prevDID; 5917 vport->fc_myDID = vport->fc_prevDID;
5839 if (phba->sli_rev < LPFC_SLI_REV4) 5918 if (phba->sli_rev < LPFC_SLI_REV4)
5840 lpfc_issue_fabric_reglogin(vport); 5919 lpfc_issue_fabric_reglogin(vport);
5841 else 5920 else {
5921 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5922 "3138 Need register VFI: (x%x/%x)\n",
5923 vport->fc_prevDID, vport->fc_myDID);
5842 lpfc_issue_reg_vfi(vport); 5924 lpfc_issue_reg_vfi(vport);
5925 }
5843 } 5926 }
5844 } 5927 }
5845 return 0; 5928 return 0;
@@ -6596,56 +6679,6 @@ dropit:
6596} 6679}
6597 6680
6598/** 6681/**
6599 * lpfc_find_vport_by_vpid - Find a vport on a HBA through vport identifier
6600 * @phba: pointer to lpfc hba data structure.
6601 * @vpi: host virtual N_Port identifier.
6602 *
6603 * This routine finds a vport on a HBA (referred by @phba) through a
6604 * @vpi. The function walks the HBA's vport list and returns the address
6605 * of the vport with the matching @vpi.
6606 *
6607 * Return code
6608 * NULL - No vport with the matching @vpi found
6609 * Otherwise - Address to the vport with the matching @vpi.
6610 **/
6611struct lpfc_vport *
6612lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi)
6613{
6614 struct lpfc_vport *vport;
6615 unsigned long flags;
6616 int i = 0;
6617
6618 /* The physical ports are always vpi 0 - translate is unnecessary. */
6619 if (vpi > 0) {
6620 /*
6621 * Translate the physical vpi to the logical vpi. The
6622 * vport stores the logical vpi.
6623 */
6624 for (i = 0; i < phba->max_vpi; i++) {
6625 if (vpi == phba->vpi_ids[i])
6626 break;
6627 }
6628
6629 if (i >= phba->max_vpi) {
6630 lpfc_printf_log(phba, KERN_ERR, LOG_ELS,
6631 "2936 Could not find Vport mapped "
6632 "to vpi %d\n", vpi);
6633 return NULL;
6634 }
6635 }
6636
6637 spin_lock_irqsave(&phba->hbalock, flags);
6638 list_for_each_entry(vport, &phba->port_list, listentry) {
6639 if (vport->vpi == i) {
6640 spin_unlock_irqrestore(&phba->hbalock, flags);
6641 return vport;
6642 }
6643 }
6644 spin_unlock_irqrestore(&phba->hbalock, flags);
6645 return NULL;
6646}
6647
6648/**
6649 * lpfc_els_unsol_event - Process an unsolicited event from an els sli ring 6682 * lpfc_els_unsol_event - Process an unsolicited event from an els sli ring
6650 * @phba: pointer to lpfc hba data structure. 6683 * @phba: pointer to lpfc hba data structure.
6651 * @pring: pointer to a SLI ring. 6684 * @pring: pointer to a SLI ring.
@@ -7281,6 +7314,7 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
7281 /* Setup CSPs accordingly for Fabric */ 7314 /* Setup CSPs accordingly for Fabric */
7282 sp->cmn.e_d_tov = 0; 7315 sp->cmn.e_d_tov = 0;
7283 sp->cmn.w2.r_a_tov = 0; 7316 sp->cmn.w2.r_a_tov = 0;
7317 sp->cmn.virtual_fabric_support = 0;
7284 sp->cls1.classValid = 0; 7318 sp->cls1.classValid = 0;
7285 sp->cls2.seqDelivery = 1; 7319 sp->cls2.seqDelivery = 1;
7286 sp->cls3.seqDelivery = 1; 7320 sp->cls3.seqDelivery = 1;