diff options
author | Heiko Schocher <hs@denx.de> | 2009-02-10 09:38:52 +0100 |
---|---|---|
committer | Ben Warren <biggerbadderben@gmail.com> | 2009-02-22 23:49:33 -0800 |
commit | 2f70c49e5b9813635ad73666aa30f304c7fdeda9 (patch) | |
tree | 57b6d6625de2648dab93e71cf74a7329c81c6adc /net/net.c | |
parent | ad2d16393e9f684e4a9255f42e8bfdd819b67a87 (diff) | |
download | u-boot-imx-2f70c49e5b9813635ad73666aa30f304c7fdeda9.zip u-boot-imx-2f70c49e5b9813635ad73666aa30f304c7fdeda9.tar.gz u-boot-imx-2f70c49e5b9813635ad73666aa30f304c7fdeda9.tar.bz2 |
netloop: speed up NetLoop
NetLoop polls every cycle with getenv some environment variables.
This is horribly slow, especially when the environment is big.
This patch reads only the environment variables in NetLoop,
when they were changed.
Also moved the init part of the NetLoop function in a seperate
function.
Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Diffstat (limited to 'net/net.c')
-rw-r--r-- | net/net.c | 134 |
1 files changed, 75 insertions, 59 deletions
@@ -209,6 +209,8 @@ uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN]; ulong NetArpWaitTimerStart; int NetArpWaitTry; +int env_changed_id = 0; + void ArpRequest (void) { int i; @@ -276,6 +278,78 @@ void ArpTimeoutCheck(void) } } +int +NetInitLoop(proto_t protocol) +{ + bd_t *bd = gd->bd; + int env_id = get_env_id (); + + /* update only when the environment has changed */ + if (env_changed_id == env_id) + return 0; + + switch (protocol) { +#if defined(CONFIG_CMD_NFS) + case NFS: +#endif +#if defined(CONFIG_CMD_PING) + case PING: +#endif +#if defined(CONFIG_CMD_SNTP) + case SNTP: +#endif + case NETCONS: + case TFTP: + NetCopyIP(&NetOurIP, &bd->bi_ip_addr); + NetOurGatewayIP = getenv_IPaddr ("gatewayip"); + NetOurSubnetMask= getenv_IPaddr ("netmask"); + NetOurVLAN = getenv_VLAN("vlan"); + NetOurNativeVLAN = getenv_VLAN("nvlan"); + + switch (protocol) { +#if defined(CONFIG_CMD_NFS) + case NFS: +#endif + case NETCONS: + case TFTP: + NetServerIP = getenv_IPaddr ("serverip"); + break; +#if defined(CONFIG_CMD_PING) + case PING: + /* nothing */ + break; +#endif +#if defined(CONFIG_CMD_SNTP) + case SNTP: + /* nothing */ + break; +#endif + default: + break; + } + + break; + case BOOTP: + case RARP: + /* + * initialize our IP addr to 0 in order to accept ANY + * IP addr assigned to us by the BOOTP / RARP server + */ + NetOurIP = 0; + NetServerIP = getenv_IPaddr ("serverip"); + NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */ + NetOurNativeVLAN = getenv_VLAN("nvlan"); + case CDP: + NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */ + NetOurNativeVLAN = getenv_VLAN("nvlan"); + break; + default: + break; + } + env_changed_id = env_id; + return 0; +} + /**********************************************************************/ /* * Main network processing loop. @@ -340,65 +414,7 @@ restart: * here on, this code is a state machine driven by received * packets and timer events. */ - - switch (protocol) { -#if defined(CONFIG_CMD_NFS) - case NFS: -#endif -#if defined(CONFIG_CMD_PING) - case PING: -#endif -#if defined(CONFIG_CMD_SNTP) - case SNTP: -#endif - case NETCONS: - case TFTP: - NetCopyIP(&NetOurIP, &bd->bi_ip_addr); - NetOurGatewayIP = getenv_IPaddr ("gatewayip"); - NetOurSubnetMask= getenv_IPaddr ("netmask"); - NetOurVLAN = getenv_VLAN("vlan"); - NetOurNativeVLAN = getenv_VLAN("nvlan"); - - switch (protocol) { -#if defined(CONFIG_CMD_NFS) - case NFS: -#endif - case NETCONS: - case TFTP: - NetServerIP = getenv_IPaddr ("serverip"); - break; -#if defined(CONFIG_CMD_PING) - case PING: - /* nothing */ - break; -#endif -#if defined(CONFIG_CMD_SNTP) - case SNTP: - /* nothing */ - break; -#endif - default: - break; - } - - break; - case BOOTP: - case RARP: - /* - * initialize our IP addr to 0 in order to accept ANY - * IP addr assigned to us by the BOOTP / RARP server - */ - NetOurIP = 0; - NetServerIP = getenv_IPaddr ("serverip"); - NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */ - NetOurNativeVLAN = getenv_VLAN("nvlan"); - case CDP: - NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */ - NetOurNativeVLAN = getenv_VLAN("nvlan"); - break; - default: - break; - } + NetInitLoop(protocol); switch (net_check_prereq (protocol)) { case 1: |