Skip to content

Commit 75d1d18

Browse files
Maor GottliebSaeed Mahameed
authored andcommitted
net/mlx5: Move the entry index allocator to flow group
When new flow table entry is added, we search for free index in the flow group and not in the flow table, therefore we can move the allocator from flow table to flow group. In downstream patches it will enable us to lock smaller part of the steering tree. Signed-off-by: Maor Gottlieb <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 800350a commit 75d1d18

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ static void del_flow_table(struct fs_node *node)
384384
err = mlx5_cmd_destroy_flow_table(dev, ft);
385385
if (err)
386386
mlx5_core_warn(dev, "flow steering can't destroy ft\n");
387-
ida_destroy(&ft->fte_allocator);
388387
rhltable_destroy(&ft->fgs_hash);
389388
fs_get_obj(prio, ft->node.parent);
390389
prio->num_ft--;
@@ -445,7 +444,7 @@ static void destroy_fte(struct fs_fte *fte, struct mlx5_flow_group *fg)
445444
WARN_ON(ret);
446445
fte->status = 0;
447446
fs_get_obj(ft, fg->node.parent);
448-
ida_simple_remove(&ft->fte_allocator, fte->index);
447+
ida_simple_remove(&fg->fte_allocator, fte->index - fg->start_index);
449448
}
450449

451450
static void del_fte(struct fs_node *node)
@@ -488,6 +487,7 @@ static void del_flow_group(struct fs_node *node)
488487
ft->autogroup.num_groups--;
489488

490489
rhashtable_destroy(&fg->ftes_hash);
490+
ida_destroy(&fg->fte_allocator);
491491
err = rhltable_remove(&ft->fgs_hash,
492492
&fg->hash,
493493
rhash_fg);
@@ -537,6 +537,7 @@ static struct mlx5_flow_group *alloc_flow_group(u32 *create_fg_in)
537537
kfree(fg);
538538
return ERR_PTR(ret);
539539
}
540+
ida_init(&fg->fte_allocator);
540541
fg->mask.match_criteria_enable = match_criteria_enable;
541542
memcpy(&fg->mask.match_criteria, match_criteria,
542543
sizeof(fg->mask.match_criteria));
@@ -575,7 +576,6 @@ static struct mlx5_flow_table *alloc_flow_table(int level, u16 vport, int max_ft
575576
ft->flags = flags;
576577
INIT_LIST_HEAD(&ft->fwd_rules);
577578
mutex_init(&ft->lock);
578-
ida_init(&ft->fte_allocator);
579579

580580
return ft;
581581
}
@@ -892,7 +892,6 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
892892
destroy_ft:
893893
mlx5_cmd_destroy_flow_table(root->dev, ft);
894894
free_ft:
895-
ida_destroy(&ft->fte_allocator);
896895
kfree(ft);
897896
unlock_root:
898897
mutex_unlock(&root->chain_lock);
@@ -1003,6 +1002,7 @@ static struct mlx5_flow_group *create_flow_group_common(struct mlx5_flow_table *
10031002
rhash_fg));
10041003
err_free_fg:
10051004
rhashtable_destroy(&fg->ftes_hash);
1005+
ida_destroy(&fg->fte_allocator);
10061006
kfree(fg);
10071007

10081008
return ERR_PTR(err);
@@ -1181,18 +1181,18 @@ static struct fs_fte *create_fte(struct mlx5_flow_group *fg,
11811181
u32 *match_value,
11821182
struct mlx5_flow_act *flow_act)
11831183
{
1184-
struct mlx5_flow_table *ft;
11851184
struct fs_fte *fte;
11861185
int index;
11871186
int ret;
11881187

1189-
fs_get_obj(ft, fg->node.parent);
1190-
index = ida_simple_get(&ft->fte_allocator, fg->start_index,
1191-
fg->start_index + fg->max_ftes,
1188+
index = ida_simple_get(&fg->fte_allocator, 0,
1189+
fg->max_ftes,
11921190
GFP_KERNEL);
11931191
if (index < 0)
11941192
return ERR_PTR(index);
11951193

1194+
index += fg->start_index;
1195+
11961196
fte = alloc_fte(flow_act, match_value, index);
11971197
if (IS_ERR(fte)) {
11981198
ret = PTR_ERR(fte);
@@ -1207,7 +1207,7 @@ static struct fs_fte *create_fte(struct mlx5_flow_group *fg,
12071207
err_hash:
12081208
kfree(fte);
12091209
err_alloc:
1210-
ida_simple_remove(&ft->fte_allocator, index);
1210+
ida_simple_remove(&fg->fte_allocator, index - fg->start_index);
12111211
return ERR_PTR(ret);
12121212
}
12131213

drivers/net/ethernet/mellanox/mlx5/core/fs_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ struct mlx5_flow_table {
119119
/* FWD rules that point on this flow table */
120120
struct list_head fwd_rules;
121121
u32 flags;
122-
struct ida fte_allocator;
123122
struct rhltable fgs_hash;
124123
};
125124

@@ -199,6 +198,7 @@ struct mlx5_flow_group {
199198
struct mlx5_flow_group_mask mask;
200199
u32 start_index;
201200
u32 max_ftes;
201+
struct ida fte_allocator;
202202
u32 id;
203203
struct rhashtable ftes_hash;
204204
struct rhlist_head hash;

0 commit comments

Comments
 (0)