Subject: Re: [PATCH v5 bpf 07/11] intel: xsk: initialize skb_frag_t::bv_offset in ZC drivers

From: Maciej Fijalkowski <[email-masked]>
Date: Wed, 24 Jan 2024 17:21:42 +0100

On Wed, Jan 24, 2024 at 09:44:03AM +0100, Magnus Karlsson wrote:
> On Mon, 22 Jan 2024 at 23:17, Maciej Fijalkowski
> <[email-masked]> wrote:
> >
> > Ice and i40e ZC drivers currently set offset of a frag within
> > skb_shared_info to 0, wchih is incorrect. xdp_buffs that come from
> 
> Is "wchih" Polish? Just kidding with you ;-)!

Huh, I was missing codespell on my system. There's another one on other
commit:

Commit ab19f322eda5 ("xsk: fix usage of multi-buffer BPF helpers for ZC
XDP")
-----------------------------------------------------------------------------
WARNING: 'appriopriate' may be misspelled - perhaps 'appropriate'?
#64:
appriopriate xsk helpers to do such node operation and use them
^^^^^^^^^^^^

so I'll address those two. Thanks!

> 
> > xsk_buff_pool always have 256 bytes of a headroom, so they need to be
> > taken into account to retrieve xdp_buff::data via skb_frag_address().
> > Otherwise, bpf_xdp_frags_increase_tail() would be starting its job from
> > xdp_buff::data_hard_start which would result in overwriting existing
> > payload.
> 
> Acked-by: Magnus Karlsson <[email-masked]>
> 
> > Fixes: 1c9ba9c14658 ("i40e: xsk: add RX multi-buffer support")
> > Fixes: 1bbc04de607b ("ice: xsk: add RX multi-buffer support")
> > Signed-off-by: Maciej Fijalkowski <[email-masked]>
> > ---
> >  drivers/net/ethernet/intel/i40e/i40e_xsk.c | 3 ++-
> >  drivers/net/ethernet/intel/ice/ice_xsk.c   | 3 ++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> > index fede0bb3e047..65f38a57b3df 100644
> > --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> > +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> > @@ -414,7 +414,8 @@ i40e_add_xsk_frag(struct i40e_ring *rx_ring, struct xdp_buff *first,
> >         }
> >
> >         __skb_fill_page_desc_noacc(sinfo, sinfo->nr_frags++,
> > -                                  virt_to_page(xdp->data_hard_start), 0, size);
> > +                                  virt_to_page(xdp->data_hard_start),
> > +                                  XDP_PACKET_HEADROOM, size);
> >         sinfo->xdp_frags_size += size;
> >         xsk_buff_add_frag(xdp);
> >
> > diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
> > index d9073a618ad6..8b81a1677045 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_xsk.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
> > @@ -825,7 +825,8 @@ ice_add_xsk_frag(struct ice_rx_ring *rx_ring, struct xdp_buff *first,
> >         }
> >
> >         __skb_fill_page_desc_noacc(sinfo, sinfo->nr_frags++,
> > -                                  virt_to_page(xdp->data_hard_start), 0, size);
> > +                                  virt_to_page(xdp->data_hard_start),
> > +                                  XDP_PACKET_HEADROOM, size);
> >         sinfo->xdp_frags_size += size;
> >         xsk_buff_add_frag(xdp);
> >
> > --
> > 2.34.1
> >
> >