hi, On 2019/02/28 06:53, Nils Frohberg wrote: > On Tue, Feb 26, 2019 at 08:57:57PM +0200, Artturi Alm wrote: >> On Tue, Feb 26, 2019 at 03:00:15PM +0100, Nils Frohberg wrote: [snip] >> Have you looked at what NetBSD has done with their axen(4)? there has >> been 20commits in 2019 so far[0], while some of them are possibly, >> idk., useless to us(thinking about hw checksum offloading), there was >> some bug fixes that did look relevant to me, but i succesfully >> installed&built kernels on nfs over axen(4) a couple of weeks ago, >> so the bugs it has didn't feel critical enough for me to make >> a branch for them. that was on arm64/dwctwo(4), tbh. i haven't been >> happy with axen(4) on amd64/{e,x}hci(4) myself in the past either. :] > > I wrote the diff last December. I looked at NetBSD's code back then, > but they didn't have any significant changes. > > At a cursory glance, many changes are similar to mine. But there are > a few things that should be worth looking at.
Do you see the link status LED of axen is down when ifconfig it up/down? The attached patch should fix that bug. I applied the diff of NetBSD's if_axen.c between rev 1.20 and 1.21 https://github.com/NetBSD/src/commit/4603809d1167ab5cc2d8d35f95722aec85789fd0#diff-4748c3be63ca566d4a07520285f031a9 to if_axen.c of 6.5-current with [1-7]/7 patches. The log reads: > Enable AXEN_RXCTL_START bit only when RX is ready. Otherwise, > the adapter eventually falls into "no carrier" state while it > is not running. I reverted 3/7 partially to keep previous value of AXEN_MAC_RXCTL reg, so that RXCTL_START is set only in axen_init and is reset in axen_stop. axen_reset does not initialise the chip any more. It does nothing but delay. The chip init, axen_ax88179_init, is called once while attach. --- sys/dev/usb/if_axen.c Wed Jun 12 12:52:01 2019 +++ sys/dev/usb/if_axen.c Thu Jun 13 09:19:32 2019 @@ -421,7 +421,10 @@ axen_iff(struct axen_softc *sc) /* Enable receiver, set RX mode */ axen_lock_mii(sc); - rxmode = AXEN_RXCTL_DROPCRCERR | AXEN_RXCTL_START; + axen_cmd(sc, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval); + rxmode = UGETW(wval); + rxmode &= ~(AXEN_RXCTL_ACPT_ALL_MCAST | AXEN_RXCTL_PROMISC | + AXEN_RXCTL_ACPT_MCAST); ifp->if_flags &= ~IFF_ALLMULTI; /* @@ -476,8 +479,6 @@ axen_reset(struct axen_softc *sc) /* Wait a little while for the chip to get its brains in order. */ DELAY(1000); - axen_ax88179_init(sc); - return; } @@ -486,7 +487,7 @@ axen_ax88179_init(struct axen_softc *sc) { uWord wval; uByte val; - u_int16_t ctl, temp; + u_int16_t ctl, rxmode, temp; DPRINTFN(2,("%s: %s: enter\n", sc->axen_dev.dv_xname,__func__)); @@ -565,6 +566,10 @@ axen_ax88179_init(struct axen_softc *sc) axen_cmd(sc, AXEN_CMD_MAC_WRITE, 1, AXEN_PAUSE_HIGH_WATERMARK, &val); /* Set RX/TX configuration. */ + rxmode = AXEN_RXCTL_DROPCRCERR; + USETW(wval, rxmode); + axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval); + #ifdef AXEN_TOE /* enable offloading */ val = AXEN_RXCOE_IPv4 | @@ -1566,7 +1571,7 @@ axen_stop(struct axen_softc *sc) usbd_status err; struct ifnet *ifp; int i; - u_int16_t ctl; + u_int16_t ctl, rxmode; uWord wval; DPRINTFN(2,("%s: %s: enter\n", sc->axen_dev.dv_xname,__func__)); @@ -1578,7 +1583,13 @@ axen_stop(struct axen_softc *sc) timeout_del(&sc->axen_stat_ch); - /* disable receive */ + /* Disable receiver, set RX mode */ + axen_cmd(sc, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval); + rxmode = UGETW(&wval); + rxmode &= ~AXEN_RXCTL_START; + USETW(wval, rxmode); + axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval); + axen_cmd(sc, AXEN_CMD_MAC_READ2, 2, AXEN_MEDIUM_STATUS, &wval); ctl = UGETW(wval); ctl &= ~AXEN_MEDIUM_RECV_EN; >> I guess i'm trying to say maybe it wouldn't hurt to sync a bit before >> deviating as much as atleast your whole WIP diff did. I haven't read >> your separate patches yet, but i'll try to get around to also testing >> those before weekend:] > > The separate patches are (more or less) the big patch split up via > $(git add -p). There are a few things that might be worth looking > into, such as the pause water levels, enabling EEE, axen_bulk_size > values, buffer sizes, ... > > More testing would be great. Especially since this is the only box > I have where I can attach it to xhci. > >> -Artturi >> >> [0] https://github.com/NetBSD/src/commits/trunk/sys/dev/usb/if_axen.c >> >