Module Name: src Committed By: martin Date: Fri Aug 4 15:06:50 UTC 2023
Modified Files: src/sys/dev/ic [netbsd-9]: rtl8169.c rtl81x9reg.h rtl81x9var.h Log Message: Pull up following revision(s) (requested by jakllsch in ticket #1705): sys/dev/ic/rtl81x9var.h: revision 1.58 sys/dev/ic/rtl81x9reg.h: revision 1.54 sys/dev/ic/rtl8169.c: revision 1.167 sys/dev/ic/rtl8169.c: revision 1.168 re(4): misc chip revision support changes * remove impossible-to-match chip revision cases * bring support for modern chips in line with FreeBSD and OpenBSD * adds support for RTL8168GU Addresses PR kern/56312. - Print chip revision. From OpenBSD. - Rename RTK_HWREV_8168_SPIN[123] to RTK_HWREV_8168'B'_SPIN[123]. Same as other *BSDs. - Rename RTK_HWREV_8168G_SPIN4 to RTK_HWREV_8411B. Same as other *BSDs. - Add definition of RTK_HWREV_8169_8110SCE. To generate a diff of this commit: cvs rdiff -u -r1.159.2.1 -r1.159.2.2 src/sys/dev/ic/rtl8169.c cvs rdiff -u -r1.50.4.1 -r1.50.4.2 src/sys/dev/ic/rtl81x9reg.h cvs rdiff -u -r1.56.18.1 -r1.56.18.2 src/sys/dev/ic/rtl81x9var.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/ic/rtl8169.c diff -u src/sys/dev/ic/rtl8169.c:1.159.2.1 src/sys/dev/ic/rtl8169.c:1.159.2.2 --- src/sys/dev/ic/rtl8169.c:1.159.2.1 Tue Jan 28 11:12:30 2020 +++ src/sys/dev/ic/rtl8169.c Fri Aug 4 15:06:50 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $ */ +/* $NetBSD: rtl8169.c,v 1.159.2.2 2023/08/04 15:06:50 martin Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159.2.2 2023/08/04 15:06:50 martin Exp $"); /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */ /* @@ -172,6 +172,54 @@ static void re_miibus_statchg(struct ifn static void re_reset(struct rtk_softc *); +static const struct re_revision { + uint32_t re_chipid; + const char *re_name; +} re_revisions[] = { + { RTK_HWREV_8100, "RTL8100" }, + { RTK_HWREV_8100E, "RTL8100E" }, + { RTK_HWREV_8100E_SPIN2, "RTL8100E 2" }, + { RTK_HWREV_8101, "RTL8101" }, + { RTK_HWREV_8101E, "RTL8101E" }, + { RTK_HWREV_8102E, "RTL8102E" }, + { RTK_HWREV_8106E, "RTL8106E" }, + { RTK_HWREV_8401E, "RTL8401E" }, + { RTK_HWREV_8402, "RTL8402" }, + { RTK_HWREV_8411, "RTL8411" }, + { RTK_HWREV_8411B, "RTL8411B" }, + { RTK_HWREV_8102EL, "RTL8102EL" }, + { RTK_HWREV_8102EL_SPIN1, "RTL8102EL 1" }, + { RTK_HWREV_8103E, "RTL8103E" }, + { RTK_HWREV_8110S, "RTL8110S" }, + { RTK_HWREV_8139CPLUS, "RTL8139C+" }, + { RTK_HWREV_8168B_SPIN1, "RTL8168 1" }, + { RTK_HWREV_8168B_SPIN2, "RTL8168 2" }, + { RTK_HWREV_8168B_SPIN3, "RTL8168 3" }, + { RTK_HWREV_8168C, "RTL8168C/8111C" }, + { RTK_HWREV_8168C_SPIN2, "RTL8168C/8111C" }, + { RTK_HWREV_8168CP, "RTL8168CP/8111CP" }, + { RTK_HWREV_8168F, "RTL8168F/8111F" }, + { RTK_HWREV_8168G, "RTL8168G/8111G" }, + { RTK_HWREV_8168GU, "RTL8168GU/8111GU" }, + { RTK_HWREV_8168H, "RTL8168H/8111H" }, + { RTK_HWREV_8105E, "RTL8105E" }, + { RTK_HWREV_8105E_SPIN1, "RTL8105E" }, + { RTK_HWREV_8168D, "RTL8168D/8111D" }, + { RTK_HWREV_8168DP, "RTL8168DP/8111DP" }, + { RTK_HWREV_8168E, "RTL8168E/8111E" }, + { RTK_HWREV_8168E_VL, "RTL8168E/8111E-VL" }, + { RTK_HWREV_8168EP, "RTL8168EP/8111EP" }, + { RTK_HWREV_8168FP, "RTL8168FP/8117" }, + { RTK_HWREV_8169, "RTL8169" }, + { RTK_HWREV_8169_8110SB, "RTL8169/8110SB" }, + { RTK_HWREV_8169_8110SBL, "RTL8169SBL" }, + { RTK_HWREV_8169_8110SC, "RTL8169/8110SCd" }, + { RTK_HWREV_8169_8110SCE, "RTL8169/8110SCe" }, + { RTK_HWREV_8169S, "RTL8169S" }, + + { 0, NULL } +}; + static inline void re_set_bufaddr(struct re_desc *d, bus_addr_t addr) { @@ -562,13 +610,26 @@ re_attach(struct rtk_softc *sc) struct ifnet *ifp; struct mii_data *mii = &sc->mii; int error = 0, i; + const struct re_revision *rr; + const char *re_name = NULL; if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) { - uint32_t hwrev; - /* Revision of 8169/8169S/8110s in bits 30..26, 23 */ - hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV; - switch (hwrev) { + sc->sc_hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV; + + for (rr = re_revisions; rr->re_name != NULL; rr++) { + if (rr->re_chipid == sc->sc_hwrev) + re_name = rr->re_name; + } + + if (re_name == NULL) + aprint_normal_dev(sc->sc_dev, + "unknown ASIC (0x%04x)\n", sc->sc_hwrev >> 16); + else + aprint_normal_dev(sc->sc_dev, + "%s (0x%04x)\n", re_name, sc->sc_hwrev >> 16); + + switch (sc->sc_hwrev) { case RTK_HWREV_8169: sc->sc_quirk |= RTKQ_8169NONS; break; @@ -579,9 +640,9 @@ re_attach(struct rtk_softc *sc) case RTK_HWREV_8169_8110SC: sc->sc_quirk |= RTKQ_MACLDPS; break; - case RTK_HWREV_8168_SPIN1: - case RTK_HWREV_8168_SPIN2: - case RTK_HWREV_8168_SPIN3: + case RTK_HWREV_8168B_SPIN1: + case RTK_HWREV_8168B_SPIN2: + case RTK_HWREV_8168B_SPIN3: sc->sc_quirk |= RTKQ_MACSTAT; break; case RTK_HWREV_8168C: @@ -607,17 +668,10 @@ re_attach(struct rtk_softc *sc) sc->sc_quirk |= RTKQ_NOJUMBO; break; case RTK_HWREV_8168E: - case RTK_HWREV_8168H_SPIN1: sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM | RTKQ_NOJUMBO; break; - case RTK_HWREV_8168H: - case RTK_HWREV_8168FP: - sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | - RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM | - RTKQ_NOJUMBO | RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER; - break; case RTK_HWREV_8168E_VL: case RTK_HWREV_8168F: case RTK_HWREV_8411: @@ -625,13 +679,14 @@ re_attach(struct rtk_softc *sc) RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO; break; case RTK_HWREV_8168EP: + case RTK_HWREV_8168FP: case RTK_HWREV_8168G: - case RTK_HWREV_8168G_SPIN1: - case RTK_HWREV_8168G_SPIN2: - case RTK_HWREV_8168G_SPIN4: + case RTK_HWREV_8168GU: + case RTK_HWREV_8168H: + case RTK_HWREV_8411B: sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO | - RTKQ_RXDV_GATED; + RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER; break; case RTK_HWREV_8100E: case RTK_HWREV_8100E_SPIN2: @@ -650,7 +705,7 @@ re_attach(struct rtk_softc *sc) break; case RTK_HWREV_8401E: case RTK_HWREV_8105E: - case RTK_HWREV_8105E_SPIN1: + case RTK_HWREV_8105E_SPIN1: /* XXX */ case RTK_HWREV_8106E: sc->sc_quirk |= RTKQ_PHYWAKE_PM | RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | @@ -662,8 +717,7 @@ re_attach(struct rtk_softc *sc) RTKQ_CMDSTOP; /* CMDSTOP_WAIT_TXQ */ break; default: - aprint_normal_dev(sc->sc_dev, - "Unknown revision (0x%08x)\n", hwrev); + aprint_normal_dev(sc->sc_dev, "Use default quirks\n"); /* assume the latest features */ sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD; sc->sc_quirk |= RTKQ_NOJUMBO; Index: src/sys/dev/ic/rtl81x9reg.h diff -u src/sys/dev/ic/rtl81x9reg.h:1.50.4.1 src/sys/dev/ic/rtl81x9reg.h:1.50.4.2 --- src/sys/dev/ic/rtl81x9reg.h:1.50.4.1 Tue Jan 28 11:12:30 2020 +++ src/sys/dev/ic/rtl81x9reg.h Fri Aug 4 15:06:50 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: rtl81x9reg.h,v 1.50.4.1 2020/01/28 11:12:30 martin Exp $ */ +/* $NetBSD: rtl81x9reg.h,v 1.50.4.2 2023/08/04 15:06:50 martin Exp $ */ /* * Copyright (c) 1997, 1998 @@ -166,13 +166,13 @@ #define RTK_HWREV_8168DP 0x28800000 #define RTK_HWREV_8168E 0x2C000000 #define RTK_HWREV_8168E_VL 0x2C800000 -#define RTK_HWREV_8168_SPIN1 0x30000000 +#define RTK_HWREV_8168B_SPIN1 0x30000000 #define RTK_HWREV_8100E 0x30800000 #define RTK_HWREV_8101E 0x34000000 #define RTK_HWREV_8102E 0x34800000 #define RTK_HWREV_8103E 0x34c00000 -#define RTK_HWREV_8168_SPIN2 0x38000000 -#define RTK_HWREV_8168_SPIN3 0x38400000 +#define RTK_HWREV_8168B_SPIN2 0x38000000 +#define RTK_HWREV_8168B_SPIN3 0x38400000 #define RTK_HWREV_8100E_SPIN2 0x38800000 #define RTK_HWREV_8168C 0x3C000000 #define RTK_HWREV_8168C_SPIN2 0x3C400000 @@ -191,7 +191,7 @@ #define RTK_HWREV_8168H 0x54000000 #define RTK_HWREV_8168H_SPIN1 0x54100000 #define RTK_HWREV_8168FP 0x54800000 -#define RTK_HWREV_8168G_SPIN4 0x5c800000 +#define RTK_HWREV_8411B 0x5c800000 #define RTK_HWREV_8139 0x60000000 #define RTK_HWREV_8139A 0x70000000 #define RTK_HWREV_8139AG 0x70800000 @@ -203,6 +203,7 @@ #define RTK_HWREV_8100 0x78800000 #define RTK_HWREV_8130 0x7C000000 #define RTK_HWREV_8169_8110SBL 0x7cc00000 +#define RTK_HWREV_8169_8110SCE 0x98000000 #define RTK_TXDMA_16BYTES 0x00000000 #define RTK_TXDMA_32BYTES 0x00000100 Index: src/sys/dev/ic/rtl81x9var.h diff -u src/sys/dev/ic/rtl81x9var.h:1.56.18.1 src/sys/dev/ic/rtl81x9var.h:1.56.18.2 --- src/sys/dev/ic/rtl81x9var.h:1.56.18.1 Tue Jan 28 11:12:30 2020 +++ src/sys/dev/ic/rtl81x9var.h Fri Aug 4 15:06:50 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: rtl81x9var.h,v 1.56.18.1 2020/01/28 11:12:30 martin Exp $ */ +/* $NetBSD: rtl81x9var.h,v 1.56.18.2 2023/08/04 15:06:50 martin Exp $ */ /* * Copyright (c) 1997, 1998 @@ -176,6 +176,7 @@ struct rtk_softc { device_t sc_dev; struct ethercom ethercom; /* interface info */ struct mii_data mii; + uint32_t sc_hwrev; struct callout rtk_tick_ch; /* tick callout */ bus_space_tag_t rtk_btag; /* bus space tag */ bus_space_handle_t rtk_bhandle; /* bus space handle */