index b3031c458094bd05000e817aa5ad83071ce064dd..1cd895d6b91d01aca873f0a9c5662d92f25a86f4 100755 (executable)
-/******************************************
+/******************************************************************************
* File: net_test_router.c
* Purpose: net_test_router application
- **************************************************************
+ ******************************************************************************
* FILE: net_test_router.c
*
* DESCRIPTION: netapi user space transport
* library net_test_router application
*
- * REVISION HISTORY: rev 0.0.1
+ * REVISION HISTORY:
*
* Copyright (c) Texas Instruments Incorporated 2013
*
* (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_util.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;
nwal_RetValue nwalRetVal;
Pktlib_HeapHandle ourHeap;
-Pktlib_HeapHandle specialSmall;
-Pktlib_HeapHandle specialLarge;
+PKTIO_HANDLE_T *netcp_tx_chan_no_crypto;
PKTIO_HANDLE_T *netcp_rx_chan;
-PKTIO_HANDLE_T *netcp_rx_chan2;
-PKTIO_HANDLE_T *netcp_tx_chan;
-PKTIO_HANDLE_T *netcp_sb_tx_chan;
-PKTIO_HANDLE_T *netcp_sb_rx_chan;
-PKTIO_CFG_T our_chan_cfg={PKTIO_RX_TX, PKTIO_LOCAL, PKTIO_Q_ANY, 8};
+PKTIO_HANDLE_T *netcp_tx_chan_esp;
+PKTIO_HANDLE_T *netcp_tx_chan_ah;
+
+
+
+
PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
-PKTIO_CFG_T netcp_rx_cfg2={PKTIO_RX, (PKTIO_GLOBAL|PKTIO_PKT), PKTIO_Q_ANY, 8};
PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
-PKTIO_CFG_T netcp_sb_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
-PKTIO_CFG_T netcp_sb_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
+
+
NETCP_CFG_EXCEPTION_PKT_T expPkt_appid;
-static hplib_spinLock_T stats_lock;
-Trie * P_trie;
Trie *p_trie_sa_rx;
Trie *p_trie_sa_tx;
#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={
};
-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_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
/* security objects. (for loopback mode) */
netTestSA_t sa_info[MAX_SEC_INDEX];
/*************************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
-NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
-void slow_path_thread(int coreid)
+#ifdef netTest_MULTI_THREAD
+/* Templates to build command labels at startup up time, required by open_pktio_tx_channels() */
+nwalTxPktInfo_t txPktInfoESP =
+{
+ NULL, /* p_pkt */
+ NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
+ 0, /* lpbackPass */
+ 1, /* enetport */
+ 0, /* msuSize */
+ 0, /* startOffset */
+ netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
+ 0, /* saPayLoadLen */
+ 0 , /* saAhIcvOffBytes */
+ 0, /* saAhMacSize */
+ 0, /* etherLenOffBytes */
+ netTest_MAC_HEADER_LEN, /* ipOffBytes */
+ 0, /* l4OffBytes */
+ 0, /* l4HdrLen */
+ 0, /* pseudoHdrChecksum */
+ 0 /* pLoadLen */
+};
+
+
+nwalTxPktInfo_t txPktInfoAH =
+{
+ NULL, /* p_pkt */
+ NWAL_TX_FLAG1_DO_IPSEC_AH_CRYPTO| NWAL_TX_FLAG1_DO_IPV4_CHKSUM | NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
+ 0, /* lpbackPass */
+ 0, /* enetport */
+ 0, /* msuSize */
+ 0, /* startOffset */
+ netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
+ 0, /* saPayLoadLen */
+ netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE, /* saAhIcvOffBytes */
+ 12, /* saAhMacSize */
+ 0, /* etherLenOffBytes */
+ netTest_MAC_HEADER_LEN, /* ipOffBytes */
+ 0, /* l4OffBytes */
+ netTest_UDP_HEADER_LEN, /* l4HdrLen */
+ 0, /* pseudoHdrChecksum */
+ 0 /* pLoadLen */
+};
+
+nwalTxPktInfo_t txPktInfoNoCrypto =
+{
+ NULL, /* p_pkt */
+ NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
+ 0, /* lpbackPass */
+ 0, /* enetport */
+ 0, /* msuSize */
+ 0, /* startOffset */
+ 0, /* saOffBytes */
+ 0, /* saPayLoadLen */
+ 0 , /* saAhIcvOffBytes */
+ 0, /* saAhMacSize */
+ 0, /* etherLenOffBytes */
+ netTest_MAC_HEADER_LEN, /* ipOffBytes */
+ netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN, /* l4OffBytes */
+ netTest_UDP_HEADER_LEN, /* l4HdrLen */
+ 0, /* pseudoHdrChecksum */
+ 0 /* pLoadLen */
+};
+
+void close_pktio_channels(void)
+{
+ int err;
+ netapi_pktioClose(netcp_tx_chan_no_crypto ,&err);
+ netapi_pktioClose(netcp_tx_chan_esp ,&err);
+ netapi_pktioClose(netcp_tx_chan_ah ,&err);
+}
+
+
+
+void open_pktio_tx_channels()
{
int err;
+ /* open netcp default TX channels */
+ netcp_tx_chan_no_crypto= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_no_crypto)
+ {
+ netapi_Log("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ else
+ {
+ if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+ {
+ PKTIO_CONTROL_T control;
+ control.op = PKTIO_UPDATE_FAST_PATH;
+ PKTIO_CFG_T cfg;
+ cfg.fast_path_cfg.fp_send_option = PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT;
+ cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
+ //netapi_pktioControl(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
+ }
+ }
+ /* open netcp default TX for ESP packets */
+ netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_esp)
+ {
+ netapi_Log("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ else
+ {
+ if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+ {
+ PKTIO_CONTROL_T control;
+ control.op = PKTIO_UPDATE_FAST_PATH;
+ PKTIO_CFG_T cfg;
+ cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_PORT;
+ cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
+ //netapi_pktioControl(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
+ }
+ }
+
+ /*/* open netcp default TX for AH packets */
+ netcp_tx_chan_ah= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
+ if (!netcp_tx_chan_ah)
+ {
+ netapi_Log("pktio open TX failed err=%d\n",err);
+ exit(1);
+ }
+ else
+ {
+ if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
+ {
+ PKTIO_CONTROL_T control;
+ control.op = PKTIO_UPDATE_FAST_PATH;
+ PKTIO_CFG_T cfg;
+ cfg.fast_path_cfg.fp_send_option = PKTIO_FP_AH_PORT;
+ cfg.fast_path_cfg.txPktInfo= &txPktInfoAH;
+ //netapi_pktioControl(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
+ }
+ }
+}
+
+
+
+
+NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
+void slow_path_thread(uint32_t index)
+{
+ int err,i;
+ uint32_t thread_num;
PKTIO_HANDLE_T *rx_chan;
- PKTIO_HANDLE_T *tx_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
- CPU_SET( coreid, &cpu_set);
- hplib_utilSetupCore(coreid, &cpu_set);
+ for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
+ {
+ printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
+ CPU_SET( i, &cpu_set);
+ }
+ hplib_utilSetupThread(thread_num, &cpu_set);
#else
- CPU_SET( 0, &cpu_set);
- hplib_utilSetupCore(coreid+1, &cpu_set);
+ for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
+ {
+ printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
+ CPU_SET( i, &cpu_set);
+ }
+ hplib_utilSetupThread(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);
+ /* 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 = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
-
- netapi_setCookie(worker_nh[coreid],(void*)coreid);
+ netapi_setCookie(worker_nh[thread_num],(void*) (thread_num | NET_TEST_SP_THREAD_MASK));
- 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);
+ netapi_Log("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);
+ netapi_Log("slow_path_thread: core %d worker thread done\n",thread_num);
- pktio_close(tx_chan, &err);
- pktio_close(rx_chan, &err);
- netapi_shutdown(worker_nh[coreid]);
+ //netapi_pktioClose(rx_chan, &err);
+ netapi_shutdown(worker_nh[thread_num]);
}
-void fast_path_thread(int coreid)
+
+void fast_path_thread(uint32_t index)
{
- int err;
+ int err,i;
+ uint32_t thread_num;
PKTIO_HANDLE_T *rx_chan;
- PKTIO_HANDLE_T *tx_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
- CPU_SET( coreid, &cpu_set);
- hplib_utilSetupCore(coreid, &cpu_set);
+ 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_utilSetupThread(thread_num, &cpu_set);
#else
- CPU_SET( 0, &cpu_set);
- hplib_utilSetupCore(coreid + 1, &cpu_set);
+ 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_utilSetupThread(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_router, &netcp_rx_cfg, &err);
- netapi_setCookie(worker_nh[coreid],(void*)coreid);
+ /* open netcp RX channel */
+ rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
+ 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);
+ netapi_Log("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);
- pktio_close(tx_chan, &err);
- pktio_close(rx_chan, &err);
- netapi_shutdown(worker_nh[coreid]);
-\r}
+ netapi_schedRun(scheduler[thread_num], &err);
+ netapi_Log("fast_path_thread: core %d worker thread done\n",thread_num);
+ netapi_pktioClose(rx_chan, &err);
+ netapi_shutdown(worker_nh[thread_num]);
+}
#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;
+ cpu_set_t cpu_set;
+ /* install signal handler for ^c */
+ signal(SIGINT,netTest_utilMySig);
- err= getrlimit(RLIMIT_STACK,&rl);
- if (!err) Debug_printf(" stack limit = %d\n",rl.rlim_cur); else Debug_printf("getrlimit failed\n");
-
- /* install signal handler for ^c */
- signal(SIGINT,mysig);
-
- fpr = fopen(input_file_name, "r");
- if (fpr == NULL)
+ if (argc == 2)
+ {
+ fpr = fopen(argv[1], "r");
+ }
+ else
+ {
+ fpr = fopen(input_file_name, "r");
+ }
+ if (fpr == NULL)
{
- Debug_printf("Error in opening %s input file\n", input_file_name);
exit(1);
}
else
{
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);
- netcp_cfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
- expPkt_appid = netcp_cfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+ /* configure expection packet handling with netapi */
+ netapi_netcpCfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+ expPkt_appid = netapi_netcpCfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
/* open the main heap */
ourHeap = Pktlib_findHeapByName("netapi");
if (!ourHeap)
{
- Debug_printf("Pktlib_findHeapByName() fail\n");
+ netapi_Log("Pktlib_findHeapByName() fail\n");
exit(1);
}
- /* create two secondary heaps */
- /* Initialize the heap configuration. */
- memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
-
- pPktifTable = netapi_getPktlibIfTable();
- /* Populate the heap configuration */
- heapCfg.name = "netapi-small";
- heapCfg.memRegion = NETAPI_GLOBAL_REGION;
- heapCfg.sharedHeap = 1;
- heapCfg.useStarvationQueue = 0;
- heapCfg.dataBufferSize = 512;
- heapCfg.numPkts = 64;
- heapCfg.numZeroBufferPackets= 0;
- heapCfg.heapInterfaceTable.data_malloc = pPktifTable->data_malloc;
- heapCfg.heapInterfaceTable.data_free = pPktifTable->data_free;
- heapCfg.dataBufferPktThreshold = 0;
- heapCfg.zeroBufferPktThreshold = 0;
-
- specialSmall = Pktlib_createHeap(&heapCfg, &errCode);
- heapCfg.name = "netapi-big";
- heapCfg.dataBufferSize = 1600;
- specialLarge = Pktlib_createHeap(&heapCfg, &errCode);
- //register these heaps so poll routine will include their garbage queues.
- netapi_registerHeap(netapi_handle, specialSmall);
- netapi_registerHeap(netapi_handle, specialLarge);
-
- /* open netcp default tx, rx queues */
- netcp_tx_chan= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
- if (!netcp_tx_chan)
- {
- Debug_printf("pktio open TX failed err=%d\n",err);
- exit(1);
- }
- netcp_rx_chan= pktio_open(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
- if (!netcp_rx_chan)
- {
- Debug_printf("pktio open RX failed err=%d\n",err);
- exit(1);
- }
+ /* Open all required PKTIO TX channels */
+ open_pktio_tx_channels();
- Debug_printf("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
+ netapi_Log("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) {netapi_Log("sched create failed\n"); exit(1);}
/*create net_test MAC interfaces, attach IP to created MAC interfaces */
- create_interfaces(&ip_rule0, &ip_rule1);
+ netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
+ /* Lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
p_trie_sa_rx = trie_new();
p_trie_sa_tx = trie_new();
if (!p_trie_sa_rx || !p_trie_sa_tx)
- {Debug_printf("trie alloc for SA failed\n"); exit(1);}
+ {netapi_Log("trie alloc for SA failed\n"); exit(1);}
- /* Create RX SA's, RX Policy and TX SA's */
- create_sec_associations(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
+ /* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
+ 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=='h') Debug_printf("'q' to quit, 's' for stats, 'h' for help\n");
+ 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);
-/*************************************************
- ************CLEAN UP****************************
- ************************************************/
+ /* cleanup*/
+ netTest_utilDeleteSecAssoc();
+ netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
- 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);
+ /* 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;
@@ -438,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
@@ -456,19 +580,26 @@ static inline void send_it(Ti_Pkt *tip, int len, ROUTE_SEC_T * p_sec, int out_po
Pktlib_setPacketLen(tip,len);
meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
meta_tx2.startOffset = 0;
- meta_tx2.ipOffBytes = 14;
+ meta_tx2.ipOffBytes = netTest_MAC_HEADER_LEN;
meta_tx2.ploadLen = len ;
meta_tx2.enetPort=out_port;
if(p_sec)
{
meta_tx2.txFlag1 |= NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO ;
- meta2.sa_handle=p_sec->tx_inflow_mode_handle; //this tells netapi that inflow crypto needs to be applied
- meta_tx2.saOffBytes=14+20;
- meta_tx2.saPayloadLen=len-14-20; //don't include tag, mac and outer header
+ //meta2.sa_handle = (void*)p_sec->tx_tunnel;
+ 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;
+ netapi_pktioSend(netcp_tx_chan_esp,tip,&meta2,&err);
stats[coreid].sec_tx+=1;
}
- meta2.u.tx_meta=&meta_tx2;
- pktio_send(netcp_tx_chan,tip,&meta2,&err);
+ else
+ {
+ meta2.u.tx_meta=&meta_tx2;
+ netapi_pktioSend(netcp_tx_chan_no_crypto,tip,&meta2,&err);
+
+ }
stats[coreid].tx +=1;
st2=hplib_mUtilGetPmuCCNT();
stats[coreid].send_cycles += (unsigned long long) (st2-st1);
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);
PKTIO_METADATA_T meta[], int n_pkts,
uint64_t ts )
{
-}
\ No newline at end of file
+}
+