From 349d850df17e2287bd6b02766e30be79b701cd6e Mon Sep 17 00:00:00 2001
From: Maher Sanalla <msanalla@nvidia.com>
Date: Sun, 19 Jun 2022 13:34:23 +0300
Subject: mlx5: Adjust Crypto BSF size if signature is used

[ Upstream commit b38f3439a983f42dd5ac8f93f0813a969720225f ]

When a Mkey is configured with crypto and signature offload, the crypto
BSF size and signature BSF size should both be set to 128 Bytes.
Currently, when building the crypto BSF, we do not take into account
if signature mode is configured or not, and we set the crypto BSF size to
64 Bytes.

The situation above does not affect crypto configuration on CX6 HCA,
but will obstruct crypto traffic in more recent HCA's such as
CX6Dx and onwards.

Thus, check if signature mode is configured when building crypto bsf,
and set the bsf size accordingly.

Fixes: b5f0a5875380 ("mlx5: Add crypto setter for MKey")
Signed-off-by: Maher Sanalla <msanalla@nvidia.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
---
 providers/mlx5/qp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/providers/mlx5/qp.c b/providers/mlx5/qp.c
index d0e5a49..f9f3d1a 100644
--- a/providers/mlx5/qp.c
+++ b/providers/mlx5/qp.c
@@ -2414,7 +2414,8 @@ static int mlx5_umr_fill_crypto_bsf(struct mlx5_crypto_bsf *crypto_bsf,
 
 	memset(crypto_bsf, 0, sizeof(*crypto_bsf));
 
-	crypto_bsf->bsf_size_type |= MLX5_BSF_SIZE_WITH_INLINE
+	crypto_bsf->bsf_size_type |= (block ? MLX5_BSF_SIZE_SIG_AND_CRYPTO :
+					      MLX5_BSF_SIZE_WITH_INLINE)
 				     << MLX5_BSF_SIZE_SHIFT;
 	crypto_bsf->bsf_size_type |= MLX5_BSF_TYPE_CRYPTO;
 	order = get_crypto_order(attr->encrypt_on_tx,
-- 
2.34.1

