Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

{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>

+35 -35
+4 -23
drivers/infiniband/hw/mlx5/std_types.c
··· 83 83 static int fill_vport_vhca_id(struct mlx5_core_dev *mdev, u16 vport, 84 84 struct mlx5_ib_uapi_query_port *info) 85 85 { 86 - size_t out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out); 87 - u32 in[MLX5_ST_SZ_DW(query_hca_cap_in)] = {}; 88 - void *out; 89 - int err; 86 + int err = mlx5_vport_get_vhca_id(mdev, vport, &info->vport_vhca_id); 90 87 91 - out = kzalloc(out_sz, GFP_KERNEL); 92 - if (!out) 93 - return -ENOMEM; 94 - 95 - MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP); 96 - MLX5_SET(query_hca_cap_in, in, other_function, true); 97 - MLX5_SET(query_hca_cap_in, in, function_id, vport); 98 - MLX5_SET(query_hca_cap_in, in, op_mod, 99 - MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE | 100 - HCA_CAP_OPMOD_GET_CUR); 101 - 102 - err = mlx5_cmd_exec(mdev, in, sizeof(in), out, out_sz); 103 88 if (err) 104 - goto out; 105 - 106 - info->vport_vhca_id = MLX5_GET(query_hca_cap_out, out, 107 - capability.cmd_hca_cap.vhca_id); 89 + return err; 108 90 109 91 info->flags |= MLX5_IB_UAPI_QUERY_PORT_VPORT_VHCA_ID; 110 - out: 111 - kfree(out); 112 - return err; 92 + 93 + return 0; 113 94 } 114 95 115 96 static int fill_multiport_info(struct mlx5_ib_dev *dev, u32 port_num,
+2
drivers/net/ethernet/mellanox/mlx5/core/diag/reporter_vnic.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB 2 2 /* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. */ 3 3 4 + #include <linux/mlx5/vport.h> 5 + 4 6 #include "reporter_vnic.h" 5 7 #include "en_stats.h" 6 8 #include "devlink.h"
-2
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
··· 447 447 #define mlx5_vport_get_other_func_general_cap(dev, vport, out) \ 448 448 mlx5_vport_get_other_func_cap(dev, vport, out, MLX5_CAP_GENERAL) 449 449 450 - int mlx5_vport_get_vhca_id(struct mlx5_core_dev *dev, u16 vport, u16 *vhca_id); 451 - 452 450 static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev) 453 451 { 454 452 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
+11 -5
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/cmd.c
··· 1199 1199 int mlx5hws_cmd_query_gvmi(struct mlx5_core_dev *mdev, bool other_function, 1200 1200 u16 vport_number, u16 *gvmi) 1201 1201 { 1202 - bool ec_vf_func = other_function ? mlx5_core_is_ec_vf_vport(mdev, vport_number) : false; 1203 1202 u32 in[MLX5_ST_SZ_DW(query_hca_cap_in)] = {}; 1204 1203 int out_size; 1205 1204 void *out; 1206 1205 int err; 1207 1206 1207 + if (other_function) { 1208 + err = mlx5_vport_get_vhca_id(mdev, vport_number, gvmi); 1209 + if (!err) 1210 + return 0; 1211 + 1212 + mlx5_core_err(mdev, "Failed to get vport vhca id for vport %d\n", 1213 + vport_number); 1214 + return err; 1215 + } 1216 + 1217 + /* get vhca_id for `this` function */ 1208 1218 out_size = MLX5_ST_SZ_BYTES(query_hca_cap_out); 1209 1219 out = kzalloc(out_size, GFP_KERNEL); 1210 1220 if (!out) 1211 1221 return -ENOMEM; 1212 1222 1213 1223 MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP); 1214 - MLX5_SET(query_hca_cap_in, in, other_function, other_function); 1215 - MLX5_SET(query_hca_cap_in, in, function_id, 1216 - mlx5_vport_to_func_id(mdev, vport_number, ec_vf_func)); 1217 - MLX5_SET(query_hca_cap_in, in, ec_vf_function, ec_vf_func); 1218 1224 MLX5_SET(query_hca_cap_in, in, op_mod, 1219 1225 MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1 | HCA_CAP_OPMOD_GET_CUR); 1220 1226
+12 -4
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_cmd.c
··· 2 2 /* Copyright (c) 2019 Mellanox Technologies. */ 3 3 4 4 #include "dr_types.h" 5 + #include "eswitch.h" 5 6 6 7 int mlx5dr_cmd_query_esw_vport_context(struct mlx5_core_dev *mdev, 7 8 bool other_vport, ··· 35 34 int mlx5dr_cmd_query_gvmi(struct mlx5_core_dev *mdev, bool other_vport, 36 35 u16 vport_number, u16 *gvmi) 37 36 { 38 - bool ec_vf_func = other_vport ? mlx5_core_is_ec_vf_vport(mdev, vport_number) : false; 39 37 u32 in[MLX5_ST_SZ_DW(query_hca_cap_in)] = {}; 40 38 int out_size; 41 39 void *out; 42 40 int err; 43 41 42 + if (other_vport) { 43 + err = mlx5_vport_get_vhca_id(mdev, vport_number, gvmi); 44 + if (!err) 45 + return 0; 46 + 47 + mlx5_core_err(mdev, "Failed to get vport vhca id for vport %d\n", 48 + vport_number); 49 + return err; 50 + } 51 + 52 + /* get vhca_id for `this` function */ 44 53 out_size = MLX5_ST_SZ_BYTES(query_hca_cap_out); 45 54 out = kzalloc(out_size, GFP_KERNEL); 46 55 if (!out) 47 56 return -ENOMEM; 48 57 49 58 MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP); 50 - MLX5_SET(query_hca_cap_in, in, other_function, other_vport); 51 - MLX5_SET(query_hca_cap_in, in, function_id, mlx5_vport_to_func_id(mdev, vport_number, ec_vf_func)); 52 - MLX5_SET(query_hca_cap_in, in, ec_vf_function, ec_vf_func); 53 59 MLX5_SET(query_hca_cap_in, in, op_mod, 54 60 MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE << 1 | 55 61 HCA_CAP_OPMOD_GET_CUR);
+4 -1
drivers/net/ethernet/mellanox/mlx5/core/vport.c
··· 1239 1239 void *hca_caps; 1240 1240 int err; 1241 1241 1242 - *vhca_id = 0; 1242 + /* try get vhca_id via eswitch */ 1243 + if (mlx5_esw_vport_vhca_id(dev->priv.eswitch, vport, vhca_id)) 1244 + return 0; 1243 1245 1244 1246 query_ctx = kzalloc(query_out_sz, GFP_KERNEL); 1245 1247 if (!query_ctx) ··· 1258 1256 kfree(query_ctx); 1259 1257 return err; 1260 1258 } 1259 + EXPORT_SYMBOL_GPL(mlx5_vport_get_vhca_id); 1261 1260 1262 1261 int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap, 1263 1262 u16 vport, u16 opmod)
+2
include/linux/mlx5/vport.h
··· 135 135 u64 mlx5_query_nic_system_image_guid(struct mlx5_core_dev *mdev); 136 136 int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 vport, void *out, 137 137 u16 opmod); 138 + int mlx5_vport_get_vhca_id(struct mlx5_core_dev *dev, u16 vport, u16 *vhca_id); 139 + 138 140 #endif /* __MLX5_VPORT_H__ */