diff options
author | raj <raj@FreeBSD.org> | 2008-08-26 09:38:28 +0000 |
---|---|---|
committer | raj <raj@FreeBSD.org> | 2008-08-26 09:38:28 +0000 |
commit | 95151c566b2fd63067837554caf4e0f2194561af (patch) | |
tree | 67ebdd501d0a6bad5c7bcdfb1b5f2bbe41b7fafa | |
parent | 7490ae7b0e7ec07f48d2423ab2ceee04145f1de4 (diff) | |
download | FreeBSD-src-95151c566b2fd63067837554caf4e0f2194561af.zip FreeBSD-src-95151c566b2fd63067837554caf4e0f2194561af.tar.gz |
tsec: Improve and clean up callouts.
- eliminate the unused tsec_tick_ch callout
- adjust and fix the main tsec callout handling
- minor naming improvements
Obtained from: Semihalf
-rw-r--r-- | sys/dev/tsec/if_tsec.c | 27 | ||||
-rw-r--r-- | sys/dev/tsec/if_tsec.h | 7 |
2 files changed, 15 insertions, 19 deletions
diff --git a/sys/dev/tsec/if_tsec.c b/sys/dev/tsec/if_tsec.c index b22d7d1..e2bf15b 100644 --- a/sys/dev/tsec/if_tsec.c +++ b/sys/dev/tsec/if_tsec.c @@ -368,16 +368,14 @@ tsec_init_locked(struct tsec_softc *sc) /* Step 23: Reset TSEC counters for Tx and Rx rings */ TSEC_TX_RX_COUNTERS_INIT(sc); - /* Step 24: Activate timer for PHY */ - callout_reset(&sc->tsec_tick_ch, hz, tsec_tick, sc); - - /* Step 25: Activate network interface */ + /* Step 24: Activate network interface */ ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; sc->tsec_if_flags = ifp->if_flags; + sc->tsec_watchdog = 0; /* Schedule watchdog timeout */ - callout_reset(&sc->wd_callout, hz, tsec_tick, sc); + callout_reset(&sc->tsec_callout, hz, tsec_tick, sc); } static void @@ -517,7 +515,7 @@ tsec_watchdog(struct tsec_softc *sc) TSEC_GLOBAL_LOCK_ASSERT(sc); - if (sc->wd_timer == 0 || --sc->wd_timer > 0) + if (sc->tsec_watchdog == 0 || --sc->tsec_watchdog > 0) return; ifp = sc->tsec_ifp; @@ -584,7 +582,7 @@ tsec_start_locked(struct ifnet *ifp) if (queued) { /* Enable transmitter and watchdog timer */ TSEC_WRITE(sc, TSEC_REG_TSTAT, TSEC_TSTAT_THLT); - sc->wd_timer = 5; + sc->tsec_watchdog = 5; } } @@ -917,7 +915,7 @@ tsec_attach(device_t dev) if (device_get_unit(dev) == 0) tsec0_sc = sc; /* XXX */ - callout_init(&sc->tsec_tick_ch, 1); + callout_init(&sc->tsec_callout, 1); mtx_init(&sc->transmit_lock, device_get_nameunit(dev), "TSEC TX lock", MTX_DEF); mtx_init(&sc->receive_lock, device_get_nameunit(dev), "TSEC RX lock", @@ -1076,7 +1074,6 @@ tsec_attach(device_t dev) tsec_get_hwaddr(sc, hwaddr); ether_ifattach(ifp, hwaddr); - callout_init(&sc->wd_callout, 0); /* Interrupts configuration (TX/RX/ERR) */ sc->sc_transmit_irid = OCP_TSEC_RID_TXIRQ; @@ -1207,7 +1204,7 @@ tsec_detach(device_t dev) tsec_shutdown(dev); /* Wait for stopping TSEC ticks */ - callout_drain(&sc->tsec_tick_ch); + callout_drain(&sc->tsec_callout); /* Stop and release all interrupts */ tsec_release_intr(dev, sc->sc_transmit_ires, sc->sc_transmit_ihand, @@ -1282,12 +1279,12 @@ tsec_stop(struct tsec_softc *sc) ifp = sc->tsec_ifp; - /* Stop PHY tick engine */ - callout_stop(&sc->tsec_tick_ch); + /* Stop tick engine */ + callout_stop(&sc->tsec_callout); /* Disable interface and watchdog timer */ ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - sc->wd_timer = 0; + sc->tsec_watchdog = 0; /* Disable all interrupts and stop DMA */ tsec_intrs_ctl(sc, 0); @@ -1472,7 +1469,7 @@ tsec_transmit_intr(void *arg) /* Stop watchdog if all sent */ if (TSEC_EMPTYQ_TX_MBUF(sc)) - sc->wd_timer = 0; + sc->tsec_watchdog = 0; } TSEC_TRANSMIT_UNLOCK(sc); } @@ -1548,7 +1545,7 @@ tsec_tick(void *xsc) tsec_start_locked(ifp); /* Schedule another timeout one second from now. */ - callout_reset(&sc->wd_callout, hz, tsec_tick, sc); + callout_reset(&sc->tsec_callout, hz, tsec_tick, sc); TSEC_GLOBAL_UNLOCK(sc); } diff --git a/sys/dev/tsec/if_tsec.h b/sys/dev/tsec/if_tsec.h index c143509..9b7b331 100644 --- a/sys/dev/tsec/if_tsec.h +++ b/sys/dev/tsec/if_tsec.h @@ -46,7 +46,6 @@ struct tsec_softc { device_t dev; device_t tsec_miibus; struct mii_data *tsec_mii; /* MII media control */ - struct callout tsec_tick_ch; int tsec_link; bus_dma_tag_t tsec_tx_dtag; /* TX descriptors tag */ @@ -91,9 +90,9 @@ struct tsec_softc { int tsec_if_flags; - /* Watchdog related */ - struct callout wd_callout; - int wd_timer; + /* Watchdog and MII tick related */ + struct callout tsec_callout; + int tsec_watchdog; /* TX maps */ bus_dmamap_t tx_map_data[TSEC_TX_NUM_DESC]; |