]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blobdiff - ti/runtime/netapi/src/netapi_init.c
Fix for SDOCM00114893
[keystone-rtos/netapi.git] / ti / runtime / netapi / src / netapi_init.c
index 8840ac348c1e8f48f24efe3cdd903acf4b7864dc..68168e0c0dfce577d449a18c4290c758c7cd97df 100755 (executable)
 #include <ti/csl/csl_xmcAux.h>
 #include <ti/drv/qmss/qmss_qm.h>
 
+
+/* pointer to NWAL local context memory block used by NWAL for local 
+   context intance*/
+void* pNwalLocCtxMem = NULL;
+extern void *pRmClientHandle;
+
+nwal_Handle gPNwalInstHandle = NULL;
+
+
 extern NETAPI_SHM_T* pnetapiShm;
 /* Global variablesto hold virtual address of various subsystems */
 extern hplib_virtualAddrInfo_T netapi_VM_VirtAddr[];
@@ -83,7 +92,8 @@ extern unsigned char *netapi_VM_QMemGlobalDescRam;
 extern unsigned char *netapi_VM_SaContextVaddr;
 
 extern Pktlib_HeapIfTable  netapi_pktlib_ifTable;
-extern NETAPI_GLOBAL_T netapi_global;
+extern NETAPI_PROC_GLOBAL_T netapi_proc_global;
+extern NETAPI_HANDLE_T * netapi_proc_master;
 
 
 /* TODO verify: */
@@ -99,6 +109,9 @@ uint8_t *QMemGlobDescRam = 0;
 uint8_t *cppiMemPaSaLinkBuf = 0;
 uint8_t *cppiMemSaPaLinkBuf = 0;
 
+
+
+#if 0
 /*****************************************************************************
  * Local Resource allocated at each Core
  *****************************************************************************/
@@ -109,6 +122,13 @@ uint8_t *cppiMemTxPktLinkBuf = NULL;
 uint8_t *cppiMemRxCtlLinkBuf = NULL;
 uint8_t *cppiMemTxCtlLinkBuf = NULL;
 
+#endif
+
+
+
+NETCP_CFG_GLOB_DEVICE_PARAMS_T   *p_netapi_device_cfg_local;
+Qmss_MemRegInfo   memInfo;
+
 
 /********************************************************************
  * FUNCTION PURPOSE:  Internal NETAPI function to setup the QM memory region
@@ -120,43 +140,38 @@ int netapip_qmSetupMemRegion(
                       uint32_t          numDesc,
                       uint32_t          descSize,
                       uint32_t*         pDescMemBase,
-                      Qmss_MemRegion    memRegion)
+                      int               memRegion,
+                      int               start_index)
 {
-    Qmss_MemRegInfo   memInfo;
-    Int32             result;
-    Int               n;
-    static int  netapi_qm_region_index=0;
+    //Qmss_MemRegInfo   memInfo;
+    int result;
 
     memset(&memInfo,0,sizeof(Qmss_MemRegInfo));
     memInfo.descBase       = pDescMemBase;
     memInfo.descSize       = descSize;
     memInfo.descNum        = numDesc;
     memInfo.manageDescFlag = Qmss_ManageDesc_MANAGE_DESCRIPTOR;
-    memInfo.memRegion      = memRegion;
 
-    if(memRegion == TUNE_NETAPI_QM_GLOBAL_REGION)
+    if (pRmClientHandle)
     {
-        memInfo.startIndex = TUNE_NETAPI_QM_START_INDEX;  //was 0
-        netapi_qm_region_index += numDesc;
-    }else if(memRegion ==NETAPI_LOCAL_REGION)
-    {
-        /* 2nd region for descriptors (perhaps private?) */
-        memInfo.startIndex     = netapi_qm_region_index;
+        memInfo.memRegion = -1;
+        memInfo.startIndex = QMSS_START_INDEX_NOT_SPECIFIED;
     }
     else
     {
-        return -1 ;
+        memInfo.memRegion = memRegion;
+        memInfo.startIndex = start_index;
     }
 
     memset (pDescMemBase, 0, (descSize * numDesc));
 
     result = Qmss_insertMemoryRegion (&memInfo);
+
     if (result < QMSS_SOK)  
     {
-        netapi_Log ("netapip_qmSetupMemRegion: Qmss_insertMemoryRegion returned error code %d\n", result);
         return (-1);
     }
-
+    netapi_proc_master->memRegion = memInfo.memRegion;
     return 1;
 }
 
@@ -166,13 +181,17 @@ int netapip_qmSetupMemRegion(
  * DESCRIPTION:  Internal NETAPI function to start QM
  *               once per thread/core
  ********************************************************************/
-int netapip_startQm(void)
+int netapip_startQm(void* rmClientServiceHandle)
 {
      int32_t          result;
-     result = Qmss_start();
+     Qmss_StartCfg    startCfg;
+
+     startCfg.rmServiceHandle = rmClientServiceHandle;
+     startCfg.pQmssGblCfgParams = NULL;
+     //result = Qmss_start();
+     result = Qmss_startCfg(&startCfg);
      if (result != QMSS_SOK)
      {
-         netapi_Log ("netapip_startQm: Qmss_start failed with error code %d\n", result);
          return (-1);
      }
      return 1;
@@ -181,28 +200,31 @@ int netapip_startQm(void)
 
 /*** NWAL Memory Buffer Configuration ***/
 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE     3400
-uint8_t nwalInstMem[NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE]ALIGN(CACHE_LINESZ);
+//uint8_t nwalInstMem[NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE]ALIGN(CACHE_LINESZ);
+
 
-#define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC                    128
+#define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC                    256
 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN      256
 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_IP                     128
 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT                   128
 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR               128
-#define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT            384
 #define NWAL_CHAN_HANDLE_SIZE    ((NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \
                                   (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) + \
                                   (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \
                                   (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS)+ \
-                                  (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT * TUNE_NETAPI_NUM_CORES) + \
                                   (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR * TUNE_NETAPI_MAX_NUM_L2_L3_HDRS))
 
-uint8_t nwalHandleMem[NWAL_CHAN_HANDLE_SIZE]ALIGN(CACHE_LINESZ);
+typedef struct NETAPI_NWAL_SHM_Tag
+{
+    uint8_t nwalInstMem[NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE]ALIGN(CACHE_LINESZ);
+    uint8_t nwalHandleMem[NWAL_CHAN_HANDLE_SIZE]ALIGN(CACHE_LINESZ);
+} NETAPI_NWAL_SHM_T;
 
 
 typedef struct NETAPI_PA_SHM_Tag
 {
 /* todo: Check if below size information can be made available from pa interface file */
-#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0      128
+#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0      256
 /* PA instance */
 /* Memory used for the PA Instance. Needs to be assigned global uncached memory for chip */
 uint8_t paBuf0[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0]ALIGN(CACHE_LINESZ);
@@ -211,7 +233,7 @@ uint8_t paBuf0[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0]ALIGN(CACHE_LINESZ);
 #define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1    128 * TUNE_NETAPI_MAX_NUM_MAC
 uint8_t paBuf1[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1]ALIGN(CACHE_LINESZ);
 
-#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2   13824
+#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2   14592
 
 
 uint8_t paBuf2[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2]ALIGN(CACHE_LINESZ);
@@ -229,6 +251,13 @@ uint8_t salldHandle[NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE]ALIGN(CACHE_LINESZ)
 uint8_t salldChanHandle[NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2]ALIGN(CACHE_LINESZ);
 } NETAPI_SA_SHM_T;
 
+
+
+
+
+
+
+
 /********************************************************************
 * FUNCTION PURPOSE:  NETAPI internal function to gracefully cleanup when startup
 *                                  issue occurs.
@@ -247,46 +276,53 @@ int netapip_initNwal(
     int region2use,
     Pktlib_HeapIfTable * p_table,
     NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_context,
-    NETAPI_CFG_T*p_cfg )
+    NETAPI_CFG_T*p_cfg)
 {
     nwalSizeInfo_t  nwalSizeInfo;
     nwal_RetValue   nwalRetVal;
     nwalGlobCfg_t   nwalGlobCfg;
+    nwalBaseAddrCfg_t nwalBaseAddrCfg;
     uint8_t         count;
     int             sizes[nwal_N_BUFS];
     int             aligns[nwal_N_BUFS];
     void*           bases[nwal_N_BUFS];   
     Pktlib_HeapCfg      heapCfg;
-    int32_t             errCode;
+    int32_t             errCode = 0;
     void* pBase = NULL;
     NETAPI_PA_SHM_T* paEntry = NULL;
     NETAPI_SA_SHM_T* saEntry = NULL;
-
+    NETAPI_NWAL_SHM_T* nwalEntry = NULL;
+    uint32_t localCtxSize = 0;
     memset(p_nwal_context,0,sizeof( NETAPI_NWAL_GLOBAL_CONTEXT_T) );
     memset(&nwalGlobCfg,0,sizeof(nwalGlobCfg_t ) );
-
+    memset (&nwalBaseAddrCfg, 0, sizeof(nwalBaseAddrCfg_t));
     pBase = hplib_shmOpen();
     if (pBase)
     {
         if(hplib_shmAddEntry(pBase, sizeof(NETAPI_PA_SHM_T), PA_ENTRY) == hplib_OK)
         {
             paEntry = (NETAPI_PA_SHM_T*)hplib_shmGetEntry(pBase,PA_ENTRY);
-            nwalGlobCfg.instPoolBaseAddr = (void *)paEntry;
-            printf("netapip_initNwal: instPoolBaseAddr: 0x%x\n", nwalGlobCfg.instPoolBaseAddr);
+            nwalBaseAddrCfg.pInstPoolPaBaseAddr= (void *)paEntry;
         }
         else
         {
-            netapi_Log("netapip_initNwal: Unable to Add shared memory segment for PASS\n");
             return -1;
         }
         if(hplib_shmAddEntry(pBase, sizeof(NETAPI_SA_SHM_T), SA_ENTRY) == hplib_OK)
         {
-            saEntry = (NETAPI_PA_SHM_T*)hplib_shmGetEntry(pBase,SA_ENTRY);
-            nwalGlobCfg.instPoolSaBaseAddr = (void*) saEntry;
+            saEntry = (NETAPI_SA_SHM_T*)hplib_shmGetEntry(pBase,SA_ENTRY);
+            nwalBaseAddrCfg.pInstPoolSaBaseAddr= (void*) saEntry;
+        }
+        else
+        {
+            return -1;
+        }
+        if(hplib_shmAddEntry(pBase, sizeof(NETAPI_NWAL_SHM_T), NWAL_ENTRY) == hplib_OK)
+        {
+            nwalEntry = (NETAPI_NWAL_SHM_T*)hplib_shmGetEntry(pBase,NWAL_ENTRY);
         }
         else
         {
-            netapi_Log("netapip_initNwal: Unable to Add shared memory segment for SASS\n");
             return -1;
         }
         
@@ -316,8 +352,6 @@ int netapip_initNwal(
                       Pktlib_createHeap(&heapCfg, &errCode);
     if(nwalGlobCfg.pa2SaBufPool.bufPool[0].heapHandle == NULL)
     {
-        netapi_Log ("netapip_initNwal: Pktlib_createHeap:Heap Creation Failed for PA to SA Buffer Pool, Error Code: %d\n",
-                    errCode); 
         netapipErrTeardown();
         return -1;
     }
@@ -331,12 +365,10 @@ int netapip_initNwal(
     heapCfg.name                = "nwal SA2PA";
     heapCfg.numPkts             = TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;
 
-    nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle = p_nwal_context->sa2pa_heap=
-        Pktlib_createHeap(&heapCfg, &errCode);
+    nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle = 
+        p_nwal_context->sa2pa_heap = Pktlib_createHeap(&heapCfg, &errCode);
     if(nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle == NULL)
     {
-        netapi_Log ("netapip_initNwal: Pktlib_createHeap:Heap Creation Failed for SA to PA Buffer Pool, Error Code: %d\n",
-                     errCode); 
         netapipErrTeardown();
         return -1;
     }
@@ -347,12 +379,20 @@ int netapip_initNwal(
     nwalGlobCfg.paFwActive = nwal_TRUE;
     nwalGlobCfg.saFwActive = nwal_FALSE;
 
-    /* Pick Default Physical Address */
-    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) ;
+
+    /* Update nwal cfg with virtual PA and SA addresses */
+
+
+    nwalBaseAddrCfg.paVirtBaseAddr = (uint32_t) netapi_VM_VirtAddr->passCfgVaddr;
+
+
+    nwalBaseAddrCfg.pSaVirtBaseAddr = (uint32_t) netapi_VM_VirtAddr->passCfgVaddr +
+                                  CSL_NETCP_CFG_SA_CFG_REGS -
+                                  CSL_NETCP_CFG_REGS;
+        ;
     nwalGlobCfg.rxDefPktQ = QMSS_PARAM_NOT_SPECIFIED;
 
+
     /* Get the Buffer Requirement from NWAL */
     memset(&nwalSizeInfo,0,sizeof(nwalSizeInfo));
     nwalSizeInfo.nMaxMacAddress = TUNE_NETAPI_MAX_NUM_MAC;
@@ -367,25 +407,34 @@ int netapip_initNwal(
                                    aligns);
     if(nwalRetVal != nwal_OK)
     {
-        netapi_Log ("netapip_initNwal: nwal_getBufferReq Failed %d\n", nwalRetVal);
         return nwal_FALSE;
     }
 
 /* Check for memory size requirement and update the base */
     count = 0;
-    bases[nwal_BUF_INDEX_INST] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalInstMem);
+    //bases[nwal_BUF_INDEX_INST] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalInstMem);
+    bases[nwal_BUF_INDEX_INST] = 
+                (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalEntry->nwalInstMem);
+
     if(NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE < sizes[nwal_BUF_INDEX_INST])
     {
         /* Resize Memory */
-        while(1);
+        return nwal_FALSE;
+        //while(1);
     }
     count++;
 
-    bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalHandleMem);
+    //bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalHandleMem);
+    bases[nwal_BUF_INDEX_INT_HANDLES] = 
+                    (uint32_t *) Osal_nwalLocToGlobAddr((uint32_t)nwalEntry->nwalHandleMem);
+
+    
     if(NWAL_CHAN_HANDLE_SIZE  < sizes[nwal_BUF_INDEX_INT_HANDLES])
     {
         /* Resize Memory */
-        while(1);
+        return nwal_FALSE;
+        //while(1);
+
     }
     count++;
      bases[nwal_BUF_INDEX_PA_LLD_BUF0] =
@@ -393,7 +442,9 @@ int netapip_initNwal(
     if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0) < sizes[nwal_BUF_INDEX_PA_LLD_BUF0])
     {
         /* Resize Memory */
-        while(1);
+        return nwal_FALSE;
+        //while(1);
+
     }
     count++;
 
@@ -402,7 +453,9 @@ int netapip_initNwal(
     if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1) < sizes[nwal_BUF_INDEX_PA_LLD_BUF1])
     {
         /* Resize Memory */
-        while(1);
+        return nwal_FALSE;
+        //while(1);
+
     }
     count++;
 
@@ -411,7 +464,9 @@ int netapip_initNwal(
     if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2) < sizes[nwal_BUF_INDEX_PA_LLD_BUF2])
     {
         /* Resize Memory */
-        while(1);
+        return nwal_FALSE;
+        //while(1);
+
     }
     count++;
 #ifdef NETAPI_ENABLE_SECURITY
@@ -420,13 +475,15 @@ int netapip_initNwal(
     if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE) < sizes[nwal_BUF_INDEX_SA_LLD_HANDLE])
     {
         /* Resize Memory */
-        while(1);
+        return nwal_FALSE;
+        //while(1);
+
     }
     count++;
 
     bases[nwal_BUF_INDEX_SA_CONTEXT] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)netapi_VM_SaContextVaddr);
     /* also save this here for easy access to sa_start */
-    nwalGlobCfg.instPoolSaBaseAddr = bases[nwal_BUF_INDEX_SA_CONTEXT];
+    nwalBaseAddrCfg.pScPoolBaseAddr= bases[nwal_BUF_INDEX_SA_CONTEXT];
     count++;
 
     bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] =
@@ -435,7 +492,9 @@ int netapip_initNwal(
         sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE])
     {
         /* Resize Memory */
-        while(1);
+        return nwal_FALSE;
+        //while(1);
+
     }
     count++;
 #else
@@ -444,24 +503,26 @@ int netapip_initNwal(
     bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] = 0;
     count = count+3;
 #endif
-    if(count != nwal_N_BUFS)
-    {
-        while(1);
-    }
 
     /* Initialize NWAL module */
+    nwal_getLocContextBufferReq(nwalSizeInfo.nProc, &localCtxSize);
+
+    pNwalLocCtxMem = malloc(localCtxSize);
+    nwal_createProc(bases[nwal_BUF_INDEX_INST],
+                          pNwalLocCtxMem,
+                          &nwalBaseAddrCfg);
+
+    nwalGlobCfg.pBaseAddrCfg = &nwalBaseAddrCfg;
     nwalRetVal = nwal_create(&nwalGlobCfg,
                              &nwalSizeInfo,
                              sizes,
                              bases,
-                             &p_nwal_context->nwalInstHandle);
+                             &gPNwalInstHandle);
     if(nwalRetVal != nwal_OK)
     {
-        netapi_Log ("netapip_initNwal: nwal_create Failed %d\n",nwalRetVal);
-        while(1);
+        return nwal_FALSE;
     }
 
-    netapi_Log("netapip_initNwal- Global and Local Network initialization Successful \n");
     return 1;
 }
 
@@ -475,14 +536,30 @@ int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
                       Pktlib_HeapHandle cmd_tx_heap,
                       NETAPI_NWAL_LOCAL_CONTEXT_T *p,
                       NETAPI_CFG_T *p_cfg,
-                      NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_glob_context  )
+                      NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_glob_context,
+                      int master)
 {
     nwalLocCfg_t    nwalLocCfg;
+    nwalBaseAddrCfg_t nwalBaseAddrCfg;
     int count=0;
     static int first_time = 0;
     nwal_RetValue       nwalRetVal;
+    void* pBase = NULL;
+    NETAPI_NWAL_SHM_T* nwalEntry = NULL;
+    void* pNwalLocCtxMem = NULL;
+
+    NETAPI_SA_SHM_T* saEntry = NULL;
+    NETAPI_PA_SHM_T* paEntry = NULL;
+
+    uint32_t            baseAddr;
+    void*               instPoolSaBaseAddr;
+    void*               pScPoolBaseAddr;
+    void*               pInstPoolPaBaseAddr;
+    void*               paVirtBaseAddr;
+    uint32_t          localCtxSize;
 
     memset(&nwalLocCfg,0,sizeof(nwalLocCfg));
+    memset(&nwalBaseAddrCfg, 0, sizeof(nwalBaseAddrCfg_t));
 
     /* Update the Start of Packet Offset for the default flows created 
      * by NWAL
@@ -509,7 +586,7 @@ int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
     nwalLocCfg.txCtlPool.bufPool[0].bufSize = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
     nwalLocCfg.txCtlPool.bufPool[0].heapHandle =  cmd_tx_heap;
 
-/* Initialize Buffer Pool for Packets from NetCP to Host */
+/* Initialize Buffer Pool for L4 Packets from NetCP to Host */
     nwalLocCfg.rxPktPool.numBufPools = 1;
     nwalLocCfg.rxPktPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
     nwalLocCfg.rxPktPool.bufPool[0].bufSize =  p_cfg->def_heap_buf_size;
@@ -521,10 +598,50 @@ int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
     nwalLocCfg.txPktPool.bufPool[0].bufSize =  p_cfg->def_heap_buf_size;
     nwalLocCfg.txPktPool.bufPool[0].heapHandle = pkt_heap;
 
+
+
+
     memcpy(&p->nwalLocCfg,&nwalLocCfg,sizeof(nwalLocCfg_t));
     while(1)
     {
-        nwalRetVal = nwal_start(p_nwal_glob_context->nwalInstHandle,&nwalLocCfg);
+        if(master == NETAPI_PROC_MASTER)
+        {
+            pBase = hplib_shmOpen();
+            nwalEntry = (NETAPI_NWAL_SHM_T*)hplib_shmGetEntry(pBase,NWAL_ENTRY);
+
+                baseAddr = (void*) netapi_VM_VirtAddr->passCfgVaddr +
+                                              CSL_NETCP_CFG_SA_CFG_REGS -
+                                              CSL_NETCP_CFG_REGS;
+                 saEntry = (NETAPI_SA_SHM_T*)hplib_shmGetEntry(pBase,SA_ENTRY);
+                 instPoolSaBaseAddr = (void*) saEntry;
+            
+                 pScPoolBaseAddr = Osal_nwalLocToGlobAddr((uint32_t)netapi_VM_SaContextVaddr);
+
+
+                 paVirtBaseAddr = (void*) netapi_VM_VirtAddr->passCfgVaddr;
+                 paEntry = (NETAPI_PA_SHM_T*)hplib_shmGetEntry(pBase,PA_ENTRY);
+                 pInstPoolPaBaseAddr = (void *)paEntry;
+
+            nwal_getLocContextBufferReq(TUNE_NETAPI_NUM_CORES, &localCtxSize);
+            pNwalLocCtxMem = malloc(localCtxSize);
+            if (pNwalLocCtxMem == NULL)
+            {
+                return -1;
+            }
+            nwalBaseAddrCfg.pSaVirtBaseAddr = baseAddr;
+            nwalBaseAddrCfg.pInstPoolSaBaseAddr = instPoolSaBaseAddr;
+            nwalBaseAddrCfg.pScPoolBaseAddr = pScPoolBaseAddr;
+            nwalBaseAddrCfg.paVirtBaseAddr = paVirtBaseAddr;
+            nwalBaseAddrCfg.pInstPoolPaBaseAddr = pInstPoolPaBaseAddr;
+            /* this is 1 time per process */
+            nwal_createProc(nwalEntry,
+                            pNwalLocCtxMem,
+                            &nwalBaseAddrCfg);
+        }
+        /* this is for every thread including 1st thread of the process */
+        netapi_proc_master->spinLock.lock(&pnetapiShm->netapi_util_lock);
+        nwalRetVal = nwal_start(gPNwalInstHandle,&nwalLocCfg);
+        netapi_proc_master->spinLock.unlock(&pnetapiShm->netapi_util_lock);
         if(nwalRetVal == nwal_ERR_INVALID_STATE)
         {
             continue;
@@ -534,7 +651,6 @@ int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
 
     if(nwalRetVal != nwal_OK)
     {
-        netapi_Log (">nwal_start:Failed ->err %d !!!\n", nwalRetVal);
         return -1;
     }
     p->state = NETAPI_NW_CXT_LOC_ACTIVE;
@@ -551,6 +667,8 @@ int netapip_initTimer(void)
 {
 #ifdef CORTEX_A8
         return t64_start();
+#else
+    return 0;
 #endif
 }
 
@@ -565,7 +683,10 @@ int netapip_initTimer(void)
 
 static uint8_t* netapip_sharedMemoryMalloc(uint32_t size)
 {
-return  (uint8_t *)hplib_vmMemAlloc(size +netapi_global.cfg.def_heap_extra_size , 128, 0); 
+    return  (uint8_t *)hplib_vmMemAlloc(size + 
+                                    pnetapiShm->netapi_global.cfg.def_heap_extra_size ,
+                                    128,
+                                    0); 
 }
 
 /********************************************************************
@@ -576,7 +697,6 @@ return  (uint8_t *)hplib_vmMemAlloc(size +netapi_global.cfg.def_heap_extra_size
 static void netapip_sharedMemoryFree(uint8_t* ptr, uint32_t size)
 {
     /* Do Nothing. */
-    netapi_Log("netapi Unexpected.  need to provide a free () for some reason!! \n");
     return;
 }
 
@@ -610,13 +730,15 @@ void netapip_cleanupAtStart(void)
  ********************************************************************
  * DESCRIPTION:  NETAPI internal function system initialization
  ********************************************************************/
-int netapip_systemInit(NETAPI_HANDLE_T * handle, Bool global_master_process)
+int netapip_systemInit(NETAPI_HANDLE_T * handle,
+                       Bool global_master_process)
 {
+
     int32_t             result;
     Pktlib_HeapHandle   sharedHeapHandle;
-    Pktlib_HeapHandle   controlRxHeapHandle,controlTxHeapHandle;    
+    Pktlib_HeapHandle   controlRxHeapHandle,controlTxHeapHandle;
     Pktlib_HeapCfg      heapCfg;
-    int32_t             errCode;
+    int32_t             errCode = 0;
     int count=0;
 
 #ifdef NETAPI_USE_DDR
@@ -625,198 +747,313 @@ int netapip_systemInit(NETAPI_HANDLE_T * handle, Bool global_master_process)
     netapi_VM_MempoolAttr[0].phys_addr = 0;
     netapi_VM_MempoolAttr[0].size = 0;
 
+#ifdef NETAPI_USE_DDR_AND_MSMC
        /* Init attributes for un-cached MSMC */
     netapi_VM_MempoolAttr[1].attr = HPLIB_ATTR_UN_CACHED;
     netapi_VM_MempoolAttr[1].phys_addr = CSL_MSMC_SRAM_REGS;
     netapi_VM_MempoolAttr[1].size = TUNE_NETAPI_PERM_MEM_SZ;
+#endif
 #else
-    netapi_VM_MempoolAttr[1].attr = HPLIB_ATTR_KM_CACHED0;
-    netapi_VM_MempoolAttr[1].phys_addr = 0;
-    netapi_VM_MempoolAttr[1].size = 0;
-
        /* Init attributes for un-cached MSMC */
     netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_UN_CACHED;
     netapi_VM_MempoolAttr[0].phys_addr = CSL_MSMC_SRAM_REGS;
     netapi_VM_MempoolAttr[0].size = TUNE_NETAPI_PERM_MEM_SZ;
+#ifdef NETAPI_USE_DDR_AND_MSMC
+    netapi_VM_MempoolAttr[1].attr = HPLIB_ATTR_KM_CACHED0;
+    netapi_VM_MempoolAttr[1].phys_addr = 0;
+    netapi_VM_MempoolAttr[1].size = 0;
+#endif
 #endif
     /* initialize all the memory we are going to use
        - chunk for buffers, descriptors
        - memory mapped peripherals we use, such as QMSS, PA, etc */
-    result = hplib_vmInit(&netapi_VM_VirtAddr[0], 2, &netapi_VM_MempoolAttr[0]);
+#ifdef NETAPI_USE_DDR_AND_MSMC
+    result = hplib_vmInit(&netapi_VM_VirtAddr[0],
+                          2,
+                          &netapi_VM_MempoolAttr[0]);
+#else
+    result = hplib_vmInit(&netapi_VM_VirtAddr[0],
+                           1,
+                           &netapi_VM_MempoolAttr[0]);
+#endif
 
-    if (global_master_process == TRUE)
+    if (result != hplib_OK)
     {
-        hplibp_initMallocArea(0);
-        hplibp_initMallocArea(1);
+        return -1;
     }
-    else
-    {
-        if (hplibp_checkMallocArea(0) != hplib_OK)
-            return -1;
-        if (hplibp_checkMallocArea(1) != hplib_OK)
-            return -1;
-            }
-
-    if (result == hplib_OK) netapi_Log("netapip_systemInit: - memory set  up OK\n");
-    else {netapi_Log("netapip_systemInit: - memory set up failed\n"); return -1;}
-
 
+    if (global_master_process == NETAPI_TRUE)
+    {
+        hplib_initMallocArea(0);
+#ifdef  NETAPI_USE_DDR_AND_MSMC
+        hplib_initMallocArea(1);
+#endif
 #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_vmMemAlloc((TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2 *
+        /* allocate 2x number of tunnels since we need one for inflow and one for data mode */
+        netapi_VM_SaContextVaddr = hplib_vmMemAlloc((TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2 *
                                         SEC_CONTEXT_SZ), 128, 0);
-    if (!netapi_VM_SaContextVaddr)
-    {
-        netapi_Log("netapip_systemInit: Failed to map SA context memory region\n");
-        return (-1);
-    }
-    netapi_Log("netapip_systemInit: SA Memory mapped/allocated at address %p.\n", netapi_VM_SaContextVaddr);
-
+        if (!netapi_VM_SaContextVaddr)
+        {
+            return (-1);
+        }
 #else
-   netapi_VM_SaContextVaddr= (char *) NULL;
+            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 netapip_systemInit */
-    /* (3) Allocate 2 QM regions from continguous chunk above */
-    netapi_VM_QMemGlobalDescRam = 
-                                  (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_GLOBAL_DESC *
-                                                            TUNE_NETAPI_DESC_SIZE),
-                                                             128, 0);
-
-    netapi_VM_QMemLocalDescRam =
-                                  (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
-                                                            TUNE_NETAPI_DESC_SIZE),
-                                                            128, 0);
-    netapi_Log("netapip_systemInit: desc region=%x global desc region=%x\n", netapi_VM_QMemLocalDescRam, netapi_VM_QMemGlobalDescRam);
-
-    //get timer running
-#ifdef CORTEX_A8
-    netapip_initTimer();
-    netapi_Log("netapip_systemInit: returned from netapip_initTimer\n");
-#endif
+        /* (3) Allocate 2 QM regions from continguous chunk above */
+        netapi_VM_QMemGlobalDescRam = 
+                (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_GLOBAL_DESC *
+                TUNE_NETAPI_DESC_SIZE),
+                128,
+                0);
+
+        netapi_VM_QMemLocalDescRam =
+                (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
+                TUNE_NETAPI_DESC_SIZE),
+                128,
+                0);
+        /* Initialize Queue Manager Sub System */
+        result = netapip_initQm (pnetapiShm->netapi_global.cfg.def_max_descriptors,
+                                 pRmClientHandle);
+        
+        if (result != 1)
+        {
+            return -1;
+        }
+        /* Start the QMSS. */
+        if (netapip_startQm(pRmClientHandle) != 1)
+        {
+            return -1;
+        }
 
-    /* Initialize Queue Manager Sub System */
-    result = netapip_initQm (netapi_global.cfg.def_max_descriptors); 
+        //clean our old junk in 1st bunch of queues that will be allocated to us
+        netapip_cleanupAtStart();
+         /* Initialize the global descriptor memory region. */
+        result= netapip_qmSetupMemRegion( 
+                           pnetapiShm->netapi_global.cfg.def_tot_descriptors_for_us,
+                           TUNE_NETAPI_DESC_SIZE,
+                           (unsigned int *) netapi_VM_QMemGlobalDescRam,
+                           pnetapiShm->netapi_global.cfg.memoryRegion,
+                           pnetapiShm->netapi_global.cfg.start_index);
+        if(result <0)
+        {
+            return -1;
+        }
+        /* Initialize CPPI CPDMA */
+        result = netapip_initCppi(pRmClientHandle);
+        if (result != 1)
+        {
+            return -1;
+        }
+        /* CPPI and Queue Manager are initialized. */
+
+        /* create main pkt heap */
+        /* Initialize the Shared Heaps. */
+        Pktlib_sharedHeapInit();
+        /* Populate the heap interface table. */
+        netapi_pktlib_ifTable.data_malloc             = netapip_sharedMemoryMalloc;
+        netapi_pktlib_ifTable.data_free               = netapip_sharedMemoryFree;
+        /* Initialize the heap configuration. */
+        memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
+        /* Populate the heap configuration */
+        heapCfg.name                = "netapi";
+        heapCfg.memRegion = memInfo.memRegion;
+        heapCfg.sharedHeap          = 1;
+        heapCfg.useStarvationQueue  = 0;
+        heapCfg.dataBufferSize      = pnetapiShm->netapi_global.cfg.def_heap_buf_size;
+        heapCfg.numPkts             = pnetapiShm->netapi_global.cfg.def_heap_n_descriptors;
+        heapCfg.numZeroBufferPackets= pnetapiShm->netapi_global.cfg.def_heap_n_zdescriptors;
+        heapCfg.heapInterfaceTable.data_malloc  = netapi_pktlib_ifTable.data_malloc;
+        heapCfg.heapInterfaceTable.data_free    = netapi_pktlib_ifTable.data_free;
+        heapCfg.dataBufferPktThreshold   = 0;
+        heapCfg.zeroBufferPktThreshold   = 0;
+
+        /* Create Shared Heap with specified configuration. */
+        sharedHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
+        if (!sharedHeapHandle) { return -1;}
+        handle->netcp_heap= sharedHeapHandle;
+        /* Update for Control */
+        heapCfg.name                = "netapi_control_rx";
+        heapCfg.sharedHeap          = 1;
+        heapCfg.dataBufferSize      = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
+        heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF;
+        heapCfg.numZeroBufferPackets= 0;
     
-    if (result != 1)
-    {
-         netapi_Log("netapip_systemInit: returned from netapip_initQm with failure\n");
-        return -1;
+        controlRxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
+        //todo -> cleanup on failure
+        if (!controlRxHeapHandle) { return -1;}
+        handle->netcp_control_rx_heap= controlRxHeapHandle;
+    
+    
+        heapCfg.name                = "netapi_control_tx";
+        heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF;
+    
+        controlTxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
+    //todo -> cleanup on failure
+    if (!controlTxHeapHandle) { return -1;}
+    handle->netcp_control_tx_heap= controlTxHeapHandle;
+             /* now NWAL */
+        result = netapip_initNwal(memInfo.memRegion,
+                              &netapi_pktlib_ifTable,
+                              &pnetapiShm->netapi_global.nwal_context,
+                              &pnetapiShm->netapi_global.cfg);
+        if (result<0) { return -1; }
+        /* Common Initialization for all cores */
+        while(count < TUNE_NETAPI_MAX_NUM_TRANS)
+        {
+            netapi_proc_global.nwal_context.transInfos[count].transId = count;
+            count++;
+        }
+        result = netapip_startNwal(sharedHeapHandle, 
+                                   controlRxHeapHandle,
+                                   controlTxHeapHandle,
+                                   &handle->nwal_local,
+                                   &pnetapiShm->netapi_global.cfg,
+                                   &pnetapiShm->netapi_global.nwal_context,
+                                   handle->master);
+        if (result<0) { return -1; }
     }
-
-    /* Start the QMSS. */
-    if (netapip_startQm() != 1)
+    else
     {
-      netapi_Log("netapip_systemInit: returned from netapip_startQm with failure\n");
-        return -1;
-    }
-    
+        if (hplib_checkMallocArea(0) != hplib_OK)
+            return -1;
+        if (hplib_checkMallocArea(1) != hplib_OK)
+            return -1;
 
-    //clean our old junk in 1st bunch of queues that will be allocated to us
-    netapip_cleanupAtStart();
- netapi_Log("netapip_systemInit: returned from netapip_cleanupAtStart\n");
-    /* Initialize the global descriptor memory region. */
-    result= netapip_qmSetupMemRegion( 
-                      netapi_global.cfg.def_tot_descriptors_for_us,
-                      TUNE_NETAPI_DESC_SIZE,
-                      (unsigned int *) netapi_VM_QMemGlobalDescRam,
-                      TUNE_NETAPI_QM_GLOBAL_REGION);
-    if(result <0) {netapi_Log("netapip_systemInit: can't setup QM shared region\n"); return -1;}
-
-netapi_Log("netapip_systemInit: returned from netapip_qmSetupMemRegion\n");
-    /* Initialize CPPI CPDMA */
-
-    result = netapip_initCppi ();
-    netapi_Log("netapip_systemInit: returned from netapip_initCppi\n");
-    if (result != 1)
-    {
-        netapi_Log ("netapi: Error initializing CPPI SubSystem error code : %d\n",result);
-        return -1;
-    }
+#ifdef NETAPI_ENABLE_SECURITY
+                /* allocate 2x number of tunnels since we need one for inflow and one for data mode */
+                netapi_VM_SaContextVaddr = hplib_vmMemAlloc((TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2 *
+                                                SEC_CONTEXT_SZ), 128, 0);
+                if (!netapi_VM_SaContextVaddr)
+                {
+                    return (-1);
+                }
+#else
+                netapi_VM_SaContextVaddr= (char *) NULL;
+#endif
 
-    /* CPPI and Queue Manager are initialized. */
-    netapi_Log ("netapi: Queue Manager and CPPI are initialized.\n");
 
-    /* create main pkt heap */
-    /* Initialize the Shared Heaps. */
-    Pktlib_sharedHeapInit();
-    netapi_Log("netapip_systemInit: returned from Pktlib_sharedHeapInit\n");
-    /* Populate the heap interface table. */
-    netapi_pktlib_ifTable.data_malloc             = netapip_sharedMemoryMalloc;
-    netapi_pktlib_ifTable.data_free               = netapip_sharedMemoryFree;
 
-    /* Initialize the heap configuration. */
-    memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
-    /* Populate the heap configuration */
-    heapCfg.name                = "netapi";
-    heapCfg.memRegion           = TUNE_NETAPI_QM_GLOBAL_REGION;
-    heapCfg.sharedHeap          = 1;
-    heapCfg.useStarvationQueue  = 0;
-    heapCfg.dataBufferSize      = netapi_global.cfg.def_heap_buf_size;
-    heapCfg.numPkts             = netapi_global.cfg.def_heap_n_descriptors;
-    heapCfg.numZeroBufferPackets= netapi_global.cfg.def_heap_n_zdescriptors;
-    heapCfg.heapInterfaceTable.data_malloc  = netapi_pktlib_ifTable.data_malloc;
-    heapCfg.heapInterfaceTable.data_free    = netapi_pktlib_ifTable.data_free;
-    heapCfg.dataBufferPktThreshold   = 0;
-    heapCfg.zeroBufferPktThreshold   = 0;
+        /* (3) Allocate 2 QM regions from continguous chunk above */
+        netapi_VM_QMemGlobalDescRam = 
+                (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_GLOBAL_DESC *
+                TUNE_NETAPI_DESC_SIZE),
+                128,
+                0);
 
-    /* Create Shared Heap with specified configuration. */
-    sharedHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
-     netapi_Log("netapip_systemInit: returned from Pktlib_createHeap1\n");
-    //todo -> cleanup on failure
-    if (!sharedHeapHandle) { netapi_Log(">'netapi' heap create failed, Error Code: %d\n",errCode); return -1;}
-    handle->netcp_heap= sharedHeapHandle;
-
-    /* Update for Control */
-    heapCfg.name                = "netapi_control_rx";
-    heapCfg.sharedHeap          = 1;
-    heapCfg.dataBufferSize      = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
-    heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF;
-    heapCfg.numZeroBufferPackets= 0;
+        netapi_VM_QMemLocalDescRam =
+                (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
+                TUNE_NETAPI_DESC_SIZE),
+                128,
+                0);
 
-    controlRxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
-     netapi_Log("netapip_systemInit: returned from Pktlib_createHeap2\n");
-   //todo -> cleanup on failure
-   if (!controlRxHeapHandle) { netapi_Log("netapi -'netapi_control_rx' heap create failed, Error Code: %d\n",errCode); return -1;}
-   handle->netcp_control_rx_heap= controlRxHeapHandle;
-
-   
-   heapCfg.name                = "netapi_control_tx";
-   heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF;
-
-   controlTxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
-    netapi_Log("netapip_systemInit: returned from Pktlib_createHeap3\n");
-   //todo -> cleanup on failure
-   if (!controlTxHeapHandle) { netapi_Log("netapi -'netapi_control_tx' heap create failed, Error Code: %d\n",errCode); return -1;}
-   handle->netcp_control_tx_heap= controlTxHeapHandle;
-
-    /* now NWAL */
-    result = netapip_initNwal(
-                              TUNE_NETAPI_QM_GLOBAL_REGION,
-                              &netapi_pktlib_ifTable, 
-                              &netapi_global.nwal_context,
-                              &netapi_global.cfg);
-    if (result<0) {netapi_Log("netapi  init_nwal() failed\n"); return -1; }
- netapi_Log("netapip_systemInit: returned from netapip_initNwal\n");
-    /* start NWAL */
-
-
-    /* Common Initialization for all cores */
-    while(count < TUNE_NETAPI_MAX_NUM_TRANS)
-    {
-        netapi_global.nwal_context.transInfos[count].transId = count;
-        count++;
-    }
-    result = netapip_startNwal(sharedHeapHandle, 
+        /****************************************************
+         * partial initialization.  For process, not for SOC
+         ***************************************************/
+        result = netapip_initQm (pnetapiShm->netapi_global.cfg.def_max_descriptors,
+                                 pRmClientHandle);
+        if (result != 1)
+        {
+            return -1;
+        }
+
+        /* Start the QMSS. */
+        if (netapip_startQm(pRmClientHandle) != 1)
+        {
+            return -1;
+        }
+
+        result= netapip_qmSetupMemRegion( 
+                           pnetapiShm->netapi_global.cfg.def_tot_descriptors_for_us,
+                           TUNE_NETAPI_DESC_SIZE,
+                           (unsigned int *) netapi_VM_QMemGlobalDescRam,
+                           pnetapiShm->netapi_global.cfg.memoryRegion,
+                           pnetapiShm->netapi_global.cfg.start_index);
+        if(result <0)
+        {
+            return -1;
+        }
+        /* Initialize CPPI CPDMA */
+        result = netapip_initCppi(pRmClientHandle);
+        if (result != 1)
+        {
+            return -1;
+        }
+        /* CPPI and Queue Manager are initialized. */
+
+        /* create main pkt heap for this process */
+        /* Initialize the Shared Heaps. */
+        Pktlib_sharedHeapInit();
+        /* Populate the heap interface table. */
+        netapi_pktlib_ifTable.data_malloc             = netapip_sharedMemoryMalloc;
+        netapi_pktlib_ifTable.data_free               = netapip_sharedMemoryFree;
+        /* Initialize the heap configuration. */
+        memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
+        /* Populate the heap configuration */
+        heapCfg.name                = "netapi";
+        //heapCfg.memRegion           = TUNE_NETAPI_QM_GLOBAL_REGION;
+        heapCfg.memRegion = memInfo.memRegion;
+        heapCfg.sharedHeap          = 1;
+        heapCfg.useStarvationQueue  = 0;
+        heapCfg.dataBufferSize      = pnetapiShm->netapi_global.cfg.def_heap_buf_size;
+        heapCfg.numPkts             = pnetapiShm->netapi_global.cfg.def_heap_n_descriptors;
+        heapCfg.numZeroBufferPackets= pnetapiShm->netapi_global.cfg.def_heap_n_zdescriptors;
+        heapCfg.heapInterfaceTable.data_malloc  = netapi_pktlib_ifTable.data_malloc;
+        heapCfg.heapInterfaceTable.data_free    = netapi_pktlib_ifTable.data_free;
+        heapCfg.dataBufferPktThreshold   = 0;
+        heapCfg.zeroBufferPktThreshold   = 0;
+        
+        /* Create Shared Heap with specified configuration. */
+        sharedHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
+        //todo -> cleanup on failure
+        if (!sharedHeapHandle) { return -1;}
+        handle->netcp_heap= sharedHeapHandle;
+
+        //open shared heap handle but create new controlRx & Tx heaps for this
+        //process
+        /* Update for Control */
+        heapCfg.name                = "netapi_control_rx";/*todo:add random#*/
+        heapCfg.sharedHeap          = 1;
+        heapCfg.dataBufferSize      = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
+        heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF;
+        heapCfg.numZeroBufferPackets= 0;
+        controlRxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
+        if (!controlRxHeapHandle) { return -1;}
+
+        handle->netcp_control_rx_heap= controlRxHeapHandle;
+        heapCfg.name                = "netapi_control_tx";
+        heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF;
+        controlTxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
+        if (!controlTxHeapHandle) { return -1;}
+        handle->netcp_control_tx_heap= controlTxHeapHandle;
+
+        /* Common Initialization for all threads in process */
+        while(count < TUNE_NETAPI_MAX_NUM_TRANS)
+        {
+          netapi_proc_global.nwal_context.transInfos[count].transId = count;
+          count++;
+        }
+        result = netapip_startNwal(sharedHeapHandle,
                                controlRxHeapHandle,
                                controlTxHeapHandle,
                                &handle->nwal_local,
-                               &netapi_global.cfg,
-                               &netapi_global.nwal_context);
-    if (result<0) {netapi_Log("netapi start_nwal() failed\n"); return -1; }
-    netapi_Log("netapip_systemInit: returned from netapip_startNwal\n");
+                               &pnetapiShm->netapi_global.cfg,
+                               &pnetapiShm->netapi_global.nwal_context,
+                               handle->master);
+        if (result<0)
+        {
+            return -1;
+        }
+    }
+
+    //get timer running
+#ifdef CORTEX_A8
+        netapip_initTimer();
+#endif
+
+
+
     return 0;
 }
 
@@ -828,7 +1065,6 @@ netapi_Log("netapip_systemInit: returned from netapip_qmSetupMemRegion\n");
  ***************************************************************************/
 void netapip_zapQ(int queueNum)
 {
-    char * descPtr;
     int i;
     if (!queueNum) 
     {
@@ -837,15 +1073,11 @@ void netapip_zapQ(int queueNum)
     for (i=0;;i+=1 )
     {
         /* Pop descriptor from source queue */
-        if ((descPtr = (char *)pktio_mQmssQueuePopRaw(queueNum)) == NULL)
+        if (pktio_mQmssQueuePopRaw(queueNum) == NULL)
         {
             break;
         }
     }
-    if(i)
-    {
-        netapi_Log("netapip_zapQ: @recovery -  %d descriptors cleaned from qn %d\n",i, queueNum);
-    }
 }
 
 
@@ -863,14 +1095,6 @@ void netapi_dump_internal_heap_stats(void)
     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);
-netapi_Log("PA2SA(egress) stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
-                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-netapi_Log("               >  #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);