summaryrefslogtreecommitdiff
path: root/net/net.c
Commit message (Collapse)AuthorAgeLines
* net: BOOTP retry timeout improvementsStephen Warren2014-08-09-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the BOOTP code sends out its initial request as soon as the Ethernet driver indicates "link up". If this packet is lost or not replied to for some reason, the code waits for a 1s timeout before retrying. For some reason, such early packets are often lost on my system, so this causes an annoying delay. To optimize this, modify the BOOTP code to have very short timeouts for the first packet transmitted, but gradually increase the timeout each time a timeout occurs. This way, if the first packet is lost, the second packet is transmitted quite quickly and hence the overall delay is low. However, if there's still no response, we don't keep spewing out packets at an insane speed. It's arguably more correct to try and find out why the first packet is lost. However, it seems to disappear inside my Ethenet chip; the TX chip indicates no error during TX (not that it has much in the way of reporting...), yet wireshark on the RX side doesn't see any packet. FWIW, I'm using an ASIX USB Ethernet adapter. Perhaps "link up" is reported too early or based on the wrong condition in HW, and we should add some fixed extra delay into the driver. However, this would slow down every link up event even if it ends up not being needed in some cases. Having BOOTP retry quickly applies the fix/WAR to every possible Ethernet device, and is quite simple to implement, so seems a better solution. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* fix: CONFIG_NETCONSOLE start/handle this stuff only outside SPLHannes Petermaier2014-06-19-2/+2
| | | | | | | SPL stage does not support various networking things, and therefore CONFIG_NETCONSOLE cannot be built within SPL. Signed-off-by: Hannes Petermaier <oe5hpm@oevsv.at>
* NET: Add net_busy_flag if CONFIG_USB_KEYBOARD is definedJim Lin2013-08-26-0/+11
| | | | | | This flag is to make console aware that NET transfer is running or not. Signed-off-by: Jim Lin <jilin@nvidia.com>
* NET: Fix system hanging if NET device is not installedJim Lin2013-06-19-1/+2
| | | | | | | | | | | | | If we try to boot from NET device, NetInitLoop in net.c will be invoked. If NET device is not installed, eth_get_dev() function will return eth_current value, which is NULL. When NetInitLoop is called, "eth_get_dev->enetaddr" will access restricted memory area and therefore cause hanging. This issue is found on Tegra30 Cardhu platform after adding CONFIG_CMD_NET and CONFIG_CMD_DHCP in config header file. Signed-off-by: Jim Lin <jilin@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* net: Use new numeric setenv functionsSimon Glass2013-02-28-6/+2
| | | | | | Use setenv_ulong(), setenv_hex() and setenv_addr() in net/ Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Add a bootfile env handlerJoe Hershberger2012-12-13-0/+17
| | | | | | Remove the hard-coded bootfile handler and use a callback instead Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Use getenv_yesno() more generallyJoe Hershberger2012-12-13-17/+15
| | | | | | | Move the getenv_yesno() to env_common.c and change most checks for 'y' or 'n' to use this helper. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net/: sparse fixesKim Phillips2012-11-04-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | bootp.c:44:14: warning: symbol 'dhcp_state' was not declared. Should it be static? bootp.c:45:15: warning: symbol 'dhcp_leasetime' was not declared. Should it be static? bootp.c:46:10: warning: symbol 'NetDHCPServerIP' was not declared. Should it be static? arp.c:30:17: warning: symbol 'NetArpWaitReplyIP' was not declared. Should it be static? arp.c:37:16: warning: symbol 'NetArpTxPacket' was not declared. Should it be static? arp.c:38:17: warning: symbol 'NetArpPacketBuf' was not declared. Should it be static? atheros.c:33:19: warning: symbol 'AR8021_driver' was not declared. Should it be static? net.c:183:7: warning: symbol 'PktBuf' was not declared. Should it be static? net.c:159:21: warning: symbol 'net_state' was not declared. Should it be static? ping.c:73:6: warning: symbol 'ping_start' was not declared. Should it be static? ping.c:82:13: warning: symbol 'ping_receive' was not declared. Should it be static? tftp.c:53:7: warning: symbol 'TftpRRQTimeoutMSecs' was not declared. Should it be static? tftp.c:54:5: warning: symbol 'TftpRRQTimeoutCountMax' was not declared. Should it be static? eth.c:125:19: warning: symbol 'eth_current' was not declared. Should it be static? Note: in the ping.c fix, commit a36b12f95a29647a06b5459198684fc142482020 "net: Move PING out of net.c" mistakenly carried the ifdef CMD_PING clause from when it was necessary to avoid warnings when it was embedded in net.c. Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
* net: fix netconsole filteringJoe Hershberger2012-10-03-1/+1
| | | | | | | | | | Adjustment of Michael Walle's fix patch Commit 8a0eccb1056b313b45ab62e3aac400f339aa71b4 breaks netconsole. src_ip must not be converted to host byte order, because nc_ip is already stored in network byte order (see string_to_ip(), called by getenv_IPaddr()). Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Filter incoming netconsole packets by IPJoe Hershberger2012-09-24-0/+1
| | | | | | | Check the incoming packets' source IP address... if ncip isn't set to a broadcast address, only listen to the client at ncip. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Improve the speed of netconsoleJoe Hershberger2012-09-24-6/+20
| | | | | | | | | | | | | | | | | | | Previously u-boot would initialize the network interface for every network operation and then shut it down again. This makes sense for most operations where the network in not known to be needed soon after the operation is complete. In the case of netconsole, it will use the network for every interaction with the shell or every printf. This means that the network is being reinitialized very often. On many devices, this intialization is very slow. This patch checks for consecutive netconsole actions and leaves the ethernet hardware initialized between them. It will still behave the same old way for all other network operations and any time another network operation happens between netconsole operations. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Cc: Stefano Babic <sbabic@denx.de> Acked-by: Stefano Babic <sbabic@denx.de>
* net: bugfix: NetSetTimeout assumes CONFIG_SYS_HZ=1000Tetsuyuki Kobayashi2012-09-24-1/+1
| | | | | | NetSetTimeout sets incorrect value to timeDelta when CONFIG_SYS_HZ != 1000. Signed-off-by: Tetsuyuki Kobayashi <koba@kmckk.co.jp>
* net: Make sure the ethaddr is updated in net_init()Joe Hershberger2012-07-24-2/+1
| | | | | | | | | | | NetConsole may call NetSendUDPPacket before NetLoop is called. This will cause the source MAC address (NetOurEther) to be wrong. Instead of only changing it in NetLoop, move it to NetLoopInit so that it is also updated when net_init() is called (especially by nc_start()). Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reported-by: Michael Walle <michael@walle.cc> Acked-by: Michael Walle <michael@walle.cc>
* net: Allow filtering on debug traces in the net subsystemJoe Hershberger2012-05-23-11/+29
| | | | | | | | | | | | Add several levels of DEBUG prints so that you can limit the noise to the severety of your problem. DEBUG_LL_STATE = Link local state machine changes DEBUG_DEV_PKT = Packets or info directed to the device DEBUG_NET_PKT = Packets on info on the network at large DEBUG_INT_STATE = Internal network state changes Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Add link-local addressing supportJoe Hershberger2012-05-23-0/+13
| | | | | | | Code based on networking/zcip.c in busybox commit 8531d76a15890c2c535908ce888b2e2aed35b172 Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Don't copy every packet that waits for an ARPJoe Hershberger2012-05-23-18/+6
| | | | | | | | | Use the NetArpTxPacket for the ARP packet, not to hold what used to be in NetTxPacket. This saves a copy and makes the code easier to understand. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Fix net buffer initializationJoe Hershberger2012-05-23-14/+31
| | | | | | | | | A new non-static function net_init() will initialize buffers and read from the environment. Only update from the env on each entry to NetLoop(). Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Remove unused parameter from NetInitLoop()Joe Hershberger2012-05-23-2/+2
| | | | | | | Noone uses it. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Add net_update_ether() to handle ARP and Ping repliesJoe Hershberger2012-05-23-0/+23
| | | | | | | | | When the network is VLAN or SNAP, net_update_ether() will preserve the original Ethernet packet header and simply replace the src and dest MACs and the protocol Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Refactor to separate the UDP handler from the ARP handlerJoe Hershberger2012-05-23-33/+62
| | | | | | | | | | | Call a built-in dummy if none is registered... don't require protocols to register a handler (eliminating dummies) NetConsole now uses the ARP handler when waiting on arp (instead of needing a #define hack in arp.c) Clear handlers at the end of net loop Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Refactor to protect access to the NetState variableJoe Hershberger2012-05-23-9/+12
| | | | | | | Changes to NetState now go through an accessor function called net_set_state() Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Refactor to use NetSendPacket instead of eth_send directlyJoe Hershberger2012-05-23-8/+1
| | | | | | | | Use this entry-point consistently across the net/ code Use a static inline function to preserve code size Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Refactor NetSendUDPPacket to share more codeJoe Hershberger2012-05-23-19/+25
| | | | | | | Share more of the code that is common between ARP vs not. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Refactor IP, UPD, and ICMP header writing functionsJoe Hershberger2012-05-23-19/+28
| | | | | | | | ICMP (ping) was reimplementing IP header code... it now shares code. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: cosmetic: Alphabetize includes in net.cJoe Hershberger2012-05-23-12/+12
| | | | | | Easier to find when alphabetized Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Rename CDPHandler to cdp_receiveJoe Hershberger2012-05-23-1/+1
| | | | | | This is not called as a handler, so don't name it that way Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Rename "x" to "eth_proto"Joe Hershberger2012-05-23-12/+12
| | | | | | | x is a poor variable name Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Add a more explicit comment about 802.2Joe Hershberger2012-05-23-1/+2
| | | | | | | Make the comment more accurate about the header including SNAP Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Rename parameter len to payload_lenJoe Hershberger2012-05-23-7/+8
| | | | | | | | This name more explicitly claims that it does not include the header size Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Un-typedef ICMP_tJoe Hershberger2012-05-23-1/+1
| | | | | | Remove typedef and lower-case name Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Un-typedef VLAN_Ethernet_tJoe Hershberger2012-05-23-2/+4
| | | | | | Eliminate the typedef and remove capital letters Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Un-typedef Ethernet_tJoe Hershberger2012-05-23-5/+6
| | | | | | | Separate the Ethernet header from the 802 header. Base the size constants on the structs. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Split struct ip_udp_hdr into ip_hdrJoe Hershberger2012-05-23-8/+8
| | | | | | | | Add a structure that only contains IP header fields to be used by functions that don't need UDP Rename IP_HDR_SIZE_NO_UDP to IP_HDR_SIZE Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Un-typedef IP_tJoe Hershberger2012-05-23-30/+32
| | | | | | | | Rename IP header related things to IP_UDP. The existing definition of IP_t includes UDP header, so name it to accurately describe the structure. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Move RARP receive logic out of net.cJoe Hershberger2012-05-23-26/+1
| | | | | | | | Separate this functionality out of the net.c behemoth Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: Move PING out of net.cJoe Hershberger2012-05-23-129/+4
| | | | | | | Separate this functionality out of the net.c behemoth Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Move ARP out of net.cJoe Hershberger2012-05-23-196/+13
| | | | | | | | Separate this functionality out of the net.c behemoth Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: Encapsulate CDP packet identificationJoe Hershberger2012-05-23-1/+1
| | | | | | Checking for CDP packets should be encapsulated, not copied code. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Move CDP out of net.cJoe Hershberger2012-05-23-365/+1
| | | | | | Separate this functionality out of the net.c behemoth Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: punt bd->bi_ip_addrMike Frysinger2012-05-15-2/+0
| | | | | | | | | This field gets read in one place (by "bdinfo"), and we can replace that with getenv("ipaddr"). After all, the bi_ip_addr field is kept up-to-date implicitly with the value of the ipaddr env var. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: net.c checkpatch complianceJoe Hershberger2012-05-15-14/+8
| | | | | Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Remove volatile from net APIJoe Hershberger2012-05-15-17/+17
| | | | | Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* bootstage: Plumb in bootstage calls for basic operationsSimon Glass2012-03-18-0/+1
| | | | | | | | This inserts bootstage calls into tftp, usb start and bootm. We could go further, but this is a reasonable start to illustrate the concept. Signed-off-by: Simon Glass <sjg@chromium.org>
* net: Make sure IPaddr_t is 32 bits in sizeMatthias Weisser2011-12-06-3/+3
| | | | | | | | | | | When building u-boot as 64 bit application (e.g. sandbox) ulong might be 64 bits in size. This breaks network code as IPaddr_t is 64 bytes in size then and an IPv4 address is 32 bits in size. This patch makes sure that IPaddr_t is always 32 bits in size. Also some warnings introduced by this patch are fixed. Signed-off-by: Matthias Weisser <weisserm@arcor.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net/net.c: Fix GCC 4.6 build warningWolfgang Denk2011-11-07-3/+1
| | | | | | | | | Fix: net.c: In function 'CDPHandler': net.c:1083:8: warning: variable 'applid' set but not used [-Wunused-but-set-variable] Signed-off-by: Wolfgang Denk <wd@denx.de>
* net: Export auto_load, use it in rarpSimon Glass2011-10-27-0/+30
| | | | | | | | | | | The rarp code includes another instance of the auto_load logic, so call what is now net_auto_load() instead. This also fixes an incorrect call to TftpStart() which was never seen since apparently no boards enable rarp. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: Change for loop to memset()Simon Glass2011-10-27-6/+2
| | | | | | This is intended purely as a code size reduction. Signed-off-by: Simon Glass <sjg@chromium.org>
* net: Hide more code behind CONFIG_CMD_TFTPPUTSimon Glass2011-10-27-0/+8
| | | | | | | | This commit reduces code size a little by making the ICMP handler only available to tftpput. This is reasonable since it is the only user at present (ping just uses the normal handler). Signed-off-by: Simon Glass <sjg@chromium.org>
* net: tftpput: implement tftp logicSimon Glass2011-10-26-0/+4
| | | | | | | This adds logic to tftp.c to implement the tftp 'put' command, and updates the README. Signed-off-by: Simon Glass <sjg@chromium.org>
* net: tftpput: Rename TFTP to TFTPGETSimon Glass2011-10-26-10/+8
| | | | | | | | This is a better name for this protocol. Also remove the typedef to keep checkpatch happy, and move zeroing of NetBootFileXferSize a little earlier since TFTPPUT will need to change this. Signed-off-by: Simon Glass <sjg@chromium.org>