[v3,2/5] net/mlx5/hws: allow destroying rule resources on error

Message ID 20230704160454.4187-2-igozlan@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [v3,1/5] net/mlx5/hws: remove unneeded new line for DR_LOG |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Itamar Gozlan July 4, 2023, 4:04 p.m. UTC
  From: Alex Vesker <valex@nvidia.com>

In case the send engine is in error state API should provide
a way to free rule resources and provide a fake completion.
Otherwise there is no way to release these resources.

Signed-off-by: Alex Vesker <valex@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
  

Patch

diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c
index 071e1ad769..931c68b160 100644
--- a/drivers/net/mlx5/hws/mlx5dr_rule.c
+++ b/drivers/net/mlx5/hws/mlx5dr_rule.c
@@ -521,6 +521,11 @@  static int mlx5dr_rule_destroy_hws(struct mlx5dr_rule *rule,
 
 	queue = &ctx->send_queue[attr->queue_id];
 
+	if (unlikely(mlx5dr_send_engine_err(queue))) {
+		mlx5dr_rule_destroy_failed_hws(rule, attr);
+		return 0;
+	}
+
 	/* Rule is not completed yet */
 	if (rule->status == MLX5DR_RULE_STATUS_CREATING) {
 		rte_errno = EBUSY;
@@ -533,11 +538,6 @@  static int mlx5dr_rule_destroy_hws(struct mlx5dr_rule *rule,
 		return 0;
 	}
 
-	if (unlikely(mlx5dr_send_engine_err(queue))) {
-		mlx5dr_rule_destroy_failed_hws(rule, attr);
-		return 0;
-	}
-
 	mlx5dr_send_engine_inc_rule(queue);
 
 	/* Send dependent WQE */