Fri Jun 19 21:51:44 2009 UTC ()
Pull up following revision(s) (requested by tsutsui in ticket #821):
	sys/dev/ic/rtl8169.c: revisions 1.107, 1.114-1.119, 1.121
	sys/dev/ic/rtl81x9reg.h: revisions 1.36-1.39
	sys/dev/ic/rtl81x9var.h: revision 1.47
	sys/dev/mii/rgephy.c: revision 1.27 via patch
	sys/dev/pci/if_re_pci.c: revision 1.36
remove extra semicolons.
--
Add HWREV values of RTL8168CP and RTL8168D.  From FreeBSD.

XXX: needs more quirk handling after wakeup for newer chips.
--
Add HWREV of RTL8102EL variant.  From FUKAUMI Naoki.
--
Assume an unknown HWREV chip has the same features with the latest one.
--
Remove suffix "B" from rtk_name of PCI_PRODUCT_REALTEK_RT8168 devices.
All 8168/8111 variants (8168/8168B/8168C/8168CP/8168D/8111B/8111C/8111CP)
have the same PCI device ID.
--
Remove magic reset sequence except wakeup for rev 2 chips which breaks 8111D.
Problem reported and fix confirmed by Thomas Bieg on current-users.

Also tested on 8111C (no bad side effect) by several users privately.
--
Pull some changes for newer chips from FreeBSD:
- pull MACSTAT and CMDSTOP quirks for 8168/8111 chips
- always set CPLUSCMD_PCI_MRW on reset
- set VLANSTRIP and RXCSUM_ENB bits on CPLUS register per if_capenable

Tested on 8111C and 8111D by several users, and
no bad side effect on my old 8169S.
--
Remove unused sc_rev settings (all quirks are handled by sc_quirk)
and merge HWREV cases which have the same quirks.
--
- rename RTK_HWREV_8102EL_SPIN2 -> RTK_HWREV_8103E
- add a HWREV value for 8168DP
Per Realtek's Linux drivers.
--
Two fixes for RX hwcsum on DESCV2 chips:
 * On checking TCPv4/UDPv4 RX checksum on DESCV2 chips, also check
   RE_RDESC_VLANCTL_IPV4 bit because those DESCV2 chips may also recognize
   IPv6 packets and set RE_PROTOID_TCPIP or RE_PROTOID_UDPIP bits for
   TCPv6/UDPv6 packets.  This may fix PR kern/40605.
 * According to Realtek's Linux driver, DESCV2 chips don't set RE_PROTOID_IP
   for non-TCP/UDP IP packets (set only RE_RDESC_VLANCTL_IPV[46]) so
   remove PROTOID check for IPv4 RX cheksum on DESCV2 chips.


(snj)
diff -r1.105.4.7 -r1.105.4.8 src/sys/dev/ic/rtl8169.c
diff -r1.32.4.3 -r1.32.4.4 src/sys/dev/ic/rtl81x9reg.h
diff -r1.41.12.4 -r1.41.12.5 src/sys/dev/ic/rtl81x9var.h
diff -r1.21 -r1.21.10.1 src/sys/dev/mii/rgephy.c
diff -r1.35 -r1.35.4.1 src/sys/dev/pci/if_re_pci.c

cvs diff -r1.105.4.7 -r1.105.4.8 src/sys/dev/ic/rtl8169.c (expand / switch to unified diff)

--- src/sys/dev/ic/rtl8169.c 2009/05/01 02:11:15 1.105.4.7
+++ src/sys/dev/ic/rtl8169.c 2009/06/19 21:51:43 1.105.4.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rtl8169.c,v 1.105.4.7 2009/05/01 02:11:15 snj Exp $ */ 1/* $NetBSD: rtl8169.c,v 1.105.4.8 2009/06/19 21:51:43 snj 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.105.4.7 2009/05/01 02:11:15 snj Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.105.4.8 2009/06/19 21:51:43 snj 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/8110S PCI NIC driver 40 * RealTek 8139C+/8169/8169S/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
@@ -557,94 +557,79 @@ re_diag(struct rtk_softc *sc) @@ -557,94 +557,79 @@ re_diag(struct rtk_softc *sc)
557void 557void
558re_attach(struct rtk_softc *sc) 558re_attach(struct rtk_softc *sc)
559{ 559{
560 uint8_t eaddr[ETHER_ADDR_LEN]; 560 uint8_t eaddr[ETHER_ADDR_LEN];
561 uint16_t val; 561 uint16_t val;
562 struct ifnet *ifp; 562 struct ifnet *ifp;
563 int error = 0, i, addr_len; 563 int error = 0, i, addr_len;
564 564
565 if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) { 565 if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) {
566 uint32_t hwrev; 566 uint32_t hwrev;
567 567
568 /* Revision of 8169/8169S/8110s in bits 30..26, 23 */ 568 /* Revision of 8169/8169S/8110s in bits 30..26, 23 */
569 hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV; 569 hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV;
570 /* These rev numbers are taken from Realtek's driver */ 
571 switch (hwrev) { 570 switch (hwrev) {
572 case RTK_HWREV_8169: 571 case RTK_HWREV_8169:
573 /* XXX not in the Realtek driver */ 
574 sc->sc_rev = 1; 
575 sc->sc_quirk |= RTKQ_8169NONS; 572 sc->sc_quirk |= RTKQ_8169NONS;
576 break; 573 break;
577 case RTK_HWREV_8169S: 574 case RTK_HWREV_8169S:
578 case RTK_HWREV_8110S: 575 case RTK_HWREV_8110S:
579 sc->sc_rev = 3; 
580 sc->sc_quirk |= RTKQ_MACLDPS; 
581 break; 
582 case RTK_HWREV_8169_8110SB: 576 case RTK_HWREV_8169_8110SB:
583 sc->sc_rev = 4; 
584 sc->sc_quirk |= RTKQ_MACLDPS; 
585 break; 
586 case RTK_HWREV_8169_8110SC: 577 case RTK_HWREV_8169_8110SC:
587 sc->sc_rev = 5; 
588 sc->sc_quirk |= RTKQ_MACLDPS; 578 sc->sc_quirk |= RTKQ_MACLDPS;
589 break; 579 break;
590 case RTK_HWREV_8101E: 
591 sc->sc_rev = 11; 
592 sc->sc_quirk |= RTKQ_NOJUMBO; 
593 break; 
594 case RTK_HWREV_8168_SPIN1: 580 case RTK_HWREV_8168_SPIN1:
595 sc->sc_rev = 21; 
596 break; 
597 case RTK_HWREV_8168_SPIN2: 581 case RTK_HWREV_8168_SPIN2:
598 sc->sc_rev = 22; 
599 break; 
600 case RTK_HWREV_8168_SPIN3: 582 case RTK_HWREV_8168_SPIN3:
601 sc->sc_rev = 23; 583 sc->sc_quirk |= RTKQ_MACSTAT;
602 break; 584 break;
603 case RTK_HWREV_8168C: 585 case RTK_HWREV_8168C:
604 case RTK_HWREV_8168C_SPIN2: 586 case RTK_HWREV_8168C_SPIN2:
605 sc->sc_rev = 24; 587 case RTK_HWREV_8168CP:
606 sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD; 588 case RTK_HWREV_8168D:
 589 sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
 590 RTKQ_MACSTAT | RTKQ_CMDSTOP;
607 /* 591 /*
608 * From FreeBSD driver: 592 * From FreeBSD driver:
609 *  593 *
610 * These (8168/8111) controllers support jumbo frame 594 * These (8168/8111) controllers support jumbo frame
611 * but it seems that enabling it requires touching 595 * but it seems that enabling it requires touching
612 * additional magic registers. Depending on MAC 596 * additional magic registers. Depending on MAC
613 * revisions some controllers need to disable 597 * revisions some controllers need to disable
614 * checksum offload. So disable jumbo frame until 598 * checksum offload. So disable jumbo frame until
615 * I have better idea what it really requires to 599 * I have better idea what it really requires to
616 * make it support. 600 * make it support.
617 * RTL8168C/CP : supports up to 6KB jumbo frame. 601 * RTL8168C/CP : supports up to 6KB jumbo frame.
618 * RTL8111C/CP : supports up to 9KB jumbo frame. 602 * RTL8111C/CP : supports up to 9KB jumbo frame.
619 */ 603 */
620 sc->sc_quirk |= RTKQ_NOJUMBO; 604 sc->sc_quirk |= RTKQ_NOJUMBO;
621 break; 605 break;
622 case RTK_HWREV_8102E: 
623 case RTK_HWREV_8102EL: 
624 sc->sc_rev = 25; 
625 sc->sc_quirk |= 
626 RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_NOJUMBO; 
627 break; 
628 case RTK_HWREV_8100E: 606 case RTK_HWREV_8100E:
629 case RTK_HWREV_8100E_SPIN2: 607 case RTK_HWREV_8100E_SPIN2:
630 /* XXX not in the Realtek driver */ 608 case RTK_HWREV_8101E:
631 sc->sc_rev = 0; 
632 sc->sc_quirk |= RTKQ_NOJUMBO; 609 sc->sc_quirk |= RTKQ_NOJUMBO;
633 break; 610 break;
 611 case RTK_HWREV_8102E:
 612 case RTK_HWREV_8102EL:
 613 case RTK_HWREV_8103E:
 614 sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
 615 RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO;
 616 break;
634 default: 617 default:
635 aprint_normal_dev(sc->sc_dev, 618 aprint_normal_dev(sc->sc_dev,
636 "Unknown revision (0x%08x)\n", hwrev); 619 "Unknown revision (0x%08x)\n", hwrev);
637 sc->sc_rev = 0; 620 /* assume the latest features */
 621 sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD;
 622 sc->sc_quirk |= RTKQ_NOJUMBO;
638 } 623 }
639 624
640 /* Set RX length mask */ 625 /* Set RX length mask */
641 sc->re_rxlenmask = RE_RDESC_STAT_GFRAGLEN; 626 sc->re_rxlenmask = RE_RDESC_STAT_GFRAGLEN;
642 sc->re_ldata.re_tx_desc_cnt = RE_TX_DESC_CNT_8169; 627 sc->re_ldata.re_tx_desc_cnt = RE_TX_DESC_CNT_8169;
643 } else { 628 } else {
644 sc->sc_quirk |= RTKQ_NOJUMBO; 629 sc->sc_quirk |= RTKQ_NOJUMBO;
645 630
646 /* Set RX length mask */ 631 /* Set RX length mask */
647 sc->re_rxlenmask = RE_RDESC_STAT_FRAGLEN; 632 sc->re_rxlenmask = RE_RDESC_STAT_FRAGLEN;
648 sc->re_ldata.re_tx_desc_cnt = RE_TX_DESC_CNT_8139; 633 sc->re_ldata.re_tx_desc_cnt = RE_TX_DESC_CNT_8139;
649 } 634 }
650 635
@@ -1256,45 +1241,69 @@ re_rxeof(struct rtk_softc *sc) @@ -1256,45 +1241,69 @@ re_rxeof(struct rtk_softc *sc)
1256 sc->re_tail->m_next = m; 1241 sc->re_tail->m_next = m;
1257 } 1242 }
1258 m = sc->re_head; 1243 m = sc->re_head;
1259 sc->re_head = sc->re_tail = NULL; 1244 sc->re_head = sc->re_tail = NULL;
1260 m->m_pkthdr.len = total_len - ETHER_CRC_LEN; 1245 m->m_pkthdr.len = total_len - ETHER_CRC_LEN;
1261 } else 1246 } else
1262 m->m_pkthdr.len = m->m_len = 1247 m->m_pkthdr.len = m->m_len =
1263 (total_len - ETHER_CRC_LEN); 1248 (total_len - ETHER_CRC_LEN);
1264 1249
1265 ifp->if_ipackets++; 1250 ifp->if_ipackets++;
1266 m->m_pkthdr.rcvif = ifp; 1251 m->m_pkthdr.rcvif = ifp;
1267 1252
1268 /* Do RX checksumming */ 1253 /* Do RX checksumming */
1269 1254 if ((sc->sc_quirk & RTKQ_DESCV2) == 0) {
1270 /* Check IP header checksum */ 1255 /* Check IP header checksum */
1271 if ((rxstat & RE_RDESC_STAT_PROTOID) != 0 && 1256 if ((rxstat & RE_RDESC_STAT_PROTOID) != 0) {
1272 ((sc->sc_quirk & RTKQ_DESCV2) == 0 || 1257 m->m_pkthdr.csum_flags |= M_CSUM_IPv4;
1273 (rxvlan & RE_RDESC_VLANCTL_IPV4) != 0)) { 1258 if (rxstat & RE_RDESC_STAT_IPSUMBAD)
1274 m->m_pkthdr.csum_flags |= M_CSUM_IPv4; 1259 m->m_pkthdr.csum_flags |=
1275 if (rxstat & RE_RDESC_STAT_IPSUMBAD) 1260 M_CSUM_IPv4_BAD;
1276 m->m_pkthdr.csum_flags |= M_CSUM_IPv4_BAD; 1261
1277 } 1262 /* Check TCP/UDP checksum */
1278 1263 if (RE_TCPPKT(rxstat)) {
1279 /* Check TCP/UDP checksum */ 1264 m->m_pkthdr.csum_flags |= M_CSUM_TCPv4;
1280 if (RE_TCPPKT(rxstat)) { 1265 if (rxstat & RE_RDESC_STAT_TCPSUMBAD)
1281 m->m_pkthdr.csum_flags |= M_CSUM_TCPv4; 1266 m->m_pkthdr.csum_flags |=
1282 if (rxstat & RE_RDESC_STAT_TCPSUMBAD) 1267 M_CSUM_TCP_UDP_BAD;
1283 m->m_pkthdr.csum_flags |= M_CSUM_TCP_UDP_BAD; 1268 } else if (RE_UDPPKT(rxstat)) {
1284 } else if (RE_UDPPKT(rxstat)) { 1269 m->m_pkthdr.csum_flags |= M_CSUM_UDPv4;
1285 m->m_pkthdr.csum_flags |= M_CSUM_UDPv4; 1270 if (rxstat & RE_RDESC_STAT_UDPSUMBAD)
1286 if (rxstat & RE_RDESC_STAT_UDPSUMBAD) 1271 m->m_pkthdr.csum_flags |=
1287 m->m_pkthdr.csum_flags |= M_CSUM_TCP_UDP_BAD; 1272 M_CSUM_TCP_UDP_BAD;
 1273 }
 1274 }
 1275 } else {
 1276 /* Check IPv4 header checksum */
 1277 if ((rxvlan & RE_RDESC_VLANCTL_IPV4) != 0) {
 1278 m->m_pkthdr.csum_flags |= M_CSUM_IPv4;
 1279 if (rxstat & RE_RDESC_STAT_IPSUMBAD)
 1280 m->m_pkthdr.csum_flags |=
 1281 M_CSUM_IPv4_BAD;
 1282
 1283 /* Check TCPv4/UDPv4 checksum */
 1284 if (RE_TCPPKT(rxstat)) {
 1285 m->m_pkthdr.csum_flags |= M_CSUM_TCPv4;
 1286 if (rxstat & RE_RDESC_STAT_TCPSUMBAD)
 1287 m->m_pkthdr.csum_flags |=
 1288 M_CSUM_TCP_UDP_BAD;
 1289 } else if (RE_UDPPKT(rxstat)) {
 1290 m->m_pkthdr.csum_flags |= M_CSUM_UDPv4;
 1291 if (rxstat & RE_RDESC_STAT_UDPSUMBAD)
 1292 m->m_pkthdr.csum_flags |=
 1293 M_CSUM_TCP_UDP_BAD;
 1294 }
 1295 }
 1296 /* XXX Check TCPv6/UDPv6 checksum? */
1288 } 1297 }
1289 1298
1290 if (rxvlan & RE_RDESC_VLANCTL_TAG) { 1299 if (rxvlan & RE_RDESC_VLANCTL_TAG) {
1291 VLAN_INPUT_TAG(ifp, m, 1300 VLAN_INPUT_TAG(ifp, m,
1292 bswap16(rxvlan & RE_RDESC_VLANCTL_DATA), 1301 bswap16(rxvlan & RE_RDESC_VLANCTL_DATA),
1293 continue); 1302 continue);
1294 } 1303 }
1295#if NBPFILTER > 0 1304#if NBPFILTER > 0
1296 if (ifp->if_bpf) 1305 if (ifp->if_bpf)
1297 bpf_mtap(ifp->if_bpf, m); 1306 bpf_mtap(ifp->if_bpf, m);
1298#endif 1307#endif
1299 (*ifp->if_input)(ifp, m); 1308 (*ifp->if_input)(ifp, m);
1300 } 1309 }
@@ -1703,69 +1712,65 @@ re_start(struct ifnet *ifp) @@ -1703,69 +1712,65 @@ re_start(struct ifnet *ifp)
1703 * Set a timeout in case the chip goes out to lunch. 1712 * Set a timeout in case the chip goes out to lunch.
1704 */ 1713 */
1705 ifp->if_timer = 5; 1714 ifp->if_timer = 5;
1706 } 1715 }
1707} 1716}
1708 1717
1709static int 1718static int
1710re_init(struct ifnet *ifp) 1719re_init(struct ifnet *ifp)
1711{ 1720{
1712 struct rtk_softc *sc = ifp->if_softc; 1721 struct rtk_softc *sc = ifp->if_softc;
1713 const uint8_t *enaddr; 1722 const uint8_t *enaddr;
1714 uint32_t rxcfg = 0; 1723 uint32_t rxcfg = 0;
1715 uint32_t reg; 1724 uint32_t reg;
 1725 uint16_t cfg;
1716 int error; 1726 int error;
1717 1727
1718 if ((error = re_enable(sc)) != 0) 1728 if ((error = re_enable(sc)) != 0)
1719 goto out; 1729 goto out;
1720 1730
1721 /* 1731 /*
1722 * Cancel pending I/O and free all RX/TX buffers. 1732 * Cancel pending I/O and free all RX/TX buffers.
1723 */ 1733 */
1724 re_stop(ifp, 0); 1734 re_stop(ifp, 0);
1725 1735
1726 re_reset(sc); 1736 re_reset(sc);
1727 1737
1728 /* 1738 /*
1729 * Enable C+ RX and TX mode, as well as VLAN stripping and 1739 * Enable C+ RX and TX mode, as well as VLAN stripping and
1730 * RX checksum offload. We must configure the C+ register 1740 * RX checksum offload. We must configure the C+ register
1731 * before all others. 1741 * before all others.
1732 */ 1742 */
1733 reg = 0; 1743 cfg = RE_CPLUSCMD_PCI_MRW;
1734 
1735 /* 
1736 * XXX: Realtek docs say bits 0 and 1 are reserved, for 8169S/8110S. 
1737 * FreeBSD drivers set these bits anyway (for 8139C+?). 
1738 * So far, it works. 
1739 */ 
1740 1744
1741 /* 1745 /*
1742 * XXX: For old 8169 set bit 14. 1746 * XXX: For old 8169 set bit 14.
1743 * For 8169S/8110S and above, do not set bit 14. 1747 * For 8169S/8110S and above, do not set bit 14.
1744 */ 1748 */
1745 if ((sc->sc_quirk & RTKQ_8169NONS) != 0) 1749 if ((sc->sc_quirk & RTKQ_8169NONS) != 0)
1746 reg |= (0x1 << 14) | RTK_CPLUSCMD_PCI_MRW;; 1750 cfg |= (0x1 << 14);
1747 1751
1748 if (1) {/* not for 8169S ? */ 1752 if ((ifp->if_capenable & ETHERCAP_VLAN_HWTAGGING) != 0)
1749 reg |= 1753 cfg |= RE_CPLUSCMD_VLANSTRIP;
1750 RTK_CPLUSCMD_VLANSTRIP | 1754 if ((ifp->if_capenable & (IFCAP_CSUM_IPv4_Rx |
1751 (ifp->if_capenable & 1755 IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Rx)) != 0)
1752 (IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_TCPv4_Rx | 1756 cfg |= RE_CPLUSCMD_RXCSUM_ENB;
1753 IFCAP_CSUM_UDPv4_Rx) ? 1757 if ((sc->sc_quirk & RTKQ_MACSTAT) != 0) {
1754 RTK_CPLUSCMD_RXCSUM_ENB : 0); 1758 cfg |= RE_CPLUSCMD_MACSTAT_DIS;
1755 } 1759 cfg |= RE_CPLUSCMD_TXENB;
 1760 } else
 1761 cfg |= RE_CPLUSCMD_RXENB | RE_CPLUSCMD_TXENB;
1756 1762
1757 CSR_WRITE_2(sc, RTK_CPLUS_CMD, 1763 CSR_WRITE_2(sc, RTK_CPLUS_CMD, cfg);
1758 reg | RTK_CPLUSCMD_RXENB | RTK_CPLUSCMD_TXENB); 
1759 1764
1760 /* XXX: from Realtek-supplied Linux driver. Wholly undocumented. */ 1765 /* XXX: from Realtek-supplied Linux driver. Wholly undocumented. */
1761 if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) 1766 if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0)
1762 CSR_WRITE_2(sc, RTK_IM, 0x0000); 1767 CSR_WRITE_2(sc, RTK_IM, 0x0000);
1763 1768
1764 DELAY(10000); 1769 DELAY(10000);
1765 1770
1766 /* 1771 /*
1767 * Init our MAC address. Even though the chipset 1772 * Init our MAC address. Even though the chipset
1768 * documentation doesn't mention it, we need to enter "Config 1773 * documentation doesn't mention it, we need to enter "Config
1769 * register write enable" mode to modify the ID registers. 1774 * register write enable" mode to modify the ID registers.
1770 */ 1775 */
1771 CSR_WRITE_1(sc, RTK_EECMD, RTK_EEMODE_WRITECFG); 1776 CSR_WRITE_1(sc, RTK_EECMD, RTK_EEMODE_WRITECFG);
@@ -1965,28 +1970,34 @@ re_watchdog(struct ifnet *ifp) @@ -1965,28 +1970,34 @@ re_watchdog(struct ifnet *ifp)
1965 * Stop the adapter and free any mbufs allocated to the 1970 * Stop the adapter and free any mbufs allocated to the
1966 * RX and TX lists. 1971 * RX and TX lists.
1967 */ 1972 */
1968static void 1973static void
1969re_stop(struct ifnet *ifp, int disable) 1974re_stop(struct ifnet *ifp, int disable)
1970{ 1975{
1971 int i; 1976 int i;
1972 struct rtk_softc *sc = ifp->if_softc; 1977 struct rtk_softc *sc = ifp->if_softc;
1973 1978
1974 callout_stop(&sc->rtk_tick_ch); 1979 callout_stop(&sc->rtk_tick_ch);
1975 1980
1976 mii_down(&sc->mii); 1981 mii_down(&sc->mii);
1977 1982
1978 CSR_WRITE_1(sc, RTK_COMMAND, 0x00); 1983 if ((sc->sc_quirk & RTKQ_CMDSTOP) != 0)
 1984 CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_STOPREQ | RTK_CMD_TX_ENB |
 1985 RTK_CMD_RX_ENB);
 1986 else
 1987 CSR_WRITE_1(sc, RTK_COMMAND, 0x00);
 1988 DELAY(1000);
1979 CSR_WRITE_2(sc, RTK_IMR, 0x0000); 1989 CSR_WRITE_2(sc, RTK_IMR, 0x0000);
 1990 CSR_WRITE_2(sc, RTK_ISR, 0xFFFF);
1980 1991
1981 if (sc->re_head != NULL) { 1992 if (sc->re_head != NULL) {
1982 m_freem(sc->re_head); 1993 m_freem(sc->re_head);
1983 sc->re_head = sc->re_tail = NULL; 1994 sc->re_head = sc->re_tail = NULL;
1984 } 1995 }
1985 1996
1986 /* Free the TX list buffers. */ 1997 /* Free the TX list buffers. */
1987 for (i = 0; i < RE_TX_QLEN; i++) { 1998 for (i = 0; i < RE_TX_QLEN; i++) {
1988 if (sc->re_ldata.re_txq[i].txq_mbuf != NULL) { 1999 if (sc->re_ldata.re_txq[i].txq_mbuf != NULL) {
1989 bus_dmamap_unload(sc->sc_dmat, 2000 bus_dmamap_unload(sc->sc_dmat,
1990 sc->re_ldata.re_txq[i].txq_dmamap); 2001 sc->re_ldata.re_txq[i].txq_dmamap);
1991 m_freem(sc->re_ldata.re_txq[i].txq_mbuf); 2002 m_freem(sc->re_ldata.re_txq[i].txq_mbuf);
1992 sc->re_ldata.re_txq[i].txq_mbuf = NULL; 2003 sc->re_ldata.re_txq[i].txq_mbuf = NULL;

cvs diff -r1.32.4.3 -r1.32.4.4 src/sys/dev/ic/rtl81x9reg.h (expand / switch to unified diff)

--- src/sys/dev/ic/rtl81x9reg.h 2009/05/01 02:10:03 1.32.4.3
+++ src/sys/dev/ic/rtl81x9reg.h 2009/06/19 21:51:43 1.32.4.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rtl81x9reg.h,v 1.32.4.3 2009/05/01 02:10:03 snj Exp $ */ 1/* $NetBSD: rtl81x9reg.h,v 1.32.4.4 2009/06/19 21:51:43 snj 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.
@@ -148,35 +148,39 @@ @@ -148,35 +148,39 @@
148#define RTK_TXCFG_HWREV 0x7CC00000 148#define RTK_TXCFG_HWREV 0x7CC00000
149 149
150#define RTK_LOOPTEST_OFF 0x00000000 150#define RTK_LOOPTEST_OFF 0x00000000
151#define RTK_LOOPTEST_ON 0x00020000 151#define RTK_LOOPTEST_ON 0x00020000
152#define RTK_LOOPTEST_ON_CPLUS 0x00060000 152#define RTK_LOOPTEST_ON_CPLUS 0x00060000
153 153
154/* Known revision codes. */ 154/* Known revision codes. */
155#define RTK_HWREV_8169 0x00000000 155#define RTK_HWREV_8169 0x00000000
156#define RTK_HWREV_8110S 0x00800000 156#define RTK_HWREV_8110S 0x00800000
157#define RTK_HWREV_8169S 0x04000000 157#define RTK_HWREV_8169S 0x04000000
158#define RTK_HWREV_8169_8110SB 0x10000000 158#define RTK_HWREV_8169_8110SB 0x10000000
159#define RTK_HWREV_8169_8110SC 0x18000000 159#define RTK_HWREV_8169_8110SC 0x18000000
160#define RTK_HWREV_8102EL 0x24800000 160#define RTK_HWREV_8102EL 0x24800000
 161#define RTK_HWREV_8103E 0x24C00000
 162#define RTK_HWREV_8168D 0x28000000
 163#define RTK_HWREV_8168DP 0x28800000
161#define RTK_HWREV_8168_SPIN1 0x30000000 164#define RTK_HWREV_8168_SPIN1 0x30000000
162#define RTK_HWREV_8100E 0x30800000 165#define RTK_HWREV_8100E 0x30800000
163#define RTK_HWREV_8101E 0x34000000 166#define RTK_HWREV_8101E 0x34000000
164#define RTK_HWREV_8102E 0x34800000 167#define RTK_HWREV_8102E 0x34800000
165#define RTK_HWREV_8168_SPIN2 0x38000000 168#define RTK_HWREV_8168_SPIN2 0x38000000
166#define RTK_HWREV_8168_SPIN3 0x38400000 169#define RTK_HWREV_8168_SPIN3 0x38400000
167#define RTK_HWREV_8100E_SPIN2 0x38800000 170#define RTK_HWREV_8100E_SPIN2 0x38800000
168#define RTK_HWREV_8168C 0x3C000000 171#define RTK_HWREV_8168C 0x3C000000
169#define RTK_HWREV_8168C_SPIN2 0x3C400000 172#define RTK_HWREV_8168C_SPIN2 0x3C400000
 173#define RTK_HWREV_8168CP 0x3C800000
170#define RTK_HWREV_8139 0x60000000 174#define RTK_HWREV_8139 0x60000000
171#define RTK_HWREV_8139A 0x70000000 175#define RTK_HWREV_8139A 0x70000000
172#define RTK_HWREV_8139AG 0x70800000 176#define RTK_HWREV_8139AG 0x70800000
173#define RTK_HWREV_8139B 0x78000000 177#define RTK_HWREV_8139B 0x78000000
174#define RTK_HWREV_8130 0x7C000000 178#define RTK_HWREV_8130 0x7C000000
175#define RTK_HWREV_8139C 0x74000000 179#define RTK_HWREV_8139C 0x74000000
176#define RTK_HWREV_8139D 0x74400000 180#define RTK_HWREV_8139D 0x74400000
177#define RTK_HWREV_8139CPLUS 0x74800000 181#define RTK_HWREV_8139CPLUS 0x74800000
178#define RTK_HWREV_8101 0x74c00000 182#define RTK_HWREV_8101 0x74c00000
179#define RTK_HWREV_8100 0x78800000 183#define RTK_HWREV_8100 0x78800000
180 184
181#define RTK_TXDMA_16BYTES 0x00000000 185#define RTK_TXDMA_16BYTES 0x00000000
182#define RTK_TXDMA_32BYTES 0x00000100 186#define RTK_TXDMA_32BYTES 0x00000100
@@ -296,26 +300,27 @@ @@ -296,26 +300,27 @@
296#define RTK_RXSTAT_BROAD 0x00002000 300#define RTK_RXSTAT_BROAD 0x00002000
297#define RTK_RXSTAT_INDIV 0x00004000 301#define RTK_RXSTAT_INDIV 0x00004000
298#define RTK_RXSTAT_MULTI 0x00008000 302#define RTK_RXSTAT_MULTI 0x00008000
299#define RTK_RXSTAT_LENMASK 0xFFFF0000 303#define RTK_RXSTAT_LENMASK 0xFFFF0000
300 304
301#define RTK_RXSTAT_UNFINISHED 0xFFF0 /* DMA still in progress */ 305#define RTK_RXSTAT_UNFINISHED 0xFFF0 /* DMA still in progress */
302/* 306/*
303 * Command register. 307 * Command register.
304 */ 308 */
305#define RTK_CMD_EMPTY_RXBUF 0x0001 309#define RTK_CMD_EMPTY_RXBUF 0x0001
306#define RTK_CMD_TX_ENB 0x0004 310#define RTK_CMD_TX_ENB 0x0004
307#define RTK_CMD_RX_ENB 0x0008 311#define RTK_CMD_RX_ENB 0x0008
308#define RTK_CMD_RESET 0x0010 312#define RTK_CMD_RESET 0x0010
 313#define RTK_CMD_STOPREQ 0x0080
309 314
310/* 315/*
311 * EEPROM control register 316 * EEPROM control register
312 */ 317 */
313#define RTK_EE_DATAOUT 0x01 /* Data out */ 318#define RTK_EE_DATAOUT 0x01 /* Data out */
314#define RTK_EE_DATAIN 0x02 /* Data in */ 319#define RTK_EE_DATAIN 0x02 /* Data in */
315#define RTK_EE_CLK 0x04 /* clock */ 320#define RTK_EE_CLK 0x04 /* clock */
316#define RTK_EE_SEL 0x08 /* chip select */ 321#define RTK_EE_SEL 0x08 /* chip select */
317#define RTK_EE_MODE (0x40|0x80) 322#define RTK_EE_MODE (0x40|0x80)
318 323
319#define RTK_EEMODE_OFF 0x00 324#define RTK_EEMODE_OFF 0x00
320#define RTK_EEMODE_AUTOLOAD 0x40 325#define RTK_EEMODE_AUTOLOAD 0x40
321#define RTK_EEMODE_PROGRAM 0x80 326#define RTK_EEMODE_PROGRAM 0x80
@@ -390,32 +395,41 @@ @@ -390,32 +395,41 @@
390 */ 395 */
391#define RTK_CFG2_BUSFREQ 0x07 396#define RTK_CFG2_BUSFREQ 0x07
392#define RTK_CFG2_BUSWIDTH 0x08 397#define RTK_CFG2_BUSWIDTH 0x08
393#define RTK_CFG2_AUXPWRSTS 0x10 398#define RTK_CFG2_AUXPWRSTS 0x10
394 399
395#define RTK_BUSFREQ_33MHZ 0x00 400#define RTK_BUSFREQ_33MHZ 0x00
396#define RTK_BUSFREQ_66MHZ 0x01 401#define RTK_BUSFREQ_66MHZ 0x01
397 402
398#define RTK_BUSWIDTH_32BITS 0x00 403#define RTK_BUSWIDTH_32BITS 0x00
399#define RTK_BUSWIDTH_64BITS 0x08 404#define RTK_BUSWIDTH_64BITS 0x08
400 405
401/* C+ mode command register */ 406/* C+ mode command register */
402 407
403#define RTK_CPLUSCMD_TXENB 0x0001 /* enable C+ transmit mode */ 408#define RE_CPLUSCMD_TXENB 0x0001 /* enable C+ transmit mode */
404#define RTK_CPLUSCMD_RXENB 0x0002 /* enable C+ receive mode */ 409#define RE_CPLUSCMD_RXENB 0x0002 /* enable C+ receive mode */
405#define RTK_CPLUSCMD_PCI_MRW 0x0008 /* enable PCI multi-read/write */ 410#define RE_CPLUSCMD_PCI_MRW 0x0008 /* enable PCI multi-read/write */
406#define RTK_CPLUSCMD_PCI_DAC 0x0010 /* PCI dual-address cycle only */ 411#define RE_CPLUSCMD_PCI_DAC 0x0010 /* PCI dual-address cycle only */
407#define RTK_CPLUSCMD_RXCSUM_ENB 0x0020 /* enable RX checksum offload */ 412#define RE_CPLUSCMD_RXCSUM_ENB 0x0020 /* enable RX checksum offload */
408#define RTK_CPLUSCMD_VLANSTRIP 0x0040 /* enable VLAN tag stripping */ 413#define RE_CPLUSCMD_VLANSTRIP 0x0040 /* enable VLAN tag stripping */
 414#define RE_CPLUSCMD_MACSTAT_DIS 0x0080 /* 8168B/C/CP */
 415#define RE_CPLUSCMD_ASF 0x0100 /* 8168C/CP */
 416#define RE_CPLUSCMD_DBG_SEL 0x0200 /* 8168C/CP */
 417#define RE_CPLUSCMD_FORCE_TXFC 0x0400 /* 8168C/CP */
 418#define RE_CPLUSCMD_FORCE_RXFC 0x0800 /* 8168C/CP */
 419#define RE_CPLUSCMD_FORCE_HDPX 0x1000 /* 8168C/CP */
 420#define RE_CPLUSCMD_NORMAL_MODE 0x2000 /* 8168C/CP */
 421#define RE_CPLUSCMD_DBG_ENB 0x4000 /* 8168C/CP */
 422#define RE_CPLUSCMD_BIST_ENB 0x8000 /* 8168C/CP */
409 423
410/* C+ early transmit threshold */ 424/* C+ early transmit threshold */
411 425
412#define RTK_EARLYTXTHRESH_CNT 0x003F /* byte count times 8 */ 426#define RTK_EARLYTXTHRESH_CNT 0x003F /* byte count times 8 */
413 427
414/* 428/*
415 * Gigabit PHY access register (8169 only) 429 * Gigabit PHY access register (8169 only)
416 */ 430 */
417 431
418#define RTK_PHYAR_PHYDATA 0x0000FFFF 432#define RTK_PHYAR_PHYDATA 0x0000FFFF
419#define RTK_PHYAR_PHYREG 0x001F0000 433#define RTK_PHYAR_PHYREG 0x001F0000
420#define RTK_PHYAR_BUSY 0x80000000 434#define RTK_PHYAR_BUSY 0x80000000
421 435

cvs diff -r1.41.12.4 -r1.41.12.5 src/sys/dev/ic/rtl81x9var.h (expand / switch to unified diff)

--- src/sys/dev/ic/rtl81x9var.h 2009/05/01 02:08:29 1.41.12.4
+++ src/sys/dev/ic/rtl81x9var.h 2009/06/19 21:51:43 1.41.12.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rtl81x9var.h,v 1.41.12.4 2009/05/01 02:08:29 snj Exp $ */ 1/* $NetBSD: rtl81x9var.h,v 1.41.12.5 2009/06/19 21:51:43 snj 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.
@@ -182,26 +182,28 @@ struct rtk_softc { @@ -182,26 +182,28 @@ struct rtk_softc {
182 struct mii_data mii; 182 struct mii_data mii;
183 struct callout rtk_tick_ch; /* tick callout */ 183 struct callout rtk_tick_ch; /* tick callout */
184 bus_space_handle_t rtk_bhandle; /* bus space handle */ 184 bus_space_handle_t rtk_bhandle; /* bus space handle */
185 bus_space_tag_t rtk_btag; /* bus space tag */ 185 bus_space_tag_t rtk_btag; /* bus space tag */
186 u_int sc_quirk; /* chip quirks */ 186 u_int sc_quirk; /* chip quirks */
187#define RTKQ_8129 0x00000001 /* 8129 */ 187#define RTKQ_8129 0x00000001 /* 8129 */
188#define RTKQ_8139CPLUS 0x00000002 /* 8139C+ */ 188#define RTKQ_8139CPLUS 0x00000002 /* 8139C+ */
189#define RTKQ_8169NONS 0x00000004 /* old non-single 8169 */ 189#define RTKQ_8169NONS 0x00000004 /* old non-single 8169 */
190#define RTKQ_PCIE 0x00000008 /* PCIe variants */ 190#define RTKQ_PCIE 0x00000008 /* PCIe variants */
191#define RTKQ_MACLDPS 0x00000010 /* has LDPS register */ 191#define RTKQ_MACLDPS 0x00000010 /* has LDPS register */
192#define RTKQ_DESCV2 0x00000020 /* has V2 TX/RX descriptor */ 192#define RTKQ_DESCV2 0x00000020 /* has V2 TX/RX descriptor */
193#define RTKQ_NOJUMBO 0x00000040 /* no jumbo MTU support */ 193#define RTKQ_NOJUMBO 0x00000040 /* no jumbo MTU support */
194#define RTKQ_NOEECMD 0x00000080 /* unusable EEPROM command */ 194#define RTKQ_NOEECMD 0x00000080 /* unusable EEPROM command */
 195#define RTKQ_MACSTAT 0x00000100 /* set MACSTAT_DIS on init */
 196#define RTKQ_CMDSTOP 0x00000200 /* set STOPREQ on stop */
195 197
196 bus_dma_tag_t sc_dmat; 198 bus_dma_tag_t sc_dmat;
197 199
198 bus_dma_segment_t sc_dmaseg; /* for rtk(4) */ 200 bus_dma_segment_t sc_dmaseg; /* for rtk(4) */
199 int sc_dmanseg; /* for rtk(4) */ 201 int sc_dmanseg; /* for rtk(4) */
200 202
201 bus_dmamap_t recv_dmamap; /* for rtk(4) */ 203 bus_dmamap_t recv_dmamap; /* for rtk(4) */
202 void * rtk_rx_buf; 204 void * rtk_rx_buf;
203 205
204 struct rtk_tx_desc rtk_tx_descs[RTK_TX_LIST_CNT]; 206 struct rtk_tx_desc rtk_tx_descs[RTK_TX_LIST_CNT];
205 SIMPLEQ_HEAD(, rtk_tx_desc) rtk_tx_free; 207 SIMPLEQ_HEAD(, rtk_tx_desc) rtk_tx_free;
206 SIMPLEQ_HEAD(, rtk_tx_desc) rtk_tx_dirty; 208 SIMPLEQ_HEAD(, rtk_tx_desc) rtk_tx_dirty;
207 209

cvs diff -r1.21 -r1.21.10.1 src/sys/dev/mii/rgephy.c (expand / switch to unified diff)

--- src/sys/dev/mii/rgephy.c 2008/05/04 17:06:10 1.21
+++ src/sys/dev/mii/rgephy.c 2009/06/19 21:51:43 1.21.10.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rgephy.c,v 1.21 2008/05/04 17:06:10 xtraeme Exp $ */ 1/* $NetBSD: rgephy.c,v 1.21.10.1 2009/06/19 21:51:43 snj Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2003 4 * Copyright (c) 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: rgephy.c,v 1.21 2008/05/04 17:06:10 xtraeme Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.21.10.1 2009/06/19 21:51:43 snj Exp $");
37 37
38 38
39/* 39/*
40 * Driver for the RealTek 8169S/8110S internal 10/100/1000 PHY. 40 * Driver for the RealTek 8169S/8110S internal 10/100/1000 PHY.
41 */ 41 */
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/kernel.h> 45#include <sys/kernel.h>
46#include <sys/device.h> 46#include <sys/device.h>
47#include <sys/socket.h> 47#include <sys/socket.h>
48 48
49 49
@@ -579,33 +579,26 @@ rgephy_load_dspcode(struct mii_softc *sc @@ -579,33 +579,26 @@ rgephy_load_dspcode(struct mii_softc *sc
579 579
580static void 580static void
581rgephy_reset(struct mii_softc *sc) 581rgephy_reset(struct mii_softc *sc)
582{ 582{
583 struct rgephy_softc *rsc; 583 struct rgephy_softc *rsc;
584 584
585 mii_phy_reset(sc); 585 mii_phy_reset(sc);
586 DELAY(1000); 586 DELAY(1000);
587 587
588 rsc = (struct rgephy_softc *)sc; 588 rsc = (struct rgephy_softc *)sc;
589 if (rsc->mii_revision < 2) 589 if (rsc->mii_revision < 2)
590 rgephy_load_dspcode(sc); 590 rgephy_load_dspcode(sc);
591 else { 591 else {
592 PHY_WRITE(sc, 0x1F, 0x0001); 
593 PHY_WRITE(sc, 0x09, 0x273a); 
594 PHY_WRITE(sc, 0x0e, 0x7bfb); 
595 PHY_WRITE(sc, 0x1b, 0x841e); 
596 
597 PHY_WRITE(sc, 0x1F, 0x0002); 
598 PHY_WRITE(sc, 0x01, 0x90D0); 
599 PHY_WRITE(sc, 0x1F, 0x0000); 592 PHY_WRITE(sc, 0x1F, 0x0000);
600 PHY_WRITE(sc, 0x0e, 0x0000); 593 PHY_WRITE(sc, 0x0e, 0x0000);
601 } 594 }
602 595
603 /* Reset capabilities */ 596 /* Reset capabilities */
604 /* Step1: write our capability */ 597 /* Step1: write our capability */
605 /* 10/100 capability */ 598 /* 10/100 capability */
606 PHY_WRITE(sc, RGEPHY_MII_ANAR, 599 PHY_WRITE(sc, RGEPHY_MII_ANAR,
607 RGEPHY_ANAR_TX_FD | RGEPHY_ANAR_TX | 600 RGEPHY_ANAR_TX_FD | RGEPHY_ANAR_TX |
608 RGEPHY_ANAR_10_FD | RGEPHY_ANAR_10 | ANAR_CSMA); 601 RGEPHY_ANAR_10_FD | RGEPHY_ANAR_10 | ANAR_CSMA);
609 /* 1000 capability */ 602 /* 1000 capability */
610 PHY_WRITE(sc, RGEPHY_MII_1000CTL, 603 PHY_WRITE(sc, RGEPHY_MII_1000CTL,
611 RGEPHY_1000CTL_AFD | RGEPHY_1000CTL_AHD); 604 RGEPHY_1000CTL_AFD | RGEPHY_1000CTL_AHD);

cvs diff -r1.35 -r1.35.4.1 src/sys/dev/pci/if_re_pci.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_re_pci.c 2008/08/23 14:27:45 1.35
+++ src/sys/dev/pci/if_re_pci.c 2009/06/19 21:51:44 1.35.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_re_pci.c,v 1.35 2008/08/23 14:27:45 tnn Exp $ */ 1/* $NetBSD: if_re_pci.c,v 1.35.4.1 2009/06/19 21:51:44 snj 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.
@@ -36,27 +36,27 @@ @@ -36,27 +36,27 @@
36 36
37/* 37/*
38 * RealTek 8139C+/8169/8169S/8110S PCI NIC driver 38 * RealTek 8139C+/8169/8169S/8110S PCI NIC driver
39 * 39 *
40 * Written by Bill Paul <wpaul@windriver.com> 40 * Written by Bill Paul <wpaul@windriver.com>
41 * Senior Networking Software Engineer 41 * Senior Networking Software Engineer
42 * Wind River Systems 42 * Wind River Systems
43 * 43 *
44 * NetBSD bus-specific frontends for written by 44 * NetBSD bus-specific frontends for written by
45 * Jonathan Stone <jonathan@netbsd.org> 45 * Jonathan Stone <jonathan@netbsd.org>
46 */ 46 */
47 47
48#include <sys/cdefs.h> 48#include <sys/cdefs.h>
49__KERNEL_RCSID(0, "$NetBSD: if_re_pci.c,v 1.35 2008/08/23 14:27:45 tnn Exp $"); 49__KERNEL_RCSID(0, "$NetBSD: if_re_pci.c,v 1.35.4.1 2009/06/19 21:51:44 snj Exp $");
50 50
51#include "bpfilter.h" 51#include "bpfilter.h"
52#include "vlan.h" 52#include "vlan.h"
53 53
54#include <sys/types.h> 54#include <sys/types.h>
55 55
56#include <sys/param.h> 56#include <sys/param.h>
57#include <sys/endian.h> 57#include <sys/endian.h>
58#include <sys/systm.h> 58#include <sys/systm.h>
59#include <sys/sockio.h> 59#include <sys/sockio.h>
60#include <sys/mbuf.h> 60#include <sys/mbuf.h>
61#include <sys/malloc.h> 61#include <sys/malloc.h>
62#include <sys/kernel.h> 62#include <sys/kernel.h>
@@ -99,27 +99,27 @@ CFATTACH_DECL_NEW(re_pci, sizeof(struct  @@ -99,27 +99,27 @@ CFATTACH_DECL_NEW(re_pci, sizeof(struct
99 99
100/* 100/*
101 * Various supported device vendors/types and their names. 101 * Various supported device vendors/types and their names.
102 */ 102 */
103static const struct rtk_type re_devs[] = { 103static const struct rtk_type re_devs[] = {
104 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8139, 104 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8139,
105 RTK_8139CPLUS, 105 RTK_8139CPLUS,
106 "RealTek 8139C+ 10/100BaseTX" }, 106 "RealTek 8139C+ 10/100BaseTX" },
107 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8101E, 107 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8101E,
108 RTK_8101E, 108 RTK_8101E,
109 "RealTek 8100E/8101E/8102E/8102EL PCIe 10/100BaseTX" }, 109 "RealTek 8100E/8101E/8102E/8102EL PCIe 10/100BaseTX" },
110 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8168, 110 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8168,
111 RTK_8168, 111 RTK_8168,
112 "RealTek 8168B/8111B PCIe Gigabit Ethernet" }, 112 "RealTek 8168/8111 PCIe Gigabit Ethernet" },
113 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169, 113 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169,
114 RTK_8169, 114 RTK_8169,
115 "RealTek 8169/8110 Gigabit Ethernet" }, 115 "RealTek 8169/8110 Gigabit Ethernet" },
116 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169SC, 116 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169SC,
117 RTK_8169, 117 RTK_8169,
118 "RealTek 8169SC/8110SC Single-chip Gigabit Ethernet" }, 118 "RealTek 8169SC/8110SC Single-chip Gigabit Ethernet" },
119 { PCI_VENDOR_COREGA, PCI_PRODUCT_COREGA_LAPCIGT, 119 { PCI_VENDOR_COREGA, PCI_PRODUCT_COREGA_LAPCIGT,
120 RTK_8169, 120 RTK_8169,
121 "Corega CG-LAPCIGT Gigabit Ethernet" }, 121 "Corega CG-LAPCIGT Gigabit Ethernet" },
122 { PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE528T, 122 { PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE528T,
123 RTK_8169, 123 RTK_8169,
124 "D-Link DGE-528T Gigabit Ethernet" }, 124 "D-Link DGE-528T Gigabit Ethernet" },
125 { PCI_VENDOR_USR2, PCI_PRODUCT_USR2_USR997902, 125 { PCI_VENDOR_USR2, PCI_PRODUCT_USR2_USR997902,