1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
28cb2d8bfSGregory CLEMENT #ifndef _HWBM_H
38cb2d8bfSGregory CLEMENT #define _HWBM_H
48cb2d8bfSGregory CLEMENT
5*949d6b40SJakub Kicinski #include <linux/mutex.h>
6*949d6b40SJakub Kicinski
78cb2d8bfSGregory CLEMENT struct hwbm_pool {
88cb2d8bfSGregory CLEMENT /* Capacity of the pool */
98cb2d8bfSGregory CLEMENT int size;
108cb2d8bfSGregory CLEMENT /* Size of the buffers managed */
118cb2d8bfSGregory CLEMENT int frag_size;
128cb2d8bfSGregory CLEMENT /* Number of buffers currently used by this pool */
138cb2d8bfSGregory CLEMENT int buf_num;
148cb2d8bfSGregory CLEMENT /* constructor called during alocation */
158cb2d8bfSGregory CLEMENT int (*construct)(struct hwbm_pool *bm_pool, void *buf);
168cb2d8bfSGregory CLEMENT /* protect acces to the buffer counter*/
176dcdd884SSebastian Andrzej Siewior struct mutex buf_lock;
188cb2d8bfSGregory CLEMENT /* private data */
198cb2d8bfSGregory CLEMENT void *priv;
208cb2d8bfSGregory CLEMENT };
218cb2d8bfSGregory CLEMENT #ifdef CONFIG_HWBM
228cb2d8bfSGregory CLEMENT void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf);
238cb2d8bfSGregory CLEMENT int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp);
246dcdd884SSebastian Andrzej Siewior int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num);
258cb2d8bfSGregory CLEMENT #else
hwbm_buf_free(struct hwbm_pool * bm_pool,void * buf)2691e2e576SBen Dooks (Codethink) static inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {}
2791e2e576SBen Dooks (Codethink)
hwbm_pool_refill(struct hwbm_pool * bm_pool,gfp_t gfp)2891e2e576SBen Dooks (Codethink) static inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp)
2991e2e576SBen Dooks (Codethink) { return 0; }
3091e2e576SBen Dooks (Codethink)
hwbm_pool_add(struct hwbm_pool * bm_pool,unsigned int buf_num)3191e2e576SBen Dooks (Codethink) static inline int hwbm_pool_add(struct hwbm_pool *bm_pool,
3291e2e576SBen Dooks (Codethink) unsigned int buf_num)
338cb2d8bfSGregory CLEMENT { return 0; }
348cb2d8bfSGregory CLEMENT #endif /* CONFIG_HWBM */
358cb2d8bfSGregory CLEMENT #endif /* _HWBM_H */
36