]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blobdiff - ti/runtime/netapi/test/net_test.c
Additional changes to integrate with highperf-lib, moved osal.c to highperf-lib
[keystone-rtos/netapi.git] / ti / runtime / netapi / test / net_test.c
index e3bcd93af9ee6d94f5e35f33322cc211864e51b6..4e88a2970c8ff1cb94986aa9eac95d28aea756f8 100755 (executable)
@@ -40,7 +40,7 @@
  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
  *****************************************/
-#define NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
+//#define NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
 #ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
 #define NWAL_ENABLE_SA
 #endif
@@ -97,6 +97,90 @@ void dump_header(unsigned long *p, int n, int a, int r)
    printf("-----------------------------\n");
 }
 
+
+static void  netapi_dump_buf
+(
+    unsigned long *                      buf,
+    uint32_t                      buf_length
+)
+{
+    uint8_t                       count = 0;
+    uint16_t                      dump_size;
+    uint8_t*                     tmp_buf;
+    uint8_t                       row_count;
+    static uint8_t                first = 0;
+
+    //if(first > 2) return;
+
+    //first++;
+
+    dump_size = buf_length ;
+
+    tmp_buf = (uint8_t *)(buf);
+
+    printf("netapi *:  - 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("netapi *:%02d : %02x    %02x    %02x    %02x \n",
+                      count,tmp_buf[0],tmp_buf[1],tmp_buf[2],tmp_buf[3]);
+                break;
+            }
+            case 3:
+            {
+                printf("netapi *: %02d : %02x    %02x    %02x \n",
+                      count,tmp_buf[0],tmp_buf[1],tmp_buf[2]);
+                break;
+            }
+
+            case 2:
+            {
+                printf("netapi *: %02d : %02x    %02x \n",
+                      count,tmp_buf[0],tmp_buf[1]);
+                break;
+            }
+
+            case 1:
+            {
+                printf("netapi *: %02d : %02x \n",
+                      count,tmp_buf[0]);
+                break;
+            }
+
+            default:
+            {
+                /* Should never reach here */
+                printf("netapi *: Internal Error in netapi_dump_buf().Row Count: %d \n",
+                    row_count);
+                return;
+            }
+        }
+
+        tmp_buf = tmp_buf + row_count;
+        count = count +  row_count;
+
+    }while(count < dump_size);
+
+    printf("netapi *:  - Byte hex Dump End \n");
+
+}
+
+
 /*****************************************/
 
 
@@ -106,6 +190,9 @@ int pktloopback=TUNE_NETAPI_NWAL_ENABLE_PASS_LOOPBACK;
 nwalTxPSCmdInfo_t   flowPSCmdInfo;
 nwal_RetValue       nwalRetVal;
 
+/* Local Per Process default resourcese maintained at NWAL */
+nwalLocCxtInfo_t    nwalLocCxt;
+
 //this device: 10.0.0.100, mac 0x,01,02,03,04,05  and .. 0x6
 
 //test packet, setup for loopback (so dest is ourself)
@@ -307,14 +394,14 @@ NETAPI_SCHED_CONFIG_T our_sched_cfg={
   NETAPI_SCHED_DURATION|NETAPI_SCHED_CBV, 0, house, 5000000  //every 5000000 poll loops
 };
 void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats);
-NETAPI_TIMER_GROUP_HANDLE_T ourTimerBlock; 
-NETAPI_TIMER_T t1;
-NETAPI_TIMER_T t2;
-NETAPI_TIMER_T t3;
+HPLIB_TIMER_GROUP_HANDLE_T ourTimerBlock; 
+HPLIB_TIMER_T t1;
+HPLIB_TIMER_T t2;
+HPLIB_TIMER_T t3;
 
-void our_timer_cb( NETAPI_TIMER_GROUP_HANDLE_T th,
+void our_timer_cb( HPLIB_TIMER_GROUP_HANDLE_T th,
         int n_fired,     //# timers fired
-        NETAPI_TIMER_LIST_T fired_list,
+        HPLIB_TIMER_LIST_T fired_list,
         uint64_t currentTime);
 
 NETCP_CFG_IP_T ip_rule0;
@@ -324,20 +411,21 @@ NETCP_CFG_CLASS_T class_1;
 NETCP_CFG_CLASS_T class_2;
 NETCP_CFG_FLOW_HANDLE_T specialFlow;
 
+
 NETCP_CFG_CLASSIFIER_T class_0_cfg=
 {
    NETCP_CFG_CLASS_TYPE_L4,
    {
-       {0,0, NWAL_APP_PLOAD_PROTO_UDP, {2500}}
+        {0,0, NWAL_APP_PLOAD_PROTO_UDP, {2500}}
    }
 };
 
 NETCP_CFG_CLASSIFIER_T class_1_cfg=
 {
-   NETCP_CFG_CLASS_TYPE_L4,
-   {
+    NETCP_CFG_CLASS_TYPE_L4,
+    {
         {0,0, NWAL_APP_PLOAD_PROTO_UDP, {2502}}
-   }
+    }
 };
 
 NETCP_CFG_ROUTE_T  class2_route=
@@ -356,21 +444,15 @@ NETCP_CFG_CLASSIFIER_T class_2_cfg=
 PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
 
 /* security objects. (for loopback mode) */
-netTestSA_t sa_info[4];
+netTestSA_t sa_info[6];
 int netapi_algorithm_set = 0;
 int netapi_sec_sa_mode = 2;
-/* tmannan-end */
-//NETCP_CFG_SA_T rx_tunnel;
-//NETCP_CFG_SA_T tx_tunnel;
+
 NETCP_CFG_IPSEC_POLICY_T rx_policy[4];
-//void * rx_data_mode_handle;
-//void * tx_data_mode_handle;
-//void * rx_inflow_mode_handle;
-//void * tx_inflow_mode_handle;
-/* rx */
 
 
-NETAPI_SEC_SA_INFO_T rx_sa [4] = {
+
+NETAPI_SEC_SA_INFO_T rx_sa [7] = {
 {
     NWAL_SA_DIR_INBOUND,
     0x11111111,  //spi
@@ -405,8 +487,8 @@ NETAPI_SEC_SA_INFO_T rx_sa [4] = {
     nwal_IPV4, //v4
     { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Src IP (them) -> set below */
     { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* dst IP (us)-> set below*/
-    64,/* replayWindow */
-    NWAL_SA_AALG_HMAC_SHA2_256,
+    0,/* replayWindow */
+    NWAL_SA_AALG_NULL,
     NWAL_SA_EALG_3DES_CBC,
     0,0  //na
 },
@@ -422,11 +504,50 @@ NETAPI_SEC_SA_INFO_T rx_sa [4] = {
     NWAL_SA_AALG_HMAC_MD5,
     NWAL_SA_EALG_NULL,
     0,0  //na
+},
+{
+    NWAL_SA_DIR_INBOUND,
+    0x55555555,  //spi
+    nwal_IpSecProtoESP, //ESP mode
+    nwal_SA_MODE_TUNNEL,  //tunnel mode
+    nwal_IPV4, //v4
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Src IP (them) -> set below */
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* dst IP (us)-> set below*/
+    64,/* replayWindow */
+    NWAL_SA_AALG_NULL,
+    NWAL_SA_EALG_AES_GCM,
+    0,0  //na
+},
+{
+    NWAL_SA_DIR_INBOUND,
+    0x66666666,  //spi
+    nwal_IpSecProtoESP, //ESP mode
+    nwal_SA_MODE_TUNNEL,  //tunnel mode
+    nwal_IPV4, //v4
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Src IP (them) -> set below */
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* dst IP (us)-> set below*/
+    64,/* replayWindow */
+    NWAL_SA_AALG_NULL,
+    NWAL_SA_EALG_AES_CCM,
+    0,0  //na
+},
+{
+    NWAL_SA_DIR_INBOUND,
+    0x77777777,  //spi
+    nwal_IpSecProtoESP, //ESP mode
+    nwal_SA_MODE_TUNNEL,  //tunnel mode
+    nwal_IPV4, //v4
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Src IP (them) -> set below */
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* dst IP (us)-> set below*/
+    64,/* replayWindow */
+    NWAL_SA_AALG_GMAC,
+    NWAL_SA_EALG_NULL,
+    0,0  //na
 }
 };
 
 /*tx */
-NETAPI_SEC_SA_INFO_T tx_sa[4]= {
+NETAPI_SEC_SA_INFO_T tx_sa[7]= {
 {
     NWAL_SA_DIR_OUTBOUND,
     0x11111111,  //spi
@@ -461,8 +582,8 @@ NETAPI_SEC_SA_INFO_T tx_sa[4]= {
     nwal_IPV4, //v4
     { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Src IP (us) -> set below */
     { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* dst IP (them) -> set below*/
-    64, /* NA replayWindow */
-    NWAL_SA_AALG_HMAC_SHA2_256,
+    0, /* NA replayWindow */
+    NWAL_SA_AALG_NULL,
     NWAL_SA_EALG_3DES_CBC,
     0,0  //seq no
 },
@@ -477,11 +598,49 @@ NETAPI_SEC_SA_INFO_T tx_sa[4]= {
     64, /* NA replayWindow */
     NWAL_SA_AALG_HMAC_MD5,
     NWAL_SA_EALG_NULL,
-    0,0  //seq no
+},
+{
+    NWAL_SA_DIR_OUTBOUND,
+    0x55555555,  //spi
+    nwal_IpSecProtoESP, //ESP mode
+    nwal_SA_MODE_TUNNEL,  //tunnel mode
+    nwal_IPV4, //v4
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Src IP (them) -> set below */
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* dst IP (us)-> set below*/
+    64,/* replayWindow */
+    NWAL_SA_AALG_NULL,
+    NWAL_SA_EALG_AES_GCM,
+    0,0  //na
+},
+{
+    NWAL_SA_DIR_OUTBOUND,
+    0x66666666,  //spi
+    nwal_IpSecProtoESP, //ESP mode
+    nwal_SA_MODE_TUNNEL,  //tunnel mode
+    nwal_IPV4, //v4
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Src IP (them) -> set below */
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* dst IP (us)-> set below*/
+    64,/* replayWindow */
+    NWAL_SA_AALG_NULL,
+    NWAL_SA_EALG_AES_CCM,
+    0,0  //na
+},
+{
+    NWAL_SA_DIR_OUTBOUND,
+    0x77777777,  //spi
+    nwal_IpSecProtoESP, //ESP mode
+    nwal_SA_MODE_TUNNEL,  //tunnel mode
+    nwal_IPV4, //v4
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Src IP (them) -> set below */
+    { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* dst IP (us)-> set below*/
+    64,/* replayWindow */
+    NWAL_SA_AALG_GMAC,
+    NWAL_SA_EALG_NULL,
+    0,0  //na
 }
 };
 
-static nwalSecKeyParams_t ourTXKeyParams[4] ={
+static nwalSecKeyParams_t ourTXKeyParams[7] ={
 {
     16, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt : 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
     20, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA1 */
@@ -496,7 +655,7 @@ static nwalSecKeyParams_t ourTXKeyParams[4] ={
 },
 {
     24, /* encKeySize: DES-CBC: 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
-    32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+    0, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
     NULL, //set below
     NULL, //set below
 },
@@ -505,11 +664,29 @@ static nwalSecKeyParams_t ourTXKeyParams[4] ={
     16, /* MD5, 16 bytes */
     NULL, //set below
     NULL, //set below
+},
+{
+    20, /* encKeySize: GCM 16 bytes Encryption Key and 4 bytes Salt */
+    0, /* macKeySize: 0*/
+    NULL, //set below
+    NULL, //set below
+},
+{
+    19, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+    0, /* macKeySize 0*/
+    NULL, //set below
+    NULL, //set below
+},
+{
+    0, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+    24, /* macKeySize 0*/
+    NULL, //set below
+    NULL, //set below
 }
 };
 
 /* these keys are for aes-ctr and hmac sha2_256 */
-static nwalSecKeyParams_t ourRXKeyParams[4] ={
+static nwalSecKeyParams_t ourRXKeyParams[7] ={
 {
     16, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt : 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
     20, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA1 */
@@ -517,14 +694,14 @@ static nwalSecKeyParams_t ourRXKeyParams[4] ={
     NULL, //set below
 },
 {
-    20, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+    20, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt */
     32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
     NULL, //set below
     NULL, //set below
 },
 {
     24, /* encKeySize: DES-CBC: 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
-    32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+    0, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
     NULL, //set below
     NULL, //set below
 },
@@ -533,6 +710,24 @@ static nwalSecKeyParams_t ourRXKeyParams[4] ={
     16, /* NWAL_SA_AALG_HMAC_MD5, 16 bytes */
     NULL, //set below
     NULL, //set below
+},
+{
+    20, /* encKeySize: GCM 16 bytes Encryption Key and 4 bytes Salt */
+    0, /* macKeySize: 0*/
+    NULL, //set below
+    NULL, //set below
+},
+{
+    19, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt t*/
+    0, /* macKeySize 0*/
+    NULL, //set below
+    NULL, //set below
+},
+{
+    0, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+    24, /* macKeySize 0*/
+    NULL, //set below
+    NULL, //set below
 }
 };
 
@@ -651,25 +846,25 @@ int check_header(HEAD_T * p_head, PKTIO_METADATA_T * p_meta)
 {
 if (NWAL_RX_FLAG1_META_DATA_VALID & p_meta->u.rx_meta->rxFlag1)
 {
-lpInfo.iface = ((unsigned int)p_meta->u.rx_meta->appId) &0xff; //last byte is interface num
-lpInfo.ipcsum =(p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_MASK )== NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_ACK ? 1 : 0;
-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; 
-if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC)
-{
-   stats.sec_rx++;
-}
-if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC_POLICY)
-{
-   stats.secp_rx++;
-}
+    lpInfo.iface = ((unsigned int)p_meta->u.rx_meta->appId) &0xff; //last byte is interface num
+    lpInfo.ipcsum =(p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_MASK )== NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_ACK ? 1 : 0;
+    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; 
+    if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC)
+    {
+    stats.sec_rx++;
+    }
+    if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC_POLICY)
+    {
+    stats.secp_rx++;
+    }
 
-if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_CLASS)
-{
-  int c= ((unsigned int)p_meta->u.rx_meta->appId >>8)&0xffff;
-  if (c==0)  stats.n_class0_rx +=1;
-  else if (c==1) stats.n_class1_rx +=1;
-  else if (c==2) stats.n_class2_rx +=1;
-  else printf("**NET_TEST RX -unknown class: %x\n",  p_meta->u.rx_meta->appId);
+    if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_CLASS)
+    {
+        int c= ((unsigned int)p_meta->u.rx_meta->appId >>8)&0xffff;
+    if (c==0)  stats.n_class0_rx +=1;
+    else if (c==1) stats.n_class1_rx +=1;
+    else if (c==2) stats.n_class2_rx +=1;
+    else printf("**NET_TEST RX -unknown class: %x\n",  p_meta->u.rx_meta->appId);
 }
 }
 
@@ -746,9 +941,9 @@ for(j=0;j<200/nfrags;j++)
     buffer[2]= (temp&0xff00)>>8;
     buffer[3]= (temp&0xff);
     Pktlib_setPacketLen(tip, temp);
-    v1= netapi_timing_stop();
+    v1= hplib_mUtil_GetTickCount();
     paEx_reassemLibProc(tip, 0xffff);
-    v2= netapi_timing_stop();
+    v2= hplib_mUtil_GetTickCount();
     sum1+= v2-v1;
   }
   sum2 += v2-v1;
@@ -775,8 +970,8 @@ int sum =0;
    printf("calibration loop .. ");
    for(i=0;i<1000;i++)
    {
-   vv1= netapi_timing_stop();
-   vv2= netapi_timing_stop();
+   vv1= hplib_mUtil_GetTickCount();
+   vv2= hplib_mUtil_GetTickCount();
    sum+=(vv2-vv1);
    }
    printf(" accuracy = +- %d cycles\n", sum/1000);
@@ -786,15 +981,15 @@ PKTIO_METADATA_T meta[10]={0};
 //send single, recv single
 for(i=0;i<ntrials;i++)
 {
-   vv1= netapi_timing_stop();
+   vv1= hplib_mUtil_GetTickCount();
    tip=Pktlib_allocPacket(OurHeap,PKT_LEN);
-   vv2= netapi_timing_stop();
+   vv2= hplib_mUtil_GetTickCount();
    Pktlib_getDataBuffer(tip,&pData,&len);
-   vv3= netapi_timing_stop();
+   vv3= hplib_mUtil_GetTickCount();
    pktio_send(our_chan,tip,&meta[0],&err);
-   vv4= netapi_timing_stop();
+   vv4= hplib_mUtil_GetTickCount();
    n=pktio_poll(our_chan,NULL , &err);
-   vv5=   netapi_timing_stop();
+   vv5=   hplib_mUtil_GetTickCount();
    timings[0]+=(vv6-vv4);
    timings[1]+=(vv5-vv4);
    timings[3]+=(vv4-vv3); 
@@ -888,162 +1083,160 @@ static int eof=0;
  *--------------------------------------------------------------*/
 void flip_and_send_pkt(Ti_Pkt *tip,  unsigned char * p_pkt, int len, int flag)
 {
-unsigned char mac_temp[6];
-unsigned char ip_temp[4];
-unsigned char new_dest_port[2]={0x75,0x30};  // 30000
-uint16_t blah; 
-uint16_t i=1;   /* for testing only */
-
-uint8_t *p_spi; 
-netTestSA_t * p_sa_info;
-uint8_t p_iv[16];
-Cppi_HostDesc*          pPloadDesc;
-
-Pktlib_setPacketLen(tip,len);
-//mac
-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
-
-//ip  (outer in case of ipsec)
-memcpy(&ip_temp, &p_pkt[14+12],4);
-memcpy(&p_pkt[14+12],&p_pkt[14+12+4],4);
-memcpy(&p_pkt[14+12+4],&ip_temp,4);
+    unsigned char mac_temp[6];
+    unsigned char ip_temp[4];
+    unsigned char new_dest_port[2]={0x75,0x30};  // 30000
+    uint16_t blah; 
+    uint16_t i=1;   /* for testing only */
+
+    uint8_t *p_spi; 
+    netTestSA_t * p_sa_info;
+    uint8_t p_iv[16];
+    uint8_t p_add[8];
+    Cppi_HostDesc*          pPloadDesc;
+
+    printf("flip_and_send_pkt()\n");
+              //netapi_dump_buf((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[14+12],4);
+    memcpy(&p_pkt[14+12],&p_pkt[14+12+4],4);
+    memcpy(&p_pkt[14+12+4],&ip_temp,4);
 
-//outer checksum to 0
-if (!flag) memset(&p_pkt[14+10],0,2);
+    //outer checksum to 0
+    if (!flag) 
+    {
+        memset(&p_pkt[14+10],0,2);
+    }
 
+    //inner ip &udp for ipsec
+    if (flag) 
+    {
+        p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
+        p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa, (char *)p_spi ,4);
+        if (p_sa_info == NULL)
+        {
+            printf("flip_and_send_pkt(): trie_lookup() failed\n");
+            return;
+        }
+        //just drop non-udp packet
+        if (p_pkt[p_sa_info->tx_payload_info.encOffset+9]!=0x11)
+        {
+            stats.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 */
+        memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+20+2],&new_dest_port[0],2);
+        memset(&p_pkt[p_sa_info->tx_payload_info.encOffset+20+6],0,2); //checksum
 
-//inner ip &udp for ipsec
-if (flag) 
-{
-    p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
-    p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa, (char *)p_spi ,4);
-    if (p_sa_info == NULL)
-    {
-        printf("flip_and_send_pkt(): trie_lookup() failed\n");
-        return;
+        if (config.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[14+10],0,2);
+        }
+        else
+        {
+            //#else //inflow, don't touch outer , clear inner 
+            //DALmemset(&p_pkt[14+20+8+16+10],0,2); //inner checksum, we will compute on way out
+            //outer ip checksum : leave alone
+        }
     }
-    //just drop non-udp packet
-    if (p_pkt[p_sa_info->tx_payload_info.encOffset+9]!=0x11)
-  
+    else
     {
-        stats.n_new+=1;Pktlib_freePacket(tip); return;
+        memset(&p_pkt[14+20+6],0,2);//0 udp checksum (we will compute on way out
+        memcpy(&p_pkt[14+20+2],&new_dest_port[0],2);
     }
 
-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);
-
-//udp
-memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+20+2],&new_dest_port[0],2);
-memset(&p_pkt[p_sa_info->tx_payload_info.encOffset+20+6],0,2); //checksum
-
-
-
-
-if (config.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND)
-{
-    //inner ip checksum : leave alone
-#if 0
-    blah=test_utilOnesCompChkSum (&p_pkt[14+20+8+16], 10);
-    p_pkt[14+20+8+16+10]= (blah&0xff00)>>8;
-    p_pkt[14+20+8+16+11]= blah&0xff;
-#endif
-
-    //tbd udp checksum (leave at 0)
-
-    //outer ip, set to 0 (we will compute on way out
-    memset(&p_pkt[14+10],0,2);
-}
-else
-{
-//#else //inflow, don't touch outer , clear inner 
-//DALmemset(&p_pkt[14+20+8+16+10],0,2); //inner checksum, we will compute on way out
-//outer ip checksum : leave alone
-
-#if 0
-blah = test_utilOnesCompChkSum (&p_pkt[14], 10);
-p_pkt[14+10]= (blah&0xff00)>>8;
-p_pkt[14+11]= blah&0xff;
-#endif
-
-}
-}
-else
-{
-memset(&p_pkt[14+20+6],0,2);//0 udp checksum (we will compute on way out
-memcpy(&p_pkt[14+20+2],&new_dest_port[0],2);
-}
-
-//IPSEC case, 
-if (flag)
-{
+    /*IPSEC case */ 
+    if (flag)
+    {
         if (config.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND)
- //send to crypto for encryption
-//12 byte auth tag
       //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=p_sa_info->tx_data_mode_handle;  //use TX SA context
-
-#if 0
+            PKTIO_METADATA_T meta = {PKTIO_META_SB_TX,{0},0};
+            int err;
+            nwalDmTxPayloadInfo_t meta_tx={0};
+            meta.sa_handle=p_sa_info->tx_data_mode_handle;  //use TX SA context
 
-           meta_tx.encOffset =p_sa_info->tx_payload_info.encOffset;
-           
-           meta_tx.authOffset =netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN;
-
-           //meta_tx.encSize=len - 14- 20-8-16-12;
-           meta_tx.encSize = len - p_sa_info->tx_payload_info.encOffset -netTest_ICV_LEN;
-           
-           //meta_tx.authSize= len -14-20-12;
-           meta_tx.authSize = len - meta_tx.authOffset - netTest_ICV_LEN;
-           //meta_tx.pEncIV= &p_pkt[14+20+8];  //just use same IV..
-#endif
             memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
 
-          
-           meta_tx.encSize = len - p_sa_info->tx_payload_info.encOffset -netTest_ICV_LEN;
-           meta_tx.authSize = len - meta_tx.authOffset - netTest_ICV_LEN;
+                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 0
+#if 1
             printf("flip_and_send_pkt(): encOffset %d\n", meta_tx.encOffset);
             printf("flip_and_send_pkt():authOffset %d\n", meta_tx.authOffset);
             printf("flip_and_send_pkt(): encSize %d\n", meta_tx.encSize);
             printf("flip_and_send_pkt(): authSize %d\n", meta_tx.authSize);
 #endif
 
-        if (p_sa_info->cipherMode ==  NWAL_SA_EALG_AES_CTR)
-        {
-           memcpy(&p_iv[0], &ourEncrKey[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_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.pAuthIV=NULL;
-           meta_tx.aadSize=0;
-           meta_tx.pAad=NULL;
-           /* post it to netcp sb tx channel*/
-           meta_tx.appCtxId = (nwal_AppId)netapi_timing_start();
-           meta.u.tx_sb_meta=&meta_tx;
-
-#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API            
-           nwal_mCmdDMUpdate(tip,
+            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], &ourEncrKey[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->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.authIvSize=0;
+
+            /* post it to netcp sb tx channel*/
+            meta_tx.appCtxId = (nwal_AppId)hplib_mUtil_GetTickCount();
+            meta.u.tx_sb_meta=&meta_tx;
+
+#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
+            /* Use the command label which was cached during create time
+            * Update the Queue to receive output packet from SA to the local 
+            * core Queue. Below information can be saved by application in 
+            * per process context to avoid API overhead per packet
+            * Application can use below rxSbSaQ for polling packets back from
+            * SA
+            */
+            nwalRetVal =  
+            nwal_getLocCxtInfo(PKTIO_GET_NWAL_INSTANCE(netcp_sb_tx_chan),
+                                                      &nwalLocCxt);
+            if(nwalRetVal == nwal_OK)
+            {
+                p_sa_info->tx_dmPSCmdInfo.rxSbSaQ = nwalLocCxt.rxSbSaQ;
+            }
+            nwal_mCmdDMUpdate(tip,
                               &p_sa_info->tx_dmPSCmdInfo,
                               meta_tx.appCtxId,
                               meta_tx.encOffset,
@@ -1061,6 +1254,7 @@ if (flag)
                                        NWAL_DESC_SIZE);
 
 #else
+            printf("flip_and_send_pkt(): sending for encryption\n");
            pktio_send(netcp_sb_tx_chan,tip,&meta,&err);
 #endif
        }
@@ -1154,12 +1348,12 @@ void recv_cb_bench(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
                          uint64_t ts )
 {
    int i;
-   vv6=   netapi_timing_stop();
+   vv6=   hplib_mUtil_GetTickCount();
    for (i=0;i<n_pkts; i++) 
    {
      Pktlib_freePacket(p_recv[i]);
    }
-   vv11 = netapi_timing_stop();
+   vv11 = hplib_mUtil_GetTickCount();
 }
 
 /****************************************************************************************/
@@ -1182,7 +1376,7 @@ char * p_pkt;
 HEAD_T * p_head;
 HEAD_T temp_head;
 int tag_cmp=0;
-unsigned int hash[3];
+unsigned int hash[4];
 uint8_t *p_spi;
 netTestSA_t *p_sa_info;
 
@@ -1197,6 +1391,7 @@ unsigned long time, delta_time;
 
 
          p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
+
         p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa, (char *)p_spi ,4);
         if (p_sa_info == NULL)
         {
@@ -1209,7 +1404,7 @@ unsigned long time, delta_time;
         if ((int)meta[i].u.rx_sb_meta->appId == p_sa_info->rx_tunnel)
         {
            
-            time = netapi_timing_start();
+            time = hplib_mUtil_GetTickCount();
            delta_time = time -(unsigned long) meta[i].u.rx_sb_meta->appCtxId;
             stats.total_decrypt_time += delta_time;
             stats.sb_rx+=1;
@@ -1217,23 +1412,27 @@ unsigned long time, delta_time;
            hash[0]= htonl( meta[i].u.rx_sb_meta->pAuthTag[0]);
            hash[1]= htonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
            hash[2]= htonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
-
+           hash[3]= htonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
            if(stats.sb_rx<=16)
            {
              char *tp = (char *) &hash[0];
              //dump_header((long*)p_pkt, stats.sb_rx, (int)meta[i].u.rx_sb_meta->appId,0);
-#if 0
-             printf("tag in pkt=%x %x %x %x %x %x %x %x %x %x %x %x\n",
+#if 1
+             printf("decrypt complete: tag in pkt= %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x \n",
+                      p_pkt[len-16],p_pkt[len-15],p_pkt[len-14],p_pkt[len-13],
                       p_pkt[len-12],p_pkt[len-11],p_pkt[len-10],p_pkt[len-9], p_pkt[len-8],
                       p_pkt[len-7],p_pkt[len-6],
                       p_pkt[len-5],p_pkt[len-4],p_pkt[len-3],p_pkt[len-2],p_pkt[len-1]);
-             printf("tag from SA=%x %x %x %x %x %x %x %x %x %x %x %x\n",
+             printf("decrypt complete: tag from SA=%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x \n",
                        tp[0],tp[1],tp[2],tp[3],tp[4],tp[5],
-                       tp[6],tp[7],tp[8],tp[9],tp[10],tp[11]);
+                       tp[6],tp[7],tp[8],tp[9],tp[10],tp[11],tp[12],tp[13],tp[14],tp[15]);
+
+            // netapi_dump_buf((long*)p_pkt,len);
 #endif
            }
            //check tag 
-           tag_cmp = memcmp(&p_pkt[len-12],(char*) &hash[0],12); //todo, really use meta->authTagLen
+           printf("recv_sb_cb(); auth tag size %d\n", p_sa_info->auth_tag_size);
+           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.n_auth_ok += !(tag_cmp);
            
             flip_and_send_pkt(tip, p_pkt, len,1);  //flip packet to echo back and send
@@ -1244,24 +1443,28 @@ unsigned long time, delta_time;
            hash[0]= htonl( meta[i].u.rx_sb_meta->pAuthTag[0]);
            hash[1]= htonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
            hash[2]= htonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
+           hash[3]= htonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
            stats.sb_tx+=1;
            if(stats.sb_tx<=16)
            {
              char *tp1 = (char *) &hash[0];
              //dump_header((long*)p_pkt, stats.sb_tx, (int)meta[i].u.rx_sb_meta->appId,0);
-#if 0
-             printf("tag in original rx pkt=%x %x %x %x %x %x %x %x %x %x %x %x\n",
+#if 1
+            printf("encrypt complete: tag in pkt=  %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x \n",
+                      p_pkt[len-16],p_pkt[len-15],p_pkt[len-14],p_pkt[len-13],
                       p_pkt[len-12],p_pkt[len-11],p_pkt[len-10],p_pkt[len-9], p_pkt[len-8],
                       p_pkt[len-7],p_pkt[len-6],
                       p_pkt[len-5],p_pkt[len-4],p_pkt[len-3],p_pkt[len-2],p_pkt[len-1]);
-
-             printf("tag from SA=%x %x %x %x %x %x %x %x %x %x %x %x\n",
+             printf("encrypt complete: tag from SA=%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x \n",
                        tp1[0],tp1[1],tp1[2],tp1[3],tp1[4],tp1[5],
-                       tp1[6],tp1[7],tp1[8],tp1[9],tp1[10],tp1[11]);
+                       tp1[6],tp1[7],tp1[8],tp1[9],tp1[10],tp1[11],tp1[12],tp1[13],tp1[14],tp1[15]);
+             //netapi_dump_buf((long*)p_pkt,len);
 #endif
            }
            //put the computed tag in the packet
-           memcpy(&p_pkt[len-12],(char*)&hash[0],12); //todo, really use meta->authTagLen
+           memcpy(&p_pkt[len-p_sa_info->auth_tag_size],(char*)&hash[0],p_sa_info->auth_tag_size); //todo, really use meta->authTagLen
+          printf("recv_sb_cb(): dumping pkt after updating computed tag, len %d, auth tag size %d\n", len, p_sa_info->auth_tag_size);
+           //netapi_dump_buf(p_pkt, len);
            {
           PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
            nwalTxPktInfo_t meta_tx={0};
@@ -1274,14 +1477,16 @@ unsigned long time, delta_time;
            meta_tx.l4OffBytes = 0;
            meta_tx.l4HdrLen = 0;
            meta_tx.ploadLen = 0;
-            time = netapi_timing_start();
+            time = hplib_mUtil_GetTickCount();
             delta_time = time -(unsigned long) meta[i].u.rx_sb_meta->appCtxId;
            stats.total_encrypt_time += delta_time;
         
 
            /* post it to netcp tx channel*/
            meta2.u.tx_meta=&meta_tx;
+           printf("recv_sb_cb(): calling pktio send to send it to network\n");
            pktio_send(netcp_tx_chan,tip,&meta2,&err);
+           hplib_CacheWbInv(p_pkt,len);
            stats.tx +=1;
            }
         }
@@ -1296,53 +1501,49 @@ 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;
-HEAD_T * p_res;
-Ti_Pkt * tip;
-unsigned int templen;
-int err;
-KEY_T key;
-char * p_pkt;
-HEAD_T * p_head;
-HEAD_T temp_head;
-netTestSA_t *p_sa_info;
-uint8_t *p_spi;
-uint8_t p_iv[16];
-Cppi_HostDesc*          pPloadDesc;
+    int i;
+    int len;
+    int p;
+    HEAD_T * p_res;
+    Ti_Pkt * tip;
+    unsigned int templen;
+    int err = 0;
+    KEY_T key;
+    char * p_pkt;
+    HEAD_T * p_head;
+    HEAD_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;
 
     p_head=&temp_head;
 
-    //debug
-#if 0
-    if (n_pkts != TX_BURST) {
-      printf("recv_cb, txsofar=%d rxsofar=%d  np = %d, NOT %d\n", 
-             stats.itx, stats.rx, n_pkts,TX_BURST);
-      our_stats_cb(netapi_handle,NULL);
-    }
-#endif
-    //test_alloc_free(7);
-    //printf("recv start\n");
-
     /* 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)-4;//real length, subtract mac trailer
+        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);
+        printf("recv_cb() packet len %d\n", len);
 
         //debug: validate descriptor */
         if(Pktlib_getNextPacket(tip) != 0) 
         {
             printf(" rcv_cb, nexpkt != NULL");
         }
-        //debug printf("recv pkt, len=%d %d\n", len, templen);
+
         stats.rx+=1;
 
-#ifdef DEBUG_DESC
+#if 1
         if (stats.rx<16)
         {
             printf(">rx dmp.."); 
@@ -1358,75 +1559,153 @@ Cppi_HostDesc*          pPloadDesc;
         if(stats.rx<=16)
         {
             dump_header((long*)p_pkt, stats.rx, (int)meta[i].u.rx_meta->appId,meta[i].u.rx_meta->rxFlag1);
+             netapi_dump_buf((long*)p_pkt,len);
         }
 #endif
         /* check header */
         memcpy(p_head,&p_pkt[14],sizeof(HEAD_T));
 
+        /* check for IPSEC packet, 0x32 is ESP tunnel mode */
         if ((p_head->ip[2]&0x0000ff00)==0x00003200)
         {
             if (!check_header(p_head,&meta[i]))
             {
+                printf("check header failed\n");
                 stats.n_bad+=1;Pktlib_freePacket(tip); 
                 continue;
             }
 
+            //process IP SEC PACKET
+            if (config.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND)
+            {
+#if 0
+                {
+                    
+                    uint8_t             count;
+                    NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) netapi_handle;
+
+
+
+
+                    printf("\n ------------- NWAL MODULE UNIT TEST BEGIN ------------- \n");
+                    retVal =
+                    nwal_getGlobCxtInfo(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, 
+                                        &nwalGlobCxt);
+                    if(retVal == nwal_OK)
+                    {
+                        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");
+                    }
+                    printf(" calling nwal_getLocCxtInfo for tx channel\n");
+                    nwal_getLocCxtInfo(PKTIO_GET_NWAL_INSTANCE(netcp_sb_tx_chan),
+                                                      &nwalLocCxt);
+                    printf(" calling nwal_getLocCxtInfo for rx channel\n");
+                    nwal_getLocCxtInfo(PKTIO_GET_NWAL_INSTANCE(netcp_sb_rx_chan),
+                                                      &nwalLocCxt);
+
+                    
+              }
+#endif
+
 
 
+                
+                p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
+                 p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa, (char *)p_spi ,4);
+                if (p_sa_info == NULL)
+                {
+                    printf("recv_cb(): trie_lookup() failed\n");
+                    continue;
+                }
 
-            //process IP SEC PACKET
-        if (config.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, (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=p_sa_info->rx_data_mode_handle;
 
-           //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=p_sa_info->rx_data_mode_handle;
+                memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
 
-           memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
+                //meta_tx.ploadLen = len;
 
-           meta_tx.encSize = len - p_sa_info->tx_payload_info.encOffset -netTest_ICV_LEN;
-           meta_tx.authSize = len - meta_tx.authOffset - netTest_ICV_LEN;
 
-#if 0
-            printf("recv_cb(): encOffset %d\n", meta_tx.encOffset);
-            printf("recv_cb():authOffset %d\n", meta_tx.authOffset);
-            printf("recv_cb(): encSize %d\n", meta_tx.encSize);
-            printf("recv_cb(): authSize %d\n", meta_tx.authSize);
+
+                    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 1
+                printf("recv_cb(): packet length %d\n", len);
+                printf("recv_cb(): encOffset %d\n", meta_tx.encOffset);
+                printf("recv_cb():authOffset %d\n", meta_tx.authOffset);
+                printf("recv_cb(): encSize %d\n", meta_tx.encSize);
+                printf("recv_cb(): authSize %d\n", meta_tx.authSize);
 #endif
 
-            if (p_sa_info->cipherMode ==  NWAL_SA_EALG_AES_CTR)
-            {
-                memcpy(&p_iv[0], &ourEncrKey[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_NULL)
-            {
-                meta_tx.pEncIV = NULL;
-            }
-            else
+                if (p_sa_info->cipherMode == NWAL_SA_EALG_AES_CTR)
+                {
+                    memcpy(&p_iv[0], &ourEncrKey[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->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)hplib_mUtil_GetTickCount();
+                //printf("recv_cb appCtxId: %lu\n", meta_tx.appCtxId);
+
+                /* post it to netcp sb tx channel*/
+            meta2.u.tx_sb_meta=&meta_tx;
+
+/* TODO: Move the following ifdef code into ptkio_sendDM */
+#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
+            /* Use the command label which was cached during create time
+            * Update the Queue to receive output packet from SA to the local 
+            * core Queue. Below information can be saved by application in 
+            * per process context to avoid API overhead per packet
+            * Application can use below rxSbSaQ for polling packets back from
+            * SA
+            */
+            nwalRetVal =  
+            nwal_getLocCxtInfo(PKTIO_GET_NWAL_INSTANCE(netcp_sb_tx_chan),
+                                                      &nwalLocCxt);
+            if(nwalRetVal == nwal_OK)
             {
-                meta_tx.pEncIV = &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN ];
+                p_sa_info->rx_dmPSCmdInfo.rxSbSaQ = nwalLocCxt.rxSbSaQ;
             }
-            meta_tx.appCtxId = (nwal_AppId)netapi_timing_start();
-            //printf("recv_cb appCtxId: %lu\n", meta_tx.appCtxId);
-
-           /* post it to netcp sb tx channel*/
-           meta2.u.tx_sb_meta=&meta_tx;
-#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API            
             nwal_mCmdDMUpdate(tip,
                               &p_sa_info->rx_dmPSCmdInfo,
                               meta_tx.appCtxId,
@@ -1438,16 +1717,16 @@ Cppi_HostDesc*          pPloadDesc;
                               meta_tx.pAuthIV,
                               meta_tx.aadSize,
                               meta_tx.pAad);
-             pPloadDesc = Pktlib_getDescFromPacket(tip);
-             pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
-             Qmss_queuePushDescSizeRaw(p_sa_info->tx_dmPSCmdInfo.txQueue,
+            pPloadDesc = Pktlib_getDescFromPacket(tip);
+            pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
+            Qmss_queuePushDescSizeRaw(p_sa_info->rx_dmPSCmdInfo.txQueue,
                                        pPloadDesc,
                                        NWAL_DESC_SIZE);
 
 #else
-           pktio_send(netcp_sb_tx_chan,tip,&meta2,&err);
+            pktio_send(netcp_sb_tx_chan,tip,&meta2,&err);
 #endif
-           continue;
+            continue;
         }
         else 
             //inflow mode.  flip and send
@@ -1459,10 +1738,11 @@ Cppi_HostDesc*          pPloadDesc;
     }
     else  //non ipsec
     {
-       if (!check_header(p_head,&meta[i])) { 
-               stats.n_bad+=1;Pktlib_freePacket(tip); 
-        continue;
-       }
+        if (!check_header(p_head,&meta[i]))
+        {
+            stats.n_bad+=1;Pktlib_freePacket(tip); 
+            continue;
+        }
 
 #if 0
        /* lookup flow */
@@ -1489,28 +1769,29 @@ Cppi_HostDesc*          pPloadDesc;
     //printf("recv done\n");
 }
 
+#ifdef TEST_TIMERS
 //timer callback 
-void our_timer_cb( NETAPI_TIMER_GROUP_HANDLE_T th,
+void our_timer_cb( HPLIB_TIMER_GROUP_HANDLE_T th,
         int n_fired,     //# timers fired
-        NETAPI_TIMER_LIST_T fired_list,
+        HPLIB_TIMER_LIST_T fired_list,
         uint64_t currentTime)
 {
 int i;
-NETAPI_TIMER_T tx;
+HPLIB_TIMER_T tx;
 int cookie;
 int err;
 unsigned long long et;
 //DEBUGprintf("TIMER CALLBACK @ %lld %d timers\n", currentTime, n_fired);
-tx = netapi_TimerGetFirst(fired_list);
+tx = hplib_Timer_GetFirst(fired_list);
 for(i=0;i<n_fired;i++)
 {
-  cookie = (int) netapi_TimerGetCookie(tx);
-  et =  netapi_TimerGetTs(tx); //debug
+  cookie = (int) hplib_Time_rGetCookie(tx);
+  et =  hplib_Timer_GetTs(tx); //debug
   //DEBUGprintf("   timer %d - cookie = %d expected ts=%lld (delta=%lld)\n", i, cookie, et, currentTime-et);
   if (cookie ==1)
   {  
      stats.n_t1+=1;
-     t1 = netapi_TimerGroupStartTimer(
+     t1 = hplib_Timer_Start(
         th,
         (void *) 1,
         100LL,  //timer group tics
@@ -1519,7 +1800,7 @@ for(i=0;i<n_fired;i++)
   else if (cookie ==2)
   {
       stats.n_t2+=1;
-      t2 = netapi_TimerGroupStartTimer(
+      t2 = hplib_Timer_Start(
         th,
         (void *) 2,
         200LL,  //timer group ticks
@@ -1528,23 +1809,23 @@ for(i=0;i<n_fired;i++)
   else
   {
     stats.n_t3+=1;
-    t3 = netapi_TimerGroupStartTimer(
+    t3 = hplib_Timer_Start(
         th,
         (void *) 3,
         300LL,  //timer group ticks
         &err);
     //cancel 1 and restart 1
-   netapi_TimerGroupCancel(th,t1,&err);
-   t1 = netapi_TimerGroupStartTimer(
+   hplib_Timer_Cancel(th,t1,&err);
+   t1 = hplib_Timer_Start(
         th,
         (void *) 1,
         100LL,  //timer group ticks
         &err);
  }
-  tx = netapi_TimerGetNext(fired_list,tx); 
+  tx = hplib_Timer_GetNext(fired_list,tx); 
 }
 }
-
+#endif
 void print_ipsec_stats(Sa_IpsecStats_t     *p_saIpsecStats, nwal_saAALG auth, nwal_saEALG cipher)
 {
 #if 0
@@ -1602,7 +1883,7 @@ unsigned long long cyclesL;
 unsigned long long ccyclesL; //cache cycles
 NETAPI_SA_STATS_T netapi_sa_stats;
 
-printf(">*****stats @ %lld\n", netapi_getTimestamp());
+printf(">*****stats @ %lld\n", hplib_mUtil_GetTimestamp());
 //printf("netcp_tx_handle check %x\n", netcp_tx_chan->back);
 printf(">itx=%d rx=%d tx=%d bad=%d slow=%d \n>rx_class0=%d rx_class1=%d rx_class2=%d  secRx=%d  secPRX=%d sb_rx=%d sb_tx=%d auth_ok=%d sec_tx=%d\n",
          stats.itx, stats.rx, stats.tx, stats.n_bad, stats.n_new, 
@@ -1695,9 +1976,12 @@ for(i=0;i<TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;i++)
    dump_descr(tip, i);
 }
 #endif
+#ifdef TEST_TIMERS
+//debug = dump timer polling stats
+dump_poll_stats();
 //debug = dump timer polling stats
 //dump_poll_stats();
-
+#endif
 #ifndef EXPERIMENTAL
     for (i = 0; i < MAX_SEC_INDEX; i++)
 #else
@@ -1736,6 +2020,7 @@ for(i=0;i<TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;i++)
                                    tx_sa[i].cipherMode);
         }
     }
+    netapi_dump_internal_heap_stats();
 }
 
 //******************************************************
@@ -1816,7 +2101,7 @@ if ((house_pkts_gened>0) && (! (house_pkts_gened%1000)) )
 
 
    /* set the pkt length */
-   vv1 = netapi_timing_start();
+   vv1 = hplib_mUtil_GetTickCount();
    Pktlib_setPacketLen(tip, len);
 
    /* set up meta data */
@@ -1860,20 +2145,20 @@ if ((house_pkts_gened>0) && (! (house_pkts_gened%1000)) )
    if(!first)
    {
        first++;
-       nwal_flow_vv1= netapi_timing_stop();
+       nwal_flow_vv1= hplib_mUtil_GetTickCount();
        if(nwal_initPSCmdInfo(PKTIO_GET_NWAL_INSTANCE(netcp_tx_chan),
                              &meta_tx,
                              &flowPSCmdInfo) != nwal_OK)
        {
            printf("nwal_initPSCmdInfo() ERROR \n");
        }
-       nwal_flow_vv2= netapi_timing_stop();
+       nwal_flow_vv2= hplib_mUtil_GetTickCount();
        nwal_sum_flow_vv1 += (nwal_flow_vv1-vv1); 
        nwal_sum_flow_vv2 += (nwal_flow_vv2-nwal_flow_vv1); 
    }
        
    cache_op_b1= Osal_cache_op_measure(&n_c_ops);
-   vv2= netapi_timing_stop();
+   vv2= hplib_mUtil_GetTickCount();
 #ifdef BEND_UDP_SEND
    nwal_mCmdSetL4CkSumPort(  tip,
                              &flowPSCmdInfo,
@@ -1893,7 +2178,7 @@ if ((house_pkts_gened>0) && (! (house_pkts_gened%1000)) )
    Qmss_queuePushDescSize (flowPSCmdInfo.txQueue, 
                         pPktDesc, 
                         NWAL_DESC_SIZE);
-   vv3= netapi_timing_stop();
+   vv3= hplib_mUtil_GetTickCount();
    cache_op_b2= Osal_cache_op_measure(&n_c_ops);
 
    sum_vv1 += (vv2-vv1);
@@ -1938,7 +2223,7 @@ if ((house_pkts_gened>0) && (! (house_pkts_gened%1000)) )
 
 void  build_sa_db(int i)
 {
-
+    long tmp_spi;
     if ((tx_sa[i].authMode == NWAL_SA_AALG_HMAC_SHA1) && (tx_sa[i].cipherMode == NWAL_SA_EALG_AES_CBC))
     {
         /* static configuration, will not change */
@@ -1951,8 +2236,6 @@ void  build_sa_db(int i)
                                                                     netTest_ESP_HEADER_LEN +
                                                                     netTest_AES_CBC_IV_LEN;
 
-       
-
         /* dynamic configuration, will  be calculated on the fly */
         sa_info[i].tx_payload_info.authSize = 0; /* pkt len - mac - ip -icv (12) */
         sa_info[i].tx_payload_info.encSize = 0;   /* authSize - esp header size (always 8 bytes) */
@@ -1983,7 +2266,10 @@ void  build_sa_db(int i)
        
         sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
 
-         trie_insert(p_trie_sa,(char *)&(tx_sa[i].spi),4, (void *) &sa_info[i]); //asociate with tx sa SPI
+        tmp_spi = htonl((long)(tx_sa[i].spi));
+         trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+         printf("*********** build_sa_db(): spi %d,0x%x\n", tx_sa[i].spi,tx_sa[i].spi);;
+         
          
     }
     else if ((tx_sa[i].authMode == NWAL_SA_AALG_HMAC_SHA2_256) && (tx_sa[i].cipherMode == NWAL_SA_EALG_AES_CTR))
@@ -1997,7 +2283,7 @@ void  build_sa_db(int i)
         sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
                                                                      netTest_IP_HEADER_LEN +
                                                                     netTest_ESP_HEADER_LEN +
-                                                                    netTest_AES_CTR_IV_PACKET_LEN;
+                                                                    netTest_AES_CTR_IV_LEN;
 
 
 
@@ -2033,9 +2319,10 @@ void  build_sa_db(int i)
        
         sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
 
-       trie_insert(p_trie_sa,(char *)&(tx_sa[i].spi),4, (void *) &sa_info[i]); //asociate with tx sa SPI
+        tmp_spi = htonl((long)(tx_sa[i].spi));
+         trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
     }
-    else if ((tx_sa[i].authMode == NWAL_SA_AALG_HMAC_SHA2_256) && (tx_sa[i].cipherMode == NWAL_SA_EALG_3DES_CBC))
+    else if ((tx_sa[i].authMode == NWAL_SA_AALG_NULL) && (tx_sa[i].cipherMode == NWAL_SA_EALG_3DES_CBC))
     {
         /* static configuration, will not change */
         sa_info[i].tx_payload_info.aadSize = 0;
@@ -2055,7 +2342,7 @@ void  build_sa_db(int i)
 
         sa_info[i].cipherMode = NWAL_SA_EALG_3DES_CBC;
         sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
-        sa_info[i].auth_tag_size = netTest_ICV_LEN;  /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
+        sa_info[i].auth_tag_size = 0;  /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
 #ifdef EXPERIMENTAL
         sa_info[i].iv_len=8;
         sa_info[i].bl=8;
@@ -2078,7 +2365,8 @@ void  build_sa_db(int i)
        
         sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
 
-       trie_insert(p_trie_sa,(char *)&(tx_sa[i].spi),4, (void *) &sa_info[i]); //asociate with tx sa SPI
+        tmp_spi = htonl((long)(tx_sa[i].spi));
+         trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
     }
     else if ((tx_sa[i].authMode == NWAL_SA_AALG_HMAC_MD5) && (rx_sa[i].cipherMode == NWAL_SA_EALG_NULL))
     {
@@ -2092,6 +2380,8 @@ void  build_sa_db(int i)
                                                                      netTest_IP_HEADER_LEN +
                                                                     netTest_ESP_HEADER_LEN +
                                                                     netTest_NULL_IV_LEN;
+
+        
 #ifdef EXPERIMENTAL
         sa_info[i].iv_len=0;
         sa_info[i].bl=4;
@@ -2123,9 +2413,160 @@ void  build_sa_db(int i)
         sa_info[i].tx_pkt_info.saPayloadLen = 0;
         sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
        
+        sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+        tmp_spi = htonl((long)(tx_sa[i].spi));
+         trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+    }
+    else if ((tx_sa[i].authMode == NWAL_SA_AALG_NULL) && (rx_sa[i].cipherMode == NWAL_SA_EALG_AES_GCM))
+    {
+        /* static configuration, will not change */
+        sa_info[i].tx_payload_info.aadSize = 0;
+        sa_info[i].tx_payload_info.pAad = NULL;
+        sa_info[i].tx_payload_info.pAuthIV = NULL;
+        sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;        /*done: same for all cipher suites */
+        //sa_info[i].tx_payload_info.encIvSize = netTest_AES_GCM_IV_LEN;
+
+        sa_info[i].tx_payload_info.encOffset =         netTest_MAC_HEADER_LEN +
+                                                                     netTest_IP_HEADER_LEN +
+                                                                    netTest_ESP_HEADER_LEN +
+                                                                    netTest_AES_GCM_IV_LEN;
+#ifdef EXPERIMENTAL
+        sa_info[i].iv_len=0;
+        sa_info[i].bl=4;
+        sa_info[i].spi = tx_sa[i].spi;
+        sa_info[i].src =*((unsigned int *)(&config.local_ipsec_ip.ipv4[0]));
+        sa_info[i].dst =*((unsigned int *)(&config.remote_ipsec_ip.ipv4[0]));
+#endif
+
+
+        /* dynamic configuration, will  be calculated on the fly */
+        sa_info[i].tx_payload_info.authSize = 0;
+        sa_info[i].tx_payload_info.encSize = 0;
+        //sa_info[i].tx_payload_info.ploadLen = 0;
+        sa_info[i].tx_payload_info.pEncIV = 0;
+        sa_info[i].tx_payload_info.pPkt = 0;
+
+        sa_info[i].cipherMode = NWAL_SA_EALG_AES_GCM;
+        sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].auth_tag_size = netTest_AES_GCM_CCM_ICV_LEN;  /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
+
+        sa_info[i].tx_pkt_info.enetPort = 0;
+        sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+        sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.startOffset = 0;
+        sa_info[i].tx_pkt_info.lpbackPass = 0;
+        sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+        sa_info[i].tx_pkt_info.pPkt = NULL;
+        sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.saPayloadLen = 0;
+        sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+       
         sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
 
-       trie_insert(p_trie_sa,(char *)&(tx_sa[i].spi),4, (void *) &sa_info[i]); //asociate with tx sa SPI
+        tmp_spi = htonl((long)(tx_sa[i].spi));
+         trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+    }
+    else if ((tx_sa[i].authMode == NWAL_SA_AALG_NULL) && (rx_sa[i].cipherMode == NWAL_SA_EALG_AES_CCM))
+    {
+        /* static configuration, will not change */
+        sa_info[i].tx_payload_info.aadSize = 0;
+        sa_info[i].tx_payload_info.pAad = NULL;
+        //sa_info[i].tx_payload_info.authIvSize = 0;
+        sa_info[i].tx_payload_info.pAuthIV = NULL;
+        sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;        /*done: same for all cipher suites */
+
+        sa_info[i].tx_payload_info.encOffset =         netTest_MAC_HEADER_LEN +
+                                                                     netTest_IP_HEADER_LEN +
+                                                                    netTest_ESP_HEADER_LEN +
+                                                                    netTest_AES_CCM_IV_LEN;
+#ifdef EXPERIMENTAL
+        sa_info[i].iv_len=0;
+        sa_info[i].bl=4;
+        sa_info[i].spi = tx_sa[i].spi;
+        sa_info[i].src =*((unsigned int *)(&config.local_ipsec_ip.ipv4[0]));
+        sa_info[i].dst =*((unsigned int *)(&config.remote_ipsec_ip.ipv4[0]));
+#endif
+
+
+        /* dynamic configuration, will  be calculated on the fly */
+        sa_info[i].tx_payload_info.authSize = 0;
+        sa_info[i].tx_payload_info.encSize = 0;
+        //sa_info[i].tx_payload_info.ploadLen = 0;
+        sa_info[i].tx_payload_info.pEncIV = 0;
+        sa_info[i].tx_payload_info.pPkt = 0;
+
+        sa_info[i].cipherMode = NWAL_SA_EALG_AES_CCM;
+        sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].auth_tag_size = netTest_AES_GCM_CCM_ICV_LEN;  /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
+
+        sa_info[i].tx_pkt_info.enetPort = 0;
+        sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+        sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.startOffset = 0;
+        sa_info[i].tx_pkt_info.lpbackPass = 0;
+        sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+        sa_info[i].tx_pkt_info.pPkt = NULL;
+        sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.saPayloadLen = 0;
+        sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+       
+        sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+
+        tmp_spi = htonl((long)(tx_sa[i].spi));
+         trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+    }
+    else if ((tx_sa[i].authMode == NWAL_SA_AALG_GMAC) && (rx_sa[i].cipherMode == NWAL_SA_EALG_NULL))
+    {
+        /* static configuration, will not change */
+        sa_info[i].tx_payload_info.aadSize = 0;
+        sa_info[i].tx_payload_info.pAad = NULL;
+        sa_info[i].tx_payload_info.pAuthIV = NULL;
+        sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+
+
+        sa_info[i].tx_payload_info.encOffset =         netTest_MAC_HEADER_LEN +
+                                                                     netTest_IP_HEADER_LEN +
+                                                                    netTest_ESP_HEADER_LEN +
+                                                                    netTest_AES_GMAC_IV_LEN;
+#ifdef EXPERIMENTAL
+        sa_info[i].iv_len=0;
+        sa_info[i].bl=4;
+        sa_info[i].spi = tx_sa[i].spi;
+        sa_info[i].src =*((unsigned int *)(&config.local_ipsec_ip.ipv4[0]));
+        sa_info[i].dst =*((unsigned int *)(&config.remote_ipsec_ip.ipv4[0]));
+#endif
+
+
+        /* dynamic configuration, will  be calculated on the fly */
+        sa_info[i].tx_payload_info.authSize = 0;
+        sa_info[i].tx_payload_info.encSize = 0;
+        //sa_info[i].tx_payload_info.ploadLen = 0;
+        sa_info[i].tx_payload_info.pEncIV = 0;
+        sa_info[i].tx_payload_info.pPkt = 0;
+
+        sa_info[i].cipherMode = NWAL_SA_EALG_NULL;
+        sa_info[i].authMode = NWAL_SA_AALG_GMAC;
+        sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].auth_tag_size = netTest_AES_GMAC_ICV_LEN;  /* icv or mac size,. always 12 except for AES_CCM/AES_GCM , GMAC*/
+
+        sa_info[i].tx_pkt_info.enetPort = 0;
+        sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+        sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.startOffset = 0;
+        sa_info[i].tx_pkt_info.lpbackPass = 0;
+        sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+        sa_info[i].tx_pkt_info.pPkt = NULL;
+        sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.saPayloadLen = 0;
+        sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+       
+        sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+
+        tmp_spi = htonl((long)(tx_sa[i].spi));
+         trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
     }
     else
         printf("build_sa_db(): invalid encryption/authentication combination selected\n");
@@ -2151,7 +2592,7 @@ void  build_sa_db(int i)
         if(strcmp(key, ARG1) == 0) { \
         if(data) strncpy(ARG2,data,CONFIG_STRING_LEN); \
         if(data2) strncpy(ARG3,data2,CONFIG_STRING_LEN); \
-        printf("CHECK_SET_PARM, match found, input cong string %s %s\n", ARG2, ARG3); \
+        printf("CHECK_SET_PARM2, match found, input cong string %s %s\n", ARG2, ARG3); \
         continue; \
         } \
     } while(0)
@@ -2225,7 +2666,6 @@ void parse_ip_address(netTestConfigFile_t *pConfig)
 void parse_ipsec_mode(netTestConfigFile_t *pConfig)
 {
 
-    printf("parse_ipsec_mode, string length %d\n", strlen(&pConfig->ipsec_mode_rx));
     if (strlen(&pConfig->ipsec_mode_rx[0]))
     {
         if (strcmp(pConfig->ipsec_mode_rx, "SIDEBAND") == 0)
@@ -2548,7 +2988,7 @@ netcp_cfgCreateMacInterface(
 if (err) {printf("addmac0 failed %d\n",err); exit(1); } 
 
 //attach an IP to this interface
-ip_rule0=netcp_addIp(
+ip_rule0=netcp_cfgAddIp(
                   netapi_handle,
                   0,
                   nwal_IPV4,
@@ -2571,7 +3011,7 @@ netcp_cfgCreateMacInterface(
 if (err) {printf("addmac1 failed %d\n",err); exit(1); }
 
 //attach an IP to this interface
-ip_rule1=netcp_addIp(
+ip_rule1=netcp_cfgAddIp(
                   netapi_handle,
                   1,
                   nwal_IPV4,
@@ -2733,32 +3173,31 @@ if (err) {printf("addTxSa failed %d\n",err); exit(1);}
 
 #ifdef TEST_TIMERS
 //timers
-ourTimerBlock = netapi_TimerGroupCreate(
+ourTimerBlock = hplib_Timer_CreateGroup(
         netapi_handle,
         "our1sttimer",
         our_timer_cb,
         0,    //1 if timers local to thread
         0,    //1 if expect to cancel
-        netapi_getTicksPerSec()/1000,  /* 1 msc resolution for these timers */
-        netapi_getTicksPerSec()/5000, /* would like .5 msc tolerence */
-        10,  //small # of timers to test garbage collection
-        &err);
-if (err) {printf("timergroupcreate failed %d\n",err); exit(1);}
+        hplib_getTicksPerSec()/1000,  /* 1 msc resolution for these timers */
+        hplib_getTicksPerSec()/5000, /* would like .5 msc tolerence */
+        10);  //small # of timers to test garbage collection
+if (err) {printf("hplib_Timer_CreateGroup() failed %d\n",err); exit(1);}
 
 //start a couple of timers 
-t1 = netapi_TimerGroupStartTimer(
+t1 = hplib_Timer_Start(
         ourTimerBlock,
         (void *) 1,
         100LL,  //timer group ticks
         &err);
 if (err) {printf("timerstart failed %d\n");}
-t2 = netapi_TimerGroupStartTimer(
+t2 = hplib_Timer_Start(
         ourTimerBlock,
         (void *) 2,
         200LL,  //timer group ticks
         &err);
 if (err) {printf("timerstart failed %d\n");}
-t3 = netapi_TimerGroupStartTimer(
+t3 = hplib_Timer_Start(
         ourTimerBlock,
         (void *) 3,
         300LL,  //timer group ticks
@@ -2901,39 +3340,39 @@ Qmss_QueueHnd freeQ=Pktlib_getInternalHeapQueue(h);
 for(i=0;i<n_trials;i++)
 {
     //raw pop
-    t1= netapi_timing_start();
+    t1= hplib_mUtil_GetTickCount();
     pHd[0] = (Ti_Pkt *)QMSS_DESC_PTR(PKTIO_QMSS_QUEUE_POP_RAW (freeQ));
     for(j=1;j<NTOPOP;j++)
     {
-       tempVA  =  _Osal_qmssPhyToVirt(pHd[j-1]);
+       tempVA  =  hplib_mVM_PhyToVirt(pHd[j-1]);
        netapi_pld(tempVA);
         //__builtin_prefetch(tempVA);
        pHd[j] = (Ti_Pkt *)QMSS_DESC_PTR(PKTIO_QMSS_QUEUE_POP_RAW (freeQ));
        sumf+= (int) (   ((Cppi_HostDesc *) tempVA)->origBuffPtr -
                   ((Cppi_HostDesc *) tempVA)->buffPtr);
     }
-    tempVA  =  _Osal_qmssPhyToVirt(pHd[j-1]);
+    tempVA  =  hplib_mVM_PhyToVirt(pHd[j-1]);
     sumf+= (int) (   ((Cppi_HostDesc *) tempVA)->origBuffPtr -
                   ((Cppi_HostDesc *) tempVA)->buffPtr);
-    t2=netapi_timing_stop();
+    t2=hplib_mUtil_GetTickCount();
     sumt+= (t2-t1);
 
     //invalidate/wb 
     for(j=0;j<NTOPOP;j++)
     {
-        tempVA  =  _Osal_qmssPhyToVirt(pHd[j]);
-        netapi_utilCacheWbInv(tempVA,128);
+        tempVA  =  hplib_mVM_PhyToVirt(pHd[j]);
+        hplib_CacheWbInv(tempVA,128);
     }
 
     //raw push 
-    t1=netapi_timing_start();
+    t1=hplib_mUtil_GetTickCount();
     for(j=0;j<NTOPOP;j++)
     {
         PKTIO_QMSS_QUEUE_PUSH_DESC_SIZE_RAW (freeQ,
                                              (void *) pHd[j],
                                              128);
     }
-    t2=netapi_timing_stop();
+    t2=hplib_mUtil_GetTickCount();
     sump += (t2-t1);
 }
 printf("\nfast poppush: np=%d  pop=%d  push=%d sumf=%d\n", (n_trials*NTOPOP),
@@ -2969,14 +3408,14 @@ Qmss_QueueHnd freeQ;
 //loop forever
 for(;max_pkts>0;)
 {
-    t1= netapi_timing_stop();
+    t1= hplib_mUtil_GetTickCount();
     pHd[0] = (Ti_Pkt *)QMSS_DESC_PTR(PKTIO_QMSS_QUEUE_POP_RAW (rxQ));
     if (!pHd[0]) continue;
     //got pkt
     for(i=1;(i<n) && (pHd[i-1]);i++)
     {
         //convert previous descriptor PA -> VA
-        tempVA  =  Osal_qmssPhyToVirt(pHd[i-1]); 
+        tempVA  =  hplib_mVM_PhyToVirt(pHd[i-1]); 
 
         //try and preload desriptor
          __builtin_prefetch(tempVA);
@@ -3006,7 +3445,7 @@ for(;max_pkts>0;)
     if(pHd[i-1])
     {
         //convert previous descriptor PA -> VA
-        tempVA  =  Osal_qmssPhyToVirt(pHd[i-1]); 
+        tempVA  =  hplib_mVM_PhyToVirt(pHd[i-1]); 
 
         /* extract some meta data */
 #if 1
@@ -3022,7 +3461,7 @@ for(;max_pkts>0;)
         Cppi_getData (Cppi_DescType_HOST, (Cppi_Desc*)tempVA, &buf[jj], &len[jj]);
         jj+=1;
     }
-    t2= netapi_timing_stop();
+    t2= hplib_mUtil_GetTickCount();
     j+=(pHd[i-1]? i: (i-1)) ;
     if (jj>(M-n)) jj=0;
     l+=1;  //n batches
@@ -3047,18 +3486,18 @@ for(;max_pkts>0;)
         {
 
         //tempVA=Qmss_osalConvertDescPhyToVirt(pHd[k]);
-        tempVA  =  Osal_qmssPhyToVirt(pHd[k]);
+        tempVA  =  hplib_mVM_PhyToVirt(pHd[k]);
         freeQ=Qmss_getQueueHandle(Cppi_getReturnQueue (Cppi_DescType_HOST, (Cppi_Desc *)tempVA));
-        netapi_utilCacheWbInv(tempVA,128);
+        hplib_CacheWbInv(tempVA,128);
         //would need to wbInv buffer also in practice. Also need to walk
         // descriptor chain 
-        t11= netapi_timing_stop();
+        t11= hplib_mUtil_GetTickCount();
        // Pktlib_freePacket(tempVA);
         PKTIO_QMSS_QUEUE_PUSH_DESC_SIZE_RAW (freeQ,
                                              (void *) pHd[k],
                                              128);
 
-        t12= netapi_timing_stop();
+        t12= hplib_mUtil_GetTickCount();
         sumf += (t12-t11);       
         }
     }
@@ -3086,7 +3525,7 @@ for(;max_pkts>0;)
         if(!pHd[0]) break;
        tempVA  =  Osal_qmssPhyToVirt(pHd[0]);
         freeQ=Qmss_getQueueHandle(Cppi_getReturnQueue (Cppi_DescType_HOST, (Cppi_Desc *)tempVA));
-        netapi_utilCacheWbInv(tempVA,128);
+        hplib_CacheWbInv(tempVA,128);
         PKTIO_QMSS_QUEUE_PUSH_DESC_SIZE_RAW (freeQ,
                                              (void *) pHd[0],
                                              128);
@@ -3102,7 +3541,7 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec)
   int err=0;
   PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
   nwalTxPktInfo_t meta_tx2={0};
-  st1=netapi_timing_start();
+  st1=hplib_mUtil_GetTickCount();
   if (len<60) 
   { 
      unsigned int templen;
@@ -3129,7 +3568,7 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec)
   meta2.u.tx_meta=&meta_tx2;
   pktio_send(netcp_tx_chan,tip,&meta2,&err);
   stats.tx +=1;
-  st2=netapi_timing_start();
+  st2=hplib_mUtil_GetTickCount();
   stats.send_cycles += (unsigned long long) (st2-st1);  
 } 
 void recv_cb_router(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
@@ -3152,7 +3591,7 @@ unsigned long ct1;
 unsigned long ct2;
 unsigned short ip_pl;
 int n_c_ops;
-t1=netapi_timing_start();
+t1=hplib_mUtil_GetTickCount();
 ct1 =Osal_cache_op_measure(&n_c_ops);
 for(i=0;i<n_pkts;i++)
 {
@@ -3239,7 +3678,7 @@ for(i=0;i<n_pkts;i++)
               break;
        }
 }
-t2=netapi_timing_start();
+t2=hplib_mUtil_GetTickCount();
 ct2 =Osal_cache_op_measure(&n_c_ops);
 stats.app_cycles +=  (unsigned long long) (t2-t1);
 stats.tx_cache_cycles += (unsigned long long) (ct2-ct1);