Переглянути джерело

[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 <stefanha@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Stefan Hajnoczi 11 роки тому
джерело
коміт
7426177d63
3 змінених файлів з 29 додано та 0 видалено
  1. 1
    0
      src/include/ipxe/vlan.h
  2. 11
    0
      src/net/netdevice.c
  3. 17
    0
      src/net/vlan.c

+ 1
- 0
src/include/ipxe/vlan.h Переглянути файл

@@ -61,6 +61,7 @@ struct vlan_header {
61 61
 
62 62
 extern struct net_device * vlan_find ( struct net_device *trunk,
63 63
 				       unsigned int tag );
64
+extern unsigned int vlan_tag ( struct net_device *netdev );
64 65
 extern int vlan_can_be_trunk ( struct net_device *trunk );
65 66
 extern int vlan_create ( struct net_device *trunk, unsigned int tag,
66 67
 			 unsigned int priority );

+ 11
- 0
src/net/netdevice.c Переглянути файл

@@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
33 33
 #include <ipxe/init.h>
34 34
 #include <ipxe/device.h>
35 35
 #include <ipxe/errortab.h>
36
+#include <ipxe/vlan.h>
36 37
 #include <ipxe/netdevice.h>
37 38
 
38 39
 /** @file
@@ -783,5 +784,15 @@ static void net_step ( struct process *process __unused ) {
783 784
 	net_poll();
784 785
 }
785 786
 
787
+/**
788
+ * Get the VLAN tag (when VLAN support is not present)
789
+ *
790
+ * @v netdev		Network device
791
+ * @ret tag		0, indicating that device is not a VLAN device
792
+ */
793
+__weak unsigned int vlan_tag ( struct net_device *netdev __unused ) {
794
+	return 0;
795
+}
796
+
786 797
 /** Networking stack process */
787 798
 PERMANENT_PROCESS ( net_process, net_step );

+ 17
- 0
src/net/vlan.c Переглянути файл

@@ -282,6 +282,23 @@ struct net_protocol vlan_protocol __net_protocol = {
282 282
 	.rx = vlan_rx,
283 283
 };
284 284
 
285
+/**
286
+ * Get the VLAN tag
287
+ *
288
+ * @v netdev		Network device
289
+ * @ret tag		VLAN tag, or 0 if device is not a VLAN device
290
+ */
291
+unsigned int vlan_tag ( struct net_device *netdev ) {
292
+	struct vlan_device *vlan;
293
+
294
+	if ( netdev->op == &vlan_operations ) {
295
+		vlan = netdev->priv;
296
+		return vlan->tag;
297
+	} else {
298
+		return 0;
299
+	}
300
+}
301
+
285 302
 /**
286 303
  * Check if network device can be used as a VLAN trunk device
287 304
  *

Завантаження…
Відмінити
Зберегти