ani.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) 2008 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 ATH9K_RSSI_EP_MULTIPLIER (1<<7)
  20. #define DO_ANI(ah) ((AH5416(ah)->ah_procPhyErr & HAL_PROCESS_ANI))
  21. #define HAL_EP_RND(x, mul) \
  22. ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
  23. #define BEACON_RSSI(ahp) \
  24. HAL_EP_RND(ahp->ah_stats.ast_nodestats.ns_avgbrssi, \
  25. ATH9K_RSSI_EP_MULTIPLIER)
  26. #define ATH9K_ANI_OFDM_TRIG_HIGH 500
  27. #define ATH9K_ANI_OFDM_TRIG_LOW 200
  28. #define ATH9K_ANI_CCK_TRIG_HIGH 200
  29. #define ATH9K_ANI_CCK_TRIG_LOW 100
  30. #define ATH9K_ANI_NOISE_IMMUNE_LVL 4
  31. #define ATH9K_ANI_USE_OFDM_WEAK_SIG true
  32. #define ATH9K_ANI_CCK_WEAK_SIG_THR false
  33. #define ATH9K_ANI_SPUR_IMMUNE_LVL 7
  34. #define ATH9K_ANI_FIRSTEP_LVL 0
  35. #define ATH9K_ANI_RSSI_THR_HIGH 40
  36. #define ATH9K_ANI_RSSI_THR_LOW 7
  37. #define ATH9K_ANI_PERIOD 100
  38. #define HAL_NOISE_IMMUNE_MAX 4
  39. #define HAL_SPUR_IMMUNE_MAX 7
  40. #define HAL_FIRST_STEP_MAX 2
  41. enum ath9k_ani_cmd {
  42. ATH9K_ANI_PRESENT = 0x1,
  43. ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2,
  44. ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x4,
  45. ATH9K_ANI_CCK_WEAK_SIGNAL_THR = 0x8,
  46. ATH9K_ANI_FIRSTEP_LEVEL = 0x10,
  47. ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x20,
  48. ATH9K_ANI_MODE = 0x40,
  49. ATH9K_ANI_PHYERR_RESET = 0x80,
  50. ATH9K_ANI_ALL = 0xff
  51. };
  52. struct ath9k_mib_stats {
  53. u32 ackrcv_bad;
  54. u32 rts_bad;
  55. u32 rts_good;
  56. u32 fcs_bad;
  57. u32 beacons;
  58. };
  59. struct ath9k_node_stats {
  60. u32 ns_avgbrssi;
  61. u32 ns_avgrssi;
  62. u32 ns_avgtxrssi;
  63. u32 ns_avgtxrate;
  64. };
  65. struct ar5416Stats {
  66. u32 ast_ani_niup;
  67. u32 ast_ani_nidown;
  68. u32 ast_ani_spurup;
  69. u32 ast_ani_spurdown;
  70. u32 ast_ani_ofdmon;
  71. u32 ast_ani_ofdmoff;
  72. u32 ast_ani_cckhigh;
  73. u32 ast_ani_ccklow;
  74. u32 ast_ani_stepup;
  75. u32 ast_ani_stepdown;
  76. u32 ast_ani_ofdmerrs;
  77. u32 ast_ani_cckerrs;
  78. u32 ast_ani_reset;
  79. u32 ast_ani_lzero;
  80. u32 ast_ani_lneg;
  81. struct ath9k_mib_stats ast_mibstats;
  82. struct ath9k_node_stats ast_nodestats;
  83. };
  84. #define ah_mibStats ah_stats.ast_mibstats
  85. void ath9k_ani_reset(struct ath_hal *ah);
  86. void ath9k_hw_ani_monitor(struct ath_hal *ah,
  87. const struct ath9k_node_stats *stats,
  88. struct ath9k_channel *chan);
  89. bool ath9k_hw_phycounters(struct ath_hal *ah);
  90. void ath9k_enable_mib_counters(struct ath_hal *ah);
  91. void ath9k_hw_disable_mib_counters(struct ath_hal *ah);
  92. u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hal *ah, u32 *rxc_pcnt,
  93. u32 *rxf_pcnt, u32 *txf_pcnt);
  94. void ath9k_hw_procmibevent(struct ath_hal *ah,
  95. const struct ath9k_node_stats *stats);
  96. void ath9k_hw_ani_setup(struct ath_hal *ah);
  97. void ath9k_hw_ani_attach(struct ath_hal *ah);
  98. void ath9k_hw_ani_detach(struct ath_hal *ah);
  99. #endif /* ANI_H */