diff options
| author | Moshe Shemesh <moshe@nvidia.com> | 2026-05-21 14:08:33 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-05-25 23:48:51 +0300 |
| commit | 69978da9bb7101911ff0f17d922914af701f092b (patch) | |
| tree | 1284e0d39adba99466385f43af7259f29804c2e8 | |
| parent | ed9671b8bd4f084b9b2798d3892c3c83f3c1010c (diff) | |
| download | linux-69978da9bb7101911ff0f17d922914af701f092b.tar.xz | |
net/mlx5: Introduce generic helper for PF SFs info
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 <moshe@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260521110843.367329-3-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 38 |
1 files 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 921ef53dc074..f7fa5ef74201 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -2044,37 +2044,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; @@ -2087,6 +2070,19 @@ out_free: 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; |
