Integration with highperf-lib
authorTinku Mannan <tmannan@ti.com>
Mon, 22 Oct 2012 20:51:56 +0000 (16:51 -0400)
committerTinku Mannan <tmannan@ti.com>
Mon, 22 Oct 2012 20:53:53 +0000 (16:53 -0400)
16 files changed:
ti/runtime/netapi/build/Makefile
ti/runtime/netapi/netapi.h
ti/runtime/netapi/netapi_tune.h
ti/runtime/netapi/netapi_util.h
ti/runtime/netapi/netsync.h
ti/runtime/netapi/src/netapi.c
ti/runtime/netapi/src/netapi_init.c
ti/runtime/netapi/src/netapi_loc.h
ti/runtime/netapi/src/netapi_sched.c
ti/runtime/netapi/src/netapi_sec.c
ti/runtime/netapi/src/osal.c
ti/runtime/netapi/src/pdk/v2/netapi_navig.c [changed mode: 0644->0755]
ti/runtime/netapi/src/pdk/v3/netapi_navig.c [changed mode: 0644->0755]
ti/runtime/netapi/test/build/Makefile
ti/runtime/netapi/test/net_test.c
ti/runtime/netapi/test/net_test.h

index 7e2be20e9bbe913b30ffeeddc7b199d4e8013ac9..f68540bdb8ac945ee5779d58e971e4ff218166f8 100755 (executable)
@@ -1,8 +1,9 @@
 # INCLUDE Directories
 QMSS_INC_DIR = $(PDK_INSTALL_PATH)/ti/drv/qmss
 CPPI_INC_DIR = $(PDK_INSTALL_PATH)/ti/drv/cppi
+HPLIB_INC_DIR = $(HPLIB_INSTALL_PATH)/ti/runtime/hplib
 
-INCDIR := $(PDK_INSTALL_PATH);  $(QMSS_INC_DIR); $(CPPI_INC_DIR)
+INCDIR := $(PDK_INSTALL_PATH);  $(QMSS_INC_DIR); $(CPPI_INC_DIR); $(HPLIB_INC_DIR)
 
 export PDK_VER ?= v2
 NETAPI_NAVIG_INIT_SRC=$(NETAPI_INC_DIR)/src/pdk/$(PDK_VER)
@@ -46,16 +47,12 @@ COMMONSRCC = \
     netapi_sec.c \
     netapi_init.c \
     netapi_sched.c \
-    netapi_timer.c \
-    netapi_vm.c \
     netcp_cfg.c \
     osal.c \
     pktio.c \
-    tim64.c\
     netapi_navig.c\
-    timlist.c
 
-CFLAGS= $(DEBUG_FLAG) -I$(NETAPI_INC_DIR) -I.  -I $(SRCDIR) -I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(TRANS_SDK_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(QMSS_DEV_DIR) -I$(CPPI_DEV_DIR) -I$(NETAPI_NAVIG_INIT_SRC) -I$(SA_INSTALL_PATH) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD -pthread -D _GNU_SOURCE
+CFLAGS= $(DEBUG_FLAG) -I$(NETAPI_INC_DIR) -I.  -I $(SRCDIR) -I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(TRANS_SDK_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(HPLIB_INC_DIR) -I$(QMSS_DEV_DIR) -I$(CPPI_DEV_DIR) -I$(NETAPI_NAVIG_INIT_SRC) -I$(SA_INSTALL_PATH) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD -pthread -D _GNU_SOURCE
 INCS = -I$(strip $(subst ;, -I,$(subst $(space),\$(space),$(INCDIR))))
 all: lib
 
index 56f814ab7c2e7268a9474b907414cf8efdca07a0..a1081c5b6a8e76c2fd071a5bb5c058185b05baa2 100755 (executable)
@@ -81,7 +81,7 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
-
+#include "hplib.h"
 
 
 /* Define NETAPI as a master group in Doxygen format and
@@ -94,8 +94,8 @@
 /** @} */
 
 
-
-
+extern HPLIB_VirtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
+extern unsigned char *netapi_VM_SaContextVaddr;
 
 /** @defgroup netapi_gen_functions NETAPI General Functions
  *  @ingroup netapi
@@ -225,12 +225,9 @@ typedef void * NETAPI_T;
 #include "netcp_cfg.h"
 #include "netapi_sec.h"
 #include "netapi_sched.h"
-#include "src/netapi_vm.h"
-#include "netapi_util.h"
-#include "netsync.h"
 #include "ti/drv/nwal/nwal.h"
-#include "netapi_timer.h"
 #include "src/netapi_loc.h"
+#include "hplib.h"
 
 /**
  *  @ingroup netapi_gen_functions
index 5f40430ecccd9038ed90b06063dce9500864be44..c8f2b5e2a57269820ed339af689469e68405357a 100755 (executable)
  * @def TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS
  *      This defines the number maximum number of ipsec channels
  */
-#define TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS     32
+#define TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS     64
 #else
 /**
  * @ingroup tune_parameters
 * @def  TUNE_NETAPI_MAX_SA
 *       This defines the maximum number of security associations
 */
-#define TUNE_NETAPI_MAX_SA 8   //rx&tx combined (so MAX_SA/4 tunnels typically)
+#define TUNE_NETAPI_MAX_SA 64   //rx&tx combined (so MAX_SA/4 tunnels typically)
 
 /**
  * @ingroup tune_parameters
  * @def  TUNE_NETAPI_MAX_POLICY
  *      This defines the maximum number of security policies.
 */
-#define TUNE_NETAPI_MAX_POLICY 8  //rx policies
+#define TUNE_NETAPI_MAX_POLICY 64  //rx policies
 
 #endif
index c3e43b3d34749e5e77600cf47f44084998030cbc..931d5e48678e56d63c7fff52ec0099ebfb2eb9a6 100755 (executable)
@@ -78,15 +78,7 @@ void Osal_cache_op_measure_reset(void);
 unsigned int Osal_cache_op_measure(int * p_n) ;
 
 //utility to convert virt2phy, phy2virt
-static inline void* _Osal_qmssVirtToPhy (void *ptr)
-{
-    return (void *)(netapi_VM_mem_start_phy + ((uint8_t*)ptr - netapi_VM_mem_start));
-}
+#define _Osal_qmssVirtToPhy hplib_mVM_VirtToPhy
 
-static inline void * _Osal_qmssPhyToVirt (void *ptr)
-{
-    if (!ptr) return (void *) 0;
-    //todo, see if out of range of mem_start_phy and size!! (like mmu would do)
-    return (void *)(netapi_VM_mem_start + ((uint8_t*)ptr - netapi_VM_mem_start_phy));
-}
+#define _Osal_qmssPhyToVirt hplib_mVM_PhyToVirt
 #endif
index 8ab74729a00509ced215ba91b71c5adc488a522f..b290949821deb0b0cc9b468c2c578c26d0b03be7 100755 (executable)
 #ifndef NETAPI_SYNC_H
 #define NETAPI_SYNCH_H
 
+#include "hplib_sync.h"
+
 /*--------------------------*/
 /*----------spinlock--------*/
 /*--------------------------*/
 
-typedef int NETAPI_SPINLOCK_T;
+#define  NETAPI_SPINLOCK_T HPLIB_SPINLOCK_T
 
-#define NETAPI_SPINLOCK_LOCKVAL 1
-#define NETAPI_SPINLOCK_UNLOCKVAL 0 //never change!!
+#define NETAPI_SPINLOCK_LOCKVAL HPLIB_SPINLOCK_LOCKVAL
+#define NETAPI_SPINLOCK_UNLOCKVAL HPLIB_SPINLOCK_UNLOCKVAL
 #define NETAPI_SPINLOCK_UNLOCKED_INITIALIZER (NETAPI_SPINLOCK_UNLOCKVAL)
 
 /* init a lock */
-static inline void netapi_spinlock_init (NETAPI_SPINLOCK_T * val) {*val=NETAPI_SPINLOCK_UNLOCKVAL;}
+#define netapi_spinlock_init hplib_mSpinlockInit
 
 /* lock a spinlock */
-static inline void netapi_spinlock_lock(NETAPI_SPINLOCK_T * val)
-{
-while(__sync_lock_test_and_set(val, NETAPI_SPINLOCK_LOCKVAL))
-    {
-        asm volatile("nop" ::  );
-        asm volatile("nop" ::  );
-        asm volatile("nop" ::  );
-        asm volatile("nop" ::  );
-    }
-}
+#define netapi_spinlock_lock hplib_mSpinlockLock
 
-/* try to get lock 1 time. Return 1 if ok, 0 if un-successful */
-static inline int netapi_spinlock_try_lock( NETAPI_SPINLOCK_T* val)
-{
-  int i=0;
-  if (__sync_lock_test_and_set(val, NETAPI_SPINLOCK_LOCKVAL))  return 0;
-  return 1;
-}
 
+/* try to get lock 1 time. Return 1 if ok, 0 if un-successful */
+#define netapi_spinlock_try_lock hplib_mSpinlockTryLock
 
 /* unlock a spinlock.   */
-static inline void netapi_spinlock_unlock(NETAPI_SPINLOCK_T * val)
-{
-  __sync_lock_release(val);
-}
+#define netapi_spinlock_unlock hplib_mSpinlockUnlock
 
 /* poll a lock, return 0 if unlocked, NETAPI_SPINLOCK_LOCKVAL if locked */
-static inline int netapi_spinlock_is_locked(NETAPI_SPINLOCK_T * val)
-{
-   return *val;
-}
+#define netapi_spinlock_is_locked hplib_mSpinlockIsLocked
+
 
 /*--------------------------*/
 /*----------rwlock--------*/
 /*--------------------------*/
 
 /* a rw lock strucuture */
-typedef struct RWLOCK_Tag
-{
-      NETAPI_SPINLOCK_T lock_outer; //lock this structure. very short duration lock
-      NETAPI_SPINLOCK_T lock_w;     //real write lock
-      unsigned long n_readers; /* # readers active */
-} NETAPI_RWLOCK_T;
+#define  NETAPI_RWLOCK_T HPLIB_RWLOCK_T
 
 //initialize a rw lock 
-static inline void netapi_rwlock_init(NETAPI_RWLOCK_T * p_lock)
-{
-        netapi_spinlock_init(&p_lock->lock_outer);
-       netapi_spinlock_init(&p_lock->lock_w);
-        p_lock->n_readers=0;
-}
+#define netapi_rwlock_init hplib_mRWlockInit
 
 // lock a write lock.  
-static inline void netapi_rwlock_write_lock(NETAPI_RWLOCK_T * p_lock)
-{
-  int ret;
-  while(1)
-  {
-        netapi_spinlock_lock(&p_lock->lock_outer); //get outer lock - now nothing can change
-       // check for 0 readers
-        if(p_lock->n_readers)
-        {
-           netapi_spinlock_unlock(&p_lock->lock_outer); //give up outer & spin
-           asm volatile("nop" ::  );
-           asm volatile("nop" ::  );
-           asm volatile("nop" ::  );
-           asm volatile("nop" ::  );
-           continue;
-        }
-
-       //ok, no readers.  see if we can get writer lock
-        ret=netapi_spinlock_try_lock(&p_lock->lock_w); //try get writer lock 1 time
-        if(!ret)      
-        {
-           netapi_spinlock_unlock(&p_lock->lock_outer); //give up outer & spin
-           asm volatile("nop" ::  );
-           asm volatile("nop" ::  );
-           asm volatile("nop" ::  );
-           asm volatile("nop" ::  );
-           continue;  /* try again */
-        }
-        netapi_spinlock_unlock(&p_lock->lock_outer); //got write lock=> no other writer, no readers!  Keep the writelock but unlock the outer.
-        return;
-  }
-}
+#define netapi_rwlock_write_lock hplib_mRWlockWriteLock
+
 
 //unlock a writer part of rwlock */
-static inline void netapi_rwlock_write_unlock(NETAPI_RWLOCK_T * p_lock)
-{
-  netapi_spinlock_unlock(&p_lock->lock_w);
-}
+#define netapi_rwlock_write_unlock hplib_mRWlockWriteUnlock
 
 //grab a read lock
 //=> can be other readers, but no writer
-static inline void netapi_rwlock_read_lock(NETAPI_RWLOCK_T * p_lock)
-{
-int ret;
-
-while(1)
-{
-  /*1st grab outer lock. once we have it, nothing can change */
-  netapi_spinlock_lock(&p_lock->lock_outer);
-
-  /* see if there is a writer */
-  ret= netapi_spinlock_is_locked(&p_lock->lock_w);
-
-  //there is a writer
-  if (ret)
-  {
-     netapi_spinlock_unlock(&p_lock->lock_outer);  //give up outer and spin
-     asm volatile("nop" ::  );
-     asm volatile("nop" ::  );
-     asm volatile("nop" ::  );
-     asm volatile("nop" ::  );
-     continue; 
-  }
-
-  /* there is no writer so we can read!*/
-  p_lock->n_readers+=1;
-
-  /* mb ? */
-  __sync_synchronize();  //make sure every core sees that n_readers has changed
-
-  /* now give back the outer lock */
-  netapi_spinlock_unlock(&p_lock->lock_outer);
-  return;
-}
-}
+#define netapi_rwlock_read_lock hplib_mRWlockReadLock
 
 //rw_lock reader unlock
-static inline void netapi_rwlock_read_unlock(NETAPI_RWLOCK_T * p_lock)
-{
-  //grab outer
-  netapi_spinlock_lock(&p_lock->lock_outer);
-
-  //decrement # of readers.  Make sure all cores see update
-  p_lock->n_readers--;
-  __sync_synchronize(); 
-  //TBD: need to check for <0? 
-  
-  /* give up the outer */
-  netapi_spinlock_unlock(&p_lock->lock_outer);
-}
+#define netapi_rwlock_read_unlock hplib_mRWlockReadUnlock
+
 
 /*--------------------------*/
 /*----------atomic32--------*/
 /*--------------------------*/
-typedef struct NETAPI_ATOMIC32_tag
-{
-       long val;
-} NETAPI_ATOMIC32_T;
+#define NETAPI_ATOMIC32_T HPLIB_ATOMIC32_T
+
+
+
+#define NETAPI_ATOMIC_INIT32 HPLIB_ATOMIC_INIT32
 
-#define NETAPI_ATOMIC_INIT32(x) {x}
-static inline int netapi_atomic_read32(NETAPI_ATOMIC32_T *p) {return p->val;}
+#define netapi_atomic_read32 hplib_mAtomic32Read
 
-static inline void netapi_atomic_set32(NETAPI_ATOMIC32_T *p, int val) 
-{__sync_fetch_and_add(&p->val,0); } //todo crude, why not p->val=val?
+#define netapi_atomic_set32 hplib_mAtomic32Set
 
-static inline void netapi_atomic_add32(NETAPI_ATOMIC32_T *p, int val)
-{__sync_fetch_and_add(&p->val,val);}
+#define netapi_atomic_add32 hplib_mAtomic32Add
 
-static inline void netapi_atomic_sub32(NETAPI_ATOMIC32_T *p, int val)
-{__sync_fetch_and_sub(&p->val,val);}
+#define netapi_atomic_sub32 hplib_mAtomic32Sub
 
-#define NETAPI_atomic_inc32(p) netapi_atomic_add32(p,1);
-#define NETAPI_atomic_dec32(p) netapi_atomic_sub32(p,1);
+#define NETAPI_atomic_inc32 HPLIB_mAtomic32Inc
 
-static inline int netapi_atomic_add_return32(NETAPI_ATOMIC32_T *p, int val)
-{return __sync_add_and_fetch(&p->val,val);}
+#define NETAPI_atomic_dec32(p) HPLIB_mAtomic32Dec
 
-static inline int netapi_atomic_sub_return32(NETAPI_ATOMIC32_T *p, int val)
-{return __sync_sub_and_fetch(&p->val,val);}
+#define netapi_atomic_add_return32 hplib_mAtomic32DecReturn
 
-static inline int netapi_atomic_inc_and_test32(NETAPI_ATOMIC32_T *p)
-{return __sync_add_and_fetch(&p->val,1);}
 
-static inline int netapi_atomic_dec_and_test32(NETAPI_ATOMIC32_T *p)
-{return !__sync_sub_and_fetch(&p->val,1);}
+#define netapi_atomic_sub_return32 hplib_mAtomic32SubReturn
 
-static inline int netapi_atomic_test_and_set32(NETAPI_ATOMIC32_T *p)
-{return (! _sync_lock_test_and_set(p, 1));}
 
-#define netapi_atomic_clear32(p) netapi_atomic_set32(p,0);
+#define netapi_atomic_inc_and_test32 hplib_mAtomic32IncAndTest
+
+#define netapi_atomic_dec_and_test32 hplib_mAtomic32DecAndTest
+
+#define netapi_atomic_test_and_set32 hplib_mAtomic32TestSetReturn
+
+#define netapi_atomic_clear32(p) hplib_mAtomic32Clear
 
 /*--------------------------*/
 /*----------atomic64--------*/
 /*--------------------------*/
-typedef struct NETAPI_ATOMIC64_Tag
-{
-       NETAPI_SPINLOCK_T lock;
-       long long val;
-} NETAPI_ATOMIC64_T;
-
-#define NETAPI_ATOMIC_INIT64(x) {NETAPI_SPINLOCK_UNLOCKED_INITIALIZER,x}
-
-static inline long long  netapi_atomic_read64(NETAPI_ATOMIC64_T *p)
-{
-long long latch_val;
-netapi_spinlock_lock(&p->lock);  //acquire lock
-latch_val = p->val;
-netapi_spinlock_unlock(&p->lock);  //free lock
-return latch_val;
-}
-
-static inline void netapi_atomic_set64(NETAPI_ATOMIC64_T *p,long long val)
-{
-netapi_spinlock_lock(&p->lock);  //acquire lock
-p->val = val;
-//__sync_synchronize();  //todo: may not need as unlock will do this also probably
-netapi_spinlock_unlock(&p->lock);  //free lock
-}
-
-static inline void netapi_atomic_add64(NETAPI_ATOMIC64_T *p, long long val) 
-{
-netapi_spinlock_lock(&p->lock);  //acquire lock
-p->val += val;
-//__sync_synchronize();  //todo: may not need as unlock will do this also probably
-netapi_spinlock_unlock(&p->lock);  //free lock
-}
+#define NETAPI_ATOMIC64_T HPLIB_ATOMIC64_T
+
+
+#define NETAPI_ATOMIC_INIT64(x) HPLIB_mATOMIC64_INIT
+
+#define netapi_atomic_read64 hplib_mAtomic64Read
+
+#define netapi_atomic_set64 hplib_mAtomic64Set
+
+#define netapi_atomic_add64 hplib_mAtomic64Add
 
 /*******************************************************
  ****************memory barrier************************
 ******************************************************/
-static inline void netapi_mb(){__sync_synchronize();}
-static inline void netapi_rmb(){__sync_synchronize();}
-static inline void netapi_wmb(){__sync_synchronize();}
+#define netapi_mb hplib_MB
+#define netapi_rmb hplib_RMB
+#define netapi_wmb hplib_WMB
 
 
 #endif
index 6a4d29aa2d632311f8bad21012a1ccbe9fc8b863..c62e0f430812e3d5ceec2a137925f7da7a07903e 100755 (executable)
@@ -80,9 +80,17 @@ TUNE_NETAPI_DEFAULT_NUM_BUFFERS,   //#descriptors+buffers in default heap
 TUNE_NETAPI_DEFAULT_NUM_SOLO_DESCRIPTORS, //#descriptors w/o buffers in default heap
 TUNE_NETAPI_DEFAULT_BUFFER_SIZE,   //size of buffers in default heap
 0,0
-
 };
 
+/* Global variablesto hold virtual address of various subsystems */
+HPLIB_VirtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
+/* Global variables which needs to be populated with memory pool attributes
+    which is passed to HPLIB for memory pool initialization*/
+ HPLIB_MemPool_Attr_T netapi_VM_MempoolAttr[HPLIB_MAX_MEM_POOLS];
+unsigned char *netapi_VM_QMemLocalDescRam;
+unsigned char *netapi_VM_QMemGlobalDescRam;
+unsigned char *netapi_VM_SaContextVaddr;
+
 static Pktlib_HeapIfTable  netapi_pktlib_ifTable;
 static NETAPI_GLOBAL_T netapi_global;
 NETAPI_GLOBAL_T * netapi_get_global(){ return &netapi_global;}
@@ -181,7 +189,7 @@ void netapi_shutdown(NETAPI_T h)
                 if (p->createdHeaps[i])  {netapi_closeHeap(h,p->createdHeaps[i]);p->createdHeaps[i]=NULL;}
            }
            netapi_cleanup_at_start();  //clear 1st 50 not-specified queues..
-           netapi_VM_memory_teardown();
+           hplib_VM_Teardown();
         } 
        free(p);
         return;
@@ -193,7 +201,7 @@ void netapi_err_teardown() { netapi_cleanup_at_start(); exit(-99); }
 /*-------------------utilities-------------------*/
 static uint8_t* netapiSharedMemoryMalloc(uint32_t size)
 {
-return  (uint8_t *)netapi_VM_memAlloc(size +netapi_global.cfg.def_heap_extra_size , 128); 
+return  (uint8_t *)hplib_VM_MemAlloc(size +netapi_global.cfg.def_heap_extra_size , 128, HPLIB_POOL_TYPE_DDR); 
 }
 
 static void netapiSharedMemoryFree(uint8_t* ptr, uint32_t size)
@@ -212,13 +220,55 @@ static int system_init(NETAPI_HANDLE_T * handle)
     Pktlib_HeapCfg      heapCfg;
     int32_t             errCode;
 
+    /* Init attributes for DDR */
+    netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_CACHE;
+    netapi_VM_MempoolAttr[0].phys_addr = 0;
+    netapi_VM_MempoolAttr[0].size = 0;
+
+       /* Init attributes for un-cached MSMC */
+    netapi_VM_MempoolAttr[1].attr = 0;
+    netapi_VM_MempoolAttr[1].phys_addr = CSL_MSMC_SRAM_REGS;
+    netapi_VM_MempoolAttr[1].size = TUNE_NETAPI_PERM_MEM_SZ;
     /* initialize all the memory we are going to use
        - chunk for buffers, descriptors
        - memory mapped peripherals we use, such as QMSS, PA, etc */
-    result= netapi_VM_memory_setup();
-    if (result) printf(">netapi: system init - memory set  up OK\n");
+    result = hplib_VM_Init(&netapi_VM_VirtAddr[0], 2, &netapi_VM_MempoolAttr[0]);
+    /* TODO: at this point, we need to create the QM regions which need to moved out of the above 
+    netapi_VM_memory_setup() call, also need to move out the SA context stuff */
+       
+    if (result == hplib_OK) printf(">netapi: system init - memory set  up OK\n");
     else {printf(">netap: system init - memory set up failed\n"); return -1;}
 
+
+#ifdef NETAPI_ENABLE_SECURITY
+#define SEC_CONTEXT_SZ 384  //not tunable
+/* allocate 2x number of tunnels since we need one for inflow and one for data mode */
+    netapi_VM_SaContextVaddr = hplib_VM_MemAlloc((TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2 *
+                                        SEC_CONTEXT_SZ), 128, HPLIB_POOL_TYPE_DDR);
+   if (!netapi_VM_SaContextVaddr)
+    {
+        printf(">netapi ERROR: Failed to map SA context memory region\n");
+        return (-1);
+    }
+    printf(">hplib VM_SaContext: Memory mapped/allocated at address %p.\n", netapi_VM_SaContextVaddr);
+
+#else
+   netapi_VM_SaContextVaddr= (char *) NULL;
+#endif
+
+/* TODO: the QM regions is application specific and needs to be moved since number of regions created is appliction specific, put this in system_init */
+    /* (3) Allocate 2 QM regions from continguous chunk above */
+    netapi_VM_QMemGlobalDescRam = 
+                                                            (void *)hplib_VM_MemAlloc((TUNE_NETAPI_NUM_GLOBAL_DESC *
+                                                                                                        TUNE_NETAPI_DESC_SIZE),
+                                                                                                        128, HPLIB_POOL_TYPE_DDR);
+
+    netapi_VM_QMemLocalDescRam =
+                                                            (void *)hplib_VM_MemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
+                                                                                                        TUNE_NETAPI_DESC_SIZE),
+                                                                                                        128, HPLIB_POOL_TYPE_DDR);
+    printf(">netapi local desc region=%x global desc region=%x\n", netapi_VM_QMemLocalDescRam, netapi_VM_QMemGlobalDescRam);
+
     //get timer running
     netapi_init_timer();
 
@@ -438,15 +488,38 @@ netapi_zapQ(q);
 
 
 
+netapi_getBufMemRemainder(void)
+{
+    hplib_VM_GetBufMemRemainder(HPLIB_POOL_TYPE_DDR);
+}
 
 
 
+void netapi_dump_internal_heap_stats(void)
+{
+Pktlib_HeapStats    pktLibHeapStats;
+Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2sa_heap,&pktLibHeapStats);
+printf("PA2SA(ingress) stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
+printf("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+                        pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
+                        pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
+#if 0
+Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2saTX_heap,&pktLibHeapStats);
+printf("PA2SA(egress) stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
+printf("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+                        pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
+                        pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
+#endif
+Pktlib_getHeapStats(netapi_get_global()->nwal_context.sa2pa_heap,&pktLibHeapStats);
+printf("SA2PA stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
+printf("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+                        pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
+                        pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
 
-
-
-
-
-
+}
 
 
 
index 6b860a7bdd185331013a3d697fc1cc588f372fe2..4cbcd96823d1145cfa6411cef48786e1fa611f84 100755 (executable)
@@ -49,7 +49,6 @@
 
 #include <ti/drv/nwal/nwal.h>
 #include "netapi.h"
-#include "netapi_vm.h"
 #include "netapi_loc.h"
 #include "ti/drv/nwal/nwal.h"
 
@@ -290,8 +289,8 @@ int netapi_init_nwal(
     nwalGlobCfg.saFwActive = nwal_FALSE;
 
     /* Pick Default Physical Address */
-    nwalGlobCfg.paVirtBaseAddr = (uint32_t) netapi_VM_passCfgVaddr;
-    nwalGlobCfg.saVirtBaseAddr = (uint32_t) netapi_VM_passCfgVaddr +
+    nwalGlobCfg.paVirtBaseAddr = (uint32_t) netapi_VM_VirtAddr->passCfgVaddr;
+    nwalGlobCfg.saVirtBaseAddr = (uint32_t) netapi_VM_VirtAddr->passCfgVaddr +
                                  ((uint32_t)CSL_PA_SS_CFG_CP_ACE_CFG_REGS - (uint32_t)CSL_PA_SS_CFG_REGS) ;
     nwalGlobCfg.rxDefPktQ = QMSS_PARAM_NOT_SPECIFIED;
 
index c66e1c6da0f59fc5beb40408882c20d37242b182..44ad682d11296031559a4281665a997d171420ea 100755 (executable)
@@ -239,8 +239,6 @@ int netapi_qm_setup_mem_region(
 #define NETAPI_GLOBAL_REGION TUNE_NETAPI_QM_GLOBAL_REGION 
 #define NETAPI_LOCAL_REGION ((NETAPI_GLOBAL_REGION)+1) 
 
-int netapi_VM_memory_setup(void);
-void netapi_VM_memory_teardown(void);
 
 //nwal callbacks
 void netapi_NWALRxPktCallback     (uint32_t            appCookie,
index d9f6b1b010e02de59bff084aba915b3c27997118..f3a62054fffbf94cac5c7583d84835351c0b0182 100755 (executable)
@@ -71,7 +71,7 @@ NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T n, NETAPI_SCHED_CONFIG_T * p_c
   if(!ph) {*p_err= NETAPI_ERR_NOMEM; return NULL;}
   if(!p_config) {*p_err=  NETAPI_ERR_BAD_INPUT; return NULL;}
   memcpy(&ph->config,p_config,sizeof(NETAPI_SCHED_CONFIG_T));
-  ph->start =   netapi_getTimestamp();
+  ph->start =   hplib_mUtil_GetTimestamp();
   ph->back = (void *) n;
   if (ph->config.valid_flags & NETAPI_SCHED_DURATION)
   {
@@ -104,7 +104,7 @@ int netapi_schedWaitForEvents(NETAPI_SCHED_HANDLE_T *s, int *p_err)
 {
   int err;
   *p_err=0;
-  unsigned long long t =  netapi_getTimestamp();
+  unsigned long long t =  hplib_mUtil_GetTimestamp();
   int next_house;
   volatile int pkts;
   volatile unsigned long t1;
@@ -117,14 +117,14 @@ int netapi_schedWaitForEvents(NETAPI_SCHED_HANDLE_T *s, int *p_err)
   for(;t< s->shutdown_time;)
   {
 #ifndef NO_TIMER
-    t = netapi_getTimestamp();
+    t = hplib_mUtil_GetTimestamp();
 #endif
     next_house -=1;
     //poll all  pktio channels we have open in RX mode 
      Osal_cache_op_measure_reset();
-     t1=netapi_timing_start();
+     t1=hplib_mUtil_GetTickCount();
      pkts=pktio_pollAll((NETAPI_T) s->back, NULL, &err);
-     t2=netapi_timing_start();
+     t2=hplib_mUtil_GetTickCount();
      if (pkts)
      {
         netapi_sched_num_pkts+= (unsigned long long) pkts;
@@ -137,10 +137,10 @@ int netapi_schedWaitForEvents(NETAPI_SCHED_HANDLE_T *s, int *p_err)
     //poll pktlib garbage collections for registered heaps..
     netapi_pollHeapGarbage((NETAPI_T) s->back);
 #endif    
-    
+
 #ifndef NO_TIMER
     //todo timers (local and global)
-    netapi_TimerGroupPollAll((NETAPI_T) s->back, NETAPI_TIMER_FITLER_ALL, 100000);
+    hplib_TimerPollAllGroups((NETAPI_T) s->back, HPLIB_TIMER_FITLER_ALL, 100000);
 #endif
     //poll NETCP/PA control channels 
     netapi_netcpPoll((NETAPI_T) s->back);
index 9b7ba92f7bcc9c25efb6d4d722d4432c4ea03cb9..388e2e19052489a86ccd1ed8e4494c157f3fd486 100755 (executable)
@@ -80,10 +80,10 @@ nwalCreateSAParams_t    createParam =
         NWAL_SA_DIR_INBOUND,
         0,
         0,
-        NWAL_SA_AALG_HMAC_SHA1,  //update
-        NWAL_SA_EALG_AES_CTR, //update
+        NWAL_SA_AALG_HMAC_SHA1,                     /* update from input */
+        NWAL_SA_EALG_AES_CTR,                       /* update from input */
         { 0x00},      /* remMacAddr:  NA */
-        12, /* macSize */
+        12,                                                         /* update from input, mac size */
         NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE,       /* Continue parsing to next route for match */
         NWAL_NEXT_ROUTE_FAIL_ACTION_HOST,            /* For next route fail action by default is route to host */
         CPPI_PARAM_NOT_SPECIFIED,                    /* Use default flow configured to NWAL  if packet is routed to host */
@@ -129,11 +129,17 @@ nwalCreateSAParams_t    createParam =
     createParam.saIpSecParam.cipherMode = sa_info->cipherMode;
     createParam.saIpSecParam.esnLo = sa_info->esnLo;
     createParam.saIpSecParam.esnHi = sa_info->esnHi;
-     if  (sa_info->authMode == NWAL_SA_AALG_NULL)
-     {
-            createParam.saIpSecParam.replayWindow = 0;
-            createParam.saIpSecParam.macSize = 0;
-     }
+    if ((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) || (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))
+    {
+       createParam.saIpSecParam.macSize = 16;
+    }
+    if  ((sa_info->authMode == NWAL_SA_AALG_NULL) && 
+        (!((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) || 
+           (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))))
+    {
+        createParam.saIpSecParam.replayWindow = 0;
+        createParam.saIpSecParam.macSize = 0;
+    }
     memcpy(&createParam.keyParam,key_params,sizeof(nwalSecKeyParams_t));
 
     if (route != NULL)
@@ -197,6 +203,19 @@ nwalCreateSAParams_t    createParam =
         dmSaParam.dmSaParam.macSize=12;        /**todo: pass in or deduce */
         dmSaParam.dmSaParam.aadSize=0;        /**todo: pass in or deduce */
         dmSaParam.dmSaParam.enc1st =  (sa_info->dir ==NWAL_SA_DIR_OUTBOUND) ? nwal_TRUE : nwal_FALSE;  //encypt 1st for outbound
+        if ((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) || (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))
+        {
+            dmSaParam.dmSaParam.macSize = 16;
+            dmSaParam.dmSaParam.aadSize=8;
+            /* Enc1st needs to always be true for combined mode algorithms */
+            dmSaParam.dmSaParam.enc1st = nwal_TRUE;
+        }
+       else
+        {
+            dmSaParam.dmSaParam.macSize=12;        /**todo: pass in or deduce */
+            dmSaParam.dmSaParam.aadSize=0;        /**todo: pass in or deduce */
+        }
+
        if  (sa_info->authMode == NWAL_SA_AALG_NULL)
        {
             dmSaParam.dmSaParam.enc1st = nwal_TRUE;
index eb29c1a2496c5dd8f8d211a93a3de52b83bd6ebf..77c7720c2cf5be5e42ace328dcf85a66e12cb584 100755 (executable)
@@ -50,8 +50,7 @@
 #include <stdio.h>
 
 #include "netapi_tune.h"
-#include "netapi_vm.h"
-#include "netapi_timer.h"
+#include "hplib.h"
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/types.h>
@@ -61,8 +60,9 @@
 #include <errno.h>
 #include <string.h>
 #include "netapi_util.h"
-#include "tools/module/netapimod.h"
+#include "hplibmod.h"
 #include <ti/drv/sa/sa_osal.h>
+#include <ti/runtime/pktlib/pktlib.h>
 #define System_printf   printf
 
 uint32_t              Osal_qmss_MallocCounter =0;
@@ -113,121 +113,6 @@ static inline void nwalTest_osalLeaveCS()
 }
 
 #endif
-
-unsigned long peek(unsigned long * p)
-{
-   return *p;
-}
-
-
-/**********USE SPACE ACCESS TO KERNEL MEMORY SERVICES*************/
-static int netapi_fd;
-
-/***init **/
-int netapi_utilModInit(void)
-{
-    netapi_fd = open("/dev/netapi", O_RDWR);
-
-    if (netapi_fd == -1) {
-        return -1;
-    }
-    return netapi_fd;
-}
-
-/***close **/
-void netapi_utilModClose(void)
-{
-    close(netapi_fd);
-}
-
-/* return physical address of region kernel module has allocated for us */
-unsigned long netapi_utilGetPhysOfBufferArea(void)
-{
-    unsigned long physp;
-
-    if (ioctl(netapi_fd, NETAPIMOD_IOCGETPHYS | NETAPIMOD_IOCMAGIC, &physp) == -1) {
-        return 0;
-    }
-    return physp;
-}
-
-/* return the size of that region */
-unsigned long netapi_utilGetSizeOfBufferArea(void)
-{
-    unsigned long size;
-
-    if (ioctl(netapi_fd, NETAPIMOD_IOCGETSIZE | NETAPIMOD_IOCMAGIC, &size) == -1) {
-        return 0;
-    }
-    return size;
-}
-
-//*****for the actual wb, inv cache ops, call the osal_xxx version, not these directly
-// (so make inline)
-/** write back operation on block */
-static inline int _netapi_utilCacheWb(void *ptr, size_t size)
-{
-    struct netapimod_block block;
-
-    block.addr = (unsigned long)ptr;
-    block.size = size;
-
-    if (ioctl(netapi_fd, NETAPIMOD_IOCCACHEWB | NETAPIMOD_IOCMAGIC, &block) == -1) {
-        return -1;
-    }
-    return 0;
-}
-int netapi_utilCacheWb(void *ptr, size_t size) {return _netapi_utilCacheWb(ptr,size);}
-
-/** write back & invalidate **/
-static inline int _netapi_utilCacheWbInv(void *ptr, size_t size)
-{
-    struct netapimod_block block;
-
-    block.addr = (unsigned long)ptr;
-    block.size = size;
-
-    if (ioctl(netapi_fd, NETAPIMOD_IOCCACHEWBINV | NETAPIMOD_IOCMAGIC, &block) == -1) {
-        return -1;
-    }
-    return 0;
-}
-
-int netapi_utilCacheWbInv(void *ptr, size_t size) {return _netapi_utilCacheWbInv(ptr,size);}
-/** just invalidate **/
-static inline int _netapi_utilCacheInv(void *ptr, size_t size)
-{
-    struct netapimod_block block;
-
-    block.addr = (unsigned long)ptr;
-    block.size = size;
-
-    if (ioctl(netapi_fd, NETAPIMOD_IOCCACHEINV | NETAPIMOD_IOCMAGIC, &block) == -1) {
-        return -1;
-    }
-    return 0;
-}
-int netapi_utilCacheInv(void *ptr, size_t size) {return _netapi_utilCacheInv(ptr,size);}
-
-//***mmap the block into our user space process memory map.  */
-unsigned long netapi_utilGetVaOfBufferArea(unsigned int offset, unsigned int size)
-{
-    void *userp;
-
-    /* Map the physical address to user space */
-    userp = mmap(0,                       // Preferred start address
-                 size,            // Length to be mapped
-                 PROT_WRITE | PROT_READ,  // Read and write access
-                 MAP_SHARED,              // Shared memory
-                 netapi_fd,               // File descriptor
-                 offset);                      // The byte offset from fd
-
-    if (userp == MAP_FAILED) {
-        return 0;
-    }
-    return (unsigned long)userp;
-}
-
 static unsigned int cache_op_cycles=0;
 static unsigned int n_cache_op_cycles=0;
 void Osal_cache_op_measure_reset(void) { cache_op_cycles=0; n_cache_op_cycles=0;}
@@ -242,10 +127,10 @@ static inline void Osal_invalidateCache (void *blockPtr, uint32_t size)
     register unsigned int v1;
     register unsigned int v2;
      
-    v1= netapi_timing_stop();
-    if (((uint8_t*)blockPtr <netapi_VM_mem_start)||( (uint8_t*)blockPtr>netapi_VM_mem_end)) return;
-    _netapi_utilCacheInv(blockPtr, size);
-    v2= netapi_timing_stop();
+    v1= hplib_mUtil_GetTickCount();
+    if ((blockPtr <hplib_VM_mem_start)||( blockPtr>hplib_VM_mem_end)) return;
+    hplib_CacheInv(blockPtr, size);
+    v2= hplib_mUtil_GetTickCount();
     cache_op_cycles += (v2-v1); 
     n_cache_op_cycles+=1;
 #endif
@@ -268,22 +153,26 @@ static inline void Osal_writeBackCache (void *blockPtr, uint32_t size)
     register unsigned int v1;
     register unsigned int v2;
      
-    v1= netapi_timing_stop();
-    if (((uint8_t*)blockPtr <netapi_VM_mem_start)||( (uint8_t*)blockPtr>netapi_VM_mem_end)) return;
-    _netapi_utilCacheWbInv(blockPtr, size);
-    v2= netapi_timing_stop();
+    v1= hplib_mUtil_GetTickCount();
+    if (((uint8_t*)blockPtr <hplib_VM_mem_start)||( (uint8_t*)blockPtr>hplib_VM_mem_end)) return;
+    hplib_CacheWb(blockPtr, size);
+    v2= hplib_mUtil_GetTickCount();
     cache_op_cycles += (v2-v1); 
     n_cache_op_cycles+=1;
 #endif
     return;
 }
 
+static HPLIB_SPINLOCK_T qmss_lock = HPLIB_SPINLOCK_UNLOCKED_INITIALIZER;
+static HPLIB_SPINLOCK_T nwal_lock = HPLIB_SPINLOCK_UNLOCKED_INITIALIZER;
+static HPLIB_SPINLOCK_T hplib_lock = HPLIB_SPINLOCK_UNLOCKED_INITIALIZER;
 
 void *  Osal_qmssMtCsEnter()
 {
     /* Stub Function. TBD: Would need to handle when for multi proc access 
      * To be handled once infrastructure is available from Kernel
      */
+     //hplib_spinlock_lock(&qmss_lock)
     return NULL;
 }
 
@@ -293,6 +182,7 @@ void Osal_qmssMtCsExit(void *key)
     /* Stub Function. TBD: Would need to handle when for multi proc access 
      * To be handled once infrastructure is available from Kernel
      */
+      //hplib_spinlock_unlock(&qmss_lock)
     return;
 }
 
@@ -490,7 +380,7 @@ uint64_t Osal_nwalGetTimeStamp(void)
 {
     /* Stub function to return timestamp
      */
-    return netapi_getTimestamp();
+    return hplib_mUtil_GetTimestamp();
 }
 
 uint16_t Osal_saGetProcId (void )
@@ -504,7 +394,7 @@ void* Osal_saGetSCPhyAddr(void* vaddr)
     {
         return NULL;
     }
-    return (void *)(netapi_VM_mem_start_phy + ((uint8_t*) vaddr - netapi_VM_mem_start));
+    return (void *)(hplib_VM_mem_start_phy + ((uint8_t*) vaddr - hplib_VM_mem_start));
 
 }
 
@@ -635,17 +525,17 @@ void  Osal_pktLibExitCriticalSection(Pktlib_HeapHandle heapHandle, void* csHandl
 
 void* Osal_pktLibPhyToVirt(void *ptr)
 {
-    return(_Osal_qmssPhyToVirt(ptr));
+    return(hplib_mVM_PhyToVirt(ptr));
 }
 
 void* Osal_qmssVirtToPhy (void *ptr)
 {
-    return _Osal_qmssVirtToPhy(ptr);
+    return hplib_mVM_VirtToPhy(ptr);
 }
 
 void * Osal_qmssPhyToVirt (void *ptr)
 {
-    return _Osal_qmssPhyToVirt(ptr);
+    return hplib_mVM_PhyToVirt(ptr);
 }
 
 /******************************************************************************
@@ -656,106 +546,16 @@ void * Osal_qmssPhyToVirt (void *ptr)
                                   //define and just host will be assumed (more efficient)
 void* Osal_qmssConvertDescVirtToPhy(void *descAddr)
 {
-    if (!descAddr) return (void *)0;
-#ifdef ASSUME_ALL_DESCRIPTOR 
-    if (Cppi_getDescType((Cppi_Desc *)QMSS_DESC_PTR(descAddr)) == Cppi_DescType_HOST)
-#endif
-    {
-        Cppi_HostDesc *nextBDPtr = (Cppi_HostDesc *)QMSS_DESC_PTR(descAddr);
-        Cppi_HostDesc *prevBDPtr = 0;
-        while (nextBDPtr)
-        {
-            void *buffPtr=NULL;
-            if (nextBDPtr->buffPtr)
-            {
-                buffPtr = (void *)nextBDPtr->buffPtr;
-                nextBDPtr->buffPtr = (uint32_t)_Osal_qmssVirtToPhy((void *)(nextBDPtr->buffPtr));
-                if (!(nextBDPtr->buffPtr)) return (void *)0;
-                Osal_writeBackCache(buffPtr, nextBDPtr->buffLen);          
-            }
-
-            if (nextBDPtr->origBuffPtr)
-            {
-                nextBDPtr->origBuffPtr = (uint32_t)_Osal_qmssVirtToPhy((void *)(nextBDPtr->origBuffPtr));
-                if (!(nextBDPtr->origBuffPtr)) return (void *)0;
-            }
-
-            prevBDPtr = nextBDPtr;
-            nextBDPtr = (Cppi_HostDesc *)QMSS_DESC_PTR((nextBDPtr->nextBDPtr));
-            if (prevBDPtr->nextBDPtr)
-            {
-                prevBDPtr->nextBDPtr = (uint32_t)_Osal_qmssVirtToPhy((void *)(prevBDPtr->nextBDPtr));
-                if (!(prevBDPtr->nextBDPtr)) return (void *)0;
-            }
-
-            Osal_writeBackCache(prevBDPtr, TUNE_NETAPI_DESC_SIZE);
-        }
-        descAddr = _Osal_qmssVirtToPhy(descAddr);
-        if (!descAddr) return (void *)0;
-    }
-#ifdef ASSUME_ALL_DESCRIPTOR 
-    else if (Cppi_getDescType((Cppi_Desc *)QMSS_DESC_PTR(descAddr)) == Cppi_DescType_MONOLITHIC)
-    {
-        Osal_writeBackCache(descAddr, TUNE_NETAPI_DESC_SIZE);
-        descAddr = _Osal_qmssVirtToPhy(descAddr);
-        if (!descAddr) return (void *)0;
-    }
-#endif
-    return descAddr;
-
+       hplib_Util_ConvertDescVirtToPhy(descAddr);
 }
-
-
 /******************************************************************************
 * Function to traverse a CPPI descriptor and convert all address references
 * from physical to virtual.
 ******************************************************************************/
 void* Osal_qmssConvertDescPhyToVirt(void *descAddr)
 {
-    if (!descAddr) return (void *)0;
-    descAddr = _Osal_qmssPhyToVirt(descAddr);
-
-#ifdef ASSUME_ALL_DESCRIPTOR 
-    if (Cppi_getDescType((Cppi_Desc *)QMSS_DESC_PTR(descAddr)) == Cppi_DescType_HOST)
-#endif
-    {
-        Cppi_HostDesc *nextBDPtr = (Cppi_HostDesc *)QMSS_DESC_PTR(descAddr);
-        while (nextBDPtr)
-        {
-            Osal_invalidateCache(nextBDPtr, TUNE_NETAPI_DESC_SIZE);
-            if (nextBDPtr->buffPtr)
-            {
-                nextBDPtr->buffPtr = (uint32_t)_Osal_qmssPhyToVirt((void *)(nextBDPtr->buffPtr));
-                if (!(nextBDPtr->buffPtr)) return (void *)0;
-                Osal_invalidateCache((void *)(nextBDPtr->buffPtr), nextBDPtr->buffLen);
-            }
-
-            if (nextBDPtr->origBuffPtr)
-            {
-                nextBDPtr->origBuffPtr = (uint32_t)_Osal_qmssPhyToVirt((void *)(nextBDPtr->origBuffPtr));
-                if (!(nextBDPtr->origBuffPtr)) return (void *)0;
-            }
-
-            if (nextBDPtr->nextBDPtr)
-            {
-                nextBDPtr->nextBDPtr = (uint32_t)_Osal_qmssPhyToVirt((void *)(nextBDPtr->nextBDPtr));
-                if (!(nextBDPtr->nextBDPtr)) return (void *)0;
-            }
-
-            nextBDPtr = (void *)QMSS_DESC_PTR((nextBDPtr->nextBDPtr));
-        }
-    }
-#ifdef ASSUME_ALL_DESCRIPTOR 
-    else if (Cppi_getDescType((Cppi_Desc *)QMSS_DESC_PTR(descAddr)) == Cppi_DescType_MONOLITHIC)
-    {
-        descAddr = _Osal_qmssPhyToVirt(descAddr);
-        if (!descAddr) return (void *)0;
-        Osal_invalidateCache(descAddr, TUNE_NETAPI_DESC_SIZE);
-    }
-#endif
-    return descAddr;
+       hplib_Util_ConvertDescPhyToVirt(descAddr);
 }
-
 void* Osal_stubCsEnter (void)
 {
 
@@ -768,4 +568,15 @@ void Osal_stubCsExit (void *CsHandle)
 
     return;
 }
+void* Osal_hplibCsEnter (void)
+{
 
+       hplib_mSpinlockLock(&hplib_lock);
+
+}
+void Osal_hplibCsExit (void *CsHandle)
+{
+   hplib_mSpinlockUnlock(&hplib_lock);
+
+    return;
+}
old mode 100644 (file)
new mode 100755 (executable)
index cff6674..b14f0c1
@@ -50,7 +50,8 @@
 
 #include <ti/csl/cslr_device.h>
 #include <ti/drv/qmss/qmss_qm.h>
-#include "netapi_vm.h"
+#include "netapi.h"
+#include "hplib.h"
 
 //pull in device config for qmss, cppi
 #include "qmss_device.c"
@@ -84,79 +85,79 @@ int netapi_init_cppi(void)
 
   /* SRIO CPDMA regs */
   netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].gblCfgRegs =
-   NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+   NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                         CSL_SRIO_CONFIG_REGS,
                         (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].gblCfgRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].txChRegs =
-   NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+   NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                         CSL_SRIO_CONFIG_REGS,
                         (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].txChRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].rxChRegs =
-   NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+   NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                         CSL_SRIO_CONFIG_REGS,
                         (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].rxChRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].txSchedRegs =
-   NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+   NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                         CSL_SRIO_CONFIG_REGS,
                         (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].txSchedRegs);
 
  netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].rxFlowRegs =
-   NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+   NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                         CSL_SRIO_CONFIG_REGS,
                         (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].rxFlowRegs);
 
   /* PASS CPDMA regs */
   netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].gblCfgRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                          CSL_PA_SS_CFG_REGS,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].gblCfgRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].txChRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                          CSL_PA_SS_CFG_REGS,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].txChRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].rxChRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                          CSL_PA_SS_CFG_REGS,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].rxChRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].txSchedRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                          CSL_PA_SS_CFG_REGS,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].txSchedRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].rxFlowRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                          CSL_PA_SS_CFG_REGS,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].rxFlowRegs);
 
  /* QMSS CPDMA regs */
   netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].gblCfgRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].gblCfgRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].txChRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].txChRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].rxChRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].rxChRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].txSchedRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].txSchedRegs);
 
   netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs);
 
@@ -189,93 +190,94 @@ int netapi_init_qm(int max_descriptors)
   netapi_qmssGblCfgParams = qmssGblCfgParams[0];
 
   netapi_qmssGblCfgParams.qmConfigReg =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmConfigReg);
 
   netapi_qmssGblCfgParams.qmDescReg =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmDescReg);
 
   netapi_qmssGblCfgParams.qmQueMgmtReg =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmQueMgmtReg);
 
   netapi_qmssGblCfgParams.qmQueMgmtProxyReg =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmQueMgmtProxyReg);
 
   netapi_qmssGblCfgParams.qmQueStatReg =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmQueStatReg);
 
   netapi_qmssGblCfgParams.qmQueIntdReg =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmQueIntdReg);
 
   netapi_qmssGblCfgParams.qmPdspCmdReg[0] =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmPdspCmdReg[0]);
 
   netapi_qmssGblCfgParams.qmPdspCmdReg[1] =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmPdspCmdReg[1]);
 
   netapi_qmssGblCfgParams.qmPdspCtrlReg[0] =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmPdspCtrlReg[0]);
 
   netapi_qmssGblCfgParams.qmPdspCtrlReg[1] =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmPdspCtrlReg[1]);
 
   netapi_qmssGblCfgParams.qmPdspIRamReg[0] =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmPdspIRamReg[0]);
 
   netapi_qmssGblCfgParams.qmPdspIRamReg[1] =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmPdspIRamReg[1]);
 
   netapi_qmssGblCfgParams.qmStatusRAM =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmStatusRAM);
   netapi_qmssGblCfgParams.qmLinkingRAMReg =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmLinkingRAMReg);
   netapi_qmssGblCfgParams.qmMcDMAReg =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmMcDMAReg);
 
   netapi_qmssGblCfgParams.qmTimer16Reg[0] =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmTimer16Reg[0]);
 
   netapi_qmssGblCfgParams.qmTimer16Reg[1] =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                          QMSS_CFG_BASE_ADDR,
                          (uint32_t)netapi_qmssGblCfgParams.qmTimer16Reg[1]);
 
-  netapi_qmssGblCfgParams.qmQueMgmtDataReg = 
-                                (void *)((uint32_t)netapi_VM_qmssDataVaddr);
 
+  netapi_qmssGblCfgParams.qmQueMgmtDataReg = 
+                                                    (void *)((uint32_t)netapi_VM_VirtAddr->qmssDataVaddr);
+  
   netapi_qmssGblCfgParams.qmQueMgmtProxyDataReg =
-    NETAPI_GET_REG_VADDR(netapi_VM_qmssDataVaddr,
+    NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssDataVaddr,
                          QMSS_DATA_BASE_ADDR,
                          QMSS_DATA_ARM_PROXY_QUEUE_DEQUEUE_REGS);
 
old mode 100644 (file)
new mode 100755 (executable)
index c325ed1..2ba03ec
@@ -50,7 +50,8 @@
 
 #include <ti/csl/cslr_device.h>
 #include <ti/drv/qmss/qmss_qm.h>
-#include "netapi_vm.h"
+#include "netapi.h"
+#include "hplib.h"
 
 //pull in device config for qmss, cppi
 #include "qmss_device.c"
@@ -86,79 +87,79 @@ int netapi_init_cppi(void)
     /* Convert Physical address to Virtual address for LLD access */
     /* SRIO CPDMA regs */
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].gblCfgRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                              CSL_SRIO_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].gblCfgRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].txChRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                              CSL_SRIO_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].txChRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].rxChRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                              CSL_SRIO_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].rxChRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].txSchedRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                              CSL_SRIO_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].txSchedRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].rxFlowRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_srioCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
                              CSL_SRIO_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_SRIO_CPDMA].rxFlowRegs);
 
     /* PASS CPDMA regs */
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].gblCfgRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                              CSL_NETCP_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].gblCfgRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].txChRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                              CSL_NETCP_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].txChRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].rxChRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                              CSL_NETCP_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].rxChRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].txSchedRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                              CSL_NETCP_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].txSchedRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].rxFlowRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_passCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
                              CSL_NETCP_CFG_REGS,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].rxFlowRegs);
 
     /* QMSS CPDMA regs */
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].gblCfgRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                              QMSS_CFG_BASE_ADDR,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].gblCfgRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].txChRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                              QMSS_CFG_BASE_ADDR,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].txChRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxChRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                              QMSS_CFG_BASE_ADDR,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxChRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].txSchedRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                              QMSS_CFG_BASE_ADDR,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].txSchedRegs);
 
     netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs =
-        NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                              QMSS_CFG_BASE_ADDR,
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs);
     result = Cppi_init (&netapi_cppiGblCfgParams);
@@ -196,42 +197,42 @@ int netapi_init_qm(int max_descriptors)
     for(count=0;count < netapi_qmssGblCfgParams.maxQueMgrGroups;count++)
     {
         netapi_qmssGblCfgParams.groupRegs[count].qmConfigReg =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmConfigReg);
 
         netapi_qmssGblCfgParams.groupRegs[count].qmDescReg =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDRnetapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmDescReg);
 
         netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtReg =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtReg);
 
         netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtProxyReg =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtProxyReg);
 
         netapi_qmssGblCfgParams.groupRegs[count].qmQueStatReg =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmQueStatReg);
 
         netapi_qmssGblCfgParams.groupRegs[count].qmStatusRAM =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmStatusRAM);
 
         netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtDataReg =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssDataVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssDataVaddr,
                                  QMSS_DATA_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtDataReg);
 
         netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtProxyDataReg =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssDataVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssDataVaddr,
                                  QMSS_DATA_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtProxyDataReg);
     }
@@ -239,7 +240,7 @@ int netapi_init_qm(int max_descriptors)
     for(count=0;count < QMSS_MAX_INTD;count++)
     {
         netapi_qmssGblCfgParams.regs.qmQueIntdReg[count] =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.regs.qmQueIntdReg[count]);
     }
@@ -247,28 +248,28 @@ int netapi_init_qm(int max_descriptors)
     for(count=0;count < QMSS_MAX_PDSP;count++)
     {
         netapi_qmssGblCfgParams.regs.qmPdspCmdReg[count] =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.regs.qmPdspCmdReg[count]);
 
         netapi_qmssGblCfgParams.regs.qmPdspCtrlReg[count] =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.regs.qmPdspCtrlReg[count]);
 
         netapi_qmssGblCfgParams.regs.qmPdspIRamReg[count] =
-            NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+            NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                                  QMSS_CFG_BASE_ADDR,
                                  (uint32_t)netapi_qmssGblCfgParams.regs.qmPdspIRamReg[count]);
     }
 
     netapi_qmssGblCfgParams.regs.qmLinkingRAMReg =
-        NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                              QMSS_CFG_BASE_ADDR,
                              (uint32_t)netapi_qmssGblCfgParams.regs.qmLinkingRAMReg);
 
     netapi_qmssGblCfgParams.regs.qmBaseAddr =
-        NETAPI_GET_REG_VADDR(netapi_VM_qmssCfgVaddr,
+        NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
                              QMSS_CFG_BASE_ADDR,
                              (uint32_t)netapi_qmssGblCfgParams.regs.qmBaseAddr);
 
index 2e6f637cb3deca04c7a0f0d8e77386482af30115..f6a4635f35b044c88ab71fc174ae97f895287d85 100755 (executable)
@@ -13,6 +13,7 @@ QMSS_INC_DIR = $(PDK_INSTALL_PATH)/ti/drv/qmss
 CPPI_INC_DIR = $(PDK_INSTALL_PATH)/ti/drv/cppi
 
 NETAPI_INC_DIR = $(NETAPI_INSTALL_PATH)/ti/runtime/netapi
+HPLIB_INC_DIR = $(NETAPI_INSTALL_PATH)/ti/runtime/hplib
 SA_INC_DIR = $(SA_INSTALL_PATH)
 
 #NETAPI LIB Build directory
@@ -26,6 +27,7 @@ PA_LIB   = -lpa
 #NWAL_LIB = -lnwal
 PKTLIB_LIB = -lpktlib
 NETAPI_LIB = -lnetapi
+HP_LIB = -lhp
 #
 #with security enabled..
 NWAL_LIB = -lnwalsa
@@ -39,14 +41,14 @@ PKTUTL_LIB=$(SA_INSTALL_PATH)/ti/mas/pktutl/gcarmv7a/pktutl_c.av7A
 CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
 AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar -r
 
-CFLAGS= $(DEBUG_FLAG) -I../ -I. -I$(NETAPI_INC_DIR) -I$(NETAPI_INC_DIR)/src -I$(PDK_INSTALL_PATH)  -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(TRANS_SDK_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(SA_INC_DIR) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD -pthread -D _GNU_SOURCE
+CFLAGS= $(DEBUG_FLAG) -I../ -I. -I$(NETAPI_INC_DIR) -I$(NETAPI_INC_DIR)/src -I$(HPLIB_INC_DIR) -I$(PDK_INSTALL_PATH)  -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(HPLIB_INSTALL_PATH) -I$(TRANS_SDK_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(SA_INC_DIR) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD -pthread -D _GNU_SOURCE
 # Linker options
-INTERNALLINKDEFS = --start-group -L$(ARMV7LIBDIR) -L$(PDK_ARMV7LIBDIR) $(NETAPI_LIB) $(PKTLIB_LIB) $(QMSS_LIB) $(CPPI_LIB) $(NWAL_LIB) $(PA_LIB) $(SA_LIB) $(AES_LIB) $(SHA1_LIB) $(PKTUTL_LIB) -lrt --end-group
+INTERNALLINKDEFS = --start-group -L$(ARMV7LIBDIR) -L$(PDK_ARMV7LIBDIR) $(NETAPI_LIB) $(PKTLIB_LIB) $(HP_LIB) $(QMSS_LIB) $(CPPI_LIB) $(NWAL_LIB) $(PA_LIB) $(SA_LIB) $(AES_LIB) $(SHA1_LIB) $(PKTUTL_LIB) -lrt --end-group
 
 
 all: tests 
 
-tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test $(ARMV7BINDIR)/netapi/test/synchtest $(ARMV7BINDIR)/netapi/test/synchtest2 
+tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test
 
 api_clean:
        rm -f  $(ARMV7LIBDIR)/libnetapi.a
index ba5c75dca9b59e342dd102b408367856ba97026a..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");
+
+}
+
+
 /*****************************************/
 
 
@@ -310,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;
@@ -327,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=
@@ -359,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
@@ -408,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
 },
@@ -425,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
@@ -464,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
 },
@@ -480,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 */
@@ -499,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
 },
@@ -508,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 */
@@ -520,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
 },
@@ -536,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
 }
 };
 
@@ -654,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);
 }
 }
 
@@ -749,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;
@@ -778,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);
@@ -789,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); 
@@ -891,176 +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
-
-           meta_tx.encOffset =p_sa_info->tx_payload_info.encOffset;
-           
-           meta_tx.authOffset =netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN;
+            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.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;
+            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
+            /* 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),
+            nwalRetVal =  
+            nwal_getLocCxtInfo(PKTIO_GET_NWAL_INSTANCE(netcp_sb_tx_chan),
                                                       &nwalLocCxt);
-           if(nwalRetVal == nwal_OK)
-           {
+            if(nwalRetVal == nwal_OK)
+            {
                 p_sa_info->tx_dmPSCmdInfo.rxSbSaQ = nwalLocCxt.rxSbSaQ;
-           }
-           nwal_mCmdDMUpdate(tip,
+            }
+            nwal_mCmdDMUpdate(tip,
                               &p_sa_info->tx_dmPSCmdInfo,
                               meta_tx.appCtxId,
                               meta_tx.encOffset,
@@ -1078,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
        }
@@ -1171,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();
 }
 
 /****************************************************************************************/
@@ -1199,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;
 
@@ -1214,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)
         {
@@ -1226,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;
@@ -1234,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
@@ -1261,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};
@@ -1291,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;
            }
         }
@@ -1313,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.."); 
@@ -1375,89 +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
 
 
-            //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;
+                
+                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;
+                }
 
-           memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
+                //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;
 
-           meta_tx.encSize = len - p_sa_info->tx_payload_info.encOffset -netTest_ICV_LEN;
-           meta_tx.authSize = len - meta_tx.authOffset - netTest_ICV_LEN;
+                memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
 
-#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);
-#endif
+                //meta_tx.ploadLen = 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 (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.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;
+
+#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_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
+            /* 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),
+            nwalRetVal =  
+            nwal_getLocCxtInfo(PKTIO_GET_NWAL_INSTANCE(netcp_sb_tx_chan),
                                                       &nwalLocCxt);
-           if(nwalRetVal == nwal_OK)
-           {
+            if(nwalRetVal == nwal_OK)
+            {
                 p_sa_info->rx_dmPSCmdInfo.rxSbSaQ = nwalLocCxt.rxSbSaQ;
-           }
+            }
             nwal_mCmdDMUpdate(tip,
                               &p_sa_info->rx_dmPSCmdInfo,
                               meta_tx.appCtxId,
@@ -1469,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->rx_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
@@ -1490,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 */
@@ -1520,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
@@ -1550,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
@@ -1559,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
@@ -1633,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, 
@@ -1726,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
@@ -1767,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();
 }
 
 //******************************************************
@@ -1847,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 */
@@ -1891,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,
@@ -1924,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);
@@ -1969,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 */
@@ -1982,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) */
@@ -2014,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))
@@ -2028,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;
 
 
 
@@ -2064,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;
@@ -2086,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;
@@ -2109,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))
     {
@@ -2123,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;
@@ -2155,8 +2414,159 @@ void  build_sa_db(int i)
         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;
 
-       trie_insert(p_trie_sa,(char *)&(tx_sa[i].spi),4, (void *) &sa_info[i]); //asociate with tx sa SPI
+        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 ;
+
+        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");
@@ -2182,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)
@@ -2256,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)
@@ -2764,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
@@ -2932,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),
@@ -3000,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);
@@ -3037,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
@@ -3053,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
@@ -3078,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);       
         }
     }
@@ -3117,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);
@@ -3133,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;
@@ -3160,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[],
@@ -3183,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++)
 {
@@ -3270,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);
index 4500846944c0fb5869de33767cdfc4f695801ea7..74702ed116d5a4e43aff8fb23100ae18196213e6 100755 (executable)
  */
 /* ============================================================= */
 
+
+#define MAX_SEC_INDEX                   6
+
+
 //IPSEC MODE(only choose one rx and one tx)
+#define IPSEC_MODE_RX_INFLOW            1
+#define IPSEC_MODE_TX_INFLOW            2
+#define IPSEC_MODE_RX_SIDEBAND          3
+#define IPSEC_MODE_TX_SIDEBAND          4
 
-#define IPSEC_MODE_RX_INFLOW 1
-#define IPSEC_MODE_TX_INFLOW 2
-#define IPSEC_MODE_RX_SIDEBAND 3
-#define IPSEC_MODE_TX_SIDEBAND 4
 
-#define MAX_SEC_INDEX 4
 #define netTest_MAC_HEADER_LEN          14
 #define netTest_IP_HEADER_LEN           20
 #define netTest_UDP_HEADER_LEN          8
 #define netTest_ESP_HEADER_LEN          8
 #define netTest_AES_CBC_IV_LEN          16
-#define netTest_AES_CTR_IV_CONTEXT_LEN          16
-#define netTest_AES_CTR_IV_PACKET_LEN          8
-#define netTest_3DES_CBC_IV_LEN          8
-#define netTest_NULL_IV_LEN 0
-#define netTest_ICV_LEN          12
-
+#define netTest_AES_CTR_IV_LEN   8
+#define netTest_3DES_CBC_IV_LEN         8
+#define netTest_AES_GCM_IV_LEN          8
+#define netTest_AES_CCM_IV_LEN          8
+#define netTest_AES_GMAC_IV_LEN          8
+#define netTest_NULL_IV_LEN             0
+#define netTest_ICV_LEN                 12
+#define netTest_AES_GCM_CCM_ICV_LEN     16
+#define netTest_AES_GMAC_ICV_LEN     16
 
 
 /* The input strings for the input config file is given below */
-#define INIT_CONFIG_MAC0      "mac0"
-#define INIT_CONFIG_MAC1      "mac1"
-#define INIT_CONFIG_IP0         "ip0"
-#define INIT_CONFIG_IP1         "ip1"
-#define INIT_CONFIG_IP2         "ip2"
-#define INIT_CONFIG_LOCAL_IPSEC_IP         "local_ipsec_ip"
-#define INIT_CONFIG_REMOTE_IPSEC_IP         "remote_ipsec_ip"
+#define INIT_CONFIG_MAC0            "mac0"
+#define INIT_CONFIG_MAC1            "mac1"
+#define INIT_CONFIG_IP0             "ip0"
+#define INIT_CONFIG_IP1             "ip1"
+#define INIT_CONFIG_IP2             "ip2"
+#define INIT_CONFIG_LOCAL_IPSEC_IP  "local_ipsec_ip"
+#define INIT_CONFIG_REMOTE_IPSEC_IP "remote_ipsec_ip"
 #define INIT_CONFIG_IPSEC_MODE_RX   "ipsec_mode_rx"
 #define INIT_CONFIG_IPSEC_MODE_TX   "ipsec_mode_tx"
 #define INIT_CONFIG_IPSEC_IF_NO     "ipsec_if"
@@ -94,6 +100,7 @@ typedef struct {
     uint8_t auth_tag_size;
     nwalTxPktInfo_t tx_pkt_info;
     nwal_saEALG         cipherMode;
+    nwal_saAALG         authMode;
     /*stuff for routing use case */
     unsigned int src;  //BE
     unsigned int dst;  //BE