fix 10GBE support for AMD Versal Gen 2
Subsystems (2)
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
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
@@ -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
PATCH 2/3 net: zynq_gem: set 128-bit AXI bus width for 10GBE
In reply to Pranav TilakSet 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
@@ -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 (®s->nwcfg); ctrl |=PCSSEL ;
Signature · 1 line
2.43.0
PATCH 3/3 net: zynq_gem: reinitialize RX BDs on every init
In reply to Pranav TilakReinitialize 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
@@ -474,28 +474,6 @@ static int zynq_gem_init(struct udevice *dev)for (i =0 ; i <STAT_SIZE ; i++)readl (®s->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), ®s->rxqbase); -#if defined(CONFIG_PHYS_64BIT ) -writel (upper_32_bits ((ulong )priv->rx_bd), ®s->upper_rxqbase); -#endif -/* Setup for DMA Configuration register */ writel (ZYNQ_GEM_DMACR_INIT , ®s->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), ®s->rxqbase); +#if defined(CONFIG_PHYS_64BIT ) +writel (upper_32_bits ((ulong )priv->rx_bd), ®s->upper_rxqbase); +#endif + ret =phy_startup (priv->phydev);if (ret)return ret;
Signature · 1 line
2.43.0
Quoted 11 lines · Pranav Tilak
This series fixes three issues in the
zynq_gemdriver required for 10GBE to function correctly on AMD Versal Gen 2.Pranav Tilak (3):
net:zynq_gem: addSPEED_10000case in clock rate selection
net:zynq_gem: set 128-bit AXI bus width for 10GBE
net:zynq_gem: reinitialize RX BDs on every initdrivers/net/zynq_gem.c | 60 ++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 22 deletions(-)
Applied.
M