iPXE
vlan.h
Go to the documentation of this file.
1#ifndef _IPXE_VLAN_H
2#define _IPXE_VLAN_H
3
4/**
5 * @file
6 *
7 * Virtual LANs
8 *
9 */
10
11FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12FILE_SECBOOT ( PERMITTED );
13
14#include <ipxe/netdevice.h>
15
16/** A VLAN header */
18 /** Tag control information */
20 /** Encapsulated protocol */
22} __attribute__ (( packed ));
23
24/**
25 * Extract VLAN tag from tag control information
26 *
27 * @v tci Tag control information
28 * @ret tag VLAN tag
29 */
30#define VLAN_TAG( tci ) ( (tci) & 0x0fff )
31
32/**
33 * Extract VLAN priority from tag control information
34 *
35 * @v tci Tag control information
36 * @ret priority Priority
37 */
38#define VLAN_PRIORITY( tci ) ( (tci) >> 13 )
39
40/**
41 * Construct VLAN tag control information
42 *
43 * @v tag VLAN tag
44 * @v priority Priority
45 * @ret tci Tag control information
46 */
47#define VLAN_TCI( tag, priority ) ( ( (priority) << 13 ) | (tag) )
48
49/**
50 * Check VLAN tag is valid
51 *
52 * @v tag VLAN tag
53 * @ret is_valid VLAN tag is valid
54 */
55#define VLAN_TAG_IS_VALID( tag ) ( (tag) < 0xfff )
56
57/**
58 * Check VLAN priority is valid
59 *
60 * @v priority VLAN priority
61 * @ret is_valid VLAN priority is valid
62 */
63#define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
64
65extern unsigned int vlan_tci ( struct net_device *netdev );
66
67/**
68 * Get the VLAN tag
69 *
70 * @v netdev Network device
71 * @ret tag VLAN tag, or 0 if device is not a VLAN device
72 */
73static inline __attribute__ (( always_inline )) unsigned int
75 return VLAN_TAG ( vlan_tci ( netdev ) );
76}
77
78extern struct net_device * vlan_find ( struct net_device *trunk,
79 unsigned int tag );
80extern int vlan_can_be_trunk ( struct net_device *trunk );
81extern int vlan_create ( struct net_device *trunk, unsigned int tag,
82 unsigned int priority );
83extern int vlan_destroy ( struct net_device *netdev );
84extern void vlan_auto ( const void *ll_addr, unsigned int tag );
85extern void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
86 struct io_buffer *iobuf );
87extern void vlan_netdev_rx_err ( struct net_device *netdev, unsigned int tag,
88 struct io_buffer *iobuf, int rc );
89
90#endif /* _IPXE_VLAN_H */
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
unsigned short uint16_t
Definition stdint.h:11
uint64_t tag
Identity tag.
Definition edd.h:1
static struct net_device * netdev
Definition gdbudp.c:53
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
__weak unsigned int vlan_tci(struct net_device *netdev __unused)
Get the VLAN tag control information (when VLAN support is not present)
Definition netdevice.c:1199
Network device management.
uint16_t priority
Priotity.
Definition stp.h:1
A persistent I/O buffer.
Definition iobuf.h:38
A network device.
Definition netdevice.h:353
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition netdevice.h:388
A VLAN header.
Definition vlan.h:17
uint16_t net_proto
Encapsulated protocol.
Definition vlan.h:21
uint16_t tci
Tag control information.
Definition vlan.h:19
int vlan_can_be_trunk(struct net_device *trunk)
Check if network device can be used as a VLAN trunk device.
Definition vlan.c:330
void vlan_auto(const void *ll_addr, unsigned int tag)
Configure automatic VLAN device.
Definition vlan.c:463
struct net_device * vlan_find(struct net_device *trunk, unsigned int tag)
Identify VLAN device.
Definition vlan.c:209
static unsigned int vlan_tag(struct net_device *netdev)
Get the VLAN tag.
Definition vlan.h:74
void vlan_netdev_rx_err(struct net_device *netdev, unsigned int tag, struct io_buffer *iobuf, int rc)
Discard received VLAN tag-stripped packet (when VLAN support is not present)
Definition netdevice.c:1228
int vlan_destroy(struct net_device *netdev)
Destroy VLAN device.
Definition vlan.c:434
void vlan_netdev_rx(struct net_device *netdev, unsigned int tag, struct io_buffer *iobuf)
Add VLAN tag-stripped packet to queue (when VLAN support is not present)
Definition netdevice.c:1210
#define VLAN_TAG(tci)
Extract VLAN tag from tag control information.
Definition vlan.h:30
unsigned int vlan_tci(struct net_device *netdev)
Get the VLAN tag control information.
Definition vlan.c:302
int vlan_create(struct net_device *trunk, unsigned int tag, unsigned int priority)
Create VLAN device.
Definition vlan.c:344