summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0663b06)
raw | patch | inline | side by side (parent: 0663b06)
author | Tinku Mannan <tmannan@ti.com> | |
Fri, 8 Feb 2013 15:30:37 +0000 (10:30 -0500) | ||
committer | Tinku Mannan <tmannan@ti.com> | |
Fri, 8 Feb 2013 15:59:40 +0000 (10:59 -0500) |
1. Adding net_test_thread_utils.c/.h files which contain internal
net_test APIs for slow and fast path thread creation.
2. Updated net_test_config.txt with slow and fast path configuration
parameters.
3. Added new config file parsing routines for slow and fast path configuration
parameters to net_test_utils.c/.h (renamed from net_test_util.c/.h).
4. General cleanup.
net_test APIs for slow and fast path thread creation.
2. Updated net_test_config.txt with slow and fast path configuration
parameters.
3. Added new config file parsing routines for slow and fast path configuration
parameters to net_test_utils.c/.h (renamed from net_test_util.c/.h).
4. General cleanup.
17 files changed:
index 2192be65ddbc517d4972987a7d054bdd72e55f38..4fd2fed5eff657f5ddb4693a97b3c8c38a921b42 100755 (executable)
#ifndef __NETAPI__H
#define __NETAPI__H
+//#define NWAL_ENABLE_SA
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include "hplib.h"
-
/* Define NETAPI as a master group in Doxygen format and
* add all NETAPI
* definitions to this group.
index 6238fdf81136ab0ff41bced2dcffa4663212fd4e..7ddb1f06f5d1577dc5b55a8c13951231706bb911 100755 (executable)
* @def NETCP_CFG_ACTION_DISCARD
* This defines the NETCP action to discard packet.
*/
-#define NETCP_CFG_ACTION_DISCARD 0
+#define NETCP_CFG_ACTION_DISCARD NWAL_MATCH_ACTION_DISCARD
/**
* @ingroup cfg_constants
* @def NETCP_CFG_ACTION_CONTINUE
* This defines the NETCP action to pass packet ono the next classifier
*/
-#define NETCP_CFG_ACTION_CONTINUE 1
+#define NETCP_CFG_ACTION_CONTINUE NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE
/**
* @ingroup cfg_constants
* @def NETCP_CFG_ACTION_TO_SW
* This defines the NETCP action to pass packet to User space application
*/
-#define NETCP_CFG_ACTION_TO_SW 2
+#define NETCP_CFG_ACTION_TO_SW NWAL_MATCH_ACTION_HOST
/**
* @ingroup cfg_constants
* @def NETCP_CFG_MATCH_EXCEPTION
* This define is used for an APPID that indicates that a packet is of type exception. Actual exception id is in byte 0 of APPID.
*/
-#define NETCP_CFG_MATCH_EXCEPTION 0x08000000
+#define NETAPI_NETCP_CFG_MATCH_EXCEPTION 0x08000000
index 336c0bf78c853a1e97a7b893ee7b5242d48663bf..2bee3237aca39f1613af2c96018981fa7eeb8c2e 100755 (executable)
* 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>
index fbd50791313cf4ce37bce21cc5930844bb0775ac..ecec82407b334f01f2beb64eb5c1f55bf0d85863 100755 (executable)
* 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>
index c728b5515aca3f68d225c39b30aaaaa74f907346..89384e77887df6a527be475c59fda73135d7464c 100755 (executable)
#ifndef __NETAPI_LOC__H
#define __NETAPI_LOC__H
-#include "ti/runtime/netapi/netapi.h"
+//#define NWAL_ENABLE_SA
+//#include "ti/runtime/netapi/netapi.h"
+//#include "ti/drv/nwal/nwal_util.h"
extern hplib_virtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
extern unsigned char *netapi_VM_SaContextVaddr;
void * sa_handle_inflow; //for inflow mode
void * sa_handle_sideband; //for sideband mode
int iface; //associated interface
+ //nwalTxDmPSCmdInfo_t rx_dmPSCmdInfo;
+ //nwalTxDmPSCmdInfo_t tx_dmPSCmdInfo;
} NETCP_IPSEC_SA_T;
/* to hold a netcp 'interface' */
index a04db91a100513d36dae6fcd7779260ec9b66ff6..63b4ea78ae5d3ae85fbc010881d68e8ac760f740 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>
index df531c4e36dc9dd63c489a00937e7bc6cd71f4ea..487f17daaf1af80c5fe358fdcc49171f6c6d0add 100755 (executable)
ctrl.appRxPktQueue = NWAL_QUEUE_NOT_SPECIFIED;
}
- ctrl.appId =NETCP_CFG_MATCH_EXCEPTION | exception_id;
+ ctrl.appId =NETAPI_NETCP_CFG_MATCH_EXCEPTION | exception_id;
ctrl.matchAction = action;
index 4c6356f601736d844a1733c1e0ffe3ff55486ba3..f183e6c6ebf6fcd0231359d8cc5c8d3d165aee2d 100755 (executable)
export NETAPI_INSTALL_PATH ?= $(TRANS_SDK_INSTALL_PATH)
TRIE_OBJS=$(ARMV7OBJDIR)/netapi/test/trie.o
-NT_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_util.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o
-NT_ROUTER_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_router.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_util.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o
+NT_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_util.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
+#
+NT_ROUTER_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_router.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_util.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
+#
NTB_OBJS= $(ARMV7OBJDIR)/netapi/test/nt_bridge.o $(ARMV7OBJDIR)/netapi/test/stubs.o
# INCLUDE Directories
index ebfabd2eef6357ae6eb4bb8a1329ca6e1f19be2b..199a655fa1def8c56a0b6833b2d206f3cc9644a6 100755 (executable)
pPloadDesc,
NWAL_DESC_SIZE);
#else
- pktio_send(netcp_tx_chan,tip,&meta,&err);
+ pktio_send(netcp_tx_chan,tip,&meta,&err);
#endif
stats[coreid].tx +=1;
stats[coreid].sec_tx +=1;
/******************************************************/
/******************PKT RECEIVE HANDLER *************************/
/******************************************************/
+
void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
PKTIO_METADATA_T meta[], int n_pkts,
uint64_t ts )
}
-
#ifdef MULTI_THREAD
NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
-void slow_path_thread(int coreid)
+
+void slow_path_thread(int thread_num)
{
- int err;
+ int err, i;;
PKTIO_HANDLE_T *rx_chan;
PKTIO_HANDLE_T *tx_chan;
PKTIO_HANDLE_T *sb_tx_chan;
PKTIO_HANDLE_T *sb_rx_chan;
- Debug_printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
+ Debug_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);
#ifdef CORTEX_A15
- CPU_SET( coreid, &cpu_set);
- hplib_utilSetupCore(coreid, &cpu_set);
+ for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+ {
+ printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+ CPU_SET( i, &cpu_set);
+ }
+ hplib_utilSetupCore(thread_num, &cpu_set);
#else
- CPU_SET( 0, &cpu_set);
- hplib_utilSetupCore(coreid+1, &cpu_set);
+ for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+ {
+ printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+ CPU_SET( i, &cpu_set);
+ }
+ hplib_utilSetupCore(thread_num, &cpu_set);
#endif
- worker_nh[coreid]=netapi_init(NETAPI_CORE_MASTER,NULL);
+ worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
- NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
/* open netcp default tx, rx queues */
- tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ tx_chan = pktio_open(worker_nh[thread_num], NETCP_TX, NULL, &netcp_tx_cfg, &err);
- rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
+ rx_chan = pktio_open(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
/* create a pktio channel for specially classified pkts */
/* open netcp default tx, rx queues for sideband crypto */
- sb_tx_chan = pktio_open(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
+ sb_tx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
- sb_rx_chan = pktio_open(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
+ sb_rx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
- netapi_setCookie(worker_nh[coreid],(void*) coreid);
+ netapi_setCookie(worker_nh[thread_num],(void*) thread_num);
- scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
- if (!scheduler[coreid])
+ 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",coreid);
+ Debug_printf("sched create failed for core%d\n",thread_num);
exit(1);
}
- scheduler[coreid]->config.yield = FALSE;
- scheduler[coreid]->config.pollGarbageQ = TRUE;
- scheduler[coreid]->config.pollCtrlQ = TRUE;
+ scheduler[thread_num]->config.yield = FALSE;
+ scheduler[thread_num]->config.pollGarbageQ = TRUE;
+ scheduler[thread_num]->config.pollCtrlQ = TRUE;
/*********************************************/
/**************Entry point into scheduler ****/
/*********************************************/
- netapi_schedRun(scheduler[coreid], &err);
- Debug_printf(">net_test: core %d worker thread done\n",coreid);
+ netapi_schedRun(scheduler[thread_num], &err);
+ Debug_printf(">net_test: core %d worker thread done\n",thread_num);
pktio_close(tx_chan, &err);
pktio_close(rx_chan, &err);
pktio_close(sb_tx_chan, &err);
pktio_close(sb_tx_chan, &err);
- netapi_shutdown(worker_nh[coreid]);
+ netapi_shutdown(worker_nh[thread_num]);
}
-void fast_path_thread(int coreid)
+void fast_path_thread(int thread_num)
{
- int err;
+ int err, i;
PKTIO_HANDLE_T *rx_chan;
PKTIO_HANDLE_T *tx_chan;
PKTIO_HANDLE_T *sb_tx_chan;
PKTIO_HANDLE_T *sb_rx_chan;
+ CPU_ZERO( &cpu_set);
+ printf("fast_path_thread: settting up for thread number %d\n", thread_num);
#ifdef CORTEX_A15
- CPU_SET( coreid, &cpu_set);
- hplib_utilSetupCore(coreid, &cpu_set);
+ for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+ {
+ printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+ CPU_SET( i, &cpu_set);
+ }
+ hplib_utilSetupCore(thread_num, &cpu_set);
#else
- CPU_SET( 0, &cpu_set);
- hplib_utilSetupCore(coreid + 1, &cpu_set);
+ for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+ {
+ printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+ CPU_SET( i, &cpu_set);
+ }
+ hplib_utilSetupCore(thread_num, &cpu_set);
#endif
- worker_nh[coreid]=netapi_init(NETAPI_CORE_MASTER,NULL);
+ worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
- NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
+ NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
/* open netcp default tx, rx queues */
- tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg, &err);
- rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
+ tx_chan = pktio_open(worker_nh[thread_num], NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ rx_chan = pktio_open(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
/* create a pktio channel for specially classified pkts */
/* open netcp default tx, rx queues for sideband crypto */
- sb_tx_chan = pktio_open(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
- sb_rx_chan = pktio_open(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
+ sb_tx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
+ sb_rx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
- netapi_setCookie(worker_nh[coreid],(void*)coreid);
+ netapi_setCookie(worker_nh[thread_num],(void*)thread_num);
//our_core = coreid;
- scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
- if (!scheduler[coreid])
+ 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",coreid);
+ Debug_printf("sched create failed for core%d\n",thread_num);
exit(1);
}
/*********************************************/
/**************Entry point into scheduler ****/
/*********************************************/
- scheduler[coreid]->config.yield = FALSE;
- scheduler[coreid]->config.pollGarbageQ = FALSE;
- scheduler[coreid]->config.pollCtrlQ = FALSE;
+ scheduler[thread_num]->config.yield = FALSE;
+ scheduler[thread_num]->config.pollGarbageQ = FALSE;
+ scheduler[thread_num]->config.pollCtrlQ = FALSE;
//sleep(100000);
- netapi_schedRun(scheduler[coreid], &err);
- Debug_printf(">net_test: core %d worker thread done\n",coreid);
+ netapi_schedRun(scheduler[thread_num], &err);
+ printf(">net_test: core %d worker thread done\n",thread_num);
pktio_close(tx_chan, &err);
pktio_close(rx_chan, &err);
pktio_close(sb_tx_chan, &err);
pktio_close(sb_tx_chan, &err);
- netapi_shutdown(worker_nh[coreid]);
+ netapi_shutdown(worker_nh[thread_num]);
}
#endif
-
/***************************************
********** test driver*****************
***************************************/
Debug_printf("pktio open SB RX failed err=%d\n",err);
exit(1);
}
-
Debug_printf("net_test: %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
/* create scheduler instance */
our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
#ifdef MULTI_THREAD
{
- CPU_ZERO( &cpu_set );
- pthread_t *thrs;
- int procs =2; //get this from config eventually
- char c;
- thrs = malloc( sizeof( pthread_t ) * procs );
- if (thrs == NULL)
- {
- perror( "malloc" );
- return -1;
- }
- Debug_printf( "Starting %d threads...\n", procs );
+ char c;
+ /* create and set affinity of slow path and fast path threads to
+ * specific CPU cores as specified in the net_test_config.txt file */
+ create_sp_fp_threads();
+ //create_sec_associations(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
- if (pthread_create( &thrs[0], NULL, (void*)slow_path_thread,
- (void *)0 ))
- {
- perror( "pthread_create" );
- exit(1);
- }
-
- if (pthread_create( &thrs[1], NULL, (void*)fast_path_thread,
- (void *)1 ))
- {
- perror( "pthread_create" );
- exit(1);
- }
//this thread of execution (main) now just waits on user input
for(;;)
{
- Debug_printf(">");
+ printf(">");
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");
}
- //wait for completion
- Debug_printf("main task now pending on slow/fast path completion\n");
- for (i = 0; i < procs; i++)
- pthread_join( thrs[i], NULL );
+ sp_fp_thread_cleanup();
- free( thrs );
}
#else
/*********************************************/
/**************Entry point into scheduler ****/
/*********************************************/
+ //create_sec_associations(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
netapi_schedRun(our_sched, &err);
#endif
index e504c99199c0db2d47acc18e8b5ad5ccb6d5a4c8..629638f8ed4a6c36cb1b5122529c16446a8f1db2 100755 (executable)
#define NWAL_ENABLE_SA
#endif
#define AH_SUPPORT
-#define NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
+//#define NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
#ifdef NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
#define NWAL_ENABLE_SA
#endif
typedef struct head_t
{
- long ip[5];
- long udp[2];
+ long ip[5];
+ long udp[2];
} HEAD_T;
typedef struct key_t
ROUTE_SEC_T * sec_ptr;
} OUR_ROUTE_T;
-#ifdef MULTI_THREAD
-void slow_path_thread(int coreid);
-void fast_path_thread(int coreid);
-#endif
+
+
+void flip_and_send_pkt(Ti_Pkt *tip, unsigned char * p_pkt, int len, int flag, uint16_t enet_port);
+void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+ PKTIO_METADATA_T meta[], int n_pkts,
+ uint64_t ts );
+void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+ PKTIO_METADATA_T meta[], int n_pkts,
+ uint64_t ts );
#endif
diff --git a/ti/runtime/netapi/test/net_test_config.txt b/ti/runtime/netapi/test/net_test_config.txt
+#sp0 thread-number start-core end-core
+sp0 = 1 0-0
+fp0 = 2 0-0
+fp1 = 3 0-0
#mac0 = mac-address switch-port
mac0 = 00-01-02-03-05-05 sp0
mac1 = 00-01-02-03-05-06 sp1
local_ipsec_ip = 192.168.1.100
remote_ipsec_ip = 192.168.1.10
ipsec_if = 0
-#ipsec_mode_rx = SIDEBAND
-#ipsec_mode_tx = SIDEBAND
-ipsec_mode_rx = INFLOW
-ipsec_mode_tx = INFLOW
+ipsec_mode_rx = SIDEBAND
+ipsec_mode_tx = SIDEBAND
+#ipsec_mode_rx = INFLOW
+#ipsec_mode_tx = INFLOW
route0 = MAC00-23-24-08-67-46 0
route1 = MAC00-22-33-44-55-56 1
index 6af6b7032755328ba32df23ab4cbc6f18fd2f2ef..b3031c458094bd05000e817aa5ad83071ce064dd 100755 (executable)
/******************************************
- * File: net_test.c
- * Purpose: test app for netapi
+ * File: net_test_router.c
+ * Purpose: net_test_router application
**************************************************************
- * FILE: net_test.c
+ * FILE: net_test_router.c
*
* DESCRIPTION: netapi user space transport
- * library test application
+ * library net_test_router application
*
* 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
- Debug_printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
CPU_ZERO( &cpu_set);
#ifdef CORTEX_A15
#ifdef MULTI_THREAD
{
- CPU_ZERO( &cpu_set );
- pthread_t *thrs;
- int procs =2; //get this from config eventually
- char c;
- thrs = malloc( sizeof( pthread_t ) * procs );
- if (thrs == NULL)
- {
- perror( "malloc" );
- return -1;
- }
- Debug_printf( "Starting %d threads...\n", procs );
+ char c;
+ /* create and set affinity of slow path and fast path threads to
+ * specific CPU cores as specified in the net_test_config.txt file */
+ create_sp_fp_threads();
+
- if (pthread_create( &thrs[0], NULL, (void*)slow_path_thread,
- (void *)0 ))
- {
- perror( "pthread_create" );
- exit(1);
- }
-#if 1
- if (pthread_create( &thrs[1], NULL, (void*)fast_path_thread,
- (void *)1 ))
- {
- perror( "pthread_create" );
- exit(1);
- }
-#endif
//this thread of execution (main) now just waits on user input
for(;;)
{
- Debug_printf(">");
+ printf(">");
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");
}
- //wait for completion
- Debug_printf("main task now pending on slow/fast path completion\n");
- for (i = 0; i < procs; i++)
- pthread_join( thrs[i], NULL );
-
- free( thrs );
}
#else
/*********************************************/
/**************Entry point into scheduler ****/
/*********************************************/
netapi_schedRun(our_sched, &err);
-
#endif
/* done */
delete_sec_associations();
delete_interfaces( &ip_rule0, &ip_rule1);
-//close pktio channels we opened
-pktio_close(netcp_tx_chan ,&err);
-pktio_close(netcp_rx_chan ,&err);
-netapi_shutdown(netapi_handle);
+ //close pktio channels we opened
+ pktio_close(netcp_tx_chan ,&err);
+ pktio_close(netcp_rx_chan ,&err);
+ netapi_shutdown(netapi_handle);
}
static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_port)
return;
}
+/* STUB functions required for compilation */
+void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+ PKTIO_METADATA_T meta[], int n_pkts,
+ uint64_t ts )
+{
+}
-
+void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
+ PKTIO_METADATA_T meta[], int n_pkts,
+ uint64_t ts )
+{
+}
\ No newline at end of file
diff --git a/ti/runtime/netapi/test/net_test_sa_utils.c b/ti/runtime/netapi/test/net_test_sa_utils.c
index 87ec903915bfab736279f89b71ad3ea96cddbc76..63a0813f2baf3a99952ba29e9449a4f64f250e77 100755 (executable)
/******************************************
- * File: net_test.c
- * Purpose: test app for netapi
+ * File: net_test_sa_utils.c
+ * Purpose: net_test application security associations utilities
**************************************************************
- * FILE: net_test.c
+ * FILE: net_test_sa_utils.c
*
- * DESCRIPTION: netapi user space transport
- * library test application
+ * DESCRIPTION: net_test application security associations utilities
*
* 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
diff --git a/ti/runtime/netapi/test/net_test_thread_utils.c b/ti/runtime/netapi/test/net_test_thread_utils.c
--- /dev/null
@@ -0,0 +1,115 @@
+/******************************************
+ * File: net_test_thread_utils.c
+ * Purpose: net_test application thread utilities
+ **************************************************************
+ * FILE: net_test_thread_utils.c
+ *
+ * DESCRIPTION: net_test application thread utilities
+ *
+ * REVISION HISTORY: rev 0.0.1
+ *
+ * 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
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ *****************************************/
+
+#include "net_test_util.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <pthread.h>
+#include "trie.h"
+#include "router.h"
+
+#include <ti/drv/sa/salld.h>
+#include <ti/drv/pa/pa.h>
+
+extern netTestConfig_t netTestCfg;
+
+
+/* Global definitions */
+pthread_t *sp_threads;
+pthread_t *fp_threads;
+
+void create_sp_fp_threads(void)
+{
+ int i;
+
+
+
+ char c;
+ sp_threads = malloc( sizeof( pthread_t ) * netTestCfg.num_sp_threads );
+ if (sp_threads == NULL)
+ {
+ perror( "malloc" );
+ return -1;
+ }
+ Debug_printf( "Starting %d threads...\n", netTestCfg.num_sp_threads );
+
+ if (pthread_create( &sp_threads[0], NULL, (void*)slow_path_thread,
+ (void *) netTestCfg.sp_thread_num[i]))
+ {
+ perror( "pthread_create" );
+ exit(1);
+ }
+
+ fp_threads = malloc( sizeof( pthread_t ) * netTestCfg.num_fp_threads);
+ if (fp_threads == NULL)
+ {
+ perror( "malloc" );
+ return -1;
+ }
+ for (i = 0; i < netTestCfg.num_fp_threads; i++)
+ {
+ if (pthread_create( &fp_threads[i], NULL, (void*)fast_path_thread,
+ (void *) netTestCfg.fp_thread_num[i]))
+ {
+ perror( "pthread_create" );
+ exit(1);
+ }
+ }
+}
+void sp_fp_thread_cleanup(void)
+{
+ int i;
+ //wait for completion
+ 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 );
+
+ for (i = 0; i < netTestCfg.num_fp_threads; i++)
+ pthread_join( fp_threads[i], NULL );
+
+ free( sp_threads);
+ free (fp_threads);
+}
diff --git a/ti/runtime/netapi/test/net_test_thread_utils.h b/ti/runtime/netapi/test/net_test_thread_utils.h
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef __NET_TEST_UTIL_H__
+#define __NET_TEST_UTIL_H__
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+
+#include "net_test.h"
+#include "net_test_util.h"
+
+void create_sp_fp_threads(void);
+void sp_fp_thread_cleanup(void);
+
+#ifdef MULTI_THREAD
+void slow_path_thread(int coreid);
+void fast_path_thread(int coreid);
+#endif
+#endif
similarity index 93%
rename from ti/runtime/netapi/test/net_test_util.c
rename to ti/runtime/netapi/test/net_test_utils.c
index 92fac7eaecc3f4ae5e8897d0c74a7244358c39c7..bf1a2a37941b8eeff73ebd00dd4d02b1e9633387 100755 (executable)
rename from ti/runtime/netapi/test/net_test_util.c
rename to ti/runtime/netapi/test/net_test_utils.c
index 92fac7eaecc3f4ae5e8897d0c74a7244358c39c7..bf1a2a37941b8eeff73ebd00dd4d02b1e9633387 100755 (executable)
/******************************************
- * File: net_test.c
- * Purpose: test app for netapi
+ * File: net_test_utils.c
+ * Purpose: net_test application general utilities
**************************************************************
- * FILE: net_test.c
+ * FILE: net_test_utils.c
*
- * DESCRIPTION: netapi user space transport
- * library test application
+ * DESCRIPTION: net_test application general utilities
*
* REVISION HISTORY: rev 0.0.1
*
}
#ifdef MULTI_THREAD
- netapi_schedGetStats(scheduler[0],&tmp_npL[0],&tmp_cyclesL[0],&tmp_ccyclesL[0]);
- netapi_schedGetStats(scheduler[1],&tmp_npL[1],&tmp_cyclesL[1],&tmp_ccyclesL[1]);
-npL = tmp_npL[0]+tmp_npL[1];
-cyclesL = tmp_cyclesL[0]+tmp_cyclesL[1];
-ccyclesL = tmp_ccyclesL[0]+tmp_ccyclesL[1];
+ for (i=0;i < TUNE_NETAPI_NUM_CORES;i++)
+ {
+ if(scheduler[i])
+ {
+ netapi_schedGetStats(scheduler[i],&tmp_npL[0],&tmp_cyclesL[0],&tmp_ccyclesL[0]);
+ npL = tmp_npL[0]+tmp_npL[1];
+ cyclesL = tmp_cyclesL[0]+tmp_cyclesL[1];
+ ccyclesL = tmp_ccyclesL[0]+tmp_ccyclesL[1];
+ }
+ }
#else
netapi_schedGetStats(our_sched, &npL,&cyclesL,&ccyclesL);
#endif
Debug_printf("parse_dir: invalid direction\n");
}
}
+void parse_one_fp(char * p_fp_str, uint8_t* start, uint8_t* end)
+{
+ int index = 0;
+ int i;
+
+ char *pch = strtok (&(p_fp_str[0]),"-");
+ *start = atoi(pch);
+ pch = strtok (NULL,"-");
+ *end = atoi(pch);
+ printf("parse_one_fp: start %d, end %d\n", *start, *end);
+}
+
+
+void parse_sp(netTestConfigFile_t *pConfig)
+{
+ int i;
+ int port = 0;
+ for(i=0;i<NET_TEST_MAX_FP_THREAD;i++)
+ {
+ if (strlen(&pConfig->sp[i][0]))
+ {
+ netTestCfg.num_sp_threads++;
+ parse_one_fp(&pConfig->sp[i][0],&netTestCfg.sp_proc_start[i], &netTestCfg.sp_proc_end);
+ }
+ if (strlen(&pConfig->sp_thread_num[i][0]))
+ {
+ netTestCfg.sp_thread_num[i] = atoi(&pConfig->sp_thread_num[i]);
+ 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);
+
+}
+
+
+void parse_fp(netTestConfigFile_t *pConfig)
+{
+ int i;
+ int port = 0;
+ for(i=0;i<NET_TEST_MAX_FP_THREAD;i++)
+ {
+ if (strlen(&pConfig->fp[i][0]))
+ {
+ netTestCfg.num_fp_threads++;
+ parse_one_fp(&pConfig->fp[i][0],&netTestCfg.fp_proc_start[i], &netTestCfg.fp_proc_end);
+ }
+ if (strlen(&pConfig->fp_thread_num[i][0]))
+ {
+ netTestCfg.fp_thread_num[i] = atoi(&pConfig->fp_thread_num[i]);
+ 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);
+
+}
+void parse_ipsec_if_no(netTestConfigFile_t *pConfig)
+{
+ 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);
+ }
+}
+
void parse_sa(netTestConfigFile_t *pConfig, int i)
{
parse_dir((char*) &pConfig->sa_config[i].dir, &netTestCfg.sa_info[i].dir);
CHECK_SET_PARAM(INIT_CONFIG_IPSEC_MODE_RX,&(pConfig->ipsec_mode_rx[0]));
CHECK_SET_PARAM(INIT_CONFIG_IPSEC_MODE_TX,&(pConfig->ipsec_mode_tx[0]));
CHECK_SET_PARAM(INIT_CONFIG_IPSEC_IF_NO,&(pConfig->ipsec_if_no[0]));
+ //CHECK_SET_PARAM(INIT_CONFIG_NUM_FP_CORES,&(pConfig->num_fp_cores[0]));
+ //CHECK_SET_PARAM(INIT_CONFIG_NUM_FP_THREADS,&(pConfig->num_fp_threads[0]));
+
sprintf(temp_str,"sa%d",sa_count);
if(strcmp(key, temp_str) == 0)
{
(char*)&pConfig->sa_config[sa_count].encr_key,
(char*)&pConfig->sa_config[sa_count].auth_key,
(char*)&pConfig->sa_config[sa_count].tunnel_id);
- parse_sa(pConfig,sa_count);
+ parse_sa(pConfig,sa_count);
sa_count++;
- //parse_sa(pConfig,i);
continue;
}
for(i=0;i<NET_TEST_MAX_MAC;i++)
{
sprintf(temp_str,"mac%d",i);
- //CHECK_SET_PARAM(temp_str,&(pConfig->mac[i][0]));
CHECK_SET_PARAM2(temp_str,&pConfig->mac[i][0],&pConfig->switch_port[i][0] );
}
for(i=0;i<NET_TEST_MAX_IP;i++)
sprintf(temp_str,"ip%d",i);
CHECK_SET_PARAM2(temp_str,&pConfig->ip[i][0], &pConfig->attach_iface[i][0]);
}
+ for(i=0;i<2;i++)
+ {
+ sprintf(temp_str,"fp%d",i);
+ CHECK_SET_PARAM2(temp_str, &pConfig->fp_thread_num[i][0],&pConfig->fp[i][0]);
+ }
+ for(i=0;i<2;i++)
+ {
+ sprintf(temp_str,"sp%d",i);
+ CHECK_SET_PARAM2(temp_str, &pConfig->sp_thread_num[i][0],&pConfig->sp[i][0]);
+ }
}
parse_mac_address(pConfig);
+ parse_fp(pConfig);
+ parse_sp(pConfig);
+
parse_ip_address(pConfig);
parse_ipsec_mode(pConfig);
- if (strlen(&pConfig->ipsec_if_no[0]))
- {
- netTestCfg.ipsec_if_no = atoi(&pConfig->ipsec_if_no[0]);
- }
#ifdef EXPERIMENTAL
parse_routes(pConfig);
#endif
+ parse_ipsec_if_no(pConfig);
+ //parse_num_fp_cores(pConfig);
+ //parse_num_fp_threads(pConfig);
}
similarity index 78%
rename from ti/runtime/netapi/test/net_test_util.h
rename to ti/runtime/netapi/test/net_test_utils.h
index 2068815c186fa2174a5f1e28926e75404a7d7f97..c66618aced5eafcfdba3e766b97eba854c8835c0 100755 (executable)
rename from ti/runtime/netapi/test/net_test_util.h
rename to ti/runtime/netapi/test/net_test_utils.h
index 2068815c186fa2174a5f1e28926e75404a7d7f97..c66618aced5eafcfdba3e766b97eba854c8835c0 100755 (executable)
#define Debug_printf
#endif
+
#define MAX_SEC_INDEX 16
#define NET_TEST_MAX_MAC 10
#define NET_TEST_MAX_IP 10
+#define NET_TEST_MAX_FP_THREAD 5
#define MAX_LINE_LENGTH 512
#define MAX_ROUTES 16
/* The input strings requird for parsing certain configuration
* paremeters from the config file */
-#define INIT_CONFIG_IPSEC_MODE_RX "ipsec_mode_rx"
-#define INIT_CONFIG_IPSEC_MODE_TX "ipsec_mode_tx"
-#define INIT_CONFIG_IPSEC_IF_NO "ipsec_if"
+#define INIT_CONFIG_IPSEC_MODE_RX "ipsec_mode_rx"
+#define INIT_CONFIG_IPSEC_MODE_TX "ipsec_mode_tx"
+#define INIT_CONFIG_IPSEC_IF_NO "ipsec_if"
+#define INIT_CONFIG_NUM_FP_CORES "fast_path_core"
+#define INIT_CONFIG_NUM_FP_THREADS "slow_path_core"
#define CONFIG_STRING_LEN 128
//IPSEC MODE(only choose one rx and one tx)
nwalIpAddr_t remote_ipsec_ip;
uint8_t ipsec_mode_rx;
uint8_t ipsec_mode_tx;
- int ipsec_if_no;
+ uint8_t ipsec_if_no;
+ uint8_t fp_proc_start[NET_TEST_MAX_FP_THREAD];
+ uint8_t fp_proc_end[NET_TEST_MAX_FP_THREAD];
+ uint8_t fp_thread_num[NET_TEST_MAX_FP_THREAD];
+ uint8_t num_fp_threads;
+ uint8_t sp_proc_start[NET_TEST_MAX_FP_THREAD];
+ uint8_t sp_proc_end[NET_TEST_MAX_FP_THREAD];
+ uint8_t sp_thread_num[NET_TEST_MAX_FP_THREAD];
+ uint8_t num_sp_threads;
+
uint8_t auth_key[MAX_SEC_INDEX][36];
uint8_t encr_key[MAX_SEC_INDEX][36];
uint32_t tunnel_id[MAX_SEC_INDEX];
char dst_ips[MAX_ROUTES][CONFIG_STRING_LEN];
char paths[MAX_ROUTES][CONFIG_STRING_LEN];
char ipsec_if_no[CONFIG_STRING_LEN];
+ char fp_thread_num[NET_TEST_MAX_FP_THREAD][CONFIG_STRING_LEN];
+ char sp_thread_num[NET_TEST_MAX_FP_THREAD][CONFIG_STRING_LEN];
+ char sp[NET_TEST_MAX_FP_THREAD][CONFIG_STRING_LEN];
+ char fp[NET_TEST_MAX_FP_THREAD][CONFIG_STRING_LEN];
char tunnel_id[CONFIG_STRING_LEN];
netTestConfigSA_t sa_config[MAX_SEC_INDEX];
void parse_one_ip(char * p_ip_addr_str, unsigned char * p_ip);
void parse_mac_address(netTestConfigFile_t *pConfig);
void parse_ip_address(netTestConfigFile_t *pConfig);
+void parse_fp(netTestConfigFile_t *pConfig);
+void parse_sp(netTestConfigFile_t *pConfig);
void parse_ipsec_mode(netTestConfigFile_t *pConfig);
void parse_auth_mode(char *auth_mode_str, nwal_saAALG *auth_mode);
void parse_encr_mode(char *ency_mode_str, nwal_saEALG*encr_mode);
void parse_key_size(char *key_size_str, uint16_t *key_size);
void parse_tunnel_id(char * tunnel_id_str, uint32_t *tunnel_id);
void parse_dir(char* dir_str, nwal_SaDir *dir);
+
+void parse_num_fp_cores(netTestConfigFile_t *pConfig);
+void parse_num_fp_threads(netTestConfigFile_t *pConfig);
+void parse_num_fp_threads(netTestConfigFile_t *pConfig);
+
+
void parse_sa(netTestConfigFile_t *pConfig, int i);
#ifdef EXPERIMENTAL
void parse_routes(netTestConfigFile_t *pConfig);
void create_interfaces(NETCP_CFG_IP_T *ip_rule0 , NETCP_CFG_IP_T *ip_rule1);
void delete_interfaces(NETCP_CFG_IP_T *ip_rule0 , NETCP_CFG_IP_T *ip_rule1);
+void slow_path_thread(int coreid);
+void fast_path_thread(int coreid);
#endif