aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_hbadisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_hbadisc.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c222
1 files changed, 213 insertions, 9 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 18d0dbfda2bc..0b47adf9fee8 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1109,6 +1109,28 @@ out:
1109 return; 1109 return;
1110} 1110}
1111 1111
1112/**
1113 * lpfc_sli4_clear_fcf_rr_bmask
1114 * @phba pointer to the struct lpfc_hba for this port.
1115 * This fucnction resets the round robin bit mask and clears the
1116 * fcf priority list. The list deletions are done while holding the
1117 * hbalock. The ON_LIST flag and the FLOGI_FAILED flags are cleared
1118 * from the lpfc_fcf_pri record.
1119 **/
1120void
1121lpfc_sli4_clear_fcf_rr_bmask(struct lpfc_hba *phba)
1122{
1123 struct lpfc_fcf_pri *fcf_pri;
1124 struct lpfc_fcf_pri *next_fcf_pri;
1125 memset(phba->fcf.fcf_rr_bmask, 0, sizeof(*phba->fcf.fcf_rr_bmask));
1126 spin_lock_irq(&phba->hbalock);
1127 list_for_each_entry_safe(fcf_pri, next_fcf_pri,
1128 &phba->fcf.fcf_pri_list, list) {
1129 list_del_init(&fcf_pri->list);
1130 fcf_pri->fcf_rec.flag = 0;
1131 }
1132 spin_unlock_irq(&phba->hbalock);
1133}
1112static void 1134static void
1113lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) 1135lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
1114{ 1136{
@@ -1130,7 +1152,8 @@ lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
1130 spin_unlock_irq(&phba->hbalock); 1152 spin_unlock_irq(&phba->hbalock);
1131 1153
1132 /* If there is a pending FCoE event, restart FCF table scan. */ 1154 /* If there is a pending FCoE event, restart FCF table scan. */
1133 if (lpfc_check_pending_fcoe_event(phba, LPFC_UNREG_FCF)) 1155 if ((!(phba->hba_flag & FCF_RR_INPROG)) &&
1156 lpfc_check_pending_fcoe_event(phba, LPFC_UNREG_FCF))
1134 goto fail_out; 1157 goto fail_out;
1135 1158
1136 /* Mark successful completion of FCF table scan */ 1159 /* Mark successful completion of FCF table scan */
@@ -1250,6 +1273,30 @@ lpfc_vlan_id_match(uint16_t curr_vlan_id, uint16_t new_vlan_id)
1250} 1273}
1251 1274
1252/** 1275/**
1276 * lpfc_update_fcf_record - Update driver fcf record
1277 * __lpfc_update_fcf_record_pri - update the lpfc_fcf_pri record.
1278 * @phba: pointer to lpfc hba data structure.
1279 * @fcf_index: Index for the lpfc_fcf_record.
1280 * @new_fcf_record: pointer to hba fcf record.
1281 *
1282 * This routine updates the driver FCF priority record from the new HBA FCF
1283 * record. This routine is called with the host lock held.
1284 **/
1285static void
1286__lpfc_update_fcf_record_pri(struct lpfc_hba *phba, uint16_t fcf_index,
1287 struct fcf_record *new_fcf_record
1288 )
1289{
1290 struct lpfc_fcf_pri *fcf_pri;
1291
1292 fcf_pri = &phba->fcf.fcf_pri[fcf_index];
1293 fcf_pri->fcf_rec.fcf_index = fcf_index;
1294 /* FCF record priority */
1295 fcf_pri->fcf_rec.priority = new_fcf_record->fip_priority;
1296
1297}
1298
1299/**
1253 * lpfc_copy_fcf_record - Copy fcf information to lpfc_hba. 1300 * lpfc_copy_fcf_record - Copy fcf information to lpfc_hba.
1254 * @fcf: pointer to driver fcf record. 1301 * @fcf: pointer to driver fcf record.
1255 * @new_fcf_record: pointer to fcf record. 1302 * @new_fcf_record: pointer to fcf record.
@@ -1332,6 +1379,9 @@ __lpfc_update_fcf_record(struct lpfc_hba *phba, struct lpfc_fcf_rec *fcf_rec,
1332 fcf_rec->addr_mode = addr_mode; 1379 fcf_rec->addr_mode = addr_mode;
1333 fcf_rec->vlan_id = vlan_id; 1380 fcf_rec->vlan_id = vlan_id;
1334 fcf_rec->flag |= (flag | RECORD_VALID); 1381 fcf_rec->flag |= (flag | RECORD_VALID);
1382 __lpfc_update_fcf_record_pri(phba,
1383 bf_get(lpfc_fcf_record_fcf_index, new_fcf_record),
1384 new_fcf_record);
1335} 1385}
1336 1386
1337/** 1387/**
@@ -1834,6 +1884,8 @@ lpfc_sli4_fcf_record_match(struct lpfc_hba *phba,
1834 return false; 1884 return false;
1835 if (!lpfc_fab_name_match(fcf_rec->fabric_name, new_fcf_record)) 1885 if (!lpfc_fab_name_match(fcf_rec->fabric_name, new_fcf_record))
1836 return false; 1886 return false;
1887 if (fcf_rec->priority != new_fcf_record->fip_priority)
1888 return false;
1837 return true; 1889 return true;
1838} 1890}
1839 1891
@@ -1897,6 +1949,152 @@ stop_flogi_current_fcf:
1897} 1949}
1898 1950
1899/** 1951/**
1952 * lpfc_sli4_fcf_pri_list_del
1953 * @phba: pointer to lpfc hba data structure.
1954 * @fcf_index the index of the fcf record to delete
1955 * This routine checks the on list flag of the fcf_index to be deleted.
1956 * If it is one the list then it is removed from the list, and the flag
1957 * is cleared. This routine grab the hbalock before removing the fcf
1958 * record from the list.
1959 **/
1960static void lpfc_sli4_fcf_pri_list_del(struct lpfc_hba *phba,
1961 uint16_t fcf_index)
1962{
1963 struct lpfc_fcf_pri *new_fcf_pri;
1964
1965 new_fcf_pri = &phba->fcf.fcf_pri[fcf_index];
1966 lpfc_printf_log(phba, KERN_INFO, LOG_FIP,
1967 "3058 deleting idx x%x pri x%x flg x%x\n",
1968 fcf_index, new_fcf_pri->fcf_rec.priority,
1969 new_fcf_pri->fcf_rec.flag);
1970 spin_lock_irq(&phba->hbalock);
1971 if (new_fcf_pri->fcf_rec.flag & LPFC_FCF_ON_PRI_LIST) {
1972 if (phba->fcf.current_rec.priority ==
1973 new_fcf_pri->fcf_rec.priority)
1974 phba->fcf.eligible_fcf_cnt--;
1975 list_del_init(&new_fcf_pri->list);
1976 new_fcf_pri->fcf_rec.flag &= ~LPFC_FCF_ON_PRI_LIST;
1977 }
1978 spin_unlock_irq(&phba->hbalock);
1979}
1980
1981/**
1982 * lpfc_sli4_set_fcf_flogi_fail
1983 * @phba: pointer to lpfc hba data structure.
1984 * @fcf_index the index of the fcf record to update
1985 * This routine acquires the hbalock and then set the LPFC_FCF_FLOGI_FAILED
1986 * flag so the the round robin slection for the particular priority level
1987 * will try a different fcf record that does not have this bit set.
1988 * If the fcf record is re-read for any reason this flag is cleared brfore
1989 * adding it to the priority list.
1990 **/
1991void
1992lpfc_sli4_set_fcf_flogi_fail(struct lpfc_hba *phba, uint16_t fcf_index)
1993{
1994 struct lpfc_fcf_pri *new_fcf_pri;
1995 new_fcf_pri = &phba->fcf.fcf_pri[fcf_index];
1996 spin_lock_irq(&phba->hbalock);
1997 new_fcf_pri->fcf_rec.flag |= LPFC_FCF_FLOGI_FAILED;
1998 spin_unlock_irq(&phba->hbalock);
1999}
2000
2001/**
2002 * lpfc_sli4_fcf_pri_list_add
2003 * @phba: pointer to lpfc hba data structure.
2004 * @fcf_index the index of the fcf record to add
2005 * This routine checks the priority of the fcf_index to be added.
2006 * If it is a lower priority than the current head of the fcf_pri list
2007 * then it is added to the list in the right order.
2008 * If it is the same priority as the current head of the list then it
2009 * is added to the head of the list and its bit in the rr_bmask is set.
2010 * If the fcf_index to be added is of a higher priority than the current
2011 * head of the list then the rr_bmask is cleared, its bit is set in the
2012 * rr_bmask and it is added to the head of the list.
2013 * returns:
2014 * 0=success 1=failure
2015 **/
2016int lpfc_sli4_fcf_pri_list_add(struct lpfc_hba *phba, uint16_t fcf_index,
2017 struct fcf_record *new_fcf_record)
2018{
2019 uint16_t current_fcf_pri;
2020 uint16_t last_index;
2021 struct lpfc_fcf_pri *fcf_pri;
2022 struct lpfc_fcf_pri *next_fcf_pri;
2023 struct lpfc_fcf_pri *new_fcf_pri;
2024 int ret;
2025
2026 new_fcf_pri = &phba->fcf.fcf_pri[fcf_index];
2027 lpfc_printf_log(phba, KERN_INFO, LOG_FIP,
2028 "3059 adding idx x%x pri x%x flg x%x\n",
2029 fcf_index, new_fcf_record->fip_priority,
2030 new_fcf_pri->fcf_rec.flag);
2031 spin_lock_irq(&phba->hbalock);
2032 if (new_fcf_pri->fcf_rec.flag & LPFC_FCF_ON_PRI_LIST)
2033 list_del_init(&new_fcf_pri->list);
2034 new_fcf_pri->fcf_rec.fcf_index = fcf_index;
2035 new_fcf_pri->fcf_rec.priority = new_fcf_record->fip_priority;
2036 if (list_empty(&phba->fcf.fcf_pri_list)) {
2037 list_add(&new_fcf_pri->list, &phba->fcf.fcf_pri_list);
2038 ret = lpfc_sli4_fcf_rr_index_set(phba,
2039 new_fcf_pri->fcf_rec.fcf_index);
2040 goto out;
2041 }
2042
2043 last_index = find_first_bit(phba->fcf.fcf_rr_bmask,
2044 LPFC_SLI4_FCF_TBL_INDX_MAX);
2045 if (last_index >= LPFC_SLI4_FCF_TBL_INDX_MAX) {
2046 ret = 0; /* Empty rr list */
2047 goto out;
2048 }
2049 current_fcf_pri = phba->fcf.fcf_pri[last_index].fcf_rec.priority;
2050 if (new_fcf_pri->fcf_rec.priority <= current_fcf_pri) {
2051 list_add(&new_fcf_pri->list, &phba->fcf.fcf_pri_list);
2052 if (new_fcf_pri->fcf_rec.priority < current_fcf_pri) {
2053 memset(phba->fcf.fcf_rr_bmask, 0,
2054 sizeof(*phba->fcf.fcf_rr_bmask));
2055 /* fcfs_at_this_priority_level = 1; */
2056 phba->fcf.eligible_fcf_cnt = 1;
2057 } else
2058 /* fcfs_at_this_priority_level++; */
2059 phba->fcf.eligible_fcf_cnt++;
2060 ret = lpfc_sli4_fcf_rr_index_set(phba,
2061 new_fcf_pri->fcf_rec.fcf_index);
2062 goto out;
2063 }
2064
2065 list_for_each_entry_safe(fcf_pri, next_fcf_pri,
2066 &phba->fcf.fcf_pri_list, list) {
2067 if (new_fcf_pri->fcf_rec.priority <=
2068 fcf_pri->fcf_rec.priority) {
2069 if (fcf_pri->list.prev == &phba->fcf.fcf_pri_list)
2070 list_add(&new_fcf_pri->list,
2071 &phba->fcf.fcf_pri_list);
2072 else
2073 list_add(&new_fcf_pri->list,
2074 &((struct lpfc_fcf_pri *)
2075 fcf_pri->list.prev)->list);
2076 ret = 0;
2077 goto out;
2078 } else if (fcf_pri->list.next == &phba->fcf.fcf_pri_list
2079 || new_fcf_pri->fcf_rec.priority <
2080 next_fcf_pri->fcf_rec.priority) {
2081 list_add(&new_fcf_pri->list, &fcf_pri->list);
2082 ret = 0;
2083 goto out;
2084 }
2085 if (new_fcf_pri->fcf_rec.priority > fcf_pri->fcf_rec.priority)
2086 continue;
2087
2088 }
2089 ret = 1;
2090out:
2091 /* we use = instead of |= to clear the FLOGI_FAILED flag. */
2092 new_fcf_pri->fcf_rec.flag = LPFC_FCF_ON_PRI_LIST;
2093 spin_unlock_irq(&phba->hbalock);
2094 return ret;
2095}
2096
2097/**
1900 * lpfc_mbx_cmpl_fcf_scan_read_fcf_rec - fcf scan read_fcf mbox cmpl handler. 2098 * lpfc_mbx_cmpl_fcf_scan_read_fcf_rec - fcf scan read_fcf mbox cmpl handler.
1901 * @phba: pointer to lpfc hba data structure. 2099 * @phba: pointer to lpfc hba data structure.
1902 * @mboxq: pointer to mailbox object. 2100 * @mboxq: pointer to mailbox object.
@@ -1958,6 +2156,9 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
1958 * record for roundrobin FCF failover. 2156 * record for roundrobin FCF failover.
1959 */ 2157 */
1960 if (!rc) { 2158 if (!rc) {
2159 lpfc_sli4_fcf_pri_list_del(phba,
2160 bf_get(lpfc_fcf_record_fcf_index,
2161 new_fcf_record));
1961 lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, 2162 lpfc_printf_log(phba, KERN_WARNING, LOG_FIP,
1962 "2781 FCF (x%x) failed connection " 2163 "2781 FCF (x%x) failed connection "
1963 "list check: (x%x/x%x)\n", 2164 "list check: (x%x/x%x)\n",
@@ -2005,7 +2206,8 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2005 goto read_next_fcf; 2206 goto read_next_fcf;
2006 } else { 2207 } else {
2007 fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); 2208 fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record);
2008 rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); 2209 rc = lpfc_sli4_fcf_pri_list_add(phba, fcf_index,
2210 new_fcf_record);
2009 if (rc) 2211 if (rc)
2010 goto read_next_fcf; 2212 goto read_next_fcf;
2011 } 2213 }
@@ -2018,7 +2220,8 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2018 */ 2220 */
2019 spin_lock_irq(&phba->hbalock); 2221 spin_lock_irq(&phba->hbalock);
2020 if (phba->fcf.fcf_flag & FCF_IN_USE) { 2222 if (phba->fcf.fcf_flag & FCF_IN_USE) {
2021 if (lpfc_sli4_fcf_record_match(phba, &phba->fcf.current_rec, 2223 if (phba->cfg_fcf_failover_policy == LPFC_FCF_FOV &&
2224 lpfc_sli4_fcf_record_match(phba, &phba->fcf.current_rec,
2022 new_fcf_record, vlan_id)) { 2225 new_fcf_record, vlan_id)) {
2023 if (bf_get(lpfc_fcf_record_fcf_index, new_fcf_record) == 2226 if (bf_get(lpfc_fcf_record_fcf_index, new_fcf_record) ==
2024 phba->fcf.current_rec.fcf_indx) { 2227 phba->fcf.current_rec.fcf_indx) {
@@ -2232,7 +2435,8 @@ read_next_fcf:
2232 (phba->fcf.fcf_flag & FCF_REDISC_PEND)) 2435 (phba->fcf.fcf_flag & FCF_REDISC_PEND))
2233 return; 2436 return;
2234 2437
2235 if (phba->fcf.fcf_flag & FCF_IN_USE) { 2438 if (phba->cfg_fcf_failover_policy == LPFC_FCF_FOV &&
2439 phba->fcf.fcf_flag & FCF_IN_USE) {
2236 /* 2440 /*
2237 * In case the current in-use FCF record no 2441 * In case the current in-use FCF record no
2238 * longer existed during FCF discovery that 2442 * longer existed during FCF discovery that
@@ -2247,7 +2451,6 @@ read_next_fcf:
2247 spin_lock_irq(&phba->hbalock); 2451 spin_lock_irq(&phba->hbalock);
2248 phba->fcf.fcf_flag |= FCF_REDISC_FOV; 2452 phba->fcf.fcf_flag |= FCF_REDISC_FOV;
2249 spin_unlock_irq(&phba->hbalock); 2453 spin_unlock_irq(&phba->hbalock);
2250 lpfc_sli4_mbox_cmd_free(phba, mboxq);
2251 lpfc_sli4_fcf_scan_read_fcf_rec(phba, 2454 lpfc_sli4_fcf_scan_read_fcf_rec(phba,
2252 LPFC_FCOE_FCF_GET_FIRST); 2455 LPFC_FCOE_FCF_GET_FIRST);
2253 return; 2456 return;
@@ -2424,7 +2627,8 @@ lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2424 2627
2425 /* Update the eligible FCF record index bmask */ 2628 /* Update the eligible FCF record index bmask */
2426 fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); 2629 fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record);
2427 rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); 2630
2631 rc = lpfc_sli4_fcf_pri_list_add(phba, fcf_index, new_fcf_record);
2428 2632
2429out: 2633out:
2430 lpfc_sli4_mbox_cmd_free(phba, mboxq); 2634 lpfc_sli4_mbox_cmd_free(phba, mboxq);
@@ -2645,6 +2849,7 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2645 vport->vpi_state |= LPFC_VPI_REGISTERED; 2849 vport->vpi_state |= LPFC_VPI_REGISTERED;
2646 vport->fc_flag |= FC_VFI_REGISTERED; 2850 vport->fc_flag |= FC_VFI_REGISTERED;
2647 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 2851 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
2852 vport->fc_flag &= ~FC_VPORT_NEEDS_INIT_VPI;
2648 spin_unlock_irq(shost->host_lock); 2853 spin_unlock_irq(shost->host_lock);
2649 2854
2650 if (vport->port_state == LPFC_FABRIC_CFG_LINK) { 2855 if (vport->port_state == LPFC_FABRIC_CFG_LINK) {
@@ -2893,8 +3098,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la)
2893 goto out; 3098 goto out;
2894 } 3099 }
2895 /* Reset FCF roundrobin bmask for new discovery */ 3100 /* Reset FCF roundrobin bmask for new discovery */
2896 memset(phba->fcf.fcf_rr_bmask, 0, 3101 lpfc_sli4_clear_fcf_rr_bmask(phba);
2897 sizeof(*phba->fcf.fcf_rr_bmask));
2898 } 3102 }
2899 3103
2900 return; 3104 return;
@@ -5592,7 +5796,7 @@ lpfc_unregister_fcf_rescan(struct lpfc_hba *phba)
5592 spin_unlock_irq(&phba->hbalock); 5796 spin_unlock_irq(&phba->hbalock);
5593 5797
5594 /* Reset FCF roundrobin bmask for new discovery */ 5798 /* Reset FCF roundrobin bmask for new discovery */
5595 memset(phba->fcf.fcf_rr_bmask, 0, sizeof(*phba->fcf.fcf_rr_bmask)); 5799 lpfc_sli4_clear_fcf_rr_bmask(phba);
5596 5800
5597 rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); 5801 rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST);
5598 5802