* [PATCH net-next V2] net/mlx5: E-Switch, Size FDB peer groups for asymmetric peers
@ 2026-12-03 21:06 Tariq Toukan
2026-12-03 21:17 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2026-12-03 21:06 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni, Willem de Bruijn
Cc: Gal Pressman, Leon Romanovsky, linux-rdma, Mark Bloch,
Moshe Shemesh, Saeed Mahameed, Shay Drori, Tariq Toukan, Uri Dar
From: Uri Dar <udar@nvidia.com>
The slow path FDB send-to-vport and peer-miss groups are sized from the
local eswitch total_vports, assuming every eswitch that may pair has the
same number of vports. Per-PF VF configuration (e.g. PF_NUM_OF_VF set
differently per port) breaks that assumption: the larger peer installs
rules sized by its own total_vports into the smaller peer's groups,
which cannot hold them, so pairing fails.
In SW and HW steering the flow table is unbounded (max_fte is INT_MAX)
and flow groups are backed by dynamically grown matchers, so size the
peer dependent groups to the architectural vport maximum. FW steering,
whose table is bounded by log_max_ft_size, keeps the current sizing.
Signed-off-by: Uri Dar <udar@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Shay Drori <shayd@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../mellanox/mlx5/core/eswitch_offloads.c | 35 ++++++++++++-------
include/linux/mlx5/eswitch.h | 2 ++
2 files changed, 25 insertions(+), 12 deletions(-)
V2:
- Never size the groups below the local total_vports in SW and HW
steering, so they are not smaller than before when vport match
metadata is disabled and total_vports exceeds MLX5_ESW_MAX_VPORT_ID.
- Update the comment at the table_size calculation to describe the new
group sizing and why it may exceed table_size in SW and HW steering.
V1:
https://lore.kernel.org/all/20261116210917.1297111-1-tariqt@nvidia.com/
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 2072921c1fff..32eae1cd7b3a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -1744,6 +1744,18 @@ esw_chains_destroy(struct mlx5_eswitch *esw, struct mlx5_fs_chains *chains)
#endif
+/* SW and HW steering tables are unbounded, so they can be sized for any peer,
+ * and never below the local total_vports.
+ * FW steering is bounded by log_max_ft_size, so it uses local total_vports.
+ */
+static int esw_max_vports(const struct mlx5_eswitch *esw)
+{
+ if (esw->dev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS)
+ return esw->total_vports;
+
+ return max_t(int, esw->total_vports, MLX5_ESW_MAX_VPORT_ID);
+}
+
static int
esw_create_send_to_vport_group(struct mlx5_eswitch *esw,
struct mlx5_flow_table *fdb,
@@ -1771,7 +1783,9 @@ esw_create_send_to_vport_group(struct mlx5_eswitch *esw,
}
/* See comment at table_size calculation */
- count = MLX5_MAX_PORTS * (esw->total_vports * MAX_SQ_NVPORTS + MAX_PF_SQ);
+ count = MLX5_MAX_PORTS *
+ (esw_max_vports(esw) * MAX_SQ_NVPORTS + MAX_PF_SQ);
+
MLX5_SET(create_flow_group_in, flow_group_in, start_flow_index, 0);
MLX5_SET(create_flow_group_in, flow_group_in, end_flow_index, *ix + count - 1);
*ix += count;
@@ -1841,7 +1855,7 @@ esw_create_peer_esw_miss_group(struct mlx5_eswitch *esw,
u32 *flow_group_in,
int *ix)
{
- int max_peer_ports = (esw->total_vports - 1) * (MLX5_MAX_PORTS - 1);
+ int max_peer_ports = (esw_max_vports(esw) - 1) * (MLX5_MAX_PORTS - 1);
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
struct mlx5_flow_group *g;
void *match_criteria;
@@ -1959,16 +1973,13 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw)
goto ns_err;
}
- /* To be strictly correct:
- * MLX5_MAX_PORTS * (esw->total_vports * MAX_SQ_NVPORTS + MAX_PF_SQ)
- * should be:
- * esw->total_vports * MAX_SQ_NVPORTS + MAX_PF_SQ +
- * peer_esw->total_vports * MAX_SQ_NVPORTS + MAX_PF_SQ
- * but as the peer device might not be in switchdev mode it's not
- * possible. We use the fact that by default FW sets max vfs and max sfs
- * to the same value on both devices. If it needs to be changed in the future note
- * the peer miss group should also be created based on the number of
- * total vports of the peer (currently is also uses esw->total_vports).
+ /* The send-to-vport and peer miss groups also hold rules installed by
+ * peer eswitches, which may have more vports than this one, so they
+ * are sized by esw_max_vports(). In FW steering that is the local
+ * total_vports, matching table_size below, so peers are assumed to
+ * have the same number of vports. In SW and HW steering the groups
+ * are sized for any peer and extend past table_size, which is fine
+ * as those tables are unbounded (max_fte is set to INT_MAX).
*/
table_size = MLX5_MAX_PORTS * (esw->total_vports * MAX_SQ_NVPORTS + MAX_PF_SQ) +
esw->total_vports * MLX5_MAX_PORTS + MLX5_ESW_MISS_FLOWS;
diff --git a/include/linux/mlx5/eswitch.h b/include/linux/mlx5/eswitch.h
index 06d7d634de0d..fbfecbd67ea5 100644
--- a/include/linux/mlx5/eswitch.h
+++ b/include/linux/mlx5/eswitch.h
@@ -107,6 +107,8 @@ bool mlx5_eswitch_vport_match_metadata_enabled(const struct mlx5_eswitch *esw);
#define ESW_REG_C0_USER_DATA_METADATA_BITS (32 - ESW_SOURCE_PORT_METADATA_BITS)
#define ESW_REG_C0_USER_DATA_METADATA_MASK GENMASK(ESW_REG_C0_USER_DATA_METADATA_BITS - 1, 0)
+#define MLX5_ESW_MAX_VPORT_ID ((1 << ESW_VPORT_BITS) - 1)
+
static inline u32 mlx5_eswitch_get_vport_metadata_mask(void)
{
return GENMASK(31, 32 - ESW_SOURCE_PORT_METADATA_BITS);
base-commit: c1165beb053a652299b1503b2dd7674ced0b1596
--
2.44.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next V2] net/mlx5: E-Switch, Size FDB peer groups for asymmetric peers
2026-12-03 21:06 [PATCH net-next V2] net/mlx5: E-Switch, Size FDB peer groups for asymmetric peers Tariq Toukan
@ 2026-12-03 21:17 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-03 21:17 UTC (permalink / raw)
To: Tariq Toukan; +Cc: linux-rdma
> From: Uri Dar <udar@nvidia.com>
>
> The slow path FDB send-to-vport and peer-miss groups are sized from the
> local eswitch total_vports, assuming every eswitch that may pair has the
> same number of vports. Per-PF VF configuration (e.g. PF_NUM_OF_VF set
> differently per port) breaks that assumption: the larger peer installs
> rules sized by its own total_vports into the smaller peer's groups,
> which cannot hold them, so pairing fails.
>
> In SW and HW steering the flow table is unbounded (max_fte is INT_MAX)
> and flow groups are backed by dynamically grown matchers, so size the
> peer dependent groups to the architectural vport maximum. FW steering,
> whose table is bounded by log_max_ft_size, keeps the current sizing.
>
> Signed-off-by: Uri Dar <udar@nvidia.com>
> Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
> Reviewed-by: Shay Drori <shayd@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203210604.4092532-1-tariqt@nvidia.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 21:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 21:06 [PATCH net-next V2] net/mlx5: E-Switch, Size FDB peer groups for asymmetric peers Tariq Toukan
2026-12-03 21:17 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox