summaryrefslogtreecommitdiffstats
path: root/net/eth.c
Commit message (Collapse)AuthorAgeFilesLines
* net: cosmetic: Fixup var names related to boot fileJoe Hershberger2015-04-181-1/+2
| | | | | | | | The variables around the bootfile were inconsistent and used CamelCase. Update them to make the code more readable. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Change IPaddr_t to struct in_addrJoe Hershberger2015-04-181-4/+4
| | | | | | | | | 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>
* dm: eth: Provide a way for drivers to manage packet buffersJoe Hershberger2015-04-181-1/+3
| | | | | | | | | | | | Some drivers need a chance to manage their receive buffers after the packet has been handled by the network stack. Add an operation that will allow the driver to be called in that case. Reported-by: Simon Glass <sjg@chromium.org> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Tested-on: pcduino3
* net: Improve error handlingJoe Hershberger2015-04-181-8/+48
| | | | | | | | | | | | Take a pass at plumbing errors through to the users of the network stack Currently only the start() function errors will be returned from NetLoop(). recv() tends not to have errors, so that is likely not worth adding. send() certainly can return errors, but this patch does not attempt to plumb them yet. halt() is not expected to error. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: eth: Add support for ethprime env varJoe Hershberger2015-04-181-1/+28
| | | | | | | | The ethprime env var is used to indicate the starting device if none is specified in ethact. Also support aliases specified in the ethprime var. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: eth: Add support for aliasesJoe Hershberger2015-04-181-9/+41
| | | | | | | | | | Allow network devices to be referred to as "eth0" instead of "eth@12345678" when specified in ethact. Add tests to verify this behavior. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: eth: Pass the packet pointer as a parameter to recvJoe Hershberger2015-04-181-1/+14
| | | | | | | | | | Stop forcing drivers to call net_process_received_packet() - formerly called NetReceive(). Now the uclass will handle calling the driver for each packet until the driver errors or has nothing to return. The uclass will then pass the good packets off to the network stack by calling net_process_received_packet(). Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* dm: eth: Add basic driver model support to Ethernet stackJoe Hershberger2015-04-181-6/+340
| | | | | | | First just add support for MAC drivers. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* net: Remove the bd* parameter from net stack functionsJoe Hershberger2015-04-181-5/+7
| | | | | | | | | | | | | This value is not used by the network stack and is available in the global data, so stop passing it around. For the one legacy function that still expects it (init op on old Ethernet drivers) pass in the global pointer version directly to avoid changing that interface. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reported-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> (Trival fix to remove an unneeded variable declaration in 4xx_enet.c)
* net: Use int instead of u8 for boolean flagJoe Hershberger2015-04-181-1/+1
| | | | | | | | On some archs masking the parameter is inefficient, so don't use u8. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reported-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* net: Change return codes from net/eth.c to use errorno constantsJoe Hershberger2015-04-181-6/+6
| | | | | | | | | Many functions returned -1 previously. Change them to return appropriate error codes. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reported-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* net: Refactor in preparation for driver modelJoe Hershberger2015-04-181-36/+43
| | | | | | | | Move some things around and organize things so that the driver model implementation will fit in more easily. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* net: Rename helper function to be more clearJoe Hershberger2015-04-181-9/+4
| | | | | | | Make it clear that the helper is checking the addr, not setting it. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* eth: make eth_address_set staticJeroen Hofstee2014-10-251-1/+1
| | | | Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
* Ethernet: let user know if there is no valid ethernet addressPavel Machek2014-07-221-8/+21
| | | | | | Improve error messages in case of invalid/unset ethernet addresses. Signed-off-by: Pavel Machek <pavel@denx.de>
* net: rename and refactor eth_rand_ethaddr() functionMasahiro Yamada2014-05-121-22/+0
| | | | | | | | | | | | | | | | | | | | Some functions in include/net.h are ported from include/linux/etherdevice.h of Linux Kernel. For ex. is_zero_ether_addr() is_multicast_ether_addr() is_broadcast_ether_addr() is_valid_ether_addr(); So, we should use the same function name as that of Linux Kernel, eth_rand_addr(), for consistency. Besides, eth_rand_addr() has been implemented as an inline function. So it should not be surrounded by #ifdef CONFIG_RANDOM_MACADDR. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* net: execute "miiphy_init" if CONFIG_PHYLIB definedAlexey Brodkin2014-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | In "common/Makefile" "miiphyutil.o" gets built if any of the following items enabled: * CONFIG_PHYLIB * CONFIG_MII * CONFIG_CMD_MII So it's possible to not define CONFIG_MII or CONFIG_CMD_MII and still use functions like "miiphy_get_dev_by_name". In its turn "miiphy_get_dev_by_name" traverses "mii_devs" list which is not initialized because "miiphy_init" never got called. Cc: Rob Herring <rob.herring@calxeda.com> Cc: Simon Glass <sjg@chromium.org> Cc: Wolfgang Denk <wd@denx.de> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-241-17/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* net: eth_write_hwaddr: Return error for invalid MACsBenoît Thébaudeau2012-09-271-2/+5
| | | | | | | | | If dev->enetaddr was supposed to be set with dev->write_hwaddr() but the MAC address was not valid, return an error. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> Cc: Joe Hershberger <joe.hershberger@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: Improve the speed of netconsoleJoe Hershberger2012-09-241-6/+2
| | | | | | | | | | | | | | | | | | | 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>
* api: net: fix length check in eth_receive()Michael Walle2012-09-241-4/+1
| | | | | | | | | | | | | | | 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>
* net: Inline the new eth_setenv_enetaddr_by_index functionJoe Hershberger2012-07-111-1/+1
| | | | | | This function is currently only used in one case. Inline for now. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: allow setting env enetaddr from net device settingRob Herring2012-07-111-0/+14
| | | | | | | | | | 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>
* net: add helper to generate random mac addressMichael Walle2012-07-071-0/+22
| | | | | | | | 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>
* net: move bootfile init into eth_initializeMike Frysinger2012-05-151-0/+10
| | | | | | | | 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>
* net: cosmetic: eth.c checkpatch complianceJoe Hershberger2012-05-151-35/+32
| | | | | Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Remove volatile from net APIJoe Hershberger2012-05-151-7/+5
| | | | | Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net/eth.c: fix eth_write_hwaddr() to use dev->enetaddr as fall backEric Miao2012-04-031-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 7616e7850804c7c69e0a22c179dfcba9e8f3f587. 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>
* bootstage: Replace show_boot_progress/error() with bootstage_...()Simon Glass2012-03-181-3/+3
| | | | | | | 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>
* bootstage: Convert net progress numbers to enumsSimon Glass2012-03-181-3/+3
| | | | | | | This changes over the network-related progress numbers to use enums from bootstage.h. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootstage: Use show_boot_error() for -ve progress numbersSimon Glass2012-03-181-1/+1
| | | | | | | | 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>
* net/miiphy/serial: drop duplicate "NAMESIZE" defineMike Frysinger2012-03-181-1/+1
| | | | | | | | | | 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>
* PPC: Drop mv6446x_eth_initialize() from net/eth.cMarek Vasut2012-03-061-5/+0
| | | | | | | | 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>
* PPC: Drop mv6436x_eth_initialize() from net/eth.cMarek Vasut2012-03-061-4/+0
| | | | | | | | 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>
* eth: remove usb-ethernet devices before re-enumerating themVincent Palatin2012-03-031-0/+29
| | | | | | | | 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>
* net: introduce per device indexMichael Walle2011-12-201-29/+12
| | | | | | | | | | | | | | | | 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>
* net: drop !NET_MULTI codeMike Frysinger2011-10-051-38/+11
| | | | | | | | | | | 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>
* net: drop !NET_MULTI ns7520 driverMike Frysinger2011-10-051-4/+0
| | | | | | | 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>
* net: Add \n before warning message so it prints on a new line.Philip Balister2011-10-011-1/+1
| | | | Signed-off-by: Philip Balister <philip@opensdr.com>
* net: turn name len check into an assertMike Frysinger2011-09-211-6/+1
| | | | | | | | | 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>
* net/eth.c: throw BUG for eth_get_dev_by_name(NULL)Helmut Raiger2011-09-091-0/+2
| | | | | | | | 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>
* Correct call to eth_write_hwaddr()Simon Glass2011-09-051-1/+1
| | | | | | | | | | | | | | 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>
* net: Check network device driver nameMichal Simek2011-09-041-0/+8
| | | | | | | | | | | | | | | 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>
* Add Ethernet hardware MAC address framework to usbnetSimon Glass2011-08-081-25/+39
| | | | | | | | | | | | 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>
* net/eth.c: drop obsolete at91rm9200 supportAndreas Bießmann2011-08-031-4/+0
| | | | | | | | | 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>
* Create PHY Lib for U-BootAndy Fleming2011-04-201-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix compile warning in net/eth.cRemy Bohmer2011-02-191-1/+1
| | | | Signed-off-by: Remy Bohmer <linux@bohmer.net>
* Add USB host ethernet adapter supportSimon Glass2011-02-191-19/+22
| | | | | | | | | | | | 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>
* Net: clarify board/cpu_eth_init callsBen Warren2010-11-151-4/+12
| | | | | | | | | | | 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>
* Net: Remove redundant CONFIG_NET_MULTI directivesBen Warren2010-10-111-12/+4
| | | | | | All are within an #ifdef CONFIG_NET_MULTI block already Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
OpenPOWER on IntegriCloud