summaryrefslogtreecommitdiffstats
path: root/net/eth.c
Commit message (Collapse)AuthorAgeFilesLines
* net: Allow hostnames for global.net.serverSascha Hauer2019-01-041-2/+2
| | | | | | | Additional to IPv4 addresses add support for global.net.server being a hostname. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-091-1/+1
|\
| * drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | | | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: only use ethaddrs registered with device node on that deviceLucas Stach2018-11-081-0/+1
|/ | | | | | | | | | | | | | If an ethaddr is registered with a device node the ethid is set to 0 via the struct initialization. Now if a device without a node (for eaxample a USB network adapter) with ethid 0 looks up the ethaddr it will wrongly get that address assigned, as the ethid matches. Avoid this by setting the ethid to something that no device will ever use when the addr is registered via a device node. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Make use of ETH_ALENAndrey Smirnov2018-08-101-7/+7
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add linuxdevname propertySascha Hauer2017-12-151-0/+2
| | | | | | | | | | | | | | | | | When you have a static network environment but more than one network device on your machine it is necessary to provide the <device> parameter to the ip parameter at kernel cmd line. The device name assigned by Linux cannot in general be predicted as it depends on driver bind order. This patch introduces a new property linux.devname to eth devices. The value is added to bootargs per interface and can be changed in env/network/INTF Based on patch by Gavin Schenk <g.schenk@eckelmann.de>. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Provide new way to configure network devicesSascha Hauer2017-12-141-0/+15
| | | | | | | | | | | | | | | | | | | This provides a new way to configure network interfaces based on nvvars. A network interface can now be configured with variables in the nv.dev.<ethname>.* namespace. There is a new network device parameter "mode" which specifies the mode used to obtain IP settings. The mode can be "dhcp", "static" or "disabled": nv.dev.eth0.mode=dhcp (ipaddr, netmask are ignored in this setting) nv.dev.eth0.mode=static nv.dev.eth0.ipaddr=192.168.0.17 nv.dev.eth0.netmask=255.255.0.0 nv.dev.eth0.mode=disabled Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: remove "current" network deviceSascha Hauer2017-12-141-17/+0
| | | | | | | Now that we can do routing we no longer need a "current" network device. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Use a single gatewaySascha Hauer2017-12-011-1/+2
| | | | | | | | | | | | | | There is not much point in having a network device specific gateway. If barebox really is part of such a complicated network in which it needs multiple gateways, then we probably need a real routing table. Until this happens, a single gateway should be enough. This introduces global.net.gateway which holds the gateway ip. The previously used device specific <ethx>.gateway variables still exist, but are only aliases for the single gateway. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: introduce global.net.serverSascha Hauer2017-12-011-1/+3
| | | | | | | | | | | | The server to use is independent of the network device, there is not much point to make the server specific to a network device. This introduces global.net.server as the serverip which is used as standard NFS/tftp server. The previously used eth device specific parameters still exist, but are only aliases for the global single variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: add linux.bootarg parameter from ifup callEnrico Jorns2016-09-221-0/+2
| | | | | | | | | | | | | This sets a `ip=dhcp` or `ip=<clientip>:<serverip>:<gatewayip>:<netmaskip>::<iface>:` bootarg for the network device upon execution of 'ifup'. This is the only point where we can distinguish between a static ip and a dhcp-based network setup and thus set a valid bootarg options as it will be required for nfs boot, for example. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: add name to struct eth_deviceSascha Hauer2016-07-141-5/+7
| | | | | | | | | Using dev_name often is not a good idea since it's a statically allocated string which gets overwritten by later calls to dev_name. Add a devname string to struct eth_device to have the name available for later use. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: introduce for_each_netdev iteratorSascha Hauer2016-07-141-7/+7
| | | | | | | | for_each_netdev is nicer to read. Also export the list of network devices since it will be used by code outside of net/eth.c in later patches. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: open correct edev in eth_check_openSascha Hauer2016-07-141-1/+1
| | | | | | | | eth_check_open gets the network device to check as parameter, so use it rather than using eth_current. Currently both are the same, so this currently does not fix anything. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Remove ethaddr_paramJan Remmet2015-11-201-2/+2
| | | | | | | | commit d00db554 introduce ethaddr_param. But it is not initialized, so devinfo fails to show the mac. Remove it and use edev->ethaddr. Signed-off-by: Jan Remmet <j.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Fixup OF tree with registered MAC addresses tooTrent Piepho2015-10-221-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | The eth code registers an OF tree fixup that looks for any nodes in the Linux oftree that match eth devices loaded in barebox and sets the mac-address property in those nodes. The purpose is to pass MAC addresses to the Linux kernel for drivers that expect the MAC address to be in the device tree. If barebox does not have a driver for the network device, either because it has been disabled or because one does not exist, then the OF tree will not be fixed up to include a MAC address. The eth code also has a list of MAC addresses which board code has registered, usually done when it reads the address from an EEPROM or on-chip memory. If an eth device is created later in the boot, it will look here for an address. The registered MAC address list is not used for the OF tree fix up, and this patch changes that. This way barebox can place a MAC address in the device-tree without needing a driver for the network device. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Refactor OF tree fixup of one node into new functionTrent Piepho2015-10-221-28/+34
| | | | | | | | Code that fixes up one node with a new MAC address is refactored into a new function that eth_of_fixup() calls in a loop. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net'Sascha Hauer2015-08-061-0/+8
|\
| * net: make eth_register_ethaddr work on registered network devicesSascha Hauer2015-07-281-0/+8
| | | | | | | | | | | | | | When eth_register_ethaddr is called after the device has been registered it should work aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: eth_send: Allow to use multiple network interfaces at onceAntony Pavlov2015-07-231-1/+1
|/ | | | | | | | | | | | | | | | | | | | The commit commit be0404c21f22da2d736168b2e56a9ae583cc3e95 Author: Sascha Hauer <s.hauer@pengutronix.de> Date: Wed May 14 16:08:04 2014 +0200 net: Allow to use multiple network interfaces at once changes the eth_send() function: - return eth_current->send(eth_current, packet, length); + return edev->send(eth_current, packet, length); But we have to change the both eth_current occurrences to edev here! Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Do not rely on CONFIG_PARAMETER to be enabledSascha Hauer2015-06-261-8/+19
| | | | | | | | | register_preset_mac_address only works when CONFIG_PARAMETER is enabled because otherwise dev_set_param is a no-op. Add a function to set the MAC address explicitly without the need of CONFIG_PARAMETER and use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* eth: halt active ethernet device on unregisterSascha Hauer2015-04-281-0/+3
| | | | | | | When an active ethernet device is unregistered it should be halted to quiesce the device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Call edev->recv with correct eth_deviceSascha Hauer2014-09-171-1/+1
| | | | | | | | edev->recv has to be called with edev as argument, not eth_current. This fixes networking when multiple network devices are used and the current one is switched during runtime. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: take eth id from devicetree aliasSascha Hauer2014-05-151-2/+11
| | | | | | | If the devicetree has an alias for the ethernet device, then use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Allow to use multiple network interfaces at onceSascha Hauer2014-05-151-27/+31
| | | | | | | | | | | | | | | | In barebox network packets always go out at the current ethernet device and are expected to be received from the current interface. This has some side effects. When for example an NFS is mounted when one interface is active and the interface is changed afterwards the NFS packets leave the new interface, but the NFS server won't be reachable there. Instead of changing the whole network traffic to the current ethernet interface we now initialize a network connection with the current network interface, but then the connection will continue to use that interface even when the current interface is changed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add dev_add_param_macSascha Hauer2014-04-041-11/+3
| | | | | | | This adds a convenience function to register a MAC address device parameter. The only current user is converted to use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/nfs'Sascha Hauer2014-03-071-1/+1
|\ | | | | | | | | Conflicts: defaultenv/defaultenv-2-base/bin/ifup
| * net: constify eth_get_byname argumentSascha Hauer2014-03-071-1/+1
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd'Sascha Hauer2014-03-071-2/+0
|\ \ | | | | | | | | | | | | | | | Conflicts: drivers/mtd/core.c net/eth.c
| * | device: remove parameters when unregistering a deviceSascha Hauer2014-02-131-2/+0
| |/ | | | | | | | | | | | | | | Otherwise we loose memory on each device_unregister. The ethernet code used to do this before calling unregister_device. This can now be removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / remove redundant NULL check on freeLucas Stach2014-02-101-1/+1
|/ | | | | | | | free() already checks the pointer to be non NULL. No need to do it again. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Add missing includesSascha Hauer2013-11-081-0/+1
| | | | | | | | A lot of files rely on include/driver.h including include/of.h (and this including include/errno.h. include the files explicitly so we can eventually get rid of including of.h from driver.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add a context pointer to fixup functionsSascha Hauer2013-11-061-2/+2
| | | | | | | If drivers want to fixup their specific instance they need some context to know which instance they have to fixup. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net, of: fixup MAC address by aliasRenaud Barbier2013-09-051-10/+12
| | | | | | | | | If a network device has not been registered from the devicetree, we may still find it by its alias in the devicetree. This way also platform based network devices can obtain a valid MAC address in the devicetree. Signed-off-by: Renaud Barbier <renaud.barbier@ge.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: net: Use correct devicetree in eth_of_fixupSascha Hauer2013-07-271-1/+1
| | | | | | | | eth_of_fixup() is passed a devicetree, so use this one instead of the internal devicetree. This makes sure it also works when the tree to fixup is not the internal one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next-manual/oftree-linux-sync'Sascha Hauer2013-07-021-1/+1
|\
* | net: Set mac-address propertySascha Hauer2013-06-051-0/+54
|/ | | | | | | | | | Linux normally has no idea how to retrieve MAC Addresses, but instead expects the MAC address in the devicetree. This patch adds the MAC address to the devicetree for Linux if we find a valid one in barebox. This mechanism is limited of course to devices barebox has a driver for and which are probed themselves from the devicetree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add of_register_ethaddrSascha Hauer2013-05-211-12/+56
| | | | | | | | | | | | We already have a possibility to register a MAC address provider based on a ethernet device id. This adds a similar functionality for devices probed from devicetree. Code can register itself to be a MAC address provider for a certain devicetree node. This helps on i.MX to let the IIM unit provide a MAC address for the FEC. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: store ethernet device parameters in deviceSascha Hauer2013-04-111-33/+7
| | | | | | | | Rather than storing the parameters globally and trying to keep them in sync with the device parameters, store the parameters in the ethernet device directly. Also, update to dev_add_param_ip(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'pu/net-link'Sascha Hauer2012-12-131-0/+3
|\
| * net phylib: force to wait for linkSascha Hauer2012-12-121-0/+3
| | | | | | | | | | | | | | | | When starting a network device wait until the link is up. Otherwise autobooting does not work with little timeout and several attempts have to be made until the network is finally up. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers/base: fix corrupt device treeSascha Hauer2012-12-121-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_add_child is a very unsafe function. If called multiple times it allows setting the same device to different parents thus corrupting the siblings list. This happens regularly since: | commit c2e568d19c5c34a05a1002d25280bf113b72b752 | Author: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | Date: Sat Nov 3 16:11:05 2012 +0100 | | bus: add bus device | | automatically add it as parent of any bus device if none already specified | | we have now a nice output per bus If for example a FATfs is mounted this nice output per bus often ends with: > `---- fat0 > `---- 0 > `---- 0x86f0000087020031-0x86f000410df27124: /dev/<NULL> > `---- sram00 > `---- 0x00000000-0xffffffffffffffff: /dev/<NULL> > `---- 0x00000000-0xffffffffffffffff: /dev/<NULL> > unable to handle NULL pointer dereference at address 0x0000000c > pc : [<87f08a20>] lr : [<87f08a04>] > sp : 86eff8c0 ip : 87f3fbde fp : ffffffff > r10: ffffffff r9 : 00000000 r8 : 00000003 > r7 : 86f075b8 r6 : 00000002 r5 : ffffffec r4 : 86f07544 > r3 : 00000000 r2 : 43f900b4 r1 : 00000020 r0 : 00000005 > Flags: Nzcv IRQs off FIQs off Mode SVC_32 > [<87f08a20>] (do_devinfo_subtree+0x90/0x130) from [<87f08a90>] (do_devinfo_subtree+0x100/0x130) > > [<87f3e070>] (unwind_backtrace+0x0/0x90) from [<87f28514>] (panic+0x28/0x3c) > [<87f28514>] (panic+0x28/0x3c) from [<87f3e4b8>] (do_exception+0x10/0x14) > [<87f3e4b8>] (do_exception+0x10/0x14) from [<87f3e544>] (do_data_abort+0x2c/0x38) > [<87f3e544>] (do_data_abort+0x2c/0x38) from [<87f3e268>] (data_abort+0x48/0x60) This patch fixes this by adding a device to its parents children list in register_device so that dev_add_child is no longer needed. This function is removed from the tree. Now callers of register_device have to clearly set the parent *before* registering a device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Jan Lübbe <jlu@pengutronix.de>
* net phylib: Call phy_update_status when no link is presentSascha Hauer2012-12-081-1/+2
| | | | | | | | | | | | We call phy_update_status only once in 5 seconds. This makes sure we do not have great overhead when using ethernet devices. However, if phylib tells us the link is down anyway, there won't be ethernet transfers, so it doesn't hurt to call phy_update_status in this case. This makes sure we can use the ethernet device when the link comes up and do not have an additional 5 second penalty in this case. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2012-11-161-1/+1
|\ | | | | | | | | | | | | Conflicts: commands/Makefile Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * eth: register device a pure deviceJean-Christophe PLAGNIOL-VILLARD2012-11-121-1/+1
| | | | | | | | | | | | | | as we do not need to probe them and they have no driver or bus attached Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net eth: make edev->init optionalSascha Hauer2012-10-301-1/+2
|/ | | | | | | | | | edev->init is called at eth_register time unconditionally and is supposed to initialize the ethernet hardware. Since it's called unconditionally this could be done by the driver without having an additional hook. Some drivers need their initialization done earlier since they also register a mdiobus which does hardware accesses on registration time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* switch all platform_bus device/driver registering to ↵Jean-Christophe PLAGNIOL-VILLARD2012-10-041-1/+1
| | | | | | | | platform_driver/device_register now register_driver and register_device are for bus only usage. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* Merge branch 'for-next/remove-fsf-address'Sascha Hauer2012-10-031-4/+0
|\ | | | | | | | | | | Conflicts: drivers/net/miidev.c include/miidev.h
| * Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | | | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/eth: fix link handlingSascha Hauer2012-09-271-18/+57
| | | | | | | | | | | | | | Check link status on eth device open time and then periodically every 5 seconds. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>