Skip to contentSkip to conversation

i40e: additional safety check

PATCH Superseded [email protected] 4 participants 8 messages Nov 17, 2025 – Dec 12, 2025

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover i40e: additional safety check

From: Gregory Herrero <[email protected]>

On code inspection, I realized we may want to check ring_len parameter against hardware specific values in i40e_config_vsi_tx_queue() and i40e_config_vsi_rx_queue().

v4:
- remove u32 cast in i40e_config_vsi_tx_queue() too and don't mention it anymore in commit description.
- wrap i40e_get_max_num_descriptors() description
v3:
- drop trailing period from the subject
- reword commit description
- remove u32 cast in i40e_config_vsi_rx_queue()
v2:
- make i40e_get_max_num_descriptors() 'pf' argument const.
- reword i40e_get_max_num_descriptors() description.
- modify commit description to explain potential behavior change.

Gregory Herrero (1):
i40e: validate ring_len parameter against hardware-specific values

 drivers/net/ethernet/intel/i40e/i40e.h         | 18 ++++++++++++++++++
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ------------
 .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  4 ++--
 3 files changed, 20 insertions(+), 14 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v4 1/1 i40e: validate ring_len parameter against hardware-specific values

From: Gregory Herrero <[email protected]>

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-specific maximum number of descriptors.

Fixes 55d225670def ("i40e: add validation for ring_len param")
---
 drivers/net/ethernet/intel/i40e/i40e.h         | 18 ++++++++++++++++++
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ------------
 .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  4 ++--
 3 files changed, 20 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +18 -0
index 801a57a925da..5b367397ae43 100644
@@ -1418,4 +1418,22 @@ 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;
 }
 
+/**
+ * i40e_get_max_num_descriptors - get maximum number of descriptors for this
+ * hardware.
+ * @pf: pointer to a PF
+ *
+ * Return: u32 value corresponding to the maximum number of descriptors.
+ **/
+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_ */
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +0 -12
index 86c72596617a..61c39e881b00 100644
@@ -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,
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +2 -2
index 081a4526a2f0..cf831c649c9c 100644
@@ -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;
 	}
Signature · 1 line
2.51.0
#2 lore raw

RE: [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

Quoted 15 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, November 17, 2025 9:33 AM
To: Loktionov, Aleksandr <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; Gregory Herrero <[email protected]>
Subject: [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

Quoted 4 lines

From: Gregory Herrero <[email protected]>

The maximum number of descriptors supported by the hardware is hardware dependent and can be retrieved using

First paragraph uses “hardware dependent” (no hyphen) while later text uses “hardware‑specific” (hyphenated). Prefer “hardware‑dependent” for consistency.

Quoted 9 lines

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-specific maximum number of descriptors.

The message explains the behavioral change but does not state how the change was tested
(e.g., which MAC types exercised, ethtool -G paths, VF configuration via virtchnl, acceptance/rejection boundaries). Netdev routinely asks for this when behavior changes.

Quoted 18 lines
Fixes 55d225670def ("i40e: add validation for ring_len param")
---
 drivers/net/ethernet/intel/i40e/i40e.h         | 18
++++++++++++++++++
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ------------
.../net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  4 ++--
 3 files changed, 20 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +0 -0
index 801a57a925da..5b367397ae43 100644
@@ -1418,4 +1418,22 @@ 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;  }

...

Quoted 2 lines

--
2.51.0

#3 lore raw

RE: [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

Quoted 60 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Loktionov, Aleksandr
Sent: Monday, November 17, 2025 12:59
To: [email protected]; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [Intel-wired-lan] [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

Quoted 13 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, November 17, 2025 9:33 AM
To: Loktionov, Aleksandr <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; Gregory Herrero <[email protected]>
Subject: [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

Quoted 4 lines

From: Gregory Herrero <[email protected]>

The maximum number of descriptors supported by the hardware is hardware dependent and can be retrieved using

First paragraph uses “hardware dependent” (no hyphen) while later text uses “hardware‑specific” (hyphenated).
Prefer “hardware‑dependent” for consistency.

Quoted 9 lines

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-specific maximum number of descriptors.

The message explains the behavioral change but does not state how the change was tested (e.g., which MAC types exercised, ethtool -G paths, VF configuration via virtchnl, acceptance/rejection boundaries).
Netdev routinely asks for this when behavior changes.

Quoted 9 lines
Fixes 55d225670def ("i40e: add validation for ring_len param")
---
 drivers/net/ethernet/intel/i40e/i40e.h         | 18
++++++++++++++++++
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ------------
.../net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  4 ++--
 3 files changed, 20 insertions(+), 14 deletions(-)
Quoted 14 lines
Quoted 9 lines
drivers/net/ethernet/intel/i40e/i40e.h +0 -0
index 801a57a925da..5b367397ae43 100644
@@ -1418,4 +1418,22 @@ 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;  }

...

Quoted 2 lines

--
2.51.0

author Tested-by Rafal Romanowski
#4 lore raw

Re: [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

In reply to Loktionov, Aleksandr
Quoted 15 lines · Aleksandr
Quoted 15 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, November 17, 2025 9:33 AM
To: Loktionov, Aleksandr <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; Gregory Herrero <[email protected]>
Subject: [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

Quoted 7 lines
Quoted 4 lines

From: Gregory Herrero <[email protected]>

The maximum number of descriptors supported by the hardware is hardware dependent and can be retrieved using

First paragraph uses “hardware dependent” (no hyphen) while later text uses “hardware‑specific” (hyphenated). Prefer “hardware‑dependent” for consistency.

I will address in v5

Quoted 4 lines
Quoted 4 lines

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.

Quoted 9 lines
Quoted 5 lines

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-specific maximum number of descriptors.

The message explains the behavioral change but does not state how the change was tested
(e.g., which MAC types exercised, ethtool -G paths, VF configuration via virtchnl, acceptance/rejection boundaries). Netdev routinely asks for this when behavior changes.

In the meantime, Rafal Romanowski tested it so I will add:

Let me know if that's enough or if more details are required.

Thanks,
Gregory

#5 lore raw

Re: [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

In reply to [email protected]
Quoted 27 lines · On 11/17/2025 12:33 AM, [email protected] wrote:

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

From: Gregory Herrero <[email protected]>

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-specific maximum number of descriptors.

Fixes 55d225670def ("i40e: add validation for ring_len param")
---
  drivers/net/ethernet/intel/i40e/i40e.h         | 18 ++++++++++++++++++
  drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ------------
  .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  4 ++--
  3 files changed, 20 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +0 -0
index 801a57a925da..5b367397ae43 100644

drivers/net/ethernet/intel/i40e/i40e.h static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf) · line 1427

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e.h +7 -0
@@ -1418,4 +1418,22 @@ 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;
  }
 
+/**
+ * i40e_get_max_num_descriptors - get maximum number of descriptors for this
+ * hardware.
+ * @pf: pointer to a PF
+ *
+ * Return: u32 value corresponding to the maximum number of descriptors.
+ **/

Nit, but the function name is descriptive enough without the documentation.

I think the purpose of the function would be even more obvious if the argument was a pointer to the hw structure instead of a pointer to the pf since the max is based on the hw not the pf.

Brett

Quoted 61 lines
drivers/net/ethernet/intel/i40e/i40e.h +11 -0
+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_ */
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +0 -12
index 86c72596617a..61c39e881b00 100644
@@ -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,
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +2 -3
index 081a4526a2f0..cf831c649c9c 100644
@@ -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;
         }
--

2.51.0

#6 lore raw

Re: [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

Quoted 42 lines · Brett
Quoted 27 lines · On 11/17/2025 12:33 AM, [email protected] wrote:

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

From: Gregory Herrero <[email protected]>

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-specific maximum number of descriptors.

Fixes 55d225670def ("i40e: add validation for ring_len param")
---
  drivers/net/ethernet/intel/i40e/i40e.h         | 18 ++++++++++++++++++
  drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ------------
  .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  4 ++--
  3 files changed, 20 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +0 -0
index 801a57a925da..5b367397ae43 100644

drivers/net/ethernet/intel/i40e/i40e.h static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf) · line 1427

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e.h +7 -0
@@ -1418,4 +1418,22 @@ 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;
  }
 
+/**
+ * i40e_get_max_num_descriptors - get maximum number of descriptors for this
+ * hardware.
+ * @pf: pointer to a PF
+ *
+ * Return: u32 value corresponding to the maximum number of descriptors.
+ **/

Nit, but the function name is descriptive enough without the documentation.

Quoted 4 lines

I think the purpose of the function would be even more obvious if the argument was a pointer to the hw structure instead of a pointer to the pf since the max is based on the hw not the pf.

I agree, it's just that it will require changing the 5 callers of this function and invalidate the testing from Rafal Romanowski. Please let me know what you think, I can wait before sending v5.

Thanks,
Gregory

Quoted 61 lines
Quoted 61 lines
drivers/net/ethernet/intel/i40e/i40e.h +11 -0
+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_ */
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +0 -12
index 86c72596617a..61c39e881b00 100644
@@ -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,
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +2 -3
index 081a4526a2f0..cf831c649c9c 100644
@@ -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;
         }
--

2.51.0

#7 lore raw

Re: [PATCH v4 1/1] i40e: validate ring_len parameter against hardware-specific values

Quoted 44 lines · Gregory Herrero

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 40 lines · Brett
Quoted 27 lines · On 11/17/2025 12:33 AM, [email protected] wrote:

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

From: Gregory Herrero <[email protected]>

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-specific maximum number of descriptors.

Fixes 55d225670def ("i40e: add validation for ring_len param")
---
   drivers/net/ethernet/intel/i40e/i40e.h         | 18 ++++++++++++++++++
   drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ------------
   .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  4 ++--
   3 files changed, 20 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +0 -0
index 801a57a925da..5b367397ae43 100644

drivers/net/ethernet/intel/i40e/i40e.h static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf) · line 1427

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e.h +7 -0
@@ -1418,4 +1418,22 @@ 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;
   }
 
+/**
+ * i40e_get_max_num_descriptors - get maximum number of descriptors for this
+ * hardware.
+ * @pf: pointer to a PF
+ *
+ * Return: u32 value corresponding to the maximum number of descriptors.
+ **/

Nit, but the function name is descriptive enough without the documentation.

Quoted 7 lines
Quoted 4 lines

I think the purpose of the function would be even more obvious if the argument was a pointer to the hw structure instead of a pointer to the pf since the max is based on the hw not the pf.

I agree, it's just that it will require changing the 5 callers of this function and invalidate the testing from Rafal Romanowski. Please let me know what you think, I can wait before sending v5.

I'm fine with the PF being the parameter. However, the documentation should really be removed IMO.

Thanks,

Brett

Quoted 64 lines

Thanks,
Gregory

Quoted 61 lines
Quoted 61 lines
drivers/net/ethernet/intel/i40e/i40e.h +11 -0
+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_ */
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +0 -12
index 86c72596617a..61c39e881b00 100644
@@ -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,
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +2 -3
index 081a4526a2f0..cf831c649c9c 100644
@@ -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;
          }
--

2.51.0