Skip to content

Commit dc6c0bf

Browse files
Linus Walleijkuba-moo
authored andcommitted
net: ethernet: cortina: Fix MTU max setting
The RX max frame size is over 10000 for the Gemini ethernet, but the TX max frame size is actually just 2047 (0x7ff after checking the datasheet). Reflect this in what we offer to Linux, cap the MTU at the TX max frame minus ethernet headers. We delete the code disabling the hardware checksum for large MTUs as netdev->mtu can no longer be larger than netdev->max_mtu meaning the if()-clause in gmac_fix_features() is never true. Fixes: 4d5ae32 ("net: ethernet: Add a driver for Gemini gigabit ethernet") Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Link: https://lore.kernel.org/r/20231109-gemini-largeframe-fix-v4-3-6e611528db08@linaro.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d4d0c5b commit dc6c0bf

2 files changed

Lines changed: 5 additions & 14 deletions

File tree

drivers/net/ethernet/cortina/gemini.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,15 +2000,6 @@ static int gmac_change_mtu(struct net_device *netdev, int new_mtu)
20002000
return 0;
20012001
}
20022002

2003-
static netdev_features_t gmac_fix_features(struct net_device *netdev,
2004-
netdev_features_t features)
2005-
{
2006-
if (netdev->mtu + ETH_HLEN + VLAN_HLEN > MTU_SIZE_BIT_MASK)
2007-
features &= ~GMAC_OFFLOAD_FEATURES;
2008-
2009-
return features;
2010-
}
2011-
20122003
static int gmac_set_features(struct net_device *netdev,
20132004
netdev_features_t features)
20142005
{
@@ -2234,7 +2225,6 @@ static const struct net_device_ops gmac_351x_ops = {
22342225
.ndo_set_mac_address = gmac_set_mac_address,
22352226
.ndo_get_stats64 = gmac_get_stats64,
22362227
.ndo_change_mtu = gmac_change_mtu,
2237-
.ndo_fix_features = gmac_fix_features,
22382228
.ndo_set_features = gmac_set_features,
22392229
};
22402230

@@ -2486,11 +2476,12 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
24862476

24872477
netdev->hw_features = GMAC_OFFLOAD_FEATURES;
24882478
netdev->features |= GMAC_OFFLOAD_FEATURES | NETIF_F_GRO;
2489-
/* We can handle jumbo frames up to 10236 bytes so, let's accept
2490-
* payloads of 10236 bytes minus VLAN and ethernet header
2479+
/* We can receive jumbo frames up to 10236 bytes but only
2480+
* transmit 2047 bytes so, let's accept payloads of 2047
2481+
* bytes minus VLAN and ethernet header
24912482
*/
24922483
netdev->min_mtu = ETH_MIN_MTU;
2493-
netdev->max_mtu = 10236 - VLAN_ETH_HLEN;
2484+
netdev->max_mtu = MTU_SIZE_BIT_MASK - VLAN_ETH_HLEN;
24942485

24952486
port->freeq_refill = 0;
24962487
netif_napi_add(netdev, &port->napi, gmac_napi_poll);

drivers/net/ethernet/cortina/gemini.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ union gmac_txdesc_3 {
502502
#define SOF_BIT 0x80000000
503503
#define EOF_BIT 0x40000000
504504
#define EOFIE_BIT BIT(29)
505-
#define MTU_SIZE_BIT_MASK 0x1fff
505+
#define MTU_SIZE_BIT_MASK 0x7ff /* Max MTU 2047 bytes */
506506

507507
/* GMAC Tx Descriptor */
508508
struct gmac_txdesc {

0 commit comments

Comments
 (0)