Netdev List
 help / color / mirror / Atom feed
From: Hangbin Liu <hangbin.liu@linux.dev>
To: Jakub Kicinski <kuba@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>
Cc: Hangbin Liu <hangbin.liu@linux.dev>,
	netdev@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	 Hangbin Liu <liuhangbin@kylinos.cn>
Subject: [PATCH net-next 2/2] selftests: netdevsim: add speed testing
Date: Mon, 31 Aug 2026 11:28:11 +0800	[thread overview]
Message-ID: <20260831-nsim_speed-v1-2-7a651ee65738@kylinos.cn> (raw)
In-Reply-To: <20260831-nsim_speed-v1-0-7a651ee65738@kylinos.cn>

From: Hangbin Liu <liuhangbin@kylinos.cn>

Add a script for netdevsim speed test. Make sure the speed and duplex
could be changed. And the speed can't be larger than the max speed.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
 .../selftests/drivers/net/netdevsim/Makefile       |  1 +
 .../drivers/net/netdevsim/ethtool-speed.sh         | 33 ++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/tools/testing/selftests/drivers/net/netdevsim/Makefile b/tools/testing/selftests/drivers/net/netdevsim/Makefile
index 9808c2fbae9e..bd3d0f5ee07a 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-speed.sh \
 	fib.sh \
 	fib_notifications.sh \
 	hw_stats_l3.sh \
diff --git a/tools/testing/selftests/drivers/net/netdevsim/ethtool-speed.sh b/tools/testing/selftests/drivers/net/netdevsim/ethtool-speed.sh
new file mode 100755
index 000000000000..c8aefa9c8a1f
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/netdevsim/ethtool-speed.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-only
+
+source ethtool-common.sh
+
+NSIM_NETDEV=$(make_netdev)
+
+set -o pipefail
+
+s=$(ethtool --json "$NSIM_NETDEV" | jq '.[].speed')
+check $? "$s" "5000"
+
+s=$(ethtool --json "$NSIM_NETDEV" | jq -r '.[].duplex')
+check $? "$s" "Full"
+
+ethtool -s "$NSIM_NETDEV" speed 1000 duplex half
+
+s=$(ethtool --json "$NSIM_NETDEV" | jq '.[].speed')
+check $? "$s" "1000"
+
+s=$(ethtool --json "$NSIM_NETDEV" | jq -r '.[].duplex')
+check $? "$s" "Half"
+
+ethtool -s "$NSIM_NETDEV" speed 10000 2>/dev/null
+check $? "" "" 1
+
+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.55.0


  parent reply	other threads:[~2026-08-31  3:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31  3:28 [PATCH net-next 0/2] netdevsim: add link speed support Hangbin Liu
2026-08-31  3:28 ` [PATCH net-next 1/2] " Hangbin Liu
2026-08-31 12:16   ` Andrew Lunn
2026-09-01  6:39     ` Hangbin Liu
2026-09-01 12:43       ` Andrew Lunn
2026-09-02  1:53         ` Hangbin Liu
2026-09-02 12:38           ` Andrew Lunn
2026-08-31 12:24   ` Andrew Lunn
2026-09-01  6:31     ` Hangbin Liu
2026-08-31 22:08   ` Jakub Kicinski
2026-09-01  6:58     ` Hangbin Liu
2026-09-01  8:23       ` Hangbin Liu
2026-09-01 14:21         ` Andrew Lunn
2026-09-02  2:01           ` Hangbin Liu
2026-09-02 12:49             ` Andrew Lunn
2026-09-01 14:18       ` Andrew Lunn
2026-08-31  3:28 ` Hangbin Liu [this message]
2026-08-31 22:06   ` [PATCH net-next 2/2] selftests: netdevsim: add speed testing Jakub Kicinski
2026-09-01  6:42     ` Hangbin Liu
2026-09-01 15:06       ` Jakub Kicinski
2026-09-02  2:04         ` Hangbin Liu

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=20260831-nsim_speed-v1-2-7a651ee65738@kylinos.cn \
    --to=hangbin.liu@linux.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=liuhangbin@kylinos.cn \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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