Browse Source

[intelxl] Use VLAN tag in receive descriptor if present

The physical function driver does not allow the virtual function to
request that VLAN tags are left unstripped.  Extract and use the VLAN
tag from the receive descriptor if present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 5 years ago
parent
commit
c901b5ca45
2 changed files with 19 additions and 3 deletions
  1. 11
    2
      src/drivers/net/intelxl.c
  2. 8
    1
      src/drivers/net/intelxl.h

+ 11
- 2
src/drivers/net/intelxl.c View File

@@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
32 32
 #include <ipxe/netdevice.h>
33 33
 #include <ipxe/ethernet.h>
34 34
 #include <ipxe/if_ether.h>
35
+#include <ipxe/vlan.h>
35 36
 #include <ipxe/iobuf.h>
36 37
 #include <ipxe/malloc.h>
37 38
 #include <ipxe/pci.h>
@@ -1254,6 +1255,7 @@ static void intelxl_poll_rx ( struct net_device *netdev ) {
1254 1255
 	struct intelxl_rx_writeback_descriptor *rx_wb;
1255 1256
 	struct io_buffer *iobuf;
1256 1257
 	unsigned int rx_idx;
1258
+	unsigned int tag;
1257 1259
 	size_t len;
1258 1260
 
1259 1261
 	/* Check for received packets */
@@ -1273,16 +1275,23 @@ static void intelxl_poll_rx ( struct net_device *netdev ) {
1273 1275
 		len = INTELXL_RX_WB_LEN ( le32_to_cpu ( rx_wb->len ) );
1274 1276
 		iob_put ( iobuf, len );
1275 1277
 
1278
+		/* Find VLAN device, if applicable */
1279
+		if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_VLAN ) ) {
1280
+			tag = VLAN_TAG ( le16_to_cpu ( rx_wb->vlan ) );
1281
+		} else {
1282
+			tag = 0;
1283
+		}
1284
+
1276 1285
 		/* Hand off to network stack */
1277 1286
 		if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_RXE ) ) {
1278 1287
 			DBGC ( intelxl, "INTELXL %p RX %d error (length %zd, "
1279 1288
 			       "flags %08x)\n", intelxl, rx_idx, len,
1280 1289
 			       le32_to_cpu ( rx_wb->flags ) );
1281
-			netdev_rx_err ( netdev, iobuf, -EIO );
1290
+			vlan_netdev_rx_err ( netdev, tag, iobuf, -EIO );
1282 1291
 		} else {
1283 1292
 			DBGC2 ( intelxl, "INTELXL %p RX %d complete (length "
1284 1293
 				"%zd)\n", intelxl, rx_idx, len );
1285
-			netdev_rx ( netdev, iobuf );
1294
+			vlan_netdev_rx ( netdev, tag, iobuf );
1286 1295
 		}
1287 1296
 		intelxl->rx.cons++;
1288 1297
 	}

+ 8
- 1
src/drivers/net/intelxl.h View File

@@ -582,7 +582,11 @@ struct intelxl_rx_data_descriptor {
582 582
 /** Receive writeback descriptor */
583 583
 struct intelxl_rx_writeback_descriptor {
584 584
 	/** Reserved */
585
-	uint8_t reserved[8];
585
+	uint8_t reserved_a[2];
586
+	/** VLAN tag */
587
+	uint16_t vlan;
588
+	/** Reserved */
589
+	uint8_t reserved_b[4];
586 590
 	/** Flags */
587 591
 	uint32_t flags;
588 592
 	/** Length */
@@ -592,6 +596,9 @@ struct intelxl_rx_writeback_descriptor {
592 596
 /** Receive writeback descriptor complete */
593 597
 #define INTELXL_RX_WB_FL_DD 0x00000001UL
594 598
 
599
+/** Receive writeback descriptor VLAN tag present */
600
+#define INTELXL_RX_WB_FL_VLAN 0x00000004UL
601
+
595 602
 /** Receive writeback descriptor error */
596 603
 #define INTELXL_RX_WB_FL_RXE 0x00080000UL
597 604
 

Loading…
Cancel
Save