Skip to content

Commit 3fd62e9

Browse files
mosheshemesh2kuba-moo
authored andcommitted
net/mlx5: fs, add dest table cache
Add cache of destination flow table HWS action per HWS table. For each flow table created cache a destination action towards this table. The cached action will be used on the downstream patch whenever a rule requires such action. 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 b581f42 commit 3fd62e9

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

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

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static int mlx5_fs_init_hws_actions_pool(struct mlx5_core_dev *dev,
6262
xa_init(&hws_pool->el2tol3tnl_pools);
6363
xa_init(&hws_pool->el2tol2tnl_pools);
6464
xa_init(&hws_pool->mh_pools);
65+
xa_init(&hws_pool->table_dests);
6566
return 0;
6667

6768
cleanup_insert_hdr:
@@ -87,6 +88,7 @@ static void mlx5_fs_cleanup_hws_actions_pool(struct mlx5_fs_hws_context *fs_ctx)
8788
struct mlx5_fs_pool *pool;
8889
unsigned long i;
8990

91+
xa_destroy(&hws_pool->table_dests);
9092
xa_for_each(&hws_pool->mh_pools, i, pool)
9193
mlx5_fs_destroy_mh_pool(pool, &hws_pool->mh_pools, i);
9294
xa_destroy(&hws_pool->mh_pools);
@@ -173,6 +175,50 @@ static int mlx5_fs_set_ft_default_miss(struct mlx5_flow_root_namespace *ns,
173175
return 0;
174176
}
175177

178+
static int mlx5_fs_add_flow_table_dest_action(struct mlx5_flow_root_namespace *ns,
179+
struct mlx5_flow_table *ft)
180+
{
181+
u32 flags = MLX5HWS_ACTION_FLAG_HWS_FDB | MLX5HWS_ACTION_FLAG_SHARED;
182+
struct mlx5_fs_hws_context *fs_ctx = &ns->fs_hws_context;
183+
struct mlx5hws_action *dest_ft_action;
184+
struct xarray *dests_xa;
185+
int err;
186+
187+
dest_ft_action = mlx5hws_action_create_dest_table_num(fs_ctx->hws_ctx,
188+
ft->id, flags);
189+
if (!dest_ft_action) {
190+
mlx5_core_err(ns->dev, "Failed creating dest table action\n");
191+
return -ENOMEM;
192+
}
193+
194+
dests_xa = &fs_ctx->hws_pool.table_dests;
195+
err = xa_insert(dests_xa, ft->id, dest_ft_action, GFP_KERNEL);
196+
if (err)
197+
mlx5hws_action_destroy(dest_ft_action);
198+
return err;
199+
}
200+
201+
static int mlx5_fs_del_flow_table_dest_action(struct mlx5_flow_root_namespace *ns,
202+
struct mlx5_flow_table *ft)
203+
{
204+
struct mlx5_fs_hws_context *fs_ctx = &ns->fs_hws_context;
205+
struct mlx5hws_action *dest_ft_action;
206+
struct xarray *dests_xa;
207+
int err;
208+
209+
dests_xa = &fs_ctx->hws_pool.table_dests;
210+
dest_ft_action = xa_erase(dests_xa, ft->id);
211+
if (!dest_ft_action) {
212+
mlx5_core_err(ns->dev, "Failed to erase dest ft action\n");
213+
return -ENOENT;
214+
}
215+
216+
err = mlx5hws_action_destroy(dest_ft_action);
217+
if (err)
218+
mlx5_core_err(ns->dev, "Failed to destroy dest ft action\n");
219+
return err;
220+
}
221+
176222
static int mlx5_cmd_hws_create_flow_table(struct mlx5_flow_root_namespace *ns,
177223
struct mlx5_flow_table *ft,
178224
struct mlx5_flow_table_attr *ft_attr,
@@ -183,9 +229,16 @@ static int mlx5_cmd_hws_create_flow_table(struct mlx5_flow_root_namespace *ns,
183229
struct mlx5hws_table *tbl;
184230
int err;
185231

186-
if (mlx5_fs_cmd_is_fw_term_table(ft))
187-
return mlx5_fs_cmd_get_fw_cmds()->create_flow_table(ns, ft, ft_attr,
188-
next_ft);
232+
if (mlx5_fs_cmd_is_fw_term_table(ft)) {
233+
err = mlx5_fs_cmd_get_fw_cmds()->create_flow_table(ns, ft, ft_attr,
234+
next_ft);
235+
if (err)
236+
return err;
237+
err = mlx5_fs_add_flow_table_dest_action(ns, ft);
238+
if (err)
239+
mlx5_fs_cmd_get_fw_cmds()->destroy_flow_table(ns, ft);
240+
return err;
241+
}
189242

190243
if (ns->table_type != FS_FT_FDB) {
191244
mlx5_core_err(ns->dev, "Table type %d not supported for HWS\n",
@@ -212,8 +265,13 @@ static int mlx5_cmd_hws_create_flow_table(struct mlx5_flow_root_namespace *ns,
212265

213266
ft->max_fte = INT_MAX;
214267

268+
err = mlx5_fs_add_flow_table_dest_action(ns, ft);
269+
if (err)
270+
goto clear_ft_miss;
215271
return 0;
216272

273+
clear_ft_miss:
274+
mlx5_fs_set_ft_default_miss(ns, ft, NULL);
217275
destroy_table:
218276
mlx5hws_table_destroy(tbl);
219277
ft->fs_hws_table.hws_table = NULL;
@@ -225,6 +283,10 @@ static int mlx5_cmd_hws_destroy_flow_table(struct mlx5_flow_root_namespace *ns,
225283
{
226284
int err;
227285

286+
err = mlx5_fs_del_flow_table_dest_action(ns, ft);
287+
if (err)
288+
mlx5_core_err(ns->dev, "Failed to remove dest action (%d)\n", err);
289+
228290
if (mlx5_fs_cmd_is_fw_term_table(ft))
229291
return mlx5_fs_cmd_get_fw_cmds()->destroy_flow_table(ns, ft);
230292

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct mlx5_fs_hws_actions_pool {
1919
struct xarray el2tol3tnl_pools;
2020
struct xarray el2tol2tnl_pools;
2121
struct xarray mh_pools;
22+
struct xarray table_dests;
2223
};
2324

2425
struct mlx5_fs_hws_context {

0 commit comments

Comments
 (0)