blob: 55779bf0627bc4072cf9392b041777294c57a003 [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,
Johannes Berg9e4afc22010-08-23 07:56:57 -0700181 REPLY_BT_COEX_SCO = 0xcf,
Johannes Berg0288d232010-08-23 07:56:54 -0700182
Zhu Yib481de92007-09-25 17:54:57 -0700183 REPLY_MAX = 0xff
184};
185
186/******************************************************************************
187 * (0)
Ben Cahillabceddb2007-11-29 11:09:50 +0800188 * Commonly used structures and definitions:
Ben Cahill80cc0c32007-11-29 11:10:09 +0800189 * Command header, rate_n_flags, txpower
Zhu Yib481de92007-09-25 17:54:57 -0700190 *
191 *****************************************************************************/
192
Tomas Winkler857485c2008-03-21 13:53:44 -0700193/* iwl_cmd_header flags value */
Zhu Yib481de92007-09-25 17:54:57 -0700194#define IWL_CMD_FAILED_MSK 0x40
195
Tomas Winkler9734cb22008-09-03 11:26:52 +0800196#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f)
197#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8)
198#define SEQ_TO_INDEX(s) ((s) & 0xff)
199#define INDEX_TO_SEQ(i) ((i) & 0xff)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800200#define SEQ_HUGE_FRAME cpu_to_le16(0x4000)
201#define SEQ_RX_FRAME cpu_to_le16(0x8000)
Tomas Winkler9734cb22008-09-03 11:26:52 +0800202
Ben Cahill075416c2007-11-29 11:10:08 +0800203/**
Tomas Winkler857485c2008-03-21 13:53:44 -0700204 * struct iwl_cmd_header
Ben Cahill075416c2007-11-29 11:10:08 +0800205 *
206 * This header format appears in the beginning of each command sent from the
207 * driver, and each response/notification received from uCode.
208 */
Tomas Winkler857485c2008-03-21 13:53:44 -0700209struct iwl_cmd_header {
Ben Cahill075416c2007-11-29 11:10:08 +0800210 u8 cmd; /* Command ID: REPLY_RXON, etc. */
Tomas Winkler9734cb22008-09-03 11:26:52 +0800211 u8 flags; /* 0:5 reserved, 6 abort, 7 internal */
Ben Cahill075416c2007-11-29 11:10:08 +0800212 /*
Tomas Winklera96a27f2008-10-23 23:48:56 -0700213 * The driver sets up the sequence number to values of its choosing.
Ben Cahill075416c2007-11-29 11:10:08 +0800214 * uCode does not use this value, but passes it back to the driver
215 * when sending the response to each driver-originated command, so
216 * the driver can match the response to the command. Since the values
217 * don't get used by uCode, the driver may set up an arbitrary format.
Zhu Yib481de92007-09-25 17:54:57 -0700218 *
Ben Cahill075416c2007-11-29 11:10:08 +0800219 * There is one exception: uCode sets bit 15 when it originates
220 * the response/notification, i.e. when the response/notification
221 * is not a direct response to a command sent by the driver. For
222 * example, uCode issues REPLY_3945_RX when it sends a received frame
223 * to the driver; it is not a direct response to any driver command.
Zhu Yib481de92007-09-25 17:54:57 -0700224 *
Ben Cahill075416c2007-11-29 11:10:08 +0800225 * The Linux driver uses the following format:
226 *
Tomas Winkler9734cb22008-09-03 11:26:52 +0800227 * 0:7 tfd index - position within TX queue
228 * 8:12 TX queue id
229 * 13 reserved
230 * 14 huge - driver sets this to indicate command is in the
231 * 'huge' storage at the end of the command buffers
232 * 15 unsolicited RX or uCode-originated notification
Zhu Yib481de92007-09-25 17:54:57 -0700233 */
234 __le16 sequence;
235
Ben Cahill075416c2007-11-29 11:10:08 +0800236 /* command or response/notification data follows immediately */
Zhu Yib481de92007-09-25 17:54:57 -0700237 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000238} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700239
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800240
241/**
242 * struct iwl3945_tx_power
243 *
244 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH
245 *
246 * Each entry contains two values:
247 * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
248 * linear value that multiplies the output of the digital signal processor,
249 * before being sent to the analog radio.
250 * 2) Radio gain. This sets the analog gain of the radio Tx path.
251 * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
252 *
253 * Driver obtains values from struct iwl3945_tx_power power_gain_table[][].
254 */
255struct iwl3945_tx_power {
256 u8 tx_gain; /* gain for analog radio */
257 u8 dsp_atten; /* gain for DSP */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000258} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800259
260/**
261 * struct iwl3945_power_per_rate
262 *
263 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
264 */
265struct iwl3945_power_per_rate {
266 u8 rate; /* plcp */
267 struct iwl3945_tx_power tpc;
268 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000269} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800270
Ben Cahillabceddb2007-11-29 11:09:50 +0800271/**
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800272 * iwlagn rate_n_flags bit fields
Ben Cahillabceddb2007-11-29 11:09:50 +0800273 *
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800274 * rate_n_flags format is used in following iwlagn commands:
Tomas Winkler857485c2008-03-21 13:53:44 -0700275 * REPLY_RX (response only)
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800276 * REPLY_RX_MPDU (response only)
Ben Cahillabceddb2007-11-29 11:09:50 +0800277 * REPLY_TX (both command and response)
278 * REPLY_TX_LINK_QUALITY_CMD
279 *
280 * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
281 * 2-0: 0) 6 Mbps
282 * 1) 12 Mbps
283 * 2) 18 Mbps
284 * 3) 24 Mbps
285 * 4) 36 Mbps
286 * 5) 48 Mbps
287 * 6) 54 Mbps
288 * 7) 60 Mbps
289 *
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800290 * 4-3: 0) Single stream (SISO)
Ben Cahillabceddb2007-11-29 11:09:50 +0800291 * 1) Dual stream (MIMO)
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800292 * 2) Triple stream (MIMO)
Ben Cahillabceddb2007-11-29 11:09:50 +0800293 *
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700294 * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
Ben Cahillabceddb2007-11-29 11:09:50 +0800295 *
296 * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
297 * 3-0: 0xD) 6 Mbps
298 * 0xF) 9 Mbps
299 * 0x5) 12 Mbps
300 * 0x7) 18 Mbps
301 * 0x9) 24 Mbps
302 * 0xB) 36 Mbps
303 * 0x1) 48 Mbps
304 * 0x3) 54 Mbps
305 *
306 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
Daniel Wu10617872008-12-20 10:53:29 -0800307 * 6-0: 10) 1 Mbps
Ben Cahillabceddb2007-11-29 11:09:50 +0800308 * 20) 2 Mbps
309 * 55) 5.5 Mbps
310 * 110) 11 Mbps
311 */
312#define RATE_MCS_CODE_MSK 0x7
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800313#define RATE_MCS_SPATIAL_POS 3
314#define RATE_MCS_SPATIAL_MSK 0x18
Ben Cahillabceddb2007-11-29 11:09:50 +0800315#define RATE_MCS_HT_DUP_POS 5
316#define RATE_MCS_HT_DUP_MSK 0x20
317
Ben Cahill075416c2007-11-29 11:10:08 +0800318/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
Ben Cahillabceddb2007-11-29 11:09:50 +0800319#define RATE_MCS_FLAGS_POS 8
320#define RATE_MCS_HT_POS 8
321#define RATE_MCS_HT_MSK 0x100
322
Ben Cahill075416c2007-11-29 11:10:08 +0800323/* 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 +0800324#define RATE_MCS_CCK_POS 9
325#define RATE_MCS_CCK_MSK 0x200
326
Ben Cahill075416c2007-11-29 11:10:08 +0800327/* Bit 10: (1) Use Green Field preamble */
Ben Cahillabceddb2007-11-29 11:09:50 +0800328#define RATE_MCS_GF_POS 10
329#define RATE_MCS_GF_MSK 0x400
330
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700331/* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */
332#define RATE_MCS_HT40_POS 11
333#define RATE_MCS_HT40_MSK 0x800
Ben Cahillabceddb2007-11-29 11:09:50 +0800334
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700335/* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */
Ben Cahillabceddb2007-11-29 11:09:50 +0800336#define RATE_MCS_DUP_POS 12
337#define RATE_MCS_DUP_MSK 0x1000
338
Ben Cahill075416c2007-11-29 11:10:08 +0800339/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
Ben Cahillabceddb2007-11-29 11:09:50 +0800340#define RATE_MCS_SGI_POS 13
341#define RATE_MCS_SGI_MSK 0x2000
342
343/**
Tomas Winkler76eff182008-10-14 12:32:45 -0700344 * rate_n_flags Tx antenna masks
345 * 4965 has 2 transmitters
346 * 5100 has 1 transmitter B
347 * 5150 has 1 transmitter A
348 * 5300 has 3 transmitters
349 * 5350 has 3 transmitters
350 * bit14:16
Ben Cahillabceddb2007-11-29 11:09:50 +0800351 */
Tomas Winkler600c0e12008-12-19 10:37:04 +0800352#define RATE_MCS_ANT_POS 14
353#define RATE_MCS_ANT_A_MSK 0x04000
354#define RATE_MCS_ANT_B_MSK 0x08000
355#define RATE_MCS_ANT_C_MSK 0x10000
356#define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK)
357#define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK)
Tomas Winkler76eff182008-10-14 12:32:45 -0700358#define RATE_ANT_NUM 3
Ben Cahill80cc0c32007-11-29 11:10:09 +0800359
360#define POWER_TABLE_NUM_ENTRIES 33
361#define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
362#define POWER_TABLE_CCK_ENTRY 32
363
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700364#define IWL_PWR_NUM_HT_OFDM_ENTRIES 24
365#define IWL_PWR_CCK_ENTRIES 2
366
Ben Cahill80cc0c32007-11-29 11:10:09 +0800367/**
368 * union iwl4965_tx_power_dual_stream
369 *
370 * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
371 * Use __le32 version (struct tx_power_dual_stream) when building command.
372 *
373 * Driver provides radio gain and DSP attenuation settings to device in pairs,
374 * one value for each transmitter chain. The first value is for transmitter A,
375 * second for transmitter B.
376 *
377 * For SISO bit rates, both values in a pair should be identical.
378 * For MIMO rates, one value may be different from the other,
379 * in order to balance the Tx output between the two transmitters.
380 *
381 * See more details in doc for TXPOWER in iwl-4965-hw.h.
382 */
383union iwl4965_tx_power_dual_stream {
384 struct {
385 u8 radio_tx_gain[2];
386 u8 dsp_predis_atten[2];
387 } s;
388 u32 dw;
389};
390
391/**
392 * struct tx_power_dual_stream
393 *
394 * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
395 *
396 * Same format as iwl_tx_power_dual_stream, but __le32
397 */
398struct tx_power_dual_stream {
399 __le32 dw;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000400} __packed;
Ben Cahill80cc0c32007-11-29 11:10:09 +0800401
402/**
403 * struct iwl4965_tx_power_db
404 *
405 * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
406 */
407struct iwl4965_tx_power_db {
408 struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000409} __packed;
Ben Cahill80cc0c32007-11-29 11:10:09 +0800410
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800411/**
Tomas Winklera96a27f2008-10-23 23:48:56 -0700412 * Command REPLY_TX_POWER_DBM_CMD = 0x98
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800413 * struct iwl5000_tx_power_dbm_cmd
414 */
415#define IWL50_TX_POWER_AUTO 0x7f
Gregory Greenman853554a2008-06-30 17:23:01 +0800416#define IWL50_TX_POWER_NO_CLOSED (0x1 << 6)
417
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800418struct iwl5000_tx_power_dbm_cmd {
419 s8 global_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
420 u8 flags;
421 s8 srv_chan_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
422 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000423} __packed;
Ben Cahill80cc0c32007-11-29 11:10:09 +0800424
Wey-Yi Guy2f748de2009-09-17 10:43:51 -0700425/**
426 * Command TX_ANT_CONFIGURATION_CMD = 0x98
427 * This command is used to configure valid Tx antenna.
428 * By default uCode concludes the valid antenna according to the radio flavor.
429 * This command enables the driver to override/modify this conclusion.
430 */
431struct iwl_tx_ant_config_cmd {
432 __le32 valid;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000433} __packed;
Wey-Yi Guy2f748de2009-09-17 10:43:51 -0700434
Zhu Yib481de92007-09-25 17:54:57 -0700435/******************************************************************************
436 * (0a)
437 * Alive and Error Commands & Responses:
438 *
439 *****************************************************************************/
440
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800441#define UCODE_VALID_OK cpu_to_le32(0x1)
Zhu Yib481de92007-09-25 17:54:57 -0700442#define INITIALIZE_SUBTYPE (9)
443
444/*
Ben Cahill075416c2007-11-29 11:10:08 +0800445 * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command)
446 *
447 * uCode issues this "initialize alive" notification once the initialization
448 * uCode image has completed its work, and is ready to load the runtime image.
449 * This is the *first* "alive" notification that the driver will receive after
450 * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
451 *
452 * See comments documenting "BSM" (bootstrap state machine).
453 *
454 * For 4965, this notification contains important calibration data for
455 * calculating txpower settings:
456 *
457 * 1) Power supply voltage indication. The voltage sensor outputs higher
Tomas Winklera96a27f2008-10-23 23:48:56 -0700458 * values for lower voltage, and vice verse.
Ben Cahill075416c2007-11-29 11:10:08 +0800459 *
460 * 2) Temperature measurement parameters, for each of two channel widths
461 * (20 MHz and 40 MHz) supported by the radios. Temperature sensing
462 * is done via one of the receiver chains, and channel width influences
463 * the results.
464 *
465 * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation,
466 * for each of 5 frequency ranges.
Zhu Yib481de92007-09-25 17:54:57 -0700467 */
Tomas Winkler885ba202008-05-29 16:34:55 +0800468struct iwl_init_alive_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700469 u8 ucode_minor;
470 u8 ucode_major;
471 __le16 reserved1;
472 u8 sw_rev[8];
473 u8 ver_type;
Ben Cahill075416c2007-11-29 11:10:08 +0800474 u8 ver_subtype; /* "9" for initialize alive */
Zhu Yib481de92007-09-25 17:54:57 -0700475 __le16 reserved2;
476 __le32 log_event_table_ptr;
477 __le32 error_event_table_ptr;
478 __le32 timestamp;
479 __le32 is_valid;
480
Zhu Yib481de92007-09-25 17:54:57 -0700481 /* calibration values from "initialize" uCode */
Ben Cahill075416c2007-11-29 11:10:08 +0800482 __le32 voltage; /* signed, higher value is lower voltage */
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700483 __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for HT40 */
Zhu Yib481de92007-09-25 17:54:57 -0700484 __le32 therm_r2[2]; /* signed */
485 __le32 therm_r3[2]; /* signed */
486 __le32 therm_r4[2]; /* signed */
487 __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups,
488 * 2 Tx chains */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000489} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700490
Ben Cahill075416c2007-11-29 11:10:08 +0800491
492/**
493 * REPLY_ALIVE = 0x1 (response only, not a command)
494 *
495 * uCode issues this "alive" notification once the runtime image is ready
496 * to receive commands from the driver. This is the *second* "alive"
497 * notification that the driver will receive after rebooting uCode;
498 * this "alive" is indicated by subtype field != 9.
499 *
500 * See comments documenting "BSM" (bootstrap state machine).
501 *
502 * This response includes two pointers to structures within the device's
503 * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
504 *
505 * 1) log_event_table_ptr indicates base of the event log. This traces
506 * a 256-entry history of uCode execution within a circular buffer.
507 * Its header format is:
508 *
509 * __le32 log_size; log capacity (in number of entries)
510 * __le32 type; (1) timestamp with each entry, (0) no timestamp
511 * __le32 wraps; # times uCode has wrapped to top of circular buffer
512 * __le32 write_index; next circular buffer entry that uCode would fill
513 *
514 * The header is followed by the circular buffer of log entries. Entries
515 * with timestamps have the following format:
516 *
517 * __le32 event_id; range 0 - 1500
518 * __le32 timestamp; low 32 bits of TSF (of network, if associated)
519 * __le32 data; event_id-specific data value
520 *
521 * Entries without timestamps contain only event_id and data.
522 *
Wey-Yi Guy461ef382010-03-30 17:57:53 -0700523 *
Ben Cahill075416c2007-11-29 11:10:08 +0800524 * 2) error_event_table_ptr indicates base of the error log. This contains
Wey-Yi Guy461ef382010-03-30 17:57:53 -0700525 * information about any uCode error that occurs. For agn, the format
Ben Cahill075416c2007-11-29 11:10:08 +0800526 * of the error log is:
527 *
528 * __le32 valid; (nonzero) valid, (0) log is empty
529 * __le32 error_id; type of error
530 * __le32 pc; program counter
531 * __le32 blink1; branch link
532 * __le32 blink2; branch link
533 * __le32 ilink1; interrupt link
534 * __le32 ilink2; interrupt link
535 * __le32 data1; error-specific data
536 * __le32 data2; error-specific data
537 * __le32 line; source code line of error
538 * __le32 bcon_time; beacon timer
539 * __le32 tsf_low; network timestamp function timer
540 * __le32 tsf_hi; network timestamp function timer
Wey-Yi Guy461ef382010-03-30 17:57:53 -0700541 * __le32 gp1; GP1 timer register
542 * __le32 gp2; GP2 timer register
543 * __le32 gp3; GP3 timer register
544 * __le32 ucode_ver; uCode version
545 * __le32 hw_ver; HW Silicon version
546 * __le32 brd_ver; HW board version
547 * __le32 log_pc; log program counter
548 * __le32 frame_ptr; frame pointer
549 * __le32 stack_ptr; stack pointer
550 * __le32 hcmd; last host command
551 * __le32 isr0; isr status register LMPM_NIC_ISR0: rxtx_flag
552 * __le32 isr1; isr status register LMPM_NIC_ISR1: host_flag
553 * __le32 isr2; isr status register LMPM_NIC_ISR2: enc_flag
554 * __le32 isr3; isr status register LMPM_NIC_ISR3: time_flag
555 * __le32 isr4; isr status register LMPM_NIC_ISR4: wico interrupt
556 * __le32 isr_pref; isr status register LMPM_NIC_PREF_STAT
557 * __le32 wait_event; wait event() caller address
558 * __le32 l2p_control; L2pControlField
559 * __le32 l2p_duration; L2pDurationField
560 * __le32 l2p_mhvalid; L2pMhValidBits
561 * __le32 l2p_addr_match; L2pAddrMatchStat
562 * __le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL)
563 * __le32 u_timestamp; indicate when the date and time of the compilation
564 * __le32 reserved;
Ben Cahill075416c2007-11-29 11:10:08 +0800565 *
566 * The Linux driver can print both logs to the system log when a uCode error
567 * occurs.
568 */
Tomas Winkler885ba202008-05-29 16:34:55 +0800569struct iwl_alive_resp {
Ben Cahill075416c2007-11-29 11:10:08 +0800570 u8 ucode_minor;
571 u8 ucode_major;
572 __le16 reserved1;
573 u8 sw_rev[8];
574 u8 ver_type;
575 u8 ver_subtype; /* not "9" for runtime alive */
576 __le16 reserved2;
577 __le32 log_event_table_ptr; /* SRAM address for event log */
578 __le32 error_event_table_ptr; /* SRAM address for error log */
579 __le32 timestamp;
580 __le32 is_valid;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000581} __packed;
Ben Cahill075416c2007-11-29 11:10:08 +0800582
Zhu Yib481de92007-09-25 17:54:57 -0700583/*
584 * REPLY_ERROR = 0x2 (response only, not a command)
585 */
Tomas Winkler885ba202008-05-29 16:34:55 +0800586struct iwl_error_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700587 __le32 error_type;
588 u8 cmd_id;
589 u8 reserved1;
590 __le16 bad_cmd_seq_num;
Zhu Yib481de92007-09-25 17:54:57 -0700591 __le32 error_info;
Tomas Winkler3195c1f2008-10-08 09:37:30 +0800592 __le64 timestamp;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000593} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700594
595/******************************************************************************
596 * (1)
597 * RXON Commands & Responses:
598 *
599 *****************************************************************************/
600
601/*
602 * Rx config defines & structure
603 */
604/* rx_config device types */
605enum {
606 RXON_DEV_TYPE_AP = 1,
607 RXON_DEV_TYPE_ESS = 3,
608 RXON_DEV_TYPE_IBSS = 4,
609 RXON_DEV_TYPE_SNIFFER = 6,
610};
611
Ben Cahill14519a02007-11-29 11:09:59 +0800612
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800613#define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0)
Rick Farrington7b841722009-01-23 13:45:10 -0800614#define RXON_RX_CHAIN_DRIVER_FORCE_POS (0)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800615#define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1)
Ben Cahill14519a02007-11-29 11:09:59 +0800616#define RXON_RX_CHAIN_VALID_POS (1)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800617#define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4)
Ben Cahill14519a02007-11-29 11:09:59 +0800618#define RXON_RX_CHAIN_FORCE_SEL_POS (4)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800619#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7)
Ben Cahill14519a02007-11-29 11:09:59 +0800620#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800621#define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10)
Ben Cahill14519a02007-11-29 11:09:59 +0800622#define RXON_RX_CHAIN_CNT_POS (10)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800623#define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12)
Ben Cahill14519a02007-11-29 11:09:59 +0800624#define RXON_RX_CHAIN_MIMO_CNT_POS (12)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800625#define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14)
Ben Cahill14519a02007-11-29 11:09:59 +0800626#define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
627
Zhu Yib481de92007-09-25 17:54:57 -0700628/* rx_config flags */
629/* band & modulation selection */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800630#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0)
631#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -0700632/* auto detection enable */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800633#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2)
Zhu Yib481de92007-09-25 17:54:57 -0700634/* TGg protection when tx */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800635#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3)
Zhu Yib481de92007-09-25 17:54:57 -0700636/* cck short slot & preamble */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800637#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4)
638#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5)
Zhu Yib481de92007-09-25 17:54:57 -0700639/* antenna selection */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800640#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7)
641#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00)
642#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
643#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
Zhu Yib481de92007-09-25 17:54:57 -0700644/* radar detection enable */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800645#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12)
646#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13)
Zhu Yib481de92007-09-25 17:54:57 -0700647/* rx response to host with 8-byte TSF
648* (according to ON_AIR deassertion) */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800649#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15)
Zhu Yib481de92007-09-25 17:54:57 -0700650
Ben Cahill14519a02007-11-29 11:09:59 +0800651
652/* HT flags */
653#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800654#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22)
Ben Cahill14519a02007-11-29 11:09:59 +0800655
656#define RXON_FLG_HT_OPERATING_MODE_POS (23)
657
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800658#define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23)
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700659#define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23)
Ben Cahill14519a02007-11-29 11:09:59 +0800660
661#define RXON_FLG_CHANNEL_MODE_POS (25)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800662#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25)
Wey-Yi Guya2b0f022009-05-22 11:01:49 -0700663
664/* channel mode */
665enum {
666 CHANNEL_MODE_LEGACY = 0,
667 CHANNEL_MODE_PURE_40 = 1,
668 CHANNEL_MODE_MIXED = 2,
669 CHANNEL_MODE_RESERVED = 3,
670};
671#define RXON_FLG_CHANNEL_MODE_LEGACY cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
672#define RXON_FLG_CHANNEL_MODE_PURE_40 cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
673#define RXON_FLG_CHANNEL_MODE_MIXED cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
674
Emmanuel Grumbacha326a5d2008-07-11 11:53:31 +0800675/* CTS to self (if spec allows) flag */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800676#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30)
Ben Cahill14519a02007-11-29 11:09:59 +0800677
Zhu Yib481de92007-09-25 17:54:57 -0700678/* rx_config filter flags */
679/* accept all data frames */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800680#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0)
Zhu Yib481de92007-09-25 17:54:57 -0700681/* pass control & management to host */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800682#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -0700683/* accept multi-cast */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800684#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2)
Zhu Yib481de92007-09-25 17:54:57 -0700685/* don't decrypt uni-cast frames */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800686#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3)
Zhu Yib481de92007-09-25 17:54:57 -0700687/* don't decrypt multi-cast frames */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800688#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
Zhu Yib481de92007-09-25 17:54:57 -0700689/* STA is associated */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800690#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5)
Zhu Yib481de92007-09-25 17:54:57 -0700691/* transfer to host non bssid beacons in associated state */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800692#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6)
Zhu Yib481de92007-09-25 17:54:57 -0700693
Ben Cahill80cc0c32007-11-29 11:10:09 +0800694/**
Zhu Yib481de92007-09-25 17:54:57 -0700695 * REPLY_RXON = 0x10 (command, has simple generic response)
Ben Cahill80cc0c32007-11-29 11:10:09 +0800696 *
697 * RXON tunes the radio tuner to a service channel, and sets up a number
698 * of parameters that are used primarily for Rx, but also for Tx operations.
699 *
700 * NOTE: When tuning to a new channel, driver must set the
701 * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent
702 * info within the device, including the station tables, tx retry
703 * rate tables, and txpower tables. Driver must build a new station
704 * table and txpower table before transmitting anything on the RXON
705 * channel.
706 *
707 * NOTE: All RXONs wipe clean the internal txpower table. Driver must
708 * issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
709 * regardless of whether RXON_FILTER_ASSOC_MSK is set.
Zhu Yib481de92007-09-25 17:54:57 -0700710 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800711
712struct iwl3945_rxon_cmd {
713 u8 node_addr[6];
714 __le16 reserved1;
715 u8 bssid_addr[6];
716 __le16 reserved2;
717 u8 wlap_bssid_addr[6];
718 __le16 reserved3;
719 u8 dev_type;
720 u8 air_propagation;
721 __le16 reserved4;
722 u8 ofdm_basic_rates;
723 u8 cck_basic_rates;
724 __le16 assoc_id;
725 __le32 flags;
726 __le32 filter_flags;
727 __le16 channel;
728 __le16 reserved5;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000729} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800730
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800731struct iwl4965_rxon_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700732 u8 node_addr[6];
733 __le16 reserved1;
734 u8 bssid_addr[6];
735 __le16 reserved2;
736 u8 wlap_bssid_addr[6];
737 __le16 reserved3;
738 u8 dev_type;
739 u8 air_propagation;
Zhu Yib481de92007-09-25 17:54:57 -0700740 __le16 rx_chain;
Zhu Yib481de92007-09-25 17:54:57 -0700741 u8 ofdm_basic_rates;
742 u8 cck_basic_rates;
743 __le16 assoc_id;
744 __le32 flags;
745 __le32 filter_flags;
746 __le16 channel;
Zhu Yib481de92007-09-25 17:54:57 -0700747 u8 ofdm_ht_single_stream_basic_rates;
748 u8 ofdm_ht_dual_stream_basic_rates;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000749} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700750
Tomas Winklera96a27f2008-10-23 23:48:56 -0700751/* 5000 HW just extend this command */
Gregory Greenmanc1adf9f2008-05-15 13:53:59 +0800752struct iwl_rxon_cmd {
753 u8 node_addr[6];
754 __le16 reserved1;
755 u8 bssid_addr[6];
756 __le16 reserved2;
757 u8 wlap_bssid_addr[6];
758 __le16 reserved3;
759 u8 dev_type;
760 u8 air_propagation;
761 __le16 rx_chain;
762 u8 ofdm_basic_rates;
763 u8 cck_basic_rates;
764 __le16 assoc_id;
765 __le32 flags;
766 __le32 filter_flags;
767 __le16 channel;
768 u8 ofdm_ht_single_stream_basic_rates;
769 u8 ofdm_ht_dual_stream_basic_rates;
770 u8 ofdm_ht_triple_stream_basic_rates;
771 u8 reserved5;
772 __le16 acquisition_data;
773 __le16 reserved6;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000774} __packed;
Gregory Greenmanc1adf9f2008-05-15 13:53:59 +0800775
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800776/*
777 * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
778 */
779struct iwl3945_rxon_assoc_cmd {
780 __le32 flags;
781 __le32 filter_flags;
782 u8 ofdm_basic_rates;
783 u8 cck_basic_rates;
784 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000785} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800786
787struct iwl4965_rxon_assoc_cmd {
788 __le32 flags;
789 __le32 filter_flags;
790 u8 ofdm_basic_rates;
791 u8 cck_basic_rates;
792 u8 ofdm_ht_single_stream_basic_rates;
793 u8 ofdm_ht_dual_stream_basic_rates;
794 __le16 rx_chain_select_flags;
795 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000796} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800797
Ron Rindjunskyfe7a90c2008-05-29 16:35:14 +0800798struct iwl5000_rxon_assoc_cmd {
799 __le32 flags;
800 __le32 filter_flags;
801 u8 ofdm_basic_rates;
802 u8 cck_basic_rates;
803 __le16 reserved1;
804 u8 ofdm_ht_single_stream_basic_rates;
805 u8 ofdm_ht_dual_stream_basic_rates;
806 u8 ofdm_ht_triple_stream_basic_rates;
807 u8 reserved2;
808 __le16 rx_chain_select_flags;
809 __le16 acquisition_data;
810 __le32 reserved3;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000811} __packed;
Gregory Greenmanc1adf9f2008-05-15 13:53:59 +0800812
Tomas Winklerb5d7be52008-07-19 04:41:24 +0300813#define IWL_CONN_MAX_LISTEN_INTERVAL 10
Tomas Winkler2c2f3b32009-06-19 13:52:45 -0700814#define IWL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */
815#define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */
Ron Rindjunskyfe7a90c2008-05-29 16:35:14 +0800816
Zhu Yib481de92007-09-25 17:54:57 -0700817/*
818 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
819 */
Tomas Winkler3195c1f2008-10-08 09:37:30 +0800820struct iwl_rxon_time_cmd {
821 __le64 timestamp;
Zhu Yib481de92007-09-25 17:54:57 -0700822 __le16 beacon_interval;
823 __le16 atim_window;
824 __le32 beacon_init_val;
825 __le16 listen_interval;
826 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000827} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700828
Zhu Yib481de92007-09-25 17:54:57 -0700829/*
830 * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
831 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800832struct iwl3945_channel_switch_cmd {
833 u8 band;
834 u8 expect_beacon;
835 __le16 channel;
836 __le32 rxon_flags;
837 __le32 rxon_filter_flags;
838 __le32 switch_time;
839 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000840} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800841
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700842struct iwl4965_channel_switch_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700843 u8 band;
844 u8 expect_beacon;
845 __le16 channel;
846 __le32 rxon_flags;
847 __le32 rxon_filter_flags;
848 __le32 switch_time;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800849 struct iwl4965_tx_power_db tx_power;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000850} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700851
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700852/**
853 * struct iwl5000_channel_switch_cmd
854 * @band: 0- 5.2GHz, 1- 2.4GHz
855 * @expect_beacon: 0- resume transmits after channel switch
856 * 1- wait for beacon to resume transmits
857 * @channel: new channel number
858 * @rxon_flags: Rx on flags
859 * @rxon_filter_flags: filtering parameters
860 * @switch_time: switch time in extended beacon format
861 * @reserved: reserved bytes
862 */
863struct iwl5000_channel_switch_cmd {
864 u8 band;
865 u8 expect_beacon;
866 __le16 channel;
867 __le32 rxon_flags;
868 __le32 rxon_filter_flags;
869 __le32 switch_time;
870 __le32 reserved[2][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000871} __packed;
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700872
873/**
874 * struct iwl6000_channel_switch_cmd
875 * @band: 0- 5.2GHz, 1- 2.4GHz
876 * @expect_beacon: 0- resume transmits after channel switch
877 * 1- wait for beacon to resume transmits
878 * @channel: new channel number
879 * @rxon_flags: Rx on flags
880 * @rxon_filter_flags: filtering parameters
881 * @switch_time: switch time in extended beacon format
882 * @reserved: reserved bytes
883 */
884struct iwl6000_channel_switch_cmd {
885 u8 band;
886 u8 expect_beacon;
887 __le16 channel;
888 __le32 rxon_flags;
889 __le32 rxon_filter_flags;
890 __le32 switch_time;
891 __le32 reserved[3][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000892} __packed;
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700893
Zhu Yib481de92007-09-25 17:54:57 -0700894/*
895 * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
896 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -0800897struct iwl_csa_notification {
Zhu Yib481de92007-09-25 17:54:57 -0700898 __le16 band;
899 __le16 channel;
900 __le32 status; /* 0 - OK, 1 - fail */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000901} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700902
903/******************************************************************************
904 * (2)
905 * Quality-of-Service (QOS) Commands & Responses:
906 *
907 *****************************************************************************/
Ben Cahill2054a002007-11-29 11:10:10 +0800908
909/**
910 * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
911 * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
912 *
913 * @cw_min: Contention window, start value in numbers of slots.
914 * Should be a power-of-2, minus 1. Device's default is 0x0f.
915 * @cw_max: Contention window, max value in numbers of slots.
916 * Should be a power-of-2, minus 1. Device's default is 0x3f.
917 * @aifsn: Number of slots in Arbitration Interframe Space (before
918 * performing random backoff timing prior to Tx). Device default 1.
919 * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
920 *
921 * Device will automatically increase contention window by (2*CW) + 1 for each
922 * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
923 * value, to cap the CW value.
924 */
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800925struct iwl_ac_qos {
Zhu Yib481de92007-09-25 17:54:57 -0700926 __le16 cw_min;
927 __le16 cw_max;
928 u8 aifsn;
929 u8 reserved1;
930 __le16 edca_txop;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000931} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700932
933/* QoS flags defines */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800934#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01)
935#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02)
936#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10)
Zhu Yib481de92007-09-25 17:54:57 -0700937
Ben Cahill2054a002007-11-29 11:10:10 +0800938/* Number of Access Categories (AC) (EDCA), queues 0..3 */
Zhu Yib481de92007-09-25 17:54:57 -0700939#define AC_NUM 4
940
941/*
942 * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
Ben Cahill2054a002007-11-29 11:10:10 +0800943 *
944 * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
945 * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
Zhu Yib481de92007-09-25 17:54:57 -0700946 */
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800947struct iwl_qosparam_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700948 __le32 qos_flags;
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800949 struct iwl_ac_qos ac[AC_NUM];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000950} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700951
952/******************************************************************************
953 * (3)
954 * Add/Modify Stations Commands & Responses:
955 *
956 *****************************************************************************/
957/*
958 * Multi station support
959 */
Ben Cahill2054a002007-11-29 11:10:10 +0800960
961/* Special, dedicated locations within device's station table */
Zhu Yib481de92007-09-25 17:54:57 -0700962#define IWL_AP_ID 0
Zhu Yib481de92007-09-25 17:54:57 -0700963#define IWL_STA_ID 2
Tomas Winkler4c897252008-12-19 10:37:05 +0800964#define IWL3945_BROADCAST_ID 24
965#define IWL3945_STATION_COUNT 25
Zhu Yib481de92007-09-25 17:54:57 -0700966#define IWL4965_BROADCAST_ID 31
967#define IWL4965_STATION_COUNT 32
Wey-Yi Guybf3c7fd2010-06-24 14:08:05 -0700968#define IWLAGN_BROADCAST_ID 15
969#define IWLAGN_STATION_COUNT 16
Zhu Yib481de92007-09-25 17:54:57 -0700970
971#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
972#define IWL_INVALID_STATION 255
973
Johannes Berg1bd14ea2010-07-15 11:48:21 -0700974#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2)
975#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800976#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17)
977#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18)
Ben Cahill74093dd2007-11-29 11:09:53 +0800978#define STA_FLG_MAX_AGG_SIZE_POS (19)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800979#define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19)
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700980#define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800981#define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22)
Ben Cahill74093dd2007-11-29 11:09:53 +0800982#define STA_FLG_AGG_MPDU_DENSITY_POS (23)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800983#define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23)
Zhu Yib481de92007-09-25 17:54:57 -0700984
Ben Cahill2054a002007-11-29 11:10:10 +0800985/* Use in mode field. 1: modify existing entry, 0: add new station entry */
Zhu Yib481de92007-09-25 17:54:57 -0700986#define STA_CONTROL_MODIFY_MSK 0x01
987
988/* key flags __le16*/
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800989#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007)
990#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000)
991#define STA_KEY_FLG_WEP cpu_to_le16(0x0001)
992#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002)
993#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003)
Zhu Yib481de92007-09-25 17:54:57 -0700994
995#define STA_KEY_FLG_KEYID_POS 8
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800996#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800)
Emmanuel Grumbacheaaf7892008-02-13 11:32:29 -0800997/* wep key is either from global key (0) or from station info array (1) */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800998#define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008)
Emmanuel Grumbacheaaf7892008-02-13 11:32:29 -0800999
1000/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001001#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000)
1002#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
Emmanuel Grumbachdeb09c42008-03-19 16:41:41 -07001003#define STA_KEY_MAX_NUM 8
Johannes Bergc10afb62010-08-23 10:46:43 +02001004#define STA_KEY_MAX_NUM_PAN 16
Zhu Yib481de92007-09-25 17:54:57 -07001005
Ben Cahill2054a002007-11-29 11:10:10 +08001006/* Flags indicate whether to modify vs. don't change various station params */
Zhu Yib481de92007-09-25 17:54:57 -07001007#define STA_MODIFY_KEY_MASK 0x01
1008#define STA_MODIFY_TID_DISABLE_TX 0x02
1009#define STA_MODIFY_TX_RATE_MSK 0x04
1010#define STA_MODIFY_ADDBA_TID_MSK 0x08
1011#define STA_MODIFY_DELBA_TID_MSK 0x10
Johannes Berg6ab10ff2009-11-13 11:56:37 -08001012#define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20
Ben Cahill2054a002007-11-29 11:10:10 +08001013
1014/* Receiver address (actually, Rx station's index into station table),
1015 * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
Zhu Yib481de92007-09-25 17:54:57 -07001016#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid))
1017
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001018struct iwl4965_keyinfo {
Zhu Yib481de92007-09-25 17:54:57 -07001019 __le16 key_flags;
1020 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
1021 u8 reserved1;
1022 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
Emmanuel Grumbacheaaf7892008-02-13 11:32:29 -08001023 u8 key_offset;
1024 u8 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -07001025 u8 key[16]; /* 16-byte unicast decryption key */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001026} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001027
Tomas Winkler133636d2008-05-05 10:22:34 +08001028/* 5000 */
1029struct iwl_keyinfo {
1030 __le16 key_flags;
1031 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
1032 u8 reserved1;
1033 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
1034 u8 key_offset;
1035 u8 reserved2;
1036 u8 key[16]; /* 16-byte unicast decryption key */
1037 __le64 tx_secur_seq_cnt;
1038 __le64 hw_tkip_mic_rx_key;
1039 __le64 hw_tkip_mic_tx_key;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001040} __packed;
Tomas Winkler133636d2008-05-05 10:22:34 +08001041
Ben Cahill2054a002007-11-29 11:10:10 +08001042/**
1043 * struct sta_id_modify
1044 * @addr[ETH_ALEN]: station's MAC address
1045 * @sta_id: index of station in uCode's station table
1046 * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
1047 *
1048 * Driver selects unused table index when adding new station,
1049 * or the index to a pre-existing station entry when modifying that station.
1050 * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
1051 *
1052 * modify_mask flags select which parameters to modify vs. leave alone.
1053 */
Zhu Yib481de92007-09-25 17:54:57 -07001054struct sta_id_modify {
1055 u8 addr[ETH_ALEN];
1056 __le16 reserved1;
1057 u8 sta_id;
1058 u8 modify_mask;
1059 __le16 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001060} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001061
1062/*
1063 * REPLY_ADD_STA = 0x18 (command)
Ben Cahill2054a002007-11-29 11:10:10 +08001064 *
1065 * The device contains an internal table of per-station information,
1066 * with info on security keys, aggregation parameters, and Tx rates for
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001067 * initial Tx attempt and any retries (agn devices uses
1068 * REPLY_TX_LINK_QUALITY_CMD,
Ben Cahill2054a002007-11-29 11:10:10 +08001069 * 3945 uses REPLY_RATE_SCALE to set up rate tables).
1070 *
1071 * REPLY_ADD_STA sets up the table entry for one station, either creating
1072 * a new entry, or modifying a pre-existing one.
1073 *
1074 * NOTE: RXON command (without "associated" bit set) wipes the station table
1075 * clean. Moving into RF_KILL state does this also. Driver must set up
1076 * new station table before transmitting anything on the RXON channel
1077 * (except active scans or active measurements; those commands carry
1078 * their own txpower/rate setup data).
1079 *
1080 * When getting started on a new channel, driver must set up the
1081 * IWL_BROADCAST_ID entry (last entry in the table). For a client
1082 * station in a BSS, once an AP is selected, driver sets up the AP STA
1083 * in the IWL_AP_ID entry (1st entry in the table). BROADCAST and AP
1084 * are all that are needed for a BSS client station. If the device is
1085 * used as AP, or in an IBSS network, driver must set up station table
1086 * entries for all STAs in network, starting with index IWL_STA_ID.
Zhu Yib481de92007-09-25 17:54:57 -07001087 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001088
1089struct iwl3945_addsta_cmd {
1090 u8 mode; /* 1: modify existing, 0: add new station */
1091 u8 reserved[3];
1092 struct sta_id_modify sta;
1093 struct iwl4965_keyinfo key;
1094 __le32 station_flags; /* STA_FLG_* */
1095 __le32 station_flags_msk; /* STA_FLG_* */
1096
1097 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1098 * corresponding to bit (e.g. bit 5 controls TID 5).
1099 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1100 __le16 tid_disable_tx;
1101
1102 __le16 rate_n_flags;
1103
1104 /* TID for which to add block-ack support.
1105 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1106 u8 add_immediate_ba_tid;
1107
1108 /* TID for which to remove block-ack support.
1109 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1110 u8 remove_immediate_ba_tid;
1111
1112 /* Starting Sequence Number for added block-ack support.
1113 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1114 __le16 add_immediate_ba_ssn;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001115} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001116
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001117struct iwl4965_addsta_cmd {
Ben Cahill2054a002007-11-29 11:10:10 +08001118 u8 mode; /* 1: modify existing, 0: add new station */
Zhu Yib481de92007-09-25 17:54:57 -07001119 u8 reserved[3];
1120 struct sta_id_modify sta;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001121 struct iwl4965_keyinfo key;
Ben Cahill2054a002007-11-29 11:10:10 +08001122 __le32 station_flags; /* STA_FLG_* */
1123 __le32 station_flags_msk; /* STA_FLG_* */
1124
1125 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1126 * corresponding to bit (e.g. bit 5 controls TID 5).
1127 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001128 __le16 tid_disable_tx;
Ben Cahill2054a002007-11-29 11:10:10 +08001129
Zhu Yib481de92007-09-25 17:54:57 -07001130 __le16 reserved1;
Ben Cahill2054a002007-11-29 11:10:10 +08001131
1132 /* TID for which to add block-ack support.
1133 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001134 u8 add_immediate_ba_tid;
Ben Cahill2054a002007-11-29 11:10:10 +08001135
1136 /* TID for which to remove block-ack support.
1137 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001138 u8 remove_immediate_ba_tid;
Ben Cahill2054a002007-11-29 11:10:10 +08001139
1140 /* Starting Sequence Number for added block-ack support.
1141 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001142 __le16 add_immediate_ba_ssn;
Ben Cahill2054a002007-11-29 11:10:10 +08001143
Johannes Berg9bb487b2009-11-13 11:56:36 -08001144 /*
1145 * Number of packets OK to transmit to station even though
1146 * it is asleep -- used to synchronise PS-poll and u-APSD
1147 * responses while ucode keeps track of STA sleep state.
1148 */
1149 __le16 sleep_tx_count;
1150
1151 __le16 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001152} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001153
Tomas Winkler133636d2008-05-05 10:22:34 +08001154/* 5000 */
1155struct iwl_addsta_cmd {
1156 u8 mode; /* 1: modify existing, 0: add new station */
1157 u8 reserved[3];
1158 struct sta_id_modify sta;
1159 struct iwl_keyinfo key;
1160 __le32 station_flags; /* STA_FLG_* */
1161 __le32 station_flags_msk; /* STA_FLG_* */
1162
1163 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1164 * corresponding to bit (e.g. bit 5 controls TID 5).
1165 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1166 __le16 tid_disable_tx;
1167
Tomas Winklerc587de02009-06-03 11:44:07 -07001168 __le16 rate_n_flags; /* 3945 only */
Tomas Winkler133636d2008-05-05 10:22:34 +08001169
1170 /* TID for which to add block-ack support.
1171 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1172 u8 add_immediate_ba_tid;
1173
1174 /* TID for which to remove block-ack support.
1175 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1176 u8 remove_immediate_ba_tid;
1177
1178 /* Starting Sequence Number for added block-ack support.
1179 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1180 __le16 add_immediate_ba_ssn;
1181
Johannes Berg9bb487b2009-11-13 11:56:36 -08001182 /*
1183 * Number of packets OK to transmit to station even though
1184 * it is asleep -- used to synchronise PS-poll and u-APSD
1185 * responses while ucode keeps track of STA sleep state.
1186 */
1187 __le16 sleep_tx_count;
1188
1189 __le16 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001190} __packed;
Tomas Winkler133636d2008-05-05 10:22:34 +08001191
1192
Ben Cahill2054a002007-11-29 11:10:10 +08001193#define ADD_STA_SUCCESS_MSK 0x1
1194#define ADD_STA_NO_ROOM_IN_TABLE 0x2
1195#define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4
1196#define ADD_STA_MODIFY_NON_EXIST_STA 0x8
Zhu Yib481de92007-09-25 17:54:57 -07001197/*
1198 * REPLY_ADD_STA = 0x18 (response)
1199 */
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001200struct iwl_add_sta_resp {
Ben Cahill2054a002007-11-29 11:10:10 +08001201 u8 status; /* ADD_STA_* */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001202} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001203
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001204#define REM_STA_SUCCESS_MSK 0x1
1205/*
1206 * REPLY_REM_STA = 0x19 (response)
1207 */
1208struct iwl_rem_sta_resp {
1209 u8 status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001210} __packed;
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001211
1212/*
1213 * REPLY_REM_STA = 0x19 (command)
1214 */
1215struct iwl_rem_sta_cmd {
1216 u8 num_sta; /* number of removed stations */
1217 u8 reserved[3];
1218 u8 addr[ETH_ALEN]; /* MAC addr of the first station */
1219 u8 reserved2[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001220} __packed;
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001221
Wey-Yi Guy947279e2010-06-24 13:18:33 -07001222#define IWL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0))
1223#define IWL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1))
1224#define IWL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2))
1225#define IWL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3))
1226#define IWL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00)
1227
Wey-Yi Guy716c74b2010-06-24 13:22:36 -07001228#define IWL_DROP_SINGLE 0
1229#define IWL_DROP_SELECTED 1
1230#define IWL_DROP_ALL 2
1231
Wey-Yi Guy947279e2010-06-24 13:18:33 -07001232/*
1233 * REPLY_TXFIFO_FLUSH = 0x1e(command and response)
1234 *
1235 * When using full FIFO flush this command checks the scheduler HW block WR/RD
1236 * pointers to check if all the frames were transferred by DMA into the
1237 * relevant TX FIFO queue. Only when the DMA is finished and the queue is
1238 * empty the command can finish.
1239 * This command is used to flush the TXFIFO from transmit commands, it may
1240 * operate on single or multiple queues, the command queue can't be flushed by
1241 * this command. The command response is returned when all the queue flush
1242 * operations are done. Each TX command flushed return response with the FLUSH
1243 * status set in the TX response status. When FIFO flush operation is used,
1244 * the flush operation ends when both the scheduler DMA done and TXFIFO empty
1245 * are set.
1246 *
1247 * @fifo_control: bit mask for which queues to flush
1248 * @flush_control: flush controls
1249 * 0: Dump single MSDU
1250 * 1: Dump multiple MSDU according to PS, INVALID STA, TTL, TID disable.
1251 * 2: Dump all FIFO
1252 */
1253struct iwl_txfifo_flush_cmd {
1254 __le32 fifo_control;
1255 __le16 flush_control;
1256 __le16 reserved;
John W. Linville0e954092010-07-14 10:37:32 -04001257} __packed;
Wey-Yi Guy947279e2010-06-24 13:18:33 -07001258
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001259/*
1260 * REPLY_WEP_KEY = 0x20
1261 */
1262struct iwl_wep_key {
1263 u8 key_index;
1264 u8 key_offset;
1265 u8 reserved1[2];
1266 u8 key_size;
1267 u8 reserved2[3];
1268 u8 key[16];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001269} __packed;
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001270
1271struct iwl_wep_cmd {
1272 u8 num_keys;
1273 u8 global_key_type;
1274 u8 flags;
1275 u8 reserved;
1276 struct iwl_wep_key key[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001277} __packed;
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001278
1279#define WEP_KEY_WEP_TYPE 1
1280#define WEP_KEYS_MAX 4
1281#define WEP_INVALID_OFFSET 0xff
Emmanuel Grumbach4564ce82008-06-12 09:47:09 +08001282#define WEP_KEY_LEN_64 5
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001283#define WEP_KEY_LEN_128 13
Zhu Yib481de92007-09-25 17:54:57 -07001284
1285/******************************************************************************
1286 * (4)
1287 * Rx Responses:
1288 *
1289 *****************************************************************************/
1290
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001291#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0)
1292#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -07001293
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001294#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0)
1295#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1)
1296#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2)
1297#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3)
Reinette Chatre9024adf2009-10-02 13:43:57 -07001298#define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0
Daniel C Halperin9f30e042009-08-13 13:30:56 -07001299#define RX_RES_PHY_FLAGS_ANTENNA_POS 4
Zhu Yib481de92007-09-25 17:54:57 -07001300
Tomas Winkler8211ef72008-03-02 01:36:04 +02001301#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
1302#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
1303#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
1304#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
1305#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
Emmanuel Grumbach17e476b2008-03-19 16:41:42 -07001306#define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8)
1307
1308#define RX_RES_STATUS_STATION_FOUND (1<<6)
1309#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7)
Zhu Yib481de92007-09-25 17:54:57 -07001310
Tomas Winkler8211ef72008-03-02 01:36:04 +02001311#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
1312#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
1313#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
1314#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
1315#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
Zhu Yib481de92007-09-25 17:54:57 -07001316
Emmanuel Grumbach17e476b2008-03-19 16:41:42 -07001317#define RX_MPDU_RES_STATUS_ICV_OK (0x20)
1318#define RX_MPDU_RES_STATUS_MIC_OK (0x40)
1319#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7)
1320#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800)
1321
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001322
1323struct iwl3945_rx_frame_stats {
1324 u8 phy_count;
1325 u8 id;
1326 u8 rssi;
1327 u8 agc;
1328 __le16 sig_avg;
1329 __le16 noise_diff;
1330 u8 payload[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001331} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001332
1333struct iwl3945_rx_frame_hdr {
1334 __le16 channel;
1335 __le16 phy_flags;
1336 u8 reserved1;
1337 u8 rate;
1338 __le16 len;
1339 u8 payload[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001340} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001341
1342struct iwl3945_rx_frame_end {
1343 __le32 status;
1344 __le64 timestamp;
1345 __le32 beacon_timestamp;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001346} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001347
1348/*
1349 * REPLY_3945_RX = 0x1b (response only, not a command)
1350 *
1351 * NOTE: DO NOT dereference from casts to this structure
1352 * It is provided only for calculating minimum data set size.
1353 * The actual offsets of the hdr and end are dynamic based on
1354 * stats.phy_count
1355 */
1356struct iwl3945_rx_frame {
1357 struct iwl3945_rx_frame_stats stats;
1358 struct iwl3945_rx_frame_hdr hdr;
1359 struct iwl3945_rx_frame_end end;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001360} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001361
1362#define IWL39_RX_FRAME_SIZE (4 + sizeof(struct iwl3945_rx_frame))
1363
Zhu Yib481de92007-09-25 17:54:57 -07001364/* Fixed (non-configurable) rx data from phy */
Tomas Winklercaab8f12008-08-04 16:00:42 +08001365
1366#define IWL49_RX_RES_PHY_CNT 14
1367#define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
1368#define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
1369#define IWL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
1370#define IWL49_AGC_DB_POS (7)
Zhu Yib481de92007-09-25 17:54:57 -07001371struct iwl4965_rx_non_cfg_phy {
1372 __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
1373 __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
1374 u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
1375 u8 pad[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001376} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001377
Tomas Winklercaab8f12008-08-04 16:00:42 +08001378
Wey-Yi Guy7ccc8962010-08-04 08:42:17 -07001379#define IWLAGN_RX_RES_PHY_CNT 8
1380#define IWLAGN_RX_RES_AGC_IDX 1
1381#define IWLAGN_RX_RES_RSSI_AB_IDX 2
1382#define IWLAGN_RX_RES_RSSI_C_IDX 3
1383#define IWLAGN_OFDM_AGC_MSK 0xfe00
1384#define IWLAGN_OFDM_AGC_BIT_POS 9
1385#define IWLAGN_OFDM_RSSI_INBAND_A_BITMSK 0x00ff
1386#define IWLAGN_OFDM_RSSI_ALLBAND_A_BITMSK 0xff00
1387#define IWLAGN_OFDM_RSSI_A_BIT_POS 0
1388#define IWLAGN_OFDM_RSSI_INBAND_B_BITMSK 0xff0000
1389#define IWLAGN_OFDM_RSSI_ALLBAND_B_BITMSK 0xff000000
1390#define IWLAGN_OFDM_RSSI_B_BIT_POS 16
1391#define IWLAGN_OFDM_RSSI_INBAND_C_BITMSK 0x00ff
1392#define IWLAGN_OFDM_RSSI_ALLBAND_C_BITMSK 0xff00
1393#define IWLAGN_OFDM_RSSI_C_BIT_POS 0
Tomas Winklercaab8f12008-08-04 16:00:42 +08001394
Wey-Yi Guy7ccc8962010-08-04 08:42:17 -07001395struct iwlagn_non_cfg_phy {
1396 __le32 non_cfg_phy[IWLAGN_RX_RES_PHY_CNT]; /* up to 8 phy entries */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001397} __packed;
Tomas Winklercaab8f12008-08-04 16:00:42 +08001398
1399
Zhu Yib481de92007-09-25 17:54:57 -07001400/*
Tomas Winkler857485c2008-03-21 13:53:44 -07001401 * REPLY_RX = 0xc3 (response only, not a command)
Zhu Yib481de92007-09-25 17:54:57 -07001402 * Used only for legacy (non 11n) frames.
1403 */
Tomas Winklercaab8f12008-08-04 16:00:42 +08001404struct iwl_rx_phy_res {
Zhu Yib481de92007-09-25 17:54:57 -07001405 u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
1406 u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
1407 u8 stat_id; /* configurable DSP phy data set ID */
1408 u8 reserved1;
1409 __le64 timestamp; /* TSF at on air rise */
1410 __le32 beacon_time_stamp; /* beacon at on-air rise */
1411 __le16 phy_flags; /* general phy flags: band, modulation, ... */
1412 __le16 channel; /* channel number */
Tomas Winklercaab8f12008-08-04 16:00:42 +08001413 u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
Ben Cahill52969982007-11-29 11:10:11 +08001414 __le32 rate_n_flags; /* RATE_MCS_* */
1415 __le16 byte_count; /* frame's byte-count */
Wey-Yi Guy30c1b0f2010-08-04 08:05:33 -07001416 __le16 frame_time; /* frame's time on the air */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001417} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001418
Emmanuel Grumbach2fb291e2010-06-07 13:21:47 -07001419struct iwl_rx_mpdu_res_start {
Zhu Yib481de92007-09-25 17:54:57 -07001420 __le16 byte_count;
1421 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001422} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001423
1424
1425/******************************************************************************
1426 * (5)
1427 * Tx Commands & Responses:
1428 *
Ben Cahill52969982007-11-29 11:10:11 +08001429 * Driver must place each REPLY_TX command into one of the prioritized Tx
1430 * queues in host DRAM, shared between driver and device (see comments for
1431 * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode
1432 * are preparing to transmit, the device pulls the Tx command over the PCI
1433 * bus via one of the device's Tx DMA channels, to fill an internal FIFO
1434 * from which data will be transmitted.
1435 *
1436 * uCode handles all timing and protocol related to control frames
1437 * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler
1438 * handle reception of block-acks; uCode updates the host driver via
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001439 * REPLY_COMPRESSED_BA.
Ben Cahill52969982007-11-29 11:10:11 +08001440 *
1441 * uCode handles retrying Tx when an ACK is expected but not received.
1442 * This includes trying lower data rates than the one requested in the Tx
1443 * command, as set up by the REPLY_RATE_SCALE (for 3945) or
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001444 * REPLY_TX_LINK_QUALITY_CMD (agn).
Ben Cahill52969982007-11-29 11:10:11 +08001445 *
1446 * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
1447 * This command must be executed after every RXON command, before Tx can occur.
Zhu Yib481de92007-09-25 17:54:57 -07001448 *****************************************************************************/
1449
Ben Cahill52969982007-11-29 11:10:11 +08001450/* REPLY_TX Tx flags field */
1451
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001452/*
1453 * 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
Emmanuel Grumbacha326a5d2008-07-11 11:53:31 +08001454 * before this frame. if CTS-to-self required check
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001455 * RXON_FLG_SELF_CTS_EN status.
1456 * unused in 3945/4965, used in 5000 series and after
1457 */
1458#define TX_CMD_FLG_PROT_REQUIRE_MSK cpu_to_le32(1 << 0)
Emmanuel Grumbacha326a5d2008-07-11 11:53:31 +08001459
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001460/*
1461 * 1: Use Request-To-Send protocol before this frame.
1462 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK.
1463 * used in 3945/4965, unused in 5000 series and after
1464 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001465#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
Ben Cahill52969982007-11-29 11:10:11 +08001466
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001467/*
1468 * 1: Transmit Clear-To-Send to self before this frame.
Ben Cahill52969982007-11-29 11:10:11 +08001469 * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001470 * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK.
1471 * used in 3945/4965, unused in 5000 series and after
1472 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001473#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
Ben Cahill52969982007-11-29 11:10:11 +08001474
1475/* 1: Expect ACK from receiving station
1476 * 0: Don't expect ACK (MAC header's duration field s/b 0)
1477 * Set this for unicast frames, but not broadcast/multicast. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001478#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
Ben Cahill52969982007-11-29 11:10:11 +08001479
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001480/* For agn devices:
Ben Cahill52969982007-11-29 11:10:11 +08001481 * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
1482 * Tx command's initial_rate_index indicates first rate to try;
1483 * uCode walks through table for additional Tx attempts.
1484 * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
1485 * This rate will be used for all Tx attempts; it will not be scaled. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001486#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
Ben Cahill52969982007-11-29 11:10:11 +08001487
1488/* 1: Expect immediate block-ack.
1489 * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001490#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6)
Ben Cahill52969982007-11-29 11:10:11 +08001491
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001492/*
1493 * 1: Frame requires full Tx-Op protection.
1494 * Set this if either RTS or CTS Tx Flag gets set.
1495 * used in 3945/4965, unused in 5000 series and after
1496 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001497#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
Ben Cahill52969982007-11-29 11:10:11 +08001498
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001499/* Tx antenna selection field; used only for 3945, reserved (0) for agn devices.
Ben Cahill52969982007-11-29 11:10:11 +08001500 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001501#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
1502#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
1503#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
Zhu Yib481de92007-09-25 17:54:57 -07001504
Ben Cahill52969982007-11-29 11:10:11 +08001505/* 1: Ignore Bluetooth priority for this frame.
1506 * 0: Delay Tx until Bluetooth device is done (normal usage). */
Johannes Bergb2e86902010-04-13 01:04:32 -07001507#define TX_CMD_FLG_IGNORE_BT cpu_to_le32(1 << 12)
Zhu Yib481de92007-09-25 17:54:57 -07001508
Ben Cahill52969982007-11-29 11:10:11 +08001509/* 1: uCode overrides sequence control field in MAC header.
1510 * 0: Driver provides sequence control field in MAC header.
1511 * Set this for management frames, non-QOS data frames, non-unicast frames,
1512 * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001513#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
Zhu Yib481de92007-09-25 17:54:57 -07001514
Ben Cahill52969982007-11-29 11:10:11 +08001515/* 1: This frame is non-last MPDU; more fragments are coming.
1516 * 0: Last fragment, or not using fragmentation. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001517#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
Zhu Yib481de92007-09-25 17:54:57 -07001518
Ben Cahill52969982007-11-29 11:10:11 +08001519/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
1520 * 0: No TSF required in outgoing frame.
1521 * Set this for transmitting beacons and probe responses. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001522#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
Zhu Yib481de92007-09-25 17:54:57 -07001523
Ben Cahill52969982007-11-29 11:10:11 +08001524/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
1525 * alignment of frame's payload data field.
1526 * 0: No pad
1527 * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
1528 * field (but not both). Driver must align frame data (i.e. data following
1529 * MAC header) to DWORD boundary. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001530#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
Zhu Yib481de92007-09-25 17:54:57 -07001531
Max Stepanov8236e182008-03-12 16:58:48 -07001532/* accelerate aggregation support
1533 * 0 - no CCMP encryption; 1 - CCMP encryption */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001534#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
Max Stepanov8236e182008-03-12 16:58:48 -07001535
Zhu Yib481de92007-09-25 17:54:57 -07001536/* HCCA-AP - disable duration overwriting. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001537#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
Zhu Yib481de92007-09-25 17:54:57 -07001538
Ben Cahill52969982007-11-29 11:10:11 +08001539
Zhu Yib481de92007-09-25 17:54:57 -07001540/*
1541 * TX command security control
1542 */
1543#define TX_CMD_SEC_WEP 0x01
1544#define TX_CMD_SEC_CCM 0x02
1545#define TX_CMD_SEC_TKIP 0x03
1546#define TX_CMD_SEC_MSK 0x03
1547#define TX_CMD_SEC_SHIFT 6
1548#define TX_CMD_SEC_KEY128 0x08
1549
1550/*
Tomas Winkler3195cdb2008-04-23 17:15:00 -07001551 * security overhead sizes
1552 */
1553#define WEP_IV_LEN 4
1554#define WEP_ICV_LEN 4
1555#define CCMP_MIC_LEN 8
1556#define TKIP_ICV_LEN 4
1557
1558/*
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001559 * REPLY_TX = 0x1c (command)
1560 */
1561
1562struct iwl3945_tx_cmd {
1563 /*
1564 * MPDU byte count:
1565 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1566 * + 8 byte IV for CCM or TKIP (not used for WEP)
1567 * + Data payload
1568 * + 8-byte MIC (not used for CCM/WEP)
1569 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1570 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1571 * Range: 14-2342 bytes.
1572 */
1573 __le16 len;
1574
1575 /*
1576 * MPDU or MSDU byte count for next frame.
1577 * Used for fragmentation and bursting, but not 11n aggregation.
1578 * Same as "len", but for next frame. Set to 0 if not applicable.
1579 */
1580 __le16 next_frame_len;
1581
1582 __le32 tx_flags; /* TX_CMD_FLG_* */
1583
1584 u8 rate;
1585
1586 /* Index of recipient station in uCode's station table */
1587 u8 sta_id;
1588 u8 tid_tspec;
1589 u8 sec_ctl;
1590 u8 key[16];
1591 union {
1592 u8 byte[8];
1593 __le16 word[4];
1594 __le32 dw[2];
1595 } tkip_mic;
1596 __le32 next_frame_info;
1597 union {
1598 __le32 life_time;
1599 __le32 attempt;
1600 } stop_time;
1601 u8 supp_rates[2];
1602 u8 rts_retry_limit; /*byte 50 */
1603 u8 data_retry_limit; /*byte 51 */
1604 union {
1605 __le16 pm_frame_timeout;
1606 __le16 attempt_duration;
1607 } timeout;
1608
1609 /*
1610 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1611 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1612 */
1613 __le16 driver_txop;
1614
1615 /*
1616 * MAC header goes here, followed by 2 bytes padding if MAC header
1617 * length is 26 or 30 bytes, followed by payload data
1618 */
1619 u8 payload[0];
1620 struct ieee80211_hdr hdr[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001621} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001622
1623/*
1624 * REPLY_TX = 0x1c (response)
1625 */
1626struct iwl3945_tx_resp {
1627 u8 failure_rts;
1628 u8 failure_frame;
1629 u8 bt_kill_count;
1630 u8 rate;
1631 __le32 wireless_media_time;
1632 __le32 status; /* TX status */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001633} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001634
1635
1636/*
Ben Cahill52969982007-11-29 11:10:11 +08001637 * 4965 uCode updates these Tx attempt count values in host DRAM.
1638 * Used for managing Tx retries when expecting block-acks.
1639 * Driver should set these fields to 0.
Zhu Yib481de92007-09-25 17:54:57 -07001640 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001641struct iwl_dram_scratch {
Ben Cahill52969982007-11-29 11:10:11 +08001642 u8 try_cnt; /* Tx attempts */
1643 u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */
Zhu Yib481de92007-09-25 17:54:57 -07001644 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001645} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001646
Tomas Winkler83d527d2008-05-15 13:54:05 +08001647struct iwl_tx_cmd {
Ben Cahill52969982007-11-29 11:10:11 +08001648 /*
1649 * MPDU byte count:
1650 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1651 * + 8 byte IV for CCM or TKIP (not used for WEP)
1652 * + Data payload
1653 * + 8-byte MIC (not used for CCM/WEP)
1654 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1655 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1656 * Range: 14-2342 bytes.
1657 */
Zhu Yib481de92007-09-25 17:54:57 -07001658 __le16 len;
Ben Cahill52969982007-11-29 11:10:11 +08001659
1660 /*
1661 * MPDU or MSDU byte count for next frame.
1662 * Used for fragmentation and bursting, but not 11n aggregation.
1663 * Same as "len", but for next frame. Set to 0 if not applicable.
1664 */
Zhu Yib481de92007-09-25 17:54:57 -07001665 __le16 next_frame_len;
Ben Cahill52969982007-11-29 11:10:11 +08001666
1667 __le32 tx_flags; /* TX_CMD_FLG_* */
1668
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001669 /* uCode may modify this field of the Tx command (in host DRAM!).
Ben Cahill52969982007-11-29 11:10:11 +08001670 * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001671 struct iwl_dram_scratch scratch;
Ben Cahill52969982007-11-29 11:10:11 +08001672
1673 /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
1674 __le32 rate_n_flags; /* RATE_MCS_* */
1675
1676 /* Index of destination station in uCode's station table */
Zhu Yib481de92007-09-25 17:54:57 -07001677 u8 sta_id;
Ben Cahill52969982007-11-29 11:10:11 +08001678
1679 /* Type of security encryption: CCM or TKIP */
1680 u8 sec_ctl; /* TX_CMD_SEC_* */
1681
1682 /*
1683 * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
1684 * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for
1685 * data frames, this field may be used to selectively reduce initial
1686 * rate (via non-0 value) for special frames (e.g. management), while
1687 * still supporting rate scaling for all frames.
1688 */
Zhu Yib481de92007-09-25 17:54:57 -07001689 u8 initial_rate_index;
1690 u8 reserved;
Zhu Yib481de92007-09-25 17:54:57 -07001691 u8 key[16];
Zhu Yib481de92007-09-25 17:54:57 -07001692 __le16 next_frame_flags;
1693 __le16 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -07001694 union {
1695 __le32 life_time;
1696 __le32 attempt;
1697 } stop_time;
Ben Cahill52969982007-11-29 11:10:11 +08001698
1699 /* Host DRAM physical address pointer to "scratch" in this command.
1700 * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */
Zhu Yib481de92007-09-25 17:54:57 -07001701 __le32 dram_lsb_ptr;
1702 u8 dram_msb_ptr;
Ben Cahill52969982007-11-29 11:10:11 +08001703
Zhu Yib481de92007-09-25 17:54:57 -07001704 u8 rts_retry_limit; /*byte 50 */
1705 u8 data_retry_limit; /*byte 51 */
Zhu Yib481de92007-09-25 17:54:57 -07001706 u8 tid_tspec;
Zhu Yib481de92007-09-25 17:54:57 -07001707 union {
1708 __le16 pm_frame_timeout;
1709 __le16 attempt_duration;
1710 } timeout;
Ben Cahill52969982007-11-29 11:10:11 +08001711
1712 /*
1713 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1714 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1715 */
Zhu Yib481de92007-09-25 17:54:57 -07001716 __le16 driver_txop;
Ben Cahill52969982007-11-29 11:10:11 +08001717
1718 /*
1719 * MAC header goes here, followed by 2 bytes padding if MAC header
1720 * length is 26 or 30 bytes, followed by payload data
1721 */
Zhu Yib481de92007-09-25 17:54:57 -07001722 u8 payload[0];
1723 struct ieee80211_hdr hdr[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001724} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001725
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001726/* TX command response is sent after *3945* transmission attempts.
Zhu Yib481de92007-09-25 17:54:57 -07001727 *
1728 * NOTES:
1729 *
1730 * TX_STATUS_FAIL_NEXT_FRAG
1731 *
1732 * If the fragment flag in the MAC header for the frame being transmitted
1733 * is set and there is insufficient time to transmit the next frame, the
1734 * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
1735 *
1736 * TX_STATUS_FIFO_UNDERRUN
1737 *
1738 * Indicates the host did not provide bytes to the FIFO fast enough while
1739 * a TX was in progress.
1740 *
1741 * TX_STATUS_FAIL_MGMNT_ABORT
1742 *
1743 * This status is only possible if the ABORT ON MGMT RX parameter was
1744 * set to true with the TX command.
1745 *
1746 * If the MSB of the status parameter is set then an abort sequence is
1747 * required. This sequence consists of the host activating the TX Abort
1748 * control line, and then waiting for the TX Abort command response. This
1749 * indicates that a the device is no longer in a transmit state, and that the
1750 * command FIFO has been cleared. The host must then deactivate the TX Abort
1751 * control line. Receiving is still allowed in this case.
1752 */
1753enum {
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001754 TX_3945_STATUS_SUCCESS = 0x01,
1755 TX_3945_STATUS_DIRECT_DONE = 0x02,
1756 TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82,
1757 TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83,
1758 TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1759 TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85,
1760 TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86,
1761 TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1762 TX_3945_STATUS_FAIL_DEST_PS = 0x88,
1763 TX_3945_STATUS_FAIL_ABORTED = 0x89,
1764 TX_3945_STATUS_FAIL_BT_RETRY = 0x8a,
1765 TX_3945_STATUS_FAIL_STA_INVALID = 0x8b,
1766 TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1767 TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d,
1768 TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
1769 TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1770 TX_3945_STATUS_FAIL_TX_LOCKED = 0x90,
1771 TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1772};
1773
1774/*
1775 * TX command response is sent after *agn* transmission attempts.
1776 *
1777 * both postpone and abort status are expected behavior from uCode. there is
1778 * no special operation required from driver; except for RFKILL_FLUSH,
1779 * which required tx flush host command to flush all the tx frames in queues
1780 */
1781enum {
Zhu Yib481de92007-09-25 17:54:57 -07001782 TX_STATUS_SUCCESS = 0x01,
1783 TX_STATUS_DIRECT_DONE = 0x02,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001784 /* postpone TX */
1785 TX_STATUS_POSTPONE_DELAY = 0x40,
1786 TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
1787 TX_STATUS_POSTPONE_BT_PRIO = 0x42,
1788 TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
1789 TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
1790 /* abort TX */
1791 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
Zhu Yib481de92007-09-25 17:54:57 -07001792 TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
1793 TX_STATUS_FAIL_LONG_LIMIT = 0x83,
1794 TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001795 TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
1796 TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
Zhu Yib481de92007-09-25 17:54:57 -07001797 TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1798 TX_STATUS_FAIL_DEST_PS = 0x88,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001799 TX_STATUS_FAIL_HOST_ABORTED = 0x89,
Zhu Yib481de92007-09-25 17:54:57 -07001800 TX_STATUS_FAIL_BT_RETRY = 0x8a,
1801 TX_STATUS_FAIL_STA_INVALID = 0x8b,
1802 TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1803 TX_STATUS_FAIL_TID_DISABLE = 0x8d,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001804 TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
Zhu Yib481de92007-09-25 17:54:57 -07001805 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001806 /* uCode drop due to FW drop request */
1807 TX_STATUS_FAIL_FW_DROP = 0x90,
1808 /*
1809 * uCode drop due to station color mismatch
1810 * between tx command and station table
1811 */
1812 TX_STATUS_FAIL_STA_COLOR_MISMATCH_DROP = 0x91,
Zhu Yib481de92007-09-25 17:54:57 -07001813};
1814
1815#define TX_PACKET_MODE_REGULAR 0x0000
1816#define TX_PACKET_MODE_BURST_SEQ 0x0100
1817#define TX_PACKET_MODE_BURST_FIRST 0x0200
1818
1819enum {
1820 TX_POWER_PA_NOT_ACTIVE = 0x0,
1821};
1822
1823enum {
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001824 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
Zhu Yib481de92007-09-25 17:54:57 -07001825 TX_STATUS_DELAY_MSK = 0x00000040,
1826 TX_STATUS_ABORT_MSK = 0x00000080,
1827 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
1828 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001829 TX_RESERVED = 0x00780000, /* bits 19:22 */
Zhu Yib481de92007-09-25 17:54:57 -07001830 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
1831 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
1832};
1833
1834/* *******************************
Ben Cahill52969982007-11-29 11:10:11 +08001835 * TX aggregation status
Zhu Yib481de92007-09-25 17:54:57 -07001836 ******************************* */
1837
1838enum {
1839 AGG_TX_STATE_TRANSMITTED = 0x00,
1840 AGG_TX_STATE_UNDERRUN_MSK = 0x01,
1841 AGG_TX_STATE_BT_PRIO_MSK = 0x02,
1842 AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1843 AGG_TX_STATE_ABORT_MSK = 0x08,
1844 AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1845 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1846 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
1847 AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1848 AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1849 AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1850 AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1851 AGG_TX_STATE_DELAY_TX_MSK = 0x400
1852};
1853
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001854#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
1855 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
1856 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
Zhu Yib481de92007-09-25 17:54:57 -07001857
Ben Cahill52969982007-11-29 11:10:11 +08001858/* # tx attempts for first frame in aggregation */
Zhu Yib481de92007-09-25 17:54:57 -07001859#define AGG_TX_STATE_TRY_CNT_POS 12
1860#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1861
Ben Cahill52969982007-11-29 11:10:11 +08001862/* Command ID and sequence number of Tx command for this frame */
Zhu Yib481de92007-09-25 17:54:57 -07001863#define AGG_TX_STATE_SEQ_NUM_POS 16
1864#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1865
1866/*
1867 * REPLY_TX = 0x1c (response)
Ben Cahill52969982007-11-29 11:10:11 +08001868 *
1869 * This response may be in one of two slightly different formats, indicated
1870 * by the frame_count field:
1871 *
1872 * 1) No aggregation (frame_count == 1). This reports Tx results for
1873 * a single frame. Multiple attempts, at various bit rates, may have
1874 * been made for this frame.
1875 *
1876 * 2) Aggregation (frame_count > 1). This reports Tx results for
1877 * 2 or more frames that used block-acknowledge. All frames were
1878 * transmitted at same rate. Rate scaling may have been used if first
1879 * frame in this new agg block failed in previous agg block(s).
1880 *
1881 * Note that, for aggregation, ACK (block-ack) status is not delivered here;
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001882 * block-ack has not been received by the time the agn device records
1883 * this status.
Ben Cahill52969982007-11-29 11:10:11 +08001884 * This status relates to reasons the tx might have been blocked or aborted
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001885 * within the sending station (this agn device), rather than whether it was
Ben Cahill52969982007-11-29 11:10:11 +08001886 * received successfully by the destination station.
Zhu Yib481de92007-09-25 17:54:57 -07001887 */
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001888struct agg_tx_status {
1889 __le16 status;
1890 __le16 sequence;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001891} __packed;
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001892
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001893struct iwl4965_tx_resp {
Zhu Yib481de92007-09-25 17:54:57 -07001894 u8 frame_count; /* 1 no aggregation, >1 aggregation */
Ben Cahill52969982007-11-29 11:10:11 +08001895 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
1896 u8 failure_rts; /* # failures due to unsuccessful RTS */
1897 u8 failure_frame; /* # failures due to no ACK (unused for agg) */
1898
1899 /* For non-agg: Rate at which frame was successful.
1900 * For agg: Rate at which all frames were transmitted. */
1901 __le32 rate_n_flags; /* RATE_MCS_* */
1902
1903 /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
1904 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1905 __le16 wireless_media_time; /* uSecs */
1906
Zhu Yib481de92007-09-25 17:54:57 -07001907 __le16 reserved;
Ben Cahill52969982007-11-29 11:10:11 +08001908 __le32 pa_power1; /* RF power amplifier measurement (not used) */
Zhu Yib481de92007-09-25 17:54:57 -07001909 __le32 pa_power2;
Ben Cahill52969982007-11-29 11:10:11 +08001910
1911 /*
1912 * For non-agg: frame status TX_STATUS_*
1913 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
1914 * fields follow this one, up to frame_count.
1915 * Bit fields:
1916 * 11- 0: AGG_TX_STATE_* status code
1917 * 15-12: Retry count for 1st frame in aggregation (retries
1918 * occur if tx failed for this frame when it was a
1919 * member of a previous aggregation block). If rate
1920 * scaling is used, retry count indicates the rate
1921 * table entry used for all frames in the new agg.
1922 * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
1923 */
Tomas Winkler25a65722008-06-12 09:47:07 +08001924 union {
1925 __le32 status;
1926 struct agg_tx_status agg_status[0]; /* for each agg frame */
1927 } u;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001928} __packed;
Ron Rindjunskyfe01b472008-01-28 14:07:24 +02001929
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001930/*
1931 * definitions for initial rate index field
Tomas Winklera96a27f2008-10-23 23:48:56 -07001932 * bits [3:0] initial rate index
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001933 * bits [6:4] rate table color, used for the initial rate
1934 * bit-7 invalid rate indication
1935 * i.e. rate was not chosen from rate table
1936 * or rate table color was changed during frame retries
1937 * refer tlc rate info
1938 */
1939
1940#define IWL50_TX_RES_INIT_RATE_INDEX_POS 0
1941#define IWL50_TX_RES_INIT_RATE_INDEX_MSK 0x0f
1942#define IWL50_TX_RES_RATE_TABLE_COLOR_POS 4
1943#define IWL50_TX_RES_RATE_TABLE_COLOR_MSK 0x70
1944#define IWL50_TX_RES_INV_RATE_INDEX_MSK 0x80
1945
1946/* refer to ra_tid */
1947#define IWL50_TX_RES_TID_POS 0
1948#define IWL50_TX_RES_TID_MSK 0x0f
1949#define IWL50_TX_RES_RA_POS 4
1950#define IWL50_TX_RES_RA_MSK 0xf0
1951
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001952struct iwl5000_tx_resp {
1953 u8 frame_count; /* 1 no aggregation, >1 aggregation */
1954 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
1955 u8 failure_rts; /* # failures due to unsuccessful RTS */
1956 u8 failure_frame; /* # failures due to no ACK (unused for agg) */
1957
1958 /* For non-agg: Rate at which frame was successful.
1959 * For agg: Rate at which all frames were transmitted. */
1960 __le32 rate_n_flags; /* RATE_MCS_* */
1961
1962 /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
1963 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1964 __le16 wireless_media_time; /* uSecs */
1965
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001966 u8 pa_status; /* RF power amplifier measurement (not used) */
1967 u8 pa_integ_res_a[3];
1968 u8 pa_integ_res_b[3];
1969 u8 pa_integ_res_C[3];
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001970
1971 __le32 tfd_info;
1972 __le16 seq_ctl;
1973 __le16 byte_cnt;
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001974 u8 tlc_info;
1975 u8 ra_tid; /* tid (0:3), sta_id (4:7) */
1976 __le16 frame_ctrl;
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001977 /*
1978 * For non-agg: frame status TX_STATUS_*
1979 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
1980 * fields follow this one, up to frame_count.
1981 * Bit fields:
1982 * 11- 0: AGG_TX_STATE_* status code
1983 * 15-12: Retry count for 1st frame in aggregation (retries
1984 * occur if tx failed for this frame when it was a
1985 * member of a previous aggregation block). If rate
1986 * scaling is used, retry count indicates the rate
1987 * table entry used for all frames in the new agg.
1988 * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
1989 */
1990 struct agg_tx_status status; /* TX status (in aggregation -
1991 * status of 1st frame) */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001992} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001993/*
1994 * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
Ben Cahill52969982007-11-29 11:10:11 +08001995 *
1996 * Reports Block-Acknowledge from recipient station
Zhu Yib481de92007-09-25 17:54:57 -07001997 */
Emmanuel Grumbach653fa4a2008-06-30 17:23:11 +08001998struct iwl_compressed_ba_resp {
Zhu Yib481de92007-09-25 17:54:57 -07001999 __le32 sta_addr_lo32;
2000 __le16 sta_addr_hi16;
2001 __le16 reserved;
Ben Cahill52969982007-11-29 11:10:11 +08002002
2003 /* Index of recipient (BA-sending) station in uCode's station table */
Zhu Yib481de92007-09-25 17:54:57 -07002004 u8 sta_id;
2005 u8 tid;
Ron Rindjunskyfe01b472008-01-28 14:07:24 +02002006 __le16 seq_ctl;
2007 __le64 bitmap;
Zhu Yib481de92007-09-25 17:54:57 -07002008 __le16 scd_flow;
2009 __le16 scd_ssn;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002010} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002011
2012/*
2013 * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
Ben Cahill2bdc7032007-11-29 11:10:12 +08002014 *
2015 * See details under "TXPOWER" in iwl-4965-hw.h.
Zhu Yib481de92007-09-25 17:54:57 -07002016 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002017
2018struct iwl3945_txpowertable_cmd {
2019 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
2020 u8 reserved;
2021 __le16 channel;
2022 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002023} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002024
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002025struct iwl4965_txpowertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002026 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
2027 u8 reserved;
2028 __le16 channel;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002029 struct iwl4965_tx_power_db tx_power;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002030} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002031
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002032
2033/**
2034 * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response
2035 *
2036 * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
2037 *
2038 * NOTE: The table of rates passed to the uCode via the
2039 * RATE_SCALE command sets up the corresponding order of
2040 * rates used for all related commands, including rate
2041 * masks, etc.
2042 *
2043 * For example, if you set 9MB (PLCP 0x0f) as the first
2044 * rate in the rate table, the bit mask for that rate
2045 * when passed through ofdm_basic_rates on the REPLY_RXON
2046 * command would be bit 0 (1 << 0)
2047 */
2048struct iwl3945_rate_scaling_info {
2049 __le16 rate_n_flags;
2050 u8 try_cnt;
2051 u8 next_rate_index;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002052} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002053
2054struct iwl3945_rate_scaling_cmd {
2055 u8 table_id;
2056 u8 reserved[3];
2057 struct iwl3945_rate_scaling_info table[IWL_MAX_RATES];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002058} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002059
2060
Zhu Yib481de92007-09-25 17:54:57 -07002061/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
Reinette Chatre8a1b0242008-01-14 17:46:25 -08002062#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0)
Zhu Yib481de92007-09-25 17:54:57 -07002063
Ben Cahill2bdc7032007-11-29 11:10:12 +08002064/* # of EDCA prioritized tx fifos */
Zhu Yib481de92007-09-25 17:54:57 -07002065#define LINK_QUAL_AC_NUM AC_NUM
Ben Cahill2bdc7032007-11-29 11:10:12 +08002066
2067/* # entries in rate scale table to support Tx retries */
Zhu Yib481de92007-09-25 17:54:57 -07002068#define LINK_QUAL_MAX_RETRY_NUM 16
2069
Ben Cahill2bdc7032007-11-29 11:10:12 +08002070/* Tx antenna selection values */
Reinette Chatre8a1b0242008-01-14 17:46:25 -08002071#define LINK_QUAL_ANT_A_MSK (1 << 0)
2072#define LINK_QUAL_ANT_B_MSK (1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -07002073#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
2074
Ben Cahill2bdc7032007-11-29 11:10:12 +08002075
2076/**
Tomas Winkler66c73db2008-04-15 16:01:40 -07002077 * struct iwl_link_qual_general_params
Ben Cahill2bdc7032007-11-29 11:10:12 +08002078 *
2079 * Used in REPLY_TX_LINK_QUALITY_CMD
2080 */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002081struct iwl_link_qual_general_params {
Zhu Yib481de92007-09-25 17:54:57 -07002082 u8 flags;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002083
2084 /* No entries at or above this (driver chosen) index contain MIMO */
Zhu Yib481de92007-09-25 17:54:57 -07002085 u8 mimo_delimiter;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002086
2087 /* Best single antenna to use for single stream (legacy, SISO). */
2088 u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */
2089
2090 /* Best antennas to use for MIMO (unused for 4965, assumes both). */
2091 u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */
2092
2093 /*
2094 * If driver needs to use different initial rates for different
2095 * EDCA QOS access categories (as implemented by tx fifos 0-3),
2096 * this table will set that up, by indicating the indexes in the
2097 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
2098 * Otherwise, driver should set all entries to 0.
2099 *
2100 * Entry usage:
2101 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
2102 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
2103 */
Zhu Yib481de92007-09-25 17:54:57 -07002104 u8 start_rate_index[LINK_QUAL_AC_NUM];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002105} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002106
Wey-Yi Guy13c33a02009-06-03 11:44:11 -07002107#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */
Wey-Yi Guyb15826a2010-07-28 09:18:53 -07002108#define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000)
2109#define LINK_QUAL_AGG_TIME_LIMIT_MIN (100)
Wey-Yi Guy13c33a02009-06-03 11:44:11 -07002110
2111#define LINK_QUAL_AGG_DISABLE_START_DEF (3)
2112#define LINK_QUAL_AGG_DISABLE_START_MAX (255)
2113#define LINK_QUAL_AGG_DISABLE_START_MIN (0)
2114
2115#define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31)
Johannes Bergb623a9f2009-07-01 14:57:59 +02002116#define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63)
Wey-Yi Guy13c33a02009-06-03 11:44:11 -07002117#define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0)
2118
Ben Cahill2bdc7032007-11-29 11:10:12 +08002119/**
Tomas Winkler66c73db2008-04-15 16:01:40 -07002120 * struct iwl_link_qual_agg_params
Ben Cahill2bdc7032007-11-29 11:10:12 +08002121 *
2122 * Used in REPLY_TX_LINK_QUALITY_CMD
2123 */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002124struct iwl_link_qual_agg_params {
Ben Cahill2bdc7032007-11-29 11:10:12 +08002125
Wey-Yi Guy74697012010-07-28 09:18:54 -07002126 /*
2127 *Maximum number of uSec in aggregation.
2128 * default set to 4000 (4 milliseconds) if not configured in .cfg
2129 */
Zhu Yib481de92007-09-25 17:54:57 -07002130 __le16 agg_time_limit;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002131
2132 /*
2133 * Number of Tx retries allowed for a frame, before that frame will
2134 * no longer be considered for the start of an aggregation sequence
2135 * (scheduler will then try to tx it as single frame).
2136 * Driver should set this to 3.
2137 */
Zhu Yib481de92007-09-25 17:54:57 -07002138 u8 agg_dis_start_th;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002139
2140 /*
2141 * Maximum number of frames in aggregation.
2142 * 0 = no limit (default). 1 = no aggregation.
2143 * Other values = max # frames in aggregation.
2144 */
Zhu Yib481de92007-09-25 17:54:57 -07002145 u8 agg_frame_cnt_limit;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002146
Zhu Yib481de92007-09-25 17:54:57 -07002147 __le32 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002148} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002149
2150/*
2151 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
Ben Cahill2bdc7032007-11-29 11:10:12 +08002152 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002153 * For agn devices only; 3945 uses REPLY_RATE_SCALE.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002154 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002155 * Each station in the agn device's internal station table has its own table
2156 * of 16
Ben Cahill2bdc7032007-11-29 11:10:12 +08002157 * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
2158 * an ACK is not received. This command replaces the entire table for
2159 * one station.
2160 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002161 * NOTE: Station must already be in agn device's station table.
2162 * Use REPLY_ADD_STA.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002163 *
2164 * The rate scaling procedures described below work well. Of course, other
2165 * procedures are possible, and may work better for particular environments.
2166 *
2167 *
2168 * FILLING THE RATE TABLE
2169 *
2170 * Given a particular initial rate and mode, as determined by the rate
2171 * scaling algorithm described below, the Linux driver uses the following
2172 * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
2173 * Link Quality command:
2174 *
2175 *
2176 * 1) If using High-throughput (HT) (SISO or MIMO) initial rate:
2177 * a) Use this same initial rate for first 3 entries.
2178 * b) Find next lower available rate using same mode (SISO or MIMO),
2179 * use for next 3 entries. If no lower rate available, switch to
Wey-Yi Guy7aafef12009-08-07 15:41:38 -07002180 * legacy mode (no HT40 channel, no MIMO, no short guard interval).
Ben Cahill2bdc7032007-11-29 11:10:12 +08002181 * c) If using MIMO, set command's mimo_delimiter to number of entries
2182 * using MIMO (3 or 6).
Wey-Yi Guy7aafef12009-08-07 15:41:38 -07002183 * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
Ben Cahill2bdc7032007-11-29 11:10:12 +08002184 * no MIMO, no short guard interval), at the next lower bit rate
2185 * (e.g. if second HT bit rate was 54, try 48 legacy), and follow
2186 * legacy procedure for remaining table entries.
2187 *
2188 * 2) If using legacy initial rate:
2189 * a) Use the initial rate for only one entry.
2190 * b) For each following entry, reduce the rate to next lower available
2191 * rate, until reaching the lowest available rate.
2192 * c) When reducing rate, also switch antenna selection.
2193 * d) Once lowest available rate is reached, repeat this rate until
2194 * rate table is filled (16 entries), switching antenna each entry.
2195 *
2196 *
2197 * ACCUMULATING HISTORY
2198 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002199 * The rate scaling algorithm for agn devices, as implemented in Linux driver,
2200 * uses two sets of frame Tx success history: One for the current/active
2201 * modulation mode, and one for a speculative/search mode that is being
2202 * attempted. If the speculative mode turns out to be more effective (i.e.
2203 * actual transfer rate is better), then the driver continues to use the
2204 * speculative mode as the new current active mode.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002205 *
2206 * Each history set contains, separately for each possible rate, data for a
2207 * sliding window of the 62 most recent tx attempts at that rate. The data
2208 * includes a shifting bitmap of success(1)/failure(0), and sums of successful
2209 * and attempted frames, from which the driver can additionally calculate a
2210 * success ratio (success / attempted) and number of failures
2211 * (attempted - success), and control the size of the window (attempted).
2212 * The driver uses the bit map to remove successes from the success sum, as
2213 * the oldest tx attempts fall out of the window.
2214 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002215 * When the agn device makes multiple tx attempts for a given frame, each
2216 * attempt might be at a different rate, and have different modulation
2217 * characteristics (e.g. antenna, fat channel, short guard interval), as set
2218 * up in the rate scaling table in the Link Quality command. The driver must
2219 * determine which rate table entry was used for each tx attempt, to determine
2220 * which rate-specific history to update, and record only those attempts that
Ben Cahill2bdc7032007-11-29 11:10:12 +08002221 * match the modulation characteristics of the history set.
2222 *
2223 * When using block-ack (aggregation), all frames are transmitted at the same
Tomas Winklera96a27f2008-10-23 23:48:56 -07002224 * rate, since there is no per-attempt acknowledgment from the destination
Ben Cahill2bdc7032007-11-29 11:10:12 +08002225 * station. The Tx response struct iwl_tx_resp indicates the Tx rate in
2226 * rate_n_flags field. After receiving a block-ack, the driver can update
2227 * history for the entire block all at once.
2228 *
2229 *
2230 * FINDING BEST STARTING RATE:
2231 *
2232 * When working with a selected initial modulation mode (see below), the
2233 * driver attempts to find a best initial rate. The initial rate is the
2234 * first entry in the Link Quality command's rate table.
2235 *
2236 * 1) Calculate actual throughput (success ratio * expected throughput, see
2237 * table below) for current initial rate. Do this only if enough frames
2238 * have been attempted to make the value meaningful: at least 6 failed
2239 * tx attempts, or at least 8 successes. If not enough, don't try rate
2240 * scaling yet.
2241 *
2242 * 2) Find available rates adjacent to current initial rate. Available means:
2243 * a) supported by hardware &&
2244 * b) supported by association &&
2245 * c) within any constraints selected by user
2246 *
2247 * 3) Gather measured throughputs for adjacent rates. These might not have
2248 * enough history to calculate a throughput. That's okay, we might try
2249 * using one of them anyway!
2250 *
2251 * 4) Try decreasing rate if, for current rate:
2252 * a) success ratio is < 15% ||
2253 * b) lower adjacent rate has better measured throughput ||
2254 * c) higher adjacent rate has worse throughput, and lower is unmeasured
2255 *
2256 * As a sanity check, if decrease was determined above, leave rate
2257 * unchanged if:
2258 * a) lower rate unavailable
2259 * b) success ratio at current rate > 85% (very good)
2260 * c) current measured throughput is better than expected throughput
2261 * of lower rate (under perfect 100% tx conditions, see table below)
2262 *
2263 * 5) Try increasing rate if, for current rate:
2264 * a) success ratio is < 15% ||
2265 * b) both adjacent rates' throughputs are unmeasured (try it!) ||
2266 * b) higher adjacent rate has better measured throughput ||
2267 * c) lower adjacent rate has worse throughput, and higher is unmeasured
2268 *
2269 * As a sanity check, if increase was determined above, leave rate
2270 * unchanged if:
2271 * a) success ratio at current rate < 70%. This is not particularly
2272 * good performance; higher rate is sure to have poorer success.
2273 *
2274 * 6) Re-evaluate the rate after each tx frame. If working with block-
2275 * acknowledge, history and statistics may be calculated for the entire
2276 * block (including prior history that fits within the history windows),
2277 * before re-evaluation.
2278 *
2279 * FINDING BEST STARTING MODULATION MODE:
2280 *
2281 * After working with a modulation mode for a "while" (and doing rate scaling),
2282 * the driver searches for a new initial mode in an attempt to improve
2283 * throughput. The "while" is measured by numbers of attempted frames:
2284 *
2285 * For legacy mode, search for new mode after:
2286 * 480 successful frames, or 160 failed frames
2287 * For high-throughput modes (SISO or MIMO), search for new mode after:
2288 * 4500 successful frames, or 400 failed frames
2289 *
2290 * Mode switch possibilities are (3 for each mode):
2291 *
2292 * For legacy:
2293 * Change antenna, try SISO (if HT association), try MIMO (if HT association)
2294 * For SISO:
2295 * Change antenna, try MIMO, try shortened guard interval (SGI)
2296 * For MIMO:
2297 * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
2298 *
2299 * When trying a new mode, use the same bit rate as the old/current mode when
2300 * trying antenna switches and shortened guard interval. When switching to
2301 * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
2302 * for which the expected throughput (under perfect conditions) is about the
2303 * same or slightly better than the actual measured throughput delivered by
2304 * the old/current mode.
2305 *
2306 * Actual throughput can be estimated by multiplying the expected throughput
2307 * by the success ratio (successful / attempted tx frames). Frame size is
2308 * not considered in this calculation; it assumes that frame size will average
2309 * out to be fairly consistent over several samples. The following are
2310 * metric values for expected throughput assuming 100% success ratio.
2311 * Only G band has support for CCK rates:
2312 *
2313 * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60
2314 *
2315 * G: 7 13 35 58 40 57 72 98 121 154 177 186 186
2316 * A: 0 0 0 0 40 57 72 98 121 154 177 186 186
2317 * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202
2318 * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211
2319 * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251
2320 * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257
2321 * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257
2322 * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264
2323 * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289
2324 * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293
2325 *
2326 * After the new mode has been tried for a short while (minimum of 6 failed
2327 * frames or 8 successful frames), compare success ratio and actual throughput
2328 * estimate of the new mode with the old. If either is better with the new
2329 * mode, continue to use the new mode.
2330 *
2331 * Continue comparing modes until all 3 possibilities have been tried.
2332 * If moving from legacy to HT, try all 3 possibilities from the new HT
2333 * mode. After trying all 3, a best mode is found. Continue to use this mode
2334 * for the longer "while" described above (e.g. 480 successful frames for
2335 * legacy), and then repeat the search process.
2336 *
Zhu Yib481de92007-09-25 17:54:57 -07002337 */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002338struct iwl_link_quality_cmd {
Ben Cahill2bdc7032007-11-29 11:10:12 +08002339
2340 /* Index of destination/recipient station in uCode's station table */
Zhu Yib481de92007-09-25 17:54:57 -07002341 u8 sta_id;
2342 u8 reserved1;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002343 __le16 control; /* not used */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002344 struct iwl_link_qual_general_params general_params;
2345 struct iwl_link_qual_agg_params agg_params;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002346
2347 /*
2348 * Rate info; when using rate-scaling, Tx command's initial_rate_index
2349 * specifies 1st Tx rate attempted, via index into this table.
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002350 * agn devices works its way through table when retrying Tx.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002351 */
Zhu Yib481de92007-09-25 17:54:57 -07002352 struct {
Ben Cahill2bdc7032007-11-29 11:10:12 +08002353 __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */
Zhu Yib481de92007-09-25 17:54:57 -07002354 } rs_table[LINK_QUAL_MAX_RETRY_NUM];
2355 __le32 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002356} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002357
Wey-Yi Guydab1c162010-01-22 14:22:50 -08002358/*
2359 * BT configuration enable flags:
2360 * bit 0 - 1: BT channel announcement enabled
2361 * 0: disable
2362 * bit 1 - 1: priority of BT device enabled
2363 * 0: disable
2364 * bit 2 - 1: BT 2 wire support enabled
2365 * 0: disable
2366 */
Wey-Yi Guy456d0f72009-10-23 13:42:23 -07002367#define BT_COEX_DISABLE (0x0)
Wey-Yi Guydab1c162010-01-22 14:22:50 -08002368#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0)
2369#define BT_ENABLE_PRIORITY BIT(1)
2370#define BT_ENABLE_2_WIRE BIT(2)
Wey-Yi Guy456d0f72009-10-23 13:42:23 -07002371
Wey-Yi Guy06702a72010-01-22 14:22:51 -08002372#define BT_COEX_DISABLE (0x0)
2373#define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY)
2374
Wey-Yi Guy456d0f72009-10-23 13:42:23 -07002375#define BT_LEAD_TIME_MIN (0x0)
2376#define BT_LEAD_TIME_DEF (0x1E)
2377#define BT_LEAD_TIME_MAX (0xFF)
2378
2379#define BT_MAX_KILL_MIN (0x1)
2380#define BT_MAX_KILL_DEF (0x5)
2381#define BT_MAX_KILL_MAX (0xFF)
2382
Wey-Yi Guy22bf59a2010-08-23 07:57:11 -07002383#define BT_DURATION_LIMIT_DEF 625
2384#define BT_DURATION_LIMIT_MAX 1250
2385#define BT_DURATION_LIMIT_MIN 625
2386
2387#define BT_ON_THRESHOLD_DEF 4
2388#define BT_ON_THRESHOLD_MAX 1000
2389#define BT_ON_THRESHOLD_MIN 1
2390
2391#define BT_FRAG_THRESHOLD_DEF 0
2392#define BT_FRAG_THRESHOLD_MAX 0
2393#define BT_FRAG_THRESHOLD_MIN 0
2394
2395#define BT_AGG_THRESHOLD_DEF 0
2396#define BT_AGG_THRESHOLD_MAX 0
2397#define BT_AGG_THRESHOLD_MIN 0
2398
Zhu Yib481de92007-09-25 17:54:57 -07002399/*
2400 * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
Ben Cahill3058f022008-01-14 17:46:17 -08002401 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002402 * 3945 and agn devices support hardware handshake with Bluetooth device on
Ben Cahill3058f022008-01-14 17:46:17 -08002403 * same platform. Bluetooth device alerts wireless device when it will Tx;
Tomas Winklera96a27f2008-10-23 23:48:56 -07002404 * wireless device can delay or kill its own Tx to accommodate.
Zhu Yib481de92007-09-25 17:54:57 -07002405 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002406struct iwl_bt_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002407 u8 flags;
2408 u8 lead_time;
2409 u8 max_kill;
2410 u8 reserved;
2411 __le32 kill_ack_mask;
2412 __le32 kill_cts_mask;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002413} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002414
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002415#define IWLAGN_BT_FLAG_CHANNEL_INHIBITION BIT(0)
Johannes Berg670245e2010-08-23 07:56:55 -07002416
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002417#define IWLAGN_BT_FLAG_COEX_MODE_MASK (BIT(3)|BIT(4)|BIT(5))
2418#define IWLAGN_BT_FLAG_COEX_MODE_SHIFT 3
2419#define IWLAGN_BT_FLAG_COEX_MODE_DISABLED 0
2420#define IWLAGN_BT_FLAG_COEX_MODE_LEGACY_2W 1
2421#define IWLAGN_BT_FLAG_COEX_MODE_3W 2
2422#define IWLAGN_BT_FLAG_COEX_MODE_4W 3
Johannes Berg670245e2010-08-23 07:56:55 -07002423
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002424#define IWLAGN_BT_FLAG_UCODE_DEFAULT BIT(6)
2425#define IWLAGN_BT_FLAG_NOCOEX_NOTIF BIT(7)
Johannes Berg670245e2010-08-23 07:56:55 -07002426
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002427#define IWLAGN_BT_PRIO_BOOST_MAX 0xFF
2428#define IWLAGN_BT_PRIO_BOOST_MIN 0x00
2429#define IWLAGN_BT_PRIO_BOOST_DEFAULT 0xF0
Johannes Berg670245e2010-08-23 07:56:55 -07002430
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002431#define IWLAGN_BT_MAX_KILL_DEFAULT 5
Johannes Berg670245e2010-08-23 07:56:55 -07002432
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002433#define IWLAGN_BT3_T7_DEFAULT 1
Johannes Berg670245e2010-08-23 07:56:55 -07002434
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002435#define IWLAGN_BT_KILL_ACK_MASK_DEFAULT cpu_to_le32(0xffffffff)
2436#define IWLAGN_BT_KILL_CTS_MASK_DEFAULT cpu_to_le32(0xffffffff)
Johannes Berg670245e2010-08-23 07:56:55 -07002437
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002438#define IWLAGN_BT3_PRIO_SAMPLE_DEFAULT 2
Johannes Berg670245e2010-08-23 07:56:55 -07002439
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002440#define IWLAGN_BT3_T2_DEFAULT 0xc
Johannes Berg670245e2010-08-23 07:56:55 -07002441
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002442#define IWLAGN_BT_VALID_ENABLE_FLAGS cpu_to_le16(BIT(0))
2443#define IWLAGN_BT_VALID_BOOST cpu_to_le16(BIT(1))
2444#define IWLAGN_BT_VALID_MAX_KILL cpu_to_le16(BIT(2))
2445#define IWLAGN_BT_VALID_3W_TIMERS cpu_to_le16(BIT(3))
2446#define IWLAGN_BT_VALID_KILL_ACK_MASK cpu_to_le16(BIT(4))
2447#define IWLAGN_BT_VALID_KILL_CTS_MASK cpu_to_le16(BIT(5))
2448#define IWLAGN_BT_VALID_BT4_TIMES cpu_to_le16(BIT(6))
2449#define IWLAGN_BT_VALID_3W_LUT cpu_to_le16(BIT(7))
Johannes Berg670245e2010-08-23 07:56:55 -07002450
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002451#define IWLAGN_BT_ALL_VALID_MSK (IWLAGN_BT_VALID_ENABLE_FLAGS | \
2452 IWLAGN_BT_VALID_BOOST | \
2453 IWLAGN_BT_VALID_MAX_KILL | \
2454 IWLAGN_BT_VALID_3W_TIMERS | \
2455 IWLAGN_BT_VALID_KILL_ACK_MASK | \
2456 IWLAGN_BT_VALID_KILL_CTS_MASK | \
2457 IWLAGN_BT_VALID_BT4_TIMES | \
2458 IWLAGN_BT_VALID_3W_LUT)
Johannes Berg670245e2010-08-23 07:56:55 -07002459
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002460struct iwlagn_bt_cmd {
Johannes Berg670245e2010-08-23 07:56:55 -07002461 u8 flags;
2462 u8 ledtime; /* unused */
2463 u8 max_kill;
2464 u8 bt3_timer_t7_value;
2465 __le32 kill_ack_mask;
2466 __le32 kill_cts_mask;
2467 u8 bt3_prio_sample_time;
2468 u8 bt3_timer_t2_value;
2469 __le16 bt4_reaction_time; /* unused */
2470 __le32 bt3_lookup_table[12];
2471 __le16 bt4_decision_time; /* unused */
2472 __le16 valid;
2473 u8 prio_boost;
2474 u8 reserved[3];
2475};
2476
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002477#define IWLAGN_BT_SCO_ACTIVE cpu_to_le32(BIT(0))
Johannes Berg9e4afc22010-08-23 07:56:57 -07002478
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002479struct iwlagn_bt_sco_cmd {
Johannes Berg9e4afc22010-08-23 07:56:57 -07002480 __le32 flags;
2481};
2482
Zhu Yib481de92007-09-25 17:54:57 -07002483/******************************************************************************
2484 * (6)
2485 * Spectrum Management (802.11h) Commands, Responses, Notifications:
2486 *
2487 *****************************************************************************/
2488
2489/*
2490 * Spectrum Management
2491 */
2492#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
2493 RXON_FILTER_CTL2HOST_MSK | \
2494 RXON_FILTER_ACCEPT_GRP_MSK | \
2495 RXON_FILTER_DIS_DECRYPT_MSK | \
2496 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
2497 RXON_FILTER_ASSOC_MSK | \
2498 RXON_FILTER_BCON_AWARE_MSK)
2499
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002500struct iwl_measure_channel {
Zhu Yib481de92007-09-25 17:54:57 -07002501 __le32 duration; /* measurement duration in extended beacon
2502 * format */
2503 u8 channel; /* channel to measure */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002504 u8 type; /* see enum iwl_measure_type */
Zhu Yib481de92007-09-25 17:54:57 -07002505 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002506} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002507
2508/*
2509 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
2510 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002511struct iwl_spectrum_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002512 __le16 len; /* number of bytes starting from token */
2513 u8 token; /* token id */
2514 u8 id; /* measurement id -- 0 or 1 */
2515 u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
2516 u8 periodic; /* 1 = periodic */
2517 __le16 path_loss_timeout;
2518 __le32 start_time; /* start time in extended beacon format */
2519 __le32 reserved2;
2520 __le32 flags; /* rxon flags */
2521 __le32 filter_flags; /* rxon filter flags */
2522 __le16 channel_count; /* minimum 1, maximum 10 */
2523 __le16 reserved3;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002524 struct iwl_measure_channel channels[10];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002525} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002526
2527/*
2528 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
2529 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002530struct iwl_spectrum_resp {
Zhu Yib481de92007-09-25 17:54:57 -07002531 u8 token;
2532 u8 id; /* id of the prior command replaced, or 0xff */
2533 __le16 status; /* 0 - command will be handled
2534 * 1 - cannot handle (conflicts with another
2535 * measurement) */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002536} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002537
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002538enum iwl_measurement_state {
Zhu Yib481de92007-09-25 17:54:57 -07002539 IWL_MEASUREMENT_START = 0,
2540 IWL_MEASUREMENT_STOP = 1,
2541};
2542
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002543enum iwl_measurement_status {
Zhu Yib481de92007-09-25 17:54:57 -07002544 IWL_MEASUREMENT_OK = 0,
2545 IWL_MEASUREMENT_CONCURRENT = 1,
2546 IWL_MEASUREMENT_CSA_CONFLICT = 2,
2547 IWL_MEASUREMENT_TGH_CONFLICT = 3,
2548 /* 4-5 reserved */
2549 IWL_MEASUREMENT_STOPPED = 6,
2550 IWL_MEASUREMENT_TIMEOUT = 7,
2551 IWL_MEASUREMENT_PERIODIC_FAILED = 8,
2552};
2553
2554#define NUM_ELEMENTS_IN_HISTOGRAM 8
2555
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002556struct iwl_measurement_histogram {
Zhu Yib481de92007-09-25 17:54:57 -07002557 __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
2558 __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002559} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002560
2561/* clear channel availability counters */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002562struct iwl_measurement_cca_counters {
Zhu Yib481de92007-09-25 17:54:57 -07002563 __le32 ofdm;
2564 __le32 cck;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002565} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002566
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002567enum iwl_measure_type {
Zhu Yib481de92007-09-25 17:54:57 -07002568 IWL_MEASURE_BASIC = (1 << 0),
2569 IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
2570 IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
2571 IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
2572 IWL_MEASURE_FRAME = (1 << 4),
2573 /* bits 5:6 are reserved */
2574 IWL_MEASURE_IDLE = (1 << 7),
2575};
2576
2577/*
2578 * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
2579 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002580struct iwl_spectrum_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002581 u8 id; /* measurement id -- 0 or 1 */
2582 u8 token;
2583 u8 channel_index; /* index in measurement channel list */
2584 u8 state; /* 0 - start, 1 - stop */
2585 __le32 start_time; /* lower 32-bits of TSF */
2586 u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
2587 u8 channel;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002588 u8 type; /* see enum iwl_measurement_type */
Zhu Yib481de92007-09-25 17:54:57 -07002589 u8 reserved1;
2590 /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
2591 * valid if applicable for measurement type requested. */
2592 __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
2593 __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
2594 __le32 cca_time; /* channel load time in usecs */
2595 u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
2596 * unidentified */
2597 u8 reserved2[3];
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002598 struct iwl_measurement_histogram histogram;
Zhu Yib481de92007-09-25 17:54:57 -07002599 __le32 stop_time; /* lower 32-bits of TSF */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002600 __le32 status; /* see iwl_measurement_status */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002601} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002602
2603/******************************************************************************
2604 * (7)
2605 * Power Management Commands, Responses, Notifications:
2606 *
2607 *****************************************************************************/
2608
2609/**
Mohamed Abbasca579612008-07-18 13:52:57 +08002610 * struct iwl_powertable_cmd - Power Table Command
Zhu Yib481de92007-09-25 17:54:57 -07002611 * @flags: See below:
2612 *
2613 * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
2614 *
2615 * PM allow:
2616 * bit 0 - '0' Driver not allow power management
2617 * '1' Driver allow PM (use rest of parameters)
Johannes Berge312c242009-08-07 15:41:51 -07002618 *
Zhu Yib481de92007-09-25 17:54:57 -07002619 * uCode send sleep notifications:
2620 * bit 1 - '0' Don't send sleep notification
2621 * '1' send sleep notification (SEND_PM_NOTIFICATION)
Johannes Berge312c242009-08-07 15:41:51 -07002622 *
Zhu Yib481de92007-09-25 17:54:57 -07002623 * Sleep over DTIM
2624 * bit 2 - '0' PM have to walk up every DTIM
2625 * '1' PM could sleep over DTIM till listen Interval.
Johannes Berge312c242009-08-07 15:41:51 -07002626 *
Zhu Yib481de92007-09-25 17:54:57 -07002627 * PCI power managed
Tomas Winklere7b63582008-09-03 11:26:49 +08002628 * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
2629 * '1' !(PCI_CFG_LINK_CTRL & 0x1)
Johannes Berge312c242009-08-07 15:41:51 -07002630 *
2631 * Fast PD
2632 * bit 4 - '1' Put radio to sleep when receiving frame for others
2633 *
Zhu Yib481de92007-09-25 17:54:57 -07002634 * Force sleep Modes
2635 * bit 31/30- '00' use both mac/xtal sleeps
2636 * '01' force Mac sleep
2637 * '10' force xtal sleep
2638 * '11' Illegal set
2639 *
2640 * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
Tomas Winklera96a27f2008-10-23 23:48:56 -07002641 * ucode assume sleep over DTIM is allowed and we don't need to wake up
Zhu Yib481de92007-09-25 17:54:57 -07002642 * for every DTIM.
2643 */
2644#define IWL_POWER_VEC_SIZE 5
2645
Tomas Winkler600c0e12008-12-19 10:37:04 +08002646#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0))
2647#define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le16(BIT(2))
2648#define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3))
2649#define IWL_POWER_FAST_PD cpu_to_le16(BIT(4))
2650
2651struct iwl3945_powertable_cmd {
2652 __le16 flags;
2653 u8 reserved[2];
2654 __le32 rx_data_timeout;
2655 __le32 tx_data_timeout;
2656 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002657} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002658
Mohamed Abbasca579612008-07-18 13:52:57 +08002659struct iwl_powertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002660 __le16 flags;
Tomas Winkler600c0e12008-12-19 10:37:04 +08002661 u8 keep_alive_seconds; /* 3945 reserved */
2662 u8 debug_flags; /* 3945 reserved */
Zhu Yib481de92007-09-25 17:54:57 -07002663 __le32 rx_data_timeout;
2664 __le32 tx_data_timeout;
2665 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
2666 __le32 keep_alive_beacons;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002667} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002668
2669/*
2670 * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002671 * all devices identical.
Zhu Yib481de92007-09-25 17:54:57 -07002672 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002673struct iwl_sleep_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002674 u8 pm_sleep_mode;
2675 u8 pm_wakeup_src;
2676 __le16 reserved;
2677 __le32 sleep_time;
2678 __le32 tsf_low;
2679 __le32 bcon_timer;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002680} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002681
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002682/* Sleep states. all devices identical. */
Zhu Yib481de92007-09-25 17:54:57 -07002683enum {
2684 IWL_PM_NO_SLEEP = 0,
2685 IWL_PM_SLP_MAC = 1,
2686 IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
2687 IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
2688 IWL_PM_SLP_PHY = 4,
2689 IWL_PM_SLP_REPENT = 5,
2690 IWL_PM_WAKEUP_BY_TIMER = 6,
2691 IWL_PM_WAKEUP_BY_DRIVER = 7,
2692 IWL_PM_WAKEUP_BY_RFKILL = 8,
2693 /* 3 reserved */
2694 IWL_PM_NUM_OF_MODES = 12,
2695};
2696
2697/*
2698 * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
2699 */
2700#define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
2701#define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
2702#define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002703struct iwl_card_state_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002704 __le32 status; /* CARD_STATE_CMD_* request new power state */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002705} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002706
2707/*
2708 * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
2709 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002710struct iwl_card_state_notif {
Zhu Yib481de92007-09-25 17:54:57 -07002711 __le32 flags;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002712} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002713
2714#define HW_CARD_DISABLED 0x01
2715#define SW_CARD_DISABLED 0x02
Wey-Yi Guy3a41bbd2009-12-10 14:37:24 -08002716#define CT_CARD_DISABLED 0x04
Zhu Yib481de92007-09-25 17:54:57 -07002717#define RXON_CARD_DISABLED 0x10
2718
Emmanuel Grumbach47f4a582008-06-12 09:47:13 +08002719struct iwl_ct_kill_config {
Zhu Yib481de92007-09-25 17:54:57 -07002720 __le32 reserved;
2721 __le32 critical_temperature_M;
2722 __le32 critical_temperature_R;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002723} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002724
Wey-Yi Guy672639d2009-07-24 11:13:01 -07002725/* 1000, and 6x00 */
2726struct iwl_ct_kill_throttling_config {
2727 __le32 critical_temperature_exit;
2728 __le32 reserved;
2729 __le32 critical_temperature_enter;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002730} __packed;
Wey-Yi Guy672639d2009-07-24 11:13:01 -07002731
Zhu Yib481de92007-09-25 17:54:57 -07002732/******************************************************************************
2733 * (8)
2734 * Scan Commands, Responses, Notifications:
2735 *
2736 *****************************************************************************/
2737
Harvey Harrison51e9bf52008-11-26 13:12:52 -08002738#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
2739#define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1)
Tomas Winklerd16dc482008-07-11 11:53:38 +08002740
Ben Cahill3058f022008-01-14 17:46:17 -08002741/**
Tomas Winkler2a421b92008-06-12 09:47:10 +08002742 * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
Ben Cahill3058f022008-01-14 17:46:17 -08002743 *
2744 * One for each channel in the scan list.
2745 * Each channel can independently select:
2746 * 1) SSID for directed active scans
2747 * 2) Txpower setting (for rate specified within Tx command)
2748 * 3) How long to stay on-channel (behavior may be modified by quiet_time,
2749 * quiet_plcp_th, good_CRC_th)
2750 *
2751 * To avoid uCode errors, make sure the following are true (see comments
Tomas Winkler2a421b92008-06-12 09:47:10 +08002752 * under struct iwl_scan_cmd about max_out_time and quiet_time):
Ben Cahill3058f022008-01-14 17:46:17 -08002753 * 1) If using passive_dwell (i.e. passive_dwell != 0):
2754 * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
2755 * 2) quiet_time <= active_dwell
2756 * 3) If restricting off-channel time (i.e. max_out_time !=0):
2757 * passive_dwell < max_out_time
2758 * active_dwell < max_out_time
2759 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002760
2761/* FIXME: rename to AP1, remove tpc */
2762struct iwl3945_scan_channel {
2763 /*
2764 * type is defined as:
2765 * 0:0 1 = active, 0 = passive
2766 * 1:4 SSID direct bit map; if a bit is set, then corresponding
2767 * SSID IE is transmitted in probe request.
2768 * 5:7 reserved
2769 */
2770 u8 type;
2771 u8 channel; /* band is selected by iwl3945_scan_cmd "flags" field */
2772 struct iwl3945_tx_power tpc;
2773 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2774 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002775} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002776
Winkler, Tomas0d210442009-01-23 13:45:21 -08002777/* set number of direct probes u8 type */
2778#define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1))))
2779
Tomas Winkler2a421b92008-06-12 09:47:10 +08002780struct iwl_scan_channel {
Ben Cahill3058f022008-01-14 17:46:17 -08002781 /*
2782 * type is defined as:
2783 * 0:0 1 = active, 0 = passive
Tomas Winklerd16dc482008-07-11 11:53:38 +08002784 * 1:20 SSID direct bit map; if a bit is set, then corresponding
Ben Cahill3058f022008-01-14 17:46:17 -08002785 * SSID IE is transmitted in probe request.
Tomas Winklerd16dc482008-07-11 11:53:38 +08002786 * 21:31 reserved
Zhu Yib481de92007-09-25 17:54:57 -07002787 */
Tomas Winklerd16dc482008-07-11 11:53:38 +08002788 __le32 type;
2789 __le16 channel; /* band is selected by iwl_scan_cmd "flags" field */
Tomas Winklerf53696d2008-06-12 09:47:12 +08002790 u8 tx_gain; /* gain for analog radio */
2791 u8 dsp_atten; /* gain for DSP */
Ben Cahill3058f022008-01-14 17:46:17 -08002792 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2793 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002794} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002795
Winkler, Tomas0d210442009-01-23 13:45:21 -08002796/* set number of direct probes __le32 type */
2797#define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
2798
Ben Cahill3058f022008-01-14 17:46:17 -08002799/**
Tomas Winkler2a421b92008-06-12 09:47:10 +08002800 * struct iwl_ssid_ie - directed scan network information element
Ben Cahill3058f022008-01-14 17:46:17 -08002801 *
Ben Cahill2a3b7932009-11-06 14:52:59 -08002802 * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in
2803 * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel;
2804 * each channel may select different ssids from among the 20 (4) entries.
2805 * SSID IEs get transmitted in reverse order of entry.
Ben Cahill3058f022008-01-14 17:46:17 -08002806 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002807struct iwl_ssid_ie {
Zhu Yib481de92007-09-25 17:54:57 -07002808 u8 id;
2809 u8 len;
2810 u8 ssid[32];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002811} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002812
Johannes Berg9b3bf062009-04-20 14:36:55 -07002813#define PROBE_OPTION_MAX_3945 4
2814#define PROBE_OPTION_MAX 20
Harvey Harrison51e9bf52008-11-26 13:12:52 -08002815#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
Johannes Berg96ff5642010-04-30 14:42:15 -07002816#define IWL_GOOD_CRC_TH_DISABLED 0
2817#define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
2818#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
Zhu Yib481de92007-09-25 17:54:57 -07002819#define IWL_MAX_SCAN_SIZE 1024
Abhijeet Kolekar89612122010-02-19 11:49:49 -08002820#define IWL_MAX_CMD_SIZE 4096
Zhu Yib481de92007-09-25 17:54:57 -07002821
2822/*
2823 * REPLY_SCAN_CMD = 0x80 (command)
Ben Cahill3058f022008-01-14 17:46:17 -08002824 *
2825 * The hardware scan command is very powerful; the driver can set it up to
2826 * maintain (relatively) normal network traffic while doing a scan in the
2827 * background. The max_out_time and suspend_time control the ratio of how
2828 * long the device stays on an associated network channel ("service channel")
2829 * vs. how long it's away from the service channel, i.e. tuned to other channels
2830 * for scanning.
2831 *
2832 * max_out_time is the max time off-channel (in usec), and suspend_time
2833 * is how long (in "extended beacon" format) that the scan is "suspended"
2834 * after returning to the service channel. That is, suspend_time is the
2835 * time that we stay on the service channel, doing normal work, between
2836 * scan segments. The driver may set these parameters differently to support
2837 * scanning when associated vs. not associated, and light vs. heavy traffic
2838 * loads when associated.
2839 *
2840 * After receiving this command, the device's scan engine does the following;
2841 *
2842 * 1) Sends SCAN_START notification to driver
2843 * 2) Checks to see if it has time to do scan for one channel
2844 * 3) Sends NULL packet, with power-save (PS) bit set to 1,
2845 * to tell AP that we're going off-channel
2846 * 4) Tunes to first channel in scan list, does active or passive scan
2847 * 5) Sends SCAN_RESULT notification to driver
2848 * 6) Checks to see if it has time to do scan on *next* channel in list
2849 * 7) Repeats 4-6 until it no longer has time to scan the next channel
2850 * before max_out_time expires
2851 * 8) Returns to service channel
2852 * 9) Sends NULL packet with PS=0 to tell AP that we're back
2853 * 10) Stays on service channel until suspend_time expires
2854 * 11) Repeats entire process 2-10 until list is complete
2855 * 12) Sends SCAN_COMPLETE notification
2856 *
2857 * For fast, efficient scans, the scan command also has support for staying on
2858 * a channel for just a short time, if doing active scanning and getting no
2859 * responses to the transmitted probe request. This time is controlled by
2860 * quiet_time, and the number of received packets below which a channel is
2861 * considered "quiet" is controlled by quiet_plcp_threshold.
2862 *
2863 * For active scanning on channels that have regulatory restrictions against
2864 * blindly transmitting, the scan can listen before transmitting, to make sure
2865 * that there is already legitimate activity on the channel. If enough
2866 * packets are cleanly received on the channel (controlled by good_CRC_th,
2867 * typical value 1), the scan engine starts transmitting probe requests.
2868 *
2869 * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
2870 *
2871 * To avoid uCode errors, see timing restrictions described under
Tomas Winkler2a421b92008-06-12 09:47:10 +08002872 * struct iwl_scan_channel.
Zhu Yib481de92007-09-25 17:54:57 -07002873 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002874
2875struct iwl3945_scan_cmd {
2876 __le16 len;
2877 u8 reserved0;
2878 u8 channel_count; /* # channels in channel list */
2879 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2880 * (only for active scan) */
2881 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2882 __le16 good_CRC_th; /* passive -> active promotion threshold */
2883 __le16 reserved1;
2884 __le32 max_out_time; /* max usec to be away from associated (service)
2885 * channel */
2886 __le32 suspend_time; /* pause scan this long (in "extended beacon
2887 * format") when returning to service channel:
2888 * 3945; 31:24 # beacons, 19:0 additional usec,
2889 * 4965; 31:22 # beacons, 21:0 additional usec.
2890 */
2891 __le32 flags; /* RXON_FLG_* */
2892 __le32 filter_flags; /* RXON_FILTER_* */
2893
2894 /* For active scans (set to all-0s for passive scans).
2895 * Does not include payload. Must specify Tx rate; no rate scaling. */
2896 struct iwl3945_tx_cmd tx_cmd;
2897
2898 /* For directed active scans (set to all-0s otherwise) */
Johannes Berg9b3bf062009-04-20 14:36:55 -07002899 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002900
2901 /*
2902 * Probe request frame, followed by channel list.
2903 *
2904 * Size of probe request frame is specified by byte count in tx_cmd.
2905 * Channel list follows immediately after probe request frame.
2906 * Number of channels in list is specified by channel_count.
2907 * Each channel in list is of type:
2908 *
2909 * struct iwl3945_scan_channel channels[0];
2910 *
2911 * NOTE: Only one band of channels can be scanned per pass. You
2912 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2913 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
2914 * before requesting another scan.
2915 */
2916 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002917} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002918
Tomas Winkler2a421b92008-06-12 09:47:10 +08002919struct iwl_scan_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002920 __le16 len;
2921 u8 reserved0;
Ben Cahill3058f022008-01-14 17:46:17 -08002922 u8 channel_count; /* # channels in channel list */
2923 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2924 * (only for active scan) */
2925 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2926 __le16 good_CRC_th; /* passive -> active promotion threshold */
2927 __le16 rx_chain; /* RXON_RX_CHAIN_* */
2928 __le32 max_out_time; /* max usec to be away from associated (service)
2929 * channel */
2930 __le32 suspend_time; /* pause scan this long (in "extended beacon
2931 * format") when returning to service chnl:
2932 * 3945; 31:24 # beacons, 19:0 additional usec,
2933 * 4965; 31:22 # beacons, 21:0 additional usec.
2934 */
2935 __le32 flags; /* RXON_FLG_* */
2936 __le32 filter_flags; /* RXON_FILTER_* */
Zhu Yib481de92007-09-25 17:54:57 -07002937
Ben Cahill3058f022008-01-14 17:46:17 -08002938 /* For active scans (set to all-0s for passive scans).
2939 * Does not include payload. Must specify Tx rate; no rate scaling. */
Tomas Winkler83d527d2008-05-15 13:54:05 +08002940 struct iwl_tx_cmd tx_cmd;
Ben Cahill3058f022008-01-14 17:46:17 -08002941
2942 /* For directed active scans (set to all-0s otherwise) */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002943 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
Zhu Yib481de92007-09-25 17:54:57 -07002944
Zhu Yib481de92007-09-25 17:54:57 -07002945 /*
Ben Cahill3058f022008-01-14 17:46:17 -08002946 * Probe request frame, followed by channel list.
2947 *
2948 * Size of probe request frame is specified by byte count in tx_cmd.
2949 * Channel list follows immediately after probe request frame.
2950 * Number of channels in list is specified by channel_count.
2951 * Each channel in list is of type:
Zhu Yib481de92007-09-25 17:54:57 -07002952 *
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002953 * struct iwl_scan_channel channels[0];
Zhu Yib481de92007-09-25 17:54:57 -07002954 *
2955 * NOTE: Only one band of channels can be scanned per pass. You
Ben Cahill3058f022008-01-14 17:46:17 -08002956 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2957 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
2958 * before requesting another scan.
Zhu Yib481de92007-09-25 17:54:57 -07002959 */
Ben Cahill3058f022008-01-14 17:46:17 -08002960 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002961} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002962
2963/* Can abort will notify by complete notification with abort status. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08002964#define CAN_ABORT_STATUS cpu_to_le32(0x1)
Zhu Yib481de92007-09-25 17:54:57 -07002965/* complete notification statuses */
2966#define ABORT_STATUS 0x2
2967
2968/*
2969 * REPLY_SCAN_CMD = 0x80 (response)
2970 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002971struct iwl_scanreq_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002972 __le32 status; /* 1: okay, 2: cannot fulfill request */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002973} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002974
2975/*
2976 * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
2977 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002978struct iwl_scanstart_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002979 __le32 tsf_low;
2980 __le32 tsf_high;
2981 __le32 beacon_timer;
2982 u8 channel;
2983 u8 band;
2984 u8 reserved[2];
2985 __le32 status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002986} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002987
2988#define SCAN_OWNER_STATUS 0x1;
2989#define MEASURE_OWNER_STATUS 0x2;
2990
Johannes Berg0288d232010-08-23 07:56:54 -07002991#define IWL_PROBE_STATUS_OK 0
2992#define IWL_PROBE_STATUS_TX_FAILED BIT(0)
2993/* error statuses combined with TX_FAILED */
2994#define IWL_PROBE_STATUS_FAIL_TTL BIT(1)
2995#define IWL_PROBE_STATUS_FAIL_BT BIT(2)
2996
Zhu Yib481de92007-09-25 17:54:57 -07002997#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
2998/*
2999 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
3000 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08003001struct iwl_scanresults_notification {
Zhu Yib481de92007-09-25 17:54:57 -07003002 u8 channel;
3003 u8 band;
Johannes Berg0288d232010-08-23 07:56:54 -07003004 u8 probe_status;
3005 u8 num_probe_not_sent; /* not enough time to send */
Zhu Yib481de92007-09-25 17:54:57 -07003006 __le32 tsf_low;
3007 __le32 tsf_high;
3008 __le32 statistics[NUMBER_OF_STATISTICS];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003009} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003010
3011/*
3012 * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
3013 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08003014struct iwl_scancomplete_notification {
Zhu Yib481de92007-09-25 17:54:57 -07003015 u8 scanned_channels;
3016 u8 status;
Wey-Yi Guyf78e5452010-08-23 07:57:15 -07003017 u8 bt_status; /* BT On/Off status */
Zhu Yib481de92007-09-25 17:54:57 -07003018 u8 last_channel;
3019 __le32 tsf_low;
3020 __le32 tsf_high;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003021} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003022
3023
3024/******************************************************************************
3025 * (9)
3026 * IBSS/AP Commands and Notifications:
3027 *
3028 *****************************************************************************/
3029
Johannes Berga85d7cc2010-07-31 08:34:10 -07003030enum iwl_ibss_manager {
3031 IWL_NOT_IBSS_MANAGER = 0,
3032 IWL_IBSS_MANAGER = 1,
3033};
3034
Zhu Yib481de92007-09-25 17:54:57 -07003035/*
3036 * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
3037 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003038
3039struct iwl3945_beacon_notif {
3040 struct iwl3945_tx_resp beacon_notify_hdr;
3041 __le32 low_tsf;
3042 __le32 high_tsf;
3043 __le32 ibss_mgr_status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003044} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003045
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08003046struct iwl4965_beacon_notif {
3047 struct iwl4965_tx_resp beacon_notify_hdr;
Zhu Yib481de92007-09-25 17:54:57 -07003048 __le32 low_tsf;
3049 __le32 high_tsf;
3050 __le32 ibss_mgr_status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003051} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003052
3053/*
3054 * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
3055 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003056
3057struct iwl3945_tx_beacon_cmd {
3058 struct iwl3945_tx_cmd tx;
3059 __le16 tim_idx;
3060 u8 tim_size;
3061 u8 reserved1;
3062 struct ieee80211_hdr frame[0]; /* beacon frame */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003063} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003064
Tomas Winkler4bf64ef2008-07-18 13:53:03 +08003065struct iwl_tx_beacon_cmd {
Tomas Winkler83d527d2008-05-15 13:54:05 +08003066 struct iwl_tx_cmd tx;
Zhu Yib481de92007-09-25 17:54:57 -07003067 __le16 tim_idx;
3068 u8 tim_size;
3069 u8 reserved1;
3070 struct ieee80211_hdr frame[0]; /* beacon frame */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003071} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003072
3073/******************************************************************************
3074 * (10)
3075 * Statistics Commands and Notifications:
3076 *
3077 *****************************************************************************/
3078
3079#define IWL_TEMP_CONVERT 260
3080
3081#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
3082#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
3083#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
3084
3085/* Used for passing to driver number of successes and failures per rate */
3086struct rate_histogram {
3087 union {
3088 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
3089 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
3090 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
3091 } success;
3092 union {
3093 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
3094 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
3095 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
3096 } failed;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003097} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003098
3099/* statistics command response */
3100
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003101struct iwl39_statistics_rx_phy {
3102 __le32 ina_cnt;
3103 __le32 fina_cnt;
3104 __le32 plcp_err;
3105 __le32 crc32_err;
3106 __le32 overrun_err;
3107 __le32 early_overrun_err;
3108 __le32 crc32_good;
3109 __le32 false_alarm_cnt;
3110 __le32 fina_sync_err_cnt;
3111 __le32 sfd_timeout;
3112 __le32 fina_timeout;
3113 __le32 unresponded_rts;
3114 __le32 rxe_frame_limit_overrun;
3115 __le32 sent_ack_cnt;
3116 __le32 sent_cts_cnt;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003117} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003118
3119struct iwl39_statistics_rx_non_phy {
3120 __le32 bogus_cts; /* CTS received when not expecting CTS */
3121 __le32 bogus_ack; /* ACK received when not expecting ACK */
3122 __le32 non_bssid_frames; /* number of frames with BSSID that
3123 * doesn't belong to the STA BSSID */
3124 __le32 filtered_frames; /* count frames that were dumped in the
3125 * filtering process */
3126 __le32 non_channel_beacons; /* beacons with our bss id but not on
3127 * our serving channel */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003128} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003129
3130struct iwl39_statistics_rx {
3131 struct iwl39_statistics_rx_phy ofdm;
3132 struct iwl39_statistics_rx_phy cck;
3133 struct iwl39_statistics_rx_non_phy general;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003134} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003135
3136struct iwl39_statistics_tx {
3137 __le32 preamble_cnt;
3138 __le32 rx_detected_cnt;
3139 __le32 bt_prio_defer_cnt;
3140 __le32 bt_prio_kill_cnt;
3141 __le32 few_bytes_cnt;
3142 __le32 cts_timeout;
3143 __le32 ack_timeout;
3144 __le32 expected_ack_cnt;
3145 __le32 actual_ack_cnt;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003146} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003147
3148struct statistics_dbg {
3149 __le32 burst_check;
3150 __le32 burst_count;
Wey-Yi Guy7c094c52010-07-06 10:39:32 -07003151 __le32 wait_for_silence_timeout_cnt;
3152 __le32 reserved[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003153} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003154
3155struct iwl39_statistics_div {
3156 __le32 tx_on_a;
3157 __le32 tx_on_b;
3158 __le32 exec_time;
3159 __le32 probe_time;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003160} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003161
3162struct iwl39_statistics_general {
3163 __le32 temperature;
3164 struct statistics_dbg dbg;
3165 __le32 sleep_time;
3166 __le32 slots_out;
3167 __le32 slots_idle;
3168 __le32 ttl_timestamp;
3169 struct iwl39_statistics_div div;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003170} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003171
Zhu Yib481de92007-09-25 17:54:57 -07003172struct statistics_rx_phy {
3173 __le32 ina_cnt;
3174 __le32 fina_cnt;
3175 __le32 plcp_err;
3176 __le32 crc32_err;
3177 __le32 overrun_err;
3178 __le32 early_overrun_err;
3179 __le32 crc32_good;
3180 __le32 false_alarm_cnt;
3181 __le32 fina_sync_err_cnt;
3182 __le32 sfd_timeout;
3183 __le32 fina_timeout;
3184 __le32 unresponded_rts;
3185 __le32 rxe_frame_limit_overrun;
3186 __le32 sent_ack_cnt;
3187 __le32 sent_cts_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07003188 __le32 sent_ba_rsp_cnt;
3189 __le32 dsp_self_kill;
3190 __le32 mh_format_err;
3191 __le32 re_acq_main_rssi_sum;
3192 __le32 reserved3;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003193} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003194
Zhu Yib481de92007-09-25 17:54:57 -07003195struct statistics_rx_ht_phy {
3196 __le32 plcp_err;
3197 __le32 overrun_err;
3198 __le32 early_overrun_err;
3199 __le32 crc32_good;
3200 __le32 crc32_err;
3201 __le32 mh_format_err;
3202 __le32 agg_crc32_good;
3203 __le32 agg_mpdu_cnt;
3204 __le32 agg_cnt;
Wey-Yi Guyf0118a42010-01-08 10:04:42 -08003205 __le32 unsupport_mcs;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003206} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003207
Harvey Harrisonc1b4aa32009-01-29 13:26:44 -08003208#define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1)
Winkler, Tomas34c22cf2008-12-17 16:52:27 +08003209
Zhu Yib481de92007-09-25 17:54:57 -07003210struct statistics_rx_non_phy {
3211 __le32 bogus_cts; /* CTS received when not expecting CTS */
3212 __le32 bogus_ack; /* ACK received when not expecting ACK */
3213 __le32 non_bssid_frames; /* number of frames with BSSID that
3214 * doesn't belong to the STA BSSID */
3215 __le32 filtered_frames; /* count frames that were dumped in the
3216 * filtering process */
3217 __le32 non_channel_beacons; /* beacons with our bss id but not on
3218 * our serving channel */
Zhu Yib481de92007-09-25 17:54:57 -07003219 __le32 channel_beacons; /* beacons with our bss id and in our
3220 * serving channel */
3221 __le32 num_missed_bcon; /* number of missed beacons */
3222 __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
3223 * ADC was in saturation */
3224 __le32 ina_detection_search_time;/* total time (in 0.8us) searched
3225 * for INA */
3226 __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
3227 __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
3228 __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
3229 __le32 interference_data_flag; /* flag for interference data
3230 * availability. 1 when data is
3231 * available. */
Ben Cahill3058f022008-01-14 17:46:17 -08003232 __le32 channel_load; /* counts RX Enable time in uSec */
Zhu Yib481de92007-09-25 17:54:57 -07003233 __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
3234 * and CCK) counter */
3235 __le32 beacon_rssi_a;
3236 __le32 beacon_rssi_b;
3237 __le32 beacon_rssi_c;
3238 __le32 beacon_energy_a;
3239 __le32 beacon_energy_b;
3240 __le32 beacon_energy_c;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003241} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003242
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003243struct statistics_rx_non_phy_bt {
3244 struct statistics_rx_non_phy common;
3245 /* additional stats for bt */
3246 __le32 num_bt_kills;
3247 __le32 reserved[2];
John W. Linvilleda22f792010-07-26 15:04:12 -04003248} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003249
Zhu Yib481de92007-09-25 17:54:57 -07003250struct statistics_rx {
3251 struct statistics_rx_phy ofdm;
3252 struct statistics_rx_phy cck;
3253 struct statistics_rx_non_phy general;
Zhu Yib481de92007-09-25 17:54:57 -07003254 struct statistics_rx_ht_phy ofdm_ht;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003255} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003256
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003257struct statistics_rx_bt {
3258 struct statistics_rx_phy ofdm;
3259 struct statistics_rx_phy cck;
3260 struct statistics_rx_non_phy_bt general;
3261 struct statistics_rx_ht_phy ofdm_ht;
John W. Linvilleda22f792010-07-26 15:04:12 -04003262} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003263
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -07003264/**
3265 * struct statistics_tx_power - current tx power
3266 *
3267 * @ant_a: current tx power on chain a in 1/2 dB step
3268 * @ant_b: current tx power on chain b in 1/2 dB step
3269 * @ant_c: current tx power on chain c in 1/2 dB step
3270 */
3271struct statistics_tx_power {
3272 u8 ant_a;
3273 u8 ant_b;
3274 u8 ant_c;
3275 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003276} __packed;
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -07003277
Zhu Yib481de92007-09-25 17:54:57 -07003278struct statistics_tx_non_phy_agg {
3279 __le32 ba_timeout;
3280 __le32 ba_reschedule_frames;
3281 __le32 scd_query_agg_frame_cnt;
3282 __le32 scd_query_no_agg;
3283 __le32 scd_query_agg;
3284 __le32 scd_query_mismatch;
3285 __le32 frame_not_ready;
3286 __le32 underrun;
3287 __le32 bt_prio_kill;
3288 __le32 rx_ba_rsp_cnt;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003289} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003290
3291struct statistics_tx {
3292 __le32 preamble_cnt;
3293 __le32 rx_detected_cnt;
3294 __le32 bt_prio_defer_cnt;
3295 __le32 bt_prio_kill_cnt;
3296 __le32 few_bytes_cnt;
3297 __le32 cts_timeout;
3298 __le32 ack_timeout;
3299 __le32 expected_ack_cnt;
3300 __le32 actual_ack_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07003301 __le32 dump_msdu_cnt;
3302 __le32 burst_abort_next_frame_mismatch_cnt;
3303 __le32 burst_abort_missing_next_frame_cnt;
3304 __le32 cts_timeout_collision;
3305 __le32 ack_or_ba_timeout_collision;
3306 struct statistics_tx_non_phy_agg agg;
Wey-Yi Guy470356b2010-04-30 11:35:15 -07003307 /*
3308 * "tx_power" are optional parameters provided by uCode,
3309 * 6000 series is the only device provide the information,
3310 * Those are reserved fields for all the other devices
3311 */
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -07003312 struct statistics_tx_power tx_power;
3313 __le32 reserved1;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003314} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003315
Zhu Yib481de92007-09-25 17:54:57 -07003316
3317struct statistics_div {
3318 __le32 tx_on_a;
3319 __le32 tx_on_b;
3320 __le32 exec_time;
3321 __le32 probe_time;
Zhu Yib481de92007-09-25 17:54:57 -07003322 __le32 reserved1;
3323 __le32 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003324} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003325
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003326struct statistics_general_common {
Wey-Yi Guyf0118a42010-01-08 10:04:42 -08003327 __le32 temperature; /* radio temperature */
3328 __le32 temperature_m; /* for 5000 and up, this is radio voltage */
Zhu Yib481de92007-09-25 17:54:57 -07003329 struct statistics_dbg dbg;
3330 __le32 sleep_time;
3331 __le32 slots_out;
3332 __le32 slots_idle;
3333 __le32 ttl_timestamp;
3334 struct statistics_div div;
Zhu Yib481de92007-09-25 17:54:57 -07003335 __le32 rx_enable_counter;
Wey-Yi Guy11fc5242010-01-15 13:43:35 -08003336 /*
3337 * num_of_sos_states:
3338 * count the number of times we have to re-tune
3339 * in order to get out of bad PHY status
3340 */
3341 __le32 num_of_sos_states;
John W. Linvilleda22f792010-07-26 15:04:12 -04003342} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003343
3344struct statistics_bt_activity {
3345 /* Tx statistics */
3346 __le32 hi_priority_tx_req_cnt;
3347 __le32 hi_priority_tx_denied_cnt;
3348 __le32 lo_priority_tx_req_cnt;
3349 __le32 lo_priority_tx_denied_cnt;
3350 /* Rx statistics */
3351 __le32 hi_priority_rx_req_cnt;
3352 __le32 hi_priority_rx_denied_cnt;
3353 __le32 lo_priority_rx_req_cnt;
3354 __le32 lo_priority_rx_denied_cnt;
John W. Linvilleda22f792010-07-26 15:04:12 -04003355} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003356
3357struct statistics_general {
3358 struct statistics_general_common common;
3359 __le32 reserved2;
3360 __le32 reserved3;
John W. Linvilleda22f792010-07-26 15:04:12 -04003361} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003362
3363struct statistics_general_bt {
3364 struct statistics_general_common common;
3365 struct statistics_bt_activity activity;
Zhu Yib481de92007-09-25 17:54:57 -07003366 __le32 reserved2;
3367 __le32 reserved3;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003368} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003369
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08003370#define UCODE_STATISTICS_CLEAR_MSK (0x1 << 0)
3371#define UCODE_STATISTICS_FREQUENCY_MSK (0x1 << 1)
3372#define UCODE_STATISTICS_NARROW_BAND_MSK (0x1 << 2)
3373
Zhu Yib481de92007-09-25 17:54:57 -07003374/*
3375 * REPLY_STATISTICS_CMD = 0x9c,
Wey-Yi Guy767d0552010-08-23 07:56:53 -07003376 * all devices identical.
Zhu Yib481de92007-09-25 17:54:57 -07003377 *
3378 * This command triggers an immediate response containing uCode statistics.
3379 * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
3380 *
3381 * If the CLEAR_STATS configuration flag is set, uCode will clear its
3382 * internal copy of the statistics (counters) after issuing the response.
3383 * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
3384 *
3385 * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
3386 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
3387 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
3388 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003389#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */
3390#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +08003391struct iwl_statistics_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07003392 __le32 configuration_flags; /* IWL_STATS_CONF_* */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003393} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003394
3395/*
3396 * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
3397 *
3398 * By default, uCode issues this notification after receiving a beacon
3399 * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
3400 * REPLY_STATISTICS_CMD 0x9c, above.
3401 *
3402 * Statistics counters continue to increment beacon after beacon, but are
3403 * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
3404 * 0x9c with CLEAR_STATS bit set (see above).
3405 *
3406 * uCode also issues this notification during scans. uCode clears statistics
3407 * appropriately so that each notification contains statistics for only the
3408 * one channel that has just been scanned.
3409 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003410#define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2)
Wey-Yi Guy7aafef12009-08-07 15:41:38 -07003411#define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8)
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003412
3413struct iwl3945_notif_statistics {
3414 __le32 flag;
3415 struct iwl39_statistics_rx rx;
3416 struct iwl39_statistics_tx tx;
3417 struct iwl39_statistics_general general;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003418} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003419
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +08003420struct iwl_notif_statistics {
Zhu Yib481de92007-09-25 17:54:57 -07003421 __le32 flag;
3422 struct statistics_rx rx;
3423 struct statistics_tx tx;
3424 struct statistics_general general;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003425} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003426
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003427struct iwl_bt_notif_statistics {
3428 __le32 flag;
3429 struct statistics_rx_bt rx;
3430 struct statistics_tx tx;
3431 struct statistics_general_bt general;
John W. Linvilleda22f792010-07-26 15:04:12 -04003432} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003433
3434/*
3435 * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
Wey-Yi Guya13d2762010-01-22 14:22:42 -08003436 *
3437 * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed
3438 * in regardless of how many missed beacons, which mean when driver receive the
3439 * notification, inside the command, it can find all the beacons information
3440 * which include number of total missed beacons, number of consecutive missed
3441 * beacons, number of beacons received and number of beacons expected to
3442 * receive.
3443 *
3444 * If uCode detected consecutive_missed_beacons > 5, it will reset the radio
3445 * in order to bring the radio/PHY back to working state; which has no relation
3446 * to when driver will perform sensitivity calibration.
3447 *
3448 * Driver should set it own missed_beacon_threshold to decide when to perform
3449 * sensitivity calibration based on number of consecutive missed beacons in
3450 * order to improve overall performance, especially in noisy environment.
3451 *
Zhu Yib481de92007-09-25 17:54:57 -07003452 */
Wey-Yi Guya13d2762010-01-22 14:22:42 -08003453
3454#define IWL_MISSED_BEACON_THRESHOLD_MIN (1)
3455#define IWL_MISSED_BEACON_THRESHOLD_DEF (5)
3456#define IWL_MISSED_BEACON_THRESHOLD_MAX IWL_MISSED_BEACON_THRESHOLD_DEF
Zhu Yib481de92007-09-25 17:54:57 -07003457
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08003458struct iwl_missed_beacon_notif {
Wey-Yi Guya13d2762010-01-22 14:22:42 -08003459 __le32 consecutive_missed_beacons;
Zhu Yib481de92007-09-25 17:54:57 -07003460 __le32 total_missed_becons;
3461 __le32 num_expected_beacons;
3462 __le32 num_recvd_beacons;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003463} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003464
Ben Cahillf7d09d72007-11-29 11:09:51 +08003465
Zhu Yib481de92007-09-25 17:54:57 -07003466/******************************************************************************
3467 * (11)
3468 * Rx Calibration Commands:
3469 *
Ben Cahillf7d09d72007-11-29 11:09:51 +08003470 * With the uCode used for open source drivers, most Tx calibration (except
3471 * for Tx Power) and most Rx calibration is done by uCode during the
3472 * "initialize" phase of uCode boot. Driver must calibrate only:
3473 *
3474 * 1) Tx power (depends on temperature), described elsewhere
3475 * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
3476 * 3) Receiver sensitivity (to optimize signal detection)
3477 *
Zhu Yib481de92007-09-25 17:54:57 -07003478 *****************************************************************************/
3479
Ben Cahillf7d09d72007-11-29 11:09:51 +08003480/**
3481 * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
3482 *
3483 * This command sets up the Rx signal detector for a sensitivity level that
3484 * is high enough to lock onto all signals within the associated network,
3485 * but low enough to ignore signals that are below a certain threshold, so as
3486 * not to have too many "false alarms". False alarms are signals that the
3487 * Rx DSP tries to lock onto, but then discards after determining that they
3488 * are noise.
3489 *
3490 * The optimum number of false alarms is between 5 and 50 per 200 TUs
3491 * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
3492 * time listening, not transmitting). Driver must adjust sensitivity so that
3493 * the ratio of actual false alarms to actual Rx time falls within this range.
3494 *
3495 * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
3496 * received beacon. These provide information to the driver to analyze the
3497 * sensitivity. Don't analyze statistics that come in from scanning, or any
3498 * other non-associated-network source. Pertinent statistics include:
3499 *
3500 * From "general" statistics (struct statistics_rx_non_phy):
3501 *
3502 * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
3503 * Measure of energy of desired signal. Used for establishing a level
3504 * below which the device does not detect signals.
3505 *
3506 * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
3507 * Measure of background noise in silent period after beacon.
3508 *
3509 * channel_load
3510 * uSecs of actual Rx time during beacon period (varies according to
3511 * how much time was spent transmitting).
3512 *
3513 * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
3514 *
3515 * false_alarm_cnt
3516 * Signal locks abandoned early (before phy-level header).
3517 *
3518 * plcp_err
3519 * Signal locks abandoned late (during phy-level header).
3520 *
3521 * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
3522 * beacon to beacon, i.e. each value is an accumulation of all errors
3523 * before and including the latest beacon. Values will wrap around to 0
3524 * after counting up to 2^32 - 1. Driver must differentiate vs.
3525 * previous beacon's values to determine # false alarms in the current
3526 * beacon period.
3527 *
3528 * Total number of false alarms = false_alarms + plcp_errs
3529 *
3530 * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
3531 * (notice that the start points for OFDM are at or close to settings for
3532 * maximum sensitivity):
3533 *
3534 * START / MIN / MAX
3535 * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120
3536 * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210
3537 * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140
3538 * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270
3539 *
3540 * If actual rate of OFDM false alarms (+ plcp_errors) is too high
3541 * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
3542 * by *adding* 1 to all 4 of the table entries above, up to the max for
3543 * each entry. Conversely, if false alarm rate is too low (less than 5
3544 * for each 204.8 msecs listening), *subtract* 1 from each entry to
3545 * increase sensitivity.
3546 *
3547 * For CCK sensitivity, keep track of the following:
3548 *
3549 * 1). 20-beacon history of maximum background noise, indicated by
3550 * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
3551 * 3 receivers. For any given beacon, the "silence reference" is
3552 * the maximum of last 60 samples (20 beacons * 3 receivers).
3553 *
3554 * 2). 10-beacon history of strongest signal level, as indicated
3555 * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
3556 * i.e. the strength of the signal through the best receiver at the
3557 * moment. These measurements are "upside down", with lower values
3558 * for stronger signals, so max energy will be *minimum* value.
3559 *
3560 * Then for any given beacon, the driver must determine the *weakest*
3561 * of the strongest signals; this is the minimum level that needs to be
3562 * successfully detected, when using the best receiver at the moment.
3563 * "Max cck energy" is the maximum (higher value means lower energy!)
3564 * of the last 10 minima. Once this is determined, driver must add
3565 * a little margin by adding "6" to it.
3566 *
3567 * 3). Number of consecutive beacon periods with too few false alarms.
3568 * Reset this to 0 at the first beacon period that falls within the
3569 * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
3570 *
3571 * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
3572 * (notice that the start points for CCK are at maximum sensitivity):
3573 *
3574 * START / MIN / MAX
3575 * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200
3576 * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400
3577 * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100
3578 *
3579 * If actual rate of CCK false alarms (+ plcp_errors) is too high
3580 * (greater than 50 for each 204.8 msecs listening), method for reducing
3581 * sensitivity is:
3582 *
3583 * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3584 * up to max 400.
3585 *
3586 * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
3587 * sensitivity has been reduced a significant amount; bring it up to
3588 * a moderate 161. Otherwise, *add* 3, up to max 200.
3589 *
3590 * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
3591 * sensitivity has been reduced only a moderate or small amount;
3592 * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
3593 * down to min 0. Otherwise (if gain has been significantly reduced),
3594 * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
3595 *
3596 * b) Save a snapshot of the "silence reference".
3597 *
3598 * If actual rate of CCK false alarms (+ plcp_errors) is too low
3599 * (less than 5 for each 204.8 msecs listening), method for increasing
3600 * sensitivity is used only if:
3601 *
3602 * 1a) Previous beacon did not have too many false alarms
3603 * 1b) AND difference between previous "silence reference" and current
3604 * "silence reference" (prev - current) is 2 or more,
3605 * OR 2) 100 or more consecutive beacon periods have had rate of
3606 * less than 5 false alarms per 204.8 milliseconds rx time.
3607 *
3608 * Method for increasing sensitivity:
3609 *
3610 * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
3611 * down to min 125.
3612 *
3613 * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3614 * down to min 200.
3615 *
3616 * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
3617 *
3618 * If actual rate of CCK false alarms (+ plcp_errors) is within good range
3619 * (between 5 and 50 for each 204.8 msecs listening):
3620 *
3621 * 1) Save a snapshot of the silence reference.
3622 *
3623 * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
3624 * give some extra margin to energy threshold by *subtracting* 8
3625 * from value in HD_MIN_ENERGY_CCK_DET_INDEX.
3626 *
3627 * For all cases (too few, too many, good range), make sure that the CCK
3628 * detection threshold (energy) is below the energy level for robust
3629 * detection over the past 10 beacon periods, the "Max cck energy".
3630 * Lower values mean higher energy; this means making sure that the value
3631 * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
3632 *
Ben Cahillf7d09d72007-11-29 11:09:51 +08003633 */
Zhu Yib481de92007-09-25 17:54:57 -07003634
Ben Cahillf7d09d72007-11-29 11:09:51 +08003635/*
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003636 * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
Ben Cahillf7d09d72007-11-29 11:09:51 +08003637 */
3638#define HD_TABLE_SIZE (11) /* number of entries */
3639#define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */
3640#define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
3641#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
3642#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
3643#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
3644#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
3645#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
3646#define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
3647#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
3648#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
3649#define HD_OFDM_ENERGY_TH_IN_INDEX (10)
3650
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07003651/*
3652 * Additional table entries in enhance SENSITIVITY_CMD
3653 */
3654#define HD_INA_NON_SQUARE_DET_OFDM_INDEX (11)
3655#define HD_INA_NON_SQUARE_DET_CCK_INDEX (12)
3656#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_INDEX (13)
3657#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_INDEX (14)
3658#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (15)
3659#define HD_OFDM_NON_SQUARE_DET_SLOPE_INDEX (16)
3660#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_INDEX (17)
3661#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_INDEX (18)
3662#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (19)
3663#define HD_CCK_NON_SQUARE_DET_SLOPE_INDEX (20)
3664#define HD_CCK_NON_SQUARE_DET_INTERCEPT_INDEX (21)
3665#define HD_RESERVED (22)
3666
3667/* number of entries for enhanced tbl */
3668#define ENHANCE_HD_TABLE_SIZE (23)
3669
3670/* number of additional entries for enhanced tbl */
3671#define ENHANCE_HD_TABLE_ENTRIES (ENHANCE_HD_TABLE_SIZE - HD_TABLE_SIZE)
3672
3673#define HD_INA_NON_SQUARE_DET_OFDM_DATA cpu_to_le16(0)
3674#define HD_INA_NON_SQUARE_DET_CCK_DATA cpu_to_le16(0)
3675#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA cpu_to_le16(0)
3676#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(668)
3677#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3678#define HD_OFDM_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(486)
3679#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(37)
3680#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(853)
3681#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3682#define HD_CCK_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(476)
3683#define HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(99)
3684
3685
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003686/* Control field in struct iwl_sensitivity_cmd */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003687#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0)
3688#define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1)
Ben Cahillf7d09d72007-11-29 11:09:51 +08003689
3690/**
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003691 * struct iwl_sensitivity_cmd
Ben Cahillf7d09d72007-11-29 11:09:51 +08003692 * @control: (1) updates working table, (0) updates default table
3693 * @table: energy threshold values, use HD_* as index into table
3694 *
3695 * Always use "1" in "control" to update uCode's working table and DSP.
3696 */
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003697struct iwl_sensitivity_cmd {
Ben Cahillf7d09d72007-11-29 11:09:51 +08003698 __le16 control; /* always use "1" */
3699 __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003700} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003701
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07003702/*
3703 *
3704 */
3705struct iwl_enhance_sensitivity_cmd {
3706 __le16 control; /* always use "1" */
3707 __le16 enhance_table[ENHANCE_HD_TABLE_SIZE]; /* use HD_* as index */
John W. Linville0e954092010-07-14 10:37:32 -04003708} __packed;
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07003709
Ben Cahillf7d09d72007-11-29 11:09:51 +08003710
3711/**
3712 * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
3713 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07003714 * This command sets the relative gains of agn device's 3 radio receiver chains.
Ben Cahillf7d09d72007-11-29 11:09:51 +08003715 *
3716 * After the first association, driver should accumulate signal and noise
3717 * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
3718 * beacons from the associated network (don't collect statistics that come
3719 * in from scanning, or any other non-network source).
3720 *
3721 * DISCONNECTED ANTENNA:
3722 *
3723 * Driver should determine which antennas are actually connected, by comparing
3724 * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
3725 * following values over 20 beacons, one accumulator for each of the chains
3726 * a/b/c, from struct statistics_rx_non_phy:
3727 *
3728 * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
3729 *
3730 * Find the strongest signal from among a/b/c. Compare the other two to the
3731 * strongest. If any signal is more than 15 dB (times 20, unless you
3732 * divide the accumulated values by 20) below the strongest, the driver
3733 * considers that antenna to be disconnected, and should not try to use that
3734 * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
3735 * driver should declare the stronger one as connected, and attempt to use it
3736 * (A and B are the only 2 Tx chains!).
3737 *
3738 *
3739 * RX BALANCE:
3740 *
3741 * Driver should balance the 3 receivers (but just the ones that are connected
3742 * to antennas, see above) for gain, by comparing the average signal levels
3743 * detected during the silence after each beacon (background noise).
3744 * Accumulate (add) the following values over 20 beacons, one accumulator for
3745 * each of the chains a/b/c, from struct statistics_rx_non_phy:
3746 *
3747 * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
3748 *
3749 * Find the weakest background noise level from among a/b/c. This Rx chain
3750 * will be the reference, with 0 gain adjustment. Attenuate other channels by
3751 * finding noise difference:
3752 *
3753 * (accum_noise[i] - accum_noise[reference]) / 30
3754 *
3755 * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
3756 * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
3757 * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
3758 * and set bit 2 to indicate "reduce gain". The value for the reference
3759 * (weakest) chain should be "0".
3760 *
3761 * diff_gain_[abc] bit fields:
3762 * 2: (1) reduce gain, (0) increase gain
3763 * 1-0: amount of gain, units of 1.5 dB
3764 */
3765
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003766/* Phy calibration command for series */
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003767
3768enum {
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003769 IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7,
3770 IWL_PHY_CALIBRATE_DC_CMD = 8,
3771 IWL_PHY_CALIBRATE_LO_CMD = 9,
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003772 IWL_PHY_CALIBRATE_TX_IQ_CMD = 11,
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003773 IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15,
3774 IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16,
3775 IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17,
Wey-Yi Guy6a822d02010-07-13 17:13:15 -07003776 IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 18,
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003777};
3778
Wey-Yi Guy6a822d02010-07-13 17:13:15 -07003779#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253)
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003780
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003781#define IWL_CALIB_INIT_CFG_ALL cpu_to_le32(0xffffffff)
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003782
3783struct iwl_calib_cfg_elmnt_s {
3784 __le32 is_enable;
3785 __le32 start;
3786 __le32 send_res;
3787 __le32 apply_res;
3788 __le32 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003789} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003790
3791struct iwl_calib_cfg_status_s {
3792 struct iwl_calib_cfg_elmnt_s once;
3793 struct iwl_calib_cfg_elmnt_s perd;
3794 __le32 flags;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003795} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003796
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003797struct iwl_calib_cfg_cmd {
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003798 struct iwl_calib_cfg_status_s ucd_calib_cfg;
3799 struct iwl_calib_cfg_status_s drv_calib_cfg;
3800 __le32 reserved1;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003801} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003802
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003803struct iwl_calib_hdr {
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003804 u8 op_code;
3805 u8 first_group;
3806 u8 groups_num;
3807 u8 data_valid;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003808} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003809
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003810struct iwl_calib_cmd {
3811 struct iwl_calib_hdr hdr;
Tomas Winklerbe5d56e2008-10-08 09:37:27 +08003812 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003813} __packed;
Tomas Winklerbe5d56e2008-10-08 09:37:27 +08003814
Tomas Winkler0d950d82008-11-25 13:36:01 -08003815/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003816struct iwl_calib_diff_gain_cmd {
Tomas Winkler0d950d82008-11-25 13:36:01 -08003817 struct iwl_calib_hdr hdr;
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003818 s8 diff_gain_a; /* see above */
3819 s8 diff_gain_b;
3820 s8 diff_gain_c;
3821 u8 reserved1;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003822} __packed;
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003823
Tomas Winkler0d950d82008-11-25 13:36:01 -08003824struct iwl_calib_xtal_freq_cmd {
3825 struct iwl_calib_hdr hdr;
3826 u8 cap_pin1;
3827 u8 cap_pin2;
3828 u8 pad[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003829} __packed;
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003830
Tomas Winkler0d950d82008-11-25 13:36:01 -08003831/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
3832struct iwl_calib_chain_noise_reset_cmd {
3833 struct iwl_calib_hdr hdr;
3834 u8 data[0];
3835};
3836
3837/* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003838struct iwl_calib_chain_noise_gain_cmd {
Tomas Winkler0d950d82008-11-25 13:36:01 -08003839 struct iwl_calib_hdr hdr;
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003840 u8 delta_gain_1;
3841 u8 delta_gain_2;
Tomas Winkler0d950d82008-11-25 13:36:01 -08003842 u8 pad[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003843} __packed;
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003844
Zhu Yib481de92007-09-25 17:54:57 -07003845/******************************************************************************
3846 * (12)
3847 * Miscellaneous Commands:
3848 *
3849 *****************************************************************************/
3850
3851/*
3852 * LEDs Command & Response
3853 * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
3854 *
3855 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
3856 * this command turns it on or off, or sets up a periodic blinking cycle.
3857 */
Tomas Winklerec1a7462008-07-11 11:53:37 +08003858struct iwl_led_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07003859 __le32 interval; /* "interval" in uSec */
3860 u8 id; /* 1: Activity, 2: Link, 3: Tech */
3861 u8 off; /* # intervals off while blinking;
3862 * "0", with >0 "on" value, turns LED on */
3863 u8 on; /* # intervals on while blinking;
3864 * "0", regardless of "off", turns LED off */
3865 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003866} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003867
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003868/*
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003869 * station priority table entries
3870 * also used as potential "events" value for both
3871 * COEX_MEDIUM_NOTIFICATION and COEX_EVENT_CMD
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003872 */
Wey-Yi Guy1933ac42009-10-30 14:36:18 -07003873
3874/*
3875 * COEX events entry flag masks
3876 * RP - Requested Priority
3877 * WP - Win Medium Priority: priority assigned when the contention has been won
3878 */
3879#define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG (0x1)
3880#define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG (0x2)
3881#define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG (0x4)
3882
3883#define COEX_CU_UNASSOC_IDLE_RP 4
3884#define COEX_CU_UNASSOC_MANUAL_SCAN_RP 4
3885#define COEX_CU_UNASSOC_AUTO_SCAN_RP 4
3886#define COEX_CU_CALIBRATION_RP 4
3887#define COEX_CU_PERIODIC_CALIBRATION_RP 4
3888#define COEX_CU_CONNECTION_ESTAB_RP 4
3889#define COEX_CU_ASSOCIATED_IDLE_RP 4
3890#define COEX_CU_ASSOC_MANUAL_SCAN_RP 4
3891#define COEX_CU_ASSOC_AUTO_SCAN_RP 4
3892#define COEX_CU_ASSOC_ACTIVE_LEVEL_RP 4
3893#define COEX_CU_RF_ON_RP 6
3894#define COEX_CU_RF_OFF_RP 4
3895#define COEX_CU_STAND_ALONE_DEBUG_RP 6
3896#define COEX_CU_IPAN_ASSOC_LEVEL_RP 4
3897#define COEX_CU_RSRVD1_RP 4
3898#define COEX_CU_RSRVD2_RP 4
3899
3900#define COEX_CU_UNASSOC_IDLE_WP 3
3901#define COEX_CU_UNASSOC_MANUAL_SCAN_WP 3
3902#define COEX_CU_UNASSOC_AUTO_SCAN_WP 3
3903#define COEX_CU_CALIBRATION_WP 3
3904#define COEX_CU_PERIODIC_CALIBRATION_WP 3
3905#define COEX_CU_CONNECTION_ESTAB_WP 3
3906#define COEX_CU_ASSOCIATED_IDLE_WP 3
3907#define COEX_CU_ASSOC_MANUAL_SCAN_WP 3
3908#define COEX_CU_ASSOC_AUTO_SCAN_WP 3
3909#define COEX_CU_ASSOC_ACTIVE_LEVEL_WP 3
3910#define COEX_CU_RF_ON_WP 3
3911#define COEX_CU_RF_OFF_WP 3
3912#define COEX_CU_STAND_ALONE_DEBUG_WP 6
3913#define COEX_CU_IPAN_ASSOC_LEVEL_WP 3
3914#define COEX_CU_RSRVD1_WP 3
3915#define COEX_CU_RSRVD2_WP 3
3916
3917#define COEX_UNASSOC_IDLE_FLAGS 0
3918#define COEX_UNASSOC_MANUAL_SCAN_FLAGS \
3919 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3920 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3921#define COEX_UNASSOC_AUTO_SCAN_FLAGS \
3922 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3923 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3924#define COEX_CALIBRATION_FLAGS \
3925 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3926 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3927#define COEX_PERIODIC_CALIBRATION_FLAGS 0
3928/*
3929 * COEX_CONNECTION_ESTAB:
3930 * we need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
3931 */
3932#define COEX_CONNECTION_ESTAB_FLAGS \
3933 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3934 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3935 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
3936#define COEX_ASSOCIATED_IDLE_FLAGS 0
3937#define COEX_ASSOC_MANUAL_SCAN_FLAGS \
3938 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3939 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3940#define COEX_ASSOC_AUTO_SCAN_FLAGS \
3941 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3942 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3943#define COEX_ASSOC_ACTIVE_LEVEL_FLAGS 0
3944#define COEX_RF_ON_FLAGS 0
3945#define COEX_RF_OFF_FLAGS 0
3946#define COEX_STAND_ALONE_DEBUG_FLAGS \
3947 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3948 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3949#define COEX_IPAN_ASSOC_LEVEL_FLAGS \
3950 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3951 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3952 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
3953#define COEX_RSRVD1_FLAGS 0
3954#define COEX_RSRVD2_FLAGS 0
3955/*
3956 * COEX_CU_RF_ON is the event wrapping all radio ownership.
3957 * We need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
3958 */
3959#define COEX_CU_RF_ON_FLAGS \
3960 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3961 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3962 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
3963
3964
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003965enum {
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003966 /* un-association part */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003967 COEX_UNASSOC_IDLE = 0,
3968 COEX_UNASSOC_MANUAL_SCAN = 1,
3969 COEX_UNASSOC_AUTO_SCAN = 2,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003970 /* calibration */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003971 COEX_CALIBRATION = 3,
3972 COEX_PERIODIC_CALIBRATION = 4,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003973 /* connection */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003974 COEX_CONNECTION_ESTAB = 5,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003975 /* association part */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003976 COEX_ASSOCIATED_IDLE = 6,
3977 COEX_ASSOC_MANUAL_SCAN = 7,
3978 COEX_ASSOC_AUTO_SCAN = 8,
3979 COEX_ASSOC_ACTIVE_LEVEL = 9,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003980 /* RF ON/OFF */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003981 COEX_RF_ON = 10,
3982 COEX_RF_OFF = 11,
3983 COEX_STAND_ALONE_DEBUG = 12,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003984 /* IPAN */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003985 COEX_IPAN_ASSOC_LEVEL = 13,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003986 /* reserved */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003987 COEX_RSRVD1 = 14,
3988 COEX_RSRVD2 = 15,
3989 COEX_NUM_OF_EVENTS = 16
3990};
3991
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003992/*
3993 * Coexistence WIFI/WIMAX Command
3994 * COEX_PRIORITY_TABLE_CMD = 0x5a
3995 *
3996 */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003997struct iwl_wimax_coex_event_entry {
3998 u8 request_prio;
3999 u8 win_medium_prio;
4000 u8 reserved;
4001 u8 flags;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004002} __packed;
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004003
4004/* COEX flag masks */
4005
Tomas Winklera96a27f2008-10-23 23:48:56 -07004006/* Station table is valid */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004007#define COEX_FLAGS_STA_TABLE_VALID_MSK (0x1)
Tomas Winklera96a27f2008-10-23 23:48:56 -07004008/* UnMask wake up src at unassociated sleep */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004009#define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK (0x4)
Tomas Winklera96a27f2008-10-23 23:48:56 -07004010/* UnMask wake up src at associated sleep */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004011#define COEX_FLAGS_ASSOC_WA_UNMASK_MSK (0x8)
4012/* Enable CoEx feature. */
4013#define COEX_FLAGS_COEX_ENABLE_MSK (0x80)
4014
4015struct iwl_wimax_coex_cmd {
4016 u8 flags;
4017 u8 reserved[3];
4018 struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
Eric Dumazetba2d3582010-06-02 18:10:09 +00004019} __packed;
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004020
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004021/*
4022 * Coexistence MEDIUM NOTIFICATION
4023 * COEX_MEDIUM_NOTIFICATION = 0x5b
4024 *
4025 * notification from uCode to host to indicate medium changes
4026 *
4027 */
4028/*
4029 * status field
4030 * bit 0 - 2: medium status
4031 * bit 3: medium change indication
4032 * bit 4 - 31: reserved
4033 */
4034/* status option values, (0 - 2 bits) */
4035#define COEX_MEDIUM_BUSY (0x0) /* radio belongs to WiMAX */
4036#define COEX_MEDIUM_ACTIVE (0x1) /* radio belongs to WiFi */
4037#define COEX_MEDIUM_PRE_RELEASE (0x2) /* received radio release */
4038#define COEX_MEDIUM_MSK (0x7)
4039
4040/* send notification status (1 bit) */
4041#define COEX_MEDIUM_CHANGED (0x8)
4042#define COEX_MEDIUM_CHANGED_MSK (0x8)
4043#define COEX_MEDIUM_SHIFT (3)
4044
4045struct iwl_coex_medium_notification {
4046 __le32 status;
4047 __le32 events;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004048} __packed;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004049
4050/*
4051 * Coexistence EVENT Command
4052 * COEX_EVENT_CMD = 0x5c
4053 *
4054 * send from host to uCode for coex event request.
4055 */
4056/* flags options */
4057#define COEX_EVENT_REQUEST_MSK (0x1)
4058
4059struct iwl_coex_event_cmd {
4060 u8 flags;
4061 u8 event;
4062 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004063} __packed;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004064
4065struct iwl_coex_event_resp {
4066 __le32 status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004067} __packed;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004068
4069
Zhu Yib481de92007-09-25 17:54:57 -07004070/******************************************************************************
Johannes Berg0288d232010-08-23 07:56:54 -07004071 * Bluetooth Coexistence commands
4072 *
4073 *****************************************************************************/
4074
4075/*
4076 * BT Status notification
Wey-Yi Guyfbba9412010-08-23 07:57:10 -07004077 * REPLY_BT_COEX_PROFILE_NOTIF = 0xce
Johannes Berg0288d232010-08-23 07:56:54 -07004078 */
4079enum iwl_bt_coex_profile_traffic_load {
4080 IWL_BT_COEX_TRAFFIC_LOAD_NONE = 0,
4081 IWL_BT_COEX_TRAFFIC_LOAD_LOW = 1,
4082 IWL_BT_COEX_TRAFFIC_LOAD_HIGH = 2,
4083 IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS = 3,
4084/*
4085 * There are no more even though below is a u8, the
4086 * indication from the BT device only has two bits.
4087 */
4088};
4089
Wey-Yi Guyfbba9412010-08-23 07:57:10 -07004090#define BT_UART_MSG_FRAME1MSGTYPE_POS (0)
4091#define BT_UART_MSG_FRAME1MSGTYPE_MSK \
4092 (0x7 << BT_UART_MSG_FRAME1MSGTYPE_POS)
4093#define BT_UART_MSG_FRAME1SSN_POS (3)
4094#define BT_UART_MSG_FRAME1SSN_MSK \
4095 (0x3 << BT_UART_MSG_FRAME1SSN_POS)
4096#define BT_UART_MSG_FRAME1UPDATEREQ_POS (5)
4097#define BT_UART_MSG_FRAME1UPDATEREQ_MSK \
4098 (0x1 << BT_UART_MSG_FRAME1UPDATEREQ_POS)
4099#define BT_UART_MSG_FRAME1RESERVED_POS (6)
4100#define BT_UART_MSG_FRAME1RESERVED_MSK \
4101 (0x3 << BT_UART_MSG_FRAME1RESERVED_POS)
4102
4103#define BT_UART_MSG_FRAME2OPENCONNECTIONS_POS (0)
4104#define BT_UART_MSG_FRAME2OPENCONNECTIONS_MSK \
4105 (0x3 << BT_UART_MSG_FRAME2OPENCONNECTIONS_POS)
4106#define BT_UART_MSG_FRAME2TRAFFICLOAD_POS (2)
4107#define BT_UART_MSG_FRAME2TRAFFICLOAD_MSK \
4108 (0x3 << BT_UART_MSG_FRAME2TRAFFICLOAD_POS)
4109#define BT_UART_MSG_FRAME2CHLSEQN_POS (4)
4110#define BT_UART_MSG_FRAME2CHLSEQN_MSK \
4111 (0x1 << BT_UART_MSG_FRAME2CHLSEQN_POS)
4112#define BT_UART_MSG_FRAME2INBAND_POS (5)
4113#define BT_UART_MSG_FRAME2INBAND_MSK \
4114 (0x1 << BT_UART_MSG_FRAME2INBAND_POS)
4115#define BT_UART_MSG_FRAME2RESERVED_POS (6)
4116#define BT_UART_MSG_FRAME2RESERVED_MSK \
4117 (0x3 << BT_UART_MSG_FRAME2RESERVED_POS)
4118
4119#define BT_UART_MSG_FRAME3SCOESCO_POS (0)
4120#define BT_UART_MSG_FRAME3SCOESCO_MSK \
4121 (0x1 << BT_UART_MSG_FRAME3SCOESCO_POS)
4122#define BT_UART_MSG_FRAME3SNIFF_POS (1)
4123#define BT_UART_MSG_FRAME3SNIFF_MSK \
4124 (0x1 << BT_UART_MSG_FRAME3SNIFF_POS)
4125#define BT_UART_MSG_FRAME3A2DP_POS (2)
4126#define BT_UART_MSG_FRAME3A2DP_MSK \
4127 (0x1 << BT_UART_MSG_FRAME3A2DP_POS)
4128#define BT_UART_MSG_FRAME3ACL_POS (3)
4129#define BT_UART_MSG_FRAME3ACL_MSK \
4130 (0x1 << BT_UART_MSG_FRAME3ACL_POS)
4131#define BT_UART_MSG_FRAME3MASTER_POS (4)
4132#define BT_UART_MSG_FRAME3MASTER_MSK \
4133 (0x1 << BT_UART_MSG_FRAME3MASTER_POS)
4134#define BT_UART_MSG_FRAME3OBEX_POS (5)
4135#define BT_UART_MSG_FRAME3OBEX_MSK \
4136 (0x1 << BT_UART_MSG_FRAME3OBEX_POS)
4137#define BT_UART_MSG_FRAME3RESERVED_POS (6)
4138#define BT_UART_MSG_FRAME3RESERVED_MSK \
4139 (0x3 << BT_UART_MSG_FRAME3RESERVED_POS)
4140
4141#define BT_UART_MSG_FRAME4IDLEDURATION_POS (0)
4142#define BT_UART_MSG_FRAME4IDLEDURATION_MSK \
4143 (0x3F << BT_UART_MSG_FRAME4IDLEDURATION_POS)
4144#define BT_UART_MSG_FRAME4RESERVED_POS (6)
4145#define BT_UART_MSG_FRAME4RESERVED_MSK \
4146 (0x3 << BT_UART_MSG_FRAME4RESERVED_POS)
4147
4148#define BT_UART_MSG_FRAME5TXACTIVITY_POS (0)
4149#define BT_UART_MSG_FRAME5TXACTIVITY_MSK \
4150 (0x3 << BT_UART_MSG_FRAME5TXACTIVITY_POS)
4151#define BT_UART_MSG_FRAME5RXACTIVITY_POS (2)
4152#define BT_UART_MSG_FRAME5RXACTIVITY_MSK \
4153 (0x3 << BT_UART_MSG_FRAME5RXACTIVITY_POS)
4154#define BT_UART_MSG_FRAME5ESCORETRANSMIT_POS (4)
4155#define BT_UART_MSG_FRAME5ESCORETRANSMIT_MSK \
4156 (0x3 << BT_UART_MSG_FRAME5ESCORETRANSMIT_POS)
4157#define BT_UART_MSG_FRAME5RESERVED_POS (6)
4158#define BT_UART_MSG_FRAME5RESERVED_MSK \
4159 (0x3 << BT_UART_MSG_FRAME5RESERVED_POS)
4160
4161#define BT_UART_MSG_FRAME6SNIFFINTERVAL_POS (0)
4162#define BT_UART_MSG_FRAME6SNIFFINTERVAL_MSK \
4163 (0x1F << BT_UART_MSG_FRAME6SNIFFINTERVAL_POS)
4164#define BT_UART_MSG_FRAME6DISCOVERABLE_POS (5)
4165#define BT_UART_MSG_FRAME6DISCOVERABLE_MSK \
4166 (0x1 << BT_UART_MSG_FRAME6DISCOVERABLE_POS)
4167#define BT_UART_MSG_FRAME6RESERVED_POS (6)
4168#define BT_UART_MSG_FRAME6RESERVED_MSK \
4169 (0x3 << BT_UART_MSG_FRAME6RESERVED_POS)
4170
4171#define BT_UART_MSG_FRAME7SNIFFACTIVITY_POS (0)
4172#define BT_UART_MSG_FRAME7SNIFFACTIVITY_MSK \
4173 (0x7 << BT_UART_MSG_FRAME7SNIFFACTIVITY_POS)
4174#define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS (3)
4175#define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_MSK \
4176 (0x3 << BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS)
4177#define BT_UART_MSG_FRAME7CONNECTABLE_POS (5)
4178#define BT_UART_MSG_FRAME7CONNECTABLE_MSK \
4179 (0x1 << BT_UART_MSG_FRAME7CONNECTABLE_POS)
4180#define BT_UART_MSG_FRAME7RESERVED_POS (6)
4181#define BT_UART_MSG_FRAME7RESERVED_MSK \
4182 (0x3 << BT_UART_MSG_FRAME7RESERVED_POS)
4183
4184
4185struct iwl_bt_uart_msg {
4186 u8 header;
4187 u8 frame1;
4188 u8 frame2;
4189 u8 frame3;
4190 u8 frame4;
4191 u8 frame5;
4192 u8 frame6;
4193 u8 frame7;
4194} __attribute__((packed));
4195
Johannes Berg0288d232010-08-23 07:56:54 -07004196struct iwl_bt_coex_profile_notif {
Wey-Yi Guyfbba9412010-08-23 07:57:10 -07004197 struct iwl_bt_uart_msg last_bt_uart_msg;
Johannes Berg0288d232010-08-23 07:56:54 -07004198 u8 bt_status; /* 0 - off, 1 - on */
4199 u8 bt_traffic_load; /* 0 .. 3? */
4200 u8 bt_ci_compliance; /* 0 - not complied, 1 - complied */
4201 u8 reserved;
4202} __attribute__((packed));
4203
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004204#define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS 0
4205#define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_MSK 0x1
4206#define IWL_BT_COEX_PRIO_TBL_PRIO_POS 1
4207#define IWL_BT_COEX_PRIO_TBL_PRIO_MASK 0x0e
4208#define IWL_BT_COEX_PRIO_TBL_RESERVED_POS 4
4209#define IWL_BT_COEX_PRIO_TBL_RESERVED_MASK 0xf0
4210#define IWL_BT_COEX_PRIO_TBL_PRIO_SHIFT 1
Johannes Berg0288d232010-08-23 07:56:54 -07004211
4212/*
4213 * BT Coexistence Priority table
4214 * REPLY_BT_COEX_PRIO_TABLE = 0xcc
4215 */
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004216enum bt_coex_prio_table_events {
4217 BT_COEX_PRIO_TBL_EVT_INIT_CALIB1 = 0,
4218 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2 = 1,
4219 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW1 = 2,
4220 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW2 = 3, /* DC calib */
4221 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH1 = 4,
4222 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH2 = 5,
4223 BT_COEX_PRIO_TBL_EVT_DTIM = 6,
4224 BT_COEX_PRIO_TBL_EVT_SCAN52 = 7,
4225 BT_COEX_PRIO_TBL_EVT_SCAN24 = 8,
4226 BT_COEX_PRIO_TBL_EVT_RESERVED0 = 9,
4227 BT_COEX_PRIO_TBL_EVT_RESERVED1 = 10,
4228 BT_COEX_PRIO_TBL_EVT_RESERVED2 = 11,
4229 BT_COEX_PRIO_TBL_EVT_RESERVED3 = 12,
4230 BT_COEX_PRIO_TBL_EVT_RESERVED4 = 13,
4231 BT_COEX_PRIO_TBL_EVT_RESERVED5 = 14,
4232 BT_COEX_PRIO_TBL_EVT_RESERVED6 = 15,
4233 /* BT_COEX_PRIO_TBL_EVT_MAX should always be last */
4234 BT_COEX_PRIO_TBL_EVT_MAX,
4235};
4236
4237enum bt_coex_prio_table_priorities {
4238 BT_COEX_PRIO_TBL_DISABLED = 0,
4239 BT_COEX_PRIO_TBL_PRIO_LOW = 1,
4240 BT_COEX_PRIO_TBL_PRIO_HIGH = 2,
4241 BT_COEX_PRIO_TBL_PRIO_BYPASS = 3,
4242 BT_COEX_PRIO_TBL_PRIO_COEX_OFF = 4,
4243 BT_COEX_PRIO_TBL_PRIO_COEX_ON = 5,
4244 BT_COEX_PRIO_TBL_PRIO_RSRVD1 = 6,
4245 BT_COEX_PRIO_TBL_PRIO_RSRVD2 = 7,
4246 BT_COEX_PRIO_TBL_MAX,
4247};
4248
Johannes Berg0288d232010-08-23 07:56:54 -07004249struct iwl_bt_coex_prio_table_cmd {
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004250 u8 prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX];
Johannes Berg0288d232010-08-23 07:56:54 -07004251} __attribute__((packed));
4252
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004253#define IWL_BT_COEX_ENV_CLOSE 0
4254#define IWL_BT_COEX_ENV_OPEN 1
Johannes Berg0288d232010-08-23 07:56:54 -07004255/*
4256 * BT Protection Envelope
4257 * REPLY_BT_COEX_PROT_ENV = 0xcd
4258 */
4259struct iwl_bt_coex_prot_env_cmd {
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004260 u8 action; /* 0 = closed, 1 = open */
Johannes Berg0288d232010-08-23 07:56:54 -07004261 u8 type; /* 0 .. 15 */
4262 u8 reserved[2];
4263} __attribute__((packed));
4264
4265/******************************************************************************
Zhu Yib481de92007-09-25 17:54:57 -07004266 * (13)
4267 * Union of all expected notifications/responses:
4268 *
4269 *****************************************************************************/
4270
Tomas Winklerdb11d632008-05-05 10:22:33 +08004271struct iwl_rx_packet {
Zhu Yi2f301222009-10-09 17:19:45 +08004272 /*
4273 * The first 4 bytes of the RX frame header contain both the RX frame
4274 * size and some flags.
4275 * Bit fields:
4276 * 31: flag flush RB request
4277 * 30: flag ignore TC (terminal counter) request
4278 * 29: flag fast IRQ request
4279 * 28-14: Reserved
4280 * 13-00: RX frame size
4281 */
Daniel C Halperin396887a2009-08-13 13:31:01 -07004282 __le32 len_n_flags;
Tomas Winkler857485c2008-03-21 13:53:44 -07004283 struct iwl_cmd_header hdr;
Zhu Yib481de92007-09-25 17:54:57 -07004284 union {
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08004285 struct iwl3945_rx_frame rx_frame;
4286 struct iwl3945_tx_resp tx_resp;
4287 struct iwl3945_beacon_notif beacon_status;
4288
Tomas Winkler885ba202008-05-29 16:34:55 +08004289 struct iwl_alive_resp alive_frame;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004290 struct iwl_spectrum_notification spectrum_notif;
4291 struct iwl_csa_notification csa_notif;
Tomas Winkler885ba202008-05-29 16:34:55 +08004292 struct iwl_error_resp err_resp;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004293 struct iwl_card_state_notif card_state_notif;
Tomas Winkler7a999bf2008-05-29 16:35:02 +08004294 struct iwl_add_sta_resp add_sta;
4295 struct iwl_rem_sta_resp rem_sta;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004296 struct iwl_sleep_notification sleep_notif;
4297 struct iwl_spectrum_resp spectrum;
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +08004298 struct iwl_notif_statistics stats;
Wey-Yi Guy7980fba2010-07-14 08:08:57 -07004299 struct iwl_bt_notif_statistics stats_bt;
Emmanuel Grumbach653fa4a2008-06-30 17:23:11 +08004300 struct iwl_compressed_ba_resp compressed_ba;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004301 struct iwl_missed_beacon_notif missed_beacon;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004302 struct iwl_coex_medium_notification coex_medium_notif;
4303 struct iwl_coex_event_resp coex_event;
Johannes Berg0288d232010-08-23 07:56:54 -07004304 struct iwl_bt_coex_profile_notif bt_coex_profile_notif;
Zhu Yib481de92007-09-25 17:54:57 -07004305 __le32 status;
4306 u8 raw[0];
4307 } u;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004308} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07004309
Samuel Ortiza3139c52008-12-19 10:37:09 +08004310int iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
Winkler, Tomas8f5c87d2008-12-02 12:13:57 -08004311
Emmanuel Grumbach6a635782008-10-29 14:05:47 -07004312#endif /* __iwl_commands_h__ */