Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Gregory CLEMENT | 8cb2d8b | 2016-03-14 09:39:04 +0100 | [diff] [blame] | 2 | #ifndef _HWBM_H |
| 3 | #define _HWBM_H |
| 4 | |
| 5 | struct 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*/ |
Sebastian Andrzej Siewior | 6dcdd88 | 2019-06-07 21:20:40 +0200 | [diff] [blame] | 15 | struct mutex buf_lock; |
Gregory CLEMENT | 8cb2d8b | 2016-03-14 09:39:04 +0100 | [diff] [blame] | 16 | /* private data */ |
| 17 | void *priv; |
| 18 | }; |
| 19 | #ifdef CONFIG_HWBM |
| 20 | void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf); |
| 21 | int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp); |
Sebastian Andrzej Siewior | 6dcdd88 | 2019-06-07 21:20:40 +0200 | [diff] [blame] | 22 | int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num); |
Gregory CLEMENT | 8cb2d8b | 2016-03-14 09:39:04 +0100 | [diff] [blame] | 23 | #else |
Ben Dooks (Codethink) | 91e2e57 | 2019-10-23 11:01:39 +0100 | [diff] [blame] | 24 | static inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {} |
| 25 | |
| 26 | static inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp) |
| 27 | { return 0; } |
| 28 | |
| 29 | static inline int hwbm_pool_add(struct hwbm_pool *bm_pool, |
| 30 | unsigned int buf_num) |
Gregory CLEMENT | 8cb2d8b | 2016-03-14 09:39:04 +0100 | [diff] [blame] | 31 | { return 0; } |
| 32 | #endif /* CONFIG_HWBM */ |
| 33 | #endif /* _HWBM_H */ |