PERFORCE change 68225 for review
Sam Leffler
sam at FreeBSD.org
Mon Jan 3 22:27:33 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=68225
Change 68225 by sam at sam_ebb on 2005/01/03 22:26:43
more frivolous futzing with fine leds:
o fix edge case where marking the interface down in the middle
of a blink stopped future blinks
o add hearbeat blink when otherwise idle (interval is controllable
for now fine tuning)
o make rx events be triggered by data frames instead of !beacon
frames; this is closer to how other devices work
Affected files ...
.. //depot/projects/wifi/sys/dev/ath/if_ath.c#55 edit
.. //depot/projects/wifi/sys/dev/ath/if_athvar.h#23 edit
Differences ...
==== //depot/projects/wifi/sys/dev/ath/if_ath.c#55 (text+ko) ====
@@ -96,6 +96,7 @@
enum {
ATH_LED_TX,
ATH_LED_RX,
+ ATH_LED_POLL,
};
static void ath_init(void *);
@@ -446,7 +447,10 @@
goto bad2;
}
+ sc->sc_blinking = 0;
sc->sc_ledstate = 1;
+ sc->sc_ledon = 0; /* low true */
+ sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */
callout_init(&sc->sc_ledtimer, CALLOUT_MPSAFE);
/*
* Auto-enable soft led processing for IBM cards and for
@@ -455,7 +459,6 @@
*/
sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID);
if (sc->sc_softled) {
- sc->sc_ledon = 0; /* low true */
ath_hal_gpioCfgOutput(ah, sc->sc_ledpin);
ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon);
}
@@ -945,6 +948,7 @@
callout_stop(&sc->sc_ledtimer);
ath_hal_gpioset(ah, sc->sc_ledpin,
!sc->sc_ledon);
+ sc->sc_blinking = 0;
}
ath_hal_intrset(ah, 0);
}
@@ -2723,16 +2727,17 @@
if (sc->sc_softled) {
/*
- * Blink for any non-beacon frames. We decide if
- * this was a beacon frame by monitoring the stats
- * which means we'll blink for things like ACK frames
- * when in monitor mode--probably not what we want.
+ * Blink for any data frame. Otherwise do a
+ * heartbeat-style blink when idle. The latter
+ * is mainly for station mode where we depend on
+ * periodic beacon frames to trigger the poll event.
*/
- if (sc->sc_beacon == ic->ic_stats.is_rx_beacon) {
+ if (sc->sc_ipackets != ifp->if_ipackets) {
+ sc->sc_ipackets = ifp->if_ipackets;
sc->sc_rxrate = ds->ds_rxstat.rs_rate;
ath_led_event(sc, ATH_LED_RX);
- } else
- sc->sc_beacon = ic->ic_stats.is_rx_beacon;
+ } else if (ticks - sc->sc_ledevent >= sc->sc_ledidle)
+ ath_led_event(sc, ATH_LED_POLL);
}
/*
@@ -4064,9 +4069,15 @@
static void
ath_led_event(struct ath_softc *sc, int event)
{
+
+ sc->sc_ledevent = ticks; /* time of last event */
if (sc->sc_blinking) /* don't interrupt active blink */
return;
switch (event) {
+ case ATH_LED_POLL:
+ ath_led_blink(sc, sc->sc_hwmap[0].ledon,
+ sc->sc_hwmap[0].ledoff);
+ break;
case ATH_LED_TX:
ath_led_blink(sc, sc->sc_hwmap[sc->sc_txrate].ledon,
sc->sc_hwmap[sc->sc_txrate].ledoff);
@@ -4458,9 +4469,12 @@
return error;
softled = (softled != 0);
if (softled != sc->sc_softled) {
- if (softled)
+ if (softled) {
+ /* NB: handle any sc_ledpin change */
ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin);
- ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon);
+ ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin,
+ !sc->sc_ledon);
+ }
sc->sc_softled = softled;
}
return 0;
@@ -4574,6 +4588,9 @@
"ledon", CTLFLAG_RW, &sc->sc_ledon, 0,
"setting to turn LED on");
SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+ "ledidle", CTLFLAG_RW, &sc->sc_ledidle, 0,
+ "idle time for inactivity LED (ticks)");
+ SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"txantenna", CTLFLAG_RW, &sc->sc_txantenna, 0,
"tx antenna (0=auto)");
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
==== //depot/projects/wifi/sys/dev/ath/if_athvar.h#23 (text+ko) ====
@@ -197,7 +197,9 @@
u_int sc_ledpin; /* GPIO pin for driving LED */
u_int sc_ledon; /* pin setting for LED on */
- u_int32_t sc_beacon; /* last beacon count */
+ u_int sc_ledidle; /* idle polling interval */
+ u_int32_t sc_ipackets; /* last data packet count */
+ int sc_ledevent; /* time of last LED event */
u_int8_t sc_rxrate; /* current rx rate for LED */
u_int8_t sc_txrate; /* current tx rate for LED */
u_int16_t sc_ledoff; /* off time for current blink */
More information about the p4-projects
mailing list