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, modify peer miss rule index to vhca_id

Replace the fixed-size array peer_miss_rules[MLX5_MAX_PORTS], indexed
by physical function index, with an xarray indexed by vhca_id.

This decouples peer_miss_rules from mlx5_get_dev_index(), removing the
dependency on a PF-derived index and the arbitrary MLX5_MAX_PORTS bounds
check. Using vhca_id as the key simplifies insertion/removal logic and
scales better across multi-peer topologies.

Initialize and destroy the xarray alongside the existing esw->paired
xarray in mlx5_esw_offloads_devcom_init/cleanup respectively.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260309093435.1850724-6-tariqt@nvidia.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Shay Drory and committed by
Leon Romanovsky
da0349d0 2b204cdb

+10 -12
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
··· 273 273 struct mlx5_flow_group *send_to_vport_grp; 274 274 struct mlx5_flow_group *send_to_vport_meta_grp; 275 275 struct mlx5_flow_group *peer_miss_grp; 276 - struct mlx5_flow_handle **peer_miss_rules[MLX5_MAX_PORTS]; 276 + struct xarray peer_miss_rules; 277 277 struct mlx5_flow_group *miss_grp; 278 278 struct mlx5_flow_handle **send_to_vport_meta_rules; 279 279 struct mlx5_flow_handle *miss_rule_uni;
+9 -11
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
··· 1190 1190 struct mlx5_flow_handle *flow; 1191 1191 struct mlx5_vport *peer_vport; 1192 1192 struct mlx5_flow_spec *spec; 1193 - int err, pfindex; 1193 + int err; 1194 1194 unsigned long i; 1195 1195 void *misc; 1196 1196 ··· 1274 1274 } 1275 1275 } 1276 1276 1277 - pfindex = mlx5_get_dev_index(peer_dev); 1278 - if (pfindex >= MLX5_MAX_PORTS) { 1279 - esw_warn(esw->dev, "Peer dev index(%d) is over the max num defined(%d)\n", 1280 - pfindex, MLX5_MAX_PORTS); 1281 - err = -EINVAL; 1277 + err = xa_insert(&esw->fdb_table.offloads.peer_miss_rules, 1278 + MLX5_CAP_GEN(peer_dev, vhca_id), flows, GFP_KERNEL); 1279 + if (err) 1282 1280 goto add_ec_vf_flow_err; 1283 - } 1284 - esw->fdb_table.offloads.peer_miss_rules[pfindex] = flows; 1285 1281 1286 1282 kvfree(spec); 1287 1283 return 0; ··· 1319 1323 struct mlx5_core_dev *peer_dev) 1320 1324 { 1321 1325 struct mlx5_eswitch *peer_esw = peer_dev->priv.eswitch; 1322 - u16 peer_index = mlx5_get_dev_index(peer_dev); 1326 + u16 peer_vhca_id = MLX5_CAP_GEN(peer_dev, vhca_id); 1323 1327 struct mlx5_flow_handle **flows; 1324 1328 struct mlx5_vport *peer_vport; 1325 1329 unsigned long i; 1326 1330 1327 - flows = esw->fdb_table.offloads.peer_miss_rules[peer_index]; 1331 + flows = xa_erase(&esw->fdb_table.offloads.peer_miss_rules, 1332 + peer_vhca_id); 1328 1333 if (!flows) 1329 1334 return; 1330 1335 ··· 1350 1353 } 1351 1354 1352 1355 kvfree(flows); 1353 - esw->fdb_table.offloads.peer_miss_rules[peer_index] = NULL; 1354 1356 } 1355 1357 1356 1358 static int esw_add_fdb_miss_rule(struct mlx5_eswitch *esw) ··· 3246 3250 return; 3247 3251 3248 3252 xa_init(&esw->paired); 3253 + xa_init(&esw->fdb_table.offloads.peer_miss_rules); 3249 3254 esw->num_peers = 0; 3250 3255 esw->devcom = mlx5_devcom_register_component(esw->dev->priv.devc, 3251 3256 MLX5_DEVCOM_ESW_OFFLOADS, ··· 3274 3277 3275 3278 mlx5_devcom_unregister_component(esw->devcom); 3276 3279 xa_destroy(&esw->paired); 3280 + xa_destroy(&esw->fdb_table.offloads.peer_miss_rules); 3277 3281 esw->devcom = NULL; 3278 3282 } 3279 3283