Commit 17809516 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: phy: Uninline PHY ethtool statistics operations

Now that we have moved the PHY ethtool statistics to be dynamically
registered, we no longer need to inline those for ethtool. This used to
be done to avoid cross symbol referencing and allow ethtool to be
decoupled from PHYLIB entirely.
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bd36ed1c
...@@ -489,6 +489,54 @@ static void phy_abort_cable_test(struct phy_device *phydev) ...@@ -489,6 +489,54 @@ static void phy_abort_cable_test(struct phy_device *phydev)
phydev_err(phydev, "Error while aborting cable test"); phydev_err(phydev, "Error while aborting cable test");
} }
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);
int phy_start_cable_test(struct phy_device *phydev, int phy_start_cable_test(struct phy_device *phydev,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
......
...@@ -1474,51 +1474,10 @@ int __init mdio_bus_init(void); ...@@ -1474,51 +1474,10 @@ int __init mdio_bus_init(void);
void mdio_bus_exit(void); void mdio_bus_exit(void);
#endif #endif
/* Inline function for use within net/core/ethtool.c (built-in) */ int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);
static inline int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data) int phy_ethtool_get_sset_count(struct phy_device *phydev);
{ int phy_ethtool_get_stats(struct phy_device *phydev,
if (!phydev->drv) struct ethtool_stats *stats, u64 *data);
return -EIO;
mutex_lock(&phydev->lock);
phydev->drv->get_strings(phydev, data);
mutex_unlock(&phydev->lock);
return 0;
}
static inline 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;
}
static inline 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;
}
static inline int phy_package_read(struct phy_device *phydev, u32 regnum) static inline int phy_package_read(struct phy_device *phydev, u32 regnum)
{ {
......
...@@ -135,6 +135,7 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr) ...@@ -135,6 +135,7 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
static int __ethtool_get_sset_count(struct net_device *dev, int sset) static int __ethtool_get_sset_count(struct net_device *dev, int sset)
{ {
const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops;
const struct ethtool_ops *ops = dev->ethtool_ops; const struct ethtool_ops *ops = dev->ethtool_ops;
if (sset == ETH_SS_FEATURES) if (sset == ETH_SS_FEATURES)
...@@ -150,8 +151,9 @@ static int __ethtool_get_sset_count(struct net_device *dev, int sset) ...@@ -150,8 +151,9 @@ static int __ethtool_get_sset_count(struct net_device *dev, int sset)
return ARRAY_SIZE(phy_tunable_strings); return ARRAY_SIZE(phy_tunable_strings);
if (sset == ETH_SS_PHY_STATS && dev->phydev && if (sset == ETH_SS_PHY_STATS && dev->phydev &&
!ops->get_ethtool_phy_stats) !ops->get_ethtool_phy_stats &&
return phy_ethtool_get_sset_count(dev->phydev); phy_ops && phy_ops->get_sset_count)
return phy_ops->get_sset_count(dev->phydev);
if (sset == ETH_SS_LINK_MODES) if (sset == ETH_SS_LINK_MODES)
return __ETHTOOL_LINK_MODE_MASK_NBITS; return __ETHTOOL_LINK_MODE_MASK_NBITS;
...@@ -165,6 +167,7 @@ static int __ethtool_get_sset_count(struct net_device *dev, int sset) ...@@ -165,6 +167,7 @@ static int __ethtool_get_sset_count(struct net_device *dev, int sset)
static void __ethtool_get_strings(struct net_device *dev, static void __ethtool_get_strings(struct net_device *dev,
u32 stringset, u8 *data) u32 stringset, u8 *data)
{ {
const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops;
const struct ethtool_ops *ops = dev->ethtool_ops; const struct ethtool_ops *ops = dev->ethtool_ops;
if (stringset == ETH_SS_FEATURES) if (stringset == ETH_SS_FEATURES)
...@@ -178,8 +181,9 @@ static void __ethtool_get_strings(struct net_device *dev, ...@@ -178,8 +181,9 @@ static void __ethtool_get_strings(struct net_device *dev,
else if (stringset == ETH_SS_PHY_TUNABLES) else if (stringset == ETH_SS_PHY_TUNABLES)
memcpy(data, phy_tunable_strings, sizeof(phy_tunable_strings)); memcpy(data, phy_tunable_strings, sizeof(phy_tunable_strings));
else if (stringset == ETH_SS_PHY_STATS && dev->phydev && else if (stringset == ETH_SS_PHY_STATS && dev->phydev &&
!ops->get_ethtool_phy_stats) !ops->get_ethtool_phy_stats && phy_ops &&
phy_ethtool_get_strings(dev->phydev, data); phy_ops->get_strings)
phy_ops->get_strings(dev->phydev, data);
else if (stringset == ETH_SS_LINK_MODES) else if (stringset == ETH_SS_LINK_MODES)
memcpy(data, link_mode_names, memcpy(data, link_mode_names,
__ETHTOOL_LINK_MODE_MASK_NBITS * ETH_GSTRING_LEN); __ETHTOOL_LINK_MODE_MASK_NBITS * ETH_GSTRING_LEN);
...@@ -1929,6 +1933,7 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr) ...@@ -1929,6 +1933,7 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr) static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
{ {
const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops;
const struct ethtool_ops *ops = dev->ethtool_ops; const struct ethtool_ops *ops = dev->ethtool_ops;
struct phy_device *phydev = dev->phydev; struct phy_device *phydev = dev->phydev;
struct ethtool_stats stats; struct ethtool_stats stats;
...@@ -1938,8 +1943,9 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr) ...@@ -1938,8 +1943,9 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
if (!phydev && (!ops->get_ethtool_phy_stats || !ops->get_sset_count)) if (!phydev && (!ops->get_ethtool_phy_stats || !ops->get_sset_count))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (dev->phydev && !ops->get_ethtool_phy_stats) if (dev->phydev && !ops->get_ethtool_phy_stats &&
n_stats = phy_ethtool_get_sset_count(dev->phydev); phy_ops && phy_ops->get_sset_count)
n_stats = phy_ops->get_sset_count(dev->phydev);
else else
n_stats = ops->get_sset_count(dev, ETH_SS_PHY_STATS); n_stats = ops->get_sset_count(dev, ETH_SS_PHY_STATS);
if (n_stats < 0) if (n_stats < 0)
...@@ -1958,8 +1964,9 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr) ...@@ -1958,8 +1964,9 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
if (dev->phydev && !ops->get_ethtool_phy_stats) { if (dev->phydev && !ops->get_ethtool_phy_stats &&
ret = phy_ethtool_get_stats(dev->phydev, &stats, data); phy_ops && phy_ops->get_stats) {
ret = phy_ops->get_stats(dev->phydev, &stats, data);
if (ret < 0) if (ret < 0)
goto out; goto out;
} else { } else {
......
...@@ -209,13 +209,15 @@ static void strset_cleanup_data(struct ethnl_reply_data *reply_base) ...@@ -209,13 +209,15 @@ static void strset_cleanup_data(struct ethnl_reply_data *reply_base)
static int strset_prepare_set(struct strset_info *info, struct net_device *dev, static int strset_prepare_set(struct strset_info *info, struct net_device *dev,
unsigned int id, bool counts_only) unsigned int id, bool counts_only)
{ {
const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops;
const struct ethtool_ops *ops = dev->ethtool_ops; const struct ethtool_ops *ops = dev->ethtool_ops;
void *strings; void *strings;
int count, ret; int count, ret;
if (id == ETH_SS_PHY_STATS && dev->phydev && if (id == ETH_SS_PHY_STATS && dev->phydev &&
!ops->get_ethtool_phy_stats) !ops->get_ethtool_phy_stats && phy_ops &&
ret = phy_ethtool_get_sset_count(dev->phydev); phy_ops->get_sset_count)
ret = phy_ops->get_sset_count(dev->phydev);
else if (ops->get_sset_count && ops->get_strings) else if (ops->get_sset_count && ops->get_strings)
ret = ops->get_sset_count(dev, id); ret = ops->get_sset_count(dev, id);
else else
...@@ -231,8 +233,9 @@ static int strset_prepare_set(struct strset_info *info, struct net_device *dev, ...@@ -231,8 +233,9 @@ static int strset_prepare_set(struct strset_info *info, struct net_device *dev,
if (!strings) if (!strings)
return -ENOMEM; return -ENOMEM;
if (id == ETH_SS_PHY_STATS && dev->phydev && if (id == ETH_SS_PHY_STATS && dev->phydev &&
!ops->get_ethtool_phy_stats) !ops->get_ethtool_phy_stats && phy_ops &&
phy_ethtool_get_strings(dev->phydev, strings); phy_ops->get_strings)
phy_ops->get_strings(dev->phydev, strings);
else else
ops->get_strings(dev, id, strings); ops->get_strings(dev, id, strings);
info->strings = strings; info->strings = strings;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment