Skip to contentSkip to conversation

fix 10GBE support for AMD Versal Gen 2

PATCH Applied Pranav Tilak 2 participants 5 messages Apr 10 – Apr 15

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

cover fix 10GBE support for AMD Versal Gen 2

This series fixes three issues in the zynq_gem driver required for 10GBE to function correctly on AMD Versal Gen 2.

Pranav Tilak (3):
net: zynq_gem: add SPEED_10000 case in clock rate selection
net: zynq_gem: set 128-bit AXI bus width for 10GBE
net: zynq_gem: reinitialize RX BDs on every init

 drivers/net/zynq_gem.c | 60 ++++++++++++++++++++++++++----------------
 1 file changed, 38 insertions(+), 22 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 net: zynq_gem: add SPEED_10000 case in clock rate selection

Add SPEED_10000 case in the speed switch with the fixed 150 MHz tx_clk rate. Without this, clk_rate stays 0 for 10000 Mbps and clk_set_rate(0) on a fixed clock aborts initialization.

---
 drivers/net/zynq_gem.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/zynq_gem.c +4 -0
index a50d5aee03f..c06d114af68 100644
@@ -134,6 +134,7 @@
 #define ZYNQ_GEM_FREQUENCY_10	2500000UL
 #define ZYNQ_GEM_FREQUENCY_100	25000000UL
 #define ZYNQ_GEM_FREQUENCY_1000	125000000UL
+#define ZYNQ_GEM_FREQUENCY_10000	150000000UL
 
 #define RXCLK_EN		BIT(0)
 
@@ -602,6 +603,9 @@ static int zynq_gem_init(struct udevice *dev)
 	}
 
 	switch (priv->phydev->speed) {
+	case SPEED_10000:
+		clk_rate = ZYNQ_GEM_FREQUENCY_10000;
+		break;
 	case SPEED_1000:
 		nwconfig |= ZYNQ_GEM_NWCFG_SPEED1000;
 		clk_rate = ZYNQ_GEM_FREQUENCY_1000;
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 net: zynq_gem: set 128-bit AXI bus width for 10GBE

In reply to Pranav Tilak

Set 128-bit AXI bus width in network config for 10GBE. The default 64-bit setting causes DMA data corruption.

---
 drivers/net/zynq_gem.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/zynq_gem.c +5 -0
index c06d114af68..e9210d42438 100644
@@ -69,10 +69,13 @@
 #define ZYNQ_GEM_NWCFG_SGMII_ENBL	0x08000000 /* SGMII Enable */
 #define ZYNQ_GEM_NWCFG_PCS_SEL		0x00000800 /* PCS select */
 
+#define ZYNQ_GEM_DBUS_WIDTH_MASK	(3 << 21) /* bits 22:21 */
 #ifdef CONFIG_ARM64
 # define ZYNQ_GEM_DBUS_WIDTH	(1 << 21) /* 64 bit bus */
+# define ZYNQ_GEM_DBUS_WIDTH_128	(2 << 21) /* 128 bit bus */
 #else
 # define ZYNQ_GEM_DBUS_WIDTH	(0 << 21) /* 32 bit bus */
+# define ZYNQ_GEM_DBUS_WIDTH_128	(0 << 21) /* 32 bit bus */
 #endif
 
 #define ZYNQ_GEM_NWCFG_INIT		(ZYNQ_GEM_DBUS_WIDTH | \
@@ -533,6 +536,8 @@ static int zynq_gem_init(struct udevice *dev)
 	nwconfig = ZYNQ_GEM_NWCFG_INIT;
 
 	if (device_is_compatible(dev, "amd,versal2-10gbe")) {
+		nwconfig &= ~ZYNQ_GEM_DBUS_WIDTH_MASK;
+		nwconfig |= ZYNQ_GEM_DBUS_WIDTH_128;
 		if (priv->interface == PHY_INTERFACE_MODE_10GBASER) {
 			ctrl = readl(&regs->nwcfg);
 			ctrl |= PCSSEL;
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 net: zynq_gem: reinitialize RX BDs on every init

In reply to Pranav Tilak

Reinitialize RX BDs and rewrite rxqbase on every init instead of only on the first init. This ensures a clean BD state on every init for all GEM configurations.
For AMD Versal Gen 2 10GBE this is required since the USX block resets the RX DMA pointer to rxqbase on each init, so BDs must be rebuilt each time to stay in sync with hardware.

---
 drivers/net/zynq_gem.c | 51 ++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 22 deletions(-)
drivers/net/zynq_gem.c +29 -22
index e9210d42438..e3f9fd72d2f 100644
@@ -474,28 +474,6 @@ static int zynq_gem_init(struct udevice *dev)
 		for (i = 0; i < STAT_SIZE; i++)
 			readl(&regs->stat[i]);
 
-		/* Setup RxBD space */
-		memset(priv->rx_bd, 0, RX_BUF * sizeof(struct emac_bd));
-
-		for (i = 0; i < RX_BUF; i++) {
-			priv->rx_bd[i].status = 0xF0000000;
-			priv->rx_bd[i].addr =
-					(lower_32_bits((ulong)(priv->rxbuffers)
-							+ (i * PKTSIZE_ALIGN)));
-#if defined(CONFIG_PHYS_64BIT)
-			priv->rx_bd[i].addr_hi =
-					(upper_32_bits((ulong)(priv->rxbuffers)
-							+ (i * PKTSIZE_ALIGN)));
-#endif
-	}
-		/* WRAP bit to last BD */
-		priv->rx_bd[--i].addr |= ZYNQ_GEM_RXBUF_WRAP_MASK;
-		/* Write RxBDs to IP */
-		writel(lower_32_bits((ulong)priv->rx_bd), &regs->rxqbase);
-#if defined(CONFIG_PHYS_64BIT)
-		writel(upper_32_bits((ulong)priv->rx_bd), &regs->upper_rxqbase);
-#endif
-
 		/* Setup for DMA Configuration register */
 		writel(ZYNQ_GEM_DMACR_INIT, &regs->dmacr);
 
@@ -524,6 +502,35 @@ static int zynq_gem_init(struct udevice *dev)
 		priv->init++;
 	}
 
+	/*
+	 * Reinitialize RX BDs on every init. The 10GBE USX block asserts
+	 * RX_SYNC_RESET during setup which resets the GEM RX DMA pointer
+	 * back to rxqbase, so BDs and rxqbase must be refreshed each time
+	 * to keep the hardware and driver ring indices in sync.
+	 */
+	priv->rxbd_current = 0;
+	priv->rx_first_buf = 0;
+	memset(priv->rx_bd, 0, RX_BUF * sizeof(struct emac_bd));
+	for (i = 0; i < RX_BUF; i++) {
+		priv->rx_bd[i].status = 0xF0000000;
+		priv->rx_bd[i].addr =
+				(lower_32_bits((ulong)(priv->rxbuffers)
+						+ (i * PKTSIZE_ALIGN)));
+#if defined(CONFIG_PHYS_64BIT)
+		priv->rx_bd[i].addr_hi =
+				(upper_32_bits((ulong)(priv->rxbuffers)
+						+ (i * PKTSIZE_ALIGN)));
+#endif
+	}
+	/* WRAP bit to last BD */
+	priv->rx_bd[--i].addr |= ZYNQ_GEM_RXBUF_WRAP_MASK;
+
+	/* Write RxBDs to IP */
+	writel(lower_32_bits((ulong)priv->rx_bd), &regs->rxqbase);
+#if defined(CONFIG_PHYS_64BIT)
+	writel(upper_32_bits((ulong)priv->rx_bd), &regs->upper_rxqbase);
+#endif
+
 	ret = phy_startup(priv->phydev);
 	if (ret)
 		return ret;
Signature · 1 line
2.43.0
maintainer Applied
#4 lore raw
In reply to Pranav Tilak
Quoted 11 lines · Pranav Tilak

This series fixes three issues in the zynq_gem driver required for 10GBE to function correctly on AMD Versal Gen 2.

Pranav Tilak (3):
net: zynq_gem: add SPEED_10000 case in clock rate selection
net: zynq_gem: set 128-bit AXI bus width for 10GBE
net: zynq_gem: reinitialize RX BDs on every init

  drivers/net/zynq_gem.c | 60 ++++++++++++++++++++++++++----------------
  1 file changed, 38 insertions(+), 22 deletions(-)

Applied.
M