From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, petrm@nvidia.com, mlxsw@nvidia.com,
Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 09/10] selftests: lib: Add a generic helper for obtaining HW stats
Date: Sun, 8 May 2022 11:08:22 +0300 [thread overview]
Message-ID: <20220508080823.32154-10-idosch@nvidia.com> (raw)
In-Reply-To: <20220508080823.32154-1-idosch@nvidia.com>
From: Petr Machata <petrm@nvidia.com>
The function get_l3_stats() from the test hw_stats_l3.sh will be useful for
any test that wishes to work with L3 stats. Furthermore, it is easy to
generalize to other HW stats suites (for when such are added). Therefore,
move the code to lib.sh, rewrite it to have the same interface as the other
stats-collecting functions, and generalize to take the name of the HW stats
suite to collect as an argument.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
.../selftests/net/forwarding/hw_stats_l3.sh | 16 ++++------------
tools/testing/selftests/net/forwarding/lib.sh | 11 +++++++++++
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/tools/testing/selftests/net/forwarding/hw_stats_l3.sh b/tools/testing/selftests/net/forwarding/hw_stats_l3.sh
index 1c11c4256d06..9c1f76e108af 100755
--- a/tools/testing/selftests/net/forwarding/hw_stats_l3.sh
+++ b/tools/testing/selftests/net/forwarding/hw_stats_l3.sh
@@ -162,14 +162,6 @@ ping_ipv6()
ping_test $h1.200 2001:db8:2::1 " IPv6"
}
-get_l3_stat()
-{
- local selector=$1; shift
-
- ip -j stats show dev $rp1.200 group offload subgroup l3_stats |
- jq '.[0].stats64.'$selector
-}
-
send_packets_rx_ipv4()
{
# Send 21 packets instead of 20, because the first one might trap and go
@@ -208,11 +200,11 @@ ___test_stats()
local a
local b
- a=$(get_l3_stat ${dir}.packets)
+ a=$(hw_stats_get l3_stats $rp1.200 ${dir} packets)
send_packets_${dir}_${prot}
"$@"
b=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $a + 20" \
- get_l3_stat ${dir}.packets)
+ hw_stats_get l3_stats $rp1.200 ${dir} packets)
check_err $? "Traffic not reflected in the counter: $a -> $b"
}
@@ -281,11 +273,11 @@ __test_stats_report()
RET=0
- a=$(get_l3_stat ${dir}.packets)
+ a=$(hw_stats_get l3_stats $rp1.200 ${dir} packets)
send_packets_${dir}_${prot}
ip address flush dev $rp1.200
b=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $a + 20" \
- get_l3_stat ${dir}.packets)
+ hw_stats_get l3_stats $rp1.200 ${dir} packets)
check_err $? "Traffic not reflected in the counter: $a -> $b"
log_test "Test ${dir} packets: stats pushed on loss of L3"
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 66681a2bcdd3..37ae49d47853 100755
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -828,6 +828,17 @@ ipv6_stats_get()
cat /proc/net/dev_snmp6/$dev | grep "^$stat" | cut -f2
}
+hw_stats_get()
+{
+ local suite=$1; shift
+ local if_name=$1; shift
+ local dir=$1; shift
+ local stat=$1; shift
+
+ ip -j stats show dev $if_name group offload subgroup $suite |
+ jq ".[0].stats64.$dir.$stat"
+}
+
humanize()
{
local speed=$1; shift
--
2.35.1
next prev parent reply other threads:[~2022-05-08 8:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-08 8:08 [PATCH net-next 00/10] mlxsw: A dedicated notifier block for router code Ido Schimmel
2022-05-08 8:08 ` [PATCH net-next 01/10] mlxsw: spectrum: Tolerate enslaving of various devices to VRF Ido Schimmel
2022-05-08 8:08 ` [PATCH net-next 02/10] mlxsw: spectrum_router: Add a dedicated notifier block Ido Schimmel
2022-05-08 8:08 ` [PATCH net-next 03/10] mlxsw: spectrum: Move handling of VRF events to router code Ido Schimmel
2022-05-08 8:08 ` [PATCH net-next 04/10] mlxsw: spectrum: Move handling of HW stats " Ido Schimmel
2022-05-08 8:08 ` [PATCH net-next 05/10] mlxsw: spectrum: Move handling of router " Ido Schimmel
2022-05-08 8:08 ` [PATCH net-next 06/10] mlxsw: spectrum: Move handling of tunnel " Ido Schimmel
2022-05-08 8:08 ` [PATCH net-next 07/10] mlxsw: spectrum: Update a comment Ido Schimmel
2022-05-08 8:08 ` [PATCH net-next 08/10] mlxsw: spectrum_router: Take router lock in router notifier handler Ido Schimmel
2022-05-08 8:08 ` Ido Schimmel [this message]
2022-05-08 8:08 ` [PATCH net-next 10/10] selftests: forwarding: Add a tunnel-based test for L3 HW stats Ido Schimmel
2022-05-08 10:50 ` [PATCH net-next 00/10] mlxsw: A dedicated notifier block for router code 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=20220508080823.32154-10-idosch@nvidia.com \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=mlxsw@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.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;
as well as URLs for NNTP newsgroup(s).