Subject: Re: RealTek 8139C+ with re(4)
To: Brian A. Seklecki <lavalamp@spiritual-machines.org>
From: Brad <brad@comstyle.com>
List: port-i386
Date: 10/18/2006 01:53:37
On Tue, Oct 17, 2006 at 11:25:39PM -0400, Brian A. Seklecki wrote:
> 
> 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 first patch has been in the OpenBSD -current src tree for
roughly a month now, not long after Pyun commited the fix to
the FreeBSD tree. I was aware of the fix before it was commited.

If your system has an 8139C+ chipset then it definitely
has an rlphy. The NetBSD rlphy driver needs to be modified
to allow rlphy to attach when using a 8139C+ chipset with
an rlphy but via the re driver, instead of the inferior
rtk driver in this case, rl for OpenBSD/FreeBSD.

int
rlphymatch(struct device *parent, struct cfdata *match __unused, void *aux)
{
        struct mii_attach_args *ma = aux;

        if (mii_phy_match(ma, rlphys) != NULL)
                return (10);

        if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 ||
            MII_MODEL(ma->mii_id2) != 0)
                return 0;

        if (!device_is_a(parent, "rtk"))
                return 0;

        /*
         * A "real" phy should get preference, but on the 8139 there
         * is no phyid register.
         */
        return 5;
}