Debian Codegraph @

drivers/net/ethernet/mellanox/mlx5/core/fs_pool.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2024 NVIDIA Corporation & Affiliates */
3
4 #ifndef __MLX5_FS_POOL_H__
5 #define __MLX5_FS_POOL_H__
6
7 #include <linux/mlx5/driver.h>
8
9 struct mlx5_fs_bulk {
10 struct list_head pool_list;
11 int bulk_len;
12 unsigned long *bitmask;
13 };
14
15 struct mlx5_fs_pool_index {
16 struct mlx5_fs_bulk *fs_bulk;
17 int index;
18 };
19
20 struct mlx5_fs_pool;
21
22 struct mlx5_fs_pool_ops {
23 int (*bulk_destroy)(struct mlx5_core_dev *dev, struct mlx5_fs_bulk *bulk);
24 struct mlx5_fs_bulk * (*bulk_create)(struct mlx5_core_dev *dev,
25 void *pool_ctx);
26 void (*update_threshold)(struct mlx5_fs_pool *pool);
27 };
28
29 struct mlx5_fs_pool {
30 struct mlx5_core_dev *dev;
31 void *pool_ctx;
32 const struct mlx5_fs_pool_ops *ops;
33 struct mutex pool_lock; /* protects pool lists */
34 struct list_head fully_used;
35 struct list_head partially_used;
36 struct list_head unused;
37 int available_units;
38 int used_units;
39 int threshold;
40 };
41
42 void mlx5_fs_bulk_init(struct mlx5_fs_bulk *fs_bulk, int bulk_len);
43 int mlx5_fs_bulk_bitmap_alloc(struct mlx5_core_dev *dev,
44 struct mlx5_fs_bulk *fs_bulk);
45 void mlx5_fs_bulk_cleanup(struct mlx5_fs_bulk *fs_bulk);
46 int mlx5_fs_bulk_get_free_amount(struct mlx5_fs_bulk *bulk);
47
48 void mlx5_fs_pool_init(struct mlx5_fs_pool *pool, struct mlx5_core_dev *dev,
49 const struct mlx5_fs_pool_ops *ops, void *pool_ctx);
50 void mlx5_fs_pool_cleanup(struct mlx5_fs_pool *pool);
51 int mlx5_fs_pool_acquire_index(struct mlx5_fs_pool *fs_pool,
52 struct mlx5_fs_pool_index *pool_index);
53 int mlx5_fs_pool_release_index(struct mlx5_fs_pool *fs_pool,
54 struct mlx5_fs_pool_index *pool_index);
55
56 #endif /* __MLX5_FS_POOL_H__ */