[vlan] Provide vlan_netdev_rx() and vlan_netdev_rx_err()
[ipxe.git] / src / include / ipxe / vlan.h
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 */
18 uint16_t tci;
19 /** Encapsulated protocol */
20 uint16_t net_proto;
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_tag ( struct net_device *netdev );
65 extern int vlan_can_be_trunk ( struct net_device *trunk );
66 extern int vlan_create ( struct net_device *trunk, unsigned int tag,
67 unsigned int priority );
68 extern int vlan_destroy ( struct net_device *netdev );
69 extern void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
70 struct io_buffer *iobuf );
71 extern void vlan_netdev_rx_err ( struct net_device *netdev, unsigned int tag,
72 struct io_buffer *iobuf, int rc );
73
74 #endif /* _IPXE_VLAN_H */