summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c934efe)
raw | patch | inline | side by side (parent: c934efe)
author | Tinku Mannan <tmannan@ti.com> | |
Tue, 12 Mar 2013 17:05:37 +0000 (13:05 -0400) | ||
committer | Tinku Mannan <tmannan@ti.com> | |
Wed, 13 Mar 2013 14:27:22 +0000 (10:27 -0400) |
1. Netapi cleanup, fix in netapi_pktioCreate to update queue number.
2. net_test cleanup, changes to create pktio channels and classifers for DSP fash path setup.
3. Added ifdma test application, updates to Makefile.
4. Updates to net_test_config file.
2. net_test cleanup, changes to create pktio channels and classifers for DSP fash path setup.
3. Added ifdma test application, updates to Makefile.
4. Updates to net_test_config file.
27 files changed:
index de1e815c7985c332f733c2f65b19066dbcc8fdd7..85f78155e1c0401b955494e676a2a9bbc8e11f1d 100755 (executable)
* @ingroup netapi_gen_functions
* @brief netapi_init API instantiates the NETAPI and allocated global resources.
*
- * @details The API will allocate global resources valid per system level common across all ARM cores
- * or per thread based on "master" argument.
+ * @details The API will allocate global resources valid per system level common
+ * across all ARM cores or per thread based on "master" argument.
* Intializes the following substems: pktio pklib qmss cppi nwal
*
* @param[in] master Can be either @ref NETAPI_SYS_MASTER or @ref NETAPI_NO_MASTER
/**
* @ingroup netapi_gen_functions
- * @brief netapi_getPktlibIfTable API returns a Pktlib_HeapIfTable to use when creating pktlib heaps
+ * @brief netapi_getPktlibIfTable API returns a Pktlib_HeapIfTable to use when creating
+ * pktlib heaps
*
* @details Application will need a Pktlib_HeapIfTable in order to create its own heaps. This
* function returns a table that can be passed in the call to Pktlib_CreateHeap
- * The memory used for these heaps is special with the following characteristics:
+ * The memory used for these heaps is special with the following characteristics:
* - Specific alignment.
* - Must be contguous.
* - Must have a physical to virtual mapping that is known by NETAPI.
/**
* @ingroup netapi_gen_functions
- * @brief netapi_getDescRemainder API is used to return the amount of free memory available for allocating descriptors
- * for additonal Pktlib heaps.
+ * @brief netapi_getDescRemainder API is used to return the amount of free memory available
+ * for allocating descriptors for additonal Pktlib heaps.
*
* @details The application can use this API to determine how much free memory is
* available for heap descriptors if it decides to create its own heap.
index ab5d3b074f35a286eefd4c85da1e24266017c10d..4cc3ed9942b6c32cec00be3823facb06a09c1706 100755 (executable)
* @ingroup sched_structures
* @brief NETAPI scheduler configuration structure.
*
- * @details Pointer to this structure is passed in the call to @ref netapi_schedOpen API
+ * @details Pointer to this structure is passed in the call to @ref netapi_schedOpen API.
*/
typedef struct NETAPI_SCHED_CONFIG_Tag
{
* @ingroup sched_structures
* @brief NETAPI scheduler statisics.
*
- * @details This structure is returned from call to @ref netapi_schedOpen API
+ * @details This structure is returned from call to @ref netapi_schedOpen API.
*/
typedef struct NETAPI_SCHED_STATS_Tag
{
* @ingroup sched_structures
* @brief NETAPI scheduler configuration structure.
*
- * @details Pointer to this structure is passed in the call to @ref netapi_schedOpen API
+ * @details Pointer to this structure is passed in the call to @ref netapi_schedOpen API.
*/
typedef struct NETAPI_SCHED_HANDLE_Tag
{
/**
* @ingroup sched_structures
- * @brief NETAPI scheduler shutdown structure
- * @details This structure is passed an an argument for @ref netapi_schedClose
+ * @brief NETAPI scheduler shutdown structure.
+ * @details This structure is passed an an argument for @ref netapi_schedClose.
*/
typedef struct NETAPI_SCHED_SHUTDOWN_Tag
{
/**
* @ingroup sched_functions
- * @brief netapi_schedOpen: API to open a scheduling context
+ * @brief netapi_schedOpen: API to open a scheduling context.
*
- * @details API to open a scheduling context
+ * @details API to open a scheduling context.
* @param[in] n the NETAPI handle, @ref NETAPI_T
* @param[in] p_config :pointer to @ref NETAPI_SCHED_CONFIG_T
* @param[out] p_err Pointer to error code.
/// @cond NOT_IMPLEMENTED
/**
* @ingroup sched_functions
- * @brief netapi_schedControl: API to re-configure a scheduling context,
+ * @brief netapi_schedControl: API to re-configure a scheduling context.
*
- * @details API to re-configure a scheduling context
+ * @details API to re-configure a scheduling context.
* @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
* @param[in] p_config Pointer to @ref NETAPI_SCHED_CONFIG_T
* @param[out] p_err Pointer to error code.
/**
* @ingroup sched_functions
- * @brief netapi_schedClose: API to close a scheduling context
+ * @brief netapi_schedClose: API to close a scheduling context.
*
- * @details API to close a scheduling context
+ * @details API to close a scheduling context.
* @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
* @param[in] p_close @ref NETAPI_SCHED_SHUTDOWN_T
* @param[out] p_err Pointer to error code.
/**
* @ingroup sched_functions
- * @brief netapi_schedGetHandle: API to get the NETAPI handle from scheduling context
+ * @brief netapi_schedGetHandle: API to get the NETAPI handle from scheduling context.
*
- * @details API to get the NETAPI handle from scheduling context
- * @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
+ * @details API to get the NETAPI handle from scheduling context.
+ * @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
* @retval Handle to NETAPI instance
*/
static NETAPI_T netapi_schedGetHandle(NETAPI_SCHED_HANDLE_T *s)
/**
* @ingroup sched_functions
- * @brief netapi_schedGetStats: API to get scheduling context statistics
+ * @brief netapi_schedGetStats: API to get scheduling context statistics.
*
- * @details API to tget scheduling context statistics
+ * @details API to get scheduling context statistics.
* @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
* @param[in] p_pkts total number of packets processed by scheduler poll loop
* @param[in] p_cycles total number cycles taken by scheduler poll loop
index b60543030a5b684deeb5fea4fc5810603b8da609..8dab9d8ea117f642aaec5128fd0769f15ca9581f 100755 (executable)
/**
* @ingroup cfg_security_functions
- * @brief netapi_secAddRxPolicy: API to add a recieve security policy
+ * @brief netapi_secAddRxPolicy: API to add a receive security policy
*
- * @details API to add a recieve security policy
+ * @details API to add a receive security policy
* @param[in] h The NETAPI handle @ref NETAPI_T
* @param[in] sa Application id returned from call to @ref netapi_secAddSA.
* This SA must have beeen configured for (a) RX and (b) Inflow mode.
* @param[in] dst_ip_addr destination IP for policy check
* @param[in] ip_qualifiers IP qualifiers for policy check
* @param[in] route Optional: @ref NETCP_CFG_ROUTE_HANDLE_T
- * @param[in] user_data Optional: pointer to user provided data associated with policy, optional
+ * @param[in] user_data Optional: pointer to user provided data associated with policy
* @param[out] perr Pointer to error code.
* @retval Aplication id associated with created receive security policy @ref NETCP_CFG_IPSEC_POLICY_T. This is used to refer to the policy in the @ref netapi_secDelRxPolicy call. Also, packets that match this policy but do not pass any further lookups in NETCP will be tagged with this ID
* @pre @ref netapi_init @ref netapi_secAddSA
/**
* @ingroup cfg_security_functions
- * @brief netapi_secDelRxPolicy: API to add a recieve security policy
+ * @brief netapi_secDelRxPolicy: API to add a receive security policy
*
- * @details API to add a recieve security policy
+ * @details API to add a receive security policy
* @param[in] h The NETAPI handle, @ref NETAPI_T
* @param[in] policy_app_id Application id returned from call to @ref netapi_secAddRxPolicy
* @param[out] perr Pointer to error code.
index 1b977fe7f893b4dfb1e745776b776ba1a0602e8c..3a087ffa39cb18164fd66fcebe89c73c108409cd 100755 (executable)
* This defines the queue manager 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 0 //ok to to use 0 since msmc addr < ddr addr
+#define TUNE_NETAPI_QM_GLOBAL_REGION 0 //ok to use 0 since msmc addr < ddr addr
#endif
index 0ae5171a14f83a8215298a5e64b9159432a414d9..fa1177968413e13f3a6ab92ef76a6a7df094e416 100755 (executable)
Pktlib_HeapHandle h)
{
Qmss_QueueHnd q;
- Pktlib_garbageCollection(p);
- q = Pktlib_getZeroHeapQueue(p);
+ Pktlib_garbageCollection(h);
+ q = Pktlib_getZeroHeapQueue(h);
netapip_zapQ(q);
- q= Pktlib_getInternalHeapQueue(p);
+ q= Pktlib_getInternalHeapQueue(h);
netapip_zapQ(q);
}
/**
/**
* @ingroup netapi_gen_functions
- * @brief netapi_getBufMemRemainder API is used to return the amount of free memory available for allocating buffers
- * for additonal Pktlib heaps
+ * @brief netapi_getBufMemRemainder API is used to return the amount of free memory available for
+ * allocating buffers for additonal Pktlib heaps
*
* @details The application can use this API to determine how much free memory is
- * available for heap buffers if it decides to create its own.
+ * available for heap buffers if it decides to create its own.
* @retval Amount of memory available for heap buffer storage (in bytes)
* @pre @ref netapi_init
*/
/**
* @ingroup netapi_gen_functions
- * @brief netapi_getDefaultFlow: API is used to return the default NETCP flow that is to be used for incoming packets.
+ * @brief netapi_getDefaultFlow: API is used to return the default NETCP flow that is to
+ * be used for incoming packets.
*
- * @details The application can use this API to return the default NETCP flow that is used
+ * @details The application can use this API to return the default NETCP flow that is used
* for received packets. A NETCP flow is a list of PacketLib Heaps that are to be
* used to supply free packets to the receive DMA function.
* @param[in] p The NETAPI handle, @ref NETAPI_T
/**
* @ingroup cfg_functions
- * @brief netapi_netcpCfgGetPolicyUserData API to retrieve user mode data associated with Policy APPID.
+ * @brief netapi_netcpCfgGetPolicyUserData API to retrieve user mode data associated with
+ * Policy APPID.
*
* @details This api is used to retrieve user mode data associated with an Policy APPID
* @param[in] h NETAPI instance handle, @ref NETAPI_T
/**
* @ingroup cfg_functions
- * @brief netapi_netcpCfgUpdateUserData API to retrieve user mode data associated with APPID.
+ * @brief netapi_netcpCfgUpdateUserData API to update user mode data associated with APPID.
*
- * @details This api is used to retrieve user mode data associated with an APPID
+ * @details This api is used to update user mode data associated with an APPID
* @param[in] h NETAPI instance handle, @ref NETAPI_T
* @param[in] app_id application id whose user mode data is to updated
* @retval void* pointer to user mode data.
index cf2b159e3639ad33a0bd91025446b7094f65c110..a20df171a810b1041d4472513d9879b2db547c7f 100755 (executable)
/**
* @file netcp_cfg.h
- * @brief Netapi NETCP configuration API header file for user space transport library
+ * @brief Netapi NETCP configuration API header file for user space transport library
*/
/**
* @ingroup cfg_structures
- * @brief CPPI flow ID for default case, use NETCP_DEFAULT_FLOW
- * @details A flow defines a set of free queues (pktlib heap) for h/w to use to get free packet descriptor(s) and buffer(s) to use when receiving a packet
+ * @brief NETCP Flow ID configuaration informaation
+ * @details A flow defines a set of free queues (pktlib heap) for hardware to use to get
+ * free packet descriptor(s) and buffer(s) to use when receiving a packet. CPPI flow ID for
+ * default case, use NETCP_DEFAULT_FLOW
*/
typedef struct NETCP_CFG_FLOW_Tag
{
* @ingroup cfg_constants
* @brief This defines the handle to a NETCP configured Flow. A Flow is a set of pktlib heaps that h/w can use to obtain free packets.
*/
-typedef void * NETCP_CFG_FLOW_HANDLE_T;
+typedef void* NETCP_CFG_FLOW_HANDLE_T;
/**
* @ingroup cfg_constants
* @def NETCP_DEFAULT_FLOW
- * @brief This defines the default FLOW for NETCP to use.
- * The default flow uses the default pktlib heap created by netapi_init; i.e. NETCP will allocate descriptors and buffers for received packets from this heap.
+ * @brief This defines the default FLOW for NETCP to use.
+ * The default flow uses the default pktlib heap created by netapi_init; i.e.
+ * NETCP will allocate descriptors and buffers for received packets from this heap.
*/
#define NETCP_DEFAULT_FLOW (NETCP_CFG_FLOW_HANDLE_T*) NULL
/**
* @ingroup cfg_constants
* @brief Handle to a NETCP route.
- * @details Application to use this handle to identify a NETCP route. A NETCP route defines the pktio channel for packets received by NETCP
+ * @details Application to use this handle to identify a NETCP route. A NETCP route defines the
+ * pktio channel for packets received by NETCP
* and the flow to use.
*/
-typedef void * NETCP_CFG_ROUTE_HANDLE_T;
+typedef void* NETCP_CFG_ROUTE_HANDLE_T;
/**
* @def NETCP_DEFAULT_ROUTE
/**
* @ingroup cfg_structures
* @brief NETCP application defined route information.
- * @details This structure is used to define a packet receive route. A route consists of a flow where to get free descriptors and buffers to hold the packet, and a destination queue where to place the packet.
+ * @details This structure is used to define a packet receive route. A route consists of a
+ * flow where to get free descriptors and buffers to hold the packet, and a destination
+ * queue where to place the packet.
*
*/
typedef struct NETCP_CFG_ROUTE_Tag
{
- NETCP_CFG_FLOW_T * p_flow; /**< NULL or NETCP_DEFAULT_FLOW for default flow, @ref NETCP_CFG_FLOW_T */
- PKTIO_HANDLE_T * p_dest_q; /**<NULL for default destination queue */
+ NETCP_CFG_FLOW_T* p_flow; /**< NULL or NETCP_DEFAULT_FLOW for default flow, @ref NETCP_CFG_FLOW_T */
+ PKTIO_HANDLE_T* p_dest_q; /**<NULL for default destination queue */
} NETCP_CFG_ROUTE_T;
/**
#define NETAPI_NETCP_MATCH_STAGE_SHIFT 24
#define NETAPI_NETCP_MATCH_STAGE_MASK 0xFF
+
+/**
+ * @brief Helper function to get match stage associated with application ID.
+ */
#define netapi_cfgGetMatchStage(appid) (((appid) >> NETAPI_NETCP_MATCH_STAGE_SHIFT) & NETAPI_NETCP_MATCH_STAGE_MASK)
+
+/**
+ * @brief Helper function to get match id associated with application ID.
+ */
#define netapi_cfgGetMatchId(appid) (((appid) >> NETAPI_NETCP_MATCH_ID_SHIFT) & NETAPI_NETCP_MATCH_ID_MASK)
+
+/**
+ * @brief Helper function to get logical match interface associated with application ID.
+ */
#define netapi_cfgGetMatchLogicalMacIface(appid) (((appid) >> NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT) & \
NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK)
* @details This api is used to add an IP address to a MAC interface along
* with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default
* may be specified to indicate where to send packets matching the MAC interface MAC address, the
- * supplied IP address and any qualifier. This API adds a rule to the NETCP level 1 lookup tables
+ * supplied IP address and any qualifier. This API adds a rule to the NETCP level 1 lookup tables.
* Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_IP
* Note: An IP address must be attached to enable NETCP receive Checksum offload feature
* @param[in] h NETAPI instance handle, @ref NETAPI_T
/**
* @ingroup cfg_functions
- * @brief netapi_netcpCfgCreateMacInterface API to create a MAC interface
+ * @brief netapi_netcpCfgCreateMacInterface API to insert a MAC interface rule in the NETCP hardware
+ * lookup engines.
*
- * @details This api is used to create a MAC interface.
+ * @details This api is used to insert a MAC interfeace in the NETCP hardware lookup engines.
* Once it is created, the MAC interface can be used to receive packets. The API
* adds a rule to the NETCP 1st level lookup tables to route all packets with destination
* MAC matching supplied argument and not matching any other lookup entry (see @ref netapi_netcpCfgAddIp) to
index 8f629ad9a537f2c543287bb7c849b4bab0df266f..cda16cfbefe3736d4ea53d30182e207c873cccc1 100755 (executable)
unsigned int tx_ifdma_dest; /**< infrastructure dma destination flow */
} u; /**< union NWAL Packet meta data information */
- void * sa_handle; /** This contains the appplication id associated with created SA.
+ void * sa_handle; /**< This contains the appplication id associated with created SA.
details This is used when crypto is to be performed on the
egress packet */
} PKTIO_METADATA_T;
*/
typedef struct PKTIO_FAST_PATH_CONFIG_Tag
{
- int fp_send_option; /** PKTIO_FP_NONE, @ref PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT,
+ int fp_send_option; /**< PKTIO_FP_NONE, @ref PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT,
PKTIO_FP_L4CKSUM_PORT, @ref PKTIO_FP_ESP_L4CKSUM_PORT,
@ref PKTIO_FP_AH_L4CKSUM_PORT, @ref PKTIO_FP_ESP_PORT,
@ref PKTIO_FP_AH_PORT */
/**
- * @def PKTIO_FP_NO_CRYPTO_PORT
+ * @def PKTIO_FP_NONE
* @ingroup pktio_constants
* Use this define to reconfigure the PKTIO channel send function to not use any PKTIO fast path
send functions.
/**
* @def PKTIO_FP_ESP_PORT
* @ingroup pktio_constants
- * TUse this define to send packet with Crypto ESP packet
+ * Use this define to send packet with Crypto ESP packet
*/
#define PKTIO_FP_ESP_PORT 5
/**
* @def PKTIO_FP_AH_PORT
* @ingroup pktio_constants
- * TUse this define to send packet with AH packet
+ * Use this define to send packet with AH packet
*/
#define PKTIO_FP_AH_PORT 6
*
* @details This assigns global resources to a NETAPI pktio channel.
* Once created, the channel can be used to send and/or receive
- * a Ti_Pkt. This can be used for communication with the
+ * a Ti_Pkt. This can be used for communication with the
* the Network co-processor (NETCP) or for internal inter-processor
- * communication. The channel is saved under the assigned name
+ * communication. The channel is saved under the assigned name
* and can be opened by other netapi threads instances.
* @param[in] netapi_handle The NETAPI handle, @ref NETAPI_T
* @param[in] name A pointer to the char string name for channel
* @retval 1 if packet sent, 0 if error
* @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
*/
-static inline int pktio_send(PKTIO_HANDLE_T* handle,
- Ti_Pkt* pkt,
- PKTIO_METADATA_T* m,
- int* err)
+static inline int netapi_pktioSend(PKTIO_HANDLE_T* handle,
+ Ti_Pkt* pkt,
+ PKTIO_METADATA_T* m,
+ int* err)
{
return handle->_send((struct PKTIO_HANDLE_tag *)handle, pkt, m, err);
}
* @retval Number of packets received by poll
* @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
*/
-static inline int pktio_poll(PKTIO_HANDLE_T* handle,
- PKTIO_POLL_T* p_poll_cfg,
- int* err)
+static inline int netapi_pktioPoll(PKTIO_HANDLE_T* handle,
+ PKTIO_POLL_T* p_poll_cfg,
+ int* err)
{
return handle->_poll((struct PKTIO_HANDLE_tag *) handle, p_poll_cfg, err);
}
* @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
*/
int netapi_pktioPollAll(NETAPI_T handle,
- PKTIO_POLL_T* p_poll_cfg,
- int* err);
+ PKTIO_POLL_T* p_poll_cfg,
+ int* err);
/**
* @brief This define sets the max number of pkts to read in one poll in the @ref PKTIO_HANDLE_T
*/
-#define pktio_set_max_n(handle,max_n) (handle)->max_n=max_n;
+#define netapi_pktioSetMaxN(handle,max_n) (handle)->max_n=max_n;
/**
* @brief This define returns NETAPI handle stored in the @ref PKTIO_HANDLE_T
*/
-#define pktio_get_netapi_handle(handle) (handle)->back
+#define netapi_pktioGetNetapiHandle(handle) (handle)->back
+
/**
* @brief This define sets a user space application cookie in the @ref PKTIO_HANDLE_T
*/
-#define pktio_set_cookie(handle, cookie) (handle)->cookie = cookie
+#define netapi_pktioSetCookie(handle, cookie) (handle)->cookie = cookie
/**
* @brief This define returns a previously set user space application cookie stored in the @ref PKTIO_HANDLE_T
*/
-#define pktio_get_cookie(handle) (handle)->cookie
-
+#define netapi_pktioGetCookie(handle) (handle)->cookie
/**
* @brief This define returns a associate queue handle stored in the @ref PKTIO_HANDLE_T
*/
-
-#define pktio_get_q(handle) (handle)->q
+#define netapi_pktioGetQ(handle) (handle)->q
/*-----------------Extra Fast Path pkt meta data macros--------------------*/
#include "cppi_desc.h"
index b346ff21511ec05c6e6f4563824586a6b2950a87..90187930427ae2dff10f94eeecddceea50b0602b 100755 (executable)
@@ -230,6 +230,16 @@ uint8_t saContext[NETAPI_NWAL_CONFIG_BUFSIZE_SA_CONTEXT_PER_CHAN * TUNE_NETAPI_M
#define NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN 512
uint8_t salldChanHandle[NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2]ALIGN(CACHE_LINESZ);
+
+/********************************************************************
+* FUNCTION PURPOSE: NETAPI internal function to gracefully cleanup when startup
+* issue occurs.
+ ********************************************************************
+ * DESCRIPTION: NETAPI internal function to gracefully cleanup when startup
+* issue occurs.
+ ********************************************************************/
+void netapipErrTeardown() { netapip_cleanupAtStart(); exit(-99); }
+
/********************************************************************
* FUNCTION PURPOSE: Internal NETAPI function to initialize NWAL subsystem
********************************************************************
if(nwalGlobCfg.pa2SaBufPool.bufPool[0].heapHandle == NULL)
{
netapi_Log (">Pktlib_createHeap:Heap Creation Failed for PA to SA Buffer Pool , Error Code: %d\n",errCode);
- netapi_err_teardown();
+ netapipErrTeardown();
return -1;
}
if(nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle == NULL)
{
netapi_Log (">Pktlib_createHeap:Heap Creation Failed for SA to PA Buffer Pool , Error Code: %d\n",errCode);
- netapi_err_teardown();
+ netapipErrTeardown();
return -1;
}
#endif
}
-/********************************************************************
-* FUNCTION PURPOSE: NETAPI internal function to gracefully cleanup when startup
-* issue occurs.
- ********************************************************************
- * DESCRIPTION: NETAPI internal function to gracefully cleanup when startup
-* issue occurs.
- ********************************************************************/
-void netapi_err_teardown() { netapip_cleanupAtStart(); exit(-99); }
+
/***************************************************************************
if (!sharedHeapHandle) { netapi_Log(">'netapi' heap create failed, Error Code: %d\n",errCode); return -1;}
handle->netcp_heap= sharedHeapHandle;
-
/* Update for Control */
heapCfg.name = "netapi_control_rx";
heapCfg.sharedHeap = 1;
index b584ef7ec54321ee74b87ad38d4d890fc200518a..bb710204e6eb6eafd36f278165ad9b79a7653fbf 100755 (executable)
/* to hold user defined flows */
typedef struct NETCP_REGISTERED_FLOWS_Tag
{
- int in_use; //1=> in use
- void * handle; //cppi handle to resource (internal)
- NETCP_CFG_FLOW_T flow;
+ int in_use; //1=> in use
+ void* handle; //cppi handle to resource (internal)
+ NETCP_CFG_FLOW_T flow;
} NETCP_REGISTERED_FLOWS_T;
/******************************
*******************************/
typedef struct
{
- int state;
+ int state;
#define NETAPI_NW_CXT_GLOB_INACTIVE 0x0
#define NETAPI__CXT_GLOB_ACTIVE 0x1
#define NETAPI_NW_CXT_GLOB_RES_ALLOC_COMPLETE 0x3
- nwal_Handle nwalInstHandle;
+ nwal_Handle nwalInstHandle;
//internal heaps used just by netcp (sa<->pa). SW doesn't touch these
- Pktlib_HeapHandle sa2pa_heap;
- Pktlib_HeapHandle pa2sa_heap;
+ Pktlib_HeapHandle sa2pa_heap;
+ Pktlib_HeapHandle pa2sa_heap;
//stats
- paSysStats_t paStats;
- int numCmdPass;
- int numCmdFail;
- int numBogusTransIds;
- NetapiNwalTransInfo_t transInfos[TUNE_NETAPI_MAX_NUM_TRANS]; //transactions
- 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_NUM_IP]; //ips
+ paSysStats_t paStats;
+ int numCmdPass;
+ int numCmdFail;
+ int numBogusTransIds;
+ NetapiNwalTransInfo_t transInfos[TUNE_NETAPI_MAX_NUM_TRANS]; //transactions
+ 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_NUM_IP]; //ips
} NETAPI_NWAL_GLOBAL_CONTEXT_T;
/* NWAL Local context (per core/thread) */
typedef struct
{
- //void * nwalLocInstance;
#define NETAPI_NW_CXT_LOC_INACTIVE 0x0
#define NETAPI_NW_CXT_LOC_ACTIVE 0x2
- int state;
+ int state;
- int numPendingCfg;
- NETCP_CFG_STATS_CB stats_cb;
+ int numPendingCfg;
+ NETCP_CFG_STATS_CB stats_cb;
/* stats */
- int numL2PktsRecvd;
- int numL3PktsRecvd;
- int numL4PktsRecvd;
- int numL4PktsSent;
- int TxErrDrop;
+ int numL2PktsRecvd;
+ int numL3PktsRecvd;
+ int numL4PktsRecvd;
+ int numL4PktsSent;
+ int TxErrDrop;
/* local config */
nwalLocCfg_t nwalLocCfg;
typedef struct NETAPI_GLOBAL_tag
{
#define NETAPI_MAX_PKTIO (TUNE_NETAPI_MAX_PKTIO)
- PKTIO_ENTRY_T pktios[NETAPI_MAX_PKTIO];
+ PKTIO_ENTRY_T pktios[NETAPI_MAX_PKTIO];
/* configuration */
- NETAPI_CFG_T cfg;
+ NETAPI_CFG_T cfg;
/* nwal context */
- NETAPI_NWAL_GLOBAL_CONTEXT_T nwal_context;
- NETAPI_T p_master; // save p'masters handle
+ NETAPI_NWAL_GLOBAL_CONTEXT_T nwal_context;
+ NETAPI_T p_master; // save p'masters handle
} NETAPI_GLOBAL_T;
**************************************/
typedef struct NETAPI_HANDLE_Tag
{
- int master; //master type
+ int master; //master type
- void * global; /* pointer to the global area */
+ void* global; /* pointer to the global area */
/* heap handles */
- Pktlib_HeapHandle netcp_heap; /* internal default */
- Pktlib_HeapHandle netcp_control_rx_heap; /* for control messages */
- Pktlib_HeapHandle netcp_control_tx_heap; /* for control messages */
- Pktlib_HeapHandle createdHeaps[TUNE_NETAPI_MAX_HEAPS]; /* created by app and registered */
+ Pktlib_HeapHandle netcp_heap; /* internal default */
+ Pktlib_HeapHandle netcp_control_rx_heap; /* for control messages */
+ Pktlib_HeapHandle netcp_control_tx_heap; /* for control messages */
+ Pktlib_HeapHandle createdHeaps[TUNE_NETAPI_MAX_HEAPS]; /* created by app and registered */
/* pktios defined */
- int n_pktios; /* #of pktios that are active for this instance */
- void* pktios[NETAPI_MAX_PKTIO]; /* the list of pktios */
+ int n_pktios; /* #of pktios that are active for this instance */
+ void* pktios[NETAPI_MAX_PKTIO]; /* the list of pktios */
/* scheduler stuff. unallocated if NETAPI_INCLUDE_SCHED not set */
- void * p_sched;
+ void* p_sched;
/* nwal local context */
NETAPI_NWAL_LOCAL_CONTEXT_T nwal_local;
- /* security stuff */
-
- /* timer stuff */
-
/* thread cookie */
- void * cookie; /*set by calling thread */
+ void* cookie; /*set by calling thread */
} NETAPI_HANDLE_T;
//internal initialization routines */
NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_context,
NETAPI_CFG_T *p_cfg );
-int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
- Pktlib_HeapHandle cmd_heapRx,
- Pktlib_HeapHandle cmd_heapTx,
- NETAPI_NWAL_LOCAL_CONTEXT_T *p ,
- NETAPI_CFG_T *p_cfg,
- NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_glob_context );
+int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
+ Pktlib_HeapHandle cmd_heapRx,
+ Pktlib_HeapHandle cmd_heapTx,
+ NETAPI_NWAL_LOCAL_CONTEXT_T* p,
+ NETAPI_CFG_T* p_cfg,
+ NETAPI_NWAL_GLOBAL_CONTEXT_T* p_nwal_glob_context );
int netapip_initTimer(void);
-int netapip_qmSetupMemRegion(
- unsigned int numDesc,
- unsigned int descSize,
- unsigned int* pDescMemBase,
- int memRegion);
+int netapip_qmSetupMemRegion(unsigned int numDesc,
+ unsigned int descSize,
+ unsigned int* pDescMemBase,
+ int memRegion);
#define NETAPI_GLOBAL_REGION TUNE_NETAPI_QM_GLOBAL_REGION
#define NETAPI_LOCAL_REGION ((NETAPI_GLOBAL_REGION)+1)
//nwal callbacks
void netapip_pktioNWALRxPktCallback(uint32_t appCookie,
- uint16_t numPkts,
- nwalRxPktInfo_t* pPktInfo,
- uint64_t timestamp,
- nwal_Bool_t* pFreePkt);
+ uint16_t numPkts,
+ nwalRxPktInfo_t* pPktInfo,
+ uint64_t timestamp,
+ nwal_Bool_t* pFreePkt);
void netapip_netcpCfgNWALCmdCallBack (nwal_AppId appHandle,
- uint16_t trans_id,
- nwal_RetValue ret);
+ uint16_t trans_id,
+ nwal_RetValue ret);
void netapip_netcpCfgNWALCmdPaStatsReply (nwal_AppId appHandle,
- nwal_TransID_t trans_id,
- paSysStats_t *stats);
+ nwal_TransID_t trans_id,
+ paSysStats_t *stats);
-void netapip_pktioNWALSBPktCallback (uint32_t appCookie,
- uint16_t numPkts,
- nwalDmRxPayloadInfo_t* pDmRxPktInfo,
- nwal_Bool_t* pFreePkt);
+void netapip_pktioNWALSBPktCallback (uint32_t appCookie,
+ uint16_t numPkts,
+ nwalDmRxPayloadInfo_t* pDmRxPktInfo,
+ nwal_Bool_t* pFreePkt);
//***********************************
index 604d1bf2a809469532bfc580d7024f1333b77783..befdb965d03899370a3d1ea0419c690c2995fcc2 100755 (executable)
if (!p_route) return;
if (p_route->p_flow) *p_flow= p_route->p_flow->flowid;
else *p_flow = CPPI_PARAM_NOT_SPECIFIED;
- if (p_route->p_dest_q) *p_q = pktio_get_q(p_route->p_dest_q);
+ if (p_route->p_dest_q) *p_q = netapi_pktioGetQ(p_route->p_dest_q);
else *p_q=QMSS_PARAM_NOT_SPECIFIED;
}
/* todo: vlan */
if (switch_port)
{
- MacInfo.validParams =NWAL_SET_MAC_VALID_PARAM_IFNUM ;
+ MacInfo.validParams =NWAL_SET_MAC_VALID_PARAM_IFNUM ;
MacInfo.ifNum = switch_port; /* */
}
QMSS_PARAM_NOT_SPECIFIED, //dest queue
};
+ *err = NETAPI_ERR_OK;
+
if(!p_class)
{
*err=NETAPI_ERR_BAD_INPUT;
/* Configure Rx flow */
rxFlowCfg.flowIdNum = p_cfg->flow_index;/*CPPI_PARAM_NOT_SPECIFIED*/;
- rxFlowCfg.rx_dest_qnum = pktio_get_q(p_cfg->p_dest_q);
+ rxFlowCfg.rx_dest_qnum = netapi_pktioGetQ(p_cfg->p_dest_q);
rxFlowCfg.rx_dest_qmgr = Qmss_getQueueNumber(rxFlowCfg.rx_dest_qnum).qMgr;
rxFlowCfg.rx_sop_offset = p_cfg->recv_offset;
rxFlowCfg.rx_ps_location = Cppi_PSLoc_PS_IN_DESC;
index a99adab3a1720e5ac13accd2ae704007610b121c..90b96d4b280edaa963b03cb5e8798e39bd98b6df 100755 (executable)
/* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
set. optimizaion maybe? */
r=nwal_pollPkt(p->nwalInstanceHandle,
- nwal_POLL_APP_MANAGED_PKT_Q,
- (uint32_t) p,
- p->max_n,
- p->q,
- (void *) NULL);
+ nwal_POLL_APP_MANAGED_PKT_Q,
+ (uint32_t) p,
+ p->max_n,
+ p->q,
+ (void *) NULL);
+
return r;
}
p->_send=netapip_pktioSendDummy;
memcpy((char *)&p->cfg, (char*) p_cfg, sizeof(PKTIO_CFG_T));
-
+ if (p_cfg->qnum!=PKTIO_Q_ANY)
+ {
+ q= p_cfg->qnum;
+ }
/* special case for infrastructure dma channels */
if (p_cfg->flags2 & PKTIO_IFDMA)
{
- if (p_cfg->qnum!=PKTIO_Q_ANY)
- {
- q= p_cfg->qnum;
- }
qtype=Qmss_QueueType_INFRASTRUCTURE_QUEUE;
}
********************************************************************
* DESCRIPTION: API opens an existing NETAPI PKTIO channel
********************************************************************/
-PKTIO_HANDLE_T * netapi_pktioOpen(NETAPI_T n,
+PKTIO_HANDLE_T * netapi_pktioOpen(NETAPI_T n,
char *name,
- PKTIO_CB cb,
- PKTIO_CFG_T * p_cfg,
+ PKTIO_CB cb,
+ PKTIO_CFG_T * p_cfg,
int * err)
{
int r=0;
{
if (pp[i]->inuse != PKTIO_INUSE) continue;
if(!(pp[i]->cfg.flags1&PKTIO_RX)) continue;
- r+=pktio_poll(pp[i], p_poll_cfg, &err2); cnt+=1;
+ r+=netapi_pktioPoll(pp[i], p_poll_cfg, &err2); cnt+=1;
if (err2) { *err = err2; break;}
}
return r;
index c30c45169bde2b397989f962083d18e5a5d09cd4..27d478830e8ef95e77168416d687759c560b7b5f 100755 (executable)
#
NT_ROUTER_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_router.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
#
-ADDSA_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_max_params.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
+NT_MAX_PARAMS_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_max_params.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
#
+#IFDMA_OBJS= $(ARMV7OBJDIR)/netapi/test/ifdma_test.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
+
+IFDMA_OBJS= $(ARMV7OBJDIR)/netapi/test/ifdma_test.o
+
NTB_OBJS= $(ARMV7OBJDIR)/netapi/test/nt_bridge.o $(ARMV7OBJDIR)/netapi/test/stubs.o
# INCLUDE Directories
all: tests
-tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test $(ARMV7BINDIR)/netapi/test/net_test_router $(ARMV7BINDIR)/netapi/test/net_test_max_params
+tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test $(ARMV7BINDIR)/netapi/test/net_test_router $(ARMV7BINDIR)/netapi/test/net_test_max_params $(ARMV7BINDIR)/netapi/test/ifdma_test
api_clean:
rm -f $(ARMV7BINDIR)/netapi/test/net_test
rm -f $(ARMV7BINDIR)/netapi/test/net_test_router
rm -f $(ARMV7BINDIR)/netapi/test/net_test_max_params
+ rm -f $(ARMV7BINDIR)/netapi/test/ifdma_test
$(ARMV7OBJDIR)/netapi/test/%.o:$(NETAPI_INC_DIR)/test/%.c $(ARMV7OBJDIR)/netapi/test/.created
$(ARMV7BINDIR)/netapi/test/net_test: $(NT_OBJS) $(TRIE_OBJS) $(ARMV7LIBDIR)/libnetapi.a
$(CC) $(LDFLAGS) $(NT_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/net_test
-$(ARMV7BINDIR)/netapi/test/net_test_max_params: $(ADDSA_OBJS) $(TRIE_OBJS) $(ARMV7LIBDIR)/libnetapi.a
- $(CC) $(LDFLAGS) $(ADDSA_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/net_test_max_params
+$(ARMV7BINDIR)/netapi/test/net_test_max_params: $(NT_MAX_PARAMS_OBJS) $(TRIE_OBJS) $(ARMV7LIBDIR)/libnetapi.a
+ $(CC) $(LDFLAGS) $(NT_MAX_PARAMS_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/net_test_max_params
$(ARMV7BINDIR)/netapi/test/net_test_router: $(NT_ROUTER_OBJS) $(TRIE_OBJS) $(ARMV7LIBDIR)/libnetapi.a
$(CC) $(LDFLAGS) $(NT_ROUTER_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/net_test_router
$(ARMV7BINDIR)/netapi/test/nt_bridge: $(NTB_OBJS) $(TRIE_OBJS) $(ARMV7LIBDIR)/libnetapi.a
$(CC) $(LDFLAGS) $(NTB_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/nt_bridge
+$(ARMV7BINDIR)/netapi/test/ifdma_test: $(IFDMA_OBJS) $(ARMV7LIBDIR)/libnetapi.a
+ $(CC) $(LDFLAGS) $(IFDMA_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/ifdma_test
+
diff --git a/ti/runtime/netapi/test/ifdma_test.c b/ti/runtime/netapi/test/ifdma_test.c
--- /dev/null
@@ -0,0 +1,463 @@
+/******************************************\r
+ * File: ifdma-test.c\r
+ * Purpose: test of infrastructure dma mode\r
+ **************************************************************\r
+ * FILE: ifdma-test.c\r
+ * \r
+ * DESCRIPTION: netapi user space transport\r
+ * library test application\r
+ * \r
+ * REVISION HISTORY: rev 0.0.1 \r
+ *\r
+ * Copyright (c) Texas Instruments Incorporated 2010-2011\r
+ * \r
+ * Redistribution and use in source and binary forms, with or without \r
+ * modification, are permitted provided that the following conditions \r
+ * are met:\r
+ *\r
+ * Redistributions of source code must retain the above copyright \r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the \r
+ * documentation and/or other materials provided with the \r
+ * distribution.\r
+ *\r
+ * Neither the name of Texas Instruments Incorporated nor the names of\r
+ * its contributors may be used to endorse or promote products derived\r
+ * from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
+ *****************************************/\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <string.h>\r
+#include <signal.h>\r
+#include <pthread.h>\r
+\r
+#include "trie.h"\r
+#include "string.h"\r
+#include "netapi.h"\r
+#include "pktio.h"\r
+#include "net_test.h"\r
+#include <ti/drv/sa/salld.h>\r
+\r
+\r
+//turn this off to use packets received from Network instead of self generated ones\r
+#define INTERNAL_PACKETS\r
+static int scnt=0;\r
+static int QUIT=0;\r
+__thread int our_core;\r
+\r
+\r
+#define IFDMA_FLOW_INDEX 33\r
+#define IFMDA_HEAP_SIZE 200\r
+#define IFDMA_MAX_NUM_HEAPS 2\r
+#define IFDMA_MAX_HEAP_PKTS 128\r
+//sig handler\r
+void netTest_utilMySig(int x)\r
+{\r
+ QUIT=1;\r
+ scnt+=1;\r
+ printf(">ifdma-test: recv'd signal %d cnt=%d\n",x,scnt);\r
+ if (scnt > 10) {printf(">ifdma-test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");exit(1);}\r
+\r
+}\r
+void recv_cb_net(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],\r
+ PKTIO_METADATA_T meta[], int n_pkts,\r
+ uint64_t ts );\r
+void recv_cb_consumer(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],\r
+ PKTIO_METADATA_T meta[], int n_pkts,\r
+ uint64_t ts );\r
+\r
+\r
+/*************debug********************/\r
+void netTest_utilDumpDescr(unsigned long *p, int n)\r
+{\r
+ printf("--------dump of descriptor %d %x\n", n, (int) p);\r
+ printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);\r
+ printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);\r
+ printf("-----------------------------\n");\r
+}\r
+void netTest_utilDumpHeader(unsigned long *p, int n, int a, int r)\r
+{\r
+ printf("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);\r
+ printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);\r
+ printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);\r
+ printf("> %x %x %x %x %x %x %x %x\n",p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23]);\r
+ printf("> %x %x %x %x %x %x %x %x\n",p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]);\r
+ printf("-----------------------------\n");\r
+}\r
+/*****************************************/\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+/*******************************************\r
+ *************NETAPI OBJECTS***************\r
+ *****************************************/\r
+static NETAPI_CFG_T our_netapi_default_cfg=\r
+{\r
+TUNE_NETAPI_PERM_MEM_SZ,\r
+128, //start of packet offset for hw to place data on rx for default flow\r
+TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system\r
+TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use\r
+TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap\r
+64, //#descriptors w/o buffers in default heap\r
+TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap\r
+128 , //tail room\r
+256 //extra room \r
+};\r
+\r
+Pktlib_HeapHandle OurHeap; //default heap, used by producer\r
+Pktlib_HeapHandle consumerHeap; //for consumer\r
+PKTIO_HANDLE_T * rx_chan; //for consumer\r
+PKTIO_HANDLE_T * tx_chan; // for producer\r
+PKTIO_CFG_T rx_chan_cfg={PKTIO_RX|PKTIO_TX, PKTIO_GLOBAL, PKTIO_Q_ANY, 8};\r
+PKTIO_CFG_T tx_chan_cfg={PKTIO_TX, PKTIO_GLOBAL|PKTIO_IFDMA, /*PKTIO_Q_ANY*/ 820, 8};\r
+PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};\r
+PKTIO_HANDLE_T * netcp_rx_chan;\r
+NETAPI_T netapi_handle;\r
+NETCP_CFG_FLOW_HANDLE_T specialFlow; //for consumer. Producer uses the "flowid" in this handle as meta data when he sends data\r
+\r
+PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};\r
+\r
+NETCP_CFG_ROUTE_T test_route=\r
+{\r
+NULL, NULL //* to be filled in\r
+};\r
+\r
+\r
+/*************************END NETAPI OBJECTS***********************/\r
+\r
+static unsigned char all_mac[]={0,0,0,0,0,0};\r
+\r
+\r
+#define IFDMA_PKT_LEN 100\r
+\r
+//stats\r
+int pkt_rx=0; \r
+int pkt_tx=0;\r
+\r
+//***************************\r
+//consumer thread \r
+//**************************\r
+void consumer_thread(int coreid)\r
+{\r
+int err;\r
+int np;\r
+ for(;!((volatile)QUIT);)\r
+ {\r
+ np = netapi_pktioPoll(rx_chan,NULL,&err);\r
+ pkt_rx+=np;\r
+ }\r
+ printf("IFDMA-TEST: CONSUMER DONE %d packets received\n", pkt_rx);\r
+}\r
+\r
+\r
+//**********************************\r
+//producer thread\r
+//*********************************\r
+void producer_thread(int coreid)\r
+{\r
+int err;\r
+int i;\r
+Ti_Pkt * tip;\r
+unsigned char * pData;\r
+int len;\r
+PKTIO_METADATA_T meta = {PKTIO_META_IFDMA_TX,{0},0};\r
+int np;\r
+#ifdef INTERNAL_PACKETS\r
+ //generate packets internally by allocating from OurHeap (the NETAPI \r
+ //default) and send to receiver via ifdma pktio channel\r
+ sleep(5);\r
+ for(i=0;!((volatile) QUIT);i++)\r
+ {\r
+ tip=Pktlib_allocPacket(OurHeap,IFDMA_PKT_LEN);\r
+ if (!tip) \r
+ {\r
+ sleep(1); //out of buffers, let consumer catch up\r
+ continue;\r
+ }\r
+ Pktlib_getDataBuffer(tip,&pData,&len);\r
+ sprintf(pData,"this is packet %d", pkt_tx);\r
+ Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, pData,IFDMA_PKT_LEN);\r
+ Pktlib_setPacketLen(tip,IFDMA_PKT_LEN);\r
+ meta.u.tx_ifdma_dest=((NETCP_CFG_FLOW_T*)specialFlow)->flowid;\r
+ netapi_pktioSend(tx_chan,tip,&meta,&err);\r
+ pkt_tx+=1;\r
+ if(!(pkt_tx % 128)) sched_yield(); //give consumer a chance\r
+ }\r
+#else\r
+ //relay packets from network. recv_cb registered when we created\r
+ //netcp_rx_chan will do this relay via the ifdma pktio channel\r
+ //so we poll the default pktio channel for pkts from net\r
+ for(i=0;!((volatile) QUIT);i++)\r
+ {\r
+ np = netapi_pktioPoll(netcp_rx_chan,NULL,&err);\r
+ if (!np) sched_yield();\r
+\r
+ }\r
+#endif\r
+ printf("IFDMA-TEST: PRODUCER DONE %d pkts sent\n", pkt_tx);\r
+}\r
+\r
+\r
+//******************************\r
+// main program\r
+//*****************************\r
+int main(int argc, char **argv)\r
+{\r
+ int err,i;\r
+ int32_t errCode;\r
+ Pktlib_HeapIfTable* pPktifTable;\r
+ Pktlib_HeapCfg heapCfg;\r
+ long t1, t2 ;\r
+\r
+ //install signal handler for ^c\r
+ signal(SIGINT,netTest_utilMySig);\r
+\r
+\r
+ /*******************************************/\r
+ /*************NETAPI STARTUP****************/\r
+ /*******************************************/\r
+\r
+ /* create netapi */\r
+ netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);\r
+\r
+ /* open the main heap */\r
+ OurHeap = Pktlib_findHeapByName("netapi");\r
+ if (!OurHeap) {printf("findheapbyname fail\n"); exit(1);}\r
+\r
+ //create a receive queue for consumer\r
+ rx_chan=netapi_pktioCreate(netapi_handle,"ourrxq",(PKTIO_CB) recv_cb_consumer, &rx_chan_cfg,&err);\r
+ if (!rx_chan) {printf("pktio create failed err=%d\n",err); exit(1);}\r
+\r
+\r
+#ifndef INTERNAL_PACKETS\r
+ //if we want to relay network packets, we create a handle to the \r
+ //default netcp receive queue here\r
+ netcp_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb_net, &netcp_rx_cfg, &err);\r
+ if (!netcp_rx_chan) {printf("pktio open RX failed err=%d\n",err); exit(1);}\r
+#endif\r
+\r
+//********************************\r
+//create a consumer heap\r
+//**********************************\r
+\r
+ /* Initialize the heap configuration. */\r
+ memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));\r
+\r
+ pPktifTable = netapi_getPktlibIfTable();\r
+\r
+ /* Populate the heap configuration */\r
+ heapCfg.name = "netapi-consumer";\r
+ heapCfg.memRegion = NETAPI_GLOBAL_REGION;\r
+ heapCfg.sharedHeap = 1;\r
+ heapCfg.useStarvationQueue = 0;\r
+ heapCfg.dataBufferSize = TUNE_NETAPI_DEFAULT_BUFFER_SIZE;\r
+ heapCfg.numPkts = IFDMA_MAX_HEAP_PKTS;\r
+ heapCfg.numZeroBufferPackets= 0;\r
+ heapCfg.heapInterfaceTable.data_malloc = pPktifTable->data_malloc;\r
+ heapCfg.heapInterfaceTable.data_free = pPktifTable->data_free;\r
+ heapCfg.dataBufferPktThreshold = 0;\r
+ heapCfg.zeroBufferPktThreshold = 0;\r
+ consumerHeap = Pktlib_createHeap(&heapCfg, &errCode);\r
+\r
+ //by registering the heap, netapi will take care of\r
+ //cleaning it up @ shutdown..\r
+ netapi_registerHeap(netapi_handle, consumerHeap); //register heap.\r
+\r
+ //**************************************************\r
+ //create a FLOW for consumer RX. Note this is created\r
+ //in the QMSS (INFRASTRUCTURE) CPPI DMA ENGINE\r
+ // todo: flowindex should be passed in or got\r
+ // from resource manager\r
+ //*************************************************\r
+ {\r
+ Pktlib_HeapHandle heaps[2];\r
+ int sizes[2];\r
+#define SPECIAL_SOP_OFF 0\r
+ NETCP_CFG_FLOW_CONFIG_T flow_config={IFDMA_FLOW_INDEX,\r
+ NETAPI_DMA_INFRASTRUCTURE,\r
+ SPECIAL_SOP_OFF,\r
+ NETAPI_FLOW_BLOCK };\r
+ heaps[0]= consumerHeap;\r
+ sizes[0]=IFMDA_HEAP_SIZE;\r
+ heaps[1]= consumerHeap;\r
+ sizes[1]=TUNE_NETAPI_DEFAULT_BUFFER_SIZE - SPECIAL_SOP_OFF;\r
+ flow_config.p_dest_q = rx_chan; // send pkts to rx_chan \r
+\r
+ //specialFlow handle will hold "magic" flowid that producer needs to\r
+ //include in his pkto_send meta data\r
+ specialFlow = netapi_netcpCfgAddFlow( netapi_handle,\r
+ IFDMA_MAX_NUM_HEAPS, //1 heap defined\r
+ heaps,\r
+ sizes,\r
+ &flow_config, //offset to start rx is 128 \r
+ &err);\r
+ if (err) {printf("add flow failed\n", err); exit(1);}\r
+}\r
+\r
+//************************************************************\r
+//create the IDMA channel: this is used by producer to either\r
+//send generated packets or relay received packets from net\r
+//***************************************************************\r
+tx_chan=netapi_pktioCreate(netapi_handle,"ourtxq",NULL, &tx_chan_cfg,&err);\r
+if (!tx_chan) {printf("pktio create failed err=%d\n",err); exit(1);}\r
+\r
+#ifndef INTERNAL_PACKETS \r
+//if we want to relay packets, creaate a simple netcp rule\r
+//to get a lot of packets\r
+netapi_netcpCfgCreateMacInterface(\r
+ netapi_handle,\r
+ &all_mac[0],\r
+ 0,0,\r
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL, \r
+ (NETCP_CFG_VLAN_T ) NULL , //future\r
+ 1,\r
+ &err);\r
+#endif\r
+\r
+/*********************************************/\r
+/*****************end NETAPI STARTUP**********/\r
+/*********************************************/\r
+\r
+\r
+//**************************************\r
+//Create a consumer and producer thread\r
+//***************************************\r
+{\r
+ pthread_t *thrs;\r
+ int procs =2; \r
+ char c;\r
+ thrs = malloc( sizeof( pthread_t ) * procs );\r
+ if (thrs == NULL)\r
+ {\r
+ perror( "malloc" );\r
+ return -1;\r
+ }\r
+ printf( "ifdma-test: Starting %d threads...\n", procs );\r
+\r
+ if (pthread_create( &thrs[0], NULL, (void*)consumer_thread,\r
+ (void *)0 ))\r
+ {\r
+ perror( "pthread_create" );\r
+ exit(1);\r
+ }\r
+ if (pthread_create( &thrs[1], NULL, (void*)producer_thread,\r
+ (void *)1 ))\r
+ {\r
+ perror( "pthread_create" );\r
+ exit(1);\r
+ }\r
+ //this thread of execution (main) now just waits on user input\r
+ for(;;)\r
+ {\r
+ printf(">");\r
+ c=getchar();\r
+ if (c=='q') {QUIT=1;break;}\r
+ else if (c=='s') printf(">IFDMA-TEST STATS: %d sent, %d received\n",pkt_tx, pkt_rx);\r
+ else if (c=='h') printf("> 'q' to quit, 's' for stats, 'h' for help\n");\r
+ }\r
+\r
+ //wait for completion \r
+ printf("main task now pending on thread completion\n");\r
+ for (i = 0; i < procs; i++)\r
+ pthread_join( thrs[i], NULL );\r
+\r
+ free( thrs );\r
+ \r
+}\r
+\r
+/*************************************************\r
+ ************CLEAN UP****************************\r
+ ************************************************/\r
+#ifndef INTERNAL_PACKETS\r
+//get rid of rule, in the case that we are relaying packets\r
+//also close our netcp rx channel\r
+netapi_netcpCfgDelMac(netapi_handle,0,&err);\r
+netapi_pktioClose(netcp_rx_chan,&err);\r
+#endif\r
+\r
+//close pktio channels we opened\r
+netapi_pktioDelete(tx_chan ,&err);\r
+netapi_pktioDelete(rx_chan ,&err);\r
+\r
+//close flow\r
+netapi_netcpCfgDelFlow(netapi_handle, specialFlow, &err);\r
+\r
+//done\r
+netapi_shutdown(netapi_handle);\r
+\r
+\r
+//!finished!\r
+}\r
+\r
+\r
+//receive callback for packets from net (for consumer)\r
+// this is used for case where we want to relay packets from\r
+// network, instead of internally generating them\r
+void recv_cb_net(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],\r
+ PKTIO_METADATA_T meta[], int n_pkts,\r
+ uint64_t ts )\r
+{\r
+int i;\r
+PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};\r
+Ti_Pkt * tip;\r
+int err;\r
+\r
+for(i=0;i<n_pkts;i++)\r
+{\r
+ tip = p_recv[i];\r
+ meta2.u.tx_ifdma_dest=((NETCP_CFG_FLOW_T*)specialFlow)->flowid;\r
+ netapi_pktioSend(tx_chan,tip,&meta2,&err);\r
+ pkt_tx+=1;\r
+ if(!(pkt_tx % 128)) sched_yield(); //give consumer a chance\r
+}\r
+\r
+\r
+}\r
+\r
+\r
+//receive callback for consumer (registered when we create pktio channel)\r
+void recv_cb_consumer(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],\r
+ PKTIO_METADATA_T meta[], int n_pkts,\r
+ uint64_t ts )\r
+{\r
+int i;\r
+int len;\r
+Ti_Pkt * tip;\r
+unsigned int templen;\r
+char * p_pkt;\r
+\r
+for(i=0;i<n_pkts;i++)\r
+{\r
+ tip = p_recv[i];\r
+ Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen\r
+ len = Pktlib_getPacketLen(tip);\r
+ Pktlib_freePacket((Ti_Pkt*)tip);\r
+}\r
+return;\r
+}\r
+\r
+\r
+\r
+\r
+\r
index 79f8c608e223ffa1d79f6efce5b237fc79dfc5e7..e6f79e18ac82fae16dbdf2d84a4d6fa50cd48720 100755 (executable)
-/******************************************
+/******************************************************************************
* File: net_test.c
* Purpose: test app for netapi
- **************************************************************
+ ******************************************************************************
* FILE: net_test.c
*
* DESCRIPTION: netapi user space transport
* (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 <signal.h>
-#include <pthread.h>
#include "net_test.h"
-#include "trie.h"
-#include "string.h"
-
-#include <sys/resource.h>
-
-#include <ti/drv/sa/salld.h>
-#include <ti/drv/pa/pa.h>
-
-#include "net_test_utils.h"
-#include "router.h"
+#include "ti/drv/nwal/test/fw_rm.h"
+#include <signal.h>
+#include <pthread.h>
extern int QUIT;
-extern STATS_T stats[TUNE_NETAPI_NUM_CORES];
+extern netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
extern paSysStats_t netcp_stats;
-/* Global definitions */
-#ifdef MULTI_THREAD
+
+#ifdef netTest_MULTI_THREAD
cpu_set_t cpu_set;
#endif
netTestConfig_t netTestCfg;
-static netTestConfigFile_t config_file;
+static netTestConfigFile_t config_file;
char input_file_name[] = "net_test_config.txt";
nwal_RetValue nwalRetVal;
-Pktlib_HeapHandle ourHeap;
+Pktlib_HeapHandle ourHeap;
PKTIO_HANDLE_T *netcp_rx_chan;
PKTIO_HANDLE_T *netcp_tx_chan_no_crypto;
PKTIO_HANDLE_T *netcp_sb_tx_chan;
PKTIO_HANDLE_T *netcp_sb_rx_chan;
-PKTIO_CFG_T our_chan_cfg={PKTIO_RX_TX, PKTIO_LOCAL, PKTIO_Q_ANY, 8};
PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
PKTIO_CFG_T netcp_rx_cfg2={PKTIO_RX, (PKTIO_GLOBAL|PKTIO_PKT), PKTIO_Q_ANY, 8};
PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
PKTIO_CFG_T netcp_sb_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
PKTIO_CFG_T netcp_sb_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
+NETCP_CFG_IP_T ip_rule[NET_TEST_MAX_IP];
+NETCP_CFG_MACIF_T mac[NET_TEST_MAX_MAC];
+#ifdef netTest_DSP_FASTPATH
+PKTIO_HANDLE_T *dsp_pktio_channels[CPU_NUM_REM_FAST_PATH_CORES];
+NETCP_CFG_CLASS_T dsp_classifers[CPU_NUM_REM_FAST_PATH_CORES];
+NETCP_CFG_FLOW_HANDLE_T dsp_flow_handles[CPU_NUM_REM_FAST_PATH_CORES];
+#endif
NETCP_CFG_EXCEPTION_PKT_T expPkt_appid;
Trie *p_trie_sa_rx;
*****************************************/
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
+ 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
};
NETAPI_T netapi_handle;
NETAPI_SCHED_HANDLE_T * our_sched;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
#endif
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_rule[NET_TEST_MAX_IP];
-NETCP_CFG_MACIF_T mac[NET_TEST_MAX_MAC];
-
+netTestSA_t sa_info[MAX_SEC_INDEX];
+NETCP_CFG_IPSEC_POLICY_T rx_policy[MAX_SEC_INDEX];
-/* security objects. (for loopback mode) */
-netTestSA_t sa_info[MAX_SEC_INDEX];
-NETCP_CFG_IPSEC_POLICY_T rx_policy[MAX_SEC_INDEX];
-/*--------------------------------------------------------------
- *----------utility to flip a packet and send
- *--------------------back to source----------------------------
- * flag=1 => ipsec
- *--------------------------------------------------------------*/
+/********************************************************************
+ * FUNCTION PURPOSE: Utility function to flip and packet and send
+ * it back to its source.
+ ********************************************************************
+ * DESCRIPTION: Utility function to flip and packet and send
+ * it back to its source.
+ ********************************************************************/
void flip_and_send_pkt(Ti_Pkt *tip, unsigned char * p_pkt, int len, int flag, uint16_t enet_port)
{
unsigned char mac_temp[6];
unsigned char ip_temp[4];
unsigned char new_dest_port[2]={0x75,0x30}; // 30000
+ uint16_t dest_udp_port_config = 0;
uint16_t blah;
uint16_t i=1; /* for testing only */
@@ -156,17 +148,17 @@ void flip_and_send_pkt(Ti_Pkt *tip, unsigned char * p_pkt, int len, int flag, u
uint8_t ah_len;
uint32_t tunnel_id;
nwalLocCxtInfo_t nwalLocCxt;
- HEAD_T * p_head;
- HEAD_T temp_head;
+ netTestHead_T * p_head;
+ netTestHead_T temp_head;
int pkt_type;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
//int coreid = our_core;
#else
int coreid=0;
#endif
- //netapi_dump_buf((long*)p_pkt,len);
+ // netTest_utilDumpBuffer((long*)p_pkt,len);
Pktlib_setPacketLen(tip,len);
//flip the mac address
memcpy(&mac_temp,&p_pkt[0],6);
//inner ip &udp for ipsec
if (flag)
{
- memcpy(p_head,&p_pkt[14],sizeof(HEAD_T));
+ memcpy(p_head,&p_pkt[14],sizeof(netTestHead_T));
if ((p_head->ip[2]&0x0000ff00)==0x00003300)
{
p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN + 4]);
- pkt_type = IPSEC_AH_PKT;
- printf("flip_and_send_pkt: AH packet received\n");
+ pkt_type = netTest_IPSEC_AH_PKT;
}
else if ((p_head->ip[2]&0x0000ff00)==0x00003200)
{
p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
- pkt_type = IPSEC_ESP_PKT;
+ pkt_type = netTest_IPSEC_ESP_PKT;
}
else
{
- printf("flip_and_send_pkt: un-supported IPSEC protocol\n");
+ netapi_Log("flip_and_send_pkt: un-supported IPSEC protocol\n");
Pktlib_freePacket(tip);
return;
}
p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa_rx, (char *)p_spi ,4);
if (p_sa_info == NULL)
{
- printf("flip_and_send_pkt(): trie_lookup() failed\n");
+ netapi_Log("flip_and_send_pkt(): trie_lookup() failed\n");
Pktlib_freePacket(tip);
return;
}
p_sa_info_tx = (netTestSA_t *) trie_lookup(p_trie_sa_tx, (char *)&tunnel_id ,4);
if (p_sa_info_tx == NULL)
{
- printf("flip_and_send_pkt(): trie_lookup() failed\n");
+ netapi_Log("flip_and_send_pkt(): trie_lookup() failed\n");
Pktlib_freePacket(tip);
return;
}
memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+12],&p_pkt[p_sa_info->tx_payload_info.encOffset+12+4],4);
memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+12+4],&ip_temp,4);
/* setting udp ports */
- memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+20+2],&new_dest_port[0],2);
+ if (netTestCfg.dest_udp_port_config == 0)
+ {
+ printf("dest_udp_port_config is 0, use src port as dest port\n");
+ memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+20+2],&p_pkt[p_sa_info->tx_payload_info.encOffset+20],2);
+ }
+ else
+ {
+ dest_udp_port_config = htons(netTestCfg.dest_udp_port_config);
+ memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+20+2],&dest_udp_port_config,2);
+ }
memset(&p_pkt[p_sa_info->tx_payload_info.encOffset+20+6],0,2); //checksum
if (netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND)
}
else
{
+ /* flip udp port */
+ if (netTestCfg.dest_udp_port_config == 0)
+ {
+ printf("dest_udp_port_config is 0, use src port as dest port\n");
+ memcpy(&p_pkt[14+20+2],&p_pkt[14+20],2);
+ }
+ else
+ {
+ dest_udp_port_config = htons(netTestCfg.dest_udp_port_config);
+ printf("flip_and_send_pkt: dest udp port is %d\n", netTestCfg.dest_udp_port_config);
+ //memcpy(&p_pkt[14+20+2],&new_dest_port[0],2);
+ memcpy(&p_pkt[14+20+2],&dest_udp_port_config,2);
+ }
+
memset(&p_pkt[14+20+6],0,2);//0 udp checksum (we will compute on way out)
- memcpy(&p_pkt[14+20+2],&new_dest_port[0],2);
}
/*IPSEC case */
/* post it to netcp sb tx channel*/
meta.u.tx_sb_meta=&meta_tx;
- pktio_send(netcp_sb_tx_chan,tip,&meta,&err);
+ netapi_pktioSend(netcp_sb_tx_chan,tip,&meta,&err);
}
else
{
meta_tx.l4HdrLen = p_sa_info_tx->tx_pkt_info.l4HdrLen;
meta_tx.ploadLen = (unsigned) ((p_pkt[meta_tx.l4OffBytes+4]<<8)|p_pkt[meta_tx.l4OffBytes+4+1]) -8 ;
meta_tx.saOffBytes= p_sa_info_tx->tx_pkt_info.saOffBytes;
- if (pkt_type == IPSEC_AH_PKT)
+ if (pkt_type == netTest_IPSEC_AH_PKT)
{
memset(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+netTest_IPSEC_AH_FIXED_HDR_SIZE],0,netTest_IPSEC_AH_FIXED_HDR_SIZE);
meta_tx.txFlag1 = p_sa_info_tx->tx_pkt_info.txFlag1;
meta_tx.enetPort = enet_port;
memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+4],&p_sa_info_tx->spi,4);
}
- else if (pkt_type == IPSEC_ESP_PKT)
+ else if (pkt_type == netTest_IPSEC_ESP_PKT)
{
meta_tx.txFlag1 = p_sa_info_tx->tx_pkt_info.txFlag1;
meta_tx.saPayloadLen=len-netTest_MAC_HEADER_LEN-netTest_IP_HEADER_LEN; //don't include mac and ip outer header
}
meta_tx.pseudoHdrChecksum =
- test_utilGetIpv4PsudoChkSum(&p_pkt[meta_tx.ipOffBytes],8+ meta_tx.ploadLen);
+ netTest_utilGetIPv4PsudoChkSum(&p_pkt[meta_tx.ipOffBytes],8+ meta_tx.ploadLen);
/* post it to netcp tx channel*/
meta.u.tx_meta=&meta_tx;
- if (stats[coreid].sec_tx<20) dump_descr((long *) tip, stats[coreid].sec_tx);
+ if (stats[coreid].sec_tx<20) netTest_utilDumpDescr((long *) tip, stats[coreid].sec_tx);
- if ( pkt_type == IPSEC_ESP_PKT)
- pktio_send(netcp_tx_chan_esp,tip,&meta,&err);
- else if ( pkt_type == IPSEC_AH_PKT)
- pktio_send(netcp_tx_chan_ah,tip,&meta,&err);
+ if ( pkt_type == netTest_IPSEC_ESP_PKT)
+ netapi_pktioSend(netcp_tx_chan_esp,tip,&meta,&err);
+ else if ( pkt_type == netTest_IPSEC_AH_PKT)
+ netapi_pktioSend(netcp_tx_chan_ah,tip,&meta,&err);
stats[coreid].tx +=1;
stats[coreid].sec_tx +=1;
}
meta_tx2.ploadLen = (unsigned) ((p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+4]<<8)|
p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+4+1]) -8 ;
meta_tx2.pseudoHdrChecksum =
- test_utilGetIpv4PsudoChkSum(&p_pkt[netTest_MAC_HEADER_LEN],8+ meta_tx2.ploadLen);
+ netTest_utilGetIPv4PsudoChkSum(&p_pkt[netTest_MAC_HEADER_LEN],8+ meta_tx2.ploadLen);
/* post it to netcp tx channel*/
meta2.u.tx_meta=&meta_tx2;
printf("flip_and_send_pkt: non-ipsec packet received\n");
- pktio_send(netcp_tx_chan_no_crypto,tip,&meta2,&err);
+ netapi_pktioSend(netcp_tx_chan_no_crypto,tip,&meta2,&err);
stats[coreid].tx +=1;
}
}
-/****************************************************************************************/
-/******************SB Accelerator Callback PKT RECEIVE HANDLER *************************/
-/****************** Handles Decrypt and Encrypt operation callbacks ******************/
-/******************************************************************************************/
+/**********************************************************************
+ * FUNCTION PURPOSE: Sideband Accelerator Callback PKT RECEIVE HANDLER
+ **********************************************************************
+ * DESCRIPTION: Sideband 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 )
int i;
int len;
int p;
- HEAD_T * p_res;
+ netTestHead_T * p_res;
Ti_Pkt * tip;
unsigned int templen;
int err;
- KEY_T key;
char * p_pkt;
- HEAD_T * p_head;
- HEAD_T temp_head;
+ netTestHead_T * p_head;
+ netTestHead_T temp_head;
int tag_cmp=0;
unsigned int hash[4];
uint8_t *p_spi;
netTestSA_t *p_sa_info;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
#else
int coreid=0;
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]);
+ hash[0]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[0]);
+ hash[1]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
+ hash[2]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
+ hash[3]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
if(stats[coreid].sb_rx<=16)
{
char *tp = (char *) &hash[0];
- //dump_header((long*)p_pkt, stats[coreid].sb_rx, (int)meta[i].u.rx_sb_meta->appId,0);
+ //netTest_utilDumpHeader((long*)p_pkt, stats[coreid].sb_rx, (int)meta[i].u.rx_sb_meta->appId,0);
}
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[coreid].n_auth_ok += !(tag_cmp);
//this is an encrypt (tx tunnel) complete
else if((int)meta[i].u.rx_sb_meta->appId== p_sa_info->tx_tunnel )
{
- 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]);
+ hash[0]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[0]);
+ hash[1]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
+ hash[2]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
+ hash[3]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
stats[coreid].sb_tx+=1;
if(stats[coreid].sb_tx<=16)
{
- //dump_header((long*)p_pkt, stats[coreid].sb_tx, (int)meta[i].u.rx_sb_meta->appId,0);
+ //netTest_utilDumpHeader((long*)p_pkt, stats[coreid].sb_tx, (int)meta[i].u.rx_sb_meta->appId,0);
}
//put the computed tag in the packet
memcpy(&p_pkt[len-p_sa_info->auth_tag_size],(char*)&hash[0],p_sa_info->auth_tag_size); //todo, really use meta->authTagLen
/* post it to netcp tx channel*/
meta2.u.tx_meta=&meta_tx;
- pktio_send(netcp_tx_chan_esp,tip,&meta2,&err);
+ netapi_pktioSend(netcp_tx_chan_esp,tip,&meta2,&err);
hplib_cacheWbInv(p_pkt,len);
stats[coreid].tx +=1;
}
}
}
-/******************************************************/
-/******************PKT RECEIVE HANDLER *************************/
-/******************************************************/
-
+/**********************************************************************
+ * FUNCTION PURPOSE: Packet receive Callback
+ *
+ **********************************************************************
+ * DESCRIPTION: packet Receive callback
+ **********************************************************************/
void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
PKTIO_METADATA_T meta[], int n_pkts,
uint64_t ts )
int i;
int len;
int p;
- HEAD_T * p_res;
+ netTestHead_T * p_res;
Ti_Pkt * tip;
unsigned int templen;
int err = 0;
- KEY_T key;
char * p_pkt;
- HEAD_T * p_head;
- HEAD_T temp_head;
+ netTestHead_T * p_head;
+ netTestHead_T temp_head;
netTestSA_t *p_sa_info;
uint8_t *p_spi;
uint8_t p_iv[16];
int ifno;
uint16_t enet_port = 0;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
//int coreid = our_core;
#else
if (stats[coreid].rx<16)
{
netapi_Log(">rx dmp..");
- dump_descr((long *) tip, stats[coreid].rx);
+ netTest_utilDumpDescr((long *) tip, stats[coreid].rx);
}
else if (stats[coreid].rx>99)
{
netapi_Log(">rx dmp..");
- dump_descr((long *) tip,stats[coreid].rx);
+ netTest_utilDumpDescr((long *) tip,stats[coreid].rx);
}
#endif
#if 0
if(stats[coreid].rx<=16)
{
- 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);
+ netTest_utilDumpHeader((long*)p_pkt,stats[coreid].rx, (int)meta[i].u.rx_meta->appId,meta[i].u.rx_meta->rxFlag1);
+ netTest_utilDumpBuffer((long*)p_pkt,len);
}
#endif
/* check header */
- memcpy(p_head,&p_pkt[14],sizeof(HEAD_T));
+ memcpy(p_head,&p_pkt[14],sizeof(netTestHead_T));
/* check for IPSEC ESP or AH packet, 0x32 is ESP tunnel mode, 0x33 is AH tunnel mode*/
if (((p_head->ip[2]&0x0000ff00)==0x00003200) || ((p_head->ip[2]&0x0000ff00)==0x00003300))
{
- if (!check_header(p_head,&meta[i]))
+ if (!netTest_utilCheckHeader(p_head,&meta[i]))
{
stats[coreid].n_bad+=1;Pktlib_freePacket(tip);
continue;
/* post it to netcp sb tx channel*/
meta2.u.tx_sb_meta=&meta_tx;
- pktio_send(netcp_sb_tx_chan,tip,&meta2,&err);
+ netapi_pktioSend(netcp_sb_tx_chan,tip,&meta2,&err);
continue;
}
else
}
else //non ipsec
{
- if (!check_header(p_head,&meta[i]))
+ if (!netTest_utilCheckHeader(p_head,&meta[i]))
{
stats[coreid].n_bad+=1;Pktlib_freePacket(tip);
continue;
}
}
+#ifdef netTest_DSP_FASTPATH
+void setup_netTestDSPFastPath(NETAPI_T handle, uint32_t thread_num)
+{
+ int i;
+ int err = 0;
+ PKTIO_CFG_T dsp_pktio_cfg;
+ NETCP_CFG_CLASSIFIER_T dsp_classi;
+ NETCP_CFG_ROUTE_T dsp_route;
+
+ memset(&dsp_pktio_cfg, 0, sizeof (PKTIO_CFG_T));
+ memset(&dsp_classi, 0, sizeof (NETCP_CFG_CLASSIFIER_T));
+ memset(&dsp_route, 0, sizeof (NETCP_CFG_ROUTE_T));
+ char dsp_name[32];
+ //for (i = 0; i < CPU_NUM_REM_FAST_PATH_CORES; i++)
+ for (i = 0; i < 1; i++)
+ {
+ sprintf(&dsp_name[0],"%s%d","dsp_chan", i);
+ printf("netTest_utilCreateInterfaces: %s\n",&dsp_name[0]);
+
+ dsp_pktio_cfg.flags1 = PKTIO_RX;
+ dsp_pktio_cfg.flags2 = PKTIO_GLOBAL | PKTIO_PKT;
+ dsp_pktio_cfg.qnum = TEST_NWAL_BASE_REM_FP_RX_PKT_QUEUE + i;
+ dsp_pktio_cfg.max_n = 8;
+
+ /* pktio channels created here will NOT be POLLED by net_test arm application */
+ dsp_pktio_channels[i] = netapi_pktioCreate(handle,
+ &dsp_name[0],
+ (PKTIO_CB)recv_cb,
+ &dsp_pktio_cfg,
+ &err);
+ if (dsp_pktio_channels[i])
+ {
+ printf("setup_netTestDSPFastPath: sucess for core %d\n", i);
+ }
+ else
+ {
+ printf("setup_netTestDSPFastPath: failed for core %d\n", i);
+ }
+
+ dsp_classi.classType =NETCP_CFG_CLASS_TYPE_L4;
+ dsp_classi.u.c_l4.iface = netTestCfg.dsp_mac;
+
+ dsp_classi.u.c_l4.ip = ip_rule[netTestCfg.dsp_ip];
+ dsp_classi.u.c_l4.proto = NWAL_APP_PLOAD_PROTO_UDP;
+ dsp_classi.u.c_l4.appProto.udpPort = TEST_NWAL_BASE_REM_FP_UDP_PORT + i;
+ printf("setup_netTestDSPFastPath: iface 0x%x, proto: 0x%x, thread_num %d\n", dsp_classi.u.c_l4.iface, dsp_classi.u.c_l4.proto, thread_num);
+
+
+ dsp_route.p_dest_q = dsp_pktio_channels[i];
+
+ dsp_route.p_flow = (NETCP_CFG_FLOW_T*)NETCP_DEFAULT_FLOW;
+
+
+ dsp_classifers[i] = netapi_netcpCfgAddClass(handle,
+ &dsp_classi,
+ (NETCP_CFG_ROUTE_HANDLE_T) &dsp_route,
+ NETCP_CFG_ACTION_TO_SW,
+ NULL,
+ &err);
+
+
+ if (err == NETAPI_ERR_OK)
+ {
+ printf("setup_netTestDSPFastPath: netapi_netcpCfgAddClass sucess for core %d\n", i);
+ }
+ else
+ {
+ printf("setup_netTestDSPFastPath: netapi_netcpCfgAddClass failed for core %d\n", i);
+ }
+ }
+}
-#ifdef MULTI_THREAD
+void teardown_netTestDSPFastPath()
+{
+ int i;
+ int err=0;
+
+ for (i = 0; i < CPU_NUM_REM_FAST_PATH_CORES; i++)
+ {
+ netapi_netcpCfgDelClass(netapi_handle,
+ dsp_classifers[i],
+ &err);
+ if (err == NETAPI_ERR_OK)
+ {
+ printf("teardown_netTestDSPFastPath: netapi_netcpCfgDelClass sucess for core %d\n", i);
+ }
+ else
+ {
+ printf("teardown_netTestDSPFastPath: netapi_netcpCfgDelClass failed for core %d\n", i);
+ }
+
+ netapi_pktioDelete(dsp_pktio_channels[i],
+ &err);
+ if (err == NETAPI_ERR_OK)
+ {
+ printf("teardown_netTestDSPFastPath: netapi_pktioDelete sucess for core %d\n", i);
+ }
+ else
+ {
+ printf("teardown_netTestDSPFastPath: netapi_pktioDelete failed for core %d\n", i);
+ }
+ }
+}
+#endif
+
+
+#ifdef netTest_MULTI_THREAD
NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
void slow_path_thread(uint32_t thread_num)
#endif
worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
- /* open netcp default RX channels*/
-
- rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
-
- sb_rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
-
netapi_setCookie(worker_nh[thread_num],(void*)(thread_num | NET_TEST_SP_THREAD_MASK));
scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
netapi_schedRun(scheduler[thread_num], &err);
printf(">net_test: core %d worker thread done\n",thread_num);
- netapi_pktioClose(rx_chan, &err);
- netapi_pktioClose(sb_rx_chan, &err);
netapi_shutdown(worker_nh[thread_num]);
}
//sb_tx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
sb_rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
-
+#ifdef netTest_DSP_FASTPATH
+ setup_netTestDSPFastPath(netapi_handle, thread_num);
+#endif
netapi_setCookie(worker_nh[thread_num],(void*)thread_num);
{
int err,i;
Pktlib_HeapCfg heapCfg;
- rlim_t oss,ss = 1024*1024;
- struct rlimit rl;
int32_t errCode;
Pktlib_HeapIfTable* pPktifTable;
- /* Local Per Process default resourcese maintained at NWAL */
- nwalLocCxtInfo_t nwalLocCxt;
- //nwalSaIpSecId_t nwalSaIpSecId;
FILE * fpr = NULL;
- err= getrlimit(RLIMIT_STACK,&rl);
- if (!err) printf(" stack limit = %d\n",rl.rlim_cur); else printf("getrlimit failed\n");
-
-
/* install signal handler for ^c */
- signal(SIGINT,mysig);
+ signal(SIGINT,netTest_utilMySig);
if (argc == 2)
{
{
memset(&config_file, 0, sizeof(netTestConfigFile_t));
memset(&netTestCfg, 0, sizeof(netTestConfig_t));
- parse_config_file(fpr,&config_file);
+
+ netTest_utilProcessConfigFile(fpr,&config_file);
+#if 1
+ netTest_utilParseMac(&config_file);
+
+ /* parse slow path/fast path thread configuration parameters */
+ netTest_utilParseThreadParams(&config_file);
+
+ netTest_utilParseIP(&config_file);
+
+ netTest_utilParseIpsecMode(&config_file);
+
+ /* DSP mac processing */
+ parse_dsp_mac(&config_file.dsp_mac[0]);
+
+ /* DSP IP processing */
+ parse_dsp_ip(&config_file.dsp_ip[0]);
+
+ /* IPSEC interface number processing */
+ parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
+
+ netTest_utilParseSA(&config_file);
+
+ parse_simple_param_u32(&config_file.dest_udp_port_config, &netTestCfg.dest_udp_port_config);
+#endif
}
memset(&sa_info, 0, sizeof(sa_info));
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
/* assign main net_test thread to run on core 0 */
CPU_ZERO( &cpu_set);
CPU_SET( 0, &cpu_set);
netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
/* configure expection packet handling with netapi */
- netapi_netcpCfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
- expPkt_appid = netapi_netcpCfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+ netapi_netcpCfgExceptions(netapi_handle,
+ NETCP_CFG_ALL_EXCEPTIONS,
+ NETCP_CFG_ACTION_DISCARD,
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+ expPkt_appid = netapi_netcpCfgExceptions(netapi_handle,
+ 7,
+ NETCP_CFG_ACTION_TO_SW,
+ (NETCP_CFG_ROUTE_HANDLE_T) NULL);
/* open the main heap */
ourHeap = Pktlib_findHeapByName("netapi");
open_pktio_tx_channels();
-
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);
/*create net_test MAC interfaces, attach IP to created MAC interfaces */
- create_interfaces();
+ netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
/* lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
p_trie_sa_rx = trie_new();
if (!p_trie_sa_rx || !p_trie_sa_tx)
{printf("trie alloc for SA failed\n"); exit(1);}
-
+#ifdef netTest_DSP_FASTPATH
+ //setup_netTestDSPFastPath();
+#endif
/* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
- create_sec_associations();
+ netTest_utilCreateSecAssoc();
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
{
+
+ nwalGlobCxtInfo_t nwalGlobCxt;
+ nwalLocCxtInfo_t nwalLocCxt;
+ int count;
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) netapi_handle;
+
+ nwal_getGlobCxtInfo(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,&nwalGlobCxt);
+ //printf("0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", Info.defFlowQ, Info.rxDefPktQ, Info.rxPaSaFlowId, Info.rxSaPaFlowId, Info.passCppiHandle);
+
+
+ printf("*******NWAL Global Context Info Dump Begin *******\n");
+ printf("rxPaSaFlowId:%d,rxSaPaFlowId:%d rxDefPktQ:0x%x \n",
+ nwalGlobCxt.rxPaSaFlowId,nwalGlobCxt.rxSaPaFlowId,
+ nwalGlobCxt.rxDefPktQ);
+ printf("defFlowQ:0x%x,passCppiHandle:0x%x extErr:%d \n",
+ nwalGlobCxt.defFlowQ,nwalGlobCxt.passCppiHandle,
+ nwalGlobCxt.extErr);
+ for(count=0;count < nwalGlobCxt.numPaPDSPs;count++)
+ {
+ printf("NetCP PASS PDSP - %d Version:0x%x \n",
+ count,nwalGlobCxt.pdspVer[count]);
+ }
+ printf("*******NWAL Global Context Info Dump End *******\n\n");
+
+
+ nwal_getLocCxtInfo(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,&nwalLocCxt);
+ printf("*******NWAL Local Context Info Dump Begin *******\n");
+ printf("rxCtlQ:%d,rxL4PktQ:%d \n",
+ nwalLocCxt.rxCtlQ,
+ nwalLocCxt.rxL4PktQ);
+ printf("rxPktFlowId:0x%x,rxCtlFlowId:0x%x extErr:%d \n",
+ nwalLocCxt.rxPktFlowId
+ ,nwalLocCxt.rxCtlFlowId,
+ nwalLocCxt.extErr);
+
+ printf("*******NWAL Local Context Info Dump End *******\n\n");
+
+
+
+
+
+#if 1
+typedef struct {
+ uint16_t numPendPAReq;/**< Number of pending PA requests for
+ * process
+ */
+ NWAL_queueHnd rxCtlQ; /**< Response Queue for receiving
+ * control response
+ */
+ NWAL_queueHnd rxL4PktQ; /**< Default Queue for receiving L4
+ * Packets
+ */
+ NWAL_queueHnd rxSbSaQ; /**< Packet Queue to receive response
+ * for all data mode SA related
+ * responses
+ */
+ uint16_t extErr; /**< Extended Error details from NetCP
+ */
+ int16_t rxPktFlowId; /**< Default Flow Handle for packets
+ * from NetCP to host
+ */
+ int16_t rxCtlFlowId; /**< Default Flow Handle for control
+ * response from NetCP to host
+ */
+} nwalLocCxtInfo_t;
+#endif
+
char c;
/* create and set affinity of slow path and fast path threads to
* specific CPU cores as specified in the net_test_config.txt file */
- create_sp_fp_threads();
+ netTest_utilCreateSpFpThreads(netTestCfg.num_sp_threads,
+ (NET_TEST_FUNC_PTR) slow_path_thread,
+ netTestCfg.num_fp_threads,
+ (NET_TEST_FUNC_PTR) fast_path_thread);
//this thread of execution (main) now just waits on user input
for(;;)
printf(">");
c=getchar();
if (c=='q') {QUIT=1;break;}
- else if (c=='s') our_stats_cb(netapi_handle, &netcp_stats);
+ else if (c=='s') netTest_utilsStatsCb(netapi_handle, &netcp_stats);
else if (c=='h') printf("'q' to quit, 's' for stats, 'h' for help\n");
}
- sp_fp_thread_cleanup();
+ netTest_utilRemoveSpFpThreads(netTestCfg.num_sp_threads, netTestCfg.num_fp_threads);
}
#else
/*********************************************/
/**************Entry point into scheduler ****/
/*********************************************/
- //create_sec_associations(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
+ //netTest_utilCreateSecAssoc(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
netapi_schedRun(our_sched, &err);
#endif
/* done */
- our_stats_cb(netapi_handle, NULL);
+ netTest_utilsStatsCb(netapi_handle, NULL);
/* cleanup*/
- delete_sec_associations();
+ netTest_utilDeleteSecAssoc();
- delete_interfaces();
+ netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
/* close pktio channels we opened via open_pktio_tx_channels() */
close_pktio_channels();
-
+#ifdef netTest_DSP_FASTPATH
+ teardown_netTestDSPFastPath();
+#endif
netapi_shutdown(netapi_handle);
}
+#if 1
/* Stub functions */
Trie * route_init(void)
{
void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route)
{
}
+#endif
index 46dafaac2ab224906b8e192eaf805cfa715fb13a..a5239d496ec2c6ea459cf0193c07cde8553c64b5 100755 (executable)
#ifndef __NET_TEST_H__
#define __NET_TEST_H__
-
-
-//define this for multi-thread
-#define MULTI_THREAD
-
-
-#define EXPERIMENTAL
-
#include "netapi.h"
+#include "trie.h"
-#define netTest_MAC_HEADER_LEN 14
-#define netTest_IP_HEADER_LEN 20
-#define netTest_UDP_HEADER_LEN 8
-#define netTest_ESP_HEADER_LEN 8
-#define netTest_AES_CBC_IV_LEN 16
-#define netTest_AES_CTR_IV_LEN 8
-#define netTest_3DES_CBC_IV_LEN 8
-#define netTest_AES_GCM_IV_LEN 8
-#define netTest_AES_CCM_IV_LEN 8
-#define netTest_AES_GMAC_IV_LEN 8
-#define netTest_NULL_IV_LEN 0
-#define netTest_ICV_LEN 12
-#define netTest_HMAC_SHA256_RFC_4868_ICV_LEN 16
-#define netTest_AES_GCM_CCM_ICV_LEN 16
-#define netTest_AES_GMAC_ICV_LEN 16
-
-#define IPSEC_AH_PKT 1
-#define IPSEC_ESP_PKT 2
-
+#include "net_test_sa_utils.h"
+#include "net_test_utils.h"
+#include "net_test_thread_utils.h"
-#define netTest_IPSEC_AH_FIXED_HDR_SIZE 12
-
-
-#define netTest_NULL_ESP_HEADER_LEN 0
-
-
-
-
-typedef struct {
- nwalDmTxPayloadInfo_t tx_payload_info;
- uint8_t inner_ip_offset;
- NETCP_CFG_SA_T rx_tunnel;
- void * rx_data_mode_handle;
- void * rx_inflow_mode_handle;
- NETCP_CFG_SA_T tx_tunnel;
- void * tx_data_mode_handle;
- void * tx_inflow_mode_handle;
- uint8_t enc_key_length;
- uint8_t auth_tag_size;
- nwalTxPktInfo_t tx_pkt_info;
- nwal_saEALG cipherMode;
- nwal_saAALG authMode;
- /*stuff for routing use case */
- unsigned int src; //BE
- unsigned int dst; //BE
- unsigned int spi; //BE
- unsigned int seq; //BE
- int iv_len; //iv len (size of iv in pkt)
- int bl; //block len (for padding calc)
-#if 1
- /* Save NETCP CMD details during create time */
- nwalTxDmPSCmdInfo_t rx_dmPSCmdInfo;
- nwalTxDmPSCmdInfo_t tx_dmPSCmdInfo;
-#endif
-#if 1
- nwalTxPSCmdInfo_t tx_psCmdInfo;
- uint32_t swInfo0;
- uint32_t swInfo1;
-#endif
- uint32_t dir;
- uint32_t tunnel_id;
- nwalSecKeyParams_t *key_params;
-
-} netTestSA_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_NUM_MAC];
- long core_rx;
- long n_stats_cb;
- long ip;
- long exceptionPktsFrag;
- long exceptionPktsOther;
-} STATS_T;
-
-typedef struct head_t
-{
- long ip[5];
- long udp[2];
-} HEAD_T;
-
-typedef struct key_t
-{
- long src_ip;
- long dst_ip;
- short src_port;
- short dst_port;
-} KEY_T;
-
-#define IPSEC_AH_PKT 1
-#define IPSEC_ESP_PKT 2
-
-
-#define BE(x) ( (((x)&0xff000000)>>24) | (((x)&0xff0000)>>8) | (((x)&0xff00)<<8) | (((x)&0xff)<<24) )
-
-typedef struct iphead_t
-{
- unsigned long w1;
- unsigned long w2;
- unsigned long w3;
- unsigned long src;
- unsigned long dst;
-} IP_HEAD_T;
-
-#define ROUTE_SEC_T netTestSA_t
-
-typedef struct our_route_t
-{
- int out_port;
- unsigned char out_mac[14];
- ROUTE_SEC_T * sec_ptr;
-} OUR_ROUTE_T;
+//#include "net_test_sa_utils.h"
+//define this for multi-thread
+#define netTest_MULTI_THREAD
+#define netTest_DSP_FASTPATH
-void flip_and_send_pkt(Ti_Pkt *tip, unsigned char * p_pkt, int len, int flag, uint16_t enet_port);
-void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
- PKTIO_METADATA_T meta[], int n_pkts,
- uint64_t ts );
-void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
- PKTIO_METADATA_T meta[], int n_pkts,
- uint64_t ts );
#endif
diff --git a/ti/runtime/netapi/test/net_test_config.txt b/ti/runtime/netapi/test/net_test_config.txt
index 862df61b2440e5bceb5b2afcb86ffde9a1d65408..f24bf63c97e9ce5c307e8da9909fb8260bf79d31 100755 (executable)
#sp0 thread-number start-core end-core
sp0 = 1 0-0
fp0 = 2 0-0
-fp1 = 3 0-0
+fp1 = 3 0-0
#mac0 = mac-address switch-port
-mac0 = 00-01-02-03-05-05 sp0
-mac1 = 00-01-02-03-05-06 sp1
+mac0 = 00-01-02-03-05-05 sp0
+#mac1 = 00-01-02-03-05-06 sp1
#ip0 = ip-address mac-interface
ip0 = 10.0.0.100 mac0
ip1 = 10.0.1.100 mac0
local_ipsec_ip = 192.168.1.100
remote_ipsec_ip = 192.168.1.10
ipsec_if = 0
+#
+dsp_mac = mac0
+dsp_ip = ip0
+#
#ipsec_mode_rx = SIDEBAND
#ipsec_mode_tx = SIDEBAND
ipsec_mode_rx = INFLOW
dstip0 = 10.1.0.100 route1
dspip1 = 10.0.0.10 route0
+# _dest_udp port config, if set to ZERO, net_test will use eceived src port as destination port when packet
+# is transmitted to network, if non-ZERO, net test will use this the the destination port when packet
+# is tranmitted to network.
+dest_udp_port_config = 30000
#sa0 = dir spi prot saMode iptype srcip destip window auth cipher esnlo esphi encrkeysize authkeysize encrkey pauthkey tunnel_id
sa13 = OUTBOUND 0x77777777 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 AES_XCBC NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x7
-sa14 = INBOUND 0x88888888 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
+#sa14 = INBOUND 0x88888888 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
-sa15 = OUTBOUND 0x88888888 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
+#sa15 = OUTBOUND 0x88888888 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
diff --git a/ti/runtime/netapi/test/net_test_max_params.c b/ti/runtime/netapi/test/net_test_max_params.c
index e83c123a73aef05cee81bf51b1faac3ad1af5dc3..bd35c060afb1ec71a4285708b2bfbbce4886ba77 100755 (executable)
*****************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+#include "net_test.h"
+#include "ti/drv/nwal/test/fw_rm.h"
#include <signal.h>
#include <pthread.h>
-#include "net_test.h"
-#include "trie.h"
-#include "string.h"
-
-#include <sys/resource.h>
-
-#include <ti/drv/sa/salld.h>
-#include <ti/drv/pa/pa.h>
-
-#include "net_test_utils.h"
-#include "router.h"
-
extern int QUIT;
-extern STATS_T stats[TUNE_NETAPI_NUM_CORES];
+extern netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
extern paSysStats_t netcp_stats;
/* Global definitions */
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
cpu_set_t cpu_set;
#endif
-#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
netTestConfig_t netTestCfg;
static netTestConfigFile_t config_file;
-char input_file_name[] = "net_test_config.txt";
+char input_file_name[] = "net_test_config_max_sa.txt";
nwal_RetValue nwalRetVal;
Pktlib_HeapHandle ourHeap;
NETAPI_T netapi_handle;
NETAPI_SCHED_HANDLE_T * our_sched;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
#endif
NETAPI_SCHED_CONFIG_T our_sched_cfg={
{
}
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
void slow_path_thread(uint32_t thread_num)
{
int err,i;
Pktlib_HeapCfg heapCfg;
- rlim_t oss,ss = 1024*1024;
- struct rlimit rl;
int32_t errCode;
Pktlib_HeapIfTable* pPktifTable;
- /* Local Per Process default resourcese maintained at NWAL */
- nwalLocCxtInfo_t nwalLocCxt;
- //nwalSaIpSecId_t nwalSaIpSecId;
FILE * fpr = NULL;
- err= getrlimit(RLIMIT_STACK,&rl);
- if (!err) printf(" stack limit = %d\n",rl.rlim_cur); else printf("getrlimit failed\n");
-
-
/* install signal handler for ^c */
- signal(SIGINT,mysig);
+ signal(SIGINT,netTest_utilMySig);
if (argc == 2)
{
{
memset(&config_file, 0, sizeof(netTestConfigFile_t));
memset(&netTestCfg, 0, sizeof(netTestConfig_t));
- parse_config_file(fpr,&config_file);
+ netTest_utilProcessConfigFile(fpr,&config_file);
+#if 1
+ netTest_utilParseMac(&config_file);
+
+ /* parse slow path/fast path thread configuration parameters */
+ netTest_utilParseThreadParams(&config_file);
+
+ netTest_utilParseIP(&config_file);
+
+ netTest_utilParseIpsecMode(&config_file);
+
+ /* DSP mac processing */
+ parse_dsp_mac(&config_file.dsp_mac[0]);
+
+ /* DSP IP processing */
+ parse_dsp_ip(&config_file.dsp_ip[0]);
+
+ /* IPSEC interface number processing */
+ parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
+
+ netTest_utilParseSA(&config_file);
+#endif
}
memset(&sa_info, 0, sizeof(sa_info));
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
/* assign main net_test thread to run on core 0 */
CPU_ZERO( &cpu_set);
CPU_SET( 0, &cpu_set);
/*create net_test MAC interfaces, attach IP to created MAC interfaces */
-//#ifdef TEST_MAC_IP
- create_interfaces();
-//#endif
+ netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
+
/* lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
p_trie_sa_rx = trie_new();
p_trie_sa_tx = trie_new();
#ifdef TEST_SA
/* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
- create_sec_associations();
+ netTest_utilCreateSecAssoc();
#endif
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
{
char c;
- /* create and set affinity of slow path and fast path threads to
- * specific CPU cores as specified in the net_test_config.txt file */
- //create_sp_fp_threads();
+
//this thread of execution (main) now just waits on user input
for(;;)
else if (c=='h')
printf("'q' to quit, 's' for stats, 'h' for help\n");
}
-
- //sp_fp_thread_cleanup();
-
}
#else
/*********************************************/
#endif
/* cleanup*/
- delete_sec_associations();
+ netTest_utilDeleteSecAssoc();
- delete_interfaces();
+ netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
/* close pktio channels we opened via open_pktio_tx_channels() */
close_pktio_channels();
index 13dd1f42b87da22e9b826952b7c0eb8a1929fba2..a002618527a16cb2b6486b191bf220578cacffd7 100755 (executable)
-/******************************************
+/******************************************************************************
* File: net_test_router.c
* Purpose: net_test_router application
- **************************************************************
+ ******************************************************************************
* FILE: net_test_router.c
*
* DESCRIPTION: netapi user space transport
* (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 <signal.h>
-#include <pthread.h>
+ ******************************************************************************/
-#include "net_test.h"
#include "trie.h"
-#include "string.h"
+#include <signal.h>
+#include <pthread.h>
#include <sys/resource.h>
-
-#include <ti/drv/sa/salld.h>
-#include <ti/drv/pa/pa.h>
-
-#include "net_test_utils.h"
-
+#include "router.h"
extern int QUIT;
/* Global definitions */
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
cpu_set_t cpu_set;
#endif
#include "router.c"
-extern Trie * our_router;
-extern OUR_ROUTE_T routes[];
+Trie * our_router;
+
+OUR_ROUTE_T routes[MAX_ROUTES]=
+{
+ {0,{0xD4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x14,0x02,0x08,0x00},0},
+ {0,{0x00,0x00,0x0,0x00,0x0,0x0, 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00},0},
+ {0,{0xD4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x14,0x02,0x08,0x00},0},
+ {0,{0x00,0x15,0x60,0xa1,0xf7,0xbe, 0x00,0x01,0x02,0x03,0x04,0x05,0x08,0x00},0},
+ {0,{0xd4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x04,0x05,0x08,0x00},0}
+};
unsigned int ip[MAX_ROUTES]={BE(0x0a0100c8),BE(0x0a00000a),BE(0x0a02000a),BE(0xc0a8010a),BE(0x9eda6719)};
void recv_cb_router(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
uint64_t ts );
-extern STATS_T stats[TUNE_NETAPI_NUM_CORES];
+extern netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
extern paSysStats_t netcp_stats;
/*******************************************
void house(NETAPI_SCHED_HANDLE_T *s);
NETAPI_T netapi_handle;
NETAPI_SCHED_HANDLE_T * our_sched;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
#endif
NETAPI_SCHED_CONFIG_T our_sched_cfg={
/*************************END NETAPI OBJECTS***********************/
-void update_header(HEAD_T * p_head, int len)
+void update_header(netTestHead_T * p_head, int len)
{
unsigned char *p = (unsigned char *) &p_head->udp[1];
len -= (20+14);
*(p+1) = len&0xff;
}
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
/* Templates to build command labels at startup up time, required by open_pktio_tx_channels() */
nwalTxPktInfo_t txPktInfoESP =
{
{
int err,i;
Pktlib_HeapCfg heapCfg;
- rlim_t oss,ss = 1024*1024;
- struct rlimit rl;
int32_t errCode;
Pktlib_HeapIfTable* pPktifTable;
-/* Local Per Process default resourcese maintained at NWAL */
- nwalLocCxtInfo_t nwalLocCxt;
-
FILE * fpr = NULL;
-
- err= getrlimit(RLIMIT_STACK,&rl);
- if (!err) netapi_Log(" stack limit = %d\n",rl.rlim_cur); else netapi_Log("getrlimit failed\n");
-
- /* install signal handler for ^c */
- signal(SIGINT,mysig);
+ /* install signal handler for ^c */
+ signal(SIGINT,netTest_utilMySig);
if (argc == 2)
{
{
memset(&config_file, 0, sizeof(netTestConfigFile_t));
memset(&netTestCfg, 0, sizeof(netTestConfig_t));
- parse_config_file(fpr,&config_file);
+ netTest_utilProcessConfigFile(fpr,&config_file);
+ netTest_utilParseMac(&config_file);
+
+ /* parse slow path/fast path thread configuration parameters */
+ netTest_utilParseThreadParams(&config_file);
+
+ netTest_utilParseIP(&config_file);
+
+ netTest_utilParseIpsecMode(&config_file);
+
+ /* DSP mac processing */
+ parse_dsp_mac(&config_file.dsp_mac[0]);
+
+ /* DSP IP processing */
+ parse_dsp_ip(&config_file.dsp_ip[0]);
+
+ netTest_utilParseRoutes(&config_file, &routes[0], &our_router);
+
+ /* IPSEC interface number processing */
+ parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
+
+ netTest_utilParseSA(&config_file);
}
memset(&sa_info, 0, sizeof(sa_info));
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
/* assign main net_test thread to run on core 0 */
CPU_ZERO( &cpu_set);
CPU_SET( 0, &cpu_set);
/*create net_test MAC interfaces, attach IP to created MAC interfaces */
- create_interfaces();
+ netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
/* Lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
p_trie_sa_rx = trie_new();
{netapi_Log("trie alloc for SA failed\n"); exit(1);}
/* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
- create_sec_associations();
+ netTest_utilCreateSecAssoc();
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
{
char c;
/* create and set affinity of slow path and fast path threads to
* specific CPU cores as specified in the net_test_config.txt file */
- create_sp_fp_threads();
-
+ netTest_utilCreateSpFpThreads(netTestCfg.num_sp_threads,
+ (NET_TEST_FUNC_PTR) slow_path_thread,
+ netTestCfg.num_fp_threads,
+ (NET_TEST_FUNC_PTR) fast_path_thread);
//this thread of execution (main) now just waits on user input
for(;;)
printf(">");
c=getchar();
if (c=='q') {QUIT=1;break;}
- else if (c=='s') our_stats_cb(netapi_handle, &netcp_stats);
+ else if (c=='s') netTest_utilsStatsCb(netapi_handle, &netcp_stats);
else if (c=='h') printf("'q' to quit, 's' for stats, 'h' for help\n");
}
-
+ netTest_utilRemoveSpFpThreads(netTestCfg.num_sp_threads, netTestCfg.num_fp_threads);
}
#else
/*********************************************/
#endif
/* done */
-our_stats_cb(netapi_handle, NULL);
+netTest_utilsStatsCb(netapi_handle, NULL);
/* cleanup*/
- delete_sec_associations();
- delete_interfaces();
+ netTest_utilDeleteSecAssoc();
+ netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
/* close pktio channels we opened via open_pktio_tx_channels() */
close_pktio_channels();
}
-static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_port)
+static inline void send_it(Ti_Pkt *tip, int len, netTestSA_t * p_sec, int out_port)
{
unsigned long st1;
unsigned long st2;
@@ -545,7 +555,7 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
nwalTxPktInfo_t meta_tx2={0};
st1=hplib_mUtilGetPmuCCNT();
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
//int coreid = our_core;
#else
@@ -574,13 +584,13 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
meta_tx2.saOffBytes=netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
meta_tx2.saPayloadLen=len-netTest_MAC_HEADER_LEN - netTest_IP_HEADER_LEN; //don't include tag, mac and outer header
meta2.u.tx_meta=&meta_tx2;
- pktio_send(netcp_tx_chan_esp,tip,&meta2,&err);
+ netapi_pktioSend(netcp_tx_chan_esp,tip,&meta2,&err);
stats[coreid].sec_tx+=1;
}
else
{
meta2.u.tx_meta=&meta_tx2;
- pktio_send(netcp_tx_chan_no_crypto,tip,&meta2,&err);
+ netapi_pktioSend(netcp_tx_chan_no_crypto,tip,&meta2,&err);
}
stats[coreid].tx +=1;
Ti_Pkt * tip;
unsigned int templen;
char * p_pkt;
- HEAD_T temp_head;
+ netTestHead_T temp_head;
unsigned int appid;
- IP_HEAD_T th;
- ROUTE_SEC_T *sec_data=NULL;
+ IP_netTestHead_T th;
+ netTestSA_t *sec_data=NULL;
unsigned long t1;
unsigned long t2;
unsigned long long ct1;
unsigned long long n_c_ops;
int ifno;
int out_port;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
//int coreid = our_core;
#else
case(NETAPI_NETCP_MATCH_IPSEC_POLICY):
{
int tailen=12+2;
- memcpy(&temp_head,&p_pkt[14],sizeof(HEAD_T));
- if (!check_header(&temp_head,&meta[i])) {
+ memcpy(&temp_head,&p_pkt[14],sizeof(netTestHead_T));
+ if (!netTest_utilCheckHeader(&temp_head,&meta[i])) {
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])) {
+ if (!netTest_utilCheckHeader(&temp_head,&meta[i])) {
stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
continue;
Pktlib_freePacket(tip);
continue;
}
- if (!check_header(&temp_head,&meta[i]))
+ if (!netTest_utilCheckHeader(&temp_head,&meta[i]))
{
stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
uint64_t ts )
{
}
+
diff --git a/ti/runtime/netapi/test/net_test_sa_utils.c b/ti/runtime/netapi/test/net_test_sa_utils.c
index a7f57d9b8429309c518d9e7a8bd78dafe01a10a7..38548a70a2eea9087bc781ab67de1f23c1f05a6a 100755 (executable)
*****************************************/
-#include "net_test_utils.h"
+#include "net_test.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
#include <signal.h>
#include <pthread.h>
-#include "trie.h"
-#include "router.h"
#include <ti/drv/sa/salld.h>
#include <ti/drv/pa/pa.h>
-void build_sa_db(int i)
+void netTest_utilBuildSADB(int i)
{
long tmp_spi;
long tmp_tunnel;
- if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_HMAC_SHA1) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_AES_CBC))
+ if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_SHA1) &&
+ (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CBC))
{
/* 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.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_AES_CBC_IV_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.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; /* not being referenced in net_test */
- sa_info[i].cipherMode = netTestCfg.sa_info[i].cipherMode;
- sa_info[i].authMode = netTestCfg.sa_info[i].authMode;
+ sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+ sa_info[i].authMode = netTestCfg.sa[i].authMode;
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].auth_tag_size = netTest_ICV_LEN;
sa_info[i].iv_len=16;
sa_info[i].bl=16;
- sa_info[i].src = *((unsigned int *)(&netTestCfg.sa_info[i].src));
- sa_info[i].dst =*((unsigned int *)(&netTestCfg.sa_info[i].dst));
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.l4HdrLen = netTest_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.ploadLen = 0;
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.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 ;
- sa_info[i].dir =netTestCfg.sa_info[i].dir;
- tmp_spi = htonl((long)(netTestCfg.sa_info[i].spi));
- tmp_tunnel = htonl((long)(netTestCfg.tunnel_id[i]));
+ 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 ;
+ sa_info[i].dir =netTestCfg.sa[i].dir;
+ tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+ tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
sa_info[i].spi =tmp_spi;
sa_info[i].tunnel_id = tmp_tunnel;
-
- if (netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
- {
+
+ if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+ {
trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
- }
- else
- {
- trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- }
-
+ }
+ else
+ {
+ trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+ }
}
- else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_HMAC_SHA2_256) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_AES_CTR))
+ else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_SHA2_256) &&
+ (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CTR))
{
/* 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;
-
-
+ 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_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 = netTestCfg.sa_info[i].cipherMode;
- sa_info[i].authMode = netTestCfg.sa_info[i].authMode;
+ sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+ sa_info[i].authMode = netTestCfg.sa[i].authMode;
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].auth_tag_size = netTest_ICV_LEN;
sa_info[i].iv_len=8;
sa_info[i].bl=8;
- sa_info[i].src = *((unsigned int *)(&netTestCfg.sa_info[i].src));
- sa_info[i].dst =*((unsigned int *)(&netTestCfg.sa_info[i].dst));
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.l4HdrLen = netTest_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.ploadLen = 0;
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].key_params = &netTestCfg.key_params[i];
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 ;
- sa_info[i].dir =netTestCfg.sa_info[i].dir;
- tmp_spi = htonl((long)(netTestCfg.sa_info[i].spi));
- tmp_tunnel = htonl((long)(netTestCfg.tunnel_id[i]));
+ sa_info[i].dir =netTestCfg.sa[i].dir;
+ tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+ tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
sa_info[i].spi =tmp_spi;
sa_info[i].tunnel_id = tmp_tunnel;
-
- if (netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
- {
- trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
- }
- else
- {
- trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- }
+
+ if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+ {
+ trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+ }
+ else
+ {
+ trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+ }
}
- else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_HMAC_SHA2_256) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_3DES_CBC))
+ else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_SHA2_256) &&
+ (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_3DES_CBC))
{
/* 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.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_3DES_CBC_IV_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 = netTestCfg.sa_info[i].cipherMode;
- sa_info[i].authMode = netTestCfg.sa_info[i].authMode;
+ sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+ sa_info[i].authMode = netTestCfg.sa[i].authMode;
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].auth_tag_size = netTest_ICV_LEN;
sa_info[i].iv_len=8;
sa_info[i].bl=8;
- sa_info[i].src = *((unsigned int *)(&netTestCfg.sa_info[i].src));
- sa_info[i].dst =*((unsigned int *)(&netTestCfg.sa_info[i].dst));
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.l4HdrLen = netTest_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.ploadLen = 0;
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 ;
+ 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 ;
- sa_info[i].dir =netTestCfg.sa_info[i].dir;
- tmp_spi = htonl((long)(netTestCfg.sa_info[i].spi));
- tmp_tunnel = htonl((long)(netTestCfg.tunnel_id[i]));
+ sa_info[i].dir =netTestCfg.sa[i].dir;
+ tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+ tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
sa_info[i].spi =tmp_spi;
sa_info[i].tunnel_id = tmp_tunnel;
-
- if (netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
- {
- trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
- }
- else
- {
- trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- }
+
+ if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+ {
+ trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+ }
+ else
+ {
+ trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+ }
}
- else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_HMAC_MD5) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_NULL))
+ else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_MD5) &&
+ (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_NULL))
{
/* 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 + 24; /*done: same for all cipher suites */
sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN;
sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
- netTest_IP_HEADER_LEN +
- netTest_NULL_ESP_HEADER_LEN +
- netTest_NULL_IV_LEN +
- 24;
+ netTest_IP_HEADER_LEN +
+ netTest_NULL_ESP_HEADER_LEN +
+ netTest_NULL_IV_LEN +
+ 24;
sa_info[i].iv_len=0;
sa_info[i].bl=4;
- sa_info[i].src = *((unsigned int *)(&netTestCfg.sa_info[i].src));
- sa_info[i].dst =*((unsigned int *)(&netTestCfg.sa_info[i].dst));
/* 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 = netTestCfg.sa_info[i].cipherMode;
- sa_info[i].authMode = netTestCfg.sa_info[i].authMode;
+ sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+ sa_info[i].authMode = netTestCfg.sa[i].authMode;
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].auth_tag_size = netTest_ICV_LEN;
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.l4HdrLen = netTest_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.ploadLen = 0;
sa_info[i].tx_pkt_info.pPkt = NULL;
sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_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_AH_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM | NWAL_TX_FLAG1_META_DATA_VALID ;
- sa_info[i].dir =netTestCfg.sa_info[i].dir;
- tmp_spi = htonl((long)(netTestCfg.sa_info[i].spi));
- tmp_tunnel = htonl((long)(netTestCfg.tunnel_id[i]));
+ sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_AH_CRYPTO |
+ NWAL_TX_FLAG1_DO_UDP_CHKSUM |
+ NWAL_TX_FLAG1_META_DATA_VALID;
+ sa_info[i].dir =netTestCfg.sa[i].dir;
+ tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+ tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
sa_info[i].spi =tmp_spi;
sa_info[i].tunnel_id = tmp_tunnel;
-
- if (netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
- {
- trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
- }
- else
- {
- trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- }
+
+ if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+ {
+ trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+ }
+ else
+ {
+ trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+ }
}
- else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_NULL) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_AES_GCM))
+ else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
+ (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_GCM))
{
/* 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.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_AES_GCM_IV_LEN;
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_AES_GCM_IV_LEN;
sa_info[i].iv_len=0;
sa_info[i].bl=4;
- sa_info[i].src = *((unsigned int *)(&netTestCfg.sa_info[i].src));
- sa_info[i].dst =*((unsigned int *)(&netTestCfg.sa_info[i].dst));
/* 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 = netTestCfg.sa_info[i].cipherMode;
- sa_info[i].authMode = netTestCfg.sa_info[i].authMode;
+ sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+ sa_info[i].authMode = netTestCfg.sa[i].authMode;
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].auth_tag_size = netTest_AES_GCM_CCM_ICV_LEN;
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.l4HdrLen = netTest_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.ploadLen = 0;
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.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 ;
+ 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;
- sa_info[i].dir =netTestCfg.sa_info[i].dir;
- tmp_spi = htonl((long)(netTestCfg.sa_info[i].spi));
- tmp_tunnel = htonl((long)(netTestCfg.tunnel_id[i]));
+ sa_info[i].dir =netTestCfg.sa[i].dir;
+ tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+ tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
sa_info[i].spi =tmp_spi;
sa_info[i].tunnel_id = tmp_tunnel;
-
- if (netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
- {
- trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
- }
- else
- {
- trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- }
+
+ if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+ {
+ trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+ }
+ else
+ {
+ trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+ }
}
- else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_NULL) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_AES_CCM))
+ else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
+ (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CCM))
{
/* 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.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_AES_CCM_IV_LEN;
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_AES_CCM_IV_LEN;
sa_info[i].iv_len=0;
sa_info[i].bl=4;
- sa_info[i].src = *((unsigned int *)(&netTestCfg.sa_info[i].src));
- sa_info[i].dst =*((unsigned int *)(&netTestCfg.sa_info[i].dst));
/* 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 = netTestCfg.sa_info[i].cipherMode;
- sa_info[i].authMode = netTestCfg.sa_info[i].authMode;
+ sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+ sa_info[i].authMode = netTestCfg.sa[i].authMode;
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].auth_tag_size = netTest_AES_GCM_CCM_ICV_LEN;
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.l4HdrLen = netTest_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.ploadLen = 0;
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 ;
+ 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;
- sa_info[i].dir =netTestCfg.sa_info[i].dir;
- tmp_spi = htonl((long)(netTestCfg.sa_info[i].spi));
- tmp_tunnel = htonl((long)(netTestCfg.tunnel_id[i]));
+ sa_info[i].dir =netTestCfg.sa[i].dir;
+ tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+ tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
sa_info[i].spi =tmp_spi;
sa_info[i].tunnel_id = tmp_tunnel;
-
- if (netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
- {
- trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
- }
- else
- {
- trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- }
+
+ if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+ {
+ trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+ }
+ else
+ {
+ trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+ }
}
- else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_AES_XCBC) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_NULL))
+ else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_AES_XCBC) &&
+ (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_NULL))
{
/* 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.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;
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_NULL_IV_LEN;
sa_info[i].iv_len=0;
sa_info[i].bl=4;
- sa_info[i].src = *((unsigned int *)(&netTestCfg.sa_info[i].src));
- sa_info[i].dst =*((unsigned int *)(&netTestCfg.sa_info[i].dst));
/* 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 = netTestCfg.sa_info[i].cipherMode;
- sa_info[i].authMode = netTestCfg.sa_info[i].authMode;
+ sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+ sa_info[i].authMode = netTestCfg.sa[i].authMode;
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].auth_tag_size = netTest_ICV_LEN;
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.l4HdrLen = netTest_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.ploadLen = 0;
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 ;
+ 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;
- sa_info[i].dir =netTestCfg.sa_info[i].dir;
- tmp_spi = htonl((long)(netTestCfg.sa_info[i].spi));
- tmp_tunnel = htonl((long)(netTestCfg.tunnel_id[i]));
+ sa_info[i].dir =netTestCfg.sa[i].dir;
+ tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+ tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
sa_info[i].spi =tmp_spi;
sa_info[i].tunnel_id = tmp_tunnel;
-
- if (netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
- {
- trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
- }
- else
- {
- trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- }
+
+ if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+ {
+ trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+ }
+ else
+ {
+ trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+ }
}
- else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_GMAC) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_NULL))
+ else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_GMAC) &&
+ (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_NULL))
{
/* 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.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_AES_GMAC_IV_LEN;
+ netTest_IP_HEADER_LEN +
+ netTest_ESP_HEADER_LEN +
+ netTest_AES_GMAC_IV_LEN;
sa_info[i].iv_len=0;
sa_info[i].bl=4;
- sa_info[i].src = *((unsigned int *)(&netTestCfg.sa_info[i].src));
- sa_info[i].dst =*((unsigned int *)(&netTestCfg.sa_info[i].dst));
/* 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.pAuthIV = 0;
- sa_info[i].tx_payload_info.pPkt = 0;
+ sa_info[i].tx_payload_info.pAuthIV = 0;
- sa_info[i].cipherMode = netTestCfg.sa_info[i].cipherMode;
- sa_info[i].authMode = netTestCfg.sa_info[i].authMode;
+ sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+ sa_info[i].authMode = netTestCfg.sa[i].authMode;
sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
- sa_info[i].auth_tag_size = netTest_AES_GMAC_ICV_LEN; /* icv or mac size,. always 12 except for AES_CCM/AES_GCM , GMAC*/
+ sa_info[i].auth_tag_size = netTest_AES_GMAC_ICV_LEN;
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.l4HdrLen = netTest_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.ploadLen = 0;
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 ;
+ 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;
- sa_info[i].dir =netTestCfg.sa_info[i].dir;
- tmp_spi = htonl((long)(netTestCfg.sa_info[i].spi));
- tmp_tunnel = htonl((long)(netTestCfg.tunnel_id[i]));
+ sa_info[i].dir =netTestCfg.sa[i].dir;
+ tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+ tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
sa_info[i].spi =tmp_spi;
sa_info[i].tunnel_id = tmp_tunnel;
-
- if (netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
- {
- trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
- }
- else
- {
- trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- }
+
+ if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+ {
+ trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+ }
+ else
+ {
+ trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+ }
}
else
- netapi_Log("build_sa_db(): invalid encryption/authentication combination selected\n");
+ netapi_Log("netTest_utilBuildSADB(): invalid encryption/authentication combination selected\n");
- //netapi_Log("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);
-
-
}
-int create_sec_associations(void)
+int netTest_utilCreateSecAssoc(void)
{
nwal_RetValue nwalRetVal;
int err,i;
for (i=0; i < netTestCfg.num_sa;i++)
{
err = 0;
- if(netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
+ if(netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
{
- build_sa_db(i);
+ netTest_utilBuildSADB(i);
saId = i;
sa_info[i].rx_tunnel = netapi_secAddSA(
netapi_handle,
netTestCfg.ipsec_if_no, //iface #0
- &netTestCfg.sa_info[i],
+ &netTestCfg.sa[i],
&netTestCfg.key_params[i],
netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND ? NETAPI_SEC_SA_SIDEBAND: NETAPI_SEC_SA_INFLOW,
NULL, //use default route
rx_policy[i]= netapi_secAddRxPolicy( netapi_handle,
sa_info[i].rx_tunnel, //link to tunnel above
4, //ipv4
- &netTestCfg.sa_info[i].src,
- &netTestCfg.sa_info[i].dst,
+ &netTestCfg.sa[i].src,
+ &netTestCfg.sa[i].dst,
NULL, // no qualifiers
NULL, //default route
NULL, //user_data
}
}
//tx SA security stuff
- if(netTestCfg.sa_info[i].dir == NWAL_SA_DIR_OUTBOUND)
+ if(netTestCfg.sa[i].dir == NWAL_SA_DIR_OUTBOUND)
{
- build_sa_db(i);
+ netTest_utilBuildSADB(i);
saId = i;
sa_info[i].tx_tunnel = netapi_secAddSA( netapi_handle,
0, //iface #0
- &netTestCfg.sa_info[i],
+ &netTestCfg.sa[i],
&netTestCfg.key_params[i],
netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND ? NETAPI_SEC_SA_SIDEBAND: NETAPI_SEC_SA_INFLOW,
NULL, //use default route
}
-void delete_sec_associations()
+void netTest_utilDeleteSecAssoc()
{
int err,i;
for (i=0; i < netTestCfg.num_sa;i++)
netapi_secDelSA(netapi_handle, 0, sa_info[i].tx_tunnel, &err);
}
}
-}
\ No newline at end of file
+}
diff --git a/ti/runtime/netapi/test/net_test_sa_utils.h b/ti/runtime/netapi/test/net_test_sa_utils.h
index ea78d83b77e8b80263d675fa8dfffebb09915f5c..51b7d034ca9f27cc2d8220742f854156194f71f3 100755 (executable)
-#ifndef __NET_TEST_UTIL_H__
-#define __NET_TEST_UTIL_H__
+#ifndef __NET_TEST_SA_UTILS_H__
+#define __NET_TEST_SA_UTILS_H__
+#include "net_test.h"
+#define netTest_MAC_HEADER_LEN 14
+#define netTest_IP_HEADER_LEN 20
+#define netTest_UDP_HEADER_LEN 8
+#define netTest_ESP_HEADER_LEN 8
+#define netTest_AES_CBC_IV_LEN 16
+#define netTest_AES_CTR_IV_LEN 8
+#define netTest_3DES_CBC_IV_LEN 8
+#define netTest_AES_GCM_IV_LEN 8
+#define netTest_AES_CCM_IV_LEN 8
+#define netTest_AES_GMAC_IV_LEN 8
+#define netTest_NULL_IV_LEN 0
+#define netTest_ICV_LEN 12
+#define netTest_HMAC_SHA256_RFC_4868_ICV_LEN 16
+#define netTest_AES_GCM_CCM_ICV_LEN 16
+#define netTest_AES_GMAC_ICV_LEN 16
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+#define netTest_IPSEC_AH_PKT 1
+#define netTest_IPSEC_ESP_PKT 2
-#include "net_test.h"
+#define netTest_IPSEC_AH_FIXED_HDR_SIZE 12
+
+
+#define netTest_NULL_ESP_HEADER_LEN 0
+
+typedef struct {
+ nwalDmTxPayloadInfo_t tx_payload_info;
+ uint8_t inner_ip_offset;
+ NETCP_CFG_SA_T rx_tunnel;
+ void* rx_data_mode_handle;
+ void* rx_inflow_mode_handle;
+ NETCP_CFG_SA_T tx_tunnel;
+ void* tx_data_mode_handle;
+ void* tx_inflow_mode_handle;
+ uint8_t enc_key_length;
+ uint8_t auth_tag_size;
+ nwalTxPktInfo_t tx_pkt_info;
+ nwal_saEALG cipherMode;
+ nwal_saAALG authMode;
+ /*stuff for routing use case */
+ unsigned int src; //BE
+ unsigned int dst; //BE
+ unsigned int spi; //BE
+ unsigned int seq; //BE
+ int iv_len; //iv len (size of iv in pkt)
+ int bl; //block len (for padding calc)
+
+ /* Save NETCP CMD details during create time */
+ nwalTxDmPSCmdInfo_t rx_dmPSCmdInfo;
+ nwalTxDmPSCmdInfo_t tx_dmPSCmdInfo;
+ nwalTxPSCmdInfo_t tx_psCmdInfo;
+ uint32_t swInfo0;
+ uint32_t swInfo1;
+
+ uint32_t dir;
+ uint32_t tunnel_id;
+ nwalSecKeyParams_t* key_params;
+} netTestSA_t;
-void build_sa_db(int i);
-int create_sec_associations(void);
+void netTest_utilBuildSADB(int i);
+int netTest_utilCreateSecAssoc(void);
-void void delete_sec_associations(void);
+void netTest_utilDeleteSecAssoc(void);
#endif
diff --git a/ti/runtime/netapi/test/net_test_thread_utils.c b/ti/runtime/netapi/test/net_test_thread_utils.c
index c6bee4de33066eb463d16fc3b1bfa794987adadc..91346435053e18d953058b6bb2ffb00c5fef4152 100755 (executable)
*****************************************/
-#include "net_test_utils.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+#include "net_test.h"
#include <signal.h>
#include <pthread.h>
-#include "trie.h"
#include "router.h"
-#include <ti/drv/sa/salld.h>
-#include <ti/drv/pa/pa.h>
-
extern netTestConfig_t netTestCfg;
pthread_t *sp_threads;
pthread_t *fp_threads;
-void create_sp_fp_threads(void)
+void netTest_utilCreateSpFpThreads(uint8_t num_sp_threads,NET_TEST_FUNC_PTR slow_path_thread,
+ uint8_t num_fp_threads, NET_TEST_FUNC_PTR fast_path_thread)
{
int i;
-
-
- char c;
- sp_threads = malloc( sizeof( pthread_t ) * netTestCfg.num_sp_threads );
+ sp_threads = malloc( sizeof( pthread_t ) * num_sp_threads );
if (sp_threads == NULL)
{
perror( "malloc" );
exit(1);
}
- netapi_Log( "Starting %d threads...\n", netTestCfg.num_sp_threads );
- for (i = 0; i < netTestCfg.num_sp_threads; i++)
+ for (i = 0; i < num_sp_threads; i++)
{
if (pthread_create( &sp_threads[i], NULL, (void*)slow_path_thread,
(void *) netTestCfg.sp_thread_num[i]))
exit(1);
}
}
- fp_threads = malloc( sizeof( pthread_t ) * netTestCfg.num_fp_threads);
+ fp_threads = malloc( sizeof( pthread_t ) * num_fp_threads);
if (fp_threads == NULL)
{
perror( "malloc" );
exit(1);
}
- for (i = 0; i < netTestCfg.num_fp_threads; i++)
+ for (i = 0; i < num_fp_threads; i++)
{
if (pthread_create( &fp_threads[i], NULL, (void*)fast_path_thread,
(void *) netTestCfg.fp_thread_num[i]))
}
}
}
-void sp_fp_thread_cleanup(void)
+void netTest_utilRemoveSpFpThreads(uint8_t num_sp_threads, uint8_t num_fp_threads)
{
int i;
//wait for completion
netapi_Log("main task now pending on slow/fast path completion\n");
- for (i = 0; i < netTestCfg.num_sp_threads; i++)
+ for (i = 0; i < num_sp_threads; i++)
pthread_join( sp_threads[i], NULL );
- for (i = 0; i < netTestCfg.num_fp_threads; i++)
+ for (i = 0; i < num_fp_threads; i++)
pthread_join( fp_threads[i], NULL );
free( sp_threads);
diff --git a/ti/runtime/netapi/test/net_test_thread_utils.h b/ti/runtime/netapi/test/net_test_thread_utils.h
index 8184b154679894a6a539f4f7cbd38f46670656a6..242591c78260493971114f4179855f025c823a2d 100755 (executable)
-#ifndef __NET_TEST_UTIL_H__
-#define __NET_TEST_UTIL_H__
+#ifndef __NET_TEST_UTILS_H__
+#define __NET_TEST_UTILS_H__
+#include "net_test.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+typedef void (*NET_TEST_FUNC_PTR)(int thread_num);
-#include "net_test.h"
-#include "net_test_util.h"
-void create_sp_fp_threads(void);
-void sp_fp_thread_cleanup(void);
+void netTest_utilCreateSpFpThreads(uint8_t num_sp_threads,
+ NET_TEST_FUNC_PTR slow_path_thread,
+ uint8_t num_fp_threads,
+ NET_TEST_FUNC_PTR fast_path_thread);
+
+
+void netTest_utilRemoveSpFpThreads(uint8_t num_sp_threads,
+ uint8_t num_fp_threads);
+
-#ifdef MULTI_THREAD
-void slow_path_thread(int coreid);
-void fast_path_thread(int coreid);
-#endif
#endif
index d7c87db4a565fba1a9c037e6dbe57ac4f5ccee34..e428dc560f6941af9cb009449c3943c23ef3d5bd 100755 (executable)
*****************************************/
#include "net_test_utils.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
#include <signal.h>
#include <pthread.h>
-#include "trie.h"
#include "router.h"
+#include "ti/drv/nwal/test/fw_rm.h"
#include <ti/drv/sa/salld.h>
#include <ti/drv/pa/pa.h>
extern Pktlib_HeapHandle ourHeap;
extern NETCP_CFG_IP_T ip_rule[];
extern NETCP_CFG_MACIF_T mac[];
-Trie * our_router;
-STATS_T stats[TUNE_NETAPI_NUM_CORES];
-paSysStats_t netcp_stats;
-//#include "router.c"
+netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
+paSysStats_t netcp_stats;
-OUR_ROUTE_T routes[MAX_ROUTES]=
-{
-{0,{0xD4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x14,0x02,0x08,0x00},0},
-{0,{0x00,0x00,0x0,0x00,0x0,0x0, 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00},0},
-{0,{0xD4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x14,0x02,0x08,0x00},0},
-{0,{0x00,0x15,0x60,0xa1,0xf7,0xbe, 0x00,0x01,0x02,0x03,0x04,0x05,0x08,0x00},0},
-{0,{0xd4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x04,0x05,0x08,0x00},0}};
-
-static struct LastPktInfo lpInfo;
-int check_header(HEAD_T * p_head, PKTIO_METADATA_T * p_meta)
+
+static LastPktInfo_t lpInfo;
+int netTest_utilCheckHeader(netTestHead_T * p_head, PKTIO_METADATA_T * p_meta)
{
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
- //int coreid = our_core;
#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.ipcsum =(p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_MASK )== NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_ACK ? 1 : 0;
- 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)
+ if (NWAL_RX_FLAG1_META_DATA_VALID & p_meta->u.rx_meta->rxFlag1)
{
- stats[coreid].sec_rx++;
- }
- if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC_POLICY)
- {
- stats[coreid].secp_rx++;
- }
+ lpInfo.iface = ((unsigned int)p_meta->u.rx_meta->appId) &0xff; //last byte is interface num
+ lpInfo.ipcsum =(p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_MASK )== NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_ACK ? 1 : 0;
+ 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[coreid].sec_rx++;
+ }
+ if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC_POLICY)
+ {
+ 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[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 netapi_Log("**NET_TEST RX -unknown class: %x\n", p_meta->u.rx_meta->appId);
-}
+ 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[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 netapi_Log("**NET_TEST RX -unknown class: %x\n", p_meta->u.rx_meta->appId);
+ }
}
return 1;
static int scnt=0;
int QUIT;
-void mysig(int x)
+void netTest_utilMySig(int x)
{
QUIT=1;
scnt+=1;
exit(1);
}
}
-unsigned long peek(unsigned long * p)
+unsigned long netTest_utilPeek(unsigned long * p)
{
return *p;
}
-void dump_descr(unsigned long *p, int n)
+void netTest_utilDumpDescr(unsigned long *p, int n)
{
netapi_Log("--------dump of descriptor %d %x\n", n, (int) p);
netapi_Log("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
netapi_Log("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
netapi_Log("-----------------------------\n");
}
-void dump_header(unsigned long *p, int n, int a, int r)
+void netTest_utilDumpHeader(unsigned long *p, int n, int a, int r)
{
netapi_Log("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
netapi_Log("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
netapi_Log("-----------------------------\n");
}
-void netapi_dump_buf
+void netTest_utilDumpBuffer
(
unsigned long * buf,
uint32_t buf_length
default:
{
/* Should never reach here */
- netapi_Log("netapi *: Internal Error in netapi_dump_buf().Row Count: %d \n", row_count);
+ netapi_Log("netapi *: Internal Error in netTest_utilDumpBuffer().Row Count: %d \n", row_count);
return;
}
}
netapi_Log("netapi *: - Byte hex Dump End \n");
}
-long htonl(long x)
+long netTest_utilHtonl(long x)
{
long temp = (x&0xff000000)>>24 | (x&0xff0000)>>8 | (x&0xff00)<<8 | (x&0xff)<<24 ;
return temp;
}
-unsigned char hex2dec(char *p_s)
+unsigned char netTest_utilHex2Dec(char *p_s)
{
- int val;
- sscanf(p_s,"%x",&val);
- return val&0xff;
+ int val;
+ sscanf(p_s,"%x",&val);
+ return val&0xff;
}
/********************************************************************
* FUNCTION PURPOSE: Ones complement addition utility
********************************************************************
********************************************************************/
-uint16_t test_utilOnesComplementAdd (uint16_t v1, uint16_t v2)
+uint16_t netTest_utilOnesComplementAdd (uint16_t v1, uint16_t v2)
{
uint32_t result;
* FUNCTION PURPOSE: Ones complement checksum utility
********************************************************************
********************************************************************/
- uint16_t test_utilOnesCompChkSum (uint8_t *p, uint32_t nwords)
+ uint16_t netTest_utilOnesCompChkSum (uint8_t *p, uint32_t nwords)
{
uint16_t chksum = 0;
uint16_t v;
for (i = j = 0; i < nwords; i++, j+=2) {
v = (p[j] << 8) | p[j+1];
- chksum = test_utilOnesComplementAdd (chksum, v);
+ chksum = netTest_utilOnesComplementAdd (chksum, v);
}
return (chksum);
} /* utilOnesCompChkSum */
**************************************************************************************
* DESCRIPTION: Compute ipv4 psudo checksum
**************************************************************************************/
-uint16_t test_utilGetIpv4PsudoChkSum (uint8_t *data, uint16_t payloadLen)
+uint16_t netTest_utilGetIPv4PsudoChkSum (uint8_t *data, uint16_t payloadLen)
{
uint16_t psudo_chksum;
- psudo_chksum = test_utilOnesCompChkSum (&data[12], 4);
- psudo_chksum = test_utilOnesComplementAdd(psudo_chksum, (uint16_t) data[9]);
- psudo_chksum = test_utilOnesComplementAdd(psudo_chksum, payloadLen);
+ psudo_chksum = netTest_utilOnesCompChkSum (&data[12], 4);
+ psudo_chksum = netTest_utilOnesComplementAdd(psudo_chksum, (uint16_t) data[9]);
+ psudo_chksum = netTest_utilOnesComplementAdd(psudo_chksum, payloadLen);
return (psudo_chksum);
#define CHECK_SET_PARAM(ARG1, ARG2) \
do { \
if(strcmp(key, ARG1) == 0) { \
- if(d1)strncpy(ARG2,d1,CONFIG_STRING_LEN); \
+ if(d1)strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
continue; \
} \
} while(0)
#define CHECK_SET_PARAM2(ARG1, ARG2, ARG3) \
do { \
if(strcmp(key, ARG1) == 0) { \
- if(d1) strncpy(ARG2,d1,CONFIG_STRING_LEN); \
- if(d2) strncpy(ARG3,d2,CONFIG_STRING_LEN); \
+ if(d1) strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
+ if(d2) strncpy(ARG3,d2,netTest_CONFIG_STRING_LEN); \
continue; \
} \
} while(0)
ARG6, ARG7, ARG8, ARG9, ARG10, \
ARG11, ARG12,ARG13, ARG14, ARG15, ARG16,ARG17, ARG18) \
do { \
- if(d1) strncpy(ARG2,d1,CONFIG_STRING_LEN); \
- if(d2) strncpy(ARG3,d2,CONFIG_STRING_LEN); \
- if(d3) strncpy(ARG4,d3,CONFIG_STRING_LEN); \
- if(d4) strncpy(ARG5,d4,CONFIG_STRING_LEN); \
- if(d5) strncpy(ARG6, d5,CONFIG_STRING_LEN); \
- if(d6) strncpy(ARG7,d6,CONFIG_STRING_LEN); \
- if(d7) strncpy(ARG8,d7,CONFIG_STRING_LEN); \
- if(d8) strncpy(ARG9,d8,CONFIG_STRING_LEN); \
- if(d9) strncpy(ARG10,d9,CONFIG_STRING_LEN); \
- if(d10) strncpy(ARG11,d10,CONFIG_STRING_LEN); \
- if(d11) strncpy(ARG12,d11,CONFIG_STRING_LEN); \
- if(d12) strncpy(ARG13,d12,CONFIG_STRING_LEN); \
- if(d13) strncpy(ARG14,d13,CONFIG_STRING_LEN); \
- if(d14) strncpy(ARG15,d14,CONFIG_STRING_LEN); \
- if(d15) strncpy(ARG16,d15,CONFIG_STRING_LEN); \
- if(d16) strncpy(ARG17,d16,CONFIG_STRING_LEN); \
- if(d17) strncpy(ARG18,d17,CONFIG_STRING_LEN); \
+ if(strcmp(key, ARG1) == 0) { \
+ if(d1) strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
+ if(d2) strncpy(ARG3,d2,netTest_CONFIG_STRING_LEN); \
+ if(d3) strncpy(ARG4,d3,netTest_CONFIG_STRING_LEN); \
+ if(d4) strncpy(ARG5,d4,netTest_CONFIG_STRING_LEN); \
+ if(d5) strncpy(ARG6, d5,netTest_CONFIG_STRING_LEN); \
+ if(d6) strncpy(ARG7,d6,netTest_CONFIG_STRING_LEN); \
+ if(d7) strncpy(ARG8,d7,netTest_CONFIG_STRING_LEN); \
+ if(d8) strncpy(ARG9,d8,netTest_CONFIG_STRING_LEN); \
+ if(d9) strncpy(ARG10,d9,netTest_CONFIG_STRING_LEN); \
+ if(d10) strncpy(ARG11,d10,netTest_CONFIG_STRING_LEN); \
+ if(d11) strncpy(ARG12,d11,netTest_CONFIG_STRING_LEN); \
+ if(d12) strncpy(ARG13,d12,netTest_CONFIG_STRING_LEN); \
+ if(d13) strncpy(ARG14,d13,netTest_CONFIG_STRING_LEN); \
+ if(d14) strncpy(ARG15,d14,netTest_CONFIG_STRING_LEN); \
+ if(d15) strncpy(ARG16,d15,netTest_CONFIG_STRING_LEN); \
+ if(d16) strncpy(ARG17,d16,netTest_CONFIG_STRING_LEN); \
+ if(d17) strncpy(ARG18,d17,netTest_CONFIG_STRING_LEN); \
continue; \
+ } \
} while(0)
-void print_ipsec_stats(Sa_IpsecStats_t *p_saIpsecStats, nwal_saAALG auth, nwal_saEALG cipher)
+void netTest_utilPrintIPSecStats(Sa_IpsecStats_t *p_saIpsecStats, nwal_saAALG auth, nwal_saEALG cipher)
{
#if 0
if(retVal != nwal_OK)
p_saIpsecStats->pktEncLo,p_saIpsecStats->pktDecHi,p_saIpsecStats->pktDecLo);
}
-void print_datamode_stats(Sa_DataModeStats_t *p_saDataModeStats, nwal_saAALG auth, nwal_saEALG cipher)
+void netTest_utilPrintDataModeStats(Sa_DataModeStats_t *p_saDataModeStats, nwal_saAALG auth, nwal_saEALG cipher)
{
netapi_Log("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
/******************************************************
* stats callback
*******************************************************/
-void our_stats_cb_mt(NETAPI_T h, paSysStats_t* pPaStats)
+void netTest_utilStatsCbMt(NETAPI_T h, paSysStats_t* pPaStats)
{
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
//int coreid = our_core;
#else
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)
+void netTest_utilsStatsCb(NETAPI_T h, paSysStats_t* pPaStats)
{
uint32_t numFreeDataPackets;
uint32_t numZeroBufferPackets;
printf("\n");
}
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
for (i=0;i < TUNE_NETAPI_NUM_CORES;i++)
{
if(scheduler[i])
{
extern long * pa2sa_descr_base;
long * tip= &pa2sa_descr_base[32*i];
- dump_descr(tip, i);
+ netTest_utilDumpDescr(tip, i);
}
netapi_Log("sa2pa descriptor area dump\n");
for(i=0;i<TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;i++)
{
extern long * sa2pa_descr_base;
long * tip= &sa2pa_descr_base[32*i];
- dump_descr(tip, i);
+ netTest_utilDumpDescr(tip, i);
}
#endif
for (i = 0; i < netTestCfg.num_sa; i++)
{
/* Statistics for RX Tunnel */
memset(&netapi_sa_stats, 0, sizeof(netapi_sa_stats));
- if (sa_info[i].dir ==NWAL_SA_DIR_INBOUND )
+ if (netTestCfg.sa[i].dir ==NWAL_SA_DIR_INBOUND )
{
netapi_getSaStats(netapi_handle, sa_info[i].rx_tunnel, &netapi_sa_stats);
if (netapi_sa_stats.validParams & NETAPI_IPSEC_STAT_VALID)
{
- print_ipsec_stats(&(netapi_sa_stats.saIpsecStats),
- sa_info[i].authMode,
- sa_info[i].cipherMode);
+ netTest_utilPrintIPSecStats(&(netapi_sa_stats.saIpsecStats),
+ netTestCfg.sa[i].authMode,
+ netTestCfg.sa[i].cipherMode);
}
if (netapi_sa_stats.validParams & NETAPI_SIDEBAND_DATA_MODE_STAT_VALID)
{
- print_datamode_stats(&(netapi_sa_stats.dataModeStats),
- sa_info[i].authMode,
- sa_info[i].cipherMode);
+ netTest_utilPrintDataModeStats(&(netapi_sa_stats.dataModeStats),
+ netTestCfg.sa[i].authMode,
+ netTestCfg.sa[i].cipherMode);
}
}
- else if (sa_info[i].dir ==NWAL_SA_DIR_OUTBOUND)
+ else if (netTestCfg.sa[i].dir ==NWAL_SA_DIR_OUTBOUND)
{
netapi_getSaStats(netapi_handle, sa_info[i].tx_tunnel, &netapi_sa_stats);
if (netapi_sa_stats.validParams & NETAPI_IPSEC_STAT_VALID)
{
- print_ipsec_stats(&(netapi_sa_stats.saIpsecStats),
- sa_info[i].authMode,
- sa_info[i].cipherMode);
+ netTest_utilPrintIPSecStats(&(netapi_sa_stats.saIpsecStats),
+ netTestCfg.sa[i].authMode,
+ netTestCfg.sa[i].cipherMode);
}
if (netapi_sa_stats.validParams & NETAPI_SIDEBAND_DATA_MODE_STAT_VALID)
{
- print_datamode_stats(&(netapi_sa_stats.dataModeStats),
- sa_info[i].authMode,
- sa_info[i].cipherMode);
+ netTest_utilPrintDataModeStats(&(netapi_sa_stats.dataModeStats),
+ netTestCfg.sa[i].authMode,
+ netTestCfg.sa[i].cipherMode);
}
}
else
- netapi_Log("our_stats_cb: invalid SA direction\n");
+ netapi_Log("netTest_utilsStatsCb: invalid SA direction\n");
}
netapi_dump_internal_heap_stats();
}
-void parse_one_mac(char * p_mac_str, unsigned char *p_mac)
-{
- int index = 0;
- int i;
- char *pch = strtok (&(p_mac_str[0]),"-");
- while (pch != NULL)
+
+void parse_dsp_mac(char * p_mac_str)
+{
+ if (strlen(&p_mac_str[0]))
{
- p_mac[index] = hex2dec(pch);
- index++;
- pch = strtok (NULL,"-");
+ printf("parse_dsp_mac(string): %s\n", p_mac_str);
+ sscanf(p_mac_str,"mac%d",&netTestCfg.dsp_mac);
+ printf("parse_dsp_mac(integer): mac: %d\n", netTestCfg.dsp_mac);
}
}
+void parse_dsp_ip(char * p_ip_str)
+{
+ if (strlen(&p_ip_str[0]))
+ {
+ printf("parse_dsp_ip: %s\n", p_ip_str);
+ sscanf(p_ip_str,"ip%d",&netTestCfg.dsp_ip);
+ printf("parse_dsp_ip: ip: %d\n", netTestCfg.dsp_ip);
+ }
+}
-void parse_one_key(char *p_key_str, unsigned char *p_key)
+void netTest_utilParseOneKey(char *p_key_str, unsigned char *p_key)
{
int index = 0;
int i;
- char * pch = strtok (&p_key_str[0],",");
-
- while (pch != NULL)
+ if (strlen(&p_key_str[0]))
{
- p_key[index] = hex2dec(pch);
- index++;
- pch = strtok (NULL,",");
+ char * pch = strtok (&p_key_str[0],",");
+
+ while (pch != NULL)
+ {
+ p_key[index] = netTest_utilHex2Dec(pch);
+ index++;
+ pch = strtok (NULL,",");
+ }
}
}
-void parse_one_ip(char * p_ip_addr_str, unsigned char * p_ip)
+void netTest_utilParseOneIP(char * p_ip_addr_str, unsigned char * p_ip)
{
int index = 0;
int i;
- char * pch = strtok (&p_ip_addr_str[0],".");
+ if (strlen(&p_ip_addr_str[0]))
+ {
+ char * pch = strtok (&p_ip_addr_str[0],".");
+
+ while (pch != NULL)
+ {
+ p_ip[index] = atoi(pch);
+ index++;
+ pch = strtok (NULL,".");
+ }
+ }
+}
- while (pch != NULL)
+void netTest_utilParseOneMac(char * p_mac_str, unsigned char *p_mac)
+{
+ int index = 0;
+ int i;
+ if (strlen(&p_mac_str[0]))
{
- p_ip[index] = atoi(pch);
- index++;
- pch = strtok (NULL,".");
+ char *pch = strtok (&(p_mac_str[0]),"-");
+
+ while (pch != NULL)
+ {
+ p_mac[index] = netTest_utilHex2Dec(pch);
+ index++;
+ pch = strtok (NULL,"-");
+ }
}
}
-void parse_mac_address(netTestConfigFile_t *pConfig)
+void netTest_utilParseMac(netTestConfigFile_t *pConfig)
{
int i;
int port = 0;
if (strlen(&pConfig->mac[i][0]))
{
netTestCfg.num_macs++;
- parse_one_mac(&pConfig->mac[i][0],&netTestCfg.mac[i][0]);
+ netTest_utilParseOneMac(&pConfig->mac[i][0],&netTestCfg.mac[i][0]);
sscanf(&pConfig->switch_port[i][0],"sp%d",&netTestCfg.switch_port[i]);
}
}
- netapi_Log("parse_mac_address: number of mac address %d\n", netTestCfg.num_macs);
+ netapi_Log("netTest_utilParseMac: number of mac address %d\n", netTestCfg.num_macs);
}
-void parse_ip_address(netTestConfigFile_t *pConfig)
+void netTest_utilParseIP(netTestConfigFile_t *pConfig)
{
int i;
if (strlen(&pConfig->ip[i][0]))
{
netTestCfg.num_ips++;
- parse_one_ip(&pConfig->ip[i][0],&netTestCfg.ip[i].ipv4[0]);
+ netTest_utilParseOneIP(&pConfig->ip[i][0],&netTestCfg.ip[i].ipv4[0]);
sscanf(&pConfig->attach_iface[i][0],"mac%d",&netTestCfg.attach_iface[i]);
}
}
- netapi_Log("parse_ip_address: number of ip address %d\n", netTestCfg.num_ips);
+ netapi_Log("netTest_utilParseIP: number of ip address %d\n", netTestCfg.num_ips);
}
-void parse_ipsec_mode(netTestConfigFile_t *pConfig)
+void netTest_utilParseIpsecMode(netTestConfigFile_t *pConfig)
{
if (strlen(&pConfig->ipsec_mode_rx[0]))
}
else
{
- netapi_Log("parse_ipsec_mode(), invalid RX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseIpsecMode(), invalid RX ipsec mode in config file \n");
}
}
}
else
{
- netapi_Log("parse_ipsec_mode(), invalid TX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseIpsecMode(), invalid TX ipsec mode in config file \n");
}
}
}
-void parse_auth_mode(char *auth_mode_str, nwal_saAALG *auth_mode)
+void netTest_utilParseAuthMode(char *auth_mode_str, nwal_saAALG *auth_mode)
{
if (strlen(auth_mode_str))
{
}
else
{
- netapi_Log("parse_auth_mode: invalid auth mode specified\n");
+ netapi_Log("netTest_utilParseAuthMode: invalid auth mode specified\n");
}
}
}
-void parse_encr_mode(char *ency_mode_str, nwal_saEALG*encr_mode)
+void netTest_utilParseEncryptMode(char *ency_mode_str, nwal_saEALG*encr_mode)
{
if (strlen(ency_mode_str))
{
}
else
{
- netapi_Log("parse_encr_mode: invalid auth mode specified\n");
+ netapi_Log("netTest_utilParseEncryptMode: invalid auth mode specified\n");
}
}
}
-void parse_proto(char *proto_str, nwal_IpSecProto *proto)
+void netTest_utilParseProto(char *proto_str, nwal_IpSecProto *proto)
{
if (strlen(proto_str))
{
if (strcmp(proto_str, "ESP") == 0)
{
*proto= nwal_IpSecProtoESP;
- netapi_Log("parse_proto(): setting proto to ESP\n");
+ netapi_Log("netTest_utilParseProto(): setting proto to ESP\n");
}
else if (strcmp(proto_str, "AH") == 0)
{
*proto = nwal_IpSecProtoAH;
- netapi_Log("parse_proto(): setting proto to AH\n");
+ netapi_Log("netTest_utilParseProto(): setting proto to AH\n");
}
else
{
- netapi_Log("parse_proto(), invalid RX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseProto(), invalid RX ipsec mode in config file \n");
}
}
}
-void parse_mode(char *mode_str, nwal_saMode *mode)
+void netTest_utilParseSaMode(char *mode_str, nwal_saMode *mode)
{
if (strlen(mode_str))
{
}
else
{
- netapi_Log("parse_mode(), invalid RX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseSaMode(), invalid RX ipsec mode in config file \n");
}
}
}
-void parse_ipType(char *ip_type_str, nwal_IpType *ipType)
+void netTest_utilParseIPType(char *ip_type_str, nwal_IpType *ipType)
{
if (strlen(ip_type_str))
{
}
else
{
- netapi_Log("parse_ipType(), invalid RX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseIPType(), invalid RX ipsec mode in config file \n");
}
}
}
-void parse_spi(char *spi_str, uint32_t *spi)
+void parse_simple_param_u16(char* input_str, uint16_t *val)
{
- if (strlen(spi_str))
+ if (strlen(input_str))
{
- *spi = (int)strtol(spi_str, NULL, 0);
+ *val = (uint16_t)strtol(input_str, NULL, 0);
}
}
-void parse_replayWindow(char *replay_window_str, uint32_t *replay_window)
-{
- *replay_window = atoi(replay_window_str);
-}
-
-void parse_esn(char *esn_str, uint32_t *esn)
-{
- *esn = atoi(esn_str);
-}
-
-void parse_key_size(char *key_size_str, uint16_t *key_size)
+void parse_simple_param_u32(char* input_str, uint32_t *val)
{
- *key_size = atoi(key_size_str);
-}
-
-void parse_tunnel_id(char * tunnel_id_str, uint32_t *tunnel_id)
-{
- if (strlen(tunnel_id_str))
+ if (strlen(input_str))
{
- *tunnel_id = (int)strtol(tunnel_id_str, NULL, 0);
+ *val = (uint32_t)strtol(input_str, NULL, 0);
}
}
-void parse_dir(char* dir_str, nwal_SaDir *dir)
+void netTest_utilParseSADir(char* dir_str, nwal_SaDir *dir)
{
if (strlen(dir_str))
{
*dir = NWAL_SA_DIR_OUTBOUND;
}
else
- netapi_Log("parse_dir: invalid direction\n");
+ netapi_Log("netTest_utilParseSADir: invalid direction\n");
}
}
-void parse_one_fp(char * p_fp_str, uint8_t* start, uint8_t* end)
+void netTest_utilParseThreadConfig(char * p_thread_str, uint8_t* start, uint8_t* end)
{
int index = 0;
int i;
- char *pch = strtok (&(p_fp_str[0]),"-");
- *start = atoi(pch);
- pch = strtok (NULL,"-");
- *end = atoi(pch);
- netapi_Log("parse_one_fp: start %d, end %d\n", *start, *end);
-}
-
-
-void parse_sp(netTestConfigFile_t *pConfig)
-{
- int i;
- int port = 0;
- for(i=0;i<NET_TEST_MAX_FP_THREAD;i++)
+ if (strlen(p_thread_str))
{
- if (strlen(&pConfig->sp[i][0]))
- {
- netTestCfg.num_sp_threads++;
- parse_one_fp(&pConfig->sp[i][0],(uint8_t*)&netTestCfg.sp_proc_start[i], (uint8_t*)&netTestCfg.sp_proc_end);
- }
- if (strlen(&pConfig->sp_thread_num[i][0]))
- {
- netTestCfg.sp_thread_num[i] = atoi((char*)(&pConfig->sp_thread_num[i]));
- netapi_Log("parse_sp: thread_num[%d]: %d\n", i, netTestCfg.sp_thread_num[i]);
- }
+ char *pch = strtok (&(p_thread_str[0]),"-");
+ *start = atoi(pch);
+ pch = strtok (NULL,"-");
+ *end = atoi(pch);
+ netapi_Log("netTest_utilParseThreadConfig: start %d, end %d\n", *start, *end);
}
- netapi_Log("parse_sp: number of sp threads %d\n", netTestCfg.num_sp_threads);
-
}
-
-void parse_fp(netTestConfigFile_t *pConfig)
+void netTest_utilParseThreadParams(netTestConfigFile_t *pConfig)
{
int i;
- int port = 0;
for(i=0;i<NET_TEST_MAX_FP_THREAD;i++)
{
if (strlen(&pConfig->fp[i][0]))
{
netTestCfg.num_fp_threads++;
- parse_one_fp(&pConfig->fp[i][0],(uint8_t*)&netTestCfg.fp_proc_start[i], (uint8_t*)&netTestCfg.fp_proc_end);
+ netTest_utilParseThreadConfig(&pConfig->fp[i][0],(uint8_t*)&netTestCfg.fp_proc_start[i], (uint8_t*)&netTestCfg.fp_proc_end);
}
if (strlen(&pConfig->fp_thread_num[i][0]))
{
}
netapi_Log("parse_fp: number of fp threads %d\n", netTestCfg.num_fp_threads);
-}
-
-
-void parse_ipsec_if_no(netTestConfigFile_t *pConfig)
-{
- if (strlen(&pConfig->ipsec_if_no[0]))
+ for(i=0;i<NET_TEST_MAX_FP_THREAD;i++)
{
- netTestCfg.ipsec_if_no= atoi(&pConfig->ipsec_if_no[0]);
- netapi_Log("parse_ipsec_if_no %d\n",netTestCfg.ipsec_if_no);
+ if (strlen(&pConfig->sp[i][0]))
+ {
+ netTestCfg.num_sp_threads++;
+ netTest_utilParseThreadConfig(&pConfig->sp[i][0],(uint8_t*)&netTestCfg.sp_proc_start[i], (uint8_t*)&netTestCfg.sp_proc_end);
+ }
+ if (strlen(&pConfig->sp_thread_num[i][0]))
+ {
+ netTestCfg.sp_thread_num[i] = atoi((char*)(&pConfig->sp_thread_num[i]));
+ netapi_Log("parse_sp: thread_num[%d]: %d\n", i, netTestCfg.sp_thread_num[i]);
+ }
}
+ netapi_Log("parse_sp: number of sp threads %d\n", netTestCfg.num_sp_threads);
}
-
-void parse_sa(netTestConfigFile_t *pConfig, int i)
+void netTest_utilParseSA(netTestConfigFile_t *pConfig)
{
- parse_dir((char*) &pConfig->sa_config[i].dir, &netTestCfg.sa_info[i].dir);
- parse_spi((char*)&pConfig->sa_config[i].spi, &netTestCfg.sa_info[i].spi);
- parse_proto((char*)&pConfig->sa_config[i].proto, &netTestCfg.sa_info[i].proto);
- parse_mode((char*)&pConfig->sa_config[i].saMode, &netTestCfg.sa_info[i].saMode);
- parse_ipType((char*)&pConfig->sa_config[i].ipType, &netTestCfg.sa_info[i].ipType);
- parse_one_ip((char*)&pConfig->sa_config[i].src, (unsigned char *)&netTestCfg.sa_info[i].src);
- parse_one_ip((char*)&pConfig->sa_config[i].dst, (unsigned char *)&netTestCfg.sa_info[i].dst);
- parse_replayWindow((char*)&pConfig->sa_config[i].replayWindow, &netTestCfg.sa_info[i].replayWindow);
- parse_auth_mode((char*)&pConfig->sa_config[i].authMode, &netTestCfg.sa_info[i].authMode);
- parse_encr_mode((char*)&pConfig->sa_config[i].cipherMode, &netTestCfg.sa_info[i].cipherMode);
- parse_esn((char*)&pConfig->sa_config[i].esnLo, &netTestCfg.sa_info[i].esnLo);
- parse_esn((char*)&pConfig->sa_config[i].esnHi, &netTestCfg.sa_info[i].esnHi);
- parse_key_size((char*)&pConfig->sa_config[i].encKeySize, &netTestCfg.key_params[i].encKeySize);
- parse_key_size((char*)&pConfig->sa_config[i].macKeySize, &netTestCfg.key_params[i].macKeySize);
+ int i;
+ for(i=0;i<MAX_SEC_INDEX;i++)
+ {
+ if (strlen((char*)&pConfig->sa_config[i][0].dir))
+ {
+ netTest_utilParseSADir((char*) &pConfig->sa_config[i][0].dir, &netTestCfg.sa[i].dir);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].spi, &netTestCfg.sa[i].spi);
+ netTest_utilParseProto((char*)&pConfig->sa_config[i][0].proto, &netTestCfg.sa[i].proto);
+ netTest_utilParseSaMode((char*)&pConfig->sa_config[i][0].saMode, &netTestCfg.sa[i].saMode);
+ netTest_utilParseIPType((char*)&pConfig->sa_config[i][0].ipType, &netTestCfg.sa[i].ipType);
+ netTest_utilParseOneIP((char*)&pConfig->sa_config[i][0].src, (unsigned char *)&netTestCfg.sa[i].src);
+ netTest_utilParseOneIP((char*)&pConfig->sa_config[i][0].dst, (unsigned char *)&netTestCfg.sa[i].dst);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].replayWindow, &netTestCfg.sa[i].replayWindow);
+ netTest_utilParseAuthMode((char*)&pConfig->sa_config[i][0].authMode, &netTestCfg.sa[i].authMode);
+ netTest_utilParseEncryptMode((char*)&pConfig->sa_config[i][0].cipherMode, &netTestCfg.sa[i].cipherMode);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].esnLo, &netTestCfg.sa[i].esnLo);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].esnHi, &netTestCfg.sa[i].esnHi);
+ parse_simple_param_u16((char*)&pConfig->sa_config[i][0].encKeySize, &netTestCfg.key_params[i].encKeySize);
+ parse_simple_param_u16((char*)&pConfig->sa_config[i][0].macKeySize, &netTestCfg.key_params[i].macKeySize);
- parse_one_key((char*) &pConfig->sa_config[i].encr_key, &netTestCfg.encr_key[i][0]);
- netTestCfg.key_params[i].pEncKey = (uint8_t*)&netTestCfg.encr_key[i][0];
+ netTest_utilParseOneKey((char*) &pConfig->sa_config[i][0].encr_key, &netTestCfg.encr_key[i][0]);
+ netTestCfg.key_params[i].pEncKey = (uint8_t*)&netTestCfg.encr_key[i][0];
- parse_one_key((char*)&pConfig->sa_config[i].auth_key, &netTestCfg.auth_key[i][0]);
- netTestCfg.key_params[i].pAuthKey= (uint8_t*)&netTestCfg.auth_key[i][0];
+ netTest_utilParseOneKey((char*)&pConfig->sa_config[i][0].auth_key, &netTestCfg.auth_key[i][0]);
+ netTestCfg.key_params[i].pAuthKey= (uint8_t*)&netTestCfg.auth_key[i][0];
- parse_tunnel_id((char*)&pConfig->sa_config[i].tunnel_id, &netTestCfg.tunnel_id[i]);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].tunnel_id, &netTestCfg.tunnel_id[i]);
- netTestCfg.num_sa++;
- printf("**************************** parse sa: num_sa %d\n", netTestCfg.num_sa);
+ netTestCfg.num_sa++;
+ }
+ }
}
-
-
-int n_routes=0;
-int n_dst_ips=0;
-void parse_routes(netTestConfigFile_t *pConfig)
+void netTest_utilParseRoutes(netTestConfigFile_t *pConfig, OUR_ROUTE_T *routes, Trie ** our_router)
{
int i;
int said=0;
if (pConfig->routes[i][0])
{
port=atoi(&pConfig->ports[i][0]);
- if((port<1)||(port>2)) continue; //bad port #: only 1 or 2 valid
- netapi_Log("parse_routes [%d]: %s\n", i, &pConfig->routes[i][0]);
- if(strncmp(&pConfig->routes[i][0],"MAC",3)==0)
- {
- routes[i].out_port = port;
- parse_one_mac(&pConfig->routes[i][3],&routes[i].out_mac[0]);
- //memcpy(&routes[i].out_mac[6], ((port==1) ?&config.mac0[0]: &config.mac1[0] ),6);
- memcpy(&routes[i].out_mac[6], ((port==1) ?&netTestCfg.mac[0][0]: &netTestCfg.mac[1][0] ),6);
- routes[i].out_mac[12]=0x08;
- routes[i].out_mac[13]=0x00;
- routes[i].sec_ptr=NULL;
- n_routes+=1;
- }
- else if (strncmp(&pConfig->routes[i][0],"SA",2)==0)
- {
- said=atoi(&pConfig->routes[i][2]) ;
- routes[i].sec_ptr=&sa_info[said];
- n_routes+=1;
- }
- }
+ if((port<1)||(port>2)) continue; //bad port #: only 1 or 2 valid
+ netapi_Log("netTest_utilParseRoutes [%d]: %s\n", i, &pConfig->routes[i][0]);
+ if(strncmp(&pConfig->routes[i][0],"MAC",3)==0)
+ {
+ routes[i].out_port = port;
+ netTest_utilParseOneMac(&pConfig->routes[i][3],&routes[i].out_mac[0]);
+ //memcpy(&routes[i].out_mac[6], ((port==1) ?&config.mac0[0]: &config.mac1[0] ),6);
+ memcpy(&routes[i].out_mac[6], ((port==1) ?&netTestCfg.mac[0][0]: &netTestCfg.mac[1][0] ),6);
+ routes[i].out_mac[12]=0x08;
+ routes[i].out_mac[13]=0x00;
+ routes[i].sec_ptr=NULL;
+ }
+ else if (strncmp(&pConfig->routes[i][0],"SA",2)==0)
+ {
+ said=atoi(&pConfig->routes[i][2]) ;
+ routes[i].sec_ptr=&sa_info[said];
+ }
+ }
}
- our_router = route_init();
+ *our_router = route_init();
for (i=0;i<MAX_ROUTES;i++)
{
unsigned long ip_be;
int route_index;
if (pConfig->dst_ips[i][0])
{
- parse_one_ip(&pConfig->dst_ips[i][0],(unsigned char *)&ip_be);
+ netTest_utilParseOneIP(&pConfig->dst_ips[i][0],(unsigned char *)&ip_be);
sscanf(&pConfig->paths[i][0],"route%d",&route_index);
- route_add(our_router,&ip_be,(void*)&routes[route_index]);
- n_dst_ips+=1;
+ route_add(*our_router,&ip_be,(void*)&routes[route_index]);
}
}
-//netapi_Log(">Route DB built. %d entries\n",n_dst_ips);
}
-void parse_config_file(FILE * fpr, netTestConfigFile_t *pConfig)
+void netTest_utilProcessConfigFile(FILE * fpr, netTestConfigFile_t *pConfig)
{
char line[MAX_LINE_LENGTH + 1];
int i;
d16 = (char *)strtok(NULL, tokens);
d17 = (char *)strtok(NULL, tokens);
- CHECK_SET_PARAM(INIT_CONFIG_IPSEC_MODE_RX,&(pConfig->ipsec_mode_rx[0]));
- CHECK_SET_PARAM(INIT_CONFIG_IPSEC_MODE_TX,&(pConfig->ipsec_mode_tx[0]));
- CHECK_SET_PARAM(INIT_CONFIG_IPSEC_IF_NO,&(pConfig->ipsec_if_no[0]));
- //CHECK_SET_PARAM(INIT_CONFIG_NUM_FP_CORES,&(pConfig->num_fp_cores[0]));
- //CHECK_SET_PARAM(INIT_CONFIG_NUM_FP_THREADS,&(pConfig->num_fp_threads[0]));
-
- sprintf(temp_str,"sa%d",sa_count);
- if(strcmp(key, temp_str) == 0)
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_IPSEC_MODE_RX,&(pConfig->ipsec_mode_rx[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_IPSEC_MODE_TX,&(pConfig->ipsec_mode_tx[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_IPSEC_IF_NO,&(pConfig->ipsec_if_no[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_DSP_MAC,&(pConfig->dsp_mac[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_DSP_IP,&(pConfig->dsp_ip[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_STATIC_LOOPBACK_PORT,&(pConfig->dest_udp_port_config[0]));
+
+
+ for(i=0;i<MAX_SEC_INDEX;i++)
{
- netapi_Log("parse_config_file, temp_str %s, sa_count: %d\n", temp_str, sa_count);
+ sprintf(temp_str,"sa%d",i);
CHECK_SET_PARAM_SA(temp_str,
- (char*)&pConfig->sa_config[sa_count].dir,
- (char*)&pConfig->sa_config[sa_count].spi,
- (char*)&pConfig->sa_config[sa_count].proto,
- (char*)&pConfig->sa_config[sa_count].saMode,
- (char*)&pConfig->sa_config[sa_count].ipType,
- (char*)&pConfig->sa_config[sa_count].src,
- (char*)&pConfig->sa_config[sa_count].dst,
- (char*)&pConfig->sa_config[sa_count].replayWindow,
- (char*)&pConfig->sa_config[sa_count].authMode,
- (char*)&pConfig->sa_config[sa_count].cipherMode,
- (char*)&pConfig->sa_config[sa_count].esnLo,
- (char*)&pConfig->sa_config[sa_count].esnHi,
- (char*)&pConfig->sa_config[sa_count].encKeySize,
- (char*)&pConfig->sa_config[sa_count].macKeySize,
- (char*)&pConfig->sa_config[sa_count].encr_key,
- (char*)&pConfig->sa_config[sa_count].auth_key,
- (char*)&pConfig->sa_config[sa_count].tunnel_id);
- parse_sa(pConfig,sa_count);
- sa_count++;
- continue;
+ (char*)&pConfig->sa_config[i][0].dir,
+ (char*)&pConfig->sa_config[i][0].spi,
+ (char*)&pConfig->sa_config[i][0].proto,
+ (char*)&pConfig->sa_config[i][0].saMode,
+ (char*)&pConfig->sa_config[i][0].ipType,
+ (char*)&pConfig->sa_config[i][0].src,
+ (char*)&pConfig->sa_config[i][0].dst,
+ (char*)&pConfig->sa_config[i][0].replayWindow,
+ (char*)&pConfig->sa_config[i][0].authMode,
+ (char*)&pConfig->sa_config[i][0].cipherMode,
+ (char*)&pConfig->sa_config[i][0].esnLo,
+ (char*)&pConfig->sa_config[i][0].esnHi,
+ (char*)&pConfig->sa_config[i][0].encKeySize,
+ (char*)&pConfig->sa_config[i][0].macKeySize,
+ (char*)&pConfig->sa_config[i][0].encr_key,
+ (char*)&pConfig->sa_config[i][0].auth_key,
+ (char*)&pConfig->sa_config[i][0].tunnel_id);
}
-#ifdef EXPERIMENTAL
for(i=0;i<MAX_ROUTES;i++)
{
sprintf(temp_str,"route%d",i);
sprintf(temp_str,"dstip%d",i);
CHECK_SET_PARAM2(temp_str,&pConfig->dst_ips[i][0],&pConfig->paths[i][0] );
}
-#endif
for(i=0;i<NET_TEST_MAX_MAC;i++)
{
sprintf(temp_str,"mac%d",i);
CHECK_SET_PARAM2(temp_str, &pConfig->sp_thread_num[i][0],&pConfig->sp[i][0]);
}
}
- parse_mac_address(pConfig);
+#if 0
+ netTest_utilParseMac(pConfig);
- parse_fp(pConfig);
- parse_sp(pConfig);
+ /* parse slow path/fast path thread configuration parameters */
+ netTest_utilParseThreadParams(pConfig);
- parse_ip_address(pConfig);
+ netTest_utilParseIP(pConfig);
- parse_ipsec_mode(pConfig);
+ netTest_utilParseIpsecMode(pConfig);
+ /* DSP mac processing */
+ parse_dsp_mac(&pConfig->dsp_mac[0]);
-#ifdef EXPERIMENTAL
- parse_routes(pConfig);
-#endif
+ /* DSP IP processing */
+ parse_dsp_ip(&pConfig->dsp_ip[0]);
- parse_ipsec_if_no(pConfig);
- //parse_num_fp_cores(pConfig);
- //parse_num_fp_threads(pConfig);
+ netTest_utilParseRoutes(pConfig);
+
+ parse_simple_param_u32((char*)&pConfig->ipsec_if_no[0], &netTestCfg.ipsec_if_no);
+
+ netTest_utilParseSA(pConfig);
+#endif
}
//******************************************************
NETAPI_SCHED_SHUTDOWN_T sched_shutdown;
uint32_t coreid = 0; //who we are
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
NETAPI_T nh= netapi_schedGetHandle(s);
coreid=(uint32_t) netapi_getCookie(nh);
/* only slow path threads get netcp stats */
if (coreid & NET_TEST_SP_THREAD_MASK)
{
- netapi_netcpCfgReqStats(nh, our_stats_cb_mt, 0,&err);
+ netapi_netcpCfgReqStats(nh, netTest_utilStatsCbMt, 0,&err);
}
coreid = NET_TEST_THREAD_NUM_MASK & coreid;
{
house_pkts_gened+=TX_BURST;
netapi_Log("net_test> request stats at n=%d \n",house_pkts_gened);
- netapi_netcpCfgReqStats(netapi_handle, our_stats_cb, 0,&err);
+ netapi_netcpCfgReqStats(netapi_handle, netTest_utilsStatsCb, 0,&err);
if (err!=0) {netapi_Log("stats req failed\n");}
if (house_pkts_gened >= np2process+ 100)
{
if ((house_pkts_gened>0) && (! (house_pkts_gened%1000)) )
{
netapi_Log("net_test> request stats at n=%d \n",house_pkts_gened);
- netapi_netcpCfgReqStats(netapi_handle, our_stats_cb, 0,&err);
+ netapi_netcpCfgReqStats(netapi_handle, netTest_utilsStatsCb, 0,&err);
if (err!=0) {netapi_Log("stats req failed\n");}
}
else if (house_pkts_gened >= np2process) { house_pkts_gened+=1; continue;}
/* manufacture a pkt to transmit */
- tip = get_pkt(house_pkts_gened, &len, ourHeap, PKT_LEN,&testPkt[0] , TEST_PKT_LEN);
+ tip = get_pkt(house_pkts_gened, &len, ourHeap, netTest_PKT_LEN,&testPkt[0] , TEST_netTest_PKT_LEN);
if(!tip) { house_pkts_gened +=1; continue; }
}
pIpHdr = pData + meta_tx.ipOffBytes;
meta_tx.pseudoHdrChecksum =
- test_utilGetIpv4PsudoChkSum(pIpHdr,(TEST_PAYLOAD_LEN+TEST_PKT_UDP_HDR_LEN));
+ netTest_utilGetIPv4PsudoChkSum(pIpHdr,(TEST_PAYLOAD_LEN+TEST_PKT_UDP_HDR_LEN));
#else
Pktlib_getDataBuffer(tip,&pData,&len);
if(house_pkts_gened &0x1)
/* post it to netcp tx channel*/
meta.u.tx_meta=&meta_tx;
#ifdef DEBUG_DESC
- if (house_pkts_gened<16) dump_descr((long *) tip, house_pkts_gened);
- else if (house_pkts_gened>99) dump_descr((long *) tip,house_pkts_gened);
+ if (house_pkts_gened<16) netTest_utilDumpDescr((long *) tip, house_pkts_gened);
+ else if (house_pkts_gened>99) netTest_utilDumpDescr((long *) tip,house_pkts_gened);
#endif
if(!first)
sum_vv3 += (vv3-vv2)-(long) (cache_op_b2-cache_op_b1); //sub out cache op cost
- // netapi_Log("pktio send. full=%d metadata=%d pktio_send=%d\n", vv3-vv1, vv2-vv1, vv3-vv2);
+ // netapi_Log("pktio send. full=%d metadata=%d netapi_pktioSend=%d\n", vv3-vv1, vv2-vv1, vv3-vv2);
stats[coreid].itx +=1;
house_pkts_gened +=1;
}
#endif
}
-void create_interfaces(void)
+void netTest_utilCreateInterfaces(uint8_t num_macs, uint8_t num_ips)
{
int err, i;
- for (i = 0; i < netTestCfg.num_macs; i++)
+ for (i = 0; i < num_macs; i++)
{
/* add mac intefaces */
mac[i] = netapi_netcpCfgCreateMacInterface(
//exit(1);
}
else
- netapi_Log("create_interfaces, added mac sucess\n");
+ netapi_Log("netTest_utilCreateInterfaces, added mac sucess\n");
}
- for (i = 0; i < netTestCfg.num_ips; i++)
+ for (i = 0; i < num_ips; i++)
{
//attach an IP to this interface
ip_rule[i]=netapi_netcpCfgAddIp(
netapi_handle,
netTestCfg.attach_iface[i],
nwal_IPV4,
- (nwalIpAddr_t *)&netTestCfg.ip[i].ipv4[0],
+ (nwalIpAddr_t*)&netTestCfg.ip[i].ipv4[0],
NULL, //all IP
(NETCP_CFG_ROUTE_HANDLE_T) NULL,
(void*)NULL,
&err
);
if (err) {
- netapi_Log("addip %d failed %d\n", i, err);
+ netapi_Log("netTest_utilCreateInterfaces: add dsp mac %d failed %d\n", i, err);
//exit(1);
}
else
- netapi_Log("create_interfaces, added ip sucess\n");
+ netapi_Log("netTest_utilCreateInterfaces, added ip sucess\n");
}
}
-void delete_interfaces(void)
+void netTest_utilDeleteInterfaces(uint8_t num_macs, uint8_t num_ips)
{
int err,i;
//delete IPs and MAC Interfacess
- for (i = 0; i < netTestCfg.num_ips; i++)
+ for (i = 0; i < num_ips; i++)
{
err = 0;
netapi_netcpCfgDelIp(netapi_handle, netTestCfg.attach_iface[i], nwal_IPV4,
NULL, NULL, ip_rule[i], &err);
}
- for (i = 0; i < netTestCfg.num_macs; i++)
+ for (i = 0; i < num_macs; i++)
{
err = 0;
netapi_netcpCfgDelMac(netapi_handle,i,&err);
index 78536fd3dace58777e818115d7d985fe5822fdf9..a0b6e89f17004158c4c419bf4584397f6a1949c9 100755 (executable)
#define __NET_TEST_UTIL_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-
+//#include "trie.h"
#include "net_test.h"
#define MAX_SEC_INDEX 64
#define MAX_LINE_LENGTH 512
#define MAX_ROUTES 16
-/* The input strings requird for parsing certain configuration
+#define BE(x) ( (((x)&0xff000000)>>24) | (((x)&0xff0000)>>8) | (((x)&0xff00)<<8) | (((x)&0xff)<<24) )
+
+/* The input strings requirEd for parsing certain configuration
* paremeters from the config file */
-#define INIT_CONFIG_IPSEC_MODE_RX "ipsec_mode_rx"
-#define INIT_CONFIG_IPSEC_MODE_TX "ipsec_mode_tx"
-#define INIT_CONFIG_IPSEC_IF_NO "ipsec_if"
-#define INIT_CONFIG_NUM_FP_CORES "fast_path_core"
-#define INIT_CONFIG_NUM_FP_THREADS "slow_path_core"
-#define CONFIG_STRING_LEN 128
+#define netTest_INIT_CONFIG_IPSEC_MODE_RX "ipsec_mode_rx"
+#define netTest_INIT_CONFIG_IPSEC_MODE_TX "ipsec_mode_tx"
+#define netTest_INIT_CONFIG_IPSEC_IF_NO "ipsec_if"
+#define netTest_INIT_CONFIG_DSP_MAC "dsp_mac"
+#define netTest_INIT_CONFIG_DSP_IP "dsp_ip"
+#define netTest_INIT_CONFIG_STATIC_LOOPBACK_PORT "dest_udp_port_config"
+#define netTest_CONFIG_STRING_LEN 512
//IPSEC MODE(only choose one rx and one tx)
#define IPSEC_MODE_RX_INFLOW 1
#define IPSEC_MODE_RX_SIDEBAND 3
#define IPSEC_MODE_TX_SIDEBAND 4
-#define PKT_LEN 1400
+#define netTest_PKT_LEN 1400
#define NET_TEST_SP_THREAD_MASK 0xF0000000
#define NET_TEST_THREAD_NUM_MASK 0x000000FF
nwalIpAddr_t remote_ipsec_ip;
uint8_t ipsec_mode_rx;
uint8_t ipsec_mode_tx;
- uint8_t ipsec_if_no;
+ int ipsec_if_no;
+ int dest_udp_port_config;
uint8_t fp_proc_start[NET_TEST_MAX_FP_THREAD];
uint8_t fp_proc_end[NET_TEST_MAX_FP_THREAD];
uint32_t fp_thread_num[NET_TEST_MAX_FP_THREAD];
uint8_t auth_key[MAX_SEC_INDEX][36];
uint8_t encr_key[MAX_SEC_INDEX][36];
uint32_t tunnel_id[MAX_SEC_INDEX];
- NETAPI_SEC_SA_INFO_T sa_info[MAX_SEC_INDEX];
+ NETAPI_SEC_SA_INFO_T sa[MAX_SEC_INDEX];
uint8_t num_sa;
nwalSecKeyParams_t key_params[MAX_SEC_INDEX];
+ uint8_t dsp_mac;
+ uint8_t dsp_ip;
} netTestConfig_t;
typedef struct
{
- char dir[CONFIG_STRING_LEN];
- char spi[CONFIG_STRING_LEN];
- char proto[CONFIG_STRING_LEN];
- char saMode[CONFIG_STRING_LEN];
- char ipType[CONFIG_STRING_LEN];
- char src[CONFIG_STRING_LEN];
- char dst[CONFIG_STRING_LEN];
- char replayWindow[CONFIG_STRING_LEN];
- char authMode[CONFIG_STRING_LEN];
- char cipherMode[CONFIG_STRING_LEN];
- char esnLo[CONFIG_STRING_LEN];
- char esnHi[CONFIG_STRING_LEN];
- char encKeySize[CONFIG_STRING_LEN];
- char macKeySize[CONFIG_STRING_LEN];
- char auth_key[CONFIG_STRING_LEN];
- char encr_key[CONFIG_STRING_LEN];
- char tunnel_id[CONFIG_STRING_LEN];
+ char dir[netTest_CONFIG_STRING_LEN];
+ char spi[netTest_CONFIG_STRING_LEN];
+ char proto[netTest_CONFIG_STRING_LEN];
+ char saMode[netTest_CONFIG_STRING_LEN];
+ char ipType[netTest_CONFIG_STRING_LEN];
+ char src[netTest_CONFIG_STRING_LEN];
+ char dst[netTest_CONFIG_STRING_LEN];
+ char replayWindow[netTest_CONFIG_STRING_LEN];
+ char authMode[netTest_CONFIG_STRING_LEN];
+ char cipherMode[netTest_CONFIG_STRING_LEN];
+ char esnLo[netTest_CONFIG_STRING_LEN];
+ char esnHi[netTest_CONFIG_STRING_LEN];
+ char encKeySize[netTest_CONFIG_STRING_LEN];
+ char macKeySize[netTest_CONFIG_STRING_LEN];
+ char auth_key[netTest_CONFIG_STRING_LEN];
+ char encr_key[netTest_CONFIG_STRING_LEN];
+ char tunnel_id[netTest_CONFIG_STRING_LEN];
} netTestConfigSA_t;
typedef struct{
- char mac[NET_TEST_MAX_MAC][CONFIG_STRING_LEN];
- char switch_port[NET_TEST_MAX_MAC][CONFIG_STRING_LEN];
- char ip[NET_TEST_MAX_IP][CONFIG_STRING_LEN];
- char attach_iface [NET_TEST_MAX_MAC][CONFIG_STRING_LEN];
- char ipsec_mode_rx[CONFIG_STRING_LEN];
- char ipsec_mode_tx[CONFIG_STRING_LEN];
- char routes[MAX_ROUTES][CONFIG_STRING_LEN];
- char ports[MAX_ROUTES][CONFIG_STRING_LEN];
- char dst_ips[MAX_ROUTES][CONFIG_STRING_LEN];
- char paths[MAX_ROUTES][CONFIG_STRING_LEN];
- char ipsec_if_no[CONFIG_STRING_LEN];
- char fp_thread_num[NET_TEST_MAX_FP_THREAD][CONFIG_STRING_LEN];
- char sp_thread_num[NET_TEST_MAX_FP_THREAD][CONFIG_STRING_LEN];
- char sp[NET_TEST_MAX_FP_THREAD][CONFIG_STRING_LEN];
- char fp[NET_TEST_MAX_FP_THREAD][CONFIG_STRING_LEN];
- char tunnel_id[CONFIG_STRING_LEN];
- netTestConfigSA_t sa_config[MAX_SEC_INDEX];
-
+ char mac[NET_TEST_MAX_MAC][netTest_CONFIG_STRING_LEN];
+ char switch_port[NET_TEST_MAX_MAC][netTest_CONFIG_STRING_LEN];
+ char ip[NET_TEST_MAX_IP][netTest_CONFIG_STRING_LEN];
+ char attach_iface [NET_TEST_MAX_MAC][netTest_CONFIG_STRING_LEN];
+ char ipsec_mode_rx[netTest_CONFIG_STRING_LEN];
+ char ipsec_mode_tx[netTest_CONFIG_STRING_LEN];
+ char routes[MAX_ROUTES][netTest_CONFIG_STRING_LEN];
+ char ports[MAX_ROUTES][netTest_CONFIG_STRING_LEN];
+ char dst_ips[MAX_ROUTES][netTest_CONFIG_STRING_LEN];
+ char paths[MAX_ROUTES][netTest_CONFIG_STRING_LEN];
+ char ipsec_if_no[netTest_CONFIG_STRING_LEN];
+ char fp_thread_num[NET_TEST_MAX_FP_THREAD][netTest_CONFIG_STRING_LEN];
+ char sp_thread_num[NET_TEST_MAX_FP_THREAD][netTest_CONFIG_STRING_LEN];
+ char sp[NET_TEST_MAX_FP_THREAD][netTest_CONFIG_STRING_LEN];
+ char fp[NET_TEST_MAX_FP_THREAD][netTest_CONFIG_STRING_LEN];
+ char tunnel_id[netTest_CONFIG_STRING_LEN];
+ netTestConfigSA_t sa_config[MAX_SEC_INDEX][netTest_CONFIG_STRING_LEN];
+ char dsp_mac[netTest_CONFIG_STRING_LEN];
+ char dsp_ip[netTest_CONFIG_STRING_LEN];
+ char dest_udp_port_config[netTest_CONFIG_STRING_LEN];
} netTestConfigFile_t;
-struct LastPktInfo
+typedef struct {
+ int iface;
+ int ipcsum;
+ int l4csum;
+} LastPktInfo_t;
+
+
+//#define netTestSA_t netTestSA_t
+
+typedef struct our_route_t
{
-int iface;
-int ipcsum;
-int l4csum;
-} ;
-int check_header(HEAD_T * p_head, PKTIO_METADATA_T * p_meta);
-
-void mysig(int x);
-unsigned long peek(unsigned long * p);
-void dump_descr(unsigned long *p, int n);
-void dump_header(unsigned long *p, int n, int a, int r);
-void netapi_dump_buf(unsigned long * buf,uint32_t buf_length);
-long htonl(long x);
-unsigned char hex2dec(char *p_s);
-uint16_t test_utilOnesComplementAdd (uint16_t v1, uint16_t v2);
-uint16_t test_utilOnesCompChkSum (uint8_t *p, uint32_t nwords);
-uint16_t test_utilGetIpv4PsudoChkSum (uint8_t *data, uint16_t payloadLen);
-void print_ipsec_stats(Sa_IpsecStats_t *p_saIpsecStats, nwal_saAALG auth, nwal_saEALG cipher);
-void print_datamode_stats(Sa_DataModeStats_t *p_saDataModeStats, nwal_saAALG auth, nwal_saEALG cipher);
-void our_stats_cb_mt(NETAPI_T h, paSysStats_t* pPaStats);
-void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats);
-void parse_one_mac(char * p_mac_str, unsigned char *p_mac);
-void parse_one_key(char *p_key_str, unsigned char *p_key);
-void parse_one_ip(char * p_ip_addr_str, unsigned char * p_ip);
-void parse_mac_address(netTestConfigFile_t *pConfig);
-void parse_ip_address(netTestConfigFile_t *pConfig);
-void parse_fp(netTestConfigFile_t *pConfig);
-void parse_sp(netTestConfigFile_t *pConfig);
-void parse_ipsec_mode(netTestConfigFile_t *pConfig);
-void parse_auth_mode(char *auth_mode_str, nwal_saAALG *auth_mode);
-void parse_encr_mode(char *ency_mode_str, nwal_saEALG*encr_mode);
-void parse_proto(char *proto_str, nwal_IpSecProto *proto);
-void parse_mode(char *mode_str, nwal_saMode *mode);
-void parse_ipType(char *ip_type_str, nwal_IpType *ipType);
-void parse_spi(char *spi_str, uint32_t *spi);
-void parse_replayWindow(char *replay_window_str, uint32_t *replay_window);
-void parse_esn(char *esn_str, uint32_t *esn);
-void parse_key_size(char *key_size_str, uint16_t *key_size);
-void parse_tunnel_id(char * tunnel_id_str, uint32_t *tunnel_id);
-void parse_dir(char* dir_str, nwal_SaDir *dir);
-
-void parse_num_fp_cores(netTestConfigFile_t *pConfig);
-void parse_num_fp_threads(netTestConfigFile_t *pConfig);
-void parse_num_fp_threads(netTestConfigFile_t *pConfig);
-
-
-void parse_sa(netTestConfigFile_t *pConfig, int i);
-#ifdef EXPERIMENTAL
-void parse_routes(netTestConfigFile_t *pConfig);
+ int out_port;
+ unsigned char out_mac[14];
+ netTestSA_t * sec_ptr;
+} OUR_ROUTE_T;
+
+typedef struct {
+ 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_NUM_MAC];
+ long core_rx;
+ long n_stats_cb;
+ long ip;
+ long exceptionPktsFrag;
+ long exceptionPktsOther;
+} netTestStats_T;
+
+#if 1
+typedef struct
+{
+ long ip[5];
+ long udp[2];
+} netTestHead_T;
#endif
-void parse_config_file(FILE * fpr, netTestConfigFile_t *pConfig);
void house(NETAPI_SCHED_HANDLE_T *s);
+void netTest_utilCreateInterfaces(uint8_t num_macs, uint8_t num_ips);
+void netTest_utilDeleteInterfaces(uint8_t num_macs, uint8_t num_ips);
+
+int netTest_utilCheckHeader(netTestHead_T * p_head, PKTIO_METADATA_T * p_meta);
+void netTest_utilMySig(int x);
+unsigned long netTest_utilPeek(unsigned long * p);
+void netTest_utilDumpDescr(unsigned long *p, int n);
+void netTest_utilDumpHeader(unsigned long *p, int n, int a, int r);
+void netTest_utilDumpBuffer(unsigned long * buf,uint32_t buf_length);
+long netTest_utilHtonl(long x);
+unsigned char netTest_utilHex2Dec(char *p_s);
+uint16_t netTest_utilOnesComplementAdd (uint16_t v1, uint16_t v2);
+uint16_t netTest_utilOnesCompChkSum (uint8_t *p, uint32_t nwords);
+uint16_t netTest_utilGetIPv4PsudoChkSum (uint8_t *data, uint16_t payloadLen);
+void netTest_utilPrintIPSecStats(Sa_IpsecStats_t *p_saIpsecStats, nwal_saAALG auth, nwal_saEALG cipher);
+void netTest_utilPrintDataModeStats(Sa_DataModeStats_t *p_saDataModeStats, nwal_saAALG auth, nwal_saEALG cipher);
+void netTest_utilStatsCbMt(NETAPI_T h, paSysStats_t* pPaStats);
+void netTest_utilsStatsCb(NETAPI_T h, paSysStats_t* pPaStats);
+
+
+void netTest_utilParseOneMac(char * p_mac_str, unsigned char *p_mac);
+void netTest_utilParseOneKey(char *p_key_str, unsigned char *p_key);
+void netTest_utilParseOneIP(char * p_ip_addr_str, unsigned char * p_ip);
+void netTest_utilParseMac(netTestConfigFile_t *pConfig);
+void netTest_utilParseIP(netTestConfigFile_t *pConfig);
+void netTest_utilParseThreadParams(netTestConfigFile_t *pConfig);
+void netTest_utilParseIpsecMode(netTestConfigFile_t *pConfig);
+void netTest_utilParseAuthMode(char *auth_mode_str, nwal_saAALG *auth_mode);
+void netTest_utilParseEncryptMode(char *ency_mode_str, nwal_saEALG*encr_mode);
+void netTest_utilParseProto(char *proto_str, nwal_IpSecProto *proto);
+void netTest_utilParseSaMode(char *mode_str, nwal_saMode *mode);
+void netTest_utilParseIPType(char *ip_type_str, nwal_IpType *ipType);
+void netTest_utilParseSADir(char* dir_str, nwal_SaDir *dir);
+void netTest_utilParseSA(netTestConfigFile_t *pConfig);
+void netTest_utilParseRoutes(netTestConfigFile_t* pConfig, OUR_ROUTE_T* routes, Trie** our_router);
+void netTest_utilProcessConfigFile(FILE* fpr, netTestConfigFile_t* pConfig);
+
-void create_interfaces(void);
-void delete_interfaces(void);
-void slow_path_thread(uint32_t coreid);
-void fast_path_thread(uint32_t coreid);
#endif
index 3cfb0870d1e48a44eb6f56d52f92f3ddd91eccbe..fd433b4b11815cb52bcd76c8c6d2da6448da8a8f 100755 (executable)
#include "router.h"
-#if 0
-#define BE(x) ( (((x)&0xff000000)>>24) | (((x)&0xff0000)>>8) | (((x)&0xff00)<<8) | (((x)&0xff)<<24) )
-typedef struct iphead_t
-{
- unsigned long w1;
- unsigned long w2;
- unsigned long w3;
- unsigned long src;
- unsigned long dst;
-} IP_HEAD_T;
-
-#define ROUTE_SEC_T netTestSA_t
-
-typedef struct our_route_t
-{
- int out_port;
- unsigned char out_mac[14];
- ROUTE_SEC_T * sec_ptr;
-} OUR_ROUTE_T;
-
-#endif
Trie * route_init(void)
{
//route the packet
// lookup next hop in route trie
-int route_pkt(Trie *Pt, void * Ppkt, IP_HEAD_T *Phead, unsigned char * Pbuf, int * Plen, ROUTE_SEC_T **Prs, int *PoutPort)
+int route_pkt(Trie *Pt, void * Ppkt, IP_netTestHead_T *Phead, unsigned char * Pbuf, int * Plen, netTestSA_t **Prs, int *PoutPort)
{
OUR_ROUTE_T *Pr;
int ret;
return 1;
}
-int process_tunnel(Trie *Pt, void *Ppkt, IP_HEAD_T * Phead,
+int process_tunnel(Trie *Pt, void *Ppkt, IP_netTestHead_T * Phead,
unsigned char * Pbuf, int* Plen, OUR_ROUTE_T * Proute,
int * PoutPort)
{
int new_pl_len;
int pad_len;
//unsigned char IV[20];
-ROUTE_SEC_T * p_sec=Proute->sec_ptr;
+netTestSA_t * p_sec=Proute->sec_ptr;
unsigned char *pc;
int nb;
int i;
unsigned int ip[]={BE(0x0a000010),BE(0xa0000110),BE(0x0a000210),BE(0x0a000310)};
Trie *rt;
char tp[1500];
-IP_HEAD_T th={0x00,0x00,0x00,0x01020304,0x1002000a};
+IP_netTestHead_T th={0x00,0x00,0x00,0x01020304,0x1002000a};
main()
{
int i;
index d247ee68ec6b35f7e2543da5b6236a35248ab0b5..a18f19457cfe3f9c40ec6377249fac07e3f81f80 100755 (executable)
#include "net_test.h"
+typedef struct
+{
+ unsigned long w1;
+ unsigned long w2;
+ unsigned long w3;
+ unsigned long src;
+ unsigned long dst;
+} IP_netTestHead_T;
Trie * route_init(void);
void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route);
-int route_pkt(Trie *Pt, void * Ppkt, IP_HEAD_T *Phead, unsigned char * Pbuf, int * Plen, ROUTE_SEC_T **Prs, int *PoutPort);
-int process_tunnel(Trie *Pt, void *Ppkt, IP_HEAD_T * Phead,
+int route_pkt(Trie *Pt, void * Ppkt, IP_netTestHead_T *Phead, unsigned char * Pbuf, int * Plen, netTestSA_t **Prs, int *PoutPort);
+int process_tunnel(Trie *Pt, void *Ppkt, IP_netTestHead_T * Phead,
unsigned char * Pbuf, int* Plen, OUR_ROUTE_T * Proute,
int * PoutPort);
index 6833ab302187ee0724711950cc3b224be2c7cba5..364d1ef3c2b751fcae4080f9cee4185ddeffc1fd 100755 (executable)
#include <sys/types.h>
#include <sys/mman.h>
-//dump_descr
-void dump_descr(unsigned long *p, int n)
+//netTest_utilDumpDescr
+void netTest_utilDumpDescr(unsigned long *p, int n)
{
netapi_Log("--------dump of descriptor %d %x\n", n, (int) p);
netapi_Log("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
for(i=0;i<num2dump;i++)
{
long * tip= &((long *)virt_addr)[32*i];
- dump_descr(tip, i);
+ netTest_utilDumpDescr(tip, i);
}
if(munmap(map_base, MAP_SIZE) == -1) FATAL;
close(fd);