]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net/mlx5: HWS, Use the new action STE pool
authorVlad Dogaru <vdogaru@nvidia.com>
Thu, 10 Apr 2025 19:17:39 +0000 (22:17 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 15 Apr 2025 00:29:16 +0000 (17:29 -0700)
Use the central action STE pool when creating / updating rules.

Signed-off-by: Vlad Dogaru <vdogaru@nvidia.com>
Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Link: https://patch.msgid.link/1744312662-356571-10-git-send-email-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.h

index a27a2d5ffc7b17e2f2092b6d384b80ed686151fd..5b758467ed03d9a8787b8a44b4e5df5cdc2db678 100644 (file)
@@ -195,44 +195,30 @@ hws_rule_load_delete_info(struct mlx5hws_rule *rule,
        }
 }
 
-static int hws_rule_alloc_action_ste(struct mlx5hws_rule *rule)
+static int mlx5hws_rule_alloc_action_ste(struct mlx5hws_rule *rule,
+                                        u16 queue_id, bool skip_rx,
+                                        bool skip_tx)
 {
        struct mlx5hws_matcher *matcher = rule->matcher;
-       struct mlx5hws_matcher_action_ste *action_ste;
-       struct mlx5hws_pool_chunk ste = {0};
-       int ret;
-
-       action_ste = &matcher->action_ste;
-       ste.order = ilog2(roundup_pow_of_two(action_ste->max_stes));
-       ret = mlx5hws_pool_chunk_alloc(action_ste->pool, &ste);
-       if (unlikely(ret)) {
-               mlx5hws_err(matcher->tbl->ctx,
-                           "Failed to allocate STE for rule actions");
-               return ret;
-       }
-
-       rule->action_ste.pool = matcher->action_ste.pool;
-       rule->action_ste.num_stes = matcher->action_ste.max_stes;
-       rule->action_ste.index = ste.offset;
+       struct mlx5hws_context *ctx = matcher->tbl->ctx;
 
-       return 0;
+       rule->action_ste.ste.order =
+               ilog2(roundup_pow_of_two(matcher->action_ste.max_stes));
+       return mlx5hws_action_ste_chunk_alloc(&ctx->action_ste_pool[queue_id],
+                                             skip_rx, skip_tx,
+                                             &rule->action_ste);
 }
 
-void mlx5hws_rule_free_action_ste(struct mlx5hws_rule_action_ste_info *action_ste)
+void mlx5hws_rule_free_action_ste(struct mlx5hws_action_ste_chunk *action_ste)
 {
-       struct mlx5hws_pool_chunk ste = {0};
-
-       if (!action_ste->num_stes)
+       if (!action_ste->action_tbl)
                return;
 
-       ste.order = ilog2(roundup_pow_of_two(action_ste->num_stes));
-       ste.offset = action_ste->index;
-
        /* This release is safe only when the rule match STE was deleted
         * (when the rule is being deleted) or replaced with the new STE that
         * isn't pointing to old action STEs (when the rule is being updated).
         */
-       mlx5hws_pool_chunk_free(action_ste->pool, &ste);
+       mlx5hws_action_ste_chunk_free(action_ste);
 }
 
 static void hws_rule_create_init(struct mlx5hws_rule *rule,
@@ -250,22 +236,15 @@ static void hws_rule_create_init(struct mlx5hws_rule *rule,
                rule->rtc_0 = 0;
                rule->rtc_1 = 0;
 
-               rule->action_ste.pool = NULL;
-               rule->action_ste.num_stes = 0;
-               rule->action_ste.index = -1;
-
                rule->status = MLX5HWS_RULE_STATUS_CREATING;
        } else {
                rule->status = MLX5HWS_RULE_STATUS_UPDATING;
+               /* Save the old action STE info so we can free it after writing
+                * new action STEs and a corresponding match STE.
+                */
+               rule->old_action_ste = rule->action_ste;
        }
 
-       /* Initialize the old action STE info - shallow-copy action_ste.
-        * In create flow this will set old_action_ste fields to initial values.
-        * In update flow this will save the existing action STE info,
-        * so that we will later use it to free old STEs.
-        */
-       rule->old_action_ste = rule->action_ste;
-
        rule->pending_wqes = 0;
 
        /* Init default send STE attributes */
@@ -277,7 +256,6 @@ static void hws_rule_create_init(struct mlx5hws_rule *rule,
        /* Init default action apply */
        apply->tbl_type = tbl->type;
        apply->common_res = &ctx->common_res;
-       apply->jump_to_action_stc = matcher->action_ste.stc.offset;
        apply->require_dep = 0;
 }
 
@@ -353,17 +331,24 @@ static int hws_rule_create_hws(struct mlx5hws_rule *rule,
 
        if (action_stes) {
                /* Allocate action STEs for rules that need more than match STE */
-               ret = hws_rule_alloc_action_ste(rule);
+               ret = mlx5hws_rule_alloc_action_ste(rule, attr->queue_id,
+                                                   !!ste_attr.rtc_0,
+                                                   !!ste_attr.rtc_1);
                if (ret) {
                        mlx5hws_err(ctx, "Failed to allocate action memory %d", ret);
                        mlx5hws_send_abort_new_dep_wqe(queue);
                        return ret;
                }
+               apply.jump_to_action_stc =
+                       rule->action_ste.action_tbl->stc.offset;
                /* Skip RX/TX based on the dep_wqe init */
-               ste_attr.rtc_0 = dep_wqe->rtc_0 ? matcher->action_ste.rtc_0_id : 0;
-               ste_attr.rtc_1 = dep_wqe->rtc_1 ? matcher->action_ste.rtc_1_id : 0;
+               ste_attr.rtc_0 = dep_wqe->rtc_0 ?
+                                rule->action_ste.action_tbl->rtc_0_id : 0;
+               ste_attr.rtc_1 = dep_wqe->rtc_1 ?
+                                rule->action_ste.action_tbl->rtc_1_id : 0;
                /* Action STEs are written to a specific index last to first */
-               ste_attr.direct_index = rule->action_ste.index + action_stes;
+               ste_attr.direct_index =
+                       rule->action_ste.ste.offset + action_stes;
                apply.next_direct_idx = ste_attr.direct_index;
        } else {
                apply.next_direct_idx = 0;
index b5ee94ac449b1a07ae1a1c8198ed23a1326bd37d..1c47a9c11572a9121244bc69df2d8d60461c3667 100644 (file)
@@ -43,12 +43,6 @@ struct mlx5hws_rule_match_tag {
        };
 };
 
-struct mlx5hws_rule_action_ste_info {
-       struct mlx5hws_pool *pool;
-       int index; /* STE array index */
-       u8 num_stes;
-};
-
 struct mlx5hws_rule_resize_info {
        u32 rtc_0;
        u32 rtc_1;
@@ -64,8 +58,8 @@ struct mlx5hws_rule {
                struct mlx5hws_rule_match_tag tag;
                struct mlx5hws_rule_resize_info *resize_info;
        };
-       struct mlx5hws_rule_action_ste_info action_ste;
-       struct mlx5hws_rule_action_ste_info old_action_ste;
+       struct mlx5hws_action_ste_chunk action_ste;
+       struct mlx5hws_action_ste_chunk old_action_ste;
        u32 rtc_0; /* The RTC into which the STE was inserted */
        u32 rtc_1; /* The RTC into which the STE was inserted */
        u8 status; /* enum mlx5hws_rule_status */
@@ -75,7 +69,7 @@ struct mlx5hws_rule {
                           */
 };
 
-void mlx5hws_rule_free_action_ste(struct mlx5hws_rule_action_ste_info *action_ste);
+void mlx5hws_rule_free_action_ste(struct mlx5hws_action_ste_chunk *action_ste);
 
 int mlx5hws_rule_move_hws_remove(struct mlx5hws_rule *rule,
                                 void *queue, void *user_data);