Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci ixl(4), iavf(4): fix endian bug in vlan tag



details:   https://anonhg.NetBSD.org/src/rev/9d08ea54d336
branches:  trunk
changeset: 366812:9d08ea54d336
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Fri Jun 17 06:18:09 2022 +0000

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

diffstat:

 sys/dev/pci/if_iavf.c |  14 ++++++++------
 sys/dev/pci/if_ixl.c  |  13 ++++++++-----
 2 files changed, 16 insertions(+), 11 deletions(-)

diffs (84 lines):

diff -r 3e302c156e10 -r 9d08ea54d336 sys/dev/pci/if_iavf.c
--- a/sys/dev/pci/if_iavf.c     Fri Jun 17 05:49:35 2022 +0000
+++ b/sys/dev/pci/if_iavf.c     Fri Jun 17 06:18:09 2022 +0000
@@ -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 @@
                        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_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,
diff -r 3e302c156e10 -r 9d08ea54d336 sys/dev/pci/if_ixl.c
--- a/sys/dev/pci/if_ixl.c      Fri Jun 17 05:49:35 2022 +0000
+++ b/sys/dev/pci/if_ixl.c      Fri Jun 17 06:18:09 2022 +0000
@@ -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 @@
                }
 
                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 @@
                        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)



Home | Main Index | Thread Index | Old Index