]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[netdevice] Add vlan_tag() to get the VLAN tag of a network device
authorStefan Hajnoczi <stefanha@redhat.com>
Fri, 1 Mar 2013 15:32:15 +0000 (16:32 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 1 Mar 2013 16:11:40 +0000 (16:11 +0000)
The iBFT has a VLAN field that should be filled in.  Add the
vlan_tag() function to extract the VLAN tag of a network device.

Since VLAN support is optional, define a weak function that returns 0
when iPXE is built without VLAN support.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/vlan.h
src/net/netdevice.c
src/net/vlan.c

index d9f4484e6bc0e76731b5449912c082efb56f6be2..083c219161fa300fc31c8088e5535e27ea8a4f64 100644 (file)
@@ -61,6 +61,7 @@ struct vlan_header {
 
 extern struct net_device * vlan_find ( struct net_device *trunk,
                                       unsigned int tag );
+extern unsigned int vlan_tag ( struct net_device *netdev );
 extern int vlan_can_be_trunk ( struct net_device *trunk );
 extern int vlan_create ( struct net_device *trunk, unsigned int tag,
                         unsigned int priority );
index ec3456a9388f17a7f69d80b825615a0bd717aee1..a7166630428b4b6e047317a11c50c9c8cab8416a 100644 (file)
@@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <ipxe/init.h>
 #include <ipxe/device.h>
 #include <ipxe/errortab.h>
+#include <ipxe/vlan.h>
 #include <ipxe/netdevice.h>
 
 /** @file
@@ -783,5 +784,15 @@ static void net_step ( struct process *process __unused ) {
        net_poll();
 }
 
+/**
+ * Get the VLAN tag (when VLAN support is not present)
+ *
+ * @v netdev           Network device
+ * @ret tag            0, indicating that device is not a VLAN device
+ */
+__weak unsigned int vlan_tag ( struct net_device *netdev __unused ) {
+       return 0;
+}
+
 /** Networking stack process */
 PERMANENT_PROCESS ( net_process, net_step );
index f7281f5d758b098bef181e4df1e2903b1b4118f3..1a2a08622121fd18ac81c43623d170373d935f3f 100644 (file)
@@ -282,6 +282,23 @@ struct net_protocol vlan_protocol __net_protocol = {
        .rx = vlan_rx,
 };
 
+/**
+ * Get the VLAN tag
+ *
+ * @v netdev           Network device
+ * @ret tag            VLAN tag, or 0 if device is not a VLAN device
+ */
+unsigned int vlan_tag ( struct net_device *netdev ) {
+       struct vlan_device *vlan;
+
+       if ( netdev->op == &vlan_operations ) {
+               vlan = netdev->priv;
+               return vlan->tag;
+       } else {
+               return 0;
+       }
+}
+
 /**
  * Check if network device can be used as a VLAN trunk device
  *