[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <dbde32b0c68a1ac5729e1c331438131bddbf3b04.1754929026.git.asml.silence@gmail.com>
Date: Mon, 11 Aug 2025 17:29:41 +0100
From: Pavel Begunkov <asml.silence@...il.com>
To: netdev@...r.kernel.org
Cc: Jakub Kicinski <kuba@...nel.org>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
davem@...emloft.net,
sdf@...ichev.me,
almasrymina@...gle.com,
dw@...idwei.uk,
Jesper Dangaard Brouer <hawk@...nel.org>,
Ilias Apalodimas <ilias.apalodimas@...aro.org>,
Byungchul Park <byungchul@...com>,
asml.silence@...il.com
Subject: [RFC net-next v1 4/6] net: convert page pool dma helpers to netmem_desc
struct netmem_desc has a clearly defined field that keeps dma_addr. Use
the new type in netmem and page_pool functions and get rid of a bunch of
now unnecessary accessor helpers.
While doing so, extract a helper for getting a dma address out of a
netmem desc, which can be used to optimise paths that already know the
underlying netmem type like memory providers.
Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
---
include/net/netmem.h | 5 -----
include/net/page_pool/helpers.h | 12 ++++++++++--
net/core/netmem_priv.h | 6 ------
net/core/page_pool_priv.h | 9 +++++----
4 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/include/net/netmem.h b/include/net/netmem.h
index d08797e40a7c..ca6d5d151acc 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -389,11 +389,6 @@ static inline bool netmem_is_pfmemalloc(netmem_ref netmem)
return page_is_pfmemalloc(netmem_to_page(netmem));
}
-static inline unsigned long netmem_get_dma_addr(netmem_ref netmem)
-{
- return netmem_to_nmdesc(netmem)->dma_addr;
-}
-
void get_netmem(netmem_ref netmem);
void put_netmem(netmem_ref netmem);
diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h
index db180626be06..a9774d582933 100644
--- a/include/net/page_pool/helpers.h
+++ b/include/net/page_pool/helpers.h
@@ -425,9 +425,10 @@ static inline void page_pool_free_va(struct page_pool *pool, void *va,
page_pool_put_page(pool, virt_to_head_page(va), -1, allow_direct);
}
-static inline dma_addr_t page_pool_get_dma_addr_netmem(netmem_ref netmem)
+static inline dma_addr_t
+page_pool_get_dma_addr_nmdesc(const struct netmem_desc *nmdesc)
{
- dma_addr_t ret = netmem_get_dma_addr(netmem);
+ dma_addr_t ret = nmdesc->dma_addr;
if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA)
ret <<= PAGE_SHIFT;
@@ -435,6 +436,13 @@ static inline dma_addr_t page_pool_get_dma_addr_netmem(netmem_ref netmem)
return ret;
}
+static inline dma_addr_t page_pool_get_dma_addr_netmem(netmem_ref netmem)
+{
+ const struct netmem_desc *desc = netmem_to_nmdesc(netmem);
+
+ return page_pool_get_dma_addr_nmdesc(desc);
+}
+
/**
* page_pool_get_dma_addr() - Retrieve the stored DMA address.
* @page: page allocated from a page pool
diff --git a/net/core/netmem_priv.h b/net/core/netmem_priv.h
index 23175cb2bd86..070faa136305 100644
--- a/net/core/netmem_priv.h
+++ b/net/core/netmem_priv.h
@@ -30,12 +30,6 @@ static inline void netmem_set_pp(netmem_ref netmem, struct page_pool *pool)
netmem_to_nmdesc(netmem)->pp = pool;
}
-static inline void netmem_set_dma_addr(netmem_ref netmem,
- unsigned long dma_addr)
-{
- netmem_to_nmdesc(netmem)->dma_addr = dma_addr;
-}
-
static inline unsigned long netmem_get_dma_index(netmem_ref netmem)
{
unsigned long magic;
diff --git a/net/core/page_pool_priv.h b/net/core/page_pool_priv.h
index 6445e7da5b82..fcf70cbc3e09 100644
--- a/net/core/page_pool_priv.h
+++ b/net/core/page_pool_priv.h
@@ -18,17 +18,18 @@ void page_pool_unlist(struct page_pool *pool);
static inline bool
page_pool_set_dma_addr_netmem(netmem_ref netmem, dma_addr_t addr)
{
+ struct netmem_desc *desc = netmem_to_nmdesc(netmem);
+
if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) {
- netmem_set_dma_addr(netmem, addr >> PAGE_SHIFT);
+ desc->dma_addr = addr >> PAGE_SHIFT;
/* We assume page alignment to shave off bottom bits,
* if this "compression" doesn't work we need to drop.
*/
- return addr != (dma_addr_t)netmem_get_dma_addr(netmem)
- << PAGE_SHIFT;
+ return addr != desc->dma_addr << PAGE_SHIFT;
}
- netmem_set_dma_addr(netmem, addr);
+ desc->dma_addr = addr;
return false;
}
--
2.49.0
Powered by blists - more mailing lists