Subject: Re: [PATCH bpf-next v7 08/18] ice: Support XDP hints in AF_XDP ZC mode

From: Maciej Fijalkowski <[email-masked]>
Date: Thu, 16 Nov 2023 16:01:53 +0100

On Thu, Nov 16, 2023 at 04:01:01AM +0100, Larysa Zaremba wrote:
> On Thu, Nov 16, 2023 at 01:49:36PM +0100, Maciej Fijalkowski wrote:
> > On Wed, Nov 15, 2023 at 06:52:50PM +0100, Larysa Zaremba wrote:
> > > In AF_XDP ZC, xdp_buff is not stored on ring,
> > > instead it is provided by xsk_buff_pool.
> > > Space for metadata sources right after such buffers was already reserved
> > > in commit 94ecc5ca4dbf ("xsk: Add cb area to struct xdp_buff_xsk").
> > > 
> > > Some things (such as pointer to packet context) do not change on a
> > > per-packet basis, so they can be set at the same time as RX queue info.
> > > On the other hand, RX descriptor is unique for each packet, but is already
> > > known when setting DMA addresses. This minimizes performance impact of
> > > hints on regular packet processing.
> > > 
> > > Update AF_XDP ZC packet processing to support XDP hints.
> > > 
> > > Co-developed-by: Maciej Fijalkowski <[email-masked]>
> > > Signed-off-by: Maciej Fijalkowski <[email-masked]>
> > > Signed-off-by: Larysa Zaremba <[email-masked]>
> > > ---
> > >  drivers/net/ethernet/intel/ice/ice_base.c | 13 +++++++++++++
> > >  drivers/net/ethernet/intel/ice/ice_xsk.c  | 17 +++++++++++------
> > >  2 files changed, 24 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
> > > index 2d83f3c029e7..d3396c1c87a9 100644
> > > --- a/drivers/net/ethernet/intel/ice/ice_base.c
> > > +++ b/drivers/net/ethernet/intel/ice/ice_base.c
> > > @@ -519,6 +519,18 @@ static int ice_setup_rx_ctx(struct ice_rx_ring *ring)
> > >  	return 0;
> > >  }
> > >  
> > > +static void ice_xsk_pool_fill_cb(struct ice_rx_ring *ring)
> > > +{
> > > +	void *ctx_ptr = &ring->pkt_ctx;
> > > +	struct xsk_cb_desc desc = {};
> > > +
> > > +	desc.src = &ctx_ptr;
> > > +	desc.off = offsetof(struct ice_xdp_buff, pkt_ctx) -
> > > +		   sizeof(struct xdp_buff);
> > 
> > Took me a while to figure out this offset calculation:D
> >
> 
> Do you have a suggestion, how to make it easier to understand?
>  

Not really, thought about moving the xdp_buff size subtraction to
xp_fill_cb but that would limit its usage. Let us keep it this way, I was
just probably being slow.