From: Tianyi Gao <tianyi@cloudflare.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, toke@redhat.com,
lorenzo@kernel.org, horms@kernel.org, bpf@vger.kernel.org,
shuah@kernel.org, hawk@kernel.org, kernel-team@cloudflare.com,
ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
sdf@fomichev.me, linux-kselftest@vger.kernel.org,
jiayuan.chen@linux.dev, Tianyi Gao <tianyi@cloudflare.com>
Subject: [PATCH net-next 3/3] selftests: net: veth: test RX queue NAPI links
Date: Thu, 5 Nov 2026 14:33:56 +0000 [thread overview]
Message-ID: <20261105143356.17062-4-tianyi@cloudflare.com> (raw)
In-Reply-To: <20261105143356.17062-1-tianyi@cloudflare.com>
Check that the napi-id of every RX queue matches a NAPI instance of the
device. Also check that the queues are linked only while NAPI is
enabled. Run the checks with GRO on and with XDP attached, and across RX
channel changes and link down/up.
queue-get and napi-get are only visible through netlink. Read them with
the ynl CLI, as the ndo-xmit checks do. Compare the results with jq.
Skip the checks if the ynl CLI or jq is not found.
Signed-off-by: Tianyi Gao <tianyi@cloudflare.com>
---
tools/testing/selftests/net/veth.sh | 79 ++++++++++++++++++++++++++++-
1 file changed, 78 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
index 17cfe412a266..affcdbf772b3 100755
--- a/tools/testing/selftests/net/veth.sh
+++ b/tools/testing/selftests/net/veth.sh
@@ -107,6 +107,44 @@ chk_xdp_feature() {
fi
}
+chk_queue_napi() {
+ local msg="$1"
+ local target=$2
+ local expected=$3
+ local ns=$BASE$target
+ local ifindex
+ local queues
+ local napis
+ local st
+ local linked
+
+ ifindex=`ip netns exec $ns cat /sys/class/net/veth$target/ifindex`
+ queues=`ip netns exec $ns "$YNL" --family netdev --dump queue-get \
+ --output-json --json "{\"ifindex\": $ifindex}" 2>&1`
+ st=$?
+ napis=`ip netns exec $ns "$YNL" --family netdev --dump napi-get \
+ --output-json --json "{\"ifindex\": $ifindex}" 2>&1` || st=$?
+
+ printf "%-60s" "$msg"
+ if [ $st -ne 0 ]; then
+ echo " fail - ynl cli error: $queues $napis"
+ ret=1
+ return
+ fi
+
+ queues=`echo "$queues" | \
+ jq -c 'map(select(.type == "rx") | ."napi-id" // empty) | sort'`
+ napis=`echo "$napis" | jq -c 'map(.id) | sort'`
+ linked=`echo "$queues" | jq length`
+
+ if [ "$queues" = "$napis" ] && [ "$linked" = "$expected" ]; then
+ echo " ok "
+ else
+ echo " fail - expected $expected found $queues napis $napis"
+ ret=1
+ fi
+}
+
chk_channels() {
local msg="$1"
local target=$2
@@ -255,7 +293,8 @@ fi
[ $CPUS -lt 2 ] && echo "Only one CPU available, some tests will be skipped"
[ $STRESS -gt 0 -a $CPUS -lt 3 ] && echo " stress test will be skipped, too"
-[ ! -f "$YNL" ] && echo "ynl cli not found, ndo-xmit tests will be skipped"
+[ ! -f "$YNL" ] && echo "ynl cli not found, ndo-xmit/napi tests will be skipped"
+[ ! -x "$(command -v jq)" ] && echo "jq not found, napi tests will be skipped"
create_ns
chk_gro_flag "default - gro flag" $SRC off
@@ -364,6 +403,44 @@ else
fi
cleanup
+if [ -f "$YNL" ] && [ -x "$(command -v jq)" ]; then
+ create_ns
+ RXQ=1
+ if [ $CPUS -gt 1 ]; then
+ ip netns exec $NS_DST ethtool -L veth$DST rx 2
+ RXQ=2
+ fi
+ chk_queue_napi "queue napi - default" $DST 0
+ ip netns exec $NS_DST ethtool -K veth$DST gro on
+ chk_queue_napi " - with gro on" $DST $RXQ
+ if [ $CPUS -gt 1 ]; then
+ ip netns exec $NS_DST ethtool -L veth$DST rx 1
+ chk_queue_napi " - fewer rx channels with gro" $DST 1
+ ip netns exec $NS_DST ethtool -L veth$DST rx 2
+ chk_queue_napi " - more rx channels with gro" $DST 2
+ fi
+ ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} section xdp
+ chk_queue_napi " - with gro and xdp on" $DST $RXQ
+ ip -n $NS_DST link set dev veth$DST xdp off
+ chk_queue_napi " - after xdp off with gro on" $DST $RXQ
+ ip netns exec $NS_DST ethtool -K veth$DST gro off
+ chk_queue_napi " - after gro off" $DST 0
+ ip -n $NS_DST link set dev veth$DST xdp object ${BPF_FILE} section xdp
+ chk_queue_napi " - with xdp on" $DST $RXQ
+ if [ $CPUS -gt 1 ]; then
+ ip netns exec $NS_DST ethtool -L veth$DST rx 1
+ chk_queue_napi " - fewer rx channels with xdp" $DST 1
+ ip netns exec $NS_DST ethtool -L veth$DST rx 2
+ chk_queue_napi " - more rx channels with xdp" $DST 2
+ fi
+ ip -n $NS_DST link set dev veth$DST down
+ ip -n $NS_DST link set dev veth$DST up
+ chk_queue_napi " - after down and up" $DST $RXQ
+ ip -n $NS_DST link set dev veth$DST xdp off
+ chk_queue_napi " - after xdp off" $DST 0
+ cleanup
+fi
+
create_ns
CUR_TX=1
--
2.56.0
prev parent reply other threads:[~2026-11-05 14:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 14:33 [PATCH net-next 0/3] veth: link RX queues to their NAPI instances Tianyi Gao
2026-11-05 14:33 ` [PATCH net-next 1/3] veth: refactor NAPI enable paths Tianyi Gao
2026-11-05 14:33 ` [PATCH net-next 2/3] veth: link RX queues to their NAPI instances Tianyi Gao
2026-11-05 14:33 ` Tianyi Gao [this message]
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=20261105143356.17062-4-tianyi@cloudflare.com \
--to=tianyi@cloudflare.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=jiayuan.chen@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=toke@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox