]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
i40e: validate ring_len parameter against hardware-specific values
authorGregory Herrero <gregory.herrero@oracle.com>
Fri, 12 Dec 2025 21:06:43 +0000 (22:06 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:55 +0000 (13:09 +0100)
[ Upstream commit 69942834215323cd9131db557091b4dec43f19c5 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/i40e/i40e.h
drivers/net/ethernet/intel/i40e/i40e_ethtool.c
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

index bbd95b3d73263a0b7ca3b2d2e3440f061a0009e6..022bf6e86164a208bfda399a2218ea0d12786f2c 100644 (file)
@@ -1305,4 +1305,15 @@ static inline u32 i40e_is_tc_mqprio_enabled(struct i40e_pf *pf)
        return pf->flags & I40E_FLAG_TC_MQPRIO;
 }
 
+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_ */
index 74a18b8df11f65d59a5053b85176d18c35e3ce3c..04d304eef3797da3163946384a7e9e2976fa70e5 100644 (file)
@@ -1918,18 +1918,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)
 {
index 5cd7a2bc40fd08692c770e0ded0c9097eccbe87d..907727604c702efc85dc9ded26b55391cb2d1024 100644 (file)
@@ -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;
        }
@@ -728,7 +728,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;
        }