From: Maayan Kashani <mkashani@nvidia.com>
To: <dev@dpdk.org>
Cc: <mkashani@nvidia.com>, <dsosnowski@nvidia.com>,
<rasland@nvidia.com>, Yevgeny Kliteynik <kliteyn@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
Matan Azrad <matan@nvidia.com>
Subject: [PATCH v2 02/34] net/mlx5/hws: split the root rule creation and destruction
Date: Mon, 3 Jun 2024 10:21:15 +0300 [thread overview]
Message-ID: <20240603072117.755-1-mkashani@nvidia.com> (raw)
In-Reply-To: <196750-1-mkashani@nvidia.com>
From: Yevgeny Kliteynik <kliteyn@nvidia.com>
Split the root rule creation/destruction into two stages:
- do the job (create/destroy rule)
- generate completion
Completion generation is required for the usual HWS API.
The create/destroy functions that don't generate completion
are exposed in header file and will be used by the coming
backward-compatible API.
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
---
drivers/net/mlx5/hws/mlx5dr_rule.c | 49 +++++++++++++++++++++---------
drivers/net/mlx5/hws/mlx5dr_rule.h | 7 +++++
2 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c
index 171a0bff38..550f00a4c1 100644
--- a/drivers/net/mlx5/hws/mlx5dr_rule.c
+++ b/drivers/net/mlx5/hws/mlx5dr_rule.c
@@ -680,15 +680,12 @@ static int mlx5dr_rule_destroy_hws(struct mlx5dr_rule *rule,
return 0;
}
-static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule,
- struct mlx5dr_rule_attr *rule_attr,
- const struct rte_flow_item items[],
- uint8_t at_idx,
- struct mlx5dr_rule_action rule_actions[])
+int mlx5dr_rule_create_root_no_comp(struct mlx5dr_rule *rule,
+ const struct rte_flow_item items[],
+ uint8_t num_actions,
+ struct mlx5dr_rule_action rule_actions[])
{
struct mlx5dv_flow_matcher *dv_matcher = rule->matcher->dv_matcher;
- uint8_t num_actions = rule->matcher->at[at_idx].num_actions;
- struct mlx5dr_context *ctx = rule->matcher->tbl->ctx;
struct mlx5dv_flow_match_parameters *value;
struct mlx5_flow_attr flow_attr = {0};
struct mlx5dv_flow_action_attr *attr;
@@ -750,9 +747,6 @@ static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule,
num_actions,
attr);
- mlx5dr_rule_gen_comp(&ctx->send_queue[rule_attr->queue_id], rule, !rule->flow,
- rule_attr->user_data, MLX5DR_RULE_STATUS_CREATED);
-
simple_free(value);
simple_free(attr);
@@ -766,14 +760,41 @@ static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule,
return rte_errno;
}
+static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule,
+ struct mlx5dr_rule_attr *rule_attr,
+ const struct rte_flow_item items[],
+ uint8_t num_actions,
+ struct mlx5dr_rule_action rule_actions[])
+{
+ struct mlx5dr_context *ctx = rule->matcher->tbl->ctx;
+ int ret;
+
+ ret = mlx5dr_rule_create_root_no_comp(rule, items,
+ num_actions, rule_actions);
+ if (ret)
+ return rte_errno;
+
+ mlx5dr_rule_gen_comp(&ctx->send_queue[rule_attr->queue_id], rule, !rule->flow,
+ rule_attr->user_data, MLX5DR_RULE_STATUS_CREATED);
+
+ return 0;
+}
+
+int mlx5dr_rule_destroy_root_no_comp(struct mlx5dr_rule *rule)
+{
+ if (rule->flow)
+ return ibv_destroy_flow(rule->flow);
+
+ return 0;
+}
+
static int mlx5dr_rule_destroy_root(struct mlx5dr_rule *rule,
struct mlx5dr_rule_attr *attr)
{
struct mlx5dr_context *ctx = rule->matcher->tbl->ctx;
- int err = 0;
+ int err;
- if (rule->flow)
- err = ibv_destroy_flow(rule->flow);
+ err = mlx5dr_rule_destroy_root_no_comp(rule);
mlx5dr_rule_gen_comp(&ctx->send_queue[attr->queue_id], rule, err,
attr->user_data, MLX5DR_RULE_STATUS_DELETED);
@@ -970,7 +991,7 @@ int mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
ret = mlx5dr_rule_create_root(rule_handle,
attr,
items,
- at_idx,
+ matcher->at[at_idx].num_actions,
rule_actions);
else
ret = mlx5dr_rule_create_hws(rule_handle,
diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.h b/drivers/net/mlx5/hws/mlx5dr_rule.h
index dffaec1c0f..bc542eb543 100644
--- a/drivers/net/mlx5/hws/mlx5dr_rule.h
+++ b/drivers/net/mlx5/hws/mlx5dr_rule.h
@@ -74,4 +74,11 @@ int mlx5dr_rule_move_hws_add(struct mlx5dr_rule *rule,
bool mlx5dr_rule_move_in_progress(struct mlx5dr_rule *rule);
+int mlx5dr_rule_create_root_no_comp(struct mlx5dr_rule *rule,
+ const struct rte_flow_item items[],
+ uint8_t num_actions,
+ struct mlx5dr_rule_action rule_actions[]);
+
+int mlx5dr_rule_destroy_root_no_comp(struct mlx5dr_rule *rule);
+
#endif /* MLX5DR_RULE_H_ */
--
2.25.1
next parent reply other threads:[~2024-06-03 7:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <196750-1-mkashani@nvidia.com>
2024-06-03 7:21 ` Maayan Kashani [this message]
2024-06-03 7:21 ` [PATCH v2 03/34] net/mlx5/hws: add support for action type LAST Maayan Kashani
2024-06-03 7:21 ` [PATCH v2 04/34] net/mlx5/hws: add support for backward-compatible API Maayan Kashani
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=20240603072117.755-1-mkashani@nvidia.com \
--to=mkashani@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=kliteyn@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=suanmingm@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).