net/mlx5: HWS, do not initialize native API queues
authorYevgeny Kliteynik <kliteyn@nvidia.com>
Thu, 19 Dec 2024 17:58:37 +0000 (19:58 +0200)
committerJakub Kicinski <kuba@kernel.org>
Mon, 23 Dec 2024 18:34:45 +0000 (10:34 -0800)
HWS has two types of APIs:
 - Native: fastest and slimmest, async API.
   The user of this API is required to manage rule handles memory,
   and to poll for completion for each rule.
 - BWC: backward compatible API, similar semantics to SWS API.
   This layer is implemented above native API and it does all
   the work for the user, so that it is easy to switch between
   SWS and HWS.

Right now the existing users of HWS require only BWC API.
Therefore, in order to not waste resources, this patch disables
send queues allocation for native API.

If in the future support for faster HWS rule insertion will be required
(such as for Connection Tracking), native queues can be enabled.

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Itamar Gozlan <igozlan@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20241219175841.1094544-8-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.h
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/context.c
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/context.h
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws.h
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c

index 0b745968e21e180a3b4051fbb3b3ad1b42494447..3d4965213b012aadfc5a01202f957c539582d247 100644 (file)
@@ -60,9 +60,11 @@ void mlx5hws_bwc_rule_fill_attr(struct mlx5hws_bwc_matcher *bwc_matcher,
 static inline u16 mlx5hws_bwc_queues(struct mlx5hws_context *ctx)
 {
        /* Besides the control queue, half of the queues are
-        * reguler HWS queues, and the other half are BWC queues.
+        * regular HWS queues, and the other half are BWC queues.
         */
-       return (ctx->queues - 1) / 2;
+       if (mlx5hws_context_bwc_supported(ctx))
+               return (ctx->queues - 1) / 2;
+       return 0;
 }
 
 static inline u16 mlx5hws_bwc_get_queue_id(struct mlx5hws_context *ctx, u16 idx)
index fd48b05e91e0546fa6f51cd4e244f888b50260dd..4a8928f33bb99a533dc52bd5c8f5ac47c8be3361 100644 (file)
@@ -161,8 +161,10 @@ static int hws_context_init_hws(struct mlx5hws_context *ctx,
        if (ret)
                goto uninit_pd;
 
-       if (attr->bwc)
-               ctx->flags |= MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT;
+       /* Context has support for backward compatible API,
+        * and does not have support for native HWS API.
+        */
+       ctx->flags |= MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT;
 
        ret = mlx5hws_send_queues_open(ctx, attr->queues, attr->queue_size);
        if (ret)
index 47f5cc8de73fa0785ed1c5cf7313ac484a17d0e6..1c9cc4fba083dba066c19a29981313978a1c3346 100644 (file)
@@ -8,6 +8,7 @@ enum mlx5hws_context_flags {
        MLX5HWS_CONTEXT_FLAG_HWS_SUPPORT = 1 << 0,
        MLX5HWS_CONTEXT_FLAG_PRIVATE_PD = 1 << 1,
        MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT = 1 << 2,
+       MLX5HWS_CONTEXT_FLAG_NATIVE_SUPPORT = 1 << 3,
 };
 
 enum mlx5hws_context_shared_stc_type {
@@ -58,6 +59,11 @@ static inline bool mlx5hws_context_bwc_supported(struct mlx5hws_context *ctx)
        return ctx->flags & MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT;
 }
 
+static inline bool mlx5hws_context_native_supported(struct mlx5hws_context *ctx)
+{
+       return ctx->flags & MLX5HWS_CONTEXT_FLAG_NATIVE_SUPPORT;
+}
+
 bool mlx5hws_context_cap_dynamic_reparse(struct mlx5hws_context *ctx);
 
 u8 mlx5hws_context_get_reparse_mode(struct mlx5hws_context *ctx);
index f39d636ff39aee7e1a0c969095077cf0a28752ad..5121951f2778a8e07398767ee39dfc381fecdba3 100644 (file)
@@ -70,7 +70,6 @@ enum mlx5hws_send_queue_actions {
 struct mlx5hws_context_attr {
        u16 queues;
        u16 queue_size;
-       bool bwc; /* add support for backward compatible API*/
 };
 
 struct mlx5hws_table_attr {
index b68b0c368771a86119f1c5edde7310236442bc61..20fe126ffd2218031cc776f06dafd53f5d99b8ad 100644 (file)
@@ -898,6 +898,9 @@ close_cq:
 
 static void mlx5hws_send_queue_close(struct mlx5hws_send_engine *queue)
 {
+       if (!queue->num_entries)
+               return; /* this queue wasn't initialized */
+
        hws_send_ring_close(queue);
        kfree(queue->completed.entries);
 }
@@ -1005,7 +1008,7 @@ int mlx5hws_send_queues_open(struct mlx5hws_context *ctx,
                             u16 queue_size)
 {
        int err = 0;
-       u32 i;
+       int i = 0;
 
        /* Open one extra queue for control path */
        ctx->queues = queues + 1;
@@ -1021,7 +1024,13 @@ int mlx5hws_send_queues_open(struct mlx5hws_context *ctx,
                goto free_bwc_locks;
        }
 
-       for (i = 0; i < ctx->queues; i++) {
+       /* If native API isn't supported, skip the unused native queues:
+        * initialize BWC queues and control queue only.
+        */
+       if (!mlx5hws_context_native_supported(ctx))
+               i = mlx5hws_bwc_get_queue_id(ctx, 0);
+
+       for (; i < ctx->queues; i++) {
                err = mlx5hws_send_queue_open(ctx, &ctx->send_queue[i], queue_size);
                if (err)
                        goto close_send_queues;