Skip to content

AF_XDP: introducing zero-copy support

Björn Töpel intel-wired-lan netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 10 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11xsk: moved struct xdp_umem definitioninclude/net/xdp_sock.h net/xdp/xdp_umem.c net/xdp/xdp_umem.h +1 more+26 -240 replies
2/11xsk: introduce xdp_umem_pageinclude/net/xdp_sock.h net/xdp/xdp_umem.c net/xdp/xdp_umem.h+21 -42 replies
3/11net: xdp: added bpf_netdev_command XDP_{QUERY,SETUP}_XSK_UMEMinclude/linux/netdevice.h+8 -00 replies
4/11xdp: add MEM_TYPE_ZERO_COPYinclude/net/xdp.h net/core/xdp.c+24 -50 replies
5/11xsk: add zero-copy support for Rxinclude/net/xdp_sock.h include/uapi/linux/if_xdp.h net/xdp/xdp_umem.c +2 more+165 -210 replies
6/11net: added netdevice operation for Txinclude/linux/netdevice.h+2 -00 replies
7/11xsk: wire upp Tx zero-copy functionsinclude/net/xdp_sock.h net/xdp/xdp_umem.c net/xdp/xdp_umem.h +2 more+137 -110 replies
8/11i40e: added queue pair disable/enable functionsdrivers/net/ethernet/intel/i40e/i40e_main.c+251 -00 replies
9/11i40e: implement AF_XDP zero-copy support for Rxdrivers/net/ethernet/intel/i40e/Makefile drivers/net/ethernet/intel/i40e/i40e.h drivers/net/ethernet/intel/i40e/i40e_main.c +6 more+789 -1462 replies
10/11i40e: implement AF_XDP zero-copy support for Txdrivers/net/ethernet/intel/i40e/i40e_main.c drivers/net/ethernet/intel/i40e/i40e_txrx.c drivers/net/ethernet/intel/i40e/i40e_txrx.h +3 more+242 -373 replies
11/11samples/bpf: xdpsock: use skb Tx path for XDP_SKBsamples/bpf/xdpsock_user.c+5 -00 replies

Reviews trailers per patch

None of the 11 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchAlexei Starovoitov
SeriesA-b
1/11
2/11
3/11
4/11
5/11
6/11
7/11
8/11
9/11
10/11
11/11

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH bpf-next 00/11] AF_XDP: introducing zero-copy support

From: Bj?rn T?pel <[email protected]>

This patch serie introduces zerocopy (ZC) support for AF_XDP. Programs using AF_XDP sockets will now receive RX packets without any copies and can also transmit packets without incurring any copies. No modifications to the application are needed, but the NIC driver needs to be modified to support ZC. If ZC is not supported by the driver, the modes introduced in the AF_XDP patch will be used. Using ZC in our micro benchmarks results in significantly improved performance as can be seen in the performance section later in this cover letter.

Note that for an untrusted application, HW packet steering to a specific queue pair (the one associated with the application) is a requirement when using ZC, as the application would otherwise be able to see other user space processes' packets. If the HW cannot support the required packet steering you need to use the XDP_SKB mode or the XDP_DRV mode without ZC turned on. The XSKMAP introduced in the AF_XDP patch set can be used to do load balancing in that case.

For benchmarking, you can use the xdpsock application from the AF_XDP patch set without any modifications. Say that you would like your UDP traffic from port 4242 to end up in queue 16, that we will enable AF_XDP on. Here, we use ethtool for this:

ethtool -N p3p2 rx-flow-hash udp4 fn
ethtool -N p3p2 flow-type udp4 src-port 4242 dst-port 4242 \
action 16

Running the rxdrop benchmark in XDP_DRV mode with zerocopy can then be done using:

      samples/bpf/xdpsock -i p3p2 -q 16 -r -N

We have run some benchmarks on a dual socket system with two Broadwell E5 2660 @ 2.0 GHz with hyperthreading turned off. Each socket has 14 cores which gives a total of 28, but only two cores are used in these experiments. One for TR/RX and one for the user space application. The memory is DDR4 @ 2133 MT/s (1067 MHz) and the size of each DIMM is 8192MB and with 8 of those DIMMs in the system we have 64 GB of total memory. The compiler used is gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0. The NIC is Intel I40E 40Gbit/s using the i40e driver.

Below are the results in Mpps of the I40E NIC benchmark runs for 64 and 1500 byte packets, generated by a commercial packet generator HW outputing packets at full 40 Gbit/s line rate. The results are without retpoline so that we can compare against previous numbers.

AF_XDP performance 64 byte packets. Results from the AF_XDP V3 patch set are also reported for ease of reference. The numbers within parantheses are from the RFC V1 ZC patch set.
Benchmark XDP_SKB XDP_DRV XDP_DRV with zerocopy

rxdrop       2.9*       9.6*       21.1(21.5)
txpush       2.6*       -          22.0(21.6)
l2fwd        1.9*       2.5*       15.3(15.0)

AF_XDP performance 1500 byte packets:
Benchmark XDP_SKB XDP_DRV XDP_DRV with zerocopy

rxdrop       2.1*       3.3*       3.3(3.3)
l2fwd        1.4*       1.8*       3.1(3.1)

* From AF_XDP V3 patch set and cover letter.

So why do we not get higher values for RX similar to the 34 Mpps we had in AF_PACKET V4? We made an experiment running the rxdrop benchmark without using the xdp_do_redirect/flush infrastructure nor using an XDP program (all traffic on a queue goes to one socket). Instead the driver acts directly on the AF_XDP socket. With this we got 36.9 Mpps, a significant improvement without any change to the uapi. So not forcing users to have an XDP program if they do not need it, might be a good idea. This measurement is actually higher than what we got with AF_PACKET V4.

XDP performance on our system as a base line:

64 byte packets:

XDP stats       CPU     pps         issue-pps
XDP-RX CPU      16      32.3M  0

1500 byte packets:

XDP stats       CPU     pps         issue-pps
XDP-RX CPU      16      3.3M    0

The structure of the patch set is as follows:

Patches 1-3: Plumbing for AF_XDP ZC support
Patches 4-5: AF_XDP ZC for RX
Patches 6-7: AF_XDP ZC for TX
Patch 8-10: ZC support for i40e.
Patch 11: Use the bind flags in sample application to force TX skb
path when -S is providedd on the command line.

This patch set is based on the new uapi introduced in "AF_XDP: bug fixes and descriptor changes". You need to apply that patch set first, before applying this one.

We based this patch set on bpf-next commit bd3a08aaa9a3 ("bpf:
flowlabel in bpf_fib_lookup should be flowinfo")

Comments:

* Implementing dynamic creation and deletion of queues in the i40e driver would facilitate the coexistence of xdp_redirect and af_xdp.

Thanks: Bj?rn and Magnus

Bj?rn T?pel (8):
xsk: moved struct xdp_umem definition
xsk: introduce xdp_umem_page
net: xdp: added bpf_netdev_command XDP_{QUERY,SETUP}_XSK_UMEM
xdp: add MEM_TYPE_ZERO_COPY
xsk: add zero-copy support for Rx
i40e: added queue pair disable/enable functions
i40e: implement AF_XDP zero-copy support for Rx samples/bpf: xdpsock: use skb Tx path for XDP_SKB

Magnus Karlsson (3):
net: added netdevice operation for Tx
xsk: wire upp Tx zero-copy functions
i40e: implement AF_XDP zero-copy support for Tx

 drivers/net/ethernet/intel/i40e/Makefile    |   3 +-
 drivers/net/ethernet/intel/i40e/i40e.h      |  23 +
 drivers/net/ethernet/intel/i40e/i40e_main.c | 287 +++++++++++-
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 256 ++++-------
 drivers/net/ethernet/intel/i40e/i40e_txrx.h | 151 ++++++-
 drivers/net/ethernet/intel/i40e/i40e_xsk.c  | 677 ++++++++++++++++++++++++++++
 drivers/net/ethernet/intel/i40e/i40e_xsk.h  |  19 +
 include/linux/netdevice.h                   |  10 +
 include/net/xdp.h                           |  10 +
 include/net/xdp_sock.h                      |  77 +++-
 include/uapi/linux/if_xdp.h                 |   4 +-
 net/core/xdp.c                              |  19 +-
 net/xdp/xdp_umem.c                          | 118 ++++-
 net/xdp/xdp_umem.h                          |  32 +-
 net/xdp/xsk.c                               | 166 +++++--
 net/xdp/xsk_queue.h                         |  35 +-
 samples/bpf/xdpsock_user.c                  |   5 +
 17 files changed, 1657 insertions(+), 235 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/i40e/i40e_xsk.c
 create mode 100644 drivers/net/ethernet/intel/i40e/i40e_xsk.h
Signature · 1 line
2.14.1