summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ad9805e)
raw | patch | inline | side by side (parent: ad9805e)
author | Tinku Mannan <tmannan@ti.com> | |
Fri, 28 Dec 2012 16:28:50 +0000 (11:28 -0500) | ||
committer | Tinku Mannan <tmannan@ti.com> | |
Fri, 28 Dec 2012 16:28:50 +0000 (11:28 -0500) |
17 files changed:
index 92ed153bf8a1eeedc9555b6a8bb507e04d6bc1a2..4ad0da297426e8295d47aa4f8779e4426818cd18 100755 (executable)
/**
* @def NETAPI_NO_MASTER
- * This defines no mater, data only
+ * This defines no master, data only
*/
#define NETAPI_NO_MASTER 0 //data only
index 86c646cf5fb2543e030c4da3c45bb3f6ea5ae3ce..d36ee6cf9b5e166a2b9afe8be658ba08104ea6c0 100755 (executable)
/**
* @def NETAPI_ERR_NOMEM
* @ingroup netapi_errors
- * @brief out of memory error
+ * @brief out of memory error
*/
#define NETAPI_ERR_NOMEM -1
/**
* @def NETAPI_ERR_NOT_IMLEMENTED_
* @ingroup netapi_errors
- * @brief Feature not implemented in this version
+ * @brief Feature not implemented in this version
*/
#define NETAPI_ERR_NOT_IMPLEMENTED -7
*/
#define NETAPI_ERR_NORES -8
+/**
+ * @def NETAPI_ERR_NORES
+ * @ingroup netapi_errors
+ * @brief error returned by NETCP PA firmware
+ */
+#define NETAPI_ERR_PA_FW -9
+
+
/**
* @def NETAPI_ERR_ALREADY_CANCELLED
* @ingroup netapi_errors
/**
* @def NETAPI_ERR_NWAL_TX_ERR
* @ingroup netapi_errors
- * @brief error trying to send to NWAL.
+ * @brief error trying to send to NWAL.
*/
#define NETAPI_ERR_NWAL_TX_ERR -65536
+
+
#endif
index 8bf1287a45fa6650f1e22f4d7ebd9573ebf00dd6..a58edd24087674e383d08cd8899cc230d73490a5 100755 (executable)
#define NETAPI_SCHED_POWER_ALWAYS_ON 100
int idle_time; /**< idle time TBD */
+
+ Bool yield; /**< option of thread/core to yield in scheduling loop in no pkts from to process */
+ Bool pollCtrlQ; /**< option to poll the control queue in scheduling loop */
+ Bool pollGarbageQ; /**< option to poll the garbage queue in scheduling loop */
} NETAPI_SCHED_CONFIG_T;
index 7d319101e47bacbb82a1c91f15b95e1b84635e30..85d2b1d75ea3ca1d83736e875c26d2fdb5e7be52 100755 (executable)
* @def TUNE_NETAPI_NUM_CORES
* This defines the number of cores (theads)
*/
-#define TUNE_NETAPI_NUM_CORES 4
+#define TUNE_NETAPI_NUM_CORES 5
/**
* @ingroup tune_parameters
index d0a289c969f8c83063a7e673b6f213982f461674..6ec7e45af22bc934fb7292dd943b04c22daca08f 100755 (executable)
extern uint8_t *netapi_VM_mem_start_phy;
extern uint8_t *netapi_VM_mem_end_phy;
-/* timing */
-static inline unsigned long netapi_timing_start(void)
-{
- volatile int vval;
- //read clock
- asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(vval));
- return vval;
-}
-#define netapi_timing_stop netapi_timing_start
+
+#define netapi_timing_start hplib_mUtilGetPmuCCNT
+#define netapi_timing_stop hplib_mUtilGetPmuCCNT
//netapi kernel module access routines
int netapi_utilModInit(void);
index 453a489914219dd215a28fdbefbcd24edc8955da..c584d5bd62b71d67a61a8219bcf999b998aa6ae1 100755 (executable)
/*--------------------defines-----------------------*/
+
+//#define PKTIO_GET_BENCHMARK
+
/**
* @def PKTIO_NOMEM
* @ingroup pktio_constants
PKTIO_POLL _poll; /**<pktio type specific POLL function */
int poll_flags;
char name[PKTIO_MAX_NAME+1]; /**< Name of pktio channel */
+#ifdef PKTIO_GET_BENCHMARK
+ /* for benchmarking .. need to be defined somewhere */
+ unsigned int vv7p;
+ unsigned int vv8p;
+ unsigned int vv9p;
+ unsigned int vv10p;
+ unsigned int vv11p;
+ unsigned int vv12p;
+ unsigned int vv13p; //rcv path
+ unsigned int vv14p;
+ unsigned int vv15p;
+#endif
} PKTIO_HANDLE_T;
index b9fcc578a4004254e56f46fbf049daa8a531ed8b..fc52ef4acbfdecb078cc8c497dec9ff3ac4f82dd 100755 (executable)
#include <string.h>
#include "netapi.h"
+
typedef struct PRESET_Tag
{
#define KMAXQ 10
*-------------------------------------*/
NETAPI_T netapi_init(int master, NETAPI_CFG_T * p_cfg)
{
- int i;
- int err;
- NETAPI_HANDLE_T * p = (NETAPI_HANDLE_T *) calloc(1,sizeof(NETAPI_HANDLE_T));
- NETAPI_HANDLE_T * p_master;
- if (!p) return NULL;
- p->master = master;
-
- /* create space for our local pktios */
- for(i=0;i<NETAPI_MAX_PKTIO; i++)
- {
- p->pktios[i] = calloc(1,sizeof(PKTIO_HANDLE_T));
- if (!p->pktios[i]) return NULL;
- }
+ int i;
+ int err;
+ NETAPI_HANDLE_T * p = (NETAPI_HANDLE_T *) calloc(1,sizeof(NETAPI_HANDLE_T));
+ NETAPI_HANDLE_T * p_master;
+ if (!p) return NULL;
+ p->master = master;
+
+ /* create space for our local pktios */
+ for(i=0;i<NETAPI_MAX_PKTIO; i++)
+ {
+ p->pktios[i] = calloc(1,sizeof(PKTIO_HANDLE_T));
+ if (!p->pktios[i])
+ {
+ return NULL;
+ }
+ }
#ifdef NETAPI_INCLUDE_SCHED
- /* create space for scheduler */
- p->p_sched = calloc(1,sizeof(NETAPI_SCHED_HANDLE_T));
-#endif
-
-
- /* global stuff (if master) */
- if (master==NETAPI_SYS_MASTER)
- {
- if (p_cfg) memcpy(&netapi_global.cfg,p_cfg, sizeof(NETAPI_CFG_T));
- else memcpy(&netapi_global.cfg,&netapi_default_cfg, sizeof(NETAPI_CFG_T));
- for(i=0;i<NETAPI_MAX_PKTIO;i++)
- {
- netapi_global.pktios[i].qn.qNum=-1;
- netapi_global.pktios[i].name[0]='\0';
- }
- }
- //this goes to shared memory eventually
- p->global = (void *) &netapi_global;
-
- //dalmt: save master's handle back in global; else for slave retrieve p_master
- if (master==NETAPI_SYS_MASTER)
- {
- netapi_global.p_master = p;
- }
- else
- {
- p_master=(NETAPI_HANDLE_T *)netapi_global.p_master;
- }
-
- /* system init */
- if(master==NETAPI_SYS_MASTER)
- {
- err = system_init(p);
- if (err<0)
- {
- //todo: cleanup
- return NULL;
- }
- /* create pktio channels for tx,rx */
- }
- else if (master==NETAPI_NO_MASTER)
- {
- //dalmt ->simple trial. Just copy master's packetio list for now
+ /* create space for scheduler */
+ p->p_sched = calloc(1,sizeof(NETAPI_SCHED_HANDLE_T));
+#endif
+
+
+ /* global stuff (if master) */
+ if (master==NETAPI_SYS_MASTER)
+ {
+ if (p_cfg)
+ {
+ memcpy(&netapi_global.cfg,p_cfg, sizeof(NETAPI_CFG_T));
+ }
+ else
+ {
+ memcpy(&netapi_global.cfg,&netapi_default_cfg, sizeof(NETAPI_CFG_T));
+ }
+ for(i=0;i<NETAPI_MAX_PKTIO;i++)
+ {
+ netapi_global.pktios[i].qn.qNum=-1;
+ netapi_global.pktios[i].name[0]='\0';
+ }
+ }
+ //this goes to shared memory eventually
+ p->global = (void *) &netapi_global;
+
+ //dalmt: save master's handle back in global; else for slave retrieve p_master
+ if (master==NETAPI_SYS_MASTER)
+ {
+ netapi_global.p_master = p;
+ }
+ else
+ {
+ /* get system master reqquired for core and no master */
+ p_master=(NETAPI_HANDLE_T *)netapi_global.p_master;
+ }
+
+ /* system init */
+ if(master==NETAPI_SYS_MASTER)
+ {
+ err = system_init(p);
+ if (err<0)
+ {
+ //todo: cleanup
+ return NULL;
+ }
+ /* create pktio channels for tx,rx */
+ }
+ else if (master==NETAPI_NO_MASTER)
+ {
+ //dalmt ->simple trial. Just copy master's packetio list for now
p->n_pktios = p_master->n_pktios;
memcpy(&p->pktios[0],&p_master->pktios[0],NETAPI_MAX_PKTIO*sizeof(PKTIO_HANDLE_T));
p->nwal_local=p_master->nwal_local;
- }
- else
- {
- /*todo init for non-system cores/threads */
- /* qm_start, */
- /* attach to heaps */
- /* nwal_start */
- }
-
- return (NETAPI_T) p;
+ }
+ /* this is the NETAPI_CORE_MASTER case */
+ else if (master==NETAPI_CORE_MASTER)
+ {
+
+ /* Start the QMSS. */
+ if (netapi_start_qm() != 1)
+ {
+ return -1;
+ }
+ netapi_start_nwal(p_master->netcp_heap,
+ p_master->netcp_control_rx_heap,
+ p_master->netcp_control_tx_heap,
+ &p->nwal_local,
+ &netapi_global.cfg,
+ &netapi_global.nwal_context);
+ }
+ else
+ {
+ printf("netapi_init: no master specified\n");
+ return -1;
+ }
+//#endif
+ return (NETAPI_T) p;
}
/*-------------------------------
if (!p) return;
printf(">netapi: WARNING shutdown may not be fully implemented\n");
- if (p->master)
+ if (p->master ==NETAPI_SYS_MASTER)
{
/* close nwal */
nwal_delete(netapi_global.nwal_context.nwalInstHandle);
Pktlib_HeapHandle controlRxHeapHandle,controlTxHeapHandle;
Pktlib_HeapCfg heapCfg;
int32_t errCode;
+ int count=0;
+
#ifdef NETAPI_USE_DDR
/* Init attributes for DDR */
netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_KM_CACHED0;
if (result<0) {printf(">netapi init_nwal() failed\n"); return -1; }
printf("system_init: returned from netapi_init_nwal\n");
/* start NWAL */
+
+
+ /* Common Initialization for all cores */
+ while(count < TUNE_NETAPI_MAX_NUM_TRANS)
+ {
+ netapi_global.nwal_context.transInfos[count].transId = count;
+ count++;
+ }
result = netapi_start_nwal(sharedHeapHandle,
controlRxHeapHandle,
controlTxHeapHandle,
index bad13f42d881fc1caa22aa71c6f502123504644f..b59ea2abe17272997118b8578f202705e20636a3 100755 (executable)
NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_glob_context )
{
nwalLocCfg_t nwalLocCfg;
- int count;
+ int count=0;
+ static int first_time = 0;
nwal_RetValue nwalRetVal;
memset(&nwalLocCfg,0,sizeof(nwalLocCfg));
- /* Common Initialization for all cores */
- while(count < TUNE_NETAPI_MAX_NUM_TRANS)
- {
- p_nwal_glob_context->transInfos[count].transId = count;
- count++;
- }
-
/* Update the Start of Packet Offset for the default flows created
* by NWAL
*/
index 0c2d2aa813c35702aa8967e001c007b2e78c7082..1f1ed605de47a2e48d3a8a551df77911e96e1f6f 100755 (executable)
#define NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING 1
#define NETAPI_NWAL_HANDLE_STATE_OPEN 2
#define NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING 3
+#define NETAPI_NWAL_HANDLE_STATE_ERR 4
nwal_Handle handle;
uint64_t transId;
NETAPI_T netapi_handle; //the thread making the transaction
**************************************/
typedef struct NETAPI_HANDLE_Tag
{
-int master; //master type
+ int master; //master type
-void * global; /* pointer to the global area */
+ void * global; /* pointer to the global area */
-/* heap handles */
-Pktlib_HeapHandle netcp_heap; /* internal default */
-Pktlib_HeapHandle netcp_control_rx_heap; /* for control messages */
-Pktlib_HeapHandle netcp_control_tx_heap; /* for control messages */
-Pktlib_HeapHandle createdHeaps[TUNE_NETAPI_MAX_HEAPS]; /* created by app and registered */
+ /* heap handles */
+ Pktlib_HeapHandle netcp_heap; /* internal default */
+ Pktlib_HeapHandle netcp_control_rx_heap; /* for control messages */
+ Pktlib_HeapHandle netcp_control_tx_heap; /* for control messages */
+ Pktlib_HeapHandle createdHeaps[TUNE_NETAPI_MAX_HEAPS]; /* created by app and registered */
-/* pktios defined */
-int n_pktios; /* #of pktios that are active for this instance */
-void* pktios[NETAPI_MAX_PKTIO]; /* the list of pktios */
+ /* pktios defined */
+ int n_pktios; /* #of pktios that are active for this instance */
+ void* pktios[NETAPI_MAX_PKTIO]; /* the list of pktios */
-/* scheduler stuff. unallocated if NETAPI_INCLUDE_SCHED not set */
-void * p_sched;
+ /* scheduler stuff. unallocated if NETAPI_INCLUDE_SCHED not set */
+ void * p_sched;
-/* nwal local context */
-NETAPI_NWAL_LOCAL_CONTEXT_T nwal_local;
+ /* nwal local context */
+ NETAPI_NWAL_LOCAL_CONTEXT_T nwal_local;
-/* security stuff */
+ /* security stuff */
-/* timer stuff */
-
-/* thread cookie */
-void * cookie; /*set by calling thread */
+ /* timer stuff */
+ /* thread cookie */
+ void * cookie; /*set by calling thread */
} NETAPI_HANDLE_T;
int sa_slot, void ** p_sideband);
void* netcp_cfgp_get_mac_handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no);
NetapiNwalTransInfo_t * netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwal_TransID_t *pTransId);
+void netapip_FreeTransInfo(NetapiNwalTransInfo_t* pTransInfo);
void *netcp_cfgp_get_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
int policy_slot);
#endif
index 1b5f5a2b1758e6baebb8e9ac7f38c0370dc2e847..cc5c657f8fc432f0fda7065a9f5018effbefec63 100755 (executable)
cache_op_b2= Osal_cache_op_measure(&n_c_ops);
t1=hplib_mUtilGetPmuCCNT();
pkts=pktio_pollAll((NETAPI_T) s->back, NULL, &err);
+ if (!pkts && (s->config.yield == TRUE))
+ {
+ sched_yield();
+ }
t2=hplib_mUtilGetPmuCCNT();
if (pkts)
{
#ifndef NO_GARBAGE
//poll pktlib garbage collections for registered heaps..
- netapi_pollHeapGarbage((NETAPI_T) s->back);
+ if (TRUE== s->config.pollGarbageQ)
+ {
+ netapi_pollHeapGarbage((NETAPI_T) s->back);
+ }
#endif
#ifndef NO_TIMER
hplib_TimerPollAllGroups((NETAPI_T) s->back, HPLIB_TIMER_FITLER_ALL, 100000);
#endif
//poll NETCP/PA control channels
- netapi_netcpPoll((NETAPI_T) s->back);
+ if (TRUE== s->config.pollGarbageQ)
+ {
+ netapi_netcpPoll((NETAPI_T) s->back);
+ }
//see if time to do a house keeping callback
if ((s->config.valid_flags & NETAPI_SCHED_CBV) && s->config.house_cb)
//see if we were closed and/or its time to close
if (s->state!= NETAPI_SCHED_STATE_OPEN)
{ s->state=NETAPI_SCHED_STATE_CLOSE; break;}
+
}
return 1;
}
index 388e2e19052489a86ccd1ed8e4494c157f3fd486..7574bb8b47018f415c5f724ea401a7e0377743f6 100755 (executable)
void **p_inflow_mode_handle,
int * perr)
{
-NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
-nwal_RetValue retValue;
-NetapiNwalTransInfo_t *pTransInfo;
-nwal_TransID_t trans_id;
-unsigned int appId = NETAPI_NETCP_MATCH_IPSEC | iface_no;
-int tunnelId;
-nwalSaIpSecId_t saInfo;
-int have_to_wait=1;
-nwalCreateSAParams_t createParam =
-{
-/* mac handle */
- NULL, //to be filled in
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
+ nwal_RetValue retValue;
+ NetapiNwalTransInfo_t *pTransInfo;
+ nwal_TransID_t trans_id;
+ unsigned int appId = NETAPI_NETCP_MATCH_IPSEC | iface_no;
+ int tunnelId;
+ nwalSaIpSecId_t saInfo;
+ int have_to_wait=1;
+ nwalCreateSAParams_t createParam =
+ {
+ /* mac handle */
+ NULL, //to be filled in
4,
-/*nwalSaIpSecParam_t */
- {
- 0,/* validParams */
- nwal_SA_MODE_TUNNEL, //update from input
- 64,/* replayWindow */
- NWAL_SA_DIR_INBOUND,
- 0,
- 0,
- NWAL_SA_AALG_HMAC_SHA1, /* update from input */
- NWAL_SA_EALG_AES_CTR, /* update from input */
- { 0x00}, /* remMacAddr: NA */
- 12, /* update from input, mac size */
- NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */
- NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */
- CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */
- QMSS_PARAM_NOT_SPECIFIED /* Use default queue configured to NWAL if packet is routed to host */
- },
- /* nwalSaIpSecKeyParams_t */
- {0}
-};
+ /*nwalSaIpSecParam_t */
+ {
+ 0,/* validParams */
+ nwal_SA_MODE_TUNNEL, //update from input
+ 64,/* replayWindow */
+ NWAL_SA_DIR_INBOUND,
+ 0,
+ 0,
+ NWAL_SA_AALG_HMAC_SHA1, /* update from input */
+ NWAL_SA_EALG_AES_CTR, /* update from input */
+ { 0x00}, /* remMacAddr: NA */
+ 12, /* update from input, mac size */
+ NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */
+ NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */
+ CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */
+ QMSS_PARAM_NOT_SPECIFIED /* Use default queue configured to NWAL if packet is routed to host */
+ },
+ /* nwalSaIpSecKeyParams_t */
+ {0}
+ };
void * mac_handle = netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context,iface_no);
*perr =0;
//reserve a slot
tunnelId = netcp_cfgp_find_sa_slot(&netapi_get_global()->nwal_context,
iface_no);
+
+ printf("netapi_secAddSA called for tunnelId %d\n", tunnelId);
if (tunnelId <0) {*perr= NETAPI_ERR_NOMEM; return -1; }
appId |= (tunnelId<<8);
*p_data_mode_handle= NULL;
*p_inflow_mode_handle= NULL;
- if (inflow_mode & NETAPI_SEC_SA_INFLOW)
+ if (inflow_mode & NETAPI_SEC_SA_INFLOW)
{
+ pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+ if (!pTransInfo)
+ {
+ *perr = NETAPI_ERR_BUSY;
+ netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+ return -1;
+ }
+ pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
+ pTransInfo->netapi_handle = h;
+
+ /* build SA parameters */
+ saInfo.spi = sa_info->spi;
+ memcpy(&saInfo.dst, &sa_info->dst, sizeof( nwalIpAddr_t));
+ memcpy(&saInfo.src, &sa_info->src, sizeof( nwalIpAddr_t));
+ saInfo.proto = sa_info->proto;
+ createParam.macHandle = mac_handle;
+ createParam.ipType = sa_info->ipType;
+ //memcpy(&createParam.saIpSecParam.src,&sa_info->src, sizeof(nwalIpAddr_t));
+ createParam.saIpSecParam.dir = sa_info->dir;
+ createParam.saIpSecParam.saMode = sa_info->saMode;
+ createParam.saIpSecParam.replayWindow = sa_info->replayWindow;
+ createParam.saIpSecParam.authMode = sa_info->authMode;
+ createParam.saIpSecParam.cipherMode = sa_info->cipherMode;
+ createParam.saIpSecParam.esnLo = sa_info->esnLo;
+ createParam.saIpSecParam.esnHi = sa_info->esnHi;
+ if ((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) || (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))
+ {
+ createParam.saIpSecParam.macSize = 16;
+ }
+ if ((sa_info->authMode == NWAL_SA_AALG_NULL) &&
+ (!((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) ||
+ (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))))
+ {
+ createParam.saIpSecParam.replayWindow = 0;
+ createParam.saIpSecParam.macSize = 0;
+ }
+ memcpy(&createParam.keyParam,key_params,sizeof(nwalSecKeyParams_t));
- pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *perr = NETAPI_ERR_BUSY;netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId); return -1;}
- pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA;
- pTransInfo->netapi_handle = h;
-
- /* build SA parameters */
- saInfo.spi = sa_info->spi;
- memcpy(&saInfo.dst, &sa_info->dst, sizeof( nwalIpAddr_t));
- memcpy(&saInfo.src, &sa_info->src, sizeof( nwalIpAddr_t));
- saInfo.proto = sa_info->proto;
- createParam.macHandle = mac_handle;
- createParam.ipType = sa_info->ipType;
- //memcpy(&createParam.saIpSecParam.src,&sa_info->src, sizeof(nwalIpAddr_t));
- createParam.saIpSecParam.dir = sa_info->dir;
- createParam.saIpSecParam.saMode = sa_info->saMode;
- createParam.saIpSecParam.replayWindow = sa_info->replayWindow;
- createParam.saIpSecParam.authMode = sa_info->authMode;
- createParam.saIpSecParam.cipherMode = sa_info->cipherMode;
- createParam.saIpSecParam.esnLo = sa_info->esnLo;
- createParam.saIpSecParam.esnHi = sa_info->esnHi;
- if ((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) || (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))
- {
- createParam.saIpSecParam.macSize = 16;
- }
- if ((sa_info->authMode == NWAL_SA_AALG_NULL) &&
- (!((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) ||
- (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))))
- {
- createParam.saIpSecParam.replayWindow = 0;
- createParam.saIpSecParam.macSize = 0;
- }
- memcpy(&createParam.keyParam,key_params,sizeof(nwalSecKeyParams_t));
+ if (route != NULL)
+ {
+ netcp_cfgp_build_route(route,&createParam.saIpSecParam.appRxPktFlowId,
+ &createParam.saIpSecParam.appRxPktQueue);
+ }
+
+ //fire off config message
+ retValue = nwal_setSecAssoc (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
+ trans_id,
+ (nwal_AppId) appId,
+ &saInfo,
+ &createParam,
+ &pTransInfo->handle);
+ if(retValue == nwal_TRANS_COMPLETE)
+ {
+ have_to_wait=0;
+ }
+ else if(retValue != nwal_OK)
+ {
+ *perr = NETAPI_ERR_NWAL_ERR0;
+ printf ("netapi_secAddSA: ERROR: nwal_setSecAssoc returned Error Code %d\n",
+ retValue);
+ netapip_FreeTransInfo(pTransInfo);
+ netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+ return -1;
+ }
- if (route != NULL)
- {
- netcp_cfgp_build_route(route,&createParam.saIpSecParam.appRxPktFlowId,
- &createParam.saIpSecParam.appRxPktQueue);
- }
-
- //fire off config message
- pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
- retValue = nwal_setSecAssoc (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
- trans_id,
- (nwal_AppId) appId,
- &saInfo,
- &createParam,
- &pTransInfo->handle);
- if(retValue == nwal_TRANS_COMPLETE)
- {
- have_to_wait=0;
- }
- else if(retValue != nwal_OK)
- {
- *perr = NETAPI_ERR_NWAL_ERR0;
- printf (">netapi_sec - ERROR: nwal_setSecAssoc returned Error Code %d\n",
- retValue);
- pTransInfo->inUse = nwal_FALSE;
- netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
- 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)&&(have_to_wait))
- {
- n->nwal_local.numPendingCfg++;
- while ((volatile) n->nwal_local.numPendingCfg)
+ //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)&&(have_to_wait))
{
- // 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);
+ 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)
+ {
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
+ pTransInfo->inUse = nwal_FALSE;
+ *perr = NETAPI_ERR_PA_FW;
+ printf (">netapi_sec - ERROR returned by NETCP PA firmware %d\n",
+ *perr);
+
+ netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+ return -1;
+ }
}
- }
- printf (">netapi sec: SA %d added to mac %d\n", tunnelId, iface_no);
+ printf ("netapi_secAddSA: SA %d added to mac %d\n", tunnelId, iface_no);
- pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
- *p_inflow_mode_handle=pTransInfo->handle;
- pTransInfo->inUse = nwal_FALSE;
+ *p_inflow_mode_handle=pTransInfo->handle;
+ netapip_FreeTransInfo(pTransInfo);
}
//sideband mode
if (inflow_mode &NETAPI_SEC_SA_SIDEBAND)
{
- nwalCreateDmSAParams_t dmSaParam;
+ nwalCreateDmSAParams_t dmSaParam;
void * dm_handle;
memset(&dmSaParam,0,sizeof(nwalCreateDmSAParams_t));
dmSaParam.dmSaParam.dmChnType= (sa_info->dir==NWAL_SA_DIR_INBOUND)? NWAL_DM_CHAN_DECRYPT: NWAL_DM_CHAN_ENCRYPT; /**direction*/
&dm_handle);
if(retValue != nwal_OK)
{
- *perr = NETAPI_ERR_NWAL_ERR0;
- printf (">netapi_sec - ERROR: nwal_setDMSecAssoc returned Error Code %d\n",
- retValue);
- netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
- return -1;
+ *perr = NETAPI_ERR_NWAL_ERR0;
+ printf (">netapi_sec - ERROR: nwal_setDMSecAssoc returned Error Code %d\n",
+ retValue);
+ netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+ return -1;
}
- printf(">netapisec. Creating sideband mode SA for %d ( mac %d)\n", tunnelId, iface_no);
+ printf("netapi_secAddSA: Creating sideband mode SA for %d ( mac %d)\n", tunnelId, iface_no);
*p_data_mode_handle = dm_handle;
}
//save stuff
+
netcp_cfgp_insert_sa(&netapi_get_global()->nwal_context,
tunnelId,
(sa_info->dir == NWAL_SA_DIR_INBOUND) ? TRUE: FALSE,
//(internal version)
static void netapi_secDelSA_internal(NETAPI_T h,int iface_no, NETCP_CFG_SA_T sa_app_id, int flags, int *perr)
{
-NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
-nwal_RetValue retValue;
-NetapiNwalTransInfo_t *pTransInfo;
-nwal_TransID_t trans_id;
-int tunnelId = (sa_app_id >>8) &0xffff;
-void * handle_inflow;
-void * handle_sideband;
-int have_to_wait = 1;
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
+ nwal_RetValue retValue;
+ NetapiNwalTransInfo_t *pTransInfo;
+ nwal_TransID_t trans_id;
+ int tunnelId = (sa_app_id >>8) &0xffff;
+ void * handle_inflow;
+ void * handle_sideband;
+ int have_to_wait = 1;
handle_inflow = netcp_cfgp_get_sa_handles(&netapi_get_global()->nwal_context,
tunnelId, &handle_sideband);
if(handle_inflow)
{
//get a transaction id
- pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *perr = NETAPI_ERR_BUSY; return ;}
- pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA;
- pTransInfo->netapi_handle = h;
+ pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+ if (!pTransInfo)
+ {
+ *perr = NETAPI_ERR_BUSY;
+ return;
+ }
+ pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
+ pTransInfo->netapi_handle = h;
- //issue request
- retValue = nwal_delSecAssoc(
+ retValue = nwal_delSecAssoc(
((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
trans_id,
handle_inflow);
- if(retValue == nwal_TRANS_COMPLETE)
- {
- have_to_wait=0;
- }
- else
- if(retValue != nwal_OK)
- {
- *perr = NETAPI_ERR_NWAL_ERR0;
- printf (">netapi_sec - ERROR: nwal_delSA returned Error Code %d\n",
- retValue);
- pTransInfo->inUse = nwal_FALSE;
- 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)&&(have_to_wait))
- {
- n->nwal_local.numPendingCfg++;
- while ((volatile) n->nwal_local.numPendingCfg)
+ if(retValue == nwal_TRANS_COMPLETE)
{
- // 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);
+ have_to_wait=0;
+ }
+ else if(retValue != nwal_OK)
+ {
+ *perr = NETAPI_ERR_NWAL_ERR0;
+ printf (">netcp cfg - ERROR: netapi_secDelSA_internal returned Error Code %d\n",
+ retValue);
+ netapip_FreeTransInfo(pTransInfo);
+ netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+ }
+ //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)&&(have_to_wait))
+ {
+ 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);
+ *perr = NETAPI_ERR_PA_FW;
+ if (!flags)
+ netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context, tunnelId);
+ printf (">netapi_sec - ERROR returned by NETCP PA firmware %d\n",
+ *perr);
+ return;
+ }
}
- }
- printf (">netapi sec: inflow tunnel %d (iface %d) deleted\n",tunnelId,iface_no);
- pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
- pTransInfo->inUse = nwal_FALSE;
+ printf (">netapi sec: inflow tunnel %d (iface %d) deleted\n",tunnelId,iface_no);
+ netapip_FreeTransInfo(pTransInfo);
}
if (handle_sideband)
{
- retValue=nwal_delDMSecAssoc( ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
+ retValue=nwal_delDMSecAssoc( ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
handle_sideband);
if(retValue != nwal_OK)
{
retValue);
}
- else printf(">netapi_sec: Sideband SA deleted\n");
- }
+ else
+ printf(">netapi_sec: Sideband SA deleted\n");
+ }
//zap the entry
- if (!flags) netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context, tunnelId);
+ if (!flags)
+ netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context, tunnelId);
}
-//external version
+
void netapi_secDelSA(NETAPI_T h,int iface_no, NETCP_CFG_SA_T sa_app_id, int *perr)
{
-netapi_secDelSA_internal( h, iface_no, sa_app_id, 0x00, perr);
+ netapi_secDelSA_internal( h, iface_no, sa_app_id, 0x00, perr);
}
@@ -350,17 +387,17 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the netapi handle
NETCP_CFG_ROUTE_HANDLE_T route, //Optional route
int * perr)
{
-NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
-nwal_RetValue retValue;
-NetapiNwalTransInfo_t *pTransInfo;
-nwal_TransID_t trans_id;
-unsigned int appId = NETAPI_NETCP_MATCH_IPSEC_POLICY | (sa&0xff);
-int policyId;
-int tunnelId= (sa>>8)&0xff;
-void * blah;
-int iface_no = sa&0xff;
-nwalSecPolParams_t createParam =
-{
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
+ nwal_RetValue retValue;
+ NetapiNwalTransInfo_t *pTransInfo;
+ nwal_TransID_t trans_id;
+ unsigned int appId = NETAPI_NETCP_MATCH_IPSEC_POLICY | (sa&0xff);
+ int policyId;
+ int tunnelId= (sa>>8)&0xff;
+ void * blah;
+ int iface_no = sa&0xff;
+ nwalSecPolParams_t createParam =
+ {
0, /* handle */
NWAL_SA_DIR_INBOUND,
4, /* IP Type */
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 */
-};
-void * sa_handle = NULL;
+ };
+ void * sa_handle = NULL;
*perr =0;
if ((!n) ) {*perr = NETAPI_ERR_BAD_INPUT; return -1;}
sa_handle = netcp_cfgp_get_sa_handles(&netapi_get_global()->nwal_context,tunnelId,&blah);
- if (!sa_handle) {*perr = NETAPI_ERR_BAD_INPUT; return -1;}
+ if (!sa_handle)
+ {
+ *perr = NETAPI_ERR_BAD_INPUT;
+ return -1;
+ }
+ //get a transaction id
pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *perr = NETAPI_ERR_BUSY; return -1;}
+ if (!pTransInfo)
+ {
+ *perr = NETAPI_ERR_BUSY;
+ return -1;
+ }
pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA_POLICY;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
pTransInfo->netapi_handle = h;
createParam.handle = sa_handle;
createParam.ipType = ipType;
//reserve a slot
policyId = netcp_cfgp_find_policy_slot(&netapi_get_global()->nwal_context,
tunnelId);
- if (policyId <0) {*perr= NETAPI_ERR_NOMEM; return -1; }
+ if (policyId <0)
+ {
+ *perr= NETAPI_ERR_NOMEM;
+ netapip_FreeTransInfo(pTransInfo);
+ return -1;
+ }
appId |= (policyId<<8);
//fire off config message
- pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
+
retValue = nwal_setSecPolicy (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
trans_id,
*perr = NETAPI_ERR_NWAL_ERR0;
printf (">netapi sec - ERROR: nwal_setPolicy returned Error Code %d\n",
retValue);
- pTransInfo->inUse = nwal_FALSE;
+ netapip_FreeTransInfo(pTransInfo);
+
netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context,policyId);
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,
// 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);
+ *perr = NETAPI_ERR_PA_FW;
+ printf (">netapi_sec - ERROR2: netapi_secAddRxPolicy returned Error Code %d\n",
+ *perr);
+ netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context,policyId);
+ return -1;
+ }
}
printf (">netapi sec: SA %d added to tunnel %d mac %d\n", policyId, tunnelId, iface_no);
netcp_cfgp_insert_policy(&netapi_get_global()->nwal_context,
policyId,
(void *) pTransInfo->handle);
- pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
- pTransInfo->inUse = nwal_FALSE;
+ netapip_FreeTransInfo(pTransInfo);
return (appId);
}
//***********************
static void netapi_secDelRxPolicy_internal(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T policy_app_id, int flags, int *perr)
{
-NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
-nwal_RetValue retValue;
-NetapiNwalTransInfo_t *pTransInfo;
-nwal_TransID_t trans_id;
-int policyId = (policy_app_id >>8) &0xffff;
-void * handle_policy=NULL;
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
+ nwal_RetValue retValue;
+ NetapiNwalTransInfo_t *pTransInfo;
+ nwal_TransID_t trans_id;
+ int policyId = (policy_app_id >>8) &0xffff;
+ void * handle_policy=NULL;
handle_policy = netcp_cfgp_get_policy(&netapi_get_global()->nwal_context,policyId);
;
//get a transaction id
pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *perr = NETAPI_ERR_BUSY; return ;}
+ if (!pTransInfo)
+ {
+ *perr = NETAPI_ERR_BUSY;
+ return -1;
+ }
pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA_POLICY;
+ pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
+ pTransInfo->inUse = nwal_TRUE;
pTransInfo->netapi_handle = h;
//issue request
if(retValue != nwal_OK)
{
*perr = NETAPI_ERR_NWAL_ERR0;
- printf (">netsec - ERROR: nwal_delSAPolicy returned Error Code %d\n",
+ printf (">netapi sec - ERROR: netapi_secDelRxPolicy_internal returned Error Code %d\n",
retValue);
- pTransInfo->inUse = nwal_FALSE;
+ netapip_FreeTransInfo(pTransInfo);
return ;
}
//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_IDLE))
{
- // 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);
+ *perr = NETAPI_ERR_PA_FW;
+ printf (">netapi_sec - ERROR2: netapi_secDelRxPolicy_internal returned Error Code %d\n",
+ *perr);
+ //zap the entry
+ if (!flags)
+ netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context, policyId);
+ return -1;
+
+ }
}
printf (">netapi sec: policy %d (iface %d) deleted\n",policyId,(policy_app_id&0xff));
- pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
- pTransInfo->inUse = nwal_FALSE;
+ netapip_FreeTransInfo(pTransInfo);
//zap the entry
if (!flags) netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context, policyId);
}
//***********************
void netapi_secDelRxPolicy(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T policy_app_id, int *perr)
{
-netapi_secDelRxPolicy_internal(h, policy_app_id, 0, perr);
+ netapi_secDelRxPolicy_internal(h, policy_app_id, 0, perr);
}
index 0d0ed36e8a1981ced24e1c99aee3f73187f46855..957b53341b3cff1f365e059067891d7e42131b0e 100755 (executable)
/******************************************************************
********************Utility*************************************
*******************************************************************/
-
+static hplib_spinLock_T netcp_cfg_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
//get a free transaction id
NetapiNwalTransInfo_t * netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwal_TransID_t *pTransId)
uint16_t count=0;
count=0;
+ hplib_mSpinLockLock(&netcp_cfg_lock);
while(count < TUNE_NETAPI_MAX_NUM_TRANS)
{
if((p_global->nwal_context.transInfos[count].inUse) != nwal_TRUE)
{
p_global->nwal_context.transInfos[count].inUse = nwal_TRUE;
*pTransId = count;
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return(&p_global->nwal_context.transInfos[count]);
}
count++;
}
-
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
/* trouble. need to wait for one to free up*/
/* to do: handle this by forcing a poll of cntrl queue*/
printf(">netcp_cfg: trying to get free transaction slot but all full!!\n");
+
return NULL;
}
+
+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)
{
int i;
if ((tunnel <0 ) || (tunnel >=TUNE_NETAPI_MAX_SA)) return -1;
+ hplib_mSpinLockLock(&netcp_cfg_lock);
//find a free entry
for(i=0;i<TUNE_NETAPI_MAX_POLICY;i++)
{
{
p->policy[i].in_use = 2; //pending
p->policy[i].tunnel= tunnel; //save tunnel this is linked to
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return i;
}
}
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return -1;
}
{
if ((iface <0 ) || (iface >=TUNE_NETAPI_MAX_NUM_MAC)) return -1;
}
+ hplib_mSpinLockLock(&netcp_cfg_lock);
//find a free entry
for(i=0;i<TUNE_NETAPI_MAX_SA;i++)
{
{
p->tunnel[i].in_use = 2; //pending
p->tunnel[i].iface= iface; //save iface
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return i;
}
}
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return -1;
}
//internal: delete an SAr from list
{
int i;
//find a free entry
+ hplib_mSpinLockLock(&netcp_cfg_lock);
for(i=0;i<TUNE_NETAPI_MAX_FLOWS;i++)
{
if (!p->flows[i].in_use)
{
p->flows[i].in_use = 2; //pending
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return i;
}
}
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return -1;
}
{
int i;
*handle=NULL;
+ hplib_mSpinLockLock(&netcp_cfg_lock);
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;
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return i;
}
}
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return -1;
}
int i;
//find a free entry
+ hplib_mSpinLockLock(&netcp_cfg_lock);
for(i=0;i<TUNE_NETAPI_MAX_NUM_IP;i++)
{
if (!p->ips[i].in_use)
{
p->ips[i].in_use = 2; //pending
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return i;
}
}
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return -1;
}
@@ -340,6 +365,7 @@ static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char
p->interfaces[iface_no].state = state;
//todo p->interfaces[iface_no].vlan = vlan;
p->interfaces[iface_no].nwal_handle = handle; //save handle assoicated with this rule
+ printf("netcp_cfgp_insert_mac, global context 0x%x\n", p);
}
else printf(">netcp_cfg insert interface # out of range %d\n",iface_no);
@@ -375,15 +401,18 @@ static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
static int netcp_cfgp_find_class_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
{
int i;
- //find a free entry
+ //find a free entry\
+ hplib_mSpinLockLock(&netcp_cfg_lock);
for(i=0;i<TUNE_NETAPI_MAX_CLASSIFIERS;i++)
{
if (!p->classi[i].in_use)
{
p->classi[i].in_use = 2; //pending
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return i;
}
}
+ hplib_mSpinLockUnlock(&netcp_cfg_lock);
return -1;
}
****************************************************************/
void netcp_cfgReqStats(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((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);
+ }
}
/*****************************************************************
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 */
+ 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;
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;}
+ 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);
{
netcp_cfgp_build_route(route,&MacInfo.appRxPktFlowId, &MacInfo.appRxPktQueue);
}
- 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),
&pTransInfo->handle);
if(retValue != nwal_OK)
{
- *err = NETAPI_ERR_NWAL_ERR0;
+ *err = NETAPI_ERR_NWAL_ERR0;
printf (">netcp cfg - 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;
+ printf (">netcp_cfgCreateMacInterface - 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,
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);
}
//get a transaction id
pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;}
+ 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,
*err = NETAPI_ERR_NWAL_ERR0;
printf (">netcp cfg - 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;
+ printf (">netcp_cfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
+ *err);
+ netcp_cfgp_delete_mac(&netapi_get_global()->nwal_context, iface_no);
+ return -1;
+ }
}
printf (">netcp cfg: MAC i/f %d deleted\n",iface_no);
- pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
- pTransInfo->inUse = nwal_FALSE;
+ netapip_FreeTransInfo(pTransInfo);
//zap the entry
netcp_cfgp_delete_mac(&netapi_get_global()->nwal_context, iface_no);
return ;
if (iface_no != NETCP_CFG_NO_INTERFACE)
{
+ printf("netcp_cfgAddIpInternal, in_use %d\n", netapi_get_global()->nwal_context.interfaces[iface_no].in_use);
+ printf("netcp-cfgAddIpInternal, p 0x%x\n", &netapi_get_global()->nwal_context);
if(netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
{
- n_handle = netapi_get_global()->nwal_context.interfaces[iface_no].nwal_handle;
+ n_handle = netapi_get_global()->nwal_context.interfaces[iface_no].nwal_handle;
}
else
{
//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 (!pTransInfo)
+ {
+ *err = NETAPI_ERR_BUSY;
+ if (flag)
+ {
+ netcp_cfgp_delete_ip(&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
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,
trans_id,
(nwal_AppId) (ip_rule_id),
*err = NETAPI_ERR_NWAL_ERR0;
printf (">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,
+ netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context,
iface_no,
ip_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);
- }
+ 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;
+ printf (">netcp_cfgAddIpInternal - 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,
+ 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);
}
- 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);
}
/*****************************************************************/
@@ -798,8 +879,14 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no, nwal_IpType ipType
//get a transaction id
pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
- if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;}
+ if (!pTransInfo)
+ {
+ *err = NETAPI_ERR_BUSY;
+ return -1;
+ }
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(
@@ -811,27 +898,35 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no, nwal_IpType ipType
*err = NETAPI_ERR_NWAL_ERR0;
printf (">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)
- {
- // 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);
- }
+ 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;
+ printf (">netcp_cfgDelIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
+ return -1;
+ }
}
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;
+ printf (">netcp cfg: Classifier IP rule deleted\n");
+
+ netapip_FreeTransInfo(pTransInfo);
//zap the entry
if (flag)
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;
+
+ //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_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,
if(retValue != nwal_OK)
{
*err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: nwal_addConn returned Error Code %d\n",
+ printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
retValue);
- pTransInfo->inUse = nwal_FALSE;
+ netapip_FreeTransInfo(pTransInfo);
netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot);
return -1;
}
// 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_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;
+ netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot);
+ printf (">netcp_cfgAddClass - ERROR returned by NETCP PA firmware %d\n", *err);
+ return -1;
+ }
}
printf (">netcp cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface_no, ip_slot, class_slot);
netcp_cfgp_insert_class(&netapi_get_global()->nwal_context,
class_slot,
p_class->classType,
- NULL, //L2 we have
- (p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4? l3_handle : NULL),
+ 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;
+
+ netapip_FreeTransInfo(pTransInfo);
+ return classHandle;
} //end switch
return -1;
}
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;
+ 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 );
//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;
+ pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+ if (!pTransInfo)
+ {
+ *err = NETAPI_ERR_BUSY;
+ return -1;
+ }
+ 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,
if(retValue != nwal_OK)
{
*err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: nwal_delConn returned Error Code %d\n",
+ printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
retValue);
- pTransInfo->inUse = nwal_FALSE;
+ netapip_FreeTransInfo(pTransInfo);
return ; /* todo: what about the L3? */
}
//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_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;
+ printf (">netcp_cfgDelClass - ERROR returned by NETCP PA firmware %d\n", *err);
+ return -1;
+ }
printf (">netcp cfg: Classifer deleted\n");
pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
pTransInfo->inUse = nwal_FALSE;
netcp_cfgDelIpInternal( h, 0, 0,
NULL, NULL, 0,
err, L3_handle, 0);
- }
- return ;
+ }
+ netapip_FreeTransInfo(pTransInfo);
+ return ;
}
if(ret != nwal_OK)
{
- printf (">netcp cfg : NWALCmdCallBack returned Error Code %d\n",
- ret);
+ printf (">netcp cfg : netapi_NWALCmdCallBack returned Error Code %d for trans_id %d\n",
+ ret, trans_id);
// update error code that is fialed in p_trans */
//todo: atomic inc
+ p_trans->state = NETAPI_NWAL_HANDLE_STATE_ERR;
netapi_get_global()->nwal_context.numCmdFail++;
}
else
{
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)
{
index 67578d039c6b559c07fbb71367a72a8f5a999d48..e6bc81c21d51fd3648db5476dbc0d543594932e4 100755 (executable)
#include <unistd.h>
#include <string.h>
#include "netapi.h"
+#include "pktio.h"
+#include "netapi_util.h"
+
+
-#ifdef PKTIO_GET_BENCHMARK
-/* for benchmarking .. need to be defined somewhere */
-unsigned int vv7p;
-unsigned int vv8p;
-unsigned int vv9p;
-unsigned int vv10p;
-unsigned int vv11p;
-unsigned int vv12p;
-unsigned int vv13p; //rcv path
-unsigned int vv14p;
-unsigned int vv15p;
-#endif
+
+static hplib_spinLock_T pktio_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
/*--------------------Utilites-----------------*/
{
if (pp[i]->inuse != PKTIO_INUSE)
{
- return pp[i];
+ pp[i]->inuse = PKTIO_INUSE;
+ return pp[i];
}
}
return NULL;
@@ -89,12 +84,12 @@ static int pktio_send_ipc(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METAD
PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
*err=0;
#ifdef PKTIO_GET_BENCHMARK
- vv8p=netapi_timing_stop();
+ p->vv8p=netapi_timing_stop();
#endif
Qmss_queuePushDesc (p->q, (void*)pkt);
#ifdef PKTIO_GET_BENCHMARK
- vv9p=netapi_timing_stop();
+ p->vv9p=netapi_timing_stop();
#endif
return 1;
}
@@ -109,11 +104,11 @@ static int pktio_send_nwal(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_META
*err=0;
pPktInfo->pPkt = pkt;
#ifdef PKTIO_GET_BENCHMARK
- vv11p=netapi_timing_stop();
+ p->vv11p=netapi_timing_stop();
#endif
res=nwal_send(p->nwalInstanceHandle, m->sa_handle,pPktInfo);
#ifdef PKTIO_GET_BENCHMARK
- vv12p=netapi_timing_stop();
+ p->vv12p=netapi_timing_stop();
#endif
if (res != nwal_OK) { *err = NETAPI_ERR_NWAL_TX_ERR -res;}
return 1;
for(r=0;r<n;r++)
{
#ifdef PKTIO_GET_BENCHMARK
- if (r==0) vv7p=netapi_timing_stop();
+ if (r==0) p->vv7p=netapi_timing_stop();
#endif
temp=(Ti_Pkt*)(Cppi_HostDesc*)QMSS_DESC_PTR(Qmss_queuePop(p->q));
#ifdef PKTIO_GET_BENCHMARK
- if (r==0) vv10p=netapi_timing_stop();
+ if (r==0) p->vv10p=netapi_timing_stop();
#endif
if(!temp) break;
/* process meta data */
/* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
set.. optimizaion maybe? */
#ifdef PKTIO_GET_BENCHMARK
- vv13p=netapi_timing_stop();
+ p->vv13p=netapi_timing_stop();
#endif
r=nwal_pollPkt(p->nwalInstanceHandle,
p->poll_flags,
/* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
set.. optimizaion maybe? */
#ifdef PKTIO_GET_BENCHMARK
- vv14p=netapi_timing_stop();
+ p->vv14p=netapi_timing_stop();
#endif
r=nwal_pollPkt(p->nwalInstanceHandle,
nwal_POLL_APP_MANAGED_PKT_Q,
@@ -273,9 +268,10 @@ if ((p_cfg->flags2 & PKTIO_SB) &&(p_cfg->flags1& PKTIO_W)) { *err=NETAPI_ERR_BAD
/* get a free channel handle */
p=pktiop_get_free_channel_slot(n);
+
if (!p) {*err = PKTIO_NOMEM; return (p); }
-p->inuse= PKTIO_INUSE;
+/* p->inuse= PKTIO_INUSE; moved to pktiop_get_free_channel_slot */
p->back = n;
p->cb = cb;
p->max_n = p_cfg->max_n;
(strcmp(name,NETCP_SB_TX)) &&
(p_cfg->flags1 & PKTIO_GLOBAL) )
{
- //todo: make sure this succeeds..
- r=netapi_add_global_pktio(n, name, &p->qInfo);
- }
+ //todo: make sure this succeeds..
+ hplib_mSpinLockLock(&pktio_lock);
+ r=netapi_add_global_pktio(n, name, &p->qInfo);
+ hplib_mSpinLockUnlock(&pktio_lock);
+ }
+
((NETAPI_HANDLE_T *)n )->n_pktios+=1;
return p;
}
if ((!p_cfg)||(!name)) {*err=NETAPI_ERR_BAD_INPUT; return NULL;}
/* get a free channel handle */
+
p=pktiop_get_free_channel_slot(n);
+
if (!p) {*err = PKTIO_NOMEM; return (p); }
((NETAPI_HANDLE_T *)n)->n_pktios+=1;
/* special handling of NETCP_RX, NETCP_TX */
if( (!strcmp(name, NETCP_RX)) || (!strcmp(name,NETCP_TX)) )
{
+ printf("pktio_open: trace 1\n");
/* these have already been opened internally, so don't search in global list */
p->use_nwal = PKTIO_DEF_NWAL;
p->q = 0;
- p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n);
+ p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n);
+ printf("pktio_open1: nwalInstanceHandle 0x%x\n", p->nwalInstanceHandle);
if (!strcmp(name,NETCP_RX))
{
p->_poll=pktio_poll_nwal;
}
else
{
- /* find queue in global list */
- p_qnum = netapi_find_global_pktio(n, name);
+ hplib_mSpinLockLock(&pktio_lock);
+ /* find queue in global list */
+ p_qnum = netapi_find_global_pktio(n, name);
+ printf("pktio_open: trace 2\n");
+
+ hplib_mSpinLockUnlock(&pktio_lock);
if (!p_qnum )
{
printf(">pktio_open: can't find %s\n",name);
return NULL;
}
p->qInfo = Qmss_getQueueNumber(p->q);
+ printf("pktio_open: queueMgr %d\, queueNum; %d\n", p->qInfo.qMgr, p->qInfo.qNum);
if (p_cfg->flags2 & PKTIO_PKT)
{
p->use_nwal = PKTIO_4_ADJ_NWAL; //additonal RX q for nwal
p->_poll = pktio_poll_nwal_adj;
p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n);
+ printf("pktio_open: nwalInstanceHandle 0x%x\n", p->nwalInstanceHandle);
}
else if (p_cfg->flags2 & PKTIO_SB)
{
strlen(name):PKTIO_MAX_NAME);
-
+ printf("pktio_open: returning with sucess for name %s\n", p->name);
return p;
}
if(!p) { *err=1; return;}
*err=0;
/* remove from name list */
+ hplib_mSpinLockLock(&pktio_lock);
netapi_del_global_pktio((NETAPI_HANDLE_T *)p->back, p->name);
+ hplib_mSpinLockUnlock(&pktio_lock);
if((p->use_nwal != PKTIO_DEF_NWAL) && (p->use_nwal != PKTIO_DEF_SB))
{
netapi_zapQ(p->q); //since we are deleting, zap the queue
@@ -526,11 +537,11 @@ int pktio_send_genric(PKTIO_HANDLE_T * p, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int
{
pPktInfo->pPkt = pkt;
#ifdef PKTIO_GET_BENCHMARK
- vv11p=netapi_timing_stop();
+ p->vv11p=netapi_timing_stop();
#endif
res=nwal_send(p->nwalInstanceHandle, m->sa_handle,pPktInfo);
#ifdef PKTIO_GET_BENCHMARK
- vv12p=netapi_timing_stop();
+ p->vv12p=netapi_timing_stop();
#endif
if (res != nwal_OK) { printf("nwal send err= %d (%x)\n", res, res); *err = NETAPI_ERR_NWAL_TX_ERR -res;}
}
@@ -546,12 +557,12 @@ int pktio_send_genric(PKTIO_HANDLE_T * p, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int
/* tod: meta data for non netcp xfers */
/* process meta data */
#ifdef PKTIO_GET_BENCHMARK
- vv8p=netapi_timing_stop();
+ p->vv8p=netapi_timing_stop();
#endif
Qmss_queuePushDesc (p->q, (void*)pkt);
#ifdef PKTIO_GET_BENCHMARK
- vv9p=netapi_timing_stop();
+ p->vv9p=netapi_timing_stop();
#endif
}
return 1;
/* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
set.. optimizaion maybe? */
#ifdef PKTIO_GET_BENCHMARK
- vv13p=netapi_timing_stop();
+ p->vv13p=netapi_timing_stop();
#endif
r=nwal_pollPkt(p->nwalInstanceHandle,
p->poll_flags,
{
/* Poll an additional NETCP RX queue */
#ifdef PKTIO_GET_BENCHMARK
- vv14p=netapi_timing_stop();
+ p->vv14p=netapi_timing_stop();
#endif
r=nwal_pollPkt(p->nwalInstanceHandle,
nwal_POLL_APP_MANAGED_PKT_Q,
for(r=0;r<n;r++)
{
#ifdef PKTIO_GET_BENCHMARK
- if (r==0) vv7p=netapi_timing_stop();
+ if (r==0) p->vv7p=netapi_timing_stop();
#endif
temp=(Ti_Pkt*)(Cppi_HostDesc*)QMSS_DESC_PTR(Qmss_queuePop(p->q));
#ifdef PKTIO_GET_BENCHMARK
- if (r==0) vv10p=netapi_timing_stop();
+ if (r==0) p->vv10p=netapi_timing_stop();
#endif
if(!temp) break;
/* process meta data */
PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
#ifdef PKTIO_GET_BENCHMARK
- vv15p=netapi_timing_stop();
+ p->vv15p=netapi_timing_stop();
#endif
for(r=0;r<numPkts;r++)
{
index c7b13a20f45067482f59396f0a95c4df2f931afd..d5ef58af5a2d1c6326c342f9256ed8ebeea63f7e 100755 (executable)
#endif
- sleep(5);
+ sleep(1);
#ifdef TEST_SA
for (i = 0; i < SA_CREATE_LOOP_COUNT;i++)
&(sa_info[i].rx_data_mode_handle),
&(sa_info[i].rx_inflow_mode_handle),
&err);
- if (err) {printf("addRxSa failed %d\n",err); exit(1);}
+ //if (err) {printf("addRxSa failed %d\n",err); exit(1);}
+ if (err) {printf("addRxSa failed %d\n",err);}
+
- if (config.ipsec_mode_rx == IPSEC_MODE_RX_INFLOW)
- {
- //assume inner and outer ip is the same
- rx_policy[i]= netapi_secAddRxPolicy( netapi_handle,
- sa_info[i].rx_tunnel, //link to tunnel above
- 4, //ipv4
- &config.remote_ipsec_ip, //src -> them
- &config.local_ipsec_ip, //dst -> us
- NULL, // no qualifiers
- NULL, //default route
- &err);
- if (err) {printf("addSaPolicy failed %d, for index %d\n",err,i); exit(1);}
- }
- else
- {
- rx_policy[i] = 0;
- }
}
//tx SA
//security stuff
index 33ecb1a222658d27acd03451839ea9798a917f61..57b5ae58807af0e5c3b96e7a71856b94def6d1b6 100755 (executable)
TRIE_OBJS=$(ARMV7OBJDIR)/netapi/test/trie.o
NT_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test.o $(ARMV7OBJDIR)/netapi/test/stubs.o
NTSA_OBJS= $(ARMV7OBJDIR)/netapi/test/addsa_test.o $(ARMV7OBJDIR)/netapi/test/stubs.o
+NTMT_OBJS= $(ARMV7OBJDIR)/netapi/test/mt_test.o $(ARMV7OBJDIR)/netapi/test/stubs.o
NTB_OBJS= $(ARMV7OBJDIR)/netapi/test/nt_bridge.o $(ARMV7OBJDIR)/netapi/test/stubs.o
# INCLUDE Directories
all: tests
-tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test $(ARMV7BINDIR)/netapi/test/addsa_test
+tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test $(ARMV7BINDIR)/netapi/test/addsa_test $(ARMV7BINDIR)/netapi/test/mt_test
api_clean:
rm -f $(ARMV7LIBDIR)/libnetapi.a
rm -f $(ARMV7BINDIR)/netapi/test/net_test
rm -f $(ARMV7BINDIR)/netapi/test/addsa_test
+ rm -f $(ARMV7BINDIR)/netapi/test/mt_test
$(ARMV7OBJDIR)/netapi/test/%.o:$(NETAPI_INC_DIR)/test/%.c $(ARMV7OBJDIR)/netapi/test/.created
$(ARMV7BINDIR)/netapi/test/addsa_test: $(NTSA_OBJS) $(TRIE_OBJS) $(ARMV7LIBDIR)/libnetapi.a
$(CC) $(LDFLAGS) $(NTSA_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/addsa_test
+$(ARMV7BINDIR)/netapi/test/mt_test: $(NTMT_OBJS) $(TRIE_OBJS) $(ARMV7LIBDIR)/libnetapi.a
+ $(CC) $(LDFLAGS) $(NTMT_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/mt_test
+
diff --git a/ti/runtime/netapi/test/mt_test.c b/ti/runtime/netapi/test/mt_test.c
--- /dev/null
@@ -0,0 +1,1840 @@
+/******************************************
+ * File: net_test.c
+ * Purpose: test app for netapi
+ **************************************************************
+ * FILE: net_test.c
+ *
+ * DESCRIPTION: netapi user space transport
+ * library test application
+ *
+ * REVISION HISTORY: rev 0.0.1
+ *
+ * Copyright (c) Texas Instruments Incorporated 2010-2011
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ *****************************************/
+#define NWAL_ENABLE_SA
+
+//define this for multi-thread
+#define MULTI_THREAD
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <pthread.h>
+
+#include "trie.h"
+#include "string.h"
+#include "netapi.h"
+#include "pktio.h"
+#include <sys/resource.h>
+#include "net_test.h"
+#include <ti/drv/sa/salld.h>
+#include "ti/drv/nwal/nwal_util.h"
+
+
+
+
+#define TEST_SA
+//#define TEST_MAC_IP
+#define SA_CREATE_LOOP_COUNT 64
+#define IP_CREATE_LOOP_COUNT 64
+#define MAC_CREATE_LOOP_COUNT 59
+
+#ifdef MULTI_THREAD
+ //__thread int our_core;
+
+ cpu_set_t cpu_set;
+#endif
+
+long htonl(long x)
+{
+ long temp = (x&0xff000000)>>24 | (x&0xff0000)>>8 | (x&0xff00)<<8 | (x&0xff)<<24 ;
+ return temp;
+}
+
+/* net test default configuration */
+netTestConfig_t config =
+{
+ {0x00,0x01,0x02,0x03,0x05,0x05},
+ {0x00,0x01,0x02,0x03,0x05,0x06},
+ {10, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {10, 0, 1, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {10, 0, 2, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {192,168 , 1, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {192,168 , 1, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ IPSEC_MODE_RX_INFLOW,
+ IPSEC_MODE_TX_INFLOW,
+ 0
+};
+
+#if 0
+netTestConfigMax_t configMax =
+{
+ {{0x00,0x00,0x02,0x03,0x05,0x07},
+ { 0x00,0x01,0x02,0x03,0x05,0x09}},
+ {{0x00,0x02,0x02,0x03,0x05,0x04},
+ { 0x00,0x03,0x02,0x03,0x05,0x03}},
+ {{0x00,0x04,0x02,0x03,0x05,0x07},
+ { 0x00,0x05,0x02,0x03,0x05,0x09}},
+ {{0x00,0x06,0x02,0x03,0x05,0x04},
+ { 0x00,0x07,0x02,0x03,0x05,0x03}},
+ {{0x00,0x08,0x02,0x03,0x05,0x07},
+ { 0x00,0x09,0x02,0x03,0x05,0x09}},
+ {{0x00,0x0a,0x02,0x03,0x05,0x04},
+ { 0x00,0x0b,0x02,0x03,0x05,0x03}},
+ {{0x00,0x0c,0x02,0x03,0x05,0x07},
+ { 0x00,0x0d,0x02,0x03,0x05,0x09}},
+ {{0x00,0x0e,0x02,0x03,0x05,0x04},
+ { 0x00,0x0f,0x02,0x03,0x05,0x03}},
+
+
+ {{0x00,0x10,0x02,0x03,0x05,0x07},
+ { 0x00,0x11,0x02,0x03,0x05,0x09}},
+ {{0x00,0x12,0x02,0x03,0x05,0x04},
+ { 0x00,0x13,0x02,0x03,0x05,0x03}},
+ {{0x00,0x14,0x02,0x03,0x05,0x07},
+ { 0x00,0x15,0x02,0x03,0x05,0x09}},
+ {{0x00,0x16,0x02,0x03,0x05,0x04},
+ { 0x00,0x17,0x02,0x03,0x05,0x03}},
+ {{0x00,0x18,0x02,0x03,0x05,0x07},
+ { 0x00,0x19,0x02,0x03,0x05,0x09}},
+ {{0x00,0x1a,0x02,0x03,0x05,0x04},
+ { 0x00,0x1b,0x02,0x03,0x05,0x03}},
+ {{0x00,0x1c,0x02,0x03,0x05,0x07},
+ { 0x00,0x1d,0x02,0x03,0x05,0x09}},
+ {{0x00,0x1e,0x02,0x03,0x05,0x04},
+ { 0x00,0x1f,0x02,0x03,0x05,0x03}},
+
+ {{0x00,0x10,0x02,0x03,0x05,0x07},
+ { 0x00,0x11,0x02,0x03,0x05,0x09}},
+ {{0x00,0x12,0x02,0x03,0x05,0x04},
+ { 0x00,0x13,0x02,0x03,0x05,0x03}},
+ {{0x00,0x14,0x02,0x03,0x05,0x07},
+ { 0x00,0x15,0x02,0x03,0x05,0x09}},
+ {{0x00,0x16,0x02,0x03,0x05,0x04},
+ { 0x00,0x17,0x02,0x03,0x05,0x03}},
+ {{0x00,0x18,0x02,0x03,0x05,0x07},
+ { 0x00,0x19,0x02,0x03,0x05,0x09}},
+ {{0x00,0x1a,0x02,0x03,0x05,0x04},
+ { 0x00,0x1b,0x02,0x03,0x05,0x03}},
+ {{0x00,0x1c,0x02,0x03,0x05,0x07},
+ { 0x00,0x1d,0x02,0x03,0x05,0x09}},
+ {{0x00,0x1e,0x02,0x03,0x05,0x04},
+ { 0x00,0x1f,0x02,0x03,0x05,0x03}},
+
+
+ {{10, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {10, 0, 1, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
+ {{10, 0, 2, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {10, 0, 3, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
+ {{10, 0, 4, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {10, 0, 5, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
+ {192,168 , 1, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ {192,168 , 1, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ IPSEC_MODE_RX_INFLOW,
+ IPSEC_MODE_TX_INFLOW,
+ 0
+};
+#endif
+
+
+
+
+Trie *p_trie_sa;
+
+static int scnt=0;
+static int QUIT=0;
+void mysig(int x)
+{
+ QUIT=1;
+ scnt+=1;
+ printf(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
+ if (scnt > 10) {printf(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");exit(1);}
+
+}
+
+/*******************************************
+ *************NETAPI OBJECTS***************
+ *****************************************/
+static NETAPI_CFG_T our_netapi_default_cfg=
+{
+TUNE_NETAPI_PERM_MEM_SZ,
+128, //start of packet offset for hw to place data on rx for default flow
+TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
+TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
+TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap
+64, //#descriptors w/o buffers in default heap
+TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap
+128 , //tail room
+256 //extra room
+};
+
+Pktlib_HeapHandle ourHeap;
+Pktlib_HeapHandle specialSmall;
+Pktlib_HeapHandle specialLarge;
+
+PKTIO_HANDLE_T *our_chan;
+PKTIO_HANDLE_T *netcp_rx_chan;
+PKTIO_HANDLE_T *netcp_rx_chan2;
+PKTIO_HANDLE_T *netcp_tx_chan;
+PKTIO_HANDLE_T *netcp_sb_tx_chan;
+PKTIO_HANDLE_T *netcp_sb_rx_chan;
+PKTIO_CFG_T our_chan_cfg={PKTIO_RW, PKTIO_LOCAL, PKTIO_Q_ANY, 8};
+PKTIO_CFG_T netcp_rx_cfg={PKTIO_R, PKTIO_NA, PKTIO_NA, 8};
+PKTIO_CFG_T netcp_rx_cfg2={PKTIO_R, (PKTIO_GLOBAL|PKTIO_PKT), PKTIO_Q_ANY, 8};
+PKTIO_CFG_T netcp_tx_cfg={PKTIO_W, PKTIO_NA, PKTIO_NA, 8};
+PKTIO_CFG_T netcp_sb_rx_cfg={PKTIO_R, PKTIO_NA, PKTIO_NA, 8};
+PKTIO_CFG_T netcp_sb_tx_cfg={PKTIO_W, PKTIO_NA, PKTIO_NA, 8};
+
+void house(NETAPI_SCHED_HANDLE_T *s);
+NETAPI_T netapi_handle;
+#ifdef MULTI_THREAD
+NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
+#endif
+NETAPI_SCHED_HANDLE_T * our_sched;
+
+NETAPI_SCHED_CONFIG_T our_sched_cfg={
+ NETAPI_SCHED_DURATION|NETAPI_SCHED_CBV, 0, house, 5000000 //every 5000000 poll loops
+};
+
+
+NETCP_CFG_IP_T ip_rule0[IP_CREATE_LOOP_COUNT];
+NETCP_CFG_IP_T ip_rule1[IP_CREATE_LOOP_COUNT];
+//NETCP_CFG_IP_T ip_rule0;
+//NETCP_CFG_IP_T ip_rule1;
+
+NETCP_CFG_CLASS_T class_0;
+NETCP_CFG_CLASS_T class_1;
+NETCP_CFG_CLASS_T class_2;
+NETCP_CFG_FLOW_HANDLE_T specialFlow;
+
+
+NETCP_CFG_CLASSIFIER_T class_0_cfg=
+{
+ NETCP_CFG_CLASS_TYPE_L4,
+ {
+ .c_l4={0,0, NWAL_APP_PLOAD_PROTO_UDP, {2500}}
+ }
+};
+
+NETCP_CFG_CLASSIFIER_T class_1_cfg=
+{
+ NETCP_CFG_CLASS_TYPE_L4,
+ {
+ .c_l4= {0,0, NWAL_APP_PLOAD_PROTO_UDP, {2502}}
+ }
+};
+
+NETCP_CFG_ROUTE_T class2_route=
+{
+NULL, NULL //* to be filled in
+};
+NETCP_CFG_CLASSIFIER_T class_2_cfg=
+{
+ NETCP_CFG_CLASS_TYPE_L3_L4,
+ {
+ .c_l3_l4={0, 4 ,0/*fill in below*/ , NULL, NULL, //L2/L3
+ NWAL_APP_PLOAD_PROTO_UDP, {2504}} //L4
+ }
+};
+
+PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
+
+/* security objects. (for loopback mode) */
+netTestSA_t sa_info[SA_CREATE_LOOP_COUNT];
+
+NETCP_CFG_IPSEC_POLICY_T rx_policy[SA_CREATE_LOOP_COUNT];
+
+
+
+NETAPI_SEC_SA_INFO_T rx_sa [14] = {
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x11111111, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_HMAC_SHA1,
+ NWAL_SA_EALG_AES_CBC,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x22222222, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_HMAC_SHA2_256,
+ NWAL_SA_EALG_AES_CTR,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x33333333, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_HMAC_SHA2_256,
+ NWAL_SA_EALG_3DES_CBC,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x44444444, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_HMAC_MD5,
+ NWAL_SA_EALG_NULL,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x55555555, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_NULL,
+ NWAL_SA_EALG_AES_GCM,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x66666666, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_NULL,
+ NWAL_SA_EALG_AES_CCM,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x77777777, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_AES_XCBC,
+ NWAL_SA_EALG_NULL,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x91111111, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_HMAC_SHA1,
+ NWAL_SA_EALG_AES_CBC,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x92222222, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_HMAC_SHA2_256,
+ NWAL_SA_EALG_AES_CTR,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x93333333, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_HMAC_SHA2_256,
+ NWAL_SA_EALG_3DES_CBC,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x94444444, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_HMAC_MD5,
+ NWAL_SA_EALG_NULL,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x95555555, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_NULL,
+ NWAL_SA_EALG_AES_GCM,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x96666666, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_NULL,
+ NWAL_SA_EALG_AES_CCM,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_INBOUND,
+ 0x97777777, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_AES_XCBC,
+ NWAL_SA_EALG_NULL,
+ 0,0 //na
+}
+
+
+
+};
+
+/*tx */
+NETAPI_SEC_SA_INFO_T tx_sa[14]= {
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x11111111, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (us) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (them) -> set below*/
+ 64, /* NA replayWindow */
+ NWAL_SA_AALG_HMAC_SHA1,
+ NWAL_SA_EALG_AES_CBC,
+ 0,0 //seq no
+},
+ {
+ NWAL_SA_DIR_OUTBOUND,
+ 0x22222222, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (us) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (them) -> set below*/
+ 64, /* NA replayWindow */
+ NWAL_SA_AALG_HMAC_SHA2_256,
+ NWAL_SA_EALG_AES_CTR,
+ 0,0 //seq no
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x33333333, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (us) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (them) -> set below*/
+ 64, /* NA replayWindow */
+ NWAL_SA_AALG_HMAC_SHA2_256,
+ NWAL_SA_EALG_3DES_CBC,
+ 0,0 //seq no
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x44444444, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (us) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (them) -> set below*/
+ 64, /* NA replayWindow */
+ NWAL_SA_AALG_HMAC_MD5,
+ NWAL_SA_EALG_NULL,
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x55555555, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_NULL,
+ NWAL_SA_EALG_AES_GCM,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x66666666, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_NULL,
+ NWAL_SA_EALG_AES_CCM,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x77777777, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_AES_XCBC,
+ NWAL_SA_EALG_NULL,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x91111111, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (us) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (them) -> set below*/
+ 64, /* NA replayWindow */
+ NWAL_SA_AALG_HMAC_SHA1,
+ NWAL_SA_EALG_AES_CBC,
+ 0,0 //seq no
+},
+ {
+ NWAL_SA_DIR_OUTBOUND,
+ 0x92222222, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (us) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (them) -> set below*/
+ 64, /* NA replayWindow */
+ NWAL_SA_AALG_HMAC_SHA2_256,
+ NWAL_SA_EALG_AES_CTR,
+ 0,0 //seq no
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x93333333, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (us) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (them) -> set below*/
+ 64, /* NA replayWindow */
+ NWAL_SA_AALG_HMAC_SHA2_256,
+ NWAL_SA_EALG_3DES_CBC,
+ 0,0 //seq no
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x94444444, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (us) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (them) -> set below*/
+ 64, /* NA replayWindow */
+ NWAL_SA_AALG_HMAC_MD5,
+ NWAL_SA_EALG_NULL,
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x95555555, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_NULL,
+ NWAL_SA_EALG_AES_GCM,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x96666666, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_NULL,
+ NWAL_SA_EALG_AES_CCM,
+ 0,0 //na
+},
+{
+ NWAL_SA_DIR_OUTBOUND,
+ 0x97777777, //spi
+ nwal_IpSecProtoESP, //ESP mode
+ nwal_SA_MODE_TUNNEL, //tunnel mode
+ nwal_IPV4, //v4
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Src IP (them) -> set below */
+ { 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* dst IP (us)-> set below*/
+ 64,/* replayWindow */
+ NWAL_SA_AALG_AES_XCBC,
+ NWAL_SA_EALG_NULL,
+ 0,0 //na
+}
+};
+
+
+static nwalSecKeyParams_t ourTXKeyParams[14] ={
+{
+ 32, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt : 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
+ 20, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA1 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 20, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+ 32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 24, /* encKeySize: DES-CBC: 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
+ 32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 0, /* NULL*/
+ 16, /* MD5, 16 bytes */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 20, /* encKeySize: GCM 16 bytes Encryption Key and 4 bytes Salt */
+ 0, /* macKeySize: 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 19, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+ 0, /* macKeySize 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 0, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+ 16, /* macKeySize 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 32, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt : 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
+ 20, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA1 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 20, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+ 32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 24, /* encKeySize: DES-CBC: 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
+ 32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 0, /* NULL*/
+ 16, /* MD5, 16 bytes */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 20, /* encKeySize: GCM 16 bytes Encryption Key and 4 bytes Salt */
+ 0, /* macKeySize: 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 19, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+ 0, /* macKeySize 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 0, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+ 16, /* macKeySize 0*/
+ NULL, //set below
+ NULL, //set below
+}
+};
+
+/* these keys are for aes-ctr and hmac sha2_256 */
+static nwalSecKeyParams_t ourRXKeyParams[14] ={
+{
+ 32, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt : 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
+ 20, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA1 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 20, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt */
+ 32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 24, /* encKeySize: DES-CBC: 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
+ 32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 0, /* NWAL_SA_EALG_NULL*/
+ 16, /* NWAL_SA_AALG_HMAC_MD5, 16 bytes */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 20, /* encKeySize: GCM 16 bytes Encryption Key and 4 bytes Salt */
+ 0, /* macKeySize: 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 19, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt t*/
+ 0, /* macKeySize 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 0, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+ 16, /* macKeySize 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 32, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt : 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
+ 20, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA1 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 20, /* encKeySize: CTR 16 bytes Encryption Key and 4 bytes Salt */
+ 32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 24, /* encKeySize: DES-CBC: 24 bytes:NWAL_SA_EALG_3DES_CBC and 0 bytes Salt*/
+ 32, /* macKeySize: 16 bytes NWAL_SA_AALG_HMAC_SHA2_256 */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 0, /* NWAL_SA_EALG_NULL*/
+ 16, /* NWAL_SA_AALG_HMAC_MD5, 16 bytes */
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 20, /* encKeySize: GCM 16 bytes Encryption Key and 4 bytes Salt */
+ 0, /* macKeySize: 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 19, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt t*/
+ 0, /* macKeySize 0*/
+ NULL, //set below
+ NULL, //set below
+},
+{
+ 0, /* encKeySize: CTR 16 bytes Encryption Key and 3 bytes Salt : 24 bytes:NWAL_SA_EALG_AES_CTR and 0 bytes Salt*/
+ 16, /* macKeySize 0*/
+ NULL, //set below
+ NULL, //set below
+}
+};
+
+
+static uint8_t ourAuthKey[36] =
+ {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x20, 0x21, 0x22, 0x23 };
+;
+
+static uint8_t ourEncrKey[36] =
+ {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
+ 0x30, 0x31, 0x32, 0x33 };
+
+
+/*************************END NETAPI OBJECTS***********************/
+
+#define START_SRC_IP 0x0a00000a
+#define DST_IP 0xc0a80001
+#define NEW_START_SRC_IP 0x9eda000a
+#define DST_PORT 0x555
+#define START_SRC_PORT 0x1234
+#define NEW_START_SRC_PORT 100
+void update_header(HEAD_T * p_head, int len)
+{
+ unsigned char *p = (unsigned char *) &p_head->udp[1];
+ len -= (20+14);
+ /* update ip checksum */
+ /* update udp checksum */
+ /* update length */
+ *p= (len&0xff00)>>8;
+ *(p+1) = len&0xff;
+}
+
+//===========stub transmitter==================
+void send_pkt(Ti_Pkt *pkt, int len)
+{
+//just free pkt. Don't send
+Pktlib_freePacket((Ti_Pkt*)pkt);
+ return;
+}
+
+
+/* check header */
+struct LastPktInfo
+{
+int iface;
+int ipcsum;
+int l4csum;
+} ;
+static struct LastPktInfo lpInfo;
+
+
+void recv_cb_bench(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+ PKTIO_METADATA_T meta[], int n_pkts,
+ uint64_t ts )
+{
+}
+
+/****************************************************************************************/
+/******************SB Accelerator Callback PKT RECEIVE HANDLER *************************/
+/****************** Handles Decrypt and Encrypt operation callbacks ******************/
+/******************************************************************************************/
+void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+ PKTIO_METADATA_T meta[], int n_pkts,
+ uint64_t ts )
+{
+}
+
+/******************************************************/
+/******************PKT RECEIVE HANDLER *************************/
+/******************************************************/
+void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+ PKTIO_METADATA_T meta[], int n_pkts,
+ uint64_t ts )
+{
+}
+
+//******************************************************
+//use scheduling housekeeping callback to generate pkts
+//******************************************************
+static int done_burst=0;
+void house(NETAPI_SCHED_HANDLE_T * s)
+{
+ int err;
+ if (QUIT) {netapi_schedShutdown(s,NULL,&err); return;}
+}
+
+void build_sa_db(int i)
+{
+ long tmp_spi;
+ static uint32_t spi = 11111111;
+ if ((tx_sa[0].authMode == NWAL_SA_AALG_HMAC_SHA1) && (tx_sa[0].cipherMode == NWAL_SA_EALG_AES_CBC))
+ {
+ tx_sa[0].spi = rx_sa[0].spi =spi++;
+ /* static configuration, will not change */
+ sa_info[i].tx_payload_info.aadSize = 0;
+ sa_info[i].tx_payload_info.pAad = NULL;
+ sa_info[i].tx_payload_info.pAuthIV = NULL;
+ sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN; /*done: same for all cipher suites */
+ sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_AES_CBC_IV_LEN;
+
+ /* dynamic configuration, will be calculated on the fly */
+ sa_info[i].tx_payload_info.authSize = 0; /* pkt len - mac - ip -icv (12) */
+ sa_info[i].tx_payload_info.encSize = 0; /* authSize - esp header size (always 8 bytes) */
+ sa_info[i].tx_payload_info.pEncIV = 0;
+ sa_info[i].tx_payload_info.pPkt = 0; /* not being referenced in net_test */
+
+ sa_info[i].cipherMode = NWAL_SA_EALG_AES_CBC;
+ sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].auth_tag_size = netTest_ICV_LEN; /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
+
+ sa_info[i].tx_pkt_info.enetPort = 0;
+ sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+ sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.startOffset = 0;
+ sa_info[i].tx_pkt_info.lpbackPass = 0;
+ sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+ sa_info[i].tx_pkt_info.pPkt = NULL;
+ sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.saPayloadLen = 0;
+ sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+
+ sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+
+ tmp_spi = htonl((long)(tx_sa[0].spi));
+ trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+
+
+ }
+ else if ((tx_sa[i].authMode == NWAL_SA_AALG_HMAC_SHA2_256) && (tx_sa[i].cipherMode == NWAL_SA_EALG_AES_CTR))
+ {
+ tx_sa[i].spi = rx_sa[i].spi =spi++;
+ /* static configuration, will not change */
+ sa_info[i].tx_payload_info.aadSize = 0;
+ sa_info[i].tx_payload_info.pAad = NULL;
+ sa_info[i].tx_payload_info.pAuthIV = NULL;
+ sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN; /*done: same for all cipher suites */
+ sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_AES_CTR_IV_LEN;
+
+
+
+
+ /* dynamic configuration, will be calculated on the fly */
+ sa_info[i].tx_payload_info.authSize = 0;
+ sa_info[i].tx_payload_info.encSize = 0;
+ sa_info[i].tx_payload_info.pEncIV = 0;
+ sa_info[i].tx_payload_info.pPkt = 0;
+
+ sa_info[i].cipherMode = NWAL_SA_EALG_AES_CTR;
+ sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].auth_tag_size = netTest_ICV_LEN; /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
+
+
+ sa_info[i].tx_pkt_info.enetPort = 0;
+ sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+ sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.startOffset = 0;
+ sa_info[i].tx_pkt_info.lpbackPass = 0;
+ sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+ sa_info[i].tx_pkt_info.pPkt = NULL;
+ sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.saPayloadLen = 0;
+ sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+
+ sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+ tmp_spi = htonl((long)(tx_sa[i].spi));
+ trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+ }
+ else if ((tx_sa[i].authMode == NWAL_SA_AALG_HMAC_SHA2_256) && (tx_sa[i].cipherMode == NWAL_SA_EALG_3DES_CBC))
+ {
+ tx_sa[i].spi = rx_sa[i].spi =spi++;
+ /* static configuration, will not change */
+ sa_info[i].tx_payload_info.aadSize = 0;
+ sa_info[i].tx_payload_info.pAad = NULL;
+ sa_info[i].tx_payload_info.pAuthIV = NULL;
+ sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN; /*done: same for all cipher suites */
+ sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_3DES_CBC_IV_LEN;
+
+ /* dynamic configuration, will be calculated on the fly */
+ sa_info[i].tx_payload_info.authSize = 0;
+ sa_info[i].tx_payload_info.encSize = 0;
+ sa_info[i].tx_payload_info.pEncIV = 0;
+ sa_info[i].tx_payload_info.pPkt = 0;
+
+ sa_info[i].cipherMode = NWAL_SA_EALG_3DES_CBC;
+ sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].auth_tag_size = netTest_ICV_LEN; /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
+
+
+ sa_info[i].tx_pkt_info.enetPort = 0;
+ sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+ sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.startOffset = 0;
+ sa_info[i].tx_pkt_info.lpbackPass = 0;
+ sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+ sa_info[i].tx_pkt_info.pPkt = NULL;
+ sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.saPayloadLen = 0;
+ sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+
+ sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+
+ tmp_spi = htonl((long)(tx_sa[i].spi));
+ trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+ }
+ else if ((tx_sa[i].authMode == NWAL_SA_AALG_HMAC_MD5) && (rx_sa[i].cipherMode == NWAL_SA_EALG_NULL))
+ {
+ tx_sa[i].spi = rx_sa[i].spi =spi++;
+ /* static configuration, will not change */
+ sa_info[i].tx_payload_info.aadSize = 0;
+ sa_info[i].tx_payload_info.pAad = NULL;
+ sa_info[i].tx_payload_info.pAuthIV = NULL;
+ sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN; /*done: same for all cipher suites */
+
+ sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_NULL_IV_LEN;
+
+
+
+ /* dynamic configuration, will be calculated on the fly */
+ sa_info[i].tx_payload_info.authSize = 0;
+ sa_info[i].tx_payload_info.encSize = 0;
+ sa_info[i].tx_payload_info.pEncIV = 0;
+ sa_info[i].tx_payload_info.pPkt = 0;
+
+ sa_info[i].cipherMode = NWAL_SA_EALG_NULL;
+ sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].auth_tag_size = netTest_ICV_LEN; /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
+
+ sa_info[i].tx_pkt_info.enetPort = 0;
+ sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+ sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.startOffset = 0;
+ sa_info[i].tx_pkt_info.lpbackPass = 0;
+ sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+ sa_info[i].tx_pkt_info.pPkt = NULL;
+ sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.saPayloadLen = 0;
+ sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+
+ sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+ tmp_spi = htonl((long)(tx_sa[i].spi));
+ trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+ }
+ else if ((tx_sa[i].authMode == NWAL_SA_AALG_NULL) && (rx_sa[i].cipherMode == NWAL_SA_EALG_AES_GCM))
+ {
+ tx_sa[i].spi = rx_sa[i].spi =spi++;
+ /* static configuration, will not change */
+ sa_info[i].tx_payload_info.aadSize = 0;
+ sa_info[i].tx_payload_info.pAad = NULL;
+ sa_info[i].tx_payload_info.pAuthIV = NULL;
+ sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN; /*done: same for all cipher suites */
+ //sa_info[i].tx_payload_info.encIvSize = netTest_AES_GCM_IV_LEN;
+
+ sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_AES_GCM_IV_LEN;
+
+
+
+ /* dynamic configuration, will be calculated on the fly */
+ sa_info[i].tx_payload_info.authSize = 0;
+ sa_info[i].tx_payload_info.encSize = 0;
+ //sa_info[i].tx_payload_info.ploadLen = 0;
+ sa_info[i].tx_payload_info.pEncIV = 0;
+ sa_info[i].tx_payload_info.pPkt = 0;
+
+ sa_info[i].cipherMode = NWAL_SA_EALG_AES_GCM;
+ sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].auth_tag_size = netTest_AES_GCM_CCM_ICV_LEN; /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
+
+ sa_info[i].tx_pkt_info.enetPort = 0;
+ sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+ sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.startOffset = 0;
+ sa_info[i].tx_pkt_info.lpbackPass = 0;
+ sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+ sa_info[i].tx_pkt_info.pPkt = NULL;
+ sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.saPayloadLen = 0;
+ sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+
+ sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+
+ tmp_spi = htonl((long)(tx_sa[i].spi));
+ trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+ }
+ else if ((tx_sa[i].authMode == NWAL_SA_AALG_NULL) && (rx_sa[i].cipherMode == NWAL_SA_EALG_AES_CCM))
+ {
+ tx_sa[i].spi = rx_sa[i].spi =spi++;
+ /* static configuration, will not change */
+ sa_info[i].tx_payload_info.aadSize = 0;
+ sa_info[i].tx_payload_info.pAad = NULL;
+ //sa_info[i].tx_payload_info.authIvSize = 0;
+ sa_info[i].tx_payload_info.pAuthIV = NULL;
+ sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN; /*done: same for all cipher suites */
+
+ sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_AES_CCM_IV_LEN;
+
+ /* dynamic configuration, will be calculated on the fly */
+ sa_info[i].tx_payload_info.authSize = 0;
+ sa_info[i].tx_payload_info.encSize = 0;
+ //sa_info[i].tx_payload_info.ploadLen = 0;
+ sa_info[i].tx_payload_info.pEncIV = 0;
+ sa_info[i].tx_payload_info.pPkt = 0;
+
+ sa_info[i].cipherMode = NWAL_SA_EALG_AES_CCM;
+ sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].auth_tag_size = netTest_AES_GCM_CCM_ICV_LEN; /* icv or mac size,. always 12 except for AES_CCM/AES_GCM */
+
+ sa_info[i].tx_pkt_info.enetPort = 0;
+ sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+ sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.startOffset = 0;
+ sa_info[i].tx_pkt_info.lpbackPass = 0;
+ sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+ sa_info[i].tx_pkt_info.pPkt = NULL;
+ sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.saPayloadLen = 0;
+ sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+
+ sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+
+ tmp_spi = htonl((long)(tx_sa[i].spi));
+ trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+ }
+ else if ((tx_sa[i].authMode == NWAL_SA_AALG_AES_XCBC) && (rx_sa[i].cipherMode == NWAL_SA_EALG_NULL))
+ {
+ tx_sa[i].spi = rx_sa[i].spi =spi++;
+ /* static configuration, will not change */
+ sa_info[i].tx_payload_info.aadSize = 0;
+ sa_info[i].tx_payload_info.pAad = NULL;
+ sa_info[i].tx_payload_info.pAuthIV = NULL;
+ sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
+
+
+ sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_NULL_IV_LEN;
+
+ /* dynamic configuration, will be calculated on the fly */
+ sa_info[i].tx_payload_info.authSize = 0;
+ sa_info[i].tx_payload_info.encSize = 0;
+ //sa_info[i].tx_payload_info.ploadLen = 0;
+ sa_info[i].tx_payload_info.pEncIV = 0;
+ sa_info[i].tx_payload_info.pPkt = 0;
+
+ sa_info[i].cipherMode = NWAL_SA_EALG_NULL;
+ sa_info[i].authMode = NWAL_SA_AALG_AES_XCBC;
+ sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].auth_tag_size = netTest_ICV_LEN; /* icv or mac size,. always 12 except for AES_CCM/AES_GCM , GMAC*/
+
+ sa_info[i].tx_pkt_info.enetPort = 0;
+ sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+ sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN; /*UDP header len */
+ sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.startOffset = 0;
+ sa_info[i].tx_pkt_info.lpbackPass = 0;
+ sa_info[i].tx_pkt_info.ploadLen = 0; /*sa_info[i].tx_pkt_info.l4OffBytes + 4 */
+ sa_info[i].tx_pkt_info.pPkt = NULL;
+ sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
+ sa_info[i].tx_pkt_info.saPayloadLen = 0;
+ sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+
+ sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+
+ tmp_spi = htonl((long)(tx_sa[i].spi));
+ trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
+ }
+ else
+ printf("build_sa_db(): invalid encryption/authentication combination selected\n");
+
+}
+
+
+
+#ifdef MULTI_THREAD
+NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
+void slow_path_thread(int coreid)
+{
+ int err, i, count=0;
+
+ PKTIO_HANDLE_T *our_chan;
+ PKTIO_HANDLE_T *rx_chan;
+ PKTIO_HANDLE_T *tx_chan;
+ PKTIO_HANDLE_T *sb_tx_chan;
+ PKTIO_HANDLE_T *sb_rx_chan;
+
+
+
+ printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
+
+ CPU_ZERO( &cpu_set);
+#ifdef CORTEX_A15
+ CPU_SET( coreid, &cpu_set);
+ hplib_utilSetupCore(coreid, &cpu_set);
+#else
+ CPU_SET( 0, &cpu_set);
+ hplib_utilSetupCore(coreid+1, &cpu_set);
+#endif
+ worker_nh[coreid]=netapi_init(NETAPI_CORE_MASTER,NULL);
+
+
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
+
+ /* open netcp default tx, rx queues */
+ tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg, &err);
+
+
+#ifdef EXPERIMENTAL
+ rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
+#else
+ rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
+#endif
+
+#ifndef EXPERIMENTAL
+ /* create a pktio channel for specially classified pkts */
+ /* open netcp default tx, rx queues for sideband crypto */
+ sb_tx_chan = pktio_open(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
+
+ sb_rx_chan = pktio_open(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
+#endif
+
+
+
+
+
+ netapi_setCookie(worker_nh[coreid],coreid);
+ //our_core = coreid;
+
+ scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
+ if (!scheduler[coreid])
+ {
+ printf("sched create failed for core%d\n",coreid);
+ exit(1);
+ }
+ scheduler[coreid]->config.yield = FALSE;
+ scheduler[coreid]->config.pollGarbageQ = TRUE;
+ scheduler[coreid]->config.pollCtrlQ = TRUE;
+ /*********************************************/
+ /**************Entry point into scheduler ****/
+ /*********************************************/
+
+#ifdef TEST_MAC_IP
+ for (i = 0; i < 30 ;i++)
+ {
+ /* add mac intefaces */
+ netcp_cfgCreateMacInterface(
+ worker_nh[coreid],
+ &config.mac0[0],
+ i,0,
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL,
+ (NETCP_CFG_VLAN_T ) NULL , //future
+ 1,
+ &err);
+ if (err) {printf("addmac0 failed %d\n",err); exit(1); }
+ else
+ {
+ printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
+ config.mac0[3]++;
+ }
+ }
+
+ for (i = 0; i < 30 ;i++)
+ {
+ //attach an IP to this interface
+ ip_rule0[i]=netcp_cfgAddIp(
+ worker_nh[coreid],
+ 0,
+ nwal_IPV4,
+ &config.ip0,
+ NULL, //all IP
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL,
+ &err
+ );
+ if (err) {printf("addip0 failed %d\n",err); exit(1); }
+ else
+ {
+ printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
+ config.ip0.ipv4[3]++;
+ }
+
+ }
+sleep(1);
+ //delete IPs and MAC Interfacess
+ for (i = 0; i < 30;i++)
+ {
+ printf("calling netcp_cfgDelIp and for index %d\n", i);
+ netcp_cfgDelIp(worker_nh[coreid], i, 0, NULL, NULL, ip_rule0[i], &err);
+ netcp_cfgDelMac(worker_nh[coreid],i,&err);
+ }
+ for (i = 0; i < 30;i++)
+ {
+ printf("calling and netcp_cfgDelMac for index %d\n", i);
+ netcp_cfgDelMac(worker_nh[coreid],i,&err);
+ }
+#endif
+
+#ifdef TEST_SA
+ for (i = 0; i < 32;i++)
+ {
+ ourRXKeyParams[0].pEncKey = &ourEncrKey[0];
+ ourRXKeyParams[0].pAuthKey = &ourAuthKey[0];
+ memcpy(&(rx_sa[0].src), &config.remote_ipsec_ip,4);
+ memcpy(&(rx_sa[0].dst), &config.local_ipsec_ip,4);
+
+ build_sa_db(i);
+ count++;
+ //printf("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid, count);
+ sa_info[i].rx_tunnel = netapi_secAddSA(
+ worker_nh[coreid],
+ config.ipsec_if_no, //iface #0
+ &rx_sa[0],
+ &ourRXKeyParams[0],
+ config.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND ? NETAPI_SEC_SA_SIDEBAND: NETAPI_SEC_SA_INFLOW,
+ NULL, //use default route
+ &(sa_info[i].rx_data_mode_handle),
+ &(sa_info[i].rx_inflow_mode_handle),
+ &err);
+ //if (err) {printf("addRxSa failed %d\n",err); exit(1);}
+ if (err) {printf("addRxSa failed %d\n",err);}
+
+
+ }
+//tx SA
+//security stuff
+ count = 0;
+ for (i = 0; i <32;i++)
+ {
+ ourTXKeyParams[0].pEncKey = &ourEncrKey[0];
+ ourTXKeyParams[0].pAuthKey = &ourAuthKey[0];
+ memcpy(&(tx_sa[0].src), &config.local_ipsec_ip,4);
+ memcpy(&(tx_sa[0].dst), &config.remote_ipsec_ip,4);
+ count++;
+ //printf("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid, count);
+ sa_info[i].tx_tunnel = netapi_secAddSA( worker_nh[coreid],
+ 0, //iface #0
+ &tx_sa[0],
+ &ourTXKeyParams[0],
+ config.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND ? NETAPI_SEC_SA_SIDEBAND: NETAPI_SEC_SA_INFLOW,
+ NULL, //use default route
+ &(sa_info[i].tx_data_mode_handle),
+ &(sa_info[i].tx_inflow_mode_handle),
+ &err);
+ if (err) {printf("addTxSa failed %d\n",err); exit(1);}
+ }
+sleep(1);
+count = 0;
+#ifdef TEST_SA
+ for (i = 0; i < 32;i++)
+ {
+ if (rx_policy[i])
+ netapi_secDelRxPolicy(worker_nh[coreid], rx_policy[i], &err);
+ count ++;
+ //delete tunnels
+ printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
+ netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].rx_tunnel, &err);
+ //sleep(1);
+ //printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
+ netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].tx_tunnel, &err);
+ }
+#endif
+#endif
+
+
+ netapi_schedWaitForEvents(scheduler[coreid], &err);
+
+ printf(">net_test: core %d worker thread done\n",coreid);
+ pktio_close(tx_chan, &err);
+ pktio_close(rx_chan, &err);
+ pktio_close(sb_tx_chan, &err);
+ pktio_close(sb_tx_chan, &err);
+ netapi_shutdown(worker_nh[coreid]);
+}
+
+void fast_path_thread(int coreid)
+{
+ int err, i, count=0;
+ PKTIO_HANDLE_T *our_chan;
+ PKTIO_HANDLE_T *rx_chan;
+ PKTIO_HANDLE_T *tx_chan;
+ PKTIO_HANDLE_T *sb_tx_chan;
+ PKTIO_HANDLE_T *sb_rx_chan;
+
+ printf("fast_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
+#ifdef CORTEX_A15
+ CPU_SET( coreid, &cpu_set);
+ hplib_utilSetupCore(coreid, &cpu_set);
+#else
+ CPU_SET( 0, &cpu_set);
+ hplib_utilSetupCore(coreid + 1, &cpu_set);
+#endif
+ worker_nh[coreid]=netapi_init(NETAPI_CORE_MASTER,NULL);
+
+
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
+
+ /* open netcp default tx, rx queues */
+ tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg, &err);
+
+
+#ifdef EXPERIMENTAL
+ rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
+#else
+ rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
+#endif
+
+#ifndef EXPERIMENTAL
+ /* create a pktio channel for specially classified pkts */
+ /* open netcp default tx, rx queues for sideband crypto */
+ sb_tx_chan = pktio_open(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
+
+ sb_rx_chan = pktio_open(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
+#endif
+
+ netapi_setCookie(worker_nh[coreid],coreid);
+ //our_core = coreid;
+ scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
+ if (!scheduler[coreid])
+ {
+ printf("sched create failed for core%d\n",coreid);
+ exit(1);
+ }
+
+ /*********************************************/
+ /**************Entry point into scheduler ****/
+ /*********************************************/
+ scheduler[coreid]->config.yield = FALSE;
+ scheduler[coreid]->config.pollGarbageQ = FALSE;
+ scheduler[coreid]->config.pollCtrlQ = FALSE;
+ //sleep(100000);
+#ifdef TEST_MAC_IP
+ for (i = 30; i < MAC_CREATE_LOOP_COUNT ;i++)
+ {
+ /* add mac intefaces */
+ netcp_cfgCreateMacInterface(
+ worker_nh[coreid],
+ &config.mac0[0],
+ i,0,
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL,
+ (NETCP_CFG_VLAN_T ) NULL , //future
+ 1,
+ &err);
+ if (err) {printf("addmac0 failed %d\n",err); exit(1); }
+ else
+ {
+ printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
+ config.mac0[3]++;
+ }
+ }
+
+ for (i = 30; i < IP_CREATE_LOOP_COUNT ;i++)
+ {
+ //attach an IP to this interface
+ ip_rule0[i]=netcp_cfgAddIp(
+ worker_nh[coreid],
+ 30,
+ nwal_IPV4,
+ &config.ip0,
+ NULL, //all IP
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL,
+ &err
+ );
+ if (err) {printf("addip0 failed %d\n",err); exit(1); }
+ else
+ {
+ printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
+ config.ip0.ipv4[3]++;
+ }
+
+ }
+sleep(1);
+ //delete IPs and MAC Interfacess
+ for (i = 30; i < IP_CREATE_LOOP_COUNT;i++)
+ {
+ printf("calling netcp_cfgDelIp and for index %d\n", i);
+ netcp_cfgDelIp(worker_nh[coreid], i, 0, NULL, NULL, ip_rule0[i], &err);
+ netcp_cfgDelMac(worker_nh[coreid],i,&err);
+ }
+ for (i = 30; i < MAC_CREATE_LOOP_COUNT;i++)
+ {
+ printf("calling and netcp_cfgDelMac for index %d\n", i);
+ netcp_cfgDelMac(worker_nh[coreid],i,&err);
+ }
+#endif
+
+
+#ifdef TEST_SA
+ for (i = 32; i < SA_CREATE_LOOP_COUNT-1;i++)
+ {
+ ourRXKeyParams[0].pEncKey = &ourEncrKey[0];
+ ourRXKeyParams[0].pAuthKey = &ourAuthKey[0];
+ memcpy(&(rx_sa[0].src), &config.remote_ipsec_ip,4);
+ memcpy(&(rx_sa[0].dst), &config.local_ipsec_ip,4);
+
+ build_sa_db(i);
+ count++;
+ //printf("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid, count);
+ sa_info[i].rx_tunnel = netapi_secAddSA(
+ worker_nh[coreid],
+ config.ipsec_if_no, //iface #0
+ &rx_sa[0],
+ &ourRXKeyParams[0],
+ config.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND ? NETAPI_SEC_SA_SIDEBAND: NETAPI_SEC_SA_INFLOW,
+ NULL, //use default route
+ &(sa_info[i].rx_data_mode_handle),
+ &(sa_info[i].rx_inflow_mode_handle),
+ &err);
+ //if (err) {printf("addRxSa failed %d\n",err); exit(1);}
+ if (err) {printf("addRxSa failed %d\n",err);}
+
+
+ }
+ count = 0;
+//tx SA
+//security stuff
+ for (i = 32; i <SA_CREATE_LOOP_COUNT-1;i++)
+ {
+ ourTXKeyParams[0].pEncKey = &ourEncrKey[0];
+ ourTXKeyParams[0].pAuthKey = &ourAuthKey[0];
+ memcpy(&(tx_sa[0].src), &config.local_ipsec_ip,4);
+ memcpy(&(tx_sa[0].dst), &config.remote_ipsec_ip,4);
+ count++;
+ //printf("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid, count);
+ sa_info[i].tx_tunnel = netapi_secAddSA( worker_nh[coreid],
+ 0, //iface #0
+ &tx_sa[0],
+ &ourTXKeyParams[0],
+ config.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND ? NETAPI_SEC_SA_SIDEBAND: NETAPI_SEC_SA_INFLOW,
+ NULL, //use default route
+ &(sa_info[i].tx_data_mode_handle),
+ &(sa_info[i].tx_inflow_mode_handle),
+ &err);
+ if (err) {printf("addTxSa failed %d\n",err); exit(1);}
+ }
+
+sleep(1);
+ count = 0;
+//#ifdef TEST_SA
+ for (i = 32; i < SA_CREATE_LOOP_COUNT-1;i++)
+ {
+ if (rx_policy[i])
+ netapi_secDelRxPolicy(worker_nh[coreid], rx_policy[i], &err);
+ count ++;
+ //delete tunnels
+ //printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
+ netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].rx_tunnel, &err);
+ //sleep(1);
+ //printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
+ netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].tx_tunnel, &err);
+ }
+#endif
+
+ netapi_schedWaitForEvents(scheduler[coreid], &err);
+ printf(">net_test: core %d worker thread done\n",coreid);
+ pktio_close(tx_chan, &err);
+ pktio_close(rx_chan, &err);
+ pktio_close(sb_tx_chan, &err);
+ pktio_close(sb_tx_chan, &err);
+ netapi_shutdown(worker_nh[coreid]);
+}
+
+#endif
+//#endif
+
+/***************************************
+ ********** test driver*****************
+ ***************************************/
+int main(int argc, char **argv)
+{
+ int err,i, j, count;
+ Pktlib_HeapCfg heapCfg;
+ rlim_t oss,ss = 1024*1024;
+ struct rlimit rl;
+ int32_t errCode;
+ Pktlib_HeapIfTable* pPktifTable;
+
+
+ FILE * fpr = NULL;
+
+
+ err= getrlimit(RLIMIT_STACK,&rl);
+ if (!err) printf(" stack limit = %d\n",rl.rlim_cur); else printf("getrlimit failed\n");
+
+
+ memset(&sa_info, 0, sizeof(sa_info));
+
+ /* create netapi */
+ netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
+
+ /* open the main heap */
+ ourHeap = Pktlib_findHeapByName("netapi");
+ if (!ourHeap)
+ {
+ printf("Pktlib_findHeapByName() fail\n");
+ exit(1);
+ }
+
+ /* create two secondary heaps */
+ /* Initialize the heap configuration. */
+ memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
+
+ pPktifTable = netapi_getPktlibIfTable();
+ /* Populate the heap configuration */
+ heapCfg.name = "netapi-small";
+ heapCfg.memRegion = NETAPI_GLOBAL_REGION;
+ heapCfg.sharedHeap = 1;
+ heapCfg.useStarvationQueue = 0;
+ heapCfg.dataBufferSize = 512;
+ heapCfg.numPkts = 64;
+ heapCfg.numZeroBufferPackets= 0;
+ heapCfg.heapInterfaceTable.data_malloc = pPktifTable->data_malloc;
+ heapCfg.heapInterfaceTable.data_free = pPktifTable->data_free;
+ heapCfg.dataBufferPktThreshold = 0;
+ heapCfg.zeroBufferPktThreshold = 0;
+
+ specialSmall = Pktlib_createHeap(&heapCfg, &errCode);
+ heapCfg.name = "netapi-big";
+ heapCfg.dataBufferSize = 1600;
+ specialLarge = Pktlib_createHeap(&heapCfg, &errCode);
+ //register these heaps so poll routine will include their garbage queues.
+ netapi_registerHeap(netapi_handle, specialSmall);
+ netapi_registerHeap(netapi_handle, specialLarge);
+
+ /* create a pktio channel */
+ our_chan=pktio_create(netapi_handle,"our1stq",(PKTIO_CB) recv_cb_bench, &our_chan_cfg,&err);
+ if (!our_chan)
+ {
+ printf("pktio create failed err=%d\n",err);
+ exit(1);
+ }
+
+ /* open netcp default tx, rx queues */
+ netcp_tx_chan= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan)
+ {
+ printf("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ netcp_rx_chan= pktio_open(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
+
+ if (!netcp_rx_chan)
+ {
+ printf("pktio open RX failed err=%d\n",err);
+ exit(1);
+ }
+
+ /* create a pktio channel for specially classified pkts */
+ netcp_rx_chan2= pktio_create(netapi_handle, "classq", (PKTIO_CB) recv_cb, &netcp_rx_cfg2, &err);
+ if (!netcp_rx_chan2) {printf("pktio create RX2 failed err=%d\n",err); exit(1);}
+
+ /* open netcp default tx, rx queues for sideband crypto */
+ netcp_sb_tx_chan= pktio_open(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
+ if (!netcp_sb_tx_chan)
+ {
+ printf("pktio open SB TX failed err=%d\n",err);
+ exit(1);
+ }
+ netcp_sb_rx_chan= pktio_open(netapi_handle, NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
+ if (!netcp_sb_rx_chan)
+ {
+ printf("pktio open SB RX failed err=%d\n",err);
+ exit(1);
+ }
+
+ printf("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
+ /* create scheduler instance */
+ our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
+ if (!our_sched) {printf("sched create failed\n"); exit(1);}
+
+ //#define PROMISCUOUS
+#define ETH0 0
+#define ETH1 1
+
+//security stuff
+ p_trie_sa = trie_new();
+ if (!p_trie_sa) {printf("trie alloc for SA failed\n"); exit(1);}
+
+
+#ifdef MULTI_THREAD
+{
+ CPU_ZERO( &cpu_set );
+ pthread_t *thrs;
+ int procs =2; //get this from config eventually
+ char c;
+ thrs = malloc( sizeof( pthread_t ) * procs );
+ if (thrs == NULL)
+ {
+ perror( "malloc" );
+ return -1;
+ }
+ printf( "Starting %d threads...\n", procs );
+
+ if (pthread_create( &thrs[0], NULL, slow_path_thread,
+ (void *)0 ))
+ {
+ perror( "pthread_create" );
+ exit(1);
+ }
+ if (pthread_create( &thrs[1], NULL, fast_path_thread,
+ (void *)1 ))
+ {
+ perror( "pthread_create" );
+ exit(1);
+ }
+
+ //this thread of execution (main) now just waits on user input
+ for(;;)
+ {
+ printf(">");
+ c=getchar();
+ if (c=='q')
+ {
+ QUIT=1;
+ break;
+ }
+ //else if (c=='s') our_stats_cb(netapi_handle, &netcp_stats);
+ else if (c=='h') printf("'q' to quit, 's' for stats, 'h' for help\n");
+ }
+
+ //wait for completion
+ printf("main task now pending on slow/fast path completion\n");
+ for (i = 0; i < procs; i++)
+ pthread_join( thrs[i], NULL );
+
+ free( thrs );
+}
+#else
+ /*********************************************/
+ /**************Entry point into scheduler ****/
+ /*********************************************/
+ netapi_schedWaitForEvents(our_sched, &err);
+
+#endif
+
+
+
+
+
+
+
+
+
+#if 0
+ //create specialFlow for this classifier
+ {
+ Pktlib_HeapHandle heaps[2];
+ //int sizes[2];
+ heaps[0]= specialSmall;
+ heaps[1]= specialLarge;
+#define SPECIAL_SOP_OFF 128
+ // sizes[0]=512-SPECIAL_SOP_OFF;
+ //sizes[1]=1600-SPECIAL_SOP_OFF;
+ }
+#endif
+
+ count = 0;
+ //sleep(1);
+
+ /*************************************************
+ ************CLEAN UP****************************
+ ************************************************/
+
+ //delete Classifiers
+ netcp_cfgDelClass(netapi_handle, class_0, &err);
+ netcp_cfgDelClass(netapi_handle, class_1, &err);
+ //netcp_cfgDelClass(netapi_handle, class_2, &err);
+
+ count = 0;
+ //close pktio channels we opened
+ printf("main: calling pktio_close for netcp_tx_chan\n");
+ pktio_close(netcp_tx_chan ,&err);
+ printf("main: calling pktio_close for netcp_rx_chan\n");
+ pktio_close(netcp_rx_chan ,&err);
+ printf("main: calling pktio_close for netcp_sb_tx_chan\n");
+ pktio_close(netcp_sb_tx_chan ,&err);
+ printf("main: calling pktio_close for netcp_sb_rx_chan\n");
+ pktio_close(netcp_sb_rx_chan ,&err);
+
+ //clear pktio channel we created
+ pktio_control(our_chan, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
+ pktio_control(netcp_rx_chan2, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
+
+ //delete pktio channels we created
+ pktio_delete(our_chan, &err);
+ pktio_delete(netcp_rx_chan2,&err);
+ netapi_shutdown(netapi_handle);
+
+}
+
+
+
+
index 50a73c3f8021463aef581e991ab6fd912b7d8d1e..33208dddeb9a17f29067f96793381b3d2ae61b76 100755 (executable)
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************/
+#define DAL_REVIEW
//#define NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
#define NWAL_ENABLE_SA
+
OUR_ROUTE_T routes[MAX_ROUTES]=
{
{0,{0xD4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x14,0x02,0x08,0x00},0},
#endif
#ifdef MULTI_THREAD
-__thread int our_core;
+ //__thread int our_core;
+
cpu_set_t cpu_set;
#endif
int check_header(HEAD_T * p_head, PKTIO_METADATA_T * p_meta)
{
#ifdef MULTI_THREAD
- int coreid=our_core; //who we are(thread local)
+ int coreid=Osal_nwalGetProcId(); //who we are(thread local)
+ //int coreid = our_core;
#else
int coreid=0;
#endif
unsigned int vv4;
unsigned int vv5;
unsigned int vv6;
-//these are updated by pktio.
-#ifdef PKTIO_GET_BENCHMARK
-extern unsigned int vv7p;
-extern unsigned int vv8p;
-extern unsigned int vv9p;
-extern unsigned int vv10p;
-extern unsigned int vv11p;
-extern unsigned int vv12p;
-extern unsigned int vv13p; //rcv path
-extern unsigned int vv14p;
-extern unsigned int vv15p;
-#endif
unsigned int vv11;
timings[8]+=(vv11-vv6);
#ifdef PKTIO_GET_BENCHMARK
- timings[2]+=(vv7p-vv4);
- timings[4]+=(vv8p-vv3);
- timings[6]+=(vv9p-vv8p);
- timings[7]+=(vv10p-vv7p);
+ timings[2]+=(our_chan->vv7p-vv4);
+ timings[4]+=(our_chan->vv8p-vv3);
+ timings[6]+=(our_chan->vv9p-our_chan->vv8p);
+ timings[7]+=(our_chan->vv10p-our_chan->vv7p);
#endif
}
Cppi_HostDesc* pPloadDesc;
#ifdef MULTI_THREAD
-int coreid=our_core; //who we are(thread local)
+ int coreid=Osal_nwalGetProcId(); //who we are(thread local)
+ //int coreid = our_core;
#else
int coreid=0;
#endif
netTestSA_t *p_sa_info;
#ifdef MULTI_THREAD
-int coreid=our_core; //who we are(thread local)
+ int coreid=Osal_nwalGetProcId(); //who we are(thread local)
+ //int coreid = our_core;
#else
int coreid=0;
#endif
Cppi_HostDesc* pPloadDesc;
int ifno;
#ifdef MULTI_THREAD
-int coreid=our_core; //who we are(thread local)
+ int coreid=Osal_nwalGetProcId(); //who we are(thread local)
+ //int coreid = our_core;
#else
int coreid=0;
#endif
for(i=0;i<n_pkts;i++)
{
ifno = ((unsigned int)meta[i].u.rx_meta->appId)&0xff;
- if(coreid<TUNE_NETAPI_NUM_CORES) stats[coreid].rx+=1;
- if (ifno < TUNE_NETAPI_MAX_NUM_MAC) stats[coreid].if_rx[ifno]+=1;
-
tip = p_recv[i];
Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);/*ignore templen */
printf(" rcv_cb, nexpkt != NULL");
}
- stats[coreid].rx+=1;
+ if(coreid<TUNE_NETAPI_NUM_CORES)
+ stats[coreid].rx+=1;
+ if (ifno < TUNE_NETAPI_MAX_NUM_MAC)
+ stats[coreid].if_rx[ifno]+=1;
+
#ifdef DEBUG_DESC
if (stats[coreid].rx<16)
int err;
unsigned long long et;
#ifdef MULTI_THREAD
- int coreid=our_core; //who we are(thread local)
+ int coreid=Osal_nwalGetProcId(); //who we are(thread local)
+ //int coreid = our_core;
#else
int coreid=0;
#endif
{
#ifdef MULTI_THREAD
-int coreid=our_core; //who we are(thread local)
+ int coreid=Osal_nwalGetProcId(); //who we are(thread local)
+ //int coreid = our_core;
#else
int coreid=0;
#endif
}
#ifdef MULTI_THREAD
-netapi_sched_get_stats(scheduler[0],&tmp_npL[0],&tmp_cyclesL[0],&tmp_ccyclesL[0]);
-netapi_sched_get_stats(scheduler[1],&tmp_npL[1],&tmp_cyclesL[1],&tmp_ccyclesL[1]);
+ netapi_sched_get_stats(scheduler[0],&tmp_npL[0],&tmp_cyclesL[0],&tmp_ccyclesL[0]);
+ netapi_sched_get_stats(scheduler[1],&tmp_npL[1],&tmp_cyclesL[1],&tmp_ccyclesL[1]);
npL = tmp_npL[0]+tmp_npL[1];
cyclesL = tmp_cyclesL[0]+tmp_cyclesL[1];
ccyclesL = tmp_ccyclesL[0]+tmp_ccyclesL[1];
{
int err;
- printf("slow_path_thread, mypid: %d\n", gettid());
+ PKTIO_HANDLE_T *our_chan;
+ PKTIO_HANDLE_T *rx_chan;
+ PKTIO_HANDLE_T *tx_chan;
+ PKTIO_HANDLE_T *sb_tx_chan;
+ PKTIO_HANDLE_T *sb_rx_chan;
+
+
+
+ printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
CPU_ZERO( &cpu_set);
-#ifdef CORTEX_15
+#ifdef CORTEX_A15
CPU_SET( coreid, &cpu_set);
hplib_utilSetupCore(coreid, &cpu_set);
#else
CPU_SET( 0, &cpu_set);
- hplib_utilSetupCore(0, &cpu_set);
+ hplib_utilSetupCore(coreid+1, &cpu_set);
#endif
- worker_nh[coreid]=netapi_init(NETAPI_NO_MASTER,NULL);
+ worker_nh[coreid]=netapi_init(NETAPI_CORE_MASTER,NULL);
+
+#ifdef DAL_REVIEW
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
+
+ /* open netcp default tx, rx queues */
+ tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg, &err);
+
+
+#ifdef EXPERIMENTAL
+ rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
+#else
+ rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
+#endif
+
+#ifndef EXPERIMENTAL
+ /* create a pktio channel for specially classified pkts */
+ /* open netcp default tx, rx queues for sideband crypto */
+ sb_tx_chan = pktio_open(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
+
+ sb_rx_chan = pktio_open(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
+#endif
+
+#endif
+
+
+
netapi_setCookie(worker_nh[coreid],coreid);
- our_core=coreid;
+ //our_core = coreid;
+
scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
if (!scheduler[coreid])
{
printf("sched create failed for core%d\n",coreid);
exit(1);
}
+ scheduler[coreid]->config.yield = FALSE;
+ scheduler[coreid]->config.pollGarbageQ = TRUE;
+ scheduler[coreid]->config.pollCtrlQ = TRUE;
/*********************************************/
/**************Entry point into scheduler ****/
/*********************************************/
netapi_schedWaitForEvents(scheduler[coreid], &err);
printf(">net_test: core %d worker thread done\n",coreid);
+ pktio_close(tx_chan, &err);
+ pktio_close(rx_chan, &err);
+ pktio_close(sb_tx_chan, &err);
+ pktio_close(sb_tx_chan, &err);
netapi_shutdown(worker_nh[coreid]);
}
void fast_path_thread(int coreid)
{
int err;
+ PKTIO_HANDLE_T *our_chan;
+ PKTIO_HANDLE_T *rx_chan;
+ PKTIO_HANDLE_T *tx_chan;
+ PKTIO_HANDLE_T *sb_tx_chan;
+ PKTIO_HANDLE_T *sb_rx_chan;
- #ifdef CORTEX_15
+#ifdef CORTEX_A15
CPU_SET( coreid, &cpu_set);
hplib_utilSetupCore(coreid, &cpu_set);
#else
CPU_SET( 0, &cpu_set);
- hplib_utilSetupCore(0, &cpu_set);
+ hplib_utilSetupCore(coreid + 1, &cpu_set);
#endif
- printf("fast_path_thread, mypid: %d\n", gettid());
- hplib_utilSetupCore(coreid, &cpu_set);
- worker_nh[coreid]=netapi_init(NETAPI_NO_MASTER,NULL);
+ worker_nh[coreid]=netapi_init(NETAPI_CORE_MASTER,NULL);
+
+#ifdef DAL_REVIEW
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
+
+ /* open netcp default tx, rx queues */
+ tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg, &err);
+
+
+#ifdef EXPERIMENTAL
+ rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
+#else
+ rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
+#endif
+
+#ifndef EXPERIMENTAL
+ /* create a pktio channel for specially classified pkts */
+ /* open netcp default tx, rx queues for sideband crypto */
+ sb_tx_chan = pktio_open(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
+
+ sb_rx_chan = pktio_open(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
+#endif
+
+#endif
+
+
netapi_setCookie(worker_nh[coreid],coreid);
- our_core=coreid;
+ //our_core = coreid;
scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
if (!scheduler[coreid])
{
/*********************************************/
/**************Entry point into scheduler ****/
/*********************************************/
+ scheduler[coreid]->config.yield = FALSE;
+ scheduler[coreid]->config.pollGarbageQ = FALSE;
+ scheduler[coreid]->config.pollCtrlQ = FALSE;
+ //sleep(100000);
netapi_schedWaitForEvents(scheduler[coreid], &err);
printf(">net_test: core %d worker thread done\n",coreid);
+ pktio_close(tx_chan, &err);
+ pktio_close(rx_chan, &err);
+ pktio_close(sb_tx_chan, &err);
+ pktio_close(sb_tx_chan, &err);
netapi_shutdown(worker_nh[coreid]);
}
#define ETH1 1
#endif
-
-
/* add mac intefaces */
netcp_cfgCreateMacInterface(
netapi_handle,
perror( "pthread_create" );
exit(1);
}
+#if 1
if (pthread_create( &thrs[1], NULL, fast_path_thread,
(void *)1 ))
{
perror( "pthread_create" );
exit(1);
}
-
+#endif
//this thread of execution (main) now just waits on user input
for(;;)
{
free( thrs );
}
#else
-
-
-/*********************************************/
-/**************Entry point into scheduler ****/
-/*********************************************/
-netapi_schedWaitForEvents(our_sched, &err);
+ /*********************************************/
+ /**************Entry point into scheduler ****/
+ /*********************************************/
+ netapi_schedWaitForEvents(our_sched, &err);
#endif
int ifno;
int out_port;
#ifdef MULTI_THREAD
-int coreid=our_core; //who we are(thread local)
+ int coreid=Osal_nwalGetProcId(); //who we are(thread local)
+ //int coreid = our_core;
#else
int coreid=0;
#endif