[1/4] net/mlx5/hws: use the same function to check rule

Message ID 20230612200552.3450964-2-akozyrev@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: implement Flow update API |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Alexander Kozyrev June 12, 2023, 8:05 p.m. UTC
  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(-)
  

Comments

Ori Kam June 14, 2023, 4:59 p.m. UTC | #1
> -----Original Message-----
> From: Alexander Kozyrev <akozyrev@nvidia.com>
> Sent: Monday, June 12, 2023 11:06 PM
> To: dev@dpdk.org
> Cc: Raslan Darawsheh <rasland@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>; Ori Kam
> <orika@nvidia.com>; Erez Shitrit <erezsh@nvidia.com>
> Subject: [PATCH 1/4] net/mlx5/hws: use the same function to check rule
> 
> 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>
> ---
Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
  

Patch

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);