net: phy: add GBit master / slave error detection
authorHeiner Kallweit <hkallweit1@gmail.com>
Sat, 21 Jul 2018 13:48:47 +0000 (15:48 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Jul 2018 21:41:08 +0000 (14:41 -0700)
Certain PHY's have issues when operating in GBit slave mode and can
be forced to master mode. Examples are RTL8211C, also the Micrel PHY
driver has a DT setting to force master mode.
If two such chips are link partners the autonegotiation will fail.
Standard defines a self-clearing on read, latched-high bit to
indicate this error. Check this bit to inform the user.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy_device.c
include/uapi/linux/mii.h

index b9f5f40a7ac1e6640a653e8207cdd8885100e09f..db1172db1e7cb7df0fed8a21b0a7757ae6c068b5 100644 (file)
@@ -1555,6 +1555,14 @@ int genphy_read_status(struct phy_device *phydev)
                        if (adv < 0)
                                return adv;
 
+                       if (lpagb & LPA_1000MSFAIL) {
+                               if (adv & CTL1000_ENABLE_MASTER)
+                                       phydev_err(phydev, "Master/Slave resolution failed, maybe conflicting manual settings?\n");
+                               else
+                                       phydev_err(phydev, "Master/Slave resolution failed\n");
+                               return -ENOLINK;
+                       }
+
                        phydev->lp_advertising =
                                mii_stat1000_to_ethtool_lpa_t(lpagb);
                        common_adv_gb = lpagb & adv << 2;
index b5c2fdcf23fdb66616fdd17e4060b85e45949728..a506216591d65b590c868c7f26e8b1355d9c4742 100644 (file)
 #define CTL1000_ENABLE_MASTER  0x1000
 
 /* 1000BASE-T Status register */
+#define LPA_1000MSFAIL         0x8000  /* Master/Slave resolution failure */
 #define LPA_1000LOCALRXOK      0x2000  /* Link partner local receiver status */
 #define LPA_1000REMRXOK                0x1000  /* Link partner remote receiver status */
 #define LPA_1000FULL           0x0800  /* Link partner 1000BASE-T full duplex */