From e1c562d83a34307928d1726c484d37f6b87d8372 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 8 Jan 2013 22:15:13 +0000 Subject: Add support for triggering spectral scan upon a channel reset/change. This is intended to support reporting FFT results during active channel scans, for users who would like to fiddle around with writing applications that do both FFT visualisation _and_ AP scanning. * add a new ioctl to enable/trigger spectral scan at channel change/reset; * set do_spectral consistently if it's enabled, so a channel set/reset will carry forth the correct PHY error configuration so frames are actually received; * for NICs that don't do spectral scan, don't bother checking the spectral scan state on channel change/reset. Tested: * AR9280 - STA and scanning; * AR5416 - STA, ensured that the SS code doesn't panic --- sys/dev/ath/if_ath_spectral.c | 54 +++++++++++++++++++++++++++++++++++++++++-- sys/dev/ath/if_athioctl.h | 2 ++ 2 files changed, 54 insertions(+), 2 deletions(-) (limited to 'sys/dev/ath') diff --git a/sys/dev/ath/if_ath_spectral.c b/sys/dev/ath/if_ath_spectral.c index 0dc0114de08f..19d40fe55364 100644 --- a/sys/dev/ath/if_ath_spectral.c +++ b/sys/dev/ath/if_ath_spectral.c @@ -73,8 +73,21 @@ __FBSDID("$FreeBSD$"); struct ath_spectral_state { HAL_SPECTRAL_PARAM spectral_state; - int spectral_active; - int spectral_enabled; + + /* + * Should we enable spectral scan upon + * each network interface reset/change? + * + * This is intended to allow spectral scan + * frame reporting during channel scans. + * + * Later on it can morph into a larger + * scale config method where it pushes + * a "channel scan" config into the hardware + * rather than just the spectral_state + * config. + */ + int spectral_enable_after_reset; }; /* @@ -135,7 +148,20 @@ ath_spectral_detach(struct ath_softc *sc) int ath_spectral_enable(struct ath_softc *sc, struct ieee80211_channel *ch) { + struct ath_spectral_state *ss = sc->sc_spectral; + /* Default to disable spectral PHY reporting */ + sc->sc_dospectral = 0; + + if (ss == NULL) + return (0); + + if (ss->spectral_enable_after_reset) { + ath_hal_spectral_configure(sc->sc_ah, + &ss->spectral_state); + (void) ath_hal_spectral_start(sc->sc_ah); + sc->sc_dospectral = 1; + } return (0); } @@ -158,6 +184,7 @@ ath_ioctl_spectral(struct ath_softc *sc, struct ath_diag *ad) HAL_SPECTRAL_PARAM peout; HAL_SPECTRAL_PARAM *pe; struct ath_spectral_state *ss = sc->sc_spectral; + int val; if (! ath_hal_spectral_supported(sc->sc_ah)) return (EINVAL); @@ -212,9 +239,32 @@ ath_ioctl_spectral(struct ath_softc *sc, struct ath_diag *ad) ath_hal_spectral_configure(sc->sc_ah, &ss->spectral_state); (void) ath_hal_spectral_start(sc->sc_ah); + sc->sc_dospectral = 1; + /* XXX need to update the PHY mask in the driver */ break; case SPECTRAL_CONTROL_STOP: (void) ath_hal_spectral_stop(sc->sc_ah); + sc->sc_dospectral = 0; + /* XXX need to update the PHY mask in the driver */ + break; + case SPECTRAL_CONTROL_ENABLE_AT_RESET: + if (insize < sizeof(int)) { + device_printf(sc->sc_dev, "%d != %d\n", + insize, + sizeof(int)); + error = EINVAL; + break; + } + if (indata == NULL) { + device_printf(sc->sc_dev, "indata=NULL\n"); + error = EINVAL; + break; + } + val = * ((int *) indata); + if (val == 0) + ss->spectral_enable_after_reset = 0; + else + ss->spectral_enable_after_reset = 1; break; case SPECTRAL_CONTROL_ENABLE: /* XXX TODO */ diff --git a/sys/dev/ath/if_athioctl.h b/sys/dev/ath/if_athioctl.h index d6adf94064ba..f7b860054855 100644 --- a/sys/dev/ath/if_athioctl.h +++ b/sys/dev/ath/if_athioctl.h @@ -427,5 +427,7 @@ struct ath_tx_radiotap_header { #define SPECTRAL_CONTROL_STOP 5 #define SPECTRAL_CONTROL_GET_PARAMS 6 #define SPECTRAL_CONTROL_SET_PARAMS 7 +#define SPECTRAL_CONTROL_ENABLE_AT_RESET 8 +#define SPECTRAL_CONTROL_DISABLE_AT_RESET 9 #endif /* _DEV_ATH_ATHIOCTL_H */ -- cgit v1.3