Skip to content

RFC AF_XDP support for veth.

William Tu netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 RFC Latest6 patches 3 repliesIn review
  2. v2 RFC3 patches 4 repliesSuperseded
  3. v1 RFC3 patches 6 repliesSuperseded

Changes in v3 from the cover letter

- refactor the xsk_umem_consume_tx_virtual, suggested by Björn Töpel
- fix the racy condition by processing tx and its peer's rx napi, suggested by Björn Töpel
- add AF_XDP zero copy TX
- add AF_XDP RX

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6xsk: add xsk_umem_consume_tx_virtual.include/net/xdp_sock.h net/xdp/xdp_umem.c net/xdp/xsk.c+39 -70 replies
2/6veth: support AF_XDP TX copy-mode.drivers/net/veth.c+199 -13 replies
3/6xsk: add new MEM type for virtual device.include/net/xdp.h net/core/xdp.c net/xdp/xsk.c+4 -10 replies
4/6veth: add zero-copy AF_XDP TX support.drivers/net/veth.c+18 -230 replies
5/6veth: add AF_XDP RX support.drivers/net/veth.c+17 -00 replies
6/6samples: bpf: add veth AF_XDP example.samples/bpf/test_veth_afxdp.sh+82 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH bpf-next RFCv3 0/6] AF_XDP support for veth.

The patch series adds AF_XDP support for veth device. The first patch adds a new API for supporting non-physical NIC device to get packet's virtual address. The second patch implements the async xmit with one extra copy. The third and forth patches implement the zero copy AF_XDP TX support. The fifth patch implements the AF_XDP RX and last patch adds example use cases.

I tested with 2 namespaces, one as sender, the other as receiver. The packet rate is measure at the receiver side.
ip netns add at_ns0
ip link add p0 type veth peer name p1
ip link set p0 netns at_ns0
ip link set dev p1 up
ip netns exec at_ns0 ip link set dev p0 up

  # receiver
  ip netns exec at_ns0 xdp_rxq_info --dev p0 --action XDP_DROP
  # receiver with AF_XDP
  ip netns exec at_ns0 xdpsock -i p0 -r -N -z 
  # sender without AF_XDP ZC
  xdpsock -i p1 -t -S
  # sender with AF_XDP
  xdpsock -i p1 -t -N -z

Without AF_XDP: 724 Kpps
With AF_XDP: 1.1 Mpps (with ksoftirqd 100% cpu)
With AF_XDP: 1.4 Mpps (with ksoftirqd 100% cpu)
With both peer running AF_XDP: 2.4Mpps

v2->v3:
- refactor the xsk_umem_consume_tx_virtual, suggested by Björn Töpel
- fix the racy condition by processing tx and its peer's rx napi, suggested by Björn Töpel
- add AF_XDP zero copy TX
- add AF_XDP RX

v1->v2:
- refactor the xsk_umem_consume_tx_virtual
- use the umems provided by netdev
- fix bug from locating peer side rq with qid

William Tu (6):
xsk: add xsk_umem_consume_tx_virtual.
veth: support AF_XDP TX copy-mode.
xsk: add new MEM type for virtual device.
veth: add zero-copy AF_XDP TX support.
veth: add AF_XDP RX support.
samples: bpf: add veth AF_XDP example.

 drivers/net/veth.c             | 212 ++++++++++++++++++++++++++++++++++++++++-
 include/net/xdp.h              |   1 +
 include/net/xdp_sock.h         |   7 ++
 net/core/xdp.c                 |   1 +
 net/xdp/xdp_umem.c             |   1 +
 net/xdp/xsk.c                  |  41 ++++++--
 samples/bpf/test_veth_afxdp.sh |  82 ++++++++++++++++
 7 files changed, 336 insertions(+), 9 deletions(-)
 create mode 100755 samples/bpf/test_veth_afxdp.sh
Signature · 1 line
2.7.4