bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: "Björn Töpel" <bjorn.topel@gmail.com>,
	ast@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: "Björn Töpel" <bjorn.topel@intel.com>,
	magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
	kuba@kernel.org, jonathan.lemon@gmail.com, maximmi@nvidia.com,
	davem@davemloft.net, hawk@kernel.org, john.fastabend@gmail.com,
	ciara.loftus@intel.com, weqaar.a.janjua@intel.com,
	andrii@kernel.org, "Marek Majtyka" <alardam@gmail.com>
Subject: Re: [PATCH bpf-next 3/3] libbpf, xsk: select AF_XDP BPF program based on kernel version
Date: Tue, 26 Jan 2021 00:12:34 +0100	[thread overview]
Message-ID: <cafcfa48-ecfd-1dbb-6b3a-220a52b6db16@iogearbox.net> (raw)
In-Reply-To: <20210122105351.11751-4-bjorn.topel@gmail.com>

On 1/22/21 11:53 AM, Björn Töpel wrote:
> From: Björn Töpel <bjorn.topel@intel.com>
> 
> Add detection for kernel version, and adapt the BPF program based on
> kernel support. This way, users will get the best possible performance
> from the BPF program.
> 
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
> Signed-off-by: Marek Majtyka  <alardam@gmail.com>
> ---
>   tools/lib/bpf/xsk.c | 82 +++++++++++++++++++++++++++++++++++++++++++--
>   1 file changed, 79 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
> index e3e41ceeb1bc..1df8c133a5bc 100644
> --- a/tools/lib/bpf/xsk.c
> +++ b/tools/lib/bpf/xsk.c
> @@ -46,6 +46,11 @@
>    #define PF_XDP AF_XDP
>   #endif
>   
> +enum xsk_prog {
> +	XSK_PROG_FALLBACK,
> +	XSK_PROG_REDIRECT_FLAGS,
> +};
> +
>   struct xsk_umem {
>   	struct xsk_ring_prod *fill_save;
>   	struct xsk_ring_cons *comp_save;
> @@ -351,6 +356,55 @@ int xsk_umem__create_v0_0_2(struct xsk_umem **umem_ptr, void *umem_area,
>   COMPAT_VERSION(xsk_umem__create_v0_0_2, xsk_umem__create, LIBBPF_0.0.2)
>   DEFAULT_VERSION(xsk_umem__create_v0_0_4, xsk_umem__create, LIBBPF_0.0.4)
>   
> +

Fyi, removed this extra newline when I applied the series, thanks!

> +static enum xsk_prog get_xsk_prog(void)
> +{
> +	enum xsk_prog detected = XSK_PROG_FALLBACK;
> +	struct bpf_load_program_attr prog_attr;
> +	struct bpf_create_map_attr map_attr;
> +	__u32 size_out, retval, duration;
> +	char data_in = 0, data_out;
> +	struct bpf_insn insns[] = {
> +		BPF_LD_MAP_FD(BPF_REG_1, 0),
> +		BPF_MOV64_IMM(BPF_REG_2, 0),
> +		BPF_MOV64_IMM(BPF_REG_3, XDP_PASS),
> +		BPF_EMIT_CALL(BPF_FUNC_redirect_map),
> +		BPF_EXIT_INSN(),
[...]

  reply	other threads:[~2021-01-25 23:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 10:53 [PATCH bpf-next 0/3] AF_XDP clean up/perf improvements Björn Töpel
2021-01-22 10:53 ` [PATCH bpf-next 1/3] xsk: remove explicit_free parameter from __xsk_rcv() Björn Töpel
2021-01-22 10:53 ` [PATCH bpf-next 2/3] xsk: fold xp_assign_dev and __xp_assign_dev Björn Töpel
2021-01-22 10:53 ` [PATCH bpf-next 3/3] libbpf, xsk: select AF_XDP BPF program based on kernel version Björn Töpel
2021-01-25 23:12   ` Daniel Borkmann [this message]
2021-01-26  8:38   ` Jesper Dangaard Brouer
2021-01-22 13:19 ` [PATCH bpf-next 0/3] AF_XDP clean up/perf improvements Toke Høiland-Jørgensen
2021-01-22 13:37   ` Björn Töpel
2021-01-22 13:40     ` Toke Høiland-Jørgensen

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=cafcfa48-ecfd-1dbb-6b3a-220a52b6db16@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=alardam@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@gmail.com \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=ciara.loftus@intel.com \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=jonathan.lemon@gmail.com \
    --cc=kuba@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=maximmi@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=weqaar.a.janjua@intel.com \
    --subject='Re: [PATCH bpf-next 3/3] libbpf, xsk: select AF_XDP BPF program based on kernel version' \
    /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

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).