Re: [PATCH net-next v2] net: phy: Maintain MDIO device and bus statistics

From: Andrew Lunn
Date: Wed Jan 15 2020 - 18:19:41 EST


On Wed, Jan 15, 2020 at 12:42:20PM -0800, Florian Fainelli wrote:
> We maintain global statistics for an entire MDIO bus, as well as broken
> down, per MDIO bus address statistics. Given that it is possible for
> MDIO devices such as switches to access MDIO bus addressies for which
> there is not a mdio_device instance created (therefore not a a
> corresponding device directory in sysfs either), we also maintain
> per-address statistics under the statistics folder. The layout looks
> like this:
>
> /sys/class/mdio_bus/../statistics/
> transfers
> errrors
> writes
> reads
> transfers_<addr>
> errors_<addr>
> writes_<addr>
> reads_<addr>
>
> When a mdio_device instance is registered, a statistics/ folder is
> created with the tranfers, errors, writes and reads attributes which
> point to the appropriate MDIO bus statistics structure.
>
> Statistics are 64-bit unsigned quantities and maintained through the
> u64_stats_sync.h helper functions.
>
> Signed-off-by: Florian Fainelli <f.fainelli@xxxxxxxxx>
> ---
> Changes in v2:
>
> - tracked per MDIO address statististics in separate attributes

Hi Florian

This is much better. Here is an MDIO bus with a Marvel MV88E6390

andrew@zii-devel-c-bidi:/sys/class/mdio_bus/0.1/statistics$ awk ' { print FILENAME " " $0 } ' transfers_? transfers_?? transfers
transfers_0 93
transfers_1 80
transfers_2 80
transfers_3 80
transfers_4 102
transfers_5 18
transfers_6 7
transfers_7 7
transfers_8 7
transfers_9 7
transfers_10 82
transfers_11 0
transfers_12 0
transfers_13 0
transfers_14 0
transfers_15 0
transfers_16 0
transfers_17 0
transfers_18 0
transfers_19 0
transfers_20 0
transfers_21 0
transfers_22 0
transfers_23 0
transfers_24 0
transfers_25 0
transfers_26 0
transfers_27 288
transfers_28 3328
transfers_29 0
transfers_30 0
transfers_31 0
transfers 4179

As you can see, there are transfers on a number of addresses.

I've not looked at the code yet, but i can give:

Tested-by: Andrew Lunn <andrew@xxxxxxx>

I will review the code soon.

Andrew