iwl-3945-rs.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * James P. Ketrenos <ipw2100-admin@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. #ifndef __iwl_3945_rs_h__
  27. #define __iwl_3945_rs_h__
  28. struct iwl3945_rate_info {
  29. u8 plcp;
  30. u8 ieee;
  31. u8 prev_ieee; /* previous rate in IEEE speeds */
  32. u8 next_ieee; /* next rate in IEEE speeds */
  33. u8 prev_rs; /* previous rate used in rs algo */
  34. u8 next_rs; /* next rate used in rs algo */
  35. u8 prev_rs_tgg; /* previous rate used in TGG rs algo */
  36. u8 next_rs_tgg; /* next rate used in TGG rs algo */
  37. u8 table_rs_index; /* index in rate scale table cmd */
  38. u8 prev_table_rs; /* prev in rate table cmd */
  39. };
  40. enum {
  41. IWL_RATE_1M_INDEX = 0,
  42. IWL_RATE_2M_INDEX,
  43. IWL_RATE_5M_INDEX,
  44. IWL_RATE_11M_INDEX,
  45. IWL_RATE_6M_INDEX,
  46. IWL_RATE_9M_INDEX,
  47. IWL_RATE_12M_INDEX,
  48. IWL_RATE_18M_INDEX,
  49. IWL_RATE_24M_INDEX,
  50. IWL_RATE_36M_INDEX,
  51. IWL_RATE_48M_INDEX,
  52. IWL_RATE_54M_INDEX,
  53. IWL_RATE_COUNT,
  54. IWL_RATE_INVM_INDEX,
  55. IWL_RATE_INVALID = IWL_RATE_INVM_INDEX
  56. };
  57. enum {
  58. IWL_RATE_6M_INDEX_TABLE = 0,
  59. IWL_RATE_9M_INDEX_TABLE,
  60. IWL_RATE_12M_INDEX_TABLE,
  61. IWL_RATE_18M_INDEX_TABLE,
  62. IWL_RATE_24M_INDEX_TABLE,
  63. IWL_RATE_36M_INDEX_TABLE,
  64. IWL_RATE_48M_INDEX_TABLE,
  65. IWL_RATE_54M_INDEX_TABLE,
  66. IWL_RATE_1M_INDEX_TABLE,
  67. IWL_RATE_2M_INDEX_TABLE,
  68. IWL_RATE_5M_INDEX_TABLE,
  69. IWL_RATE_11M_INDEX_TABLE,
  70. IWL_RATE_INVM_INDEX_TABLE = IWL_RATE_INVM_INDEX,
  71. };
  72. enum {
  73. IWL_FIRST_OFDM_RATE = IWL_RATE_6M_INDEX,
  74. IWL_LAST_OFDM_RATE = IWL_RATE_54M_INDEX,
  75. IWL_FIRST_CCK_RATE = IWL_RATE_1M_INDEX,
  76. IWL_LAST_CCK_RATE = IWL_RATE_11M_INDEX,
  77. };
  78. /* #define vs. enum to keep from defaulting to 'large integer' */
  79. #define IWL_RATE_6M_MASK (1<<IWL_RATE_6M_INDEX)
  80. #define IWL_RATE_9M_MASK (1<<IWL_RATE_9M_INDEX)
  81. #define IWL_RATE_12M_MASK (1<<IWL_RATE_12M_INDEX)
  82. #define IWL_RATE_18M_MASK (1<<IWL_RATE_18M_INDEX)
  83. #define IWL_RATE_24M_MASK (1<<IWL_RATE_24M_INDEX)
  84. #define IWL_RATE_36M_MASK (1<<IWL_RATE_36M_INDEX)
  85. #define IWL_RATE_48M_MASK (1<<IWL_RATE_48M_INDEX)
  86. #define IWL_RATE_54M_MASK (1<<IWL_RATE_54M_INDEX)
  87. #define IWL_RATE_1M_MASK (1<<IWL_RATE_1M_INDEX)
  88. #define IWL_RATE_2M_MASK (1<<IWL_RATE_2M_INDEX)
  89. #define IWL_RATE_5M_MASK (1<<IWL_RATE_5M_INDEX)
  90. #define IWL_RATE_11M_MASK (1<<IWL_RATE_11M_INDEX)
  91. enum {
  92. IWL_RATE_6M_PLCP = 13,
  93. IWL_RATE_9M_PLCP = 15,
  94. IWL_RATE_12M_PLCP = 5,
  95. IWL_RATE_18M_PLCP = 7,
  96. IWL_RATE_24M_PLCP = 9,
  97. IWL_RATE_36M_PLCP = 11,
  98. IWL_RATE_48M_PLCP = 1,
  99. IWL_RATE_54M_PLCP = 3,
  100. IWL_RATE_1M_PLCP = 10,
  101. IWL_RATE_2M_PLCP = 20,
  102. IWL_RATE_5M_PLCP = 55,
  103. IWL_RATE_11M_PLCP = 110,
  104. };
  105. enum {
  106. IWL_RATE_6M_IEEE = 12,
  107. IWL_RATE_9M_IEEE = 18,
  108. IWL_RATE_12M_IEEE = 24,
  109. IWL_RATE_18M_IEEE = 36,
  110. IWL_RATE_24M_IEEE = 48,
  111. IWL_RATE_36M_IEEE = 72,
  112. IWL_RATE_48M_IEEE = 96,
  113. IWL_RATE_54M_IEEE = 108,
  114. IWL_RATE_1M_IEEE = 2,
  115. IWL_RATE_2M_IEEE = 4,
  116. IWL_RATE_5M_IEEE = 11,
  117. IWL_RATE_11M_IEEE = 22,
  118. };
  119. #define IWL_CCK_BASIC_RATES_MASK \
  120. (IWL_RATE_1M_MASK | \
  121. IWL_RATE_2M_MASK)
  122. #define IWL_CCK_RATES_MASK \
  123. (IWL_BASIC_RATES_MASK | \
  124. IWL_RATE_5M_MASK | \
  125. IWL_RATE_11M_MASK)
  126. #define IWL_OFDM_BASIC_RATES_MASK \
  127. (IWL_RATE_6M_MASK | \
  128. IWL_RATE_12M_MASK | \
  129. IWL_RATE_24M_MASK)
  130. #define IWL_OFDM_RATES_MASK \
  131. (IWL_OFDM_BASIC_RATES_MASK | \
  132. IWL_RATE_9M_MASK | \
  133. IWL_RATE_18M_MASK | \
  134. IWL_RATE_36M_MASK | \
  135. IWL_RATE_48M_MASK | \
  136. IWL_RATE_54M_MASK)
  137. #define IWL_BASIC_RATES_MASK \
  138. (IWL_OFDM_BASIC_RATES_MASK | \
  139. IWL_CCK_BASIC_RATES_MASK)
  140. #define IWL_RATES_MASK ((1<<IWL_RATE_COUNT)-1)
  141. #define IWL_INVALID_VALUE -1
  142. #define IWL_MIN_RSSI_VAL -100
  143. #define IWL_MAX_RSSI_VAL 0
  144. extern const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT];
  145. static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index)
  146. {
  147. u8 rate = iwl3945_rates[rate_index].prev_ieee;
  148. if (rate == IWL_RATE_INVALID)
  149. rate = rate_index;
  150. return rate;
  151. }
  152. /**
  153. * iwl3945_fill_rs_info - Fill an output text buffer with the rate representation
  154. *
  155. * NOTE: This is provided as a quick mechanism for a user to visualize
  156. * the performance of the rate control algorithm and is not meant to be
  157. * parsed software.
  158. */
  159. extern int iwl3945_fill_rs_info(struct ieee80211_hw *, char *buf, u8 sta_id);
  160. /**
  161. * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info
  162. *
  163. * The specific throughput table used is based on the type of network
  164. * the associated with, including A, B, G, and G w/ TGG protection
  165. */
  166. extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id);
  167. /**
  168. * iwl3945_rate_control_register - Register the rate control algorithm callbacks
  169. *
  170. * Since the rate control algorithm is hardware specific, there is no need
  171. * or reason to place it as a stand alone module. The driver can call
  172. * iwl3945_rate_control_register in order to register the rate control callbacks
  173. * with the mac80211 subsystem. This should be performed prior to calling
  174. * ieee80211_register_hw
  175. *
  176. */
  177. extern void iwl3945_rate_control_register(struct ieee80211_hw *hw);
  178. /**
  179. * iwl3945_rate_control_unregister - Unregister the rate control callbacks
  180. *
  181. * This should be called after calling ieee80211_unregister_hw, but before
  182. * the driver is unloaded.
  183. */
  184. extern void iwl3945_rate_control_unregister(struct ieee80211_hw *hw);
  185. #endif