[PATCH 6.18 029/122] net/mlx5e: dont assume psp tx skbs are ipv6 csum handling

Greg Kroah-Hartman
2026-02-04T15:31:24Z

From: Daniel Zahka <daniel.zahka@gmail.com>

[ Upstream commit a62f7d62d2b115e67c7224e36ace4ef12a9650b4 ]

mlx5e_psp_handle_tx_skb() assumes skbs are ipv6 when doing a partial
TCP checksum with tso. Make correctly mlx5e_psp_handle_tx_skb() handle
ipv4 packets.

Fixes: e5a1861a298e ("net/mlx5e: Implement PSP Tx data path")
Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Link: https://patch.msgid.link/20260126-dzahka-fix-tx-csum-partial-v2-1-0a905590ea5f@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../mellanox/mlx5/core/en_accel/psp_rxtx.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c
index 828bff1137aff..fa98d0074531b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c
@@ -177,8 +177,6 @@ bool mlx5e_psp_handle_tx_skb(struct net_device *netdev,
{
struct mlx5e_priv *priv = netdev_priv(netdev);
struct net *net = sock_net(skb->sk);
- const struct ipv6hdr *ip6;
- struct tcphdr *th;

if (!mlx5e_psp_set_state(priv, skb, psp_st))
return true;
@@ -189,11 +187,18 @@ bool mlx5e_psp_handle_tx_skb(struct net_device *netdev,
return false;
}
if (skb_is_gso(skb)) {
- ip6 = ipv6_hdr(skb);
- th = inner_tcp_hdr(skb);
+ int len = skb_shinfo(skb)->gso_size + inner_tcp_hdrlen(skb);
+ struct tcphdr *th = inner_tcp_hdr(skb);

- th->check = ~tcp_v6_check(skb_shinfo(skb)->gso_size + inner_tcp_hdrlen(skb), &ip6->saddr,
- &ip6->daddr, 0);
+ if (skb->protocol == htons(ETH_P_IP)) {
+ const struct iphdr *ip = ip_hdr(skb);
+
+ th->check = ~tcp_v4_check(len, ip->saddr, ip->daddr, 0);
+ } else {
+ const struct ipv6hdr *ip6 = ipv6_hdr(skb);
+
+ th->check = ~tcp_v6_check(len, &ip6->saddr, &ip6->daddr, 0);
+ }
}

return true;
--
2.51.0