diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2009-11-19 22:14:23 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2009-11-19 22:14:23 +0000 |
| commit | e55bc0154dddb1fa0087f2858229691bbf6b5429 (patch) | |
| tree | 56a1666c810529df49b7c20e9c73407f13a80405 /sys/dev/tl | |
| parent | 7cf545d0a16bce3e3ecda172a69504aee58f3e14 (diff) | |
Notes
Diffstat (limited to 'sys/dev/tl')
| -rw-r--r-- | sys/dev/tl/if_tl.c | 23 | ||||
| -rw-r--r-- | sys/dev/tl/if_tlreg.h | 1 |
2 files changed, 13 insertions, 11 deletions
diff --git a/sys/dev/tl/if_tl.c b/sys/dev/tl/if_tl.c index 2d23b5ee2705b..d18d21a63b69c 100644 --- a/sys/dev/tl/if_tl.c +++ b/sys/dev/tl/if_tl.c @@ -281,7 +281,7 @@ static int tl_ioctl(struct ifnet *, u_long, caddr_t); static void tl_init(void *); static void tl_init_locked(struct tl_softc *); static void tl_stop(struct tl_softc *); -static void tl_watchdog(struct ifnet *); +static void tl_watchdog(struct tl_softc *); static int tl_shutdown(device_t); static int tl_ifmedia_upd(struct ifnet *); static void tl_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -1260,7 +1260,6 @@ tl_attach(dev) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = tl_ioctl; ifp->if_start = tl_start; - ifp->if_watchdog = tl_watchdog; ifp->if_init = tl_init; ifp->if_mtu = ETHERMTU; ifp->if_snd.ifq_maxlen = TL_TX_LIST_CNT - 1; @@ -1337,11 +1336,11 @@ tl_detach(dev) /* These should only be active if attach succeeded */ if (device_is_attached(dev)) { + ether_ifdetach(ifp); TL_LOCK(sc); tl_stop(sc); TL_UNLOCK(sc); callout_drain(&sc->tl_stat_callout); - ether_ifdetach(ifp); } if (sc->tl_miibus) device_delete_child(dev, sc->tl_miibus); @@ -1635,7 +1634,7 @@ tl_intvec_txeoc(xsc, type) ifp = sc->tl_ifp; /* Clear the timeout timer. */ - ifp->if_timer = 0; + sc->tl_timer = 0; if (sc->tl_cdata.tl_tx_head == NULL) { ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -1821,6 +1820,9 @@ tl_stats_update(xsc) } } + if (sc->tl_timer > 0 && --sc->tl_timer == 0) + tl_watchdog(sc); + callout_reset(&sc->tl_stat_callout, hz, tl_stats_update, sc); if (!sc->tl_bitrate) { @@ -2029,7 +2031,7 @@ tl_start_locked(ifp) /* * Set a timeout in case the chip goes out to lunch. */ - ifp->if_timer = 5; + sc->tl_timer = 5; return; } @@ -2254,21 +2256,20 @@ tl_ioctl(ifp, command, data) } static void -tl_watchdog(ifp) - struct ifnet *ifp; -{ +tl_watchdog(sc) struct tl_softc *sc; +{ + struct ifnet *ifp; - sc = ifp->if_softc; + TL_LOCK_ASSERT(sc); + ifp = sc->tl_ifp; if_printf(ifp, "device timeout\n"); - TL_LOCK(sc); ifp->if_oerrors++; tl_softreset(sc, 1); tl_init_locked(sc); - TL_UNLOCK(sc); return; } diff --git a/sys/dev/tl/if_tlreg.h b/sys/dev/tl/if_tlreg.h index 46a79865b5b63..f0347e769ee03 100644 --- a/sys/dev/tl/if_tlreg.h +++ b/sys/dev/tl/if_tlreg.h @@ -125,6 +125,7 @@ struct tl_softc { int tl_if_flags; struct callout tl_stat_callout; struct mtx tl_mtx; + int tl_timer; }; #define TL_LOCK(_sc) mtx_lock(&(_sc)->tl_mtx) |
