tech-net archive

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

(vainly?) attempting to back-port wm(4) to netbsd-5....



So, I've got this newish HP laptop here (an EliteBook 8460p with a dual
Core i5 vPro CPU and Intel "6 series" mobile chipset) that has a bunch
of hardware that doesn't get detected by NetBSD-5, most importantly all
of the network devices (except, oddly, fwip0) are ignored.

So, after looking up all the PCI codes I found it was "simply" a matter
of there not being a new enough version of wm(4) for the main Ethernet
interface, for example.

Having successfully back-ported a much older version of wm(4) from
-current at the time to netbsd-1-6, I thought "How hard could it be?"  :-)

Well the mechanics of porting the code and getting it to compile and
link were indeed relatively easy.

On boot it detects the hardware fine and attaches as expected:
(all output re-typed by hand of course....)

wm0: at pci0 dev 25 function 0: PCH2 LAN (82579LM) Controller, rev. 4
wm0 PCI-Express bus
wm0: FLASH
wm0: Ethernet address blah
ukphy at wm0 phy 2: Generic IEEE 802.3u media interface
ukphy0: OUI 0x00aa00, model 0x0009, rev. 3
ukphy0: 10baseT, ... 1000baseT-FDX, auto


However I'm getting a panic when I try to access the device, e.g. by
running dhclient, and there are some odd occurances of 0xffffffff in the
parameter lists:

uvm_fault(0xdcf876a0, 0, 1) -> 0xe
fatal page fault in supervisor mode
trap type 6 code 0 eip c055bf90 cs 8 eflags 10292 cr2 10 ilevel 6
kernel: supervisor trap page fault, code=0
stopped in pid 72.1 (dhclient) at netbsd:catchpacket+0x20: movl 0x10(%eax),%eax
db{3}>trace
catchpacket(ffffffff,c08e1bc0,dd0dda38,156,0,dd070580,c08e1bc0,156,ce472802,1)
at netbsd:catchpacket+0x20
bpf_mtap(....)
wm_start(....)
ifq_enqueue(....)
ether_output(....)
bpf_write(dcf98c00,dcf98c00,dd0ddc94,ce2a7f00,1,ffffffff,dcf98c00,dd0ddc54,0,18)
at netbsd:bpf_write+0x2fd
do_filewritev()
sys_writev()
syscall(dd0ddd48,b3,ab,1f,1f,88f4aae,bfbfe828,bfbfe878,bfbfe878,bbb07080)
at netbsd:syscall+0x100
db{3}> 


Does this look familiar to anyone, or does anyone have any other ideas
or suggestions as to what could be wrong and I could try?

(if I can manage to clear some space on my rickety old build machine
I'll try building a -current kernel, but at the moment I don't even have
the -current tools built.)


Now clearly I'm off in virgin territory, but unless someone happens to
have a working, tested, pullup request already in the releng queue to
fit i82579LM (and i82577) support into netbsd-5, I'd like to try to try
to get this backport of the current driver working myself.

Here are the basic changes I made to the driver itself, after which I
copied sys/dev/pci/if_wm* to my netbsd-5 source tree.  I also pulled up
sys/dev/pci/pcidevs of course, and fixed some fallout from that.
(I'll backport ihphy(4) as well, but I don't think it can be causing the
panic above.)

Index: sys/dev/pci/if_wm.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/sys/dev/pci/if_wm.c,v
retrieving revision 1.225
diff -u -r1.225 if_wm.c
--- sys/dev/pci/if_wm.c 28 Nov 2011 18:21:46 -0000      1.225
+++ sys/dev/pci/if_wm.c 21 Dec 2011 01:09:31 -0000
@@ -130,6 +130,14 @@
 #include <dev/pci/if_wmreg.h>
 #include <dev/pci/if_wmvar.h>
 
+#if __NetBSD_Version__ < 106010000     /* 1.6A is not right, but good enough! 
*/
+/* XXX HACK ALERT! */
+# define aprint_naive  printf
+# define aprint_normal printf
+# define aprint_verbose printf
+# define aprint_error  printf
+#endif
+
 #ifdef WM_DEBUG
 #define        WM_DEBUG_LINK           0x01
 #define        WM_DEBUG_TX             0x02
@@ -379,7 +387,12 @@
        int sc_mchash_type;             /* multicast filter offset */
 
 #if NRND > 0
+/* this was quite a bit too early, but 599005800 is a few days too late */
+# if __NetBSD_Version__ < 599005700
+       rndsource_element_t rnd_source; /* random source */
+# else
        krndsource_t rnd_source;        /* random source */
+# endif
 #endif
 };
 
@@ -497,12 +510,19 @@
 
 static void    wm_start(struct ifnet *);
 static void    wm_watchdog(struct ifnet *);
+#if __NetBSD_Version__ >= 599003700    /* actually part of the major if_ether 
rework? */
 static int     wm_ifflags_cb(struct ethercom *);
+#endif
 static int     wm_ioctl(struct ifnet *, u_long, void *);
 static int     wm_init(struct ifnet *);
 static void    wm_stop(struct ifnet *, int);
+#if __NetBSD_Version__ < 599001800
+static bool    wm_suspend(device_t PMF_FN_PROTO);
+static bool    wm_resume(device_t PMF_FN_PROTO);
+#else
 static bool    wm_suspend(device_t, const pmf_qual_t *);
 static bool    wm_resume(device_t, const pmf_qual_t *);
+#endif
 
 static void    wm_reset(struct wm_softc *);
 static void    wm_rxdrain(struct wm_softc *);
@@ -610,8 +630,26 @@
 #endif
 static void    wm_init_manageability(struct wm_softc *);
 
+
+#ifdef CFATTACH_DECL3_NEW
 CFATTACH_DECL3_NEW(wm, sizeof(struct wm_softc),
     wm_match, wm_attach, wm_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
+#else
+# ifdef CFATTACH_DECL2_NEW
+CFATTACH_DECL2_NEW(wm, sizeof(struct wm_softc),
+    wm_match, wm_attach, wm_detach, NULL, NULL, NULL);
+# else
+#  ifdef CFATTACH_DECL                 /* #if __NetBSD_Version__ >= 106080000 
*/
+CFATTACH_DECL_NEW(wm, sizeof(struct wm_softc),
+    wm_match, wm_attach, NULL, NULL);
+#  else
+const struct cfattach wm_pci_ca = {
+       sizeof(struct wm_softc), wm_match, wm_attach
+};
+#  endif
+# endif
+#endif
+
 
 /*
  * Devices supported by this driver.
@@ -1958,7 +1996,9 @@
         */
        if_attach(ifp);
        ether_ifattach(ifp, enaddr);
+#if __NetBSD_Version__ >= 599003700    /* actually part of the major if_ether 
rework? */
        ether_set_ifflags_cb(&sc->sc_ethercom, wm_ifflags_cb);
+#endif
 #if NRND > 0
        rnd_attach_source(&sc->rnd_source, xname, RND_TYPE_NET, 0);
 #endif
@@ -2778,6 +2818,7 @@
        wm_start(ifp);
 }
 
+#if __NetBSD_Version__ >= 599003700    /* actually part of the major if_ether 
rework? */
 static int
 wm_ifflags_cb(struct ethercom *ec)
 {
@@ -2798,6 +2839,7 @@
 
        return 0;
 }
+#endif
 
 /*
  * wm_ioctl:           [ifnet interface function]
@@ -3603,7 +3645,7 @@
                if (wm_check_reset_block(sc) == 0) {
                        /*
                         * Gate automatic PHY configuration by hardware on
-                        * manaed 82579
+                        * managed 82579
                         */
                        if ((sc->sc_type == WM_T_PCH2)
                            && ((CSR_READ(sc, WMREG_FWSM) & FWSM_FW_VALID)
@@ -7759,7 +7801,13 @@
 #endif /* WM_WOL */
 
 static bool
-wm_suspend(device_t self, const pmf_qual_t *qual)
+wm_suspend(device_t self
+#if __NetBSD_Version__ < 599001800
+          PMF_FN_PROTO unused
+#else
+          , const pmf_qual_t *qual
+#endif
+         )
 {
        struct wm_softc *sc = device_private(self);
 
@@ -7773,7 +7821,13 @@
 }
 
 static bool
-wm_resume(device_t self, const pmf_qual_t *qual)
+wm_resume(device_t self
+#if __NetBSD_Version__ < 599001800
+          PMF_FN_PROTO unused
+#else
+          , const pmf_qual_t *qual
+#endif
+         )
 {
        struct wm_softc *sc = device_private(self);
 


-- 
                                                Greg A. Woods
                                                Planix, Inc.

<woods%planix.com@localhost>       +1 250 762-7675        http://www.planix.com/

Attachment: pgpWx5Tk3Zmbi.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index