net/mlx5: DR, update query of HCA caps for EC VFs
authorDaniel Jurgens <danielj@nvidia.com>
Tue, 13 Jun 2023 19:30:49 +0000 (22:30 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Fri, 16 Jun 2023 19:02:08 +0000 (12:02 -0700)
This change is needed to use EC VFs with metadata based steering.

There was an assumption that vport was equal to function ID. That's
not the case for EC VF functions. Adjust to function ID and set the
ec_vf_function bit accordingly.

Fixes: 9ac0b128248e ("net/mlx5: Update vport caps query/set for EC VFs")
Signed-off-by: Daniel Jurgens <danielj@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c
drivers/net/ethernet/mellanox/mlx5/core/vport.c

index 60673f98de2b027658496d1979d6db2126f20ab2..c4be257c043d4fe1702951b6178392b49b6e1ad4 100644 (file)
@@ -358,4 +358,11 @@ static inline bool mlx5_core_is_ec_vf_vport(const struct mlx5_core_dev *dev, u16
 
        return (vport_num >= base_vport && vport_num < max_vport);
 }
+
+static inline int mlx5_vport_to_func_id(const struct mlx5_core_dev *dev, u16 vport, bool ec_vf_func)
+{
+       return ec_vf_func ? vport - mlx5_core_ec_vf_vport_base(dev)
+                         : vport;
+}
+
 #endif /* __MLX5_CORE_H__ */
index 1aa525e509f109277b03d53c11f51e18886fde95..7491911ebcb50d00f608e046755b3834aa4848b0 100644 (file)
@@ -34,6 +34,7 @@ int mlx5dr_cmd_query_esw_vport_context(struct mlx5_core_dev *mdev,
 int mlx5dr_cmd_query_gvmi(struct mlx5_core_dev *mdev, bool other_vport,
                          u16 vport_number, u16 *gvmi)
 {
+       bool ec_vf_func = other_vport ? mlx5_core_is_ec_vf_vport(mdev, vport_number) : false;
        u32 in[MLX5_ST_SZ_DW(query_hca_cap_in)] = {};
        int out_size;
        void *out;
@@ -46,7 +47,8 @@ int mlx5dr_cmd_query_gvmi(struct mlx5_core_dev *mdev, bool other_vport,
 
        MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP);
        MLX5_SET(query_hca_cap_in, in, other_function, other_vport);
-       MLX5_SET(query_hca_cap_in, in, function_id, vport_number);
+       MLX5_SET(query_hca_cap_in, in, function_id, mlx5_vport_to_func_id(mdev, vport_number, ec_vf_func));
+       MLX5_SET(query_hca_cap_in, in, ec_vf_function, ec_vf_func);
        MLX5_SET(query_hca_cap_in, in, op_mod,
                 MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1 |
                 HCA_CAP_OPMOD_GET_CUR);
index 6d3984dd5b21e421a16184d5e455049fd4bdd3b3..5a31fb47ffa58bb23c84013b0a1f7f8983a787d4 100644 (file)
@@ -1161,12 +1161,6 @@ u64 mlx5_query_nic_system_image_guid(struct mlx5_core_dev *mdev)
 }
 EXPORT_SYMBOL_GPL(mlx5_query_nic_system_image_guid);
 
-static int mlx5_vport_to_func_id(const struct mlx5_core_dev *dev, u16 vport, bool ec_vf_func)
-{
-       return ec_vf_func ? vport - mlx5_core_ec_vf_vport_base(dev)
-                         : vport;
-}
-
 int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 vport, void *out,
                                  u16 opmod)
 {