]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: fs, split bulk init
authorMark Bloch <mbloch@nvidia.com>
Mon, 12 Jan 2026 09:40:24 +0000 (11:40 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 15 Jan 2026 11:10:27 +0000 (12:10 +0100)
Refactor mlx5_fs_bulk_init() by moving bitmap allocation logic into a
new helper function mlx5_fs_bulk_bitmap_alloc(). This change does not
alter any logic.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/1768210825-1598472-3-git-send-email-tariqt@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
drivers/net/ethernet/mellanox/mlx5/core/fs_pool.c
drivers/net/ethernet/mellanox/mlx5/core/fs_pool.h
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws_pools.c

index e14570a3d492d3a554467fe0b4c50a7be5417da9..14539a20a60f9f67f2a3b07b6d1558e5bb410e7b 100644 (file)
@@ -449,7 +449,9 @@ static struct mlx5_fs_bulk *mlx5_fc_bulk_create(struct mlx5_core_dev *dev,
        if (!fc_bulk)
                return NULL;
 
-       if (mlx5_fs_bulk_init(dev, &fc_bulk->fs_bulk, bulk_len))
+       mlx5_fs_bulk_init(&fc_bulk->fs_bulk, bulk_len);
+
+       if (mlx5_fs_bulk_bitmap_alloc(dev, &fc_bulk->fs_bulk))
                goto fc_bulk_free;
 
        if (mlx5_cmd_fc_bulk_alloc(dev, alloc_bitmask, &base_id))
@@ -566,7 +568,7 @@ mlx5_fc_local_create(u32 counter_id, u32 offset, u32 bulk_size)
 
        counter->type = MLX5_FC_TYPE_LOCAL;
        counter->id = counter_id;
-       fc_bulk->fs_bulk.bulk_len = bulk_size;
+       mlx5_fs_bulk_init(&fc_bulk->fs_bulk, bulk_size);
        mlx5_fc_bulk_init(fc_bulk, counter_id - offset);
        counter->bulk = fc_bulk;
        refcount_set(&counter->fc_local_refcount, 1);
index f6c226664602ec6151b35047943ed2e5fe1419ef..faa5192543163a7e0ad5a1fd78f6f9d627a7bdc9 100644 (file)
@@ -4,23 +4,27 @@
 #include <mlx5_core.h>
 #include "fs_pool.h"
 
-int mlx5_fs_bulk_init(struct mlx5_core_dev *dev, struct mlx5_fs_bulk *fs_bulk,
-                     int bulk_len)
+int mlx5_fs_bulk_bitmap_alloc(struct mlx5_core_dev *dev,
+                             struct mlx5_fs_bulk *fs_bulk)
 {
        int i;
 
-       fs_bulk->bitmask = kvcalloc(BITS_TO_LONGS(bulk_len), sizeof(unsigned long),
-                                   GFP_KERNEL);
+       fs_bulk->bitmask = kvcalloc(BITS_TO_LONGS(fs_bulk->bulk_len),
+                                   sizeof(unsigned long), GFP_KERNEL);
        if (!fs_bulk->bitmask)
                return -ENOMEM;
 
-       fs_bulk->bulk_len = bulk_len;
-       for (i = 0; i < bulk_len; i++)
+       for (i = 0; i < fs_bulk->bulk_len; i++)
                set_bit(i, fs_bulk->bitmask);
 
        return 0;
 }
 
+void mlx5_fs_bulk_init(struct mlx5_fs_bulk *fs_bulk, int bulk_len)
+{
+       fs_bulk->bulk_len = bulk_len;
+}
+
 void mlx5_fs_bulk_cleanup(struct mlx5_fs_bulk *fs_bulk)
 {
        kvfree(fs_bulk->bitmask);
index f04ec3107498b2334e285cc5feb7c3588d8834c0..4deb66479d162ddd51ab44cd1821a160ca287356 100644 (file)
@@ -39,8 +39,9 @@ struct mlx5_fs_pool {
        int threshold;
 };
 
-int mlx5_fs_bulk_init(struct mlx5_core_dev *dev, struct mlx5_fs_bulk *fs_bulk,
-                     int bulk_len);
+void mlx5_fs_bulk_init(struct mlx5_fs_bulk *fs_bulk, int bulk_len);
+int mlx5_fs_bulk_bitmap_alloc(struct mlx5_core_dev *dev,
+                             struct mlx5_fs_bulk *fs_bulk);
 void mlx5_fs_bulk_cleanup(struct mlx5_fs_bulk *fs_bulk);
 int mlx5_fs_bulk_get_free_amount(struct mlx5_fs_bulk *bulk);
 
index 839d71bd42164f894c1c4e04931453814151f513..5bc8e97ecf1cfebc43a3709e93ef136eb792c4ff 100644 (file)
@@ -121,7 +121,9 @@ mlx5_fs_hws_pr_bulk_create(struct mlx5_core_dev *dev, void *pool_ctx)
        if (!pr_bulk)
                return NULL;
 
-       if (mlx5_fs_bulk_init(dev, &pr_bulk->fs_bulk, bulk_len))
+       mlx5_fs_bulk_init(&pr_bulk->fs_bulk, bulk_len);
+
+       if (mlx5_fs_bulk_bitmap_alloc(dev, &pr_bulk->fs_bulk))
                goto free_pr_bulk;
 
        for (i = 0; i < bulk_len; i++) {
@@ -275,7 +277,9 @@ mlx5_fs_hws_mh_bulk_create(struct mlx5_core_dev *dev, void *pool_ctx)
        if (!mh_bulk)
                return NULL;
 
-       if (mlx5_fs_bulk_init(dev, &mh_bulk->fs_bulk, bulk_len))
+       mlx5_fs_bulk_init(&mh_bulk->fs_bulk, bulk_len);
+
+       if (mlx5_fs_bulk_bitmap_alloc(dev, &mh_bulk->fs_bulk))
                goto free_mh_bulk;
 
        for (int i = 0; i < bulk_len; i++) {