* [PATCH net-next 0/2] net: phy: improve genphy_c45_read_lpa
@ 2019-03-31 17:51 Heiner Kallweit
2019-03-31 17:52 ` [PATCH net-next 1/2] net: phy: use c45 standard to detect link partner autoneg capability Heiner Kallweit
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-03-31 17:51 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev@vger.kernel.org
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(-)
--
2.21.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/2] net: phy: use c45 standard to detect link partner autoneg capability
2019-03-31 17:51 [PATCH net-next 0/2] net: phy: improve genphy_c45_read_lpa Heiner Kallweit
@ 2019-03-31 17:52 ` Heiner Kallweit
2019-04-02 13:56 ` Andrew Lunn
2019-03-31 17:54 ` [PATCH net-next 2/2] net: phy: deal properly with autoneg incomplete in genphy_c45_read_lpa Heiner Kallweit
2019-04-02 20:16 ` [PATCH net-next 0/2] net: phy: improve genphy_c45_read_lpa David Miller
2 siblings, 1 reply; 6+ messages in thread
From: Heiner Kallweit @ 2019-03-31 17:52 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev@vger.kernel.org
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.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy-c45.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 9e24d9569..666fbb0ee 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -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;
--
2.21.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/2] net: phy: deal properly with autoneg incomplete in genphy_c45_read_lpa
2019-03-31 17:51 [PATCH net-next 0/2] net: phy: improve genphy_c45_read_lpa Heiner Kallweit
2019-03-31 17:52 ` [PATCH net-next 1/2] net: phy: use c45 standard to detect link partner autoneg capability Heiner Kallweit
@ 2019-03-31 17:54 ` Heiner Kallweit
2019-04-02 13:56 ` Andrew Lunn
2019-04-02 20:16 ` [PATCH net-next 0/2] net: phy: improve genphy_c45_read_lpa David Miller
2 siblings, 1 reply; 6+ messages in thread
From: Heiner Kallweit @ 2019-03-31 17:54 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev@vger.kernel.org
The 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.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy-c45.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 666fbb0ee..05c3e87ff 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -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);
--
2.21.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 2/2] net: phy: deal properly with autoneg incomplete in genphy_c45_read_lpa
2019-03-31 17:54 ` [PATCH net-next 2/2] net: phy: deal properly with autoneg incomplete in genphy_c45_read_lpa Heiner Kallweit
@ 2019-04-02 13:56 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2019-04-02 13:56 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: Florian Fainelli, David Miller, netdev@vger.kernel.org
On Sun, Mar 31, 2019 at 07:54:07PM +0200, Heiner Kallweit wrote:
> The 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.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] net: phy: use c45 standard to detect link partner autoneg capability
2019-03-31 17:52 ` [PATCH net-next 1/2] net: phy: use c45 standard to detect link partner autoneg capability Heiner Kallweit
@ 2019-04-02 13:56 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2019-04-02 13:56 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: Florian Fainelli, David Miller, netdev@vger.kernel.org
On Sun, Mar 31, 2019 at 07:52:51PM +0200, Heiner Kallweit wrote:
> 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.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/2] net: phy: improve genphy_c45_read_lpa
2019-03-31 17:51 [PATCH net-next 0/2] net: phy: improve genphy_c45_read_lpa Heiner Kallweit
2019-03-31 17:52 ` [PATCH net-next 1/2] net: phy: use c45 standard to detect link partner autoneg capability Heiner Kallweit
2019-03-31 17:54 ` [PATCH net-next 2/2] net: phy: deal properly with autoneg incomplete in genphy_c45_read_lpa Heiner Kallweit
@ 2019-04-02 20:16 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-04-02 20:16 UTC (permalink / raw)
To: hkallweit1; +Cc: andrew, f.fainelli, netdev
From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Sun, 31 Mar 2019 19:51:45 +0200
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-04-02 20:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-31 17:51 [PATCH net-next 0/2] net: phy: improve genphy_c45_read_lpa Heiner Kallweit
2019-03-31 17:52 ` [PATCH net-next 1/2] net: phy: use c45 standard to detect link partner autoneg capability Heiner Kallweit
2019-04-02 13:56 ` Andrew Lunn
2019-03-31 17:54 ` [PATCH net-next 2/2] net: phy: deal properly with autoneg incomplete in genphy_c45_read_lpa Heiner Kallweit
2019-04-02 13:56 ` Andrew Lunn
2019-04-02 20:16 ` [PATCH net-next 0/2] net: phy: improve genphy_c45_read_lpa David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).