162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _HWBM_H
362306a36Sopenharmony_ci#define _HWBM_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/mutex.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_cistruct hwbm_pool {
862306a36Sopenharmony_ci	/* Capacity of the pool */
962306a36Sopenharmony_ci	int size;
1062306a36Sopenharmony_ci	/* Size of the buffers managed */
1162306a36Sopenharmony_ci	int frag_size;
1262306a36Sopenharmony_ci	/* Number of buffers currently used by this pool */
1362306a36Sopenharmony_ci	int buf_num;
1462306a36Sopenharmony_ci	/* constructor called during alocation */
1562306a36Sopenharmony_ci	int (*construct)(struct hwbm_pool *bm_pool, void *buf);
1662306a36Sopenharmony_ci	/* protect acces to the buffer counter*/
1762306a36Sopenharmony_ci	struct mutex buf_lock;
1862306a36Sopenharmony_ci	/* private data */
1962306a36Sopenharmony_ci	void *priv;
2062306a36Sopenharmony_ci};
2162306a36Sopenharmony_ci#ifdef CONFIG_HWBM
2262306a36Sopenharmony_civoid hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf);
2362306a36Sopenharmony_ciint hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp);
2462306a36Sopenharmony_ciint hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num);
2562306a36Sopenharmony_ci#else
2662306a36Sopenharmony_cistatic inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {}
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cistatic inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp)
2962306a36Sopenharmony_ci{ return 0; }
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_cistatic inline int hwbm_pool_add(struct hwbm_pool *bm_pool,
3262306a36Sopenharmony_ci				unsigned int buf_num)
3362306a36Sopenharmony_ci{ return 0; }
3462306a36Sopenharmony_ci#endif /* CONFIG_HWBM */
3562306a36Sopenharmony_ci#endif /* _HWBM_H */
36