From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>
Cc: <getelson@nvidia.com>, <mkashani@nvidia.com>,
<rasland@nvidia.com>, "Hamdan Igbaria" <hamdani@nvidia.com>,
Alex Vesker <valex@nvidia.com>, Matan Azrad <matan@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>
Subject: [PATCH 21/30] net/mlx5/hws: support remove header action
Date: Sun, 29 Oct 2023 18:31:53 +0200 [thread overview]
Message-ID: <20231029163202.216450-21-getelson@nvidia.com> (raw)
In-Reply-To: <20231029163202.216450-1-getelson@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: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx5/hws/mlx5dr.h | 40 ++++++++++++++
drivers/net/mlx5/hws/mlx5dr_action.c | 78 ++++++++++++++++++++++++++++
drivers/net/mlx5/hws/mlx5dr_action.h | 7 +++
drivers/net/mlx5/hws/mlx5dr_debug.c | 1 +
4 files changed, 126 insertions(+)
diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h
index a6bbb85eed..2e692f76c3 100644
--- a/drivers/net/mlx5/hws/mlx5dr.h
+++ b/drivers/net/mlx5/hws/mlx5dr.h
@@ -51,6 +51,7 @@ enum mlx5dr_action_type {
MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT,
MLX5DR_ACTION_TYP_CRYPTO_DECRYPT,
MLX5DR_ACTION_TYP_INSERT_HEADER,
+ MLX5DR_ACTION_TYP_REMOVE_HEADER,
MLX5DR_ACTION_TYP_DEST_ROOT,
MLX5DR_ACTION_TYP_DEST_ARRAY,
MLX5DR_ACTION_TYP_MAX,
@@ -189,6 +190,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;
@@ -849,6 +873,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 9885555a8f..1a6296a728 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.c
+++ b/drivers/net/mlx5/hws/mlx5dr_action.c
@@ -9,6 +9,9 @@
#define MLX5DR_ACTION_METER_INIT_COLOR_OFFSET 1
#define MLX5DR_ACTION_ASO_FIRST_HIT_SET_OFFSET 9
+/* 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, PUSH_VLAN, MODIFY, ENCAP, TRAILER, ENCRYPT,
* Term
@@ -21,6 +24,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_
[MLX5DR_TABLE_TYPE_NIC_RX] = {
BIT(MLX5DR_ACTION_TYP_TAG),
BIT(MLX5DR_ACTION_TYP_REFORMAT_TRAILER),
+ 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),
@@ -69,6 +73,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_
},
[MLX5DR_TABLE_TYPE_FDB] = {
BIT(MLX5DR_ACTION_TYP_REFORMAT_TRAILER),
+ 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),
@@ -719,6 +724,19 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
attr->reformat_trailer.op = action->reformat_trailer.op;
attr->reformat_trailer.size = action->reformat_trailer.size;
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);
@@ -2266,6 +2284,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;
@@ -2291,6 +2367,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action)
case MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT:
case MLX5DR_ACTION_TYP_CRYPTO_DECRYPT:
case MLX5DR_ACTION_TYP_REFORMAT_TRAILER:
+ case MLX5DR_ACTION_TYP_REMOVE_HEADER:
mlx5dr_action_destroy_stcs(action);
break;
case MLX5DR_ACTION_TYP_DEST_ROOT:
@@ -2923,6 +3000,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 02358da4cb..4046f658e6 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.h
+++ b/drivers/net/mlx5/hws/mlx5dr_action.h
@@ -161,6 +161,13 @@ struct mlx5dr_action {
uint8_t op;
uint8_t size;
} reformat_trailer;
+ struct {
+ uint8_t type;
+ uint8_t start_anchor;
+ uint8_t end_anchor;
+ uint8_t num_of_words;
+ bool decap;
+ } remove_header;
struct {
struct mlx5dr_devx_obj *devx_obj;
} devx_dest;
diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c
index 29e207765b..5111f41648 100644
--- a/drivers/net/mlx5/hws/mlx5dr_debug.c
+++ b/drivers/net/mlx5/hws/mlx5dr_debug.c
@@ -30,6 +30,7 @@ const char *mlx5dr_debug_action_type_str[] = {
[MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT] = "CRYPTO_ENCRYPT",
[MLX5DR_ACTION_TYP_CRYPTO_DECRYPT] = "CRYPTO_DECRYPT",
[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.39.2
next prev parent reply other threads:[~2023-10-29 16:35 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-29 16:31 [PATCH 01/30] net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data Gregory Etelson
2023-10-29 16:31 ` [PATCH 02/30] net/mlx5: add flow_hw_get_reg_id_from_ctx() Gregory Etelson
2023-10-29 16:31 ` [PATCH 03/30] net/mlx5/hws: Definer, use flow_hw_get_reg_id_from_ctx function call Gregory Etelson
2023-10-29 16:31 ` [PATCH 04/30] net/mlx5: add rte_device parameter to locate HWS registers Gregory Etelson
2023-11-05 20:27 ` Thomas Monjalon
2023-10-29 16:31 ` [PATCH 05/30] net/mlx5: separate port REG_C registers usage Gregory Etelson
2023-10-29 16:31 ` [PATCH 06/30] net/mlx5: merge REG_C aliases Gregory Etelson
2023-10-29 16:31 ` [PATCH 07/30] net/mlx5: initialize HWS flow tags registers in shared dev context Gregory Etelson
2023-10-29 16:31 ` [PATCH 08/30] net/mlx5/hws: adding method to query rule hash Gregory Etelson
2023-10-29 16:31 ` [PATCH 09/30] net/mlx5: add support for calc hash Gregory Etelson
2023-10-29 16:31 ` [PATCH 10/30] net/mlx5: fix insert by index Gregory Etelson
2023-10-29 16:31 ` [PATCH 11/30] net/mlx5: fix query for NIC flow cap Gregory Etelson
2023-10-29 16:31 ` [PATCH 12/30] net/mlx5: add support for more registers Gregory Etelson
2023-10-29 16:31 ` [PATCH 13/30] net/mlx5: add validation support for tags Gregory Etelson
2023-10-29 16:31 ` [PATCH 14/30] net/mlx5: reuse reformat and modify header actions in a table Gregory Etelson
2023-10-29 16:31 ` [PATCH 15/30] net/mlx5/hws: check the rule status on rule update Gregory Etelson
2023-10-29 16:31 ` [PATCH 16/30] net/mlx5/hws: support IPsec encryption/decryption action Gregory Etelson
2023-10-29 16:31 ` [PATCH 17/30] net/mlx5/hws: support ASO IPsec action Gregory Etelson
2023-10-29 16:31 ` [PATCH 18/30] net/mlx5/hws: support reformat trailer action Gregory Etelson
2023-10-29 16:31 ` [PATCH 19/30] net/mlx5/hws: support ASO first hit action Gregory Etelson
2023-10-29 16:31 ` [PATCH 20/30] net/mlx5/hws: support insert header action Gregory Etelson
2023-10-29 16:31 ` Gregory Etelson [this message]
2023-10-29 16:31 ` [PATCH 22/30] net/mlx5/hws: allow jump to TIR over FDB Gregory Etelson
2023-10-29 16:31 ` [PATCH 23/30] net/mlx5/hws: support dynamic re-parse Gregory Etelson
2023-10-29 16:31 ` [PATCH 24/30] net/mlx5/hws: dynamic re-parse for modify header Gregory Etelson
2023-10-29 16:31 ` [PATCH 25/30] net/mlx5: sample the srv6 last segment Gregory Etelson
2023-10-29 16:31 ` [PATCH 26/30] net/mlx5/hws: fix potential wrong errno value Gregory Etelson
2023-10-29 16:31 ` [PATCH 27/30] net/mlx5/hws: add IPv6 routing extension push remove actions Gregory Etelson
2023-10-29 16:32 ` [PATCH 28/30] net/mlx5/hws: add setter for IPv6 routing push remove Gregory Etelson
2023-10-29 16:32 ` [PATCH 29/30] net/mlx5: implement " Gregory Etelson
2023-10-29 16:32 ` [PATCH 30/30] net/mlx5/hws: add stc reparse support for srv6 push pop Gregory Etelson
2023-11-05 18:49 ` [PATCH 01/30] net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data Thomas Monjalon
2023-11-06 7:32 ` Etelson, Gregory
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=20231029163202.216450-21-getelson@nvidia.com \
--to=getelson@nvidia.com \
--cc=dev@dpdk.org \
--cc=hamdani@nvidia.com \
--cc=matan@nvidia.com \
--cc=mkashani@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=suanmingm@nvidia.com \
--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).