mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
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>
This commit is contained in:
parent
2b204cdb12
commit
da0349d0ff
|
|
@ -273,7 +273,7 @@ struct mlx5_eswitch_fdb {
|
|||
struct mlx5_flow_group *send_to_vport_grp;
|
||||
struct mlx5_flow_group *send_to_vport_meta_grp;
|
||||
struct mlx5_flow_group *peer_miss_grp;
|
||||
struct mlx5_flow_handle **peer_miss_rules[MLX5_MAX_PORTS];
|
||||
struct xarray peer_miss_rules;
|
||||
struct mlx5_flow_group *miss_grp;
|
||||
struct mlx5_flow_handle **send_to_vport_meta_rules;
|
||||
struct mlx5_flow_handle *miss_rule_uni;
|
||||
|
|
|
|||
|
|
@ -1190,7 +1190,7 @@ static int esw_add_fdb_peer_miss_rules(struct mlx5_eswitch *esw,
|
|||
struct mlx5_flow_handle *flow;
|
||||
struct mlx5_vport *peer_vport;
|
||||
struct mlx5_flow_spec *spec;
|
||||
int err, pfindex;
|
||||
int err;
|
||||
unsigned long i;
|
||||
void *misc;
|
||||
|
||||
|
|
@ -1274,14 +1274,10 @@ static int esw_add_fdb_peer_miss_rules(struct mlx5_eswitch *esw,
|
|||
}
|
||||
}
|
||||
|
||||
pfindex = mlx5_get_dev_index(peer_dev);
|
||||
if (pfindex >= MLX5_MAX_PORTS) {
|
||||
esw_warn(esw->dev, "Peer dev index(%d) is over the max num defined(%d)\n",
|
||||
pfindex, MLX5_MAX_PORTS);
|
||||
err = -EINVAL;
|
||||
err = xa_insert(&esw->fdb_table.offloads.peer_miss_rules,
|
||||
MLX5_CAP_GEN(peer_dev, vhca_id), flows, GFP_KERNEL);
|
||||
if (err)
|
||||
goto add_ec_vf_flow_err;
|
||||
}
|
||||
esw->fdb_table.offloads.peer_miss_rules[pfindex] = flows;
|
||||
|
||||
kvfree(spec);
|
||||
return 0;
|
||||
|
|
@ -1323,12 +1319,13 @@ static void esw_del_fdb_peer_miss_rules(struct mlx5_eswitch *esw,
|
|||
struct mlx5_core_dev *peer_dev)
|
||||
{
|
||||
struct mlx5_eswitch *peer_esw = peer_dev->priv.eswitch;
|
||||
u16 peer_index = mlx5_get_dev_index(peer_dev);
|
||||
u16 peer_vhca_id = MLX5_CAP_GEN(peer_dev, vhca_id);
|
||||
struct mlx5_flow_handle **flows;
|
||||
struct mlx5_vport *peer_vport;
|
||||
unsigned long i;
|
||||
|
||||
flows = esw->fdb_table.offloads.peer_miss_rules[peer_index];
|
||||
flows = xa_erase(&esw->fdb_table.offloads.peer_miss_rules,
|
||||
peer_vhca_id);
|
||||
if (!flows)
|
||||
return;
|
||||
|
||||
|
|
@ -1353,7 +1350,6 @@ static void esw_del_fdb_peer_miss_rules(struct mlx5_eswitch *esw,
|
|||
}
|
||||
|
||||
kvfree(flows);
|
||||
esw->fdb_table.offloads.peer_miss_rules[peer_index] = NULL;
|
||||
}
|
||||
|
||||
static int esw_add_fdb_miss_rule(struct mlx5_eswitch *esw)
|
||||
|
|
@ -3250,6 +3246,7 @@ void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw,
|
|||
return;
|
||||
|
||||
xa_init(&esw->paired);
|
||||
xa_init(&esw->fdb_table.offloads.peer_miss_rules);
|
||||
esw->num_peers = 0;
|
||||
esw->devcom = mlx5_devcom_register_component(esw->dev->priv.devc,
|
||||
MLX5_DEVCOM_ESW_OFFLOADS,
|
||||
|
|
@ -3277,6 +3274,7 @@ void mlx5_esw_offloads_devcom_cleanup(struct mlx5_eswitch *esw)
|
|||
|
||||
mlx5_devcom_unregister_component(esw->devcom);
|
||||
xa_destroy(&esw->paired);
|
||||
xa_destroy(&esw->fdb_table.offloads.peer_miss_rules);
|
||||
esw->devcom = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user