index 77003686fde0119873ded4b2d3952855df72f050..2b778c4a7dd407150d2dc5146a54bc8eb21daa96 100755 (executable)
* 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;
/******************************************************************
- ********************Utility*************************************
+ ********************Netapi internal*************************************
*******************************************************************/
-//get a free transaction id
-NetapiNwalTransInfo_t * netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwal_TransID_t *pTransId)
+/********************************************************************
+ * 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_HANDLE_T *p_handle,
+ NETAPI_PROC_GLOBAL_T *p_proc_global,
+ nwal_TransID_t *pTransId)
{
- uint16_t count=0;
+ uint16_t count=0;
- count=0;
- while(count < TUNE_NETAPI_MAX_NUM_TRANS)
+ count=0;
+ p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
+ while(count < TUNE_NETAPI_MAX_NUM_TRANS)
+ {
+ if((p_proc_global->nwal_context.transInfos[count].inUse) != nwal_TRUE)
{
- if((p_global->nwal_context.transInfos[count].inUse) != nwal_TRUE)
- {
- p_global->nwal_context.transInfos[count].inUse = nwal_TRUE;
- *pTransId = count;
- return(&p_global->nwal_context.transInfos[count]);
- }
- count++;
+ p_proc_global->nwal_context.transInfos[count].inUse = nwal_TRUE;
+ *pTransId = count;
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+ return(&p_proc_global->nwal_context.transInfos[count]);
}
-
- /* 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");
- return NULL;
+ count++;
+ }
+ 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*/
+ netapi_Log(">netcp_cfg: trying to get free transaction slot but all full!!\n");
+ return NULL;
+
+}
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to free a transaction id
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to free a transaction id
+ ********************************************************************/
+void netapip_freeTransInfo(NetapiNwalTransInfo_t *pTransInfo)
+{
+ pTransInfo->inUse = nwal_FALSE;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
+ pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_NONE;
}
-//internal: build route
-void netcp_cfgp_build_route(NETCP_CFG_ROUTE_T * p_route, int16_t * p_flow, Qmss_QueueHnd * p_q)
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to build a route
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to build a route
+ ********************************************************************/
+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;
}
-/*-----------------------------------------------------------*/
-/*----------------database management stuff-------------------*/
-/*-----------------------------------------------------------*/
-/*=====================Policies=============================*/
-//internal: find a free slot for an SA
-int netcp_cfgp_find_policy_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int tunnel)
+
+/******************************************************/
+/*----------------database management stuff */
+/******************************************************/
+
+/*=====================POLICIES=============================*/
+
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to find a free slot for an SA
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to find a free slot for an SA
+ ********************************************************************/
+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;
+ int i;
+ if ((tunnel <0 ) || (tunnel >=TUNE_NETAPI_MAX_SA))
+ return -1;
- //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
- return i;
- }
- }
- return -1;
+ 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
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+ return i;
+ }
+ }
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+ return -1;
}
-//internal: delete a policy from list
-void netcp_cfgp_delete_policy(
- NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
- int policy_slot )
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to delete a policy from policy list
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to delete a policy from policy list
+ ********************************************************************/
+void netapip_netcpCfgDeletePolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ int policy_slot)
{
- if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY))
- {
+ if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY))
+ {
return ;
- }
- p->policy[policy_slot].in_use=0;
- return;
+ }
+ p->policy[policy_slot].in_use=0;
+ return;
}
-//internal: insert an policy into the list
-void netcp_cfgp_insert_policy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
- int policy_slot, //we 'reserved it already'
- void * handle)
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to insert a policy to the policy list
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to insert a policy to the policy list
+ ********************************************************************/
+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;
- return;
+ p->policy[policy_slot].in_use=1;
+ p->policy[policy_slot].nwal_handle = handle;
+ p->policy[policy_slot].user_data = user_data;
+ return;
}
-//internal: return nwal_handle for policy
-void *netcp_cfgp_get_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
- int policy_slot)
+/************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function which returns NWAL handle for a policy
+ ************************************************************************
+ * DESCRIPTION: Netapi internal function which returns NWAL handle for a policy
+ ************************************************************************/
+void *netapip_netcpCfgGetPolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ int policy_slot)
{
- if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY)) return NULL;
- if (!p->policy[policy_slot].in_use) return NULL;
- return p->policy[policy_slot].nwal_handle;
+ if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY))
+ return NULL;
+ if (!p->policy[policy_slot].in_use)
+ return NULL;
+ return p->policy[policy_slot].nwal_handle;
}
-
-
-/*======================SAs==================================*/
-//internal: find a free slot for an SA
-int netcp_cfgp_find_sa_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface)
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to find a free slot in SA list for a SA
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to find a free slot in SA list for an SA
+ ********************************************************************/
+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_INTERFACES)) return -1;
+ if ((iface <0 ) || (iface >=TUNE_NETAPI_MAX_NUM_MAC)) return -1;
}
- //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
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
return i;
}
}
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
return -1;
}
- //internal: delete an SAr from list
-void netcp_cfgp_delete_sa(
- NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
- int sa_slot )
+
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to delete an SA from SA list
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to delete an SA from SA list
+ ********************************************************************/
+void netapip_netcpCfgDeleteSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ int sa_slot)
{
- if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
- {
+ if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
+ {
return ;
- }
- p->tunnel[sa_slot].in_use=0;
- return;
+ }
+ p->tunnel[sa_slot].in_use=0;
+ return;
}
-//internal: insert an SA into the 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)
+
+/****************************************************************************
+ * 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)
{
- 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;
+ 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);
}
-//internal: return nwal_handles for SA
-void *netcp_cfgp_get_sa_handles( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
- int sa_slot, void ** p_sideband)
+/****************************************************************************
+ * 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)
{
- if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA)) return NULL;
- if (!p->tunnel[sa_slot].in_use) return NULL;
- *p_sideband = p->tunnel[sa_slot].sa_handle_sideband;
- return p->tunnel[sa_slot].sa_handle_inflow;
+ 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 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;
+ 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;
+}
-/*==============================fLOWS=============================*/
-//internal: find a free slot for a flow
-static int netcp_cfgp_find_flow_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to return NWAL handles for an SA
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to return NWAL handles for an SA
+ ********************************************************************/
+ void *netapip_netcpCfgGetSaHandles(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ int sa_slot,
+ void ** p_sideband)
{
- int i;
- //find a free entry
- for(i=0;i<TUNE_NETAPI_MAX_FLOWS;i++)
- {
- if (!p->flows[i].in_use)
- {
- p->flows[i].in_use = 2; //pending
- return i;
- }
- }
- return -1;
+ if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
+ return NULL;
+ if (!p->tunnel[sa_slot].in_use)
+ return NULL;
+ *p_sideband = p->tunnel[sa_slot].sa_handle_sideband;
+ return p->tunnel[sa_slot].sa_handle_inflow;
}
-//internal: clear flow slot
-static void netcp_cfgp_delete_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int slot)
+
+/*==============================FLOWS=============================*/
+
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to find a free slot for a flow
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to find a free slot for a flow
+ ********************************************************************/
+static int netapip_netcpCfgFindFlowSlot(NETAPI_HANDLE_T *p_handle,
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
{
- if ((slot >=0 ) && (slot < TUNE_NETAPI_MAX_FLOWS))
- {
+ int i;
+ //find a free entry
+ 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 */
+ 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 delete a flow from flow list
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to find delete a flow from flow list
+ ********************************************************************/
+static void netapip_netcpCfgDeleteFlow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ int slot)
+{
+ if ((slot >=0 ) && (slot < TUNE_NETAPI_MAX_FLOWS))
+ {
p->flows[slot].in_use = 0;
- }
+ }
}
-//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
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to insert a flow to the flow list
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to delete a flow from flow list
+ ********************************************************************/
+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].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;
}
-//find entry matching the flowid. return slot# and the cppi handle
-static int netcp_cfgp_find_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
- int flowid,
- void ** handle)
+/********************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to find entry matching the flowid
+ ********************************************************************
+ * DESCRIPTION: Netapi internal function to find entry matching the flowid. Returns
+ * the slot number and the cPPI 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;
- for(i=0;i<TUNE_NETAPI_MAX_FLOWS;i++)
- {
- if ((p->flows[i].in_use)&&(p->flows[i].flow.flowid == flowid))
- {
- *handle = p->flows[i].handle;
- return i;
- }
- }
- return -1;
+ int i;
+ *handle=NULL;
+ 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)&&
+ (p->flows[i].flow.dma_engine == dma_engine))
+ {
+ *handle = p->flows[i].handle;
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+ return i;
+ }
+ }
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+ return -1;
}
+
/*============================IP ADDRESSES==========================*/
-//internal: find a free slot for IP rule
-static int netcp_cfgp_find_ip_slot(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
- int iface_no)
+/***************************************************************************
+ * 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 netapip_netcpCfgFindIpSlot(NETAPI_HANDLE_T *p_handle,
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ int iface_no)
{
- int i;
+ int i;
- //find a free entry
- for(i=0;i<TUNE_NETAPI_MAX_IP;i++)
- {
- if (!p->ips[i].in_use)
- {
- p->ips[i].in_use = 2; //pending
- return i;
- }
- }
- return -1;
+ //find a free entry
+ 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
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+ return i;
+ }
+ }
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+ return -1;
}
-
-//internal: insert an IP address into iface
-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)
+/***************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to insert an IP address into interface
+ ***************************************************************************
+ * DESCRIPTION: Netapi internal function to insert an IP address into interface
+ ***************************************************************************/
+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;
- memcpy(&p->ips[ip_slot].ip_addr, ip_addr, sizeof(nwalIpAddr_t));
- if(ip_qualifiers)
+ 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
+ }
+ 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;
- return;
+ }
+ p->ips[ip_slot].ip_type = ipType;
+ p->ips[ip_slot].nwal_handle = handle;
+ p->ips[ip_slot].user_data = user_data;
+ p->ips[ip_slot].ref_count++;
+
}
-
-//internal: 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 )
+/***************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to free IP slot associated with IP address
+ ***************************************************************************
+ * DESCRIPTION: Netapi internal function to free IP slot associated with IP address
+ ***************************************************************************/
+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_IP)) return ;
- p->ips[ip_slot].in_use=0;
- return;
+ if ((ip_slot >=0) &&(ip_slot <=TUNE_NETAPI_MAX_NUM_IP))
+ {
+ p->ips[ip_slot].in_use=0;
+ p->ips[ip_slot].ref_count = 0;
+ }
}
-
-//internal: 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 )
+/***************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to get IP handle associated with IP address
+ ***************************************************************************
+ * DESCRIPTION: Netapi internal function to get IP handle associated with IP address
+ ***************************************************************************/
+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_IP)) return NULL;
- if (!p->ips[ip_slot].in_use) return NULL;
- return (void *) p->ips[ip_slot].nwal_handle;
+ if ((ip_slot <0)||(ip_slot>=TUNE_NETAPI_MAX_NUM_IP))
+ return NULL;
+ if (!p->ips[ip_slot].in_use)
+ return NULL;
+ return (void *) p->ips[ip_slot].nwal_handle;
}
/*==========================MAC INTERFACES======================*/
-//internal: insert interface info into global context
-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)
+
+
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to insert an interface to the interface list
+ *******************************************************************************
+ * DESCRIPTION: Netapi internal function to insert an interface to the interface list
+ *******************************************************************************/
+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_INTERFACES))
- {
+ if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
+ {
memset(&p->interfaces[iface_no],0,sizeof(NETCP_INTERFACE_T));
p->interfaces[iface_no].in_use = 1;
memcpy(&p->interfaces[iface_no].mac[0], p_mac,6);
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
- }
- else printf(">netcp_cfg insert interface # out of range %d\n",iface_no);
+ netapi_Log("netapip_netcpCfgInsertMac, global context 0x%x\n", p);
+ }
+ else
+ netapi_Log(">netapip_netcpCfgInsertMac insert interface # out of range %d\n",iface_no);
}
-//internal: get handle associated with interface
-void* netcp_cfgp_get_mac_handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
+/*******************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to get handle associated with interface
+ *******************************************************************************
+ * DESCRIPTION: Netapi internal function to get handle associated with interface
+ *******************************************************************************/
+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_INTERFACES))
- {
- 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;
}
-//internal: clear inteface entry
-static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
+/*******************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to delete interface from interface list
+ *******************************************************************************
+ * DESCRIPTION: Netapi internal function to delete interface from interface list
+ *******************************************************************************/
+static void netapip_netcpCfgDeleteMac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ int iface_no)
{
- if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_INTERFACES))
- {
+ if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
+ {
p->interfaces[iface_no].in_use = 0;
- }
+ }
}
-
/*========================CLASSIFIERS==========================*/
-//internal: find a free slot for classifier rule
-static int netcp_cfgp_find_class_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to find a free slot for classifier rule
+ *******************************************************************************
+ * DESCRIPTION: Netapi internal function to find a free slot for classifier rule
+ *******************************************************************************/
+static int netapip_netcpCfgFindClassSlot(NETAPI_HANDLE_T *p_handle,
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
{
- int i;
- //find a free entry
- for(i=0;i<TUNE_NETAPI_MAX_CLASSIFIERS;i++)
- {
- if (!p->classi[i].in_use)
- {
- p->classi[i].in_use = 2; //pending
- return i;
- }
- }
- 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;
}
-
- //internal: delete a classifer from list
-static void netcp_cfgp_delete_class(
+/*******************************************************************************
+ * 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 netapip_netcpCfgDeleteClass(
NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
int class_slot )
{
- if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
- {
- return ;
- }
- p->classi[class_slot].in_use=0;
- return;
+ if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
+ {
+ return;
+ }
+ p->classi[class_slot].in_use=0;
}
-//internal: insert a classifier into 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)
+/*******************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to find a insert a classifer to classifer list
+ *******************************************************************************
+ * DESCRIPTION: Netapi internal function to find a insert a classifer to classifer list
+ *******************************************************************************/
+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)
{
+ 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;
- return;
+ p->classi[class_slot].class_type = class_type;
+ p->classi[class_slot].user_data = user_data;
+ }
}
-//internal: return L4 nwal_handle for class
-static void *netcp_cfgp_get_l4_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
- int class_slot)
+/*******************************************************************************
+ * FUNCTION PURPOSE: Netapi internal function to get L4 nwal handle for classifier
+ *******************************************************************************
+ * DESCRIPTION: Netapi internal function to get L4 nwal handle for classifier
+ *******************************************************************************/
+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;
- return p->classi[class_slot].nwal_L4_handle;
+ 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;
}
-//internal: return L3 nwal_handle for class
-static void *netcp_cfgp_get_l3_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
- int class_slot)
+/*******************************************************************************
+ * 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;
+ 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;
}
/***********************************************************************************/
-/*****************************************************************
- * Queury Stats
- ****************************************************************/
-void netcp_cfgReqStats(NETAPI_T h, NETCP_CFG_STATS_CB cb, int doClear, int *err)
+/********************************************************************
+ * FUNCTION PURPOSE: API to request statistics from NETCP
+ ********************************************************************
+ * DESCRIPTION: API to request statistics from NETCP
+ ********************************************************************/
+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;
-if ((!n) || (!cb)) {*err = NETAPI_ERR_BAD_INPUT; return ;}
-*err =0;
-
-
-pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->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;
-ret = nwal_getPAStats( ((NETAPI_GLOBAL_T *) n->global)->nwal_context.nwalInstHandle,
- transId,
- NULL,
- doClear);
-if(ret != nwal_OK)
-{
- pTransInfo->inUse = nwal_FALSE;
- *err = NETAPI_ERR_BUSY; //no resources??
- printf("> netcp_cfg reqStats failed, err=%d\n",ret);
-}
+ nwal_RetValue ret;
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
+ NetapiNwalTransInfo_t *pTransInfo;
+ nwal_TransID_t transId;
+ if ((!n) || (!cb))
+ {
+ *err = NETAPI_ERR_BAD_INPUT;
+ return ;
+ }
+ *err =0;
+ 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;
+ ret = nwal_getPAStats( ((NETAPI_GLOBAL_T *) n->global)->nwal_context.nwalInstHandle,
+ transId,
+ NULL,
+ doClear);
+ if(ret != nwal_OK)
+ {
+ //pTransInfo->inUse = nwal_FALSE;
+ *err = NETAPI_ERR_BUSY; //no resources??
+ netapi_Log("> netapi_netcpCfg reqStats failed, err=%d\n",ret);
+ }
+ netapip_freeTransInfo(pTransInfo);
}
-/*****************************************************************
- * 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
- )
+/********************************************************************
+ * FUNCTION PURPOSE: API to create a MAC interface
+ ********************************************************************
+ * DESCRIPTION: API to create a MAC interface
+ ********************************************************************/
+NETCP_CFG_MACIF_T netapi_netcpCfgCreateMacInterface(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)
{
-NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
-nwalMacParam_t MacInfo= {
- 0, /* validParams */
- 0, /* ifNum */
- 0, /* vlanId */
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Local 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 */
-};
-
-nwal_RetValue retValue;
-NetapiNwalTransInfo_t *pTransInfo;
-nwal_TransID_t trans_id;
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
+ 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 */
+ 0
+ };
+
+ nwal_RetValue retValue;
+ NetapiNwalTransInfo_t *pTransInfo;
+ nwal_TransID_t trans_id;
if ((!n) || (!p_mac)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}
*err =0;
- pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return -1;}
+ pTransInfo = netapip_getFreeTransInfo(n,
+ (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+ &trans_id);
+ if (!pTransInfo)
+ {
+ *err = NETAPI_ERR_BUSY;
+ return -1;
+ }
pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_MAC;
- pTransInfo->netapi_handle = h;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
+ pTransInfo->netapi_handle = h;
/* set up MacInfo */
- memcpy(&MacInfo.macAddr,p_mac,6);
+ memcpy(&macInfo.macAddr,p_mac,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 (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);
}
- pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
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",
+ *err = NETAPI_ERR_NWAL_ERR0;
+ netapi_Log ("netapi_netcpCfg - ERROR: nwal_setMacIface returned Error Code %d\n",
retValue);
- pTransInfo->inUse = nwal_FALSE;
+ netapip_freeTransInfo(pTransInfo);
return -1;
}
- //pTransInfo->inUse = nwal_FALSE;
//wait here until its done since scheduler isn't running yet most likely..
// todo: make this handled by scheduler poll later ??
if(trans_id != NWAL_TRANSID_SPIN_WAIT)
{
n->nwal_local.numPendingCfg++;
- while ((volatile) n->nwal_local.numPendingCfg)
+ while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
+ (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
{
- // if response is there, then this poll squirts out in the CTl poll callback,
+ // if response is there, then this poll squirts out in the CTl poll callback,
// which handles the rest (including decrmenting #pending!!
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
}
+ if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
+ {
+ netapip_freeTransInfo(pTransInfo);
+ *err = NETAPI_ERR_PA_FW;
+ 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);
- pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
- pTransInfo->inUse = nwal_FALSE;
+ netapip_freeTransInfo(pTransInfo);
return (NETAPI_NETCP_MATCH_GENERIC_MAC | iface_no);
}
-
-/*****************************************************************/
-/***************Delete a mac interface****************************/
-/*****************************************************************/
-void netcp_cfgDelMac(NETAPI_T h,int iface_no, int *err)
+/********************************************************************
+ * FUNCTION PURPOSE: API to delete MAC interface
+ ********************************************************************
+ * DESCRIPTION: API to delete MAC interface
+ ********************************************************************/
+void netapi_netcpCfgDelMac(NETAPI_T h,
+ int iface_no,
+ int *err)
{
nwal_RetValue ret;
NetapiNwalTransInfo_t *pTransInfo;
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);
- if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;}
+ pTransInfo = netapip_getFreeTransInfo(n,
+ (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+ &trans_id);
+ if (!pTransInfo)
+ {
+ *err = NETAPI_ERR_BUSY;
+ return ;
+ }
pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_MAC;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
pTransInfo->netapi_handle = h;
+
//issue request
ret = nwal_delMacIface(
((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
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);
- pTransInfo->inUse = nwal_FALSE;
- return ;
+ netapip_freeTransInfo(pTransInfo);
+ return;
}
//wait here until its done since scheduler isn't running yet most likely..
// todo: make this handled by scheduler poll later ??
if(trans_id != NWAL_TRANSID_SPIN_WAIT)
{
n->nwal_local.numPendingCfg++;
- while ((volatile) n->nwal_local.numPendingCfg)
+ while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
+ (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
{
// if response is there, then this poll squirts out in the CTl poll callback,
// which handles the rest (including decrmenting #pending!!
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
}
+ if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
+ {
+ netapip_freeTransInfo(pTransInfo);
+ *err = NETAPI_ERR_PA_FW;
+ netapi_Log (">netapi_netcpCfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
+ *err);
+ netapip_netcpCfgDeleteMac(&netapi_get_global()->nwal_context, iface_no);
+ return;
+ }
}
- printf (">netcp cfg: MAC i/f %d deleted\n",iface_no);
- pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
- pTransInfo->inUse = nwal_FALSE;
+ 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 ;
}
-/*****************************************************************/
-/***************Add IP to MAC interface (internal)****************/
-/*****************************************************************/
-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
+/********************************************************************
+ * FUNCTION PURPOSE: NETAPi internal function to Add IP to MAC interface
+ ********************************************************************
+ * DESCRIPTION: NETAPi internal function to Add IP to MAC interface
+ ********************************************************************/
+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 */
{
-NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
-void * n_handle=NULL;
-nwalIpParam_t nwalIpParam= {
+ static unsigned char zeroIP4[]={0,0,0,0};
+ 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;
-nwal_TransID_t trans_id;
-int ip_slot=-1;
-NETCP_CFG_IP_T ip_rule_id;
-NETCP_CFG_IP_T temp;
-
- //verify that iface has been configured
- if (iface_no != NETCP_CFG_NO_INTERFACE)
- {
- if ((iface_no<0) || (iface_no>= TUNE_NETAPI_MAX_INTERFACES)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}
- }
-
- if (iface_no != NETCP_CFG_NO_INTERFACE)
- {
- if(netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
- {
- n_handle = netapi_get_global()->nwal_context.interfaces[iface_no].nwal_handle;
- }
- else
- {
- *err = NETAPI_ERR_BAD_INPUT;
- return -1;
- }
- }
- 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);
- if (ip_slot <0)
- {
- *err= NETAPI_ERR_NOMEM; //no room
- return -1;
- }
- }
+ nwal_RetValue retValue;
+ NetapiNwalTransInfo_t *pTransInfo;
+ nwal_TransID_t trans_id;
+ int ip_slot=-1;
+ NETCP_CFG_IP_T ip_rule_id;
+ NETCP_CFG_IP_T temp;
+
+ //verify that iface has been configured
+ if (iface_no != NETCP_CFG_NO_INTERFACE)
+ {
+ if ((iface_no<0) || (iface_no>= TUNE_NETAPI_MAX_NUM_MAC)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}
+ }
- //get a transaction object for config action
- pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return -1;}
+ if (iface_no != NETCP_CFG_NO_INTERFACE)
+ {
+ 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;
+ }
+ else
+ {
+ *err = NETAPI_ERR_BAD_INPUT;
+ return -1;
+ }
+ }
+ if (flag) //if adding IP to MAC then reserve a slot to save info
+ {
+ //find free slot for IP & reserve
+ ip_slot= netapip_netcpCfgFindIpSlot(n,
+ &netapi_get_global()->nwal_context,
+ iface_no);
+ if (ip_slot <0)
+ {
+ *err= NETAPI_ERR_NOMEM; //no room
+ return -1;
+ }
+ }
+
+ //get a transaction object for config action
+ pTransInfo = netapip_getFreeTransInfo(n,
+ (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+ &trans_id);
+ if (!pTransInfo)
+ {
+ *err = NETAPI_ERR_BUSY;
+ if (flag)
+ {
+ netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,
+ iface_no,
+ ip_slot);
+ }
+ return -1;
+ }
pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
pTransInfo->netapi_handle = h;
- //build nwalIpParam
- memcpy(&nwalIpParam.locIpAddr,ip_addr, sizeof(nwalIpAddr_t));
- nwalIpParam.ipType=ipType;
- if(route)
- {
- netcp_cfgp_build_route(route,&nwalIpParam.appRxPktFlowId, &nwalIpParam.appRxPktQueue);
- }
- else{} //use nwal defaults
- if (ip_qualifiers)
- memcpy(&nwalIpParam.ipOpt,ip_qualifiers, sizeof(nwalIpOpt_t));
- else
+ //build nwalIpParam
+ memcpy(&nwalIpParam.locIpAddr,ip_addr, sizeof(nwalIpAddr_t));
+ if (ip_rem_addr)
+ {
+ if (ipType == nwal_IPV4)
+ {
+ if(memcmp(ip_rem_addr, zeroIP4, 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)
+ {
+ 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
+
+ if (ip_qualifiers)
+ memcpy(&nwalIpParam.ipOpt,ip_qualifiers, sizeof(nwalIpOpt_t));
+ else
memset(&nwalIpParam.ipOpt,0, sizeof(nwalIpOpt_t));
- //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);
- else
+ //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&& NETAPI_NETCP_MATCH_ID_MASK) << NETAPI_NETCP_MATCH_ID_SHIFT);
+ else
ip_rule_id = (NETAPI_NETCP_MATCH_CLASS_L3 | iface_no);
- //perform config action
- pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
- retValue = nwal_setIPAddr( netapi_get_global()->nwal_context.nwalInstHandle,
+ retValue = nwal_setIPAddr( netapi_get_global()->nwal_context.nwalInstHandle,
trans_id,
(nwal_AppId) (ip_rule_id),
n_handle,
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);
- pTransInfo->inUse = nwal_FALSE;
+ 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 -1;
}
//wait here until its done since scheduler isn't running yet most likely..
if(trans_id != NWAL_TRANSID_SPIN_WAIT)
{
n->nwal_local.numPendingCfg++;
- while ((volatile) n->nwal_local.numPendingCfg)
+ while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
+ (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
{
// if response is there, then this poll squirts out in the CTl poll callback,
// which handles the rest (including decrmenting #pending!!
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
}
+ if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
+ {
+ netapip_freeTransInfo(pTransInfo);
+ *err = NETAPI_ERR_PA_FW;
+ 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);
}
- pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
+
temp = (NETCP_CFG_IP_T) pTransInfo->handle;
- pTransInfo->inUse = nwal_FALSE;
+ netapip_freeTransInfo(pTransInfo);
return (flag ? ip_rule_id: temp);
}
-/*****************************************************************/
-/***************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
- )
+
+/********************************************************************
+ * FUNCTION PURPOSE: API to Add IP to MAC interface
+ ********************************************************************
+ * DESCRIPTION: API to Add IP to MAC interface
+ ********************************************************************/
+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);
}
+/***************************************************************************
+* DESCRIPTION:Netapi internal function to check reference count of IP
+***************************************************************************/
+static Bool netapip_netcpCfgCheckIpRefCount(NETAPI_HANDLE_T *p_handle,
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ int ip_slot)
+{
-/*****************************************************************/
-/***************Delete an attached IP*****************************/
-/*****************************************************************/
-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 */
+ if ((ip_slot >=0) &&(ip_slot <=TUNE_NETAPI_MAX_NUM_IP))
+ {
+ p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
+ /* IS IP is associated with alteast 2 rules, if yes, then dont delete IP */
+ if(p->ips[ip_slot].ref_count)
+ p->ips[ip_slot].ref_count--;
+ if (p->ips[ip_slot].ref_count)
+ {
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+ return FALSE;
+ }
+ else
+ {
+ p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
+ return TRUE;
+ }
+ }
+ else
+ return FALSE;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: NETAPI internal function to detach IP from MAC interface
+ ********************************************************************
+ * DESCRIPTION: NETAPI internal function to detach IP from MAC 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;
-
+ 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
{
- ifHandle = handle;
+ ifHandle = handle;
}
if(!ifHandle)
- {*err = NETAPI_ERR_BAD_INPUT; return ;}
+ {
+ *err = NETAPI_ERR_BAD_INPUT;
+ return ;
+ }
*err =0;
+ /* need to check to see if this IP is attached to a classifier(s)
+ and only delete if this is last classifier */
+ if (!netapip_netcpCfgCheckIpRefCount(n,
+ &netapi_get_global()->nwal_context,
+ ip_slot))
+ {
+ return;
+ }
+
//get a transaction id
- pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;}
+ pTransInfo = netapip_getFreeTransInfo(n,
+ (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+ &trans_id);
+ if (!pTransInfo)
+ {
+ *err = NETAPI_ERR_BUSY;
+ return;
+ }
pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
pTransInfo->netapi_handle = h;
//issue request
ret = nwal_delIPAddr(
@@ -809,472 +1250,651 @@ 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);
- pTransInfo->inUse = nwal_FALSE;
+ netapip_freeTransInfo(pTransInfo);
return ;
}
//wait here until its done since scheduler isn't running yet most likely..
// todo: make this handled by scheduler poll later ??
if(trans_id != NWAL_TRANSID_SPIN_WAIT)
{
- n->nwal_local.numPendingCfg++;
- while ((volatile) n->nwal_local.numPendingCfg)
+ n->nwal_local.numPendingCfg++;
+ while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
+ (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
{
// if response is there, then this poll squirts out in the CTl poll callback,
// which handles the rest (including decrmenting #pending!!
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
}
+ if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
+ {
+ netapip_freeTransInfo(pTransInfo);
+ *err = NETAPI_ERR_PA_FW;
+ 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");
- pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
- pTransInfo->inUse = nwal_FALSE;
+
+ 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 ;
}
-/*****************************************************************/
-/***************Delete an attached IP*****************************/
-/*****************************************************************/
-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)
+/********************************************************************
+ * FUNCTION PURPOSE: API to detach IP from MAC interface
+ ********************************************************************
+ * DESCRIPTION: API to detach IP from MAC interface
+ ********************************************************************/
+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;
+ return;
}
-/**
- * @def netcp_cfgAddClass
- * @brief add a classifier rule into 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)
+/********************************************************************
+ * FUNCTION PURPOSE: API to attach a classifier rule to NETCP
+ ********************************************************************
+ * DESCRIPTION: API to attach a classifier rule to NETCP
+ ********************************************************************/
+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
-nwal_RetValue retValue;
-NetapiNwalTransInfo_t *pTransInfo;
-nwal_TransID_t trans_id;
-int class_slot=-1;
-int iface_no;
-int ip_slot=-1;
-NETCP_CFG_CLASS_T classHandle; //returned by us
-nwal_appProtoType_t proto;
-nwalLocConnCfg_t tempCfg={
-0, //nwal_handle: 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
-};
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
+ void * l3_handle=NULL; //ip handle
+ nwal_RetValue retValue;
+ NetapiNwalTransInfo_t *pTransInfo;
+ nwal_TransID_t trans_id;
+ int class_slot=-1;
+ int iface_no;
+ int ip_slot=-1;
+ NETCP_CFG_CLASS_T classHandle; //returned by us
+ nwal_appProtoType_t proto;
+ nwalRxConnCfg_t tempCfg=
+ {
+ 0, //nwal_handle: 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;
+ return -1;
+ }
+ switch(p_class->classType)
+ {
+ default:
+ netapi_Log(">netapi_netcpCfg : classifier type %d not supported\n",p_class->classType);
+ break;
+ case(NETCP_CFG_CLASS_TYPE_L3_L4):
+ 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 = netapi_cfgGetMatchId(p_class->u.c_l4.ip);
+ }
-if(!p_class) { *err=NETAPI_ERR_BAD_INPUT; return -1;}
-switch(p_class->classType)
-{
-default:
- printf(">netcp_cfg : classifier type %d not supported\n",p_class->classType);
- break;
-case(NETCP_CFG_CLASS_TYPE_L3_L4):
-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;
- }
-
- //verify that iface has been configured
- if (iface_no != NETCP_CFG_NO_INTERFACE)
- {
- if(!netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
- {
- *err = NETAPI_ERR_BAD_INPUT;
- return -1;
- }
- }
+ //verify that iface has been configured
+ if (iface_no != NETCP_CFG_NO_INTERFACE)
+ {
+ if(!netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
+ {
+ *err = NETAPI_ERR_BAD_INPUT;
+ return -1;
+ }
+ }
- 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(
- &netapi_get_global()->nwal_context, iface_no,
- ip_slot );
- }
- else
- {
- nwalIpParam_t tempParam={
- pa_IPV4, /* IP Type */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Dest 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 */
- };
- //build nwalIpParam
- memcpy(&tempParam.locIpAddr,p_class->u.c_l3_l4.ip_addr, sizeof(nwalIpAddr_t));
- tempParam.ipType=p_class->u.c_l3_l4.ipType;
- //use nwal defauls for route
- if (p_class->u.c_l3_l4.ip_qualifiers)
- memcpy(&tempParam.ipOpt,p_class->u.c_l3_l4.ip_qualifiers, sizeof(nwalIpOpt_t));
- else
- memset(&tempParam.ipOpt,0, sizeof(nwalIpOpt_t));
-
-
- //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 ),
- &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(
- h, iface_no,
- p_class->u.c_l3_l4.ipType,
- p_class->u.c_l3_l4.ip_addr,
- p_class->u.c_l3_l4.ip_qualifiers,
- p_class->u.c_l3_l4.p_fail_route,
- &ret,
- FALSE);
- if(!ret)
- {
- l3_handle=NULL;
- }
- }
- }
- if(!l3_handle)
- {*err = NETAPI_ERR_BAD_INPUT; 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);
- //build request from template
- tempCfg.inHandle=l3_handle;
- if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
- {
- memcpy(&tempCfg.appProto,&p_class->u.c_l4.appProto,sizeof(nwalAppProto_t));
- proto = p_class->u.c_l4.proto;
- }
- else
- {
- memcpy(&tempCfg.appProto,&p_class->u.c_l3_l4.appProto,sizeof(nwalAppProto_t));
- proto = p_class->u.c_l3_l4.proto;
- }
-
- 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);
- }
-
- //get a transaction id
- pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return -1 ;}
- pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP; /* todo: fix this to TRANS_L4*/
- pTransInfo->netapi_handle = h;
- //issue request
- retValue = nwal_addConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
+ if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
+ {
+ //verify that ip has been configured and get its handle
+ l3_handle = netapip_netcpCfgGetIpHandle(
+ &netapi_get_global()->nwal_context, iface_no,
+ ip_slot );
+ }
+ else
+ {
+ 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 */
+ 0
+ };
+ //build nwalIpParam
+ memcpy(&tempParam.locIpAddr,p_class->u.c_l3_l4.ip_addr, sizeof(nwalIpAddr_t));
+ tempParam.ipType=p_class->u.c_l3_l4.ipType;
+ //use nwal defauls for route
+ if (p_class->u.c_l3_l4.ip_qualifiers)
+ memcpy(&tempParam.ipOpt,p_class->u.c_l3_l4.ip_qualifiers, sizeof(nwalIpOpt_t));
+ else
+ memset(&tempParam.ipOpt,0, sizeof(nwalIpOpt_t));
+
+ //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,
+ 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 *) 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);
+ if(!ret)
+ {
+ l3_handle=NULL;
+ }
+ }
+ }
+ if(!l3_handle)
+ {
+ *err = NETAPI_ERR_BAD_INPUT;
+ return -1 ;
+ }
+
+
+ //find free slot for CLASS & reserve
+ class_slot= netapip_netcpCfgFindClassSlot(n,
+ &netapi_get_global()->nwal_context);
+ if(class_slot<0) {*err = NETAPI_ERR_NOMEM; 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)
+ {
+ memcpy(&tempCfg.appProto,&p_class->u.c_l4.appProto,sizeof(nwalAppProto_t));
+ proto = p_class->u.c_l4.proto;
+ }
+ else
+ {
+ memcpy(&tempCfg.appProto,&p_class->u.c_l3_l4.appProto,sizeof(nwalAppProto_t));
+ proto = p_class->u.c_l3_l4.proto;
+ }
+
+ tempCfg.matchAction = (action==NETCP_CFG_ACTION_TO_SW) ? NWAL_MATCH_ACTION_HOST : NWAL_MATCH_ACTION_DISCARD;
+ if (route)
+ {
+ 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(n,
+ (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+ &trans_id);
+ if (!pTransInfo)
+ {
+ *err = NETAPI_ERR_BUSY;
+ return -1;
+ }
+ pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_PORT;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
+ pTransInfo->netapi_handle = h;
+ //issue request
+ retValue = nwal_addConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
trans_id,
- (nwal_AppId) classHandle,
+ (nwal_AppId) classHandle,
proto,
&tempCfg,
NULL,
&pTransInfo->handle);
- if(retValue != nwal_OK)
- {
- *err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: nwal_addConn returned Error Code %d\n",
- retValue);
- pTransInfo->inUse = nwal_FALSE;
- netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot);
- return -1;
- }
- //wait here until its done since scheduler isn't running yet most likely..
- // todo: make this handled by scheduler poll later ??
- if(trans_id != NWAL_TRANSID_SPIN_WAIT)
- {
- n->nwal_local.numPendingCfg++;
- while ((volatile) n->nwal_local.numPendingCfg)
- {
- // if response is there, then this poll squirts out in the CTl poll callback,
- // which handles the rest (including decrmenting #pending!!
- nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
- }
- }
- 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,
+ if(retValue != nwal_OK)
+ {
+ *err = NETAPI_ERR_NWAL_ERR0;
+ netapi_Log ("netcp_cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+ retValue);
+ netapip_freeTransInfo(pTransInfo);
+ netapip_netcpCfgDeleteClass(&netapi_get_global()->nwal_context, class_slot);
+ return -1;
+ }
+ //wait here until its done since scheduler isn't running yet most likely..
+ // todo: make this handled by scheduler poll later ??
+ if(trans_id != NWAL_TRANSID_SPIN_WAIT)
+ {
+ n->nwal_local.numPendingCfg++;
+ while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
+ (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
+ {
+ // if response is there, then this poll squirts out in the CTl poll callback,
+ // which handles the rest (including decrmenting #pending!!
+ nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
+ }
+ if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
+ {
+ netapip_freeTransInfo(pTransInfo);
+ *err = NETAPI_ERR_PA_FW;
+ netapip_netcpCfgDeleteClass(&netapi_get_global()->nwal_context, class_slot);
+ netapi_Log (">netcp_cfgAddClass - ERROR returned by NETCP PA firmware %d\n", *err);
+ return -1;
+ }
+ }
+ 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->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
- return classHandle;
-} //end switch
+ NULL, //L2 we have
+ (p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4? l3_handle : NULL),
+ pTransInfo->handle,
+ user_data);
+
+ netapip_freeTransInfo(pTransInfo);
+ return classHandle;
+ } //end switch
+
return -1;
}
-//delete classifier
-void netcp_cfgDelClass(NETAPI_T h,
- NETCP_CFG_CLASS_T classId,
- int *err)
+/********************************************************************
+ * FUNCTION PURPOSE: API to delete a preconfigured classifier
+ ********************************************************************
+ * DESCRIPTION: API to delete a preconfigured classifier
+ ********************************************************************/
+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
-nwal_RetValue retValue;
-NetapiNwalTransInfo_t *pTransInfo;
-nwal_TransID_t trans_id;
-int class_slot=-1;
-//int iface;
-//int ip_slot;
-
- class_slot = (classId>>8)&0xffff;
- L4_handle=netcp_cfgp_get_l4_handle(
- &netapi_get_global()->nwal_context,
- class_slot );
- if(!L4_handle) {*err = NETAPI_ERR_BAD_INPUT; return ;}
- L3_handle = netcp_cfgp_get_l3_handle(
- &netapi_get_global()->nwal_context,
- class_slot );
- /* l3 handle might be NULL,, depending on type of classifier */
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
+ void * L4_handle; //class handle -> L4
+ void * L3_handle; //class handle -> L3
+ nwal_RetValue retValue;
+ NetapiNwalTransInfo_t *pTransInfo;
+ nwal_TransID_t trans_id;
+ int class_slot=-1;
+
+ class_slot = netapi_cfgGetMatchId(classId);
+ L4_handle=netapip_netcpCfgGetL4Handle(&netapi_get_global()->nwal_context, class_slot);
+ if(!L4_handle)
+ {
+ *err = NETAPI_ERR_BAD_INPUT;
+ goto ERR_netapi_netcpCfgDelClass;
+ }
+ 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(
+ netapip_netcpCfgDeleteClass(
&netapi_get_global()->nwal_context,
class_slot );
- //get a transaction id
- pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;}
- pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP;
- pTransInfo->netapi_handle = h;
- //issue request for L4
- retValue = nwal_delConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
- trans_id,
- L4_handle);
- if(retValue != nwal_OK)
+ //get a transaction id
+ pTransInfo = netapip_getFreeTransInfo(n,
+ (NETAPI_PROC_GLOBAL_T *) n->proc_global,
+ &trans_id);
+ if (!pTransInfo)
+ {
+ *err = NETAPI_ERR_BUSY;
+ goto ERR_netapi_netcpCfgDelClass;
+ }
+ pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_PORT;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
+ pTransInfo->netapi_handle = h;
+ //issue request for L4
+ retValue = nwal_delConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
+ trans_id,
+ L4_handle);
+ if(retValue != nwal_OK)
+ {
+ *err = NETAPI_ERR_NWAL_ERR0;
+ 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 ??
+ if(trans_id != NWAL_TRANSID_SPIN_WAIT)
+ {
+ n->nwal_local.numPendingCfg++;
+ while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
+ (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
{
- *err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: nwal_delConn returned Error Code %d\n",
- retValue);
- pTransInfo->inUse = nwal_FALSE;
- return ; /* todo: what about the L3? */
+ // if response is there, then this poll squirts out in the CTl poll callback,
+ // which handles the rest (including decrmenting #pending!!
+ nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
}
- //wait here until its done since scheduler isn't running yet most likely..
- // todo: make this handled by scheduler poll later ??
- if(trans_id != NWAL_TRANSID_SPIN_WAIT)
- {
- n->nwal_local.numPendingCfg++;
- while ((volatile) n->nwal_local.numPendingCfg)
- {
- // if response is there, then this poll squirts out in the CTl poll callback,
- // which handles the rest (including decrmenting #pending!!
- nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
- }
- }
- printf (">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)
- {
- netcp_cfgDelIpInternal( h, 0, 0,
+ }
+ if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
+ {
+ netapip_freeTransInfo(pTransInfo);
+ *err = NETAPI_ERR_PA_FW;
+ netapi_Log (">netapi_netcpCfgDelClass - ERROR returned by NETCP PA firmware %d\n", *err);
+ goto ERR_netapi_netcpCfgDelClass;
+ }
+ 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)
+ {
+ netapip_netcpCfgDelIpInternal( h, 0, 0,
NULL, NULL, 0,
err, L3_handle, 0);
- }
- return ;
-}
+ }
+ netapip_freeTransInfo(pTransInfo);
+ERR_netapi_netcpCfgDelClass:
+ return;
+}
+/********************************************************************
+ * FUNCTION PURPOSE: API to add a flow
+ ********************************************************************
+ * DESCRIPTION: API to add a flow
+ ********************************************************************/
/*--------------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;
- Qmss_QueueHnd rxBufQ[TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW];
- Uint32 rxBufSize[TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW];
- int i;
- Cppi_FlowHnd FlowHnd;
- int slot;
- NETCP_CFG_FLOW_HANDLE_T retVal;
-
- *err= 0; /* ok */
- //get a slot to save new flow
- slot = netcp_cfgp_find_flow_slot(&netapi_get_global()->nwal_context);
- if (slot<0) { *err= NETAPI_ERR_NOMEM; return NULL; }
-
- //configure flow
- memset(&rxFlowCfg,0,sizeof(Cppi_RxFlowCfg));
- for (i = 0; i < TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW; i++)
- {
- if (i >= n)
- {
- rxBufQ[i] = 0;
- rxBufSize[i] = 0;
- } else
- {
- rxBufQ[i] = Pktlib_getInternalHeapQueue(handles[i]);
- //todo: verity sizes< heapsize
- //todo: verify order
- rxBufSize[i]= sizes[i];
- }
- if (i && (rxBufQ[i] <= 0))
- {
- rxBufQ[i] = rxBufQ[i-1];
- rxBufSize[i] = 0;
- }
- }
- /* 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.rx_ps_location = Cppi_PSLoc_PS_IN_DESC;
- rxFlowCfg.rx_desc_type = Cppi_DescType_HOST;
- rxFlowCfg.rx_error_handling = 0;
-
- rxFlowCfg.rx_psinfo_present = 1;
- rxFlowCfg.rx_einfo_present = 1;
-
- rxFlowCfg.rx_dest_tag_lo = 0;
- rxFlowCfg.rx_dest_tag_hi = 0;
- rxFlowCfg.rx_src_tag_lo = 0;
- rxFlowCfg.rx_src_tag_hi = 0;
-
- rxFlowCfg.rx_size_thresh0_en = rxBufSize[1] ? 1 : 0;
- 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;
- 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_fdq2_qnum = rxBufQ[2];
-
- rxFlowCfg.rx_fdq2_qmgr = 0;
- rxFlowCfg.rx_fdq3_qnum = rxBufQ[3];
-
- rxFlowCfg.rx_fdq3_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_sz1_qnum = rxBufQ[1];
- rxFlowCfg.rx_fdq0_sz1_qmgr = 0;
- rxFlowCfg.rx_fdq0_sz2_qnum = rxBufQ[2];
- rxFlowCfg.rx_fdq0_sz2_qmgr = 0;
- rxFlowCfg.rx_fdq0_sz3_qnum = rxBufQ[3];
- rxFlowCfg.rx_fdq0_sz3_qmgr = 0;
-
- {
- //todo: replace this with a nwal call to get global cntx info
- Cppi_CpDmaInitCfg cpdmaCfg;
- memset(&cpdmaCfg,0,sizeof(Cppi_CpDmaInitCfg));
- cpdmaCfg.dmaNum = Cppi_CpDma_PASS_CPDMA;
- FlowHnd =
- Cppi_configureRxFlow (Cppi_open (&cpdmaCfg), &rxFlowCfg, &isAlloc);
-}
- if (FlowHnd == NULL)
- {
- *err= NETAPI_ERR_NORES;
- netcp_cfgp_delete_flow(&netapi_get_global()->nwal_context, slot);
- return (NULL);
- }
+ Cppi_RxFlowCfg rxFlowCfg;
+ Uint8 isAlloc;
+ Qmss_QueueHnd rxBufQ[TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW];
+ Uint32 rxBufSize[TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW];
+ int i;
+ 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 = netapip_netcpCfgFindFlowSlot(pHandle,
+ &netapi_get_global()->nwal_context);
- //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);
+ if (slot<0) { *err= NETAPI_ERR_NOMEM; return NULL; }
+ //configure flow
+ memset(&rxFlowCfg,0,sizeof(Cppi_RxFlowCfg));
+ for (i = 0; i < TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW; i++)
+ {
+ if (i >= n)
+ {
+ rxBufQ[i] = 0;
+ rxBufSize[i] = 0;
+ }
+ else
+ {
+ rxBufQ[i] = Pktlib_getInternalHeapQueue(handles[i]);
+ //todo: verity sizes< heapsize
+ //todo: verify order
+ rxBufSize[i]= sizes[i];
+ }
+ if (i && (rxBufQ[i] <= 0))
+ {
+ rxBufQ[i] = rxBufQ[i-1];
+ rxBufSize[i] = 0;
+ }
+ }
+ /* Configure Rx flow */
+ 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 = p_cfg->block;
+
+ rxFlowCfg.rx_psinfo_present = 1;
+ rxFlowCfg.rx_einfo_present = 1;
+
+ rxFlowCfg.rx_dest_tag_lo = 0;
+ rxFlowCfg.rx_dest_tag_hi = 0;
+ rxFlowCfg.rx_src_tag_lo = 0;
+ rxFlowCfg.rx_src_tag_hi = 0;
+
+ rxFlowCfg.rx_size_thresh0_en = rxBufSize[1] ? 1 : 0;
+ rxFlowCfg.rx_size_thresh1_en = rxBufSize[2] ? 1 : 0;
+ rxFlowCfg.rx_size_thresh2_en = rxBufSize[3] ? 1 : 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 = (rxBufQ[1] ? Qmss_getQueueNumber(rxBufQ[1]).qMgr: 0);
+ rxFlowCfg.rx_fdq2_qnum = rxBufQ[2];
+ rxFlowCfg.rx_fdq2_qmgr = (rxBufQ[2] ? Qmss_getQueueNumber(rxBufQ[2]).qMgr: 0);
+ rxFlowCfg.rx_fdq3_qnum = rxBufQ[3];
+ 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 = (rxBufQ[0] ? Qmss_getQueueNumber(rxBufQ[0]).qMgr: 0);
+ rxFlowCfg.rx_fdq0_sz1_qnum = rxBufQ[1];
+ 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 = (rxBufQ[2] ? Qmss_getQueueNumber(rxBufQ[2]).qMgr:0);
+ rxFlowCfg.rx_fdq0_sz3_qnum = rxBufQ[3];
+ 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 = (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;
+ netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context, slot);
+ return (NULL);
+ }
+ //update slot
+ 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);
}
-//Delete a flow
-void netcp_cfgDelFlow(NETAPI_T h , NETCP_CFG_FLOW_HANDLE_T f , int * err)
+/********************************************************************
+ * FUNCTION PURPOSE: API to delete a flow
+ ********************************************************************
+ * DESCRIPTION: API to delete a flow
+ ********************************************************************/
+void netapi_netcpCfgDelFlow(NETAPI_T h,
+ NETCP_CFG_FLOW_HANDLE_T f,
+ int* err)
{
- int slot;
- void * handle;
- *err=0;
- /* find entry */
- slot = netcp_cfgp_find_flow(&netapi_get_global()->nwal_context, ((NETCP_CFG_FLOW_T *) f) ->flowid, &handle);
- if (slot<0) {*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);
+ int slot;
+ void * handle;
+ *err=0;
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
+ /* find entry */
+ 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;
return;
+ }
+
+ Cppi_closeRxFlow( (Cppi_FlowHnd) handle);
+ netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context,
+ slot);
+ netapi_Log(">netcp cfg: flow %d (dma index %d) deleted\n",
+ ((NETCP_CFG_FLOW_T *) f)->flowid,
+ ((NETCP_CFG_FLOW_T *) f)->dma_engine);
+ return;
}
+/******************************************************************************
+ * FUNCTION PURPOSE: API to configure NETCP with global rules for exception packet handling
+ ******************************************************************************
+ * DESCRIPTION: API to configure NETCP with global rules for exception packet handling
+ *****************************************************************************/
+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;
+ nwal_RetValue retVal = 0;
+ memset(&ctrl, 0, sizeof(nwalCtlInfo_t));
+
+
+ if (p_route != NULL)
+ {
+ 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
+ {
+ ctrl.appRxPktFlowId = NWAL_FLOW_NOT_SPECIFIED;
+ ctrl.appRxPktQueue = NWAL_QUEUE_NOT_SPECIFIED;
+ }
+
+ ctrl.appId = (void*)(NETAPI_NETCP_CFG_MATCH_EXCEPTION | exception_id);
+
+ ctrl.matchAction = action;
+
+ if (exception_id == NETCP_CFG_ALL_EXCEPTIONS)
+ {
+ ctrl.pktCtl = NWAL_CTRL_CFG_ALL_EXCEPTIONS;
+ }
+ else
+ {
+ ctrl.pa_EROUTE_Id = exception_id;
+ ctrl.pktCtl = NWAL_CTRL_CFG_SINGLE_EXCEPTION;
+ }
+
+ retVal = nwal_control(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &ctrl);
+
+ return (NETCP_CFG_EXCEPTION_PKT_T) ctrl.appId;
+
+}
/*************************************************************************/
/*********************************INTERNAL*******************************/
/************************************************************************/
-/***************************************************************
- ********************METCP CMD Reply Callback******************
- ***************************************************************/
-void netapi_NWALCmdCallBack (nwal_AppId appHandle,
- uint16_t trans_id,
- nwal_RetValue ret)
+/********************************************************************
+ * FUNCTION PURPOSE: NETAPI internal function, NETCP command reply callback
+ ********************************************************************
+ * DESCRIPTION: NETAPI internal function, NETCP command reply callback
+ ********************************************************************/
+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 : NWALCmdCallBack returned Error Code %d\n",
- ret);
- //todo: atomic inc
- netapi_get_global()->nwal_context.numCmdFail++;
+ 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_proc_global()->nwal_context.numCmdFail++;
}
else
{
- //todo: atomic inc
- netapi_get_global()->nwal_context.numCmdPass++;
+ //todo: atomic inc
+ netapi_get_proc_global()->nwal_context.numCmdPass++;
switch(p_trans->transType)
{
case NETAPI_NWAL_HANDLE_TRANS_MAC:
{
if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING)
{
- p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN;
+ p_trans->state = NETAPI_NWAL_HANDLE_STATE_OPEN;
}
else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING)
{
}
break;
}
- case NETAPI_NWAL_HANDLE_TRANS_SA_POLICY:
+ case NETAPI_NWAL_HANDLE_TRANS_SA_POLICY:
{
if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING)
{
}
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;
}
{
p_trans->inUse = nwal_FALSE;
}
-
}
-/*******************************************************/
-/**************stats reply callback**********************/
-/*******************************************************/
-void netapi_NWALCmdPaStatsReply (nwal_AppId appHandle,
- nwal_TransID_t trans_id,
- paSysStats_t *stats)
+/********************************************************************
+ * FUNCTION PURPOSE: NETAPI internal function, PA stats reply callback
+ ********************************************************************
+ * DESCRIPTION: NETAPI internal function, PA stats reply callback
+ ********************************************************************/
+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;
//save a local copy of some stuff*/
p_local->numL2PktsRecvd=stats->classify1.nPackets;
p_local->numL3PktsRecvd=stats->classify1.nIpv4Packets;
-#if 0
- p_local->numL4PktsRecvd=stats->;
- p_local->numL4PktsSent=stats->;
- p_local->TxErrDrop=stats->;
-#endif
+
//callout result to application !!
- if (p_local->stats_cb) (*p_local->stats_cb)(p_trans->netapi_handle,stats);
-
-}
+ if (p_local->stats_cb)
+ {
+ (*p_local->stats_cb)(p_trans->netapi_handle,stats);
+ }
+}