Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _HWBM_H
0003 #define _HWBM_H
0004 
0005 #include <linux/mutex.h>
0006 
0007 struct hwbm_pool {
0008     /* Capacity of the pool */
0009     int size;
0010     /* Size of the buffers managed */
0011     int frag_size;
0012     /* Number of buffers currently used by this pool */
0013     int buf_num;
0014     /* constructor called during alocation */
0015     int (*construct)(struct hwbm_pool *bm_pool, void *buf);
0016     /* protect acces to the buffer counter*/
0017     struct mutex buf_lock;
0018     /* private data */
0019     void *priv;
0020 };
0021 #ifdef CONFIG_HWBM
0022 void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf);
0023 int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp);
0024 int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num);
0025 #else
0026 static inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {}
0027 
0028 static inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp)
0029 { return 0; }
0030 
0031 static inline int hwbm_pool_add(struct hwbm_pool *bm_pool,
0032                 unsigned int buf_num)
0033 { return 0; }
0034 #endif /* CONFIG_HWBM */
0035 #endif /* _HWBM_H */