Common interface for NIC statistics
In Linux 5.13 ethtool gains an interface for querying IEEE and IETF statistics. This removes the need to parse vendor specific strings in ethtool -S.
Linux has two sources of NIC statistics, the common interface stats (which show up in ifconfig, ip link, sysfs and few other places) and ethtool -S. The former – common interface stats – are a mix of basic info (packets, bytes, drops, errors in each direction) and a handful of lower level stats like CRC errors, framing errors, collisions or FIFO errors. Many of these statistics became either irrelevant (collisions) or semantically unclear (FIFO errors) in modern NICs.
This is why deployments increasingly depend on ethtool -S statistics for error tracking. ethtool -S is a free form list of stats provided by the driver. It started out as a place for drivers to report custom, implementation specific stats, but ended up also serving as a reporting place for new statistics as the networking standards developed.
Sadly there is no commonality in how vendors name their ethtool statistics. The spelling and abbreviation of IEEE stats always differ, sometimes the names chosen do not resemble the standard names at all (reportedly because vendors consider those names “too confusing” for the users). This forces infrastructure teams to maintain translations and custom per-vendor logic to scrape ethtool -S output.
Starting with Linux 5.6 Michal Kubecek has been progressively porting ethtool from ioctls to a more structured and extensible netlink interface. Thanks to that we can now augment the old commands to carry statistics. When user specifies
-I | --include-statistics on the command line (or the appropriate flag in netlink) kernel will include relevant statistics in its response, e.g. for flow control:
# ethtool -I -a eth0 Pause parameters for eth0: Autonegotiate: off RX: off TX: on Statistics: tx_pause_frames: 25545561 rx_pause_frames: 0
General statistics such as PHY and MAC counters are now available via ethtool -S under standard-based names though a new
--groups switch, e.g.:
# ethtool -S eth0 --groups eth-mac Standard stats for eth0: eth-mac-FramesTransmittedOK: 902623288966 eth-mac-FramesReceivedOK: 28727667047 eth-mac-FrameCheckSequenceErrors: 1 eth-mac-AlignmentErrors: 0 eth-mac-OutOfRangeLengthField: 0
Each of the commands supports JSON-formatted output for ease of parsing (
So little, so late
Admittedly the new interface is quite basic. It mostly includes statistics provided in IEEE or IETF standards, and NICs may report more interesting data. There is also no metadata about “freshness” of the stats here, or filtering built into the interface.
The starting point is based on fulfilling immediate needs. We hope the interfaces will be extended as needed. Statistics can be made arbitrarily complex, so after a couple false-starts with complex interfaces we decided to let the use cases drive the interface.
It’s also very useful to lean on the standards for clear definition of the semantics. Going forward we can work with vendors on codifying the definitions of other counters they have.
List of currently supported stats
IEEE 802.3 attributes::
220.127.116.11.5 aSymbolErrorDuringCarrier 18.104.22.168.2 aFramesTransmittedOK 22.214.171.124.3 aSingleCollisionFrames 126.96.36.199.4 aMultipleCollisionFrames 188.8.131.52.5 aFramesReceivedOK 184.108.40.206.6 aFrameCheckSequenceErrors 220.127.116.11.7 aAlignmentErrors 18.104.22.168.8 aOctetsTransmittedOK 22.214.171.124.9 aFramesWithDeferredXmissions 126.96.36.199.10 aLateCollisions 188.8.131.52.11 aFramesAbortedDueToXSColls 184.108.40.206.12 aFramesLostDueToIntMACXmitError 220.127.116.11.13 aCarrierSenseErrors 18.104.22.168.14 aOctetsReceivedOK 22.214.171.124.15 aFramesLostDueToIntMACRcvError 126.96.36.199.18 aMulticastFramesXmittedOK 188.8.131.52.19 aBroadcastFramesXmittedOK 184.108.40.206.20 aFramesWithExcessiveDeferral 220.127.116.11.21 aMulticastFramesReceivedOK 18.104.22.168.22 aBroadcastFramesReceivedOK 22.214.171.124.23 aInRangeLengthErrors 126.96.36.199.24 aOutOfRangeLengthField 188.8.131.52.25 aFrameTooLongErrors 184.108.40.206 aMACControlFramesTransmitted 220.127.116.11 aMACControlFramesReceived 18.104.22.168 aUnsupportedOpcodesReceived 22.214.171.124 aPAUSEMACCtrlFramesTransmitted 126.96.36.199 aPAUSEMACCtrlFramesReceived 188.8.131.52.17 aFECCorrectedBlocks 184.108.40.206.18 aFECUncorrectableBlocks
IETF RMON (RFC 2819)
etherStatsUndersizePkts etherStatsOversizePkts etherStatsFragments etherStatsJabbers etherStatsPkts64Octets etherStatsPkts65to127Octets etherStatsPkts128to255Octets etherStatsPkts256to511Octets etherStatsPkts512to1023Octets etherStatsPkts1024to1518Octets (incl. further stats for jumbo MTUs)