net/mlx5: Fix auto group size calculation
authorMaor Gottlieb <maorg@mellanox.com>
Thu, 5 Sep 2019 06:56:10 +0000 (09:56 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Wed, 20 Nov 2019 20:33:06 +0000 (12:33 -0800)
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: f0d22d187473 ("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>
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h

index 3bbb49354829a6f36efab13e1420feefd73b907c..791e14ac26f4b7469e2301be504b01a207e430c7 100644 (file)
@@ -579,7 +579,7 @@ static void del_sw_flow_group(struct fs_node *node)
 
        rhashtable_destroy(&fg->ftes_hash);
        ida_destroy(&fg->fte_allocator);
-       if (ft->autogroup.active)
+       if (ft->autogroup.active && fg->max_ftes == ft->autogroup.group_size)
                ft->autogroup.num_groups--;
        err = rhltable_remove(&ft->fgs_hash,
                              &fg->hash,
@@ -1126,6 +1126,8 @@ mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
 
        ft->autogroup.active = true;
        ft->autogroup.required_groups = max_num_groups;
+       /* We save place for flow groups in addition to max types */
+       ft->autogroup.group_size = ft->max_fte / (max_num_groups + 1);
 
        return ft;
 }
@@ -1328,8 +1330,7 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table  *ft
                return ERR_PTR(-ENOENT);
 
        if (ft->autogroup.num_groups < ft->autogroup.required_groups)
-               /* We save place for flow groups in addition to max types */
-               group_size = ft->max_fte / (ft->autogroup.required_groups + 1);
+               group_size = ft->autogroup.group_size;
 
        /*  ft->max_fte == ft->autogroup.max_types */
        if (group_size == 0)
@@ -1356,7 +1357,8 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table  *ft
        if (IS_ERR(fg))
                goto out;
 
-       ft->autogroup.num_groups++;
+       if (group_size == ft->autogroup.group_size)
+               ft->autogroup.num_groups++;
 
 out:
        return fg;
index 00717eba22569ea8791556747b6b216cb6fc8ed6..c2621b9115633b53fe21d738bcd909f53d1bf108 100644 (file)
@@ -162,6 +162,7 @@ struct mlx5_flow_table {
        struct {
                bool                    active;
                unsigned int            required_groups;
+               unsigned int            group_size;
                unsigned int            num_groups;
        } autogroup;
        /* Protect fwd_rules */