From: Tariq Toukan <tariqt@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
"Saeed Mahameed" <saeedm@nvidia.com>,
Tariq Toukan <tariqt@nvidia.com>
Cc: Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Mark Bloch <mbloch@nvidia.com>, <linux-kernel@vger.kernel.org>,
<linux-rdma@vger.kernel.org>, <netdev@vger.kernel.org>,
Gal Pressman <gal@nvidia.com>,
Dragos Tatulea <dtatulea@nvidia.com>,
Moshe Shemesh <moshe@nvidia.com>, Shay Drory <shayd@nvidia.com>,
Alexei Lazar <alazar@nvidia.com>
Subject: [PATCH mlx5-next V2 5/9] net/mlx5: E-switch, modify peer miss rule index to vhca_id
Date: Mon, 9 Mar 2026 11:34:31 +0200 [thread overview]
Message-ID: <20260309093435.1850724-6-tariqt@nvidia.com> (raw)
In-Reply-To: <20260309093435.1850724-1-tariqt@nvidia.com>
From: Shay Drory <shayd@nvidia.com>
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>
---
.../net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +-
.../mellanox/mlx5/core/eswitch_offloads.c | 20 +++++++++----------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index 6841caef02d1..96309a732d50 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -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;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 1366f6e489bd..90e6f97bdf4a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -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;
}
--
2.44.0
next prev parent reply other threads:[~2026-03-09 9:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 9:34 [PATCH mlx5-next V2 0/9] mlx5-next updates 2026-03-09 Tariq Toukan
2026-03-09 9:34 ` [PATCH mlx5-next V2 1/9] net/mlx5: Add IFC bits for shared headroom pool PBMC support Tariq Toukan
2026-03-09 9:34 ` [PATCH mlx5-next V2 2/9] net/mlx5: Add silent mode set/query and VHCA RX IFC bits Tariq Toukan
2026-03-09 9:34 ` [PATCH mlx5-next V2 3/9] net/mlx5: LAG, replace pf array with xarray Tariq Toukan
2026-03-09 9:34 ` [PATCH mlx5-next V2 4/9] net/mlx5: LAG, use xa_alloc to manage LAG device indices Tariq Toukan
2026-03-09 9:34 ` Tariq Toukan [this message]
2026-03-09 9:34 ` [PATCH mlx5-next V2 6/9] net/mlx5: LAG, replace mlx5_get_dev_index with LAG sequence number Tariq Toukan
2026-03-09 9:34 ` [PATCH mlx5-next V2 7/9] net/mlx5: Add VHCA RX flow destination support for FW steering Tariq Toukan
2026-03-09 9:34 ` [PATCH mlx5-next V2 8/9] {net/RDMA}/mlx5: Add LAG demux table API and vport demux rules Tariq Toukan
2026-03-09 9:34 ` [PATCH mlx5-next V2 9/9] net/mlx5: Expose MLX5_UMR_ALIGN definition Tariq Toukan
2026-03-14 18:08 ` [PATCH mlx5-next V2 0/9] mlx5-next updates 2026-03-09 Tariq Toukan
2026-03-16 20:23 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260309093435.1850724-6-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=alazar@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=jgg@ziepe.ca \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=shayd@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox