iwl-4965.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 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_4965_h__
  27. #define __iwl_4965_h__
  28. struct iwl_priv;
  29. struct sta_ht_info;
  30. /*
  31. * Forward declare iwl-4965.c functions for iwl-base.c
  32. */
  33. extern int iwl_eeprom_aqcuire_semaphore(struct iwl_priv *priv);
  34. extern void iwl_eeprom_release_semaphore(struct iwl_priv *priv);
  35. extern int iwl4965_tx_queue_update_wr_ptr(struct iwl_priv *priv,
  36. struct iwl_tx_queue *txq,
  37. u16 byte_cnt);
  38. extern void iwl4965_add_station(struct iwl_priv *priv, const u8 *addr,
  39. int is_ap);
  40. extern void iwl4965_set_rxon_ht(struct iwl_priv *priv,
  41. struct sta_ht_info *ht_info);
  42. extern void iwl4965_set_rxon_chain(struct iwl_priv *priv);
  43. extern int iwl4965_tx_cmd(struct iwl_priv *priv, struct iwl_cmd *out_cmd,
  44. u8 sta_id, dma_addr_t txcmd_phys,
  45. struct ieee80211_hdr *hdr, u8 hdr_len,
  46. struct ieee80211_tx_control *ctrl, void *sta_in);
  47. extern int iwl4965_init_hw_rates(struct iwl_priv *priv,
  48. struct ieee80211_rate *rates);
  49. extern int iwl4965_alive_notify(struct iwl_priv *priv);
  50. extern void iwl4965_update_rate_scaling(struct iwl_priv *priv, u8 mode);
  51. extern void iwl4965_set_ht_add_station(struct iwl_priv *priv, u8 index);
  52. extern void iwl4965_chain_noise_reset(struct iwl_priv *priv);
  53. extern void iwl4965_init_sensitivity(struct iwl_priv *priv, u8 flags,
  54. u8 force);
  55. extern int iwl4965_set_fat_chan_info(struct iwl_priv *priv, int phymode,
  56. u16 channel,
  57. const struct iwl_eeprom_channel *eeprom_ch,
  58. u8 fat_extension_channel);
  59. extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv);
  60. #ifdef CONFIG_IWLWIFI_HT
  61. #ifdef CONFIG_IWLWIFI_HT_AGG
  62. extern int iwl_mac_ht_tx_agg_start(struct ieee80211_hw *hw, u8 *da,
  63. u16 tid, u16 *start_seq_num);
  64. extern int iwl_mac_ht_rx_agg_start(struct ieee80211_hw *hw, u8 *da,
  65. u16 tid, u16 start_seq_num);
  66. extern int iwl_mac_ht_rx_agg_stop(struct ieee80211_hw *hw, u8 *da,
  67. u16 tid, int generator);
  68. extern int iwl_mac_ht_tx_agg_stop(struct ieee80211_hw *hw, u8 *da,
  69. u16 tid, int generator);
  70. extern void iwl4965_turn_off_agg(struct iwl_priv *priv, u8 tid);
  71. #endif /* CONFIG_IWLWIFI_HT_AGG */
  72. #endif /*CONFIG_IWLWIFI_HT */
  73. /* Structures, enum, and defines specific to the 4965 */
  74. #define IWL4965_KW_SIZE 0x1000 /*4k */
  75. struct iwl_kw {
  76. dma_addr_t dma_addr;
  77. void *v_addr;
  78. size_t size;
  79. };
  80. #define TID_QUEUE_CELL_SPACING 50 /*mS */
  81. #define TID_QUEUE_MAX_SIZE 20
  82. #define TID_ROUND_VALUE 5 /* mS */
  83. #define TID_MAX_LOAD_COUNT 8
  84. #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING)
  85. #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y))
  86. #define TID_ALL_ENABLED 0x7f
  87. #define TID_ALL_SPECIFIED 0xff
  88. #define TID_AGG_TPT_THREHOLD 0x0
  89. #define IWL_CHANNEL_WIDTH_20MHZ 0
  90. #define IWL_CHANNEL_WIDTH_40MHZ 1
  91. #define IWL_MIMO_PS_STATIC 0
  92. #define IWL_MIMO_PS_NONE 3
  93. #define IWL_MIMO_PS_DYNAMIC 1
  94. #define IWL_MIMO_PS_INVALID 2
  95. #define IWL_OPERATION_MODE_AUTO 0
  96. #define IWL_OPERATION_MODE_HT_ONLY 1
  97. #define IWL_OPERATION_MODE_MIXED 2
  98. #define IWL_OPERATION_MODE_20MHZ 3
  99. #define IWL_EXT_CHANNEL_OFFSET_AUTO 0
  100. #define IWL_EXT_CHANNEL_OFFSET_ABOVE 1
  101. #define IWL_EXT_CHANNEL_OFFSET_ 2
  102. #define IWL_EXT_CHANNEL_OFFSET_BELOW 3
  103. #define IWL_EXT_CHANNEL_OFFSET_MAX 4
  104. #define NRG_NUM_PREV_STAT_L 20
  105. #define NUM_RX_CHAINS (3)
  106. #define TX_POWER_IWL_ILLEGAL_VDET -100000
  107. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  108. #define TX_POWER_IWL_CLOSED_LOOP_MIN_POWER 18
  109. #define TX_POWER_IWL_CLOSED_LOOP_MAX_POWER 34
  110. #define TX_POWER_IWL_VDET_SLOPE_BELOW_NOMINAL 17
  111. #define TX_POWER_IWL_VDET_SLOPE_ABOVE_NOMINAL 20
  112. #define TX_POWER_IWL_NOMINAL_POWER 26
  113. #define TX_POWER_IWL_CLOSED_LOOP_ITERATION_LIMIT 1
  114. #define TX_POWER_IWL_VOLTAGE_CODES_PER_03V 7
  115. #define TX_POWER_IWL_DEGREES_PER_VDET_CODE 11
  116. #define IWL_TX_POWER_MAX_NUM_PA_MEASUREMENTS 1
  117. #define IWL_TX_POWER_CCK_COMPENSATION_B_STEP (9)
  118. #define IWL_TX_POWER_CCK_COMPENSATION_C_STEP (5)
  119. struct iwl_traffic_load {
  120. unsigned long time_stamp;
  121. u32 packet_count[TID_QUEUE_MAX_SIZE];
  122. u8 queue_count;
  123. u8 head;
  124. u32 total;
  125. };
  126. #ifdef CONFIG_IWLWIFI_HT_AGG
  127. struct iwl_agg_control {
  128. unsigned long next_retry;
  129. u32 wait_for_agg_status;
  130. u32 tid_retry;
  131. u32 requested_ba;
  132. u32 granted_ba;
  133. u8 auto_agg;
  134. u32 tid_traffic_load_threshold;
  135. u32 ba_timeout;
  136. struct iwl_traffic_load traffic_load[TID_MAX_LOAD_COUNT];
  137. };
  138. #endif /*CONFIG_IWLWIFI_HT_AGG */
  139. struct iwl_lq_mngr {
  140. #ifdef CONFIG_IWLWIFI_HT_AGG
  141. struct iwl_agg_control agg_ctrl;
  142. #endif
  143. spinlock_t lock;
  144. s32 max_window_size;
  145. s32 *expected_tpt;
  146. u8 *next_higher_rate;
  147. u8 *next_lower_rate;
  148. unsigned long stamp;
  149. unsigned long stamp_last;
  150. u32 flush_time;
  151. u32 tx_packets;
  152. u8 lq_ready;
  153. };
  154. /* Sensitivity and chain noise calibration */
  155. #define INTERFERENCE_DATA_AVAILABLE __constant_cpu_to_le32(1)
  156. #define INITIALIZATION_VALUE 0xFFFF
  157. #define CAL_NUM_OF_BEACONS 20
  158. #define MAXIMUM_ALLOWED_PATHLOSS 15
  159. /* Param table within SENSITIVITY_CMD */
  160. #define HD_MIN_ENERGY_CCK_DET_INDEX (0)
  161. #define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
  162. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
  163. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
  164. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
  165. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
  166. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
  167. #define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
  168. #define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
  169. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
  170. #define HD_OFDM_ENERGY_TH_IN_INDEX (10)
  171. #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE __constant_cpu_to_le16(0)
  172. #define SENSITIVITY_CMD_CONTROL_WORK_TABLE __constant_cpu_to_le16(1)
  173. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  174. #define MAX_FA_OFDM 50
  175. #define MIN_FA_OFDM 5
  176. #define MAX_FA_CCK 50
  177. #define MIN_FA_CCK 5
  178. #define NRG_MIN_CCK 97
  179. #define NRG_MAX_CCK 0
  180. #define AUTO_CORR_MIN_OFDM 85
  181. #define AUTO_CORR_MIN_OFDM_MRC 170
  182. #define AUTO_CORR_MIN_OFDM_X1 105
  183. #define AUTO_CORR_MIN_OFDM_MRC_X1 220
  184. #define AUTO_CORR_MAX_OFDM 120
  185. #define AUTO_CORR_MAX_OFDM_MRC 210
  186. #define AUTO_CORR_MAX_OFDM_X1 140
  187. #define AUTO_CORR_MAX_OFDM_MRC_X1 270
  188. #define AUTO_CORR_STEP_OFDM 1
  189. #define AUTO_CORR_MIN_CCK (125)
  190. #define AUTO_CORR_MAX_CCK (200)
  191. #define AUTO_CORR_MIN_CCK_MRC 200
  192. #define AUTO_CORR_MAX_CCK_MRC 400
  193. #define AUTO_CORR_STEP_CCK 3
  194. #define AUTO_CORR_MAX_TH_CCK 160
  195. #define NRG_ALG 0
  196. #define AUTO_CORR_ALG 1
  197. #define NRG_DIFF 2
  198. #define NRG_STEP_CCK 2
  199. #define NRG_MARGIN 8
  200. #define MAX_NUMBER_CCK_NO_FA 100
  201. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  202. #define CHAIN_A 0
  203. #define CHAIN_B 1
  204. #define CHAIN_C 2
  205. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  206. #define ALL_BAND_FILTER 0xFF00
  207. #define IN_BAND_FILTER 0xFF
  208. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  209. enum iwl_false_alarm_state {
  210. IWL_FA_TOO_MANY = 0,
  211. IWL_FA_TOO_FEW = 1,
  212. IWL_FA_GOOD_RANGE = 2,
  213. };
  214. enum iwl_chain_noise_state {
  215. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  216. IWL_CHAIN_NOISE_ACCUMULATE = 1,
  217. IWL_CHAIN_NOISE_CALIBRATED = 2,
  218. };
  219. enum iwl_sensitivity_state {
  220. IWL_SENS_CALIB_ALLOWED = 0,
  221. IWL_SENS_CALIB_NEED_REINIT = 1,
  222. };
  223. enum iwl_calib_enabled_state {
  224. IWL_CALIB_DISABLED = 0, /* must be 0 */
  225. IWL_CALIB_ENABLED = 1,
  226. };
  227. struct statistics_general_data {
  228. u32 beacon_silence_rssi_a;
  229. u32 beacon_silence_rssi_b;
  230. u32 beacon_silence_rssi_c;
  231. u32 beacon_energy_a;
  232. u32 beacon_energy_b;
  233. u32 beacon_energy_c;
  234. };
  235. /* Sensitivity calib data */
  236. struct iwl_sensitivity_data {
  237. u32 auto_corr_ofdm;
  238. u32 auto_corr_ofdm_mrc;
  239. u32 auto_corr_ofdm_x1;
  240. u32 auto_corr_ofdm_mrc_x1;
  241. u32 auto_corr_cck;
  242. u32 auto_corr_cck_mrc;
  243. u32 last_bad_plcp_cnt_ofdm;
  244. u32 last_fa_cnt_ofdm;
  245. u32 last_bad_plcp_cnt_cck;
  246. u32 last_fa_cnt_cck;
  247. u32 nrg_curr_state;
  248. u32 nrg_prev_state;
  249. u32 nrg_value[10];
  250. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  251. u32 nrg_silence_ref;
  252. u32 nrg_energy_idx;
  253. u32 nrg_silence_idx;
  254. u32 nrg_th_cck;
  255. s32 nrg_auto_corr_silence_diff;
  256. u32 num_in_cck_no_fa;
  257. u32 nrg_th_ofdm;
  258. u8 state;
  259. };
  260. /* Chain noise (differential Rx gain) calib data */
  261. struct iwl_chain_noise_data {
  262. u8 state;
  263. u16 beacon_count;
  264. u32 chain_noise_a;
  265. u32 chain_noise_b;
  266. u32 chain_noise_c;
  267. u32 chain_signal_a;
  268. u32 chain_signal_b;
  269. u32 chain_signal_c;
  270. u8 disconn_array[NUM_RX_CHAINS];
  271. u8 delta_gain_code[NUM_RX_CHAINS];
  272. u8 radio_write;
  273. };
  274. /* IWL4965 */
  275. #define RATE_MCS_CODE_MSK 0x7
  276. #define RATE_MCS_MIMO_POS 3
  277. #define RATE_MCS_MIMO_MSK 0x8
  278. #define RATE_MCS_HT_DUP_POS 5
  279. #define RATE_MCS_HT_DUP_MSK 0x20
  280. #define RATE_MCS_FLAGS_POS 8
  281. #define RATE_MCS_HT_POS 8
  282. #define RATE_MCS_HT_MSK 0x100
  283. #define RATE_MCS_CCK_POS 9
  284. #define RATE_MCS_CCK_MSK 0x200
  285. #define RATE_MCS_GF_POS 10
  286. #define RATE_MCS_GF_MSK 0x400
  287. #define RATE_MCS_FAT_POS 11
  288. #define RATE_MCS_FAT_MSK 0x800
  289. #define RATE_MCS_DUP_POS 12
  290. #define RATE_MCS_DUP_MSK 0x1000
  291. #define RATE_MCS_SGI_POS 13
  292. #define RATE_MCS_SGI_MSK 0x2000
  293. #define EEPROM_SEM_TIMEOUT 10
  294. #define EEPROM_SEM_RETRY_LIMIT 1000
  295. #endif /* __iwl_4965_h__ */