]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blobdiff - ti/runtime/netapi/test/net_test_loopback.c
NETAPI library and test changes to integrate with Resource Manager(RM)
[keystone-rtos/netapi.git] / ti / runtime / netapi / test / net_test_loopback.c
index cb70c1216c01183e3c929f711d74e53522481fe7..3e47c94ba442701eba7d7627ec763ee74e042ec2 100755 (executable)
@@ -69,6 +69,8 @@ extern int QUIT;
 extern netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
 extern paSysStats_t netcp_stats;
 
+extern Rm_ServiceHandle   *rmClientServiceHandle;
+
 
 netTestConfig_t netTestCfg;
 static netTestConfigFile_t config_file;
@@ -117,7 +119,8 @@ static NETAPI_CFG_T our_netapi_default_cfg=
     TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128,  //size of buffers in default heap
     128, //tail room
     256, //extra room
-    0
+    0,
+    NULL
 };
 
 NETAPI_T netapi_handle;
@@ -996,13 +999,11 @@ void slow_path_thread(uint32_t index)
 #else
     for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
     {
-        printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
         CPU_SET( i, &cpu_set);
     }
     hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
 #endif
-    worker_nh[thread_num] = netapi_init(NETAPI_CORE_MASTER,
-                                        NULL);
+    worker_nh[thread_num] = netapi_init(NETAPI_CORE_MASTER,NULL);
 
     if (worker_nh[thread_num] == NULL)
     {
@@ -1025,6 +1026,7 @@ void slow_path_thread(uint32_t index)
     netapi_schedRun(scheduler[thread_num], &err);
 
 ERR_slow_path_thread:
+    printf("slow_path_thread: calling netapi_shutdown\n");
     netapi_shutdown(worker_nh[thread_num]);
 }
 
@@ -1057,8 +1059,8 @@ void fast_path_thread(uint32_t index)
     }
     hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
 #endif
-    worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,
-                                      NULL);
+    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");
@@ -1093,7 +1095,8 @@ void fast_path_thread(uint32_t index)
 ERR_fast_path_thread:
     netapi_pktioClose(rx_chan, &err);
     netapi_pktioClose(sb_rx_chan, &err);
-
+    
+    printf("fast_path_thread: calling netapi_shutdown\n");
     netapi_shutdown(worker_nh[thread_num]);
 }
 
@@ -1129,35 +1132,39 @@ int main(int argc, char **argv)
         printf("Cant open config file: filepath %s, %s\n", input_file_name, strerror(errno));
         exit(1);
     }
-    else
+
+    if (initRm())
     {
-        memset(&config_file, 0, sizeof(netTestConfigFile_t));
-        memset(&netTestCfg, 0, sizeof(netTestConfig_t));
-        
-        netTest_utilProcessConfigFile(fpr,&config_file);
+        printf("main: initRm() returned error\n");
+        exit(1);
+    }
+    our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
+    memset(&config_file, 0, sizeof(netTestConfigFile_t));
+    memset(&netTestCfg, 0, sizeof(netTestConfig_t));
 
-        netTest_utilParseMac(&config_file);
+    netTest_utilProcessConfigFile(fpr,&config_file);
 
-        /* parse slow path/fast path thread configuration parameters */
-        netTest_utilParseThreadParams(&config_file);
+    netTest_utilParseMac(&config_file);
 
-        netTest_utilParseIP(&config_file);
+    /* parse slow path/fast path thread configuration parameters */
+    netTest_utilParseThreadParams(&config_file);
 
-        netTest_utilParseIpsecMode(&config_file);
+    netTest_utilParseIP(&config_file);
 
-        /* DSP mac processing */
-        parse_dsp_mac(&config_file.dsp_mac[0]);
+    netTest_utilParseIpsecMode(&config_file);
 
-       /* DSP IP processing */
-        parse_dsp_ip(&config_file.dsp_ip[0]);
+    /* DSP mac processing */
+    parse_dsp_mac(&config_file.dsp_mac[0]);
 
-        /* IPSEC interface number processing */
-        parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
+    /* DSP IP processing */
+    parse_dsp_ip(&config_file.dsp_ip[0]);
 
-        netTest_utilParseSA(&config_file);
+    /* IPSEC interface number processing */
+    parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
 
-        parse_simple_param_u32(&config_file.dest_udp_port_config, &netTestCfg.dest_udp_port_config);
-    }
+    netTest_utilParseSA(&config_file);
+
+    parse_simple_param_u32(&config_file.dest_udp_port_config, &netTestCfg.dest_udp_port_config);
 
     memset(&sa_info, 0, sizeof(sa_info));
 
@@ -1170,17 +1177,17 @@ int main(int argc, char **argv)
 #endif
 
     /* create netapi */
+
     netapi_handle = netapi_init(NETAPI_SYS_MASTER,
                                 &our_netapi_default_cfg);
 
     if (netapi_handle == NULL)
     {
         printf("main: netapi_init failure, exiting\n");
+        closeRm();
         exit(1);
     }
 
-
-
     /* configure expection packet handling with netapi */
     netapi_netcpCfgExceptions(netapi_handle,
                               NETCP_CFG_ALL_EXCEPTIONS,
@@ -1196,6 +1203,7 @@ int main(int argc, char **argv)
     if (!ourHeap)
     {
         printf("Pktlib_findHeapByName()  fail\n");
+        closeRm();
         exit(1);
     }
 
@@ -1203,7 +1211,12 @@ int main(int argc, char **argv)
 
     /* create scheduler instance */
     our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
-    if (!our_sched) {printf("sched create failed\n"); exit(1);}
+    if (!our_sched)
+    {
+        printf("sched create failed\n");
+        closeRm();
+        exit(1);
+    }
 
 
     /*create net_test MAC interfaces, attach IP to created MAC interfaces */
@@ -1215,6 +1228,7 @@ int main(int argc, char **argv)
     if (!p_trie_sa_rx || !p_trie_sa_tx)
     {
         printf("trie alloc for SA  failed\n");
+        closeRm();
         exit(1);
     }
 
@@ -1238,24 +1252,25 @@ int main(int argc, char **argv)
     printf("\n Enter 's' for stats or 'q'to quit net_test_loopback app, or 'h' for help\n");
 
 
+
+
     char c;
-        //this thread of execution (main) now just waits on user input
-        for(;;)
-        {
-           printf(">");
-           c=getchar();
-           if (c=='q')
-            {
-                QUIT=1;
-                printf("net_test_loopback: please wait for application shutdown and resource cleanup\n");
-                break;
-           }
-           else if (c=='s') netTest_utilsStatsCb(netapi_handle, &netcp_stats);
-           else if (c=='h') printf("'q' to quit,  's' for stats, 'h' for help\n");
-        }
+    //this thread of execution (main) now just waits on user input
+    for(;;)
+    {
+       printf(">");
+       c=getchar();
+       if (c=='q')
+       {
+            QUIT=1;
+            printf("net_test_loopback: please wait for application shutdown and resource cleanup\n");
+            break;
+       }
+       else if (c=='s') netTest_utilsStatsCb(netapi_handle, &netcp_stats);
+       else if (c=='h') printf("'q' to quit,  's' for stats, 'h' for help\n");
+    }
 
         netTest_utilRemoveSpFpThreads(netTestCfg.num_sp_threads, netTestCfg.num_fp_threads);
-
 }
 #else
     /*********************************************/
@@ -1281,6 +1296,7 @@ int main(int argc, char **argv)
 #endif
 
     netapi_shutdown(netapi_handle);
+    closeRm();
     printf("net_test shutdown complete\n");
 
 }