Lines Matching refs:netmem
156 /* netmem */
168 static inline bool netmem_is_net_iov(const netmem_ref netmem)
170 return (__force unsigned long)netmem & NET_IOV;
174 * __netmem_to_page - unsafely get pointer to the &page backing @netmem
175 * @netmem: netmem reference to convert
177 * Unsafe version of netmem_to_page(). When @netmem is always page-backed,
179 * object code (no check for the LSB, no WARN). When @netmem points to IOV,
182 * Return: pointer to the &page (garbage if @netmem is not page-backed).
184 static inline struct page *__netmem_to_page(netmem_ref netmem)
186 return (__force struct page *)netmem;
189 static inline struct page *netmem_to_page(netmem_ref netmem)
191 if (WARN_ON_ONCE(netmem_is_net_iov(netmem)))
194 return __netmem_to_page(netmem);
197 static inline struct net_iov *netmem_to_net_iov(netmem_ref netmem)
199 if (netmem_is_net_iov(netmem))
200 return (struct net_iov *)((__force unsigned long)netmem &
217 * virt_to_netmem - convert virtual memory pointer to a netmem reference
220 * Return: netmem reference to the &page backing this virtual address.
227 static inline int netmem_ref_count(netmem_ref netmem)
232 if (netmem_is_net_iov(netmem))
235 return page_ref_count(netmem_to_page(netmem));
238 static inline unsigned long netmem_pfn_trace(netmem_ref netmem)
240 if (netmem_is_net_iov(netmem))
243 return page_to_pfn(netmem_to_page(netmem));
265 * @netmem
266 * @netmem: netmem reference to convert
268 * Unsafe version that can be used only when @netmem is always backed by
270 * check for the LSB, no WARN). When @netmem points to IOV, provokes
273 * Return: pointer to the &netmem_desc (garbage if @netmem is not backed
276 static inline struct netmem_desc *__netmem_to_nmdesc(netmem_ref netmem)
278 return (__force struct netmem_desc *)netmem;
283 * @netmem: netmem reference to get netmem_desc.
291 static inline struct netmem_desc *netmem_to_nmdesc(netmem_ref netmem)
293 void *p = (void *)((__force unsigned long)netmem & ~NET_IOV);
295 if (netmem_is_net_iov(netmem))
302 * __netmem_get_pp - unsafely get pointer to the &page_pool backing @netmem
303 * @netmem: netmem reference to get the pointer from
305 * Unsafe version of netmem_get_pp(). When @netmem is always page-backed,
307 * object code (avoids clearing the LSB). When @netmem points to IOV,
310 * Return: pointer to the &page_pool (garbage if @netmem is not page-backed).
312 static inline struct page_pool *__netmem_get_pp(netmem_ref netmem)
314 return __netmem_to_nmdesc(netmem)->pp;
317 static inline struct page_pool *netmem_get_pp(netmem_ref netmem)
319 return netmem_to_nmdesc(netmem)->pp;
322 static inline atomic_long_t *netmem_get_pp_ref_count_ref(netmem_ref netmem)
324 return &netmem_to_nmdesc(netmem)->pp_ref_count;
327 static inline bool netmem_is_pref_nid(netmem_ref netmem, int pref_nid)
333 if (netmem_is_net_iov(netmem))
336 return page_to_nid(netmem_to_page(netmem)) == pref_nid;
339 static inline netmem_ref netmem_compound_head(netmem_ref netmem)
342 if (netmem_is_net_iov(netmem))
343 return netmem;
345 return page_to_netmem(compound_head(netmem_to_page(netmem)));
349 * __netmem_address - unsafely get pointer to the memory backing @netmem
350 * @netmem: netmem reference to get the pointer for
352 * Unsafe version of netmem_address(). When @netmem is always page-backed,
354 * object code (no check for the LSB). When @netmem points to IOV, provokes
357 * Return: pointer to the memory (garbage if @netmem is not page-backed).
359 static inline void *__netmem_address(netmem_ref netmem)
361 return page_address(__netmem_to_page(netmem));
364 static inline void *netmem_address(netmem_ref netmem)
366 if (netmem_is_net_iov(netmem))
369 return __netmem_address(netmem);
373 * netmem_is_pfmemalloc - check if @netmem was allocated under memory pressure
374 * @netmem: netmem reference to check
376 * Return: true if @netmem is page-backed and the page was allocated under
379 static inline bool netmem_is_pfmemalloc(netmem_ref netmem)
381 if (netmem_is_net_iov(netmem))
384 return page_is_pfmemalloc(netmem_to_page(netmem));
387 static inline unsigned long netmem_get_dma_addr(netmem_ref netmem)
389 return netmem_to_nmdesc(netmem)->dma_addr;
392 void get_netmem(netmem_ref netmem);
393 void put_netmem(netmem_ref netmem);