[ipxe-devel] [PATCH 1/2] [netdevice] Add netdev_vlan() to get 802.1Q VLAN Identifier
Stefan Hajnoczi
stefanha at redhat.com
Fri Mar 1 15:32:15 UTC 2013
The iBFT has a VLAN field that should be filled in. We need to fetch
the 802.1Q VLAN Identifier from net_device. Introduce the new
netdev_vlan() function to get the VID.
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 at redhat.com>
---
src/include/ipxe/netdevice.h | 1 +
src/net/netdevice.c | 11 +++++++++++
src/net/vlan.c | 17 +++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h
index e5dbd99..3545464 100644
--- a/src/include/ipxe/netdevice.h
+++ b/src/include/ipxe/netdevice.h
@@ -602,6 +602,7 @@ netdev_rx_frozen ( struct net_device *netdev ) {
return ( netdev->state & NETDEV_RX_FROZEN );
}
+extern uint16_t netdev_vlan ( struct net_device *netdev );
extern void netdev_link_err ( struct net_device *netdev, int rc );
extern void netdev_link_down ( struct net_device *netdev );
extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index ec3456a..79cb31d 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -93,6 +93,17 @@ static void netdev_notify ( struct net_device *netdev ) {
}
/**
+ * Get the 802.1Q VLAN Identifier for this net_device
+ *
+ * @v netdev Network device
+ * @ret vlan 802.1Q VLAN Identifier
+ */
+__weak uint16_t netdev_vlan ( struct net_device *netdev __unused ) {
+ /* 802.1Q VLAN Identifier 0 is reserved to mean no VLAN */
+ return 0;
+}
+
+/**
* Mark network device as having a specific link state
*
* @v netdev Network device
diff --git a/src/net/vlan.c b/src/net/vlan.c
index f7281f5..adf7279 100644
--- a/src/net/vlan.c
+++ b/src/net/vlan.c
@@ -283,6 +283,23 @@ struct net_protocol vlan_protocol __net_protocol = {
};
/**
+ * Get the 802.1Q VLAN Identifier for this net_device
+ *
+ * @v netdev Network device
+ * @ret vlan 802.1Q VLAN Identifier
+ */
+uint16_t netdev_vlan ( struct net_device *netdev ) {
+
+ if ( netdev->op == &vlan_operations ) {
+ struct vlan_device *vlan = netdev->priv;
+ return vlan->tag;
+ }
+
+ /* 802.1Q VLAN Identifier 0 is reserved to mean no VLAN */
+ return 0;
+}
+
+/**
* Check if network device can be used as a VLAN trunk device
*
* @v trunk Trunk network device
--
1.8.1.2
More information about the ipxe-devel
mailing list