xref: /openbmc/linux/include/net/hwbm.h (revision 91e2e576)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
28cb2d8bfSGregory CLEMENT #ifndef _HWBM_H
38cb2d8bfSGregory CLEMENT #define _HWBM_H
48cb2d8bfSGregory CLEMENT 
58cb2d8bfSGregory CLEMENT struct hwbm_pool {
68cb2d8bfSGregory CLEMENT 	/* Capacity of the pool */
78cb2d8bfSGregory CLEMENT 	int size;
88cb2d8bfSGregory CLEMENT 	/* Size of the buffers managed */
98cb2d8bfSGregory CLEMENT 	int frag_size;
108cb2d8bfSGregory CLEMENT 	/* Number of buffers currently used by this pool */
118cb2d8bfSGregory CLEMENT 	int buf_num;
128cb2d8bfSGregory CLEMENT 	/* constructor called during alocation */
138cb2d8bfSGregory CLEMENT 	int (*construct)(struct hwbm_pool *bm_pool, void *buf);
148cb2d8bfSGregory CLEMENT 	/* protect acces to the buffer counter*/
156dcdd884SSebastian Andrzej Siewior 	struct mutex buf_lock;
168cb2d8bfSGregory CLEMENT 	/* private data */
178cb2d8bfSGregory CLEMENT 	void *priv;
188cb2d8bfSGregory CLEMENT };
198cb2d8bfSGregory CLEMENT #ifdef CONFIG_HWBM
208cb2d8bfSGregory CLEMENT void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf);
218cb2d8bfSGregory CLEMENT int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp);
226dcdd884SSebastian Andrzej Siewior int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num);
238cb2d8bfSGregory CLEMENT #else
2491e2e576SBen Dooks (Codethink) static inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {}
2591e2e576SBen Dooks (Codethink) 
2691e2e576SBen Dooks (Codethink) static inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp)
2791e2e576SBen Dooks (Codethink) { return 0; }
2891e2e576SBen Dooks (Codethink) 
2991e2e576SBen Dooks (Codethink) static inline int hwbm_pool_add(struct hwbm_pool *bm_pool,
3091e2e576SBen Dooks (Codethink) 				unsigned int buf_num)
318cb2d8bfSGregory CLEMENT { return 0; }
328cb2d8bfSGregory CLEMENT #endif /* CONFIG_HWBM */
338cb2d8bfSGregory CLEMENT #endif /* _HWBM_H */
34