mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 06:01:53 +02:00
{rdma,net}/mlx5: export mlx5_vport_get_vhca_id
vhca id is already cached in the vport structure no need to query on every mlx5 layer, use the mlx5_vport_get_vhca_id, where possible. Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Reviewed-by: Mark Bloch <mbloch@nvidia.com> Reviewed-by: Parav Pandit <parav@nvidia.com> Signed-off-by: Alexei Lazar <alazar@nvidia.com> Reviewed-by: Feng Liu <feliu@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
This commit is contained in:
parent
1baf304265
commit
40653f280b
|
|
@ -83,33 +83,14 @@ static int fill_vport_icm_addr(struct mlx5_core_dev *mdev, u16 vport,
|
|||
static int fill_vport_vhca_id(struct mlx5_core_dev *mdev, u16 vport,
|
||||
struct mlx5_ib_uapi_query_port *info)
|
||||
{
|
||||
size_t out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out);
|
||||
u32 in[MLX5_ST_SZ_DW(query_hca_cap_in)] = {};
|
||||
void *out;
|
||||
int err;
|
||||
int err = mlx5_vport_get_vhca_id(mdev, vport, &info->vport_vhca_id);
|
||||
|
||||
out = kzalloc(out_sz, 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, other_function, true);
|
||||
MLX5_SET(query_hca_cap_in, in, function_id, vport);
|
||||
MLX5_SET(query_hca_cap_in, in, op_mod,
|
||||
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE |
|
||||
HCA_CAP_OPMOD_GET_CUR);
|
||||
|
||||
err = mlx5_cmd_exec(mdev, in, sizeof(in), out, out_sz);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
info->vport_vhca_id = MLX5_GET(query_hca_cap_out, out,
|
||||
capability.cmd_hca_cap.vhca_id);
|
||||
return err;
|
||||
|
||||
info->flags |= MLX5_IB_UAPI_QUERY_PORT_VPORT_VHCA_ID;
|
||||
out:
|
||||
kfree(out);
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fill_multiport_info(struct mlx5_ib_dev *dev, u32 port_num,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
|
||||
/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. */
|
||||
|
||||
#include <linux/mlx5/vport.h>
|
||||
|
||||
#include "reporter_vnic.h"
|
||||
#include "en_stats.h"
|
||||
#include "devlink.h"
|
||||
|
|
|
|||
|
|
@ -447,8 +447,6 @@ int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap
|
|||
#define mlx5_vport_get_other_func_general_cap(dev, vport, out) \
|
||||
mlx5_vport_get_other_func_cap(dev, vport, out, MLX5_CAP_GENERAL)
|
||||
|
||||
int mlx5_vport_get_vhca_id(struct mlx5_core_dev *dev, u16 vport, u16 *vhca_id);
|
||||
|
||||
static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev)
|
||||
{
|
||||
struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
|
||||
|
|
|
|||
|
|
@ -1199,22 +1199,28 @@ int mlx5hws_cmd_query_caps(struct mlx5_core_dev *mdev,
|
|||
int mlx5hws_cmd_query_gvmi(struct mlx5_core_dev *mdev, bool other_function,
|
||||
u16 vport_number, u16 *gvmi)
|
||||
{
|
||||
bool ec_vf_func = other_function ? 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;
|
||||
int err;
|
||||
|
||||
if (other_function) {
|
||||
err = mlx5_vport_get_vhca_id(mdev, vport_number, gvmi);
|
||||
if (!err)
|
||||
return 0;
|
||||
|
||||
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, other_function, other_function);
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
/* Copyright (c) 2019 Mellanox Technologies. */
|
||||
|
||||
#include "dr_types.h"
|
||||
#include "eswitch.h"
|
||||
|
||||
int mlx5dr_cmd_query_esw_vport_context(struct mlx5_core_dev *mdev,
|
||||
bool other_vport,
|
||||
|
|
@ -34,21 +35,28 @@ 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;
|
||||
int err;
|
||||
|
||||
if (other_vport) {
|
||||
err = mlx5_vport_get_vhca_id(mdev, vport_number, gvmi);
|
||||
if (!err)
|
||||
return 0;
|
||||
|
||||
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, other_function, other_vport);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -1239,7 +1239,9 @@ int mlx5_vport_get_vhca_id(struct mlx5_core_dev *dev, u16 vport, u16 *vhca_id)
|
|||
void *hca_caps;
|
||||
int err;
|
||||
|
||||
*vhca_id = 0;
|
||||
/* try get vhca_id via eswitch */
|
||||
if (mlx5_esw_vport_vhca_id(dev->priv.eswitch, vport, vhca_id))
|
||||
return 0;
|
||||
|
||||
query_ctx = kzalloc(query_out_sz, GFP_KERNEL);
|
||||
if (!query_ctx)
|
||||
|
|
@ -1256,6 +1258,7 @@ int mlx5_vport_get_vhca_id(struct mlx5_core_dev *dev, u16 vport, u16 *vhca_id)
|
|||
kfree(query_ctx);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mlx5_vport_get_vhca_id);
|
||||
|
||||
int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap,
|
||||
u16 vport, u16 opmod)
|
||||
|
|
|
|||
|
|
@ -135,4 +135,6 @@ int mlx5_nic_vport_unaffiliate_multiport(struct mlx5_core_dev *port_mdev);
|
|||
u64 mlx5_query_nic_system_image_guid(struct mlx5_core_dev *mdev);
|
||||
int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 vport, void *out,
|
||||
u16 opmod);
|
||||
int mlx5_vport_get_vhca_id(struct mlx5_core_dev *dev, u16 vport, u16 *vhca_id);
|
||||
|
||||
#endif /* __MLX5_VPORT_H__ */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user