[SCSI] lpfc 8.3.18: FC/FCoE Discovery fixes

FC/FCoE Discovery fixes:

- Call the lpfc_drain_txq only for SLI4 hba
- In lpfc_cmpl_els_fdisc, fix code path that does not free IOCB.
- Treated firmware matching FCF property with different index as error
- Propagate error returns from lpfc_issue_els_flogi()
- Refactored lpfc_unregister_unused_fcf() to create a post
lpfc_dev_loss_tmo handler call for SLI-4 devices. Allows checking of
fcf after last ndlp released so that fcf can be released if no longer
in use.
- Replaced individual FCF_XXXX_DISC flag clearing in lieu of aggregate
FCF_DISCOVERY flag upon succesful completion of flogi.
- Correct setting of altBbCredit value in sparams to correct issue with
logins with remote loop-based devices.

Signed-off-by: Alex Iannicelli <alex.iannicelli@emulex.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>

authored by

James Smart and committed by
James Bottomley
5ac6b303 32622bde

+58 -50
+11 -9
drivers/scsi/lpfc/lpfc_els.c
··· 523 523 spin_lock_irq(shost->host_lock); 524 524 vport->fc_flag |= FC_PUBLIC_LOOP; 525 525 spin_unlock_irq(shost->host_lock); 526 - } else { 527 - /* 528 - * If we are a N-port connected to a Fabric, fixup sparam's so 529 - * logins to devices on remote loops work. 530 - */ 531 - vport->fc_sparam.cmn.altBbCredit = 1; 532 526 } 533 527 534 528 vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; ··· 1169 1175 return 0; 1170 1176 } 1171 1177 1172 - if (lpfc_issue_els_flogi(vport, ndlp, 0)) 1178 + if (lpfc_issue_els_flogi(vport, ndlp, 0)) { 1173 1179 /* This decrement of reference count to node shall kick off 1174 1180 * the release of the node. 1175 1181 */ 1176 1182 lpfc_nlp_put(ndlp); 1177 - 1183 + return 0; 1184 + } 1178 1185 return 1; 1179 1186 } 1180 1187 ··· 1639 1644 pcmd += sizeof(uint32_t); 1640 1645 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); 1641 1646 sp = (struct serv_parm *) pcmd; 1647 + 1648 + /* 1649 + * If we are a N-port connected to a Fabric, fix-up paramm's so logins 1650 + * to device on remote loops work. 1651 + */ 1652 + if ((vport->fc_flag & FC_FABRIC) && !(vport->fc_flag & FC_PUBLIC_LOOP)) 1653 + sp->cmn.altBbCredit = 1; 1642 1654 1643 1655 if (sp->cmn.fcphLow < FC_PH_4_3) 1644 1656 sp->cmn.fcphLow = FC_PH_4_3; ··· 6454 6452 * to update the MAC address. 6455 6453 */ 6456 6454 lpfc_register_new_vport(phba, vport, ndlp); 6457 - return ; 6455 + goto out; 6458 6456 } 6459 6457 6460 6458 if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)
+42 -37
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 1803 1803 if ((phba->fcf.fcf_flag & FCF_IN_USE) && 1804 1804 lpfc_sli4_fcf_record_match(phba, &phba->fcf.current_rec, 1805 1805 new_fcf_record, LPFC_FCOE_IGNORE_VID)) { 1806 + if (bf_get(lpfc_fcf_record_fcf_index, new_fcf_record) != 1807 + phba->fcf.current_rec.fcf_indx) { 1808 + lpfc_printf_log(phba, KERN_ERR, LOG_FIP, 1809 + "2862 FCF (x%x) matches property " 1810 + "of in-use FCF (x%x)\n", 1811 + bf_get(lpfc_fcf_record_fcf_index, 1812 + new_fcf_record), 1813 + phba->fcf.current_rec.fcf_indx); 1814 + goto read_next_fcf; 1815 + } 1806 1816 /* 1807 1817 * In case the current in-use FCF record becomes 1808 1818 * invalid/unavailable during FCF discovery that ··· 1854 1844 if (phba->fcf.fcf_flag & FCF_IN_USE) { 1855 1845 if (lpfc_sli4_fcf_record_match(phba, &phba->fcf.current_rec, 1856 1846 new_fcf_record, vlan_id)) { 1857 - phba->fcf.fcf_flag |= FCF_AVAILABLE; 1858 - if (phba->fcf.fcf_flag & FCF_REDISC_PEND) 1859 - /* Stop FCF redisc wait timer if pending */ 1860 - __lpfc_sli4_stop_fcf_redisc_wait_timer(phba); 1861 - else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) 1862 - /* If in fast failover, mark it's completed */ 1863 - phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; 1864 - spin_unlock_irq(&phba->hbalock); 1865 - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, 1866 - "2836 The new FCF record (x%x) " 1867 - "matches the in-use FCF record " 1868 - "(x%x)\n", 1869 - phba->fcf.current_rec.fcf_indx, 1847 + if (bf_get(lpfc_fcf_record_fcf_index, new_fcf_record) == 1848 + phba->fcf.current_rec.fcf_indx) { 1849 + phba->fcf.fcf_flag |= FCF_AVAILABLE; 1850 + if (phba->fcf.fcf_flag & FCF_REDISC_PEND) 1851 + /* Stop FCF redisc wait timer */ 1852 + __lpfc_sli4_stop_fcf_redisc_wait_timer( 1853 + phba); 1854 + else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) 1855 + /* Fast failover, mark completed */ 1856 + phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; 1857 + spin_unlock_irq(&phba->hbalock); 1858 + lpfc_printf_log(phba, KERN_INFO, LOG_FIP, 1859 + "2836 New FCF matches in-use " 1860 + "FCF (x%x)\n", 1861 + phba->fcf.current_rec.fcf_indx); 1862 + goto out; 1863 + } else 1864 + lpfc_printf_log(phba, KERN_ERR, LOG_FIP, 1865 + "2863 New FCF (x%x) matches " 1866 + "property of in-use FCF (x%x)\n", 1870 1867 bf_get(lpfc_fcf_record_fcf_index, 1871 - new_fcf_record)); 1872 - goto out; 1868 + new_fcf_record), 1869 + phba->fcf.current_rec.fcf_indx); 1873 1870 } 1874 1871 /* 1875 1872 * Read next FCF record from HBA searching for the matching ··· 2086 2069 LPFC_FCOE_FCF_GET_FIRST); 2087 2070 return; 2088 2071 } 2089 - 2090 - /* 2091 - * Otherwise, initial scan or post linkdown rescan, 2092 - * register with the best FCF record found so far 2093 - * through the FCF scanning process. 2094 - */ 2095 - 2096 - /* 2097 - * Mark the initial FCF discovery completed and 2098 - * the start of the first round of the roundrobin 2099 - * FCF failover. 2100 - */ 2101 - spin_lock_irq(&phba->hbalock); 2102 - phba->fcf.fcf_flag &= 2103 - ~(FCF_INIT_DISC | FCF_REDISC_RRU); 2104 - spin_unlock_irq(&phba->hbalock); 2105 - /* 2106 - * Set up the initial registered FCF index for FLOGI 2107 - * round robin FCF failover 2108 - */ 2109 - phba->fcf.fcf_rr_init_indx = 2110 - phba->fcf.current_rec.fcf_indx; 2111 2072 /* Register to the new FCF record */ 2112 2073 lpfc_register_fcf(phba); 2113 2074 } ··· 3987 3992 } 3988 3993 3989 3994 spin_lock_irq(&phba->hbalock); 3995 + /* Cleanup REG_LOGIN completions which are not yet processed */ 3996 + list_for_each_entry(mb, &phba->sli.mboxq_cmpl, list) { 3997 + if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) || 3998 + (ndlp != (struct lpfc_nodelist *) mb->context2)) 3999 + continue; 4000 + 4001 + mb->context2 = NULL; 4002 + mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 4003 + } 4004 + 3990 4005 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { 3991 4006 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && 3992 4007 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
+5 -4
drivers/scsi/lpfc/lpfc_init.c
··· 2234 2234 void 2235 2235 __lpfc_sli4_stop_fcf_redisc_wait_timer(struct lpfc_hba *phba) 2236 2236 { 2237 - /* Clear pending FCF rediscovery wait and failover in progress flags */ 2238 - phba->fcf.fcf_flag &= ~(FCF_REDISC_PEND | 2239 - FCF_DEAD_DISC | 2240 - FCF_ACVL_DISC); 2237 + /* Clear pending FCF rediscovery wait flag */ 2238 + phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; 2239 + 2241 2240 /* Now, try to stop the timer */ 2242 2241 del_timer(&phba->fcf.redisc_wait); 2243 2242 } ··· 2260 2261 return; 2261 2262 } 2262 2263 __lpfc_sli4_stop_fcf_redisc_wait_timer(phba); 2264 + /* Clear failover in progress flags */ 2265 + phba->fcf.fcf_flag &= ~(FCF_DEAD_DISC | FCF_ACVL_DISC); 2263 2266 spin_unlock_irq(&phba->hbalock); 2264 2267 } 2265 2268