# HG changeset patch # User gthomas # Date 1061313781 0 # Node ID 83f799d5b41a404a10a5a042d852dc35df79c67e # Parent a8252a1c38eaad9b6258f9228cf44b361e8a56b0 Improve stand-alone networking speeds. diff --git a/packages/io/eth/current/ChangeLog b/packages/io/eth/current/ChangeLog --- a/packages/io/eth/current/ChangeLog +++ b/packages/io/eth/current/ChangeLog @@ -1,3 +1,9 @@ +2003-08-19 Gary Thomas + + * src/stand_alone/eth_drv.c: + * src/net/eth_drv.c: Improve network speeds by reducing some + overhead and also the delay when sending a packet. + 2003-07-23 Nick Garnett * include/eth_drv.h: diff --git a/packages/io/eth/current/src/net/eth_drv.c b/packages/io/eth/current/src/net/eth_drv.c --- a/packages/io/eth/current/src/net/eth_drv.c +++ b/packages/io/eth/current/src/net/eth_drv.c @@ -9,7 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. -// Copyright (C) 2002 Gary Thomas +// Copyright (C) 2002, 2003 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -647,6 +647,11 @@ eth_drv_send(struct ifnet *ifp) return; } + // If nothing on the queue, no need to bother hardware + if (IF_IS_EMPTY(&ifp->if_snd)) { + return; + } + while ((sc->funs->can_send)(sc) > 0) { IF_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) { @@ -1027,7 +1032,9 @@ void eth_drv_tickle_devices( void ) // this function from tx_done() which normally provide // continuous transmissions; otherwise we do not get control. // This call fixes that. - eth_drv_send(ifp); + if (!IF_IS_EMPTY(&ifp->if_snd)) { + eth_drv_send(ifp); + } } } } diff --git a/packages/io/eth/current/src/stand_alone/eth_drv.c b/packages/io/eth/current/src/stand_alone/eth_drv.c --- a/packages/io/eth/current/src/stand_alone/eth_drv.c +++ b/packages/io/eth/current/src/stand_alone/eth_drv.c @@ -9,6 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. +// Copyright (C) 2003 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -311,14 +312,14 @@ eth_drv_write(char *eth_hdr, char *buf, (sc->funs->send)(sc, sg_list, sg_len, len+14, (CYG_ADDRWORD)&packet_sent); - wait_time = 500; + wait_time = 50000; while (1) { (sc->funs->poll)(sc); if(packet_sent) break; - CYGACC_CALL_IF_DELAY_US(2*1000); + CYGACC_CALL_IF_DELAY_US(2*10); if (--wait_time <= 0) goto reset_and_out; // Give up on sending packet } diff --git a/packages/redboot/current/ChangeLog b/packages/redboot/current/ChangeLog --- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,12 @@ +2003-08-19 Gary Thomas + + * src/net/udp.c (__udp_recvfrom): Rework loop so delay only happens + if no packet is immediately available - improves network throughput. + + * src/ticks.c: + * cdl/redboot.cdl: Add control over granularity of timers used + by RedBoot and the network stack. + 2003-08-05 Jonathan Larmour * doc/redboot_installing.sgml: Fix brain fart in last change to diff --git a/packages/redboot/current/cdl/redboot.cdl b/packages/redboot/current/cdl/redboot.cdl --- a/packages/redboot/current/cdl/redboot.cdl +++ b/packages/redboot/current/cdl/redboot.cdl @@ -212,6 +212,19 @@ cdl_package CYGPKG_REDBOOT { stripping before being converted to a binary image. This is handled by a rule in the target CDL." + + cdl_option CYGDBG_REDBOOT_TICK_GRANULARITY { + display "Granularity of timer/ticks" + flavor data + legal_values { 50 100 250 500 1000 } + default_value 250 + description " + This option controls the granularity of the timers. + Faster CPUs can afford higher granularity (lower values) + which should give higher network performance since the stack + is purely polled." + } + compile main.c compile misc_funs.c io.c parse.c ticks.c syscall.c alias.c compile -library=libextras.a load.c diff --git a/packages/redboot/current/src/flash.c b/packages/redboot/current/src/flash.c --- a/packages/redboot/current/src/flash.c +++ b/packages/redboot/current/src/flash.c @@ -1519,7 +1519,7 @@ get_config(unsigned char *dp, char *titl int index; const char *name; diag_printf("Sorry, Port name must be one of:\n"); - for (index = 0; name = net_devname(index); index++) + for (index = 0; (name = net_devname(index)) != NULL; index++) diag_printf(" %s\n", name); return CONFIG_BAD; } diff --git a/packages/redboot/current/src/net/udp.c b/packages/redboot/current/src/net/udp.c --- a/packages/redboot/current/src/net/udp.c +++ b/packages/redboot/current/src/net/udp.c @@ -9,7 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. -// Copyright (C) 2002 Gary Thomas +// Copyright (C) 2002, 2003 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -255,14 +255,14 @@ int total_ms = (timo->tv_sec * 1000) + (timo->tv_usec / 1000); start = MS_TICKS(); res = -1; - while ((MS_TICKS_DELAY() - start) < total_ms) { + do { __enet_poll(); // Handle the hardware if (!recvfrom_buf) { // Data have arrived res = recvfrom_len; break; } - } + } while ((MS_TICKS_DELAY() - start) < total_ms); __udp_remove_listener(my_port); return res; } diff --git a/packages/redboot/current/src/ticks.c b/packages/redboot/current/src/ticks.c --- a/packages/redboot/current/src/ticks.c +++ b/packages/redboot/current/src/ticks.c @@ -9,6 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 2003 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -55,12 +56,18 @@ #include "redboot.h" static unsigned long ticks = 0; +static long elapsed = 0; unsigned long do_ms_tick(void) { - CYGACC_CALL_IF_DELAY_US(1000); // Wait for 1ms - return ++ticks; + CYGACC_CALL_IF_DELAY_US(CYGDBG_REDBOOT_TICK_GRANULARITY); + elapsed += CYGDBG_REDBOOT_TICK_GRANULARITY; + if (elapsed >= 1000) { + elapsed = 0; + ticks++; + } + return ticks; } unsigned long