ani.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright (C) 2010 Bruno Randolf <br1@einfach.org>
  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. #include "../ath.h"
  19. enum ath5k_phy_error_code;
  20. /* these thresholds are relative to the ATH5K_ANI_LISTEN_PERIOD */
  21. #define ATH5K_ANI_LISTEN_PERIOD 100
  22. #define ATH5K_ANI_OFDM_TRIG_HIGH 500
  23. #define ATH5K_ANI_OFDM_TRIG_LOW 200
  24. #define ATH5K_ANI_CCK_TRIG_HIGH 200
  25. #define ATH5K_ANI_CCK_TRIG_LOW 100
  26. /* average beacon RSSI thresholds */
  27. #define ATH5K_ANI_RSSI_THR_HIGH 40
  28. #define ATH5K_ANI_RSSI_THR_LOW 7
  29. /* maximum available levels */
  30. #define ATH5K_ANI_MAX_FIRSTEP_LVL 2
  31. #define ATH5K_ANI_MAX_NOISE_IMM_LVL 1
  32. /**
  33. * enum ath5k_ani_mode - mode for ANI / noise sensitivity
  34. *
  35. * @ATH5K_ANI_MODE_OFF: Turn ANI off. This can be useful to just stop the ANI
  36. * algorithm after it has been on auto mode.
  37. * @ATH5K_ANI_MODE_MANUAL_LOW: Manually set all immunity parameters to low,
  38. * maximizing sensitivity. ANI will not run.
  39. * @ATH5K_ANI_MODE_MANUAL_HIGH: Manually set all immunity parameters to high,
  40. * minimizing sensitivity. ANI will not run.
  41. * @ATH5K_ANI_MODE_AUTO: Automatically control immunity parameters based on the
  42. * amount of OFDM and CCK frame errors (default).
  43. */
  44. enum ath5k_ani_mode {
  45. ATH5K_ANI_MODE_OFF = 0,
  46. ATH5K_ANI_MODE_MANUAL_LOW = 1,
  47. ATH5K_ANI_MODE_MANUAL_HIGH = 2,
  48. ATH5K_ANI_MODE_AUTO = 3
  49. };
  50. /**
  51. * struct ath5k_ani_state - ANI state and associated counters
  52. * @ani_mode: One of enum ath5k_ani_mode
  53. * @noise_imm_level: Noise immunity level
  54. * @spur_level: Spur immunity level
  55. * @firstep_level: FIRstep level
  56. * @ofdm_weak_sig: OFDM weak signal detection state (on/off)
  57. * @cck_weak_sig: CCK weak signal detection state (on/off)
  58. * @max_spur_level: Max spur immunity level (chip specific)
  59. * @listen_time: Listen time
  60. * @ofdm_errors: OFDM timing error count
  61. * @cck_errors: CCK timing error count
  62. * @last_cc: The &struct ath_cycle_counters (for stats)
  63. * @last_listen: Listen time from previous run (for stats)
  64. * @last_ofdm_errors: OFDM timing error count from previous run (for tats)
  65. * @last_cck_errors: CCK timing error count from previous run (for stats)
  66. * @sum_ofdm_errors: Sum of OFDM timing errors (for stats)
  67. * @sum_cck_errors: Sum of all CCK timing errors (for stats)
  68. */
  69. struct ath5k_ani_state {
  70. enum ath5k_ani_mode ani_mode;
  71. /* state */
  72. int noise_imm_level;
  73. int spur_level;
  74. int firstep_level;
  75. bool ofdm_weak_sig;
  76. bool cck_weak_sig;
  77. int max_spur_level;
  78. /* used by the algorithm */
  79. unsigned int listen_time;
  80. unsigned int ofdm_errors;
  81. unsigned int cck_errors;
  82. /* debug/statistics only: numbers from last ANI calibration */
  83. struct ath_cycle_counters last_cc;
  84. unsigned int last_listen;
  85. unsigned int last_ofdm_errors;
  86. unsigned int last_cck_errors;
  87. unsigned int sum_ofdm_errors;
  88. unsigned int sum_cck_errors;
  89. };
  90. void ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode);
  91. void ath5k_ani_mib_intr(struct ath5k_hw *ah);
  92. void ath5k_ani_calibration(struct ath5k_hw *ah);
  93. void ath5k_ani_phy_error_report(struct ath5k_hw *ah,
  94. enum ath5k_phy_error_code phyerr);
  95. /* for manual control */
  96. void ath5k_ani_set_noise_immunity_level(struct ath5k_hw *ah, int level);
  97. void ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level);
  98. void ath5k_ani_set_firstep_level(struct ath5k_hw *ah, int level);
  99. void ath5k_ani_set_ofdm_weak_signal_detection(struct ath5k_hw *ah, bool on);
  100. void ath5k_ani_set_cck_weak_signal_detection(struct ath5k_hw *ah, bool on);
  101. void ath5k_ani_print_counters(struct ath5k_hw *ah);
  102. #endif /* ANI_H */