Test application updates for Multi-process support in NETAPI
authorTinku Mannan <tmannan@ti.com>
Tue, 17 Jun 2014 18:55:28 +0000 (14:55 -0400)
committerTinku Mannan <tmannan@ti.com>
Tue, 17 Jun 2014 18:55:28 +0000 (14:55 -0400)
ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapi_ipsecmgr.c
ti/runtime/netapi/test/net_test_bench.c
ti/runtime/netapi/test/net_test_loopback.c
ti/runtime/netapi/test/net_test_router.c
ti/runtime/netapi/test/net_test_sa_utils.c
ti/runtime/netapi/test/net_test_utils.h

index 07ccd673b70aa382fceb7449292c1caca04b9c86..93dbe0df6ea23c8012e4638363bd26a824681d23 100755 (executable)
@@ -104,19 +104,6 @@ char*  DTS_LOG_FILE_FLOW_ETHx[] = {
 /**********************************************************************
  ************************** Local Definitions *************************
  **********************************************************************/
-#if 0
-
-char*  DTS_LOG_FILE_QUEUE_ETHx[] = {
- "/proc/device-tree/soc/pktdma@2004000/channels/netrx0/complete-queue"};
-char*  DTS_LOG_FILE_FLOW_ETHx[] = {
-"/proc/device-tree/soc/pktdma@2004000/channels/netrx0/flow"};
-
-char*  DTS_LOG_FILE_QUEUE_ETHx[] = {
- "/proc/device-tree/soc/pktdma@26186000/channels/netrx0/complete-queue"};
-char*  DTS_LOG_FILE_FLOW_ETHx[] = {
-"/proc/device-tree/soc/pktdma@26186000/channels/netrx0/flow"};
-#endif
-
 
 /**********************************************************************
  ************************** Global Variables **************************
@@ -246,7 +233,6 @@ static void* snoop_run_thread (void* arg)
     cleanup_sa_sp();
     netapi_shutdown(netapi_handle);
 
-    if (use_rm)
         closeRm();
     return;
 }
@@ -799,17 +785,10 @@ int32_t main (int argc, char* argv[])
     memset(&globalDB, 0, sizeof(globalDB));
     globalDB.sa_tx_flow = -1;
     int temp;
-    while ((c = getopt (argc, argv, "s:f:r:")) != -1)
+    while ((c = getopt (argc, argv, "s:f:")) != -1)
     {
        switch (c)
        {
-            case 'r':
-                if(strncmp("yes", optarg,1) == 0)
-                {
-                    use_rm = 1;
-                }
-                break;
-
             case 's':
                 /* check is user input 0 for oseq_offset (valid but also default)*/
                 if(strncmp("0", optarg,1) == 0)
@@ -853,20 +832,19 @@ int32_t main (int argc, char* argv[])
                    "main: oseq_offset: %d, sa_tx_flow: %d\n",
                     globalDB.oseq_offset, globalDB.sa_tx_flow);
 
-    if (use_rm)
+    if (initRm())
     {
-        if (initRm())
-        {
-            exit(EXIT_FAILURE);
-        }
+        printf("main: initRm() returned error\n");
+        exit(1);
     }
+    our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
+
 
     /* assign main net_test thread to run on core 0 */
     CPU_ZERO( &cpu_set);
     CPU_SET( 0, &cpu_set);
     hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
     /* create netapi */
-    our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
     netapi_handle = netapi_init(NETAPI_SYS_MASTER,
                                 &our_netapi_default_cfg);
     if(netapi_handle == NULL)
index ff5e96911fff056b53d235b62a2d47b0ffd7477c..70933a82ea3a8c56bc715cf3a622839c4b93fb73 100755 (executable)
@@ -73,6 +73,7 @@
 #include <ti/drv/cppi/device/k2h/src/cppi_device.c>
 #endif /* Device */
 
+extern Rm_ServiceHandle   *rmClientServiceHandle;
 #define netapi_timing_start hplib_mUtilGetPmuCCNT
 
 static int scnt=0;
@@ -243,7 +244,7 @@ unsigned long t2;
 
     CPU_ZERO( &cpu_set);
     CPU_SET( 2, &cpu_set);
-    hplib_utilSetupThread(2, &cpu_set, hplib_spinLock_Type_LOL);
+    hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
     start_time = hplib_mUtilGetTimestamp();
 
      //DAL we poll the default pktio channel for pkts from net
@@ -301,14 +302,15 @@ int main(int argc, char **argv)
      //install signal handler for ^c
     signal(SIGINT,netTest_utilMySig);
 
-
-
-
-
+        if (initRm())
+    {
+        printf("main: initRm() returned error\n");
+        exit(1);
+    }
 
     CPU_ZERO( &cpu_set);
     CPU_SET( 0, &cpu_set);
-    hplib_utilSetupThread(2, &cpu_set, hplib_spinLock_Type_LOL);
+    hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
 
 
     /*******************************************/
@@ -316,6 +318,7 @@ int main(int argc, char **argv)
     /*******************************************/
 
     /* create netapi */
+    our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
     netapi_handle = netapi_init(NETAPI_SYS_MASTER,
                                 &our_netapi_default_cfg);
     if (netapi_handle == NULL)
index 64767c9543d953db8ffe0210e5a0b2075dd65fec..e94281931f51e262b46d49a22307ff8638fe11e9 100755 (executable)
@@ -135,6 +135,7 @@ NETAPI_SCHED_CONFIG_T our_sched_cfg={
 netTestSA_t sa_info[MAX_SEC_INDEX];
 NETCP_CFG_IPSEC_POLICY_T rx_policy[MAX_SEC_INDEX];
 
+int masterType = NETAPI_SYS_MASTER;
 
 
 
@@ -899,12 +900,12 @@ void setup_netTestDSPFastPath(NETAPI_T handle)
     memset(&dsp_pktio_cfg, 0, sizeof (PKTIO_CFG_T));
     memset(&dsp_classi, 0, sizeof (NETCP_CFG_CLASSIFIER_T));
     memset(&dsp_route, 0, sizeof (NETCP_CFG_ROUTE_T));
-    char dsp_name[32];
+    char dsp_name[PKTIO_MAX_NAME];
     for (i = 0; i < CPU_NUM_REM_FAST_PATH_CORES; i++)
     {
         sprintf(&dsp_name[0],"%s%d","dsp_chan", i);
         dsp_pktio_cfg.flags1 = PKTIO_RX;
-        dsp_pktio_cfg.flags2 = PKTIO_GLOBAL | PKTIO_PKT;
+        dsp_pktio_cfg.flags2 = PKTIO_PKT;
         dsp_pktio_cfg.qnum = TEST_NWAL_BASE_REM_FP_RX_PKT_QUEUE + i;
         dsp_pktio_cfg.max_n = 8;
 
@@ -1069,13 +1070,23 @@ void fast_path_thread(uint32_t index)
     /* open netcp default RX channels*/
     rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
 
+    netcp_rx_cfg.flags2 = PKTIO_PKT;
+
+    if(masterType == NETAPI_SYS_MASTER)
+        netapi_pktioOpen(worker_nh[thread_num], "sysMaster", (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
+
+    else if(masterType == NETAPI_PROC_MASTER)
+        netapi_pktioOpen(worker_nh[thread_num], "procMaster", (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
+
     /* create a pktio channel for specially classified pkts */
     /* open netcp default tx, rx queues for sideband crypto */
     sb_rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
 
     netapi_setCookie(worker_nh[thread_num],(void*)thread_num);
     
-    scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
+    scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],
+                                            &our_sched_cfg,
+                                            &err);
     if (!scheduler[thread_num]) 
         {
         printf("sched create failed for core%d\n",thread_num);
@@ -1111,26 +1122,49 @@ int main(int argc, char **argv)
     int32_t             errCode;
     Pktlib_HeapIfTable*  pPktifTable;
     FILE * fpr = NULL;
+    int c;
 
+    static char usage[] = "usage: %s -f < config File Name> -t <masterType: procMaster or sysMater> >\n";
 #ifdef netTest_MULTI_THREAD
     cpu_set_t cpu_set;
 #endif
      /* install signal handler for ^c */
     signal(SIGINT,netTest_utilMySig);
 
-    if (argc == 2)
-    {
-        printf("main: filename1 %s\n", argv[1]);
-        fpr = fopen(argv[1], "r");
-    }
-    else
-    {
-        fpr = fopen(input_file_name, "r");
-    }
-    if (fpr == NULL)
+    fpr = fopen(input_file_name, "r");
+
+    while ((c = getopt (argc, argv, "f:t:?")) != -1)
     {
-        printf("Cant open config file: filepath %s, %s\n", input_file_name, strerror(errno));
-        exit(1);
+       switch (c)
+       {
+            case 'f':
+                fclose(fpr);
+                fpr = fopen(optarg, "r");
+                printf("main: filename1 %s\n", optarg);
+                break;
+            case 't':
+                if(strcmp("sysMaster", optarg) == 0)
+                {
+                    masterType = NETAPI_SYS_MASTER;
+                }
+                else if (strcmp("procMaster", optarg) == 0)
+                {
+                    masterType = NETAPI_PROC_MASTER;
+                }
+                else
+                {
+                    printf("%s\n", usage);
+                }
+                printf("optionValue %s: %d\n", optarg, masterType);
+                break;
+
+            case '?':
+                printf("optionValue %s: %d\n", optarg, masterType);
+                exit(EXIT_FAILURE);
+                break;
+            default:
+                break;
+        }
     }
 
     if (initRm())
@@ -1178,7 +1212,7 @@ int main(int argc, char **argv)
 
     /* create netapi */
 
-    netapi_handle = netapi_init(NETAPI_SYS_MASTER,
+    netapi_handle = netapi_init(masterType,
                                 &our_netapi_default_cfg);
 
     if (netapi_handle == NULL)
@@ -1233,9 +1267,13 @@ int main(int argc, char **argv)
     }
 
 #ifdef netTest_DSP_FASTPATH
-    setup_netTestDSPFastPath(netapi_handle);
+    if (masterType == NETAPI_SYS_MASTER)
+    {
+        setup_netTestDSPFastPath(netapi_handle);
+    }
 #endif
 
+    netTest_utilCreateDefaultFlow(netapi_handle, masterType);
     /* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
     netTest_utilCreateSecAssoc();
 
index 5ce5f002fed2e371ffa6588057854738beda48c6..746547ce24453730caba659953dd56d1b38a305b 100755 (executable)
@@ -48,6 +48,7 @@
 #include <sys/resource.h>
 #include "router.h"
 extern int QUIT;
+extern Rm_ServiceHandle   *rmClientServiceHandle;
 
 
 #if defined(DEVICE_K2H)
@@ -467,6 +468,11 @@ int main(int argc, char **argv)
     }
     else
     {
+    if (initRm())
+    {
+        printf("main: initRm() returned error\n");
+        exit(1);
+    }
         memset(&config_file, 0, sizeof(netTestConfigFile_t));
         memset(&netTestCfg, 0, sizeof(netTestConfig_t));
         netTest_utilProcessConfigFile(fpr,&config_file);
@@ -502,6 +508,7 @@ int main(int argc, char **argv)
     hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
 #endif
     /* create netapi */
+    our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
     netapi_handle = netapi_init(NETAPI_SYS_MASTER,
                                 &our_netapi_default_cfg);
 
index 1e28ea9bc844c186d81642c9d506940508245e97..12f74d6fd39202a79e958b935d268acfe7e9d0a6 100755 (executable)
@@ -679,6 +679,62 @@ void  netTest_utilBuildSADB(int i)
         netapi_Log("netTest_utilBuildSADB(): invalid encryption/authentication combination selected\n");
 
 }
+NETCP_CFG_ROUTE_T routeInfo;
+PKTIO_HANDLE_T *pPktioHandle;
+
+int netTest_utilCreateDefaultFlow(NETAPI_T handle, int masterType)
+{
+    int err = 0;
+    PKTIO_CFG_T pktio_cfg;
+    Qmss_QueueHnd   qHandle;
+
+    memset(&pktio_cfg, 0, sizeof (PKTIO_CFG_T));
+    memset(&routeInfo, 0, sizeof (NETCP_CFG_ROUTE_T));
+
+    pktio_cfg.flags1 = PKTIO_RX | PKTIO_GLOBAL;
+    pktio_cfg.flags2 = PKTIO_PKT;
+
+    if (nwal_CreateGenPurposeQueue (&qHandle) == nwal_OK)
+    {
+        printf("netTest_utilCreateDefaultFlow: qHandle: 0x%x\n", qHandle);
+        pktio_cfg.qnum = qHandle ;
+        pktio_cfg.max_n = 8;
+    }
+    else
+    {
+        netapi_Log("netTest_utilCreateDefaultFlow:GenPurposeQueue create failure\n");
+        return -1;
+    }
+
+    if(masterType == NETAPI_PROC_MASTER)
+    {
+        pPktioHandle = netapi_pktioCreate(handle,
+                                               "procMaster",
+                                               (PKTIO_CB)recv_cb,
+                                               &pktio_cfg,
+                                               &err);
+    }
+    else if(masterType == NETAPI_SYS_MASTER)
+    {
+        pPktioHandle = netapi_pktioCreate(handle,
+                                               "sysMaster",
+                                               (PKTIO_CB)recv_cb,
+                                               &pktio_cfg,
+                                               &err);
+    }
+    else;
+
+    if (!pPktioHandle)
+    {
+        netapi_Log("netTest_utilCreateDefaultFlow: failed for %d\n", masterType);
+    }
+    routeInfo.p_dest_q = pPktioHandle;
+    
+    routeInfo.p_flow = (NETCP_CFG_FLOW_T*)NETCP_DEFAULT_FLOW;
+    routeInfo.valid_params = NETCP_CFG_VALID_PARAM_ROUTE_TYPE;
+
+    printf("netTest_utilCreateDefaultFlow setup complete\n");
+}
 int netTest_utilCreateSecAssoc(void)
 {
     nwal_RetValue       nwalRetVal;
@@ -698,7 +754,7 @@ int netTest_utilCreateSecAssoc(void)
             &netTestCfg.sa[i],
             &netTestCfg.key_params[i],
             netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND ? NETAPI_SEC_SA_SIDEBAND: NETAPI_SEC_SA_INFLOW,
-                NULL,  //use default route 
+            (NETCP_CFG_ROUTE_HANDLE_T)&routeInfo,
             &(sa_info[i].rx_data_mode_handle),
             &(sa_info[i].rx_inflow_mode_handle),
             (void*) saId,
@@ -719,7 +775,7 @@ int netTest_utilCreateSecAssoc(void)
                              &netTestCfg.sa[i].src,
                              &netTestCfg.sa[i].dst,
                             NULL,  // no qualifiers
-                            NULL,  //default route
+                            (NETCP_CFG_ROUTE_HANDLE_T)&routeInfo,
                             NULL, //user_data
                              &err);
                 if (err)
index e97912a9d2c344bf5c97f128d125fcae6aba0172..4f609848a03e937e1024e17541b57d065e775c2b 100755 (executable)
@@ -208,6 +208,9 @@ void netTest_utilParseSADir(char* dir_str, nwal_SaDir *dir);
 void netTest_utilParseSA(netTestConfigFile_t *pConfig);
 void netTest_utilParseRoutes(netTestConfigFile_t* pConfig, OUR_ROUTE_T* routes, Trie** our_router);
 void netTest_utilProcessConfigFile(FILE* fpr, netTestConfigFile_t* pConfig);
+void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+                         PKTIO_METADATA_T meta[], int n_pkts,
+                         uint64_t ts );
 
 
 #endif