404-net-phy-restart-phy-autonegotiation-after-EEE-advert.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From: Russell King <[email protected]>
  2. Date: Thu, 5 Jan 2017 12:21:09 +0000
  3. Subject: [PATCH] net: phy: restart phy autonegotiation after EEE
  4. advertisment change
  5. When the EEE advertisment is changed, we should restart autonegotiation
  6. to update the link partner with the new EEE settings. Add this trigger
  7. but only if the advertisment has changed.
  8. Signed-off-by: Russell King <[email protected]>
  9. ---
  10. --- a/drivers/net/phy/phy.c
  11. +++ b/drivers/net/phy/phy.c
  12. @@ -1343,19 +1343,36 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
  13. */
  14. int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
  15. {
  16. - int cap, adv;
  17. + int cap, old_adv, adv, ret;
  18. /* Get Supported EEE */
  19. cap = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
  20. if (cap < 0)
  21. return cap;
  22. + old_adv = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
  23. + if (old_adv < 0)
  24. + return old_adv;
  25. +
  26. adv = ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
  27. /* Mask prohibited EEE modes */
  28. adv &= ~phydev->eee_broken_modes;
  29. - return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
  30. + if (old_adv != adv) {
  31. + ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
  32. + if (ret < 0)
  33. + return ret;
  34. +
  35. + /* Restart autonegotiation so the new modes get sent to the
  36. + * link partner.
  37. + */
  38. + ret = phy_restart_aneg(phydev);
  39. + if (ret < 0)
  40. + return ret;
  41. + }
  42. +
  43. + return 0;
  44. }
  45. EXPORT_SYMBOL(phy_ethtool_set_eee);