* marvell/octeontx2: XDP vs skb headroom reservation
@ 2025-10-02 11:46 Jakub Sitnicki
2025-10-03 10:40 ` [EXTERNAL] " Geethasowjanya Akula
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Sitnicki @ 2025-10-02 11:46 UTC (permalink / raw)
To: Sunil Goutham, Geetha sowjanya, Subbaraya Sundeep, hariprasad,
Bharat Bhushan
Cc: netdev
Hi,
I'm auditing calls to skb_metadata_set() in drivers and something seems
off in oceontx2. I may be completely misreading the code. I'm a total
stranger to that driver.
It would seem that there is a difference between the amount of headroom
that the driver reserves for the XDP buffer vs the skb that is built
from on that buffer, while the two should match.
In the receive handler we have:
otx2_rcv_pkt_handler
otx2_xdp_rcv_pkt_handler if pfvf->xdp_prog
xdp_prepare_buff(..., OTX2_HEAD_ROOM, ...)
where OTX2_HEAD_ROOM = OTX2_ALIGN = 128
skb = napi_get_frags
napi_alloc_skb
skb_reserve(NET_SKB_PAD + NET_IP_ALIGN)
where NET_SKB_PAD = 64, NET_IP_ALIGN = 0 on x86
napi_gro_frags
There are no other calls to skb_reserve there, so we seem to have a
mismatch. 128B of headroom in XDP buff, and only 64B of headroom in skb
head.
Again, I could be totally wrong about this, I'm not familiar with the
driver, but I thought you might want to double check this.
Thanks,
-jkbs
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [EXTERNAL] marvell/octeontx2: XDP vs skb headroom reservation
2025-10-02 11:46 marvell/octeontx2: XDP vs skb headroom reservation Jakub Sitnicki
@ 2025-10-03 10:40 ` Geethasowjanya Akula
0 siblings, 0 replies; 2+ messages in thread
From: Geethasowjanya Akula @ 2025-10-03 10:40 UTC (permalink / raw)
To: Jakub Sitnicki, Sunil Kovvuri Goutham, Subbaraya Sundeep Bhatta,
Hariprasad Kelam, Bharat Bhushan
Cc: netdev@vger.kernel.org
Hi,
>-----Original Message-----
>From: Jakub Sitnicki <jakub@cloudflare.com>
>Sent: Thursday, October 2, 2025 5:16 PM
>To: Sunil Kovvuri Goutham <sgoutham@marvell.com>; Geethasowjanya Akula
><gakula@marvell.com>; Subbaraya Sundeep Bhatta <sbhatta@marvell.com>;
>Hariprasad Kelam <hkelam@marvell.com>; Bharat Bhushan
><bbhushan2@marvell.com>
>Cc: netdev@vger.kernel.org
>Subject: [EXTERNAL] marvell/octeontx2: XDP vs skb headroom reservation
>
>Hi,
>
>I'm auditing calls to skb_metadata_set() in drivers and something seems off in
>oceontx2. I may be completely misreading the code. I'm a total stranger to that
>driver.
>
>It would seem that there is a difference between the amount of headroom that
>the driver reserves for the XDP buffer vs the skb that is built from on that
>buffer, while the two should match.
>
>In the receive handler we have:
>
>otx2_rcv_pkt_handler
> otx2_xdp_rcv_pkt_handler if pfvf->xdp_prog
> xdp_prepare_buff(..., OTX2_HEAD_ROOM, ...)
> where OTX2_HEAD_ROOM = OTX2_ALIGN = 128
> skb = napi_get_frags
> napi_alloc_skb
> skb_reserve(NET_SKB_PAD + NET_IP_ALIGN)
> where NET_SKB_PAD = 64, NET_IP_ALIGN = 0 on x86
> napi_gro_frags
>
>There are no other calls to skb_reserve there, so we seem to have a mismatch.
>128B of headroom in XDP buff, and only 64B of headroom in skb head.
>
>Again, I could be totally wrong about this, I'm not familiar with the driver, but I
>thought you might want to double check this.
>
The otx2 netdev driver calculates the receive buffer size to accommodate the full network
packet as follows:
hw.buf_len = mtu + OTX2_ETH_HLEN + OTX2_HW_TIMESTAMP_LEN;
In addition, it reserves OTX2_HEAD_ROOM (128 bytes). The hardware actually copies
the packet starting at (u64*)bufptr + OTX2_HEAD_ROOM. This means the SKB has
128 bytes of headroom available, which is especially useful in the XDP case for adding any extra headers.
static int otx2_get_rbuf_size(struct otx2_nic *pf, int mtu)
{
int frame_size;
int total_size;
int rbuf_size;
if (pf->hw.rbuf_len)
return ALIGN(pf->hw.rbuf_len, OTX2_ALIGN) + OTX2_HEAD_ROOM;
Thanks,
Geetha.
>Thanks,
>-jkbs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-03 10:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-02 11:46 marvell/octeontx2: XDP vs skb headroom reservation Jakub Sitnicki
2025-10-03 10:40 ` [EXTERNAL] " Geethasowjanya Akula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).