ani.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. #define ATH9K_ANI_OFDM_TRIG_HIGH 500
  22. #define ATH9K_ANI_OFDM_TRIG_LOW 200
  23. #define ATH9K_ANI_CCK_TRIG_HIGH 200
  24. #define ATH9K_ANI_CCK_TRIG_LOW 100
  25. #define ATH9K_ANI_NOISE_IMMUNE_LVL 4
  26. #define ATH9K_ANI_USE_OFDM_WEAK_SIG true
  27. #define ATH9K_ANI_CCK_WEAK_SIG_THR false
  28. #define ATH9K_ANI_SPUR_IMMUNE_LVL 7
  29. #define ATH9K_ANI_FIRSTEP_LVL 0
  30. #define ATH9K_ANI_RSSI_THR_HIGH 40
  31. #define ATH9K_ANI_RSSI_THR_LOW 7
  32. #define ATH9K_ANI_PERIOD 100
  33. #define HAL_NOISE_IMMUNE_MAX 4
  34. #define HAL_SPUR_IMMUNE_MAX 7
  35. #define HAL_FIRST_STEP_MAX 2
  36. enum ath9k_ani_cmd {
  37. ATH9K_ANI_PRESENT = 0x1,
  38. ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2,
  39. ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x4,
  40. ATH9K_ANI_CCK_WEAK_SIGNAL_THR = 0x8,
  41. ATH9K_ANI_FIRSTEP_LEVEL = 0x10,
  42. ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x20,
  43. ATH9K_ANI_MODE = 0x40,
  44. ATH9K_ANI_PHYERR_RESET = 0x80,
  45. ATH9K_ANI_ALL = 0xff
  46. };
  47. struct ath9k_mib_stats {
  48. u32 ackrcv_bad;
  49. u32 rts_bad;
  50. u32 rts_good;
  51. u32 fcs_bad;
  52. u32 beacons;
  53. };
  54. struct ar5416AniState {
  55. struct ath9k_channel *c;
  56. u8 noiseImmunityLevel;
  57. u8 spurImmunityLevel;
  58. u8 firstepLevel;
  59. u8 ofdmWeakSigDetectOff;
  60. u8 cckWeakSigThreshold;
  61. u32 listenTime;
  62. u32 ofdmTrigHigh;
  63. u32 ofdmTrigLow;
  64. int32_t cckTrigHigh;
  65. int32_t cckTrigLow;
  66. int32_t rssiThrLow;
  67. int32_t rssiThrHigh;
  68. u32 noiseFloor;
  69. u32 txFrameCount;
  70. u32 rxFrameCount;
  71. u32 cycleCount;
  72. u32 ofdmPhyErrCount;
  73. u32 cckPhyErrCount;
  74. u32 ofdmPhyErrBase;
  75. u32 cckPhyErrBase;
  76. int16_t pktRssi[2];
  77. int16_t ofdmErrRssi[2];
  78. int16_t cckErrRssi[2];
  79. };
  80. struct ar5416Stats {
  81. u32 ast_ani_niup;
  82. u32 ast_ani_nidown;
  83. u32 ast_ani_spurup;
  84. u32 ast_ani_spurdown;
  85. u32 ast_ani_ofdmon;
  86. u32 ast_ani_ofdmoff;
  87. u32 ast_ani_cckhigh;
  88. u32 ast_ani_ccklow;
  89. u32 ast_ani_stepup;
  90. u32 ast_ani_stepdown;
  91. u32 ast_ani_ofdmerrs;
  92. u32 ast_ani_cckerrs;
  93. u32 ast_ani_reset;
  94. u32 ast_ani_lzero;
  95. u32 ast_ani_lneg;
  96. u32 avgbrssi;
  97. struct ath9k_mib_stats ast_mibstats;
  98. };
  99. #define ah_mibStats stats.ast_mibstats
  100. void ath9k_ani_reset(struct ath_hw *ah);
  101. void ath9k_hw_ani_monitor(struct ath_hw *ah,
  102. struct ath9k_channel *chan);
  103. void ath9k_enable_mib_counters(struct ath_hw *ah);
  104. void ath9k_hw_disable_mib_counters(struct ath_hw *ah);
  105. u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hw *ah, u32 *rxc_pcnt,
  106. u32 *rxf_pcnt, u32 *txf_pcnt);
  107. void ath9k_hw_procmibevent(struct ath_hw *ah);
  108. void ath9k_hw_ani_setup(struct ath_hw *ah);
  109. void ath9k_hw_ani_init(struct ath_hw *ah);
  110. void ath9k_hw_ani_disable(struct ath_hw *ah);
  111. #endif /* ANI_H */