[RFC PATCH v3 01/20] net: page_pool: add ppiov mangling helper

David Wei
2023-12-19T21:04:06Z

From: Pavel Begunkov <asml.silence@gmail.com>

NOT FOR UPSTREAM

The final version will depend on how ppiov looks like, but add a
convenience helper for now.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: David Wei <dw@davidwei.uk>
---
include/net/page_pool/helpers.h | 5 +++++
net/core/page_pool.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h
index 95f4d579cbc4..92804c499833 100644
--- a/include/net/page_pool/helpers.h
+++ b/include/net/page_pool/helpers.h
@@ -86,6 +86,11 @@ static inline u64 *page_pool_ethtool_stats_get(u64 *data, void *stats)

/* page_pool_iov support */

+static inline struct page *page_pool_mangle_ppiov(struct page_pool_iov *ppiov)
+{
+ return (struct page *)((unsigned long)ppiov | PP_DEVMEM);
+}
+
static inline struct dmabuf_genpool_chunk_owner *
page_pool_iov_owner(const struct page_pool_iov *ppiov)
{
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index c0bc62ee77c6..38eff947f679 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -1074,7 +1074,7 @@ static struct page *mp_dmabuf_devmem_alloc_pages(struct page_pool *pool,
pool->pages_state_hold_cnt++;
trace_page_pool_state_hold(pool, (struct page *)ppiov,
pool->pages_state_hold_cnt);
- return (struct page *)((unsigned long)ppiov | PP_DEVMEM);
+ return page_pool_mangle_ppiov(ppiov);
}

static void mp_dmabuf_devmem_destroy(struct page_pool *pool)
--
2.39.3