]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blobdiff - ti/runtime/netapi/test/net_test_max_params.c
Fixed issue with running and gracefully terminating net_test_router application.
[keystone-rtos/netapi.git] / ti / runtime / netapi / test / net_test_max_params.c
index e83c123a73aef05cee81bf51b1faac3ad1af5dc3..980a78d38d52c61117c133a6d53ca052994d79ca 100755 (executable)
 
  *****************************************/
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+#include "net_test.h"
+#include "ti/drv/nwal/test/fw_rm.h"
 #include <signal.h>
 #include <pthread.h>
 
-#include "net_test.h"
-#include "trie.h"
-#include "string.h"
-
-#include <sys/resource.h>
-
-#include <ti/drv/sa/salld.h>
-#include <ti/drv/pa/pa.h>
-
-#include "net_test_utils.h"
-#include "router.h"
-
 extern int QUIT;
-extern STATS_T stats[TUNE_NETAPI_NUM_CORES];
+extern netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
 extern paSysStats_t netcp_stats;
 /* Global definitions */
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
     cpu_set_t cpu_set;
 #endif
 
 
-#define TEST_SA
-//#define TEST_MAC_IP
 #define SA_CREATE_LOOP_COUNT 64
 #define IP_CREATE_LOOP_COUNT 64
 #define MAC_CREATE_LOOP_COUNT 59
@@ -80,7 +64,7 @@ extern paSysStats_t netcp_stats;
 netTestConfig_t netTestCfg;
 static  netTestConfigFile_t config_file;
 
-char    input_file_name[] = "net_test_config.txt";
+char    input_file_name[] = "net_test_config_max_iface.txt";
 
 nwal_RetValue       nwalRetVal;
 Pktlib_HeapHandle ourHeap;
@@ -124,7 +108,7 @@ TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128,  //size of buffers in default heap
 
 NETAPI_T netapi_handle;
 NETAPI_SCHED_HANDLE_T * our_sched;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
 NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
 #endif
 NETAPI_SCHED_CONFIG_T our_sched_cfg={
@@ -170,7 +154,7 @@ void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route)
 {
 }
 
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
 NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
 
 void slow_path_thread(uint32_t thread_num)
@@ -280,7 +264,7 @@ void open_pktio_tx_channels(void)
         }
     }
 
-    /*/* open netcp default  TX for AH packets */
+    /* open netcp default  TX for AH packets */
     netcp_tx_chan_ah= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_ah)
     {
@@ -335,21 +319,14 @@ int main(int argc, char **argv)
 {
     int err,i;
     Pktlib_HeapCfg      heapCfg;
-    rlim_t oss,ss = 1024*1024;
-    struct rlimit rl;
     int32_t             errCode;
     Pktlib_HeapIfTable*  pPktifTable;
-    /* Local Per Process default resourcese maintained at NWAL */
-    nwalLocCxtInfo_t    nwalLocCxt;
-    //nwalSaIpSecId_t  nwalSaIpSecId;
     FILE * fpr = NULL;
 
-    err= getrlimit(RLIMIT_STACK,&rl);
-    if (!err) printf(" stack limit = %d\n",rl.rlim_cur); else printf("getrlimit failed\n");
-
 
+    setvbuf(stdout,NULL,_IONBF,0);
      /* install signal handler for ^c */
-    signal(SIGINT,mysig);
+    signal(SIGINT,netTest_utilMySig);
 
     if (argc == 2)
     {
@@ -362,28 +339,55 @@ int main(int argc, char **argv)
     }
     if (fpr == NULL)
     {
+        printf("error opening configfile\n");
         exit(1);
     }
     else
     {
         memset(&config_file, 0, sizeof(netTestConfigFile_t));
         memset(&netTestCfg, 0, sizeof(netTestConfig_t));
-        parse_config_file(fpr,&config_file);
+        netTest_utilProcessConfigFile(fpr,&config_file);
+#if 1
+        netTest_utilParseMac(&config_file);
+
+        /* parse slow path/fast path thread configuration parameters */
+        netTest_utilParseThreadParams(&config_file);
+
+        netTest_utilParseIP(&config_file);
+
+        netTest_utilParseIpsecMode(&config_file);
+
+        /* DSP mac processing */
+        parse_dsp_mac(&config_file.dsp_mac[0]);
+
+       /* DSP IP processing */
+        parse_dsp_ip(&config_file.dsp_ip[0]);
+
+        /* IPSEC interface number processing */
+        parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
+
+        netTest_utilParseSA(&config_file);
+#endif
     }
 
     memset(&sa_info, 0, sizeof(sa_info));
 
 
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
     /* assign main net_test thread to run on core 0 */
     CPU_ZERO( &cpu_set);
     CPU_SET( 0, &cpu_set);
-    hplib_utilSetupCore(0, &cpu_set);
+    hplib_utilSetupThread(0, &cpu_set);
 #endif
 
     /* create netapi */
     netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
 
+    if (netapi_handle)
+        printf("main: netapi_init sucess\n");
+    else
+        printf("main: netapi_init fail, null netapi_handle\n");
+
     /* open the main heap */
     ourHeap = Pktlib_findHeapByName("netapi");
     if (!ourHeap)
@@ -400,9 +404,8 @@ int main(int argc, char **argv)
 
 
     /*create net_test MAC interfaces, attach IP to created MAC interfaces */
-//#ifdef TEST_MAC_IP
-    create_interfaces();
-//#endif
+    netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
+
     /* lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
     p_trie_sa_rx = trie_new();
     p_trie_sa_tx = trie_new();
@@ -412,14 +415,12 @@ int main(int argc, char **argv)
 
 #ifdef TEST_SA
     /* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
-    create_sec_associations();
+    netTest_utilCreateSecAssoc();
 #endif
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
 {
     char c;
-    /* create and set affinity of slow path and fast path threads to
-    * specific CPU cores as specified in the net_test_config.txt file */
-    //create_sp_fp_threads();
+
 
         //this thread of execution (main) now just waits on user input
         for(;;)
@@ -434,9 +435,6 @@ int main(int argc, char **argv)
             else if (c=='h')
                 printf("'q' to quit,  's' for stats, 'h' for help\n");
         }
-
-        //sp_fp_thread_cleanup();
-
 }
 #else
     /*********************************************/
@@ -446,9 +444,9 @@ int main(int argc, char **argv)
 #endif
 
     /* cleanup*/
-     delete_sec_associations();
+     netTest_utilDeleteSecAssoc();
 
-    delete_interfaces();
+    netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
 
     /* close pktio channels we opened via open_pktio_tx_channels() */
     close_pktio_channels();