From: William Tu Subject: [PATCH bpf-next RFCv3 0/6] AF_XDP support for veth. Date: Wed, 26 Dec 2018 12:27:47 -0800 Message-ID: <1545856073-8680-1-git-send-email-u9012063@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: bjorn.topel@gmail.com, magnus.karlsson@gmail.com, ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, makita.toshiaki@lab.ntt.co.jp, yihung.wei@gmail.com, magnus.karlsson@intel.com Return-path: Received: from mail-pg1-f193.google.com ([209.85.215.193]:45703 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727513AbeLZU2U (ORCPT ); Wed, 26 Dec 2018 15:28:20 -0500 Received: by mail-pg1-f193.google.com with SMTP id y4so7909929pgc.12 for ; Wed, 26 Dec 2018 12:28:19 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: 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