From: Erez Shitrit <erezsh@nvidia.com>
To: <dev@dpdk.org>
Cc: Matan Azrad <matan@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [PATCH v4] net/mlx5/hws: add check for modify-header actions
Date: Wed, 22 Mar 2023 16:45:16 +0200 [thread overview]
Message-ID: <20230322144517.656185-1-erezsh@nvidia.com> (raw)
In-Reply-To: <20230322101621.642765-4-erezsh@nvidia.com>
Allow only actions that are currently supported.
A check for each action in the modify-header list was added to
verify that is a know action, otherwise the modify-header is
failed.
Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/common/mlx5/mlx5_prm.h | 1 +
drivers/net/mlx5/hws/mlx5dr_action.c | 6 ++++++
drivers/net/mlx5/hws/mlx5dr_pat_arg.c | 16 ++++++++++++++++
drivers/net/mlx5/hws/mlx5dr_pat_arg.h | 2 ++
4 files changed, 25 insertions(+)
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 4b0a56f4e5..0b6dc43752 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -715,6 +715,7 @@ enum {
MLX5_MODIFICATION_TYPE_REMOVE = 0x5,
MLX5_MODIFICATION_TYPE_NOP = 0x6,
MLX5_MODIFICATION_TYPE_REMOVE_WORDS = 0x7,
+ MLX5_MODIFICATION_TYPE_MAX,
};
/* The field of packet to be modified. */
diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c
index 77cf1f5132..2d93be717f 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.c
+++ b/drivers/net/mlx5/hws/mlx5dr_action.c
@@ -1603,6 +1603,12 @@ mlx5dr_action_create_modify_header(struct mlx5dr_context *ctx,
goto free_action;
}
+ if (!mlx5dr_pat_arg_verify_actions(pattern, pattern_sz / MLX5DR_MODIFY_ACTION_SIZE)) {
+ DR_LOG(ERR, "One of the actions is not supported\n");
+ rte_errno = EINVAL;
+ goto free_action;
+ }
+
if (pattern_sz / MLX5DR_MODIFY_ACTION_SIZE == 1) {
/* Optimize single modiy action to be used inline */
action->modify_header.single_action = pattern[0];
diff --git a/drivers/net/mlx5/hws/mlx5dr_pat_arg.c b/drivers/net/mlx5/hws/mlx5dr_pat_arg.c
index 6ed04dac6d..830bc08678 100644
--- a/drivers/net/mlx5/hws/mlx5dr_pat_arg.c
+++ b/drivers/net/mlx5/hws/mlx5dr_pat_arg.c
@@ -441,6 +441,22 @@ mlx5dr_arg_create_modify_header_arg(struct mlx5dr_context *ctx,
return 0;
}
+bool mlx5dr_pat_arg_verify_actions(__be64 pattern[], uint16_t num_of_actions)
+{
+ int i;
+
+ for (i = 0; i < num_of_actions; i++) {
+ u8 action_id =
+ MLX5_GET(set_action_in, &pattern[i], action_type);
+ if (action_id >= MLX5_MODIFICATION_TYPE_MAX) {
+ DR_LOG(ERR, "Invalid action %u\n", action_id);
+ return false;
+ }
+ }
+
+ return true;
+}
+
int mlx5dr_pat_arg_create_modify_header(struct mlx5dr_context *ctx,
struct mlx5dr_action *action,
size_t pattern_sz,
diff --git a/drivers/net/mlx5/hws/mlx5dr_pat_arg.h b/drivers/net/mlx5/hws/mlx5dr_pat_arg.h
index 92db6d6aee..ec467dbb4b 100644
--- a/drivers/net/mlx5/hws/mlx5dr_pat_arg.h
+++ b/drivers/net/mlx5/hws/mlx5dr_pat_arg.h
@@ -53,6 +53,8 @@ int mlx5dr_pat_init_pattern_cache(struct mlx5dr_pattern_cache **cache);
void mlx5dr_pat_uninit_pattern_cache(struct mlx5dr_pattern_cache *cache);
+bool mlx5dr_pat_arg_verify_actions(__be64 pattern[], uint16_t num_of_actions);
+
int mlx5dr_pat_arg_create_modify_header(struct mlx5dr_context *ctx,
struct mlx5dr_action *action,
size_t pattern_sz,
--
2.18.2
next prev parent reply other threads:[~2023-03-22 14:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 10:16 [PATCH] net/mlx5/hws: fix bug in pattern creation Erez Shitrit
2023-03-22 10:16 ` [PATCH] net/mlx5/hws: fix shared context to use local defaults Erez Shitrit
2023-03-22 12:26 ` Raslan Darawsheh
2023-03-22 14:42 ` [PATCH v4] " Erez Shitrit
2023-03-23 7:20 ` Raslan Darawsheh
2023-03-22 10:16 ` [PATCH] net/mlx5/hws: fix saving of jumbo tag for deletion Erez Shitrit
2023-03-22 14:44 ` [PATCH v4] " Erez Shitrit
2023-03-23 7:20 ` Raslan Darawsheh
2023-03-22 10:16 ` [PATCH] net/mlx5/hws: add check for modify-header actions Erez Shitrit
2023-03-22 14:45 ` Erez Shitrit [this message]
2023-03-23 7:21 ` [PATCH v4] " Raslan Darawsheh
2023-03-22 14:41 ` [PATCH v4] net/mlx5/hws: fix bug in pattern creation Erez Shitrit
2023-03-23 7:19 ` Raslan Darawsheh
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=20230322144517.656185-1-erezsh@nvidia.com \
--to=erezsh@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@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).