From 7426177d631c0fd8b2ef3ffae4449637d5bca32a Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Fri, 1 Mar 2013 16:32:15 +0100 Subject: [netdevice] Add vlan_tag() to get the VLAN tag of a network device 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 Modified-by: Michael Brown Signed-off-by: Michael Brown --- src/net/netdevice.c | 11 +++++++++++ src/net/vlan.c | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'src/net') diff --git a/src/net/netdevice.c b/src/net/netdevice.c index ec3456a93..a71666304 100644 --- a/src/net/netdevice.c +++ b/src/net/netdevice.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include #include /** @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 ); diff --git a/src/net/vlan.c b/src/net/vlan.c index f7281f5d7..1a2a08622 100644 --- a/src/net/vlan.c +++ b/src/net/vlan.c @@ -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 * -- cgit v1.2.3-55-g7522