This source file includes following definitions.
- page_pool_dev_alloc_pages
- page_pool_get_dma_dir
- page_pool_destroy
- page_pool_use_xdp_mem
- page_pool_put_page
- page_pool_recycle_direct
- page_pool_release_page
- page_pool_get_dma_addr
- is_page_pool_compiled_in
- page_pool_put
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #ifndef _NET_PAGE_POOL_H
31 #define _NET_PAGE_POOL_H
32
33 #include <linux/mm.h>
34 #include <linux/ptr_ring.h>
35 #include <linux/dma-direction.h>
36
37 #define PP_FLAG_DMA_MAP 1
38 #define PP_FLAG_ALL PP_FLAG_DMA_MAP
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 #define PP_ALLOC_CACHE_SIZE 128
55 #define PP_ALLOC_CACHE_REFILL 64
56 struct pp_alloc_cache {
57 u32 count;
58 void *cache[PP_ALLOC_CACHE_SIZE];
59 };
60
61 struct page_pool_params {
62 unsigned int flags;
63 unsigned int order;
64 unsigned int pool_size;
65 int nid;
66 struct device *dev;
67 enum dma_data_direction dma_dir;
68 };
69
70 struct page_pool {
71 struct page_pool_params p;
72
73 struct delayed_work release_dw;
74 void (*disconnect)(void *);
75 unsigned long defer_start;
76 unsigned long defer_warn;
77
78 u32 pages_state_hold_cnt;
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 struct pp_alloc_cache alloc ____cacheline_aligned_in_smp;
94
95
96
97
98
99
100
101
102
103
104
105
106 struct ptr_ring ring;
107
108 atomic_t pages_state_release_cnt;
109
110
111
112
113
114 refcount_t user_cnt;
115 };
116
117 struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp);
118
119 static inline struct page *page_pool_dev_alloc_pages(struct page_pool *pool)
120 {
121 gfp_t gfp = (GFP_ATOMIC | __GFP_NOWARN);
122
123 return page_pool_alloc_pages(pool, gfp);
124 }
125
126
127
128
129 static
130 inline enum dma_data_direction page_pool_get_dma_dir(struct page_pool *pool)
131 {
132 return pool->p.dma_dir;
133 }
134
135 struct page_pool *page_pool_create(const struct page_pool_params *params);
136
137 #ifdef CONFIG_PAGE_POOL
138 void page_pool_destroy(struct page_pool *pool);
139 void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *));
140 #else
141 static inline void page_pool_destroy(struct page_pool *pool)
142 {
143 }
144
145 static inline void page_pool_use_xdp_mem(struct page_pool *pool,
146 void (*disconnect)(void *))
147 {
148 }
149 #endif
150
151
152 void __page_pool_put_page(struct page_pool *pool,
153 struct page *page, bool allow_direct);
154
155 static inline void page_pool_put_page(struct page_pool *pool,
156 struct page *page, bool allow_direct)
157 {
158
159
160
161 #ifdef CONFIG_PAGE_POOL
162 __page_pool_put_page(pool, page, allow_direct);
163 #endif
164 }
165
166 static inline void page_pool_recycle_direct(struct page_pool *pool,
167 struct page *page)
168 {
169 __page_pool_put_page(pool, page, true);
170 }
171
172
173
174
175
176
177 void page_pool_unmap_page(struct page_pool *pool, struct page *page);
178 static inline void page_pool_release_page(struct page_pool *pool,
179 struct page *page)
180 {
181 #ifdef CONFIG_PAGE_POOL
182 page_pool_unmap_page(pool, page);
183 #endif
184 }
185
186 static inline dma_addr_t page_pool_get_dma_addr(struct page *page)
187 {
188 return page->dma_addr;
189 }
190
191 static inline bool is_page_pool_compiled_in(void)
192 {
193 #ifdef CONFIG_PAGE_POOL
194 return true;
195 #else
196 return false;
197 #endif
198 }
199
200 static inline bool page_pool_put(struct page_pool *pool)
201 {
202 return refcount_dec_and_test(&pool->user_cnt);
203 }
204
205 #endif