Module Name: src Committed By: tsutsui Date: Fri May 10 14:05:57 UTC 2013
Modified Files: src/sys/dev/ic: rtl8169.c Log Message: Make re(4) driver always use IDR register values for its MAC address. Some sandpoint NAS firmwares set MAC address per their firmware settings and don't use re(4)'s EEPROM values. Per rtl8169 manuals re(4) chip reads EEPROM automatically after hardware reset and Linux driver also uses IDR registers, so this change should not affect existing other boards which actually have vaild EEPROM. Per discussion in old tech-kern@ thread: http://mail-index.netbsd.org/tech-kern/2012/12/01/msg014573.html Note rtl81x9.c is still shared among rtk(4) only for a multicast function (to avoid boring refactoring work). To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/dev/ic/rtl8169.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/rtl8169.c diff -u src/sys/dev/ic/rtl8169.c:1.137 src/sys/dev/ic/rtl8169.c:1.138 --- src/sys/dev/ic/rtl8169.c:1.137 Sat Apr 6 01:53:14 2013 +++ src/sys/dev/ic/rtl8169.c Fri May 10 14:05:57 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rtl8169.c,v 1.137 2013/04/06 01:53:14 khorben Exp $ */ +/* $NetBSD: rtl8169.c,v 1.138 2013/05/10 14:05:57 tsutsui Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.137 2013/04/06 01:53:14 khorben Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.138 2013/05/10 14:05:57 tsutsui Exp $"); /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */ /* @@ -554,9 +554,8 @@ void re_attach(struct rtk_softc *sc) { uint8_t eaddr[ETHER_ADDR_LEN]; - uint16_t val; struct ifnet *ifp; - int error = 0, i, addr_len; + int error = 0, i; if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) { uint32_t hwrev; @@ -644,6 +643,12 @@ re_attach(struct rtk_softc *sc) /* Reset the adapter. */ re_reset(sc); + /* + * RTL81x9 chips automatically read EEPROM to init MAC address, + * and some NAS override its MAC address per own configuration, + * so no need to explicitely read EEPROM and set ID registers. + */ +#ifdef RE_USE_EECMD if ((sc->sc_quirk & RTKQ_NOEECMD) != 0) { /* * Get station address from ID registers. @@ -651,6 +656,9 @@ re_attach(struct rtk_softc *sc) for (i = 0; i < ETHER_ADDR_LEN; i++) eaddr[i] = CSR_READ_1(sc, RTK_IDR0 + i); } else { + uint16_t val; + int addr_len; + /* * Get station address from the EEPROM. */ @@ -668,6 +676,13 @@ re_attach(struct rtk_softc *sc) eaddr[(i * 2) + 1] = val >> 8; } } +#else + /* + * Get station address from ID registers. + */ + for (i = 0; i < ETHER_ADDR_LEN; i++) + eaddr[i] = CSR_READ_1(sc, RTK_IDR0 + i); +#endif /* Take PHY out of power down mode. */ if ((sc->sc_quirk & RTKQ_PHYWAKE_PM) != 0) @@ -1726,11 +1741,13 @@ static int re_init(struct ifnet *ifp) { struct rtk_softc *sc = ifp->if_softc; - const uint8_t *enaddr; uint32_t rxcfg = 0; - uint32_t reg; uint16_t cfg; int error; +#ifdef RE_USE_EECMD + const uint8_t *enaddr; + uint32_t reg; +#endif if ((error = re_enable(sc)) != 0) goto out; @@ -1775,6 +1792,7 @@ re_init(struct ifnet *ifp) DELAY(10000); +#ifdef RE_USE_EECMD /* * Init our MAC address. Even though the chipset * documentation doesn't mention it, we need to enter "Config @@ -1788,6 +1806,7 @@ re_init(struct ifnet *ifp) reg = enaddr[4] | (enaddr[5] << 8); CSR_WRITE_4(sc, RTK_IDR4, reg); CSR_WRITE_1(sc, RTK_EECMD, RTK_EEMODE_OFF); +#endif /* * For C+ mode, initialize the RX descriptors and mbufs.