3e4ba31b5d59ad0a666ad185d3e4c058e00383a8
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / iwl-commands.h
1 /******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63 /*
64 * Please use this file (iwl-commands.h) only for uCode API definitions.
65 * Please use iwl-xxxx-hw.h for hardware-related definitions.
66 * Please use iwl-dev.h for driver implementation definitions.
67 */
68
69 #ifndef __iwl_commands_h__
70 #define __iwl_commands_h__
71
72 struct iwl_priv;
73
74 /* uCode version contains 4 values: Major/Minor/API/Serial */
75 #define IWL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24)
76 #define IWL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16)
77 #define IWL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8)
78 #define IWL_UCODE_SERIAL(ver) ((ver) & 0x000000FF)
79
80
81 /* Tx rates */
82 #define IWL_CCK_RATES 4
83 #define IWL_OFDM_RATES 8
84 #define IWL_MAX_RATES (IWL_CCK_RATES + IWL_OFDM_RATES)
85
86 enum {
87 REPLY_ALIVE = 0x1,
88 REPLY_ERROR = 0x2,
89
90 /* RXON and QOS commands */
91 REPLY_RXON = 0x10,
92 REPLY_RXON_ASSOC = 0x11,
93 REPLY_QOS_PARAM = 0x13,
94 REPLY_RXON_TIMING = 0x14,
95
96 /* Multi-Station support */
97 REPLY_ADD_STA = 0x18,
98 REPLY_REMOVE_STA = 0x19,
99 REPLY_REMOVE_ALL_STA = 0x1a, /* not used */
100 REPLY_TXFIFO_FLUSH = 0x1e,
101
102 /* Security */
103 REPLY_WEPKEY = 0x20,
104
105 /* RX, TX, LEDs */
106 REPLY_3945_RX = 0x1b, /* 3945 only */
107 REPLY_TX = 0x1c,
108 REPLY_RATE_SCALE = 0x47, /* 3945 only */
109 REPLY_LEDS_CMD = 0x48,
110 REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 and up */
111
112 /* WiMAX coexistence */
113 COEX_PRIORITY_TABLE_CMD = 0x5a, /* for 5000 series and up */
114 COEX_MEDIUM_NOTIFICATION = 0x5b,
115 COEX_EVENT_CMD = 0x5c,
116
117 /* Calibration */
118 TEMPERATURE_NOTIFICATION = 0x62,
119 CALIBRATION_CFG_CMD = 0x65,
120 CALIBRATION_RES_NOTIFICATION = 0x66,
121 CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
122
123 /* 802.11h related */
124 REPLY_QUIET_CMD = 0x71, /* not used */
125 REPLY_CHANNEL_SWITCH = 0x72,
126 CHANNEL_SWITCH_NOTIFICATION = 0x73,
127 REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
128 SPECTRUM_MEASURE_NOTIFICATION = 0x75,
129
130 /* Power Management */
131 POWER_TABLE_CMD = 0x77,
132 PM_SLEEP_NOTIFICATION = 0x7A,
133 PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
134
135 /* Scan commands and notifications */
136 REPLY_SCAN_CMD = 0x80,
137 REPLY_SCAN_ABORT_CMD = 0x81,
138 SCAN_START_NOTIFICATION = 0x82,
139 SCAN_RESULTS_NOTIFICATION = 0x83,
140 SCAN_COMPLETE_NOTIFICATION = 0x84,
141
142 /* IBSS/AP commands */
143 BEACON_NOTIFICATION = 0x90,
144 REPLY_TX_BEACON = 0x91,
145 WHO_IS_AWAKE_NOTIFICATION = 0x94, /* not used */
146
147 /* Miscellaneous commands */
148 REPLY_TX_POWER_DBM_CMD = 0x95,
149 QUIET_NOTIFICATION = 0x96, /* not used */
150 REPLY_TX_PWR_TABLE_CMD = 0x97,
151 REPLY_TX_POWER_DBM_CMD_V1 = 0x98, /* old version of API */
152 TX_ANT_CONFIGURATION_CMD = 0x98,
153 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
154
155 /* Bluetooth device coexistence config command */
156 REPLY_BT_CONFIG = 0x9b,
157
158 /* Statistics */
159 REPLY_STATISTICS_CMD = 0x9c,
160 STATISTICS_NOTIFICATION = 0x9d,
161
162 /* RF-KILL commands and notifications */
163 REPLY_CARD_STATE_CMD = 0xa0,
164 CARD_STATE_NOTIFICATION = 0xa1,
165
166 /* Missed beacons notification */
167 MISSED_BEACONS_NOTIFICATION = 0xa2,
168
169 REPLY_CT_KILL_CONFIG_CMD = 0xa4,
170 SENSITIVITY_CMD = 0xa8,
171 REPLY_PHY_CALIBRATION_CMD = 0xb0,
172 REPLY_RX_PHY_CMD = 0xc0,
173 REPLY_RX_MPDU_CMD = 0xc1,
174 REPLY_RX = 0xc3,
175 REPLY_COMPRESSED_BA = 0xc5,
176
177 /* BT Coex */
178 REPLY_BT_COEX_PRIO_TABLE = 0xcc,
179 REPLY_BT_COEX_PROT_ENV = 0xcd,
180 REPLY_BT_COEX_PROFILE_NOTIF = 0xce,
181 REPLY_BT_COEX_SCO = 0xcf,
182
183 /* PAN commands */
184 REPLY_WIPAN_PARAMS = 0xb2,
185 REPLY_WIPAN_RXON = 0xb3, /* use REPLY_RXON structure */
186 REPLY_WIPAN_RXON_TIMING = 0xb4, /* use REPLY_RXON_TIMING structure */
187 REPLY_WIPAN_RXON_ASSOC = 0xb6, /* use REPLY_RXON_ASSOC structure */
188 REPLY_WIPAN_QOS_PARAM = 0xb7, /* use REPLY_QOS_PARAM structure */
189 REPLY_WIPAN_WEPKEY = 0xb8, /* use REPLY_WEPKEY structure */
190 REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9,
191 REPLY_WIPAN_NOA_NOTIFICATION = 0xbc,
192
193 REPLY_MAX = 0xff
194 };
195
196 /******************************************************************************
197 * (0)
198 * Commonly used structures and definitions:
199 * Command header, rate_n_flags, txpower
200 *
201 *****************************************************************************/
202
203 /* iwl_cmd_header flags value */
204 #define IWL_CMD_FAILED_MSK 0x40
205
206 #define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f)
207 #define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8)
208 #define SEQ_TO_INDEX(s) ((s) & 0xff)
209 #define INDEX_TO_SEQ(i) ((i) & 0xff)
210 #define SEQ_HUGE_FRAME cpu_to_le16(0x4000)
211 #define SEQ_RX_FRAME cpu_to_le16(0x8000)
212
213 /**
214 * struct iwl_cmd_header
215 *
216 * This header format appears in the beginning of each command sent from the
217 * driver, and each response/notification received from uCode.
218 */
219 struct iwl_cmd_header {
220 u8 cmd; /* Command ID: REPLY_RXON, etc. */
221 u8 flags; /* 0:5 reserved, 6 abort, 7 internal */
222 /*
223 * The driver sets up the sequence number to values of its choosing.
224 * uCode does not use this value, but passes it back to the driver
225 * when sending the response to each driver-originated command, so
226 * the driver can match the response to the command. Since the values
227 * don't get used by uCode, the driver may set up an arbitrary format.
228 *
229 * There is one exception: uCode sets bit 15 when it originates
230 * the response/notification, i.e. when the response/notification
231 * is not a direct response to a command sent by the driver. For
232 * example, uCode issues REPLY_3945_RX when it sends a received frame
233 * to the driver; it is not a direct response to any driver command.
234 *
235 * The Linux driver uses the following format:
236 *
237 * 0:7 tfd index - position within TX queue
238 * 8:12 TX queue id
239 * 13 reserved
240 * 14 huge - driver sets this to indicate command is in the
241 * 'huge' storage at the end of the command buffers
242 * 15 unsolicited RX or uCode-originated notification
243 */
244 __le16 sequence;
245
246 /* command or response/notification data follows immediately */
247 u8 data[0];
248 } __packed;
249
250
251 /**
252 * struct iwl3945_tx_power
253 *
254 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH
255 *
256 * Each entry contains two values:
257 * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
258 * linear value that multiplies the output of the digital signal processor,
259 * before being sent to the analog radio.
260 * 2) Radio gain. This sets the analog gain of the radio Tx path.
261 * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
262 *
263 * Driver obtains values from struct iwl3945_tx_power power_gain_table[][].
264 */
265 struct iwl3945_tx_power {
266 u8 tx_gain; /* gain for analog radio */
267 u8 dsp_atten; /* gain for DSP */
268 } __packed;
269
270 /**
271 * struct iwl3945_power_per_rate
272 *
273 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
274 */
275 struct iwl3945_power_per_rate {
276 u8 rate; /* plcp */
277 struct iwl3945_tx_power tpc;
278 u8 reserved;
279 } __packed;
280
281 /**
282 * iwlagn rate_n_flags bit fields
283 *
284 * rate_n_flags format is used in following iwlagn commands:
285 * REPLY_RX (response only)
286 * REPLY_RX_MPDU (response only)
287 * REPLY_TX (both command and response)
288 * REPLY_TX_LINK_QUALITY_CMD
289 *
290 * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
291 * 2-0: 0) 6 Mbps
292 * 1) 12 Mbps
293 * 2) 18 Mbps
294 * 3) 24 Mbps
295 * 4) 36 Mbps
296 * 5) 48 Mbps
297 * 6) 54 Mbps
298 * 7) 60 Mbps
299 *
300 * 4-3: 0) Single stream (SISO)
301 * 1) Dual stream (MIMO)
302 * 2) Triple stream (MIMO)
303 *
304 * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
305 *
306 * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
307 * 3-0: 0xD) 6 Mbps
308 * 0xF) 9 Mbps
309 * 0x5) 12 Mbps
310 * 0x7) 18 Mbps
311 * 0x9) 24 Mbps
312 * 0xB) 36 Mbps
313 * 0x1) 48 Mbps
314 * 0x3) 54 Mbps
315 *
316 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
317 * 6-0: 10) 1 Mbps
318 * 20) 2 Mbps
319 * 55) 5.5 Mbps
320 * 110) 11 Mbps
321 */
322 #define RATE_MCS_CODE_MSK 0x7
323 #define RATE_MCS_SPATIAL_POS 3
324 #define RATE_MCS_SPATIAL_MSK 0x18
325 #define RATE_MCS_HT_DUP_POS 5
326 #define RATE_MCS_HT_DUP_MSK 0x20
327
328 /* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
329 #define RATE_MCS_FLAGS_POS 8
330 #define RATE_MCS_HT_POS 8
331 #define RATE_MCS_HT_MSK 0x100
332
333 /* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */
334 #define RATE_MCS_CCK_POS 9
335 #define RATE_MCS_CCK_MSK 0x200
336
337 /* Bit 10: (1) Use Green Field preamble */
338 #define RATE_MCS_GF_POS 10
339 #define RATE_MCS_GF_MSK 0x400
340
341 /* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */
342 #define RATE_MCS_HT40_POS 11
343 #define RATE_MCS_HT40_MSK 0x800
344
345 /* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */
346 #define RATE_MCS_DUP_POS 12
347 #define RATE_MCS_DUP_MSK 0x1000
348
349 /* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
350 #define RATE_MCS_SGI_POS 13
351 #define RATE_MCS_SGI_MSK 0x2000
352
353 /**
354 * rate_n_flags Tx antenna masks
355 * 4965 has 2 transmitters
356 * 5100 has 1 transmitter B
357 * 5150 has 1 transmitter A
358 * 5300 has 3 transmitters
359 * 5350 has 3 transmitters
360 * bit14:16
361 */
362 #define RATE_MCS_ANT_POS 14
363 #define RATE_MCS_ANT_A_MSK 0x04000
364 #define RATE_MCS_ANT_B_MSK 0x08000
365 #define RATE_MCS_ANT_C_MSK 0x10000
366 #define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK)
367 #define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK)
368 #define RATE_ANT_NUM 3
369
370 #define POWER_TABLE_NUM_ENTRIES 33
371 #define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
372 #define POWER_TABLE_CCK_ENTRY 32
373
374 #define IWL_PWR_NUM_HT_OFDM_ENTRIES 24
375 #define IWL_PWR_CCK_ENTRIES 2
376
377 /**
378 * union iwl4965_tx_power_dual_stream
379 *
380 * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
381 * Use __le32 version (struct tx_power_dual_stream) when building command.
382 *
383 * Driver provides radio gain and DSP attenuation settings to device in pairs,
384 * one value for each transmitter chain. The first value is for transmitter A,
385 * second for transmitter B.
386 *
387 * For SISO bit rates, both values in a pair should be identical.
388 * For MIMO rates, one value may be different from the other,
389 * in order to balance the Tx output between the two transmitters.
390 *
391 * See more details in doc for TXPOWER in iwl-4965-hw.h.
392 */
393 union iwl4965_tx_power_dual_stream {
394 struct {
395 u8 radio_tx_gain[2];
396 u8 dsp_predis_atten[2];
397 } s;
398 u32 dw;
399 };
400
401 /**
402 * struct tx_power_dual_stream
403 *
404 * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
405 *
406 * Same format as iwl_tx_power_dual_stream, but __le32
407 */
408 struct tx_power_dual_stream {
409 __le32 dw;
410 } __packed;
411
412 /**
413 * struct iwl4965_tx_power_db
414 *
415 * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
416 */
417 struct iwl4965_tx_power_db {
418 struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
419 } __packed;
420
421 /**
422 * Command REPLY_TX_POWER_DBM_CMD = 0x98
423 * struct iwl5000_tx_power_dbm_cmd
424 */
425 #define IWL50_TX_POWER_AUTO 0x7f
426 #define IWL50_TX_POWER_NO_CLOSED (0x1 << 6)
427
428 struct iwl5000_tx_power_dbm_cmd {
429 s8 global_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
430 u8 flags;
431 s8 srv_chan_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
432 u8 reserved;
433 } __packed;
434
435 /**
436 * Command TX_ANT_CONFIGURATION_CMD = 0x98
437 * This command is used to configure valid Tx antenna.
438 * By default uCode concludes the valid antenna according to the radio flavor.
439 * This command enables the driver to override/modify this conclusion.
440 */
441 struct iwl_tx_ant_config_cmd {
442 __le32 valid;
443 } __packed;
444
445 /******************************************************************************
446 * (0a)
447 * Alive and Error Commands & Responses:
448 *
449 *****************************************************************************/
450
451 #define UCODE_VALID_OK cpu_to_le32(0x1)
452 #define INITIALIZE_SUBTYPE (9)
453
454 /*
455 * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command)
456 *
457 * uCode issues this "initialize alive" notification once the initialization
458 * uCode image has completed its work, and is ready to load the runtime image.
459 * This is the *first* "alive" notification that the driver will receive after
460 * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
461 *
462 * See comments documenting "BSM" (bootstrap state machine).
463 *
464 * For 4965, this notification contains important calibration data for
465 * calculating txpower settings:
466 *
467 * 1) Power supply voltage indication. The voltage sensor outputs higher
468 * values for lower voltage, and vice verse.
469 *
470 * 2) Temperature measurement parameters, for each of two channel widths
471 * (20 MHz and 40 MHz) supported by the radios. Temperature sensing
472 * is done via one of the receiver chains, and channel width influences
473 * the results.
474 *
475 * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation,
476 * for each of 5 frequency ranges.
477 */
478 struct iwl_init_alive_resp {
479 u8 ucode_minor;
480 u8 ucode_major;
481 __le16 reserved1;
482 u8 sw_rev[8];
483 u8 ver_type;
484 u8 ver_subtype; /* "9" for initialize alive */
485 __le16 reserved2;
486 __le32 log_event_table_ptr;
487 __le32 error_event_table_ptr;
488 __le32 timestamp;
489 __le32 is_valid;
490
491 /* calibration values from "initialize" uCode */
492 __le32 voltage; /* signed, higher value is lower voltage */
493 __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for HT40 */
494 __le32 therm_r2[2]; /* signed */
495 __le32 therm_r3[2]; /* signed */
496 __le32 therm_r4[2]; /* signed */
497 __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups,
498 * 2 Tx chains */
499 } __packed;
500
501
502 /**
503 * REPLY_ALIVE = 0x1 (response only, not a command)
504 *
505 * uCode issues this "alive" notification once the runtime image is ready
506 * to receive commands from the driver. This is the *second* "alive"
507 * notification that the driver will receive after rebooting uCode;
508 * this "alive" is indicated by subtype field != 9.
509 *
510 * See comments documenting "BSM" (bootstrap state machine).
511 *
512 * This response includes two pointers to structures within the device's
513 * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
514 *
515 * 1) log_event_table_ptr indicates base of the event log. This traces
516 * a 256-entry history of uCode execution within a circular buffer.
517 * Its header format is:
518 *
519 * __le32 log_size; log capacity (in number of entries)
520 * __le32 type; (1) timestamp with each entry, (0) no timestamp
521 * __le32 wraps; # times uCode has wrapped to top of circular buffer
522 * __le32 write_index; next circular buffer entry that uCode would fill
523 *
524 * The header is followed by the circular buffer of log entries. Entries
525 * with timestamps have the following format:
526 *
527 * __le32 event_id; range 0 - 1500
528 * __le32 timestamp; low 32 bits of TSF (of network, if associated)
529 * __le32 data; event_id-specific data value
530 *
531 * Entries without timestamps contain only event_id and data.
532 *
533 *
534 * 2) error_event_table_ptr indicates base of the error log. This contains
535 * information about any uCode error that occurs. For agn, the format
536 * of the error log is:
537 *
538 * __le32 valid; (nonzero) valid, (0) log is empty
539 * __le32 error_id; type of error
540 * __le32 pc; program counter
541 * __le32 blink1; branch link
542 * __le32 blink2; branch link
543 * __le32 ilink1; interrupt link
544 * __le32 ilink2; interrupt link
545 * __le32 data1; error-specific data
546 * __le32 data2; error-specific data
547 * __le32 line; source code line of error
548 * __le32 bcon_time; beacon timer
549 * __le32 tsf_low; network timestamp function timer
550 * __le32 tsf_hi; network timestamp function timer
551 * __le32 gp1; GP1 timer register
552 * __le32 gp2; GP2 timer register
553 * __le32 gp3; GP3 timer register
554 * __le32 ucode_ver; uCode version
555 * __le32 hw_ver; HW Silicon version
556 * __le32 brd_ver; HW board version
557 * __le32 log_pc; log program counter
558 * __le32 frame_ptr; frame pointer
559 * __le32 stack_ptr; stack pointer
560 * __le32 hcmd; last host command
561 * __le32 isr0; isr status register LMPM_NIC_ISR0: rxtx_flag
562 * __le32 isr1; isr status register LMPM_NIC_ISR1: host_flag
563 * __le32 isr2; isr status register LMPM_NIC_ISR2: enc_flag
564 * __le32 isr3; isr status register LMPM_NIC_ISR3: time_flag
565 * __le32 isr4; isr status register LMPM_NIC_ISR4: wico interrupt
566 * __le32 isr_pref; isr status register LMPM_NIC_PREF_STAT
567 * __le32 wait_event; wait event() caller address
568 * __le32 l2p_control; L2pControlField
569 * __le32 l2p_duration; L2pDurationField
570 * __le32 l2p_mhvalid; L2pMhValidBits
571 * __le32 l2p_addr_match; L2pAddrMatchStat
572 * __le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL)
573 * __le32 u_timestamp; indicate when the date and time of the compilation
574 * __le32 reserved;
575 *
576 * The Linux driver can print both logs to the system log when a uCode error
577 * occurs.
578 */
579 struct iwl_alive_resp {
580 u8 ucode_minor;
581 u8 ucode_major;
582 __le16 reserved1;
583 u8 sw_rev[8];
584 u8 ver_type;
585 u8 ver_subtype; /* not "9" for runtime alive */
586 __le16 reserved2;
587 __le32 log_event_table_ptr; /* SRAM address for event log */
588 __le32 error_event_table_ptr; /* SRAM address for error log */
589 __le32 timestamp;
590 __le32 is_valid;
591 } __packed;
592
593 /*
594 * REPLY_ERROR = 0x2 (response only, not a command)
595 */
596 struct iwl_error_resp {
597 __le32 error_type;
598 u8 cmd_id;
599 u8 reserved1;
600 __le16 bad_cmd_seq_num;
601 __le32 error_info;
602 __le64 timestamp;
603 } __packed;
604
605 /******************************************************************************
606 * (1)
607 * RXON Commands & Responses:
608 *
609 *****************************************************************************/
610
611 /*
612 * Rx config defines & structure
613 */
614 /* rx_config device types */
615 enum {
616 RXON_DEV_TYPE_AP = 1,
617 RXON_DEV_TYPE_ESS = 3,
618 RXON_DEV_TYPE_IBSS = 4,
619 RXON_DEV_TYPE_SNIFFER = 6,
620 RXON_DEV_TYPE_CP = 7,
621 RXON_DEV_TYPE_2STA = 8,
622 RXON_DEV_TYPE_P2P = 9,
623 };
624
625
626 #define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0)
627 #define RXON_RX_CHAIN_DRIVER_FORCE_POS (0)
628 #define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1)
629 #define RXON_RX_CHAIN_VALID_POS (1)
630 #define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4)
631 #define RXON_RX_CHAIN_FORCE_SEL_POS (4)
632 #define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7)
633 #define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
634 #define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10)
635 #define RXON_RX_CHAIN_CNT_POS (10)
636 #define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12)
637 #define RXON_RX_CHAIN_MIMO_CNT_POS (12)
638 #define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14)
639 #define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
640
641 /* rx_config flags */
642 /* band & modulation selection */
643 #define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0)
644 #define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1)
645 /* auto detection enable */
646 #define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2)
647 /* TGg protection when tx */
648 #define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3)
649 /* cck short slot & preamble */
650 #define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4)
651 #define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5)
652 /* antenna selection */
653 #define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7)
654 #define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00)
655 #define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
656 #define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
657 /* radar detection enable */
658 #define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12)
659 #define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13)
660 /* rx response to host with 8-byte TSF
661 * (according to ON_AIR deassertion) */
662 #define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15)
663
664
665 /* HT flags */
666 #define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
667 #define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22)
668
669 #define RXON_FLG_HT_OPERATING_MODE_POS (23)
670
671 #define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23)
672 #define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23)
673
674 #define RXON_FLG_CHANNEL_MODE_POS (25)
675 #define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25)
676
677 /* channel mode */
678 enum {
679 CHANNEL_MODE_LEGACY = 0,
680 CHANNEL_MODE_PURE_40 = 1,
681 CHANNEL_MODE_MIXED = 2,
682 CHANNEL_MODE_RESERVED = 3,
683 };
684 #define RXON_FLG_CHANNEL_MODE_LEGACY cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
685 #define RXON_FLG_CHANNEL_MODE_PURE_40 cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
686 #define RXON_FLG_CHANNEL_MODE_MIXED cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
687
688 /* CTS to self (if spec allows) flag */
689 #define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30)
690
691 /* rx_config filter flags */
692 /* accept all data frames */
693 #define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0)
694 /* pass control & management to host */
695 #define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1)
696 /* accept multi-cast */
697 #define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2)
698 /* don't decrypt uni-cast frames */
699 #define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3)
700 /* don't decrypt multi-cast frames */
701 #define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
702 /* STA is associated */
703 #define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5)
704 /* transfer to host non bssid beacons in associated state */
705 #define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6)
706
707 /**
708 * REPLY_RXON = 0x10 (command, has simple generic response)
709 *
710 * RXON tunes the radio tuner to a service channel, and sets up a number
711 * of parameters that are used primarily for Rx, but also for Tx operations.
712 *
713 * NOTE: When tuning to a new channel, driver must set the
714 * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent
715 * info within the device, including the station tables, tx retry
716 * rate tables, and txpower tables. Driver must build a new station
717 * table and txpower table before transmitting anything on the RXON
718 * channel.
719 *
720 * NOTE: All RXONs wipe clean the internal txpower table. Driver must
721 * issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
722 * regardless of whether RXON_FILTER_ASSOC_MSK is set.
723 */
724
725 struct iwl3945_rxon_cmd {
726 u8 node_addr[6];
727 __le16 reserved1;
728 u8 bssid_addr[6];
729 __le16 reserved2;
730 u8 wlap_bssid_addr[6];
731 __le16 reserved3;
732 u8 dev_type;
733 u8 air_propagation;
734 __le16 reserved4;
735 u8 ofdm_basic_rates;
736 u8 cck_basic_rates;
737 __le16 assoc_id;
738 __le32 flags;
739 __le32 filter_flags;
740 __le16 channel;
741 __le16 reserved5;
742 } __packed;
743
744 struct iwl4965_rxon_cmd {
745 u8 node_addr[6];
746 __le16 reserved1;
747 u8 bssid_addr[6];
748 __le16 reserved2;
749 u8 wlap_bssid_addr[6];
750 __le16 reserved3;
751 u8 dev_type;
752 u8 air_propagation;
753 __le16 rx_chain;
754 u8 ofdm_basic_rates;
755 u8 cck_basic_rates;
756 __le16 assoc_id;
757 __le32 flags;
758 __le32 filter_flags;
759 __le16 channel;
760 u8 ofdm_ht_single_stream_basic_rates;
761 u8 ofdm_ht_dual_stream_basic_rates;
762 } __packed;
763
764 /* 5000 HW just extend this command */
765 struct iwl_rxon_cmd {
766 u8 node_addr[6];
767 __le16 reserved1;
768 u8 bssid_addr[6];
769 __le16 reserved2;
770 u8 wlap_bssid_addr[6];
771 __le16 reserved3;
772 u8 dev_type;
773 u8 air_propagation;
774 __le16 rx_chain;
775 u8 ofdm_basic_rates;
776 u8 cck_basic_rates;
777 __le16 assoc_id;
778 __le32 flags;
779 __le32 filter_flags;
780 __le16 channel;
781 u8 ofdm_ht_single_stream_basic_rates;
782 u8 ofdm_ht_dual_stream_basic_rates;
783 u8 ofdm_ht_triple_stream_basic_rates;
784 u8 reserved5;
785 __le16 acquisition_data;
786 __le16 reserved6;
787 } __packed;
788
789 /*
790 * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
791 */
792 struct iwl3945_rxon_assoc_cmd {
793 __le32 flags;
794 __le32 filter_flags;
795 u8 ofdm_basic_rates;
796 u8 cck_basic_rates;
797 __le16 reserved;
798 } __packed;
799
800 struct iwl4965_rxon_assoc_cmd {
801 __le32 flags;
802 __le32 filter_flags;
803 u8 ofdm_basic_rates;
804 u8 cck_basic_rates;
805 u8 ofdm_ht_single_stream_basic_rates;
806 u8 ofdm_ht_dual_stream_basic_rates;
807 __le16 rx_chain_select_flags;
808 __le16 reserved;
809 } __packed;
810
811 struct iwl5000_rxon_assoc_cmd {
812 __le32 flags;
813 __le32 filter_flags;
814 u8 ofdm_basic_rates;
815 u8 cck_basic_rates;
816 __le16 reserved1;
817 u8 ofdm_ht_single_stream_basic_rates;
818 u8 ofdm_ht_dual_stream_basic_rates;
819 u8 ofdm_ht_triple_stream_basic_rates;
820 u8 reserved2;
821 __le16 rx_chain_select_flags;
822 __le16 acquisition_data;
823 __le32 reserved3;
824 } __packed;
825
826 #define IWL_CONN_MAX_LISTEN_INTERVAL 10
827 #define IWL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */
828 #define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */
829
830 /*
831 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
832 */
833 struct iwl_rxon_time_cmd {
834 __le64 timestamp;
835 __le16 beacon_interval;
836 __le16 atim_window;
837 __le32 beacon_init_val;
838 __le16 listen_interval;
839 u8 dtim_period;
840 u8 delta_cp_bss_tbtts;
841 } __packed;
842
843 /*
844 * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
845 */
846 struct iwl3945_channel_switch_cmd {
847 u8 band;
848 u8 expect_beacon;
849 __le16 channel;
850 __le32 rxon_flags;
851 __le32 rxon_filter_flags;
852 __le32 switch_time;
853 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
854 } __packed;
855
856 struct iwl4965_channel_switch_cmd {
857 u8 band;
858 u8 expect_beacon;
859 __le16 channel;
860 __le32 rxon_flags;
861 __le32 rxon_filter_flags;
862 __le32 switch_time;
863 struct iwl4965_tx_power_db tx_power;
864 } __packed;
865
866 /**
867 * struct iwl5000_channel_switch_cmd
868 * @band: 0- 5.2GHz, 1- 2.4GHz
869 * @expect_beacon: 0- resume transmits after channel switch
870 * 1- wait for beacon to resume transmits
871 * @channel: new channel number
872 * @rxon_flags: Rx on flags
873 * @rxon_filter_flags: filtering parameters
874 * @switch_time: switch time in extended beacon format
875 * @reserved: reserved bytes
876 */
877 struct iwl5000_channel_switch_cmd {
878 u8 band;
879 u8 expect_beacon;
880 __le16 channel;
881 __le32 rxon_flags;
882 __le32 rxon_filter_flags;
883 __le32 switch_time;
884 __le32 reserved[2][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
885 } __packed;
886
887 /**
888 * struct iwl6000_channel_switch_cmd
889 * @band: 0- 5.2GHz, 1- 2.4GHz
890 * @expect_beacon: 0- resume transmits after channel switch
891 * 1- wait for beacon to resume transmits
892 * @channel: new channel number
893 * @rxon_flags: Rx on flags
894 * @rxon_filter_flags: filtering parameters
895 * @switch_time: switch time in extended beacon format
896 * @reserved: reserved bytes
897 */
898 struct iwl6000_channel_switch_cmd {
899 u8 band;
900 u8 expect_beacon;
901 __le16 channel;
902 __le32 rxon_flags;
903 __le32 rxon_filter_flags;
904 __le32 switch_time;
905 __le32 reserved[3][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
906 } __packed;
907
908 /*
909 * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
910 */
911 struct iwl_csa_notification {
912 __le16 band;
913 __le16 channel;
914 __le32 status; /* 0 - OK, 1 - fail */
915 } __packed;
916
917 /******************************************************************************
918 * (2)
919 * Quality-of-Service (QOS) Commands & Responses:
920 *
921 *****************************************************************************/
922
923 /**
924 * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
925 * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
926 *
927 * @cw_min: Contention window, start value in numbers of slots.
928 * Should be a power-of-2, minus 1. Device's default is 0x0f.
929 * @cw_max: Contention window, max value in numbers of slots.
930 * Should be a power-of-2, minus 1. Device's default is 0x3f.
931 * @aifsn: Number of slots in Arbitration Interframe Space (before
932 * performing random backoff timing prior to Tx). Device default 1.
933 * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
934 *
935 * Device will automatically increase contention window by (2*CW) + 1 for each
936 * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
937 * value, to cap the CW value.
938 */
939 struct iwl_ac_qos {
940 __le16 cw_min;
941 __le16 cw_max;
942 u8 aifsn;
943 u8 reserved1;
944 __le16 edca_txop;
945 } __packed;
946
947 /* QoS flags defines */
948 #define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01)
949 #define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02)
950 #define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10)
951
952 /* Number of Access Categories (AC) (EDCA), queues 0..3 */
953 #define AC_NUM 4
954
955 /*
956 * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
957 *
958 * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
959 * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
960 */
961 struct iwl_qosparam_cmd {
962 __le32 qos_flags;
963 struct iwl_ac_qos ac[AC_NUM];
964 } __packed;
965
966 /******************************************************************************
967 * (3)
968 * Add/Modify Stations Commands & Responses:
969 *
970 *****************************************************************************/
971 /*
972 * Multi station support
973 */
974
975 /* Special, dedicated locations within device's station table */
976 #define IWL_AP_ID 0
977 #define IWL_AP_ID_PAN 1
978 #define IWL_STA_ID 2
979 #define IWL3945_BROADCAST_ID 24
980 #define IWL3945_STATION_COUNT 25
981 #define IWL4965_BROADCAST_ID 31
982 #define IWL4965_STATION_COUNT 32
983 #define IWLAGN_PAN_BCAST_ID 14
984 #define IWLAGN_BROADCAST_ID 15
985 #define IWLAGN_STATION_COUNT 16
986
987 #define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
988 #define IWL_INVALID_STATION 255
989
990 #define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2)
991 #define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8)
992 #define STA_FLG_PAN_STATION cpu_to_le32(1 << 13)
993 #define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17)
994 #define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18)
995 #define STA_FLG_MAX_AGG_SIZE_POS (19)
996 #define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19)
997 #define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21)
998 #define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22)
999 #define STA_FLG_AGG_MPDU_DENSITY_POS (23)
1000 #define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23)
1001
1002 /* Use in mode field. 1: modify existing entry, 0: add new station entry */
1003 #define STA_CONTROL_MODIFY_MSK 0x01
1004
1005 /* key flags __le16*/
1006 #define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007)
1007 #define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000)
1008 #define STA_KEY_FLG_WEP cpu_to_le16(0x0001)
1009 #define STA_KEY_FLG_CCMP cpu_to_le16(0x0002)
1010 #define STA_KEY_FLG_TKIP cpu_to_le16(0x0003)
1011
1012 #define STA_KEY_FLG_KEYID_POS 8
1013 #define STA_KEY_FLG_INVALID cpu_to_le16(0x0800)
1014 /* wep key is either from global key (0) or from station info array (1) */
1015 #define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008)
1016
1017 /* wep key in STA: 5-bytes (0) or 13-bytes (1) */
1018 #define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000)
1019 #define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
1020 #define STA_KEY_MAX_NUM 8
1021 #define STA_KEY_MAX_NUM_PAN 16
1022
1023 /* Flags indicate whether to modify vs. don't change various station params */
1024 #define STA_MODIFY_KEY_MASK 0x01
1025 #define STA_MODIFY_TID_DISABLE_TX 0x02
1026 #define STA_MODIFY_TX_RATE_MSK 0x04
1027 #define STA_MODIFY_ADDBA_TID_MSK 0x08
1028 #define STA_MODIFY_DELBA_TID_MSK 0x10
1029 #define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20
1030
1031 /* Receiver address (actually, Rx station's index into station table),
1032 * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
1033 #define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid))
1034
1035 struct iwl4965_keyinfo {
1036 __le16 key_flags;
1037 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
1038 u8 reserved1;
1039 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
1040 u8 key_offset;
1041 u8 reserved2;
1042 u8 key[16]; /* 16-byte unicast decryption key */
1043 } __packed;
1044
1045 /* 5000 */
1046 struct iwl_keyinfo {
1047 __le16 key_flags;
1048 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
1049 u8 reserved1;
1050 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
1051 u8 key_offset;
1052 u8 reserved2;
1053 u8 key[16]; /* 16-byte unicast decryption key */
1054 __le64 tx_secur_seq_cnt;
1055 __le64 hw_tkip_mic_rx_key;
1056 __le64 hw_tkip_mic_tx_key;
1057 } __packed;
1058
1059 /**
1060 * struct sta_id_modify
1061 * @addr[ETH_ALEN]: station's MAC address
1062 * @sta_id: index of station in uCode's station table
1063 * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
1064 *
1065 * Driver selects unused table index when adding new station,
1066 * or the index to a pre-existing station entry when modifying that station.
1067 * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
1068 *
1069 * modify_mask flags select which parameters to modify vs. leave alone.
1070 */
1071 struct sta_id_modify {
1072 u8 addr[ETH_ALEN];
1073 __le16 reserved1;
1074 u8 sta_id;
1075 u8 modify_mask;
1076 __le16 reserved2;
1077 } __packed;
1078
1079 /*
1080 * REPLY_ADD_STA = 0x18 (command)
1081 *
1082 * The device contains an internal table of per-station information,
1083 * with info on security keys, aggregation parameters, and Tx rates for
1084 * initial Tx attempt and any retries (agn devices uses
1085 * REPLY_TX_LINK_QUALITY_CMD,
1086 * 3945 uses REPLY_RATE_SCALE to set up rate tables).
1087 *
1088 * REPLY_ADD_STA sets up the table entry for one station, either creating
1089 * a new entry, or modifying a pre-existing one.
1090 *
1091 * NOTE: RXON command (without "associated" bit set) wipes the station table
1092 * clean. Moving into RF_KILL state does this also. Driver must set up
1093 * new station table before transmitting anything on the RXON channel
1094 * (except active scans or active measurements; those commands carry
1095 * their own txpower/rate setup data).
1096 *
1097 * When getting started on a new channel, driver must set up the
1098 * IWL_BROADCAST_ID entry (last entry in the table). For a client
1099 * station in a BSS, once an AP is selected, driver sets up the AP STA
1100 * in the IWL_AP_ID entry (1st entry in the table). BROADCAST and AP
1101 * are all that are needed for a BSS client station. If the device is
1102 * used as AP, or in an IBSS network, driver must set up station table
1103 * entries for all STAs in network, starting with index IWL_STA_ID.
1104 */
1105
1106 struct iwl3945_addsta_cmd {
1107 u8 mode; /* 1: modify existing, 0: add new station */
1108 u8 reserved[3];
1109 struct sta_id_modify sta;
1110 struct iwl4965_keyinfo key;
1111 __le32 station_flags; /* STA_FLG_* */
1112 __le32 station_flags_msk; /* STA_FLG_* */
1113
1114 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1115 * corresponding to bit (e.g. bit 5 controls TID 5).
1116 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1117 __le16 tid_disable_tx;
1118
1119 __le16 rate_n_flags;
1120
1121 /* TID for which to add block-ack support.
1122 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1123 u8 add_immediate_ba_tid;
1124
1125 /* TID for which to remove block-ack support.
1126 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1127 u8 remove_immediate_ba_tid;
1128
1129 /* Starting Sequence Number for added block-ack support.
1130 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1131 __le16 add_immediate_ba_ssn;
1132 } __packed;
1133
1134 struct iwl4965_addsta_cmd {
1135 u8 mode; /* 1: modify existing, 0: add new station */
1136 u8 reserved[3];
1137 struct sta_id_modify sta;
1138 struct iwl4965_keyinfo key;
1139 __le32 station_flags; /* STA_FLG_* */
1140 __le32 station_flags_msk; /* STA_FLG_* */
1141
1142 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1143 * corresponding to bit (e.g. bit 5 controls TID 5).
1144 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1145 __le16 tid_disable_tx;
1146
1147 __le16 reserved1;
1148
1149 /* TID for which to add block-ack support.
1150 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1151 u8 add_immediate_ba_tid;
1152
1153 /* TID for which to remove block-ack support.
1154 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1155 u8 remove_immediate_ba_tid;
1156
1157 /* Starting Sequence Number for added block-ack support.
1158 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1159 __le16 add_immediate_ba_ssn;
1160
1161 /*
1162 * Number of packets OK to transmit to station even though
1163 * it is asleep -- used to synchronise PS-poll and u-APSD
1164 * responses while ucode keeps track of STA sleep state.
1165 */
1166 __le16 sleep_tx_count;
1167
1168 __le16 reserved2;
1169 } __packed;
1170
1171 /* 5000 */
1172 struct iwl_addsta_cmd {
1173 u8 mode; /* 1: modify existing, 0: add new station */
1174 u8 reserved[3];
1175 struct sta_id_modify sta;
1176 struct iwl_keyinfo key;
1177 __le32 station_flags; /* STA_FLG_* */
1178 __le32 station_flags_msk; /* STA_FLG_* */
1179
1180 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1181 * corresponding to bit (e.g. bit 5 controls TID 5).
1182 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1183 __le16 tid_disable_tx;
1184
1185 __le16 rate_n_flags; /* 3945 only */
1186
1187 /* TID for which to add block-ack support.
1188 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1189 u8 add_immediate_ba_tid;
1190
1191 /* TID for which to remove block-ack support.
1192 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1193 u8 remove_immediate_ba_tid;
1194
1195 /* Starting Sequence Number for added block-ack support.
1196 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1197 __le16 add_immediate_ba_ssn;
1198
1199 /*
1200 * Number of packets OK to transmit to station even though
1201 * it is asleep -- used to synchronise PS-poll and u-APSD
1202 * responses while ucode keeps track of STA sleep state.
1203 */
1204 __le16 sleep_tx_count;
1205
1206 __le16 reserved2;
1207 } __packed;
1208
1209
1210 #define ADD_STA_SUCCESS_MSK 0x1
1211 #define ADD_STA_NO_ROOM_IN_TABLE 0x2
1212 #define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4
1213 #define ADD_STA_MODIFY_NON_EXIST_STA 0x8
1214 /*
1215 * REPLY_ADD_STA = 0x18 (response)
1216 */
1217 struct iwl_add_sta_resp {
1218 u8 status; /* ADD_STA_* */
1219 } __packed;
1220
1221 #define REM_STA_SUCCESS_MSK 0x1
1222 /*
1223 * REPLY_REM_STA = 0x19 (response)
1224 */
1225 struct iwl_rem_sta_resp {
1226 u8 status;
1227 } __packed;
1228
1229 /*
1230 * REPLY_REM_STA = 0x19 (command)
1231 */
1232 struct iwl_rem_sta_cmd {
1233 u8 num_sta; /* number of removed stations */
1234 u8 reserved[3];
1235 u8 addr[ETH_ALEN]; /* MAC addr of the first station */
1236 u8 reserved2[2];
1237 } __packed;
1238
1239 #define IWL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0))
1240 #define IWL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1))
1241 #define IWL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2))
1242 #define IWL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3))
1243 #define IWL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00)
1244
1245 #define IWL_DROP_SINGLE 0
1246 #define IWL_DROP_SELECTED 1
1247 #define IWL_DROP_ALL 2
1248
1249 /*
1250 * REPLY_TXFIFO_FLUSH = 0x1e(command and response)
1251 *
1252 * When using full FIFO flush this command checks the scheduler HW block WR/RD
1253 * pointers to check if all the frames were transferred by DMA into the
1254 * relevant TX FIFO queue. Only when the DMA is finished and the queue is
1255 * empty the command can finish.
1256 * This command is used to flush the TXFIFO from transmit commands, it may
1257 * operate on single or multiple queues, the command queue can't be flushed by
1258 * this command. The command response is returned when all the queue flush
1259 * operations are done. Each TX command flushed return response with the FLUSH
1260 * status set in the TX response status. When FIFO flush operation is used,
1261 * the flush operation ends when both the scheduler DMA done and TXFIFO empty
1262 * are set.
1263 *
1264 * @fifo_control: bit mask for which queues to flush
1265 * @flush_control: flush controls
1266 * 0: Dump single MSDU
1267 * 1: Dump multiple MSDU according to PS, INVALID STA, TTL, TID disable.
1268 * 2: Dump all FIFO
1269 */
1270 struct iwl_txfifo_flush_cmd {
1271 __le32 fifo_control;
1272 __le16 flush_control;
1273 __le16 reserved;
1274 } __packed;
1275
1276 /*
1277 * REPLY_WEP_KEY = 0x20
1278 */
1279 struct iwl_wep_key {
1280 u8 key_index;
1281 u8 key_offset;
1282 u8 reserved1[2];
1283 u8 key_size;
1284 u8 reserved2[3];
1285 u8 key[16];
1286 } __packed;
1287
1288 struct iwl_wep_cmd {
1289 u8 num_keys;
1290 u8 global_key_type;
1291 u8 flags;
1292 u8 reserved;
1293 struct iwl_wep_key key[0];
1294 } __packed;
1295
1296 #define WEP_KEY_WEP_TYPE 1
1297 #define WEP_KEYS_MAX 4
1298 #define WEP_INVALID_OFFSET 0xff
1299 #define WEP_KEY_LEN_64 5
1300 #define WEP_KEY_LEN_128 13
1301
1302 /******************************************************************************
1303 * (4)
1304 * Rx Responses:
1305 *
1306 *****************************************************************************/
1307
1308 #define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0)
1309 #define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1)
1310
1311 #define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0)
1312 #define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1)
1313 #define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2)
1314 #define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3)
1315 #define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0
1316 #define RX_RES_PHY_FLAGS_ANTENNA_POS 4
1317
1318 #define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
1319 #define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
1320 #define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
1321 #define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
1322 #define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
1323 #define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8)
1324
1325 #define RX_RES_STATUS_STATION_FOUND (1<<6)
1326 #define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7)
1327
1328 #define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
1329 #define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
1330 #define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
1331 #define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
1332 #define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
1333
1334 #define RX_MPDU_RES_STATUS_ICV_OK (0x20)
1335 #define RX_MPDU_RES_STATUS_MIC_OK (0x40)
1336 #define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7)
1337 #define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800)
1338
1339
1340 struct iwl3945_rx_frame_stats {
1341 u8 phy_count;
1342 u8 id;
1343 u8 rssi;
1344 u8 agc;
1345 __le16 sig_avg;
1346 __le16 noise_diff;
1347 u8 payload[0];
1348 } __packed;
1349
1350 struct iwl3945_rx_frame_hdr {
1351 __le16 channel;
1352 __le16 phy_flags;
1353 u8 reserved1;
1354 u8 rate;
1355 __le16 len;
1356 u8 payload[0];
1357 } __packed;
1358
1359 struct iwl3945_rx_frame_end {
1360 __le32 status;
1361 __le64 timestamp;
1362 __le32 beacon_timestamp;
1363 } __packed;
1364
1365 /*
1366 * REPLY_3945_RX = 0x1b (response only, not a command)
1367 *
1368 * NOTE: DO NOT dereference from casts to this structure
1369 * It is provided only for calculating minimum data set size.
1370 * The actual offsets of the hdr and end are dynamic based on
1371 * stats.phy_count
1372 */
1373 struct iwl3945_rx_frame {
1374 struct iwl3945_rx_frame_stats stats;
1375 struct iwl3945_rx_frame_hdr hdr;
1376 struct iwl3945_rx_frame_end end;
1377 } __packed;
1378
1379 #define IWL39_RX_FRAME_SIZE (4 + sizeof(struct iwl3945_rx_frame))
1380
1381 /* Fixed (non-configurable) rx data from phy */
1382
1383 #define IWL49_RX_RES_PHY_CNT 14
1384 #define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
1385 #define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
1386 #define IWL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
1387 #define IWL49_AGC_DB_POS (7)
1388 struct iwl4965_rx_non_cfg_phy {
1389 __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
1390 __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
1391 u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
1392 u8 pad[0];
1393 } __packed;
1394
1395
1396 #define IWLAGN_RX_RES_PHY_CNT 8
1397 #define IWLAGN_RX_RES_AGC_IDX 1
1398 #define IWLAGN_RX_RES_RSSI_AB_IDX 2
1399 #define IWLAGN_RX_RES_RSSI_C_IDX 3
1400 #define IWLAGN_OFDM_AGC_MSK 0xfe00
1401 #define IWLAGN_OFDM_AGC_BIT_POS 9
1402 #define IWLAGN_OFDM_RSSI_INBAND_A_BITMSK 0x00ff
1403 #define IWLAGN_OFDM_RSSI_ALLBAND_A_BITMSK 0xff00
1404 #define IWLAGN_OFDM_RSSI_A_BIT_POS 0
1405 #define IWLAGN_OFDM_RSSI_INBAND_B_BITMSK 0xff0000
1406 #define IWLAGN_OFDM_RSSI_ALLBAND_B_BITMSK 0xff000000
1407 #define IWLAGN_OFDM_RSSI_B_BIT_POS 16
1408 #define IWLAGN_OFDM_RSSI_INBAND_C_BITMSK 0x00ff
1409 #define IWLAGN_OFDM_RSSI_ALLBAND_C_BITMSK 0xff00
1410 #define IWLAGN_OFDM_RSSI_C_BIT_POS 0
1411
1412 struct iwlagn_non_cfg_phy {
1413 __le32 non_cfg_phy[IWLAGN_RX_RES_PHY_CNT]; /* up to 8 phy entries */
1414 } __packed;
1415
1416
1417 /*
1418 * REPLY_RX = 0xc3 (response only, not a command)
1419 * Used only for legacy (non 11n) frames.
1420 */
1421 struct iwl_rx_phy_res {
1422 u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
1423 u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
1424 u8 stat_id; /* configurable DSP phy data set ID */
1425 u8 reserved1;
1426 __le64 timestamp; /* TSF at on air rise */
1427 __le32 beacon_time_stamp; /* beacon at on-air rise */
1428 __le16 phy_flags; /* general phy flags: band, modulation, ... */
1429 __le16 channel; /* channel number */
1430 u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
1431 __le32 rate_n_flags; /* RATE_MCS_* */
1432 __le16 byte_count; /* frame's byte-count */
1433 __le16 frame_time; /* frame's time on the air */
1434 } __packed;
1435
1436 struct iwl_rx_mpdu_res_start {
1437 __le16 byte_count;
1438 __le16 reserved;
1439 } __packed;
1440
1441
1442 /******************************************************************************
1443 * (5)
1444 * Tx Commands & Responses:
1445 *
1446 * Driver must place each REPLY_TX command into one of the prioritized Tx
1447 * queues in host DRAM, shared between driver and device (see comments for
1448 * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode
1449 * are preparing to transmit, the device pulls the Tx command over the PCI
1450 * bus via one of the device's Tx DMA channels, to fill an internal FIFO
1451 * from which data will be transmitted.
1452 *
1453 * uCode handles all timing and protocol related to control frames
1454 * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler
1455 * handle reception of block-acks; uCode updates the host driver via
1456 * REPLY_COMPRESSED_BA.
1457 *
1458 * uCode handles retrying Tx when an ACK is expected but not received.
1459 * This includes trying lower data rates than the one requested in the Tx
1460 * command, as set up by the REPLY_RATE_SCALE (for 3945) or
1461 * REPLY_TX_LINK_QUALITY_CMD (agn).
1462 *
1463 * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
1464 * This command must be executed after every RXON command, before Tx can occur.
1465 *****************************************************************************/
1466
1467 /* REPLY_TX Tx flags field */
1468
1469 /*
1470 * 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
1471 * before this frame. if CTS-to-self required check
1472 * RXON_FLG_SELF_CTS_EN status.
1473 * unused in 3945/4965, used in 5000 series and after
1474 */
1475 #define TX_CMD_FLG_PROT_REQUIRE_MSK cpu_to_le32(1 << 0)
1476
1477 /*
1478 * 1: Use Request-To-Send protocol before this frame.
1479 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK.
1480 * used in 3945/4965, unused in 5000 series and after
1481 */
1482 #define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
1483
1484 /*
1485 * 1: Transmit Clear-To-Send to self before this frame.
1486 * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
1487 * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK.
1488 * used in 3945/4965, unused in 5000 series and after
1489 */
1490 #define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
1491
1492 /* 1: Expect ACK from receiving station
1493 * 0: Don't expect ACK (MAC header's duration field s/b 0)
1494 * Set this for unicast frames, but not broadcast/multicast. */
1495 #define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
1496
1497 /* For agn devices:
1498 * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
1499 * Tx command's initial_rate_index indicates first rate to try;
1500 * uCode walks through table for additional Tx attempts.
1501 * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
1502 * This rate will be used for all Tx attempts; it will not be scaled. */
1503 #define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
1504
1505 /* 1: Expect immediate block-ack.
1506 * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */
1507 #define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6)
1508
1509 /*
1510 * 1: Frame requires full Tx-Op protection.
1511 * Set this if either RTS or CTS Tx Flag gets set.
1512 * used in 3945/4965, unused in 5000 series and after
1513 */
1514 #define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
1515
1516 /* Tx antenna selection field; used only for 3945, reserved (0) for agn devices.
1517 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
1518 #define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
1519 #define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
1520 #define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
1521
1522 /* 1: Ignore Bluetooth priority for this frame.
1523 * 0: Delay Tx until Bluetooth device is done (normal usage). */
1524 #define TX_CMD_FLG_IGNORE_BT cpu_to_le32(1 << 12)
1525
1526 /* 1: uCode overrides sequence control field in MAC header.
1527 * 0: Driver provides sequence control field in MAC header.
1528 * Set this for management frames, non-QOS data frames, non-unicast frames,
1529 * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
1530 #define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
1531
1532 /* 1: This frame is non-last MPDU; more fragments are coming.
1533 * 0: Last fragment, or not using fragmentation. */
1534 #define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
1535
1536 /* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
1537 * 0: No TSF required in outgoing frame.
1538 * Set this for transmitting beacons and probe responses. */
1539 #define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
1540
1541 /* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
1542 * alignment of frame's payload data field.
1543 * 0: No pad
1544 * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
1545 * field (but not both). Driver must align frame data (i.e. data following
1546 * MAC header) to DWORD boundary. */
1547 #define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
1548
1549 /* accelerate aggregation support
1550 * 0 - no CCMP encryption; 1 - CCMP encryption */
1551 #define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
1552
1553 /* HCCA-AP - disable duration overwriting. */
1554 #define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
1555
1556
1557 /*
1558 * TX command security control
1559 */
1560 #define TX_CMD_SEC_WEP 0x01
1561 #define TX_CMD_SEC_CCM 0x02
1562 #define TX_CMD_SEC_TKIP 0x03
1563 #define TX_CMD_SEC_MSK 0x03
1564 #define TX_CMD_SEC_SHIFT 6
1565 #define TX_CMD_SEC_KEY128 0x08
1566
1567 /*
1568 * security overhead sizes
1569 */
1570 #define WEP_IV_LEN 4
1571 #define WEP_ICV_LEN 4
1572 #define CCMP_MIC_LEN 8
1573 #define TKIP_ICV_LEN 4
1574
1575 /*
1576 * REPLY_TX = 0x1c (command)
1577 */
1578
1579 struct iwl3945_tx_cmd {
1580 /*
1581 * MPDU byte count:
1582 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1583 * + 8 byte IV for CCM or TKIP (not used for WEP)
1584 * + Data payload
1585 * + 8-byte MIC (not used for CCM/WEP)
1586 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1587 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1588 * Range: 14-2342 bytes.
1589 */
1590 __le16 len;
1591
1592 /*
1593 * MPDU or MSDU byte count for next frame.
1594 * Used for fragmentation and bursting, but not 11n aggregation.
1595 * Same as "len", but for next frame. Set to 0 if not applicable.
1596 */
1597 __le16 next_frame_len;
1598
1599 __le32 tx_flags; /* TX_CMD_FLG_* */
1600
1601 u8 rate;
1602
1603 /* Index of recipient station in uCode's station table */
1604 u8 sta_id;
1605 u8 tid_tspec;
1606 u8 sec_ctl;
1607 u8 key[16];
1608 union {
1609 u8 byte[8];
1610 __le16 word[4];
1611 __le32 dw[2];
1612 } tkip_mic;
1613 __le32 next_frame_info;
1614 union {
1615 __le32 life_time;
1616 __le32 attempt;
1617 } stop_time;
1618 u8 supp_rates[2];
1619 u8 rts_retry_limit; /*byte 50 */
1620 u8 data_retry_limit; /*byte 51 */
1621 union {
1622 __le16 pm_frame_timeout;
1623 __le16 attempt_duration;
1624 } timeout;
1625
1626 /*
1627 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1628 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1629 */
1630 __le16 driver_txop;
1631
1632 /*
1633 * MAC header goes here, followed by 2 bytes padding if MAC header
1634 * length is 26 or 30 bytes, followed by payload data
1635 */
1636 u8 payload[0];
1637 struct ieee80211_hdr hdr[0];
1638 } __packed;
1639
1640 /*
1641 * REPLY_TX = 0x1c (response)
1642 */
1643 struct iwl3945_tx_resp {
1644 u8 failure_rts;
1645 u8 failure_frame;
1646 u8 bt_kill_count;
1647 u8 rate;
1648 __le32 wireless_media_time;
1649 __le32 status; /* TX status */
1650 } __packed;
1651
1652
1653 /*
1654 * 4965 uCode updates these Tx attempt count values in host DRAM.
1655 * Used for managing Tx retries when expecting block-acks.
1656 * Driver should set these fields to 0.
1657 */
1658 struct iwl_dram_scratch {
1659 u8 try_cnt; /* Tx attempts */
1660 u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */
1661 __le16 reserved;
1662 } __packed;
1663
1664 struct iwl_tx_cmd {
1665 /*
1666 * MPDU byte count:
1667 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1668 * + 8 byte IV for CCM or TKIP (not used for WEP)
1669 * + Data payload
1670 * + 8-byte MIC (not used for CCM/WEP)
1671 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1672 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1673 * Range: 14-2342 bytes.
1674 */
1675 __le16 len;
1676
1677 /*
1678 * MPDU or MSDU byte count for next frame.
1679 * Used for fragmentation and bursting, but not 11n aggregation.
1680 * Same as "len", but for next frame. Set to 0 if not applicable.
1681 */
1682 __le16 next_frame_len;
1683
1684 __le32 tx_flags; /* TX_CMD_FLG_* */
1685
1686 /* uCode may modify this field of the Tx command (in host DRAM!).
1687 * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
1688 struct iwl_dram_scratch scratch;
1689
1690 /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
1691 __le32 rate_n_flags; /* RATE_MCS_* */
1692
1693 /* Index of destination station in uCode's station table */
1694 u8 sta_id;
1695
1696 /* Type of security encryption: CCM or TKIP */
1697 u8 sec_ctl; /* TX_CMD_SEC_* */
1698
1699 /*
1700 * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
1701 * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for
1702 * data frames, this field may be used to selectively reduce initial
1703 * rate (via non-0 value) for special frames (e.g. management), while
1704 * still supporting rate scaling for all frames.
1705 */
1706 u8 initial_rate_index;
1707 u8 reserved;
1708 u8 key[16];
1709 __le16 next_frame_flags;
1710 __le16 reserved2;
1711 union {
1712 __le32 life_time;
1713 __le32 attempt;
1714 } stop_time;
1715
1716 /* Host DRAM physical address pointer to "scratch" in this command.
1717 * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */
1718 __le32 dram_lsb_ptr;
1719 u8 dram_msb_ptr;
1720
1721 u8 rts_retry_limit; /*byte 50 */
1722 u8 data_retry_limit; /*byte 51 */
1723 u8 tid_tspec;
1724 union {
1725 __le16 pm_frame_timeout;
1726 __le16 attempt_duration;
1727 } timeout;
1728
1729 /*
1730 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1731 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1732 */
1733 __le16 driver_txop;
1734
1735 /*
1736 * MAC header goes here, followed by 2 bytes padding if MAC header
1737 * length is 26 or 30 bytes, followed by payload data
1738 */
1739 u8 payload[0];
1740 struct ieee80211_hdr hdr[0];
1741 } __packed;
1742
1743 /* TX command response is sent after *3945* transmission attempts.
1744 *
1745 * NOTES:
1746 *
1747 * TX_STATUS_FAIL_NEXT_FRAG
1748 *
1749 * If the fragment flag in the MAC header for the frame being transmitted
1750 * is set and there is insufficient time to transmit the next frame, the
1751 * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
1752 *
1753 * TX_STATUS_FIFO_UNDERRUN
1754 *
1755 * Indicates the host did not provide bytes to the FIFO fast enough while
1756 * a TX was in progress.
1757 *
1758 * TX_STATUS_FAIL_MGMNT_ABORT
1759 *
1760 * This status is only possible if the ABORT ON MGMT RX parameter was
1761 * set to true with the TX command.
1762 *
1763 * If the MSB of the status parameter is set then an abort sequence is
1764 * required. This sequence consists of the host activating the TX Abort
1765 * control line, and then waiting for the TX Abort command response. This
1766 * indicates that a the device is no longer in a transmit state, and that the
1767 * command FIFO has been cleared. The host must then deactivate the TX Abort
1768 * control line. Receiving is still allowed in this case.
1769 */
1770 enum {
1771 TX_3945_STATUS_SUCCESS = 0x01,
1772 TX_3945_STATUS_DIRECT_DONE = 0x02,
1773 TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82,
1774 TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83,
1775 TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1776 TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85,
1777 TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86,
1778 TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1779 TX_3945_STATUS_FAIL_DEST_PS = 0x88,
1780 TX_3945_STATUS_FAIL_ABORTED = 0x89,
1781 TX_3945_STATUS_FAIL_BT_RETRY = 0x8a,
1782 TX_3945_STATUS_FAIL_STA_INVALID = 0x8b,
1783 TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1784 TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d,
1785 TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
1786 TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1787 TX_3945_STATUS_FAIL_TX_LOCKED = 0x90,
1788 TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1789 };
1790
1791 /*
1792 * TX command response is sent after *agn* transmission attempts.
1793 *
1794 * both postpone and abort status are expected behavior from uCode. there is
1795 * no special operation required from driver; except for RFKILL_FLUSH,
1796 * which required tx flush host command to flush all the tx frames in queues
1797 */
1798 enum {
1799 TX_STATUS_SUCCESS = 0x01,
1800 TX_STATUS_DIRECT_DONE = 0x02,
1801 /* postpone TX */
1802 TX_STATUS_POSTPONE_DELAY = 0x40,
1803 TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
1804 TX_STATUS_POSTPONE_BT_PRIO = 0x42,
1805 TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
1806 TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
1807 /* abort TX */
1808 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
1809 TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
1810 TX_STATUS_FAIL_LONG_LIMIT = 0x83,
1811 TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1812 TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
1813 TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
1814 TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1815 TX_STATUS_FAIL_DEST_PS = 0x88,
1816 TX_STATUS_FAIL_HOST_ABORTED = 0x89,
1817 TX_STATUS_FAIL_BT_RETRY = 0x8a,
1818 TX_STATUS_FAIL_STA_INVALID = 0x8b,
1819 TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1820 TX_STATUS_FAIL_TID_DISABLE = 0x8d,
1821 TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
1822 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1823 /* uCode drop due to FW drop request */
1824 TX_STATUS_FAIL_FW_DROP = 0x90,
1825 /*
1826 * uCode drop due to station color mismatch
1827 * between tx command and station table
1828 */
1829 TX_STATUS_FAIL_STA_COLOR_MISMATCH_DROP = 0x91,
1830 };
1831
1832 #define TX_PACKET_MODE_REGULAR 0x0000
1833 #define TX_PACKET_MODE_BURST_SEQ 0x0100
1834 #define TX_PACKET_MODE_BURST_FIRST 0x0200
1835
1836 enum {
1837 TX_POWER_PA_NOT_ACTIVE = 0x0,
1838 };
1839
1840 enum {
1841 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
1842 TX_STATUS_DELAY_MSK = 0x00000040,
1843 TX_STATUS_ABORT_MSK = 0x00000080,
1844 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
1845 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
1846 TX_RESERVED = 0x00780000, /* bits 19:22 */
1847 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
1848 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
1849 };
1850
1851 /* *******************************
1852 * TX aggregation status
1853 ******************************* */
1854
1855 enum {
1856 AGG_TX_STATE_TRANSMITTED = 0x00,
1857 AGG_TX_STATE_UNDERRUN_MSK = 0x01,
1858 AGG_TX_STATE_BT_PRIO_MSK = 0x02,
1859 AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1860 AGG_TX_STATE_ABORT_MSK = 0x08,
1861 AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1862 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1863 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
1864 AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1865 AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1866 AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1867 AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1868 AGG_TX_STATE_DELAY_TX_MSK = 0x400
1869 };
1870
1871 #define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
1872 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
1873 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
1874
1875 /* # tx attempts for first frame in aggregation */
1876 #define AGG_TX_STATE_TRY_CNT_POS 12
1877 #define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1878
1879 /* Command ID and sequence number of Tx command for this frame */
1880 #define AGG_TX_STATE_SEQ_NUM_POS 16
1881 #define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1882
1883 /*
1884 * REPLY_TX = 0x1c (response)
1885 *
1886 * This response may be in one of two slightly different formats, indicated
1887 * by the frame_count field:
1888 *
1889 * 1) No aggregation (frame_count == 1). This reports Tx results for
1890 * a single frame. Multiple attempts, at various bit rates, may have
1891 * been made for this frame.
1892 *
1893 * 2) Aggregation (frame_count > 1). This reports Tx results for
1894 * 2 or more frames that used block-acknowledge. All frames were
1895 * transmitted at same rate. Rate scaling may have been used if first
1896 * frame in this new agg block failed in previous agg block(s).
1897 *
1898 * Note that, for aggregation, ACK (block-ack) status is not delivered here;
1899 * block-ack has not been received by the time the agn device records
1900 * this status.
1901 * This status relates to reasons the tx might have been blocked or aborted
1902 * within the sending station (this agn device), rather than whether it was
1903 * received successfully by the destination station.
1904 */
1905 struct agg_tx_status {
1906 __le16 status;
1907 __le16 sequence;
1908 } __packed;
1909
1910 struct iwl4965_tx_resp {
1911 u8 frame_count; /* 1 no aggregation, >1 aggregation */
1912 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
1913 u8 failure_rts; /* # failures due to unsuccessful RTS */
1914 u8 failure_frame; /* # failures due to no ACK (unused for agg) */
1915
1916 /* For non-agg: Rate at which frame was successful.
1917 * For agg: Rate at which all frames were transmitted. */
1918 __le32 rate_n_flags; /* RATE_MCS_* */
1919
1920 /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
1921 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1922 __le16 wireless_media_time; /* uSecs */
1923
1924 __le16 reserved;
1925 __le32 pa_power1; /* RF power amplifier measurement (not used) */
1926 __le32 pa_power2;
1927
1928 /*
1929 * For non-agg: frame status TX_STATUS_*
1930 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
1931 * fields follow this one, up to frame_count.
1932 * Bit fields:
1933 * 11- 0: AGG_TX_STATE_* status code
1934 * 15-12: Retry count for 1st frame in aggregation (retries
1935 * occur if tx failed for this frame when it was a
1936 * member of a previous aggregation block). If rate
1937 * scaling is used, retry count indicates the rate
1938 * table entry used for all frames in the new agg.
1939 * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
1940 */
1941 union {
1942 __le32 status;
1943 struct agg_tx_status agg_status[0]; /* for each agg frame */
1944 } u;
1945 } __packed;
1946
1947 /*
1948 * definitions for initial rate index field
1949 * bits [3:0] initial rate index
1950 * bits [6:4] rate table color, used for the initial rate
1951 * bit-7 invalid rate indication
1952 * i.e. rate was not chosen from rate table
1953 * or rate table color was changed during frame retries
1954 * refer tlc rate info
1955 */
1956
1957 #define IWL50_TX_RES_INIT_RATE_INDEX_POS 0
1958 #define IWL50_TX_RES_INIT_RATE_INDEX_MSK 0x0f
1959 #define IWL50_TX_RES_RATE_TABLE_COLOR_POS 4
1960 #define IWL50_TX_RES_RATE_TABLE_COLOR_MSK 0x70
1961 #define IWL50_TX_RES_INV_RATE_INDEX_MSK 0x80
1962
1963 /* refer to ra_tid */
1964 #define IWL50_TX_RES_TID_POS 0
1965 #define IWL50_TX_RES_TID_MSK 0x0f
1966 #define IWL50_TX_RES_RA_POS 4
1967 #define IWL50_TX_RES_RA_MSK 0xf0
1968
1969 struct iwl5000_tx_resp {
1970 u8 frame_count; /* 1 no aggregation, >1 aggregation */
1971 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
1972 u8 failure_rts; /* # failures due to unsuccessful RTS */
1973 u8 failure_frame; /* # failures due to no ACK (unused for agg) */
1974
1975 /* For non-agg: Rate at which frame was successful.
1976 * For agg: Rate at which all frames were transmitted. */
1977 __le32 rate_n_flags; /* RATE_MCS_* */
1978
1979 /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
1980 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1981 __le16 wireless_media_time; /* uSecs */
1982
1983 u8 pa_status; /* RF power amplifier measurement (not used) */
1984 u8 pa_integ_res_a[3];
1985 u8 pa_integ_res_b[3];
1986 u8 pa_integ_res_C[3];
1987
1988 __le32 tfd_info;
1989 __le16 seq_ctl;
1990 __le16 byte_cnt;
1991 u8 tlc_info;
1992 u8 ra_tid; /* tid (0:3), sta_id (4:7) */
1993 __le16 frame_ctrl;
1994 /*
1995 * For non-agg: frame status TX_STATUS_*
1996 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
1997 * fields follow this one, up to frame_count.
1998 * Bit fields:
1999 * 11- 0: AGG_TX_STATE_* status code
2000 * 15-12: Retry count for 1st frame in aggregation (retries
2001 * occur if tx failed for this frame when it was a
2002 * member of a previous aggregation block). If rate
2003 * scaling is used, retry count indicates the rate
2004 * table entry used for all frames in the new agg.
2005 * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
2006 */
2007 struct agg_tx_status status; /* TX status (in aggregation -
2008 * status of 1st frame) */
2009 } __packed;
2010 /*
2011 * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
2012 *
2013 * Reports Block-Acknowledge from recipient station
2014 */
2015 struct iwl_compressed_ba_resp {
2016 __le32 sta_addr_lo32;
2017 __le16 sta_addr_hi16;
2018 __le16 reserved;
2019
2020 /* Index of recipient (BA-sending) station in uCode's station table */
2021 u8 sta_id;
2022 u8 tid;
2023 __le16 seq_ctl;
2024 __le64 bitmap;
2025 __le16 scd_flow;
2026 __le16 scd_ssn;
2027 } __packed;
2028
2029 /*
2030 * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
2031 *
2032 * See details under "TXPOWER" in iwl-4965-hw.h.
2033 */
2034
2035 struct iwl3945_txpowertable_cmd {
2036 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
2037 u8 reserved;
2038 __le16 channel;
2039 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
2040 } __packed;
2041
2042 struct iwl4965_txpowertable_cmd {
2043 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
2044 u8 reserved;
2045 __le16 channel;
2046 struct iwl4965_tx_power_db tx_power;
2047 } __packed;
2048
2049
2050 /**
2051 * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response
2052 *
2053 * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
2054 *
2055 * NOTE: The table of rates passed to the uCode via the
2056 * RATE_SCALE command sets up the corresponding order of
2057 * rates used for all related commands, including rate
2058 * masks, etc.
2059 *
2060 * For example, if you set 9MB (PLCP 0x0f) as the first
2061 * rate in the rate table, the bit mask for that rate
2062 * when passed through ofdm_basic_rates on the REPLY_RXON
2063 * command would be bit 0 (1 << 0)
2064 */
2065 struct iwl3945_rate_scaling_info {
2066 __le16 rate_n_flags;
2067 u8 try_cnt;
2068 u8 next_rate_index;
2069 } __packed;
2070
2071 struct iwl3945_rate_scaling_cmd {
2072 u8 table_id;
2073 u8 reserved[3];
2074 struct iwl3945_rate_scaling_info table[IWL_MAX_RATES];
2075 } __packed;
2076
2077
2078 /*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
2079 #define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0)
2080
2081 /* # of EDCA prioritized tx fifos */
2082 #define LINK_QUAL_AC_NUM AC_NUM
2083
2084 /* # entries in rate scale table to support Tx retries */
2085 #define LINK_QUAL_MAX_RETRY_NUM 16
2086
2087 /* Tx antenna selection values */
2088 #define LINK_QUAL_ANT_A_MSK (1 << 0)
2089 #define LINK_QUAL_ANT_B_MSK (1 << 1)
2090 #define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
2091
2092
2093 /**
2094 * struct iwl_link_qual_general_params
2095 *
2096 * Used in REPLY_TX_LINK_QUALITY_CMD
2097 */
2098 struct iwl_link_qual_general_params {
2099 u8 flags;
2100
2101 /* No entries at or above this (driver chosen) index contain MIMO */
2102 u8 mimo_delimiter;
2103
2104 /* Best single antenna to use for single stream (legacy, SISO). */
2105 u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */
2106
2107 /* Best antennas to use for MIMO (unused for 4965, assumes both). */
2108 u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */
2109
2110 /*
2111 * If driver needs to use different initial rates for different
2112 * EDCA QOS access categories (as implemented by tx fifos 0-3),
2113 * this table will set that up, by indicating the indexes in the
2114 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
2115 * Otherwise, driver should set all entries to 0.
2116 *
2117 * Entry usage:
2118 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
2119 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
2120 */
2121 u8 start_rate_index[LINK_QUAL_AC_NUM];
2122 } __packed;
2123
2124 #define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */
2125 #define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000)
2126 #define LINK_QUAL_AGG_TIME_LIMIT_MIN (100)
2127
2128 #define LINK_QUAL_AGG_DISABLE_START_DEF (3)
2129 #define LINK_QUAL_AGG_DISABLE_START_MAX (255)
2130 #define LINK_QUAL_AGG_DISABLE_START_MIN (0)
2131
2132 #define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31)
2133 #define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63)
2134 #define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0)
2135
2136 /**
2137 * struct iwl_link_qual_agg_params
2138 *
2139 * Used in REPLY_TX_LINK_QUALITY_CMD
2140 */
2141 struct iwl_link_qual_agg_params {
2142
2143 /*
2144 *Maximum number of uSec in aggregation.
2145 * default set to 4000 (4 milliseconds) if not configured in .cfg
2146 */
2147 __le16 agg_time_limit;
2148
2149 /*
2150 * Number of Tx retries allowed for a frame, before that frame will
2151 * no longer be considered for the start of an aggregation sequence
2152 * (scheduler will then try to tx it as single frame).
2153 * Driver should set this to 3.
2154 */
2155 u8 agg_dis_start_th;
2156
2157 /*
2158 * Maximum number of frames in aggregation.
2159 * 0 = no limit (default). 1 = no aggregation.
2160 * Other values = max # frames in aggregation.
2161 */
2162 u8 agg_frame_cnt_limit;
2163
2164 __le32 reserved;
2165 } __packed;
2166
2167 /*
2168 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
2169 *
2170 * For agn devices only; 3945 uses REPLY_RATE_SCALE.
2171 *
2172 * Each station in the agn device's internal station table has its own table
2173 * of 16
2174 * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
2175 * an ACK is not received. This command replaces the entire table for
2176 * one station.
2177 *
2178 * NOTE: Station must already be in agn device's station table.
2179 * Use REPLY_ADD_STA.
2180 *
2181 * The rate scaling procedures described below work well. Of course, other
2182 * procedures are possible, and may work better for particular environments.
2183 *
2184 *
2185 * FILLING THE RATE TABLE
2186 *
2187 * Given a particular initial rate and mode, as determined by the rate
2188 * scaling algorithm described below, the Linux driver uses the following
2189 * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
2190 * Link Quality command:
2191 *
2192 *
2193 * 1) If using High-throughput (HT) (SISO or MIMO) initial rate:
2194 * a) Use this same initial rate for first 3 entries.
2195 * b) Find next lower available rate using same mode (SISO or MIMO),
2196 * use for next 3 entries. If no lower rate available, switch to
2197 * legacy mode (no HT40 channel, no MIMO, no short guard interval).
2198 * c) If using MIMO, set command's mimo_delimiter to number of entries
2199 * using MIMO (3 or 6).
2200 * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
2201 * no MIMO, no short guard interval), at the next lower bit rate
2202 * (e.g. if second HT bit rate was 54, try 48 legacy), and follow
2203 * legacy procedure for remaining table entries.
2204 *
2205 * 2) If using legacy initial rate:
2206 * a) Use the initial rate for only one entry.
2207 * b) For each following entry, reduce the rate to next lower available
2208 * rate, until reaching the lowest available rate.
2209 * c) When reducing rate, also switch antenna selection.
2210 * d) Once lowest available rate is reached, repeat this rate until
2211 * rate table is filled (16 entries), switching antenna each entry.
2212 *
2213 *
2214 * ACCUMULATING HISTORY
2215 *
2216 * The rate scaling algorithm for agn devices, as implemented in Linux driver,
2217 * uses two sets of frame Tx success history: One for the current/active
2218 * modulation mode, and one for a speculative/search mode that is being
2219 * attempted. If the speculative mode turns out to be more effective (i.e.
2220 * actual transfer rate is better), then the driver continues to use the
2221 * speculative mode as the new current active mode.
2222 *
2223 * Each history set contains, separately for each possible rate, data for a
2224 * sliding window of the 62 most recent tx attempts at that rate. The data
2225 * includes a shifting bitmap of success(1)/failure(0), and sums of successful
2226 * and attempted frames, from which the driver can additionally calculate a
2227 * success ratio (success / attempted) and number of failures
2228 * (attempted - success), and control the size of the window (attempted).
2229 * The driver uses the bit map to remove successes from the success sum, as
2230 * the oldest tx attempts fall out of the window.
2231 *
2232 * When the agn device makes multiple tx attempts for a given frame, each
2233 * attempt might be at a different rate, and have different modulation
2234 * characteristics (e.g. antenna, fat channel, short guard interval), as set
2235 * up in the rate scaling table in the Link Quality command. The driver must
2236 * determine which rate table entry was used for each tx attempt, to determine
2237 * which rate-specific history to update, and record only those attempts that
2238 * match the modulation characteristics of the history set.
2239 *
2240 * When using block-ack (aggregation), all frames are transmitted at the same
2241 * rate, since there is no per-attempt acknowledgment from the destination
2242 * station. The Tx response struct iwl_tx_resp indicates the Tx rate in
2243 * rate_n_flags field. After receiving a block-ack, the driver can update
2244 * history for the entire block all at once.
2245 *
2246 *
2247 * FINDING BEST STARTING RATE:
2248 *
2249 * When working with a selected initial modulation mode (see below), the
2250 * driver attempts to find a best initial rate. The initial rate is the
2251 * first entry in the Link Quality command's rate table.
2252 *
2253 * 1) Calculate actual throughput (success ratio * expected throughput, see
2254 * table below) for current initial rate. Do this only if enough frames
2255 * have been attempted to make the value meaningful: at least 6 failed
2256 * tx attempts, or at least 8 successes. If not enough, don't try rate
2257 * scaling yet.
2258 *
2259 * 2) Find available rates adjacent to current initial rate. Available means:
2260 * a) supported by hardware &&
2261 * b) supported by association &&
2262 * c) within any constraints selected by user
2263 *
2264 * 3) Gather measured throughputs for adjacent rates. These might not have
2265 * enough history to calculate a throughput. That's okay, we might try
2266 * using one of them anyway!
2267 *
2268 * 4) Try decreasing rate if, for current rate:
2269 * a) success ratio is < 15% ||
2270 * b) lower adjacent rate has better measured throughput ||
2271 * c) higher adjacent rate has worse throughput, and lower is unmeasured
2272 *
2273 * As a sanity check, if decrease was determined above, leave rate
2274 * unchanged if:
2275 * a) lower rate unavailable
2276 * b) success ratio at current rate > 85% (very good)
2277 * c) current measured throughput is better than expected throughput
2278 * of lower rate (under perfect 100% tx conditions, see table below)
2279 *
2280 * 5) Try increasing rate if, for current rate:
2281 * a) success ratio is < 15% ||
2282 * b) both adjacent rates' throughputs are unmeasured (try it!) ||
2283 * b) higher adjacent rate has better measured throughput ||
2284 * c) lower adjacent rate has worse throughput, and higher is unmeasured
2285 *
2286 * As a sanity check, if increase was determined above, leave rate
2287 * unchanged if:
2288 * a) success ratio at current rate < 70%. This is not particularly
2289 * good performance; higher rate is sure to have poorer success.
2290 *
2291 * 6) Re-evaluate the rate after each tx frame. If working with block-
2292 * acknowledge, history and statistics may be calculated for the entire
2293 * block (including prior history that fits within the history windows),
2294 * before re-evaluation.
2295 *
2296 * FINDING BEST STARTING MODULATION MODE:
2297 *
2298 * After working with a modulation mode for a "while" (and doing rate scaling),
2299 * the driver searches for a new initial mode in an attempt to improve
2300 * throughput. The "while" is measured by numbers of attempted frames:
2301 *
2302 * For legacy mode, search for new mode after:
2303 * 480 successful frames, or 160 failed frames
2304 * For high-throughput modes (SISO or MIMO), search for new mode after:
2305 * 4500 successful frames, or 400 failed frames
2306 *
2307 * Mode switch possibilities are (3 for each mode):
2308 *
2309 * For legacy:
2310 * Change antenna, try SISO (if HT association), try MIMO (if HT association)
2311 * For SISO:
2312 * Change antenna, try MIMO, try shortened guard interval (SGI)
2313 * For MIMO:
2314 * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
2315 *
2316 * When trying a new mode, use the same bit rate as the old/current mode when
2317 * trying antenna switches and shortened guard interval. When switching to
2318 * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
2319 * for which the expected throughput (under perfect conditions) is about the
2320 * same or slightly better than the actual measured throughput delivered by
2321 * the old/current mode.
2322 *
2323 * Actual throughput can be estimated by multiplying the expected throughput
2324 * by the success ratio (successful / attempted tx frames). Frame size is
2325 * not considered in this calculation; it assumes that frame size will average
2326 * out to be fairly consistent over several samples. The following are
2327 * metric values for expected throughput assuming 100% success ratio.
2328 * Only G band has support for CCK rates:
2329 *
2330 * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60
2331 *
2332 * G: 7 13 35 58 40 57 72 98 121 154 177 186 186
2333 * A: 0 0 0 0 40 57 72 98 121 154 177 186 186
2334 * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202
2335 * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211
2336 * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251
2337 * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257
2338 * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257
2339 * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264
2340 * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289
2341 * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293
2342 *
2343 * After the new mode has been tried for a short while (minimum of 6 failed
2344 * frames or 8 successful frames), compare success ratio and actual throughput
2345 * estimate of the new mode with the old. If either is better with the new
2346 * mode, continue to use the new mode.
2347 *
2348 * Continue comparing modes until all 3 possibilities have been tried.
2349 * If moving from legacy to HT, try all 3 possibilities from the new HT
2350 * mode. After trying all 3, a best mode is found. Continue to use this mode
2351 * for the longer "while" described above (e.g. 480 successful frames for
2352 * legacy), and then repeat the search process.
2353 *
2354 */
2355 struct iwl_link_quality_cmd {
2356
2357 /* Index of destination/recipient station in uCode's station table */
2358 u8 sta_id;
2359 u8 reserved1;
2360 __le16 control; /* not used */
2361 struct iwl_link_qual_general_params general_params;
2362 struct iwl_link_qual_agg_params agg_params;
2363
2364 /*
2365 * Rate info; when using rate-scaling, Tx command's initial_rate_index
2366 * specifies 1st Tx rate attempted, via index into this table.
2367 * agn devices works its way through table when retrying Tx.
2368 */
2369 struct {
2370 __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */
2371 } rs_table[LINK_QUAL_MAX_RETRY_NUM];
2372 __le32 reserved2;
2373 } __packed;
2374
2375 /*
2376 * BT configuration enable flags:
2377 * bit 0 - 1: BT channel announcement enabled
2378 * 0: disable
2379 * bit 1 - 1: priority of BT device enabled
2380 * 0: disable
2381 * bit 2 - 1: BT 2 wire support enabled
2382 * 0: disable
2383 */
2384 #define BT_COEX_DISABLE (0x0)
2385 #define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0)
2386 #define BT_ENABLE_PRIORITY BIT(1)
2387 #define BT_ENABLE_2_WIRE BIT(2)
2388
2389 #define BT_COEX_DISABLE (0x0)
2390 #define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY)
2391
2392 #define BT_LEAD_TIME_MIN (0x0)
2393 #define BT_LEAD_TIME_DEF (0x1E)
2394 #define BT_LEAD_TIME_MAX (0xFF)
2395
2396 #define BT_MAX_KILL_MIN (0x1)
2397 #define BT_MAX_KILL_DEF (0x5)
2398 #define BT_MAX_KILL_MAX (0xFF)
2399
2400 #define BT_DURATION_LIMIT_DEF 625
2401 #define BT_DURATION_LIMIT_MAX 1250
2402 #define BT_DURATION_LIMIT_MIN 625
2403
2404 #define BT_ON_THRESHOLD_DEF 4
2405 #define BT_ON_THRESHOLD_MAX 1000
2406 #define BT_ON_THRESHOLD_MIN 1
2407
2408 #define BT_FRAG_THRESHOLD_DEF 0
2409 #define BT_FRAG_THRESHOLD_MAX 0
2410 #define BT_FRAG_THRESHOLD_MIN 0
2411
2412 #define BT_AGG_THRESHOLD_DEF 0
2413 #define BT_AGG_THRESHOLD_MAX 0
2414 #define BT_AGG_THRESHOLD_MIN 0
2415
2416 /*
2417 * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
2418 *
2419 * 3945 and agn devices support hardware handshake with Bluetooth device on
2420 * same platform. Bluetooth device alerts wireless device when it will Tx;
2421 * wireless device can delay or kill its own Tx to accommodate.
2422 */
2423 struct iwl_bt_cmd {
2424 u8 flags;
2425 u8 lead_time;
2426 u8 max_kill;
2427 u8 reserved;
2428 __le32 kill_ack_mask;
2429 __le32 kill_cts_mask;
2430 } __packed;
2431
2432 #define IWLAGN_BT_FLAG_CHANNEL_INHIBITION BIT(0)
2433
2434 #define IWLAGN_BT_FLAG_COEX_MODE_MASK (BIT(3)|BIT(4)|BIT(5))
2435 #define IWLAGN_BT_FLAG_COEX_MODE_SHIFT 3
2436 #define IWLAGN_BT_FLAG_COEX_MODE_DISABLED 0
2437 #define IWLAGN_BT_FLAG_COEX_MODE_LEGACY_2W 1
2438 #define IWLAGN_BT_FLAG_COEX_MODE_3W 2
2439 #define IWLAGN_BT_FLAG_COEX_MODE_4W 3
2440
2441 #define IWLAGN_BT_FLAG_UCODE_DEFAULT BIT(6)
2442 #define IWLAGN_BT_FLAG_NOCOEX_NOTIF BIT(7)
2443
2444 #define IWLAGN_BT_PRIO_BOOST_MAX 0xFF
2445 #define IWLAGN_BT_PRIO_BOOST_MIN 0x00
2446 #define IWLAGN_BT_PRIO_BOOST_DEFAULT 0xF0
2447
2448 #define IWLAGN_BT_MAX_KILL_DEFAULT 5
2449
2450 #define IWLAGN_BT3_T7_DEFAULT 1
2451
2452 #define IWLAGN_BT_KILL_ACK_MASK_DEFAULT cpu_to_le32(0xffffffff)
2453 #define IWLAGN_BT_KILL_CTS_MASK_DEFAULT cpu_to_le32(0xffffffff)
2454
2455 #define IWLAGN_BT3_PRIO_SAMPLE_DEFAULT 2
2456
2457 #define IWLAGN_BT3_T2_DEFAULT 0xc
2458
2459 #define IWLAGN_BT_VALID_ENABLE_FLAGS cpu_to_le16(BIT(0))
2460 #define IWLAGN_BT_VALID_BOOST cpu_to_le16(BIT(1))
2461 #define IWLAGN_BT_VALID_MAX_KILL cpu_to_le16(BIT(2))
2462 #define IWLAGN_BT_VALID_3W_TIMERS cpu_to_le16(BIT(3))
2463 #define IWLAGN_BT_VALID_KILL_ACK_MASK cpu_to_le16(BIT(4))
2464 #define IWLAGN_BT_VALID_KILL_CTS_MASK cpu_to_le16(BIT(5))
2465 #define IWLAGN_BT_VALID_BT4_TIMES cpu_to_le16(BIT(6))
2466 #define IWLAGN_BT_VALID_3W_LUT cpu_to_le16(BIT(7))
2467
2468 #define IWLAGN_BT_ALL_VALID_MSK (IWLAGN_BT_VALID_ENABLE_FLAGS | \
2469 IWLAGN_BT_VALID_BOOST | \
2470 IWLAGN_BT_VALID_MAX_KILL | \
2471 IWLAGN_BT_VALID_3W_TIMERS | \
2472 IWLAGN_BT_VALID_KILL_ACK_MASK | \
2473 IWLAGN_BT_VALID_KILL_CTS_MASK | \
2474 IWLAGN_BT_VALID_BT4_TIMES | \
2475 IWLAGN_BT_VALID_3W_LUT)
2476
2477 struct iwlagn_bt_cmd {
2478 u8 flags;
2479 u8 ledtime; /* unused */
2480 u8 max_kill;
2481 u8 bt3_timer_t7_value;
2482 __le32 kill_ack_mask;
2483 __le32 kill_cts_mask;
2484 u8 bt3_prio_sample_time;
2485 u8 bt3_timer_t2_value;
2486 __le16 bt4_reaction_time; /* unused */
2487 __le32 bt3_lookup_table[12];
2488 __le16 bt4_decision_time; /* unused */
2489 __le16 valid;
2490 u8 prio_boost;
2491 u8 reserved[3];
2492 };
2493
2494 #define IWLAGN_BT_SCO_ACTIVE cpu_to_le32(BIT(0))
2495
2496 struct iwlagn_bt_sco_cmd {
2497 __le32 flags;
2498 };
2499
2500 /******************************************************************************
2501 * (6)
2502 * Spectrum Management (802.11h) Commands, Responses, Notifications:
2503 *
2504 *****************************************************************************/
2505
2506 /*
2507 * Spectrum Management
2508 */
2509 #define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
2510 RXON_FILTER_CTL2HOST_MSK | \
2511 RXON_FILTER_ACCEPT_GRP_MSK | \
2512 RXON_FILTER_DIS_DECRYPT_MSK | \
2513 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
2514 RXON_FILTER_ASSOC_MSK | \
2515 RXON_FILTER_BCON_AWARE_MSK)
2516
2517 struct iwl_measure_channel {
2518 __le32 duration; /* measurement duration in extended beacon
2519 * format */
2520 u8 channel; /* channel to measure */
2521 u8 type; /* see enum iwl_measure_type */
2522 __le16 reserved;
2523 } __packed;
2524
2525 /*
2526 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
2527 */
2528 struct iwl_spectrum_cmd {
2529 __le16 len; /* number of bytes starting from token */
2530 u8 token; /* token id */
2531 u8 id; /* measurement id -- 0 or 1 */
2532 u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
2533 u8 periodic; /* 1 = periodic */
2534 __le16 path_loss_timeout;
2535 __le32 start_time; /* start time in extended beacon format */
2536 __le32 reserved2;
2537 __le32 flags; /* rxon flags */
2538 __le32 filter_flags; /* rxon filter flags */
2539 __le16 channel_count; /* minimum 1, maximum 10 */
2540 __le16 reserved3;
2541 struct iwl_measure_channel channels[10];
2542 } __packed;
2543
2544 /*
2545 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
2546 */
2547 struct iwl_spectrum_resp {
2548 u8 token;
2549 u8 id; /* id of the prior command replaced, or 0xff */
2550 __le16 status; /* 0 - command will be handled
2551 * 1 - cannot handle (conflicts with another
2552 * measurement) */
2553 } __packed;
2554
2555 enum iwl_measurement_state {
2556 IWL_MEASUREMENT_START = 0,
2557 IWL_MEASUREMENT_STOP = 1,
2558 };
2559
2560 enum iwl_measurement_status {
2561 IWL_MEASUREMENT_OK = 0,
2562 IWL_MEASUREMENT_CONCURRENT = 1,
2563 IWL_MEASUREMENT_CSA_CONFLICT = 2,
2564 IWL_MEASUREMENT_TGH_CONFLICT = 3,
2565 /* 4-5 reserved */
2566 IWL_MEASUREMENT_STOPPED = 6,
2567 IWL_MEASUREMENT_TIMEOUT = 7,
2568 IWL_MEASUREMENT_PERIODIC_FAILED = 8,
2569 };
2570
2571 #define NUM_ELEMENTS_IN_HISTOGRAM 8
2572
2573 struct iwl_measurement_histogram {
2574 __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
2575 __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
2576 } __packed;
2577
2578 /* clear channel availability counters */
2579 struct iwl_measurement_cca_counters {
2580 __le32 ofdm;
2581 __le32 cck;
2582 } __packed;
2583
2584 enum iwl_measure_type {
2585 IWL_MEASURE_BASIC = (1 << 0),
2586 IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
2587 IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
2588 IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
2589 IWL_MEASURE_FRAME = (1 << 4),
2590 /* bits 5:6 are reserved */
2591 IWL_MEASURE_IDLE = (1 << 7),
2592 };
2593
2594 /*
2595 * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
2596 */
2597 struct iwl_spectrum_notification {
2598 u8 id; /* measurement id -- 0 or 1 */
2599 u8 token;
2600 u8 channel_index; /* index in measurement channel list */
2601 u8 state; /* 0 - start, 1 - stop */
2602 __le32 start_time; /* lower 32-bits of TSF */
2603 u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
2604 u8 channel;
2605 u8 type; /* see enum iwl_measurement_type */
2606 u8 reserved1;
2607 /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
2608 * valid if applicable for measurement type requested. */
2609 __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
2610 __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
2611 __le32 cca_time; /* channel load time in usecs */
2612 u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
2613 * unidentified */
2614 u8 reserved2[3];
2615 struct iwl_measurement_histogram histogram;
2616 __le32 stop_time; /* lower 32-bits of TSF */
2617 __le32 status; /* see iwl_measurement_status */
2618 } __packed;
2619
2620 /******************************************************************************
2621 * (7)
2622 * Power Management Commands, Responses, Notifications:
2623 *
2624 *****************************************************************************/
2625
2626 /**
2627 * struct iwl_powertable_cmd - Power Table Command
2628 * @flags: See below:
2629 *
2630 * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
2631 *
2632 * PM allow:
2633 * bit 0 - '0' Driver not allow power management
2634 * '1' Driver allow PM (use rest of parameters)
2635 *
2636 * uCode send sleep notifications:
2637 * bit 1 - '0' Don't send sleep notification
2638 * '1' send sleep notification (SEND_PM_NOTIFICATION)
2639 *
2640 * Sleep over DTIM
2641 * bit 2 - '0' PM have to walk up every DTIM
2642 * '1' PM could sleep over DTIM till listen Interval.
2643 *
2644 * PCI power managed
2645 * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
2646 * '1' !(PCI_CFG_LINK_CTRL & 0x1)
2647 *
2648 * Fast PD
2649 * bit 4 - '1' Put radio to sleep when receiving frame for others
2650 *
2651 * Force sleep Modes
2652 * bit 31/30- '00' use both mac/xtal sleeps
2653 * '01' force Mac sleep
2654 * '10' force xtal sleep
2655 * '11' Illegal set
2656 *
2657 * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
2658 * ucode assume sleep over DTIM is allowed and we don't need to wake up
2659 * for every DTIM.
2660 */
2661 #define IWL_POWER_VEC_SIZE 5
2662
2663 #define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0))
2664 #define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le16(BIT(2))
2665 #define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3))
2666 #define IWL_POWER_FAST_PD cpu_to_le16(BIT(4))
2667
2668 struct iwl3945_powertable_cmd {
2669 __le16 flags;
2670 u8 reserved[2];
2671 __le32 rx_data_timeout;
2672 __le32 tx_data_timeout;
2673 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
2674 } __packed;
2675
2676 struct iwl_powertable_cmd {
2677 __le16 flags;
2678 u8 keep_alive_seconds; /* 3945 reserved */
2679 u8 debug_flags; /* 3945 reserved */
2680 __le32 rx_data_timeout;
2681 __le32 tx_data_timeout;
2682 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
2683 __le32 keep_alive_beacons;
2684 } __packed;
2685
2686 /*
2687 * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
2688 * all devices identical.
2689 */
2690 struct iwl_sleep_notification {
2691 u8 pm_sleep_mode;
2692 u8 pm_wakeup_src;
2693 __le16 reserved;
2694 __le32 sleep_time;
2695 __le32 tsf_low;
2696 __le32 bcon_timer;
2697 } __packed;
2698
2699 /* Sleep states. all devices identical. */
2700 enum {
2701 IWL_PM_NO_SLEEP = 0,
2702 IWL_PM_SLP_MAC = 1,
2703 IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
2704 IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
2705 IWL_PM_SLP_PHY = 4,
2706 IWL_PM_SLP_REPENT = 5,
2707 IWL_PM_WAKEUP_BY_TIMER = 6,
2708 IWL_PM_WAKEUP_BY_DRIVER = 7,
2709 IWL_PM_WAKEUP_BY_RFKILL = 8,
2710 /* 3 reserved */
2711 IWL_PM_NUM_OF_MODES = 12,
2712 };
2713
2714 /*
2715 * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
2716 */
2717 #define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
2718 #define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
2719 #define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
2720 struct iwl_card_state_cmd {
2721 __le32 status; /* CARD_STATE_CMD_* request new power state */
2722 } __packed;
2723
2724 /*
2725 * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
2726 */
2727 struct iwl_card_state_notif {
2728 __le32 flags;
2729 } __packed;
2730
2731 #define HW_CARD_DISABLED 0x01
2732 #define SW_CARD_DISABLED 0x02
2733 #define CT_CARD_DISABLED 0x04
2734 #define RXON_CARD_DISABLED 0x10
2735
2736 struct iwl_ct_kill_config {
2737 __le32 reserved;
2738 __le32 critical_temperature_M;
2739 __le32 critical_temperature_R;
2740 } __packed;
2741
2742 /* 1000, and 6x00 */
2743 struct iwl_ct_kill_throttling_config {
2744 __le32 critical_temperature_exit;
2745 __le32 reserved;
2746 __le32 critical_temperature_enter;
2747 } __packed;
2748
2749 /******************************************************************************
2750 * (8)
2751 * Scan Commands, Responses, Notifications:
2752 *
2753 *****************************************************************************/
2754
2755 #define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
2756 #define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1)
2757
2758 /**
2759 * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
2760 *
2761 * One for each channel in the scan list.
2762 * Each channel can independently select:
2763 * 1) SSID for directed active scans
2764 * 2) Txpower setting (for rate specified within Tx command)
2765 * 3) How long to stay on-channel (behavior may be modified by quiet_time,
2766 * quiet_plcp_th, good_CRC_th)
2767 *
2768 * To avoid uCode errors, make sure the following are true (see comments
2769 * under struct iwl_scan_cmd about max_out_time and quiet_time):
2770 * 1) If using passive_dwell (i.e. passive_dwell != 0):
2771 * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
2772 * 2) quiet_time <= active_dwell
2773 * 3) If restricting off-channel time (i.e. max_out_time !=0):
2774 * passive_dwell < max_out_time
2775 * active_dwell < max_out_time
2776 */
2777
2778 /* FIXME: rename to AP1, remove tpc */
2779 struct iwl3945_scan_channel {
2780 /*
2781 * type is defined as:
2782 * 0:0 1 = active, 0 = passive
2783 * 1:4 SSID direct bit map; if a bit is set, then corresponding
2784 * SSID IE is transmitted in probe request.
2785 * 5:7 reserved
2786 */
2787 u8 type;
2788 u8 channel; /* band is selected by iwl3945_scan_cmd "flags" field */
2789 struct iwl3945_tx_power tpc;
2790 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2791 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
2792 } __packed;
2793
2794 /* set number of direct probes u8 type */
2795 #define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1))))
2796
2797 struct iwl_scan_channel {
2798 /*
2799 * type is defined as:
2800 * 0:0 1 = active, 0 = passive
2801 * 1:20 SSID direct bit map; if a bit is set, then corresponding
2802 * SSID IE is transmitted in probe request.
2803 * 21:31 reserved
2804 */
2805 __le32 type;
2806 __le16 channel; /* band is selected by iwl_scan_cmd "flags" field */
2807 u8 tx_gain; /* gain for analog radio */
2808 u8 dsp_atten; /* gain for DSP */
2809 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2810 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
2811 } __packed;
2812
2813 /* set number of direct probes __le32 type */
2814 #define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
2815
2816 /**
2817 * struct iwl_ssid_ie - directed scan network information element
2818 *
2819 * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in
2820 * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel;
2821 * each channel may select different ssids from among the 20 (4) entries.
2822 * SSID IEs get transmitted in reverse order of entry.
2823 */
2824 struct iwl_ssid_ie {
2825 u8 id;
2826 u8 len;
2827 u8 ssid[32];
2828 } __packed;
2829
2830 #define PROBE_OPTION_MAX_3945 4
2831 #define PROBE_OPTION_MAX 20
2832 #define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
2833 #define IWL_GOOD_CRC_TH_DISABLED 0
2834 #define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
2835 #define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
2836 #define IWL_MAX_SCAN_SIZE 1024
2837 #define IWL_MAX_CMD_SIZE 4096
2838
2839 /*
2840 * REPLY_SCAN_CMD = 0x80 (command)
2841 *
2842 * The hardware scan command is very powerful; the driver can set it up to
2843 * maintain (relatively) normal network traffic while doing a scan in the
2844 * background. The max_out_time and suspend_time control the ratio of how
2845 * long the device stays on an associated network channel ("service channel")
2846 * vs. how long it's away from the service channel, i.e. tuned to other channels
2847 * for scanning.
2848 *
2849 * max_out_time is the max time off-channel (in usec), and suspend_time
2850 * is how long (in "extended beacon" format) that the scan is "suspended"
2851 * after returning to the service channel. That is, suspend_time is the
2852 * time that we stay on the service channel, doing normal work, between
2853 * scan segments. The driver may set these parameters differently to support
2854 * scanning when associated vs. not associated, and light vs. heavy traffic
2855 * loads when associated.
2856 *
2857 * After receiving this command, the device's scan engine does the following;
2858 *
2859 * 1) Sends SCAN_START notification to driver
2860 * 2) Checks to see if it has time to do scan for one channel
2861 * 3) Sends NULL packet, with power-save (PS) bit set to 1,
2862 * to tell AP that we're going off-channel
2863 * 4) Tunes to first channel in scan list, does active or passive scan
2864 * 5) Sends SCAN_RESULT notification to driver
2865 * 6) Checks to see if it has time to do scan on *next* channel in list
2866 * 7) Repeats 4-6 until it no longer has time to scan the next channel
2867 * before max_out_time expires
2868 * 8) Returns to service channel
2869 * 9) Sends NULL packet with PS=0 to tell AP that we're back
2870 * 10) Stays on service channel until suspend_time expires
2871 * 11) Repeats entire process 2-10 until list is complete
2872 * 12) Sends SCAN_COMPLETE notification
2873 *
2874 * For fast, efficient scans, the scan command also has support for staying on
2875 * a channel for just a short time, if doing active scanning and getting no
2876 * responses to the transmitted probe request. This time is controlled by
2877 * quiet_time, and the number of received packets below which a channel is
2878 * considered "quiet" is controlled by quiet_plcp_threshold.
2879 *
2880 * For active scanning on channels that have regulatory restrictions against
2881 * blindly transmitting, the scan can listen before transmitting, to make sure
2882 * that there is already legitimate activity on the channel. If enough
2883 * packets are cleanly received on the channel (controlled by good_CRC_th,
2884 * typical value 1), the scan engine starts transmitting probe requests.
2885 *
2886 * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
2887 *
2888 * To avoid uCode errors, see timing restrictions described under
2889 * struct iwl_scan_channel.
2890 */
2891
2892 struct iwl3945_scan_cmd {
2893 __le16 len;
2894 u8 reserved0;
2895 u8 channel_count; /* # channels in channel list */
2896 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2897 * (only for active scan) */
2898 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2899 __le16 good_CRC_th; /* passive -> active promotion threshold */
2900 __le16 reserved1;
2901 __le32 max_out_time; /* max usec to be away from associated (service)
2902 * channel */
2903 __le32 suspend_time; /* pause scan this long (in "extended beacon
2904 * format") when returning to service channel:
2905 * 3945; 31:24 # beacons, 19:0 additional usec,
2906 * 4965; 31:22 # beacons, 21:0 additional usec.
2907 */
2908 __le32 flags; /* RXON_FLG_* */
2909 __le32 filter_flags; /* RXON_FILTER_* */
2910
2911 /* For active scans (set to all-0s for passive scans).
2912 * Does not include payload. Must specify Tx rate; no rate scaling. */
2913 struct iwl3945_tx_cmd tx_cmd;
2914
2915 /* For directed active scans (set to all-0s otherwise) */
2916 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
2917
2918 /*
2919 * Probe request frame, followed by channel list.
2920 *
2921 * Size of probe request frame is specified by byte count in tx_cmd.
2922 * Channel list follows immediately after probe request frame.
2923 * Number of channels in list is specified by channel_count.
2924 * Each channel in list is of type:
2925 *
2926 * struct iwl3945_scan_channel channels[0];
2927 *
2928 * NOTE: Only one band of channels can be scanned per pass. You
2929 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2930 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
2931 * before requesting another scan.
2932 */
2933 u8 data[0];
2934 } __packed;
2935
2936 struct iwl_scan_cmd {
2937 __le16 len;
2938 u8 reserved0;
2939 u8 channel_count; /* # channels in channel list */
2940 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2941 * (only for active scan) */
2942 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2943 __le16 good_CRC_th; /* passive -> active promotion threshold */
2944 __le16 rx_chain; /* RXON_RX_CHAIN_* */
2945 __le32 max_out_time; /* max usec to be away from associated (service)
2946 * channel */
2947 __le32 suspend_time; /* pause scan this long (in "extended beacon
2948 * format") when returning to service chnl:
2949 * 3945; 31:24 # beacons, 19:0 additional usec,
2950 * 4965; 31:22 # beacons, 21:0 additional usec.
2951 */
2952 __le32 flags; /* RXON_FLG_* */
2953 __le32 filter_flags; /* RXON_FILTER_* */
2954
2955 /* For active scans (set to all-0s for passive scans).
2956 * Does not include payload. Must specify Tx rate; no rate scaling. */
2957 struct iwl_tx_cmd tx_cmd;
2958
2959 /* For directed active scans (set to all-0s otherwise) */
2960 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
2961
2962 /*
2963 * Probe request frame, followed by channel list.
2964 *
2965 * Size of probe request frame is specified by byte count in tx_cmd.
2966 * Channel list follows immediately after probe request frame.
2967 * Number of channels in list is specified by channel_count.
2968 * Each channel in list is of type:
2969 *
2970 * struct iwl_scan_channel channels[0];
2971 *
2972 * NOTE: Only one band of channels can be scanned per pass. You
2973 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2974 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
2975 * before requesting another scan.
2976 */
2977 u8 data[0];
2978 } __packed;
2979
2980 /* Can abort will notify by complete notification with abort status. */
2981 #define CAN_ABORT_STATUS cpu_to_le32(0x1)
2982 /* complete notification statuses */
2983 #define ABORT_STATUS 0x2
2984
2985 /*
2986 * REPLY_SCAN_CMD = 0x80 (response)
2987 */
2988 struct iwl_scanreq_notification {
2989 __le32 status; /* 1: okay, 2: cannot fulfill request */
2990 } __packed;
2991
2992 /*
2993 * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
2994 */
2995 struct iwl_scanstart_notification {
2996 __le32 tsf_low;
2997 __le32 tsf_high;
2998 __le32 beacon_timer;
2999 u8 channel;
3000 u8 band;
3001 u8 reserved[2];
3002 __le32 status;
3003 } __packed;
3004
3005 #define SCAN_OWNER_STATUS 0x1;
3006 #define MEASURE_OWNER_STATUS 0x2;
3007
3008 #define IWL_PROBE_STATUS_OK 0
3009 #define IWL_PROBE_STATUS_TX_FAILED BIT(0)
3010 /* error statuses combined with TX_FAILED */
3011 #define IWL_PROBE_STATUS_FAIL_TTL BIT(1)
3012 #define IWL_PROBE_STATUS_FAIL_BT BIT(2)
3013
3014 #define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
3015 /*
3016 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
3017 */
3018 struct iwl_scanresults_notification {
3019 u8 channel;
3020 u8 band;
3021 u8 probe_status;
3022 u8 num_probe_not_sent; /* not enough time to send */
3023 __le32 tsf_low;
3024 __le32 tsf_high;
3025 __le32 statistics[NUMBER_OF_STATISTICS];
3026 } __packed;
3027
3028 /*
3029 * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
3030 */
3031 struct iwl_scancomplete_notification {
3032 u8 scanned_channels;
3033 u8 status;
3034 u8 bt_status; /* BT On/Off status */
3035 u8 last_channel;
3036 __le32 tsf_low;
3037 __le32 tsf_high;
3038 } __packed;
3039
3040
3041 /******************************************************************************
3042 * (9)
3043 * IBSS/AP Commands and Notifications:
3044 *
3045 *****************************************************************************/
3046
3047 enum iwl_ibss_manager {
3048 IWL_NOT_IBSS_MANAGER = 0,
3049 IWL_IBSS_MANAGER = 1,
3050 };
3051
3052 /*
3053 * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
3054 */
3055
3056 struct iwl3945_beacon_notif {
3057 struct iwl3945_tx_resp beacon_notify_hdr;
3058 __le32 low_tsf;
3059 __le32 high_tsf;
3060 __le32 ibss_mgr_status;
3061 } __packed;
3062
3063 struct iwl4965_beacon_notif {
3064 struct iwl4965_tx_resp beacon_notify_hdr;
3065 __le32 low_tsf;
3066 __le32 high_tsf;
3067 __le32 ibss_mgr_status;
3068 } __packed;
3069
3070 /*
3071 * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
3072 */
3073
3074 struct iwl3945_tx_beacon_cmd {
3075 struct iwl3945_tx_cmd tx;
3076 __le16 tim_idx;
3077 u8 tim_size;
3078 u8 reserved1;
3079 struct ieee80211_hdr frame[0]; /* beacon frame */
3080 } __packed;
3081
3082 struct iwl_tx_beacon_cmd {
3083 struct iwl_tx_cmd tx;
3084 __le16 tim_idx;
3085 u8 tim_size;
3086 u8 reserved1;
3087 struct ieee80211_hdr frame[0]; /* beacon frame */
3088 } __packed;
3089
3090 /******************************************************************************
3091 * (10)
3092 * Statistics Commands and Notifications:
3093 *
3094 *****************************************************************************/
3095
3096 #define IWL_TEMP_CONVERT 260
3097
3098 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
3099 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
3100 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
3101
3102 /* Used for passing to driver number of successes and failures per rate */
3103 struct rate_histogram {
3104 union {
3105 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
3106 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
3107 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
3108 } success;
3109 union {
3110 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
3111 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
3112 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
3113 } failed;
3114 } __packed;
3115
3116 /* statistics command response */
3117
3118 struct iwl39_statistics_rx_phy {
3119 __le32 ina_cnt;
3120 __le32 fina_cnt;
3121 __le32 plcp_err;
3122 __le32 crc32_err;
3123 __le32 overrun_err;
3124 __le32 early_overrun_err;
3125 __le32 crc32_good;
3126 __le32 false_alarm_cnt;
3127 __le32 fina_sync_err_cnt;
3128 __le32 sfd_timeout;
3129 __le32 fina_timeout;
3130 __le32 unresponded_rts;
3131 __le32 rxe_frame_limit_overrun;
3132 __le32 sent_ack_cnt;
3133 __le32 sent_cts_cnt;
3134 } __packed;
3135
3136 struct iwl39_statistics_rx_non_phy {
3137 __le32 bogus_cts; /* CTS received when not expecting CTS */
3138 __le32 bogus_ack; /* ACK received when not expecting ACK */
3139 __le32 non_bssid_frames; /* number of frames with BSSID that
3140 * doesn't belong to the STA BSSID */
3141 __le32 filtered_frames; /* count frames that were dumped in the
3142 * filtering process */
3143 __le32 non_channel_beacons; /* beacons with our bss id but not on
3144 * our serving channel */
3145 } __packed;
3146
3147 struct iwl39_statistics_rx {
3148 struct iwl39_statistics_rx_phy ofdm;
3149 struct iwl39_statistics_rx_phy cck;
3150 struct iwl39_statistics_rx_non_phy general;
3151 } __packed;
3152
3153 struct iwl39_statistics_tx {
3154 __le32 preamble_cnt;
3155 __le32 rx_detected_cnt;
3156 __le32 bt_prio_defer_cnt;
3157 __le32 bt_prio_kill_cnt;
3158 __le32 few_bytes_cnt;
3159 __le32 cts_timeout;
3160 __le32 ack_timeout;
3161 __le32 expected_ack_cnt;
3162 __le32 actual_ack_cnt;
3163 } __packed;
3164
3165 struct statistics_dbg {
3166 __le32 burst_check;
3167 __le32 burst_count;
3168 __le32 wait_for_silence_timeout_cnt;
3169 __le32 reserved[3];
3170 } __packed;
3171
3172 struct iwl39_statistics_div {
3173 __le32 tx_on_a;
3174 __le32 tx_on_b;
3175 __le32 exec_time;
3176 __le32 probe_time;
3177 } __packed;
3178
3179 struct iwl39_statistics_general {
3180 __le32 temperature;
3181 struct statistics_dbg dbg;
3182 __le32 sleep_time;
3183 __le32 slots_out;
3184 __le32 slots_idle;
3185 __le32 ttl_timestamp;
3186 struct iwl39_statistics_div div;
3187 } __packed;
3188
3189 struct statistics_rx_phy {
3190 __le32 ina_cnt;
3191 __le32 fina_cnt;
3192 __le32 plcp_err;
3193 __le32 crc32_err;
3194 __le32 overrun_err;
3195 __le32 early_overrun_err;
3196 __le32 crc32_good;
3197 __le32 false_alarm_cnt;
3198 __le32 fina_sync_err_cnt;
3199 __le32 sfd_timeout;
3200 __le32 fina_timeout;
3201 __le32 unresponded_rts;
3202 __le32 rxe_frame_limit_overrun;
3203 __le32 sent_ack_cnt;
3204 __le32 sent_cts_cnt;
3205 __le32 sent_ba_rsp_cnt;
3206 __le32 dsp_self_kill;
3207 __le32 mh_format_err;
3208 __le32 re_acq_main_rssi_sum;
3209 __le32 reserved3;
3210 } __packed;
3211
3212 struct statistics_rx_ht_phy {
3213 __le32 plcp_err;
3214 __le32 overrun_err;
3215 __le32 early_overrun_err;
3216 __le32 crc32_good;
3217 __le32 crc32_err;
3218 __le32 mh_format_err;
3219 __le32 agg_crc32_good;
3220 __le32 agg_mpdu_cnt;
3221 __le32 agg_cnt;
3222 __le32 unsupport_mcs;
3223 } __packed;
3224
3225 #define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1)
3226
3227 struct statistics_rx_non_phy {
3228 __le32 bogus_cts; /* CTS received when not expecting CTS */
3229 __le32 bogus_ack; /* ACK received when not expecting ACK */
3230 __le32 non_bssid_frames; /* number of frames with BSSID that
3231 * doesn't belong to the STA BSSID */
3232 __le32 filtered_frames; /* count frames that were dumped in the
3233 * filtering process */
3234 __le32 non_channel_beacons; /* beacons with our bss id but not on
3235 * our serving channel */
3236 __le32 channel_beacons; /* beacons with our bss id and in our
3237 * serving channel */
3238 __le32 num_missed_bcon; /* number of missed beacons */
3239 __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
3240 * ADC was in saturation */
3241 __le32 ina_detection_search_time;/* total time (in 0.8us) searched
3242 * for INA */
3243 __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
3244 __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
3245 __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
3246 __le32 interference_data_flag; /* flag for interference data
3247 * availability. 1 when data is
3248 * available. */
3249 __le32 channel_load; /* counts RX Enable time in uSec */
3250 __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
3251 * and CCK) counter */
3252 __le32 beacon_rssi_a;
3253 __le32 beacon_rssi_b;
3254 __le32 beacon_rssi_c;
3255 __le32 beacon_energy_a;
3256 __le32 beacon_energy_b;
3257 __le32 beacon_energy_c;
3258 } __packed;
3259
3260 struct statistics_rx_non_phy_bt {
3261 struct statistics_rx_non_phy common;
3262 /* additional stats for bt */
3263 __le32 num_bt_kills;
3264 __le32 reserved[2];
3265 } __packed;
3266
3267 struct statistics_rx {
3268 struct statistics_rx_phy ofdm;
3269 struct statistics_rx_phy cck;
3270 struct statistics_rx_non_phy general;
3271 struct statistics_rx_ht_phy ofdm_ht;
3272 } __packed;
3273
3274 struct statistics_rx_bt {
3275 struct statistics_rx_phy ofdm;
3276 struct statistics_rx_phy cck;
3277 struct statistics_rx_non_phy_bt general;
3278 struct statistics_rx_ht_phy ofdm_ht;
3279 } __packed;
3280
3281 /**
3282 * struct statistics_tx_power - current tx power
3283 *
3284 * @ant_a: current tx power on chain a in 1/2 dB step
3285 * @ant_b: current tx power on chain b in 1/2 dB step
3286 * @ant_c: current tx power on chain c in 1/2 dB step
3287 */
3288 struct statistics_tx_power {
3289 u8 ant_a;
3290 u8 ant_b;
3291 u8 ant_c;
3292 u8 reserved;
3293 } __packed;
3294
3295 struct statistics_tx_non_phy_agg {
3296 __le32 ba_timeout;
3297 __le32 ba_reschedule_frames;
3298 __le32 scd_query_agg_frame_cnt;
3299 __le32 scd_query_no_agg;
3300 __le32 scd_query_agg;
3301 __le32 scd_query_mismatch;
3302 __le32 frame_not_ready;
3303 __le32 underrun;
3304 __le32 bt_prio_kill;
3305 __le32 rx_ba_rsp_cnt;
3306 } __packed;
3307
3308 struct statistics_tx {
3309 __le32 preamble_cnt;
3310 __le32 rx_detected_cnt;
3311 __le32 bt_prio_defer_cnt;
3312 __le32 bt_prio_kill_cnt;
3313 __le32 few_bytes_cnt;
3314 __le32 cts_timeout;
3315 __le32 ack_timeout;
3316 __le32 expected_ack_cnt;
3317 __le32 actual_ack_cnt;
3318 __le32 dump_msdu_cnt;
3319 __le32 burst_abort_next_frame_mismatch_cnt;
3320 __le32 burst_abort_missing_next_frame_cnt;
3321 __le32 cts_timeout_collision;
3322 __le32 ack_or_ba_timeout_collision;
3323 struct statistics_tx_non_phy_agg agg;
3324 /*
3325 * "tx_power" are optional parameters provided by uCode,
3326 * 6000 series is the only device provide the information,
3327 * Those are reserved fields for all the other devices
3328 */
3329 struct statistics_tx_power tx_power;
3330 __le32 reserved1;
3331 } __packed;
3332
3333
3334 struct statistics_div {
3335 __le32 tx_on_a;
3336 __le32 tx_on_b;
3337 __le32 exec_time;
3338 __le32 probe_time;
3339 __le32 reserved1;
3340 __le32 reserved2;
3341 } __packed;
3342
3343 struct statistics_general_common {
3344 __le32 temperature; /* radio temperature */
3345 __le32 temperature_m; /* for 5000 and up, this is radio voltage */
3346 struct statistics_dbg dbg;
3347 __le32 sleep_time;
3348 __le32 slots_out;
3349 __le32 slots_idle;
3350 __le32 ttl_timestamp;
3351 struct statistics_div div;
3352 __le32 rx_enable_counter;
3353 /*
3354 * num_of_sos_states:
3355 * count the number of times we have to re-tune
3356 * in order to get out of bad PHY status
3357 */
3358 __le32 num_of_sos_states;
3359 } __packed;
3360
3361 struct statistics_bt_activity {
3362 /* Tx statistics */
3363 __le32 hi_priority_tx_req_cnt;
3364 __le32 hi_priority_tx_denied_cnt;
3365 __le32 lo_priority_tx_req_cnt;
3366 __le32 lo_priority_tx_denied_cnt;
3367 /* Rx statistics */
3368 __le32 hi_priority_rx_req_cnt;
3369 __le32 hi_priority_rx_denied_cnt;
3370 __le32 lo_priority_rx_req_cnt;
3371 __le32 lo_priority_rx_denied_cnt;
3372 } __packed;
3373
3374 struct statistics_general {
3375 struct statistics_general_common common;
3376 __le32 reserved2;
3377 __le32 reserved3;
3378 } __packed;
3379
3380 struct statistics_general_bt {
3381 struct statistics_general_common common;
3382 struct statistics_bt_activity activity;
3383 __le32 reserved2;
3384 __le32 reserved3;
3385 } __packed;
3386
3387 #define UCODE_STATISTICS_CLEAR_MSK (0x1 << 0)
3388 #define UCODE_STATISTICS_FREQUENCY_MSK (0x1 << 1)
3389 #define UCODE_STATISTICS_NARROW_BAND_MSK (0x1 << 2)
3390
3391 /*
3392 * REPLY_STATISTICS_CMD = 0x9c,
3393 * all devices identical.
3394 *
3395 * This command triggers an immediate response containing uCode statistics.
3396 * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
3397 *
3398 * If the CLEAR_STATS configuration flag is set, uCode will clear its
3399 * internal copy of the statistics (counters) after issuing the response.
3400 * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
3401 *
3402 * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
3403 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
3404 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
3405 */
3406 #define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */
3407 #define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
3408 struct iwl_statistics_cmd {
3409 __le32 configuration_flags; /* IWL_STATS_CONF_* */
3410 } __packed;
3411
3412 /*
3413 * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
3414 *
3415 * By default, uCode issues this notification after receiving a beacon
3416 * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
3417 * REPLY_STATISTICS_CMD 0x9c, above.
3418 *
3419 * Statistics counters continue to increment beacon after beacon, but are
3420 * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
3421 * 0x9c with CLEAR_STATS bit set (see above).
3422 *
3423 * uCode also issues this notification during scans. uCode clears statistics
3424 * appropriately so that each notification contains statistics for only the
3425 * one channel that has just been scanned.
3426 */
3427 #define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2)
3428 #define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8)
3429
3430 struct iwl3945_notif_statistics {
3431 __le32 flag;
3432 struct iwl39_statistics_rx rx;
3433 struct iwl39_statistics_tx tx;
3434 struct iwl39_statistics_general general;
3435 } __packed;
3436
3437 struct iwl_notif_statistics {
3438 __le32 flag;
3439 struct statistics_rx rx;
3440 struct statistics_tx tx;
3441 struct statistics_general general;
3442 } __packed;
3443
3444 struct iwl_bt_notif_statistics {
3445 __le32 flag;
3446 struct statistics_rx_bt rx;
3447 struct statistics_tx tx;
3448 struct statistics_general_bt general;
3449 } __packed;
3450
3451 /*
3452 * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
3453 *
3454 * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed
3455 * in regardless of how many missed beacons, which mean when driver receive the
3456 * notification, inside the command, it can find all the beacons information
3457 * which include number of total missed beacons, number of consecutive missed
3458 * beacons, number of beacons received and number of beacons expected to
3459 * receive.
3460 *
3461 * If uCode detected consecutive_missed_beacons > 5, it will reset the radio
3462 * in order to bring the radio/PHY back to working state; which has no relation
3463 * to when driver will perform sensitivity calibration.
3464 *
3465 * Driver should set it own missed_beacon_threshold to decide when to perform
3466 * sensitivity calibration based on number of consecutive missed beacons in
3467 * order to improve overall performance, especially in noisy environment.
3468 *
3469 */
3470
3471 #define IWL_MISSED_BEACON_THRESHOLD_MIN (1)
3472 #define IWL_MISSED_BEACON_THRESHOLD_DEF (5)
3473 #define IWL_MISSED_BEACON_THRESHOLD_MAX IWL_MISSED_BEACON_THRESHOLD_DEF
3474
3475 struct iwl_missed_beacon_notif {
3476 __le32 consecutive_missed_beacons;
3477 __le32 total_missed_becons;
3478 __le32 num_expected_beacons;
3479 __le32 num_recvd_beacons;
3480 } __packed;
3481
3482
3483 /******************************************************************************
3484 * (11)
3485 * Rx Calibration Commands:
3486 *
3487 * With the uCode used for open source drivers, most Tx calibration (except
3488 * for Tx Power) and most Rx calibration is done by uCode during the
3489 * "initialize" phase of uCode boot. Driver must calibrate only:
3490 *
3491 * 1) Tx power (depends on temperature), described elsewhere
3492 * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
3493 * 3) Receiver sensitivity (to optimize signal detection)
3494 *
3495 *****************************************************************************/
3496
3497 /**
3498 * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
3499 *
3500 * This command sets up the Rx signal detector for a sensitivity level that
3501 * is high enough to lock onto all signals within the associated network,
3502 * but low enough to ignore signals that are below a certain threshold, so as
3503 * not to have too many "false alarms". False alarms are signals that the
3504 * Rx DSP tries to lock onto, but then discards after determining that they
3505 * are noise.
3506 *
3507 * The optimum number of false alarms is between 5 and 50 per 200 TUs
3508 * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
3509 * time listening, not transmitting). Driver must adjust sensitivity so that
3510 * the ratio of actual false alarms to actual Rx time falls within this range.
3511 *
3512 * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
3513 * received beacon. These provide information to the driver to analyze the
3514 * sensitivity. Don't analyze statistics that come in from scanning, or any
3515 * other non-associated-network source. Pertinent statistics include:
3516 *
3517 * From "general" statistics (struct statistics_rx_non_phy):
3518 *
3519 * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
3520 * Measure of energy of desired signal. Used for establishing a level
3521 * below which the device does not detect signals.
3522 *
3523 * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
3524 * Measure of background noise in silent period after beacon.
3525 *
3526 * channel_load
3527 * uSecs of actual Rx time during beacon period (varies according to
3528 * how much time was spent transmitting).
3529 *
3530 * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
3531 *
3532 * false_alarm_cnt
3533 * Signal locks abandoned early (before phy-level header).
3534 *
3535 * plcp_err
3536 * Signal locks abandoned late (during phy-level header).
3537 *
3538 * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
3539 * beacon to beacon, i.e. each value is an accumulation of all errors
3540 * before and including the latest beacon. Values will wrap around to 0
3541 * after counting up to 2^32 - 1. Driver must differentiate vs.
3542 * previous beacon's values to determine # false alarms in the current
3543 * beacon period.
3544 *
3545 * Total number of false alarms = false_alarms + plcp_errs
3546 *
3547 * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
3548 * (notice that the start points for OFDM are at or close to settings for
3549 * maximum sensitivity):
3550 *
3551 * START / MIN / MAX
3552 * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120
3553 * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210
3554 * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140
3555 * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270
3556 *
3557 * If actual rate of OFDM false alarms (+ plcp_errors) is too high
3558 * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
3559 * by *adding* 1 to all 4 of the table entries above, up to the max for
3560 * each entry. Conversely, if false alarm rate is too low (less than 5
3561 * for each 204.8 msecs listening), *subtract* 1 from each entry to
3562 * increase sensitivity.
3563 *
3564 * For CCK sensitivity, keep track of the following:
3565 *
3566 * 1). 20-beacon history of maximum background noise, indicated by
3567 * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
3568 * 3 receivers. For any given beacon, the "silence reference" is
3569 * the maximum of last 60 samples (20 beacons * 3 receivers).
3570 *
3571 * 2). 10-beacon history of strongest signal level, as indicated
3572 * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
3573 * i.e. the strength of the signal through the best receiver at the
3574 * moment. These measurements are "upside down", with lower values
3575 * for stronger signals, so max energy will be *minimum* value.
3576 *
3577 * Then for any given beacon, the driver must determine the *weakest*
3578 * of the strongest signals; this is the minimum level that needs to be
3579 * successfully detected, when using the best receiver at the moment.
3580 * "Max cck energy" is the maximum (higher value means lower energy!)
3581 * of the last 10 minima. Once this is determined, driver must add
3582 * a little margin by adding "6" to it.
3583 *
3584 * 3). Number of consecutive beacon periods with too few false alarms.
3585 * Reset this to 0 at the first beacon period that falls within the
3586 * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
3587 *
3588 * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
3589 * (notice that the start points for CCK are at maximum sensitivity):
3590 *
3591 * START / MIN / MAX
3592 * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200
3593 * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400
3594 * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100
3595 *
3596 * If actual rate of CCK false alarms (+ plcp_errors) is too high
3597 * (greater than 50 for each 204.8 msecs listening), method for reducing
3598 * sensitivity is:
3599 *
3600 * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3601 * up to max 400.
3602 *
3603 * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
3604 * sensitivity has been reduced a significant amount; bring it up to
3605 * a moderate 161. Otherwise, *add* 3, up to max 200.
3606 *
3607 * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
3608 * sensitivity has been reduced only a moderate or small amount;
3609 * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
3610 * down to min 0. Otherwise (if gain has been significantly reduced),
3611 * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
3612 *
3613 * b) Save a snapshot of the "silence reference".
3614 *
3615 * If actual rate of CCK false alarms (+ plcp_errors) is too low
3616 * (less than 5 for each 204.8 msecs listening), method for increasing
3617 * sensitivity is used only if:
3618 *
3619 * 1a) Previous beacon did not have too many false alarms
3620 * 1b) AND difference between previous "silence reference" and current
3621 * "silence reference" (prev - current) is 2 or more,
3622 * OR 2) 100 or more consecutive beacon periods have had rate of
3623 * less than 5 false alarms per 204.8 milliseconds rx time.
3624 *
3625 * Method for increasing sensitivity:
3626 *
3627 * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
3628 * down to min 125.
3629 *
3630 * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3631 * down to min 200.
3632 *
3633 * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
3634 *
3635 * If actual rate of CCK false alarms (+ plcp_errors) is within good range
3636 * (between 5 and 50 for each 204.8 msecs listening):
3637 *
3638 * 1) Save a snapshot of the silence reference.
3639 *
3640 * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
3641 * give some extra margin to energy threshold by *subtracting* 8
3642 * from value in HD_MIN_ENERGY_CCK_DET_INDEX.
3643 *
3644 * For all cases (too few, too many, good range), make sure that the CCK
3645 * detection threshold (energy) is below the energy level for robust
3646 * detection over the past 10 beacon periods, the "Max cck energy".
3647 * Lower values mean higher energy; this means making sure that the value
3648 * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
3649 *
3650 */
3651
3652 /*
3653 * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
3654 */
3655 #define HD_TABLE_SIZE (11) /* number of entries */
3656 #define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */
3657 #define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
3658 #define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
3659 #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
3660 #define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
3661 #define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
3662 #define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
3663 #define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
3664 #define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
3665 #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
3666 #define HD_OFDM_ENERGY_TH_IN_INDEX (10)
3667
3668 /*
3669 * Additional table entries in enhance SENSITIVITY_CMD
3670 */
3671 #define HD_INA_NON_SQUARE_DET_OFDM_INDEX (11)
3672 #define HD_INA_NON_SQUARE_DET_CCK_INDEX (12)
3673 #define HD_CORR_11_INSTEAD_OF_CORR_9_EN_INDEX (13)
3674 #define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_INDEX (14)
3675 #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (15)
3676 #define HD_OFDM_NON_SQUARE_DET_SLOPE_INDEX (16)
3677 #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_INDEX (17)
3678 #define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_INDEX (18)
3679 #define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (19)
3680 #define HD_CCK_NON_SQUARE_DET_SLOPE_INDEX (20)
3681 #define HD_CCK_NON_SQUARE_DET_INTERCEPT_INDEX (21)
3682 #define HD_RESERVED (22)
3683
3684 /* number of entries for enhanced tbl */
3685 #define ENHANCE_HD_TABLE_SIZE (23)
3686
3687 /* number of additional entries for enhanced tbl */
3688 #define ENHANCE_HD_TABLE_ENTRIES (ENHANCE_HD_TABLE_SIZE - HD_TABLE_SIZE)
3689
3690 #define HD_INA_NON_SQUARE_DET_OFDM_DATA cpu_to_le16(0)
3691 #define HD_INA_NON_SQUARE_DET_CCK_DATA cpu_to_le16(0)
3692 #define HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA cpu_to_le16(0)
3693 #define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(668)
3694 #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3695 #define HD_OFDM_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(486)
3696 #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(37)
3697 #define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(853)
3698 #define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3699 #define HD_CCK_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(476)
3700 #define HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(99)
3701
3702
3703 /* Control field in struct iwl_sensitivity_cmd */
3704 #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0)
3705 #define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1)
3706
3707 /**
3708 * struct iwl_sensitivity_cmd
3709 * @control: (1) updates working table, (0) updates default table
3710 * @table: energy threshold values, use HD_* as index into table
3711 *
3712 * Always use "1" in "control" to update uCode's working table and DSP.
3713 */
3714 struct iwl_sensitivity_cmd {
3715 __le16 control; /* always use "1" */
3716 __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
3717 } __packed;
3718
3719 /*
3720 *
3721 */
3722 struct iwl_enhance_sensitivity_cmd {
3723 __le16 control; /* always use "1" */
3724 __le16 enhance_table[ENHANCE_HD_TABLE_SIZE]; /* use HD_* as index */
3725 } __packed;
3726
3727
3728 /**
3729 * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
3730 *
3731 * This command sets the relative gains of agn device's 3 radio receiver chains.
3732 *
3733 * After the first association, driver should accumulate signal and noise
3734 * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
3735 * beacons from the associated network (don't collect statistics that come
3736 * in from scanning, or any other non-network source).
3737 *
3738 * DISCONNECTED ANTENNA:
3739 *
3740 * Driver should determine which antennas are actually connected, by comparing
3741 * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
3742 * following values over 20 beacons, one accumulator for each of the chains
3743 * a/b/c, from struct statistics_rx_non_phy:
3744 *
3745 * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
3746 *
3747 * Find the strongest signal from among a/b/c. Compare the other two to the
3748 * strongest. If any signal is more than 15 dB (times 20, unless you
3749 * divide the accumulated values by 20) below the strongest, the driver
3750 * considers that antenna to be disconnected, and should not try to use that
3751 * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
3752 * driver should declare the stronger one as connected, and attempt to use it
3753 * (A and B are the only 2 Tx chains!).
3754 *
3755 *
3756 * RX BALANCE:
3757 *
3758 * Driver should balance the 3 receivers (but just the ones that are connected
3759 * to antennas, see above) for gain, by comparing the average signal levels
3760 * detected during the silence after each beacon (background noise).
3761 * Accumulate (add) the following values over 20 beacons, one accumulator for
3762 * each of the chains a/b/c, from struct statistics_rx_non_phy:
3763 *
3764 * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
3765 *
3766 * Find the weakest background noise level from among a/b/c. This Rx chain
3767 * will be the reference, with 0 gain adjustment. Attenuate other channels by
3768 * finding noise difference:
3769 *
3770 * (accum_noise[i] - accum_noise[reference]) / 30
3771 *
3772 * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
3773 * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
3774 * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
3775 * and set bit 2 to indicate "reduce gain". The value for the reference
3776 * (weakest) chain should be "0".
3777 *
3778 * diff_gain_[abc] bit fields:
3779 * 2: (1) reduce gain, (0) increase gain
3780 * 1-0: amount of gain, units of 1.5 dB
3781 */
3782
3783 /* Phy calibration command for series */
3784
3785 enum {
3786 IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7,
3787 IWL_PHY_CALIBRATE_DC_CMD = 8,
3788 IWL_PHY_CALIBRATE_LO_CMD = 9,
3789 IWL_PHY_CALIBRATE_TX_IQ_CMD = 11,
3790 IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15,
3791 IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16,
3792 IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17,
3793 IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 18,
3794 };
3795
3796 #define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253)
3797
3798 #define IWL_CALIB_INIT_CFG_ALL cpu_to_le32(0xffffffff)
3799
3800 struct iwl_calib_cfg_elmnt_s {
3801 __le32 is_enable;
3802 __le32 start;
3803 __le32 send_res;
3804 __le32 apply_res;
3805 __le32 reserved;
3806 } __packed;
3807
3808 struct iwl_calib_cfg_status_s {
3809 struct iwl_calib_cfg_elmnt_s once;
3810 struct iwl_calib_cfg_elmnt_s perd;
3811 __le32 flags;
3812 } __packed;
3813
3814 struct iwl_calib_cfg_cmd {
3815 struct iwl_calib_cfg_status_s ucd_calib_cfg;
3816 struct iwl_calib_cfg_status_s drv_calib_cfg;
3817 __le32 reserved1;
3818 } __packed;
3819
3820 struct iwl_calib_hdr {
3821 u8 op_code;
3822 u8 first_group;
3823 u8 groups_num;
3824 u8 data_valid;
3825 } __packed;
3826
3827 struct iwl_calib_cmd {
3828 struct iwl_calib_hdr hdr;
3829 u8 data[0];
3830 } __packed;
3831
3832 /* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
3833 struct iwl_calib_diff_gain_cmd {
3834 struct iwl_calib_hdr hdr;
3835 s8 diff_gain_a; /* see above */
3836 s8 diff_gain_b;
3837 s8 diff_gain_c;
3838 u8 reserved1;
3839 } __packed;
3840
3841 struct iwl_calib_xtal_freq_cmd {
3842 struct iwl_calib_hdr hdr;
3843 u8 cap_pin1;
3844 u8 cap_pin2;
3845 u8 pad[2];
3846 } __packed;
3847
3848 /* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
3849 struct iwl_calib_chain_noise_reset_cmd {
3850 struct iwl_calib_hdr hdr;
3851 u8 data[0];
3852 };
3853
3854 /* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
3855 struct iwl_calib_chain_noise_gain_cmd {
3856 struct iwl_calib_hdr hdr;
3857 u8 delta_gain_1;
3858 u8 delta_gain_2;
3859 u8 pad[2];
3860 } __packed;
3861
3862 /******************************************************************************
3863 * (12)
3864 * Miscellaneous Commands:
3865 *
3866 *****************************************************************************/
3867
3868 /*
3869 * LEDs Command & Response
3870 * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
3871 *
3872 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
3873 * this command turns it on or off, or sets up a periodic blinking cycle.
3874 */
3875 struct iwl_led_cmd {
3876 __le32 interval; /* "interval" in uSec */
3877 u8 id; /* 1: Activity, 2: Link, 3: Tech */
3878 u8 off; /* # intervals off while blinking;
3879 * "0", with >0 "on" value, turns LED on */
3880 u8 on; /* # intervals on while blinking;
3881 * "0", regardless of "off", turns LED off */
3882 u8 reserved;
3883 } __packed;
3884
3885 /*
3886 * station priority table entries
3887 * also used as potential "events" value for both
3888 * COEX_MEDIUM_NOTIFICATION and COEX_EVENT_CMD
3889 */
3890
3891 /*
3892 * COEX events entry flag masks
3893 * RP - Requested Priority
3894 * WP - Win Medium Priority: priority assigned when the contention has been won
3895 */
3896 #define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG (0x1)
3897 #define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG (0x2)
3898 #define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG (0x4)
3899
3900 #define COEX_CU_UNASSOC_IDLE_RP 4
3901 #define COEX_CU_UNASSOC_MANUAL_SCAN_RP 4
3902 #define COEX_CU_UNASSOC_AUTO_SCAN_RP 4
3903 #define COEX_CU_CALIBRATION_RP 4
3904 #define COEX_CU_PERIODIC_CALIBRATION_RP 4
3905 #define COEX_CU_CONNECTION_ESTAB_RP 4
3906 #define COEX_CU_ASSOCIATED_IDLE_RP 4
3907 #define COEX_CU_ASSOC_MANUAL_SCAN_RP 4
3908 #define COEX_CU_ASSOC_AUTO_SCAN_RP 4
3909 #define COEX_CU_ASSOC_ACTIVE_LEVEL_RP 4
3910 #define COEX_CU_RF_ON_RP 6
3911 #define COEX_CU_RF_OFF_RP 4
3912 #define COEX_CU_STAND_ALONE_DEBUG_RP 6
3913 #define COEX_CU_IPAN_ASSOC_LEVEL_RP 4
3914 #define COEX_CU_RSRVD1_RP 4
3915 #define COEX_CU_RSRVD2_RP 4
3916
3917 #define COEX_CU_UNASSOC_IDLE_WP 3
3918 #define COEX_CU_UNASSOC_MANUAL_SCAN_WP 3
3919 #define COEX_CU_UNASSOC_AUTO_SCAN_WP 3
3920 #define COEX_CU_CALIBRATION_WP 3
3921 #define COEX_CU_PERIODIC_CALIBRATION_WP 3
3922 #define COEX_CU_CONNECTION_ESTAB_WP 3
3923 #define COEX_CU_ASSOCIATED_IDLE_WP 3
3924 #define COEX_CU_ASSOC_MANUAL_SCAN_WP 3
3925 #define COEX_CU_ASSOC_AUTO_SCAN_WP 3
3926 #define COEX_CU_ASSOC_ACTIVE_LEVEL_WP 3
3927 #define COEX_CU_RF_ON_WP 3
3928 #define COEX_CU_RF_OFF_WP 3
3929 #define COEX_CU_STAND_ALONE_DEBUG_WP 6
3930 #define COEX_CU_IPAN_ASSOC_LEVEL_WP 3
3931 #define COEX_CU_RSRVD1_WP 3
3932 #define COEX_CU_RSRVD2_WP 3
3933
3934 #define COEX_UNASSOC_IDLE_FLAGS 0
3935 #define COEX_UNASSOC_MANUAL_SCAN_FLAGS \
3936 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3937 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3938 #define COEX_UNASSOC_AUTO_SCAN_FLAGS \
3939 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3940 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3941 #define COEX_CALIBRATION_FLAGS \
3942 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3943 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3944 #define COEX_PERIODIC_CALIBRATION_FLAGS 0
3945 /*
3946 * COEX_CONNECTION_ESTAB:
3947 * we need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
3948 */
3949 #define COEX_CONNECTION_ESTAB_FLAGS \
3950 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3951 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3952 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
3953 #define COEX_ASSOCIATED_IDLE_FLAGS 0
3954 #define COEX_ASSOC_MANUAL_SCAN_FLAGS \
3955 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3956 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3957 #define COEX_ASSOC_AUTO_SCAN_FLAGS \
3958 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3959 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3960 #define COEX_ASSOC_ACTIVE_LEVEL_FLAGS 0
3961 #define COEX_RF_ON_FLAGS 0
3962 #define COEX_RF_OFF_FLAGS 0
3963 #define COEX_STAND_ALONE_DEBUG_FLAGS \
3964 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3965 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3966 #define COEX_IPAN_ASSOC_LEVEL_FLAGS \
3967 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3968 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3969 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
3970 #define COEX_RSRVD1_FLAGS 0
3971 #define COEX_RSRVD2_FLAGS 0
3972 /*
3973 * COEX_CU_RF_ON is the event wrapping all radio ownership.
3974 * We need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
3975 */
3976 #define COEX_CU_RF_ON_FLAGS \
3977 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3978 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3979 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
3980
3981
3982 enum {
3983 /* un-association part */
3984 COEX_UNASSOC_IDLE = 0,
3985 COEX_UNASSOC_MANUAL_SCAN = 1,
3986 COEX_UNASSOC_AUTO_SCAN = 2,
3987 /* calibration */
3988 COEX_CALIBRATION = 3,
3989 COEX_PERIODIC_CALIBRATION = 4,
3990 /* connection */
3991 COEX_CONNECTION_ESTAB = 5,
3992 /* association part */
3993 COEX_ASSOCIATED_IDLE = 6,
3994 COEX_ASSOC_MANUAL_SCAN = 7,
3995 COEX_ASSOC_AUTO_SCAN = 8,
3996 COEX_ASSOC_ACTIVE_LEVEL = 9,
3997 /* RF ON/OFF */
3998 COEX_RF_ON = 10,
3999 COEX_RF_OFF = 11,
4000 COEX_STAND_ALONE_DEBUG = 12,
4001 /* IPAN */
4002 COEX_IPAN_ASSOC_LEVEL = 13,
4003 /* reserved */
4004 COEX_RSRVD1 = 14,
4005 COEX_RSRVD2 = 15,
4006 COEX_NUM_OF_EVENTS = 16
4007 };
4008
4009 /*
4010 * Coexistence WIFI/WIMAX Command
4011 * COEX_PRIORITY_TABLE_CMD = 0x5a
4012 *
4013 */
4014 struct iwl_wimax_coex_event_entry {
4015 u8 request_prio;
4016 u8 win_medium_prio;
4017 u8 reserved;
4018 u8 flags;
4019 } __packed;
4020
4021 /* COEX flag masks */
4022
4023 /* Station table is valid */
4024 #define COEX_FLAGS_STA_TABLE_VALID_MSK (0x1)
4025 /* UnMask wake up src at unassociated sleep */
4026 #define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK (0x4)
4027 /* UnMask wake up src at associated sleep */
4028 #define COEX_FLAGS_ASSOC_WA_UNMASK_MSK (0x8)
4029 /* Enable CoEx feature. */
4030 #define COEX_FLAGS_COEX_ENABLE_MSK (0x80)
4031
4032 struct iwl_wimax_coex_cmd {
4033 u8 flags;
4034 u8 reserved[3];
4035 struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
4036 } __packed;
4037
4038 /*
4039 * Coexistence MEDIUM NOTIFICATION
4040 * COEX_MEDIUM_NOTIFICATION = 0x5b
4041 *
4042 * notification from uCode to host to indicate medium changes
4043 *
4044 */
4045 /*
4046 * status field
4047 * bit 0 - 2: medium status
4048 * bit 3: medium change indication
4049 * bit 4 - 31: reserved
4050 */
4051 /* status option values, (0 - 2 bits) */
4052 #define COEX_MEDIUM_BUSY (0x0) /* radio belongs to WiMAX */
4053 #define COEX_MEDIUM_ACTIVE (0x1) /* radio belongs to WiFi */
4054 #define COEX_MEDIUM_PRE_RELEASE (0x2) /* received radio release */
4055 #define COEX_MEDIUM_MSK (0x7)
4056
4057 /* send notification status (1 bit) */
4058 #define COEX_MEDIUM_CHANGED (0x8)
4059 #define COEX_MEDIUM_CHANGED_MSK (0x8)
4060 #define COEX_MEDIUM_SHIFT (3)
4061
4062 struct iwl_coex_medium_notification {
4063 __le32 status;
4064 __le32 events;
4065 } __packed;
4066
4067 /*
4068 * Coexistence EVENT Command
4069 * COEX_EVENT_CMD = 0x5c
4070 *
4071 * send from host to uCode for coex event request.
4072 */
4073 /* flags options */
4074 #define COEX_EVENT_REQUEST_MSK (0x1)
4075
4076 struct iwl_coex_event_cmd {
4077 u8 flags;
4078 u8 event;
4079 __le16 reserved;
4080 } __packed;
4081
4082 struct iwl_coex_event_resp {
4083 __le32 status;
4084 } __packed;
4085
4086
4087 /******************************************************************************
4088 * Bluetooth Coexistence commands
4089 *
4090 *****************************************************************************/
4091
4092 /*
4093 * BT Status notification
4094 * REPLY_BT_COEX_PROFILE_NOTIF = 0xce
4095 */
4096 enum iwl_bt_coex_profile_traffic_load {
4097 IWL_BT_COEX_TRAFFIC_LOAD_NONE = 0,
4098 IWL_BT_COEX_TRAFFIC_LOAD_LOW = 1,
4099 IWL_BT_COEX_TRAFFIC_LOAD_HIGH = 2,
4100 IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS = 3,
4101 /*
4102 * There are no more even though below is a u8, the
4103 * indication from the BT device only has two bits.
4104 */
4105 };
4106
4107 #define BT_UART_MSG_FRAME1MSGTYPE_POS (0)
4108 #define BT_UART_MSG_FRAME1MSGTYPE_MSK \
4109 (0x7 << BT_UART_MSG_FRAME1MSGTYPE_POS)
4110 #define BT_UART_MSG_FRAME1SSN_POS (3)
4111 #define BT_UART_MSG_FRAME1SSN_MSK \
4112 (0x3 << BT_UART_MSG_FRAME1SSN_POS)
4113 #define BT_UART_MSG_FRAME1UPDATEREQ_POS (5)
4114 #define BT_UART_MSG_FRAME1UPDATEREQ_MSK \
4115 (0x1 << BT_UART_MSG_FRAME1UPDATEREQ_POS)
4116 #define BT_UART_MSG_FRAME1RESERVED_POS (6)
4117 #define BT_UART_MSG_FRAME1RESERVED_MSK \
4118 (0x3 << BT_UART_MSG_FRAME1RESERVED_POS)
4119
4120 #define BT_UART_MSG_FRAME2OPENCONNECTIONS_POS (0)
4121 #define BT_UART_MSG_FRAME2OPENCONNECTIONS_MSK \
4122 (0x3 << BT_UART_MSG_FRAME2OPENCONNECTIONS_POS)
4123 #define BT_UART_MSG_FRAME2TRAFFICLOAD_POS (2)
4124 #define BT_UART_MSG_FRAME2TRAFFICLOAD_MSK \
4125 (0x3 << BT_UART_MSG_FRAME2TRAFFICLOAD_POS)
4126 #define BT_UART_MSG_FRAME2CHLSEQN_POS (4)
4127 #define BT_UART_MSG_FRAME2CHLSEQN_MSK \
4128 (0x1 << BT_UART_MSG_FRAME2CHLSEQN_POS)
4129 #define BT_UART_MSG_FRAME2INBAND_POS (5)
4130 #define BT_UART_MSG_FRAME2INBAND_MSK \
4131 (0x1 << BT_UART_MSG_FRAME2INBAND_POS)
4132 #define BT_UART_MSG_FRAME2RESERVED_POS (6)
4133 #define BT_UART_MSG_FRAME2RESERVED_MSK \
4134 (0x3 << BT_UART_MSG_FRAME2RESERVED_POS)
4135
4136 #define BT_UART_MSG_FRAME3SCOESCO_POS (0)
4137 #define BT_UART_MSG_FRAME3SCOESCO_MSK \
4138 (0x1 << BT_UART_MSG_FRAME3SCOESCO_POS)
4139 #define BT_UART_MSG_FRAME3SNIFF_POS (1)
4140 #define BT_UART_MSG_FRAME3SNIFF_MSK \
4141 (0x1 << BT_UART_MSG_FRAME3SNIFF_POS)
4142 #define BT_UART_MSG_FRAME3A2DP_POS (2)
4143 #define BT_UART_MSG_FRAME3A2DP_MSK \
4144 (0x1 << BT_UART_MSG_FRAME3A2DP_POS)
4145 #define BT_UART_MSG_FRAME3ACL_POS (3)
4146 #define BT_UART_MSG_FRAME3ACL_MSK \
4147 (0x1 << BT_UART_MSG_FRAME3ACL_POS)
4148 #define BT_UART_MSG_FRAME3MASTER_POS (4)
4149 #define BT_UART_MSG_FRAME3MASTER_MSK \
4150 (0x1 << BT_UART_MSG_FRAME3MASTER_POS)
4151 #define BT_UART_MSG_FRAME3OBEX_POS (5)
4152 #define BT_UART_MSG_FRAME3OBEX_MSK \
4153 (0x1 << BT_UART_MSG_FRAME3OBEX_POS)
4154 #define BT_UART_MSG_FRAME3RESERVED_POS (6)
4155 #define BT_UART_MSG_FRAME3RESERVED_MSK \
4156 (0x3 << BT_UART_MSG_FRAME3RESERVED_POS)
4157
4158 #define BT_UART_MSG_FRAME4IDLEDURATION_POS (0)
4159 #define BT_UART_MSG_FRAME4IDLEDURATION_MSK \
4160 (0x3F << BT_UART_MSG_FRAME4IDLEDURATION_POS)
4161 #define BT_UART_MSG_FRAME4RESERVED_POS (6)
4162 #define BT_UART_MSG_FRAME4RESERVED_MSK \
4163 (0x3 << BT_UART_MSG_FRAME4RESERVED_POS)
4164
4165 #define BT_UART_MSG_FRAME5TXACTIVITY_POS (0)
4166 #define BT_UART_MSG_FRAME5TXACTIVITY_MSK \
4167 (0x3 << BT_UART_MSG_FRAME5TXACTIVITY_POS)
4168 #define BT_UART_MSG_FRAME5RXACTIVITY_POS (2)
4169 #define BT_UART_MSG_FRAME5RXACTIVITY_MSK \
4170 (0x3 << BT_UART_MSG_FRAME5RXACTIVITY_POS)
4171 #define BT_UART_MSG_FRAME5ESCORETRANSMIT_POS (4)
4172 #define BT_UART_MSG_FRAME5ESCORETRANSMIT_MSK \
4173 (0x3 << BT_UART_MSG_FRAME5ESCORETRANSMIT_POS)
4174 #define BT_UART_MSG_FRAME5RESERVED_POS (6)
4175 #define BT_UART_MSG_FRAME5RESERVED_MSK \
4176 (0x3 << BT_UART_MSG_FRAME5RESERVED_POS)
4177
4178 #define BT_UART_MSG_FRAME6SNIFFINTERVAL_POS (0)
4179 #define BT_UART_MSG_FRAME6SNIFFINTERVAL_MSK \
4180 (0x1F << BT_UART_MSG_FRAME6SNIFFINTERVAL_POS)
4181 #define BT_UART_MSG_FRAME6DISCOVERABLE_POS (5)
4182 #define BT_UART_MSG_FRAME6DISCOVERABLE_MSK \
4183 (0x1 << BT_UART_MSG_FRAME6DISCOVERABLE_POS)
4184 #define BT_UART_MSG_FRAME6RESERVED_POS (6)
4185 #define BT_UART_MSG_FRAME6RESERVED_MSK \
4186 (0x3 << BT_UART_MSG_FRAME6RESERVED_POS)
4187
4188 #define BT_UART_MSG_FRAME7SNIFFACTIVITY_POS (0)
4189 #define BT_UART_MSG_FRAME7SNIFFACTIVITY_MSK \
4190 (0x7 << BT_UART_MSG_FRAME7SNIFFACTIVITY_POS)
4191 #define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS (3)
4192 #define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_MSK \
4193 (0x3 << BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS)
4194 #define BT_UART_MSG_FRAME7CONNECTABLE_POS (5)
4195 #define BT_UART_MSG_FRAME7CONNECTABLE_MSK \
4196 (0x1 << BT_UART_MSG_FRAME7CONNECTABLE_POS)
4197 #define BT_UART_MSG_FRAME7RESERVED_POS (6)
4198 #define BT_UART_MSG_FRAME7RESERVED_MSK \
4199 (0x3 << BT_UART_MSG_FRAME7RESERVED_POS)
4200
4201
4202 struct iwl_bt_uart_msg {
4203 u8 header;
4204 u8 frame1;
4205 u8 frame2;
4206 u8 frame3;
4207 u8 frame4;
4208 u8 frame5;
4209 u8 frame6;
4210 u8 frame7;
4211 } __attribute__((packed));
4212
4213 struct iwl_bt_coex_profile_notif {
4214 struct iwl_bt_uart_msg last_bt_uart_msg;
4215 u8 bt_status; /* 0 - off, 1 - on */
4216 u8 bt_traffic_load; /* 0 .. 3? */
4217 u8 bt_ci_compliance; /* 0 - not complied, 1 - complied */
4218 u8 reserved;
4219 } __attribute__((packed));
4220
4221 #define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS 0
4222 #define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_MSK 0x1
4223 #define IWL_BT_COEX_PRIO_TBL_PRIO_POS 1
4224 #define IWL_BT_COEX_PRIO_TBL_PRIO_MASK 0x0e
4225 #define IWL_BT_COEX_PRIO_TBL_RESERVED_POS 4
4226 #define IWL_BT_COEX_PRIO_TBL_RESERVED_MASK 0xf0
4227 #define IWL_BT_COEX_PRIO_TBL_PRIO_SHIFT 1
4228
4229 /*
4230 * BT Coexistence Priority table
4231 * REPLY_BT_COEX_PRIO_TABLE = 0xcc
4232 */
4233 enum bt_coex_prio_table_events {
4234 BT_COEX_PRIO_TBL_EVT_INIT_CALIB1 = 0,
4235 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2 = 1,
4236 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW1 = 2,
4237 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW2 = 3, /* DC calib */
4238 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH1 = 4,
4239 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH2 = 5,
4240 BT_COEX_PRIO_TBL_EVT_DTIM = 6,
4241 BT_COEX_PRIO_TBL_EVT_SCAN52 = 7,
4242 BT_COEX_PRIO_TBL_EVT_SCAN24 = 8,
4243 BT_COEX_PRIO_TBL_EVT_RESERVED0 = 9,
4244 BT_COEX_PRIO_TBL_EVT_RESERVED1 = 10,
4245 BT_COEX_PRIO_TBL_EVT_RESERVED2 = 11,
4246 BT_COEX_PRIO_TBL_EVT_RESERVED3 = 12,
4247 BT_COEX_PRIO_TBL_EVT_RESERVED4 = 13,
4248 BT_COEX_PRIO_TBL_EVT_RESERVED5 = 14,
4249 BT_COEX_PRIO_TBL_EVT_RESERVED6 = 15,
4250 /* BT_COEX_PRIO_TBL_EVT_MAX should always be last */
4251 BT_COEX_PRIO_TBL_EVT_MAX,
4252 };
4253
4254 enum bt_coex_prio_table_priorities {
4255 BT_COEX_PRIO_TBL_DISABLED = 0,
4256 BT_COEX_PRIO_TBL_PRIO_LOW = 1,
4257 BT_COEX_PRIO_TBL_PRIO_HIGH = 2,
4258 BT_COEX_PRIO_TBL_PRIO_BYPASS = 3,
4259 BT_COEX_PRIO_TBL_PRIO_COEX_OFF = 4,
4260 BT_COEX_PRIO_TBL_PRIO_COEX_ON = 5,
4261 BT_COEX_PRIO_TBL_PRIO_RSRVD1 = 6,
4262 BT_COEX_PRIO_TBL_PRIO_RSRVD2 = 7,
4263 BT_COEX_PRIO_TBL_MAX,
4264 };
4265
4266 struct iwl_bt_coex_prio_table_cmd {
4267 u8 prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX];
4268 } __attribute__((packed));
4269
4270 #define IWL_BT_COEX_ENV_CLOSE 0
4271 #define IWL_BT_COEX_ENV_OPEN 1
4272 /*
4273 * BT Protection Envelope
4274 * REPLY_BT_COEX_PROT_ENV = 0xcd
4275 */
4276 struct iwl_bt_coex_prot_env_cmd {
4277 u8 action; /* 0 = closed, 1 = open */
4278 u8 type; /* 0 .. 15 */
4279 u8 reserved[2];
4280 } __attribute__((packed));
4281
4282 /******************************************************************************
4283 * (13)
4284 * Union of all expected notifications/responses:
4285 *
4286 *****************************************************************************/
4287
4288 struct iwl_rx_packet {
4289 /*
4290 * The first 4 bytes of the RX frame header contain both the RX frame
4291 * size and some flags.
4292 * Bit fields:
4293 * 31: flag flush RB request
4294 * 30: flag ignore TC (terminal counter) request
4295 * 29: flag fast IRQ request
4296 * 28-14: Reserved
4297 * 13-00: RX frame size
4298 */
4299 __le32 len_n_flags;
4300 struct iwl_cmd_header hdr;
4301 union {
4302 struct iwl3945_rx_frame rx_frame;
4303 struct iwl3945_tx_resp tx_resp;
4304 struct iwl3945_beacon_notif beacon_status;
4305
4306 struct iwl_alive_resp alive_frame;
4307 struct iwl_spectrum_notification spectrum_notif;
4308 struct iwl_csa_notification csa_notif;
4309 struct iwl_error_resp err_resp;
4310 struct iwl_card_state_notif card_state_notif;
4311 struct iwl_add_sta_resp add_sta;
4312 struct iwl_rem_sta_resp rem_sta;
4313 struct iwl_sleep_notification sleep_notif;
4314 struct iwl_spectrum_resp spectrum;
4315 struct iwl_notif_statistics stats;
4316 struct iwl_bt_notif_statistics stats_bt;
4317 struct iwl_compressed_ba_resp compressed_ba;
4318 struct iwl_missed_beacon_notif missed_beacon;
4319 struct iwl_coex_medium_notification coex_medium_notif;
4320 struct iwl_coex_event_resp coex_event;
4321 struct iwl_bt_coex_profile_notif bt_coex_profile_notif;
4322 __le32 status;
4323 u8 raw[0];
4324 } u;
4325 } __packed;
4326
4327 int iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
4328
4329 /*
4330 * REPLY_WIPAN_PARAMS = 0xb2 (Commands and Notification)
4331 */
4332
4333 /**
4334 * struct iwl_wipan_slot
4335 * @width: Time in TU
4336 * @type:
4337 * 0 - BSS
4338 * 1 - PAN
4339 */
4340 struct iwl_wipan_slot {
4341 __le16 width;
4342 u8 type;
4343 u8 reserved;
4344 } __packed;
4345
4346 #define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_CTS BIT(1) /* reserved */
4347 #define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_QUIET BIT(2) /* reserved */
4348 #define IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE BIT(3) /* reserved */
4349 #define IWL_WIPAN_PARAMS_FLG_FILTER_BEACON_NOTIF BIT(4)
4350 #define IWL_WIPAN_PARAMS_FLG_FULL_SLOTTED_MODE BIT(5)
4351
4352 /**
4353 * struct iwl_wipan_params_cmd
4354 * @flags:
4355 * bit0: reserved
4356 * bit1: CP leave channel with CTS
4357 * bit2: CP leave channel qith Quiet
4358 * bit3: slotted mode
4359 * 1 - work in slotted mode
4360 * 0 - work in non slotted mode
4361 * bit4: filter beacon notification
4362 * bit5: full tx slotted mode. if this flag is set,
4363 * uCode will perform leaving channel methods in context switch
4364 * also when working in same channel mode
4365 * @num_slots: 1 - 10
4366 */
4367 struct iwl_wipan_params_cmd {
4368 __le16 flags;
4369 u8 reserved;
4370 u8 num_slots;
4371 struct iwl_wipan_slot slots[10];
4372 } __packed;
4373
4374 /*
4375 * REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9
4376 *
4377 * TODO: Figure out what this is used for,
4378 * it can only switch between 2.4 GHz
4379 * channels!!
4380 */
4381
4382 struct iwl_wipan_p2p_channel_switch_cmd {
4383 __le16 channel;
4384 __le16 reserved;
4385 };
4386
4387 /*
4388 * REPLY_WIPAN_NOA_NOTIFICATION = 0xbc
4389 *
4390 * This is used by the device to notify us of the
4391 * NoA schedule it determined so we can forward it
4392 * to userspace for inclusion in probe responses.
4393 *
4394 * In beacons, the NoA schedule is simply appended
4395 * to the frame we give the device.
4396 */
4397
4398 struct iwl_wipan_noa_descriptor {
4399 u8 count;
4400 __le32 duration;
4401 __le32 interval;
4402 __le32 starttime;
4403 } __packed;
4404
4405 struct iwl_wipan_noa_attribute {
4406 u8 id;
4407 __le16 length;
4408 u8 index;
4409 u8 ct_window;
4410 struct iwl_wipan_noa_descriptor descr0, descr1;
4411 u8 reserved;
4412 } __packed;
4413
4414 struct iwl_wipan_noa_notification {
4415 u32 noa_active;
4416 struct iwl_wipan_noa_attribute noa_attribute;
4417 } __packed;
4418
4419 #endif /* __iwl_commands_h__ */
This page took 0.168862 seconds and 4 git commands to generate.