ani.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (c) 2008-2009 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))
  20. #define BEACON_RSSI(ahp) (ahp->stats.avgbrssi)
  21. /* units are errors per second */
  22. #define ATH9K_ANI_OFDM_TRIG_HIGH_OLD 500
  23. #define ATH9K_ANI_OFDM_TRIG_HIGH_NEW 1000
  24. /* units are errors per second */
  25. #define ATH9K_ANI_OFDM_TRIG_LOW_OLD 200
  26. #define ATH9K_ANI_OFDM_TRIG_LOW_NEW 400
  27. /* units are errors per second */
  28. #define ATH9K_ANI_CCK_TRIG_HIGH_OLD 200
  29. #define ATH9K_ANI_CCK_TRIG_HIGH_NEW 600
  30. /* units are errors per second */
  31. #define ATH9K_ANI_CCK_TRIG_LOW_OLD 100
  32. #define ATH9K_ANI_CCK_TRIG_LOW_NEW 300
  33. #define ATH9K_ANI_NOISE_IMMUNE_LVL 4
  34. #define ATH9K_ANI_USE_OFDM_WEAK_SIG true
  35. #define ATH9K_ANI_CCK_WEAK_SIG_THR false
  36. #define ATH9K_ANI_SPUR_IMMUNE_LVL_OLD 7
  37. #define ATH9K_ANI_SPUR_IMMUNE_LVL_NEW 3
  38. #define ATH9K_ANI_FIRSTEP_LVL_OLD 0
  39. #define ATH9K_ANI_FIRSTEP_LVL_NEW 2
  40. #define ATH9K_ANI_RSSI_THR_HIGH 40
  41. #define ATH9K_ANI_RSSI_THR_LOW 7
  42. #define ATH9K_ANI_PERIOD_OLD 100
  43. #define ATH9K_ANI_PERIOD_NEW 1000
  44. /* in ms */
  45. #define ATH9K_ANI_POLLINTERVAL_OLD 100
  46. #define ATH9K_ANI_POLLINTERVAL_NEW 1000
  47. #define HAL_NOISE_IMMUNE_MAX 4
  48. #define HAL_SPUR_IMMUNE_MAX 7
  49. #define HAL_FIRST_STEP_MAX 2
  50. #define ATH9K_SIG_FIRSTEP_SETTING_MIN 0
  51. #define ATH9K_SIG_FIRSTEP_SETTING_MAX 20
  52. #define ATH9K_SIG_SPUR_IMM_SETTING_MIN 0
  53. #define ATH9K_SIG_SPUR_IMM_SETTING_MAX 22
  54. #define ATH9K_ANI_ENABLE_MRC_CCK true
  55. /* values here are relative to the INI */
  56. enum ath9k_ani_cmd {
  57. ATH9K_ANI_PRESENT = 0x1,
  58. ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2,
  59. ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x4,
  60. ATH9K_ANI_CCK_WEAK_SIGNAL_THR = 0x8,
  61. ATH9K_ANI_FIRSTEP_LEVEL = 0x10,
  62. ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x20,
  63. ATH9K_ANI_MODE = 0x40,
  64. ATH9K_ANI_PHYERR_RESET = 0x80,
  65. ATH9K_ANI_MRC_CCK = 0x100,
  66. ATH9K_ANI_ALL = 0xfff
  67. };
  68. struct ath9k_mib_stats {
  69. u32 ackrcv_bad;
  70. u32 rts_bad;
  71. u32 rts_good;
  72. u32 fcs_bad;
  73. u32 beacons;
  74. };
  75. /* INI default values for ANI registers */
  76. struct ath9k_ani_default {
  77. u16 m1ThreshLow;
  78. u16 m2ThreshLow;
  79. u16 m1Thresh;
  80. u16 m2Thresh;
  81. u16 m2CountThr;
  82. u16 m2CountThrLow;
  83. u16 m1ThreshLowExt;
  84. u16 m2ThreshLowExt;
  85. u16 m1ThreshExt;
  86. u16 m2ThreshExt;
  87. u16 firstep;
  88. u16 firstepLow;
  89. u16 cycpwrThr1;
  90. u16 cycpwrThr1Ext;
  91. };
  92. struct ar5416AniState {
  93. struct ath9k_channel *c;
  94. u8 noiseImmunityLevel;
  95. u8 ofdmNoiseImmunityLevel;
  96. u8 cckNoiseImmunityLevel;
  97. bool ofdmsTurn;
  98. u8 mrcCCKOff;
  99. u8 spurImmunityLevel;
  100. u8 firstepLevel;
  101. u8 ofdmWeakSigDetectOff;
  102. u8 cckWeakSigThreshold;
  103. u32 listenTime;
  104. u32 ofdmTrigHigh;
  105. u32 ofdmTrigLow;
  106. int32_t cckTrigHigh;
  107. int32_t cckTrigLow;
  108. int32_t rssiThrLow;
  109. int32_t rssiThrHigh;
  110. u32 noiseFloor;
  111. u32 txFrameCount;
  112. u32 rxFrameCount;
  113. u32 cycleCount;
  114. u32 ofdmPhyErrCount;
  115. u32 cckPhyErrCount;
  116. u32 ofdmPhyErrBase;
  117. u32 cckPhyErrBase;
  118. int16_t pktRssi[2];
  119. int16_t ofdmErrRssi[2];
  120. int16_t cckErrRssi[2];
  121. struct ath9k_ani_default iniDef;
  122. };
  123. struct ar5416Stats {
  124. u32 ast_ani_niup;
  125. u32 ast_ani_nidown;
  126. u32 ast_ani_spurup;
  127. u32 ast_ani_spurdown;
  128. u32 ast_ani_ofdmon;
  129. u32 ast_ani_ofdmoff;
  130. u32 ast_ani_cckhigh;
  131. u32 ast_ani_ccklow;
  132. u32 ast_ani_stepup;
  133. u32 ast_ani_stepdown;
  134. u32 ast_ani_ofdmerrs;
  135. u32 ast_ani_cckerrs;
  136. u32 ast_ani_reset;
  137. u32 ast_ani_lzero;
  138. u32 ast_ani_lneg;
  139. u32 avgbrssi;
  140. struct ath9k_mib_stats ast_mibstats;
  141. };
  142. #define ah_mibStats stats.ast_mibstats
  143. void ath9k_enable_mib_counters(struct ath_hw *ah);
  144. void ath9k_hw_disable_mib_counters(struct ath_hw *ah);
  145. u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hw *ah, u32 *rxc_pcnt,
  146. u32 *rxf_pcnt, u32 *txf_pcnt);
  147. void ath9k_hw_ani_setup(struct ath_hw *ah);
  148. void ath9k_hw_ani_init(struct ath_hw *ah);
  149. int ath9k_hw_get_ani_channel_idx(struct ath_hw *ah,
  150. struct ath9k_channel *chan);
  151. #endif /* ANI_H */