netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 iwl-net] i40e: Prevent setting MTU if greater than MFS
@ 2024-03-13  9:07 Erwan Velu
  2024-03-14 16:10 ` Brett Creeley
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Erwan Velu @ 2024-03-13  9:07 UTC (permalink / raw)
  Cc: Erwan Velu, Jesse Brandeburg, Tony Nguyen, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, intel-wired-lan,
	netdev, linux-kernel

Commit 6871a7de705 ("[intelxl] Use admin queue to set port MAC address
and maximum frame size") from iPXE project set the MFS to 0x600 = 1536.
See https://github.com/ipxe/ipxe/commit/6871a7de705

At boot time the i40e driver complains about it with
the following message but continues.

	MFS for port 1 has been set below the default: 600

If the MTU size is increased, the driver accepts it but large packets will
not be processed by the firmware generating tx_errors. The issue is pretty
silent for users. i.e doing TCP in such context will generates lots of
retransmissions until the proper window size (below 1500) will be used.

To fix this case, it would have been ideal to increase the MFS,
via i40e_aqc_opc_set_mac_config, incoming patch will take care of it.

At least, commit prevents setting up an MTU greater than the current MFS.
It will avoid being in the position of having an MTU set to 9000 on the
netdev with a firmware refusing packets larger than 1536.

A typical trace looks like:
[  377.548696] i40e 0000:5d:00.0 eno5: Error changing mtu to 9000, Max is 1500. MFS is too small.

Signed-off-by: Erwan Velu <e.velu@criteo.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index f86578857e8a..85ecf2f3de18 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -2946,7 +2946,7 @@ static int i40e_change_mtu(struct net_device *netdev, int new_mtu)
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_vsi *vsi = np->vsi;
 	struct i40e_pf *pf = vsi->back;
-	int frame_size;
+	int frame_size, mfs, max_mtu;
 
 	frame_size = i40e_max_vsi_frame_size(vsi, vsi->xdp_prog);
 	if (new_mtu > frame_size - I40E_PACKET_HDR_PAD) {
@@ -2955,6 +2955,14 @@ static int i40e_change_mtu(struct net_device *netdev, int new_mtu)
 		return -EINVAL;
 	}
 
+	mfs = pf->hw.phy.link_info.max_frame_size;
+	max_mtu = mfs - I40E_PACKET_HDR_PAD;
+	if (new_mtu > max_mtu) {
+		netdev_err(netdev, "Error changing mtu to %d, Max is %d. MFS is too small.\n",
+			   new_mtu, max_mtu);
+		return -EINVAL;
+	}
+
 	netdev_dbg(netdev, "changing MTU from %d to %d\n",
 		   netdev->mtu, new_mtu);
 	netdev->mtu = new_mtu;
-- 
2.44.0


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

end of thread, other threads:[~2024-04-22 13:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-13  9:07 [PATCH v4 iwl-net] i40e: Prevent setting MTU if greater than MFS Erwan Velu
2024-03-14 16:10 ` Brett Creeley
2024-03-14 17:10   ` Erwan Velu
2024-03-14 17:55     ` Brett Creeley
2024-03-14 18:04       ` Erwan Velu
2024-03-14 20:31         ` Tony Nguyen
2024-03-15  9:17           ` Erwan Velu
2024-03-15 16:19             ` Brett Creeley
2024-03-18 17:45 ` Simon Horman
2024-03-19 10:26   ` Sunil Kovvuri Goutham
     [not found]   ` <d33b98de-dfc0-445e-bdd7-0ae76d050ed4@criteo.com>
2024-03-19 12:20     ` Simon Horman
2024-03-19 13:33       ` Erwan Velu
2024-04-19 14:26 ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
     [not found]   ` <CAL2JzuxraP5xCxt4_EK3zbz9kyAyxJFuEadtq4zHsdMjR5PGTw@mail.gmail.com>
2024-04-22 13:19     ` Pucha, HimasekharX Reddy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).