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 
13 #include <ipxe/netdevice.h>
14 
15 /** A VLAN header */
16 struct vlan_header {
17  /** Tag control information */
19  /** Encapsulated protocol */
21 } __attribute__ (( packed ));
22 
23 /**
24  * Extract VLAN tag from tag control information
25  *
26  * @v tci Tag control information
27  * @ret tag VLAN tag
28  */
29 #define VLAN_TAG( tci ) ( (tci) & 0x0fff )
30 
31 /**
32  * Extract VLAN priority from tag control information
33  *
34  * @v tci Tag control information
35  * @ret priority Priority
36  */
37 #define VLAN_PRIORITY( tci ) ( (tci) >> 13 )
38 
39 /**
40  * Construct VLAN tag control information
41  *
42  * @v tag VLAN tag
43  * @v priority Priority
44  * @ret tci Tag control information
45  */
46 #define VLAN_TCI( tag, priority ) ( ( (priority) << 13 ) | (tag) )
47 
48 /**
49  * Check VLAN tag is valid
50  *
51  * @v tag VLAN tag
52  * @ret is_valid VLAN tag is valid
53  */
54 #define VLAN_TAG_IS_VALID( tag ) ( (tag) < 0xfff )
55 
56 /**
57  * Check VLAN priority is valid
58  *
59  * @v priority VLAN priority
60  * @ret is_valid VLAN priority is valid
61  */
62 #define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
63 
64 extern unsigned int vlan_tci ( struct net_device *netdev );
65 
66 /**
67  * Get the VLAN tag
68  *
69  * @v netdev Network device
70  * @ret tag VLAN tag, or 0 if device is not a VLAN device
71  */
72 static inline __attribute__ (( always_inline )) unsigned int
73 vlan_tag ( struct net_device *netdev ) {
74  return VLAN_TAG ( vlan_tci ( netdev ) );
75 }
76 
77 extern struct net_device * vlan_find ( struct net_device *trunk,
78  unsigned int tag );
79 extern int vlan_can_be_trunk ( struct net_device *trunk );
80 extern int vlan_create ( struct net_device *trunk, unsigned int tag,
81  unsigned int priority );
82 extern int vlan_destroy ( struct net_device *netdev );
83 extern void vlan_auto ( const void *ll_addr, unsigned int tag );
84 extern void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
85  struct io_buffer *iobuf );
86 extern void vlan_netdev_rx_err ( struct net_device *netdev, unsigned int tag,
87  struct io_buffer *iobuf, int rc );
88 
89 #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:29
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:18
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:1209
unsigned int vlan_tci(struct net_device *netdev)
Get the VLAN tag control information.
Definition: vlan.c:301
uint16_t net_proto
Encapsulated protocol.
Definition: vlan.h:20
void vlan_auto(const void *ll_addr, unsigned int tag)
Configure automatic VLAN device.
Definition: vlan.c:462
struct net_device * vlan_find(struct net_device *trunk, unsigned int tag)
Identify VLAN device.
Definition: vlan.c:208
int vlan_create(struct net_device *trunk, unsigned int tag, unsigned int priority)
Create VLAN device.
Definition: vlan.c:343
A VLAN header.
Definition: vlan.h:16
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:329
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:1227
A network device.
Definition: netdevice.h:352
Network device management.
uint16_t priority
Priotity.
Definition: stp.h:12
int vlan_destroy(struct net_device *netdev)
Destroy VLAN device.
Definition: vlan.c:433
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
static unsigned int vlan_tag(struct net_device *netdev)
Get the VLAN tag.
Definition: vlan.h:73
uint64_t tag
Identity tag.
Definition: edd.h:30
A persistent I/O buffer.
Definition: iobuf.h:33