git: 75767cb88997 - main - mlx5en: Share DEK objects with TLS RX.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Tue, 01 Feb 2022 15:24:17 UTC
The branch main has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=75767cb88997b6b3fc99b2336de8398cff46db2a

commit 75767cb88997b6b3fc99b2336de8398cff46db2a
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-02-01 15:20:08 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-02-01 15:21:14 +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.
    
    MFC after:      1 week
    Sponsored by:   NVIDIA Networking
---
 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 01581693f744..f6ac2200f076 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
@@ -150,7 +150,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");
@@ -166,7 +167,8 @@ mlx5e_tls_init(struct mlx5e_priv *priv)
 	     sizeof(struct mlx5e_tls_tag), NULL, NULL, NULL, NULL,
 	     mlx5e_tls_tag_import, mlx5e_tls_tag_release, priv->mdev, 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);
@@ -193,7 +195,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;