Subject: RealTek 8139C+ with re(4)
To: Pyun YongHyeon <pyunyh@gmail.com>
From: Brian A. Seklecki <lavalamp@spiritual-machines.org>
List: port-i386
Date: 10/17/2006 23:25:39
All:

A FreeBSD/i386 -current ISO snapshot boots just fine and probes all 4 
chips.  All 4 physically verified to pass traffic.

I imagine FreeBSD if_re.c 1.72 -> 1.73 fixes the no-traffic problem with 
the conditional check around the register bit layout when reading a frame:

http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/re/if_re.c.diff?r1=1.72&r2=1.73&f=h

Also, I imagine the re_diag changes in FreeBSD if_re.c 1.67->1.68 correct 
the re_diag() problems by using "#ifdef RE_DIAG" and "if (hwrev == 
RL_HWREV_8169)"

These two patches will need to be adapted and patched into NetBSD and 
RFP/MFC'd into netbsd-3.


> Long ago re_diag() code was disabled by default(rev 1.68). So I think
> you should never see the "diagnostic failed" message on FreeBSD.


Alright, well, I don't have time to port the entire 8139/8139C+ 
conditional checks around #ifdef RE_DIAG and revision checking tonith. 
It's mostly variable name adaptation, but my eyes are about to glaze over 
if I don't leave the office soon.  I'll look into it in the morning.  In 
the mean time I've opened NetBSD PR: kern/34845

http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=34845

> The other odd thing I see from your demsg output is ukphy(4)
> attachment. If you boot system with bootverbose mode ukphy(4) would
> have printed PHY OID and model number. Please let me know the
> OID/model number. I guess it should use rlphy(4).

Right I noticed this, to try to work around this I killed "ukphy*". 
Oddly, when both ukphy(4), rgephy(4), and rlphy(4) enabled...ukphy(4) 
seems to take priority.  I'm not sure if it's supposed to be rgephy(4) or 
rlphy(4) because neither attach as-is.

The cards work perfectly fine with ukphy(4), though.

http://netbsd.gw.com/cgi-bin/man-cgi?rgephy++NetBSD-current
http://netbsd.gw.com/cgi-bin/man-cgi?rlphy++NetBSD-current

These drivers were added after netbsd-3 branched, it seems (well, not in 
the latest netbsd-3 GENERIC...I'll check CVS), so they'd need pulled up 
too.

I'll get a copy of dmesg(8) out to all with the MIIVERBOSE kernel option.

In the mean time, here is the attach failure message which may be 
sufficiently useful:

re0 at pci0 dev 16 function 0: RealTek 8139C+ 10/100BaseTX
re0: interrupting at irq 5
re0: Ethernet address 00:60:e0:e1:3e:31
re0: using 64 tx descriptors
OUI 0x000000 model 0x0000 rev 0 at re0 phy 0 not configured
ifmedia_set: no match for 0x20/0xfffffff


> (If you should use NetBSD you may need to define MIIVERBOSE to active

On that note, I've CC'd the folks on the NetBSD team who've hacked on on 
rtl8169.c who may be interested tsutsui@, yamt@, pavel@, jdolecek@, 
kanaoka@, jonathan@).

I also CC'd the principal persons at OpenBSD (I think, hard to tell based 
on the CVS commit logs), for whom I'd be happy to test OpenBSD -current 
with a similar patch

> verbose message.)
> -- 
> Regards,
> Pyun YongHyeon
>

l8*
 	-lava (Brian A. Seklecki - Pittsburgh, PA, USA)


---------------

     The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
     The Regents of the University of California.  All rights reserved.

NetBSD 4.99.3 (CFRDMDROOT.MPACPI-$Revision: 1.21.4.5 $) #3: Tue Oct 17 
22:36:29 EDT 2006

root@thunderwing:/home/nbsd/obj.i386/temp-current/sys/arch/i386/compile/CFRDMDROOT.MPACPI
total memory = 189 MB
avail memory = 166 MB
timecounter: Timecounters tick every 10.000 msec
timecounter: Timecounter "i8254" frequency 1193182 Hz quality 100
timecounter: selected timecounter "i8254" frequency 1193182 Hz quality 100
BIOS32 rev. 0 found at 0xfb570
mainbus0 (root)
cpu0 at mainbus0: (uniprocessor)
cpu0: VIA C3 Samuel 2/Ezra (686-class), 800.08 MHz, id 0x673
cpu0: features 80803035<FPU,DE,TSC,MSR,MTRR>
cpu0: features 80803035<PGE,MMX>
cpu0: features 80803035<3DNOW>
cpu0: "VIA Samuel 2"
cpu0: I-cache 64 KB 32B/line 4-way, D-cache 64 KB 32B/line 4-way
cpu0: L2 cache 64 KB 32B/line 4-way
cpu0: ITLB 128 4 KB entries 8-way
cpu0: DTLB 128 4 KB entries 8-way
cpu0: 4 page colors
acpi0 at mainbus0: Advanced Configuration and Power Interface
acpi0: using Intel ACPI CA subsystem version 20060217
acpi0: X/RSDT: OemId <VIA601,AWRDACPI,42302e31>, AslId <AWRD,00000000>
acpi0: SCI interrupting at int 9
acpi0: fixed-feature power button present
timecounter: Timecounter "ACPI-Safe" frequency 3579545 Hz quality 900
timecounter: selected timecounter "ACPI-Safe" frequency 3579545 Hz quality 
900
ACPI-Safe 24-bit timer
mpacpi: could not get bus number, assuming bus 0
LNKC: ACPI: Found matching pin for 0.19.INTA at func 0: 11
LNKD: ACPI: Found matching pin for 0.18.INTA at func 0: 10
LNKA: ACPI: Found matching pin for 0.17.INTA at func 0: 12
LNKB: ACPI: Found matching pin for 0.16.INTA at func 0: 5
LNKD: ACPI: Found matching pin for 0.7.INTD at func 2: 10
ACPI Object Type 'Processor' (0x0c) at acpi0 not configured
acpibut0 at acpi0 (PNP0C0C): ACPI Power Button
PNP0C01 [System Board] at acpi0 not configured
PNP0A03 [PCI/PCI-X Host Bridge] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C02 [Plug and Play motherboard register resources] at acpi0 not 
configured
PNP0000 [AT Interrupt Controller] at acpi0 not configured
PNP0200 [AT DMA Controller] at acpi0 not configured
attimer1 at acpi0 (PNP0100): AT Timer
attimer1: io 0x40-0x43 irq 0
PNP0B00 [AT Real-Time Clock] at acpi0 not configured
pcppi1 at acpi0 (PNP0800)
pcppi1: io 0x61
sysbeep0 at pcppi1
npx1 at acpi0 (PNP0C04)
npx1: io 0xf0-0xff irq 13
npx1: using exception 16
fdc0 at acpi0 (PNP0700)
fdc0: io 0x3f0-0x3f5,0x3f7 irq 6 drq 2
com0 at acpi0 (PNP0501-1)
com0: io 0x3f8-0x3ff irq 4
com0: ns16550a, working fifo
com1 at acpi0 (PNP0501-2)
com1: io 0x2f8-0x2ff irq 3
com1: ns16550a, working fifo
lpt0 at acpi0 (PNP0400-1)
lpt0: io 0x378-0x37f irq 7
pcppi1: attached to attimer1
pci0 at mainbus0 bus 0: configuration mode 1
pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
pchb0 at pci0 dev 0 function 0
pchb0: VIA Technologies product 0x0601 (rev. 0x05)
agp0 at pchb0: aperture at 0xe8000000, size 0x10000000
ppb0 at pci0 dev 1 function 0: VIA Technologies product 0x8601 (rev. 0x00)
pci1 at ppb0 bus 1
pci1: i/o space, memory space enabled
vga0 at pci1 dev 0 function 0: Trident Microsystems product 0x8500 (rev. 
0x6a)
wsdisplay0 at vga0 kbdmux 1: console (80x25, vt100 emulation)
wsmux1: connecting to wsdisplay0
pcib0 at pci0 dev 7 function 0
pcib0: VIA Technologies VT82C686A PCI-ISA Bridge (rev. 0x40)
viaide0 at pci0 dev 7 function 1
viaide0: VIA Technologies VT82C686A (Apollo KX133) ATA100 controller
viaide0: bus-master DMA support present
viaide0: primary channel configured to compatibility mode
viaide0: primary channel interrupting at irq 14
atabus0 at viaide0 channel 0
viaide0: secondary channel configured to compatibility mode
viaide0: secondary channel interrupting at irq 15
atabus1 at viaide0 channel 1
uhc0 at pci0 dev 7 function 2: VIA Technologies VT83C572 USB Controller 
(rev. 0x1a)
uhci0: interrupting at irq 10
usb0 at uhci0: USB revision 1.0
uhub0 at usb0
uhub0: VIA Technologies UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
uhci1 at pci0 dev 7 function 3: VIA Technologies VT83C572 USB Controller 
(rev. 0x1a)
uhci1: interrupting at irq 10
usb1 at uhci1: USB revision 1.0
uhub1 at usb1
uhub1: VIA Technologies UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1: 2 ports with 2 removable, self powered
VIA Technologies VT82C686A SMBus Controller (miscellaneous bridge, 
revision 0x40) at pci0 dev 7 function 4 not co
nfigured
re0 at pci0 dev 16 function 0: RealTek 8139C+ 10/100BaseTX
re0: interrupting at irq 5
re0: Ethernet address 00:60:e0:e1:3e:31
re0: using 64 tx descriptors
OUI 0x000000 model 0x0000 rev 0 at re0 phy 0 not configured
ifmedia_set: no match for 0x20/0xfffffff
re1 at pci0 dev 17 function 0: RealTek 8139C+ 10/100BaseTX
re1: interrupting at irq 12
re1: Ethernet address 00:60:e0:e1:3e:30
re1: using 64 tx descriptors
OUI 0x000000 model 0x0000 rev 0 at re1 phy 0 not configured
ifmedia_set: no match for 0x20/0xfffffff
re2 at pci0 dev 18 function 0: RealTek 8139C+ 10/100BaseTX
re2: interrupting at irq 10
re2: Ethernet address 00:60:e0:e1:3e:2f
re2: using 64 tx descriptors
OUI 0x000000 model 0x0000 rev 0 at re2 phy 0 not configured
ifmedia_set: no match for 0x20/0xfffffff
re3 at pci0 dev 19 function 0: RealTek 8139C+ 10/100BaseTX
re3: interrupting at irq 11
re3: Ethernet address 00:60:e0:e1:3e:2e
re3: using 64 tx descriptors
OUI 0x000000 model 0x0000 rev 0 at re3 phy 0 not configured
ifmedia_set: no match for 0x20/0xfffffff
isa0 at pcib0
isapnp0 at isa0 port 0x279: ISA Plug 'n Play device support
isapnp0: no ISA Plug 'n Play devices found
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
md0: internal 10500 KB image area
IPsec: Initialized Security Association Processing.
uhidev0 at uhub0 port 2 configuration 1 interface 0
uhidev0: Dell Dell USB Keyboard, rev 1.10/2.00, addr 2, iclass 3/1
ukbd0 at uhidev0
wskbd0 at ukbd0 mux 1
wskbd0: connecting to wsdisplay0
wd0 at atabus0 drive 0: <SanDisk SDCFH-2048>
wd0: drive supports 4-sector PIO transfers, LBA addressing
wd0: 1953 MB, 3970 cyl, 16 head, 63 sec, 512 bytes/sect x 4001760 sectors
wd0: 32-bit data port
wd0: drive supports PIO mode 4, DMA mode 2
wd0(viaide0:0:0): using PIO mode 4, DMA mode 2 (using DMA)
atapibus0 at atabus1: 2 targets
cd0 at atapibus0 drive 1: <SAMSUNG CD-ROM  SC-148A, , B403> cdrom 
removable
cd0: 32-bit data port
cd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 2 (Ultra/33)
cd0(viaide0:1:1): using PIO mode 4, Ultra-DMA mode 2 (Ultra/33) (using 
DMA)
boot device: wd0
root on md0a dumps on md0b
root file system type: ffs

Patches so far:


seklecki@thunderwing:/home/nbsd/src-current/sys/dev/ic$ sudo cvs diff -u 
rtl8169.c
Password: 
Index: rtl8169.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/rtl8169.c,v
retrieving revision 1.31
diff -u -r1.31 rtl8169.c
--- rtl8169.c   17 Oct 2006 14:03:26 -0000      1.31
+++ rtl8169.c   18 Oct 2006 03:21:50 -0000
@@ -303,6 +303,10 @@
                 return 0;
         }
         rval = CSR_READ_2(sc, re8139_reg);
+       if (sc->rtk_type == RTK_8139CPLUS && re8139_reg == RTK_BMCR) {
+               /* 8139C+ has different bit layout. */
+               rval &= ~(BMCR_LOOP | BMCR_ISO);
+       }
         splx(s);
         return rval;
  }
@@ -330,6 +334,10 @@
         switch (reg) {
         case MII_BMCR:
                 re8139_reg = RTK_BMCR;
+               if (sc->rtk_type == RTK_8139CPLUS) {
+                       /* 8139C+ has different bit layout. */
+                       data &= ~(BMCR_LOOP | BMCR_ISO);
+               }
                 break;
         case MII_BMSR:
                 re8139_reg = RTK_BMSR;



---------------


$ sudo cvs diff -u if_re_pci.c
Index: if_re_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_re_pci.c,v
retrieving revision 1.14
diff -u -r1.14 if_re_pci.c
--- if_re_pci.c 12 Oct 2006 01:31:30 -0000      1.14
+++ if_re_pci.c 18 Oct 2006 03:22:28 -0000
@@ -333,6 +333,9 @@
          * XXX: this diagnostic only makes sense for attachemnts with 
64-bit
          * busses: PCI, but not CardBus.
          */
+
+       error = 0;
+       /*
         error = re_diag(sc);
         if (error) {
                 aprint_error(
@@ -349,4 +352,5 @@
                 if (bsize)
                         bus_space_unmap(sc->rtk_btag, sc->rtk_bhandle, 
bsize);
         }
+       */
  }