summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/vlan.h
blob: 7f93439b364e4d0a4e5352e0537138d9b172ca41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef _IPXE_VLAN_H
#define _IPXE_VLAN_H

/**
 * @file
 *
 * Virtual LANs
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

#include <ipxe/netdevice.h>

/** A VLAN header */
struct vlan_header {
	/** Tag control information */
	uint16_t tci;
	/** Encapsulated protocol */
	uint16_t net_proto;
} __attribute__ (( packed ));

/**
 * Extract VLAN tag from tag control information
 *
 * @v tci		Tag control information
 * @ret tag		VLAN tag
 */
#define VLAN_TAG( tci ) ( (tci) & 0x0fff )

/**
 * Extract VLAN priority from tag control information
 *
 * @v tci		Tag control information
 * @ret priority	Priority
 */
#define VLAN_PRIORITY( tci ) ( (tci) >> 13 )

/**
 * Construct VLAN tag control information
 *
 * @v tag		VLAN tag
 * @v priority		Priority
 * @ret tci		Tag control information
 */
#define VLAN_TCI( tag, priority ) ( ( (priority) << 13 ) | (tag) )

/**
 * Check VLAN tag is valid
 *
 * @v tag		VLAN tag
 * @ret is_valid	VLAN tag is valid
 */
#define VLAN_TAG_IS_VALID( tag ) ( (tag) < 0xfff )

/**
 * Check VLAN priority is valid
 *
 * @v priority		VLAN priority
 * @ret is_valid	VLAN priority is valid
 */
#define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )

extern unsigned int vlan_tag ( struct net_device *netdev );
extern int vlan_can_be_trunk ( struct net_device *trunk );
extern int vlan_create ( struct net_device *trunk, unsigned int tag,
			 unsigned int priority );
extern int vlan_destroy ( struct net_device *netdev );
extern void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
			     struct io_buffer *iobuf );
extern void vlan_netdev_rx_err ( struct net_device *netdev, unsigned int tag,
				 struct io_buffer *iobuf, int rc );

#endif /* _IPXE_VLAN_H */