AM64x MCU+ SDK  08.02.00
Enet Layer 2 CPSW SWITCH Example

Introduction

The layer 2 cpsw switch example is dedicated to demonstrate usage of Enet CPSW3G peripheral operation as a basic switch.

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

  • This is a standard ethernet switch + port HW

This example do below:

  • Target-side application running on a Cortex R5F core.
    • Target-side application running on a Cortex R5F core.
    • Application receives the broadcast packet for switch operation, copies the payload into a new packet which is then sent back out to the source port as well as to all the other ports on the device.
    • The application has a menu to enable/disable features, such as getting mac address and stats. This menu along with application logs are implemented via UART.
  • Host-side functionality
    • Software applications like Colasoft Pkt Builder or packETH tool could be used to generate and send packets, Wireshark can be used to receive and verify packet contents
  • The data path enabled in this example is as follows:
    • Host side (PC) application sends a broadcast packet to MAC port.
    • Target side application receives the broadcast packet, updates the MAC addresses in the Layer-2 header and sends the packet out back out to the source port as well as to all the other ports on the device.
    • Application like Wireshark (PC) receives the packet and can be seen in the capture window.

Supported Combinations

Parameter Value
CPU + OS r5fss0-0_freertos
Toolchain ti-arm-clang
Board am64x-evm
Example folder examples/networking/enet_layer2_cpsw_switch/V0

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)

HW Setup

Note
Make sure you have setup the EVM with cable connections as shown here, EVM Setup. In addition do below steps.

AM64X-EVM

For CPSW based example

  • Connect a ethernet cable to the EVM from host PC as shown below

Ethernet cable for CPSW based ethernet

Run the example

Attention
If you need to reload and run again, a CPU power-cycle is MUST
  • Launch a CCS debug session and run the example executable, see CCS Launch, Load and Run
  • You will see logs in the UART terminal as shown in the next section.
  • We can start sending packets from Colasoft Pkt Builder or packETH tool and capture the packets in Wireshark.

Sample output for Multiport example

==========================
Layer 2 CPSW SWITCH Test
==========================
Init Enet's OSAL and utils to use defaults
Init memory utils
Create clock and task for periodic tick
Create periodic tick task
Create periodic tick clock
Init all peripheral clocks
----------------------------------------------
Init all configs
----------------------------------------------
cpsw-3g: init config
Create RX tasks
----------------------------------------------
cpsw-3g: Create RX task
Open all peripherals
----------------------------------------------
cpsw-3g: Open enet
cpsw-3g: Open port 1
cpsw-3g: Open port 1 link
EnetPhy_bindDriver: PHY 0: OUI:080028 Model:0f Ver:01 <-> 'dp83869' : OK
cpsw-3g: Open port 2
cpsw-3g: Open port 2 link
EnetPhy_bindDriver: PHY 3: OUI:080028 Model:0f Ver:01 <-> 'dp83869' : OK
cpsw-3g: Open DMA
initQs() txFreePktInfoQ initialized with 16 pkts
Host MAC address: 70:ff:76:1d:ec:f2
cpsw-3g: Waiting for link up...
Cpsw_handleLinkUp: Port 1: Link up: 1-Gbps Full-Duplex
MAC Port 1: link up
Cpsw_handleLinkUp: Port 2: Link up: 1-Gbps Full-Duplex
MAC Port 2: link up
cpsw-3g: Port 1 link is up
cpsw-3g: Port 2 link is up
cpsw-3g: MAC port addr: 70:ff:76:1d:ec:f2
Enet L2 cpsw Menu:
's' - Print statistics
'r' - Reset statistics
'm' - Show allocated MAC addresses
'x' - Stop the test
s
Print statistics
----------------------------------------------
rxGoodFrames = 361
rxOctets = 39134
txGoodFrames = 361
txBcastFrames = 9
txMcastFrames = 352
txOctets = 39134
octetsFrames64 = 52
octetsFrames65to127 = 568
octetsFrames128to255 = 96
octetsFrames256to511 = 6
netOctets = 78268
aleUnknownUcast = 1
aleUnknownUcastBcnt = 110
txPri[0] = 361
txPriBcnt[0] = 39134
cpsw-3g - Port 1 statistics
--------------------------------
rxGoodFrames = 188
rxBcastFrames = 7
rxMcastFrames = 176
aleDrop = 6
rxOctets = 20760
txGoodFrames = 373
txBcastFrames = 6
txMcastFrames = 193
txOctets = 40687
octetsFrames64 = 45
octetsFrames65to127 = 427
octetsFrames128to255 = 84
octetsFrames256to511 = 5
netOctets = 61447
portMaskDrop = 6
aleUnknownMcast = 1
aleUnknownMcastBcnt = 64
txPri[0] = 373
txPriBcnt[0] = 40687
rxGoodFrames = 363
rxOctets = 39572
txGoodFrames = 363
txBcastFrames = 9
txMcastFrames = 354
txOctets = 39572
octetsFrames64 = 52
octetsFrames65to127 = 568
octetsFrames128to255 = 100
octetsFrames256to511 = 6
netOctets = 79144
aleUnknownUcast = 1
aleUnknownUcastBcnt = 110
txPri[0] = 363
txPriBcnt[0] = 39572
cpsw-3g - Port 2 statistics
--------------------------------
rxGoodFrames = 206
rxBcastFrames = 6
rxMcastFrames = 197
rxOctets = 22381
txGoodFrames = 382
txBcastFrames = 5
txMcastFrames = 176
txOctets = 41614
octetsFrames64 = 47
octetsFrames65to127 = 453
octetsFrames128to255 = 83
octetsFrames256to511 = 5
netOctets = 63995
aleUnknownMcast = 1
aleUnknownMcastBcnt = 64
txPri[0] = 382
txPriBcnt[0] = 41614
  • On Wireshark we can see the packets received:

Wireshark log for Layer 2 CPSW Example

See Also

Networking