]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blobdiff - ti/runtime/netapi/src/netcp_cfg.c
Add support for etherType field for netapi_netcpCfgCraeteMacInterface
[keystone-rtos/netapi.git] / ti / runtime / netapi / src / netcp_cfg.c
index df531c4e36dc9dd63c489a00937e7bc6cd71f4ea..823b28bca2bef1066653626d9b55241e8506a2df 100755 (executable)
@@ -7,9 +7,9 @@
  * DESCRIPTION:  netcp configuration main source file for user space transport
  *               library
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
- *  Copyright (c) Texas Instruments Incorporated 2010-2011
+ *  Copyright (c) Texas Instruments Incorporated 2013
  * 
  *  Redistribution and use in source and binary forms, with or without 
  *  modification, are permitted provided that the following conditions 
  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
  ******************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+
 #include "netapi.h"
-#include "netcp_cfg.h"
-#include "netapi_loc.h"
+
+extern NETAPI_SHM_T* pnetapiShm;
 
 /******************************************************************
  ********************Netapi internal*************************************
 *******************************************************************/
-static hplib_spinLock_T netcp_cfg_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
+
 
 /********************************************************************
  * FUNCTION PURPOSE:  Netapi internal function to get a free transaction id
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to get a free transaction id.
  ********************************************************************/
-NetapiNwalTransInfo_t *  netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwal_TransID_t *pTransId)
+NetapiNwalTransInfo_t * netapip_getFreeTransInfo(NETAPI_HANDLE_T *p_handle,
+                                                 NETAPI_PROC_GLOBAL_T *p_proc_global,
+                                                 nwal_TransID_t *pTransId)
 {
     uint16_t    count=0;
 
     count=0;
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
     while(count < TUNE_NETAPI_MAX_NUM_TRANS)
     {
-        if((p_global->nwal_context.transInfos[count].inUse) != nwal_TRUE)
+        if((p_proc_global->nwal_context.transInfos[count].inUse) != nwal_TRUE)
         {
-            p_global->nwal_context.transInfos[count].inUse = nwal_TRUE;
+            p_proc_global->nwal_context.transInfos[count].inUse = nwal_TRUE;
             *pTransId = count;
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
-            return(&p_global->nwal_context.transInfos[count]);
+            p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+            return(&p_proc_global->nwal_context.transInfos[count]);
         }
         count++;
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
+    p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
     /* trouble.  need to wait for one to free up*/
     /* to do: handle this by forcing a poll of cntrl queue*/
-    printf(">netcp_cfg: trying to get free transaction slot but all full!!\n");
+    netapi_Log(">netcp_cfg: trying to get free transaction slot but all full!!\n");
     return NULL;
 
 }
@@ -88,7 +87,7 @@ NetapiNwalTransInfo_t *  netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwa
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to free a transaction id
  ********************************************************************/
-void netapip_FreeTransInfo(NetapiNwalTransInfo_t *pTransInfo)
+void netapip_freeTransInfo(NetapiNwalTransInfo_t *pTransInfo)
 {
     pTransInfo->inUse = nwal_FALSE;
     pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
@@ -99,13 +98,19 @@ void netapip_FreeTransInfo(NetapiNwalTransInfo_t *pTransInfo)
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to build a route
  ********************************************************************/
-void netcp_cfgp_build_route(NETCP_CFG_ROUTE_T * p_route, int16_t * p_flow,  Qmss_QueueHnd * p_q)
+void netapip_netcpCfgBuildRoute(NETCP_CFG_ROUTE_T * p_route,
+                                int16_t *p_flow,
+                                Qmss_QueueHnd *p_q,
+                                nwalRouteType_t *p_type)
 {
     if (!p_route) return;
     if (p_route->p_flow)  *p_flow= p_route->p_flow->flowid;
     else *p_flow = CPPI_PARAM_NOT_SPECIFIED;
-    if (p_route->p_dest_q) *p_q = pktio_get_q(p_route->p_dest_q);
+
+    if (p_route->p_dest_q) *p_q = netapi_pktioGetQ(p_route->p_dest_q);
     else *p_q=QMSS_PARAM_NOT_SPECIFIED;
+
+    *p_type = p_route->routeType;
 }
 
 
@@ -120,25 +125,27 @@ void netcp_cfgp_build_route(NETCP_CFG_ROUTE_T * p_route, int16_t * p_flow,  Qmss
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to find a free slot for an SA
  ********************************************************************/
-int netcp_cfgp_find_policy_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int tunnel)
+int netapip_netcpCfgFindPolicySlot(NETAPI_HANDLE_T *p_handle,
+                                   NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                   int tunnel)
 {
     int i;
     if ((tunnel <0 ) || (tunnel >=TUNE_NETAPI_MAX_SA))
         return -1;
 
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
     //find a free entry
     for(i=0;i<TUNE_NETAPI_MAX_POLICY;i++)
     {
         if (!p->policy[i].in_use)
         {
             p->policy[i].in_use = 2; //pending
-            p->policy[i].tunnel= tunnel; //save tunnel this is linked to 
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
+            p->policy[i].tunnel= tunnel; //save tunnel this is linked to
+            p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
             return i;
         }
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
+    p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
     return -1;
 }
 
@@ -147,10 +154,8 @@ int netcp_cfgp_find_policy_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int tunnel)
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to delete a policy from policy list
  ********************************************************************/
-//internal: delete a policy from list 
-void netcp_cfgp_delete_policy(
-         NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-         int policy_slot )
+void netapip_netcpCfgDeletePolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                  int policy_slot)
 {
     if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY))
     {
@@ -165,12 +170,14 @@ void netcp_cfgp_delete_policy(
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to insert a policy to the policy list
  ********************************************************************/
-void netcp_cfgp_insert_policy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int policy_slot,  //we 'reserved it already'
-                          void * handle)
+void netapip_netcpCfgInsertPolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                  int policy_slot,
+                                  void * handle,
+                                  void * user_data)
 {
     p->policy[policy_slot].in_use=1;
     p->policy[policy_slot].nwal_handle = handle;
+    p->policy[policy_slot].user_data = user_data;
     return;
 }
 
@@ -179,8 +186,8 @@ void netcp_cfgp_insert_policy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ************************************************************************
  * DESCRIPTION:  Netapi internal function which returns NWAL handle for a policy
  ************************************************************************/
-void *netcp_cfgp_get_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int policy_slot)
+void *netapip_netcpCfgGetPolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                int policy_slot)
 {
     if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY))
         return NULL;
@@ -194,26 +201,28 @@ void *netcp_cfgp_get_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to find a free slot in SA list for an SA
  ********************************************************************/
-int netcp_cfgp_find_sa_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface)
+int netapip_netcpCfgFindSaSlot(NETAPI_HANDLE_T *p_handle,
+                               NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                               int iface)
 {                                    
    int i;
    if (iface != NETCP_CFG_NO_INTERFACE)
    {
    if ((iface <0 ) || (iface >=TUNE_NETAPI_MAX_NUM_MAC)) return -1;
    }
-           hplib_mSpinLockLock(&netcp_cfg_lock);
-         //find a free entry
+   p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
+   //find a free entry
    for(i=0;i<TUNE_NETAPI_MAX_SA;i++)
    {                       
        if (!p->tunnel[i].in_use)
        {
            p->tunnel[i].in_use = 2; //pending
            p->tunnel[i].iface= iface; //save iface
-           hplib_mSpinLockUnlock(&netcp_cfg_lock);
+           p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
            return i;
        }
    }
-   hplib_mSpinLockUnlock(&netcp_cfg_lock);
+   p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
    return -1;
 }
 
@@ -222,9 +231,8 @@ int netcp_cfgp_find_sa_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface)
  ********************************************************************
  * DESCRIPTION: Netapi internal function to delete an SA from SA list 
  ********************************************************************/
-void netcp_cfgp_delete_sa(
-         NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-         int sa_slot )
+void netapip_netcpCfgDeleteSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                              int sa_slot)
 {
     if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
     {
@@ -234,26 +242,79 @@ void netcp_cfgp_delete_sa(
     return;
 }
 
+
+/****************************************************************************
+ * FUNCTION PURPOSE:  Internal function to retrieve SB command info template
+ **************************************************************************
+ * DESCRIPTION:  Internal function to retrieve SB command info template
+ ***************************************************************************/
+nwalTxDmPSCmdInfo_t* netapip_netcpCfgGetSaSBInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                                 NETCP_CFG_SA_T    sa_app_id)
+{
+     int sa_slot = netapi_cfgGetMatchId(sa_app_id);
+    if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
+    {
+        return NULL;
+    }
+    return (&p->tunnel[sa_slot].dmPSCmdInfo);
+}
+
+/****************************************************************************
+ * FUNCTION PURPOSE:  Internal function to retrieve Inflow mode 
+ *                    software information required to transmit packet
+ **************************************************************************
+ * DESCRIPTION:  Internal function to retrieve Inflow mode 
+ *                    software information required to transmit packet
+ ***************************************************************************/
+int netapip_netcpCfgGetSaInflowInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                    NETCP_CFG_SA_T    sa_app_id,
+                                    uint32_t *swInfo0,
+                                    uint32_t *swInfo1)
+{
+    int sa_slot = netapi_cfgGetMatchId(sa_app_id);
+    if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
+    {
+        return 0;
+    }
+    *swInfo0 = p->tunnel[sa_slot].swInfo0;
+    *swInfo1 = p->tunnel[sa_slot].swInfo1;
+    return 1;
+}
+
 /********************************************************************
  * FUNCTION PURPOSE:  Netapi internal function to insert an SA to the SA list
  ********************************************************************
  * DESCRIPTION: Netapi internal function to insert an SA to the SA list 
  ********************************************************************/
-void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int sa_slot,  //we 'reserved it already'
-                          int dir,
-                          int mode,
-                          void * temp1,
-                          void * temp2,
-                          void * handle_inflow,
-                          void * handle_sideband)
+void netapip_netcpCfgInsertSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                              int sa_slot,
+                              int dir,
+                              int mode,
+                              void * temp1,
+                              void * temp2,
+                              void * handle_inflow,
+                              void * handle_sideband,
+                              nwalTxDmPSCmdInfo_t *dmPSCmdInfo,
+                              uint32_t swInfo0,
+                              uint32_t swInfo1,
+                              void* user_data)
 {
-        p->tunnel[sa_slot].in_use=1;
-        p->tunnel[sa_slot].inbound = dir;
-        p->tunnel[sa_slot].sa_mode = mode;
-        p->tunnel[sa_slot].sa_handle_inflow = handle_inflow;
-        p->tunnel[sa_slot].sa_handle_sideband = handle_sideband;
-        return;
+    p->tunnel[sa_slot].in_use=1;
+    p->tunnel[sa_slot].inbound = dir;
+    p->tunnel[sa_slot].sa_mode = mode;
+    p->tunnel[sa_slot].sa_handle_inflow = handle_inflow;
+    p->tunnel[sa_slot].sa_handle_sideband = handle_sideband;
+    p->tunnel[sa_slot].swInfo0 = swInfo0;
+    p->tunnel[sa_slot].swInfo1 = swInfo1;
+    p->tunnel[sa_slot].user_data = user_data;
+    //netapi_Log("netapip_netcpCfgInsertSa: swInfo0 0x%x, swInfo1: 0x%x, user data: %d\n",
+//        p->tunnel[sa_slot].swInfo0, p->tunnel[sa_slot].swInfo1, (uint32_t)p->tunnel[sa_slot].user_data);
+
+    if (dmPSCmdInfo)
+    {
+        memcpy(&p->tunnel[sa_slot].dmPSCmdInfo, dmPSCmdInfo, sizeof(nwalTxDmPSCmdInfo_t));
+    }
+    return;
 }
 
 /********************************************************************
@@ -261,8 +322,9 @@ void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ********************************************************************
  * DESCRIPTION: Netapi internal function to return NWAL handles for an SA
  ********************************************************************/
- void *netcp_cfgp_get_sa_handles( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int sa_slot, void ** p_sideband)
+ void *netapip_netcpCfgGetSaHandles(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                    int sa_slot,
+                                    void ** p_sideband)
 {
     if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
         return NULL;
@@ -280,21 +342,22 @@ void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ********************************************************************
  * DESCRIPTION: Netapi internal function to find a free slot for a flow
  ********************************************************************/
-static int netcp_cfgp_find_flow_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
+static int netapip_netcpCfgFindFlowSlot(NETAPI_HANDLE_T *p_handle,
+                                        NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
 {
     int i;
     //find a free entry
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
     for(i=0;i<TUNE_NETAPI_MAX_FLOWS;i++)
     {
         if (!p->flows[i].in_use)
         {
-            p->flows[i].in_use = 2; //pending
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
+            p->flows[i].in_use = 2; /* pending */
+            p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
             return i;
         }
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
+   p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
     return -1;
 }
 
@@ -303,7 +366,8 @@ static int netcp_cfgp_find_flow_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
  ********************************************************************
  * DESCRIPTION: Netapi internal function to find delete a flow from flow list
  ********************************************************************/
-static void netcp_cfgp_delete_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int slot)
+static void netapip_netcpCfgDeleteFlow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                       int slot)
 {
     if ((slot >=0 ) && (slot < TUNE_NETAPI_MAX_FLOWS))
     {
@@ -316,14 +380,15 @@ static void netcp_cfgp_delete_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int slot)
  ********************************************************************
  * DESCRIPTION: Netapi internal function to  delete a flow from flow list
  ********************************************************************/
-//internal:  insert a flow into flow slot
-static NETCP_CFG_FLOW_HANDLE_T netcp_cfgp_insert_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int slot,  //we 'reserved it already'
-                          void * handle)  //cppi flow handle. Save this for delete
+static NETCP_CFG_FLOW_HANDLE_T netapip_netcpCfgInsertFlow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                                          int slot,
+                                                          int dma_engine,
+                                                          void * handle)
 {
     p->flows[slot].in_use=1;
     p->flows[slot].handle = handle;
     p->flows[slot].flow.flowid  = Cppi_getFlowId(handle);
+    p->flows[slot].flow.dma_engine  = dma_engine;
         return (NETCP_CFG_FLOW_HANDLE_T) &p->flows[slot].flow;
 }
 
@@ -333,24 +398,28 @@ static NETCP_CFG_FLOW_HANDLE_T netcp_cfgp_insert_flow(NETAPI_NWAL_GLOBAL_CONTEXT
  * DESCRIPTION: Netapi internal function to find entry matching the flowid. Returns
  * the slot number and the cPPI handle.
  ********************************************************************/
-static int netcp_cfgp_find_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int flowid,  
-                          void ** handle) 
+static int netapip_netcpCfgFindFlow(NETAPI_HANDLE_T *p_handle,
+                                    NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                    int flowid,  
+                                    int dma_engine,
+                                    void ** handle) 
 {
     int i;
     *handle=NULL;
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
     for(i=0;i<TUNE_NETAPI_MAX_FLOWS;i++)
     {
-        if ((p->flows[i].in_use)&&(p->flows[i].flow.flowid == flowid))
+       if ((p->flows[i].in_use)&&
+           (p->flows[i].flow.flowid == flowid)&&
+           (p->flows[i].flow.dma_engine == dma_engine))
         {
             *handle = p->flows[i].handle;
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
+             p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
             return i;
         }
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
-   return -1;
+    p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+    return -1;
 }
 
 
@@ -358,27 +427,28 @@ static int netcp_cfgp_find_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
 /*============================IP ADDRESSES==========================*/
 
 /***************************************************************************
- * FUNCTION PURPOSE:  Netapi internal function to find a free slot for IP rule in IP slot list 
+ * FUNCTION PURPOSE:  Netapi internal function to find a free slot for IP rule in IP slot list
  ***************************************************************************
  * DESCRIPTION: NNetapi internal function to find a free slot for IP rule in IP slot list
  ***************************************************************************/
-static int netcp_cfgp_find_ip_slot(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int iface_no)
+static int netapip_netcpCfgFindIpSlot(NETAPI_HANDLE_T *p_handle,
+                                      NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                      int iface_no)
 {
     int i;
 
     //find a free entry
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
     for(i=0;i<TUNE_NETAPI_MAX_NUM_IP;i++)
     {
         if (!p->ips[i].in_use)
         {
             p->ips[i].in_use = 2; //pending
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
+            p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
             return i;
         }
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
+    p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
     return -1;
 }
 
@@ -387,22 +457,28 @@ static int netcp_cfgp_find_ip_slot(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ***************************************************************************
  * DESCRIPTION: Netapi internal function to insert an IP address into interface
  ***************************************************************************/
-static void netcp_cfgp_insert_ip(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, 
-                          nwal_IpType ipType,
-                          nwalIpAddr_t *ip_addr, 
-                          nwalIpOpt_t *ip_qualifiers, 
-                          int iface_no,
-                          int ip_slot,  //we 'reserved it already'
-                          void * handle)
+static void netapip_netcpCfgInsertIp(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, 
+                                     nwal_IpType ipType,
+                                     nwalIpAddr_t *ip_addr, 
+                                     nwalIpOpt_t *ip_qualifiers, 
+                                     int iface_no,
+                                     int ip_slot,
+                                     void * handle,
+                                     void * user_data)
 {
-     p->ips[ip_slot].in_use=1;
+    p->ips[ip_slot].in_use=1;
     memcpy(&p->ips[ip_slot].ip_addr, ip_addr, sizeof(nwalIpAddr_t));
     if(ip_qualifiers)
+    {
         memcpy(&p->ips[ip_slot].ip_qualifiers, ip_qualifiers, sizeof(nwalIpOpt_t));
+    }
     else
+    {
         memset(&p->ips[ip_slot].ip_qualifiers, 0, sizeof(nwalIpOpt_t));
+    }
     p->ips[ip_slot].ip_type = ipType;
     p->ips[ip_slot].nwal_handle = handle;
+    p->ips[ip_slot].user_data = user_data;
 }
 
 /***************************************************************************
@@ -410,12 +486,11 @@ static void netcp_cfgp_insert_ip(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ***************************************************************************
  * DESCRIPTION: Netapi internal function to free IP slot associated with IP address
  ***************************************************************************/
-static void netcp_cfgp_delete_ip(
-         NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-         int iface_no,
-         int ip_slot )
+static void netapip_netcpCfgDeleteIp(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                     int iface_no,
+                                     int ip_slot)
 {
-    if ((ip_slot >=0) &&(ip_slot <=TUNE_NETAPI_MAX_NUM_IP))
+    if ((ip_slot >=0) &&(ip_slot < TUNE_NETAPI_MAX_NUM_IP))
     {
         p->ips[ip_slot].in_use=0;
     }
@@ -426,10 +501,9 @@ static void netcp_cfgp_delete_ip(
  ***************************************************************************
  * DESCRIPTION: Netapi internal function to get IP handle associated with IP address
  ***************************************************************************/
-static void *netcp_cfgp_get_ip_handle(
-         NETAPI_NWAL_GLOBAL_CONTEXT_T *p, 
-         int iface_no,
-         int ip_slot )
+static void *netapip_netcpCfgGetIpHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                         int iface_no,
+                                         int ip_slot)
 {
     if ((ip_slot <0)||(ip_slot>=TUNE_NETAPI_MAX_NUM_IP))
         return NULL;
@@ -447,8 +521,11 @@ static void *netcp_cfgp_get_ip_handle(
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to insert an interface to the interface list
  *******************************************************************************/
-static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char * p_mac,
-                           int iface_no, int state, NETCP_CFG_VLAN_T vlan, void * handle)
+static void netapip_netcpCfgInsertMac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                      unsigned char * p_mac,
+                                      int iface_no, 
+                                      int state, NETCP_CFG_VLAN_T vlan, 
+                                      void * handle)
 {
     if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
     {
@@ -458,10 +535,10 @@ static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char
         p->interfaces[iface_no].state = state;
         //todo p->interfaces[iface_no].vlan = vlan;
         p->interfaces[iface_no].nwal_handle = handle; //save handle assoicated with this rule
-        printf("netcp_cfgp_insert_mac, global context 0x%x\n", p);
+        netapi_Log("netapip_netcpCfgInsertMac, global context 0x%x\n", p);
     }
     else 
-        printf(">netcp_cfg insert interface # out of range %d\n",iface_no);
+        netapi_Log(">netapip_netcpCfgInsertMac insert interface # out of range %d\n",iface_no);
 
 }
 
@@ -470,26 +547,31 @@ static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to get handle associated with interface
  *******************************************************************************/
-void* netcp_cfgp_get_mac_handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
+void* netapip_netcpCfgGetMacHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                   int iface_no)
 {
-   if (iface_no == NETCP_CFG_NO_INTERFACE) return NULL;
-   if ((iface_no <0 ) || (iface_no >= TUNE_NETAPI_MAX_NUM_MAC))
-   {
-       return NULL;
-   }
-   else if ( p->interfaces[iface_no].in_use)
-   {
-     return (void *) p->interfaces[iface_no].nwal_handle;
-   }
-   //no valid entry in slot
-   return NULL;
+    if (iface_no == NETCP_CFG_NO_INTERFACE)
+    {
+        return NULL;
+    }
+    if ((iface_no <0 ) || (iface_no >= TUNE_NETAPI_MAX_NUM_MAC))
+    {
+        return NULL;
+    }
+    else if ( p->interfaces[iface_no].in_use)
+    {
+      return (void *) p->interfaces[iface_no].nwal_handle;
+    }
+    //no valid entry in slot
+    return NULL;
 }
 /*******************************************************************************
  * FUNCTION PURPOSE:  Netapi internal function to delete interface from interface list
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to delete interface from interface list
  *******************************************************************************/
-static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
+static void netapip_netcpCfgDeleteMac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                      int iface_no)
 {
     if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
     {
@@ -497,7 +579,6 @@ static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
     }
 }
 
-
 /*========================CLASSIFIERS==========================*/
 
 /*******************************************************************************
@@ -505,35 +586,35 @@ static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to find a free slot for classifier rule
  *******************************************************************************/
-static int netcp_cfgp_find_class_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
+static int netapip_netcpCfgFindClassSlot(NETAPI_HANDLE_T *p_handle,
+                                         NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
 {
-   int i;
-         //find a free entry\
-    hplib_mSpinLockLock(&netcp_cfg_lock);
-   for(i=0;i<TUNE_NETAPI_MAX_CLASSIFIERS;i++)
-   {
-       if (!p->classi[i].in_use)
-       {
-           p->classi[i].in_use = 2; //pending
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
-           return i;
-       }
-   }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
-   return -1;
+    int i;
+    p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
+    for(i=0;i<TUNE_NETAPI_MAX_CLASSIFIERS;i++)
+    {
+        if (!p->classi[i].in_use)
+        {
+            p->classi[i].in_use = 2; //pending
+            p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+            return i;
+        }
+    }
+    p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+    return -1;
 }
 /*******************************************************************************
  * FUNCTION PURPOSE:  Netapi internal function to find a delete a classifer from classifer list
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to find a delete a classifer from classifer list
  *******************************************************************************/
-static void netcp_cfgp_delete_class(
+static void netapip_netcpCfgDeleteClass(
          NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
          int class_slot )
 {
     if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
     {
-        return ;
+        return;
     }
     p->classi[class_slot].in_use=0;
 }
@@ -543,18 +624,23 @@ static void netcp_cfgp_delete_class(
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to find a insert a classifer to classifer list
  *******************************************************************************/
-static void netcp_cfgp_insert_class(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                            int class_slot,  //we 'reserved it already'
-                            int class_type,
-                            void * L2_handle,
-                            void * L3_handle,
-                            void * L4_handle)
+static void netapip_netcpCfgInsertClass(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                        int class_slot,
+                                        int class_type,
+                                        void * L2_handle,
+                                        void * L3_handle,
+                                        void * L4_handle,
+                                        void * user_data)
 {
-    p->classi[class_slot].in_use=1;
-    p->classi[class_slot].nwal_L2_handle = L2_handle;
-    p->classi[class_slot].nwal_L3_handle = L3_handle;
-    p->classi[class_slot].nwal_L4_handle = L4_handle;
-    p->classi[class_slot].class_type = class_type;
+    if ((class_slot >=0 ) && (class_slot < TUNE_NETAPI_MAX_CLASSIFIERS))
+    {
+        p->classi[class_slot].in_use=1;
+        p->classi[class_slot].nwal_L2_handle = L2_handle;
+        p->classi[class_slot].nwal_L3_handle = L3_handle;
+        p->classi[class_slot].nwal_L4_handle = L4_handle;
+        p->classi[class_slot].class_type = class_type;
+        p->classi[class_slot].user_data = user_data;
+    }
 }
 
 /*******************************************************************************
@@ -562,24 +648,68 @@ static void netcp_cfgp_insert_class(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to get L4 nwal handle for classifier
  *******************************************************************************/
-static void *netcp_cfgp_get_l4_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int class_slot)
+static void *netapip_netcpCfgGetL4Handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                         int class_slot)
 {
-    if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS)) return NULL;
-    if (!p->classi[class_slot].in_use) return NULL;
+    if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
+    {
+        return NULL;
+    }
+    if (!p->classi[class_slot].in_use)
+    {
+        return NULL;
+    }
     return p->classi[class_slot].nwal_L4_handle;
 }
 
+
+
 /*******************************************************************************
  * FUNCTION PURPOSE:  Netapi internal function to get L3 nwal handle for classifier
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to get L3 nwal handle for classifier
  *******************************************************************************/
-static void *netcp_cfgp_get_l3_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int class_slot)
+static int cfgOkToDeleteL3ClassiHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                         void*  l3_handle)
 {
-    if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS)) return NULL;
-    if (!p->classi[class_slot].in_use) return NULL;
+    int i;
+    int count=0;
+
+    if(l3_handle == NULL)
+        return NETAPI_FALSE;
+    for(i=0; i< TUNE_NETAPI_MAX_CLASSIFIERS;i++)
+    {
+        if (!p->classi[i].in_use)
+        {
+            continue;
+        }
+        if (l3_handle == p->classi[i].nwal_L3_handle)
+        {
+            count++;
+        }
+    }
+    if (count > 0)
+        return NETAPI_FALSE;
+
+    return NETAPI_TRUE;
+}
+
+/*******************************************************************************
+ * FUNCTION PURPOSE:  Netapi internal function to get L3 nwal handle for classifier
+ *******************************************************************************
+ * DESCRIPTION:  Netapi internal function to get L3 nwal handle for classifier
+ *******************************************************************************/
+static void *netapip_netcpCfgGetL3Handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                         int class_slot)
+{
+    if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
+    {
+        return NULL;
+    }
+    if (!p->classi[class_slot].in_use)
+    {
+        return NULL;
+    }
     return p->classi[class_slot].nwal_L3_handle;
 }
 
@@ -594,12 +724,17 @@ static void *netcp_cfgp_get_l3_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ********************************************************************
  * DESCRIPTION:  API to request statistics from NETCP
  ********************************************************************/
-void netcp_cfgReqStats(NETAPI_T  h, NETCP_CFG_STATS_CB cb, int doClear, int *err) 
+void netapi_netcpCfgReqStats(NETAPI_T  h, 
+                             NETCP_CFG_STATS_CB cb,
+                             int doClear,
+                             int *err)
 {
     nwal_RetValue ret;
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     NetapiNwalTransInfo_t *pTransInfo;
     nwal_TransID_t     transId;
+
+    paSysStats_t netcp_stats;
     if ((!n) || (!cb))
     {
         *err = NETAPI_ERR_BAD_INPUT;
@@ -607,50 +742,64 @@ void netcp_cfgReqStats(NETAPI_T  h, NETCP_CFG_STATS_CB cb, int doClear, int *err
     }
     *err =0;
 
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &transId);
+    pTransInfo = netapip_getFreeTransInfo(n,
+                                          (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+                                          &transId);
     if (!pTransInfo) { *err =  NETAPI_ERR_BUSY; return ;}
     pTransInfo->transType = NETAPI_NWAL_HANDLE_STAT_REQUEST;
     pTransInfo->netapi_handle = h;
     n->nwal_local.stats_cb = cb;
+
+    memset(&netcp_stats, 0, sizeof(paSysStats_t));
     ret = nwal_getPAStats( ((NETAPI_GLOBAL_T *) n->global)->nwal_context.nwalInstHandle,
                               transId,
-                              NULL,
+                              &netcp_stats,
                               doClear);
     if(ret !=  nwal_OK)
     {
-        pTransInfo->inUse = nwal_FALSE;
         *err = NETAPI_ERR_BUSY;  //no resources??
-        printf("> netcp_cfg reqStats failed, err=%d\n",ret);
+        netapi_Log("> netapi_netcpCfg reqStats failed, err=%d\n",ret);
+        netapip_freeTransInfo(pTransInfo);
+        return;
     }
-
+#if defined(DEVICE_K2E) || defined(DEVICE_K2L)
+    if (cb)
+    {
+        cb(h, &netcp_stats);
+    }
+#endif
+    netapip_freeTransInfo(pTransInfo);
 }
 /********************************************************************
  * FUNCTION PURPOSE:  API to create a MAC interface
  ********************************************************************
  * DESCRIPTION:  API to create a MAC interface
  ********************************************************************/
-NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
-                    NETAPI_T  h,
-                    uint8_t *p_mac,
-                    int  iface_no, 
-                    int switch_port, 
-                    NETCP_CFG_ROUTE_HANDLE_T  route,
-                    NETCP_CFG_VLAN_T  vlan,  //future
-                    int state,  //0=down, 1=up  //ignored
-                    int * err
-)
+NETCP_CFG_MACIF_T  netapi_netcpCfgCreateMacInterface(NETAPI_T  h,
+                                                     uint8_t *p_mac,
+                                                     uint8_t *p_mac_remote,
+                                                     int  iface_no, 
+                                                     int switch_port, 
+                                                     NETCP_CFG_ROUTE_HANDLE_T  route,
+                                                     NETCP_CFG_VLAN_T  vlan,  //future
+                                                     uint16_t etherType,
+                                                     int state,  //0=down, 1=up  //ignored
+                                                     int * err)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
-    nwalMacParam_t   MacInfo=
+    nwalMacParam_t   macInfo=
     {
         0,      /* validParams */
         0,      /* ifNum */
         0,      /* vlanId      */
         { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },      /* Local mac */
+        { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },      /* Remote mac */
         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 */
-        QMSS_PARAM_NOT_SPECIFIED                     /* Use default queue configured to NWAL if packet is routed to host */
+        QMSS_PARAM_NOT_SPECIFIED,                     /* Use default queue configured to NWAL if packet is routed to host */
+        0,
+        0
     };
 
     nwal_RetValue       retValue;
@@ -660,7 +809,9 @@ NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
     if ((!n) || (!p_mac)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}
     *err =0;
 
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo(n,
+                                          (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+                                          &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY;
@@ -672,25 +823,49 @@ NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
     pTransInfo->netapi_handle = h;
 
     /* set up MacInfo */
-    memcpy(&MacInfo.macAddr,p_mac,6); 
+    memcpy(&macInfo.macAddr,p_mac,6);
+    if(p_mac_remote)
+    {
+        macInfo.validParams |=  NWAL_SET_MAC_VALID_PARAM_REMOTE_MAC;
+        memcpy(&macInfo.remMacAddr,p_mac_remote,6);
+    }
     /* todo: vlan */
-    MacInfo.ifNum = switch_port;  /* todo: check for 0/1 relative*/
+    if (switch_port)
+    {
+        macInfo.validParams |= NWAL_SET_MAC_VALID_PARAM_IFNUM ;
+        macInfo.ifNum = switch_port;
+    }
+
+    if(etherType)
+    {
+        macInfo.validParams |= NWAL_SET_MAC_VALID_PARAM_ETHER_TYPE;
+        macInfo.etherType = etherType;
+    }
 
     if (route != NULL)
     {
-        netcp_cfgp_build_route(route,&MacInfo.appRxPktFlowId, &MacInfo.appRxPktQueue);
+        if((route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
+            NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
+        {
+           macInfo.validParams |= 
+                    NWAL_SET_MAC_VALID_PARAM_ROUTE_TYPE;
+        }
+        netapip_netcpCfgBuildRoute(route,
+                                   &macInfo.appRxPktFlowId,
+                                   &macInfo.appRxPktQueue,
+                                   &macInfo.routeType);
     }
     retValue = nwal_setMacIface( ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
                                   trans_id,
                                   (nwal_AppId) (NETAPI_NETCP_MATCH_GENERIC_MAC | iface_no),
-                                  &MacInfo,
+                                  &macInfo,
                                   &pTransInfo->handle);
     if(retValue !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-        printf (">netcp cfg - ERROR: nwal_setMacIface returned Error Code %d\n",
+        netapi_Log ("netapi_netcpCfg - ERROR: nwal_setMacIface returned Error Code %d\n",
                     retValue);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         return -1;
     }
 
@@ -708,19 +883,19 @@ NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *err = NETAPI_ERR_PA_FW;
-            printf (">netcp_cfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
+            netapi_Log (">netapi_netcpCfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
                     *err);
             return -1;
         }
 
     }
-    printf (">netcp cfg: MAC i/f %d added\n", iface_no);
-    netcp_cfgp_insert_mac(&netapi_get_global()->nwal_context, 
+    netapi_Log ("netapi_netcpCfg: MAC i/f %d added\n", iface_no);
+    netapip_netcpCfgInsertMac(&netapi_get_global()->nwal_context, 
                           p_mac, iface_no, state,vlan,
                           (void *) pTransInfo->handle);
-    netapip_FreeTransInfo(pTransInfo);
+    netapip_freeTransInfo(pTransInfo);
     return  (NETAPI_NETCP_MATCH_GENERIC_MAC | iface_no);
 }
 
@@ -729,7 +904,9 @@ NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
  ********************************************************************
  * DESCRIPTION:  API to delete MAC  interface
  ********************************************************************/
-void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
+void netapi_netcpCfgDelMac(NETAPI_T h,
+                           int iface_no,
+                           int *err)
 {
     nwal_RetValue ret;
     NetapiNwalTransInfo_t *pTransInfo;
@@ -738,13 +915,17 @@ void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
     void * ifHandle;
 
     //get the nwal handle assoicated with this iface
-    ifHandle = netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context, iface_no );
+    ifHandle = netapip_netcpCfgGetMacHandle(&netapi_get_global()->nwal_context, iface_no );
     if(!ifHandle) 
-            {*err = NETAPI_ERR_BAD_INPUT; return ;}
+    {
+        *err = NETAPI_ERR_BAD_INPUT; return ;
+    }
     *err =0;
 
     //get a transaction id
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo(n,
+                                          (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+                                          &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY;
@@ -763,9 +944,9 @@ void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
     if(ret !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-        printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+        netapi_Log ("netapi_netcpCfg - ERROR: nwal_delMacIface returned Error Code %d\n",
                     ret);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         return;
     }
     //wait here until its done since scheduler isn't running yet most likely..
@@ -782,18 +963,18 @@ void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *err = NETAPI_ERR_PA_FW;
-            printf (">netcp_cfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
+            netapi_Log (">netapi_netcpCfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
                     *err);
-            netcp_cfgp_delete_mac(&netapi_get_global()->nwal_context,  iface_no);
+            netapip_netcpCfgDeleteMac(&netapi_get_global()->nwal_context,  iface_no);
             return;
         }
     }
-    printf (">netcp cfg: MAC i/f %d deleted\n",iface_no);
-    netapip_FreeTransInfo(pTransInfo);
+    netapi_Log ("netapi_netcpCfg: MAC i/f %d deleted\n",iface_no);
+    netapip_freeTransInfo(pTransInfo);
     //zap the entry
-    netcp_cfgp_delete_mac(&netapi_get_global()->nwal_context,  iface_no);
+    netapip_netcpCfgDeleteMac(&netapi_get_global()->nwal_context,  iface_no);
     return ;
 }
 
@@ -803,26 +984,32 @@ void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
  ********************************************************************
  * DESCRIPTION:  NETAPi internal function to Add IP to MAC interface
  ********************************************************************/
-static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
-                  NETAPI_T  h,
-                  int  iface_no,
-                  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers,
-                  NETCP_CFG_ROUTE_HANDLE_T  route,  //NULL for default
-                  int * err,
-                  int  flag) //TRUE: add IP to iface.  False: add IP as part of classifier
+static NETCP_CFG_IP_T  netapip_netcpCfgAddIpInternal(NETAPI_T  h,
+                                                     int  iface_no,
+                                                     nwal_IpType ipType,
+                                                     nwalIpAddr_t  * ip_addr,
+                                                     nwalIpAddr_t  *ip_rem_addr,
+                                                     nwalIpOpt_t * ip_qualifiers,
+                                                     NETCP_CFG_ROUTE_HANDLE_T  route,/*NULL for default*/
+                                                     void * user_data,
+                                                     int * err,
+                                                     int  flag) /*TRUE: add IP to iface,
+                                                     FALSE: add IP as part of classifier */
 {
+    static unsigned char zeroIP6[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * n_handle=NULL;
     nwalIpParam_t    nwalIpParam= {
+    0,
     pa_IPV4,      /* IP Type */
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Dest IP */
+    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Source IP */
     { 0x0,0,0,0},/* IP Options */
     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 */
-    QMSS_PARAM_NOT_SPECIFIED                     /* Use default queue configured to NWAL if packet is routed to host */
+    QMSS_PARAM_NOT_SPECIFIED,                     /* Use default queue configured to NWAL if packet is routed to host */
+    0
 };
     nwal_RetValue       retValue;
     NetapiNwalTransInfo_t *pTransInfo;
@@ -839,8 +1026,8 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
 
     if (iface_no != NETCP_CFG_NO_INTERFACE)
     {
-        printf("netcp_cfgAddIpInternal, in_use %d\n", netapi_get_global()->nwal_context.interfaces[iface_no].in_use);
-        printf("netcp-cfgAddIpInternal, p 0x%x\n", &netapi_get_global()->nwal_context);
+        netapi_Log("netapip_netcpCfgAddIpInternal, in_use %d\n", netapi_get_global()->nwal_context.interfaces[iface_no].in_use);
+        netapi_Log("netapip_netcpCfgAddIpInternal, p 0x%x\n", &netapi_get_global()->nwal_context);
         if(netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
         {
             n_handle =  netapi_get_global()->nwal_context.interfaces[iface_no].nwal_handle;
@@ -854,8 +1041,9 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
     if (flag) //if adding IP to MAC then reserve a slot to save info
     {
         //find free slot for IP & reserve
-         ip_slot= netcp_cfgp_find_ip_slot(&netapi_get_global()->nwal_context, 
-                                   iface_no);
+         ip_slot= netapip_netcpCfgFindIpSlot(n,
+                                             &netapi_get_global()->nwal_context, 
+                                             iface_no);
         if (ip_slot <0) 
         {
             *err= NETAPI_ERR_NOMEM;  //no room 
@@ -864,13 +1052,15 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
     }
 
     //get a transaction object for config action
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo(n, 
+                                          (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+                                          &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY;
         if (flag)
         {
-            netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context,
+            netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,
                          iface_no,
                          ip_slot);
         }
@@ -883,10 +1073,38 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
 
     //build nwalIpParam
     memcpy(&nwalIpParam.locIpAddr,ip_addr, sizeof(nwalIpAddr_t));
+    if (ip_rem_addr)
+    {
+        if (ipType == nwal_IPV4)
+        {
+            if(memcmp(ip_rem_addr, zeroIP6, sizeof(nwalIpv4Addr_t)))
+            {
+                nwalIpParam.validParams |= NWAL_SET_IP_VALID_PARAM_REMOTE_IP;
+                memcpy(&nwalIpParam.remIpAddr,ip_rem_addr, sizeof(nwalIpAddr_t));
+            }
+        }
+        else
+        {
+            if(memcmp(ip_rem_addr, zeroIP6, sizeof(nwalIpv6Addr_t)))
+            {
+                nwalIpParam.validParams |= NWAL_SET_IP_VALID_PARAM_REMOTE_IP;
+                memcpy(&nwalIpParam.remIpAddr,ip_rem_addr, sizeof(nwalIpAddr_t));
+            }
+        }
+    }
     nwalIpParam.ipType=ipType;
     if(route)
     {
-        netcp_cfgp_build_route(route,&nwalIpParam.appRxPktFlowId, &nwalIpParam.appRxPktQueue);
+        if((route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
+            NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
+        {
+           nwalIpParam.validParams |= 
+                    NWAL_SET_IP_VALID_PARAM_ROUTE_TYPE;
+        }
+        netapip_netcpCfgBuildRoute(route,
+                                   &nwalIpParam.appRxPktFlowId,
+                                   &nwalIpParam.appRxPktQueue,
+                                   &nwalIpParam.routeType);
     }
     else{} //use nwal defaults
 
@@ -897,7 +1115,7 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
 
     //build the rule id that will be returned when a packet matches 
     if (flag)
-        ip_rule_id = NETAPI_NETCP_MATCH_GENERIC_IP | iface_no | ((ip_slot&&0xff)<<8);
+        ip_rule_id = NETAPI_NETCP_MATCH_GENERIC_IP | iface_no | ((ip_slot&& NETAPI_NETCP_MATCH_ID_MASK) << NETAPI_NETCP_MATCH_ID_SHIFT);
     else
         ip_rule_id = (NETAPI_NETCP_MATCH_CLASS_L3 | iface_no);
 
@@ -911,13 +1129,13 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
     if(retValue !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-        printf (">netcp cfg: nwal_setIP returned Error Code %d\n",
+        netapi_Log ("netcp_cfg: nwal_setIP returned Error Code %d\n",
                     retValue);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         //zap the entry
         if (flag)
         {
-            netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context,
+            netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,
                          iface_no,
                          ip_slot);
         }
@@ -937,22 +1155,27 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *err = NETAPI_ERR_PA_FW;
-            printf (">netcp_cfgAddIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
+            netapi_Log ("netapip_netcpCfgAddIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
             return -1;
         }
     }
     if (flag)
     {
-        printf (">netcp cfg: IP added to interface %d (slot%d)\n", iface_no, ip_slot);
-        netcp_cfgp_insert_ip(&netapi_get_global()->nwal_context, ipType, 
-                          ip_addr, ip_qualifiers, iface_no, ip_slot,
-                          pTransInfo->handle);
+        netapi_Log ("netcp_cfg: IP added to interface %d (slot%d)\n", iface_no, ip_slot);
+        netapip_netcpCfgInsertIp(&netapi_get_global()->nwal_context,
+                                 ipType, 
+                                 ip_addr,
+                                 ip_qualifiers,
+                                 iface_no,
+                                 ip_slot,
+                                 pTransInfo->handle,
+                                 user_data);
     }
 
     temp = (NETCP_CFG_IP_T) pTransInfo->handle;
-    netapip_FreeTransInfo(pTransInfo);
+    netapip_freeTransInfo(pTransInfo);
     return  (flag ? ip_rule_id:  temp);
 }
 
@@ -961,46 +1184,56 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
  ********************************************************************
  * DESCRIPTION:  API to Add IP to MAC interface
  ********************************************************************/
-NETCP_CFG_IP_T  netcp_cfgAddIp(
-                  NETAPI_T  h,
-                  int  iface_no,
-                  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers,
-                  NETCP_CFG_ROUTE_HANDLE_T  route,  //NULL for default
-                  int * err
-                  )
+NETCP_CFG_IP_T  netapi_netcpCfgAddIp(NETAPI_T                  h,
+                                     int                       iface_no,
+                                     nwal_IpType               ipType,
+                                     nwalIpAddr_t*             ip_addr,
+                                     nwalIpAddr_t*             ip_rem_addr,
+                                     nwalIpOpt_t*              ip_qualifiers,
+                                     NETCP_CFG_ROUTE_HANDLE_T  route,  //NULL for default
+                                     void*                     user_data,
+                                     int*                      err)
 {
-    return netcp_cfgAddIpInternal(h, iface_no, ipType, ip_addr, 
-                                                        ip_qualifiers, route, err, 1);
+    return netapip_netcpCfgAddIpInternal(h,
+                                         iface_no,
+                                         ipType,
+                                         ip_addr,
+                                         ip_rem_addr,
+                                         ip_qualifiers, 
+                                         route, 
+                                         user_data,
+                                         err,
+                                         1);
 }
 
+
 /********************************************************************
  * FUNCTION PURPOSE:  NETAPI internal function to detach IP from MAC interface
  ********************************************************************
  * DESCRIPTION:  NETAPI internal function to detach IP from MAC interface
  ********************************************************************/
-static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers, 
-                  NETCP_CFG_IP_T  ip_rule_id,
-                  int *err, 
-                  void * handle,   /* if flag==0, handle must be valid */
-                  int flag)        /* flag==0 => delete IP rule that was part of classifier, not interface */
+static void netapip_netcpCfgDelIpInternal(NETAPI_T h, 
+                                          int iface_no,
+                                          nwal_IpType ipType,
+                                          nwalIpAddr_t  * ip_addr,
+                                          nwalIpOpt_t * ip_qualifiers, 
+                                          NETCP_CFG_IP_T  ip_rule_id,
+                                          int *err, 
+                                          void * handle,   /* if flag==0, handle must be valid */
+                                          int flag)        /* flag==0 => delete IP rule that was part of classifier, not interface */
 {
     nwal_RetValue ret;
     NetapiNwalTransInfo_t *pTransInfo;
     nwal_TransID_t     trans_id;
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * ifHandle;
-    int ip_slot = (ip_rule_id>>8)&0xff;
-
-    //get the nwal handle assoicated with this ip   
+    int ip_slot = netapi_cfgGetMatchId(ip_rule_id);
+    /* get the nwal handle assoicated with this ip */
     if (flag)
     {
-        ifHandle = netcp_cfgp_get_ip_handle(
-                                        &netapi_get_global()->nwal_context, iface_no,
-                                        ip_slot );
+        ifHandle = netapip_netcpCfgGetIpHandle(&netapi_get_global()->nwal_context,
+                                                iface_no,
+                                                ip_slot);
     }
     else 
     {
@@ -1014,7 +1247,9 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType
     *err =0;
 
     //get a transaction id
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo(n,
+                                          (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+                                          &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY;
@@ -1032,9 +1267,9 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType
     if(ret !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-        printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+        netapi_Log ("netcp_cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
                     ret);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         return ;
     }
     //wait here until its done since scheduler isn't running yet most likely..
@@ -1051,22 +1286,18 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *err = NETAPI_ERR_PA_FW;
-            printf (">netcp_cfgDelIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
+            netapi_Log ("netapip_netcpCfgDelIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
             return;
         }
     }
-    if (flag)
-        printf (">netcp cfg: attached IP deleted\n");
-    else
-        printf (">netcp cfg: Classifier IP rule deleted\n");
 
-    netapip_FreeTransInfo(pTransInfo);
+    netapip_freeTransInfo(pTransInfo);
 
     //zap the entry
     if (flag)
-        netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context,  
+        netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,  
                          iface_no,
                          ip_slot);
     return ;
@@ -1077,13 +1308,15 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType
  ********************************************************************
  * DESCRIPTION:  API  to detach IP from MAC interface
  ********************************************************************/
-void netcp_cfgDelIp(NETAPI_T h, int iface_no,  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers,
-                  NETCP_CFG_IP_T  ip_rule_id,
-                  int *err)
+void netapi_netcpCfgDelIp(NETAPI_T              h,
+                          int                   iface_no,
+                          nwal_IpType           ipType,
+                          nwalIpAddr_t*         ip_addr,
+                          nwalIpOpt_t*          ip_qualifiers,
+                          NETCP_CFG_IP_T        ip_rule_id,
+                          int*                  err)
 {
-    netcp_cfgDelIpInternal( h, iface_no, ipType,
+    netapip_netcpCfgDelIpInternal( h, iface_no, ipType,
                   ip_addr, ip_qualifiers, ip_rule_id,
                   err, NULL, 1);
     return;
@@ -1095,10 +1328,12 @@ void netcp_cfgDelIp(NETAPI_T h, int iface_no,  nwal_IpType ipType,
  ********************************************************************
  * DESCRIPTION:  API to attach a classifier rule to NETCP
  ********************************************************************/
-NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
-                                      NETCP_CFG_CLASSIFIER_T *p_class,
-                                      NETCP_CFG_ROUTE_HANDLE_T route,
-                                      int action, int * err)
+NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T                  h,
+                                          NETCP_CFG_CLASSIFIER_T*   p_class,
+                                          NETCP_CFG_ROUTE_HANDLE_T  route,
+                                          int                       action, 
+                                          void*                     user_data, 
+                                          int*                      err)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * l3_handle=NULL;  //ip handle
@@ -1113,13 +1348,17 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
     nwalRxConnCfg_t tempCfg=
     {
         0,  //nwal_handle: to be filled in
-        {0}, // l4 ports: to be filled in
+        0, // l4 ports: to be filled in
         0,  //core id (NA)
         0, //action
         CPPI_PARAM_NOT_SPECIFIED, //flow id
         QMSS_PARAM_NOT_SPECIFIED, //dest queue
+        0,
+        0, // l4 ports: to be filled in
     };
 
+    *err = NETAPI_ERR_OK;
+
     if(!p_class)
     {
         *err=NETAPI_ERR_BAD_INPUT;
@@ -1128,15 +1367,16 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
     switch(p_class->classType)
     {
         default:
-            printf(">netcp_cfg : classifier type %d not supported\n",p_class->classType);
+            netapi_Log(">netapi_netcpCfg : classifier type %d not supported\n",p_class->classType);
             break;
         case(NETCP_CFG_CLASS_TYPE_L3_L4):
+            n->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
         case(NETCP_CFG_CLASS_TYPE_L4):
             //assume just type l4 only (L2, L3 defined by iface, l3 id )
             iface_no = p_class->u.c_l4.iface;
             if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
             {
-                ip_slot = (p_class->u.c_l4.ip>>8)&0xff;
+                ip_slot = netapi_cfgGetMatchId(p_class->u.c_l4.ip);
             }
 
             //verify that iface has been configured 
@@ -1145,6 +1385,8 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
                 if(!netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
                 {
                     *err = NETAPI_ERR_BAD_INPUT;
+                    if(p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4)
+                        n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
                     return -1;
                 }
             }
@@ -1152,7 +1394,7 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
             if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
             {
                 //verify that ip has been configured and get its handle
-                l3_handle = netcp_cfgp_get_ip_handle(
+                l3_handle = netapip_netcpCfgGetIpHandle(
                       &netapi_get_global()->nwal_context, iface_no,
                       ip_slot );
             }
@@ -1160,13 +1402,16 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
             {
                 nwalIpParam_t tempParam=
                 {
+                    0,
                     pa_IPV4,      /* IP Type */
                     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Dest IP */
+                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Source IP */
                     { 0x0,0,0,0},/* IP Options */
                     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 */
-                    QMSS_PARAM_NOT_SPECIFIED                     /* Use default queue configured to NWAL if packet is routed to host */
+                    QMSS_PARAM_NOT_SPECIFIED,                    /* Use default queue configured to NWAL if packet is routed to host */
+                    0
                 };
                 //build nwalIpParam
                 memcpy(&tempParam.locIpAddr,p_class->u.c_l3_l4.ip_addr, sizeof(nwalIpAddr_t));
@@ -1180,21 +1425,23 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
                 //find if we have a matching L3 handle for IP classifier; if not create it
                 retValue =  nwal_getIPAddr (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
                             &tempParam,
-                            netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context, iface_no ),
+                            netapip_netcpCfgGetMacHandle(&netapi_get_global()->nwal_context, iface_no ),
                             &l3_handle); 
                 if (retValue != nwal_TRUE) 
                 {
                     int ret;
                     //**NEW IP RULE  
                     //need to attach this IP RULE to the MAC
-                    l3_handle= (void *) netcp_cfgAddIpInternal(
+                    l3_handle= (void *) netapip_netcpCfgAddIpInternal(
                                       h, iface_no, 
                                       p_class->u.c_l3_l4.ipType,
                                       p_class->u.c_l3_l4.ip_addr,
+                                      NULL,
                                       p_class->u.c_l3_l4.ip_qualifiers,
                                       p_class->u.c_l3_l4.p_fail_route,
+                                      user_data,
                                       &ret,
-                                      FALSE);
+                                      NETAPI_FALSE);
                     if(!ret)
                     {
                         l3_handle=NULL;
@@ -1204,14 +1451,24 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
             if(!l3_handle)
             {
                 *err = NETAPI_ERR_BAD_INPUT; 
+                if(p_class->classType == NETCP_CFG_CLASS_TYPE_L3_L4)
+                        n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
                 return -1 ;
             }
 
-
             //find free slot for CLASS & reserve
-            class_slot= netcp_cfgp_find_class_slot(&netapi_get_global()->nwal_context);
-            if(class_slot<0) {*err = NETAPI_ERR_NOMEM; return -1;}
-            classHandle = NETAPI_NETCP_MATCH_CLASS | (class_slot<<8) | (iface_no&0xff);
+            class_slot= netapip_netcpCfgFindClassSlot(n,
+                                                      &netapi_get_global()->nwal_context);
+            if(class_slot<0) 
+            {
+                *err = NETAPI_ERR_NOMEM;
+                if(p_class->classType == NETCP_CFG_CLASS_TYPE_L3_L4)
+                        n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
+                return -1;
+                }
+            classHandle = NETAPI_NETCP_MATCH_CLASS |
+                          (class_slot << NETAPI_NETCP_MATCH_ID_SHIFT) | 
+                          (iface_no & NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK);
             //build request from template
             tempCfg.inHandle=l3_handle;
             if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
@@ -1228,15 +1485,28 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
             tempCfg.matchAction = (action==NETCP_CFG_ACTION_TO_SW)  ? NWAL_MATCH_ACTION_HOST : NWAL_MATCH_ACTION_DISCARD;
             if (route)
             {
-                netcp_cfgp_build_route(route,&tempCfg.appRxPktFlowId, &tempCfg.appRxPktQueue);
+                if((route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
+                    NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
+                {
+                    tempCfg.validParams |= 
+                        NWAL_SET_CONN_VALID_PARAM_ROUTE_TYPE;
+                }
+                netapip_netcpCfgBuildRoute(route,
+                                           &tempCfg.appRxPktFlowId,
+                                           &tempCfg.appRxPktQueue,
+                                           &tempCfg.routeType);
             }
 
 
             //get a transaction id
-            pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+            pTransInfo = netapip_getFreeTransInfo(n,
+                                                  (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+                                                  &trans_id);
             if (!pTransInfo)
             {
-                *err =  NETAPI_ERR_BUSY; 
+                *err =  NETAPI_ERR_BUSY;
+                if(p_class->classType == NETCP_CFG_CLASS_TYPE_L3_L4)
+                    n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
                 return -1;
             }
             pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_PORT;
@@ -1254,10 +1524,12 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
             if(retValue !=  nwal_OK)
             {
                 *err = NETAPI_ERR_NWAL_ERR0;
-                printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+                netapi_Log ("netcp_cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
                         retValue);
-                netapip_FreeTransInfo(pTransInfo);
-                netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot);
+                netapip_freeTransInfo(pTransInfo);
+                netapip_netcpCfgDeleteClass(&netapi_get_global()->nwal_context, class_slot);
+                if(p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4)
+                    n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
                 return -1;
             }
             //wait here until its done since scheduler isn't running yet most likely..
@@ -1274,22 +1546,27 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
                 }
                 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
                 {
-                    netapip_FreeTransInfo(pTransInfo);
+                    netapip_freeTransInfo(pTransInfo);
                     *err = NETAPI_ERR_PA_FW;
-                    netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot);
-                    printf (">netcp_cfgAddClass - ERROR returned by NETCP PA firmware %d\n", *err);
+                    netapip_netcpCfgDeleteClass(&netapi_get_global()->nwal_context, class_slot);
+                    netapi_Log (">netcp_cfgAddClass - ERROR returned by NETCP PA firmware %d\n", *err);
+                    if(p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4)
+                        n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
                     return -1;
                 }
             }
-            printf (">netcp cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface_no, ip_slot, class_slot);
-            netcp_cfgp_insert_class(&netapi_get_global()->nwal_context, 
+            netapi_Log ("netcp_cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface_no, ip_slot, class_slot);
+            netapip_netcpCfgInsertClass(&netapi_get_global()->nwal_context, 
                                    class_slot,
                                  p_class->classType, 
                                 NULL,  //L2 we have
                                 (p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4? l3_handle : NULL),
-                                  pTransInfo->handle);
+                                  pTransInfo->handle,
+                                  user_data);
 
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
+            if(p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4)
+                n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
             return classHandle;
     } //end switch
 
@@ -1301,37 +1578,45 @@ return -1;
  ********************************************************************
  * DESCRIPTION:  API to delete a preconfigured classifier
  ********************************************************************/
-void netcp_cfgDelClass(NETAPI_T h,
-                         NETCP_CFG_CLASS_T classId,
-                         int *err)
+void netapi_netcpCfgDelClass(NETAPI_T           h,
+                             NETCP_CFG_CLASS_T  classId,
+                             int*               err)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
-    void * L4_handle;  //class handle -> L4
-    void * L3_handle;  //class handle -> L3
+    void *L4_handle = NULL;  //class handle -> L4
+    void *L3_handle = NULL;  //class handle -> L3
     nwal_RetValue       retValue;
     NetapiNwalTransInfo_t *pTransInfo;
     nwal_TransID_t     trans_id;
     int class_slot=-1;
 
-    class_slot = (classId>>8)&0xffff;
-    L4_handle=netcp_cfgp_get_l4_handle(&netapi_get_global()->nwal_context, class_slot);
+    class_slot = netapi_cfgGetMatchId(classId);
+    L4_handle=netapip_netcpCfgGetL4Handle(&netapi_get_global()->nwal_context, class_slot);
     if(!L4_handle)
     {
         *err = NETAPI_ERR_BAD_INPUT; 
-        return ;
+        goto ERR_netapi_netcpCfgDelClass;
     }
-    L3_handle = netcp_cfgp_get_l3_handle( &netapi_get_global()->nwal_context, class_slot );
-    /* l3 handle might be NULL,, depending on type of classifier */
+    L3_handle = netapip_netcpCfgGetL3Handle( &netapi_get_global()->nwal_context,
+                                            class_slot);
+    /* l3 handle might be NULL, depending on type of classifier */
 
-    netcp_cfgp_delete_class(
+    if(L3_handle)
+    {
+        // grab l3 lock
+        n->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
+    }
+    netapip_netcpCfgDeleteClass(
                         &netapi_get_global()->nwal_context,
                         class_slot );
     //get a transaction id
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo(n,
+                                          (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+                                          &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY; 
-        return -1;
+        goto ERR_netapi_netcpCfgDelClass;
     }
     pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_PORT;
     pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
@@ -1339,14 +1624,14 @@ void netcp_cfgDelClass(NETAPI_T h,
     pTransInfo->netapi_handle = h;
     //issue request for L4
     retValue = nwal_delConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
-                                                  trans_id,
-                                                L4_handle);
+                                                 trans_id,
+                                                 L4_handle);
     if(retValue !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-         printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n", retValue);
-         netapip_FreeTransInfo(pTransInfo);
-         return ;  /* todo: what about the L3? */
+         netapi_Log ("netcp_cfg - ERROR: nwal_delMacIface returned Error Code %d\n", retValue);
+         netapip_freeTransInfo(pTransInfo);
+         goto ERR_netapi_netcpCfgDelClass;  /* todo: what about the L3? */
     }
     //wait here until its done since scheduler isn't running yet most likely..
     // todo:  make this handled by scheduler poll later ??
@@ -1363,24 +1648,35 @@ void netcp_cfgDelClass(NETAPI_T h,
     }
     if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
     {
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         *err = NETAPI_ERR_PA_FW;
-         printf (">netcp_cfgDelClass - ERROR returned by NETCP PA firmware %d\n", *err);
-         return -1;
+         netapi_Log (">netapi_netcpCfgDelClass - ERROR returned by NETCP PA firmware %d\n", *err);
+         goto ERR_netapi_netcpCfgDelClass;
     }
-    printf (">netcp cfg: Classifer deleted\n");
+    netapi_Log ("netcp_cfg: Classifer deleted\n");
     pTransInfo->state =  NETAPI_NWAL_HANDLE_STATE_IDLE;
     pTransInfo->inUse = nwal_FALSE;
 
     /* delete L3 if we have to */
-    if (L3_handle)
+    if (cfgOkToDeleteL3ClassiHandle(h, L3_handle))
     {
-        netcp_cfgDelIpInternal( h, 0, 0,
-                  NULL, NULL, 0,
-                  err, L3_handle,  0);
+        netapip_netcpCfgDelIpInternal(h,
+                                      0,
+                                      0,
+                                      NULL,
+                                      NULL,
+                                      0,
+                                      err,
+                                      L3_handle,
+                                      0);
     }
-    netapip_FreeTransInfo(pTransInfo);
-    return ;
+    netapip_freeTransInfo(pTransInfo);
+
+ERR_netapi_netcpCfgDelClass:
+    if(L3_handle)
+        n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
+
+    return;
 }
 
 /********************************************************************
@@ -1390,12 +1686,12 @@ void netcp_cfgDelClass(NETAPI_T h,
  ********************************************************************/
 /*--------------flow management--------*/
 // ADD A Flow
-NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
-                                            int n,
-                                            Pktlib_HeapHandle handles[],
-                                            int sizes[],
-                                            int byte_offset,
-                                            int * err )
+NETCP_CFG_FLOW_HANDLE_T netapi_netcpCfgAddFlow(NETAPI_T                 h,
+                                               int                      n,
+                                               Pktlib_HeapHandle        handles[],
+                                               int                      sizes[],
+                                               NETCP_CFG_FLOW_CONFIG_T* p_cfg,
+                                               int*                     err )
 {
     Cppi_RxFlowCfg  rxFlowCfg;
     Uint8           isAlloc;
@@ -1405,10 +1701,17 @@ NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
     Cppi_FlowHnd FlowHnd;
     int  slot;
     NETCP_CFG_FLOW_HANDLE_T retVal;
-
+    NETAPI_HANDLE_T * pHandle = (NETAPI_HANDLE_T *) h;
     *err= 0;  /* ok */
+    if (!p_cfg)
+    {
+        *err= NETAPI_ERR_BAD_INPUT;
+        return NULL;
+    }
     //get a slot to save new flow
-    slot = netcp_cfgp_find_flow_slot(&netapi_get_global()->nwal_context);
+    slot = netapip_netcpCfgFindFlowSlot(pHandle,
+                                        &netapi_get_global()->nwal_context);
+
     if (slot<0) { *err= NETAPI_ERR_NOMEM;  return NULL; }
 
     //configure flow
@@ -1435,13 +1738,13 @@ NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
     }
 
     /* Configure Rx flow */
-    rxFlowCfg.flowIdNum      = CPPI_PARAM_NOT_SPECIFIED;
-    rxFlowCfg.rx_dest_qnum   = 100;   //DANGEROUS>  TODO PUT VALID Q HERE
-    rxFlowCfg.rx_dest_qmgr   = 0;
-    rxFlowCfg.rx_sop_offset  = byte_offset;
+    rxFlowCfg.flowIdNum      = p_cfg->flow_index;/*CPPI_PARAM_NOT_SPECIFIED*/;
+    rxFlowCfg.rx_dest_qnum   = netapi_pktioGetQ(p_cfg->p_dest_q);
+    rxFlowCfg.rx_dest_qmgr   = Qmss_getQueueNumber(rxFlowCfg.rx_dest_qnum).qMgr; 
+    rxFlowCfg.rx_sop_offset  = p_cfg->recv_offset;
     rxFlowCfg.rx_ps_location = Cppi_PSLoc_PS_IN_DESC;
     rxFlowCfg.rx_desc_type   = Cppi_DescType_HOST;
-    rxFlowCfg.rx_error_handling = 0;
+    rxFlowCfg.rx_error_handling = p_cfg->block;
 
     rxFlowCfg.rx_psinfo_present = 1;
     rxFlowCfg.rx_einfo_present  = 1;
@@ -1455,51 +1758,63 @@ NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
     rxFlowCfg.rx_size_thresh1_en = rxBufSize[2] ? 1 : 0;
     rxFlowCfg.rx_size_thresh2_en = rxBufSize[3] ? 1 : 0;
 
-    rxFlowCfg.rx_dest_tag_lo_sel = 0;
+  if (p_cfg->dma_index==NETAPI_DMA_NETCP )
+    rxFlowCfg.rx_dest_tag_lo_sel =0;
+  else
+    rxFlowCfg.rx_dest_tag_lo_sel = 0x4;
     rxFlowCfg.rx_dest_tag_hi_sel = 0;
     rxFlowCfg.rx_src_tag_lo_sel  = 0;
     rxFlowCfg.rx_src_tag_hi_sel  = 0;
 
     rxFlowCfg.rx_fdq1_qnum = rxBufQ[1];
-    rxFlowCfg.rx_fdq1_qmgr = 0;
+    rxFlowCfg.rx_fdq1_qmgr = (rxBufQ[1] ? Qmss_getQueueNumber(rxBufQ[1]).qMgr: 0);
     rxFlowCfg.rx_fdq2_qnum = rxBufQ[2];
-
-    rxFlowCfg.rx_fdq2_qmgr = 0;
+    rxFlowCfg.rx_fdq2_qmgr = (rxBufQ[2] ? Qmss_getQueueNumber(rxBufQ[2]).qMgr: 0);
     rxFlowCfg.rx_fdq3_qnum = rxBufQ[3];
-
-    rxFlowCfg.rx_fdq3_qmgr = 0;
+    rxFlowCfg.rx_fdq3_qmgr = (rxBufQ[3] ? Qmss_getQueueNumber(rxBufQ[3]).qMgr: 0);
 
     rxFlowCfg.rx_size_thresh0 = rxBufSize[1] ? rxBufSize[0] : 0;
     rxFlowCfg.rx_size_thresh1 = rxBufSize[2] ? rxBufSize[1] : 0;
     rxFlowCfg.rx_size_thresh2 = rxBufSize[3] ? rxBufSize[2] : 0;
 
     rxFlowCfg.rx_fdq0_sz0_qnum = rxBufQ[0];
-    rxFlowCfg.rx_fdq0_sz0_qmgr = 0;
+    rxFlowCfg.rx_fdq0_sz0_qmgr =  (rxBufQ[0] ? Qmss_getQueueNumber(rxBufQ[0]).qMgr: 0);
     rxFlowCfg.rx_fdq0_sz1_qnum = rxBufQ[1];
-    rxFlowCfg.rx_fdq0_sz1_qmgr = 0;
+    rxFlowCfg.rx_fdq0_sz1_qmgr =  (rxBufQ[1] ? Qmss_getQueueNumber(rxBufQ[1]).qMgr:0);
     rxFlowCfg.rx_fdq0_sz2_qnum = rxBufQ[2];
-    rxFlowCfg.rx_fdq0_sz2_qmgr = 0;
+    rxFlowCfg.rx_fdq0_sz2_qmgr =  (rxBufQ[2] ? Qmss_getQueueNumber(rxBufQ[2]).qMgr:0);
     rxFlowCfg.rx_fdq0_sz3_qnum = rxBufQ[3];
-    rxFlowCfg.rx_fdq0_sz3_qmgr = 0;
-
+    rxFlowCfg.rx_fdq0_sz3_qmgr =  (rxBufQ[3] ? Qmss_getQueueNumber(rxBufQ[3]).qMgr:0);
     {
         //todo: replace this with a nwal call to get global cntx info
         Cppi_CpDmaInitCfg cpdmaCfg;
+        Cppi_Handle cppiHnd;
         memset(&cpdmaCfg,0,sizeof(Cppi_CpDmaInitCfg));
-        cpdmaCfg.dmaNum   = Cppi_CpDma_PASS_CPDMA;
-        FlowHnd = Cppi_configureRxFlow (Cppi_open (&cpdmaCfg), &rxFlowCfg, &isAlloc);
+        cpdmaCfg.dmaNum   = (p_cfg->dma_index==NETAPI_DMA_NETCP ) ?Cppi_CpDma_PASS_CPDMA: Cppi_CpDma_QMSS_CPDMA;
+        cppiHnd= Cppi_open (&cpdmaCfg);
+        if (cppiHnd == NULL)
+        {
+              netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context, slot);
+              *err= NETAPI_ERR_NORES;
+              return NULL;
+        }
+        FlowHnd = Cppi_configureRxFlow (cppiHnd, &rxFlowCfg, &isAlloc);
     }
     if (FlowHnd == NULL)
     {
         *err= NETAPI_ERR_NORES;
-        netcp_cfgp_delete_flow(&netapi_get_global()->nwal_context, slot);
+        netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context, slot);
         return (NULL);
     }
 
     //update slot
-    retVal = netcp_cfgp_insert_flow(&netapi_get_global()->nwal_context, slot, (void*) FlowHnd);
-    printf(">netcp cfg:  flow %d created\n",  ((NETCP_CFG_FLOW_T *) retVal)->flowid);
-    return ( retVal);
+    retVal = netapip_netcpCfgInsertFlow(&netapi_get_global()->nwal_context,
+                                        slot,
+                                        p_cfg->dma_index,
+                                        (void*) FlowHnd);
+    netapi_Log(">netcp cfg:  flow %d created in dma index %d\n",
+        ((NETCP_CFG_FLOW_T *) retVal)->flowid, p_cfg->dma_index);
+    return (retVal);
 }
 
 /********************************************************************
@@ -1507,22 +1822,30 @@ NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
  ********************************************************************
  * DESCRIPTION:  API to delete a flow
  ********************************************************************/
-void netcp_cfgDelFlow(NETAPI_T h , NETCP_CFG_FLOW_HANDLE_T f , int * err)
+void netapi_netcpCfgDelFlow(NETAPI_T                h,
+                            NETCP_CFG_FLOW_HANDLE_T f,
+                            int*                    err)
 {
     int slot;
     void * handle;
     *err=0;
+    NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     /* find entry */
-    slot = netcp_cfgp_find_flow(&netapi_get_global()->nwal_context, ((NETCP_CFG_FLOW_T *) f) ->flowid, &handle);
+        slot = netapip_netcpCfgFindFlow(n,
+                                        &netapi_get_global()->nwal_context,
+                                        ((NETCP_CFG_FLOW_T *) f) ->flowid,
+                                        ((NETCP_CFG_FLOW_T *) f) ->dma_engine,
+                                        &handle);
     if (slot<0)
     {
-        *err = NETAPI_ERR_BAD_INPUT; 
+        *err = NETAPI_ERR_BAD_INPUT;
         return;
     }
-
-    Cppi_closeRxFlow( (Cppi_FlowHnd) handle);
-    netcp_cfgp_delete_flow(&netapi_get_global()->nwal_context, slot);
-    printf(">netcp cfg:  flow %d deleted\n",  ((NETCP_CFG_FLOW_T *) f)->flowid);
+    if ((Cppi_closeRxFlow( (Cppi_FlowHnd) handle)) == 0)
+    {
+        netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context,
+                               slot);
+    }
     return;
 }
 
@@ -1531,10 +1854,10 @@ void netcp_cfgDelFlow(NETAPI_T h , NETCP_CFG_FLOW_HANDLE_T f , int * err)
  ******************************************************************************
  * DESCRIPTION:  API to configure NETCP with global rules for exception packet handling
  *****************************************************************************/
-NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
-                                    int exception_id ,
-                                    nwal_matchAction_t action,
-                                    NETCP_CFG_ROUTE_HANDLE_T p_route)
+NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T                    h,
+                                                    int                         exception_id,
+                                                    nwal_matchAction_t          action,
+                                                    NETCP_CFG_ROUTE_HANDLE_T    p_route)
 {
     nwalCtlInfo_t   ctrl;
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
@@ -1543,7 +1866,17 @@ NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
 
     if (p_route != NULL)
     {
-        netcp_cfgp_build_route(p_route, &ctrl.appRxPktFlowId,& ctrl.appRxPktQueue);
+        if((p_route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
+            NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
+        {
+           ctrl.validParams |= 
+                    NWAL_CONTROL_VALID_PARAM_ROUTE_TYPE;
+           ctrl.routeType = p_route->routeType;
+        }
+        netapip_netcpCfgBuildRoute(p_route,
+                                   &ctrl.appRxPktFlowId,
+                                   &ctrl.appRxPktQueue,
+                                   &ctrl.routeType);
     }
     else
     {
@@ -1551,7 +1884,7 @@ NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
         ctrl.appRxPktQueue = NWAL_QUEUE_NOT_SPECIFIED;
     }
 
-    ctrl.appId =NETCP_CFG_MATCH_EXCEPTION | exception_id;
+    ctrl.appId = (void*)(NETAPI_NETCP_CFG_MATCH_EXCEPTION | exception_id);
 
     ctrl.matchAction = action;
 
@@ -1567,6 +1900,7 @@ NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
 
     retVal = nwal_control(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &ctrl);
 
+
     return (NETCP_CFG_EXCEPTION_PKT_T) ctrl.appId;
 }
 
@@ -1579,35 +1913,35 @@ NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
  ********************************************************************
  * DESCRIPTION:  NETAPI internal function, NETCP command reply callback
  ********************************************************************/
-void netapi_NWALCmdCallBack (nwal_AppId        appHandle,
-                          uint16_t            trans_id,
-                          nwal_RetValue     ret)
+void netapip_netcpCfgNWALCmdCallBack(nwal_AppId        appHandle,
+                            uint16_t            trans_id,
+                            nwal_RetValue     ret)
 {
     NetapiNwalTransInfo_t * p_trans;
     NETAPI_NWAL_LOCAL_CONTEXT_T *p_local=NULL;
 
     if(trans_id == NWAL_TRANSID_SPIN_WAIT)
     {
-        netapi_get_global()->nwal_context.numBogusTransIds++;
+        netapi_get_proc_global()->nwal_context.numBogusTransIds++;
         return;
     }
 
-    p_trans= &netapi_get_global()->nwal_context.transInfos[trans_id];
+    p_trans= &netapi_get_proc_global()->nwal_context.transInfos[trans_id];
     p_local =&((NETAPI_HANDLE_T*) (p_trans->netapi_handle))->nwal_local;
 
     if(ret != nwal_OK)
     {
-        printf (">netcp cfg : netapi_NWALCmdCallBack returned Error Code %d for trans_id %d\n",
+        netapi_Log ("netcp_cfg : netapip_netcpCfgNWALCmdCallBack returned Error Code %d for trans_id %d\n",
                     ret, trans_id);
         // update error code that is fialed  in p_trans */
         //todo: atomic inc
         p_trans->state = NETAPI_NWAL_HANDLE_STATE_ERR;
-        netapi_get_global()->nwal_context.numCmdFail++;
+        netapi_get_proc_global()->nwal_context.numCmdFail++;
     }
     else
     {
         //todo: atomic inc
-        netapi_get_global()->nwal_context.numCmdPass++;
+        netapi_get_proc_global()->nwal_context.numCmdPass++;
         switch(p_trans->transType)
         {
             case NETAPI_NWAL_HANDLE_TRANS_MAC:
@@ -1672,7 +2006,7 @@ void netapi_NWALCmdCallBack (nwal_AppId        appHandle,
             }
             default:
             {
-                printf ("netcp cfg> Invalid transaction type %d for trans_id: %d\n",
+                netapi_Log ("netcp cfg> Invalid transaction type %d for trans_id: %d\n",
                     p_trans->transType,trans_id);
                 break;
             }
@@ -1693,20 +2027,20 @@ void netapi_NWALCmdCallBack (nwal_AppId        appHandle,
  ********************************************************************
  * DESCRIPTION:  NETAPI internal function, PA stats reply callback
  ********************************************************************/
-void netapi_NWALCmdPaStatsReply (nwal_AppId        appHandle,
-                              nwal_TransID_t    trans_id,
-                              paSysStats_t      *stats)
+void netapip_netcpCfgNWALCmdPaStatsReply(nwal_AppId        appHandle,
+                                nwal_TransID_t    trans_id,
+                                paSysStats_t      *stats)
 {
     NetapiNwalTransInfo_t * p_trans;
     NETAPI_NWAL_LOCAL_CONTEXT_T *p_local=NULL;
 
     if(trans_id == NWAL_TRANSID_SPIN_WAIT)
     {
-        netapi_get_global()->nwal_context.numBogusTransIds++;
+        netapi_get_proc_global()->nwal_context.numBogusTransIds++;
         return;
     }
 
-    p_trans= &netapi_get_global()->nwal_context.transInfos[trans_id];
+    p_trans= &netapi_get_proc_global()->nwal_context.transInfos[trans_id];
     p_trans->inUse = nwal_FALSE;
     p_local =&((NETAPI_HANDLE_T*) (p_trans->netapi_handle))->nwal_local;