aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2022-12-09 14:40:54 +0000
committerMichael Brown <mcb30@ipxe.org>2022-12-09 14:40:54 +0000
commit0bde40d4ba366d8419fa19f64530ea23bfc9450d (patch)
treec3bf7bc249528c7d1445438e44b5be93ac39a5e6
parent563bff472276b25a6788abc3c916cda65e7ceead (diff)
downloadipxe-0bde40d4ba366d8419fa19f64530ea23bfc9450d.zip
ipxe-0bde40d4ba366d8419fa19f64530ea23bfc9450d.tar.gz
ipxe-0bde40d4ba366d8419fa19f64530ea23bfc9450d.tar.bz2
[vlan] Allow external code to identify VLAN priority as well as tag
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/include/ipxe/vlan.h14
-rw-r--r--src/net/netdevice.c4
-rw-r--r--src/net/vlan.c8
3 files changed, 19 insertions, 7 deletions
diff --git a/src/include/ipxe/vlan.h b/src/include/ipxe/vlan.h
index 7f93439..e4baf4c 100644
--- a/src/include/ipxe/vlan.h
+++ b/src/include/ipxe/vlan.h
@@ -61,7 +61,19 @@ struct vlan_header {
*/
#define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
-extern unsigned int vlan_tag ( struct net_device *netdev );
+extern unsigned int vlan_tci ( struct net_device *netdev );
+
+/**
+ * Get the VLAN tag
+ *
+ * @v netdev Network device
+ * @ret tag VLAN tag, or 0 if device is not a VLAN device
+ */
+static inline __attribute__ (( always_inline )) unsigned int
+vlan_tag ( struct net_device *netdev ) {
+ return VLAN_TAG ( vlan_tci ( 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 );
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index 5df306e..51d1831 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -1171,12 +1171,12 @@ static void net_step ( struct process *process __unused ) {
}
/**
- * Get the VLAN tag (when VLAN support is not present)
+ * Get the VLAN tag control information (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 ) {
+__weak unsigned int vlan_tci ( struct net_device *netdev __unused ) {
return 0;
}
diff --git a/src/net/vlan.c b/src/net/vlan.c
index 90f2934..fe44886 100644
--- a/src/net/vlan.c
+++ b/src/net/vlan.c
@@ -288,17 +288,17 @@ struct net_protocol vlan_protocol __net_protocol = {
};
/**
- * Get the VLAN tag
+ * Get the VLAN tag control information
*
* @v netdev Network device
- * @ret tag VLAN tag, or 0 if device is not a VLAN device
+ * @ret tci VLAN tag control information, or 0 if not a VLAN device
*/
-unsigned int vlan_tag ( struct net_device *netdev ) {
+unsigned int vlan_tci ( struct net_device *netdev ) {
struct vlan_device *vlan;
if ( netdev->op == &vlan_operations ) {
vlan = netdev->priv;
- return vlan->tag;
+ return ( VLAN_TCI ( vlan->tag, vlan->priority ) );
} else {
return 0;
}