Commit Graph

519 Commits

Author SHA1 Message Date
Michael Walle
46c07bcf12 api: net: fix length check in eth_receive()
If the requested length is too small to hold the received packet,
eth_receive() will return -1 and will leave the packet in the receive
buffers. Instead of returning an error in this case, we return the first
portion of the received packet and remove it from the receive buffers.

This fixes FreeBSD's ubldr. Without this patch it will just stop receiving
packets if the NIC receives more than PKTBUFSRX too large packets.

Signed-off-by: Michael Walle <michael@walle.cc>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
Cc: Rafal Jaworowski <raj@semihalf.com>
Cc: Piotr Kruszynski <ppk@semihalf.com>
2012-09-24 13:17:24 -05:00
Wolfgang Denk
b98b611502 Merge branch 'next' of git://git.denx.de/u-boot
* 'next' of git://git.denx.de/u-boot:
  MPC8xx: Fixup warning in arch/powerpc/cpu/mpc8xx/cpu.c
  doc: cleanup - move board READMEs into respective board directories
  net: sh_eth: add support for SH7757's GETHER
  net: sh_eth: modify the definitions of regsiter
  net: sh_eth: add SH_ETH_TYPE_ condition
  net: sh_eth: clean up for the SH7757's code
  net: fec_mxc: Fix MDC for xMII
  net: fec_mxc: Fix setting of RCR for xMII
  net: nfs: make NFS_TIMEOUT configurable
  net: Inline the new eth_setenv_enetaddr_by_index function
  net: allow setting env enetaddr from net device setting
  net/designware: Consecutive writes to the same register to be avoided
  CACHE: net: asix: Fix asix driver to work with data cache on
  net: phy: micrel: make ksz9021 phy accessible
  net: abort network initialization if the PHY driver fails
  phylib: phy_startup() should return an error code on failure
  net: tftp: fix type of block arg to store_block

Signed-off-by: Wolfgang Denk <wd@denx.de>
2012-07-30 20:39:52 +02:00
Joe Hershberger
a03d638805 net: Make sure the ethaddr is updated in net_init()
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>
2012-07-24 14:09:40 -05:00
benoit.thebaudeau@advans
b684115791 net: link_local: fix build
Fix comment within comment build error.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
2012-07-19 13:11:31 -05:00
benoit.thebaudeau@advans
b977aa80b5 net: bootp: fix build
Fix NetSetState function name used with CONFIG_BOOTP_MAY_FAIL.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
2012-07-19 13:11:31 -05:00
Tetsuyuki Kobayashi
48a3e999c8 net: nfs: make NFS_TIMEOUT configurable
NFS_TIMEOUT is constant value defined in net/nfs.c. But sometimes it needs to adjust.
This patch enables to override NFS_TIMEOUT by defining CONFIG_NFS_TIMEOUT in a board specific config file.

Signed-off-by: Tetsuyuki Kobayashi <koba@kmckk.co.jp>
2012-07-12 14:13:24 -05:00
Wolfgang Denk
0878222fed Merge branch 'next' of git://git.denx.de/u-boot-net into next
* 'next' of git://git.denx.de/u-boot-net:
  net: Inline the new eth_setenv_enetaddr_by_index function
  net: allow setting env enetaddr from net device setting
  net/designware: Consecutive writes to the same register to be avoided
  CACHE: net: asix: Fix asix driver to work with data cache on
  net: phy: micrel: make ksz9021 phy accessible
  net: abort network initialization if the PHY driver fails
  phylib: phy_startup() should return an error code on failure
  net: tftp: fix type of block arg to store_block

Signed-off-by: Wolfgang Denk <wd@denx.de>
2012-07-12 08:23:58 +02:00
Joe Hershberger
154177e14a net: Inline the new eth_setenv_enetaddr_by_index function
This function is currently only used in one case.  Inline for now.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-07-11 13:15:32 -05:00
Rob Herring
c88ef3c12d net: allow setting env enetaddr from net device setting
If the net driver has setup a valid ethernet address and an ethernet
address is not set in the environment already, then set the environment
variables from the net driver setting.

This enables pxe booting on boards which don't set ethaddr env variable.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
2012-07-11 13:15:32 -05:00
Jayachandran Chandrasekharan Nair
bc46dfac2f net: tftp: fix type of block arg to store_block
The block argument for store_block can be -1 when the tftp sequence
number rolls over (i.e TftpBlock == 0), so the first argument to
store_block has to be of type 'int' instead of 'unsigned'.

In our environment (gcc 4.4.5 mips toolchain), this causes incorrect
'offset' to be generated for storing the block, and the tftp block
with number 0 will be written elsewhere, resulting in a bad block in
the downloaded file and a memory corruption.

Signed-off-by: Jayachandran Chandrasekharan Nair <jayachandranc@netlogicmicro.com>
2012-07-11 13:14:16 -05: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
Wolfgang Denk
3fe63839f3 Minor Coding Style cleanup
Signed-off-by: Wolfgang Denk <wd@denx.de>
2012-07-10 09:18:33 +02:00
Kim Phillips
db7720bad4 net: make net_rand.h inclusion depend on BOOTP_RANDOM_DELAY
commit "net: use common rand()/srand() functions" introduced the following
build warning on the current u-boot-arm tree:

$ ./MAKEALL MPC8313ERDB_66
Configuring for MPC8313ERDB_66 - Board: MPC8313ERDB, Options: SYS_66MHZ
   text	   data	    bss	    dec	    hex	filename
 271988	  13976	  41768	 327732	  50034	./u-boot
In file included from bootp.c:15:0:
net_rand.h: In function 'srand_mac':
net_rand.h:40:2: warning: implicit declaration of function 'srand' [-Wimplicit-function-declaration]

adding this dependency fixes it.

Cc: Michael Walle <michael@walle.cc>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Acked-by: Michael Walle <michael@walle.cc>
2012-07-08 22:39:42 +02:00
Michael Walle
03c1b04f86 net: add helper to generate random mac address
Add new function eth_random_enetaddr() to generate a locally administered
ethernet address.

Signed-off-by: Michael Walle <michael@walle.cc>
Acked-by: Joe Hershberger <joe.hershberger@gmail.com>
2012-07-07 14:07:32 +02:00
Michael Walle
99e139d590 net: use common rand()/srand() functions
Replace rand() with the functions from lib/. The link-local network code
stores its own seed, derived from the MAC address. Thus making it
independent from calls to srand() in other modules.

Signed-off-by: Michael Walle <michael@walle.cc>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2012-07-07 14:07:32 +02: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
d22c338e07 net: Add link-local addressing support
Code based on networking/zcip.c in busybox
commit 8531d76a15890c2c535908ce888b2e2aed35b172

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
46c495d524 net: Fix net buffer initialization
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>
2012-05-23 17:53:06 -05:00
Joe Hershberger
cb1c991120 net: Remove unused parameter from NetInitLoop()
Noone uses it.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-23 17:53:06 -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
2c00e099fe net: Add option CONFIG_BOOTP_MAY_FAIL
This is useful if you want to look for a DHCP server, but try some
other settings if not available.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-23 17:53:05 -05:00
Joe Hershberger
1752f0fdc7 net: Fix unused variable compile warning
If CONFIG_BOOTP_SERVERIP is not defined, unused variable warning is
reported.  This was fixed upstream using a compiler feature instead
of a simple reorder of the statements.

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: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
22f6e99d5b net: Refactor to protect access to the NetState variable
Changes to NetState now go through an accessor function called
net_set_state()

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:21 -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
61da3c2af8 net: Refactor ping receive handler
There is no need to call through the handler... inline it

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:20 -05:00
Joe Hershberger
f9623229fd net: Move debug trace to point of action
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
ae446f5622 net: Refactor bootp packet length computations
Eliminate pointer subtraction that recovers values computed earlier

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-23 17:46:19 -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
9214637a56 net: Refactor NetSendUDPPacket to share more code
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>
2012-05-23 17:46:18 -05:00
Joe Hershberger
4b11c9166b net: Refactor IP, UPD, and ICMP header writing functions
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>
2012-05-23 17:46:18 -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
4545f4e6db net: cosmetic: Alphabetize includes in net.c
Easier to find when alphabetized

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:17 -05:00
Joe Hershberger
f8315731db net: cosmetic: Rename OPT_SIZE to OPT_FIELD_SIZE
Clearer constant name.
Also remove related BOOTP_SIZE which was unused and doesn't take
into account VLAN packets.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:17 -05:00
Joe Hershberger
0b4c5ff4ab net: cosmetic: Rename CDPHandler to cdp_receive
This is not called as a handler, so don't name it that way

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:16 -05:00
Joe Hershberger
8d353eb86d net: cosmetic: Rename "x" to "eth_proto"
x is a poor variable name

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-23 17:46:16 -05:00
Joe Hershberger
da5ebe2c9a net: cosmetic: Add a more explicit comment about 802.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>
2012-05-23 17:46:16 -05:00
Joe Hershberger
206d07fd7c net: cosmetic: Rename parameter len to payload_len
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>
2012-05-23 17:46:15 -05:00
Joe Hershberger
e0a630795b net: cosmetic: Un-typedef ICMP_t
Remove typedef and lower-case name

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:15 -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
c68cca35b3 net: cosmetic: Un-typedef VLAN_Ethernet_t
Eliminate the typedef and remove capital letters

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:14 -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
c5c59df04d net: cosmetic: Split struct ip_udp_hdr into ip_hdr
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>
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
8b9c53221f net: Move RARP receive logic 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:24 -05:00
Joe Hershberger
a36b12f95a net: Move PING 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>
2012-05-23 14:19:23 -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
Joe Hershberger
1735188329 net: Encapsulate CDP packet identification
Checking for CDP packets should be encapsulated, not copied code.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 14:19:23 -05:00
Joe Hershberger
f575ae1f7d net: Move CDP out of net.c
Separate this functionality out of the net.c behemoth

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 14:19:22 -05:00
Joe Hershberger
eafc8db0e3 net: Move MAC-seeded rand out of bootp.c
Make the MAC-seeded random number generator available to /net in
general.  MAC-seeded rand will be needed by link-local as well, so
give it an interface.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-23 14:19:22 -05:00
Mike Frysinger
de30122bb5 net: move bootfile init into eth_initialize
All arches init this the same way, so move the logic into the core
net code to avoid duplicating it everywhere else.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-15 17:32:33 -05:00
Mike Frysinger
50a47d0523 net: punt bd->bi_ip_addr
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>
2012-05-15 17:32:05 -05:00
Joe Hershberger
13dfe94379 net: cosmetic: tftp.* checkpatch compliance
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:16:52 -05:00
Joe Hershberger
6c3234a343 net: cosmetic: sntp.* checkpatch compliance
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:16:45 -05:00
Joe Hershberger
c2faf4f901 net: cosmetic: rarp.* checkpatch compliance
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:16:36 -05:00
Joe Hershberger
c9f6c91b48 net: cosmetic: nfs.* checkpatch compliance
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:16:27 -05:00
Joe Hershberger
48522bb503 net: cosmetic: net.c checkpatch compliance
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:16:19 -05:00
Joe Hershberger
66c7385a5f net: cosmetic: eth.c checkpatch compliance
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:16:10 -05:00
Joe Hershberger
3090b7e36c net: cosmetic: bootp.* checkpatch compliance
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:15:58 -05:00
Joe Hershberger
db288a9602 net: Remove volatile from net API
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:10:04 -05:00
Eric Miao
6937664426 net/eth.c: fix eth_write_hwaddr() to use dev->enetaddr as fall back
Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
fails, fall back to use dev->enetaddr, which could be filled up by
the ethernet device driver:

With the current code, introduced with below commit, eth_write_hwaddr()
will fail immediately if there is no eth<n>addr in the environment variables.

However, e.g. for an overo based product that uses the SMSC911x ethernet
chip (with the MAC address set via EEPROM connected to the SMSC911x chip),
the MAC address is still OK.

On mx28 boards that are depending on the OCOTP bits to set the MAC address
(like the Denx m28 board), the OCOTP bits should be used instead of
failing on the environment variables.

Actually, this was the original behavior, and was later changed by
commit 7616e78508.

Signed-off-by: Eric Miao <eric.miao@linaro.org>
Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Dirk Behme <dirk.behme@de.bosch.com>
CC: Stefan Roese <sr@denx.de>
CC: Eric Miao <eric.miao@linaro.org>
CC: Wolfgang Denk <wd@denx.de>
CC: Philip Balister <philip@balister.org>
CC: Zach Sadecki <zach@itwatchdogs.com>
2012-04-03 19:25:45 -05:00
Simon Glass
573f14fe4e bootstage: Plumb in bootstage calls for basic operations
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>
2012-03-18 21:42:56 +01:00
Simon Glass
770605e4f9 bootstage: Replace show_boot_progress/error() with bootstage_...()
These calls should not be made directly any more, since bootstage
will call the show_boot_...() functions as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2012-03-18 21:41:39 +01:00
Simon Glass
c8e66db789 bootstage: Convert net progress numbers to enums
This changes over the network-related progress numbers to use enums
from bootstage.h.

Signed-off-by: Simon Glass <sjg@chromium.org>
2012-03-18 21:33:05 +01:00
Simon Glass
5ddb118da4 bootstage: Use show_boot_error() for -ve progress numbers
Rather than the caller negating our progress numbers to indicate an
error has occurred, which seems hacky, add a function to indicate this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2012-03-18 20:56:00 +01:00
Mike Frysinger
f6add132f6 net/miiphy/serial: drop duplicate "NAMESIZE" define
A few subsystems are using the same define "NAMESIZE".  This has been
working so far because they define it to the same number.  However, I
want to change the size of eth_device's NAMESIZE, so rather than tweak
the define names, simply drop references to it.  Almost no one does,
and the handful that do can easily be changed to a sizeof().

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-03-18 20:11:22 +01:00
Marek Vasut
021f6038a2 PPC: Drop mv6446x_eth_initialize() from net/eth.c
This function was defined as an extern in net/eth.c, drop that and use
standard means of calling it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
2012-03-06 21:13:26 +01:00
Marek Vasut
658c3b9eaf PPC: Drop mv6436x_eth_initialize() from net/eth.c
This function was defined as an extern in net/eth.c, drop that and use
standard means of calling it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Reinhard Arlt <reinhard.arlt@esd-electronics.com>
2012-03-06 21:13:22 +01:00
Vincent Palatin
e7e982d69c eth: remove usb-ethernet devices before re-enumerating them
Fix the crash when running several times usb_init() with a USB ethernet
device plugged.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Wolfgang Grandegger <wg@denx.de>
2012-03-03 16:56:04 +01:00
Michael Walle
fea7dcae50 net: introduce per device index
Instead of counting the device index everytime a functions needs it, store
it in the eth_device struct. eth_register() keeps track of the indices and
updates the device's index number. This simplifies some functions in
net/eth.c.

Additionally, a network driver can now query its index, eg. to get the
correct environment ethaddr name.

Signed-off-by: Michael Walle <michael@walle.cc>
Cc: Prafulla Wadaskar <prafulla@marvell.com>
Cc: Mike Frysinger <vapier@gentoo.com>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-12-20 22:57:25 +01:00
Matthias Weisser
ea45cb0adc net: Make sure IPaddr_t is 32 bits in size
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>
2011-12-06 22:15:32 +01:00
Anatolij Gustschin
c0fe04bf65 net/bootp.c: Fix GCC 4.6 warning
Fix:
bootp.c: In function 'BootpCopyNetParams':
bootp.c:108:11: warning: unused variable 'tmp_ip' [-Wunused-variable]

Signed-off-by: Anatolij Gustschin <agust@denx.de>
2011-11-23 08:25:50 +01:00
Wolfgang Denk
5c10419cea net/net.c: Fix GCC 4.6 build warning
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>
2011-11-07 22:14:29 +01:00
Simon Glass
e4a3d57dc7 net: Export auto_load, use it in rarp
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>
2011-10-27 23:53:58 +02:00
Simon Glass
ed1ada712a net: Change for loop to memset()
This is intended purely as a code size reduction.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-27 23:53:58 +02:00
Simon Glass
8c6914f10f net: Add more #ifdefs for tftpput to reduce code size
If CONFIG_CMD_TFTPPUT is not enabled, we want minimal code size impact
on the tftp code. This introduces a few more #ifdefs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-27 23:53:58 +02:00
Simon Glass
165099e753 net: Make net_transfer() a static function
This should be a static function so it can be inlined.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-10-27 23:53:57 +02:00
Simon Glass
39bccd21d0 net: Hide more code behind CONFIG_CMD_TFTPPUT
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>
2011-10-27 23:53:57 +02:00
Simon Glass
1fb7cd498e net: tftpput: implement tftp logic
This adds logic to tftp.c to implement the tftp 'put' command, and
updates the README.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-26 21:36:22 +02:00
Simon Glass
58f317d182 net: tftpput: Support selecting get/put for tftp
TftpStart should support starting either a get or a put.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-26 21:34:44 +02:00
Simon Glass
e4cde2f70d net: tftpput: Factor out start, restart and next block functions
This code is required for tftpput, so move it into separate functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-26 21:34:27 +02:00
Simon Glass
f5329bbc3f net: tftpput: move common code into separate functions
We want to show block markers on completion of get and put, so
move this common code into separate functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-26 21:34:04 +02:00
Simon Glass
e4bf0c5cfe net: tftpput: Rename TFTP to TFTPGET
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>
2011-10-26 21:33:42 +02:00
Simon Glass
4793ee6522 net: tftpput: Add support for receiving ICMP packets
ICMP packets can tell you when there is no server at the other end. It
is useful for tftp to figure this out, so that a quick error can be
displayed, rather than pointlessly retrying.

This adds an ICMP packet handler to the net interface.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-26 21:33:25 +02:00
Simon Glass
8f79bb17a4 net: tftpput: Move ICMP code into its own function
NetReceive() is a very long function with a lot of indent. Before adding
code to the ICMP bit, split it out.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-26 21:32:59 +02:00
Bernhard Kaindl
6dc809f407 net/dns.c: Fix endian conversion for big-endian in dns command
net/dns.c used endian conversion macros wrongly (shorts in reply
were put swapped into CPU, and then ntohs() was used to swap it
back, which broke on big-endian).

Fix this by using the correct linux conversion macro for reading
a unaligned short in network byte order: get_unaligned_be16()
Thanks to Mike Frysinger pointing at the best macro to use.

Tested on big and little endian qemu boards (mips and versatile)

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@thalesgroup.com>
Cc: Pieter Voorthuijsen <pieter.voorthuijsen@prodrive.nl>
Cc: Robin Getz <rgetz@blackfin.uclinux.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-10-23 23:34:19 +02:00
Jason Hobbs
d2b5d5c4c1 net: bootp: add PXE/RFC 4578 DHCP options support
These options are required to be present in RFC 4578 compliant DHCP
requests. They give more information to DHCP servers to allow serving

different DHCP responses to different systems based on client
architecture, client capabilities, UUID, or vendor.

Signed-off-by: Jason Hobbs <jason.hobbs@calxeda.com>
2011-10-17 22:25:35 +02:00
Mike Frysinger
e2a53458a7 net: drop !NET_MULTI code
This is long over due.  All but two net drivers have been converted, but
those have now been dropped.

The only thing left to do is actually delete all references to NET_MULTI
and code that is compiled when that is not defined.  So here we scrub the
core code.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-10-05 22:22:16 +02:00
Mike Frysinger
d90f0c107b net: drop !NET_MULTI ns7520 driver
This driver was never converted to NET_MULTI, and no board uses it.
So punt it and be done.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-10-05 22:22:15 +02:00
Philip Balister
a9a730e0bc net: Add \n before warning message so it prints on a new line.
Signed-off-by: Philip Balister <philip@opensdr.com>
2011-10-01 21:55:42 +02:00
Mike Frysinger
ff25d32c25 net: turn name len check into an assert
The new sanity check introduces a printf warning for some systems:
	eth.c:233: warning: format '%zu' expects type 'size_t', but argument 3 has type 'int'

Rather than tweak the format string, use the new assert() helper instead.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-09-21 23:04:34 +02:00
Peter Korsgaard
7aabad2804 net/bootp.c: fix tftp load if autoload environment var isn't set
Commit 093498669 (Put common autoload code into auto_load() function)
broke handling of autoload environment variable not being set.
The bootp/dhcp code will just keep on requesting IP address forever
and never start TFTP download.

Fix it by moving TftpStart() outside the conditional like it was before.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Simon Glass <sjg@chromium.org>
2011-09-19 23:25:08 +02:00
Helmut Raiger
7e7f903fcd net/eth.c: throw BUG for eth_get_dev_by_name(NULL)
eth_get_dev_by_name() is not safe to use for devname being NULL
as it uses strcmp. This patch makes it fail with a BUG().

Signed-off-by: Helmut Raiger <helmut.raiger@hale.at>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-09-09 23:58:47 +02:00
Simon Glass
019fd6d45b Correct call to eth_write_hwaddr()
This fixes "Warning: failed to set MAC address" on platforms which rely on
an 'ethaddr' environment variable to set the MAC address.

This bug was introduced by this commit:

7616e785 Add Ethernet hardware MAC address framework to usbnet

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Kumar Gala <galak@kernel.crashing.org>
Tested-by: Michal Simek <monstr@monstr.eu>
Tested-by: Heiko Schocher <hs@denx.de>
2011-09-05 16:06:06 +02:00
Michal Simek
58c583b6c2 net: Check network device driver name
If name is longer than allocated space NAMESIZE
mac address is rewritten which show error
message like:

Error message:
Warning: Xlltemac.87000000 MAC addresses don't match:
Address in SROM is         30:00:00:00:00:00
Address in environment is  00:0a:35:00:6a:04

NAMESIZE contains Driver name + zero terminated character.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2011-09-04 23:29:39 +02:00
Simon Glass
093498669e Put common autoload code into auto_load() function
This is a small clean-up patch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Eric Bénard <eric@eukrea.com>
2011-08-08 21:05:23 +02:00
Simon Glass
7616e78508 Add Ethernet hardware MAC address framework to usbnet
Built-in Ethernet adapters support setting the mac address by means of a
ethaddr environment variable for each interface (ethaddr, eth1addr, eth2addr).

This adds similar support to the USB network side, using the names
usbethaddr, usbeth1addr, etc. They are kept separate since we don't want
a USB device taking the MAC address of a built-in device or vice versa.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Eric Bénard <eric@eukrea.com>
2011-08-08 21:05:23 +02:00
Andreas Bießmann
d1228ea900 net/eth.c: drop obsolete at91rm9200 support
All available at91rm9200 boards have migrated to ar920t/at91 and
therefore to CONFIG_NET_MULTI.
The obsolete at91rm9200_miiphy_initialize() was removed in "ARM: remove
obsolete at91rm9200".

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
2011-08-03 13:00:56 +02:00
Luuk Paulussen
09e3a67dec bootp: add ntpserver option to bootp request
Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: Ben Warren <biggerbadderben@gmail.com>
2011-07-27 23:20:46 +02:00
Enric Balletbo i Serra
23a70bf9c3 net/net.c: Update ipaddr if the environment has changed
At least on ARM the ipaddr is only set in board_init_r function. The
problem is if ipaddr is not defined in environment importing another
environment defined don't update the ipaddr value.

For example, suppose we've a default environment without net variables
defined and we want to import an uEnv.txt environment from SD-card like
this:

  ipaddr=192.168.2.240
  netmask=255.255.255.0
  gatewayip=192.168.2.1
  serverip=192.168.2.114

Then if you try boot from NFS results in:

  Importing environment from mmc ...
  Running uenvcmd ...
  smc911x: detected LAN9221 controller
  smc911x: phy initialized
  smc911x: MAC ac🇩🇪48:00:00:00
  *** ERROR: `ipaddr' not set

The ipaddr at this point is NULL beacause is only set at board_init_r
function. This patch updates the ipaddr value if the environment has
changed.

Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-06-01 22:17:49 +02:00
Luca Ceresoli
4d69e98c06 net/tftp.c: fix typo
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-05-19 21:38:38 +02:00
Luca Ceresoli
7a83af07ae TFTP: add tftpsrv command
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-05-19 21:38:32 +02:00
Luca Ceresoli
e59e35620a TFTP: net/tftp.c: add server mode receive
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-05-19 21:38:26 +02:00
Luca Ceresoli
e3fb0abe2b TFTP: rename STATE_RRQ to STATE_SEND_RRQ
With the upcoming TFTP server implementation, requests can be either
outgoing or incoming, so avoid ambiguities.

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-05-19 21:38:19 +02:00
Luca Ceresoli
20478ceaa2 TFTP: replace "server" with "remote" in local variable names
With the upcoming TFTP server implementation, the remote node can be
either a client or a server, so avoid ambiguities.

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-05-19 21:38:12 +02:00
Luca Ceresoli
9bb0a1bf98 net/tftp.c: cosmetic: do not initialise statics to 0 or NULL
This removes the following checkpatch issue:
 - ERROR: do not initialise statics to 0 or NULL

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
2011-05-19 21:36:21 +02:00
Luca Ceresoli
0bdd8acc35 net/tftp.c: cosmetic: fix indentation
This removes the following checkpatch issue:
 - WARNING: suspect code indent for conditional statements

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
2011-05-19 21:36:15 +02:00
Luca Ceresoli
6d2231e8fa net/tftp.c: cosmetic: trailing statements should be on next line
This removes the following checkpatch issue:
 - ERROR: trailing statements should be on next line

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
2011-05-19 21:36:08 +02:00
Luca Ceresoli
7bc325a1b2 net/tftp.c: cosmetic: fix brace issues
This removes the following checkpatch issues:
 - WARNING: braces {} are not necessary for single statement blocks
 - WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
2011-05-19 21:36:02 +02:00
Luca Ceresoli
2cb5360807 net/tftp.c: cosmetic: do not use assignment in if condition
This removes the following checkpatch issue:
 - ERROR: do not use assignment in if condition.

There is one such error left:

  ERROR: do not use assignment in if condition
  #239: FILE: tftp.c:239:
  +		if (!ProhibitMcast
  +		 && (Bitmap = malloc(Mapsize))
  +		 && eth_get_dev()->mcast) {

which would require an additional nested if to be fixed, resulting in longer
and less readable code.

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
2011-05-19 21:35:55 +02:00
Luca Ceresoli
2e320257c8 net/tftp.c: cosmetic: fix pointer syntax issues
This removes the following checkpatch issues:
 - ERROR: "foo * bar" should be "foo *bar"
 - ERROR: "(foo*)" should be "(foo *)"

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
2011-05-19 21:35:48 +02:00
Luca Ceresoli
c718b1439b net/tftp.c: cosmetic: fix whitespace issues
This removes the following checkpatch issues:
 - ERROR: space prohibited before that close parenthesis ')'
 - ERROR: space required after that ';' (ctx:BxV)
 - ERROR: space required after that ',' (ctx:VxV)
 - ERROR: space required after that ';' (ctx:VxV)
 - ERROR: spaces required around that '<<=' (ctx:VxV)
 - ERROR: spaces required around that '<' (ctx:VxV)
 - ERROR: spaces required around that '=' (ctx:VxV)
 - ERROR: spaces required around that '+=' (ctx:VxV)
 - ERROR: spaces required around that '=' (ctx:VxW)
 - WARNING: please, no spaces at the start of a line
 - WARNING: space prohibited between function name and open parenthesis '('

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
2011-05-19 21:35:40 +02:00
Luca Ceresoli
2f09413fd9 net/tftp.c: cosmetic: fix lines over 80 characters
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
2011-05-19 21:34:48 +02:00
Luca Ceresoli
ccb9ebefbe net/net.c: cosmetic: do not use assignment in if condition
This removes the following checkpatch issue:
 - ERROR: do not use assignment in if condition

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
2011-05-12 22:07:41 +02:00
Luca Ceresoli
c819abeef7 net/net.c: cosmetic: fix indentation
This removes the following checkpatch issues:
 - ERROR: switch and case should be at the same indent
 - WARNING: suspect code indent for conditional statements
 - WARNING: labels should not be indented

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
2011-05-12 22:07:31 +02:00
Luca Ceresoli
92895de978 net/net.c: cosmetic: parentheses not required for return
This removes the following checkpatch issue:
 - ERROR: return is not a function, parentheses are not required

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
2011-05-12 22:06:04 +02:00
Luca Ceresoli
6b147d1139 net/net.c: cosmetic: fix pointer syntax issues
This removes the following checkpatch issues:
 - ERROR: "foo * bar" should be "foo *bar"
 - ERROR: "(foo*)" should be "(foo *)"

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
2011-05-12 22:03:47 +02:00
Luca Ceresoli
d3c65b015a net/net.c: cosmetic: fix brace issues
This removes the following checkpatch issues:
 - WARNING: braces {} are not necessary for single statement blocks
 - WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
2011-05-12 22:01:34 +02:00
Luca Ceresoli
4f63acd062 net/net.c: cosmetic: fix whitespace issues
This removes the following checkpatch issues:
 - ERROR: space prohibited after that open parenthesis '('
 - ERROR: space prohibited before that close parenthesis ')'
 - ERROR: space prohibited after that open square bracket '['
 - ERROR: space prohibited after that '&' (ctx:WxW)
 - ERROR: spaces required around that '=' (ctx:VxW)
 - ERROR: space required before the open parenthesis '('
 - ERROR: space required after that ',' (ctx:VxV)
 - ERROR: need consistent spacing around '+' (ctx:WxV)
 - WARNING: unnecessary whitespace before a quoted newline
 - WARNING: please, no spaces at the start of a line
 - WARNING: space prohibited between function name and open
   parenthesis '('

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
2011-05-12 22:01:05 +02:00
Luca Ceresoli
c586ce6e01 net/net.c: cosmetic: variable initializations
This removes the following checkpatch errors:
 - ERROR: do not initialise globals to 0 or NULL
 - ERROR: spaces required around that '=' (ctx:VxV)
 - ERROR: that open brace { should be on the previous line

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
2011-05-12 21:49:56 +02:00
Luca Ceresoli
3e38e429ff net/net.c: cosmetic: fix lines over 80 characters
This removes the following checkpatch warning:
 - WARNING: line over 80 characters

There are three such warnings left.

The first is hard to fix with cosmetic-only changes without compromising code
readability, so I'm leaving it as it is for now:
  WARNING: line over 80 characters
  #1537: FILE: net.c:1537:
  + [4 tabs] memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, ...

The other two cannot be fixed without splitting string literals, so it is
preferred to keep them longer than 80 characters.

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
2011-05-12 21:49:49 +02:00
Luca Ceresoli
03eb129f8a NET: pass source IP address to packet handlers
This is needed for the upcoming TFTP server implementation.

This also simplifies PingHandler() and fixes rxhand_f documentation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-05-12 19:38:19 +02:00
Simon Guinot
8b6bbe104f netconsole: remove `serverip' check
Netconsole use the environment variable `ncip' to configure the
destination IP. `serverip' don't need to be defined.

Signed-off-by: Simon Guinot <sguinot@lacie.com>
2011-05-12 19:11:51 +02:00
Gray Remlin
9030a55ef3 NET: Correct potential missing goto label in case statement.
If neither CONFIG_CMD_PING or CONFIG_CMD_SNTP are defined but
CONFIG_CMD_DNS is, a compile-time error will occur due to the
absence of a goto label.

Signed-off-by: Gray Remlin <gryrmln@gmail.com>
2011-04-28 00:46:49 +02:00
Andy Fleming
5f184715ec Create PHY Lib for U-Boot
Extends the mii_dev structure to participate in a full-blown MDIO and
PHY driver scheme.  The mii_dev structure and miiphy calls are modified
in such a way to allow the original mii command and miiphy
infrastructure to work as before, but also to support a new set of APIs
which allow (among other things) sharing of PHY driver code and 10G support

The mii command will continue to support normal PHY management functions
(Clause 22 of 802.3), but will not be changed to support 10G
(Clause 45).

The basic design is similar to PHY Lib from Linux, but simplified for
U-Boot's network and driver infrastructure.

We now have MDIO drivers and PHY drivers

An MDIO driver provides:
read
write
reset

A PHY driver provides:
(optionally): probe
config - initial setup, starting of auto-negotiation
startup - waiting for AN, and reading link state
shutdown - any cleanup needed

The ethernet drivers interact with the PHY Lib using these functions:
phy_connect()
phy_config()
phy_startup()
phy_shutdown()

Each PHY driver can be configured separately, or all at once using
config_phylib_all_drivers.h (added in the patch which adds the drivers)

We also provide generic drivers for Clause 22 (10/100/1000), and
Clause 45 (10G) PHYs.

We also implement phy_reset(), and call it in phy_connect(). Because
phy_reset() is essentially the same as miiphy_reset, but:
a) must support 10G PHYs, and
b) should use the phylib primitives,

we implement miiphy_reset, using phy_reset(), but only when
CONFIG_PHYLIB is set. Otherwise, we just use the old version. In this
way, we save on compile size, even if we don't manage to save code size.

Pulled ethtool.h and mdio.h from:
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
782d640afd15af7a1faf01cfe566ca4ac511319d
With many, many deletions so as to enable compilation under u-boot

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-04-20 15:09:19 -05:00
Simon Glass
21076f61c7 Fix bad padding of bootp request packet
This seems to pad to one byte longer than required

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-04-13 22:25:07 +02:00
Remy Bohmer
c650e1be41 Fix compile warning in net/eth.c
Signed-off-by: Remy Bohmer <linux@bohmer.net>
2011-02-19 20:32:38 +01:00
Simon Glass
89d48367ed Add USB host ethernet adapter support
This adds support for using USB Ethernet dongles in host mode. This is just
the framework - drivers will come later. A new config option called
CONFIG_USB_HOST_ETHER can be defined in board config files to switch this
on.

The was originally written by NVIDIA and was cleaned up for release by the
Chromium authors.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-02-19 20:32:36 +01:00
Mike Frysinger
2e3ef6e4e4 string_to_VLAN: constify "var" arg
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-11-28 21:56:12 +01:00
Mike Frysinger
b920ee9db2 copy_filename: constify "src" arg
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-11-28 21:55:15 +01:00
Sebastien Carlier
6d8962e814 Switch from archive libraries to partial linking
Before this commit, weak symbols were not overridden by non-weak symbols
found in archive libraries when linking with recent versions of
binutils.  As stated in the System V ABI, "the link editor does not
extract archive members to resolve undefined weak symbols".

This commit changes all Makefiles to use partial linking (ld -r) instead
of creating library archives, which forces all symbols to participate in
linking, allowing non-weak symbols to override weak symbols as intended.
This approach is also used by Linux, from which the gmake function
cmd_link_o_target (defined in config.mk and used in all Makefiles) is
inspired.

The name of each former library archive is preserved except for
extensions which change from ".a" to ".o".  This commit updates
references accordingly where needed, in particular in some linker
scripts.

This commit reveals board configurations that exclude some features but
include source files that depend these disabled features in the build,
resulting in undefined symbols.  Known such cases include:
- disabling CMD_NET but not CMD_NFS;
- enabling CONFIG_OF_LIBFDT but not CONFIG_QE.

Signed-off-by: Sebastien Carlier <sebastien.carlier@gmail.com>
2010-11-17 21:02:18 +01:00
Ben Warren
8ad25bf8d9 Net: clarify board/cpu_eth_init calls
This has always been confusing, and the idea of these functions returning the
number of interfaces initialized was half-baked and ultimately pointless.
Instead, act more like regular functions and return < 0 on failure, >= 0 on
success.

This change shouldn't break anything.

Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-11-15 00:01:15 +01:00
Jason Liu
258ccd6817 net: Fix potential empty DHCP Parameter Request List
Can't get IP address with dhcp due to the dhcp server not
allow the empty param list request under some network env

This patch is based on Gray Remlin's initial patch.

Signed-off-by: Jason Liu <r64343@freescale.com>
Signed-off-by: Gray Remlin <g_remlin@rocketmail.com>
2010-11-14 23:29:29 +01:00
Peter Tyser
bf6cb247a5 rarp: Condtionally compile rarp support
Most people don't use the 'rarpboot' command, so only enable it when
CONFIG_CMD_RARP is defined.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-10-11 23:00:29 -07:00
Ben Warren
68e1ede88a Net: Remove redundant CONFIG_NET_MULTI directives
All are within an #ifdef CONFIG_NET_MULTI block already

Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-10-11 22:47:48 -07:00
Ben Warren
d7fb9bcfb2 Fix compile warnings for const correctness
Commit 6e37b1a3a25004d3df5867de49fff6b3fc9c4f04 modifies several net calls
to take a (const char *) parameter instead of (char *), but in some cases
the modified functions call other functions taking (char *).  The end result
is warnings about discarding the const qualifier.

This patch fixes these other function signatures.

Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-08-09 11:52:30 -07:00
Mike Frysinger
1384f3bb8a net: warn about spaces in device names
Some commands operate on eth device names (like 'mii'), but those cannot
be passed on the command line as one argument.  So detect devices like
these and warn about them so someone will fix it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-07-12 00:14:28 -07:00
Wolfgang Denk
6de27bdc78 net/eth.c: eth_mac_skip() is only needed when CONFIG_NET_MULTI is set
Move it inside the #ifdef CONFIG_NET_MULTI to avoid

	eth.c:64: warning: 'eth_mac_skip' defined but not used

messages from a number of old, non-CONFIG_NET_MULTI boards.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-06-20 22:13:18 -07:00
Fillod Stephane
e397e59e86 ip/defrag: fix processing of last short fragment
TFTP'ing a file of size 1747851 bytes with CONFIG_IP_DEFRAG and
CONFIG_TFTP_BLOCKSIZE set to 4096 fails with a timeout, because
the last fragment is not taken into account. This patch fixes
IP fragments having less than 8 bytes of payload.

Signed-off-by: Stephane Fillod <stephane.fillod@grassvalley.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-06-20 22:11:32 -07:00
Ben Warren
ecee9324d7 Program net device MAC addresses after initializing
Add a new function to the eth_device struct for programming a network
controller's hardware address.

After all network devices have been initialized and the proper MAC address
for each has been determined, make a device driver call to program the
address into the device.  Only device instances with valid unicast addresses
will be programmed.

Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Acked-by: Detlev Zundel <dzu@denx.de>
Tested-by: Prafulla Wadaskar <prafulla@marvell.com>
Tested-by: Heiko Schocher <hs@denx.de>
Tested-by: Thomas Chou <thomas@wytron.com.tw>
2010-05-03 14:52:49 -07:00
Robin Getz
9739946cc5 ./net/net.c - make Microsoft dns servers happy with random_port() numbers
For some reason, (which I can't find any documentation on), if U-Boot
gives a port number higher than 17500 to a Microsoft DNS server, the
server will reply to port 17500, and U-Boot will ignore things (since
that isn't the port it asked the DNS server to reply to).

This fixes that by ensuring the random port number is less than 17500.

Signed-off-by:  Robin Getz <rgetz@blackfin.uclinux.org>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-05-03 14:52:48 -07:00
Detlev Zundel
aba4b69d01 net: Trivial coding style issue with empty for statement
Signed-off-by: Detlev Zundel <dzu@denx.de>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-05-03 14:52:47 -07:00
Wolfgang Denk
c96f86eefc TFTP: allow for adjustable retransmission timout
So far, TFTP negotiated a fixed retransmission timeout of 5 seconds.
In some cases (busy networks, slow TFTP servers) this caused very
slow transfers. A new environment variable "tftptimeout" allows to
set this timeout. Lowering this value may make downloads succeed
faster in networks with high packet loss rates or with unreliable
TFTP servers.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-03-21 22:22:44 +01:00
Dirk Behme
6a45e38495 Make getenv_IPaddr() global
There are boards out there that do not have network support in
U-Boot (CONFIG_CMD_NET not set), but they do so in Linux. This
makes it desirable to be able to port network configuration (like
the IP address) to the Linux kernel.

We should not make the passing of the IP configuration to Linux
dependent on U-Boot features / settings.

For this, make getenv_IPaddr() global. This fixes build error

u-boot/lib_xxx/board.c:360: undefined reference to `getenv_IPaddr'

on various architectures.

Signed-off-by: Dirk Behme <dirk.behme@googlemail.com>
Acked-by: Ben Warren <biggerbadderben@gmail.com>
2010-01-17 20:14:47 +01:00
Remy Bohmer
aafda38fb2 Add error codes/handling for TFTP-server
Signed-off-by: Remy Bohmer <linux@bohmer.net>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2009-12-13 21:31:26 -08:00