ani.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. /* these thresholds are relative to the ATH5K_ANI_LISTEN_PERIOD */
  19. #define ATH5K_ANI_LISTEN_PERIOD 100
  20. #define ATH5K_ANI_OFDM_TRIG_HIGH 500
  21. #define ATH5K_ANI_OFDM_TRIG_LOW 200
  22. #define ATH5K_ANI_CCK_TRIG_HIGH 200
  23. #define ATH5K_ANI_CCK_TRIG_LOW 100
  24. /* average beacon RSSI thresholds */
  25. #define ATH5K_ANI_RSSI_THR_HIGH 40
  26. #define ATH5K_ANI_RSSI_THR_LOW 7
  27. /* maximum availabe levels */
  28. #define ATH5K_ANI_MAX_FIRSTEP_LVL 2
  29. #define ATH5K_ANI_MAX_NOISE_IMM_LVL 1
  30. /**
  31. * enum ath5k_ani_mode - mode for ANI / noise sensitivity
  32. *
  33. * @ATH5K_ANI_MODE_OFF: Turn ANI off. This can be useful to just stop the ANI
  34. * algorithm after it has been on auto mode.
  35. * ATH5K_ANI_MODE_MANUAL_LOW: Manually set all immunity parameters to low,
  36. * maximizing sensitivity. ANI will not run.
  37. * ATH5K_ANI_MODE_MANUAL_HIGH: Manually set all immunity parameters to high,
  38. * minimizing sensitivity. ANI will not run.
  39. * ATH5K_ANI_MODE_AUTO: Automatically control immunity parameters based on the
  40. * amount of OFDM and CCK frame errors (default).
  41. */
  42. enum ath5k_ani_mode {
  43. ATH5K_ANI_MODE_OFF = 0,
  44. ATH5K_ANI_MODE_MANUAL_LOW = 1,
  45. ATH5K_ANI_MODE_MANUAL_HIGH = 2,
  46. ATH5K_ANI_MODE_AUTO = 3
  47. };
  48. /**
  49. * struct ath5k_ani_state - ANI state and associated counters
  50. *
  51. * @max_spur_level: the maximum spur level is chip dependent
  52. */
  53. struct ath5k_ani_state {
  54. enum ath5k_ani_mode ani_mode;
  55. /* state */
  56. int noise_imm_level;
  57. int spur_level;
  58. int firstep_level;
  59. bool ofdm_weak_sig;
  60. bool cck_weak_sig;
  61. int max_spur_level;
  62. /* used by the algorithm */
  63. unsigned int listen_time;
  64. unsigned int ofdm_errors;
  65. unsigned int cck_errors;
  66. /* debug/statistics only: numbers from last ANI calibration */
  67. unsigned int pfc_tx;
  68. unsigned int pfc_rx;
  69. unsigned int pfc_busy;
  70. unsigned int pfc_cycles;
  71. unsigned int last_listen;
  72. unsigned int last_ofdm_errors;
  73. unsigned int last_cck_errors;
  74. unsigned int sum_ofdm_errors;
  75. unsigned int sum_cck_errors;
  76. };
  77. void ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode);
  78. void ath5k_ani_mib_intr(struct ath5k_hw *ah);
  79. void ath5k_ani_calibration(struct ath5k_hw *ah);
  80. void ath5k_ani_phy_error_report(struct ath5k_hw *ah,
  81. enum ath5k_phy_error_code phyerr);
  82. /* for manual control */
  83. void ath5k_ani_set_noise_immunity_level(struct ath5k_hw *ah, int level);
  84. void ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level);
  85. void ath5k_ani_set_firstep_level(struct ath5k_hw *ah, int level);
  86. void ath5k_ani_set_ofdm_weak_signal_detection(struct ath5k_hw *ah, bool on);
  87. void ath5k_ani_set_cck_weak_signal_detection(struct ath5k_hw *ah, bool on);
  88. void ath5k_ani_print_counters(struct ath5k_hw *ah);
  89. #endif /* ANI_H */