NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/40120: NetBSD 5.0 BETA bge(4) driver not working correctly for some (fiber) interface cards


I found out what the problem was.  The fix is a "one-line diff".

The "struct ifmedia" has a ifm_media word, which has as a comment
"current user-set media word".  This word is used by ifmedia_ioctl()
as an input value.  However, contrary to what one might think, the
ifmedia_set() routine does *not* set this word: it only sets the
ifm_cur pointer to the member in the "media list" which matched what
ifmedia_set() was told to set the media to (if found).

So the one-line diff is to, after ifmedia_set() has been called in
the bge_tbi case to also manually initialize bge_ifmedia.ifm_media,
like this:

Index: if_bge.c
RCS file: /cvsroot/src/sys/dev/pci/if_bge.c,v
retrieving revision
diff -u -p -r1.152.4.1 if_bge.c
--- if_bge.c    15 Nov 2008 02:39:17 -0000
+++ if_bge.c    30 Jan 2009 14:05:42 -0000
@@ -2845,6 +2845,9 @@ bge_attach(device_t parent, device_t sel
                            0, NULL);
                ifmedia_add(&sc->bge_ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL);
                ifmedia_set(&sc->bge_ifmedia, IFM_ETHER|IFM_AUTO);
+               /* Pretend the user requested this setting */
+               sc->bge_ifmedia.ifm_media =
+                       sc->bge_ifmedia.ifm_cur->ifm_media;
        } else {
                 * Do transceiver setup.

A corresponding change can be seen in FreeBSD's cvs repository, but
it was hidden away bundled together with some handling of BGE 5704
cards (TBI variangs, aka. fibre cards), revision 1.71, visible here:;r2=1.71;f=h


- Havard

Home | Main Index | Thread Index | Old Index