index bf1a2a37941b8eeff73ebd00dd4d02b1e9633387..4d5b4fc09ef4dc758aad68373b1719128c9db8ff 100755 (executable)
*
* DESCRIPTION: net_test application general utilities
*
- * REVISION HISTORY: rev 0.0.1
+ * REVISION HISTORY:
*
* Copyright (c) Texas Instruments Incorporated 2010-2011
*
*****************************************/
-#include "net_test_util.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+#include "net_test_utils.h"
#include <signal.h>
#include <pthread.h>
-#include "trie.h"
#include "router.h"
+#include "ti/drv/nwal/test/fw_rm.h"
#include <ti/drv/sa/salld.h>
#include <ti/drv/pa/pa.h>
extern netTestSA_t sa_info[];
extern NETAPI_SCHED_HANDLE_T * scheduler[];
extern Pktlib_HeapHandle ourHeap;
-extern Pktlib_HeapHandle specialSmall;
-extern Pktlib_HeapHandle specialLarge;
-extern 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;
-//#include "router.c"
+netTestStats_T stats[NET_TEST_MAX_SP_THREAD + NET_TEST_MAX_FP_THREAD +1];
+paSysStats_t netcp_stats;
-OUR_ROUTE_T routes[MAX_ROUTES]=
+static LastPktInfo_t lpInfo;
+int netTest_utilCheckHeader(netTestHead_T * p_head, PKTIO_METADATA_T * p_meta)
{
-{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}};
-
-static struct LastPktInfo lpInfo;
-int check_header(HEAD_T * p_head, PKTIO_METADATA_T * p_meta)
-{
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
- //int coreid = our_core;
#else
int coreid=0;
#endif
-if (NWAL_RX_FLAG1_META_DATA_VALID & p_meta->u.rx_meta->rxFlag1)
-{
- lpInfo.iface = ((unsigned int)p_meta->u.rx_meta->appId) &0xff; //last byte is interface num
- lpInfo.ipcsum =(p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_MASK )== NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_ACK ? 1 : 0;
- lpInfo.l4csum = (p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_MASK )== ((NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_ACK) << NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_SHIFT) ? 1 : 0;
- if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC)
- {
- stats[coreid].sec_rx++;
- }
- if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC_POLICY)
+ if (NWAL_RX_FLAG1_META_DATA_VALID & p_meta->u.rx_meta->rxFlag1)
{
- stats[coreid].secp_rx++;
- }
+ lpInfo.iface = ((unsigned int)p_meta->u.rx_meta->appId) &0xff; //last byte is interface num
+ lpInfo.ipcsum =(p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_MASK )== NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_ACK ? 1 : 0;
+ lpInfo.l4csum = (p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_MASK )== ((NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_ACK) << NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_SHIFT) ? 1 : 0;
+ if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC)
+ {
+ stats[coreid].sec_rx++;
+ }
+ if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC_POLICY)
+ {
+ stats[coreid].secp_rx++;
+ }
- if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_CLASS)
- {
- int c= ((unsigned int)p_meta->u.rx_meta->appId >>8)&0xffff;
- if (c==0) stats[coreid].n_class0_rx +=1;
- else if (c==1) stats[coreid].n_class1_rx +=1;
- else if (c==2) stats[coreid].n_class2_rx +=1;
- else Debug_printf("**NET_TEST RX -unknown class: %x\n", p_meta->u.rx_meta->appId);
-}
+ if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_CLASS)
+ {
+ int c= ((unsigned int)p_meta->u.rx_meta->appId >>8)&0xffff;
+ if (c==0) stats[coreid].n_class0_rx +=1;
+ else if (c==1) stats[coreid].n_class1_rx +=1;
+ else if (c==2) stats[coreid].n_class2_rx +=1;
+ else netapi_Log("**NET_TEST RX -unknown class: %x\n", p_meta->u.rx_meta->appId);
+ }
}
return 1;
static int scnt=0;
int QUIT;
-void mysig(int x)
+void netTest_utilMySig(int x)
{
QUIT=1;
scnt+=1;
- printf(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
+ netapi_Log(">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");
+ netapi_Log(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");
exit(1);
}
}
-unsigned long peek(unsigned long * p)
+unsigned long netTest_utilPeek(unsigned long * p)
{
return *p;
}
-void dump_descr(unsigned long *p, int n)
+void netTest_utilDumpDescr(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");
+ netapi_Log("--------dump of descriptor %d %x\n", n, (int) p);
+ netapi_Log("> %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]);
+ netapi_Log("> %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]);
+ netapi_Log("-----------------------------\n");
}
-void dump_header(unsigned long *p, int n, int a, int r)
+void netTest_utilDumpHeader(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");
+ netapi_Log("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
+ netapi_Log("> %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]);
+ netapi_Log("> %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]);
+ netapi_Log("> %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]);
+ netapi_Log("> %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]);
+ netapi_Log("-----------------------------\n");
}
-void netapi_dump_buf
+void netTest_utilDumpBuffer
(
unsigned long * buf,
uint32_t buf_length
tmp_buf = (uint8_t *)(buf);
- printf("netapi *: - 8 bit word hex Length: %d Start \n",buf_length);
+ netapi_Log("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",
+ netapi_Log("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",
+ netapi_Log("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",
+ netapi_Log("netapi *: %02d : %02x %02x \n",
count,tmp_buf[0],tmp_buf[1]);
break;
}
case 1:
{
- printf("netapi *: %02d : %02x \n",
+ netapi_Log("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);
+ netapi_Log("netapi *: Internal Error in netTest_utilDumpBuffer().Row Count: %d \n", row_count);
return;
}
}
}while(count < dump_size);
- printf("netapi *: - Byte hex Dump End \n");
+ netapi_Log("netapi *: - Byte hex Dump End \n");
}
-long htonl(long x)
+long netTest_utilHtonl(long x)
{
long temp = (x&0xff000000)>>24 | (x&0xff0000)>>8 | (x&0xff00)<<8 | (x&0xff)<<24 ;
return temp;
}
-unsigned char hex2dec(char *p_s)
+unsigned char netTest_utilHex2Dec(char *p_s)
{
- int val;
- sscanf(p_s,"%x",&val);
- return val&0xff;
+ int val;
+ sscanf(p_s,"%x",&val);
+ return val&0xff;
}
/********************************************************************
* FUNCTION PURPOSE: Ones complement addition utility
********************************************************************
********************************************************************/
-uint16_t test_utilOnesComplementAdd (uint16_t v1, uint16_t v2)
+uint16_t netTest_utilOnesComplementAdd (uint16_t v1, uint16_t v2)
{
uint32_t result;
* FUNCTION PURPOSE: Ones complement checksum utility
********************************************************************
********************************************************************/
- uint16_t test_utilOnesCompChkSum (uint8_t *p, uint32_t nwords)
+ uint16_t netTest_utilOnesCompChkSum (uint8_t *p, uint32_t nwords)
{
uint16_t chksum = 0;
uint16_t v;
for (i = j = 0; i < nwords; i++, j+=2) {
v = (p[j] << 8) | p[j+1];
- chksum = test_utilOnesComplementAdd (chksum, v);
+ chksum = netTest_utilOnesComplementAdd (chksum, v);
}
return (chksum);
} /* utilOnesCompChkSum */
**************************************************************************************
* DESCRIPTION: Compute ipv4 psudo checksum
**************************************************************************************/
-uint16_t test_utilGetIpv4PsudoChkSum (uint8_t *data, uint16_t payloadLen)
+uint16_t netTest_utilGetIPv4PsudoChkSum (uint8_t *data, uint16_t payloadLen)
{
uint16_t psudo_chksum;
- psudo_chksum = test_utilOnesCompChkSum (&data[12], 4);
- psudo_chksum = test_utilOnesComplementAdd(psudo_chksum, (uint16_t) data[9]);
- psudo_chksum = test_utilOnesComplementAdd(psudo_chksum, payloadLen);
+ psudo_chksum = netTest_utilOnesCompChkSum (&data[12], 4);
+ psudo_chksum = netTest_utilOnesComplementAdd(psudo_chksum, (uint16_t) data[9]);
+ psudo_chksum = netTest_utilOnesComplementAdd(psudo_chksum, payloadLen);
return (psudo_chksum);
#define CHECK_SET_PARAM(ARG1, ARG2) \
do { \
if(strcmp(key, ARG1) == 0) { \
- if(d1)strncpy(ARG2,d1,CONFIG_STRING_LEN); \
+ if(d1)strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
continue; \
} \
} while(0)
#define CHECK_SET_PARAM2(ARG1, ARG2, ARG3) \
do { \
if(strcmp(key, ARG1) == 0) { \
- if(d1) strncpy(ARG2,d1,CONFIG_STRING_LEN); \
- if(d2) strncpy(ARG3,d2,CONFIG_STRING_LEN); \
+ if(d1) strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
+ if(d2) strncpy(ARG3,d2,netTest_CONFIG_STRING_LEN); \
continue; \
} \
} while(0)
ARG6, ARG7, ARG8, ARG9, ARG10, \
ARG11, ARG12,ARG13, ARG14, ARG15, ARG16,ARG17, ARG18) \
do { \
- if(d1) strncpy(ARG2,d1,CONFIG_STRING_LEN); \
- if(d2) strncpy(ARG3,d2,CONFIG_STRING_LEN); \
- if(d3) strncpy(ARG4,d3,CONFIG_STRING_LEN); \
- if(d4) strncpy(ARG5,d4,CONFIG_STRING_LEN); \
- if(d5) strncpy(ARG6, d5,CONFIG_STRING_LEN); \
- if(d6) strncpy(ARG7,d6,CONFIG_STRING_LEN); \
- if(d7) strncpy(ARG8,d7,CONFIG_STRING_LEN); \
- if(d8) strncpy(ARG9,d8,CONFIG_STRING_LEN); \
- if(d9) strncpy(ARG10,d9,CONFIG_STRING_LEN); \
- if(d10) strncpy(ARG11,d10,CONFIG_STRING_LEN); \
- if(d11) strncpy(ARG12,d11,CONFIG_STRING_LEN); \
- if(d12) strncpy(ARG13,d12,CONFIG_STRING_LEN); \
- if(d13) strncpy(ARG14,d13,CONFIG_STRING_LEN); \
- if(d14) strncpy(ARG15,d14,CONFIG_STRING_LEN); \
- if(d15) strncpy(ARG16,d15,CONFIG_STRING_LEN); \
- if(d16) strncpy(ARG17,d16,CONFIG_STRING_LEN); \
- if(d17) strncpy(ARG18,d17,CONFIG_STRING_LEN); \
+ if(strcmp(key, ARG1) == 0) { \
+ if(d1) strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
+ if(d2) strncpy(ARG3,d2,netTest_CONFIG_STRING_LEN); \
+ if(d3) strncpy(ARG4,d3,netTest_CONFIG_STRING_LEN); \
+ if(d4) strncpy(ARG5,d4,netTest_CONFIG_STRING_LEN); \
+ if(d5) strncpy(ARG6, d5,netTest_CONFIG_STRING_LEN); \
+ if(d6) strncpy(ARG7,d6,netTest_CONFIG_STRING_LEN); \
+ if(d7) strncpy(ARG8,d7,netTest_CONFIG_STRING_LEN); \
+ if(d8) strncpy(ARG9,d8,netTest_CONFIG_STRING_LEN); \
+ if(d9) strncpy(ARG10,d9,netTest_CONFIG_STRING_LEN); \
+ if(d10) strncpy(ARG11,d10,netTest_CONFIG_STRING_LEN); \
+ if(d11) strncpy(ARG12,d11,netTest_CONFIG_STRING_LEN); \
+ if(d12) strncpy(ARG13,d12,netTest_CONFIG_STRING_LEN); \
+ if(d13) strncpy(ARG14,d13,netTest_CONFIG_STRING_LEN); \
+ if(d14) strncpy(ARG15,d14,netTest_CONFIG_STRING_LEN); \
+ if(d15) strncpy(ARG16,d15,netTest_CONFIG_STRING_LEN); \
+ if(d16) strncpy(ARG17,d16,netTest_CONFIG_STRING_LEN); \
+ if(d17) strncpy(ARG18,d17,netTest_CONFIG_STRING_LEN); \
continue; \
+ } \
} while(0)
-void print_ipsec_stats(Sa_IpsecStats_t *p_saIpsecStats, nwal_saAALG auth, nwal_saEALG cipher)
+void netTest_utilPrintIPSecStats(Sa_IpsecStats_t *p_saIpsecStats, nwal_saAALG auth, nwal_saEALG cipher)
{
#if 0
if(retVal != nwal_OK)
{
- System_System_Debug_printf("CORE: %d Error getting IP Sec Stats: Ret Status: %d \n",
+ System_System_netapi_Log("CORE: %d Error getting IP Sec Stats: Ret Status: %d \n",
retVal);
return(nwal_FALSE);
}
if((p_saIpsecStats->pktEncHi) ||(p_saIpsecStats->pktEncLo))
{
- Debug_printf("------------- IPSec TX (Encryption Channel) Stats BEGIN --\n");
+ Debug_netapi_Log("------------- IPSec TX (Encryption Channel) Stats BEGIN --\n");
}
else
{
- printf("------------- IPSec RX (Decryption Channel) Stats BEGIN --\n");
+ netapi_Log("------------- 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",
+ netapi_Log("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
+ netapi_Log("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",
+ netapi_Log("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)
+void netTest_utilPrintDataModeStats(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",
+ netapi_Log("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
+ netapi_Log(" Packets processedHi: 0x%x, Packets processed Lo:0x%x\n",
p_saDataModeStats->pktHi, p_saDataModeStats->pktLo);
}
/******************************************************
* stats callback
*******************************************************/
-void our_stats_cb_mt(NETAPI_T h, paSysStats_t* pPaStats)
+void netTest_utilStatsCbMt(NETAPI_T h, paSysStats_t* pPaStats)
{
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
int coreid=Osal_nwalGetProcId(); //who we are(thread local)
//int coreid = our_core;
#else
stats[coreid].n_stats_cb +=1;
if(pPaStats) memcpy(&netcp_stats,pPaStats, sizeof(paSysStats_t));
}
-void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats)
+void netTest_utilsStatsCb(NETAPI_T h, paSysStats_t* pPaStats)
{
-uint32_t numFreeDataPackets;
-uint32_t numZeroBufferPackets;
-uint32_t numPacketsinGarbage;
-Pktlib_HeapStats pktLibHeapStats;
-int i;
-unsigned long long bcpp;
-unsigned long long bcpp_noc;
-unsigned long long bcpp_app;
-unsigned long long bcpp_tx;
-unsigned long long npL;
-unsigned long long cyclesL;
-unsigned long long ccyclesL; //cache cycles
-unsigned long long tmp_npL[TUNE_NETAPI_NUM_CORES];
-unsigned long long tmp_cyclesL[TUNE_NETAPI_NUM_CORES];
-unsigned long long tmp_ccyclesL[TUNE_NETAPI_NUM_CORES]; //cache cycles
-NETAPI_SA_STATS_T netapi_sa_stats;
-
- for (i=0;i < TUNE_NETAPI_NUM_CORES;i++)
+ uint32_t numFreeDataPackets;
+ uint32_t numZeroBufferPackets;
+ uint32_t numPacketsinGarbage;
+ Pktlib_HeapStats pktLibHeapStats;
+ int i,j;
+ unsigned long long bcpp;
+ unsigned long long bcpp_noc;
+ unsigned long long bcpp_app;
+ unsigned long long bcpp_tx;
+ unsigned long long npL;
+ unsigned long long cyclesL;
+ unsigned long long ccyclesL; //cache cycles
+ unsigned long long tmp_npL[TUNE_NETAPI_NUM_CORES];
+ unsigned long long tmp_cyclesL[TUNE_NETAPI_NUM_CORES];
+ unsigned long long tmp_ccyclesL[TUNE_NETAPI_NUM_CORES]; //cache cycles
+ NETAPI_SA_STATS_T netapi_sa_stats;
+
+ uint8_t num_threads = netTestCfg.num_fp_threads;
+ for (j= 0;j < num_threads;j++)
{
- printf("Per Core Statistics for CORE %d\n", i);
+ if (netTestCfg.fp_thread_num[j] == 0)
+ continue;
+ i = netTestCfg.fp_thread_num[j];
+ printf("Per THREAD Statistics for Thread %d\n", netTestCfg.fp_thread_num[j]);;
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"
"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].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);
+ printf(">thread 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",
printf("\n");
}
-#ifdef MULTI_THREAD
+#ifdef netTest_MULTI_THREAD
for (i=0;i < TUNE_NETAPI_NUM_CORES;i++)
{
if(scheduler[i])
pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-Pktlib_getHeapStats(specialSmall, &pktLibHeapStats);
-printf("specialSmall heap stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
- pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
- pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
- pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-
-
-Pktlib_getHeapStats(specialLarge, &pktLibHeapStats);
-printf("specialLarge heap stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
- pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
- pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
- pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-
-
#if 0
-printf("pa2sa descriptor area dump\n");
+netapi_Log("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);
+ netTest_utilDumpDescr(tip, i);
}
-printf("sa2pa descriptor area dump\n");
+netapi_Log("sa2pa descriptor area dump\n");
for(i=0;i<TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;i++)
{
extern long * sa2pa_descr_base;
long * tip= &sa2pa_descr_base[32*i];
- dump_descr(tip, i);
+ netTest_utilDumpDescr(tip, i);
}
#endif
- for (i = 0; i < MAX_SEC_INDEX; i++)
+ for (i = 0; i < netTestCfg.num_sa; i++)
{
/* Statistics for RX Tunnel */
memset(&netapi_sa_stats, 0, sizeof(netapi_sa_stats));
- if (sa_info[i].dir ==NWAL_SA_DIR_INBOUND )
+ if (netTestCfg.sa[i].dir ==NWAL_SA_DIR_INBOUND )
{
netapi_getSaStats(netapi_handle, sa_info[i].rx_tunnel, &netapi_sa_stats);
if (netapi_sa_stats.validParams & NETAPI_IPSEC_STAT_VALID)
{
- print_ipsec_stats(&(netapi_sa_stats.saIpsecStats),
- sa_info[i].authMode,
- sa_info[i].cipherMode);
+ netTest_utilPrintIPSecStats(&(netapi_sa_stats.saIpsecStats),
+ netTestCfg.sa[i].authMode,
+ netTestCfg.sa[i].cipherMode);
}
if (netapi_sa_stats.validParams & NETAPI_SIDEBAND_DATA_MODE_STAT_VALID)
{
- print_datamode_stats(&(netapi_sa_stats.dataModeStats),
- sa_info[i].authMode,
- sa_info[i].cipherMode);
+ netTest_utilPrintDataModeStats(&(netapi_sa_stats.dataModeStats),
+ netTestCfg.sa[i].authMode,
+ netTestCfg.sa[i].cipherMode);
}
}
- else if (sa_info[i].dir ==NWAL_SA_DIR_OUTBOUND)
+ else if (netTestCfg.sa[i].dir ==NWAL_SA_DIR_OUTBOUND)
{
netapi_getSaStats(netapi_handle, sa_info[i].tx_tunnel, &netapi_sa_stats);
if (netapi_sa_stats.validParams & NETAPI_IPSEC_STAT_VALID)
{
- print_ipsec_stats(&(netapi_sa_stats.saIpsecStats),
- sa_info[i].authMode,
- sa_info[i].cipherMode);
+ netTest_utilPrintIPSecStats(&(netapi_sa_stats.saIpsecStats),
+ netTestCfg.sa[i].authMode,
+ netTestCfg.sa[i].cipherMode);
}
if (netapi_sa_stats.validParams & NETAPI_SIDEBAND_DATA_MODE_STAT_VALID)
{
- print_datamode_stats(&(netapi_sa_stats.dataModeStats),
- sa_info[i].authMode,
- sa_info[i].cipherMode);
+ netTest_utilPrintDataModeStats(&(netapi_sa_stats.dataModeStats),
+ netTestCfg.sa[i].authMode,
+ netTestCfg.sa[i].cipherMode);
}
}
else
- printf("our_stats_cb: invalid SA direction\n");
+ netapi_Log("netTest_utilsStatsCb: invalid SA direction\n");
}
netapi_dump_internal_heap_stats();
}
-void parse_one_mac(char * p_mac_str, unsigned char *p_mac)
-{
- int index = 0;
- int i;
- char *pch = strtok (&(p_mac_str[0]),"-");
- while (pch != NULL)
+
+void parse_dsp_mac(char * p_mac_str)
+{
+ if (strlen(&p_mac_str[0]))
{
- p_mac[index] = hex2dec(pch);
- index++;
- pch = strtok (NULL,"-");
+ printf("parse_dsp_mac(string): %s\n", p_mac_str);
+ sscanf(p_mac_str,"mac%d",&netTestCfg.dsp_mac);
+ printf("parse_dsp_mac(integer): mac: %d\n", netTestCfg.dsp_mac);
}
}
+void parse_dsp_ip(char * p_ip_str)
+{
+ if (strlen(&p_ip_str[0]))
+ {
+ printf("parse_dsp_ip: %s\n", p_ip_str);
+ sscanf(p_ip_str,"ip%d",&netTestCfg.dsp_ip);
+ printf("parse_dsp_ip: ip: %d\n", netTestCfg.dsp_ip);
+ }
+}
-void parse_one_key(char *p_key_str, unsigned char *p_key)
+void netTest_utilParseOneKey(char *p_key_str, unsigned char *p_key)
{
int index = 0;
int i;
- char * pch = strtok (&p_key_str[0],",");
-
- while (pch != NULL)
+ if (strlen(&p_key_str[0]))
{
- p_key[index] = hex2dec(pch);
- index++;
- pch = strtok (NULL,",");
+ char * pch = strtok (&p_key_str[0],",");
+
+ while (pch != NULL)
+ {
+ p_key[index] = netTest_utilHex2Dec(pch);
+ index++;
+ pch = strtok (NULL,",");
+ }
}
}
-void parse_one_ip(char * p_ip_addr_str, unsigned char * p_ip)
+void netTest_utilParseOneIP(char * p_ip_addr_str, unsigned char * p_ip)
{
int index = 0;
int i;
- char * pch = strtok (&p_ip_addr_str[0],".");
+ if (strlen(&p_ip_addr_str[0]))
+ {
+ char * pch = strtok (&p_ip_addr_str[0],".");
+
+ while (pch != NULL)
+ {
+ p_ip[index] = atoi(pch);
+ index++;
+ pch = strtok (NULL,".");
+ }
+ }
+}
- while (pch != NULL)
+void netTest_utilParseOneMac(char * p_mac_str, unsigned char *p_mac)
+{
+ int index = 0;
+ int i;
+ if (strlen(&p_mac_str[0]))
{
- p_ip[index] = atoi(pch);
- index++;
- pch = strtok (NULL,".");
+ char *pch = strtok (&(p_mac_str[0]),"-");
+
+ while (pch != NULL)
+ {
+ p_mac[index] = netTest_utilHex2Dec(pch);
+ index++;
+ pch = strtok (NULL,"-");
+ }
}
}
-void parse_mac_address(netTestConfigFile_t *pConfig)
+void netTest_utilParseMac(netTestConfigFile_t *pConfig)
{
int i;
int port = 0;
if (strlen(&pConfig->mac[i][0]))
{
netTestCfg.num_macs++;
- parse_one_mac(&pConfig->mac[i][0],&netTestCfg.mac[i][0]);
+ netTest_utilParseOneMac(&pConfig->mac[i][0],&netTestCfg.mac[i][0]);
sscanf(&pConfig->switch_port[i][0],"sp%d",&netTestCfg.switch_port[i]);
}
}
- Debug_printf("parse_mac_address: number of mac address %d\n", netTestCfg.num_macs);
+ netapi_Log("netTest_utilParseMac: number of mac address %d\n", netTestCfg.num_macs);
}
-void parse_ip_address(netTestConfigFile_t *pConfig)
+void netTest_utilParseIP(netTestConfigFile_t *pConfig)
{
int i;
if (strlen(&pConfig->ip[i][0]))
{
netTestCfg.num_ips++;
- parse_one_ip(&pConfig->ip[i][0],&netTestCfg.ip[i].ipv4[0]);
+ netTest_utilParseOneIP(&pConfig->ip[i][0],&netTestCfg.ip[i].ipv4[0]);
sscanf(&pConfig->attach_iface[i][0],"mac%d",&netTestCfg.attach_iface[i]);
}
}
- Debug_printf("parse_ip_address: number of ip address %d\n", netTestCfg.num_ips);
+ netapi_Log("netTest_utilParseIP: number of ip address %d\n", netTestCfg.num_ips);
}
-void parse_ipsec_mode(netTestConfigFile_t *pConfig)
+void netTest_utilParseIpsecMode(netTestConfigFile_t *pConfig)
{
if (strlen(&pConfig->ipsec_mode_rx[0]))
}
else
{
- Debug_printf("parse_ipsec_mode(), invalid RX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseIpsecMode(), invalid RX ipsec mode in config file \n");
}
}
}
else
{
- Debug_printf("parse_ipsec_mode(), invalid TX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseIpsecMode(), invalid TX ipsec mode in config file \n");
}
}
}
-void parse_auth_mode(char *auth_mode_str, nwal_saAALG *auth_mode)
+void netTest_utilParseAuthMode(char *auth_mode_str, nwal_saAALG *auth_mode)
{
if (strlen(auth_mode_str))
{
- Debug_printf("strlen of auth_mode_str is %d\n", strlen(auth_mode_str));
+ netapi_Log("strlen of auth_mode_str is %d\n", strlen(auth_mode_str));
if (strcmp(auth_mode_str, "NULL") == 0)
{
}
else
{
- Debug_printf("parse_auth_mode: invalid auth mode specified\n");
+ netapi_Log("netTest_utilParseAuthMode: invalid auth mode specified\n");
}
}
}
-void parse_encr_mode(char *ency_mode_str, nwal_saEALG*encr_mode)
+void netTest_utilParseEncryptMode(char *ency_mode_str, nwal_saEALG*encr_mode)
{
if (strlen(ency_mode_str))
{
}
else
{
- Debug_printf("parse_encr_mode: invalid auth mode specified\n");
+ netapi_Log("netTest_utilParseEncryptMode: invalid auth mode specified\n");
}
}
}
-void parse_proto(char *proto_str, nwal_IpSecProto *proto)
+void netTest_utilParseProto(char *proto_str, nwal_IpSecProto *proto)
{
if (strlen(proto_str))
{
if (strcmp(proto_str, "ESP") == 0)
{
*proto= nwal_IpSecProtoESP;
- Debug_printf("parse_proto(): setting proto to ESP\n");
+ netapi_Log("netTest_utilParseProto(): setting proto to ESP\n");
}
else if (strcmp(proto_str, "AH") == 0)
{
*proto = nwal_IpSecProtoAH;
- Debug_printf("parse_proto(): setting proto to AH\n");
+ netapi_Log("netTest_utilParseProto(): setting proto to AH\n");
}
else
{
- Debug_printf("parse_proto(), invalid RX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseProto(), invalid RX ipsec mode in config file \n");
}
}
}
-void parse_mode(char *mode_str, nwal_saMode *mode)
+void netTest_utilParseSaMode(char *mode_str, nwal_saMode *mode)
{
if (strlen(mode_str))
{
}
else
{
- Debug_printf("parse_mode(), invalid RX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseSaMode(), invalid RX ipsec mode in config file \n");
}
}
}
-void parse_ipType(char *ip_type_str, nwal_IpType *ipType)
+void netTest_utilParseIPType(char *ip_type_str, nwal_IpType *ipType)
{
if (strlen(ip_type_str))
{
}
else
{
- Debug_printf("parse_ipType(), invalid RX ipsec mode in config file \n");
+ netapi_Log("netTest_utilParseIPType(), invalid RX ipsec mode in config file \n");
}
}
}
-void parse_spi(char *spi_str, uint32_t *spi)
+void parse_simple_param_u16(char* input_str, uint16_t *val)
{
- if (strlen(spi_str))
+ if (strlen(input_str))
{
- *spi = (int)strtol(spi_str, NULL, 0);
+ *val = (uint16_t)strtol(input_str, NULL, 0);
}
}
-void parse_replayWindow(char *replay_window_str, uint32_t *replay_window)
-{
- *replay_window = atoi(replay_window_str);
-}
-
-void parse_esn(char *esn_str, uint32_t *esn)
+void parse_simple_param_u32(char* input_str, uint32_t *val)
{
- *esn = atoi(esn_str);
-}
-
-void parse_key_size(char *key_size_str, uint16_t *key_size)
-{
- *key_size = atoi(key_size_str);
-}
-
-void parse_tunnel_id(char * tunnel_id_str, uint32_t *tunnel_id)
-{
- if (strlen(tunnel_id_str))
+ if (strlen(input_str))
{
- *tunnel_id = (int)strtol(tunnel_id_str, NULL, 0);
+ *val = (uint32_t)strtol(input_str, NULL, 0);
}
}
-void parse_dir(char* dir_str, nwal_SaDir *dir)
+void netTest_utilParseSADir(char* dir_str, nwal_SaDir *dir)
{
if (strlen(dir_str))
{
*dir = NWAL_SA_DIR_OUTBOUND;
}
else
- Debug_printf("parse_dir: invalid direction\n");
+ netapi_Log("netTest_utilParseSADir: invalid direction\n");
}
}
-void parse_one_fp(char * p_fp_str, uint8_t* start, uint8_t* end)
+void netTest_utilParseThreadConfig(char * p_thread_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(p_thread_str))
{
- 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]);
- }
+ char *pch = strtok (&(p_thread_str[0]),"-");
+ *start = atoi(pch);
+ pch = strtok (NULL,"-");
+ *end = atoi(pch);
+ netapi_Log("netTest_utilParseThreadConfig: start %d, end %d\n", *start, *end);
}
- printf("parse_sp: number of sp threads %d\n", netTestCfg.num_sp_threads);
-
}
-
-void parse_fp(netTestConfigFile_t *pConfig)
+void netTest_utilParseThreadParams(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);
+ netTest_utilParseThreadConfig(&pConfig->fp[i][0],
+ (uint8_t*)&netTestCfg.fp_proc_start[i],
+ (uint8_t*)&netTestCfg.fp_proc_end[i]);
+ printf("netTest_utilParseThreadParams: fp start[%d]: %d, fp end[%d]: %d\n",
+ i,
+ netTestCfg.fp_proc_start[i],
+ i,
+ netTestCfg.fp_proc_end[i]);
}
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]);
+ netTestCfg.fp_thread_num[i] = atoi((char*)(&pConfig->fp_thread_num[i]));
+ netapi_Log("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);
+ netapi_Log("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]))
+ for(i=0;i<NET_TEST_MAX_SP_THREAD;i++)
{
- netTestCfg.ipsec_if_no= atoi(&pConfig->ipsec_if_no[0]);
- printf("parse_ipsec_if_no %d\n",netTestCfg.ipsec_if_no);
+ if (strlen(&pConfig->sp[i][0]))
+ {
+ netTestCfg.num_sp_threads++;
+ netTest_utilParseThreadConfig(&pConfig->sp[i][0],
+ (uint8_t*)&netTestCfg.sp_proc_start[i],
+ (uint8_t*)&netTestCfg.sp_proc_end[i]);
+ }
+ if (strlen(&pConfig->sp_thread_num[i][0]))
+ {
+ netTestCfg.sp_thread_num[i] = atoi((char*)(&pConfig->sp_thread_num[i]));
+ netapi_Log("parse_sp: thread_num[%d]: %d\n", i, netTestCfg.sp_thread_num[i]);
+ }
}
+ netapi_Log("parse_sp: number of sp threads %d\n", netTestCfg.num_sp_threads);
}
-
-void parse_sa(netTestConfigFile_t *pConfig, int i)
+void netTest_utilParseSA(netTestConfigFile_t *pConfig)
{
- parse_dir((char*) &pConfig->sa_config[i].dir, &netTestCfg.sa_info[i].dir);
- parse_spi((char*)&pConfig->sa_config[i].spi, &netTestCfg.sa_info[i].spi);
- parse_proto((char*)&pConfig->sa_config[i].proto, &netTestCfg.sa_info[i].proto);
- parse_mode((char*)&pConfig->sa_config[i].saMode, &netTestCfg.sa_info[i].saMode);
- parse_ipType((char*)&pConfig->sa_config[i].ipType, &netTestCfg.sa_info[i].ipType);
- parse_one_ip((char*)&pConfig->sa_config[i].src, (unsigned char *)&netTestCfg.sa_info[i].src);
- parse_one_ip((char*)&pConfig->sa_config[i].dst, (unsigned char *)&netTestCfg.sa_info[i].dst);
- parse_replayWindow((char*)&pConfig->sa_config[i].replayWindow, &netTestCfg.sa_info[i].replayWindow);
- parse_auth_mode((char*)&pConfig->sa_config[i].authMode, &netTestCfg.sa_info[i].authMode);
- parse_encr_mode((char*)&pConfig->sa_config[i].cipherMode, &netTestCfg.sa_info[i].cipherMode);
- parse_esn((char*)&pConfig->sa_config[i].esnLo, &netTestCfg.sa_info[i].esnLo);
- parse_esn((char*)&pConfig->sa_config[i].esnHi, &netTestCfg.sa_info[i].esnHi);
- parse_key_size((char*)&pConfig->sa_config[i].encKeySize, &netTestCfg.key_params[i].encKeySize);
- parse_key_size((char*)&pConfig->sa_config[i].macKeySize, &netTestCfg.key_params[i].macKeySize);
+ int i;
+ for(i=0;i<MAX_SEC_INDEX;i++)
+ {
+ if (strlen((char*)&pConfig->sa_config[i][0].dir))
+ {
+ netTest_utilParseSADir((char*) &pConfig->sa_config[i][0].dir, &netTestCfg.sa[i].dir);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].spi, &netTestCfg.sa[i].spi);
+ netTest_utilParseProto((char*)&pConfig->sa_config[i][0].proto, &netTestCfg.sa[i].proto);
+ netTest_utilParseSaMode((char*)&pConfig->sa_config[i][0].saMode, &netTestCfg.sa[i].saMode);
+ netTest_utilParseIPType((char*)&pConfig->sa_config[i][0].ipType, &netTestCfg.sa[i].ipType);
+ netTest_utilParseOneIP((char*)&pConfig->sa_config[i][0].src, (unsigned char *)&netTestCfg.sa[i].src);
+ netTest_utilParseOneIP((char*)&pConfig->sa_config[i][0].dst, (unsigned char *)&netTestCfg.sa[i].dst);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].replayWindow, &netTestCfg.sa[i].replayWindow);
+ netTest_utilParseAuthMode((char*)&pConfig->sa_config[i][0].authMode, &netTestCfg.sa[i].authMode);
+ netTest_utilParseEncryptMode((char*)&pConfig->sa_config[i][0].cipherMode, &netTestCfg.sa[i].cipherMode);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].esnLo, &netTestCfg.sa[i].esnLo);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].esnHi, &netTestCfg.sa[i].esnHi);
+ parse_simple_param_u16((char*)&pConfig->sa_config[i][0].encKeySize, &netTestCfg.key_params[i].encKeySize);
+ parse_simple_param_u16((char*)&pConfig->sa_config[i][0].macKeySize, &netTestCfg.key_params[i].macKeySize);
- parse_one_key((char*) &pConfig->sa_config[i].encr_key, &netTestCfg.encr_key[i][0]);
- netTestCfg.key_params[i].pEncKey = (uint8_t*)&netTestCfg.encr_key[i][0];
+ netTest_utilParseOneKey((char*) &pConfig->sa_config[i][0].encr_key, &netTestCfg.encr_key[i][0]);
+ netTestCfg.key_params[i].pEncKey = (uint8_t*)&netTestCfg.encr_key[i][0];
- parse_one_key((char*)&pConfig->sa_config[i].auth_key, &netTestCfg.auth_key[i][0]);
- netTestCfg.key_params[i].pAuthKey= (uint8_t*)&netTestCfg.auth_key[i][0];
+ netTest_utilParseOneKey((char*)&pConfig->sa_config[i][0].auth_key, &netTestCfg.auth_key[i][0]);
+ netTestCfg.key_params[i].pAuthKey= (uint8_t*)&netTestCfg.auth_key[i][0];
- parse_tunnel_id((char*)&pConfig->sa_config[i].tunnel_id, &netTestCfg.tunnel_id[i]);
+ parse_simple_param_u32((char*)&pConfig->sa_config[i][0].tunnel_id, &netTestCfg.tunnel_id[i]);
-
+ netTestCfg.num_sa++;
+ }
+ }
}
-
-
-int n_routes=0;
-int n_dst_ips=0;
-void parse_routes(netTestConfigFile_t *pConfig)
+void netTest_utilParseRoutes(netTestConfigFile_t *pConfig, OUR_ROUTE_T *routes, Trie ** our_router)
{
int i;
int said=0;
if (pConfig->routes[i][0])
{
port=atoi(&pConfig->ports[i][0]);
- if((port<1)||(port>2)) continue; //bad port #: only 1 or 2 valid
- Debug_printf("parse_routes [%d]: %s\n", i, &pConfig->routes[i][0]);
- if(strncmp(&pConfig->routes[i][0],"MAC",3)==0)
- {
- routes[i].out_port = port;
- parse_one_mac(&pConfig->routes[i][3],&routes[i].out_mac[0]);
- //memcpy(&routes[i].out_mac[6], ((port==1) ?&config.mac0[0]: &config.mac1[0] ),6);
- memcpy(&routes[i].out_mac[6], ((port==1) ?&netTestCfg.mac[0][0]: &netTestCfg.mac[1][0] ),6);
- routes[i].out_mac[12]=0x08;
- routes[i].out_mac[13]=0x00;
- routes[i].sec_ptr=NULL;
- n_routes+=1;
- }
- else if (strncmp(&pConfig->routes[i][0],"SA",2)==0)
- {
- said=atoi(&pConfig->routes[i][2]) ;
- routes[i].sec_ptr=&sa_info[said];
- n_routes+=1;
- }
- }
+ if((port<1)||(port>2)) continue; //bad port #: only 1 or 2 valid
+ netapi_Log("netTest_utilParseRoutes [%d]: %s\n", i, &pConfig->routes[i][0]);
+ if(strncmp(&pConfig->routes[i][0],"MAC",3)==0)
+ {
+ routes[i].out_port = port;
+ netTest_utilParseOneMac(&pConfig->routes[i][3],&routes[i].out_mac[0]);
+ //memcpy(&routes[i].out_mac[6], ((port==1) ?&config.mac0[0]: &config.mac1[0] ),6);
+ memcpy(&routes[i].out_mac[6], ((port==1) ?&netTestCfg.mac[0][0]: &netTestCfg.mac[1][0] ),6);
+ routes[i].out_mac[12]=0x08;
+ routes[i].out_mac[13]=0x00;
+ routes[i].sec_ptr=NULL;
+ }
+ else if (strncmp(&pConfig->routes[i][0],"SA",2)==0)
+ {
+ said=atoi(&pConfig->routes[i][2]) ;
+ routes[i].sec_ptr=&sa_info[said];
+ }
+ }
}
- our_router = route_init();
+ *our_router = route_init();
for (i=0;i<MAX_ROUTES;i++)
{
unsigned long ip_be;
int route_index;
if (pConfig->dst_ips[i][0])
{
- parse_one_ip(&pConfig->dst_ips[i][0],(unsigned char *)&ip_be);
+ netTest_utilParseOneIP(&pConfig->dst_ips[i][0],(unsigned char *)&ip_be);
sscanf(&pConfig->paths[i][0],"route%d",&route_index);
- route_add(our_router,&ip_be,(void*)&routes[route_index]);
- n_dst_ips+=1;
+ route_add(*our_router,&ip_be,(void*)&routes[route_index]);
}
}
-//Debug_printf(">Route DB built. %d entries\n",n_dst_ips);
}
-void parse_config_file(FILE * fpr, netTestConfigFile_t *pConfig)
+void netTest_utilProcessConfigFile(FILE * fpr, netTestConfigFile_t *pConfig)
{
char line[MAX_LINE_LENGTH + 1];
int i;
d16 = (char *)strtok(NULL, tokens);
d17 = (char *)strtok(NULL, tokens);
- 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)
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_IPSEC_MODE_RX,&(pConfig->ipsec_mode_rx[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_IPSEC_MODE_TX,&(pConfig->ipsec_mode_tx[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_IPSEC_IF_NO,&(pConfig->ipsec_if_no[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_DSP_MAC,&(pConfig->dsp_mac[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_DSP_IP,&(pConfig->dsp_ip[0]));
+ CHECK_SET_PARAM(netTest_INIT_CONFIG_STATIC_LOOPBACK_PORT,&(pConfig->dest_udp_port_config[0]));
+
+
+ for(i=0;i<MAX_SEC_INDEX;i++)
{
- Debug_printf("parse_config_file, temp_str %s, sa_count: %d\n", temp_str, sa_count);
+ sprintf(temp_str,"sa%d",i);
CHECK_SET_PARAM_SA(temp_str,
- (char*)&pConfig->sa_config[sa_count].dir,
- (char*)&pConfig->sa_config[sa_count].spi,
- (char*)&pConfig->sa_config[sa_count].proto,
- (char*)&pConfig->sa_config[sa_count].saMode,
- (char*)&pConfig->sa_config[sa_count].ipType,
- (char*)&pConfig->sa_config[sa_count].src,
- (char*)&pConfig->sa_config[sa_count].dst,
- (char*)&pConfig->sa_config[sa_count].replayWindow,
- (char*)&pConfig->sa_config[sa_count].authMode,
- (char*)&pConfig->sa_config[sa_count].cipherMode,
- (char*)&pConfig->sa_config[sa_count].esnLo,
- (char*)&pConfig->sa_config[sa_count].esnHi,
- (char*)&pConfig->sa_config[sa_count].encKeySize,
- (char*)&pConfig->sa_config[sa_count].macKeySize,
- (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);
- sa_count++;
- continue;
+ (char*)&pConfig->sa_config[i][0].dir,
+ (char*)&pConfig->sa_config[i][0].spi,
+ (char*)&pConfig->sa_config[i][0].proto,
+ (char*)&pConfig->sa_config[i][0].saMode,
+ (char*)&pConfig->sa_config[i][0].ipType,
+ (char*)&pConfig->sa_config[i][0].src,
+ (char*)&pConfig->sa_config[i][0].dst,
+ (char*)&pConfig->sa_config[i][0].replayWindow,
+ (char*)&pConfig->sa_config[i][0].authMode,
+ (char*)&pConfig->sa_config[i][0].cipherMode,
+ (char*)&pConfig->sa_config[i][0].esnLo,
+ (char*)&pConfig->sa_config[i][0].esnHi,
+ (char*)&pConfig->sa_config[i][0].encKeySize,
+ (char*)&pConfig->sa_config[i][0].macKeySize,
+ (char*)&pConfig->sa_config[i][0].encr_key,
+ (char*)&pConfig->sa_config[i][0].auth_key,
+ (char*)&pConfig->sa_config[i][0].tunnel_id);
}
-#ifdef EXPERIMENTAL
for(i=0;i<MAX_ROUTES;i++)
{
sprintf(temp_str,"route%d",i);
sprintf(temp_str,"dstip%d",i);
CHECK_SET_PARAM2(temp_str,&pConfig->dst_ips[i][0],&pConfig->paths[i][0] );
}
-#endif
for(i=0;i<NET_TEST_MAX_MAC;i++)
{
sprintf(temp_str,"mac%d",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++)
+ for(i=0;i<NET_TEST_MAX_FP_THREAD;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++)
+ for(i=0;i<NET_TEST_MAX_SP_THREAD;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);
-
-
-#ifdef EXPERIMENTAL
- parse_routes(pConfig);
-#endif
-
- parse_ipsec_if_no(pConfig);
- //parse_num_fp_cores(pConfig);
- //parse_num_fp_threads(pConfig);
-
}
//******************************************************
unsigned long long n_c_ops;
static int first =0;
Cppi_HostDesc* pPktDesc;
+ NETAPI_SCHED_SHUTDOWN_T sched_shutdown;
- int coreid = 0; //who we are
-#ifdef MULTI_THREAD
+ uint32_t coreid = 0; //who we are
+#ifdef netTest_MULTI_THREAD
NETAPI_T nh= netapi_schedGetHandle(s);
- coreid=(int) netapi_getCookie(nh);
+ coreid=(uint32_t) netapi_getCookie(nh);
- if (QUIT) {netapi_schedClose(s,NULL,&err); return;}
+ if (QUIT)
+ {
+ sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
+ netapi_schedClose(s,&sched_shutdown,&err);
+ return;
+ }
- if (coreid==0) //slave
+
+ /* only slow path threads get netcp stats */
+ if (coreid & NET_TEST_SP_THREAD_MASK)
{
- netcp_cfgReqStats(nh, our_stats_cb_mt, 0,&err);
+ netapi_netcpCfgReqStats(nh, netTest_utilStatsCbMt, 0,&err);
}
+
+ coreid = NET_TEST_THREAD_NUM_MASK & coreid;
#else
+ coreid = NET_TEST_THREAD_NUM_MASK & coreid;
if(done_burst)
{
house_pkts_gened+=TX_BURST;
- Debug_printf("net_test> request stats at n=%d \n",house_pkts_gened);
- netcp_cfgReqStats(netapi_handle, our_stats_cb, 0,&err);
- if (err!=0) {Debug_printf("stats req failed\n");}
+ netapi_Log("net_test> request stats at n=%d \n",house_pkts_gened);
+ netapi_netcpCfgReqStats(netapi_handle, netTest_utilsStatsCb, 0,&err);
+ if (err!=0) {netapi_Log("stats req failed\n");}
if (house_pkts_gened >= np2process+ 100)
{
- netapi_schedClose(s,NULL,&err);
+ sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
+ netapi_schedClose(s,&sched_shutdown,&err);
}
return;
}
//reguest stats
if ((house_pkts_gened>0) && (! (house_pkts_gened%1000)) )
{
- Debug_printf("net_test> request stats at n=%d \n",house_pkts_gened);
- netcp_cfgReqStats(netapi_handle, our_stats_cb, 0,&err);
- if (err!=0) {Debug_printf("stats req failed\n");}
+ netapi_Log("net_test> request stats at n=%d \n",house_pkts_gened);
+ netapi_netcpCfgReqStats(netapi_handle, netTest_utilsStatsCb, 0,&err);
+ if (err!=0) {netapi_Log("stats req failed\n");}
}
if (house_pkts_gened >= np2process+ 100)
{
- //shutdown
- netapi_schedClose(s,NULL,&err);
- continue;
+ //shutdown
+ sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
+ netapi_schedClose(s,&sched_shutdown,&err);
+ continue;
}
else if (house_pkts_gened >= np2process) { house_pkts_gened+=1; continue;}
/* manufacture a pkt to transmit */
- tip = get_pkt(house_pkts_gened, &len, ourHeap, PKT_LEN,&testPkt[0] , TEST_PKT_LEN);
+ tip = get_pkt(house_pkts_gened, &len, ourHeap, netTest_PKT_LEN,&testPkt[0] , TEST_netTest_PKT_LEN);
if(!tip) { house_pkts_gened +=1; continue; }
}
pIpHdr = pData + meta_tx.ipOffBytes;
meta_tx.pseudoHdrChecksum =
- test_utilGetIpv4PsudoChkSum(pIpHdr,(TEST_PAYLOAD_LEN+TEST_PKT_UDP_HDR_LEN));
+ netTest_utilGetIPv4PsudoChkSum(pIpHdr,(TEST_PAYLOAD_LEN+TEST_PKT_UDP_HDR_LEN));
#else
Pktlib_getDataBuffer(tip,&pData,&len);
if(house_pkts_gened &0x1)
/* post it to netcp tx channel*/
meta.u.tx_meta=&meta_tx;
#ifdef DEBUG_DESC
- if (house_pkts_gened<16) dump_descr((long *) tip, house_pkts_gened);
- else if (house_pkts_gened>99) dump_descr((long *) tip,house_pkts_gened);
+ if (house_pkts_gened<16) netTest_utilDumpDescr((long *) tip, house_pkts_gened);
+ else if (house_pkts_gened>99) netTest_utilDumpDescr((long *) tip,house_pkts_gened);
#endif
if(!first)
&meta_tx,
&flowPSCmdInfo) != nwal_OK)
{
- Debug_printf("nwal_initPSCmdInfo() ERROR \n");
+ netapi_Log("nwal_initPSCmdInfo() ERROR \n");
}
nwal_flow_vv2= hplib_mUtilGetPmuCCNT();
nwal_sum_flow_vv1 += (nwal_flow_vv1-vv1);
sum_vv3 += (vv3-vv2)-(long) (cache_op_b2-cache_op_b1); //sub out cache op cost
- // Debug_printf("pktio send. full=%d metadata=%d pktio_send=%d\n", vv3-vv1, vv2-vv1, vv3-vv2);
+ // netapi_Log("pktio send. full=%d metadata=%d netapi_pktioSend=%d\n", vv3-vv1, vv2-vv1, vv3-vv2);
stats[coreid].itx +=1;
house_pkts_gened +=1;
}
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",
+ netapi_Log("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
- Debug_printf("NWAL Profile Cycles: Prof1= %d,Prof2=%d,Prof3=%d,Prof4=%d,Prof5=%d ,Prof6=%d \n",
+ netapi_Log("NWAL Profile Cycles: Prof1= %d,Prof2=%d,Prof3=%d,Prof4=%d,Prof5=%d ,Prof6=%d \n",
nwal_sum_vv1/stats[coreid].itx,nwal_sum_vv2/stats[coreid].itx,nwal_sum_vv3/stats[coreid].itx,
nwal_sum_vv4/stats[coreid].itx,nwal_sum_vv5/stats[coreid].itx,nwal_sum_vv6/stats[coreid].itx);
if(stats[core_id].itx2)
{
- printf("nwal_flowSend Profile Cycles: Prof1= %d,Prof2=%d \n",
+ netapi_Log("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 netTest_utilCreateInterfaces(uint8_t num_macs, uint8_t num_ips)
{
int err, i;
- for (i = 0; i < netTestCfg.num_macs; i++)
+ for (i = 0; i < num_macs; i++)
{
/* add mac intefaces */
- netcp_cfgCreateMacInterface(
+ mac[i] = netapi_netcpCfgCreateMacInterface(
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);
+ netapi_Log("addmac %d failed %d\n",i, err);
//exit(1);
}
else
- printf("create_interfaces, added mac sucess\n");
+ netapi_Log("netTest_utilCreateInterfaces, added mac sucess\n");
}
- for (i = 0; i < netTestCfg.num_ips; i++)
+ for (i = 0; i < num_ips; i++)
{
//attach an IP to this interface
- *ip_rule0=netcp_cfgAddIp(
+ ip_rule[i]=netapi_netcpCfgAddIp(
netapi_handle,
- //ETH0,
netTestCfg.attach_iface[i],
nwal_IPV4,
- (nwalIpAddr_t *)&netTestCfg.ip[i].ipv4[0],
+ (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);
+ netapi_Log("netTest_utilCreateInterfaces: add ip %d failed %d\n", i, err);
//exit(1);
}
else
- printf("create_interfaces, added ip sucess\n");
+ netapi_Log("netTest_utilCreateInterfaces, added ip sucess\n");
}
}
-void delete_interfaces(NETCP_CFG_IP_T *ip_rule0 , NETCP_CFG_IP_T *ip_rule1)
+void netTest_utilDeleteInterfaces(uint8_t num_macs, uint8_t num_ips)
{
- 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 < num_ips; i++)
+ {
+ err = 0;
+ netapi_netcpCfgDelIp(netapi_handle, netTestCfg.attach_iface[i], nwal_IPV4,
+ NULL, NULL, ip_rule[i], &err);
+ }
+ for (i = 0; i < num_macs; i++)
+ {
+ err = 0;
+ netapi_netcpCfgDelMac(netapi_handle,i,&err);
+ }
+
+ //netapi_netcpCfgDelMac(netapi_handle,0,&err);
+ //netapi_netcpCfgDelMac(netapi_handle,1,&err);
+
}
+
+