Commit Graph

37 Commits

Author SHA1 Message Date
Simon Glass c05ed00afb common: Drop linux/delay.h from common header
Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18 21:19:23 -04:00
Simon Glass f7ae49fc4f common: Drop log.h from common header
Move this header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18 21:19:18 -04:00
Simon Glass 0914011310 command: Remove the cmd_tbl_t typedef
We should not use typedefs in U-Boot. They cannot be used as forward
declarations which means that header files must include the full header to
access them.

Drop the typedef and rename the struct to remove the _s suffix which is
now not useful.

This requires quite a few header-file additions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18 18:36:55 -04:00
Simon Glass 90526e9fba common: Drop net.h from common header
Move this header out of the common header. Network support is used in
quite a few places but it still does not warrant blanket inclusion.

Note that this net.h header itself has quite a lot in it. It could be
split into the driver-mode support, functions, structures, checksumming,
etc.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18 17:33:31 -04:00
Joe Hershberger ac3f26cc15 net: Don't overwrite waiting packets with asynchronous replies
Peter originally sent a fix, but it breaks a number of other things.
This addresses the original reported issue in a different way.

That report was:

> U-Boot has 1 common buffer to send Ethernet frames, pointed to by
> net_tx_packet.  When sending to an IP address without knowing the MAC
> address, U-Boot makes an ARP request (using the arp_tx_packet buffer)
> to find out the MAC address of the IP addressr. When a matching ARP
> reply is received, U-Boot continues sending the frame stored in the
> net_tx_packet buffer.
>
> However, in the mean time, if U-Boot needs to send out any network
> packets (e.g. replying ping packets or ARP requests for its own IP
> address etc.), it will use the net_tx_packet buffer to prepare the
> new packet. Thus this buffer is no longer the original packet meant
> to be transmitted after the ARP reply. The original packet will be
> lost.

This instead uses the ARP tx buffer to send async replies in the case
where we are actively waiting for an ARP reply.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

Reported-by: Tran Tien Dat <peter.trantiendat@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
2018-10-10 12:29:01 -05:00
Joe Hershberger 3f02c98bd1 net: Add an accessor to know if waiting for ARP
This single-sources the state of the ARP.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2018-10-10 12:28:58 -05:00
Mario Six 2d8f25ed7b net: Always align tx packets
Make sure that TX packets are always cache-aligned.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2018-06-13 13:54:15 -05:00
Tom Rini f739fcd831 SPDX: Convert a few files that were missed before
As part of the main conversion a few files were missed.  These files had
additional whitespace after the '*' and before the SPDX tag and my
previous regex was too strict.  This time I did a grep for all SPDX tags
and then filtered out anything that matched the correct styles.

Fixes: 83d290c56f ("SPDX: Convert all of our single license tags to Linux Kernel style")
Reported-by: Heinrich Schuchardt <xypron.debian@gmx.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
2018-05-10 20:38:35 -04:00
Simon Glass 382bee57f1 env: Rename setenv() to env_set()
We are now using an env_ prefix for environment functions. Rename setenv()
for consistency. Also add function comments in common.h.

Suggested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16 08:22:18 -04:00
xypron.glpk@gmx.de 8cfb77387e net/arp: remove superfluous assignments
The value of variable pkt is never used.

The problem was indicated by clang scan-build.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2017-05-12 08:37:19 -04:00
Stefan Brüns 45b47734a0 net/arp: account for ARP delay, avoid duplicate packets on timeout
eth_rx() in the main reception loop may trigger sending a packet which
is already timed out (or will immediately) upon reception of an ARP reply.
As long as the ARP reply is pending, the timeout handler of a packet
should be postponed.
Happens on TFTP with bad network (e.g. WLAN).

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2015-10-28 14:57:37 -05:00
Stefan Brüns 943231119f net/arp: Do not run net_start_again() on timeout
net_start_again() will be called from net_loop() if state is NETLOOP_FAIL.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2015-10-28 14:57:00 -05:00
Joe Hershberger bc0571fc10 net: cosmetic: Fix checkpatch.pl failures in net.c
Finish eliminating CamelCase from net.c and other failures

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:35 -06:00
Joe Hershberger 85d25e0e76 net: cosmetic: Clean up ARP variables and functions
Make a thorough pass through all variables and function names contained
within arp and remove CamelCase and improve naming.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:33 -06:00
Joe Hershberger 1203fcceec net: cosmetic: Cleanup internal packet buffer names
This patch cleans up the names of internal packet buffer names that are
used within the network stack and the functions that use them.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2015-04-18 11:11:32 -06:00
Joe Hershberger 0adb5b761f net: cosmetic: Name ethaddr variables consistently
Use "_ethaddr" at the end of variables and drop CamelCase.
Make constant values actually 'const'.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:32 -06:00
Joe Hershberger 049a95a775 net: cosmetic: Change IPaddr_t to struct in_addr
This patch is simply clean-up to make the IPv4 type that is used match
what Linux uses. It also attempts to move all variables that are IP
addresses use good naming instead of CamelCase. No functional change.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:32 -06:00
Wolfgang Denk 2ea9103924 SPDX License cleanup for LiMon imported files
A number of network related files were imported from the LiMon
project; these contain a somewhat unclear license statement:

	Copyright 1994 - 2000 Neil Russell.
	(See License)

I analyzed the source code of LiMon v1.4.2 which was used for this
import.  It does not contain any "License" file, but the top level
directory contains a file "COPYING", which turns out to be GPL v2
of June 1991.  So it is legitimate to conclude that the LiMon derived
files are also to be released under GPLv2.  Mark them as such.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2014-10-10 09:44:43 -04:00
Kim Phillips 0637059088 net/: sparse fixes
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 a36b12f95a
"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>
2012-11-04 11:00:36 -07:00
Mike Frysinger a0bc44e68e net: fix typo in arp clean up
The clean up patch missed an &, so we end up passing an int rather than
a pointer to the sprintf function.

arp.c: In function 'ArpReceive':
arp.c:197: warning: format '%p' expects type 'void *', but argument 3 has type 'int'

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-07-10 10:14:56 -05:00
Joe Hershberger 4ef8d53caa net: Allow filtering on debug traces in the net subsystem
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>
2012-05-23 17:53:08 -05:00
Joe Hershberger c697576262 net: Work-around for brain-damaged Cisco equipment with arp-proxy
Cisco's arp-proxy feature fails to ignore the link-local address range
This means that a link-local device on a network with this Cisco
equipment will reply to ARP requests for our device (in addition to
our reply).
If we happen to reply first, the requester's ARP table will be
populated with our MAC address, and one packet will be sent to us...
shortly following this, the requester will get an ARP reply from the
Cisco equipment telling the requester to send packets their way
instead of to our device from now on.
This work-around detects this link-local condition and will delay
replying to the ARP request for 5ms so that the first packet is sent
to the Cisco equipment and all following packets are sent to our
device.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:53:08 -05:00
Joe Hershberger 228041893c net: Separate ArpRequest() into lower-level func
Link-local support will need to send ARP packets, but needs more
fine-grained control over the contents.  Split the implementation
into 2 parts so link-local can share the code.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:53:07 -05:00
Joe Hershberger e94070c443 net: Don't copy every packet that waits for an ARP
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>
2012-05-23 17:53:07 -05:00
Joe Hershberger f1d2d28469 net: Remove static allocation for MAC address in PingSend()
Don't force ARP clients to return the MAC address if they don't care
(such as ping)

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2012-05-23 17:53:05 -05:00
Joe Hershberger e711101581 net: Add net_update_ether() to handle ARP and Ping replies
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>
2012-05-23 17:53:04 -05:00
Joe Hershberger ece223b52a net: Refactor to separate the UDP handler from the ARP handler
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>
2012-05-23 17:52:53 -05:00
Joe Hershberger adf5d93e44 net: Refactor to use NetSendPacket instead of eth_send directly
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>
2012-05-23 17:46:20 -05:00
Joe Hershberger 00f33268ab net: Refactor packet length computations
Save the length when it is computed instead of forgetting it and
subtracting pointers to figure it out again.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2012-05-23 17:46:19 -05:00
Joe Hershberger 674bb24982 net: cosmetic: Replace magic numbers in arp.c with constants
Use field names and sizes when accessing ARP packets

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:18 -05:00
Joe Hershberger 1256793b18 net: cosmetic: Rename tmp to reply_ip_addr in arp.c
Renamed for clarity

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-23 17:46:17 -05:00
Joe Hershberger 738853bb6d net: cosmetic: Un-typedef ARP_t
Remove typedef and lower-case letters

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:15 -05:00
Joe Hershberger cb487f5664 net: cosmetic: Un-typedef Ethernet_t
Separate the Ethernet header from the 802 header.
Base the size constants on the structs.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:14 -05:00
Joe Hershberger 594c26f8a7 net: cosmetic: Un-typedef IP_t
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>
2012-05-23 17:46:00 -05:00
Joe Hershberger d280d3f430 net: Move ARP out of net.c
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>
2012-05-23 14:19:23 -05:00
wdenk 73a8b27c57 * Add support for RMU board
* Add support for TQM862L at 100/50 MHz

* Patch by Pantelis Antoniou, 02 Jun 2003:
  major reconstruction of networking code;
  add "ping" support (outgoing only!)
2003-06-05 19:27:42 +00:00
wdenk 14aba9c1dc Initial revision 2002-09-28 00:23:46 +00:00