Skip to contentSkip to conversation

net: phy: xpcs: Link errors improvements

PATCH In review Jose Abreu 2 participants 8 messages Mar 13, 2020

Subsystems (3)
lore
Share & tools
lore
author
#7 lore raw

PATCH 4/4 net: phy: xpcs: Reset XPCS upon probe

In reply to Jose Abreu

Reset the XPCS upon probe stage so that we start it from well known state.

---
Cc: Jose Abreu <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: Russell King <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 drivers/net/phy/mdio-xpcs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/mdio-xpcs.c +1 -1
index 83ced7180a44..7960dc52c4bd 100644
@@ -595,7 +595,7 @@ static int xpcs_probe(struct mdio_xpcs_args *xpcs, phy_interface_t interface)
 			match = entry;
 
 			if (xpcs_check_features(xpcs, match, interface))
-				return 0;
+				return xpcs_soft_reset(xpcs, MDIO_MMD_PCS);
 		}
 	}
 
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/4 net: phy: xpcs: Clear latched value of RX/TX fault

In reply to Jose Abreu

When reading RX/TX fault register we may have latched values from Link down. Clear the latched value first and then read it again to make sure no old errors are flagged and that new errors are caught.

---
Cc: Jose Abreu <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: Russell King <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 drivers/net/phy/mdio-xpcs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/phy/mdio-xpcs.c +1 -0
index 973f588146f7..a4cbeecc6d42 100644
@@ -185,6 +185,7 @@ static int xpcs_read_fault(struct mdio_xpcs_args *xpcs,
 		return -EFAULT;
 	}
 
+	xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT2);
 	ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT2);
 	if (ret < 0)
 		return ret;
Signature · 1 line
2.7.4
author
#6 lore raw

PATCH 3/4 net: phy: xpcs: Return error when 10GKR link errors are found

In reply to Jose Abreu

For 10GKR rate, when link errors are found we need to return fault status so that XPCS is correctly resumed.

---
Cc: Jose Abreu <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: Russell King <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 drivers/net/phy/mdio-xpcs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/phy/mdio-xpcs.c +3 -1
index 23516397b982..83ced7180a44 100644
@@ -219,8 +219,10 @@ static int xpcs_read_fault(struct mdio_xpcs_args *xpcs,
 	if (ret < 0)
 		return ret;
 
-	if (ret & MDIO_PCS_10GBRT_STAT2_ERR)
+	if (ret & MDIO_PCS_10GBRT_STAT2_ERR) {
 		xpcs_warn(xpcs, state, "Link has errors!\n");
+		return -EFAULT;
+	}
 
 	return 0;
 }
Signature · 1 line
2.7.4
author
#4 lore raw

PATCH 2/4 net: phy: xpcs: Return error upon RX/TX fault

In reply to Jose Abreu

RX/TX fault status results in link errors. Return error upon these cases so that XPCS can be correctly resumed.

---
Cc: Jose Abreu <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: Russell King <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 drivers/net/phy/mdio-xpcs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/phy/mdio-xpcs.c +6 -2
index a4cbeecc6d42..23516397b982 100644
@@ -190,10 +190,14 @@ static int xpcs_read_fault(struct mdio_xpcs_args *xpcs,
 	if (ret < 0)
 		return ret;
 
-	if (ret & MDIO_STAT2_RXFAULT)
+	if (ret & MDIO_STAT2_RXFAULT) {
 		xpcs_warn(xpcs, state, "Receiver fault detected!\n");
-	if (ret & MDIO_STAT2_TXFAULT)
+		return -EFAULT;
+	}
+	if (ret & MDIO_STAT2_TXFAULT) {
 		xpcs_warn(xpcs, state, "Transmitter fault detected!\n");
+		return -EFAULT;
+	}
 
 	ret = xpcs_read_vendor(xpcs, MDIO_MMD_PCS, DW_VR_XS_PCS_DIG_STS);
 	if (ret < 0)
Signature · 1 line
2.7.4

Jose Abreu

author
#0 lore raw

cover net: phy: xpcs: Link errors improvements

First set of improvements for XPCS that were developed after exhaustive tests of Link Down / Link Up transitions.

As a side note, more fixes and improvements may come in the near future as we are adding XLGMII support at 25G, 40G, 50G and 100G speeds for both XPCS and stmmac drivers.

Patch 1/4, prevents reading old values from RX/TX fault.

Patch 2/4 and 3/4, signals the check link function for critical errors that can disturbe link normal operation and that need XPCS reset.

Patch 4/4, resets the XPCS at probe so that we start from a well known state.

---
Cc: Jose Abreu <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: Russell King <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Cc: [email protected]
---

Jose Abreu (4):
net: phy: xpcs: Clear latched value of RX/TX fault
net: phy: xpcs: Return error upon RX/TX fault
net: phy: xpcs: Return error when 10GKR link errors are found
net: phy: xpcs: Reset XPCS upon probe

 drivers/net/phy/mdio-xpcs.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH net-next 1/4] net: phy: xpcs: Clear latched value of RX/TX fault

In reply to Jose Abreu
Quoted 3 lines · Jose Abreu

When reading RX/TX fault register we may have latched values from Link down. Clear the latched value first and then read it again to make sure no old errors are flagged and that new errors are caught.

The purpose of the latched link down is so that software can respond to a momentary loss of link with a possible change in the negotiation results. That is why IEEE 802.3 wants a link loss to be a latched event.

Double-reading the status register loses that information, and hides it from phylink. A change in negotiation, which can occur very quickly on fiber links) can go unnoticed if the latching is not propagated up through phylink.

If the negotiation parameters have changed, and pcs_get_state() does not report that the link has failed, then mac_link_up() will _not_ be called with the new link parameters, and the MAC will continue using the old ones. Therefore, it is very important that any link-down event is reported to phylink.

Phylink currently doesn't respond to a link-down event reported via PCS by re-checking after processing the link loss, but it could do, which would improve it's behaviour in that scenario. I would prefer this resolution, rather than your proposed double-reading of the status register to "lose" the link-down event.

I do have some patches that make that easier, but they're delayed behind the mass of patches that I still have outstanding - and trying to get progress on getting phylink patches merged has been glacial, and fraught with problems this time around.

Quoted 32 lines

---
Cc: Jose Abreu <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: Russell King <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 drivers/net/phy/mdio-xpcs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/phy/mdio-xpcs.c +1 -0
index 973f588146f7..a4cbeecc6d42 100644
@@ -185,6 +185,7 @@ static int xpcs_read_fault(struct mdio_xpcs_args *xpcs,
 		return -EFAULT;
 	}
 
+	xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT2);
 	ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT2);
 	if (ret < 0)
 		return ret;
Signature · 1 line
2.7.4
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up
#5 lore raw

Re: [PATCH net-next 2/4] net: phy: xpcs: Return error upon RX/TX fault

In reply to Jose Abreu
Quoted 2 lines · Jose Abreu

RX/TX fault status results in link errors. Return error upon these cases so that XPCS can be correctly resumed.

Are you sure about this? I'm sure that I read in IEEE 802.3 that a loss of link results in a receive fault being indicated in status register 2.

See 49.2.14.1 describing "PCS_status" and the descriptions of MDIO registers 3.1.2 and 3.8.10. Basically, the link status (3.1.2) is a latched-low version of PCS_status, and 3.8.10 is an inverted version of this, independently latched-high.

Returning -EFAULT seems to mean that we'll soft-reset the PHY, and reconfigure it every time we attempt to read the status whenever the link is down.

Quoted 41 lines

---
Cc: Jose Abreu <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: Russell King <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 drivers/net/phy/mdio-xpcs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/phy/mdio-xpcs.c +6 -2
index a4cbeecc6d42..23516397b982 100644
@@ -190,10 +190,14 @@ static int xpcs_read_fault(struct mdio_xpcs_args *xpcs,
 	if (ret < 0)
 		return ret;
 
-	if (ret & MDIO_STAT2_RXFAULT)
+	if (ret & MDIO_STAT2_RXFAULT) {
 		xpcs_warn(xpcs, state, "Receiver fault detected!\n");
-	if (ret & MDIO_STAT2_TXFAULT)
+		return -EFAULT;
+	}
+	if (ret & MDIO_STAT2_TXFAULT) {
 		xpcs_warn(xpcs, state, "Transmitter fault detected!\n");
+		return -EFAULT;
+	}
 
 	ret = xpcs_read_vendor(xpcs, MDIO_MMD_PCS, DW_VR_XS_PCS_DIG_STS);
 	if (ret < 0)
Signature · 1 line
2.7.4
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up
author
#3 lore raw

RE: [PATCH net-next 1/4] net: phy: xpcs: Clear latched value of RX/TX fault

In reply to Russell King - ARM Linux admin

From: Russell King - ARM Linux admin <[email protected]>
Date: Mar/13/2020, 14:01:22 (UTC+00:00)

Quoted 27 lines · Jose Abreu
Quoted 3 lines

When reading RX/TX fault register we may have latched values from Link down. Clear the latched value first and then read it again to make sure no old errors are flagged and that new errors are caught.

The purpose of the latched link down is so that software can respond to a momentary loss of link with a possible change in the negotiation results. That is why IEEE 802.3 wants a link loss to be a latched event.

Double-reading the status register loses that information, and hides it from phylink. A change in negotiation, which can occur very quickly on fiber links) can go unnoticed if the latching is not propagated up through phylink.

If the negotiation parameters have changed, and pcs_get_state() does not report that the link has failed, then mac_link_up() will _not_ be called with the new link parameters, and the MAC will continue using the old ones. Therefore, it is very important that any link-down event is reported to phylink.

Phylink currently doesn't respond to a link-down event reported via PCS by re-checking after processing the link loss, but it could do, which would improve it's behaviour in that scenario. I would prefer this resolution, rather than your proposed double-reading of the status register to "lose" the link-down event.

Quoted 4 lines

I do have some patches that make that easier, but they're delayed behind the mass of patches that I still have outstanding - and trying to get progress on getting phylink patches merged has been glacial, and fraught with problems this time around.

This is not link status register. Its TX / RX fault and its latched high. Link status is another register and we only read it once because of the above reasons you mentioned.

When in 10GKR, this seems to always go up after link transition, hence we added the double read.

I just read your reply to patch 2/4 of this series and it looks like the two patches are correlated.

---
Thanks,
Jose Miguel Abreu