i40e: Prevent setting MTU if greater than MFS
Subsystems (3)
PATCH v3 1/1 i40e: Prevent setting MTU if greater than MFS
Commit 6871a7de705b6f6a4046f0d19da9bcd689c3bc8e from iPXE project is setting the MFS to 0x600 = 1536.
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 accept 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, this 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.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +9 -1
@@ -2950,7 +2950,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 ) {
@@ -2959,6 +2959,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;
Signature · 1 line
2.44.0
Dear Erwan,
Thank you very umch for your patch.
Am 12.03.24 um 10:42 schrieb Erwan Velu:
Quoted 2 lines
Commit
6871a7de705b6f6a4046f0d19da9bcd689c3bc8efrom iPXE project is setting the MFS to0x600= 1536.
Please add a link, as most people do not have the iPXE archive checked out. Maybe also add the commit message summary.
Quoted 4 lines
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
Hmm, but 1536 > 600. So the log message is incorrect?
Quoted 1 line
If the MTU size is increased, the driver accept it but large packets will not
accept*s*
Quoted 10 lines
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, this 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.
Maybe add the new log message.
One last formal nit: Please use a line length limit of 75 characters per line.
Quoted 19 lines
Signed-off-by Erwan Velu <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/i40e/i40e_main.c +1
-1@@ -2950,7 +2950,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 ) {
drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_change_mtu(struct net_device *netdev, int new_mtu) · line 2966
Quoted 8 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +5
-0@@ -2959,6 +2959,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);
The other log messages capitalize MTU.
drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_change_mtu(struct net_device *netdev, int new_mtu) · line 2972
Quoted 6 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +3
-0+return -EINVAL ; + } +netdev_dbg (netdev,"changing MTU from %d to %d\n" , netdev->mtu, new_mtu); netdev->mtu = new_mtu;
The rest looks reasonable.
Kind regards,
Paul
Quoted 6 lines
Am 12.03.24 um 10:42 schrieb Erwan Velu:
Quoted 2 lines
Commit
6871a7de705b6f6a4046f0d19da9bcd689c3bc8efrom iPXE project is setting the MFS to0x600= 1536.Please add a link, as most people do not have the iPXE archive checked out. Maybe also add the commit message summary.
I will, thanks.
Quoted 5 lines
Quoted 4 lines
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
Hmm, but 1536 > 600. So the log message is incorrect?
As mentioned earlier in the commit message, the 600 is 0x600 = 1536. I can offer a patch to report it in decimal or add an explicit 0x prefix.
Quoted 2 lines
Quoted 1 line
If the MTU size is increased, the driver accept it but large packets will not
accept*s*
Fixed.
[...]
Quoted 4 lines
Quoted 3 lines
At least, this 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.
Maybe add the new log message.
Done.
Quoted 2 lines
One last formal nit: Please use a line length limit of 75 characters per line.
Done.
Quoted 7 lines
drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_change_mtu(struct net_device *netdev, int new_mtu) · line 2966
Quoted 5 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +5
-0+ 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);The other log messages capitalize MTU.
Yeah but the exact previous one was in the same case. Shall I bump all of them to upper or lower cast ?
Quoted 1 line
The rest looks reasonable.
Thx for the review.
Paolo Abeni
maintainerHi,
Quoted 1 line · Erwan Velu
Commit
6871a7de705b6f6a4046f0d19da9bcd689c3bc8efrom iPXE project is
Please use the checkpatch-friendly commit reference: <12char hash> ("<title>")
Quoted 12 lines
setting the MFS to
0x600= 1536.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 accept 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.
Quoted 6 lines
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, this 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.
This looks like a legit fix that should target the 'net' tree, @Tony:
do you agree?
If so, Erwan, please include a suitable fixes tag in the next revision. Please include into the subj prefix a suitable target tree. I think this should go first via the intel tree for testing, so 'iwl-net' should fit.
In any case please respect the 24h grace period when posting on netdev:
https://elixir.bootlin.com/linux/latest/source/Documentation/process/maintainer-netdev.rst#L399
Cheers,
Paolo
Quoted 5 lines · Erwan Velu
Quoted 1 line
Commit
6871a7de705b6f6a4046f0d19da9bcd689c3bc8efrom iPXE project isPlease use the checkpatch-friendly commit reference: <12char hash> ("<title>")
Done.
Quoted 6 lines
This looks like a legit fix that should target the 'net' tree, @Tony:
do you agree?
If so, Erwan, please include a suitable fixes tag in the next revision. Please include into the subj prefix a suitable target tree. I think this should go first via the intel tree for testing, so 'iwl-net' should fit.
Oh I didn't knew that part, thx. I'll wait @Tony to see what target I should use.
Quoted 1 line
In any case please respect the 24h grace period when posting on netdev:
Yeah sorry for the v3 ... I shouldn't have done that way, that fast.
Tony Nguyen
maintainerQuoted 10 lines · Erwan Velu
Quoted 8 lines · Erwan Velu
This looks like a legit fix that should target the 'net' tree, @Tony:
do you agree?
If so, Erwan, please include a suitable fixes tag in the next revision. Please include into the subj prefix a suitable target tree. I think this should go first via the intel tree for testing, so 'iwl-net' should fit.Oh I didn't knew that part, thx. I'll wait @Tony to see what target I should use.
I agree with both parts, so 'iwl-net' would be best.
Thanks,
Tony
Quoted 3 lines
Quoted 2 lines
In any case please respect the 24h grace period when posting on netdev:
Yeah sorry for the v3 ... I shouldn't have done that way, that fast.