git: 8c5cc4498499 - stable/15 - mlx5en: destroy TIR before DEK during TLS RX teardown

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 13 May 2026 00:24:25 UTC
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=8c5cc4498499f9e3bb64cb6e8244ccd212ee514a

commit 8c5cc4498499f9e3bb64cb6e8244ccd212ee514a
Author:     Ariel Ehrenberg <aehrenberg@nvidia.com>
AuthorDate: 2026-04-15 21:45:07 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-05-13 00:23:53 +0000

    mlx5en: destroy TIR before DEK during TLS RX teardown
    
    (cherry picked from commit bf636accdde4bb9af2c6c07af5420dffffd82332)
---
 sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c
index 89d2010656c5..b6a9a0c01d09 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c
@@ -596,14 +596,21 @@ mlx5e_tls_rx_work(struct work_struct *work)
 		if (ptag->flow_rule != NULL)
 			mlx5e_accel_fs_del_inpcb(ptag->flow_rule);
 
+		/*
+		 * Destroy TIR before DEK.  DESTROY_TIR for a TLS-
+		 * enabled TIR issues a TRA RX fence that drains all
+		 * in-flight packets from the crypto pipeline.  If the
+		 * DEK were destroyed first, packets still in flight
+		 * would hit a TPT encryption error (vendor syndrome
+		 * 0x55) because the key they reference is already gone.
+		 */
+		if (ptag->tirn != 0)
+			mlx5_tls_close_tir(priv->mdev, ptag->tirn);
+
 		/* try to destroy DEK context by ID */
 		if (ptag->dek_index_ok)
 			mlx5_encryption_key_destroy(priv->mdev, ptag->dek_index);
 
-		/* try to destroy TIR context by ID */
-		if (ptag->tirn != 0)
-			mlx5_tls_close_tir(priv->mdev, ptag->tirn);
-
 		/* free tag */
 		mlx5e_tls_rx_tag_zfree(ptag);
 		break;