rc.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * Copyright (c) 2004 Sam Leffler, Errno Consulting
  3. * Copyright (c) 2004 Video54 Technologies, Inc.
  4. * Copyright (c) 2008-2009 Atheros Communications Inc.
  5. *
  6. * Permission to use, copy, modify, and/or distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef RC_H
  19. #define RC_H
  20. #include "hw.h"
  21. struct ath_softc;
  22. #define ATH_RATE_MAX 30
  23. #define RATE_TABLE_SIZE 64
  24. #define MAX_TX_RATE_PHY 48
  25. /* VALID_ALL - valid for 20/40/Legacy,
  26. * VALID - Legacy only,
  27. * VALID_20 - HT 20 only,
  28. * VALID_40 - HT 40 only */
  29. #define INVALID 0x0
  30. #define VALID 0x1
  31. #define VALID_20 0x2
  32. #define VALID_40 0x4
  33. #define VALID_2040 (VALID_20|VALID_40)
  34. #define VALID_ALL (VALID_2040|VALID)
  35. enum {
  36. WLAN_RC_PHY_OFDM,
  37. WLAN_RC_PHY_CCK,
  38. WLAN_RC_PHY_HT_20_SS,
  39. WLAN_RC_PHY_HT_20_DS,
  40. WLAN_RC_PHY_HT_40_SS,
  41. WLAN_RC_PHY_HT_40_DS,
  42. WLAN_RC_PHY_HT_20_SS_HGI,
  43. WLAN_RC_PHY_HT_20_DS_HGI,
  44. WLAN_RC_PHY_HT_40_SS_HGI,
  45. WLAN_RC_PHY_HT_40_DS_HGI,
  46. WLAN_RC_PHY_MAX
  47. };
  48. #define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \
  49. || (_phy == WLAN_RC_PHY_HT_40_DS) \
  50. || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
  51. || (_phy == WLAN_RC_PHY_HT_40_DS_HGI))
  52. #define WLAN_RC_PHY_20(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS) \
  53. || (_phy == WLAN_RC_PHY_HT_20_DS) \
  54. || (_phy == WLAN_RC_PHY_HT_20_SS_HGI) \
  55. || (_phy == WLAN_RC_PHY_HT_20_DS_HGI))
  56. #define WLAN_RC_PHY_40(_phy) ((_phy == WLAN_RC_PHY_HT_40_SS) \
  57. || (_phy == WLAN_RC_PHY_HT_40_DS) \
  58. || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
  59. || (_phy == WLAN_RC_PHY_HT_40_DS_HGI))
  60. #define WLAN_RC_PHY_SGI(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS_HGI) \
  61. || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
  62. || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
  63. || (_phy == WLAN_RC_PHY_HT_40_DS_HGI))
  64. #define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS)
  65. #define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \
  66. (capflag & WLAN_RC_40_FLAG) ? VALID_40 : VALID_20 : VALID))
  67. /* Return TRUE if flag supports HT20 && client supports HT20 or
  68. * return TRUE if flag supports HT40 && client supports HT40.
  69. * This is used becos some rates overlap between HT20/HT40.
  70. */
  71. #define WLAN_RC_PHY_HT_VALID(flag, capflag) \
  72. (((flag & VALID_20) && !(capflag & WLAN_RC_40_FLAG)) || \
  73. ((flag & VALID_40) && (capflag & WLAN_RC_40_FLAG)))
  74. #define WLAN_RC_DS_FLAG (0x01)
  75. #define WLAN_RC_40_FLAG (0x02)
  76. #define WLAN_RC_SGI_FLAG (0x04)
  77. #define WLAN_RC_HT_FLAG (0x08)
  78. /**
  79. * struct ath_rate_table - Rate Control table
  80. * @valid: valid for use in rate control
  81. * @valid_single_stream: valid for use in rate control for
  82. * single stream operation
  83. * @phy: CCK/OFDM
  84. * @ratekbps: rate in Kbits per second
  85. * @user_ratekbps: user rate in Kbits per second
  86. * @ratecode: rate that goes into HW descriptors
  87. * @short_preamble: Mask for enabling short preamble in ratecode for CCK
  88. * @dot11rate: value that goes into supported
  89. * rates info element of MLME
  90. * @ctrl_rate: Index of next lower basic rate, used for duration computation
  91. * @max_4ms_framelen: maximum frame length(bytes) for tx duration
  92. * @probe_interval: interval for rate control to probe for other rates
  93. * @rssi_reduce_interval: interval for rate control to reduce rssi
  94. * @initial_ratemax: initial ratemax value
  95. */
  96. struct ath_rate_table {
  97. int rate_cnt;
  98. int mcs_start;
  99. struct {
  100. u8 valid;
  101. u8 valid_single_stream;
  102. u8 phy;
  103. u32 ratekbps;
  104. u32 user_ratekbps;
  105. u8 ratecode;
  106. u8 dot11rate;
  107. u8 ctrl_rate;
  108. u8 base_index;
  109. u8 cw40index;
  110. u8 sgi_index;
  111. u8 ht_index;
  112. } info[RATE_TABLE_SIZE];
  113. u32 probe_interval;
  114. u8 initial_ratemax;
  115. };
  116. struct ath_rateset {
  117. u8 rs_nrates;
  118. u8 rs_rates[ATH_RATE_MAX];
  119. };
  120. /**
  121. * struct ath_rate_priv - Rate Control priv data
  122. * @state: RC state
  123. * @probe_rate: rate we are probing at
  124. * @probe_time: msec timestamp for last probe
  125. * @hw_maxretry_pktcnt: num of packets since we got HW max retry error
  126. * @max_valid_rate: maximum number of valid rate
  127. * @per_down_time: msec timestamp for last PER down step
  128. * @valid_phy_ratecnt: valid rate count
  129. * @rate_max_phy: phy index for the max rate
  130. * @per: PER for every valid rate in %
  131. * @probe_interval: interval for ratectrl to probe for other rates
  132. * @prev_data_rix: rate idx of last data frame
  133. * @ht_cap: HT capabilities
  134. * @neg_rates: Negotatied rates
  135. * @neg_ht_rates: Negotiated HT rates
  136. */
  137. struct ath_rate_priv {
  138. u8 rate_table_size;
  139. u8 probe_rate;
  140. u8 hw_maxretry_pktcnt;
  141. u8 max_valid_rate;
  142. u8 valid_rate_index[RATE_TABLE_SIZE];
  143. u8 ht_cap;
  144. u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX];
  145. u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][RATE_TABLE_SIZE];
  146. u8 rate_max_phy;
  147. u8 per[RATE_TABLE_SIZE];
  148. u32 probe_time;
  149. u32 per_down_time;
  150. u32 probe_interval;
  151. u32 prev_data_rix;
  152. u32 tx_triglevel_max;
  153. struct ath_rateset neg_rates;
  154. struct ath_rateset neg_ht_rates;
  155. struct ath_rate_softc *asc;
  156. };
  157. #define ATH_TX_INFO_FRAME_TYPE_INTERNAL (1 << 0)
  158. #define ATH_TX_INFO_FRAME_TYPE_PAUSE (1 << 1)
  159. #define ATH_TX_INFO_XRETRY (1 << 3)
  160. #define ATH_TX_INFO_UNDERRUN (1 << 4)
  161. enum ath9k_internal_frame_type {
  162. ATH9K_IFT_NOT_INTERNAL,
  163. ATH9K_IFT_PAUSE,
  164. ATH9K_IFT_UNPAUSE
  165. };
  166. int ath_rate_control_register(void);
  167. void ath_rate_control_unregister(void);
  168. #endif /* RC_H */