summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 44b0e31)
raw | patch | inline | side by side (parent: 44b0e31)
author | Tinku Mannan <tmannan@ti.com> | |
Fri, 15 Feb 2013 18:32:06 +0000 (13:32 -0500) | ||
committer | Tinku Mannan <tmannan@ti.com> | |
Fri, 15 Feb 2013 18:32:06 +0000 (13:32 -0500) |
1. New netcp_cfg APIs to allow getting and updating user data associated with APP ID.
2. API updates to allow user applications t store user data associated with APP ID.
3. Header file dependency cleanup.
4. Fixes in net_test utility functions when creating and deleting MAC/IP interfaces.
5. Additional cleanup of compiling warnings.
2. API updates to allow user applications t store user data associated with APP ID.
3. Header file dependency cleanup.
4. Fixes in net_test utility functions when creating and deleting MAC/IP interfaces.
5. Additional cleanup of compiling warnings.
29 files changed:
diff --git a/ti/runtime/netapi/build/netapi_doxygen.cfg b/ti/runtime/netapi/build/netapi_doxygen.cfg
index 41e090596a280b4e4bdb132cee386207043f7243..557adbbf940979bcc1f80af12103ea0cbaf2d3fa 100755 (executable)
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = ../netapi.h ../netcp_cfg.h ../netapi_sec.h ../netapi_tune.h ../netapi_sched.h ../pktio.h ../netapi_err.h ../netapi_ver.h
+INPUT = ../netapi.h ../netcp_cfg.h ../netapi_sec.h ../netapi_tune.h ../netapi_sched.h ../pktio.h ../netapi_types.h ../netapi_ver.h
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
index 4fd2fed5eff657f5ddb4693a97b3c8c38a921b42..09f8460da481afc928b6991b3031a786051da6b7 100755 (executable)
*
* REVISION HISTORY: rev 0.0.1
*
- * Copyright (c) Texas Instruments Incorporated 2010-2012
+ * 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 __NETAPI__H
#define __NETAPI__H
-//#define NWAL_ENABLE_SA
+
+#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include "hplib.h"
+#include "netapi_types.h"
+#include "netapi_tune.h"
+#include "pktio.h"
+#include "netcp_cfg.h"
+#include "netapi_sec.h"
+#include "netapi_sched.h"
+#include "netapi_util.h"
+
+
+
+
/* Define NETAPI as a master group in Doxygen format and
* add all NETAPI
* definitions to this group.
* @ingroup netapi
*/
-/**
- * @ingroup cfg_constants
- * @brief One per thread, used in most NETAPI function calls.
- */
-typedef void * NETAPI_T;
-
-
/**
* @def NETAPI_SYS_MASTER
* This defines the master core for the system
*/
#define NETAPI_NO_MASTER 0 //data only
-#include "netapi_err.h"
-#include "netapi_tune.h"
-#include "pktio.h"
-#include "netcp_cfg.h"
-#include "netapi_sec.h"
-#include "netapi_sched.h"
-#include "src/netapi_loc.h"
-#include "hplib.h"
-static hplib_spinLock_T netapi_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
/**
* @ingroup netapi_gen_functions
*/
Pktlib_HeapIfTable *netapi_getPktlibIfTable(void) ;
-/**
- * @ingroup netapi_gen_functions
- * @brief netapi_getBufMemRemainder API is used to return the amount of free memory available for allocating buffers
- * for additonal Pktlib heaps
- *
- * @details The application can use this API to determine how much free memory is
- * available for heap buffers if it decides to create its own.
- * @retval Amount of memory available for heap buffer storage (in bytes)
- * @pre @ref netapi_init
- */
-static inline int netapi_getBufMemRemainder(void)
-{
- return hplib_vmGetMemPoolRemainder(0);
-}
+
/**
* @ingroup netapi_gen_functions
*/
int netapi_getDescRemainder(void);
-/**
- * @ingroup netapi_gen_functions
- * @brief netapi_getDefaultFlow: API is used to return the default NETCP flow that is to be used for incoming packets.
- *
- * @details The application can use this API to return the default NETCP flow that is used
- * for received packets. A NETCP flow is a list of PacketLib Heaps that are to be
- * used to supply free packets to the receive DMA function.
- * @param[in] p The NETAPI handle, @ref NETAPI_T
- * @retval NETCP_CFG_FLOW_HANDLE_T The handle to default flow
- * @pre @ref netapi_init
- */
-static inline NETCP_CFG_FLOW_HANDLE_T netapi_getDefaultFlow(NETAPI_T p)
-{
- return NETCP_DEFAULT_FLOW;
-}
-
-/**
- * @ingroup netapi_gen_functions
- * @brief netapi_getDefaultRoute: API is used to return the default NETCP route handle.
- *
- * @details This API returns the default NETCP route created by @ref netapi_init.
- * A netcp route consists of a NETCP flow plus a destination pktio channel
- * @param[in] p The NETAPI handle, @ref NETAPI_T
- * @retval The handle of the default route, NETCP_CFG_ROUTE_HANDLE_T
- * @pre @ref netapi_init
- */
-static inline NETCP_CFG_ROUTE_HANDLE_T netapi_getDefaultRoute(NETAPI_T p)
-{
- return NETCP_DEFAULT_ROUTE;
-}
-
-/**
- * @ingroup netapi_gen_functions
- * @brief netapi_getCookie API is used to return a piece of application-provided opaque data that has been
- * stored in the netapi instance.
- *
- * @details The application can save a pointer to opaque data in the @ref NETAPI_T instance.
- * This APi lets this data be returned to the application.
- * @param[in] p The NETAPI handle, @ref NETAPI_T
- * @retval Data provided in @ref netapi_setCookie
- * @pre @ref netapi_init, @ref netapi_setCookie
- */
-
-static inline void * netapi_getCookie(NETAPI_T p)
-{
- NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
- return pp->cookie;
-}
-
-/**
- * @ingroup netapi_gen_functions
- * @brief netapi_setCookie API is used to set a piece of application-provided opaque data t in the netapi instance.
- *
- * @details The applicaiton can save a pointer to opaque data in the @ref NETAPI_T instance.
- * Pointer to a opaque data can be returned later to the application via @ref netapi_getCookie
- * @param[in] p The NETAPI handle, @ref NETAPI_T
- * @param[in] cookie Opaque data to be saved
- * @retval none
- * @pre @ref netapi_init
- */
-static inline void netapi_setCookie(NETAPI_T p, void * cookie)
-{
- NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
- pp->cookie= cookie;
-}
-
/**
* @ingroup netapi_gen_functions
* @brief netapi_netcpPoll API is used to poll for NETCP configuration response messages.
*/
void netapi_netcpPoll(NETAPI_T p);
-/**
- * @ingroup netapi_gen_functions
- * @brief netapi_registerHeap API is used to register a heap that is created by application so that
- * it's garbage queue can be polled automatically by @ref netapi_pollHeapGarbage.
- *
- * @details This API registers an application-created heap with the netapi instance
- * so that it can add that heap's garbage queue to the garbage poll function.
- * NOTE: netapi internal heap is automatically registered
- * @param[in] p The NETAPI handle, @ref NETAPI_T
- * @param[in] h Handle of pklib heap to register
- * @retval 1 if OK, <0 on error
- * @pre @ref netapi_init
- */
-static inline int netapi_registerHeap(NETAPI_T p, Pktlib_HeapHandle h)
-{
- NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
- int i;
- hplib_mSpinLockLock(&netapi_lock);
- for(i=0;i<TUNE_NETAPI_MAX_HEAPS;i++)
- {
- if (!pp->createdHeaps[i])
- {
- pp->createdHeaps[i]=h;
- hplib_mSpinLockUnlock(&netapi_lock);
- return 1;
- }
- }
- hplib_mSpinLockUnlock(&netapi_lock);
- return -1;
-}
-/**
- * @ingroup netapi_gen_functions
- * @brief netapi_unregisterHeap API is used to un-register a heap that was created by application
- * and previously registered so that it's garbage queue could be polled
- * automatically by @ref netapi_pollHeapGarbage.
- *
- * @details This API un-registers an application-created heap with the netapi instance.
- * NOTE: netapi internal heap is automatically registered
- * @param[in] p The NETAPI handle, @ref NETAPI_T
- * @param[in] h The pklib handle to heap
- * @retval <0 if err, 1 if OK
- * @pre @ref netapi_init
- */
-static inline int netapi_unregisterHeap(NETAPI_T p, Pktlib_HeapHandle h)
-{
- NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
- int i;
- hplib_mSpinLockLock(&netapi_lock);
- for(i=0;i<TUNE_NETAPI_MAX_HEAPS;i++)
- {
- if (pp->createdHeaps[i] == h)
- {
- pp->createdHeaps[i]=NULL;
- hplib_mSpinLockUnlock(&netapi_lock);
- return 1;
- }
- }
- hplib_mSpinLockUnlock(&netapi_lock);
- return -1;
-}
-
-/**
- * @ingroup netapi_gen_functions
- * @brief netapi_closeHeap API is used to remove a created pktlib heap
- *
- * @details This API removes an application-created heap with the netapi instance
- * NOTE: descriptors are zapped and cannot be reused]
- * @param[in] p The NETAPI handle, @ref NETAPI_T
- * @param[in] h : handle to pklib heap
- * @retval <0 if err, 1 if OK
- * @pre @ref netapi_init @ref netapi_registerHeap
- */
-static inline int netapi_closeHeap(NETAPI_T p, Pktlib_HeapHandle h)
-{
- Qmss_QueueHnd q;
- Pktlib_garbageCollection(p);
- q = Pktlib_getZeroHeapQueue(p);
- netapi_zapQ(q);
- q= Pktlib_getInternalHeapQueue(p);
- netapi_zapQ(q);
-}
/**
* @ingroup netapi_gen_functions
* @brief netapi_pollHeapGarbage API is used to poll the garbage collection queue for
index f2cdd1f7c5837b5fff3479581b6c938dd5017c3a..000cbded27a504e3559654ce5a118939bc8d8bab 100755 (executable)
#ifndef __NETAPI_SEC__H
#define __NETAPI_SEC__H
#include "netapi.h"
-#include "ti/runtime/pktlib/pktlib.h"
#include "ti/drv/nwal/nwal.h"
#include <ti/drv/sa/salld.h>
* @param[in] sa_info Information on the SA being added, @ref NETAPI_SEC_SA_INFO_T
* @param[in] key_params Security key information for the SA.
* @param[in] mode SA implementation mode @ref NETAPI_SEC_SA_SIDEBAND or @ref NETAPI_SEC_SA_INFLOW
- * @param[in] route @ref NETCP_CFG_ROUTE_HANDLE_T
+ * @param[in] route Optional: @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[in] user_data Optional: pointer to user provided data associated with SA, optional
* @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).
NETCP_CFG_ROUTE_HANDLE_T route,
void ** data_mode_handle,
void ** inflow_mode_handle,
- void * p_user_data,
+ void * user_data,
int * perr);
/**
* @ingroup cfg_security_functions
* @param[in] src_ip_addr source IP for policy check
* @param[in] dst_ip_addr destination IP for policy check
* @param[in] ip_qualifiers IP qualifiers for policy check
- * @param[in] route Optional route @ref NETCP_CFG_ROUTE_HANDLE_T
+ * @param[in] route Optional: @ref NETCP_CFG_ROUTE_HANDLE_T
+ * @param[in] user_data Optional: pointer to user provided data associated with policy, optional
* @param[out] perr Pointer to error code.
* @retval Aplication id associated with created receive security policy @ref NETCP_CFG_IPSEC_POLICY_T. This is used to refer to the policy in the @ref netapi_secDelRxPolicy call. Also, packets that match this policy but do not pass any further lookups in NETCP will be tagged with this ID
* @pre @ref netapi_init @ref netapi_secAddSA
nwalIpAddr_t * dst_ip_addr,
nwalIpOpt_t * ip_qualifiers,
NETCP_CFG_ROUTE_HANDLE_T route,
+ void * user_data,
int * perr);
/**
index 3a58e1e86ec25df3cfad287c5bd0b3c373df27f2..1b977fe7f893b4dfb1e745776b776ba1a0602e8c 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
similarity index 92%
rename from ti/runtime/netapi/netapi_err.h
rename to ti/runtime/netapi/netapi_types.h
index 9f8fd8ae0542ddb5dbb23bd8c9075b3f1c6053a7..a1db13348c7b225b709e50c3e010704b1c3c3399 100755 (executable)
rename from ti/runtime/netapi/netapi_err.h
rename to ti/runtime/netapi/netapi_types.h
index 9f8fd8ae0542ddb5dbb23bd8c9075b3f1c6053a7..a1db13348c7b225b709e50c3e010704b1c3c3399 100755 (executable)
#ifndef __NETAPI_ERR__
#define __NETAPI_ERR__
+
+/**
+ * @ingroup cfg_constants
+ * @brief One per thread/core, used in most NETAPI function calls, returned from call to netapi_init().
+ */
+typedef void * NETAPI_T;
+
+
+
+/**
+ * @defgroup netapi_RetValue NETAPI API Return Values
+ * @ingroup netapi
+ */
+/** @ingroup nwal_RetValue */
+typedef int16_t netapi_RetValue;
+
/** @defgroup netapi_errors NETAPI Error Return Values
* @ingroup netapi
*/
index 6ec7e45af22bc934fb7292dd943b04c22daca08f..724663d115f47afb5cf4b9180c6adda479c9e596 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
#define __NETAPI_UTIL__H
#include <stdint.h>
+#include "ti/runtime/netapi/src/netapi_loc.h"
-/* virtual address of the [only] memory pool */
-extern uint8_t *netapi_VM_mem_start;
-extern uint8_t *netapi_VM_mem_end;
-/* Physical address of the [only] memory pool */
-extern uint8_t *netapi_VM_mem_start_phy;
-extern uint8_t *netapi_VM_mem_end_phy;
+#define NETAPI_DEBUG */
+#ifdef NETAPI_DEBUG
+#define Debug_printf printf
+#else
+#define Debug_printf
+#endif
-#define netapi_timing_start hplib_mUtilGetPmuCCNT
-#define netapi_timing_stop hplib_mUtilGetPmuCCNT
+/* Wrapper functions around HPLIB APIs for QMSS , *utility to convert virt2phy, phy2virt */
+#define _Osal_qmssVirtToPhy hplib_mVMVirtToPhy
-//netapi kernel module access routines
-int netapi_utilModInit(void);
-void netapi_utilModClose(void);
-unsigned long netapi_utilGetPhysOfBufferArea(void);
-unsigned long netap_utilGetSizeofBufferArea(void);
-int netapi_utilCacheWbInv(void *ptr, size_t size);
-int netapi_utilCacheInv(void *ptr, size_t size);
-int netapi_utilCacheWb(void *ptr, size_t size);
-unsigned long netapi_utilGetVaOfBufferArea(unsigned int offset, unsigned int size);
+#define _Osal_qmssPhyToVirt hplib_mVMPhyToVirt
-//for benchmarking
-void Osal_cache_op_measure_reset(void);
-unsigned int Osal_cache_op_measure(int * p_n) ;
+static hplib_spinLock_T netapi_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
-//utility to convert virt2phy, phy2virt
-#define _Osal_qmssVirtToPhy hplib_mVMVirtToPhy
+/**
+ * @ingroup netapi_gen_functions
+ * @brief netapi_registerHeap API is used to register a heap that is created by application so that
+ * it's garbage queue can be polled automatically by @ref netapi_pollHeapGarbage.
+ *
+ * @details This API registers an application-created heap with the netapi instance
+ * so that it can add that heap's garbage queue to the garbage poll function.
+ * NOTE: netapi internal heap is automatically registered
+ * @param[in] p The NETAPI handle, @ref NETAPI_T
+ * @param[in] h Handle of pklib heap to register
+ * @retval 1 if OK, <0 on error
+ * @pre @ref netapi_init
+ */
+static inline int netapi_registerHeap(NETAPI_T p, Pktlib_HeapHandle h)
+{
+ NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
+ int i;
+ hplib_mSpinLockLock(&netapi_lock);
+ for(i=0;i<TUNE_NETAPI_MAX_HEAPS;i++)
+ {
+ if (!pp->createdHeaps[i])
+ {
+ pp->createdHeaps[i]=h;
+ hplib_mSpinLockUnlock(&netapi_lock);
+ return 1;
+ }
+ }
+ hplib_mSpinLockUnlock(&netapi_lock);
+ return -1;
+}
+
+/**
+ * @ingroup netapi_gen_functions
+ * @brief netapi_unregisterHeap API is used to un-register a heap that was created by application
+ * and previously registered so that it's garbage queue could be polled
+ * automatically by @ref netapi_pollHeapGarbage.
+ *
+ * @details This API un-registers an application-created heap with the netapi instance.
+ * NOTE: netapi internal heap is automatically registered
+ * @param[in] p The NETAPI handle, @ref NETAPI_T
+ * @param[in] h The pklib handle to heap
+ * @retval <0 if err, 1 if OK
+ * @pre @ref netapi_init
+ */
+static inline int netapi_unregisterHeap(NETAPI_T p, Pktlib_HeapHandle h)
+{
+ NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
+ int i;
+ hplib_mSpinLockLock(&netapi_lock);
+ for(i=0;i<TUNE_NETAPI_MAX_HEAPS;i++)
+ {
+ if (pp->createdHeaps[i] == h)
+ {
+ pp->createdHeaps[i]=NULL;
+ hplib_mSpinLockUnlock(&netapi_lock);
+ return 1;
+ }
+ }
+ hplib_mSpinLockUnlock(&netapi_lock);
+ return -1;
+}
+
+/**
+ * @ingroup netapi_gen_functions
+ * @brief netapi_closeHeap API is used to remove a created pktlib heap
+ *
+ * @details This API removes an application-created heap with the netapi instance
+ * NOTE: descriptors are zapped and cannot be reused]
+ * @param[in] p The NETAPI handle, @ref NETAPI_T
+ * @param[in] h : handle to pklib heap
+ * @retval <0 if err, 1 if OK
+ * @pre @ref netapi_init @ref netapi_registerHeap
+ */
+static inline int netapi_closeHeap(NETAPI_T p, Pktlib_HeapHandle h)
+{
+ Qmss_QueueHnd q;
+ Pktlib_garbageCollection(p);
+ q = Pktlib_getZeroHeapQueue(p);
+ netapi_zapQ(q);
+ q= Pktlib_getInternalHeapQueue(p);
+ netapi_zapQ(q);
+}
+/**
+ * @ingroup netapi_gen_functions
+ * @brief netapi_getCookie API is used to return a piece of application-provided opaque data that has been
+ * stored in the netapi instance.
+ *
+ * @details The application can save a pointer to opaque data in the @ref NETAPI_T instance.
+ * This APi lets this data be returned to the application.
+ * @param[in] p The NETAPI handle, @ref NETAPI_T
+ * @retval Data provided in @ref netapi_setCookie
+ * @pre @ref netapi_init, @ref netapi_setCookie
+ */
+
+static inline void * netapi_getCookie(NETAPI_T p)
+{
+ NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
+ return pp->cookie;
+}
+
+/**
+ * @ingroup netapi_gen_functions
+ * @brief netapi_setCookie API is used to set a piece of application-provided opaque data t in the netapi instance.
+ *
+ * @details The applicaiton can save a pointer to opaque data in the @ref NETAPI_T instance.
+ * Pointer to a opaque data can be returned later to the application via @ref netapi_getCookie
+ * @param[in] p The NETAPI handle, @ref NETAPI_T
+ * @param[in] cookie Opaque data to be saved
+ * @retval none
+ * @pre @ref netapi_init
+ */
+static inline void netapi_setCookie(NETAPI_T p, void * cookie)
+{
+ NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
+ pp->cookie= cookie;
+}
+
+/**
+ * @ingroup netapi_gen_functions
+ * @brief netapi_getBufMemRemainder API is used to return the amount of free memory available for allocating buffers
+ * for additonal Pktlib heaps
+ *
+ * @details The application can use this API to determine how much free memory is
+ * available for heap buffers if it decides to create its own.
+ * @retval Amount of memory available for heap buffer storage (in bytes)
+ * @pre @ref netapi_init
+ */
+static inline int netapi_getBufMemRemainder(void)
+{
+ return hplib_vmGetMemPoolRemainder(0);
+}
+
+/**
+ * @ingroup netapi_gen_functions
+ * @brief netapi_getDefaultFlow: API is used to return the default NETCP flow that is to be used for incoming packets.
+ *
+ * @details The application can use this API to return the default NETCP flow that is used
+ * for received packets. A NETCP flow is a list of PacketLib Heaps that are to be
+ * used to supply free packets to the receive DMA function.
+ * @param[in] p The NETAPI handle, @ref NETAPI_T
+ * @retval NETCP_CFG_FLOW_HANDLE_T The handle to default flow
+ * @pre @ref netapi_init
+ */
+static inline NETCP_CFG_FLOW_HANDLE_T netapi_getDefaultFlow(NETAPI_T p)
+{
+ return NETCP_DEFAULT_FLOW;
+}
+
+/**
+ * @ingroup netapi_gen_functions
+ * @brief netapi_getDefaultRoute: API is used to return the default NETCP route handle.
+ *
+ * @details This API returns the default NETCP route created by @ref netapi_init.
+ * A netcp route consists of a NETCP flow plus a destination pktio channel
+ * @param[in] p The NETAPI handle, @ref NETAPI_T
+ * @retval The handle of the default route, NETCP_CFG_ROUTE_HANDLE_T
+ * @pre @ref netapi_init
+ */
+static inline NETCP_CFG_ROUTE_HANDLE_T netapi_getDefaultRoute(NETAPI_T p)
+{
+ return NETCP_DEFAULT_ROUTE;
+}
+
+/**
+ * @ingroup cfg_functions
+ * @brief netcp_cfgGetPolicyUserData API to retrieve user mode data associated with Policy APPID.
+ *
+ * @details This api is used to retrieve user mode data associated with an Policy APPID
+ * @param[in] h NETAPI instance handle, @ref NETAPI_T
+ * @param[in] app_id application id whose user mode data is to be retrieved
+ * @retval void* pointer to user mode data.
+ * @pre @ref netapi_init
+ */
+static inline void* netcp_cfgGetPolicyUserData(NETAPI_T h,
+ NETCP_CFG_SA_T app_id)
+{
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
+ int slot = (app_id >>8) &0xffff;
+ if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_POLICY))
+ {
+ return NULL;
+ }
+ return (p->policy[slot].user_data);
+}
+
+/**
+ * @ingroup cfg_functions
+ * @brief netcp_cfgGetIpSecUserData API to retrieve user mode data associated with IPSEC APPID.
+ *
+ * @details This api is used to retrieve user mode data associated with an IPSEC APPID
+ * @param[in] h NETAPI instance handle, @ref NETAPI_T
+ * @param[in] app_id application id whose user mode data is to be retrieved
+ * @retval void* pointer to user mode data.
+ * @pre @ref netapi_init
+ */
+static inline void* netcp_cfgGetIpSecUserData(NETAPI_T h,
+ NETCP_CFG_SA_T app_id)
+{
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
+ int slot = (app_id >>8) &0xffff;
+ Debug_printf("netcp_cfgGetIpSecUserData: slot found %d\n", slot);
+ if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_SA))
+ {
+ return NULL;
+ }
+ Debug_printf("netcp_cfgGetIpSecUserData: user data being returned %d\n",
+ (uint32_t)(p->tunnel[slot].user_data));
+ return (p->tunnel[slot].user_data);
+}
+
+
+/**
+ * @ingroup cfg_functions
+ * @brief netcp_cfgGetIpUserData API to retrieve user mode data associated with Generic IP APPID.
+ *
+ * @details This api is used to retrieve user mode data associated with a Generic IP APPID
+ * @param[in] h NETAPI instance handle, @ref NETAPI_T
+ * @param[in] app_id application id whose user mode data is to be retrieved
+ * @retval void* pointer to user mode data.
+ * @pre @ref netapi_init
+ */
+static inline void* netcp_cfgGetIpUserData(NETAPI_T h,
+ NETCP_CFG_SA_T app_id)
+{
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
+ int slot = (app_id >>8) &0xffff;
+ if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_NUM_IP))
+ {
+ return NULL;
+ }
+ return (p->ips[slot].user_data);
+}
+
+/**
+ * @ingroup cfg_functions
+ * @brief netcp_cfgGetClassiferUserData API to retrieve user mode data associated with Classifer APPID.
+ *
+ * @details This api is used to retrieve user mode data associated with a flassifier APPID
+ * @param[in] h NETAPI instance handle, @ref NETAPI_T
+ * @param[in] app_id application id whose user mode data is to be retrieved
+ * @retval void* pointer to user mode data.
+ * @pre @ref netapi_init
+ */
+static inline void* netcp_cfgGetClassiferUserData(NETAPI_T h,
+ NETCP_CFG_SA_T app_id)
+{
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
+ int slot = (app_id >>8) &0xffff;
+ if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
+ {
+ return NULL;
+ }
+ return (p->classi[slot].user_data);
+}
+
+
+/**
+ * @ingroup cfg_functions
+ * @brief netcp_cfgGetUserData API to retrieve user mode data associated with APPID.
+ *
+ * @details This api is used to retrieve user mode data associated with an APPID
+ * @param[in] h NETAPI instance handle, @ref NETAPI_T
+ * @param[in] app_id application id whose user mode data is to be retrieved
+ * @retval void* pointer to user mode data.
+ * @pre @ref netapi_init
+ */
+static inline void* netcp_cfgGetUserData(NETAPI_T h,
+ NETCP_CFG_SA_T app_id)
+{
+ NETCP_CFG_SA_T appIdType;
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
+
+ appIdType = app_id & 0xff000000;
+ switch(appIdType)
+ {
+ case(NETAPI_NETCP_MATCH_IPSEC):
+ Debug_printf("netcp_cfgGetUserData: ipsec appID found\n");
+ return (netcp_cfgGetIpSecUserData(h, app_id));
+ break;
+ case(NETAPI_NETCP_MATCH_IPSEC_POLICY):
+ Debug_printf("netcp_cfgGetUserData: policy appID found\n");
+ return (netcp_cfgGetPolicyUserData(h, app_id));
+ break;
+ case(NETAPI_NETCP_MATCH_GENERIC_IP):
+ Debug_printf("netcp_cfgGetUserData: IP appID found\n");
+ return (netcp_cfgGetIpUserData(h, app_id));
+ break;
+ case(NETAPI_NETCP_MATCH_CLASS):
+ Debug_printf("netcp_cfgGetUserData: classifier appID found\n");
+ return (netcp_cfgGetClassiferUserData(h, app_id));
+ break;
+ default:
+ return NULL;
+ break;
+ }
+}
+
+/**
+ * @ingroup cfg_functions
+ * @brief netcp_cfgUpdateUserData API to retrieve user mode data associated with APPID.
+ *
+ * @details This api is used to retrieve user mode data associated with an APPID
+ * @param[in] h NETAPI instance handle, @ref NETAPI_T
+ * @param[in] app_id application id whose user mode data is to updated
+ * @retval void* pointer to user mode data.
+ * @pre @ref netapi_init
+ */
+static inline netapi_RetValue netcp_cfgUpdateUserData(NETAPI_T h,
+ NETCP_CFG_SA_T app_id,
+ void * user_data)
+{
+ NETCP_CFG_SA_T appIdType;
+ NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
+
+ int slot = (app_id >>8) &0xffff;
+ if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
+ {
+ return NETAPI_ERR_BAD_INPUT;
+ }
+ appIdType = app_id & 0xff000000;
+ switch(appIdType)
+ {
+ case(NETAPI_NETCP_MATCH_IPSEC):
+ Debug_printf("netcp_cfgUpdateUserData: ipsec appID found\n");
+ p->tunnel[slot].user_data = user_data;
+ return NETAPI_ERR_OK;
+ break;
+ case(NETAPI_NETCP_MATCH_IPSEC_POLICY):
+ Debug_printf("netcp_cfgUpdateUserData: policy appID found\n");
+ p->policy[slot].user_data = user_data;
+ return NETAPI_ERR_OK;
+ break;
+ case(NETAPI_NETCP_MATCH_GENERIC_IP):
+ Debug_printf("netcp_cfgUpdateUserData: IP appID found\n");
+ p->ips[slot].user_data = user_data;
+ return NETAPI_ERR_OK;
+ break;
+ case(NETAPI_NETCP_MATCH_CLASS):
+ Debug_printf("netcp_cfgUpdateUserData: classifier appID found\n");
+ p->classi[slot].user_data = user_data;
+ return NETAPI_ERR_OK;
+ break;
+ default:
+ return NETAPI_ERR_BAD_INPUT;
+ break;
+ }
+}
-#define _Osal_qmssPhyToVirt hplib_mVMPhyToVirt
#endif
index da9596fa587ee9f50c8e7680c2cb840b387ee8bd..65a16e8b1510d5eed9ed15a4619b45aecea6e403 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 b86d42f534e6ec9dfebdd69de8764357c8bd3d34..edda8d55ac01af2bd508767551066f4c41ca54ea 100755 (executable)
#ifndef __NETCP_CFG__H
#define __NETCP_CFG__H
-
#include "netapi.h"
-//#include "netapi_loc.h"
/**
* @ingroup cfg_structures
* @def NETAPI_NETCP_MATCH_CLASS_L3
* This define is used for an APPID that indicates that a packet matched a MAC entry. Entry # (logical interface) is in byte 0 of APPID.
* Packet also matched a general IP rule added as part of a classifier. But it not match a
- * L4 port or any other rule. We cannout say what classifer partially matched so Bytes 3-2 are
+ * L4 port or any other rule. We cannot say what classifer partially matched so Bytes 3-2 are
* not applicable
*/
#define NETAPI_NETCP_MATCH_CLASS_L3 0x40000000 //MATCHED L3 but not L4. lower byte==interface
* @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
* diffserv category for example.
* @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
+ * @param[in] user_data Optional: pointer to user provided data associated with IP
* @param[out] err pointer to error return
* @retval returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
* @pre @ref netapi_init
nwalIpAddr_t * ip_addr,
nwalIpOpt_t * ip_qualifiers,
NETCP_CFG_ROUTE_HANDLE_T route,
+ void * user_data,
int * err
);
* @param[in] p_class definition of the classifier
* @param[in] p_route handle to NETCP route.
* @param[in] action what to do with packet: one of NETCP_CFG_ACTION_TO_SW, DISCARD or CONTINUE
+ * @param[in] user_data Optional: pointer to user provided data associated with SA
* @param[out] err pointer to error return
* @retval returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
* @pre @ref netapi_init
*/NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
NETCP_CFG_CLASSIFIER_T *p_class,
NETCP_CFG_ROUTE_HANDLE_T p_route,
- int action,
+ int action,void * user_data,
int * err);
index 9a68ce7bc26b2bc5ab5e21f964fde281aa9fa175..66d42fcb4956ed60023fab19e8ee2265a4a0ac1b 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 8c9419679a64c1555566c77cba2937d6425fe0df..b88d8b8edf8d773757b9ef2243598c8f9de62002 100755 (executable)
#ifndef __PKTIO__H
#define __PKTIO__H
#include "netapi.h"
-#include "ti/runtime/pktlib/pktlib.h"
#include "ti/drv/nwal/nwal.h"
#include "ti/drv/nwal/nwal_util.h"
-#include "netapi_err.h"
-
-
-/**
- * @def PKTIO_NOMEM
- * @ingroup pktio_constants
- * This define is used to indicate out of memory error to the user space application
- */
-#define PKTIO_NOMEM NETAPI_ERR_NOMEM
/**
* @def NETCP_TX
index 4ea8975b4b2281a113ac7832a8bde375c9002b56..82278511ace732a5cc0aa7a98576cec1b7cfa38e 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
#include <unistd.h>
#include <string.h>
#include "netapi.h"
-//#include "src/netapi_loc.h"
+
/*------------internal prototypes---------------*/
}
else
{
- printf("netapi_init: no master specified\n");
+ Debug_printf("netapi_init: no master specified\n");
goto ERR_netapi_init;
}
NETAPI_HANDLE_T * p = (NETAPI_HANDLE_T *) h;
if (!p) return;
- printf(">netapi: WARNING shutdown may not be fully implemented\n");
+ Debug_printf(">netapi: WARNING shutdown may not be fully implemented\n");
if (p->master ==NETAPI_SYS_MASTER)
{
/* close nwal */
static void netapiSharedMemoryFree(uint8_t* ptr, uint32_t size)
{
/* Do Nothing. */
- printf(">netapi Unexpected. need to provide a free () for some reason!! \n");
+ Debug_printf(">netapi Unexpected. need to provide a free () for some reason!! \n");
return;
}
/* TODO: at this point, we need to create the QM regions which need to moved out of the above
netapi_VM_memory_setup() call, also need to move out the SA context stuff */
- if (result == hplib_OK) printf(">netapi: system init - memory set up OK\n");
- else {printf(">netap: system init - memory set up failed\n"); return -1;}
+ if (result == hplib_OK) Debug_printf(">netapi: system init - memory set up OK\n");
+ else {Debug_printf(">netap: system init - memory set up failed\n"); return -1;}
#ifdef NETAPI_ENABLE_SECURITY
SEC_CONTEXT_SZ), 128, 0);
if (!netapi_VM_SaContextVaddr)
{
- printf(">netapi ERROR: Failed to map SA context memory region\n");
+ Debug_printf(">netapi ERROR: Failed to map SA context memory region\n");
return (-1);
}
- printf(">hplib VM_SaContext: Memory mapped/allocated at address %p.\n", netapi_VM_SaContextVaddr);
+ Debug_printf(">hplib VM_SaContext: Memory mapped/allocated at address %p.\n", netapi_VM_SaContextVaddr);
#else
netapi_VM_SaContextVaddr= (char *) NULL;
(void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
TUNE_NETAPI_DESC_SIZE),
128, 0);
- printf("netapi local desc region=%x global desc region=%x\n", netapi_VM_QMemLocalDescRam, netapi_VM_QMemGlobalDescRam);
+ Debug_printf("netapi local desc region=%x global desc region=%x\n", netapi_VM_QMemLocalDescRam, netapi_VM_QMemGlobalDescRam);
//get timer running
#ifdef CORTEX_A8
netapi_init_timer();
#endif
- printf("system_init: returned from netapi_init_timer\n");
+ Debug_printf("system_init: returned from netapi_init_timer\n");
/* Initialize Queue Manager Sub System */
result = netapi_init_qm (netapi_global.cfg.def_max_descriptors);
if (result != 1)
{
- printf("system_init: returned from netapi_init_qm with failure\n");
+ Debug_printf("system_init: returned from netapi_init_qm with failure\n");
return -1;
}
/* Start the QMSS. */
if (netapi_start_qm() != 1)
{
- printf("system_init: returned from netapi_start_qm with failure\n");
+ Debug_printf("system_init: returned from netapi_start_qm with failure\n");
return -1;
}
//clean our old junk in 1st bunch of queues that will be allocated to us
netapi_cleanup_at_start();
- printf("system_init: returned from netapi_cleanup_at_start\n");
+ Debug_printf("system_init: returned from netapi_cleanup_at_start\n");
/* Initialize the global descriptor memory region. */
result= netapi_qm_setup_mem_region(
netapi_global.cfg.def_tot_descriptors_for_us,
SIZE_SHARED_DESC,
(unsigned int *) netapi_VM_QMemGlobalDescRam,
NETAPI_GLOBAL_REGION);
- if(result <0) {printf(">netapi; can't setup QM shared region\n"); return -1;}
+ if(result <0) {Debug_printf(">netapi; can't setup QM shared region\n"); return -1;}
-printf(">system_init: returned from netapi_qm_setup_mem_region\n");
+Debug_printf(">system_init: returned from netapi_qm_setup_mem_region\n");
#if 0 //todo setup 2nd region
/* Initialize the local memory region configuration. */
result= netapi_qm_setup_mem_region(
SIZE_LOCAL_DESC,
netapi_VM_QMemLocalDescRam,
NETAPI_LOCAL_REGION);
- if(result <0) {printf("can't setup local region\n"); return -1;}
+ if(result <0) {Debug_printf("can't setup local region\n"); return -1;}
#endif
/* Initialize CPPI CPDMA */
result = netapi_init_cppi ();
- printf(">system_init: returned from netapi_init_cppi\n");
+ Debug_printf(">system_init: returned from netapi_init_cppi\n");
if (result != 1)
{
- printf (">netapi: Error initializing CPPI SubSystem error code : %d\n",result);
+ Debug_printf (">netapi: Error initializing CPPI SubSystem error code : %d\n",result);
return -1;
}
/* CPPI and Queue Manager are initialized. */
- printf (">netapi: Queue Manager and CPPI are initialized.\n");
+ Debug_printf (">netapi: Queue Manager and CPPI are initialized.\n");
/* create main pkt heap */
/* Initialize the Shared Heaps. */
Pktlib_sharedHeapInit();
- printf(">system_init: returned from Pktlib_sharedHeapInit\n");
+ Debug_printf(">system_init: returned from Pktlib_sharedHeapInit\n");
/* Populate the heap interface table. */
netapi_pktlib_ifTable.data_malloc = netapiSharedMemoryMalloc;
netapi_pktlib_ifTable.data_free = netapiSharedMemoryFree;
/* Create Shared Heap with specified configuration. */
sharedHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
- printf(">system_init: returned from Pktlib_createHeap1\n");
+ Debug_printf(">system_init: returned from Pktlib_createHeap1\n");
//todo -> cleanup on failure
- if (!sharedHeapHandle) { printf(">'netapi' heap create failed, Error Code: %d\n",errCode); return -1;}
+ if (!sharedHeapHandle) { Debug_printf(">'netapi' heap create failed, Error Code: %d\n",errCode); return -1;}
handle->netcp_heap= sharedHeapHandle;
heapCfg.numZeroBufferPackets= 0;
controlRxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
- printf(">system_init: returned from Pktlib_createHeap2\n");
+ Debug_printf(">system_init: returned from Pktlib_createHeap2\n");
//todo -> cleanup on failure
- if (!controlRxHeapHandle) { printf(">netapi -'netapi_control_rx' heap create failed, Error Code: %d\n",errCode); return -1;}
+ if (!controlRxHeapHandle) { Debug_printf(">netapi -'netapi_control_rx' heap create failed, Error Code: %d\n",errCode); return -1;}
handle->netcp_control_rx_heap= controlRxHeapHandle;
heapCfg.numPkts = TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF;
controlTxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
- printf(">system_init: returned from Pktlib_createHeap3\n");
+ Debug_printf(">system_init: returned from Pktlib_createHeap3\n");
//todo -> cleanup on failure
- if (!controlTxHeapHandle) { printf(">netapi -'netapi_control_tx' heap create failed, Error Code: %d\n",errCode); return -1;}
+ if (!controlTxHeapHandle) { Debug_printf(">netapi -'netapi_control_tx' heap create failed, Error Code: %d\n",errCode); return -1;}
handle->netcp_control_tx_heap= controlTxHeapHandle;
/* now NWAL */
&netapi_pktlib_ifTable,
&netapi_global.nwal_context,
&netapi_global.cfg);
- if (result<0) {printf(">netapi init_nwal() failed\n"); return -1; }
- printf("system_init: returned from netapi_init_nwal\n");
+ if (result<0) {Debug_printf(">netapi init_nwal() failed\n"); return -1; }
+ Debug_printf("system_init: returned from netapi_init_nwal\n");
/* start NWAL */
&handle->nwal_local,
&netapi_global.cfg,
&netapi_global.nwal_context);
- if (result<0) {printf("netapi start_nwal() failed\n"); return -1; }
- printf("system_init: returned from netapi_start_nwal\n");
+ if (result<0) {Debug_printf("netapi start_nwal() failed\n"); return -1; }
+ Debug_printf("system_init: returned from netapi_start_nwal\n");
return 0;
}
}
if(i)
{
- printf("netapi_zapQ: @recovery - %d descriptors cleaned from qn %d\n",i, queueNum);
+ Debug_printf("netapi_zapQ: @recovery - %d descriptors cleaned from qn %d\n",i, queueNum);
}
}
{
Pktlib_HeapStats pktLibHeapStats;
Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2sa_heap,&pktLibHeapStats);
- printf("PA2SA(ingress) stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+ Debug_printf("PA2SA(ingress) stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
- printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+ Debug_printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
#if 0
Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2saTX_heap,&pktLibHeapStats);
-printf("PA2SA(egress) stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+Debug_printf("PA2SA(egress) stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+Debug_printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
#endif
Pktlib_getHeapStats(netapi_get_global()->nwal_context.sa2pa_heap,&pktLibHeapStats);
- printf("SA2PA stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+ Debug_printf("SA2PA stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
- printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+ Debug_printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
index ecec82407b334f01f2beb64eb5c1f55bf0d85863..75a256881ffdaa4bacef4b7d3aec3fc35d586860 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.
*
***********************************************/
-//#define NWAL_ENABLE_SA
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
+
+#include "netapi.h"
+
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
-#include <ti/drv/nwal/nwal.h>
-#include "netapi.h"
-#include "netapi_loc.h"
#include "ti/drv/nwal/nwal.h"
/* CSL RL includes */
/* TODO verify: */
#define CACHE_LINESZ 64
-#define System_printf printf
+#define System_Debug_printf Debug_printf
#define ALIGN(x) __attribute__((aligned (x)))
/*****************************************************************************
result = Qmss_insertMemoryRegion (&memInfo);
if (result < QMSS_SOK)
{
- printf (">function setup_qm_region: Qmss_insertMemoryRegion returned error code %d\n", result);
+ Debug_printf (">function setup_qm_region: Qmss_insertMemoryRegion returned error code %d\n", result);
return (-1);
}
result = Qmss_start();
if (result != QMSS_SOK)
{
- System_printf (">start_qm: Qmss_start failed with error code %d\n", result);
+ System_Debug_printf (">start_qm: Qmss_start failed with error code %d\n", result);
return (-1);
}
return 1;
Pktlib_createHeap(&heapCfg, &errCode);
if(nwalGlobCfg.pa2SaBufPool.bufPool[0].heapHandle == NULL)
{
- printf (">Pktlib_createHeap:Heap Creation Failed for PA to SA Buffer Pool , Error Code: %d\n",errCode);
+ Debug_printf (">Pktlib_createHeap:Heap Creation Failed for PA to SA Buffer Pool , Error Code: %d\n",errCode);
netapi_err_teardown();
return -1;
}
Pktlib_createHeap(&heapCfg, &errCode);
if(nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle == NULL)
{
- printf (">Pktlib_createHeap:Heap Creation Failed for SA to PA Buffer Pool , Error Code: %d\n",errCode);
+ Debug_printf (">Pktlib_createHeap:Heap Creation Failed for SA to PA Buffer Pool , Error Code: %d\n",errCode);
netapi_err_teardown();
return -1;
}
aligns);
if(nwalRetVal != nwal_OK)
{
- printf (">netapi: init_nwal - nwal_getBufferReq Failed %d\n", nwalRetVal);
+ Debug_printf (">netapi: init_nwal - nwal_getBufferReq Failed %d\n", nwalRetVal);
return nwal_FALSE;
}
bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalHandleMem);
if(NWAL_CHAN_HANDLE_SIZE < sizes[nwal_BUF_INDEX_INT_HANDLES])
{
- printf("one\n");
+ Debug_printf("one\n");
/* Resize Memory */
while(1);
}
if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0) < sizes[nwal_BUF_INDEX_PA_LLD_BUF0])
{
/* Resize Memory */
- printf("two\n");
+ Debug_printf("two\n");
while(1);
}
count++;
bases[nwal_BUF_INDEX_PA_LLD_BUF1] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paBuf1);
- printf("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
+ Debug_printf("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1, sizes[nwal_BUF_INDEX_PA_LLD_BUF1]);
if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1) < sizes[nwal_BUF_INDEX_PA_LLD_BUF1])
{
- printf("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
+ Debug_printf("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1, sizes[nwal_BUF_INDEX_PA_LLD_BUF1]);
/* Resize Memory */
while(1);
bases[nwal_BUF_INDEX_PA_LLD_BUF2] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paBuf2);
if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2) < sizes[nwal_BUF_INDEX_PA_LLD_BUF2])
{
- printf("four\n");
+ Debug_printf("four\n");
/* Resize Memory */
while(1);
}
bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)salldHandle);
if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE) < sizes[nwal_BUF_INDEX_SA_LLD_HANDLE])
{
- printf("five\n");
+ Debug_printf("five\n");
/* Resize Memory */
while(1);
}
if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) <
sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE])
{
- printf("netapi_init_nwal: sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] %d\n", sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE]);
+ Debug_printf("netapi_init_nwal: sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] %d\n", sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE]);
/* Resize Memory */
while(1);
}
&p_nwal_context->nwalInstHandle);
if(nwalRetVal != nwal_OK)
{
- printf (">netapi: init_nwal- nwal_create Failed %d\n",nwalRetVal);
+ Debug_printf (">netapi: init_nwal- nwal_create Failed %d\n",nwalRetVal);
while(1);
}
- printf(">netapi: init_nwal - Global and Local Network initialization Successful \n");
+ Debug_printf(">netapi: init_nwal - Global and Local Network initialization Successful \n");
return 1;
}
if(nwalRetVal != nwal_OK)
{
- printf (">nwal_start:Failed ->err %d !!!\n", nwalRetVal);
+ Debug_printf (">nwal_start:Failed ->err %d !!!\n", nwalRetVal);
return -1;
}
p->state = NETAPI_NW_CXT_LOC_ACTIVE;
index 0864de76107be0842067d3cd8e476d34fca1d2f8..76ae1ffa7239a9cb0ae04e04f6d25292c4b2ae1f 100755 (executable)
//#include "ti/runtime/netapi/netapi.h"
-//#include "ti/drv/nwal/nwal_util.h"
+#include "ti/drv/nwal/nwal_util.h"
+#include "pktio.h"
+#include "ti/drv/nwal/nwal.h"
+#include "ti/drv/nwal/nwal_util.h"
+
extern hplib_virtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
nwal_IpType ip_type;
nwalIpAddr_t ip_addr;
nwalIpOpt_t ip_qualifiers;
+ void * user_data;
} NETCP_INTERFACE_IP_T;
/* to hold a classifier */
typedef struct NETCP_INTERFACE_CLASSIFIER_Tag
{
- int in_use;
- int class_type; //see netcp_cfg.h
- void * nwal_L2_handle;
- void * nwal_L3_handle;
- void * nwal_L4_handle;
+ int in_use;
+ int class_type; //see netcp_cfg.h
+ void * nwal_L2_handle;
+ void * nwal_L3_handle;
+ void * nwal_L4_handle;
+ void * user_data;
} NETCP_INTERFACE_CLASSIFIER_T;
/* to hold an ipsec rx policy */
typedef struct NETCP_IPSEC_POLICY_Tag
{
- int in_use;
- int tunnel; //associated tunnel
- void * nwal_handle; //handle associated with this RX Policy
+ int in_use;
+ int tunnel; //associated tunnel
+ void * nwal_handle; //handle associated with this RX Policy
+ void * user_data; // user data associtaed with this RX Policy
} NETCP_IPSEC_POLICY_T;
/* to hold a tunnel */
index 63ae7fb30b2be69f217a1e554e5431d562d53687..12fc2a97a1dfd2897d5cc6a87d23f7065a16e858 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
****************************************/
-#include "netapi.h"
#include "netapi_sched.h"
#define NO_TIMER //turn off timer related scheduling
t = hplib_mUtilGetTimestamp();
#endif
next_house -=1;
- //poll all pktio channels we have open in RX mode
- //Osal_cache_op_measure_reset();
+
cache_op_b2= Osal_cache_op_measure(&n_c_ops);
t1=hplib_mUtilGetPmuCCNT();
+ //poll all pktio channels we have open in RX mode
pkts=pktio_pollAll((NETAPI_T) s->back, NULL, &err);
if (!pkts && (s->config.yield == TRUE))
{
index c18492b877484349e8e4454832741635be9cce0b..67c36060563d13bd5acce990e541a10948ab65fd 100755 (executable)
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
-//#define NWAL_ENABLE_SA
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include "netapi.h"
-#include "netapi_loc.h"
+
+#include "netapi_sec.h"
/********************************************************************
********************************************************************
* DESCRIPTION: API to add an IPSEC SA
********************************************************************/
-NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h, //the netapi handle
- int iface_no, //inteface to attach to
- NETAPI_SEC_SA_INFO_T *sa_info ,//info on the SA
- nwalSecKeyParams_t * key_params, //keys,etc
- int inflow_mode, //SA implementation mode: inflow or sideband or both
- NETCP_CFG_ROUTE_HANDLE_T route, //Optional route
+NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
+ int iface_no,
+ NETAPI_SEC_SA_INFO_T *sa_info,
+ nwalSecKeyParams_t * key_params,
+ int inflow_mode,
+ NETCP_CFG_ROUTE_HANDLE_T route,
void **p_data_mode_handle,
void **p_inflow_mode_handle,
void * p_user_data,
{0}
};
void * mac_handle = netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context,iface_no);
- int coreid = Osal_nwalGetProcId();
*perr =0;
if ((!n) || (!sa_info) || (!p_data_mode_handle) ) {*perr = NETAPI_ERR_BAD_INPUT; return -1;}
- //reserve a slot
+ /* reserve a slot */
tunnelId = netcp_cfgp_find_sa_slot(&netapi_get_global()->nwal_context,
iface_no);
- printf("coreid: %d, netapi_secAddSA called for tunnelId %d\n", coreid, tunnelId);
- if (tunnelId <0) {*perr= NETAPI_ERR_NOMEM; return -1; }
+ if (tunnelId <0)
+ {
+ *perr= NETAPI_ERR_NOMEM;
+ return -1;
+ }
appId |= (tunnelId<<8);
+ Debug_printf("netapi_secAddSA: app id: 0x%x\n", appId);
*p_data_mode_handle= NULL;
*p_inflow_mode_handle= NULL;
saInfo.proto = sa_info->proto;
createParam.macHandle = mac_handle;
createParam.ipType = sa_info->ipType;
- //memcpy(&createParam.saIpSecParam.src,&sa_info->src, sizeof(nwalIpAddr_t));
createParam.saIpSecParam.dir = sa_info->dir;
createParam.saIpSecParam.saMode = sa_info->saMode;
createParam.saIpSecParam.replayWindow = sa_info->replayWindow;
&createParam.saIpSecParam.appRxPktQueue);
}
- //fire off config message
+ /* fire off config message */
retValue = nwal_setSecAssoc (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
trans_id,
(nwal_AppId) appId,
else if(retValue != nwal_OK)
{
*perr = NETAPI_ERR_NWAL_ERR0;
- printf ("coreid: %d, netapi_secAddSA: ERROR: nwal_setSecAssoc returned Error Code %d\n",
- coreid, retValue);
netapip_FreeTransInfo(pTransInfo);
netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
return -1;
}
- //wait here until its done since scheduler isn't running yet most likely..
- // todo: make this handled by scheduler poll later ??
if((trans_id != NWAL_TRANSID_SPIN_WAIT)&&(have_to_wait))
{
n->nwal_local.numPendingCfg++;
while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
(pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
{
- // if response is there, then this poll squirts out in the CTl poll callback,
- // which handles the rest (including decrmenting #pending!!
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
}
if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
pTransInfo->inUse = nwal_FALSE;
*perr = NETAPI_ERR_PA_FW;
- printf (">netapi_sec - ERROR returned by NETCP PA firmware %d\n",
+ Debug_printf (">netapi_sec - ERROR returned by NETCP PA firmware %d\n",
*perr);
netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
return -1;
}
}
- printf ("coreid: %d, netapi_secAddSA: SA %d added to mac %d\n", coreid, tunnelId, iface_no);
*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));
&swInfo0,
&swInfo1) == nwal_TRUE)
{
- printf("netapisecAddSA swInfo0: 0x%x, swInfo1: 0x%x\n", swInfo0, swInfo1);
+ Debug_printf("netapisecAddSA swInfo0: 0x%x, swInfo1: 0x%x\n", swInfo0, swInfo1);
}
else
- printf("netapisecAddSA: call to nwal_getSecAssoc returne error\n");
+ Debug_printf("netapisecAddSA: call to nwal_getSecAssoc() returne error\n");
}
-#endif
}
- //sideband mode
+ /* sideband mode */
if (inflow_mode &NETAPI_SEC_SA_SIDEBAND)
{
nwalCreateDmSAParams_t dmSaParam;
void * dm_handle;
memset(&dmSaParam,0,sizeof(nwalCreateDmSAParams_t));
dmSaParam.dmSaParam.dmChnType= (sa_info->dir==NWAL_SA_DIR_INBOUND)? NWAL_DM_CHAN_DECRYPT: NWAL_DM_CHAN_ENCRYPT; /**direction*/
- dmSaParam.dmSaParam.replayWindow=sa_info->replayWindow; /**< Replay Window Size */
- dmSaParam.dmSaParam.authMode=sa_info->authMode; /**< Authentication Algorithm */
- dmSaParam.dmSaParam.cipherMode=sa_info->cipherMode ; /**< Encryption Algorithm */
- dmSaParam.dmSaParam.macSize=12; /**todo: pass in or deduce */
- dmSaParam.dmSaParam.aadSize=0; /**todo: pass in or deduce */
+ dmSaParam.dmSaParam.replayWindow=sa_info->replayWindow;
+ dmSaParam.dmSaParam.authMode=sa_info->authMode;
+ dmSaParam.dmSaParam.cipherMode=sa_info->cipherMode;
+ dmSaParam.dmSaParam.macSize=12;
+ dmSaParam.dmSaParam.aadSize=0;
dmSaParam.dmSaParam.enc1st = (sa_info->dir ==NWAL_SA_DIR_OUTBOUND) ? nwal_TRUE : nwal_FALSE; //encypt 1st for outbound
if ((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) ||
(sa_info->cipherMode == NWAL_SA_EALG_AES_CCM) ||
}
else
{
- dmSaParam.dmSaParam.macSize=12; /**todo: pass in or deduce */
- dmSaParam.dmSaParam.aadSize=0; /**todo: pass in or deduce */
+ dmSaParam.dmSaParam.macSize=12;
+ dmSaParam.dmSaParam.aadSize=0;
}
if (sa_info->authMode == NWAL_SA_AALG_NULL)
{
dmSaParam.dmSaParam.enc1st = nwal_TRUE;
}
- //todo; allow app q for Sideband return
+ /* todo; allow app q for Sideband return */
memcpy(&dmSaParam.keyParam,key_params,sizeof(nwalSecKeyParams_t));
retValue = nwal_setDMSecAssoc(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
(nwal_AppId)appId,
if(retValue != nwal_OK)
{
*perr = NETAPI_ERR_NWAL_ERR0;
- printf (">netapi_sec - ERROR: nwal_setDMSecAssoc returned Error Code %d\n",
+ Debug_printf ("netapi_secAddSA: nwal_setDMSecAssoc() returned Error Code %d\n",
retValue);
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);
+ Debug_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),
********************************************************************/
void netapi_secInflowMode(int iface, NETCP_CFG_SA_T sa, int on)
{
- /*todo */ /* FUTURE */
- printf(">netapi_sec: dynamic switch between inflow and sideband is not functional yet\n");
+ /* NOT_IMPLEMENTED */
+ Debug_printf("netapi_secInflowMode: dynamic switch between inflow and sideband is NOT_IMPLEMENTED\n");
}
/********************************************************************
if(handle_inflow)
{
- //get a transaction id
+ /* get a transaction id */
pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
if (!pTransInfo)
{
@@ -368,13 +356,11 @@ static void netapi_secDelSA_internal(NETAPI_T h,int iface_no, NETCP_CFG_SA_T sa
else if(retValue != nwal_OK)
{
*perr = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: netapi_secDelSA_internal returned Error Code %d\n",
+ Debug_printf (">netcp cfg - ERROR: netapi_secDelSA_internal returned Error Code %d\n",
retValue);
netapip_FreeTransInfo(pTransInfo);
netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
}
- //wait here until its done since scheduler isn't running yet most likely..
- // todo: make this handled by scheduler poll later ??
if((trans_id != NWAL_TRANSID_SPIN_WAIT)&&(have_to_wait))
{
n->nwal_local.numPendingCfg++;
while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
(pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
{
- // if response is there, then this poll squirts out in the CTl poll callback,
- // which handles the rest (including decrmenting #pending!!
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
}
if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
@@ -392,12 +376,12 @@ static void netapi_secDelSA_internal(NETAPI_T h,int iface_no, NETCP_CFG_SA_T sa
*perr = NETAPI_ERR_PA_FW;
if (!flags)
netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context, tunnelId);
- printf (">netapi_sec - ERROR returned by NETCP PA firmware %d\n",
+ Debug_printf (">netapi_sec - ERROR returned by NETCP PA firmware %d\n",
*perr);
return;
}
}
- printf (">netapi sec: inflow tunnel %d (iface %d) deleted\n",tunnelId,iface_no);
+ Debug_printf (">netapi sec: inflow tunnel %d (iface %d) deleted\n",tunnelId,iface_no);
netapip_FreeTransInfo(pTransInfo);
}
if (handle_sideband)
@@ -407,15 +391,15 @@ static void netapi_secDelSA_internal(NETAPI_T h,int iface_no, NETCP_CFG_SA_T sa
if(retValue != nwal_OK)
{
*perr = NETAPI_ERR_NWAL_ERR0;
- printf (">netapi_sec - ERROR: nwal_delDMSA returned Error Code %d\n",
+ Debug_printf (">netapi_sec - ERROR: nwal_delDMSA returned Error Code %d\n",
retValue);
}
else
- printf(">netapi_sec: Sideband SA deleted\n");
+ Debug_printf(">netapi_sec: Sideband SA deleted\n");
}
- //zap the entry
+ /* zap the entry */
if (!flags)
netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context, tunnelId);
}
@@ -438,11 +422,12 @@ void netapi_secDelSA(NETAPI_T h,int iface_no, NETCP_CFG_SA_T sa_app_id, int *p
********************************************************************/
NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the netapi handle
NETCP_CFG_SA_T sa, //tunnel to attach to
- nwal_IpType ipType, //V4 or V6
- nwalIpAddr_t * src_ip_addr, //src (from where)
- nwalIpAddr_t * dst_ip_addr, //dst (us)
- nwalIpOpt_t * ip_qualifiers, //other qualifiers
+ nwal_IpType ipType, //V4 or V6
+ nwalIpAddr_t * src_ip_addr, //src (from where)
+ nwalIpAddr_t * dst_ip_addr, //dst (us)
+ nwalIpOpt_t * ip_qualifiers, //other qualifiers
NETCP_CFG_ROUTE_HANDLE_T route, //Optional route
+ void * user_data, // optional user specified data associated with policy
int * perr)
{
NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
@@ -467,10 +452,15 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the netapi handle
CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */
QMSS_PARAM_NOT_SPECIFIED /* Use default queue configured to NWAL if packet is routed to host */
};
- void * sa_handle = NULL;
+ void * sa_handle = NULL;
*perr =0;
- if ((!n) ) {*perr = NETAPI_ERR_BAD_INPUT; return -1;}
+
+ if ((!n) )
+ {
+ *perr = NETAPI_ERR_BAD_INPUT;
+ return -1;
+ }
sa_handle = netcp_cfgp_get_sa_handles(&netapi_get_global()->nwal_context,tunnelId,&blah);
if (!sa_handle)
return -1;
}
- //get a transaction id
+ /* get a transaction id */
pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
if (!pTransInfo)
{
netcp_cfgp_build_route(route,&createParam.appRxPktFlowId,
&createParam.appRxPktQueue);
}
- //reserve a slot
+ /* reserve a slot */
policyId = netcp_cfgp_find_policy_slot(&netapi_get_global()->nwal_context,
tunnelId);
if (policyId <0)
}
appId |= (policyId<<8);
- //fire off config message
-
+ /* fire off config message */
retValue = nwal_setSecPolicy (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
trans_id,
(nwal_AppId) appId,
if(retValue != nwal_OK)
{
*perr = NETAPI_ERR_NWAL_ERR0;
- printf (">netapi sec - ERROR: nwal_setPolicy returned Error Code %d\n",
+ Debug_printf (">netapi sec - ERROR: nwal_setPolicy returned Error Code %d\n",
retValue);
netapip_FreeTransInfo(pTransInfo);
@@ -529,36 +518,31 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the netapi handle
return -1;
}
- //wait here until its done since scheduler isn't running yet most likely..
- // todo: make this handled by scheduler poll later ??
if(trans_id != NWAL_TRANSID_SPIN_WAIT)
{
n->nwal_local.numPendingCfg++;
while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
(pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
{
- // if response is there, then this poll squirts out in the CTl poll callback,
- // which handles the rest (including decrmenting #pending!!
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
}
if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
{
netapip_FreeTransInfo(pTransInfo);
*perr = NETAPI_ERR_PA_FW;
- printf (">netapi_sec - ERROR2: netapi_secAddRxPolicy returned Error Code %d\n",
+ Debug_printf (">netapi_sec - ERROR2: netapi_secAddRxPolicy returned Error Code %d\n",
*perr);
netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context,policyId);
return -1;
}
}
- printf (">netapi sec: SA %d added to tunnel %d mac %d\n", policyId, tunnelId, iface_no);
+ Debug_printf (">netapi sec: SA %d added to tunnel %d mac %d\n", policyId, tunnelId, iface_no);
- //todo: the sideband i/f
-
- //save stuff
+ /* save stuff */
netcp_cfgp_insert_policy(&netapi_get_global()->nwal_context,
policyId,
- (void *) pTransInfo->handle);
+ (void *) pTransInfo->handle,
+ user_data);
netapip_FreeTransInfo(pTransInfo);
return (appId);
}
}
*perr =0;
- //get a transaction id
+ /* get a transaction id */
pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
if (!pTransInfo)
{
pTransInfo->inUse = nwal_TRUE;
pTransInfo->netapi_handle = h;
- //issue request
+ /* issue request */
retValue = nwal_delSecPolicy(
((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
trans_id,
@@ -606,28 +590,25 @@ static void netapi_secDelRxPolicy_internal(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T
if(retValue != nwal_OK)
{
*perr = NETAPI_ERR_NWAL_ERR0;
- printf (">netapi sec - ERROR: netapi_secDelRxPolicy_internal returned Error Code %d\n",
+ Debug_printf (">netapi sec - ERROR: netapi_secDelRxPolicy_internal returned Error Code %d\n",
retValue);
netapip_FreeTransInfo(pTransInfo);
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 ??
+
if(trans_id != NWAL_TRANSID_SPIN_WAIT)
{
n->nwal_local.numPendingCfg++;
while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
(pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
{
- // if response is there, then this poll squirts out in the CTl poll callback,
- // which handles the rest (including decrmenting #pending!!
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
}
if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
{
netapip_FreeTransInfo(pTransInfo);
*perr = NETAPI_ERR_PA_FW;
- printf (">netapi_sec - ERROR2: netapi_secDelRxPolicy_internal returned Error Code %d\n",
+ Debug_printf (">netapi_sec - ERROR2: netapi_secDelRxPolicy_internal returned Error Code %d\n",
*perr);
//zap the entry
if (!flags)
}
}
- printf (">netapi sec: policy %d (iface %d) deleted\n",policyId,(policy_app_id&0xff));
+ Debug_printf (">netapi sec: policy %d (iface %d) deleted\n",policyId,(policy_app_id&0xff));
netapip_FreeTransInfo(pTransInfo);
- //zap the entry
+ /* zap the entry */
if (!flags)
{
netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context, policyId);
index 74e74893e55f08d67cd63212ed1a080ddbc4c24d..a39fb9682711256781d3560a7f7fd520dacc8fe4 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
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+
#include "netapi.h"
-//#include "netcp_cfg.h"
-#include "netapi_loc.h"
-#include "netcp_cfg.h"
+
+
/******************************************************************
********************Netapi internal*************************************
*******************************************************************/
hplib_mSpinLockUnlock(&netcp_cfg_lock);
/* trouble. need to wait for one to free up*/
/* to do: handle this by forcing a poll of cntrl queue*/
- printf(">netcp_cfg: trying to get free transaction slot but all full!!\n");
+ Debug_printf(">netcp_cfg: trying to get free transaction slot but all full!!\n");
return NULL;
}
********************************************************************/
void netcp_cfgp_insert_policy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
int policy_slot, //we 'reserved it already'
- void * handle)
+ void * handle,
+ void * user_data)
{
p->policy[policy_slot].in_use=1;
p->policy[policy_slot].nwal_handle = handle;
+ p->policy[policy_slot].user_data = user_data;
return;
}
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);
+ Debug_printf("netcp_cfgp_insert_sa: swInfo0 0x%x, swInfo1: 0x%x, user data: %d\n",
+ p->tunnel[sa_slot].swInfo0, p->tunnel[sa_slot].swInfo1, (uint32_t)p->tunnel[sa_slot].user_data);
if (dmPSCmdInfo)
{
nwalIpOpt_t *ip_qualifiers,
int iface_no,
int ip_slot, //we 'reserved it already'
- void * handle)
+ void * handle,
+ void * user_data)
{
p->ips[ip_slot].in_use=1;
memcpy(&p->ips[ip_slot].ip_addr, ip_addr, sizeof(nwalIpAddr_t));
memset(&p->ips[ip_slot].ip_qualifiers, 0, sizeof(nwalIpOpt_t));
p->ips[ip_slot].ip_type = ipType;
p->ips[ip_slot].nwal_handle = handle;
+ p->ips[ip_slot].user_data = user_data;
+
}
/***************************************************************************
@@ -513,10 +515,10 @@ static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char
p->interfaces[iface_no].state = state;
//todo p->interfaces[iface_no].vlan = vlan;
p->interfaces[iface_no].nwal_handle = handle; //save handle assoicated with this rule
- printf("netcp_cfgp_insert_mac, global context 0x%x\n", p);
+ Debug_printf("netcp_cfgp_insert_mac, global context 0x%x\n", p);
}
else
- printf(">netcp_cfg insert interface # out of range %d\n",iface_no);
+ Debug_printf(">netcp_cfg insert interface # out of range %d\n",iface_no);
}
int class_type,
void * L2_handle,
void * L3_handle,
- void * L4_handle)
+ void * L4_handle,
+ void * user_data)
{
p->classi[class_slot].in_use=1;
p->classi[class_slot].nwal_L2_handle = L2_handle;
p->classi[class_slot].nwal_L3_handle = L3_handle;
p->classi[class_slot].nwal_L4_handle = L4_handle;
p->classi[class_slot].class_type = class_type;
+ p->classi[class_slot].user_data = user_data;
+
}
/*******************************************************************************
{
pTransInfo->inUse = nwal_FALSE;
*err = NETAPI_ERR_BUSY; //no resources??
- printf("> netcp_cfg reqStats failed, err=%d\n",ret);
+ Debug_printf("> netcp_cfg reqStats failed, err=%d\n",ret);
}
}
if(retValue != nwal_OK)
{
*err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: nwal_setMacIface returned Error Code %d\n",
+ Debug_printf (">netcp cfg - ERROR: nwal_setMacIface returned Error Code %d\n",
retValue);
netapip_FreeTransInfo(pTransInfo);
return -1;
{
netapip_FreeTransInfo(pTransInfo);
*err = NETAPI_ERR_PA_FW;
- printf (">netcp_cfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
+ Debug_printf (">netcp_cfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
*err);
return -1;
}
}
- printf (">netcp cfg: MAC i/f %d added\n", iface_no);
+ Debug_printf (">netcp cfg: MAC i/f %d added\n", iface_no);
netcp_cfgp_insert_mac(&netapi_get_global()->nwal_context,
p_mac, iface_no, state,vlan,
(void *) pTransInfo->handle);
if(ret != nwal_OK)
{
*err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+ Debug_printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
ret);
netapip_FreeTransInfo(pTransInfo);
return;
{
netapip_FreeTransInfo(pTransInfo);
*err = NETAPI_ERR_PA_FW;
- printf (">netcp_cfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
+ Debug_printf (">netcp_cfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
*err);
netcp_cfgp_delete_mac(&netapi_get_global()->nwal_context, iface_no);
return;
}
}
- printf (">netcp cfg: MAC i/f %d deleted\n",iface_no);
+ Debug_printf (">netcp cfg: MAC i/f %d deleted\n",iface_no);
netapip_FreeTransInfo(pTransInfo);
//zap the entry
netcp_cfgp_delete_mac(&netapi_get_global()->nwal_context, iface_no);
nwalIpAddr_t * ip_addr,
nwalIpOpt_t * ip_qualifiers,
NETCP_CFG_ROUTE_HANDLE_T route, //NULL for default
+ void * user_data,
int * err,
int flag) //TRUE: add IP to iface. False: add IP as part of classifier
{
if (iface_no != NETCP_CFG_NO_INTERFACE)
{
- printf("netcp_cfgAddIpInternal, in_use %d\n", netapi_get_global()->nwal_context.interfaces[iface_no].in_use);
- printf("netcp-cfgAddIpInternal, p 0x%x\n", &netapi_get_global()->nwal_context);
+ Debug_printf("netcp_cfgAddIpInternal, in_use %d\n", netapi_get_global()->nwal_context.interfaces[iface_no].in_use);
+ Debug_printf("netcp-cfgAddIpInternal, p 0x%x\n", &netapi_get_global()->nwal_context);
if(netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
{
n_handle = netapi_get_global()->nwal_context.interfaces[iface_no].nwal_handle;
if(retValue != nwal_OK)
{
*err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg: nwal_setIP returned Error Code %d\n",
+ Debug_printf (">netcp cfg: nwal_setIP returned Error Code %d\n",
retValue);
netapip_FreeTransInfo(pTransInfo);
//zap the entry
{
netapip_FreeTransInfo(pTransInfo);
*err = NETAPI_ERR_PA_FW;
- printf (">netcp_cfgAddIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
+ Debug_printf (">netcp_cfgAddIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
return -1;
}
}
if (flag)
{
- printf (">netcp cfg: IP added to interface %d (slot%d)\n", iface_no, ip_slot);
+ Debug_printf (">netcp cfg: IP added to interface %d (slot%d)\n", iface_no, ip_slot);
netcp_cfgp_insert_ip(&netapi_get_global()->nwal_context, ipType,
ip_addr, ip_qualifiers, iface_no, ip_slot,
- pTransInfo->handle);
+ pTransInfo->handle, user_data);
}
temp = (NETCP_CFG_IP_T) pTransInfo->handle;
nwalIpAddr_t * ip_addr,
nwalIpOpt_t * ip_qualifiers,
NETCP_CFG_ROUTE_HANDLE_T route, //NULL for default
+ void * user_data,
int * err
)
{
return netcp_cfgAddIpInternal(h, iface_no, ipType, ip_addr,
- ip_qualifiers, route, err, 1);
+ ip_qualifiers, route, user_data,err, 1);
}
/********************************************************************
@@ -1087,7 +1094,7 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no, nwal_IpType ipType
if(ret != nwal_OK)
{
*err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+ Debug_printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
ret);
netapip_FreeTransInfo(pTransInfo);
return ;
@@ -1108,14 +1115,14 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no, nwal_IpType ipType
{
netapip_FreeTransInfo(pTransInfo);
*err = NETAPI_ERR_PA_FW;
- printf (">netcp_cfgDelIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
+ Debug_printf (">netcp_cfgDelIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
return;
}
}
if (flag)
- printf (">netcp cfg: attached IP deleted\n");
+ Debug_printf (">netcp cfg: attached IP deleted\n");
else
- printf (">netcp cfg: Classifier IP rule deleted\n");
+ Debug_printf (">netcp cfg: Classifier IP rule deleted\n");
netapip_FreeTransInfo(pTransInfo);
NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
NETCP_CFG_CLASSIFIER_T *p_class,
NETCP_CFG_ROUTE_HANDLE_T route,
- int action, int * err)
+ int action, void * user_data, int * err)
{
NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
void * l3_handle=NULL; //ip handle
switch(p_class->classType)
{
default:
- printf(">netcp_cfg : classifier type %d not supported\n",p_class->classType);
+ Debug_printf(">netcp_cfg : classifier type %d not supported\n",p_class->classType);
break;
case(NETCP_CFG_CLASS_TYPE_L3_L4):
case(NETCP_CFG_CLASS_TYPE_L4):
p_class->u.c_l3_l4.ip_addr,
p_class->u.c_l3_l4.ip_qualifiers,
p_class->u.c_l3_l4.p_fail_route,
+ user_data,
&ret,
FALSE);
if(!ret)
if(retValue != nwal_OK)
{
*err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+ Debug_printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
retValue);
netapip_FreeTransInfo(pTransInfo);
netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot);
netapip_FreeTransInfo(pTransInfo);
*err = NETAPI_ERR_PA_FW;
netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot);
- printf (">netcp_cfgAddClass - ERROR returned by NETCP PA firmware %d\n", *err);
+ Debug_printf (">netcp_cfgAddClass - ERROR returned by NETCP PA firmware %d\n", *err);
return -1;
}
}
- printf (">netcp cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface_no, ip_slot, class_slot);
+ Debug_printf (">netcp cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface_no, ip_slot, class_slot);
netcp_cfgp_insert_class(&netapi_get_global()->nwal_context,
class_slot,
p_class->classType,
NULL, //L2 we have
(p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4? l3_handle : NULL),
- pTransInfo->handle);
+ pTransInfo->handle,
+ user_data);
netapip_FreeTransInfo(pTransInfo);
return classHandle;
if(retValue != nwal_OK)
{
*err = NETAPI_ERR_NWAL_ERR0;
- printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n", retValue);
+ Debug_printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n", retValue);
netapip_FreeTransInfo(pTransInfo);
goto ERR_netcp_cfgDelClass; /* todo: what about the L3? */
}
{
netapip_FreeTransInfo(pTransInfo);
*err = NETAPI_ERR_PA_FW;
- printf (">netcp_cfgDelClass - ERROR returned by NETCP PA firmware %d\n", *err);
+ Debug_printf (">netcp_cfgDelClass - ERROR returned by NETCP PA firmware %d\n", *err);
goto ERR_netcp_cfgDelClass;
}
- printf (">netcp cfg: Classifer deleted\n");
+ Debug_printf (">netcp cfg: Classifer deleted\n");
pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
pTransInfo->inUse = nwal_FALSE;
//update slot
retVal = netcp_cfgp_insert_flow(&netapi_get_global()->nwal_context, slot, (void*) FlowHnd);
- printf(">netcp cfg: flow %d created\n", ((NETCP_CFG_FLOW_T *) retVal)->flowid);
+ Debug_printf(">netcp cfg: flow %d created\n", ((NETCP_CFG_FLOW_T *) retVal)->flowid);
return ( retVal);
}
Cppi_closeRxFlow( (Cppi_FlowHnd) handle);
netcp_cfgp_delete_flow(&netapi_get_global()->nwal_context, slot);
- printf(">netcp cfg: flow %d deleted\n", ((NETCP_CFG_FLOW_T *) f)->flowid);
+ Debug_printf(">netcp cfg: flow %d deleted\n", ((NETCP_CFG_FLOW_T *) f)->flowid);
return;
}
if(ret != nwal_OK)
{
- printf (">netcp cfg : netapi_NWALCmdCallBack returned Error Code %d for trans_id %d\n",
+ Debug_printf (">netcp cfg : netapi_NWALCmdCallBack returned Error Code %d for trans_id %d\n",
ret, trans_id);
// update error code that is fialed in p_trans */
//todo: atomic inc
}
default:
{
- printf ("netcp cfg> Invalid transaction type %d for trans_id: %d\n",
+ Debug_printf ("netcp cfg> Invalid transaction type %d for trans_id: %d\n",
p_trans->transType,trans_id);
break;
}
diff --git a/ti/runtime/netapi/src/pdkv2/netapi_navig.c b/ti/runtime/netapi/src/pdkv2/netapi_navig.c
index 83e2b7d9eb2ecd16ab6ef17380da0e4bdee3b0fd..263f847f78457b8b46d9aaba4d1ac38431ae9673 100755 (executable)
*
* REVISION HISTORY:
*
- * Copyright (c) Texas Instruments Incorporated 2010-2012
+ * Copyright (c) Texas Instruments Incorporated 2013
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
***********************************************/
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
+
+#include "netapi.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <ti/csl/cslr_device.h>
#include <ti/drv/qmss/qmss_qm.h>
-#include "netapi.h"
-#include "hplib.h"
//pull in device config for qmss, cppi
#include "qmss_device.c"
result = Cppi_init (netapi_cppiGblCfgParams);
if (result != CPPI_SOK)
{
- printf (">function cppi_init: Cppi_init failed with error code %d\n", result);
+ Debug_printf (">function cppi_init: Cppi_init failed with error code %d\n", result);
return (-1);
}
return 1;
result = Qmss_init (&qmssInitConfig, &netapi_qmssGblCfgParams);
if (result != QMSS_SOK) {
- printf (">function init_qm: qmss_Init failed with error code %d\n", result);
+ Debug_printf (">function init_qm: qmss_Init failed with error code %d\n", result);
return (nwal_FALSE);
}
return 1;
diff --git a/ti/runtime/netapi/src/pdkv3/netapi_navig.c b/ti/runtime/netapi/src/pdkv3/netapi_navig.c
index 3888ba7929168c9c17e0a2db7585d7838b520d8a..aaffb217410dc2539a9523671337b9346c07c886 100755 (executable)
*
* REVISION HISTORY:
*
- * Copyright (c) Texas Instruments Incorporated 2010-2012
+ * Copyright (c) Texas Instruments Incorporated 2013
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
***********************************************/
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
+
+#include "netapi.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <ti/csl/cslr_device.h>
#include <ti/drv/qmss/qmss_qm.h>
-#include "netapi.h"
-#include "hplib.h"
//pull in device config for qmss, cppi
#include "qmss_device.c"
(uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs);
result = Cppi_init (&netapi_cppiGblCfgParams);
if (result != CPPI_SOK) {
- printf ("function testNwGlobCppiInit: Cppi_init failed with error code %d\n", result);
+ Debug_printf ("function testNwGlobCppiInit: Cppi_init failed with error code %d\n", result);
return (-1);
}
return (1);
result = Qmss_init (&qmssInitConfig, &netapi_qmssGblCfgParams);
if (result != QMSS_SOK)
{
- printf ("function testNwGlobQmInit: qmss_Init failed with error code %d\n", result);
+ Debug_printf ("function testNwGlobQmInit: qmss_Init failed with error code %d\n", result);
return (nwal_FALSE);
}
return 1;
index cc145c7f4513600253ba36791e48f0e4bc365be4..6636d013f86a7a890dff1ba1b2e814926f5d5c7f 100755 (executable)
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
********************************/
-#include <stdio.h>
-#include <stdlib.h>
+
#include <unistd.h>
-#include <string.h>
#include "netapi.h"
#include "pktio.h"
-#include "netapi_util.h"
+
* 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)
+static int pktio_sendL4CkSumCryptPort(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;
@@ -115,7 +113,7 @@ static int pktio_send_L4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt
swInfo1,
0);
- printf("pktio_send_L4CkSumCryptoPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1);
+ Debug_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,
@@ -154,6 +152,12 @@ static int pktio_send_CryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO
swInfo0,
swInfo1,
0);
+ Debug_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;
}
@@ -167,7 +171,7 @@ static int pktio_send_CryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO
* 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)
+static int pktio_sendL4CkSumAHCryptPort(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;
@@ -191,7 +195,7 @@ static int pktio_send_L4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *p
pTxPktInfo->saAhMacSize,
pTxPktInfo->enetPort);
- printf("pktio_send_L4CkSumAHCryptoPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1);
+ Debug_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,
@@ -210,7 +214,7 @@ static int pktio_send_L4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *p
* 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)
+static int pktio_sendAHCryptPort(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;
@@ -251,14 +255,14 @@ static int pktio_send_AHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKT
* 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)
+static int pktio_sendL4CkSumPort(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",
+ Debug_printf("pktio_send_L4CkSumPort: non-ipsec packet sent with L4 chksum\n");
+ Debug_printf("pktio_send_L4CkSumPort, l4offbytes: %d, l4HdrLen: %d, enetPort %d\n",
pTxPktInfo->l4OffBytes,
pTxPktInfo->l4HdrLen,
pTxPktInfo->enetPort);
@@ -284,7 +288,7 @@ static int pktio_send_L4CkSumPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKT
* 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)
+static int pktio_sendPort(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;
/* get a free channel handle */
p=pktiop_get_free_channel_slot(n);
- if (!p) {*err = PKTIO_NOMEM; return (p); }
+ if (!p) {*err = NETAPI_ERR_NOMEM; return (p); }
p->back = n;
p->cb = cb;
QMSS_PARAM_NOT_SPECIFIED, &isAllocated);
if (p->q == (Qmss_QueueHnd) NULL)
{
- printf(">pktio_create: queueOpen failed\n");
+ Debug_printf(">pktio_create: queueOpen failed\n");
p->inuse=0;
*err= NETAPI_ERR_QLLD; ///queue lld error
return NULL;
p=pktiop_get_free_channel_slot(n);
- if (!p) {*err = PKTIO_NOMEM; return (p); }
+ if (!p) {*err = NETAPI_ERR_NOMEM; return (p); }
((NETAPI_HANDLE_T *)n)->n_pktios+=1;
p->inuse= PKTIO_INUSE;
hplib_mSpinLockUnlock(&pktio_lock);
if (!p_qnum )
{
- printf(">pktio_open: can't find %s\n",name);
+ Debug_printf(">pktio_open: can't find %s\n",name);
p->inuse=0;
*err= NETAPI_ERR_NOTFOUND; ///queue lld error
return NULL;
p_qnum->qNum , &isAllocated);
if (p->q == (Qmss_QueueHnd) NULL)
{
- printf(">pktio_create: queueOpen failed\n");
+ Debug_printf(">pktio_create: queueOpen failed\n");
p->inuse=0;
*err= NETAPI_ERR_QLLD; ///queue lld error
return NULL;
}
p->qInfo = Qmss_getQueueNumber(p->q);
- printf("pktio_open: queueMgr %d, queueNum; %d\n", p->qInfo.qMgr, p->qInfo.qNum);
+ Debug_printf("pktio_open: queueMgr %d, queueNum; %d\n", p->qInfo.qMgr, p->qInfo.qNum);
if (p_cfg->flags2 & PKTIO_PKT)
{
p->use_nwal = PKTIO_4_ADJ_NWAL; //additonal RX q for nwal
p->_poll = pktio_poll_nwal_adj;
p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n);
- printf("pktio_open: nwalInstanceHandle 0x%x\n", p->nwalInstanceHandle);
+ Debug_printf("pktio_open: nwalInstanceHandle 0x%x\n", p->nwalInstanceHandle);
}
else if (p_cfg->flags2 & PKTIO_SB)
{
strlen(name)<PKTIO_MAX_NAME ?
strlen(name):PKTIO_MAX_NAME);
- printf("pktio_open: returning with sucess for name %s\n", p->name);
+ Debug_printf("pktio_open: returning with sucess for name %s\n", p->name);
return p;
}
switch (p_cfg->fast_path_cfg.fp_send_option)
{
case (PKTIO_FP_ESP_L4CKSUM_PORT):
- p->_send = pktio_send_L4CkSumCryptPort;
+ p->_send = pktio_sendL4CkSumCryptPort;
break;
case (PKTIO_FP_AH_L4CKSUM_PORT):
- p->_send = pktio_send_L4CkSumAHCryptPort;
+ p->_send = pktio_sendL4CkSumAHCryptPort;
break;
case (PKTIO_FP_ESP_PORT):
p->_send = pktio_send_CryptPort;
break;
case (PKTIO_FP_AH_PORT):
- p->_send = pktio_send_AHCryptPort;
+ p->_send = pktio_sendAHCryptPort;
break;
case (PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT):
- p->_send = pktio_send_Port;
+ p->_send = pktio_sendPort;
break;
case (PKTIO_FP_L4CKSUM_PORT):
- p->_send = pktio_send_L4CkSumPort;
+ p->_send = pktio_sendL4CkSumPort;
break;
default:
break;
break;
case(PKTIO_DIVERT):
default:
- printf(">pktio_control: pktio_control op %d not implemented\n",p_control->op);
+ Debug_printf(">pktio_control: pktio_control op %d not implemented\n",p_control->op);
*err= NETAPI_ERR_NOT_IMPLEMENTED;
break;
}
index ca5834c0214766e9d031bcbb27df8982d8fe4cd1..f899c7d88075a3e870f1b08a7d4e2bb087231105 100755 (executable)
trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
}
else
- printf("build_sa_db(): invalid encryption/authentication combination selected\n");
+ Debug_printf("build_sa_db(): invalid encryption/authentication combination selected\n");
- //printf("sa_build_db(): authOffset %d, innerIpOffset %d, encOffset %d\n", sa_info[i].tx_payload_info.authOffset, sa_info[i].inner_ip_offset, sa_info[i].tx_payload_info.encOffset);
- printf("build_sa_db spi 0x%x\n", spi);
+ //Debug_printf("sa_build_db(): authOffset %d, innerIpOffset %d, encOffset %d\n", sa_info[i].tx_payload_info.authOffset, sa_info[i].inner_ip_offset, sa_info[i].tx_payload_info.encOffset);
+ Debug_printf("build_sa_db spi 0x%x\n", spi);
}
err= getrlimit(RLIMIT_STACK,&rl);
- if (!err) printf(" stack limit = %d\n",rl.rlim_cur); else printf("getrlimit failed\n");
+ if (!err) Debug_printf(" stack limit = %d\n",rl.rlim_cur); else Debug_printf("getrlimit failed\n");
memset(&sa_info, 0, sizeof(sa_info));
ourHeap = Pktlib_findHeapByName("netapi");
if (!ourHeap)
{
- printf("Pktlib_findHeapByName() fail\n");
+ Debug_printf("Pktlib_findHeapByName() fail\n");
exit(1);
}
our_chan=pktio_create(netapi_handle,"our1stq",(PKTIO_CB) recv_cb_bench, &our_chan_cfg,&err);
if (!our_chan)
{
- printf("pktio create failed err=%d\n",err);
+ Debug_printf("pktio create failed err=%d\n",err);
exit(1);
}
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);
+ 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)
{
- printf("pktio open RX failed err=%d\n",err);
+ Debug_printf("pktio open RX failed err=%d\n",err);
exit(1);
}
/* create a pktio channel for specially classified pkts */
netcp_rx_chan2= pktio_create(netapi_handle, "classq", (PKTIO_CB) recv_cb, &netcp_rx_cfg2, &err);
- if (!netcp_rx_chan2) {printf("pktio create RX2 failed err=%d\n",err); exit(1);}
+ 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)
{
- printf("pktio open SB TX failed err=%d\n",err);
+ 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)
{
- printf("pktio open SB RX failed err=%d\n",err);
+ Debug_printf("pktio open SB RX failed err=%d\n",err);
exit(1);
}
- printf("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
+ 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);
- if (!our_sched) {printf("sched create failed\n"); exit(1);}
+ if (!our_sched) {Debug_printf("sched create failed\n"); exit(1);}
//#define PROMISCUOUS
#define ETH0 0
(NETCP_CFG_VLAN_T ) NULL , //future
1,
&err);
- if (err) {printf("addmac0 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addmac0 failed %d\n",err); exit(1); }
//attach an IP to this interface
ip_rule0[0]=netcp_cfgAddIp(
(NETCP_CFG_ROUTE_HANDLE_T) NULL,
&err
);
- if (err) {printf("addip0 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addip0 failed %d\n",err); exit(1); }
//create a 2nd mac instance
netcp_cfgCreateMacInterface(
(NETCP_CFG_VLAN_T ) NULL , //future
1,
&err);
- if (err) {printf("addmac1 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addmac1 failed %d\n",err); exit(1); }
//attach an IP to this interface
ip_rule1[0]=netcp_cfgAddIp(
(NETCP_CFG_ROUTE_HANDLE_T) NULL,
&err
);
- if (err) {printf("addip1 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addip1 failed %d\n",err); exit(1); }
#endif
NULL,
NETCP_CFG_ACTION_TO_SW,
&err);
- if (err) {printf("addclass0 failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addclass0 failed %d\n",err); exit(1);}
class_1_cfg.u.c_l4.ip = ip_rule0[0];
class_1 = netcp_cfgAddClass(netapi_handle,
NULL,
NETCP_CFG_ACTION_TO_SW,
&err);
- if (err) {printf("addclass1 failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addclass1 failed %d\n",err); exit(1);}
//3rd classifier has a different IP and route
//security stuff
p_trie_sa = trie_new();
- if (!p_trie_sa) {printf("trie alloc for SA failed\n"); exit(1);}
+ if (!p_trie_sa) {Debug_printf("trie alloc for SA failed\n"); exit(1);}
count = 0;
(NETCP_CFG_VLAN_T ) NULL , //future
1,
&err);
- if (err) {printf("addmac0 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addmac0 failed %d\n",err); exit(1); }
else
{
- printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
+ Debug_printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
config.mac0[3]++;
}
}
(NETCP_CFG_ROUTE_HANDLE_T) NULL,
&err
);
- if (err) {printf("addip0 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addip0 failed %d\n",err); exit(1); }
else
{
- printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
+ Debug_printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
config.ip0.ipv4[3]++;
}
build_sa_db(i);
count++;
- printf("main: calling netapi_secAddSA for rx, count = %d\n", count);
+ Debug_printf("main: calling netapi_secAddSA for rx, count = %d\n", count);
sa_info[i].rx_tunnel = netapi_secAddSA(
netapi_handle,
config.ipsec_if_no, //iface #0
&(sa_info[i].rx_data_mode_handle),
&(sa_info[i].rx_inflow_mode_handle),
&err);
- //if (err) {printf("addRxSa failed %d\n",err); exit(1);}
- if (err) {printf("addRxSa failed %d\n",err);}
+ //if (err) {Debug_printf("addRxSa failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addRxSa failed %d\n",err);}
}
memcpy(&(tx_sa[0].src), &config.local_ipsec_ip,4);
memcpy(&(tx_sa[0].dst), &config.remote_ipsec_ip,4);
count++;
- printf("main: calling netapi_secAddSA for tx, count = %d\n", count);
+ Debug_printf("main: calling netapi_secAddSA for tx, count = %d\n", count);
sa_info[i].tx_tunnel = netapi_secAddSA( netapi_handle,
0, //iface #0
&tx_sa[0],
&(sa_info[i].tx_data_mode_handle),
&(sa_info[i].tx_inflow_mode_handle),
&err);
- if (err) {printf("addTxSa failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addTxSa failed %d\n",err); exit(1);}
}
#endif
netapi_secDelRxPolicy(netapi_handle, rx_policy[i], &err);
count ++;
//delete tunnels
- printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
+ Debug_printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
netapi_secDelSA(netapi_handle, 0, sa_info[i].rx_tunnel, &err);
//sleep(1);
- //printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
+ //Debug_printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
netapi_secDelSA(netapi_handle, 0, sa_info[i].tx_tunnel, &err);
}
#endif
//delete IPs and MAC Interfacess
for (i = 0; i < IP_CREATE_LOOP_COUNT;i++)
{
- printf("calling netcp_cfgDelIp and for index %d\n", i);
+ Debug_printf("calling netcp_cfgDelIp and for index %d\n", i);
netcp_cfgDelIp(netapi_handle, i, 0, NULL, NULL, ip_rule0[i], &err);
netcp_cfgDelMac(netapi_handle,i,&err);
}
for (i = 0; i < MAC_CREATE_LOOP_COUNT;i++)
{
- printf("calling and netcp_cfgDelMac for index %d\n", i);
+ Debug_printf("calling and netcp_cfgDelMac for index %d\n", i);
netcp_cfgDelMac(netapi_handle,i,&err);
}
#endif
//close pktio channels we opened
- printf("main: calling pktio_close for netcp_tx_chan_esp\n");
+ Debug_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");
+ Debug_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");
+ Debug_printf("main: calling pktio_close for netcp_sb_tx_chan\n");
pktio_close(netcp_sb_tx_chan ,&err);
- printf("main: calling pktio_close for netcp_sb_rx_chan\n");
+ Debug_printf("main: calling pktio_close for netcp_sb_rx_chan\n");
pktio_close(netcp_sb_rx_chan ,&err);
//clear pktio channel we created
index f74b8915dafc4519a1d4a61a46e4c92ab8ee536a..11d63884554ed57baf6a0b56d213b462451a7797 100755 (executable)
{
QUIT=1;
scnt+=1;
- printf(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
- if (scnt > 10) {printf(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");exit(1);}
+ Debug_printf(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
+ if (scnt > 10) {Debug_printf(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");exit(1);}
}
{
tx_sa[0].spi = rx_sa[0].spi = hplib_mAtomic32AddReturn(&spi,1);
- printf("coreid: %d, build_sa_db: spi %d\n", coreid, spi);
+ Debug_printf("coreid: %d, build_sa_db: spi %d\n", coreid, spi);
/* static configuration, will not change */
sa_info[i].tx_payload_info.aadSize = 0;
sa_info[i].tx_payload_info.pAad = NULL;
trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
}
else
- printf("build_sa_db(): invalid encryption/authentication combination selected\n");
+ Debug_printf("build_sa_db(): invalid encryption/authentication combination selected\n");
}
- printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
+ Debug_printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
CPU_ZERO( &cpu_set);
#ifdef CORTEX_A15
scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
if (!scheduler[coreid])
{
- printf("sched create failed for core%d\n",coreid);
+ Debug_printf("sched create failed for core%d\n",coreid);
exit(1);
}
scheduler[coreid]->config.yield = FALSE;
(NETCP_CFG_VLAN_T ) NULL , //future
1,
&err);
- if (err) {printf("addmac0 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addmac0 failed %d\n",err); exit(1); }
else
{
- printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
+ Debug_printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
config.mac0[3]++;
}
}
(NETCP_CFG_ROUTE_HANDLE_T) NULL,
&err
);
- if (err) {printf("addip0 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addip0 failed %d\n",err); exit(1); }
else
{
- printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
+ Debug_printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
config.ip0.ipv4[3]++;
}
//delete IPs and MAC Interfacess
for (i = 0; i < 30;i++)
{
- printf("calling netcp_cfgDelIp and for index %d\n", i);
+ Debug_printf("calling netcp_cfgDelIp and for index %d\n", i);
netcp_cfgDelIp(worker_nh[coreid], i, 0, NULL, NULL, ip_rule0[i], &err);
netcp_cfgDelMac(worker_nh[coreid],i,&err);
}
for (i = 0; i < 30;i++)
{
- printf("calling and netcp_cfgDelMac for index %d\n", i);
+ Debug_printf("calling and netcp_cfgDelMac for index %d\n", i);
netcp_cfgDelMac(worker_nh[coreid],i,&err);
}
#endif
build_sa_db(i);
count++;
- //printf("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid, count);
+ //Debug_printf("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid, count);
sa_info[i].rx_tunnel = netapi_secAddSA(
worker_nh[coreid],
config.ipsec_if_no, //iface #0
&(sa_info[i].rx_data_mode_handle),
&(sa_info[i].rx_inflow_mode_handle),
&err);
- //if (err) {printf("addRxSa failed %d\n",err); exit(1);}
- if (err) {printf("addRxSa failed %d\n",err);}
+ //if (err) {Debug_printf("addRxSa failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addRxSa failed %d\n",err);}
sched_yield();
memcpy(&(tx_sa[0].src), &config.local_ipsec_ip,4);
memcpy(&(tx_sa[0].dst), &config.remote_ipsec_ip,4);
count++;
- //printf("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid, count);
+ //Debug_printf("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid, count);
sa_info[i].tx_tunnel = netapi_secAddSA( worker_nh[coreid],
0, //iface #0
&tx_sa[0],
&(sa_info[i].tx_data_mode_handle),
&(sa_info[i].tx_inflow_mode_handle),
&err);
- if (err) {printf("addTxSa failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addTxSa failed %d\n",err); exit(1);}
sched_yield();
}
sleep(1);
netapi_secDelRxPolicy(worker_nh[coreid], rx_policy[i], &err);
count ++;
//delete tunnels
- printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
+ Debug_printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].rx_tunnel, &err);
//sleep(1);
- //printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
+ //Debug_printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].tx_tunnel, &err);
}
#endif
netapi_schedRun(scheduler[coreid], &err);
- printf(">net_test: core %d worker thread done\n",coreid);
+ Debug_printf(">net_test: core %d worker thread done\n",coreid);
pktio_close(tx_chan, &err);
pktio_close(rx_chan, &err);
pktio_close(sb_tx_chan, &err);
PKTIO_HANDLE_T *sb_tx_chan;
PKTIO_HANDLE_T *sb_rx_chan;
- printf("fast_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
+ Debug_printf("fast_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
#ifdef CORTEX_A15
CPU_SET( coreid, &cpu_set);
hplib_utilSetupCore(coreid, &cpu_set);
scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
if (!scheduler[coreid])
{
- printf("sched create failed for core%d\n",coreid);
+ Debug_printf("sched create failed for core%d\n",coreid);
exit(1);
}
(NETCP_CFG_VLAN_T ) NULL , //future
1,
&err);
- if (err) {printf("addmac0 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addmac0 failed %d\n",err); exit(1); }
else
{
- printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
+ Debug_printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
config.mac0[3]++;
}
}
(NETCP_CFG_ROUTE_HANDLE_T) NULL,
&err
);
- if (err) {printf("addip0 failed %d\n",err); exit(1); }
+ if (err) {Debug_printf("addip0 failed %d\n",err); exit(1); }
else
{
- printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
+ Debug_printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
config.ip0.ipv4[3]++;
}
//delete IPs and MAC Interfacess
for (i = 30; i < IP_CREATE_LOOP_COUNT;i++)
{
- printf("calling netcp_cfgDelIp and for index %d\n", i);
+ Debug_printf("calling netcp_cfgDelIp and for index %d\n", i);
netcp_cfgDelIp(worker_nh[coreid], i, 0, NULL, NULL, ip_rule0[i], &err);
netcp_cfgDelMac(worker_nh[coreid],i,&err);
}
for (i = 30; i < MAC_CREATE_LOOP_COUNT;i++)
{
- printf("calling and netcp_cfgDelMac for index %d\n", i);
+ Debug_printf("calling and netcp_cfgDelMac for index %d\n", i);
netcp_cfgDelMac(worker_nh[coreid],i,&err);
}
#endif
build_sa_db(i);
count++;
- //printf("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid, count);
+ //Debug_printf("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid, count);
sa_info[i].rx_tunnel = netapi_secAddSA(
worker_nh[coreid],
config.ipsec_if_no, //iface #0
&(sa_info[i].rx_data_mode_handle),
&(sa_info[i].rx_inflow_mode_handle),
&err);
- //if (err) {printf("addRxSa failed %d\n",err); exit(1);}
- if (err) {printf("addRxSa failed %d\n",err);}
+ //if (err) {Debug_printf("addRxSa failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addRxSa failed %d\n",err);}
sched_yield();
}
memcpy(&(tx_sa[0].src), &config.local_ipsec_ip,4);
memcpy(&(tx_sa[0].dst), &config.remote_ipsec_ip,4);
count++;
- //printf("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid, count);
+ //Debug_printf("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid, count);
sa_info[i].tx_tunnel = netapi_secAddSA( worker_nh[coreid],
0, //iface #0
&tx_sa[0],
&(sa_info[i].tx_data_mode_handle),
&(sa_info[i].tx_inflow_mode_handle),
&err);
- if (err) {printf("addTxSa failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addTxSa failed %d\n",err); exit(1);}
sched_yield();
}
netapi_secDelRxPolicy(worker_nh[coreid], rx_policy[i], &err);
count ++;
//delete tunnels
- //printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
+ //Debug_printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].rx_tunnel, &err);
//sleep(1);
- //printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
+ //Debug_printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].tx_tunnel, &err);
}
#endif
netapi_schedRun(scheduler[coreid], &err);
- printf(">net_test: core %d worker thread done\n",coreid);
+ Debug_printf(">net_test: core %d worker thread done\n",coreid);
pktio_close(tx_chan, &err);
pktio_close(rx_chan, &err);
pktio_close(sb_tx_chan, &err);
err= getrlimit(RLIMIT_STACK,&rl);
- if (!err) printf(" stack limit = %d\n",rl.rlim_cur); else printf("getrlimit failed\n");
+ if (!err) Debug_printf(" stack limit = %d\n",rl.rlim_cur); else Debug_printf("getrlimit failed\n");
memset(&sa_info, 0, sizeof(sa_info));
ourHeap = Pktlib_findHeapByName("netapi");
if (!ourHeap)
{
- printf("Pktlib_findHeapByName() fail\n");
+ Debug_printf("Pktlib_findHeapByName() fail\n");
exit(1);
}
our_chan=pktio_create(netapi_handle,"our1stq",(PKTIO_CB) recv_cb_bench, &our_chan_cfg,&err);
if (!our_chan)
{
- printf("pktio create failed err=%d\n",err);
+ Debug_printf("pktio create failed err=%d\n",err);
exit(1);
}
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);
+ 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)
{
- printf("pktio open RX failed err=%d\n",err);
+ Debug_printf("pktio open RX failed err=%d\n",err);
exit(1);
}
/* create a pktio channel for specially classified pkts */
netcp_rx_chan2= pktio_create(netapi_handle, "classq", (PKTIO_CB) recv_cb, &netcp_rx_cfg2, &err);
- if (!netcp_rx_chan2) {printf("pktio create RX2 failed err=%d\n",err); exit(1);}
+ 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)
{
- printf("pktio open SB TX failed err=%d\n",err);
+ 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)
{
- printf("pktio open SB RX failed err=%d\n",err);
+ Debug_printf("pktio open SB RX failed err=%d\n",err);
exit(1);
}
- printf("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
+ 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);
- if (!our_sched) {printf("sched create failed\n"); exit(1);}
+ if (!our_sched) {Debug_printf("sched create failed\n"); exit(1);}
//#define PROMISCUOUS
#define ETH0 0
//security stuff
p_trie_sa = trie_new();
- if (!p_trie_sa) {printf("trie alloc for SA failed\n"); exit(1);}
+ if (!p_trie_sa) {Debug_printf("trie alloc for SA failed\n"); exit(1);}
#ifdef MULTI_THREAD
perror( "malloc" );
return -1;
}
- printf( "Starting %d threads...\n", procs );
+ Debug_printf( "Starting %d threads...\n", procs );
if (pthread_create( &thrs[0], NULL, slow_path_thread,
(void *)0 ))
//this thread of execution (main) now just waits on user input
for(;;)
{
- printf(">");
+ Debug_printf(">");
c=getchar();
if (c=='q')
{
break;
}
//else if (c=='s') our_stats_cb(netapi_handle, &netcp_stats);
- else if (c=='h') printf("'q' to quit, 's' for stats, 'h' for help\n");
+ else if (c=='h') Debug_printf("'q' to quit, 's' for stats, 'h' for help\n");
}
//wait for completion
- printf("main task now pending on slow/fast path completion\n");
+ Debug_printf("main task now pending on slow/fast path completion\n");
for (i = 0; i < procs; i++)
pthread_join( thrs[i], NULL );
count = 0;
//close pktio channels we opened
- printf("main: calling pktio_close for netcp_tx_chan_esp\n");
+ Debug_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");
+ Debug_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");
+ Debug_printf("main: calling pktio_close for netcp_sb_tx_chan\n");
pktio_close(netcp_sb_tx_chan ,&err);
- printf("main: calling pktio_close for netcp_sb_rx_chan\n");
+ Debug_printf("main: calling pktio_close for netcp_sb_rx_chan\n");
pktio_close(netcp_sb_rx_chan ,&err);
//clear pktio channel we created
index 46d5a656187bf43742ac9b12a34e001dcf2e3181..a621c65516b30edc8d6437f0130bf1747b763f80 100755 (executable)
NETAPI_SCHED_DURATION|NETAPI_SCHED_CBV, 0, house, 5000000 //every 5000000 poll loops
};
-NETCP_CFG_IP_T ip_rule0;
-NETCP_CFG_IP_T ip_rule1;
+NETCP_CFG_IP_T ip_rule[NET_TEST_MAX_IP];
+NETCP_CFG_MACIF_T mac[NET_TEST_MAX_MAC];
}
else
{
- Debug_printf("flip_and_send_pkt: un-supported IPSEC protocol\n");
+ printf("flip_and_send_pkt: un-supported IPSEC protocol\n");
Pktlib_freePacket(tip);
return;
}
p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa_rx, (char *)p_spi ,4);
if (p_sa_info == NULL)
{
- Debug_printf("flip_and_send_pkt(): trie_lookup() failed\n");
+ printf("flip_and_send_pkt(): trie_lookup() failed\n");
Pktlib_freePacket(tip);
return;
}
p_sa_info_tx = (netTestSA_t *) trie_lookup(p_trie_sa_tx, (char *)&tunnel_id ,4);
if (p_sa_info_tx == NULL)
{
- Debug_printf("flip_and_send_pkt(): trie_lookup() failed\n");
+ printf("flip_and_send_pkt(): trie_lookup() failed\n");
Pktlib_freePacket(tip);
return;
}
}
else
{
- Debug_printf("flip_and_send_pkt: invalid ESP protocol\n");
+ printf("flip_and_send_pkt: invalid ESP protocol\n");
return;
}
p_sa_info = (netTestSA_t*)meta[i].u.rx_sb_meta->appCtxId;
if (p_sa_info == NULL)
{
- Debug_printf("recv_sb_cb(): trie_lookup failed\n");
+ printf("recv_sb_cb(): trie_lookup failed\n");
continue;
}
stats[coreid].tx +=1;
}
}
- else Debug_printf("netapi recv_sb_cb: unknown appiD %x \n",meta[i].u.rx_sb_meta->appId );
+ else printf("netapi recv_sb_cb: unknown appiD %x \n",meta[i].u.rx_sb_meta->appId );
}
}
if(((unsigned int)meta[i].u.rx_meta->rxFlag1 & NWAL_RX_IP_FRAGMENT_PKT) ==
NWAL_RX_IP_FRAGMENT_PKT)
{
- Debug_printf("recv_cb: received fragmented packet\n");
stats[coreid].exceptionPktsFrag+=1;
- }
+ }
else
{
- Debug_printf("recv_cb: received exception packet but not fragmented packet\n");
stats[coreid].exceptionPktsOther+=1;
- }
+ }
continue;
}
//debug: validate descriptor */
if(Pktlib_getNextPacket(tip) != 0)
{
- Debug_printf(" rcv_cb, nexpkt != NULL");
+ printf(" rcv_cb, nexpkt != NULL");
}
if(coreid<TUNE_NETAPI_NUM_CORES)
#ifdef DEBUG_DESC
if (stats[coreid].rx<16)
{
- printf(">rx dmp..");
+ Debug_printf(">rx dmp..");
dump_descr((long *) tip, stats[coreid].rx);
}
else if (stats[coreid].rx>99)
{
- printf(">rx dmp..");
+ Debug_printf(">rx dmp..");
dump_descr((long *) tip,stats[coreid].rx);
}
#endif
//process IP SEC PACKET
if (netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND)
{
-
p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
- p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa_rx, (char *)p_spi ,4);
+ p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa_rx, (char *)p_spi ,4);
if (p_sa_info == NULL)
{
- Debug_printf("recv_cb(): trie_lookup() failed\n");
+ printf("recv_cb(): trie_lookup() failed\n");
continue;
}
}
meta_tx.appCtxId = (nwal_AppId)p_sa_info;
- //Debug_printf("recv_cb appCtxId: %lu\n", meta_tx.appCtxId);
+ //printf("recv_cb appCtxId: %lu\n", meta_tx.appCtxId);
/* post it to netcp sb tx channel*/
meta2.u.tx_sb_meta=&meta_tx;
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);
+ printf("pktio open TX failed err=%d\n",err);
exit(1);
}
else
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);
+ printf("pktio open TX failed err=%d\n",err);
exit(1);
}
else
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);
+ printf("pktio open TX failed err=%d\n",err);
exit(1);
}
else
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);
+ printf("pktio open SB TX failed err=%d\n",err);
exit(1);
}
}
PKTIO_HANDLE_T *rx_chan;
PKTIO_HANDLE_T *sb_rx_chan;
- Debug_printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), thread_num);
+ printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), thread_num);
CPU_ZERO( &cpu_set);
printf("fast_path_thread: settting up for thread number %d\n", thread_num);
scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
if (!scheduler[thread_num])
{
- Debug_printf("sched create failed for core%d\n",thread_num);
+ printf("sched create failed for core%d\n",thread_num);
exit(1);
}
scheduler[thread_num]->config.yield = TRUE;
/* Entry point to scheduler */
netapi_schedRun(scheduler[thread_num], &err);
- Debug_printf(">net_test: core %d worker thread done\n",thread_num);
+ printf(">net_test: core %d worker thread done\n",thread_num);
//pktio_close(tx_chan, &err);
pktio_close(rx_chan, &err);
scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
if (!scheduler[thread_num])
{
- Debug_printf("sched create failed for core%d\n",thread_num);
+ printf("sched create failed for core%d\n",thread_num);
exit(1);
}
FILE * fpr = NULL;
err= getrlimit(RLIMIT_STACK,&rl);
- if (!err) Debug_printf(" stack limit = %d\n",rl.rlim_cur); else Debug_printf("getrlimit failed\n");
+ if (!err) printf(" stack limit = %d\n",rl.rlim_cur); else printf("getrlimit failed\n");
/* install signal handler for ^c */
fpr = fopen(input_file_name, "r");
if (fpr == NULL)
{
- Debug_printf("Error in opening %s input file\n", input_file_name);
+ printf("Error in opening %s input file\n", input_file_name);
exit(1);
}
else
ourHeap = Pktlib_findHeapByName("netapi");
if (!ourHeap)
{
- Debug_printf("Pktlib_findHeapByName() fail\n");
+ printf("Pktlib_findHeapByName() fail\n");
exit(1);
}
open_pktio_tx_channels();
- Debug_printf("net_test: %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
+ printf("net_test: %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
/* create scheduler instance */
our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
- if (!our_sched) {Debug_printf("sched create failed\n"); exit(1);}
+ if (!our_sched) {printf("sched create failed\n"); exit(1);}
/*create net_test MAC interfaces, attach IP to created MAC interfaces */
- create_interfaces(&ip_rule0, &ip_rule1);
+ create_interfaces();
/* 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);}
+ {printf("trie alloc for SA failed\n"); exit(1);}
c=getchar();
if (c=='q') {QUIT=1;break;}
else if (c=='s') our_stats_cb(netapi_handle, &netcp_stats);
- else if (c=='h') Debug_printf("'q' to quit, 's' for stats, 'h' for help\n");
+ else if (c=='h') printf("'q' to quit, 's' for stats, 'h' for help\n");
}
sp_fp_thread_cleanup();
/* cleanup*/
delete_sec_associations();
- delete_interfaces( &ip_rule0, &ip_rule1);
+ delete_interfaces();
/* close pktio channels we opened via open_pktio_tx_channels() */
close_pktio_channels();
index 5422d0b0508023d7263232a664adf9e52cfec4d8..c916411acfa8d32a444561043c2e4d123437635d 100755 (executable)
};
-NETCP_CFG_IP_T ip_rule0;
-NETCP_CFG_IP_T ip_rule1;
+NETCP_CFG_IP_T ip_rule[NET_TEST_MAX_IP];
+NETCP_CFG_MACIF_T mac[NET_TEST_MAX_MAC];
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);
+ //pktio_control(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
}
}
/* open netcp default TX for ESP packets */
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);
+ //pktio_control(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
}
}
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);
+ //pktio_control(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
}
}
}
/*create net_test MAC interfaces, attach IP to created MAC interfaces */
- create_interfaces(&ip_rule0, &ip_rule1);
+ create_interfaces();
/* 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();
//this thread of execution (main) now just waits on user input
for(;;)
{
- printf(">");
+ Debug_printf(">");
c=getchar();
if (c=='q') {QUIT=1;break;}
else if (c=='s') our_stats_cb(netapi_handle, &netcp_stats);
/* cleanup*/
delete_sec_associations();
- delete_interfaces( &ip_rule0, &ip_rule1);
+ delete_interfaces();
/* close pktio channels we opened via open_pktio_tx_channels() */
close_pktio_channels();
@@ -547,7 +547,8 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
if(p_sec)
{
meta_tx2.txFlag1 |= NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO ;
- meta2.sa_handle = (void*)p_sec->tx_tunnel;
+ //meta2.sa_handle = (void*)p_sec->tx_tunnel;
+ meta2.sa_handle=p_sec->tx_inflow_mode_handle;
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;
diff --git a/ti/runtime/netapi/test/net_test_sa_utils.c b/ti/runtime/netapi/test/net_test_sa_utils.c
index 0edb65411cee6598f5f9521af321b2537d3575e6..7bfb14a5f715d52eec741e0f09e5c038f5a3d840 100755 (executable)
}
}
else
- printf("build_sa_db(): invalid encryption/authentication combination selected\n");
+ Debug_printf("build_sa_db(): invalid encryption/authentication combination selected\n");
- //printf("sa_build_db(): authOffset %d, innerIpOffset %d, encOffset %d\n", sa_info[i].tx_payload_info.authOffset, sa_info[i].inner_ip_offset, sa_info[i].tx_payload_info.encOffset);
+ //Debug_printf("sa_build_db(): authOffset %d, innerIpOffset %d, encOffset %d\n", sa_info[i].tx_payload_info.authOffset, sa_info[i].inner_ip_offset, sa_info[i].tx_payload_info.encOffset);
}
&(sa_info[i].rx_inflow_mode_handle),
(void*) saId,
&err);
- if (err) {printf("addRxSa failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addRxSa failed %d\n",err); exit(1);}
if (netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_INFLOW)
{
&netTestCfg.sa_info[i].dst,
NULL, // no qualifiers
NULL, //default route
+ NULL, //user_data
&err);
if (err)
{
- printf("addSaPolicy failed %d, for index %d\n",err,i);
+ Debug_printf("addSaPolicy failed %d, for index %d\n",err,i);
exit(1);
}
}
&(sa_info[i].tx_inflow_mode_handle),
(void*)saId,
&err);
- if (err) {printf("addTxSa failed %d\n",err); exit(1);}
+ if (err) {Debug_printf("addTxSa failed %d\n",err); exit(1);}
}
}
{
if (rx_policy[i])
netapi_secDelRxPolicy(netapi_handle, rx_policy[i], &err);
- if (err == 0) printf("polcicy deleted %d\n", i );
+ if (err == 0) Debug_printf("polcicy deleted %d\n", i );
//delete tunnels
netapi_secDelSA(netapi_handle, 0, sa_info[i].rx_tunnel, &err);
}
diff --git a/ti/runtime/netapi/test/net_test_thread_utils.c b/ti/runtime/netapi/test/net_test_thread_utils.c
index 3162c212583c2f7dff05b87a0f30e738c35240b3..fdeb383880d4c757a3728ab35fccbaf4445a77bd 100755 (executable)
{
int i;
//wait for completion
- printf("main task now pending on slow/fast path completion\n");
+ Debug_printf("main task now pending on slow/fast path completion\n");
for (i = 0; i < netTestCfg.num_sp_threads; i++)
pthread_join( sp_threads[i], NULL );
index fd26d19eb161eb01933d1937cffc608a17857df2..a4cde1f628721d6f347b7a2220c992c12a733f94 100755 (executable)
extern netTestSA_t sa_info[];
extern NETAPI_SCHED_HANDLE_T * scheduler[];
extern Pktlib_HeapHandle ourHeap;
-//extern Pktlib_HeapHandle specialSmall;
-//extern Pktlib_HeapHandle specialLarge;
-extern NETCP_CFG_IP_T ip_rule0;
-extern NETCP_CFG_IP_T ip_rule1;
-
+extern NETCP_CFG_IP_T ip_rule[];
+extern NETCP_CFG_MACIF_T mac[];
Trie * our_router;
STATS_T stats[TUNE_NETAPI_NUM_CORES];
paSysStats_t netcp_stats;
{
QUIT=1;
scnt+=1;
- printf(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
+ Debug_printf(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
if (scnt > 10)
{
- printf(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");
+ Debug_printf(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");
exit(1);
}
}
}
void dump_descr(unsigned long *p, int n)
{
- printf("--------dump of descriptor %d %x\n", n, (int) p);
- printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
- printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
- printf("-----------------------------\n");
+ Debug_printf("--------dump of descriptor %d %x\n", n, (int) p);
+ Debug_printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
+ Debug_printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
+ Debug_printf("-----------------------------\n");
}
void dump_header(unsigned long *p, int n, int a, int r)
{
- printf("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
- printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
- printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
- printf("> %x %x %x %x %x %x %x %x\n",p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23]);
- printf("> %x %x %x %x %x %x %x %x\n",p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]);
- printf("-----------------------------\n");
+ Debug_printf("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
+ Debug_printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
+ Debug_printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
+ Debug_printf("> %x %x %x %x %x %x %x %x\n",p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23]);
+ Debug_printf("> %x %x %x %x %x %x %x %x\n",p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]);
+ Debug_printf("-----------------------------\n");
}
void netapi_dump_buf
tmp_buf = (uint8_t *)(buf);
- printf("netapi *: - 8 bit word hex Length: %d Start \n",buf_length);
+ Debug_printf("netapi *: - 8 bit word hex Length: %d Start \n",buf_length);
do
{
row_count = (dump_size - count);
{
case 4:
{
- printf("netapi *:%02d : %02x %02x %02x %02x \n",
+ Debug_printf("netapi *:%02d : %02x %02x %02x %02x \n",
count,tmp_buf[0],tmp_buf[1],tmp_buf[2],tmp_buf[3]);
break;
}
case 3:
{
- printf("netapi *: %02d : %02x %02x %02x \n",
+ Debug_printf("netapi *: %02d : %02x %02x %02x \n",
count,tmp_buf[0],tmp_buf[1],tmp_buf[2]);
break;
}
case 2:
{
- printf("netapi *: %02d : %02x %02x \n",
+ Debug_printf("netapi *: %02d : %02x %02x \n",
count,tmp_buf[0],tmp_buf[1]);
break;
}
case 1:
{
- printf("netapi *: %02d : %02x \n",
+ Debug_printf("netapi *: %02d : %02x \n",
count,tmp_buf[0]);
break;
}
default:
{
/* Should never reach here */
- printf("netapi *: Internal Error in netapi_dump_buf().Row Count: %d \n", row_count);
+ Debug_printf("netapi *: Internal Error in netapi_dump_buf().Row Count: %d \n", row_count);
return;
}
}
}while(count < dump_size);
- printf("netapi *: - Byte hex Dump End \n");
+ Debug_printf("netapi *: - Byte hex Dump End \n");
}
long htonl(long x)
}
if((p_saIpsecStats->pktEncHi) ||(p_saIpsecStats->pktEncLo))
{
- Debug_printf("------------- IPSec TX (Encryption Channel) Stats BEGIN --\n");
+ Debug_Debug_printf("------------- IPSec TX (Encryption Channel) Stats BEGIN --\n");
}
else
{
- printf("------------- IPSec RX (Decryption Channel) Stats BEGIN --\n");
+ Debug_printf("------------- IPSec RX (Decryption Channel) Stats BEGIN --\n");
}
#endif
- printf("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
- printf("IPSec replayOld:0x%x,replayDup:0x%x,authFail:0x%x \n",
+ Debug_printf("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
+ Debug_printf("IPSec replayOld:0x%x,replayDup:0x%x,authFail:0x%x \n",
p_saIpsecStats->replayOld,p_saIpsecStats->replayDup,p_saIpsecStats->authFail);
- printf("IPSec txESN:0x%x,rxESN:0x%x,pktEncHi:0x%x,pktEncLo:0x%x,pktDecHi:0x%x,pktDecLo:0x%x \n",
+ Debug_printf("IPSec txESN:0x%x,rxESN:0x%x,pktEncHi:0x%x,pktEncLo:0x%x,pktDecHi:0x%x,pktDecLo:0x%x \n",
p_saIpsecStats->txESN,p_saIpsecStats->rxESN,p_saIpsecStats->pktEncHi,
p_saIpsecStats->pktEncLo,p_saIpsecStats->pktDecHi,p_saIpsecStats->pktDecLo);
}
void print_datamode_stats(Sa_DataModeStats_t *p_saDataModeStats, nwal_saAALG auth, nwal_saEALG cipher)
{
- printf("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
- printf(" Packets processedHi: 0x%x, Packets processed Lo:0x%x\n",
+ Debug_printf("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
+ Debug_printf(" Packets processedHi: 0x%x, Packets processed Lo:0x%x\n",
p_saDataModeStats->pktHi, p_saDataModeStats->pktLo);
}
for (i=0;i < TUNE_NETAPI_NUM_CORES;i++)
{
- printf("Per Core Statistics for CORE %d\n", i);
- printf(">*****stats @ %lld (#cbs%d) \n", hplib_mUtilGetTimestamp(),stats[i].n_stats_cb);
- printf(">itx=%d rx=%d tx=%d bad=%d slow=%d \n>rx_class0=%d rx_class1=%d rx_class2=%dsecRx=%d\t"
+ Debug_printf("Per Core Statistics for CORE %d\n", i);
+ Debug_printf(">*****stats @ %lld (#cbs%d) \n", hplib_mUtilGetTimestamp(),stats[i].n_stats_cb);
+ Debug_printf(">itx=%d rx=%d tx=%d bad=%d slow=%d \n>rx_class0=%d rx_class1=%d rx_class2=%dsecRx=%d\t"
"secPRX=%d sb_rx=%d sb_tx=%d auth_ok=%d sec_tx=%d min_rx=%d min_tx=%d fragPkt=%d, exceptionPktOther=%d\n",
stats[i].itx, stats[i].rx, stats[i].tx, stats[i].n_bad, stats[i].n_new,
stats[i].n_class0_rx, stats[i].n_class1_rx, stats[i].n_class2_rx, stats[i].sec_rx,
stats[i].secp_rx, stats[i].sb_rx, stats[i].sb_tx, stats[i].n_auth_ok,
stats[i].sec_tx, stats[i].rx_min, stats[i].tx_min, stats[i].exceptionPktsFrag, stats[i].exceptionPktsOther);
- printf(">if rx stats: %d %d %d\n",stats[i].if_rx[0],stats[i].if_rx[1],stats[i].if_rx[2]);
- printf(">core rx stats: %d \n",stats[i].core_rx);
+ Debug_printf(">if rx stats: %d %d %d\n",stats[i].if_rx[0],stats[i].if_rx[1],stats[i].if_rx[2]);
+ Debug_printf(">core rx stats: %d \n",stats[i].core_rx);
if (stats[i].rx && stats[i].tx)
- printf("decrypt time per packet(avg): %lu, encrypt time per packet(avg): %lu\n",
+ Debug_printf("decrypt time per packet(avg): %lu, encrypt time per packet(avg): %lu\n",
(unsigned long) stats[i].total_decrypt_time/stats[i].rx, (unsigned long) stats[i].total_encrypt_time/stats[i].tx);
{
bcpp_tx = 0L;
}
- printf("> ++ busy cycles pp=%lld (%lld wo cache ops) (app+tx= %lld) (tx= %lld) ++\n",
+ Debug_printf("> ++ busy cycles pp=%lld (%lld wo cache ops) (app+tx= %lld) (tx= %lld) ++\n",
bcpp,bcpp_noc,bcpp_app, bcpp_tx);
- printf("\n");
+ Debug_printf("\n");
}
#ifdef MULTI_THREAD
if(pPaStats)
{
- printf("C1 number of packets: %d\n", pPaStats->classify1.nPackets);
- printf("C1 number IPv4 packets: %d\n", pPaStats->classify1.nIpv4Packets);
- printf("C1 number IPv6 packets: %d\n", pPaStats->classify1.nIpv6Packets);
- printf("C1 number Custom packets: %d\n", pPaStats->classify1.nCustomPackets);
- printf("C1 number SRIO packets: %d\n", pPaStats->classify1.nSrioPackets);
- printf("C1 number LLC/SNAP Fail packets: %d\n", pPaStats->classify1.nLlcSnapFail);
- printf("C1 number table matched: %d\n", pPaStats->classify1.nTableMatch);
- printf("C1 number failed table matched: %d\n", pPaStats->classify1.nNoTableMatch);
- printf("C1 number IP Fragmented packets: %d\n", pPaStats->classify1.nIpFrag);
- printf("C1 number IP Depth Overflow: %d\n", pPaStats->classify1.nIpDepthOverflow);
- printf("C1 number VLAN Depth Overflow: %d\n", pPaStats->classify1.nVlanDepthOverflow);
- printf("C1 number GRE Depth Overflow: %d\n", pPaStats->classify1.nGreDepthOverflow);
- printf("C1 number MPLS Packets: %d\n", pPaStats->classify1.nMplsPackets);
- printf ("C1 number of parse fail: %d\n",pPaStats->classify1.nParseFail);
- printf("C1 number of Invalid IPv6 Opt: %d\n", pPaStats->classify1.nInvalidIPv6Opt);
- printf("C1 number of TX IP Fragments: %d\n", pPaStats->classify1.nTxIpFrag);
- printf ("C1 number of silent discard: %d\n",pPaStats->classify1.nSilentDiscard);
- printf("C1 number of invalid control: %d\n", pPaStats->classify1.nInvalidControl);
- printf ("C1 number of invalid states: %d\n",pPaStats->classify1.nInvalidState);
- printf ("C1 number of system fails: %d\n",pPaStats->classify1.nSystemFail);
- printf ("C2 number Packets : %d\n",pPaStats->classify2.nPackets);
- printf ("C2 number udp : %d\n",pPaStats->classify2.nUdp);
- printf ("C2 number tcp : %d\n",pPaStats->classify2.nTcp);
- printf ("C2 number Custom : %d\n",pPaStats->classify2.nCustom);
- printf ("C2 number silent drop : %d\n",pPaStats->classify2.nSilentDiscard);
- printf ("C2 number invalid cntrl : %d\n\n",pPaStats->classify2.nInvalidControl);
- printf ("C2 number Modify Stats Cmd Fail : %d\n\n",pPaStats->modify.nCommandFail);
+ Debug_printf("C1 number of packets: %d\n", pPaStats->classify1.nPackets);
+ Debug_printf("C1 number IPv4 packets: %d\n", pPaStats->classify1.nIpv4Packets);
+ Debug_printf("C1 number IPv6 packets: %d\n", pPaStats->classify1.nIpv6Packets);
+ Debug_printf("C1 number Custom packets: %d\n", pPaStats->classify1.nCustomPackets);
+ Debug_printf("C1 number SRIO packets: %d\n", pPaStats->classify1.nSrioPackets);
+ Debug_printf("C1 number LLC/SNAP Fail packets: %d\n", pPaStats->classify1.nLlcSnapFail);
+ Debug_printf("C1 number table matched: %d\n", pPaStats->classify1.nTableMatch);
+ Debug_printf("C1 number failed table matched: %d\n", pPaStats->classify1.nNoTableMatch);
+ Debug_printf("C1 number IP Fragmented packets: %d\n", pPaStats->classify1.nIpFrag);
+ Debug_printf("C1 number IP Depth Overflow: %d\n", pPaStats->classify1.nIpDepthOverflow);
+ Debug_printf("C1 number VLAN Depth Overflow: %d\n", pPaStats->classify1.nVlanDepthOverflow);
+ Debug_printf("C1 number GRE Depth Overflow: %d\n", pPaStats->classify1.nGreDepthOverflow);
+ Debug_printf("C1 number MPLS Packets: %d\n", pPaStats->classify1.nMplsPackets);
+ Debug_printf ("C1 number of parse fail: %d\n",pPaStats->classify1.nParseFail);
+ Debug_printf("C1 number of Invalid IPv6 Opt: %d\n", pPaStats->classify1.nInvalidIPv6Opt);
+ Debug_printf("C1 number of TX IP Fragments: %d\n", pPaStats->classify1.nTxIpFrag);
+ Debug_printf ("C1 number of silent discard: %d\n",pPaStats->classify1.nSilentDiscard);
+ Debug_printf("C1 number of invalid control: %d\n", pPaStats->classify1.nInvalidControl);
+ Debug_printf ("C1 number of invalid states: %d\n",pPaStats->classify1.nInvalidState);
+ Debug_printf ("C1 number of system fails: %d\n",pPaStats->classify1.nSystemFail);
+ Debug_printf ("C2 number Packets : %d\n",pPaStats->classify2.nPackets);
+ Debug_printf ("C2 number udp : %d\n",pPaStats->classify2.nUdp);
+ Debug_printf ("C2 number tcp : %d\n",pPaStats->classify2.nTcp);
+ Debug_printf ("C2 number Custom : %d\n",pPaStats->classify2.nCustom);
+ Debug_printf ("C2 number silent drop : %d\n",pPaStats->classify2.nSilentDiscard);
+ Debug_printf ("C2 number invalid cntrl : %d\n\n",pPaStats->classify2.nInvalidControl);
+ Debug_printf ("C2 number Modify Stats Cmd Fail : %d\n\n",pPaStats->modify.nCommandFail);
}
Pktlib_getHeapStats(ourHeap, &pktLibHeapStats);
-printf("main heap stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+Debug_printf("main 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",
+Debug_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");
+Debug_printf("pa2sa descriptor area dump\n");
for(i=0;i<TUNE_NETAPI_CONFIG_MAX_PA_TO_SA_DESC;i++)
{
extern long * pa2sa_descr_base;
long * tip= &pa2sa_descr_base[32*i];
dump_descr(tip, i);
}
-printf("sa2pa descriptor area dump\n");
+Debug_printf("sa2pa descriptor area dump\n");
for(i=0;i<TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;i++)
{
extern long * sa2pa_descr_base;
}
}
else
- printf("our_stats_cb: invalid SA direction\n");
+ Debug_printf("our_stats_cb: invalid SA direction\n");
}
netapi_dump_internal_heap_stats();
}
*start = atoi(pch);
pch = strtok (NULL,"-");
*end = atoi(pch);
- printf("parse_one_fp: start %d, end %d\n", *start, *end);
+ Debug_printf("parse_one_fp: start %d, end %d\n", *start, *end);
}
if (strlen(&pConfig->sp_thread_num[i][0]))
{
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]);
+ Debug_printf("parse_sp: thread_num[%d]: %d\n", i, netTestCfg.sp_thread_num[i]);
}
}
- printf("parse_sp: number of sp threads %d\n", netTestCfg.num_sp_threads);
+ Debug_printf("parse_sp: number of sp threads %d\n", netTestCfg.num_sp_threads);
}
if (strlen(&pConfig->fp_thread_num[i][0]))
{
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]);
+ Debug_printf("parse_fp: thread_num[%d]: %d\n", i, netTestCfg.fp_thread_num[i]);
}
}
- printf("parse_fp: number of fp threads %d\n", netTestCfg.num_fp_threads);
+ Debug_printf("parse_fp: number of fp threads %d\n", netTestCfg.num_fp_threads);
}
if (strlen(&pConfig->ipsec_if_no[0]))
{
netTestCfg.ipsec_if_no= atoi(&pConfig->ipsec_if_no[0]);
- printf("parse_ipsec_if_no %d\n",netTestCfg.ipsec_if_no);
+ Debug_printf("parse_ipsec_if_no %d\n",netTestCfg.ipsec_if_no);
}
}
ccycles =Osal_cache_op_measure(&n_c_ops);
if (sum_vv1)
{
- printf("BURST NWAL Fast send %d pkts. metadata=%d Cmd Label Creation Cost=%d nwal Fast Send Cost (less cacheop)= %d n_c_ops=%lld cache_op_time=%lld (pp-> %d)\n",
+ Debug_printf("BURST NWAL Fast send %d pkts. metadata=%d Cmd Label Creation Cost=%d nwal Fast Send Cost (less cacheop)= %d n_c_ops=%lld cache_op_time=%lld (pp-> %d)\n",
stats[coreid].itx, sum_vv1/stats[coreid].itx, nwal_sum_flow_vv2, sum_vv3/stats[coreid].itx,
n_c_ops, ccycles, n_c_ops? (ccycles/(n_c_ops/2L)) : 0);
#if 0
if(stats[core_id].itx2)
{
- printf("nwal_flowSend Profile Cycles: Prof1= %d,Prof2=%d \n",
+ Debug_printf("nwal_flowSend Profile Cycles: Prof1= %d,Prof2=%d \n",
nwal_sum_flow_vv1/stats[coreid].itx2,nwal_sum_flow_vv2/stats[coreid].itx2);
}
}
#endif
}
-void create_interfaces(NETCP_CFG_IP_T *ip_rule0 , NETCP_CFG_IP_T *ip_rule1)
+void create_interfaces(void)
{
int err, i;
for (i = 0; i < netTestCfg.num_macs; i++)
{
/* add mac intefaces */
- netcp_cfgCreateMacInterface(
+ mac[i] = netcp_cfgCreateMacInterface(
netapi_handle,
&netTestCfg.mac[i][0],
- //ETH0,
i,
netTestCfg.switch_port[i],
(NETCP_CFG_ROUTE_HANDLE_T) NULL,
&err);
if (err)
{
- printf("addmac %d failed %d\n",i, err);
+ Debug_printf("addmac %d failed %d\n",i, err);
//exit(1);
}
else
- printf("create_interfaces, added mac sucess\n");
+ Debug_printf("create_interfaces, added mac sucess\n");
}
for (i = 0; i < netTestCfg.num_ips; i++)
{
//attach an IP to this interface
- *ip_rule0=netcp_cfgAddIp(
+ ip_rule[i]=netcp_cfgAddIp(
netapi_handle,
- //ETH0,
netTestCfg.attach_iface[i],
nwal_IPV4,
(nwalIpAddr_t *)&netTestCfg.ip[i].ipv4[0],
NULL, //all IP
(NETCP_CFG_ROUTE_HANDLE_T) NULL,
+ (void*)NULL,
&err
);
if (err) {
- printf("addip %d failed %d\n", i, err);
+ Debug_printf("addip %d failed %d\n", i, err);
//exit(1);
}
else
- printf("create_interfaces, added ip sucess\n");
+ Debug_printf("create_interfaces, added ip sucess\n");
}
}
-void delete_interfaces(NETCP_CFG_IP_T *ip_rule0 , NETCP_CFG_IP_T *ip_rule1)
+void delete_interfaces(void)
{
- int err;
+
+ int err,i;
//delete IPs and MAC Interfacess
- netcp_cfgDelIp(netapi_handle, 0, 0, NULL, NULL, *ip_rule0, &err);
- netcp_cfgDelIp(netapi_handle, 1, 0, NULL, NULL, *ip_rule1, &err);
- netcp_cfgDelMac(netapi_handle,0,&err);
- netcp_cfgDelMac(netapi_handle,1,&err);
-#ifdef PROMISCUOUS
- netcp_cfgDelMac(netapi_handle,2,&err);
-#endif
+ for (i = 0; i < netTestCfg.num_ips; i++)
+ {
+ err = 0;
+ netcp_cfgDelIp(netapi_handle, netTestCfg.attach_iface[i], nwal_IPV4,
+ NULL, NULL, ip_rule[i], &err);
+ }
+ for (i = 0; i < netTestCfg.num_macs; i++)
+ {
+ err = 0;
+ netcp_cfgDelMac(netapi_handle,i,&err);
+ }
+
+ //netcp_cfgDelMac(netapi_handle,0,&err);
+ //netcp_cfgDelMac(netapi_handle,1,&err);
+
}
index 081d22869814c6803ec1377cc1f38d99f775da19..ba07d53a55edcedeb14a4715df4244167f723ba7 100755 (executable)
#include "net_test.h"
-#ifdef __LINUX_USER_SPACE
-#define Debug_printf
-#else
-#define Debug_printf
-#endif
-
-
-
-
#define MAX_SEC_INDEX 16
#define NET_TEST_MAX_MAC 10
#define NET_TEST_MAX_IP 10
void house(NETAPI_SCHED_HANDLE_T *s);
-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 create_interfaces(void);
+void delete_interfaces(void);
void slow_path_thread(int coreid);
void fast_path_thread(int coreid);
#endif
index 2324d52f9a46f2636a96bf9c367aea19f2cf9d43..85496e1625729f238875ac8f08cc1a46886aeca6 100755 (executable)
Trie * p_trie;
char * p_res;
p_trie = trie_new();
-if (!p_trie) {printf("trie alloc failed\n"); exit(1);}
+if (!p_trie) {Debug_printf("trie alloc failed\n"); exit(1);}
trie_insert(p_trie,"key1","this is key 1");
trie_insert(p_trie,"key12","this is key 2");
trie_insert(p_trie,"key4","this is key 4");
p_res= trie_lookup(p_trie,"key1");
-printf("lookup %s = %s\n", "key1", p_res ? p_res : "not found");
+Debug_printf("lookup %s = %s\n", "key1", p_res ? p_res : "not found");
p_res= trie_lookup(p_trie,"key12");
-printf("lookup %s = %s\n", "key2", p_res ? p_res : "not found");
+Debug_printf("lookup %s = %s\n", "key2", p_res ? p_res : "not found");
p_res= trie_lookup(p_trie,"key3");
-printf("lookup %s = %s\n", "key3", p_res ? p_res : "not found");
+Debug_printf("lookup %s = %s\n", "key3", p_res ? p_res : "not found");
p_res= trie_lookup(p_trie,"key4");
-printf("lookup %s = %s\n", "key4", p_res ? p_res : "not found");
+Debug_printf("lookup %s = %s\n", "key4", p_res ? p_res : "not found");
p_res= trie_lookup(p_trie,"key5");
-printf("lookup %s = %s\n", "key5", p_res ? p_res : "not found");
+Debug_printf("lookup %s = %s\n", "key5", p_res ? p_res : "not found");
p_res= trie_lookup(p_trie,"k5");
-printf("lookup %s = %s\n", "k5", p_res ? p_res : "not found");
+Debug_printf("lookup %s = %s\n", "k5", p_res ? p_res : "not found");
trie_free(p_trie);
//dump_descr
void dump_descr(unsigned long *p, int n)
{
- printf("--------dump of descriptor %d %x\n", n, (int) p);
- printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
- printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
- printf("-----------------------------\n");
+ Debug_printf("--------dump of descriptor %d %x\n", n, (int) p);
+ Debug_printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
+ Debug_printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
+ Debug_printf("-----------------------------\n");
}
static inline unsigned long netapi_timing_start(void)
}
-#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
+#define FATAL do { fDebug_printf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
#define MAP_SIZE 4096UL
if(argc < 2) {
- fprintf(stderr, "\nUsage:\t%s { address } nun ] ]\n"
+ fDebug_printf(stderr, "\nUsage:\t%s { address } nun ] ]\n"
"\taddress : memory address to act upon\n"
"\tnum : #descriptors to be dumped (def 32)\n\n",
argv[0]);
if((fd = open("/dev/mem", ((cached) ? (O_RDWR) : (O_RDWR | O_SYNC)))) == -1) FATAL;
- printf("/dev/mem opened.\n");
+ Debug_printf("/dev/mem opened.\n");
fflush(stdout);
/* Map one page */
map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~MAP_MASK);
if(map_base == (void *) -1) FATAL;
- printf("Memory mapped at address %p. (cached=%d)\n", map_base,cached);
+ Debug_printf("Memory mapped at address %p. (cached=%d)\n", map_base,cached);
fflush(stdout);
virt_addr = map_base + (target & MAP_MASK);