Even though pause frame statistics are not exported through the same
ethtool command, there is no point in adding another helper just for
them. Extent the ethtool_std_stats_get() function so that we are able to
interrogate using the same helper all the standard statistics.

And since we are touching the function, convert the initial ethtool call
as well to the jq --arg form in order to be easier to read.

Signed-off-by: Ioana Ciornei <[email protected]>
Reviewed-by: Petr Machata <[email protected]>
---
Changes in v4:
- wrap the lines to max 80 chars
- replace the if-else with a simple if and return in order to be easier
  to maintain the 80 chars limit.
Changes in v3:
- none
Changes in v2:
- convert jq to the --arg usage form

 tools/testing/selftests/net/forwarding/lib.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh 
b/tools/testing/selftests/net/forwarding/lib.sh
index a9034f0bb58b..3009ce00c5dc 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -831,8 +831,14 @@ ethtool_std_stats_get()
        local name=$1; shift
        local src=$1; shift
 
-       ethtool --json -S $dev --groups $grp -- --src $src | \
-               jq '.[]."'"$grp"'"."'$name'"'
+       if [[ "$grp" == "pause" ]]; then
+               ethtool -I --json -a "$dev" --src "$src" | \
+                       jq --arg name "$name" '.[].statistics[$name]'
+               return
+       fi
+
+       ethtool --json -S "$dev" --groups "$grp" -- --src "$src" | \
+               jq --arg grp "$grp" --arg name "$name" '.[][$grp][$name]'
 }
 
 qdisc_stats_get()
-- 
2.25.1


Reply via email to