Skip to content

Commit 8cc2956

Browse files
Ivan Vecerakuba-moo
authored andcommitted
i40e: Initialize hardware capabilities at single place
Some i40e_hw.caps bits are set in i40e_set_hw_caps(), some of them in i40e_init_adminq() and the rest of them in i40e_sw_init(). Consolidate the initialization to single proper place i40e_set_hw_caps(). Signed-off-by: Ivan Vecera <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0e8b9fd commit 8cc2956

File tree

4 files changed

+51
-72
lines changed

4 files changed

+51
-72
lines changed

drivers/net/ethernet/intel/i40e/i40e_adminq.c

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,52 @@ static void i40e_set_hw_caps(struct i40e_hw *hw)
522522
/* The ability to RX (not drop) 802.1ad frames */
523523
set_bit(I40E_HW_CAP_802_1AD, hw->caps);
524524
}
525+
if ((aq->api_maj_ver == 1 && aq->api_min_ver > 4) ||
526+
aq->api_maj_ver > 1) {
527+
/* Supported in FW API version higher than 1.4 */
528+
set_bit(I40E_HW_CAP_GENEVE_OFFLOAD, hw->caps);
529+
}
530+
if ((aq->fw_maj_ver == 4 && aq->fw_min_ver < 33) ||
531+
aq->fw_maj_ver < 4) {
532+
set_bit(I40E_HW_CAP_RESTART_AUTONEG, hw->caps);
533+
/* No DCB support for FW < v4.33 */
534+
set_bit(I40E_HW_CAP_NO_DCB_SUPPORT, hw->caps);
535+
}
536+
if ((aq->fw_maj_ver == 4 && aq->fw_min_ver < 3) ||
537+
aq->fw_maj_ver < 4) {
538+
/* Disable FW LLDP if FW < v4.3 */
539+
set_bit(I40E_HW_CAP_STOP_FW_LLDP, hw->caps);
540+
}
541+
if ((aq->fw_maj_ver == 4 && aq->fw_min_ver >= 40) ||
542+
aq->fw_maj_ver >= 5) {
543+
/* Use the FW Set LLDP MIB API if FW > v4.40 */
544+
set_bit(I40E_HW_CAP_USE_SET_LLDP_MIB, hw->caps);
545+
}
546+
if (aq->fw_maj_ver >= 6) {
547+
/* Enable PTP L4 if FW > v6.0 */
548+
set_bit(I40E_HW_CAP_PTP_L4, hw->caps);
549+
}
525550
break;
526551
case I40E_MAC_X722:
527552
set_bit(I40E_HW_CAP_AQ_SRCTL_ACCESS_ENABLE, hw->caps);
528553
set_bit(I40E_HW_CAP_NVM_READ_REQUIRES_LOCK, hw->caps);
554+
set_bit(I40E_HW_CAP_RSS_AQ, hw->caps);
555+
set_bit(I40E_HW_CAP_128_QP_RSS, hw->caps);
556+
set_bit(I40E_HW_CAP_ATR_EVICT, hw->caps);
557+
set_bit(I40E_HW_CAP_WB_ON_ITR, hw->caps);
558+
set_bit(I40E_HW_CAP_MULTI_TCP_UDP_RSS_PCTYPE, hw->caps);
559+
set_bit(I40E_HW_CAP_NO_PCI_LINK_CHECK, hw->caps);
560+
set_bit(I40E_HW_CAP_USE_SET_LLDP_MIB, hw->caps);
561+
set_bit(I40E_HW_CAP_GENEVE_OFFLOAD, hw->caps);
562+
set_bit(I40E_HW_CAP_PTP_L4, hw->caps);
563+
set_bit(I40E_HW_CAP_WOL_MC_MAGIC_PKT_WAKE, hw->caps);
564+
set_bit(I40E_HW_CAP_OUTER_UDP_CSUM, hw->caps);
565+
566+
if (rd32(hw, I40E_GLQF_FDEVICTENA(1)) !=
567+
I40E_FDEVICT_PCTYPE_DEFAULT) {
568+
hw_warn(hw, "FD EVICT PCTYPES are not right, disable FD HW EVICT\n");
569+
clear_bit(I40E_HW_CAP_ATR_EVICT, hw->caps);
570+
}
529571

530572
if (aq->api_maj_ver > 1 ||
531573
(aq->api_maj_ver == 1 &&
@@ -553,6 +595,12 @@ static void i40e_set_hw_caps(struct i40e_hw *hw)
553595
aq->api_min_ver >= 5))
554596
set_bit(I40E_HW_CAP_NVM_READ_REQUIRES_LOCK, hw->caps);
555597

598+
/* The ability to RX (not drop) 802.1ad frames was added in API 1.7 */
599+
if (aq->api_maj_ver > 1 ||
600+
(aq->api_maj_ver == 1 &&
601+
aq->api_min_ver >= 7))
602+
set_bit(I40E_HW_CAP_802_1AD, hw->caps);
603+
556604
if (aq->api_maj_ver > 1 ||
557605
(aq->api_maj_ver == 1 &&
558606
aq->api_min_ver >= 8))
@@ -646,24 +694,6 @@ int i40e_init_adminq(struct i40e_hw *hw)
646694
&oem_lo);
647695
hw->nvm.oem_ver = ((u32)oem_hi << 16) | oem_lo;
648696

649-
if (hw->mac.type == I40E_MAC_XL710 &&
650-
hw->aq.api_maj_ver == I40E_FW_API_VERSION_MAJOR &&
651-
hw->aq.api_min_ver >= I40E_MINOR_VER_GET_LINK_INFO_XL710) {
652-
set_bit(I40E_HW_CAP_AQ_PHY_ACCESS, hw->caps);
653-
set_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, hw->caps);
654-
}
655-
if (hw->mac.type == I40E_MAC_X722 &&
656-
hw->aq.api_maj_ver == I40E_FW_API_VERSION_MAJOR &&
657-
hw->aq.api_min_ver >= I40E_MINOR_VER_FW_LLDP_STOPPABLE_X722) {
658-
set_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, hw->caps);
659-
}
660-
661-
/* The ability to RX (not drop) 802.1ad frames was added in API 1.7 */
662-
if (hw->aq.api_maj_ver > 1 ||
663-
(hw->aq.api_maj_ver == 1 &&
664-
hw->aq.api_min_ver >= 7))
665-
set_bit(I40E_HW_CAP_802_1AD, hw->caps);
666-
667697
if (hw->aq.api_maj_ver > I40E_FW_API_VERSION_MAJOR) {
668698
ret_code = -EIO;
669699
goto init_adminq_free_arq;

drivers/net/ethernet/intel/i40e/i40e_debug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct i40e_hw;
3737
struct device *i40e_hw_to_dev(struct i40e_hw *hw);
3838

3939
#define hw_dbg(hw, S, A...) dev_dbg(i40e_hw_to_dev(hw), S, ##A)
40+
#define hw_warn(hw, S, A...) dev_warn(i40e_hw_to_dev(hw), S, ##A)
4041

4142
#define i40e_debug(h, m, s, ...) \
4243
do { \

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12782,62 +12782,10 @@ static int i40e_sw_init(struct i40e_pf *pf)
1278212782
pf->hw.func_caps.fd_filters_best_effort;
1278312783
}
1278412784

12785-
if (pf->hw.mac.type == I40E_MAC_X722) {
12786-
set_bit(I40E_HW_CAP_RSS_AQ, pf->hw.caps);
12787-
set_bit(I40E_HW_CAP_128_QP_RSS, pf->hw.caps);
12788-
set_bit(I40E_HW_CAP_ATR_EVICT, pf->hw.caps);
12789-
set_bit(I40E_HW_CAP_WB_ON_ITR, pf->hw.caps);
12790-
set_bit(I40E_HW_CAP_MULTI_TCP_UDP_RSS_PCTYPE, pf->hw.caps);
12791-
set_bit(I40E_HW_CAP_NO_PCI_LINK_CHECK, pf->hw.caps);
12792-
set_bit(I40E_HW_CAP_USE_SET_LLDP_MIB, pf->hw.caps);
12793-
set_bit(I40E_HW_CAP_GENEVE_OFFLOAD, pf->hw.caps);
12794-
set_bit(I40E_HW_CAP_PTP_L4, pf->hw.caps);
12795-
set_bit(I40E_HW_CAP_WOL_MC_MAGIC_PKT_WAKE, pf->hw.caps);
12796-
set_bit(I40E_HW_CAP_OUTER_UDP_CSUM, pf->hw.caps);
12797-
12798-
#define I40E_FDEVICT_PCTYPE_DEFAULT 0xc03
12799-
if (rd32(&pf->hw, I40E_GLQF_FDEVICTENA(1)) !=
12800-
I40E_FDEVICT_PCTYPE_DEFAULT) {
12801-
dev_warn(&pf->pdev->dev,
12802-
"FD EVICT PCTYPES are not right, disable FD HW EVICT\n");
12803-
clear_bit(I40E_HW_CAP_ATR_EVICT, pf->hw.caps);
12804-
}
12805-
} else if ((pf->hw.aq.api_maj_ver > 1) ||
12806-
((pf->hw.aq.api_maj_ver == 1) &&
12807-
(pf->hw.aq.api_min_ver > 4))) {
12808-
/* Supported in FW API version higher than 1.4 */
12809-
set_bit(I40E_HW_CAP_GENEVE_OFFLOAD, pf->hw.caps);
12810-
}
12811-
1281212785
/* Enable HW ATR eviction if possible */
1281312786
if (test_bit(I40E_HW_CAP_ATR_EVICT, pf->hw.caps))
1281412787
set_bit(I40E_FLAG_HW_ATR_EVICT_ENA, pf->flags);
1281512788

12816-
if ((pf->hw.mac.type == I40E_MAC_XL710) &&
12817-
(((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver < 33)) ||
12818-
(pf->hw.aq.fw_maj_ver < 4))) {
12819-
set_bit(I40E_HW_CAP_RESTART_AUTONEG, pf->hw.caps);
12820-
/* No DCB support for FW < v4.33 */
12821-
set_bit(I40E_HW_CAP_NO_DCB_SUPPORT, pf->hw.caps);
12822-
}
12823-
12824-
/* Disable FW LLDP if FW < v4.3 */
12825-
if ((pf->hw.mac.type == I40E_MAC_XL710) &&
12826-
(((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver < 3)) ||
12827-
(pf->hw.aq.fw_maj_ver < 4)))
12828-
set_bit(I40E_HW_CAP_STOP_FW_LLDP, pf->hw.caps);
12829-
12830-
/* Use the FW Set LLDP MIB API if FW > v4.40 */
12831-
if ((pf->hw.mac.type == I40E_MAC_XL710) &&
12832-
(((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver >= 40)) ||
12833-
(pf->hw.aq.fw_maj_ver >= 5)))
12834-
set_bit(I40E_HW_CAP_USE_SET_LLDP_MIB, pf->hw.caps);
12835-
12836-
/* Enable PTP L4 if FW > v6.0 */
12837-
if (pf->hw.mac.type == I40E_MAC_XL710 &&
12838-
pf->hw.aq.fw_maj_ver >= 6)
12839-
set_bit(I40E_HW_CAP_PTP_L4, pf->hw.caps);
12840-
1284112789
if (pf->hw.func_caps.vmdq && num_online_cpus() != 1) {
1284212790
pf->num_vmdq_vsis = I40E_DEFAULT_NUM_VMDQ_VSI;
1284312791
set_bit(I40E_FLAG_VMDQ_ENA, pf->flags);
@@ -12855,8 +12803,7 @@ static int i40e_sw_init(struct i40e_pf *pf)
1285512803
* if NPAR is functioning so unset this hw flag in this case.
1285612804
*/
1285712805
if (pf->hw.mac.type == I40E_MAC_XL710 &&
12858-
pf->hw.func_caps.npar_enable &&
12859-
test_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, pf->hw.caps))
12806+
pf->hw.func_caps.npar_enable)
1286012807
clear_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, pf->hw.caps);
1286112808

1286212809
#ifdef CONFIG_PCI_IOV

drivers/net/ethernet/intel/i40e/i40e_register.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@
899899
#define I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT 7
900900
#define I40E_GLQF_ORT_FLX_PAYLOAD_MASK I40E_MASK(0x1, I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT)
901901
#define I40E_GLQF_FDEVICTENA(_i) (0x00270384 + ((_i) * 4)) /* _i=0...1 */ /* Reset: CORER */
902+
#define I40E_FDEVICT_PCTYPE_DEFAULT 0xc03
902903
/* Redefined for X722 family */
903904
#define I40E_GLGEN_STAT_CLEAR 0x00390004 /* Reset: CORER */
904905
#endif /* _I40E_REGISTER_H_ */

0 commit comments

Comments
 (0)