]> git.itanic.dy.fi Git - linux-stable/commitdiff
selftests: forwarding: ethtool_mm: fall back to aggregate if device does not report...
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 19 Dec 2023 10:57:57 +0000 (12:57 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 23 Dec 2023 01:01:19 +0000 (01:01 +0000)
Some devices do not support individual 'pmac' and 'emac' stats.
For such devices, resort to 'aggregate' stats.

Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Roger Quadros <rogerq@kernel.org>
Signed-off-by: Roger Quadros <rogerq@kernel.org>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/ethtool_mm.sh
tools/testing/selftests/net/forwarding/lib.sh

index 6212913f4ad1b6e6b10c9340370a632ca447d9ee..50d5bfb17ef184a9d74408ccc596cf828a3064a5 100755 (executable)
@@ -25,6 +25,10 @@ traffic_test()
        local after=
        local delta=
 
+       if [ ${has_pmac_stats[$if]} = false ]; then
+               src="aggregate"
+       fi
+
        before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
 
        $MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
@@ -317,6 +321,13 @@ for netif in ${NETIFS[@]}; do
                echo "SKIP: $netif does not support MAC Merge"
                exit $ksft_skip
        fi
+
+       if check_ethtool_pmac_std_stats_support $netif eth-mac; then
+               has_pmac_stats[$netif]=true
+       else
+               has_pmac_stats[$netif]=false
+               echo "$netif does not report pMAC statistics, falling back to aggregate"
+       fi
 done
 
 trap cleanup EXIT
index e3740163c384fdfaa9e9b29a6ca79e1295d688e9..69ef2a40df21b2f5dfeef49a5bdf98d11e846334 100755 (executable)
@@ -155,6 +155,15 @@ check_ethtool_counter_group_support()
        fi
 }
 
+check_ethtool_pmac_std_stats_support()
+{
+       local dev=$1; shift
+       local grp=$1; shift
+
+       [ 0 -ne $(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null \
+               | jq ".[].\"$grp\" | length") ]
+}
+
 check_locked_port_support()
 {
        if ! bridge -d link show | grep -q " locked"; then