]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[intelxl] Use VLAN tag in receive descriptor if present
authorMichael Brown <mcb30@ipxe.org>
Sat, 27 Apr 2019 19:21:22 +0000 (20:21 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sat, 27 Apr 2019 19:25:57 +0000 (20:25 +0100)
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>
src/drivers/net/intelxl.c
src/drivers/net/intelxl.h

index 3e40fa4ae32d7a8743963af7fe61e4cb8882c809..66221cbaffec623680aef733111dedba9bbc8a3f 100644 (file)
@@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/netdevice.h>
 #include <ipxe/ethernet.h>
 #include <ipxe/if_ether.h>
+#include <ipxe/vlan.h>
 #include <ipxe/iobuf.h>
 #include <ipxe/malloc.h>
 #include <ipxe/pci.h>
@@ -1254,6 +1255,7 @@ static void intelxl_poll_rx ( struct net_device *netdev ) {
        struct intelxl_rx_writeback_descriptor *rx_wb;
        struct io_buffer *iobuf;
        unsigned int rx_idx;
+       unsigned int tag;
        size_t len;
 
        /* Check for received packets */
@@ -1273,16 +1275,23 @@ static void intelxl_poll_rx ( struct net_device *netdev ) {
                len = INTELXL_RX_WB_LEN ( le32_to_cpu ( rx_wb->len ) );
                iob_put ( iobuf, len );
 
+               /* Find VLAN device, if applicable */
+               if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_VLAN ) ) {
+                       tag = VLAN_TAG ( le16_to_cpu ( rx_wb->vlan ) );
+               } else {
+                       tag = 0;
+               }
+
                /* Hand off to network stack */
                if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_RXE ) ) {
                        DBGC ( intelxl, "INTELXL %p RX %d error (length %zd, "
                               "flags %08x)\n", intelxl, rx_idx, len,
                               le32_to_cpu ( rx_wb->flags ) );
-                       netdev_rx_err ( netdev, iobuf, -EIO );
+                       vlan_netdev_rx_err ( netdev, tag, iobuf, -EIO );
                } else {
                        DBGC2 ( intelxl, "INTELXL %p RX %d complete (length "
                                "%zd)\n", intelxl, rx_idx, len );
-                       netdev_rx ( netdev, iobuf );
+                       vlan_netdev_rx ( netdev, tag, iobuf );
                }
                intelxl->rx.cons++;
        }
index 02d9b98a2d60f07352464a01f6cbd1df60d6308a..fd3fc75b808851492e78dac834d7c3c51f9aad7d 100644 (file)
@@ -582,7 +582,11 @@ struct intelxl_rx_data_descriptor {
 /** Receive writeback descriptor */
 struct intelxl_rx_writeback_descriptor {
        /** Reserved */
-       uint8_t reserved[8];
+       uint8_t reserved_a[2];
+       /** VLAN tag */
+       uint16_t vlan;
+       /** Reserved */
+       uint8_t reserved_b[4];
        /** Flags */
        uint32_t flags;
        /** Length */
@@ -592,6 +596,9 @@ struct intelxl_rx_writeback_descriptor {
 /** Receive writeback descriptor complete */
 #define INTELXL_RX_WB_FL_DD 0x00000001UL
 
+/** Receive writeback descriptor VLAN tag present */
+#define INTELXL_RX_WB_FL_VLAN 0x00000004UL
+
 /** Receive writeback descriptor error */
 #define INTELXL_RX_WB_FL_RXE 0x00080000UL