]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net/mlx5e: Use custom tunnel header for vxlan gbp
authorVlad Dogaru <vdogaru@nvidia.com>
Wed, 23 Apr 2025 08:36:07 +0000 (11:36 +0300)
committerJakub Kicinski <kuba@kernel.org>
Fri, 25 Apr 2025 01:19:56 +0000 (18:19 -0700)
Symbolic (e.g. "vxlan") and custom (e.g. "tunnel_header_0") tunnels
cannot be combined, but the match params interface does not have fields
for matching on vxlan gbp. To match vxlan bgp, the tc_tun layer uses
tunnel_header_0.

Allow matching on both VNI and GBP by matching the VNI with a custom
tunnel header instead of the symbolic field name.

Matching solely on the VNI continues to use the symbolic field name.

Fixes: 74a778b4a63f ("net/mlx5: HWS, added definers handling")
Signed-off-by: Vlad Dogaru <vdogaru@nvidia.com>
Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Link: https://patch.msgid.link/20250423083611.324567-2-mbloch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c

index 5c762a71818db0c487f936262ded3f90f95f26b4..7a18a469961db809890d69f7d6d8bc656e560946 100644 (file)
@@ -165,9 +165,6 @@ static int mlx5e_tc_tun_parse_vxlan(struct mlx5e_priv *priv,
        struct flow_match_enc_keyid enc_keyid;
        void *misc_c, *misc_v;
 
-       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);
-
        if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID))
                return 0;
 
@@ -182,6 +179,30 @@ static int mlx5e_tc_tun_parse_vxlan(struct mlx5e_priv *priv,
                err = mlx5e_tc_tun_parse_vxlan_gbp_option(priv, spec, f);
                if (err)
                        return err;
+
+               /* We can't mix custom tunnel headers with symbolic ones and we
+                * don't have a symbolic field name for GBP, so we use custom
+                * tunnel headers in this case. We need hardware support to
+                * match on custom tunnel headers, but we already know it's
+                * supported because the previous call successfully checked for
+                * that.
+                */
+               misc_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
+                                     misc_parameters_5);
+               misc_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
+                                     misc_parameters_5);
+
+               /* Shift by 8 to account for the reserved bits in the vxlan
+                * header after the VNI.
+                */
+               MLX5_SET(fte_match_set_misc5, misc_c, tunnel_header_1,
+                        be32_to_cpu(enc_keyid.mask->keyid) << 8);
+               MLX5_SET(fte_match_set_misc5, misc_v, tunnel_header_1,
+                        be32_to_cpu(enc_keyid.key->keyid) << 8);
+
+               spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS_5;
+
+               return 0;
        }
 
        /* match on VNI is required */
@@ -195,6 +216,11 @@ static int mlx5e_tc_tun_parse_vxlan(struct mlx5e_priv *priv,
                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,
                 be32_to_cpu(enc_keyid.mask->keyid));
        MLX5_SET(fte_match_set_misc, misc_v, vxlan_vni,