]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: stmmac: add TSO check for header length
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 1 Apr 2026 07:21:34 +0000 (08:21 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 2 Apr 2026 18:28:18 +0000 (11:28 -0700)
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) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1w7ptO-0000000EatC-39il@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 3e7675cfd57e4411b119b683027cdb0bb6713201..c23de66227245cd1028197472d8cc886e11c3854 100644 (file)
@@ -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;
        }