mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 00:21:59 +00:00
8ab79ed50c
Convert netmem to be a union of struct page and struct netmem. Overload the LSB of struct netmem* to indicate that it's a net_iov, otherwise it's a page. Currently these entries in struct page are rented by the page_pool and used exclusively by the net stack: struct { unsigned long pp_magic; struct page_pool *pp; unsigned long _pp_mapping_pad; unsigned long dma_addr; atomic_long_t pp_ref_count; }; Mirror these (and only these) entries into struct net_iov and implement netmem helpers that can access these common fields regardless of whether the underlying type is page or net_iov. Implement checks for net_iov in netmem helpers which delegate to mm APIs, to ensure net_iov are never passed to the mm stack. Signed-off-by: Mina Almasry <almasrymina@google.com> Reviewed-by: Pavel Begunkov <asml.silence@gmail.com> Acked-by: Jakub Kicinski <kuba@kernel.org> Link: https://patch.msgid.link/20240910171458.219195-6-almasrymina@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
32 lines
727 B
C
32 lines
727 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef __NETMEM_PRIV_H
|
|
#define __NETMEM_PRIV_H
|
|
|
|
static inline unsigned long netmem_get_pp_magic(netmem_ref netmem)
|
|
{
|
|
return __netmem_clear_lsb(netmem)->pp_magic;
|
|
}
|
|
|
|
static inline void netmem_or_pp_magic(netmem_ref netmem, unsigned long pp_magic)
|
|
{
|
|
__netmem_clear_lsb(netmem)->pp_magic |= pp_magic;
|
|
}
|
|
|
|
static inline void netmem_clear_pp_magic(netmem_ref netmem)
|
|
{
|
|
__netmem_clear_lsb(netmem)->pp_magic = 0;
|
|
}
|
|
|
|
static inline void netmem_set_pp(netmem_ref netmem, struct page_pool *pool)
|
|
{
|
|
__netmem_clear_lsb(netmem)->pp = pool;
|
|
}
|
|
|
|
static inline void netmem_set_dma_addr(netmem_ref netmem,
|
|
unsigned long dma_addr)
|
|
{
|
|
__netmem_clear_lsb(netmem)->dma_addr = dma_addr;
|
|
}
|
|
#endif
|