Skip to content

Commit 19be80b

Browse files
Maor Gottliebgregkh
authored andcommitted
net/mlx5: Fix auto group size calculation
[ Upstream commit 97fd8da ] Once all the large flow groups (defined by the user when the flow table is created - max_num_groups) were created, then all the following new flow groups will have only one flow table entry, even though the flow table has place to larger groups. Fix the condition to prefer large flow group. Fixes: f0d22d1 ("net/mlx5_core: Introduce flow steering autogrouped flow table") Signed-off-by: Maor Gottlieb <maorg@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7fbdbcc commit 19be80b

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ static void del_sw_flow_group(struct fs_node *node)
549549

550550
rhashtable_destroy(&fg->ftes_hash);
551551
ida_destroy(&fg->fte_allocator);
552-
if (ft->autogroup.active)
552+
if (ft->autogroup.active && fg->max_ftes == ft->autogroup.group_size)
553553
ft->autogroup.num_groups--;
554554
err = rhltable_remove(&ft->fgs_hash,
555555
&fg->hash,
@@ -1095,6 +1095,8 @@ mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
10951095

10961096
ft->autogroup.active = true;
10971097
ft->autogroup.required_groups = max_num_groups;
1098+
/* We save place for flow groups in addition to max types */
1099+
ft->autogroup.group_size = ft->max_fte / (max_num_groups + 1);
10981100

10991101
return ft;
11001102
}
@@ -1297,8 +1299,7 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table *ft
12971299
return ERR_PTR(-ENOENT);
12981300

12991301
if (ft->autogroup.num_groups < ft->autogroup.required_groups)
1300-
/* We save place for flow groups in addition to max types */
1301-
group_size = ft->max_fte / (ft->autogroup.required_groups + 1);
1302+
group_size = ft->autogroup.group_size;
13021303

13031304
/* ft->max_fte == ft->autogroup.max_types */
13041305
if (group_size == 0)
@@ -1325,7 +1326,8 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table *ft
13251326
if (IS_ERR(fg))
13261327
goto out;
13271328

1328-
ft->autogroup.num_groups++;
1329+
if (group_size == ft->autogroup.group_size)
1330+
ft->autogroup.num_groups++;
13291331

13301332
out:
13311333
return fg;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ struct mlx5_flow_table {
137137
struct {
138138
bool active;
139139
unsigned int required_groups;
140+
unsigned int group_size;
140141
unsigned int num_groups;
141142
} autogroup;
142143
/* Protect fwd_rules */

0 commit comments

Comments
 (0)