From nobody Wed Nov 15 23:09:10 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SVzPg04Zjz50ryF; Wed, 15 Nov 2023 23:09:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SVzPf4H9lz3N9P; Wed, 15 Nov 2023 23:09:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700089750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xlh0Ce9/uDN1PlZKDNkB3ZAh0yM40gxDXaoBOTfiSd4=; b=IxLC0r3b3YFMBi+GDBSHCGkzFuXNIhlzR4vLTQbwK1LssWhq990XCp/Ar8UY6pNOqUORSa SAiDVkkIJBHTxf5ly6c4jjrVyD85wsLdc0OhPw7cNlHPKxyLq82QnTcoAMh6eP3D9fwTCB OfuF6P118SVF+6OZTixaLMmYD6N8MqQcna7ApaJCPixoTUsDaTrhKFJSO2adz19lPNbF5K zYqR3xc4wJBQXYEzmBOGEFqHj7eNRg3vWm7aHcRJ64i0lzC3A+QxtHaLe/xyWen3sfhvio gc4lUSGT29fyK1WPPdYwxXypZlquW7fg0e7edWMCXpWE94S7ee5Zsx3499R/EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700089750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xlh0Ce9/uDN1PlZKDNkB3ZAh0yM40gxDXaoBOTfiSd4=; b=aujgl+TUF3n8x8QkfNQyOkyoubVy/wnQ23RNgVj+wDBO3Hpg7F1FwHL04G6G0E4YyB3Jl6 8Ca6iLaVkbsg5Ley7lgEIo2efp2aYrCN/tIeEF97Vteu7zzjyKznBxM+6gIcEfNBdZ6Ua9 vGyvrEUgImaHibOGNciHKBeaRVf1dqNRd8kztCARbjFPIuRv+faozUc2AncjBdHZwMEZsw EdjTgeGjhWZS0qcGgXGB1+Ay4fT/7NpfufiYkwFwmuRiJ4daPOp5/Dc+89RNm4tt4rnAvm z5xS7uH1f1GcOGofCaLZe2XFjzKVi959ctvJqx0hVf//OAsSgwuMlxUkMD4agQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700089750; a=rsa-sha256; cv=none; b=J8dwsLg2EZhmTV+K6QGFxC7xuF58G3vF6gMsLAJhVKihaeKc0nUn69nvILVJyN3LHq/DmJ /qBofNCyqEepWwNB+QwcPEIJpXkfet1QJJKXAkC9qwD1OvDtheybziR5Vbd+bI8iJdebkB mTGIu23MKOwJic74tRE1L3nC3xZgEY7Uco5naZ5CrcMoyE/6HTri0DAO7TrYtPINOvtdMT UIumlcceplWTCQFhqOGL/fZVjsjXi8qkgeyBqKDTOdJNGAjYmii07kkFDtxCKwMqQIatem Jfae+36XcktwNEV/V/klTH4MAQGAit8jcxoZK/X5f3EqEdJK0/gxwLEtwvkD5w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SVzPf3Ln5zbK9; Wed, 15 Nov 2023 23:09:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AFN9AG2064807; Wed, 15 Nov 2023 23:09:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AFN9AcW064804; Wed, 15 Nov 2023 23:09:10 GMT (envelope-from git) Date: Wed, 15 Nov 2023 23:09:10 GMT Message-Id: <202311152309.3AFN9AcW064804@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 04db54fe4309 - main - net/mlx5: Fix auto group size calculation List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 04db54fe4309e896c4c80baadbcc47b171722027 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=04db54fe4309e896c4c80baadbcc47b171722027 commit 04db54fe4309e896c4c80baadbcc47b171722027 Author: Mark Bloch AuthorDate: 2023-02-19 14:05:16 +0000 Commit: Konstantin Belousov 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 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;