AM261x MCU+ SDK: Enet CPSW Loopback Example

| AM261x MCU+ SDK 26.00.00 |

Enet CPSW Loopback Example

# Introduction

This example exercises the MAC loopback and PHY loopback functionality of the hardware. The CPSW hardware is opened with default initialization parameters and either the MAC loopback or PHY loopback is enabled based on the user input.

On AM261X, we can do ethernet based communication using CPSW as HW mechanism

- CPSW is a standard ethernet switch + port HW
- It uses ethernet driver underneath with LwIP TCP/IP networking stack

The examples do the following:

- A Tx channel and an 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 5000 packets. After reaching the count of 5000, the application closes the Tx channel, Rx flow, 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 at any time.

# Supported Combinations

Parameter | Value
--- | ---
CPU + OS | r5fss0-0_freertos
Toolchain | ti-arm-clang
Boards | am261x-lp, am261x-som
Example folder | source/networking/enet/core/examples/enet_loopback/enet_cpsw_loopback

For support on am261x-lp please refer Ethernet Add-on Boards

# Packet pool configuration

To change packet pool configuration from syscfg, please refer to Ethernet Packet Pool Allocation Guidelines

# Steps to Run the Example

## Build the example

- When using CCS projects to build, import the CCS project for the required combination and build it using the CCS project menu (see Using SDK with CCS Projects).
- When using makefiles to build, note the required combination and build using make command (see Using SDK with Makefiles)

## Sample output for MAC Loopback

=============================
Enet Loopback: Iteration 1
=============================
CPSW_3G Test
Open MAC port 1
Setting in NO-PHY mode for MAC port 1
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
=============================
Enet Loopback: Iteration 2
=============================
CPSW_3G Test
EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:0 From 4 To 1
Open MAC port 1
Setting in NO-PHY mode for MAC port 1
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
=============================
Enet Loopback: Iteration 3
=============================
CPSW_3G Test
EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:0 From 4 To 1
Open MAC port 1
Setting in NO-PHY mode for MAC port 1
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
=============================
Enet Loopback: Iteration 4
=============================
CPSW_3G Test
EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:0 From 4 To 1
Open MAC port 1
Setting in NO-PHY mode for MAC port 1
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
=============================
Enet Loopback: Iteration 5
=============================
CPSW_3G Test
EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:0 From 4 To 1
Open MAC port 1
Setting in NO-PHY mode for MAC port 1
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
Loopback application completed
All tests have passed!!

## Sample output for PHY Loopback

=============================
Enet Loopback: Iteration 1
=============================
CPSW_3G Test
Open MAC port 1
EnetPhy_bindDriver:1873
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Cpsw_handleLinkUp:1653
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
=============================
Enet Loopback: Iteration 2
=============================
CPSW_3G Test
EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:0 From 4 To 1
Open MAC port 1
EnetPhy_bindDriver:1873
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Cpsw_handleLinkUp:1653
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
=============================
Enet Loopback: Iteration 3
=============================
CPSW_3G Test
EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:0 From 4 To 1
Open MAC port 1
EnetPhy_bindDriver:1873
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Cpsw_handleLinkUp:1653
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
=============================
Enet Loopback: Iteration 4
=============================
CPSW_3G Test
EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:0 From 4 To 1
Open MAC port 1
EnetPhy_bindDriver:1873
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Cpsw_handleLinkUp:1653
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
=============================
Enet Loopback: Iteration 5
=============================
CPSW_3G Test
EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:0 From 4 To 1
Open MAC port 1
EnetPhy_bindDriver:1873
PHY 0 is alive
PHY 3 is alive
initQs() txFreePktInfoQ initialized with 16 pkts
Cpsw_handleLinkUp:1653
Received 5000 packets
Delete EnetApp_rxTask() and exit..
Transmitted 5000 packets
Delete EnetApp_txTask() and exit..
Port 0 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Port 1 Statistics
-----------------------------------------
rxGoodFrames = 5000
rxBcastFrames = 5000
rxOctets = 2590000
txGoodFrames = 5000
txBcastFrames = 5000
txOctets = 2590000
octetsFrames512to1023 = 10000
netOctets = 5180000
txPri[0] = 5000
txPriBcnt[0] = 2590000
Cpsw_handleLinkDown:1679
Test complete: PASS
Loopback application completed
All tests have passed!!

## Troubleshooting issues

- For am261x-lp, software configures MDIO based on the Board version(E1/E2) which is read from EEPROM. It expects on-board EEPROM to be pre-programmed for E2 EVMs. If EEPROM(0x51) is not programmed, the software considers EVM as "E1" version.

# See Also

Ethernet And Networking