summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2010-11-19 01:23:26 +0100
committerMichael Brown2010-11-20 17:52:04 +0100
commit6fd09b541fbc426057661c7e0da4f39000b6803e (patch)
tree042ecae7db862b934180566b16645969987343de /src/include
parent[lotest] Fix endianness in status message (diff)
downloadipxe-6fd09b541fbc426057661c7e0da4f39000b6803e.tar.gz
ipxe-6fd09b541fbc426057661c7e0da4f39000b6803e.tar.xz
ipxe-6fd09b541fbc426057661c7e0da4f39000b6803e.zip
[vlan] Add support for IEEE 802.1Q VLANs
Originally-implemented-by: michael-dev@fami-braun.de Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ipxe/errfile.h1
-rw-r--r--src/include/ipxe/features.h1
-rw-r--r--src/include/ipxe/if_ether.h1
-rw-r--r--src/include/ipxe/netdevice.h11
-rw-r--r--src/include/ipxe/vlan.h66
5 files changed, 75 insertions, 5 deletions
diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h
index 2255f8a30..5f0f16611 100644
--- a/src/include/ipxe/errfile.h
+++ b/src/include/ipxe/errfile.h
@@ -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 )
diff --git a/src/include/ipxe/features.h b/src/include/ipxe/features.h
index 76b59321f..660015cd2 100644
--- a/src/include/ipxe/features.h
+++ b/src/include/ipxe/features.h
@@ -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 */
/** @} */
diff --git a/src/include/ipxe/if_ether.h b/src/include/ipxe/if_ether.h
index db6cb0dfb..a7e237349 100644
--- a/src/include/ipxe/if_ether.h
+++ b/src/include/ipxe/if_ether.h
@@ -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 */
diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h
index 26e2ab897..6986233e2 100644
--- a/src/include/ipxe/netdevice.h
+++ b/src/include/ipxe/netdevice.h
@@ -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;
diff --git a/src/include/ipxe/vlan.h b/src/include/ipxe/vlan.h
new file mode 100644
index 000000000..86d78bed0
--- /dev/null
+++ b/src/include/ipxe/vlan.h
@@ -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 */