git: 2fb2c0351237 - main - mlx5_core: fix "no space" error on sriov enablement

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 15 Dec 2024 22:48:45 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=2fb2c0351237aed71abedb7eb6d737b4390b490a

commit 2fb2c0351237aed71abedb7eb6d737b4390b490a
Author:     Ariel Ehrenberg <aehrenberg@nvidia.com>
AuthorDate: 2024-11-25 13:10:41 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-12-15 22:27:53 +0000

    mlx5_core: fix "no space" error on sriov enablement
    
    Change POOL_NEXT_SIZE define value from 0 to BIT(30), since this define
    is used to request the available maximum sized flow table, and zero doesn't
    make sense for it, whereas many places in the driver use zero explicitly
    expecting the smallest table size possible but instead due to this
    define they end up allocating the biggest table size unawarely.
    
    Sponsored by:   NVidia networking
---
 sys/dev/mlx5/mlx5_core/fs_ft_pool.h      | 2 +-
 sys/dev/mlx5/mlx5_core/mlx5_fs_ft_pool.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/dev/mlx5/mlx5_core/fs_ft_pool.h b/sys/dev/mlx5/mlx5_core/fs_ft_pool.h
index b81e70d51bd6..a5e4df624e27 100644
--- a/sys/dev/mlx5/mlx5_core/fs_ft_pool.h
+++ b/sys/dev/mlx5/mlx5_core/fs_ft_pool.h
@@ -9,7 +9,7 @@
 #include <dev/mlx5/mlx5_core/fs_core.h>
 #include <linux/compiler.h>
 
-#define POOL_NEXT_SIZE 0
+#define POOL_NEXT_SIZE BIT(30)
 
 int mlx5_ft_pool_init(struct mlx5_core_dev *dev);
 void mlx5_ft_pool_destroy(struct mlx5_core_dev *dev);
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_ft_pool.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_ft_pool.c
index c14590acc772..70d9d235b629 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_fs_ft_pool.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_ft_pool.c
@@ -50,7 +50,8 @@ mlx5_ft_pool_get_avail_sz(struct mlx5_core_dev *dev, enum fs_flow_table_type tab
 	int i, found_i = -1;
 
 	for (i = ARRAY_SIZE(FT_POOLS) - 1; i >= 0; i--) {
-		if (dev->priv.ft_pool->ft_left[i] && FT_POOLS[i] >= desired_size &&
+		if (dev->priv.ft_pool->ft_left[i] &&
+                    (FT_POOLS[i] >= desired_size || desired_size == POOL_NEXT_SIZE) &&
 		    FT_POOLS[i] <= max_ft_size) {
 			found_i = i;
 			if (desired_size != POOL_NEXT_SIZE)