Integrate net_test_router with RM.
[keystone-rtos/netapi.git] / ti / runtime / netapi / test / net_test_loopback.c
index 2dac9a251fe0656427ee383f0b73ef65cc781a3a..d85a8f1b9db31dd3f2aa9f37f89f8f7527eb6a6b 100755 (executable)
@@ -73,6 +73,7 @@ extern netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
 extern paSysStats_t netcp_stats;
 
 extern Rm_ServiceHandle   *rmClientServiceHandle;
+hplib_spinLock_T net_test_thread_lock;
 
 
 netTestConfig_t netTestCfg;
@@ -1067,13 +1068,16 @@ void fast_path_thread(uint32_t index)
     }
     hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
 #endif
+    hplib_mSpinLockLock(&net_test_thread_lock);
     worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
     
     if (worker_nh[thread_num] == NULL)
     {
         printf("fast_path_thread: netapi_init failure, exiting\n");
+        hplib_mSpinLockUnlock(&net_test_thread_lock);
         exit(1);
     }
+    hplib_mSpinLockUnlock(&net_test_thread_lock);
     /* open netcp default RX channels*/
     rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
 
@@ -1146,6 +1150,7 @@ int main(int argc, char **argv)
         printf("main: initRm() returned error\n");
         exit(1);
     }
+    hplib_mSpinLockInit(&net_test_thread_lock );
     our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
     memset(&config_file, 0, sizeof(netTestConfigFile_t));
     memset(&netTestCfg, 0, sizeof(netTestConfig_t));