git: 9aca51170316 - stable/13 - mlx5en: Share DEK objects with TLS RX.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Tue, 08 Feb 2022 15:13:54 UTC
The branch stable/13 has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=9aca51170316a1632dfc0186210fce7c35d10a50

commit 9aca51170316a1632dfc0186210fce7c35d10a50
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-02-08 15:08:52 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-02-08 15:08:52 +0000

    mlx5en: Share DEK objects with TLS RX.
    
    The TLS RX support also needs to be able to allocate DEK objects.
    Share the available objects 1:1.
    
    Sponsored by:   NVIDIA Networking
    
    (cherry picked from commit 75767cb88997b6b3fc99b2336de8398cff46db2a)
---
 sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
index 8140100685e1..57d77cc897db 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
@@ -121,7 +121,8 @@ mlx5e_tls_init(struct mlx5e_priv *priv)
 	struct sysctl_oid *node;
 	uint32_t x;
 
-	if (MLX5_CAP_GEN(priv->mdev, tls_tx) == 0)
+	if (MLX5_CAP_GEN(priv->mdev, tls_tx) == 0 ||
+	    MLX5_CAP_GEN(priv->mdev, log_max_dek) == 0)
 		return (0);
 
 	ptls->wq = create_singlethread_workqueue("mlx5-tls-wq");
@@ -136,7 +137,8 @@ mlx5e_tls_init(struct mlx5e_priv *priv)
 	ptls->zone = uma_zcreate(ptls->zname, sizeof(struct mlx5e_tls_tag),
 	    NULL, NULL, mlx5e_tls_tag_zinit, mlx5e_tls_tag_zfini, UMA_ALIGN_CACHE, 0);
 
-	ptls->max_resources = 1U << MLX5_CAP_GEN(priv->mdev, log_max_dek);
+	/* shared between RX and TX TLS */
+	ptls->max_resources = 1U << (MLX5_CAP_GEN(priv->mdev, log_max_dek) - 1);
 
 	for (x = 0; x != MLX5E_TLS_STATS_NUM; x++)
 		ptls->stats.arg[x] = counter_u64_alloc(M_WAITOK);
@@ -163,7 +165,7 @@ mlx5e_tls_cleanup(struct mlx5e_priv *priv)
 	struct mlx5e_tls *ptls = &priv->tls;
 	uint32_t x;
 
-	if (MLX5_CAP_GEN(priv->mdev, tls_tx) == 0)
+	if (ptls->init == 0)
 		return;
 
 	ptls->init = 0;