netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Jesper Dangaard Brouer <brouer@redhat.com>,
	Daniel Borkmann <borkmann@iogearbox.net>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC bpf-next PATCH] bpf: add comments to BPF ld/ldx sizes
Date: Wed, 17 Jan 2018 00:21:27 +0100	[thread overview]
Message-ID: <cc1bddb8-7be3-9969-a5e9-7e8682caee68@iogearbox.net> (raw)
In-Reply-To: <151610226596.29962.4661213256715212454.stgit@firesoul>

On 01/16/2018 12:31 PM, Jesper Dangaard Brouer wrote:
> Doc BPF ld/ldx size defines, as it help me understand the code in filter.c.
> 
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> ---
>  0 files changed
> 
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 395d261948de..4729d9a002d4 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -17,7 +17,7 @@
>  #define BPF_ALU64	0x07	/* alu mode in double word width */
>  
>  /* ld/ldx fields */
> -#define BPF_DW		0x18	/* double word */
> +#define BPF_DW		0x18	/* double word (64-bit) */
>  #define BPF_XADD	0xc0	/* exclusive add */
>  
>  /* alu/jmp fields */
> diff --git a/include/uapi/linux/bpf_common.h b/include/uapi/linux/bpf_common.h
> index 18be90725ab0..ee97668bdadb 100644
> --- a/include/uapi/linux/bpf_common.h
> +++ b/include/uapi/linux/bpf_common.h
> @@ -15,9 +15,10 @@
>  
>  /* ld/ldx fields */
>  #define BPF_SIZE(code)  ((code) & 0x18)
> -#define		BPF_W		0x00
> -#define		BPF_H		0x08
> -#define		BPF_B		0x10
> +#define		BPF_W		0x00 /* 32-bit */
> +#define		BPF_H		0x08 /* 16-bit */
> +#define		BPF_B		0x10 /*  8-bit */
> +/* eBPF		BPF_DW		0x18    64-bit */

Hmm, I don't really mind, but we do have it documented in:

  Documentation/networking/filter.txt +942

Feels like if we put a comment only on BPF_{B,H,W}, then we
might also want to document all the others such as ALU ops,
etc.

>  #define BPF_MODE(code)  ((code) & 0xe0)
>  #define		BPF_IMM		0x00
>  #define		BPF_ABS		0x20
> 

  reply	other threads:[~2018-01-16 23:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 11:31 [RFC bpf-next PATCH] bpf: add comments to BPF ld/ldx sizes Jesper Dangaard Brouer
2018-01-16 23:21 ` Daniel Borkmann [this message]
2018-01-17 10:41   ` Jesper Dangaard Brouer

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=cc1bddb8-7be3-9969-a5e9-7e8682caee68@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=alexei.starovoitov@gmail.com \
    --cc=borkmann@iogearbox.net \
    --cc=brouer@redhat.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).