aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe/netdevice.h
AgeCommit message (Collapse)AuthorFilesLines
2023-09-13[netdevice] Allocate private data for each network upper-layer driverMichael Brown1-3/+10
Allow network upper-layer drivers (such as LLDP, which attaches to each network device in order to provide a corresponding LLDP settings block) to specify a size for private data, which will be allocated as part of the network device structure (as with the existing private data allocated for the underlying device driver). This will allow network upper-layer drivers to be simplified by omitting memory allocation and freeing code. If the upper-layer driver requires a reference counter (e.g. for interface initialisation), then it may use the network device's existing reference counter, since this is now the reference counter for the containing block of memory. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-09-13[netdevice] Remove netdev_priv() helper functionMichael Brown1-11/+0
Some network device drivers use the trivial netdev_priv() helper function while others use the netdev->priv pointer directly. Standardise on direct use of netdev->priv, in order to free up the function name netdev_priv() for reuse. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-15[netdevice] Allow duplicate MAC addressesMichael Brown1-2/+0
Many laptops now include the ability to specify a "system-specific MAC address" (also known as "pass-through MAC"), which is supposed to be used for both the onboard NIC and for any attached docking station or other USB NIC. This is intended to simplify interoperability with software or hardware that relies on a MAC address to recognise an individual machine: for example, a deployment server may associate the MAC address with a particular operating system image to be deployed. This therefore creates legitimate situations in which duplicate MAC addresses may exist within the same system. As described in commit 98d09a1 ("[netdevice] Avoid registering duplicate network devices"), the Xen netfront driver relies on the rejection of duplicate MAC addresses in order to inhibit registration of the emulated PCI devices that a Xen PV-HVM guest will create to shadow each of the paravirtual network devices. Move the code that rejects duplicate MAC addresses from the network device core to the Xen netfront driver, to allow for the existence of duplicate MAC addresses in non-Xen setups. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-14[netdevice] Separate concept of scope ID from network device name indexMichael Brown1-3/+3
The network device index currently serves two purposes: acting as a sequential index for network device names ("net0", "net1", etc), and acting as an opaque unique integer identifier used in socket address scope IDs. There is no particular need for these usages to be linked, and it can lead to situations in which devices are named unexpectedly. For example: if a system has two network devices "net0" and "net1", a VLAN is created as "net1-42", and then a USB NIC is connected, then the USB NIC will be named "net3" rather than the expected "net2" since the VLAN device "net1-42" will have consumed an index. Separate the usages: rename the "index" field to "scope_id" (matching its one and only use case), and assign the name without reference to the scope ID by finding the first unused name. For consistency, assign the scope ID by similarly finding the first unused scope ID. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-10[netdevice] Ensure driver transmit() and poll() will not be re-enteredMichael Brown1-0/+6
When CONSOLE_SYSLOG is used, a DBG() from within a network device driver may cause its transmit() or poll() methods to be unexpectedly re-entered. Since these methods are not intended to be re-entrant, this can lead to undefined behaviour. Add an explicit re-entrancy guard to both methods. Note that this must operate at a per-netdevice level, since there are legitimate circumstances under which the netdev_tx() or netdev_poll() functions may be re-entered (e.g. when using VLAN devices). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-11-28[dma] Move I/O buffer DMA operations to iobuf.hMichael Brown1-0/+6
Include a potential DMA mapping within the definition of an I/O buffer, and move all I/O buffer DMA mapping functions from dma.h to iobuf.h. This avoids the need for drivers to maintain a separate list of DMA mappings for each I/O buffer that they may handle. Network device drivers typically do not keep track of transmit I/O buffers, since the network device core already maintains a transmit queue. Drivers will typically call netdev_tx_complete_next() to complete a transmission without first obtaining the relevant I/O buffer pointer (and will rely on the network device core automatically cancelling any pending transmissions when the device is closed). To allow this driver design approach to be retained, update the netdev_tx_complete() family of functions to automatically perform the DMA unmapping operation if required. For symmetry, also update the netdev_rx() family of functions to behave the same way. As a further convenience for drivers, allow the network device core to automatically perform DMA mapping on the transmit datapath before calling the driver's transmit() method. This avoids the need to introduce a mapping error handling code path into the typically error-free transmit methods. With these changes, the modifications required to update a typical network device driver to use the new DMA API are fairly minimal: - Allocate and free descriptor rings and similar coherent structures using dma_alloc()/dma_free() rather than malloc_phys()/free_phys() - Allocate and free receive buffers using alloc_rx_iob()/free_rx_iob() rather than alloc_iob()/free_iob() - Calculate DMA addresses using dma() or iob_dma() rather than virt_to_bus() - Set a 64-bit DMA mask if needed using dma_set_mask_64bit() and thereafter eliminate checks on DMA address ranges - Either record the DMA device in netdev->dma, or call iob_map_tx() as part of the transmit() method - Ensure that debug messages use virt_to_phys() when displaying "hardware" addresses Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-01-25[netdevice] Limit MTU by hardware maximum frame lengthMichael Brown1-1/+8
Separate out the concept of "hardware maximum supported frame length" and "configured link MTU", and limit the latter according to the former. In networks where the DHCP-supplied link MTU is inconsistent with the hardware or driver capabilities (e.g. a network using jumbo frames), this will result in iPXE advertising a TCP MSS consistent with a size that can actually be received. Note that the term "MTU" is typically used to refer to the maximum length excluding the link-layer headers; we adopt this usage. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28[netdevice] Allow network devices to disclaim IRQ support at runtimeMichael Brown1-1/+10
VLAN and 802.11 devices use a network device operations structure that wraps an underlying structure. For example, the vlan_operations structure wraps the network device operations structure of the underlying trunk device. This can cause false positives from the current implementation of netdev_irq_supported(), which will always report that VLAN devices support interrupts since it has no visibility into the support provided by the underlying trunk device. Fix by allowing network devices to explicitly flag that interrupts are not supported, despite the presence of an irq() method. Originally-fixed-by: Wissam Shoukair <wissams@mellanox.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-25[netdevice] Add a generic concept of a "blocked link"Michael Brown1-0/+17
When Spanning Tree Protocol (STP) is used, there may be a substantial delay (tens of seconds) from the time that the link goes up to the time that the port starts forwarding packets. Add a generic concept of a "blocked link" (i.e. a link which is up but which is not expected to communicate successfully), and allow "ifstat" to indicate when a link is blocked. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02[legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown1-1/+1
These files cannot be automatically relicensed by util/relicense.pl since they either contain unusual but trivial contributions (such as the addition of __nonnull function attributes), or contain lines dating back to the initial git revision (and so require manual knowledge of the code's origin). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-18[rndis] Add generic RNDIS device abstractionMichael Brown1-6/+5
RNDIS provides an abstraction of a network device on top of a generic packet transmission mechanism. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-30[netdevice] Avoid registering duplicate network devicesMichael Brown1-0/+2
Reject network devices which appear to be duplicates of those already available via a different underlying hardware device. On a Xen PV-HVM system, this allows us to filter out the emulated PCI NICs (which would otherwise appear alongside the netfront NICs). Note that we cannot use the Xen facility to "unplug" the emulated PCI NICs, since there is no guarantee that the OS we subsequently load will have a native netfront driver. We permit devices with the same MAC address if they are attached to the same underlying hardware device (e.g. VLAN devices). Inspired-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-14[netdevice] Notify upper-layer drivers when RX processing is (un)frozenMichael Brown1-20/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05[netdevice] Add generic concept of a network device configuratorMichael Brown1-0/+79
iPXE supports multiple mechanisms for network device configuration: DHCPv4 for IPv4, FIP for FCoE, and SLAAC for IPv6. At present, DHCPv4 requires an explicit action (e.g. a "dhcp" command), FIP is initiated implicitly upon opening a network device, and SLAAC takes place whenever a RA happens to be received. Add a generic concept of a network device configurator, which provides a common interface to triggering configuration and to reporting the result of the configuration process. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-10-21[ipv6] Add IPv6 socket address converterMichael Brown1-1/+4
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-10-21[netdevice] Add find_netdev_by_index()Michael Brown1-0/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-09-03[netdevice] Add method for generating EUI-64 address from link-layer addressMichael Brown1-0/+9
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-09-03[netdevice] Add concept of a network device indexMichael Brown1-0/+2
IPv6 link-local socket addresses require some way to specify a local network device. We cannot simply use a pointer to the network device, since a struct sockaddr_in6 may be long-lived and has no way to hold a reference to the network device. Using a network device index allows a socket address to cleanly refer to a network device without worrying about whether or not that device continues to exist. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-09-03[netdevice] Increase maximum network-layer address lengthMichael Brown1-1/+1
IPv6 uses 16-byte network-layer addresses. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-05-01[settings] Eliminate settings "tag magic"Michael Brown1-32/+0
Create an explicit concept of "settings scope" and eliminate the magic values used for numerical setting tags. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-05-01[netdevice] Add netdev_tx_defer() to allow drivers to defer transmissionsMichael Brown1-0/+4
Devices with small transmit descriptor rings may temporarily run out of space. Provide netdev_tx_defer() to allow drivers to defer packets for retransmission as soon as a descriptor becomes available. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-31[ipoib] Expose Ethernet-compatible eIPoIB link-layer addresses and headersMichael Brown1-0/+9
Almost all clients of the raw-packet interfaces (UNDI and SNP) can handle only Ethernet link layers. Expose an Ethernet-compatible link layer to local clients, while remaining compatible with IPoIB on the wire. This requires manipulation of ARP (but not DHCP) packets within the IPoIB driver. This is ugly, but it's the only viable way to allow IPoIB devices to be driven via the raw-packet interfaces. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-07-15[netdevice] Allow link layer to report broadcast/multicast packets via pull()Michael Brown1-9/+19
Allow the link layer to directly report whether or not a packet is multicast or broadcast at the time of calling pull(), rather than relying on heuristics to determine this at a later stage. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-06-28[netdevice] Allow non-completion TX errors to be recordedMichael Brown1-0/+2
Allow TX errors to be recorded against a network device even when the packet didn't make it as far as netdev_tx(). Inspired-by: Dominik Russenberger <dominik.russenberger@terreactive.ch> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22[settings] Formalise notion of setting applicabilityMichael Brown1-0/+32
Expose a function setting_applies() to allow a caller to determine whether or not a particular setting is applicable to a particular settings block. Restrict DHCP-backed settings blocks to accepting only DHCP-based settings. Restrict network device settings blocks to accepting only DHCP-based settings and network device-specific settings such as "mac". Inspired-by: Glenn Brown <glenn@myri.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-01-25[netdevice] Allow devices to indicate that interrupts are not supportedMichael Brown1-0/+14
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-01[settings] Apply settings block name in register_settings()Michael Brown1-2/+1
Pass the settings block name as a parameter to register_settings(), rather than defining it with settings_init() (and then possibly changing it by directly manipulating settings->name). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-20[vlan] Add support for IEEE 802.1Q VLANsMichael Brown1-5/+6
Originally-implemented-by: michael-dev@fami-braun.de Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-20[netdevice] Allow per-device receive queue processing to be frozenMichael Brown1-2/+37
Several use cases (e.g. the UNDI API and the EFI SNP API) require access to the raw network device receive queue, and so currently use manual calls to netdev_poll() on a specific network device in order to prevent received packets from being processed by the network stack. As an alternative, provide a flag that allows receive queue processing to be frozen on a per-device basis. When receive queue processing is frozen, packets will be enqueued as normal, but will not be automatically dequeued and passed up the network stack. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-19[netdevice] Add MAX_NET_HEADER_LEN and MAX_LL_NET_HEADER_LENMichael Brown1-0/+10
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-10-07[netdevice] Pass both link-layer addresses in net_tx() and net_rx()Michael Brown1-3/+6
FCoE requires the use of fabric-provided MAC addresses, which breaks the assumption that the net device's MAC address is implicitly the source address for net_tx() and the (unicast) destination address for net_rx(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-05[netdevice] Add the concept of a network upper-layer driverMichael Brown1-21/+39
Add the concept of a network upper-layer driver, which can create arbitrary devices on top of network devices. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-19[build] Rename gPXE to iPXEMichael Brown1-0/+557
Access to the gpxe.org and etherboot.org domains and associated resources has been revoked by the registrant of the domain. Work around this problem by renaming project from gPXE to iPXE, and updating URLs to match. Also update README, LOG and COPYRIGHTS to remove obsolete information. Signed-off-by: Michael Brown <mcb30@ipxe.org>