[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sat, 12 Dec 2020 15:34:27 +0100
From: Lorenzo Bianconi <lorenzo@...nel.org>
To: Saeed Mahameed <saeed@...nel.org>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, davem@...emloft.net,
kuba@...nel.org, ast@...nel.org, daniel@...earbox.net,
brouer@...hat.com, lorenzo.bianconi@...hat.com,
alexander.duyck@...il.com, maciej.fijalkowski@...el.com
Subject: Re: [PATCH v2 bpf-next 2/2] net: xdp: introduce xdp_prepare_buff
utility routine
On Dec 11, Saeed Mahameed wrote:
> On Fri, 2020-12-11 at 20:28 +0100, Lorenzo Bianconi wrote:
> > Introduce xdp_prepare_buff utility routine to initialize per-
> > descriptor
> > xdp_buff fields (e.g. xdp_buff pointers). Rely on xdp_prepare_buff()
> > in
> > all XDP capable drivers.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@...nel.org>
> >
> ...
> > +static inline void
> > +xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
> > + int headroom, int data_len)
> > +{
> > + xdp->data_hard_start = hard_start;
> > + xdp->data = hard_start + headroom;
> > + xdp->data_end = xdp->data + data_len;
> > + xdp->data_meta = xdp->data;
>
> You might want to compute data = hard_start + headroom; on a local var,
> and hopefully gcc will put it into a register, then reuse it three
> times instead of the 2 xdp->data de-references you got at the end of
> the function.
>
> unsigned char *data = hard_start + headroom;
>
> xdp->data_hard_start = hard_start;
> xdp->data = data;
> xdp->data_end = data + data_len;
> xdp->data_meta = data;
ack, I will fix it in v3.
Regards,
Lorenzo
>
>
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists