index 13dd1f42b87da22e9b826952b7c0eb8a1929fba2..1cd895d6b91d01aca873f0a9c5662d92f25a86f4 100755 (executable)
-/******************************************
+/******************************************************************************
* File: net_test_router.c
* Purpose: net_test_router application
- **************************************************************
+ ******************************************************************************
* FILE: net_test_router.c
*
* DESCRIPTION: netapi user space transport
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *****************************************/
+ ******************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <pthread.h>
-
-#include "net_test.h"
#include "trie.h"
-#include "string.h"
+#include <signal.h>
+#include <pthread.h>
#include <sys/resource.h>
-
-#include <ti/drv/sa/salld.h>
-#include <ti/drv/pa/pa.h>
-
-#include "net_test_utils.h"
-
+#include "router.h"
extern int QUIT;
/* Global definitions */
-#ifdef MULTI_THREAD
- cpu_set_t cpu_set;
-#endif
netTestConfig_t netTestCfg;
static netTestConfigFile_t config_file;
#include "router.c"
-extern Trie * our_router;
-extern OUR_ROUTE_T routes[];
+Trie * our_router;
+
+OUR_ROUTE_T routes[MAX_ROUTES]=
+{
+ {0,{0xD4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x14,0x02,0x08,0x00},0},
+ {0,{0x00,0x00,0x0,0x00,0x0,0x0, 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00},0},
+ {0,{0xD4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x14,0x02,0x08,0x00},0},
+ {0,{0x00,0x15,0x60,0xa1,0xf7,0xbe, 0x00,0x01,0x02,0x03,0x04,0x05,0x08,0x00},0},
+ {0,{0xd4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x04,0x05,0x08,0x00},0}
+};
unsigned int ip[MAX_ROUTES]={BE(0x0a0100c8),BE(0x0a00000a),BE(0x0a02000a),BE(0xc0a8010a),BE(0x9eda6719)};
void recv_cb_router(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
uint64_t ts );
-extern STATS_T stats[TUNE_NETAPI_NUM_CORES];
+extern netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
extern paSysStats_t netcp_stats;
/*******************************************
void house(NETAPI_SCHED_HANDLE_T *s);
NETAPI_T netapi_handle;
NETAPI_SCHED_HANDLE_T * our_sched;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
#endif
NETAPI_SCHED_CONFIG_T our_sched_cfg={
/*************************END NETAPI OBJECTS***********************/
-void update_header(HEAD_T * p_head, int len)
+void update_header(netTestHead_T * p_head, int len)
{
unsigned char *p = (unsigned char *) &p_head->udp[1];
len -= (20+14);
*(p+1) = len&0xff;
}
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
/* Templates to build command labels at startup up time, required by open_pktio_tx_channels() */
nwalTxPktInfo_t txPktInfoESP =
{
NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
-void slow_path_thread(uint32_t thread_num)
+void slow_path_thread(uint32_t index)
{
int err,i;
+ uint32_t thread_num;
PKTIO_HANDLE_T *rx_chan;
PKTIO_HANDLE_T *sb_tx_chan;
PKTIO_HANDLE_T *sb_rx_chan;
+ cpu_set_t cpu_set;
+ thread_num = netTestCfg.sp_thread_num[index];
+ printf("slow_path_thread for index %d called for thread %d\n", index, thread_num);
CPU_ZERO( &cpu_set);
#ifdef CORTEX_A15
- for (i = netTestCfg.sp_proc_start[thread_num]; i <= netTestCfg.sp_proc_end[thread_num];i++)
+ for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
{
- printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+ printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
CPU_SET( i, &cpu_set);
}
- hplib_utilSetupCore(thread_num, &cpu_set);
+ hplib_utilSetupThread(thread_num, &cpu_set);
#else
- for (i = netTestCfg.sp_proc_start[thread_num]; i <= netTestCfg.sp_proc_end[thread_num];i++)
+ for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
{
- printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+ printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
CPU_SET( i, &cpu_set);
}
- hplib_utilSetupCore(thread_num, &cpu_set);
+ hplib_utilSetupThread(thread_num, &cpu_set);
#endif
worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
/* open netcp RX channel */
- rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
+ //rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
/**************Entry point into scheduler ****/
/*********************************************/
netapi_schedRun(scheduler[thread_num], &err);
- netapi_Log(">net_test: core %d worker thread done\n",thread_num);
+ netapi_Log("slow_path_thread: core %d worker thread done\n",thread_num);
- netapi_pktioClose(rx_chan, &err);
+ //netapi_pktioClose(rx_chan, &err);
netapi_shutdown(worker_nh[thread_num]);
}
-void fast_path_thread(uint32_t thread_num)
+void fast_path_thread(uint32_t index)
{
int err,i;
+ uint32_t thread_num;
PKTIO_HANDLE_T *rx_chan;
PKTIO_HANDLE_T *sb_tx_chan;
- //PKTIO_HANDLE_T *sb_rx_chan;
+ cpu_set_t cpu_set;
+
+ thread_num = netTestCfg.fp_thread_num[index];
+ printf("fast_path_thread for index %d called for thread %d\n", index, thread_num);
+ CPU_ZERO( &cpu_set);
#ifdef CORTEX_A15
- for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+ for (i = netTestCfg.fp_proc_start[index]; i <= netTestCfg.fp_proc_end[index];i++)
{
printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
CPU_SET( i, &cpu_set);
}
- hplib_utilSetupCore(thread_num, &cpu_set);
+ hplib_utilSetupThread(thread_num, &cpu_set);
#else
- for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+ for (i = netTestCfg.fp_proc_start[index]; i <= netTestCfg.fp_proc_end[index];i++)
{
printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
CPU_SET( i, &cpu_set);
}
- hplib_utilSetupCore(thread_num, &cpu_set);
+ hplib_utilSetupThread(thread_num, &cpu_set);
#endif
worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
scheduler[thread_num]->config.pollCtrlQ = FALSE;
//sleep(100000);
netapi_schedRun(scheduler[thread_num], &err);
- netapi_Log(">net_test: core %d worker thread done\n",thread_num);
+ netapi_Log("fast_path_thread: core %d worker thread done\n",thread_num);
netapi_pktioClose(rx_chan, &err);
netapi_shutdown(worker_nh[thread_num]);
-\r}
-
+}
#endif
/***************************************
{
int err,i;
Pktlib_HeapCfg heapCfg;
- rlim_t oss,ss = 1024*1024;
- struct rlimit rl;
int32_t errCode;
Pktlib_HeapIfTable* pPktifTable;
-/* Local Per Process default resourcese maintained at NWAL */
- nwalLocCxtInfo_t nwalLocCxt;
-
FILE * fpr = NULL;
-
- err= getrlimit(RLIMIT_STACK,&rl);
- if (!err) netapi_Log(" stack limit = %d\n",rl.rlim_cur); else netapi_Log("getrlimit failed\n");
-
- /* install signal handler for ^c */
- signal(SIGINT,mysig);
+ cpu_set_t cpu_set;
+ /* install signal handler for ^c */
+ signal(SIGINT,netTest_utilMySig);
if (argc == 2)
{
{
memset(&config_file, 0, sizeof(netTestConfigFile_t));
memset(&netTestCfg, 0, sizeof(netTestConfig_t));
- parse_config_file(fpr,&config_file);
+ netTest_utilProcessConfigFile(fpr,&config_file);
+ netTest_utilParseMac(&config_file);
+
+ /* parse slow path/fast path thread configuration parameters */
+ netTest_utilParseThreadParams(&config_file);
+
+ netTest_utilParseIP(&config_file);
+
+ netTest_utilParseIpsecMode(&config_file);
+
+ /* DSP mac processing */
+ parse_dsp_mac(&config_file.dsp_mac[0]);
+
+ /* DSP IP processing */
+ parse_dsp_ip(&config_file.dsp_ip[0]);
+
+ netTest_utilParseRoutes(&config_file, &routes[0], &our_router);
+
+ /* IPSEC interface number processing */
+ parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
+
+ netTest_utilParseSA(&config_file);
}
memset(&sa_info, 0, sizeof(sa_info));
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
/* assign main net_test thread to run on core 0 */
CPU_ZERO( &cpu_set);
CPU_SET( 0, &cpu_set);
- hplib_utilSetupCore(0, &cpu_set);
+ hplib_utilSetupThread(0, &cpu_set);
#endif
/* create netapi */
netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
/*create net_test MAC interfaces, attach IP to created MAC interfaces */
- create_interfaces();
+ netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
/* Lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
p_trie_sa_rx = trie_new();
{netapi_Log("trie alloc for SA failed\n"); exit(1);}
/* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
- create_sec_associations();
+ netTest_utilCreateSecAssoc();
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
{
char c;
/* create and set affinity of slow path and fast path threads to
* specific CPU cores as specified in the net_test_config.txt file */
- create_sp_fp_threads();
-
+ netTest_utilCreateSpFpThreads(netTestCfg.num_sp_threads,
+ (NET_TEST_FUNC_PTR) slow_path_thread,
+ netTestCfg.num_fp_threads,
+ (NET_TEST_FUNC_PTR) fast_path_thread);
//this thread of execution (main) now just waits on user input
for(;;)
printf(">");
c=getchar();
if (c=='q') {QUIT=1;break;}
- else if (c=='s') our_stats_cb(netapi_handle, &netcp_stats);
+ else if (c=='s') netTest_utilsStatsCb(netapi_handle, &netcp_stats);
else if (c=='h') printf("'q' to quit, 's' for stats, 'h' for help\n");
}
-
+ netTest_utilRemoveSpFpThreads(netTestCfg.num_sp_threads, netTestCfg.num_fp_threads);
}
#else
/*********************************************/
#endif
/* done */
-our_stats_cb(netapi_handle, NULL);
+netTest_utilsStatsCb(netapi_handle, NULL);
/* cleanup*/
- delete_sec_associations();
- delete_interfaces();
+ netTest_utilDeleteSecAssoc();
+ netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
/* close pktio channels we opened via open_pktio_tx_channels() */
close_pktio_channels();
+ netapi_shutdown(netapi_handle);
}
-static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_port)
+static inline void send_it(Ti_Pkt *tip, int len, netTestSA_t * p_sec, int out_port)
{
unsigned long st1;
unsigned long st2;
@@ -545,7 +562,7 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
nwalTxPktInfo_t meta_tx2={0};
st1=hplib_mUtilGetPmuCCNT();
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
//int coreid = our_core;
#else
@@ -574,13 +591,13 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
meta_tx2.saOffBytes=netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
meta_tx2.saPayloadLen=len-netTest_MAC_HEADER_LEN - netTest_IP_HEADER_LEN; //don't include tag, mac and outer header
meta2.u.tx_meta=&meta_tx2;
- pktio_send(netcp_tx_chan_esp,tip,&meta2,&err);
+ netapi_pktioSend(netcp_tx_chan_esp,tip,&meta2,&err);
stats[coreid].sec_tx+=1;
}
else
{
meta2.u.tx_meta=&meta_tx2;
- pktio_send(netcp_tx_chan_no_crypto,tip,&meta2,&err);
+ netapi_pktioSend(netcp_tx_chan_no_crypto,tip,&meta2,&err);
}
stats[coreid].tx +=1;
Ti_Pkt * tip;
unsigned int templen;
char * p_pkt;
- HEAD_T temp_head;
+ netTestHead_T temp_head;
unsigned int appid;
- IP_HEAD_T th;
- ROUTE_SEC_T *sec_data=NULL;
+ IP_netTestHead_T th;
+ netTestSA_t *sec_data=NULL;
unsigned long t1;
unsigned long t2;
unsigned long long ct1;
unsigned long long n_c_ops;
int ifno;
int out_port;
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
//int coreid = our_core;
#else
case(NETAPI_NETCP_MATCH_IPSEC_POLICY):
{
int tailen=12+2;
- memcpy(&temp_head,&p_pkt[14],sizeof(HEAD_T));
- if (!check_header(&temp_head,&meta[i])) {
+ memcpy(&temp_head,&p_pkt[14],sizeof(netTestHead_T));
+ if (!netTest_utilCheckHeader(&temp_head,&meta[i])) {
stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
continue;
//now check inner headder.
memcpy(&th,&p_pkt[14],20);
- if (!check_header(&temp_head,&meta[i])) {
+ if (!netTest_utilCheckHeader(&temp_head,&meta[i])) {
stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
continue;
Pktlib_freePacket(tip);
continue;
}
- if (!check_header(&temp_head,&meta[i]))
+ if (!netTest_utilCheckHeader(&temp_head,&meta[i]))
{
stats[coreid].n_bad+=1;
Pktlib_freePacket(tip);
uint64_t ts )
{
}
+