blob: 69fc7745edaad6e9ed971c8b9f332cea0dad7257 [file] [log] [blame]
Zhu Yib481de92007-09-25 17:54:57 -07001/******************************************************************************
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 *
Reinette Chatre1f447802010-01-15 13:43:41 -08008 * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved.
Zhu Yib481de92007-09-25 17:54:57 -07009 *
10 * This program is free software; you can redistribute it and/or modify
Ian Schram01ebd062007-10-25 17:15:22 +080011 * it under the terms of version 2 of the GNU General Public License as
Zhu Yib481de92007-09-25 17:54:57 -070012 * 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:
Winkler, Tomas759ef892008-12-09 11:28:58 -080028 * Intel Linux Wireless <ilw@linux.intel.com>
Zhu Yib481de92007-09-25 17:54:57 -070029 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
Reinette Chatre1f447802010-01-15 13:43:41 -080033 * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved.
Zhu Yib481de92007-09-25 17:54:57 -070034 * 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 *****************************************************************************/
Ben Cahillfcd427b2007-11-29 11:10:00 +080063/*
Tomas Winkler5a36ba02008-04-24 11:55:37 -070064 * Please use this file (iwl-commands.h) only for uCode API definitions.
Wey-Yi Guy767d0552010-08-23 07:56:53 -070065 * Please use iwl-xxxx-hw.h for hardware-related definitions.
Tomas Winkler3e0d4cb2008-04-24 11:55:38 -070066 * Please use iwl-dev.h for driver implementation definitions.
Ben Cahillfcd427b2007-11-29 11:10:00 +080067 */
Zhu Yib481de92007-09-25 17:54:57 -070068
Emmanuel Grumbach6a635782008-10-29 14:05:47 -070069#ifndef __iwl_commands_h__
70#define __iwl_commands_h__
Zhu Yib481de92007-09-25 17:54:57 -070071
Samuel Ortiza3139c52008-12-19 10:37:09 +080072struct iwl_priv;
73
Chatre, Reinettec02b3ac2008-12-02 12:14:05 -080074/* 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
Tomas Winkler4c897252008-12-19 10:37:05 +080080
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
Zhu Yib481de92007-09-25 17:54:57 -070086enum {
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,
Wey-Yi Guyfc66be22010-05-14 16:21:55 -070098 REPLY_REMOVE_STA = 0x19,
Zhu Yib481de92007-09-25 17:54:57 -070099 REPLY_REMOVE_ALL_STA = 0x1a, /* not used */
Wey-Yi Guy947279e2010-06-24 13:18:33 -0700100 REPLY_TXFIFO_FLUSH = 0x1e,
Zhu Yib481de92007-09-25 17:54:57 -0700101
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -0700102 /* Security */
103 REPLY_WEPKEY = 0x20,
104
Zhu Yib481de92007-09-25 17:54:57 -0700105 /* RX, TX, LEDs */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -0800106 REPLY_3945_RX = 0x1b, /* 3945 only */
Zhu Yib481de92007-09-25 17:54:57 -0700107 REPLY_TX = 0x1c,
108 REPLY_RATE_SCALE = 0x47, /* 3945 only */
109 REPLY_LEDS_CMD = 0x48,
Wey-Yi Guy4c8d1912010-03-31 18:16:52 -0700110 REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 and up */
Zhu Yib481de92007-09-25 17:54:57 -0700111
Ron Rindjunsky9636e582008-05-15 13:54:14 +0800112 /* WiMAX coexistence */
Wey-Yi Guyd23000c2009-10-23 13:42:36 -0700113 COEX_PRIORITY_TABLE_CMD = 0x5a, /* for 5000 series and up */
Ron Rindjunsky9636e582008-05-15 13:54:14 +0800114 COEX_MEDIUM_NOTIFICATION = 0x5b,
115 COEX_EVENT_CMD = 0x5c,
116
Tomas Winklerbe5d56e2008-10-08 09:37:27 +0800117 /* Calibration */
Jay Sternberg1a5c3d62009-10-23 13:42:19 -0700118 TEMPERATURE_NOTIFICATION = 0x62,
Tomas Winklerbe5d56e2008-10-08 09:37:27 +0800119 CALIBRATION_CFG_CMD = 0x65,
120 CALIBRATION_RES_NOTIFICATION = 0x66,
121 CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
122
Zhu Yib481de92007-09-25 17:54:57 -0700123 /* 802.11h related */
Zhu Yib481de92007-09-25 17:54:57 -0700124 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 */
Jay Sternberg76a24072009-01-29 11:09:14 -0800148 REPLY_TX_POWER_DBM_CMD = 0x95,
Zhu Yib481de92007-09-25 17:54:57 -0700149 QUIET_NOTIFICATION = 0x96, /* not used */
150 REPLY_TX_PWR_TABLE_CMD = 0x97,
Jay Sternberg76a24072009-01-29 11:09:14 -0800151 REPLY_TX_POWER_DBM_CMD_V1 = 0x98, /* old version of API */
Wey-Yi Guy2f748de2009-09-17 10:43:51 -0700152 TX_ANT_CONFIGURATION_CMD = 0x98,
Zhu Yib481de92007-09-25 17:54:57 -0700153 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
154
Tomas Winklera96a27f2008-10-23 23:48:56 -0700155 /* Bluetooth device coexistence config command */
Zhu Yib481de92007-09-25 17:54:57 -0700156 REPLY_BT_CONFIG = 0x9b,
157
Ben Cahill80cc0c32007-11-29 11:10:09 +0800158 /* Statistics */
Zhu Yib481de92007-09-25 17:54:57 -0700159 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
Zhu Yib481de92007-09-25 17:54:57 -0700169 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,
Tomas Winkler857485c2008-03-21 13:53:44 -0700174 REPLY_RX = 0xc3,
Zhu Yib481de92007-09-25 17:54:57 -0700175 REPLY_COMPRESSED_BA = 0xc5,
Johannes Berg0288d232010-08-23 07:56:54 -0700176
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
Zhu Yib481de92007-09-25 17:54:57 -0700182 REPLY_MAX = 0xff
183};
184
185/******************************************************************************
186 * (0)
Ben Cahillabceddb2007-11-29 11:09:50 +0800187 * Commonly used structures and definitions:
Ben Cahill80cc0c32007-11-29 11:10:09 +0800188 * Command header, rate_n_flags, txpower
Zhu Yib481de92007-09-25 17:54:57 -0700189 *
190 *****************************************************************************/
191
Tomas Winkler857485c2008-03-21 13:53:44 -0700192/* iwl_cmd_header flags value */
Zhu Yib481de92007-09-25 17:54:57 -0700193#define IWL_CMD_FAILED_MSK 0x40
194
Tomas Winkler9734cb22008-09-03 11:26:52 +0800195#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f)
196#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8)
197#define SEQ_TO_INDEX(s) ((s) & 0xff)
198#define INDEX_TO_SEQ(i) ((i) & 0xff)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800199#define SEQ_HUGE_FRAME cpu_to_le16(0x4000)
200#define SEQ_RX_FRAME cpu_to_le16(0x8000)
Tomas Winkler9734cb22008-09-03 11:26:52 +0800201
Ben Cahill075416c2007-11-29 11:10:08 +0800202/**
Tomas Winkler857485c2008-03-21 13:53:44 -0700203 * struct iwl_cmd_header
Ben Cahill075416c2007-11-29 11:10:08 +0800204 *
205 * This header format appears in the beginning of each command sent from the
206 * driver, and each response/notification received from uCode.
207 */
Tomas Winkler857485c2008-03-21 13:53:44 -0700208struct iwl_cmd_header {
Ben Cahill075416c2007-11-29 11:10:08 +0800209 u8 cmd; /* Command ID: REPLY_RXON, etc. */
Tomas Winkler9734cb22008-09-03 11:26:52 +0800210 u8 flags; /* 0:5 reserved, 6 abort, 7 internal */
Ben Cahill075416c2007-11-29 11:10:08 +0800211 /*
Tomas Winklera96a27f2008-10-23 23:48:56 -0700212 * The driver sets up the sequence number to values of its choosing.
Ben Cahill075416c2007-11-29 11:10:08 +0800213 * uCode does not use this value, but passes it back to the driver
214 * when sending the response to each driver-originated command, so
215 * the driver can match the response to the command. Since the values
216 * don't get used by uCode, the driver may set up an arbitrary format.
Zhu Yib481de92007-09-25 17:54:57 -0700217 *
Ben Cahill075416c2007-11-29 11:10:08 +0800218 * There is one exception: uCode sets bit 15 when it originates
219 * the response/notification, i.e. when the response/notification
220 * is not a direct response to a command sent by the driver. For
221 * example, uCode issues REPLY_3945_RX when it sends a received frame
222 * to the driver; it is not a direct response to any driver command.
Zhu Yib481de92007-09-25 17:54:57 -0700223 *
Ben Cahill075416c2007-11-29 11:10:08 +0800224 * The Linux driver uses the following format:
225 *
Tomas Winkler9734cb22008-09-03 11:26:52 +0800226 * 0:7 tfd index - position within TX queue
227 * 8:12 TX queue id
228 * 13 reserved
229 * 14 huge - driver sets this to indicate command is in the
230 * 'huge' storage at the end of the command buffers
231 * 15 unsolicited RX or uCode-originated notification
Zhu Yib481de92007-09-25 17:54:57 -0700232 */
233 __le16 sequence;
234
Ben Cahill075416c2007-11-29 11:10:08 +0800235 /* command or response/notification data follows immediately */
Zhu Yib481de92007-09-25 17:54:57 -0700236 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000237} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700238
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800239
240/**
241 * struct iwl3945_tx_power
242 *
243 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH
244 *
245 * Each entry contains two values:
246 * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
247 * linear value that multiplies the output of the digital signal processor,
248 * before being sent to the analog radio.
249 * 2) Radio gain. This sets the analog gain of the radio Tx path.
250 * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
251 *
252 * Driver obtains values from struct iwl3945_tx_power power_gain_table[][].
253 */
254struct iwl3945_tx_power {
255 u8 tx_gain; /* gain for analog radio */
256 u8 dsp_atten; /* gain for DSP */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000257} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800258
259/**
260 * struct iwl3945_power_per_rate
261 *
262 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
263 */
264struct iwl3945_power_per_rate {
265 u8 rate; /* plcp */
266 struct iwl3945_tx_power tpc;
267 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000268} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800269
Ben Cahillabceddb2007-11-29 11:09:50 +0800270/**
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800271 * iwlagn rate_n_flags bit fields
Ben Cahillabceddb2007-11-29 11:09:50 +0800272 *
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800273 * rate_n_flags format is used in following iwlagn commands:
Tomas Winkler857485c2008-03-21 13:53:44 -0700274 * REPLY_RX (response only)
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800275 * REPLY_RX_MPDU (response only)
Ben Cahillabceddb2007-11-29 11:09:50 +0800276 * REPLY_TX (both command and response)
277 * REPLY_TX_LINK_QUALITY_CMD
278 *
279 * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
280 * 2-0: 0) 6 Mbps
281 * 1) 12 Mbps
282 * 2) 18 Mbps
283 * 3) 24 Mbps
284 * 4) 36 Mbps
285 * 5) 48 Mbps
286 * 6) 54 Mbps
287 * 7) 60 Mbps
288 *
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800289 * 4-3: 0) Single stream (SISO)
Ben Cahillabceddb2007-11-29 11:09:50 +0800290 * 1) Dual stream (MIMO)
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800291 * 2) Triple stream (MIMO)
Ben Cahillabceddb2007-11-29 11:09:50 +0800292 *
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700293 * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
Ben Cahillabceddb2007-11-29 11:09:50 +0800294 *
295 * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
296 * 3-0: 0xD) 6 Mbps
297 * 0xF) 9 Mbps
298 * 0x5) 12 Mbps
299 * 0x7) 18 Mbps
300 * 0x9) 24 Mbps
301 * 0xB) 36 Mbps
302 * 0x1) 48 Mbps
303 * 0x3) 54 Mbps
304 *
305 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
Daniel Wu10617872008-12-20 10:53:29 -0800306 * 6-0: 10) 1 Mbps
Ben Cahillabceddb2007-11-29 11:09:50 +0800307 * 20) 2 Mbps
308 * 55) 5.5 Mbps
309 * 110) 11 Mbps
310 */
311#define RATE_MCS_CODE_MSK 0x7
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800312#define RATE_MCS_SPATIAL_POS 3
313#define RATE_MCS_SPATIAL_MSK 0x18
Ben Cahillabceddb2007-11-29 11:09:50 +0800314#define RATE_MCS_HT_DUP_POS 5
315#define RATE_MCS_HT_DUP_MSK 0x20
316
Ben Cahill075416c2007-11-29 11:10:08 +0800317/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
Ben Cahillabceddb2007-11-29 11:09:50 +0800318#define RATE_MCS_FLAGS_POS 8
319#define RATE_MCS_HT_POS 8
320#define RATE_MCS_HT_MSK 0x100
321
Ben Cahill075416c2007-11-29 11:10:08 +0800322/* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */
Ben Cahillabceddb2007-11-29 11:09:50 +0800323#define RATE_MCS_CCK_POS 9
324#define RATE_MCS_CCK_MSK 0x200
325
Ben Cahill075416c2007-11-29 11:10:08 +0800326/* Bit 10: (1) Use Green Field preamble */
Ben Cahillabceddb2007-11-29 11:09:50 +0800327#define RATE_MCS_GF_POS 10
328#define RATE_MCS_GF_MSK 0x400
329
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700330/* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */
331#define RATE_MCS_HT40_POS 11
332#define RATE_MCS_HT40_MSK 0x800
Ben Cahillabceddb2007-11-29 11:09:50 +0800333
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700334/* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */
Ben Cahillabceddb2007-11-29 11:09:50 +0800335#define RATE_MCS_DUP_POS 12
336#define RATE_MCS_DUP_MSK 0x1000
337
Ben Cahill075416c2007-11-29 11:10:08 +0800338/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
Ben Cahillabceddb2007-11-29 11:09:50 +0800339#define RATE_MCS_SGI_POS 13
340#define RATE_MCS_SGI_MSK 0x2000
341
342/**
Tomas Winkler76eff182008-10-14 12:32:45 -0700343 * rate_n_flags Tx antenna masks
344 * 4965 has 2 transmitters
345 * 5100 has 1 transmitter B
346 * 5150 has 1 transmitter A
347 * 5300 has 3 transmitters
348 * 5350 has 3 transmitters
349 * bit14:16
Ben Cahillabceddb2007-11-29 11:09:50 +0800350 */
Tomas Winkler600c0e12008-12-19 10:37:04 +0800351#define RATE_MCS_ANT_POS 14
352#define RATE_MCS_ANT_A_MSK 0x04000
353#define RATE_MCS_ANT_B_MSK 0x08000
354#define RATE_MCS_ANT_C_MSK 0x10000
355#define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK)
356#define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK)
Tomas Winkler76eff182008-10-14 12:32:45 -0700357#define RATE_ANT_NUM 3
Ben Cahill80cc0c32007-11-29 11:10:09 +0800358
359#define POWER_TABLE_NUM_ENTRIES 33
360#define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
361#define POWER_TABLE_CCK_ENTRY 32
362
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700363#define IWL_PWR_NUM_HT_OFDM_ENTRIES 24
364#define IWL_PWR_CCK_ENTRIES 2
365
Ben Cahill80cc0c32007-11-29 11:10:09 +0800366/**
367 * union iwl4965_tx_power_dual_stream
368 *
369 * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
370 * Use __le32 version (struct tx_power_dual_stream) when building command.
371 *
372 * Driver provides radio gain and DSP attenuation settings to device in pairs,
373 * one value for each transmitter chain. The first value is for transmitter A,
374 * second for transmitter B.
375 *
376 * For SISO bit rates, both values in a pair should be identical.
377 * For MIMO rates, one value may be different from the other,
378 * in order to balance the Tx output between the two transmitters.
379 *
380 * See more details in doc for TXPOWER in iwl-4965-hw.h.
381 */
382union iwl4965_tx_power_dual_stream {
383 struct {
384 u8 radio_tx_gain[2];
385 u8 dsp_predis_atten[2];
386 } s;
387 u32 dw;
388};
389
390/**
391 * struct tx_power_dual_stream
392 *
393 * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
394 *
395 * Same format as iwl_tx_power_dual_stream, but __le32
396 */
397struct tx_power_dual_stream {
398 __le32 dw;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000399} __packed;
Ben Cahill80cc0c32007-11-29 11:10:09 +0800400
401/**
402 * struct iwl4965_tx_power_db
403 *
404 * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
405 */
406struct iwl4965_tx_power_db {
407 struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000408} __packed;
Ben Cahill80cc0c32007-11-29 11:10:09 +0800409
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800410/**
Tomas Winklera96a27f2008-10-23 23:48:56 -0700411 * Command REPLY_TX_POWER_DBM_CMD = 0x98
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800412 * struct iwl5000_tx_power_dbm_cmd
413 */
414#define IWL50_TX_POWER_AUTO 0x7f
Gregory Greenman853554a2008-06-30 17:23:01 +0800415#define IWL50_TX_POWER_NO_CLOSED (0x1 << 6)
416
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800417struct iwl5000_tx_power_dbm_cmd {
418 s8 global_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
419 u8 flags;
420 s8 srv_chan_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
421 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000422} __packed;
Ben Cahill80cc0c32007-11-29 11:10:09 +0800423
Wey-Yi Guy2f748de2009-09-17 10:43:51 -0700424/**
425 * Command TX_ANT_CONFIGURATION_CMD = 0x98
426 * This command is used to configure valid Tx antenna.
427 * By default uCode concludes the valid antenna according to the radio flavor.
428 * This command enables the driver to override/modify this conclusion.
429 */
430struct iwl_tx_ant_config_cmd {
431 __le32 valid;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000432} __packed;
Wey-Yi Guy2f748de2009-09-17 10:43:51 -0700433
Zhu Yib481de92007-09-25 17:54:57 -0700434/******************************************************************************
435 * (0a)
436 * Alive and Error Commands & Responses:
437 *
438 *****************************************************************************/
439
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800440#define UCODE_VALID_OK cpu_to_le32(0x1)
Zhu Yib481de92007-09-25 17:54:57 -0700441#define INITIALIZE_SUBTYPE (9)
442
443/*
Ben Cahill075416c2007-11-29 11:10:08 +0800444 * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command)
445 *
446 * uCode issues this "initialize alive" notification once the initialization
447 * uCode image has completed its work, and is ready to load the runtime image.
448 * This is the *first* "alive" notification that the driver will receive after
449 * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
450 *
451 * See comments documenting "BSM" (bootstrap state machine).
452 *
453 * For 4965, this notification contains important calibration data for
454 * calculating txpower settings:
455 *
456 * 1) Power supply voltage indication. The voltage sensor outputs higher
Tomas Winklera96a27f2008-10-23 23:48:56 -0700457 * values for lower voltage, and vice verse.
Ben Cahill075416c2007-11-29 11:10:08 +0800458 *
459 * 2) Temperature measurement parameters, for each of two channel widths
460 * (20 MHz and 40 MHz) supported by the radios. Temperature sensing
461 * is done via one of the receiver chains, and channel width influences
462 * the results.
463 *
464 * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation,
465 * for each of 5 frequency ranges.
Zhu Yib481de92007-09-25 17:54:57 -0700466 */
Tomas Winkler885ba202008-05-29 16:34:55 +0800467struct iwl_init_alive_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700468 u8 ucode_minor;
469 u8 ucode_major;
470 __le16 reserved1;
471 u8 sw_rev[8];
472 u8 ver_type;
Ben Cahill075416c2007-11-29 11:10:08 +0800473 u8 ver_subtype; /* "9" for initialize alive */
Zhu Yib481de92007-09-25 17:54:57 -0700474 __le16 reserved2;
475 __le32 log_event_table_ptr;
476 __le32 error_event_table_ptr;
477 __le32 timestamp;
478 __le32 is_valid;
479
Zhu Yib481de92007-09-25 17:54:57 -0700480 /* calibration values from "initialize" uCode */
Ben Cahill075416c2007-11-29 11:10:08 +0800481 __le32 voltage; /* signed, higher value is lower voltage */
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700482 __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for HT40 */
Zhu Yib481de92007-09-25 17:54:57 -0700483 __le32 therm_r2[2]; /* signed */
484 __le32 therm_r3[2]; /* signed */
485 __le32 therm_r4[2]; /* signed */
486 __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups,
487 * 2 Tx chains */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000488} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700489
Ben Cahill075416c2007-11-29 11:10:08 +0800490
491/**
492 * REPLY_ALIVE = 0x1 (response only, not a command)
493 *
494 * uCode issues this "alive" notification once the runtime image is ready
495 * to receive commands from the driver. This is the *second* "alive"
496 * notification that the driver will receive after rebooting uCode;
497 * this "alive" is indicated by subtype field != 9.
498 *
499 * See comments documenting "BSM" (bootstrap state machine).
500 *
501 * This response includes two pointers to structures within the device's
502 * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
503 *
504 * 1) log_event_table_ptr indicates base of the event log. This traces
505 * a 256-entry history of uCode execution within a circular buffer.
506 * Its header format is:
507 *
508 * __le32 log_size; log capacity (in number of entries)
509 * __le32 type; (1) timestamp with each entry, (0) no timestamp
510 * __le32 wraps; # times uCode has wrapped to top of circular buffer
511 * __le32 write_index; next circular buffer entry that uCode would fill
512 *
513 * The header is followed by the circular buffer of log entries. Entries
514 * with timestamps have the following format:
515 *
516 * __le32 event_id; range 0 - 1500
517 * __le32 timestamp; low 32 bits of TSF (of network, if associated)
518 * __le32 data; event_id-specific data value
519 *
520 * Entries without timestamps contain only event_id and data.
521 *
Wey-Yi Guy461ef382010-03-30 17:57:53 -0700522 *
Ben Cahill075416c2007-11-29 11:10:08 +0800523 * 2) error_event_table_ptr indicates base of the error log. This contains
Wey-Yi Guy461ef382010-03-30 17:57:53 -0700524 * information about any uCode error that occurs. For agn, the format
Ben Cahill075416c2007-11-29 11:10:08 +0800525 * of the error log is:
526 *
527 * __le32 valid; (nonzero) valid, (0) log is empty
528 * __le32 error_id; type of error
529 * __le32 pc; program counter
530 * __le32 blink1; branch link
531 * __le32 blink2; branch link
532 * __le32 ilink1; interrupt link
533 * __le32 ilink2; interrupt link
534 * __le32 data1; error-specific data
535 * __le32 data2; error-specific data
536 * __le32 line; source code line of error
537 * __le32 bcon_time; beacon timer
538 * __le32 tsf_low; network timestamp function timer
539 * __le32 tsf_hi; network timestamp function timer
Wey-Yi Guy461ef382010-03-30 17:57:53 -0700540 * __le32 gp1; GP1 timer register
541 * __le32 gp2; GP2 timer register
542 * __le32 gp3; GP3 timer register
543 * __le32 ucode_ver; uCode version
544 * __le32 hw_ver; HW Silicon version
545 * __le32 brd_ver; HW board version
546 * __le32 log_pc; log program counter
547 * __le32 frame_ptr; frame pointer
548 * __le32 stack_ptr; stack pointer
549 * __le32 hcmd; last host command
550 * __le32 isr0; isr status register LMPM_NIC_ISR0: rxtx_flag
551 * __le32 isr1; isr status register LMPM_NIC_ISR1: host_flag
552 * __le32 isr2; isr status register LMPM_NIC_ISR2: enc_flag
553 * __le32 isr3; isr status register LMPM_NIC_ISR3: time_flag
554 * __le32 isr4; isr status register LMPM_NIC_ISR4: wico interrupt
555 * __le32 isr_pref; isr status register LMPM_NIC_PREF_STAT
556 * __le32 wait_event; wait event() caller address
557 * __le32 l2p_control; L2pControlField
558 * __le32 l2p_duration; L2pDurationField
559 * __le32 l2p_mhvalid; L2pMhValidBits
560 * __le32 l2p_addr_match; L2pAddrMatchStat
561 * __le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL)
562 * __le32 u_timestamp; indicate when the date and time of the compilation
563 * __le32 reserved;
Ben Cahill075416c2007-11-29 11:10:08 +0800564 *
565 * The Linux driver can print both logs to the system log when a uCode error
566 * occurs.
567 */
Tomas Winkler885ba202008-05-29 16:34:55 +0800568struct iwl_alive_resp {
Ben Cahill075416c2007-11-29 11:10:08 +0800569 u8 ucode_minor;
570 u8 ucode_major;
571 __le16 reserved1;
572 u8 sw_rev[8];
573 u8 ver_type;
574 u8 ver_subtype; /* not "9" for runtime alive */
575 __le16 reserved2;
576 __le32 log_event_table_ptr; /* SRAM address for event log */
577 __le32 error_event_table_ptr; /* SRAM address for error log */
578 __le32 timestamp;
579 __le32 is_valid;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000580} __packed;
Ben Cahill075416c2007-11-29 11:10:08 +0800581
Zhu Yib481de92007-09-25 17:54:57 -0700582/*
583 * REPLY_ERROR = 0x2 (response only, not a command)
584 */
Tomas Winkler885ba202008-05-29 16:34:55 +0800585struct iwl_error_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700586 __le32 error_type;
587 u8 cmd_id;
588 u8 reserved1;
589 __le16 bad_cmd_seq_num;
Zhu Yib481de92007-09-25 17:54:57 -0700590 __le32 error_info;
Tomas Winkler3195c1f2008-10-08 09:37:30 +0800591 __le64 timestamp;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000592} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700593
594/******************************************************************************
595 * (1)
596 * RXON Commands & Responses:
597 *
598 *****************************************************************************/
599
600/*
601 * Rx config defines & structure
602 */
603/* rx_config device types */
604enum {
605 RXON_DEV_TYPE_AP = 1,
606 RXON_DEV_TYPE_ESS = 3,
607 RXON_DEV_TYPE_IBSS = 4,
608 RXON_DEV_TYPE_SNIFFER = 6,
609};
610
Ben Cahill14519a02007-11-29 11:09:59 +0800611
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800612#define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0)
Rick Farrington7b841722009-01-23 13:45:10 -0800613#define RXON_RX_CHAIN_DRIVER_FORCE_POS (0)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800614#define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1)
Ben Cahill14519a02007-11-29 11:09:59 +0800615#define RXON_RX_CHAIN_VALID_POS (1)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800616#define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4)
Ben Cahill14519a02007-11-29 11:09:59 +0800617#define RXON_RX_CHAIN_FORCE_SEL_POS (4)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800618#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7)
Ben Cahill14519a02007-11-29 11:09:59 +0800619#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800620#define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10)
Ben Cahill14519a02007-11-29 11:09:59 +0800621#define RXON_RX_CHAIN_CNT_POS (10)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800622#define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12)
Ben Cahill14519a02007-11-29 11:09:59 +0800623#define RXON_RX_CHAIN_MIMO_CNT_POS (12)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800624#define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14)
Ben Cahill14519a02007-11-29 11:09:59 +0800625#define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
626
Zhu Yib481de92007-09-25 17:54:57 -0700627/* rx_config flags */
628/* band & modulation selection */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800629#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0)
630#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -0700631/* auto detection enable */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800632#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2)
Zhu Yib481de92007-09-25 17:54:57 -0700633/* TGg protection when tx */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800634#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3)
Zhu Yib481de92007-09-25 17:54:57 -0700635/* cck short slot & preamble */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800636#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4)
637#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5)
Zhu Yib481de92007-09-25 17:54:57 -0700638/* antenna selection */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800639#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7)
640#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00)
641#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
642#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
Zhu Yib481de92007-09-25 17:54:57 -0700643/* radar detection enable */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800644#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12)
645#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13)
Zhu Yib481de92007-09-25 17:54:57 -0700646/* rx response to host with 8-byte TSF
647* (according to ON_AIR deassertion) */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800648#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15)
Zhu Yib481de92007-09-25 17:54:57 -0700649
Ben Cahill14519a02007-11-29 11:09:59 +0800650
651/* HT flags */
652#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800653#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22)
Ben Cahill14519a02007-11-29 11:09:59 +0800654
655#define RXON_FLG_HT_OPERATING_MODE_POS (23)
656
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800657#define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23)
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700658#define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23)
Ben Cahill14519a02007-11-29 11:09:59 +0800659
660#define RXON_FLG_CHANNEL_MODE_POS (25)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800661#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25)
Wey-Yi Guya2b0f022009-05-22 11:01:49 -0700662
663/* channel mode */
664enum {
665 CHANNEL_MODE_LEGACY = 0,
666 CHANNEL_MODE_PURE_40 = 1,
667 CHANNEL_MODE_MIXED = 2,
668 CHANNEL_MODE_RESERVED = 3,
669};
670#define RXON_FLG_CHANNEL_MODE_LEGACY cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
671#define RXON_FLG_CHANNEL_MODE_PURE_40 cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
672#define RXON_FLG_CHANNEL_MODE_MIXED cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
673
Emmanuel Grumbacha326a5d2008-07-11 11:53:31 +0800674/* CTS to self (if spec allows) flag */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800675#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30)
Ben Cahill14519a02007-11-29 11:09:59 +0800676
Zhu Yib481de92007-09-25 17:54:57 -0700677/* rx_config filter flags */
678/* accept all data frames */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800679#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0)
Zhu Yib481de92007-09-25 17:54:57 -0700680/* pass control & management to host */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800681#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -0700682/* accept multi-cast */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800683#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2)
Zhu Yib481de92007-09-25 17:54:57 -0700684/* don't decrypt uni-cast frames */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800685#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3)
Zhu Yib481de92007-09-25 17:54:57 -0700686/* don't decrypt multi-cast frames */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800687#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
Zhu Yib481de92007-09-25 17:54:57 -0700688/* STA is associated */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800689#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5)
Zhu Yib481de92007-09-25 17:54:57 -0700690/* transfer to host non bssid beacons in associated state */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800691#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6)
Zhu Yib481de92007-09-25 17:54:57 -0700692
Ben Cahill80cc0c32007-11-29 11:10:09 +0800693/**
Zhu Yib481de92007-09-25 17:54:57 -0700694 * REPLY_RXON = 0x10 (command, has simple generic response)
Ben Cahill80cc0c32007-11-29 11:10:09 +0800695 *
696 * RXON tunes the radio tuner to a service channel, and sets up a number
697 * of parameters that are used primarily for Rx, but also for Tx operations.
698 *
699 * NOTE: When tuning to a new channel, driver must set the
700 * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent
701 * info within the device, including the station tables, tx retry
702 * rate tables, and txpower tables. Driver must build a new station
703 * table and txpower table before transmitting anything on the RXON
704 * channel.
705 *
706 * NOTE: All RXONs wipe clean the internal txpower table. Driver must
707 * issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
708 * regardless of whether RXON_FILTER_ASSOC_MSK is set.
Zhu Yib481de92007-09-25 17:54:57 -0700709 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800710
711struct iwl3945_rxon_cmd {
712 u8 node_addr[6];
713 __le16 reserved1;
714 u8 bssid_addr[6];
715 __le16 reserved2;
716 u8 wlap_bssid_addr[6];
717 __le16 reserved3;
718 u8 dev_type;
719 u8 air_propagation;
720 __le16 reserved4;
721 u8 ofdm_basic_rates;
722 u8 cck_basic_rates;
723 __le16 assoc_id;
724 __le32 flags;
725 __le32 filter_flags;
726 __le16 channel;
727 __le16 reserved5;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000728} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800729
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800730struct iwl4965_rxon_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700731 u8 node_addr[6];
732 __le16 reserved1;
733 u8 bssid_addr[6];
734 __le16 reserved2;
735 u8 wlap_bssid_addr[6];
736 __le16 reserved3;
737 u8 dev_type;
738 u8 air_propagation;
Zhu Yib481de92007-09-25 17:54:57 -0700739 __le16 rx_chain;
Zhu Yib481de92007-09-25 17:54:57 -0700740 u8 ofdm_basic_rates;
741 u8 cck_basic_rates;
742 __le16 assoc_id;
743 __le32 flags;
744 __le32 filter_flags;
745 __le16 channel;
Zhu Yib481de92007-09-25 17:54:57 -0700746 u8 ofdm_ht_single_stream_basic_rates;
747 u8 ofdm_ht_dual_stream_basic_rates;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000748} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700749
Tomas Winklera96a27f2008-10-23 23:48:56 -0700750/* 5000 HW just extend this command */
Gregory Greenmanc1adf9f2008-05-15 13:53:59 +0800751struct iwl_rxon_cmd {
752 u8 node_addr[6];
753 __le16 reserved1;
754 u8 bssid_addr[6];
755 __le16 reserved2;
756 u8 wlap_bssid_addr[6];
757 __le16 reserved3;
758 u8 dev_type;
759 u8 air_propagation;
760 __le16 rx_chain;
761 u8 ofdm_basic_rates;
762 u8 cck_basic_rates;
763 __le16 assoc_id;
764 __le32 flags;
765 __le32 filter_flags;
766 __le16 channel;
767 u8 ofdm_ht_single_stream_basic_rates;
768 u8 ofdm_ht_dual_stream_basic_rates;
769 u8 ofdm_ht_triple_stream_basic_rates;
770 u8 reserved5;
771 __le16 acquisition_data;
772 __le16 reserved6;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000773} __packed;
Gregory Greenmanc1adf9f2008-05-15 13:53:59 +0800774
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800775/*
776 * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
777 */
778struct iwl3945_rxon_assoc_cmd {
779 __le32 flags;
780 __le32 filter_flags;
781 u8 ofdm_basic_rates;
782 u8 cck_basic_rates;
783 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000784} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800785
786struct iwl4965_rxon_assoc_cmd {
787 __le32 flags;
788 __le32 filter_flags;
789 u8 ofdm_basic_rates;
790 u8 cck_basic_rates;
791 u8 ofdm_ht_single_stream_basic_rates;
792 u8 ofdm_ht_dual_stream_basic_rates;
793 __le16 rx_chain_select_flags;
794 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000795} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800796
Ron Rindjunskyfe7a90c2008-05-29 16:35:14 +0800797struct iwl5000_rxon_assoc_cmd {
798 __le32 flags;
799 __le32 filter_flags;
800 u8 ofdm_basic_rates;
801 u8 cck_basic_rates;
802 __le16 reserved1;
803 u8 ofdm_ht_single_stream_basic_rates;
804 u8 ofdm_ht_dual_stream_basic_rates;
805 u8 ofdm_ht_triple_stream_basic_rates;
806 u8 reserved2;
807 __le16 rx_chain_select_flags;
808 __le16 acquisition_data;
809 __le32 reserved3;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000810} __packed;
Gregory Greenmanc1adf9f2008-05-15 13:53:59 +0800811
Tomas Winklerb5d7be52008-07-19 04:41:24 +0300812#define IWL_CONN_MAX_LISTEN_INTERVAL 10
Tomas Winkler2c2f3b32009-06-19 13:52:45 -0700813#define IWL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */
814#define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */
Ron Rindjunskyfe7a90c2008-05-29 16:35:14 +0800815
Zhu Yib481de92007-09-25 17:54:57 -0700816/*
817 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
818 */
Tomas Winkler3195c1f2008-10-08 09:37:30 +0800819struct iwl_rxon_time_cmd {
820 __le64 timestamp;
Zhu Yib481de92007-09-25 17:54:57 -0700821 __le16 beacon_interval;
822 __le16 atim_window;
823 __le32 beacon_init_val;
824 __le16 listen_interval;
825 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000826} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700827
Zhu Yib481de92007-09-25 17:54:57 -0700828/*
829 * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
830 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800831struct iwl3945_channel_switch_cmd {
832 u8 band;
833 u8 expect_beacon;
834 __le16 channel;
835 __le32 rxon_flags;
836 __le32 rxon_filter_flags;
837 __le32 switch_time;
838 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000839} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800840
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700841struct iwl4965_channel_switch_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700842 u8 band;
843 u8 expect_beacon;
844 __le16 channel;
845 __le32 rxon_flags;
846 __le32 rxon_filter_flags;
847 __le32 switch_time;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800848 struct iwl4965_tx_power_db tx_power;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000849} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700850
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700851/**
852 * struct iwl5000_channel_switch_cmd
853 * @band: 0- 5.2GHz, 1- 2.4GHz
854 * @expect_beacon: 0- resume transmits after channel switch
855 * 1- wait for beacon to resume transmits
856 * @channel: new channel number
857 * @rxon_flags: Rx on flags
858 * @rxon_filter_flags: filtering parameters
859 * @switch_time: switch time in extended beacon format
860 * @reserved: reserved bytes
861 */
862struct iwl5000_channel_switch_cmd {
863 u8 band;
864 u8 expect_beacon;
865 __le16 channel;
866 __le32 rxon_flags;
867 __le32 rxon_filter_flags;
868 __le32 switch_time;
869 __le32 reserved[2][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000870} __packed;
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700871
872/**
873 * struct iwl6000_channel_switch_cmd
874 * @band: 0- 5.2GHz, 1- 2.4GHz
875 * @expect_beacon: 0- resume transmits after channel switch
876 * 1- wait for beacon to resume transmits
877 * @channel: new channel number
878 * @rxon_flags: Rx on flags
879 * @rxon_filter_flags: filtering parameters
880 * @switch_time: switch time in extended beacon format
881 * @reserved: reserved bytes
882 */
883struct iwl6000_channel_switch_cmd {
884 u8 band;
885 u8 expect_beacon;
886 __le16 channel;
887 __le32 rxon_flags;
888 __le32 rxon_filter_flags;
889 __le32 switch_time;
890 __le32 reserved[3][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000891} __packed;
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700892
Zhu Yib481de92007-09-25 17:54:57 -0700893/*
894 * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
895 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -0800896struct iwl_csa_notification {
Zhu Yib481de92007-09-25 17:54:57 -0700897 __le16 band;
898 __le16 channel;
899 __le32 status; /* 0 - OK, 1 - fail */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000900} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700901
902/******************************************************************************
903 * (2)
904 * Quality-of-Service (QOS) Commands & Responses:
905 *
906 *****************************************************************************/
Ben Cahill2054a002007-11-29 11:10:10 +0800907
908/**
909 * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
910 * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
911 *
912 * @cw_min: Contention window, start value in numbers of slots.
913 * Should be a power-of-2, minus 1. Device's default is 0x0f.
914 * @cw_max: Contention window, max value in numbers of slots.
915 * Should be a power-of-2, minus 1. Device's default is 0x3f.
916 * @aifsn: Number of slots in Arbitration Interframe Space (before
917 * performing random backoff timing prior to Tx). Device default 1.
918 * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
919 *
920 * Device will automatically increase contention window by (2*CW) + 1 for each
921 * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
922 * value, to cap the CW value.
923 */
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800924struct iwl_ac_qos {
Zhu Yib481de92007-09-25 17:54:57 -0700925 __le16 cw_min;
926 __le16 cw_max;
927 u8 aifsn;
928 u8 reserved1;
929 __le16 edca_txop;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000930} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700931
932/* QoS flags defines */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800933#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01)
934#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02)
935#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10)
Zhu Yib481de92007-09-25 17:54:57 -0700936
Ben Cahill2054a002007-11-29 11:10:10 +0800937/* Number of Access Categories (AC) (EDCA), queues 0..3 */
Zhu Yib481de92007-09-25 17:54:57 -0700938#define AC_NUM 4
939
940/*
941 * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
Ben Cahill2054a002007-11-29 11:10:10 +0800942 *
943 * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
944 * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
Zhu Yib481de92007-09-25 17:54:57 -0700945 */
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800946struct iwl_qosparam_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700947 __le32 qos_flags;
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800948 struct iwl_ac_qos ac[AC_NUM];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000949} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700950
951/******************************************************************************
952 * (3)
953 * Add/Modify Stations Commands & Responses:
954 *
955 *****************************************************************************/
956/*
957 * Multi station support
958 */
Ben Cahill2054a002007-11-29 11:10:10 +0800959
960/* Special, dedicated locations within device's station table */
Zhu Yib481de92007-09-25 17:54:57 -0700961#define IWL_AP_ID 0
Zhu Yib481de92007-09-25 17:54:57 -0700962#define IWL_STA_ID 2
Tomas Winkler4c897252008-12-19 10:37:05 +0800963#define IWL3945_BROADCAST_ID 24
964#define IWL3945_STATION_COUNT 25
Zhu Yib481de92007-09-25 17:54:57 -0700965#define IWL4965_BROADCAST_ID 31
966#define IWL4965_STATION_COUNT 32
Wey-Yi Guybf3c7fd2010-06-24 14:08:05 -0700967#define IWLAGN_BROADCAST_ID 15
968#define IWLAGN_STATION_COUNT 16
Zhu Yib481de92007-09-25 17:54:57 -0700969
970#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
971#define IWL_INVALID_STATION 255
972
Johannes Berg1bd14ea2010-07-15 11:48:21 -0700973#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2)
974#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800975#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17)
976#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18)
Ben Cahill74093dd2007-11-29 11:09:53 +0800977#define STA_FLG_MAX_AGG_SIZE_POS (19)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800978#define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19)
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700979#define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800980#define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22)
Ben Cahill74093dd2007-11-29 11:09:53 +0800981#define STA_FLG_AGG_MPDU_DENSITY_POS (23)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800982#define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23)
Zhu Yib481de92007-09-25 17:54:57 -0700983
Ben Cahill2054a002007-11-29 11:10:10 +0800984/* Use in mode field. 1: modify existing entry, 0: add new station entry */
Zhu Yib481de92007-09-25 17:54:57 -0700985#define STA_CONTROL_MODIFY_MSK 0x01
986
987/* key flags __le16*/
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800988#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007)
989#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000)
990#define STA_KEY_FLG_WEP cpu_to_le16(0x0001)
991#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002)
992#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003)
Zhu Yib481de92007-09-25 17:54:57 -0700993
994#define STA_KEY_FLG_KEYID_POS 8
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800995#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800)
Emmanuel Grumbacheaaf7892008-02-13 11:32:29 -0800996/* wep key is either from global key (0) or from station info array (1) */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800997#define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008)
Emmanuel Grumbacheaaf7892008-02-13 11:32:29 -0800998
999/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001000#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000)
1001#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
Emmanuel Grumbachdeb09c42008-03-19 16:41:41 -07001002#define STA_KEY_MAX_NUM 8
Zhu Yib481de92007-09-25 17:54:57 -07001003
Ben Cahill2054a002007-11-29 11:10:10 +08001004/* Flags indicate whether to modify vs. don't change various station params */
Zhu Yib481de92007-09-25 17:54:57 -07001005#define STA_MODIFY_KEY_MASK 0x01
1006#define STA_MODIFY_TID_DISABLE_TX 0x02
1007#define STA_MODIFY_TX_RATE_MSK 0x04
1008#define STA_MODIFY_ADDBA_TID_MSK 0x08
1009#define STA_MODIFY_DELBA_TID_MSK 0x10
Johannes Berg6ab10ff2009-11-13 11:56:37 -08001010#define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20
Ben Cahill2054a002007-11-29 11:10:10 +08001011
1012/* Receiver address (actually, Rx station's index into station table),
1013 * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
Zhu Yib481de92007-09-25 17:54:57 -07001014#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid))
1015
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001016struct iwl4965_keyinfo {
Zhu Yib481de92007-09-25 17:54:57 -07001017 __le16 key_flags;
1018 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
1019 u8 reserved1;
1020 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
Emmanuel Grumbacheaaf7892008-02-13 11:32:29 -08001021 u8 key_offset;
1022 u8 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -07001023 u8 key[16]; /* 16-byte unicast decryption key */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001024} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001025
Tomas Winkler133636d2008-05-05 10:22:34 +08001026/* 5000 */
1027struct iwl_keyinfo {
1028 __le16 key_flags;
1029 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
1030 u8 reserved1;
1031 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
1032 u8 key_offset;
1033 u8 reserved2;
1034 u8 key[16]; /* 16-byte unicast decryption key */
1035 __le64 tx_secur_seq_cnt;
1036 __le64 hw_tkip_mic_rx_key;
1037 __le64 hw_tkip_mic_tx_key;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001038} __packed;
Tomas Winkler133636d2008-05-05 10:22:34 +08001039
Ben Cahill2054a002007-11-29 11:10:10 +08001040/**
1041 * struct sta_id_modify
1042 * @addr[ETH_ALEN]: station's MAC address
1043 * @sta_id: index of station in uCode's station table
1044 * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
1045 *
1046 * Driver selects unused table index when adding new station,
1047 * or the index to a pre-existing station entry when modifying that station.
1048 * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
1049 *
1050 * modify_mask flags select which parameters to modify vs. leave alone.
1051 */
Zhu Yib481de92007-09-25 17:54:57 -07001052struct sta_id_modify {
1053 u8 addr[ETH_ALEN];
1054 __le16 reserved1;
1055 u8 sta_id;
1056 u8 modify_mask;
1057 __le16 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001058} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001059
1060/*
1061 * REPLY_ADD_STA = 0x18 (command)
Ben Cahill2054a002007-11-29 11:10:10 +08001062 *
1063 * The device contains an internal table of per-station information,
1064 * with info on security keys, aggregation parameters, and Tx rates for
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001065 * initial Tx attempt and any retries (agn devices uses
1066 * REPLY_TX_LINK_QUALITY_CMD,
Ben Cahill2054a002007-11-29 11:10:10 +08001067 * 3945 uses REPLY_RATE_SCALE to set up rate tables).
1068 *
1069 * REPLY_ADD_STA sets up the table entry for one station, either creating
1070 * a new entry, or modifying a pre-existing one.
1071 *
1072 * NOTE: RXON command (without "associated" bit set) wipes the station table
1073 * clean. Moving into RF_KILL state does this also. Driver must set up
1074 * new station table before transmitting anything on the RXON channel
1075 * (except active scans or active measurements; those commands carry
1076 * their own txpower/rate setup data).
1077 *
1078 * When getting started on a new channel, driver must set up the
1079 * IWL_BROADCAST_ID entry (last entry in the table). For a client
1080 * station in a BSS, once an AP is selected, driver sets up the AP STA
1081 * in the IWL_AP_ID entry (1st entry in the table). BROADCAST and AP
1082 * are all that are needed for a BSS client station. If the device is
1083 * used as AP, or in an IBSS network, driver must set up station table
1084 * entries for all STAs in network, starting with index IWL_STA_ID.
Zhu Yib481de92007-09-25 17:54:57 -07001085 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001086
1087struct iwl3945_addsta_cmd {
1088 u8 mode; /* 1: modify existing, 0: add new station */
1089 u8 reserved[3];
1090 struct sta_id_modify sta;
1091 struct iwl4965_keyinfo key;
1092 __le32 station_flags; /* STA_FLG_* */
1093 __le32 station_flags_msk; /* STA_FLG_* */
1094
1095 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1096 * corresponding to bit (e.g. bit 5 controls TID 5).
1097 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1098 __le16 tid_disable_tx;
1099
1100 __le16 rate_n_flags;
1101
1102 /* TID for which to add block-ack support.
1103 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1104 u8 add_immediate_ba_tid;
1105
1106 /* TID for which to remove block-ack support.
1107 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1108 u8 remove_immediate_ba_tid;
1109
1110 /* Starting Sequence Number for added block-ack support.
1111 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1112 __le16 add_immediate_ba_ssn;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001113} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001114
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001115struct iwl4965_addsta_cmd {
Ben Cahill2054a002007-11-29 11:10:10 +08001116 u8 mode; /* 1: modify existing, 0: add new station */
Zhu Yib481de92007-09-25 17:54:57 -07001117 u8 reserved[3];
1118 struct sta_id_modify sta;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001119 struct iwl4965_keyinfo key;
Ben Cahill2054a002007-11-29 11:10:10 +08001120 __le32 station_flags; /* STA_FLG_* */
1121 __le32 station_flags_msk; /* STA_FLG_* */
1122
1123 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1124 * corresponding to bit (e.g. bit 5 controls TID 5).
1125 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001126 __le16 tid_disable_tx;
Ben Cahill2054a002007-11-29 11:10:10 +08001127
Zhu Yib481de92007-09-25 17:54:57 -07001128 __le16 reserved1;
Ben Cahill2054a002007-11-29 11:10:10 +08001129
1130 /* TID for which to add block-ack support.
1131 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001132 u8 add_immediate_ba_tid;
Ben Cahill2054a002007-11-29 11:10:10 +08001133
1134 /* TID for which to remove block-ack support.
1135 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001136 u8 remove_immediate_ba_tid;
Ben Cahill2054a002007-11-29 11:10:10 +08001137
1138 /* Starting Sequence Number for added block-ack support.
1139 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001140 __le16 add_immediate_ba_ssn;
Ben Cahill2054a002007-11-29 11:10:10 +08001141
Johannes Berg9bb487b2009-11-13 11:56:36 -08001142 /*
1143 * Number of packets OK to transmit to station even though
1144 * it is asleep -- used to synchronise PS-poll and u-APSD
1145 * responses while ucode keeps track of STA sleep state.
1146 */
1147 __le16 sleep_tx_count;
1148
1149 __le16 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001150} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001151
Tomas Winkler133636d2008-05-05 10:22:34 +08001152/* 5000 */
1153struct iwl_addsta_cmd {
1154 u8 mode; /* 1: modify existing, 0: add new station */
1155 u8 reserved[3];
1156 struct sta_id_modify sta;
1157 struct iwl_keyinfo key;
1158 __le32 station_flags; /* STA_FLG_* */
1159 __le32 station_flags_msk; /* STA_FLG_* */
1160
1161 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1162 * corresponding to bit (e.g. bit 5 controls TID 5).
1163 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1164 __le16 tid_disable_tx;
1165
Tomas Winklerc587de02009-06-03 11:44:07 -07001166 __le16 rate_n_flags; /* 3945 only */
Tomas Winkler133636d2008-05-05 10:22:34 +08001167
1168 /* TID for which to add block-ack support.
1169 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1170 u8 add_immediate_ba_tid;
1171
1172 /* TID for which to remove block-ack support.
1173 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1174 u8 remove_immediate_ba_tid;
1175
1176 /* Starting Sequence Number for added block-ack support.
1177 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1178 __le16 add_immediate_ba_ssn;
1179
Johannes Berg9bb487b2009-11-13 11:56:36 -08001180 /*
1181 * Number of packets OK to transmit to station even though
1182 * it is asleep -- used to synchronise PS-poll and u-APSD
1183 * responses while ucode keeps track of STA sleep state.
1184 */
1185 __le16 sleep_tx_count;
1186
1187 __le16 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001188} __packed;
Tomas Winkler133636d2008-05-05 10:22:34 +08001189
1190
Ben Cahill2054a002007-11-29 11:10:10 +08001191#define ADD_STA_SUCCESS_MSK 0x1
1192#define ADD_STA_NO_ROOM_IN_TABLE 0x2
1193#define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4
1194#define ADD_STA_MODIFY_NON_EXIST_STA 0x8
Zhu Yib481de92007-09-25 17:54:57 -07001195/*
1196 * REPLY_ADD_STA = 0x18 (response)
1197 */
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001198struct iwl_add_sta_resp {
Ben Cahill2054a002007-11-29 11:10:10 +08001199 u8 status; /* ADD_STA_* */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001200} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001201
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001202#define REM_STA_SUCCESS_MSK 0x1
1203/*
1204 * REPLY_REM_STA = 0x19 (response)
1205 */
1206struct iwl_rem_sta_resp {
1207 u8 status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001208} __packed;
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001209
1210/*
1211 * REPLY_REM_STA = 0x19 (command)
1212 */
1213struct iwl_rem_sta_cmd {
1214 u8 num_sta; /* number of removed stations */
1215 u8 reserved[3];
1216 u8 addr[ETH_ALEN]; /* MAC addr of the first station */
1217 u8 reserved2[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001218} __packed;
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001219
Wey-Yi Guy947279e2010-06-24 13:18:33 -07001220#define IWL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0))
1221#define IWL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1))
1222#define IWL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2))
1223#define IWL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3))
1224#define IWL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00)
1225
Wey-Yi Guy716c74b2010-06-24 13:22:36 -07001226#define IWL_DROP_SINGLE 0
1227#define IWL_DROP_SELECTED 1
1228#define IWL_DROP_ALL 2
1229
Wey-Yi Guy947279e2010-06-24 13:18:33 -07001230/*
1231 * REPLY_TXFIFO_FLUSH = 0x1e(command and response)
1232 *
1233 * When using full FIFO flush this command checks the scheduler HW block WR/RD
1234 * pointers to check if all the frames were transferred by DMA into the
1235 * relevant TX FIFO queue. Only when the DMA is finished and the queue is
1236 * empty the command can finish.
1237 * This command is used to flush the TXFIFO from transmit commands, it may
1238 * operate on single or multiple queues, the command queue can't be flushed by
1239 * this command. The command response is returned when all the queue flush
1240 * operations are done. Each TX command flushed return response with the FLUSH
1241 * status set in the TX response status. When FIFO flush operation is used,
1242 * the flush operation ends when both the scheduler DMA done and TXFIFO empty
1243 * are set.
1244 *
1245 * @fifo_control: bit mask for which queues to flush
1246 * @flush_control: flush controls
1247 * 0: Dump single MSDU
1248 * 1: Dump multiple MSDU according to PS, INVALID STA, TTL, TID disable.
1249 * 2: Dump all FIFO
1250 */
1251struct iwl_txfifo_flush_cmd {
1252 __le32 fifo_control;
1253 __le16 flush_control;
1254 __le16 reserved;
John W. Linville0e954092010-07-14 10:37:32 -04001255} __packed;
Wey-Yi Guy947279e2010-06-24 13:18:33 -07001256
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001257/*
1258 * REPLY_WEP_KEY = 0x20
1259 */
1260struct iwl_wep_key {
1261 u8 key_index;
1262 u8 key_offset;
1263 u8 reserved1[2];
1264 u8 key_size;
1265 u8 reserved2[3];
1266 u8 key[16];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001267} __packed;
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001268
1269struct iwl_wep_cmd {
1270 u8 num_keys;
1271 u8 global_key_type;
1272 u8 flags;
1273 u8 reserved;
1274 struct iwl_wep_key key[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001275} __packed;
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001276
1277#define WEP_KEY_WEP_TYPE 1
1278#define WEP_KEYS_MAX 4
1279#define WEP_INVALID_OFFSET 0xff
Emmanuel Grumbach4564ce82008-06-12 09:47:09 +08001280#define WEP_KEY_LEN_64 5
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001281#define WEP_KEY_LEN_128 13
Zhu Yib481de92007-09-25 17:54:57 -07001282
1283/******************************************************************************
1284 * (4)
1285 * Rx Responses:
1286 *
1287 *****************************************************************************/
1288
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001289#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0)
1290#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -07001291
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001292#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0)
1293#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1)
1294#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2)
1295#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3)
Reinette Chatre9024adf2009-10-02 13:43:57 -07001296#define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0
Daniel C Halperin9f30e042009-08-13 13:30:56 -07001297#define RX_RES_PHY_FLAGS_ANTENNA_POS 4
Zhu Yib481de92007-09-25 17:54:57 -07001298
Tomas Winkler8211ef72008-03-02 01:36:04 +02001299#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
1300#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
1301#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
1302#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
1303#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
Emmanuel Grumbach17e476b2008-03-19 16:41:42 -07001304#define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8)
1305
1306#define RX_RES_STATUS_STATION_FOUND (1<<6)
1307#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7)
Zhu Yib481de92007-09-25 17:54:57 -07001308
Tomas Winkler8211ef72008-03-02 01:36:04 +02001309#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
1310#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
1311#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
1312#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
1313#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
Zhu Yib481de92007-09-25 17:54:57 -07001314
Emmanuel Grumbach17e476b2008-03-19 16:41:42 -07001315#define RX_MPDU_RES_STATUS_ICV_OK (0x20)
1316#define RX_MPDU_RES_STATUS_MIC_OK (0x40)
1317#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7)
1318#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800)
1319
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001320
1321struct iwl3945_rx_frame_stats {
1322 u8 phy_count;
1323 u8 id;
1324 u8 rssi;
1325 u8 agc;
1326 __le16 sig_avg;
1327 __le16 noise_diff;
1328 u8 payload[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001329} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001330
1331struct iwl3945_rx_frame_hdr {
1332 __le16 channel;
1333 __le16 phy_flags;
1334 u8 reserved1;
1335 u8 rate;
1336 __le16 len;
1337 u8 payload[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001338} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001339
1340struct iwl3945_rx_frame_end {
1341 __le32 status;
1342 __le64 timestamp;
1343 __le32 beacon_timestamp;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001344} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001345
1346/*
1347 * REPLY_3945_RX = 0x1b (response only, not a command)
1348 *
1349 * NOTE: DO NOT dereference from casts to this structure
1350 * It is provided only for calculating minimum data set size.
1351 * The actual offsets of the hdr and end are dynamic based on
1352 * stats.phy_count
1353 */
1354struct iwl3945_rx_frame {
1355 struct iwl3945_rx_frame_stats stats;
1356 struct iwl3945_rx_frame_hdr hdr;
1357 struct iwl3945_rx_frame_end end;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001358} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001359
1360#define IWL39_RX_FRAME_SIZE (4 + sizeof(struct iwl3945_rx_frame))
1361
Zhu Yib481de92007-09-25 17:54:57 -07001362/* Fixed (non-configurable) rx data from phy */
Tomas Winklercaab8f12008-08-04 16:00:42 +08001363
1364#define IWL49_RX_RES_PHY_CNT 14
1365#define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
1366#define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
1367#define IWL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
1368#define IWL49_AGC_DB_POS (7)
Zhu Yib481de92007-09-25 17:54:57 -07001369struct iwl4965_rx_non_cfg_phy {
1370 __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
1371 __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
1372 u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
1373 u8 pad[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001374} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001375
Tomas Winklercaab8f12008-08-04 16:00:42 +08001376
Wey-Yi Guy7ccc8962010-08-04 08:42:17 -07001377#define IWLAGN_RX_RES_PHY_CNT 8
1378#define IWLAGN_RX_RES_AGC_IDX 1
1379#define IWLAGN_RX_RES_RSSI_AB_IDX 2
1380#define IWLAGN_RX_RES_RSSI_C_IDX 3
1381#define IWLAGN_OFDM_AGC_MSK 0xfe00
1382#define IWLAGN_OFDM_AGC_BIT_POS 9
1383#define IWLAGN_OFDM_RSSI_INBAND_A_BITMSK 0x00ff
1384#define IWLAGN_OFDM_RSSI_ALLBAND_A_BITMSK 0xff00
1385#define IWLAGN_OFDM_RSSI_A_BIT_POS 0
1386#define IWLAGN_OFDM_RSSI_INBAND_B_BITMSK 0xff0000
1387#define IWLAGN_OFDM_RSSI_ALLBAND_B_BITMSK 0xff000000
1388#define IWLAGN_OFDM_RSSI_B_BIT_POS 16
1389#define IWLAGN_OFDM_RSSI_INBAND_C_BITMSK 0x00ff
1390#define IWLAGN_OFDM_RSSI_ALLBAND_C_BITMSK 0xff00
1391#define IWLAGN_OFDM_RSSI_C_BIT_POS 0
Tomas Winklercaab8f12008-08-04 16:00:42 +08001392
Wey-Yi Guy7ccc8962010-08-04 08:42:17 -07001393struct iwlagn_non_cfg_phy {
1394 __le32 non_cfg_phy[IWLAGN_RX_RES_PHY_CNT]; /* up to 8 phy entries */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001395} __packed;
Tomas Winklercaab8f12008-08-04 16:00:42 +08001396
1397
Zhu Yib481de92007-09-25 17:54:57 -07001398/*
Tomas Winkler857485c2008-03-21 13:53:44 -07001399 * REPLY_RX = 0xc3 (response only, not a command)
Zhu Yib481de92007-09-25 17:54:57 -07001400 * Used only for legacy (non 11n) frames.
1401 */
Tomas Winklercaab8f12008-08-04 16:00:42 +08001402struct iwl_rx_phy_res {
Zhu Yib481de92007-09-25 17:54:57 -07001403 u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
1404 u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
1405 u8 stat_id; /* configurable DSP phy data set ID */
1406 u8 reserved1;
1407 __le64 timestamp; /* TSF at on air rise */
1408 __le32 beacon_time_stamp; /* beacon at on-air rise */
1409 __le16 phy_flags; /* general phy flags: band, modulation, ... */
1410 __le16 channel; /* channel number */
Tomas Winklercaab8f12008-08-04 16:00:42 +08001411 u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
Ben Cahill52969982007-11-29 11:10:11 +08001412 __le32 rate_n_flags; /* RATE_MCS_* */
1413 __le16 byte_count; /* frame's byte-count */
Wey-Yi Guy30c1b0f2010-08-04 08:05:33 -07001414 __le16 frame_time; /* frame's time on the air */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001415} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001416
Emmanuel Grumbach2fb291e2010-06-07 13:21:47 -07001417struct iwl_rx_mpdu_res_start {
Zhu Yib481de92007-09-25 17:54:57 -07001418 __le16 byte_count;
1419 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001420} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001421
1422
1423/******************************************************************************
1424 * (5)
1425 * Tx Commands & Responses:
1426 *
Ben Cahill52969982007-11-29 11:10:11 +08001427 * Driver must place each REPLY_TX command into one of the prioritized Tx
1428 * queues in host DRAM, shared between driver and device (see comments for
1429 * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode
1430 * are preparing to transmit, the device pulls the Tx command over the PCI
1431 * bus via one of the device's Tx DMA channels, to fill an internal FIFO
1432 * from which data will be transmitted.
1433 *
1434 * uCode handles all timing and protocol related to control frames
1435 * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler
1436 * handle reception of block-acks; uCode updates the host driver via
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001437 * REPLY_COMPRESSED_BA.
Ben Cahill52969982007-11-29 11:10:11 +08001438 *
1439 * uCode handles retrying Tx when an ACK is expected but not received.
1440 * This includes trying lower data rates than the one requested in the Tx
1441 * command, as set up by the REPLY_RATE_SCALE (for 3945) or
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001442 * REPLY_TX_LINK_QUALITY_CMD (agn).
Ben Cahill52969982007-11-29 11:10:11 +08001443 *
1444 * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
1445 * This command must be executed after every RXON command, before Tx can occur.
Zhu Yib481de92007-09-25 17:54:57 -07001446 *****************************************************************************/
1447
Ben Cahill52969982007-11-29 11:10:11 +08001448/* REPLY_TX Tx flags field */
1449
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001450/*
1451 * 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
Emmanuel Grumbacha326a5d2008-07-11 11:53:31 +08001452 * before this frame. if CTS-to-self required check
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001453 * RXON_FLG_SELF_CTS_EN status.
1454 * unused in 3945/4965, used in 5000 series and after
1455 */
1456#define TX_CMD_FLG_PROT_REQUIRE_MSK cpu_to_le32(1 << 0)
Emmanuel Grumbacha326a5d2008-07-11 11:53:31 +08001457
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001458/*
1459 * 1: Use Request-To-Send protocol before this frame.
1460 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK.
1461 * used in 3945/4965, unused in 5000 series and after
1462 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001463#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
Ben Cahill52969982007-11-29 11:10:11 +08001464
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001465/*
1466 * 1: Transmit Clear-To-Send to self before this frame.
Ben Cahill52969982007-11-29 11:10:11 +08001467 * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001468 * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK.
1469 * used in 3945/4965, unused in 5000 series and after
1470 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001471#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
Ben Cahill52969982007-11-29 11:10:11 +08001472
1473/* 1: Expect ACK from receiving station
1474 * 0: Don't expect ACK (MAC header's duration field s/b 0)
1475 * Set this for unicast frames, but not broadcast/multicast. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001476#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
Ben Cahill52969982007-11-29 11:10:11 +08001477
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001478/* For agn devices:
Ben Cahill52969982007-11-29 11:10:11 +08001479 * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
1480 * Tx command's initial_rate_index indicates first rate to try;
1481 * uCode walks through table for additional Tx attempts.
1482 * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
1483 * This rate will be used for all Tx attempts; it will not be scaled. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001484#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
Ben Cahill52969982007-11-29 11:10:11 +08001485
1486/* 1: Expect immediate block-ack.
1487 * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001488#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6)
Ben Cahill52969982007-11-29 11:10:11 +08001489
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001490/*
1491 * 1: Frame requires full Tx-Op protection.
1492 * Set this if either RTS or CTS Tx Flag gets set.
1493 * used in 3945/4965, unused in 5000 series and after
1494 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001495#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
Ben Cahill52969982007-11-29 11:10:11 +08001496
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001497/* Tx antenna selection field; used only for 3945, reserved (0) for agn devices.
Ben Cahill52969982007-11-29 11:10:11 +08001498 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001499#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
1500#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
1501#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
Zhu Yib481de92007-09-25 17:54:57 -07001502
Ben Cahill52969982007-11-29 11:10:11 +08001503/* 1: Ignore Bluetooth priority for this frame.
1504 * 0: Delay Tx until Bluetooth device is done (normal usage). */
Johannes Bergb2e86902010-04-13 01:04:32 -07001505#define TX_CMD_FLG_IGNORE_BT cpu_to_le32(1 << 12)
Zhu Yib481de92007-09-25 17:54:57 -07001506
Ben Cahill52969982007-11-29 11:10:11 +08001507/* 1: uCode overrides sequence control field in MAC header.
1508 * 0: Driver provides sequence control field in MAC header.
1509 * Set this for management frames, non-QOS data frames, non-unicast frames,
1510 * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001511#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
Zhu Yib481de92007-09-25 17:54:57 -07001512
Ben Cahill52969982007-11-29 11:10:11 +08001513/* 1: This frame is non-last MPDU; more fragments are coming.
1514 * 0: Last fragment, or not using fragmentation. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001515#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
Zhu Yib481de92007-09-25 17:54:57 -07001516
Ben Cahill52969982007-11-29 11:10:11 +08001517/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
1518 * 0: No TSF required in outgoing frame.
1519 * Set this for transmitting beacons and probe responses. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001520#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
Zhu Yib481de92007-09-25 17:54:57 -07001521
Ben Cahill52969982007-11-29 11:10:11 +08001522/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
1523 * alignment of frame's payload data field.
1524 * 0: No pad
1525 * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
1526 * field (but not both). Driver must align frame data (i.e. data following
1527 * MAC header) to DWORD boundary. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001528#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
Zhu Yib481de92007-09-25 17:54:57 -07001529
Max Stepanov8236e182008-03-12 16:58:48 -07001530/* accelerate aggregation support
1531 * 0 - no CCMP encryption; 1 - CCMP encryption */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001532#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
Max Stepanov8236e182008-03-12 16:58:48 -07001533
Zhu Yib481de92007-09-25 17:54:57 -07001534/* HCCA-AP - disable duration overwriting. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001535#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
Zhu Yib481de92007-09-25 17:54:57 -07001536
Ben Cahill52969982007-11-29 11:10:11 +08001537
Zhu Yib481de92007-09-25 17:54:57 -07001538/*
1539 * TX command security control
1540 */
1541#define TX_CMD_SEC_WEP 0x01
1542#define TX_CMD_SEC_CCM 0x02
1543#define TX_CMD_SEC_TKIP 0x03
1544#define TX_CMD_SEC_MSK 0x03
1545#define TX_CMD_SEC_SHIFT 6
1546#define TX_CMD_SEC_KEY128 0x08
1547
1548/*
Tomas Winkler3195cdb2008-04-23 17:15:00 -07001549 * security overhead sizes
1550 */
1551#define WEP_IV_LEN 4
1552#define WEP_ICV_LEN 4
1553#define CCMP_MIC_LEN 8
1554#define TKIP_ICV_LEN 4
1555
1556/*
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001557 * REPLY_TX = 0x1c (command)
1558 */
1559
1560struct iwl3945_tx_cmd {
1561 /*
1562 * MPDU byte count:
1563 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1564 * + 8 byte IV for CCM or TKIP (not used for WEP)
1565 * + Data payload
1566 * + 8-byte MIC (not used for CCM/WEP)
1567 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1568 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1569 * Range: 14-2342 bytes.
1570 */
1571 __le16 len;
1572
1573 /*
1574 * MPDU or MSDU byte count for next frame.
1575 * Used for fragmentation and bursting, but not 11n aggregation.
1576 * Same as "len", but for next frame. Set to 0 if not applicable.
1577 */
1578 __le16 next_frame_len;
1579
1580 __le32 tx_flags; /* TX_CMD_FLG_* */
1581
1582 u8 rate;
1583
1584 /* Index of recipient station in uCode's station table */
1585 u8 sta_id;
1586 u8 tid_tspec;
1587 u8 sec_ctl;
1588 u8 key[16];
1589 union {
1590 u8 byte[8];
1591 __le16 word[4];
1592 __le32 dw[2];
1593 } tkip_mic;
1594 __le32 next_frame_info;
1595 union {
1596 __le32 life_time;
1597 __le32 attempt;
1598 } stop_time;
1599 u8 supp_rates[2];
1600 u8 rts_retry_limit; /*byte 50 */
1601 u8 data_retry_limit; /*byte 51 */
1602 union {
1603 __le16 pm_frame_timeout;
1604 __le16 attempt_duration;
1605 } timeout;
1606
1607 /*
1608 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1609 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1610 */
1611 __le16 driver_txop;
1612
1613 /*
1614 * MAC header goes here, followed by 2 bytes padding if MAC header
1615 * length is 26 or 30 bytes, followed by payload data
1616 */
1617 u8 payload[0];
1618 struct ieee80211_hdr hdr[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001619} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001620
1621/*
1622 * REPLY_TX = 0x1c (response)
1623 */
1624struct iwl3945_tx_resp {
1625 u8 failure_rts;
1626 u8 failure_frame;
1627 u8 bt_kill_count;
1628 u8 rate;
1629 __le32 wireless_media_time;
1630 __le32 status; /* TX status */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001631} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001632
1633
1634/*
Ben Cahill52969982007-11-29 11:10:11 +08001635 * 4965 uCode updates these Tx attempt count values in host DRAM.
1636 * Used for managing Tx retries when expecting block-acks.
1637 * Driver should set these fields to 0.
Zhu Yib481de92007-09-25 17:54:57 -07001638 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001639struct iwl_dram_scratch {
Ben Cahill52969982007-11-29 11:10:11 +08001640 u8 try_cnt; /* Tx attempts */
1641 u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */
Zhu Yib481de92007-09-25 17:54:57 -07001642 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001643} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001644
Tomas Winkler83d527d2008-05-15 13:54:05 +08001645struct iwl_tx_cmd {
Ben Cahill52969982007-11-29 11:10:11 +08001646 /*
1647 * MPDU byte count:
1648 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1649 * + 8 byte IV for CCM or TKIP (not used for WEP)
1650 * + Data payload
1651 * + 8-byte MIC (not used for CCM/WEP)
1652 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1653 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1654 * Range: 14-2342 bytes.
1655 */
Zhu Yib481de92007-09-25 17:54:57 -07001656 __le16 len;
Ben Cahill52969982007-11-29 11:10:11 +08001657
1658 /*
1659 * MPDU or MSDU byte count for next frame.
1660 * Used for fragmentation and bursting, but not 11n aggregation.
1661 * Same as "len", but for next frame. Set to 0 if not applicable.
1662 */
Zhu Yib481de92007-09-25 17:54:57 -07001663 __le16 next_frame_len;
Ben Cahill52969982007-11-29 11:10:11 +08001664
1665 __le32 tx_flags; /* TX_CMD_FLG_* */
1666
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001667 /* uCode may modify this field of the Tx command (in host DRAM!).
Ben Cahill52969982007-11-29 11:10:11 +08001668 * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001669 struct iwl_dram_scratch scratch;
Ben Cahill52969982007-11-29 11:10:11 +08001670
1671 /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
1672 __le32 rate_n_flags; /* RATE_MCS_* */
1673
1674 /* Index of destination station in uCode's station table */
Zhu Yib481de92007-09-25 17:54:57 -07001675 u8 sta_id;
Ben Cahill52969982007-11-29 11:10:11 +08001676
1677 /* Type of security encryption: CCM or TKIP */
1678 u8 sec_ctl; /* TX_CMD_SEC_* */
1679
1680 /*
1681 * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
1682 * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for
1683 * data frames, this field may be used to selectively reduce initial
1684 * rate (via non-0 value) for special frames (e.g. management), while
1685 * still supporting rate scaling for all frames.
1686 */
Zhu Yib481de92007-09-25 17:54:57 -07001687 u8 initial_rate_index;
1688 u8 reserved;
Zhu Yib481de92007-09-25 17:54:57 -07001689 u8 key[16];
Zhu Yib481de92007-09-25 17:54:57 -07001690 __le16 next_frame_flags;
1691 __le16 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -07001692 union {
1693 __le32 life_time;
1694 __le32 attempt;
1695 } stop_time;
Ben Cahill52969982007-11-29 11:10:11 +08001696
1697 /* Host DRAM physical address pointer to "scratch" in this command.
1698 * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */
Zhu Yib481de92007-09-25 17:54:57 -07001699 __le32 dram_lsb_ptr;
1700 u8 dram_msb_ptr;
Ben Cahill52969982007-11-29 11:10:11 +08001701
Zhu Yib481de92007-09-25 17:54:57 -07001702 u8 rts_retry_limit; /*byte 50 */
1703 u8 data_retry_limit; /*byte 51 */
Zhu Yib481de92007-09-25 17:54:57 -07001704 u8 tid_tspec;
Zhu Yib481de92007-09-25 17:54:57 -07001705 union {
1706 __le16 pm_frame_timeout;
1707 __le16 attempt_duration;
1708 } timeout;
Ben Cahill52969982007-11-29 11:10:11 +08001709
1710 /*
1711 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1712 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1713 */
Zhu Yib481de92007-09-25 17:54:57 -07001714 __le16 driver_txop;
Ben Cahill52969982007-11-29 11:10:11 +08001715
1716 /*
1717 * MAC header goes here, followed by 2 bytes padding if MAC header
1718 * length is 26 or 30 bytes, followed by payload data
1719 */
Zhu Yib481de92007-09-25 17:54:57 -07001720 u8 payload[0];
1721 struct ieee80211_hdr hdr[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001722} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001723
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001724/* TX command response is sent after *3945* transmission attempts.
Zhu Yib481de92007-09-25 17:54:57 -07001725 *
1726 * NOTES:
1727 *
1728 * TX_STATUS_FAIL_NEXT_FRAG
1729 *
1730 * If the fragment flag in the MAC header for the frame being transmitted
1731 * is set and there is insufficient time to transmit the next frame, the
1732 * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
1733 *
1734 * TX_STATUS_FIFO_UNDERRUN
1735 *
1736 * Indicates the host did not provide bytes to the FIFO fast enough while
1737 * a TX was in progress.
1738 *
1739 * TX_STATUS_FAIL_MGMNT_ABORT
1740 *
1741 * This status is only possible if the ABORT ON MGMT RX parameter was
1742 * set to true with the TX command.
1743 *
1744 * If the MSB of the status parameter is set then an abort sequence is
1745 * required. This sequence consists of the host activating the TX Abort
1746 * control line, and then waiting for the TX Abort command response. This
1747 * indicates that a the device is no longer in a transmit state, and that the
1748 * command FIFO has been cleared. The host must then deactivate the TX Abort
1749 * control line. Receiving is still allowed in this case.
1750 */
1751enum {
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001752 TX_3945_STATUS_SUCCESS = 0x01,
1753 TX_3945_STATUS_DIRECT_DONE = 0x02,
1754 TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82,
1755 TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83,
1756 TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1757 TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85,
1758 TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86,
1759 TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1760 TX_3945_STATUS_FAIL_DEST_PS = 0x88,
1761 TX_3945_STATUS_FAIL_ABORTED = 0x89,
1762 TX_3945_STATUS_FAIL_BT_RETRY = 0x8a,
1763 TX_3945_STATUS_FAIL_STA_INVALID = 0x8b,
1764 TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1765 TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d,
1766 TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
1767 TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1768 TX_3945_STATUS_FAIL_TX_LOCKED = 0x90,
1769 TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1770};
1771
1772/*
1773 * TX command response is sent after *agn* transmission attempts.
1774 *
1775 * both postpone and abort status are expected behavior from uCode. there is
1776 * no special operation required from driver; except for RFKILL_FLUSH,
1777 * which required tx flush host command to flush all the tx frames in queues
1778 */
1779enum {
Zhu Yib481de92007-09-25 17:54:57 -07001780 TX_STATUS_SUCCESS = 0x01,
1781 TX_STATUS_DIRECT_DONE = 0x02,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001782 /* postpone TX */
1783 TX_STATUS_POSTPONE_DELAY = 0x40,
1784 TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
1785 TX_STATUS_POSTPONE_BT_PRIO = 0x42,
1786 TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
1787 TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
1788 /* abort TX */
1789 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
Zhu Yib481de92007-09-25 17:54:57 -07001790 TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
1791 TX_STATUS_FAIL_LONG_LIMIT = 0x83,
1792 TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001793 TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
1794 TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
Zhu Yib481de92007-09-25 17:54:57 -07001795 TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1796 TX_STATUS_FAIL_DEST_PS = 0x88,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001797 TX_STATUS_FAIL_HOST_ABORTED = 0x89,
Zhu Yib481de92007-09-25 17:54:57 -07001798 TX_STATUS_FAIL_BT_RETRY = 0x8a,
1799 TX_STATUS_FAIL_STA_INVALID = 0x8b,
1800 TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1801 TX_STATUS_FAIL_TID_DISABLE = 0x8d,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001802 TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
Zhu Yib481de92007-09-25 17:54:57 -07001803 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001804 /* uCode drop due to FW drop request */
1805 TX_STATUS_FAIL_FW_DROP = 0x90,
1806 /*
1807 * uCode drop due to station color mismatch
1808 * between tx command and station table
1809 */
1810 TX_STATUS_FAIL_STA_COLOR_MISMATCH_DROP = 0x91,
Zhu Yib481de92007-09-25 17:54:57 -07001811};
1812
1813#define TX_PACKET_MODE_REGULAR 0x0000
1814#define TX_PACKET_MODE_BURST_SEQ 0x0100
1815#define TX_PACKET_MODE_BURST_FIRST 0x0200
1816
1817enum {
1818 TX_POWER_PA_NOT_ACTIVE = 0x0,
1819};
1820
1821enum {
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001822 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
Zhu Yib481de92007-09-25 17:54:57 -07001823 TX_STATUS_DELAY_MSK = 0x00000040,
1824 TX_STATUS_ABORT_MSK = 0x00000080,
1825 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
1826 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001827 TX_RESERVED = 0x00780000, /* bits 19:22 */
Zhu Yib481de92007-09-25 17:54:57 -07001828 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
1829 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
1830};
1831
1832/* *******************************
Ben Cahill52969982007-11-29 11:10:11 +08001833 * TX aggregation status
Zhu Yib481de92007-09-25 17:54:57 -07001834 ******************************* */
1835
1836enum {
1837 AGG_TX_STATE_TRANSMITTED = 0x00,
1838 AGG_TX_STATE_UNDERRUN_MSK = 0x01,
1839 AGG_TX_STATE_BT_PRIO_MSK = 0x02,
1840 AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1841 AGG_TX_STATE_ABORT_MSK = 0x08,
1842 AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1843 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1844 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
1845 AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1846 AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1847 AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1848 AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1849 AGG_TX_STATE_DELAY_TX_MSK = 0x400
1850};
1851
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001852#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
1853 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
1854 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
Zhu Yib481de92007-09-25 17:54:57 -07001855
Ben Cahill52969982007-11-29 11:10:11 +08001856/* # tx attempts for first frame in aggregation */
Zhu Yib481de92007-09-25 17:54:57 -07001857#define AGG_TX_STATE_TRY_CNT_POS 12
1858#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1859
Ben Cahill52969982007-11-29 11:10:11 +08001860/* Command ID and sequence number of Tx command for this frame */
Zhu Yib481de92007-09-25 17:54:57 -07001861#define AGG_TX_STATE_SEQ_NUM_POS 16
1862#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1863
1864/*
1865 * REPLY_TX = 0x1c (response)
Ben Cahill52969982007-11-29 11:10:11 +08001866 *
1867 * This response may be in one of two slightly different formats, indicated
1868 * by the frame_count field:
1869 *
1870 * 1) No aggregation (frame_count == 1). This reports Tx results for
1871 * a single frame. Multiple attempts, at various bit rates, may have
1872 * been made for this frame.
1873 *
1874 * 2) Aggregation (frame_count > 1). This reports Tx results for
1875 * 2 or more frames that used block-acknowledge. All frames were
1876 * transmitted at same rate. Rate scaling may have been used if first
1877 * frame in this new agg block failed in previous agg block(s).
1878 *
1879 * Note that, for aggregation, ACK (block-ack) status is not delivered here;
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001880 * block-ack has not been received by the time the agn device records
1881 * this status.
Ben Cahill52969982007-11-29 11:10:11 +08001882 * This status relates to reasons the tx might have been blocked or aborted
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001883 * within the sending station (this agn device), rather than whether it was
Ben Cahill52969982007-11-29 11:10:11 +08001884 * received successfully by the destination station.
Zhu Yib481de92007-09-25 17:54:57 -07001885 */
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001886struct agg_tx_status {
1887 __le16 status;
1888 __le16 sequence;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001889} __packed;
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001890
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001891struct iwl4965_tx_resp {
Zhu Yib481de92007-09-25 17:54:57 -07001892 u8 frame_count; /* 1 no aggregation, >1 aggregation */
Ben Cahill52969982007-11-29 11:10:11 +08001893 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
1894 u8 failure_rts; /* # failures due to unsuccessful RTS */
1895 u8 failure_frame; /* # failures due to no ACK (unused for agg) */
1896
1897 /* For non-agg: Rate at which frame was successful.
1898 * For agg: Rate at which all frames were transmitted. */
1899 __le32 rate_n_flags; /* RATE_MCS_* */
1900
1901 /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
1902 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1903 __le16 wireless_media_time; /* uSecs */
1904
Zhu Yib481de92007-09-25 17:54:57 -07001905 __le16 reserved;
Ben Cahill52969982007-11-29 11:10:11 +08001906 __le32 pa_power1; /* RF power amplifier measurement (not used) */
Zhu Yib481de92007-09-25 17:54:57 -07001907 __le32 pa_power2;
Ben Cahill52969982007-11-29 11:10:11 +08001908
1909 /*
1910 * For non-agg: frame status TX_STATUS_*
1911 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
1912 * fields follow this one, up to frame_count.
1913 * Bit fields:
1914 * 11- 0: AGG_TX_STATE_* status code
1915 * 15-12: Retry count for 1st frame in aggregation (retries
1916 * occur if tx failed for this frame when it was a
1917 * member of a previous aggregation block). If rate
1918 * scaling is used, retry count indicates the rate
1919 * table entry used for all frames in the new agg.
1920 * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
1921 */
Tomas Winkler25a65722008-06-12 09:47:07 +08001922 union {
1923 __le32 status;
1924 struct agg_tx_status agg_status[0]; /* for each agg frame */
1925 } u;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001926} __packed;
Ron Rindjunskyfe01b472008-01-28 14:07:24 +02001927
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001928/*
1929 * definitions for initial rate index field
Tomas Winklera96a27f2008-10-23 23:48:56 -07001930 * bits [3:0] initial rate index
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001931 * bits [6:4] rate table color, used for the initial rate
1932 * bit-7 invalid rate indication
1933 * i.e. rate was not chosen from rate table
1934 * or rate table color was changed during frame retries
1935 * refer tlc rate info
1936 */
1937
1938#define IWL50_TX_RES_INIT_RATE_INDEX_POS 0
1939#define IWL50_TX_RES_INIT_RATE_INDEX_MSK 0x0f
1940#define IWL50_TX_RES_RATE_TABLE_COLOR_POS 4
1941#define IWL50_TX_RES_RATE_TABLE_COLOR_MSK 0x70
1942#define IWL50_TX_RES_INV_RATE_INDEX_MSK 0x80
1943
1944/* refer to ra_tid */
1945#define IWL50_TX_RES_TID_POS 0
1946#define IWL50_TX_RES_TID_MSK 0x0f
1947#define IWL50_TX_RES_RA_POS 4
1948#define IWL50_TX_RES_RA_MSK 0xf0
1949
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001950struct iwl5000_tx_resp {
1951 u8 frame_count; /* 1 no aggregation, >1 aggregation */
1952 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
1953 u8 failure_rts; /* # failures due to unsuccessful RTS */
1954 u8 failure_frame; /* # failures due to no ACK (unused for agg) */
1955
1956 /* For non-agg: Rate at which frame was successful.
1957 * For agg: Rate at which all frames were transmitted. */
1958 __le32 rate_n_flags; /* RATE_MCS_* */
1959
1960 /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
1961 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1962 __le16 wireless_media_time; /* uSecs */
1963
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001964 u8 pa_status; /* RF power amplifier measurement (not used) */
1965 u8 pa_integ_res_a[3];
1966 u8 pa_integ_res_b[3];
1967 u8 pa_integ_res_C[3];
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001968
1969 __le32 tfd_info;
1970 __le16 seq_ctl;
1971 __le16 byte_cnt;
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001972 u8 tlc_info;
1973 u8 ra_tid; /* tid (0:3), sta_id (4:7) */
1974 __le16 frame_ctrl;
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001975 /*
1976 * For non-agg: frame status TX_STATUS_*
1977 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
1978 * fields follow this one, up to frame_count.
1979 * Bit fields:
1980 * 11- 0: AGG_TX_STATE_* status code
1981 * 15-12: Retry count for 1st frame in aggregation (retries
1982 * occur if tx failed for this frame when it was a
1983 * member of a previous aggregation block). If rate
1984 * scaling is used, retry count indicates the rate
1985 * table entry used for all frames in the new agg.
1986 * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
1987 */
1988 struct agg_tx_status status; /* TX status (in aggregation -
1989 * status of 1st frame) */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001990} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001991/*
1992 * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
Ben Cahill52969982007-11-29 11:10:11 +08001993 *
1994 * Reports Block-Acknowledge from recipient station
Zhu Yib481de92007-09-25 17:54:57 -07001995 */
Emmanuel Grumbach653fa4a2008-06-30 17:23:11 +08001996struct iwl_compressed_ba_resp {
Zhu Yib481de92007-09-25 17:54:57 -07001997 __le32 sta_addr_lo32;
1998 __le16 sta_addr_hi16;
1999 __le16 reserved;
Ben Cahill52969982007-11-29 11:10:11 +08002000
2001 /* Index of recipient (BA-sending) station in uCode's station table */
Zhu Yib481de92007-09-25 17:54:57 -07002002 u8 sta_id;
2003 u8 tid;
Ron Rindjunskyfe01b472008-01-28 14:07:24 +02002004 __le16 seq_ctl;
2005 __le64 bitmap;
Zhu Yib481de92007-09-25 17:54:57 -07002006 __le16 scd_flow;
2007 __le16 scd_ssn;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002008} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002009
2010/*
2011 * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
Ben Cahill2bdc7032007-11-29 11:10:12 +08002012 *
2013 * See details under "TXPOWER" in iwl-4965-hw.h.
Zhu Yib481de92007-09-25 17:54:57 -07002014 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002015
2016struct iwl3945_txpowertable_cmd {
2017 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
2018 u8 reserved;
2019 __le16 channel;
2020 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002021} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002022
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002023struct iwl4965_txpowertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002024 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
2025 u8 reserved;
2026 __le16 channel;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002027 struct iwl4965_tx_power_db tx_power;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002028} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002029
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002030
2031/**
2032 * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response
2033 *
2034 * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
2035 *
2036 * NOTE: The table of rates passed to the uCode via the
2037 * RATE_SCALE command sets up the corresponding order of
2038 * rates used for all related commands, including rate
2039 * masks, etc.
2040 *
2041 * For example, if you set 9MB (PLCP 0x0f) as the first
2042 * rate in the rate table, the bit mask for that rate
2043 * when passed through ofdm_basic_rates on the REPLY_RXON
2044 * command would be bit 0 (1 << 0)
2045 */
2046struct iwl3945_rate_scaling_info {
2047 __le16 rate_n_flags;
2048 u8 try_cnt;
2049 u8 next_rate_index;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002050} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002051
2052struct iwl3945_rate_scaling_cmd {
2053 u8 table_id;
2054 u8 reserved[3];
2055 struct iwl3945_rate_scaling_info table[IWL_MAX_RATES];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002056} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002057
2058
Zhu Yib481de92007-09-25 17:54:57 -07002059/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
Reinette Chatre8a1b0242008-01-14 17:46:25 -08002060#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0)
Zhu Yib481de92007-09-25 17:54:57 -07002061
Ben Cahill2bdc7032007-11-29 11:10:12 +08002062/* # of EDCA prioritized tx fifos */
Zhu Yib481de92007-09-25 17:54:57 -07002063#define LINK_QUAL_AC_NUM AC_NUM
Ben Cahill2bdc7032007-11-29 11:10:12 +08002064
2065/* # entries in rate scale table to support Tx retries */
Zhu Yib481de92007-09-25 17:54:57 -07002066#define LINK_QUAL_MAX_RETRY_NUM 16
2067
Ben Cahill2bdc7032007-11-29 11:10:12 +08002068/* Tx antenna selection values */
Reinette Chatre8a1b0242008-01-14 17:46:25 -08002069#define LINK_QUAL_ANT_A_MSK (1 << 0)
2070#define LINK_QUAL_ANT_B_MSK (1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -07002071#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
2072
Ben Cahill2bdc7032007-11-29 11:10:12 +08002073
2074/**
Tomas Winkler66c73db2008-04-15 16:01:40 -07002075 * struct iwl_link_qual_general_params
Ben Cahill2bdc7032007-11-29 11:10:12 +08002076 *
2077 * Used in REPLY_TX_LINK_QUALITY_CMD
2078 */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002079struct iwl_link_qual_general_params {
Zhu Yib481de92007-09-25 17:54:57 -07002080 u8 flags;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002081
2082 /* No entries at or above this (driver chosen) index contain MIMO */
Zhu Yib481de92007-09-25 17:54:57 -07002083 u8 mimo_delimiter;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002084
2085 /* Best single antenna to use for single stream (legacy, SISO). */
2086 u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */
2087
2088 /* Best antennas to use for MIMO (unused for 4965, assumes both). */
2089 u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */
2090
2091 /*
2092 * If driver needs to use different initial rates for different
2093 * EDCA QOS access categories (as implemented by tx fifos 0-3),
2094 * this table will set that up, by indicating the indexes in the
2095 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
2096 * Otherwise, driver should set all entries to 0.
2097 *
2098 * Entry usage:
2099 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
2100 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
2101 */
Zhu Yib481de92007-09-25 17:54:57 -07002102 u8 start_rate_index[LINK_QUAL_AC_NUM];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002103} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002104
Wey-Yi Guy13c33a02009-06-03 11:44:11 -07002105#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */
Wey-Yi Guyb15826a2010-07-28 09:18:53 -07002106#define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000)
2107#define LINK_QUAL_AGG_TIME_LIMIT_MIN (100)
Wey-Yi Guy13c33a02009-06-03 11:44:11 -07002108
2109#define LINK_QUAL_AGG_DISABLE_START_DEF (3)
2110#define LINK_QUAL_AGG_DISABLE_START_MAX (255)
2111#define LINK_QUAL_AGG_DISABLE_START_MIN (0)
2112
2113#define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31)
Johannes Bergb623a9f2009-07-01 14:57:59 +02002114#define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63)
Wey-Yi Guy13c33a02009-06-03 11:44:11 -07002115#define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0)
2116
Ben Cahill2bdc7032007-11-29 11:10:12 +08002117/**
Tomas Winkler66c73db2008-04-15 16:01:40 -07002118 * struct iwl_link_qual_agg_params
Ben Cahill2bdc7032007-11-29 11:10:12 +08002119 *
2120 * Used in REPLY_TX_LINK_QUALITY_CMD
2121 */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002122struct iwl_link_qual_agg_params {
Ben Cahill2bdc7032007-11-29 11:10:12 +08002123
Wey-Yi Guy74697012010-07-28 09:18:54 -07002124 /*
2125 *Maximum number of uSec in aggregation.
2126 * default set to 4000 (4 milliseconds) if not configured in .cfg
2127 */
Zhu Yib481de92007-09-25 17:54:57 -07002128 __le16 agg_time_limit;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002129
2130 /*
2131 * Number of Tx retries allowed for a frame, before that frame will
2132 * no longer be considered for the start of an aggregation sequence
2133 * (scheduler will then try to tx it as single frame).
2134 * Driver should set this to 3.
2135 */
Zhu Yib481de92007-09-25 17:54:57 -07002136 u8 agg_dis_start_th;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002137
2138 /*
2139 * Maximum number of frames in aggregation.
2140 * 0 = no limit (default). 1 = no aggregation.
2141 * Other values = max # frames in aggregation.
2142 */
Zhu Yib481de92007-09-25 17:54:57 -07002143 u8 agg_frame_cnt_limit;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002144
Zhu Yib481de92007-09-25 17:54:57 -07002145 __le32 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002146} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002147
2148/*
2149 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
Ben Cahill2bdc7032007-11-29 11:10:12 +08002150 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002151 * For agn devices only; 3945 uses REPLY_RATE_SCALE.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002152 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002153 * Each station in the agn device's internal station table has its own table
2154 * of 16
Ben Cahill2bdc7032007-11-29 11:10:12 +08002155 * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
2156 * an ACK is not received. This command replaces the entire table for
2157 * one station.
2158 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002159 * NOTE: Station must already be in agn device's station table.
2160 * Use REPLY_ADD_STA.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002161 *
2162 * The rate scaling procedures described below work well. Of course, other
2163 * procedures are possible, and may work better for particular environments.
2164 *
2165 *
2166 * FILLING THE RATE TABLE
2167 *
2168 * Given a particular initial rate and mode, as determined by the rate
2169 * scaling algorithm described below, the Linux driver uses the following
2170 * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
2171 * Link Quality command:
2172 *
2173 *
2174 * 1) If using High-throughput (HT) (SISO or MIMO) initial rate:
2175 * a) Use this same initial rate for first 3 entries.
2176 * b) Find next lower available rate using same mode (SISO or MIMO),
2177 * use for next 3 entries. If no lower rate available, switch to
Wey-Yi Guy7aafef12009-08-07 15:41:38 -07002178 * legacy mode (no HT40 channel, no MIMO, no short guard interval).
Ben Cahill2bdc7032007-11-29 11:10:12 +08002179 * c) If using MIMO, set command's mimo_delimiter to number of entries
2180 * using MIMO (3 or 6).
Wey-Yi Guy7aafef12009-08-07 15:41:38 -07002181 * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
Ben Cahill2bdc7032007-11-29 11:10:12 +08002182 * no MIMO, no short guard interval), at the next lower bit rate
2183 * (e.g. if second HT bit rate was 54, try 48 legacy), and follow
2184 * legacy procedure for remaining table entries.
2185 *
2186 * 2) If using legacy initial rate:
2187 * a) Use the initial rate for only one entry.
2188 * b) For each following entry, reduce the rate to next lower available
2189 * rate, until reaching the lowest available rate.
2190 * c) When reducing rate, also switch antenna selection.
2191 * d) Once lowest available rate is reached, repeat this rate until
2192 * rate table is filled (16 entries), switching antenna each entry.
2193 *
2194 *
2195 * ACCUMULATING HISTORY
2196 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002197 * The rate scaling algorithm for agn devices, as implemented in Linux driver,
2198 * uses two sets of frame Tx success history: One for the current/active
2199 * modulation mode, and one for a speculative/search mode that is being
2200 * attempted. If the speculative mode turns out to be more effective (i.e.
2201 * actual transfer rate is better), then the driver continues to use the
2202 * speculative mode as the new current active mode.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002203 *
2204 * Each history set contains, separately for each possible rate, data for a
2205 * sliding window of the 62 most recent tx attempts at that rate. The data
2206 * includes a shifting bitmap of success(1)/failure(0), and sums of successful
2207 * and attempted frames, from which the driver can additionally calculate a
2208 * success ratio (success / attempted) and number of failures
2209 * (attempted - success), and control the size of the window (attempted).
2210 * The driver uses the bit map to remove successes from the success sum, as
2211 * the oldest tx attempts fall out of the window.
2212 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002213 * When the agn device makes multiple tx attempts for a given frame, each
2214 * attempt might be at a different rate, and have different modulation
2215 * characteristics (e.g. antenna, fat channel, short guard interval), as set
2216 * up in the rate scaling table in the Link Quality command. The driver must
2217 * determine which rate table entry was used for each tx attempt, to determine
2218 * which rate-specific history to update, and record only those attempts that
Ben Cahill2bdc7032007-11-29 11:10:12 +08002219 * match the modulation characteristics of the history set.
2220 *
2221 * When using block-ack (aggregation), all frames are transmitted at the same
Tomas Winklera96a27f2008-10-23 23:48:56 -07002222 * rate, since there is no per-attempt acknowledgment from the destination
Ben Cahill2bdc7032007-11-29 11:10:12 +08002223 * station. The Tx response struct iwl_tx_resp indicates the Tx rate in
2224 * rate_n_flags field. After receiving a block-ack, the driver can update
2225 * history for the entire block all at once.
2226 *
2227 *
2228 * FINDING BEST STARTING RATE:
2229 *
2230 * When working with a selected initial modulation mode (see below), the
2231 * driver attempts to find a best initial rate. The initial rate is the
2232 * first entry in the Link Quality command's rate table.
2233 *
2234 * 1) Calculate actual throughput (success ratio * expected throughput, see
2235 * table below) for current initial rate. Do this only if enough frames
2236 * have been attempted to make the value meaningful: at least 6 failed
2237 * tx attempts, or at least 8 successes. If not enough, don't try rate
2238 * scaling yet.
2239 *
2240 * 2) Find available rates adjacent to current initial rate. Available means:
2241 * a) supported by hardware &&
2242 * b) supported by association &&
2243 * c) within any constraints selected by user
2244 *
2245 * 3) Gather measured throughputs for adjacent rates. These might not have
2246 * enough history to calculate a throughput. That's okay, we might try
2247 * using one of them anyway!
2248 *
2249 * 4) Try decreasing rate if, for current rate:
2250 * a) success ratio is < 15% ||
2251 * b) lower adjacent rate has better measured throughput ||
2252 * c) higher adjacent rate has worse throughput, and lower is unmeasured
2253 *
2254 * As a sanity check, if decrease was determined above, leave rate
2255 * unchanged if:
2256 * a) lower rate unavailable
2257 * b) success ratio at current rate > 85% (very good)
2258 * c) current measured throughput is better than expected throughput
2259 * of lower rate (under perfect 100% tx conditions, see table below)
2260 *
2261 * 5) Try increasing rate if, for current rate:
2262 * a) success ratio is < 15% ||
2263 * b) both adjacent rates' throughputs are unmeasured (try it!) ||
2264 * b) higher adjacent rate has better measured throughput ||
2265 * c) lower adjacent rate has worse throughput, and higher is unmeasured
2266 *
2267 * As a sanity check, if increase was determined above, leave rate
2268 * unchanged if:
2269 * a) success ratio at current rate < 70%. This is not particularly
2270 * good performance; higher rate is sure to have poorer success.
2271 *
2272 * 6) Re-evaluate the rate after each tx frame. If working with block-
2273 * acknowledge, history and statistics may be calculated for the entire
2274 * block (including prior history that fits within the history windows),
2275 * before re-evaluation.
2276 *
2277 * FINDING BEST STARTING MODULATION MODE:
2278 *
2279 * After working with a modulation mode for a "while" (and doing rate scaling),
2280 * the driver searches for a new initial mode in an attempt to improve
2281 * throughput. The "while" is measured by numbers of attempted frames:
2282 *
2283 * For legacy mode, search for new mode after:
2284 * 480 successful frames, or 160 failed frames
2285 * For high-throughput modes (SISO or MIMO), search for new mode after:
2286 * 4500 successful frames, or 400 failed frames
2287 *
2288 * Mode switch possibilities are (3 for each mode):
2289 *
2290 * For legacy:
2291 * Change antenna, try SISO (if HT association), try MIMO (if HT association)
2292 * For SISO:
2293 * Change antenna, try MIMO, try shortened guard interval (SGI)
2294 * For MIMO:
2295 * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
2296 *
2297 * When trying a new mode, use the same bit rate as the old/current mode when
2298 * trying antenna switches and shortened guard interval. When switching to
2299 * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
2300 * for which the expected throughput (under perfect conditions) is about the
2301 * same or slightly better than the actual measured throughput delivered by
2302 * the old/current mode.
2303 *
2304 * Actual throughput can be estimated by multiplying the expected throughput
2305 * by the success ratio (successful / attempted tx frames). Frame size is
2306 * not considered in this calculation; it assumes that frame size will average
2307 * out to be fairly consistent over several samples. The following are
2308 * metric values for expected throughput assuming 100% success ratio.
2309 * Only G band has support for CCK rates:
2310 *
2311 * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60
2312 *
2313 * G: 7 13 35 58 40 57 72 98 121 154 177 186 186
2314 * A: 0 0 0 0 40 57 72 98 121 154 177 186 186
2315 * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202
2316 * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211
2317 * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251
2318 * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257
2319 * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257
2320 * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264
2321 * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289
2322 * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293
2323 *
2324 * After the new mode has been tried for a short while (minimum of 6 failed
2325 * frames or 8 successful frames), compare success ratio and actual throughput
2326 * estimate of the new mode with the old. If either is better with the new
2327 * mode, continue to use the new mode.
2328 *
2329 * Continue comparing modes until all 3 possibilities have been tried.
2330 * If moving from legacy to HT, try all 3 possibilities from the new HT
2331 * mode. After trying all 3, a best mode is found. Continue to use this mode
2332 * for the longer "while" described above (e.g. 480 successful frames for
2333 * legacy), and then repeat the search process.
2334 *
Zhu Yib481de92007-09-25 17:54:57 -07002335 */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002336struct iwl_link_quality_cmd {
Ben Cahill2bdc7032007-11-29 11:10:12 +08002337
2338 /* Index of destination/recipient station in uCode's station table */
Zhu Yib481de92007-09-25 17:54:57 -07002339 u8 sta_id;
2340 u8 reserved1;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002341 __le16 control; /* not used */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002342 struct iwl_link_qual_general_params general_params;
2343 struct iwl_link_qual_agg_params agg_params;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002344
2345 /*
2346 * Rate info; when using rate-scaling, Tx command's initial_rate_index
2347 * specifies 1st Tx rate attempted, via index into this table.
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002348 * agn devices works its way through table when retrying Tx.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002349 */
Zhu Yib481de92007-09-25 17:54:57 -07002350 struct {
Ben Cahill2bdc7032007-11-29 11:10:12 +08002351 __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */
Zhu Yib481de92007-09-25 17:54:57 -07002352 } rs_table[LINK_QUAL_MAX_RETRY_NUM];
2353 __le32 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002354} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002355
Wey-Yi Guydab1c162010-01-22 14:22:50 -08002356/*
2357 * BT configuration enable flags:
2358 * bit 0 - 1: BT channel announcement enabled
2359 * 0: disable
2360 * bit 1 - 1: priority of BT device enabled
2361 * 0: disable
2362 * bit 2 - 1: BT 2 wire support enabled
2363 * 0: disable
2364 */
Wey-Yi Guy456d0f72009-10-23 13:42:23 -07002365#define BT_COEX_DISABLE (0x0)
Wey-Yi Guydab1c162010-01-22 14:22:50 -08002366#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0)
2367#define BT_ENABLE_PRIORITY BIT(1)
2368#define BT_ENABLE_2_WIRE BIT(2)
Wey-Yi Guy456d0f72009-10-23 13:42:23 -07002369
Wey-Yi Guy06702a72010-01-22 14:22:51 -08002370#define BT_COEX_DISABLE (0x0)
2371#define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY)
2372
Wey-Yi Guy456d0f72009-10-23 13:42:23 -07002373#define BT_LEAD_TIME_MIN (0x0)
2374#define BT_LEAD_TIME_DEF (0x1E)
2375#define BT_LEAD_TIME_MAX (0xFF)
2376
2377#define BT_MAX_KILL_MIN (0x1)
2378#define BT_MAX_KILL_DEF (0x5)
2379#define BT_MAX_KILL_MAX (0xFF)
2380
Zhu Yib481de92007-09-25 17:54:57 -07002381/*
2382 * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
Ben Cahill3058f022008-01-14 17:46:17 -08002383 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002384 * 3945 and agn devices support hardware handshake with Bluetooth device on
Ben Cahill3058f022008-01-14 17:46:17 -08002385 * same platform. Bluetooth device alerts wireless device when it will Tx;
Tomas Winklera96a27f2008-10-23 23:48:56 -07002386 * wireless device can delay or kill its own Tx to accommodate.
Zhu Yib481de92007-09-25 17:54:57 -07002387 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002388struct iwl_bt_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002389 u8 flags;
2390 u8 lead_time;
2391 u8 max_kill;
2392 u8 reserved;
2393 __le32 kill_ack_mask;
2394 __le32 kill_cts_mask;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002395} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002396
Johannes Berg670245e2010-08-23 07:56:55 -07002397#define IWL6000G2B_BT_FLAG_CHANNEL_INHIBITION BIT(0)
2398
2399#define IWL6000G2B_BT_FLAG_COEX_MODE_MASK (BIT(3)|BIT(4)|BIT(5))
2400#define IWL6000G2B_BT_FLAG_COEX_MODE_SHIFT 3
2401#define IWL6000G2B_BT_FLAG_COEX_MODE_DISABLED 0
2402#define IWL6000G2B_BT_FLAG_COEX_MODE_LEGACY_2W 1
2403#define IWL6000G2B_BT_FLAG_COEX_MODE_3W 2
2404#define IWL6000G2B_BT_FLAG_COEX_MODE_4W 3
2405
2406#define IWL6000G2B_BT_FLAG_UCODE_DEFAULT BIT(6)
2407#define IWL6000G2B_BT_FLAG_NOCOEX_NOTIF BIT(7)
2408
2409#define IWL6000G2B_BT_PRIO_BOOST_MAX 0xFF
2410#define IWL6000G2B_BT_PRIO_BOOST_MIN 0x00
2411#define IWL6000G2B_BT_PRIO_BOOST_DEFAULT 0x00
2412
2413#define IWL6000G2B_BT_MAX_KILL_DEFAULT 5
2414
2415#define IWL6000G2B_BT3_T7_DEFAULT 1
2416
2417#define IWL6000G2B_BT_KILL_ACK_MASK_DEFAULT cpu_to_le32(0xffffffff)
2418#define IWL6000G2B_BT_KILL_CTS_MASK_DEFAULT cpu_to_le32(0xffffffff)
2419
2420#define IWL6000G2B_BT3_PRIO_SAMPLE_DEFAULT 2
2421
2422#define IWL6000G2B_BT3_T2_DEFAULT 0xc
2423
2424#define IWL6000G2B_BT_VALID_ENABLE_FLAGS cpu_to_le16(BIT(0))
2425#define IWL6000G2B_BT_VALID_BOOST cpu_to_le16(BIT(1))
2426#define IWL6000G2B_BT_VALID_MAX_KILL cpu_to_le16(BIT(2))
2427#define IWL6000G2B_BT_VALID_3W_TIMERS cpu_to_le16(BIT(3))
2428#define IWL6000G2B_BT_VALID_KILL_ACK_MASK cpu_to_le16(BIT(4))
2429#define IWL6000G2B_BT_VALID_KILL_CTS_MASK cpu_to_le16(BIT(5))
2430#define IWL6000G2B_BT_VALID_BT4_TIMES cpu_to_le16(BIT(6))
2431#define IWL6000G2B_BT_VALID_3W_LUT cpu_to_le16(BIT(7))
2432
2433#define IWL6000G2B_BT_ALL_VALID_MSK (IWL6000G2B_BT_VALID_ENABLE_FLAGS | \
2434 IWL6000G2B_BT_VALID_BOOST | \
2435 IWL6000G2B_BT_VALID_MAX_KILL | \
2436 IWL6000G2B_BT_VALID_3W_TIMERS | \
2437 IWL6000G2B_BT_VALID_KILL_ACK_MASK | \
2438 IWL6000G2B_BT_VALID_KILL_CTS_MASK | \
2439 IWL6000G2B_BT_VALID_BT4_TIMES | \
2440 IWL6000G2B_BT_VALID_3W_LUT)
2441
2442struct iwl6000g2b_bt_cmd {
2443 u8 flags;
2444 u8 ledtime; /* unused */
2445 u8 max_kill;
2446 u8 bt3_timer_t7_value;
2447 __le32 kill_ack_mask;
2448 __le32 kill_cts_mask;
2449 u8 bt3_prio_sample_time;
2450 u8 bt3_timer_t2_value;
2451 __le16 bt4_reaction_time; /* unused */
2452 __le32 bt3_lookup_table[12];
2453 __le16 bt4_decision_time; /* unused */
2454 __le16 valid;
2455 u8 prio_boost;
2456 u8 reserved[3];
2457};
2458
Zhu Yib481de92007-09-25 17:54:57 -07002459/******************************************************************************
2460 * (6)
2461 * Spectrum Management (802.11h) Commands, Responses, Notifications:
2462 *
2463 *****************************************************************************/
2464
2465/*
2466 * Spectrum Management
2467 */
2468#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
2469 RXON_FILTER_CTL2HOST_MSK | \
2470 RXON_FILTER_ACCEPT_GRP_MSK | \
2471 RXON_FILTER_DIS_DECRYPT_MSK | \
2472 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
2473 RXON_FILTER_ASSOC_MSK | \
2474 RXON_FILTER_BCON_AWARE_MSK)
2475
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002476struct iwl_measure_channel {
Zhu Yib481de92007-09-25 17:54:57 -07002477 __le32 duration; /* measurement duration in extended beacon
2478 * format */
2479 u8 channel; /* channel to measure */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002480 u8 type; /* see enum iwl_measure_type */
Zhu Yib481de92007-09-25 17:54:57 -07002481 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002482} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002483
2484/*
2485 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
2486 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002487struct iwl_spectrum_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002488 __le16 len; /* number of bytes starting from token */
2489 u8 token; /* token id */
2490 u8 id; /* measurement id -- 0 or 1 */
2491 u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
2492 u8 periodic; /* 1 = periodic */
2493 __le16 path_loss_timeout;
2494 __le32 start_time; /* start time in extended beacon format */
2495 __le32 reserved2;
2496 __le32 flags; /* rxon flags */
2497 __le32 filter_flags; /* rxon filter flags */
2498 __le16 channel_count; /* minimum 1, maximum 10 */
2499 __le16 reserved3;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002500 struct iwl_measure_channel channels[10];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002501} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002502
2503/*
2504 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
2505 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002506struct iwl_spectrum_resp {
Zhu Yib481de92007-09-25 17:54:57 -07002507 u8 token;
2508 u8 id; /* id of the prior command replaced, or 0xff */
2509 __le16 status; /* 0 - command will be handled
2510 * 1 - cannot handle (conflicts with another
2511 * measurement) */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002512} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002513
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002514enum iwl_measurement_state {
Zhu Yib481de92007-09-25 17:54:57 -07002515 IWL_MEASUREMENT_START = 0,
2516 IWL_MEASUREMENT_STOP = 1,
2517};
2518
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002519enum iwl_measurement_status {
Zhu Yib481de92007-09-25 17:54:57 -07002520 IWL_MEASUREMENT_OK = 0,
2521 IWL_MEASUREMENT_CONCURRENT = 1,
2522 IWL_MEASUREMENT_CSA_CONFLICT = 2,
2523 IWL_MEASUREMENT_TGH_CONFLICT = 3,
2524 /* 4-5 reserved */
2525 IWL_MEASUREMENT_STOPPED = 6,
2526 IWL_MEASUREMENT_TIMEOUT = 7,
2527 IWL_MEASUREMENT_PERIODIC_FAILED = 8,
2528};
2529
2530#define NUM_ELEMENTS_IN_HISTOGRAM 8
2531
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002532struct iwl_measurement_histogram {
Zhu Yib481de92007-09-25 17:54:57 -07002533 __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
2534 __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002535} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002536
2537/* clear channel availability counters */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002538struct iwl_measurement_cca_counters {
Zhu Yib481de92007-09-25 17:54:57 -07002539 __le32 ofdm;
2540 __le32 cck;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002541} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002542
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002543enum iwl_measure_type {
Zhu Yib481de92007-09-25 17:54:57 -07002544 IWL_MEASURE_BASIC = (1 << 0),
2545 IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
2546 IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
2547 IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
2548 IWL_MEASURE_FRAME = (1 << 4),
2549 /* bits 5:6 are reserved */
2550 IWL_MEASURE_IDLE = (1 << 7),
2551};
2552
2553/*
2554 * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
2555 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002556struct iwl_spectrum_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002557 u8 id; /* measurement id -- 0 or 1 */
2558 u8 token;
2559 u8 channel_index; /* index in measurement channel list */
2560 u8 state; /* 0 - start, 1 - stop */
2561 __le32 start_time; /* lower 32-bits of TSF */
2562 u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
2563 u8 channel;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002564 u8 type; /* see enum iwl_measurement_type */
Zhu Yib481de92007-09-25 17:54:57 -07002565 u8 reserved1;
2566 /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
2567 * valid if applicable for measurement type requested. */
2568 __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
2569 __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
2570 __le32 cca_time; /* channel load time in usecs */
2571 u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
2572 * unidentified */
2573 u8 reserved2[3];
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002574 struct iwl_measurement_histogram histogram;
Zhu Yib481de92007-09-25 17:54:57 -07002575 __le32 stop_time; /* lower 32-bits of TSF */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002576 __le32 status; /* see iwl_measurement_status */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002577} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002578
2579/******************************************************************************
2580 * (7)
2581 * Power Management Commands, Responses, Notifications:
2582 *
2583 *****************************************************************************/
2584
2585/**
Mohamed Abbasca579612008-07-18 13:52:57 +08002586 * struct iwl_powertable_cmd - Power Table Command
Zhu Yib481de92007-09-25 17:54:57 -07002587 * @flags: See below:
2588 *
2589 * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
2590 *
2591 * PM allow:
2592 * bit 0 - '0' Driver not allow power management
2593 * '1' Driver allow PM (use rest of parameters)
Johannes Berge312c242009-08-07 15:41:51 -07002594 *
Zhu Yib481de92007-09-25 17:54:57 -07002595 * uCode send sleep notifications:
2596 * bit 1 - '0' Don't send sleep notification
2597 * '1' send sleep notification (SEND_PM_NOTIFICATION)
Johannes Berge312c242009-08-07 15:41:51 -07002598 *
Zhu Yib481de92007-09-25 17:54:57 -07002599 * Sleep over DTIM
2600 * bit 2 - '0' PM have to walk up every DTIM
2601 * '1' PM could sleep over DTIM till listen Interval.
Johannes Berge312c242009-08-07 15:41:51 -07002602 *
Zhu Yib481de92007-09-25 17:54:57 -07002603 * PCI power managed
Tomas Winklere7b63582008-09-03 11:26:49 +08002604 * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
2605 * '1' !(PCI_CFG_LINK_CTRL & 0x1)
Johannes Berge312c242009-08-07 15:41:51 -07002606 *
2607 * Fast PD
2608 * bit 4 - '1' Put radio to sleep when receiving frame for others
2609 *
Zhu Yib481de92007-09-25 17:54:57 -07002610 * Force sleep Modes
2611 * bit 31/30- '00' use both mac/xtal sleeps
2612 * '01' force Mac sleep
2613 * '10' force xtal sleep
2614 * '11' Illegal set
2615 *
2616 * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
Tomas Winklera96a27f2008-10-23 23:48:56 -07002617 * ucode assume sleep over DTIM is allowed and we don't need to wake up
Zhu Yib481de92007-09-25 17:54:57 -07002618 * for every DTIM.
2619 */
2620#define IWL_POWER_VEC_SIZE 5
2621
Tomas Winkler600c0e12008-12-19 10:37:04 +08002622#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0))
2623#define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le16(BIT(2))
2624#define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3))
2625#define IWL_POWER_FAST_PD cpu_to_le16(BIT(4))
2626
2627struct iwl3945_powertable_cmd {
2628 __le16 flags;
2629 u8 reserved[2];
2630 __le32 rx_data_timeout;
2631 __le32 tx_data_timeout;
2632 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002633} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002634
Mohamed Abbasca579612008-07-18 13:52:57 +08002635struct iwl_powertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002636 __le16 flags;
Tomas Winkler600c0e12008-12-19 10:37:04 +08002637 u8 keep_alive_seconds; /* 3945 reserved */
2638 u8 debug_flags; /* 3945 reserved */
Zhu Yib481de92007-09-25 17:54:57 -07002639 __le32 rx_data_timeout;
2640 __le32 tx_data_timeout;
2641 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
2642 __le32 keep_alive_beacons;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002643} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002644
2645/*
2646 * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002647 * all devices identical.
Zhu Yib481de92007-09-25 17:54:57 -07002648 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002649struct iwl_sleep_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002650 u8 pm_sleep_mode;
2651 u8 pm_wakeup_src;
2652 __le16 reserved;
2653 __le32 sleep_time;
2654 __le32 tsf_low;
2655 __le32 bcon_timer;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002656} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002657
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002658/* Sleep states. all devices identical. */
Zhu Yib481de92007-09-25 17:54:57 -07002659enum {
2660 IWL_PM_NO_SLEEP = 0,
2661 IWL_PM_SLP_MAC = 1,
2662 IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
2663 IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
2664 IWL_PM_SLP_PHY = 4,
2665 IWL_PM_SLP_REPENT = 5,
2666 IWL_PM_WAKEUP_BY_TIMER = 6,
2667 IWL_PM_WAKEUP_BY_DRIVER = 7,
2668 IWL_PM_WAKEUP_BY_RFKILL = 8,
2669 /* 3 reserved */
2670 IWL_PM_NUM_OF_MODES = 12,
2671};
2672
2673/*
2674 * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
2675 */
2676#define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
2677#define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
2678#define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002679struct iwl_card_state_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002680 __le32 status; /* CARD_STATE_CMD_* request new power state */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002681} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002682
2683/*
2684 * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
2685 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002686struct iwl_card_state_notif {
Zhu Yib481de92007-09-25 17:54:57 -07002687 __le32 flags;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002688} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002689
2690#define HW_CARD_DISABLED 0x01
2691#define SW_CARD_DISABLED 0x02
Wey-Yi Guy3a41bbd2009-12-10 14:37:24 -08002692#define CT_CARD_DISABLED 0x04
Zhu Yib481de92007-09-25 17:54:57 -07002693#define RXON_CARD_DISABLED 0x10
2694
Emmanuel Grumbach47f4a582008-06-12 09:47:13 +08002695struct iwl_ct_kill_config {
Zhu Yib481de92007-09-25 17:54:57 -07002696 __le32 reserved;
2697 __le32 critical_temperature_M;
2698 __le32 critical_temperature_R;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002699} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002700
Wey-Yi Guy672639d2009-07-24 11:13:01 -07002701/* 1000, and 6x00 */
2702struct iwl_ct_kill_throttling_config {
2703 __le32 critical_temperature_exit;
2704 __le32 reserved;
2705 __le32 critical_temperature_enter;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002706} __packed;
Wey-Yi Guy672639d2009-07-24 11:13:01 -07002707
Zhu Yib481de92007-09-25 17:54:57 -07002708/******************************************************************************
2709 * (8)
2710 * Scan Commands, Responses, Notifications:
2711 *
2712 *****************************************************************************/
2713
Harvey Harrison51e9bf52008-11-26 13:12:52 -08002714#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
2715#define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1)
Tomas Winklerd16dc482008-07-11 11:53:38 +08002716
Ben Cahill3058f022008-01-14 17:46:17 -08002717/**
Tomas Winkler2a421b92008-06-12 09:47:10 +08002718 * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
Ben Cahill3058f022008-01-14 17:46:17 -08002719 *
2720 * One for each channel in the scan list.
2721 * Each channel can independently select:
2722 * 1) SSID for directed active scans
2723 * 2) Txpower setting (for rate specified within Tx command)
2724 * 3) How long to stay on-channel (behavior may be modified by quiet_time,
2725 * quiet_plcp_th, good_CRC_th)
2726 *
2727 * To avoid uCode errors, make sure the following are true (see comments
Tomas Winkler2a421b92008-06-12 09:47:10 +08002728 * under struct iwl_scan_cmd about max_out_time and quiet_time):
Ben Cahill3058f022008-01-14 17:46:17 -08002729 * 1) If using passive_dwell (i.e. passive_dwell != 0):
2730 * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
2731 * 2) quiet_time <= active_dwell
2732 * 3) If restricting off-channel time (i.e. max_out_time !=0):
2733 * passive_dwell < max_out_time
2734 * active_dwell < max_out_time
2735 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002736
2737/* FIXME: rename to AP1, remove tpc */
2738struct iwl3945_scan_channel {
2739 /*
2740 * type is defined as:
2741 * 0:0 1 = active, 0 = passive
2742 * 1:4 SSID direct bit map; if a bit is set, then corresponding
2743 * SSID IE is transmitted in probe request.
2744 * 5:7 reserved
2745 */
2746 u8 type;
2747 u8 channel; /* band is selected by iwl3945_scan_cmd "flags" field */
2748 struct iwl3945_tx_power tpc;
2749 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2750 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002751} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002752
Winkler, Tomas0d210442009-01-23 13:45:21 -08002753/* set number of direct probes u8 type */
2754#define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1))))
2755
Tomas Winkler2a421b92008-06-12 09:47:10 +08002756struct iwl_scan_channel {
Ben Cahill3058f022008-01-14 17:46:17 -08002757 /*
2758 * type is defined as:
2759 * 0:0 1 = active, 0 = passive
Tomas Winklerd16dc482008-07-11 11:53:38 +08002760 * 1:20 SSID direct bit map; if a bit is set, then corresponding
Ben Cahill3058f022008-01-14 17:46:17 -08002761 * SSID IE is transmitted in probe request.
Tomas Winklerd16dc482008-07-11 11:53:38 +08002762 * 21:31 reserved
Zhu Yib481de92007-09-25 17:54:57 -07002763 */
Tomas Winklerd16dc482008-07-11 11:53:38 +08002764 __le32 type;
2765 __le16 channel; /* band is selected by iwl_scan_cmd "flags" field */
Tomas Winklerf53696d2008-06-12 09:47:12 +08002766 u8 tx_gain; /* gain for analog radio */
2767 u8 dsp_atten; /* gain for DSP */
Ben Cahill3058f022008-01-14 17:46:17 -08002768 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2769 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002770} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002771
Winkler, Tomas0d210442009-01-23 13:45:21 -08002772/* set number of direct probes __le32 type */
2773#define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
2774
Ben Cahill3058f022008-01-14 17:46:17 -08002775/**
Tomas Winkler2a421b92008-06-12 09:47:10 +08002776 * struct iwl_ssid_ie - directed scan network information element
Ben Cahill3058f022008-01-14 17:46:17 -08002777 *
Ben Cahill2a3b7932009-11-06 14:52:59 -08002778 * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in
2779 * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel;
2780 * each channel may select different ssids from among the 20 (4) entries.
2781 * SSID IEs get transmitted in reverse order of entry.
Ben Cahill3058f022008-01-14 17:46:17 -08002782 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002783struct iwl_ssid_ie {
Zhu Yib481de92007-09-25 17:54:57 -07002784 u8 id;
2785 u8 len;
2786 u8 ssid[32];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002787} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002788
Johannes Berg9b3bf062009-04-20 14:36:55 -07002789#define PROBE_OPTION_MAX_3945 4
2790#define PROBE_OPTION_MAX 20
Harvey Harrison51e9bf52008-11-26 13:12:52 -08002791#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
Johannes Berg96ff5642010-04-30 14:42:15 -07002792#define IWL_GOOD_CRC_TH_DISABLED 0
2793#define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
2794#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
Zhu Yib481de92007-09-25 17:54:57 -07002795#define IWL_MAX_SCAN_SIZE 1024
Abhijeet Kolekar89612122010-02-19 11:49:49 -08002796#define IWL_MAX_CMD_SIZE 4096
Zhu Yib481de92007-09-25 17:54:57 -07002797
2798/*
2799 * REPLY_SCAN_CMD = 0x80 (command)
Ben Cahill3058f022008-01-14 17:46:17 -08002800 *
2801 * The hardware scan command is very powerful; the driver can set it up to
2802 * maintain (relatively) normal network traffic while doing a scan in the
2803 * background. The max_out_time and suspend_time control the ratio of how
2804 * long the device stays on an associated network channel ("service channel")
2805 * vs. how long it's away from the service channel, i.e. tuned to other channels
2806 * for scanning.
2807 *
2808 * max_out_time is the max time off-channel (in usec), and suspend_time
2809 * is how long (in "extended beacon" format) that the scan is "suspended"
2810 * after returning to the service channel. That is, suspend_time is the
2811 * time that we stay on the service channel, doing normal work, between
2812 * scan segments. The driver may set these parameters differently to support
2813 * scanning when associated vs. not associated, and light vs. heavy traffic
2814 * loads when associated.
2815 *
2816 * After receiving this command, the device's scan engine does the following;
2817 *
2818 * 1) Sends SCAN_START notification to driver
2819 * 2) Checks to see if it has time to do scan for one channel
2820 * 3) Sends NULL packet, with power-save (PS) bit set to 1,
2821 * to tell AP that we're going off-channel
2822 * 4) Tunes to first channel in scan list, does active or passive scan
2823 * 5) Sends SCAN_RESULT notification to driver
2824 * 6) Checks to see if it has time to do scan on *next* channel in list
2825 * 7) Repeats 4-6 until it no longer has time to scan the next channel
2826 * before max_out_time expires
2827 * 8) Returns to service channel
2828 * 9) Sends NULL packet with PS=0 to tell AP that we're back
2829 * 10) Stays on service channel until suspend_time expires
2830 * 11) Repeats entire process 2-10 until list is complete
2831 * 12) Sends SCAN_COMPLETE notification
2832 *
2833 * For fast, efficient scans, the scan command also has support for staying on
2834 * a channel for just a short time, if doing active scanning and getting no
2835 * responses to the transmitted probe request. This time is controlled by
2836 * quiet_time, and the number of received packets below which a channel is
2837 * considered "quiet" is controlled by quiet_plcp_threshold.
2838 *
2839 * For active scanning on channels that have regulatory restrictions against
2840 * blindly transmitting, the scan can listen before transmitting, to make sure
2841 * that there is already legitimate activity on the channel. If enough
2842 * packets are cleanly received on the channel (controlled by good_CRC_th,
2843 * typical value 1), the scan engine starts transmitting probe requests.
2844 *
2845 * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
2846 *
2847 * To avoid uCode errors, see timing restrictions described under
Tomas Winkler2a421b92008-06-12 09:47:10 +08002848 * struct iwl_scan_channel.
Zhu Yib481de92007-09-25 17:54:57 -07002849 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002850
2851struct iwl3945_scan_cmd {
2852 __le16 len;
2853 u8 reserved0;
2854 u8 channel_count; /* # channels in channel list */
2855 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2856 * (only for active scan) */
2857 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2858 __le16 good_CRC_th; /* passive -> active promotion threshold */
2859 __le16 reserved1;
2860 __le32 max_out_time; /* max usec to be away from associated (service)
2861 * channel */
2862 __le32 suspend_time; /* pause scan this long (in "extended beacon
2863 * format") when returning to service channel:
2864 * 3945; 31:24 # beacons, 19:0 additional usec,
2865 * 4965; 31:22 # beacons, 21:0 additional usec.
2866 */
2867 __le32 flags; /* RXON_FLG_* */
2868 __le32 filter_flags; /* RXON_FILTER_* */
2869
2870 /* For active scans (set to all-0s for passive scans).
2871 * Does not include payload. Must specify Tx rate; no rate scaling. */
2872 struct iwl3945_tx_cmd tx_cmd;
2873
2874 /* For directed active scans (set to all-0s otherwise) */
Johannes Berg9b3bf062009-04-20 14:36:55 -07002875 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002876
2877 /*
2878 * Probe request frame, followed by channel list.
2879 *
2880 * Size of probe request frame is specified by byte count in tx_cmd.
2881 * Channel list follows immediately after probe request frame.
2882 * Number of channels in list is specified by channel_count.
2883 * Each channel in list is of type:
2884 *
2885 * struct iwl3945_scan_channel channels[0];
2886 *
2887 * NOTE: Only one band of channels can be scanned per pass. You
2888 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2889 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
2890 * before requesting another scan.
2891 */
2892 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002893} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002894
Tomas Winkler2a421b92008-06-12 09:47:10 +08002895struct iwl_scan_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002896 __le16 len;
2897 u8 reserved0;
Ben Cahill3058f022008-01-14 17:46:17 -08002898 u8 channel_count; /* # channels in channel list */
2899 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2900 * (only for active scan) */
2901 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2902 __le16 good_CRC_th; /* passive -> active promotion threshold */
2903 __le16 rx_chain; /* RXON_RX_CHAIN_* */
2904 __le32 max_out_time; /* max usec to be away from associated (service)
2905 * channel */
2906 __le32 suspend_time; /* pause scan this long (in "extended beacon
2907 * format") when returning to service chnl:
2908 * 3945; 31:24 # beacons, 19:0 additional usec,
2909 * 4965; 31:22 # beacons, 21:0 additional usec.
2910 */
2911 __le32 flags; /* RXON_FLG_* */
2912 __le32 filter_flags; /* RXON_FILTER_* */
Zhu Yib481de92007-09-25 17:54:57 -07002913
Ben Cahill3058f022008-01-14 17:46:17 -08002914 /* For active scans (set to all-0s for passive scans).
2915 * Does not include payload. Must specify Tx rate; no rate scaling. */
Tomas Winkler83d527d2008-05-15 13:54:05 +08002916 struct iwl_tx_cmd tx_cmd;
Ben Cahill3058f022008-01-14 17:46:17 -08002917
2918 /* For directed active scans (set to all-0s otherwise) */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002919 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
Zhu Yib481de92007-09-25 17:54:57 -07002920
Zhu Yib481de92007-09-25 17:54:57 -07002921 /*
Ben Cahill3058f022008-01-14 17:46:17 -08002922 * Probe request frame, followed by channel list.
2923 *
2924 * Size of probe request frame is specified by byte count in tx_cmd.
2925 * Channel list follows immediately after probe request frame.
2926 * Number of channels in list is specified by channel_count.
2927 * Each channel in list is of type:
Zhu Yib481de92007-09-25 17:54:57 -07002928 *
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002929 * struct iwl_scan_channel channels[0];
Zhu Yib481de92007-09-25 17:54:57 -07002930 *
2931 * NOTE: Only one band of channels can be scanned per pass. You
Ben Cahill3058f022008-01-14 17:46:17 -08002932 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2933 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
2934 * before requesting another scan.
Zhu Yib481de92007-09-25 17:54:57 -07002935 */
Ben Cahill3058f022008-01-14 17:46:17 -08002936 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002937} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002938
2939/* Can abort will notify by complete notification with abort status. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08002940#define CAN_ABORT_STATUS cpu_to_le32(0x1)
Zhu Yib481de92007-09-25 17:54:57 -07002941/* complete notification statuses */
2942#define ABORT_STATUS 0x2
2943
2944/*
2945 * REPLY_SCAN_CMD = 0x80 (response)
2946 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002947struct iwl_scanreq_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002948 __le32 status; /* 1: okay, 2: cannot fulfill request */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002949} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002950
2951/*
2952 * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
2953 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002954struct iwl_scanstart_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002955 __le32 tsf_low;
2956 __le32 tsf_high;
2957 __le32 beacon_timer;
2958 u8 channel;
2959 u8 band;
2960 u8 reserved[2];
2961 __le32 status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002962} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002963
2964#define SCAN_OWNER_STATUS 0x1;
2965#define MEASURE_OWNER_STATUS 0x2;
2966
Johannes Berg0288d232010-08-23 07:56:54 -07002967#define IWL_PROBE_STATUS_OK 0
2968#define IWL_PROBE_STATUS_TX_FAILED BIT(0)
2969/* error statuses combined with TX_FAILED */
2970#define IWL_PROBE_STATUS_FAIL_TTL BIT(1)
2971#define IWL_PROBE_STATUS_FAIL_BT BIT(2)
2972
Zhu Yib481de92007-09-25 17:54:57 -07002973#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
2974/*
2975 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
2976 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002977struct iwl_scanresults_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002978 u8 channel;
2979 u8 band;
Johannes Berg0288d232010-08-23 07:56:54 -07002980 u8 probe_status;
2981 u8 num_probe_not_sent; /* not enough time to send */
Zhu Yib481de92007-09-25 17:54:57 -07002982 __le32 tsf_low;
2983 __le32 tsf_high;
2984 __le32 statistics[NUMBER_OF_STATISTICS];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002985} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002986
2987/*
2988 * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
2989 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002990struct iwl_scancomplete_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002991 u8 scanned_channels;
2992 u8 status;
2993 u8 reserved;
2994 u8 last_channel;
2995 __le32 tsf_low;
2996 __le32 tsf_high;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002997} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002998
2999
3000/******************************************************************************
3001 * (9)
3002 * IBSS/AP Commands and Notifications:
3003 *
3004 *****************************************************************************/
3005
Johannes Berga85d7cc2010-07-31 08:34:10 -07003006enum iwl_ibss_manager {
3007 IWL_NOT_IBSS_MANAGER = 0,
3008 IWL_IBSS_MANAGER = 1,
3009};
3010
Zhu Yib481de92007-09-25 17:54:57 -07003011/*
3012 * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
3013 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003014
3015struct iwl3945_beacon_notif {
3016 struct iwl3945_tx_resp beacon_notify_hdr;
3017 __le32 low_tsf;
3018 __le32 high_tsf;
3019 __le32 ibss_mgr_status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003020} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003021
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08003022struct iwl4965_beacon_notif {
3023 struct iwl4965_tx_resp beacon_notify_hdr;
Zhu Yib481de92007-09-25 17:54:57 -07003024 __le32 low_tsf;
3025 __le32 high_tsf;
3026 __le32 ibss_mgr_status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003027} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003028
3029/*
3030 * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
3031 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003032
3033struct iwl3945_tx_beacon_cmd {
3034 struct iwl3945_tx_cmd tx;
3035 __le16 tim_idx;
3036 u8 tim_size;
3037 u8 reserved1;
3038 struct ieee80211_hdr frame[0]; /* beacon frame */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003039} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003040
Tomas Winkler4bf64ef2008-07-18 13:53:03 +08003041struct iwl_tx_beacon_cmd {
Tomas Winkler83d527d2008-05-15 13:54:05 +08003042 struct iwl_tx_cmd tx;
Zhu Yib481de92007-09-25 17:54:57 -07003043 __le16 tim_idx;
3044 u8 tim_size;
3045 u8 reserved1;
3046 struct ieee80211_hdr frame[0]; /* beacon frame */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003047} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003048
3049/******************************************************************************
3050 * (10)
3051 * Statistics Commands and Notifications:
3052 *
3053 *****************************************************************************/
3054
3055#define IWL_TEMP_CONVERT 260
3056
3057#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
3058#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
3059#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
3060
3061/* Used for passing to driver number of successes and failures per rate */
3062struct rate_histogram {
3063 union {
3064 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
3065 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
3066 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
3067 } success;
3068 union {
3069 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
3070 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
3071 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
3072 } failed;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003073} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003074
3075/* statistics command response */
3076
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003077struct iwl39_statistics_rx_phy {
3078 __le32 ina_cnt;
3079 __le32 fina_cnt;
3080 __le32 plcp_err;
3081 __le32 crc32_err;
3082 __le32 overrun_err;
3083 __le32 early_overrun_err;
3084 __le32 crc32_good;
3085 __le32 false_alarm_cnt;
3086 __le32 fina_sync_err_cnt;
3087 __le32 sfd_timeout;
3088 __le32 fina_timeout;
3089 __le32 unresponded_rts;
3090 __le32 rxe_frame_limit_overrun;
3091 __le32 sent_ack_cnt;
3092 __le32 sent_cts_cnt;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003093} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003094
3095struct iwl39_statistics_rx_non_phy {
3096 __le32 bogus_cts; /* CTS received when not expecting CTS */
3097 __le32 bogus_ack; /* ACK received when not expecting ACK */
3098 __le32 non_bssid_frames; /* number of frames with BSSID that
3099 * doesn't belong to the STA BSSID */
3100 __le32 filtered_frames; /* count frames that were dumped in the
3101 * filtering process */
3102 __le32 non_channel_beacons; /* beacons with our bss id but not on
3103 * our serving channel */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003104} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003105
3106struct iwl39_statistics_rx {
3107 struct iwl39_statistics_rx_phy ofdm;
3108 struct iwl39_statistics_rx_phy cck;
3109 struct iwl39_statistics_rx_non_phy general;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003110} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003111
3112struct iwl39_statistics_tx {
3113 __le32 preamble_cnt;
3114 __le32 rx_detected_cnt;
3115 __le32 bt_prio_defer_cnt;
3116 __le32 bt_prio_kill_cnt;
3117 __le32 few_bytes_cnt;
3118 __le32 cts_timeout;
3119 __le32 ack_timeout;
3120 __le32 expected_ack_cnt;
3121 __le32 actual_ack_cnt;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003122} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003123
3124struct statistics_dbg {
3125 __le32 burst_check;
3126 __le32 burst_count;
Wey-Yi Guy7c094c52010-07-06 10:39:32 -07003127 __le32 wait_for_silence_timeout_cnt;
3128 __le32 reserved[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003129} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003130
3131struct iwl39_statistics_div {
3132 __le32 tx_on_a;
3133 __le32 tx_on_b;
3134 __le32 exec_time;
3135 __le32 probe_time;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003136} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003137
3138struct iwl39_statistics_general {
3139 __le32 temperature;
3140 struct statistics_dbg dbg;
3141 __le32 sleep_time;
3142 __le32 slots_out;
3143 __le32 slots_idle;
3144 __le32 ttl_timestamp;
3145 struct iwl39_statistics_div div;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003146} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003147
Zhu Yib481de92007-09-25 17:54:57 -07003148struct statistics_rx_phy {
3149 __le32 ina_cnt;
3150 __le32 fina_cnt;
3151 __le32 plcp_err;
3152 __le32 crc32_err;
3153 __le32 overrun_err;
3154 __le32 early_overrun_err;
3155 __le32 crc32_good;
3156 __le32 false_alarm_cnt;
3157 __le32 fina_sync_err_cnt;
3158 __le32 sfd_timeout;
3159 __le32 fina_timeout;
3160 __le32 unresponded_rts;
3161 __le32 rxe_frame_limit_overrun;
3162 __le32 sent_ack_cnt;
3163 __le32 sent_cts_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07003164 __le32 sent_ba_rsp_cnt;
3165 __le32 dsp_self_kill;
3166 __le32 mh_format_err;
3167 __le32 re_acq_main_rssi_sum;
3168 __le32 reserved3;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003169} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003170
Zhu Yib481de92007-09-25 17:54:57 -07003171struct statistics_rx_ht_phy {
3172 __le32 plcp_err;
3173 __le32 overrun_err;
3174 __le32 early_overrun_err;
3175 __le32 crc32_good;
3176 __le32 crc32_err;
3177 __le32 mh_format_err;
3178 __le32 agg_crc32_good;
3179 __le32 agg_mpdu_cnt;
3180 __le32 agg_cnt;
Wey-Yi Guyf0118a42010-01-08 10:04:42 -08003181 __le32 unsupport_mcs;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003182} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003183
Harvey Harrisonc1b4aa32009-01-29 13:26:44 -08003184#define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1)
Winkler, Tomas34c22cf2008-12-17 16:52:27 +08003185
Zhu Yib481de92007-09-25 17:54:57 -07003186struct statistics_rx_non_phy {
3187 __le32 bogus_cts; /* CTS received when not expecting CTS */
3188 __le32 bogus_ack; /* ACK received when not expecting ACK */
3189 __le32 non_bssid_frames; /* number of frames with BSSID that
3190 * doesn't belong to the STA BSSID */
3191 __le32 filtered_frames; /* count frames that were dumped in the
3192 * filtering process */
3193 __le32 non_channel_beacons; /* beacons with our bss id but not on
3194 * our serving channel */
Zhu Yib481de92007-09-25 17:54:57 -07003195 __le32 channel_beacons; /* beacons with our bss id and in our
3196 * serving channel */
3197 __le32 num_missed_bcon; /* number of missed beacons */
3198 __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
3199 * ADC was in saturation */
3200 __le32 ina_detection_search_time;/* total time (in 0.8us) searched
3201 * for INA */
3202 __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
3203 __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
3204 __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
3205 __le32 interference_data_flag; /* flag for interference data
3206 * availability. 1 when data is
3207 * available. */
Ben Cahill3058f022008-01-14 17:46:17 -08003208 __le32 channel_load; /* counts RX Enable time in uSec */
Zhu Yib481de92007-09-25 17:54:57 -07003209 __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
3210 * and CCK) counter */
3211 __le32 beacon_rssi_a;
3212 __le32 beacon_rssi_b;
3213 __le32 beacon_rssi_c;
3214 __le32 beacon_energy_a;
3215 __le32 beacon_energy_b;
3216 __le32 beacon_energy_c;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003217} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003218
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003219struct statistics_rx_non_phy_bt {
3220 struct statistics_rx_non_phy common;
3221 /* additional stats for bt */
3222 __le32 num_bt_kills;
3223 __le32 reserved[2];
John W. Linvilleda22f792010-07-26 15:04:12 -04003224} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003225
Zhu Yib481de92007-09-25 17:54:57 -07003226struct statistics_rx {
3227 struct statistics_rx_phy ofdm;
3228 struct statistics_rx_phy cck;
3229 struct statistics_rx_non_phy general;
Zhu Yib481de92007-09-25 17:54:57 -07003230 struct statistics_rx_ht_phy ofdm_ht;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003231} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003232
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003233struct statistics_rx_bt {
3234 struct statistics_rx_phy ofdm;
3235 struct statistics_rx_phy cck;
3236 struct statistics_rx_non_phy_bt general;
3237 struct statistics_rx_ht_phy ofdm_ht;
John W. Linvilleda22f792010-07-26 15:04:12 -04003238} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003239
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -07003240/**
3241 * struct statistics_tx_power - current tx power
3242 *
3243 * @ant_a: current tx power on chain a in 1/2 dB step
3244 * @ant_b: current tx power on chain b in 1/2 dB step
3245 * @ant_c: current tx power on chain c in 1/2 dB step
3246 */
3247struct statistics_tx_power {
3248 u8 ant_a;
3249 u8 ant_b;
3250 u8 ant_c;
3251 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003252} __packed;
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -07003253
Zhu Yib481de92007-09-25 17:54:57 -07003254struct statistics_tx_non_phy_agg {
3255 __le32 ba_timeout;
3256 __le32 ba_reschedule_frames;
3257 __le32 scd_query_agg_frame_cnt;
3258 __le32 scd_query_no_agg;
3259 __le32 scd_query_agg;
3260 __le32 scd_query_mismatch;
3261 __le32 frame_not_ready;
3262 __le32 underrun;
3263 __le32 bt_prio_kill;
3264 __le32 rx_ba_rsp_cnt;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003265} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003266
3267struct statistics_tx {
3268 __le32 preamble_cnt;
3269 __le32 rx_detected_cnt;
3270 __le32 bt_prio_defer_cnt;
3271 __le32 bt_prio_kill_cnt;
3272 __le32 few_bytes_cnt;
3273 __le32 cts_timeout;
3274 __le32 ack_timeout;
3275 __le32 expected_ack_cnt;
3276 __le32 actual_ack_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07003277 __le32 dump_msdu_cnt;
3278 __le32 burst_abort_next_frame_mismatch_cnt;
3279 __le32 burst_abort_missing_next_frame_cnt;
3280 __le32 cts_timeout_collision;
3281 __le32 ack_or_ba_timeout_collision;
3282 struct statistics_tx_non_phy_agg agg;
Wey-Yi Guy470356b2010-04-30 11:35:15 -07003283 /*
3284 * "tx_power" are optional parameters provided by uCode,
3285 * 6000 series is the only device provide the information,
3286 * Those are reserved fields for all the other devices
3287 */
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -07003288 struct statistics_tx_power tx_power;
3289 __le32 reserved1;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003290} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003291
Zhu Yib481de92007-09-25 17:54:57 -07003292
3293struct statistics_div {
3294 __le32 tx_on_a;
3295 __le32 tx_on_b;
3296 __le32 exec_time;
3297 __le32 probe_time;
Zhu Yib481de92007-09-25 17:54:57 -07003298 __le32 reserved1;
3299 __le32 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003300} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003301
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003302struct statistics_general_common {
Wey-Yi Guyf0118a42010-01-08 10:04:42 -08003303 __le32 temperature; /* radio temperature */
3304 __le32 temperature_m; /* for 5000 and up, this is radio voltage */
Zhu Yib481de92007-09-25 17:54:57 -07003305 struct statistics_dbg dbg;
3306 __le32 sleep_time;
3307 __le32 slots_out;
3308 __le32 slots_idle;
3309 __le32 ttl_timestamp;
3310 struct statistics_div div;
Zhu Yib481de92007-09-25 17:54:57 -07003311 __le32 rx_enable_counter;
Wey-Yi Guy11fc5242010-01-15 13:43:35 -08003312 /*
3313 * num_of_sos_states:
3314 * count the number of times we have to re-tune
3315 * in order to get out of bad PHY status
3316 */
3317 __le32 num_of_sos_states;
John W. Linvilleda22f792010-07-26 15:04:12 -04003318} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003319
3320struct statistics_bt_activity {
3321 /* Tx statistics */
3322 __le32 hi_priority_tx_req_cnt;
3323 __le32 hi_priority_tx_denied_cnt;
3324 __le32 lo_priority_tx_req_cnt;
3325 __le32 lo_priority_tx_denied_cnt;
3326 /* Rx statistics */
3327 __le32 hi_priority_rx_req_cnt;
3328 __le32 hi_priority_rx_denied_cnt;
3329 __le32 lo_priority_rx_req_cnt;
3330 __le32 lo_priority_rx_denied_cnt;
John W. Linvilleda22f792010-07-26 15:04:12 -04003331} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003332
3333struct statistics_general {
3334 struct statistics_general_common common;
3335 __le32 reserved2;
3336 __le32 reserved3;
John W. Linvilleda22f792010-07-26 15:04:12 -04003337} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003338
3339struct statistics_general_bt {
3340 struct statistics_general_common common;
3341 struct statistics_bt_activity activity;
Zhu Yib481de92007-09-25 17:54:57 -07003342 __le32 reserved2;
3343 __le32 reserved3;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003344} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003345
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08003346#define UCODE_STATISTICS_CLEAR_MSK (0x1 << 0)
3347#define UCODE_STATISTICS_FREQUENCY_MSK (0x1 << 1)
3348#define UCODE_STATISTICS_NARROW_BAND_MSK (0x1 << 2)
3349
Zhu Yib481de92007-09-25 17:54:57 -07003350/*
3351 * REPLY_STATISTICS_CMD = 0x9c,
Wey-Yi Guy767d0552010-08-23 07:56:53 -07003352 * all devices identical.
Zhu Yib481de92007-09-25 17:54:57 -07003353 *
3354 * This command triggers an immediate response containing uCode statistics.
3355 * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
3356 *
3357 * If the CLEAR_STATS configuration flag is set, uCode will clear its
3358 * internal copy of the statistics (counters) after issuing the response.
3359 * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
3360 *
3361 * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
3362 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
3363 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
3364 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003365#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */
3366#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +08003367struct iwl_statistics_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07003368 __le32 configuration_flags; /* IWL_STATS_CONF_* */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003369} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003370
3371/*
3372 * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
3373 *
3374 * By default, uCode issues this notification after receiving a beacon
3375 * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
3376 * REPLY_STATISTICS_CMD 0x9c, above.
3377 *
3378 * Statistics counters continue to increment beacon after beacon, but are
3379 * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
3380 * 0x9c with CLEAR_STATS bit set (see above).
3381 *
3382 * uCode also issues this notification during scans. uCode clears statistics
3383 * appropriately so that each notification contains statistics for only the
3384 * one channel that has just been scanned.
3385 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003386#define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2)
Wey-Yi Guy7aafef12009-08-07 15:41:38 -07003387#define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8)
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003388
3389struct iwl3945_notif_statistics {
3390 __le32 flag;
3391 struct iwl39_statistics_rx rx;
3392 struct iwl39_statistics_tx tx;
3393 struct iwl39_statistics_general general;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003394} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003395
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +08003396struct iwl_notif_statistics {
Zhu Yib481de92007-09-25 17:54:57 -07003397 __le32 flag;
3398 struct statistics_rx rx;
3399 struct statistics_tx tx;
3400 struct statistics_general general;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003401} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003402
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003403struct iwl_bt_notif_statistics {
3404 __le32 flag;
3405 struct statistics_rx_bt rx;
3406 struct statistics_tx tx;
3407 struct statistics_general_bt general;
John W. Linvilleda22f792010-07-26 15:04:12 -04003408} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003409
3410/*
3411 * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
Wey-Yi Guya13d2762010-01-22 14:22:42 -08003412 *
3413 * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed
3414 * in regardless of how many missed beacons, which mean when driver receive the
3415 * notification, inside the command, it can find all the beacons information
3416 * which include number of total missed beacons, number of consecutive missed
3417 * beacons, number of beacons received and number of beacons expected to
3418 * receive.
3419 *
3420 * If uCode detected consecutive_missed_beacons > 5, it will reset the radio
3421 * in order to bring the radio/PHY back to working state; which has no relation
3422 * to when driver will perform sensitivity calibration.
3423 *
3424 * Driver should set it own missed_beacon_threshold to decide when to perform
3425 * sensitivity calibration based on number of consecutive missed beacons in
3426 * order to improve overall performance, especially in noisy environment.
3427 *
Zhu Yib481de92007-09-25 17:54:57 -07003428 */
Wey-Yi Guya13d2762010-01-22 14:22:42 -08003429
3430#define IWL_MISSED_BEACON_THRESHOLD_MIN (1)
3431#define IWL_MISSED_BEACON_THRESHOLD_DEF (5)
3432#define IWL_MISSED_BEACON_THRESHOLD_MAX IWL_MISSED_BEACON_THRESHOLD_DEF
Zhu Yib481de92007-09-25 17:54:57 -07003433
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08003434struct iwl_missed_beacon_notif {
Wey-Yi Guya13d2762010-01-22 14:22:42 -08003435 __le32 consecutive_missed_beacons;
Zhu Yib481de92007-09-25 17:54:57 -07003436 __le32 total_missed_becons;
3437 __le32 num_expected_beacons;
3438 __le32 num_recvd_beacons;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003439} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003440
Ben Cahillf7d09d72007-11-29 11:09:51 +08003441
Zhu Yib481de92007-09-25 17:54:57 -07003442/******************************************************************************
3443 * (11)
3444 * Rx Calibration Commands:
3445 *
Ben Cahillf7d09d72007-11-29 11:09:51 +08003446 * With the uCode used for open source drivers, most Tx calibration (except
3447 * for Tx Power) and most Rx calibration is done by uCode during the
3448 * "initialize" phase of uCode boot. Driver must calibrate only:
3449 *
3450 * 1) Tx power (depends on temperature), described elsewhere
3451 * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
3452 * 3) Receiver sensitivity (to optimize signal detection)
3453 *
Zhu Yib481de92007-09-25 17:54:57 -07003454 *****************************************************************************/
3455
Ben Cahillf7d09d72007-11-29 11:09:51 +08003456/**
3457 * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
3458 *
3459 * This command sets up the Rx signal detector for a sensitivity level that
3460 * is high enough to lock onto all signals within the associated network,
3461 * but low enough to ignore signals that are below a certain threshold, so as
3462 * not to have too many "false alarms". False alarms are signals that the
3463 * Rx DSP tries to lock onto, but then discards after determining that they
3464 * are noise.
3465 *
3466 * The optimum number of false alarms is between 5 and 50 per 200 TUs
3467 * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
3468 * time listening, not transmitting). Driver must adjust sensitivity so that
3469 * the ratio of actual false alarms to actual Rx time falls within this range.
3470 *
3471 * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
3472 * received beacon. These provide information to the driver to analyze the
3473 * sensitivity. Don't analyze statistics that come in from scanning, or any
3474 * other non-associated-network source. Pertinent statistics include:
3475 *
3476 * From "general" statistics (struct statistics_rx_non_phy):
3477 *
3478 * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
3479 * Measure of energy of desired signal. Used for establishing a level
3480 * below which the device does not detect signals.
3481 *
3482 * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
3483 * Measure of background noise in silent period after beacon.
3484 *
3485 * channel_load
3486 * uSecs of actual Rx time during beacon period (varies according to
3487 * how much time was spent transmitting).
3488 *
3489 * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
3490 *
3491 * false_alarm_cnt
3492 * Signal locks abandoned early (before phy-level header).
3493 *
3494 * plcp_err
3495 * Signal locks abandoned late (during phy-level header).
3496 *
3497 * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
3498 * beacon to beacon, i.e. each value is an accumulation of all errors
3499 * before and including the latest beacon. Values will wrap around to 0
3500 * after counting up to 2^32 - 1. Driver must differentiate vs.
3501 * previous beacon's values to determine # false alarms in the current
3502 * beacon period.
3503 *
3504 * Total number of false alarms = false_alarms + plcp_errs
3505 *
3506 * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
3507 * (notice that the start points for OFDM are at or close to settings for
3508 * maximum sensitivity):
3509 *
3510 * START / MIN / MAX
3511 * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120
3512 * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210
3513 * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140
3514 * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270
3515 *
3516 * If actual rate of OFDM false alarms (+ plcp_errors) is too high
3517 * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
3518 * by *adding* 1 to all 4 of the table entries above, up to the max for
3519 * each entry. Conversely, if false alarm rate is too low (less than 5
3520 * for each 204.8 msecs listening), *subtract* 1 from each entry to
3521 * increase sensitivity.
3522 *
3523 * For CCK sensitivity, keep track of the following:
3524 *
3525 * 1). 20-beacon history of maximum background noise, indicated by
3526 * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
3527 * 3 receivers. For any given beacon, the "silence reference" is
3528 * the maximum of last 60 samples (20 beacons * 3 receivers).
3529 *
3530 * 2). 10-beacon history of strongest signal level, as indicated
3531 * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
3532 * i.e. the strength of the signal through the best receiver at the
3533 * moment. These measurements are "upside down", with lower values
3534 * for stronger signals, so max energy will be *minimum* value.
3535 *
3536 * Then for any given beacon, the driver must determine the *weakest*
3537 * of the strongest signals; this is the minimum level that needs to be
3538 * successfully detected, when using the best receiver at the moment.
3539 * "Max cck energy" is the maximum (higher value means lower energy!)
3540 * of the last 10 minima. Once this is determined, driver must add
3541 * a little margin by adding "6" to it.
3542 *
3543 * 3). Number of consecutive beacon periods with too few false alarms.
3544 * Reset this to 0 at the first beacon period that falls within the
3545 * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
3546 *
3547 * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
3548 * (notice that the start points for CCK are at maximum sensitivity):
3549 *
3550 * START / MIN / MAX
3551 * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200
3552 * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400
3553 * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100
3554 *
3555 * If actual rate of CCK false alarms (+ plcp_errors) is too high
3556 * (greater than 50 for each 204.8 msecs listening), method for reducing
3557 * sensitivity is:
3558 *
3559 * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3560 * up to max 400.
3561 *
3562 * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
3563 * sensitivity has been reduced a significant amount; bring it up to
3564 * a moderate 161. Otherwise, *add* 3, up to max 200.
3565 *
3566 * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
3567 * sensitivity has been reduced only a moderate or small amount;
3568 * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
3569 * down to min 0. Otherwise (if gain has been significantly reduced),
3570 * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
3571 *
3572 * b) Save a snapshot of the "silence reference".
3573 *
3574 * If actual rate of CCK false alarms (+ plcp_errors) is too low
3575 * (less than 5 for each 204.8 msecs listening), method for increasing
3576 * sensitivity is used only if:
3577 *
3578 * 1a) Previous beacon did not have too many false alarms
3579 * 1b) AND difference between previous "silence reference" and current
3580 * "silence reference" (prev - current) is 2 or more,
3581 * OR 2) 100 or more consecutive beacon periods have had rate of
3582 * less than 5 false alarms per 204.8 milliseconds rx time.
3583 *
3584 * Method for increasing sensitivity:
3585 *
3586 * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
3587 * down to min 125.
3588 *
3589 * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3590 * down to min 200.
3591 *
3592 * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
3593 *
3594 * If actual rate of CCK false alarms (+ plcp_errors) is within good range
3595 * (between 5 and 50 for each 204.8 msecs listening):
3596 *
3597 * 1) Save a snapshot of the silence reference.
3598 *
3599 * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
3600 * give some extra margin to energy threshold by *subtracting* 8
3601 * from value in HD_MIN_ENERGY_CCK_DET_INDEX.
3602 *
3603 * For all cases (too few, too many, good range), make sure that the CCK
3604 * detection threshold (energy) is below the energy level for robust
3605 * detection over the past 10 beacon periods, the "Max cck energy".
3606 * Lower values mean higher energy; this means making sure that the value
3607 * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
3608 *
Ben Cahillf7d09d72007-11-29 11:09:51 +08003609 */
Zhu Yib481de92007-09-25 17:54:57 -07003610
Ben Cahillf7d09d72007-11-29 11:09:51 +08003611/*
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003612 * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
Ben Cahillf7d09d72007-11-29 11:09:51 +08003613 */
3614#define HD_TABLE_SIZE (11) /* number of entries */
3615#define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */
3616#define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
3617#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
3618#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
3619#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
3620#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
3621#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
3622#define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
3623#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
3624#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
3625#define HD_OFDM_ENERGY_TH_IN_INDEX (10)
3626
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07003627/*
3628 * Additional table entries in enhance SENSITIVITY_CMD
3629 */
3630#define HD_INA_NON_SQUARE_DET_OFDM_INDEX (11)
3631#define HD_INA_NON_SQUARE_DET_CCK_INDEX (12)
3632#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_INDEX (13)
3633#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_INDEX (14)
3634#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (15)
3635#define HD_OFDM_NON_SQUARE_DET_SLOPE_INDEX (16)
3636#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_INDEX (17)
3637#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_INDEX (18)
3638#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (19)
3639#define HD_CCK_NON_SQUARE_DET_SLOPE_INDEX (20)
3640#define HD_CCK_NON_SQUARE_DET_INTERCEPT_INDEX (21)
3641#define HD_RESERVED (22)
3642
3643/* number of entries for enhanced tbl */
3644#define ENHANCE_HD_TABLE_SIZE (23)
3645
3646/* number of additional entries for enhanced tbl */
3647#define ENHANCE_HD_TABLE_ENTRIES (ENHANCE_HD_TABLE_SIZE - HD_TABLE_SIZE)
3648
3649#define HD_INA_NON_SQUARE_DET_OFDM_DATA cpu_to_le16(0)
3650#define HD_INA_NON_SQUARE_DET_CCK_DATA cpu_to_le16(0)
3651#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA cpu_to_le16(0)
3652#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(668)
3653#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3654#define HD_OFDM_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(486)
3655#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(37)
3656#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(853)
3657#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3658#define HD_CCK_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(476)
3659#define HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(99)
3660
3661
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003662/* Control field in struct iwl_sensitivity_cmd */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003663#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0)
3664#define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1)
Ben Cahillf7d09d72007-11-29 11:09:51 +08003665
3666/**
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003667 * struct iwl_sensitivity_cmd
Ben Cahillf7d09d72007-11-29 11:09:51 +08003668 * @control: (1) updates working table, (0) updates default table
3669 * @table: energy threshold values, use HD_* as index into table
3670 *
3671 * Always use "1" in "control" to update uCode's working table and DSP.
3672 */
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003673struct iwl_sensitivity_cmd {
Ben Cahillf7d09d72007-11-29 11:09:51 +08003674 __le16 control; /* always use "1" */
3675 __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003676} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003677
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07003678/*
3679 *
3680 */
3681struct iwl_enhance_sensitivity_cmd {
3682 __le16 control; /* always use "1" */
3683 __le16 enhance_table[ENHANCE_HD_TABLE_SIZE]; /* use HD_* as index */
John W. Linville0e954092010-07-14 10:37:32 -04003684} __packed;
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07003685
Ben Cahillf7d09d72007-11-29 11:09:51 +08003686
3687/**
3688 * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
3689 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07003690 * This command sets the relative gains of agn device's 3 radio receiver chains.
Ben Cahillf7d09d72007-11-29 11:09:51 +08003691 *
3692 * After the first association, driver should accumulate signal and noise
3693 * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
3694 * beacons from the associated network (don't collect statistics that come
3695 * in from scanning, or any other non-network source).
3696 *
3697 * DISCONNECTED ANTENNA:
3698 *
3699 * Driver should determine which antennas are actually connected, by comparing
3700 * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
3701 * following values over 20 beacons, one accumulator for each of the chains
3702 * a/b/c, from struct statistics_rx_non_phy:
3703 *
3704 * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
3705 *
3706 * Find the strongest signal from among a/b/c. Compare the other two to the
3707 * strongest. If any signal is more than 15 dB (times 20, unless you
3708 * divide the accumulated values by 20) below the strongest, the driver
3709 * considers that antenna to be disconnected, and should not try to use that
3710 * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
3711 * driver should declare the stronger one as connected, and attempt to use it
3712 * (A and B are the only 2 Tx chains!).
3713 *
3714 *
3715 * RX BALANCE:
3716 *
3717 * Driver should balance the 3 receivers (but just the ones that are connected
3718 * to antennas, see above) for gain, by comparing the average signal levels
3719 * detected during the silence after each beacon (background noise).
3720 * Accumulate (add) the following values over 20 beacons, one accumulator for
3721 * each of the chains a/b/c, from struct statistics_rx_non_phy:
3722 *
3723 * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
3724 *
3725 * Find the weakest background noise level from among a/b/c. This Rx chain
3726 * will be the reference, with 0 gain adjustment. Attenuate other channels by
3727 * finding noise difference:
3728 *
3729 * (accum_noise[i] - accum_noise[reference]) / 30
3730 *
3731 * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
3732 * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
3733 * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
3734 * and set bit 2 to indicate "reduce gain". The value for the reference
3735 * (weakest) chain should be "0".
3736 *
3737 * diff_gain_[abc] bit fields:
3738 * 2: (1) reduce gain, (0) increase gain
3739 * 1-0: amount of gain, units of 1.5 dB
3740 */
3741
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003742/* Phy calibration command for series */
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003743
3744enum {
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003745 IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7,
3746 IWL_PHY_CALIBRATE_DC_CMD = 8,
3747 IWL_PHY_CALIBRATE_LO_CMD = 9,
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003748 IWL_PHY_CALIBRATE_TX_IQ_CMD = 11,
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003749 IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15,
3750 IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16,
3751 IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17,
Wey-Yi Guy6a822d02010-07-13 17:13:15 -07003752 IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 18,
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003753};
3754
Wey-Yi Guy6a822d02010-07-13 17:13:15 -07003755#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253)
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003756
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003757#define IWL_CALIB_INIT_CFG_ALL cpu_to_le32(0xffffffff)
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003758
3759struct iwl_calib_cfg_elmnt_s {
3760 __le32 is_enable;
3761 __le32 start;
3762 __le32 send_res;
3763 __le32 apply_res;
3764 __le32 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003765} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003766
3767struct iwl_calib_cfg_status_s {
3768 struct iwl_calib_cfg_elmnt_s once;
3769 struct iwl_calib_cfg_elmnt_s perd;
3770 __le32 flags;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003771} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003772
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003773struct iwl_calib_cfg_cmd {
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003774 struct iwl_calib_cfg_status_s ucd_calib_cfg;
3775 struct iwl_calib_cfg_status_s drv_calib_cfg;
3776 __le32 reserved1;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003777} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003778
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003779struct iwl_calib_hdr {
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003780 u8 op_code;
3781 u8 first_group;
3782 u8 groups_num;
3783 u8 data_valid;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003784} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003785
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003786struct iwl_calib_cmd {
3787 struct iwl_calib_hdr hdr;
Tomas Winklerbe5d56e2008-10-08 09:37:27 +08003788 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003789} __packed;
Tomas Winklerbe5d56e2008-10-08 09:37:27 +08003790
Tomas Winkler0d950d82008-11-25 13:36:01 -08003791/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003792struct iwl_calib_diff_gain_cmd {
Tomas Winkler0d950d82008-11-25 13:36:01 -08003793 struct iwl_calib_hdr hdr;
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003794 s8 diff_gain_a; /* see above */
3795 s8 diff_gain_b;
3796 s8 diff_gain_c;
3797 u8 reserved1;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003798} __packed;
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003799
Tomas Winkler0d950d82008-11-25 13:36:01 -08003800struct iwl_calib_xtal_freq_cmd {
3801 struct iwl_calib_hdr hdr;
3802 u8 cap_pin1;
3803 u8 cap_pin2;
3804 u8 pad[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003805} __packed;
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003806
Tomas Winkler0d950d82008-11-25 13:36:01 -08003807/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
3808struct iwl_calib_chain_noise_reset_cmd {
3809 struct iwl_calib_hdr hdr;
3810 u8 data[0];
3811};
3812
3813/* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003814struct iwl_calib_chain_noise_gain_cmd {
Tomas Winkler0d950d82008-11-25 13:36:01 -08003815 struct iwl_calib_hdr hdr;
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003816 u8 delta_gain_1;
3817 u8 delta_gain_2;
Tomas Winkler0d950d82008-11-25 13:36:01 -08003818 u8 pad[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003819} __packed;
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003820
Zhu Yib481de92007-09-25 17:54:57 -07003821/******************************************************************************
3822 * (12)
3823 * Miscellaneous Commands:
3824 *
3825 *****************************************************************************/
3826
3827/*
3828 * LEDs Command & Response
3829 * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
3830 *
3831 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
3832 * this command turns it on or off, or sets up a periodic blinking cycle.
3833 */
Tomas Winklerec1a7462008-07-11 11:53:37 +08003834struct iwl_led_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07003835 __le32 interval; /* "interval" in uSec */
3836 u8 id; /* 1: Activity, 2: Link, 3: Tech */
3837 u8 off; /* # intervals off while blinking;
3838 * "0", with >0 "on" value, turns LED on */
3839 u8 on; /* # intervals on while blinking;
3840 * "0", regardless of "off", turns LED off */
3841 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003842} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003843
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003844/*
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003845 * station priority table entries
3846 * also used as potential "events" value for both
3847 * COEX_MEDIUM_NOTIFICATION and COEX_EVENT_CMD
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003848 */
Wey-Yi Guy1933ac42009-10-30 14:36:18 -07003849
3850/*
3851 * COEX events entry flag masks
3852 * RP - Requested Priority
3853 * WP - Win Medium Priority: priority assigned when the contention has been won
3854 */
3855#define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG (0x1)
3856#define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG (0x2)
3857#define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG (0x4)
3858
3859#define COEX_CU_UNASSOC_IDLE_RP 4
3860#define COEX_CU_UNASSOC_MANUAL_SCAN_RP 4
3861#define COEX_CU_UNASSOC_AUTO_SCAN_RP 4
3862#define COEX_CU_CALIBRATION_RP 4
3863#define COEX_CU_PERIODIC_CALIBRATION_RP 4
3864#define COEX_CU_CONNECTION_ESTAB_RP 4
3865#define COEX_CU_ASSOCIATED_IDLE_RP 4
3866#define COEX_CU_ASSOC_MANUAL_SCAN_RP 4
3867#define COEX_CU_ASSOC_AUTO_SCAN_RP 4
3868#define COEX_CU_ASSOC_ACTIVE_LEVEL_RP 4
3869#define COEX_CU_RF_ON_RP 6
3870#define COEX_CU_RF_OFF_RP 4
3871#define COEX_CU_STAND_ALONE_DEBUG_RP 6
3872#define COEX_CU_IPAN_ASSOC_LEVEL_RP 4
3873#define COEX_CU_RSRVD1_RP 4
3874#define COEX_CU_RSRVD2_RP 4
3875
3876#define COEX_CU_UNASSOC_IDLE_WP 3
3877#define COEX_CU_UNASSOC_MANUAL_SCAN_WP 3
3878#define COEX_CU_UNASSOC_AUTO_SCAN_WP 3
3879#define COEX_CU_CALIBRATION_WP 3
3880#define COEX_CU_PERIODIC_CALIBRATION_WP 3
3881#define COEX_CU_CONNECTION_ESTAB_WP 3
3882#define COEX_CU_ASSOCIATED_IDLE_WP 3
3883#define COEX_CU_ASSOC_MANUAL_SCAN_WP 3
3884#define COEX_CU_ASSOC_AUTO_SCAN_WP 3
3885#define COEX_CU_ASSOC_ACTIVE_LEVEL_WP 3
3886#define COEX_CU_RF_ON_WP 3
3887#define COEX_CU_RF_OFF_WP 3
3888#define COEX_CU_STAND_ALONE_DEBUG_WP 6
3889#define COEX_CU_IPAN_ASSOC_LEVEL_WP 3
3890#define COEX_CU_RSRVD1_WP 3
3891#define COEX_CU_RSRVD2_WP 3
3892
3893#define COEX_UNASSOC_IDLE_FLAGS 0
3894#define COEX_UNASSOC_MANUAL_SCAN_FLAGS \
3895 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3896 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3897#define COEX_UNASSOC_AUTO_SCAN_FLAGS \
3898 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3899 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3900#define COEX_CALIBRATION_FLAGS \
3901 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3902 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3903#define COEX_PERIODIC_CALIBRATION_FLAGS 0
3904/*
3905 * COEX_CONNECTION_ESTAB:
3906 * we need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
3907 */
3908#define COEX_CONNECTION_ESTAB_FLAGS \
3909 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3910 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3911 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
3912#define COEX_ASSOCIATED_IDLE_FLAGS 0
3913#define COEX_ASSOC_MANUAL_SCAN_FLAGS \
3914 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3915 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3916#define COEX_ASSOC_AUTO_SCAN_FLAGS \
3917 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3918 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3919#define COEX_ASSOC_ACTIVE_LEVEL_FLAGS 0
3920#define COEX_RF_ON_FLAGS 0
3921#define COEX_RF_OFF_FLAGS 0
3922#define COEX_STAND_ALONE_DEBUG_FLAGS \
3923 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3924 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3925#define COEX_IPAN_ASSOC_LEVEL_FLAGS \
3926 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3927 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3928 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
3929#define COEX_RSRVD1_FLAGS 0
3930#define COEX_RSRVD2_FLAGS 0
3931/*
3932 * COEX_CU_RF_ON is the event wrapping all radio ownership.
3933 * We need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
3934 */
3935#define COEX_CU_RF_ON_FLAGS \
3936 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3937 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3938 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
3939
3940
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003941enum {
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003942 /* un-association part */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003943 COEX_UNASSOC_IDLE = 0,
3944 COEX_UNASSOC_MANUAL_SCAN = 1,
3945 COEX_UNASSOC_AUTO_SCAN = 2,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003946 /* calibration */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003947 COEX_CALIBRATION = 3,
3948 COEX_PERIODIC_CALIBRATION = 4,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003949 /* connection */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003950 COEX_CONNECTION_ESTAB = 5,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003951 /* association part */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003952 COEX_ASSOCIATED_IDLE = 6,
3953 COEX_ASSOC_MANUAL_SCAN = 7,
3954 COEX_ASSOC_AUTO_SCAN = 8,
3955 COEX_ASSOC_ACTIVE_LEVEL = 9,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003956 /* RF ON/OFF */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003957 COEX_RF_ON = 10,
3958 COEX_RF_OFF = 11,
3959 COEX_STAND_ALONE_DEBUG = 12,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003960 /* IPAN */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003961 COEX_IPAN_ASSOC_LEVEL = 13,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003962 /* reserved */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003963 COEX_RSRVD1 = 14,
3964 COEX_RSRVD2 = 15,
3965 COEX_NUM_OF_EVENTS = 16
3966};
3967
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003968/*
3969 * Coexistence WIFI/WIMAX Command
3970 * COEX_PRIORITY_TABLE_CMD = 0x5a
3971 *
3972 */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003973struct iwl_wimax_coex_event_entry {
3974 u8 request_prio;
3975 u8 win_medium_prio;
3976 u8 reserved;
3977 u8 flags;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003978} __packed;
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003979
3980/* COEX flag masks */
3981
Tomas Winklera96a27f2008-10-23 23:48:56 -07003982/* Station table is valid */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003983#define COEX_FLAGS_STA_TABLE_VALID_MSK (0x1)
Tomas Winklera96a27f2008-10-23 23:48:56 -07003984/* UnMask wake up src at unassociated sleep */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003985#define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK (0x4)
Tomas Winklera96a27f2008-10-23 23:48:56 -07003986/* UnMask wake up src at associated sleep */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003987#define COEX_FLAGS_ASSOC_WA_UNMASK_MSK (0x8)
3988/* Enable CoEx feature. */
3989#define COEX_FLAGS_COEX_ENABLE_MSK (0x80)
3990
3991struct iwl_wimax_coex_cmd {
3992 u8 flags;
3993 u8 reserved[3];
3994 struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003995} __packed;
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003996
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003997/*
3998 * Coexistence MEDIUM NOTIFICATION
3999 * COEX_MEDIUM_NOTIFICATION = 0x5b
4000 *
4001 * notification from uCode to host to indicate medium changes
4002 *
4003 */
4004/*
4005 * status field
4006 * bit 0 - 2: medium status
4007 * bit 3: medium change indication
4008 * bit 4 - 31: reserved
4009 */
4010/* status option values, (0 - 2 bits) */
4011#define COEX_MEDIUM_BUSY (0x0) /* radio belongs to WiMAX */
4012#define COEX_MEDIUM_ACTIVE (0x1) /* radio belongs to WiFi */
4013#define COEX_MEDIUM_PRE_RELEASE (0x2) /* received radio release */
4014#define COEX_MEDIUM_MSK (0x7)
4015
4016/* send notification status (1 bit) */
4017#define COEX_MEDIUM_CHANGED (0x8)
4018#define COEX_MEDIUM_CHANGED_MSK (0x8)
4019#define COEX_MEDIUM_SHIFT (3)
4020
4021struct iwl_coex_medium_notification {
4022 __le32 status;
4023 __le32 events;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004024} __packed;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004025
4026/*
4027 * Coexistence EVENT Command
4028 * COEX_EVENT_CMD = 0x5c
4029 *
4030 * send from host to uCode for coex event request.
4031 */
4032/* flags options */
4033#define COEX_EVENT_REQUEST_MSK (0x1)
4034
4035struct iwl_coex_event_cmd {
4036 u8 flags;
4037 u8 event;
4038 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004039} __packed;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004040
4041struct iwl_coex_event_resp {
4042 __le32 status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004043} __packed;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004044
4045
Zhu Yib481de92007-09-25 17:54:57 -07004046/******************************************************************************
Johannes Berg0288d232010-08-23 07:56:54 -07004047 * Bluetooth Coexistence commands
4048 *
4049 *****************************************************************************/
4050
4051/*
4052 * BT Status notification
4053 * REPLY_BT_COEX_PROFILE_NOTIF = 0xcb
4054 */
4055enum iwl_bt_coex_profile_traffic_load {
4056 IWL_BT_COEX_TRAFFIC_LOAD_NONE = 0,
4057 IWL_BT_COEX_TRAFFIC_LOAD_LOW = 1,
4058 IWL_BT_COEX_TRAFFIC_LOAD_HIGH = 2,
4059 IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS = 3,
4060/*
4061 * There are no more even though below is a u8, the
4062 * indication from the BT device only has two bits.
4063 */
4064};
4065
4066struct iwl_bt_coex_profile_notif {
4067 u8 uart_msg[8];
4068 u8 bt_status; /* 0 - off, 1 - on */
4069 u8 bt_traffic_load; /* 0 .. 3? */
4070 u8 bt_ci_compliance; /* 0 - not complied, 1 - complied */
4071 u8 reserved;
4072} __attribute__((packed));
4073
4074#define IWL_BT_COEX_PRIO_SHARED_ANTENNA 0x1
4075#define IWL_BT_COEX_PRIO_PRIO_MASK 0xe
4076#define IWL_BT_COEX_PRIO_PRIO_SHIFT 1
4077
4078/*
4079 * BT Coexistence Priority table
4080 * REPLY_BT_COEX_PRIO_TABLE = 0xcc
4081 */
4082struct iwl_bt_coex_prio_table_cmd {
4083 u8 init_calib_protection_cfg1,
4084 init_calib_protection_cfg2,
4085 init_calib_protection_lowprio_cfg1,
4086 init_calib_protection_lowprio_cfg2,
4087 init_calib_protection_highprio_cfg1,
4088 init_calib_protection_highprio_cfg2,
4089 dtim_protection_prio_cfg,
4090 scan_52_protection_cfg,
4091 scan_24_protection_cfg,
4092 bc_mc_protection_cfg;
4093 u8 reserved[6];
4094} __attribute__((packed));
4095
4096/*
4097 * BT Protection Envelope
4098 * REPLY_BT_COEX_PROT_ENV = 0xcd
4099 */
4100struct iwl_bt_coex_prot_env_cmd {
4101 u8 open; /* 0 = closed, 1 = open */
4102 u8 type; /* 0 .. 15 */
4103 u8 reserved[2];
4104} __attribute__((packed));
4105
4106/******************************************************************************
Zhu Yib481de92007-09-25 17:54:57 -07004107 * (13)
4108 * Union of all expected notifications/responses:
4109 *
4110 *****************************************************************************/
4111
Tomas Winklerdb11d632008-05-05 10:22:33 +08004112struct iwl_rx_packet {
Zhu Yi2f301222009-10-09 17:19:45 +08004113 /*
4114 * The first 4 bytes of the RX frame header contain both the RX frame
4115 * size and some flags.
4116 * Bit fields:
4117 * 31: flag flush RB request
4118 * 30: flag ignore TC (terminal counter) request
4119 * 29: flag fast IRQ request
4120 * 28-14: Reserved
4121 * 13-00: RX frame size
4122 */
Daniel C Halperin396887a2009-08-13 13:31:01 -07004123 __le32 len_n_flags;
Tomas Winkler857485c2008-03-21 13:53:44 -07004124 struct iwl_cmd_header hdr;
Zhu Yib481de92007-09-25 17:54:57 -07004125 union {
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08004126 struct iwl3945_rx_frame rx_frame;
4127 struct iwl3945_tx_resp tx_resp;
4128 struct iwl3945_beacon_notif beacon_status;
4129
Tomas Winkler885ba202008-05-29 16:34:55 +08004130 struct iwl_alive_resp alive_frame;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004131 struct iwl_spectrum_notification spectrum_notif;
4132 struct iwl_csa_notification csa_notif;
Tomas Winkler885ba202008-05-29 16:34:55 +08004133 struct iwl_error_resp err_resp;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004134 struct iwl_card_state_notif card_state_notif;
Tomas Winkler7a999bf2008-05-29 16:35:02 +08004135 struct iwl_add_sta_resp add_sta;
4136 struct iwl_rem_sta_resp rem_sta;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004137 struct iwl_sleep_notification sleep_notif;
4138 struct iwl_spectrum_resp spectrum;
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +08004139 struct iwl_notif_statistics stats;
Wey-Yi Guy7980fba2010-07-14 08:08:57 -07004140 struct iwl_bt_notif_statistics stats_bt;
Emmanuel Grumbach653fa4a2008-06-30 17:23:11 +08004141 struct iwl_compressed_ba_resp compressed_ba;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004142 struct iwl_missed_beacon_notif missed_beacon;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004143 struct iwl_coex_medium_notification coex_medium_notif;
4144 struct iwl_coex_event_resp coex_event;
Johannes Berg0288d232010-08-23 07:56:54 -07004145 struct iwl_bt_coex_profile_notif bt_coex_profile_notif;
Zhu Yib481de92007-09-25 17:54:57 -07004146 __le32 status;
4147 u8 raw[0];
4148 } u;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004149} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07004150
Samuel Ortiza3139c52008-12-19 10:37:09 +08004151int iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
Winkler, Tomas8f5c87d2008-12-02 12:13:57 -08004152
Emmanuel Grumbach6a635782008-10-29 14:05:47 -07004153#endif /* __iwl_commands_h__ */