Enet LLD is an unified Ethernet driver that support Ethernet peripherals found in TI SoCs, such as CPSW and ICSSG. Enet LLD supports CPSW_2G and CPSW_9G in J721E devices.
The diagram below shows the overall software architecture of the Enet low-level driver. A top-level driver layer provides the interface that the applications can use to configure the switch and to send/receive Ethernet frames.
For instance, the CPSW support in the Enet driver consists of several software submodules that mirror those of the CPSW hardware, like DMA, ALE, MAC port, host port, MDIO, etc. Additionally, the Enet driver also includes PHY driver support as well as a resource manager to administrate the CPSW resources.
Enet LLD relies on other PDK drivers like UDMA for data transfer to/from the Ethernet peripheral’s host port to the other processing cores inside the TI SoC devices. For the lower level access to the hardware registers, Enet LLD relies on the Chip Support Library (CSL).
4.5.2. User Interface¶
For details about individual fields of this library structure, see the PDK doxygen documentation
The Enet LLD APIs can be broadly divided into two categories: control and data path. The control APIs can be used to configure all Ethernet hardware submodules like FDB, MAC port, host port, MDIO, statistics, as well as PHY drivers and resource management. The data path APIs are exclusive for the DMA-based data transfers between the TI SoC processing cores and the Ethernet peripheral.
API reference for application:
The main APIs of the Enet LLD are the following:
184.108.40.206.1. Data Path APIs¶
The main Enet LLD functions used to send and receive packets are:
It’s worth noting that the control path APIs are mainly IOCTL-based, and the data path APIs are direct functions in order to avoid any additional overhead associated with IOCTL calls as DMA data operations occur highly frequently.
220.127.116.11.2. IOCTL Interface¶
IOCTLs are system calls that take an argument specifying the command code and
can take none or additional parameters via
IOCTL are used by all Enet submodules except for DMA.
Enet_IoctlPrms parameter structure consists of input and output
argument pointers and their corresponding size. The following helper macros are
provided to help construct the IOCTL params:
ENET_IOCTL_SET_NO_ARGS(prms). Used for IOCTL commands that take no parameters.
ENET_IOCTL_SET_IN_ARGS(prms, in). Used for IOCTL commands that take input parameters but don’t output any parameter.
ENET_IOCTL_SET_OUT_ARGS(prms, out). Used for IOCTL commands that don’t take input parameters but return output parameters.
ENET_IOCTL_SET_INOUT_ARGS(prms, in, out). Used for IOCTL commands that take input parameters and also return output parameters.
prms in a pointer to
in is the pointer
to IOCTL input argument and
out is the pointer to IOCTL output argument.
It’s recommended that the application doesn’t set the
members individually, but only through the helper macros listed above.
Please refer to the individual IOCTL command to find out if it requires input and/or output parameters.
4.5.3. lwIP Integration¶
See lwIP User’s Guide for further information about lwIP integration into PDK using Enet LLD, and NDK-to-lwIP migration guide.
Enet LLD comes with a set of examples demonstrating the usage of driver APIs. The examples are:
- enet_loopback: Internal (MAC port) or external loopback test.
- enet_lwip_example: TCP/IP stack integration using lwIP.
|Name||Description||Expected Results||Cores Supported||Peripherals|
|Loopback||Enet Loopback example demonstrates basic packet send and receive on an Ethernet peripheral configured in MAC loopback or PHY loopback.||All packets sent from the example application shall be received back after being looped in MAC or PHY.||mcu1_0||CPSW_2G|
|lwIP||Enet lwIP example demonstrates Enet driver integration with open source lwIP TCP/IP stack. The example enables DHCP client, it can get an IP address when connected to a network.||lwIP example application shall be able to get an IP address when connected to a network. User can test ‘ping’, ‘echo’ and ‘iperf’.||mcu1_0||CPSW_2G|
18.104.22.168.1. Enet loopback¶
This example exercises the MAC loopback functionality of the hardware. The example is developed and tested on both bare metal and TI RTOS code base. The Ethernet peripheral is opened with default initialization parameters and the MAC loopback is enabled.
A Tx channel and a Rx flow are opened to enable data transfers. Packets are transmitted from the Switch R5F (Main R5F0_0) to the host port using the Tx channel. These packets are routed back to the host port by the switch hardware as the internal loopback feature is enabled. These packets are then transmitted to the Switch R5F by the Rx flow and the application is notified.
The Tx and Rx functions in the example are set to transmit and receive 10000 packets. After reaching the count of 10000, the application closes the Tx channel, Rx flow, peripheral (i.e. CPSW) and restarts the application for a configurable number of times. Restarting the loopback test application ensures that there aren’t any memory leaks, and the hardware is closed properly and can be reopened any time.
22.214.171.124.2. Enet LWIP¶
Building LWIP example
Enabling specific features in the test
To configure what gets built in the example, navigate to the example directory
pdk/packages/ti/drv/enet/examples/enet_lwip_exampleand find the
lwipcfg.hfile. Inside, change the macros corresponding to the program that you wish to build to 1.
For example, if udpecho is required, set:
#define LWIP_UDPECHO_APP 1
The heap memory may need to be increased in the
FreeRTOSConfig.hfile to accomodate multiple apps.
To build the lwip example, issue the following command:
make -s enet_lwip_example_freertos
Running LWIP example
Load and run the enet_lwip_example image from the corresponding binaries folder.
The setup requires a LAN cable to be connected between the device and a multiport-router for the link status to be UP and aquire an IP address.
Connect the LAN cable between the same router and Laptop/PC from where the ping/echo tests are run.
Wait until the local interface IP is assigned and printed on the console like below.
Starting lwIP, local interface IP is dhcp-enabled CPSW_2G Test on MCU NAVSS EnetPhy_bindDriver: PHY 0: OUI:080028 Model:23 Ver:01 <-> 'dp83867' : OK PHY 0 is alive Host MAC address: 70:ff:76:01:02:03 [LWIPIF_LWIP] CPSW has been started successfully [LWIPIF_LWIP] NETIF INIT SUCCESS status_callback==UP, local interface IP is 0.0.0.0 Cpsw_handleLinkUp: Port 1: Link up: 100-Mbps Full-Duplex MAC Port 1: link up link_callback==UP status_callback==UP, local interface IP is 192.168.0.9 Initializing apps UDP server listening on port 5001
Testing LWIP example
Prerequisites: LAN cable setup and device link is UP and Local interface IP is successfully aquired.
ping -t <ip_addr> ping -t 192.168.0.9
UDP/ TCP echo test
Download echotool from this website and execute the commands to see the response.
UDP echo command:
echotool.exe <ip_addr> /p udp /r 7 /n 0 echotool.exe 192.168.0.9 /p udp /r 7 /n 0
TCP echo command:
echotool.exe <ip_addr> /p tcp /r 7 /n 0 echotool.exe 192.168.0.9 /p tcp /r 7 /n 0
Download iperf2 from iperf website and execute the commands to see the response.
iperf TCP test command:
iperf.exe -c <ip_addr> -r iperf.exe -c 192.168.0.9 -r
iperf UDP test command:
iperf.exe -c <ip_addr> -r -u iperf.exe -c 192.168.0.9 -r -u
The Enet lwIP example uses DHCP by default. If static IP needs to be tested, the following
two config options need to be disabled in
#define USE_DHCP 0 #define USE_AUTOIP 0
The IP address, gateway and netmask can be set in the same lwipcfg.h file.
#define LWIP_PORT_INIT_IPADDR(addr) IP4_ADDR((addr), 192,168,1,200) #define LWIP_PORT_INIT_GW(addr) IP4_ADDR((addr), 192,168,1,1) #define LWIP_PORT_INIT_NETMASK(addr) IP4_ADDR((addr), 255,255,255,0)
126.96.36.199.3. Enet Multiport¶
Not supported for this SoC.
188.8.131.52.4. Enet TAS¶
Not supported for this SoC.