From 47af0126d555dd66e4ba8e63d0b2ad89252c1b99 Mon Sep 17 00:00:00 2001 From: tsutsui Date: Fri, 24 Nov 2006 16:30:45 +0000 Subject: [PATCH] Change RXFIFO, RXDMA and TXDMA configrations to values taken from the Reaktek's driver, which are also used in FreeBSD. Fixes RX FIFO overrun errors on my Duron 1300MHz PC. (Note the configuration values for rtk(4) are not changed) Also add some debug printf's in RX error case (disabled by default). --- sys/dev/ic/rtl8169.c | 27 ++++++++++++++++++++++----- sys/dev/ic/rtl81x9reg.h | 8 +++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/sys/dev/ic/rtl8169.c b/sys/dev/ic/rtl8169.c index d1abfca0dd4b..863e9d5cc227 100644 --- a/sys/dev/ic/rtl8169.c +++ b/sys/dev/ic/rtl8169.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtl8169.c,v 1.69 2006/11/22 14:32:28 tsutsui Exp $ */ +/* $NetBSD: rtl8169.c,v 1.70 2006/11/24 16:30:45 tsutsui Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -1212,6 +1212,23 @@ re_rxeof(struct rtk_softc *sc) rxstat >>= 1; if ((rxstat & RE_RDESC_STAT_RXERRSUM) != 0) { +#ifdef RE_DEBUG + aprint_error("%s: RX error (rxstat = 0x%08x)", + sc->sc_dev.dv_xname, rxstat); + if (rxstat & RE_RDESC_STAT_FRALIGN) + aprint_error(", frame alignment error"); + if (rxstat & RE_RDESC_STAT_BUFOFLOW) + aprint_error(", out of buffer space"); + if (rxstat & RE_RDESC_STAT_FIFOOFLOW) + aprint_error(", FIFO overrun"); + if (rxstat & RE_RDESC_STAT_GIANT) + aprint_error(", giant packet"); + if (rxstat & RE_RDESC_STAT_RUNT) + aprint_error(", runt packet"); + if (rxstat & RE_RDESC_STAT_CRCERR) + aprint_error(", CRC error"); + aprint_error("\n"); +#endif ifp->if_ierrors++; /* * If this is part of a multi-fragment packet, @@ -1857,16 +1874,16 @@ re_init(struct ifnet *ifp) if (sc->re_testmode) { if (sc->rtk_type == RTK_8169) CSR_WRITE_4(sc, RTK_TXCFG, - RTK_TXCFG_CONFIG | RTK_LOOPTEST_ON); + RE_TXCFG_CONFIG | RTK_LOOPTEST_ON); else CSR_WRITE_4(sc, RTK_TXCFG, - RTK_TXCFG_CONFIG | RTK_LOOPTEST_ON_CPLUS); + RE_TXCFG_CONFIG | RTK_LOOPTEST_ON_CPLUS); } else - CSR_WRITE_4(sc, RTK_TXCFG, RTK_TXCFG_CONFIG); + CSR_WRITE_4(sc, RTK_TXCFG, RE_TXCFG_CONFIG); CSR_WRITE_1(sc, RTK_EARLY_TX_THRESH, 16); - CSR_WRITE_4(sc, RTK_RXCFG, RTK_RXCFG_CONFIG); + CSR_WRITE_4(sc, RTK_RXCFG, RE_RXCFG_CONFIG); /* Set the individual bit to receive frames for this host only. */ rxcfg = CSR_READ_4(sc, RTK_RXCFG); diff --git a/sys/dev/ic/rtl81x9reg.h b/sys/dev/ic/rtl81x9reg.h index 126865c3f6d4..7011bcc4fd58 100644 --- a/sys/dev/ic/rtl81x9reg.h +++ b/sys/dev/ic/rtl81x9reg.h @@ -1,4 +1,4 @@ -/* $NetBSD: rtl81x9reg.h,v 1.24 2006/11/18 07:22:06 tsutsui Exp $ */ +/* $NetBSD: rtl81x9reg.h,v 1.25 2006/11/24 16:30:45 tsutsui Exp $ */ /* * Copyright (c) 1997, 1998 @@ -432,6 +432,12 @@ #define RTK_RXCFG_CONFIG (RTK_RX_FIFOTHRESH|RTK_RX_MAXDMA|RTK_RX_BUF_SZ) #define RTK_TXCFG_CONFIG (RTK_TXCFG_IFG|RTK_TX_MAXDMA) +#define RE_RX_FIFOTHRESH RTK_RXFIFO_NOTHRESH +#define RE_RX_MAXDMA RTK_RXDMA_UNLIMITED +#define RE_TX_MAXDMA RTK_TXDMA_2048BYTES + +#define RE_RXCFG_CONFIG (RE_RX_FIFOTHRESH|RE_RX_MAXDMA|RTK_RX_BUF_SZ) +#define RE_TXCFG_CONFIG (RTK_TXCFG_IFG|RE_TX_MAXDMA) /* * RX/TX descriptor definition. When large send mode is enabled, the