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