[vlan] Add support for IEEE 802.1Q VLANs

Originally-implemented-by: michael-dev@fami-braun.de
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2010-11-19 00:23:26 +00:00
parent f12fcd53b1
commit 6fd09b541f
10 changed files with 725 additions and 10 deletions

View File

@@ -190,6 +190,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define ERRFILE_fcp ( ERRFILE_NET | 0x002d0000 )
#define ERRFILE_fcoe ( ERRFILE_NET | 0x002e0000 )
#define ERRFILE_fcns ( ERRFILE_NET | 0x002f0000 )
#define ERRFILE_vlan ( ERRFILE_NET | 0x00300000 )
#define ERRFILE_image ( ERRFILE_IMAGE | 0x00000000 )
#define ERRFILE_elf ( ERRFILE_IMAGE | 0x00010000 )

View File

@@ -51,6 +51,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define DHCP_EB_FEATURE_COMBOOT 0x23 /**< COMBOOT format */
#define DHCP_EB_FEATURE_EFI 0x24 /**< EFI format */
#define DHCP_EB_FEATURE_FCOE 0x25 /**< FCoE protocol */
#define DHCP_EB_FEATURE_VLAN 0x26 /**< VLAN support */
/** @} */

View File

@@ -18,6 +18,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define ETH_P_IP 0x0800 /* Internet Protocl Packet */
#define ETH_P_ARP 0x0806 /* Address Resolution Protocol */
#define ETH_P_RARP 0x8035 /* Reverse Address resolution Protocol */
#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
#define ETH_P_IPV6 0x86DD /* IPv6 over blueblook */
#define ETH_P_SLOW 0x8809 /* Ethernet slow protocols */
#define ETH_P_EAPOL 0x888E /* 802.1X EAP over LANs */

View File

@@ -36,11 +36,12 @@ struct device;
/** Maximum length of a link-layer header
*
* The longest currently-supported link-layer header is for 802.11: a
* 24-byte frame header plus an 8-byte 802.3 LLC/SNAP header. (The
* IPoIB link-layer pseudo-header doesn't actually include link-layer
* addresses; see ipoib.c for details).
* 24-byte frame header plus an 8-byte 802.3 LLC/SNAP header, plus a
* possible 4-byte VLAN header. (The IPoIB link-layer pseudo-header
* doesn't actually include link-layer addresses; see ipoib.c for
* details.)
*/
#define MAX_LL_HEADER_LEN 32
#define MAX_LL_HEADER_LEN 36
/** Maximum length of a network-layer address */
#define MAX_NET_ADDR_LEN 4
@@ -278,7 +279,7 @@ struct net_device {
/** List of open network devices */
struct list_head open_list;
/** Name of this network device */
char name[8];
char name[12];
/** Underlying hardware device */
struct device *dev;

66
src/include/ipxe/vlan.h Normal file
View File

@@ -0,0 +1,66 @@
#ifndef _IPXE_VLAN_H
#define _IPXE_VLAN_H
/**
* @file
*
* Virtual LANs
*
*/
FILE_LICENCE ( GPL2_OR_LATER );
/** 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) >= 1 ) && ( (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 int vlan_create ( struct net_device *trunk, unsigned int tag,
unsigned int priority );
extern int vlan_destroy ( struct net_device *netdev );
#endif /* _IPXE_VLAN_H */