* [PATCH net-next v2 01/10] bnxt_en: require an exact tunnel id in TC flows
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-17 9:29 ` [PATCH net-next v2 02/10] cxgb4: flower: refuse a tunnel key wider than the VNI Alexandre Cassen
` (8 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers
bnxt programs the value of enc_key_id and never reads its mask. Flower is
about to accept partial masks. bnxt would offload them as an exact match
on the masked key. Reject them like the other exact fields.
Found by an AI code review agent while auditing the users of enc_key_id.
Build tested only.
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
index c6b4a14c0e6e..e493c85ecf28 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
@@ -1081,6 +1081,13 @@ static bool bnxt_tc_can_offload(struct bnxt *bp, struct bnxt_tc_flow *flow)
return false;
}
+ /* Currently tunnel id cannot be partial wildcard */
+ if ((flow->flags & BNXT_TC_FLOW_FLAGS_TUNL_ID) &&
+ flow->tun_mask.tun_id != key32_to_tunnel_id(cpu_to_be32(U32_MAX))) {
+ netdev_info(bp->dev, "Wildcard match unsupported for tunnel id\n");
+ return false;
+ }
+
/* Currently Ethertype must be set */
if (!is_exactmatch(&flow->l2_mask.ether_type,
sizeof(flow->l2_mask.ether_type))) {
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH net-next v2 02/10] cxgb4: flower: refuse a tunnel key wider than the VNI
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
2026-11-17 9:29 ` [PATCH net-next v2 01/10] bnxt_en: require an exact tunnel id in TC flows Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-17 14:05 ` Potnuri Bharat Teja
2026-11-17 9:29 ` [PATCH net-next v2 03/10] nfp: " Alexandre Cassen
` (7 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers
cxgb4 holds a 24 bit VNI and truncates the key and the mask of enc_key_id.
An exact key above bit 23 already selects the wrong VNI. Flower is about
to accept partial masks. A mask that only covers bits above 23 would then
clear the VNI mask and encap_vld. The rule would match any traffic its
other keys allow. Refuse a key that no VNI can match and a mask that
leaves no VNI bit.
Found by an AI code review agent while auditing the users of enc_key_id.
Confirmed by code inspection. The wrong match was not triggered. Build
tested only.
Fixes: 98f3697f8d41 ("cxgb4: add tc flower match support for tunnel VNI")
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
.../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
index 3307e5042681..467f055e318c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
@@ -316,6 +316,21 @@ static int cxgb4_validate_flow_match(struct netlink_ext_ack *extack,
return -EOPNOTSUPP;
}
+ if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
+ struct flow_match_enc_keyid match;
+ u32 key, mask;
+
+ flow_rule_match_enc_keyid(rule, &match);
+ key = be32_to_cpu(match.key->keyid);
+ mask = be32_to_cpu(match.mask->keyid);
+ if (key >> ENCAP_VNI_BITWIDTH ||
+ !(mask & GENMASK(ENCAP_VNI_BITWIDTH - 1, 0))) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Tunnel key does not fit the 24 bit VNI");
+ return -EOPNOTSUPP;
+ }
+ }
+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
struct flow_match_basic match;
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH net-next v2 02/10] cxgb4: flower: refuse a tunnel key wider than the VNI
2026-11-17 9:29 ` [PATCH net-next v2 02/10] cxgb4: flower: refuse a tunnel key wider than the VNI Alexandre Cassen
@ 2026-11-17 14:05 ` Potnuri Bharat Teja
0 siblings, 0 replies; 17+ messages in thread
From: Potnuri Bharat Teja @ 2026-11-17 14:05 UTC (permalink / raw)
To: Alexandre Cassen
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Michael Chan, Pavan Chebbi, Donald Hunter, Jonathan Corbet,
Shuah Khan, Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
oss-drivers@corigine.com
On Tuesday, November 11/17/26, 2026 at 14:59:05 +0530, Alexandre Cassen wrote:
> cxgb4 holds a 24 bit VNI and truncates the key and the mask of enc_key_id.
> An exact key above bit 23 already selects the wrong VNI. Flower is about
> to accept partial masks. A mask that only covers bits above 23 would then
> clear the VNI mask and encap_vld. The rule would match any traffic its
> other keys allow. Refuse a key that no VNI can match and a mask that
> leaves no VNI bit.
>
> Found by an AI code review agent while auditing the users of enc_key_id.
> Confirmed by code inspection. The wrong match was not triggered. Build
> tested only.
>
> Fixes: 98f3697f8d41 ("cxgb4: add tc flower match support for tunnel VNI")
> Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
> ---
> .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
> index 3307e5042681..467f055e318c 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
> @@ -316,6 +316,21 @@ static int cxgb4_validate_flow_match(struct netlink_ext_ack *extack,
> return -EOPNOTSUPP;
> }
>
> + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
> + struct flow_match_enc_keyid match;
> + u32 key, mask;
> +
> + flow_rule_match_enc_keyid(rule, &match);
> + key = be32_to_cpu(match.key->keyid);
> + mask = be32_to_cpu(match.mask->keyid);
> + if (key >> ENCAP_VNI_BITWIDTH ||
> + !(mask & GENMASK(ENCAP_VNI_BITWIDTH - 1, 0))) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Tunnel key does not fit the 24 bit VNI");
> + return -EOPNOTSUPP;
> + }
> + }
> +
Thanks for the change. the 24-bit vni bitfield silently truncated wider keys and masks.
Reviewed-by: Potnuri Bharat Teja <bharat@chelsio.com>
> if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
> struct flow_match_basic match;
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net-next v2 03/10] nfp: flower: refuse a tunnel key wider than the VNI
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
2026-11-17 9:29 ` [PATCH net-next v2 01/10] bnxt_en: require an exact tunnel id in TC flows Alexandre Cassen
2026-11-17 9:29 ` [PATCH net-next v2 02/10] cxgb4: flower: refuse a tunnel key wider than the VNI Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-17 9:29 ` [PATCH net-next v2 04/10] net/mlx5e: TC, " Alexandre Cassen
` (6 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers
VXLAN and GENEVE rules shift the key and the mask of enc_key_id into a 24
bit VNI. An exact key above bit 23 already selects the wrong VNI. Flower
is about to accept partial masks. A mask that only covers bits above 23
would then match any VNI. Refuse a key that no VNI can match. GRE keeps
its 32 bit key.
Found by an AI code review agent while auditing the users of enc_key_id.
Confirmed by code inspection. The wrong match was not triggered. Build
tested only.
Fixes: 611aec101ab7 ("nfp: compile flower vxlan tunnel metadata match fields")
Fixes: bedeca15afd8 ("nfp: flower: compile Geneve match fields")
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
.../ethernet/netronome/nfp/flower/offload.c | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c
index 161190200dbd..a560cdef8d23 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/offload.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c
@@ -150,6 +150,24 @@ static bool nfp_flower_check_higher_than_l3(struct flow_rule *rule)
flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ICMP);
}
+static int
+nfp_flower_check_tun_vni(struct flow_rule *rule,
+ struct netlink_ext_ack *extack)
+{
+ struct flow_match_enc_keyid enc_keyid;
+
+ if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID))
+ return 0;
+
+ flow_rule_match_enc_keyid(rule, &enc_keyid);
+ if (be32_to_cpu(enc_keyid.key->keyid) < VXLAN_N_VID)
+ return 0;
+
+ NL_SET_ERR_MSG_MOD(extack,
+ "unsupported offload: tunnel key does not fit the 24 bit VNI");
+ return -EOPNOTSUPP;
+}
+
static int
nfp_flower_calc_opt_layer(struct flow_dissector_key_enc_opts *enc_opts,
u32 *key_layer_two, int *key_size, bool ipv6,
@@ -411,6 +429,10 @@ nfp_flower_calculate_key_layers(struct nfp_app *app,
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: ingress netdev does not match the expected tunnel type");
return -EOPNOTSUPP;
}
+
+ err = nfp_flower_check_tun_vni(rule, extack);
+ if (err)
+ return err;
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH net-next v2 04/10] net/mlx5e: TC, refuse a tunnel key wider than the VNI
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
` (2 preceding siblings ...)
2026-11-17 9:29 ` [PATCH net-next v2 03/10] nfp: " Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-17 9:29 ` [PATCH net-next v2 05/10] net/mlx5e: TC, reject a partial tunnel key with tunnel mapping Alexandre Cassen
` (5 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers
VXLAN and GENEVE flows truncate the key and the mask of enc_key_id to a 24
bit VNI. An exact key above bit 23 already selects the wrong VNI. Flower
is about to accept partial masks. A mask that only covers bits above 23
would then match any VNI. Refuse a key that no VNI can match. GRE keeps
its 32 bit key.
Found by an AI code review agent while auditing the users of enc_key_id.
Confirmed by code inspection. The wrong match was not triggered. Tested
on ConnectX-7 with firmware 28.48.1000 in switchdev mode on VXLAN, GENEVE
and gretap devices.
Fixes: bbd00f7e2349 ("net/mlx5e: Add TC tunnel release action for SRIOV offloads")
Fixes: 9272e3df3023 ("net/mlx5e: Geneve, Add support for encap/decap flows offload")
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h | 3 +++
.../net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c | 8 ++++++++
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c | 8 ++++++++
3 files changed, 19 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h
index 6873c1201803..d7c778bbb2ef 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h
@@ -13,6 +13,9 @@
#ifdef CONFIG_MLX5_ESWITCH
+/* VXLAN and GENEVE match registers hold a 24 bit VNI */
+#define MLX5E_TC_TUN_N_VNI BIT(24)
+
enum {
MLX5E_TC_TUNNEL_TYPE_UNKNOWN,
MLX5E_TC_TUNNEL_TYPE_VXLAN,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
index bf969212cc77..ee04fcdca6ff 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
@@ -141,6 +141,14 @@ static int mlx5e_tc_tun_parse_geneve_vni(struct mlx5e_priv *priv,
if (!enc_keyid.mask->keyid)
return 0;
+ if (be32_to_cpu(enc_keyid.key->keyid) >= MLX5E_TC_TUN_N_VNI) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Tunnel key does not fit the 24 bit VNI");
+ netdev_warn(priv->netdev,
+ "Tunnel key does not fit the 24 bit VNI\n");
+ return -EOPNOTSUPP;
+ }
+
if (!MLX5_CAP_ESW_FLOWTABLE_FDB(priv->mdev, ft_field_support.outer_geneve_vni)) {
NL_SET_ERR_MSG_MOD(extack, "Matching on GENEVE VNI is not supported");
netdev_warn(priv->netdev, "Matching on GENEVE VNI is not supported\n");
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
index 467fbe43b89e..33911e72d20d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
@@ -173,6 +173,14 @@ static int mlx5e_tc_tun_parse_vxlan(struct mlx5e_priv *priv,
if (!enc_keyid.mask->keyid)
return 0;
+ if (be32_to_cpu(enc_keyid.key->keyid) >= MLX5E_TC_TUN_N_VNI) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Tunnel key does not fit the 24 bit VNI");
+ netdev_warn(priv->netdev,
+ "Tunnel key does not fit the 24 bit VNI\n");
+ return -EOPNOTSUPP;
+ }
+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_OPTS)) {
int err;
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH net-next v2 05/10] net/mlx5e: TC, reject a partial tunnel key with tunnel mapping
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
` (3 preceding siblings ...)
2026-11-17 9:29 ` [PATCH net-next v2 04/10] net/mlx5e: TC, " Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-20 3:30 ` netdev-bot+sashiko
2026-11-17 9:29 ` [PATCH net-next v2 06/10] net/sched: cls_flower: add enc_key_id mask Alexandre Cassen
` (4 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers
Tunnel mapping stores the matched tunnel key. The metadata of a packet
missing in hardware after a goto chain or a sample is restored from it.
A partial enc_key_id mask would restore a wrong tunnel id. Flower is about
to accept such masks.
Tunnel options with a partial class or type are already rejected here.
Rules without tunnel mapping keep working.
Found by an AI code review agent while auditing the users of enc_key_id.
Tested on ConnectX-7 with firmware 28.48.1000 in switchdev mode.
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 1d35c97aea0b..ba3aef3c8063 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2257,6 +2257,7 @@ static int mlx5e_get_flow_tunnel_id(struct mlx5e_priv *priv,
struct tunnel_match_enc_opts tun_enc_opts;
struct mlx5_rep_uplink_priv *uplink_priv;
struct mlx5_flow_attr *attr = flow->attr;
+ struct flow_match_enc_keyid enc_keyid;
struct mlx5e_rep_priv *uplink_rpriv;
struct tunnel_match_key tunnel_key;
bool enc_opts_is_dont_care = true;
@@ -2265,6 +2266,16 @@ static int mlx5e_get_flow_tunnel_id(struct mlx5e_priv *priv,
u32 value, mask;
int err;
+ /* The mapping restores the tunnel id of a packet missing in hardware */
+ if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
+ flow_rule_match_enc_keyid(rule, &enc_keyid);
+ if (enc_keyid.mask->keyid != cpu_to_be32(U32_MAX)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Partial match of tunnel key in chains isn't supported");
+ return -EOPNOTSUPP;
+ }
+ }
+
esw = priv->mdev->priv.eswitch;
uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH);
uplink_priv = &uplink_rpriv->uplink_priv;
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH net-next v2 05/10] net/mlx5e: TC, reject a partial tunnel key with tunnel mapping
2026-11-17 9:29 ` [PATCH net-next v2 05/10] net/mlx5e: TC, reject a partial tunnel key with tunnel mapping Alexandre Cassen
@ 2026-11-20 3:30 ` netdev-bot+sashiko
0 siblings, 0 replies; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-20 3:30 UTC (permalink / raw)
To: acassen
Cc: saeedm, leon, tariqt, mbloch, jhs, jiri, andrew+netdev, davem,
edumazet, kuba, pabeni, horms, michael.chan, pavan.chebbi, bharat,
donald.hunter, corbet, skhan, rdunlap, dsahern, idosch, shuah,
netdev, linux-rdma, linux-doc, linux-kselftest, oss-drivers
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In mlx5e_get_flow_tunnel_id()
(drivers/net/ethernet/mellanox/mlx5/core/en_tc.c), the new check only…
--
I found one low-severity regression in this patch: the new check in mlx5e_get_flow_tunnel_id() refuses a VXLAN or Geneve rule that uses the full 24-bit VNI mask, even though the hardware programs it the same way as an all-ones mask. The reply below is ready to send to the list.
net/mlx5e: TC, reject a partial tunnel key with tunnel mapping
This patch makes mlx5e_get_flow_tunnel_id() reject flower rules whose
enc_key_id mask is not all ones. The tunnel mapping keeps the matched key
and uses it to restore metadata after a hardware miss. The change prepares
for flower accepting enc_key_id masks.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 1d35c97aea0bc..ba3aef3c80635 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
[ ... ]
> @@ -2265,6 +2266,16 @@ static int mlx5e_get_flow_tunnel_id(struct mlx5e_priv *priv,
> u32 value, mask;
> int err;
>
> + /* The mapping restores the tunnel id of a packet missing in hardware */
> + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
> + flow_rule_match_enc_keyid(rule, &enc_keyid);
> + if (enc_keyid.mask->keyid != cpu_to_be32(U32_MAX)) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Partial match of tunnel key in chains isn't supported");
> + return -EOPNOTSUPP;
> + }
> + }
> +
[Severity: Low]
Should this check depend on the tunnel type? For VXLAN and Geneve the
tunnel id is a 24-bit VNI, but this check requires all 32 mask bits.
The VXLAN and Geneve parsers already refuse keys that do not fit in 24
bits:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c:mlx5e_tc_tun_parse_geneve_vni() {
...
if (be32_to_cpu(enc_keyid.key->keyid) >= MLX5E_TC_TUN_N_VNI) {
...
MLX5_SET(fte_match_set_misc, misc_c, geneve_vni, be32_to_cpu(enc_keyid.mask->keyid));
...
}
mlx5e_tc_tun_parse_vxlan() has the same check. The mask is then written
into the 24-bit vxlan_vni or geneve_vni field of fte_match_set_misc, so
MLX5_SET() cuts it down to 0xffffff. On the VXLAN-GBP path,
tunnel_header_1 gets mask << 8, which is 0xffffff00 for both masks.
As a result, enc_key_id <vni>/0xffffff and enc_key_id <vni>/0xffffffff
program the same hardware match. Also, key & 0x00ffffff equals key for
every key the parser accepts. So the wrong-tunnel-id case from the commit
message does not seem possible with this mask.
After "net/sched: cls_flower: add enc_key_id mask" later in this series,
a VXLAN or Geneve rule with the natural full-VNI mask 0xffffff would get
-EOPNOTSUPP on every tunnel-mapping path. That covers rules in a chain
greater than 0, and chain 0 rules with goto or sample actions.
Would it work better to compare against the id width of the tunnel (24
bits for VXLAN/Geneve, 32 for GRE)? Another option is to compare the mask
only over the bits the device actually programs.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117092915.255194-1-acassen%40corp.free.fr
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net-next v2 06/10] net/sched: cls_flower: add enc_key_id mask
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
` (4 preceding siblings ...)
2026-11-17 9:29 ` [PATCH net-next v2 05/10] net/mlx5e: TC, reject a partial tunnel key with tunnel mapping Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-17 9:29 ` [PATCH net-next v2 07/10] selftests: forwarding: tc_flower: test the " Alexandre Cassen
` (3 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers,
Asbjørn Sloth Tønnesen
Flower only matches enc_key_id exactly. A block of tunnel keys takes one
filter per key. Add an optional mask. Without one the match stays exact.
tc filter add dev <dev> ingress protocol ip flower \
enc_key_id 0x100/0xf00 action ...
cxgb4, mlx5 and nfp program the mask. sfc does when its firmware supports
it. hns3 and ice reject a partial one. The previous patches make bnxt and
mlx5 tunnel mapping reject it too. i40e and iavf never program the value
of enc_key_id, with or without this patch.
Hardware holding a 24 bit VNI truncates the mask too. This is correct when
the key fits the VNI. The previous patches enforce this on cxgb4, nfp and
mlx5. On cxgb4 a mask without a VNI bit would also drop the tunnel match,
and the cxgb4 patch refuses it.
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
Documentation/netlink/specs/tc.yaml | 4 ++++
include/uapi/linux/pkt_cls.h | 2 ++
net/sched/cls_flower.c | 5 +++--
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml
index b6ccc645b0e3..a20fa42e6715 100644
--- a/Documentation/netlink/specs/tc.yaml
+++ b/Documentation/netlink/specs/tc.yaml
@@ -2908,6 +2908,10 @@ attribute-sets:
byte-order: big-endian
enum: flower-key-ctrl-flags
enum-as-flags: true
+ -
+ name: key-enc-key-id-mask
+ type: u32
+ byte-order: big-endian
-
name: flower-key-enc-opts-attrs
name-prefix: tca-flower-key-enc-opts-
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 28d94b11d1aa..fcaf06c6892d 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -560,6 +560,8 @@ enum {
TCA_FLOWER_KEY_ENC_FLAGS, /* be32 */
TCA_FLOWER_KEY_ENC_FLAGS_MASK, /* be32 */
+ TCA_FLOWER_KEY_ENC_KEY_ID_MASK, /* be32 */
+
__TCA_FLOWER_MAX,
};
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 23eba4a00a94..dd248a335402 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -661,6 +661,7 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = {
[TCA_FLOWER_KEY_VLAN_PRIO] = { .type = NLA_U8 },
[TCA_FLOWER_KEY_VLAN_ETH_TYPE] = { .type = NLA_U16 },
[TCA_FLOWER_KEY_ENC_KEY_ID] = { .type = NLA_U32 },
+ [TCA_FLOWER_KEY_ENC_KEY_ID_MASK] = { .type = NLA_U32 },
[TCA_FLOWER_KEY_ENC_IPV4_SRC] = { .type = NLA_U32 },
[TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK] = { .type = NLA_U32 },
[TCA_FLOWER_KEY_ENC_IPV4_DST] = { .type = NLA_U32 },
@@ -2110,7 +2111,7 @@ static int fl_set_key(struct net *net, struct nlattr *tca_opts,
}
fl_set_key_val(tb, &key->enc_key_id.keyid, TCA_FLOWER_KEY_ENC_KEY_ID,
- &mask->enc_key_id.keyid, TCA_FLOWER_UNSPEC,
+ &mask->enc_key_id.keyid, TCA_FLOWER_KEY_ENC_KEY_ID_MASK,
sizeof(key->enc_key_id.keyid));
fl_set_key_val(tb, &key->enc_tp.src, TCA_FLOWER_KEY_ENC_UDP_SRC_PORT,
@@ -3680,7 +3681,7 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net,
goto nla_put_failure;
if (fl_dump_key_val(skb, &key->enc_key_id, TCA_FLOWER_KEY_ENC_KEY_ID,
- &mask->enc_key_id, TCA_FLOWER_UNSPEC,
+ &mask->enc_key_id, TCA_FLOWER_KEY_ENC_KEY_ID_MASK,
sizeof(key->enc_key_id)) ||
fl_dump_key_val(skb, &key->enc_tp.src,
TCA_FLOWER_KEY_ENC_UDP_SRC_PORT,
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH net-next v2 07/10] selftests: forwarding: tc_flower: test the enc_key_id mask
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
` (5 preceding siblings ...)
2026-11-17 9:29 ` [PATCH net-next v2 06/10] net/sched: cls_flower: add enc_key_id mask Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-20 3:30 ` netdev-bot+sashiko
2026-11-17 9:29 ` [PATCH net-next v2 08/10] net/mlx5e: TC, offload RX queue mapping in NIC flows Alexandre Cassen
` (2 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers
A filter on a block of tunnel keys must match a key inside the block and
no key outside it. It must also dump its mask. A second filter proves that
the frame outside the block reaches the device.
When tc does not know the mask, the test only logs this. Reporting a skip
would turn the exit status of the whole script into a skip. A tunnel
device takes no skip_sw filter. The test only runs in software.
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
.../selftests/net/forwarding/tc_flower.sh | 54 +++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/tools/testing/selftests/net/forwarding/tc_flower.sh b/tools/testing/selftests/net/forwarding/tc_flower.sh
index b58909a93112..693361c4b8f7 100755
--- a/tools/testing/selftests/net/forwarding/tc_flower.sh
+++ b/tools/testing/selftests/net/forwarding/tc_flower.sh
@@ -3,6 +3,7 @@
ALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \
match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test \
+ match_enc_key_id_mask_test \
match_ip_tos_test match_indev_test match_ip_ttl_test
match_mpls_label_test \
match_mpls_tc_test match_mpls_bos_test match_mpls_ttl_test \
@@ -280,6 +281,59 @@ match_vlan_test()
log_test "VLAN match ($tcflags)"
}
+match_enc_key_id_mask_test()
+{
+ RET=0
+
+ # A tunnel device has no offload to take a skip_sw filter
+ if [[ $tcflags == "skip_sw" ]]; then
+ return 0
+ fi
+
+ if ! tc filter add dev $h2 ingress flower help 2>&1 | \
+ grep -q MASKED-KEY-ID; then
+ echo "SKIP: iproute2 too old; tc is missing the enc_key_id mask"
+ return 0
+ fi
+
+ tunnel_create gt1 gretap 192.0.2.1 192.0.2.2 dev $h1 key 300
+ tunnel_create gt2 gretap 192.0.2.1 192.0.2.2 dev $h1 key 600
+ ip link set dev gt1 master v$h1
+ ip link set dev gt2 master v$h1
+ ip link add gt-ex type gretap external # To collect tunnel info
+ ip link set dev gt-ex up
+ ip link set dev gt-ex master v$h2
+ tc qdisc add dev gt-ex clsact
+
+ tc filter add dev gt-ex ingress protocol ip pref 1 handle 101 flower \
+ $tcflags enc_key_id 256/0xf00 action drop
+ tc filter add dev gt-ex ingress protocol ip pref 2 handle 102 flower \
+ $tcflags enc_key_id 600 action drop
+
+ tc filter show dev gt-ex ingress pref 1 | grep -q "enc_key_id 256/0xf00"
+ check_err $? "Did not dump the mask"
+
+ $MZ gt1 -c 1 -p 64 -a "$(mac_get gt1)" -b $h2mac -t ip -q
+
+ tc_check_packets "dev gt-ex ingress" 101 1
+ check_err $? "Did not match a key inside the mask"
+
+ $MZ gt2 -c 1 -p 64 -a "$(mac_get gt2)" -b $h2mac -t ip -q
+
+ tc_check_packets "dev gt-ex ingress" 102 1
+ check_err $? "Did not receive the key outside the mask"
+
+ tc_check_packets "dev gt-ex ingress" 101 1
+ check_err $? "Matched a key outside the mask"
+
+ tc qdisc del dev gt-ex clsact
+ tunnel_destroy gt-ex
+ tunnel_destroy gt2
+ tunnel_destroy gt1
+
+ log_test "enc_key_id mask match ($tcflags)"
+}
+
match_ip_tos_test()
{
RET=0
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH net-next v2 07/10] selftests: forwarding: tc_flower: test the enc_key_id mask
2026-11-17 9:29 ` [PATCH net-next v2 07/10] selftests: forwarding: tc_flower: test the " Alexandre Cassen
@ 2026-11-20 3:30 ` netdev-bot+sashiko
0 siblings, 0 replies; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-20 3:30 UTC (permalink / raw)
To: acassen
Cc: saeedm, leon, tariqt, mbloch, jhs, jiri, andrew+netdev, davem,
edumazet, kuba, pabeni, horms, michael.chan, pavan.chebbi, bharat,
donald.hunter, corbet, skhan, rdunlap, dsahern, idosch, shuah,
netdev, linux-rdma, linux-doc, linux-kselftest, oss-drivers
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] match_enc_key_id_mask_test() in
tools/testing/selftests/net/forwarding/tc_flower.sh only checks…
- [Low] In tools/testing/selftests/net/forwarding/tc_flower.sh,
match_enc_key_id_mask_test() depends on a tc (iproute2) change that…
--
selftests: forwarding: tc_flower: test the enc_key_id mask
This adds match_enc_key_id_mask_test() to tc_flower.sh. It creates two
gretap tunnels with keys 300 and 600 and adds a flower filter matching
enc_key_id 256/0xf00 on an external gretap device. It then checks that
key 300 matches and that key 600 falls through to a second filter. The
test returns early without a result when tcflags is skip_sw or when tc
does not know the enc_key_id mask.
> diff --git a/tools/testing/selftests/net/forwarding/tc_flower.sh b/tools/testing/selftests/net/forwarding/tc_flower.sh
> index b58909a931129..693361c4b8f7e 100755
> --- a/tools/testing/selftests/net/forwarding/tc_flower.sh
> +++ b/tools/testing/selftests/net/forwarding/tc_flower.sh
[ ... ]
> @@ -280,6 +281,59 @@ match_vlan_test()
> log_test "VLAN match ($tcflags)"
> }
>
> +match_enc_key_id_mask_test()
> +{
> + RET=0
> +
> + # A tunnel device has no offload to take a skip_sw filter
> + if [[ $tcflags == "skip_sw" ]]; then
> + return 0
> + fi
> +
> + if ! tc filter add dev $h2 ingress flower help 2>&1 | \
> + grep -q MASKED-KEY-ID; then
> + echo "SKIP: iproute2 too old; tc is missing the enc_key_id mask"
> + return 0
> + fi
[Severity: Low]
Which iproute2 change adds the MASKED-KEY-ID token to the flower help
output?
The kernel tree does not contain MASKED-KEY-ID. It also does not contain
the "enc_key_id 256/0xf00" dump format checked further down. Released tc
parses enc_key_id as a plain be32 and rejects 256/0xf00. The commit
message does not name or link the tc patch that these strings come from.
With any tc that lacks this exact token, the test echoes the SKIP line
and returns 0 without a TEST: line. The new TCA_FLOWER_KEY_ENC_KEY_ID_MASK
handling in fl_set_key() and fl_dump_key() is then never exercised.
If the final tc patch uses a different help placeholder, the test would
skip forever. If tc prints the key in another format, the dump check
would fail.
Could the commit reference the tc change it depends on? Then the probe
string and the dump format could be checked against it.
> +
> + tunnel_create gt1 gretap 192.0.2.1 192.0.2.2 dev $h1 key 300
> + tunnel_create gt2 gretap 192.0.2.1 192.0.2.2 dev $h1 key 600
> + ip link set dev gt1 master v$h1
> + ip link set dev gt2 master v$h1
> + ip link add gt-ex type gretap external # To collect tunnel info
> + ip link set dev gt-ex up
> + ip link set dev gt-ex master v$h2
> + tc qdisc add dev gt-ex clsact
> +
> + tc filter add dev gt-ex ingress protocol ip pref 1 handle 101 flower \
> + $tcflags enc_key_id 256/0xf00 action drop
> + tc filter add dev gt-ex ingress protocol ip pref 2 handle 102 flower \
> + $tcflags enc_key_id 600 action drop
> +
> + tc filter show dev gt-ex ingress pref 1 | grep -q "enc_key_id 256/0xf00"
> + check_err $? "Did not dump the mask"
[Severity: Medium]
What happens here when a tc that knows the mask runs on a kernel without
TCA_FLOWER_KEY_ENC_KEY_ID_MASK?
tc answers the flower help probe above by itself and never asks the
kernel. So the probe only detects userspace support.
TCA_FLOWER_KEY_ENC_KEY_ID_MASK is added just before __TCA_FLOWER_MAX, so
older kernels have a smaller TCA_FLOWER_MAX. fl_change() parses the
options liberally:
net/sched/cls_flower.c:fl_change() {
...
err = nla_parse_nested_deprecated(tb, TCA_FLOWER_MAX,
tca_opts, fl_policy, NULL);
...
}
In that mode, __nla_validate_parse() skips attributes above maxtype:
lib/nlattr.c:__nla_validate_parse() {
...
if (type == 0 || type > maxtype) {
if (validate & NL_VALIDATE_MAXTYPE) {
...
return -EINVAL;
}
continue;
}
...
}
So an older kernel would install the enc_key_id 256/0xf00 filter as an
exact match on key 256. The "Did not dump the mask" and "Did not match a
key inside the mask" checks would both fail, and tc_flower.sh would exit
with ksft_fail.
Documentation/dev-tools/kselftest.rst says mainline kselftests should
skip gracefully on older stable kernels. The test already reads the dump
back. Could a missing mask in the dump be handled the same way as the tc
probe, instead of being reported as a failure?
> +
> + $MZ gt1 -c 1 -p 64 -a "$(mac_get gt1)" -b $h2mac -t ip -q
> +
> + tc_check_packets "dev gt-ex ingress" 101 1
> + check_err $? "Did not match a key inside the mask"
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117092915.255194-1-acassen%40corp.free.fr
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net-next v2 08/10] net/mlx5e: TC, offload RX queue mapping in NIC flows
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
` (6 preceding siblings ...)
2026-11-17 9:29 ` [PATCH net-next v2 07/10] selftests: forwarding: tc_flower: test the " Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-20 3:30 ` netdev-bot+sashiko
2026-11-17 9:29 ` [PATCH net-next v2 09/10] net/mlx5e: TC, match the tunnel key without a tunnel device Alexandre Cassen
2026-11-17 9:29 ` [PATCH net-next v2 10/10] docs: networking: describe tunnel key partitioning in TC queue filtering Alexandre Cassen
9 siblings, 1 reply; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers
skbedit queue_mapping steers a flow to one RX queue. ice, hns3 and
octeontx2 already offload it. Add it to mlx5e NIC flows. The rule points
to the direct TIR of the channel like ethtool steering rules.
The direct TIR takes over the destination of the rule. The action must
come last and cannot follow a terminating action such as ok, goto or
mirred. A goto would also unbalance the reference count of its chain
table.
Reducing the channel count below the queue of a rule drops its traffic
until the channel returns. The direct RQT of an inactive channel points to
the drop RQ. ethtool refuses such a change for its own rules but nothing
tracks the queues of TC rules. A channel change racing with the range
check of a new rule has the same result. Direct TIRs exist up to the
maximum channel count. The rule always points to a valid one.
Tested on ConnectX-7 with firmware 28.48.1000.
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
.../net/ethernet/mellanox/mlx5/core/Makefile | 3 +-
.../mellanox/mlx5/core/en/tc/act/act.c | 1 +
.../mellanox/mlx5/core/en/tc/act/act.h | 1 +
.../mellanox/mlx5/core/en/tc/act/rx_queue.c | 67 +++++++++++++++++++
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 4 ++
.../net/ethernet/mellanox/mlx5/core/en_tc.h | 1 +
6 files changed, 76 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index a1871259210d..f8d1696ab5eb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -56,7 +56,8 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/a
en/tc/act/vlan.o en/tc/act/vlan_mangle.o en/tc/act/mpls.o \
en/tc/act/mirred.o en/tc/act/mirred_nic.o \
en/tc/act/ct.o en/tc/act/sample.o en/tc/act/ptype.o \
- en/tc/act/redirect_ingress.o en/tc/act/police.o
+ en/tc/act/redirect_ingress.o en/tc/act/police.o \
+ en/tc/act/rx_queue.o
ifneq ($(CONFIG_MLX5_TC_CT),)
mlx5_core-y += en/tc_ct.o en/tc/ct_fs_dmfs.o
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c
index 0380a04c3691..9b5d7d5ee271 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c
@@ -41,6 +41,7 @@ static struct mlx5e_tc_act *tc_acts_nic[NUM_FLOW_ACTIONS] = {
[FLOW_ACTION_ADD] = &mlx5e_tc_act_pedit,
[FLOW_ACTION_CSUM] = &mlx5e_tc_act_csum,
[FLOW_ACTION_MARK] = &mlx5e_tc_act_mark,
+ [FLOW_ACTION_RX_QUEUE_MAPPING] = &mlx5e_tc_act_rx_queue,
[FLOW_ACTION_CT] = &mlx5e_tc_act_ct,
};
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h
index 2e528b2c34d6..e6df5f0f27a7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h
@@ -94,6 +94,7 @@ extern struct mlx5e_tc_act mlx5e_tc_act_sample;
extern struct mlx5e_tc_act mlx5e_tc_act_ptype;
extern struct mlx5e_tc_act mlx5e_tc_act_redirect_ingress;
extern struct mlx5e_tc_act mlx5e_tc_act_police;
+extern struct mlx5e_tc_act mlx5e_tc_act_rx_queue;
struct mlx5e_tc_act *
mlx5e_tc_act_get(enum flow_action_id act_id,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c
new file mode 100644
index 000000000000..32598a216300
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
+
+#include "act.h"
+#include "en/tc_priv.h"
+#include "en/rx_res.h"
+
+/* No action runs after a terminating one */
+static bool
+tc_act_rx_queue_is_reachable(struct flow_action *flow_action, int act_index)
+{
+ struct mlx5e_tc_act *tc_act;
+ int i;
+
+ for (i = 0; i < act_index; i++) {
+ tc_act = mlx5e_tc_act_get(flow_action->entries[i].id,
+ MLX5_FLOW_NAMESPACE_KERNEL);
+ if (tc_act->is_terminating_action)
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+tc_act_can_offload_rx_queue(struct mlx5e_tc_act_parse_state *parse_state,
+ const struct flow_action_entry *act,
+ int act_index,
+ struct mlx5_flow_attr *attr)
+{
+ struct flow_action *flow_action = parse_state->flow_action;
+ struct netlink_ext_ack *extack = parse_state->extack;
+ struct mlx5e_tc_flow *flow = parse_state->flow;
+
+ /* The direct TIR takes over the destination of the rule */
+ if (!flow_action_is_last_entry(flow_action, act) ||
+ !tc_act_rx_queue_is_reachable(flow_action, act_index)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "RX queue mapping must be the last action and cannot follow a terminating action");
+ return false;
+ }
+
+ if (act->rx_queue >= flow->priv->channels.params.num_channels) {
+ NL_SET_ERR_MSG_MOD(extack, "RX queue index out of range");
+ return false;
+ }
+
+ return true;
+}
+
+static int
+tc_act_parse_rx_queue(struct mlx5e_tc_act_parse_state *parse_state,
+ const struct flow_action_entry *act,
+ struct mlx5e_priv *priv,
+ struct mlx5_flow_attr *attr)
+{
+ attr->nic_attr->rx_tirn = mlx5e_rx_res_get_tirn_direct(priv->rx_res,
+ act->rx_queue);
+ attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
+
+ return 0;
+}
+
+struct mlx5e_tc_act mlx5e_tc_act_rx_queue = {
+ .can_offload = tc_act_can_offload_rx_queue,
+ .parse_action = tc_act_parse_rx_queue,
+ .is_terminating_action = true,
+};
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index ba3aef3c8063..2326fb21da66 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1267,6 +1267,10 @@ mlx5e_add_offloaded_nic_rule(struct mlx5e_priv *priv,
dest[dest_ix].type = MLX5_FLOW_DESTINATION_TYPE_TIR;
dest[dest_ix].tir_num = nic_attr->hairpin_tirn;
dest_ix++;
+ } else if (nic_attr->rx_tirn) {
+ dest[dest_ix].type = MLX5_FLOW_DESTINATION_TYPE_TIR;
+ dest[dest_ix].tir_num = nic_attr->rx_tirn;
+ dest_ix++;
} else if (attr->action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
dest[dest_ix].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
if (attr->dest_chain) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
index e1b8cb78369f..254ea76fcbe9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
@@ -66,6 +66,7 @@ struct mlx5e_tc_update_priv {
struct mlx5_nic_flow_attr {
u32 flow_tag;
u32 hairpin_tirn;
+ u32 rx_tirn;
struct mlx5_flow_table *hairpin_ft;
};
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH net-next v2 08/10] net/mlx5e: TC, offload RX queue mapping in NIC flows
2026-11-17 9:29 ` [PATCH net-next v2 08/10] net/mlx5e: TC, offload RX queue mapping in NIC flows Alexandre Cassen
@ 2026-11-20 3:30 ` netdev-bot+sashiko
0 siblings, 0 replies; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-20 3:30 UTC (permalink / raw)
To: acassen
Cc: saeedm, leon, tariqt, mbloch, jhs, jiri, andrew+netdev, davem,
edumazet, kuba, pabeni, horms, michael.chan, pavan.chebbi, bharat,
donald.hunter, corbet, skhan, rdunlap, dsahern, idosch, shuah,
netdev, linux-rdma, linux-doc, linux-kselftest, oss-drivers
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] A TC rule that maps a flow to an RX queue keeps a hardware
destination that turns into a silent blackhole once the channel count…
- [Low] tc_act_can_offload_rx_queue()
(drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c:42)…
--
net/mlx5e: TC, offload RX queue mapping in NIC flows
This adds offload of the skbedit queue_mapping action to mlx5e NIC TC
flows. The rule's destination becomes the direct TIR of the requested
channel. The action must be the last one and must not follow a
terminating action.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c
> new file mode 100644
> index 0000000000000..32598a2163009
> --- /dev/null
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c
[ ... ]
> +static bool
> +tc_act_can_offload_rx_queue(struct mlx5e_tc_act_parse_state *parse_state,
> + const struct flow_action_entry *act,
> + int act_index,
> + struct mlx5_flow_attr *attr)
> +{
[ ... ]
> + if (act->rx_queue >= flow->priv->channels.params.num_channels) {
> + NL_SET_ERR_MSG_MOD(extack, "RX queue index out of range");
> + return false;
> + }
[Severity: Medium]
The queue index is only checked against num_channels here, when the rule
is inserted. What happens to the offloaded rule after a later
"ethtool -L combined N" with N <= rx_queue?
tc_act_parse_rx_queue() stores the direct TIR number in nic_attr->rx_tirn.
mlx5e_add_offloaded_nic_rule() then programs it as a TIR destination.
On the channel switch:
mlx5e_switch_priv_channels()
mlx5e_deactivate_priv_channels()
mlx5e_rx_res_channels_deactivate()
mlx5e_rx_res_channel_deactivate_direct()
mlx5e_rqt_redirect_direct(&res->channels[ix].direct_rqt,
res->drop_rqn, NULL);
mlx5e_rx_res_channels_activate() then re-points the direct RQTs only for
indices below the new channel count. The FTE still points at the direct
TIR for rx_queue, and that TIR's RQT now points at the drop RQ. Hardware
drops the matched flow, but tc still reports the filter as in_hw.
The ethtool core check (ethtool_get_max_rxnfc_channel() and
ethtool_get_max_rxfh_channel() in net/ethtool/common.c) only knows about
ntuple and RSS users. So the reduction is allowed, and nothing
re-validates, reprograms or removes the TC rule.
The drops are counted on priv->drop_rq_q_counter, and
mlx5e_grp_q_update_stats() reports them as rx_if_down_packets even though
the interface is up.
The commit message acknowledges this:
"Reducing the channel count below the queue of a rule drops its traffic
until the channel returns."
Could the driver track the queues used by TC rules, so that set_channels
can refuse the change as it does for ethtool's own rules? Alternatively,
could it reprogram the affected rules so they don't keep dropping
traffic?
[Severity: Low]
Is it safe to read priv->channels.params.num_channels here without a lock?
mlx5e_setup_tc() sets f->unlocked_driver_cb = true, so this path can run
without rtnl:
mlx5e_configure_flower()->...->parse_tc_nic_actions()->parse_tc_actions()
->tc_act_can_offload_rx_queue()
This path doesn't take priv->state_lock either. Meanwhile,
mlx5e_switch_priv_params() and mlx5e_switch_priv_channels() overwrite the
structures with plain struct copies under state_lock:
priv->channels.params = *new_params;
...
priv->channels = *new_chs;
The two sides share no lock, so this is an unannotated data race that
KCSAN would likely report.
The check is also check-then-act:
CPU0 (tc filter add) CPU1 (ethtool -L combined 4)
reads num_channels == 8
accepts rx_queue == 7
switches channels, direct RQT 7 now
points at the drop RQ
installs FTE to direct TIR 7
The filter add succeeds, but its traffic is silently dropped. Direct TIRs
exist for all max_nch indices, so the rule still references a valid TIR.
The commit message mentions this window too ("A channel change racing
with the range check of a new rule has the same result").
If the channel reduction issue above is fixed by tracking TC queue usage,
would this check also need to run under priv->state_lock?
> +
> + return true;
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117092915.255194-1-acassen%40corp.free.fr
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net-next v2 09/10] net/mlx5e: TC, match the tunnel key without a tunnel device
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
` (7 preceding siblings ...)
2026-11-17 9:29 ` [PATCH net-next v2 08/10] net/mlx5e: TC, offload RX queue mapping in NIC flows Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-20 3:30 ` netdev-bot+sashiko
2026-11-17 9:29 ` [PATCH net-next v2 10/10] docs: networking: describe tunnel key partitioning in TC queue filtering Alexandre Cassen
9 siblings, 1 reply; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers
RSS can't spread GTP-U traffic between a few endpoints. The outer headers
barely vary and the TEID is not hashed. A masked tunnel key partitions
this traffic into RX queues. Other tunnels spread better under RSS. The
same match still gives a block of tenants its own queue.
Without a tunnel device nothing decapsulates. enc_key_id reads the tunnel
header on the wire like cxgb4 and hns3 do on a physical port. The plain
ip_proto and dst_port keys select the match register and its capability:
GRE ip_proto 0x2f misc.gre_key ft_field_support
VXLAN dst_port 4789 misc.vxlan_vni ft_field_support
GENEVE dst_port 6081 misc.geneve_vni flex parser and
ft_field_support
GTP-U dst_port 2152 misc3.gtpu_teid flex parser
These keys stay in the match. Without them a rule on a masked TEID of zero
also catches all other IPv4 traffic on ConnectX-7. The port must be exact
to name a tunnel. Only the default VXLAN port qualifies. The hardware can
stop parsing any other while the rule stays. A keyless GRE packet reads as
key zero like in software.
The parse_tunnel ops can't serve these flows. The VXLAN and GENEVE ones
check eswitch capabilities. The GRE one only matches gretap frames. A new
op keeps each register in the file of its tunnel.
This covers NIC and eswitch flows. A rule without a tunnel device used to
accept enc_key_id without matching on it. It caught all the traffic of its
other keys. It now matches the key or gets refused.
Nothing matches the other tunnel keys on this path. Refuse them in such a
rule. On a VF representor the eswitch only reads the headers the VF
inlines, which can stop before the tunnel header. Refuse the rule there
unless the min inline mode is none.
Software only has tunnel metadata after decapsulation. Refuse the offload
without skip_sw to keep both datapaths from diverging. Such a rule stays in
software. There a physical port reads key zero. Refuse a decap action too.
In software it only releases metadata and such a flow has none.
tc filter add dev <dev> ingress protocol ip flower skip_sw \
ip_proto udp dst_port 2152 enc_key_id <teid>/<mask> \
action skbedit queue_mapping <q> skip_sw
tc filter add dev <dev> ingress protocol ip flower skip_sw \
ip_proto 0x2f enc_key_id <key>/<mask> \
action skbedit queue_mapping <q> skip_sw
Tested on ConnectX-7 with firmware 28.48.1000 on NIC flows. Also tested on
the uplink and VF representors in dmfs, smfs and hmfs. This includes
redirect to a VF. GTP-U needs flex parser profile 3 and GENEVE profile 0.
GRE and VXLAN work on both. ConnectX-7 needs no inlining. The min inline
check is therefore build tested only.
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
.../net/ethernet/mellanox/mlx5/core/Makefile | 3 +-
.../ethernet/mellanox/mlx5/core/en/tc_tun.c | 110 ++++++++++++++++++
.../ethernet/mellanox/mlx5/core/en/tc_tun.h | 11 ++
.../mellanox/mlx5/core/en/tc_tun_geneve.c | 38 ++++++
.../mellanox/mlx5/core/en/tc_tun_gre.c | 31 +++++
.../mellanox/mlx5/core/en/tc_tun_gtp.c | 36 ++++++
.../mellanox/mlx5/core/en/tc_tun_vxlan.c | 37 ++++++
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 4 +
8 files changed, 269 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gtp.c
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index f8d1696ab5eb..5d42c681dc7b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -46,7 +46,8 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \
lib/fs_chains.o en/tc_tun.o \
esw/indir_table.o en/tc_tun_encap.o \
en/tc_tun_vxlan.o en/tc_tun_gre.o en/tc_tun_geneve.o \
- en/tc_tun_mplsoudp.o diag/en_tc_tracepoint.o \
+ en/tc_tun_mplsoudp.o en/tc_tun_gtp.o \
+ diag/en_tc_tracepoint.o \
en/tc/post_act.o en/tc/int_port.o en/tc/meter.o \
en/tc/post_meter.o en/tc/act_stats.o
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
index de74dbfe7b20..a037ffd5bd4a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
@@ -7,6 +7,7 @@
#include <net/gre.h>
#include <net/geneve.h>
#include <net/bareudp.h>
+#include <net/gtp.h>
#include "en/tc_tun.h"
#include "en/tc_priv.h"
#include "en_tc.h"
@@ -996,3 +997,112 @@ int mlx5e_tc_tun_parse_udp_ports(struct mlx5e_priv *priv,
return 0;
}
+
+/* Without a tunnel device the outer headers name the tunnel */
+static struct mlx5e_tc_tunnel *
+mlx5e_tc_tun_outer_lookup(struct flow_rule *rule)
+{
+ struct flow_match_basic basic;
+ struct flow_match_ports ports;
+
+ if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC))
+ return NULL;
+
+ flow_rule_match_basic(rule, &basic);
+ if (basic.key->ip_proto == IPPROTO_GRE)
+ return &gre_tunnel;
+
+ if (basic.key->ip_proto != IPPROTO_UDP ||
+ !flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS))
+ return NULL;
+
+ flow_rule_match_ports(rule, &ports);
+ /* Only an exact port names a tunnel */
+ if (ports.mask->dst != htons(U16_MAX))
+ return NULL;
+
+ switch (ntohs(ports.key->dst)) {
+ case GTP1U_PORT:
+ return >p_tunnel;
+ case IANA_VXLAN_UDP_PORT:
+ return &vxlan_tunnel;
+ case GENEVE_UDP_PORT:
+ return &geneve_tunnel;
+ default:
+ return NULL;
+ }
+}
+
+static bool
+mlx5e_tc_tun_has_decap(struct flow_rule *rule)
+{
+ const struct flow_action_entry *act;
+ int i;
+
+ flow_action_for_each(i, act, &rule->action) {
+ if (act->id == FLOW_ACTION_TUNNEL_DECAP)
+ return true;
+ }
+
+ return false;
+}
+
+/* Without a tunnel device only the hardware can read the tunnel key */
+int
+mlx5e_tc_tun_parse_outer_key(struct mlx5e_priv *priv,
+ struct mlx5_flow_spec *spec,
+ struct flow_cls_offload *f,
+ enum fs_flow_table_type fs_type)
+{
+ struct flow_rule *rule = flow_cls_offload_flow_rule(f);
+ struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
+ struct netlink_ext_ack *extack = f->common.extack;
+ struct flow_match_enc_keyid enc_keyid;
+ struct mlx5e_tc_tunnel *tunnel;
+
+ if (!f->common.skip_sw) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "enc_key_id without a tunnel device requires skip_sw");
+ return -EOPNOTSUPP;
+ }
+
+ if (mlx5e_tc_tun_has_decap(rule)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "enc_key_id without a tunnel device cannot decap");
+ return -EOPNOTSUPP;
+ }
+
+ /* Without a tunnel device the other tunnel keys go unmatched */
+ if (rule->match.dissector->used_keys &
+ (BIT_ULL(FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS) |
+ BIT_ULL(FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS) |
+ BIT_ULL(FLOW_DISSECTOR_KEY_ENC_PORTS) |
+ BIT_ULL(FLOW_DISSECTOR_KEY_ENC_CONTROL) |
+ BIT_ULL(FLOW_DISSECTOR_KEY_ENC_IP) |
+ BIT_ULL(FLOW_DISSECTOR_KEY_ENC_OPTS))) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "enc_key_id without a tunnel device cannot match other tunnel keys");
+ return -EOPNOTSUPP;
+ }
+
+ /* The eswitch only reads the headers a VF inlines */
+ if (fs_type == FS_FT_FDB && !mlx5e_is_uplink_rep(priv) &&
+ esw->offloads.inline_mode != MLX5_INLINE_MODE_NONE) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Flow is not offloaded due to min inline setting");
+ return -EOPNOTSUPP;
+ }
+
+ tunnel = mlx5e_tc_tun_outer_lookup(rule);
+ if (!tunnel) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "enc_key_id needs ip_proto 0x2f or the exact dst_port of a supported tunnel");
+ return -EOPNOTSUPP;
+ }
+
+ flow_rule_match_enc_keyid(rule, &enc_keyid);
+ return tunnel->parse_outer_key(priv, spec, extack,
+ be32_to_cpu(enc_keyid.key->keyid),
+ be32_to_cpu(enc_keyid.mask->keyid),
+ fs_type);
+}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h
index d7c778bbb2ef..8eccaecb70b2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h
@@ -52,6 +52,11 @@ struct mlx5e_tc_tunnel {
struct flow_cls_offload *f,
void *headers_c,
void *headers_v);
+ int (*parse_outer_key)(struct mlx5e_priv *priv,
+ struct mlx5_flow_spec *spec,
+ struct netlink_ext_ack *extack,
+ u32 key, u32 mask,
+ enum fs_flow_table_type fs_type);
bool (*encap_info_equal)(struct mlx5e_encap_key *a,
struct mlx5e_encap_key *b);
int (*get_remote_ifindex)(struct net_device *mirred_dev);
@@ -61,6 +66,7 @@ extern struct mlx5e_tc_tunnel vxlan_tunnel;
extern struct mlx5e_tc_tunnel geneve_tunnel;
extern struct mlx5e_tc_tunnel gre_tunnel;
extern struct mlx5e_tc_tunnel mplsoudp_tunnel;
+extern struct mlx5e_tc_tunnel gtp_tunnel;
struct mlx5e_tc_tunnel *mlx5e_get_tc_tun(struct net_device *tunnel_dev);
@@ -115,6 +121,11 @@ int mlx5e_tc_tun_parse_udp_ports(struct mlx5e_priv *priv,
void *headers_c,
void *headers_v);
+int mlx5e_tc_tun_parse_outer_key(struct mlx5e_priv *priv,
+ struct mlx5_flow_spec *spec,
+ struct flow_cls_offload *f,
+ enum fs_flow_table_type fs_type);
+
bool mlx5e_tc_tun_encap_info_equal_generic(struct mlx5e_encap_key *a,
struct mlx5e_encap_key *b);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
index ee04fcdca6ff..9a2f7a409a82 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
@@ -4,6 +4,7 @@
#include <net/geneve.h>
#include "lib/geneve.h"
#include "en/tc_tun.h"
+#include "fs_core.h"
#define MLX5E_GENEVE_VER 0
@@ -350,6 +351,42 @@ static bool mlx5e_tc_tun_encap_info_equal_geneve(struct mlx5e_encap_key *a,
IP_TUNNEL_GENEVE_OPT_BIT);
}
+static int
+mlx5e_tc_tun_parse_outer_key_geneve(struct mlx5e_priv *priv,
+ struct mlx5_flow_spec *spec,
+ struct netlink_ext_ack *extack,
+ u32 key, u32 mask,
+ enum fs_flow_table_type fs_type)
+{
+ void *misc_c, *misc_v;
+
+ if (key >= MLX5E_TC_TUN_N_VNI) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Tunnel key does not fit the 24 bit VNI");
+ return -EOPNOTSUPP;
+ }
+
+ if (!mlx5e_tc_tun_can_offload_geneve(priv) ||
+ !MLX5_CAP_FLOWTABLE_TYPE(priv->mdev,
+ ft_field_support.outer_geneve_vni,
+ fs_type)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Matching on GENEVE VNI is not supported");
+ return -EOPNOTSUPP;
+ }
+
+ misc_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
+ misc_parameters);
+ misc_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
+ misc_parameters);
+
+ MLX5_SET(fte_match_set_misc, misc_c, geneve_vni, mask);
+ MLX5_SET(fte_match_set_misc, misc_v, geneve_vni, key);
+ spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS;
+
+ return 0;
+}
+
struct mlx5e_tc_tunnel geneve_tunnel = {
.tunnel_type = MLX5E_TC_TUNNEL_TYPE_GENEVE,
.match_level = MLX5_MATCH_L4,
@@ -359,5 +396,6 @@ struct mlx5e_tc_tunnel geneve_tunnel = {
.generate_ip_tun_hdr = mlx5e_gen_ip_tunnel_header_geneve,
.parse_udp_ports = mlx5e_tc_tun_parse_udp_ports_geneve,
.parse_tunnel = mlx5e_tc_tun_parse_geneve,
+ .parse_outer_key = mlx5e_tc_tun_parse_outer_key_geneve,
.encap_info_equal = mlx5e_tc_tun_encap_info_equal_geneve,
};
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gre.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gre.c
index 579eda89fc76..1a3d329408f4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gre.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gre.c
@@ -3,6 +3,7 @@
#include <net/gre.h>
#include "en/tc_tun.h"
+#include "fs_core.h"
static bool mlx5e_tc_tun_can_offload_gretap(struct mlx5e_priv *priv)
{
@@ -89,6 +90,35 @@ static int mlx5e_tc_tun_parse_gretap(struct mlx5e_priv *priv,
return 0;
}
+static int
+mlx5e_tc_tun_parse_outer_key_gre(struct mlx5e_priv *priv,
+ struct mlx5_flow_spec *spec,
+ struct netlink_ext_ack *extack,
+ u32 key, u32 mask,
+ enum fs_flow_table_type fs_type)
+{
+ void *misc_c, *misc_v;
+
+ if (!MLX5_CAP_FLOWTABLE_TYPE(priv->mdev,
+ ft_field_support.outer_gre_key,
+ fs_type)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Matching on GRE key is not supported");
+ return -EOPNOTSUPP;
+ }
+
+ misc_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
+ misc_parameters);
+ misc_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
+ misc_parameters);
+
+ MLX5_SET(fte_match_set_misc, misc_c, gre_key.key, mask);
+ MLX5_SET(fte_match_set_misc, misc_v, gre_key.key, key);
+ spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS;
+
+ return 0;
+}
+
struct mlx5e_tc_tunnel gre_tunnel = {
.tunnel_type = MLX5E_TC_TUNNEL_TYPE_GRETAP,
.match_level = MLX5_MATCH_L3,
@@ -98,5 +128,6 @@ struct mlx5e_tc_tunnel gre_tunnel = {
.generate_ip_tun_hdr = mlx5e_gen_ip_tunnel_header_gretap,
.parse_udp_ports = NULL,
.parse_tunnel = mlx5e_tc_tun_parse_gretap,
+ .parse_outer_key = mlx5e_tc_tun_parse_outer_key_gre,
.encap_info_equal = mlx5e_tc_tun_encap_info_equal_generic,
};
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gtp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gtp.c
new file mode 100644
index 000000000000..19c9bc1a30f5
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gtp.c
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
+
+#include "en/tc_tun.h"
+
+static int
+mlx5e_tc_tun_parse_outer_key_gtp(struct mlx5e_priv *priv,
+ struct mlx5_flow_spec *spec,
+ struct netlink_ext_ack *extack,
+ u32 key, u32 mask,
+ enum fs_flow_table_type fs_type)
+{
+ void *misc3_c, *misc3_v;
+
+ if (!(MLX5_CAP_GEN(priv->mdev, flex_parser_protocols) &
+ MLX5_FLEX_PARSER_GTPU_TEID_ENABLED)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Matching on GTP-U TEID is not supported");
+ return -EOPNOTSUPP;
+ }
+
+ misc3_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
+ misc_parameters_3);
+ misc3_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
+ misc_parameters_3);
+
+ MLX5_SET(fte_match_set_misc3, misc3_c, gtpu_teid, mask);
+ MLX5_SET(fte_match_set_misc3, misc3_v, gtpu_teid, key);
+ spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS_3;
+
+ return 0;
+}
+
+/* The driver offloads no GTP device so this only matches on the wire */
+struct mlx5e_tc_tunnel gtp_tunnel = {
+ .parse_outer_key = mlx5e_tc_tun_parse_outer_key_gtp,
+};
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
index 33911e72d20d..610e2bbc21f1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
@@ -5,6 +5,7 @@
#include <net/vxlan.h>
#include "lib/vxlan.h"
#include "en/tc_tun.h"
+#include "fs_core.h"
static bool mlx5e_tc_tun_can_offload_vxlan(struct mlx5e_priv *priv)
{
@@ -261,6 +262,41 @@ static int mlx5e_tc_tun_get_remote_ifindex(struct net_device *mirred_dev)
return ifindex;
}
+static int
+mlx5e_tc_tun_parse_outer_key_vxlan(struct mlx5e_priv *priv,
+ struct mlx5_flow_spec *spec,
+ struct netlink_ext_ack *extack,
+ u32 key, u32 mask,
+ enum fs_flow_table_type fs_type)
+{
+ void *misc_c, *misc_v;
+
+ if (key >= MLX5E_TC_TUN_N_VNI) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Tunnel key does not fit the 24 bit VNI");
+ return -EOPNOTSUPP;
+ }
+
+ if (!MLX5_CAP_FLOWTABLE_TYPE(priv->mdev,
+ ft_field_support.outer_vxlan_vni,
+ fs_type)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Matching on VXLAN VNI is not supported");
+ return -EOPNOTSUPP;
+ }
+
+ misc_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
+ misc_parameters);
+ misc_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
+ misc_parameters);
+
+ MLX5_SET(fte_match_set_misc, misc_c, vxlan_vni, mask);
+ MLX5_SET(fte_match_set_misc, misc_v, vxlan_vni, key);
+ spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS;
+
+ return 0;
+}
+
struct mlx5e_tc_tunnel vxlan_tunnel = {
.tunnel_type = MLX5E_TC_TUNNEL_TYPE_VXLAN,
.match_level = MLX5_MATCH_L4,
@@ -270,6 +306,7 @@ struct mlx5e_tc_tunnel vxlan_tunnel = {
.generate_ip_tun_hdr = mlx5e_gen_ip_tunnel_header_vxlan,
.parse_udp_ports = mlx5e_tc_tun_parse_udp_ports_vxlan,
.parse_tunnel = mlx5e_tc_tun_parse_vxlan,
+ .parse_outer_key = mlx5e_tc_tun_parse_outer_key_vxlan,
.encap_info_equal = mlx5e_tc_tun_encap_info_equal_vxlan,
.get_remote_ifindex = mlx5e_tc_tun_get_remote_ifindex,
};
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 2326fb21da66..d2b961d473b8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2786,6 +2786,10 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
err = mlx5e_tc_verify_tunnel_ecn(priv, f, &match_inner_ecn);
if (err)
return err;
+ } else if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
+ err = mlx5e_tc_tun_parse_outer_key(priv, spec, f, fs_type);
+ if (err)
+ return err;
}
err = mlx5e_flower_parse_meta(filter_dev, f);
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH net-next v2 09/10] net/mlx5e: TC, match the tunnel key without a tunnel device
2026-11-17 9:29 ` [PATCH net-next v2 09/10] net/mlx5e: TC, match the tunnel key without a tunnel device Alexandre Cassen
@ 2026-11-20 3:30 ` netdev-bot+sashiko
0 siblings, 0 replies; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-20 3:30 UTC (permalink / raw)
To: acassen
Cc: saeedm, leon, tariqt, mbloch, jhs, jiri, andrew+netdev, davem,
edumazet, kuba, pabeni, horms, michael.chan, pavan.chebbi, bharat,
donald.hunter, corbet, skhan, rdunlap, dsahern, idosch, shuah,
netdev, linux-rdma, linux-doc, linux-kselftest, oss-drivers
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] When a rule has no tunnel device, the refusal of the other
tunnel keys only runs if enc_key_id is also present.
- [Medium] This one is speculative.
- [Low] The commit message describes an existing user-visible mis-
offload: 'A rule without a tunnel device used to accept enc_key_id…
--
net/mlx5e: TC, match the tunnel key without a tunnel device
This adds a parse_outer_key op to the mlx5e tunnel ops. On a device that
is not a tunnel, a flower enc_key_id match now programs the GRE key,
VXLAN VNI, GENEVE VNI or GTP-U TEID register, chosen by the outer
ip_proto and dst_port keys. Such rules must be skip_sw, cannot decap and
cannot carry other enc_* keys.
> This covers NIC and eswitch flows. A rule without a tunnel device used to
> accept enc_key_id without matching on it. It caught all the traffic of its
> other keys. It now matches the key or gets refused.
[Severity: Low]
This isn't a bug, but this paragraph describes an existing mis-offload.
On a device that is not a tunnel, __parse_cls_flower() accepts
FLOW_DISSECTOR_KEY_ENC_KEYID in its used_keys allow-list, and nothing on
that path reads it.
In this patch the fix arrives as a side effect of a new feature (a new
tc_tun_gtp.c, a new parse_outer_key op, new capability requirements).
There is no Fixes: tag, so the fix can't go to net or stable on its own.
Other fixes in the same series do carry Fixes: tags, for example
"net/mlx5e: TC, refuse a tunnel key wider than the VNI".
Would it make sense to send a minimal fix to net that refuses enc_* keys
when filter_dev is not a tunnel device, and then build the feature on
top of it? That fix would also cover the __parse_cls_flower() gap
described below.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
> index 33911e72d20d0..610e2bbc21f1f 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
[ ... ]
> @@ -261,6 +262,41 @@ static int mlx5e_tc_tun_get_remote_ifindex(struct net_device *mirred_dev)
> return ifindex;
> }
>
> +static int
> +mlx5e_tc_tun_parse_outer_key_vxlan(struct mlx5e_priv *priv,
> + struct mlx5_flow_spec *spec,
> + struct netlink_ext_ack *extack,
> + u32 key, u32 mask,
> + enum fs_flow_table_type fs_type)
> +{
> + void *misc_c, *misc_v;
> +
> + if (key >= MLX5E_TC_TUN_N_VNI) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Tunnel key does not fit the 24 bit VNI");
> + return -EOPNOTSUPP;
> + }
> +
> + if (!MLX5_CAP_FLOWTABLE_TYPE(priv->mdev,
> + ft_field_support.outer_vxlan_vni,
> + fs_type)) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Matching on VXLAN VNI is not supported");
> + return -EOPNOTSUPP;
> + }
[Severity: Medium]
This one may be speculative. Should this path also check the driver's
VXLAN port table?
The tunnel device path goes through
mlx5e_tc_tun_parse_udp_ports_vxlan()->mlx5e_tc_tun_check_udp_dport_vxlan(),
which refuses the rule unless the port is known:
if (!mlx5_vxlan_lookup_port(priv->mdev->vxlan,
be16_to_cpu(enc_ports.key->dst))) {
NL_SET_ERR_MSG_MOD(extack,
"Matched UDP dst port is not registered as a VXLAN port");
mlx5_vxlan_lookup_port() returns false when mlx5_vxlan_allowed() is
false. mlx5_vxlan_create() leaves VXLAN disallowed when
tunnel_stateless_vxlan is missing or the function is not a PF.
Here mlx5e_tc_tun_outer_lookup() picks vxlan_tunnel from an exact
dst_port 4789 alone. After that, only ft_field_support.outer_vxlan_vni is
checked.
Suppose firmware can advertise that capability while the parser does not
handle UDP 4789. Could a skip_sw rule then be installed with a VNI match
that the parser never fills? The rule would match nothing or, if the
masked key includes zero, all UDP/4789 traffic.
I couldn't confirm whether firmware can report outer_vxlan_vni in that
state. mlx5_vxlan_create() notes that the hardware adds 4789 by default,
so this may not happen in practice.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 2326fb21da66b..d2b961d473b89 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -2786,6 +2786,10 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
> err = mlx5e_tc_verify_tunnel_ecn(priv, f, &match_inner_ecn);
> if (err)
> return err;
> + } else if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
> + err = mlx5e_tc_tun_parse_outer_key(priv, spec, f, fs_type);
> + if (err)
> + return err;
> }
[Severity: High]
Can a rule with other enc_* keys but no enc_key_id still be offloaded
without those keys being matched?
The refusal of the other tunnel keys only exists inside
mlx5e_tc_tun_parse_outer_key():
/* Without a tunnel device the other tunnel keys go unmatched */
if (rule->match.dissector->used_keys &
(BIT_ULL(FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS) |
...
That function is only called when FLOW_DISSECTOR_KEY_ENC_KEYID is
present.
The used_keys allow-list at the top of __parse_cls_flower() accepts every
ENC_* key for any filter_dev. Nothing else on the non-tunnel path reads
these keys. mlx5e_get_flow_tunnel_id() and mlx5e_tc_verify_tunnel_ecn()
are only reached through the mlx5e_get_tc_tun(filter_dev) branch.
Take a rule like this:
tc filter add dev <uplink|VF rep|NIC netdev> ingress flower skip_sw \
ip_proto udp enc_dst_port 4789 \
action mirred egress redirect dev <vf_rep>
The same goes for a rule with enc_dst_ip X action drop. Wouldn't such a
rule skip both branches, reach hardware with the enc_* key dropped, and
catch all traffic that matches its other keys?
The over-match itself predates this patch. However, the commit message
says "Nothing matches the other tunnel keys on this path. Refuse them in
such a rule.", and the new code comment states the same rule for any
rule without a tunnel device.
Should this check cover every rule where mlx5e_get_tc_tun(filter_dev)
returns NULL, and not only rules that carry enc_key_id?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117092915.255194-1-acassen%40corp.free.fr
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net-next v2 10/10] docs: networking: describe tunnel key partitioning in TC queue filtering
2026-11-17 9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
` (8 preceding siblings ...)
2026-11-17 9:29 ` [PATCH net-next v2 09/10] net/mlx5e: TC, match the tunnel key without a tunnel device Alexandre Cassen
@ 2026-11-17 9:29 ` Alexandre Cassen
2026-11-20 3:30 ` netdev-bot+sashiko
9 siblings, 1 reply; 17+ messages in thread
From: Alexandre Cassen @ 2026-11-17 9:29 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Jamal Hadi Salim, Jiri Pirko
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael Chan, Pavan Chebbi,
Potnuri Bharat Teja, Donald Hunter, Jonathan Corbet, Shuah Khan,
Randy Dunlap, David Ahern, Ido Schimmel, Shuah Khan, netdev,
linux-rdma, linux-doc, linux-kselftest, oss-drivers
Tunnel key partitioning steers blocks of tunnel flows to RX queues with a
mask on enc_key_id. Document this use and what enc_key_id means on a
physical port of mlx5. Also document what happens to such a filter when
its queue goes away.
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
Documentation/networking/tc-queue-filters.rst | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/Documentation/networking/tc-queue-filters.rst b/Documentation/networking/tc-queue-filters.rst
index 6b417092276f..14032375d630 100644
--- a/Documentation/networking/tc-queue-filters.rst
+++ b/Documentation/networking/tc-queue-filters.rst
@@ -35,3 +35,25 @@ queues and/or a single queue are supported as below:
devices, TC filter directing traffic to a queue have higher
priority over flow director filter assigning a queue. The hash
filter has lowest priority.
+
+Tunnel key partitioning splits the key space of a tunnel into blocks. One
+filter with a mask on enc_key_id steers a block to its own queue. This
+helps with traffic that RSS cannot spread because its hashed fields barely
+vary, such as GTP-U tunnels between a few endpoints::
+
+ # GTP-U TEIDs whose two top bits are 01 go to queue 1
+ tc filter add dev eth0 ingress protocol ip flower skip_sw \
+ ip_proto udp dst_port 2152 enc_key_id 0x40000000/0xc0000000 \
+ action skbedit queue_mapping 1 skip_sw
+
+Not all drivers can program a partial mask.
+
+On mlx5 devices such a filter runs on a physical port where nothing
+decapsulates the packet. All the keys describe the packet on the wire.
+enc_key_id is the only tunnel key such a filter matches.
+ip_proto 0x2f, or udp with dst_port 2152, 4789 or 6081, tells the hardware
+which tunnel header holds the key. The software datapath has no tunnel
+metadata on such a port. Only the hardware can match the key.
+
+Reducing the number of channels below the queue of a filter drops the
+traffic of that filter on mlx5 devices until the channel returns.
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH net-next v2 10/10] docs: networking: describe tunnel key partitioning in TC queue filtering
2026-11-17 9:29 ` [PATCH net-next v2 10/10] docs: networking: describe tunnel key partitioning in TC queue filtering Alexandre Cassen
@ 2026-11-20 3:30 ` netdev-bot+sashiko
0 siblings, 0 replies; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-20 3:30 UTC (permalink / raw)
To: acassen
Cc: saeedm, leon, tariqt, mbloch, jhs, jiri, andrew+netdev, davem,
edumazet, kuba, pabeni, horms, michael.chan, pavan.chebbi, bharat,
donald.hunter, corbet, skhan, rdunlap, dsahern, idosch, shuah,
netdev, linux-rdma, linux-doc, linux-kselftest, oss-drivers
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The new 'Tunnel key partitioning' text in
Documentation/networking/tc-queue-filters.rst (lines 39-56) uses a…
- [Low] The mlx5 paragraph in Documentation/networking/tc-queue-
filters.rst (lines 51-56) says a masked enc_key_id filter "runs on a…
- [Low] Documentation/networking/tc-queue-filters.rst (lines 39-47)
describes splitting "the key space of a tunnel" into blocks, and its…
--
docs: networking: describe tunnel key partitioning in TC queue filtering
This commit documents tunnel key partitioning, where a filter with a mask
on enc_key_id steers a block of tunnel flows to an RX queue. It gives a
GTP-U example, describes what enc_key_id means on an mlx5 physical port,
and explains what happens to the filter's traffic when its channel goes
away.
> diff --git a/Documentation/networking/tc-queue-filters.rst b/Documentation/networking/tc-queue-filters.rst
> index 6b417092276f6..14032375d6308 100644
> --- a/Documentation/networking/tc-queue-filters.rst
> +++ b/Documentation/networking/tc-queue-filters.rst
> @@ -35,3 +35,25 @@ queues and/or a single queue are supported as below:
> devices, TC filter directing traffic to a queue have higher
> priority over flow director filter assigning a queue. The hash
> filter has lowest priority.
> +
> +Tunnel key partitioning splits the key space of a tunnel into blocks. One
> +filter with a mask on enc_key_id steers a block to its own queue. This
> +helps with traffic that RSS cannot spread because its hashed fields barely
> +vary, such as GTP-U tunnels between a few endpoints::
> +
> + # GTP-U TEIDs whose two top bits are 01 go to queue 1
> + tc filter add dev eth0 ingress protocol ip flower skip_sw \
> + ip_proto udp dst_port 2152 enc_key_id 0x40000000/0xc0000000 \
> + action skbedit queue_mapping 1 skip_sw
[Severity: Low]
Does this example work on mlx5 with the default firmware configuration?
mlx5e_tc_tun_parse_outer_key_gtp() refuses the filter unless the firmware
reports the GTP-U TEID flex parser:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gtp.c:mlx5e_tc_tun_parse_outer_key_gtp() {
...
if (!(MLX5_CAP_GEN(priv->mdev, flex_parser_protocols) &
MLX5_FLEX_PARSER_GTPU_TEID_ENABLED)) {
NL_SET_ERR_MSG_MOD(extack,
"Matching on GTP-U TEID is not supported");
return -EOPNOTSUPP;
}
...
}
The GENEVE selector also needs a flex parser bit (MLX5_FLEX_PROTO_GENEVE,
checked through mlx5e_tc_tun_can_offload_geneve()). The preceding commit
"net/mlx5e: TC, match the tunnel key without a tunnel device" says "GTP-U
needs flex parser profile 3 and GENEVE profile 0". That means the 2152 and
6081 selectors listed further down cannot both be available at once.
If the firmware default is profile 0, the firmware will refuse this
example, and the extack message does not mention the flex parser profile.
Could the text mention this firmware dependency?
Also, the example passes skip_sw on the filter, but the text only implies
that it is required ("Only the hardware can match the key").
mlx5e_tc_tun_parse_outer_key() refuses the offload without it:
if (!f->common.skip_sw) {
NL_SET_ERR_MSG_MOD(extack,
"enc_key_id without a tunnel device requires skip_sw");
return -EOPNOTSUPP;
}
Would it help to state that requirement explicitly?
> +
> +Not all drivers can program a partial mask.
> +
> +On mlx5 devices such a filter runs on a physical port where nothing
> +decapsulates the packet. All the keys describe the packet on the wire.
[Severity: Low]
Is "physical port" the full scope here? __parse_cls_flower() calls
mlx5e_tc_tun_parse_outer_key() for any filter_dev that is not a tunnel
device. That includes FDB flows on VF representors:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c:mlx5e_tc_tun_parse_outer_key() {
...
if (fs_type == FS_FT_FDB && !mlx5e_is_uplink_rep(priv) &&
esw->offloads.inline_mode != MLX5_INLINE_MODE_NONE) {
NL_SET_ERR_MSG_MOD(extack,
"Flow is not offloaded due to min inline setting");
return -EOPNOTSUPP;
}
...
}
On a VF representor the keys describe what the VF sent, not the packet on
the physical wire. The text also does not mention the min inline
requirement.
Separately, the example's action is only registered for NIC flows:
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c:tc_acts_nic[] {
...
[FLOW_ACTION_RX_QUEUE_MAPPING] = &mlx5e_tc_act_rx_queue,
...
}
tc_acts_fdb[] has no such entry, and mlx5e_tc_act_get() uses tc_acts_fdb
for MLX5_FLOW_NAMESPACE_FDB. Wouldn't the documented command then be
refused on the uplink representor in switchdev mode, even though that is
the physical port?
Could the paragraph say that queue_mapping steering only applies to NIC
(legacy mode) flows?
> +enc_key_id is the only tunnel key such a filter matches.
> +ip_proto 0x2f, or udp with dst_port 2152, 4789 or 6081, tells the hardware
> +which tunnel header holds the key. The software datapath has no tunnel
[Severity: Low]
Should this mention that VXLAN (4789) and GENEVE (6081) carry a 24 bit
VNI? The example above partitions on the top two bits of a 32 bit key,
but both parsers refuse keys that do not fit in 24 bits:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c:mlx5e_tc_tun_parse_outer_key_vxlan() {
...
if (key >= MLX5E_TC_TUN_N_VNI) {
NL_SET_ERR_MSG_MOD(extack,
"Tunnel key does not fit the 24 bit VNI");
return -EOPNOTSUPP;
}
...
}
mlx5e_tc_tun_parse_outer_key_geneve() has the same check. So a filter that
copies the example with dst_port 4789 and enc_key_id
0x40000000/0xc0000000 would be refused. For those tunnels the top of the
key space is bits 23:22, not 31:30.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117092915.255194-1-acassen%40corp.free.fr
^ permalink raw reply [flat|nested] 17+ messages in thread