1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _HWBM_H
3*4882a593Smuzhiyun #define _HWBM_H
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun struct hwbm_pool {
6*4882a593Smuzhiyun /* Capacity of the pool */
7*4882a593Smuzhiyun int size;
8*4882a593Smuzhiyun /* Size of the buffers managed */
9*4882a593Smuzhiyun int frag_size;
10*4882a593Smuzhiyun /* Number of buffers currently used by this pool */
11*4882a593Smuzhiyun int buf_num;
12*4882a593Smuzhiyun /* constructor called during alocation */
13*4882a593Smuzhiyun int (*construct)(struct hwbm_pool *bm_pool, void *buf);
14*4882a593Smuzhiyun /* protect acces to the buffer counter*/
15*4882a593Smuzhiyun struct mutex buf_lock;
16*4882a593Smuzhiyun /* private data */
17*4882a593Smuzhiyun void *priv;
18*4882a593Smuzhiyun };
19*4882a593Smuzhiyun #ifdef CONFIG_HWBM
20*4882a593Smuzhiyun void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf);
21*4882a593Smuzhiyun int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp);
22*4882a593Smuzhiyun int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num);
23*4882a593Smuzhiyun #else
hwbm_buf_free(struct hwbm_pool * bm_pool,void * buf)24*4882a593Smuzhiyun static inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {}
25*4882a593Smuzhiyun
hwbm_pool_refill(struct hwbm_pool * bm_pool,gfp_t gfp)26*4882a593Smuzhiyun static inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp)
27*4882a593Smuzhiyun { return 0; }
28*4882a593Smuzhiyun
hwbm_pool_add(struct hwbm_pool * bm_pool,unsigned int buf_num)29*4882a593Smuzhiyun static inline int hwbm_pool_add(struct hwbm_pool *bm_pool,
30*4882a593Smuzhiyun unsigned int buf_num)
31*4882a593Smuzhiyun { return 0; }
32*4882a593Smuzhiyun #endif /* CONFIG_HWBM */
33*4882a593Smuzhiyun #endif /* _HWBM_H */
34