Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch/zynq-mpsoc improve the ethernet driver #15769

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Documentation/platforms/arm64/zynq-mpsoc/boards/zcu111/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,37 @@ LEDs and Buttons
The PS-side pushbutton SW19 is connected to MIO22 (pin U1.Y28). The PS-side LED DS50,
which is physically placed adjacent to the pushbutton, is connected to MIO23(pin U1.U29).

Networking
==========

The ZCU111 board uses the TI DP83867IRPAP Ethernet RGMII PHY for Ethernet communications
at 10 Mb/s, 100 Mb/s, or 1000 Mb/s. The board supports RGMII mode only. The PHY connection
to a user-provided Ethernet cable is through a RJ-45 connector with built-in magnetics.
The Ethernet connections from XCZU28DR to the DP83867 PHY device at are listed in fllowing:

=== ================== === =============
Pin XCZU28DR Name Pin DP83867 Name
=== ================== === =============
J32 MIO65_ENET_TX_D0 38 TX_DO
J34 MIO66_ENET_TX_D1 37 TX_D1
K28 MIO67_ENET_TX_D2 36 TX_D2
K29 MIO68_ENET_TX_D3 35 TX_D3
K30 MIO69_ENET_TX_CTRL 52 TX_EN_TX_CTRL
K31 MIO70_ENET_RX_CLK 43 RX_CLK
K32 MIO71_ENET_RX_D0 44 RX_DO
K33 MIO72_ENET_RX_D1 45 RX_D1
K34 MIO73_ENET_RX_D2 46 RX_D2
L29 MIO74_ENET_RX_D3 47 RX_D3
L30 MIO75_ENET_RX_CTRL 53 RX_DV_RX_CTRL
L33 MIO76_ENET_MDC 20 MDC
L34 MIO77_ENET_MDIO 21 MDIO
=== ================== === =============

Networking is supported via GEM3. DHCP is not used in this configuration; rather, a hard-coded
IP address of 192.168.0.15 is used with a netmask of 255.255.255.0. The host is assumed to
be 192.168.0.101 in places. You can reconfigure to enabled DHCPC or to change these addresses
as you see fit.

Configurations
==============

Expand All @@ -83,6 +114,18 @@ zynqmp_fsbl.elf, zynqmp_pmufw.elf, bl31.elf and nuttx.elf in Vivado SDK or XSCT
shell. Also we need copy BOOT.BIN into SD Card(in SD card boot mode) or Flash it
into the QSPI FLASH(in QSPI boot mode).

netjtag
-------

This is a network enabled configuration based on the NuttShell (NSH) for JTAG boot mode

netnsh
------

This is a network enabled configuration based on the NuttShell (NSH). We need create boot
image with zynqmp_fsbl.elf, zynqmp_pmufw.elf, bl31.elf and nuttx.elf in Vivado SDK or XSCT
shell. Also we need Flash BOOT.BIN intothe QSPI FLASH(in QSPI boot mode).

ARM64 Toolchain
===============

Expand Down
33 changes: 32 additions & 1 deletion Documentation/platforms/arm64/zynq-mpsoc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MIO Yes
EMIO Yes Depending on PL
I2C No
CAN No
NET No
NET Yes GEM3
SPI No
QSPI No
TIMER NO
Expand Down Expand Up @@ -63,6 +63,37 @@ number of interrupts which may be undesirable.
UART can be configured/operated using ``zynq_uart_*`` functions. Both receive and
transmit can be operated in interrupt mode and polling mode.

ETHERNET
--------

The gigabit Ethernet controller (GEM) implements a 10/100/1000 Mb/s Ethernet MAC that
is compatible with the IEEE Standard for Ethernet (IEEE Std 802.3-2008) and capable of
operating in either half or full-duplex mode in 10/100 mode and full-duplex in 1000 mode.
The processing system (PS) is equipped with four gigabit Ethernet controllers. Each
controller can be configured independently. Each controller uses a reduced gigabit media
independent interface (RGMII) v2.0. Each GEM controller provides management data
input/output (MDIO) interfaces for PHY management. Key features of the NET driver are
summarized as follows:

- Configurable MAC.
- Configurable DMA receive buffer size.
- Configurable transmit packet size.
- Configurable TX and RX buffer number.
- Preallocate or malloc TX and RX buffer.
- Configurable PHY.
- MDIO phy read and write interface.
- Configurable phy address.
- PHY autonegotiation to determine speed and mode.
- Board support phy initialize.
- Configurable ethernet 1,2,3,4.
- Configurable ethernet speed 10M,100M,1000M.

Access to the programmable logic (PL) is through the EMIO which provides the gigabit
media independent interface (GMII). Other Ethernet communications interfaces can be
created in the PL using the GMII available on the EMIO interface. GEM supports the serial
gigabit media-independent interface (SGMII, 1000BASE-SX, and 1000BASE-LX) at 1000
Mb/s using the PS-GTR interface.

Psci and debug
--------------

Expand Down
10 changes: 10 additions & 0 deletions arch/arm64/src/zynq-mpsoc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ config ZYNQ_GMAC_NTXBUFFERS
that can be in flight. This is also equal to the number of TX
descriptors that will be allocated.

config ZYNQ_GMAC_RXDMA_BUFSIZE
int "RX DMA buffer size"
default 128
range 64 10240
---help---
DMA receive buffer size in external AMBA (AHB/AXI) system memory.
The value defined by these bits determines the size of buffer to
use in main system memory when writing received data. The value
must be defined as multiples of 64 bytes, i.e. 64, 128, 256...

config ZYNQ_GMAC_PREALLOCATE
bool "Preallocate buffers"
default n
Expand Down
7 changes: 0 additions & 7 deletions arch/arm64/src/zynq-mpsoc/zynq_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,3 @@ void arm64_chip_boot(void)
up_perf_init((void *)CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
#endif
}

#if defined(CONFIG_NET) && !defined(CONFIG_NETDEV_LATEINIT)
void arm64_netinitialize(void)
{
/* TODO: Support net initialize */
}
#endif
16 changes: 12 additions & 4 deletions arch/arm64/src/zynq-mpsoc/zynq_enet.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@

/* GMAC buffer sizes, number of buffers, and number of descriptors. *********/

#define GMAC_RX_UNITSIZE 128 /* Fixed size for RX buffer */
#define GMAC_TX_UNITSIZE CONFIG_NET_ETH_PKTSIZE /* MAX size for Ethernet packet */
#define GMAC_RX_UNITSIZE CONFIG_ZYNQ_GMAC_RXDMA_BUFSIZE /* DMA buffer size for receive */
#define GMAC_TX_UNITSIZE CONFIG_NET_ETH_PKTSIZE /* MAX size for Ethernet packet */

/* The MAC can support frame lengths up to 1536 bytes */

Expand Down Expand Up @@ -3551,8 +3551,8 @@ static int zynq_gmac_configure(struct zynq_gmac_s *priv)
* IRXER = 0 : Disable ignore IPG GXER
*/

regval = GMAC_NCFGR_FD | GMAC_NCFGR_GBE |
GMAC_NCFGR_CLK_DIV64 | GMAC_NCFGR_DBW_64;
regval = GMAC_NCFGR_FD | GMAC_NCFGR_GBE | GMAC_NCFGR_PEN |
GMAC_NCFGR_RFCS | GMAC_NCFGR_CLK_DIV64 | GMAC_NCFGR_DBW_64;

#ifdef CONFIG_NET_PROMISCUOUS
regval |= GMAC_NCFGR_CAF;
Expand All @@ -3568,6 +3568,14 @@ static int zynq_gmac_configure(struct zynq_gmac_s *priv)

regval = zynq_getreg(priv, ZYNQ_GMAC_DCFGR);

/* DMA receive buffer size in external AMBA (AHB/AXI) system memory */

regval &= ~GMAC_DCFGR_DRBS_MASK;

/* The value is defined in multiples of 64 bytes */

regval |= GMAC_DCFGR_DRBS(GMAC_RX_UNITSIZE / 64);

regval &= ~GMAC_DCFGR_ESPA;

#ifdef CDNS_TX_CSUM_OFFLOAD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,33 @@ CONFIG_IDLETHREAD_STACKSIZE=8192
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=9192
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDB_DNSCLIENT_ENTRIES=4
CONFIG_NETDB_DNSSERVER_NOADDR=y
CONFIG_NETINIT_DRIPADDR=0xc0a80002
CONFIG_NETINIT_IPADDR=0xc0a8000f
CONFIG_NETINIT_NOMAC=y
CONFIG_NETUTILS_CODECS=y
CONFIG_NETUTILS_IPERF=y
CONFIG_NET_BINDTODEVICE=y
CONFIG_NETUTILS_TELNETD=y
CONFIG_NETUTILS_TFTPC=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1500
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_NETLINK=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_LL_GUARDSIZE=32
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_RECV_BUFSIZE=32768
CONFIG_NET_SENDFILE=y
CONFIG_NET_SOLINGER=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPPROTO_OPTIONS=y
CONFIG_NET_TIMESTAMP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_DELAYED_ACK=y
CONFIG_NET_TCP_KEEPALIVE=y
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_UDP=y
CONFIG_NET_UDP_WRITE_BUFFERS=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
Expand Down Expand Up @@ -93,3 +108,4 @@ CONFIG_USERLED_LOWER=y
CONFIG_ZYNQ_ENET=y
CONFIG_ZYNQ_GMAC_NRXBUFFERS=256
CONFIG_ZYNQ_GMAC_NTXBUFFERS=256
CONFIG_ZYNQ_GMAC_PHYADDR=12
105 changes: 105 additions & 0 deletions boards/arm64/zynq-mpsoc/zcu111/configs/netnsh/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
CONFIG_ARCH="arm64"
CONFIG_ARCH_ARM64=y
CONFIG_ARCH_BOARD="zcu111"
CONFIG_ARCH_BOARD_ZCU111=y
CONFIG_ARCH_CHIP="zynq-mpsoc"
CONFIG_ARCH_CHIP_ZYNQ_MPSOC=y
CONFIG_ARCH_EARLY_PRINT=y
CONFIG_ARCH_INTERRUPTSTACK=4096
CONFIG_ARM64_DCACHE_DISABLE=y
CONFIG_ARM64_GIC_VERSION=2
CONFIG_ARM64_ICACHE_DISABLE=y
CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_LOOPSPERMSEC=116524
CONFIG_BUILTIN=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_IRQ=y
CONFIG_DEBUG_IRQ_INFO=y
CONFIG_DEBUG_SCHED=y
CONFIG_DEBUG_SCHED_ERROR=y
CONFIG_DEBUG_SCHED_INFO=y
CONFIG_DEBUG_SCHED_WARN=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=8192
CONFIG_ETC_ROMFS=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_LEDS=y
CONFIG_EXPERIMENTAL=y
CONFIG_FRAME_POINTER=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_IDLETHREAD_STACKSIZE=8192
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=9192
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDB_DNSCLIENT_ENTRIES=4
CONFIG_NETDB_DNSSERVER_NOADDR=y
CONFIG_NETINIT_DRIPADDR=0xc0a80002
CONFIG_NETINIT_IPADDR=0xc0a8000f
CONFIG_NETINIT_NOMAC=y
CONFIG_NETUTILS_CODECS=y
CONFIG_NETUTILS_IPERF=y
CONFIG_NETUTILS_TELNETD=y
CONFIG_NETUTILS_TFTPC=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1500
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_LL_GUARDSIZE=32
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_RECV_BUFSIZE=32768
CONFIG_NET_SENDFILE=y
CONFIG_NET_SOLINGER=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_DELAYED_ACK=y
CONFIG_NET_TCP_KEEPALIVE=y
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_UDP=y
CONFIG_NET_UDP_WRITE_BUFFERS=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_PTHREAD_STACK_MIN=8192
CONFIG_RAMLOG=y
CONFIG_RAM_SIZE=2145386496
CONFIG_RAM_START=0x00100000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_BACKTRACE=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKPRIORITY=192
CONFIG_SPINLOCK=y
CONFIG_STACK_COLORATION=y
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2022
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_SYSTEM=y
CONFIG_SYSTEM_TIME64=y
CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USEC_PER_TICK=1000
CONFIG_USERLED=y
CONFIG_USERLED_LOWER=y
CONFIG_ZYNQ_ENET=y
CONFIG_ZYNQ_GMAC_NRXBUFFERS=256
CONFIG_ZYNQ_GMAC_NTXBUFFERS=256
CONFIG_ZYNQ_GMAC_PHYADDR=12
4 changes: 4 additions & 0 deletions boards/arm64/zynq-mpsoc/zcu111/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ ifeq ($(CONFIG_USERLED),y)
CSRCS += zcu111_userleds.c
endif

ifeq ($(CONFIG_NET),y)
CSRCS += zcu111_ethernet.c
endif

ifeq ($(CONFIG_ETC_ROMFS),y)
RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS
endif
Expand Down