Commit Graph

375 Commits

Author SHA1 Message Date
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