| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
|
| 3 |
#ifndef __PAGE_POOL_PRIV_H |
| 4 |
#define __PAGE_POOL_PRIV_H |
| 5 |
|
| 6 |
#include <net/page_pool/helpers.h> |
| 7 |
|
| 8 |
#include "netmem_priv.h" |
| 9 |
|
| 10 |
extern struct mutex page_pools_lock; |
| 11 |
|
| 12 |
s32 page_pool_inflight(const struct page_pool *pool, bool strict); |
| 13 |
|
| 14 |
int page_pool_list(struct page_pool *pool); |
| 15 |
void page_pool_detached(struct page_pool *pool); |
| 16 |
void page_pool_unlist(struct page_pool *pool); |
| 17 |
|
| 18 |
static inline bool |
| 19 |
page_pool_set_dma_addr_netmem(netmem_ref netmem, dma_addr_t addr) |
| 20 |
{ |
| 21 |
if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) { |
| 22 |
netmem_set_dma_addr(netmem, addr >> PAGE_SHIFT); |
| 23 |
|
| 24 |
/* We assume page alignment to shave off bottom bits, |
| 25 |
* if this "compression" doesn't work we need to drop. |
| 26 |
*/ |
| 27 |
return addr != (dma_addr_t)netmem_get_dma_addr(netmem) |
| 28 |
<< PAGE_SHIFT; |
| 29 |
} |
| 30 |
|
| 31 |
netmem_set_dma_addr(netmem, addr); |
| 32 |
return false; |
| 33 |
} |
| 34 |
|
| 35 |
static inline bool page_pool_set_dma_addr(struct page *page, dma_addr_t addr) |
| 36 |
{ |
| 37 |
return page_pool_set_dma_addr_netmem(page_to_netmem(page), addr); |
| 38 |
} |
| 39 |
|
| 40 |
#if defined(CONFIG_PAGE_POOL) |
| 41 |
void page_pool_set_pp_info(struct page_pool *pool, netmem_ref netmem); |
| 42 |
void page_pool_clear_pp_info(netmem_ref netmem); |
| 43 |
int page_pool_check_memory_provider(struct net_device *dev, |
| 44 |
struct netdev_rx_queue *rxq); |
| 45 |
#else |
| 46 |
static inline void page_pool_set_pp_info(struct page_pool *pool, |
| 47 |
netmem_ref netmem) |
| 48 |
{ |
| 49 |
} |
| 50 |
static inline void page_pool_clear_pp_info(netmem_ref netmem) |
| 51 |
{ |
| 52 |
} |
| 53 |
static inline int page_pool_check_memory_provider(struct net_device *dev, |
| 54 |
struct netdev_rx_queue *rxq) |
| 55 |
{ |
| 56 |
return 0; |
| 57 |
} |
| 58 |
#endif |
| 59 |
|
| 60 |
#endif |