diff options
author | Gregory CLEMENT <gregory.clement@free-electrons.com> | 2016-03-14 09:39:04 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-03-14 17:19:46 +0100 |
commit | 8cb2d8bf57e6e004c37db2fb4ce74f4d032b7cd0 (patch) | |
tree | d70238eede693b7bf8b42d86a4eab534754ce341 /include/net/hwbm.h | |
parent | net: mvneta: bm: add support for hardware buffer management (diff) | |
download | linux-8cb2d8bf57e6e004c37db2fb4ce74f4d032b7cd0.tar.xz linux-8cb2d8bf57e6e004c37db2fb4ce74f4d032b7cd0.zip |
net: add a hardware buffer management helper API
This basic implementation allows to share code between driver using
hardware buffer management. As the code is hardware agnostic, there is
few helpers, most of the optimization brought by the an HW BM has to be
done at driver level.
Tested-by: Sebastian Careba <nitroshift@yahoo.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/hwbm.h')
-rw-r--r-- | include/net/hwbm.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/net/hwbm.h b/include/net/hwbm.h new file mode 100644 index 000000000000..47d08662501b --- /dev/null +++ b/include/net/hwbm.h @@ -0,0 +1,28 @@ +#ifndef _HWBM_H +#define _HWBM_H + +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; + /* constructor called during alocation */ + int (*construct)(struct hwbm_pool *bm_pool, void *buf); + /* protect acces to the buffer counter*/ + spinlock_t lock; + /* 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); +int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num, gfp_t gfp); +#else +void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {} +int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp) { return 0; } +int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num, gfp_t gfp) +{ return 0; } +#endif /* CONFIG_HWBM */ +#endif /* _HWBM_H */ |