From: Tinku Mannan Date: Thu, 21 May 2020 19:38:52 +0000 (-0400) Subject: PDK-6487: emac: test app updates X-Git-Tag: REL.CORESDK.07.00.00.10^0 X-Git-Url: https://git.ti.com/gitweb?p=processor-sdk%2Fpdk.git;a=commitdiff_plain;h=9c8f378180f530e4925a197bb683c30ae68120d5 PDK-6487: emac: test app updates update to demonstrate use of timer based polling when calling emac_poll_ctrl api. minor cleanup Signed-off-by: Tinku Mannan --- diff --git a/packages/ti/drv/emac/test/EmacLoopbackTest/main_am65xx.c b/packages/ti/drv/emac/test/EmacLoopbackTest/main_am65xx.c old mode 100755 new mode 100644 index bb27fc365..f429417e2 --- a/packages/ti/drv/emac/test/EmacLoopbackTest/main_am65xx.c +++ b/packages/ti/drv/emac/test/EmacLoopbackTest/main_am65xx.c @@ -74,10 +74,8 @@ extern uint32_t app_test_recv_port; #include "ti/drv/emac/test/EmacLoopbackTest/test_loc.h" #include "ti/drv/emac/test/EmacLoopbackTest/test_utils.h" - extern void app_test_task_verify_ut_dual_mac_cpsw(UArg arg0, UArg arg1); extern void app_test_task_benchmark(UArg arg0, UArg arg1); -extern void app_test_task_verify_ut_switch(UArg arg0, UArg arg1); /* * ======== Globals======== */ @@ -85,10 +83,7 @@ extern void app_test_task_verify_ut_switch(UArg arg0, UArg arg1); const char* rxTaskName[7] = {"rxPort0","rxPort1","rxPort2","rxPort3","rxPort4","rxPort5","rxPort6"}; const char* rxMgmtTaskName[7] = {"rxMgmtPort0","rxMgmtPort1","rxMgmtPort2","rxMgmtPort3","rxMgmtPort4","rxMgmtPort5","rxMgmtPort6"}; -#ifdef EMAC_TEST_APP_ICSSG_SWITCH -int32_t port_en[EMAC_PORT_CPSW + 1] = {1, 1, 1, 1, 0, 0, 0}; -#else - #ifdef EMAC_TEST_APP_WITHOUT_DDR +#ifdef EMAC_TEST_APP_WITHOUT_DDR int32_t port_en[EMAC_PORT_CPSW + 1] = {1, 1, 0, 0, 0, 0, 0}; #else #ifdef EMAC_BENCHMARK @@ -104,7 +99,6 @@ int32_t port_en[EMAC_PORT_CPSW + 1] = {1, 1, 1, 1, 0, 0, 0}; int32_t port_en[EMAC_PORT_CPSW + 1] = {0, 0, 0, 0, 0, 0, 1}; #endif #endif - #endif #endif #ifdef EMAC_TEST_APP_CPSW @@ -114,7 +108,7 @@ uint32_t endPort = EMAC_PORT_CPSW; /* ICSSG case */ #ifdef am65xx_idk uint32_t portNum = EMAC_PORT_ICSS; -uint32_t endPort = EMAC_PORT_ICSS+5; +uint32_t endPort = EMAC_PORT_ICSS + 5; #else uint32_t portNum = EMAC_PORT_ICSS + 4; uint32_t endPort = EMAC_PORT_ICSS + 5; @@ -125,6 +119,21 @@ uint32_t AsmReadActlr(void); void AsmWriteActlr(uint32_t); #endif +#ifdef APP_TEST_ENABLE_POLL_CTRL_TIMER +extern uint32_t initComplete; +void * gTimerHandle; +SemaphoreP_Params emac_app_timer_sem_params; +SemaphoreP_Handle gAppTestPollCtrlTimerSem; + +void app_test_timer_isr (UArg arg) +{ + if (initComplete != 0) + { + SemaphoreP_post(gAppTestPollCtrlTimerSem); + } +} +#endif + /* * ======== main ======== */ @@ -134,42 +143,45 @@ int main(void) Error_Block eb; Error_init(&eb); -#ifdef EMAC_TEST_APP_ICSSG_SWITCH -#ifndef EMAC_BENCHMARK - /* Create the task start the unit test.*/ - Task_Params_init(&taskParams); - taskParams.priority = 10; - taskParams.instance->name = "app_test_task_verify_ut_switch"; - Task_create( app_test_task_verify_ut_switch, &taskParams, NULL); -#else - /* Create the task to start BENCHMARK testing.*/ - Task_Params_init(&taskParams); - taskParams.priority = 11; - taskParams.arg0 = EMAC_SWITCH_PORT1; - taskParams.instance->name = "app_test_task_benchmark"; - Task_create( app_test_task_benchmark, &taskParams, NULL); -#endif - -#ifndef EMAC_CHECK_LINK_STATUS - /* Create the task to poll driver to rx pkts.*/ - /* set the priority to 10 for both polling tasks */ - taskParams.priority = 10; +#ifdef APP_TEST_ENABLE_POLL_CTRL_TIMER + TimerP_Params timerParams; - taskParams.arg0 = EMAC_SWITCH_PORT1; - taskParams.instance->name = rxTaskName[0]; - Task_create(app_test_task_poll_ctrl, &taskParams, NULL); + TimerP_Params_init(&timerParams); + timerParams.runMode = TimerP_RunMode_CONTINUOUS; + timerParams.startMode = TimerP_StartMode_AUTO; + timerParams.periodType = TimerP_PeriodType_MICROSECS; + timerParams.period = 500; + timerParams.arg = (void*)portNum; + gTimerHandle = TimerP_create(TimerP_ANY, (TimerP_Fxn)app_test_timer_isr, &timerParams); + if ( gTimerHandle == NULL) + { + UART_printf("timer create failed\n"); + while(1); + } - taskParams.arg0 = EMAC_SWITCH_PORT2; - taskParams.instance->name = rxTaskName[2]; - Task_create(app_test_task_poll_ctrl, &taskParams, NULL); + SemaphoreP_Params emac_app_timer_sem_params; + EMAC_osalSemParamsInit(&emac_app_timer_sem_params); + emac_app_timer_sem_params.mode = SemaphoreP_Mode_BINARY; + gAppTestPollCtrlTimerSem = EMAC_osalCreateBlockingLock(0,&emac_app_timer_sem_params); #endif -#else + #ifndef EMAC_BENCHMARK /* Create the task start the unit test.*/ Task_Params_init(&taskParams); taskParams.priority = 10; taskParams.instance->name = "app_test_task_verify_ut_dual_mac_cpsw"; Task_create( app_test_task_verify_ut_dual_mac_cpsw, &taskParams, NULL); + + +#ifndef EMAC_BENCHMARK + /* Create the task to poll driver to rx cfg responses.*/ + Task_Params_init(&taskParams); + taskParams.arg0 = 0; + taskParams.priority = 10; + taskParams.instance->name = rxMgmtTaskName[0]; + Task_create(app_test_task_poll_ctrl, &taskParams, NULL); +#endif + #else /* Create the task to start BENCHMARK testing.*/ Task_Params_init(&taskParams); @@ -196,17 +208,9 @@ int main(void) taskParams.instance->name = rxTaskName[i]; Task_create(app_test_task_poll_pkt, &taskParams, NULL); -#ifndef EMAC_BENCHMARK - /* Create the task to poll driver to rx cfg responses.*/ - Task_Params_init(&taskParams); - taskParams.arg0 = i; - taskParams.priority = 10; - taskParams.instance->name = rxMgmtTaskName[i]; - Task_create(app_test_task_poll_ctrl, &taskParams, NULL); -#endif + } -#endif { #ifdef BUILD_MCU uint32_t actlrRegVal = AsmReadActlr(); diff --git a/packages/ti/drv/emac/test/EmacLoopbackTest/test_utils_k3.c b/packages/ti/drv/emac/test/EmacLoopbackTest/test_utils_k3.c index 71423991c..d923cda24 100644 --- a/packages/ti/drv/emac/test/EmacLoopbackTest/test_utils_k3.c +++ b/packages/ti/drv/emac/test/EmacLoopbackTest/test_utils_k3.c @@ -93,6 +93,10 @@ extern uint32_t portNum; extern uint32_t endPort; extern int port_en[]; +#ifdef APP_TEST_ENABLE_POLL_CTRL_TIMER +extern SemaphoreP_Handle gAppTestPollCtrlTimerSem; +#endif + /********************************************************************** ************************** Global Variables ************************** **********************************************************************/ @@ -195,7 +199,6 @@ int32_t app_test_task_disable_pruicss(uint32_t portNum); void app_test_wait_mgmt_resp(uint32_t waitTimeMilliSec); uint32_t pollModeEnabled = 0; -uint32_t linkStatus = 0; uint32_t initComplete = 0; uint32_t app_test_id = 0; #if defined (EMAC_BENCHMARK) @@ -730,8 +733,6 @@ void app_test_rx_pkt_cb(uint32_t port_num, EMAC_PKT_DESC_T* p_desc) #endif } - - /****************************************************************************** * Function: EMAC RX timestamp_response back function ******************************************************************************/ @@ -753,7 +754,6 @@ void app_test_ts_response_cb(uint32_t port_num, uint32_t ts_id, uint64_t ts, boo void app_test_task_poll_pkt (UArg arg0, UArg arg1) { uint32_t port = (uint32_t) arg0; - linkStatus = 1; while(initComplete == 0) { Task_sleep(1); @@ -813,35 +813,77 @@ void app_test_task_poll_pkt (UArg arg0, UArg arg1) } } +#ifdef APP_TEST_ENABLE_POLL_CTRL_TIMER void app_test_task_poll_ctrl (UArg arg0, UArg arg1) { - uint32_t port = (uint32_t) arg0; + uint32_t pNum = 0; +#ifdef EMAC_TEST_APP_ICSSG + uint32_t mgmtRings =EMAC_POLL_RX_MGMT_RING2 | EMAC_POLL_RX_MGMT_RING3; + uint32_t pktRings =EMAC_POLL_RX_PKT_RING1 | EMAC_POLL_RX_PKT_RING2; + uint32_t txRings = EMAC_POLL_TX_COMPLETION_RING_ALL; +#else + uint32_t mgmtRings =0x0; + uint32_t pktRings =EMAC_POLL_RX_PKT_RING1; + uint32_t txRings = EMAC_POLL_TX_COMPLETION_RING1; +#endif + while(initComplete == 0) + { + Task_sleep(1); + } + + UART_printf("app_test_task_poll_ctrl: timer based polling\n"); + while(1) + { + SemaphoreP_pend(gAppTestPollCtrlTimerSem, BIOS_WAIT_FOREVER); + + for (pNum = portNum; pNum <= endPort; pNum++) + { + if (!port_en[pNum]) + continue; + emac_poll_ctrl (pNum, pktRings, mgmtRings, txRings); + } + } +} +#else +void app_test_task_poll_ctrl (UArg arg0, UArg arg1) +{ + uint32_t pNum; #ifdef EMAC_TEST_APP_ICSSG - uint32_t mgmtRings =0x7; - uint32_t pktRings =0x1ff; - uint32_t txRings = 0xf; + uint32_t mgmtRings =EMAC_POLL_RX_MGMT_RING2 | EMAC_POLL_RX_MGMT_RING3; + uint32_t pktRings =EMAC_POLL_RX_PKT_RING1 | EMAC_POLL_RX_PKT_RING2; + uint32_t txRings = EMAC_POLL_TX_COMPLETION_RING_ALL; #else uint32_t mgmtRings =0x0; - uint32_t pktRings =0x1; - uint32_t txRings = 0x0; + uint32_t pktRings =EMAC_POLL_RX_PKT_RING1; + uint32_t txRings = EMAC_POLL_TX_COMPLETION_RING1; #endif - linkStatus = 1; while(initComplete == 0) { Task_sleep(1); } - UART_printf("polling all pkts on port: %d\n", port); + UART_printf("app_test_task_poll_ctrl: sleep polling\n"); while(1) { - if (pollModeEnabled == 1) - emac_poll_ctrl(port, pktRings,mgmtRings,txRings); - else - emac_poll_ctrl(port, 0,EMAC_POLL_RX_MGMT_RING2,txRings); - Task_sleep(2); + for (pNum = portNum; pNum <= endPort; pNum++) + { + if (!port_en[pNum]) + continue; + if (pollModeEnabled == 1) + { + emac_poll_ctrl(pNum, pktRings,mgmtRings,txRings); + } + else + { + emac_poll_ctrl(pNum, 0,EMAC_POLL_RX_MGMT_RING2,txRings); + } + Task_sleep(2); + } } } +#endif + int32_t emac_send_fail = 0;