From: Russell King (Oracle) Date: Wed, 1 Apr 2026 07:21:34 +0000 (+0100) Subject: net: stmmac: add TSO check for header length X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6732e474f880468435a79d05811c8c814c5d71f8;p=thirdparty%2Flinux.git net: stmmac: add TSO check for header length According to the STM32MP151 documentation which covers dwmac v4.2, the hardware TSO feature can handle header lengths up to a maximum of 1023 bytes. Add a .ndo_features_check() method implementation to check the header length meets these requirements, otherwise fall back to software GSO. Signed-off-by: Russell King (Oracle) Link: https://patch.msgid.link/E1w7ptO-0000000EatC-39il@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 3e7675cfd57e4..c23de66227245 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -4385,6 +4385,20 @@ static size_t stmmac_tso_header_size(struct sk_buff *skb) return size; } +/* STM32MP151 (dwmac v4.2) and STM32MP25xx (dwmac v5.3) states for TDES2 normal + * (read format) descriptor that the maximum header length supported for the + * TSO feature is 1023 bytes. + * + * While IPv4 is limited to MAC+VLAN+IPv4+ext+TCP+ext = 138 bytes, the IPv6 + * extension headers aren't similarly limited. + */ +static bool stmmac_tso_valid_packet(struct sk_buff *skb) +{ + size_t header_len = stmmac_tso_header_size(skb); + + return header_len <= 1023; +} + /** * stmmac_tso_xmit - Tx entry point of the driver for oversized frames (TSO) * @skb : the socket buffer @@ -4945,7 +4959,8 @@ static netdev_features_t stmmac_features_check(struct sk_buff *skb, if (skb_is_gso(skb)) { queue = skb_get_queue_mapping(skb); - if (!stmmac_tso_channel_permitted(netdev_priv(dev), queue)) + if (!stmmac_tso_channel_permitted(netdev_priv(dev), queue) || + !stmmac_tso_valid_packet(skb)) features &= ~NETIF_F_GSO_MASK; }