From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381925; b=ZVsWm7wysaMuGU4kAw82HFxFxbBmbfAdN7CXmdV/3X5brOGwKPaBzdi+4uDStK4bbqsc Zzy68KYZYbf9nIPdlOUKylTK6wsOsuMS8hVBGvYfjyksttmDe7EqfuDya/ykEjcJBP2ds x5ujz2A+lw5kZlRRTbNzhg7O8rBpO5tFQEz9MVYocb6kGLHtJruXBOGS1ratde78hozWt UBuQGUQeWS7lfyexMXKXTFYYfNhs0TbMDa7rahcQtOA+du9PBNaR9uWaquBLyY3GUncvM w82NUnTMIZXPxtEbFwpf40I32wCWmCvEtNDXheYpbj+MupQikl3MoHElyvEF8MjDH/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381925; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=DX1l3wPThu6rva+m2AIyS2ip7IprOa+b4EtE2me8h1E=; b=vX23j4zB8r/ZHCnuXYdv/NpSx7HCll9B+7fEWf2JMYIzmPp47gupUAFm8nXWcKrqk35b U/nl5E+oFDUbMy1l7qUDwuSnSCh9mQTnpzZfiwWUoJTRzamURSL5xBc44547TpA3a1IEq 52U668waCfYQ26GZTFGvogBTPbSlmfGKau+frEKTDANYpsxxe2owzMhOghA5jlZvYdYjG i/E+cXOm2D8qcWObhuIbvFK4Ep08rdxwIdox5j3YW6P8KKj6zZ6C6V1JewnzMqXXweRGC D7iVuMKRZ3l9p9osJN4/NBQQGBSLBtu8fg6GpQNUKqR/1GtJN4xBhR7Ycxq8sfdXEAA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=WwDpFR4Y; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B697606A32C; Fri, 4 Dec 2026 10:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=WwDpFR4Y Received: by smtp.kernel.org (Postfix) with ESMTPSA id A21181F000C2; Fri, 4 Dec 2026 10:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381925; bh=DX1l3wPThu6rva+m2AIyS2ip7IprOa+b4EtE2me8h1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WwDpFR4YG0/GCtNH/h1YLXGVzqnk3vHKcnJI8dBk5XpOFr+9UbSHr9I3rNSDIoIeX Gpe24W9r8buekkTzlqBmNV3vhDTLXN3XSU6ukCGZ/HoPFKHaK5uYXbW88JgIq0j30t 9RY/ADqap9oj1E7pwH+ge2szodMBj0omVB30P3aA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tariq Toukan , Gal Pressman , Cosmin Ratiu , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 191/703] net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state Date: Fri, 4 Dec 2026 19:01:30 +0900 Message-ID: <20261204100632.941227967@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tariq Toukan [ Upstream commit e421df3c838692c0c3503768ec3c9183f6df77aa ] 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 Reviewed-by: Gal Pressman Reviewed-by: Cosmin Ratiu Link: https://patch.msgid.link/20261118144042.1916204-1-tariqt@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- .../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 a276abebfb016..cde72fa7ba002 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 @@ -236,9 +236,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 cb08799769ee1..a65dc7604d65a 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 @@ -59,6 +59,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, @@ -92,6 +107,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 b651b28dd2ed3..fdc3aa1c2f6b9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -2415,7 +2415,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); } -- 2.53.0