mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-11 17:10:13 +00:00
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: 55d225670def ("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>
This commit is contained in:
parent
be43abc551
commit
6994283421
@ -1422,4 +1422,15 @@ static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf)
|
||||
return (pf->lan_veb != I40E_NO_VEB) ? pf->veb[pf->lan_veb] : NULL;
|
||||
}
|
||||
|
||||
static inline u32 i40e_get_max_num_descriptors(const struct i40e_pf *pf)
|
||||
{
|
||||
const struct i40e_hw *hw = &pf->hw;
|
||||
|
||||
switch (hw->mac.type) {
|
||||
case I40E_MAC_XL710:
|
||||
return I40E_MAX_NUM_DESCRIPTORS_XL710;
|
||||
default:
|
||||
return I40E_MAX_NUM_DESCRIPTORS;
|
||||
}
|
||||
}
|
||||
#endif /* _I40E_H_ */
|
||||
|
||||
@ -2013,18 +2013,6 @@ static void i40e_get_drvinfo(struct net_device *netdev,
|
||||
drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN;
|
||||
}
|
||||
|
||||
static u32 i40e_get_max_num_descriptors(struct i40e_pf *pf)
|
||||
{
|
||||
struct i40e_hw *hw = &pf->hw;
|
||||
|
||||
switch (hw->mac.type) {
|
||||
case I40E_MAC_XL710:
|
||||
return I40E_MAX_NUM_DESCRIPTORS_XL710;
|
||||
default:
|
||||
return I40E_MAX_NUM_DESCRIPTORS;
|
||||
}
|
||||
}
|
||||
|
||||
static void i40e_get_ringparam(struct net_device *netdev,
|
||||
struct ethtool_ringparam *ring,
|
||||
struct kernel_ethtool_ringparam *kernel_ring,
|
||||
|
||||
@ -656,7 +656,7 @@ static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_id,
|
||||
|
||||
/* ring_len has to be multiple of 8 */
|
||||
if (!IS_ALIGNED(info->ring_len, 8) ||
|
||||
info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) {
|
||||
info->ring_len > i40e_get_max_num_descriptors(pf)) {
|
||||
ret = -EINVAL;
|
||||
goto error_context;
|
||||
}
|
||||
@ -726,7 +726,7 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id,
|
||||
|
||||
/* ring_len has to be multiple of 32 */
|
||||
if (!IS_ALIGNED(info->ring_len, 32) ||
|
||||
info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) {
|
||||
info->ring_len > i40e_get_max_num_descriptors(pf)) {
|
||||
ret = -EINVAL;
|
||||
goto error_param;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user