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.

net/mlx5: E-Switch, Set/Query hca cap via vhca id

Dynamically created vports require vhca id as input to set/query other
vport hca cap, when FW is capable and the vhca id of a vport is valid
use it instead of the local function id.

Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Adithya Jayachandran <ajayachandra@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Feng Liu <feliu@nvidia.com>
Reviewed-by: William Tu <witu@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>

+68 -5
+12
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
··· 840 840 return err; 841 841 } 842 842 843 + bool mlx5_esw_vport_vhca_id(struct mlx5_eswitch *esw, u16 vportn, u16 *vhca_id) 844 + { 845 + struct mlx5_vport *vport; 846 + 847 + vport = mlx5_eswitch_get_vport(esw, vportn); 848 + if (IS_ERR(vport) || MLX5_VPORT_INVAL_VHCA_ID(vport)) 849 + return false; 850 + 851 + *vhca_id = vport->vhca_id; 852 + return true; 853 + } 854 + 843 855 static int esw_vport_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport) 844 856 { 845 857 bool vst_mode_steering = esw_vst_mode_is_steering(esw);
+8
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
··· 833 833 void mlx5_esw_vport_vhca_id_unmap(struct mlx5_eswitch *esw, 834 834 struct mlx5_vport *vport); 835 835 int mlx5_eswitch_vhca_id_to_vport(struct mlx5_eswitch *esw, u16 vhca_id, u16 *vport_num); 836 + bool mlx5_esw_vport_vhca_id(struct mlx5_eswitch *esw, u16 vportn, u16 *vhca_id); 836 837 837 838 /** 838 839 * struct mlx5_esw_event_info - Indicates eswitch mode changed/changing. ··· 974 973 } 975 974 976 975 static inline void mlx5_eswitch_unblock_ipsec(struct mlx5_core_dev *dev) {} 976 + 977 + static inline bool 978 + mlx5_esw_vport_vhca_id(struct mlx5_eswitch *esw, u16 vportn, u16 *vhca_id) 979 + { 980 + return -EOPNOTSUPP; 981 + } 982 + 977 983 #endif /* CONFIG_MLX5_ESWITCH */ 978 984 979 985 #endif /* __MLX5_ESWITCH_H__ */
+48 -5
drivers/net/ethernet/mellanox/mlx5/core/vport.c
··· 36 36 #include <linux/mlx5/vport.h> 37 37 #include <linux/mlx5/eswitch.h> 38 38 #include "mlx5_core.h" 39 + #include "eswitch.h" 39 40 #include "sf/sf.h" 40 41 41 42 /* Mutex to hold while enabling or disabling RoCE */ ··· 1190 1189 } 1191 1190 EXPORT_SYMBOL_GPL(mlx5_query_nic_system_image_guid); 1192 1191 1192 + static bool mlx5_vport_use_vhca_id_as_func_id(struct mlx5_core_dev *dev, 1193 + u16 vport_num, u16 *vhca_id) 1194 + { 1195 + if (!MLX5_CAP_GEN_2(dev, function_id_type_vhca_id)) 1196 + return false; 1197 + 1198 + return mlx5_esw_vport_vhca_id(dev->priv.eswitch, vport_num, vhca_id); 1199 + } 1200 + 1193 1201 int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 vport, void *out, 1194 1202 u16 opmod) 1195 1203 { 1196 - bool ec_vf_func = mlx5_core_is_ec_vf_vport(dev, vport); 1197 1204 u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)] = {}; 1205 + u16 vhca_id = 0, function_id = 0; 1206 + bool ec_vf_func = false; 1207 + 1208 + /* if this vport is referring to a vport on the ec PF (embedded cpu ) 1209 + * let the FW know which domain we are querying since vport numbers or 1210 + * function_ids are not unique across the different PF domains, 1211 + * unless we use vhca_id as the function_id below. 1212 + */ 1213 + ec_vf_func = mlx5_core_is_ec_vf_vport(dev, vport); 1214 + function_id = mlx5_vport_to_func_id(dev, vport, ec_vf_func); 1215 + 1216 + if (mlx5_vport_use_vhca_id_as_func_id(dev, vport, &vhca_id)) { 1217 + MLX5_SET(query_hca_cap_in, in, function_id_type, 1); 1218 + function_id = vhca_id; 1219 + ec_vf_func = false; 1220 + mlx5_core_dbg(dev, "%s using vhca_id as function_id for vport %d vhca_id 0x%x\n", 1221 + __func__, vport, vhca_id); 1222 + } 1198 1223 1199 1224 opmod = (opmod << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01); 1200 1225 MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP); 1201 1226 MLX5_SET(query_hca_cap_in, in, op_mod, opmod); 1202 - MLX5_SET(query_hca_cap_in, in, function_id, mlx5_vport_to_func_id(dev, vport, ec_vf_func)); 1203 1227 MLX5_SET(query_hca_cap_in, in, other_function, true); 1204 1228 MLX5_SET(query_hca_cap_in, in, ec_vf_function, ec_vf_func); 1229 + MLX5_SET(query_hca_cap_in, in, function_id, function_id); 1205 1230 return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out); 1206 1231 } 1207 1232 EXPORT_SYMBOL_GPL(mlx5_vport_get_other_func_cap); ··· 1260 1233 int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap, 1261 1234 u16 vport, u16 opmod) 1262 1235 { 1263 - bool ec_vf_func = mlx5_core_is_ec_vf_vport(dev, vport); 1264 1236 int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in); 1237 + u16 vhca_id = 0, function_id = 0; 1238 + bool ec_vf_func = false; 1265 1239 void *set_hca_cap; 1266 1240 void *set_ctx; 1267 1241 int ret; ··· 1271 1243 if (!set_ctx) 1272 1244 return -ENOMEM; 1273 1245 1246 + /* if this vport is referring to a vport on the ec PF (embedded cpu ) 1247 + * let the FW know which domain we are querying since vport numbers or 1248 + * function_ids are not unique across the different PF domains, 1249 + * unless we use vhca_id as the function_id below. 1250 + */ 1251 + ec_vf_func = mlx5_core_is_ec_vf_vport(dev, vport); 1252 + function_id = mlx5_vport_to_func_id(dev, vport, ec_vf_func); 1253 + 1254 + if (mlx5_vport_use_vhca_id_as_func_id(dev, vport, &vhca_id)) { 1255 + MLX5_SET(set_hca_cap_in, set_ctx, function_id_type, 1); 1256 + function_id = vhca_id; 1257 + ec_vf_func = false; 1258 + mlx5_core_dbg(dev, "%s using vhca_id as function_id for vport %d vhca_id 0x%x\n", 1259 + __func__, vport, vhca_id); 1260 + } 1261 + 1274 1262 MLX5_SET(set_hca_cap_in, set_ctx, opcode, MLX5_CMD_OP_SET_HCA_CAP); 1275 1263 MLX5_SET(set_hca_cap_in, set_ctx, op_mod, opmod << 1); 1276 1264 set_hca_cap = MLX5_ADDR_OF(set_hca_cap_in, set_ctx, capability); 1277 1265 memcpy(set_hca_cap, hca_cap, MLX5_ST_SZ_BYTES(cmd_hca_cap)); 1278 - MLX5_SET(set_hca_cap_in, set_ctx, function_id, 1279 - mlx5_vport_to_func_id(dev, vport, ec_vf_func)); 1280 1266 MLX5_SET(set_hca_cap_in, set_ctx, other_function, true); 1281 1267 MLX5_SET(set_hca_cap_in, set_ctx, ec_vf_function, ec_vf_func); 1268 + MLX5_SET(set_hca_cap_in, set_ctx, function_id, function_id); 1282 1269 ret = mlx5_cmd_exec_in(dev, set_hca_cap, set_ctx); 1283 1270 1284 1271 kfree(set_ctx);