diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_hbadisc.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_hbadisc.c | 1321 |
1 files changed, 977 insertions, 344 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index e6a47e25b218..e1466eec56b7 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -20,6 +20,7 @@ | |||
20 | *******************************************************************/ | 20 | *******************************************************************/ |
21 | 21 | ||
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/slab.h> | ||
23 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
24 | #include <linux/kthread.h> | 25 | #include <linux/kthread.h> |
25 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
@@ -525,8 +526,8 @@ lpfc_work_done(struct lpfc_hba *phba) | |||
525 | spin_unlock_irq(&phba->hbalock); | 526 | spin_unlock_irq(&phba->hbalock); |
526 | lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ); | 527 | lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ); |
527 | } | 528 | } |
528 | if (phba->hba_flag & HBA_RECEIVE_BUFFER) | 529 | if (phba->fcf.fcf_flag & FCF_REDISC_EVT) |
529 | lpfc_sli4_handle_received_buffer(phba); | 530 | lpfc_sli4_fcf_redisc_event_proc(phba); |
530 | } | 531 | } |
531 | 532 | ||
532 | vports = lpfc_create_vport_work_array(phba); | 533 | vports = lpfc_create_vport_work_array(phba); |
@@ -568,8 +569,9 @@ lpfc_work_done(struct lpfc_hba *phba) | |||
568 | pring = &phba->sli.ring[LPFC_ELS_RING]; | 569 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
569 | status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); | 570 | status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); |
570 | status >>= (4*LPFC_ELS_RING); | 571 | status >>= (4*LPFC_ELS_RING); |
571 | if ((status & HA_RXMASK) | 572 | if ((status & HA_RXMASK) || |
572 | || (pring->flag & LPFC_DEFERRED_RING_EVENT)) { | 573 | (pring->flag & LPFC_DEFERRED_RING_EVENT) || |
574 | (phba->hba_flag & HBA_SP_QUEUE_EVT)) { | ||
573 | if (pring->flag & LPFC_STOP_IOCB_EVENT) { | 575 | if (pring->flag & LPFC_STOP_IOCB_EVENT) { |
574 | pring->flag |= LPFC_DEFERRED_RING_EVENT; | 576 | pring->flag |= LPFC_DEFERRED_RING_EVENT; |
575 | /* Set the lpfc data pending flag */ | 577 | /* Set the lpfc data pending flag */ |
@@ -688,7 +690,8 @@ lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove) | |||
688 | lpfc_unreg_rpi(vport, ndlp); | 690 | lpfc_unreg_rpi(vport, ndlp); |
689 | 691 | ||
690 | /* Leave Fabric nodes alone on link down */ | 692 | /* Leave Fabric nodes alone on link down */ |
691 | if (!remove && ndlp->nlp_type & NLP_FABRIC) | 693 | if ((phba->sli_rev < LPFC_SLI_REV4) && |
694 | (!remove && ndlp->nlp_type & NLP_FABRIC)) | ||
692 | continue; | 695 | continue; |
693 | rc = lpfc_disc_state_machine(vport, ndlp, NULL, | 696 | rc = lpfc_disc_state_machine(vport, ndlp, NULL, |
694 | remove | 697 | remove |
@@ -706,6 +709,11 @@ lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove) | |||
706 | void | 709 | void |
707 | lpfc_port_link_failure(struct lpfc_vport *vport) | 710 | lpfc_port_link_failure(struct lpfc_vport *vport) |
708 | { | 711 | { |
712 | lpfc_vport_set_state(vport, FC_VPORT_LINKDOWN); | ||
713 | |||
714 | /* Cleanup any outstanding received buffers */ | ||
715 | lpfc_cleanup_rcv_buffers(vport); | ||
716 | |||
709 | /* Cleanup any outstanding RSCN activity */ | 717 | /* Cleanup any outstanding RSCN activity */ |
710 | lpfc_els_flush_rscn(vport); | 718 | lpfc_els_flush_rscn(vport); |
711 | 719 | ||
@@ -744,13 +752,19 @@ lpfc_linkdown(struct lpfc_hba *phba) | |||
744 | 752 | ||
745 | if (phba->link_state == LPFC_LINK_DOWN) | 753 | if (phba->link_state == LPFC_LINK_DOWN) |
746 | return 0; | 754 | return 0; |
755 | |||
756 | /* Block all SCSI stack I/Os */ | ||
757 | lpfc_scsi_dev_block(phba); | ||
758 | |||
747 | spin_lock_irq(&phba->hbalock); | 759 | spin_lock_irq(&phba->hbalock); |
748 | phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_DISCOVERED); | 760 | phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); |
761 | spin_unlock_irq(&phba->hbalock); | ||
749 | if (phba->link_state > LPFC_LINK_DOWN) { | 762 | if (phba->link_state > LPFC_LINK_DOWN) { |
750 | phba->link_state = LPFC_LINK_DOWN; | 763 | phba->link_state = LPFC_LINK_DOWN; |
764 | spin_lock_irq(shost->host_lock); | ||
751 | phba->pport->fc_flag &= ~FC_LBIT; | 765 | phba->pport->fc_flag &= ~FC_LBIT; |
766 | spin_unlock_irq(shost->host_lock); | ||
752 | } | 767 | } |
753 | spin_unlock_irq(&phba->hbalock); | ||
754 | vports = lpfc_create_vport_work_array(phba); | 768 | vports = lpfc_create_vport_work_array(phba); |
755 | if (vports != NULL) | 769 | if (vports != NULL) |
756 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { | 770 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
@@ -1015,13 +1029,12 @@ lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1015 | mempool_free(mboxq, phba->mbox_mem_pool); | 1029 | mempool_free(mboxq, phba->mbox_mem_pool); |
1016 | return; | 1030 | return; |
1017 | } | 1031 | } |
1018 | if (vport->port_state != LPFC_FLOGI) { | 1032 | spin_lock_irqsave(&phba->hbalock, flags); |
1019 | spin_lock_irqsave(&phba->hbalock, flags); | 1033 | phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE); |
1020 | phba->fcf.fcf_flag |= (FCF_DISCOVERED | FCF_IN_USE); | 1034 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; |
1021 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1035 | spin_unlock_irqrestore(&phba->hbalock, flags); |
1022 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1036 | if (vport->port_state != LPFC_FLOGI) |
1023 | lpfc_initial_flogi(vport); | 1037 | lpfc_initial_flogi(vport); |
1024 | } | ||
1025 | 1038 | ||
1026 | mempool_free(mboxq, phba->mbox_mem_pool); | 1039 | mempool_free(mboxq, phba->mbox_mem_pool); |
1027 | return; | 1040 | return; |
@@ -1039,25 +1052,23 @@ lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1039 | static uint32_t | 1052 | static uint32_t |
1040 | lpfc_fab_name_match(uint8_t *fab_name, struct fcf_record *new_fcf_record) | 1053 | lpfc_fab_name_match(uint8_t *fab_name, struct fcf_record *new_fcf_record) |
1041 | { | 1054 | { |
1042 | if ((fab_name[0] == | 1055 | if (fab_name[0] != bf_get(lpfc_fcf_record_fab_name_0, new_fcf_record)) |
1043 | bf_get(lpfc_fcf_record_fab_name_0, new_fcf_record)) && | 1056 | return 0; |
1044 | (fab_name[1] == | 1057 | if (fab_name[1] != bf_get(lpfc_fcf_record_fab_name_1, new_fcf_record)) |
1045 | bf_get(lpfc_fcf_record_fab_name_1, new_fcf_record)) && | 1058 | return 0; |
1046 | (fab_name[2] == | 1059 | if (fab_name[2] != bf_get(lpfc_fcf_record_fab_name_2, new_fcf_record)) |
1047 | bf_get(lpfc_fcf_record_fab_name_2, new_fcf_record)) && | 1060 | return 0; |
1048 | (fab_name[3] == | 1061 | if (fab_name[3] != bf_get(lpfc_fcf_record_fab_name_3, new_fcf_record)) |
1049 | bf_get(lpfc_fcf_record_fab_name_3, new_fcf_record)) && | 1062 | return 0; |
1050 | (fab_name[4] == | 1063 | if (fab_name[4] != bf_get(lpfc_fcf_record_fab_name_4, new_fcf_record)) |
1051 | bf_get(lpfc_fcf_record_fab_name_4, new_fcf_record)) && | 1064 | return 0; |
1052 | (fab_name[5] == | 1065 | if (fab_name[5] != bf_get(lpfc_fcf_record_fab_name_5, new_fcf_record)) |
1053 | bf_get(lpfc_fcf_record_fab_name_5, new_fcf_record)) && | 1066 | return 0; |
1054 | (fab_name[6] == | 1067 | if (fab_name[6] != bf_get(lpfc_fcf_record_fab_name_6, new_fcf_record)) |
1055 | bf_get(lpfc_fcf_record_fab_name_6, new_fcf_record)) && | 1068 | return 0; |
1056 | (fab_name[7] == | 1069 | if (fab_name[7] != bf_get(lpfc_fcf_record_fab_name_7, new_fcf_record)) |
1057 | bf_get(lpfc_fcf_record_fab_name_7, new_fcf_record))) | ||
1058 | return 1; | ||
1059 | else | ||
1060 | return 0; | 1070 | return 0; |
1071 | return 1; | ||
1061 | } | 1072 | } |
1062 | 1073 | ||
1063 | /** | 1074 | /** |
@@ -1072,30 +1083,28 @@ lpfc_fab_name_match(uint8_t *fab_name, struct fcf_record *new_fcf_record) | |||
1072 | static uint32_t | 1083 | static uint32_t |
1073 | lpfc_sw_name_match(uint8_t *sw_name, struct fcf_record *new_fcf_record) | 1084 | lpfc_sw_name_match(uint8_t *sw_name, struct fcf_record *new_fcf_record) |
1074 | { | 1085 | { |
1075 | if ((sw_name[0] == | 1086 | if (sw_name[0] != bf_get(lpfc_fcf_record_switch_name_0, new_fcf_record)) |
1076 | bf_get(lpfc_fcf_record_switch_name_0, new_fcf_record)) && | 1087 | return 0; |
1077 | (sw_name[1] == | 1088 | if (sw_name[1] != bf_get(lpfc_fcf_record_switch_name_1, new_fcf_record)) |
1078 | bf_get(lpfc_fcf_record_switch_name_1, new_fcf_record)) && | 1089 | return 0; |
1079 | (sw_name[2] == | 1090 | if (sw_name[2] != bf_get(lpfc_fcf_record_switch_name_2, new_fcf_record)) |
1080 | bf_get(lpfc_fcf_record_switch_name_2, new_fcf_record)) && | 1091 | return 0; |
1081 | (sw_name[3] == | 1092 | if (sw_name[3] != bf_get(lpfc_fcf_record_switch_name_3, new_fcf_record)) |
1082 | bf_get(lpfc_fcf_record_switch_name_3, new_fcf_record)) && | 1093 | return 0; |
1083 | (sw_name[4] == | 1094 | if (sw_name[4] != bf_get(lpfc_fcf_record_switch_name_4, new_fcf_record)) |
1084 | bf_get(lpfc_fcf_record_switch_name_4, new_fcf_record)) && | ||
1085 | (sw_name[5] == | ||
1086 | bf_get(lpfc_fcf_record_switch_name_5, new_fcf_record)) && | ||
1087 | (sw_name[6] == | ||
1088 | bf_get(lpfc_fcf_record_switch_name_6, new_fcf_record)) && | ||
1089 | (sw_name[7] == | ||
1090 | bf_get(lpfc_fcf_record_switch_name_7, new_fcf_record))) | ||
1091 | return 1; | ||
1092 | else | ||
1093 | return 0; | 1095 | return 0; |
1096 | if (sw_name[5] != bf_get(lpfc_fcf_record_switch_name_5, new_fcf_record)) | ||
1097 | return 0; | ||
1098 | if (sw_name[6] != bf_get(lpfc_fcf_record_switch_name_6, new_fcf_record)) | ||
1099 | return 0; | ||
1100 | if (sw_name[7] != bf_get(lpfc_fcf_record_switch_name_7, new_fcf_record)) | ||
1101 | return 0; | ||
1102 | return 1; | ||
1094 | } | 1103 | } |
1095 | 1104 | ||
1096 | /** | 1105 | /** |
1097 | * lpfc_mac_addr_match - Check if the fcf mac address match. | 1106 | * lpfc_mac_addr_match - Check if the fcf mac address match. |
1098 | * @phba: pointer to lpfc hba data structure. | 1107 | * @mac_addr: pointer to mac address. |
1099 | * @new_fcf_record: pointer to fcf record. | 1108 | * @new_fcf_record: pointer to fcf record. |
1100 | * | 1109 | * |
1101 | * This routine compare the fcf record's mac address with HBA's | 1110 | * This routine compare the fcf record's mac address with HBA's |
@@ -1103,85 +1112,115 @@ lpfc_sw_name_match(uint8_t *sw_name, struct fcf_record *new_fcf_record) | |||
1103 | * returns 1 else return 0. | 1112 | * returns 1 else return 0. |
1104 | **/ | 1113 | **/ |
1105 | static uint32_t | 1114 | static uint32_t |
1106 | lpfc_mac_addr_match(struct lpfc_hba *phba, struct fcf_record *new_fcf_record) | 1115 | lpfc_mac_addr_match(uint8_t *mac_addr, struct fcf_record *new_fcf_record) |
1107 | { | 1116 | { |
1108 | if ((phba->fcf.mac_addr[0] == | 1117 | if (mac_addr[0] != bf_get(lpfc_fcf_record_mac_0, new_fcf_record)) |
1109 | bf_get(lpfc_fcf_record_mac_0, new_fcf_record)) && | 1118 | return 0; |
1110 | (phba->fcf.mac_addr[1] == | 1119 | if (mac_addr[1] != bf_get(lpfc_fcf_record_mac_1, new_fcf_record)) |
1111 | bf_get(lpfc_fcf_record_mac_1, new_fcf_record)) && | ||
1112 | (phba->fcf.mac_addr[2] == | ||
1113 | bf_get(lpfc_fcf_record_mac_2, new_fcf_record)) && | ||
1114 | (phba->fcf.mac_addr[3] == | ||
1115 | bf_get(lpfc_fcf_record_mac_3, new_fcf_record)) && | ||
1116 | (phba->fcf.mac_addr[4] == | ||
1117 | bf_get(lpfc_fcf_record_mac_4, new_fcf_record)) && | ||
1118 | (phba->fcf.mac_addr[5] == | ||
1119 | bf_get(lpfc_fcf_record_mac_5, new_fcf_record))) | ||
1120 | return 1; | ||
1121 | else | ||
1122 | return 0; | 1120 | return 0; |
1121 | if (mac_addr[2] != bf_get(lpfc_fcf_record_mac_2, new_fcf_record)) | ||
1122 | return 0; | ||
1123 | if (mac_addr[3] != bf_get(lpfc_fcf_record_mac_3, new_fcf_record)) | ||
1124 | return 0; | ||
1125 | if (mac_addr[4] != bf_get(lpfc_fcf_record_mac_4, new_fcf_record)) | ||
1126 | return 0; | ||
1127 | if (mac_addr[5] != bf_get(lpfc_fcf_record_mac_5, new_fcf_record)) | ||
1128 | return 0; | ||
1129 | return 1; | ||
1130 | } | ||
1131 | |||
1132 | static bool | ||
1133 | lpfc_vlan_id_match(uint16_t curr_vlan_id, uint16_t new_vlan_id) | ||
1134 | { | ||
1135 | return (curr_vlan_id == new_vlan_id); | ||
1123 | } | 1136 | } |
1124 | 1137 | ||
1125 | /** | 1138 | /** |
1126 | * lpfc_copy_fcf_record - Copy fcf information to lpfc_hba. | 1139 | * lpfc_copy_fcf_record - Copy fcf information to lpfc_hba. |
1127 | * @phba: pointer to lpfc hba data structure. | 1140 | * @fcf: pointer to driver fcf record. |
1128 | * @new_fcf_record: pointer to fcf record. | 1141 | * @new_fcf_record: pointer to fcf record. |
1129 | * | 1142 | * |
1130 | * This routine copies the FCF information from the FCF | 1143 | * This routine copies the FCF information from the FCF |
1131 | * record to lpfc_hba data structure. | 1144 | * record to lpfc_hba data structure. |
1132 | **/ | 1145 | **/ |
1133 | static void | 1146 | static void |
1134 | lpfc_copy_fcf_record(struct lpfc_hba *phba, struct fcf_record *new_fcf_record) | 1147 | lpfc_copy_fcf_record(struct lpfc_fcf_rec *fcf_rec, |
1148 | struct fcf_record *new_fcf_record) | ||
1135 | { | 1149 | { |
1136 | phba->fcf.fabric_name[0] = | 1150 | /* Fabric name */ |
1151 | fcf_rec->fabric_name[0] = | ||
1137 | bf_get(lpfc_fcf_record_fab_name_0, new_fcf_record); | 1152 | bf_get(lpfc_fcf_record_fab_name_0, new_fcf_record); |
1138 | phba->fcf.fabric_name[1] = | 1153 | fcf_rec->fabric_name[1] = |
1139 | bf_get(lpfc_fcf_record_fab_name_1, new_fcf_record); | 1154 | bf_get(lpfc_fcf_record_fab_name_1, new_fcf_record); |
1140 | phba->fcf.fabric_name[2] = | 1155 | fcf_rec->fabric_name[2] = |
1141 | bf_get(lpfc_fcf_record_fab_name_2, new_fcf_record); | 1156 | bf_get(lpfc_fcf_record_fab_name_2, new_fcf_record); |
1142 | phba->fcf.fabric_name[3] = | 1157 | fcf_rec->fabric_name[3] = |
1143 | bf_get(lpfc_fcf_record_fab_name_3, new_fcf_record); | 1158 | bf_get(lpfc_fcf_record_fab_name_3, new_fcf_record); |
1144 | phba->fcf.fabric_name[4] = | 1159 | fcf_rec->fabric_name[4] = |
1145 | bf_get(lpfc_fcf_record_fab_name_4, new_fcf_record); | 1160 | bf_get(lpfc_fcf_record_fab_name_4, new_fcf_record); |
1146 | phba->fcf.fabric_name[5] = | 1161 | fcf_rec->fabric_name[5] = |
1147 | bf_get(lpfc_fcf_record_fab_name_5, new_fcf_record); | 1162 | bf_get(lpfc_fcf_record_fab_name_5, new_fcf_record); |
1148 | phba->fcf.fabric_name[6] = | 1163 | fcf_rec->fabric_name[6] = |
1149 | bf_get(lpfc_fcf_record_fab_name_6, new_fcf_record); | 1164 | bf_get(lpfc_fcf_record_fab_name_6, new_fcf_record); |
1150 | phba->fcf.fabric_name[7] = | 1165 | fcf_rec->fabric_name[7] = |
1151 | bf_get(lpfc_fcf_record_fab_name_7, new_fcf_record); | 1166 | bf_get(lpfc_fcf_record_fab_name_7, new_fcf_record); |
1152 | phba->fcf.mac_addr[0] = | 1167 | /* Mac address */ |
1153 | bf_get(lpfc_fcf_record_mac_0, new_fcf_record); | 1168 | fcf_rec->mac_addr[0] = bf_get(lpfc_fcf_record_mac_0, new_fcf_record); |
1154 | phba->fcf.mac_addr[1] = | 1169 | fcf_rec->mac_addr[1] = bf_get(lpfc_fcf_record_mac_1, new_fcf_record); |
1155 | bf_get(lpfc_fcf_record_mac_1, new_fcf_record); | 1170 | fcf_rec->mac_addr[2] = bf_get(lpfc_fcf_record_mac_2, new_fcf_record); |
1156 | phba->fcf.mac_addr[2] = | 1171 | fcf_rec->mac_addr[3] = bf_get(lpfc_fcf_record_mac_3, new_fcf_record); |
1157 | bf_get(lpfc_fcf_record_mac_2, new_fcf_record); | 1172 | fcf_rec->mac_addr[4] = bf_get(lpfc_fcf_record_mac_4, new_fcf_record); |
1158 | phba->fcf.mac_addr[3] = | 1173 | fcf_rec->mac_addr[5] = bf_get(lpfc_fcf_record_mac_5, new_fcf_record); |
1159 | bf_get(lpfc_fcf_record_mac_3, new_fcf_record); | 1174 | /* FCF record index */ |
1160 | phba->fcf.mac_addr[4] = | 1175 | fcf_rec->fcf_indx = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); |
1161 | bf_get(lpfc_fcf_record_mac_4, new_fcf_record); | 1176 | /* FCF record priority */ |
1162 | phba->fcf.mac_addr[5] = | 1177 | fcf_rec->priority = new_fcf_record->fip_priority; |
1163 | bf_get(lpfc_fcf_record_mac_5, new_fcf_record); | 1178 | /* Switch name */ |
1164 | phba->fcf.fcf_indx = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); | 1179 | fcf_rec->switch_name[0] = |
1165 | phba->fcf.priority = new_fcf_record->fip_priority; | ||
1166 | phba->fcf.switch_name[0] = | ||
1167 | bf_get(lpfc_fcf_record_switch_name_0, new_fcf_record); | 1180 | bf_get(lpfc_fcf_record_switch_name_0, new_fcf_record); |
1168 | phba->fcf.switch_name[1] = | 1181 | fcf_rec->switch_name[1] = |
1169 | bf_get(lpfc_fcf_record_switch_name_1, new_fcf_record); | 1182 | bf_get(lpfc_fcf_record_switch_name_1, new_fcf_record); |
1170 | phba->fcf.switch_name[2] = | 1183 | fcf_rec->switch_name[2] = |
1171 | bf_get(lpfc_fcf_record_switch_name_2, new_fcf_record); | 1184 | bf_get(lpfc_fcf_record_switch_name_2, new_fcf_record); |
1172 | phba->fcf.switch_name[3] = | 1185 | fcf_rec->switch_name[3] = |
1173 | bf_get(lpfc_fcf_record_switch_name_3, new_fcf_record); | 1186 | bf_get(lpfc_fcf_record_switch_name_3, new_fcf_record); |
1174 | phba->fcf.switch_name[4] = | 1187 | fcf_rec->switch_name[4] = |
1175 | bf_get(lpfc_fcf_record_switch_name_4, new_fcf_record); | 1188 | bf_get(lpfc_fcf_record_switch_name_4, new_fcf_record); |
1176 | phba->fcf.switch_name[5] = | 1189 | fcf_rec->switch_name[5] = |
1177 | bf_get(lpfc_fcf_record_switch_name_5, new_fcf_record); | 1190 | bf_get(lpfc_fcf_record_switch_name_5, new_fcf_record); |
1178 | phba->fcf.switch_name[6] = | 1191 | fcf_rec->switch_name[6] = |
1179 | bf_get(lpfc_fcf_record_switch_name_6, new_fcf_record); | 1192 | bf_get(lpfc_fcf_record_switch_name_6, new_fcf_record); |
1180 | phba->fcf.switch_name[7] = | 1193 | fcf_rec->switch_name[7] = |
1181 | bf_get(lpfc_fcf_record_switch_name_7, new_fcf_record); | 1194 | bf_get(lpfc_fcf_record_switch_name_7, new_fcf_record); |
1182 | } | 1195 | } |
1183 | 1196 | ||
1184 | /** | 1197 | /** |
1198 | * lpfc_update_fcf_record - Update driver fcf record | ||
1199 | * @phba: pointer to lpfc hba data structure. | ||
1200 | * @fcf_rec: pointer to driver fcf record. | ||
1201 | * @new_fcf_record: pointer to hba fcf record. | ||
1202 | * @addr_mode: address mode to be set to the driver fcf record. | ||
1203 | * @vlan_id: vlan tag to be set to the driver fcf record. | ||
1204 | * @flag: flag bits to be set to the driver fcf record. | ||
1205 | * | ||
1206 | * This routine updates the driver FCF record from the new HBA FCF record | ||
1207 | * together with the address mode, vlan_id, and other informations. This | ||
1208 | * routine is called with the host lock held. | ||
1209 | **/ | ||
1210 | static void | ||
1211 | __lpfc_update_fcf_record(struct lpfc_hba *phba, struct lpfc_fcf_rec *fcf_rec, | ||
1212 | struct fcf_record *new_fcf_record, uint32_t addr_mode, | ||
1213 | uint16_t vlan_id, uint32_t flag) | ||
1214 | { | ||
1215 | /* Copy the fields from the HBA's FCF record */ | ||
1216 | lpfc_copy_fcf_record(fcf_rec, new_fcf_record); | ||
1217 | /* Update other fields of driver FCF record */ | ||
1218 | fcf_rec->addr_mode = addr_mode; | ||
1219 | fcf_rec->vlan_id = vlan_id; | ||
1220 | fcf_rec->flag |= (flag | RECORD_VALID); | ||
1221 | } | ||
1222 | |||
1223 | /** | ||
1185 | * lpfc_register_fcf - Register the FCF with hba. | 1224 | * lpfc_register_fcf - Register the FCF with hba. |
1186 | * @phba: pointer to lpfc hba data structure. | 1225 | * @phba: pointer to lpfc hba data structure. |
1187 | * | 1226 | * |
@@ -1199,13 +1238,14 @@ lpfc_register_fcf(struct lpfc_hba *phba) | |||
1199 | 1238 | ||
1200 | /* If the FCF is not availabe do nothing. */ | 1239 | /* If the FCF is not availabe do nothing. */ |
1201 | if (!(phba->fcf.fcf_flag & FCF_AVAILABLE)) { | 1240 | if (!(phba->fcf.fcf_flag & FCF_AVAILABLE)) { |
1241 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | ||
1202 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1242 | spin_unlock_irqrestore(&phba->hbalock, flags); |
1203 | return; | 1243 | return; |
1204 | } | 1244 | } |
1205 | 1245 | ||
1206 | /* The FCF is already registered, start discovery */ | 1246 | /* The FCF is already registered, start discovery */ |
1207 | if (phba->fcf.fcf_flag & FCF_REGISTERED) { | 1247 | if (phba->fcf.fcf_flag & FCF_REGISTERED) { |
1208 | phba->fcf.fcf_flag |= (FCF_DISCOVERED | FCF_IN_USE); | 1248 | phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE); |
1209 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1249 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; |
1210 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1250 | spin_unlock_irqrestore(&phba->hbalock, flags); |
1211 | if (phba->pport->port_state != LPFC_FLOGI) | 1251 | if (phba->pport->port_state != LPFC_FLOGI) |
@@ -1216,15 +1256,23 @@ lpfc_register_fcf(struct lpfc_hba *phba) | |||
1216 | 1256 | ||
1217 | fcf_mbxq = mempool_alloc(phba->mbox_mem_pool, | 1257 | fcf_mbxq = mempool_alloc(phba->mbox_mem_pool, |
1218 | GFP_KERNEL); | 1258 | GFP_KERNEL); |
1219 | if (!fcf_mbxq) | 1259 | if (!fcf_mbxq) { |
1260 | spin_lock_irqsave(&phba->hbalock, flags); | ||
1261 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | ||
1262 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
1220 | return; | 1263 | return; |
1264 | } | ||
1221 | 1265 | ||
1222 | lpfc_reg_fcfi(phba, fcf_mbxq); | 1266 | lpfc_reg_fcfi(phba, fcf_mbxq); |
1223 | fcf_mbxq->vport = phba->pport; | 1267 | fcf_mbxq->vport = phba->pport; |
1224 | fcf_mbxq->mbox_cmpl = lpfc_mbx_cmpl_reg_fcfi; | 1268 | fcf_mbxq->mbox_cmpl = lpfc_mbx_cmpl_reg_fcfi; |
1225 | rc = lpfc_sli_issue_mbox(phba, fcf_mbxq, MBX_NOWAIT); | 1269 | rc = lpfc_sli_issue_mbox(phba, fcf_mbxq, MBX_NOWAIT); |
1226 | if (rc == MBX_NOT_FINISHED) | 1270 | if (rc == MBX_NOT_FINISHED) { |
1271 | spin_lock_irqsave(&phba->hbalock, flags); | ||
1272 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | ||
1273 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
1227 | mempool_free(fcf_mbxq, phba->mbox_mem_pool); | 1274 | mempool_free(fcf_mbxq, phba->mbox_mem_pool); |
1275 | } | ||
1228 | 1276 | ||
1229 | return; | 1277 | return; |
1230 | } | 1278 | } |
@@ -1235,6 +1283,7 @@ lpfc_register_fcf(struct lpfc_hba *phba) | |||
1235 | * @new_fcf_record: pointer to fcf record. | 1283 | * @new_fcf_record: pointer to fcf record. |
1236 | * @boot_flag: Indicates if this record used by boot bios. | 1284 | * @boot_flag: Indicates if this record used by boot bios. |
1237 | * @addr_mode: The address mode to be used by this FCF | 1285 | * @addr_mode: The address mode to be used by this FCF |
1286 | * @vlan_id: The vlan id to be used as vlan tagging by this FCF. | ||
1238 | * | 1287 | * |
1239 | * This routine compare the fcf record with connect list obtained from the | 1288 | * This routine compare the fcf record with connect list obtained from the |
1240 | * config region to decide if this FCF can be used for SAN discovery. It returns | 1289 | * config region to decide if this FCF can be used for SAN discovery. It returns |
@@ -1253,13 +1302,27 @@ lpfc_match_fcf_conn_list(struct lpfc_hba *phba, | |||
1253 | uint16_t *vlan_id) | 1302 | uint16_t *vlan_id) |
1254 | { | 1303 | { |
1255 | struct lpfc_fcf_conn_entry *conn_entry; | 1304 | struct lpfc_fcf_conn_entry *conn_entry; |
1305 | int i, j, fcf_vlan_id = 0; | ||
1306 | |||
1307 | /* Find the lowest VLAN id in the FCF record */ | ||
1308 | for (i = 0; i < 512; i++) { | ||
1309 | if (new_fcf_record->vlan_bitmap[i]) { | ||
1310 | fcf_vlan_id = i * 8; | ||
1311 | j = 0; | ||
1312 | while (!((new_fcf_record->vlan_bitmap[i] >> j) & 1)) { | ||
1313 | j++; | ||
1314 | fcf_vlan_id++; | ||
1315 | } | ||
1316 | break; | ||
1317 | } | ||
1318 | } | ||
1256 | 1319 | ||
1257 | /* If FCF not available return 0 */ | 1320 | /* If FCF not available return 0 */ |
1258 | if (!bf_get(lpfc_fcf_record_fcf_avail, new_fcf_record) || | 1321 | if (!bf_get(lpfc_fcf_record_fcf_avail, new_fcf_record) || |
1259 | !bf_get(lpfc_fcf_record_fcf_valid, new_fcf_record)) | 1322 | !bf_get(lpfc_fcf_record_fcf_valid, new_fcf_record)) |
1260 | return 0; | 1323 | return 0; |
1261 | 1324 | ||
1262 | if (!phba->cfg_enable_fip) { | 1325 | if (!(phba->hba_flag & HBA_FIP_SUPPORT)) { |
1263 | *boot_flag = 0; | 1326 | *boot_flag = 0; |
1264 | *addr_mode = bf_get(lpfc_fcf_record_mac_addr_prov, | 1327 | *addr_mode = bf_get(lpfc_fcf_record_mac_addr_prov, |
1265 | new_fcf_record); | 1328 | new_fcf_record); |
@@ -1286,11 +1349,16 @@ lpfc_match_fcf_conn_list(struct lpfc_hba *phba, | |||
1286 | if (*addr_mode & LPFC_FCF_FPMA) | 1349 | if (*addr_mode & LPFC_FCF_FPMA) |
1287 | *addr_mode = LPFC_FCF_FPMA; | 1350 | *addr_mode = LPFC_FCF_FPMA; |
1288 | 1351 | ||
1289 | *vlan_id = 0xFFFF; | 1352 | /* If FCF record report a vlan id use that vlan id */ |
1353 | if (fcf_vlan_id) | ||
1354 | *vlan_id = fcf_vlan_id; | ||
1355 | else | ||
1356 | *vlan_id = 0xFFFF; | ||
1290 | return 1; | 1357 | return 1; |
1291 | } | 1358 | } |
1292 | 1359 | ||
1293 | list_for_each_entry(conn_entry, &phba->fcf_conn_rec_list, list) { | 1360 | list_for_each_entry(conn_entry, |
1361 | &phba->fcf_conn_rec_list, list) { | ||
1294 | if (!(conn_entry->conn_rec.flags & FCFCNCT_VALID)) | 1362 | if (!(conn_entry->conn_rec.flags & FCFCNCT_VALID)) |
1295 | continue; | 1363 | continue; |
1296 | 1364 | ||
@@ -1384,8 +1452,15 @@ lpfc_match_fcf_conn_list(struct lpfc_hba *phba, | |||
1384 | (*addr_mode & LPFC_FCF_FPMA)) | 1452 | (*addr_mode & LPFC_FCF_FPMA)) |
1385 | *addr_mode = LPFC_FCF_FPMA; | 1453 | *addr_mode = LPFC_FCF_FPMA; |
1386 | 1454 | ||
1455 | /* If matching connect list has a vlan id, use it */ | ||
1387 | if (conn_entry->conn_rec.flags & FCFCNCT_VLAN_VALID) | 1456 | if (conn_entry->conn_rec.flags & FCFCNCT_VLAN_VALID) |
1388 | *vlan_id = conn_entry->conn_rec.vlan_tag; | 1457 | *vlan_id = conn_entry->conn_rec.vlan_tag; |
1458 | /* | ||
1459 | * If no vlan id is specified in connect list, use the vlan id | ||
1460 | * in the FCF record | ||
1461 | */ | ||
1462 | else if (fcf_vlan_id) | ||
1463 | *vlan_id = fcf_vlan_id; | ||
1389 | else | 1464 | else |
1390 | *vlan_id = 0xFFFF; | 1465 | *vlan_id = 0xFFFF; |
1391 | 1466 | ||
@@ -1407,8 +1482,6 @@ lpfc_match_fcf_conn_list(struct lpfc_hba *phba, | |||
1407 | int | 1482 | int |
1408 | lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) | 1483 | lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) |
1409 | { | 1484 | { |
1410 | LPFC_MBOXQ_t *mbox; | ||
1411 | int rc; | ||
1412 | /* | 1485 | /* |
1413 | * If the Link is up and no FCoE events while in the | 1486 | * If the Link is up and no FCoE events while in the |
1414 | * FCF discovery, no need to restart FCF discovery. | 1487 | * FCF discovery, no need to restart FCF discovery. |
@@ -1417,75 +1490,70 @@ lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) | |||
1417 | (phba->fcoe_eventtag == phba->fcoe_eventtag_at_fcf_scan)) | 1490 | (phba->fcoe_eventtag == phba->fcoe_eventtag_at_fcf_scan)) |
1418 | return 0; | 1491 | return 0; |
1419 | 1492 | ||
1493 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1494 | "2768 Pending link or FCF event during current " | ||
1495 | "handling of the previous event: link_state:x%x, " | ||
1496 | "evt_tag_at_scan:x%x, evt_tag_current:x%x\n", | ||
1497 | phba->link_state, phba->fcoe_eventtag_at_fcf_scan, | ||
1498 | phba->fcoe_eventtag); | ||
1499 | |||
1420 | spin_lock_irq(&phba->hbalock); | 1500 | spin_lock_irq(&phba->hbalock); |
1421 | phba->fcf.fcf_flag &= ~FCF_AVAILABLE; | 1501 | phba->fcf.fcf_flag &= ~FCF_AVAILABLE; |
1422 | spin_unlock_irq(&phba->hbalock); | 1502 | spin_unlock_irq(&phba->hbalock); |
1423 | 1503 | ||
1424 | if (phba->link_state >= LPFC_LINK_UP) | 1504 | if (phba->link_state >= LPFC_LINK_UP) { |
1425 | lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 1505 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, |
1506 | "2780 Restart FCF table scan due to " | ||
1507 | "pending FCF event:evt_tag_at_scan:x%x, " | ||
1508 | "evt_tag_current:x%x\n", | ||
1509 | phba->fcoe_eventtag_at_fcf_scan, | ||
1510 | phba->fcoe_eventtag); | ||
1511 | lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); | ||
1512 | } else { | ||
1513 | /* | ||
1514 | * Do not continue FCF discovery and clear FCF_DISC_INPROGRESS | ||
1515 | * flag | ||
1516 | */ | ||
1517 | spin_lock_irq(&phba->hbalock); | ||
1518 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | ||
1519 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | FCF_DISCOVERY); | ||
1520 | spin_unlock_irq(&phba->hbalock); | ||
1521 | } | ||
1426 | 1522 | ||
1523 | /* Unregister the currently registered FCF if required */ | ||
1427 | if (unreg_fcf) { | 1524 | if (unreg_fcf) { |
1428 | spin_lock_irq(&phba->hbalock); | 1525 | spin_lock_irq(&phba->hbalock); |
1429 | phba->fcf.fcf_flag &= ~FCF_REGISTERED; | 1526 | phba->fcf.fcf_flag &= ~FCF_REGISTERED; |
1430 | spin_unlock_irq(&phba->hbalock); | 1527 | spin_unlock_irq(&phba->hbalock); |
1431 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 1528 | lpfc_sli4_unregister_fcf(phba); |
1432 | if (!mbox) { | ||
1433 | lpfc_printf_log(phba, KERN_ERR, | ||
1434 | LOG_DISCOVERY|LOG_MBOX, | ||
1435 | "2610 UNREG_FCFI mbox allocation failed\n"); | ||
1436 | return 1; | ||
1437 | } | ||
1438 | lpfc_unreg_fcfi(mbox, phba->fcf.fcfi); | ||
1439 | mbox->vport = phba->pport; | ||
1440 | mbox->mbox_cmpl = lpfc_unregister_fcfi_cmpl; | ||
1441 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); | ||
1442 | if (rc == MBX_NOT_FINISHED) { | ||
1443 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | ||
1444 | "2611 UNREG_FCFI issue mbox failed\n"); | ||
1445 | mempool_free(mbox, phba->mbox_mem_pool); | ||
1446 | } | ||
1447 | } | 1529 | } |
1448 | |||
1449 | return 1; | 1530 | return 1; |
1450 | } | 1531 | } |
1451 | 1532 | ||
1452 | /** | 1533 | /** |
1453 | * lpfc_mbx_cmpl_read_fcf_record - Completion handler for read_fcf mbox. | 1534 | * lpfc_sli4_fcf_rec_mbox_parse - parse non-embedded fcf record mailbox command |
1454 | * @phba: pointer to lpfc hba data structure. | 1535 | * @phba: pointer to lpfc hba data structure. |
1455 | * @mboxq: pointer to mailbox object. | 1536 | * @mboxq: pointer to mailbox object. |
1537 | * @next_fcf_index: pointer to holder of next fcf index. | ||
1456 | * | 1538 | * |
1457 | * This function iterate through all the fcf records available in | 1539 | * This routine parses the non-embedded fcf mailbox command by performing the |
1458 | * HBA and choose the optimal FCF record for discovery. After finding | 1540 | * necessarily error checking, non-embedded read FCF record mailbox command |
1459 | * the FCF for discovery it register the FCF record and kick start | 1541 | * SGE parsing, and endianness swapping. |
1460 | * discovery. | 1542 | * |
1461 | * If FCF_IN_USE flag is set in currently used FCF, the routine try to | 1543 | * Returns the pointer to the new FCF record in the non-embedded mailbox |
1462 | * use a FCF record which match fabric name and mac address of the | 1544 | * command DMA memory if successfully, other NULL. |
1463 | * currently used FCF record. | ||
1464 | * If the driver support only one FCF, it will try to use the FCF record | ||
1465 | * used by BOOT_BIOS. | ||
1466 | */ | 1545 | */ |
1467 | void | 1546 | static struct fcf_record * |
1468 | lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | 1547 | lpfc_sli4_fcf_rec_mbox_parse(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq, |
1548 | uint16_t *next_fcf_index) | ||
1469 | { | 1549 | { |
1470 | void *virt_addr; | 1550 | void *virt_addr; |
1471 | dma_addr_t phys_addr; | 1551 | dma_addr_t phys_addr; |
1472 | uint8_t *bytep; | ||
1473 | struct lpfc_mbx_sge sge; | 1552 | struct lpfc_mbx_sge sge; |
1474 | struct lpfc_mbx_read_fcf_tbl *read_fcf; | 1553 | struct lpfc_mbx_read_fcf_tbl *read_fcf; |
1475 | uint32_t shdr_status, shdr_add_status; | 1554 | uint32_t shdr_status, shdr_add_status; |
1476 | union lpfc_sli4_cfg_shdr *shdr; | 1555 | union lpfc_sli4_cfg_shdr *shdr; |
1477 | struct fcf_record *new_fcf_record; | 1556 | struct fcf_record *new_fcf_record; |
1478 | int rc; | ||
1479 | uint32_t boot_flag, addr_mode; | ||
1480 | uint32_t next_fcf_index; | ||
1481 | unsigned long flags; | ||
1482 | uint16_t vlan_id; | ||
1483 | |||
1484 | /* If there is pending FCoE event restart FCF table scan */ | ||
1485 | if (lpfc_check_pending_fcoe_event(phba, 0)) { | ||
1486 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1487 | return; | ||
1488 | } | ||
1489 | 1557 | ||
1490 | /* Get the first SGE entry from the non-embedded DMA memory. This | 1558 | /* Get the first SGE entry from the non-embedded DMA memory. This |
1491 | * routine only uses a single SGE. | 1559 | * routine only uses a single SGE. |
@@ -1496,134 +1564,359 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1496 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, | 1564 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
1497 | "2524 Failed to get the non-embedded SGE " | 1565 | "2524 Failed to get the non-embedded SGE " |
1498 | "virtual address\n"); | 1566 | "virtual address\n"); |
1499 | goto out; | 1567 | return NULL; |
1500 | } | 1568 | } |
1501 | virt_addr = mboxq->sge_array->addr[0]; | 1569 | virt_addr = mboxq->sge_array->addr[0]; |
1502 | 1570 | ||
1503 | shdr = (union lpfc_sli4_cfg_shdr *)virt_addr; | 1571 | shdr = (union lpfc_sli4_cfg_shdr *)virt_addr; |
1504 | shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); | 1572 | shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); |
1505 | shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, | 1573 | shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); |
1506 | &shdr->response); | ||
1507 | /* | ||
1508 | * The FCF Record was read and there is no reason for the driver | ||
1509 | * to maintain the FCF record data or memory. Instead, just need | ||
1510 | * to book keeping the FCFIs can be used. | ||
1511 | */ | ||
1512 | if (shdr_status || shdr_add_status) { | 1574 | if (shdr_status || shdr_add_status) { |
1513 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 1575 | if (shdr_status == STATUS_FCF_TABLE_EMPTY) |
1514 | "2521 READ_FCF_RECORD mailbox failed " | 1576 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, |
1515 | "with status x%x add_status x%x, mbx\n", | 1577 | "2726 READ_FCF_RECORD Indicates empty " |
1516 | shdr_status, shdr_add_status); | 1578 | "FCF table.\n"); |
1517 | goto out; | 1579 | else |
1580 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, | ||
1581 | "2521 READ_FCF_RECORD mailbox failed " | ||
1582 | "with status x%x add_status x%x, " | ||
1583 | "mbx\n", shdr_status, shdr_add_status); | ||
1584 | return NULL; | ||
1518 | } | 1585 | } |
1519 | /* Interpreting the returned information of FCF records */ | 1586 | |
1587 | /* Interpreting the returned information of the FCF record */ | ||
1520 | read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr; | 1588 | read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr; |
1521 | lpfc_sli_pcimem_bcopy(read_fcf, read_fcf, | 1589 | lpfc_sli_pcimem_bcopy(read_fcf, read_fcf, |
1522 | sizeof(struct lpfc_mbx_read_fcf_tbl)); | 1590 | sizeof(struct lpfc_mbx_read_fcf_tbl)); |
1523 | next_fcf_index = bf_get(lpfc_mbx_read_fcf_tbl_nxt_vindx, read_fcf); | 1591 | *next_fcf_index = bf_get(lpfc_mbx_read_fcf_tbl_nxt_vindx, read_fcf); |
1524 | |||
1525 | new_fcf_record = (struct fcf_record *)(virt_addr + | 1592 | new_fcf_record = (struct fcf_record *)(virt_addr + |
1526 | sizeof(struct lpfc_mbx_read_fcf_tbl)); | 1593 | sizeof(struct lpfc_mbx_read_fcf_tbl)); |
1527 | lpfc_sli_pcimem_bcopy(new_fcf_record, new_fcf_record, | 1594 | lpfc_sli_pcimem_bcopy(new_fcf_record, new_fcf_record, |
1528 | sizeof(struct fcf_record)); | 1595 | sizeof(struct fcf_record)); |
1529 | bytep = virt_addr + sizeof(union lpfc_sli4_cfg_shdr); | ||
1530 | 1596 | ||
1531 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, | 1597 | return new_fcf_record; |
1532 | &boot_flag, &addr_mode, | 1598 | } |
1533 | &vlan_id); | 1599 | |
1600 | /** | ||
1601 | * lpfc_sli4_log_fcf_record_info - Log the information of a fcf record | ||
1602 | * @phba: pointer to lpfc hba data structure. | ||
1603 | * @fcf_record: pointer to the fcf record. | ||
1604 | * @vlan_id: the lowest vlan identifier associated to this fcf record. | ||
1605 | * @next_fcf_index: the index to the next fcf record in hba's fcf table. | ||
1606 | * | ||
1607 | * This routine logs the detailed FCF record if the LOG_FIP loggin is | ||
1608 | * enabled. | ||
1609 | **/ | ||
1610 | static void | ||
1611 | lpfc_sli4_log_fcf_record_info(struct lpfc_hba *phba, | ||
1612 | struct fcf_record *fcf_record, | ||
1613 | uint16_t vlan_id, | ||
1614 | uint16_t next_fcf_index) | ||
1615 | { | ||
1616 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1617 | "2764 READ_FCF_RECORD:\n" | ||
1618 | "\tFCF_Index : x%x\n" | ||
1619 | "\tFCF_Avail : x%x\n" | ||
1620 | "\tFCF_Valid : x%x\n" | ||
1621 | "\tFIP_Priority : x%x\n" | ||
1622 | "\tMAC_Provider : x%x\n" | ||
1623 | "\tLowest VLANID : x%x\n" | ||
1624 | "\tFCF_MAC Addr : x%x:%x:%x:%x:%x:%x\n" | ||
1625 | "\tFabric_Name : x%x:%x:%x:%x:%x:%x:%x:%x\n" | ||
1626 | "\tSwitch_Name : x%x:%x:%x:%x:%x:%x:%x:%x\n" | ||
1627 | "\tNext_FCF_Index: x%x\n", | ||
1628 | bf_get(lpfc_fcf_record_fcf_index, fcf_record), | ||
1629 | bf_get(lpfc_fcf_record_fcf_avail, fcf_record), | ||
1630 | bf_get(lpfc_fcf_record_fcf_valid, fcf_record), | ||
1631 | fcf_record->fip_priority, | ||
1632 | bf_get(lpfc_fcf_record_mac_addr_prov, fcf_record), | ||
1633 | vlan_id, | ||
1634 | bf_get(lpfc_fcf_record_mac_0, fcf_record), | ||
1635 | bf_get(lpfc_fcf_record_mac_1, fcf_record), | ||
1636 | bf_get(lpfc_fcf_record_mac_2, fcf_record), | ||
1637 | bf_get(lpfc_fcf_record_mac_3, fcf_record), | ||
1638 | bf_get(lpfc_fcf_record_mac_4, fcf_record), | ||
1639 | bf_get(lpfc_fcf_record_mac_5, fcf_record), | ||
1640 | bf_get(lpfc_fcf_record_fab_name_0, fcf_record), | ||
1641 | bf_get(lpfc_fcf_record_fab_name_1, fcf_record), | ||
1642 | bf_get(lpfc_fcf_record_fab_name_2, fcf_record), | ||
1643 | bf_get(lpfc_fcf_record_fab_name_3, fcf_record), | ||
1644 | bf_get(lpfc_fcf_record_fab_name_4, fcf_record), | ||
1645 | bf_get(lpfc_fcf_record_fab_name_5, fcf_record), | ||
1646 | bf_get(lpfc_fcf_record_fab_name_6, fcf_record), | ||
1647 | bf_get(lpfc_fcf_record_fab_name_7, fcf_record), | ||
1648 | bf_get(lpfc_fcf_record_switch_name_0, fcf_record), | ||
1649 | bf_get(lpfc_fcf_record_switch_name_1, fcf_record), | ||
1650 | bf_get(lpfc_fcf_record_switch_name_2, fcf_record), | ||
1651 | bf_get(lpfc_fcf_record_switch_name_3, fcf_record), | ||
1652 | bf_get(lpfc_fcf_record_switch_name_4, fcf_record), | ||
1653 | bf_get(lpfc_fcf_record_switch_name_5, fcf_record), | ||
1654 | bf_get(lpfc_fcf_record_switch_name_6, fcf_record), | ||
1655 | bf_get(lpfc_fcf_record_switch_name_7, fcf_record), | ||
1656 | next_fcf_index); | ||
1657 | } | ||
1658 | |||
1659 | /** | ||
1660 | * lpfc_mbx_cmpl_fcf_scan_read_fcf_rec - fcf scan read_fcf mbox cmpl handler. | ||
1661 | * @phba: pointer to lpfc hba data structure. | ||
1662 | * @mboxq: pointer to mailbox object. | ||
1663 | * | ||
1664 | * This function iterates through all the fcf records available in | ||
1665 | * HBA and chooses the optimal FCF record for discovery. After finding | ||
1666 | * the FCF for discovery it registers the FCF record and kicks start | ||
1667 | * discovery. | ||
1668 | * If FCF_IN_USE flag is set in currently used FCF, the routine tries to | ||
1669 | * use an FCF record which matches fabric name and mac address of the | ||
1670 | * currently used FCF record. | ||
1671 | * If the driver supports only one FCF, it will try to use the FCF record | ||
1672 | * used by BOOT_BIOS. | ||
1673 | */ | ||
1674 | void | ||
1675 | lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | ||
1676 | { | ||
1677 | struct fcf_record *new_fcf_record; | ||
1678 | uint32_t boot_flag, addr_mode; | ||
1679 | uint16_t fcf_index, next_fcf_index; | ||
1680 | struct lpfc_fcf_rec *fcf_rec = NULL; | ||
1681 | uint16_t vlan_id; | ||
1682 | int rc; | ||
1683 | |||
1684 | /* If there is pending FCoE event restart FCF table scan */ | ||
1685 | if (lpfc_check_pending_fcoe_event(phba, 0)) { | ||
1686 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1687 | return; | ||
1688 | } | ||
1689 | |||
1690 | /* Parse the FCF record from the non-embedded mailbox command */ | ||
1691 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | ||
1692 | &next_fcf_index); | ||
1693 | if (!new_fcf_record) { | ||
1694 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1695 | "2765 Mailbox command READ_FCF_RECORD " | ||
1696 | "failed to retrieve a FCF record.\n"); | ||
1697 | /* Let next new FCF event trigger fast failover */ | ||
1698 | spin_lock_irq(&phba->hbalock); | ||
1699 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | ||
1700 | spin_unlock_irq(&phba->hbalock); | ||
1701 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1702 | return; | ||
1703 | } | ||
1704 | |||
1705 | /* Check the FCF record against the connection list */ | ||
1706 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | ||
1707 | &addr_mode, &vlan_id); | ||
1708 | |||
1709 | /* Log the FCF record information if turned on */ | ||
1710 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | ||
1711 | next_fcf_index); | ||
1712 | |||
1534 | /* | 1713 | /* |
1535 | * If the fcf record does not match with connect list entries | 1714 | * If the fcf record does not match with connect list entries |
1536 | * read the next entry. | 1715 | * read the next entry; otherwise, this is an eligible FCF |
1716 | * record for round robin FCF failover. | ||
1537 | */ | 1717 | */ |
1538 | if (!rc) | 1718 | if (!rc) { |
1719 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1720 | "2781 FCF record fcf_index:x%x failed FCF " | ||
1721 | "connection list check, fcf_avail:x%x, " | ||
1722 | "fcf_valid:x%x\n", | ||
1723 | bf_get(lpfc_fcf_record_fcf_index, | ||
1724 | new_fcf_record), | ||
1725 | bf_get(lpfc_fcf_record_fcf_avail, | ||
1726 | new_fcf_record), | ||
1727 | bf_get(lpfc_fcf_record_fcf_valid, | ||
1728 | new_fcf_record)); | ||
1539 | goto read_next_fcf; | 1729 | goto read_next_fcf; |
1730 | } else { | ||
1731 | fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); | ||
1732 | rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); | ||
1733 | if (rc) | ||
1734 | goto read_next_fcf; | ||
1735 | } | ||
1736 | |||
1540 | /* | 1737 | /* |
1541 | * If this is not the first FCF discovery of the HBA, use last | 1738 | * If this is not the first FCF discovery of the HBA, use last |
1542 | * FCF record for the discovery. | 1739 | * FCF record for the discovery. The condition that a rescan |
1740 | * matches the in-use FCF record: fabric name, switch name, mac | ||
1741 | * address, and vlan_id. | ||
1543 | */ | 1742 | */ |
1544 | spin_lock_irqsave(&phba->hbalock, flags); | 1743 | spin_lock_irq(&phba->hbalock); |
1545 | if (phba->fcf.fcf_flag & FCF_IN_USE) { | 1744 | if (phba->fcf.fcf_flag & FCF_IN_USE) { |
1546 | if (lpfc_fab_name_match(phba->fcf.fabric_name, | 1745 | if (lpfc_fab_name_match(phba->fcf.current_rec.fabric_name, |
1746 | new_fcf_record) && | ||
1747 | lpfc_sw_name_match(phba->fcf.current_rec.switch_name, | ||
1547 | new_fcf_record) && | 1748 | new_fcf_record) && |
1548 | lpfc_sw_name_match(phba->fcf.switch_name, | 1749 | lpfc_mac_addr_match(phba->fcf.current_rec.mac_addr, |
1549 | new_fcf_record) && | 1750 | new_fcf_record) && |
1550 | lpfc_mac_addr_match(phba, new_fcf_record)) { | 1751 | lpfc_vlan_id_match(phba->fcf.current_rec.vlan_id, |
1752 | vlan_id)) { | ||
1551 | phba->fcf.fcf_flag |= FCF_AVAILABLE; | 1753 | phba->fcf.fcf_flag |= FCF_AVAILABLE; |
1552 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1754 | if (phba->fcf.fcf_flag & FCF_REDISC_PEND) |
1755 | /* Stop FCF redisc wait timer if pending */ | ||
1756 | __lpfc_sli4_stop_fcf_redisc_wait_timer(phba); | ||
1757 | else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) | ||
1758 | /* If in fast failover, mark it's completed */ | ||
1759 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | | ||
1760 | FCF_DISCOVERY); | ||
1761 | spin_unlock_irq(&phba->hbalock); | ||
1553 | goto out; | 1762 | goto out; |
1554 | } | 1763 | } |
1555 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1764 | /* |
1556 | goto read_next_fcf; | 1765 | * Read next FCF record from HBA searching for the matching |
1766 | * with in-use record only if not during the fast failover | ||
1767 | * period. In case of fast failover period, it shall try to | ||
1768 | * determine whether the FCF record just read should be the | ||
1769 | * next candidate. | ||
1770 | */ | ||
1771 | if (!(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { | ||
1772 | spin_unlock_irq(&phba->hbalock); | ||
1773 | goto read_next_fcf; | ||
1774 | } | ||
1557 | } | 1775 | } |
1776 | /* | ||
1777 | * Update on failover FCF record only if it's in FCF fast-failover | ||
1778 | * period; otherwise, update on current FCF record. | ||
1779 | */ | ||
1780 | if (phba->fcf.fcf_flag & FCF_REDISC_FOV) | ||
1781 | fcf_rec = &phba->fcf.failover_rec; | ||
1782 | else | ||
1783 | fcf_rec = &phba->fcf.current_rec; | ||
1784 | |||
1558 | if (phba->fcf.fcf_flag & FCF_AVAILABLE) { | 1785 | if (phba->fcf.fcf_flag & FCF_AVAILABLE) { |
1559 | /* | 1786 | /* |
1560 | * If the current FCF record does not have boot flag | 1787 | * If the driver FCF record does not have boot flag |
1561 | * set and new fcf record has boot flag set, use the | 1788 | * set and new hba fcf record has boot flag set, use |
1562 | * new fcf record. | 1789 | * the new hba fcf record. |
1563 | */ | 1790 | */ |
1564 | if (boot_flag && !(phba->fcf.fcf_flag & FCF_BOOT_ENABLE)) { | 1791 | if (boot_flag && !(fcf_rec->flag & BOOT_ENABLE)) { |
1565 | /* Use this FCF record */ | 1792 | /* Choose this FCF record */ |
1566 | lpfc_copy_fcf_record(phba, new_fcf_record); | 1793 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, |
1567 | phba->fcf.addr_mode = addr_mode; | 1794 | addr_mode, vlan_id, BOOT_ENABLE); |
1568 | phba->fcf.fcf_flag |= FCF_BOOT_ENABLE; | 1795 | spin_unlock_irq(&phba->hbalock); |
1569 | if (vlan_id != 0xFFFF) { | ||
1570 | phba->fcf.fcf_flag |= FCF_VALID_VLAN; | ||
1571 | phba->fcf.vlan_id = vlan_id; | ||
1572 | } | ||
1573 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
1574 | goto read_next_fcf; | 1796 | goto read_next_fcf; |
1575 | } | 1797 | } |
1576 | /* | 1798 | /* |
1577 | * If the current FCF record has boot flag set and the | 1799 | * If the driver FCF record has boot flag set and the |
1578 | * new FCF record does not have boot flag, read the next | 1800 | * new hba FCF record does not have boot flag, read |
1579 | * FCF record. | 1801 | * the next FCF record. |
1580 | */ | 1802 | */ |
1581 | if (!boot_flag && (phba->fcf.fcf_flag & FCF_BOOT_ENABLE)) { | 1803 | if (!boot_flag && (fcf_rec->flag & BOOT_ENABLE)) { |
1582 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1804 | spin_unlock_irq(&phba->hbalock); |
1583 | goto read_next_fcf; | 1805 | goto read_next_fcf; |
1584 | } | 1806 | } |
1585 | /* | 1807 | /* |
1586 | * If there is a record with lower priority value for | 1808 | * If the new hba FCF record has lower priority value |
1587 | * the current FCF, use that record. | 1809 | * than the driver FCF record, use the new record. |
1588 | */ | 1810 | */ |
1589 | if (lpfc_fab_name_match(phba->fcf.fabric_name, | 1811 | if (new_fcf_record->fip_priority < fcf_rec->priority) { |
1590 | new_fcf_record) && | 1812 | /* Choose this FCF record */ |
1591 | (new_fcf_record->fip_priority < phba->fcf.priority)) { | 1813 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, |
1592 | /* Use this FCF record */ | 1814 | addr_mode, vlan_id, 0); |
1593 | lpfc_copy_fcf_record(phba, new_fcf_record); | ||
1594 | phba->fcf.addr_mode = addr_mode; | ||
1595 | if (vlan_id != 0xFFFF) { | ||
1596 | phba->fcf.fcf_flag |= FCF_VALID_VLAN; | ||
1597 | phba->fcf.vlan_id = vlan_id; | ||
1598 | } | ||
1599 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
1600 | goto read_next_fcf; | ||
1601 | } | 1815 | } |
1602 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1816 | spin_unlock_irq(&phba->hbalock); |
1603 | goto read_next_fcf; | 1817 | goto read_next_fcf; |
1604 | } | 1818 | } |
1605 | /* | 1819 | /* |
1606 | * This is the first available FCF record, use this | 1820 | * This is the first suitable FCF record, choose this record for |
1607 | * record. | 1821 | * initial best-fit FCF. |
1608 | */ | 1822 | */ |
1609 | lpfc_copy_fcf_record(phba, new_fcf_record); | 1823 | if (fcf_rec) { |
1610 | phba->fcf.addr_mode = addr_mode; | 1824 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, |
1611 | if (boot_flag) | 1825 | addr_mode, vlan_id, (boot_flag ? |
1612 | phba->fcf.fcf_flag |= FCF_BOOT_ENABLE; | 1826 | BOOT_ENABLE : 0)); |
1613 | phba->fcf.fcf_flag |= FCF_AVAILABLE; | 1827 | phba->fcf.fcf_flag |= FCF_AVAILABLE; |
1614 | if (vlan_id != 0xFFFF) { | ||
1615 | phba->fcf.fcf_flag |= FCF_VALID_VLAN; | ||
1616 | phba->fcf.vlan_id = vlan_id; | ||
1617 | } | 1828 | } |
1618 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1829 | spin_unlock_irq(&phba->hbalock); |
1619 | goto read_next_fcf; | 1830 | goto read_next_fcf; |
1620 | 1831 | ||
1621 | read_next_fcf: | 1832 | read_next_fcf: |
1622 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | 1833 | lpfc_sli4_mbox_cmd_free(phba, mboxq); |
1623 | if (next_fcf_index == LPFC_FCOE_FCF_NEXT_NONE || next_fcf_index == 0) | 1834 | if (next_fcf_index == LPFC_FCOE_FCF_NEXT_NONE || next_fcf_index == 0) { |
1624 | lpfc_register_fcf(phba); | 1835 | if (phba->fcf.fcf_flag & FCF_REDISC_FOV) { |
1625 | else | 1836 | /* |
1626 | lpfc_sli4_read_fcf_record(phba, next_fcf_index); | 1837 | * Case of FCF fast failover scan |
1838 | */ | ||
1839 | |||
1840 | /* | ||
1841 | * It has not found any suitable FCF record, cancel | ||
1842 | * FCF scan inprogress, and do nothing | ||
1843 | */ | ||
1844 | if (!(phba->fcf.failover_rec.flag & RECORD_VALID)) { | ||
1845 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1846 | "2782 No suitable FCF record " | ||
1847 | "found during this round of " | ||
1848 | "post FCF rediscovery scan: " | ||
1849 | "fcf_evt_tag:x%x, fcf_index: " | ||
1850 | "x%x\n", | ||
1851 | phba->fcoe_eventtag_at_fcf_scan, | ||
1852 | bf_get(lpfc_fcf_record_fcf_index, | ||
1853 | new_fcf_record)); | ||
1854 | /* | ||
1855 | * Let next new FCF event trigger fast | ||
1856 | * failover | ||
1857 | */ | ||
1858 | spin_lock_irq(&phba->hbalock); | ||
1859 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | ||
1860 | spin_unlock_irq(&phba->hbalock); | ||
1861 | return; | ||
1862 | } | ||
1863 | /* | ||
1864 | * It has found a suitable FCF record that is not | ||
1865 | * the same as in-use FCF record, unregister the | ||
1866 | * in-use FCF record, replace the in-use FCF record | ||
1867 | * with the new FCF record, mark FCF fast failover | ||
1868 | * completed, and then start register the new FCF | ||
1869 | * record. | ||
1870 | */ | ||
1871 | |||
1872 | /* Unregister the current in-use FCF record */ | ||
1873 | lpfc_unregister_fcf(phba); | ||
1874 | |||
1875 | /* Replace in-use record with the new record */ | ||
1876 | memcpy(&phba->fcf.current_rec, | ||
1877 | &phba->fcf.failover_rec, | ||
1878 | sizeof(struct lpfc_fcf_rec)); | ||
1879 | /* mark the FCF fast failover completed */ | ||
1880 | spin_lock_irq(&phba->hbalock); | ||
1881 | phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; | ||
1882 | spin_unlock_irq(&phba->hbalock); | ||
1883 | /* | ||
1884 | * Set up the initial registered FCF index for FLOGI | ||
1885 | * round robin FCF failover. | ||
1886 | */ | ||
1887 | phba->fcf.fcf_rr_init_indx = | ||
1888 | phba->fcf.failover_rec.fcf_indx; | ||
1889 | /* Register to the new FCF record */ | ||
1890 | lpfc_register_fcf(phba); | ||
1891 | } else { | ||
1892 | /* | ||
1893 | * In case of transaction period to fast FCF failover, | ||
1894 | * do nothing when search to the end of the FCF table. | ||
1895 | */ | ||
1896 | if ((phba->fcf.fcf_flag & FCF_REDISC_EVT) || | ||
1897 | (phba->fcf.fcf_flag & FCF_REDISC_PEND)) | ||
1898 | return; | ||
1899 | /* | ||
1900 | * Otherwise, initial scan or post linkdown rescan, | ||
1901 | * register with the best FCF record found so far | ||
1902 | * through the FCF scanning process. | ||
1903 | */ | ||
1904 | |||
1905 | /* mark the initial FCF discovery completed */ | ||
1906 | spin_lock_irq(&phba->hbalock); | ||
1907 | phba->fcf.fcf_flag &= ~FCF_INIT_DISC; | ||
1908 | spin_unlock_irq(&phba->hbalock); | ||
1909 | /* | ||
1910 | * Set up the initial registered FCF index for FLOGI | ||
1911 | * round robin FCF failover | ||
1912 | */ | ||
1913 | phba->fcf.fcf_rr_init_indx = | ||
1914 | phba->fcf.current_rec.fcf_indx; | ||
1915 | /* Register to the new FCF record */ | ||
1916 | lpfc_register_fcf(phba); | ||
1917 | } | ||
1918 | } else | ||
1919 | lpfc_sli4_fcf_scan_read_fcf_rec(phba, next_fcf_index); | ||
1627 | return; | 1920 | return; |
1628 | 1921 | ||
1629 | out: | 1922 | out: |
@@ -1634,16 +1927,154 @@ out: | |||
1634 | } | 1927 | } |
1635 | 1928 | ||
1636 | /** | 1929 | /** |
1930 | * lpfc_mbx_cmpl_fcf_rr_read_fcf_rec - fcf round robin read_fcf mbox cmpl hdler | ||
1931 | * @phba: pointer to lpfc hba data structure. | ||
1932 | * @mboxq: pointer to mailbox object. | ||
1933 | * | ||
1934 | * This is the callback function for FLOGI failure round robin FCF failover | ||
1935 | * read FCF record mailbox command from the eligible FCF record bmask for | ||
1936 | * performing the failover. If the FCF read back is not valid/available, it | ||
1937 | * fails through to retrying FLOGI to the currently registered FCF again. | ||
1938 | * Otherwise, if the FCF read back is valid and available, it will set the | ||
1939 | * newly read FCF record to the failover FCF record, unregister currently | ||
1940 | * registered FCF record, copy the failover FCF record to the current | ||
1941 | * FCF record, and then register the current FCF record before proceeding | ||
1942 | * to trying FLOGI on the new failover FCF. | ||
1943 | */ | ||
1944 | void | ||
1945 | lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | ||
1946 | { | ||
1947 | struct fcf_record *new_fcf_record; | ||
1948 | uint32_t boot_flag, addr_mode; | ||
1949 | uint16_t next_fcf_index; | ||
1950 | uint16_t current_fcf_index; | ||
1951 | uint16_t vlan_id; | ||
1952 | |||
1953 | /* If link state is not up, stop the round robin failover process */ | ||
1954 | if (phba->link_state < LPFC_LINK_UP) { | ||
1955 | spin_lock_irq(&phba->hbalock); | ||
1956 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; | ||
1957 | spin_unlock_irq(&phba->hbalock); | ||
1958 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1959 | return; | ||
1960 | } | ||
1961 | |||
1962 | /* Parse the FCF record from the non-embedded mailbox command */ | ||
1963 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | ||
1964 | &next_fcf_index); | ||
1965 | if (!new_fcf_record) { | ||
1966 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1967 | "2766 Mailbox command READ_FCF_RECORD " | ||
1968 | "failed to retrieve a FCF record.\n"); | ||
1969 | goto out; | ||
1970 | } | ||
1971 | |||
1972 | /* Get the needed parameters from FCF record */ | ||
1973 | lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | ||
1974 | &addr_mode, &vlan_id); | ||
1975 | |||
1976 | /* Log the FCF record information if turned on */ | ||
1977 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | ||
1978 | next_fcf_index); | ||
1979 | |||
1980 | /* Upload new FCF record to the failover FCF record */ | ||
1981 | spin_lock_irq(&phba->hbalock); | ||
1982 | __lpfc_update_fcf_record(phba, &phba->fcf.failover_rec, | ||
1983 | new_fcf_record, addr_mode, vlan_id, | ||
1984 | (boot_flag ? BOOT_ENABLE : 0)); | ||
1985 | spin_unlock_irq(&phba->hbalock); | ||
1986 | |||
1987 | current_fcf_index = phba->fcf.current_rec.fcf_indx; | ||
1988 | |||
1989 | /* Unregister the current in-use FCF record */ | ||
1990 | lpfc_unregister_fcf(phba); | ||
1991 | |||
1992 | /* Replace in-use record with the new record */ | ||
1993 | memcpy(&phba->fcf.current_rec, &phba->fcf.failover_rec, | ||
1994 | sizeof(struct lpfc_fcf_rec)); | ||
1995 | |||
1996 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1997 | "2783 FLOGI round robin FCF failover from FCF " | ||
1998 | "(index:x%x) to FCF (index:x%x).\n", | ||
1999 | current_fcf_index, | ||
2000 | bf_get(lpfc_fcf_record_fcf_index, new_fcf_record)); | ||
2001 | |||
2002 | out: | ||
2003 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
2004 | lpfc_register_fcf(phba); | ||
2005 | } | ||
2006 | |||
2007 | /** | ||
2008 | * lpfc_mbx_cmpl_read_fcf_rec - read fcf completion handler. | ||
2009 | * @phba: pointer to lpfc hba data structure. | ||
2010 | * @mboxq: pointer to mailbox object. | ||
2011 | * | ||
2012 | * This is the callback function of read FCF record mailbox command for | ||
2013 | * updating the eligible FCF bmask for FLOGI failure round robin FCF | ||
2014 | * failover when a new FCF event happened. If the FCF read back is | ||
2015 | * valid/available and it passes the connection list check, it updates | ||
2016 | * the bmask for the eligible FCF record for round robin failover. | ||
2017 | */ | ||
2018 | void | ||
2019 | lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | ||
2020 | { | ||
2021 | struct fcf_record *new_fcf_record; | ||
2022 | uint32_t boot_flag, addr_mode; | ||
2023 | uint16_t fcf_index, next_fcf_index; | ||
2024 | uint16_t vlan_id; | ||
2025 | int rc; | ||
2026 | |||
2027 | /* If link state is not up, no need to proceed */ | ||
2028 | if (phba->link_state < LPFC_LINK_UP) | ||
2029 | goto out; | ||
2030 | |||
2031 | /* If FCF discovery period is over, no need to proceed */ | ||
2032 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) | ||
2033 | goto out; | ||
2034 | |||
2035 | /* Parse the FCF record from the non-embedded mailbox command */ | ||
2036 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | ||
2037 | &next_fcf_index); | ||
2038 | if (!new_fcf_record) { | ||
2039 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
2040 | "2767 Mailbox command READ_FCF_RECORD " | ||
2041 | "failed to retrieve a FCF record.\n"); | ||
2042 | goto out; | ||
2043 | } | ||
2044 | |||
2045 | /* Check the connection list for eligibility */ | ||
2046 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | ||
2047 | &addr_mode, &vlan_id); | ||
2048 | |||
2049 | /* Log the FCF record information if turned on */ | ||
2050 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | ||
2051 | next_fcf_index); | ||
2052 | |||
2053 | if (!rc) | ||
2054 | goto out; | ||
2055 | |||
2056 | /* Update the eligible FCF record index bmask */ | ||
2057 | fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); | ||
2058 | rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); | ||
2059 | |||
2060 | out: | ||
2061 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
2062 | } | ||
2063 | |||
2064 | /** | ||
1637 | * lpfc_init_vpi_cmpl - Completion handler for init_vpi mbox command. | 2065 | * lpfc_init_vpi_cmpl - Completion handler for init_vpi mbox command. |
1638 | * @phba: pointer to lpfc hba data structure. | 2066 | * @phba: pointer to lpfc hba data structure. |
1639 | * @mboxq: pointer to mailbox data structure. | 2067 | * @mboxq: pointer to mailbox data structure. |
1640 | * | 2068 | * |
1641 | * This function handles completion of init vpi mailbox command. | 2069 | * This function handles completion of init vpi mailbox command. |
1642 | */ | 2070 | */ |
1643 | static void | 2071 | void |
1644 | lpfc_init_vpi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | 2072 | lpfc_init_vpi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) |
1645 | { | 2073 | { |
1646 | struct lpfc_vport *vport = mboxq->vport; | 2074 | struct lpfc_vport *vport = mboxq->vport; |
2075 | struct lpfc_nodelist *ndlp; | ||
2076 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | ||
2077 | |||
1647 | if (mboxq->u.mb.mbxStatus) { | 2078 | if (mboxq->u.mb.mbxStatus) { |
1648 | lpfc_printf_vlog(vport, KERN_ERR, | 2079 | lpfc_printf_vlog(vport, KERN_ERR, |
1649 | LOG_MBOX, | 2080 | LOG_MBOX, |
@@ -1653,20 +2084,67 @@ lpfc_init_vpi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1653 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); | 2084 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
1654 | return; | 2085 | return; |
1655 | } | 2086 | } |
2087 | spin_lock_irq(shost->host_lock); | ||
1656 | vport->fc_flag &= ~FC_VPORT_NEEDS_INIT_VPI; | 2088 | vport->fc_flag &= ~FC_VPORT_NEEDS_INIT_VPI; |
2089 | spin_unlock_irq(shost->host_lock); | ||
2090 | |||
2091 | /* If this port is physical port or FDISC is done, do reg_vpi */ | ||
2092 | if ((phba->pport == vport) || (vport->port_state == LPFC_FDISC)) { | ||
2093 | ndlp = lpfc_findnode_did(vport, Fabric_DID); | ||
2094 | if (!ndlp) | ||
2095 | lpfc_printf_vlog(vport, KERN_ERR, | ||
2096 | LOG_DISCOVERY, | ||
2097 | "2731 Cannot find fabric " | ||
2098 | "controller node\n"); | ||
2099 | else | ||
2100 | lpfc_register_new_vport(phba, vport, ndlp); | ||
2101 | mempool_free(mboxq, phba->mbox_mem_pool); | ||
2102 | return; | ||
2103 | } | ||
1657 | 2104 | ||
1658 | if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) | 2105 | if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) |
1659 | lpfc_initial_fdisc(vport); | 2106 | lpfc_initial_fdisc(vport); |
1660 | else { | 2107 | else { |
1661 | lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP); | 2108 | lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP); |
1662 | lpfc_printf_vlog(vport, KERN_ERR, | 2109 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
1663 | LOG_ELS, | 2110 | "2606 No NPIV Fabric support\n"); |
1664 | "2606 No NPIV Fabric support\n"); | ||
1665 | } | 2111 | } |
2112 | mempool_free(mboxq, phba->mbox_mem_pool); | ||
1666 | return; | 2113 | return; |
1667 | } | 2114 | } |
1668 | 2115 | ||
1669 | /** | 2116 | /** |
2117 | * lpfc_issue_init_vpi - Issue init_vpi mailbox command. | ||
2118 | * @vport: pointer to lpfc_vport data structure. | ||
2119 | * | ||
2120 | * This function issue a init_vpi mailbox command to initialize | ||
2121 | * VPI for the vport. | ||
2122 | */ | ||
2123 | void | ||
2124 | lpfc_issue_init_vpi(struct lpfc_vport *vport) | ||
2125 | { | ||
2126 | LPFC_MBOXQ_t *mboxq; | ||
2127 | int rc; | ||
2128 | |||
2129 | mboxq = mempool_alloc(vport->phba->mbox_mem_pool, GFP_KERNEL); | ||
2130 | if (!mboxq) { | ||
2131 | lpfc_printf_vlog(vport, KERN_ERR, | ||
2132 | LOG_MBOX, "2607 Failed to allocate " | ||
2133 | "init_vpi mailbox\n"); | ||
2134 | return; | ||
2135 | } | ||
2136 | lpfc_init_vpi(vport->phba, mboxq, vport->vpi); | ||
2137 | mboxq->vport = vport; | ||
2138 | mboxq->mbox_cmpl = lpfc_init_vpi_cmpl; | ||
2139 | rc = lpfc_sli_issue_mbox(vport->phba, mboxq, MBX_NOWAIT); | ||
2140 | if (rc == MBX_NOT_FINISHED) { | ||
2141 | lpfc_printf_vlog(vport, KERN_ERR, | ||
2142 | LOG_MBOX, "2608 Failed to issue init_vpi mailbox\n"); | ||
2143 | mempool_free(mboxq, vport->phba->mbox_mem_pool); | ||
2144 | } | ||
2145 | } | ||
2146 | |||
2147 | /** | ||
1670 | * lpfc_start_fdiscs - send fdiscs for each vports on this port. | 2148 | * lpfc_start_fdiscs - send fdiscs for each vports on this port. |
1671 | * @phba: pointer to lpfc hba data structure. | 2149 | * @phba: pointer to lpfc hba data structure. |
1672 | * | 2150 | * |
@@ -1678,8 +2156,6 @@ lpfc_start_fdiscs(struct lpfc_hba *phba) | |||
1678 | { | 2156 | { |
1679 | struct lpfc_vport **vports; | 2157 | struct lpfc_vport **vports; |
1680 | int i; | 2158 | int i; |
1681 | LPFC_MBOXQ_t *mboxq; | ||
1682 | int rc; | ||
1683 | 2159 | ||
1684 | vports = lpfc_create_vport_work_array(phba); | 2160 | vports = lpfc_create_vport_work_array(phba); |
1685 | if (vports != NULL) { | 2161 | if (vports != NULL) { |
@@ -1698,26 +2174,7 @@ lpfc_start_fdiscs(struct lpfc_hba *phba) | |||
1698 | continue; | 2174 | continue; |
1699 | } | 2175 | } |
1700 | if (vports[i]->fc_flag & FC_VPORT_NEEDS_INIT_VPI) { | 2176 | if (vports[i]->fc_flag & FC_VPORT_NEEDS_INIT_VPI) { |
1701 | mboxq = mempool_alloc(phba->mbox_mem_pool, | 2177 | lpfc_issue_init_vpi(vports[i]); |
1702 | GFP_KERNEL); | ||
1703 | if (!mboxq) { | ||
1704 | lpfc_printf_vlog(vports[i], KERN_ERR, | ||
1705 | LOG_MBOX, "2607 Failed to allocate " | ||
1706 | "init_vpi mailbox\n"); | ||
1707 | continue; | ||
1708 | } | ||
1709 | lpfc_init_vpi(phba, mboxq, vports[i]->vpi); | ||
1710 | mboxq->vport = vports[i]; | ||
1711 | mboxq->mbox_cmpl = lpfc_init_vpi_cmpl; | ||
1712 | rc = lpfc_sli_issue_mbox(phba, mboxq, | ||
1713 | MBX_NOWAIT); | ||
1714 | if (rc == MBX_NOT_FINISHED) { | ||
1715 | lpfc_printf_vlog(vports[i], KERN_ERR, | ||
1716 | LOG_MBOX, "2608 Failed to issue " | ||
1717 | "init_vpi mailbox\n"); | ||
1718 | mempool_free(mboxq, | ||
1719 | phba->mbox_mem_pool); | ||
1720 | } | ||
1721 | continue; | 2178 | continue; |
1722 | } | 2179 | } |
1723 | if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) | 2180 | if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) |
@@ -1740,6 +2197,7 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1740 | { | 2197 | { |
1741 | struct lpfc_dmabuf *dmabuf = mboxq->context1; | 2198 | struct lpfc_dmabuf *dmabuf = mboxq->context1; |
1742 | struct lpfc_vport *vport = mboxq->vport; | 2199 | struct lpfc_vport *vport = mboxq->vport; |
2200 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | ||
1743 | 2201 | ||
1744 | if (mboxq->u.mb.mbxStatus) { | 2202 | if (mboxq->u.mb.mbxStatus) { |
1745 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, | 2203 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
@@ -1756,8 +2214,12 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1756 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); | 2214 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
1757 | goto fail_free_mem; | 2215 | goto fail_free_mem; |
1758 | } | 2216 | } |
1759 | /* Mark the vport has registered with its VFI */ | 2217 | /* The VPI is implicitly registered when the VFI is registered */ |
1760 | vport->vfi_state |= LPFC_VFI_REGISTERED; | 2218 | spin_lock_irq(shost->host_lock); |
2219 | vport->vpi_state |= LPFC_VPI_REGISTERED; | ||
2220 | vport->fc_flag |= FC_VFI_REGISTERED; | ||
2221 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; | ||
2222 | spin_unlock_irq(shost->host_lock); | ||
1761 | 2223 | ||
1762 | if (vport->port_state == LPFC_FABRIC_CFG_LINK) { | 2224 | if (vport->port_state == LPFC_FABRIC_CFG_LINK) { |
1763 | lpfc_start_fdiscs(phba); | 2225 | lpfc_start_fdiscs(phba); |
@@ -1831,8 +2293,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
1831 | int rc; | 2293 | int rc; |
1832 | struct fcf_record *fcf_record; | 2294 | struct fcf_record *fcf_record; |
1833 | 2295 | ||
1834 | sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | ||
1835 | |||
1836 | spin_lock_irq(&phba->hbalock); | 2296 | spin_lock_irq(&phba->hbalock); |
1837 | switch (la->UlnkSpeed) { | 2297 | switch (la->UlnkSpeed) { |
1838 | case LA_1GHZ_LINK: | 2298 | case LA_1GHZ_LINK: |
@@ -1861,7 +2321,10 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
1861 | if (phba->fc_topology == TOPOLOGY_LOOP) { | 2321 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
1862 | phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; | 2322 | phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; |
1863 | 2323 | ||
1864 | if (phba->cfg_enable_npiv) | 2324 | /* if npiv is enabled and this adapter supports npiv log |
2325 | * a message that npiv is not supported in this topology | ||
2326 | */ | ||
2327 | if (phba->cfg_enable_npiv && phba->max_vpi) | ||
1865 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | 2328 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, |
1866 | "1309 Link Up Event npiv not supported in loop " | 2329 | "1309 Link Up Event npiv not supported in loop " |
1867 | "topology\n"); | 2330 | "topology\n"); |
@@ -1921,18 +2384,24 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
1921 | spin_unlock_irq(&phba->hbalock); | 2384 | spin_unlock_irq(&phba->hbalock); |
1922 | 2385 | ||
1923 | lpfc_linkup(phba); | 2386 | lpfc_linkup(phba); |
1924 | if (sparam_mbox) { | 2387 | sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
1925 | lpfc_read_sparam(phba, sparam_mbox, 0); | 2388 | if (!sparam_mbox) |
1926 | sparam_mbox->vport = vport; | 2389 | goto out; |
1927 | sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; | 2390 | |
1928 | rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT); | 2391 | rc = lpfc_read_sparam(phba, sparam_mbox, 0); |
1929 | if (rc == MBX_NOT_FINISHED) { | 2392 | if (rc) { |
1930 | mp = (struct lpfc_dmabuf *) sparam_mbox->context1; | 2393 | mempool_free(sparam_mbox, phba->mbox_mem_pool); |
1931 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 2394 | goto out; |
1932 | kfree(mp); | 2395 | } |
1933 | mempool_free(sparam_mbox, phba->mbox_mem_pool); | 2396 | sparam_mbox->vport = vport; |
1934 | goto out; | 2397 | sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; |
1935 | } | 2398 | rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT); |
2399 | if (rc == MBX_NOT_FINISHED) { | ||
2400 | mp = (struct lpfc_dmabuf *) sparam_mbox->context1; | ||
2401 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | ||
2402 | kfree(mp); | ||
2403 | mempool_free(sparam_mbox, phba->mbox_mem_pool); | ||
2404 | goto out; | ||
1936 | } | 2405 | } |
1937 | 2406 | ||
1938 | if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) { | 2407 | if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) { |
@@ -1955,7 +2424,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
1955 | * is phase 1 implementation that support FCF index 0 and driver | 2424 | * is phase 1 implementation that support FCF index 0 and driver |
1956 | * defaults. | 2425 | * defaults. |
1957 | */ | 2426 | */ |
1958 | if (phba->cfg_enable_fip == 0) { | 2427 | if (!(phba->hba_flag & HBA_FIP_SUPPORT)) { |
1959 | fcf_record = kzalloc(sizeof(struct fcf_record), | 2428 | fcf_record = kzalloc(sizeof(struct fcf_record), |
1960 | GFP_KERNEL); | 2429 | GFP_KERNEL); |
1961 | if (unlikely(!fcf_record)) { | 2430 | if (unlikely(!fcf_record)) { |
@@ -1990,11 +2459,20 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
1990 | spin_unlock_irq(&phba->hbalock); | 2459 | spin_unlock_irq(&phba->hbalock); |
1991 | return; | 2460 | return; |
1992 | } | 2461 | } |
2462 | /* This is the initial FCF discovery scan */ | ||
2463 | phba->fcf.fcf_flag |= FCF_INIT_DISC; | ||
1993 | spin_unlock_irq(&phba->hbalock); | 2464 | spin_unlock_irq(&phba->hbalock); |
1994 | rc = lpfc_sli4_read_fcf_record(phba, | 2465 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, |
1995 | LPFC_FCOE_FCF_GET_FIRST); | 2466 | "2778 Start FCF table scan at linkup\n"); |
1996 | if (rc) | 2467 | |
2468 | rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, | ||
2469 | LPFC_FCOE_FCF_GET_FIRST); | ||
2470 | if (rc) { | ||
2471 | spin_lock_irq(&phba->hbalock); | ||
2472 | phba->fcf.fcf_flag &= ~FCF_INIT_DISC; | ||
2473 | spin_unlock_irq(&phba->hbalock); | ||
1997 | goto out; | 2474 | goto out; |
2475 | } | ||
1998 | } | 2476 | } |
1999 | 2477 | ||
2000 | return; | 2478 | return; |
@@ -2080,11 +2558,14 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
2080 | } | 2558 | } |
2081 | 2559 | ||
2082 | phba->fc_eventTag = la->eventTag; | 2560 | phba->fc_eventTag = la->eventTag; |
2561 | spin_lock_irq(&phba->hbalock); | ||
2083 | if (la->mm) | 2562 | if (la->mm) |
2084 | phba->sli.sli_flag |= LPFC_MENLO_MAINT; | 2563 | phba->sli.sli_flag |= LPFC_MENLO_MAINT; |
2085 | else | 2564 | else |
2086 | phba->sli.sli_flag &= ~LPFC_MENLO_MAINT; | 2565 | phba->sli.sli_flag &= ~LPFC_MENLO_MAINT; |
2566 | spin_unlock_irq(&phba->hbalock); | ||
2087 | 2567 | ||
2568 | phba->link_events++; | ||
2088 | if (la->attType == AT_LINK_UP && (!la->mm)) { | 2569 | if (la->attType == AT_LINK_UP && (!la->mm)) { |
2089 | phba->fc_stat.LinkUp++; | 2570 | phba->fc_stat.LinkUp++; |
2090 | if (phba->link_flag & LS_LOOPBACK_MODE) { | 2571 | if (phba->link_flag & LS_LOOPBACK_MODE) { |
@@ -2211,13 +2692,17 @@ lpfc_mbx_cmpl_unreg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
2211 | mb->mbxStatus); | 2692 | mb->mbxStatus); |
2212 | break; | 2693 | break; |
2213 | } | 2694 | } |
2695 | spin_lock_irq(shost->host_lock); | ||
2696 | vport->vpi_state &= ~LPFC_VPI_REGISTERED; | ||
2697 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | ||
2698 | spin_unlock_irq(shost->host_lock); | ||
2214 | vport->unreg_vpi_cmpl = VPORT_OK; | 2699 | vport->unreg_vpi_cmpl = VPORT_OK; |
2215 | mempool_free(pmb, phba->mbox_mem_pool); | 2700 | mempool_free(pmb, phba->mbox_mem_pool); |
2216 | /* | 2701 | /* |
2217 | * This shost reference might have been taken at the beginning of | 2702 | * This shost reference might have been taken at the beginning of |
2218 | * lpfc_vport_delete() | 2703 | * lpfc_vport_delete() |
2219 | */ | 2704 | */ |
2220 | if (vport->load_flag & FC_UNLOADING) | 2705 | if ((vport->load_flag & FC_UNLOADING) && (vport != phba->pport)) |
2221 | scsi_host_put(shost); | 2706 | scsi_host_put(shost); |
2222 | } | 2707 | } |
2223 | 2708 | ||
@@ -2268,6 +2753,10 @@ lpfc_mbx_cmpl_reg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
2268 | goto out; | 2753 | goto out; |
2269 | } | 2754 | } |
2270 | 2755 | ||
2756 | spin_lock_irq(shost->host_lock); | ||
2757 | vport->vpi_state |= LPFC_VPI_REGISTERED; | ||
2758 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; | ||
2759 | spin_unlock_irq(shost->host_lock); | ||
2271 | vport->num_disc_nodes = 0; | 2760 | vport->num_disc_nodes = 0; |
2272 | /* go thru NPR list and issue ELS PLOGIs */ | 2761 | /* go thru NPR list and issue ELS PLOGIs */ |
2273 | if (vport->fc_npr_cnt) | 2762 | if (vport->fc_npr_cnt) |
@@ -3077,7 +3566,7 @@ lpfc_no_rpi(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | |||
3077 | struct lpfc_sli *psli; | 3566 | struct lpfc_sli *psli; |
3078 | struct lpfc_sli_ring *pring; | 3567 | struct lpfc_sli_ring *pring; |
3079 | struct lpfc_iocbq *iocb, *next_iocb; | 3568 | struct lpfc_iocbq *iocb, *next_iocb; |
3080 | uint32_t rpi, i; | 3569 | uint32_t i; |
3081 | 3570 | ||
3082 | lpfc_fabric_abort_nport(ndlp); | 3571 | lpfc_fabric_abort_nport(ndlp); |
3083 | 3572 | ||
@@ -3086,7 +3575,6 @@ lpfc_no_rpi(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | |||
3086 | * by firmware with a no rpi error. | 3575 | * by firmware with a no rpi error. |
3087 | */ | 3576 | */ |
3088 | psli = &phba->sli; | 3577 | psli = &phba->sli; |
3089 | rpi = ndlp->nlp_rpi; | ||
3090 | if (ndlp->nlp_flag & NLP_RPI_VALID) { | 3578 | if (ndlp->nlp_flag & NLP_RPI_VALID) { |
3091 | /* Now process each ring */ | 3579 | /* Now process each ring */ |
3092 | for (i = 0; i < psli->num_rings; i++) { | 3580 | for (i = 0; i < psli->num_rings; i++) { |
@@ -3154,6 +3642,38 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
3154 | return 0; | 3642 | return 0; |
3155 | } | 3643 | } |
3156 | 3644 | ||
3645 | /** | ||
3646 | * lpfc_unreg_hba_rpis - Unregister rpis registered to the hba. | ||
3647 | * @phba: pointer to lpfc hba data structure. | ||
3648 | * | ||
3649 | * This routine is invoked to unregister all the currently registered RPIs | ||
3650 | * to the HBA. | ||
3651 | **/ | ||
3652 | void | ||
3653 | lpfc_unreg_hba_rpis(struct lpfc_hba *phba) | ||
3654 | { | ||
3655 | struct lpfc_vport **vports; | ||
3656 | struct lpfc_nodelist *ndlp; | ||
3657 | struct Scsi_Host *shost; | ||
3658 | int i; | ||
3659 | |||
3660 | vports = lpfc_create_vport_work_array(phba); | ||
3661 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { | ||
3662 | shost = lpfc_shost_from_vport(vports[i]); | ||
3663 | spin_lock_irq(shost->host_lock); | ||
3664 | list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) { | ||
3665 | if (ndlp->nlp_flag & NLP_RPI_VALID) { | ||
3666 | /* The mempool_alloc might sleep */ | ||
3667 | spin_unlock_irq(shost->host_lock); | ||
3668 | lpfc_unreg_rpi(vports[i], ndlp); | ||
3669 | spin_lock_irq(shost->host_lock); | ||
3670 | } | ||
3671 | } | ||
3672 | spin_unlock_irq(shost->host_lock); | ||
3673 | } | ||
3674 | lpfc_destroy_vport_work_array(phba, vports); | ||
3675 | } | ||
3676 | |||
3157 | void | 3677 | void |
3158 | lpfc_unreg_all_rpis(struct lpfc_vport *vport) | 3678 | lpfc_unreg_all_rpis(struct lpfc_vport *vport) |
3159 | { | 3679 | { |
@@ -4322,6 +4842,14 @@ lpfc_fcf_inuse(struct lpfc_hba *phba) | |||
4322 | ret = 1; | 4842 | ret = 1; |
4323 | spin_unlock_irq(shost->host_lock); | 4843 | spin_unlock_irq(shost->host_lock); |
4324 | goto out; | 4844 | goto out; |
4845 | } else { | ||
4846 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, | ||
4847 | "2624 RPI %x DID %x flg %x still " | ||
4848 | "logged in\n", | ||
4849 | ndlp->nlp_rpi, ndlp->nlp_DID, | ||
4850 | ndlp->nlp_flag); | ||
4851 | if (ndlp->nlp_flag & NLP_RPI_VALID) | ||
4852 | ret = 1; | ||
4325 | } | 4853 | } |
4326 | } | 4854 | } |
4327 | spin_unlock_irq(shost->host_lock); | 4855 | spin_unlock_irq(shost->host_lock); |
@@ -4376,120 +4904,231 @@ lpfc_unregister_fcfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
4376 | } | 4904 | } |
4377 | 4905 | ||
4378 | /** | 4906 | /** |
4379 | * lpfc_unregister_unused_fcf - Unregister FCF if all devices are disconnected. | 4907 | * lpfc_unregister_fcf_prep - Unregister fcf record preparation |
4380 | * @phba: Pointer to hba context object. | 4908 | * @phba: Pointer to hba context object. |
4381 | * | 4909 | * |
4382 | * This function check if there are any connected remote port for the FCF and | 4910 | * This function prepare the HBA for unregistering the currently registered |
4383 | * if all the devices are disconnected, this function unregister FCFI. | 4911 | * FCF from the HBA. It performs unregistering, in order, RPIs, VPIs, and |
4384 | * This function also tries to use another FCF for discovery. | 4912 | * VFIs. |
4385 | */ | 4913 | */ |
4386 | void | 4914 | int |
4387 | lpfc_unregister_unused_fcf(struct lpfc_hba *phba) | 4915 | lpfc_unregister_fcf_prep(struct lpfc_hba *phba) |
4388 | { | 4916 | { |
4389 | LPFC_MBOXQ_t *mbox; | 4917 | LPFC_MBOXQ_t *mbox; |
4390 | int rc; | ||
4391 | struct lpfc_vport **vports; | 4918 | struct lpfc_vport **vports; |
4392 | int i; | 4919 | struct lpfc_nodelist *ndlp; |
4393 | 4920 | struct Scsi_Host *shost; | |
4394 | spin_lock_irq(&phba->hbalock); | 4921 | int i, rc; |
4395 | /* | ||
4396 | * If HBA is not running in FIP mode or | ||
4397 | * If HBA does not support FCoE or | ||
4398 | * If FCF is not registered. | ||
4399 | * do nothing. | ||
4400 | */ | ||
4401 | if (!(phba->hba_flag & HBA_FCOE_SUPPORT) || | ||
4402 | !(phba->fcf.fcf_flag & FCF_REGISTERED) || | ||
4403 | (phba->cfg_enable_fip == 0)) { | ||
4404 | spin_unlock_irq(&phba->hbalock); | ||
4405 | return; | ||
4406 | } | ||
4407 | spin_unlock_irq(&phba->hbalock); | ||
4408 | 4922 | ||
4923 | /* Unregister RPIs */ | ||
4409 | if (lpfc_fcf_inuse(phba)) | 4924 | if (lpfc_fcf_inuse(phba)) |
4410 | return; | 4925 | lpfc_unreg_hba_rpis(phba); |
4411 | 4926 | ||
4927 | /* At this point, all discovery is aborted */ | ||
4928 | phba->pport->port_state = LPFC_VPORT_UNKNOWN; | ||
4412 | 4929 | ||
4413 | /* Unregister VPIs */ | 4930 | /* Unregister VPIs */ |
4414 | vports = lpfc_create_vport_work_array(phba); | 4931 | vports = lpfc_create_vport_work_array(phba); |
4415 | if (vports && | 4932 | if (vports && (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) |
4416 | (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) | ||
4417 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { | 4933 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
4934 | /* Stop FLOGI/FDISC retries */ | ||
4935 | ndlp = lpfc_findnode_did(vports[i], Fabric_DID); | ||
4936 | if (ndlp) | ||
4937 | lpfc_cancel_retry_delay_tmo(vports[i], ndlp); | ||
4418 | lpfc_mbx_unreg_vpi(vports[i]); | 4938 | lpfc_mbx_unreg_vpi(vports[i]); |
4419 | vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | 4939 | shost = lpfc_shost_from_vport(vports[i]); |
4420 | vports[i]->vfi_state &= ~LPFC_VFI_REGISTERED; | 4940 | spin_lock_irq(shost->host_lock); |
4941 | vports[i]->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; | ||
4942 | vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; | ||
4943 | spin_unlock_irq(shost->host_lock); | ||
4421 | } | 4944 | } |
4422 | lpfc_destroy_vport_work_array(phba, vports); | 4945 | lpfc_destroy_vport_work_array(phba, vports); |
4423 | 4946 | ||
4947 | /* Cleanup any outstanding ELS commands */ | ||
4948 | lpfc_els_flush_all_cmd(phba); | ||
4949 | |||
4424 | /* Unregister VFI */ | 4950 | /* Unregister VFI */ |
4425 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 4951 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
4426 | if (!mbox) { | 4952 | if (!mbox) { |
4427 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | 4953 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
4428 | "2556 UNREG_VFI mbox allocation failed" | 4954 | "2556 UNREG_VFI mbox allocation failed" |
4429 | "HBA state x%x\n", | 4955 | "HBA state x%x\n", phba->pport->port_state); |
4430 | phba->pport->port_state); | 4956 | return -ENOMEM; |
4431 | return; | ||
4432 | } | 4957 | } |
4433 | 4958 | ||
4434 | lpfc_unreg_vfi(mbox, phba->pport->vfi); | 4959 | lpfc_unreg_vfi(mbox, phba->pport); |
4435 | mbox->vport = phba->pport; | 4960 | mbox->vport = phba->pport; |
4436 | mbox->mbox_cmpl = lpfc_unregister_vfi_cmpl; | 4961 | mbox->mbox_cmpl = lpfc_unregister_vfi_cmpl; |
4437 | 4962 | ||
4438 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); | 4963 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
4439 | if (rc == MBX_NOT_FINISHED) { | 4964 | if (rc == MBX_NOT_FINISHED) { |
4440 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | 4965 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
4441 | "2557 UNREG_VFI issue mbox failed rc x%x " | 4966 | "2557 UNREG_VFI issue mbox failed rc x%x " |
4442 | "HBA state x%x\n", | 4967 | "HBA state x%x\n", |
4443 | rc, phba->pport->port_state); | 4968 | rc, phba->pport->port_state); |
4444 | mempool_free(mbox, phba->mbox_mem_pool); | 4969 | mempool_free(mbox, phba->mbox_mem_pool); |
4445 | return; | 4970 | return -EIO; |
4446 | } | 4971 | } |
4447 | 4972 | ||
4448 | /* Unregister FCF */ | 4973 | shost = lpfc_shost_from_vport(phba->pport); |
4974 | spin_lock_irq(shost->host_lock); | ||
4975 | phba->pport->fc_flag &= ~FC_VFI_REGISTERED; | ||
4976 | spin_unlock_irq(shost->host_lock); | ||
4977 | |||
4978 | return 0; | ||
4979 | } | ||
4980 | |||
4981 | /** | ||
4982 | * lpfc_sli4_unregister_fcf - Unregister currently registered FCF record | ||
4983 | * @phba: Pointer to hba context object. | ||
4984 | * | ||
4985 | * This function issues synchronous unregister FCF mailbox command to HBA to | ||
4986 | * unregister the currently registered FCF record. The driver does not reset | ||
4987 | * the driver FCF usage state flags. | ||
4988 | * | ||
4989 | * Return 0 if successfully issued, none-zero otherwise. | ||
4990 | */ | ||
4991 | int | ||
4992 | lpfc_sli4_unregister_fcf(struct lpfc_hba *phba) | ||
4993 | { | ||
4994 | LPFC_MBOXQ_t *mbox; | ||
4995 | int rc; | ||
4996 | |||
4449 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 4997 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
4450 | if (!mbox) { | 4998 | if (!mbox) { |
4451 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | 4999 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
4452 | "2551 UNREG_FCFI mbox allocation failed" | 5000 | "2551 UNREG_FCFI mbox allocation failed" |
4453 | "HBA state x%x\n", | 5001 | "HBA state x%x\n", phba->pport->port_state); |
4454 | phba->pport->port_state); | 5002 | return -ENOMEM; |
4455 | return; | ||
4456 | } | 5003 | } |
4457 | |||
4458 | lpfc_unreg_fcfi(mbox, phba->fcf.fcfi); | 5004 | lpfc_unreg_fcfi(mbox, phba->fcf.fcfi); |
4459 | mbox->vport = phba->pport; | 5005 | mbox->vport = phba->pport; |
4460 | mbox->mbox_cmpl = lpfc_unregister_fcfi_cmpl; | 5006 | mbox->mbox_cmpl = lpfc_unregister_fcfi_cmpl; |
4461 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); | 5007 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
4462 | 5008 | ||
4463 | if (rc == MBX_NOT_FINISHED) { | 5009 | if (rc == MBX_NOT_FINISHED) { |
4464 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | 5010 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
4465 | "2552 UNREG_FCFI issue mbox failed rc x%x " | 5011 | "2552 Unregister FCFI command failed rc x%x " |
4466 | "HBA state x%x\n", | 5012 | "HBA state x%x\n", |
4467 | rc, phba->pport->port_state); | 5013 | rc, phba->pport->port_state); |
4468 | mempool_free(mbox, phba->mbox_mem_pool); | 5014 | return -EINVAL; |
5015 | } | ||
5016 | return 0; | ||
5017 | } | ||
5018 | |||
5019 | /** | ||
5020 | * lpfc_unregister_fcf_rescan - Unregister currently registered fcf and rescan | ||
5021 | * @phba: Pointer to hba context object. | ||
5022 | * | ||
5023 | * This function unregisters the currently reigstered FCF. This function | ||
5024 | * also tries to find another FCF for discovery by rescan the HBA FCF table. | ||
5025 | */ | ||
5026 | void | ||
5027 | lpfc_unregister_fcf_rescan(struct lpfc_hba *phba) | ||
5028 | { | ||
5029 | int rc; | ||
5030 | |||
5031 | /* Preparation for unregistering fcf */ | ||
5032 | rc = lpfc_unregister_fcf_prep(phba); | ||
5033 | if (rc) { | ||
5034 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | ||
5035 | "2748 Failed to prepare for unregistering " | ||
5036 | "HBA's FCF record: rc=%d\n", rc); | ||
4469 | return; | 5037 | return; |
4470 | } | 5038 | } |
4471 | 5039 | ||
4472 | spin_lock_irq(&phba->hbalock); | 5040 | /* Now, unregister FCF record and reset HBA FCF state */ |
4473 | phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_REGISTERED | | 5041 | rc = lpfc_sli4_unregister_fcf(phba); |
4474 | FCF_DISCOVERED | FCF_BOOT_ENABLE | FCF_IN_USE | | 5042 | if (rc) |
4475 | FCF_VALID_VLAN); | 5043 | return; |
4476 | spin_unlock_irq(&phba->hbalock); | 5044 | /* Reset HBA FCF states after successful unregister FCF */ |
5045 | phba->fcf.fcf_flag = 0; | ||
5046 | phba->fcf.current_rec.flag = 0; | ||
4477 | 5047 | ||
4478 | /* | 5048 | /* |
4479 | * If driver is not unloading, check if there is any other | 5049 | * If driver is not unloading, check if there is any other |
4480 | * FCF record that can be used for discovery. | 5050 | * FCF record that can be used for discovery. |
4481 | */ | 5051 | */ |
4482 | if ((phba->pport->load_flag & FC_UNLOADING) || | 5052 | if ((phba->pport->load_flag & FC_UNLOADING) || |
4483 | (phba->link_state < LPFC_LINK_UP)) | 5053 | (phba->link_state < LPFC_LINK_UP)) |
4484 | return; | 5054 | return; |
4485 | 5055 | ||
4486 | rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 5056 | /* This is considered as the initial FCF discovery scan */ |
5057 | spin_lock_irq(&phba->hbalock); | ||
5058 | phba->fcf.fcf_flag |= FCF_INIT_DISC; | ||
5059 | spin_unlock_irq(&phba->hbalock); | ||
5060 | rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); | ||
4487 | 5061 | ||
4488 | if (rc) | 5062 | if (rc) { |
5063 | spin_lock_irq(&phba->hbalock); | ||
5064 | phba->fcf.fcf_flag &= ~FCF_INIT_DISC; | ||
5065 | spin_unlock_irq(&phba->hbalock); | ||
4489 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | 5066 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
4490 | "2553 lpfc_unregister_unused_fcf failed to read FCF" | 5067 | "2553 lpfc_unregister_unused_fcf failed " |
4491 | " record HBA state x%x\n", | 5068 | "to read FCF record HBA state x%x\n", |
4492 | phba->pport->port_state); | 5069 | phba->pport->port_state); |
5070 | } | ||
5071 | } | ||
5072 | |||
5073 | /** | ||
5074 | * lpfc_unregister_fcf - Unregister the currently registered fcf record | ||
5075 | * @phba: Pointer to hba context object. | ||
5076 | * | ||
5077 | * This function just unregisters the currently reigstered FCF. It does not | ||
5078 | * try to find another FCF for discovery. | ||
5079 | */ | ||
5080 | void | ||
5081 | lpfc_unregister_fcf(struct lpfc_hba *phba) | ||
5082 | { | ||
5083 | int rc; | ||
5084 | |||
5085 | /* Preparation for unregistering fcf */ | ||
5086 | rc = lpfc_unregister_fcf_prep(phba); | ||
5087 | if (rc) { | ||
5088 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | ||
5089 | "2749 Failed to prepare for unregistering " | ||
5090 | "HBA's FCF record: rc=%d\n", rc); | ||
5091 | return; | ||
5092 | } | ||
5093 | |||
5094 | /* Now, unregister FCF record and reset HBA FCF state */ | ||
5095 | rc = lpfc_sli4_unregister_fcf(phba); | ||
5096 | if (rc) | ||
5097 | return; | ||
5098 | /* Set proper HBA FCF states after successful unregister FCF */ | ||
5099 | spin_lock_irq(&phba->hbalock); | ||
5100 | phba->fcf.fcf_flag &= ~FCF_REGISTERED; | ||
5101 | spin_unlock_irq(&phba->hbalock); | ||
5102 | } | ||
5103 | |||
5104 | /** | ||
5105 | * lpfc_unregister_unused_fcf - Unregister FCF if all devices are disconnected. | ||
5106 | * @phba: Pointer to hba context object. | ||
5107 | * | ||
5108 | * This function check if there are any connected remote port for the FCF and | ||
5109 | * if all the devices are disconnected, this function unregister FCFI. | ||
5110 | * This function also tries to use another FCF for discovery. | ||
5111 | */ | ||
5112 | void | ||
5113 | lpfc_unregister_unused_fcf(struct lpfc_hba *phba) | ||
5114 | { | ||
5115 | /* | ||
5116 | * If HBA is not running in FIP mode or if HBA does not support | ||
5117 | * FCoE or if FCF is not registered, do nothing. | ||
5118 | */ | ||
5119 | spin_lock_irq(&phba->hbalock); | ||
5120 | if (!(phba->hba_flag & HBA_FCOE_SUPPORT) || | ||
5121 | !(phba->fcf.fcf_flag & FCF_REGISTERED) || | ||
5122 | !(phba->hba_flag & HBA_FIP_SUPPORT)) { | ||
5123 | spin_unlock_irq(&phba->hbalock); | ||
5124 | return; | ||
5125 | } | ||
5126 | spin_unlock_irq(&phba->hbalock); | ||
5127 | |||
5128 | if (lpfc_fcf_inuse(phba)) | ||
5129 | return; | ||
5130 | |||
5131 | lpfc_unregister_fcf_rescan(phba); | ||
4493 | } | 5132 | } |
4494 | 5133 | ||
4495 | /** | 5134 | /** |
@@ -4512,8 +5151,10 @@ lpfc_read_fcf_conn_tbl(struct lpfc_hba *phba, | |||
4512 | 5151 | ||
4513 | /* Free the current connect table */ | 5152 | /* Free the current connect table */ |
4514 | list_for_each_entry_safe(conn_entry, next_conn_entry, | 5153 | list_for_each_entry_safe(conn_entry, next_conn_entry, |
4515 | &phba->fcf_conn_rec_list, list) | 5154 | &phba->fcf_conn_rec_list, list) { |
5155 | list_del_init(&conn_entry->list); | ||
4516 | kfree(conn_entry); | 5156 | kfree(conn_entry); |
5157 | } | ||
4517 | 5158 | ||
4518 | conn_hdr = (struct lpfc_fcf_conn_hdr *) buff; | 5159 | conn_hdr = (struct lpfc_fcf_conn_hdr *) buff; |
4519 | record_count = conn_hdr->length * sizeof(uint32_t)/ | 5160 | record_count = conn_hdr->length * sizeof(uint32_t)/ |
@@ -4569,14 +5210,6 @@ lpfc_read_fcoe_param(struct lpfc_hba *phba, | |||
4569 | (fcoe_param_hdr->length != FCOE_PARAM_LENGTH)) | 5210 | (fcoe_param_hdr->length != FCOE_PARAM_LENGTH)) |
4570 | return; | 5211 | return; |
4571 | 5212 | ||
4572 | if (bf_get(lpfc_fip_param_hdr_fipp_mode, fcoe_param_hdr) == | ||
4573 | FIPP_MODE_ON) | ||
4574 | phba->cfg_enable_fip = 1; | ||
4575 | |||
4576 | if (bf_get(lpfc_fip_param_hdr_fipp_mode, fcoe_param_hdr) == | ||
4577 | FIPP_MODE_OFF) | ||
4578 | phba->cfg_enable_fip = 0; | ||
4579 | |||
4580 | if (fcoe_param_hdr->parm_flags & FIPP_VLAN_VALID) { | 5213 | if (fcoe_param_hdr->parm_flags & FIPP_VLAN_VALID) { |
4581 | phba->valid_vlan = 1; | 5214 | phba->valid_vlan = 1; |
4582 | phba->vlan_id = le16_to_cpu(fcoe_param->vlan_tag) & | 5215 | phba->vlan_id = le16_to_cpu(fcoe_param->vlan_tag) & |