net: ethtool: add helpers for aggregate statistics
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 19 Jan 2023 12:26:58 +0000 (14:26 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 23 Jan 2023 12:44:18 +0000 (12:44 +0000)
commit449c5459641ad72a504884abb9fb9b19ee31397b
tree77984748091b4d1dbb0e9ffbb1a08337946a8f6e
parentc319df10a4c854bb2e1085c01e7a9f1dadd810a2
net: ethtool: add helpers for aggregate statistics

When a pMAC exists but the driver is unable to atomically query the
aggregate eMAC+pMAC statistics, the user should be given back at least
the sum of eMAC and pMAC counters queried separately.

This is a generic problem, so add helpers in ethtool to do this
operation, if the driver doesn't have a better way to report aggregate
stats. Do this in a way that does not require changes to these functions
when new stats are added (basically treat the structures as an array of
u64 values, except for the first element which is the stats source).

In include/linux/ethtool.h, there is already a section where helper
function prototypes should be placed. The trouble is, this section is
too early, before the definitions of struct ethtool_eth_mac_stats et.al.
Move that section at the end and append these new helpers to it.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/ethtool.h
net/ethtool/stats.c