Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Nov 2009 20:27:53 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r199197 - head/sys/dev/bwi
Message-ID:  <200911112027.nABKRriX005987@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Nov 11 20:27:53 2009
New Revision: 199197
URL: http://svn.freebsd.org/changeset/base/199197

Log:
  Use a dedicated callout to drive the transmit watchdog timer instead of
  using if_watchdog and if_timer.
  
  Tested by:	gavin

Modified:
  head/sys/dev/bwi/if_bwi.c
  head/sys/dev/bwi/if_bwivar.h

Modified: head/sys/dev/bwi/if_bwi.c
==============================================================================
--- head/sys/dev/bwi/if_bwi.c	Wed Nov 11 20:00:57 2009	(r199196)
+++ head/sys/dev/bwi/if_bwi.c	Wed Nov 11 20:27:53 2009	(r199197)
@@ -106,7 +106,7 @@ static void	bwi_start(struct ifnet *);
 static void	bwi_start_locked(struct ifnet *);
 static int	bwi_raw_xmit(struct ieee80211_node *, struct mbuf *,
 			const struct ieee80211_bpf_params *);
-static void	bwi_watchdog(struct ifnet *);
+static void	bwi_watchdog(void *);
 static void	bwi_scan_start(struct ieee80211com *);
 static void	bwi_set_channel(struct ieee80211com *);
 static void	bwi_scan_end(struct ieee80211com *);
@@ -464,10 +464,10 @@ bwi_attach(struct bwi_softc *sc)
 	ifp->if_init = bwi_init;
 	ifp->if_ioctl = bwi_ioctl;
 	ifp->if_start = bwi_start;
-	ifp->if_watchdog = bwi_watchdog;
 	IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
 	ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
 	IFQ_SET_READY(&ifp->if_snd);
+	callout_init_mtx(&sc->sc_watchdog_timer, &sc->sc_mtx, 0);
 
 	/*
 	 * Setup ratesets, phytype, channels and get MAC address
@@ -581,6 +581,7 @@ bwi_detach(struct bwi_softc *sc)
 	bwi_stop(sc, 1);
 	callout_drain(&sc->sc_led_blink_ch);
 	callout_drain(&sc->sc_calib_ch);
+	callout_drain(&sc->sc_watchdog_timer);
 	ieee80211_ifdetach(ic);
 
 	for (i = 0; i < sc->sc_nmac; ++i)
@@ -1295,6 +1296,7 @@ bwi_init_statechg(struct bwi_softc *sc, 
 	sc->sc_flags &= ~BWI_F_STOP;
 
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
+	callout_reset(&sc->sc_watchdog_timer, hz, bwi_watchdog, sc);
 
 	/* Enable intrs */
 	bwi_enable_intrs(sc, BWI_INIT_INTRS);
@@ -1433,7 +1435,7 @@ bwi_start_locked(struct ifnet *ifp)
 	tbd->tbd_idx = idx;
 
 	if (trans)
-		ifp->if_timer = 5;
+		sc->sc_tx_timer = 5;
 }
 
 static int
@@ -1474,7 +1476,7 @@ bwi_raw_xmit(struct ieee80211_node *ni, 
 		if (++tbd->tbd_used + BWI_TX_NSPRDESC >= BWI_TX_NDESC)
 			ifp->if_drv_flags |= IFF_DRV_OACTIVE;
 		tbd->tbd_idx = (idx + 1) % BWI_TX_NDESC;
-		ifp->if_timer = 5;
+		sc->sc_tx_timer = 5;
 	} else {
 		/* NB: m is reclaimed on encap failure */
 		ieee80211_free_node(ni);
@@ -1485,17 +1487,20 @@ bwi_raw_xmit(struct ieee80211_node *ni, 
 }
 
 static void
-bwi_watchdog(struct ifnet *ifp)
+bwi_watchdog(void *arg)
 {
-	struct bwi_softc *sc = ifp->if_softc;
+	struct bwi_softc *sc;
+	struct ifnet *ifp;
 
-	BWI_LOCK(sc);
-	if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+	sc = arg;
+	ifp = sc->sc_ifp;
+	BWI_ASSERT_LOCKED(sc);
+	if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0) {
 		if_printf(ifp, "watchdog timeout\n");
 		ifp->if_oerrors++;
 		taskqueue_enqueue(sc->sc_tq, &sc->sc_restart_task);
 	}
-	BWI_UNLOCK(sc);
+	callout_reset(&sc->sc_watchdog_timer, hz, bwi_watchdog, sc);
 }
 
 static void
@@ -1551,7 +1556,7 @@ bwi_stop_locked(struct bwi_softc *sc, in
 		bwi_bbp_power_off(sc);
 
 	sc->sc_tx_timer = 0;
-	ifp->if_timer = 0;
+	callout_stop(&sc->sc_watchdog_timer);
 	ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
 }
 
@@ -3420,7 +3425,7 @@ _bwi_txeof(struct bwi_softc *sc, uint16_
 	tb->tb_mbuf = NULL;
 
 	if (tbd->tbd_used == 0)
-		ifp->if_timer = 0;
+		sc->sc_tx_timer = 0;
 
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 }
@@ -3922,7 +3927,7 @@ bwi_led_attach(struct bwi_softc *sc)
 			"%dth led, act %d, lowact %d\n", i,
 			led->l_act, led->l_flags & BWI_LED_F_ACTLOW);
 	}
-	callout_init(&sc->sc_led_blink_ch, CALLOUT_MPSAFE);
+	callout_init_mtx(&sc->sc_led_blink_ch, &sc->sc_mtx, 0);
 }
 
 static __inline uint16_t

Modified: head/sys/dev/bwi/if_bwivar.h
==============================================================================
--- head/sys/dev/bwi/if_bwivar.h	Wed Nov 11 20:00:57 2009	(r199196)
+++ head/sys/dev/bwi/if_bwivar.h	Wed Nov 11 20:27:53 2009	(r199197)
@@ -578,6 +578,7 @@ struct bwi_softc {
 	bus_space_handle_t	sc_mem_bh;
 
 	struct callout		sc_calib_ch;
+	struct callout	sc_watchdog_timer;
 
 	struct bwi_regwin	*sc_cur_regwin;
 	struct bwi_regwin	sc_com_regwin;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911112027.nABKRriX005987>