Module Name: src Committed By: msaitoh Date: Tue Sep 15 08:39:04 UTC 2020
Modified Files: src/sys/dev/pci: if_wm.c if_wmvar.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.686 -r1.687 src/sys/dev/pci/if_wm.c cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/if_wmvar.h 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_wm.c diff -u src/sys/dev/pci/if_wm.c:1.686 src/sys/dev/pci/if_wm.c:1.687 --- src/sys/dev/pci/if_wm.c:1.686 Mon Aug 24 05:34:00 2020 +++ src/sys/dev/pci/if_wm.c Tue Sep 15 08:39:04 2020 @@ -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 @@ alloc_retry: 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 @@ wm_init_locked(struct ifnet *ifp) 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 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l /* * 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); Index: src/sys/dev/pci/if_wmvar.h diff -u src/sys/dev/pci/if_wmvar.h:1.45 src/sys/dev/pci/if_wmvar.h:1.46 --- src/sys/dev/pci/if_wmvar.h:1.45 Wed Dec 11 10:28:19 2019 +++ src/sys/dev/pci/if_wmvar.h Tue Sep 15 08:39:04 2020 @@ -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: