Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Add new flag named WM_F_CRC_STRIP and use it. No...



details:   https://anonhg.NetBSD.org/src/rev/3f25cd2b1864
branches:  trunk
changeset: 955024:3f25cd2b1864
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Sep 15 08:39:04 2020 +0000

description:
Add new flag named WM_F_CRC_STRIP and use it. No functional change.

 This change also sets the RCTL_SECRC bit on I211 but it doesn't change
the behavior because I211 always strips CRC like I35[04] and I210.

diffstat:

 sys/dev/pci/if_wm.c    |  36 +++++++++++++++++++-----------------
 sys/dev/pci/if_wmvar.h |   5 +++--
 2 files changed, 22 insertions(+), 19 deletions(-)

diffs (99 lines):

diff -r 327eda44c239 -r 3f25cd2b1864 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Tue Sep 15 08:33:40 2020 +0000
+++ b/sys/dev/pci/if_wm.c       Tue Sep 15 08:39:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.686 2020/08/24 05:34:00 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.687 2020/09/15 08:39:04 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.686 2020/08/24 05:34:00 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.687 2020/09/15 08:39:04 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2887,6 +2887,14 @@
                        sc->sc_flags |= WM_F_EEE;
        }
 
+       /*
+        * The I350 has a bug where it always strips the CRC whether
+        * asked to or not. So ask for stripped CRC here and cope in rxeof
+        */
+       if ((sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354)
+           || (sc->sc_type == WM_T_I210) || (sc->sc_type == WM_T_I211))
+               sc->sc_flags |= WM_F_CRC_STRIP;
+
        /* Set device properties (macflags) */
        prop_dictionary_set_uint32(dict, "macflags", sc->sc_flags);
 
@@ -6311,12 +6319,7 @@
        if (sc->sc_type == WM_T_82574)
                sc->sc_rctl |= RCTL_DTYP_ONEBUF;
 
-       /*
-        * The I350 has a bug where it always strips the CRC whether
-        * asked to or not. So ask for stripped CRC here and cope in rxeof
-        */
-       if ((sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354)
-           || (sc->sc_type == WM_T_I210))
+       if ((sc->sc_flags & WM_F_CRC_STRIP) != 0)
                sc->sc_rctl |= RCTL_SECRC;
 
        if (((ec->ec_capabilities & ETHERCAP_JUMBO_MTU) != 0)
@@ -9057,17 +9060,16 @@
 
                /*
                 * Okay, we have the entire packet now. The chip is
-                * configured to include the FCS except I350 and I21[01]
-                * (not all chips can be configured to strip it),
-                * so we need to trim it.
+                * configured to include the FCS except I35[05], I21[01].
+                * (not all chips can be configured to strip it), so we need
+                * to trim it. Those chips have an eratta, the RCTL_SECRC bit
+                * in RCTL register is always set, so we don't trim it.
+                * PCH2 and newer chip also not include FCS when jumbo
+                * frame is used to do workaround an errata.
                 * May need to adjust length of previous mbuf in the
                 * chain if the current mbuf is too short.
-                * For an eratta, the RCTL_SECRC bit in RCTL register
-                * is always set in I350, so we don't trim it.
-                */
-               if ((sc->sc_type != WM_T_I350) && (sc->sc_type != WM_T_I354)
-                   && (sc->sc_type != WM_T_I210)
-                   && (sc->sc_type != WM_T_I211)) {
+                */
+               if ((sc->sc_flags & WM_F_CRC_STRIP) == 0) {
                        if (m->m_len < ETHER_CRC_LEN) {
                                rxq->rxq_tail->m_len
                                    -= (ETHER_CRC_LEN - m->m_len);
diff -r 327eda44c239 -r 3f25cd2b1864 sys/dev/pci/if_wmvar.h
--- a/sys/dev/pci/if_wmvar.h    Tue Sep 15 08:33:40 2020 +0000
+++ b/sys/dev/pci/if_wmvar.h    Tue Sep 15 08:39:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wmvar.h,v 1.45 2019/12/11 10:28:19 msaitoh Exp $    */
+/*     $NetBSD: if_wmvar.h,v 1.46 2020/09/15 08:39:04 msaitoh Exp $    */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -99,6 +99,7 @@
 #define        WM_F_WA_I210_CLSEM      0x08000000 /* I21[01] Semaphore workaround */
 #define        WM_F_SFP                0x10000000 /* SFP */
 #define        WM_F_MAS                0x20000000 /* Media Auto Sense */
+#define        WM_F_CRC_STRIP          0x40000000 /* CRC strip */
 
 #define WM_FLAGS "\20" \
        "\1" "HAS_MII"  "\2" "LOCK_EECD" "\3" "_B02"    "\4" "_B03"     \
@@ -108,7 +109,7 @@
        "\21" "NEWQUEUE" "\22" "ASF_FIRM" "\23" "ARC_SUBSYS" "\24" "AMT" \
        "\25" "MANAGE"  "\26" "WOL"     "\27" "EEE"     "\30" "ATTACHED" \
        "\31" "MDIC_WA" "\32" "PCS_DIS_AUTONEGO" "\33" "PLLWA" "\34" "CLSEMWA" \
-       "\35" "SFP"     "\36" "MAS"
+       "\35" "SFP"     "\36" "MAS"     "\37" "CRC_STRIP"
 
 /*
  * Variations of Intel gigabit Ethernet controller:



Home | Main Index | Thread Index | Old Index