mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
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>
This commit is contained in:
parent
ed9671b8bd
commit
69978da9bb
|
|
@ -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 @@ 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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user