From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795791966; b=ehA1eGGXzMzXWHZtbKvhv/FxL9QO7h8Rz2l7NhlzLdjHTwb5GUZuX6B0vhJln9g0vKg7 98kJdWYLviM9wXczVwRg9I5Hi1zkdyv4SX0ycnGlhvLIZ5lpjG+2S9ibH0ywIHCXtPSVp vcWzO6ONenaV9ne0lmXeBq4vwmGetiXC9okMi51qniXW7JjQJVy4hQJYdWwAYS3nW1Bnu ISq1g2zoEyM/yHrQx9aRH2XmXArsGMjgtClKOh63UgHbJvMH8TR/cqH47Sscuu4Bcq9/f tcKvPs1Y3N74SMNBdgEWhz+MDPGwyZNjWE/f/wgCOjzUGcZuXfscGbZpwAFmXWakzRA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795791966; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=Tmy5qAaYY9WzaLVzz/4SEp49kM/yssz9YoZDNN0DTQ0=; b=wMuH3OMv7wyMuAT1zx/dwxgBw8wrwIGbgsT2oLstl/G4+D2jKh0FjkSmokHu1/JRyL93 eeAWwIYDTMckb6YFWMu/54RfODdECGacuentqZBrryHh3mR5zTGUUKrJoBn1oWzIDVXQp rUKRQBimIvxTzx1liS1qvJFXY0Y9kt56In1uZFexEJXm1M0uT1iwDekcZ/qmyThRcQger stf3y7D4qs6V4s+xBGV3fg3KMZZKTkaaqbKockMFwD7lWy4lyjmtOQIKD6z5h/gFmumj0 uvLWtH5s7lZBfxY2xAu1HDa8xK0Cy6lBcU4O0LBLI+Kj3T8lQpLCt+QxFO3l1YamPeQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ZrISbBWK; arc=none smtp.remote-ip=192.198.163.14 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69937606A685 for ; Fri, 27 Nov 2026 15:06:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 69937606A685 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ZrISbBWK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1795791965; x=1827327965; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mG42BuN+fA0DPlxC8BQRcnG33jhHtqciAgFTfp7nIYI=; b=ZrISbBWKKW8Y5kHn9Xpmggg5is7BcavjGsdZMUJ9ttNMT8gVtQuBBb7m ySBcbwrgIQDhjCLF9DHfrCR5TaZJ2w0hqMoKLBurtHJBaHnS70e+B5Dp+ LLhJRX7Xnimpz+R/NsbD5N5HQkjJD7ZKRRNzarH4GTCbX0XUlKsHiHxIp Ygl1jjGH9wRxme3QD0SQd19wDzynA+aovMFe2X3tgVaoCjP0FuknEQfs7 bY3Qnynws7AxkrCKoeJ1Zr3/UW5Za9hzFQBYtwlIzCj/m5GW1B8wSak4j MhNhF9uukdWmRU7ao7w+Qv+LfW1DgFRP87NUPP8ldayAM5KtBcXrIT/Oy Q==; X-CSE-ConnectionGUID: lUFMxAwPTCW9ZskKzhehMA== X-CSE-MsgGUID: 7TMAGmYcSuqa1GzRUG0ztA== X-IronPort-AV: E=McAfee;i="6800,10657,11979"; a="4666076" X-IronPort-AV: E=Sophos;i="6.27,237,1787036400"; d="scan'208";a="4666076" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2026 07:06:04 -0800 X-CSE-ConnectionGUID: Epqdy14yR0WCHZnY1ki64A== X-CSE-MsgGUID: oH43cFDhRCeccbTXmCV84A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,237,1787036400"; d="scan'208";a="12202753" Received: from boxer.igk.intel.com ([10.102.20.173]) by orviesa008.jf.intel.com with ESMTP; 27 Nov 2026 07:06:02 -0800 From: Maciej Fijalkowski To: netdev@vger.kernel.org Cc: magnus.karlsson@intel.com, stfomichev@gmail.com, kuba@kernel.org, pabeni@redhat.com, tushar.vyavahare@intel.com, kerneljasonxing@gmail.com, bjorn@kernel.org, Maciej Fijalkowski Subject: [PATCH v6 net-next 07/15] selftests: xsk: run one test case per xskxceiver invocation Date: Fri, 27 Nov 2026 16:05:19 +0100 Message-Id: <20261127150527.1122049-8-maciej.fijalkowski@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20261127150527.1122049-1-maciej.fijalkowski@intel.com> References: <20261127150527.1122049-1-maciej.fijalkowski@intel.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run one test case in one mode per xskxceiver invocation, so that each case starts from a fresh process and a crash fails only that case. xskxceiver now requires -m and -t and exits with the verdict of the case; an unsupported mode skips it rather than exiting with XFAIL. This breaks test_xsk.sh, which ran all cases in one invocation. Remove it and xsk_prereqs.sh; drivers/net/xsk.py, added later in this series, replaces them. As test_xsk.sh was in TEST_PROGS_EXTENDED, the default run loses no test in between. Reviewed-by: Björn Töpel Signed-off-by: Maciej Fijalkowski --- MAINTAINERS | 1 - tools/testing/selftests/net/Makefile | 2 - tools/testing/selftests/net/lib/Makefile | 2 +- .../selftests/net/lib/xsk/xskxceiver.c | 64 ++--- tools/testing/selftests/net/test_xsk.sh | 230 ------------------ tools/testing/selftests/net/xsk_prereqs.sh | 86 ------- 6 files changed, 22 insertions(+), 363 deletions(-) delete mode 100755 tools/testing/selftests/net/test_xsk.sh delete mode 100755 tools/testing/selftests/net/xsk_prereqs.sh diff --git a/MAINTAINERS b/MAINTAINERS index 05b2d9e36b6d..8b7d54034856 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -30608,7 +30608,6 @@ F: include/net/xsk_buff_pool.h F: include/uapi/linux/if_xdp.h F: include/uapi/linux/xdp_diag.h F: net/xdp/ -F: tools/testing/selftests/net/*xsk* F: tools/testing/selftests/net/lib/xsk/ XEN BLOCK SUBSYSTEM diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index fb0a64662053..09c345f4d211 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -143,7 +143,6 @@ TEST_PROGS := \ # end of TEST_PROGS TEST_PROGS_EXTENDED := \ - test_xsk.sh \ xfrm_policy_add_speed.sh \ # end of TEST_PROGS_EXTENDED @@ -216,7 +215,6 @@ TEST_FILES := \ in_netns.sh \ lib.sh \ settings \ - xsk_prereqs.sh \ # end of TEST_FILES # YNL files, must be before "include ..lib.mk" diff --git a/tools/testing/selftests/net/lib/Makefile b/tools/testing/selftests/net/lib/Makefile index 0a6cd733883d..2b77d960d91a 100644 --- a/tools/testing/selftests/net/lib/Makefile +++ b/tools/testing/selftests/net/lib/Makefile @@ -35,7 +35,7 @@ include ../../lib.mk BPF_PROG_DIRS := xsk include ../bpf.mk -# AF_XDP test engine used by net/test_xsk.sh. +# AF_XDP test engine. XSK_SRCS := $(filter-out %.bpf.c,$(wildcard xsk/*.c)) \ $(top_srcdir)/tools/lib/find_bit.c diff --git a/tools/testing/selftests/net/lib/xsk/xskxceiver.c b/tools/testing/selftests/net/lib/xsk/xskxceiver.c index 97eece4c57f8..42fb3149ca6b 100644 --- a/tools/testing/selftests/net/lib/xsk/xskxceiver.c +++ b/tools/testing/selftests/net/lib/xsk/xskxceiver.c @@ -6,9 +6,6 @@ * Linux kernel samples/bpf/xdpsock* and modified * for use. * - * See test_xsk.sh for detailed information on test topology - * and prerequisite network setup. - * * This 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. @@ -64,11 +61,6 @@ * - Tx thread Transmits a number of packets from veth to veth * - Rx thread verifies if all packets were received and delivered in-order, * and have the right content - * - * Enable/disable packet dump mode: - * -------------------------- - * To enable L2 - L4 headers and payload dump of each packet on STDOUT, add - * parameter -D to params array in test_xsk.sh, i.e. params=("-S" "-D") */ #define _GNU_SOURCE @@ -169,14 +161,14 @@ static struct option long_options[] = { static void print_usage(char **argv) { const char *str = - " Usage: xskxceiver [OPTIONS]\n" + " Usage: %s -i TX_IFACE -i RX_IFACE -m MODE -t TEST [OPTIONS]\n" " Options:\n" " -i, --interface Use interface\n" " -v, --verbose Verbose output\n" " -b, --busy-poll Enable busy poll\n" - " -m, --mode Run only mode skb, drv, or zc\n" + " -m, --mode Mode to run: skb, drv or zc\n" " -l, --list List all available tests\n" - " -t, --test Run a specific test. Enter number from -l option.\n" + " -t, --test Test case to run, a number from -l\n" " -h, --help Display this help and exit\n"; ksft_print_msg(str, basename(argv[0])); @@ -267,6 +259,9 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj } } + if (opt_run_test == RUN_ALL_TESTS || opt_mode == TEST_MODE_ALL) + print_usage(argv); + bind_iface(ifobj_tx, ifname[0], worker_testapp_validate_tx, argv); bind_iface(ifobj_rx, ifname[1], worker_testapp_validate_rx, argv); } @@ -365,10 +360,9 @@ int main(int argc, char **argv) u32 cache_line_size, max_frags, umem_tailroom; const size_t total_tests = ARRAY_SIZE(tests); struct ifobject *ifobj_tx, *ifobj_rx; - u32 i, j, failed_tests = 0, nb_tests; struct test_spec test = {}; int ret = TEST_FAILURE; - u32 caps, modes = 0; + u32 caps; /* Use libbpf 1.0 API mode */ libbpf_set_strict_mode(LIBBPF_STRICT_ALL); @@ -419,40 +413,18 @@ int main(int argc, char **argv) caps = detect_mode_caps(ifobj_tx); - if (opt_mode != TEST_MODE_ALL && !mode_supported(opt_mode, caps)) { + if (!mode_supported(opt_mode, caps)) { if (opt_mode == TEST_MODE_DRV) - ksft_print_msg("Error: XDP_DRV mode not supported.\n"); + ksft_print_msg("XDP_DRV mode not supported.\n"); else - ksft_print_msg("Error: zero-copy mode not supported.\n"); - ksft_exit_xfail(); + ksft_print_msg("zero-copy mode not supported.\n"); + ret = TEST_SKIP; + goto out; } - for (i = TEST_MODE_SKB; i <= TEST_MODE_ZC; i++) - if ((opt_mode == TEST_MODE_ALL || i == opt_mode) && mode_supported(i, caps)) - modes++; - if (opt_run_test == RUN_ALL_TESTS) - nb_tests = total_tests; - else - nb_tests = 1; - ksft_set_plan(modes * nb_tests); - - for (i = TEST_MODE_SKB; i <= TEST_MODE_ZC; i++) { - if (opt_mode != TEST_MODE_ALL && i != opt_mode) - continue; - if (!mode_supported(i, caps)) - continue; - - for (j = 0; j < total_tests; j++) { - if (opt_run_test != RUN_ALL_TESTS && j != opt_run_test) - continue; - - test_init(&test, ifobj_tx, ifobj_rx, i, &tests[j]); - if (run_pkt_test(&test) == TEST_FAILURE) - failed_tests++; - usleep(USLEEP_MAX); - } - } - ret = failed_tests ? TEST_FAILURE : TEST_PASS; + ksft_set_plan(1); + test_init(&test, ifobj_tx, ifobj_rx, opt_mode, &tests[opt_run_test]); + ret = run_pkt_test(&test); out: cleanup_iface(ifobj_tx); @@ -462,6 +434,12 @@ int main(int argc, char **argv) ifobject_delete(ifobj_tx); ifobject_delete(ifobj_rx); + if (ret == TEST_SKIP && ksft_test_num()) { + ksft_print_cnts(); + return KSFT_SKIP; + } + if (ret == TEST_SKIP) + ksft_exit_skip("mode not supported\n"); if (ret) ksft_exit_fail(); else diff --git a/tools/testing/selftests/net/test_xsk.sh b/tools/testing/selftests/net/test_xsk.sh deleted file mode 100755 index fbf4551d596a..000000000000 --- a/tools/testing/selftests/net/test_xsk.sh +++ /dev/null @@ -1,230 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-2.0 -# Copyright(c) 2020 Intel Corporation, Weqaar Janjua - -# AF_XDP selftests based on veth -# -# End-to-end AF_XDP over Veth test -# -# Topology: -# --------- -# ----------- -# _ | Process | _ -# / ----------- \ -# / | \ -# / | \ -# ----------- | ----------- -# | Thread1 | | | Thread2 | -# ----------- | ----------- -# | | | -# ----------- | ----------- -# | xskX | | | xskY | -# ----------- | ----------- -# | | | -# ----------- | ---------- -# | vethX | --------- | vethY | -# ----------- peer ---------- -# -# AF_XDP is an address family optimized for high performance packet processing, -# it is XDP’s user-space interface. -# -# An AF_XDP socket is linked to a single UMEM which is a region of virtual -# contiguous memory, divided into equal-sized frames. -# -# Refer to AF_XDP Kernel Documentation for detailed information: -# https://www.kernel.org/doc/html/latest/networking/af_xdp.html -# -# Prerequisites setup by script: -# -# Set up veth interfaces as per the topology shown ^^: -# * setup two veth interfaces -# ** veth -# ** veth -# *** xxxx and yyyy are randomly generated 4 digit numbers used to avoid -# conflict with any existing interface -# * tests the veth and xsk layers of the topology -# -# See the source xskxceiver.c for information on each test -# -# Kernel configuration: -# --------------------- -# See "config" file for recommended kernel config options. -# -# Turn on XDP sockets and veth support when compiling i.e. -# Networking support --> -# Networking options --> -# [ * ] XDP sockets -# -# Executing Tests: -# ---------------- -# Must run with CAP_NET_ADMIN capability. -# -# Run: -# sudo ./test_xsk.sh -# -# If running from kselftests: -# sudo make run_tests -# -# Run with verbose output: -# sudo ./test_xsk.sh -v -# -# Set up veth interfaces and leave them up so xskxceiver can be launched in a debugger: -# sudo ./test_xsk.sh -d -# -# Run test suite in a specific mode only [skb,drv,zc] -# sudo ./test_xsk.sh -m MODE -# -# List available tests -# ./test_xsk.sh -l -# -# Run a specific test from the test suite -# sudo ./test_xsk.sh -t TEST_NAME -# -# Display the available command line options -# ./test_xsk.sh -h - -. xsk_prereqs.sh - -while getopts "vdm:lt:h" flag -do - case "${flag}" in - v) verbose=1;; - d) debug=1;; - m) MODE=${OPTARG};; - l) list=1;; - t) TEST=${OPTARG};; - h) help=1;; - esac -done - -if [ ! -x "./${XSKOBJ}" ]; then - echo "xskxceiver was not built; skipping" - exit $ksft_skip -fi - -TEST_NAME="PREREQUISITES" - -URANDOM=/dev/urandom -[ ! -e "${URANDOM}" ] && { echo "${URANDOM} not found. Skipping tests."; test_exit $ksft_fail; } - -VETH0_POSTFIX=$(cat ${URANDOM} | tr -dc '0-9' | fold -w 256 | head -n 1 | head --bytes 4) -VETH0=ve${VETH0_POSTFIX} -VETH1_POSTFIX=$(cat ${URANDOM} | tr -dc '0-9' | fold -w 256 | head -n 1 | head --bytes 4) -VETH1=ve${VETH1_POSTFIX} -MTU=1500 - -trap ctrl_c INT - -function ctrl_c() { - cleanup_exit ${VETH0} ${VETH1} - exit 1 -} - -setup_vethPairs() { - if [[ $verbose -eq 1 ]]; then - echo "setting up ${VETH0}" - fi - ip link add ${VETH0} numtxqueues 4 numrxqueues 4 type veth peer name ${VETH1} numtxqueues 4 numrxqueues 4 - if [ -f /proc/net/if_inet6 ]; then - echo 1 > /proc/sys/net/ipv6/conf/${VETH0}/disable_ipv6 - echo 1 > /proc/sys/net/ipv6/conf/${VETH1}/disable_ipv6 - fi - if [[ $verbose -eq 1 ]]; then - echo "setting up ${VETH1}" - fi - - if [[ $busy_poll -eq 1 ]]; then - echo 2 > /sys/class/net/${VETH0}/napi_defer_hard_irqs - echo 200000 > /sys/class/net/${VETH0}/gro_flush_timeout - echo 2 > /sys/class/net/${VETH1}/napi_defer_hard_irqs - echo 200000 > /sys/class/net/${VETH1}/gro_flush_timeout - fi - - ip link set ${VETH1} mtu ${MTU} - ip link set ${VETH0} mtu ${MTU} - ip link set ${VETH1} up - ip link set ${VETH0} up -} - -if [[ $list -eq 1 ]]; then - ./${XSKOBJ} -l - exit -fi - -if [[ $help -eq 1 ]]; then - ./${XSKOBJ} - exit -fi - -validate_root_exec -validate_veth_support ${VETH0} -validate_ip_utility -setup_vethPairs - -retval=$? -if [ $retval -ne 0 ]; then - test_status $retval "${TEST_NAME}" - cleanup_exit ${VETH0} ${VETH1} - exit $retval -fi - - -if [[ $verbose -eq 1 ]]; then - ARGS+="-v " -fi - -if [ -n "$MODE" ]; then - ARGS+="-m ${MODE} " -fi - -if [ -n "$TEST" ]; then - ARGS+="-t ${TEST} " -fi - -retval=$? -test_status $retval "${TEST_NAME}" - -## START TESTS - -statusList=() - -TEST_NAME="XSK_SELFTESTS_${VETH0}_SOFTIRQ" - -if [[ $debug -eq 1 ]]; then - echo "-i" ${VETH0} "-i" ${VETH1} - exit -fi - -exec_xskxceiver - -cleanup_exit ${VETH0} ${VETH1} - -if [[ $list -eq 1 ]]; then - exit -fi - -TEST_NAME="XSK_SELFTESTS_${VETH0}_BUSY_POLL" -busy_poll=1 - -setup_vethPairs -exec_xskxceiver - -## END TESTS - -cleanup_exit ${VETH0} ${VETH1} - -failures=0 -echo -e "\nSummary:" -for i in "${!statusList[@]}" -do - if [ ${statusList[$i]} -ne 0 ]; then - test_status ${statusList[$i]} ${nameList[$i]} - failures=1 - fi -done - -if [ $failures -eq 0 ]; then - echo "All tests successful!" -else - exit 1 -fi diff --git a/tools/testing/selftests/net/xsk_prereqs.sh b/tools/testing/selftests/net/xsk_prereqs.sh deleted file mode 100755 index 5e5c8ef3fff2..000000000000 --- a/tools/testing/selftests/net/xsk_prereqs.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-2.0 -# Copyright(c) 2020 Intel Corporation. - -ksft_pass=0 -ksft_fail=1 -ksft_xfail=2 -ksft_xpass=3 -ksft_skip=4 - -XSKOBJ=lib/xskxceiver - -validate_root_exec() -{ - msg="skip all tests:" - if [ $UID != 0 ]; then - echo $msg must be run as root >&2 - test_exit $ksft_fail - else - return $ksft_pass - fi -} - -validate_veth_support() -{ - msg="skip all tests:" - if [ $(ip link add $1 type veth 2>/dev/null; echo $?;) != 0 ]; then - echo $msg veth kernel support not available >&2 - test_exit $ksft_skip - else - ip link del $1 - return $ksft_pass - fi -} - -test_status() -{ - statusval=$1 - if [ $statusval -eq $ksft_fail ]; then - echo "$2: [ FAIL ]" - elif [ $statusval -eq $ksft_skip ]; then - echo "$2: [ SKIPPED ]" - elif [ $statusval -eq $ksft_pass ]; then - echo "$2: [ PASS ]" - fi -} - -test_exit() -{ - if [ $1 -ne 0 ]; then - test_status $1 $(basename $0) - fi - exit 1 -} - -clear_configs() -{ - [ $(ip link show $1 &>/dev/null; echo $?;) == 0 ] && - { ip link del $1; } -} - -cleanup_exit() -{ - clear_configs $1 $2 -} - -validate_ip_utility() -{ - [ ! $(type -P ip) ] && { echo "'ip' not found. Skipping tests."; test_exit $ksft_skip; } -} - -exec_xskxceiver() -{ - if [[ $busy_poll -eq 1 ]]; then - ARGS+="-b " - fi - - ./${XSKOBJ} -i ${VETH0} -i ${VETH1} ${ARGS} - retval=$? - - if [[ $list -ne 1 ]]; then - test_status $retval "${TEST_NAME}" - statusList+=($retval) - nameList+=(${TEST_NAME}) - fi -} -- 2.43.0