mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 09:34:12 +08:00
0f92140468
Implement a memory provider that allocates dmabuf devmem in the form of net_iov. The provider receives a reference to the struct netdev_dmabuf_binding via the pool->mp_priv pointer. The driver needs to set this pointer for the provider in the net_iov. The provider obtains a reference on the netdev_dmabuf_binding which guarantees the binding and the underlying mapping remains alive until the provider is destroyed. Usage of PP_FLAG_DMA_MAP is required for this memory provide such that the page_pool can provide the driver with the dma-addrs of the devmem. Support for PP_FLAG_DMA_SYNC_DEV is omitted for simplicity & p.order != 0. Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Kaiyuan Zhang <kaiyuanz@google.com> Signed-off-by: Mina Almasry <almasrymina@google.com> Reviewed-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Link: https://patch.msgid.link/20240910171458.219195-7-almasrymina@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
45 lines
964 B
C
45 lines
964 B
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Dmabuf device memory provider.
|
|
*
|
|
* Authors: Mina Almasry <almasrymina@google.com>
|
|
*
|
|
*/
|
|
#ifndef _NET_MP_DMABUF_DEVMEM_H
|
|
#define _NET_MP_DMABUF_DEVMEM_H
|
|
|
|
#include <net/netmem.h>
|
|
|
|
#if defined(CONFIG_NET_DEVMEM)
|
|
int mp_dmabuf_devmem_init(struct page_pool *pool);
|
|
|
|
netmem_ref mp_dmabuf_devmem_alloc_netmems(struct page_pool *pool, gfp_t gfp);
|
|
|
|
void mp_dmabuf_devmem_destroy(struct page_pool *pool);
|
|
|
|
bool mp_dmabuf_devmem_release_page(struct page_pool *pool, netmem_ref netmem);
|
|
#else
|
|
static inline int mp_dmabuf_devmem_init(struct page_pool *pool)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
static inline netmem_ref
|
|
mp_dmabuf_devmem_alloc_netmems(struct page_pool *pool, gfp_t gfp)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void mp_dmabuf_devmem_destroy(struct page_pool *pool)
|
|
{
|
|
}
|
|
|
|
static inline bool
|
|
mp_dmabuf_devmem_release_page(struct page_pool *pool, netmem_ref netmem)
|
|
{
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
#endif /* _NET_MP_DMABUF_DEVMEM_H */
|