Pull up following revision(s) (requested by msaitoh in ticket #667): sys/dev/ic/rtl81x9var.h: revision 1.57 sys/dev/ic/rtl81x9.c: revision 1.107 sys/dev/ic/rtl81x9reg.h: revision 1.51 sys/dev/ic/rtl8169.c: revision 1.160 sys/dev/ic/rtl81x9reg.h: revision 1.52 sys/dev/ic/rtl8169.c: revision 1.161 Use unsigned in rtk_setmulti() to avoid undefined behavior. Found bk kUBSan. 8168H model didn't link up well. some models seems to require to enable TX/RX after configuration. RTKQ_TXRXEN_LATER quirk flag added. it may be able to unify with RTKQ_RXDV_GATED flag? Sort RTK_HWREV_* by value. Improve some chip revisions support: - Add 8168FP, 8411, 8168G, 8401E, 8105E, 8105E_SPIN1, 8106E and 8402 from {Free,Open}BSD. - Renumber RTK_HWREV_8103E from 0x24C00000 to 0x34c00000. 0x24C00000 is newly used as RTK_HWREV_8102EL_SPIN1. Same as {Free,Open}BSD.diff -r1.159 -r1.159.2.1 src/sys/dev/ic/rtl8169.c
(martin)
--- src/sys/dev/ic/rtl8169.c 2019/05/30 02:32:18 1.159
+++ src/sys/dev/ic/rtl8169.c 2020/01/28 11:12:30 1.159.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $ */ | 1 | /* $NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997, 1998-2003 | 4 | * Copyright (c) 1997, 1998-2003 | |
5 | * Bill Paul <wpaul@windriver.com>. All rights reserved. | 5 | * Bill Paul <wpaul@windriver.com>. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD | |
26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
32 | * THE POSSIBILITY OF SUCH DAMAGE. | 32 | * THE POSSIBILITY OF SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | __KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $"); | 36 | __KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $"); | |
37 | /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */ | 37 | /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */ | |
38 | 38 | |||
39 | /* | 39 | /* | |
40 | * RealTek 8139C+/8169/8169S/8168/8110S PCI NIC driver | 40 | * RealTek 8139C+/8169/8169S/8168/8110S PCI NIC driver | |
41 | * | 41 | * | |
42 | * Written by Bill Paul <wpaul@windriver.com> | 42 | * Written by Bill Paul <wpaul@windriver.com> | |
43 | * Senior Networking Software Engineer | 43 | * Senior Networking Software Engineer | |
44 | * Wind River Systems | 44 | * Wind River Systems | |
45 | */ | 45 | */ | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | * This driver is designed to support RealTek's next generation of | 48 | * This driver is designed to support RealTek's next generation of | |
49 | * 10/100 and 10/100/1000 PCI ethernet controllers. There are currently | 49 | * 10/100 and 10/100/1000 PCI ethernet controllers. There are currently | |
@@ -597,56 +597,80 @@ re_attach(struct rtk_softc *sc) | @@ -597,56 +597,80 @@ re_attach(struct rtk_softc *sc) | |||
597 | * These (8168/8111) controllers support jumbo frame | 597 | * These (8168/8111) controllers support jumbo frame | |
598 | * but it seems that enabling it requires touching | 598 | * but it seems that enabling it requires touching | |
599 | * additional magic registers. Depending on MAC | 599 | * additional magic registers. Depending on MAC | |
600 | * revisions some controllers need to disable | 600 | * revisions some controllers need to disable | |
601 | * checksum offload. So disable jumbo frame until | 601 | * checksum offload. So disable jumbo frame until | |
602 | * I have better idea what it really requires to | 602 | * I have better idea what it really requires to | |
603 | * make it support. | 603 | * make it support. | |
604 | * RTL8168C/CP : supports up to 6KB jumbo frame. | 604 | * RTL8168C/CP : supports up to 6KB jumbo frame. | |
605 | * RTL8111C/CP : supports up to 9KB jumbo frame. | 605 | * RTL8111C/CP : supports up to 9KB jumbo frame. | |
606 | */ | 606 | */ | |
607 | sc->sc_quirk |= RTKQ_NOJUMBO; | 607 | sc->sc_quirk |= RTKQ_NOJUMBO; | |
608 | break; | 608 | break; | |
609 | case RTK_HWREV_8168E: | 609 | case RTK_HWREV_8168E: | |
610 | case RTK_HWREV_8168H: | |||
611 | case RTK_HWREV_8168H_SPIN1: | 610 | case RTK_HWREV_8168H_SPIN1: | |
612 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | 611 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | |
613 | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM | | 612 | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM | | |
614 | RTKQ_NOJUMBO; | 613 | RTKQ_NOJUMBO; | |
615 | break; | 614 | break; | |
615 | case RTK_HWREV_8168H: | |||
616 | case RTK_HWREV_8168FP: | |||
617 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | |||
618 | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM | | |||
619 | RTKQ_NOJUMBO | RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER; | |||
620 | break; | |||
616 | case RTK_HWREV_8168E_VL: | 621 | case RTK_HWREV_8168E_VL: | |
617 | case RTK_HWREV_8168F: | 622 | case RTK_HWREV_8168F: | |
623 | case RTK_HWREV_8411: | |||
618 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | 624 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | |
619 | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO; | 625 | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO; | |
620 | break; | 626 | break; | |
627 | case RTK_HWREV_8168EP: | |||
621 | case RTK_HWREV_8168G: | 628 | case RTK_HWREV_8168G: | |
622 | case RTK_HWREV_8168G_SPIN1: | 629 | case RTK_HWREV_8168G_SPIN1: | |
623 | case RTK_HWREV_8168G_SPIN2: | 630 | case RTK_HWREV_8168G_SPIN2: | |
624 | case RTK_HWREV_8168G_SPIN4: | 631 | case RTK_HWREV_8168G_SPIN4: | |
625 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | 632 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | |
626 | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO | | 633 | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO | | |
627 | RTKQ_RXDV_GATED; | 634 | RTKQ_RXDV_GATED; | |
628 | break; | 635 | break; | |
629 | case RTK_HWREV_8100E: | 636 | case RTK_HWREV_8100E: | |
630 | case RTK_HWREV_8100E_SPIN2: | 637 | case RTK_HWREV_8100E_SPIN2: | |
631 | case RTK_HWREV_8101E: | 638 | case RTK_HWREV_8101E: | |
632 | sc->sc_quirk |= RTKQ_NOJUMBO; | 639 | sc->sc_quirk |= RTKQ_NOJUMBO; | |
633 | break; | 640 | break; | |
634 | case RTK_HWREV_8102E: | 641 | case RTK_HWREV_8102E: | |
635 | case RTK_HWREV_8102EL: | 642 | case RTK_HWREV_8102EL: | |
636 | case RTK_HWREV_8103E: | 643 | case RTK_HWREV_8102EL_SPIN1: | |
637 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | 644 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | |
638 | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO; | 645 | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO; | |
639 | break; | 646 | break; | |
647 | case RTK_HWREV_8103E: | |||
648 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | | |||
649 | RTKQ_MACSTAT | RTKQ_CMDSTOP; | |||
650 | break; | |||
651 | case RTK_HWREV_8401E: | |||
652 | case RTK_HWREV_8105E: | |||
653 | case RTK_HWREV_8105E_SPIN1: | |||
654 | case RTK_HWREV_8106E: | |||
655 | sc->sc_quirk |= RTKQ_PHYWAKE_PM | | |||
656 | RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | | |||
657 | RTKQ_CMDSTOP; | |||
658 | break; | |||
659 | case RTK_HWREV_8402: | |||
660 | sc->sc_quirk |= RTKQ_PHYWAKE_PM | | |||
661 | RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | | |||
662 | RTKQ_CMDSTOP; /* CMDSTOP_WAIT_TXQ */ | |||
663 | break; | |||
640 | default: | 664 | default: | |
641 | aprint_normal_dev(sc->sc_dev, | 665 | aprint_normal_dev(sc->sc_dev, | |
642 | "Unknown revision (0x%08x)\n", hwrev); | 666 | "Unknown revision (0x%08x)\n", hwrev); | |
643 | /* assume the latest features */ | 667 | /* assume the latest features */ | |
644 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD; | 668 | sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD; | |
645 | sc->sc_quirk |= RTKQ_NOJUMBO; | 669 | sc->sc_quirk |= RTKQ_NOJUMBO; | |
646 | } | 670 | } | |
647 | 671 | |||
648 | /* Set RX length mask */ | 672 | /* Set RX length mask */ | |
649 | sc->re_rxlenmask = RE_RDESC_STAT_GFRAGLEN; | 673 | sc->re_rxlenmask = RE_RDESC_STAT_GFRAGLEN; | |
650 | sc->re_ldata.re_tx_desc_cnt = RE_TX_DESC_CNT_8169; | 674 | sc->re_ldata.re_tx_desc_cnt = RE_TX_DESC_CNT_8169; | |
651 | } else { | 675 | } else { | |
652 | sc->sc_quirk |= RTKQ_NOJUMBO; | 676 | sc->sc_quirk |= RTKQ_NOJUMBO; | |
@@ -1863,27 +1887,28 @@ re_init(struct ifnet *ifp) | @@ -1863,27 +1887,28 @@ re_init(struct ifnet *ifp) | |||
1863 | CSR_WRITE_4(sc, RTK_TXLIST_ADDR_HI, | 1887 | CSR_WRITE_4(sc, RTK_TXLIST_ADDR_HI, | |
1864 | RE_ADDR_HI(sc->re_ldata.re_tx_list_map->dm_segs[0].ds_addr)); | 1888 | RE_ADDR_HI(sc->re_ldata.re_tx_list_map->dm_segs[0].ds_addr)); | |
1865 | CSR_WRITE_4(sc, RTK_TXLIST_ADDR_LO, | 1889 | CSR_WRITE_4(sc, RTK_TXLIST_ADDR_LO, | |
1866 | RE_ADDR_LO(sc->re_ldata.re_tx_list_map->dm_segs[0].ds_addr)); | 1890 | RE_ADDR_LO(sc->re_ldata.re_tx_list_map->dm_segs[0].ds_addr)); | |
1867 | 1891 | |||
1868 | if (sc->sc_quirk & RTKQ_RXDV_GATED) { | 1892 | if (sc->sc_quirk & RTKQ_RXDV_GATED) { | |
1869 | CSR_WRITE_4(sc, RTK_MISC, | 1893 | CSR_WRITE_4(sc, RTK_MISC, | |
1870 | CSR_READ_4(sc, RTK_MISC) & ~RTK_MISC_RXDV_GATED_EN); | 1894 | CSR_READ_4(sc, RTK_MISC) & ~RTK_MISC_RXDV_GATED_EN); | |
1871 | } | 1895 | } | |
1872 | 1896 | |||
1873 | /* | 1897 | /* | |
1874 | * Enable transmit and receive. | 1898 | * Enable transmit and receive. | |
1875 | */ | 1899 | */ | |
1876 | CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB); | 1900 | if ((sc->sc_quirk & RTKQ_TXRXEN_LATER) == 0) | |
1901 | CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB); | |||
1877 | 1902 | |||
1878 | /* | 1903 | /* | |
1879 | * Set the initial TX and RX configuration. | 1904 | * Set the initial TX and RX configuration. | |
1880 | */ | 1905 | */ | |
1881 | if (sc->re_testmode && (sc->sc_quirk & RTKQ_8169NONS) != 0) { | 1906 | if (sc->re_testmode && (sc->sc_quirk & RTKQ_8169NONS) != 0) { | |
1882 | /* test mode is needed only for old 8169 */ | 1907 | /* test mode is needed only for old 8169 */ | |
1883 | CSR_WRITE_4(sc, RTK_TXCFG, | 1908 | CSR_WRITE_4(sc, RTK_TXCFG, | |
1884 | RE_TXCFG_CONFIG | RTK_LOOPTEST_ON); | 1909 | RE_TXCFG_CONFIG | RTK_LOOPTEST_ON); | |
1885 | } else | 1910 | } else | |
1886 | CSR_WRITE_4(sc, RTK_TXCFG, RE_TXCFG_CONFIG); | 1911 | CSR_WRITE_4(sc, RTK_TXCFG, RE_TXCFG_CONFIG); | |
1887 | 1912 | |||
1888 | CSR_WRITE_1(sc, RTK_EARLY_TX_THRESH, 16); | 1913 | CSR_WRITE_1(sc, RTK_EARLY_TX_THRESH, 16); | |
1889 | 1914 | |||
@@ -1905,26 +1930,32 @@ re_init(struct ifnet *ifp) | @@ -1905,26 +1930,32 @@ re_init(struct ifnet *ifp) | |||
1905 | */ | 1930 | */ | |
1906 | if (ifp->if_flags & IFF_BROADCAST) | 1931 | if (ifp->if_flags & IFF_BROADCAST) | |
1907 | rxcfg |= RTK_RXCFG_RX_BROAD; | 1932 | rxcfg |= RTK_RXCFG_RX_BROAD; | |
1908 | else | 1933 | else | |
1909 | rxcfg &= ~RTK_RXCFG_RX_BROAD; | 1934 | rxcfg &= ~RTK_RXCFG_RX_BROAD; | |
1910 | CSR_WRITE_4(sc, RTK_RXCFG, rxcfg); | 1935 | CSR_WRITE_4(sc, RTK_RXCFG, rxcfg); | |
1911 | 1936 | |||
1912 | /* | 1937 | /* | |
1913 | * Program the multicast filter, if necessary. | 1938 | * Program the multicast filter, if necessary. | |
1914 | */ | 1939 | */ | |
1915 | rtk_setmulti(sc); | 1940 | rtk_setmulti(sc); | |
1916 | 1941 | |||
1917 | /* | 1942 | /* | |
1943 | * some chips require to enable TX/RX *AFTER* TX/RX configuration | |||
1944 | */ | |||
1945 | if ((sc->sc_quirk & RTKQ_TXRXEN_LATER) != 0) | |||
1946 | CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB); | |||
1947 | ||||
1948 | /* | |||
1918 | * Enable interrupts. | 1949 | * Enable interrupts. | |
1919 | */ | 1950 | */ | |
1920 | if (sc->re_testmode) | 1951 | if (sc->re_testmode) | |
1921 | CSR_WRITE_2(sc, RTK_IMR, 0); | 1952 | CSR_WRITE_2(sc, RTK_IMR, 0); | |
1922 | else if ((sc->sc_quirk & RTKQ_IM_HW) != 0) | 1953 | else if ((sc->sc_quirk & RTKQ_IM_HW) != 0) | |
1923 | CSR_WRITE_2(sc, RTK_IMR, RTK_INTRS_IM_HW); | 1954 | CSR_WRITE_2(sc, RTK_IMR, RTK_INTRS_IM_HW); | |
1924 | else | 1955 | else | |
1925 | CSR_WRITE_2(sc, RTK_IMR, RTK_INTRS_CPLUS); | 1956 | CSR_WRITE_2(sc, RTK_IMR, RTK_INTRS_CPLUS); | |
1926 | 1957 | |||
1927 | /* Start RX/TX process. */ | 1958 | /* Start RX/TX process. */ | |
1928 | CSR_WRITE_4(sc, RTK_MISSEDPKT, 0); | 1959 | CSR_WRITE_4(sc, RTK_MISSEDPKT, 0); | |
1929 | #ifdef notdef | 1960 | #ifdef notdef | |
1930 | /* Enable receiver and transmitter. */ | 1961 | /* Enable receiver and transmitter. */ |
--- src/sys/dev/ic/rtl81x9.c 2019/05/28 07:41:48 1.106
+++ src/sys/dev/ic/rtl81x9.c 2020/01/28 11:12:30 1.106.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rtl81x9.c,v 1.106 2019/05/28 07:41:48 msaitoh Exp $ */ | 1 | /* $NetBSD: rtl81x9.c,v 1.106.2.1 2020/01/28 11:12:30 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997, 1998 | 4 | * Copyright (c) 1997, 1998 | |
5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | 5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -76,27 +76,27 @@ | @@ -76,27 +76,27 @@ | |||
76 | * On the bright side, the 8139 does have a built-in PHY, although | 76 | * On the bright side, the 8139 does have a built-in PHY, although | |
77 | * rather than using an MDIO serial interface like most other NICs, the | 77 | * rather than using an MDIO serial interface like most other NICs, the | |
78 | * PHY registers are directly accessible through the 8139's register | 78 | * PHY registers are directly accessible through the 8139's register | |
79 | * space. The 8139 supports autonegotiation, as well as a 64-bit multicast | 79 | * space. The 8139 supports autonegotiation, as well as a 64-bit multicast | |
80 | * filter. | 80 | * filter. | |
81 | * | 81 | * | |
82 | * The 8129 chip is an older version of the 8139 that uses an external PHY | 82 | * The 8129 chip is an older version of the 8139 that uses an external PHY | |
83 | * chip. The 8129 has a serial MDIO interface for accessing the MII where | 83 | * chip. The 8129 has a serial MDIO interface for accessing the MII where | |
84 | * the 8139 lets you directly access the on-board PHY registers. We need | 84 | * the 8139 lets you directly access the on-board PHY registers. We need | |
85 | * to select which interface to use depending on the chip type. | 85 | * to select which interface to use depending on the chip type. | |
86 | */ | 86 | */ | |
87 | 87 | |||
88 | #include <sys/cdefs.h> | 88 | #include <sys/cdefs.h> | |
89 | __KERNEL_RCSID(0, "$NetBSD: rtl81x9.c,v 1.106 2019/05/28 07:41:48 msaitoh Exp $"); | 89 | __KERNEL_RCSID(0, "$NetBSD: rtl81x9.c,v 1.106.2.1 2020/01/28 11:12:30 martin Exp $"); | |
90 | 90 | |||
91 | 91 | |||
92 | #include <sys/param.h> | 92 | #include <sys/param.h> | |
93 | #include <sys/systm.h> | 93 | #include <sys/systm.h> | |
94 | #include <sys/callout.h> | 94 | #include <sys/callout.h> | |
95 | #include <sys/device.h> | 95 | #include <sys/device.h> | |
96 | #include <sys/sockio.h> | 96 | #include <sys/sockio.h> | |
97 | #include <sys/mbuf.h> | 97 | #include <sys/mbuf.h> | |
98 | #include <sys/malloc.h> | 98 | #include <sys/malloc.h> | |
99 | #include <sys/kernel.h> | 99 | #include <sys/kernel.h> | |
100 | #include <sys/socket.h> | 100 | #include <sys/socket.h> | |
101 | 101 | |||
102 | #include <net/if.h> | 102 | #include <net/if.h> | |
@@ -551,29 +551,29 @@ rtk_setmulti(struct rtk_softc *sc) | @@ -551,29 +551,29 @@ rtk_setmulti(struct rtk_softc *sc) | |||
551 | /* now program new ones */ | 551 | /* now program new ones */ | |
552 | ETHER_LOCK(ec); | 552 | ETHER_LOCK(ec); | |
553 | ETHER_FIRST_MULTI(step, ec, enm); | 553 | ETHER_FIRST_MULTI(step, ec, enm); | |
554 | mcnt = 0; | 554 | mcnt = 0; | |
555 | while (enm != NULL) { | 555 | while (enm != NULL) { | |
556 | if (memcmp(enm->enm_addrlo, enm->enm_addrhi, | 556 | if (memcmp(enm->enm_addrlo, enm->enm_addrhi, | |
557 | ETHER_ADDR_LEN) != 0) { | 557 | ETHER_ADDR_LEN) != 0) { | |
558 | ETHER_UNLOCK(ec); | 558 | ETHER_UNLOCK(ec); | |
559 | goto allmulti; | 559 | goto allmulti; | |
560 | } | 560 | } | |
561 | 561 | |||
562 | h = rtk_calchash(enm->enm_addrlo); | 562 | h = rtk_calchash(enm->enm_addrlo); | |
563 | if (h < 32) | 563 | if (h < 32) | |
564 | hashes[0] |= (1 << h); | 564 | hashes[0] |= __BIT(h); | |
565 | else | 565 | else | |
566 | hashes[1] |= (1 << (h - 32)); | 566 | hashes[1] |= __BIT(h - 32); | |
567 | mcnt++; | 567 | mcnt++; | |
568 | ETHER_NEXT_MULTI(step, enm); | 568 | ETHER_NEXT_MULTI(step, enm); | |
569 | } | 569 | } | |
570 | ETHER_UNLOCK(ec); | 570 | ETHER_UNLOCK(ec); | |
571 | 571 | |||
572 | ifp->if_flags &= ~IFF_ALLMULTI; | 572 | ifp->if_flags &= ~IFF_ALLMULTI; | |
573 | 573 | |||
574 | if (mcnt) | 574 | if (mcnt) | |
575 | rxfilt |= RTK_RXCFG_RX_MULTI; | 575 | rxfilt |= RTK_RXCFG_RX_MULTI; | |
576 | else | 576 | else | |
577 | rxfilt &= ~RTK_RXCFG_RX_MULTI; | 577 | rxfilt &= ~RTK_RXCFG_RX_MULTI; | |
578 | 578 | |||
579 | CSR_WRITE_4(sc, RTK_RXCFG, rxfilt); | 579 | CSR_WRITE_4(sc, RTK_RXCFG, rxfilt); |
--- src/sys/dev/ic/rtl81x9reg.h 2019/04/05 23:46:04 1.50
+++ src/sys/dev/ic/rtl81x9reg.h 2020/01/28 11:12:30 1.50.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rtl81x9reg.h,v 1.50 2019/04/05 23:46:04 uwe Exp $ */ | 1 | /* $NetBSD: rtl81x9reg.h,v 1.50.4.1 2020/01/28 11:12:30 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997, 1998 | 4 | * Copyright (c) 1997, 1998 | |
5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | 5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -139,70 +139,79 @@ | @@ -139,70 +139,79 @@ | |||
139 | #define RTK_MISC 0x00F0 | 139 | #define RTK_MISC 0x00F0 | |
140 | 140 | |||
141 | /* | 141 | /* | |
142 | * TX config register bits | 142 | * TX config register bits | |
143 | */ | 143 | */ | |
144 | #define RTK_TXCFG_CLRABRT 0x00000001 /* retransmit aborted pkt */ | 144 | #define RTK_TXCFG_CLRABRT 0x00000001 /* retransmit aborted pkt */ | |
145 | #define RTK_TXCFG_MAXDMA 0x00000700 /* max DMA burst size */ | 145 | #define RTK_TXCFG_MAXDMA 0x00000700 /* max DMA burst size */ | |
146 | #define RTK_TXCFG_CRCAPPEND 0x00010000 /* CRC append (0 = yes) */ | 146 | #define RTK_TXCFG_CRCAPPEND 0x00010000 /* CRC append (0 = yes) */ | |
147 | #define RTK_TXCFG_LOOPBKTST 0x00060000 /* loopback test */ | 147 | #define RTK_TXCFG_LOOPBKTST 0x00060000 /* loopback test */ | |
148 | #define RTK_TXCFG_IFG2 0x00080000 /* 8169 only */ | 148 | #define RTK_TXCFG_IFG2 0x00080000 /* 8169 only */ | |
149 | #define RTK_TXCFG_IFG 0x03000000 /* interframe gap */ | 149 | #define RTK_TXCFG_IFG 0x03000000 /* interframe gap */ | |
150 | #define RTK_TXCFG_HWREV 0x7CC00000 | 150 | #define RTK_TXCFG_HWREV 0x7CC00000 | |
151 | 151 | |||
152 | #define RTK_LOOPTEST_OFF 0x00000000 | 152 | #define RTK_LOOPTEST_OFF 0x00000000 | |
153 | #define RTK_LOOPTEST_ON 0x00020000 | 153 | #define RTK_LOOPTEST_ON 0x00020000 | |
154 | #define RTK_LOOPTEST_ON_CPLUS 0x00060000 | 154 | #define RTK_LOOPTEST_ON_CPLUS 0x00060000 | |
155 | 155 | |||
156 | /* Known revision codes. */ | 156 | /* Known revision codes. */ | |
157 | #define RTK_HWREV_8169 0x00000000 | 157 | #define RTK_HWREV_8169 0x00000000 | |
158 | #define RTK_HWREV_8110S 0x00800000 | 158 | #define RTK_HWREV_8110S 0x00800000 | |
159 | #define RTK_HWREV_8169S 0x04000000 | 159 | #define RTK_HWREV_8169S 0x04000000 | |
160 | #define RTK_HWREV_8169_8110SB 0x10000000 | 160 | #define RTK_HWREV_8169_8110SB 0x10000000 | |
161 | #define RTK_HWREV_8169_8110SC 0x18000000 | 161 | #define RTK_HWREV_8169_8110SC 0x18000000 | |
162 | #define RTK_HWREV_8401E 0x24000000 | |||
162 | #define RTK_HWREV_8102EL 0x24800000 | 163 | #define RTK_HWREV_8102EL 0x24800000 | |
163 | #define RTK_HWREV_8103E 0x24C00000 | 164 | #define RTK_HWREV_8102EL_SPIN1 0x24C00000 | |
164 | #define RTK_HWREV_8168D 0x28000000 | 165 | #define RTK_HWREV_8168D 0x28000000 | |
165 | #define RTK_HWREV_8168DP 0x28800000 | 166 | #define RTK_HWREV_8168DP 0x28800000 | |
166 | #define RTK_HWREV_8168E 0x2C000000 | 167 | #define RTK_HWREV_8168E 0x2C000000 | |
167 | #define RTK_HWREV_8168E_VL 0x2C800000 | 168 | #define RTK_HWREV_8168E_VL 0x2C800000 | |
168 | #define RTK_HWREV_8168_SPIN1 0x30000000 | 169 | #define RTK_HWREV_8168_SPIN1 0x30000000 | |
169 | #define RTK_HWREV_8168G 0x4c000000 | |||
170 | #define RTK_HWREV_8168G_SPIN1 0x4c100000 | |||
171 | #define RTK_HWREV_8168G_SPIN2 0x50900000 | |||
172 | #define RTK_HWREV_8168G_SPIN4 0x5c800000 | |||
173 | #define RTK_HWREV_8168GU 0x50800000 | |||
174 | #define RTK_HWREV_8100E 0x30800000 | 170 | #define RTK_HWREV_8100E 0x30800000 | |
175 | #define RTK_HWREV_8101E 0x34000000 | 171 | #define RTK_HWREV_8101E 0x34000000 | |
176 | #define RTK_HWREV_8102E 0x34800000 | 172 | #define RTK_HWREV_8102E 0x34800000 | |
173 | #define RTK_HWREV_8103E 0x34c00000 | |||
177 | #define RTK_HWREV_8168_SPIN2 0x38000000 | 174 | #define RTK_HWREV_8168_SPIN2 0x38000000 | |
178 | #define RTK_HWREV_8168_SPIN3 0x38400000 | 175 | #define RTK_HWREV_8168_SPIN3 0x38400000 | |
179 | #define RTK_HWREV_8100E_SPIN2 0x38800000 | 176 | #define RTK_HWREV_8100E_SPIN2 0x38800000 | |
180 | #define RTK_HWREV_8168C 0x3C000000 | 177 | #define RTK_HWREV_8168C 0x3C000000 | |
181 | #define RTK_HWREV_8168C_SPIN2 0x3C400000 | 178 | #define RTK_HWREV_8168C_SPIN2 0x3C400000 | |
182 | #define RTK_HWREV_8168CP 0x3C800000 | 179 | #define RTK_HWREV_8168CP 0x3C800000 | |
180 | #define RTK_HWREV_8105E 0x40800000 | |||
181 | #define RTK_HWREV_8105E_SPIN1 0x40C00000 | |||
182 | #define RTK_HWREV_8402 0x44000000 | |||
183 | #define RTK_HWREV_8106E 0x44800000 | |||
183 | #define RTK_HWREV_8168F 0x48000000 | 184 | #define RTK_HWREV_8168F 0x48000000 | |
185 | #define RTK_HWREV_8411 0x48800000 | |||
186 | #define RTK_HWREV_8168G 0x4c000000 | |||
187 | #define RTK_HWREV_8168G_SPIN1 0x4c100000 | |||
188 | #define RTK_HWREV_8168EP 0x50000000 | |||
189 | #define RTK_HWREV_8168GU 0x50800000 | |||
190 | #define RTK_HWREV_8168G_SPIN2 0x50900000 | |||
184 | #define RTK_HWREV_8168H 0x54000000 | 191 | #define RTK_HWREV_8168H 0x54000000 | |
185 | #define RTK_HWREV_8168H_SPIN1 0x54100000 | 192 | #define RTK_HWREV_8168H_SPIN1 0x54100000 | |
193 | #define RTK_HWREV_8168FP 0x54800000 | |||
194 | #define RTK_HWREV_8168G_SPIN4 0x5c800000 | |||
186 | #define RTK_HWREV_8139 0x60000000 | 195 | #define RTK_HWREV_8139 0x60000000 | |
187 | #define RTK_HWREV_8139A 0x70000000 | 196 | #define RTK_HWREV_8139A 0x70000000 | |
188 | #define RTK_HWREV_8139AG 0x70800000 | 197 | #define RTK_HWREV_8139AG 0x70800000 | |
189 | #define RTK_HWREV_8139B 0x78000000 | |||
190 | #define RTK_HWREV_8130 0x7C000000 | |||
191 | #define RTK_HWREV_8139C 0x74000000 | 198 | #define RTK_HWREV_8139C 0x74000000 | |
192 | #define RTK_HWREV_8139D 0x74400000 | 199 | #define RTK_HWREV_8139D 0x74400000 | |
193 | #define RTK_HWREV_8139CPLUS 0x74800000 | 200 | #define RTK_HWREV_8139CPLUS 0x74800000 | |
194 | #define RTK_HWREV_8101 0x74c00000 | 201 | #define RTK_HWREV_8101 0x74c00000 | |
202 | #define RTK_HWREV_8139B 0x78000000 | |||
195 | #define RTK_HWREV_8100 0x78800000 | 203 | #define RTK_HWREV_8100 0x78800000 | |
204 | #define RTK_HWREV_8130 0x7C000000 | |||
196 | #define RTK_HWREV_8169_8110SBL 0x7cc00000 | 205 | #define RTK_HWREV_8169_8110SBL 0x7cc00000 | |
197 | 206 | |||
198 | #define RTK_TXDMA_16BYTES 0x00000000 | 207 | #define RTK_TXDMA_16BYTES 0x00000000 | |
199 | #define RTK_TXDMA_32BYTES 0x00000100 | 208 | #define RTK_TXDMA_32BYTES 0x00000100 | |
200 | #define RTK_TXDMA_64BYTES 0x00000200 | 209 | #define RTK_TXDMA_64BYTES 0x00000200 | |
201 | #define RTK_TXDMA_128BYTES 0x00000300 | 210 | #define RTK_TXDMA_128BYTES 0x00000300 | |
202 | #define RTK_TXDMA_256BYTES 0x00000400 | 211 | #define RTK_TXDMA_256BYTES 0x00000400 | |
203 | #define RTK_TXDMA_512BYTES 0x00000500 | 212 | #define RTK_TXDMA_512BYTES 0x00000500 | |
204 | #define RTK_TXDMA_1024BYTES 0x00000600 | 213 | #define RTK_TXDMA_1024BYTES 0x00000600 | |
205 | #define RTK_TXDMA_2048BYTES 0x00000700 | 214 | #define RTK_TXDMA_2048BYTES 0x00000700 | |
206 | 215 | |||
207 | /* | 216 | /* | |
208 | * Transmit descriptor status register bits. | 217 | * Transmit descriptor status register bits. |
--- src/sys/dev/ic/rtl81x9var.h 2017/04/19 00:20:02 1.56
+++ src/sys/dev/ic/rtl81x9var.h 2020/01/28 11:12:30 1.56.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rtl81x9var.h,v 1.56 2017/04/19 00:20:02 jmcneill Exp $ */ | 1 | /* $NetBSD: rtl81x9var.h,v 1.56.18.1 2020/01/28 11:12:30 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997, 1998 | 4 | * Copyright (c) 1997, 1998 | |
5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | 5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -184,26 +184,27 @@ struct rtk_softc { | @@ -184,26 +184,27 @@ struct rtk_softc { | |||
184 | #define RTKQ_8129 0x00000001 /* 8129 */ | 184 | #define RTKQ_8129 0x00000001 /* 8129 */ | |
185 | #define RTKQ_8139CPLUS 0x00000002 /* 8139C+ */ | 185 | #define RTKQ_8139CPLUS 0x00000002 /* 8139C+ */ | |
186 | #define RTKQ_8169NONS 0x00000004 /* old non-single 8169 */ | 186 | #define RTKQ_8169NONS 0x00000004 /* old non-single 8169 */ | |
187 | #define RTKQ_PCIE 0x00000008 /* PCIe variants */ | 187 | #define RTKQ_PCIE 0x00000008 /* PCIe variants */ | |
188 | #define RTKQ_MACLDPS 0x00000010 /* has LDPS register */ | 188 | #define RTKQ_MACLDPS 0x00000010 /* has LDPS register */ | |
189 | #define RTKQ_DESCV2 0x00000020 /* has V2 TX/RX descriptor */ | 189 | #define RTKQ_DESCV2 0x00000020 /* has V2 TX/RX descriptor */ | |
190 | #define RTKQ_NOJUMBO 0x00000040 /* no jumbo MTU support */ | 190 | #define RTKQ_NOJUMBO 0x00000040 /* no jumbo MTU support */ | |
191 | #define RTKQ_NOEECMD 0x00000080 /* unusable EEPROM command */ | 191 | #define RTKQ_NOEECMD 0x00000080 /* unusable EEPROM command */ | |
192 | #define RTKQ_MACSTAT 0x00000100 /* set MACSTAT_DIS on init */ | 192 | #define RTKQ_MACSTAT 0x00000100 /* set MACSTAT_DIS on init */ | |
193 | #define RTKQ_CMDSTOP 0x00000200 /* set STOPREQ on stop */ | 193 | #define RTKQ_CMDSTOP 0x00000200 /* set STOPREQ on stop */ | |
194 | #define RTKQ_PHYWAKE_PM 0x00000400 /* wake PHY from power down */ | 194 | #define RTKQ_PHYWAKE_PM 0x00000400 /* wake PHY from power down */ | |
195 | #define RTKQ_RXDV_GATED 0x00000800 | 195 | #define RTKQ_RXDV_GATED 0x00000800 | |
196 | #define RTKQ_IM_HW 0x00001000 /* HW interrupt mitigation */ | 196 | #define RTKQ_IM_HW 0x00001000 /* HW interrupt mitigation */ | |
197 | #define RTKQ_TXRXEN_LATER 0x00002000 /* TX/RX enable timing */ | |||
197 | 198 | |||
198 | bus_dma_tag_t sc_dmat; | 199 | bus_dma_tag_t sc_dmat; | |
199 | 200 | |||
200 | bus_dma_segment_t sc_dmaseg; /* for rtk(4) */ | 201 | bus_dma_segment_t sc_dmaseg; /* for rtk(4) */ | |
201 | int sc_dmanseg; /* for rtk(4) */ | 202 | int sc_dmanseg; /* for rtk(4) */ | |
202 | 203 | |||
203 | bus_dmamap_t recv_dmamap; /* for rtk(4) */ | 204 | bus_dmamap_t recv_dmamap; /* for rtk(4) */ | |
204 | uint8_t *rtk_rx_buf; | 205 | uint8_t *rtk_rx_buf; | |
205 | 206 | |||
206 | struct rtk_tx_desc rtk_tx_descs[RTK_TX_LIST_CNT]; | 207 | struct rtk_tx_desc rtk_tx_descs[RTK_TX_LIST_CNT]; | |
207 | SIMPLEQ_HEAD(, rtk_tx_desc) rtk_tx_free; | 208 | SIMPLEQ_HEAD(, rtk_tx_desc) rtk_tx_free; | |
208 | SIMPLEQ_HEAD(, rtk_tx_desc) rtk_tx_dirty; | 209 | SIMPLEQ_HEAD(, rtk_tx_desc) rtk_tx_dirty; | |
209 | 210 |