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

-- 
2.7.4

Reply via email to