You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
328 lines
12 KiB
328 lines
12 KiB
From af5a918bec18ded5235fe365baf92c6978e36369 Mon Sep 17 00:00:00 2001
|
|
From: Alaa Hleihel <ahleihel@redhat.com>
|
|
Date: Tue, 19 May 2020 07:48:55 -0400
|
|
Subject: [PATCH 233/312] [netdrv] net/mlx5e: Move tc tunnel parsing logic with
|
|
the rest at tc_tun module
|
|
|
|
Message-id: <20200519074934.6303-25-ahleihel@redhat.com>
|
|
Patchwork-id: 310526
|
|
Patchwork-instance: patchwork
|
|
O-Subject: [RHEL8.3 BZ 1663246 24/63] net/mlx5e: Move tc tunnel parsing logic with the rest at tc_tun module
|
|
Bugzilla: 1790219 1790218 1663246
|
|
RH-Acked-by: Marcelo Leitner <mleitner@redhat.com>
|
|
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
|
|
RH-Acked-by: John Linville <linville@redhat.com>
|
|
RH-Acked-by: Ivan Vecera <ivecera@redhat.com>
|
|
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
|
|
RH-Acked-by: Kamal Heib <kheib@redhat.com>
|
|
|
|
Bugzilla: http://bugzilla.redhat.com/1663246
|
|
Bugzilla: http://bugzilla.redhat.com/1790219
|
|
Bugzilla: http://bugzilla.redhat.com/1790218
|
|
Upstream: v5.7-rc1
|
|
|
|
commit ea4cd837b99df6693c3aa067ade528f62544c18d
|
|
Author: Paul Blakey <paulb@mellanox.com>
|
|
Date: Sun Feb 16 12:01:32 2020 +0200
|
|
|
|
net/mlx5e: Move tc tunnel parsing logic with the rest at tc_tun module
|
|
|
|
Currently, tunnel parsing is split between en_tc and tc_tun. The next
|
|
patch will replace the tunnel fields matching with a register match,
|
|
and will not need this parsing.
|
|
|
|
Move the tunnel parsing logic to tc_tun as a pre-step for skipping
|
|
it in the next patch.
|
|
|
|
Signed-off-by: Paul Blakey <paulb@mellanox.com>
|
|
Reviewed-by: Roi Dayan <roid@mellanox.com>
|
|
Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
|
|
Reviewed-by: Mark Bloch <markb@mellanox.com>
|
|
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
|
|
|
|
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
|
|
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
|
|
---
|
|
.../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 112 ++++++++++++++++++++-
|
|
.../net/ethernet/mellanox/mlx5/core/en/tc_tun.h | 3 +-
|
|
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 109 +-------------------
|
|
3 files changed, 112 insertions(+), 112 deletions(-)
|
|
|
|
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 b855933f6bec..ae497981ce58 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
|
|
@@ -469,10 +469,15 @@ int mlx5e_tc_tun_parse(struct net_device *filter_dev,
|
|
struct mlx5e_priv *priv,
|
|
struct mlx5_flow_spec *spec,
|
|
struct flow_cls_offload *f,
|
|
- void *headers_c,
|
|
- void *headers_v, u8 *match_level)
|
|
+ u8 *match_level)
|
|
{
|
|
struct mlx5e_tc_tunnel *tunnel = mlx5e_get_tc_tun(filter_dev);
|
|
+ struct flow_rule *rule = flow_cls_offload_flow_rule(f);
|
|
+ void *headers_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
|
|
+ outer_headers);
|
|
+ void *headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
|
|
+ outer_headers);
|
|
+ struct netlink_ext_ack *extack = f->common.extack;
|
|
int err = 0;
|
|
|
|
if (!tunnel) {
|
|
@@ -499,6 +504,109 @@ int mlx5e_tc_tun_parse(struct net_device *filter_dev,
|
|
goto out;
|
|
}
|
|
|
|
+ if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_CONTROL)) {
|
|
+ struct flow_match_control match;
|
|
+ u16 addr_type;
|
|
+
|
|
+ flow_rule_match_enc_control(rule, &match);
|
|
+ addr_type = match.key->addr_type;
|
|
+
|
|
+ /* For tunnel addr_type used same key id`s as for non-tunnel */
|
|
+ if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
|
|
+ struct flow_match_ipv4_addrs match;
|
|
+
|
|
+ flow_rule_match_enc_ipv4_addrs(rule, &match);
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_c,
|
|
+ src_ipv4_src_ipv6.ipv4_layout.ipv4,
|
|
+ ntohl(match.mask->src));
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_v,
|
|
+ src_ipv4_src_ipv6.ipv4_layout.ipv4,
|
|
+ ntohl(match.key->src));
|
|
+
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_c,
|
|
+ dst_ipv4_dst_ipv6.ipv4_layout.ipv4,
|
|
+ ntohl(match.mask->dst));
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_v,
|
|
+ dst_ipv4_dst_ipv6.ipv4_layout.ipv4,
|
|
+ ntohl(match.key->dst));
|
|
+
|
|
+ MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
|
|
+ ethertype);
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype,
|
|
+ ETH_P_IP);
|
|
+ } else if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
|
|
+ struct flow_match_ipv6_addrs match;
|
|
+
|
|
+ flow_rule_match_enc_ipv6_addrs(rule, &match);
|
|
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c,
|
|
+ src_ipv4_src_ipv6.ipv6_layout.ipv6),
|
|
+ &match.mask->src, MLX5_FLD_SZ_BYTES(ipv6_layout,
|
|
+ ipv6));
|
|
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
|
|
+ src_ipv4_src_ipv6.ipv6_layout.ipv6),
|
|
+ &match.key->src, MLX5_FLD_SZ_BYTES(ipv6_layout,
|
|
+ ipv6));
|
|
+
|
|
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c,
|
|
+ dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
|
|
+ &match.mask->dst, MLX5_FLD_SZ_BYTES(ipv6_layout,
|
|
+ ipv6));
|
|
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
|
|
+ dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
|
|
+ &match.key->dst, MLX5_FLD_SZ_BYTES(ipv6_layout,
|
|
+ ipv6));
|
|
+
|
|
+ MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
|
|
+ ethertype);
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype,
|
|
+ ETH_P_IPV6);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_IP)) {
|
|
+ struct flow_match_ip match;
|
|
+
|
|
+ flow_rule_match_enc_ip(rule, &match);
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_c, ip_ecn,
|
|
+ match.mask->tos & 0x3);
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn,
|
|
+ match.key->tos & 0x3);
|
|
+
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_c, ip_dscp,
|
|
+ match.mask->tos >> 2);
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_dscp,
|
|
+ match.key->tos >> 2);
|
|
+
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_c, ttl_hoplimit,
|
|
+ match.mask->ttl);
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_v, ttl_hoplimit,
|
|
+ match.key->ttl);
|
|
+
|
|
+ if (match.mask->ttl &&
|
|
+ !MLX5_CAP_ESW_FLOWTABLE_FDB
|
|
+ (priv->mdev,
|
|
+ ft_field_support.outer_ipv4_ttl)) {
|
|
+ NL_SET_ERR_MSG_MOD(extack,
|
|
+ "Matching on TTL is not supported");
|
|
+ err = -EOPNOTSUPP;
|
|
+ goto out;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /* Enforce DMAC when offloading incoming tunneled flows.
|
|
+ * Flow counters require a match on the DMAC.
|
|
+ */
|
|
+ MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, dmac_47_16);
|
|
+ MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, dmac_15_0);
|
|
+ ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
|
|
+ dmac_47_16), priv->netdev->dev_addr);
|
|
+
|
|
+ /* let software handle IP fragments */
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_c, frag, 1);
|
|
+ MLX5_SET(fte_match_set_lyr_2_4, headers_v, frag, 0);
|
|
+
|
|
+ return 0;
|
|
+
|
|
out:
|
|
return err;
|
|
}
|
|
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 6f9a78c85ffd..1630f0ec3ad7 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h
|
|
@@ -76,8 +76,7 @@ int mlx5e_tc_tun_parse(struct net_device *filter_dev,
|
|
struct mlx5e_priv *priv,
|
|
struct mlx5_flow_spec *spec,
|
|
struct flow_cls_offload *f,
|
|
- void *headers_c,
|
|
- void *headers_v, u8 *match_level);
|
|
+ u8 *match_level);
|
|
|
|
int mlx5e_tc_tun_parse_udp_ports(struct mlx5e_priv *priv,
|
|
struct mlx5_flow_spec *spec,
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
|
|
index 747979c6601a..3d0a5c63d083 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
|
|
@@ -1675,122 +1675,15 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
|
|
struct net_device *filter_dev, u8 *match_level)
|
|
{
|
|
struct netlink_ext_ack *extack = f->common.extack;
|
|
- void *headers_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
|
|
- outer_headers);
|
|
- void *headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
|
|
- outer_headers);
|
|
- struct flow_rule *rule = flow_cls_offload_flow_rule(f);
|
|
int err;
|
|
|
|
- err = mlx5e_tc_tun_parse(filter_dev, priv, spec, f,
|
|
- headers_c, headers_v, match_level);
|
|
+ err = mlx5e_tc_tun_parse(filter_dev, priv, spec, f, match_level);
|
|
if (err) {
|
|
NL_SET_ERR_MSG_MOD(extack,
|
|
"failed to parse tunnel attributes");
|
|
return err;
|
|
}
|
|
|
|
- if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_CONTROL)) {
|
|
- struct flow_match_control match;
|
|
- u16 addr_type;
|
|
-
|
|
- flow_rule_match_enc_control(rule, &match);
|
|
- addr_type = match.key->addr_type;
|
|
-
|
|
- /* For tunnel addr_type used same key id`s as for non-tunnel */
|
|
- if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
|
|
- struct flow_match_ipv4_addrs match;
|
|
-
|
|
- flow_rule_match_enc_ipv4_addrs(rule, &match);
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_c,
|
|
- src_ipv4_src_ipv6.ipv4_layout.ipv4,
|
|
- ntohl(match.mask->src));
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_v,
|
|
- src_ipv4_src_ipv6.ipv4_layout.ipv4,
|
|
- ntohl(match.key->src));
|
|
-
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_c,
|
|
- dst_ipv4_dst_ipv6.ipv4_layout.ipv4,
|
|
- ntohl(match.mask->dst));
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_v,
|
|
- dst_ipv4_dst_ipv6.ipv4_layout.ipv4,
|
|
- ntohl(match.key->dst));
|
|
-
|
|
- MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
|
|
- ethertype);
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype,
|
|
- ETH_P_IP);
|
|
- } else if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
|
|
- struct flow_match_ipv6_addrs match;
|
|
-
|
|
- flow_rule_match_enc_ipv6_addrs(rule, &match);
|
|
- memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c,
|
|
- src_ipv4_src_ipv6.ipv6_layout.ipv6),
|
|
- &match.mask->src, MLX5_FLD_SZ_BYTES(ipv6_layout,
|
|
- ipv6));
|
|
- memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
|
|
- src_ipv4_src_ipv6.ipv6_layout.ipv6),
|
|
- &match.key->src, MLX5_FLD_SZ_BYTES(ipv6_layout,
|
|
- ipv6));
|
|
-
|
|
- memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c,
|
|
- dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
|
|
- &match.mask->dst, MLX5_FLD_SZ_BYTES(ipv6_layout,
|
|
- ipv6));
|
|
- memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
|
|
- dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
|
|
- &match.key->dst, MLX5_FLD_SZ_BYTES(ipv6_layout,
|
|
- ipv6));
|
|
-
|
|
- MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
|
|
- ethertype);
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype,
|
|
- ETH_P_IPV6);
|
|
- }
|
|
- }
|
|
-
|
|
- if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_IP)) {
|
|
- struct flow_match_ip match;
|
|
-
|
|
- flow_rule_match_enc_ip(rule, &match);
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_c, ip_ecn,
|
|
- match.mask->tos & 0x3);
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn,
|
|
- match.key->tos & 0x3);
|
|
-
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_c, ip_dscp,
|
|
- match.mask->tos >> 2);
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_dscp,
|
|
- match.key->tos >> 2);
|
|
-
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_c, ttl_hoplimit,
|
|
- match.mask->ttl);
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_v, ttl_hoplimit,
|
|
- match.key->ttl);
|
|
-
|
|
- if (match.mask->ttl &&
|
|
- !MLX5_CAP_ESW_FLOWTABLE_FDB
|
|
- (priv->mdev,
|
|
- ft_field_support.outer_ipv4_ttl)) {
|
|
- NL_SET_ERR_MSG_MOD(extack,
|
|
- "Matching on TTL is not supported");
|
|
- return -EOPNOTSUPP;
|
|
- }
|
|
-
|
|
- }
|
|
-
|
|
- /* Enforce DMAC when offloading incoming tunneled flows.
|
|
- * Flow counters require a match on the DMAC.
|
|
- */
|
|
- MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, dmac_47_16);
|
|
- MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, dmac_15_0);
|
|
- ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
|
|
- dmac_47_16), priv->netdev->dev_addr);
|
|
-
|
|
- /* let software handle IP fragments */
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_c, frag, 1);
|
|
- MLX5_SET(fte_match_set_lyr_2_4, headers_v, frag, 0);
|
|
-
|
|
return 0;
|
|
}
|
|
|
|
--
|
|
2.13.6
|
|
|