Skip to content

RFC ethtool: add uAPI for reading standard stats

Jakub Kicinski netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6docs: networking: extend the statistics documentationDocumentation/networking/statistics.rst+42 -20 replies
2/6docs: ethtool: document standard statisticsDocumentation/networking/ethtool-netlink.rst+74 -00 replies
3/6ethtool: add a new command for reading standard statsinclude/linux/ethtool.h include/uapi/linux/ethtool.h include/uapi/linux/ethtool_netlink.h +5 more+250 -10 replies
4/6ethtool: add interface to read standard MAC statsinclude/linux/ethtool.h include/uapi/linux/ethtool.h include/uapi/linux/ethtool_netlink.h +3 more+182 -05 replies
5/6ethtool: add interface to read standard MAC Ctrl statsinclude/linux/ethtool.h include/uapi/linux/ethtool.h include/uapi/linux/ethtool_netlink.h +3 more+66 -00 replies
6/6ethtool: add interface to read RMON statsinclude/linux/ethtool.h include/uapi/linux/ethtool.h include/uapi/linux/ethtool_netlink.h +3 more+156 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC net-next 0/6] ethtool: add uAPI for reading standard stats

This series adds a new ethtool command to read well defined device statistics. There is nothing clever here, just a netlink API for dumping statistics defined by standards and RFCs which today end up in ethtool -S under infinite variations of names.

This series adds basic IEEE stats (for PHY, MAC, Ctrl frames) and RMON stats. AFAICT other RFCs only duplicate the IEEE stats.

This series does _not_ add a netlink API to read driver-defined stats. There seems to be little to gain from moving that part to netlink.

The netlink message format is very simple, and aims to allow adding stats and groups with no changes to user tooling (which IIUC is expected for ethtool). Stats are dumped directly into netlink with netlink attributes used as IDs. This is perhaps where the biggest question mark is. We could instead pack the stats into individual wrappers:

[grp]
[stat] // nest

     [id]    // u32
     [value] // u64
   [stat] // nest
     [id]    // u32
     [value] // u64

which would increase the message size 2x but allow to ID the stats from 0, saving strset space as well as allow seamless adding of legacy stats to this API (which are IDed from 0).

On user space side we can re-use -S, and make it dump standard stats if --groups are defined.

$ ethtool -S eth0 --groups eth-phy eth-mac rmon eth-ctrl
Stats for eth0:
eth-phy-SymbolErrorDuringCarrier: 0
eth-mac-FramesTransmittedOK: 0
eth-mac-FrameTooLongErrors: 0
eth-ctrl-MACControlFramesTransmitted: 0
eth-ctrl-MACControlFramesReceived: 1
eth-ctrl-UnsupportedOpcodesReceived: 0
rmon-etherStatsUndersizePkts: 0
rmon-etherStatsJabbers: 0
rmon-rx-etherStatsPkts64Octets: 1
rmon-rx-etherStatsPkts128to255Octets: 0
rmon-rx-etherStatsPkts1024toMaxOctets: 1
rmon-tx-etherStatsPkts64Octets: 1
rmon-tx-etherStatsPkts128to255Octets: 0
rmon-tx-etherStatsPkts1024toMaxOctets: 1

Jakub Kicinski (6):
docs: networking: extend the statistics documentation
docs: ethtool: document standard statistics
ethtool: add a new command for reading standard stats
ethtool: add interface to read standard MAC stats
ethtool: add interface to read standard MAC Ctrl stats
ethtool: add interface to read RMON stats

 Documentation/networking/ethtool-netlink.rst |  74 ++++
 Documentation/networking/statistics.rst      |  44 ++-
 include/linux/ethtool.h                      |  95 +++++
 include/uapi/linux/ethtool.h                 |  10 +
 include/uapi/linux/ethtool_netlink.h         | 134 +++++++
 net/ethtool/Makefile                         |   2 +-
 net/ethtool/netlink.c                        |  10 +
 net/ethtool/netlink.h                        |   8 +
 net/ethtool/stats.c                          | 374 +++++++++++++++++++
 net/ethtool/strset.c                         |  25 ++
 10 files changed, 773 insertions(+), 3 deletions(-)
 create mode 100644 net/ethtool/stats.c
Signature · 1 line
2.30.2