Module Name:    src
Committed By:   yamaguchi
Date:           Fri Jun 17 06:18:09 UTC 2022

Modified Files:
        src/sys/dev/pci: if_iavf.c if_ixl.c

Log Message:
ixl(4), iavf(4): fix endian bug in vlan tag


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/if_iavf.c
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/pci/if_ixl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_iavf.c
diff -u src/sys/dev/pci/if_iavf.c:1.15 src/sys/dev/pci/if_iavf.c:1.16
--- src/sys/dev/pci/if_iavf.c:1.15	Sat Nov  6 22:11:39 2021
+++ src/sys/dev/pci/if_iavf.c	Fri Jun 17 06:18:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iavf.c,v 1.15 2021/11/06 22:11:39 andvar Exp $	*/
+/*	$NetBSD: if_iavf.c,v 1.16 2022/06/17 06:18:09 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2013-2015, Intel Corporation
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.15 2021/11/06 22:11:39 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.16 2022/06/17 06:18:09 yamaguchi Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -2699,8 +2699,9 @@ iavf_rxeof(struct iavf_softc *sc, struct
 			word0 = le64toh(rxd->qword0);
 
 			if (ISSET(word, IXL_RX_DESC_L2TAG1P)) {
-				vlan_set_tag(m,
-				    __SHIFTOUT(word0, IXL_RX_DESC_L2TAG1_MASK));
+				uint16_t vtag;
+				vtag = __SHIFTOUT(word0, IXL_RX_DESC_L2TAG1_MASK);
+				vlan_set_tag(m, le16toh(vtag));
 			}
 
 			if ((ifp->if_capenable & IAVF_IFCAP_RXCSUM) != 0)
@@ -3032,9 +3033,10 @@ iavf_tx_common_locked(struct ifnet *ifp,
 			iavf_tx_setup_offloads(m, &cmd_txd);
 		}
 		if (vlan_has_tag(m)) {
+			uint16_t vtag;
+			vtag = htole16(vlan_get_tag(m));
 			cmd_txd |= IXL_TX_DESC_CMD_IL2TAG1 |
-			    ((uint64_t)vlan_get_tag(m)
-			    << IXL_TX_DESC_L2TAG1_SHIFT);
+			    ((uint64_t)vtag << IXL_TX_DESC_L2TAG1_SHIFT);
 		}
 
 		bus_dmamap_sync(sc->sc_dmat, map, 0,

Index: src/sys/dev/pci/if_ixl.c
diff -u src/sys/dev/pci/if_ixl.c:1.83 src/sys/dev/pci/if_ixl.c:1.84
--- src/sys/dev/pci/if_ixl.c:1.83	Mon May 23 13:53:37 2022
+++ src/sys/dev/pci/if_ixl.c	Fri Jun 17 06:18:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ixl.c,v 1.83 2022/05/23 13:53:37 rin Exp $	*/
+/*	$NetBSD: if_ixl.c,v 1.84 2022/06/17 06:18:09 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2013-2015, Intel Corporation
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.83 2022/05/23 13:53:37 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.84 2022/06/17 06:18:09 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2714,7 +2714,9 @@ ixl_tx_common_locked(struct ifnet *ifp, 
 		}
 
 		if (vlan_has_tag(m)) {
-			cmd_txd |= (uint64_t)vlan_get_tag(m) <<
+			uint16_t vtag;
+			vtag = htole16(vlan_get_tag(m));
+			cmd_txd |= (uint64_t)vtag <<
 			    IXL_TX_DESC_L2TAG1_SHIFT;
 			cmd_txd |= IXL_TX_DESC_CMD_IL2TAG1;
 		}
@@ -3223,8 +3225,9 @@ ixl_rxeof(struct ixl_softc *sc, struct i
 			word0 = le64toh(rxd->qword0);
 
 			if (ISSET(word, IXL_RX_DESC_L2TAG1P)) {
-				vlan_set_tag(m,
-				    __SHIFTOUT(word0, IXL_RX_DESC_L2TAG1_MASK));
+				uint16_t vtag;
+				vtag = __SHIFTOUT(word0, IXL_RX_DESC_L2TAG1_MASK);
+				vlan_set_tag(m, le16toh(vtag));
 			}
 
 			if ((ifp->if_capenable & IXL_IFCAP_RXCSUM) != 0)

Reply via email to