diff options
author | Oleksij Rempel <o.rempel@pengutronix.de> | 2025-01-10 07:05:15 +0100 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2025-01-14 11:44:19 +0100 |
commit | f2bc1c2655728ac00c35cfb992bdb3243ca17e7e (patch) | |
tree | 52d0f1e68e6add98375f9ac94d200d0cb6c30703 /include/linux/phy.h | |
parent | 7d66c74a171d6c667cbf36f4b6cf1cc98744a83c (diff) |
net: phy: introduce optional polling interface for PHY statistics
Add an optional polling interface for PHY statistics to simplify driver
implementation.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r-- | include/linux/phy.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h index 81d1612e7d35..afaae74d0949 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1173,6 +1173,24 @@ struct phy_driver { */ void (*get_link_stats)(struct phy_device *dev, struct ethtool_link_ext_stats *link_stats); + + /** + * @update_stats: Trigger periodic statistics updates. + * @dev: The PHY device for which statistics updates are triggered. + * + * Periodically gathers statistics from the PHY device to update locally + * maintained 64-bit counters. This is necessary for PHYs that implement + * reduced-width counters (e.g., 16-bit or 32-bit) which can overflow + * more frequently compared to 64-bit counters. By invoking this + * callback, drivers can fetch the current counter values, handle + * overflow detection, and accumulate the results into local 64-bit + * counters for accurate reporting through the `get_phy_stats` and + * `get_link_stats` interfaces. + * + * Return: 0 on success or a negative error code on failure. + */ + int (*update_stats)(struct phy_device *dev); + /** @get_sset_count: Number of statistic counters */ int (*get_sset_count)(struct phy_device *dev); /** @get_strings: Names of the statistic counters */ @@ -1663,6 +1681,9 @@ static inline bool phy_polling_mode(struct phy_device *phydev) if (phydev->drv->flags & PHY_POLL_CABLE_TEST) return true; + if (phydev->drv->update_stats) + return true; + return phydev->irq == PHY_POLL; } |