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
22#include <linux/timer.h>22#include <linux/timer.h>
23#include <linux/workqueue.h>23#include <linux/workqueue.h>
24#include <linux/mod_devicetable.h>24#include <linux/mod_devicetable.h>
25#include <linux/u64_stats_sync.h>
25 26
26#include <linux/atomic.h>27#include <linux/atomic.h>
27 28
@@ -212,6 +213,15 @@ struct sfp_bus; · 184 unmodified lines
212struct sfp_upstream_ops;213struct sfp_upstream_ops;
213struct sk_buff;214struct sk_buff;
214 215
216struct 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
215/*225/*
216 * The Bus class for PHYs. Devices which provide access to226 * The Bus class for PHYs. Devices which provide access to
217 * PHYs should register using this structure227 * PHYs should register using this structure
@@ -224,6 +234,7 @@ struct mii_bus { · 6 unmodified lines
224 int (*read)(struct mii_bus *bus, int addr, int regnum);234 int (*read)(struct mii_bus *bus, int addr, int regnum);
225 int (*write)(struct mii_bus *bus, int addr, int regnum, u16 val);235 int (*write)(struct mii_bus *bus, int addr, int regnum, u16 val);
226 int (*reset)(struct mii_bus *bus);236 int (*reset)(struct mii_bus *bus);
237 struct mdio_bus_stats stats[PHY_MAX_ADDR];
227 238
228 /*239 /*
229 * A lock to ensure that only one thing can read/write240 * A lock to ensure that only one thing can read/write