Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH net] net/mlx5: E-Switch, Fix offloaded nf flowtable rules never being hit
@ 2026-11-25 11:58 Tariq Toukan
  2026-11-26 11:58 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2026-11-25 11:58 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	netdev, Paolo Abeni, Willem de Bruijn
  Cc: Ariel Levkovich, Cosmin Ratiu, Gal Pressman, Leon Romanovsky,
	linux-rdma, Mark Bloch, Muhammad Zuhayr al-Tayyar, Roi Dayan,
	Saeed Mahameed, Saeed Mahameed, Tariq Toukan

In switchdev mode, nf flowtable entries offloaded to the FDB are
installed but never hit, and the traffic keeps going through the slow
path.

esw_chains_create() opens the nf flowtable chain, then the root table
(chain 0, prio 1), and only then sets the nf flowtable table as the end
table of the chains. mlx5_chains_create_prio() takes the miss
destination of a new prio from the end table when the prio is created,
which for the root is still the default table, i.e. the slow path. So
the root misses to the slow path, and the nf flowtable chain is never
reached.

Another chain 0 prio, e.g. of a tc rule, hides the issue: the root's
miss is rewired to it, and its own miss goes to the nf flowtable chain.
This stays so after that prio is destroyed, until the eswitch is set up
again. Setups that always have such a prio, like OVS, don't hit it.

Set the end table before opening the root, as it was before the
offending commit.

Tested on ConnectX-6 Dx in switchdev mode, with two VFs routed through
their representors and an nftables flowtable with offload on them.
Without this patch, the connections are HW_OFFLOAD but 99% of their
packets go through the representors until a chain 0 prio 2 tc rule is
added; with it, they are forwarded by the eswitch from the start, in
both SMFS and DMFS.

Fixes: ae430332557a ("net/mlx5: Refactor multi chains and prios support")
Reported-by: Muhammad Zuhayr al-Tayyar <mzuhayr@earthlink.iq>
Closes: https://lore.kernel.org/netdev/AM0PR02MB4307F6D53A2B0AD628D91C81C6682@AM0PR02MB4307.eurprd02.prod.outlook.com/
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 474784131091..f71cd0303592 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -1693,6 +1693,11 @@ esw_chains_create(struct mlx5_eswitch *esw, struct mlx5_flow_table *miss_fdb)
 		goto nf_ft_err;
 	}
 
+	/* Set the end table before opening the root, so that the root's
+	 * miss rule goes to the nf flowtable chain, not to the slow path.
+	 */
+	mlx5_chains_set_end_ft(chains, nf_ft);
+
 	/* Always open the root for fast path */
 	ft = mlx5_chains_get_table(chains, 0, 1, 0);
 	if (IS_ERR(ft)) {
@@ -1707,8 +1712,6 @@ esw_chains_create(struct mlx5_eswitch *esw, struct mlx5_flow_table *miss_fdb)
 			goto level_1_err;
 	}
 
-	mlx5_chains_set_end_ft(chains, nf_ft);
-
 	return 0;
 
 level_1_err:

base-commit: cc7fe6e741730fef549e484379281736d32746f0
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net/mlx5: E-Switch, Fix offloaded nf flowtable rules never being hit
  2026-11-25 11:58 [PATCH net] net/mlx5: E-Switch, Fix offloaded nf flowtable rules never being hit Tariq Toukan
@ 2026-11-26 11:58 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-26 11:58 UTC (permalink / raw)
  To: Tariq Toukan; +Cc: linux-rdma

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] net/mlx5: off-by-one FDB sub-namespace priority in
  esw_chains_create() [1]
--

commit 60c8dade186c303e933b7f1b16d70cd37bc59342
Author: Tariq Toukan <tariqt@nvidia.com>

net/mlx5: E-Switch, Fix offloaded nf flowtable rules never being hit

This commit sets the nf flowtable as the chains end table before creating
the root flow table in esw_chains_create(), ensuring the root table's miss
rule points to the nf flowtable chain rather than the slow path.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> index 4747841310914..f71cd03035924 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> @@ -1693,6 +1693,11 @@ esw_chains_create(struct mlx5_eswitch *esw, struct mlx5_flow_table *miss_fdb)
>  		goto nf_ft_err;
>  	}
>  
> +	/* Set the end table before opening the root, so that the root's
> +	 * miss rule goes to the nf flowtable chain, not to the slow path.
> +	 */
> +	mlx5_chains_set_end_ft(chains, nf_ft);
> +
>  	/* Always open the root for fast path */
>  	ft = mlx5_chains_get_table(chains, 0, 1, 0);
>  	if (IS_ERR(ft)) {
> @@ -1707,8 +1712,6 @@ esw_chains_create(struct mlx5_eswitch *esw, struct mlx5_flow_table *miss_fdb)
>  			goto level_1_err;
>  	}
>  
> -	mlx5_chains_set_end_ft(chains, nf_ft);
> -
>  	return 0;
>  
>  level_1_err:

[Severity: High]
This problem wasn't introduced by this patch, but does setting
attr.fs_base_prio to FDB_BYPASS_PATH (1) earlier in esw_chains_create()
cause an off-by-one priority lookup [1] when mlx5_chains_get_table()
creates managed FDB tables?

When mlx5_chains_create_table() creates a managed table in
MLX5_FLOW_NAMESPACE_FDB (the root table at chain 0, prio 1, level 0, or any
table when ignore_flow_level is not supported), it looks up the per-chain
sub-namespace and adds chains->fs_base_prio:

drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c:mlx5_chains_create_table() {
    ...
	if (!mlx5_chains_ignore_flow_level_supported(chains) ||
	    (chain == 0 && prio == 1 && level == 0)) {
		ft_attr.level = chains->fs_base_level;
		ft_attr.prio = chains->fs_base_prio + prio - 1;
		ns = (chains->ns == MLX5_FLOW_NAMESPACE_FDB) ?
			mlx5_get_fdb_sub_ns(chains->dev, chain) :
			mlx5_get_flow_namespace(chains->dev, chains->ns);
    ...
}

However, create_fdb_sub_ns_prio_chain() initializes each FDB sub-namespace
with 0-based priorities 0 through FDB_TC_MAX_PRIO - 1 (0..15).  Adding
FDB_BYPASS_PATH (1) places the root table at sub-namespace priority 1
instead of 0, and on devices without ignore_flow_level support, creating a
table at the maximum priority FDB_TC_MAX_PRIO (16) asks for ft_attr.prio =
16 and fails in find_prio() with -EINVAL.

[1] https://sashiko.dev/#/bug/linux-9702e5c8-96e6-42e9-a756-b9f79ba339e1

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125115815.87909-1-tariqt@nvidia.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-26 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 11:58 [PATCH net] net/mlx5: E-Switch, Fix offloaded nf flowtable rules never being hit Tariq Toukan
2026-11-26 11:58 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox