MCUSW
Eth & EthTrcv User Guide

Introduction

This document details AUTOSAR BSW ETH & ETHTRCV module implementations

  • Supported AUTOSAR Release : 4.3.1
  • Supported Configuration Variants : Pre-Compile/LinkTime/PostBuild for Eth and Pre-Compile for EthTrcv
  • Vendor ID : ETH_VENDOR_ID (44), ETHTRCV_VENDOR_ID (44)
  • Module ID : ETH_MODULE_ID (88), ETHTRCV_VENDOR_ID (73)

The ETH module initializes, configures and controls the Gigabit Ethernet Switch (CPSW) in the J7xx device families as well as SITARA AM6xx device families as detailed in the AUTOSAR BSW ETH Driver Specification.

The ETHTRCV module initializes and configures the Ethernet transceiver (PHY) as detailed in the AUTOSAR BSW ETHTRCV Driver Specification.

Following section highlights key aspects of this implementation, which would be of interest to an integrator.


SDK/PDK dependency

Currently, the MCAL Ethernet driver only depends on SciClient module in SDK


Eth Driver Architecture/Design

Please refer the ETH design page, which is included as part of release [3].


Functional Description

This ETH driver implementation supports the Gigabit Ethernet Switch (CPSW) peripheral present in the J7xx and AM6xx devices.
The CPSW peripheral in J7xx devices has an Ethernet port (port 1) which supports RGMII and RMII interfaces, and a host port (port 0) which supports the internal Communications Port Programming Interface (CPPI). The ETH driver uses UDMA to setup data transfers to/from the CPPI port.

In CPSW peripheral in AM6xx devices has 2 Ethernet ports (port 1 and port 2) which support RGMII and RMII interfaces, and a host port (port 0). However, the driver supports only one port. The port selection can be done via configurator.
The ETH driver uses DMSS to setup data transfers to/from the CPPI port.

The ETH driver implements single UDMA channel for data transmission and single channel (flow) for data reception. Only the CPSW default thread ID is enabled and configured according to the DMA receive channel's default flow. Interrupts can be enabled for DMA transmit and receive completion events.

The DMA transfers are based on descriptors called Host Mode Packet Descriptors (HMPD). The descriptors are given to and retrieved from the UDMA via Ring Accelerators. There are three rings used per data direction in this implementation:

  • Transmit
    • Free Queue Ring - Descriptors with the address and length of the buffers to be transmitted are queued into this ring. In normal conditions, only CPSW will dequeue descriptors from this queue.
    • Completion Queue Ring - Descriptors that correspond to Ethernet frames which have already been consumed by the CPSW are placed in this queue. CPSW is the producer and host is the consumer of this ring.
    • Tear-down Completion Queue Ring - This ring is used only when the UDMA channel is torn down.
  • Receive
    • Free Queue Ring - Descriptors with the address and length of free buffers to be filled with incoming Ethernet frames are queued into this ring. In normal conditions, only the CPSW will dequeue descriptors from this queue.
    • Completion Queue Ring - Descriptors that correspond to buffers filled with new data from incoming Ethernet frames are placed in this queue. CPSW is the producer and host is the consumer of this ring.
    • Tear-down Completion Queue Ring - This ring is used only when the UDMA channel is torn down.

The depth of each ring as well as its associated memory is configurable. The ring memories can be any memory in the system, but it's recommended that they are placed in a fast memory (i.e. OCMRAM or MSMC3). The depth of these rings is determined by the number of TX and RX buffers set in the driver configuration (EthTxBufTotal and EthRxBufTotal).

Similarly, the HMPDs can be placed in any memory of the system, but it's recommended that they are placed in OCMRAM or MSMC3 as well.

The Management Data I/O interface (MDIO) of the CPSW peripheral is used by the ETH driver to implement the MII register read and write APIs which are ultimately used by the ETHTRCV driver to configure the Ethernet transceiver (PHY). The ETH driver handles the MDIO interrupt which indicates the completion event of the Ethernet transceiver register accesses.

The Address Lookup Engine (ALE) of the CPSW peripheral is used by the ETH driver to implement the receive filter API. The ALE provides 64 entries that can be used to set filter rules.

The Statistics submodule of the CPSW peripheral is used by the ETH driver to implement the statistics and drop count APIs.

Back To Top


Ethernet interrupt to ISR mapping

The following table lists the mapping between Ethernet interrupts and the corresponding interrupt service routines.

Interrupt Number Description Associated ISR
Configurable DMA RX Completion Eth_RxIrqHdlr_0
Configurable DMA TX Completion Eth_TxIrqHdlr_0
135 MDIO Access Completion Eth_MdioIrqHdlr_0

The DMA interrupt numbers can be set via the Ethernet driver configuration parameters EthDmaTxChIntrNum and EthDmaRxChIntrNum.

The table below summarizes the interrupt ranges allocated by default in TI SDK for the SoCs and the processing cores where the MCAL ETH driver is supported.

SOC Starting Resource (Value) Range -----—
J7xx Devices MCU0_INTR_NAVSS0_R5_0_PEND_0 (74) 9
AM62x DMASS0_INTAGGR_0_INTAGGR_VINTR_PEND_44 (66) 36
AM62Ax DMASS0_INTAGGR_0_INTAGGR_VINTR_PEND_168 (64) 16

The interrupt numbers passed to the Ethernet driver configuration must be within the range stated above for each device, otherwise the interrupt allocation will fail while enabling the Ethernet controller.

Please refer to the UDMA Driver Resource Manager allocation for further details.

There are no interrupts in the ETHTRCV module.

Back To Top


Configuration

Configuration files struture

The Eth Driver implementation in this release supports the Pre-Compile/LinkTime/ PostBuild configuration variant.
The driver expects generated: Eth_Cfg.h, Eth_Cfg.c, Eth_Lcfg.c and Eth_PBcfg.c to be present at the locations specified in the Eth File Structure section.

The EthTrcv Driver implementation only supports the Pre-Compile variant.
The driver expects generated EthTrcv_Cfg.h and EthTrcv_Cfg.c to be present at the locations specified in the EthTrcv File Structure section.

DMA configuration guideline

Use sysconfig tools to open am62a-evm.syscfg sysconfig file to get all DMA information
Please enable Resource Allocation Markdown.

eth_ug_dma_resource_allocation_markdown.png
Ethernet DMA resource allocation detail


Native Eth Driver

In the Resource Sharing tab in sysconfig, you can see that MCU_0_R5_0 is sharing the following resource with A53_2 core.

  • DMASS Packet DMA CPSW Tx channel
  • DMASS Packet DMA CPSW Rx channel
  • DMASS Packet DMA Rings for CPSW Rx channel
  • DMASS Packet DMA Free flows for Rx channel
    eth_ug_dma_resource_sharing.png
    Ethernet DMA resouce sharing

For these resources, use the A53_2 column, instead of MCU_0_R5_0 column, to get DMA information.

eth_ug_dma_resource_sharing_a53_2.png
Ethernet DMA resouce sharing detail


  • EthDmaTxChStartNum - equal DMASS Packet DMA CPSW Tx channel of A52_2
  • EthDmaRxChStartNum - equal DMASS Packet DMA CPSW Rx channel of A52_2
  • EthDmaRingStartNum - equal DMASS Packet DMA Rings for CPSW Rx channel of A52_2
  • EthDmaFlowStartNum - equal DMASS Packet DMA Free flows for Rx channel of A52_2

For the Global Event Resource, since MCU_0_R5_0 don't share this with any other cores, use the MCU_0_R5_0 column to get the DMA information
Look at the column MCU_0_R5_0 to get DMA information for Global Event

eth_ug_dma_resource_mcu_1_0.png
Ethernet DMA resouce MCU_0_R5_0 detail


  • EthDmaGlobalStartNum - equal to DMASS Interrupt aggregator Global events of MCU_0_R5_0

Back To Top


Variance / Deviation from the specification

QoS feature of Transmit/Receive APIs

The current implementation doesn't support QoS feature in transmission and reception:

  • Transmit frame priority is not supported in this release. The Priority pamareter should be set to 0 when requesting a buffer via Eth_ProvideTxBuffer().
  • Receive FIFO is not supported in this release. The FifoIdx parameter should be set to 0 when receiving a buffer via Eth_Receive().

Ethernet Switch Interface

The driver doesn't call Ethernet Switch Interface APIs.

Back To Top


Ethernet Transceiver Wake-Up

The wake-up related APIs are not implemented in this release:

  • EthTrcv_SetTransceiverWakeupMode()
  • EthTrcv_GetTransceiverWakeupMode()
  • EthTrcv_CheckWakeup()

The wake-up related functionality of other non wake-up specific APIs (i.e. EthTrcv_TransceiverInit(), EthTrcv_SetTransceiverMode(), etc) are not implemented in this release either.

Back To Top


Ethernet Transceiver Manual/Auto-Negotiation Mode

The current EthTrcv driver implementation only supports auto-negotiation mode. The following APIs are impacted and partial functionality of the API is implemented:

  • EthTrcv_TransceiverInit()
  • EthTrcv_SetTransceiverMode()

Back To Top


Ethernet Transceiver ECUC

The following EthTrcv ECUC APIs are not implemented in this release:

  • EthTrcvPhysLayerType
  • EthTrcvConnNeg
  • EthTrcvMainFunctionPeriod

Back To Top


Non Standard Service APIs

None.

Back To Top


Interrupt Configuration

The Ethernet driver doesn't register any interrupt handlers (ISR), it is expected that consumer of this driver registers the required interrupt handler.

The Ethernet interrupts are:

  • TX DMA Completion - Asserted when a packet has been consumed by CPSW for transmission. The interrupt number is configurable and is passed via Ethernet configuration parameters. Please refer to the resource partitioning information for further details about what interrupt numbers are allocated for the MCU
  • RX DMA Completion - Asserted when a packet has been received. The interrupt number is configurable and is passed via Ethernet configuration parameters. Please refer to the resource partitioning information for further details about what interrupt numbers are allocated for the MCU
  • MDIO Access Completion - Asserted when an Ethernet transceiver (PHY) register read or write operation is complete. The interrupt number is 135

Other CPSW interrupts (like the Statistics Pending interrupt) are not handled by the driver.

Please refer to the EthApp_InterruptConfig() function in Eth demo application for the implementation details of the interrupt registration.

Back To Top


Power-up

The driver doesn't configure the functional clock and power for the Ethernet module. It is expected that a Secondary Bootloader (SBL) or a Secondary Program loadeder (SPL) powers up and initialized the required modules.
When running the Ethernet driver MCAL example test application in AM62x, it is recommened to use the SBL for SOC Initialization instead of SPL, since running the linux and side loading the Eth MCAL may have some conflict in resource usage.

Back To Top


Build and Running the Application

Please follow steps detailed in section (Build) to build library or example.

Building the host-side example application

The GCC compiler is required to build the host-side application.

The steps to build the host-side application in Linux are listed below:

$ cd mcal_drv/mcal/examples/Eth/eth_app/host/
$ make

Building the target-side MCAL example application

The Eth example application follows the same makefile base build system mentioned in the general mcal build user guide.

e.g.

$ cd build
$ make -s eth_app BOARD=am62x_evm SOC=am62x CORE=mcu0_0 BUILD_PROFILE=debug BUILD_OS_TYPE=baremetal

Building the target-side example application in loopback mode

The Eth example application can run an internal loopback test when configured accordingly in the driver's configuration parameters.

The example application per se doesn't need any change for loopback, but the loopback parameter must be set to TRUE as shown below. The example application can then be rebuilt following the regular steps listed in Build.

diff --git a/mcal_drv/mcal/examples_config/Eth_Demo_Cfg/output/generated/src/Eth_Cfg.c b/mcal_drv/mcal/examples_config/Eth_Demo_Cfg/output/generated/src/Eth_Cfg.c
index 24c046a..21cf137 100755
--- a/mcal_drv/mcal/examples_config/Eth_Demo_Cfg/output/generated/src/Eth_Cfg.c
+++ b/mcal_drv/mcal/examples_config/Eth_Demo_Cfg/output/generated/src/Eth_Cfg.c
@@ -75,7 +75,7 @@ ETH_CONFIG_DATA_SECTION CONST(Eth_ConfigType, ETH_CONFIG_SECTION)
     /**< MDIO bus clock (MDCLK) frequency (in Hz) */
     .connType           =    ETH_MAC_CONN_TYPE_RGMII_FORCE_1000_FULL,
     /**< MII connection type */
-    .loopback           =    FALSE,
+    .loopback           =    TRUE,
     /**< Loopback enable */
     .enableCacheOps     =     (uint32)TRUE,
     /**< Packet memory is cacheable */

Back To Top


Steps to run example application

Running the loopback test

In order to run the loopback test, it's required to set the Ethernet driver's 'loopback' configuration parameter to TRUE as described in Building the target-side example application in loopback mode. In loopback mode, CPSW is configured with ALE in bypass mode and loopback is enabled in the MAC port (port 1).

This test doesn't require any additional external setup and the example can run standalone on the device. The example application will transmit and receive 1000 frames, and will verify the frame content.

Running the default (non-loopback) test

This test consists of two applications: host-side application that runs on a Linux machine, and a target-side application that is loaded to the device (DUT).

Please refer to the Building the host-side example application section for instructions to build the host-side application.

  1. Connect a CAT5e/CAT6 Ethernet cable to the MCU ETHERNET connector of the DUT and to the PC's Ethernet port
  2. Don't setup the Network Connection in Linux, disable automatic connection if needed. The intention is to avoid any frames going to the DUT, other than those sent by the test application
  3. Find the interface name on the host PC side by running the following command:
$ ifconfig -s
  1. Run the host-side application with root privileges (needed for raw sockets) and specify the interface name to be used, for instance:
    $ cd mcal_drv/mcal/examples/Eth/eth_app/host/
    $ sudo ./EthHostApp -i eth2
    
  2. At this point, the host-side application will be waiting for the DUT
  3. Load the target-side application to the device and run it. The host-side application should detect that the device is now ready and all tests will be run (including frame transmission with and without confirmation, frame reception, filtering MAC addresses, transmission and reception of VLAN tagged packets, transmit throughput, etc)
  4. Check the logs printed in the Linux terminal and verify that the host-side application didn't report any errors
  5. Check the logs printed in the serial console (or CCS console if UART is not enabled) and verify that the target-side application didn't report any errors

The example applications on either side (host or target) will report a fail status if any test Ethernet frames is lost. So even frames which are lost due to physical link will cause the example application to report as a failure.

Note: The test steps listed above have been tested in Ubuntu 16.04. Test errors have been found when running the test in Ubuntu 18.04.

Back To Top


Memory Mapping

Various objects of this implementation (e.g. variables, functions, constants) are defined under different sections. The linker command file at (Examples Linker File (Select memory location to hold example binary)) defines separate section for these objects. When the driver is integrated, it is expected that these sections are created and placed in appropriate memory locations. (Locations of these objects depend on the system design and performance needs)

Section ETH_CODE ETH_VAR ETH_VAR_NOINIT ETH_CONST ETH_CONFIG ETH_UDMA_RING ETH_UDMA_DESC ETH_TX_DATA ETH_RX_DATA
ETH_TEXT_SECTION USED
ETH_ISR_TEXT_SECTION USED
ETH_CONST_32_SECTION USED
ETH_CONFIG_SECTION USED
ETH_DATA_INIT_UNSPECIFIED_SECTION USED
ETH_DATA_NO_INIT_UNSPECIFIED_SECTION USED
ETH_UDMA_RING_SECTION USED
ETH_UDMA_DESC_SECTION USED
ETH_TX_DATA_SECTION USED
ETH_RX_DATA_SECTION USED


Section ETHTRCV_CODE ETHTRCV_VAR ETHTRCV_VAR_NOINIT ETHTRCV_CONST ETHTRCV_CONFIG
ETHTRCV_TEXT_SECTION USED
ETHTRCV_CONST_32_SECTION USED
ETHTRCV_CONFIG_SECTION USED
ETHTRCV_DATA_INIT_UNSPECIFIED_SECTION USED
ETHTRCV_DATA_INIT_32_SECTION USED
ETHTRCV_DATA_NO_INIT_UNSPECIFIED_SECTION USED
ETHTRCV_DATA_NO_INIT_16_SECTION USED

Back To Top


Cache

This driver implementation has been validated with cache enabled. For optimal performance it's recommended to place (Memory Mapping) sections in cache enabled memory area.

The Ethernet driver supports ring and descriptor memory placement in non-cached memory. It's configurable through the following parameters:

  • EthRingInCachedMem - Cache management operations will be performed in ring memory only if this parameter is set.
  • EthDescInCachedMem - Cache management operations will be performed in descriptor memory only if this parameter is set.

Cache management operations refer to invalidate, write-back and write-back invalidate calls.

Back To Top


Dependencies on SW Modules


DET

This implementation depends on the DET in order to report development errors and can be turned OFF. Refer to the Development Error Reporting section for detailed error codes.

Back To Top


SchM

This implementation requires 1 level of exclusive access to guard critical sections. Invokes SchM_Enter_Eth_ETH_EXCLUSIVE_AREA_0(), SchM_Exit_Eth_ETH_EXCLUSIVE_AREA_0() to enter critical section and exit.

In the example implementation (SchM_Eth.c), all the interrupts on CPU are disabled. However, disabling of the enabled Ethernet related interrupts should suffice.

Back To Top


File Structure