From 0c9330e967a2926a2424155c941904e7d4d5815f Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 21 Aug 1998 13:22:35 +0000 Subject: KA9Q -> FreeBSD changes from Eric Norum --- ttcp/Makefile | 25 +++---- ttcp/README | 15 ---- ttcp/init.c | 205 +++++------------------------------------------------- ttcp/rtems_ttcp.c | 82 +++++----------------- 4 files changed, 46 insertions(+), 281 deletions(-) (limited to 'ttcp') diff --git a/ttcp/Makefile b/ttcp/Makefile index 5b46a4b..39f2d68 100644 --- a/ttcp/Makefile +++ b/ttcp/Makefile @@ -1,18 +1,14 @@ -# -# $Revision$ $Date$ $Author$ -# - SAMPLE=ttcp PGM=${ARCH}/$(SAMPLE).exe -MANAGERS=io event message rate_monotonic semaphore timer +MANAGERS=io event semaphore # C source names, if any, go here -- minus the .c -C_PIECES= init rtems_ttcp +C_PIECES= init rtems_ttcp C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) -H_FILES= +H_FILES= DOCTYPES= DOCS=$(DOCTYPES:%=$(SAMPLE).%) @@ -34,9 +30,10 @@ include $(PROJECT_ROOT)/make/leaf.cfg DEFINES += CPPFLAGS += -CFLAGS += -I./include -CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0x200000 # KA9Q needs more space +CFLAGS += +CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000 CFLAGS_OPTIMIZE_V += +CFLAGS_DEBUG_V += -v -qrtems_debug LD_PATHS += LD_LIBS += @@ -48,7 +45,7 @@ LD_LIBS += # 'make clobber' already includes 'make clean' # -CLEAN_ADDITIONS += +CLEAN_ADDITIONS += CLOBBER_ADDITIONS += all: ${ARCH} $(SRCS) $(PGM) @@ -56,7 +53,7 @@ all: ${ARCH} $(SRCS) $(PGM) ${PGM}: $(OBJS) $(LINK_FILES) $(make-exe) -install: $(INSTALL_TARGET) - -$(INSTALL_TARGET): all - cp ${PGM} $(INSTALL_TARGET) +# Install the program(s), appending _g or _p as appropriate. +# for include files, just use $(INSTALL) +install: all + $(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests diff --git a/ttcp/README b/ttcp/README index 8eb9ed3..5f209ab 100644 --- a/ttcp/README +++ b/ttcp/README @@ -1,22 +1,7 @@ -# -# $Id$ -# - This directory contains an RTEMS application for measuring TCP/UDP network throughput. The ttcp_orig subdirectory contains the original UNIX program which can be compiled and run on your host machine. -The RTEMS version of the test program is a little clumsy to use. You -have to edit the rtems_ttcp.c source file and change the ttcp_argv -array of strings to set the arguments you want passed to the ttcp -task. - -It does work, though. The best throughputs I've seen so far are: - 68360 card can transmit a TCP stream at 198 kbytes/second. - 68360 card can receive a TCP stream at 119 kbytes/second. -In both cases, the other end of the transfer was a 486DX2/66 running -OPENSTEP/MACH 4.1. - One noteworthy item is that I was able to get the UNIX test program running under RTEMS with no changes to the test program itself. The entire UNIX source file is included, without changes, into the RTEMS diff --git a/ttcp/init.c b/ttcp/init.c index 4df07c9..68cbff7 100644 --- a/ttcp/init.c +++ b/ttcp/init.c @@ -3,8 +3,8 @@ * * This program may be distributed and used for any purpose. * I ask only that you: - * 1. Leave this author information intact. - * 2. Document any changes you make. + * 1. Leave this author information intact. + * 2. Document any changes you make. * * W. Eric Norum * Saskatchewan Accelerator Laboratory @@ -13,20 +13,24 @@ * eric@skatter.usask.ca */ -#include "../usercfg.h" - #include #define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER #define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER #define CONFIGURE_RTEMS_INIT_TASKS_TABLE -#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024) -#define CONFIGURE_MAXIMUM_SEMAPHORES 20 -#define CONFIGURE_MAXIMUM_TASKS 20 -#define CONFIGURE_MAXIMUM_TIMERS 10 -#define CONFIGURE_MAXIMUM_PERIODS 1 -#define CONFIGURE_MICROSECONDS_PER_TICK 10486 +#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024) +#define CONFIGURE_MAXIMUM_SEMAPHORES 20 +#define CONFIGURE_MAXIMUM_TASKS 20 + +#define CONFIGURE_MICROSECONDS_PER_TICK 10486 + +#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024) +#define CONFIGURE_INIT_TASK_PRIORITY 100 +#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \ + RTEMS_NO_TIMESLICE | \ + RTEMS_NO_ASR | \ + RTEMS_INTERRUPT_LEVEL(0)) #define CONFIGURE_INIT rtems_task Init (rtems_task_argument argument); @@ -34,49 +38,8 @@ rtems_task Init (rtems_task_argument argument); #include #include -#include - -#if (defined (USE_BOOTP)) -#include -#endif - -volatile int ttcp_running; - -/* - * Suspend execution for the specified number of seconds - */ -static void -delay_task (int seconds) -{ - rtems_task_wake_after ((seconds * 1000000) / BSP_Configuration.microseconds_per_tick); -} - -/* - * Display the contents of several KA9Q tables - */ -void -show_ka9q_tables (void) -{ - printf ("\n****************** MALLOC Statistics ***************\n"); - malloc_dump (); - printf ("\n****************** MBUF Statistics ***************\n"); - mbufstat (); - mbufsizes (); - printf ("\n****************** Routing Table ***************\n"); - rtems_ka9q_execute_command ("route"); - printf ("\n****************** ARP Table ***************\n"); - rtems_ka9q_execute_command ("arp"); - printf ("\n****************** Driver Statistics ***************\n"); - rtems_ka9q_execute_command ("ifconfig rtems"); - printf ("\n****************** Ip Statistics ***************\n"); - rtems_ka9q_execute_command ("ip status"); - printf ("\n****************** ICMP Statistics ***************\n"); - rtems_ka9q_execute_command ("icmp status"); - printf ("\n****************** UDP Statistics ***************\n"); - rtems_ka9q_execute_command ("udp status"); - printf ("\n****************** TCP Statistics ***************\n"); - rtems_ka9q_execute_command ("tcp status"); -} +#include +#include "../networkconfig.h" /* * RTEMS Startup Task @@ -84,141 +47,7 @@ show_ka9q_tables (void) rtems_task Init (rtems_task_argument ignored) { - rtems_task_priority oldPri; - rtems_mode old_mode; - -#if (defined (m68040)) - /* - * Hook up FPSP - */ - M68kFPSPInstallExceptionHandlers (); - - /* - * Turn on instruction cache - */ - asm volatile ("cinva bc"); - asm volatile ("movec %0,itt0" : : "d" (0x00ffc004)); - asm volatile ("movec %0,dtt0" : : "d" (0x00ffc040)); - asm volatile ("cinva bc\n\t" - "movec %0,cacr" : : "d" (0x80008000)); -#endif - - ttcp_running = 0; - - /* - * Start KA9Q - */ - rtems_task_set_priority (RTEMS_SELF, 30, &oldPri); - rtems_ka9q_start (30); - - /* - * Hook up drivers - */ - if (rtems_ka9q_execute_command ("attach rtems" - /* " rbuf 24 tbuf 5" */ - " rbuf 100 tbuf 10" -#if !(defined (USE_BOOTP)) - " ip " MY_IP_ADDRESS -#endif - " ether " MY_ETHERNET_ADDRESS)) - rtems_panic ("Can't attach Ethernet driver.\n"); - -#if (defined (TRACE_NETWORK_DRIVER)) - /* - * Turn on debugging - */ - puts( "Enabling debug mode of KA9Q" ); - if (rtems_ka9q_execute_command ("trace rtems input ") - || rtems_ka9q_execute_command ("trace rtems output ") - || rtems_ka9q_execute_command ("trace rtems ascii ")) - rtems_panic ("Can't set tracing for Ethernet driver.\n"); -#endif - - - /* - * Configure the driver - */ - if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255")) - rtems_panic ("Can't configure Ethernet driver.\n"); - - /* - * Add the ethernet broadcast address to the ARP table. - */ - if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF")) - rtems_panic ("Can't add broadcast entry to ARP table.\n"); - -#if (defined (USE_BOOTP)) - { - int i; - /* - * Get BOOTP information - */ - for (i = 0 ; ; ) { - if (rtems_ka9q_execute_command ("bootp") == 0) - break; - if (++i == 10) - rtems_panic ("Can't get information from BOOTP server.\n"); - delay_task (i); - } - if (BootpFileName) - printf ("BOOTP filename: `%s'\n", BootpFileName); - else - printf ("BOOTP -- No filename!\n"); - } -#else - if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0")) - rtems_panic ("Can't set netmask.\n"); - if (rtems_ka9q_execute_command ("route add default rtems")) - rtems_panic ("Can't add default route.\n"); - printf ("Routing table after adding default route\n"); - rtems_ka9q_execute_command ("route"); -#endif - /* - * Issue a gratuitous ARP request to update tables in - * other hosts on this network. - */ - if (rtems_ka9q_execute_command ("arp gratuitous rtems")) - rtems_panic ("Can't send gratuitous ARP.\n"); - - rtems_ka9q_execute_command ("tcp window"); - rtems_ka9q_execute_command ("tcp window 4096"); - rtems_ka9q_execute_command ("tcp window"); - - /* - * Whew! - */ - printf ("NETWORK INITIALIZED!\n"); - - /* - * Let other tasks preempt this one - */ - rtems_task_mode (RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode); - - /* - * See if sockets work properly - */ + rtems_bsdnet_initialize_network (); test_network (); - - /* - * Wait for characters from console terminal - */ - do { - rtems_task_wake_after( 1 ); - } while ( !ttcp_running ); - printf( "Now accepting input from the console\n" ); - for (;;) { - switch (getchar ()) { - case '\004': - printf( "Exiting test\n" ); - return; - - case 's': - /* - * Show what's been accomplished - */ - show_ka9q_tables (); - break; - } - } exit (0); } diff --git a/ttcp/rtems_ttcp.c b/ttcp/rtems_ttcp.c index 356e5b3..cb97b99 100644 --- a/ttcp/rtems_ttcp.c +++ b/ttcp/rtems_ttcp.c @@ -2,7 +2,7 @@ * A collection of hacks, glue, and patches to * provide a `UNIX-like' environment to ttcp. * - * Some of the code here should migrate to the libc + * Some of the code here may migrate to the libc * support routines some day. Some of the more sleazy * hacks should never make it outside this file! * @@ -19,12 +19,14 @@ */ #include +#include #include -#include +#include #include -#include -#include -#include +#include +#include +#include +#include #include /* @@ -32,26 +34,6 @@ */ int rtems_ttcp_main (int argc, char **argv); -#define ENOBUFS 2000 - -struct hostent { - char *h_name; /* official name of host */ - char **h_aliases; /* alias list */ - int h_addrtype; /* host address type */ - int h_length; /* length of address */ - char **h_addr_list; /* list of addresses from name server */ - #define h_addr h_addr_list[0] /* address, for backward compatiblity */ -}; - -#define SOL_SOCKET 0 -#define SO_DEBUG 0 - -static struct hostent * -gethostbyname (const char *cp) -{ - rtems_panic ("gethostbyname()"); -} - static int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { @@ -64,14 +46,6 @@ static void return 0;; } -static char * -rtems_inet_ntoa (struct in_addr in) -{ - return inet_ntoa (in.s_addr); -} -#define inet_ntoa rtems_inet_ntoa -#define inet_addr(cp) resolve(cp) - int gettimeofday (struct timeval *tp, struct timezone *tzp) { @@ -119,21 +93,16 @@ getrusage(int ignored, struct rusage *ru) return 0; } -void show_ka9q_tables (void); - static void rtems_ttcp_exit (int code) { - rtems_interval ticksPerSecond; - - rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond); - rtems_task_wake_after (ticksPerSecond * 2); - show_ka9q_tables (); + rtems_bsdnet_show_mbuf_stats (); + rtems_bsdnet_show_if_stats (); + rtems_bsdnet_show_ip_stats (); + rtems_bsdnet_show_tcp_stats (); exit (code); } -extern volatile int ttcp_running; - /* * Task to run UNIX ttcp command */ @@ -157,12 +126,18 @@ ttcpTask (rtems_task_argument arg) strcpy (arg0, "ttcp"); argv[0] = __progname = arg0; +#if (defined (WRITE_TEST_ONLY)) + strcpy (linebuf, "-s -t crux"); +#elif (defined (READ_TEST_ONLY)) + strcpy (linebuf, "-s -r"); +#else /* * Read a line */ printf (">>> %s ", argv[0]); fflush (stdout); fgets (linebuf, sizeof linebuf, stdin); +#endif /* * Break line into arguments @@ -195,23 +170,10 @@ ttcpTask (rtems_task_argument arg) printf ("or\n"); printf (" -t destination.internet.address\n"); } - ttcp_running = 1; code = rtems_ttcp_main (argc, argv); rtems_ttcp_exit (code); } -static int -rtems_ttcp_bind (int s, struct sockaddr *name, int namelen) -{ - struct sockaddr_in *in = (struct sockaddr_in *)name; - /* - * KA9Q doesn't like 0 port numbers - */ - if (in->sin_port == 0) - in->sin_port = 2662; - return bind (s, name, namelen); -} - /* * Test network throughput */ @@ -258,19 +220,11 @@ test_network (void) printf ("Can't start task; %s\n", rtems_status_text (sc)); return; } - /* rtems_task_suspend (RTEMS_SELF); */ + rtems_task_suspend (RTEMS_SELF); } #define main rtems_ttcp_main #define exit(code) close(fd),rtems_ttcp_exit(code) -#define bind rtems_ttcp_bind #define read_timer rtems_read_timer -/* - * RTEMS/KA9Q code expects port numbers in host byte order! - */ -#define htons(x) (x) - -#undef delay - #include "ttcp_orig/ttcp.c" -- cgit v1.2.3