git: 0cd90ee598ce - main - mlx5: Fix HCA cap 2 query

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 03 Dec 2023 08:22:37 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=0cd90ee598cef68cef72db8b912241868d1067d0

commit 0cd90ee598cef68cef72db8b912241868d1067d0
Author:     Patrisious Haddad <phaddad@nvidia.com>
AuthorDate: 2023-05-11 09:48:26 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-12-03 08:21:44 +0000

    mlx5: Fix HCA cap 2 query
    
    Previously we were trying to set hca_cap_2 without checking if
    sw_vhca_id_valid max value, which is the only settable value inside
    hca_cap_2, and seeing that we dont have driver support for sw_vhca_id
    yet there is no need to set hca_cap_2 at all, it is enough to query it.
    
    Fixes: 7b959396ca6fae5635260131eedb9bc19f2726a3 ("mlx5: Introduce new destination type TABLE_TYPE")
    MFC after:      3 days
---
 sys/dev/mlx5/mlx5_core/mlx5_main.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/sys/dev/mlx5/mlx5_core/mlx5_main.c b/sys/dev/mlx5/mlx5_core/mlx5_main.c
index efaf726e19e5..f6dc1158f085 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_main.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_main.c
@@ -561,39 +561,15 @@ static int handle_hca_cap_atomic(struct mlx5_core_dev *dev)
 
 static int handle_hca_cap_2(struct mlx5_core_dev *dev)
 {
-	void *set_ctx;
-	void *set_hca_cap;
-	int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
 	int err;
 
 	if (MLX5_CAP_GEN_MAX(dev, hca_cap_2)) {
 		err = mlx5_core_get_caps(dev, MLX5_CAP_GENERAL_2);
 		if (err)
 			return err;
-	} else {
-		return 0;
 	}
 
-	/* To be added if sw_vhca support was added */
-	/*if (!MLX5_CAP_GEN_2_MAX(dev, sw_vhca_id_valid) ||
-	    !(dev->priv.sw_vhca_id > 0))
-		return 0;*/
-
-	set_ctx = kzalloc(set_sz, GFP_KERNEL);
-	if (!set_ctx)
-		return -ENOMEM;
-
-	MLX5_SET(set_hca_cap_in, set_ctx, op_mod,
-		 MLX5_CAP_GENERAL_2 << 1);
-	set_hca_cap = MLX5_ADDR_OF(set_hca_cap_in, set_ctx, capability);
-	memcpy(set_hca_cap, dev->hca_caps_cur[MLX5_CAP_GENERAL_2],
-	       MLX5_ST_SZ_BYTES(cmd_hca_cap_2));
-	//MLX5_SET(cmd_hca_cap_2, set_hca_cap, sw_vhca_id_valid, 1);
-
-	err = set_caps(dev, set_ctx, set_sz);
-
-	kfree(set_ctx);
-	return err;
+	return 0;
 }
 
 static int set_hca_ctrl(struct mlx5_core_dev *dev)