Skip to contentSkip to conversation

net: bcmgenet: use MAC link status for fixed phy

PATCH Superseded Doug Berger 3 participants 3 messages Aug 28, 2018 – Aug 30, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Doug Berger

author maintainer
#0 lore raw

PATCH 1/1 net: bcmgenet: use MAC link status for fixed phy

When using the fixed PHY with GENET (e.g. MOCA) the PHY link status can be determined from the internal link status captured by the MAC. This allows the PHY state machine to use the correct link state with the fixed PHY even if MAC link event interrupts are missed when the net device is opened.

Fixes 8d88c6e ("net: bcmgenet: enable MoCA link state change detection")
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |  3 +++
 drivers/net/ethernet/broadcom/genet/bcmmii.c   | 10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.h +3 -0
index b773bc0..14b49612a 100644
@@ -186,6 +186,9 @@ struct bcmgenet_mib_counters {
 #define UMAC_MAC1			0x010
 #define UMAC_MAX_FRAME_LEN		0x014
 
+#define UMAC_MODE			0x44
+#define  MODE_LINK_STATUS		(1 << 5)
+
 #define UMAC_EEE_CTRL			0x064
 #define  EN_LPI_RX_PAUSE		(1 << 0)
 #define  EN_LPI_TX_PFC			(1 << 1)
drivers/net/ethernet/broadcom/genet/bcmmii.c +8 -2
index 5333274..4241ae9 100644
@@ -115,8 +115,14 @@ void bcmgenet_mii_setup(struct net_device *dev)
 static int bcmgenet_fixed_phy_link_update(struct net_device *dev,
 					  struct fixed_phy_status *status)
 {
-	if (dev && dev->phydev && status)
-		status->link = dev->phydev->link;
+	struct bcmgenet_priv *priv;
+	u32 reg;
+
+	if (dev && dev->phydev && status) {
+		priv = netdev_priv(dev);
+		reg = bcmgenet_umac_readl(priv, UMAC_MODE);
+		status->link = !!(reg & MODE_LINK_STATUS);
+	}
 
 	return 0;
 }
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Doug Berger

When using the fixed PHY with GENET (e.g. MOCA) the PHY link status can be determined from the internal link status captured by the MAC. This allows the PHY state machine to use the correct link state with the fixed PHY even if MAC link event interrupts are missed when the net device is opened.

Fixes 8d88c6e ("net: bcmgenet: enable MoCA link state change detection")

The 12-digit sha1 for that commit would be 8d88c6ebb34c

Quoted 1 line

Thanks Doug!

Quoted 41 lines
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |  3 +++
 drivers/net/ethernet/broadcom/genet/bcmmii.c   | 10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.h +3 -0
index b773bc0..14b49612a 100644
@@ -186,6 +186,9 @@ struct bcmgenet_mib_counters {
 #define UMAC_MAC1			0x010
 #define UMAC_MAX_FRAME_LEN		0x014
 
+#define UMAC_MODE			0x44
+#define  MODE_LINK_STATUS		(1 << 5)
+
 #define UMAC_EEE_CTRL			0x064
 #define  EN_LPI_RX_PAUSE		(1 << 0)
 #define  EN_LPI_TX_PFC			(1 << 1)
drivers/net/ethernet/broadcom/genet/bcmmii.c +8 -2
index 5333274..4241ae9 100644
@@ -115,8 +115,14 @@ void bcmgenet_mii_setup(struct net_device *dev)
 static int bcmgenet_fixed_phy_link_update(struct net_device *dev,
 					  struct fixed_phy_status *status)
 {
-	if (dev && dev->phydev && status)
-		status->link = dev->phydev->link;
+	struct bcmgenet_priv *priv;
+	u32 reg;
+
+	if (dev && dev->phydev && status) {
+		priv = netdev_priv(dev);
+		reg = bcmgenet_umac_readl(priv, UMAC_MODE);
+		status->link = !!(reg & MODE_LINK_STATUS);
+	}
 
 	return 0;
 }
Signature · 1 line
Florian
maintainer
#2 lore raw
In reply to Doug Berger

From: Doug Berger <[email protected]>
Date: Tue, 28 Aug 2018 12:33:15 -0700

Quoted 8 lines

When using the fixed PHY with GENET (e.g. MOCA) the PHY link status can be determined from the internal link status captured by the MAC. This allows the PHY state machine to use the correct link state with the fixed PHY even if MAC link event interrupts are missed when the net device is opened.

Fixes 8d88c6e ("net: bcmgenet: enable MoCA link state change detection")

Applied with fixed Fixes: tag SHA1-ID and queued up for -stable.