summaryrefslogtreecommitdiffstats
path: root/sys/dev/stge
diff options
context:
space:
mode:
authoryongari <yongari@FreeBSD.org>2007-05-01 03:15:04 +0000
committeryongari <yongari@FreeBSD.org>2007-05-01 03:15:04 +0000
commit5f685fc1dc9b6bbebc958f733b9d99cdf82e0111 (patch)
tree8a28461d70ba50fbfaf1b5e1feff42bd802a1e7c /sys/dev/stge
parent9c008bb303f5e83730828adf7adc7316a6bd7715 (diff)
downloadFreeBSD-src-5f685fc1dc9b6bbebc958f733b9d99cdf82e0111.zip
FreeBSD-src-5f685fc1dc9b6bbebc958f733b9d99cdf82e0111.tar.gz
Use our own timer for watchdog instead of if_watchdog/if_timer
interface.
Diffstat (limited to 'sys/dev/stge')
-rw-r--r--sys/dev/stge/if_stge.c27
-rw-r--r--sys/dev/stge/if_stgereg.h1
2 files changed, 17 insertions, 11 deletions
diff --git a/sys/dev/stge/if_stge.c b/sys/dev/stge/if_stge.c
index caca238..10ca8d5 100644
--- a/sys/dev/stge/if_stge.c
+++ b/sys/dev/stge/if_stge.c
@@ -137,7 +137,7 @@ static int stge_resume(device_t);
static int stge_encap(struct stge_softc *, struct mbuf **);
static void stge_start(struct ifnet *);
static void stge_start_locked(struct ifnet *);
-static void stge_watchdog(struct ifnet *);
+static void stge_watchdog(struct stge_softc *);
static int stge_ioctl(struct ifnet *, u_long, caddr_t);
static void stge_init(void *);
static void stge_init_locked(struct stge_softc *);
@@ -744,7 +744,8 @@ stge_attach(device_t dev)
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = stge_ioctl;
ifp->if_start = stge_start;
- ifp->if_watchdog = stge_watchdog;
+ ifp->if_timer = 0;
+ ifp->if_watchdog = NULL;
ifp->if_init = stge_init;
ifp->if_mtu = ETHERMTU;
ifp->if_snd.ifq_drv_maxlen = STGE_TX_RING_CNT - 1;
@@ -1354,27 +1355,29 @@ stge_start_locked(struct ifnet *ifp)
CSR_WRITE_4(sc, STGE_DMACtrl, DMAC_TxDMAPollNow);
/* Set a timeout in case the chip goes out to lunch. */
- ifp->if_timer = 5;
+ sc->sc_watchdog_timer = 5;
}
}
/*
- * stge_watchdog: [ifnet interface function]
+ * stge_watchdog:
*
* Watchdog timer handler.
*/
static void
-stge_watchdog(struct ifnet *ifp)
+stge_watchdog(struct stge_softc *sc)
{
- struct stge_softc *sc;
+ struct ifnet *ifp;
- sc = ifp->if_softc;
+ STGE_LOCK_ASSERT(sc);
- STGE_LOCK(sc);
+ if (sc->sc_watchdog_timer == 0 || --sc->sc_watchdog_timer)
+ return;
+
+ ifp = sc->sc_ifp;
if_printf(sc->sc_ifp, "device timeout\n");
ifp->if_oerrors++;
stge_init_locked(sc);
- STGE_UNLOCK(sc);
}
/*
@@ -1677,7 +1680,7 @@ stge_txeof(struct stge_softc *sc)
}
sc->sc_cdata.stge_tx_cons = cons;
if (sc->sc_cdata.stge_tx_cnt == 0)
- ifp->if_timer = 0;
+ sc->sc_watchdog_timer = 0;
bus_dmamap_sync(sc->sc_cdata.stge_tx_ring_tag,
sc->sc_cdata.stge_tx_ring_map,
@@ -1952,6 +1955,8 @@ stge_tick(void *arg)
if (sc->sc_cdata.stge_tx_cnt != 0)
stge_txeof(sc);
+ stge_watchdog(sc);
+
callout_reset(&sc->sc_tick_ch, hz, stge_tick, sc);
}
@@ -2303,6 +2308,7 @@ stge_stop(struct stge_softc *sc)
* Stop the one second clock.
*/
callout_stop(&sc->sc_tick_ch);
+ sc->sc_watchdog_timer = 0;
/*
* Reset the chip to a known state.
@@ -2363,7 +2369,6 @@ stge_stop(struct stge_softc *sc)
*/
ifp = sc->sc_ifp;
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
- ifp->if_timer = 0;
}
static void
diff --git a/sys/dev/stge/if_stgereg.h b/sys/dev/stge/if_stgereg.h
index 1354439..55ab927 100644
--- a/sys/dev/stge/if_stgereg.h
+++ b/sys/dev/stge/if_stgereg.h
@@ -651,6 +651,7 @@ struct stge_softc {
int sc_rxint_nframe;
int sc_rxint_dmawait;
int sc_nerr;
+ int sc_watchdog_timer;
struct task sc_link_task;
struct mtx sc_mii_mtx; /* MII mutex */
OpenPOWER on IntegriCloud