[PATCH net-next 3/4] net: stmmac: enhance VLAN protocol detection for GRO

From: Konrad Leszczynski
Date: Thu Aug 28 2025 - 10:50:06 EST


From: Piotr Warpechowski <piotr.warpechowski@xxxxxxxxx>

Enhance protocol extraction in stmmac_has_ip_ethertype() by introducing
MAC offset parameter and changing:

__vlan_get_protocol() -> __vlan_get_protocol_offset()

Add correct header length for VLAN tags, which enable Generic Receive
Offload (GRO) in VLAN.

Co-developed-by: Karol Jurczenia <karol.jurczenia@xxxxxxxxx>
Signed-off-by: Karol Jurczenia <karol.jurczenia@xxxxxxxxx>
Reviewed-by: Sebastian Basierski <sebastian.basierski@xxxxxxxxx>
Reviewed-by: Cezary Rojewski <cezary.rojewski@xxxxxxxxx>
Signed-off-by: Piotr Warpechowski <piotr.warpechowski@xxxxxxxxx>
Signed-off-by: Konrad Leszczynski <konrad.leszczynski@xxxxxxxxx>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8977e5aebc71..630ffb8dd0c3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4590,13 +4590,14 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
*/
static bool stmmac_has_ip_ethertype(struct sk_buff *skb)
{
- int depth = 0;
+ int depth = 0, hlen;
__be16 proto;

- proto = __vlan_get_protocol(skb, eth_header_parse_protocol(skb),
- &depth);
+ proto = __vlan_get_protocol_offset(skb, skb->protocol,
+ skb_mac_offset(skb), &depth);
+ hlen = eth_type_vlan(skb->protocol) ? VLAN_ETH_HLEN : ETH_HLEN;

- return (depth <= ETH_HLEN) &&
+ return (depth <= hlen) &&
(proto == htons(ETH_P_IP) || proto == htons(ETH_P_IPV6));
}

--
2.34.1