提交 07e13edb 编写于 作者: L Lorenzo Bianconi 提交者: David S. Miller

net: mvneta: get rid of huge dma sync in mvneta_rx_refill

Get rid of costly dma_sync_single_for_device in mvneta_rx_refill
since now the driver can let page_pool API to manage needed DMA
sync with a proper size.

- XDP_DROP DMA sync managed by mvneta driver:	~420Kpps
- XDP_DROP DMA sync managed by page_pool API:	~585Kpps
Tested-by: NMatteo Croce <mcroce@redhat.com>
Signed-off-by: NLorenzo Bianconi <lorenzo@kernel.org>
Acked-by: NJesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 e68bc756
...@@ -1846,7 +1846,6 @@ static int mvneta_rx_refill(struct mvneta_port *pp, ...@@ -1846,7 +1846,6 @@ static int mvneta_rx_refill(struct mvneta_port *pp,
struct mvneta_rx_queue *rxq, struct mvneta_rx_queue *rxq,
gfp_t gfp_mask) gfp_t gfp_mask)
{ {
enum dma_data_direction dma_dir;
dma_addr_t phys_addr; dma_addr_t phys_addr;
struct page *page; struct page *page;
...@@ -1856,9 +1855,6 @@ static int mvneta_rx_refill(struct mvneta_port *pp, ...@@ -1856,9 +1855,6 @@ static int mvneta_rx_refill(struct mvneta_port *pp,
return -ENOMEM; return -ENOMEM;
phys_addr = page_pool_get_dma_addr(page) + pp->rx_offset_correction; phys_addr = page_pool_get_dma_addr(page) + pp->rx_offset_correction;
dma_dir = page_pool_get_dma_dir(rxq->page_pool);
dma_sync_single_for_device(pp->dev->dev.parent, phys_addr,
MVNETA_MAX_RX_BUF_SIZE, dma_dir);
mvneta_rx_desc_fill(rx_desc, phys_addr, page, rxq); mvneta_rx_desc_fill(rx_desc, phys_addr, page, rxq);
return 0; return 0;
...@@ -2097,8 +2093,10 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq, ...@@ -2097,8 +2093,10 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
err = xdp_do_redirect(pp->dev, xdp, prog); err = xdp_do_redirect(pp->dev, xdp, prog);
if (err) { if (err) {
ret = MVNETA_XDP_DROPPED; ret = MVNETA_XDP_DROPPED;
page_pool_recycle_direct(rxq->page_pool, __page_pool_put_page(rxq->page_pool,
virt_to_head_page(xdp->data)); virt_to_head_page(xdp->data),
xdp->data_end - xdp->data_hard_start,
true);
} else { } else {
ret = MVNETA_XDP_REDIR; ret = MVNETA_XDP_REDIR;
} }
...@@ -2107,8 +2105,10 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq, ...@@ -2107,8 +2105,10 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
case XDP_TX: case XDP_TX:
ret = mvneta_xdp_xmit_back(pp, xdp); ret = mvneta_xdp_xmit_back(pp, xdp);
if (ret != MVNETA_XDP_TX) if (ret != MVNETA_XDP_TX)
page_pool_recycle_direct(rxq->page_pool, __page_pool_put_page(rxq->page_pool,
virt_to_head_page(xdp->data)); virt_to_head_page(xdp->data),
xdp->data_end - xdp->data_hard_start,
true);
break; break;
default: default:
bpf_warn_invalid_xdp_action(act); bpf_warn_invalid_xdp_action(act);
...@@ -2117,8 +2117,10 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq, ...@@ -2117,8 +2117,10 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
trace_xdp_exception(pp->dev, prog, act); trace_xdp_exception(pp->dev, prog, act);
/* fall through */ /* fall through */
case XDP_DROP: case XDP_DROP:
page_pool_recycle_direct(rxq->page_pool, __page_pool_put_page(rxq->page_pool,
virt_to_head_page(xdp->data)); virt_to_head_page(xdp->data),
xdp->data_end - xdp->data_hard_start,
true);
ret = MVNETA_XDP_DROPPED; ret = MVNETA_XDP_DROPPED;
break; break;
} }
...@@ -3067,11 +3069,13 @@ static int mvneta_create_page_pool(struct mvneta_port *pp, ...@@ -3067,11 +3069,13 @@ static int mvneta_create_page_pool(struct mvneta_port *pp,
struct bpf_prog *xdp_prog = READ_ONCE(pp->xdp_prog); struct bpf_prog *xdp_prog = READ_ONCE(pp->xdp_prog);
struct page_pool_params pp_params = { struct page_pool_params pp_params = {
.order = 0, .order = 0,
.flags = PP_FLAG_DMA_MAP, .flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV,
.pool_size = size, .pool_size = size,
.nid = cpu_to_node(0), .nid = cpu_to_node(0),
.dev = pp->dev->dev.parent, .dev = pp->dev->dev.parent,
.dma_dir = xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE, .dma_dir = xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE,
.offset = pp->rx_offset_correction,
.max_len = MVNETA_MAX_RX_BUF_SIZE,
}; };
int err; int err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册