Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Nov 2023 01:51:56 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4c6a46cea41b - stable/14 - net/mlx5: Fix auto group size calculation
Message-ID:  <202311220151.3AM1pudu077325@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=4c6a46cea41b236f9b06e702e8491055dddc7d4c

commit 4c6a46cea41b236f9b06e702e8491055dddc7d4c
Author:     Mark Bloch <mbloch@nvidia.com>
AuthorDate: 2023-02-19 14:05:16 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-11-22 01:40:28 +0000

    net/mlx5: Fix auto group size calculation
    
    (cherry picked from commit 04db54fe4309e896c4c80baadbcc47b171722027)
---
 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;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202311220151.3AM1pudu077325>