Commit 8eb4980c authored by Felix Fietkau's avatar Felix Fietkau Committed by John W. Linville

ath9k_hw: remove function pointer abstraction for internal ANI ops

The code gets more concise and readable when making the new ANI functions
fall back to the old ones if ANI v2 is disabled. This also makes further code
cleanup easier.
Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent bfc472bb
...@@ -103,12 +103,6 @@ static const struct ani_cck_level_entry cck_level_table[] = { ...@@ -103,12 +103,6 @@ static const struct ani_cck_level_entry cck_level_table[] = {
#define ATH9K_ANI_CCK_DEF_LEVEL \ #define ATH9K_ANI_CCK_DEF_LEVEL \
2 /* default level - matches the INI settings */ 2 /* default level - matches the INI settings */
/* Private to ani.c */
static void ath9k_hw_ani_lower_immunity(struct ath_hw *ah)
{
ath9k_hw_private_ops(ah)->ani_lower_immunity(ah);
}
static bool use_new_ani(struct ath_hw *ah) static bool use_new_ani(struct ath_hw *ah)
{ {
return AR_SREV_9300_20_OR_LATER(ah) || modparam_force_new_ani; return AR_SREV_9300_20_OR_LATER(ah) || modparam_force_new_ani;
...@@ -165,9 +159,6 @@ static void ath9k_hw_ani_ofdm_err_trigger_old(struct ath_hw *ah) ...@@ -165,9 +159,6 @@ static void ath9k_hw_ani_ofdm_err_trigger_old(struct ath_hw *ah)
struct ar5416AniState *aniState; struct ar5416AniState *aniState;
int32_t rssi; int32_t rssi;
if (!DO_ANI(ah))
return;
aniState = &ah->curchan->ani; aniState = &ah->curchan->ani;
if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) { if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
...@@ -237,9 +228,6 @@ static void ath9k_hw_ani_cck_err_trigger_old(struct ath_hw *ah) ...@@ -237,9 +228,6 @@ static void ath9k_hw_ani_cck_err_trigger_old(struct ath_hw *ah)
struct ar5416AniState *aniState; struct ar5416AniState *aniState;
int32_t rssi; int32_t rssi;
if (!DO_ANI(ah))
return;
aniState = &ah->curchan->ani; aniState = &ah->curchan->ani;
if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) { if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL, if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
...@@ -317,13 +305,18 @@ static void ath9k_hw_set_ofdm_nil(struct ath_hw *ah, u8 immunityLevel) ...@@ -317,13 +305,18 @@ static void ath9k_hw_set_ofdm_nil(struct ath_hw *ah, u8 immunityLevel)
} }
} }
static void ath9k_hw_ani_ofdm_err_trigger_new(struct ath_hw *ah) static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hw *ah)
{ {
struct ar5416AniState *aniState; struct ar5416AniState *aniState;
if (!DO_ANI(ah)) if (!DO_ANI(ah))
return; return;
if (!use_new_ani(ah)) {
ath9k_hw_ani_ofdm_err_trigger_old(ah);
return;
}
aniState = &ah->curchan->ani; aniState = &ah->curchan->ani;
if (aniState->ofdmNoiseImmunityLevel < ATH9K_ANI_OFDM_MAX_LEVEL) if (aniState->ofdmNoiseImmunityLevel < ATH9K_ANI_OFDM_MAX_LEVEL)
...@@ -374,13 +367,18 @@ static void ath9k_hw_set_cck_nil(struct ath_hw *ah, u_int8_t immunityLevel) ...@@ -374,13 +367,18 @@ static void ath9k_hw_set_cck_nil(struct ath_hw *ah, u_int8_t immunityLevel)
entry_cck->mrc_cck_on); entry_cck->mrc_cck_on);
} }
static void ath9k_hw_ani_cck_err_trigger_new(struct ath_hw *ah) static void ath9k_hw_ani_cck_err_trigger(struct ath_hw *ah)
{ {
struct ar5416AniState *aniState; struct ar5416AniState *aniState;
if (!DO_ANI(ah)) if (!DO_ANI(ah))
return; return;
if (!use_new_ani(ah)) {
ath9k_hw_ani_cck_err_trigger_old(ah);
return;
}
aniState = &ah->curchan->ani; aniState = &ah->curchan->ani;
if (aniState->cckNoiseImmunityLevel < ATH9K_ANI_CCK_MAX_LEVEL) if (aniState->cckNoiseImmunityLevel < ATH9K_ANI_CCK_MAX_LEVEL)
...@@ -444,12 +442,17 @@ static void ath9k_hw_ani_lower_immunity_old(struct ath_hw *ah) ...@@ -444,12 +442,17 @@ static void ath9k_hw_ani_lower_immunity_old(struct ath_hw *ah)
* only lower either OFDM or CCK errors per turn * only lower either OFDM or CCK errors per turn
* we lower the other one next time * we lower the other one next time
*/ */
static void ath9k_hw_ani_lower_immunity_new(struct ath_hw *ah) static void ath9k_hw_ani_lower_immunity(struct ath_hw *ah)
{ {
struct ar5416AniState *aniState; struct ar5416AniState *aniState;
aniState = &ah->curchan->ani; aniState = &ah->curchan->ani;
if (!use_new_ani(ah)) {
ath9k_hw_ani_lower_immunity_old(ah);
return;
}
/* lower OFDM noise immunity */ /* lower OFDM noise immunity */
if (aniState->ofdmNoiseImmunityLevel > 0 && if (aniState->ofdmNoiseImmunityLevel > 0 &&
(aniState->ofdmsTurn || aniState->cckNoiseImmunityLevel == 0)) { (aniState->ofdmsTurn || aniState->cckNoiseImmunityLevel == 0)) {
...@@ -573,7 +576,7 @@ static void ath9k_ani_reset_old(struct ath_hw *ah, bool is_scanning) ...@@ -573,7 +576,7 @@ static void ath9k_ani_reset_old(struct ath_hw *ah, bool is_scanning)
* This routine should be called for every hardware reset and for * This routine should be called for every hardware reset and for
* every channel change. * every channel change.
*/ */
static void ath9k_ani_reset_new(struct ath_hw *ah, bool is_scanning) void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning)
{ {
struct ar5416AniState *aniState = &ah->curchan->ani; struct ar5416AniState *aniState = &ah->curchan->ani;
struct ath9k_channel *chan = ah->curchan; struct ath9k_channel *chan = ah->curchan;
...@@ -582,6 +585,9 @@ static void ath9k_ani_reset_new(struct ath_hw *ah, bool is_scanning) ...@@ -582,6 +585,9 @@ static void ath9k_ani_reset_new(struct ath_hw *ah, bool is_scanning)
if (!DO_ANI(ah)) if (!DO_ANI(ah))
return; return;
if (!use_new_ani(ah))
return ath9k_ani_reset_old(ah, is_scanning);
BUG_ON(aniState == NULL); BUG_ON(aniState == NULL);
ah->stats.ast_ani_reset++; ah->stats.ast_ani_reset++;
...@@ -745,12 +751,12 @@ static void ath9k_hw_ani_monitor_old(struct ath_hw *ah, ...@@ -745,12 +751,12 @@ static void ath9k_hw_ani_monitor_old(struct ath_hw *ah,
} else if (aniState->listenTime > ah->aniperiod) { } else if (aniState->listenTime > ah->aniperiod) {
if (aniState->ofdmPhyErrCount > aniState->listenTime * if (aniState->ofdmPhyErrCount > aniState->listenTime *
ah->config.ofdm_trig_high / 1000) { ah->config.ofdm_trig_high / 1000) {
ath9k_hw_ani_ofdm_err_trigger_old(ah); ath9k_hw_ani_ofdm_err_trigger(ah);
ath9k_ani_restart(ah); ath9k_ani_restart(ah);
} else if (aniState->cckPhyErrCount > } else if (aniState->cckPhyErrCount >
aniState->listenTime * ah->config.cck_trig_high / aniState->listenTime * ah->config.cck_trig_high /
1000) { 1000) {
ath9k_hw_ani_cck_err_trigger_old(ah); ath9k_hw_ani_cck_err_trigger(ah);
ath9k_ani_restart(ah); ath9k_ani_restart(ah);
} }
} }
...@@ -814,23 +820,23 @@ static void ath9k_hw_ani_monitor_new(struct ath_hw *ah, ...@@ -814,23 +820,23 @@ static void ath9k_hw_ani_monitor_new(struct ath_hw *ah,
aniState->ofdmsTurn)) { aniState->ofdmsTurn)) {
ath_print(common, ATH_DBG_ANI, ath_print(common, ATH_DBG_ANI,
"2 listenTime=%d OFDM:%d errs=%d/s(>%d) -> " "2 listenTime=%d OFDM:%d errs=%d/s(>%d) -> "
"ath9k_hw_ani_ofdm_err_trigger_new()\n", "ath9k_hw_ani_ofdm_err_trigger()\n",
aniState->listenTime, aniState->listenTime,
aniState->ofdmNoiseImmunityLevel, aniState->ofdmNoiseImmunityLevel,
ofdmPhyErrRate, ofdmPhyErrRate,
ah->config.ofdm_trig_high); ah->config.ofdm_trig_high);
ath9k_hw_ani_ofdm_err_trigger_new(ah); ath9k_hw_ani_ofdm_err_trigger(ah);
ath9k_ani_restart(ah); ath9k_ani_restart(ah);
aniState->ofdmsTurn = false; aniState->ofdmsTurn = false;
} else if (cckPhyErrRate > ah->config.cck_trig_high) { } else if (cckPhyErrRate > ah->config.cck_trig_high) {
ath_print(common, ATH_DBG_ANI, ath_print(common, ATH_DBG_ANI,
"3 listenTime=%d CCK:%d errs=%d/s(>%d) -> " "3 listenTime=%d CCK:%d errs=%d/s(>%d) -> "
"ath9k_hw_ani_cck_err_trigger_new()\n", "ath9k_hw_ani_cck_err_trigger()\n",
aniState->listenTime, aniState->listenTime,
aniState->cckNoiseImmunityLevel, aniState->cckNoiseImmunityLevel,
cckPhyErrRate, cckPhyErrRate,
ah->config.cck_trig_high); ah->config.cck_trig_high);
ath9k_hw_ani_cck_err_trigger_new(ah); ath9k_hw_ani_cck_err_trigger(ah);
ath9k_ani_restart(ah); ath9k_ani_restart(ah);
aniState->ofdmsTurn = true; aniState->ofdmsTurn = true;
} }
...@@ -1062,12 +1068,8 @@ void ath9k_hw_ani_init(struct ath_hw *ah) ...@@ -1062,12 +1068,8 @@ void ath9k_hw_ani_init(struct ath_hw *ah)
void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah) void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah)
{ {
struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
struct ath_hw_ops *ops = ath9k_hw_ops(ah); struct ath_hw_ops *ops = ath9k_hw_ops(ah);
priv_ops->ani_reset = ath9k_ani_reset_old;
priv_ops->ani_lower_immunity = ath9k_hw_ani_lower_immunity_old;
ops->ani_monitor = ath9k_hw_ani_monitor_old; ops->ani_monitor = ath9k_hw_ani_monitor_old;
ath_print(ath9k_hw_common(ah), ATH_DBG_ANY, "Using ANI v1\n"); ath_print(ath9k_hw_common(ah), ATH_DBG_ANY, "Using ANI v1\n");
...@@ -1075,12 +1077,8 @@ void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah) ...@@ -1075,12 +1077,8 @@ void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah)
void ath9k_hw_attach_ani_ops_new(struct ath_hw *ah) void ath9k_hw_attach_ani_ops_new(struct ath_hw *ah)
{ {
struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
struct ath_hw_ops *ops = ath9k_hw_ops(ah); struct ath_hw_ops *ops = ath9k_hw_ops(ah);
priv_ops->ani_reset = ath9k_ani_reset_new;
priv_ops->ani_lower_immunity = ath9k_hw_ani_lower_immunity_new;
ops->ani_monitor = ath9k_hw_ani_monitor_new; ops->ani_monitor = ath9k_hw_ani_monitor_new;
ath_print(ath9k_hw_common(ah), ATH_DBG_ANY, "Using ANI v2\n"); ath_print(ath9k_hw_common(ah), ATH_DBG_ANY, "Using ANI v2\n");
......
...@@ -271,9 +271,4 @@ static inline void ath9k_hw_setup_calibration(struct ath_hw *ah, ...@@ -271,9 +271,4 @@ static inline void ath9k_hw_setup_calibration(struct ath_hw *ah,
ath9k_hw_private_ops(ah)->setup_calibration(ah, currCal); ath9k_hw_private_ops(ah)->setup_calibration(ah, currCal);
} }
static inline void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning)
{
ath9k_hw_private_ops(ah)->ani_reset(ah, is_scanning);
}
#endif /* ATH9K_HW_OPS_H */ #endif /* ATH9K_HW_OPS_H */
...@@ -509,14 +509,6 @@ struct ath_hw_antcomb_conf { ...@@ -509,14 +509,6 @@ struct ath_hw_antcomb_conf {
* @setup_calibration: set up calibration * @setup_calibration: set up calibration
* @iscal_supported: used to query if a type of calibration is supported * @iscal_supported: used to query if a type of calibration is supported
* *
* @ani_reset: reset ANI parameters to default values
* @ani_lower_immunity: lower the noise immunity level. The level controls
* the power-based packet detection on hardware. If a power jump is
* detected the adapter takes it as an indication that a packet has
* arrived. The level ranges from 0-5. Each level corresponds to a
* few dB more of noise immunity. If you have a strong time-varying
* interference that is causing false detections (OFDM timing errors or
* CCK timing errors) the level can be increased.
* @ani_cache_ini_regs: cache the values for ANI from the initial * @ani_cache_ini_regs: cache the values for ANI from the initial
* register settings through the register initialization. * register settings through the register initialization.
*/ */
...@@ -561,8 +553,6 @@ struct ath_hw_private_ops { ...@@ -561,8 +553,6 @@ struct ath_hw_private_ops {
void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]); void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]);
/* ANI */ /* ANI */
void (*ani_reset)(struct ath_hw *ah, bool is_scanning);
void (*ani_lower_immunity)(struct ath_hw *ah);
void (*ani_cache_ini_regs)(struct ath_hw *ah); void (*ani_cache_ini_regs)(struct ath_hw *ah);
}; };
...@@ -977,6 +967,7 @@ void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan); ...@@ -977,6 +967,7 @@ void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan);
* older families (AR5008, AR9001, AR9002) by using modparam_force_new_ani. * older families (AR5008, AR9001, AR9002) by using modparam_force_new_ani.
*/ */
extern int modparam_force_new_ani; extern int modparam_force_new_ani;
void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning);
void ath9k_hw_proc_mib_event(struct ath_hw *ah); void ath9k_hw_proc_mib_event(struct ath_hw *ah);
void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah); void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah);
void ath9k_hw_attach_ani_ops_new(struct ath_hw *ah); void ath9k_hw_attach_ani_ops_new(struct ath_hw *ah);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment