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 #include <ipxe/netdevice.h>
00014 
00015 /** A VLAN header */
00016 struct vlan_header {
00017         /** Tag control information */
00018         uint16_t tci;
00019         /** Encapsulated protocol */
00020         uint16_t net_proto;
00021 } __attribute__ (( packed ));
00022 
00023 /**
00024  * Extract VLAN tag from tag control information
00025  *
00026  * @v tci               Tag control information
00027  * @ret tag             VLAN tag
00028  */
00029 #define VLAN_TAG( tci ) ( (tci) & 0x0fff )
00030 
00031 /**
00032  * Extract VLAN priority from tag control information
00033  *
00034  * @v tci               Tag control information
00035  * @ret priority        Priority
00036  */
00037 #define VLAN_PRIORITY( tci ) ( (tci) >> 13 )
00038 
00039 /**
00040  * Construct VLAN tag control information
00041  *
00042  * @v tag               VLAN tag
00043  * @v priority          Priority
00044  * @ret tci             Tag control information
00045  */
00046 #define VLAN_TCI( tag, priority ) ( ( (priority) << 13 ) | (tag) )
00047 
00048 /**
00049  * Check VLAN tag is valid
00050  *
00051  * @v tag               VLAN tag
00052  * @ret is_valid        VLAN tag is valid
00053  */
00054 #define VLAN_TAG_IS_VALID( tag ) ( (tag) < 0xfff )
00055 
00056 /**
00057  * Check VLAN priority is valid
00058  *
00059  * @v priority          VLAN priority
00060  * @ret is_valid        VLAN priority is valid
00061  */
00062 #define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
00063 
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 extern void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
00070                              struct io_buffer *iobuf );
00071 extern void vlan_netdev_rx_err ( struct net_device *netdev, unsigned int tag,
00072                                  struct io_buffer *iobuf, int rc );
00073 
00074 #endif /* _IPXE_VLAN_H */