ani.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright (c) 2008-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef ANI_H
  17. #define ANI_H
  18. #define HAL_PROCESS_ANI 0x00000001
  19. #define DO_ANI(ah) (((ah)->proc_phyerr & HAL_PROCESS_ANI) && ah->curchan)
  20. #define BEACON_RSSI(ahp) (ahp->stats.avgbrssi)
  21. /* units are errors per second */
  22. #define ATH9K_ANI_OFDM_TRIG_HIGH 3500
  23. #define ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI 1000
  24. /* units are errors per second */
  25. #define ATH9K_ANI_OFDM_TRIG_LOW 400
  26. #define ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI 900
  27. /* units are errors per second */
  28. #define ATH9K_ANI_CCK_TRIG_HIGH 600
  29. /* units are errors per second */
  30. #define ATH9K_ANI_CCK_TRIG_LOW 300
  31. #define ATH9K_ANI_NOISE_IMMUNE_LVL 4
  32. #define ATH9K_ANI_USE_OFDM_WEAK_SIG true
  33. #define ATH9K_ANI_CCK_WEAK_SIG_THR false
  34. #define ATH9K_ANI_SPUR_IMMUNE_LVL 3
  35. #define ATH9K_ANI_FIRSTEP_LVL 2
  36. #define ATH9K_ANI_RSSI_THR_HIGH 40
  37. #define ATH9K_ANI_RSSI_THR_LOW 7
  38. #define ATH9K_ANI_PERIOD 300
  39. /* in ms */
  40. #define ATH9K_ANI_POLLINTERVAL 1000
  41. #define HAL_NOISE_IMMUNE_MAX 4
  42. #define HAL_SPUR_IMMUNE_MAX 7
  43. #define HAL_FIRST_STEP_MAX 2
  44. #define ATH9K_SIG_FIRSTEP_SETTING_MIN 0
  45. #define ATH9K_SIG_FIRSTEP_SETTING_MAX 20
  46. #define ATH9K_SIG_SPUR_IMM_SETTING_MIN 0
  47. #define ATH9K_SIG_SPUR_IMM_SETTING_MAX 22
  48. /* values here are relative to the INI */
  49. enum ath9k_ani_cmd {
  50. ATH9K_ANI_PRESENT = 0x1,
  51. ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2,
  52. ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x4,
  53. ATH9K_ANI_CCK_WEAK_SIGNAL_THR = 0x8,
  54. ATH9K_ANI_FIRSTEP_LEVEL = 0x10,
  55. ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x20,
  56. ATH9K_ANI_MODE = 0x40,
  57. ATH9K_ANI_PHYERR_RESET = 0x80,
  58. ATH9K_ANI_MRC_CCK = 0x100,
  59. ATH9K_ANI_ALL = 0xfff
  60. };
  61. struct ath9k_mib_stats {
  62. u32 ackrcv_bad;
  63. u32 rts_bad;
  64. u32 rts_good;
  65. u32 fcs_bad;
  66. u32 beacons;
  67. };
  68. /* INI default values for ANI registers */
  69. struct ath9k_ani_default {
  70. u16 m1ThreshLow;
  71. u16 m2ThreshLow;
  72. u16 m1Thresh;
  73. u16 m2Thresh;
  74. u16 m2CountThr;
  75. u16 m2CountThrLow;
  76. u16 m1ThreshLowExt;
  77. u16 m2ThreshLowExt;
  78. u16 m1ThreshExt;
  79. u16 m2ThreshExt;
  80. u16 firstep;
  81. u16 firstepLow;
  82. u16 cycpwrThr1;
  83. u16 cycpwrThr1Ext;
  84. };
  85. struct ar5416AniState {
  86. u8 noiseImmunityLevel;
  87. u8 ofdmNoiseImmunityLevel;
  88. u8 cckNoiseImmunityLevel;
  89. bool ofdmsTurn;
  90. u8 mrcCCK;
  91. u8 spurImmunityLevel;
  92. u8 firstepLevel;
  93. u8 ofdmWeakSigDetect;
  94. u32 listenTime;
  95. u32 ofdmPhyErrCount;
  96. u32 cckPhyErrCount;
  97. struct ath9k_ani_default iniDef;
  98. };
  99. struct ar5416Stats {
  100. u32 ast_ani_niup;
  101. u32 ast_ani_nidown;
  102. u32 ast_ani_spurup;
  103. u32 ast_ani_spurdown;
  104. u32 ast_ani_ofdmon;
  105. u32 ast_ani_ofdmoff;
  106. u32 ast_ani_cckhigh;
  107. u32 ast_ani_ccklow;
  108. u32 ast_ani_stepup;
  109. u32 ast_ani_stepdown;
  110. u32 ast_ani_ofdmerrs;
  111. u32 ast_ani_cckerrs;
  112. u32 ast_ani_reset;
  113. u32 ast_ani_lneg_or_lzero;
  114. u32 avgbrssi;
  115. struct ath9k_mib_stats ast_mibstats;
  116. };
  117. #define ah_mibStats stats.ast_mibstats
  118. void ath9k_enable_mib_counters(struct ath_hw *ah);
  119. void ath9k_hw_disable_mib_counters(struct ath_hw *ah);
  120. void ath9k_hw_ani_init(struct ath_hw *ah);
  121. #endif /* ANI_H */