net: phy: improve genphy_c45_read_lpa
Subsystems (3)
Heiner Kallweit
maintainercover 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.
Heiner Kallweit (2):
net: phy: use c45 standard to detect link partner autoneg capability
net: phy: deal properly with autoneg incomplete in genphy_c45_read_lpa
drivers/net/phy/phy-c45.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
Signature · 1 line
2.21.0
Heiner Kallweit
maintainerPATCH 1/2 net: phy: use c45 standard to detect link partner autoneg capability
Currently mii_lpa_mod_linkmode_lpa_t() checks bit LPA_LPACK to detect whether link partner supports autoneg. This doesn't work correctly at least on Aquantia AQCS109 when it negotiates 1000Base-T2 mode. The "link partner is autoneg-capable" bit as defined by clause 45 is set however. Better let's switch in general to use the clause 45 standard for link partner autoneg detection.
--- drivers/net/phy/phy-c45.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/phy/phy-c45.c +8 -1
@@ -262,12 +262,19 @@ 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; + +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 ;
Signature · 1 line
2.21.0
Re: [PATCH net-next 1/2] net: phy: use c45 standard to detect link partner autoneg capability
Quoted 8 lines · Heiner Kallweit
Currently
mii_lpa_mod_linkmode_lpa_t()checks bitLPA_LPACKto detect whether link partner supports autoneg. This doesn't work correctly at least on Aquantia AQCS109 when it negotiates 1000Base-T2 mode. The "link partner is autoneg-capable" bit as defined by clause 45 is set however. Better let's switch in general to use the clause 45 standard for link partner autoneg detection.Signed-off-by Heiner Kallweit <[email protected]>
Andrew
Heiner Kallweit
maintainerPATCH 2/2 net: phy: deal properly with autoneg incomplete in genphy_c45_read_lpa
In reply to Heiner KallweitThe link partner advertisement registers are not guaranteed to contain valid values if autoneg is incomplete. Therefore, if MDIO_AN_STAT1_COMPLETE isn't set, let's clear all link partner capability bits. This also avoids unnecessary register reads if link is down and phylib is in polling mode.
--- drivers/net/phy/phy-c45.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/phy/phy-c45.c +11 -0
@@ -266,6 +266,17 @@ int genphy_c45_read_lpa(struct phy_device *phydev)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 );
Signature · 1 line
2.21.0
Re: [PATCH net-next 2/2] net: phy: deal properly with autoneg incomplete in genphy_c45_read_lpa
Quoted 7 lines · Heiner Kallweit
The link partner advertisement registers are not guaranteed to contain valid values if autoneg is incomplete. Therefore, if
MDIO_AN_STAT1_COMPLETEisn't set, let's clear all link partner capability bits. This also avoids unnecessary register reads if link is down and phylib is in polling mode.Signed-off-by Heiner Kallweit <[email protected]>
Andrew
David Miller
maintainerFrom: Heiner Kallweit <[email protected]>
Date: Sun, 31 Mar 2019 19:51:45 +0200
Quoted 5 lines
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.
Series applied, thanks Heiner.