aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/net/forwarding/lib.sh
diff options
context:
space:
mode:
authorPetr Machata <petrm@nvidia.com>2022-05-08 11:08:22 +0300
committerDavid S. Miller <davem@davemloft.net>2022-05-08 11:46:20 +0100
commit32fb67a3e7a65171cd790ff0e65fcee49cae7cf5 (patch)
tree5814a2b4eed84e3c394de3d7c95f70c1a77036a8 /tools/testing/selftests/net/forwarding/lib.sh
parentmlxsw: spectrum_router: Take router lock in router notifier handler (diff)
downloadlinux-32fb67a3e7a65171cd790ff0e65fcee49cae7cf5.tar.xz
linux-32fb67a3e7a65171cd790ff0e65fcee49cae7cf5.zip
selftests: lib: Add a generic helper for obtaining HW stats
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/forwarding/lib.sh')
-rwxr-xr-xtools/testing/selftests/net/forwarding/lib.sh11
1 files changed, 11 insertions, 0 deletions
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