aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/vlan.h
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2010-11-19 00:23:26 +0000
committerMichael Brown <mcb30@ipxe.org>2010-11-20 16:52:04 +0000
commit6fd09b541fbc426057661c7e0da4f39000b6803e (patch)
tree042ecae7db862b934180566b16645969987343de /src/include/ipxe/vlan.h
parentf12fcd53b1b661b5bfe7b5048398225297133b95 (diff)
downloadipxe-6fd09b541fbc426057661c7e0da4f39000b6803e.tar.gz
[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/ipxe/vlan.h')
-rw-r--r--src/include/ipxe/vlan.h66
1 files changed, 66 insertions, 0 deletions
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 */