From 4c6873a2fc0f0c48493508c2cf3b251c86abaaf3 Mon Sep 17 00:00:00 2001 From: Tinku Mannan Date: Thu, 16 May 2013 15:23:20 -0400 Subject: [PATCH] Updates to net_test_bench application, removed net_test_setup.sh --- ti/runtime/netapi/test/net_test_bench.c | 111 ++++++++++++++++------- ti/runtime/netapi/test/net_test_setup.sh | 14 --- 2 files changed, 77 insertions(+), 48 deletions(-) delete mode 100644 ti/runtime/netapi/test/net_test_setup.sh diff --git a/ti/runtime/netapi/test/net_test_bench.c b/ti/runtime/netapi/test/net_test_bench.c index 0acd1df..15177e8 100755 --- a/ti/runtime/netapi/test/net_test_bench.c +++ b/ti/runtime/netapi/test/net_test_bench.c @@ -124,7 +124,9 @@ TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap Pktlib_HeapHandle OurHeap; //default heap, used by producer PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8}; +PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8}; PKTIO_HANDLE_T * netcp_rx_chan; +PKTIO_HANDLE_T * netcp_tx_chan; NETAPI_T netapi_handle; PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL}; @@ -181,11 +183,12 @@ unsigned long t2; pkt_rx_cycles += (t2-t1); } } - printf("nt-bench: recevier DONE %d pkts rx, pkt poll cycles=% u; pkt rx cycle=%u pkt tx cycles=%u \n", pkt_rx, + printf("nt-bench: receiver DONE %d pkts rx, pkt poll cycles=% u; pkt rx cycle=%u pkt tx cycles=%u \n", pkt_rx, (unsigned) (pkt_rx ? (pkt_rx_cycles - pkt_cb_cycles)/pkt_rx : 0), (unsigned) (pkt_rx ? (pkt_rx_cycles) /pkt_rx : 0), (unsigned) (pkt_tx ? (pkt_tx_cycles) /pkt_tx : 0) ); + printf("Leaving producer_thread\n"); } @@ -204,6 +207,12 @@ int main(int argc, char **argv) //install signal handler for ^c signal(SIGINT,netTest_utilMySig); + + + + + + CPU_ZERO( &cpu_set); CPU_SET( 0, &cpu_set); hplib_utilSetupThread(2, &cpu_set); @@ -226,6 +235,9 @@ int main(int argc, char **argv) netcp_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb_net, &netcp_rx_cfg, &err); if (!netcp_rx_chan) {printf("pktio open RX failed err=%d\n",err); exit(1);} + netcp_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_TX, (PKTIO_CB) NULL, &netcp_tx_cfg, &err); + if (!netcp_tx_chan) {printf("pktio open TX failed err=%d\n",err); exit(1);} + /*********************************************/ /*****************end NETAPI STARTUP**********/ /*********************************************/ @@ -257,40 +269,41 @@ netapi_netcpCfgCreateMacInterface( //Create a worked thread //*************************************** { - pthread_t *thrs; - int procs =1; - char c; - thrs = malloc( sizeof( pthread_t ) * procs ); - if (thrs == NULL) - { - perror( "malloc" ); - return -1; - } - printf( "benchmark-test: Starting %d threads...\n", procs ); + pthread_t *thrs; + int procs =1; + char c; + thrs = malloc( sizeof( pthread_t ) * procs ); + if (thrs == NULL) + { + perror( "malloc" ); + return -1; + } + printf( "benchmark-test: Starting %d threads...\n", procs ); - if (pthread_create( &thrs[0], NULL, (void*)producer_thread, - (void *)0 )) - { - perror( "pthread_create" ); - exit(1); - } - //this thread of execution (main) now just waits on user input - for(;;) - { - printf(">"); - c=getchar(); - if (c=='q') {QUIT=1;break;} - if (c=='t') {XMIT=!XMIT; printf("XMIT= %d\n", XMIT); } - else if (c=='s') printf(">IFDMA-TEST STATS: %d received %d xmitted \n", pkt_rx,pkt_tx); - else if (c=='h') printf("> 'q' to quit, 's' for stats, 't' to toggle transmit 'h' for help\n"); - } + if (pthread_create( &thrs[0], NULL, (void*)producer_thread, + (void *)0 )) + { + perror( "pthread_create" ); + exit(1); + } + //this thread of execution (main) now just waits on user input + for(;;) + { + printf(">"); + c=getchar(); + if (c=='q') {QUIT=1;break;} + if (c=='t') {XMIT=!XMIT; printf("XMIT= %d\n", XMIT); } + else if (c=='s') printf(">IFDMA-TEST STATS: %d received %d xmitted \n", pkt_rx,pkt_tx); + else if (c=='h') printf("> 'q' to quit, 's' for stats, 't' to toggle transmit 'h' for help\n"); + } - //wait for completion - printf("main task now pending on thread completion\n"); - for (i = 0; i < procs; i++) - pthread_join( thrs[i], NULL ); + //wait for completion + printf("main task now pending on thread completion\n"); + for (i = 0; i < procs; i++) + pthread_join( thrs[i], NULL ); - free( thrs ); + free( thrs ); + } /************************************************* @@ -300,6 +313,7 @@ netapi_netcpCfgCreateMacInterface( //also close our netcp rx channel netapi_netcpCfgDelMac(netapi_handle,0,&err); netapi_pktioClose(netcp_rx_chan,&err); +netapi_pktioClose(netcp_tx_chan,&err); //done @@ -308,7 +322,26 @@ netapi_shutdown(netapi_handle); //!finished! } - +static inline void sendit(Ti_Pkt *tip, int len, int out_port) +{ + int err=0; + PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0}; + nwalTxPktInfo_t meta_tx2={0}; + if (len<60) + { + unsigned int templen; + char * p_pkt; + len=60; + Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen + Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, p_pkt,len); + } + Pktlib_setPacketLen(tip,len); + meta_tx2.txFlag1 = NWAL_TX_FLAG1_META_DATA_VALID ; + meta_tx2.ploadLen = len ; + meta_tx2.enetPort=out_port; + meta2.u.tx_meta=&meta_tx2; + netapi_pktioSend(netcp_tx_chan,tip,&meta2,&err); +} //receive callback for packets from net (for consumer) void recv_cb_net(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[], @@ -322,6 +355,9 @@ unsigned long t1; unsigned long t2; unsigned long t3; unsigned long t4; +pasahoLongInfo_t* protoInfo; +int ifno; +int out_port; t1= netapi_timing_start(); for(i=0;i just output to other port! + //---------------------------------------------------- + if (ifno ==1) out_port=2; else out_port=1; + t3= netapi_timing_start(); - //sendit(tip); + sendit(tip,len,out_port); pkt_tx+=1; t4= netapi_timing_start(); pkt_tx_cycles += (t4-t3); diff --git a/ti/runtime/netapi/test/net_test_setup.sh b/ti/runtime/netapi/test/net_test_setup.sh deleted file mode 100644 index 0295498..0000000 --- a/ti/runtime/netapi/test/net_test_setup.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -export KERNEL_VER=$(uname -r) -#install kernel module -echo $KERNEL_VER -insmod /lib/modules/$KERNEL_VER/extra/hplibmod.ko -# -cat /proc/netapi -# -devmem2 0x2090804 w 0x4 -# -# run net_test applicaton, default location of config file is in /etc/netapi, -# default config file name is net_test_config.txt -/usr/bin/net_test_loopback /etc/netapi/net_test_config.txt -- 2.39.2