From: Rongwei Liu <rongweil@nvidia.com>
To: <dev@dpdk.org>, <matan@nvidia.com>, <viacheslavo@nvidia.com>,
<orika@nvidia.com>, <suanmingm@nvidia.com>, <thomas@monjalon.net>
Cc: Hamdan Igbaria <hamdani@nvidia.com>, Alex Vesker <valex@nvidia.com>
Subject: [PATCH v4 02/13] net/mlx5/hws: support remove header action
Date: Wed, 1 Nov 2023 06:44:08 +0200 [thread overview]
Message-ID: <20231101044419.732726-3-rongweil@nvidia.com> (raw)
In-Reply-To: <20231101044419.732726-1-rongweil@nvidia.com>
From: Hamdan Igbaria <hamdani@nvidia.com>
Support remove header action, this action will allow the user
to execute dynamic decaps by choosing to decap by providing a
start anchor and number of words to remove, or providing a
start anchor and end anchor.
Signed-off-by: Hamdan Igbaria <hamdani@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
drivers/net/mlx5/hws/mlx5dr.h | 40 +++++++++++++++
drivers/net/mlx5/hws/mlx5dr_action.c | 77 ++++++++++++++++++++++++++++
drivers/net/mlx5/hws/mlx5dr_action.h | 7 +++
drivers/net/mlx5/hws/mlx5dr_debug.c | 1 +
4 files changed, 125 insertions(+)
diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h
index f3367297c6..e21dcd72ae 100644
--- a/drivers/net/mlx5/hws/mlx5dr.h
+++ b/drivers/net/mlx5/hws/mlx5dr.h
@@ -46,6 +46,7 @@ enum mlx5dr_action_type {
MLX5DR_ACTION_TYP_ASO_METER,
MLX5DR_ACTION_TYP_ASO_CT,
MLX5DR_ACTION_TYP_INSERT_HEADER,
+ MLX5DR_ACTION_TYP_REMOVE_HEADER,
MLX5DR_ACTION_TYP_DEST_ROOT,
MLX5DR_ACTION_TYP_DEST_ARRAY,
MLX5DR_ACTION_TYP_MAX,
@@ -184,6 +185,29 @@ struct mlx5dr_action_insert_header {
bool encap;
};
+enum mlx5dr_action_remove_header_type {
+ MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_OFFSET,
+ MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_HEADER,
+};
+
+struct mlx5dr_action_remove_header_attr {
+ enum mlx5dr_action_remove_header_type type;
+ union {
+ struct {
+ /* PRM start anchor from which header will be removed */
+ uint8_t start_anchor;
+ /* PRM end anchor till which header will be removed */
+ uint8_t end_anchor;
+ bool decap;
+ } by_anchor;
+ struct {
+ /* PRM start anchor from which header will be removed */
+ uint8_t start_anchor;
+ uint8_t size;
+ } by_offset;
+ };
+};
+
struct mlx5dr_action_mh_pattern {
/* Byte size of modify actions provided by "data" */
size_t sz;
@@ -727,6 +751,22 @@ mlx5dr_action_create_insert_header(struct mlx5dr_context *ctx,
uint32_t log_bulk_size,
uint32_t flags);
+/* Create remove header action.
+ *
+ * @param[in] ctx
+ * The context in which the new action will be created.
+ * @param[in] attr
+ * attributes: specifies the remove header type, PRM start anchor and
+ * the PRM end anchor or the PRM start anchor and remove size in bytes.
+ * @param[in] flags
+ * Action creation flags. (enum mlx5dr_action_flags)
+ * @return pointer to mlx5dr_action on success NULL otherwise.
+ */
+struct mlx5dr_action *
+mlx5dr_action_create_remove_header(struct mlx5dr_context *ctx,
+ struct mlx5dr_action_remove_header_attr *attr,
+ uint32_t flags);
+
/* Destroy direct rule action.
*
* @param[in] action
diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c
index 45e23e2d28..f794d6cd78 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.c
+++ b/drivers/net/mlx5/hws/mlx5dr_action.c
@@ -7,6 +7,8 @@
#define WIRE_PORT 0xFFFF
#define MLX5DR_ACTION_METER_INIT_COLOR_OFFSET 1
+/* Header removal size limited to 128B (64 words) */
+#define MLX5DR_ACTION_REMOVE_HEADER_MAX_SIZE 128
/* This is the maximum allowed action order for each table type:
* TX: POP_VLAN, CTR, ASO_METER, AS_CT, PUSH_VLAN, MODIFY, ENCAP, Term
@@ -18,6 +20,7 @@
static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_MAX] = {
[MLX5DR_TABLE_TYPE_NIC_RX] = {
BIT(MLX5DR_ACTION_TYP_TAG),
+ BIT(MLX5DR_ACTION_TYP_REMOVE_HEADER) |
BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2) |
BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2),
BIT(MLX5DR_ACTION_TYP_POP_VLAN),
@@ -58,6 +61,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_
BIT(MLX5DR_ACTION_TYP_LAST),
},
[MLX5DR_TABLE_TYPE_FDB] = {
+ BIT(MLX5DR_ACTION_TYP_REMOVE_HEADER) |
BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2) |
BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2),
BIT(MLX5DR_ACTION_TYP_POP_VLAN),
@@ -603,6 +607,19 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
attr->insert_header.insert_offset = MLX5DR_ACTION_HDR_LEN_L2_MACS;
attr->insert_header.header_size = MLX5DR_ACTION_HDR_LEN_L2_VLAN;
break;
+ case MLX5DR_ACTION_TYP_REMOVE_HEADER:
+ if (action->remove_header.type == MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_HEADER) {
+ attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_REMOVE;
+ attr->remove_header.decap = action->remove_header.decap;
+ attr->remove_header.start_anchor = action->remove_header.start_anchor;
+ attr->remove_header.end_anchor = action->remove_header.end_anchor;
+ } else {
+ attr->action_type = MLX5_IFC_STC_ACTION_TYPE_REMOVE_WORDS;
+ attr->remove_words.start_anchor = action->remove_header.start_anchor;
+ attr->remove_words.num_of_words = action->remove_header.num_of_words;
+ }
+ attr->action_offset = MLX5DR_ACTION_OFFSET_DW5;
+ break;
default:
DR_LOG(ERR, "Invalid action type %d", action->type);
assert(false);
@@ -2023,6 +2040,64 @@ mlx5dr_action_create_insert_header(struct mlx5dr_context *ctx,
return NULL;
}
+struct mlx5dr_action *
+mlx5dr_action_create_remove_header(struct mlx5dr_context *ctx,
+ struct mlx5dr_action_remove_header_attr *attr,
+ uint32_t flags)
+{
+ struct mlx5dr_action *action;
+
+ if (mlx5dr_action_is_root_flags(flags)) {
+ DR_LOG(ERR, "Remove header action not supported over root");
+ rte_errno = ENOTSUP;
+ return NULL;
+ }
+
+ action = mlx5dr_action_create_generic(ctx, flags, MLX5DR_ACTION_TYP_REMOVE_HEADER);
+ if (!action)
+ return NULL;
+
+ switch (attr->type) {
+ case MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_HEADER:
+ action->remove_header.type = MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_HEADER;
+ action->remove_header.start_anchor = attr->by_anchor.start_anchor;
+ action->remove_header.end_anchor = attr->by_anchor.end_anchor;
+ action->remove_header.decap = attr->by_anchor.decap;
+ break;
+ case MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_OFFSET:
+ if (attr->by_offset.size % W_SIZE != 0) {
+ DR_LOG(ERR, "Invalid size, HW supports header remove in WORD granularity");
+ rte_errno = EINVAL;
+ goto free_action;
+ }
+
+ if (attr->by_offset.size > MLX5DR_ACTION_REMOVE_HEADER_MAX_SIZE) {
+ DR_LOG(ERR, "Header removal size limited to %u bytes",
+ MLX5DR_ACTION_REMOVE_HEADER_MAX_SIZE);
+ rte_errno = EINVAL;
+ goto free_action;
+ }
+
+ action->remove_header.type = MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_OFFSET;
+ action->remove_header.start_anchor = attr->by_offset.start_anchor;
+ action->remove_header.num_of_words = attr->by_offset.size / W_SIZE;
+ break;
+ default:
+ DR_LOG(ERR, "Unsupported remove header type %u", attr->type);
+ rte_errno = ENOTSUP;
+ goto free_action;
+ }
+
+ if (mlx5dr_action_create_stcs(action, NULL))
+ goto free_action;
+
+ return action;
+
+free_action:
+ simple_free(action);
+ return NULL;
+}
+
static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action)
{
struct mlx5dr_devx_obj *obj = NULL;
@@ -2043,6 +2118,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action)
case MLX5DR_ACTION_TYP_ASO_METER:
case MLX5DR_ACTION_TYP_ASO_CT:
case MLX5DR_ACTION_TYP_PUSH_VLAN:
+ case MLX5DR_ACTION_TYP_REMOVE_HEADER:
mlx5dr_action_destroy_stcs(action);
break;
case MLX5DR_ACTION_TYP_DEST_ROOT:
@@ -2620,6 +2696,7 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at)
setter->idx_double = i;
break;
+ case MLX5DR_ACTION_TYP_REMOVE_HEADER:
case MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2:
/* Single remove header to header */
setter = mlx5dr_action_setter_find_first(last_setter, ASF_SINGLE1 | ASF_MODIFY);
diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h
index 593a7f3817..33a674906e 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.h
+++ b/drivers/net/mlx5/hws/mlx5dr_action.h
@@ -159,6 +159,13 @@ struct mlx5dr_action {
size_t num_dest;
struct mlx5dr_cmd_set_fte_dest *dest_list;
} dest_array;
+ struct {
+ uint8_t type;
+ uint8_t start_anchor;
+ uint8_t end_anchor;
+ uint8_t num_of_words;
+ bool decap;
+ } remove_header;
};
};
diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c
index a04dfbb97a..6607daaa63 100644
--- a/drivers/net/mlx5/hws/mlx5dr_debug.c
+++ b/drivers/net/mlx5/hws/mlx5dr_debug.c
@@ -25,6 +25,7 @@ const char *mlx5dr_debug_action_type_str[] = {
[MLX5DR_ACTION_TYP_DEST_ROOT] = "DEST_ROOT",
[MLX5DR_ACTION_TYP_DEST_ARRAY] = "DEST_ARRAY",
[MLX5DR_ACTION_TYP_INSERT_HEADER] = "INSERT_HEADER",
+ [MLX5DR_ACTION_TYP_REMOVE_HEADER] = "REMOVE_HEADER",
};
static_assert(ARRAY_SIZE(mlx5dr_debug_action_type_str) == MLX5DR_ACTION_TYP_MAX,
--
2.27.0
next prev parent reply other threads:[~2023-11-01 4:45 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 9:25 [PATCH v1 0/8] add IPv6 extension push remove Rongwei Liu
2023-04-17 9:25 ` [PATCH v1 1/8] ethdev: add IPv6 extension push remove action Rongwei Liu
2023-05-24 6:55 ` Ori Kam
2023-05-24 7:39 ` [PATCH v1 0/2] add IPv6 extension push remove Rongwei Liu
2023-05-24 7:39 ` [PATCH v1 1/2] ethdev: add IPv6 extension push remove action Rongwei Liu
2023-05-24 10:30 ` Ori Kam
2023-05-24 7:39 ` [PATCH v1 2/2] app/testpmd: add IPv6 extension push remove cli Rongwei Liu
2023-06-02 14:39 ` [PATCH v1 0/2] add IPv6 extension push remove Ferruh Yigit
2023-07-10 2:32 ` Rongwei Liu
2023-07-10 8:55 ` Ferruh Yigit
2023-07-10 14:41 ` Stephen Hemminger
2023-07-11 6:16 ` Thomas Monjalon
2023-09-19 8:12 ` [PATCH v3] net/mlx5: add test for live migration Rongwei Liu
2023-10-16 8:19 ` Thomas Monjalon
2023-10-16 8:25 ` Rongwei Liu
2023-10-16 9:26 ` Rongwei Liu
2023-10-16 9:26 ` Thomas Monjalon
2023-10-16 9:29 ` Rongwei Liu
2023-10-25 9:07 ` Rongwei Liu
2023-10-16 9:22 ` [PATCH v4] " Rongwei Liu
2023-10-25 9:36 ` [PATCH v5] " Rongwei Liu
2023-10-25 9:41 ` Thomas Monjalon
2023-10-25 9:45 ` [PATCH v6] " Rongwei Liu
2023-10-25 9:48 ` [PATCH v5] " Rongwei Liu
2023-10-25 9:50 ` [PATCH v7] " Rongwei Liu
2023-10-25 13:10 ` Thomas Monjalon
2023-10-26 8:15 ` Raslan Darawsheh
2023-04-17 9:25 ` [PATCH v1 2/8] app/testpmd: add IPv6 extension push remove cli Rongwei Liu
2023-05-24 7:06 ` Ori Kam
2023-04-17 9:25 ` [PATCH v1 3/8] net/mlx5/hws: add no reparse support Rongwei Liu
2023-04-17 9:25 ` [PATCH v1 4/8] net/mlx5: sample the srv6 last segment Rongwei Liu
2023-10-31 9:42 ` [PATCH v2 0/6] support IPv6 extension push remove Rongwei Liu
2023-10-31 9:42 ` [PATCH v2 1/6] net/mlx5: sample the srv6 last segment Rongwei Liu
2023-10-31 9:42 ` [PATCH v2 2/6] net/mlx5/hws: fix potential wrong errno value Rongwei Liu
2023-10-31 9:42 ` [PATCH v2 3/6] net/mlx5/hws: add IPv6 routing extension push remove actions Rongwei Liu
2023-10-31 9:42 ` [PATCH v2 4/6] net/mlx5/hws: add setter for IPv6 routing push remove Rongwei Liu
2023-10-31 9:42 ` [PATCH v2 5/6] net/mlx5: implement " Rongwei Liu
2023-10-31 9:42 ` [PATCH v2 6/6] net/mlx5/hws: add stc reparse support for srv6 push pop Rongwei Liu
2023-10-31 10:51 ` [PATCH v3 0/6] support IPv6 extension push remove Rongwei Liu
2023-10-31 10:51 ` [PATCH v3 1/6] net/mlx5: sample the srv6 last segment Rongwei Liu
2023-10-31 10:51 ` [PATCH v3 2/6] net/mlx5/hws: fix potential wrong errno value Rongwei Liu
2023-10-31 10:51 ` [PATCH v3 3/6] net/mlx5/hws: add IPv6 routing extension push remove actions Rongwei Liu
2023-10-31 10:51 ` [PATCH v3 4/6] net/mlx5/hws: add setter for IPv6 routing push remove Rongwei Liu
2023-10-31 10:51 ` [PATCH v3 5/6] net/mlx5: implement " Rongwei Liu
2023-10-31 10:51 ` [PATCH v3 6/6] net/mlx5/hws: add stc reparse support for srv6 push pop Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 00/13] support IPv6 push remove action Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 01/13] net/mlx5/hws: support insert header action Rongwei Liu
2023-11-01 4:44 ` Rongwei Liu [this message]
2023-11-01 4:44 ` [PATCH v4 03/13] net/mlx5/hws: allow jump to TIR over FDB Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 04/13] net/mlx5/hws: support dynamic re-parse Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 05/13] net/mlx5/hws: dynamic re-parse for modify header Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 06/13] net/mlx5/hws: fix incorrect re-parse on complex rules Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 07/13] net/mlx5: sample the srv6 last segment Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 08/13] net/mlx5/hws: fix potential wrong rte_errno value Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 09/13] net/mlx5/hws: add IPv6 routing extension push remove actions Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 10/13] net/mlx5/hws: add setter for IPv6 routing push remove Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 11/13] net/mlx5: implement " Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 12/13] net/mlx5/hws: fix srv6 push compilation failure Rongwei Liu
2023-11-01 4:44 ` [PATCH v4 13/13] net/mlx5/hws: add stc reparse support for srv6 push pop Rongwei Liu
2023-11-02 13:44 ` [PATCH v4 00/13] support IPv6 push remove action Raslan Darawsheh
2023-04-17 9:25 ` [PATCH v1 5/8] net/mlx5: generate srv6 modify header resource Rongwei Liu
2023-04-17 9:25 ` [PATCH v1 6/8] net/mlx5/hws: add IPv6 routing extension push pop actions Rongwei Liu
2023-04-17 9:25 ` [PATCH v1 7/8] net/mlx5/hws: add setter for IPv6 routing push pop Rongwei Liu
2023-04-17 9:25 ` [PATCH v1 8/8] net/mlx5: implement " Rongwei Liu
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=20231101044419.732726-3-rongweil@nvidia.com \
--to=rongweil@nvidia.com \
--cc=dev@dpdk.org \
--cc=hamdani@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=suanmingm@nvidia.com \
--cc=thomas@monjalon.net \
--cc=valex@nvidia.com \
--cc=viacheslavo@nvidia.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).