Commit ed7a58cb authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Alexei Starovoitov

net: marvell: rely on xdp_update_skb_shared_info utility routine

Rely on xdp_update_skb_shared_info routine in order to avoid
resetting frags array in skb_shared_info structure building
the skb in mvneta_swbm_build_skb(). Frags array is expected to
be initialized by the receiving driver building the xdp_buff
and here we just need to update memory metadata.
Acked-by: default avatarToke Hoiland-Jorgensen <toke@redhat.com>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/e0dad97f5d02b13f189f99f1e5bc8e61bef73412.1642758637.git.lorenzo@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent d65a1906
...@@ -2332,8 +2332,12 @@ mvneta_swbm_add_rx_fragment(struct mvneta_port *pp, ...@@ -2332,8 +2332,12 @@ mvneta_swbm_add_rx_fragment(struct mvneta_port *pp,
skb_frag_size_set(frag, data_len); skb_frag_size_set(frag, data_len);
__skb_frag_set_page(frag, page); __skb_frag_set_page(frag, page);
if (!xdp_buff_has_frags(xdp)) if (!xdp_buff_has_frags(xdp)) {
sinfo->xdp_frags_size = *size;
xdp_buff_set_frags_flag(xdp); xdp_buff_set_frags_flag(xdp);
}
if (page_is_pfmemalloc(page))
xdp_buff_set_frag_pfmemalloc(xdp);
} else { } else {
page_pool_put_full_page(rxq->page_pool, page, true); page_pool_put_full_page(rxq->page_pool, page, true);
} }
...@@ -2347,7 +2351,6 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct page_pool *pool, ...@@ -2347,7 +2351,6 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct page_pool *pool,
struct skb_shared_info *sinfo = xdp_get_shared_info_from_buff(xdp); struct skb_shared_info *sinfo = xdp_get_shared_info_from_buff(xdp);
struct sk_buff *skb; struct sk_buff *skb;
u8 num_frags; u8 num_frags;
int i;
if (unlikely(xdp_buff_has_frags(xdp))) if (unlikely(xdp_buff_has_frags(xdp)))
num_frags = sinfo->nr_frags; num_frags = sinfo->nr_frags;
...@@ -2362,18 +2365,12 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct page_pool *pool, ...@@ -2362,18 +2365,12 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct page_pool *pool,
skb_put(skb, xdp->data_end - xdp->data); skb_put(skb, xdp->data_end - xdp->data);
skb->ip_summed = mvneta_rx_csum(pp, desc_status); skb->ip_summed = mvneta_rx_csum(pp, desc_status);
if (likely(!xdp_buff_has_frags(xdp))) if (unlikely(xdp_buff_has_frags(xdp)))
goto out; xdp_update_skb_shared_info(skb, num_frags,
sinfo->xdp_frags_size,
for (i = 0; i < num_frags; i++) { num_frags * xdp->frame_sz,
skb_frag_t *frag = &sinfo->frags[i]; xdp_buff_is_frag_pfmemalloc(xdp));
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
skb_frag_page(frag), skb_frag_off(frag),
skb_frag_size(frag), PAGE_SIZE);
}
out:
return skb; return skb;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment