From: Moshe Shemesh Introduce mlx5_esw_sf_max_pf_functions() that queries a PF's max_num_sf and sf_base_id using mlx5_vport_get_other_func_general_cap(), which supports both function_id and vhca_id based addressing. Refactor mlx5_esw_sf_max_hpf_functions() into a thin wrapper that adds the host PF precondition checks and calls the new generic helper. Remove mlx5_query_hca_cap_host_pf() as it is not used anymore. This prepares for querying SFs info of Satellite PFs. Signed-off-by: Moshe Shemesh Signed-off-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index e75925a99852..815538ba754f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -2023,37 +2023,20 @@ void mlx5_eswitch_disable(struct mlx5_eswitch *esw) mlx5_lag_enable_change(esw->dev); } -static int mlx5_query_hca_cap_host_pf(struct mlx5_core_dev *dev, void *out) -{ - u16 opmod = (MLX5_CAP_GENERAL << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01); - u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)] = {}; - - MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP); - MLX5_SET(query_hca_cap_in, in, op_mod, opmod); - MLX5_SET(query_hca_cap_in, in, function_id, MLX5_VPORT_HOST_PF); - MLX5_SET(query_hca_cap_in, in, other_function, true); - return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out); -} - -int mlx5_esw_sf_max_hpf_functions(struct mlx5_core_dev *dev, u16 *max_sfs, u16 *sf_base_id) - +static int mlx5_esw_sf_max_pf_functions(struct mlx5_core_dev *dev, + u16 vport_num, u16 *max_sfs, + u16 *sf_base_id) { int query_out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out); void *query_ctx; void *hca_caps; int err; - if (!mlx5_core_is_ecpf(dev) || - !mlx5_esw_host_functions_enabled(dev)) { - *max_sfs = 0; - return 0; - } - query_ctx = kzalloc(query_out_sz, GFP_KERNEL); if (!query_ctx) return -ENOMEM; - err = mlx5_query_hca_cap_host_pf(dev, query_ctx); + err = mlx5_vport_get_other_func_general_cap(dev, vport_num, query_ctx); if (err) goto out_free; @@ -2066,6 +2049,19 @@ int mlx5_esw_sf_max_hpf_functions(struct mlx5_core_dev *dev, u16 *max_sfs, u16 * return err; } +int mlx5_esw_sf_max_hpf_functions(struct mlx5_core_dev *dev, u16 *max_sfs, + u16 *sf_base_id) +{ + if (!mlx5_core_is_ecpf(dev) || + !mlx5_esw_host_functions_enabled(dev)) { + *max_sfs = 0; + return 0; + } + + return mlx5_esw_sf_max_pf_functions(dev, MLX5_VPORT_HOST_PF, max_sfs, + sf_base_id); +} + int mlx5_esw_vport_alloc(struct mlx5_eswitch *esw, int index, u16 vport_num) { struct mlx5_vport *vport; -- 2.44.0