lkml.org 
[lkml]   [2022]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH net-next 1/5] net: lan966x: Add XDP_PACKET_HEADROOM
Date
From: Horatiu Vultur <horatiu.vultur@microchip.com>
Date: Sun, 13 Nov 2022 12:15:55 +0100

> Update the page_pool params to allocate XDP_PACKET_HEADROOM space as
> headroom for all received frames.
> This is needed for when the XDP_TX and XDP_REDIRECT are implemented.
>
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---

[...]

> @@ -466,7 +472,8 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx,
>
> skb_mark_for_recycle(skb);
>
> - skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status));
> + skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status) + XDP_PACKET_HEADROOM);
> + skb_pull(skb, XDP_PACKET_HEADROOM);

These two must be:

+ skb_reserve(skb, XDP_PACKET_HEADROOM);
skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status));

i.e. you only need to add reserve, and that's it. It's not only
faster, but also moves ::tail, which is essential.

>
> lan966x_ifh_get_timestamp(skb->data, &timestamp);
>

[...]

> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c
> @@ -44,8 +44,9 @@ int lan966x_xdp_run(struct lan966x_port *port, struct page *page, u32 data_len)
>
> xdp_init_buff(&xdp, PAGE_SIZE << lan966x->rx.page_order,
> &port->xdp_rxq);
> - xdp_prepare_buff(&xdp, page_address(page), IFH_LEN_BYTES,
> - data_len - IFH_LEN_BYTES, false);
> + xdp_prepare_buff(&xdp, page_address(page),
> + IFH_LEN_BYTES + XDP_PACKET_HEADROOM,
> + data_len - IFH_LEN_BYTES - XDP_PACKET_HEADROOM, false);

Are you sure you need to substract %XDP_PACKET_HEADROOM from
@data_len? I think @data_len is the frame length, so headroom is not
included?

> act = bpf_prog_run_xdp(xdp_prog, &xdp);
> switch (act) {
> case XDP_PASS:
> --
> 2.38.0

Thanks,
Olek

\
 
 \ /
  Last update: 2022-11-14 15:17    [W:0.359 / U:0.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site