summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 379d0f9)
raw | patch | inline | side by side (parent: 379d0f9)
author | Tinku Mannan <tmannan@ti.com> | |
Tue, 18 Dec 2012 15:35:56 +0000 (10:35 -0500) | ||
committer | Tinku Mannan <tmannan@ti.com> | |
Tue, 18 Dec 2012 15:35:56 +0000 (10:35 -0500) |
15 files changed:
ti/runtime/netapi/netapi_timer.h | [deleted file] | patch | blob | history |
ti/runtime/netapi/netapi_tune.h | patch | blob | history | |
ti/runtime/netapi/src/netapi.c | patch | blob | history | |
ti/runtime/netapi/src/netapi_init.c | patch | blob | history | |
ti/runtime/netapi/src/netapi_loc.h | patch | blob | history | |
ti/runtime/netapi/src/netapi_sched.c | patch | blob | history | |
ti/runtime/netapi/src/netapi_timer.c | [deleted file] | patch | blob | history |
ti/runtime/netapi/src/netcp_cfg.c | patch | blob | history | |
ti/runtime/netapi/src/tim64.c | [deleted file] | patch | blob | history |
ti/runtime/netapi/src/timer_loc.h | [deleted file] | patch | blob | history |
ti/runtime/netapi/src/timlist.c | [deleted file] | patch | blob | history |
ti/runtime/netapi/test/addsa_test.c | [new file with mode: 0755] | patch | blob |
ti/runtime/netapi/test/build/Makefile | patch | blob | history | |
ti/runtime/netapi/test/net_test.c | patch | blob | history | |
ti/runtime/netapi/test/net_test.h | patch | blob | history |
diff --git a/ti/runtime/netapi/netapi_timer.h b/ti/runtime/netapi/netapi_timer.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/************************************************
- *FILE: netapi_timer.h
- *Purpose: netapi timer related functions
- **************************************************************
- * @file netapi_timer.h
- *
- * @breif DESCRIPTION: netapi timer library header file for user space transport
- * library
- *
- * 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.
-
- ***********************************************/
-
-/** @mainpage Netapi Timer Lib
- *
- * @section intro Introduction
- *
- * The network API provides a user space interface to timers
- * - a function to read a hw provided 64bit time stamp, @ref netapi_getTimestamp
- * This returns a tick running at 1/6 cpu frequency
- * - functions to create or open timer groups: @ref netapi_TimerGroupCreateTimer
- * and @ref netapi_TimerGroupOpenTimer. A timer group
- * is a group of timers with the same characteristics:
- * -> local or global
- * -> timer resolution (msc, 10 msc, etc)
- * -> expect to fire or expect to cancel
- * -> the same call back function for fired timers
- * - functions to close or delete timer groups
- * - function to start a timer, @ref netapi_TimerGroupStartTimer
- * - function to cancel a timer, @ref netapi_TimerGroupCancelTimer
- * - function to poll a timer group, or all timer groups registered to a NETAPI
- * instance
- * \par
- * NOTE:
- * (C) Copyright 2010-2011 Texas Instruments, Inc.
- * \par
- */
-
-
-#ifndef __NETAPI_TIMER__H
-#define __NETAPI_TIMER__H
-#include "netapi.h"
-
-extern volatile unsigned long * t64_virt_addr;
-extern unsigned int cpu_cycles_sec;
-
-//return hw timer clock ticks per second
-unsigned long t64_ticks_sec(void);
-#define netapi_getTicksPerSec t64_ticks_sec
-
-
-/** @ingroup netapi_api_functions */
-
-/*
- * @brief API returns a 64bit h/w timestamp
- *
- * @details reads a h/w timer (TIMER64 on Appleton SOC) and returns a 64 bit time stamp
- * timer runs at @ref t64_ticks_sec. Nominally this should be 1/6 CPU clk (@ref cpu_cycles_sec)
- *
- * @param[in] none
- * @retval unsigned long long timestamp (64 buts)
- * @pre @ref netapi_init
- */
-//return 64 bit timestamp from hw timer
-volatile static inline unsigned long long netapi_getTimestamp(void)
-{
- volatile unsigned long long t1;
- volatile unsigned long long t2;
- unsigned long long val;
- t1 = t64_virt_addr[0x10/4]; //lo
- t2 = t64_virt_addr[0x14/4]; //hi
- val = ((unsigned long long) t2) <<32 | t1;
- return val;
-}
-
-/******************************************************/
-/*******************TIMER API***************************/
-/******************************************************/
-typedef void * NETAPI_TIMER_GROUP_HANDLE_T;
-typedef void * NETAPI_TIMER_T;
-typedef void * NETAPI_TIMER_LIST_T;
-
-/* timer filter values */
-typedef int NETAPI_TIMER_FILTER_T;
-#define NETAPI_TIMER_NA (void*) NULL
-#define NETAPI_TIMER_FILTER_GLOBAL 0x1
-#define NETAPI_TIMER_FILTER_LOCAL 0x2
-#define NETAPI_TIMER_FILTER_E2F 0x4
-#define NETAPI_TIMER_FILTER_E2C 0x8
-#define NETAPI_TIMER_FITLER_ALL 0xf
-
-//iterator on TIMER_LIST_T
-NETAPI_TIMER_T netapi_TimerGetFirst( NETAPI_TIMER_LIST_T list);
-NETAPI_TIMER_T netapi_TimerGetNext( NETAPI_TIMER_LIST_T list,NETAPI_TIMER_T prev);
-void * netapi_TimerGetCookie(NETAPI_TIMER_T timer);
-unsigned long long netapi_TimerGetTs(NETAPI_TIMER_T timer); //debug
-
-/*
- * @brief API callback for timer expiration
- *
- * @details this function, provided by application, is registered by application
- * when timer group is created. It is called by timer library when a timer or set of timers
- * expire. The timer list can be walled with iterators: @ref netapi_TimerGetFirst,
- * @ref netapi_TimerGetNext. The timer id or "cookie" can be accessed via @ref netapi_TimerGetCookie
- * NOTE: callback should check for cookie==NULL since timer could be cancelled as it is being fired
- * @param[in] @ref NETAPI_TIMER_GROUP_HANDLE_T : the handle to the timer group
- * @param[in] int : the number of timers that have fired
- * @param[in] @ref NETAPI_TIMER_LIST_T : the list of timers that hace expired
- * @param[in] uint64_t : the current time
- * @retval none
- * @pre @ref netapi_init , @ref netapi_TimerGroupCreate, @ref netapi_TimerGroupStartTimer
- */
-//timer callback
-typedef void (*NETAPI_TIMER_CB_T) (
- NETAPI_TIMER_GROUP_HANDLE_T th, //timer group
- int n_fired, //# timers fired
- NETAPI_TIMER_LIST_T fired_list, //the list of fired timers. Access via iterators above
- uint64_t currentTime); //current timestamp
-
-/*
-* @brief API for Timer Group Creation
- *
- * @details this function is used to create a timer group. A timer group is a block of timers
- * that share the same characteristics.
- * @param[in] @ref NETAPI_T : the handle to the NETAPI Instance
- * @param[in] char * : the name of the timer
- * @param[in] @ref NETAPI_TIMER_CB_T : the callback function
- * @param[in] int : local (=1 if this timer group is local to this netapi instance, =0 if global)
- * @param[in] int : exp2cancel. (=1 if this timer group is expected to be cancelled, =0 otherwise))
- * @param[in] int : the timer group 'tick'. This is the group timer resolution in hw timestamp units.
- * Eg for 10 msc , enter @ref netapi_getTicksPerSec()/100
- * @param[in] int : timerTolerence in hw timestamp ticks. This is FUTURE.
- * @param[in] int : maxTimers - the max number of timers that can be handled by the group.
- * @param[in] int* : pointer to error return
- * @retval @ref NETAPI_TIMER_GROUP_HANDLE_T : handle for this timer group
- * @pre @ref netapi_init
- */
-//create a timer group
-NETAPI_TIMER_GROUP_HANDLE_T netapi_TimerGroupCreate(
- NETAPI_T netHandle, //netapi instance
- char * name, //name of the timer block
- NETAPI_TIMER_CB_T cb, //the callback function
- int local, //1 if timers local to thread
- int exp2cancel,//1 if expect to cancel
- int timerTicksPerGroupTick, //resolution for this timer block, in hw timer ticks
- int timerTolerence, //tolerence for this timer block, in hw timer ticksi [FUTURE]
- int maxTimers, //max # of timer objects for this group
- int *pErr);
-
-//open a [global] timer group [FUTURE]
-NETAPI_TIMER_GROUP_HANDLE_T netapi_TimerGroupOpen(
- NETAPI_T netHandle,
- char * name,
- NETAPI_TIMER_CB_T cb,
- int *pErr);
-
-/*
-* @brief API for Start a Timer
- *
- * @details this function is used to start a timer. When it expires, the @ref NETAPI_TIMER_CB_T
- * will be called.
- * @param[in] @ref NATAPI_TIMER_GROUP_HANDLE_T : the handle to the timer group
- * @param[in] void * : application provided timer id or cookie. MUST NOT BE NULL!!!
- * @param[in] uint64_t : offset from current time when to fire this timer. This offset MUST be in
- * units of timer group ticks (set at create time). Eg. For 10 msc timer group,
- * offset2fire =1 => timer is to fire in 10 msc.
- * @param[in] int* : pointer to error return
- * @retval @ref NETAPI_TIMER_T : handle for this timer. Used to reference the timer for cancel
- * @pre @ref netapi_init , @ref netapi_TimerGroupCreate
- */
-//start an individual timer
-NETAPI_TIMER_T netapi_TimerGroupStartTimer(
- NETAPI_TIMER_GROUP_HANDLE_T th, //the group handle
- void * cookie, //user id -> CANNONT BE NULL
- uint64_t offs2fire, //offset in timerGroup ticks (eg msc)
- int * pErr); //error return
-
-/*
-* @brief API for Cancel a Timer
- *
- * @details this function is used to cancel a timer. When it expires, the @ref NETAPI_TIMER_CB_T
- * will be called.
- * @param[in] @ref NATAPI_TIMER_GROUP_HANDLE_T : the handle to the timer group
- * @param[in] @ref NATAPI_TIMER_T : the handle to the individual timer to cancel
- * @param[in] int* : pointer to error return
- * @retval none
- * @pre @ref netapi_TimerGroupStartTimer
- */
-//Cancel a timer
-void netapi_TimerGroupCancel(
- NETAPI_TIMER_GROUP_HANDLE_T th,
- NETAPI_TIMER_T timerId,
- int *pErr);
-
-//close an opened timer group
-void netapi_TimerGroupClose(
- NETAPI_TIMER_GROUP_HANDLE_T th,
- int *pErr);
-
-//close an opened timer group
-void netapi_TimerGroupDelete(
- NETAPI_TIMER_GROUP_HANDLE_T th,
- int *pErr);
-
-//extract netapi handle from timer group handle
-NETAPI_T netap_TimerGroupGetNH( NETAPI_TIMER_GROUP_HANDLE_T th);
-
-//poll a specific timer group
-int netapi_TimerGroupPoll(NETAPI_TIMER_GROUP_HANDLE_T th, int maxTimers);
-
-/*
-* @brief API for Polling all timer groups attached to an instance
- *
- * @details this function is used to poll all or a specified subset of the timer groups of an
- * instance. A mask can be set to filter which categories of timer groups (local vs global etc)
- * to poll. The approximate max # of timers to process can also be set.
- * @param[in] @ref NATAPI_T : the handle of the netapi instance.
- * @param[in] @ref NATAPI_TIMER_FILTER_T : the bit mask of timer group types to poll
- * @param[in] int : approximate max number of timers to process. NOTE: this can be used to
- * coarsely control how many timers to process. In general, all timers that have been
- * hashed into the same cell and have expired will be processed regardless of the
- * maxTmers setting.. [FUTURE]
- * @retval none
- * @pre @ref netapi_init, @ref netapi_TimerGroupCreate
- */
-
-//poll all timers
-int netapi_TimerGroupPollAll(NETAPI_T nh, NETAPI_TIMER_FILTER_T f, int maxTimers);
-
-/*****************END API*********************************/
-
-
-#endif
index 68e2ad1277327e6b7ff6216495d57ed8cc3b7e2d..7d319101e47bacbb82a1c91f15b95e1b84635e30 100755 (executable)
* @note This must reflect what the kernel is uding for their region, see device tree blob for details.
*/
#define TUNE_NETAPI_QM_START_INDEX 0x2000 //WARNING: must reflect what kernel is using for their region, see device tree blob
-
+//#define TUNE_NETAPI_QM_START_INDEX 0
/**
* @ingroup tune_parameters
* @def TUNE_NETAPI_QM_GLOBAL_REGION
* @note This must reflect what the kernel is uding for their region, see device tree blob for details.
*/
#define TUNE_NETAPI_QM_GLOBAL_REGION 18 //WARNING: must reflect what kernel is using for their region, see device tree blob
+//#define TUNE_NETAPI_QM_GLOBAL_REGION 0 //WARNING: must reflect what kernel is using for their region, see device tree blob
#else //use msmc..
/**
* @def TUNE_NETAPI_MAX_NUM_MAC
* This defines the number of logical mac addresses
*/
-#define TUNE_NETAPI_MAX_NUM_MAC 2
+#define TUNE_NETAPI_MAX_NUM_MAC 64
/**
* @ingroup tune_parameters
* @def TUNE_NETAPI_MAX_NUM_IP
* This defines the number of ip addresses
*/
-#define TUNE_NETAPI_MAX_NUM_IP 32
+#define TUNE_NETAPI_MAX_NUM_IP 64
/**
* @ingroup tune_parameters
* @def TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS
* This defines the number maximum number of ipsec channels
*/
-#define TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS 64
+#define TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS 128
#else
/**
* @ingroup tune_parameters
*/
#define TUNE_NETAPI_MAX_BURST_RCV 32
-/**
- * @ingroup tune_parameters
- * @def TUNE_NETAPI_MAX_IP
- * This defines the maximum number of IP's that can be attached to MAC interfaces.
- */
-#define TUNE_NETAPI_MAX_IP 4
-/**
- * @ingroup tune_parameters
- * @def TUNE_NETAPI_MAX_INTERFACES
- * This defines the maximum number of MAX interfaces */
-#define TUNE_NETAPI_MAX_INTERFACES 3 //2 interfaces
/**
* @ingroup tune_parameters
* @def TUNE_NETAPI_MAX_SA
* This defines the maximum number of security associations
*/
-#define TUNE_NETAPI_MAX_SA 64 //rx&tx combined (so MAX_SA/4 tunnels typically)
+#define TUNE_NETAPI_MAX_SA 128 //rx&tx combined (so MAX_SA/4 tunnels typically)
/**
* @ingroup tune_parameters
* @def TUNE_NETAPI_MAX_POLICY
* This defines the maximum number of security policies.
*/
-#define TUNE_NETAPI_MAX_POLICY 64 //rx policies
+#define TUNE_NETAPI_MAX_POLICY 128 //rx policies
#endif
index 9914a79bc4e786cd25b070294f2934adc7f5e0ef..b9fcc578a4004254e56f46fbf049daa8a531ed8b 100755 (executable)
&netapi_global.nwal_context,
&netapi_global.cfg);
if (result<0) {printf(">netapi init_nwal() failed\n"); return -1; }
- printf(">system_init: returned from netapi_init_nwal\n");
+ printf("system_init: returned from netapi_init_nwal\n");
/* start NWAL */
result = netapi_start_nwal(sharedHeapHandle,
controlRxHeapHandle,
&handle->nwal_local,
&netapi_global.cfg,
&netapi_global.nwal_context);
- if (result<0) {printf(">netapi start_nwal() failed\n"); return -1; }
- printf(">system_init: returned from netapi_start_nwal\n");
+ if (result<0) {printf("netapi start_nwal() failed\n"); return -1; }
+ printf("system_init: returned from netapi_start_nwal\n");
//** success **
netapi_getBufMemRemainder(void)
{
- hplib_vmGetBufMemRemainder(0);
+ hplib_vmGetMemPoolRemainder(0);
}
index 4cbcd96823d1145cfa6411cef48786e1fa611f84..bad13f42d881fc1caa22aa71c6f502123504644f 100755 (executable)
uint8_t paBuf0[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0]ALIGN(CACHE_LINESZ);
/* Memory used for PA handles */
-#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 128
+#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 128 * TUNE_NETAPI_MAX_NUM_MAC
uint8_t paBuf1[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1]ALIGN(CACHE_LINESZ);
//#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2 768
-#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2 6144
+//#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2 6144
+#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2 12288
+
+
uint8_t paBuf2[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2]ALIGN(CACHE_LINESZ);
/* Memory used for SA LLD global Handle */
bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalHandleMem);
if(NWAL_CHAN_HANDLE_SIZE < sizes[nwal_BUF_INDEX_INT_HANDLES])
{
+ printf("one\n");
/* Resize Memory */
while(1);
}
if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0) < sizes[nwal_BUF_INDEX_PA_LLD_BUF0])
{
/* Resize Memory */
+ printf("two\n");
while(1);
}
count++;
bases[nwal_BUF_INDEX_PA_LLD_BUF1] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paBuf1);
+ printf("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
+ NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1, sizes[nwal_BUF_INDEX_PA_LLD_BUF1]);
if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1) < sizes[nwal_BUF_INDEX_PA_LLD_BUF1])
{
+ printf("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
+ NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1, sizes[nwal_BUF_INDEX_PA_LLD_BUF1]);
/* Resize Memory */
while(1);
}
bases[nwal_BUF_INDEX_PA_LLD_BUF2] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paBuf2);
if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2) < sizes[nwal_BUF_INDEX_PA_LLD_BUF2])
{
+ printf("four\n");
/* Resize Memory */
while(1);
}
bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)salldHandle);
if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE) < sizes[nwal_BUF_INDEX_SA_LLD_HANDLE])
{
+ printf("five\n");
/* Resize Memory */
while(1);
}
if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) <
sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE])
{
+ printf("netapi_init_nwal: sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] %d\n", sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE]);
/* Resize Memory */
while(1);
}
//***************************************************
int netapi_init_timer(void)
{
+#ifdef CORTEX_A8
return t64_start();
+#endif
}
index d5126394a2c400a8fc27391ded700e566372222d..0c2d2aa813c35702aa8967e001c007b2e78c7082 100755 (executable)
int numCmdFail;
int numBogusTransIds;
NetapiNwalTransInfo_t transInfos[TUNE_NETAPI_MAX_NUM_TRANS]; //transactions
- NETCP_INTERFACE_T interfaces[TUNE_NETAPI_MAX_INTERFACES]; //interfaces
+ NETCP_INTERFACE_T interfaces[TUNE_NETAPI_MAX_NUM_MAC]; //interfaces
NETCP_INTERFACE_CLASSIFIER_T classi[TUNE_NETAPI_MAX_CLASSIFIERS]; //classifiers
NETCP_REGISTERED_FLOWS_T flows[TUNE_NETAPI_MAX_FLOWS]; //flows
NETCP_IPSEC_SA_T tunnel[TUNE_NETAPI_MAX_SA]; //tunnels
NETCP_IPSEC_POLICY_T policy[TUNE_NETAPI_MAX_POLICY]; //policies
- NETCP_INTERFACE_IP_T ips[TUNE_NETAPI_MAX_IP]; //ips
+ NETCP_INTERFACE_IP_T ips[TUNE_NETAPI_MAX_NUM_IP]; //ips
} NETAPI_NWAL_GLOBAL_CONTEXT_T;
/* NWAL Local context (per core/thread) */
index 9794d1eaac652ea85d76be6aa1410cce5c2257d8..1b5f5a2b1758e6baebb8e9ac7f38c0370dc2e847 100755 (executable)
//poll all pktio channels we have open in RX mode
//Osal_cache_op_measure_reset();
cache_op_b2= Osal_cache_op_measure(&n_c_ops);
- t1=hplib_mUtilGetTickCount();
+ t1=hplib_mUtilGetPmuCCNT();
pkts=pktio_pollAll((NETAPI_T) s->back, NULL, &err);
- t2=hplib_mUtilGetTickCount();
+ t2=hplib_mUtilGetPmuCCNT();
if (pkts)
{
s->num_pkts+= (unsigned long long) pkts;
diff --git a/ti/runtime/netapi/src/netapi_timer.c b/ti/runtime/netapi/src/netapi_timer.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************
- * FILE: netapi_timer.c
- * Purpose: implementation of user space timers
- **************************************************************
- * FILE: netapi.c
- *
- * DESCRIPTION: user space timers main source file for user space transport
- * library
- *
- * 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.
- *
- ***************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include "netapi.h"
-#include "netapi_timer.h"
-#include "timer_loc.h"
-
-
-/*******************************************************************
- * hash function: returns cell to place timer object in
- *
- ******************************************************************/
-/* static */ int our_hash(
- unsigned long long ct,
- int n_cells,
- unsigned int cell_width)
-{
-int c;
- //simple hash function
- c= (ct/cell_width) % n_cells;
- return c;
-
-}
-
-//iterator on TIMER_LIST_T
-NETAPI_TIMER_T netapi_TimerGetFirst( NETAPI_TIMER_LIST_T list)
-{ return (NETAPI_TIMER_T) ((TIM_LIST_T *)list)->head; }
-
-NETAPI_TIMER_T netapi_TimerGetNext( NETAPI_TIMER_LIST_T list,NETAPI_TIMER_T prev)
-{return prev ? (NETAPI_TIMER_T) ((TIM_T*) prev)->next:NULL ;}
-
-//return cookie associated with timer object
-void * netapi_TimerGetCookie(NETAPI_TIMER_T timer)
-{ return ((TIM_T*) timer)->cookie; }
-
-//return timeer value associated with timer object
-unsigned long long netapi_TimerGetTs(NETAPI_TIMER_T timer)
-{ return ((TIM_T*) timer)->t; }
-
-#if 0
-//timer callback
-typedef void (*NETAPI_TIMER_CB_T) (
- NETAPI_TIMER_GROUP_HANDLE_T th,
- int n_fired, //# timers fired
- NETAPI_TIMER_LIST_T fired_list,
- uint64_t currentTime);
-#endif
-
-static TIMER_GROUP_T temp_g; //temp. todo: put inot netHandle
-
-//create a timer group
-NETAPI_TIMER_GROUP_HANDLE_T netapi_TimerGroupCreate(
- NETAPI_T netHandle,
- char * name,
- NETAPI_TIMER_CB_T cb,
- int local, //1 if timers local to thread
- int exp2cancel,//1 if expect to cancel
- int cell_width, //in ticks
- int tol, //in ticks
- int maxTimers,
- int *pErr)
-{
- int ret= tim_group_create(&temp_g, TUNE_NETAPI_NUM_TIMER_CELLS, maxTimers);
- if (!ret) {*pErr = NETAPI_ERR_NOMEM; return NULL;}
- *pErr=0;
- temp_g.cb = cb;
- temp_g.local = local;
- temp_g.exp2cancel= exp2cancel;
- temp_g.cell_width=cell_width;
- temp_g.tol=tol;
- temp_g.h = netHandle;
- temp_g.last_polled=(netapi_getTimestamp()/cell_width) * cell_width + (cell_width-1);
- printf(">timer group %s created. width = %d (ticks)\n", name, cell_width);
- return (NETAPI_TIMER_GROUP_HANDLE_T) &temp_g;
-}
-
-//open a [global] timer group
-NETAPI_TIMER_GROUP_HANDLE_T netapi_TimerGroupOpen(
- NETAPI_T netHandle,
- char * name,
- NETAPI_TIMER_CB_T cb,
- int *pErr)
-{
-printf(">timer group open not implemented \n");
-
-}
-
-//start an individual timer
-NETAPI_TIMER_T netapi_TimerGroupStartTimer(
- NETAPI_TIMER_GROUP_HANDLE_T th,
- void * cookie,
- uint64_t offs2fire, //offset in group ticks
- int * pErr)
-{
-TIM_T * timer_obj;
-unsigned long long ct= netapi_getTimestamp() + offs2fire* ((TIMER_GROUP_T*) th)->cell_width;
-int cell;
-*pErr=0;
-
-//find cell where to insert
-cell = our_hash(ct,((TIMER_GROUP_T*) th)->n_cells , ((TIMER_GROUP_T*) th)->cell_width);
-
-//get object and insert into this cell
-timer_obj =tim_set(
- &((TIMER_GROUP_T*) th)->cells[cell],
- &((TIMER_GROUP_T*) th)->free ,
- ct,
- cookie,
- pErr);
-if (!timer_obj) {return NULL;}
-//DEBUGprintf(">timer: setting timer %x for %lld ticks -> hased to cell %d\n",cookie, ct,cell);
-return (NETAPI_TIMER_T) timer_obj;
-}
-
-//Cancel a timer
-void netapi_TimerGroupCancel(
- NETAPI_TIMER_GROUP_HANDLE_T th,
- NETAPI_TIMER_T timerId,
- int *pErr)
-{
- tim_cancel((TIM_T *) timerId, pErr);
-}
-
-//close an opened timer group
-void netapi_TimerGroupClose(
- NETAPI_TIMER_GROUP_HANDLE_T th,
- int *pErr){}
-
-//delete atimer group
-void netapi_TimerGroupDelete(
- NETAPI_TIMER_GROUP_HANDLE_T th,
- int *pErr) {printf(">timer group delete not implemented\n");}
-
-//extract netapi handle from timer group handle
-NETAPI_T netap_TimerGroupGetNH( NETAPI_TIMER_GROUP_HANDLE_T th) { return ((TIMER_GROUP_T*) th)->h; }
-
-
-//-----for timer debuggingi-------
-struct
-{
-//last poll stats
-int n_tot;
-int c_seen;
-
-int max_c_seen;
-int max_n_tot;
-
-} timer_poll_stats;
-void dump_poll_stats(void)
-{
- printf("debug timer poll> n_tot=%d c_seen=%d mnt=%d mcs=%d\n",
- timer_poll_stats.n_tot, timer_poll_stats.c_seen,
- timer_poll_stats.max_n_tot, timer_poll_stats.max_c_seen);
-}
-//-------end timer debugging----
-
-//poll a specific timer group
-int netapi_TimerGroupPoll(NETAPI_TIMER_GROUP_HANDLE_T th, int maxTimers)
-{
-unsigned long long ct= netapi_getTimestamp();
-unsigned long long i;
-int cell;
-TIM_LIST_T res={NULL,NULL};
-int n;
-int n_tot=0;
-int c_seen=0;
-
- for(i=((TIMER_GROUP_T*) th)->last_polled; (i<= ct) && (n_tot<maxTimers); )
- {
- cell = our_hash(i,((TIMER_GROUP_T*) th)->n_cells , ((TIMER_GROUP_T*) th)->cell_width);
- tim_return_fired_list(&((TIMER_GROUP_T*) th)->cells[cell],
- &res,
- &((TIMER_GROUP_T*) th)->free,
- i,
- &n);
- n_tot+=n;
- i += ((TIMER_GROUP_T*) th)->cell_width;
- c_seen+=1;
- }
- if (n_tot)
- {
- ((TIMER_GROUP_T*) th)->cb(th, n_tot, (NETAPI_TIMER_LIST_T) &res, ct);
- tim_return_free(&((TIMER_GROUP_T*) th)->free,&res,n_tot);
- }
-
- ((TIMER_GROUP_T*) th)->last_polled = i;
- if (c_seen) timer_poll_stats.n_tot = n_tot;
- if (c_seen) timer_poll_stats.c_seen = c_seen;
- if (n_tot > timer_poll_stats.max_n_tot) timer_poll_stats.max_n_tot = n_tot;
- if (c_seen > timer_poll_stats.max_c_seen) timer_poll_stats.max_c_seen = c_seen;
- return n_tot;
-}
-
-//poll all timers
-int netapi_TimerGroupPollAll(NETAPI_T nh, NETAPI_TIMER_FILTER_T f, int maxTimers)
-{
- //todo: use filters and poll global, local lists in nh
- if (temp_g.h)
- netapi_TimerGroupPoll(&temp_g, maxTimers);
- return 0;
-}
-
-
index 1cfd679cd63b36f63ea66b72762859e84c08dcff..0d0ed36e8a1981ced24e1c99aee3f73187f46855 100755 (executable)
int i;
if (iface != NETCP_CFG_NO_INTERFACE)
{
- if ((iface <0 ) || (iface >=TUNE_NETAPI_MAX_INTERFACES)) return -1;
+ if ((iface <0 ) || (iface >=TUNE_NETAPI_MAX_NUM_MAC)) return -1;
}
//find a free entry
for(i=0;i<TUNE_NETAPI_MAX_SA;i++)
int i;
//find a free entry
- for(i=0;i<TUNE_NETAPI_MAX_IP;i++)
+ for(i=0;i<TUNE_NETAPI_MAX_NUM_IP;i++)
{
if (!p->ips[i].in_use)
{
int iface_no,
int ip_slot )
{
- if ((ip_slot <0)||(ip_slot>TUNE_NETAPI_MAX_IP)) return ;
+ if ((ip_slot <0)||(ip_slot>TUNE_NETAPI_MAX_NUM_IP)) return ;
p->ips[ip_slot].in_use=0;
return;
}
int iface_no,
int ip_slot )
{
- if ((ip_slot <0)||(ip_slot>=TUNE_NETAPI_MAX_IP)) return NULL;
+ if ((ip_slot <0)||(ip_slot>=TUNE_NETAPI_MAX_NUM_IP)) return NULL;
if (!p->ips[ip_slot].in_use) return NULL;
return (void *) p->ips[ip_slot].nwal_handle;
}
static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char * p_mac,
int iface_no, int state, NETCP_CFG_VLAN_T vlan, void * handle)
{
- if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_INTERFACES))
+ if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
{
memset(&p->interfaces[iface_no],0,sizeof(NETCP_INTERFACE_T));
p->interfaces[iface_no].in_use = 1;
@@ -349,7 +349,7 @@ static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char
void* netcp_cfgp_get_mac_handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
{
if (iface_no == NETCP_CFG_NO_INTERFACE) return NULL;
- if ((iface_no <0 ) || (iface_no >= TUNE_NETAPI_MAX_INTERFACES))
+ if ((iface_no <0 ) || (iface_no >= TUNE_NETAPI_MAX_NUM_MAC))
{
return NULL;
}
//internal: clear inteface entry
static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
{
- if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_INTERFACES))
+ if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
{
p->interfaces[iface_no].in_use = 0;
}
//verify that iface has been configured
if (iface_no != NETCP_CFG_NO_INTERFACE)
{
- if ((iface_no<0) || (iface_no>= TUNE_NETAPI_MAX_INTERFACES)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}
+ if ((iface_no<0) || (iface_no>= TUNE_NETAPI_MAX_NUM_MAC)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}
}
if (iface_no != NETCP_CFG_NO_INTERFACE)
/************************************************************************/
/***************************************************************
- ********************METCP CMD Reply Callback******************
+ ********************NETCP CMD Reply Callback******************
***************************************************************/
void netapi_NWALCmdCallBack (nwal_AppId appHandle,
uint16_t trans_id,
{
printf (">netcp cfg : NWALCmdCallBack returned Error Code %d\n",
ret);
+ // update error code that is fialed in p_trans */
//todo: atomic inc
netapi_get_global()->nwal_context.numCmdFail++;
}
diff --git a/ti/runtime/netapi/src/tim64.c b/ti/runtime/netapi/src/tim64.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * tim64.c : enable use of timer64 from user space
- * (using 64 bit mode)
- * TIMER 6
- **************************************************************
- * FILE: tim64.c
- *
- * DESCRIPTION: tim64 peripheral driver for user space transport
- * library
- *
- * 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.
-
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <termios.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include "netapi_timer.h"
-
-/* timing */
-static inline unsigned long timing_start(void)
-{
- volatile int vval;
- //read clock
- asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(vval));
- return vval;
-}
-static inline unsigned long timing_stop(void)
-{
- volatile int vval2;
- //read clock
- asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(vval2));
- return vval2;
-}
-
-
-
-#define MAP_SIZE 4096UL
-#define MAP_MASK (MAP_SIZE - 1)
-//this is for timer 6
-#define T64BASE_6 (void *)0x02260000
-volatile unsigned long * t64_virt_addr;
-static unsigned long tv_lo;
-static unsigned long tv_hi;
-
-//read
-static unsigned long long read_t64(void)
-{
- volatile unsigned long long t1;
- volatile unsigned long long t2;
- unsigned long long val;
- t1 = t64_virt_addr[0x10/4]; //lo
- t2 = t64_virt_addr[0x14/4]; //hi
-
- val = ((unsigned long long) t2) <<32 | t1;
- return val;
-
-}
-
-//claibrate
-static unsigned int t64_cpu_cycle_per_tick=0;
-unsigned int cpu_cycles_sec=983040000;
-unsigned long t64_ticks_sec(void)
-{
- if (t64_cpu_cycle_per_tick)
- return ( cpu_cycles_sec/t64_cpu_cycle_per_tick); //ticks per/sec
- else return 166666666;
-
-}
-static int t64_calibrate(int n)
-{
-volatile unsigned long t1;
-volatile unsigned long t2;
-volatile unsigned long long t164;
-volatile unsigned long long t264;
-int i;
-volatile int s;
-t1=timing_start();
-t164=read_t64();
-
-sleep(1);
-#if 0
-for(i=0;i<n;i++)
-{
- s+=t164*20; s=s*(2+i);
-}
-#endif
-t264=read_t64();
-t2=timing_stop();
-t64_cpu_cycle_per_tick = (unsigned long) ((t2-t1)/(t264-t164));
-printf(">netapi: tim64 calibration - n=%d t2-t1=%lu t264-t164=%llu ccpt=%ld tps=%ld\n",
- n, t2-t1, t264-t164, t64_cpu_cycle_per_tick, t64_ticks_sec());
-
-t1=timing_stop();
-t164=netapi_getTimestamp();
-t264=netapi_getTimestamp();
-t2=timing_stop();
-printf(">netapi: tim64 cycle cost= %d(cpu ticks), back2back= %lld\n", (t2-t1)/2, t264-t164);
-
-}
-
-
-/*********************************
- * memory map t64 into user space
-t264=read_t64();
-t264=read_t64();
- * input: pass in fd for /dev/mem
- **********************************/
-int t64_memmap(int fd)
-{
- off_t t64_base= (off_t) T64BASE_6;
- void * map_base;
- int op;
- volatile unsigned long t1;
- volatile unsigned long t2;
- unsigned long long blah;
-
-
- /* Map one page */
- map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, t64_base & ~MAP_MASK);
- if(map_base == (void *) -1) exit(-99);
- fflush(stdout);
-
- t64_virt_addr = (long *) map_base + (t64_base & MAP_MASK);
- printf(">netapi timer64: T64 Memory mapped at address %p.\n", t64_virt_addr);
- fflush(stdout);
- return 1;
-}
-
-
- /*********************************
- * start the timer64
- ***********************************/
-int t64_start(void)
-{
- t64_virt_addr[0x24/4]= 0x00;
- t64_virt_addr[0x10/4]= 0x00;
- t64_virt_addr[0x14/4]= 0x00;
- t64_virt_addr[0x18/4]= 0xffffffff;
- t64_virt_addr[0x1c/4]= 0xffffffff;
- t64_virt_addr[0x20/4]= 0x80;
- t64_virt_addr[0x24/4]= 0x03; //go
- t64_calibrate(100000);
- return 1;
-}
-
-
-#ifdef TEST_DRIVER
-int main(int argc, char **argv) {
- int fd;
- off_t t64_base= (off_t) T64BASE_6;
- void * map_base;
- int op;
-volatile unsigned long t1;
-volatile unsigned long t2;
-unsigned long long blah;
-
- if(argc < 2) {
- fprintf(stderr, "Usage: tim64 start|stop|read \n"
- );
- exit(1);
- }
- if (!strcmp(argv[1],"start")) op=0;
- else if (!strcmp(argv[1],"stop")) op =1;
- else if (!strcmp(argv[1],"read")) op =2;
- else { fprintf(stderr, "Usage: tim64 start|stop|read \n"
- );
- exit(1);
- }
-
-
- if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) exit(-99);
- printf("/dev/mem opened.\n");
- fflush(stdout);
-
- /* Map one page */
- map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, t64_base & ~MAP_MASK);
- if(map_base == (void *) -1) exit(-99);
- printf("mapbase=Memory mapped at address %p.\n", map_base);
- fflush(stdout);
-
- t64_virt_addr = (long *) map_base + (t64_base & MAP_MASK);
- printf("t64_virt_ddr: Memory mapped at address %p.\n", t64_virt_addr);
- fflush(stdout);
-
- switch(op)
- {
- case(0):
- default:
- //start
- t64_virt_addr[0x24/4]= 0x00;
- t64_virt_addr[0x10/4]= 0x00;
- t64_virt_addr[0x14/4]= 0x00;
- t64_virt_addr[0x18/4]= 0xffffffff;
- t64_virt_addr[0x1c/4]= 0xffffffff;
- t64_virt_addr[0x20/4]= 0x80;
- t64_virt_addr[0x24/4]= 0x03; //go
- t64_calibrate(100000);
- break;
- case(1):
- //stop
- t64_virt_addr[0x24/4]= 0x00;
- break;
- case(2):
- //read
- tv_lo= t64_virt_addr[0x10/4];
- tv_hi= t64_virt_addr[0x14/4];
-t1=timing_start();
-blah = read_t64();
-t2=timing_stop();
-
- printf("t64 = %x%x %llx (read_t64 takes %d ticks)\n",tv_hi,tv_lo,blah, t2-t1);
- break;
- }
- if(munmap(map_base, MAP_SIZE) == -1) exit(-99);
- close(fd);
- return 0;
-}
-#endif
diff --git a/ti/runtime/netapi/src/timer_loc.h b/ti/runtime/netapi/src/timer_loc.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/********************************************************
- * File: timer_loc.h
- * Purpose: local definitions for timer module
- ******************************************************/
-
-#ifndef __TIMER_LOC__H
-#define __TIMER_LOC__H
-
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-
-/**********************************
- * A timer object
- * active timrs have non zero cookie
- **********************************/
-struct TIM_tag;
-typedef struct TIM_tag
-{
-struct TIM_tag * next;
-void * cookie;
-unsigned long long t;
-} TIM_T;
-
-//a list of timers
-typedef struct TIM_LIST_tAG
-{
- TIM_T * head;
- TIM_T * tail;
-} TIM_LIST_T;
-
-
-//the timer group context
-typedef struct TIMER_GROUP_Tag
-{
- NETAPI_T h; //back pointer
- int n_cells; //#of cells (hash entries)
- int n_timers; //# of timer objects
- int cell_width; //size of each cell in ticks
- TIM_LIST_T free; //free list of timer objects
- TIM_LIST_T * cells;//active timers hash table
- unsigned long long last_polled; //in ticks
- NETAPI_TIMER_CB_T cb; //timer callback
- int local; //1 => local timer, 0 =>global timer
- int exp2cancel; //1=> expect to cancel, 0=> expect to fire
- int tol; //in ticks [FUTURE]
-} TIMER_GROUP_T;
-
-/**********************INTERNAL API*******************/
-//create a timer group
-int tim_group_create(TIMER_GROUP_T *g, int n_cells, int n_timers);
-
-//return a list of timer objects to free list
-void tim_return_free(TIM_LIST_T *ftl, TIM_LIST_T *p, int n);
-
-//get a free timer oblject
-TIM_T * tim_get_free(TIM_LIST_T *ftl, void *cookie, unsigned long long t);
-
-//return a list of timers that have fired
-void tim_return_fired_list(TIM_LIST_T *tl, TIM_LIST_T * pr, TIM_LIST_T * ftl, unsigned long long t, int * p_nf);
-
-
-//cancel a timer
-void tim_cancel(TIM_T * p, int *pErr);
-
-//insert an active timer into hash cell
-TIM_T *tim_set(TIM_LIST_T *tl, TIM_LIST_T *free_tl, unsigned long long t, void *cookie, int *pErr);
-
-/********************************************************/
-/********************internal control of hw*************/
-/******************************************************/
-//memmap t64 registers. fd is open(/dev/mem)
-int t64_memmap(int fd);
-
-//start the timer
-int t64_start(void);
-
-
-#endif
diff --git a/ti/runtime/netapi/src/timlist.c b/ti/runtime/netapi/src/timlist.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/******************************************
- * FILE:timlist.c
- * Purpose: timer low level primitives
- ***********************************************
-* FILE:timlist.c
- *
- * DESCRIPTION: netapi timer library source file for user space transport
- * library
- *
- * 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 TEST_DRIVER
-#ifdef TEST_DRIVER
-typedef void * NETAPI_T;
-typedef void * NETAPI_TIMER_CB_T;
-#else
-#include "../netapi_timer.h"
-#endif
-#include "timer_loc.h"
-#include "../netapi_err.h"
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-
-//create a timer group
-int tim_group_create(TIMER_GROUP_T *g, int n_cells, int n_timers)
-{
-char * mem= (char *) malloc(n_timers * sizeof (TIM_T));
-if (!mem) return -1;
-g->n_cells = n_cells;
-tim_build_free(&g->free, mem, sizeof(TIM_T) * n_timers);
-g->cells=(TIM_LIST_T *) malloc(n_cells * sizeof(TIM_LIST_T));
-if (!g->cells) {free(mem); return -1;}
-g->n_timers=n_timers;
-g->last_polled=0;
-return 1;
-}
-
-//return as single timer to end of free list, zero cookie, etc
-void tim_return_single_free(TIM_LIST_T *ftl, TIM_T *p)
-{
-TIM_T * pt;
-int i;
-pt = ftl->tail;
-if (!pt)
-{
-ftl->head=p;
-ftl->tail=p;
-}
-else
-{
-pt->next=p;
-ftl->tail = p;
-}
- p->t=0LL;
- p->cookie=NULL;
- p->next=NULL;
-}
-
-
-//return a list of N timers to end of [free] list. zero cookie, etc
-void tim_return_free(TIM_LIST_T *ftl, TIM_LIST_T *p, int n)
-{
-TIM_T * pt;
-int i;
-pt = ftl->tail;
-if (!pt)
-{
-ftl->head=p->head;
-ftl->tail=p->tail;
-}
-else
-{
-pt->next=p->head;
-ftl->tail = p->tail;
-}
-
-pt= p->head;
-for(i=0;i<n;i++)
-{
- pt->t=0LL;
- pt->cookie=NULL;
- pt= pt->next;
-}
-ftl->tail->next=NULL;
-}
-
-//get a [free] entry from front of a list
-TIM_T * tim_get_free(TIM_LIST_T *tl, void *cookie, unsigned long long t)
-{
-TIM_T *p = tl->head;
-if (p)
-{
- tl->head=p->next;
- p->next=NULL;
- p->cookie = cookie;
- p->t = t;
- if (!tl->head) tl->tail=NULL;
-}
-return p;
-}
-
-//build a timer list from chunk of memory
-int tim_build_free(TIM_LIST_T *tl, char *p_mem, int mem_size)
-{
-TIM_T * p = (TIM_T*) p_mem;
-TIM_T * p_old = (TIM_T*) p_mem;
-int i=0;
-tl->head = p;
-while(mem_size)
-{
- p_old = p;
- p->cookie=NULL;
- p->t = 0LL;
- mem_size -= sizeof(TIM_T);
- p+=1;
- i+=1;
- p_old->next=p;
-}
-p_old->next = NULL;
-tl->tail = p_old;
-return i;
-}
-
-//return a list of timers that have fired
-void tim_return_fired_list(TIM_LIST_T *tl, TIM_LIST_T * pr, TIM_LIST_T * ftl, unsigned long long t, int * p_nf)
-{
-int i=0;
-int got_start=0;
-int found_end=0;
-TIM_T * p_last, *p, *temp_p_next;
-TIM_LIST_T p_free={NULL,NULL};
-if (! tl->head) { *p_nf=0; return ;}
-
-p = tl->head;
-p_last= NULL;
-
-for(i=0;p;)
-{
- if(p->t <= t)
- {
- if(!got_start)
- {
- if(p->cookie)
- {
- //start results chain
- got_start=1;
- if(pr->tail) {pr->tail->next = p; pr->tail=p;}
- else {pr->head=pr->tail = p;}
- i+=1;
- p_last=p;
- p=p->next;
- continue;
- }
- else //skip over cancelled timer..
- {
- //skip & free. make sure we adjust head or tail if necessary
- if (p_last){
- p_last->next=p->next;
- }
- else {
- tl->head = p->next; /* we are freeing old head..*/
- }
- if (tl->tail ==p) tl->tail=p_last; /* we are freeing old tail */
- temp_p_next=p->next;
- tim_return_single_free(ftl,p);
- p=temp_p_next;
- /*keep p_last the same! */
- continue;
- }
- }
- else
- {
- if(!p->cookie)
- {
- //skip & free
- if (p_last){
- p_last->next=p->next;
- }
- else {
- tl->head = p->next;
- }
- if (tl->tail ==p) tl->tail=p_last; /* we are freeing old tail */
- temp_p_next=p->next;
- tim_return_single_free(ftl,p);
- p=temp_p_next;
- /*keep p_last the same! */
- continue;
- }
- else { //valid entry for list.
- p_last=p;
- p=p->next;
- i+=1;
- continue;
- }
- }
- }
- else /* p->t > t */
- {
- if(got_start)
- {
- found_end =1; //found end of chain to return. All is good
- pr->tail = p_last;
- p_last->next=NULL;
- tl->head=p;
- }
- // done
- break;
- }
-}
-
-*p_nf=i;
-if ((got_start) && (!found_end))
-{
- //cleared the list
- //DEBUGprintf("clearingthelist\n");
- tl->head = tl->tail=NULL;
-}
-return;
-}
-
-//cancel a timer
-void tim_cancel(TIM_T * p, int *pErr)
-{
- *pErr =0;
- if (!p) {*pErr = NETAPI_ERR_BAD_INPUT; return; }
- if (!p->cookie) {*pErr= NETAPI_ERR_ALREADY_CANCELLED; return;}
- p->cookie = NULL;
- return;
-}
-
-//set a timer
-TIM_T *tim_set(TIM_LIST_T *tl, TIM_LIST_T *free_tl, unsigned long long t, void *cookie, int *pErr)
-{
-TIM_T *pt = tl->head;
-TIM_T *p = tim_get_free(free_tl, cookie, t);
-TIM_T *pt_last= NULL;
-int i;
-*pErr=0;
-if (!p ) { *pErr=NETAPI_ERR_NOMEM; return NULL;}
-
-if (!pt) //first one
-{
- tl->head = p;
- tl->tail =p;
- return p;
-}
-
-//see if we can place at front of list
-if (pt->t >=t)
-{
- tl->head=p;
- p->next=pt;
- return p;
-}
-
- //timer has hashed into this chain. find out where
-for(;pt;)
-{
- if (pt->t >= t)
- {
- if (pt_last) {
- pt_last->next = p;
- p->next=pt;
- return p;
- }
- else
- {
- tl->head=p;
- p->next=pt;
- return p;
- }
- }
- else {pt_last=pt;pt=pt->next;}
-}
-//last one
-pt_last->next=p;
-p->next=NULL;
-tl->tail=p;
-return p;
-}
-
-#ifdef TEST_DRIVER
-TIM_LIST_T the_base={NULL,NULL};
-TIM_LIST_T cell_base={NULL,NULL};
-char *mem;
-TIM_T * timers[10];
-TIM_LIST_T res;
-main()
-{
- int err;
- mem= malloc(100*sizeof(TIM_T));
- TIM_T *p;
- int n;
- int i;
-
- tim_build_free(&the_base, mem , 100*sizeof(TIM_T));
-
- timers[0]=tim_set(&cell_base, &the_base, 100LL, (void *) 1, &err);
- timers[1]=tim_set(&cell_base, &the_base, 101LL, (void *) 2, &err);
- timers[2]=tim_set(&cell_base, &the_base, 105LL, (void *) 3, &err);
- timers[3]=tim_set(&cell_base, &the_base, 95LL, (void *) 4, &err);
- timers[4]=tim_set(&cell_base, &the_base, 95LL, (void *) 5, &err);
- timers[5]=tim_set(&cell_base, &the_base, 95LL, (void *) 6, &err);
- timers[6]=tim_set(&cell_base, &the_base, 104LL, (void *) 7, &err);
- timers[7]=tim_set(&cell_base, &the_base, 104LL, (void *) 8, &err);
- timers[8]=tim_set(&cell_base, &the_base, 104LL, (void *) 9, &err);
-
- tim_cancel(timers[6], &err);
-
-
- res.head=res.tail=NULL;
-for(i=90;i<106;i++)
- {
-tim_return_fired_list(&cell_base, &res, &the_base, (unsigned long long) i, &n);
- printf("at %d got %d\n", i, n);
- if (n) {tim_return_free(&the_base,&res,n); res.head=res.tail=NULL;
-
- }
-
-//special cases..
- res.head=res.tail=NULL;
- timers[0]=tim_set(&cell_base, &the_base, 106LL, (void *)10, &err);
- tim_cancel(timers[0],&err);
- tim_return_fired_list(&cell_base, &res, &the_base, (unsigned long long) 106, &n);
-
- res.head=res.tail=NULL;
- timers[0]=tim_set(&cell_base, &the_base, 106LL, (void *)10, &err);
- timers[1]=tim_set(&cell_base, &the_base, 106LL, (void *)10, &err);
- tim_cancel(timers[0],&err);
- tim_return_fired_list(&cell_base, &res, &the_base, (unsigned long long) 106, &n);
-
- res.head=res.tail=NULL;
- timers[0]=tim_set(&cell_base, &the_base, 106LL, (void *)10, &err);
- timers[1]=tim_set(&cell_base, &the_base, 106LL, (void *)10, &err);
- tim_cancel(timers[0],&err);
- tim_cancel(timers[1],&err);
- tim_return_fired_list(&cell_base, &res, &the_base, (unsigned long long) 106, &n);
-
-}
-#endif
diff --git a/ti/runtime/netapi/test/addsa_test.c b/ti/runtime/netapi/test/addsa_test.c
--- /dev/null
@@ -0,0 +1,1576 @@
+/******************************************
+ * 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
+
+
+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
+
+
+//#define NP 5000
+//int n_pkt = NP;
+
+Trie *p_trie_sa;
+
+/*******************************************
+ *************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;
+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)
+{
+}
+
+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");
+
+ //printf("sa_build_db(): authOffset %d, innerIpOffset %d, encOffset %d\n", sa_info[i].tx_payload_info.authOffset, sa_info[i].inner_ip_offset, sa_info[i].tx_payload_info.encOffset);
+ printf("build_sa_db spi 0x%x\n", spi);
+
+}
+
+/***************************************
+ ********** 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
+
+
+#if 0
+ /* add mac intefaces */
+ netcp_cfgCreateMacInterface(
+ netapi_handle,
+ &config.mac0[0],
+ ETH0,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); }
+
+ //attach an IP to this interface
+ ip_rule0[0]=netcp_cfgAddIp(
+ netapi_handle,
+ ETH0,
+ nwal_IPV4,
+ &config.ip0,
+ NULL, //all IP
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL,
+ &err
+ );
+ if (err) {printf("addip0 failed %d\n",err); exit(1); }
+
+ //create a 2nd mac instance
+ netcp_cfgCreateMacInterface(
+ netapi_handle,
+ &config.mac1[0],
+ ETH1,1,
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL,
+ (NETCP_CFG_VLAN_T ) NULL , //future
+ 1,
+ &err);
+ if (err) {printf("addmac1 failed %d\n",err); exit(1); }
+
+ //attach an IP to this interface
+ ip_rule1[0]=netcp_cfgAddIp(
+ netapi_handle,
+ ETH1,
+ nwal_IPV4,
+ &config.ip1,
+ NULL, //all IP
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL,
+ &err
+ );
+ if (err) {printf("addip1 failed %d\n",err); exit(1); }
+#endif
+
+
+#if todo
+ //attach 2 classifiers to iface 0, ip0
+ class_0_cfg.u.c_l4.ip = ip_rule0[0];
+ class_0 = netcp_cfgAddClass(netapi_handle,
+ &class_0_cfg,
+ NULL,
+ NETCP_CFG_ACTION_TO_SW,
+ &err);
+ if (err) {printf("addclass0 failed %d\n",err); exit(1);}
+
+ class_1_cfg.u.c_l4.ip = ip_rule0[0];
+ class_1 = netcp_cfgAddClass(netapi_handle,
+ &class_1_cfg,
+ NULL,
+ NETCP_CFG_ACTION_TO_SW,
+ &err);
+ if (err) {printf("addclass1 failed %d\n",err); exit(1);}
+
+
+ //3rd classifier has a different IP and route
+ class_2_cfg.u.c_l3_l4.ip_addr = &config.ip2;
+#endif
+
+ //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;
+ }
+
+//security stuff
+ p_trie_sa = trie_new();
+ if (!p_trie_sa) {printf("trie alloc for SA failed\n"); exit(1);}
+
+ count = 0;
+
+#ifdef TEST_MAC_IP
+ for (i = 0; i < MAC_CREATE_LOOP_COUNT ;i++)
+ {
+ /* add mac intefaces */
+ netcp_cfgCreateMacInterface(
+ netapi_handle,
+ &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 < IP_CREATE_LOOP_COUNT ;i++)
+ {
+ //attach an IP to this interface
+ ip_rule0[i]=netcp_cfgAddIp(
+ netapi_handle,
+ 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]++;
+ }
+
+ }
+#endif
+
+
+ sleep(5);
+#ifdef TEST_SA
+
+ for (i = 0; i < SA_CREATE_LOOP_COUNT;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("main: calling netapi_secAddSA for rx, count = %d\n", count);
+ sa_info[i].rx_tunnel = netapi_secAddSA(
+ netapi_handle,
+ 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 (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
+ for (i = 0; i <SA_CREATE_LOOP_COUNT;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("main: calling netapi_secAddSA for tx, count = %d\n", count);
+ sa_info[i].tx_tunnel = netapi_secAddSA( netapi_handle,
+ 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);}
+ }
+
+#endif
+
+ /*************************************************
+ ************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;
+ //delete policy
+#ifdef TEST_SA
+ for (i = 0; i < SA_CREATE_LOOP_COUNT;i++)
+ {
+ if (rx_policy[i])
+ netapi_secDelRxPolicy(netapi_handle, rx_policy[i], &err);
+ count ++;
+ //delete tunnels
+ printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
+ netapi_secDelSA(netapi_handle, 0, sa_info[i].rx_tunnel, &err);
+ //sleep(1);
+ //printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
+ netapi_secDelSA(netapi_handle, 0, sa_info[i].tx_tunnel, &err);
+ }
+#endif
+
+#ifdef TEST_MAC_IP
+ //delete IPs and MAC Interfacess
+ for (i = 0; i < IP_CREATE_LOOP_COUNT;i++)
+ {
+ printf("calling netcp_cfgDelIp and for index %d\n", i);
+ netcp_cfgDelIp(netapi_handle, i, 0, NULL, NULL, ip_rule0[i], &err);
+ netcp_cfgDelMac(netapi_handle,i,&err);
+ }
+ for (i = 0; i < MAC_CREATE_LOOP_COUNT;i++)
+ {
+ printf("calling and netcp_cfgDelMac for index %d\n", i);
+ netcp_cfgDelMac(netapi_handle,i,&err);
+ }
+#endif
+ //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 b0f695fd54ad311c29989142034b8943d5b630f5..33ecb1a222658d27acd03451839ea9798a917f61 100755 (executable)
export NETAPI_INSTALL_PATH ?= $(TRANS_SDK_INSTALL_PATH)
TRIE_OBJS=$(ARMV7OBJDIR)/netapi/test/trie.o
-NT_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test.o $(ARMV7OBJDIR)/netapi/test/stubs.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
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
+tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test $(ARMV7BINDIR)/netapi/test/addsa_test
+
api_clean:
rm -f $(ARMV7LIBDIR)/libnetapi.a
clean:
rm -f $(ARMV7OBJDIR)/netapi/test/*.o
rm -f $(ARMV7LIBDIR)/libnetapi.a
- rm -f $(ARMV7BINDIR)/netapi/test/net_test $(ARMV7BINDIR)/netapi/test/synchtest $(ARMV7BINDIR)/netapi/test/synchtest2
+ rm -f $(ARMV7BINDIR)/netapi/test/net_test
+ rm -f $(ARMV7BINDIR)/netapi/test/addsa_test
$(ARMV7OBJDIR)/netapi/test/%.o:$(NETAPI_INC_DIR)/test/%.c $(ARMV7OBJDIR)/netapi/test/.created
$(CC) $(LDFLAGS) $(NTB_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/nt_bridge
+$(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
+
index cfd49f7cc3002cb780df7d49d2c854056540a35c..50a73c3f8021463aef581e991ab6fd912b7d8d1e 100755 (executable)
#define NP 5000
int n_pkt = NP;
-STATS_T stats;
+STATS_T stats[TUNE_NETAPI_NUM_CORES];
paSysStats_t netcp_stats;
Trie * P_trie;
};
void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats);
void our_stats_cb_mt(NETAPI_T h, paSysStats_t* pPaStats);
+
+
+#ifdef TEST_TIMERS
HPLIB_TIMER_GROUP_HANDLE_T ourTimerBlock;
HPLIB_TIMER_T t1;
HPLIB_TIMER_T t2;
int n_fired, //# timers fired
HPLIB_TIMER_LIST_T fired_list,
uint64_t currentTime);
-
+#endif
NETCP_CFG_IP_T ip_rule0;
NETCP_CFG_IP_T ip_rule1;
NETCP_CFG_CLASS_T class_0;
int netapi_algorithm_set = 0;
int netapi_sec_sa_mode = 2;
-NETCP_CFG_IPSEC_POLICY_T rx_policy[4];
+NETCP_CFG_IPSEC_POLICY_T rx_policy[7];
int check_header(HEAD_T * p_head, PKTIO_METADATA_T * p_meta)
{
+#ifdef MULTI_THREAD
+ int coreid=our_core; //who we are(thread local)
+#else
+ int coreid=0;
+#endif
if (NWAL_RX_FLAG1_META_DATA_VALID & p_meta->u.rx_meta->rxFlag1)
{
lpInfo.iface = ((unsigned int)p_meta->u.rx_meta->appId) &0xff; //last byte is interface num
lpInfo.l4csum = (p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_MASK )== ((NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_ACK) << NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_SHIFT) ? 1 : 0;
if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC)
{
- stats.sec_rx++;
+ stats[coreid].sec_rx++;
}
if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC_POLICY)
{
- stats.secp_rx++;
+ stats[coreid].secp_rx++;
}
if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_CLASS)
{
int c= ((unsigned int)p_meta->u.rx_meta->appId >>8)&0xffff;
- if (c==0) stats.n_class0_rx +=1;
- else if (c==1) stats.n_class1_rx +=1;
- else if (c==2) stats.n_class2_rx +=1;
+ if (c==0) stats[coreid].n_class0_rx +=1;
+ else if (c==1) stats[coreid].n_class1_rx +=1;
+ else if (c==2) stats[coreid].n_class2_rx +=1;
else printf("**NET_TEST RX -unknown class: %x\n", p_meta->u.rx_meta->appId);
}
}
buffer[2]= (temp&0xff00)>>8;
buffer[3]= (temp&0xff);
Pktlib_setPacketLen(tip, temp);
- v1= hplib_mUtilGetTickCount();
+ v1= hplib_mUtilGetPmuCCNT();
paEx_reassemLibProc(tip, 0xffff);
- v2= hplib_mUtilGetTickCount();
+ v2= hplib_mUtilGetPmuCCNT();
sum1+= v2-v1;
}
sum2 += v2-v1;
printf("calibration loop .. ");
for(i=0;i<1000;i++)
{
- vv1= hplib_mUtilGetTickCount();
- vv2= hplib_mUtilGetTickCount();
+ vv1= hplib_mUtilGetPmuCCNT();
+ vv2= hplib_mUtilGetPmuCCNT();
sum+=(vv2-vv1);
}
printf(" accuracy = +- %d cycles\n", sum/1000);
//send single, recv single
for(i=0;i<ntrials;i++)
{
- vv1= hplib_mUtilGetTickCount();
+ vv1= hplib_mUtilGetPmuCCNT();
tip=Pktlib_allocPacket(ourHeap,PKT_LEN);
- vv2= hplib_mUtilGetTickCount();
+ vv2= hplib_mUtilGetPmuCCNT();
Pktlib_getDataBuffer(tip,&pData,&len);
- vv3= hplib_mUtilGetTickCount();
+ vv3= hplib_mUtilGetPmuCCNT();
pktio_send(our_chan,tip,&meta[0],&err);
- vv4= hplib_mUtilGetTickCount();
+ vv4= hplib_mUtilGetPmuCCNT();
n=pktio_poll(our_chan,NULL , &err);
- vv5= hplib_mUtilGetTickCount();
+ vv5= hplib_mUtilGetPmuCCNT();
timings[0]+=(vv6-vv4);
timings[1]+=(vv5-vv4);
timings[3]+=(vv4-vv3);
@@ -1123,6 +1131,11 @@ void flip_and_send_pkt(Ti_Pkt *tip, unsigned char * p_pkt, int len, int flag)
uint8_t p_add[8];
Cppi_HostDesc* pPloadDesc;
+#ifdef MULTI_THREAD
+int coreid=our_core; //who we are(thread local)
+#else
+int coreid=0;
+#endif
//netapi_dump_buf((long*)p_pkt,len);
Pktlib_setPacketLen(tip,len);
//flip the mac address
//just drop non-udp packet
if (p_pkt[p_sa_info->tx_payload_info.encOffset+9]!=0x11)
{
- stats.n_new+=1;Pktlib_freePacket(tip); return;
+ stats[coreid].n_new+=1;Pktlib_freePacket(tip); return;
}
/* flip inner IP */
//meta_tx.authIvSize=0;
/* post it to netcp sb tx channel*/
- meta_tx.appCtxId = (nwal_AppId)hplib_mUtilGetTickCount();
+ meta_tx.appCtxId = (nwal_AppId)hplib_mUtilGetPmuCCNT();
meta.u.tx_sb_meta=&meta_tx;
#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
Pktlib_freePacket(tip);
tip=new_tip;
Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&new_len); //reset p_pkt to point to new buffer as its used below
- Cppi_setTimeStamp (Cppi_DescType_HOST, (Cppi_Desc *) tip,stats.sec_tx);
+ Cppi_setTimeStamp (Cppi_DescType_HOST, (Cppi_Desc *) tip,stats[coreid].sec_tx);
}
}
if (len <1500)
/* post it to netcp tx channel*/
meta.u.tx_meta=&meta_tx;
- if (stats.sec_tx<20) dump_descr((long *) tip, stats.sec_tx);
+ if (stats[coreid].sec_tx<20) dump_descr((long *) tip, stats[coreid].sec_tx);
pktio_send(netcp_tx_chan,tip,&meta,&err);
- stats.tx +=1;
- stats.sec_tx +=1;
+ stats[coreid].tx +=1;
+ stats[coreid].sec_tx +=1;
}
}
else //non ipsec send pkt directly, asking for IP and UDP checksum ofload
/* post it to netcp tx channel*/
meta2.u.tx_meta=&meta_tx2;
pktio_send(netcp_tx_chan,tip,&meta2,&err);
- stats.tx +=1;
+ stats[coreid].tx +=1;
}
}
uint64_t ts )
{
int i;
- vv6= hplib_mUtilGetTickCount();
+ vv6= hplib_mUtilGetPmuCCNT();
for (i=0;i<n_pkts; i++)
{
Pktlib_freePacket(p_recv[i]);
}
- vv11 = hplib_mUtilGetTickCount();
+ vv11 = hplib_mUtilGetPmuCCNT();
}
/****************************************************************************************/
uint8_t *p_spi;
netTestSA_t *p_sa_info;
+#ifdef MULTI_THREAD
+int coreid=our_core; //who we are(thread local)
+#else
+int coreid=0;
+#endif
//nwal_AppId time;
unsigned long time, delta_time;
/* loop over received pkts */
if ((int)meta[i].u.rx_sb_meta->appId == p_sa_info->rx_tunnel)
{
- time = hplib_mUtilGetTickCount();
+ time = hplib_mUtilGetPmuCCNT();
delta_time = time -(unsigned long) meta[i].u.rx_sb_meta->appCtxId;
- stats.total_decrypt_time += delta_time;
- stats.sb_rx+=1;
+ stats[coreid].total_decrypt_time += delta_time;
+ stats[coreid].sb_rx+=1;
//copy hash out of meta data (for some reason it needs endian conversion)
hash[0]= htonl( meta[i].u.rx_sb_meta->pAuthTag[0]);
hash[1]= htonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
hash[2]= htonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
hash[3]= htonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
- if(stats.sb_rx<=16)
+ if(stats[coreid].sb_rx<=16)
{
char *tp = (char *) &hash[0];
- //dump_header((long*)p_pkt, stats.sb_rx, (int)meta[i].u.rx_sb_meta->appId,0);
+ //dump_header((long*)p_pkt, stats[coreid].sb_rx, (int)meta[i].u.rx_sb_meta->appId,0);
#if 0
printf("decrypt complete: tag in pkt= %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x \n",
p_pkt[len-16],p_pkt[len-15],p_pkt[len-14],p_pkt[len-13],
//check tag
//printf("recv_sb_cb(); auth tag size %d\n", p_sa_info->auth_tag_size);
tag_cmp = memcmp(&p_pkt[len-p_sa_info->auth_tag_size],(char*) &hash[0],p_sa_info->auth_tag_size); //todo, really use meta->authTagLen
- stats.n_auth_ok += !(tag_cmp);
+ stats[coreid].n_auth_ok += !(tag_cmp);
flip_and_send_pkt(tip, p_pkt, len,1); //flip packet to echo back and send
}
hash[1]= htonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
hash[2]= htonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
hash[3]= htonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
- stats.sb_tx+=1;
- if(stats.sb_tx<=16)
+ stats[coreid].sb_tx+=1;
+ if(stats[coreid].sb_tx<=16)
{
char *tp1 = (char *) &hash[0];
- //dump_header((long*)p_pkt, stats.sb_tx, (int)meta[i].u.rx_sb_meta->appId,0);
+ //dump_header((long*)p_pkt, stats[coreid].sb_tx, (int)meta[i].u.rx_sb_meta->appId,0);
#if 0
printf("encrypt complete: tag in pkt= %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x \n",
p_pkt[len-16],p_pkt[len-15],p_pkt[len-14],p_pkt[len-13],
meta_tx.l4OffBytes = 0;
meta_tx.l4HdrLen = 0;
meta_tx.ploadLen = 0;
- time = hplib_mUtilGetTickCount();
+ time = hplib_mUtilGetPmuCCNT();
delta_time = time -(unsigned long) meta[i].u.rx_sb_meta->appCtxId;
- stats.total_encrypt_time += delta_time;
+ stats[coreid].total_encrypt_time += delta_time;
/* post it to netcp tx channel*/
// printf("recv_sb_cb(): calling pktio send to send it to network\n");
pktio_send(netcp_tx_chan,tip,&meta2,&err);
hplib_cacheWbInv(p_pkt,len);
- stats.tx +=1;
+ stats[coreid].tx +=1;
}
}
else printf("netapi recv_sb_cb: unknown appiD %x \n",meta[i].u.rx_sb_meta->appId );
for(i=0;i<n_pkts;i++)
{
ifno = ((unsigned int)meta[i].u.rx_meta->appId)&0xff;
- if(coreid<TUNE_NETAPI_NUM_CORES) stats.core_rx[coreid]+=1;
- if (ifno < TUNE_NETAPI_MAX_INTERFACES) stats.if_rx[ifno]+=1;
+ 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];
printf(" rcv_cb, nexpkt != NULL");
}
- stats.rx+=1;
+ stats[coreid].rx+=1;
#ifdef DEBUG_DESC
- if (stats.rx<16)
+ if (stats[coreid].rx<16)
{
printf(">rx dmp..");
- dump_descr((long *) tip, stats.rx);
+ dump_descr((long *) tip, stats[coreid].rx);
}
- else if (stats.rx>99)
+ else if (stats[coreid].rx>99)
{
printf(">rx dmp..");
- dump_descr((long *) tip,stats.rx);
+ dump_descr((long *) tip,stats[coreid].rx);
}
#endif
#if 0
- if(stats.rx<=16)
+ if(stats[coreid].rx<=16)
{
- dump_header((long*)p_pkt, stats.rx, (int)meta[i].u.rx_meta->appId,meta[i].u.rx_meta->rxFlag1);
+ dump_header((long*)p_pkt,stats[coreid].rx, (int)meta[i].u.rx_meta->appId,meta[i].u.rx_meta->rxFlag1);
netapi_dump_buf((long*)p_pkt,len);
}
#endif
{
if (!check_header(p_head,&meta[i]))
{
- stats.n_bad+=1;Pktlib_freePacket(tip);
+ stats[coreid].n_bad+=1;Pktlib_freePacket(tip);
continue;
}
meta_tx.pEncIV = &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN ];
}
- meta_tx.appCtxId = (nwal_AppId)hplib_mUtilGetTickCount();
+ meta_tx.appCtxId = (nwal_AppId)hplib_mUtilGetPmuCCNT();
//printf("recv_cb appCtxId: %lu\n", meta_tx.appCtxId);
/* post it to netcp sb tx channel*/
}
else if ((p_head->ip[2]&0x0000ff00)!=0x00001100)
{
- stats.n_new+=1;Pktlib_freePacket(tip); continue;
+ stats[coreid].n_new+=1;Pktlib_freePacket(tip); continue;
}
else //non ipsec
{
if (!check_header(p_head,&meta[i]))
{
- stats.n_bad+=1;Pktlib_freePacket(tip);
+ stats[coreid].n_bad+=1;Pktlib_freePacket(tip);
continue;
}
key.src_port= (p_head->udp[0]&0xffff0000)>>16;
key.dst_port= (p_head->udp[0]&0x0000ffff);
p_res= (HEAD_T *) trie_lookup(P_trie, (char *) &key, sizeof(key));
- if (!p_res) { stats.n_new+=1; slow_path(tip, len); continue;}
+ if (!p_res) { stats[coreid].n_new+=1; slow_path(tip, len); continue;}
/* copy header */
memcpy((char *) p_head, (char *) p_res, sizeof(HEAD_T));
int cookie;
int err;
unsigned long long et;
+#ifdef MULTI_THREAD
+ int coreid=our_core; //who we are(thread local)
+#else
+ int coreid=0;
+#endif
//DEBUGprintf("TIMER CALLBACK @ %lld %d timers\n", currentTime, n_fired);
tx = hplib_Timer_GetFirst(fired_list);
for(i=0;i<n_fired;i++)
//DEBUGprintf(" timer %d - cookie = %d expected ts=%lld (delta=%lld)\n", i, cookie, et, currentTime-et);
if (cookie ==1)
{
- stats.n_t1+=1;
+ stats[coreid].n_t1+=1;
t1 = hplib_Timer_Start(
th,
(void *) 1,
}
else if (cookie ==2)
{
- stats.n_t2+=1;
+ stats[coreid].n_t2+=1;
t2 = hplib_Timer_Start(
th,
(void *) 2,
}
else
{
- stats.n_t3+=1;
+ stats[coreid].n_t3+=1;
t3 = hplib_Timer_Start(
th,
(void *) 3,
*******************************************************/
void our_stats_cb_mt(NETAPI_T h, paSysStats_t* pPaStats)
{
- stats.n_stats_cb +=1;
+
+#ifdef MULTI_THREAD
+int coreid=our_core; //who we are(thread local)
+#else
+int coreid=0;
+#endif
+
+ stats[coreid].n_stats_cb +=1;
if(pPaStats) memcpy(&netcp_stats,pPaStats, sizeof(paSysStats_t));
}
void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats)
unsigned long long tmp_ccyclesL[TUNE_NETAPI_NUM_CORES]; //cache cycles
NETAPI_SA_STATS_T netapi_sa_stats;
-printf(">*****stats @ %lld (#cbs%d) \n", hplib_mUtilGetTimestamp(),stats.n_stats_cb);
-//printf("netcp_tx_handle check %x\n", netcp_tx_chan->back);
-printf(">itx=%d rx=%d tx=%d bad=%d slow=%d \n>rx_class0=%d rx_class1=%d rx_class2=%d secRx=%d secPRX=%d sb_rx=%d sb_tx=%d auth_ok=%d sec_tx=%d min_rx=%d min_tx=%d\n",
- stats.itx, stats.rx, stats.tx, stats.n_bad, stats.n_new,
- stats.n_class0_rx, stats.n_class1_rx,
- stats.n_class2_rx, stats.sec_rx, stats.secp_rx, stats.sb_rx, stats.sb_tx, stats.n_auth_ok,
- stats.sec_tx, stats.rx_min, stats.tx_min);
-printf(">if rx stats: %d %d %d\n",stats.if_rx[0],stats.if_rx[1],stats.if_rx[2]);
-printf(">core rx stats: %d %d %d\n",stats.core_rx[0],stats.core_rx[1],stats.core_rx[2]);
-
+ for (i=0;i < TUNE_NETAPI_NUM_CORES;i++)
+ {
+ printf("Per Core Statistics for CORE %d\n", i);
+ printf(">*****stats @ %lld (#cbs%d) \n", hplib_mUtilGetTimestamp(),stats[i].n_stats_cb);
+ printf(">itx=%d rx=%d tx=%d bad=%d slow=%d \n>rx_class0=%d rx_class1=%d rx_class2=%d secRx=%d secPRX=%d sb_rx=%d sb_tx=%d auth_ok=%d sec_tx=%d min_rx=%d min_tx=%d\n",
+ stats[i].itx, stats[i].rx, stats[i].tx, stats[i].n_bad, stats[i].n_new,
+ stats[i].n_class0_rx, stats[i].n_class1_rx,
+ stats[i].n_class2_rx, stats[i].sec_rx, stats[i].secp_rx, stats[i].sb_rx, stats[i].sb_tx, stats[i].n_auth_ok,
+ stats[i].sec_tx, stats[i].rx_min, stats[i].tx_min);
+ printf(">if rx stats: %d %d %d\n",stats[i].if_rx[0],stats[i].if_rx[1],stats[i].if_rx[2]);
+ printf(">core rx stats: %d \n",stats[i].core_rx);
+
+ if (stats[i].rx && stats[i].tx)
+ printf("decrypt time per packet(avg): %lu, encrypt time per packet(avg): %lu\n",
+ (unsigned long) stats[i].total_decrypt_time/stats[i].rx, (unsigned long) stats[i].total_encrypt_time/stats[i].tx);
+
+
+ if (npL && stats[i].rx)
+ {
+ bcpp = cyclesL/npL;
+ bcpp_noc = (cyclesL-ccyclesL)/npL;
+ bcpp_app = (stats[i].app_cycles-stats[i].tx_cache_cycles)/stats[i].rx;
+ }
+ else
+ {
+ bcpp = bcpp_noc=bcpp_app=0L;
+ }
+ if (stats[i].tx)
+ {
+ bcpp_tx = (stats[i].send_cycles-stats[i].tx_cache_cycles)/stats[i].tx;
+ }
+ else
+ {
+ bcpp_tx = 0L;
+ }
+ printf("> ++ busy cycles pp=%lld (%lld wo cache ops) (app+tx= %lld) (tx= %lld) ++\n",
+ bcpp,bcpp_noc,bcpp_app, bcpp_tx);
+ printf("\n");
+ }
-if (stats.rx && stats.tx)
- printf("decrypt time per packet(avg): %lu, encrypt time per packet(avg): %lu\n",
- (unsigned long) stats.total_decrypt_time/stats.rx, (unsigned long) stats.total_encrypt_time/stats.tx);
#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]);
#else
netapi_sched_get_stats(our_sched, &npL,&cyclesL,&ccyclesL);
#endif
-if (npL && stats.rx) {
- bcpp = cyclesL/npL;
- bcpp_noc = (cyclesL-ccyclesL)/npL;
- bcpp_app = (stats.app_cycles-stats.tx_cache_cycles)/stats.rx;
-}
-else {bcpp = bcpp_noc=bcpp_app=0L;}
-if (stats.tx)
-{
- bcpp_tx = (stats.send_cycles-stats.tx_cache_cycles)/stats.tx;
-}else {bcpp_tx = 0L;}
-printf("> ++ busy cycles pp=%lld (%lld wo cache ops) (app+tx= %lld) (tx= %lld) ++\n",
- bcpp,bcpp_noc,bcpp_app, bcpp_tx);
+
if(pPaStats)
{
printf("C1 number of packets: %d\n", pPaStats->classify1.nPackets);
static int first =0;
Cppi_HostDesc* pPktDesc;
+int coreid = 0; //who we are
#ifdef MULTI_THREAD
-int coreid; //who we are
NETAPI_T nh= netapi_schedGetNetapiHandle(s);
coreid=(int) netapi_getCookie(nh);
/* set the pkt length */
- vv1 = hplib_mUtilGetTickCount();
+ vv1 = hplib_mUtilGetPmuCCNT();
Pktlib_setPacketLen(tip, len);
/* set up meta data */
if(!first)
{
first++;
- nwal_flow_vv1= hplib_mUtilGetTickCount();
+ nwal_flow_vv1= hplib_mUtilGetPmuCCNT();
if(nwal_initPSCmdInfo(PKTIO_GET_NWAL_INSTANCE(netcp_tx_chan),
&meta_tx,
&flowPSCmdInfo) != nwal_OK)
{
printf("nwal_initPSCmdInfo() ERROR \n");
}
- nwal_flow_vv2= hplib_mUtilGetTickCount();
+ nwal_flow_vv2= hplib_mUtilGetPmuCCNT();
nwal_sum_flow_vv1 += (nwal_flow_vv1-vv1);
nwal_sum_flow_vv2 += (nwal_flow_vv2-nwal_flow_vv1);
}
cache_op_b1= Osal_cache_op_measure(&n_c_ops);
- vv2= hplib_mUtilGetTickCount();
+ vv2= hplib_mUtilGetPmuCCNT();
#ifdef BEND_UDP_SEND
nwal_mCmdSetL4CkSumPort( tip,
&flowPSCmdInfo,
Qmss_queuePushDescSize (flowPSCmdInfo.txQueue,
pPktDesc,
NWAL_DESC_SIZE);
- vv3= hplib_mUtilGetTickCount();
+ vv3= hplib_mUtilGetPmuCCNT();
cache_op_b2= Osal_cache_op_measure(&n_c_ops);
sum_vv1 += (vv2-vv1);
// printf("pktio send. full=%d metadata=%d pktio_send=%d\n", vv3-vv1, vv2-vv1, vv3-vv2);
- stats.itx +=1;
+ stats[coreid].itx +=1;
house_pkts_gened +=1;
}
{
if (sum_vv1)
{
printf("BURST NWAL Fast send %d pkts. metadata=%d Cmd Label Creation Cost=%d nwal Fast Send Cost (less cacheop)= %d n_c_ops=%lld cache_op_time=%lld (pp-> %d)\n",
- stats.itx, sum_vv1/stats.itx, nwal_sum_flow_vv2, sum_vv3/stats.itx,
+ stats[coreid].itx, sum_vv1/stats[coreid].itx, nwal_sum_flow_vv2, sum_vv3/stats[coreid].itx,
n_c_ops, ccycles, n_c_ops? (ccycles/(n_c_ops/2L)) : 0);
#if 0
printf("NWAL Profile Cycles: Prof1= %d,Prof2=%d,Prof3=%d,Prof4=%d,Prof5=%d ,Prof6=%d \n",
- nwal_sum_vv1/stats.itx,nwal_sum_vv2/stats.itx,nwal_sum_vv3/stats.itx,
- nwal_sum_vv4/stats.itx,nwal_sum_vv5/stats.itx,nwal_sum_vv6/stats.itx);
+ nwal_sum_vv1/stats[coreid].itx,nwal_sum_vv2/stats[coreid].itx,nwal_sum_vv3/stats[coreid].itx,
+ nwal_sum_vv4/stats[coreid].itx,nwal_sum_vv5/stats[coreid].itx,nwal_sum_vv6/stats[coreid].itx);
#endif
- if(stats.itx2)
+ if(stats[core_id].itx2)
{
printf("nwal_flowSend Profile Cycles: Prof1= %d,Prof2=%d \n",
- nwal_sum_flow_vv1/stats.itx2,nwal_sum_flow_vv2/stats.itx2);
+ nwal_sum_flow_vv1/stats[coreid].itx2,nwal_sum_flow_vv2/stats[coreid].itx2);
}
}
CPU_ZERO( &cpu_set);
#ifdef CORTEX_15
CPU_SET( coreid, &cpu_set);
- hplib_Util_SetupCore(coreid, &cpu_set);
+ hplib_utilSetupCore(coreid, &cpu_set);
#else
CPU_SET( 0, &cpu_set);
- hplib_Util_SetupCore(0, &cpu_set);
+ hplib_utilSetupCore(0, &cpu_set);
#endif
worker_nh[coreid]=netapi_init(NETAPI_NO_MASTER,NULL);
netapi_setCookie(worker_nh[coreid],coreid);
#ifdef CORTEX_15
CPU_SET( coreid, &cpu_set);
- hplib_Util_SetupCore(coreid, &cpu_set);
+ hplib_utilSetupCore(coreid, &cpu_set);
#else
CPU_SET( 0, &cpu_set);
- hplib_Util_SetupCore(0, &cpu_set);
+ hplib_utilSetupCore(0, &cpu_set);
#endif
printf("fast_path_thread, mypid: %d\n", gettid());
- hplib_Util_SetupCore(coreid, &cpu_set);
+ hplib_utilSetupCore(coreid, &cpu_set);
worker_nh[coreid]=netapi_init(NETAPI_NO_MASTER,NULL);
netapi_setCookie(worker_nh[coreid],coreid);
our_core=coreid;
memcpy(&testPkt[26],&real_ip_addr[0],8);//overrite test pkt ip addresses
}
+#ifdef MULTI_THREAD
/* assign main net_test thread to run on core 0 */
CPU_ZERO( &cpu_set);
CPU_SET( 0, &cpu_set);
- hplib_Util_SetupCore(0, &cpu_set);
-
+ hplib_utilSetupCore(0, &cpu_set);
+#endif
/* create netapi */
netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
for(i=0;i<n_trials;i++)
{
//raw pop
- t1= hplib_mUtilGetTickCount();
+ t1= hplib_mUtilGetPmuCCNT();
pHd[0] = (Ti_Pkt *)QMSS_DESC_PTR(PKTIO_QMSS_QUEUE_POP_RAW (freeQ));
for(j=1;j<NTOPOP;j++)
{
tempVA = hplib_mVMPhyToVirt(pHd[j-1]);
sumf+= (int) ( ((Cppi_HostDesc *) tempVA)->origBuffPtr -
((Cppi_HostDesc *) tempVA)->buffPtr);
- t2=hplib_mUtilGetTickCount();
+ t2=hplib_mUtilGetPmuCCNT();
sumt+= (t2-t1);
//invalidate/wb
}
//raw push
- t1=hplib_mUtilGetTickCount();
+ t1=hplib_mUtilGetPmuCCNT();
for(j=0;j<NTOPOP;j++)
{
PKTIO_QMSS_QUEUE_PUSH_DESC_SIZE_RAW (freeQ,
(void *) pHd[j],
128);
}
- t2=hplib_mUtilGetTickCount();
+ t2=hplib_mUtilGetPmuCCNT();
sump += (t2-t1);
}
printf("\nfast poppush: np=%d pop=%d push=%d sumf=%d\n", (n_trials*NTOPOP),
//loop forever
for(;max_pkts>0;)
{
- t1= hplib_mUtilGetTickCount();
+ t1= hplib_mUtilGetPmuCCNT();
pHd[0] = (Ti_Pkt *)QMSS_DESC_PTR(PKTIO_QMSS_QUEUE_POP_RAW (rxQ));
if (!pHd[0]) continue;
//got pkt
Cppi_getData (Cppi_DescType_HOST, (Cppi_Desc*)tempVA, &buf[jj], &len[jj]);
jj+=1;
}
- t2= hplib_mUtilGetTickCount();
+ t2= hplib_mUtilGetPmuCCNT();
j+=(pHd[i-1]? i: (i-1)) ;
if (jj>(M-n)) jj=0;
l+=1; //n batches
hplib_cacheWbInv(tempVA,128);
//would need to wbInv buffer also in practice. Also need to walk
// descriptor chain
- t11= hplib_mUtilGetTickCount();
+ t11= hplib_mUtilGetPmuCCNT();
// Pktlib_freePacket(tempVA);
PKTIO_QMSS_QUEUE_PUSH_DESC_SIZE_RAW (freeQ,
(void *) pHd[k],
128);
- t12= hplib_mUtilGetTickCount();
+ t12= hplib_mUtilGetPmuCCNT();
sumf += (t12-t11);
}
}
@@ -3698,7 +3744,7 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
int err=0;
PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
nwalTxPktInfo_t meta_tx2={0};
- st1=hplib_mUtilGetTickCount();
+ st1=hplib_mUtilGetPmuCCNT();
if (len<60)
{
unsigned int templen;
@@ -3706,7 +3752,7 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
len=60;
Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, p_pkt,len);
- stats.tx_min+=1;
+ stats[coreid].tx_min+=1;
}
Pktlib_setPacketLen(tip,len);
meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
@@ -3720,13 +3766,13 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
meta2.sa_handle=p_sec->tx_inflow_mode_handle; //this tells netapi that inflow crypto needs to be applied
meta_tx2.saOffBytes=14+20;
meta_tx2.saPayloadLen=len-14-20; //don't include tag, mac and outer header
- stats.sec_tx+=1;
+ stats[coreid].sec_tx+=1;
}
meta2.u.tx_meta=&meta_tx2;
pktio_send(netcp_tx_chan,tip,&meta2,&err);
- stats.tx +=1;
- st2=hplib_mUtilGetTickCount();
- stats.send_cycles += (unsigned long long) (st2-st1);
+ stats[coreid].tx +=1;
+ st2=hplib_mUtilGetPmuCCNT();
+ stats[coreid].send_cycles += (unsigned long long) (st2-st1);
}
void recv_cb_router(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
PKTIO_METADATA_T meta[], int n_pkts,
#else
int coreid=0;
#endif
-t1=hplib_mUtilGetTickCount();
+t1=hplib_mUtilGetPmuCCNT();
ct1 =Osal_cache_op_measure(&n_c_ops);
for(i=0;i<n_pkts;i++)
{
ifno = ((unsigned int)meta[i].u.rx_meta->appId)&0xff;
- if(coreid<TUNE_NETAPI_NUM_CORES) stats.core_rx[coreid]+=1;
- if (ifno < TUNE_NETAPI_MAX_INTERFACES) stats.if_rx[ifno]+=1;
+ 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
len = Pktlib_getPacketLen(tip)-4;//real length, subtract mac trailer
- stats.rx+=1;
+ stats[coreid].rx+=1;
appid = ((unsigned int)meta[i].u.rx_meta->appId)&0xff000000;
switch(appid)
{
int tailen=12+2;
memcpy(&temp_head,&p_pkt[14],sizeof(HEAD_T));
if (!check_header(&temp_head,&meta[i])) {
- stats.n_bad+=1;
+ stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
continue;
}
//now check inner headder.
memcpy(&th,&p_pkt[14],20);
if (!check_header(&temp_head,&meta[i])) {
- stats.n_bad+=1;
+ stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
continue;
}
if (route_pkt(our_router, tip, &th, p_pkt, &len,&sec_data,&out_port)<0)
{
- stats.n_bad+=1;
+ stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
}
else
case(NETAPI_NETCP_MATCH_GENERIC_MAC):
if((p_pkt[12]!=0x8)||(p_pkt[13]!=0x00))
{
- stats.n_new+=1;
+ stats[coreid].n_new+=1;
Pktlib_freePacket(tip);
continue;
}
if (!check_header(&temp_head,&meta[i]))
{
- stats.n_bad+=1;
+ stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
continue;
}
if ((ip_pl+14)<60)
{
len-= (60-(ip_pl+14));
- stats.rx_min+=1;
+ stats[coreid].rx_min+=1;
}
Pktlib_setPacketLen(tip,len);
if (route_pkt(our_router, tip, &th, p_pkt, &len,&sec_data,&out_port)<0)
{
- stats.n_bad+=1;
+ stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
}
else
break;
case(NETAPI_NETCP_MATCH_GENERIC_IP):
Pktlib_freePacket(tip);
- stats.n_new=1;
+ stats[coreid].n_new=1;
break;
default:
- stats.n_new+=1;
+ stats[coreid].n_new+=1;
Pktlib_freePacket(tip);
break;
}
}
-t2=hplib_mUtilGetTickCount();
+t2=hplib_mUtilGetPmuCCNT();
ct2 =Osal_cache_op_measure(&n_c_ops);
-stats.app_cycles += (unsigned long long) (t2-t1);
-stats.tx_cache_cycles += (unsigned long long) (ct2-ct1);
+stats[coreid].app_cycles += (unsigned long long) (t2-t1);
+stats[coreid].tx_cache_cycles += (unsigned long long) (ct2-ct1);
return;
}
#endif
index f2517c137dcb4571af05fee3b3382e78aa56b850..b997b815a7e4bf1875c92b6397fd1649e01a8bad 100755 (executable)
#define MAX_SEC_INDEX 7
-
//IPSEC MODE(only choose one rx and one tx)
#define IPSEC_MODE_RX_INFLOW 1
#define IPSEC_MODE_TX_INFLOW 2
} netTestConfig_t;
+
+typedef struct {
+unsigned char mac0[2][6];
+unsigned char mac1[2][6];
+nwalIpAddr_t ip0[2];
+nwalIpAddr_t ip1[2];
+nwalIpAddr_t ip2[2];
+nwalIpAddr_t local_ipsec_ip;
+nwalIpAddr_t remote_ipsec_ip;
+uint8_t ipsec_mode_rx;
+uint8_t ipsec_mode_tx;
+int ipsec_if_no; /* 0 if mac0, 1 if mac 1 */
+
+} netTestConfigMax_t;
+
typedef struct stats_t
{
long itx; //initially generated
long itx2;
- long rx;
- long tx;
- long n_bad;
- long n_new;
- long n_class0_rx; //count of pkts classified
- long n_class1_rx; //count of pkts classified
- long n_class2_rx; //count of pkts classified
- long n_t1;
- long n_t2;
- long n_t3;
- long sec_tx;
- long sec_rx;
- long sb_tx;
- long sb_rx;
- long secp_rx;
- long n_auth_ok;
- unsigned long long app_cycles;
- unsigned long long send_cycles;
- unsigned long long tx_cache_cycles;
- unsigned long long total_decrypt_time;
- unsigned long long total_encrypt_time;
- long rx_min;
- long tx_min;
- long if_rx[TUNE_NETAPI_MAX_INTERFACES];
- long core_rx[TUNE_NETAPI_NUM_CORES];
- long n_stats_cb;
- long ip;
+ long rx;
+ long tx;
+ long n_bad;
+ long n_new;
+ long n_class0_rx; //count of pkts classified
+ long n_class1_rx; //count of pkts classified
+ long n_class2_rx; //count of pkts classified
+ long n_t1;
+ long n_t2;
+ long n_t3;
+ long sec_tx;
+ long sec_rx;
+ long sb_tx;
+ long sb_rx;
+ long secp_rx;
+ long n_auth_ok;
+ unsigned long long app_cycles;
+ unsigned long long send_cycles;
+ unsigned long long tx_cache_cycles;
+ unsigned long long total_decrypt_time;
+ unsigned long long total_encrypt_time;
+ long rx_min;
+ long tx_min;
+ long if_rx[TUNE_NETAPI_MAX_NUM_MAC];
+ long core_rx;
+ long n_stats_cb;
+ long ip;
} STATS_T;
typedef struct head_t