xref: /linux/net/core/mp_dmabuf_devmem.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Dmabuf device memory provider.
4  *
5  * Authors:	Mina Almasry <almasrymina@google.com>
6  *
7  */
8 #ifndef _NET_MP_DMABUF_DEVMEM_H
9 #define _NET_MP_DMABUF_DEVMEM_H
10 
11 #include <net/netmem.h>
12 
13 #if defined(CONFIG_NET_DEVMEM)
14 int mp_dmabuf_devmem_init(struct page_pool *pool);
15 
16 netmem_ref mp_dmabuf_devmem_alloc_netmems(struct page_pool *pool, gfp_t gfp);
17 
18 void mp_dmabuf_devmem_destroy(struct page_pool *pool);
19 
20 bool mp_dmabuf_devmem_release_page(struct page_pool *pool, netmem_ref netmem);
21 #else
22 static inline int mp_dmabuf_devmem_init(struct page_pool *pool)
23 {
24 	return -EOPNOTSUPP;
25 }
26 
27 static inline netmem_ref
28 mp_dmabuf_devmem_alloc_netmems(struct page_pool *pool, gfp_t gfp)
29 {
30 	return 0;
31 }
32 
33 static inline void mp_dmabuf_devmem_destroy(struct page_pool *pool)
34 {
35 }
36 
37 static inline bool
38 mp_dmabuf_devmem_release_page(struct page_pool *pool, netmem_ref netmem)
39 {
40 	return false;
41 }
42 #endif
43 
44 #endif /* _NET_MP_DMABUF_DEVMEM_H */
45