~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/ipxe/src/include/ipxe/vlan.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
/** A VLAN header */
 
14
struct vlan_header {
 
15
        /** Tag control information */
 
16
        uint16_t tci;
 
17
        /** Encapsulated protocol */
 
18
        uint16_t net_proto;
 
19
} __attribute__ (( packed ));
 
20
 
 
21
/**
 
22
 * Extract VLAN tag from tag control information
 
23
 *
 
24
 * @v tci               Tag control information
 
25
 * @ret tag             VLAN tag
 
26
 */
 
27
#define VLAN_TAG( tci ) ( (tci) & 0x0fff )
 
28
 
 
29
/**
 
30
 * Extract VLAN priority from tag control information
 
31
 *
 
32
 * @v tci               Tag control information
 
33
 * @ret priority        Priority
 
34
 */
 
35
#define VLAN_PRIORITY( tci ) ( (tci) >> 13 )
 
36
 
 
37
/**
 
38
 * Construct VLAN tag control information
 
39
 *
 
40
 * @v tag               VLAN tag
 
41
 * @v priority          Priority
 
42
 * @ret tci             Tag control information
 
43
 */
 
44
#define VLAN_TCI( tag, priority ) ( ( (priority) << 13 ) | (tag) )
 
45
 
 
46
/**
 
47
 * Check VLAN tag is valid
 
48
 *
 
49
 * @v tag               VLAN tag
 
50
 * @ret is_valid        VLAN tag is valid
 
51
 */
 
52
#define VLAN_TAG_IS_VALID( tag ) ( (tag) < 0xfff )
 
53
 
 
54
/**
 
55
 * Check VLAN priority is valid
 
56
 *
 
57
 * @v priority          VLAN priority
 
58
 * @ret is_valid        VLAN priority is valid
 
59
 */
 
60
#define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
 
61
 
 
62
extern struct net_device * vlan_find ( struct net_device *trunk,
 
63
                                       unsigned int tag );
 
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
 
 
70
#endif /* _IPXE_VLAN_H */