net/mlx5: Change POOL_NEXT_SIZE define value and make it global
authorPatrisious Haddad <phaddad@nvidia.com>
Wed, 19 Feb 2025 08:58:08 +0000 (10:58 +0200)
committerLeon Romanovsky <leon@kernel.org>
Sun, 23 Feb 2025 09:43:14 +0000 (04:43 -0500)
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 some 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.

In addition move the definition to "include/linux/mlx5/fs.h" to expose the
define to IB driver as well, while appropriately renaming it.

Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20250219085808.349923-3-tariqt@nvidia.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/esw/legacy.c
drivers/net/ethernet/mellanox/mlx5/core/fs_ft_pool.c
drivers/net/ethernet/mellanox/mlx5/core/fs_ft_pool.h
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
include/linux/mlx5/fs.h

index 45183de424f3ddc2dee99ddbb35c7f93c75a93cb..76382626ad41d3aea8a82d900c6bc8fa3edd0c22 100644 (file)
@@ -96,7 +96,7 @@ static int esw_create_legacy_fdb_table(struct mlx5_eswitch *esw)
        if (!flow_group_in)
                return -ENOMEM;
 
-       ft_attr.max_fte = POOL_NEXT_SIZE;
+       ft_attr.max_fte = MLX5_FS_MAX_POOL_SIZE;
        ft_attr.prio = LEGACY_FDB_PRIO;
        fdb = mlx5_create_flow_table(root_ns, &ft_attr);
        if (IS_ERR(fdb)) {
index c14590acc7726061a880b72a2ea1c87b7b22e730..f6abfd00d7e68c523d027fadff445dd5f05cb6b9 100644 (file)
@@ -50,10 +50,12 @@ 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 == MLX5_FS_MAX_POOL_SIZE) &&
                    FT_POOLS[i] <= max_ft_size) {
                        found_i = i;
-                       if (desired_size != POOL_NEXT_SIZE)
+                       if (desired_size != MLX5_FS_MAX_POOL_SIZE)
                                break;
                }
        }
index 25f4274b372b56301e28169237af2a447440b4fe..173e312db7204fb5f6b92501ba4a293579396060 100644 (file)
@@ -7,8 +7,6 @@
 #include <linux/mlx5/driver.h>
 #include "fs_core.h"
 
-#define POOL_NEXT_SIZE 0
-
 int mlx5_ft_pool_init(struct mlx5_core_dev *dev);
 void mlx5_ft_pool_destroy(struct mlx5_core_dev *dev);
 
index a80ecb672f33dd2319b230bdc3d5eece550bcdcb..c862dd28c46619f086671f8509b1c085fea88185 100644 (file)
@@ -161,7 +161,8 @@ mlx5_chains_create_table(struct mlx5_fs_chains *chains,
                ft_attr.flags |= (MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT |
                                  MLX5_FLOW_TABLE_TUNNEL_EN_DECAP);
 
-       sz = (chain == mlx5_chains_get_nf_ft_chain(chains)) ? FT_TBL_SZ : POOL_NEXT_SIZE;
+       sz = (chain == mlx5_chains_get_nf_ft_chain(chains)) ?
+               FT_TBL_SZ : MLX5_FS_MAX_POOL_SIZE;
        ft_attr.max_fte = sz;
 
        /* We use chains_default_ft(chains) as the table's next_ft till
index 2a69d9d71276d6f4147f01e2207f2e57ed626447..01cb72d68c231f6543c838b578d2ff1b96b22c8c 100644 (file)
@@ -40,6 +40,8 @@
 
 #define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v)
 
+#define MLX5_FS_MAX_POOL_SIZE BIT(30)
+
 enum mlx5_flow_destination_type {
        MLX5_FLOW_DESTINATION_TYPE_NONE,
        MLX5_FLOW_DESTINATION_TYPE_VPORT,