summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 894c56f)
raw | patch | inline | side by side (parent: 894c56f)
author | Tinku Mannan <tmannan@ti.com> | |
Thu, 14 Feb 2013 16:02:41 +0000 (11:02 -0500) | ||
committer | Tinku Mannan <tmannan@ti.com> | |
Thu, 14 Feb 2013 16:02:41 +0000 (11:02 -0500) |
1. Implemented fast path send functions in pktio which directly use low level nwal
fast send macros.
2. net_test and net_test router application updates to use pktio fast path send functions.
3. Resolved all compilation warnings for netapi library and net_test user space applications.
4. General cleanup.
fast send macros.
2. net_test and net_test router application updates to use pktio fast path send functions.
3. Resolved all compilation warnings for netapi library and net_test user space applications.
4. General cleanup.
25 files changed:
index 90f3cef9b6c2eb7a50ca7b6b4ab903f00b4faff6..d17b48aeaf0bb01f64dc88e9979496b777335455 100755 (executable)
pktio.c \
netapi_navig.c\
-CFLAGS+= $(DEBUG_FLAG) -I$(NETAPI_INC_DIR) -I. -I $(SRCDIR) -I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(TRANS_SDK_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(HPLIB_INC_DIR) -I$(QMSS_DEV_DIR) -I$(CPPI_DEV_DIR) -I$(NETAPI_NAVIG_INIT_SRC) -I$(SA_INSTALL_PATH) $(CSL_DEVICE) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD -pthread -D _GNU_SOURCE
+CFLAGS+= $(DEBUG_FLAG) -I$(NETAPI_INC_DIR) -I. -I $(SRCDIR) -I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(TRANS_SDK_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(HPLIB_INC_DIR) -I$(QMSS_DEV_DIR) -I$(CPPI_DEV_DIR) -I$(NETAPI_NAVIG_INIT_SRC) -I$(SA_INSTALL_PATH) $(CSL_DEVICE) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD -DNWAL_ENABLE_SA -pthread -D _GNU_SOURCE
INCS = -I$(strip $(subst ;, -I,$(subst $(space),\$(space),$(INCDIR))))
all: lib
index a7f835849d5f900126a96008266856955a9289fd..9f8fd8ae0542ddb5dbb23bd8c9075b3f1c6053a7 100755 (executable)
*
* REVISION HISTORY: rev 0.0.1
*
- * Copyright (c) Texas Instruments Incorporated 2010-2011
+ * Copyright (c) Texas Instruments Incorporated 2013
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
index 8b49f6a1f37db826181875fb4d2acc70a15f6fbf..fd18617e7b0d690c6e17a3dccfb2b6ec6fbd174e 100755 (executable)
-/******************************************************************************
- * FILE PURPOSE: Netapi scheduler module
- ******************************************************************************
+/**************************************************************************************
+ * FILE PURPOSE: Netapi scheduler module
+ ***************************************************************************************
* FILE NAME: netapi_sched.h
*
- * DESCRIPTION: Netapi sample event scheduler header file for user space transport library
+ * DESCRIPTION: Netapi sample scheduler header file for user space transport library
*
* REVISION HISTORY:
*
- * Copyright (c) Texas Instruments Incorporated 2010-2011
+ * Copyright (c) Texas Instruments Incorporated 2013
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-/* ============================================================= */
/**
* @file netapi_sched.h
#include "netapi.h"
/**
- * @brief This define the handle to the NETAPI scheduling context. Each transport application thread should have its own scheduler context.
+ * @brief This defines the handle to the NETAPI scheduling context.
+ * Each user space transport application thread/core should have its own
+ * scheduler context.
*/
struct NETAPI_SCHED_HANDLE_Tag;
/**
* @ingroup netapi_cb_functions
- * @brief NETAPI_SCHED_CB Callback function for scheduling context house keeping. This allows application to set a function to be periodically called by scheduler to perform house keeping chores. If NULL, then no callback will be invoked
+ * @brief NETAPI_SCHED_CB Callback function for scheduling context house keeping.
+ * This allows application to set a function to be periodically called by scheduler
+ * to perform house keeping operations. If NULL, then no callback will be invoked
*
- * @details The application provides a callback function that NETAPI scheduling context will call on a periodic/ low priority basis.
+ * @details The application provides a callback function that the NETAPI scheduling context
+ * will call on a periodic/ low priority basis.
* @param[in] h The handle to the NETAPI scheduling context
* @retval none
- * @pre @ref netapi_init
+ * @pre @ref netapi_init
*/
typedef void (*NETAPI_SCHED_CB)(struct NETAPI_SCHED_HANDLE_Tag *h);
-
/**
* @ingroup sched_structures
* @brief NETAPI scheduler configuration structure.
#define NETAPI_SCHED_DURATION 0x1
/**
- * @def NETAPI_SCHED_POWER
+ * @def NETAPI_SCHED_CBV
* @ingroup sched_constants
- * This defines the Power option of scheduler context being configured. FUTURE
+ * This defines that the housekeeping call back option of scheduler context has been configured.
*/
-#define NETAPI_SCHED_POWER 0x2
+#define NETAPI_SCHED_CBV 0x2
+/// @cond NOT_IMPLEMENTED
/**
- * @def NETAPI_SCHED_FINE
+ * @def NETAPI_SCHED_POWER
* @ingroup sched_constants
- * This defines the fine tune option of scheduler context being configured. FUTURE
+ * This defines the power option of scheduler context being configured.
*/
-#define NETAPI_SCHED_FINE 0x4
+#define NETAPI_SCHED_POWER 0x4
/**
- * @def NETAPI_SCHED_CBV
+ * @def NETAPI_SCHED_FINE
* @ingroup sched_constants
- * This defines that the housekeeping call back option of scheduler context has been configured.
+ * This defines the fine tune option of scheduler context being configured.
*/
-#define NETAPI_SCHED_CBV 0x8
-
+#define NETAPI_SCHED_FINE 0x8
+/// @endcond
/**
* @def NETAPI_SCHED_FOREVER
* @ingroup sched_constants
*/
#define NETAPI_SCHED_FOREVER 0L
-/**
- * Valid flag options of scheduler context being configured.
- * <br>
- * The following are flags used to configure the scheduler:
- * @ref NETAPI_SCHED_DURATION , @ref NETAPI_SCHED_POWER, @ref NETAPI_SCHED_FINE, @ref NETAPI_SCHED_FINE
- */
- int valid_flags;
-
-
-
-
- uint64_t duration; /**< Duration scheduler is configured to run, 0 == forever,
- * non-zero value is ticks for scheduler to run
- */
+ int valid_flags; /**< Flags used to configure the scheduler, @ref NETAPI_SCHED_DURATION,
+ @ref NETAPI_SCHED_CBV. */
+ uint64_t duration; /**< Duration scheduler is configured to run, 0 == forever,
+ non-zero value is ticks for scheduler to run */
+ NETAPI_SCHED_CB house_cb; /**< House keeping callback */
+ uint32_t interval; /**< How many poll loop intervals after which to call the house keeping
+ callback function*/
- NETAPI_SCHED_CB house_cb; /**< House keeping callback */
+ int power_control; /**< Currently NOT_IMPLEMENTED */
- uint32_t interval; /**< How many poll loop intervals after which to call the house keeping callback */
-
-/**
- * Power control option configuration for scheduler
- * <br>
- * The following are flags used to configure the power control option:
- * @ref NETAPI_SCHED_POWER_ALWAYS_OFF , @ref NETAPI_SCHED_POWER_ALWAYS_OFF
- */
- int power_control;
/**
* @def NETAPI_SCHED_POWER_ALWAYS_OFF
* @ingroup sched_constants
- * This define is used to configure scheduler power_control option to be always off FUTURE
+ * This define is used to configure scheduler power_control option to be always off.
*/
#define NETAPI_SCHED_POWER_ALWAYS_OFF 0
/**
* @def NETAPI_SCHED_POWER_ALWAYS_ON
* @ingroup sched_constants
- * This define is used to configure scheduler power_control option to be always on FUTURE
+ * This define is used to configure scheduler power_control option to be always on.
*/
-#define NETAPI_SCHED_POWER_ALWAYS_ON 100
+#define NETAPI_SCHED_POWER_ALWAYS_ON 1
- int idle_time; /**< idle time TBD */
- Bool yield; /**< option of thread/core to yield in scheduling loop in no pkts from to process */
- Bool pollCtrlQ; /**< option to poll the control queue in scheduling loop */
- Bool pollGarbageQ; /**< option to poll the garbage queue in scheduling loop */
+ int idle_time; /**< Currently NOT_IMPLEMENTED */
+ Bool yield; /**< Option to yield in scheduling loop if no packets received
+ from any NETAPI PKTIO channel associated with NETAPI instance.*/
+ Bool pollCtrlQ; /**< Option to poll the NETCP control queues associated with the NETAPI
+ intance in scheduling loop. */
+ Bool pollGarbageQ; /**< Option to poll the internal heaps and any application heaps that have
+ been registerd with NETAPI instance. in scheduling loop. */
} NETAPI_SCHED_CONFIG_T;
/**
{
unsigned long long num_pkts; /**< Number of packets processed in sheduler context */
unsigned long long busy_cycles; /**< Number of CPU cyles scheduler was busy processing packets */
- unsigned long long cache_cycles; /**< Number of CPU cyles scheduler was busy in cache operations */
+ unsigned long long cache_cycles; /**< Number of CPU cyles scheduler was busy in cache operations */
} NETAPI_SCHED_STATS_T;
-
/**
* @ingroup sched_structures
- * @brief NETAPI scheduler context handle.
+ * @brief NETAPI scheduler configuration structure.
*
- * @details This structure is returned from 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
{
-
/**
* @def NETAPI_SCHED_STATE_CLOSE
* @ingroup sched_constants
- * This define indicates the state of the scheduler to be CLOSE (idle) state
+ * This define indicates the state of the scheduler to be CLOSE state or idle
*/
-#define NETAPI_SCHED_STATE_CLOSE 0
+#define NETAPI_SCHED_STATE_CLOSE 0x0
/**
* @def NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS
/**
* @def NETAPI_SCHED_STATE_OPEN
* @ingroup sched_constants
- * This define indicates the state of the scheduler is OPEN (running)
+ * This define indicates the state of the scheduler is OPEN or running
*/
#define NETAPI_SCHED_STATE_OPEN 2
-/**
- * State of the scheduler
- * <br>
- * The following are valid states of the scheduler,
- * @ref NETAPI_SCHED_STATE_CLOSE , @ref NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS, @ref NETAPI_SCHED_STATE_OPEN
- */
- volatile int state; /**< 0= shutdown, 1= shutting down, 2=active */
- void * back; /**< Pointer back to NETAPI handle */
+ volatile int state; /**< @ref NETAPI_SCHED_STATE_CLOSE ,
+ @ref NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS ,
+ @ref NETAPI_SCHED_STATE_OPEN */
+ void * back; /**< Pointer back to NETAPI handle */
NETAPI_SCHED_CONFIG_T config; /**< NETAPI scheduler configuration */
uint64_t start; /**< Start time of NETAPI scheduler context */
- volatile int shutdown_reason; /**< FUTURE-not implemented */
+ volatile int shutdown_reason; /**< Currently NOT_IMPLEMENTED */
volatile uint64_t shutdown_time; /**< Time till scheduler context will be shutdown/closed */
NETAPI_SCHED_STATS_T stats; /**< Per scheduler satistics */
} NETAPI_SCHED_HANDLE_T;
-/// @cond FUTURE
-/* return codes for sched run, () currently not used*/
+/// @cond NOT_IMPLEMENTED
+/* return codes for sched run */
#define NETAPI_SCHED_RETURN_ERR 0 /**<unknown, err */
#define NETAPI_SCHED_RETURN_TO 1 /**<returned after timeout */
#define NETAPI_SCHED_RETURN_SHUTDOWN 2 /**<returned after shutdown */
/// @endcond
-
-
/**
* @ingroup sched_structures
* @brief NETAPI scheduler shutdown structure
*/
typedef struct NETAPI_SCHED_SHUTDOWN_Tag
{
-/**
- * Scheduler shutdown options
- * <br>
- * The following options of how to shutdown the scheduler
- * @ref NETAPI_SCHED_SHUTDOWN_NOW , @ref NETAPI_SCHED_SHUTDOWN_TO, @ref NETAPI_SCHED_SHUTDOWN_NEXT_IDLE
- */
- int shutdown_type; /**< shutdown type */
-
/**
* @def NETAPI_SCHED_SHUTDOWN_NOW
* @ingroup sched_constants
*/
#define NETAPI_SCHED_SHUTDOWN_NOW 0
+/// @cond NOT_IMPLEMENTED
/**
* @def NETAPI_SCHED_SHUTDOWN_TO
* @ingroup sched_constants
- * This define is used to shudown the scheduling context after a short while. FUTURE
+ * This define is used to shudown the scheduling context after a short while.
*/
#define NETAPI_SCHED_SHUTDOWN_TO 1
* This define is used to shudown the scheduling context during next idle period
*/
#define NETAPI_SCHED_SHUTDOWN_NEXT_IDLE 2
+/// @endcond
+ int shutdown_type; /**< @ref NETAPI_SCHED_SHUTDOWN_NOW*/
- int timeout; /**< Ticks from now to close the scheduling context */
+ int timeout; /**< Currently NOT_IMPLEMENTED */
} NETAPI_SCHED_SHUTDOWN_T;
/**
NETAPI_SCHED_CONFIG_T * p_config,
int *p_err);
-
+/// @cond NOT_IMPLEMENTED
/**
* @ingroup sched_functions
- * @brief netapi_schedControl: API to re-configure a scheduling context, FUTURE, not implemented
+ * @brief netapi_schedControl: 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
int netapi_schedControl(NETAPI_SCHED_HANDLE_T *s,
NETAPI_SCHED_CONFIG_T *p_config,
int *p_err);
-
+/// @endcond
/**
* @ingroup sched_functions
return (NETAPI_T)s->back;
}
-
-
-
/**
* @ingroup sched_functions
* @brief netapi_schedGetStats: API to get scheduling context statistics
index 00b598c1e4f36936a6bc94db990f693ffa3969c7..f2cdd1f7c5837b5fff3479581b6c938dd5017c3a 100755 (executable)
*
* REVISION HISTORY:
*
- * Copyright (c) Texas Instruments Incorporated 2010-2011
+ * Copyright (c) Texas Instruments Incorporated 2013
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
/**
* @file netapi_sec.h
- * @brief netapi security header file for user space transport library
+ * @brief netapi security header file for user space transport library
*/
#ifndef __NETAPI_SEC__H
* @param[in] route @ref NETCP_CFG_ROUTE_HANDLE_T
* @param[in] data_mode_handle Returned data mode handle for PKTIO (in the case of sideband SAs)
* @param[in] inflow_mode_handle Returned inflow mode handle for PKTIO (in the case of TX inflow SAs)
+ * @param[in] p_user_data user provided data which can be extracted XXXX
* @param[out] perr Pointer to error code.
- * @retval Application id associated with created SA @ref NETCP_CFG_SA_T. This ID is used when referencing this SA in subsequent APIs (eg. to delete it). Also in the case of Receive Inflow, packets will be tagged with this ID so that s/w will know that the packet has already been decrypted, authenticated and window-replay checked. (note: if a RX policy is matched also then the ID associated with the policy will be tagged instead).
+ * @retval Application id associated with created SA @ref NETCP_CFG_SA_T.
+ * This ID is used when referencing this SA in subsequent APIs (eg. to delete it).
+ * Also in the case of Receive Inflow, packets will be tagged with this ID so that s/w will know
+ * that the packet has already been decrypted, authenticated and window-replay checked.
+ * (note: if a RX policy is matched also then the ID associated with the policy will be tagged instead).
* @pre @ref netapi_init
*/
NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
NETCP_CFG_ROUTE_HANDLE_T route,
void ** data_mode_handle,
void ** inflow_mode_handle,
+ void * p_user_data,
int * perr);
-
/**
* @ingroup cfg_security_functions
* @brief netapi_secDelSA: API to delete an IPSEC SA.
*
* @details API to add a recieve 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] 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] ipType IPV4 or IPV6
* @param[in] src_ip_addr source IP for policy check
* @param[in] dst_ip_addr destination IP for policy check
index 979f8a0c17c1dcba1b8e083807e5e8fcd168f116..3a58e1e86ec25df3cfad287c5bd0b3c373df27f2 100755 (executable)
#ifndef __NETAPI_TUNE__H
#define __NETAPI_TUNE__H
-
/**
* @ingroup tune_parameters
* @def NETAPI_ENABLE_SECURITY
*/
#define TUNE_NETAPI_MAX_BURST_RCV 32
-
-
/**
* @ingroup tune_parameters
* @def TUNE_NETAPI_NUM_TIMER_CELLS
* This defines the number of hash bins in a timer group.
*/
-#define TUNE_NETAPI_NUM_TIMER_CELLS 128 //# of hash bins in a timer group
+#define TUNE_NETAPI_NUM_TIMER_CELLS 128
/**
* @ingroup tune_parameters
* @def TUNE_NETAPI_NUM_GLOBAL_TIMERS
* This defines the number of global timer blocks
*/
-#define TUNE_NETAPI_NUM_GLOBAL_TIMERS 4 //# global timer blocks
+#define TUNE_NETAPI_NUM_GLOBAL_TIMERS 4
/**
* @ingroup tune_parameters
* @def TUNE_NETAPI_MAX_HEAPS
- * This defines the maximum number of heaps
+ * This defines the maximum number of heaps one NETAPI instance can create
*/
-#define TUNE_NETAPI_MAX_HEAPS 4 //max # of heaps one instance can create
+#define TUNE_NETAPI_MAX_HEAPS 4
/**
* @ingroup tune_parameters
/**
* @ingroup tune_parameters
* @def TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW
- * This defines the maximum number of buffer pools in flow - A flow is used by hw when it needs a buffer for a receive packet. This define allows the maximum number of pools (free descriptor queues) to be defined for a flow, so that different sized packets can be allocated from different memory areas.
+ * This defines the maximum number of buffer pools in a flow - A flow is used by hardware
+ * when it needs a buffer for a receive packet. This define allows the maximum number
+ * of pools (free descriptor queues) to be defined for a flow, so that different sized packets
+ * can be allocated from different memory areas.
* @note This define should NOT be changed as HW assumes at most 4 now
*/
-#define TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW 4 //!!do not change!!
+#define TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW 4
/**
index 7ddb1f06f5d1577dc5b55a8c13951231706bb911..b86d42f534e6ec9dfebdd69de8764357c8bd3d34 100755 (executable)
*
* REVISION HISTORY:
*
- * Copyright (c) Texas Instruments Incorporated 2010-2011
+ * Copyright (c) Texas Instruments Incorporated 2013
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#ifndef __NETCP_CFG__H
#define __NETCP_CFG__H
-#include "netapi.h"
-#include "ti/drv/pa/pa.h"
-#include "ti/runtime/pktlib/pktlib.h"
+#include "netapi.h"
+//#include "netapi_loc.h"
/**
* @ingroup cfg_structures
/**
* @ingroup cfg_constants
- * @def NETCP_CFG_MATCH_EXCEPTION
- * This define is used for an APPID that indicates that a packet is of type exception. Actual exception id is in byte 0 of APPID.
+ * @def NETAPI_NETCP_CFG_MATCH_EXCEPTION
+ * This define is used for an APPID that indicates that a packet is of type exception.
+ Actual exception id is in byte 0 of APPID.
*/
#define NETAPI_NETCP_CFG_MATCH_EXCEPTION 0x08000000
int recv_offset,
int * err );
-
/**
* @ingroup cfg_functions
* @brief netcp_cfgDelFlow API to delete a flow
NETCP_CFG_IP_T ip_rule_id,
int *err);
-
-
/**
* @ingroup cfg_functions
* @brief netcp_cfgCreateMacInterface API to create a MAC interface
int exception_id ,
nwal_matchAction_t action,
NETCP_CFG_ROUTE_HANDLE_T p_route);
+
+
#endif
index fe0c64be894132758beb87471ef5b08738841577..8c9419679a64c1555566c77cba2937d6425fe0df 100755 (executable)
*
* REVISION HISTORY:
*
- * Copyright (c) Texas Instruments Incorporated 2010-2011
+ * Copyright (c) Texas Instruments Incorporated 2013
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-/* ============================================================= */
/**
* @file pktio.h
* @brief pktio module main header file for user space transport library
- * @details: pktio provides an abstraction to H/W queues that are used to transmit and receive packets, IPC messages, etc. Pktio channels can be created by user but there are also several canned channels available for NETCP transmit, receive, SA sideband crypto transmit and receive
+ * @details: pktio provides an abstraction to H/W queues that are used to transmit and receive packets,
+ * IPC messages, etc. Pktio channels can be created by user but there are also several canned
+ * channels available for NETCP transmit, receive, SA sideband crypto transmit and receive
*/
#include "ti/drv/nwal/nwal_util.h"
#include "netapi_err.h"
-/*--------------------defines-----------------------*/
-
-
-//#define PKTIO_GET_BENCHMARK
/**
* @def PKTIO_NOMEM
* @ingroup pktio_constants
- * This define is used to indicate out of memory to user space application
+ * This define is used to indicate out of memory error to the user space application
*/
#define PKTIO_NOMEM NETAPI_ERR_NOMEM
/**
* @def NETCP_TX
* @ingroup pktio_constants
- * This defines the pktio NETCP transmit channel name
+ * This defines the default PKTIO NETCP transmit channel name
*/
#define NETCP_TX "NETCP_TX"
/**
* @def NETCP_RX
* @ingroup pktio_constants
- * @brief This defines the default pktio NETCP receive channel name
+ * @brief This defines the default PKTIO NETCP receive channel name
*/
#define NETCP_RX "NETCP_RX"
/**
* @def NETCP_SB_RX
* @ingroup pktio_constants
- * @brief This defines the pktio NETCP-SA receive SIDEBAND channel name. This channel is used to receive the results from sideband crypto operations
+ * @brief This defines the PKTIO NETCP-SA receive SIDEBAND channel name.
+ This channel is used to receive the results from sideband crypto operations
*/
#define NETCP_SB_RX "NETCP_SB_RX"
/**
* @def NETCP_SB_TX
* @ingroup pktio_constants
- * @brief This defines the pktio NETCP-SA transmit SIDEBAND channel name. This channle is used to send packets to sideband crypto
+ * @brief This defines the PKTIO NETCP-SA transmit SIDEBAND channel name.
+ This channel is used to send packets for sideband crypto operations
*/
#define NETCP_SB_TX "NETCP_SB_TX"
* @ingroup pktio_constants
* This defines the maximum length of a pktio channel name
*/
-#define PKTIO_MAX_NAME 19
+#define PKTIO_MAX_NAME 19
/**
* @ingroup pktio_structures
*/
typedef struct PKTIO_METADATA_Tag
{
-/**
- * Flags for PKTIO Meta Data configuration
- * <br>
- * valid flag1 parameters are as follows:
- * @ref PKTIO_META_RX , @ref PKTIO_META_TX, @ref PKTIO_META_SB_RX, @ref PKTIO_META_SB_TX
- */
- int flags1;
+
+ int flags1; /**< Configuration flags for PKTIO channel, @ref PKTIO_META_RX,
+ @ref PKTIO_META_TX,
+ @ref PKTIO_META_SB_RX,
+ @ref PKTIO_META_SB_TX*/
/**
* @def PKTIO_META_RX
* @ingroup pktio_constants
- * This defines the pktio NETCP receive INFLOW channel
+ * This defines the PKTIO NETCP receive INFLOW channel
*/
#define PKTIO_META_RX 0x01
/**
* @def PKTIO_META_TX
* @ingroup pktio_constants
- * This defines the pktio NETCP transmit INFLOW channel
+ * This defines the PKTIO NETCP transmit INFLOW channel
*/
#define PKTIO_META_TX 0x02
/**
* @def PKTIO_META_SB_RX
* @ingroup pktio_constants
- * This defines the pktio NETCP SIDEBAND channel channel
+ * This defines the PKTIO NETCP SIDEBAND channel channel
*/
-#define PKTIO_META_SB_RX 0x4 /**< SB crypto rx */
+#define PKTIO_META_SB_RX 0x4
/**
* @def PKTIO_META_SB_TX
* @ingroup pktio_constants
- * This defines the pktio NETCP transmit SIDEBAND channel
+ * This defines the PKTIO NETCP transmit SIDEBAND channel
*/
-#define PKTIO_META_SB_TX 0x8 /** <SB crypto tx */
+#define PKTIO_META_SB_TX 0x8
/**
* @def PKTIO_META_APP_DEF
* @ingroup pktio_constants
- * This allows application to define custom packet types.
+ * This allows user space application to define custom packet types.
*/
#define PKTIO_META_APP_DEF 0x80000000
nwalDmTxPayloadInfo_t * tx_sb_meta; /**< NWAL Data Mode Payload information for packet to SA */
} u; /**< union NWAL Packet meta data information */
-/**
- * @brief valid for PKTIO_META_TX with IPSEC inflow or PKTIO_PKTIO_META_SB_TX MUST BE nwal_HANDLE_INVALID otherwise.
- * @details This is used when crypto is to be preformed on egress packet.
- */
- void * sa_handle;
+ 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;
-/* the callback function */
-struct PKTIO_HANDLE_tag;
-
/**
* @ingroup pktio_structures
- * @brief PKTIO polling control struct FUTURE-
+ * @brief PKTIO fast path configuration structure.
+ *
+ * @details This strucuture allows user space applications to specify the PKTIO packet send function.
*
- * @details PKTIO polling control struct FUTURE-
+ * @note This configuration is not expected at time of @ref pktio_open but can be updated via
+ * @ref pktio_control API.
*/
-typedef struct PKTIO_POLL_Tag
+typedef struct PKTIO_FAST_PATH_CONFIG_Tag
{
-/* future */
-} PKTIO_POLL_T;
+ 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 */
/**
- * @ingroup netapi_cb_functions
- * @brief PKTIO_CB Callback function to be issued on packet receive
- *
- * @details The application provides a callback function that gets invoked on packet receive
- * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
- * @param[in] p_recv Pointer to the packets received.
- * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
- * @param[in] n_pkts Number of packets received.
- * @param[in] ts Timestamp associted with received packets.
- * @retval none
- * @pre @ref pktio_open
+ * @def PKTIO_FP_NO_CRYPTO_PORT
+ * @ingroup pktio_constants
+ * Use this define to reconfigure the PKTIO channel send function to not use any PKTIO fast path
+ send functions.
*/
-typedef void (*PKTIO_CB)(struct PKTIO_HANDLE_tag * channel,
- Ti_Pkt* p_recv[],
- PKTIO_METADATA_T p_meta[],
- int n_pkts,
- uint64_t ts);
+#define PKTIO_FP_NONE 0
/**
- * @ingroup pktio_functions
- * @brief PKTIO_SEND PKTIO specific send function
- *
- * @details The application calls this PKTIO specific send function to transmit packet
- * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
- * @param[in] p_send Pointer to the packet to send
- * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
- * @param[out] p_err Pointer to error code.
- * @retval none
- * @pre @ref pktio_open
+ * @def PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT
+ * @ingroup pktio_constants
+ * Use this define to send packet with updates to ENET port, no crypto operation,
+ * no L4 checksum to be performed.
*/
-typedef int (*PKTIO_SEND)(struct PKTIO_HANDLE_tag * channel,
- Ti_Pkt* p_send,
- PKTIO_METADATA_T *p_meta,
- int * p_err);
+#define PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT 1
+/**
+ * @def PKTIO_FP_L4CKSUM_PORT
+ * @ingroup pktio_constants
+ * Use this define to send packet with updates to L4 checksum, ENET port, no crypto operation
+ * to be performed.
+ */
+#define PKTIO_FP_L4CKSUM_PORT 2
/**
- * @ingroup pktio_functions
- * @brief PKTIO_POLL PKTIO specific poll function
- *
- * @details The application calls this PKTIO specific POLL function
- * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
- * @param[in] p_poll_cfg Pointer to pktio poll configuration. @ref PKTIO_POLL_T
- * @param[out] p_err Pointer to error code.
- * @retval none
- * @pre @ref pktio_open
+ * @def PKTIO_FP_ESP_L4CKSUM_PORT
+ * @ingroup pktio_constants
+ * Use this define to send packet with Crypto ESP, UDP checksum, updates to ENET port
*/
-typedef int (*PKTIO_POLL)(struct PKTIO_HANDLE_tag * channel,
- PKTIO_POLL_T * p_poll_cfg,
- int * p_err);
+#define PKTIO_FP_ESP_L4CKSUM_PORT 3
/**
- * @brief This defines an unused packet io channel slot
+ * @def PKTIO_FP_AH_L4CKSUM_PORT
+ * @ingroup pktio_constants
+ * Use this define to send packet with Cypto AH, UDP checksum, updates to ENET port
*/
-#define PKTIO_NA 0
+#define PKTIO_FP_AH_L4CKSUM_PORT 4
+
+/**
+ * @def PKTIO_FP_ESP_PORT
+ * @ingroup pktio_constants
+ * TUse 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
+ */
+#define PKTIO_FP_AH_PORT 6
+
+ nwalTxPktInfo_t *txPktInfo; /** <The parameters in this structure are used to
+ provide additional details for the outgoing packet*/
+} PKTIO_FAST_PATH_CONFIG_T;
+
+
+
+struct PKTIO_HANDLE_tag;
/**
* @ingroup pktio_structures
* @brief PKTIO configuration information
/**
* @def PKTIO_GLOBAL
* @ingroup pktio_constants
- * This defines the pktio channel as type global. Type global means that this channel can be used by all worker threads/cores
+ * This defines the pktio channel as type global.
+ Type global means that this channel can be used by all worker threads/cores
*/
#define PKTIO_GLOBAL 0x1
/**
* @def PKTIO_LOCAL
* @ingroup pktio_constants
- * This defines the pktio channel as type local. Type local means that thi s channel can only be used by the the thread/core that created it; its name will not be visible to other threads/cores
+ * This defines the pktio channel as type local.
+ Type local means that thi s channel can only be used by the the thread/core that created it;
+ its name will not be visible to other threads/cores
*/
#define PKTIO_LOCAL 0x2
*/
#define PKTIO_SB 0x8
-
-
-/**
- * Additional flags for PKTIO channel configuration
- * <br>
- * The following are flags used to configure the pktio channel:
- * @ref PKTIO_LOCAL , @ref PKTIO_GLOBAL, @ref PKTIO_PKT, @ref PKTIO_SB
- */
-int flags2; /**< Flags for PKTIO channel configuration */
-
+ int flags2; /**< Flags for PKTIO channel configuration, @ref PKTIO_LOCAL , @ref PKTIO_GLOBAL,
+ @ref PKTIO_PKT, @ref PKTIO_SB*/
/**
* @def PKTIO_Q_ANY
*/
#define PKTIO_Q_ANY -1
-int qnum; /**< PKTIO channel queue number */
-
-
-int max_n; /**< Maximum number of packets read in 1 poll */
+ int qnum; /**< PKTIO channel queue number */
+ int max_n; /**< Maximum number of packets read in 1 poll */
+ PKTIO_FAST_PATH_CONFIG_T fast_path_cfg; /** < @ref PKTIO_FAST_PATH_CONFIG_T */
} PKTIO_CFG_T;
-struct NETAPI_tag;
-
-/* a pktio channel .. */
/**
* @ingroup pktio_structures
- * @brief Per PKTIO channel statistics
+ * @brief PKTIO polling control struct, currently NOT_IMPLEMENTED
*
- * @details Per PKTIO channel statistics
+ * @details PKTIO polling control struct, currently NOT_IMPLEMENTED
*/
-typedef struct PKTIO_CHAN_STATS_Tag
+typedef struct PKTIO_POLL_Tag
{
- /* for benchmarking .. need to be defined somewhere */
- unsigned int vv7p;
- unsigned int vv8p;
- unsigned int vv9p;
- unsigned int vv10p;
- unsigned int vv11p;
- unsigned int vv12p;
- unsigned int vv13p; //rcv path
- unsigned int vv14p;
- unsigned int vv15p;
-} PKTIO_CHAN_STATS_T;
+} PKTIO_POLL_T;
+
+/**
+ * @ingroup netapi_cb_functions
+ * @brief PKTIO_CB Callback function to be issued on packet receive
+ *
+ * @details The application provides a callback function that gets invoked on packet receive
+ * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] p_recv Pointer to the packets received.
+ * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
+ * @param[in] n_pkts Number of packets received.
+ * @param[in] ts Timestamp associted with received packets.
+ * @retval none
+ * @pre @ref pktio_open
+ */
+typedef void (*PKTIO_CB)(struct PKTIO_HANDLE_tag * channel,
+ Ti_Pkt* p_recv[],
+ PKTIO_METADATA_T p_meta[],
+ int n_pkts,
+ uint64_t ts);
+
+/**
+ * @ingroup pktio_functions
+ * @brief PKTIO_SEND PKTIO specific send function
+ *
+ * @details The application calls this PKTIO specific send function to transmit packet
+ * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] p_send Pointer to the packet to send
+ * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
+ * @param[out] p_err Pointer to error code.
+ * @retval none
+ * @pre @ref pktio_open
+ */
+typedef int (*PKTIO_SEND)(struct PKTIO_HANDLE_tag * channel,
+ Ti_Pkt* p_send,
+ PKTIO_METADATA_T *p_meta,
+ int * p_err);
+
+
+/**
+ * @ingroup pktio_functions
+ * @brief PKTIO_POLL PKTIO specific poll function
+ *
+ * @details The application calls this PKTIO specific POLL function
+ * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] p_poll_cfg @ref PKTIO_POLL_T, currently NOT_IMPLEMENTED
+ * @param[out] p_err Pointer to error code.
+ * @retval none
+ * @pre @ref pktio_open
+ */
+typedef int (*PKTIO_POLL)(struct PKTIO_HANDLE_tag * channel,
+ PKTIO_POLL_T * p_poll_cfg,
+ int * p_err);
+
+
+/**
+ * @brief This defines an unused packet io channel slot
+ */
+#define PKTIO_NA 0
+
+
+struct NETAPI_tag;
/**
* @ingroup pktio_structures
PKTIO_POLL _poll; /**<pktio type specific POLL function */
int poll_flags; /**< pktio flags to control polling options */
char name[PKTIO_MAX_NAME+1]; /**< Name of pktio channel */
-#ifdef PKTIO_GET_BENCHMARK
- PKTIO_CHAN_STATS_T stats; /**<Per PKTIO channel stats, @ref PKTIO_CHAN_STATS_T */
- /* for benchmarking .. need to be defined somewhere */
-#endif
+ nwalTxPSCmdInfo_t tx_psCmdInfo; /**<Command Label to be sent to NetCP for the packet flow */
} PKTIO_HANDLE_T;
*/
#define PKTIO_CLEAR 0x1
+// @cond NOT_IMPLEMENTED
/**
* @def PKTIO_DIVERT
* This define is used to divert to a dest pktio channel
*/
#define PKTIO_DIVERT 0x2
+/// @endcond
/**
* @def PKTIO_SET_POLL_FLAGS
* This define is used to set poll flags for a pktio channel
*/
#define PKTIO_SET_POLL_FLAGS 0x4 //control poll flags (netcp_rx only)
+/**
+ * @def PKTIO_UPDATE_FAST_PATH
+ * This define is used to update the command information template for
+ * INFLOW mode of operation of a ptktio channel (netcp_tx only)
+ */
+#define PKTIO_UPDATE_FAST_PATH 0x8
+
+/**<max # of pkts to read in one poll */
+/**
+ * @def PKTIO_UPDATE_MAX_PKTS_PER_POLL
+ * This define is used to update the maximum number of packets to read in 1 poll
+ * period for the pktio channel.
+ */
+#define PKTIO_UPDATE_MAX_PKTS_PER_POLL 0x10
int op; /**< Control operation (CLEAR, DIVERT, ..) */
PKTIO_HANDLE_T *dest; /**< Handle to PKTIO channel (for DIVERT) */
int poll_flags; /**< Flags to indicate polling options */
} PKTIO_CONTROL_T;
-
-
/**
* @ingroup pktio_functions
* @brief API creates a NETAPI PKTIO channel
index 2bee3237aca39f1613af2c96018981fa7eeb8c2e..4ea8975b4b2281a113ac7832a8bde375c9002b56 100755 (executable)
#include <unistd.h>
#include <string.h>
#include "netapi.h"
-#include "src/netapi_loc.h"
+//#include "src/netapi_loc.h"
/*------------internal prototypes---------------*/
#ifdef NETAPI_INCLUDE_SCHED
/* create space for scheduler */
p->p_sched = calloc(1,sizeof(NETAPI_SCHED_HANDLE_T));
+ if (!p->p_sched)
+ {
+ goto ERR_netapi_init;
+ }
#endif
-
- /* global stuff (if master) */
+ /* Global init for SYS_MATER */
if (master==NETAPI_SYS_MASTER)
{
if (p_cfg)
//this goes to shared memory eventually
p->global = (void *) &netapi_global;
- //dalmt: save master's handle back in global; else for slave retrieve p_master
+ //save master's handle back in global; else for slave retrieve p_master
if (master==NETAPI_SYS_MASTER)
{
netapi_global.p_master = p;
netcp_cfgExceptions(p, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
if (err<0)
{
- //todo: cleanup
- return NULL;
+ goto ERR_netapi_init;
}
/* create pktio channels for tx,rx */
}
/* Start the QMSS. */
if (netapi_start_qm() != 1)
{
- return -1;
+ goto ERR_netapi_init;
}
netapi_start_nwal(p_master->netcp_heap,
p_master->netcp_control_rx_heap,
else
{
printf("netapi_init: no master specified\n");
- return -1;
+ goto ERR_netapi_init;
}
return (NETAPI_T) p;
+
+ERR_netapi_init:
+ for(i=0;i<TUNE_NETAPI_MAX_PKTIO; i++)
+ {
+ if (p->pktios[i])
+ {
+ free(p->pktios[i]);
+ }
+ }
+#ifdef NETAPI_INCLUDE_SCHED
+ if (p->p_sched)
+ {
+ free(p->p_sched);
+ }
+#endif
+ return NULL;
}
/********************************************************************
/***********************************************************************
* FUNCTION PURPOSE: NETAPI internal function to poll the internal heaps
-* and any application created heaps that have been registered
-* with NETAPI instance.
+* and any application created heaps that have been registered
+* with NETAPI instance.
************************************************************************
-* DESCRIPTION: The poll function checks the garbage collection queue associated
-* with the heap and returnsdescriptors and buffers when appropriate
-* to the main free queue.
+* DESCRIPTION: The poll function checks the garbage collection queue
+ associated with the heap and returns descriptors and
+ buffers when appropriate to the main free queue.
***********************************************************************/
void netapi_pollHeapGarbage(NETAPI_T h)
{
{
char * descPtr;
int i;
- if (!queueNum) return;
+ if (!queueNum)
+ {
+ return;
+ }
for (i=0;;i+=1 )
{
/* Pop descriptor from source queue */
if ((descPtr = (char *)pktio_mQmssQueuePopRaw(queueNum)) == NULL)
{
- break;
+ break;
}
- else {/*printf("netapi qzap in play\n");*/}
}
- if(i) printf(">netapi: @recovery - %d descriptors cleaned from qn %d\n",i, queueNum);
+ if(i)
+ {
+ printf("netapi_zapQ: @recovery - %d descriptors cleaned from qn %d\n",i, queueNum);
+ }
}
//defensive: clean out stuff hanging around
static Qmss_QueueHnd tempQH[NQUEUES2CLEAR];
static void netapi_cleanup_at_start(void)
{
-int i;
-uint8_t isAllocated;
+ int i;
+ uint8_t isAllocated;
-for(i=0;i<NQUEUES2CLEAR;i++)
-{
- tempQH[i] = Qmss_queueOpen(Qmss_QueueType_GENERAL_PURPOSE_QUEUE,
+ for(i=0;i<NQUEUES2CLEAR;i++)
+ {
+ tempQH[i] = Qmss_queueOpen(Qmss_QueueType_GENERAL_PURPOSE_QUEUE,
QMSS_PARAM_NOT_SPECIFIED, &isAllocated);
- netapi_zapQ(tempQH[i]);
-}
+ netapi_zapQ(tempQH[i]);
+ }
-for(i=0;i<NQUEUES2CLEAR;i++)
-{
+ for(i=0;i<NQUEUES2CLEAR;i++)
+ {
Qmss_queueClose(tempQH[i]);
-}
-
+ }
}
/****************************************************************************
index 89384e77887df6a527be475c59fda73135d7464c..0864de76107be0842067d3cd8e476d34fca1d2f8 100755 (executable)
#ifndef __NETAPI_LOC__H
#define __NETAPI_LOC__H
-//#define NWAL_ENABLE_SA
//#include "ti/runtime/netapi/netapi.h"
//#include "ti/drv/nwal/nwal_util.h"
+
extern hplib_virtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
extern unsigned char *netapi_VM_SaContextVaddr;
/***********************************************
/* to hold a tunnel */
typedef struct NETCP_IPSEC_SA_Tag
{
- int in_use;
- int inbound; //true if inbound
+ int in_use;
+ int inbound; //true if inbound
- int sa_mode; //mode we are going to use
+ int sa_mode; //mode we are going to use
#define NETCP_IPSEC_SA_MODE_INFLOW 0
#define NETCP_IPSEC_SA_MODE_SIDEBAND 1
- void * sa_handle_inflow; //for inflow mode
- void * sa_handle_sideband; //for sideband mode
- int iface; //associated interface
- //nwalTxDmPSCmdInfo_t rx_dmPSCmdInfo;
- //nwalTxDmPSCmdInfo_t tx_dmPSCmdInfo;
+ void * sa_handle_inflow; //for inflow mode
+ void * sa_handle_sideband; //for sideband mode
+ int iface; //associated interface
+ nwalTxDmPSCmdInfo_t dmPSCmdInfo;
+ uint32_t swInfo0;
+ uint32_t swInfo1;
+ void* user_data;
} NETCP_IPSEC_SA_T;
/* to hold a netcp 'interface' */
/* to hold user defined flows */
typedef struct NETCP_REGISTERED_FLOWS_Tag
{
- int in_use; //1=> in use
- void * handle; //cppi handle to resource (internal)
+ int in_use; //1=> in use
+ void * handle; //cppi handle to resource (internal)
NETCP_CFG_FLOW_T flow;
} NETCP_REGISTERED_FLOWS_T;
typedef struct NETAPI_GLOBAL_tag
{
#define NETAPI_MAX_PKTIO (TUNE_NETAPI_MAX_PKTIO)
-PKTIO_ENTRY_T pktios[NETAPI_MAX_PKTIO];
-
-/* configuration */
-NETAPI_CFG_T cfg;
-
-/* global timers */
-
-/* nwal context */
-NETAPI_NWAL_GLOBAL_CONTEXT_T nwal_context;
-
-NETAPI_T p_master; //DALMT save p'masters handle
+ PKTIO_ENTRY_T pktios[NETAPI_MAX_PKTIO];
+ /* configuration */
+ NETAPI_CFG_T cfg;
+ /* nwal context */
+ NETAPI_NWAL_GLOBAL_CONTEXT_T nwal_context;
+ NETAPI_T p_master; // save p'masters handle
} NETAPI_GLOBAL_T;
-#if 1
/************************************
* this is a per thread structure.
* It contains stuff local to thread
void * cookie; /*set by calling thread */
} NETAPI_HANDLE_T;
-#endif
-
//internal initialization routines */
int netapi_init_qm(int max_descriptors);
int netapi_init_cppi(void);
void * temp1,
void * temp2,
void * handle_inflow,
- void * handle_sideband);
+ void * handle_sideband,
+ nwalTxDmPSCmdInfo_t *dmPSCmdInfo;);
void *netcp_cfgp_get_sa_handles( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
int sa_slot, void ** p_sideband);
void* netcp_cfgp_get_mac_handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no);
@@ -391,4 +386,10 @@ NetapiNwalTransInfo_t * netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwa
void netapip_FreeTransInfo(NetapiNwalTransInfo_t* pTransInfo);
void *netcp_cfgp_get_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
int policy_slot);
+nwalTxDmPSCmdInfo_t* netcp_cfg_get_sa_sb_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ NETCP_CFG_SA_T sa_app_id);
+int netcp_cfg_get_sa_inflow_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ NETCP_CFG_SA_T sa_app_id,
+ uint32_t *swInfo0,
+ uint32_t *swInfo1);
#endif
index db993fb676bfd924450257b6c60a676e8fe1f9da..63ae7fb30b2be69f217a1e554e5431d562d53687 100755 (executable)
#include "netapi_sched.h"
#define NO_TIMER //turn off timer related scheduling
-#define NO_GARBAGE //turn off garbage collection
/********************************************************************
********************************************************************
* DESCRIPTION: API to open a scheduling context
********************************************************************/
-NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T n, NETAPI_SCHED_CONFIG_T * p_config, int *p_err)
+NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T n,
+ NETAPI_SCHED_CONFIG_T * p_config,
+ int *p_err)
{
- *p_err=0;
- NETAPI_SCHED_HANDLE_T * ph = (NETAPI_SCHED_HANDLE_T *) netapi_get_scheduler(n);
- if(!ph) {*p_err= NETAPI_ERR_NOMEM; return NULL;}
- if(!p_config) {*p_err= NETAPI_ERR_BAD_INPUT; return NULL;}
- memcpy(&ph->config,p_config,sizeof(NETAPI_SCHED_CONFIG_T));
- ph->start = hplib_mUtilGetTimestamp();
- ph->back = (void *) n;
- if (ph->config.valid_flags & NETAPI_SCHED_DURATION)
- {
- if (ph->config.duration == NETAPI_SCHED_FOREVER)
- {
- ph->shutdown_time=(uint64_t) -1;
- }
- else
- {
- ph->shutdown_time = ph->start + ph->config.duration;
- }
- }
- else ph->shutdown_time = (uint64_t) -1;
- ph->state =NETAPI_SCHED_STATE_OPEN;
- return(ph);
-
+ *p_err=0;
+ NETAPI_SCHED_HANDLE_T * ph = (NETAPI_SCHED_HANDLE_T *) netapi_get_scheduler(n);
+ if(!ph) {*p_err= NETAPI_ERR_NOMEM; return NULL;}
+ if(!p_config) {*p_err= NETAPI_ERR_BAD_INPUT; return NULL;}
+ memcpy(&ph->config,p_config,sizeof(NETAPI_SCHED_CONFIG_T));
+ ph->start = hplib_mUtilGetTimestamp();
+ ph->back = (void *) n;
+ if (ph->config.valid_flags & NETAPI_SCHED_DURATION)
+ {
+ if (ph->config.duration == NETAPI_SCHED_FOREVER)
+ {
+ ph->shutdown_time=(uint64_t) -1;
+ }
+ else
+ {
+ ph->shutdown_time = ph->start + ph->config.duration;
+ }
+ }
+ else ph->shutdown_time = (uint64_t) -1;
+ ph->state =NETAPI_SCHED_STATE_OPEN;
+ return(ph);
}
/********************************************************************
@@ -106,10 +106,12 @@ NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T n, NETAPI_SCHED_CONFIG_T * p_c
* DESCRIPTION: API to re-configure a scheduling context, FUTURE,
* not implemented
********************************************************************/
-/* re-configure a scheduling context */
-int netapi_schedControl(NETAPI_SCHED_HANDLE_T *s, NETAPI_SCHED_CONFIG_T *p_config, int *p_err)
+
+int netapi_schedControl(NETAPI_SCHED_HANDLE_T *s,
+ NETAPI_SCHED_CONFIG_T *p_config,
+ int *p_err)
{
- /* not implemented */
+ /* NOT_IMPLEMENTED */
return 0;
}
s->stats.cache_cycles += (unsigned long long) cache_op_b2;
}
-#ifndef NO_GARBAGE
- //poll pktlib garbage collections for registered heaps..
- if (TRUE== s->config.pollGarbageQ)
+ //poll pktlib garbage collections for registered heaps
+ if (TRUE == s->config.pollGarbageQ)
{
netapi_pollHeapGarbage((NETAPI_T) s->back);
}
-#endif
//poll NETCP/PA control channels
- if (TRUE== s->config.pollGarbageQ)
+ if (TRUE == s->config.pollCtrlQ)
{
netapi_netcpPoll((NETAPI_T) s->back);
}
/* shutdown scheduler context */
int netapi_schedClose(NETAPI_SCHED_HANDLE_T * s, NETAPI_SCHED_SHUTDOWN_T * p_close, int * p_err)
{
- *p_err=0;
- s->state=NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS; //say we are closing
-
+ *p_err=0;
+ if (p_close->shutdown_type == NETAPI_SCHED_SHUTDOWN_NOW)
+ {
+ s->state=NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS; //say we are closing
+ }
return 1;
}
index 63b4ea78ae5d3ae85fbc010881d68e8ac760f740..c18492b877484349e8e4454832741635be9cce0b 100755 (executable)
*
* REVISION HISTORY: rev 0.0.1
*
- * Copyright (c) Texas Instruments Incorporated 2010-2011
+ * Copyright (c) Texas Instruments Incorporated 2013
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
NETCP_CFG_ROUTE_HANDLE_T route, //Optional route
void **p_data_mode_handle,
void **p_inflow_mode_handle,
+ void * p_user_data,
int * perr)
{
NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
int tunnelId;
nwalSaIpSecId_t saInfo;
int have_to_wait=1;
+ nwalTxDmPSCmdInfo_t dmPSCmdInfo;
+ nwalSaIpSecId_t nwalSaIpSecId;
+ uint32_t swInfo0;
+ uint32_t swInfo1;
+
nwalCreateSAParams_t createParam =
{
/* mac handle */
*p_inflow_mode_handle=pTransInfo->handle;
netapip_FreeTransInfo(pTransInfo);
+
+#if 1
+ if (sa_info->dir == NWAL_SA_DIR_OUTBOUND)
+ {
+ memset(&nwalSaIpSecId, 0, sizeof(nwalSaIpSecId_t));
+ nwalSaIpSecId.spi = sa_info->spi;
+ memcpy(&(nwalSaIpSecId.src), &sa_info->src,sizeof( nwalIpAddr_t));
+ memcpy(&(nwalSaIpSecId.dst), &sa_info->dst,sizeof( nwalIpAddr_t));
+ nwalSaIpSecId.proto = sa_info->proto;
+ if (nwal_getSecAssoc(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
+ &nwalSaIpSecId,
+ NWAL_SA_DIR_OUTBOUND,
+ p_inflow_mode_handle,
+ &swInfo0,
+ &swInfo1) == nwal_TRUE)
+ {
+ printf("netapisecAddSA swInfo0: 0x%x, swInfo1: 0x%x\n", swInfo0, swInfo1);
+ }
+ else
+ printf("netapisecAddSA: call to nwal_getSecAssoc returne error\n");
+ }
+#endif
}
//sideband mode
netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
return -1;
}
+
printf("netapi_secAddSA: Creating sideband mode SA for %d ( mac %d)\n", tunnelId, iface_no);
*p_data_mode_handle = dm_handle;
+ memset(&dmPSCmdInfo, 0, sizeof(nwalTxDmPSCmdInfo_t));
+ retValue = nwal_initDMPSCmdInfo(netapi_return_nwal_instance_handle(h),
+ *p_data_mode_handle,
+ &dmPSCmdInfo);
}
netcp_cfgp_insert_sa(&netapi_get_global()->nwal_context,
- tunnelId,
- (sa_info->dir == NWAL_SA_DIR_INBOUND) ? TRUE: FALSE,
+ tunnelId,
+ (sa_info->dir == NWAL_SA_DIR_INBOUND) ? TRUE: FALSE,
inflow_mode,
&saInfo, &createParam,
*p_inflow_mode_handle,
- *p_data_mode_handle);
+ *p_data_mode_handle,
+ &dmPSCmdInfo,
+ swInfo0,
+ swInfo1,
+ p_user_data);
return (appId);
}
@@ -542,7 +579,11 @@ static void netapi_secDelRxPolicy_internal(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T
handle_policy = netcp_cfgp_get_policy(&netapi_get_global()->nwal_context,policyId);
;
- if (!handle_policy) {*perr = NETAPI_ERR_BAD_INPUT; return ;}
+ if (!handle_policy)
+ {
+ *perr = NETAPI_ERR_BAD_INPUT;
+ goto ERR_netapi_secDelRxPolicy_internal;
+ }
*perr =0;
//get a transaction id
if (!pTransInfo)
{
*perr = NETAPI_ERR_BUSY;
- return -1;
+ goto ERR_netapi_secDelRxPolicy_internal;
}
pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA_POLICY;
pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
printf (">netapi sec - ERROR: netapi_secDelRxPolicy_internal returned Error Code %d\n",
retValue);
netapip_FreeTransInfo(pTransInfo);
- return ;
+ goto ERR_netapi_secDelRxPolicy_internal;
}
//wait here until its done since scheduler isn't running yet most likely..
// todo: make this handled by scheduler poll later ??
@@ -591,14 +632,19 @@ static void netapi_secDelRxPolicy_internal(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T
//zap the entry
if (!flags)
netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context, policyId);
- return -1;
+ goto ERR_netapi_secDelRxPolicy_internal;
}
}
printf (">netapi sec: policy %d (iface %d) deleted\n",policyId,(policy_app_id&0xff));
netapip_FreeTransInfo(pTransInfo);
//zap the entry
- if (!flags) netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context, policyId);
+ if (!flags)
+ {
+ netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context, policyId);
+ }
+ERR_netapi_secDelRxPolicy_internal:
+ return;
}
/********************************************************************
index 487f17daaf1af80c5fe358fdcc49171f6c6d0add..74e74893e55f08d67cd63212ed1a080ddbc4c24d 100755 (executable)
#include <unistd.h>
#include <string.h>
#include "netapi.h"
-#include "netcp_cfg.h"
+//#include "netcp_cfg.h"
#include "netapi_loc.h"
-
+#include "netcp_cfg.h"
/******************************************************************
********************Netapi internal*************************************
*******************************************************************/
return;
}
+
+/****************************************************************************
+ * FUNCTION PURPOSE: Internal function to retrieve SB command info template
+ **************************************************************************
+ * DESCRIPTION: Internal function to retrieve SB command info template
+ ***************************************************************************/
+nwalTxDmPSCmdInfo_t* netcp_cfg_get_sa_sb_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ NETCP_CFG_SA_T sa_app_id)
+{
+ int sa_slot = (sa_app_id >>8) &0xffff;
+ if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
+ {
+ return NULL;
+ }
+
+ return (&p->tunnel[sa_slot].dmPSCmdInfo);
+}
+
+/****************************************************************************
+ * FUNCTION PURPOSE: Internal function to retrieve Inflow mode
+ * software information required to transmit packet
+ **************************************************************************
+ * DESCRIPTION: Internal function to retrieve Inflow mode
+ * software information required to transmit packet
+ ***************************************************************************/
+int netcp_cfg_get_sa_inflow_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+ NETCP_CFG_SA_T sa_app_id,
+ uint32_t *swInfo0,
+ uint32_t *swInfo1)
+{
+ int sa_slot = (sa_app_id >>8) &0xffff;
+ if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
+ {
+ return 0;
+ }
+
+ *swInfo0 = p->tunnel[sa_slot].swInfo0;
+ *swInfo1 = p->tunnel[sa_slot].swInfo1;
+ return 1;
+
+}
+
/********************************************************************
* FUNCTION PURPOSE: Netapi internal function to insert an SA to the SA list
********************************************************************
void * temp1,
void * temp2,
void * handle_inflow,
- void * handle_sideband)
+ void * handle_sideband,
+ nwalTxDmPSCmdInfo_t *dmPSCmdInfo,
+ uint32_t swInfo0,
+ uint32_t swInfo1,
+ void* user_data)
{
- p->tunnel[sa_slot].in_use=1;
- p->tunnel[sa_slot].inbound = dir;
- p->tunnel[sa_slot].sa_mode = mode;
- p->tunnel[sa_slot].sa_handle_inflow = handle_inflow;
- p->tunnel[sa_slot].sa_handle_sideband = handle_sideband;
- return;
+ p->tunnel[sa_slot].in_use=1;
+ p->tunnel[sa_slot].inbound = dir;
+ p->tunnel[sa_slot].sa_mode = mode;
+ p->tunnel[sa_slot].sa_handle_inflow = handle_inflow;
+ p->tunnel[sa_slot].sa_handle_sideband = handle_sideband;
+ p->tunnel[sa_slot].swInfo0 = swInfo0;
+ p->tunnel[sa_slot].swInfo1 = swInfo1;
+ p->tunnel[sa_slot].user_data = user_data;
+ printf("netcp_cfgp_insert_sa: swInfo0 0x%x, swInfo1: 0x%x\n",p->tunnel[sa_slot].swInfo0, p->tunnel[sa_slot].swInfo1);
+
+ if (dmPSCmdInfo)
+ {
+ memcpy(&p->tunnel[sa_slot].dmPSCmdInfo, dmPSCmdInfo, sizeof(nwalTxDmPSCmdInfo_t));
+ }
+ return;
}
/********************************************************************
if(!L4_handle)
{
*err = NETAPI_ERR_BAD_INPUT;
- return ;
+ goto ERR_netcp_cfgDelClass;
}
L3_handle = netcp_cfgp_get_l3_handle( &netapi_get_global()->nwal_context, class_slot );
/* l3 handle might be NULL,, depending on type of classifier */
if (!pTransInfo)
{
*err = NETAPI_ERR_BUSY;
- return -1;
+ goto ERR_netcp_cfgDelClass;
}
pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_PORT;
pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
*err = NETAPI_ERR_NWAL_ERR0;
printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n", retValue);
netapip_FreeTransInfo(pTransInfo);
- return ; /* todo: what about the L3? */
+ goto ERR_netcp_cfgDelClass; /* todo: what about the L3? */
}
//wait here until its done since scheduler isn't running yet most likely..
// todo: make this handled by scheduler poll later ??
netapip_FreeTransInfo(pTransInfo);
*err = NETAPI_ERR_PA_FW;
printf (">netcp_cfgDelClass - ERROR returned by NETCP PA firmware %d\n", *err);
- return -1;
+ goto ERR_netcp_cfgDelClass;
}
printf (">netcp cfg: Classifer deleted\n");
pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
err, L3_handle, 0);
}
netapip_FreeTransInfo(pTransInfo);
- return ;
+
+ERR_netcp_cfgDelClass:
+ return;
}
/********************************************************************
ctrl.appRxPktQueue = NWAL_QUEUE_NOT_SPECIFIED;
}
- ctrl.appId =NETAPI_NETCP_CFG_MATCH_EXCEPTION | exception_id;
+ ctrl.appId = (void*)(NETAPI_NETCP_CFG_MATCH_EXCEPTION | exception_id);
ctrl.matchAction = action;
index 6dc7568e4ae7854dfcc9d4583e9f3fd2968e85f4..cc145c7f4513600253ba36791e48f0e4bc365be4 100755 (executable)
/*----------------------------------------------------*/
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for L4 checksum,ESP Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for L4 checksum,ESP Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************/
+static int pktio_send_L4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+{
+ PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+ nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+ Cppi_HostDesc* pPloadDesc;
+ uint32_t swInfo0, swInfo1;
+
+ NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+ netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1);
+
+ if (netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+ {
+ nwal_mCmdSetL4CkSumCrypPort(pkt,
+ &p->tx_psCmdInfo,
+ pTxPktInfo->l4OffBytes,
+ pTxPktInfo->ploadLen + pTxPktInfo->l4HdrLen,
+ pTxPktInfo->pseudoHdrChecksum,
+ pTxPktInfo->saOffBytes,
+ pTxPktInfo->saPayloadLen,
+ swInfo0,
+ swInfo1,
+ 0);
+
+ printf("pktio_send_L4CkSumCryptoPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1);
+ pPloadDesc = Pktlib_getDescFromPacket(pkt);
+ pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
+ Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+ pPloadDesc,
+ NWAL_DESC_SIZE);
+ }
+ return 1;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for ESP Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for ESP Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************/
+static int pktio_send_CryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+{
+ PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+ nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+ Cppi_HostDesc* pPloadDesc;
+ uint32_t swInfo0, swInfo1;
+
+ NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+ netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1);
+
+ if (netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+ {
+ nwal_mCmdSetCrypPort(pkt,
+ &p->tx_psCmdInfo,
+ pTxPktInfo->saOffBytes,
+ pTxPktInfo->saPayloadLen,
+ swInfo0,
+ swInfo1,
+ 0);
+ }
+ return 1;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for L4 checksum,AH Crypto and outgoing EMAC port
+ * to NetCP command.
+ *******************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for L4 checksum,AH Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************/
+static int pktio_send_L4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+{
+ PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+ nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+ Cppi_HostDesc* pPloadDesc;
+ uint32_t swInfo0, swInfo1;
+
+ NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+ if (netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+ {
+ nwal_mCmdSetL4CkSumAHCrypPort(pkt,
+ &p->tx_psCmdInfo,
+ pTxPktInfo->l4OffBytes,
+ pTxPktInfo->ploadLen + pTxPktInfo->l4HdrLen,
+ pTxPktInfo->pseudoHdrChecksum,
+ pTxPktInfo->saOffBytes,
+ pTxPktInfo->saPayloadLen,
+ swInfo0,
+ swInfo1,
+ pTxPktInfo->saAhIcvOffBytes,
+ pTxPktInfo->saAhMacSize,
+ pTxPktInfo->enetPort);
+
+ printf("pktio_send_L4CkSumAHCryptoPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1);
+ pPloadDesc = Pktlib_getDescFromPacket(pkt);
+ pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
+ Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+ pPloadDesc,
+ NWAL_DESC_SIZE);
+ }
+ return 1;
+}
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for AH Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for AH Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************/
+static int pktio_send_AHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+{
+ PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+ nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+ Cppi_HostDesc* pPloadDesc;
+ uint32_t swInfo0, swInfo1;
+
+ NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+ if (netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+ {
+ nwal_mCmdSetAHCrypPort(pkt,
+ &p->tx_psCmdInfo,
+ pTxPktInfo->saOffBytes,
+ pTxPktInfo->saPayloadLen,
+ swInfo0,
+ swInfo1,
+ pTxPktInfo->saAhIcvOffBytes,
+ pTxPktInfo->saAhMacSize,
+ pTxPktInfo->enetPort);
+
+ pPloadDesc = Pktlib_getDescFromPacket(pkt);
+ pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
+ Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+ pPloadDesc,
+ NWAL_DESC_SIZE);
+ }
+ return 1;
+}
+
+
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for L4 checksum and outgoing EMAC port
+ * to NetCP command.
+ *******************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for L4 checksum and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************/
+static int pktio_send_L4CkSumPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+{
+
+ PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+ nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+ Cppi_HostDesc* pPloadDesc;
+ printf("pktio_send_L4CkSumPort: non-ipsec packet sent with L4 chksum\n");
+ printf("pktio_send_L4CkSumPort, l4offbytes: %d, l4HdrLen: %d, enetPort %d\n",
+ pTxPktInfo->l4OffBytes,
+ pTxPktInfo->l4HdrLen,
+ pTxPktInfo->enetPort);
+ nwal_mCmdSetL4CkSumPort(pkt,
+ &p->tx_psCmdInfo,
+ pTxPktInfo->l4OffBytes,
+ pTxPktInfo->l4HdrLen + pTxPktInfo->ploadLen,
+ pTxPktInfo->pseudoHdrChecksum,
+ pTxPktInfo->enetPort);
+
+ pPloadDesc = Pktlib_getDescFromPacket(pkt);
+ pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
+ Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+ pPloadDesc,
+ NWAL_DESC_SIZE);
+}
+
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for outgoing EMAC port to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for outgoing EMAC port to NetCP command.
+ ********************************************************************/
+static int pktio_send_Port(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+{
+ PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+ nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+ Cppi_HostDesc* pPloadDesc;
+ nwal_mCmdSetPort(pkt,
+ &p->tx_psCmdInfo,
+ pTxPktInfo->enetPort);
+ pPloadDesc = Pktlib_getDescFromPacket(pkt);
+ pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
+ Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+ pPloadDesc,
+ NWAL_DESC_SIZE);
+ return 1;
+}
+
/********************************************************************
* FUNCTION PURPOSE: Send packet via IPC queue
********************************************************************
@@ -91,14 +309,7 @@ static int pktio_send_ipc(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METAD
{
PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
err=0;
-#ifdef PKTIO_GET_BENCHMARK
- p->stats.vv8p=hplib_mUtilGetPmuCCNT();
-#endif
Qmss_queuePushDesc (p->q, (void*)pkt);
-
-#ifdef PKTIO_GET_BENCHMARK
- p->stats.vv9p=hplib_mUtilGetPmuCCNT();
-#endif
return 1;
}
/********************************************************************
@@ -113,13 +324,7 @@ static int pktio_send_nwal(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_META
nwal_RetValue res;
*err=0;
pPktInfo->pPkt = pkt;
-#ifdef PKTIO_GET_BENCHMARK
- p->stats.vv11p=hplib_mUtilGetPmuCCNT();
-#endif
res=nwal_send(p->nwalInstanceHandle, m->sa_handle,pPktInfo);
-#ifdef PKTIO_GET_BENCHMARK
- p->stats.vv12p=hplib_mUtilGetPmuCCNT();
-#endif
if (res != nwal_OK)
{
*err = NETAPI_ERR_NWAL_TX_ERR -res;
@@ -135,17 +340,41 @@ static int pktio_send_nwal(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_META
********************************************************************/
static int pktio_send_sb(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
{
+ nwal_RetValue nwalRetVal;
+ nwalTxDmPSCmdInfo_t *dmPSCmdInfo;
+ nwalLocCxtInfo_t nwalLocCxt;
+ Cppi_HostDesc* pPloadDesc;
PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+ Qmss_QueueHnd rxQ;
nwalDmTxPayloadInfo_t *pPktInfoSB = m->u.tx_sb_meta;
- nwal_RetValue res;
- *err=0;
- pPktInfoSB->pPkt = pkt;
- res=nwal_sendDM(p->nwalInstanceHandle, m->sa_handle,pPktInfoSB);
- if (res != nwal_OK)
+
+ NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+ dmPSCmdInfo = netcp_cfg_get_sa_sb_info(&netapi_get_global()->nwal_context, tunnel_id);
+ if (dmPSCmdInfo)
{
- *err = NETAPI_ERR_NWAL_TX_ERR -res;
+ nwalRetVal = nwal_getDmRxQueue(pktio_mGetNwalInstance(p), &rxQ);
+ if(nwalRetVal == nwal_OK)
+ {
+ dmPSCmdInfo->rxSbSaQ = rxQ;
+ }
+ nwal_mCmdDMUpdate(pkt,
+ dmPSCmdInfo,
+ pPktInfoSB->appCtxId,
+ pPktInfoSB->encOffset,
+ pPktInfoSB->encSize,
+ pPktInfoSB->pEncIV,
+ pPktInfoSB->authOffset,
+ pPktInfoSB->authSize,
+ pPktInfoSB->pAuthIV,
+ pPktInfoSB->aadSize,
+ pPktInfoSB->pAad);
+ pPloadDesc = Pktlib_getDescFromPacket(pkt);
+ pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
+ Qmss_queuePushDescSizeRaw(dmPSCmdInfo->txQueue,
+ pPloadDesc,
+ NWAL_DESC_SIZE);
}
- return 1;
}
/********************************************************************
@@ -187,14 +416,9 @@ static int pktio_poll_ipc(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_cf
n= (p->max_n< PKTIO_MAX_RECV) ? p->max_n : PKTIO_MAX_RECV;
for(r=0;r<n;r++)
{
-#ifdef PKTIO_GET_BENCHMARK
- if (r==0) p->stats.vv7p=hplib_mUtilGetPmuCCNT();
-#endif
+
temp=(Ti_Pkt*)(Cppi_HostDesc*)QMSS_DESC_PTR(Qmss_queuePop(p->q));
-#ifdef PKTIO_GET_BENCHMARK
- if (r==0) p->stats.vv10p=hplib_mUtilGetPmuCCNT();
-#endif
if(!temp) break;
/* process meta data */
pkt_list[r]= temp;
@@ -219,9 +443,6 @@ static int pktio_poll_nwal(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_c
*err=0;
/* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
set. optimizaion maybe? */
-#ifdef PKTIO_GET_BENCHMARK
- p->stats.vv13p=hplib_mUtilGetPmuCCNT();
-#endif
r=nwal_pollPkt(p->nwalInstanceHandle,
p->poll_flags,
(uint32_t) p,
@@ -261,9 +482,6 @@ static int pktio_poll_nwal_adj(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_po
*err=0;
/* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
set. optimizaion maybe? */
-#ifdef PKTIO_GET_BENCHMARK
- p->stats.vv14p=hplib_mUtilGetPmuCCNT();
-#endif
r=nwal_pollPkt(p->nwalInstanceHandle,
nwal_POLL_APP_MANAGED_PKT_Q,
(uint32_t) p,
void pktio_control(PKTIO_HANDLE_T * p,
PKTIO_CB cb,
PKTIO_CFG_T * p_cfg,
- PKTIO_CONTROL_T * p_control,
+ PKTIO_CONTROL_T * p_control,
int *err)
{
+ nwal_RetValue nwalRetVal;
if (!p)
{
- *err=1;
+ *err= NETAPI_ERR_BAD_INPUT;
return;
}
if (cb)
case(PKTIO_CLEAR):
netapi_zapQ(p->q);
break;
+ case (PKTIO_UPDATE_FAST_PATH):
+ if (p_cfg)
+ {
+ nwalRetVal = nwal_initPSCmdInfo(p->nwalInstanceHandle,
+ p_cfg->fast_path_cfg.txPktInfo,
+ &p->tx_psCmdInfo);
+ if (nwalRetVal == nwal_OK)
+ {
+ switch (p_cfg->fast_path_cfg.fp_send_option)
+ {
+ case (PKTIO_FP_ESP_L4CKSUM_PORT):
+ p->_send = pktio_send_L4CkSumCryptPort;
+ break;
+ case (PKTIO_FP_AH_L4CKSUM_PORT):
+ p->_send = pktio_send_L4CkSumAHCryptPort;
+ break;
+ case (PKTIO_FP_ESP_PORT):
+ p->_send = pktio_send_CryptPort;
+ break;
+ case (PKTIO_FP_AH_PORT):
+ p->_send = pktio_send_AHCryptPort;
+ break;
+ case (PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT):
+ p->_send = pktio_send_Port;
+ break;
+ case (PKTIO_FP_L4CKSUM_PORT):
+ p->_send = pktio_send_L4CkSumPort;
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ *err = NETAPI_ERR_BAD_INPUT;
+ }
+ }
+ else
+ {
+ *err = NETAPI_ERR_BAD_INPUT;
+ }
+ break;
+ case (PKTIO_UPDATE_MAX_PKTS_PER_POLL):
+ if (p_cfg)
+ {
+ p->max_n = p_cfg->max_n;
+ }
+ else
+ {
+ *err = NETAPI_ERR_BAD_INPUT;
+ }
+ break;
case(PKTIO_DIVERT):
default:
printf(">pktio_control: pktio_control op %d not implemented\n",p_control->op);
break;
}
}
- //all we configure is max_n. Can't change type of queue, rx/tx, etc
- if (p_cfg)
- {
- p->max_n = p_cfg->max_n;
- }
- *err=0;
+
+ *err = NETAPI_ERR_OK;
return;
}
/********************************************************************
int r=0;
for(r=0;r<np;r++)
{
- p->_send((struct PKTIO_HANDLE_tag *)p, pkt, m, err);
+ p->_send((struct PKTIO_HANDLE_tag *)p, (Ti_Pkt *)pkt, (PKTIO_METADATA_T *)m, err);
}
return r;
}
Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
-#ifdef PKTIO_GET_BENCHMARK
- p->stats.vv15p=hplib_mUtilGetPmuCCNT();
-#endif
for(r=0;r<numPkts;r++)
{
pkt_list[r] = pPktInfo[r].pPkt;
index ea5cb25bf00cbdf1b64a8b5d81bd4a97e22673ac..ca5834c0214766e9d031bcbb27df8982d8fe4cd1 100755 (executable)
PKTIO_HANDLE_T *our_chan;
PKTIO_HANDLE_T *netcp_rx_chan;
PKTIO_HANDLE_T *netcp_rx_chan2;
-PKTIO_HANDLE_T *netcp_tx_chan;
+PKTIO_HANDLE_T *netcp_tx_chan_esp;
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};
}
/* open netcp default tx, rx queues */
- netcp_tx_chan= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
- if (!netcp_tx_chan)
+ netcp_tx_chan_esp= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_esp)
{
printf("pktio open TX failed err=%d\n",err);
exit(1);
}
#endif
//close pktio channels we opened
- printf("main: calling pktio_close for netcp_tx_chan\n");
- pktio_close(netcp_tx_chan ,&err);
+ printf("main: calling pktio_close for netcp_tx_chan_esp\n");
+ pktio_close(netcp_tx_chan_esp ,&err);
printf("main: calling pktio_close for netcp_rx_chan\n");
pktio_close(netcp_rx_chan ,&err);
printf("main: calling pktio_close for netcp_sb_tx_chan\n");
index f183e6c6ebf6fcd0231359d8cc5c8d3d165aee2d..f8eac95bf078819e80033544d43cc3b198377ba3 100755 (executable)
export NETAPI_INSTALL_PATH ?= $(TRANS_SDK_INSTALL_PATH)
TRIE_OBJS=$(ARMV7OBJDIR)/netapi/test/trie.o
-NT_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_util.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
+NT_OBJS= $(ARMV7OBJDIR)/netapi/test/net_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
#
-NT_ROUTER_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_router.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_util.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
+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
#
NTB_OBJS= $(ARMV7OBJDIR)/netapi/test/nt_bridge.o $(ARMV7OBJDIR)/netapi/test/stubs.o
CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar -r
-CFLAGS+= $(DEBUG_FLAG) -I../ -I. -I$(NETAPI_INC_DIR) -I$(NETAPI_INC_DIR)/src -I$(HPLIB_INC_DIR) -I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(HPLIB_INSTALL_PATH) -I$(TRANS_SDK_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(SA_INC_DIR) $(CSL_DEVICE) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD -D _GNU_SOURCE
+CFLAGS+= $(DEBUG_FLAG) -I../ -I. -I$(NETAPI_INC_DIR) -I$(NETAPI_INC_DIR)/src -I$(HPLIB_INC_DIR) -I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(HPLIB_INSTALL_PATH) -I$(TRANS_SDK_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(SA_INC_DIR) $(CSL_DEVICE) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DNWAL_ENABLE_SA -DMAKEFILE_BUILD -D _GNU_SOURCE
# Linker options
INTERNALLINKDEFS = --start-group -L$(ARMV7LIBDIR) -L$(PDK_ARMV7LIBDIR) $(NETAPI_LIB) $(PKTLIB_LIB) $(HP_LIB) $(QMSS_LIB) $(CPPI_LIB) $(NWAL_LIB) $(PA_LIB) $(SA_LIB) $(AES_LIB) $(SHA1_LIB) $(PKTUTL_LIB) -lrt --end-group -pthread
index fa2eb9ee67119f6bc72e26a2805084a0ec9dea48..f74b8915dafc4519a1d4a61a46e4c92ab8ee536a 100755 (executable)
PKTIO_HANDLE_T *our_chan;
PKTIO_HANDLE_T *netcp_rx_chan;
PKTIO_HANDLE_T *netcp_rx_chan2;
-PKTIO_HANDLE_T *netcp_tx_chan;
+PKTIO_HANDLE_T *netcp_tx_chan_esp;
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};
}
/* open netcp default tx, rx queues */
- netcp_tx_chan= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
- if (!netcp_tx_chan)
+ netcp_tx_chan_esp= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_esp)
{
printf("pktio open TX failed err=%d\n",err);
exit(1);
count = 0;
//close pktio channels we opened
- printf("main: calling pktio_close for netcp_tx_chan\n");
- pktio_close(netcp_tx_chan ,&err);
+ printf("main: calling pktio_close for netcp_tx_chan_esp\n");
+ pktio_close(netcp_tx_chan_esp ,&err);
printf("main: calling pktio_close for netcp_rx_chan\n");
pktio_close(netcp_rx_chan ,&err);
printf("main: calling pktio_close for netcp_sb_tx_chan\n");
index 199a655fa1def8c56a0b6833b2d206f3cc9644a6..46d5a656187bf43742ac9b12a34e001dcf2e3181 100755 (executable)
#include <ti/drv/sa/salld.h>
#include <ti/drv/pa/pa.h>
-#include "net_test_util.h"
+#include "net_test_utils.h"
#include "router.h"
extern int QUIT;
nwal_RetValue nwalRetVal;
Pktlib_HeapHandle ourHeap;
-Pktlib_HeapHandle specialSmall;
-Pktlib_HeapHandle specialLarge;
PKTIO_HANDLE_T *netcp_rx_chan;
-PKTIO_HANDLE_T *netcp_rx_chan2;
-PKTIO_HANDLE_T *netcp_tx_chan;
+PKTIO_HANDLE_T *netcp_tx_chan_no_crypto;
+PKTIO_HANDLE_T *netcp_tx_chan_esp;
+PKTIO_HANDLE_T *netcp_tx_chan_ah;
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_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_EXCEPTION_PKT_T expPkt_appid;
-static hplib_spinLock_T stats_lock;
-Trie * P_trie;
Trie *p_trie_sa_rx;
Trie *p_trie_sa_tx;
NETCP_CFG_IP_T ip_rule0;
NETCP_CFG_IP_T ip_rule1;
-PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
+
/* security objects. (for loopback mode) */
netTestSA_t sa_info[MAX_SEC_INDEX];
NETCP_CFG_IPSEC_POLICY_T rx_policy[MAX_SEC_INDEX];
-/*-----------test driver: gen an input pkt------- */
-//char buffer[sizeof(HEAD_T)+PKT_LEN];
-Ti_Pkt * get_pkt(int n, unsigned int *p_len, Pktlib_HeapHandle heap2use, int size, unsigned char * buf2cpy, int copy_size)
-{
- int ind;
- long long temp;
- Ti_Pkt * b;
- char * buffer;
- unsigned int len;
-
-
- b=Pktlib_allocPacket(heap2use,size);
- if (!b)
- {
- Debug_printf("net_test: get_pkt() heap empty!! %d pkts gen'd %d \n", n);
- return NULL;
- }
-
- //debug - way to validate descriptor
- {Ti_Pkt* k= Pktlib_getNextPacket(b);
- if(k != 0) {Debug_printf(" genpkt, nexpkt != NULL");}}
-
-
- //get pointer to buffer area of packet
- Pktlib_getDataBuffer(b,(uint8_t**)&buffer,&len);
- if (!buffer)
- {
- Debug_printf("net_test: get_pkt() heap returned empty buffer %d \n", n);
- return NULL;
- }
- //copy test packet into buffer
- {
- memcpy(&buffer[0], buf2cpy, copy_size);
- *p_len = copy_size;
-}
- return b;
-}
/*--------------------------------------------------------------
*----------utility to flip a packet and send
@@ -194,11 +156,9 @@ 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;
-#ifdef AH_SUPPORT
HEAD_T * p_head;
HEAD_T temp_head;
int pkt_type;
-#endif
#ifdef MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
memcpy(&p_pkt[14+12],&p_pkt[14+12+4],4);
memcpy(&p_pkt[14+12+4],&ip_temp,4);
-#ifdef AH_SUPPORT
p_head=&temp_head;
-#endif
- //outer checksum to 0
- if (!flag)
- {
- memset(&p_pkt[14+10],0,2);
- }
//inner ip &udp for ipsec
if (flag)
{
-#ifdef AH_SUPPORT
memcpy(p_head,&p_pkt[14],sizeof(HEAD_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");
}
else if ((p_head->ip[2]&0x0000ff00)==0x00003200)
{
Pktlib_freePacket(tip);
return;
}
-#endif
p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa_rx, (char *)p_spi ,4);
if (p_sa_info == NULL)
}
else
{
- memset(&p_pkt[14+20+6],0,2);//0 udp checksum (we will compute on way out
+ 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);
}
PKTIO_METADATA_T meta = {PKTIO_META_SB_TX,{0},0};
int err;
nwalDmTxPayloadInfo_t meta_tx={0};
- meta.sa_handle=p_sa_info_tx->tx_data_mode_handle; //use TX SA context
+
+ meta.sa_handle = (void*)p_sa_info_tx->tx_tunnel; //use TX SA APPID
+
memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
meta_tx.appCtxId = (nwal_AppId)p_sa_info_tx;
meta_tx.encSize = len - p_sa_info->tx_payload_info.encOffset -p_sa_info->auth_tag_size;
/* post it to netcp sb tx channel*/
meta.u.tx_sb_meta=&meta_tx;
-#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
- /* Use the command label which was cached during create time
- * Update the Queue to receive output packet from SA to the local
- * core Queue. Below information can be saved by application in
- * per process context to avoid API overhead per packet
- * Application can use below rxSbSaQ for polling packets back from
- * SA
- */
- nwalRetVal =
- nwal_getLocCxtInfo(pktio_mGetNwalInstance(netcp_sb_tx_chan),
- &nwalLocCxt);
- if(nwalRetVal == nwal_OK)
- {
- p_sa_info_tx->tx_dmPSCmdInfo.rxSbSaQ = nwalLocCxt.rxSbSaQ;
- }
- nwal_mCmdDMUpdate(tip,
- &p_sa_info_tx->tx_dmPSCmdInfo,
- meta_tx.appCtxId,
- meta_tx.encOffset,
- meta_tx.encSize,
- meta_tx.pEncIV,
- meta_tx.authOffset,
- meta_tx.authSize,
- meta_tx.pAuthIV,
- meta_tx.aadSize,
- meta_tx.pAad);
- pPloadDesc = Pktlib_getDescFromPacket(tip);
- pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
- Qmss_queuePushDescSizeRaw(p_sa_info_tx->tx_dmPSCmdInfo.txQueue,
- pPloadDesc,
- NWAL_DESC_SIZE);
-
-#else
pktio_send(netcp_sb_tx_chan,tip,&meta,&err);
-#endif
}
else
{
PKTIO_METADATA_T meta = {PKTIO_META_TX,{0},0};
int err;
nwalTxPktInfo_t meta_tx={0};
- meta.sa_handle=p_sa_info_tx->tx_inflow_mode_handle; //this tells netapi that inflow crypto needs to be applied
- meta_tx.startOffset = p_sa_info->tx_pkt_info.startOffset;
- meta_tx.ipOffBytes =p_sa_info->tx_payload_info.encOffset;
- meta_tx.l4OffBytes = p_sa_info->tx_pkt_info.l4OffBytes;
- meta_tx.l4HdrLen = p_sa_info->tx_pkt_info.l4HdrLen;
+
+ meta.sa_handle = (void*)p_sa_info_tx->tx_tunnel; //use TX SA APPID
+
+ meta_tx.startOffset = p_sa_info_tx->tx_pkt_info.startOffset;
+ meta_tx.ipOffBytes =p_sa_info_tx->tx_payload_info.encOffset;
+ meta_tx.l4OffBytes = p_sa_info_tx->tx_pkt_info.l4OffBytes;
+ 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_pkt_info.saOffBytes;
+ meta_tx.saOffBytes= p_sa_info_tx->tx_pkt_info.saOffBytes;
if (pkt_type == 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_pkt_info.txFlag1;
+ meta_tx.txFlag1 = p_sa_info_tx->tx_pkt_info.txFlag1;
meta_tx.saPayloadLen=len-netTest_MAC_HEADER_LEN; //don't inlcude mac
meta_tx.saAhMacSize = 12;
meta_tx.saAhIcvOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE;
}
else if (pkt_type == IPSEC_ESP_PKT)
{
- meta_tx.txFlag1 = p_sa_info->tx_pkt_info.txFlag1;
+ 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.enetPort = 0;
memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN],&p_sa_info_tx->spi,4);
/* 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);
-#ifdef NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
+
if ( pkt_type == IPSEC_ESP_PKT)
- {
- nwal_mCmdSetL4CkSumCrypPort(tip,
- &p_sa_info_tx->tx_psCmdInfo,
- meta_tx.l4OffBytes,
- meta_tx.ploadLen + meta_tx.l4HdrLen,
- meta_tx.pseudoHdrChecksum,
- p_sa_info_tx->tx_pkt_info.saOffBytes,
- meta_tx.saPayloadLen,
- p_sa_info_tx->swInfo0,
- p_sa_info_tx->swInfo1,
- 0);
- }
- else
- {
- nwal_mCmdSetL4CkSumAHCrypPort(tip,
- &p_sa_info_tx->tx_psCmdInfo,
- meta_tx.l4OffBytes,
- meta_tx.ploadLen + meta_tx.l4HdrLen,
- meta_tx.pseudoHdrChecksum,
- meta_tx.saOffBytes,
- meta_tx.saPayloadLen,
- p_sa_info_tx->swInfo0,
- p_sa_info_tx->swInfo1,
- meta_tx.saAhIcvOffBytes,
- meta_tx.saAhMacSize,
- meta_tx.enetPort);
- }
- pPloadDesc = Pktlib_getDescFromPacket(tip);
- pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
- Qmss_queuePushDescSizeRaw(p_sa_info_tx->tx_psCmdInfo.txQueue,
- pPloadDesc,
- NWAL_DESC_SIZE);
-#else
- pktio_send(netcp_tx_chan,tip,&meta,&err);
-#endif
+ 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);
stats[coreid].tx +=1;
stats[coreid].sec_tx +=1;
}
int err;
nwalTxPktInfo_t meta_tx2={0};
meta2.sa_handle=nwal_HANDLE_INVALID;
- meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM|NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
+ meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
meta_tx2.startOffset = 0;
- meta_tx2.ipOffBytes = 14;
- meta_tx2.l4OffBytes = 14+20;
- meta_tx2.l4HdrLen = 8;
- meta_tx2.ploadLen = (unsigned) ((p_pkt[14+20+4]<<8)|p_pkt[14+20+4+1]) -8 ;
+ meta_tx2.ipOffBytes = netTest_MAC_HEADER_LEN;
+ meta_tx2.l4OffBytes = netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN;
+ meta_tx2.l4HdrLen = netTest_UDP_HEADER_LEN;
+ 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[14],8+ meta_tx2.ploadLen);
+ test_utilGetIpv4PsudoChkSum(&p_pkt[netTest_MAC_HEADER_LEN],8+ meta_tx2.ploadLen);
/* post it to netcp tx channel*/
meta2.u.tx_meta=&meta_tx2;
- pktio_send(netcp_tx_chan,tip,&meta2,&err);
+ printf("flip_and_send_pkt: non-ipsec packet received\n");
+ pktio_send(netcp_tx_chan_no_crypto,tip,&meta2,&err);
stats[coreid].tx +=1;
}
}
/* post it to netcp tx channel*/
meta2.u.tx_meta=&meta_tx;
- pktio_send(netcp_tx_chan,tip,&meta2,&err);
+ pktio_send(netcp_tx_chan_esp,tip,&meta2,&err);
hplib_cacheWbInv(p_pkt,len);
stats[coreid].tx +=1;
}
#ifdef DEBUG_DESC
if (stats[coreid].rx<16)
{
- Debug_printf(">rx dmp..");
+ printf(">rx dmp..");
dump_descr((long *) tip, stats[coreid].rx);
}
else if (stats[coreid].rx>99)
{
- Debug_printf(">rx dmp..");
+ printf(">rx dmp..");
dump_descr((long *) tip,stats[coreid].rx);
}
#endif
//12 byte auth tag
PKTIO_METADATA_T meta2 = {PKTIO_META_SB_TX,{0},0};
nwalDmTxPayloadInfo_t meta_tx={0};
- meta2.sa_handle=p_sa_info->rx_data_mode_handle;
+
+ meta2.sa_handle = (void*) p_sa_info->rx_tunnel;
memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
/* post it to netcp sb tx channel*/
meta2.u.tx_sb_meta=&meta_tx;
-/* TODO: Move the following ifdef code into ptkio_sendDM */
-#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
- /* Use the command label which was cached during create time
- * Update the Queue to receive output packet from SA to the local
- * core Queue. Below information can be saved by application in
- * per process context to avoid API overhead per packet
- * Application can use below rxSbSaQ for polling packets back from
- * SA
- */
- nwalRetVal =
- nwal_getLocCxtInfo(pktio_mGetNwalInstance(netcp_sb_tx_chan),
- &nwalLocCxt);
- if(nwalRetVal == nwal_OK)
- {
- p_sa_info->rx_dmPSCmdInfo.rxSbSaQ = nwalLocCxt.rxSbSaQ;
- }
- nwal_mCmdDMUpdate(tip,
- &p_sa_info->rx_dmPSCmdInfo,
- meta_tx.appCtxId,
- meta_tx.encOffset,
- meta_tx.encSize,
- meta_tx.pEncIV,
- meta_tx.authOffset,
- meta_tx.authSize,
- meta_tx.pAuthIV,
- meta_tx.aadSize,
- meta_tx.pAad);
- pPloadDesc = Pktlib_getDescFromPacket(tip);
- pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
- Qmss_queuePushDescSizeRaw(p_sa_info->rx_dmPSCmdInfo.txQueue,
- pPloadDesc,
- NWAL_DESC_SIZE);
-
-#else
pktio_send(netcp_sb_tx_chan,tip,&meta2,&err);
-#endif
continue;
}
else
}
}
+/* Templates to build command labels at startup up time, required by open_pktio_tx_channels() */
+nwalTxPktInfo_t txPktInfoESP =
+{
+ NULL, /* p_pkt */
+ NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
+ 0, /* lpbackPass */
+ 0, /* enetport */
+ 0, /* msuSize */
+ 0, /* startOffset */
+ netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
+ 0, /* saPayLoadLen */
+ 0 , /* saAhIcvOffBytes */
+ 0, /* saAhMacSize */
+ 0, /* etherLenOffBytes */
+ 0, /* ipOffBytes */
+ 0, /* l4OffBytes */
+ netTest_UDP_HEADER_LEN, /* l4HdrLen */
+ 0, /* pseudoHdrChecksum */
+ 0 /* pLoadLen */
+};
+
+
+nwalTxPktInfo_t txPktInfoAH =
+{
+ NULL, /* p_pkt */
+ NWAL_TX_FLAG1_DO_IPSEC_AH_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM | NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
+ 0, /* lpbackPass */
+ 0, /* enetport */
+ 0, /* msuSize */
+ 0, /* startOffset */
+ netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
+ 0, /* saPayLoadLen */
+ netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE, /* saAhIcvOffBytes */
+ 12, /* saAhMacSize */
+ 0, /* etherLenOffBytes */
+ 0, /* ipOffBytes */
+ 0, /* l4OffBytes */
+ netTest_UDP_HEADER_LEN, /* l4HdrLen */
+ 0, /* pseudoHdrChecksum */
+ 0 /* pLoadLen */
+};
+
+nwalTxPktInfo_t txPktInfoNoCrypto =
+{
+ NULL, /* p_pkt */
+ NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
+ 0, /* lpbackPass */
+ 0, /* enetport */
+ 0, /* msuSize */
+ 0, /* startOffset */
+ 0, /* saOffBytes */
+ 0, /* saPayLoadLen */
+ 0 , /* saAhIcvOffBytes */
+ 0, /* saAhMacSize */
+ 0, /* etherLenOffBytes */
+ 0, /* ipOffBytes */
+ netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN, /* l4OffBytes */
+ netTest_UDP_HEADER_LEN, /* l4HdrLen */
+ 0, /* pseudoHdrChecksum */
+ 0 /* pLoadLen */
+};
+
+
+void close_pktio_channels(void)
+{
+ int err;
+ pktio_close(netcp_tx_chan_esp ,&err);
+ pktio_close(netcp_tx_chan_ah ,&err);
+ pktio_close(netcp_sb_tx_chan ,&err);
+ pktio_close(netcp_tx_chan_no_crypto,&err);
+}
+
+void open_pktio_tx_channels(void)
+{
+ int err;
+ /* open netcp default TX for ESP packets */
+ netcp_tx_chan_esp= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_esp)
+ {
+ Debug_printf("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ else
+ {
+ if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+ {
+ PKTIO_CONTROL_T control;
+ control.op = PKTIO_UPDATE_FAST_PATH;
+ PKTIO_CFG_T cfg;
+ cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_L4CKSUM_PORT;
+ cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
+ pktio_control(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
+ }
+ }
+
+ /*/* open netcp default TX for AH packets */
+ netcp_tx_chan_ah= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_ah)
+ {
+ Debug_printf("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ else
+ {
+ if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+ {
+ PKTIO_CONTROL_T control;
+ control.op = PKTIO_UPDATE_FAST_PATH;
+ PKTIO_CFG_T cfg;
+ cfg.fast_path_cfg.fp_send_option = PKTIO_FP_AH_L4CKSUM_PORT;
+ cfg.fast_path_cfg.txPktInfo= &txPktInfoAH;
+ pktio_control(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
+ }
+ }
+
+ /* open netcp default TX channels for non-Crypto packets */
+ netcp_tx_chan_no_crypto= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_no_crypto)
+ {
+ Debug_printf("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ else
+ {
+ if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+ {
+ PKTIO_CONTROL_T control;
+ control.op = PKTIO_UPDATE_FAST_PATH;
+ PKTIO_CFG_T cfg;
+ cfg.fast_path_cfg.fp_send_option = PKTIO_FP_L4CKSUM_PORT;
+ cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
+ pktio_control(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
+ }
+ }
+
+ /* open netcp default TX channels for SB crypto */
+ netcp_sb_tx_chan= pktio_open(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
+ if (!netcp_sb_tx_chan)
+ {
+ Debug_printf("pktio open SB TX failed err=%d\n",err);
+ exit(1);
+ }
+}
+
#ifdef MULTI_THREAD
NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
int err, i;;
PKTIO_HANDLE_T *rx_chan;
- PKTIO_HANDLE_T *tx_chan;
- PKTIO_HANDLE_T *sb_tx_chan;
PKTIO_HANDLE_T *sb_rx_chan;
Debug_printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), thread_num);
#endif
worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
- NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
+ //NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
- /* open netcp default tx, rx queues */
- tx_chan = pktio_open(worker_nh[thread_num], NETCP_TX, NULL, &netcp_tx_cfg, &err);
-
+ /* open netcp default RX channels*/
rx_chan = pktio_open(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
- /* create a pktio channel for specially classified pkts */
- /* open netcp default tx, rx queues for sideband crypto */
- sb_tx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
-
sb_rx_chan = pktio_open(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);
Debug_printf("sched create failed for core%d\n",thread_num);
exit(1);
}
- scheduler[thread_num]->config.yield = FALSE;
+ scheduler[thread_num]->config.yield = TRUE;
scheduler[thread_num]->config.pollGarbageQ = TRUE;
scheduler[thread_num]->config.pollCtrlQ = TRUE;
- /*********************************************/
- /**************Entry point into scheduler ****/
- /*********************************************/
+
+ /* Entry point to scheduler */
netapi_schedRun(scheduler[thread_num], &err);
Debug_printf(">net_test: core %d worker thread done\n",thread_num);
- pktio_close(tx_chan, &err);
+ //pktio_close(tx_chan, &err);
pktio_close(rx_chan, &err);
- pktio_close(sb_tx_chan, &err);
- pktio_close(sb_tx_chan, &err);
+ pktio_close(sb_rx_chan, &err);
netapi_shutdown(worker_nh[thread_num]);
}
{
int err, i;
PKTIO_HANDLE_T *rx_chan;
- PKTIO_HANDLE_T *tx_chan;
- PKTIO_HANDLE_T *sb_tx_chan;
PKTIO_HANDLE_T *sb_rx_chan;
CPU_ZERO( &cpu_set);
#endif
worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
- NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
+ //NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
- /* open netcp default tx, rx queues */
- tx_chan = pktio_open(worker_nh[thread_num], NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ /* open netcp default RX channels*/
rx_chan = pktio_open(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
/* create a pktio channel for specially classified pkts */
/* open netcp default tx, rx queues for sideband crypto */
- sb_tx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
- sb_rx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
+ //sb_tx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
+ sb_rx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
exit(1);
}
- /*********************************************/
- /**************Entry point into scheduler ****/
- /*********************************************/
+
scheduler[thread_num]->config.yield = FALSE;
- scheduler[thread_num]->config.pollGarbageQ = FALSE;
- scheduler[thread_num]->config.pollCtrlQ = FALSE;
+ scheduler[thread_num]->config.pollGarbageQ = FALSE;
+ scheduler[thread_num]->config.pollCtrlQ = FALSE;
//sleep(100000);
- netapi_schedRun(scheduler[thread_num], &err);
+ /* Entry point to scheduler */
+ netapi_schedRun(scheduler[thread_num], &err);
printf(">net_test: core %d worker thread done\n",thread_num);
- pktio_close(tx_chan, &err);
+
pktio_close(rx_chan, &err);
- pktio_close(sb_tx_chan, &err);
- pktio_close(sb_tx_chan, &err);
+
+ pktio_close(sb_rx_chan, &err);
netapi_shutdown(worker_nh[thread_num]);
}
struct rlimit rl;
int32_t errCode;
Pktlib_HeapIfTable* pPktifTable;
-/* Local Per Process default resourcese maintained at NWAL */
+ /* Local Per Process default resourcese maintained at NWAL */
nwalLocCxtInfo_t nwalLocCxt;
//nwalSaIpSecId_t nwalSaIpSecId;
FILE * fpr = NULL;
/* create netapi */
netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
+ /* configure expection packet handling with netapi */
netcp_cfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
expPkt_appid = netcp_cfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
exit(1);
}
- /* create two secondary heaps */
- /* Initialize the heap configuration. */
- memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
-
- pPktifTable = netapi_getPktlibIfTable();
- /* Populate the heap configuration */
- heapCfg.name = "netapi-small";
- heapCfg.memRegion = NETAPI_GLOBAL_REGION;
- heapCfg.sharedHeap = 1;
- heapCfg.useStarvationQueue = 0;
- heapCfg.dataBufferSize = 512;
- heapCfg.numPkts = 64;
- heapCfg.numZeroBufferPackets= 0;
- heapCfg.heapInterfaceTable.data_malloc = pPktifTable->data_malloc;
- heapCfg.heapInterfaceTable.data_free = pPktifTable->data_free;
- heapCfg.dataBufferPktThreshold = 0;
- heapCfg.zeroBufferPktThreshold = 0;
-
- specialSmall = Pktlib_createHeap(&heapCfg, &errCode);
- heapCfg.name = "netapi-big";
- heapCfg.dataBufferSize = 1600;
- specialLarge = Pktlib_createHeap(&heapCfg, &errCode);
- //register these heaps so poll routine will include their garbage queues.
- netapi_registerHeap(netapi_handle, specialSmall);
- netapi_registerHeap(netapi_handle, specialLarge);
-
-
-
- /* open netcp default tx, rx queues */
- netcp_tx_chan= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
- if (!netcp_tx_chan)
- {
- Debug_printf("pktio open TX failed err=%d\n",err);
- exit(1);
- }
- netcp_rx_chan= pktio_open(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
- if (!netcp_rx_chan)
- {
- Debug_printf("pktio open RX failed err=%d\n",err);
- exit(1);
- }
+ open_pktio_tx_channels();
- /* create a pktio channel for specially classified pkts */
- netcp_rx_chan2= pktio_create(netapi_handle, "classq", (PKTIO_CB) recv_cb, &netcp_rx_cfg2, &err);
- if (!netcp_rx_chan2) {Debug_printf("pktio create RX2 failed err=%d\n",err); exit(1);}
- /* open netcp default tx, rx queues for sideband crypto */
- netcp_sb_tx_chan= pktio_open(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
- if (!netcp_sb_tx_chan)
- {
- Debug_printf("pktio open SB TX failed err=%d\n",err);
- exit(1);
- }
- netcp_sb_rx_chan= pktio_open(netapi_handle, NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
- if (!netcp_sb_rx_chan)
- {
- Debug_printf("pktio open SB RX failed err=%d\n",err);
- exit(1);
- }
Debug_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(&ip_rule0, &ip_rule1);
-
+
+ /* 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();
- if (!p_trie_sa_rx || !p_trie_sa_tx)
+ if (!p_trie_sa_rx || !p_trie_sa_tx)
{Debug_printf("trie alloc for SA failed\n"); exit(1);}
- /* Create RX SA's, RX Policy and TX SA's */
- create_sec_associations(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
+ /* 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();
#ifdef MULTI_THREAD
{
/* 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();
- //create_sec_associations(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
//this thread of execution (main) now just waits on user input
for(;;)
our_stats_cb(netapi_handle, NULL);
-
-
-/*************************************************
- ************CLEAN UP****************************
- ************************************************/
+ /* cleanup*/
delete_sec_associations();
delete_interfaces( &ip_rule0, &ip_rule1);
- //close pktio channels we opened
- pktio_close(netcp_tx_chan ,&err);
- pktio_close(netcp_rx_chan ,&err);
- pktio_close(netcp_sb_tx_chan ,&err);
- pktio_close(netcp_sb_rx_chan ,&err);
-
- //clear pktio channel we created
- pktio_control(netcp_rx_chan2, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
-
- //delete pktio channels we created
- pktio_delete(netcp_rx_chan2,&err);
+ /* close pktio channels we opened via open_pktio_tx_channels() */
+ close_pktio_channels();
+
netapi_shutdown(netapi_handle);
}
index 629638f8ed4a6c36cb1b5122529c16446a8f1db2..431e1e3cec5c3d075c0815f1d4ef388b6afd0dc4 100755 (executable)
#ifndef __NET_TEST_H__
#define __NET_TEST_H__
-#define NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
-#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
-#define NWAL_ENABLE_SA
-#endif
-#define AH_SUPPORT
-//#define NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
-#ifdef NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
-#define NWAL_ENABLE_SA
-#endif
+
//define this for multi-thread
#define MULTI_THREAD
unsigned int seq; //BE
int iv_len; //iv len (size of iv in pkt)
int bl; //block len (for padding calc)
-#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
+#if 1
/* Save NETCP CMD details during create time */
nwalTxDmPSCmdInfo_t rx_dmPSCmdInfo;
nwalTxDmPSCmdInfo_t tx_dmPSCmdInfo;
#endif
-#ifdef NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
+#if 1
nwalTxPSCmdInfo_t tx_psCmdInfo;
uint32_t swInfo0;
uint32_t swInfo1;
diff --git a/ti/runtime/netapi/test/net_test_config.txt b/ti/runtime/netapi/test/net_test_config.txt
index be71e7f93e9ad0e30b192be69677b5c6bd0206f4..862df61b2440e5bceb5b2afcb86ffde9a1d65408 100755 (executable)
local_ipsec_ip = 192.168.1.100
remote_ipsec_ip = 192.168.1.10
ipsec_if = 0
-ipsec_mode_rx = SIDEBAND
-ipsec_mode_tx = SIDEBAND
-#ipsec_mode_rx = INFLOW
-#ipsec_mode_tx = INFLOW
+#ipsec_mode_rx = SIDEBAND
+#ipsec_mode_tx = SIDEBAND
+ipsec_mode_rx = INFLOW
+ipsec_mode_tx = INFLOW
route0 = MAC00-23-24-08-67-46 0
route1 = MAC00-22-33-44-55-56 1
index b3031c458094bd05000e817aa5ad83071ce064dd..5422d0b0508023d7263232a664adf9e52cfec4d8 100755 (executable)
#include <ti/drv/sa/salld.h>
#include <ti/drv/pa/pa.h>
-#include "net_test_util.h"
+#include "net_test_utils.h"
extern int QUIT;
nwal_RetValue nwalRetVal;
Pktlib_HeapHandle ourHeap;
-Pktlib_HeapHandle specialSmall;
-Pktlib_HeapHandle specialLarge;
+PKTIO_HANDLE_T *netcp_tx_chan_no_crypto;
PKTIO_HANDLE_T *netcp_rx_chan;
-PKTIO_HANDLE_T *netcp_rx_chan2;
-PKTIO_HANDLE_T *netcp_tx_chan;
-PKTIO_HANDLE_T *netcp_sb_tx_chan;
-PKTIO_HANDLE_T *netcp_sb_rx_chan;
-PKTIO_CFG_T our_chan_cfg={PKTIO_RX_TX, PKTIO_LOCAL, PKTIO_Q_ANY, 8};
+PKTIO_HANDLE_T *netcp_tx_chan_esp;
+PKTIO_HANDLE_T *netcp_tx_chan_ah;
+
+
+
+
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_EXCEPTION_PKT_T expPkt_appid;
-static hplib_spinLock_T stats_lock;
-Trie * P_trie;
Trie *p_trie_sa_rx;
Trie *p_trie_sa_tx;
NETCP_CFG_IP_T ip_rule0;
NETCP_CFG_IP_T ip_rule1;
-PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
+
/* security objects. (for loopback mode) */
netTestSA_t sa_info[MAX_SEC_INDEX];
}
#ifdef MULTI_THREAD
+/* Templates to build command labels at startup up time, required by open_pktio_tx_channels() */
+nwalTxPktInfo_t txPktInfoESP =
+{
+ NULL, /* p_pkt */
+ NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
+ 0, /* lpbackPass */
+ 0, /* enetport */
+ 0, /* msuSize */
+ 0, /* startOffset */
+ netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
+ 0, /* saPayLoadLen */
+ 0 , /* saAhIcvOffBytes */
+ 0, /* saAhMacSize */
+ 0, /* etherLenOffBytes */
+ netTest_MAC_HEADER_LEN, /* ipOffBytes */
+ 0, /* l4OffBytes */
+ 0, /* l4HdrLen */
+ 0, /* pseudoHdrChecksum */
+ 0 /* pLoadLen */
+};
+
+
+nwalTxPktInfo_t txPktInfoAH =
+{
+ NULL, /* p_pkt */
+ NWAL_TX_FLAG1_DO_IPSEC_AH_CRYPTO| NWAL_TX_FLAG1_DO_IPV4_CHKSUM | NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
+ 0, /* lpbackPass */
+ 0, /* enetport */
+ 0, /* msuSize */
+ 0, /* startOffset */
+ netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
+ 0, /* saPayLoadLen */
+ netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE, /* saAhIcvOffBytes */
+ 12, /* saAhMacSize */
+ 0, /* etherLenOffBytes */
+ netTest_MAC_HEADER_LEN, /* ipOffBytes */
+ 0, /* l4OffBytes */
+ netTest_UDP_HEADER_LEN, /* l4HdrLen */
+ 0, /* pseudoHdrChecksum */
+ 0 /* pLoadLen */
+};
+
+nwalTxPktInfo_t txPktInfoNoCrypto =
+{
+ NULL, /* p_pkt */
+ NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
+ 0, /* lpbackPass */
+ 0, /* enetport */
+ 0, /* msuSize */
+ 0, /* startOffset */
+ 0, /* saOffBytes */
+ 0, /* saPayLoadLen */
+ 0 , /* saAhIcvOffBytes */
+ 0, /* saAhMacSize */
+ 0, /* etherLenOffBytes */
+ netTest_MAC_HEADER_LEN, /* ipOffBytes */
+ netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN, /* l4OffBytes */
+ netTest_UDP_HEADER_LEN, /* l4HdrLen */
+ 0, /* pseudoHdrChecksum */
+ 0 /* pLoadLen */
+};
+
+void close_pktio_channels(void)
+{
+ int err;
+ pktio_close(netcp_tx_chan_no_crypto ,&err);
+ pktio_close(netcp_tx_chan_esp ,&err);
+ pktio_close(netcp_tx_chan_ah ,&err);
+}
+
+
+
+void open_pktio_tx_channels()
+{
+ int err;
+ /* open netcp default TX channels */
+ netcp_tx_chan_no_crypto= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_no_crypto)
+ {
+ Debug_printf("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ else
+ {
+ if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+ {
+ PKTIO_CONTROL_T control;
+ control.op = PKTIO_UPDATE_FAST_PATH;
+ PKTIO_CFG_T cfg;
+ cfg.fast_path_cfg.fp_send_option = PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT;
+ cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
+ pktio_control(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
+ }
+ }
+ /* open netcp default TX for ESP packets */
+ netcp_tx_chan_esp= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_esp)
+ {
+ Debug_printf("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ else
+ {
+ if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+ {
+ PKTIO_CONTROL_T control;
+ control.op = PKTIO_UPDATE_FAST_PATH;
+ PKTIO_CFG_T cfg;
+ cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_PORT;
+ cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
+ pktio_control(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
+ }
+ }
+
+ /*/* open netcp default TX for AH packets */
+ netcp_tx_chan_ah= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_ah)
+ {
+ Debug_printf("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ else
+ {
+ if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+ {
+ PKTIO_CONTROL_T control;
+ control.op = PKTIO_UPDATE_FAST_PATH;
+ PKTIO_CFG_T cfg;
+ cfg.fast_path_cfg.fp_send_option = PKTIO_FP_AH_PORT;
+ cfg.fast_path_cfg.txPktInfo= &txPktInfoAH;
+ pktio_control(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
+ }
+ }
+}
+
+
+
+
NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
void slow_path_thread(int coreid)
{
int err;
PKTIO_HANDLE_T *rx_chan;
- PKTIO_HANDLE_T *tx_chan;
PKTIO_HANDLE_T *sb_tx_chan;
PKTIO_HANDLE_T *sb_rx_chan;
-
-
CPU_ZERO( &cpu_set);
#ifdef CORTEX_A15
NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
- /* open netcp default tx, rx queues */
- tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg, &err);
-
+ /* open netcp RX channel */
rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
netapi_schedRun(scheduler[coreid], &err);
Debug_printf(">net_test: core %d worker thread done\n",coreid);
- pktio_close(tx_chan, &err);
pktio_close(rx_chan, &err);
netapi_shutdown(worker_nh[coreid]);
}
+
void fast_path_thread(int coreid)
{
int err;
PKTIO_HANDLE_T *rx_chan;
- PKTIO_HANDLE_T *tx_chan;
PKTIO_HANDLE_T *sb_tx_chan;
- PKTIO_HANDLE_T *sb_rx_chan;
+ //PKTIO_HANDLE_T *sb_rx_chan;
#ifdef CORTEX_A15
CPU_SET( coreid, &cpu_set);
NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
- /* open netcp default tx, rx queues */
- tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg, &err);
-
-
+ /* open netcp RX channel */
rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
netapi_setCookie(worker_nh[coreid],(void*)coreid);
//sleep(100000);
netapi_schedRun(scheduler[coreid], &err);
Debug_printf(">net_test: core %d worker thread done\n",coreid);
- pktio_close(tx_chan, &err);
+
pktio_close(rx_chan, &err);
netapi_shutdown(worker_nh[coreid]);
\r}
/* create netapi */
netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
+ /* configure expection packet handling with netapi */
netcp_cfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
expPkt_appid = netcp_cfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
exit(1);
}
- /* create two secondary heaps */
- /* Initialize the heap configuration. */
- memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
-
- pPktifTable = netapi_getPktlibIfTable();
- /* Populate the heap configuration */
- heapCfg.name = "netapi-small";
- heapCfg.memRegion = NETAPI_GLOBAL_REGION;
- heapCfg.sharedHeap = 1;
- heapCfg.useStarvationQueue = 0;
- heapCfg.dataBufferSize = 512;
- heapCfg.numPkts = 64;
- heapCfg.numZeroBufferPackets= 0;
- heapCfg.heapInterfaceTable.data_malloc = pPktifTable->data_malloc;
- heapCfg.heapInterfaceTable.data_free = pPktifTable->data_free;
- heapCfg.dataBufferPktThreshold = 0;
- heapCfg.zeroBufferPktThreshold = 0;
-
- specialSmall = Pktlib_createHeap(&heapCfg, &errCode);
- heapCfg.name = "netapi-big";
- heapCfg.dataBufferSize = 1600;
- specialLarge = Pktlib_createHeap(&heapCfg, &errCode);
- //register these heaps so poll routine will include their garbage queues.
- netapi_registerHeap(netapi_handle, specialSmall);
- netapi_registerHeap(netapi_handle, specialLarge);
-
- /* open netcp default tx, rx queues */
- netcp_tx_chan= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
- if (!netcp_tx_chan)
- {
- Debug_printf("pktio open TX failed err=%d\n",err);
- exit(1);
- }
- netcp_rx_chan= pktio_open(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
- if (!netcp_rx_chan)
- {
- Debug_printf("pktio open RX failed err=%d\n",err);
- exit(1);
- }
+ /* Open all required PKTIO TX channels */
+ open_pktio_tx_channels();
Debug_printf("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
/* create scheduler instance */
/*create net_test MAC interfaces, attach IP to created MAC interfaces */
create_interfaces(&ip_rule0, &ip_rule1);
+ /* 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();
if (!p_trie_sa_rx || !p_trie_sa_tx)
{Debug_printf("trie alloc for SA failed\n"); exit(1);}
- /* Create RX SA's, RX Policy and TX SA's */
- create_sec_associations(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
+ /* 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();
#ifdef MULTI_THREAD
-/*************************************************
- ************CLEAN UP****************************
- ************************************************/
-
-
+ /* cleanup*/
delete_sec_associations();
delete_interfaces( &ip_rule0, &ip_rule1);
- //close pktio channels we opened
- pktio_close(netcp_tx_chan ,&err);
- pktio_close(netcp_rx_chan ,&err);
- netapi_shutdown(netapi_handle);
+ /* 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)
@@ -456,19 +541,25 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
Pktlib_setPacketLen(tip,len);
meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
meta_tx2.startOffset = 0;
- meta_tx2.ipOffBytes = 14;
+ meta_tx2.ipOffBytes = netTest_MAC_HEADER_LEN;
meta_tx2.ploadLen = len ;
meta_tx2.enetPort=out_port;
if(p_sec)
{
meta_tx2.txFlag1 |= NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO ;
- meta2.sa_handle=p_sec->tx_inflow_mode_handle; //this tells netapi that inflow crypto needs to be applied
- meta_tx2.saOffBytes=14+20;
- meta_tx2.saPayloadLen=len-14-20; //don't include tag, mac and outer header
+ meta2.sa_handle = (void*)p_sec->tx_tunnel;
+ 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);
stats[coreid].sec_tx+=1;
}
- meta2.u.tx_meta=&meta_tx2;
- pktio_send(netcp_tx_chan,tip,&meta2,&err);
+ else
+ {
+ meta2.u.tx_meta=&meta_tx2;
+ pktio_send(netcp_tx_chan_no_crypto,tip,&meta2,&err);
+
+ }
stats[coreid].tx +=1;
st2=hplib_mUtilGetPmuCCNT();
stats[coreid].send_cycles += (unsigned long long) (st2-st1);
PKTIO_METADATA_T meta[], int n_pkts,
uint64_t ts )
{
-}
\ No newline at end of file
+}
diff --git a/ti/runtime/netapi/test/net_test_sa_utils.c b/ti/runtime/netapi/test/net_test_sa_utils.c
index 63a0813f2baf3a99952ba29e9449a4f64f250e77..0edb65411cee6598f5f9521af321b2537d3575e6 100755 (executable)
*****************************************/
-#include "net_test_util.h"
+#include "net_test_utils.h"
#include <stdio.h>
#include <stdlib.h>
extern netTestSA_t sa_info[];
extern NETCP_CFG_IPSEC_POLICY_T rx_policy[];
-//extern NETAPI_SCHED_HANDLE_T * scheduler[];
-//extern Pktlib_HeapHandle ourHeap;
-//extern Pktlib_HeapHandle specialSmall;
-//extern Pktlib_HeapHandle specialLarge;
+/* pktio channels externs */
+extern PKTIO_HANDLE_T *netcp_rx_chan;
+extern PKTIO_HANDLE_T *netcp_rx_chan2;
+extern PKTIO_HANDLE_T *netcp_tx_chan;
+extern PKTIO_HANDLE_T *netcp_tx_chan_ah;
+extern PKTIO_HANDLE_T *netcp_sb_tx_chan;
+extern PKTIO_HANDLE_T *netcp_sb_rx_chan;
+extern PKTIO_CFG_T our_chan_cfg;
+extern PKTIO_CFG_T netcp_rx_cfg;
+extern PKTIO_CFG_T netcp_rx_cfg2;
+extern PKTIO_CFG_T netcp_tx_cfg;
+extern PKTIO_CFG_T netcp_sb_rx_cfg;
+extern PKTIO_CFG_T netcp_sb_tx_cfg;
+/* end pktio channels externs */
extern Trie *p_trie_sa_rx;
extern Trie *p_trie_sa_tx;
else
{
trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- printf("**************************build_sa_db: tunnel id %d\n", tmp_tunnel);
}
}
else
{
trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- printf("**************************build_sa_db: tunnel id %d\n", tmp_tunnel);
}
}
else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_HMAC_SHA2_256) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_3DES_CBC))
else
{
trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- printf("**************************build_sa_db: tunnel id %d\n", tmp_tunnel);
}
}
else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_HMAC_MD5) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_NULL))
else
{
trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- printf("**************************build_sa_db: tunnel id %d\n", tmp_tunnel);
}
}
else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_NULL) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_AES_GCM))
else
{
trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- printf("**************************build_sa_db: tunnel id %d\n", tmp_tunnel);
}
}
else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_NULL) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_AES_CCM))
else
{
trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- printf("**************************build_sa_db: tunnel id %d\n", tmp_tunnel);
}
}
else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_AES_XCBC) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_NULL))
else
{
trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- printf("**************************build_sa_db: tunnel id %d\n", tmp_tunnel);
}
}
else if ((netTestCfg.sa_info[i].authMode== NWAL_SA_AALG_GMAC) && (netTestCfg.sa_info[i].cipherMode == NWAL_SA_EALG_NULL))
else
{
trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
- printf("**************************build_sa_db: tunnel id %d\n", tmp_tunnel);
}
}
else
}
-int create_sec_associations(PKTIO_HANDLE_T* netcp_sb_rx_chan,
- PKTIO_HANDLE_T* netcp_sb_tx_chan,
- PKTIO_HANDLE_T *netcp_tx_chan)
+int create_sec_associations(void)
{
nwal_RetValue nwalRetVal;
int err,i;
nwalSaIpSecId_t nwalSaIpSecId;
+ uint32_t saId;
for (i=0; i < MAX_SEC_INDEX;i++)
{
err = 0;
if(netTestCfg.sa_info[i].dir == NWAL_SA_DIR_INBOUND)
{
build_sa_db(i);
+ saId = i;
sa_info[i].rx_tunnel = netapi_secAddSA(
netapi_handle,
netTestCfg.ipsec_if_no, //iface #0
NULL, //use default route
&(sa_info[i].rx_data_mode_handle),
&(sa_info[i].rx_inflow_mode_handle),
+ (void*) saId,
&err);
if (err) {printf("addRxSa failed %d\n",err); exit(1);}
printf("addSaPolicy failed %d, for index %d\n",err,i);
exit(1);
}
- else
- printf("addSA policy pass for %d\n", i);
}
else
{
rx_policy[i] = 0;
}
-
-#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
- /* Remember the NetCP Command Label so save cycles per Crypto
- * operation */
- if(netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND)
- {
- nwalRetVal =
- nwal_initDMPSCmdInfo(pktio_mGetNwalInstance(netcp_sb_rx_chan),
- sa_info[i].rx_data_mode_handle,
- &sa_info[i].rx_dmPSCmdInfo);
- }
-#endif
}
//tx SA security stuff
if(netTestCfg.sa_info[i].dir == NWAL_SA_DIR_OUTBOUND)
{
build_sa_db(i);
+ saId = i;
sa_info[i].tx_tunnel = netapi_secAddSA( netapi_handle,
0, //iface #0
&netTestCfg.sa_info[i],
NULL, //use default route
&(sa_info[i].tx_data_mode_handle),
&(sa_info[i].tx_inflow_mode_handle),
+ (void*)saId,
&err);
if (err) {printf("addTxSa failed %d\n",err); exit(1);}
-#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
- /* Remember the NetCP Command Label so save cycles per Crypto
- * operation */
- if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND)
- {
- nwalRetVal =
- nwal_initDMPSCmdInfo(pktio_mGetNwalInstance(netcp_sb_tx_chan),
- sa_info[i].tx_data_mode_handle,
- &sa_info[i].tx_dmPSCmdInfo);
- }
-#endif
-
-#ifdef NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
- if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
- {
- memset(&nwalSaIpSecId, 0, sizeof(nwalSaIpSecId_t));
- nwalSaIpSecId.spi = netTestCfg.sa_info[i].spi;
- memcpy(&(nwalSaIpSecId.src), &netTestCfg.sa_info[i].src,sizeof( nwalIpAddr_t));
- memcpy(&(nwalSaIpSecId.dst), &netTestCfg.sa_info[i].dst,sizeof( nwalIpAddr_t));
- nwalSaIpSecId.proto = netTestCfg.sa_info[i].proto;
-
- nwalRetVal = nwal_initPSCmdInfo(pktio_mGetNwalInstance(netcp_tx_chan),
- &sa_info[i].tx_pkt_info,
- &sa_info[i].tx_psCmdInfo);
-
- if (nwalRetVal == nwal_OK)
- {
- if (nwal_getSecAssoc(pktio_mGetNwalInstance(netcp_tx_chan),
- &nwalSaIpSecId,
- NWAL_SA_DIR_OUTBOUND,
- &(sa_info[i].tx_inflow_mode_handle),
- &sa_info[i].swInfo0,
- &sa_info[i].swInfo1) != nwal_TRUE)
- {
- printf("main: nwal_getSecAssoc failed\n");
- exit (1);
- }
- }
- else
- {
- printf("main: nwal_initPSCmdInfo failed\n");
- exit (1);
- }
- }
-#endif
}
}
}
diff --git a/ti/runtime/netapi/test/net_test_sa_utils.h b/ti/runtime/netapi/test/net_test_sa_utils.h
index d9e0afbe2a8700ee3d19cc541e02f54ed5eecc3d..ea78d83b77e8b80263d675fa8dfffebb09915f5c 100755 (executable)
#include "net_test.h"
void build_sa_db(int i);
-int create_sec_associations(PKTIO_HANDLE_T* netcp_sb_rx_chan,
- PKTIO_HANDLE_T* netcp_sb_tx_chan,
- PKTIO_HANDLE_T *netcp_tx_chan);
+int create_sec_associations(void);
void void delete_sec_associations(void);
diff --git a/ti/runtime/netapi/test/net_test_thread_utils.c b/ti/runtime/netapi/test/net_test_thread_utils.c
index 315c8c96784b1a9e8dc39c5b8a9a094107ebdb1c..3162c212583c2f7dff05b87a0f30e738c35240b3 100755 (executable)
*****************************************/
-#include "net_test_util.h"
+#include "net_test_utils.h"
#include <stdio.h>
#include <stdlib.h>
if (sp_threads == NULL)
{
perror( "malloc" );
- return -1;
+ exit(1);
}
Debug_printf( "Starting %d threads...\n", netTestCfg.num_sp_threads );
- if (pthread_create( &sp_threads[0], NULL, (void*)slow_path_thread,
- (void *) netTestCfg.sp_thread_num[i]))
+ for (i = 0; i < netTestCfg.num_sp_threads; i++)
{
- perror( "pthread_create" );
- exit(1);
+ if (pthread_create( &sp_threads[i], NULL, (void*)slow_path_thread,
+ (void *) netTestCfg.sp_thread_num[i]))
+ {
+ perror( "pthread_create" );
+ exit(1);
+ }
}
-
fp_threads = malloc( sizeof( pthread_t ) * netTestCfg.num_fp_threads);
if (fp_threads == NULL)
{
perror( "malloc" );
- return -1;
+ exit(1);
}
for (i = 0; i < netTestCfg.num_fp_threads; i++)
{
index bf1a2a37941b8eeff73ebd00dd4d02b1e9633387..fd26d19eb161eb01933d1937cffc608a17857df2 100755 (executable)
*****************************************/
-#include "net_test_util.h"
+#include "net_test_utils.h"
#include <stdio.h>
#include <stdlib.h>
extern netTestSA_t sa_info[];
extern NETAPI_SCHED_HANDLE_T * scheduler[];
extern Pktlib_HeapHandle ourHeap;
-extern Pktlib_HeapHandle specialSmall;
-extern Pktlib_HeapHandle specialLarge;
+//extern Pktlib_HeapHandle specialSmall;
+//extern Pktlib_HeapHandle specialLarge;
extern NETCP_CFG_IP_T ip_rule0;
extern NETCP_CFG_IP_T ip_rule1;
default:
{
/* Should never reach here */
- printf("netapi *: Internal Error in netapi_dump_buf().Row Count: %d \n",
- row_count);
+ printf("netapi *: Internal Error in netapi_dump_buf().Row Count: %d \n", row_count);
return;
}
}
pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-Pktlib_getHeapStats(specialSmall, &pktLibHeapStats);
-printf("specialSmall heap stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
- pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
- pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
- pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-
-
-Pktlib_getHeapStats(specialLarge, &pktLibHeapStats);
-printf("specialLarge heap stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
- pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
- pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
- pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-
-
#if 0
printf("pa2sa descriptor area dump\n");
for(i=0;i<TUNE_NETAPI_CONFIG_MAX_PA_TO_SA_DESC;i++)
if (strlen(&pConfig->sp[i][0]))
{
netTestCfg.num_sp_threads++;
- parse_one_fp(&pConfig->sp[i][0],&netTestCfg.sp_proc_start[i], &netTestCfg.sp_proc_end);
+ 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(&pConfig->sp_thread_num[i]);
+ netTestCfg.sp_thread_num[i] = atoi((char*)(&pConfig->sp_thread_num[i]));
printf("parse_sp: thread_num[%d]: %d\n", i, netTestCfg.sp_thread_num[i]);
}
}
if (strlen(&pConfig->fp[i][0]))
{
netTestCfg.num_fp_threads++;
- parse_one_fp(&pConfig->fp[i][0],&netTestCfg.fp_proc_start[i], &netTestCfg.fp_proc_end);
+ parse_one_fp(&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]))
{
- netTestCfg.fp_thread_num[i] = atoi(&pConfig->fp_thread_num[i]);
+ netTestCfg.fp_thread_num[i] = atoi((char*)(&pConfig->fp_thread_num[i]));
printf("parse_fp: thread_num[%d]: %d\n", i, netTestCfg.fp_thread_num[i]);
}
}
unsigned long long n_c_ops;
static int first =0;
Cppi_HostDesc* pPktDesc;
+ NETAPI_SCHED_SHUTDOWN_T sched_shutdown;
int coreid = 0; //who we are
#ifdef MULTI_THREAD
NETAPI_T nh= netapi_schedGetHandle(s);
coreid=(int) netapi_getCookie(nh);
- if (QUIT) {netapi_schedClose(s,NULL,&err); return;}
+ if (QUIT)
+ {
+ sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
+ netapi_schedClose(s,&sched_shutdown,&err);
+ return;
+ }
if (coreid==0) //slave
{
if (err!=0) {Debug_printf("stats req failed\n");}
if (house_pkts_gened >= np2process+ 100)
{
- netapi_schedClose(s,NULL,&err);
+ sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
+ netapi_schedClose(s,&sched_shutdown,&err);
}
return;
}
if (house_pkts_gened >= np2process+ 100)
{
- //shutdown
- netapi_schedClose(s,NULL,&err);
- continue;
+ //shutdown
+ sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
+ netapi_schedClose(s,&sched_shutdown,&err);
+ continue;
}
else if (house_pkts_gened >= np2process) { house_pkts_gened+=1; continue;}
netcp_cfgDelMac(netapi_handle,2,&err);
#endif
}
+
+
index c66618aced5eafcfdba3e766b97eba854c8835c0..081d22869814c6803ec1377cc1f38d99f775da19 100755 (executable)
#endif
+
+
#define MAX_SEC_INDEX 16
#define NET_TEST_MAX_MAC 10
#define NET_TEST_MAX_IP 10
uint8_t ipsec_if_no;
uint8_t fp_proc_start[NET_TEST_MAX_FP_THREAD];
uint8_t fp_proc_end[NET_TEST_MAX_FP_THREAD];
- uint8_t fp_thread_num[NET_TEST_MAX_FP_THREAD];
+ uint32_t fp_thread_num[NET_TEST_MAX_FP_THREAD];
uint8_t num_fp_threads;
uint8_t sp_proc_start[NET_TEST_MAX_FP_THREAD];
uint8_t sp_proc_end[NET_TEST_MAX_FP_THREAD];
- uint8_t sp_thread_num[NET_TEST_MAX_FP_THREAD];
+ uint32_t sp_thread_num[NET_TEST_MAX_FP_THREAD];
uint8_t num_sp_threads;
uint8_t auth_key[MAX_SEC_INDEX][36];
void house(NETAPI_SCHED_HANDLE_T *s);
-void create_interfaces(NETCP_CFG_IP_T *ip_rule0 , NETCP_CFG_IP_T *ip_rule1);
+void create_interfaces(NETCP_CFG_IP_T *ip_rule0 , NETCP_CFG_IP_T *ip_rule1);
void delete_interfaces(NETCP_CFG_IP_T *ip_rule0 , NETCP_CFG_IP_T *ip_rule1);
void slow_path_thread(int coreid);
void fast_path_thread(int coreid);