]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: lan966x: Fix the MTU calculation
authorHoratiu Vultur <horatiu.vultur@microchip.com>
Sun, 30 Oct 2022 21:36:34 +0000 (22:36 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2022 17:17:18 +0000 (18:17 +0100)
[ Upstream commit 486c292230166c2d61701d3c984bf9143588ea28 ]

When the MTU was changed, the lan966x didn't take in consideration
the L2 header and the FCS. So the HW was configured with a smaller
value than what was desired. Therefore the correct value to configure
the HW would be new_mtu + ETH_HLEN + ETH_FCS_LEN.
The vlan tag is not considered here, because at the time when the
blamed commit was added, there was no vlan filtering support. The
vlan fix will be part of the next patch.

Fixes: d28d6d2e37d1 ("net: lan966x: add port module support")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/microchip/lan966x/lan966x_main.c
drivers/net/ethernet/microchip/lan966x/lan966x_main.h

index d928b75f37803992b87298753d894e546dd4d65f..989e5f045d7ec06328cdf2555653db14665cc96c 100644 (file)
@@ -385,7 +385,7 @@ static int lan966x_port_change_mtu(struct net_device *dev, int new_mtu)
        int old_mtu = dev->mtu;
        int err;
 
-       lan_wr(DEV_MAC_MAXLEN_CFG_MAX_LEN_SET(new_mtu),
+       lan_wr(DEV_MAC_MAXLEN_CFG_MAX_LEN_SET(LAN966X_HW_MTU(new_mtu)),
               lan966x, DEV_MAC_MAXLEN_CFG(port->chip_port));
        dev->mtu = new_mtu;
 
index 2787055c1847535c09a1eb5a3086ffe42305b3ea..e316bfe186d746f4c1e0c0e5c18d5e85f48cff00 100644 (file)
@@ -24,6 +24,8 @@
 #define LAN966X_BUFFER_MEMORY          (160 * 1024)
 #define LAN966X_BUFFER_MIN_SZ          60
 
+#define LAN966X_HW_MTU(mtu)            ((mtu) + ETH_HLEN + ETH_FCS_LEN)
+
 #define PGID_AGGR                      64
 #define PGID_SRC                       80
 #define PGID_ENTRIES                   89