iPXE
|
Virtual LANs. More...
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/features.h>
#include <ipxe/if_ether.h>
#include <ipxe/ethernet.h>
#include <ipxe/netdevice.h>
#include <ipxe/iobuf.h>
#include <ipxe/vlan.h>
Go to the source code of this file.
Data Structures | |
struct | vlan_device |
VLAN device private data. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
FEATURE (FEATURE_PROTOCOL, "VLAN", DHCP_EB_FEATURE_VLAN, 1) | |
static int | vlan_open (struct net_device *netdev) |
Open VLAN device. More... | |
static void | vlan_close (struct net_device *netdev) |
Close VLAN device. More... | |
static int | vlan_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet on VLAN device. More... | |
static void | vlan_poll (struct net_device *netdev) |
Poll VLAN device. More... | |
static void | vlan_irq (struct net_device *netdev, int enable) |
Enable/disable interrupts on VLAN device. More... | |
static void | vlan_sync (struct net_device *netdev) |
Synchronise VLAN device. More... | |
struct net_device * | vlan_find (struct net_device *trunk, unsigned int tag) |
Identify VLAN device. More... | |
static int | vlan_rx (struct io_buffer *iobuf, struct net_device *trunk, const void *ll_dest, const void *ll_source, unsigned int flags __unused) |
Process incoming VLAN packet. More... | |
unsigned int | vlan_tci (struct net_device *netdev) |
Get the VLAN tag control information. More... | |
int | vlan_can_be_trunk (struct net_device *trunk) |
Check if network device can be used as a VLAN trunk device. More... | |
int | vlan_create (struct net_device *trunk, unsigned int tag, unsigned int priority) |
Create VLAN device. More... | |
int | vlan_destroy (struct net_device *netdev) |
Destroy VLAN device. More... | |
void | vlan_auto (const void *ll_addr, unsigned int tag) |
Configure automatic VLAN device. More... | |
static int | vlan_probe (struct net_device *trunk, void *priv __unused) |
Create automatic VLAN device. More... | |
static void | vlan_notify (struct net_device *trunk, void *priv __unused) |
Handle trunk network device link state change. More... | |
static int | vlan_remove_first (struct net_device *trunk) |
Destroy first VLAN device for a given trunk. More... | |
static void | vlan_remove (struct net_device *trunk, void *priv __unused) |
Destroy all VLAN devices for a given trunk. More... | |
void | vlan_netdev_rx (struct net_device *netdev, unsigned int tag, struct io_buffer *iobuf) |
Add VLAN tag-stripped packet to receive queue. More... | |
void | vlan_netdev_rx_err (struct net_device *netdev, unsigned int tag, struct io_buffer *iobuf, int rc) |
Discard received VLAN tag-stripped packet. More... | |
Variables | |
struct net_protocol vlan_protocol | __net_protocol |
VLAN protocol. More... | |
static uint8_t | vlan_auto_ll_addr [ETH_ALEN] |
Automatic VLAN device link-layer address. More... | |
static unsigned int | vlan_auto_tag |
Automatic VLAN tag. More... | |
static struct net_device_operations | vlan_operations |
VLAN device operations. More... | |
struct net_driver vlan_driver | __net_driver |
VLAN driver. More... | |
Virtual LANs.
Definition in file vlan.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
FEATURE | ( | FEATURE_PROTOCOL | , |
"VLAN" | , | ||
DHCP_EB_FEATURE_VLAN | , | ||
1 | |||
) |
|
static |
Open VLAN device.
netdev | Network device |
rc | Return status code |
Definition at line 70 of file vlan.c.
References netdev, netdev_open(), net_device::priv, and vlan_device::trunk.
|
static |
Close VLAN device.
netdev | Network device |
Definition at line 81 of file vlan.c.
References netdev, netdev_close(), net_device::priv, and vlan_device::trunk.
|
static |
Transmit packet on VLAN device.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 94 of file vlan.c.
References DBGC, ETH_ALEN, flags, htons, iob_disown, iob_push, io_buffer::list, list_del, net_device::ll_protocol, memcpy(), net_device::name, vlan_header::net_proto, net_tx(), netdev, vlan_device::priority, net_device::priv, ll_protocol::pull, rc, strerror(), vlan_device::tag, vlan_header::tci, vlan_device::trunk, and VLAN_TCI.
|
static |
Poll VLAN device.
netdev | Network device |
Definition at line 146 of file vlan.c.
References netdev, netdev_poll(), net_device::priv, and vlan_device::trunk.
|
static |
Enable/disable interrupts on VLAN device.
netdev | Network device |
enable | Interrupts should be enabled |
Definition at line 159 of file vlan.c.
References netdev, netdev_irq(), net_device::priv, and vlan_device::trunk.
|
static |
Synchronise VLAN device.
netdev | Network device |
Definition at line 183 of file vlan.c.
References net_device::link_rc, netdev, netdev_close(), netdev_is_open(), netdev_link_err(), netdev_open(), net_device::priv, and vlan_device::trunk.
Referenced by vlan_create(), and vlan_notify().
struct net_device* vlan_find | ( | struct net_device * | trunk, |
unsigned int | tag | ||
) |
Identify VLAN device.
trunk | Trunk network device |
tag | VLAN tag |
netdev | VLAN device, if any |
Definition at line 208 of file vlan.c.
References for_each_netdev, netdev, NULL, net_device::op, net_device::priv, tag, vlan_device::tag, vlan_device::trunk, and vlan_operations.
Referenced by efi_vlan_find(), efi_vlan_remove(), vlan_create(), vlan_netdev_rx(), vlan_netdev_rx_err(), and vlan_rx().
|
static |
Process incoming VLAN packet.
iobuf | I/O buffer |
trunk | Trunk network device |
ll_dest | Link-layer destination address |
ll_source | Link-layer source address |
flags | Packet flags |
rc | Return status code |
Definition at line 232 of file vlan.c.
References io_buffer::data, DBGC, DBGC2, EINVAL, EPIPE, ETH_ALEN, free_iob(), iob_disown, iob_len(), iob_pull, net_device::ll_protocol, memcpy(), net_device::name, vlan_header::net_proto, netdev, netdev_rx(), ntohs, ll_protocol::push, rc, strerror(), tag, vlan_header::tci, vlan_find(), and VLAN_TAG.
unsigned int vlan_tci | ( | struct net_device * | netdev | ) |
Get the VLAN tag control information.
netdev | Network device |
tci | VLAN tag control information, or 0 if not a VLAN device |
Definition at line 301 of file vlan.c.
References netdev, net_device::op, vlan_device::priority, net_device::priv, vlan_device::tag, vlan_operations, and VLAN_TCI.
Referenced by vlan_tag().
int vlan_can_be_trunk | ( | struct net_device * | trunk | ) |
Check if network device can be used as a VLAN trunk device.
trunk | Trunk network device |
is_ok | Trunk network device is usable |
VLAN devices will be created as Ethernet devices. (We cannot simply clone the link layer of the trunk network device, because this link layer may expect the network device structure to contain some link-layer-private data.) The trunk network device must therefore have a link layer that is in some sense 'compatible' with Ethernet; specifically, it must have link-layer addresses that are the same length as Ethernet link-layer addresses.
As an additional check, and primarily to assist with the sanity of the FCoE code, we refuse to allow nested VLANs.
Definition at line 329 of file vlan.c.
References ETH_ALEN, ll_protocol::ll_addr_len, net_device::ll_protocol, net_device::op, vlan_device::trunk, and vlan_operations.
Referenced by fcoe_expired(), fcoe_reset(), vlan_create(), and vlan_probe().
int vlan_create | ( | struct net_device * | trunk, |
unsigned int | tag, | ||
unsigned int | priority | ||
) |
Create VLAN device.
trunk | Trunk network device |
tag | VLAN tag |
priority | Default VLAN priority |
rc | Return status code |
Definition at line 343 of file vlan.c.
References alloc_etherdev(), DBGC, net_device::dev, EINVAL, ENOMEM, ENOTTY, ETH_ALEN, net_device::hw_addr, net_device::ll_addr, memcpy(), net_device::name, netdev, netdev_get(), netdev_init(), netdev_irq_supported(), NETDEV_IRQ_UNSUPPORTED, netdev_nullify(), netdev_put(), NULL, priority, vlan_device::priority, net_device::priv, rc, register_netdev(), snprintf(), net_device::state, strerror(), tag, vlan_device::tag, vlan_device::trunk, unregister_netdev(), vlan_can_be_trunk(), vlan_find(), vlan_operations, VLAN_PRIORITY_IS_VALID, vlan_sync(), and VLAN_TAG_IS_VALID.
Referenced by efi_vlan_set(), fcoe_fip_rx_vlan(), vcreate_exec(), and vlan_probe().
int vlan_destroy | ( | struct net_device * | netdev | ) |
Destroy VLAN device.
netdev | Network device |
rc | Return status code |
Definition at line 433 of file vlan.c.
References DBGC, ENOTTY, net_device::name, netdev, netdev_nullify(), netdev_put(), net_device::op, net_device::priv, vlan_device::trunk, unregister_netdev(), and vlan_operations.
Referenced by efi_vlan_remove(), vdestroy_exec(), and vlan_remove_first().
void vlan_auto | ( | const void * | ll_addr, |
unsigned int | tag | ||
) |
Configure automatic VLAN device.
ll_addr | Link-layer address |
tag | VLAN tag |
Definition at line 462 of file vlan.c.
References ETH_ALEN, net_device::ll_addr, memcpy(), tag, vlan_auto_ll_addr, and vlan_auto_tag.
Referenced by efi_set_autoboot_ll_addr().
|
static |
Create automatic VLAN device.
trunk | Trunk network device |
priv | Private data |
rc | Return status code |
Definition at line 476 of file vlan.c.
References ETH_ALEN, net_device::ll_addr, memcmp(), rc, vlan_auto_ll_addr, vlan_auto_tag, vlan_can_be_trunk(), and vlan_create().
|
static |
Handle trunk network device link state change.
trunk | Trunk network device |
priv | Private data |
Definition at line 504 of file vlan.c.
References for_each_netdev, netdev, net_device::op, net_device::priv, vlan_device::trunk, vlan_operations, and vlan_sync().
|
static |
Destroy first VLAN device for a given trunk.
trunk | Trunk network device |
found | A VLAN device was found |
Definition at line 523 of file vlan.c.
References for_each_netdev, netdev, net_device::op, net_device::priv, vlan_device::trunk, vlan_destroy(), and vlan_operations.
Referenced by vlan_remove().
|
static |
Destroy all VLAN devices for a given trunk.
trunk | Trunk network device |
priv | Private data |
Definition at line 545 of file vlan.c.
References vlan_device::trunk, and vlan_remove_first().
void vlan_netdev_rx | ( | struct net_device * | netdev, |
unsigned int | tag, | ||
struct io_buffer * | iobuf | ||
) |
Add VLAN tag-stripped packet to receive queue.
Add VLAN tag-stripped packet to queue (when VLAN support is not present)
netdev | Network device |
tag | VLAN tag, or zero |
iobuf | I/O buffer |
Definition at line 568 of file vlan.c.
References ENODEV, netdev, netdev_rx(), netdev_rx_err(), NULL, tag, and vlan_find().
void vlan_netdev_rx_err | ( | struct net_device * | netdev, |
unsigned int tag | , | ||
struct io_buffer * | iobuf, | ||
int | rc | ||
) |
Discard received VLAN tag-stripped packet.
Discard received VLAN tag-stripped packet (when VLAN support is not present)
netdev | Network device |
tag | VLAN tag, or zero |
iobuf | I/O buffer, or NULL |
rc | Packet status code |
Definition at line 593 of file vlan.c.
References netdev, netdev_rx_err(), NULL, rc, tag, and vlan_find().
struct net_protocol vlan_protocol __net_protocol |
VLAN protocol.
AoE protocol.
Automatic VLAN device link-layer address.
Definition at line 59 of file vlan.c.
Referenced by vlan_auto(), and vlan_probe().
|
static |
Automatic VLAN tag.
Definition at line 62 of file vlan.c.
Referenced by vlan_auto(), and vlan_probe().
|
static |
VLAN device operations.
Definition at line 170 of file vlan.c.
Referenced by vlan_can_be_trunk(), vlan_create(), vlan_destroy(), vlan_find(), vlan_notify(), vlan_remove_first(), and vlan_tci().
struct net_driver vlan_driver __net_driver |
VLAN driver.