All of lore.kernel.org
 help / color / mirror / Atom feed
From: Weqaar Janjua <weqaar.janjua@gmail.com>
To: bpf@vger.kernel.org, netdev@vger.kernel.org,
	daniel@iogearbox.net, ast@kernel.org, yhs@fb.com,
	magnus.karlsson@gmail.com, bjorn.topel@intel.com
Cc: Weqaar Janjua <weqaar.a.janjua@intel.com>,
	shuah@kernel.org, skhan@linuxfoundation.org,
	linux-kselftest@vger.kernel.org, anders.roxell@linaro.org,
	jonathan.lemon@gmail.com
Subject: [PATCH bpf-next v4 0/5] selftests/bpf: xsk selftests
Date: Mon,  7 Dec 2020 21:53:28 +0000	[thread overview]
Message-ID: <20201207215333.11586-1-weqaar.a.janjua@intel.com> (raw)

This patch set adds AF_XDP selftests based on veth to selftests/bpf.

# Topology:
# ---------
#                 -----------
#               _ | Process | _
#              /  -----------  \
#             /        |        \
#            /         |         \
#      -----------     |     -----------
#      | Thread1 |     |     | Thread2 |
#      -----------     |     -----------
#           |          |          |
#      -----------     |     -----------
#      |  xskX   |     |     |  xskY   |
#      -----------     |     -----------
#           |          |          |
#      -----------     |     ----------
#      |  vethX  | --------- |  vethY |
#      -----------   peer    ----------
#           |          |          |
#      namespaceX      |     namespaceY

These selftests test AF_XDP SKB and Native/DRV modes using veth Virtual
Ethernet interfaces.

The test program contains two threads, each thread is single socket with
a unique UMEM. It validates in-order packet delivery and packet content
by sending packets to each other.

Prerequisites setup by script test_xsk.sh:

   Set up veth interfaces as per the topology shown ^^:
   * setup two veth interfaces and one namespace
   ** veth<xxxx> in root namespace
   ** veth<yyyy> in af_xdp<xxxx> namespace
   ** namespace af_xdp<xxxx>
   * create a spec file veth.spec that includes this run-time configuration
   *** xxxx and yyyy are randomly generated 4 digit numbers used to avoid
       conflict with any existing interface
   
   Adds xsk framework test to validate veth xdp DRV and SKB modes.

The following tests are provided:

1. AF_XDP SKB mode
   Generic mode XDP is driver independent, used when the driver does
   not have support for XDP. Works on any netdevice using sockets and
   generic XDP path. XDP hook from netif_receive_skb().
   a. nopoll - soft-irq processing
   b. poll - using poll() syscall
   c. Socket Teardown
      Create a Tx and a Rx socket, Tx from one socket, Rx on another.
      Destroy both sockets, then repeat multiple times. Only nopoll mode
	  is used
   d. Bi-directional Sockets
      Configure sockets as bi-directional tx/rx sockets, sets up fill
	  and completion rings on each socket, tx/rx in both directions.
	  Only nopoll mode is used

2. AF_XDP DRV/Native mode
   Works on any netdevice with XDP_REDIRECT support, driver dependent.
   Processes packets before SKB allocation. Provides better performance
   than SKB. Driver hook available just after DMA of buffer descriptor.
   a. nopoll
   b. poll
   c. Socket Teardown
   d. Bi-directional Sockets
   * Only copy mode is supported because veth does not currently support
     zero-copy mode

Total tests: 8

Flow:
* Single process spawns two threads: Tx and Rx
* Each of these two threads attach to a veth interface within their
  assigned namespaces
* Each thread creates one AF_XDP socket connected to a unique umem
  for each veth interface
* Tx thread transmits 10k packets from veth<xxxx> to veth<yyyy>
* Rx thread verifies if all 10k packets were received and delivered
  in-order, and have the right content

v2 changes:
* Move selftests/xsk to selftests/bpf
* Remove Makefiles under selftests/xsk, and utilize selftests/bpf/Makefile

v3 changes:
* merge all test scripts test_xsk_*.sh into test_xsk.sh

v4 changes:
* merge xsk_env.sh into xsk_prereqs.sh
* test_xsk.sh add cliarg -c for color-coded output
* test_xsk.sh PREREQUISITES disables IPv6 on veth interfaces
* test_xsk.sh PREREQUISITES adds xsk framework test
* test_xsk.sh is independently executable
* xdpxceiver.c Tx/Rx validates only IPv4 packets with TOS 0x9, ignores
  others

Structure of the patch set:

Patch 1: Adds XSK selftests framework and test under selftests/bpf
Patch 2: Adds tests: SKB poll and nopoll mode, and mac-ip-udp debug
Patch 3: Adds tests: DRV poll and nopoll mode
Patch 4: Adds tests: SKB and DRV Socket Teardown
Patch 5: Adds tests: SKB and DRV Bi-directional Sockets

Thanks: Weqaar

Weqaar Janjua (5):
  selftests/bpf: xsk selftests framework
  selftests/bpf: xsk selftests - SKB POLL, NOPOLL
  selftests/bpf: xsk selftests - DRV POLL, NOPOLL
  selftests/bpf: xsk selftests - Socket Teardown - SKB, DRV
  selftests/bpf: xsk selftests - Bi-directional Sockets - SKB, DRV

 tools/testing/selftests/bpf/Makefile       |    7 +-
 tools/testing/selftests/bpf/test_xsk.sh    |  259 +++++
 tools/testing/selftests/bpf/xdpxceiver.c   | 1074 ++++++++++++++++++++
 tools/testing/selftests/bpf/xdpxceiver.h   |  160 +++
 tools/testing/selftests/bpf/xsk_prereqs.sh |  135 +++
 5 files changed, 1633 insertions(+), 2 deletions(-)
 create mode 100755 tools/testing/selftests/bpf/test_xsk.sh
 create mode 100644 tools/testing/selftests/bpf/xdpxceiver.c
 create mode 100644 tools/testing/selftests/bpf/xdpxceiver.h
 create mode 100755 tools/testing/selftests/bpf/xsk_prereqs.sh

-- 
2.20.1


             reply	other threads:[~2020-12-07 21:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 21:53 Weqaar Janjua [this message]
2020-12-07 21:53 ` [PATCH bpf-next v4 1/5] selftests/bpf: xsk selftests framework Weqaar Janjua
2020-12-07 21:53 ` [PATCH bpf-next v4 2/5] selftests/bpf: xsk selftests - SKB POLL, NOPOLL Weqaar Janjua
2020-12-09 18:29   ` Yonghong Song
2020-12-10 11:55     ` Weqaar Janjua
2020-12-07 21:53 ` [PATCH bpf-next v4 3/5] selftests/bpf: xsk selftests - DRV " Weqaar Janjua
2020-12-07 21:53 ` [PATCH bpf-next v4 4/5] selftests/bpf: xsk selftests - Socket Teardown - SKB, DRV Weqaar Janjua
2020-12-07 21:53 ` [PATCH bpf-next v4 5/5] selftests/bpf: xsk selftests - Bi-directional Sockets " Weqaar Janjua
2020-12-08  3:56 ` [PATCH bpf-next v4 0/5] selftests/bpf: xsk selftests Yonghong Song
2020-12-08  7:03   ` Björn Töpel
2020-12-09 16:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201207215333.11586-1-weqaar.a.janjua@intel.com \
    --to=weqaar.janjua@gmail.com \
    --cc=anders.roxell@linaro.org \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jonathan.lemon@gmail.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=magnus.karlsson@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=weqaar.a.janjua@intel.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.