diff options
| author | David S. Miller <[email protected]> | 2018-04-27 11:53:04 -0400 | 
|---|---|---|
| committer | David S. Miller <[email protected]> | 2018-04-27 11:53:04 -0400 | 
| commit | 21fca6e01beb9cae33c7d45a69e032d91c81f07d (patch) | |
| tree | ee5924b4a53b16f813c239101935af3f480b7781 /drivers/net/phy/phy.c | |
| parent | 834944073301e85001c3ed9913027ca47c6f889b (diff) | |
| parent | 96cbddcd52e76d9052948e408b17bedc8aa1c11a (diff) | |
Merge branch 'net-Extend-availability-of-PHY-statistics'
Florian Fainelli says:
====================
net: Extend availability of PHY statistics
This patch series adds support for retrieving PHY statistics with DSA switches
when the CPU port uses a PHY to PHY connection (as opposed to MAC to MAC).
To get there a number of things are done:
- first we move the code dealing with PHY statistics outside of net/core/ethtool.c
  and create helper functions since the same code will be reused
- then we allow network device drivers to provide an ethtool_get_phy_stats callback
  when the standard PHY library helpers are not suitable
- we update the DSA functions dealing with ethtool operations to get passed a
  stringset instead of assuming ETH_SS_STATS like they currently do
- then we provide a set of standard helpers within DSA as a framework and add
  the plumbing to allow retrieving the PHY statistics of the CPU port(s)
- finally plug support for retrieving such PHY statistics with the b53 driver
Changes in v3:
- retrict the b53 change to 539x and 531x5 series of switches
- added a change to dsa_loop.c to help test the feature
Changes in v2:
- got actual testing when the DSA master network device has a PHY that
  already provides statistics (thanks Nikita!)
- fixed the kbuild error reported when CONFIG_PHYLIB=n
- removed the checking of ops which is redundant and not needed
====================
Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'drivers/net/phy/phy.c')
| -rw-r--r-- | drivers/net/phy/phy.c | 48 | 
1 files changed, 48 insertions, 0 deletions
| diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 05c1e8ef15e6..a98ed12c0009 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1277,3 +1277,51 @@ int phy_ethtool_nway_reset(struct net_device *ndev)  	return phy_restart_aneg(phydev);  }  EXPORT_SYMBOL(phy_ethtool_nway_reset); + +int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data) +{ +	if (!phydev->drv) +		return -EIO; + +	mutex_lock(&phydev->lock); +	phydev->drv->get_strings(phydev, data); +	mutex_unlock(&phydev->lock); + +	return 0; +} +EXPORT_SYMBOL(phy_ethtool_get_strings); + +int phy_ethtool_get_sset_count(struct phy_device *phydev) +{ +	int ret; + +	if (!phydev->drv) +		return -EIO; + +	if (phydev->drv->get_sset_count && +	    phydev->drv->get_strings && +	    phydev->drv->get_stats) { +		mutex_lock(&phydev->lock); +		ret = phydev->drv->get_sset_count(phydev); +		mutex_unlock(&phydev->lock); + +		return ret; +	} + +	return -EOPNOTSUPP; +} +EXPORT_SYMBOL(phy_ethtool_get_sset_count); + +int phy_ethtool_get_stats(struct phy_device *phydev, +			  struct ethtool_stats *stats, u64 *data) +{ +	if (!phydev->drv) +		return -EIO; + +	mutex_lock(&phydev->lock); +	phydev->drv->get_stats(phydev, stats, data); +	mutex_unlock(&phydev->lock); + +	return 0; +} +EXPORT_SYMBOL(phy_ethtool_get_stats); |