bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: Lorenzo Bianconi <lorenzo@kernel.org>,
	bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, ast@kernel.org,
	daniel@iogearbox.net, brouer@redhat.com,
	lorenzo.bianconi@redhat.com, alexander.duyck@gmail.com,
	maciej.fijalkowski@intel.com
Subject: Re: [PATCH v2 bpf-next 2/2] net: xdp: introduce xdp_prepare_buff utility routine
Date: Fri, 11 Dec 2020 17:00:52 -0800	[thread overview]
Message-ID: <59bc3e140cfb859bb8451a1e87da5125b956d778.camel@kernel.org> (raw)
In-Reply-To: <afc242ec96097ae8318a1ba2819aa2daa5e56a51.1607714335.git.lorenzo@kernel.org>

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@kernel.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;



  reply	other threads:[~2020-12-12  1:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 19:28 [PATCH v2 bpf-next 0/2] introduce xdp_init_buff/xdp_prepare_buff Lorenzo Bianconi
2020-12-11 19:28 ` [PATCH v2 bpf-next 1/2] net: xdp: introduce xdp_init_buff utility routine Lorenzo Bianconi
2020-12-11 19:28 ` [PATCH v2 bpf-next 2/2] net: xdp: introduce xdp_prepare_buff " Lorenzo Bianconi
2020-12-12  1:00   ` Saeed Mahameed [this message]
2020-12-12 14:34     ` Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59bc3e140cfb859bb8451a1e87da5125b956d778.camel@kernel.org \
    --to=saeed@kernel.org \
    --cc=alexander.duyck@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).