Lines Matching defs:netmem
57 /* netmem */
70 static inline bool netmem_is_net_iov(const netmem_ref netmem)
72 return (__force unsigned long)netmem & NET_IOV;
76 * __netmem_to_page - unsafely get pointer to the &page backing @netmem
77 * @netmem: netmem reference to convert
79 * Unsafe version of netmem_to_page(). When @netmem is always page-backed,
81 * object code (no check for the LSB, no WARN). When @netmem points to IOV,
84 * Return: pointer to the &page (garbage if @netmem is not page-backed).
86 static inline struct page *__netmem_to_page(netmem_ref netmem)
88 return (__force struct page *)netmem;
94 static inline struct page *netmem_to_page(netmem_ref netmem)
96 if (WARN_ON_ONCE(netmem_is_net_iov(netmem)))
99 return __netmem_to_page(netmem);
102 static inline struct net_iov *netmem_to_net_iov(netmem_ref netmem)
104 if (netmem_is_net_iov(netmem))
105 return (struct net_iov *)((__force unsigned long)netmem &
123 * virt_to_netmem - convert virtual memory pointer to a netmem reference
126 * Return: netmem reference to the &page backing this virtual address.
133 static inline int netmem_ref_count(netmem_ref netmem)
138 if (netmem_is_net_iov(netmem))
141 return page_ref_count(netmem_to_page(netmem));
144 static inline unsigned long netmem_pfn_trace(netmem_ref netmem)
146 if (netmem_is_net_iov(netmem))
149 return page_to_pfn(netmem_to_page(netmem));
152 static inline struct net_iov *__netmem_clear_lsb(netmem_ref netmem)
154 return (struct net_iov *)((__force unsigned long)netmem & ~NET_IOV);
158 * __netmem_get_pp - unsafely get pointer to the &page_pool backing @netmem
159 * @netmem: netmem reference to get the pointer from
161 * Unsafe version of netmem_get_pp(). When @netmem is always page-backed,
163 * object code (avoids clearing the LSB). When @netmem points to IOV,
166 * Return: pointer to the &page_pool (garbage if @netmem is not page-backed).
168 static inline struct page_pool *__netmem_get_pp(netmem_ref netmem)
170 return __netmem_to_page(netmem)->pp;
173 static inline struct page_pool *netmem_get_pp(netmem_ref netmem)
175 return __netmem_clear_lsb(netmem)->pp;
178 static inline atomic_long_t *netmem_get_pp_ref_count_ref(netmem_ref netmem)
180 return &__netmem_clear_lsb(netmem)->pp_ref_count;
183 static inline bool netmem_is_pref_nid(netmem_ref netmem, int pref_nid)
189 if (netmem_is_net_iov(netmem))
192 return page_to_nid(netmem_to_page(netmem)) == pref_nid;
195 static inline netmem_ref netmem_compound_head(netmem_ref netmem)
198 if (netmem_is_net_iov(netmem))
199 return netmem;
201 return page_to_netmem(compound_head(netmem_to_page(netmem)));
205 * __netmem_address - unsafely get pointer to the memory backing @netmem
206 * @netmem: netmem reference to get the pointer for
208 * Unsafe version of netmem_address(). When @netmem is always page-backed,
210 * object code (no check for the LSB). When @netmem points to IOV, provokes
213 * Return: pointer to the memory (garbage if @netmem is not page-backed).
215 static inline void *__netmem_address(netmem_ref netmem)
217 return page_address(__netmem_to_page(netmem));
220 static inline void *netmem_address(netmem_ref netmem)
222 if (netmem_is_net_iov(netmem))
225 return __netmem_address(netmem);
229 * netmem_is_pfmemalloc - check if @netmem was allocated under memory pressure
230 * @netmem: netmem reference to check
232 * Return: true if @netmem is page-backed and the page was allocated under
235 static inline bool netmem_is_pfmemalloc(netmem_ref netmem)
237 if (netmem_is_net_iov(netmem))
240 return page_is_pfmemalloc(netmem_to_page(netmem));
243 static inline unsigned long netmem_get_dma_addr(netmem_ref netmem)
245 return __netmem_clear_lsb(netmem)->dma_addr;