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.

PROCESSOR-SDK-AM64X: CPSW send will freeze at EnetUdmaStats_addCnt when calling EnetDma_submitTxPktQ after sending hundreds of packages

Part Number: PROCESSOR-SDK-AM64X

Tool/software:

Hi Sir,

     We are using fast startup CPSW example to evaluate the CPSW sending function, my sending function is like this:

while(1)
    {
        EnetQueue_initQ(&txSubmitQ);

        EnetApp_retrieveFreeTxPkts();
        /* Dequeue one free TX Eth packet */
        txPktInfo = (EnetDma_Pkt *)EnetQueue_deq(&gEnetApp.txFreePktInfoQ);
        if (txPktInfo != NULL)
        {
            /* Fill the TX Eth frame with test content */
            txFrame = (EthFrame *)txPktInfo->sgList.list[0].bufPtr;
            memcpy(txFrame->hdr.dstMac, &dstMac[0], ENET_MAC_ADDR_LEN);
            memcpy(txFrame->hdr.srcMac, &srcMac[0U], ENET_MAC_ADDR_LEN);
            txFrame->hdr.etherType = 0x88a4;

            txPktInfo->sgList.list[0].segmentFilledLen = 120;

            memcpy(&txFrame->payload[0U],
                   &layload[0U],
                   txPktInfo->sgList.list[0].segmentFilledLen - sizeof(EthFrameHeader));

            txPktInfo->sgList.numScatterSegments = 1;
            txPktInfo->chkSumInfo = 0U;
            txPktInfo->appPriv = &gEnetApp;
            txPktInfo->tsInfo.enableHostTxTs = false;

            EnetDma_checkPktState(&txPktInfo->pktState,
                                    ENET_PKTSTATE_MODULE_APP,
                                    ENET_PKTSTATE_APP_WITH_FREEQ,
                                    ENET_PKTSTATE_APP_WITH_DRIVER);

//            EnetAppUtils_print("before enqueue txPkt %d \r\n", i);
            /* Enqueue the packet for later transmission */
            EnetQueue_enq(&txSubmitQ, &txPktInfo->node);
        }
        else
        {
            EnetAppUtils_print("Drop due to TX pkt not available\r\n");
        }

//        EnetAppUtils_print("before Transmit %d \r\n", i);
        /* Transmit all enqueued packets */
        status = EnetDma_submitTxPktQ(gEnetApp.hTxCh, &txSubmitQ);
        if (status != ENET_SOK)
        {
            EnetAppUtils_print("Failed to submit TX pkt queue: %d\r\n", status);
        }

        i++;
//        EnetAppUtils_print("before sleep %d \r\n", i);

//        ClockP_usleep(200000U);
    }

but after sending ardound 230 packages, the function will freeze and send no more packages, by looking from the jtag, I found out the function is freeze at EnetDma_submitTxPktQ -> EnetUdmaStats_addCnt in enet_udma.c file here:

int32_t EnetDma_submitTxPktQ(EnetDma_TxChHandle hTxCh,
                                  EnetDma_PktQ *pSubmitQ)

{
    EnetPer_Handle hPer = hTxCh->hDma->hPer;
    int32_t retVal = UDMA_SOK;
    Udma_RingHandle ringHandle;

#if ENET_CFG_IS_ON(DEV_ERROR)
    if ((NULL == hTxCh) ||
        (NULL == pSubmitQ))
    {
        ENETTRACE_ERR_IF((NULL == hTxCh), "[Enet UDMA] hTxCh is NULL!!\n");
        ENETTRACE_ERR_IF((NULL == pSubmitQ), "[Enet UDMA] pSubmitQ is NULL!!\n");
        Enet_assert(FALSE);
        retVal = UDMA_EBADARGS;
    }
    else
#endif
    {
#if defined(ENETDMA_INSTRUMENTATION_ENABLED)
        uint32_t startTime, diffTime;
        uint32_t pktCnt, notifyCount;
        startTime = EnetOsal_timerRead();
        pktCnt    = EnetQueue_getQCount(pSubmitQ);
#endif
#if (UDMA_SOC_CFG_UDMAP_PRESENT == 1)
        ringHandle = hTxCh->fqRing;
#else
        ringHandle = hTxCh->cqRing;
#endif
        /* Enqueue descs to fqRing regardless of caller's queue state */
        if (EnetQueue_getQCount(pSubmitQ) > 0U)
        {
            retVal = EnetUdma_submitPkts(hPer,
                                         ringHandle,
                                         pSubmitQ,
                                         hTxCh->hDmaDescPool,
                                         hTxCh->txChPrms.disableCacheOpsFlag,
                                         ENET_UDMA_DIR_TX
#if (UDMA_SOC_CFG_PROXY_PRESENT == 1)
                                         ,
                                         hTxCh->hUdmaProxy
#endif
                                         );
        }

        /* If fqRing ran out of space it is not an error, packets will be re-submitted by application*/
        if (UDMA_ETIMEOUT == retVal)
        {
            ENETTRACE_INFO("TX Channel FQ underflow had occurred\n");
            retVal = UDMA_SOK;
        }

#if defined(ENETDMA_INSTRUMENTATION_ENABLED)
        EnetUdmaStats_addCnt(&hTxCh->stats.txSubmitPktOverFlowCnt, EnetQueue_getQCount(pSubmitQ));
        pktCnt -= EnetQueue_getQCount(pSubmitQ);
        EnetUdmaStats_addCnt(&hTxCh->stats.txSubmitPktEnq, pktCnt);
        diffTime                                                  = EnetOsal_timerGetDiff(startTime);
        notifyCount                                               = hTxCh->stats.submitPktStats.dataNotifyCnt & (ENET_DMA_STATS_HISTORY_CNT - 1U);
        hTxCh->stats.submitPktStats.readyDmaDescQCnt[notifyCount] = hTxCh->hDmaDescPool->count;

        EnetUdmaStats_updateNotifyStats(&hTxCh->stats.submitPktStats, pktCnt, diffTime);
#endif
    }

By the way, is the marco ENETDMA_INSTRUMENTATION_ENABLED essential for normal function of CPSW DMA send? Can I switch it off and where I can switch it off?

     Thank you!

  • One more thing, I also tried to disable the ENETDMA_INSTRUMENTATION_ENABLED in the lib makefile, the rebuild the lib. The freezing of EnetDma_submitTxPktQ still happen. Every time I halt from the JTAG when the system stop sending out packages, I found the PC is in the ClockP_timerTickIsr function to handle the ClockP_timerClearOverflowInt. Then jump back to EnetDma_submitTxPktQ. So I have no idea what really happened and don't know how to keep on debuging.

  • Hi Brian,

    Please allow me one week to try and reproduce the issue. I will get back to you based on the results seen. Meanwhile, please share the details of what is the MCU+ SDK version that you are using, and the environment (custom board or TI evaluation module), size of packets sent, and any additional info about the application which is different from MCU+ SDK. This example needs changes on the board as well to operate correctly. Please refer to the link below for details:

    https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/EXAMPLES_ENET_LAYER2_CPSW_FAST_STARTUP.html#autotoc_md1641

    Regards,
    Teja.

  • Hi Teja,

         OK. Thank you!

         My enviorment is like this:

    CCS Version: 12.8.1

    SDK Version: mcu_plus_sdk_am64x_10_01_00_32

    Board: Custom made, Chip: AM6442F, PHY on CPSW RGMII1 Port1: DP83867, no I2C EEPROM to store MAC address

    Packets send: I have tried 60,128 and 512 bytes

         By the way, because of the limit of time line, we have to shift to use the example of l2 cpsw which using FREERTOS as the basic start point to meet the needs of show on September. Now it can work under freertos. But next step will come back to barematel again to try to improve the performance. So we are looking forward for your test result. Thank you again!

  • Hi Brian,

    I will try to reproduce this issue on our test bench. You can expect the results in 2 weeks. I will update the E2E once I am able to reproduce this, or when I need additional information.

    Regards,
    Teja.