ani.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 BEACON_RSSI(ahp) (ahp->stats.avgbrssi)
  19. /* units are errors per second */
  20. #define ATH9K_ANI_OFDM_TRIG_HIGH 3500
  21. /* units are errors per second */
  22. #define ATH9K_ANI_OFDM_TRIG_LOW 400
  23. /* units are errors per second */
  24. #define ATH9K_ANI_CCK_TRIG_HIGH 600
  25. /* units are errors per second */
  26. #define ATH9K_ANI_CCK_TRIG_LOW 300
  27. #define ATH9K_ANI_NOISE_IMMUNE_LVL 4
  28. #define ATH9K_ANI_SPUR_IMMUNE_LVL 3
  29. #define ATH9K_ANI_FIRSTEP_LVL 2
  30. #define ATH9K_ANI_RSSI_THR_HIGH 40
  31. #define ATH9K_ANI_RSSI_THR_LOW 7
  32. #define ATH9K_ANI_PERIOD 300
  33. /* in ms */
  34. #define ATH9K_ANI_POLLINTERVAL 1000
  35. #define HAL_NOISE_IMMUNE_MAX 4
  36. #define HAL_SPUR_IMMUNE_MAX 7
  37. #define HAL_FIRST_STEP_MAX 2
  38. #define ATH9K_SIG_FIRSTEP_SETTING_MIN 0
  39. #define ATH9K_SIG_FIRSTEP_SETTING_MAX 20
  40. #define ATH9K_SIG_SPUR_IMM_SETTING_MIN 0
  41. #define ATH9K_SIG_SPUR_IMM_SETTING_MAX 22
  42. /* values here are relative to the INI */
  43. enum ath9k_ani_cmd {
  44. ATH9K_ANI_PRESENT = 0x1,
  45. ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2,
  46. ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x4,
  47. ATH9K_ANI_CCK_WEAK_SIGNAL_THR = 0x8,
  48. ATH9K_ANI_FIRSTEP_LEVEL = 0x10,
  49. ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x20,
  50. ATH9K_ANI_MODE = 0x40,
  51. ATH9K_ANI_PHYERR_RESET = 0x80,
  52. ATH9K_ANI_MRC_CCK = 0x100,
  53. ATH9K_ANI_ALL = 0xfff
  54. };
  55. struct ath9k_mib_stats {
  56. u32 ackrcv_bad;
  57. u32 rts_bad;
  58. u32 rts_good;
  59. u32 fcs_bad;
  60. u32 beacons;
  61. };
  62. /* INI default values for ANI registers */
  63. struct ath9k_ani_default {
  64. u16 m1ThreshLow;
  65. u16 m2ThreshLow;
  66. u16 m1Thresh;
  67. u16 m2Thresh;
  68. u16 m2CountThr;
  69. u16 m2CountThrLow;
  70. u16 m1ThreshLowExt;
  71. u16 m2ThreshLowExt;
  72. u16 m1ThreshExt;
  73. u16 m2ThreshExt;
  74. u16 firstep;
  75. u16 firstepLow;
  76. u16 cycpwrThr1;
  77. u16 cycpwrThr1Ext;
  78. };
  79. struct ar5416AniState {
  80. u8 noiseImmunityLevel;
  81. u8 ofdmNoiseImmunityLevel;
  82. u8 cckNoiseImmunityLevel;
  83. bool ofdmsTurn;
  84. u8 mrcCCK;
  85. u8 spurImmunityLevel;
  86. u8 firstepLevel;
  87. bool ofdmWeakSigDetect;
  88. u32 listenTime;
  89. u32 ofdmPhyErrCount;
  90. u32 cckPhyErrCount;
  91. struct ath9k_ani_default iniDef;
  92. };
  93. struct ar5416Stats {
  94. u32 ast_ani_spurup;
  95. u32 ast_ani_spurdown;
  96. u32 ast_ani_ofdmon;
  97. u32 ast_ani_ofdmoff;
  98. u32 ast_ani_cckhigh;
  99. u32 ast_ani_ccklow;
  100. u32 ast_ani_stepup;
  101. u32 ast_ani_stepdown;
  102. u32 ast_ani_ofdmerrs;
  103. u32 ast_ani_cckerrs;
  104. u32 ast_ani_reset;
  105. u32 ast_ani_lneg_or_lzero;
  106. u32 avgbrssi;
  107. struct ath9k_mib_stats ast_mibstats;
  108. };
  109. #define ah_mibStats stats.ast_mibstats
  110. void ath9k_enable_mib_counters(struct ath_hw *ah);
  111. void ath9k_hw_disable_mib_counters(struct ath_hw *ah);
  112. void ath9k_hw_ani_init(struct ath_hw *ah);
  113. #endif /* ANI_H */