blob: c81444611a228e51413fd162a67b2bec44400012 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _HWBM_H
3#define _HWBM_H
4
5struct hwbm_pool {
6 /* Capacity of the pool */
7 int size;
8 /* Size of the buffers managed */
9 int frag_size;
10 /* Number of buffers currently used by this pool */
11 int buf_num;
12 /* constructor called during alocation */
13 int (*construct)(struct hwbm_pool *bm_pool, void *buf);
14 /* protect acces to the buffer counter*/
David Brazdil0f672f62019-12-10 10:32:29 +000015 struct mutex buf_lock;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000016 /* private data */
17 void *priv;
18};
19#ifdef CONFIG_HWBM
20void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf);
21int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp);
David Brazdil0f672f62019-12-10 10:32:29 +000022int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000023#else
David Brazdil0f672f62019-12-10 10:32:29 +000024static inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {}
25
26static inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp)
27{ return 0; }
28
29static inline int hwbm_pool_add(struct hwbm_pool *bm_pool,
30 unsigned int buf_num)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000031{ return 0; }
32#endif /* CONFIG_HWBM */
33#endif /* _HWBM_H */