diff mbox series

[1/5] net: dsa: b53: fix jumbo frame mtu check

Message ID 20241004-b53_jumbo_fixes-v1-1-ce1e54aa7b3c@gmail.com (mailing list archive)
State Accepted
Commit 42fb3acf6826c6764ba79feb6e15229b43fd2f9f
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: b53: assorted jumbo frame fixes | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 6 this patch: 6
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 6 this patch: 6
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 5 this patch: 5
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-06--15-00 (tests: 775)

Commit Message

Jonas Gorski Oct. 4, 2024, 8:47 a.m. UTC
JMS_MIN_SIZE is the full ethernet frame length, while mtu is just the
data payload size. Comparing these two meant that mtus between 1500 and
1518 did not trigger enabling jumbo frames.

So instead compare the set mtu ETH_DATA_LEN, which is equal to
JMS_MIN_SIZE - ETH_HLEN - ETH_FCS_LEN;

Also do a check that the requested mtu is actually greater than the
minimum length, else we do not need to enable jumbo frames.

In practice this only introduced a very small range of mtus that did not
work properly. Newer chips allow 2000 byte large frames by default, and
older chips allow 1536 bytes long, which is equivalent to an mtu of
1514. So effectivly only mtus of 1515~1517 were broken.

Fixes: 6ae5834b983a ("net: dsa: b53: add MTU configuration support")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Florian Fainelli Oct. 5, 2024, 3:38 a.m. UTC | #1
On 10/4/2024 1:47 AM, Jonas Gorski wrote:
> JMS_MIN_SIZE is the full ethernet frame length, while mtu is just the
> data payload size. Comparing these two meant that mtus between 1500 and
> 1518 did not trigger enabling jumbo frames.
> 
> So instead compare the set mtu ETH_DATA_LEN, which is equal to
> JMS_MIN_SIZE - ETH_HLEN - ETH_FCS_LEN;
> 
> Also do a check that the requested mtu is actually greater than the
> minimum length, else we do not need to enable jumbo frames.
> 
> In practice this only introduced a very small range of mtus that did not
> work properly. Newer chips allow 2000 byte large frames by default, and
> older chips allow 1536 bytes long, which is equivalent to an mtu of
> 1514. So effectivly only mtus of 1515~1517 were broken.
> 
> Fixes: 6ae5834b983a ("net: dsa: b53: add MTU configuration support")
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
diff mbox series

Patch

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 0783fc121bbbf979abe6c9985b10cf4379bf2a9b..57df00ad9dd4cedfe9e959ea779d48e3f8f36142 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -2259,7 +2259,7 @@  static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
 	if (!dsa_is_cpu_port(ds, port))
 		return 0;
 
-	enable_jumbo = (mtu >= JMS_MIN_SIZE);
+	enable_jumbo = (mtu > ETH_DATA_LEN);
 	allow_10_100 = (dev->chip_id == BCM583XX_DEVICE_ID);
 
 	return b53_set_jumbo(dev, enable_jumbo, allow_10_100);