Subject: Re: [PATCH net-next v4 10/10] selftests: drivers: hw: add test for the ethtool standard counters

From: Petr Machata <[email-masked]>
Date: Mon, 30 Mar 2026 14:03:35 +0200

Ioana Ciornei <[email-masked]> writes:

> Add a new selftest - ethtool_std_stats.sh - which validates the
> eth-ctrl, eth-mac and pause standard statistics exported by an
> interface. Collision related eth-mac counters as well as the error ones
> will be checked against zero since that is the most likely correct
> scenario.
>
> The central part of this patch is the traffic_test() function which
> gathers the 'before' counter values, sends a batch of traffic and then
> interrogates again the same counters in order to determine if the delta
> is on target. The function receives an array through which the caller
> can request what counters to be interrogated and, for each of them, what
> is their target delta value.
>
> The output from this selftest looks as follows on a LX2160ARDB board:
>
>  $ ./run_kselftest.sh -t drivers/net/hw:ethtool_std_stats.sh
>  TAP version 13
>  1..1
>  # timeout set to 0
>  # selftests: drivers/net/hw: ethtool_std_stats.sh
>  # TAP version 13
>  # 1..26
>  # ok 1 ethtool_std_stats.eth-ctrl-MACControlFramesTransmitted
>  # ok 2 ethtool_std_stats.eth-ctrl-MACControlFramesReceived
>  # ok 3 ethtool_std_stats.eth-mac-FrameCheckSequenceErrors
>  # ok 4 ethtool_std_stats.eth-mac-AlignmentErrors
>  # ok 5 ethtool_std_stats.eth-mac-FramesLostDueToIntMACXmitError
>  # ok 6 ethtool_std_stats.eth-mac-CarrierSenseErrors # SKIP
>  # ok 7 ethtool_std_stats.eth-mac-FramesLostDueToIntMACRcvError
>  # ok 8 ethtool_std_stats.eth-mac-InRangeLengthErrors # SKIP
>  # ok 9 ethtool_std_stats.eth-mac-OutOfRangeLengthField # SKIP
>  # ok 10 ethtool_std_stats.eth-mac-FrameTooLongErrors # SKIP
>  # ok 11 ethtool_std_stats.eth-mac-FramesAbortedDueToXSColls # SKIP
>  # ok 12 ethtool_std_stats.eth-mac-SingleCollisionFrames # SKIP
>  # ok 13 ethtool_std_stats.eth-mac-MultipleCollisionFrames # SKIP
>  # ok 14 ethtool_std_stats.eth-mac-FramesWithDeferredXmissions # SKIP
>  # ok 15 ethtool_std_stats.eth-mac-LateCollisions # SKIP
>  # ok 16 ethtool_std_stats.eth-mac-FramesWithExcessiveDeferral # SKIP
>  # ok 17 ethtool_std_stats.eth-mac-BroadcastFramesXmittedOK
>  # ok 18 ethtool_std_stats.eth-mac-OctetsTransmittedOK
>  # ok 19 ethtool_std_stats.eth-mac-BroadcastFramesReceivedOK
>  # ok 20 ethtool_std_stats.eth-mac-OctetsReceivedOK
>  # ok 21 ethtool_std_stats.eth-mac-FramesTransmittedOK
>  # ok 22 ethtool_std_stats.eth-mac-MulticastFramesXmittedOK
>  # ok 23 ethtool_std_stats.eth-mac-FramesReceivedOK
>  # ok 24 ethtool_std_stats.eth-mac-MulticastFramesReceivedOK
>  # ok 25 ethtool_std_stats.pause-tx_pause_frames
>  # ok 26 ethtool_std_stats.pause-rx_pause_frames
>  # # 10 skipped test(s) detected.  Consider enabling relevant config options to improve coverage.
>  # # Totals: pass:16 fail:0 xfail:0 xpass:0 skip:10 error:0
>  ok 1 selftests: drivers/net/hw: ethtool_std_stats.sh
>
> Please note that not all MACs are counting the software injected pause
> frames as real Tx pause. For example, on a LS1028ARDB the selftest
> output will reflect the fact that neither the ENETC MAC, nor the Felix
> switch MAC are able to detect Tx pause frames injected by software.
>
>  $ ./run_kselftest.sh -t drivers/net/hw:ethtool_std_stats.sh
>  (...)
>  # # software sent pause frames not detected
>  # ok 25 ethtool_std_stats.pause-tx_pause_frames # XFAIL
>  # ok 26 ethtool_std_stats.pause-rx_pause_frames
>
> Signed-off-by: Ioana Ciornei <[email-masked]>

I didn't go into details much, but the code looks broadly correct.

Acked-by: Petr Machata <[email-masked]>