Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: qca8k: fix MTU calculation

qca8k has a global MTU, so its tracking the MTU per port to make sure
that the largest MTU gets applied.
Since it uses the frame size instead of MTU the driver MTU change function
will then add the size of Ethernet header and checksum on top of MTU.

The driver currently populates the per port MTU size as Ethernet frame
length + checksum which equals 1518.

The issue is that then MTU change function will go through all of the
ports, find the largest MTU and apply the Ethernet header + checksum on
top of it again, so for a desired MTU of 1500 you will end up with 1536.

This is obviously incorrect, so to correct it populate the per port struct
MTU with just the MTU and not include the Ethernet header + checksum size
as those will be added by the MTU change function.

Fixes: f58d2598cf70 ("net: dsa: qca8k: implement the port MTU callbacks")
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Robert Marko and committed by
David S. Miller
65258b9d 3b00a07c

+5 -1
+5 -1
drivers/net/dsa/qca8k.c
··· 1256 1256 /* Set initial MTU for every port. 1257 1257 * We have only have a general MTU setting. So track 1258 1258 * every port and set the max across all port. 1259 + * Set per port MTU to 1500 as the MTU change function 1260 + * will add the overhead and if its set to 1518 then it 1261 + * will apply the overhead again and we will end up with 1262 + * MTU of 1536 instead of 1518 1259 1263 */ 1260 - priv->port_mtu[i] = ETH_FRAME_LEN + ETH_FCS_LEN; 1264 + priv->port_mtu[i] = ETH_DATA_LEN; 1261 1265 } 1262 1266 1263 1267 /* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */