2020-03-13 13:41:26

by Jose Abreu

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

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

Signed-off-by: Jose Abreu <[email protected]>

---
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(-)

diff --git a/drivers/net/phy/mdio-xpcs.c b/drivers/net/phy/mdio-xpcs.c
index a4cbeecc6d42..23516397b982 100644
--- a/drivers/net/phy/mdio-xpcs.c
+++ b/drivers/net/phy/mdio-xpcs.c
@@ -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)
--
2.7.4


2020-03-13 14:08:30

by Russell King (Oracle)

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

On Fri, Mar 13, 2020 at 02:39:41PM +0100, Jose Abreu wrote:
> 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.

>
> Signed-off-by: Jose Abreu <[email protected]>
>
> ---
> 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(-)
>
> diff --git a/drivers/net/phy/mdio-xpcs.c b/drivers/net/phy/mdio-xpcs.c
> index a4cbeecc6d42..23516397b982 100644
> --- a/drivers/net/phy/mdio-xpcs.c
> +++ b/drivers/net/phy/mdio-xpcs.c
> @@ -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)
> --
> 2.7.4
>
>

--
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