diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/dvm/dev.h')
-rw-r--r-- | drivers/net/wireless/iwlwifi/dvm/dev.h | 953 |
1 files changed, 953 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwlwifi/dvm/dev.h b/drivers/net/wireless/iwlwifi/dvm/dev.h new file mode 100644 index 000000000000..89f2e1040e7f --- /dev/null +++ b/drivers/net/wireless/iwlwifi/dvm/dev.h | |||
@@ -0,0 +1,953 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Copyright(c) 2003 - 2012 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 | * Intel Linux Wireless <ilw@linux.intel.com> | ||
23 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
24 | * | ||
25 | *****************************************************************************/ | ||
26 | /* | ||
27 | * Please use this file (dev.h) for driver implementation definitions. | ||
28 | * Please use commands.h for uCode API definitions. | ||
29 | */ | ||
30 | |||
31 | #ifndef __iwl_dev_h__ | ||
32 | #define __iwl_dev_h__ | ||
33 | |||
34 | #include <linux/interrupt.h> | ||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/wait.h> | ||
37 | #include <linux/leds.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/mutex.h> | ||
40 | |||
41 | #include "iwl-fw.h" | ||
42 | #include "iwl-eeprom-parse.h" | ||
43 | #include "iwl-csr.h" | ||
44 | #include "iwl-debug.h" | ||
45 | #include "iwl-agn-hw.h" | ||
46 | #include "iwl-op-mode.h" | ||
47 | #include "iwl-notif-wait.h" | ||
48 | #include "iwl-trans.h" | ||
49 | |||
50 | #include "led.h" | ||
51 | #include "power.h" | ||
52 | #include "rs.h" | ||
53 | #include "tt.h" | ||
54 | |||
55 | /* CT-KILL constants */ | ||
56 | #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ | ||
57 | #define CT_KILL_THRESHOLD 114 /* in Celsius */ | ||
58 | #define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */ | ||
59 | |||
60 | /* Default noise level to report when noise measurement is not available. | ||
61 | * This may be because we're: | ||
62 | * 1) Not associated no beacon statistics being sent to driver) | ||
63 | * 2) Scanning (noise measurement does not apply to associated channel) | ||
64 | * Use default noise value of -127 ... this is below the range of measurable | ||
65 | * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user. | ||
66 | * Also, -127 works better than 0 when averaging frames with/without | ||
67 | * noise info (e.g. averaging might be done in app); measured dBm values are | ||
68 | * always negative ... using a negative value as the default keeps all | ||
69 | * averages within an s8's (used in some apps) range of negative values. */ | ||
70 | #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127) | ||
71 | |||
72 | /* | ||
73 | * RTS threshold here is total size [2347] minus 4 FCS bytes | ||
74 | * Per spec: | ||
75 | * a value of 0 means RTS on all data/management packets | ||
76 | * a value > max MSDU size means no RTS | ||
77 | * else RTS for data/management frames where MPDU is larger | ||
78 | * than RTS value. | ||
79 | */ | ||
80 | #define DEFAULT_RTS_THRESHOLD 2347U | ||
81 | #define MIN_RTS_THRESHOLD 0U | ||
82 | #define MAX_RTS_THRESHOLD 2347U | ||
83 | #define MAX_MSDU_SIZE 2304U | ||
84 | #define MAX_MPDU_SIZE 2346U | ||
85 | #define DEFAULT_BEACON_INTERVAL 200U | ||
86 | #define DEFAULT_SHORT_RETRY_LIMIT 7U | ||
87 | #define DEFAULT_LONG_RETRY_LIMIT 4U | ||
88 | |||
89 | #define IWL_NUM_SCAN_RATES (2) | ||
90 | |||
91 | /* | ||
92 | * Minimum number of queues. MAX_NUM is defined in hw specific files. | ||
93 | * Set the minimum to accommodate | ||
94 | * - 4 standard TX queues | ||
95 | * - the command queue | ||
96 | * - 4 PAN TX queues | ||
97 | * - the PAN multicast queue, and | ||
98 | * - the AUX (TX during scan dwell) queue. | ||
99 | */ | ||
100 | #define IWL_MIN_NUM_QUEUES 11 | ||
101 | |||
102 | /* | ||
103 | * Command queue depends on iPAN support. | ||
104 | */ | ||
105 | #define IWL_DEFAULT_CMD_QUEUE_NUM 4 | ||
106 | #define IWL_IPAN_CMD_QUEUE_NUM 9 | ||
107 | |||
108 | #define IEEE80211_DATA_LEN 2304 | ||
109 | #define IEEE80211_4ADDR_LEN 30 | ||
110 | #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) | ||
111 | #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) | ||
112 | |||
113 | #define SUP_RATE_11A_MAX_NUM_CHANNELS 8 | ||
114 | #define SUP_RATE_11B_MAX_NUM_CHANNELS 4 | ||
115 | #define SUP_RATE_11G_MAX_NUM_CHANNELS 12 | ||
116 | |||
117 | #define IWL_SUPPORTED_RATES_IE_LEN 8 | ||
118 | |||
119 | #define IWL_INVALID_RATE 0xFF | ||
120 | #define IWL_INVALID_VALUE -1 | ||
121 | |||
122 | union iwl_ht_rate_supp { | ||
123 | u16 rates; | ||
124 | struct { | ||
125 | u8 siso_rate; | ||
126 | u8 mimo_rate; | ||
127 | }; | ||
128 | }; | ||
129 | |||
130 | struct iwl_ht_config { | ||
131 | bool single_chain_sufficient; | ||
132 | enum ieee80211_smps_mode smps; /* current smps mode */ | ||
133 | }; | ||
134 | |||
135 | /* QoS structures */ | ||
136 | struct iwl_qos_info { | ||
137 | int qos_active; | ||
138 | struct iwl_qosparam_cmd def_qos_parm; | ||
139 | }; | ||
140 | |||
141 | /** | ||
142 | * enum iwl_agg_state | ||
143 | * | ||
144 | * The state machine of the BA agreement establishment / tear down. | ||
145 | * These states relate to a specific RA / TID. | ||
146 | * | ||
147 | * @IWL_AGG_OFF: aggregation is not used | ||
148 | * @IWL_AGG_STARTING: aggregation are starting (between start and oper) | ||
149 | * @IWL_AGG_ON: aggregation session is up | ||
150 | * @IWL_EMPTYING_HW_QUEUE_ADDBA: establishing a BA session - waiting for the | ||
151 | * HW queue to be empty from packets for this RA /TID. | ||
152 | * @IWL_EMPTYING_HW_QUEUE_DELBA: tearing down a BA session - waiting for the | ||
153 | * HW queue to be empty from packets for this RA /TID. | ||
154 | */ | ||
155 | enum iwl_agg_state { | ||
156 | IWL_AGG_OFF = 0, | ||
157 | IWL_AGG_STARTING, | ||
158 | IWL_AGG_ON, | ||
159 | IWL_EMPTYING_HW_QUEUE_ADDBA, | ||
160 | IWL_EMPTYING_HW_QUEUE_DELBA, | ||
161 | }; | ||
162 | |||
163 | /** | ||
164 | * struct iwl_ht_agg - aggregation state machine | ||
165 | |||
166 | * This structs holds the states for the BA agreement establishment and tear | ||
167 | * down. It also holds the state during the BA session itself. This struct is | ||
168 | * duplicated for each RA / TID. | ||
169 | |||
170 | * @rate_n_flags: Rate at which Tx was attempted. Holds the data between the | ||
171 | * Tx response (REPLY_TX), and the block ack notification | ||
172 | * (REPLY_COMPRESSED_BA). | ||
173 | * @state: state of the BA agreement establishment / tear down. | ||
174 | * @txq_id: Tx queue used by the BA session | ||
175 | * @ssn: the first packet to be sent in AGG HW queue in Tx AGG start flow, or | ||
176 | * the first packet to be sent in legacy HW queue in Tx AGG stop flow. | ||
177 | * Basically when next_reclaimed reaches ssn, we can tell mac80211 that | ||
178 | * we are ready to finish the Tx AGG stop / start flow. | ||
179 | * @wait_for_ba: Expect block-ack before next Tx reply | ||
180 | */ | ||
181 | struct iwl_ht_agg { | ||
182 | u32 rate_n_flags; | ||
183 | enum iwl_agg_state state; | ||
184 | u16 txq_id; | ||
185 | u16 ssn; | ||
186 | bool wait_for_ba; | ||
187 | }; | ||
188 | |||
189 | /** | ||
190 | * struct iwl_tid_data - one for each RA / TID | ||
191 | |||
192 | * This structs holds the states for each RA / TID. | ||
193 | |||
194 | * @seq_number: the next WiFi sequence number to use | ||
195 | * @next_reclaimed: the WiFi sequence number of the next packet to be acked. | ||
196 | * This is basically (last acked packet++). | ||
197 | * @agg: aggregation state machine | ||
198 | */ | ||
199 | struct iwl_tid_data { | ||
200 | u16 seq_number; | ||
201 | u16 next_reclaimed; | ||
202 | struct iwl_ht_agg agg; | ||
203 | }; | ||
204 | |||
205 | /* | ||
206 | * Structure should be accessed with sta_lock held. When station addition | ||
207 | * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only | ||
208 | * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock | ||
209 | * held. | ||
210 | */ | ||
211 | struct iwl_station_entry { | ||
212 | struct iwl_addsta_cmd sta; | ||
213 | u8 used, ctxid; | ||
214 | struct iwl_link_quality_cmd *lq; | ||
215 | }; | ||
216 | |||
217 | /* | ||
218 | * iwl_station_priv: Driver's private station information | ||
219 | * | ||
220 | * When mac80211 creates a station it reserves some space (hw->sta_data_size) | ||
221 | * in the structure for use by driver. This structure is places in that | ||
222 | * space. | ||
223 | */ | ||
224 | struct iwl_station_priv { | ||
225 | struct iwl_rxon_context *ctx; | ||
226 | struct iwl_lq_sta lq_sta; | ||
227 | atomic_t pending_frames; | ||
228 | bool client; | ||
229 | bool asleep; | ||
230 | u8 max_agg_bufsize; | ||
231 | u8 sta_id; | ||
232 | }; | ||
233 | |||
234 | /** | ||
235 | * struct iwl_vif_priv - driver's private per-interface information | ||
236 | * | ||
237 | * When mac80211 allocates a virtual interface, it can allocate | ||
238 | * space for us to put data into. | ||
239 | */ | ||
240 | struct iwl_vif_priv { | ||
241 | struct iwl_rxon_context *ctx; | ||
242 | u8 ibss_bssid_sta_id; | ||
243 | }; | ||
244 | |||
245 | struct iwl_sensitivity_ranges { | ||
246 | u16 min_nrg_cck; | ||
247 | |||
248 | u16 nrg_th_cck; | ||
249 | u16 nrg_th_ofdm; | ||
250 | |||
251 | u16 auto_corr_min_ofdm; | ||
252 | u16 auto_corr_min_ofdm_mrc; | ||
253 | u16 auto_corr_min_ofdm_x1; | ||
254 | u16 auto_corr_min_ofdm_mrc_x1; | ||
255 | |||
256 | u16 auto_corr_max_ofdm; | ||
257 | u16 auto_corr_max_ofdm_mrc; | ||
258 | u16 auto_corr_max_ofdm_x1; | ||
259 | u16 auto_corr_max_ofdm_mrc_x1; | ||
260 | |||
261 | u16 auto_corr_max_cck; | ||
262 | u16 auto_corr_max_cck_mrc; | ||
263 | u16 auto_corr_min_cck; | ||
264 | u16 auto_corr_min_cck_mrc; | ||
265 | |||
266 | u16 barker_corr_th_min; | ||
267 | u16 barker_corr_th_min_mrc; | ||
268 | u16 nrg_th_cca; | ||
269 | }; | ||
270 | |||
271 | |||
272 | #define KELVIN_TO_CELSIUS(x) ((x)-273) | ||
273 | #define CELSIUS_TO_KELVIN(x) ((x)+273) | ||
274 | |||
275 | |||
276 | /****************************************************************************** | ||
277 | * | ||
278 | * Functions implemented in core module which are forward declared here | ||
279 | * for use by iwl-[4-5].c | ||
280 | * | ||
281 | * NOTE: The implementation of these functions are not hardware specific | ||
282 | * which is why they are in the core module files. | ||
283 | * | ||
284 | * Naming convention -- | ||
285 | * iwl_ <-- Is part of iwlwifi | ||
286 | * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) | ||
287 | * | ||
288 | ****************************************************************************/ | ||
289 | extern void iwl_update_chain_flags(struct iwl_priv *priv); | ||
290 | extern const u8 iwl_bcast_addr[ETH_ALEN]; | ||
291 | |||
292 | #define IWL_OPERATION_MODE_AUTO 0 | ||
293 | #define IWL_OPERATION_MODE_HT_ONLY 1 | ||
294 | #define IWL_OPERATION_MODE_MIXED 2 | ||
295 | #define IWL_OPERATION_MODE_20MHZ 3 | ||
296 | |||
297 | #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000 | ||
298 | |||
299 | /* Sensitivity and chain noise calibration */ | ||
300 | #define INITIALIZATION_VALUE 0xFFFF | ||
301 | #define IWL_CAL_NUM_BEACONS 16 | ||
302 | #define MAXIMUM_ALLOWED_PATHLOSS 15 | ||
303 | |||
304 | #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3 | ||
305 | |||
306 | #define MAX_FA_OFDM 50 | ||
307 | #define MIN_FA_OFDM 5 | ||
308 | #define MAX_FA_CCK 50 | ||
309 | #define MIN_FA_CCK 5 | ||
310 | |||
311 | #define AUTO_CORR_STEP_OFDM 1 | ||
312 | |||
313 | #define AUTO_CORR_STEP_CCK 3 | ||
314 | #define AUTO_CORR_MAX_TH_CCK 160 | ||
315 | |||
316 | #define NRG_DIFF 2 | ||
317 | #define NRG_STEP_CCK 2 | ||
318 | #define NRG_MARGIN 8 | ||
319 | #define MAX_NUMBER_CCK_NO_FA 100 | ||
320 | |||
321 | #define AUTO_CORR_CCK_MIN_VAL_DEF (125) | ||
322 | |||
323 | #define CHAIN_A 0 | ||
324 | #define CHAIN_B 1 | ||
325 | #define CHAIN_C 2 | ||
326 | #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4 | ||
327 | #define ALL_BAND_FILTER 0xFF00 | ||
328 | #define IN_BAND_FILTER 0xFF | ||
329 | #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF | ||
330 | |||
331 | #define NRG_NUM_PREV_STAT_L 20 | ||
332 | #define NUM_RX_CHAINS 3 | ||
333 | |||
334 | enum iwlagn_false_alarm_state { | ||
335 | IWL_FA_TOO_MANY = 0, | ||
336 | IWL_FA_TOO_FEW = 1, | ||
337 | IWL_FA_GOOD_RANGE = 2, | ||
338 | }; | ||
339 | |||
340 | enum iwlagn_chain_noise_state { | ||
341 | IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ | ||
342 | IWL_CHAIN_NOISE_ACCUMULATE, | ||
343 | IWL_CHAIN_NOISE_CALIBRATED, | ||
344 | IWL_CHAIN_NOISE_DONE, | ||
345 | }; | ||
346 | |||
347 | /* Sensitivity calib data */ | ||
348 | struct iwl_sensitivity_data { | ||
349 | u32 auto_corr_ofdm; | ||
350 | u32 auto_corr_ofdm_mrc; | ||
351 | u32 auto_corr_ofdm_x1; | ||
352 | u32 auto_corr_ofdm_mrc_x1; | ||
353 | u32 auto_corr_cck; | ||
354 | u32 auto_corr_cck_mrc; | ||
355 | |||
356 | u32 last_bad_plcp_cnt_ofdm; | ||
357 | u32 last_fa_cnt_ofdm; | ||
358 | u32 last_bad_plcp_cnt_cck; | ||
359 | u32 last_fa_cnt_cck; | ||
360 | |||
361 | u32 nrg_curr_state; | ||
362 | u32 nrg_prev_state; | ||
363 | u32 nrg_value[10]; | ||
364 | u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; | ||
365 | u32 nrg_silence_ref; | ||
366 | u32 nrg_energy_idx; | ||
367 | u32 nrg_silence_idx; | ||
368 | u32 nrg_th_cck; | ||
369 | s32 nrg_auto_corr_silence_diff; | ||
370 | u32 num_in_cck_no_fa; | ||
371 | u32 nrg_th_ofdm; | ||
372 | |||
373 | u16 barker_corr_th_min; | ||
374 | u16 barker_corr_th_min_mrc; | ||
375 | u16 nrg_th_cca; | ||
376 | }; | ||
377 | |||
378 | /* Chain noise (differential Rx gain) calib data */ | ||
379 | struct iwl_chain_noise_data { | ||
380 | u32 active_chains; | ||
381 | u32 chain_noise_a; | ||
382 | u32 chain_noise_b; | ||
383 | u32 chain_noise_c; | ||
384 | u32 chain_signal_a; | ||
385 | u32 chain_signal_b; | ||
386 | u32 chain_signal_c; | ||
387 | u16 beacon_count; | ||
388 | u8 disconn_array[NUM_RX_CHAINS]; | ||
389 | u8 delta_gain_code[NUM_RX_CHAINS]; | ||
390 | u8 radio_write; | ||
391 | u8 state; | ||
392 | }; | ||
393 | |||
394 | enum { | ||
395 | MEASUREMENT_READY = (1 << 0), | ||
396 | MEASUREMENT_ACTIVE = (1 << 1), | ||
397 | }; | ||
398 | |||
399 | /* reply_tx_statistics (for _agn devices) */ | ||
400 | struct reply_tx_error_statistics { | ||
401 | u32 pp_delay; | ||
402 | u32 pp_few_bytes; | ||
403 | u32 pp_bt_prio; | ||
404 | u32 pp_quiet_period; | ||
405 | u32 pp_calc_ttak; | ||
406 | u32 int_crossed_retry; | ||
407 | u32 short_limit; | ||
408 | u32 long_limit; | ||
409 | u32 fifo_underrun; | ||
410 | u32 drain_flow; | ||
411 | u32 rfkill_flush; | ||
412 | u32 life_expire; | ||
413 | u32 dest_ps; | ||
414 | u32 host_abort; | ||
415 | u32 bt_retry; | ||
416 | u32 sta_invalid; | ||
417 | u32 frag_drop; | ||
418 | u32 tid_disable; | ||
419 | u32 fifo_flush; | ||
420 | u32 insuff_cf_poll; | ||
421 | u32 fail_hw_drop; | ||
422 | u32 sta_color_mismatch; | ||
423 | u32 unknown; | ||
424 | }; | ||
425 | |||
426 | /* reply_agg_tx_statistics (for _agn devices) */ | ||
427 | struct reply_agg_tx_error_statistics { | ||
428 | u32 underrun; | ||
429 | u32 bt_prio; | ||
430 | u32 few_bytes; | ||
431 | u32 abort; | ||
432 | u32 last_sent_ttl; | ||
433 | u32 last_sent_try; | ||
434 | u32 last_sent_bt_kill; | ||
435 | u32 scd_query; | ||
436 | u32 bad_crc32; | ||
437 | u32 response; | ||
438 | u32 dump_tx; | ||
439 | u32 delay_tx; | ||
440 | u32 unknown; | ||
441 | }; | ||
442 | |||
443 | /* | ||
444 | * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds | ||
445 | * to perform continuous uCode event logging operation if enabled | ||
446 | */ | ||
447 | #define UCODE_TRACE_PERIOD (10) | ||
448 | |||
449 | /* | ||
450 | * iwl_event_log: current uCode event log position | ||
451 | * | ||
452 | * @ucode_trace: enable/disable ucode continuous trace timer | ||
453 | * @num_wraps: how many times the event buffer wraps | ||
454 | * @next_entry: the entry just before the next one that uCode would fill | ||
455 | * @non_wraps_count: counter for no wrap detected when dump ucode events | ||
456 | * @wraps_once_count: counter for wrap once detected when dump ucode events | ||
457 | * @wraps_more_count: counter for wrap more than once detected | ||
458 | * when dump ucode events | ||
459 | */ | ||
460 | struct iwl_event_log { | ||
461 | bool ucode_trace; | ||
462 | u32 num_wraps; | ||
463 | u32 next_entry; | ||
464 | int non_wraps_count; | ||
465 | int wraps_once_count; | ||
466 | int wraps_more_count; | ||
467 | }; | ||
468 | |||
469 | #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3) | ||
470 | |||
471 | /* BT Antenna Coupling Threshold (dB) */ | ||
472 | #define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35) | ||
473 | |||
474 | /* Firmware reload counter and Timestamp */ | ||
475 | #define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */ | ||
476 | #define IWL_MAX_CONTINUE_RELOAD_CNT 4 | ||
477 | |||
478 | |||
479 | struct iwl_rf_reset { | ||
480 | int reset_request_count; | ||
481 | int reset_success_count; | ||
482 | int reset_reject_count; | ||
483 | unsigned long last_reset_jiffies; | ||
484 | }; | ||
485 | |||
486 | enum iwl_rxon_context_id { | ||
487 | IWL_RXON_CTX_BSS, | ||
488 | IWL_RXON_CTX_PAN, | ||
489 | |||
490 | NUM_IWL_RXON_CTX | ||
491 | }; | ||
492 | |||
493 | /* extend beacon time format bit shifting */ | ||
494 | /* | ||
495 | * for _agn devices | ||
496 | * bits 31:22 - extended | ||
497 | * bits 21:0 - interval | ||
498 | */ | ||
499 | #define IWLAGN_EXT_BEACON_TIME_POS 22 | ||
500 | |||
501 | struct iwl_rxon_context { | ||
502 | struct ieee80211_vif *vif; | ||
503 | |||
504 | u8 mcast_queue; | ||
505 | u8 ac_to_queue[IEEE80211_NUM_ACS]; | ||
506 | u8 ac_to_fifo[IEEE80211_NUM_ACS]; | ||
507 | |||
508 | /* | ||
509 | * We could use the vif to indicate active, but we | ||
510 | * also need it to be active during disabling when | ||
511 | * we already removed the vif for type setting. | ||
512 | */ | ||
513 | bool always_active, is_active; | ||
514 | |||
515 | bool ht_need_multiple_chains; | ||
516 | |||
517 | enum iwl_rxon_context_id ctxid; | ||
518 | |||
519 | u32 interface_modes, exclusive_interface_modes; | ||
520 | u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; | ||
521 | |||
522 | /* | ||
523 | * We declare this const so it can only be | ||
524 | * changed via explicit cast within the | ||
525 | * routines that actually update the physical | ||
526 | * hardware. | ||
527 | */ | ||
528 | const struct iwl_rxon_cmd active; | ||
529 | struct iwl_rxon_cmd staging; | ||
530 | |||
531 | struct iwl_rxon_time_cmd timing; | ||
532 | |||
533 | struct iwl_qos_info qos_data; | ||
534 | |||
535 | u8 bcast_sta_id, ap_sta_id; | ||
536 | |||
537 | u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd; | ||
538 | u8 qos_cmd; | ||
539 | u8 wep_key_cmd; | ||
540 | |||
541 | struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; | ||
542 | u8 key_mapping_keys; | ||
543 | |||
544 | __le32 station_flags; | ||
545 | |||
546 | int beacon_int; | ||
547 | |||
548 | struct { | ||
549 | bool non_gf_sta_present; | ||
550 | u8 protection; | ||
551 | bool enabled, is_40mhz; | ||
552 | u8 extension_chan_offset; | ||
553 | } ht; | ||
554 | }; | ||
555 | |||
556 | enum iwl_scan_type { | ||
557 | IWL_SCAN_NORMAL, | ||
558 | IWL_SCAN_RADIO_RESET, | ||
559 | IWL_SCAN_ROC, | ||
560 | }; | ||
561 | |||
562 | /** | ||
563 | * struct iwl_hw_params | ||
564 | * | ||
565 | * Holds the module parameters | ||
566 | * | ||
567 | * @tx_chains_num: Number of TX chains | ||
568 | * @rx_chains_num: Number of RX chains | ||
569 | * @sku: sku read from EEPROM | ||
570 | * @ct_kill_threshold: temperature threshold - in hw dependent unit | ||
571 | * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit | ||
572 | * relevant for 1000, 6000 and up | ||
573 | * @struct iwl_sensitivity_ranges: range of sensitivity values | ||
574 | * @use_rts_for_aggregation: use rts/cts protection for HT traffic | ||
575 | */ | ||
576 | struct iwl_hw_params { | ||
577 | u8 tx_chains_num; | ||
578 | u8 rx_chains_num; | ||
579 | bool use_rts_for_aggregation; | ||
580 | u16 sku; | ||
581 | u32 ct_kill_threshold; | ||
582 | u32 ct_kill_exit_threshold; | ||
583 | |||
584 | const struct iwl_sensitivity_ranges *sens; | ||
585 | }; | ||
586 | |||
587 | struct iwl_lib_ops { | ||
588 | /* set hw dependent parameters */ | ||
589 | void (*set_hw_params)(struct iwl_priv *priv); | ||
590 | int (*set_channel_switch)(struct iwl_priv *priv, | ||
591 | struct ieee80211_channel_switch *ch_switch); | ||
592 | /* device specific configuration */ | ||
593 | void (*nic_config)(struct iwl_priv *priv); | ||
594 | |||
595 | /* temperature */ | ||
596 | void (*temperature)(struct iwl_priv *priv); | ||
597 | }; | ||
598 | |||
599 | #ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE | ||
600 | struct iwl_testmode_trace { | ||
601 | u32 buff_size; | ||
602 | u32 total_size; | ||
603 | u32 num_chunks; | ||
604 | u8 *cpu_addr; | ||
605 | u8 *trace_addr; | ||
606 | dma_addr_t dma_addr; | ||
607 | bool trace_enabled; | ||
608 | }; | ||
609 | struct iwl_testmode_mem { | ||
610 | u32 buff_size; | ||
611 | u32 num_chunks; | ||
612 | u8 *buff_addr; | ||
613 | bool read_in_progress; | ||
614 | }; | ||
615 | #endif | ||
616 | |||
617 | struct iwl_wipan_noa_data { | ||
618 | struct rcu_head rcu_head; | ||
619 | u32 length; | ||
620 | u8 data[]; | ||
621 | }; | ||
622 | |||
623 | /* Calibration disabling bit mask */ | ||
624 | enum { | ||
625 | IWL_CALIB_ENABLE_ALL = 0, | ||
626 | |||
627 | IWL_SENSITIVITY_CALIB_DISABLED = BIT(0), | ||
628 | IWL_CHAIN_NOISE_CALIB_DISABLED = BIT(1), | ||
629 | IWL_TX_POWER_CALIB_DISABLED = BIT(2), | ||
630 | |||
631 | IWL_CALIB_DISABLE_ALL = 0xFFFFFFFF, | ||
632 | }; | ||
633 | |||
634 | #define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \ | ||
635 | ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific)) | ||
636 | |||
637 | #define IWL_MAC80211_GET_DVM(_hw) \ | ||
638 | ((struct iwl_priv *) ((struct iwl_op_mode *) \ | ||
639 | (_hw)->priv)->op_mode_specific) | ||
640 | |||
641 | struct iwl_priv { | ||
642 | |||
643 | struct iwl_trans *trans; | ||
644 | struct device *dev; /* for debug prints only */ | ||
645 | const struct iwl_cfg *cfg; | ||
646 | const struct iwl_fw *fw; | ||
647 | const struct iwl_lib_ops *lib; | ||
648 | unsigned long status; | ||
649 | |||
650 | spinlock_t sta_lock; | ||
651 | struct mutex mutex; | ||
652 | |||
653 | unsigned long transport_queue_stop; | ||
654 | bool passive_no_rx; | ||
655 | #define IWL_INVALID_MAC80211_QUEUE 0xff | ||
656 | u8 queue_to_mac80211[IWL_MAX_HW_QUEUES]; | ||
657 | atomic_t queue_stop_count[IWL_MAX_HW_QUEUES]; | ||
658 | |||
659 | unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)]; | ||
660 | |||
661 | /* ieee device used by generic ieee processing code */ | ||
662 | struct ieee80211_hw *hw; | ||
663 | |||
664 | struct list_head calib_results; | ||
665 | |||
666 | struct workqueue_struct *workqueue; | ||
667 | |||
668 | struct iwl_hw_params hw_params; | ||
669 | |||
670 | enum ieee80211_band band; | ||
671 | u8 valid_contexts; | ||
672 | |||
673 | void (*pre_rx_handler)(struct iwl_priv *priv, | ||
674 | struct iwl_rx_cmd_buffer *rxb); | ||
675 | int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv, | ||
676 | struct iwl_rx_cmd_buffer *rxb, | ||
677 | struct iwl_device_cmd *cmd); | ||
678 | |||
679 | struct iwl_notif_wait_data notif_wait; | ||
680 | |||
681 | /* spectrum measurement report caching */ | ||
682 | struct iwl_spectrum_notification measure_report; | ||
683 | u8 measurement_status; | ||
684 | |||
685 | #define IWL_OWNERSHIP_DRIVER 0 | ||
686 | #define IWL_OWNERSHIP_TM 1 | ||
687 | u8 ucode_owner; | ||
688 | |||
689 | /* ucode beacon time */ | ||
690 | u32 ucode_beacon_time; | ||
691 | int missed_beacon_threshold; | ||
692 | |||
693 | /* track IBSS manager (last beacon) status */ | ||
694 | u32 ibss_manager; | ||
695 | |||
696 | /* jiffies when last recovery from statistics was performed */ | ||
697 | unsigned long rx_statistics_jiffies; | ||
698 | |||
699 | /*counters */ | ||
700 | u32 rx_handlers_stats[REPLY_MAX]; | ||
701 | |||
702 | /* rf reset */ | ||
703 | struct iwl_rf_reset rf_reset; | ||
704 | |||
705 | /* firmware reload counter and timestamp */ | ||
706 | unsigned long reload_jiffies; | ||
707 | int reload_count; | ||
708 | bool ucode_loaded; | ||
709 | bool init_ucode_run; /* Don't run init uCode again */ | ||
710 | |||
711 | u8 plcp_delta_threshold; | ||
712 | |||
713 | /* thermal calibration */ | ||
714 | s32 temperature; /* Celsius */ | ||
715 | s32 last_temperature; | ||
716 | |||
717 | struct iwl_wipan_noa_data __rcu *noa_data; | ||
718 | |||
719 | /* Scan related variables */ | ||
720 | unsigned long scan_start; | ||
721 | unsigned long scan_start_tsf; | ||
722 | void *scan_cmd; | ||
723 | enum ieee80211_band scan_band; | ||
724 | struct cfg80211_scan_request *scan_request; | ||
725 | struct ieee80211_vif *scan_vif; | ||
726 | enum iwl_scan_type scan_type; | ||
727 | u8 scan_tx_ant[IEEE80211_NUM_BANDS]; | ||
728 | u8 mgmt_tx_ant; | ||
729 | |||
730 | /* max number of station keys */ | ||
731 | u8 sta_key_max_num; | ||
732 | |||
733 | bool new_scan_threshold_behaviour; | ||
734 | |||
735 | bool wowlan; | ||
736 | |||
737 | /* EEPROM MAC addresses */ | ||
738 | struct mac_address addresses[2]; | ||
739 | |||
740 | struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; | ||
741 | |||
742 | __le16 switch_channel; | ||
743 | |||
744 | u8 start_calib; | ||
745 | struct iwl_sensitivity_data sensitivity_data; | ||
746 | struct iwl_chain_noise_data chain_noise_data; | ||
747 | __le16 sensitivity_tbl[HD_TABLE_SIZE]; | ||
748 | __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES]; | ||
749 | |||
750 | struct iwl_ht_config current_ht_config; | ||
751 | |||
752 | /* Rate scaling data */ | ||
753 | u8 retry_rate; | ||
754 | |||
755 | int activity_timer_active; | ||
756 | |||
757 | struct iwl_power_mgr power_data; | ||
758 | struct iwl_tt_mgmt thermal_throttle; | ||
759 | |||
760 | /* station table variables */ | ||
761 | int num_stations; | ||
762 | struct iwl_station_entry stations[IWLAGN_STATION_COUNT]; | ||
763 | unsigned long ucode_key_table; | ||
764 | struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT]; | ||
765 | atomic_t num_aux_in_flight; | ||
766 | |||
767 | u8 mac80211_registered; | ||
768 | |||
769 | /* Indication if ieee80211_ops->open has been called */ | ||
770 | u8 is_open; | ||
771 | |||
772 | enum nl80211_iftype iw_mode; | ||
773 | |||
774 | /* Last Rx'd beacon timestamp */ | ||
775 | u64 timestamp; | ||
776 | |||
777 | struct { | ||
778 | __le32 flag; | ||
779 | struct statistics_general_common common; | ||
780 | struct statistics_rx_non_phy rx_non_phy; | ||
781 | struct statistics_rx_phy rx_ofdm; | ||
782 | struct statistics_rx_ht_phy rx_ofdm_ht; | ||
783 | struct statistics_rx_phy rx_cck; | ||
784 | struct statistics_tx tx; | ||
785 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
786 | struct statistics_bt_activity bt_activity; | ||
787 | __le32 num_bt_kills, accum_num_bt_kills; | ||
788 | #endif | ||
789 | spinlock_t lock; | ||
790 | } statistics; | ||
791 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
792 | struct { | ||
793 | struct statistics_general_common common; | ||
794 | struct statistics_rx_non_phy rx_non_phy; | ||
795 | struct statistics_rx_phy rx_ofdm; | ||
796 | struct statistics_rx_ht_phy rx_ofdm_ht; | ||
797 | struct statistics_rx_phy rx_cck; | ||
798 | struct statistics_tx tx; | ||
799 | struct statistics_bt_activity bt_activity; | ||
800 | } accum_stats, delta_stats, max_delta_stats; | ||
801 | #endif | ||
802 | |||
803 | /* | ||
804 | * reporting the number of tids has AGG on. 0 means | ||
805 | * no AGGREGATION | ||
806 | */ | ||
807 | u8 agg_tids_count; | ||
808 | |||
809 | struct iwl_rx_phy_res last_phy_res; | ||
810 | bool last_phy_res_valid; | ||
811 | |||
812 | /* | ||
813 | * chain noise reset and gain commands are the | ||
814 | * two extra calibration commands follows the standard | ||
815 | * phy calibration commands | ||
816 | */ | ||
817 | u8 phy_calib_chain_noise_reset_cmd; | ||
818 | u8 phy_calib_chain_noise_gain_cmd; | ||
819 | |||
820 | /* counts reply_tx error */ | ||
821 | struct reply_tx_error_statistics reply_tx_stats; | ||
822 | struct reply_agg_tx_error_statistics reply_agg_tx_stats; | ||
823 | |||
824 | /* remain-on-channel offload support */ | ||
825 | struct ieee80211_channel *hw_roc_channel; | ||
826 | struct delayed_work hw_roc_disable_work; | ||
827 | enum nl80211_channel_type hw_roc_chantype; | ||
828 | int hw_roc_duration; | ||
829 | bool hw_roc_setup, hw_roc_start_notified; | ||
830 | |||
831 | /* bt coex */ | ||
832 | u8 bt_enable_flag; | ||
833 | u8 bt_status; | ||
834 | u8 bt_traffic_load, last_bt_traffic_load; | ||
835 | bool bt_ch_announce; | ||
836 | bool bt_full_concurrent; | ||
837 | bool bt_ant_couple_ok; | ||
838 | __le32 kill_ack_mask; | ||
839 | __le32 kill_cts_mask; | ||
840 | __le16 bt_valid; | ||
841 | bool reduced_txpower; | ||
842 | u16 bt_on_thresh; | ||
843 | u16 bt_duration; | ||
844 | u16 dynamic_frag_thresh; | ||
845 | u8 bt_ci_compliance; | ||
846 | struct work_struct bt_traffic_change_work; | ||
847 | bool bt_enable_pspoll; | ||
848 | struct iwl_rxon_context *cur_rssi_ctx; | ||
849 | bool bt_is_sco; | ||
850 | |||
851 | struct work_struct restart; | ||
852 | struct work_struct scan_completed; | ||
853 | struct work_struct abort_scan; | ||
854 | |||
855 | struct work_struct beacon_update; | ||
856 | struct iwl_rxon_context *beacon_ctx; | ||
857 | struct sk_buff *beacon_skb; | ||
858 | void *beacon_cmd; | ||
859 | |||
860 | struct work_struct tt_work; | ||
861 | struct work_struct ct_enter; | ||
862 | struct work_struct ct_exit; | ||
863 | struct work_struct start_internal_scan; | ||
864 | struct work_struct tx_flush; | ||
865 | struct work_struct bt_full_concurrency; | ||
866 | struct work_struct bt_runtime_config; | ||
867 | |||
868 | struct delayed_work scan_check; | ||
869 | |||
870 | /* TX Power settings */ | ||
871 | s8 tx_power_user_lmt; | ||
872 | s8 tx_power_next; | ||
873 | |||
874 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
875 | /* debugfs */ | ||
876 | struct dentry *debugfs_dir; | ||
877 | u32 dbgfs_sram_offset, dbgfs_sram_len; | ||
878 | bool disable_ht40; | ||
879 | void *wowlan_sram; | ||
880 | #endif /* CONFIG_IWLWIFI_DEBUGFS */ | ||
881 | |||
882 | struct iwl_eeprom_data *eeprom_data; | ||
883 | /* eeprom blob for debugfs/testmode */ | ||
884 | u8 *eeprom_blob; | ||
885 | size_t eeprom_blob_size; | ||
886 | |||
887 | struct work_struct txpower_work; | ||
888 | u32 calib_disabled; | ||
889 | struct work_struct run_time_calib_work; | ||
890 | struct timer_list statistics_periodic; | ||
891 | struct timer_list ucode_trace; | ||
892 | |||
893 | struct iwl_event_log event_log; | ||
894 | |||
895 | struct led_classdev led; | ||
896 | unsigned long blink_on, blink_off; | ||
897 | bool led_registered; | ||
898 | #ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE | ||
899 | struct iwl_testmode_trace testmode_trace; | ||
900 | struct iwl_testmode_mem testmode_mem; | ||
901 | u32 tm_fixed_rate; | ||
902 | #endif | ||
903 | |||
904 | /* WoWLAN GTK rekey data */ | ||
905 | u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN]; | ||
906 | __le64 replay_ctr; | ||
907 | __le16 last_seq_ctl; | ||
908 | bool have_rekey_data; | ||
909 | |||
910 | /* device_pointers: pointers to ucode event tables */ | ||
911 | struct { | ||
912 | u32 error_event_table; | ||
913 | u32 log_event_table; | ||
914 | } device_pointers; | ||
915 | |||
916 | /* indicator of loaded ucode image */ | ||
917 | enum iwl_ucode_type cur_ucode; | ||
918 | }; /*iwl_priv */ | ||
919 | |||
920 | static inline struct iwl_rxon_context * | ||
921 | iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif) | ||
922 | { | ||
923 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
924 | |||
925 | return vif_priv->ctx; | ||
926 | } | ||
927 | |||
928 | #define for_each_context(priv, ctx) \ | ||
929 | for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \ | ||
930 | ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \ | ||
931 | if (priv->valid_contexts & BIT(ctx->ctxid)) | ||
932 | |||
933 | static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx) | ||
934 | { | ||
935 | return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; | ||
936 | } | ||
937 | |||
938 | static inline int iwl_is_associated(struct iwl_priv *priv, | ||
939 | enum iwl_rxon_context_id ctxid) | ||
940 | { | ||
941 | return iwl_is_associated_ctx(&priv->contexts[ctxid]); | ||
942 | } | ||
943 | |||
944 | static inline int iwl_is_any_associated(struct iwl_priv *priv) | ||
945 | { | ||
946 | struct iwl_rxon_context *ctx; | ||
947 | for_each_context(priv, ctx) | ||
948 | if (iwl_is_associated_ctx(ctx)) | ||
949 | return true; | ||
950 | return false; | ||
951 | } | ||
952 | |||
953 | #endif /* __iwl_dev_h__ */ | ||