Skip to content

Commit

Permalink
net: phy: restart phy autonegotiation after EEE advertisment change
Browse files Browse the repository at this point in the history
When the EEE advertisment is changed, we should restart autonegotiation
to update the link partner with the new EEE settings.  Add this trigger
but only if the advertisment has changed.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Russell King authored and David S. Miller committed Apr 2, 2017
1 parent 83ea067 commit f75abeb
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
*/
int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
{
int cap, adv;
int cap, old_adv, adv, ret;

if (!phydev->drv)
return -EIO;
Expand All @@ -1342,12 +1342,29 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
if (cap < 0)
return cap;

old_adv = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
if (old_adv < 0)
return old_adv;

adv = ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;

/* Mask prohibited EEE modes */
adv &= ~phydev->eee_broken_modes;

return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
if (old_adv != adv) {
ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
if (ret < 0)
return ret;

/* Restart autonegotiation so the new modes get sent to the
* link partner.
*/
ret = genphy_restart_aneg(phydev);
if (ret < 0)
return ret;
}

return 0;
}
EXPORT_SYMBOL(phy_ethtool_set_eee);

Expand Down

0 comments on commit f75abeb

Please sign in to comment.