]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blobdiff - ti/runtime/netapi/test/net_test.c
NETAPI net test application updates
[keystone-rtos/netapi.git] / ti / runtime / netapi / test / net_test.c
index 2073b432e481eda611fe1df6c7d15366fe5b0a35..87f2adfafef0fdbeaa0c27f832087675303b530b 100755 (executable)
-/******************************************\r
- * File: net_test.c\r
- * Purpose: test app for netapi\r
- **************************************************************\r
- * FILE:  net_test.c\r
- * \r
- * DESCRIPTION:  netapi user space transport\r
- *               library  test application\r
- * \r
- * REVISION HISTORY:  rev 0.0.1 \r
- *\r
- *  Copyright (c) Texas Instruments Incorporated 2010-2011\r
- * \r
- *  Redistribution and use in source and binary forms, with or without \r
- *  modification, are permitted provided that the following conditions \r
- *  are met:\r
- *\r
- *    Redistributions of source code must retain the above copyright \r
- *    notice, this list of conditions and the following disclaimer.\r
- *\r
- *    Redistributions in binary form must reproduce the above copyright\r
- *    notice, this list of conditions and the following disclaimer in the \r
- *    documentation and/or other materials provided with the   \r
- *    distribution.\r
- *\r
- *    Neither the name of Texas Instruments Incorporated nor the names of\r
- *    its contributors may be used to endorse or promote products derived\r
- *    from this software without specific prior written permission.\r
- *\r
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\r
- *****************************************/\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <unistd.h>\r
-#include <string.h>\r
-\r
-\r
-#include "trie.h"\r
-#include "string.h"\r
-#include "netapi.h"\r
-#include "pktio.h"\r
-#include <sys/resource.h>\r
-\r
-/*************debug********************/\r
-void dump_descr(unsigned long *p, int n)\r
-{\r
-   printf("--------dump of descriptor %d %x\n", n, (int) p);\r
-   printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);\r
-   printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);\r
-   printf("-----------------------------\n");\r
-}\r
-/*****************************************/\r
-\r
-\r
-//************for multi pkt burst  xfer test in loopback mode\r
-#define TX_BURST 4\r
-int pktloopback=TUNE_NETAPI_NWAL_ENABLE_PASS_LOOPBACK;\r
-\r
-//this device: 10.0.0.100, mac 0x,01,02,03,04,05  and .. 0x6\r
-\r
-//test packet, setup for loopback (so dest is ourself)\r
-static uint8_t testPkt[] = {\r
-\r
-  /* MAC header */\r
-  0x00, 0x01, 0x02, 0x03, 0x04, 0x05,\r
-  0x00, 0xe0, 0xa6, 0x66, 0x57, 0x04,\r
-  0x08, 0x00,\r
-\r
-  /* IP header */\r
-  0x45, 0x00,\r
-  0x00, 0x6c,  /* Length (including this header) */\r
-  0x00, 0x00, 0x00, 0x00, 0x05, 0x11,\r
-  0x00, 0x00,  /* Header checksum */\r
-  0x0a, 0x00, 0x00, 0x0a, 0x0a, 0x00, 0x00, 0x64,\r
-\r
-  /* UDP header */\r
-  0x12, 0x34, 0x05, 0x55,\r
-  0x00, 0x58,  /* Length, including this header */\r
-  0x00, 0x00,  /* Header checksum */\r
-\r
- /* Payload */\r
-  0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,\r
-  0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41,\r
-  0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,\r
-  0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,\r
-  0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,\r
-  0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61,\r
-  0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,\r
-  0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71,\r
-  0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,\r
-  0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81\r
-\r
-};\r
-\r
-#define TEST_PAYLOAD_LEN            80\r
-\r
-#define TEST_PKT_IP_OFFSET_BYTES        14\r
-#define TEST_PKT_UDP_OFFSET_BYTES       34\r
-#define TEST_PKT_PLOAD_OFFSET_BYTES     42\r
-#define TEST_PKT_UDP_HDR_LEN            8\r
-/* Offsets to length fields */\r
-#define TEST_PKT_OFFSET_IP_LEN      16\r
-#define TEST_PKT_OFFSET_UDP_LEN     38\r
-\r
-#define TEST_PKT_LEN                122\r
-\r
-/* The pseudo header checksum of the packet except for the 16 bit length */\r
-#define TEST_PKT_PSEUDO_HDR_CHKSUM_SANS_LEN  0x0FFC\r
-\r
-\r
-\r
-#if 1\r
-//#include "arpa/inet.h"\r
-long htonl(long x)\r
-{\r
-       long temp = (x&0xff000000)>>24 | (x&0xff0000)>>8 | (x&0xff00)<<8 |  (x&0xff)<<24 ;\r
-       return temp;\r
-}\r
-\r
-/********************************************************************\r
- *  FUNCTION PURPOSE: Ones complement addition utility\r
- ********************************************************************\r
- ********************************************************************/\r
-uint16_t test_utilOnesComplementAdd (uint16_t v1, uint16_t v2)\r
-{\r
-  uint32_t result;\r
-\r
-  result = (uint32_t)v1 + (uint32_t)v2;\r
-  result = (result >> 16) + (result & 0xffff);\r
-  result = (result >> 16) + (result & 0xffff);\r
-\r
-  return ((uint16_t)result);\r
-}\r
-\r
-/********************************************************************\r
- *  FUNCTION PURPOSE: Ones complement checksum utility\r
- ********************************************************************\r
- ********************************************************************/\r
- uint16_t test_utilOnesCompChkSum (uint8_t *p, uint32_t nwords)\r
-{\r
-  uint16_t chksum = 0;\r
-  uint16_t v;\r
-  uint32_t i;\r
-  uint32_t j;\r
-\r
-  for (i = j = 0; i < nwords; i++, j+=2)  {\r
-    v = (p[j] << 8) | p[j+1];\r
-    chksum = test_utilOnesComplementAdd (chksum, v);\r
-  }\r
-  return (chksum);\r
-} /* utilOnesCompChkSum */\r
-\r
-/**************************************************************************************\r
- * FUNCTION PURPOSE: Compute ipv4 psudo checksum\r
- **************************************************************************************\r
- * DESCRIPTION: Compute ipv4 psudo checksum\r
- **************************************************************************************/\r
-uint16_t test_utilGetIpv4PsudoChkSum (uint8_t *data, uint16_t payloadLen)\r
-{\r
-  uint16_t psudo_chksum;\r
-\r
-  psudo_chksum = test_utilOnesCompChkSum (&data[12], 4);\r
-  psudo_chksum = test_utilOnesComplementAdd(psudo_chksum, (uint16_t) data[9]);\r
-  psudo_chksum = test_utilOnesComplementAdd(psudo_chksum, payloadLen);\r
-\r
-  return (psudo_chksum);\r
-\r
-} /* utilGetIpv4PsudoChkSum */\r
-\r
-\r
-\r
-#endif\r
-typedef struct stats_t\r
-{\r
-        long itx;  //initially generated\r
-       long rx;\r
-       long tx;\r
-       long n_bad;\r
-       long n_new;\r
-        long n_class0_rx;   //count of pkts classified \r
-        long n_class1_rx;   //count of pkts classified \r
-        long n_t1;\r
-        long n_t2;\r
-        long n_t3;\r
-} STATS_T;\r
-\r
-typedef struct head_t\r
-{\r
-       long ip[5];\r
-       long udp[2];\r
-} HEAD_T;\r
-\r
-typedef struct key_t\r
-{\r
-  long src_ip;\r
-  long dst_ip;\r
-  short src_port;\r
-  short dst_port;\r
-} KEY_T;\r
-\r
-unsigned char mac0[]={0x00,0x01,0x02,0x03,0x04,0x05}; //interface 0\r
-unsigned char mac1[]={0x00,0x01,0x02,0x03,0x04,0x06}; //interface 1\r
-nwalIpAddr_t OurIp0={ 10, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
-nwalIpAddr_t OurIp1={ 10, 0, 1, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
-\r
-#if 1  //goes with real tx (to laptop) \r
-unsigned char real_mac_header[]={0xd4,0xbe,0xd9,0x00,0xd3,0x7e,\r
-                      0x00,0x01,0x02,0x03,0x04,0x05,\r
-                      0x08,0x00};\r
-unsigned char real_ip_addr[]={0xa,0x00,0x00,0x64,0xa,0x0,0x0,0xa};\r
-#endif\r
-\r
-#if 0  //goes with loopback\r
-unsigned char mac_header[]={0x00,0x01,0x02,0x03,0x04,0x05, \r
-                      0x00,0x11,0x22,0x33,0x44,0x55,\r
-                      0x08,0x00};\r
-#endif\r
-#define NE 65536 \r
-HEAD_T *nat;\r
-\r
-#define NP 5000\r
-int n_pkt = NP;\r
-STATS_T stats;\r
-\r
-Trie * P_trie;\r
-HEAD_T pkts[NP];\r
-#define PERSLOW  10  //% of pkts that will not be fastpath'd \r
-int perslow= PERSLOW;\r
-\r
-/*******************************************\r
- *************NETAPI OBJECTS***************\r
- *****************************************/\r
-Pktlib_HeapHandle OurHeap;\r
-PKTIO_HANDLE_T *our_chan;\r
-PKTIO_HANDLE_T *netcp_rx_chan;\r
-PKTIO_HANDLE_T *netcp_tx_chan;\r
-PKTIO_CFG_T our_chan_cfg={PKTIO_RW, PKTIO_LOCAL, PKTIO_Q_ANY, 8};\r
-PKTIO_CFG_T netcp_rx_cfg={PKTIO_R, PKTIO_NA, PKTIO_NA, 8};\r
-PKTIO_CFG_T netcp_tx_cfg={PKTIO_W, PKTIO_NA, PKTIO_NA, 8};\r
-\r
-void house(NETAPI_SCHED_HANDLE_T *s);\r
-NETAPI_T netapi_handle;\r
-NETAPI_SCHED_HANDLE_T * our_sched;\r
-NETAPI_SCHED_CONFIG_T our_sched_cfg={\r
-  NETAPI_SCHED_DURATION|NETAPI_SCHED_CBV, 0, house, 500  //every 500 poll loops\r
-};\r
-void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats);\r
-NETAPI_TIMER_GROUP_HANDLE_T ourTimerBlock; \r
-NETAPI_TIMER_T t1;\r
-NETAPI_TIMER_T t2;\r
-NETAPI_TIMER_T t3;\r
-\r
-void our_timer_cb( NETAPI_TIMER_GROUP_HANDLE_T th,\r
-        int n_fired,     //# timers fired\r
-        NETAPI_TIMER_LIST_T fired_list,\r
-        uint64_t currentTime);\r
-\r
-NETCP_CFG_IP_T ip_rule0;\r
-NETCP_CFG_IP_T ip_rule1;\r
-NETCP_CFG_CLASS_T class_0;\r
-NETCP_CFG_CLASS_T class_1;\r
-\r
-NETCP_CFG_CLASSIFIER_T class_0_cfg=\r
-{\r
-   NETCP_CFG_CLASS_TYPE_L4,\r
-   {\r
-       {0,0, NWAL_APP_PLOAD_PROTO_UDP, {2500}}\r
-   }\r
-};\r
-\r
-NETCP_CFG_CLASSIFIER_T class_1_cfg=\r
-{\r
-   NETCP_CFG_CLASS_TYPE_L4,\r
-   {\r
-        {0,0, NWAL_APP_PLOAD_PROTO_UDP, {2502}}\r
-   }\r
-};\r
-\r
-PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};\r
-\r
-/*************************END NETAPI OBJECTS***********************/\r
-\r
-#define START_SRC_IP 0x0a00000a\r
-#define DST_IP       0xc0a80001\r
-#define NEW_START_SRC_IP 0x9eda000a\r
-#define DST_PORT 0x555 \r
-#define START_SRC_PORT 0x1234\r
-#define NEW_START_SRC_PORT 100\r
-void update_header(HEAD_T * p_head, int len)\r
-{\r
-   unsigned char *p = (unsigned char *) &p_head->udp[1];\r
-   len -= (20+14);\r
-   /* update ip checksum */\r
-   /* update udp checksum */\r
-   /* update length */\r
-   *p= (len&0xff00)>>8;\r
-   *(p+1) = len&0xff;\r
-}\r
-\r
-#if 0\r
-void gen_pkts(int np)\r
-{\r
-int i;\r
-int ip = START_SRC_IP &0xff;\r
-int port= START_SRC_PORT;\r
-//HEAD_T temp={{0x25000200,0xdead0000,0x80110000,START_SRC_IP,DST_IP},\r
-//             {START_SRC_PORT<<16|DST_PORT,0x01ec<<16|0x0000}};\r
-HEAD_T temp;\r
-memcpy(&temp,&testPkt[0],sizeof(HEAD_T));\r
-\r
-for(i=0;(i<np) && (i<NP);i++)\r
-  {\r
-       memcpy(&pkts[i],&temp,sizeof(temp));\r
-       update_header(&pkts[i],512);      /* update checksums etc */\r
-       /* change template for new pkt */\r
-       ip+=1;\r
-       if(ip>254) {(ip=START_SRC_IP&0xff); port+=1; }\r
-       temp.ip[3] = htonl((START_SRC_IP&0xffffff00)| ip);\r
-       temp.udp[0] = htonl( (temp.udp[0]&0xffff0000)| port);\r
-       temp.udp[1] = htonl(temp.udp[1]);\r
-     \r
-  }\r
-  n_pkt=np;\r
-}\r
-#endif\r
-\r
-void build_table(Trie * p_trie)\r
-{\r
-int i;\r
-int sport=NEW_START_SRC_PORT; \r
-HEAD_T temp,temp2;\r
-KEY_T key;\r
-\r
-memcpy(&temp,&testPkt[14],sizeof(temp));\r
-\r
- //insert entry into trie\r
-key.src_ip = temp.ip[3];\r
-key.dst_ip = temp.ip[4];\r
-key.src_port= (temp.udp[0]&0xffff0000)>>16;\r
-key.dst_port= (temp.udp[0]&0x0000ffff);\r
-trie_insert(p_trie,(char *)&key,sizeof(key), (void *) &nat[0]); //asociate with nat entry 0\r
-\r
-//build nat table\r
-for(i=0;i<100;i++)\r
-{\r
-   memcpy(&temp2,&testPkt[14],sizeof(temp));\r
-   temp2.udp[0] = (temp2.udp[0] & 0xffff0000) |  sport;\r
-   memcpy(&nat[i], &temp2, sizeof(temp2));\r
-   sport+= 1;\r
-}\r
-}\r
-\r
-//===========stub transmitter==================\r
-void send_pkt(Ti_Pkt *pkt, int len)\r
-{\r
-//just free pkt.  Don't send\r
-Pktlib_freePacket((Ti_Pkt*)pkt);\r
-       return;\r
-}\r
-\r
-//==========stub slow path============\r
-void slow_path(Ti_Pkt *pkt, int len)\r
-{\r
-// debug: check descriptor for validity by verifying that desciptor link field is null as expected\n");\r
-         {Ti_Pkt * k= Pktlib_getNextPacket(pkt); if(k != 0) {printf(" slowpath, nexpkt != NULL");}}\r
-//just free pkt\r
-Pktlib_freePacket((Ti_Pkt*)pkt);\r
-       return;\r
-}\r
-/* check header */\r
-struct LastPktInfo\r
-{\r
-int iface;\r
-int ipcsum;\r
-int l4csum;\r
-} ;\r
-static struct LastPktInfo lpInfo;\r
-\r
-int check_header(HEAD_T * p_head, PKTIO_METADATA_T * p_meta)\r
-{\r
-if (NWAL_RX_FLAG1_META_DATA_VALID & p_meta->u.rx_meta->rxFlag1)\r
-{\r
-lpInfo.iface = ((unsigned int)p_meta->u.rx_meta->appId) &0xff; //last byte is interface num\r
-lpInfo.ipcsum =(p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_MASK )== NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_ACK ? 1 : 0;\r
-lpInfo.l4csum = (p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_MASK )== ((NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_ACK) << NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_SHIFT) ? 1 : 0; \r
-if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_CLASS)\r
-{\r
-  int c= ((unsigned int)p_meta->u.rx_meta->appId >>8)&0xffff;\r
-  if (c==0) stats.n_class0_rx +=1;\r
-  else if (c==1) stats.n_class1_rx +=1;\r
-  else printf("**NET_TEST RX -unknown class: %x\n",  p_meta->u.rx_meta->appId);\r
-}\r
-}\r
-\r
- return 1;\r
-}\r
-\r
-#define PKT_LEN 1400\r
-void test_alloc_free(int n)\r
-{\r
-int i;\r
-Ti_Pkt * b;\r
-\r
-for(i=0;i<n;i++)\r
-{\r
-  b=Pktlib_allocPacket(OurHeap,PKT_LEN);\r
-  Pktlib_freePacket(b);\r
-}\r
-}\r
-/*-----------test driver: gen an input pkt------- */\r
-//char buffer[sizeof(HEAD_T)+PKT_LEN];\r
-Ti_Pkt * get_pkt(int n, unsigned int *p_len)\r
-{\r
-   int ind;\r
-   long long temp;\r
-   Ti_Pkt * b;\r
-   char * buffer;\r
-   unsigned int len;\r
-\r
-  if (pktloopback==0)\r
-  {\r
-       if (n>=4) return NULL;   //just gen pkts to warm swtich, so that it knows\r
-                                //our mac is valid\r
-  }  \r
-  b=Pktlib_allocPacket(OurHeap,PKT_LEN);\r
-  if (!b) \r
-    {printf("net_test: get_pkt() heap empty!! %d pkts gen'd %d \n", n); return NULL;};\r
-\r
-    //debug - way to validate descriptor\r
-    {Ti_Pkt* k= Pktlib_getNextPacket(b); \r
-         if(k != 0) {printf(" genpkt, nexpkt != NULL");}}\r
-\r
-\r
-   //get pointer to buffer area of packet\r
-   Pktlib_getDataBuffer(b,(uint8_t**)&buffer,&len);\r
-\r
-#if 0 \r
-if (pktloopback==0)\r
-{\r
-   temp = (long long) rand();\r
-   temp *= PKT_LEN;\r
-   temp /= RAND_MAX;\r
-   temp +=2;\r
-   *p_len = (int) temp; \r
-   *p_len = *p_len &0xfffffffe;\r
-   temp = (long long) rand();\r
-   temp *= n_pkt;\r
-   temp /= RAND_MAX;\r
-   ind = (int) temp;\r
-   update_header(&pkts[ind],*p_len);\r
-   //printf("get pkt:%d %d ind=%d len=%d\n",RAND_MAX, rand(),ind, *p_len);\r
-    memcpy(&buffer[0], &mac_header[0],14);\r
-    memcpy(&buffer[14],(char*)&pkts[ind],sizeof(HEAD_T)); \r
-}\r
-else\r
-#endif\r
-\r
-   //copy test packet into buffer\r
-{\r
-    memcpy(&buffer[0], &testPkt[0],TEST_PKT_LEN);\r
-    *p_len = TEST_PKT_LEN;\r
-}\r
-    return b; \r
-}\r
-\r
-\r
-/******************************************************/\r
-/******************PKT RECEIVE HANDLER *************************/\r
-/******************************************************/\r
-void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],\r
-                         PKTIO_METADATA_T meta[], int n_pkts,\r
-                         uint64_t ts )\r
-{\r
-int i;\r
-int len;\r
-int p;\r
-HEAD_T * p_res;\r
-Ti_Pkt * tip;\r
-unsigned int templen;\r
-int err;\r
-KEY_T key;\r
-char * p_pkt;\r
-HEAD_T * p_head;\r
-HEAD_T temp_head;\r
-\r
-    p_head=&temp_head;\r
-\r
-    //debug\r
-#if 0\r
-    if (n_pkts != TX_BURST) {\r
-      printf("recv_cb, txsofar=%d rxsofar=%d  np = %d, NOT %d\n", \r
-             stats.itx, stats.rx, n_pkts,TX_BURST);\r
-      our_stats_cb(netapi_handle,NULL);\r
-    }\r
-#endif\r
-    //test_alloc_free(7);\r
-    //printf("recv start\n");\r
-\r
-   /* loop over received pkts */\r
-   for(i=0;i<n_pkts;i++)\r
-   {\r
-       tip = p_recv[i];\r
-       Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen\r
-       len = Pktlib_getPacketLen(tip);//real length\r
-\r
-         //debug: validate descriptor */\r
-         if(Pktlib_getNextPacket(tip) != 0) {printf(" rcv_cb, nexpkt != NULL");}\r
-        //debug printf("recv pkt, len=%d %d\n", len, templen);\r
-       stats.rx+=1;\r
-\r
-#ifdef DEBUG_DESC\r
-   if (stats.rx<16){printf(">rx dmp.."); dump_descr((long *) tip, stats.rx);}\r
-   else if (stats.rx>99) {printf(">rx dmp.."); dump_descr((long *) tip,stats.rx);}\r
-#endif\r
-\r
-\r
-       /* check header */\r
-       memcpy(p_head,&p_pkt[14],sizeof(HEAD_T));\r
-       if (!check_header(p_head,&meta[i])) { \r
-               stats.n_bad+=1;Pktlib_freePacket(tip); continue;\r
-       }\r
-\r
-       /* lookup flow */\r
-       key.src_ip = p_head->ip[3];\r
-       key.dst_ip = p_head->ip[4];\r
-       key.src_port= (p_head->udp[0]&0xffff0000)>>16;\r
-       key.dst_port= (p_head->udp[0]&0x0000ffff);\r
-       p_res= (HEAD_T *) trie_lookup(P_trie, (char *) &key, sizeof(key));\r
-       if (!p_res) { stats.n_new+=1;  slow_path(tip, len); continue;}\r
-\r
-       /* copy header */\r
-       memcpy((char *) p_head, (char *) p_res, sizeof(HEAD_T));\r
-\r
-       memcpy(&p_pkt[14],p_head,sizeof(HEAD_T));\r
-        /* update_mac(&p_pkt[0]);  */\r
-\r
-       /* 'simulate' send pkt */\r
-       send_pkt(tip,len);\r
-       stats.tx+=1;\r
-    }\r
-    //printf("recv done\n");\r
-}\r
-\r
-//timer callback \r
-void our_timer_cb( NETAPI_TIMER_GROUP_HANDLE_T th,\r
-        int n_fired,     //# timers fired\r
-        NETAPI_TIMER_LIST_T fired_list,\r
-        uint64_t currentTime)\r
-{\r
-int i;\r
-NETAPI_TIMER_T tx;\r
-int cookie;\r
-int err;\r
-unsigned long long et;\r
-//DEBUGprintf("TIMER CALLBACK @ %lld %d timers\n", currentTime, n_fired);\r
-tx = netapi_TimerGetFirst(fired_list);\r
-for(i=0;i<n_fired;i++)\r
-{\r
-  cookie = (int) netapi_TimerGetCookie(tx);\r
-  et =  netapi_TimerGetTs(tx); //debug\r
-  //DEBUGprintf("   timer %d - cookie = %d expected ts=%lld (delta=%lld)\n", i, cookie, et, currentTime-et);\r
-  if (cookie ==1)\r
-  {  \r
-     stats.n_t1+=1;\r
-     t1 = netapi_TimerGroupStartTimer(\r
-        th,\r
-        (void *) 1,\r
-        100LL,  //timer group tics\r
-        &err);\r
-  }\r
-  else if (cookie ==2)\r
-  {\r
-      stats.n_t2+=1;\r
-      t2 = netapi_TimerGroupStartTimer(\r
-        th,\r
-        (void *) 2,\r
-        200LL,  //timer group ticks\r
-        &err);\r
-  }\r
-  else\r
-  {\r
-    stats.n_t3+=1;\r
-    t3 = netapi_TimerGroupStartTimer(\r
-        th,\r
-        (void *) 3,\r
-        300LL,  //timer group ticks\r
-        &err);\r
-    //cancel 1 and restart 1\r
-   netapi_TimerGroupCancel(th,t1,&err);\r
-   t1 = netapi_TimerGroupStartTimer(\r
-        th,\r
-        (void *) 1,\r
-        100LL,  //timer group ticks\r
-        &err);\r
- }\r
-  tx = netapi_TimerGetNext(fired_list,tx); \r
-}\r
-}\r
-\r
-\r
-static int np2process = NP;\r
-/******************************************************\r
- * stats callback\r
- *******************************************************/\r
-void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats)\r
-{\r
-uint32_t numFreeDataPackets;\r
-uint32_t numZeroBufferPackets;\r
-uint32_t numPacketsinGarbage;\r
-\r
-printf("stats @ %lld\n", netapi_getTimestamp());\r
-printf("netcp_tx_handle check %x\n", netcp_tx_chan->back);\r
-printf("itx=%d rx=%d tx=%d bad=%d slow=%d rx_class0=%d rx_class1=%d n_t1=%d n_t2=%d n_t3=%d\n",stats.itx, stats.rx, stats.tx, stats.n_bad, stats.n_new,stats.n_class0_rx, stats.n_class1_rx, stats.n_t1, stats.n_t2,stats.n_t3);\r
-\r
-if(pPaStats)\r
-{\r
-       printf("C1 number of packets:           %d\n", pPaStats->classify1.nPackets);\r
-       printf("C1 number IPv4 packets:         %d\n", pPaStats->classify1.nIpv4Packets);\r
-       //printf("C1 number llc/snap fail:        %d\n", pPaStats->classify1.nLlcSnapFail);\r
-       printf("C1 number table matched:        %d\n", pPaStats->classify1.nTableMatch);\r
-       printf("C1 number failed table matched: %d\n", pPaStats->classify1.nNoTableMatch);\r
-       printf ("C1 number of parse fail:        %d\n",pPaStats->classify1.nParseFail);\r
-       printf("C1 number of command failures:  %d\n", pPaStats->classify1.nCommandFail);\r
-       printf("C1 number invalid reply dests:  %d\n", pPaStats->classify1.nInvalidComReplyDest);\r
-       printf ("C1 number of silent discard:    %d\n",pPaStats->classify1.nSilentDiscard);\r
-       printf("C1 number of invalid control:   %d\n", pPaStats->classify1.nInvalidControl);\r
-       printf ("C1 number of invalid states:    %d\n",pPaStats->classify1.nInvalidState);\r
-       printf ("C1 number of system fails:      %d\n",pPaStats->classify1.nSystemFail);\r
-       printf ("C2 number parse failed  :      %d\n",pPaStats->classify2.nParseFail);\r
-       printf ("C2 number Invld Header  :      %d\n",pPaStats->classify2.nInvldHdr);\r
-       printf ("C2 number udp           :      %d\n",pPaStats->classify2.nUdp);\r
-       printf ("C2 number tcp           :      %d\n",pPaStats->classify2.nTcp);\r
-       printf ("C2 number cmd fail      :      %d\n",pPaStats->classify2.nCommandFail);\r
-       printf ("C2 number silent drop   :      %d\n",pPaStats->classify2.nSilentDiscard);\r
-       printf ("C2 number invalid cntrl :      %d\n\n",pPaStats->classify2.nInvalidControl);\r
-}\r
-Pktlib_getHeapStats(OurHeap, &numFreeDataPackets,\r
-                             &numZeroBufferPackets, &numPacketsinGarbage);\r
-printf("heap stats>  #free=%d #zb=%d #garbage=%d\n", numFreeDataPackets,\r
-                                numZeroBufferPackets, numPacketsinGarbage);\r
-//debug = dump timer polling stats\r
-dump_poll_stats();\r
-\r
-\r
-}\r
-\r
-//******************************************************\r
-//use scheduling housekeeping callback to generate pkts\r
-//******************************************************\r
-void house(NETAPI_SCHED_HANDLE_T * s)\r
-{\r
-Ti_Pkt * tip;\r
-unsigned int len;\r
-nwalTxPktInfo_t meta_tx={0};\r
-PKTIO_METADATA_T meta = {PKTIO_META_TX,0};\r
-int err;\r
-static int house_pkts_gened=0;\r
-int p;\r
-unsigned char * pIpHdr,* pData;\r
-unsigned int vv1,vv2,vv3;\r
-\r
-for(p=0;p<TX_BURST;p++) {  \r
-//reguest stats \r
-if ((house_pkts_gened>0) && (! (house_pkts_gened%400)) )\r
-{\r
-   printf("net_test> request stats at n=%d \n",house_pkts_gened);\r
-   netcp_cfgReqStats(netapi_handle, our_stats_cb, 0,&err); \r
-   if (err!=0) {printf("stats req failed\n");}\r
-}\r
-\r
-\r
-  if (house_pkts_gened >= np2process+ 100)\r
-  {\r
-     //shutdown\r
-     netapi_schedShutdown(s,NULL,&err);\r
-     continue;\r
-  }\r
-\r
-  else if (house_pkts_gened >= np2process) { house_pkts_gened+=1;  continue;}\r
-  \r
-\r
-/* manufacture a pkt to transmit */\r
-   tip = get_pkt(house_pkts_gened, &len);\r
-   if(!tip) { house_pkts_gened +=1; continue; }\r
-\r
-\r
-   /* set the pkt length */\r
-   vv1 = netapi_timing_start();\r
-   Pktlib_setPacketLen(tip, len);\r
-\r
-   /* set up meta data */\r
-    meta_tx.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM | NWAL_TX_FLAG1_DO_UDP_CHKSUM);\r
-    meta_tx.startOffset = 0;\r
-    meta_tx.pktLen = len;\r
-    meta_tx.ipOffBytes = TEST_PKT_IP_OFFSET_BYTES;\r
-    meta_tx.l4OffBytes = TEST_PKT_UDP_OFFSET_BYTES;\r
-    meta_tx.l4HdrLen = TEST_PKT_UDP_HDR_LEN;\r
-    meta_tx.ploadOffBytes = TEST_PKT_PLOAD_OFFSET_BYTES;\r
-    meta_tx.ploadLen = TEST_PAYLOAD_LEN;\r
-\r
-    Pktlib_getDataBuffer(tip,&pData,&len);\r
-    pIpHdr = pData + meta_tx.ipOffBytes;\r
-    meta_tx.pseudoHdrChecksum =\r
-        test_utilGetIpv4PsudoChkSum(pIpHdr,(TEST_PAYLOAD_LEN+TEST_PKT_UDP_HDR_LEN));\r
-\r
-   /* post it to netcp tx channel*/\r
-   meta.u.tx_meta=&meta_tx;\r
-#ifdef DEBUG_DESC\r
-   if (house_pkts_gened<16) dump_descr((long *) tip, house_pkts_gened);\r
-   else if (house_pkts_gened>99) dump_descr((long *) tip,house_pkts_gened);\r
-#endif\r
-   vv2= netapi_timing_stop();\r
-   pktio_send(netcp_tx_chan,tip,&meta,&err);\r
-   vv3= netapi_timing_stop();\r
-   printf("pktio send. full=%d metadata=%d pktio_send=%d\n", vv3-vv1,  vv2-vv1,  vv3-vv2);\r
-   if (err == 0) stats.itx +=1;\r
-\r
-   house_pkts_gened +=1;\r
- }\r
-}\r
-\r
-\r
-/***************************************\r
- ********** test driver*****************\r
- ***************************************/\r
-int main(int argc, char **argv)\r
-{\r
-int err;\r
-rlim_t oss,ss = 1024*1024;\r
-struct rlimit rl;\r
-\r
-err= getrlimit(RLIMIT_STACK,&rl);\r
-if (!err) printf(" stack limit = %d\n",rl.rlim_cur); else printf("getrlimit failed\n");\r
-#if 0\r
-rl.rlim_cur = ss;\r
-err=setrlimit(RLIMIT_STACK,&rl);\r
-if (!err) printf("set stack to %d\n",rl.rlim_cur); else printf("setrlimit failed\n");\r
-#endif\r
-\r
-if (argc>=2)  np2process = atoi(argv[1]);\r
-if (np2process<0) np2process = NP; /* default */\r
-if (argc==3)  perslow = atoi(argv[2]);\r
-if ((perslow<0)||(perslow>100)) perslow=PERSLOW;//default\r
-if (argc>3) {printf("net_test  <no of pkts to process> <percent slow path>\n"); exit(1);}\r
-\r
-\r
-//real mode, so update our test packet mac header and ip header\r
-if (pktloopback==0)\r
-{\r
-memcpy(&testPkt,&real_mac_header[0],14); //overwrite test pkt mac address\r
-memcpy(&testPkt[26],&real_ip_addr[0],8);//overrite test pkt ip addresses\r
-}\r
-\r
-/*******************************************/\r
-/*************NETAPI STARTUP****************/\r
-/*******************************************/\r
-\r
-/* create netapi */\r
-netapi_handle = netapi_init(NETAPI_SYS_MASTER);\r
-\r
-/* open the main heap */\r
-OurHeap = Pktlib_findHeapByName("netapi");\r
-if (!OurHeap) {printf("findheapbyname fail\n"); exit(1);}\r
-\r
-/* create a pktio channel */\r
-our_chan=pktio_create(netapi_handle,"our1stq",(PKTIO_CB) recv_cb, &our_chan_cfg,&err);\r
-if (!our_chan) {printf("pktio create failed err=%d\n",err); exit(1);}\r
-\r
-/* open netcp default tx, rx queues */\r
-netcp_tx_chan= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);\r
-if (!netcp_tx_chan) {printf("pktio open TX failed err=%d\n",err); exit(1);}\r
-netcp_rx_chan= pktio_open(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);\r
-if (!netcp_rx_chan) {printf("pktio open RX failed err=%d\n",err); exit(1);}\r
-\r
-\r
-/* create scheduler instance */\r
-our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);\r
-if (!our_sched) {printf("sched create failed\n"); exit(1);}\r
-\r
-/* add mac intefaces */\r
-netcp_cfgCreateMacInterface(\r
-                  netapi_handle,\r
-                  &mac0[0],\r
-                  0,0,\r
-                  (NETCP_CFG_ROUTE_HANDLE_T)  NULL,\r
-                  (NETCP_CFG_VLAN_T ) NULL ,  //future\r
-                  1, \r
-                  &err);\r
-if (err) {printf("addmac0 failed %d\n",err); exit(1); } \r
-\r
-//attach an IP to this interface\r
-ip_rule0=netcp_addIp(\r
-                  netapi_handle,\r
-                  0,\r
-                  nwal_IPV4,\r
-                  &OurIp0,\r
-                  NULL,  //all IP\r
-                  (NETCP_CFG_ROUTE_HANDLE_T) NULL,\r
-                  &err\r
-                  );\r
-if (err) {printf("addip0 failed %d\n",err); exit(1); } \r
-#if 1\r
-//create a 2nd mac instance\r
-netcp_cfgCreateMacInterface(\r
-                  netapi_handle,\r
-                  &mac1[0],\r
-                  1,1,\r
-                  (NETCP_CFG_ROUTE_HANDLE_T)  NULL,\r
-                  (NETCP_CFG_VLAN_T ) NULL ,  //future\r
-                  1,\r
-                  &err);\r
-if (err) {printf("addmac1 failed %d\n",err); exit(1); }\r
-\r
-//attach an IP to this interface\r
-ip_rule1=netcp_addIp(\r
-                  netapi_handle,\r
-                  1,\r
-                  nwal_IPV4,\r
-                  &OurIp1,\r
-                  NULL,  //all IP\r
-                  (NETCP_CFG_ROUTE_HANDLE_T) NULL,\r
-                  &err\r
-                  );\r
-if (err) {printf("addip1 failed %d\n",err); exit(1); }\r
-\r
-//attach 2 classifiers to iface 0, ip0\r
-class_0_cfg.u.c_l4.ip = ip_rule0;\r
-class_0 =  netcp_cfgAddClass(netapi_handle,\r
-                             &class_0_cfg,\r
-                             NULL,\r
-                             NETCP_CFG_ACTION_TO_SW,\r
-                            &err);\r
-if (err) {printf("addclass0 failed %d\n",err); exit(1);}\r
-\r
-class_1_cfg.u.c_l4.ip = ip_rule0;\r
-class_1 =  netcp_cfgAddClass(netapi_handle,\r
-                             &class_1_cfg,\r
-                             NULL,\r
-                             NETCP_CFG_ACTION_TO_SW,\r
-                             &err);\r
-if (err) {printf("addclass1 failed %d\n",err); exit(1);}\r
-\r
-\r
-#endif\r
-\r
- ourTimerBlock = netapi_TimerGroupCreate(\r
-        netapi_handle,\r
-        "our1sttimer",\r
-        our_timer_cb,\r
-        0,    //1 if timers local to thread\r
-        0,    //1 if expect to cancel\r
-        netapi_getTicksPerSec()/1000,  /* 1 msc resolution for these timers */\r
-        netapi_getTicksPerSec()/5000, /* would like .5 msc tolerence */\r
-        10,  //small # of timers to test garbage collection\r
-        &err);\r
-if (err) {printf("timergroupcreate failed %d\n",err); exit(1);}\r
-\r
-//start a couple of timers \r
-t1 = netapi_TimerGroupStartTimer(\r
-        ourTimerBlock,\r
-        (void *) 1,\r
-        100LL,  //timer group ticks\r
-        &err);\r
-if (err) {printf("timerstart failed %d\n");}\r
-t2 = netapi_TimerGroupStartTimer(\r
-        ourTimerBlock,\r
-        (void *) 2,\r
-        200LL,  //timer group ticks\r
-        &err);\r
-if (err) {printf("timerstart failed %d\n");}\r
-t3 = netapi_TimerGroupStartTimer(\r
-        ourTimerBlock,\r
-        (void *) 3,\r
-        300LL,  //timer group ticks\r
-        &err);\r
-if (err) {printf("timerstart failed %d\n");}\r
-\r
-\r
-/*********************************************/\r
-/*****************end NETAPI STARTUP**********/\r
-/*********************************************/\r
-\r
-\r
-/********************************************\r
-* Basic pkt loopback test\r
-*********************************************/\r
-\r
-\r
-/* create TRIE */\r
-P_trie = trie_new();\r
-if (!P_trie) {printf("trie alloc failed\n"); exit(1);}\r
-\r
-nat = (HEAD_T *) malloc(NE * sizeof(HEAD_T));\r
-if (!nat) {printf("malloc of nat table failed\n"); exit(1);}\r
-\r
-//gen_pkts(np2process<NP ? np2process:NP);\r
-n_pkt= np2process;\r
-\r
-/* build table */\r
-build_table(P_trie);\r
-\r
-\r
-/* processing loop: get pkt, check it, look up in table, copy new header,\r
-   send packet */\r
-srand((unsigned) np2process);\r
-\r
-\r
-/*********************************************/\r
-/**************Entry point into scheduler ****/\r
-/*********************************************/\r
-netapi_schedWaitForEvents(our_sched, &err);\r
-\r
-/* done */\r
-printf("done: itx=%d rx=%d tx=%d bad=%d slow=%d\n",stats.itx, stats.rx, stats.tx, stats.n_bad, stats.n_new);\r
-our_stats_cb(netapi_handle, NULL);\r
-\r
-//delete Classifiers\r
-netcp_cfgDelClass(netapi_handle, class_0, &err); \r
-netcp_cfgDelClass(netapi_handle, class_1, &err); \r
-\r
-//delete IPs and MAC Interfacess\r
-netcp_cfgDelIp(netapi_handle, 0, 0, NULL, NULL, ip_rule0, &err);\r
-netcp_cfgDelIp(netapi_handle, 1, 0, NULL, NULL, ip_rule1, &err);\r
-netcp_cfgDelMac(netapi_handle,0,&err);\r
-netcp_cfgDelMac(netapi_handle,1,&err);\r
-\r
-//close pktio channels we opened\r
-pktio_close(netcp_tx_chan ,&err);\r
-pktio_close(netcp_rx_chan ,&err);\r
-\r
-//clear pktio channel we created\r
-pktio_control(our_chan, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);\r
-//delete pktio channels we created\r
-pktio_delete(our_chan, &err);\r
-\r
-netapi_shutdown(netapi_handle);\r
-\r
-}\r
+/******************************************************************************
+ * File: net_test.c
+ * Purpose: test app for netapi
+ ******************************************************************************
+ * FILE:  net_test.c
+ * 
+ * DESCRIPTION:  netapi user space transport
+ *               library  test application
+ * 
+ * REVISION HISTORY:
+ *
+ *  Copyright (c) Texas Instruments Incorporated 2013
+ * 
+ *  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 "net_test.h"
+#include "ti/drv/nwal/test/fw_rm.h"
+#include <signal.h>
+#include <pthread.h>
+
+extern int QUIT;
+extern netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
+extern paSysStats_t netcp_stats;
+
+
+netTestConfig_t netTestCfg;
+static netTestConfigFile_t config_file;
+
+char    input_file_name[] = "/etc/netapi/net_test_config.txt";
+nwal_RetValue       nwalRetVal;
+Pktlib_HeapHandle   ourHeap;
+
+PKTIO_HANDLE_T *netcp_rx_chan;
+PKTIO_HANDLE_T *netcp_tx_chan_no_crypto;
+PKTIO_HANDLE_T *netcp_tx_chan_esp;
+PKTIO_HANDLE_T *netcp_tx_chan_ah;
+PKTIO_HANDLE_T *netcp_sb_tx_chan;
+PKTIO_HANDLE_T *netcp_sb_rx_chan;
+
+PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
+PKTIO_CFG_T netcp_rx_cfg2={PKTIO_RX, (PKTIO_GLOBAL|PKTIO_PKT), PKTIO_Q_ANY, 8};
+PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
+PKTIO_CFG_T netcp_sb_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
+PKTIO_CFG_T netcp_sb_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
+
+NETCP_CFG_IP_T ip_rule[NET_TEST_MAX_IP];
+NETCP_CFG_MACIF_T mac[NET_TEST_MAX_MAC];
+
+#ifdef netTest_DSP_FASTPATH
+PKTIO_HANDLE_T *dsp_pktio_channels[CPU_NUM_REM_FAST_PATH_CORES];
+NETCP_CFG_CLASS_T dsp_classifers[CPU_NUM_REM_FAST_PATH_CORES];
+NETCP_CFG_FLOW_HANDLE_T dsp_flow_handles[CPU_NUM_REM_FAST_PATH_CORES];
+#endif
+NETCP_CFG_EXCEPTION_PKT_T expPkt_appid;
+
+Trie *p_trie_sa_rx;
+Trie *p_trie_sa_tx;
+
+
+/*******************************************
+ *************NETAPI OBJECTS***************
+ *****************************************/
+static NETAPI_CFG_T our_netapi_default_cfg=
+{
+    TUNE_NETAPI_PERM_MEM_SZ,
+    128,  //start of packet offset for hw to place data on rx for default flow
+    TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
+    TUNE_NETAPI_NUM_GLOBAL_DESC,        //total we will use
+    TUNE_NETAPI_DEFAULT_NUM_BUFFERS,   //#descriptors+buffers in default heap
+    64, //#descriptors w/o buffers in default heap
+    TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128,  //size of buffers in default heap
+    128   ,  //tail room
+    256      //extra room
+};
+
+NETAPI_T netapi_handle;
+NETAPI_SCHED_HANDLE_T * our_sched;
+#ifdef netTest_MULTI_THREAD
+NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
+#endif
+NETAPI_SCHED_CONFIG_T our_sched_cfg={
+  NETAPI_SCHED_DURATION|NETAPI_SCHED_CBV, 0, house, 5000000  //every 5000000 poll loops
+};
+
+netTestSA_t sa_info[MAX_SEC_INDEX];
+NETCP_CFG_IPSEC_POLICY_T rx_policy[MAX_SEC_INDEX];
+
+
+
+
+
+
+/********************************************************************
+ * FUNCTION PURPOSE:  Utility function to flip and packet and send
+ *                    it back to its source.
+ ********************************************************************
+ * DESCRIPTION:   Utility function to flip and packet and send
+ *                    it back to its source.
+ ********************************************************************/
+void flip_and_send_pkt(Ti_Pkt *tip,  unsigned char * p_pkt, int len, int flag, uint16_t enet_port)
+{
+    unsigned char mac_temp[6];
+    unsigned char ip_temp[4];
+    unsigned char new_dest_port[2]={0x75,0x30};  // 30000
+    uint16_t dest_udp_port_config = 0;
+    uint16_t blah; 
+    uint16_t i=1;   /* for testing only */
+
+    uint8_t *p_spi; 
+    netTestSA_t * p_sa_info;
+    netTestSA_t *p_sa_info_tx;
+    uint8_t p_iv[16];
+    uint8_t p_add[8];
+    Cppi_HostDesc*          pPloadDesc;
+    uint8_t ah_len;
+    uint32_t tunnel_id;
+    nwalLocCxtInfo_t    nwalLocCxt;
+    netTestHead_T * p_head;
+    netTestHead_T temp_head;
+    int pkt_type;
+
+#ifdef netTest_MULTI_THREAD
+    int coreid=Osal_nwalGetProcId(); //who we are(thread local)
+        //int coreid = our_core;
+#else
+int coreid=0;
+#endif
+              // netTest_utilDumpBuffer((long*)p_pkt,len);
+    Pktlib_setPacketLen(tip,len);
+    //flip the mac address
+    memcpy(&mac_temp,&p_pkt[0],6);
+    memcpy(&p_pkt[0],&p_pkt[6],6);
+    memcpy(&p_pkt[6],&mac_temp,6);
+    //memcpy(&p_pkt[0],real_mac_header,6); //for testing to wireshark pc
+
+    //flip the ip  (outer in case of ipsec)
+    memcpy(&ip_temp, &p_pkt[netTest_MAC_HEADER_LEN+12],4);
+    memcpy(&p_pkt[netTest_MAC_HEADER_LEN+12],&p_pkt[netTest_MAC_HEADER_LEN+12+4],4);
+    memcpy(&p_pkt[netTest_MAC_HEADER_LEN+12+4],&ip_temp,4);
+
+    p_head=&temp_head;
+
+    //inner ip &udp for ipsec
+    if (flag) 
+    {
+        memcpy(p_head,&p_pkt[netTest_MAC_HEADER_LEN],sizeof(netTestHead_T));
+
+        if ((p_head->ip[2]&0x0000ff00)==0x00003300)
+        {
+            p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN + 4]);
+            pkt_type = netTest_IPSEC_AH_PKT;
+        }
+        else if ((p_head->ip[2]&0x0000ff00)==0x00003200)
+        {
+            p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
+            pkt_type = netTest_IPSEC_ESP_PKT;
+        }
+        else
+        {
+            netapi_Log("flip_and_send_pkt: un-supported IPSEC protocol\n");
+            Pktlib_freePacket(tip);
+            return;
+        }
+
+        p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa_rx, (char *)p_spi ,4);
+        if (p_sa_info == NULL)
+        {
+            netapi_Log("flip_and_send_pkt(): trie_lookup() failed\n");
+            Pktlib_freePacket(tip);
+            return;
+        }
+        tunnel_id = p_sa_info->tunnel_id;
+        p_sa_info_tx = (netTestSA_t *) trie_lookup(p_trie_sa_tx, (char *)&tunnel_id ,4);
+        if (p_sa_info_tx == NULL)
+        {
+            netapi_Log("flip_and_send_pkt(): trie_lookup() failed\n");
+            Pktlib_freePacket(tip);
+            return;
+        }
+        //just drop non-udp packet
+        if (p_pkt[p_sa_info->tx_payload_info.encOffset+9]!=0x11)
+        {
+            stats[coreid].n_new+=1;Pktlib_freePacket(tip); return;
+        }
+
+        /* flip inner IP */
+        memcpy(&ip_temp, &p_pkt[p_sa_info->tx_payload_info.encOffset+12],4);
+        memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+12],&p_pkt[p_sa_info->tx_payload_info.encOffset+12+4],4);
+        memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+12+4],&ip_temp,4);
+        /* setting udp ports */
+        if (netTestCfg.dest_udp_port_config == 0)
+        {
+            memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+netTest_IP_HEADER_LEN+2],
+                   &p_pkt[p_sa_info->tx_payload_info.encOffset+netTest_IP_HEADER_LEN],2);
+        }
+        else
+        {
+           dest_udp_port_config = htons(netTestCfg.dest_udp_port_config);
+            memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+netTest_IP_HEADER_LEN+2],
+                   &dest_udp_port_config,2);
+        }
+        memset(&p_pkt[p_sa_info->tx_payload_info.encOffset+netTest_IP_HEADER_LEN+6],0,2); //checksum
+
+        if (netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND)
+        {
+            /* inner ip checksum : leave alone, outer ip, set to 0 (we will compute on way out */
+            memset(&p_pkt[netTest_MAC_HEADER_LEN+10],0,2);
+        }
+    }
+    else
+    {
+        /* flip udp port */
+        if (netTestCfg.dest_udp_port_config == 0)
+        {
+            memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+2],
+                   &p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN],2);
+        }
+        else
+        {
+            dest_udp_port_config = htons(netTestCfg.dest_udp_port_config);
+            //memcpy(&p_pkt[netTest_MAC_HEADER_LEN+20+2],&new_dest_port[0],2);
+            memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+2],&dest_udp_port_config,2);
+        }
+
+        memset(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+6],0,2);//0 udp checksum (we will compute on way out)
+    }
+
+    /*IPSEC case */ 
+    if (flag)
+    {
+        if (netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND)
+        //send to crypto for encryption
+        //12 byte auth tag
+        {
+            PKTIO_METADATA_T meta = {PKTIO_META_SB_TX,{0},0};
+            int err;
+            nwalDmTxPayloadInfo_t meta_tx={0};
+            
+            meta.sa_handle = (void*)p_sa_info_tx->tx_tunnel;  //use TX SA APPID
+
+            memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
+            meta_tx.appCtxId = (nwal_AppId)p_sa_info_tx;
+            meta_tx.encSize = len - p_sa_info->tx_payload_info.encOffset -p_sa_info->auth_tag_size;
+            meta_tx.authSize = len - meta_tx.authOffset - p_sa_info->auth_tag_size;
+            meta_tx.pAuthIV=NULL;
+            meta_tx.aadSize=0;
+            meta_tx.pAad=NULL;
+            if (p_sa_info->cipherMode ==  NWAL_SA_EALG_AES_CTR)
+            {
+                memcpy(&p_iv[0], &p_sa_info->key_params->pEncKey[16], 4);
+                memcpy(&p_iv[4], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
+                p_iv[12] = 0;
+                p_iv[13] = 0;
+                p_iv[14] = 0;
+                p_iv[15] = 1;
+                meta_tx.pEncIV = &p_iv[0];
+            }
+            else if ((p_sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) || (p_sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))
+            {
+                memcpy(&p_iv[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
+                meta_tx.pEncIV = &p_iv[0];
+                memcpy(&p_add[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN], 8);
+                meta_tx.pAad= &p_add[0];
+                meta_tx.aadSize = 8;
+            }
+            else if (p_sa_info->authMode == NWAL_SA_AALG_GMAC)
+            {
+                memcpy(&p_iv[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
+                meta_tx.pAuthIV= &p_iv[0];
+                memcpy(&p_add[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN], 8);
+                meta_tx.pAad= &p_add[0];
+                meta_tx.aadSize = 8;
+            }
+            else if (p_sa_info->cipherMode ==  NWAL_SA_EALG_NULL)
+            {
+                meta_tx.pEncIV = NULL;
+            }
+            else
+            {
+                meta_tx.pEncIV = &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN ];
+            }
+            /* post it to netcp sb tx channel*/
+            meta.u.tx_sb_meta=&meta_tx;
+
+            netapi_pktioSend(netcp_sb_tx_chan,tip,&meta,&err);
+        }
+        else
+        {
+            //INFLOW TX, send pkt directly, asking for IP and UDP checksum offloads AND IPSEC to be applied
+            PKTIO_METADATA_T meta = {PKTIO_META_TX,{0},0};
+            int err;
+            nwalTxPktInfo_t meta_tx={0};
+
+            meta.sa_handle = (void*)p_sa_info_tx->tx_tunnel;  //use TX SA APPID
+
+            meta_tx.startOffset = p_sa_info_tx->tx_pkt_info.startOffset;
+            meta_tx.ipOffBytes =p_sa_info_tx->tx_payload_info.encOffset; 
+            meta_tx.l4OffBytes = p_sa_info_tx->tx_pkt_info.l4OffBytes;
+            meta_tx.l4HdrLen = p_sa_info_tx->tx_pkt_info.l4HdrLen;
+            meta_tx.ploadLen = (unsigned) ((p_pkt[meta_tx.l4OffBytes+4]<<8)|p_pkt[meta_tx.l4OffBytes+4+1]) -8 ;
+            meta_tx.saOffBytes=  p_sa_info_tx->tx_pkt_info.saOffBytes;
+            if (pkt_type == netTest_IPSEC_AH_PKT)
+            {
+                memset(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+netTest_IPSEC_AH_FIXED_HDR_SIZE],0,netTest_IPSEC_AH_FIXED_HDR_SIZE);
+                meta_tx.txFlag1 = p_sa_info_tx->tx_pkt_info.txFlag1;
+                meta_tx.saPayloadLen=len-netTest_MAC_HEADER_LEN;   //don't inlcude mac 
+                meta_tx.saAhMacSize = 12;
+                meta_tx.saAhIcvOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE;
+                
+                meta_tx.enetPort = enet_port;
+                 memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+4],&p_sa_info_tx->spi,4);
+            }
+            else if (pkt_type == netTest_IPSEC_ESP_PKT)
+            {
+                meta_tx.txFlag1 = p_sa_info_tx->tx_pkt_info.txFlag1;
+                meta_tx.saPayloadLen=len-netTest_MAC_HEADER_LEN-netTest_IP_HEADER_LEN;   //don't include mac and ip outer header
+                meta_tx.enetPort = 0;
+                 memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN],&p_sa_info_tx->spi,4);
+            }
+            else
+            {
+                printf("flip_and_send_pkt: invalid ESP protocol\n");
+                return;
+            }
+
+            meta_tx.pseudoHdrChecksum =
+            netTest_utilGetIPv4PsudoChkSum(&p_pkt[meta_tx.ipOffBytes],8+ meta_tx.ploadLen);
+
+
+            /* post it to netcp tx channel*/
+            meta.u.tx_meta=&meta_tx;
+#ifdef DEBUG_DESC
+            if (stats[coreid].sec_tx<20) netTest_utilDumpDescr((long *) tip, stats[coreid].sec_tx);
+#endif
+            if ( pkt_type == netTest_IPSEC_ESP_PKT)
+                netapi_pktioSend(netcp_tx_chan_esp,tip,&meta,&err);
+            else if ( pkt_type == netTest_IPSEC_AH_PKT)
+                 netapi_pktioSend(netcp_tx_chan_ah,tip,&meta,&err);
+            stats[coreid].tx +=1;
+            stats[coreid].sec_tx +=1;
+        }
+    }
+    else  //non ipsec send pkt directly, asking for IP and UDP checksum ofload
+    {
+        PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
+        int err;
+        nwalTxPktInfo_t meta_tx2={0};
+        meta2.sa_handle=nwal_HANDLE_INVALID;
+        meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
+        meta_tx2.startOffset = 0;
+        meta_tx2.ipOffBytes = netTest_MAC_HEADER_LEN;
+        meta_tx2.l4OffBytes = netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN;
+        meta_tx2.l4HdrLen = netTest_UDP_HEADER_LEN;
+        meta_tx2.ploadLen = (unsigned) ((p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+4]<<8)|
+                                        p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+4+1]) -8 ;
+        meta_tx2.pseudoHdrChecksum =
+        netTest_utilGetIPv4PsudoChkSum(&p_pkt[netTest_MAC_HEADER_LEN],8+ meta_tx2.ploadLen);
+
+        /* post it to netcp tx channel*/
+        meta2.u.tx_meta=&meta_tx2;
+        netapi_pktioSend(netcp_tx_chan_no_crypto,tip,&meta2,&err);
+        stats[coreid].tx +=1;
+    }
+}
+
+
+/**********************************************************************
+ * FUNCTION PURPOSE:  Sideband Accelerator Callback PKT RECEIVE HANDLER
+ **********************************************************************
+ * DESCRIPTION:   Sideband Accelerator Callback PKT RECEIVE HANDLER
+ *                Handles Decrypt and Encrypt operation callbacks
+ **********************************************************************/
+void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+                         PKTIO_METADATA_T meta[], int n_pkts,
+                         uint64_t ts )
+{
+    int i;
+    int len;
+    int p;
+    netTestHead_T * p_res;
+    Ti_Pkt * tip;
+    unsigned int templen;
+    int err;
+    char * p_pkt;
+    netTestHead_T * p_head;
+    netTestHead_T temp_head;
+    int tag_cmp=0;
+    unsigned int hash[4];
+    uint8_t *p_spi;
+    netTestSA_t *p_sa_info;
+
+#ifdef netTest_MULTI_THREAD
+    int coreid=Osal_nwalGetProcId();  //who we are(thread local)
+#else
+    int coreid=0;
+#endif
+    //nwal_AppId time;
+    unsigned long time, delta_time;
+    /* loop over received pkts */
+    for(i=0;i<n_pkts;i++)
+   {
+        tip = p_recv[i];
+        Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
+        len = Pktlib_getPacketLen(tip);//real length
+
+        /*p_sa_info is for rx context */
+        p_sa_info = (netTestSA_t*)meta[i].u.rx_sb_meta->appCtxId;
+        if (p_sa_info == NULL)
+        {
+            printf("recv_sb_cb(): trie_lookup failed\n");
+            continue;
+        }
+
+        //is this a decrypt (rx_tunnel) complete
+        if ((int)meta[i].u.rx_sb_meta->appId == p_sa_info->rx_tunnel)
+        {
+            //time = hplib_mUtilGetPmuCCNT();
+            //delta_time = time -(unsigned long) meta[i].u.rx_sb_meta->appCtxId;
+            stats[coreid].total_decrypt_time += delta_time;
+            stats[coreid].sb_rx+=1;
+            //copy hash out of meta data (for some reason it needs endian conversion)
+            hash[0]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[0]);
+            hash[1]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
+            hash[2]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
+            hash[3]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
+            if(stats[coreid].sb_rx<=16)
+            {
+                char *tp = (char *) &hash[0];
+                //netTest_utilDumpHeader((long*)p_pkt, stats[coreid].sb_rx, (int)meta[i].u.rx_sb_meta->appId,0);
+            }
+            tag_cmp = memcmp(&p_pkt[len-p_sa_info->auth_tag_size],(char*) &hash[0],p_sa_info->auth_tag_size); //todo, really use meta->authTagLen
+            stats[coreid].n_auth_ok += !(tag_cmp);
+            flip_and_send_pkt(tip, p_pkt, len,1, 0);  //flip packet to echo back and send
+        }
+        //this is an encrypt (tx tunnel) complete
+        else if((int)meta[i].u.rx_sb_meta->appId== p_sa_info->tx_tunnel )
+        {
+            hash[0]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[0]);
+            hash[1]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
+            hash[2]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
+            hash[3]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
+            stats[coreid].sb_tx+=1;
+            if(stats[coreid].sb_tx<=16)
+            {
+                //netTest_utilDumpHeader((long*)p_pkt, stats[coreid].sb_tx, (int)meta[i].u.rx_sb_meta->appId,0);
+            }
+            //put the computed tag in the packet
+             memcpy(&p_pkt[len-p_sa_info->auth_tag_size],(char*)&hash[0],p_sa_info->auth_tag_size); //todo, really use meta->authTagLen
+            {
+                PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
+                nwalTxPktInfo_t meta_tx={0};
+                // now send directly 
+                meta2.sa_handle=nwal_HANDLE_INVALID;
+                meta_tx.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID);//only outer IP header checksum. no udp checksum possible since pkt is already encrypted
+                meta_tx.startOffset = 0;
+                meta_tx.ipOffBytes = netTest_MAC_HEADER_LEN;
+                meta_tx.l4OffBytes = 0;
+                meta_tx.l4HdrLen = 0;
+                meta_tx.ploadLen = 0;
+                time = hplib_mUtilGetPmuCCNT();
+                delta_time = time -(unsigned long) meta[i].u.rx_sb_meta->appCtxId;
+                stats[coreid].total_encrypt_time += delta_time;
+
+                /* post it to netcp tx channel*/
+                meta2.u.tx_meta=&meta_tx;
+                netapi_pktioSend(netcp_tx_chan_esp,tip,&meta2,&err);
+                hplib_cacheWbInv(p_pkt,len);
+                stats[coreid].tx +=1;
+            }
+        }
+        else printf("netapi recv_sb_cb: unknown appiD %x \n",meta[i].u.rx_sb_meta->appId );
+    }
+}
+
+/**********************************************************************
+ * FUNCTION PURPOSE:  Packet receive Callback
+ *
+ **********************************************************************
+ * DESCRIPTION:   packet Receive callback
+ **********************************************************************/
+void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+                         PKTIO_METADATA_T meta[], int n_pkts,
+                         uint64_t ts )
+{
+    int i;
+    int len;
+    int p;
+    netTestHead_T * p_res;
+    Ti_Pkt * tip;
+    unsigned int templen;
+    int err = 0;
+    char * p_pkt;
+    netTestHead_T * p_head;
+    netTestHead_T temp_head;
+    netTestSA_t *p_sa_info;
+    uint8_t *p_spi;
+    uint8_t p_iv[16];
+    uint8_t p_add[8];
+    uint8_t p_add1[1500];
+    int16_t       retVal;
+
+    nwalGlobCxtInfo_t   nwalGlobCxt;
+    nwalLocCxtInfo_t    nwalLocCxt;
+
+    Cppi_HostDesc*          pPloadDesc;
+    int ifno;
+    uint16_t enet_port = 0;
+
+#ifdef netTest_MULTI_THREAD
+    int coreid=Osal_nwalGetProcId();  //who we are(thread local)
+#else
+    int coreid=0;
+#endif
+    p_head=&temp_head;
+
+    /* loop over received pkts */
+    for(i=0;i<n_pkts;i++)
+    {
+        ifno = ((unsigned int)meta[i].u.rx_meta->appId)&0xff;
+        
+        enet_port = meta[i].u.rx_meta->enetPort;
+        tip = p_recv[i];
+
+        Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);/*ignore templen */
+        len = Pktlib_getPacketLen(tip)-4;   /*real length, subtract mac trailer */
+        Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, p_pkt,len);
+        Pktlib_setPacketLen(tip,len);
+
+        if(((unsigned int)meta[i].u.rx_meta->appId) == expPkt_appid)
+        {
+            netapi_Log("recv_cb: received exception packet\n");
+            Pktlib_freePacket(tip);
+            if(((unsigned int)meta[i].u.rx_meta->rxFlag1  & NWAL_RX_IP_FRAGMENT_PKT) ==
+                                             NWAL_RX_IP_FRAGMENT_PKT)
+            {
+                stats[coreid].exceptionPktsFrag+=1;
+            }
+            else
+            {
+                stats[coreid].exceptionPktsOther+=1;
+            }
+            continue;
+        }
+        //debug: validate descriptor */
+        if(Pktlib_getNextPacket(tip) != 0) 
+        {
+            printf(" rcv_cb, nexpkt != NULL");
+        }
+
+        if(coreid<TUNE_NETAPI_NUM_CORES)
+            stats[coreid].rx+=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) 
+        {
+            netapi_Log(">rx dmp.."); 
+            netTest_utilDumpDescr((long *) tip,stats[coreid].rx);
+        }
+#endif
+#if 0
+        //
+        if(stats[coreid].rx<=16)
+        {
+            netTest_utilDumpHeader((long*)p_pkt,stats[coreid].rx, (int)meta[i].u.rx_meta->appId,meta[i].u.rx_meta->rxFlag1);
+            netTest_utilDumpBuffer((long*)p_pkt,len);
+        }
+#endif
+        /* check header */
+        memcpy(p_head,&p_pkt[netTest_MAC_HEADER_LEN],sizeof(netTestHead_T));
+
+        /* check for IPSEC ESP or AH packet, 0x32 is ESP tunnel mode, 0x33 is AH tunnel mode*/
+        if (((p_head->ip[2]&0x0000ff00)==0x00003200) || ((p_head->ip[2]&0x0000ff00)==0x00003300))
+        {
+            if (!netTest_utilCheckHeader(p_head,&meta[i]))
+            {
+                printf("recv_cb: error in ipsec pkt\n");
+                stats[coreid].n_bad+=1;Pktlib_freePacket(tip); 
+                continue;
+            }
+
+            //process IP SEC PACKET
+            if (netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND)
+            {
+                p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
+                p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa_rx, (char *)p_spi ,4);
+                if (p_sa_info == NULL)
+                {
+                    printf("recv_cb(): trie_lookup() failed\n");
+                    continue;
+                }
+
+                //ship to crypto for decrypt!!
+                //12 byte auth tag
+                PKTIO_METADATA_T meta2 = {PKTIO_META_SB_TX,{0},0};
+                nwalDmTxPayloadInfo_t meta_tx={0};
+
+                meta2.sa_handle = (void*) p_sa_info->rx_tunnel;
+
+                memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
+
+                meta_tx.encSize = len - p_sa_info->tx_payload_info.encOffset -p_sa_info->auth_tag_size;
+                meta_tx.authSize = len - meta_tx.authOffset - p_sa_info->auth_tag_size;
+
+                if (p_sa_info->cipherMode == NWAL_SA_EALG_AES_CTR)
+                {
+                    memcpy(&p_iv[0], &p_sa_info->key_params->pEncKey[16], 4);
+                    memcpy(&p_iv[4], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
+                    p_iv[12] = 0;
+                    p_iv[13] = 0;
+                    p_iv[14] = 0;
+                    p_iv[15] = 1;
+                    meta_tx.pEncIV = &p_iv[0];
+                 
+                }
+                else if ((p_sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) ||
+                            (p_sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))
+                {
+                        memcpy(&p_iv[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
+                        meta_tx.pEncIV = &p_iv[0];
+                        /* aad is the ESP header which is 8 bytes */
+                        memcpy(&p_add[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN], 8);
+                        meta_tx.pAad= &p_add[0];
+                        meta_tx.aadSize = 8;
+                }
+                else if (p_sa_info->authMode == NWAL_SA_AALG_GMAC)
+                {
+                    memcpy(&p_iv[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
+                        meta_tx.pAuthIV= &p_iv[0];
+                        /* aad is the ESP header which is 8 bytes */
+                        memcpy(&p_add[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN], 8);
+                        meta_tx.pAad= &p_add[0];
+                        meta_tx.aadSize = 8;
+                }
+                else if (p_sa_info->cipherMode ==  NWAL_SA_EALG_NULL)
+                {
+                    meta_tx.pEncIV = NULL;
+                }
+                else
+                {
+                    meta_tx.pEncIV = &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN ];
+                }
+               
+                meta_tx.appCtxId = (nwal_AppId)p_sa_info;
+
+                /* post it to netcp sb tx channel*/
+                meta2.u.tx_sb_meta=&meta_tx;
+
+                netapi_pktioSend(netcp_sb_tx_chan,tip,&meta2,&err);
+                continue;
+            }
+            else
+            {
+                //inflow mode.  flip and send
+                flip_and_send_pkt(tip,p_pkt,len,1, enet_port);
+            }
+        }
+        /* check for udp protocol */
+        else if ((p_head->ip[2]&0x0000ff00)!=0x00001100)
+         //else if ((p_head->ip[2]&0x00ff0000)!=0x00110000)
+        {
+            stats[coreid].n_new+=1;Pktlib_freePacket(tip); continue;
+        }
+        else  //non ipsec
+        {
+            if (!netTest_utilCheckHeader(p_head,&meta[i]))
+            {
+                stats[coreid].n_bad+=1;Pktlib_freePacket(tip); 
+                continue;
+            }
+            //just flip and send
+            flip_and_send_pkt(tip,p_pkt,len,0, enet_port);
+        }
+    }
+}
+
+/* Templates to build command labels at startup up time, required by open_pktio_tx_channels() */
+nwalTxPktInfo_t txPktInfoESP = 
+{
+    NULL,                                                                                               /* p_pkt */
+    NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID,      /* txFlags */
+    0,                                                                                                  /* lpbackPass */
+    0,                                                                                                  /* enetport */
+    0,                                                                                                  /* msuSize */
+    0,                                                                                                   /* startOffset */
+    netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN,                                                    /* saOffBytes */
+    0,                                                                                                  /* saPayLoadLen */
+    0               ,                                                                                    /* saAhIcvOffBytes */
+    0,                                                                                                 /* saAhMacSize */
+    0,                                                                                                  /* etherLenOffBytes */
+    0,                                                                                                  /* ipOffBytes */
+    0,                                                                                                  /* l4OffBytes */
+    netTest_UDP_HEADER_LEN,                                                                             /* l4HdrLen */
+    0,                                                                                                  /* pseudoHdrChecksum */
+    0                                                                                                   /* pLoadLen */
+};
+
+
+nwalTxPktInfo_t txPktInfoAH = 
+{
+    NULL,                                                                                               /* p_pkt */
+    NWAL_TX_FLAG1_DO_IPSEC_AH_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM | NWAL_TX_FLAG1_META_DATA_VALID,      /* txFlags */
+    0,                                                                                                  /* lpbackPass */
+    0,                                                                                                  /* enetport */
+    0,                                                                                                  /* msuSize */
+    0,                                                                                                   /* startOffset */
+    netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN,                                                    /* saOffBytes */
+    0,                                                                                                  /* saPayLoadLen */
+    netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE,                    /* saAhIcvOffBytes */
+    12,                                                                                                 /* saAhMacSize */
+    0,                                                                                                  /* etherLenOffBytes */
+    0,                                             /* ipOffBytes */
+    0,                                                                                                  /* l4OffBytes */
+    netTest_UDP_HEADER_LEN,                                                                            /* l4HdrLen */
+    0,                                                                                                  /* pseudoHdrChecksum */
+    0                                                                                                   /* pLoadLen */
+};
+
+nwalTxPktInfo_t txPktInfoNoCrypto = 
+{
+    NULL,                                                                                               /* p_pkt */
+    NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID,      /* txFlags */
+    0,                                                                                                  /* lpbackPass */
+    0,                                                                                                  /* enetport */
+    0,                                                                                                  /* msuSize */
+    0,                                                                                                   /* startOffset */
+    0,                                                    /* saOffBytes */
+    0,                                                                                                  /* saPayLoadLen */
+    0               ,                                                                                    /* saAhIcvOffBytes */
+    0,                                                                                                 /* saAhMacSize */
+    0,                                                                                                  /* etherLenOffBytes */
+    0,                                                                                                  /* ipOffBytes */
+    netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN,                                        /* l4OffBytes */
+    netTest_UDP_HEADER_LEN,                                                             /* l4HdrLen */
+    0,                                                                         /* pseudoHdrChecksum */
+    0                                                                                                   /* pLoadLen */
+};
+
+
+void close_pktio_channels(void)
+{
+    int err;
+    netapi_pktioClose(netcp_tx_chan_esp ,&err);
+    netapi_pktioClose(netcp_tx_chan_ah ,&err);
+    netapi_pktioClose(netcp_sb_tx_chan ,&err);
+    netapi_pktioClose(netcp_tx_chan_no_crypto,&err);
+}
+
+void open_pktio_tx_channels(void)
+{
+    int err;
+    /* open netcp default  TX for ESP packets */
+    netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    if (!netcp_tx_chan_esp)
+    {
+        printf("pktio open TX failed err=%d\n",err);
+        exit(1);
+    }
+    else
+    {
+        if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+        {
+            PKTIO_CONTROL_T control;
+            control.op = PKTIO_UPDATE_FAST_PATH;
+            PKTIO_CFG_T cfg;
+            cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_L4CKSUM_PORT;
+            cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
+            netapi_pktioControl(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
+        }
+    }
+
+    /*/* open netcp default  TX for AH packets */
+    netcp_tx_chan_ah= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    if (!netcp_tx_chan_ah)
+    {
+        printf("pktio open TX failed err=%d\n",err);
+        exit(1);
+    }
+    else
+    {
+        if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+        {
+            PKTIO_CONTROL_T control;
+            control.op = PKTIO_UPDATE_FAST_PATH;
+            PKTIO_CFG_T cfg;
+            cfg.fast_path_cfg.fp_send_option = PKTIO_FP_AH_L4CKSUM_PORT;
+            cfg.fast_path_cfg.txPktInfo= &txPktInfoAH;
+            netapi_pktioControl(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
+        }
+    }
+
+    /* open netcp default  TX channels for non-Crypto packets */
+    netcp_tx_chan_no_crypto= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    if (!netcp_tx_chan_no_crypto)
+    {
+        printf("pktio open TX failed err=%d\n",err);
+        exit(1);
+    }
+    else
+    {
+        if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+        {
+            PKTIO_CONTROL_T control;
+            control.op = PKTIO_UPDATE_FAST_PATH;
+            PKTIO_CFG_T cfg;
+            cfg.fast_path_cfg.fp_send_option = PKTIO_FP_L4CKSUM_PORT;
+            cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
+            netapi_pktioControl(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
+        }
+    }
+
+    /* open netcp default  TX channels for SB crypto */
+    netcp_sb_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
+    if (!netcp_sb_tx_chan)
+    {
+        printf("pktio open SB TX failed err=%d\n",err);
+        exit(1);
+    }
+}
+
+#ifdef netTest_DSP_FASTPATH
+void setup_netTestDSPFastPath(NETAPI_T handle)
+
+{
+    int i;
+    int err = 0;
+    PKTIO_CFG_T dsp_pktio_cfg;
+    NETCP_CFG_CLASSIFIER_T dsp_classi;
+    NETCP_CFG_ROUTE_T dsp_route;
+
+    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];
+    //for (i = 0; i < CPU_NUM_REM_FAST_PATH_CORES; i++)
+    for (i = 0; i < 1; i++)
+    {
+        sprintf(&dsp_name[0],"%s%d","dsp_chan", i);
+        printf("netTest_utilCreateInterfaces: %s\n",&dsp_name[0]);
+
+        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;
+        dsp_pktio_cfg.max_n = 8;
+
+        /* pktio channels created here will NOT be POLLED by net_test arm application */
+        dsp_pktio_channels[i] = netapi_pktioCreate(handle,
+                                               &dsp_name[0],
+                                               (PKTIO_CB)recv_cb,
+                                               &dsp_pktio_cfg,
+                                               &err);
+        if (dsp_pktio_channels[i])
+        {
+            printf("setup_netTestDSPFastPath: sucess for core %d\n", i);
+        }
+        else
+        {
+            printf("setup_netTestDSPFastPath: failed for core %d\n", i);
+        }
+
+        dsp_classi.classType =NETCP_CFG_CLASS_TYPE_L4;
+        dsp_classi.u.c_l4.iface = netTestCfg.dsp_mac;
+        
+        dsp_classi.u.c_l4.ip = ip_rule[netTestCfg.dsp_ip];
+        dsp_classi.u.c_l4.proto = NWAL_APP_PLOAD_PROTO_UDP;
+        dsp_classi.u.c_l4.appProto.udpPort = TEST_NWAL_BASE_REM_FP_UDP_PORT + i;
+
+        dsp_route.p_dest_q = dsp_pktio_channels[i];
+       
+        dsp_route.p_flow = (NETCP_CFG_FLOW_T*)NETCP_DEFAULT_FLOW;
+        
+        
+        dsp_classifers[i] = netapi_netcpCfgAddClass(handle, 
+                                &dsp_classi, 
+                                (NETCP_CFG_ROUTE_HANDLE_T) &dsp_route, 
+                                NETCP_CFG_ACTION_TO_SW,
+                                NULL,
+                                &err);
+
+        if (err == NETAPI_ERR_OK)
+        {
+            printf("setup_netTestDSPFastPath: netapi_netcpCfgAddClass sucess for core %d\n", i);
+        }
+        else
+        {
+            printf("setup_netTestDSPFastPath: netapi_netcpCfgAddClass failed for core %d\n", i);
+        }
+    }
+}
+
+void teardown_netTestDSPFastPath()
+{
+    int i;
+    int err=0;
+
+    for (i = 0; i < CPU_NUM_REM_FAST_PATH_CORES; i++)
+    {
+        netapi_netcpCfgDelClass(netapi_handle,
+                                dsp_classifers[i],
+                                &err);
+        if (err == NETAPI_ERR_OK)
+        {
+            printf("teardown_netTestDSPFastPath: netapi_netcpCfgDelClass sucess for core %d\n", i);
+        }
+        else
+        {
+            printf("teardown_netTestDSPFastPath: netapi_netcpCfgDelClass failed for core %d\n", i);
+        }
+
+        netapi_pktioDelete(dsp_pktio_channels[i],
+                           &err);
+        if (err == NETAPI_ERR_OK)
+        {
+            printf("teardown_netTestDSPFastPath: netapi_pktioDelete sucess for core %d\n", i);
+        }
+        else
+        {
+            printf("teardown_netTestDSPFastPath: netapi_pktioDelete failed for core %d\n", i);
+        }
+    }
+}
+#endif
+
+
+#ifdef netTest_MULTI_THREAD
+NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
+
+void slow_path_thread(uint32_t index)
+{
+    int err, i;;
+    uint32_t thread_num;
+    PKTIO_HANDLE_T *rx_chan;
+    PKTIO_HANDLE_T *sb_rx_chan;
+
+
+    cpu_set_t cpu_set;
+
+    thread_num = netTestCfg.sp_thread_num[index];
+    printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), netTestCfg.sp_thread_num[index]);
+
+    CPU_ZERO( &cpu_set);
+    printf("slow_path_thread: settting up for thread number %d\n", thread_num);
+#ifdef CORTEX_A15
+    for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
+    {
+        printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
+        CPU_SET( i, &cpu_set);
+    }
+    hplib_utilSetupThread(thread_num, &cpu_set);
+#else
+    for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
+    {
+        printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
+        CPU_SET( i, &cpu_set);
+    }
+    hplib_utilSetupThread(thread_num, &cpu_set);
+#endif
+    worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
+
+    netapi_setCookie(worker_nh[thread_num],(void*)(thread_num | NET_TEST_SP_THREAD_MASK));
+
+    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);
+        exit(1);
+    }
+    scheduler[thread_num]->config.yield = TRUE;
+    scheduler[thread_num]->config.pollGarbageQ = TRUE;
+    scheduler[thread_num]->config.pollCtrlQ = TRUE;
+
+    /* Entry point to scheduler */
+    netapi_schedRun(scheduler[thread_num], &err);
+    printf(">net_test: core %d worker thread done\n",thread_num);
+
+    netapi_shutdown(worker_nh[thread_num]);
+}
+
+void fast_path_thread(uint32_t index)
+{
+    int err, i;
+    PKTIO_HANDLE_T *rx_chan;
+    PKTIO_HANDLE_T *sb_rx_chan;
+    uint32_t thread_num;
+
+
+    cpu_set_t cpu_set;
+
+    CPU_ZERO( &cpu_set);
+    printf("fast_path_thread: settting up for thread number %d\n", netTestCfg.fp_thread_num[index]);
+    thread_num = netTestCfg.fp_thread_num[index];
+#ifdef CORTEX_A15
+    for (i = netTestCfg.fp_proc_start[index]; i <= netTestCfg.fp_proc_end[index];i++)
+    {
+        printf("fast_path_thread: start core %d, end core %d\n",
+                netTestCfg.fp_proc_start[index],
+                netTestCfg.fp_proc_end[index]);
+        printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+        CPU_SET( i, &cpu_set);
+    }
+    hplib_utilSetupThread(thread_num, &cpu_set);
+#else
+    for (i = netTestCfg.fp_proc_start[index]; i <= netTestCfg.fp_proc_end[index];i++)
+    {
+        printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+        CPU_SET( i, &cpu_set);
+    }
+    hplib_utilSetupThread(thread_num, &cpu_set);
+#endif
+    worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
+
+   /* open netcp default RX channels*/
+    rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (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_tx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
+     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);
+    if (!scheduler[thread_num]) 
+        {
+        printf("sched create failed for core%d\n",thread_num); 
+        exit(1);
+    }
+
+    scheduler[thread_num]->config.yield = FALSE;
+    scheduler[thread_num]->config.pollGarbageQ = FALSE;
+    scheduler[thread_num]->config.pollCtrlQ = FALSE;
+     //sleep(100000);
+   /* Entry point to scheduler */
+     netapi_schedRun(scheduler[thread_num], &err);
+    printf(">net_test: core %d worker thread done\n",thread_num);
+
+    netapi_pktioClose(rx_chan, &err);
+
+    netapi_pktioClose(sb_rx_chan, &err);
+    netapi_shutdown(worker_nh[thread_num]);
+}
+
+#endif
+/***************************************
+ ********** test driver*****************
+ ***************************************/
+int main(int argc, char **argv)
+{
+    int err,i;
+    Pktlib_HeapCfg      heapCfg;
+    int32_t             errCode;
+    Pktlib_HeapIfTable*  pPktifTable;
+    FILE * fpr = NULL;
+
+#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)
+    {
+       printf("Cant open config file: filepath %s, %s\n", input_file_name, strerror(errno));
+        exit(1);
+    }
+    else
+    {
+        memset(&config_file, 0, sizeof(netTestConfigFile_t));
+        memset(&netTestCfg, 0, sizeof(netTestConfig_t));
+        
+        netTest_utilProcessConfigFile(fpr,&config_file);
+
+        netTest_utilParseMac(&config_file);
+
+        /* parse slow path/fast path thread configuration parameters */
+        netTest_utilParseThreadParams(&config_file);
+
+        netTest_utilParseIP(&config_file);
+
+        netTest_utilParseIpsecMode(&config_file);
+
+        /* DSP mac processing */
+        parse_dsp_mac(&config_file.dsp_mac[0]);
+
+       /* DSP IP processing */
+        parse_dsp_ip(&config_file.dsp_ip[0]);
+
+        /* IPSEC interface number processing */
+        parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
+
+        netTest_utilParseSA(&config_file);
+
+        parse_simple_param_u32(&config_file.dest_udp_port_config, &netTestCfg.dest_udp_port_config);
+    }
+
+    memset(&sa_info, 0, sizeof(sa_info));
+
+
+#ifdef netTest_MULTI_THREAD
+    /* assign main net_test thread to run on core 0 */
+    CPU_ZERO( &cpu_set);
+    CPU_SET( 0, &cpu_set);
+    hplib_utilSetupThread(0, &cpu_set);
+#endif
+
+    /* create netapi */
+    netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
+
+    /* configure expection packet handling with netapi */
+    netapi_netcpCfgExceptions(netapi_handle,
+                              NETCP_CFG_ALL_EXCEPTIONS,
+                              NETCP_CFG_ACTION_DISCARD, 
+                              (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+    expPkt_appid = netapi_netcpCfgExceptions(netapi_handle, 
+                                             7,
+                                             NETCP_CFG_ACTION_TO_SW,
+                                             (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+
+    /* open the main heap */
+    ourHeap = Pktlib_findHeapByName("netapi");
+    if (!ourHeap)
+    {
+        printf("Pktlib_findHeapByName()  fail\n");
+        exit(1);
+    }
+
+    open_pktio_tx_channels();
+
+    printf("net_test: %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
+    /* create scheduler instance */
+    our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
+    if (!our_sched) {printf("sched create failed\n"); exit(1);}
+
+
+    /*create net_test MAC interfaces, attach IP to created MAC interfaces */
+    netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
+
+    /* lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
+    p_trie_sa_rx = trie_new();
+    p_trie_sa_tx = trie_new();
+    if (!p_trie_sa_rx || !p_trie_sa_tx)
+        {printf("trie alloc for SA  failed\n"); exit(1);}
+
+#ifdef netTest_DSP_FASTPATH
+    setup_netTestDSPFastPath(netapi_handle);
+#endif
+
+    /* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
+    netTest_utilCreateSecAssoc();
+
+#ifdef netTest_MULTI_THREAD
+{
+#if 0
+    nwalGlobCxtInfo_t nwalGlobCxt;
+    nwalLocCxtInfo_t nwalLocCxt;
+    int count;
+    NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) netapi_handle;
+
+    nwal_getGlobCxtInfo(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,&nwalGlobCxt);
+
+
+    printf("*******NWAL Global Context Info Dump Begin *******\n");
+    printf("rxPaSaFlowId:%d,rxSaPaFlowId:%d rxDefPktQ:0x%x \n",
+                       nwalGlobCxt.rxPaSaFlowId,nwalGlobCxt.rxSaPaFlowId,
+                        nwalGlobCxt.rxDefPktQ);
+    printf("defFlowQ:0x%x,passCppiHandle:0x%x extErr:%d \n",
+                       nwalGlobCxt.defFlowQ,nwalGlobCxt.passCppiHandle,
+                       nwalGlobCxt.extErr);
+    for(count=0;count < nwalGlobCxt.numPaPDSPs;count++)
+    {
+        printf("NetCP PASS PDSP - %d Version:0x%x \n",
+                      count,nwalGlobCxt.pdspVer[count]);
+    }
+    printf("*******NWAL Global Context Info Dump End *******\n\n");
+
+
+    nwal_getLocCxtInfo(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,&nwalLocCxt);
+    printf("*******NWAL Local Context Info Dump Begin *******\n");
+    printf("rxCtlQ:%d,rxL4PktQ:%d \n",
+                        nwalLocCxt.rxCtlQ,
+                        nwalLocCxt.rxL4PktQ);
+    printf("rxPktFlowId:0x%x,rxCtlFlowId:0x%x extErr:%d \n",
+                       nwalLocCxt.rxPktFlowId
+                       ,nwalLocCxt.rxCtlFlowId,
+                       nwalLocCxt.extErr);
+    
+    printf("*******NWAL Local Context Info Dump End *******\n\n");
+
+#endif
+
+    /* 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, 
+                                  (NET_TEST_FUNC_PTR) slow_path_thread,
+                                  netTestCfg.num_fp_threads,
+                                  (NET_TEST_FUNC_PTR) fast_path_thread);
+
+    char c;
+        //this thread of execution (main) now just waits on user input
+        for(;;)
+        {
+           printf(">");
+           c=getchar();
+           if (c=='q') {QUIT=1;break;}
+           else if (c=='s') netTest_utilsStatsCb(netapi_handle, &netcp_stats);
+           else if (c=='h') printf("'q' to quit,  's' for stats, 'h' for help\n");
+        }
+
+        netTest_utilRemoveSpFpThreads(netTestCfg.num_sp_threads, netTestCfg.num_fp_threads);
+
+}
+#else
+    /*********************************************/
+    /**************Entry point into scheduler ****/
+    /*********************************************/
+    //netTest_utilCreateSecAssoc(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
+    netapi_schedRun(our_sched, &err);
+#endif
+
+    /* done */
+    netTest_utilsStatsCb(netapi_handle, NULL);
+
+
+    /* cleanup*/
+     netTest_utilDeleteSecAssoc();
+
+    netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
+
+    /* close pktio channels we opened via open_pktio_tx_channels() */
+    close_pktio_channels();
+#ifdef netTest_DSP_FASTPATH
+    teardown_netTestDSPFastPath();
+#endif
+    netapi_shutdown(netapi_handle);
+
+}
+
+#if 1
+/* Stub functions */
+Trie * route_init(void)
+{
+}
+void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route)
+{
+}
+#endif