diff options
author | David S. Miller <davem@davemloft.net> | 2019-04-02 13:16:17 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-02 13:16:17 -0700 |
commit | 40d0690bd0b681a797d5b9752b72c2890d9d1220 (patch) | |
tree | b5bf6c846595526713022e0ee9f82bc05907f9e9 | |
parent | fa288a42646c3294c5061812c2314a822bfd537c (diff) | |
parent | 372fcc1b8b66148367af8374d09d48b6a0385faf (diff) | |
download | linux-40d0690bd0b681a797d5b9752b72c2890d9d1220.tar.gz linux-40d0690bd0b681a797d5b9752b72c2890d9d1220.tar.bz2 linux-40d0690bd0b681a797d5b9752b72c2890d9d1220.zip |
Merge branch 'net-phy-improve-genphy_c45_read_lpa'
Heiner Kallweit says:
====================
net: phy: improve genphy_c45_read_lpa
This series improves genphy_c45_read_lpa:
- Use clause 45 standard register / bit to detect link partner autoneg
capability.
- Consider that lpa register values may be invalid if "autoneg complete"
bit isn't set.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/phy/phy-c45.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 9e24d9569424..05c3e87ffc2d 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -262,12 +262,30 @@ int genphy_c45_read_lpa(struct phy_device *phydev) { int val; + val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1); + if (val < 0) + return val; + + if (!(val & MDIO_AN_STAT1_COMPLETE)) { + linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, + phydev->lp_advertising); + mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0); + mii_adv_mod_linkmode_adv_t(phydev->lp_advertising, 0); + phydev->pause = 0; + phydev->asym_pause = 0; + + return 0; + } + + linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->lp_advertising, + val & MDIO_AN_STAT1_LPABLE); + /* Read the link partner's base page advertisement */ val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_LPA); if (val < 0) return val; - mii_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, val); + mii_adv_mod_linkmode_adv_t(phydev->lp_advertising, val); phydev->pause = val & LPA_PAUSE_CAP ? 1 : 0; phydev->asym_pause = val & LPA_PAUSE_ASYM ? 1 : 0; |