@@ -5226,7 +5226,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
/* XDP program may expand or reduce tail */
buf1_len = xdp.data_end - xdp.data;
- skb = napi_alloc_skb(&ch->rx_napi, buf1_len);
+ skb = napi_alloc_skb(&ch->rx_napi, ETH_HLEN);
if (!skb) {
priv->dev->stats.rx_dropped++;
count++;
@@ -5234,11 +5234,15 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
}
/* XDP program may adjust header */
- skb_copy_to_linear_data(skb, xdp.data, buf1_len);
- skb_put(skb, buf1_len);
+ memcpy(skb->data, xdp.data, ETH_HLEN);
+ skb_put(skb, ETH_HLEN);
+ skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
+ buf->page, buf->page_offset + ETH_HLEN,
+ buf1_len - ETH_HLEN,
+ priv->dma_buf_sz);
- /* Data payload copied into SKB, page ready for recycle */
- page_pool_recycle_direct(rx_q->page_pool, buf->page);
+ /* Data payload appended into SKB */
+ page_pool_release_page(rx_q->page_pool, buf->page);
buf->page = NULL;
} else if (buf1_len) {
dma_sync_single_for_cpu(priv->device, buf->addr,
Use skb_add_rx_frag() to reduce the memory copy for rx data, only copy ethernet header. Signed-off-by: David Wu <david.wu@rock-chips.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)