[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230111042214.907030-25-willy@infradead.org>
Date: Wed, 11 Jan 2023 04:22:12 +0000
From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
To: Jesper Dangaard Brouer <hawk@...nel.org>,
Ilias Apalodimas <ilias.apalodimas@...aro.org>
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
netdev@...r.kernel.org, linux-mm@...ck.org,
Shakeel Butt <shakeelb@...gle.com>,
Jesse Brandeburg <jesse.brandeburg@...el.com>
Subject: [PATCH v3 24/26] mvneta: Convert to netmem
Use the netmem APIs instead of the page APIs. Improves type-safety.
Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@...el.com>
---
drivers/net/ethernet/marvell/mvneta.c | 48 +++++++++++++--------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index f8925cac61e4..6177d2ffd33c 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1931,15 +1931,15 @@ static int mvneta_rx_refill(struct mvneta_port *pp,
gfp_t gfp_mask)
{
dma_addr_t phys_addr;
- struct page *page;
+ struct netmem *nmem;
- page = page_pool_alloc_pages(rxq->page_pool,
+ nmem = page_pool_alloc_netmem(rxq->page_pool,
gfp_mask | __GFP_NOWARN);
- if (!page)
+ if (!nmem)
return -ENOMEM;
- phys_addr = page_pool_get_dma_addr(page) + pp->rx_offset_correction;
- mvneta_rx_desc_fill(rx_desc, phys_addr, page, rxq);
+ phys_addr = netmem_get_dma_addr(nmem) + pp->rx_offset_correction;
+ mvneta_rx_desc_fill(rx_desc, phys_addr, nmem, rxq);
return 0;
}
@@ -2006,7 +2006,7 @@ static void mvneta_rxq_drop_pkts(struct mvneta_port *pp,
if (!data || !(rx_desc->buf_phys_addr))
continue;
- page_pool_put_full_page(rxq->page_pool, data, false);
+ page_pool_put_full_netmem(rxq->page_pool, data, false);
}
if (xdp_rxq_info_is_reg(&rxq->xdp_rxq))
xdp_rxq_info_unreg(&rxq->xdp_rxq);
@@ -2072,11 +2072,11 @@ mvneta_xdp_put_buff(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
goto out;
for (i = 0; i < sinfo->nr_frags; i++)
- page_pool_put_full_page(rxq->page_pool,
- skb_frag_page(&sinfo->frags[i]), true);
+ page_pool_put_full_netmem(rxq->page_pool,
+ skb_frag_netmem(&sinfo->frags[i]), true);
out:
- page_pool_put_page(rxq->page_pool, virt_to_head_page(xdp->data),
+ page_pool_put_netmem(rxq->page_pool, virt_to_netmem(xdp->data),
sync_len, true);
}
@@ -2088,7 +2088,6 @@ mvneta_xdp_submit_frame(struct mvneta_port *pp, struct mvneta_tx_queue *txq,
struct device *dev = pp->dev->dev.parent;
struct mvneta_tx_desc *tx_desc;
int i, num_frames = 1;
- struct page *page;
if (unlikely(xdp_frame_has_frags(xdpf)))
num_frames += sinfo->nr_frags;
@@ -2123,9 +2122,10 @@ mvneta_xdp_submit_frame(struct mvneta_port *pp, struct mvneta_tx_queue *txq,
buf->type = MVNETA_TYPE_XDP_NDO;
} else {
- page = unlikely(frag) ? skb_frag_page(frag)
- : virt_to_page(xdpf->data);
- dma_addr = page_pool_get_dma_addr(page);
+ struct netmem *nmem = unlikely(frag) ?
+ skb_frag_netmem(frag) :
+ virt_to_netmem(xdpf->data);
+ dma_addr = netmem_get_dma_addr(nmem);
if (unlikely(frag))
dma_addr += skb_frag_off(frag);
else
@@ -2308,9 +2308,9 @@ mvneta_swbm_rx_frame(struct mvneta_port *pp,
struct mvneta_rx_desc *rx_desc,
struct mvneta_rx_queue *rxq,
struct xdp_buff *xdp, int *size,
- struct page *page)
+ struct netmem *nmem)
{
- unsigned char *data = page_address(page);
+ unsigned char *data = netmem_to_virt(nmem);
int data_len = -MVNETA_MH_SIZE, len;
struct net_device *dev = pp->dev;
enum dma_data_direction dma_dir;
@@ -2343,7 +2343,7 @@ mvneta_swbm_add_rx_fragment(struct mvneta_port *pp,
struct mvneta_rx_desc *rx_desc,
struct mvneta_rx_queue *rxq,
struct xdp_buff *xdp, int *size,
- struct page *page)
+ struct netmem *nmem)
{
struct skb_shared_info *sinfo = xdp_get_shared_info_from_buff(xdp);
struct net_device *dev = pp->dev;
@@ -2371,16 +2371,16 @@ mvneta_swbm_add_rx_fragment(struct mvneta_port *pp,
skb_frag_off_set(frag, pp->rx_offset_correction);
skb_frag_size_set(frag, data_len);
- __skb_frag_set_page(frag, page);
+ __skb_frag_set_netmem(frag, nmem);
if (!xdp_buff_has_frags(xdp)) {
sinfo->xdp_frags_size = *size;
xdp_buff_set_frags_flag(xdp);
}
- if (page_is_pfmemalloc(page))
+ if (netmem_is_pfmemalloc(nmem))
xdp_buff_set_frag_pfmemalloc(xdp);
} else {
- page_pool_put_full_page(rxq->page_pool, page, true);
+ page_pool_put_full_netmem(rxq->page_pool, nmem, true);
}
*size -= len;
}
@@ -2440,10 +2440,10 @@ static int mvneta_rx_swbm(struct napi_struct *napi,
struct mvneta_rx_desc *rx_desc = mvneta_rxq_next_desc_get(rxq);
u32 rx_status, index;
struct sk_buff *skb;
- struct page *page;
+ struct netmem *nmem;
index = rx_desc - rxq->descs;
- page = (struct page *)rxq->buf_virt_addr[index];
+ nmem = rxq->buf_virt_addr[index];
rx_status = rx_desc->status;
rx_proc++;
@@ -2461,17 +2461,17 @@ static int mvneta_rx_swbm(struct napi_struct *napi,
desc_status = rx_status;
mvneta_swbm_rx_frame(pp, rx_desc, rxq, &xdp_buf,
- &size, page);
+ &size, nmem);
} else {
if (unlikely(!xdp_buf.data_hard_start)) {
rx_desc->buf_phys_addr = 0;
- page_pool_put_full_page(rxq->page_pool, page,
+ page_pool_put_full_netmem(rxq->page_pool, nmem,
true);
goto next;
}
mvneta_swbm_add_rx_fragment(pp, rx_desc, rxq, &xdp_buf,
- &size, page);
+ &size, nmem);
} /* Middle or Last descriptor */
if (!(rx_status & MVNETA_RXD_LAST_DESC))
--
2.35.1
Powered by blists - more mailing lists