[PATCH bpf] bpf, riscv: clear target register high 32-bits for and/or/xor on ALU32

2019-05-21 Thread Björn Töpel
riscv: add BPF JIT for RV64G") Signed-off-by: Björn Töpel --- arch/riscv/net/bpf_jit_comp.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/net/bpf_jit_comp.c b/arch/riscv/net/bpf_jit_comp.c index 80b12aa5e10d..e5c8d675bd6e 100644 --- a/arch/riscv/net/bpf_jit

Re: [PATCH bpf] bpf, riscv: clear target register high 32-bits for and/or/xor on ALU32

2019-05-21 Thread Björn Töpel
On Tue, 21 May 2019 at 16:02, Daniel Borkmann wrote: > > On 05/21/2019 03:46 PM, Björn Töpel wrote: > > When using 32-bit subregisters (ALU32), the RISC-V JIT would not clear > > the high 32-bits of the target register and therefore generate > > incorrect code. > > &

[PATCH bpf] selftests: bpf: add zero extend checks for ALU32 and/or/xor

2019-05-22 Thread Björn Töpel
Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the destination register is cleared after an ALU32 and/or/xor. Signed-off-by: Björn Töpel --- .../selftests/bpf/verifier/basic_instr.c | 39 +++ 1 file changed, 39 insertions(+) diff --git

[PATCH bpf-next 0/2] net: xdp: refactor the XDP_QUERY_PROG and XDP_QUERY_PROG_HW code

2019-05-22 Thread Björn Töpel
r+sk2dxxfyo8qpr-wjx0...@mail.gmail.com/ Björn Töpel (2): net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev net: xdp: remove XDP_QUERY_PROG{,_HW} drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 - .../net/ethernet/cavium/thunder/nicvf_main.c | 3 - .../net/ethernet/freescale/dpaa2/dpa

[PATCH bpf-next 2/2] net: xdp: remove XDP_QUERY_PROG{,_HW}

2019-05-22 Thread Björn Töpel
From: Björn Töpel Remove all use of XDP_QUERY_PROG{,_HW}, since it was moved to the generic code path. Signed-off-by: Björn Töpel --- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 .../net/ethernet/cavium/thunder/nicvf_main.c | 3 --- .../net/ethernet/freescale/dpaa2/dpaa2-eth.c

[PATCH bpf-next 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-05-22 Thread Björn Töpel
From: Björn Töpel All XDP capable drivers need to implement the XDP_QUERY_PROG{,_HW} command of ndo_bpf. The query code is fairly generic. This commit refactors the query code up from the drivers to the netdev level. The struct net_device has gained four new members tracking the XDP program

[PATCH bpf-next v2 0/2] net: xdp: Two XSKMAP improvements

2019-05-22 Thread Björn Töpel
socket tracks which maps it resides in, and remove itself from those maps at relase. 2. The XSKMAP did not honor the BPF_EXIST/BPF_NOEXIST flag on insert, which this patch addresses. Thanks, Björn v1->v2: Fixed deadlock and broken cleanup. (Daniel) Björn Töpel (2): xsk: remove AF_XD

[PATCH bpf-next v2 2/2] xsk: support BPF_EXIST and BPF_NOEXIST flags in XSKMAP

2019-05-22 Thread Björn Töpel
From: Björn Töpel The XSKMAP did not honor the BPF_EXIST/BPF_NOEXIST flags when updating an entry. This patch addressed that. Signed-off-by: Björn Töpel --- kernel/bpf/xskmap.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kernel/bpf/xskmap.c b/kernel

[PATCH bpf-next v2 1/2] xsk: remove AF_XDP socket from map when the socket is released

2019-05-22 Thread Björn Töpel
From: Björn Töpel When an AF_XDP socket is released/closed the XSKMAP still holds a reference to the socket in a "released" state. The socket will still use the netdev queue resource, and block newly created sockets from attaching to that queue, but no user application can acces

Re: [PATCH bpf] selftests: bpf: add zero extend checks for ALU32 and/or/xor

2019-05-22 Thread Björn Töpel
On Wed, 22 May 2019 at 20:13, Y Song wrote: > > On Wed, May 22, 2019 at 2:25 AM Björn Töpel wrote: > > > > Add three tests to test_verifier/basic_instr that make sure that the > > high 32-bits of the destination register is cleared after an ALU32 > > and/or/xor

Re: [PATCH bpf-next 0/2] net: xdp: refactor the XDP_QUERY_PROG and XDP_QUERY_PROG_HW code

2019-05-22 Thread Björn Töpel
On Wed, 22 May 2019 at 19:41, Jakub Kicinski wrote: > > On Wed, 22 May 2019 14:53:50 +0200, Björn Töpel wrote: > > Shout out to all XDP driver hackers to check that the second patch > > doesn't break anything (especially Jakub). I've only been able to test > >

Re: [PATCH bpf-next 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-05-22 Thread Björn Töpel
On Wed, 22 May 2019 at 20:32, Jakub Kicinski wrote: > > On Wed, 22 May 2019 14:53:51 +0200, Björn Töpel wrote: > > From: Björn Töpel > > > > All XDP capable drivers need to implement the XDP_QUERY_PROG{,_HW} > > command of ndo_bpf. The query code is fairly generic.

Re: [PATCH bpf-next 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-05-22 Thread Björn Töpel
On Wed, 22 May 2019 at 23:04, Jakub Kicinski wrote: > > On Wed, 22 May 2019 22:54:44 +0200, Björn Töpel wrote: > > > > Now, the same commands give: > > > > > > > > # ip link set dev eth0 xdp obj foo.o sec main > > > > # ip link set dev e

Re: [PATCH bpf-next 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-05-22 Thread Björn Töpel
On Thu, 23 May 2019 at 07:47, Saeed Mahameed wrote: > > On Wed, 2019-05-22 at 14:53 +0200, Björn Töpel wrote: > > From: Björn Töpel > > > > All XDP capable drivers need to implement the XDP_QUERY_PROG{,_HW} > > command of ndo_bpf. The query code is fairly generic.

Re: [PATCH bpf] selftests: bpf: add zero extend checks for ALU32 and/or/xor

2019-05-23 Thread Björn Töpel
On Thu, 23 May 2019 at 08:39, Y Song wrote: > > On Wed, May 22, 2019 at 1:46 PM Björn Töpel wrote: > > > > On Wed, 22 May 2019 at 20:13, Y Song wrote: > > > > > > On Wed, May 22, 2019 at 2:25 AM Björn Töpel wrote: > > > > > > > > Add

Re: [PATCH bpf] selftests: bpf: add zero extend checks for ALU32 and/or/xor

2019-05-23 Thread Björn Töpel
On Thu, 23 May 2019 at 16:31, Jiong Wang wrote: > > > > On 23 May 2019, at 15:02, Daniel Borkmann wrote: > > > > On 05/23/2019 08:38 AM, Y Song wrote: > >> On Wed, May 22, 2019 at 1:46 PM Björn Töpel wrote: > >>> On Wed, 22 May 2019 at 20:13, Y Son

Re: [PATCH bpf-next v3 00/16] AF_XDP infrastructure improvements and mlx5e support

2019-05-24 Thread Björn Töpel
On 2019-05-24 11:35, Maxim Mikityanskiy wrote: This series contains improvements to the AF_XDP kernel infrastructure and AF_XDP support in mlx5e. The infrastructure improvements are required for mlx5e, but also some of them benefit to all drivers, and some can be useful for other drivers that wan

Re: [PATCH v8 bpf-next 15/16] riscv: bpf: eliminate zero extension code-gen

2019-05-24 Thread Björn Töpel
On Fri, 24 May 2019 at 13:36, Jiong Wang wrote: > > Cc: Björn Töpel > Acked-by: Björn Töpel > Tested-by: Björn Töpel > Signed-off-by: Jiong Wang > --- > arch/riscv/net/bpf_jit_comp.c | 43 > ++- > 1 file changed, 30

Re: [PATCH v8 bpf-next 15/16] riscv: bpf: eliminate zero extension code-gen

2019-05-24 Thread Björn Töpel
On Fri, 24 May 2019 at 18:36, Jiong Wang wrote: > [...] > > Hmm, missing is64 check here (fall-through for 64-bit movs)? > > (re-send because of bouncing back) > > FOR BPF_X form, when imm == 1, it is a special mov32 constructed by > verifier, it can only be BPF_ALU, not BPF_ALU64. And it is used

Re: [PATCH bpf-next 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-05-28 Thread Björn Töpel
On Wed, 22 May 2019 at 20:32, Jakub Kicinski wrote: > [...] > > You should be able to just call install with the original flags, and > install handler should do the right maths again to direct it either to > drv or generic, no? > On a related note: I ran the test_offload.py test (thanks for point

[PATCH bpf-next v2 2/2] net: xdp: remove XDP_QUERY_PROG{,_HW}

2019-05-31 Thread Björn Töpel
From: Björn Töpel Remove all use of XDP_QUERY_PROG{,_HW}, since it was moved to the generic code path. Signed-off-by: Björn Töpel --- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 .../net/ethernet/cavium/thunder/nicvf_main.c | 3 --- .../net/ethernet/freescale/dpaa2/dpaa2-eth.c

[PATCH bpf-next v2 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-05-31 Thread Björn Töpel
From: Björn Töpel All XDP capable drivers need to implement the XDP_QUERY_PROG{,_HW} command of ndo_bpf. The query code is fairly generic. This commit refactors the query code up from the drivers to the netdev level. The struct net_device has gained two new members: xdp_prog_hw and xdp_flags

[PATCH bpf-next v2 0/2] net: xdp: refactor the XDP_QUERY_PROG and XDP_QUERY_PROG_HW code

2019-05-31 Thread Björn Töpel
more details. The patch passes test_offload.py from selftests. Thanks to Jakub for pointing this out. I, hopefully, addressed all comments from Jakub and Saeed, except one; I did not move the XDP struct net_device into a struct of its own. Thanks, Björn Björn Töpel (2): net: xdp: ref

Re: [PATCH bpf-next v2 0/2] net: xdp: refactor the XDP_QUERY_PROG and XDP_QUERY_PROG_HW code

2019-05-31 Thread Björn Töpel
On Fri, 31 May 2019 at 11:42, Björn Töpel wrote: > [...] > > I, hopefully, addressed all comments from Jakub and Saeed, except one; > I did not move the XDP struct net_device into a struct of its own. > Uhm, the last sentence was weird. What I meant was: I did not move the newly

Re: [PATCH v2 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap

2019-05-31 Thread Björn Töpel
32 *)key); + + return xs ? &xs->queue_id : NULL; I like this! I haven't taken it for a spin, but still: Acked-by: Björn Töpel } static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value, diff --git a/tools/testing/selftests/bpf/verifier/prevent_map_lookup.c b/tools/t

Re: [PATCH v2 bpf-next 2/2] libbpf: remove qidconf and better support external bpf programs.

2019-05-31 Thread Björn Töpel
On 2019-05-30 20:57, Jonathan Lemon wrote: Use the recent change to XSKMAP bpf_map_lookup_elem() to test if there is a xsk present in the map instead of duplicating the work with qidconf. Fix things so callers using XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD bypass any internal bpf maps, so xsk_socket_

Re: [PATCH v2 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap

2019-05-31 Thread Björn Töpel
On Fri, 31 May 2019 at 18:27, Jonathan Lemon wrote: > > On 31 May 2019, at 4:49, Björn Töpel wrote: > > > On 2019-05-30 20:57, Jonathan Lemon wrote: > >> Currently, the AF_XDP code uses a separate map in order to > >> determine if an xsk is bound to a queue.

Re: [PATCH bpf-next v2 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-06-03 Thread Björn Töpel
On Sat, 1 Jun 2019 at 20:12, Jonathan Lemon wrote: > > On 31 May 2019, at 2:42, Björn Töpel wrote: > > > From: Björn Töpel > > > > All XDP capable drivers need to implement the XDP_QUERY_PROG{,_HW} > > command of ndo_bpf. The query code is fairly generic. This co

Re: [PATCH bpf-next v2 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-06-03 Thread Björn Töpel
On Sat, 1 Jun 2019 at 21:42, Jakub Kicinski wrote: > > On Fri, 31 May 2019 19:18:17 +, Saeed Mahameed wrote: > > On Fri, 2019-05-31 at 11:42 +0200, Björn Töpel wrote: > > > From: Björn Töpel > > > > > > All XDP capable drivers need to implement th

Re: [PATCH bpf-next v2 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-06-03 Thread Björn Töpel
On Sat, 1 Jun 2019 at 21:57, Jakub Kicinski wrote: > > On Fri, 31 May 2019 19:18:17 +, Saeed Mahameed wrote: > > > + if (!bpf_op || flags & XDP_FLAGS_SKB_MODE) > > > + mode = XDP_FLAGS_SKB_MODE; > > > + > > > + curr_mode = dev_xdp_current_mode(dev); > > > + > > > + if (!offload

Re: [PATCH bpf-next v2 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-06-03 Thread Björn Töpel
On Sat, 1 Jun 2019 at 22:02, Jakub Kicinski wrote: > > On Fri, 31 May 2019 11:42:14 +0200, Björn Töpel wrote: > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > > index 44b47e9df94a..f3a875a52c6c 100644 > > --- a/include/linux/netdevice.h > > +

Re: [PATCH bpf-next v2 1/2] xsk: remove AF_XDP socket from map when the socket is released

2019-06-03 Thread Björn Töpel
On Sun, 2 Jun 2019 at 00:32, Song Liu wrote: > > On Wed, May 22, 2019 at 6:38 AM Björn Töpel wrote: > > > > From: Björn Töpel > > > > When an AF_XDP socket is released/closed the XSKMAP still holds a > > reference to the socket in a "released" s

Re: [PATCH v3 bpf-next 2/2] libbpf: remove qidconf and better support external bpf programs.

2019-06-03 Thread Björn Töpel
t;> { > >> -int qid = true, fd = xsk->fd, err; > >> - > >> -err = bpf_map_update_elem(xsk->qidconf_map_fd, &xsk->queue_id, > >> &qid, 0); > >> -if (err) > >> -goto out; > >> - > >>

Re: [PATCH bpf-next v2 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-06-03 Thread Björn Töpel
On Mon, 3 Jun 2019 at 19:03, Jakub Kicinski wrote: > > On Mon, 3 Jun 2019 11:04:36 +0200, Björn Töpel wrote: > > On Sat, 1 Jun 2019 at 21:57, Jakub Kicinski > > wrote: > > > > > > On Fri, 31 May 2019 19:18:17 +, Saeed Mahameed wrote: > > > >

Re: [PATCH bpf-next v2 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-06-03 Thread Björn Töpel
On Mon, 3 Jun 2019 at 23:20, Saeed Mahameed wrote: > > On Mon, 2019-06-03 at 11:04 +0200, Björn Töpel wrote: > > On Sat, 1 Jun 2019 at 21:42, Jakub Kicinski > > wrote: > > > On Fri, 31 May 2019 19:18:17 +, Saeed Mahameed wrote: > > > > On Fri, 2019-

Re: [PATCH bpf-next v2 1/2] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-06-03 Thread Björn Töpel
On Tue, 4 Jun 2019 at 01:11, Daniel Borkmann wrote: > > On 06/03/2019 10:39 AM, Björn Töpel wrote: > > On Sat, 1 Jun 2019 at 20:12, Jonathan Lemon wrote: > >> On 31 May 2019, at 2:42, Björn Töpel wrote: > >>> From: Björn Töpel > >>> > &

Re: [PATCH v4 bpf-next 0/2] Better handling of xskmap entries

2019-06-03 Thread Björn Töpel
nal bpf programs. > Nice work! For the series, Acked-by: Björn Töpel > include/net/xdp_sock.h| 6 +- > kernel/bpf/verifier.c | 6 +- > kernel/bpf/xskmap.c | 4 +- > tools/lib/bpf/xsk.c

Re: [RFC PATCH bpf-next 1/4] libbpf: fill the AF_XDP fill queue before bind() call

2019-06-04 Thread Björn Töpel
On 2019-06-03 15:19, Maciej Fijalkowski wrote: Let's get into the driver via ndo_bpf with command set to XDP_SETUP_UMEM with fill queue that already contains some available entries that can be used by Rx driver rings. Things worked in such way on old version of xdpsock (that lacked libbpf support

Re: [RFC PATCH bpf-next 2/4] libbpf: check for channels.max_{t,r}x in xsk_get_max_queues

2019-06-04 Thread Björn Töpel
On 2019-06-03 15:19, Maciej Fijalkowski wrote: When it comes down to ethtool's get channels API, various drivers are reporting the queue count in two ways - they are setting max_combined or max_tx/max_rx fields. When creating the eBPF maps for xsk socket, this API is used so that we have an entri

Re: [RFC PATCH bpf-next 3/4] libbpf: move xdp program removal to libbpf

2019-06-04 Thread Björn Töpel
On 2019-06-03 15:19, Maciej Fijalkowski wrote: Since xsk support in libbpf loads the xdp program interface, make it also responsible for its removal. Store the prog id in xsk_socket_config so when removing the program we are still able to compare the current program id with the id from the atta

Re: [RFC PATCH bpf-next 4/4] libbpf: don't remove eBPF resources when other xsks are present

2019-06-04 Thread Björn Töpel
On 2019-06-03 15:19, Maciej Fijalkowski wrote: In case where multiple xsk sockets are attached to a single interface and one of them gets detached, the eBPF maps and program are removed. This should not happen as the rest of xsksocks are still using these resources. In order to fix that, let's h

Re: [PATCH v4 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap

2019-06-04 Thread Björn Töpel
On 2019-06-04 19:25, Jonathan Lemon wrote: On 4 Jun 2019, at 9:43, Jesper Dangaard Brouer wrote: On Mon, 3 Jun 2019 09:38:51 -0700 Jonathan Lemon wrote: Currently, the AF_XDP code uses a separate map in order to determine if an xsk is bound to a queue. Instead of doing this, have bpf_map_lo

Re: [PATCH v4 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap

2019-06-05 Thread Björn Töpel
On Tue, 4 Jun 2019 at 20:13, Martin Lau wrote: > > On Tue, Jun 04, 2019 at 10:25:23AM -0700, Jonathan Lemon wrote: > > On 4 Jun 2019, at 9:43, Jesper Dangaard Brouer wrote: > > > > > On Mon, 3 Jun 2019 09:38:51 -0700 > > > Jonathan Lemon wrote: > > > > > >> Currently, the AF_XDP code uses a separ

Re: [RFC PATCH bpf-next 1/4] libbpf: fill the AF_XDP fill queue before bind() call

2019-06-05 Thread Björn Töpel
On Tue, 4 Jun 2019 at 17:06, Maciej Fijalkowski wrote: > > On Tue, 4 Jun 2019 10:06:36 +0200 > Björn Töpel wrote: > > > On 2019-06-03 15:19, Maciej Fijalkowski wrote: > > > Let's get into the driver via ndo_bpf with command set to XDP_SETUP_UMEM > > > w

Re: [RFC PATCH bpf-next 3/4] libbpf: move xdp program removal to libbpf

2019-06-05 Thread Björn Töpel
On Tue, 4 Jun 2019 at 17:07, Maciej Fijalkowski wrote: > > On Tue, 4 Jun 2019 10:07:25 +0200 > Björn Töpel wrote: > > > > > On 2019-06-03 15:19, Maciej Fijalkowski wrote: > > > Since xsk support in libbpf loads the xdp program interface, make it > > > a

Re: [RFC PATCH bpf-next 4/4] libbpf: don't remove eBPF resources when other xsks are present

2019-06-05 Thread Björn Töpel
On Tue, 4 Jun 2019 at 17:07, Maciej Fijalkowski wrote: > > On Tue, 4 Jun 2019 10:08:03 +0200 > Björn Töpel wrote: > > > On 2019-06-03 15:19, Maciej Fijalkowski wrote: > > > In case where multiple xsk sockets are attached to a single interface > > > and one

Re: [PATCH 1/1] bpf: Allow bpf_map_lookup_elem() on an xskmap

2019-06-05 Thread Björn Töpel
On Wed, 5 Jun 2019 at 17:58, Jonathan Lemon wrote: > > Currently, the AF_XDP code uses a separate map in order to > determine if an xsk is bound to a queue. Instead of doing this, > have bpf_map_lookup_elem() return a xdp_sock. > > Rearrange some xdp_sock members to eliminate structure holes. > >

Re: questions about AF_PACKET V4 and AF_XDP

2019-06-06 Thread Björn Töpel
On 2019-06-05 19:56, Junsong Zhao (junszhao) wrote: Hi Magnus and Bjorn, I saw your articles and presentation about AF_PACKET V4. It is exciting to know that the kernel socket can have 40G throughput. But it seems the code is not in the 4.19 or 5.1 kernel. Instead there is a new feature AF_X

Re: [PATCH bpf-next v2 1/2] xsk: remove AF_XDP socket from map when the socket is released

2019-06-06 Thread Björn Töpel
On Mon, 3 Jun 2019 at 11:25, Björn Töpel wrote: > > On Sun, 2 Jun 2019 at 00:32, Song Liu wrote: > > > > On Wed, May 22, 2019 at 6:38 AM Björn Töpel wrote: > > > > > > From: Björn Töpel > > > > > > When an AF_XDP socket is released/closed

Re: [PATCH v5 bpf-next 0/4] Better handling of xskmap entries

2019-06-08 Thread Björn Töpel
s. > Very nice! Thanks for doing this, Jonathan. Again, for the series: Acked-by: Björn Töpel > Patches: > 1 - adds XSK_SOCK type > 2 - sync bpf.h with tools > 3 - add tools selftest > 4 - update lib/bpf, removing qidconf > > v4->v5: > - xskmap lookup now return

[PATCH bpf-next v3 0/5] net: xdp: refactor XDP program queries

2019-06-10 Thread Björn Töpel
test_offload.py from selftests. Thanks to Jakub for pointing this out. Thanks, Björn Björn Töpel (5): net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev nfp, netdevsim: use dev_xdp_support_offload() function net: xdp: remove XDP_QUERY_PROG{,_HW} net: xdp: refactor XDP fla

[PATCH bpf-next v3 3/5] net: xdp: remove XDP_QUERY_PROG{,_HW}

2019-06-10 Thread Björn Töpel
From: Björn Töpel Remove all use of XDP_QUERY_PROG{,_HW}, since it was moved to the generic code path. Signed-off-by: Björn Töpel --- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 .../net/ethernet/cavium/thunder/nicvf_main.c | 3 --- .../net/ethernet/freescale/dpaa2/dpaa2-eth.c

[PATCH bpf-next v3 1/5] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev

2019-06-10 Thread Björn Töpel
From: Björn Töpel All XDP capable drivers need to implement the XDP_QUERY_PROG{,_HW} command of ndo_bpf. This commit refactors the query code up from the drivers to the netdev level. The xdp_prog member of the struct net_device has evolved into a struct netdev_xdp. The new structure contains an

[PATCH bpf-next v3 2/5] nfp, netdevsim: use dev_xdp_support_offload() function

2019-06-10 Thread Björn Töpel
From: Björn Töpel Make all drivers with XDP offloading support use dev_xdp_support_offload(). Signed-off-by: Björn Töpel --- drivers/net/ethernet/netronome/nfp/nfp_net_main.c | 7 +++ drivers/net/netdevsim/netdev.c| 4 2 files changed, 11 insertions(+) diff --git

[PATCH bpf-next v3 5/5] net: xdp: remove xdp_attachment_flags_ok() and flags member

2019-06-10 Thread Björn Töpel
From: Björn Töpel The attachment flags check is done in the generic netdev code, so there is no need for this function anymore. Remove it and all uses of it. Further; Passing flags from struct netdev_bpf when attaching an XDP program is no longer necessary, so let us remove that member. Signed

[PATCH bpf-next v3 4/5] net: xdp: refactor XDP flags checking

2019-06-10 Thread Björn Töpel
From: Björn Töpel Similar to query a driver for a loaded XDP program, each driver need to check the attachment flags when a program is loaded. E.g., if an XDP program was loaded without explicit flags (fallback mode), it must be reloaded/removed without explicit flags. This commit moves that

Re: [Intel-wired-lan] [PATCH bpf-next v4 03/11] libbpf: add flags to umem config

2019-07-31 Thread Björn Töpel
On Tue, 30 Jul 2019 at 19:43, Kevin Laatz wrote: > > This patch adds a 'flags' field to the umem_config and umem_reg structs. > This will allow for more options to be added for configuring umems. > > The first use for the flags field is to add a flag for unaligned chunks > mode. These flags can ei

Re: [Intel-wired-lan] [PATCH bpf-next v4 03/11] libbpf: add flags to umem config

2019-07-31 Thread Björn Töpel
On Tue, 30 Jul 2019 at 19:43, Kevin Laatz wrote: > > This patch adds a 'flags' field to the umem_config and umem_reg structs. > This will allow for more options to be added for configuring umems. > > The first use for the flags field is to add a flag for unaligned chunks > mode. These flags can ei

Re: [Intel-wired-lan] [PATCH bpf-next v4 03/11] libbpf: add flags to umem config

2019-08-01 Thread Björn Töpel
On Thu, 1 Aug 2019 at 08:59, Andrii Nakryiko wrote: > > On Wed, Jul 31, 2019 at 8:21 AM Björn Töpel wrote: > > > > On Tue, 30 Jul 2019 at 19:43, Kevin Laatz wrote: > > > > > > This patch adds a 'flags' field to the umem_config and umem_reg structs

Re: [Intel-wired-lan] [PATCH bpf-next v4 03/11] libbpf: add flags to umem config

2019-08-02 Thread Björn Töpel
On Fri, 2 Aug 2019 at 09:19, Andrii Nakryiko wrote: > > On Thu, Aug 1, 2019 at 12:34 AM Björn Töpel wrote: > > [...] > > > > Old application, dynamically linked to new libbpf.so will crash, > > right? Old application passes old version of xsk_umem_config, and

[PATCH bpf-next v4 1/2] xsk: remove AF_XDP socket from map when the socket is released

2019-08-02 Thread Björn Töpel
From: Björn Töpel When an AF_XDP socket is released/closed the XSKMAP still holds a reference to the socket in a "released" state. The socket will still use the netdev queue resource, and block newly created sockets from attaching to that queue, but no user application can acces

[PATCH bpf-next v4 0/2] net: xdp: XSKMAP improvements

2019-08-02 Thread Björn Töpel
v3->v4: {READ, WRITE}_ONCE consistency. (Daniel) Socket release/map update race. (Daniel) Björn Töpel (2): xsk: remove AF_XDP socket from map when the socket is released xsk: support BPF_EXIST and BPF_NOEXIST flags in XSKMAP include/net/xdp_sock.h | 18 ++

[PATCH bpf-next v4 2/2] xsk: support BPF_EXIST and BPF_NOEXIST flags in XSKMAP

2019-08-02 Thread Björn Töpel
From: Björn Töpel The XSKMAP did not honor the BPF_EXIST/BPF_NOEXIST flags when updating an entry. This patch addresses that. Signed-off-by: Björn Töpel --- kernel/bpf/xskmap.c | 19 --- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/kernel/bpf/xskmap.c b

Re: [PATCH bpf-next v4 1/2] xsk: remove AF_XDP socket from map when the socket is released

2019-08-12 Thread Björn Töpel
On Mon, 12 Aug 2019 at 14:28, Daniel Borkmann wrote: > [...] > > diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c > > index 59b57d708697..c3447bad608a 100644 > > --- a/net/xdp/xsk.c > > +++ b/net/xdp/xsk.c > > @@ -362,6 +362,50 @@ static void xsk_unbind_dev(struct xdp_sock *xs) > > dev_put(dev); >

[PATCH bpf] MAINTAINERS: update my email address

2021-01-15 Thread Björn Töpel
From: Björn Töpel My Intel email will stop working in a not too distant future. Move my MAINTAINERS entries to my kernel.org address. Signed-off-by: Björn Töpel --- .mailmap| 2 ++ MAINTAINERS | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap

Re: general protection fault in xsk_recvmsg

2021-01-15 Thread Björn Töpel
#syz fix: xsk: Validate socket state in xsk_recvmsg, prior touching socket members

[PATCH bpf-next] samples/bpf: add BPF_ATOMIC_OP macro for BPF samples

2021-01-18 Thread Björn Töpel
From: Björn Töpel Brendan Jackman added extend atomic operations to the BPF instruction set in commit 7064a7341a0d ("Merge branch 'Atomics for eBPF'"), which introduces the BPF_ATOMIC_OP macro. However, that macro was missing for the BPF samples. Fix that by adding it into

Re: [PATCH bpf-next] samples/bpf: add BPF_ATOMIC_OP macro for BPF samples

2021-01-18 Thread Björn Töpel
that one sample broke w/o the BPF_ATOMIC_OP. On Mon, 18 Jan 2021 at 10:18, Björn Töpel wrote: From: Björn Töpel Brendan Jackman added extend atomic operations to the BPF instruction set in commit 7064a7341a0d ("Merge branch 'Atomics for eBPF'"), which introduces the BPF

[PATCH bpf-next 0/8] Introduce bpf_redirect_xsk() helper

2021-01-19 Thread Björn Töpel
Baseline Two cores: 21.3 Mpps One core:24.5 Mpps Patched Two cores, bpf_redirect_map: 21.7 Mpps + 2% One core, bpf_redirect_map: 24.9 Mpps + 2% Two cores, bpf_redirect_xsk: 24.0 Mpps +13% One core, bpf_redirect_xsk: 25.5 Mpps + 4% Thanks! Björn Björn Töpel (8)

[PATCH bpf-next 1/8] xdp: restructure redirect actions

2021-01-19 Thread Björn Töpel
From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect targets for XDP either uses a map, or is based on ifindex. Future commits will

[PATCH bpf-next 8/8] selftest/bpf: remove a lot of ifobject casting in xdpxceiver

2021-01-19 Thread Björn Töpel
From: Björn Töpel Instead of passing void * all over the place, let us pass the actual type (ifobject) and remove the void-ptr-to-type-ptr casting. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 87 1 file changed, 42 insertions(+), 45

[PATCH bpf-next 6/8] libbpf, xsk: select bpf_redirect_xsk(), if supported

2021-01-19 Thread Björn Töpel
From: Björn Töpel Select bpf_redirect_xsk() as the default AF_XDP BPF program, if supported. The bpf_redirect_xsk() helper does not require an XSKMAP, so make sure that no map is created/updated when using it. Reviewed-by: Maciej Fijalkowski Signed-off-by: Björn Töpel --- tools/lib/bpf

[PATCH bpf-next 7/8] selftest/bpf: add XDP socket tests for bpf_redirect_{xsk, map}()

2021-01-19 Thread Björn Töpel
From: Björn Töpel Add support for externally loaded XDP programs to xdpxceiver/test_xsk.sh, so that bpf_redirect_xsk() and bpf_redirect_map() can be exercised. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/test_xsk.sh | 48 +++ tools/testing/selftests/bpf

[PATCH bpf-next 4/8] xsk: register XDP sockets at bind(), and add new AF_XDP BPF helper

2021-01-19 Thread Björn Töpel
From: Björn Töpel Extend bind() for XDP sockets, so that the bound socket is added to the netdev_rx_queue _rx array in the netdevice. We call this to register an XDP socket. To redirect packets to a registered socket, a new BPF helper is used: bpf_redirect_xsk(). For shared XDP sockets, only

[PATCH bpf-next 3/8] xsk: fold xp_assign_dev and __xp_assign_dev

2021-01-19 Thread Björn Töpel
From: Björn Töpel Fold xp_assign_dev and __xp_assign_dev. The former directly calls the latter. Reviewed-by: Maciej Fijalkowski Signed-off-by: Björn Töpel --- net/xdp/xsk_buff_pool.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/net/xdp/xsk_buff_pool.c b

[PATCH bpf-next 2/8] xsk: remove explicit_free parameter from __xsk_rcv()

2021-01-19 Thread Björn Töpel
From: Björn Töpel The explicit_free parameter of the __xsk_rcv() function was used to mark whether the call was via the generic XDP or the native XDP path. Instead of clutter the code with if-statements and "true/false" parameters which are hard to understand, simply move the explic

[PATCH bpf-next 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-19 Thread Björn Töpel
From: Björn Töpel 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 Acked-by: Maciej Fijalkowski Signed-off-by: Björn Töpel Signed-off-by: Marek

Re: [PATCH bpf-next 7/8] selftest/bpf: add XDP socket tests for bpf_redirect_{xsk, map}()

2021-01-19 Thread Björn Töpel
On Tue, 19 Jan 2021 at 16:37, Björn Töpel wrote: > > From: Björn Töpel > > Add support for externally loaded XDP programs to > xdpxceiver/test_xsk.sh, so that bpf_redirect_xsk() and > bpf_redirect_map() can be exercised. > Ah, crap. Forgot two files. Will resend. Björn

[PATCH bpf-next v2 8/8] selftest/bpf: remove a lot of ifobject casting in xdpxceiver

2021-01-19 Thread Björn Töpel
From: Björn Töpel Instead of passing void * all over the place, let us pass the actual type (ifobject) and remove the void-ptr-to-type-ptr casting. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 87 1 file changed, 42 insertions(+), 45

[PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-19 Thread Björn Töpel
From: Björn Töpel 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 Acked-by: Maciej Fijalkowski Signed-off-by: Björn Töpel Signed-off-by: Marek

[PATCH bpf-next v2 7/8] selftest/bpf: add XDP socket tests for bpf_redirect_{xsk, map}()

2021-01-19 Thread Björn Töpel
From: Björn Töpel Add support for externally loaded XDP programs to xdpxceiver/test_xsk.sh, so that bpf_redirect_xsk() and bpf_redirect_map() can be exercised. Signed-off-by: Björn Töpel --- .../selftests/bpf/progs/xdpxceiver_ext1.c | 15 .../selftests/bpf/progs/xdpxceiver_ext2.c

[PATCH bpf-next v2 6/8] libbpf, xsk: select bpf_redirect_xsk(), if supported

2021-01-19 Thread Björn Töpel
From: Björn Töpel Select bpf_redirect_xsk() as the default AF_XDP BPF program, if supported. The bpf_redirect_xsk() helper does not require an XSKMAP, so make sure that no map is created/updated when using it. Reviewed-by: Maciej Fijalkowski Signed-off-by: Björn Töpel --- tools/lib/bpf

[PATCH bpf-next v2 3/8] xsk: fold xp_assign_dev and __xp_assign_dev

2021-01-19 Thread Björn Töpel
From: Björn Töpel Fold xp_assign_dev and __xp_assign_dev. The former directly calls the latter. Reviewed-by: Maciej Fijalkowski Signed-off-by: Björn Töpel --- net/xdp/xsk_buff_pool.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/net/xdp/xsk_buff_pool.c b

[PATCH bpf-next v2 4/8] xsk: register XDP sockets at bind(), and add new AF_XDP BPF helper

2021-01-19 Thread Björn Töpel
From: Björn Töpel Extend bind() for XDP sockets, so that the bound socket is added to the netdev_rx_queue _rx array in the netdevice. We call this to register an XDP socket. To redirect packets to a registered socket, a new BPF helper is used: bpf_redirect_xsk(). For shared XDP sockets, only

[PATCH bpf-next v2 1/8] xdp: restructure redirect actions

2021-01-19 Thread Björn Töpel
From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect targets for XDP either uses a map, or is based on ifindex. Future commits will

[PATCH bpf-next v2 2/8] xsk: remove explicit_free parameter from __xsk_rcv()

2021-01-19 Thread Björn Töpel
From: Björn Töpel The explicit_free parameter of the __xsk_rcv() function was used to mark whether the call was via the generic XDP or the native XDP path. Instead of clutter the code with if-statements and "true/false" parameters which are hard to understand, simply move the explic

[PATCH bpf-next v2 0/8] Introduce bpf_redirect_xsk() helper

2021-01-19 Thread Björn Töpel
ed missing XDP programs to selftests. * Fixed checkpatch warning in selftests. Björn Töpel (8): xdp: restructure redirect actions xsk: remove explicit_free parameter from __xsk_rcv() xsk: fold xp_assign_dev and __xp_assign_dev xsk: register XDP sockets at bind(), and add new AF_XDP B

Re: [PATCH bpf] xsk: Clear pool even for inactive queues

2021-01-19 Thread Björn Töpel
umem_at_qid implementation") Signed-off-by: Maxim Mikityanskiy Thanks, Maxim! Acked-by: Björn Töpel --- net/xdp/xsk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 8037b04a9edd..4a83117507f5 100644 --- a/net/xdp/xsk.c +++ b

Re: [PATCH bpf-next v2 4/8] xsk: register XDP sockets at bind(), and add new AF_XDP BPF helper

2021-01-20 Thread Björn Töpel
On 2021-01-20 09:25, kernel test robot wrote: Hi "Björn, I love your patch! Yet something to improve: [auto build test ERROR on 95204c9bfa48d2f4d3bab7df55c1cc823957ff81] url: https://github.com/0day-ci/linux/commits/Bj-rn-T-pel/Introduce-bpf_redirect_xsk-helper/20210120-150357 base:952

Re: [PATCH bpf-next v2 4/8] xsk: register XDP sockets at bind(), and add new AF_XDP BPF helper

2021-01-20 Thread Björn Töpel
On 2021-01-20 13:50, Toke Høiland-Jørgensen wrote: Björn Töpel writes: diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index c001766adcbc..bbc7d9a57262 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -3836,6 +3836,12 @@ union bpf_attr { *Return

Re: [PATCH bpf-next v2 0/8] Introduce bpf_redirect_xsk() helper

2021-01-20 Thread Björn Töpel
On 2021-01-20 14:15, Maxim Mikityanskiy wrote: On 2021-01-19 17:50, Björn Töpel wrote: This series extends bind() for XDP sockets, so that the bound socket is added to the netdev_rx_queue _rx array in the netdevice. We call this to register the socket. To redirect packets to the registered

Re: [PATCH bpf-next v2 4/8] xsk: register XDP sockets at bind(), and add new AF_XDP BPF helper

2021-01-20 Thread Björn Töpel
On 2021-01-20 15:54, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 13:50, Toke Høiland-Jørgensen wrote: Björn Töpel writes: diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index c001766adcbc..bbc7d9a57262 100644 --- a/include/uapi/linux/bpf.h +++ b

Re: [PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-20 Thread Björn Töpel
On 2021-01-20 16:11, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 14:25, Björn Töpel wrote: On 2021-01-20 13:52, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Add detection for kernel version, and adapt the BPF program based on kernel support

Re: [PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-20 Thread Björn Töpel
On 2021-01-20 14:25, Björn Töpel wrote: On 2021-01-20 13:52, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel 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

Re: [PATCH bpf-next v2 1/8] xdp: restructure redirect actions

2021-01-20 Thread Björn Töpel
On 2021-01-20 15:52, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 13:44, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths

Re: [PATCH bpf-next v2 1/8] xdp: restructure redirect actions

2021-01-20 Thread Björn Töpel
On 2021-01-20 13:44, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect

Re: [PATCH bpf-next v2 1/8] xdp: restructure redirect actions

2021-01-20 Thread Björn Töpel
On 2021-01-20 17:30, Toke Høiland-Jørgensen wrote: Björn Töpel writes: [...] It can't be free'd but, ri->map can be cleared via bpf_clear_redirect_map(). So, between the helper (setting) and the tracepoint in xdp_do_redirect() it can be cleared (say if the XDP program is swapp

Re: [PATCH bpf-next v2 4/8] xsk: register XDP sockets at bind(), and add new AF_XDP BPF helper

2021-01-20 Thread Björn Töpel
On 2021-01-20 18:29, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 15:54, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 13:50, Toke Høiland-Jørgensen wrote: Björn Töpel writes: diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index

Re: [PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-20 Thread Björn Töpel
On 2021-01-20 19:25, Alexei Starovoitov wrote: On Wed, Jan 20, 2021 at 7:27 AM Björn Töpel wrote: Would it make sense with some kind of BPF-specific "supported features" mechanism? Something else with a bigger scope (whole kernel)? Heh, in my opinion, yeah. Seems like we'll

Re: [PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-20 Thread Björn Töpel
On 2021-01-20 13:52, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel 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. Please do explicit feature detection

  1   2   3   4   5   6   7   8   9   10   >