Skip to contentSkip to conversation

net: ethernet: add support for high speed mac and usxgmii pcs

PATCH In review Parshuram Thombare 2 participants 3 messages Feb 22, 2019 – Feb 23, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 net: ethernet: add support for high speed mac and usxgmii pcs

This patch add support for (10G) high speed mac, usxgmii pcs and usxgmii interface in Cadence ethernet controller driver.

---
 drivers/net/ethernet/cadence/macb.h      |   33 +++++++++
 drivers/net/ethernet/cadence/macb_main.c |  110 ++++++++++++++++++++++++++++--
 include/linux/phy.h                      |    3 +
 3 files changed, 140 insertions(+), 6 deletions(-)
drivers/net/ethernet/cadence/macb.h +33 -0
index 59c23e0..34df014 100644
@@ -84,6 +84,7 @@
 #define GEM_USRIO		0x000c /* User IO */
 #define GEM_DMACFG		0x0010 /* DMA Configuration */
 #define GEM_JML			0x0048 /* Jumbo Max Length */
+#define GEM_HS_MAC_CONFIG	0x0050 /* GEM high speed config */
 #define GEM_HRB			0x0080 /* Hash Bottom */
 #define GEM_HRT			0x0084 /* Hash Top */
 #define GEM_SA1B		0x0088 /* Specific1 Bottom */
@@ -168,6 +169,9 @@
 #define GEM_DCFG7		0x0298 /* Design Config 7 */
 #define GEM_DCFG8		0x029C /* Design Config 8 */
 #define GEM_DCFG10		0x02A4 /* Design Config 10 */
+#define GEM_DCFG12		0x02AC /* Design Config 12 */
+#define GEM_USX_CONTROL		0x0A80 /* USXGMII control register */
+#define GEM_USX_STATUS		0x0A88 /* USXGMII status register */
 
 #define GEM_TXBDCTRL	0x04cc /* TX Buffer Descriptor control register */
 #define GEM_RXBDCTRL	0x04d0 /* RX Buffer Descriptor control register */
@@ -275,6 +279,8 @@
 #define MACB_IRXFCS_SIZE	1
 
 /* GEM specific NCR bitfields. */
+#define GEM_ENABLE_HS_MAC_OFFSET	31
+#define GEM_ENABLE_HS_MAC_SIZE		1
 #define GEM_TWO_PT_FIVE_GIG_OFFSET	29
 #define GEM_TWO_PT_FIVE_GIG_SIZE	1
 
@@ -463,6 +469,10 @@
 #define MACB_REV_OFFSET				0
 #define MACB_REV_SIZE				16
 
+/* Bitfield in HS_MAC_CONFIG */
+#define GEM_HS_MAC_SPEED_OFFSET			0
+#define GEM_HS_MAC_SPEED_SIZE			3
+
 /* Bitfields in DCFG1. */
 #define GEM_IRQCOR_OFFSET			23
 #define GEM_IRQCOR_SIZE				1
@@ -504,6 +514,28 @@
 #define GEM_RXBD_RDBUFF_OFFSET			8
 #define GEM_RXBD_RDBUFF_SIZE			4
 
+/* Bitfields in DCFG12. */
+#define GEM_HIGH_SPEED_OFFSET			26
+#define GEM_HIGH_SPEED_SIZE			1
+
+/* Bitfields in USX_CONTROL. */
+#define GEM_USX_CTRL_SPEED_OFFSET		14
+#define GEM_USX_CTRL_SPEED_SIZE			3
+#define GEM_SERDES_RATE_OFFSET			12
+#define GEM_SERDES_RATE_SIZE			2
+#define GEM_TX_EN_OFFSET			1
+#define GEM_TX_EN_SIZE				1
+#define GEM_SIGNAL_OK_OFFSET			0
+#define GEM_SIGNAL_OK_SIZE			1
+
+/* Bitfields in USX_STATUS. */
+#define GEM_USX_TX_FAULT_OFFSET			28
+#define GEM_USX_TX_FAULT_SIZE			1
+#define GEM_USX_RX_FAULT_OFFSET			27
+#define GEM_USX_RX_FAULT_SIZE			1
+#define GEM_USX_BLOCK_LOCK_OFFSET		0
+#define GEM_USX_BLOCK_LOCK_SIZE			1
+
 /* Bitfields in TISUBN */
 #define GEM_SUBNSINCR_OFFSET			0
 #define GEM_SUBNSINCR_SIZE			16
@@ -664,6 +696,7 @@
 #define MACB_CAPS_MACB_IS_GEM			0x80000000
 #define MACB_CAPS_PCS				0x01000000
 #define MACB_CAPS_TWO_PT_FIVE_GIG_SPEED		0x02000000
+#define MACB_CAPS_HIGH_SPEED			0x04000000
 
 #define MACB_GEM7010_IDNUM			0x009
 #define MACB_GEM7014_IDNUM			0x107
drivers/net/ethernet/cadence/macb_main.c +104 -6

152 lines not on this page · raw message

include/linux/phy.h +3 -0
index 8e9fc57..b627e30 100644
@@ -94,6 +94,7 @@
 	PHY_INTERFACE_MODE_RTBI,
 	PHY_INTERFACE_MODE_SMII,
 	PHY_INTERFACE_MODE_XGMII,
+	PHY_INTERFACE_MODE_USXGMII,
 	PHY_INTERFACE_MODE_MOCA,
 	PHY_INTERFACE_MODE_QSGMII,
 	PHY_INTERFACE_MODE_TRGMII,
@@ -162,6 +163,8 @@ unsigned int phy_supported_speeds(struct phy_device *phy,
 		return "smii";
 	case PHY_INTERFACE_MODE_XGMII:
 		return "xgmii";
+	case PHY_INTERFACE_MODE_USXGMII:
+		return "usxgmii";
 	case PHY_INTERFACE_MODE_MOCA:
 		return "moca";
 	case PHY_INTERFACE_MODE_QSGMII:
Signature · 1 line
1.7.1
maintainer
#1 lore raw
Quoted 4 lines
drivers/net/ethernet/cadence/macb_main.c +0 -3
 	if (macb_is_gem(bp)) {
-		linkmode_copy(phydev->supported, PHY_GBIT_FEATURES);
-		if (bp->caps & MACB_CAPS_TWO_PT_FIVE_GIG_SPEED)
-			linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev) · line 713

Quoted 10 lines
drivers/net/ethernet/cadence/macb_main.c +9 -1
-					 phydev->supported);
+		if (bp->caps & MACB_CAPS_HIGH_SPEED) {
+			linkmode_copy(phydev->supported, PHY_10GBIT_FEATURES);
+		} else {
+			u32 bitmask = ETHTOOL_LINK_MODE_2500baseT_Full_BIT;
+
+			linkmode_copy(phydev->supported, PHY_GBIT_FEATURES);
+			if (bp->caps & MACB_CAPS_TWO_PT_FIVE_GIG_SPEED)
+				linkmode_set_bit(bitmask, phydev->supported);
+		}

Same issue again. Somebody could be using a 10G MAC with a 2.5G PHY.

Andrew

#2 lore raw
Quoted 15 lines

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev)

Quoted 4 lines
drivers/net/ethernet/cadence/macb_main.c +0 -3
 	if (macb_is_gem(bp)) {
-		linkmode_copy(phydev->supported, PHY_GBIT_FEATURES);
-		if (bp->caps & MACB_CAPS_TWO_PT_FIVE_GIG_SPEED)
-

linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev)

Quoted 3 lines
drivers/net/ethernet/cadence/macb_main.c +2 -1
-					 phydev->supported);
+		if (bp->caps & MACB_CAPS_HIGH_SPEED) {
+			linkmode_copy(phydev->supported,

PHY_10GBIT_FEATURES);

Review

Quoted 2 lines
(quoted diff) +2 -0
+		} else {
+			u32 bitmask =

ETHTOOL_LINK_MODE_2500baseT_Full_BIT;

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+			linkmode_copy(phydev->supported,

PHY_GBIT_FEATURES);

Quoted 7 lines

drivers/net/ethernet/cadence/macb_main.c static int macb_mii_probe(struct net_device *dev) · line 713

Quoted 3 lines
drivers/net/ethernet/cadence/macb_main.c +3 -0
+			if (bp->caps & MACB_CAPS_TWO_PT_FIVE_GIG_SPEED)
+				linkmode_set_bit(bitmask, phydev->supported);
+		}

Same issue again. Somebody could be using a 10G MAC with a 2.5G PHY.

Andrew

Hi Andrew,

Ok, I think this should have been logical AND. I will modify to use phy_set_max_speed() instead of directly copying linkmodes.

Regards,
Parshuram Thombare