2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2016-03-14 09:39:04 +01:00
|
|
|
#ifndef _HWBM_H
|
|
|
|
|
#define _HWBM_H
|
|
|
|
|
|
2022-07-20 16:57:58 -07:00
|
|
|
#include <linux/mutex.h>
|
|
|
|
|
|
2016-03-14 09:39:04 +01:00
|
|
|
struct hwbm_pool {
|
|
|
|
|
/* Capacity of the pool */
|
|
|
|
|
int size;
|
|
|
|
|
/* Size of the buffers managed */
|
|
|
|
|
int frag_size;
|
|
|
|
|
/* Number of buffers currently used by this pool */
|
|
|
|
|
int buf_num;
|
2024-08-22 13:57:33 +01:00
|
|
|
/* constructor called during allocation */
|
2016-03-14 09:39:04 +01:00
|
|
|
int (*construct)(struct hwbm_pool *bm_pool, void *buf);
|
2024-08-22 13:57:33 +01:00
|
|
|
/* protect access to the buffer counter*/
|
2019-06-07 21:20:40 +02:00
|
|
|
struct mutex buf_lock;
|
2016-03-14 09:39:04 +01:00
|
|
|
/* private data */
|
|
|
|
|
void *priv;
|
|
|
|
|
};
|
|
|
|
|
#ifdef CONFIG_HWBM
|
|
|
|
|
void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf);
|
|
|
|
|
int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp);
|
2019-06-07 21:20:40 +02:00
|
|
|
int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num);
|
2016-03-14 09:39:04 +01:00
|
|
|
#else
|
2019-10-23 11:01:39 +01:00
|
|
|
static inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {}
|
|
|
|
|
|
|
|
|
|
static inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp)
|
|
|
|
|
{ return 0; }
|
|
|
|
|
|
|
|
|
|
static inline int hwbm_pool_add(struct hwbm_pool *bm_pool,
|
|
|
|
|
unsigned int buf_num)
|
2016-03-14 09:39:04 +01:00
|
|
|
{ return 0; }
|
|
|
|
|
#endif /* CONFIG_HWBM */
|
|
|
|
|
#endif /* _HWBM_H */
|