Resolve NETAPI library coverity warnings.
authorTinku Mannan <tmannan@ti.com>
Fri, 18 Jul 2014 18:24:09 +0000 (14:24 -0400)
committerTinku Mannan <tmannan@ti.com>
Fri, 18 Jul 2014 18:24:09 +0000 (14:24 -0400)
28 files changed:
ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell.c
ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_main.c
ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapi_ipsecmgr.c
ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.c
ti/runtime/netapi/netapi_sched.h
ti/runtime/netapi/netapi_sec.h
ti/runtime/netapi/netcp_cfg.h
ti/runtime/netapi/pktio.h
ti/runtime/netapi/src/netapi_init.c
ti/runtime/netapi/src/netapi_loc.h
ti/runtime/netapi/src/netapi_sec.c
ti/runtime/netapi/src/netcp_cfg.c
ti/runtime/netapi/src/pktio.c
ti/runtime/netapi/src/pktio.c~ [new file with mode: 0755]
ti/runtime/netapi/test/ifdma_test.c
ti/runtime/netapi/test/net_test.h
ti/runtime/netapi/test/net_test_bench.c
ti/runtime/netapi/test/net_test_loopback.c
ti/runtime/netapi/test/net_test_max_params.c
ti/runtime/netapi/test/net_test_router.c
ti/runtime/netapi/test/net_test_sa_utils.c
ti/runtime/netapi/test/net_test_sa_utils.h
ti/runtime/netapi/test/net_test_thread_utils.c
ti/runtime/netapi/test/net_test_utils.c
ti/runtime/netapi/test/net_test_utils.h
ti/runtime/netapi/test/router.h
ti/runtime/netapi/utils/netapi_util_rm.c
ti/runtime/netapi/utils/sockutils.c

index 918c549429f41619a96a3f2f8251834ba090382c..e2c31e555ff43a3f2ffa23c49636899587967215 100755 (executable)
 */
 
 /* Standard include files */
+
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <getopt.h>
@@ -105,12 +109,13 @@ static int parse_strval(char* str, opt_attr_gen_t *opt_attr) {
     return 0;
 }
 
-static char short_opts[200];
+#define CMD_SHORT_OPTS_LEN 200
+static char short_opts[CMD_SHORT_OPTS_LEN];
 
 #define CMD_NAME_OFFLOAD_SP   "offload_sp"
 #define CMD_DESC_OFFLOAD_SP   "Offload an IPSec Policy to Fast Path"
 #define CMD_MIN_ARGS_OFFLOAD_SP    3
-#define CMD_SHORT_OPTS_OFFLOAD_SP sprintf(short_opts, "%d:%d:%d%d:%d:",\
+#define CMD_SHORT_OPTS_OFFLOAD_SP snprintf(short_opts,CMD_SHORT_OPTS_LEN, "%d:%d:%d%d:%d:",\
                            OPTION_ID_SP_ID, OPTION_ID_IF_NAME, OPTION_ID_ESN,\
                            OPTION_ID_GTPU_TEID, OPTION_ID_NUM_TEIDS,\
                            OPTION_ID_SHARED_SA);
@@ -129,7 +134,7 @@ static struct option offload_sp_options[] =
 #define CMD_NAME_STOP_OFFLOAD   "stop_offload"
 #define CMD_DESC_STOP_OFFLOAD   "Stop Offload of an IPSec Policy"
 #define CMD_MIN_ARGS_STOP_OFFLOAD   3
-#define CMD_SHORT_OPTS_STOP_OFFLOAD sprintf(short_opts, "%d:", OPTION_ID_SP_ID);
+#define CMD_SHORT_OPTS_STOP_OFFLOAD snprintf(short_opts,CMD_SHORT_OPTS_LEN, "%d:", OPTION_ID_SP_ID);
 static struct option stop_offload_options[] =
 {
     {"sp_id",  required_argument, 0, OPTION_ID_SP_ID},
@@ -139,7 +144,7 @@ static struct option stop_offload_options[] =
 #define CMD_NAME_EXIT   "exit"
 #define CMD_DESC_EXIT   "Exit the netcpcfg command shell"
 #define CMD_MIN_ARGS_EXIT    1
-#define CMD_SHORT_OPTS_EXIT sprintf(short_opts, ""); 
+#define CMD_SHORT_OPTS_EXIT snprintf(short_opts,CMD_SHORT_OPTS_LEN, ""); 
 static struct option exit_options[] =
 {
     {0, 0, 0, 0}
@@ -148,7 +153,7 @@ static struct option exit_options[] =
 #define CMD_NAME_HELP       "help"
 #define CMD_DESC_HELP       "Help on available commands"
 #define CMD_MIN_ARGS_HELP   1
-#define CMD_SHORT_OPTS_HELP sprintf(short_opts, "%d:", OPTION_ID_CMD_NAME); 
+#define CMD_SHORT_OPTS_HELP snprintf(short_opts,CMD_SHORT_OPTS_LEN, "%d:", OPTION_ID_CMD_NAME); 
 static struct option help_options[] =
 {
     {"cmd",  required_argument, 0, OPTION_ID_CMD_NAME},
@@ -230,7 +235,7 @@ static char **parsedargs(char *args, int *argc)
           argn = setargs(args,argv);
     }
 
-    if (args && !argv) free(args);
+    //if (args && !argv) free(args);
 
     *argc = argn;
     return argv;
@@ -251,7 +256,7 @@ void* cmd_shell (void* args)
     char *line = NULL;
     size_t len = 0;
     ssize_t read = 0;
-    char cmd[20];
+    char cmd[COMMAND_LINE_SIZE];
     int nargs, c, rargs;
     struct option *long_options; 
     char **av;
@@ -260,7 +265,7 @@ void* cmd_shell (void* args)
     memset(&shell_ctx, 0, sizeof(shell_ctx));
     if (ipsecmgr_ipc_get_user_send_iface(&shell_ctx.ipc_send_if)) {
         printf ("\ncmd_shell: Failed to get IPC send interface\n");
-        return;
+        return (void*)(0);
     }
 
     while (1) {
@@ -273,11 +278,11 @@ void* cmd_shell (void* args)
         line = malloc(COMMAND_LINE_SIZE);
         if (line == NULL) {
             printf("\nError allocating memory");
-            return;
+            return (void*)(0);
         }
 
         read = getline(&line, &len, stdin);
-        if (read == -1) {
+        if ((read == -1) || (read > COMMAND_LINE_SIZE)) {
             printf("\nERROR: reading line");
             continue;
         }
@@ -310,7 +315,7 @@ void* cmd_shell (void* args)
         }
 
         if ((av = parsedargs(line, &nargs)) == NULL) {
-            printf ("error parsing arguments");
+            printf ("error parsing arguments\n");
             continue;
         }
 
index 0f29763afd8e8feffd531e0f23944e8da41dbe32..d610a639767eab2a9bb2b84c2bdcf641829ebb49 100755 (executable)
@@ -93,14 +93,12 @@ static int task_create ( void *(start_routine)(void*), void* args, void* handle)
             "pthread_attr_setschedparam failed: (%s)\n", strerror(err));
         return err;
     }
-    if (err) return err;
     err = pthread_create(&thread, &attr, start_routine, args);
     if (err) {
         ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
             "pthread_create failed: (%s)\n", strerror(err));
         return err;
     }
-    if (err) return err;
     *(pthread_t*)handle = thread;
     return 0;
 }
index 07ccd673b70aa382fceb7449292c1caca04b9c86..ff1b2eae5d928a1f26cf18b49ee2f2bd4fb9f8de 100755 (executable)
@@ -248,7 +248,7 @@ static void* snoop_run_thread (void* arg)
 
     if (use_rm)
         closeRm();
-    return;
+    return ((void*)NULL);
 }
 
 /**
@@ -648,15 +648,16 @@ static void daemonize (const char *lock_file)
                                 strerror(errno));
             exit (-1);
         }
-    }
-
-    if (lockf (lock_fp, F_TLOCK, 0) < 0) 
-        exit(-1); /* can not lock */
+    
 
-    /* Record pid to lockfile */
-    sprintf (str, "%d\n", getpid());
-    write (lock_fp, str, strlen(str)); 
+        if (lockf (lock_fp, F_TLOCK, 0) < 0) 
+            exit(-1); /* can not lock */
 
+        /* Record pid to lockfile */
+        snprintf (str, 10,"%d\n", getpid());
+        write (lock_fp, str, strlen(str));
+        close(lock_fp);
+    }
     /* Cancel certain signals */
     signal (SIGCHLD, SIG_DFL); /* A child process dies */
     signal (SIGTSTP, SIG_IGN); /* Various TTY signals */
@@ -683,8 +684,10 @@ int get_kernel_config()
 
     if(pDts)
     {
-        fread((void*)&temp, sizeof(uint32_t), 1, pDts);
-        globalDB.qNum = (int)swap32(temp);
+        if(fread((void*)&temp, sizeof(uint32_t), 1, pDts))
+        {
+            globalDB.qNum = (int)swap32(temp);
+        }
         fclose(pDts);
     }
     else
@@ -699,8 +702,10 @@ int get_kernel_config()
 
     if(pDts)
     {
-        fread((void*)&temp, sizeof(uint32_t), 1, pDts);
-        globalDB.flowId = (int)swap32(temp);
+        if (fread((void*)&temp, sizeof(uint32_t), 1, pDts))
+        {
+            globalDB.flowId = (int)swap32(temp);
+        }
         fclose(pDts);
     }
     else
@@ -730,7 +735,7 @@ int create_pktio_channel()
     memset((void *)&route, 0, sizeof (NETCP_CFG_ROUTE_T));
     memset((void *)&flow, 0, sizeof (NETCP_CFG_FLOW_T));
 
-    sprintf(&name[0],"%s","offload_0");
+    snprintf(&name[0],PKTIO_MAX_NAME, "%s","offload_0");
     pktio_cfg.qnum = globalDB.qNum;
     pktio_cfg.flags1 = PKTIO_RX;
     pktio_cfg.flags2 = PKTIO_GLOBAL | PKTIO_PKT;
index 37259234211abd5a805d38865451b01174bfa359..4af466e695e2b28427f2c7cc2200d011141ac40f 100755 (executable)
@@ -60,7 +60,6 @@ int findFreeAppIdSlot(ipsecMgrAppId_T *pList)
     {                       
         if (!pList[i].in_use)
         {
-            if (free)
             pList[i].in_use = 1; //pending
             return i;
         }
@@ -75,14 +74,14 @@ int findFreeAppIdSlot(ipsecMgrAppId_T *pList)
  * DESCRIPTION:  Internal function to find a SA app id  in SA list
  *                    and free SA Slot entry if specified
  ********************************************************************/
-int findAppIdSlot(ipsecMgrAppId_T *pList, uint32_t saAppId, int free)
+int findAppIdSlot(ipsecMgrAppId_T *pList, uint32_t saAppId, int freeSlot)
 {
     int i;
     for(i=0;i<64;i++)
     {                       
         if ((pList[i].in_use) && (pList[i].saAppId == saAppId))
         {
-            if(free)
+            if(freeSlot)
                 pList[i].in_use = 0;
             return i;
         }
@@ -348,7 +347,8 @@ int netapilib_ifAddSA
  ********************************************************************/
 int netapilib_ifDeleteSA (ipsecmgr_fp_handle_t sa_handle)
 {
-    int error, slot;
+    int error = 0;
+    int slot = 0;
 
     slot = findAppIdSlot(&globalDB.rx_sa[0],sa_handle, 1);
 
@@ -568,14 +568,15 @@ int netapilib_ifGetSACtx
     ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,"netapilib_ifGetSACtx: called\n");
 
 
-    netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context,
+    if(netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context,
                                     (NETCP_CFG_SA_T) sa_handle,
                                     &swInfo0,
-                                    &swInfo1);
-
+                                    &swInfo1))
+    {
+        hw_ctx->swinfo[0] = swInfo0;
+        hw_ctx->swinfo[1] = swInfo1;
+    }
     hw_ctx->swinfo_sz = 2;
-    hw_ctx->swinfo[0] = swInfo0;
-    hw_ctx->swinfo[1] = swInfo1;
 
  
     if(globalDB.sa_tx_flow == -1)
index 1fa1bd9a4c19059697d827e0ee65f30b57d53e3c..a42a09f133fae3f1f6ced010d7e08b3d453c60ab 100755 (executable)
 extern "C" {
 #endif
 
-#include "netapi.h"
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "ti/csl/tistdtypes.h"
+#include "netapi_types.h"
+#include "ti/runtime/netapi/src/netapi_loc.h"
+
+//#include "netapi.h"
 
 /**
  * @brief This defines the handle to the NETAPI scheduling context.
index bdd5c49f88b306ba56dfcc053663eef20e9f3853..600404292370c6441dc4ff669f068a43a86b4c77 100755 (executable)
@@ -54,7 +54,7 @@ extern "C" {
 #endif
 
 
-#include "netapi.h"
+#include "netcp_cfg.h"
 #include "ti/drv/nwal/nwal.h"
 #include <ti/drv/sa/salld.h>
 
index 9115f3ad51a25ecc252e59a8ebd61b0632c53395..c6b8f140871595fe6fc4f949dd0e4c4bbfae5144 100755 (executable)
@@ -54,7 +54,7 @@
 extern "C" {
 #endif
 
-#include "netapi.h"
+//#include "netapi.h"
 
 /**
  *  @ingroup cfg_structures
index 7302b61bf34beb8e52d8a36ff208a5fef18c4f8e..f58ec8723701511d50e6f3181167809caad1fc00 100755 (executable)
@@ -57,7 +57,7 @@ extern "C" {
 #endif
 
 
-#include "netapi.h"
+//#include "netapi.h"
 #include "ti/drv/nwal/nwal.h"
 #include "ti/drv/nwal/nwal_util.h"
 
index 12d7cf70c4713233e8db78a72dcab19eae5df650..ffc828e1dc0bb7f5ca8f25a3b8d50f5dcf74ff10 100755 (executable)
@@ -271,7 +271,7 @@ int netapip_initNwal(
     int             aligns[nwal_N_BUFS];
     void*           bases[nwal_N_BUFS];   
     Pktlib_HeapCfg      heapCfg;
-    int32_t             errCode;
+    int32_t             errCode = 0;
     void* pBase = NULL;
     NETAPI_PA_SHM_T* paEntry = NULL;
     NETAPI_SA_SHM_T* saEntry = NULL;
@@ -494,12 +494,6 @@ int netapip_initNwal(
     bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] = 0;
     count = count+3;
 #endif
-    if(count != nwal_N_BUFS)
-    {
-        printf("count failure: %d\n", count);
-        return nwal_FALSE;
-        //while(1);
-    }
 
     /* Initialize NWAL module */
     nwalRetVal = nwal_create(&nwalGlobCfg,
@@ -604,6 +598,8 @@ int netapip_initTimer(void)
 {
 #ifdef CORTEX_A8
         return t64_start();
+#else
+    return 0;
 #endif
 }
 
@@ -677,7 +673,7 @@ int netapip_systemInit(NETAPI_HANDLE_T * handle,
     Pktlib_HeapHandle   sharedHeapHandle;
     Pktlib_HeapHandle   controlRxHeapHandle,controlTxHeapHandle;    
     Pktlib_HeapCfg      heapCfg;
-    int32_t             errCode;
+    int32_t             errCode = 0;
     int count=0;
 
 #ifdef NETAPI_USE_DDR
@@ -749,7 +745,7 @@ int netapip_systemInit(NETAPI_HANDLE_T * handle,
         netapi_pktlib_ifTable.data_malloc  = netapip_sharedMemoryMalloc;
         netapi_pktlib_ifTable.data_free    = netapip_sharedMemoryFree;
         sharedHeapHandle = Pktlib_findHeapByName("netapi");
-        if (!sharedHeapHandle) { netapi_Log(">'netapi' heap create failed, Error Code: %d\n",errCode); return -1;}
+        if (!sharedHeapHandle) { netapi_Log(">'netapi' Pktlib_findHeapByName failed\n");return -1;}
         handle->netcp_heap= sharedHeapHandle;
 
         /* Update for Control */
@@ -950,7 +946,6 @@ int netapip_systemInit(NETAPI_HANDLE_T * handle,
  ***************************************************************************/
 void netapip_zapQ(int queueNum)
 {
-    char * descPtr;
     int i;
     if (!queueNum) 
     {
@@ -959,15 +954,11 @@ void netapip_zapQ(int queueNum)
     for (i=0;;i+=1 )
     {
         /* Pop descriptor from source queue */
-        if ((descPtr = (char *)pktio_mQmssQueuePopRaw(queueNum)) == NULL)
+        if (pktio_mQmssQueuePopRaw(queueNum) == NULL)
         {
             break;
         }
     }
-    if(i)
-    {
-        netapi_Log("netapip_zapQ: @recovery -  %d descriptors cleaned from qn %d\n",i, queueNum);
-    }
 }
 
 
index 1be8cd4aa898545009de7708634961a18294e02e..99b7e525e6ae93c7ee878ae1fb89858d0078b3ae 100755 (executable)
@@ -13,10 +13,11 @@ extern "C" {
 
 
 #include "ti/drv/nwal/nwal_util.h"
-#include "ti/runtime/netapi/pktio.h"
 #include "ti/drv/nwal/nwal.h"
-#include "ti/drv/nwal/nwal_util.h"
 #include "ti/runtime/hplib/hplib.h"
+#include "ti/runtime/netapi/pktio.h"
+#include "ti/runtime/netapi/netcp_cfg.h"
+#include "ti/runtime/netapi/netapi_tune.h"
 
 
 extern hplib_virtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
@@ -331,7 +332,7 @@ int i;
 //find a free slot
 pe = &((NETAPI_GLOBAL_T *)(pp->global))->pktios[0];
 
-for(i=0;i<NETAPI_MAX_PKTIO; i++,pe++)
+    for(i=0;i<NETAPI_MAX_PKTIO; i++)
  {
    if (pe->qn.qNum ==  -1)
    {
@@ -354,7 +355,7 @@ int i;
 //find slot
 pe = &((NETAPI_GLOBAL_T *)(pp->global))->pktios[0];
 
-for(i=0;i<NETAPI_MAX_PKTIO; i++,pe++)
+for(i=0;i<NETAPI_MAX_PKTIO; i++)
  {
    if (pe->qn.qNum == -1) continue;
    if (!strncmp(name, pe->name, PKTIO_MAX_NAME))
@@ -378,7 +379,7 @@ int i;
 //find slot
 pe = &((NETAPI_GLOBAL_T *)(pp->global))->pktios[0];
 
-for(i=0;i<NETAPI_MAX_PKTIO; i++,pe++)
+for(i=0;i<NETAPI_MAX_PKTIO; i++)
  {
    if (pe->qn.qNum  == -1) continue;
    if (!strncmp(name, pe->name, PKTIO_MAX_NAME))
index 5967591205d22e798f69551183a93d351cd48079..efcc884fab04c61b6842aa1d0d99d19226684efe 100755 (executable)
@@ -40,7 +40,7 @@
  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *****************************************************************************/
 
-#include "netapi_sec.h"
+#include "netapi.h"
 
 /********************************************************************
  * FUNCTION PURPOSE:  API to add an IPSEC SA
@@ -68,8 +68,8 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
     int have_to_wait=1;
     nwalTxDmPSCmdInfo_t     dmPSCmdInfo;
     nwalSaIpSecId_t nwalSaIpSecId;
-    uint32_t    swInfo0;
-    uint32_t    swInfo1;
+    uint32_t    swInfo0 = 0;
+    uint32_t    swInfo1 = 0;
 
     nwalCreateSAParams_t    createParam =
     {
index fa98dbdeed384cfc0b103936596d319ae27fcfaf..55a75bf28eee5f931a9f6257c90be5e958e5cc6f 100755 (executable)
@@ -490,7 +490,7 @@ static void netapip_netcpCfgDeleteIp(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
                                      int iface_no,
                                      int ip_slot)
 {
-    if ((ip_slot >=0) &&(ip_slot <=TUNE_NETAPI_MAX_NUM_IP))
+    if ((ip_slot >=0) &&(ip_slot < TUNE_NETAPI_MAX_NUM_IP))
     {
         p->ips[ip_slot].in_use=0;
     }
@@ -1575,8 +1575,8 @@ void netapi_netcpCfgDelClass(NETAPI_T           h,
                              int*               err)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
-    void * L4_handle;  //class handle -> L4
-    void * L3_handle;  //class handle -> L3
+    void *L4_handle = NULL;  //class handle -> L4
+    void *L3_handle = NULL;  //class handle -> L3
     nwal_RetValue       retValue;
     NetapiNwalTransInfo_t *pTransInfo;
     nwal_TransID_t     trans_id;
@@ -1833,13 +1833,11 @@ void netapi_netcpCfgDelFlow(NETAPI_T                h,
         *err = NETAPI_ERR_BAD_INPUT;
         return;
     }
-
-    Cppi_closeRxFlow( (Cppi_FlowHnd) handle);
-    netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context,
+    if ((Cppi_closeRxFlow( (Cppi_FlowHnd) handle)) == 0)
+    {
+        netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context,
                                slot);
-    netapi_Log(">netcp cfg:  flow %d (dma index %d) deleted\n",
-                ((NETCP_CFG_FLOW_T *) f)->flowid,
-                ((NETCP_CFG_FLOW_T *) f)->dma_engine);
+    }
     return;
 }
 
index fc1f9f78dc0ec04e4447178358b29565d5c7dbf9..08a55d107808b580de1b310c6d9fef7c8a9df041 100755 (executable)
@@ -367,6 +367,7 @@ static int netapip_pktioSendL4CkSumPort(struct PKTIO_HANDLE_tag * pp,
     Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
                                   pPloadDesc,
                                   NWAL_DESC_SIZE);
+    return 1;
 }
 
 
@@ -441,161 +442,7 @@ static int netapip_pktioSendNwal(struct PKTIO_HANDLE_tag * pp,
 }
 
 
-static void  PKTIO_dump_buf_32bit
-(
-    uint8_t*                      buf,
-    uint32_t                      buf_length
-)
-{
-    uint8_t                       count = 0;
-    uint16_t                      dump_size;
-    uint32_t*                     tmp_buf;
-    uint8_t                       row_count;
-
-    dump_size = buf_length/4 ;
-
-    tmp_buf = (uint32_t *)(buf);
-
-    printf("pktio *:  - 32 bit word hex Length: %d Start \n",buf_length);
-    do
-    {
-        row_count = (dump_size - count);
-
-        if(row_count == 0)
-        {
-            break;
-        }
-
-        if(row_count > 4)
-        {
-            row_count = 4;
-        }
-
-        switch (row_count)
-        {
-            case 4:
-            {
-                printf("pktio *:%02d : %08x    %08x    %08x    %08x \n",
-                      count,tmp_buf[0],tmp_buf[1],tmp_buf[2],tmp_buf[3]);
-                break;
-            }
-            case 3:
-            {
-                printf("pktio *: %02d : %08x    %08x    %08x \n",
-                      count,tmp_buf[0],tmp_buf[1],tmp_buf[2]);
-                break;
-            }
-
-            case 2:
-            {
-                printf("pktio *: %02d : %08x    %08x \n",
-                      count,tmp_buf[0],tmp_buf[1]);
-                break;
-            }
-
-            case 1:
-            {
-                printf("pktio *: %02d : %08x \n",
-                      count,tmp_buf[0]);
-                break;
-            }
-
-            default:
-            {
-                /* Should never reach here */
-                printf("pktio *: Internal Error in nwal_dump_buf_32bit().Row Count: %d \n",
-                    row_count);
-                return;
-            }
-        }
-
-        tmp_buf = tmp_buf + row_count;
-        count = count +  row_count;
-
-    }while(count < dump_size);
-
-    printf("NWAL *:  - Byte hex Dump End \n");
-
-}
-
-
-static void  PKTIO_dump_buf
-(
-    uint8_t*                      buf,
-    uint32_t                      buf_length
-)
-{
-    uint8_t                       count = 0;
-    uint16_t                      dump_size;
-    uint8_t*                     tmp_buf;
-    uint8_t                       row_count;
-
-
-    dump_size = buf_length ;
-
-    tmp_buf = (uint8_t *)(buf);
-
-    printf("PKTIO *:  - 8 bit word hex Length: %d Start \n",buf_length);
-    do
-    {
-        row_count = (dump_size - count);
-
-        if(row_count == 0)
-        {
-            break;
-        }
-
-        if(row_count > 4)
-        {
-            row_count = 4;
-        }
-
-        switch (row_count)
-        {
-            case 4:
-            {
-                printf("PKTIO *:%02d : %02x    %02x    %02x    %02x \n",
-                      count,tmp_buf[0],tmp_buf[1],tmp_buf[2],tmp_buf[3]);
-                break;
-            }
-            case 3:
-            {
-                printf("PKTIO *: %02d : %02x    %02x    %02x \n",
-                      count,tmp_buf[0],tmp_buf[1],tmp_buf[2]);
-                break;
-            }
 
-            case 2:
-            {
-                printf("PKTIO *: %02d : %02x    %02x \n",
-                      count,tmp_buf[0],tmp_buf[1]);
-                break;
-            }
-
-            case 1:
-            {
-                printf("PKTIO *: %02d : %02x \n",
-                      count,tmp_buf[0]);
-                break;
-            }
-
-            default:
-            {
-                /* Should never reach here */
-                printf("PKTIO *: Internal Error in PKTIO_dump_buf().Row Count: %d \n",
-                    row_count);
-                return;
-            }
-        }
-
-        tmp_buf = tmp_buf + row_count;
-        count = count +  row_count;
-
-    }while(count < dump_size);
-
-    printf("PKTIO *:  - Byte hex Dump End \n");
-
-}
 
 /********************************************************************
  * FUNCTION PURPOSE: Send packet to SA via NWAL
@@ -877,6 +724,11 @@ PKTIO_HANDLE_T * netapi_pktioCreate(NETAPI_T n,
 
     int qtype = Qmss_QueueType_GENERAL_PURPOSE_QUEUE;
 
+    if(p_cfg == NULL)
+    {
+        *err = NETAPI_ERR_BAD_INPUT;
+        return NULL;
+    }
     /* over-ride only for Qmss_QueueType_GIC400_QUEUE */
     if (p_cfg->queueType == Qmss_QueueType_GIC400_QUEUE)
         qtype = p_cfg->queueType;
diff --git a/ti/runtime/netapi/src/pktio.c~ b/ti/runtime/netapi/src/pktio.c~
new file mode 100755 (executable)
index 0000000..6b69469
--- /dev/null
@@ -0,0 +1,1323 @@
+/*********************************
+ * FILE: pktio.c
+ * PURPOSE: pktio library for NETAPI
+ **************************************************************
+ * FILE:  pktio.c
+ * 
+ * DESCRIPTION:  pktio source file for user space transport
+ *               library
+ * 
+ * REVISION HISTORY:  rev 0.0.1 
+ *
+ *  Copyright (c) Texas Instruments Incorporated 2010-2011
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ ********************************/
+
+#include <unistd.h>
+#include "netapi.h"
+#include "pktio.h"
+#include <ti/csl/csl_qm_queue.h>
+
+
+
+/*This defines the maximum number of packets to receive in one pktio poll */
+#define PKTIO_MAX_RECV  (TUNE_NETAPI_MAX_BURST_RCV)
+
+extern NETAPI_SHM_T* pnetapiShm;
+
+
+/* Utilites*/
+static PKTIO_HANDLE_T * netapip_pktioGetFreeChannelSlot(NETAPI_T n)
+{
+    NETAPI_HANDLE_T *p_handle;
+    PKTIO_HANDLE_T ** pp = (PKTIO_HANDLE_T **) netapi_get_pktio_list(n);
+    int i;
+    p_handle = (NETAPI_HANDLE_T*) n;
+    p_handle->spinLock.lock(&pnetapiShm->netapi_pktio_lock);
+    for(i=0;i<NETAPI_MAX_PKTIO;i++)
+    {
+        if (pp[i]->inuse != PKTIO_INUSE)
+        {
+            pp[i]->inuse = PKTIO_INUSE;
+            p_handle->spinLock.unlock(&pnetapiShm->netapi_pktio_lock);
+            return  pp[i];
+        }
+    }
+    p_handle->spinLock.unlock(&pnetapiShm->netapi_pktio_lock);
+    return NULL;
+}
+
+
+/*Optimized send functions */
+
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for L4 checksum,ESP Crypto and outgoing EMAC port 
+ * to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for L4 checksum,ESP Crypto and outgoing EMAC port 
+ * to NetCP command.
+ ********************************************************************/
+static int netapip_pktioSendL4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                            Ti_Pkt *pkt,
+                                            PKTIO_METADATA_T *m,
+                                            int * err)
+{
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+    Cppi_HostDesc*          pPloadDesc;
+    uint32_t swInfo0, swInfo1;
+
+    NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+    //printf("netapip_pktioSendL4CkSumCryptPort\n");
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    {
+        nwal_mCmdSetL4CkSumCrypPort(pkt,
+                                    &p->tx_psCmdInfo,
+                                    pTxPktInfo->l4OffBytes, 
+                                    pTxPktInfo->ploadLen + pTxPktInfo->l4HdrLen, 
+                                    pTxPktInfo->pseudoHdrChecksum, 
+                                    pTxPktInfo->saOffBytes, 
+                                    pTxPktInfo->saPayloadLen, 
+                                    swInfo0, 
+                                    swInfo1,
+                                    pTxPktInfo->enetPort);
+
+        pPloadDesc = Pktlib_getDescFromPacket(pkt);
+        pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
+        Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+                                  pPloadDesc,
+                                  NWAL_DESC_SIZE);
+    }
+    else
+    {
+          *err=NETAPI_ERR_BAD_INPUT;
+          return -1;
+    }
+
+    return 1;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for ESP Crypto and outgoing EMAC port 
+ * to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for ESP Crypto and outgoing EMAC port 
+ * to NetCP command.
+ ********************************************************************/
+static int netapip_pktioSendCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                     Ti_Pkt *pkt,
+                                     PKTIO_METADATA_T *m,
+                                     int * err)
+{
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+    Cppi_HostDesc*          pPloadDesc;
+    uint32_t swInfo0, swInfo1;
+
+    printf("netapip_pktioSendCryptPort\n");
+
+    NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    {
+        nwal_mCmdSetCrypPort(pkt,
+                             &p->tx_psCmdInfo,
+                              pTxPktInfo->saOffBytes,
+                              pTxPktInfo->saPayloadLen,
+                              swInfo0,
+                              swInfo1,
+                              pTxPktInfo->enetPort);
+
+        pPloadDesc = Pktlib_getDescFromPacket(pkt);
+        pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
+        Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+                                  pPloadDesc,
+                                  NWAL_DESC_SIZE);
+    }
+    else
+    {
+          *err=NETAPI_ERR_BAD_INPUT;
+          return -1;
+    }
+
+    return 1;
+}
+
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for L3 checksum, ESP Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for L3 checksum, ESP Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************/
+static int netapip_pktioSendL3CkSumCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                     Ti_Pkt *pkt,
+                                     PKTIO_METADATA_T *m,
+                                     int * err)
+{
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+    Cppi_HostDesc*          pPloadDesc;
+    uint32_t swInfo0, swInfo1;
+
+    NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+    printf("netapip_pktioSendL3CkSumCryptPort\n");
+
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    {
+        nwal_mCmdSetL3CkSumCrypPort(pkt,
+                                    &p->tx_psCmdInfo,
+                                    pTxPktInfo->saOffBytes,
+                                    pTxPktInfo->saPayloadLen,
+                                    swInfo0,
+                                    swInfo1,
+                                    pTxPktInfo->enetPort);
+
+        pPloadDesc = Pktlib_getDescFromPacket(pkt);
+        pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
+
+        Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+                                  pPloadDesc,
+                                  NWAL_DESC_SIZE);
+    }
+    else
+    {
+          *err=NETAPI_ERR_BAD_INPUT;
+          return -1;
+    }
+
+    return 1;
+}
+
+
+
+
+
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for L4 checksum,AH Crypto and outgoing EMAC port 
+ * to NetCP command.
+ *******************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for L4 checksum,AH Crypto and outgoing EMAC port 
+ * to NetCP command.
+ ********************************************************************/
+static int netapip_pktioSendL4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                              Ti_Pkt *pkt,
+                                              PKTIO_METADATA_T *m,
+                                              int * err)
+{
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+    Cppi_HostDesc*          pPloadDesc;
+    uint32_t swInfo0, swInfo1;
+
+    NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+    printf("netapip_pktioSendL4CkSumAHCryptPort\n");
+
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    {
+        nwal_mCmdSetL4CkSumAHCrypPort(pkt,
+                                &p->tx_psCmdInfo,
+                                pTxPktInfo->l4OffBytes, 
+                                pTxPktInfo->ploadLen + pTxPktInfo->l4HdrLen, 
+                                pTxPktInfo->pseudoHdrChecksum, 
+                                pTxPktInfo->saOffBytes, 
+                                pTxPktInfo->saPayloadLen, 
+                                swInfo0, 
+                                swInfo1,
+                                pTxPktInfo->saAhIcvOffBytes,
+                                pTxPktInfo->saAhMacSize,
+                                pTxPktInfo->enetPort);
+
+        pPloadDesc = Pktlib_getDescFromPacket(pkt);
+        pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
+
+        Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+                                  pPloadDesc,
+                                  NWAL_DESC_SIZE);
+    }
+    else
+    {
+          *err=NETAPI_ERR_BAD_INPUT;
+          return -1;
+    }
+
+    return 1;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for AH Crypto and outgoing EMAC port 
+ * to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for AH Crypto and outgoing EMAC port 
+ * to NetCP command.
+ ********************************************************************/
+static int netapip_pktioSendAHCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                       Ti_Pkt *pkt,
+                                       PKTIO_METADATA_T *m,
+                                       int * err)
+{
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+    Cppi_HostDesc*          pPloadDesc;
+    uint32_t swInfo0, swInfo1;
+
+    printf("netapip_pktioSendAHCryptPort\n");
+
+    NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    {
+        nwal_mCmdSetAHCrypPort(pkt,
+                               &p->tx_psCmdInfo,
+                               pTxPktInfo->saOffBytes, 
+                               pTxPktInfo->saPayloadLen, 
+                               swInfo0, 
+                               swInfo1,
+                               pTxPktInfo->saAhIcvOffBytes,
+                               pTxPktInfo->saAhMacSize,
+                               pTxPktInfo->enetPort);
+        
+        pPloadDesc = Pktlib_getDescFromPacket(pkt);
+        pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
+
+        Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+                                  pPloadDesc,
+                                  NWAL_DESC_SIZE);
+    }
+    else
+    {
+       *err= NETAPI_ERR_BAD_INPUT;
+       return -1;
+    }
+    return NETAPI_TRUE;
+}
+
+
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for L4 checksum and outgoing EMAC port 
+ * to NetCP command.
+ *******************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for L4 checksum and outgoing EMAC port 
+ * to NetCP command.
+ ********************************************************************/
+static int netapip_pktioSendL4CkSumPort(struct PKTIO_HANDLE_tag * pp,
+                                      Ti_Pkt *pkt,
+                                      PKTIO_METADATA_T *m,
+                                      int * err)
+{
+
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+    Cppi_HostDesc*          pPloadDesc;
+
+    nwal_mCmdSetL4CkSumPort(pkt,
+                            &p->tx_psCmdInfo,
+                            pTxPktInfo->l4OffBytes,
+                            pTxPktInfo->l4HdrLen + pTxPktInfo->ploadLen,
+                            pTxPktInfo->pseudoHdrChecksum,
+                            pTxPktInfo->enetPort);
+
+    pPloadDesc = Pktlib_getDescFromPacket(pkt);
+    pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
+    Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+                                  pPloadDesc,
+                                  NWAL_DESC_SIZE);
+    return NETAPI_TRUE;
+}
+
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for outgoing EMAC port to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for outgoing EMAC port to NetCP command.
+ ********************************************************************/
+static int netapip_pktioSendPort(struct PKTIO_HANDLE_tag * pp,
+                                Ti_Pkt *pkt, 
+                                PKTIO_METADATA_T *m, 
+                                int * err)
+{
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+    Cppi_HostDesc*          pPloadDesc;
+    
+    printf("netapip_pktioSendPort\n");
+
+
+    nwal_mCmdSetPort(pkt,
+                     &p->tx_psCmdInfo,
+                     pTxPktInfo->enetPort);
+    pPloadDesc = Pktlib_getDescFromPacket(pkt);
+    pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
+
+    Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+                                  pPloadDesc,
+                                  NWAL_DESC_SIZE);
+    return NETAPI_TRUE;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via IPC queue
+ ********************************************************************
+ * DESCRIPTION: Send packet via IPC queue
+ ********************************************************************/
+static int netapip_pktioSendIpc(struct PKTIO_HANDLE_tag * pp,
+                               Ti_Pkt *pkt,
+                               PKTIO_METADATA_T *m,
+                               int * err)
+{
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    err=0;
+    Qmss_queuePushDesc (p->q, (void*)pkt);
+    return 1;
+}
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet to NETCP via NWAL
+ ********************************************************************
+ * DESCRIPTION: Send packet to NETCP via NWAL
+ ********************************************************************/
+static int netapip_pktioSendNwal(struct PKTIO_HANDLE_tag * pp,
+                                Ti_Pkt *pkt,
+                                PKTIO_METADATA_T *m,
+                                int * err)
+{
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalTxPktInfo_t * pPktInfo=m->u.tx_meta;
+    nwal_RetValue res;
+    *err=0;
+    pPktInfo->pPkt = pkt;
+    res=nwal_send(p->nwalInstanceHandle, m->sa_handle,pPktInfo);
+    if (res != nwal_OK)
+    {
+        *err = NETAPI_ERR_NWAL_TX_ERR -res;
+       return -1;
+    }
+    return 1;
+}
+
+
+
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet to SA via NWAL
+ ********************************************************************
+ * DESCRIPTION: Send packet to NETCP via NWAL for side band data mode 
+ * channel via NWAL
+ ********************************************************************/
+static int netapip_pktioSendSb(struct PKTIO_HANDLE_tag * pp,
+                              Ti_Pkt *pkt, 
+                              PKTIO_METADATA_T *m, 
+                              int * err)
+{
+
+    nwal_RetValue nwalRetVal;
+    nwalTxDmPSCmdInfo_t     *dmPSCmdInfo;
+    nwalLocCxtInfo_t    nwalLocCxt;
+    Cppi_HostDesc*          pPloadDesc;
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalLocCxtInfo_t      info;
+    void* virtAddr = NULL;
+    nwalDmTxPayloadInfo_t *pPktInfoSB =  m->u.tx_sb_meta;
+
+    NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+    dmPSCmdInfo = netapip_netcpCfgGetSaSBInfo(&netapi_get_global()->nwal_context, tunnel_id);
+    if (dmPSCmdInfo)
+    {
+        nwalRetVal = nwal_getLocCxtInfo(pktio_mGetNwalInstance(p),&info);
+        if(nwalRetVal == nwal_OK)
+        {
+            dmPSCmdInfo->rxSbSaQ = info.rxSbSaQ;
+        }
+        else
+        {
+            *err=NETAPI_ERR_BAD_INPUT;
+            return -1;
+        }
+        nwal_mCmdDMUpdate(pkt,
+            dmPSCmdInfo,
+            pPktInfoSB->appCtxId,
+            pPktInfoSB->encOffset,
+            pPktInfoSB->encSize,
+            pPktInfoSB->pEncIV,
+            pPktInfoSB->authOffset,
+            pPktInfoSB->authSize,
+            pPktInfoSB->pAuthIV,
+            pPktInfoSB->aadSize,
+            pPktInfoSB->pAad);
+        pPloadDesc = Pktlib_getDescFromPacket(pkt);
+
+#if 0
+        printf("netapip_pktioSendSb: dumping descriptor begin\n");
+        PKTIO_dump_buf_32bit(pPloadDesc, 128);
+        printf("netapip_pktioSendSb: dumping descriptor end\n");
+        
+                virtAddr= hplib_mVMPhyToVirt(pPloadDesc->softwareInfo1);
+
+                printf("phy Addr: 0x%x\n", pPloadDesc->softwareInfo1);
+                printf("virtAddr: 0x%x\n", virtAddr);
+
+                printf("netapip_pktioSendSb: dumping security context begin\n");
+                PKTIO_dump_buf((uint8_t*)virtAddr, 128);
+                PKTIO_dump_buf((uint8_t*)virtAddr+128, 128);
+                printf("netapip_pktioSendSb: dumping security context end\n");
+#endif
+
+
+        pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
+
+        Qmss_queuePushDescSizeRaw(dmPSCmdInfo->txQueue,
+                                             pPloadDesc,
+                                             NWAL_DESC_SIZE); 
+    }
+    else
+    {
+          *err=NETAPI_ERR_BAD_INPUT;
+          return -1;
+    }
+
+    return 1;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via infrastructure DMA channel
+ ********************************************************************
+ * DESCRIPTION: Send packet via infrastructure DMA channel
+ ********************************************************************/
+static int netapip_pktioSendIfdma(struct PKTIO_HANDLE_tag * pp,
+                                 Ti_Pkt *pkt, 
+                                 PKTIO_METADATA_T *m, 
+                                 int * err)
+{
+        Cppi_DescTag            tag={0};
+        Cppi_HostDesc*          pPloadDesc;
+        PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+        *err=0;
+        tag.srcTagLo = m->u.tx_ifdma_dest;
+        Cppi_setTag (Cppi_DescType_HOST, (Cppi_Desc *)pkt, &tag);
+        pPloadDesc = Pktlib_getDescFromPacket(pkt);
+        pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
+
+        Qmss_queuePushDescSizeRaw(p->q,
+                                  pPloadDesc,
+                                  NWAL_DESC_SIZE);
+        return 1;
+}
+
+
+
+/********************************************************************
+ * FUNCTION PURPOSE: Stub function for send, do nothing.
+ ********************************************************************
+ * DESCRIPTION: Stub function for send, do nothing.
+ ********************************************************************/
+static int netapip_pktioSendDummy(struct PKTIO_HANDLE_tag * p,
+                                 Ti_Pkt *pkt, 
+                                 PKTIO_METADATA_T *m, 
+                                 int * err)
+{
+    *err =  NETAPI_ERR_BAD_INPUT;
+    return -1;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Stub function for poll, do nothing.
+ ********************************************************************
+ * DESCRIPTION: Stub function for send, do nothing.
+ ********************************************************************/
+static int netapip_pktioPollDummy(struct PKTIO_HANDLE_tag * p, 
+                                 PKTIO_POLL_T * p_poll_cfg,
+                                 int * err)
+{
+    *err= NETAPI_ERR_BAD_INPUT;
+    return 0;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Poll IPC queue
+ ********************************************************************
+ * DESCRIPTION: Poll IPC queue
+ ********************************************************************/
+static int netapip_pktioPollIpc(struct PKTIO_HANDLE_tag * pp, 
+                               PKTIO_POLL_T * p_poll_cfg,  
+                               int * err)
+{
+    Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
+    PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    int r=0;
+    int n;
+    Ti_Pkt * temp;
+    *err=0;
+    n= (p->max_n< PKTIO_MAX_RECV) ? p->max_n : PKTIO_MAX_RECV;
+    for(r=0;r<n;r++)
+    {
+
+        temp=(Ti_Pkt*)(Cppi_HostDesc*)QMSS_DESC_PTR(Qmss_queuePop(p->q));
+
+        if(!temp) break;
+        /* process meta data */
+        pkt_list[r]= temp;
+        meta_s[r].flags1=0x1;
+    }
+    if (r)
+    {
+        p->cb((struct PKTIO_HANDLE_tag *)p, pkt_list, &meta_s[0], r, 0LL);
+    }
+    return r;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Poll nwal data queues for pkts from netcp
+ ********************************************************************
+ * DESCRIPTION: Poll nwal data queues for pkts from netcp
+ ********************************************************************/
+static int netapip_pktioPollNwal(struct PKTIO_HANDLE_tag * pp, 
+                                PKTIO_POLL_T * p_poll_cfg,  
+                                int * err)
+{
+    int r=0;
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    *err=0;
+    /* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
+        set.  optimizaion maybe? */
+    r=nwal_pollPkt(p->nwalInstanceHandle,
+                   p->poll_flags,
+                   (uint32_t) p,
+                   p->max_n,
+                   QMSS_PARAM_NOT_SPECIFIED,
+                   (void*) NULL);
+    return r;
+}
+/********************************************************************
+ * FUNCTION PURPOSE: Poll nwal sideband queues for pkts from SA
+ ********************************************************************
+ * DESCRIPTION: Poll nwal sideband queues for pkts from SA
+ ********************************************************************/
+static int  netapip_pktioPollSb(struct PKTIO_HANDLE_tag * pp, 
+                               PKTIO_POLL_T * p_poll_cfg,  
+                               int * err)
+{
+    int r=0;
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    *err=0;
+    r=nwal_pollDm(p->nwalInstanceHandle,
+                    nwal_POLL_DM_DEF_SB_SA_Q,
+                     (uint32_t) p,
+                     p->max_n,
+                     QMSS_PARAM_NOT_SPECIFIED,
+             (void *) NULL);
+    return r;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Poll application provided NETCP RX queue
+ ********************************************************************
+ * DESCRIPTION: Poll application provided NETCP RX queue
+ ********************************************************************/
+static int netapip_pktioPollNwalAdj(struct PKTIO_HANDLE_tag * pp, 
+                                   PKTIO_POLL_T * p_poll_cfg,  
+                                   int * err)
+{
+    int r=0;
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    *err=0;
+    /* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
+         set. optimizaion maybe? */
+    r=nwal_pollPkt(p->nwalInstanceHandle,
+                   nwal_POLL_APP_MANAGED_PKT_Q,
+                   (uint32_t) p,
+                   p->max_n,
+                   p->q,
+                   (void *) NULL);
+
+    return r;
+}
+
+/*************************************************************************
+ * FUNCTION PURPOSE: Poll application defined sideband queues for packets
+ *                   from SA
+ ************************************************************************
+ * DESCRIPTION: Poll application defined sideband queues for packets
+ *                   from SA
+ *************************************************************************/
+static int  netapip_pktioPollSbAdj(struct PKTIO_HANDLE_tag * pp, 
+                                  PKTIO_POLL_T * p_poll_cfg,  
+                                  int * err)
+{
+    int r=0;
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    *err=0;
+    r=nwal_pollDm(p->nwalInstanceHandle,
+                     nwal_POLL_DM_APP_MANAGED_Q,
+                     (uint32_t) p,
+                     p->max_n,
+                     p->q,
+                     (void *)  NULL);
+    return r;
+}
+
+/*-----------------------MAIN API----------------------*/
+/********************************************************************
+ * FUNCTION PURPOSE:  API creates a NETAPI PKTIO channel 
+ ********************************************************************
+ * DESCRIPTION:  API creates a NETAPI PKTIO channel 
+ ********************************************************************/
+PKTIO_HANDLE_T * netapi_pktioCreate(NETAPI_T n,
+                                    char * name,
+                                    PKTIO_CB cb, 
+                                    PKTIO_CFG_T * p_cfg, 
+                                    int * err)
+{
+    int r = 0;
+    PKTIO_HANDLE_T *p;
+    uint8_t         isAllocated;
+
+    *err=0;
+    int q = QMSS_PARAM_NOT_SPECIFIED;
+
+    int qtype = Qmss_QueueType_GENERAL_PURPOSE_QUEUE;
+
+    if(p_cfg == NULL)
+    {
+        *err = NETAPI_ERR_BAD_INPUT;
+        return NULL;
+    }
+    /* over-ride only for Qmss_QueueType_GIC400_QUEUE */
+    if (p_cfg->queueType == Qmss_QueueType_GIC400_QUEUE)
+        qtype = p_cfg->queueType;
+
+    if ((!p_cfg)||(!name)) {*err=NETAPI_ERR_BAD_INPUT; return NULL;}
+    if ((p_cfg->flags2 & PKTIO_PKT) &&(p_cfg->flags1& PKTIO_TX)) { *err=NETAPI_ERR_BAD_INPUT; return NULL;};
+    if ((p_cfg->flags2 & PKTIO_SB) &&(p_cfg->flags1& PKTIO_TX)) { *err=NETAPI_ERR_BAD_INPUT; return NULL;};
+
+    /* get a free channel handle */
+    p=netapip_pktioGetFreeChannelSlot(n);
+
+    if (!p) {*err = NETAPI_ERR_NOMEM; return (p); }
+
+    p->back = n;
+    p->cb = cb;
+    p->max_n = p_cfg->max_n;
+    p->_poll=netapip_pktioPollDummy;
+    p->_send=netapip_pktioSendDummy;
+    memcpy((char *)&p->cfg, (char*) p_cfg, sizeof(PKTIO_CFG_T));
+
+    if (p_cfg->qnum!=PKTIO_Q_ANY)
+    {
+        q= p_cfg->qnum;
+    }
+    /* special case for infrastructure dma channels */
+    if (p_cfg->flags2 & PKTIO_IFDMA)
+    {
+        qtype=Qmss_QueueType_INFRASTRUCTURE_QUEUE;
+    }
+
+
+    /* create a  general queue */
+     p->q  = Qmss_queueOpen(qtype,
+                                q, 
+                                &isAllocated);
+    if (p->q < 0)
+    {
+        netapi_Log("netapi_pktioCreate:  queueOpen failed\n");
+        p->inuse=0;
+        *err= NETAPI_ERR_QLLD;  ///queue lld error
+        return NULL;
+    }
+
+    p->qInfo = Qmss_getQueueNumber(p->q);
+
+    if (p_cfg->flags2 & PKTIO_PKT)
+    {
+        p->use_nwal = PKTIO_4_ADJ_NWAL;
+        p->_poll=netapip_pktioPollNwalAdj;
+        p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
+    }
+    else if (p_cfg->flags2 & PKTIO_SB)
+    {
+        p->use_nwal = PKTIO_4_ADJ_SB;
+        p->_poll=netapip_pktioPollSbAdj;
+        p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
+    }
+   else if (p_cfg->flags2 & PKTIO_IFDMA)
+   {
+        p->use_nwal = 0;
+        p->_send = netapip_pktioSendIfdma;
+        p->cfg.flags1=PKTIO_TX;
+        r= netapip_pktioCreateIFDMA(p); //we create the IF DMA channel here
+        if (r<0) 
+        {
+            //trouble -> couldn't set up DMA 
+            //close queue and return failure
+            if (p->q)
+            {
+                Qmss_queueClose(p->q);
+            }
+            p->inuse=0;
+            *err= NETAPI_ERR_QLLD;  ///queue lld error TODO: fix error code 
+            return NULL;
+        }
+   }
+    else
+    {
+        p->use_nwal=0;
+        if (p_cfg->flags1& PKTIO_TX) p->_send=netapip_pktioSendIpc;
+        if (p_cfg->flags1& PKTIO_RX) p->_poll=netapip_pktioPollIpc;
+    }
+
+    /* save name */ 
+    strncpy(p->name,name,
+       strlen(name)<PKTIO_MAX_NAME ?
+               strlen(name):PKTIO_MAX_NAME);   
+
+    /* add name, qnum to global name list */
+    if ((strcmp(name,NETCP_RX)) &&
+        (strcmp(name,NETCP_TX)) &&
+        (strcmp(name,NETCP_SB_RX)) &&
+        (strcmp(name,NETCP_SB_TX)) &&
+        (p_cfg->flags1 & PKTIO_GLOBAL))
+    {
+         //todo: make sure this succeeds..
+        hplib_mSpinLockLock(&pnetapiShm->netapi_pktio_lock);
+        r=netapip_addGlobalPktio(n, name, &p->qInfo);
+        hplib_mSpinLockUnlock(&pnetapiShm->netapi_pktio_lock);
+    }
+
+  ((NETAPI_HANDLE_T *)n )->n_pktios+=1;
+   return p;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE:  API opens an existing  NETAPI PKTIO channel
+ ********************************************************************
+ * DESCRIPTION:  API opens an existing  NETAPI PKTIO channel
+ ********************************************************************/
+PKTIO_HANDLE_T * netapi_pktioOpen(NETAPI_T  n,
+                                  char *name,
+                                  PKTIO_CB cb,
+                                  PKTIO_CFG_T * p_cfg,
+                                  int * err)
+{
+    int r=0;
+    PKTIO_HANDLE_T *p, *p2;
+    uint8_t         isAllocated;
+    *err=0;
+    Qmss_Queue *p_qnum;
+    int qtype=Qmss_QueueType_GENERAL_PURPOSE_QUEUE;
+
+
+    if ((!p_cfg)||(!name)) {*err=NETAPI_ERR_BAD_INPUT; return NULL;}
+
+    /* get a free channel handle */
+
+    p=netapip_pktioGetFreeChannelSlot(n);
+
+    if (!p) {*err = NETAPI_ERR_NOMEM; return (p); }
+    ((NETAPI_HANDLE_T *)n)->n_pktios+=1;
+
+    p->inuse= PKTIO_INUSE;
+    p->back = n;
+    p->cb = cb;
+    p->max_n = p_cfg->max_n;
+    p->_poll=netapip_pktioPollDummy;
+    p->_send=netapip_pktioSendDummy;
+    memcpy((char *)&p->cfg, (char*) p_cfg, sizeof(PKTIO_CFG_T));
+
+    /* special handling of NETCP_RX, NETCP_TX */
+    if( (!strcmp(name, NETCP_RX)) || (!strcmp(name,NETCP_TX)) )
+    {
+       /* these have already been opened internally, so don't search in global list */
+        p->use_nwal = PKTIO_DEF_NWAL;
+        p->q = 0;  
+        p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
+        if (!strcmp(name,NETCP_RX))
+        {
+            p->_poll=netapip_pktioPollNwal; 
+            p->poll_flags= nwal_POLL_DEFAULT_GLOB_PKT_Q|
+                                    nwal_POLL_DEFAULT_PER_PROC_PKT_Q;
+        }
+        if (!strcmp(name,NETCP_TX))
+        {
+            p->_send=netapip_pktioSendNwal;
+        }
+    }
+    else if( (!strcmp(name, NETCP_SB_RX)) || (!strcmp(name,NETCP_SB_TX)) )
+    {
+       /* these have already been opened internally, so don't search in global list */
+        p->use_nwal =  PKTIO_DEF_SB;
+        p->q = 0;
+        p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
+        if (!strcmp(name,NETCP_SB_RX)) p->_poll=netapip_pktioPollSb;
+        if (!strcmp(name,NETCP_SB_TX)) p->_send=netapip_pktioSendSb;
+    }
+    else
+    {
+        hplib_mSpinLockLock(&pnetapiShm->netapi_pktio_lock);
+        /* Find queue in global list 
+           Note names like "QUEUE:%d" or IFDMA:%d cause general purpose or
+           IFDMA queues of that number to be opened */
+        if (p_cfg->flags2 & PKTIO_IFDMA)
+        {
+            qtype= Qmss_QueueType_INFRASTRUCTURE_QUEUE;
+        }
+
+        hplib_mSpinLockUnlock(&pnetapiShm->netapi_pktio_lock);
+        p_qnum = netapip_findGlobalPktio(n, name);
+
+        if (!p_qnum ) 
+        {
+            netapi_Log("netapi_pktioOpen: can't find %s\n",name);
+            p->inuse=0;
+            *err= NETAPI_ERR_NOTFOUND;  ///queue lld error
+            return NULL;
+      }
+
+     /* open a general queue (for now). use qnum that was just found */
+         p->q  = Qmss_queueOpen(qtype,
+                           p_qnum->qNum , &isAllocated);
+        if (p->q == (Qmss_QueueHnd) NULL)
+        {
+            netapi_Log("netapi_pktioCreate:  queueOpen failed\n");
+            p->inuse=0;
+            *err= NETAPI_ERR_QLLD;  ///queue lld error
+            return NULL;
+        }
+        p->qInfo = Qmss_getQueueNumber(p->q);
+        netapi_Log("netapi_pktioOpen: queueMgr %d,  queueNum; %d\n", p->qInfo.qMgr, p->qInfo.qNum);
+        if (p_cfg->flags2 & PKTIO_PKT)
+        {
+           p->use_nwal = PKTIO_4_ADJ_NWAL;  //additonal RX q for nwal
+           p->_poll = netapip_pktioPollNwalAdj;
+           p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n); 
+           netapi_Log("netapi_pktioOpen: nwalInstanceHandle 0x%x\n", p->nwalInstanceHandle);
+        } 
+        else if (p_cfg->flags2 & PKTIO_SB)
+        {
+           p->use_nwal = PKTIO_4_ADJ_SB;  //additional RX q for sideband with NWAL
+           p->_poll = netapip_pktioPollSbAdj;
+           p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
+        }
+        else if (p_cfg->flags2 & PKTIO_IFDMA)
+        {
+            p->_send= netapip_pktioSendIfdma;
+            p->use_nwal = 0;
+        }
+        else
+        {
+           p->use_nwal=0; //not handled by nwal
+            if (p_cfg->flags1& PKTIO_TX) p->_send=netapip_pktioSendIpc;
+            if (p_cfg->flags1& PKTIO_RX) p->_poll=netapip_pktioPollIpc;
+        }
+    }
+
+        /* save name */
+        strncpy(p->name,name,
+           strlen(name)<PKTIO_MAX_NAME ?
+                   strlen(name):PKTIO_MAX_NAME);
+
+        netapi_Log("netapi_pktioOpen: returning with sucess for name %s\n", p->name);
+    return p;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE:  API controls an existing NETAPI PKTIO channel
+ ********************************************************************
+ * DESCRIPTION:  API controls an existing NETAPI PKTIO channel
+ ********************************************************************/
+void netapi_pktioControl(PKTIO_HANDLE_T * p,
+                         PKTIO_CB cb,
+                         PKTIO_CFG_T * p_cfg,
+                         PKTIO_CONTROL_T * p_control,
+                         int *err)
+{
+    nwal_RetValue       nwalRetVal;
+    if (!p)
+    {
+        *err= NETAPI_ERR_BAD_INPUT; 
+        return;
+    }
+    if (cb) 
+    {
+        p->cb = cb;
+    }
+    if (p_control)
+    {
+        /* todo: check for validity, eg don't allow clear of NETCP TX queues */
+        /* todo: implement divert */
+        switch(p_control->op)
+        {
+            //clear the queue
+            case(PKTIO_SET_POLL_FLAGS):
+                p->poll_flags=p_control->poll_flags;
+                break;
+            case(PKTIO_CLEAR):
+                netapip_zapQ(p->q);
+                break;
+            case (PKTIO_UPDATE_FAST_PATH):
+                if (p_cfg)
+                {
+                    nwalRetVal = nwal_initPSCmdInfo(p->nwalInstanceHandle, 
+                                                            p_cfg->fast_path_cfg.txPktInfo,
+                                                            &p->tx_psCmdInfo);
+                    if (nwalRetVal == nwal_OK)
+                    {
+                        switch (p_cfg->fast_path_cfg.fp_send_option)
+                        {
+                            case (PKTIO_FP_ESP_L4CKSUM_PORT):
+                                p->_send = netapip_pktioSendL4CkSumCryptPort;
+                                break;
+                            case (PKTIO_FP_AH_L4CKSUM_PORT):
+                                p->_send = netapip_pktioSendL4CkSumAHCryptPort;
+                                break;
+                            case (PKTIO_FP_ESP_PORT):
+                                p->_send = netapip_pktioSendCryptPort;
+                                break;
+                            case (PKTIO_FP_ESP_L3CKSUM_PORT):
+                                p->_send = netapip_pktioSendL3CkSumCryptPort;
+                                break;
+                            case (PKTIO_FP_AH_PORT):
+                                p->_send = netapip_pktioSendAHCryptPort;
+                                break;
+                            case (PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT):
+                                p->_send = netapip_pktioSendPort;
+                                break;
+                            case (PKTIO_FP_L4CKSUM_PORT):
+                                p->_send = netapip_pktioSendL4CkSumPort;
+                                break;
+                            default:
+                                break;
+                        }
+                    }
+                    else
+                    {
+                        *err = NETAPI_ERR_BAD_INPUT;
+                    }
+                }
+                else
+                {
+                    *err = NETAPI_ERR_BAD_INPUT;
+                }
+                break;
+            case (PKTIO_UPDATE_MAX_PKTS_PER_POLL):
+                if (p_cfg)
+                {
+                    p->max_n = p_cfg->max_n;
+                }
+                else
+                {
+                    *err = NETAPI_ERR_BAD_INPUT;
+                }
+                break;
+            case(PKTIO_DIVERT):
+            default:
+                netapi_Log("netapi_pktioControl: pktio_control op %d not implemented\n",p_control->op);
+                *err= NETAPI_ERR_NOT_IMPLEMENTED;
+                break;
+        }
+    }
+
+    *err = NETAPI_ERR_OK;
+    return;
+}
+/********************************************************************
+ * FUNCTION PURPOSE:  API closes a NETAPI PKTIO channel
+ ********************************************************************
+ * DESCRIPTION:  API closes a NETAPI PKTIO channel
+ ********************************************************************/
+void netapi_pktioClose(PKTIO_HANDLE_T * p, 
+                       int * err)
+{
+    if(!p)
+    {
+        *err=1;
+        return;
+    }
+    *err=0;
+    if (p->q)
+    {
+        Qmss_queueClose(p->q);
+    }
+    p->q=-1;
+    p->inuse=0;
+    ((NETAPI_HANDLE_T *)p->back)->n_pktios-=1;
+    return;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE:  API deletes a NETAPI PKTIO channel
+ ********************************************************************
+ * DESCRIPTION:  API deletes a NETAPI PKTIO channel
+ ********************************************************************/
+void netapi_pktioDelete(PKTIO_HANDLE_T * p, 
+                        int * err)
+{
+    if(!p)
+    {
+        *err=1;
+        return;
+    }
+    *err=0;
+    if (p->cfg.flags2 & PKTIO_IFDMA)
+    {
+        netapip_pktioDeleteIFDMA(p);
+    }
+
+        /* remove from name list */
+    hplib_mSpinLockLock(&pnetapiShm->netapi_pktio_lock);
+        netapi_del_global_pktio((NETAPI_HANDLE_T *)p->back, p->name);
+    hplib_mSpinLockUnlock(&pnetapiShm->netapi_pktio_lock);
+        if((p->use_nwal != PKTIO_DEF_NWAL) && (p->use_nwal != PKTIO_DEF_SB)) 
+    {
+                netapip_zapQ(p->q);   //since we are deleting, zap the queue 
+            Qmss_queueClose(p->q);
+    }
+    p->q=-1;
+    p->inuse=0;
+    ((NETAPI_HANDLE_T *)p->back)->n_pktios-=1;
+    return ;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE:  API sends multiple packets to a NETAPI PKTIO channel
+ ********************************************************************
+ * DESCRIPTION:  API sends multiple packets to a NETAPI PKTIO channel
+ ********************************************************************/
+int netapi_pktioSendMulti(PKTIO_HANDLE_T * p, 
+                          Ti_Pkt * pkt[], 
+                          PKTIO_METADATA_T * m[], 
+                          int np, 
+                          int* err)
+{
+    int r=0;
+    for(r=0;r<np;r++)
+    {
+        p->_send((struct PKTIO_HANDLE_tag *)p, (Ti_Pkt *)pkt, (PKTIO_METADATA_T *)m, err);
+    }
+    return r;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE:  API polls all NETAPI PKTIO channels associated with NETAPI_T
+ * instance for received packets
+ ********************************************************************
+ * DESCRIPTION:  API polls all NETAPI PKTIO channels associated with NETAPI_T
+ * instance for received packets
+ ********************************************************************/
+int netapi_pktioPollAll(NETAPI_T  handle, 
+                        PKTIO_POLL_T * p_poll_cfg, 
+                        int *err)
+{
+    int i=0;
+    int r=0;
+    int err2;
+    int cnt=0;
+    PKTIO_HANDLE_T **pp =( PKTIO_HANDLE_T **)  netapi_get_pktio_list(handle);
+    
+    *err=0;
+    for(i=0;i<NETAPI_MAX_PKTIO && cnt < ((NETAPI_HANDLE_T *)handle)->n_pktios;i++)
+    {
+        if (pp[i]->inuse != PKTIO_INUSE) continue;
+        if(!(pp[i]->cfg.flags1&PKTIO_RX)) continue;
+        r+=netapi_pktioPoll(pp[i],  p_poll_cfg,  &err2); cnt+=1;
+        if (err2) { *err = err2; break;}
+    }
+    return r;
+
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE:  Internal function to delete a PKTIO infrastructure DMA channel
+ ********************************************************************
+ * DESCRIPTION:  Internal function to delete a PKTIO infrastructure DMA channel
+ ********************************************************************/
+int netapip_pktioDeleteIFDMA(PKTIO_HANDLE_T *p)
+{
+        Cppi_channelDisable (p->txChHnd);
+        Cppi_channelDisable (p->rxChHnd);
+        Cppi_channelClose(p->txChHnd);
+        Cppi_channelClose(p->rxChHnd);
+        Cppi_close(p->cppiHnd);
+        return 1;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE:  Internal function to create a PKTIO infrastructure DMA channel
+ ********************************************************************
+ * DESCRIPTION:  Internal function to create a PKTIO infrastructure DMA channel
+ *               for infrastructure DMQ queue
+ ********************************************************************/
+int netapip_pktioCreateIFDMA(PKTIO_HANDLE_T * p )
+{
+   int dmaChan =  p->qInfo.qNum - QMSS_INFRASTRUCTURE_QUEUE_BASE;
+   unsigned char           isAllocated;
+   Cppi_TxChInitCfg        txChCfg;
+   Cppi_RxChInitCfg        rxChCfg;
+   Cppi_CpDmaInitCfg       cpdmaCfg;
+
+    /* Set up QMSS CPDMA configuration */
+    memset ((void *) &cpdmaCfg, 0, sizeof (Cppi_CpDmaInitCfg));
+    cpdmaCfg.dmaNum = Cppi_CpDma_QMSS_CPDMA;
+
+    /* Open QMSS CPDMA */
+    p->cppiHnd = (Cppi_Handle) Cppi_open (&cpdmaCfg);
+    if (p->cppiHnd == NULL)
+    {
+        return -1;
+    }
+
+ /* Set up Tx Channel parameters */
+    memset ((void *) &txChCfg, 0, sizeof (Cppi_TxChInitCfg));
+    txChCfg.channelNum = dmaChan;
+    txChCfg.priority = 0;
+    txChCfg.filterEPIB = 0;
+    txChCfg.filterPS = 0;
+    txChCfg.aifMonoMode = 0;
+    txChCfg.txEnable = Cppi_ChState_CHANNEL_DISABLE;
+
+    /* Open Tx Channel */
+    p->txChHnd = (Cppi_ChHnd) Cppi_txChannelOpen (p->cppiHnd, &txChCfg, &isAllocated);
+    if (p->txChHnd == NULL)
+    {
+        Cppi_close(p->cppiHnd);
+        return -1;
+    }
+
+     /* Set up Rx Channel parameters */
+    memset ((void *) &rxChCfg, 0, sizeof (Cppi_RxChInitCfg));
+    rxChCfg.channelNum = dmaChan;
+    rxChCfg.rxEnable = Cppi_ChState_CHANNEL_DISABLE;
+
+    /* Open Rx Channel */
+    p->rxChHnd = (Cppi_ChHnd) Cppi_rxChannelOpen (p->cppiHnd, &rxChCfg, &isAllocated);
+    if (p->rxChHnd == NULL)
+    {
+        Cppi_channelClose(p->txChHnd);
+        Cppi_close(p->cppiHnd);
+        return -1;
+    }
+    if (Cppi_channelEnable (p->txChHnd) != CPPI_SOK)
+    {
+        Cppi_channelClose(p->txChHnd);
+        Cppi_channelClose(p->rxChHnd);
+        Cppi_close(p->cppiHnd);
+        return -1;
+    }
+
+    /* Enable receive channel */
+    if (Cppi_channelEnable (p->rxChHnd) != CPPI_SOK)
+    {
+        Cppi_channelDisable (p->txChHnd);
+        Cppi_channelClose(p->txChHnd);
+        Cppi_channelClose(p->rxChHnd);
+        Cppi_close(p->cppiHnd);
+        return -1;
+    }
+    return 1;
+}
+
+/**********************************************************************
+ * FUNCTION PURPOSE:  Internal Callback that gets registered with NWAL for packet reception
+ **********************************************************************
+ * DESCRIPTION:  Callback that gets registered with NWAL for packet reception
+ * appCookie is the pktio handle 
+ **********************************************************************/
+void netapip_pktioNWALRxPktCallback(uint32_t            appCookie,
+                              uint16_t             numPkts,
+                              nwalRxPktInfo_t*    pPktInfo,
+                              uint64_t            timestamp,
+                              nwal_Bool_t*        pFreePkt)
+{
+    PKTIO_HANDLE_T * p = (PKTIO_HANDLE_T *) appCookie;
+    int r=0;
+    int n;
+    Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
+    PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
+
+    for(r=0;r<numPkts;r++)
+    {
+        pkt_list[r] = pPktInfo[r].pPkt;
+        meta_s[r].flags1 = PKTIO_META_RX;
+        meta_s[r].u.rx_meta = &pPktInfo[r];
+    }
+    if (r)
+    {
+        p->cb((struct PKTIO_HANDLE_tag *)p, pkt_list, &meta_s[0], r, timestamp);
+    }
+}
+
+
+/**********************************************************************
+ * FUNCTION PURPOSE:  Internal Callback that gets registered with NWAL for crypto reception
+ **********************************************************************
+ * DESCRIPTION:  Callback that gets registered with NWAL for crypto reception,
+ * appCookie is the pktio handle 
+ **********************************************************************/
+void netapip_pktioNWALSBPktCallback(uint32_t            appCookie,
+                              uint16_t             numPkts,
+                              nwalDmRxPayloadInfo_t*  pDmRxPktInfo,
+                              nwal_Bool_t*        pFreePkt)
+{
+    PKTIO_HANDLE_T * p = (PKTIO_HANDLE_T *) appCookie;
+    int r=0;
+    int n;
+    Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
+    PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
+    for(r=0;r<numPkts;r++)
+    {
+        pkt_list[r] = pDmRxPktInfo[r].pPkt;
+        meta_s[r].flags1 =  PKTIO_META_SB_RX;
+        meta_s[r].u.rx_sb_meta = &pDmRxPktInfo[r];
+    }
+    if (r)
+    {
+        p->cb((struct PKTIO_HANDLE_tag *)p, pkt_list, &meta_s[0], r, 0LL);
+    }
+}
+
index b5fbb071296d725b907a899a60d66aa4072009db..50c9ba5c7188b8f842f1a8cf1208238e241f39e5 100755 (executable)
@@ -392,7 +392,7 @@ benchmarks();
 {
        pthread_t *thrs;
         int procs =2; 
-        char c;
+        int c;
         thrs = malloc( sizeof( pthread_t ) * procs );
         if (thrs == NULL)
         {
index a5239d496ec2c6ea459cf0193c07cde8553c64b5..9caae3f17993d2bdb7971e332daa3905179ac405 100755 (executable)
@@ -46,9 +46,9 @@
 #include "netapi.h"
 #include "trie.h"
 
-#include "net_test_sa_utils.h"
-#include "net_test_utils.h"
-#include "net_test_thread_utils.h"
+//#include "net_test_sa_utils.h"
+//#include "net_test_utils.h"
+//#include "net_test_thread_utils.h"
 
 //#include "net_test_sa_utils.h"
 //define this for multi-thread
index ff5e96911fff056b53d235b62a2d47b0ffd7477c..33a3b10533e4aa8ecee52e183359ded37c8f0295 100755 (executable)
 #include <pthread.h>
 #include <sched.h>
 
-#include "trie.h"
+//#include "trie.h"
 #include "string.h"
 #include "netapi.h"
-#include "pktio.h"
+//#include "pktio.h"
 #include "net_test.h"
+#include "net_test_sa_utils.h"
+#include "net_test_utils.h"
+#include "net_test_thread_utils.h"
 #include <ti/drv/sa/salld.h>
 
 #if defined(DEVICE_K2H)
@@ -72,6 +75,7 @@
 #include <ti/drv/qmss/device/k2h/src/qmss_device.c>
 #include <ti/drv/cppi/device/k2h/src/cppi_device.c>
 #endif /* Device */
+extern Rm_ServiceHandle   *rmClientServiceHandle;
 
 #define netapi_timing_start hplib_mUtilGetPmuCCNT
 
@@ -303,7 +307,13 @@ int main(int argc, char **argv)
 
 
 
-
+#if 1
+    if (initRm())
+    {
+        printf("main: initRm() returned error\n");
+        exit(1);
+    }
+#endif
 
 
     CPU_ZERO( &cpu_set);
@@ -414,8 +424,13 @@ netapi_netcpCfgCreateMacInterface(
                        pkt_rx,pkt_tx,
                        idle_cycles,
                        (et-start_time),
-                       (idle_cycles*100)/(CALIB*(et-start_time))
-                    );
+                       (idle_cycles*100)/(CALIB*(et-start_time)));
+              Pktlib_HeapStats    pktLibHeapStats;
+              Pktlib_getHeapStats(OurHeap, &pktLibHeapStats);
+              printf("main  heap stats>  #free=%d #zb=%d #garbage=%d\n",
+                                pktLibHeapStats.numFreeDataPackets,
+                                pktLibHeapStats.numZeroBufferPackets,
+                                pktLibHeapStats.numPacketsinGarbage);
            }
            else if (c=='r')
            {
@@ -607,23 +622,6 @@ volatile unsigned long sum3=0;
 volatile unsigned long sum4=0;
 volatile Ti_Pkt * pHd[NTOPOP];
 
-void * pop_raw(int n)
-{
-
-}
-void * p2v (void* in)
-{
-
-
-}
-void * v2p(void * in)
-{
-
-}
-void push_raw(void *pkt, int n)
-{
-
-}
 
 void benchmarks2(Pktlib_HeapHandle h , int ntrials)
 {
index 64767c9543d953db8ffe0210e5a0b2075dd65fec..2dac9a251fe0656427ee383f0b73ef65cc781a3a 100755 (executable)
 
  *****************************************************************************/
 
-#include "net_test.h"
+#include "netapi.h"
+#include "net_test_sa_utils.h"
+#include "net_test_utils.h"
+#include "net_test_thread_utils.h"
 #include "ti/drv/nwal/test/fw_rm.h"
 #include <signal.h>
 #include <pthread.h>
@@ -444,7 +447,8 @@ void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
     int coreid=0;
 #endif
     //nwal_AppId time;
-    unsigned long time, delta_time;
+    unsigned long time = 0;
+    unsigned long delta_time = 0;
     /* loop over received pkts */
     for(i=0;i<n_pkts;i++)
    {
@@ -605,21 +609,25 @@ void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
         }
 
         if(coreid<TUNE_NETAPI_NUM_CORES)
+        {
             stats[coreid].rx+=1;
-        if (ifno < TUNE_NETAPI_MAX_NUM_MAC)
-            stats[coreid].if_rx[ifno]+=1;
-
+            if (ifno < TUNE_NETAPI_MAX_NUM_MAC)
+                stats[coreid].if_rx[ifno]+=1;
+        }
 
 #ifdef DEBUG_DESC
-        if (stats[coreid].rx<16)
-        {
-            netapi_Log(">rx dmp.."); 
-            netTest_utilDumpDescr((long *) tip, stats[coreid].rx);
-        }
-        else if (stats[coreid].rx>99) 
+        if(coreid<TUNE_NETAPI_NUM_CORES)
         {
-            netapi_Log(">rx dmp.."); 
-            netTest_utilDumpDescr((long *) tip,stats[coreid].rx);
+            if (stats[coreid].rx<16)
+            {
+                netapi_Log(">rx dmp.."); 
+                netTest_utilDumpDescr((long *) tip, stats[coreid].rx);
+            }
+            else if (stats[coreid].rx>99) 
+            {
+                netapi_Log(">rx dmp.."); 
+                netTest_utilDumpDescr((long *) tip,stats[coreid].rx);
+            }
         }
 #endif
 #if 0
@@ -902,7 +910,7 @@ void setup_netTestDSPFastPath(NETAPI_T handle)
     char dsp_name[32];
     for (i = 0; i < CPU_NUM_REM_FAST_PATH_CORES; i++)
     {
-        sprintf(&dsp_name[0],"%s%d","dsp_chan", i);
+        snprintf(&dsp_name[0],32, "%s%d","dsp_chan", i);
         dsp_pktio_cfg.flags1 = PKTIO_RX;
         dsp_pktio_cfg.flags2 = PKTIO_GLOBAL | PKTIO_PKT;
         dsp_pktio_cfg.qnum = TEST_NWAL_BASE_REM_FP_RX_PKT_QUEUE + i;
@@ -1051,7 +1059,7 @@ void fast_path_thread(uint32_t index)
 #else
     for (i = netTestCfg.fp_proc_start[index]; i <= netTestCfg.fp_proc_end[index];i++)
     {
-        netapi_Log("fast_path_thread: start core %d, end core %d\n",
+        netapi_Log("fast_path_thread: start core %d end core %d\n",
                 netTestCfg.fp_proc_start[index],
                 netTestCfg.fp_proc_end[index]);
         netapi_Log("fast_path_thread: setting cpu %d to cpu_set\n", i);
@@ -1254,7 +1262,7 @@ int main(int argc, char **argv)
 
 
 
-    char c;
+    int c;
     //this thread of execution (main) now just waits on user input
     for(;;)
     {
@@ -1305,6 +1313,7 @@ int main(int argc, char **argv)
 /* Stub functions */
 Trie * route_init(void)
 {
+    return NULL;
 }
 void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route)
 {
index 4c2a0c3290c67d81c92d58dfc4b7865775d9e1b2..d30a63b5439263cbbe65992483e8d76729ff2565 100755 (executable)
@@ -151,6 +151,7 @@ void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
 
 Trie * route_init(void)
 {
+    return NULL;
 }
 void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route)
 {
@@ -421,7 +422,7 @@ int main(int argc, char **argv)
 #endif
 #ifdef netTest_MULTI_THREAD
 {
-    char c;
+    int c;
 
 
         //this thread of execution (main) now just waits on user input
index 5ce5f002fed2e371ffa6588057854738beda48c6..2d753a59dac95f235d920c0eda61373bd7859498 100755 (executable)
 
  ******************************************************************************/
 
-#include "trie.h"
+#include "netapi.h"
+#include "net_test_sa_utils.h"
+#include "net_test_utils.h"
+#include "net_test_thread_utils.h"
 
 #include <signal.h>
 #include <pthread.h>
@@ -546,7 +549,7 @@ int main(int argc, char **argv)
 
 #ifdef netTest_MULTI_THREAD
 {
-    char c;
+    int 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 */
      netTest_utilCreateSpFpThreads(netTestCfg.num_sp_threads, 
@@ -668,8 +671,12 @@ void recv_cb_router(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
     for(i=0;i<n_pkts;i++)
     {
         ifno = ((unsigned int)meta[i].u.rx_meta->appId)&0xff;
-        if(coreid<TUNE_NETAPI_NUM_CORES) stats[coreid].rx+=1;
-        if (ifno < TUNE_NETAPI_MAX_NUM_MAC) stats[coreid].if_rx[ifno]+=1;
+        if(coreid<TUNE_NETAPI_NUM_CORES) 
+        {
+            stats[coreid].rx+=1;
+            if (ifno < TUNE_NETAPI_MAX_NUM_MAC)
+                stats[coreid].if_rx[ifno]+=1;
+        }
         tip = p_recv[i];
         Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
         len = Pktlib_getPacketLen(tip)-4;//real length, subtract mac trailer
index 1e28ea9bc844c186d81642c9d506940508245e97..23fbb367c318d46fa1b4db10f3bfd17ca5a6ef73 100755 (executable)
@@ -41,6 +41,9 @@
  *****************************************/
 
 #include "net_test.h"
+#include "ti/runtime/netapi/netapi.h"
+#include "net_test_sa_utils.h"
+#include "net_test_utils.h"
 
 #include <signal.h>
 #include <pthread.h>
@@ -682,7 +685,8 @@ void  netTest_utilBuildSADB(int i)
 int netTest_utilCreateSecAssoc(void)
 {
     nwal_RetValue       nwalRetVal;
-    int err,i;
+    int err = 0;
+    int i;
     nwalSaIpSecId_t  nwalSaIpSecId;
     uint32_t saId;
     for (i=0; i < netTestCfg.num_sa;i++)
@@ -724,7 +728,7 @@ int netTest_utilCreateSecAssoc(void)
                              &err);
                 if (err)
                 {
-                    netapi_Log("addSaPolicy failed  %d, for index %d\n",err,i); 
+                    netapi_Log("addSaPolicy failed  %d for index %d\n",err,i); 
                     exit(1);
                 }
             }
@@ -751,6 +755,7 @@ int netTest_utilCreateSecAssoc(void)
             if (err) {netapi_Log("addTxSa failed %d\n",err); exit(1);}
         }
     }
+    return err;
 }
 
 
index 51b7d034ca9f27cc2d8220742f854156194f71f3..dffc7d2492197eb4d9d868822896fbc7c4070fb3 100755 (executable)
@@ -1,7 +1,10 @@
 #ifndef __NET_TEST_SA_UTILS_H__
 #define __NET_TEST_SA_UTILS_H__
 
-#include "net_test.h"
+//#include "net_test.h"
+//#include "net_test_utils.h"
+//#include "net_test_thread_utils.h"
+#include "ti/runtime/netapi/netapi.h"
 
 #define netTest_MAC_HEADER_LEN          14
 #define netTest_IP_HEADER_LEN           20
index 8abdc2383bc5a8da1d061fae830a8de004a42675..4b412c2dbe01ea0f8dd11a153860b51cbda2e93e 100755 (executable)
@@ -44,7 +44,7 @@
 #include <signal.h>
 #include <pthread.h>
 #include "router.h"
-
+#include "net_test_thread_utils.h"
 extern netTestConfig_t netTestCfg;
 
 
index 1ed02b2f152caceea1a84f456f3176d8fa0b5089..2980f121c7b5f96dcd02f92e1bdacaea970c7b37 100755 (executable)
@@ -199,12 +199,6 @@ void   netTest_utilDumpBuffer
                 break;
             }
 
-            default:
-            {
-                /* Should never reach here */
-                netapi_Log("netapi *: Internal Error in  netTest_utilDumpBuffer().Row Count: %d \n", row_count);
-                return;
-            }
         }
 
         tmp_buf = tmp_buf + row_count;
@@ -378,13 +372,13 @@ void netTest_utilsStatsCb(NETAPI_T h, paSysStats_t* pPaStats)
     uint32_t            numPacketsinGarbage;
     Pktlib_HeapStats    pktLibHeapStats;
     int i,j;
-    unsigned long long bcpp;
-    unsigned long long bcpp_noc;
-    unsigned long long bcpp_app;
-    unsigned long long bcpp_tx;
-    unsigned long long npL;
-    unsigned long long cyclesL;
-    unsigned long long ccyclesL; //cache cycles
+    unsigned long long bcpp = 0;
+    unsigned long long bcpp_noc = 0;
+    unsigned long long bcpp_app = 0;
+    unsigned long long bcpp_tx = 0;
+    unsigned long long npL = 0;
+    unsigned long long cyclesL = 0;
+    unsigned long long ccyclesL = 0; //cache cycles
     unsigned long long tmp_npL[TUNE_NETAPI_NUM_CORES];
     unsigned long long tmp_cyclesL[TUNE_NETAPI_NUM_CORES];
     unsigned long long tmp_ccyclesL[TUNE_NETAPI_NUM_CORES]; //cache cycles
@@ -867,7 +861,6 @@ void netTest_utilParseThreadConfig(char * p_thread_str, uint8_t* start, uint8_t*
         *start = atoi(pch);
         pch = strtok (NULL,"-");
         *end = atoi(pch);
-        netapi_Log("netTest_utilParseThreadConfig: start %d, end %d\n", *start, *end);
     }
 }
 
@@ -882,19 +875,12 @@ void netTest_utilParseThreadParams(netTestConfigFile_t *pConfig)
             netTest_utilParseThreadConfig(&pConfig->fp[i][0],
                                          (uint8_t*)&netTestCfg.fp_proc_start[i],
                                          (uint8_t*)&netTestCfg.fp_proc_end[i]);
-            netapi_Log("netTest_utilParseThreadParams: fp start[%d]: %d, fp end[%d]: %d\n",
-                    i,
-                    netTestCfg.fp_proc_start[i],
-                    i,
-                    netTestCfg.fp_proc_end[i]);
         }
         if (strlen(&pConfig->fp_thread_num[i][0]))
         {
             netTestCfg.fp_thread_num[i] = atoi((char*)(&pConfig->fp_thread_num[i]));
-            netapi_Log("parse_fp: thread_num[%d]: %d\n", i, netTestCfg.fp_thread_num[i]);
         }
     }
-    netapi_Log("parse_fp: number of fp threads  %d\n", netTestCfg.num_fp_threads);
 
     for(i=0;i<NET_TEST_MAX_SP_THREAD;i++)
     {
@@ -908,10 +894,8 @@ void netTest_utilParseThreadParams(netTestConfigFile_t *pConfig)
         if (strlen(&pConfig->sp_thread_num[i][0]))
         {
             netTestCfg.sp_thread_num[i] = atoi((char*)(&pConfig->sp_thread_num[i]));
-            netapi_Log("parse_sp: thread_num[%d]: %d\n", i, netTestCfg.sp_thread_num[i]);
         }
     }
-    netapi_Log("parse_sp: number of sp threads  %d\n", netTestCfg.num_sp_threads);
 }
 void netTest_utilParseSA(netTestConfigFile_t *pConfig)
 {
@@ -960,7 +944,7 @@ void netTest_utilParseRoutes(netTestConfigFile_t *pConfig, OUR_ROUTE_T *routes,
         {
             port=atoi(&pConfig->ports[i][0]);
             if((port<1)||(port>2)) continue; //bad port #: only 1 or 2 valid
-            netapi_Log("netTest_utilParseRoutes [%d]: %s\n", i, &pConfig->routes[i][0]);
+
             if(strncmp(&pConfig->routes[i][0],"MAC",3)==0)
             {
                routes[i].out_port = port;
@@ -1345,11 +1329,11 @@ void netTest_utilCreateInterfaces(uint8_t num_macs, uint8_t num_ips)
                           &err);
        if (err)
        {
-            netapi_Log("addmac %d  failed %d\n",i, err);
+            netapi_Log("addmac %d failed %d\n",i, err);
         //exit(1); 
        }
        else
-        netapi_Log("netTest_utilCreateInterfaces, added mac sucess\n");
+        netapi_Log("netTest_utilCreateInterfaces: added mac sucess\n");
     }
     for (i = 0; i < num_ips; i++)
     {
@@ -1370,7 +1354,7 @@ void netTest_utilCreateInterfaces(uint8_t num_macs, uint8_t num_ips)
         //exit(1); 
         }
         else
-            netapi_Log("netTest_utilCreateInterfaces, added ip sucess\n");
+            netapi_Log("netTest_utilCreateInterfaces: added ip sucess\n");
     }
 }
 
index e97912a9d2c344bf5c97f128d125fcae6aba0172..457d0d4e83ad3eefeec34295c33277badbbccf7f 100755 (executable)
@@ -2,8 +2,10 @@
 #define __NET_TEST_UTIL_H__
 
 
-//#include "trie.h"
-#include "net_test.h"
+#include "trie.h"
+//#include "net_test.h"
+#include "ti/runtime/netapi/netapi.h"
+#include "net_test_sa_utils.h"
 
 #define MAX_SEC_INDEX          64
 #define NET_TEST_MAX_MAC                64
index a18f19457cfe3f9c40ec6377249fac07e3f81f80..5377400074032ecb07a73708364eccc8312456fa 100755 (executable)
@@ -10,6 +10,8 @@
 
 
 #include "net_test.h"
+#include "net_test_sa_utils.h"
+#include "net_test_utils.h"
 
 typedef struct
 {
index 79281df330f44e79a24398d576b185b6f49bb34c..34cc047811439c4662ea439cc2d6e6ac7490fb8f 100755 (executable)
@@ -337,9 +337,9 @@ int initRm (void)
     return(connection_setup());
 }
 
-int closeRm(void)
+int32_t closeRm(void)
 {
-    int32_t            result;
+    int32_t            result = 0;
 
     if(rmClientHandle)
     {
@@ -352,6 +352,7 @@ int closeRm(void)
         result = Rm_delete(rmClientHandle, 1);  
         RM_ERROR_CHECK(RM_OK, result, rmClientName, "Instance delete failed");
     }
+    return (result);
 }
 
 
index 028c130db99b5d14f93856eeb706e6b824fbbd8e..5992bd35d1cbc668bfb93811734277cc66742555 100755 (executable)
@@ -235,7 +235,7 @@ int sock_recv (sock_h handle, char *data, int length, sock_name_t *from)
     }
 
     if (from) {
-        if((from->type = sock_addr_e) && (from->s.addr))
+        if((from->type == sock_addr_e) && (from->s.addr))
             from_length = sizeof(struct sockaddr_un);
         else {
             error_msg("invalid from parameter");