Module Name:    src
Committed By:   sekiya
Date:           Tue Aug  9 23:58:46 UTC 2022

Modified Files:
        src/sys/dev/ic: dwc_gmac.c

Log Message:
Turn off AWIN_GMAC_MAC_CONF_ACS, so that all received packets retain FCS
bytes.

ether_input() can now trust M_HASFCS to accurately represent the packet
contents.

Discussed on tech-net@


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.76 src/sys/dev/ic/dwc_gmac.c:1.77
--- src/sys/dev/ic/dwc_gmac.c:1.76	Fri Aug  5 21:03:43 2022
+++ src/sys/dev/ic/dwc_gmac.c	Tue Aug  9 23:58:46 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.76 2022/08/05 21:03:43 sekiya Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.77 2022/08/09 23:58:46 sekiya Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.76 2022/08/05 21:03:43 sekiya Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.77 2022/08/09 23:58:46 sekiya Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -803,7 +803,6 @@ dwc_gmac_miibus_statchg(struct ifnet *if
 	conf |= AWIN_GMAC_MAC_CONF_FRAMEBURST
 	    | AWIN_GMAC_MAC_CONF_DISABLERXOWN
 	    | AWIN_GMAC_MAC_CONF_DISABLEJABBER
-	    | AWIN_GMAC_MAC_CONF_ACS
 	    | AWIN_GMAC_MAC_CONF_RXENABLE
 	    | AWIN_GMAC_MAC_CONF_TXENABLE;
 	switch (IFM_SUBTYPE(mii->mii_media_active)) {
@@ -1229,8 +1228,6 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 	struct mbuf *m, *mnew;
 	int i, len, error;
 
-	uint16_t etype;
-
 	mutex_enter(&sc->sc_rxq.r_mtx);
 	for (i = sc->sc_rxq.r_cur; ; i = RX_NEXT(i)) {
 		bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
@@ -1313,29 +1310,8 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 		/* finalize mbuf */
 		m->m_pkthdr.len = m->m_len = len;
 		m_set_rcvif(m, ifp);
+		m->m_flags |= M_HASFCS;
 
-#define ETYPE_OFFSET 20
-		etype = (m->m_data[ETYPE_OFFSET] << 8) + m->m_data[ETYPE_OFFSET+1];
-
-		/*
-		 * The hardware doesn't trim the four FCS bytes for us, so
-		 * we need to trim it ourselves.
-		 * Having the upper layer remove it by passing M_HASFCS breaks
-		 * protocols that don't have FCS bytes at the end of the packet
-		 * (AppleTalk, for example), so we do it here instead.
-		 */
-
-		switch (etype) {
-			case ETHERTYPE_ATALK:
-			case ETHERTYPE_AARP:
-				/* No FCS removal needed */
-				break;
-			default:
-				/* remove FCS */
-				m_adj(m, -ETHER_CRC_LEN);
-				break;
-		}
-	
 		if_percpuq_enqueue(sc->sc_ipq, m);
 
 skip:

Reply via email to