Introduction
The Multi-channel example illustrates the usage of multiple channels of CPDMA. The application creates two independent TX and RX channels each, one for L2 echo server and the second for TimeSync PTP stack.
This example illustrates the usage of multiple CPDMA channels to carry two types of traffic: echo test and PTP. The segregation of Ethernet packets into separate CPDMA channel is based on the priority field (PCP) of the 802.1Q VLAN tagged packets. PTP packets are expected to have a priority of 1, and echo test packets a priority of 0. The source generator for packets must send packets with 802.1Q VLAN tag enabled to the application.
802.1Q VLAN Tag Format
CPDMA Channels Control Flow
- Enet-lld utilizes hardware timestamping provided by CPTS(CPSW) and provides IOCTL commands for enabling Packet Timestamping functionality.
- The Multi-channel example illustrates using three such IOCTL Commands to exercise the CPTS IOCTLs from application(ENET_TIMESYNC_IOCTL_GET_CURRENT_TIMESTAMP, ENET_TIMESYNC_IOCTL_GET_ETH_RX_TIMESTAMP, ENET_TIMESYNC_IOCTL_GET_ETH_TX_TIMESTAMP). Appropriate apis are defined for calling these IOCTLs and enet-lld has implementation for the IOCTLs to execute the desired feature.
- This example also illustrates on registering for CPTS event notification by using IOCTL ref\ CPSW_CPTS_IOCTL_REGISTER_STACK .
- Moreover, the example also has a demo of 'PTP Ordinary Clock' using a combined Timesync PTP stack using P2P delay mechanism.
- Please refer Enet Time Synchronization for details on all other IOCTLs supported by ENET-LLD for Timesync.
On AM263X, we can do ethernet based communication using CPSW HW mechanism
- CPSW is a standard ethernet switch + port HW
- It uses ethernet driver underneath with LwIP TCP/IP networking stack
Configuration Parameters
- Opening TX 0 and TX 1 channels using EnetAppUtils_openTxCh () API by passing channel number as a parameter to this API.
- Opening RX channels 0 and 1 using EnetAppUtils_openRxCh () API by passing channel number as a parameter to this API.
- Separate RX task and RX packet callback needs to be implemented for each channel creation. Existing flows for channels can be referred to.
- Set the vlanLType1 field of macport stats in EnetApp_setPortTsEventPrms () API to 0x8100, to make CPTS aware of VLAN tagging enabled for packets.
- CPDMA supports upto 8 TX/RX channels. By default, applications has only 3 TX/RX channels and this can be changed by modifying the macros ENET_CFG_CPDMA_CPSW_MAX_TX_CH/ENET_CFG_CPDMA_CPSW_MAX_RX_CH in enet_cfg.h file.
Configuring the Packeth tool to send vlan tagged packets
In packETH tool, select the 802.1q field to configure vlan parameters(priority).
Packeth tool configuration for 802.1q vlan tag
Application Functionality
Application Functionality
Packeth tool is configured with the 802.1Q (PCP) field set to either 0 or 1 to send either L2 packets or PTP packets. CPSW peripheral maps the value of the PCP field to appropriate DMA channel queue for the receiving packets.
Application Flow
Application Flow
The Multi-channel app on starting its main task initializes the Enet driver, memory and queues. Followed by this, the app opens the CPSW peripheral and creates two pairs of TX and RX channels:
- L2 echo server
- PTP Timestamping
Each RX channel will have a separate OS task to process each traffic type separately. Additionally, the test enables timestamping of PTP packets. The Multi-channel App continues to run until user decides to terminate the app by pressing ‘x’ from the App menu.
Channel Overriding
To override the channel mapping, we can use ALE classifier along with CPDMA_CONTROL.
- The example shows the usage of ALE classifier where we create a classifier based on Ethertype and route the matched traffic to the corresponding RX channel.
- CPDMA provides channel override feature using the thost_ch_override bit in CPDMA_CONTROL register.
- When set, the RX channel is overridden with the ALE classification match value. This value is what we set in the ALE Classifier as threadId.
- We need to set the default channel when we are overriding, this will handle the unclassified traffic and is passed as a parameter to EnetApp_setCpswAleClassifier() API. The application sets RX channel 0 to be the default channel for handling unclassified traffic.
- We need to set the enChOverrideFlag Flag in the application if we want to use the channel overriding feature. This is done in EnetApp_open() API.
Supported Combinations
| Parameter | Value |
| CPU + OS | r5fss0-0_freertos r5fss0-1_freertos |
| Toolchain | ti-arm-clang |
| Boards | am263x-cc |
| Example folder | source/networking/enet/core/examples/enet_layer2_multi_channel/V1 |
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)
HW Setup
- Note
- Make sure you have setup the EVM with cable connections as shown here, EVM Setup. In addition do below steps.
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 with Multicast addresses (01:80:C2:00:00:0E) PTP frames (Ethertype 0x88F7U) from Colasoft Pkt Builder or packETH tool and capture the packets in Wireshark. Packets must be sent with 802.1Q VLAN tag enabled to the application.
- By selecting 't' option from the menu we can toggle the timestamp printing on the Terminal.
Sample output for Multi-Channel example
==========================
L2 Multi-channel Test
==========================
Init all peripheral clocks
----------------------------------------------
Create RX tasks
----------------------------------------------
cpsw-3g: Create RX task
Open all peripherals
----------------------------------------------
cpsw-3g: Open enet
Init all configs
----------------------------------------------
cpsw-3g: init config
Link Status Changed. PHY: 0x0, state: up
Open MAC port 1
EnetPhy_bindDriver:1873
PHY 0 is alive
PHY 3 is alive
Attach core id 0 on all peripherals
----------------------------------------------
cpsw-3g: Attach core
cpsw-3g: Open DMA
initQs() freePktInfoQ initialized with 16 pkts
initQs() freePktInfoQ initialized with 16 pkts
cpsw-3g: Waiting for link up...
Cpsw_handleLinkUp:1653
MAC Port 1: link up
cpsw-3g: Port 1 link is up
cpsw-3g: MAC port addr: f4:84:4c:fc:34:fe
TimeSync PTP enabled
Enet Multi-channel Menu:
'c' - GetCurrentTime
't' - Toggle Printing timestamps
's' - Print statistics
'r' - Reset statistics
'm' - Show allocated MAC addresses
'p' - Enable Policer for rate limiting
'x' - Stop the test
t
Enable Timestamp Printing
TX Timestamp: 12042935861
TX Timestamp: 12252934996
TX Timestamp: 12462935116
TX Timestamp: 20672934936
TX Timestamp: 20882934951
TX Timestamp: 21092935541
See Also
Ethernet And Networking |
Ethernet TSN CPSW gPTP Bridge Example | Ethernet TSN CPSW gPTP TimeReceiver (gPTP Slave) Example | Ethernet TSN CPSW gPTP TimeTransmitter (gPTP Master) Example | Ethernet TSN and gPTP Stack - API and Integration Guide