DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alexander Kozyrev <akozyrev@nvidia.com>
To: <dev@dpdk.org>
Cc: <rasland@nvidia.com>, <matan@nvidia.com>,
	<viacheslavo@nvidia.com>, <orika@nvidia.com>, <erezsh@nvidia.com>
Subject: [PATCH 1/4] net/mlx5/hws: use the same function to check rule
Date: Mon, 12 Jun 2023 23:05:49 +0300	[thread overview]
Message-ID: <20230612200552.3450964-2-akozyrev@nvidia.com> (raw)
In-Reply-To: <20230612200552.3450964-1-akozyrev@nvidia.com>

From: Erez Shitrit <erezsh@nvidia.com>

Before handling it for insert/delete

Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 38 +++++++++++++++---------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c
index 2418ca0b26..e0c4a6a91a 100644
--- a/drivers/net/mlx5/hws/mlx5dr_rule.c
+++ b/drivers/net/mlx5/hws/mlx5dr_rule.c
@@ -630,6 +630,23 @@ static int mlx5dr_rule_destroy_root(struct mlx5dr_rule *rule,
 	return 0;
 }
 
+static int mlx5dr_rule_enqueue_precheck(struct mlx5dr_context *ctx,
+					struct mlx5dr_rule_attr *attr)
+{
+	if (unlikely(!attr->user_data)) {
+		rte_errno = EINVAL;
+		return rte_errno;
+	}
+
+	/* Check if there is room in queue */
+	if (unlikely(mlx5dr_send_engine_full(&ctx->send_queue[attr->queue_id]))) {
+		rte_errno = EBUSY;
+		return rte_errno;
+	}
+
+	return 0;
+}
+
 int mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
 		       uint8_t mt_idx,
 		       const struct rte_flow_item items[],
@@ -644,16 +661,8 @@ int mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
 	rule_handle->matcher = matcher;
 	ctx = matcher->tbl->ctx;
 
-	if (unlikely(!attr->user_data)) {
-		rte_errno = EINVAL;
+	if (mlx5dr_rule_enqueue_precheck(ctx, attr))
 		return -rte_errno;
-	}
-
-	/* Check if there is room in queue */
-	if (unlikely(mlx5dr_send_engine_full(&ctx->send_queue[attr->queue_id]))) {
-		rte_errno = EBUSY;
-		return -rte_errno;
-	}
 
 	assert(matcher->num_of_mt >= mt_idx);
 	assert(matcher->num_of_at >= at_idx);
@@ -677,19 +686,10 @@ int mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
 int mlx5dr_rule_destroy(struct mlx5dr_rule *rule,
 			struct mlx5dr_rule_attr *attr)
 {
-	struct mlx5dr_context *ctx = rule->matcher->tbl->ctx;
 	int ret;
 
-	if (unlikely(!attr->user_data)) {
-		rte_errno = EINVAL;
-		return -rte_errno;
-	}
-
-	/* Check if there is room in queue */
-	if (unlikely(mlx5dr_send_engine_full(&ctx->send_queue[attr->queue_id]))) {
-		rte_errno = EBUSY;
+	if (mlx5dr_rule_enqueue_precheck(rule->matcher->tbl->ctx, attr))
 		return -rte_errno;
-	}
 
 	if (unlikely(mlx5dr_table_is_root(rule->matcher->tbl)))
 		ret = mlx5dr_rule_destroy_root(rule, attr);
-- 
2.18.2


  reply	other threads:[~2023-06-12 20:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 20:05 [PATCH 0/4] net/mlx5: implement Flow update API Alexander Kozyrev
2023-06-12 20:05 ` Alexander Kozyrev [this message]
2023-06-14 16:59   ` [PATCH 1/4] net/mlx5/hws: use the same function to check rule Ori Kam
2023-06-12 20:05 ` [PATCH 2/4] net/mlx5/hws: use union in the wqe-data struct Alexander Kozyrev
2023-06-14 17:00   ` Ori Kam
2023-06-12 20:05 ` [PATCH 3/4] net/mlx5/hws: support rule update after its creation Alexander Kozyrev
2023-06-14 17:00   ` Ori Kam
2023-06-12 20:05 ` [PATCH 4/4] net/mlx5: implement Flow update API Alexander Kozyrev
2023-06-19 15:03 ` [PATCH 0/4] " 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=20230612200552.3450964-2-akozyrev@nvidia.com \
    --to=akozyrev@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=erezsh@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@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).