From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>, kuba@kernel.org
Cc: netdev@vger.kernel.org, Eli Cohen <eli@mellanox.com>,
Roi Dayan <roid@mellanox.com>, Paul Blakey <paulb@mellanox.com>,
Saeed Mahameed <saeedm@mellanox.com>
Subject: [net-next 10/10] net/mlx5e: Support pedit on mpls over UDP decap
Date: Fri, 22 May 2020 16:51:48 -0700 [thread overview]
Message-ID: <20200522235148.28987-11-saeedm@mellanox.com> (raw)
In-Reply-To: <20200522235148.28987-1-saeedm@mellanox.com>
From: Eli Cohen <eli@mellanox.com>
Allow to modify ethernet headers while decapsulating mpls over UDP
packets. This is implemented using the same reformat object used for
decapsulation.
Signed-off-by: Eli Cohen <eli@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 65 +++++++++++++++----
1 file changed, 53 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index a6b18f0444e7..cc669ea450ae 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2900,10 +2900,12 @@ void dealloc_mod_hdr_actions(struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts)
static const struct pedit_headers zero_masks = {};
-static int parse_tc_pedit_action(struct mlx5e_priv *priv,
- const struct flow_action_entry *act, int namespace,
- struct pedit_headers_action *hdrs,
- struct netlink_ext_ack *extack)
+static int
+parse_pedit_to_modify_hdr(struct mlx5e_priv *priv,
+ const struct flow_action_entry *act, int namespace,
+ struct mlx5e_tc_flow_parse_attr *parse_attr,
+ struct pedit_headers_action *hdrs,
+ struct netlink_ext_ack *extack)
{
u8 cmd = (act->id == FLOW_ACTION_MANGLE) ? 0 : 1;
int err = -EOPNOTSUPP;
@@ -2939,6 +2941,46 @@ static int parse_tc_pedit_action(struct mlx5e_priv *priv,
return err;
}
+static int
+parse_pedit_to_reformat(struct mlx5e_priv *priv,
+ const struct flow_action_entry *act,
+ struct mlx5e_tc_flow_parse_attr *parse_attr,
+ struct netlink_ext_ack *extack)
+{
+ u32 mask, val, offset;
+ u32 *p;
+
+ if (act->id != FLOW_ACTION_MANGLE)
+ return -EOPNOTSUPP;
+
+ if (act->mangle.htype != FLOW_ACT_MANGLE_HDR_TYPE_ETH) {
+ NL_SET_ERR_MSG_MOD(extack, "Only Ethernet modification is supported");
+ return -EOPNOTSUPP;
+ }
+
+ mask = ~act->mangle.mask;
+ val = act->mangle.val;
+ offset = act->mangle.offset;
+ p = (u32 *)&parse_attr->eth;
+ *(p + (offset >> 2)) |= (val & mask);
+
+ return 0;
+}
+
+static int parse_tc_pedit_action(struct mlx5e_priv *priv,
+ const struct flow_action_entry *act, int namespace,
+ struct mlx5e_tc_flow_parse_attr *parse_attr,
+ struct pedit_headers_action *hdrs,
+ struct mlx5e_tc_flow *flow,
+ struct netlink_ext_ack *extack)
+{
+ if (flow && flow_flag_test(flow, L3_TO_L2_DECAP))
+ return parse_pedit_to_reformat(priv, act, parse_attr, extack);
+
+ return parse_pedit_to_modify_hdr(priv, act, namespace,
+ parse_attr, hdrs, extack);
+}
+
static int alloc_tc_pedit_action(struct mlx5e_priv *priv, int namespace,
struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
@@ -3197,7 +3239,7 @@ static int add_vlan_rewrite_action(struct mlx5e_priv *priv, int namespace,
return -EOPNOTSUPP;
}
- err = parse_tc_pedit_action(priv, &pedit_act, namespace, hdrs, NULL);
+ err = parse_tc_pedit_action(priv, &pedit_act, namespace, parse_attr, hdrs, NULL, extack);
*action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
return err;
@@ -3263,7 +3305,7 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
case FLOW_ACTION_MANGLE:
case FLOW_ACTION_ADD:
err = parse_tc_pedit_action(priv, act, MLX5_FLOW_NAMESPACE_KERNEL,
- hdrs, extack);
+ parse_attr, hdrs, NULL, extack);
if (err)
return err;
@@ -3932,16 +3974,15 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
break;
case FLOW_ACTION_MANGLE:
case FLOW_ACTION_ADD:
- if (flow_flag_test(flow, L3_TO_L2_DECAP))
- return -EOPNOTSUPP;
-
err = parse_tc_pedit_action(priv, act, MLX5_FLOW_NAMESPACE_FDB,
- hdrs, extack);
+ parse_attr, hdrs, flow, extack);
if (err)
return err;
- action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
- attr->split_count = attr->out_count;
+ if (!flow_flag_test(flow, L3_TO_L2_DECAP)) {
+ action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
+ attr->split_count = attr->out_count;
+ }
break;
case FLOW_ACTION_CSUM:
if (csum_offload_supported(priv, action,
--
2.25.4
next prev parent reply other threads:[~2020-05-22 23:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-22 23:51 [pull request][net-next 00/10] mlx5 updates 2020-05-22 Saeed Mahameed
2020-05-22 23:51 ` [net-next 01/10] net/mlx5e: Use IS_ERR() to check and simplify code Saeed Mahameed
2020-05-22 23:51 ` [net-next 02/10] net/mlx5e: Extract TC-specific code from en_rep.c to rep/tc.c Saeed Mahameed
2020-05-22 23:51 ` [net-next 03/10] net/mlx5e: Extract neigh-specific code from en_rep.c to rep/neigh.c Saeed Mahameed
2020-05-22 23:51 ` [net-next 04/10] net/mlx5e: Move TC-specific code from en_main.c to en_tc.c Saeed Mahameed
2020-05-22 23:51 ` [net-next 05/10] net/mlx5e: Introduce kconfig var for TC support Saeed Mahameed
2020-05-25 14:46 ` Marcelo Ricardo Leitner
2020-05-27 5:08 ` Saeed Mahameed
2020-05-22 23:51 ` [net-next 06/10] net: Add netif_is_bareudp() API to identify bareudp devices Saeed Mahameed
2020-05-22 23:51 ` [net-next 07/10] net/mlx5e: Add support for hw encapsulation of MPLS over UDP Saeed Mahameed
2020-05-26 19:19 ` Jakub Kicinski
2020-05-26 19:27 ` David Ahern
2020-05-27 5:15 ` Saeed Mahameed
2020-05-22 23:51 ` [net-next 08/10] net/mlx5e: Allow to match on mpls parameters Saeed Mahameed
2020-05-22 23:51 ` [net-next 09/10] net/mlx5e: Add support for hw decapsulation of MPLS over UDP Saeed Mahameed
2020-05-22 23:51 ` Saeed Mahameed [this message]
2020-05-22 23:58 ` [pull request][net-next 00/10] mlx5 updates 2020-05-22 Saeed Mahameed
2020-05-23 23:39 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200522235148.28987-11-saeedm@mellanox.com \
--to=saeedm@mellanox.com \
--cc=davem@davemloft.net \
--cc=eli@mellanox.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paulb@mellanox.com \
--cc=roid@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).