diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c index ff22fb800064..e2f27e66e67e 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c @@ -462,13 +462,55 @@ ar9300_ani_control(struct ath_hal *ah, HAL_ANI_CMD cmd, int param) u_int level = param; u_int is_on; + HALDEBUG(ah, HAL_DEBUG_ANI, "%s: cmd=%d, param=%d, chan=%p, funcmask=0x%08x\n", + __func__, + cmd, + param, + chan, + ahp->ah_ani_function); + + if (chan == NULL && cmd != HAL_ANI_MODE) { HALDEBUG(ah, HAL_DEBUG_UNMASKABLE, "%s: ignoring cmd 0x%02x - no channel\n", __func__, cmd); return AH_FALSE; } - switch (cmd & ahp->ah_ani_function) { + /* + * These two control the top-level cck/ofdm immunity levels and will + * program the rest of the values. + */ + if (cmd == HAL_ANI_NOISE_IMMUNITY_LEVEL) { + if (param > HAL_ANI_OFDM_NUM_LEVEL) + return AH_FALSE; + ar9300_ani_set_odfm_noise_immunity_level(ah, param); + return AH_TRUE; + } + + if (cmd == HAL_ANI_CCK_NOISE_IMMUNITY_LEVEL) { + if (param > HAL_ANI_CCK_NUM_LEVEL) + return AH_FALSE; + ar9300_ani_set_cck_noise_immunity_level(ah, param); + return AH_TRUE; + } + + /* + * Check to see if this command is available in the + * current operating mode. + */ + if (((1 << cmd) & ahp->ah_ani_function) == 0) { + HALDEBUG(ah, HAL_DEBUG_ANI, + "%s: early check: invalid cmd 0x%02x (allowed=0x%02x)\n", + __func__, cmd, ahp->ah_ani_function); + return AH_FALSE; + } + + /* + * The rest of these program in the requested parameter values + * into the PHY. + */ + switch (cmd) { + case HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION: { int m1_thresh_low, m2_thresh_low; @@ -887,13 +929,16 @@ ar9300_ani_reset(struct ath_hal *ah, HAL_BOOL is_scanning) /* only allow a subset of functions in AP mode */ if (AH_PRIVATE(ah)->ah_opmode == HAL_M_HOSTAP) { if (IS_CHAN_2GHZ(ichan)) { - ahp->ah_ani_function = (HAL_ANI_SPUR_IMMUNITY_LEVEL | - HAL_ANI_FIRSTEP_LEVEL | - HAL_ANI_MRC_CCK); + ahp->ah_ani_function = (1 << HAL_ANI_SPUR_IMMUNITY_LEVEL) | + (1 << HAL_ANI_FIRSTEP_LEVEL) | + (1 << HAL_ANI_MRC_CCK); } else { ahp->ah_ani_function = 0; } + } else { + ahp->ah_ani_function = HAL_ANI_ALL; } + /* always allow mode (on/off) to be controlled */ ahp->ah_ani_function |= HAL_ANI_MODE; diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c index 52454b58077d..1793cf06378b 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c @@ -1268,7 +1268,7 @@ ar9300_get_diag_state(struct ath_hal *ah, int request, ahp->ext_ani_state.spurImmunityLevel = ani->spur_immunity_level; ahp->ext_ani_state.firstepLevel = ani->firstep_level; ahp->ext_ani_state.ofdmWeakSigDetectOff = ani->ofdm_weak_sig_detect_off; - ahp->ext_ani_state.mrcCckOff = ani->mrc_cck_off; + ahp->ext_ani_state.mrcCck = !! ani->mrc_cck_off; ahp->ext_ani_state.cckNoiseImmunityLevel = ani->cck_noise_immunity_level; ahp->ext_ani_state.listenTime = ani->listen_time; @@ -1287,12 +1287,18 @@ ar9300_get_diag_state(struct ath_hal *ah, int request, 0 : sizeof(HAL_ANI_STATS); return AH_TRUE; case HAL_DIAG_ANI_CMD: + { + HAL_ANI_CMD savefunc = ahp->ah_ani_function; if (argsize != 2*sizeof(u_int32_t)) { return AH_FALSE; } + /* temporarly allow all functions so we can override */ + ahp->ah_ani_function = HAL_ANI_ALL; ar9300_ani_control( ah, ((const u_int32_t *)args)[0], ((const u_int32_t *)args)[1]); + ahp->ah_ani_function = savefunc; return AH_TRUE; + } #if 0 case HAL_DIAG_TXCONT: /*AR9300_CONTTXMODE(ah, (struct ath_desc *)args, argsize );*/