iPXE
vlan.h
Go to the documentation of this file.
00001 #ifndef _IPXE_VLAN_H
00002 #define _IPXE_VLAN_H
00003 
00004 /**
00005  * @file
00006  *
00007  * Virtual LANs
00008  *
00009  */
00010 
00011 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00012 
00013 /** A VLAN header */
00014 struct vlan_header {
00015         /** Tag control information */
00016         uint16_t tci;
00017         /** Encapsulated protocol */
00018         uint16_t net_proto;
00019 } __attribute__ (( packed ));
00020 
00021 /**
00022  * Extract VLAN tag from tag control information
00023  *
00024  * @v tci               Tag control information
00025  * @ret tag             VLAN tag
00026  */
00027 #define VLAN_TAG( tci ) ( (tci) & 0x0fff )
00028 
00029 /**
00030  * Extract VLAN priority from tag control information
00031  *
00032  * @v tci               Tag control information
00033  * @ret priority        Priority
00034  */
00035 #define VLAN_PRIORITY( tci ) ( (tci) >> 13 )
00036 
00037 /**
00038  * Construct VLAN tag control information
00039  *
00040  * @v tag               VLAN tag
00041  * @v priority          Priority
00042  * @ret tci             Tag control information
00043  */
00044 #define VLAN_TCI( tag, priority ) ( ( (priority) << 13 ) | (tag) )
00045 
00046 /**
00047  * Check VLAN tag is valid
00048  *
00049  * @v tag               VLAN tag
00050  * @ret is_valid        VLAN tag is valid
00051  */
00052 #define VLAN_TAG_IS_VALID( tag ) ( (tag) < 0xfff )
00053 
00054 /**
00055  * Check VLAN priority is valid
00056  *
00057  * @v priority          VLAN priority
00058  * @ret is_valid        VLAN priority is valid
00059  */
00060 #define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
00061 
00062 extern struct net_device * vlan_find ( struct net_device *trunk,
00063                                        unsigned int tag );
00064 extern unsigned int vlan_tag ( struct net_device *netdev );
00065 extern int vlan_can_be_trunk ( struct net_device *trunk );
00066 extern int vlan_create ( struct net_device *trunk, unsigned int tag,
00067                          unsigned int priority );
00068 extern int vlan_destroy ( struct net_device *netdev );
00069 
00070 #endif /* _IPXE_VLAN_H */