Skip to content

Commit f74bb72

Browse files
herrerogNipaLocal
authored andcommitted
i40e: validate ring_len parameter against hardware-specific values
The maximum number of descriptors supported by the hardware is hardware-dependent and can be retrieved using i40e_get_max_num_descriptors(). Move this function to a shared header and use it when checking for valid ring_len parameter rather than using hardcoded value. By fixing an over-acceptance issue, behavior change could be seen where ring_len could now be rejected while configuring rx and tx queues if its size is larger than the hardware-dependent maximum number of descriptors. Fixes: 55d2256 ("i40e: add validation for ring_len param") Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Reviewed-by: Brett Creeley <brett.creeley@amd.com> Signed-off-by: NipaLocal <nipa@local>
1 parent 732238c commit f74bb72

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,4 +1422,15 @@ static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf)
14221422
return (pf->lan_veb != I40E_NO_VEB) ? pf->veb[pf->lan_veb] : NULL;
14231423
}
14241424

1425+
static inline u32 i40e_get_max_num_descriptors(const struct i40e_pf *pf)
1426+
{
1427+
const struct i40e_hw *hw = &pf->hw;
1428+
1429+
switch (hw->mac.type) {
1430+
case I40E_MAC_XL710:
1431+
return I40E_MAX_NUM_DESCRIPTORS_XL710;
1432+
default:
1433+
return I40E_MAX_NUM_DESCRIPTORS;
1434+
}
1435+
}
14251436
#endif /* _I40E_H_ */

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,18 +2013,6 @@ static void i40e_get_drvinfo(struct net_device *netdev,
20132013
drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN;
20142014
}
20152015

2016-
static u32 i40e_get_max_num_descriptors(struct i40e_pf *pf)
2017-
{
2018-
struct i40e_hw *hw = &pf->hw;
2019-
2020-
switch (hw->mac.type) {
2021-
case I40E_MAC_XL710:
2022-
return I40E_MAX_NUM_DESCRIPTORS_XL710;
2023-
default:
2024-
return I40E_MAX_NUM_DESCRIPTORS;
2025-
}
2026-
}
2027-
20282016
static void i40e_get_ringparam(struct net_device *netdev,
20292017
struct ethtool_ringparam *ring,
20302018
struct kernel_ethtool_ringparam *kernel_ring,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_id,
656656

657657
/* ring_len has to be multiple of 8 */
658658
if (!IS_ALIGNED(info->ring_len, 8) ||
659-
info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) {
659+
info->ring_len > i40e_get_max_num_descriptors(pf)) {
660660
ret = -EINVAL;
661661
goto error_context;
662662
}
@@ -726,7 +726,7 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id,
726726

727727
/* ring_len has to be multiple of 32 */
728728
if (!IS_ALIGNED(info->ring_len, 32) ||
729-
info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) {
729+
info->ring_len > i40e_get_max_num_descriptors(pf)) {
730730
ret = -EINVAL;
731731
goto error_param;
732732
}

0 commit comments

Comments
 (0)