History

net: phy: Maintain MDIO device and bus statistics

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 addresses 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.

Florian Fainelli committed 6 years ago

Commit 080bb351 parent 41cdc743 files · +323 −2Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/phy.h+11−0
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include <linux/timer.h>
2323 #include <linux/workqueue.h>
2424 #include <linux/mod_devicetable.h>
25+#include <linux/u64_stats_sync.h>
2526
2627 #include <linux/atomic.h>
2728
@@ -212,6 +213,15 @@ struct sfp_bus; · 184 unmodified lines
212213 struct sfp_upstream_ops;
213214 struct sk_buff;
214215
216+struct mdio_bus_stats {
217+ u64_stats_t transfers;
218+ u64_stats_t errors;
219+ u64_stats_t writes;
220+ u64_stats_t reads;
221+ /* Must be last, add new statistics above */
222+ struct u64_stats_sync syncp;
223+};
224+
215225 /*
216226 * The Bus class for PHYs. Devices which provide access to
217227 * PHYs should register using this structure
@@ -224,6 +234,7 @@ struct mii_bus { · 6 unmodified lines
224234 int (*read)(struct mii_bus *bus, int addr, int regnum);
225235 int (*write)(struct mii_bus *bus, int addr, int regnum, u16 val);
226236 int (*reset)(struct mii_bus *bus);
237+ struct mdio_bus_stats stats[PHY_MAX_ADDR];
227238
228239 /*
229240 * A lock to ensure that only one thing can read/write