summaryrefslogtreecommitdiffstats
path: root/net/eth.c
Commit message (Collapse)AuthorAgeFilesLines
* net: Handle ethaddr changes as an env callbackJoe Hershberger2015-05-211-43/+60
| | | | | | | | | | | When the ethaddr is changed in the env, update the device pdata at the same time (only if it is probed for the DM case; only if registered for the non-DM case). Again this gets us closer to completely non-polled env needed to simplify the net_loop. This requires that the NET feature select the REGEX feature. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Remove duplicate bootfile syncing functionalityJoe Hershberger2015-05-211-12/+0
| | | | | | | The bootfile env var is already kept up to date by the callback in net.c so there is no need to poll it too. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Implement random ethaddr fallback in eth.cJoe Hershberger2015-05-191-0/+12
| | | | | | | | | Implement the random ethaddr fallback in eth.c so it is in a common place and not reimplemented in each board or driver that wants this behavior. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* net: Update hardware MAC address if it changes in envJoe Hershberger2015-05-191-28/+48
| | | | | | | | | | | | When the ethaddr changes in the env, the hardware should also be updated so that MAC filtering will work properly without resetting U-Boot. Also remove the manual calls to set the hwaddr that was included in a few drivers as a result of the framework not doing it. Reported-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Tested-by: Michal Simek <michal.simek@xilinx.com>
* dm: net: Use existing Ethernet init for driver modelSimon Glass2015-04-181-37/+42
| | | | | | | | | | | | | At present even with driver model is used there is still much manual init of related devices: PHY, environment and board init. Until these requirements are dealt with in another way we need to keep them around. Break out the init portion of the legacy eth_initialize() into a separate function and call it from both the legacy and driver model eth_initialize() functions. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Fix checkpatch.pl failures in net.cJoe Hershberger2015-04-181-1/+1
| | | | | | | Finish eliminating CamelCase from net.c and other failures Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Fix checkpatch.pl failures in eth.cJoe Hershberger2015-04-181-10/+16
| | | | | | | | There were still a few failures in net/eth.c, especially in the legacy part of the code. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Name ethaddr variables consistentlyJoe Hershberger2015-04-181-11/+11
| | | | | | | | Use "_ethaddr" at the end of variables and drop CamelCase. Make constant values actually 'const'. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* 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>
OpenPOWER on IntegriCloud