Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH net] net: mvneta: fix dma sync size in mvneta_run_xdp
@ 2020-01-14 10:21 Lorenzo Bianconi
  2020-01-14 10:43 ` Jesper Dangaard Brouer
  2020-01-15  2:50 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2020-01-14 10:21 UTC (permalink / raw)
  To: netdev; +Cc: lorenzo.bianconi, davem, brouer, ilias.apalodimas, kuba

Page pool API will start syncing (if requested) starting from
page->dma_addr + pool->p.offset. Fix dma sync length in
mvneta_run_xdp since we do not need to account xdp headroom

Fixes: 07e13edbb6a6 ("net: mvneta: get rid of huge dma sync in mvneta_rx_refill")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/marvell/mvneta.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 71a872d46bc4..67ad8b8b127d 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2081,7 +2081,11 @@ static int
 mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
 	       struct bpf_prog *prog, struct xdp_buff *xdp)
 {
-	u32 ret, act = bpf_prog_run_xdp(prog, xdp);
+	unsigned int len;
+	u32 ret, act;
+
+	len = xdp->data_end - xdp->data_hard_start - pp->rx_offset_correction;
+	act = bpf_prog_run_xdp(prog, xdp);
 
 	switch (act) {
 	case XDP_PASS:
@@ -2094,9 +2098,8 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
 		if (err) {
 			ret = MVNETA_XDP_DROPPED;
 			__page_pool_put_page(rxq->page_pool,
-					virt_to_head_page(xdp->data),
-					xdp->data_end - xdp->data_hard_start,
-					true);
+					     virt_to_head_page(xdp->data),
+					     len, true);
 		} else {
 			ret = MVNETA_XDP_REDIR;
 		}
@@ -2106,9 +2109,8 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
 		ret = mvneta_xdp_xmit_back(pp, xdp);
 		if (ret != MVNETA_XDP_TX)
 			__page_pool_put_page(rxq->page_pool,
-					virt_to_head_page(xdp->data),
-					xdp->data_end - xdp->data_hard_start,
-					true);
+					     virt_to_head_page(xdp->data),
+					     len, true);
 		break;
 	default:
 		bpf_warn_invalid_xdp_action(act);
@@ -2119,8 +2121,7 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
 	case XDP_DROP:
 		__page_pool_put_page(rxq->page_pool,
 				     virt_to_head_page(xdp->data),
-				     xdp->data_end - xdp->data_hard_start,
-				     true);
+				     len, true);
 		ret = MVNETA_XDP_DROPPED;
 		break;
 	}
-- 
2.21.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: mvneta: fix dma sync size in mvneta_run_xdp
  2020-01-14 10:21 [PATCH net] net: mvneta: fix dma sync size in mvneta_run_xdp Lorenzo Bianconi
@ 2020-01-14 10:43 ` Jesper Dangaard Brouer
  2020-01-15  2:50 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2020-01-14 10:43 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: netdev, lorenzo.bianconi, davem, ilias.apalodimas, kuba, brouer

On Tue, 14 Jan 2020 11:21:16 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Page pool API will start syncing (if requested) starting from
> page->dma_addr + pool->p.offset. Fix dma sync length in
> mvneta_run_xdp since we do not need to account xdp headroom
> 
> Fixes: 07e13edbb6a6 ("net: mvneta: get rid of huge dma sync in mvneta_rx_refill")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Looks correct to me.

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: mvneta: fix dma sync size in mvneta_run_xdp
  2020-01-14 10:21 [PATCH net] net: mvneta: fix dma sync size in mvneta_run_xdp Lorenzo Bianconi
  2020-01-14 10:43 ` Jesper Dangaard Brouer
@ 2020-01-15  2:50 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-01-15  2:50 UTC (permalink / raw)
  To: lorenzo; +Cc: netdev, lorenzo.bianconi, brouer, ilias.apalodimas, kuba

From: Lorenzo Bianconi <lorenzo@kernel.org>
Date: Tue, 14 Jan 2020 11:21:16 +0100

> Page pool API will start syncing (if requested) starting from
> page->dma_addr + pool->p.offset. Fix dma sync length in
> mvneta_run_xdp since we do not need to account xdp headroom
> 
> Fixes: 07e13edbb6a6 ("net: mvneta: get rid of huge dma sync in mvneta_rx_refill")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 10:21 [PATCH net] net: mvneta: fix dma sync size in mvneta_run_xdp Lorenzo Bianconi
2020-01-14 10:43 ` Jesper Dangaard Brouer
2020-01-15  2:50 ` David Miller

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git