net/mlx5: {DR,HWS}, Use the cached vhca_id for this device
The mlx5 driver caches many capabilities to be used by mlx5 layers. In SW and HW steering we can use the cached vhca_id instead of invoking FW commands. Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250829223722.900629-8-saeed@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
5d8ae2c2cf
commit
0c2a02f3c0
@@ -1200,40 +1200,20 @@ out:
|
||||
int mlx5hws_cmd_query_gvmi(struct mlx5_core_dev *mdev, bool other_function,
|
||||
u16 vport_number, u16 *gvmi)
|
||||
{
|
||||
u32 in[MLX5_ST_SZ_DW(query_hca_cap_in)] = {};
|
||||
int out_size;
|
||||
void *out;
|
||||
int err;
|
||||
|
||||
if (other_function) {
|
||||
err = mlx5_vport_get_vhca_id(mdev, vport_number, gvmi);
|
||||
if (!err)
|
||||
return 0;
|
||||
if (!other_function) {
|
||||
/* self vhca_id */
|
||||
*gvmi = MLX5_CAP_GEN(mdev, vhca_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = mlx5_vport_get_vhca_id(mdev, vport_number, gvmi);
|
||||
if (err) {
|
||||
mlx5_core_err(mdev, "Failed to get vport vhca id for vport %d\n",
|
||||
vport_number);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* get vhca_id for `this` function */
|
||||
out_size = MLX5_ST_SZ_BYTES(query_hca_cap_out);
|
||||
out = kzalloc(out_size, GFP_KERNEL);
|
||||
if (!out)
|
||||
return -ENOMEM;
|
||||
|
||||
MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP);
|
||||
MLX5_SET(query_hca_cap_in, in, op_mod,
|
||||
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1 | HCA_CAP_OPMOD_GET_CUR);
|
||||
|
||||
err = mlx5_cmd_exec_inout(mdev, query_hca_cap, in, out);
|
||||
if (err) {
|
||||
kfree(out);
|
||||
return err;
|
||||
}
|
||||
|
||||
*gvmi = MLX5_GET(query_hca_cap_out, out, capability.cmd_hca_cap.vhca_id);
|
||||
|
||||
kfree(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -35,41 +35,21 @@ 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)
|
||||
{
|
||||
u32 in[MLX5_ST_SZ_DW(query_hca_cap_in)] = {};
|
||||
int out_size;
|
||||
void *out;
|
||||
int err;
|
||||
|
||||
if (other_vport) {
|
||||
err = mlx5_vport_get_vhca_id(mdev, vport_number, gvmi);
|
||||
if (!err)
|
||||
return 0;
|
||||
if (!other_vport) {
|
||||
/* self vhca_id */
|
||||
*gvmi = MLX5_CAP_GEN(mdev, vhca_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = mlx5_vport_get_vhca_id(mdev, vport_number, gvmi);
|
||||
if (err) {
|
||||
mlx5_core_err(mdev, "Failed to get vport vhca id for vport %d\n",
|
||||
vport_number);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* get vhca_id for `this` function */
|
||||
out_size = MLX5_ST_SZ_BYTES(query_hca_cap_out);
|
||||
out = kzalloc(out_size, GFP_KERNEL);
|
||||
if (!out)
|
||||
return -ENOMEM;
|
||||
|
||||
MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP);
|
||||
MLX5_SET(query_hca_cap_in, in, op_mod,
|
||||
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1 |
|
||||
HCA_CAP_OPMOD_GET_CUR);
|
||||
|
||||
err = mlx5_cmd_exec_inout(mdev, query_hca_cap, in, out);
|
||||
if (err) {
|
||||
kfree(out);
|
||||
return err;
|
||||
}
|
||||
|
||||
*gvmi = MLX5_GET(query_hca_cap_out, out, capability.cmd_hca_cap.vhca_id);
|
||||
|
||||
kfree(out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user