public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual hardware limit
@ 2026-02-10 15:57 Kohei Enju
  2026-02-10 16:37 ` Alexander Lobakin
  0 siblings, 1 reply; 5+ messages in thread
From: Kohei Enju @ 2026-02-10 15:57 UTC (permalink / raw)
  To: intel-wired-lan, netdev
  Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexander Lobakin,
	kohei.enju, Kohei Enju

iavf sets LIBIE_MAX_MTU as netdev->max_mtu, ignoring vf_res->max_mtu
from PF [1]. This allows setting an MTU beyond the actual hardware
limit, causing TX queue timeouts [2].

Set correct netdev->max_mtu using vf_res->max_mtu from the PF.

Note that currently PF drivers such as ice/i40e set the frame size in
vf_res->max_mtu, not MTU. Convert vf_res->max_mtu to MTU before setting
netdev->max_mtu.

[1]
 # ip -j -d link show $DEV | jq '.[0].max_mtu'
 16356

[2]
 iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU: 1: transmit queue 0 timed out 5692 ms
 iavf 0000:00:05.0 enp0s5: NIC Link is Up Speed is 10 Gbps Full Duplex
 iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU: 6: transmit queue 3 timed out 5312 ms
 iavf 0000:00:05.0 enp0s5: NIC Link is Up Speed is 10 Gbps Full Duplex
 ...

Fixes: 5fa4caff59f2 ("iavf: switch to Page Pool")
Signed-off-by: Kohei Enju <kohei@enjuk.jp>
---
Ideally we may fix ice/i40e to set max MTU (not frame size) in
vf_res->max_mtu on the PF side, but this would break PF/VF API
compatibility between different kernel versions and would need
modifications on code that treats vf_res->max_mtu as the frame size.

If it's acceptable to change the PF/VF API, this patch would be simply:
    netdev->max_mtu = min_not_zero(adapter->vf_res->max_mtu, 
                                   LIBIE_MAX_MTU);
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index b625ce00b836..d911c634596a 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -2772,7 +2772,22 @@ static void iavf_init_config_adapter(struct iavf_adapter *adapter)
 	netdev->watchdog_timeo = 5 * HZ;
 
 	netdev->min_mtu = ETH_MIN_MTU;
-	netdev->max_mtu = LIBIE_MAX_MTU;
+
+	/* PF/VF API: vf_res->max_mtu is max frame size (not MTU).
+	 * Convert to MTU.
+	 */
+	if (!adapter->vf_res->max_mtu) {
+		netdev->max_mtu = LIBIE_MAX_MTU;
+	} else if (adapter->vf_res->max_mtu < LIBETH_RX_LL_LEN + ETH_MIN_MTU ||
+		   adapter->vf_res->max_mtu >
+			   LIBETH_RX_LL_LEN + LIBIE_MAX_MTU) {
+		netdev_warn_once(adapter->netdev,
+				 "invalid max frame size %d from PF, using default MTU %d",
+				 adapter->vf_res->max_mtu, LIBIE_MAX_MTU);
+		netdev->max_mtu = LIBIE_MAX_MTU;
+	} else {
+		netdev->max_mtu = adapter->vf_res->max_mtu - LIBETH_RX_LL_LEN;
+	}
 
 	if (!is_valid_ether_addr(adapter->hw.mac.addr)) {
 		dev_info(&pdev->dev, "Invalid MAC address %pM, using random\n",
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual hardware limit
  2026-02-10 15:57 [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual hardware limit Kohei Enju
@ 2026-02-10 16:37 ` Alexander Lobakin
  2026-02-10 17:05   ` [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual Kohei Enju
  2026-02-23 15:56   ` [Intel-wired-lan] [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual hardware limit Romanowski, Rafal
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Lobakin @ 2026-02-10 16:37 UTC (permalink / raw)
  To: Kohei Enju
  Cc: intel-wired-lan, netdev, Tony Nguyen, Przemek Kitszel,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, kohei.enju

From: Kohei Enju <kohei@enjuk.jp>
Date: Tue, 10 Feb 2026 15:57:14 +0000

> iavf sets LIBIE_MAX_MTU as netdev->max_mtu, ignoring vf_res->max_mtu
> from PF [1]. This allows setting an MTU beyond the actual hardware
> limit, causing TX queue timeouts [2].
> 
> Set correct netdev->max_mtu using vf_res->max_mtu from the PF.
> 
> Note that currently PF drivers such as ice/i40e set the frame size in
> vf_res->max_mtu, not MTU. Convert vf_res->max_mtu to MTU before setting
> netdev->max_mtu.
> 
> [1]
>  # ip -j -d link show $DEV | jq '.[0].max_mtu'
>  16356
> 
> [2]
>  iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU: 1: transmit queue 0 timed out 5692 ms
>  iavf 0000:00:05.0 enp0s5: NIC Link is Up Speed is 10 Gbps Full Duplex
>  iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU: 6: transmit queue 3 timed out 5312 ms
>  iavf 0000:00:05.0 enp0s5: NIC Link is Up Speed is 10 Gbps Full Duplex
>  ...
> 
> Fixes: 5fa4caff59f2 ("iavf: switch to Page Pool")
> Signed-off-by: Kohei Enju <kohei@enjuk.jp>

Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>

Although I'm not sure the 'Fixes:' tag is correct. Was vs_res->max_mtu
accounted before switching to Page Pool? If so, then yes, my fault.
Otherwise, this issue is older than libie.
I'm asking as IIRC before I did set max_mtu to the libie definition,
there was a hardcoded value already.

> ---
> Ideally we may fix ice/i40e to set max MTU (not frame size) in
> vf_res->max_mtu on the PF side, but this would break PF/VF API
> compatibility between different kernel versions and would need
> modifications on code that treats vf_res->max_mtu as the frame size.
> 
> If it's acceptable to change the PF/VF API, this patch would be simply:
>     netdev->max_mtu = min_not_zero(adapter->vf_res->max_mtu, 
>                                    LIBIE_MAX_MTU);
> ---
>  drivers/net/ethernet/intel/iavf/iavf_main.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
Thanks,
Olek

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual
  2026-02-10 16:37 ` Alexander Lobakin
@ 2026-02-10 17:05   ` Kohei Enju
  2026-02-12 18:15     ` Simon Horman
  2026-02-23 15:56   ` [Intel-wired-lan] [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual hardware limit Romanowski, Rafal
  1 sibling, 1 reply; 5+ messages in thread
From: Kohei Enju @ 2026-02-10 17:05 UTC (permalink / raw)
  To: aleksander.lobakin
  Cc: andrew+netdev, anthony.l.nguyen, davem, edumazet, intel-wired-lan,
	kohei.enju, kohei, kuba, netdev, pabeni, przemyslaw.kitszel

On Tue, 10 Feb 2026 17:37:23 +0100, Alexander Lobakin wrote:

> From: Kohei Enju <kohei@enjuk.jp>
> Date: Tue, 10 Feb 2026 15:57:14 +0000
> 
> > iavf sets LIBIE_MAX_MTU as netdev->max_mtu, ignoring vf_res->max_mtu
> > from PF [1]. This allows setting an MTU beyond the actual hardware
> > limit, causing TX queue timeouts [2].
> > 
> > Set correct netdev->max_mtu using vf_res->max_mtu from the PF.
> > 
> > Note that currently PF drivers such as ice/i40e set the frame size in
> > vf_res->max_mtu, not MTU. Convert vf_res->max_mtu to MTU before setting
> > netdev->max_mtu.
> > 
> > [1]
> >  # ip -j -d link show $DEV | jq '.[0].max_mtu'
> >  16356
> > 
> > [2]
> >  iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU: 1: transmit queue 0 timed out 5692 ms
> >  iavf 0000:00:05.0 enp0s5: NIC Link is Up Speed is 10 Gbps Full Duplex
> >  iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU: 6: transmit queue 3 timed out 5312 ms
> >  iavf 0000:00:05.0 enp0s5: NIC Link is Up Speed is 10 Gbps Full Duplex
> >  ...
> > 
> > Fixes: 5fa4caff59f2 ("iavf: switch to Page Pool")
> > Signed-off-by: Kohei Enju <kohei@enjuk.jp>
> 
> Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> 
> Although I'm not sure the 'Fixes:' tag is correct. Was vs_res->max_mtu
> accounted before switching to Page Pool? If so, then yes, my fault.
> Otherwise, this issue is older than libie.

You're right that vf_res->mtu was also not accounted before the commit.

The commit changes:
-       netdev->max_mtu = IAVF_MAX_RXBUFFER - IAVF_PACKET_HDR_PAD;
+       netdev->max_mtu = LIBIE_MAX_MTU;
...
-#define IAVF_MAX_RXBUFFER   9728  /* largest size for single descriptor */

and thus netdev->max_mtu was already hardcoded, but just because
IAVF_MAX_RXBUFFER was valid for VFs there hadn't been any issues, and
invalid MTU could start to be set after the commit.

> I'm asking as IIRC before I did set max_mtu to the libie definition,
> there was a hardcoded value already.

Yea, as far as I checked the value was hardcoded from the beginning
(91c527a55664 ("ethernet/intel: use core min/max MTU checking")).

Although I'm not attached to the exact commit as the Fixes: tag, I chose
that since (coincidently) that commit made this regression.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual
  2026-02-10 17:05   ` [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual Kohei Enju
@ 2026-02-12 18:15     ` Simon Horman
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2026-02-12 18:15 UTC (permalink / raw)
  To: Kohei Enju
  Cc: aleksander.lobakin, andrew+netdev, anthony.l.nguyen, davem,
	edumazet, intel-wired-lan, kohei.enju, kuba, netdev, pabeni,
	przemyslaw.kitszel

On Tue, Feb 10, 2026 at 05:05:55PM +0000, Kohei Enju wrote:
> On Tue, 10 Feb 2026 17:37:23 +0100, Alexander Lobakin wrote:
> 
> > From: Kohei Enju <kohei@enjuk.jp>
> > Date: Tue, 10 Feb 2026 15:57:14 +0000
> > 
> > > iavf sets LIBIE_MAX_MTU as netdev->max_mtu, ignoring vf_res->max_mtu
> > > from PF [1]. This allows setting an MTU beyond the actual hardware
> > > limit, causing TX queue timeouts [2].
> > > 
> > > Set correct netdev->max_mtu using vf_res->max_mtu from the PF.
> > > 
> > > Note that currently PF drivers such as ice/i40e set the frame size in
> > > vf_res->max_mtu, not MTU. Convert vf_res->max_mtu to MTU before setting
> > > netdev->max_mtu.
> > > 
> > > [1]
> > >  # ip -j -d link show $DEV | jq '.[0].max_mtu'
> > >  16356
> > > 
> > > [2]
> > >  iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU: 1: transmit queue 0 timed out 5692 ms
> > >  iavf 0000:00:05.0 enp0s5: NIC Link is Up Speed is 10 Gbps Full Duplex
> > >  iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU: 6: transmit queue 3 timed out 5312 ms
> > >  iavf 0000:00:05.0 enp0s5: NIC Link is Up Speed is 10 Gbps Full Duplex
> > >  ...
> > > 
> > > Fixes: 5fa4caff59f2 ("iavf: switch to Page Pool")
> > > Signed-off-by: Kohei Enju <kohei@enjuk.jp>
> > 
> > Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> > 
> > Although I'm not sure the 'Fixes:' tag is correct. Was vs_res->max_mtu
> > accounted before switching to Page Pool? If so, then yes, my fault.
> > Otherwise, this issue is older than libie.
> 
> You're right that vf_res->mtu was also not accounted before the commit.
> 
> The commit changes:
> -       netdev->max_mtu = IAVF_MAX_RXBUFFER - IAVF_PACKET_HDR_PAD;
> +       netdev->max_mtu = LIBIE_MAX_MTU;
> ...
> -#define IAVF_MAX_RXBUFFER   9728  /* largest size for single descriptor */
> 
> and thus netdev->max_mtu was already hardcoded, but just because
> IAVF_MAX_RXBUFFER was valid for VFs there hadn't been any issues, and
> invalid MTU could start to be set after the commit.
> 
> > I'm asking as IIRC before I did set max_mtu to the libie definition,
> > there was a hardcoded value already.
> 
> Yea, as far as I checked the value was hardcoded from the beginning
> (91c527a55664 ("ethernet/intel: use core min/max MTU checking")).
> 
> Although I'm not attached to the exact commit as the Fixes: tag, I chose
> that since (coincidently) that commit made this regression.

That seems like a reasonable approach to me.

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [Intel-wired-lan] [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual hardware limit
  2026-02-10 16:37 ` Alexander Lobakin
  2026-02-10 17:05   ` [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual Kohei Enju
@ 2026-02-23 15:56   ` Romanowski, Rafal
  1 sibling, 0 replies; 5+ messages in thread
From: Romanowski, Rafal @ 2026-02-23 15:56 UTC (permalink / raw)
  To: Lobakin, Aleksander, Kohei Enju
  Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	Nguyen, Anthony L, Kitszel, Przemyslaw, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	kohei.enju@gmail.com

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Alexander Lobakin
> Sent: Tuesday, February 10, 2026 17:37
> To: Kohei Enju <kohei@enjuk.jp>
> Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; Nguyen, Anthony L
> <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; Andrew Lunn <andrew+netdev@lunn.ch>;
> David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; kohei.enju@gmail.com
> Subject: Re: [Intel-wired-lan] [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to
> respect actual hardware limit
> 
> From: Kohei Enju <kohei@enjuk.jp>
> Date: Tue, 10 Feb 2026 15:57:14 +0000
> 
> > iavf sets LIBIE_MAX_MTU as netdev->max_mtu, ignoring vf_res->max_mtu
> > from PF [1]. This allows setting an MTU beyond the actual hardware
> > limit, causing TX queue timeouts [2].
> >
> > Set correct netdev->max_mtu using vf_res->max_mtu from the PF.
> >
> > Note that currently PF drivers such as ice/i40e set the frame size in
> > vf_res->max_mtu, not MTU. Convert vf_res->max_mtu to MTU before
> > setting
> > netdev->max_mtu.
> >
> > [1]
> >  # ip -j -d link show $DEV | jq '.[0].max_mtu'
> >  16356
> >
> > [2]
> >  iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU: 1: transmit queue 0
> > timed out 5692 ms  iavf 0000:00:05.0 enp0s5: NIC Link is Up Speed is
> > 10 Gbps Full Duplex  iavf 0000:00:05.0 enp0s5: NETDEV WATCHDOG: CPU:
> > 6: transmit queue 3 timed out 5312 ms  iavf 0000:00:05.0 enp0s5: NIC
> > Link is Up Speed is 10 Gbps Full Duplex  ...
> >
> > Fixes: 5fa4caff59f2 ("iavf: switch to Page Pool")
> > Signed-off-by: Kohei Enju <kohei@enjuk.jp>
> 
> Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> 
> Although I'm not sure the 'Fixes:' tag is correct. Was vs_res->max_mtu accounted
> before switching to Page Pool? If so, then yes, my fault.
> Otherwise, this issue is older than libie.
> I'm asking as IIRC before I did set max_mtu to the libie definition, there was a
> hardcoded value already.
> 
> > ---
> > Ideally we may fix ice/i40e to set max MTU (not frame size) in
> > vf_res->max_mtu on the PF side, but this would break PF/VF API
> > compatibility between different kernel versions and would need
> > modifications on code that treats vf_res->max_mtu as the frame size.
> >
> > If it's acceptable to change the PF/VF API, this patch would be simply:
> >     netdev->max_mtu = min_not_zero(adapter->vf_res->max_mtu,
> >                                    LIBIE_MAX_MTU);
> > ---
> >  drivers/net/ethernet/intel/iavf/iavf_main.c | 17 ++++++++++++++++-
> >  1 file changed, 16 insertions(+), 1 deletion(-)
> Thanks,
> Olek


Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-23 15:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10 15:57 [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual hardware limit Kohei Enju
2026-02-10 16:37 ` Alexander Lobakin
2026-02-10 17:05   ` [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual Kohei Enju
2026-02-12 18:15     ` Simon Horman
2026-02-23 15:56   ` [Intel-wired-lan] [PATCH v1 iwl-net] iavf: fix netdev->max_mtu to respect actual hardware limit Romanowski, Rafal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox