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 
11 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12 FILE_SECBOOT ( PERMITTED );
13 
14 #include <ipxe/netdevice.h>
15 
16 /** A VLAN header */
17 struct 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 
65 extern 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  */
73 static inline __attribute__ (( always_inline )) unsigned int
74 vlan_tag ( struct net_device *netdev ) {
75  return VLAN_TAG ( vlan_tci ( netdev ) );
76 }
77 
78 extern struct net_device * vlan_find ( struct net_device *trunk,
79  unsigned int tag );
80 extern int vlan_can_be_trunk ( struct net_device *trunk );
81 extern int vlan_create ( struct net_device *trunk, unsigned int tag,
82  unsigned int priority );
83 extern int vlan_destroy ( struct net_device *netdev );
84 extern void vlan_auto ( const void *ll_addr, unsigned int tag );
85 extern void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
86  struct io_buffer *iobuf );
87 extern 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 */
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define __attribute__(x)
Definition: compiler.h:10
#define VLAN_TAG(tci)
Extract VLAN tag from tag control information.
Definition: vlan.h:30
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
uint16_t tci
Tag control information.
Definition: vlan.h:19
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
unsigned int vlan_tci(struct net_device *netdev)
Get the VLAN tag control information.
Definition: vlan.c:302
uint16_t net_proto
Encapsulated protocol.
Definition: vlan.h:21
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
int vlan_create(struct net_device *trunk, unsigned int tag, unsigned int priority)
Create VLAN device.
Definition: vlan.c:344
FILE_SECBOOT(PERMITTED)
A VLAN header.
Definition: vlan.h:17
static struct net_device * netdev
Definition: gdbudp.c:52
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_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
A network device.
Definition: netdevice.h:353
Network device management.
uint16_t priority
Priotity.
Definition: stp.h:13
int vlan_destroy(struct net_device *netdev)
Destroy VLAN device.
Definition: vlan.c:434
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:388
static unsigned int vlan_tag(struct net_device *netdev)
Get the VLAN tag.
Definition: vlan.h:74
uint64_t tag
Identity tag.
Definition: edd.h:31
A persistent I/O buffer.
Definition: iobuf.h:38