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

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

582
 /** Receive writeback descriptor */
582
 /** Receive writeback descriptor */
583
 struct intelxl_rx_writeback_descriptor {
583
 struct intelxl_rx_writeback_descriptor {
584
 	/** Reserved */
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
 	/** Flags */
590
 	/** Flags */
587
 	uint32_t flags;
591
 	uint32_t flags;
588
 	/** Length */
592
 	/** Length */
592
 /** Receive writeback descriptor complete */
596
 /** Receive writeback descriptor complete */
593
 #define INTELXL_RX_WB_FL_DD 0x00000001UL
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
 /** Receive writeback descriptor error */
602
 /** Receive writeback descriptor error */
596
 #define INTELXL_RX_WB_FL_RXE 0x00080000UL
603
 #define INTELXL_RX_WB_FL_RXE 0x00080000UL
597
 
604
 

Loading…
Cancel
Save