xref: /linux/net/core/page_pool_priv.h (revision 06a130e42a5bfc84795464bff023bff4c16f58c5)
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 s32 page_pool_inflight(const struct page_pool *pool, bool strict);
11 
12 int page_pool_list(struct page_pool *pool);
13 void page_pool_detached(struct page_pool *pool);
14 void page_pool_unlist(struct page_pool *pool);
15 
16 static inline bool
17 page_pool_set_dma_addr_netmem(netmem_ref netmem, dma_addr_t addr)
18 {
19 	if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) {
20 		netmem_set_dma_addr(netmem, addr >> PAGE_SHIFT);
21 
22 		/* We assume page alignment to shave off bottom bits,
23 		 * if this "compression" doesn't work we need to drop.
24 		 */
25 		return addr != (dma_addr_t)netmem_get_dma_addr(netmem)
26 				       << PAGE_SHIFT;
27 	}
28 
29 	netmem_set_dma_addr(netmem, addr);
30 	return false;
31 }
32 
33 static inline bool page_pool_set_dma_addr(struct page *page, dma_addr_t addr)
34 {
35 	return page_pool_set_dma_addr_netmem(page_to_netmem(page), addr);
36 }
37 
38 #if defined(CONFIG_PAGE_POOL)
39 void page_pool_set_pp_info(struct page_pool *pool, netmem_ref netmem);
40 void page_pool_clear_pp_info(netmem_ref netmem);
41 int page_pool_check_memory_provider(struct net_device *dev,
42 				    struct netdev_rx_queue *rxq);
43 #else
44 static inline void page_pool_set_pp_info(struct page_pool *pool,
45 					 netmem_ref netmem)
46 {
47 }
48 static inline void page_pool_clear_pp_info(netmem_ref netmem)
49 {
50 }
51 static inline int page_pool_check_memory_provider(struct net_device *dev,
52 						  struct netdev_rx_queue *rxq)
53 {
54 	return 0;
55 }
56 #endif
57 
58 #endif
59