public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Björn Töpel" <bjorn@kernel.org>
To: Michael Chan <michael.chan@broadcom.com>,
	Pavan Chebbi <pavan.chebbi@broadcom.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Cc: "Björn Töpel" <bjorn@kernel.org>,
	"Willem de Bruijn" <willemb@google.com>
Subject: [PATCH net-next 4/5] selftests: netdevsim: Add RSS indirection table resize test
Date: Tue,  3 Mar 2026 19:15:32 +0100	[thread overview]
Message-ID: <20260303181535.2671734-5-bjorn@kernel.org> (raw)
In-Reply-To: <20260303181535.2671734-1-bjorn@kernel.org>

Test fold/unfold of RSS indirection tables on channel changes
using netdevsim:

 - default table regenerates on channel change
 - periodic table folds on shrink and unfolds on grow
 - non-periodic table blocks channel reduction
 - non-default RSS context resizes on channel change
 - non-periodic non-default context blocks fold
 - table and channel count unchanged after failed reduction

Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
 .../selftests/drivers/net/netdevsim/Makefile  |   1 +
 .../drivers/net/netdevsim/ethtool-rss.sh      | 123 ++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100755 tools/testing/selftests/drivers/net/netdevsim/ethtool-rss.sh

diff --git a/tools/testing/selftests/drivers/net/netdevsim/Makefile b/tools/testing/selftests/drivers/net/netdevsim/Makefile
index 1a228c5430f5..d764d08dff1a 100644
--- a/tools/testing/selftests/drivers/net/netdevsim/Makefile
+++ b/tools/testing/selftests/drivers/net/netdevsim/Makefile
@@ -8,6 +8,7 @@ TEST_PROGS := \
 	ethtool-features.sh \
 	ethtool-fec.sh \
 	ethtool-pause.sh \
+	ethtool-rss.sh \
 	fib.sh \
 	fib_notifications.sh \
 	hw_stats_l3.sh \
diff --git a/tools/testing/selftests/drivers/net/netdevsim/ethtool-rss.sh b/tools/testing/selftests/drivers/net/netdevsim/ethtool-rss.sh
new file mode 100755
index 000000000000..1c1876f888ba
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/netdevsim/ethtool-rss.sh
@@ -0,0 +1,123 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Test RSS indirection table resize on channel count changes.
+# Exercises ethtool_rxfh_indir_resize() and
+# ethtool_rxfh_contexts_resize_all() via netdevsim.
+
+source ethtool-common.sh
+
+# Create device with 8 queues
+NSIM_NETDEV=$(make_netdev 1 8)
+
+set -o pipefail
+
+# --- Test 1: Default table regenerates on channel change ---
+s=$(ethtool --json -x $NSIM_NETDEV | jq '.[0]["rss-indirection-table"] | length')
+check $? "$s" "128" # roundup_pow_of_two(8) * 16 = 128
+
+ethtool -L $NSIM_NETDEV combined 2
+s=$(ethtool --json -x $NSIM_NETDEV | jq '.[0]["rss-indirection-table"] | length')
+check $? "$s" "32" # roundup_pow_of_two(2) * 16 = 32
+
+ethtool -L $NSIM_NETDEV combined 8
+
+# --- Test 2: Periodic context 0 table folds on channel reduction ---
+ethtool -X $NSIM_NETDEV equal 2
+s=$(ethtool --json -x $NSIM_NETDEV | jq '[.[0]["rss-indirection-table"][]] | max')
+check $? "$s" "1"
+
+ethtool -L $NSIM_NETDEV combined 2
+s=$(ethtool --json -x $NSIM_NETDEV | jq '.[0]["rss-indirection-table"] | length')
+check $? "$s" "32"
+s=$(ethtool --json -x $NSIM_NETDEV | jq '[.[0]["rss-indirection-table"][]] | max')
+check $? "$s" "1"
+
+# Grow back — should unfold
+ethtool -L $NSIM_NETDEV combined 8
+s=$(ethtool --json -x $NSIM_NETDEV | jq '.[0]["rss-indirection-table"] | length')
+check $? "$s" "128"
+s=$(ethtool --json -x $NSIM_NETDEV | jq '[.[0]["rss-indirection-table"][]] | max')
+check $? "$s" "1"
+
+ethtool -X $NSIM_NETDEV default
+
+# --- Test 3: Non-periodic context 0 table blocks fold ---
+ethtool -X $NSIM_NETDEV equal 8
+
+ethtool -L $NSIM_NETDEV combined 2 2>/dev/null
+if [ $? -ne 0 ]; then
+    ((num_passes++))
+else
+    echo "Expected channel reduction to fail with non-periodic table"
+    ((num_errors++))
+fi
+
+ethtool -X $NSIM_NETDEV default
+
+# --- Test 4: Non-default context resizes on channel change ---
+ctx_id=$(ethtool -X $NSIM_NETDEV context new equal 2 2>/dev/null | awk '{print $NF}')
+if [ -z "$ctx_id" ]; then
+    echo "SKIP: context creation failed"
+else
+    s=$(ethtool --json -x $NSIM_NETDEV context $ctx_id | jq '.[0]["rss-indirection-table"] | length')
+    check $? "$s" "128"
+
+    ethtool -L $NSIM_NETDEV combined 2
+    s=$(ethtool --json -x $NSIM_NETDEV context $ctx_id | jq '.[0]["rss-indirection-table"] | length')
+    check $? "$s" "32"
+    s=$(ethtool --json -x $NSIM_NETDEV context $ctx_id | jq '[.[0]["rss-indirection-table"][]] | max')
+    check $? "$s" "1"
+
+    # Grow back
+    ethtool -L $NSIM_NETDEV combined 8
+    s=$(ethtool --json -x $NSIM_NETDEV context $ctx_id | jq '.[0]["rss-indirection-table"] | length')
+    check $? "$s" "128"
+    s=$(ethtool --json -x $NSIM_NETDEV context $ctx_id | jq '[.[0]["rss-indirection-table"][]] | max')
+    check $? "$s" "1"
+
+    ethtool -X $NSIM_NETDEV context $ctx_id delete
+fi
+
+# --- Test 5: Non-periodic non-default context blocks fold ---
+ctx_id=$(ethtool -X $NSIM_NETDEV context new equal 8 2>/dev/null | awk '{print $NF}')
+if [ -z "$ctx_id" ]; then
+    echo "SKIP: context creation failed"
+else
+    ethtool -L $NSIM_NETDEV combined 2 2>/dev/null
+    if [ $? -ne 0 ]; then
+        ((num_passes++))
+    else
+        echo "Expected channel reduction to fail with non-periodic context"
+        ((num_errors++))
+    fi
+
+    ethtool -X $NSIM_NETDEV context $ctx_id delete
+fi
+
+# --- Test 6: Table unchanged after failed channel reduction ---
+ethtool -X $NSIM_NETDEV equal 8
+s_before=$(ethtool --json -x $NSIM_NETDEV | jq '.[0]["rss-indirection-table"]')
+
+ethtool -L $NSIM_NETDEV combined 2 2>/dev/null
+s_after=$(ethtool --json -x $NSIM_NETDEV | jq '.[0]["rss-indirection-table"]')
+check $? "$s_after" "$s_before"
+
+ethtool -X $NSIM_NETDEV default
+
+# --- Test 7: Channel count unchanged after failed reduction ---
+ethtool -X $NSIM_NETDEV equal 8
+ethtool -L $NSIM_NETDEV combined 2 2>/dev/null
+s=$(ethtool --json -l $NSIM_NETDEV | jq '.[0]["combined-count"]')
+check $? "$s" "8"
+
+ethtool -X $NSIM_NETDEV default
+
+# --- Results ---
+if [ $num_errors -eq 0 ]; then
+    echo "PASSED all $((num_passes)) checks"
+    exit 0
+else
+    echo "FAILED $num_errors/$((num_errors+num_passes)) checks"
+    exit 1
+fi
-- 
2.53.0


  parent reply	other threads:[~2026-03-03 18:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 18:15 [PATCH net-next 0/5] ethtool: Dynamic RSS context indirection table resizing Björn Töpel
2026-03-03 18:15 ` [PATCH net-next 1/5] ethtool: Add RSS indirection table resize helpers Björn Töpel
2026-03-04  0:03   ` Jakub Kicinski
2026-03-04 11:37     ` Björn Töpel
2026-03-04 17:09       ` Jakub Kicinski
2026-03-03 18:15 ` [PATCH net-next 2/5] bnxt_en: Resize RSS contexts on channel count change Björn Töpel
2026-03-03 19:20   ` Michael Chan
2026-03-04 11:38     ` Björn Töpel
2026-03-04  0:05   ` Jakub Kicinski
2026-03-04 11:39     ` Björn Töpel
2026-03-03 18:15 ` [PATCH net-next 3/5] netdevsim: Add RSS context support with dynamic table sizing Björn Töpel
2026-03-04  0:07   ` Jakub Kicinski
2026-03-04 11:40     ` Björn Töpel
2026-03-03 18:15 ` Björn Töpel [this message]
2026-03-04  0:07   ` [PATCH net-next 4/5] selftests: netdevsim: Add RSS indirection table resize test Jakub Kicinski
2026-03-03 18:15 ` [PATCH net-next 5/5] selftests: rss_drv: Add RSS indirection table resize tests Björn Töpel
2026-03-04  0:16   ` Jakub Kicinski
2026-03-04  8:23 ` [PATCH net-next 0/5] ethtool: Dynamic RSS context indirection table resizing Pavan Chebbi

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=20260303181535.2671734-5-bjorn@kernel.org \
    --to=bjorn@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=willemb@google.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