Commit 8a296591 authored by David S. Miller's avatar David S. Miller

Merge branch 'phy_ethtool_nway_reset'

Florian Fainelli says:

====================
net: phy: Centralize auto-negotation restart

This patch series centralizes how ethtool::nway_reset is implemented
by providing a PHYLIB function which calls into genphy_restart_aneg().

All drivers below are converted to use this new helper function. Some
other have specific requirements that make them not quite suitable for
a straight forward conversion.

There is another patch series which implements ethtool::nway_reset
using the helper function introduced that depends on this patch
series.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 8ebd115b 860ce4b4
...@@ -1037,16 +1037,6 @@ static const struct net_device_ops nb8800_netdev_ops = { ...@@ -1037,16 +1037,6 @@ static const struct net_device_ops nb8800_netdev_ops = {
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
}; };
static int nb8800_nway_reset(struct net_device *dev)
{
struct phy_device *phydev = dev->phydev;
if (!phydev)
return -ENODEV;
return genphy_restart_aneg(phydev);
}
static void nb8800_get_pauseparam(struct net_device *dev, static void nb8800_get_pauseparam(struct net_device *dev,
struct ethtool_pauseparam *pp) struct ethtool_pauseparam *pp)
{ {
...@@ -1165,7 +1155,7 @@ static void nb8800_get_ethtool_stats(struct net_device *dev, ...@@ -1165,7 +1155,7 @@ static void nb8800_get_ethtool_stats(struct net_device *dev,
} }
static const struct ethtool_ops nb8800_ethtool_ops = { static const struct ethtool_ops nb8800_ethtool_ops = {
.nway_reset = nb8800_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_pauseparam = nb8800_get_pauseparam, .get_pauseparam = nb8800_get_pauseparam,
.set_pauseparam = nb8800_set_pauseparam, .set_pauseparam = nb8800_set_pauseparam,
......
...@@ -1434,11 +1434,8 @@ static int bcm_enet_nway_reset(struct net_device *dev) ...@@ -1434,11 +1434,8 @@ static int bcm_enet_nway_reset(struct net_device *dev)
struct bcm_enet_priv *priv; struct bcm_enet_priv *priv;
priv = netdev_priv(dev); priv = netdev_priv(dev);
if (priv->has_phy) { if (priv->has_phy)
if (!dev->phydev) return phy_ethtool_nway_reset(dev),
return -ENODEV;
return genphy_restart_aneg(dev->phydev);
}
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
...@@ -971,13 +971,6 @@ static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e) ...@@ -971,13 +971,6 @@ static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e)
return phy_ethtool_set_eee(priv->phydev, e); return phy_ethtool_set_eee(priv->phydev, e);
} }
static int bcmgenet_nway_reset(struct net_device *dev)
{
struct bcmgenet_priv *priv = netdev_priv(dev);
return genphy_restart_aneg(priv->phydev);
}
/* standard ethtool support functions. */ /* standard ethtool support functions. */
static const struct ethtool_ops bcmgenet_ethtool_ops = { static const struct ethtool_ops bcmgenet_ethtool_ops = {
.get_strings = bcmgenet_get_strings, .get_strings = bcmgenet_get_strings,
...@@ -991,7 +984,7 @@ static const struct ethtool_ops bcmgenet_ethtool_ops = { ...@@ -991,7 +984,7 @@ static const struct ethtool_ops bcmgenet_ethtool_ops = {
.set_wol = bcmgenet_set_wol, .set_wol = bcmgenet_set_wol,
.get_eee = bcmgenet_get_eee, .get_eee = bcmgenet_get_eee,
.set_eee = bcmgenet_set_eee, .set_eee = bcmgenet_set_eee,
.nway_reset = bcmgenet_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_coalesce = bcmgenet_get_coalesce, .get_coalesce = bcmgenet_get_coalesce,
.set_coalesce = bcmgenet_set_coalesce, .set_coalesce = bcmgenet_set_coalesce,
.get_link_ksettings = bcmgenet_get_link_ksettings, .get_link_ksettings = bcmgenet_get_link_ksettings,
......
...@@ -2344,16 +2344,6 @@ static int fec_enet_get_sset_count(struct net_device *dev, int sset) ...@@ -2344,16 +2344,6 @@ static int fec_enet_get_sset_count(struct net_device *dev, int sset)
} }
#endif /* !defined(CONFIG_M5272) */ #endif /* !defined(CONFIG_M5272) */
static int fec_enet_nway_reset(struct net_device *dev)
{
struct phy_device *phydev = dev->phydev;
if (!phydev)
return -ENODEV;
return genphy_restart_aneg(phydev);
}
/* ITR clock source is enet system clock (clk_ahb). /* ITR clock source is enet system clock (clk_ahb).
* TCTT unit is cycle_ns * 64 cycle * TCTT unit is cycle_ns * 64 cycle
* So, the ICTT value = X us / (cycle_ns * 64) * So, the ICTT value = X us / (cycle_ns * 64)
...@@ -2553,7 +2543,7 @@ static const struct ethtool_ops fec_enet_ethtool_ops = { ...@@ -2553,7 +2543,7 @@ static const struct ethtool_ops fec_enet_ethtool_ops = {
.get_drvinfo = fec_enet_get_drvinfo, .get_drvinfo = fec_enet_get_drvinfo,
.get_regs_len = fec_enet_get_regs_len, .get_regs_len = fec_enet_get_regs_len,
.get_regs = fec_enet_get_regs, .get_regs = fec_enet_get_regs,
.nway_reset = fec_enet_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_coalesce = fec_enet_get_coalesce, .get_coalesce = fec_enet_get_coalesce,
.set_coalesce = fec_enet_set_coalesce, .set_coalesce = fec_enet_set_coalesce,
......
...@@ -807,11 +807,6 @@ static void fs_get_regs(struct net_device *dev, struct ethtool_regs *regs, ...@@ -807,11 +807,6 @@ static void fs_get_regs(struct net_device *dev, struct ethtool_regs *regs,
regs->version = 0; regs->version = 0;
} }
static int fs_nway_reset(struct net_device *dev)
{
return 0;
}
static u32 fs_get_msglevel(struct net_device *dev) static u32 fs_get_msglevel(struct net_device *dev)
{ {
struct fs_enet_private *fep = netdev_priv(dev); struct fs_enet_private *fep = netdev_priv(dev);
...@@ -865,7 +860,7 @@ static int fs_set_tunable(struct net_device *dev, ...@@ -865,7 +860,7 @@ static int fs_set_tunable(struct net_device *dev,
static const struct ethtool_ops fs_ethtool_ops = { static const struct ethtool_ops fs_ethtool_ops = {
.get_drvinfo = fs_get_drvinfo, .get_drvinfo = fs_get_drvinfo,
.get_regs_len = fs_get_regs_len, .get_regs_len = fs_get_regs_len,
.nway_reset = fs_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_msglevel = fs_get_msglevel, .get_msglevel = fs_get_msglevel,
.set_msglevel = fs_set_msglevel, .set_msglevel = fs_set_msglevel,
......
...@@ -332,13 +332,6 @@ static void uec_get_ethtool_stats(struct net_device *netdev, ...@@ -332,13 +332,6 @@ static void uec_get_ethtool_stats(struct net_device *netdev,
} }
} }
static int uec_nway_reset(struct net_device *netdev)
{
struct ucc_geth_private *ugeth = netdev_priv(netdev);
return phy_start_aneg(ugeth->phydev);
}
/* Report driver information */ /* Report driver information */
static void static void
uec_get_drvinfo(struct net_device *netdev, uec_get_drvinfo(struct net_device *netdev,
...@@ -394,7 +387,7 @@ static const struct ethtool_ops uec_ethtool_ops = { ...@@ -394,7 +387,7 @@ static const struct ethtool_ops uec_ethtool_ops = {
.get_regs = uec_get_regs, .get_regs = uec_get_regs,
.get_msglevel = uec_get_msglevel, .get_msglevel = uec_get_msglevel,
.set_msglevel = uec_set_msglevel, .set_msglevel = uec_set_msglevel,
.nway_reset = uec_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_ringparam = uec_get_ringparam, .get_ringparam = uec_get_ringparam,
.set_ringparam = uec_set_ringparam, .set_ringparam = uec_set_ringparam,
......
...@@ -303,15 +303,9 @@ ltq_etop_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) ...@@ -303,15 +303,9 @@ ltq_etop_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
strlcpy(info->version, DRV_VERSION, sizeof(info->version)); strlcpy(info->version, DRV_VERSION, sizeof(info->version));
} }
static int
ltq_etop_nway_reset(struct net_device *dev)
{
return phy_start_aneg(dev->phydev);
}
static const struct ethtool_ops ltq_etop_ethtool_ops = { static const struct ethtool_ops ltq_etop_ethtool_ops = {
.get_drvinfo = ltq_etop_get_drvinfo, .get_drvinfo = ltq_etop_get_drvinfo,
.nway_reset = ltq_etop_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link_ksettings = phy_ethtool_get_link_ksettings, .get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings,
}; };
......
...@@ -1639,14 +1639,6 @@ static void mv643xx_eth_get_drvinfo(struct net_device *dev, ...@@ -1639,14 +1639,6 @@ static void mv643xx_eth_get_drvinfo(struct net_device *dev,
strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info)); strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info));
} }
static int mv643xx_eth_nway_reset(struct net_device *dev)
{
if (!dev->phydev)
return -EINVAL;
return genphy_restart_aneg(dev->phydev);
}
static int static int
mv643xx_eth_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) mv643xx_eth_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
{ {
...@@ -1770,7 +1762,7 @@ static int mv643xx_eth_get_sset_count(struct net_device *dev, int sset) ...@@ -1770,7 +1762,7 @@ static int mv643xx_eth_get_sset_count(struct net_device *dev, int sset)
static const struct ethtool_ops mv643xx_eth_ethtool_ops = { static const struct ethtool_ops mv643xx_eth_ethtool_ops = {
.get_drvinfo = mv643xx_eth_get_drvinfo, .get_drvinfo = mv643xx_eth_get_drvinfo,
.nway_reset = mv643xx_eth_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_coalesce = mv643xx_eth_get_coalesce, .get_coalesce = mv643xx_eth_get_coalesce,
.set_coalesce = mv643xx_eth_set_coalesce, .set_coalesce = mv643xx_eth_set_coalesce,
......
...@@ -1956,11 +1956,6 @@ static void smsc911x_ethtool_getdrvinfo(struct net_device *dev, ...@@ -1956,11 +1956,6 @@ static void smsc911x_ethtool_getdrvinfo(struct net_device *dev,
sizeof(info->bus_info)); sizeof(info->bus_info));
} }
static int smsc911x_ethtool_nwayreset(struct net_device *dev)
{
return phy_start_aneg(dev->phydev);
}
static u32 smsc911x_ethtool_getmsglevel(struct net_device *dev) static u32 smsc911x_ethtool_getmsglevel(struct net_device *dev)
{ {
struct smsc911x_data *pdata = netdev_priv(dev); struct smsc911x_data *pdata = netdev_priv(dev);
...@@ -2132,7 +2127,7 @@ static int smsc911x_ethtool_set_eeprom(struct net_device *dev, ...@@ -2132,7 +2127,7 @@ static int smsc911x_ethtool_set_eeprom(struct net_device *dev,
static const struct ethtool_ops smsc911x_ethtool_ops = { static const struct ethtool_ops smsc911x_ethtool_ops = {
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_drvinfo = smsc911x_ethtool_getdrvinfo, .get_drvinfo = smsc911x_ethtool_getdrvinfo,
.nway_reset = smsc911x_ethtool_nwayreset, .nway_reset = phy_ethtool_nway_reset,
.get_msglevel = smsc911x_ethtool_getmsglevel, .get_msglevel = smsc911x_ethtool_getmsglevel,
.set_msglevel = smsc911x_ethtool_setmsglevel, .set_msglevel = smsc911x_ethtool_setmsglevel,
.get_regs_len = smsc911x_ethtool_getregslen, .get_regs_len = smsc911x_ethtool_getregslen,
......
...@@ -254,14 +254,6 @@ static void smsc9420_ethtool_set_msglevel(struct net_device *netdev, u32 data) ...@@ -254,14 +254,6 @@ static void smsc9420_ethtool_set_msglevel(struct net_device *netdev, u32 data)
pd->msg_enable = data; pd->msg_enable = data;
} }
static int smsc9420_ethtool_nway_reset(struct net_device *netdev)
{
if (!netdev->phydev)
return -ENODEV;
return phy_start_aneg(netdev->phydev);
}
static int smsc9420_ethtool_getregslen(struct net_device *dev) static int smsc9420_ethtool_getregslen(struct net_device *dev)
{ {
/* all smsc9420 registers plus all phy registers */ /* all smsc9420 registers plus all phy registers */
...@@ -417,7 +409,7 @@ static const struct ethtool_ops smsc9420_ethtool_ops = { ...@@ -417,7 +409,7 @@ static const struct ethtool_ops smsc9420_ethtool_ops = {
.get_drvinfo = smsc9420_ethtool_get_drvinfo, .get_drvinfo = smsc9420_ethtool_get_drvinfo,
.get_msglevel = smsc9420_ethtool_get_msglevel, .get_msglevel = smsc9420_ethtool_get_msglevel,
.set_msglevel = smsc9420_ethtool_set_msglevel, .set_msglevel = smsc9420_ethtool_set_msglevel,
.nway_reset = smsc9420_ethtool_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_eeprom_len = smsc9420_ethtool_get_eeprom_len, .get_eeprom_len = smsc9420_ethtool_get_eeprom_len,
.get_eeprom = smsc9420_ethtool_get_eeprom, .get_eeprom = smsc9420_ethtool_get_eeprom,
......
...@@ -967,13 +967,8 @@ static const struct attribute_group temac_attr_group = { ...@@ -967,13 +967,8 @@ static const struct attribute_group temac_attr_group = {
}; };
/* ethtool support */ /* ethtool support */
static int temac_nway_reset(struct net_device *ndev)
{
return phy_start_aneg(ndev->phydev);
}
static const struct ethtool_ops temac_ethtool_ops = { static const struct ethtool_ops temac_ethtool_ops = {
.nway_reset = temac_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_ts_info = ethtool_op_get_ts_info, .get_ts_info = ethtool_op_get_ts_info,
.get_link_ksettings = phy_ethtool_get_link_ksettings, .get_link_ksettings = phy_ethtool_get_link_ksettings,
......
...@@ -1001,11 +1001,6 @@ static void ixp4xx_get_drvinfo(struct net_device *dev, ...@@ -1001,11 +1001,6 @@ static void ixp4xx_get_drvinfo(struct net_device *dev,
strlcpy(info->bus_info, "internal", sizeof(info->bus_info)); strlcpy(info->bus_info, "internal", sizeof(info->bus_info));
} }
static int ixp4xx_nway_reset(struct net_device *dev)
{
return phy_start_aneg(dev->phydev);
}
int ixp46x_phc_index = -1; int ixp46x_phc_index = -1;
EXPORT_SYMBOL_GPL(ixp46x_phc_index); EXPORT_SYMBOL_GPL(ixp46x_phc_index);
...@@ -1037,7 +1032,7 @@ static int ixp4xx_get_ts_info(struct net_device *dev, ...@@ -1037,7 +1032,7 @@ static int ixp4xx_get_ts_info(struct net_device *dev,
static const struct ethtool_ops ixp4xx_ethtool_ops = { static const struct ethtool_ops ixp4xx_ethtool_ops = {
.get_drvinfo = ixp4xx_get_drvinfo, .get_drvinfo = ixp4xx_get_drvinfo,
.nway_reset = ixp4xx_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_ts_info = ixp4xx_get_ts_info, .get_ts_info = ixp4xx_get_ts_info,
.get_link_ksettings = phy_ethtool_get_link_ksettings, .get_link_ksettings = phy_ethtool_get_link_ksettings,
......
...@@ -1441,3 +1441,14 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev, ...@@ -1441,3 +1441,14 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev,
return phy_ethtool_ksettings_set(phydev, cmd); return phy_ethtool_ksettings_set(phydev, cmd);
} }
EXPORT_SYMBOL(phy_ethtool_set_link_ksettings); EXPORT_SYMBOL(phy_ethtool_set_link_ksettings);
int phy_ethtool_nway_reset(struct net_device *ndev)
{
struct phy_device *phydev = ndev->phydev;
if (!phydev)
return -ENODEV;
return genphy_restart_aneg(phydev);
}
EXPORT_SYMBOL(phy_ethtool_nway_reset);
...@@ -149,14 +149,6 @@ static const struct net_device_ops ax88172a_netdev_ops = { ...@@ -149,14 +149,6 @@ static const struct net_device_ops ax88172a_netdev_ops = {
.ndo_set_rx_mode = asix_set_multicast, .ndo_set_rx_mode = asix_set_multicast,
}; };
static int ax88172a_nway_reset(struct net_device *net)
{
if (!net->phydev)
return -ENODEV;
return phy_start_aneg(net->phydev);
}
static const struct ethtool_ops ax88172a_ethtool_ops = { static const struct ethtool_ops ax88172a_ethtool_ops = {
.get_drvinfo = asix_get_drvinfo, .get_drvinfo = asix_get_drvinfo,
.get_link = usbnet_get_link, .get_link = usbnet_get_link,
...@@ -167,7 +159,7 @@ static const struct ethtool_ops ax88172a_ethtool_ops = { ...@@ -167,7 +159,7 @@ static const struct ethtool_ops ax88172a_ethtool_ops = {
.get_eeprom_len = asix_get_eeprom_len, .get_eeprom_len = asix_get_eeprom_len,
.get_eeprom = asix_get_eeprom, .get_eeprom = asix_get_eeprom,
.set_eeprom = asix_set_eeprom, .set_eeprom = asix_set_eeprom,
.nway_reset = ax88172a_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_link_ksettings = phy_ethtool_get_link_ksettings, .get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings,
}; };
......
...@@ -1447,11 +1447,6 @@ static u32 lan78xx_get_link(struct net_device *net) ...@@ -1447,11 +1447,6 @@ static u32 lan78xx_get_link(struct net_device *net)
return net->phydev->link; return net->phydev->link;
} }
static int lan78xx_nway_reset(struct net_device *net)
{
return phy_start_aneg(net->phydev);
}
static void lan78xx_get_drvinfo(struct net_device *net, static void lan78xx_get_drvinfo(struct net_device *net,
struct ethtool_drvinfo *info) struct ethtool_drvinfo *info)
{ {
...@@ -1655,7 +1650,7 @@ static int lan78xx_set_pause(struct net_device *net, ...@@ -1655,7 +1650,7 @@ static int lan78xx_set_pause(struct net_device *net,
static const struct ethtool_ops lan78xx_ethtool_ops = { static const struct ethtool_ops lan78xx_ethtool_ops = {
.get_link = lan78xx_get_link, .get_link = lan78xx_get_link,
.nway_reset = lan78xx_nway_reset, .nway_reset = phy_ethtool_nway_reset,
.get_drvinfo = lan78xx_get_drvinfo, .get_drvinfo = lan78xx_get_drvinfo,
.get_msglevel = lan78xx_get_msglevel, .get_msglevel = lan78xx_get_msglevel,
.set_msglevel = lan78xx_set_msglevel, .set_msglevel = lan78xx_set_msglevel,
......
...@@ -860,6 +860,7 @@ int phy_ethtool_get_link_ksettings(struct net_device *ndev, ...@@ -860,6 +860,7 @@ int phy_ethtool_get_link_ksettings(struct net_device *ndev,
struct ethtool_link_ksettings *cmd); struct ethtool_link_ksettings *cmd);
int phy_ethtool_set_link_ksettings(struct net_device *ndev, int phy_ethtool_set_link_ksettings(struct net_device *ndev,
const struct ethtool_link_ksettings *cmd); const struct ethtool_link_ksettings *cmd);
int phy_ethtool_nway_reset(struct net_device *ndev);
int __init mdio_bus_init(void); int __init mdio_bus_init(void);
void mdio_bus_exit(void); void mdio_bus_exit(void);
......
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