From: Erez Shitrit <erezsh@nvidia.com>
To: <valex@nvidia.com>, <thomas@monjalon.net>, <suanmingm@nvidia.com>,
"Matan Azrad" <matan@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
"Ori Kam" <orika@nvidia.com>
Cc: <dev@dpdk.org>
Subject: [PATCH 2/4] net/mlx5/hws: allow attaching action template to matcher
Date: Sun, 10 Sep 2023 17:03:17 +0300 [thread overview]
Message-ID: <20230910140319.3064208-2-erezsh@nvidia.com> (raw)
In-Reply-To: <20230910140319.3064208-1-erezsh@nvidia.com>
Allow user to add new action-template after the creation of the matcher.
It is allowed only if the user indicates in the mlx5dr_matcher_attr
that he might add new AT in the future by indicating the max_num_of_at
and if needed the max_num_of_actions_in_at value.
With these two values the matcher is configured to get new AT in the
future.
Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Signed-off-by: Alex Vesker <valex@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx5/hws/mlx5dr.h | 13 +++++
drivers/net/mlx5/hws/mlx5dr_matcher.c | 82 +++++++++++++++++++++++----
2 files changed, 83 insertions(+), 12 deletions(-)
diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h
index 5592af93c9..184de8feaf 100644
--- a/drivers/net/mlx5/hws/mlx5dr.h
+++ b/drivers/net/mlx5/hws/mlx5dr.h
@@ -139,6 +139,8 @@ struct mlx5dr_matcher_attr {
uint8_t num_log;
} rule;
};
+ /* Optional AT attach configuration - Max number of additional AT */
+ uint8_t max_num_of_at_attach;
};
struct mlx5dr_rule_attr {
@@ -328,6 +330,17 @@ mlx5dr_matcher_create(struct mlx5dr_table *table,
*/
int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);
+/* Attach new action template to direct rule matcher.
+ *
+ * @param[in] matcher
+ * Matcher to attach at to.
+ * @param[in] at
+ * Action template to be attached to the matcher.
+ * @return zero on success non zero otherwise.
+ */
+int mlx5dr_matcher_attach_at(struct mlx5dr_matcher *matcher,
+ struct mlx5dr_action_template *at);
+
/* Get the size of the rule handle (mlx5dr_rule) to be used on rule creation.
*
* @return size in bytes of rule handle struct.
diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c
index 1fe7ec1bc3..a02f42a7e8 100644
--- a/drivers/net/mlx5/hws/mlx5dr_matcher.c
+++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c
@@ -680,6 +680,30 @@ static void mlx5dr_matcher_set_pool_attr(struct mlx5dr_pool_attr *attr,
}
}
+static int mlx5dr_matcher_check_and_process_at(struct mlx5dr_matcher *matcher,
+ struct mlx5dr_action_template *at)
+{
+ bool valid;
+ int ret;
+
+ /* Check if action combinabtion is valid */
+ valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type);
+ if (!valid) {
+ DR_LOG(ERR, "Invalid combination in action template");
+ rte_errno = EINVAL;
+ return rte_errno;
+ }
+
+ /* Process action template to setters */
+ ret = mlx5dr_action_template_process(at);
+ if (ret) {
+ DR_LOG(ERR, "Failed to process action template");
+ return ret;
+ }
+
+ return 0;
+}
+
static int mlx5dr_matcher_bind_at(struct mlx5dr_matcher *matcher)
{
bool is_jumbo = mlx5dr_matcher_mt_is_jumbo(matcher->mt);
@@ -689,22 +713,13 @@ static int mlx5dr_matcher_bind_at(struct mlx5dr_matcher *matcher)
struct mlx5dr_context *ctx = tbl->ctx;
uint32_t required_stes;
int i, ret;
- bool valid;
for (i = 0; i < matcher->num_of_at; i++) {
struct mlx5dr_action_template *at = &matcher->at[i];
- /* Check if action combinabtion is valid */
- valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type);
- if (!valid) {
- DR_LOG(ERR, "Invalid combination in action template %d", i);
- return rte_errno;
- }
-
- /* Process action template to setters */
- ret = mlx5dr_action_template_process(at);
+ ret = mlx5dr_matcher_check_and_process_at(matcher, at);
if (ret) {
- DR_LOG(ERR, "Failed to process action template %d", i);
+ DR_LOG(ERR, "Invalid at %d", i);
return rte_errno;
}
@@ -924,6 +939,10 @@ mlx5dr_matcher_process_attr(struct mlx5dr_cmd_query_caps *caps,
DR_LOG(ERR, "Root matcher can't specify FDB direction");
goto not_supported;
}
+ if (attr->max_num_of_at_attach) {
+ DR_LOG(ERR, "Root matcher does not support at attaching");
+ goto not_supported;
+ }
return 0;
}
@@ -1039,6 +1058,8 @@ mlx5dr_matcher_create_col_matcher(struct mlx5dr_matcher *matcher)
if (col_matcher->attr.table.sz_row_log > MLX5DR_MATCHER_ASSURED_ROW_RATIO)
col_matcher->attr.table.sz_row_log -= MLX5DR_MATCHER_ASSURED_ROW_RATIO;
+ col_matcher->attr.max_num_of_at_attach = matcher->attr.max_num_of_at_attach;
+
ret = mlx5dr_matcher_process_attr(ctx->caps, col_matcher, false);
if (ret)
goto free_col_matcher;
@@ -1212,6 +1233,42 @@ static int mlx5dr_matcher_uninit_root(struct mlx5dr_matcher *matcher)
return ret;
}
+int mlx5dr_matcher_attach_at(struct mlx5dr_matcher *matcher,
+ struct mlx5dr_action_template *at)
+{
+ bool is_jumbo = mlx5dr_matcher_mt_is_jumbo(matcher->mt);
+ uint32_t required_stes;
+ int ret;
+
+ if (!matcher->attr.max_num_of_at_attach) {
+ DR_LOG(ERR, "Num of current at (%d) exceed allowed value",
+ matcher->num_of_at);
+ rte_errno = ENOTSUP;
+ return -rte_errno;
+ }
+
+ ret = mlx5dr_matcher_check_and_process_at(matcher, at);
+ if (ret)
+ return -rte_errno;
+
+ required_stes = at->num_of_action_stes - (!is_jumbo || at->only_term);
+ if (matcher->action_ste.max_stes < required_stes) {
+ DR_LOG(ERR, "Required STEs [%d] exceeds initial action template STE [%d]",
+ required_stes, matcher->action_ste.max_stes);
+ rte_errno = ENOMEM;
+ return -rte_errno;
+ }
+
+ matcher->at[matcher->num_of_at] = *at;
+ matcher->num_of_at += 1;
+ matcher->attr.max_num_of_at_attach -= 1;
+
+ if (matcher->col_matcher)
+ matcher->col_matcher->num_of_at = matcher->num_of_at;
+
+ return 0;
+}
+
static int
mlx5dr_matcher_set_templates(struct mlx5dr_matcher *matcher,
struct mlx5dr_match_template *mt[],
@@ -1241,7 +1298,8 @@ mlx5dr_matcher_set_templates(struct mlx5dr_matcher *matcher,
return rte_errno;
}
- matcher->at = simple_calloc(num_of_at, sizeof(*matcher->at));
+ matcher->at = simple_calloc(num_of_at + matcher->attr.max_num_of_at_attach,
+ sizeof(*matcher->at));
if (!matcher->at) {
DR_LOG(ERR, "Failed to allocate action template array");
rte_errno = ENOMEM;
--
2.18.2
next prev parent reply other threads:[~2023-09-10 14:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-10 14:03 [PATCH 1/4] net/mlx5/hws: allow relaxed mode in MPLS matching Erez Shitrit
2023-09-10 14:03 ` Erez Shitrit [this message]
2023-09-10 14:03 ` [PATCH 3/4] net/mlx5/hws: print syndrome value on error Erez Shitrit
2023-09-10 14:03 ` [PATCH 4/4] net/mlx5/hws: skip process action-template on coll matcher Erez Shitrit
2023-09-19 12:02 ` [PATCH 1/4] net/mlx5/hws: allow relaxed mode in MPLS matching 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=20230910140319.3064208-2-erezsh@nvidia.com \
--to=erezsh@nvidia.com \
--cc=dev@dpdk.org \
--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).