fix for net_test_setup.sh script for hplibmod.ko path, adding some net_test tools
authorTinku Mannan <tmannan@ti.com>
Fri, 26 Apr 2013 20:17:21 +0000 (16:17 -0400)
committerTinku Mannan <tmannan@ti.com>
Fri, 26 Apr 2013 20:17:21 +0000 (16:17 -0400)
ti/runtime/netapi/test/build/Makefile
ti/runtime/netapi/test/net_test_looback.c [moved from ti/runtime/netapi/test/net_test.c with 100% similarity]
ti/runtime/netapi/test/net_test_setup.sh
ti/runtime/netapi/tools/pcsetupfornetapi.sh [new file with mode: 0755]
ti/runtime/netapi/tools/setkey_hmac-sha1_aes-cbc.conf [new file with mode: 0644]
ti/runtime/netapi/tools/udpif [new file with mode: 0755]
ti/runtime/netapi/tools/udpif.c [new file with mode: 0644]

index 65cbaacd68e6db8ff7ca8589589fc56642f578bb..387db01cf9e7869be994f3d6245a3e633ed69720 100755 (executable)
@@ -18,16 +18,12 @@ NWAL_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/nwal
 PKTLIB_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/runtime/pktlib
 
 
-#NETAPI_INC_DIR = $(NETAPI_INSTALL_PATH)/ti/runtime/netapi
-#HPLIB_INC_DIR = $()/ti/runtime/hplib
 
 #NETAPI LIB Build directory
 NETAPI_BUILD_DIR = $(NETAPI_INC_DIR)/ti/runtime/netapi/build
-#NETAPI_BUILD_DIR = $(NETAPI_INC_DIR)/build
 
 
 # Set NETAPI INSTALL PATH to Transport SDK for default
-#export NETAPI_INSTALL_PATH ?= $(TRANS_SDK_INSTALL_PATH)
 
 CSL_DEVICE ?= -DDEVICE_K2H
 
@@ -36,13 +32,12 @@ ifeq ($(CPU),  cortex-a8)
 endif
 
 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_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
+NT_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_loopback.o  $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.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_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
 #
 NT_MAX_PARAMS_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_max_params.o  $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
 #
-#IFDMA_OBJS= $(ARMV7OBJDIR)/netapi/test/ifdma_test.o  $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
 
 IFDMA_OBJS= $(ARMV7OBJDIR)/netapi/test/ifdma_test.o
 
@@ -62,10 +57,6 @@ SA_LIB = -lsa
 #
 #with security enabled..
 NWAL_LIB = -lnwalsa
-#SA_LIB=$(SA_INSTALL_PATH)/ti/drv/sa/lib/salld_c.av7A
-#AES_LIB=$(SA_INSTALL_PATH)/ti/mas/aes/gcarmv7a/aes_c.av7A
-#SHA1_LIB=$(SA_INSTALL_PATH)/ti/mas/sha1/gcarmv7a/sha1_c.av7A
-#PKTUTL_LIB=$(SA_INSTALL_PATH)/ti/mas/pktutl/gcarmv7a/pktutl_c.av7A
 
 ifdef CROSS_TOOL_INSTALL_PATH
 ## Support backwards compatibility with KeyStone1 approach
@@ -86,7 +77,7 @@ INTERNALLINKDEFS = -Wl,--start-group $(NETAPI_LIB) $(PKTLIB_LIB) $(HP_LIB) $(QMS
 
 all: tests 
 
-tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test $(ARMV7BINDIR)/netapi/test/net_test_router $(ARMV7BINDIR)/netapi/test/net_test_max_params $(ARMV7BINDIR)/netapi/test/ifdma_test
+tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test_loopback $(ARMV7BINDIR)/netapi/test/net_test_router $(ARMV7BINDIR)/netapi/test/net_test_max_params $(ARMV7BINDIR)/netapi/test/ifdma_test
 
 
 api_clean:
@@ -96,7 +87,7 @@ api_clean:
 clean: 
        rm -f $(ARMV7OBJDIR)/netapi/test/*.o
        rm -f $(ARMV7LIBDIR)/libnetapi.a
-       rm -f $(ARMV7BINDIR)/netapi/test/net_test 
+       rm -f $(ARMV7BINDIR)/netapi/test/net_test_loopback
        rm -f $(ARMV7BINDIR)/netapi/test/net_test_router 
        rm -f $(ARMV7BINDIR)/netapi/test/net_test_max_params
        rm -f $(ARMV7BINDIR)/netapi/test/ifdma_test
@@ -116,8 +107,8 @@ $(ARMV7BINDIR)/netapi/test/.created:
 
 
 
-$(ARMV7BINDIR)/netapi/test/net_test:  $(NT_OBJS) $(TRIE_OBJS)
-       $(CC) $(LDFLAGS)  $(NT_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS)  -o $(ARMV7BINDIR)/netapi/test/net_test
+$(ARMV7BINDIR)/netapi/test/net_test_loopback:  $(NT_OBJS) $(TRIE_OBJS)
+       $(CC) $(LDFLAGS)  $(NT_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS)  -o $(ARMV7BINDIR)/netapi/test/net_test_loopback
 
 $(ARMV7BINDIR)/netapi/test/net_test_max_params:  $(NT_MAX_PARAMS_OBJS) $(TRIE_OBJS) $(ARMV7LIBDIR)/libnetapi.a
        $(CC) $(LDFLAGS)  $(NT_MAX_PARAMS_OBJS) $(TRIE_OBJS) $(INTERNALLINKDEFS)  -o $(ARMV7BINDIR)/netapi/test/net_test_max_params
index 7d680062af9bbd0ae0cf1e1549de7f5e689f965b..0295498582fcb192b2b67b7408d8262ed6115279 100644 (file)
@@ -1,13 +1,14 @@
 #!/bin/sh
 
+export KERNEL_VER=$(uname -r)
 #install kernel module
-insmod /lib/modules/3.8.4-rt2/extra/hplibmod.ko
+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, 
+# 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 /etc/netapi/net_test_config.txt
-#
+/usr/bin/net_test_loopback /etc/netapi/net_test_config.txt
diff --git a/ti/runtime/netapi/tools/pcsetupfornetapi.sh b/ti/runtime/netapi/tools/pcsetupfornetapi.sh
new file mode 100755 (executable)
index 0000000..3c5657f
--- /dev/null
@@ -0,0 +1,7 @@
+#add local ips
+ifconfig eth0:1 10.0.0.10
+ifconfig eth0:2 192.168.1.10
+
+#install netapi evm ip addresses into arp cache
+arp -v -n -s  10.0.0.100 00:01:02:03:05:05
+arp -v -n -s 192.168.1.100 00:01:02:03:05:05
diff --git a/ti/runtime/netapi/tools/setkey_hmac-sha1_aes-cbc.conf b/ti/runtime/netapi/tools/setkey_hmac-sha1_aes-cbc.conf
new file mode 100644 (file)
index 0000000..d65b144
--- /dev/null
@@ -0,0 +1,15 @@
+#!/mnt/host/netbench/setkey -f
+#pc->shannon
+flush;
+spdflush;
+add -4 192.168.1.10 192.168.1.100 esp 0x11111111 -m tunnel -E rijndael-cbc 0x55112233445566778899aabbccddeeff00112233445566778899aabbccddeeff -A hmac-sha1 0x000102030405060708090a0b0c0d0e0f10111213;
+
+spdadd 192.168.1.10 192.168.1.100 any -P out ipsec
+       esp/tunnel/192.168.1.10-192.168.1.100/require;
+
+
+add -4 192.168.1.100 192.168.1.10 esp 0x11111111 -m tunnel -E rijndael-cbc 0x55112233445566778899aabbccddeeff00112233445566778899aabbccddeeff -A hmac-sha1 0x000102030405060708090a0b0c0d0e0f10111213;
+                                                                                
+spdadd 192.168.1.100 192.168.1.10 any  -P in ipsec
+        esp/tunnel/192.168.1.100-192.168.1.10/require;
+
diff --git a/ti/runtime/netapi/tools/udpif b/ti/runtime/netapi/tools/udpif
new file mode 100755 (executable)
index 0000000..9e19b11
Binary files /dev/null and b/ti/runtime/netapi/tools/udpif differ
diff --git a/ti/runtime/netapi/tools/udpif.c b/ti/runtime/netapi/tools/udpif.c
new file mode 100644 (file)
index 0000000..e150062
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+ *
+ * udpIf.c - provides udp 
+ *
+ */
+//#define BENCHMARK
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/time.h>
+
+int nSent=0;
+
+#ifdef BENCHMARK
+struct timeval stime,mtime,etime;
+#endif
+
+#define SENDSZ 1396
+int SendSize=SENDSZ;
+
+#define MAIN_NEEDED
+#ifdef MAIN_NEEDED
+/******************************************************************************
+    main
+*******************************************************************************/
+/* argv[1] = S for Send, R for Receive
+   argv[2] = fileName
+   argv[3] = port
+   argv[4] = ipAddress
+   argv[5] = send size
+*/
+main(argc,argv)
+int argc;
+char **argv;
+{
+int  sending = 0;
+char fileName[256];
+int  port;
+char ipAddress[64];
+    if (argc < 4) 
+        {
+        printf ("usage:udpIf S|R fileName port [ipAddress] [send size]\n");
+        exit(-1);
+        }
+    sending = (*argv[1] == 'S') ? 1 : 0;
+    strcpy(fileName,argv[2]);
+    port = atoi(argv[3]);
+    if (argc >= 5)
+        strcpy(ipAddress,argv[4]);
+    else
+        strcpy(ipAddress,"");
+    if (argc ==6) SendSize=atoi(argv[5]);
+    if (SendSize > SENDSZ) SendSize=SENDSZ;
+    udpif(sending,fileName,port,ipAddress);
+}
+#endif
+char startstring[]="start";
+char endstring[]="done";
+/******************************************************************************
+    udpif
+*******************************************************************************/
+udpif(sending,fileName,port,ipAddress)
+int  sending;
+char *fileName;
+int  port;
+char *ipAddress;
+{
+struct sockaddr_in addr,fraddr;
+int    addrlen, fd, cnt;
+socklen_t fraddrlen;
+char message[SENDSZ+3];
+int  numTries = 0;
+#define MAX_TRIES 5
+int rc;
+int sstate=0;
+int total, rtotal;
+total=rtotal=0; 
+    if (sending)
+        {    
+        int inFile;
+        inFile = open(fileName,O_RDONLY);
+        if (inFile < 0)
+            {
+            printf ("Can't read %s in tcpIf\n",fileName);
+            exit(-1);
+            }
+        fd = socket(AF_INET, SOCK_DGRAM, 0);
+        printf ("socket is %d\n",fd);
+        if (fd < 0) 
+            {
+            perror("socket");
+            exit(1);
+            }
+        bzero(&addr, sizeof(addr));
+        addr.sin_family = AF_INET;
+        addr.sin_addr.s_addr = INADDR_ANY;
+        addr.sin_port = 40000;
+        addrlen = sizeof(addr);
+        rc = bind(fd, &addr, sizeof(addr));
+        printf ("Sender:bind rc is %d\n",rc);
+        if (rc < 0) 
+            {
+            perror("bind");
+            exit(1);
+            }
+        addr.sin_addr.s_addr = inet_addr(ipAddress);
+        addr.sin_port = htons(port);
+        printf("dbg: %x %x\n", addr.sin_addr.s_addr, addr.sin_port);
+#ifdef BENCHMARK
+               sendto(fd,
+                     startstring,
+                     strlen(startstring)+1,
+                     0,&addr,sizeof(addr));
+#endif
+        while(1)
+            {
+            char *mPtr;
+            int len;
+            int count = read(inFile,message,/*4096*/ /*SENDSZ*/SendSize);
+#ifndef BENCHMARK
+            //printf ("Sender:in count is %d\n",count);
+#endif
+            if (count == 0) 
+                {
+                close(inFile);
+#ifdef BENCHMARK
+               sendto(fd,
+                     endstring,
+                     strlen(endstring)+1,
+                     0,&addr,sizeof(addr));
+                                     
+ sendto(fd,
+                     endstring,
+                     strlen(endstring)+1,
+                     0,&addr,sizeof(addr));
+ sendto(fd,
+                     endstring,
+                     strlen(endstring)+1,
+                     0,&addr,sizeof(addr));
+               printf("sending done %d\n",nSent);
+               sleep(1);
+#endif
+                printf("sending done %d\n",nSent);
+
+                break;
+                }
+            mPtr = message;
+            len = count==-1 ? 5: count;
+            do {
+                cnt = sendto(fd, 
+                     mPtr,
+                     len,
+                     0,&addr,sizeof(addr));
+#ifndef BENCHMARK
+               // printf ("Sender:sendto count is %d\n",cnt);
+#endif
+                if (cnt < 0) 
+                    {
+                    close(inFile);
+                    perror("sendto");
+                    exit(1);
+                    }
+                nSent+=1;
+                mPtr += cnt;
+                len -= cnt;
+                } while(len > 0);
+            }
+        } 
+    else 
+        { 
+        /* receive */
+        int outFile;
+        int newSocket;
+        int rc;
+        fd = socket(AF_INET, SOCK_DGRAM, 0);
+        printf ("socket is %d\n",fd);
+        if (fd < 0) 
+            {
+            perror("socket");
+            exit(1);
+            }
+        bzero(&addr, sizeof(addr));
+        addr.sin_family = AF_INET;
+        addr.sin_addr.s_addr = htonl(INADDR_ANY);
+        addr.sin_port = htons(port);
+        addrlen = sizeof(addr);
+        rc = bind(fd, &addr, sizeof(addr));
+        printf ("Receiver:bind is %d\n",rc);
+        if (rc < 0) 
+            {
+            perror("bind");
+            exit(1);
+            }
+        /*outFile = open(fileName,O_WRONLY | O_CREAT);
+        if (outFile < 0)
+            {
+            printf ("Can't write to %s in tcpIf\n",fileName);
+            exit(-1);
+            }*/
+       memset(&fraddr,0,sizeof(fraddr));
+       fraddr.sin_family= AF_INET;
+       fraddrlen = sizeof(fraddr); 
+#ifdef BENCHMARK
+        gettimeofday(&stime, 0                  );
+        printf("rcv start @ %d: %d\n",stime.tv_sec, stime.tv_usec);
+
+#endif
+       while(1)
+            {
+#ifdef BENCHMARK
+
+        gettimeofday(&mtime, 0                  );
+        if(rtotal >= 10000000) 
+        {
+        printf("rcv mtime @ %d: %d %d %d\n",mtime.tv_sec, mtime.tv_usec,total, rtotal);
+        rtotal=0;
+        }
+#endif
+            cnt = recvfrom(fd, 
+                       message, 
+                       sizeof(message), 
+                       0,
+                       NULL,
+                       &fraddrlen);
+            //printf ("Receiver:recv count = %d\n",cnt);
+            if (cnt == 0) 
+                {
+                /*close(outFile);*/
+                continue;
+                }
+            if (cnt < 0) 
+                {
+                /*close(outFile);*/
+                perror("recvfrom");
+                exit(1);
+                }
+           rtotal+=cnt;
+           total+=cnt;
+           message[cnt+1] = '\0';
+#ifndef BENCHMARK
+            printf("rcvd %s\n",message);
+#else
+            if (strcmp("done",message)==0)
+            {
+                time_t blah1;
+                suseconds_t blah2;
+                gettimeofday(&etime, 0                  );
+                blah1= (etime.tv_usec>stime.tv_usec) ?
+                               etime.tv_sec-stime.tv_sec :
+                               etime.tv_sec-stime.tv_sec-1;
+                blah2 = (etime.tv_usec>stime.tv_usec) ?
+                                     etime.tv_usec-stime.tv_usec :
+                                     1000000-stime.tv_usec+etime.tv_usec;
+                printf("DONE @ %d: %d {%d %d}\n",etime.tv_sec, etime.tv_usec,
+                                                 blah1, blah2 );
+                gettimeofday(&etime, 0                  );
+            }
+            if (strcmp("start",message)==0)
+            {
+                gettimeofday(&stime, 0                  );
+                printf("START @ %d: %d\n",stime.tv_sec, stime.tv_usec);
+            }
+
+#endif
+            }
+        }
+}