With no better name for a variant of page_pool_recycle_direct() which
takes a netmem instead of a page, use _Generic() to allow it to take
either a page or a netmem argument. It's a bit ugly, but maybe not
the worst alternative?
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Jesse Brandeburg <redacted>
---
include/net/page_pool.h | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/net/page_pool.h b/include/net/page_pool.h
index e205eaed21a5..64ac397dcd9f 100644
--- a/include/net/page_pool.h
+++ b/include/net/page_pool.h
@@ -482,12 +482,22 @@ static inline void page_pool_put_full_page(struct page_pool *pool,
}
/* Same as above but the caller must guarantee safe context. e.g NAPI */
-static inline void page_pool_recycle_direct(struct page_pool *pool,
+static inline void __page_pool_recycle_direct(struct page_pool *pool,
+ struct netmem *nmem)
+{
+ page_pool_put_full_netmem(pool, nmem, true);
+}
+
+static inline void __page_pool_recycle_page_direct(struct page_pool *pool,
struct page *page)
{
- page_pool_put_full_page(pool, page, true);
+ page_pool_put_full_netmem(pool, page_netmem(page), true);
}
+#define page_pool_recycle_direct(pool, mem) _Generic((mem), \
+ struct netmem *: __page_pool_recycle_direct(pool, (struct netmem *)mem), \
+ struct page *: __page_pool_recycle_page_direct(pool, (struct page *)mem))
+
#define PAGE_POOL_DMA_USE_PP_FRAG_COUNT \
(sizeof(dma_addr_t) > sizeof(unsigned long))
--
2.35.1