aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-10-04 14:09:49 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-10-06 16:30:39 -0400
commit8eb4980c33c35e97a0a226fdbc07e38da0f1f4aa (patch)
treef3e4b3a36d97f9fce5e8919489fa7a929b9941d3 /drivers/net
parentbfc472bb736bf309158ea76897d255a283d0d31c (diff)
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: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ath/ath9k/ani.c58
-rw-r--r--drivers/net/wireless/ath/ath9k/hw-ops.h5
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h11
3 files changed, 29 insertions, 45 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c
index d5c9df5c4569..b9595647810a 100644
--- a/drivers/net/wireless/ath/ath9k/ani.c
+++ b/drivers/net/wireless/ath/ath9k/ani.c
@@ -103,12 +103,6 @@ static const struct ani_cck_level_entry cck_level_table[] = {
103#define ATH9K_ANI_CCK_DEF_LEVEL \ 103#define ATH9K_ANI_CCK_DEF_LEVEL \
104 2 /* default level - matches the INI settings */ 104 2 /* default level - matches the INI settings */
105 105
106/* Private to ani.c */
107static void ath9k_hw_ani_lower_immunity(struct ath_hw *ah)
108{
109 ath9k_hw_private_ops(ah)->ani_lower_immunity(ah);
110}
111
112static bool use_new_ani(struct ath_hw *ah) 106static bool use_new_ani(struct ath_hw *ah)
113{ 107{
114 return AR_SREV_9300_20_OR_LATER(ah) || modparam_force_new_ani; 108 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 struct ar5416AniState *aniState; 159 struct ar5416AniState *aniState;
166 int32_t rssi; 160 int32_t rssi;
167 161
168 if (!DO_ANI(ah))
169 return;
170
171 aniState = &ah->curchan->ani; 162 aniState = &ah->curchan->ani;
172 163
173 if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) { 164 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 struct ar5416AniState *aniState; 228 struct ar5416AniState *aniState;
238 int32_t rssi; 229 int32_t rssi;
239 230
240 if (!DO_ANI(ah))
241 return;
242
243 aniState = &ah->curchan->ani; 231 aniState = &ah->curchan->ani;
244 if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) { 232 if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
245 if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL, 233 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 } 305 }
318} 306}
319 307
320static void ath9k_hw_ani_ofdm_err_trigger_new(struct ath_hw *ah) 308static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hw *ah)
321{ 309{
322 struct ar5416AniState *aniState; 310 struct ar5416AniState *aniState;
323 311
324 if (!DO_ANI(ah)) 312 if (!DO_ANI(ah))
325 return; 313 return;
326 314
315 if (!use_new_ani(ah)) {
316 ath9k_hw_ani_ofdm_err_trigger_old(ah);
317 return;
318 }
319
327 aniState = &ah->curchan->ani; 320 aniState = &ah->curchan->ani;
328 321
329 if (aniState->ofdmNoiseImmunityLevel < ATH9K_ANI_OFDM_MAX_LEVEL) 322 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 entry_cck->mrc_cck_on); 367 entry_cck->mrc_cck_on);
375} 368}
376 369
377static void ath9k_hw_ani_cck_err_trigger_new(struct ath_hw *ah) 370static void ath9k_hw_ani_cck_err_trigger(struct ath_hw *ah)
378{ 371{
379 struct ar5416AniState *aniState; 372 struct ar5416AniState *aniState;
380 373
381 if (!DO_ANI(ah)) 374 if (!DO_ANI(ah))
382 return; 375 return;
383 376
377 if (!use_new_ani(ah)) {
378 ath9k_hw_ani_cck_err_trigger_old(ah);
379 return;
380 }
381
384 aniState = &ah->curchan->ani; 382 aniState = &ah->curchan->ani;
385 383
386 if (aniState->cckNoiseImmunityLevel < ATH9K_ANI_CCK_MAX_LEVEL) 384 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 * only lower either OFDM or CCK errors per turn 442 * only lower either OFDM or CCK errors per turn
445 * we lower the other one next time 443 * we lower the other one next time
446 */ 444 */
447static void ath9k_hw_ani_lower_immunity_new(struct ath_hw *ah) 445static void ath9k_hw_ani_lower_immunity(struct ath_hw *ah)
448{ 446{
449 struct ar5416AniState *aniState; 447 struct ar5416AniState *aniState;
450 448
451 aniState = &ah->curchan->ani; 449 aniState = &ah->curchan->ani;
452 450
451 if (!use_new_ani(ah)) {
452 ath9k_hw_ani_lower_immunity_old(ah);
453 return;
454 }
455
453 /* lower OFDM noise immunity */ 456 /* lower OFDM noise immunity */
454 if (aniState->ofdmNoiseImmunityLevel > 0 && 457 if (aniState->ofdmNoiseImmunityLevel > 0 &&
455 (aniState->ofdmsTurn || aniState->cckNoiseImmunityLevel == 0)) { 458 (aniState->ofdmsTurn || aniState->cckNoiseImmunityLevel == 0)) {
@@ -573,7 +576,7 @@ static void ath9k_ani_reset_old(struct ath_hw *ah, bool is_scanning)
573 * This routine should be called for every hardware reset and for 576 * This routine should be called for every hardware reset and for
574 * every channel change. 577 * every channel change.
575 */ 578 */
576static void ath9k_ani_reset_new(struct ath_hw *ah, bool is_scanning) 579void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning)
577{ 580{
578 struct ar5416AniState *aniState = &ah->curchan->ani; 581 struct ar5416AniState *aniState = &ah->curchan->ani;
579 struct ath9k_channel *chan = ah->curchan; 582 struct ath9k_channel *chan = ah->curchan;
@@ -582,6 +585,9 @@ static void ath9k_ani_reset_new(struct ath_hw *ah, bool is_scanning)
582 if (!DO_ANI(ah)) 585 if (!DO_ANI(ah))
583 return; 586 return;
584 587
588 if (!use_new_ani(ah))
589 return ath9k_ani_reset_old(ah, is_scanning);
590
585 BUG_ON(aniState == NULL); 591 BUG_ON(aniState == NULL);
586 ah->stats.ast_ani_reset++; 592 ah->stats.ast_ani_reset++;
587 593
@@ -745,12 +751,12 @@ static void ath9k_hw_ani_monitor_old(struct ath_hw *ah,
745 } else if (aniState->listenTime > ah->aniperiod) { 751 } else if (aniState->listenTime > ah->aniperiod) {
746 if (aniState->ofdmPhyErrCount > aniState->listenTime * 752 if (aniState->ofdmPhyErrCount > aniState->listenTime *
747 ah->config.ofdm_trig_high / 1000) { 753 ah->config.ofdm_trig_high / 1000) {
748 ath9k_hw_ani_ofdm_err_trigger_old(ah); 754 ath9k_hw_ani_ofdm_err_trigger(ah);
749 ath9k_ani_restart(ah); 755 ath9k_ani_restart(ah);
750 } else if (aniState->cckPhyErrCount > 756 } else if (aniState->cckPhyErrCount >
751 aniState->listenTime * ah->config.cck_trig_high / 757 aniState->listenTime * ah->config.cck_trig_high /
752 1000) { 758 1000) {
753 ath9k_hw_ani_cck_err_trigger_old(ah); 759 ath9k_hw_ani_cck_err_trigger(ah);
754 ath9k_ani_restart(ah); 760 ath9k_ani_restart(ah);
755 } 761 }
756 } 762 }
@@ -814,23 +820,23 @@ static void ath9k_hw_ani_monitor_new(struct ath_hw *ah,
814 aniState->ofdmsTurn)) { 820 aniState->ofdmsTurn)) {
815 ath_print(common, ATH_DBG_ANI, 821 ath_print(common, ATH_DBG_ANI,
816 "2 listenTime=%d OFDM:%d errs=%d/s(>%d) -> " 822 "2 listenTime=%d OFDM:%d errs=%d/s(>%d) -> "
817 "ath9k_hw_ani_ofdm_err_trigger_new()\n", 823 "ath9k_hw_ani_ofdm_err_trigger()\n",
818 aniState->listenTime, 824 aniState->listenTime,
819 aniState->ofdmNoiseImmunityLevel, 825 aniState->ofdmNoiseImmunityLevel,
820 ofdmPhyErrRate, 826 ofdmPhyErrRate,
821 ah->config.ofdm_trig_high); 827 ah->config.ofdm_trig_high);
822 ath9k_hw_ani_ofdm_err_trigger_new(ah); 828 ath9k_hw_ani_ofdm_err_trigger(ah);
823 ath9k_ani_restart(ah); 829 ath9k_ani_restart(ah);
824 aniState->ofdmsTurn = false; 830 aniState->ofdmsTurn = false;
825 } else if (cckPhyErrRate > ah->config.cck_trig_high) { 831 } else if (cckPhyErrRate > ah->config.cck_trig_high) {
826 ath_print(common, ATH_DBG_ANI, 832 ath_print(common, ATH_DBG_ANI,
827 "3 listenTime=%d CCK:%d errs=%d/s(>%d) -> " 833 "3 listenTime=%d CCK:%d errs=%d/s(>%d) -> "
828 "ath9k_hw_ani_cck_err_trigger_new()\n", 834 "ath9k_hw_ani_cck_err_trigger()\n",
829 aniState->listenTime, 835 aniState->listenTime,
830 aniState->cckNoiseImmunityLevel, 836 aniState->cckNoiseImmunityLevel,
831 cckPhyErrRate, 837 cckPhyErrRate,
832 ah->config.cck_trig_high); 838 ah->config.cck_trig_high);
833 ath9k_hw_ani_cck_err_trigger_new(ah); 839 ath9k_hw_ani_cck_err_trigger(ah);
834 ath9k_ani_restart(ah); 840 ath9k_ani_restart(ah);
835 aniState->ofdmsTurn = true; 841 aniState->ofdmsTurn = true;
836 } 842 }
@@ -1062,12 +1068,8 @@ void ath9k_hw_ani_init(struct ath_hw *ah)
1062 1068
1063void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah) 1069void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah)
1064{ 1070{
1065 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
1066 struct ath_hw_ops *ops = ath9k_hw_ops(ah); 1071 struct ath_hw_ops *ops = ath9k_hw_ops(ah);
1067 1072
1068 priv_ops->ani_reset = ath9k_ani_reset_old;
1069 priv_ops->ani_lower_immunity = ath9k_hw_ani_lower_immunity_old;
1070
1071 ops->ani_monitor = ath9k_hw_ani_monitor_old; 1073 ops->ani_monitor = ath9k_hw_ani_monitor_old;
1072 1074
1073 ath_print(ath9k_hw_common(ah), ATH_DBG_ANY, "Using ANI v1\n"); 1075 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 1077
1076void ath9k_hw_attach_ani_ops_new(struct ath_hw *ah) 1078void ath9k_hw_attach_ani_ops_new(struct ath_hw *ah)
1077{ 1079{
1078 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
1079 struct ath_hw_ops *ops = ath9k_hw_ops(ah); 1080 struct ath_hw_ops *ops = ath9k_hw_ops(ah);
1080 1081
1081 priv_ops->ani_reset = ath9k_ani_reset_new;
1082 priv_ops->ani_lower_immunity = ath9k_hw_ani_lower_immunity_new;
1083
1084 ops->ani_monitor = ath9k_hw_ani_monitor_new; 1082 ops->ani_monitor = ath9k_hw_ani_monitor_new;
1085 1083
1086 ath_print(ath9k_hw_common(ah), ATH_DBG_ANY, "Using ANI v2\n"); 1084 ath_print(ath9k_hw_common(ah), ATH_DBG_ANY, "Using ANI v2\n");
diff --git a/drivers/net/wireless/ath/ath9k/hw-ops.h b/drivers/net/wireless/ath/ath9k/hw-ops.h
index f42c1980e654..6564d1f0ffb1 100644
--- a/drivers/net/wireless/ath/ath9k/hw-ops.h
+++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
@@ -271,9 +271,4 @@ static inline void ath9k_hw_setup_calibration(struct ath_hw *ah,
271 ath9k_hw_private_ops(ah)->setup_calibration(ah, currCal); 271 ath9k_hw_private_ops(ah)->setup_calibration(ah, currCal);
272} 272}
273 273
274static inline void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning)
275{
276 ath9k_hw_private_ops(ah)->ani_reset(ah, is_scanning);
277}
278
279#endif /* ATH9K_HW_OPS_H */ 274#endif /* ATH9K_HW_OPS_H */
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index a87840bab2ad..c982a24146d2 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -509,14 +509,6 @@ struct ath_hw_antcomb_conf {
509 * @setup_calibration: set up calibration 509 * @setup_calibration: set up calibration
510 * @iscal_supported: used to query if a type of calibration is supported 510 * @iscal_supported: used to query if a type of calibration is supported
511 * 511 *
512 * @ani_reset: reset ANI parameters to default values
513 * @ani_lower_immunity: lower the noise immunity level. The level controls
514 * the power-based packet detection on hardware. If a power jump is
515 * detected the adapter takes it as an indication that a packet has
516 * arrived. The level ranges from 0-5. Each level corresponds to a
517 * few dB more of noise immunity. If you have a strong time-varying
518 * interference that is causing false detections (OFDM timing errors or
519 * CCK timing errors) the level can be increased.
520 * @ani_cache_ini_regs: cache the values for ANI from the initial 512 * @ani_cache_ini_regs: cache the values for ANI from the initial
521 * register settings through the register initialization. 513 * register settings through the register initialization.
522 */ 514 */
@@ -561,8 +553,6 @@ struct ath_hw_private_ops {
561 void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]); 553 void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]);
562 554
563 /* ANI */ 555 /* ANI */
564 void (*ani_reset)(struct ath_hw *ah, bool is_scanning);
565 void (*ani_lower_immunity)(struct ath_hw *ah);
566 void (*ani_cache_ini_regs)(struct ath_hw *ah); 556 void (*ani_cache_ini_regs)(struct ath_hw *ah);
567}; 557};
568 558
@@ -977,6 +967,7 @@ void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan);
977 * older families (AR5008, AR9001, AR9002) by using modparam_force_new_ani. 967 * older families (AR5008, AR9001, AR9002) by using modparam_force_new_ani.
978 */ 968 */
979extern int modparam_force_new_ani; 969extern int modparam_force_new_ani;
970void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning);
980void ath9k_hw_proc_mib_event(struct ath_hw *ah); 971void ath9k_hw_proc_mib_event(struct ath_hw *ah);
981void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah); 972void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah);
982void ath9k_hw_attach_ani_ops_new(struct ath_hw *ah); 973void ath9k_hw_attach_ani_ops_new(struct ath_hw *ah);