Skip to content

Commit c7e62a7

Browse files
mosheshemesh2kuba-moo
authored andcommitted
net/mlx5: fs, add HWS actions pool
The HW Steering actions pool will help utilize the option in HW Steering to share steering actions among different rules. Create pool on root namespace creation and add few HW Steering actions that don't depend on the steering rule itself and thus can be shared between rules, created on same namespace: tag, pop_vlan, push_vlan, drop, decap l2. Signed-off-by: Moshe Shemesh <[email protected]> Reviewed-by: Yevgeny Kliteynik <[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 4160405 commit c7e62a7

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,60 @@
99
#define MLX5HWS_CTX_MAX_NUM_OF_QUEUES 16
1010
#define MLX5HWS_CTX_QUEUE_SIZE 256
1111

12+
static int mlx5_fs_init_hws_actions_pool(struct mlx5_fs_hws_context *fs_ctx)
13+
{
14+
u32 flags = MLX5HWS_ACTION_FLAG_HWS_FDB | MLX5HWS_ACTION_FLAG_SHARED;
15+
struct mlx5_fs_hws_actions_pool *hws_pool = &fs_ctx->hws_pool;
16+
struct mlx5hws_action_reformat_header reformat_hdr = {};
17+
struct mlx5hws_context *ctx = fs_ctx->hws_ctx;
18+
enum mlx5hws_action_type action_type;
19+
20+
hws_pool->tag_action = mlx5hws_action_create_tag(ctx, flags);
21+
if (!hws_pool->tag_action)
22+
return -ENOSPC;
23+
hws_pool->pop_vlan_action = mlx5hws_action_create_pop_vlan(ctx, flags);
24+
if (!hws_pool->pop_vlan_action)
25+
goto destroy_tag;
26+
hws_pool->push_vlan_action = mlx5hws_action_create_push_vlan(ctx, flags);
27+
if (!hws_pool->push_vlan_action)
28+
goto destroy_pop_vlan;
29+
hws_pool->drop_action = mlx5hws_action_create_dest_drop(ctx, flags);
30+
if (!hws_pool->drop_action)
31+
goto destroy_push_vlan;
32+
action_type = MLX5HWS_ACTION_TYP_REFORMAT_TNL_L2_TO_L2;
33+
hws_pool->decapl2_action =
34+
mlx5hws_action_create_reformat(ctx, action_type, 1,
35+
&reformat_hdr, 0, flags);
36+
if (!hws_pool->decapl2_action)
37+
goto destroy_drop;
38+
return 0;
39+
40+
destroy_drop:
41+
mlx5hws_action_destroy(hws_pool->drop_action);
42+
destroy_push_vlan:
43+
mlx5hws_action_destroy(hws_pool->push_vlan_action);
44+
destroy_pop_vlan:
45+
mlx5hws_action_destroy(hws_pool->pop_vlan_action);
46+
destroy_tag:
47+
mlx5hws_action_destroy(hws_pool->tag_action);
48+
return -ENOSPC;
49+
}
50+
51+
static void mlx5_fs_cleanup_hws_actions_pool(struct mlx5_fs_hws_context *fs_ctx)
52+
{
53+
struct mlx5_fs_hws_actions_pool *hws_pool = &fs_ctx->hws_pool;
54+
55+
mlx5hws_action_destroy(hws_pool->decapl2_action);
56+
mlx5hws_action_destroy(hws_pool->drop_action);
57+
mlx5hws_action_destroy(hws_pool->push_vlan_action);
58+
mlx5hws_action_destroy(hws_pool->pop_vlan_action);
59+
mlx5hws_action_destroy(hws_pool->tag_action);
60+
}
61+
1262
static int mlx5_cmd_hws_create_ns(struct mlx5_flow_root_namespace *ns)
1363
{
1464
struct mlx5hws_context_attr hws_ctx_attr = {};
65+
int err;
1566

1667
hws_ctx_attr.queues = min_t(int, num_online_cpus(),
1768
MLX5HWS_CTX_MAX_NUM_OF_QUEUES);
@@ -23,11 +74,18 @@ static int mlx5_cmd_hws_create_ns(struct mlx5_flow_root_namespace *ns)
2374
mlx5_core_err(ns->dev, "Failed to create hws flow namespace\n");
2475
return -EINVAL;
2576
}
77+
err = mlx5_fs_init_hws_actions_pool(&ns->fs_hws_context);
78+
if (err) {
79+
mlx5_core_err(ns->dev, "Failed to init hws actions pool\n");
80+
mlx5hws_context_close(ns->fs_hws_context.hws_ctx);
81+
return err;
82+
}
2683
return 0;
2784
}
2885

2986
static int mlx5_cmd_hws_destroy_ns(struct mlx5_flow_root_namespace *ns)
3087
{
88+
mlx5_fs_cleanup_hws_actions_pool(&ns->fs_hws_context);
3189
return mlx5hws_context_close(ns->fs_hws_context.hws_ctx);
3290
}
3391

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@
66

77
#include "mlx5hws.h"
88

9+
struct mlx5_fs_hws_actions_pool {
10+
struct mlx5hws_action *tag_action;
11+
struct mlx5hws_action *pop_vlan_action;
12+
struct mlx5hws_action *push_vlan_action;
13+
struct mlx5hws_action *drop_action;
14+
struct mlx5hws_action *decapl2_action;
15+
};
16+
917
struct mlx5_fs_hws_context {
1018
struct mlx5hws_context *hws_ctx;
19+
struct mlx5_fs_hws_actions_pool hws_pool;
1120
};
1221

1322
struct mlx5_fs_hws_table {

0 commit comments

Comments
 (0)