The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=04db54fe4309e896c4c80baadbcc47b171722027

commit 04db54fe4309e896c4c80baadbcc47b171722027
Author:     Mark Bloch <[email protected]>
AuthorDate: 2023-02-19 14:05:16 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2023-11-15 23:08:16 +0000

    net/mlx5: Fix auto group size calculation
    
    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.
    
    Upstream Linux commit: 97fd8da281f80e7e69e0114bc906575734d4dfaf
    Signed-off-by: Mark Bloch <[email protected]>
    Sponsored by:   NVidia networking
    MFC after:      1 week
---
 sys/dev/mlx5/mlx5_core/fs_core.h      |  1 +
 sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/sys/dev/mlx5/mlx5_core/fs_core.h b/sys/dev/mlx5/mlx5_core/fs_core.h
index 3eae7868833f..dc619fc2d2db 100644
--- a/sys/dev/mlx5/mlx5_core/fs_core.h
+++ b/sys/dev/mlx5/mlx5_core/fs_core.h
@@ -97,6 +97,7 @@ struct mlx5_flow_table {
        struct {
                bool                    active;
                unsigned int            max_types;
+               unsigned int            group_size;
                unsigned int            num_types;
        } autogroup;
        unsigned int                    max_fte;
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c 
b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
index 60353e4b3d5b..b59373d48730 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
@@ -918,6 +918,9 @@ struct mlx5_flow_table 
*mlx5_create_auto_grouped_flow_table(struct mlx5_flow_nam
 
        ft->autogroup.active = true;
        ft->autogroup.max_types = 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);
+
        if (is_shared_prio)
                ft->shared_refcount = 1;
 
@@ -1066,6 +1069,7 @@ static struct mlx5_flow_group *fs_create_fg(struct 
mlx5_core_dev *dev,
                                            int refcount)
 {
        struct mlx5_flow_group *fg;
+       unsigned int group_size;
        int err;
        char name[20];
 
@@ -1073,6 +1077,8 @@ static struct mlx5_flow_group *fs_create_fg(struct 
mlx5_core_dev *dev,
        if (IS_ERR(fg))
                return fg;
 
+       group_size = MLX5_GET(create_flow_group_in, fg_in, end_flow_index) -
+               MLX5_GET(create_flow_group_in, fg_in, start_flow_index) + 1;
        err =  mlx5_cmd_fs_create_fg(dev, fg_in,
                                     ft->vport, ft->type, ft->id,
                                     &fg->id);
@@ -1080,7 +1086,8 @@ static struct mlx5_flow_group *fs_create_fg(struct 
mlx5_core_dev *dev,
                goto free_fg;
 
        mutex_lock(&ft->base.lock);
-       if (ft->autogroup.active)
+
+       if (ft->autogroup.active && group_size == ft->autogroup.group_size)
                ft->autogroup.num_types++;
 
        snprintf(name, sizeof(name), "group_%u", fg->id);
@@ -1125,7 +1132,7 @@ static void fs_del_fg(struct mlx5_flow_group *fg)
        dev = fs_get_dev(&parent_ft->base);
        WARN_ON(!dev);
 
-       if (parent_ft->autogroup.active)
+       if (parent_ft->autogroup.active && fg->max_ftes == 
parent_ft->autogroup.group_size)
                parent_ft->autogroup.num_types--;
 
        if (mlx5_cmd_fs_destroy_fg(dev, parent_ft->vport,
@@ -1432,7 +1439,7 @@ static struct mlx5_flow_group *create_autogroup(struct 
mlx5_flow_table *ft,
 
 
        if (ft->autogroup.num_types < ft->autogroup.max_types)
-               group_size = ft->max_fte / (ft->autogroup.max_types + 1);
+               group_size = ft->autogroup.group_size;
        else
                group_size = 1;
 

Reply via email to