This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] TDA4VM: How to get CPSW Ethernet Statistics on TDA4/DRA8 devices?

Part Number: TDA4VM
Other Parts Discussed in Thread: DRA821, , TDA4VH, DRA829

I need to see Ethernet statistics for CPSW on TDA4/DRA8 devices for debugging. Is there any way for me to read them?

  • Hi All,

    The CPSW IP has an statistics module where multiple stats are recorded for all the ports of the IP. The description and register addresses for the individual stats can be found in the TRM (Section - 12.2.2.4.6.19, Title - CPSW Network Statistics) of the SoC. To read these statistics easily, we have the following tools in place.

    From CCS (for Enet LLD applications and Ethfw)

    1. Launch the correct target configuration and connect to the core running the application. It will be mcu2_0(MAIN_Cortex_R5_0_0 in CCS Debug window) in case of Ethfw server.
    2. Select the Tools → GEL Files option. It should open a window titled GEL Files
    3. Right Click on the empty area on the right side of the GEL Files window and select "Load GEL..."
    4. Navigate to "[PSDK-RTOS-INSTALL-DIR]/pdk-[version]/packages/ti/drv/enet/tool/debug_gels/" folder and select the cpsw_stats_print_regs.gel
    5. You should see "cpsw_stats_print_regs.gel" in the GEL Files window. Pause/Suspend the core which you have connected to (If you want to get stats while the application is running, pause/suspend another core which is not running any application. You might have to repeat steps 3 and 4 in this case).
    6. Go to Scripts → CPSW Statistics Print and select the IP for which you would like to print the ALE Table for
      1. cpsw_2g_statsprint_nonzero for MCU CPSW 2G
      2. cpsw_5g_statsprint_nonzero for MAIN CPSW 5G (DRA821)
      3. cpsw_9g_statsprint_nonzero for MAIN CPSW 9G (DRA829/TDA4VM/TDA4VH)
    7. You should see the ALE Table printed in Console. The output will be like the following:
      1. Fullscreen
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        MCU_Cortex_R5_0: GEL Output: STATS
        MCU_Cortex_R5_0: GEL Output: --------------------------------
        MCU_Cortex_R5_0: GEL Output: PORT0 STATS
        MCU_Cortex_R5_0: GEL Output: --------------------------------
        MCU_Cortex_R5_0: GEL Output: STAT_0_RXGOODFRAMES = 0x0002F960
        MCU_Cortex_R5_0: GEL Output: STAT_0_RXBROADCASTFRAMES = 0x0000193B
        MCU_Cortex_R5_0: GEL Output: STAT_0_RXMULTICASTFRAMES = 0x0000012C
        MCU_Cortex_R5_0: GEL Output: STAT_0_RXOCTETS = 0x01049D67
        MCU_Cortex_R5_0: GEL Output: STAT_0_TXGOODFRAMES = 0x00006AD5
        MCU_Cortex_R5_0: GEL Output: STAT_0_TXBROADCASTFRAMES = 0x0000193C
        MCU_Cortex_R5_0: GEL Output: STAT_0_TXMULTICASTFRAMES = 0x000025A7
        MCU_Cortex_R5_0: GEL Output: STAT_0_TXOCTETS = 0x005AAD86
        MCU_Cortex_R5_0: GEL Output: STAT_0_OCTETFRAMES64 = 0x000057BB
        MCU_Cortex_R5_0: GEL Output: STAT_0_OCTETFRAMES65T127 = 0x0002C0DE
        MCU_Cortex_R5_0: GEL Output: STAT_0_OCTETFRAMES128T255 = 0x00000113
        MCU_Cortex_R5_0: GEL Output: STAT_0_OCTETFRAMES256T511 = 0x00004A86
        MCU_Cortex_R5_0: GEL Output: STAT_0_OCTETFRAMES512T1023 = 0x00000003
        MCU_Cortex_R5_0: GEL Output: STAT_0_NETOCTETS = 0x015F4AED
        MCU_Cortex_R5_0: GEL Output: STAT_0_TX_PRI_REG [0]= 0x00006AD5
        MCU_Cortex_R5_0: GEL Output: STAT_0_TX_PRI_BCNT_REG [0]= 0x005AAD86
        MCU_Cortex_R5_0: GEL Output: --------------------------------
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    8. Note : This will only print the nonzero stats. So the stats which are not mentioned will be 0.

    From Ethfw with Linux (Output on Ethfw UART)

    1. From Linux Command Prompt, run the following command :
      1. ethtool -t $IF_NAME
        1. $IF_NAME is the name of the network interface you want to see statistics of.
        2. $IF_NAME=eth1 for switch port (Default)
        3. $IF_NAME=eth2 for MAC-only port (Default)
    2. Sample Log:
      1. Fullscreen
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        Port 0 Statistics
        -----------------------------------------
        rxGoodFrames = 56
        rxBcastFrames = 16
        rxMcastFrames = 40
        aleDrop = 42
        rxOctets = 9712
        txGoodFrames = 573
        txBcastFrames = 220
        txMcastFrames = 353
        txOctets = 65372
        octetsFrames64 = 210
        octetsFrames65to127 = 299
        octetsFrames128to255 = 41
        octetsFrames256to511 = 71
        octetsFrames512to1023 = 8
        netOctets = 75084
        portMaskDrop = 42
        alePolicyMatch = 6
        txPri[0] = 573
        txPriBcnt[0] = 65372
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    3. Note : This will only print the nonzero stats. So the stats which are not mentioned will be 0.

    From Ethfw with Linux (Output on Linux Console)

    In some cases, it might be possible that you do not have a ethfw UART available on board, in those cases a patch needs to be applied to ethfw to enable periodic dump of stats to the IPC buffer which can be viewed from Linux. The patch is available in the following attachment and is tested on SDK 8.6.

    Attachment : 6685.CPSW_Periodic_stat_dump.zip

    To apply the patch and build ethfw :

    1. Extract the patch from the attachment.
    2. Go to "[PSDK-RTOS-INSTALL-DIR]/ethfw" and create a git repository there if not one already. Run 
      1. git init - to create an empty git repository
      2. git add . - to add all the files to the git repo
      3. git commit -m "Initial Commit" - to do the first commit 
    3. Apply the patch "0001-Adds-support-for-periodic-CPSW-stat-collection.patch"
      1. run "git am [Path_to_0001-Adds-support-for-periodic-CPSW-stat-collection.patch]" to apply the patch
    4. Modify the code based on "readme.txt" given in the attachment for your setup and requirements
    5. To build ethfw, go to "[PSDK-RTOS-INSTALL-DIR]/ethfw" and run the following command
      1. make ethfw_all BUILD_SOC_LIST=<SOC_NAME>
        1. <SOC_NAME>=J721E for DRA829 and TDA4VM
        2. <SOC_NAME>=J7200 for DRA821
        3. <SOC_NAME>=J784S4 for TDA4VH

    To read the stats:

    1. The printed stats can be read using the command
      1. cat /sys/kernel/debug/remoteproc/remoteproc*/trace0
    2. Sample Log :
      1. Fullscreen
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        =======================================================
        CPSW Ethernet Firmware
        =======================================================
        Warning: Using 6 MAC address(es) from static pool
        ETHFW: Shared multicasts (software fanout):
        01:00:5e:00:00:01
        01:00:5e:00:00:fb
        01:00:5e:00:00:fc
        33:33:00:00:00:01
        33:33:ff:1d:92:c2
        01:80:c2:00:00:00
        01:80:c2:00:00:03
        ETHFW: Reserved multicasts:
        01:80:c2:00:00:0e
        01:1b:19:00:00:00
        EnetMcm: CPSW_5G on MAIN NAVSS
        Mdio_open: MDIO manual mode enabled
        PHY 16 is alive
        PHY 17 is alive
        PHY 18 is alive
        PHY 19 is alive
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    3. Note : This will only print the nonzero stats. So the stats which are not mentioned will be 0.

    From Linux (for Native Linux Driver)

    1. From Linux Command Prompt, run the following command
      1. ethtool -S $IF_NAME
        1. $IF_NAME is the name of the network interface you want to see statistics of.
    2. Sample Log :
      1. Fullscreen
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        root@j7200-evm:~# ethtool -S eth2
        NIC statistics:
        p0_rx_good_frames: 345
        p0_rx_broadcast_frames: 21
        p0_rx_multicast_frames: 98
        p0_rx_crc_errors: 0
        p0_rx_oversized_frames: 0
        p0_rx_undersized_frames: 0
        p0_ale_drop: 0
        p0_ale_overrun_drop: 0
        p0_rx_octets: 39012
        p0_tx_good_frames: 59
        p0_tx_broadcast_frames: 27
        p0_tx_multicast_frames: 17
        p0_tx_octets: 13470
        p0_tx_64B_frames: 23
        p0_tx_65_to_127B_frames: 276
        p0_tx_128_to_255B_frames: 51
        p0_tx_256_to_511B_frames: 54
        p0_tx_512_to_1023B_frames: 0
        p0_tx_1024B_frames: 0
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Regards,
    Tanmay