Skip to content

Commit 429776b

Browse files
kliteynkuba-moo
authored andcommitted
net/mlx5: HWS, do not initialize native API queues
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 <[email protected]> Reviewed-by: Itamar Gozlan <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9a0155a commit 429776b

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ void mlx5hws_bwc_rule_fill_attr(struct mlx5hws_bwc_matcher *bwc_matcher,
6060
static inline u16 mlx5hws_bwc_queues(struct mlx5hws_context *ctx)
6161
{
6262
/* Besides the control queue, half of the queues are
63-
* reguler HWS queues, and the other half are BWC queues.
63+
* regular HWS queues, and the other half are BWC queues.
6464
*/
65-
return (ctx->queues - 1) / 2;
65+
if (mlx5hws_context_bwc_supported(ctx))
66+
return (ctx->queues - 1) / 2;
67+
return 0;
6668
}
6769

6870
static inline u16 mlx5hws_bwc_get_queue_id(struct mlx5hws_context *ctx, u16 idx)

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/context.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ static int hws_context_init_hws(struct mlx5hws_context *ctx,
161161
if (ret)
162162
goto uninit_pd;
163163

164-
if (attr->bwc)
165-
ctx->flags |= MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT;
164+
/* Context has support for backward compatible API,
165+
* and does not have support for native HWS API.
166+
*/
167+
ctx->flags |= MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT;
166168

167169
ret = mlx5hws_send_queues_open(ctx, attr->queues, attr->queue_size);
168170
if (ret)

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/context.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ enum mlx5hws_context_flags {
88
MLX5HWS_CONTEXT_FLAG_HWS_SUPPORT = 1 << 0,
99
MLX5HWS_CONTEXT_FLAG_PRIVATE_PD = 1 << 1,
1010
MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT = 1 << 2,
11+
MLX5HWS_CONTEXT_FLAG_NATIVE_SUPPORT = 1 << 3,
1112
};
1213

1314
enum mlx5hws_context_shared_stc_type {
@@ -58,6 +59,11 @@ static inline bool mlx5hws_context_bwc_supported(struct mlx5hws_context *ctx)
5859
return ctx->flags & MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT;
5960
}
6061

62+
static inline bool mlx5hws_context_native_supported(struct mlx5hws_context *ctx)
63+
{
64+
return ctx->flags & MLX5HWS_CONTEXT_FLAG_NATIVE_SUPPORT;
65+
}
66+
6167
bool mlx5hws_context_cap_dynamic_reparse(struct mlx5hws_context *ctx);
6268

6369
u8 mlx5hws_context_get_reparse_mode(struct mlx5hws_context *ctx);

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ enum mlx5hws_send_queue_actions {
7070
struct mlx5hws_context_attr {
7171
u16 queues;
7272
u16 queue_size;
73-
bool bwc; /* add support for backward compatible API*/
7473
};
7574

7675
struct mlx5hws_table_attr {

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,9 @@ static int mlx5hws_send_ring_open(struct mlx5hws_context *ctx,
898898

899899
static void mlx5hws_send_queue_close(struct mlx5hws_send_engine *queue)
900900
{
901+
if (!queue->num_entries)
902+
return; /* this queue wasn't initialized */
903+
901904
hws_send_ring_close(queue);
902905
kfree(queue->completed.entries);
903906
}
@@ -1005,7 +1008,7 @@ int mlx5hws_send_queues_open(struct mlx5hws_context *ctx,
10051008
u16 queue_size)
10061009
{
10071010
int err = 0;
1008-
u32 i;
1011+
int i = 0;
10091012

10101013
/* Open one extra queue for control path */
10111014
ctx->queues = queues + 1;
@@ -1021,7 +1024,13 @@ int mlx5hws_send_queues_open(struct mlx5hws_context *ctx,
10211024
goto free_bwc_locks;
10221025
}
10231026

1024-
for (i = 0; i < ctx->queues; i++) {
1027+
/* If native API isn't supported, skip the unused native queues:
1028+
* initialize BWC queues and control queue only.
1029+
*/
1030+
if (!mlx5hws_context_native_supported(ctx))
1031+
i = mlx5hws_bwc_get_queue_id(ctx, 0);
1032+
1033+
for (; i < ctx->queues; i++) {
10251034
err = mlx5hws_send_queue_open(ctx, &ctx->send_queue[i], queue_size);
10261035
if (err)
10271036
goto close_send_queues;

0 commit comments

Comments
 (0)