* [PATCH net] net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state
@ 2026-11-18 14:40 Tariq Toukan
2026-11-18 14:51 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2026-11-18 14:40 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni
Cc: Ben Ben-Ishay, Boris Pismenny, Cosmin Ratiu, Dragos Tatulea,
Gal Pressman, Khalid Manaa, Leon Romanovsky, open list,
linux-rdma, Mark Bloch, Saeed Mahameed, Tariq Toukan, William Tu
HW-GRO (SHAMPO) sessions are not terminated by HW when the kTLS RX
offload indication in the CQE changes. The driver applies the offload
metadata of the first packet in the session only, so ciphertext and
plaintext can end up in the same skb under a single skb->decrypted
indication, and resync requests carried by non-first packets are lost.
Do not merge a CQE whose decryption state differs from skb->decrypted,
which the first packet of the session sets. Never merge a CQE that
carries a resync request or a TLS error, so that each of them starts a
session and is handled.
The failure was reproduced on ConnectX-7 with HW GRO and kTLS RX offload
on and 0.3% loss added by netem on the sender's egress: TlsDecryptError
increased and the receiving sockets failed with EBADMSG. With this
patch, TlsDecryptError stays 0.
Fixes: 92552d3abd32 ("net/mlx5e: HW_GRO cqe handler implementation")
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
---
.../mellanox/mlx5/core/en_accel/en_accel.h | 5 +++--
.../mellanox/mlx5/core/en_accel/ktls_txrx.h | 21 +++++++++++++++++++
.../net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +-
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h
index 5a340f1435e6..554c225f7376 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h
@@ -219,9 +219,10 @@ static inline void mlx5e_accel_tx_finish(struct mlx5e_txqsq *sq,
}
static inline bool
-mlx5e_accel_shampo_can_merge(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
+mlx5e_accel_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
{
- return mlx5e_psp_shampo_can_merge(rq->hw_gro_data->skb, cqe);
+ return mlx5e_psp_shampo_can_merge(skb, cqe) &&
+ mlx5e_ktls_shampo_can_merge(skb, cqe);
}
static inline int mlx5e_accel_init_rx(struct mlx5e_priv *priv)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h
index 93bd383a23d8..20e5dc6a718e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h
@@ -60,6 +60,21 @@ mlx5e_ktls_handle_tx_wqe(struct mlx5_wqe_ctrl_seg *cseg,
{
cseg->tis_tir_num = cpu_to_be32(state->tls_tisn << 8);
}
+
+/* The first CQE of a HW-GRO session sets skb->decrypted. A resync request or
+ * a TLS error is handled on the first CQE only, so it starts a new session.
+ */
+static inline bool
+mlx5e_ktls_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+ u8 tls_offload = get_cqe_tls_offload(cqe);
+
+ if (unlikely(tls_offload > CQE_TLS_OFFLOAD_DECRYPTED))
+ return false;
+
+ return (tls_offload == CQE_TLS_OFFLOAD_DECRYPTED) ==
+ skb_is_decrypted(skb);
+}
#else
static inline bool
mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
@@ -93,6 +108,12 @@ static inline void mlx5e_ktls_handle_rx_skb(struct mlx5e_rq *rq,
u32 *cqe_bcnt)
{
}
+
+static inline bool
+mlx5e_ktls_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+ return true;
+}
#endif /* CONFIG_MLX5_EN_TLS */
#endif /* __MLX5E_TLS_TXRX_H__ */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 22fea4739a2c..1586cb2404c0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -2271,7 +2271,7 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq
if (*skb &&
!(match &&
mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt, page_size) &&
- mlx5e_accel_shampo_can_merge(rq, cqe))) {
+ mlx5e_accel_shampo_can_merge(*skb, cqe))) {
match = false;
mlx5e_shampo_flush_skb(rq, cqe, match);
}
base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
--
2.44.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state
2026-11-18 14:40 [PATCH net] net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state Tariq Toukan
@ 2026-11-18 14:51 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-18 14:51 UTC (permalink / raw)
To: Tariq Toukan; +Cc: linux-rdma
> HW-GRO (SHAMPO) sessions are not terminated by HW when the kTLS RX
> offload indication in the CQE changes. The driver applies the offload
> metadata of the first packet in the session only, so ciphertext and
> plaintext can end up in the same skb under a single skb->decrypted
> indication, and resync requests carried by non-first packets are lost.
>
> Do not merge a CQE whose decryption state differs from skb->decrypted,
> which the first packet of the session sets. Never merge a CQE that
> carries a resync request or a TLS error, so that each of them starts a
> session and is handled.
>
> The failure was reproduced on ConnectX-7 with HW GRO and kTLS RX offload
> on and 0.3% loss added by netem on the sender's egress: TlsDecryptError
> increased and the receiving sockets failed with EBADMSG. With this
> patch, TlsDecryptError stays 0.
>
> Fixes: 92552d3abd32 ("net/mlx5e: HW_GRO cqe handler implementation")
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118144042.1916204-1-tariqt@nvidia.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 14:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 14:40 [PATCH net] net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state Tariq Toukan
2026-11-18 14:51 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox