blob: c3ab6ba5b45a4eb85a3c2e5a95c2038980aff113 [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
Johannes Berg946ba302010-08-23 10:46:48 +0200183 /* PAN commands */
184 REPLY_WIPAN_PARAMS = 0xb2,
185 REPLY_WIPAN_RXON = 0xb3, /* use REPLY_RXON structure */
186 REPLY_WIPAN_RXON_TIMING = 0xb4, /* use REPLY_RXON_TIMING structure */
187 REPLY_WIPAN_RXON_ASSOC = 0xb6, /* use REPLY_RXON_ASSOC structure */
188 REPLY_WIPAN_QOS_PARAM = 0xb7, /* use REPLY_QOS_PARAM structure */
189 REPLY_WIPAN_WEPKEY = 0xb8, /* use REPLY_WEPKEY structure */
190 REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9,
191 REPLY_WIPAN_NOA_NOTIFICATION = 0xbc,
Johannes Berg311dce72011-01-04 16:22:01 -0800192 REPLY_WIPAN_DEACTIVATION_COMPLETE = 0xbd,
Johannes Berg946ba302010-08-23 10:46:48 +0200193
Zhu Yib481de92007-09-25 17:54:57 -0700194 REPLY_MAX = 0xff
195};
196
197/******************************************************************************
198 * (0)
Ben Cahillabceddb2007-11-29 11:09:50 +0800199 * Commonly used structures and definitions:
Ben Cahill80cc0c32007-11-29 11:10:09 +0800200 * Command header, rate_n_flags, txpower
Zhu Yib481de92007-09-25 17:54:57 -0700201 *
202 *****************************************************************************/
203
Tomas Winkler857485c2008-03-21 13:53:44 -0700204/* iwl_cmd_header flags value */
Zhu Yib481de92007-09-25 17:54:57 -0700205#define IWL_CMD_FAILED_MSK 0x40
206
Tomas Winkler9734cb22008-09-03 11:26:52 +0800207#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f)
208#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8)
209#define SEQ_TO_INDEX(s) ((s) & 0xff)
210#define INDEX_TO_SEQ(i) ((i) & 0xff)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800211#define SEQ_HUGE_FRAME cpu_to_le16(0x4000)
212#define SEQ_RX_FRAME cpu_to_le16(0x8000)
Tomas Winkler9734cb22008-09-03 11:26:52 +0800213
Ben Cahill075416c2007-11-29 11:10:08 +0800214/**
Tomas Winkler857485c2008-03-21 13:53:44 -0700215 * struct iwl_cmd_header
Ben Cahill075416c2007-11-29 11:10:08 +0800216 *
217 * This header format appears in the beginning of each command sent from the
218 * driver, and each response/notification received from uCode.
219 */
Tomas Winkler857485c2008-03-21 13:53:44 -0700220struct iwl_cmd_header {
Ben Cahill075416c2007-11-29 11:10:08 +0800221 u8 cmd; /* Command ID: REPLY_RXON, etc. */
Tomas Winkler9734cb22008-09-03 11:26:52 +0800222 u8 flags; /* 0:5 reserved, 6 abort, 7 internal */
Ben Cahill075416c2007-11-29 11:10:08 +0800223 /*
Tomas Winklera96a27f2008-10-23 23:48:56 -0700224 * The driver sets up the sequence number to values of its choosing.
Ben Cahill075416c2007-11-29 11:10:08 +0800225 * uCode does not use this value, but passes it back to the driver
226 * when sending the response to each driver-originated command, so
227 * the driver can match the response to the command. Since the values
228 * don't get used by uCode, the driver may set up an arbitrary format.
Zhu Yib481de92007-09-25 17:54:57 -0700229 *
Ben Cahill075416c2007-11-29 11:10:08 +0800230 * There is one exception: uCode sets bit 15 when it originates
231 * the response/notification, i.e. when the response/notification
232 * is not a direct response to a command sent by the driver. For
233 * example, uCode issues REPLY_3945_RX when it sends a received frame
234 * to the driver; it is not a direct response to any driver command.
Zhu Yib481de92007-09-25 17:54:57 -0700235 *
Ben Cahill075416c2007-11-29 11:10:08 +0800236 * The Linux driver uses the following format:
237 *
Tomas Winkler9734cb22008-09-03 11:26:52 +0800238 * 0:7 tfd index - position within TX queue
239 * 8:12 TX queue id
240 * 13 reserved
241 * 14 huge - driver sets this to indicate command is in the
242 * 'huge' storage at the end of the command buffers
243 * 15 unsolicited RX or uCode-originated notification
Zhu Yib481de92007-09-25 17:54:57 -0700244 */
245 __le16 sequence;
246
Ben Cahill075416c2007-11-29 11:10:08 +0800247 /* command or response/notification data follows immediately */
Zhu Yib481de92007-09-25 17:54:57 -0700248 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000249} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700250
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800251
252/**
253 * struct iwl3945_tx_power
254 *
255 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH
256 *
257 * Each entry contains two values:
258 * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
259 * linear value that multiplies the output of the digital signal processor,
260 * before being sent to the analog radio.
261 * 2) Radio gain. This sets the analog gain of the radio Tx path.
262 * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
263 *
264 * Driver obtains values from struct iwl3945_tx_power power_gain_table[][].
265 */
266struct iwl3945_tx_power {
267 u8 tx_gain; /* gain for analog radio */
268 u8 dsp_atten; /* gain for DSP */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000269} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800270
271/**
272 * struct iwl3945_power_per_rate
273 *
274 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
275 */
276struct iwl3945_power_per_rate {
277 u8 rate; /* plcp */
278 struct iwl3945_tx_power tpc;
279 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000280} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800281
Ben Cahillabceddb2007-11-29 11:09:50 +0800282/**
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800283 * iwlagn rate_n_flags bit fields
Ben Cahillabceddb2007-11-29 11:09:50 +0800284 *
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800285 * rate_n_flags format is used in following iwlagn commands:
Tomas Winkler857485c2008-03-21 13:53:44 -0700286 * REPLY_RX (response only)
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800287 * REPLY_RX_MPDU (response only)
Ben Cahillabceddb2007-11-29 11:09:50 +0800288 * REPLY_TX (both command and response)
289 * REPLY_TX_LINK_QUALITY_CMD
290 *
291 * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
292 * 2-0: 0) 6 Mbps
293 * 1) 12 Mbps
294 * 2) 18 Mbps
295 * 3) 24 Mbps
296 * 4) 36 Mbps
297 * 5) 48 Mbps
298 * 6) 54 Mbps
299 * 7) 60 Mbps
300 *
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800301 * 4-3: 0) Single stream (SISO)
Ben Cahillabceddb2007-11-29 11:09:50 +0800302 * 1) Dual stream (MIMO)
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800303 * 2) Triple stream (MIMO)
Ben Cahillabceddb2007-11-29 11:09:50 +0800304 *
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700305 * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
Ben Cahillabceddb2007-11-29 11:09:50 +0800306 *
307 * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
308 * 3-0: 0xD) 6 Mbps
309 * 0xF) 9 Mbps
310 * 0x5) 12 Mbps
311 * 0x7) 18 Mbps
312 * 0x9) 24 Mbps
313 * 0xB) 36 Mbps
314 * 0x1) 48 Mbps
315 * 0x3) 54 Mbps
316 *
317 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
Daniel Wu10617872008-12-20 10:53:29 -0800318 * 6-0: 10) 1 Mbps
Ben Cahillabceddb2007-11-29 11:09:50 +0800319 * 20) 2 Mbps
320 * 55) 5.5 Mbps
321 * 110) 11 Mbps
322 */
323#define RATE_MCS_CODE_MSK 0x7
Halperin, Daniel C5c5aa3f2008-11-07 09:58:38 -0800324#define RATE_MCS_SPATIAL_POS 3
325#define RATE_MCS_SPATIAL_MSK 0x18
Ben Cahillabceddb2007-11-29 11:09:50 +0800326#define RATE_MCS_HT_DUP_POS 5
327#define RATE_MCS_HT_DUP_MSK 0x20
328
Ben Cahill075416c2007-11-29 11:10:08 +0800329/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
Ben Cahillabceddb2007-11-29 11:09:50 +0800330#define RATE_MCS_FLAGS_POS 8
331#define RATE_MCS_HT_POS 8
332#define RATE_MCS_HT_MSK 0x100
333
Ben Cahill075416c2007-11-29 11:10:08 +0800334/* 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 +0800335#define RATE_MCS_CCK_POS 9
336#define RATE_MCS_CCK_MSK 0x200
337
Ben Cahill075416c2007-11-29 11:10:08 +0800338/* Bit 10: (1) Use Green Field preamble */
Ben Cahillabceddb2007-11-29 11:09:50 +0800339#define RATE_MCS_GF_POS 10
340#define RATE_MCS_GF_MSK 0x400
341
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700342/* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */
343#define RATE_MCS_HT40_POS 11
344#define RATE_MCS_HT40_MSK 0x800
Ben Cahillabceddb2007-11-29 11:09:50 +0800345
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700346/* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */
Ben Cahillabceddb2007-11-29 11:09:50 +0800347#define RATE_MCS_DUP_POS 12
348#define RATE_MCS_DUP_MSK 0x1000
349
Ben Cahill075416c2007-11-29 11:10:08 +0800350/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
Ben Cahillabceddb2007-11-29 11:09:50 +0800351#define RATE_MCS_SGI_POS 13
352#define RATE_MCS_SGI_MSK 0x2000
353
354/**
Tomas Winkler76eff182008-10-14 12:32:45 -0700355 * rate_n_flags Tx antenna masks
356 * 4965 has 2 transmitters
357 * 5100 has 1 transmitter B
358 * 5150 has 1 transmitter A
359 * 5300 has 3 transmitters
360 * 5350 has 3 transmitters
361 * bit14:16
Ben Cahillabceddb2007-11-29 11:09:50 +0800362 */
Tomas Winkler600c0e12008-12-19 10:37:04 +0800363#define RATE_MCS_ANT_POS 14
364#define RATE_MCS_ANT_A_MSK 0x04000
365#define RATE_MCS_ANT_B_MSK 0x08000
366#define RATE_MCS_ANT_C_MSK 0x10000
367#define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK)
368#define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK)
Tomas Winkler76eff182008-10-14 12:32:45 -0700369#define RATE_ANT_NUM 3
Ben Cahill80cc0c32007-11-29 11:10:09 +0800370
371#define POWER_TABLE_NUM_ENTRIES 33
372#define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
373#define POWER_TABLE_CCK_ENTRY 32
374
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700375#define IWL_PWR_NUM_HT_OFDM_ENTRIES 24
376#define IWL_PWR_CCK_ENTRIES 2
377
Ben Cahill80cc0c32007-11-29 11:10:09 +0800378/**
379 * union iwl4965_tx_power_dual_stream
380 *
381 * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
382 * Use __le32 version (struct tx_power_dual_stream) when building command.
383 *
384 * Driver provides radio gain and DSP attenuation settings to device in pairs,
385 * one value for each transmitter chain. The first value is for transmitter A,
386 * second for transmitter B.
387 *
388 * For SISO bit rates, both values in a pair should be identical.
389 * For MIMO rates, one value may be different from the other,
390 * in order to balance the Tx output between the two transmitters.
391 *
392 * See more details in doc for TXPOWER in iwl-4965-hw.h.
393 */
394union iwl4965_tx_power_dual_stream {
395 struct {
396 u8 radio_tx_gain[2];
397 u8 dsp_predis_atten[2];
398 } s;
399 u32 dw;
400};
401
402/**
403 * struct tx_power_dual_stream
404 *
405 * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
406 *
407 * Same format as iwl_tx_power_dual_stream, but __le32
408 */
409struct tx_power_dual_stream {
410 __le32 dw;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000411} __packed;
Ben Cahill80cc0c32007-11-29 11:10:09 +0800412
413/**
414 * struct iwl4965_tx_power_db
415 *
416 * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
417 */
418struct iwl4965_tx_power_db {
419 struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000420} __packed;
Ben Cahill80cc0c32007-11-29 11:10:09 +0800421
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800422/**
Tomas Winklera96a27f2008-10-23 23:48:56 -0700423 * Command REPLY_TX_POWER_DBM_CMD = 0x98
Wey-Yi Guyab63c682010-09-20 09:12:31 -0700424 * struct iwlagn_tx_power_dbm_cmd
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800425 */
Wey-Yi Guyab63c682010-09-20 09:12:31 -0700426#define IWLAGN_TX_POWER_AUTO 0x7f
427#define IWLAGN_TX_POWER_NO_CLOSED (0x1 << 6)
Gregory Greenman853554a2008-06-30 17:23:01 +0800428
Wey-Yi Guyab63c682010-09-20 09:12:31 -0700429struct iwlagn_tx_power_dbm_cmd {
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800430 s8 global_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
431 u8 flags;
432 s8 srv_chan_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
433 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000434} __packed;
Ben Cahill80cc0c32007-11-29 11:10:09 +0800435
Wey-Yi Guy2f748de2009-09-17 10:43:51 -0700436/**
437 * Command TX_ANT_CONFIGURATION_CMD = 0x98
438 * This command is used to configure valid Tx antenna.
439 * By default uCode concludes the valid antenna according to the radio flavor.
440 * This command enables the driver to override/modify this conclusion.
441 */
442struct iwl_tx_ant_config_cmd {
443 __le32 valid;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000444} __packed;
Wey-Yi Guy2f748de2009-09-17 10:43:51 -0700445
Zhu Yib481de92007-09-25 17:54:57 -0700446/******************************************************************************
447 * (0a)
448 * Alive and Error Commands & Responses:
449 *
450 *****************************************************************************/
451
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800452#define UCODE_VALID_OK cpu_to_le32(0x1)
Zhu Yib481de92007-09-25 17:54:57 -0700453#define INITIALIZE_SUBTYPE (9)
454
455/*
Ben Cahill075416c2007-11-29 11:10:08 +0800456 * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command)
457 *
458 * uCode issues this "initialize alive" notification once the initialization
459 * uCode image has completed its work, and is ready to load the runtime image.
460 * This is the *first* "alive" notification that the driver will receive after
461 * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
462 *
463 * See comments documenting "BSM" (bootstrap state machine).
464 *
465 * For 4965, this notification contains important calibration data for
466 * calculating txpower settings:
467 *
468 * 1) Power supply voltage indication. The voltage sensor outputs higher
Tomas Winklera96a27f2008-10-23 23:48:56 -0700469 * values for lower voltage, and vice verse.
Ben Cahill075416c2007-11-29 11:10:08 +0800470 *
471 * 2) Temperature measurement parameters, for each of two channel widths
472 * (20 MHz and 40 MHz) supported by the radios. Temperature sensing
473 * is done via one of the receiver chains, and channel width influences
474 * the results.
475 *
476 * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation,
477 * for each of 5 frequency ranges.
Zhu Yib481de92007-09-25 17:54:57 -0700478 */
Tomas Winkler885ba202008-05-29 16:34:55 +0800479struct iwl_init_alive_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700480 u8 ucode_minor;
481 u8 ucode_major;
482 __le16 reserved1;
483 u8 sw_rev[8];
484 u8 ver_type;
Ben Cahill075416c2007-11-29 11:10:08 +0800485 u8 ver_subtype; /* "9" for initialize alive */
Zhu Yib481de92007-09-25 17:54:57 -0700486 __le16 reserved2;
487 __le32 log_event_table_ptr;
488 __le32 error_event_table_ptr;
489 __le32 timestamp;
490 __le32 is_valid;
491
Zhu Yib481de92007-09-25 17:54:57 -0700492 /* calibration values from "initialize" uCode */
Ben Cahill075416c2007-11-29 11:10:08 +0800493 __le32 voltage; /* signed, higher value is lower voltage */
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700494 __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for HT40 */
Zhu Yib481de92007-09-25 17:54:57 -0700495 __le32 therm_r2[2]; /* signed */
496 __le32 therm_r3[2]; /* signed */
497 __le32 therm_r4[2]; /* signed */
498 __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups,
499 * 2 Tx chains */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000500} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700501
Ben Cahill075416c2007-11-29 11:10:08 +0800502
503/**
504 * REPLY_ALIVE = 0x1 (response only, not a command)
505 *
506 * uCode issues this "alive" notification once the runtime image is ready
507 * to receive commands from the driver. This is the *second* "alive"
508 * notification that the driver will receive after rebooting uCode;
509 * this "alive" is indicated by subtype field != 9.
510 *
511 * See comments documenting "BSM" (bootstrap state machine).
512 *
513 * This response includes two pointers to structures within the device's
514 * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
515 *
516 * 1) log_event_table_ptr indicates base of the event log. This traces
517 * a 256-entry history of uCode execution within a circular buffer.
518 * Its header format is:
519 *
520 * __le32 log_size; log capacity (in number of entries)
521 * __le32 type; (1) timestamp with each entry, (0) no timestamp
522 * __le32 wraps; # times uCode has wrapped to top of circular buffer
523 * __le32 write_index; next circular buffer entry that uCode would fill
524 *
525 * The header is followed by the circular buffer of log entries. Entries
526 * with timestamps have the following format:
527 *
528 * __le32 event_id; range 0 - 1500
529 * __le32 timestamp; low 32 bits of TSF (of network, if associated)
530 * __le32 data; event_id-specific data value
531 *
532 * Entries without timestamps contain only event_id and data.
533 *
Wey-Yi Guy461ef382010-03-30 17:57:53 -0700534 *
Ben Cahill075416c2007-11-29 11:10:08 +0800535 * 2) error_event_table_ptr indicates base of the error log. This contains
Wey-Yi Guy461ef382010-03-30 17:57:53 -0700536 * information about any uCode error that occurs. For agn, the format
Ben Cahill075416c2007-11-29 11:10:08 +0800537 * of the error log is:
538 *
539 * __le32 valid; (nonzero) valid, (0) log is empty
540 * __le32 error_id; type of error
541 * __le32 pc; program counter
542 * __le32 blink1; branch link
543 * __le32 blink2; branch link
544 * __le32 ilink1; interrupt link
545 * __le32 ilink2; interrupt link
546 * __le32 data1; error-specific data
547 * __le32 data2; error-specific data
548 * __le32 line; source code line of error
549 * __le32 bcon_time; beacon timer
550 * __le32 tsf_low; network timestamp function timer
551 * __le32 tsf_hi; network timestamp function timer
Wey-Yi Guy461ef382010-03-30 17:57:53 -0700552 * __le32 gp1; GP1 timer register
553 * __le32 gp2; GP2 timer register
554 * __le32 gp3; GP3 timer register
555 * __le32 ucode_ver; uCode version
556 * __le32 hw_ver; HW Silicon version
557 * __le32 brd_ver; HW board version
558 * __le32 log_pc; log program counter
559 * __le32 frame_ptr; frame pointer
560 * __le32 stack_ptr; stack pointer
561 * __le32 hcmd; last host command
562 * __le32 isr0; isr status register LMPM_NIC_ISR0: rxtx_flag
563 * __le32 isr1; isr status register LMPM_NIC_ISR1: host_flag
564 * __le32 isr2; isr status register LMPM_NIC_ISR2: enc_flag
565 * __le32 isr3; isr status register LMPM_NIC_ISR3: time_flag
566 * __le32 isr4; isr status register LMPM_NIC_ISR4: wico interrupt
567 * __le32 isr_pref; isr status register LMPM_NIC_PREF_STAT
568 * __le32 wait_event; wait event() caller address
569 * __le32 l2p_control; L2pControlField
570 * __le32 l2p_duration; L2pDurationField
571 * __le32 l2p_mhvalid; L2pMhValidBits
572 * __le32 l2p_addr_match; L2pAddrMatchStat
573 * __le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL)
574 * __le32 u_timestamp; indicate when the date and time of the compilation
575 * __le32 reserved;
Ben Cahill075416c2007-11-29 11:10:08 +0800576 *
577 * The Linux driver can print both logs to the system log when a uCode error
578 * occurs.
579 */
Tomas Winkler885ba202008-05-29 16:34:55 +0800580struct iwl_alive_resp {
Ben Cahill075416c2007-11-29 11:10:08 +0800581 u8 ucode_minor;
582 u8 ucode_major;
583 __le16 reserved1;
584 u8 sw_rev[8];
585 u8 ver_type;
586 u8 ver_subtype; /* not "9" for runtime alive */
587 __le16 reserved2;
588 __le32 log_event_table_ptr; /* SRAM address for event log */
589 __le32 error_event_table_ptr; /* SRAM address for error log */
590 __le32 timestamp;
591 __le32 is_valid;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000592} __packed;
Ben Cahill075416c2007-11-29 11:10:08 +0800593
Zhu Yib481de92007-09-25 17:54:57 -0700594/*
595 * REPLY_ERROR = 0x2 (response only, not a command)
596 */
Tomas Winkler885ba202008-05-29 16:34:55 +0800597struct iwl_error_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700598 __le32 error_type;
599 u8 cmd_id;
600 u8 reserved1;
601 __le16 bad_cmd_seq_num;
Zhu Yib481de92007-09-25 17:54:57 -0700602 __le32 error_info;
Tomas Winkler3195c1f2008-10-08 09:37:30 +0800603 __le64 timestamp;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000604} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700605
606/******************************************************************************
607 * (1)
608 * RXON Commands & Responses:
609 *
610 *****************************************************************************/
611
612/*
613 * Rx config defines & structure
614 */
615/* rx_config device types */
616enum {
617 RXON_DEV_TYPE_AP = 1,
618 RXON_DEV_TYPE_ESS = 3,
619 RXON_DEV_TYPE_IBSS = 4,
620 RXON_DEV_TYPE_SNIFFER = 6,
Johannes Berg946ba302010-08-23 10:46:48 +0200621 RXON_DEV_TYPE_CP = 7,
622 RXON_DEV_TYPE_2STA = 8,
623 RXON_DEV_TYPE_P2P = 9,
Zhu Yib481de92007-09-25 17:54:57 -0700624};
625
Ben Cahill14519a02007-11-29 11:09:59 +0800626
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800627#define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0)
Rick Farrington7b841722009-01-23 13:45:10 -0800628#define RXON_RX_CHAIN_DRIVER_FORCE_POS (0)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800629#define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1)
Ben Cahill14519a02007-11-29 11:09:59 +0800630#define RXON_RX_CHAIN_VALID_POS (1)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800631#define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4)
Ben Cahill14519a02007-11-29 11:09:59 +0800632#define RXON_RX_CHAIN_FORCE_SEL_POS (4)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800633#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7)
Ben Cahill14519a02007-11-29 11:09:59 +0800634#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800635#define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10)
Ben Cahill14519a02007-11-29 11:09:59 +0800636#define RXON_RX_CHAIN_CNT_POS (10)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800637#define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12)
Ben Cahill14519a02007-11-29 11:09:59 +0800638#define RXON_RX_CHAIN_MIMO_CNT_POS (12)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800639#define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14)
Ben Cahill14519a02007-11-29 11:09:59 +0800640#define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
641
Zhu Yib481de92007-09-25 17:54:57 -0700642/* rx_config flags */
643/* band & modulation selection */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800644#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0)
645#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -0700646/* auto detection enable */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800647#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2)
Zhu Yib481de92007-09-25 17:54:57 -0700648/* TGg protection when tx */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800649#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3)
Zhu Yib481de92007-09-25 17:54:57 -0700650/* cck short slot & preamble */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800651#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4)
652#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5)
Zhu Yib481de92007-09-25 17:54:57 -0700653/* antenna selection */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800654#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7)
655#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00)
656#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
657#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
Zhu Yib481de92007-09-25 17:54:57 -0700658/* radar detection enable */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800659#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12)
660#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13)
Zhu Yib481de92007-09-25 17:54:57 -0700661/* rx response to host with 8-byte TSF
662* (according to ON_AIR deassertion) */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800663#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15)
Zhu Yib481de92007-09-25 17:54:57 -0700664
Ben Cahill14519a02007-11-29 11:09:59 +0800665
666/* HT flags */
667#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800668#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22)
Ben Cahill14519a02007-11-29 11:09:59 +0800669
670#define RXON_FLG_HT_OPERATING_MODE_POS (23)
671
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800672#define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23)
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700673#define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23)
Ben Cahill14519a02007-11-29 11:09:59 +0800674
675#define RXON_FLG_CHANNEL_MODE_POS (25)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800676#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25)
Wey-Yi Guya2b0f022009-05-22 11:01:49 -0700677
678/* channel mode */
679enum {
680 CHANNEL_MODE_LEGACY = 0,
681 CHANNEL_MODE_PURE_40 = 1,
682 CHANNEL_MODE_MIXED = 2,
683 CHANNEL_MODE_RESERVED = 3,
684};
685#define RXON_FLG_CHANNEL_MODE_LEGACY cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
686#define RXON_FLG_CHANNEL_MODE_PURE_40 cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
687#define RXON_FLG_CHANNEL_MODE_MIXED cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
688
Emmanuel Grumbacha326a5d2008-07-11 11:53:31 +0800689/* CTS to self (if spec allows) flag */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800690#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30)
Ben Cahill14519a02007-11-29 11:09:59 +0800691
Zhu Yib481de92007-09-25 17:54:57 -0700692/* rx_config filter flags */
693/* accept all data frames */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800694#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0)
Zhu Yib481de92007-09-25 17:54:57 -0700695/* pass control & management to host */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800696#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -0700697/* accept multi-cast */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800698#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2)
Zhu Yib481de92007-09-25 17:54:57 -0700699/* don't decrypt uni-cast frames */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800700#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3)
Zhu Yib481de92007-09-25 17:54:57 -0700701/* don't decrypt multi-cast frames */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800702#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
Zhu Yib481de92007-09-25 17:54:57 -0700703/* STA is associated */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800704#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5)
Zhu Yib481de92007-09-25 17:54:57 -0700705/* transfer to host non bssid beacons in associated state */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800706#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6)
Zhu Yib481de92007-09-25 17:54:57 -0700707
Ben Cahill80cc0c32007-11-29 11:10:09 +0800708/**
Zhu Yib481de92007-09-25 17:54:57 -0700709 * REPLY_RXON = 0x10 (command, has simple generic response)
Ben Cahill80cc0c32007-11-29 11:10:09 +0800710 *
711 * RXON tunes the radio tuner to a service channel, and sets up a number
712 * of parameters that are used primarily for Rx, but also for Tx operations.
713 *
714 * NOTE: When tuning to a new channel, driver must set the
715 * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent
716 * info within the device, including the station tables, tx retry
717 * rate tables, and txpower tables. Driver must build a new station
718 * table and txpower table before transmitting anything on the RXON
719 * channel.
720 *
721 * NOTE: All RXONs wipe clean the internal txpower table. Driver must
722 * issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
723 * regardless of whether RXON_FILTER_ASSOC_MSK is set.
Zhu Yib481de92007-09-25 17:54:57 -0700724 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800725
726struct iwl3945_rxon_cmd {
727 u8 node_addr[6];
728 __le16 reserved1;
729 u8 bssid_addr[6];
730 __le16 reserved2;
731 u8 wlap_bssid_addr[6];
732 __le16 reserved3;
733 u8 dev_type;
734 u8 air_propagation;
735 __le16 reserved4;
736 u8 ofdm_basic_rates;
737 u8 cck_basic_rates;
738 __le16 assoc_id;
739 __le32 flags;
740 __le32 filter_flags;
741 __le16 channel;
742 __le16 reserved5;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000743} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800744
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800745struct iwl4965_rxon_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700746 u8 node_addr[6];
747 __le16 reserved1;
748 u8 bssid_addr[6];
749 __le16 reserved2;
750 u8 wlap_bssid_addr[6];
751 __le16 reserved3;
752 u8 dev_type;
753 u8 air_propagation;
Zhu Yib481de92007-09-25 17:54:57 -0700754 __le16 rx_chain;
Zhu Yib481de92007-09-25 17:54:57 -0700755 u8 ofdm_basic_rates;
756 u8 cck_basic_rates;
757 __le16 assoc_id;
758 __le32 flags;
759 __le32 filter_flags;
760 __le16 channel;
Zhu Yib481de92007-09-25 17:54:57 -0700761 u8 ofdm_ht_single_stream_basic_rates;
762 u8 ofdm_ht_dual_stream_basic_rates;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000763} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700764
Tomas Winklera96a27f2008-10-23 23:48:56 -0700765/* 5000 HW just extend this command */
Gregory Greenmanc1adf9f2008-05-15 13:53:59 +0800766struct iwl_rxon_cmd {
767 u8 node_addr[6];
768 __le16 reserved1;
769 u8 bssid_addr[6];
770 __le16 reserved2;
771 u8 wlap_bssid_addr[6];
772 __le16 reserved3;
773 u8 dev_type;
774 u8 air_propagation;
775 __le16 rx_chain;
776 u8 ofdm_basic_rates;
777 u8 cck_basic_rates;
778 __le16 assoc_id;
779 __le32 flags;
780 __le32 filter_flags;
781 __le16 channel;
782 u8 ofdm_ht_single_stream_basic_rates;
783 u8 ofdm_ht_dual_stream_basic_rates;
784 u8 ofdm_ht_triple_stream_basic_rates;
785 u8 reserved5;
786 __le16 acquisition_data;
787 __le16 reserved6;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000788} __packed;
Gregory Greenmanc1adf9f2008-05-15 13:53:59 +0800789
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800790/*
791 * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
792 */
793struct iwl3945_rxon_assoc_cmd {
794 __le32 flags;
795 __le32 filter_flags;
796 u8 ofdm_basic_rates;
797 u8 cck_basic_rates;
798 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000799} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800800
801struct iwl4965_rxon_assoc_cmd {
802 __le32 flags;
803 __le32 filter_flags;
804 u8 ofdm_basic_rates;
805 u8 cck_basic_rates;
806 u8 ofdm_ht_single_stream_basic_rates;
807 u8 ofdm_ht_dual_stream_basic_rates;
808 __le16 rx_chain_select_flags;
809 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000810} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800811
Ron Rindjunskyfe7a90c2008-05-29 16:35:14 +0800812struct iwl5000_rxon_assoc_cmd {
813 __le32 flags;
814 __le32 filter_flags;
815 u8 ofdm_basic_rates;
816 u8 cck_basic_rates;
817 __le16 reserved1;
818 u8 ofdm_ht_single_stream_basic_rates;
819 u8 ofdm_ht_dual_stream_basic_rates;
820 u8 ofdm_ht_triple_stream_basic_rates;
821 u8 reserved2;
822 __le16 rx_chain_select_flags;
823 __le16 acquisition_data;
824 __le32 reserved3;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000825} __packed;
Gregory Greenmanc1adf9f2008-05-15 13:53:59 +0800826
Tomas Winklerb5d7be52008-07-19 04:41:24 +0300827#define IWL_CONN_MAX_LISTEN_INTERVAL 10
Tomas Winkler2c2f3b32009-06-19 13:52:45 -0700828#define IWL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */
829#define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */
Ron Rindjunskyfe7a90c2008-05-29 16:35:14 +0800830
Zhu Yib481de92007-09-25 17:54:57 -0700831/*
832 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
833 */
Tomas Winkler3195c1f2008-10-08 09:37:30 +0800834struct iwl_rxon_time_cmd {
835 __le64 timestamp;
Zhu Yib481de92007-09-25 17:54:57 -0700836 __le16 beacon_interval;
837 __le16 atim_window;
838 __le32 beacon_init_val;
839 __le16 listen_interval;
Johannes Berg946ba302010-08-23 10:46:48 +0200840 u8 dtim_period;
841 u8 delta_cp_bss_tbtts;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000842} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700843
Zhu Yib481de92007-09-25 17:54:57 -0700844/*
845 * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
846 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800847struct iwl3945_channel_switch_cmd {
848 u8 band;
849 u8 expect_beacon;
850 __le16 channel;
851 __le32 rxon_flags;
852 __le32 rxon_filter_flags;
853 __le32 switch_time;
854 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000855} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +0800856
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700857struct iwl4965_channel_switch_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700858 u8 band;
859 u8 expect_beacon;
860 __le16 channel;
861 __le32 rxon_flags;
862 __le32 rxon_filter_flags;
863 __le32 switch_time;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800864 struct iwl4965_tx_power_db tx_power;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000865} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700866
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700867/**
868 * struct iwl5000_channel_switch_cmd
869 * @band: 0- 5.2GHz, 1- 2.4GHz
870 * @expect_beacon: 0- resume transmits after channel switch
871 * 1- wait for beacon to resume transmits
872 * @channel: new channel number
873 * @rxon_flags: Rx on flags
874 * @rxon_filter_flags: filtering parameters
875 * @switch_time: switch time in extended beacon format
876 * @reserved: reserved bytes
877 */
878struct iwl5000_channel_switch_cmd {
879 u8 band;
880 u8 expect_beacon;
881 __le16 channel;
882 __le32 rxon_flags;
883 __le32 rxon_filter_flags;
884 __le32 switch_time;
885 __le32 reserved[2][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000886} __packed;
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700887
888/**
889 * struct iwl6000_channel_switch_cmd
890 * @band: 0- 5.2GHz, 1- 2.4GHz
891 * @expect_beacon: 0- resume transmits after channel switch
892 * 1- wait for beacon to resume transmits
893 * @channel: new channel number
894 * @rxon_flags: Rx on flags
895 * @rxon_filter_flags: filtering parameters
896 * @switch_time: switch time in extended beacon format
897 * @reserved: reserved bytes
898 */
899struct iwl6000_channel_switch_cmd {
900 u8 band;
901 u8 expect_beacon;
902 __le16 channel;
903 __le32 rxon_flags;
904 __le32 rxon_filter_flags;
905 __le32 switch_time;
906 __le32 reserved[3][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000907} __packed;
Wey-Yi Guye57f1482009-10-09 13:20:34 -0700908
Zhu Yib481de92007-09-25 17:54:57 -0700909/*
910 * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
911 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -0800912struct iwl_csa_notification {
Zhu Yib481de92007-09-25 17:54:57 -0700913 __le16 band;
914 __le16 channel;
915 __le32 status; /* 0 - OK, 1 - fail */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000916} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700917
918/******************************************************************************
919 * (2)
920 * Quality-of-Service (QOS) Commands & Responses:
921 *
922 *****************************************************************************/
Ben Cahill2054a002007-11-29 11:10:10 +0800923
924/**
925 * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
926 * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
927 *
928 * @cw_min: Contention window, start value in numbers of slots.
929 * Should be a power-of-2, minus 1. Device's default is 0x0f.
930 * @cw_max: Contention window, max value in numbers of slots.
931 * Should be a power-of-2, minus 1. Device's default is 0x3f.
932 * @aifsn: Number of slots in Arbitration Interframe Space (before
933 * performing random backoff timing prior to Tx). Device default 1.
934 * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
935 *
936 * Device will automatically increase contention window by (2*CW) + 1 for each
937 * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
938 * value, to cap the CW value.
939 */
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800940struct iwl_ac_qos {
Zhu Yib481de92007-09-25 17:54:57 -0700941 __le16 cw_min;
942 __le16 cw_max;
943 u8 aifsn;
944 u8 reserved1;
945 __le16 edca_txop;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000946} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700947
948/* QoS flags defines */
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800949#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01)
950#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02)
951#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10)
Zhu Yib481de92007-09-25 17:54:57 -0700952
Ben Cahill2054a002007-11-29 11:10:10 +0800953/* Number of Access Categories (AC) (EDCA), queues 0..3 */
Zhu Yib481de92007-09-25 17:54:57 -0700954#define AC_NUM 4
955
956/*
957 * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
Ben Cahill2054a002007-11-29 11:10:10 +0800958 *
959 * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
960 * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
Zhu Yib481de92007-09-25 17:54:57 -0700961 */
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800962struct iwl_qosparam_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700963 __le32 qos_flags;
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800964 struct iwl_ac_qos ac[AC_NUM];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000965} __packed;
Zhu Yib481de92007-09-25 17:54:57 -0700966
967/******************************************************************************
968 * (3)
969 * Add/Modify Stations Commands & Responses:
970 *
971 *****************************************************************************/
972/*
973 * Multi station support
974 */
Ben Cahill2054a002007-11-29 11:10:10 +0800975
976/* Special, dedicated locations within device's station table */
Zhu Yib481de92007-09-25 17:54:57 -0700977#define IWL_AP_ID 0
Johannes Berg946ba302010-08-23 10:46:48 +0200978#define IWL_AP_ID_PAN 1
Zhu Yib481de92007-09-25 17:54:57 -0700979#define IWL_STA_ID 2
Tomas Winkler4c897252008-12-19 10:37:05 +0800980#define IWL3945_BROADCAST_ID 24
981#define IWL3945_STATION_COUNT 25
Zhu Yib481de92007-09-25 17:54:57 -0700982#define IWL4965_BROADCAST_ID 31
983#define IWL4965_STATION_COUNT 32
Johannes Berg946ba302010-08-23 10:46:48 +0200984#define IWLAGN_PAN_BCAST_ID 14
Wey-Yi Guybf3c7fd2010-06-24 14:08:05 -0700985#define IWLAGN_BROADCAST_ID 15
986#define IWLAGN_STATION_COUNT 16
Zhu Yib481de92007-09-25 17:54:57 -0700987
988#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
989#define IWL_INVALID_STATION 255
990
Johannes Berg1bd14ea2010-07-15 11:48:21 -0700991#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2)
992#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8)
Johannes Berg946ba302010-08-23 10:46:48 +0200993#define STA_FLG_PAN_STATION cpu_to_le32(1 << 13)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800994#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17)
995#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18)
Ben Cahill74093dd2007-11-29 11:09:53 +0800996#define STA_FLG_MAX_AGG_SIZE_POS (19)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800997#define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19)
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700998#define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21)
Harvey Harrison51e9bf52008-11-26 13:12:52 -0800999#define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22)
Ben Cahill74093dd2007-11-29 11:09:53 +08001000#define STA_FLG_AGG_MPDU_DENSITY_POS (23)
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001001#define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23)
Zhu Yib481de92007-09-25 17:54:57 -07001002
Ben Cahill2054a002007-11-29 11:10:10 +08001003/* Use in mode field. 1: modify existing entry, 0: add new station entry */
Zhu Yib481de92007-09-25 17:54:57 -07001004#define STA_CONTROL_MODIFY_MSK 0x01
1005
1006/* key flags __le16*/
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001007#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007)
1008#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000)
1009#define STA_KEY_FLG_WEP cpu_to_le16(0x0001)
1010#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002)
1011#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003)
Zhu Yib481de92007-09-25 17:54:57 -07001012
1013#define STA_KEY_FLG_KEYID_POS 8
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001014#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800)
Emmanuel Grumbacheaaf7892008-02-13 11:32:29 -08001015/* wep key is either from global key (0) or from station info array (1) */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001016#define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008)
Emmanuel Grumbacheaaf7892008-02-13 11:32:29 -08001017
1018/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001019#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000)
1020#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
Emmanuel Grumbachdeb09c42008-03-19 16:41:41 -07001021#define STA_KEY_MAX_NUM 8
Johannes Bergc10afb62010-08-23 10:46:43 +02001022#define STA_KEY_MAX_NUM_PAN 16
Zhu Yib481de92007-09-25 17:54:57 -07001023
Ben Cahill2054a002007-11-29 11:10:10 +08001024/* Flags indicate whether to modify vs. don't change various station params */
Zhu Yib481de92007-09-25 17:54:57 -07001025#define STA_MODIFY_KEY_MASK 0x01
1026#define STA_MODIFY_TID_DISABLE_TX 0x02
1027#define STA_MODIFY_TX_RATE_MSK 0x04
1028#define STA_MODIFY_ADDBA_TID_MSK 0x08
1029#define STA_MODIFY_DELBA_TID_MSK 0x10
Johannes Berg6ab10ff2009-11-13 11:56:37 -08001030#define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20
Ben Cahill2054a002007-11-29 11:10:10 +08001031
1032/* Receiver address (actually, Rx station's index into station table),
1033 * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
Zhu Yib481de92007-09-25 17:54:57 -07001034#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid))
1035
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001036struct iwl4965_keyinfo {
Zhu Yib481de92007-09-25 17:54:57 -07001037 __le16 key_flags;
1038 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
1039 u8 reserved1;
1040 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
Emmanuel Grumbacheaaf7892008-02-13 11:32:29 -08001041 u8 key_offset;
1042 u8 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -07001043 u8 key[16]; /* 16-byte unicast decryption key */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001044} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001045
Wey-Yi Guya8029bb2010-09-20 09:12:32 -07001046/* agn */
Tomas Winkler133636d2008-05-05 10:22:34 +08001047struct iwl_keyinfo {
1048 __le16 key_flags;
1049 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
1050 u8 reserved1;
1051 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
1052 u8 key_offset;
1053 u8 reserved2;
1054 u8 key[16]; /* 16-byte unicast decryption key */
1055 __le64 tx_secur_seq_cnt;
1056 __le64 hw_tkip_mic_rx_key;
1057 __le64 hw_tkip_mic_tx_key;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001058} __packed;
Tomas Winkler133636d2008-05-05 10:22:34 +08001059
Ben Cahill2054a002007-11-29 11:10:10 +08001060/**
1061 * struct sta_id_modify
1062 * @addr[ETH_ALEN]: station's MAC address
1063 * @sta_id: index of station in uCode's station table
1064 * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
1065 *
1066 * Driver selects unused table index when adding new station,
1067 * or the index to a pre-existing station entry when modifying that station.
1068 * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
1069 *
1070 * modify_mask flags select which parameters to modify vs. leave alone.
1071 */
Zhu Yib481de92007-09-25 17:54:57 -07001072struct sta_id_modify {
1073 u8 addr[ETH_ALEN];
1074 __le16 reserved1;
1075 u8 sta_id;
1076 u8 modify_mask;
1077 __le16 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001078} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001079
1080/*
1081 * REPLY_ADD_STA = 0x18 (command)
Ben Cahill2054a002007-11-29 11:10:10 +08001082 *
1083 * The device contains an internal table of per-station information,
1084 * with info on security keys, aggregation parameters, and Tx rates for
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001085 * initial Tx attempt and any retries (agn devices uses
1086 * REPLY_TX_LINK_QUALITY_CMD,
Ben Cahill2054a002007-11-29 11:10:10 +08001087 * 3945 uses REPLY_RATE_SCALE to set up rate tables).
1088 *
1089 * REPLY_ADD_STA sets up the table entry for one station, either creating
1090 * a new entry, or modifying a pre-existing one.
1091 *
1092 * NOTE: RXON command (without "associated" bit set) wipes the station table
1093 * clean. Moving into RF_KILL state does this also. Driver must set up
1094 * new station table before transmitting anything on the RXON channel
1095 * (except active scans or active measurements; those commands carry
1096 * their own txpower/rate setup data).
1097 *
1098 * When getting started on a new channel, driver must set up the
1099 * IWL_BROADCAST_ID entry (last entry in the table). For a client
1100 * station in a BSS, once an AP is selected, driver sets up the AP STA
1101 * in the IWL_AP_ID entry (1st entry in the table). BROADCAST and AP
1102 * are all that are needed for a BSS client station. If the device is
1103 * used as AP, or in an IBSS network, driver must set up station table
1104 * entries for all STAs in network, starting with index IWL_STA_ID.
Zhu Yib481de92007-09-25 17:54:57 -07001105 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001106
1107struct iwl3945_addsta_cmd {
1108 u8 mode; /* 1: modify existing, 0: add new station */
1109 u8 reserved[3];
1110 struct sta_id_modify sta;
1111 struct iwl4965_keyinfo key;
1112 __le32 station_flags; /* STA_FLG_* */
1113 __le32 station_flags_msk; /* STA_FLG_* */
1114
1115 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1116 * corresponding to bit (e.g. bit 5 controls TID 5).
1117 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1118 __le16 tid_disable_tx;
1119
1120 __le16 rate_n_flags;
1121
1122 /* TID for which to add block-ack support.
1123 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1124 u8 add_immediate_ba_tid;
1125
1126 /* TID for which to remove block-ack support.
1127 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1128 u8 remove_immediate_ba_tid;
1129
1130 /* Starting Sequence Number for added block-ack support.
1131 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1132 __le16 add_immediate_ba_ssn;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001133} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001134
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001135struct iwl4965_addsta_cmd {
Ben Cahill2054a002007-11-29 11:10:10 +08001136 u8 mode; /* 1: modify existing, 0: add new station */
Zhu Yib481de92007-09-25 17:54:57 -07001137 u8 reserved[3];
1138 struct sta_id_modify sta;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001139 struct iwl4965_keyinfo key;
Ben Cahill2054a002007-11-29 11:10:10 +08001140 __le32 station_flags; /* STA_FLG_* */
1141 __le32 station_flags_msk; /* STA_FLG_* */
1142
1143 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1144 * corresponding to bit (e.g. bit 5 controls TID 5).
1145 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001146 __le16 tid_disable_tx;
Ben Cahill2054a002007-11-29 11:10:10 +08001147
Zhu Yib481de92007-09-25 17:54:57 -07001148 __le16 reserved1;
Ben Cahill2054a002007-11-29 11:10:10 +08001149
1150 /* TID for which to add block-ack support.
1151 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001152 u8 add_immediate_ba_tid;
Ben Cahill2054a002007-11-29 11:10:10 +08001153
1154 /* TID for which to remove block-ack support.
1155 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001156 u8 remove_immediate_ba_tid;
Ben Cahill2054a002007-11-29 11:10:10 +08001157
1158 /* Starting Sequence Number for added block-ack support.
1159 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -07001160 __le16 add_immediate_ba_ssn;
Ben Cahill2054a002007-11-29 11:10:10 +08001161
Johannes Berg9bb487b2009-11-13 11:56:36 -08001162 /*
1163 * Number of packets OK to transmit to station even though
1164 * it is asleep -- used to synchronise PS-poll and u-APSD
1165 * responses while ucode keeps track of STA sleep state.
1166 */
1167 __le16 sleep_tx_count;
1168
1169 __le16 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001170} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001171
Wey-Yi Guya8029bb2010-09-20 09:12:32 -07001172/* agn */
Tomas Winkler133636d2008-05-05 10:22:34 +08001173struct iwl_addsta_cmd {
1174 u8 mode; /* 1: modify existing, 0: add new station */
1175 u8 reserved[3];
1176 struct sta_id_modify sta;
1177 struct iwl_keyinfo key;
1178 __le32 station_flags; /* STA_FLG_* */
1179 __le32 station_flags_msk; /* STA_FLG_* */
1180
1181 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1182 * corresponding to bit (e.g. bit 5 controls TID 5).
1183 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1184 __le16 tid_disable_tx;
1185
Tomas Winklerc587de02009-06-03 11:44:07 -07001186 __le16 rate_n_flags; /* 3945 only */
Tomas Winkler133636d2008-05-05 10:22:34 +08001187
1188 /* TID for which to add block-ack support.
1189 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1190 u8 add_immediate_ba_tid;
1191
1192 /* TID for which to remove block-ack support.
1193 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1194 u8 remove_immediate_ba_tid;
1195
1196 /* Starting Sequence Number for added block-ack support.
1197 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1198 __le16 add_immediate_ba_ssn;
1199
Johannes Berg9bb487b2009-11-13 11:56:36 -08001200 /*
1201 * Number of packets OK to transmit to station even though
1202 * it is asleep -- used to synchronise PS-poll and u-APSD
1203 * responses while ucode keeps track of STA sleep state.
1204 */
1205 __le16 sleep_tx_count;
1206
1207 __le16 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001208} __packed;
Tomas Winkler133636d2008-05-05 10:22:34 +08001209
1210
Ben Cahill2054a002007-11-29 11:10:10 +08001211#define ADD_STA_SUCCESS_MSK 0x1
1212#define ADD_STA_NO_ROOM_IN_TABLE 0x2
1213#define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4
1214#define ADD_STA_MODIFY_NON_EXIST_STA 0x8
Zhu Yib481de92007-09-25 17:54:57 -07001215/*
1216 * REPLY_ADD_STA = 0x18 (response)
1217 */
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001218struct iwl_add_sta_resp {
Ben Cahill2054a002007-11-29 11:10:10 +08001219 u8 status; /* ADD_STA_* */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001220} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001221
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001222#define REM_STA_SUCCESS_MSK 0x1
1223/*
1224 * REPLY_REM_STA = 0x19 (response)
1225 */
1226struct iwl_rem_sta_resp {
1227 u8 status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001228} __packed;
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001229
1230/*
1231 * REPLY_REM_STA = 0x19 (command)
1232 */
1233struct iwl_rem_sta_cmd {
1234 u8 num_sta; /* number of removed stations */
1235 u8 reserved[3];
1236 u8 addr[ETH_ALEN]; /* MAC addr of the first station */
1237 u8 reserved2[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001238} __packed;
Tomas Winkler7a999bf2008-05-29 16:35:02 +08001239
Wey-Yi Guy947279e2010-06-24 13:18:33 -07001240#define IWL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0))
1241#define IWL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1))
1242#define IWL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2))
1243#define IWL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3))
1244#define IWL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00)
1245
Wey-Yi Guy716c74b2010-06-24 13:22:36 -07001246#define IWL_DROP_SINGLE 0
1247#define IWL_DROP_SELECTED 1
1248#define IWL_DROP_ALL 2
1249
Wey-Yi Guy947279e2010-06-24 13:18:33 -07001250/*
1251 * REPLY_TXFIFO_FLUSH = 0x1e(command and response)
1252 *
1253 * When using full FIFO flush this command checks the scheduler HW block WR/RD
1254 * pointers to check if all the frames were transferred by DMA into the
1255 * relevant TX FIFO queue. Only when the DMA is finished and the queue is
1256 * empty the command can finish.
1257 * This command is used to flush the TXFIFO from transmit commands, it may
1258 * operate on single or multiple queues, the command queue can't be flushed by
1259 * this command. The command response is returned when all the queue flush
1260 * operations are done. Each TX command flushed return response with the FLUSH
1261 * status set in the TX response status. When FIFO flush operation is used,
1262 * the flush operation ends when both the scheduler DMA done and TXFIFO empty
1263 * are set.
1264 *
1265 * @fifo_control: bit mask for which queues to flush
1266 * @flush_control: flush controls
1267 * 0: Dump single MSDU
1268 * 1: Dump multiple MSDU according to PS, INVALID STA, TTL, TID disable.
1269 * 2: Dump all FIFO
1270 */
1271struct iwl_txfifo_flush_cmd {
1272 __le32 fifo_control;
1273 __le16 flush_control;
1274 __le16 reserved;
John W. Linville0e954092010-07-14 10:37:32 -04001275} __packed;
Wey-Yi Guy947279e2010-06-24 13:18:33 -07001276
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001277/*
1278 * REPLY_WEP_KEY = 0x20
1279 */
1280struct iwl_wep_key {
1281 u8 key_index;
1282 u8 key_offset;
1283 u8 reserved1[2];
1284 u8 key_size;
1285 u8 reserved2[3];
1286 u8 key[16];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001287} __packed;
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001288
1289struct iwl_wep_cmd {
1290 u8 num_keys;
1291 u8 global_key_type;
1292 u8 flags;
1293 u8 reserved;
1294 struct iwl_wep_key key[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001295} __packed;
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001296
1297#define WEP_KEY_WEP_TYPE 1
1298#define WEP_KEYS_MAX 4
1299#define WEP_INVALID_OFFSET 0xff
Emmanuel Grumbach4564ce82008-06-12 09:47:09 +08001300#define WEP_KEY_LEN_64 5
Emmanuel Grumbach0a0bed12008-04-14 21:16:05 -07001301#define WEP_KEY_LEN_128 13
Zhu Yib481de92007-09-25 17:54:57 -07001302
1303/******************************************************************************
1304 * (4)
1305 * Rx Responses:
1306 *
1307 *****************************************************************************/
1308
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001309#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0)
1310#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -07001311
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001312#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0)
1313#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1)
1314#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2)
1315#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3)
Reinette Chatre9024adf2009-10-02 13:43:57 -07001316#define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0
Daniel C Halperin9f30e042009-08-13 13:30:56 -07001317#define RX_RES_PHY_FLAGS_ANTENNA_POS 4
Zhu Yib481de92007-09-25 17:54:57 -07001318
Tomas Winkler8211ef72008-03-02 01:36:04 +02001319#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
1320#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
1321#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
1322#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
1323#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
Emmanuel Grumbach17e476b2008-03-19 16:41:42 -07001324#define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8)
1325
1326#define RX_RES_STATUS_STATION_FOUND (1<<6)
1327#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7)
Zhu Yib481de92007-09-25 17:54:57 -07001328
Tomas Winkler8211ef72008-03-02 01:36:04 +02001329#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
1330#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
1331#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
1332#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
1333#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
Zhu Yib481de92007-09-25 17:54:57 -07001334
Emmanuel Grumbach17e476b2008-03-19 16:41:42 -07001335#define RX_MPDU_RES_STATUS_ICV_OK (0x20)
1336#define RX_MPDU_RES_STATUS_MIC_OK (0x40)
1337#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7)
1338#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800)
1339
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001340
1341struct iwl3945_rx_frame_stats {
1342 u8 phy_count;
1343 u8 id;
1344 u8 rssi;
1345 u8 agc;
1346 __le16 sig_avg;
1347 __le16 noise_diff;
1348 u8 payload[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001349} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001350
1351struct iwl3945_rx_frame_hdr {
1352 __le16 channel;
1353 __le16 phy_flags;
1354 u8 reserved1;
1355 u8 rate;
1356 __le16 len;
1357 u8 payload[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001358} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001359
1360struct iwl3945_rx_frame_end {
1361 __le32 status;
1362 __le64 timestamp;
1363 __le32 beacon_timestamp;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001364} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001365
1366/*
1367 * REPLY_3945_RX = 0x1b (response only, not a command)
1368 *
1369 * NOTE: DO NOT dereference from casts to this structure
1370 * It is provided only for calculating minimum data set size.
1371 * The actual offsets of the hdr and end are dynamic based on
1372 * stats.phy_count
1373 */
1374struct iwl3945_rx_frame {
1375 struct iwl3945_rx_frame_stats stats;
1376 struct iwl3945_rx_frame_hdr hdr;
1377 struct iwl3945_rx_frame_end end;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001378} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001379
1380#define IWL39_RX_FRAME_SIZE (4 + sizeof(struct iwl3945_rx_frame))
1381
Zhu Yib481de92007-09-25 17:54:57 -07001382/* Fixed (non-configurable) rx data from phy */
Tomas Winklercaab8f12008-08-04 16:00:42 +08001383
1384#define IWL49_RX_RES_PHY_CNT 14
1385#define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
1386#define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
1387#define IWL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
1388#define IWL49_AGC_DB_POS (7)
Zhu Yib481de92007-09-25 17:54:57 -07001389struct iwl4965_rx_non_cfg_phy {
1390 __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
1391 __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
1392 u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
1393 u8 pad[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001394} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001395
Tomas Winklercaab8f12008-08-04 16:00:42 +08001396
Wey-Yi Guy7ccc8962010-08-04 08:42:17 -07001397#define IWLAGN_RX_RES_PHY_CNT 8
1398#define IWLAGN_RX_RES_AGC_IDX 1
1399#define IWLAGN_RX_RES_RSSI_AB_IDX 2
1400#define IWLAGN_RX_RES_RSSI_C_IDX 3
1401#define IWLAGN_OFDM_AGC_MSK 0xfe00
1402#define IWLAGN_OFDM_AGC_BIT_POS 9
1403#define IWLAGN_OFDM_RSSI_INBAND_A_BITMSK 0x00ff
1404#define IWLAGN_OFDM_RSSI_ALLBAND_A_BITMSK 0xff00
1405#define IWLAGN_OFDM_RSSI_A_BIT_POS 0
1406#define IWLAGN_OFDM_RSSI_INBAND_B_BITMSK 0xff0000
1407#define IWLAGN_OFDM_RSSI_ALLBAND_B_BITMSK 0xff000000
1408#define IWLAGN_OFDM_RSSI_B_BIT_POS 16
1409#define IWLAGN_OFDM_RSSI_INBAND_C_BITMSK 0x00ff
1410#define IWLAGN_OFDM_RSSI_ALLBAND_C_BITMSK 0xff00
1411#define IWLAGN_OFDM_RSSI_C_BIT_POS 0
Tomas Winklercaab8f12008-08-04 16:00:42 +08001412
Wey-Yi Guy7ccc8962010-08-04 08:42:17 -07001413struct iwlagn_non_cfg_phy {
1414 __le32 non_cfg_phy[IWLAGN_RX_RES_PHY_CNT]; /* up to 8 phy entries */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001415} __packed;
Tomas Winklercaab8f12008-08-04 16:00:42 +08001416
1417
Zhu Yib481de92007-09-25 17:54:57 -07001418/*
Tomas Winkler857485c2008-03-21 13:53:44 -07001419 * REPLY_RX = 0xc3 (response only, not a command)
Zhu Yib481de92007-09-25 17:54:57 -07001420 * Used only for legacy (non 11n) frames.
1421 */
Tomas Winklercaab8f12008-08-04 16:00:42 +08001422struct iwl_rx_phy_res {
Zhu Yib481de92007-09-25 17:54:57 -07001423 u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
1424 u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
1425 u8 stat_id; /* configurable DSP phy data set ID */
1426 u8 reserved1;
1427 __le64 timestamp; /* TSF at on air rise */
1428 __le32 beacon_time_stamp; /* beacon at on-air rise */
1429 __le16 phy_flags; /* general phy flags: band, modulation, ... */
1430 __le16 channel; /* channel number */
Tomas Winklercaab8f12008-08-04 16:00:42 +08001431 u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
Ben Cahill52969982007-11-29 11:10:11 +08001432 __le32 rate_n_flags; /* RATE_MCS_* */
1433 __le16 byte_count; /* frame's byte-count */
Wey-Yi Guy30c1b0f2010-08-04 08:05:33 -07001434 __le16 frame_time; /* frame's time on the air */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001435} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001436
Emmanuel Grumbach2fb291e2010-06-07 13:21:47 -07001437struct iwl_rx_mpdu_res_start {
Zhu Yib481de92007-09-25 17:54:57 -07001438 __le16 byte_count;
1439 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001440} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001441
1442
1443/******************************************************************************
1444 * (5)
1445 * Tx Commands & Responses:
1446 *
Ben Cahill52969982007-11-29 11:10:11 +08001447 * Driver must place each REPLY_TX command into one of the prioritized Tx
1448 * queues in host DRAM, shared between driver and device (see comments for
1449 * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode
1450 * are preparing to transmit, the device pulls the Tx command over the PCI
1451 * bus via one of the device's Tx DMA channels, to fill an internal FIFO
1452 * from which data will be transmitted.
1453 *
1454 * uCode handles all timing and protocol related to control frames
1455 * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler
1456 * handle reception of block-acks; uCode updates the host driver via
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001457 * REPLY_COMPRESSED_BA.
Ben Cahill52969982007-11-29 11:10:11 +08001458 *
1459 * uCode handles retrying Tx when an ACK is expected but not received.
1460 * This includes trying lower data rates than the one requested in the Tx
1461 * command, as set up by the REPLY_RATE_SCALE (for 3945) or
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001462 * REPLY_TX_LINK_QUALITY_CMD (agn).
Ben Cahill52969982007-11-29 11:10:11 +08001463 *
1464 * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
1465 * This command must be executed after every RXON command, before Tx can occur.
Zhu Yib481de92007-09-25 17:54:57 -07001466 *****************************************************************************/
1467
Ben Cahill52969982007-11-29 11:10:11 +08001468/* REPLY_TX Tx flags field */
1469
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001470/*
1471 * 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
Emmanuel Grumbacha326a5d2008-07-11 11:53:31 +08001472 * before this frame. if CTS-to-self required check
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001473 * RXON_FLG_SELF_CTS_EN status.
1474 * unused in 3945/4965, used in 5000 series and after
1475 */
1476#define TX_CMD_FLG_PROT_REQUIRE_MSK cpu_to_le32(1 << 0)
Emmanuel Grumbacha326a5d2008-07-11 11:53:31 +08001477
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001478/*
1479 * 1: Use Request-To-Send protocol before this frame.
1480 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK.
1481 * used in 3945/4965, unused in 5000 series and after
1482 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001483#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
Ben Cahill52969982007-11-29 11:10:11 +08001484
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001485/*
1486 * 1: Transmit Clear-To-Send to self before this frame.
Ben Cahill52969982007-11-29 11:10:11 +08001487 * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001488 * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK.
1489 * used in 3945/4965, unused in 5000 series and after
1490 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001491#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
Ben Cahill52969982007-11-29 11:10:11 +08001492
1493/* 1: Expect ACK from receiving station
1494 * 0: Don't expect ACK (MAC header's duration field s/b 0)
1495 * Set this for unicast frames, but not broadcast/multicast. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001496#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
Ben Cahill52969982007-11-29 11:10:11 +08001497
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001498/* For agn devices:
Ben Cahill52969982007-11-29 11:10:11 +08001499 * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
1500 * Tx command's initial_rate_index indicates first rate to try;
1501 * uCode walks through table for additional Tx attempts.
1502 * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
1503 * This rate will be used for all Tx attempts; it will not be scaled. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001504#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
Ben Cahill52969982007-11-29 11:10:11 +08001505
1506/* 1: Expect immediate block-ack.
1507 * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001508#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6)
Ben Cahill52969982007-11-29 11:10:11 +08001509
Wey-Yi Guy4e3243f2010-06-18 11:33:16 -07001510/*
1511 * 1: Frame requires full Tx-Op protection.
1512 * Set this if either RTS or CTS Tx Flag gets set.
1513 * used in 3945/4965, unused in 5000 series and after
1514 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001515#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
Ben Cahill52969982007-11-29 11:10:11 +08001516
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001517/* Tx antenna selection field; used only for 3945, reserved (0) for agn devices.
Ben Cahill52969982007-11-29 11:10:11 +08001518 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001519#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
1520#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
1521#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
Zhu Yib481de92007-09-25 17:54:57 -07001522
Ben Cahill52969982007-11-29 11:10:11 +08001523/* 1: Ignore Bluetooth priority for this frame.
1524 * 0: Delay Tx until Bluetooth device is done (normal usage). */
Johannes Bergb2e86902010-04-13 01:04:32 -07001525#define TX_CMD_FLG_IGNORE_BT cpu_to_le32(1 << 12)
Zhu Yib481de92007-09-25 17:54:57 -07001526
Ben Cahill52969982007-11-29 11:10:11 +08001527/* 1: uCode overrides sequence control field in MAC header.
1528 * 0: Driver provides sequence control field in MAC header.
1529 * Set this for management frames, non-QOS data frames, non-unicast frames,
1530 * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001531#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
Zhu Yib481de92007-09-25 17:54:57 -07001532
Ben Cahill52969982007-11-29 11:10:11 +08001533/* 1: This frame is non-last MPDU; more fragments are coming.
1534 * 0: Last fragment, or not using fragmentation. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001535#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
Zhu Yib481de92007-09-25 17:54:57 -07001536
Ben Cahill52969982007-11-29 11:10:11 +08001537/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
1538 * 0: No TSF required in outgoing frame.
1539 * Set this for transmitting beacons and probe responses. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001540#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
Zhu Yib481de92007-09-25 17:54:57 -07001541
Ben Cahill52969982007-11-29 11:10:11 +08001542/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
1543 * alignment of frame's payload data field.
1544 * 0: No pad
1545 * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
1546 * field (but not both). Driver must align frame data (i.e. data following
1547 * MAC header) to DWORD boundary. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001548#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
Zhu Yib481de92007-09-25 17:54:57 -07001549
Max Stepanov8236e182008-03-12 16:58:48 -07001550/* accelerate aggregation support
1551 * 0 - no CCMP encryption; 1 - CCMP encryption */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001552#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
Max Stepanov8236e182008-03-12 16:58:48 -07001553
Zhu Yib481de92007-09-25 17:54:57 -07001554/* HCCA-AP - disable duration overwriting. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08001555#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
Zhu Yib481de92007-09-25 17:54:57 -07001556
Ben Cahill52969982007-11-29 11:10:11 +08001557
Zhu Yib481de92007-09-25 17:54:57 -07001558/*
1559 * TX command security control
1560 */
1561#define TX_CMD_SEC_WEP 0x01
1562#define TX_CMD_SEC_CCM 0x02
1563#define TX_CMD_SEC_TKIP 0x03
1564#define TX_CMD_SEC_MSK 0x03
1565#define TX_CMD_SEC_SHIFT 6
1566#define TX_CMD_SEC_KEY128 0x08
1567
1568/*
Tomas Winkler3195cdb2008-04-23 17:15:00 -07001569 * security overhead sizes
1570 */
1571#define WEP_IV_LEN 4
1572#define WEP_ICV_LEN 4
1573#define CCMP_MIC_LEN 8
1574#define TKIP_ICV_LEN 4
1575
1576/*
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001577 * REPLY_TX = 0x1c (command)
1578 */
1579
1580struct iwl3945_tx_cmd {
1581 /*
1582 * MPDU byte count:
1583 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1584 * + 8 byte IV for CCM or TKIP (not used for WEP)
1585 * + Data payload
1586 * + 8-byte MIC (not used for CCM/WEP)
1587 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1588 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1589 * Range: 14-2342 bytes.
1590 */
1591 __le16 len;
1592
1593 /*
1594 * MPDU or MSDU byte count for next frame.
1595 * Used for fragmentation and bursting, but not 11n aggregation.
1596 * Same as "len", but for next frame. Set to 0 if not applicable.
1597 */
1598 __le16 next_frame_len;
1599
1600 __le32 tx_flags; /* TX_CMD_FLG_* */
1601
1602 u8 rate;
1603
1604 /* Index of recipient station in uCode's station table */
1605 u8 sta_id;
1606 u8 tid_tspec;
1607 u8 sec_ctl;
1608 u8 key[16];
1609 union {
1610 u8 byte[8];
1611 __le16 word[4];
1612 __le32 dw[2];
1613 } tkip_mic;
1614 __le32 next_frame_info;
1615 union {
1616 __le32 life_time;
1617 __le32 attempt;
1618 } stop_time;
1619 u8 supp_rates[2];
1620 u8 rts_retry_limit; /*byte 50 */
1621 u8 data_retry_limit; /*byte 51 */
1622 union {
1623 __le16 pm_frame_timeout;
1624 __le16 attempt_duration;
1625 } timeout;
1626
1627 /*
1628 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1629 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1630 */
1631 __le16 driver_txop;
1632
1633 /*
1634 * MAC header goes here, followed by 2 bytes padding if MAC header
1635 * length is 26 or 30 bytes, followed by payload data
1636 */
1637 u8 payload[0];
1638 struct ieee80211_hdr hdr[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001639} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001640
1641/*
1642 * REPLY_TX = 0x1c (response)
1643 */
1644struct iwl3945_tx_resp {
1645 u8 failure_rts;
1646 u8 failure_frame;
1647 u8 bt_kill_count;
1648 u8 rate;
1649 __le32 wireless_media_time;
1650 __le32 status; /* TX status */
Eric Dumazetba2d3582010-06-02 18:10:09 +00001651} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08001652
1653
1654/*
Ben Cahill52969982007-11-29 11:10:11 +08001655 * 4965 uCode updates these Tx attempt count values in host DRAM.
1656 * Used for managing Tx retries when expecting block-acks.
1657 * Driver should set these fields to 0.
Zhu Yib481de92007-09-25 17:54:57 -07001658 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001659struct iwl_dram_scratch {
Ben Cahill52969982007-11-29 11:10:11 +08001660 u8 try_cnt; /* Tx attempts */
1661 u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */
Zhu Yib481de92007-09-25 17:54:57 -07001662 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001663} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001664
Tomas Winkler83d527d2008-05-15 13:54:05 +08001665struct iwl_tx_cmd {
Ben Cahill52969982007-11-29 11:10:11 +08001666 /*
1667 * MPDU byte count:
1668 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1669 * + 8 byte IV for CCM or TKIP (not used for WEP)
1670 * + Data payload
1671 * + 8-byte MIC (not used for CCM/WEP)
1672 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1673 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1674 * Range: 14-2342 bytes.
1675 */
Zhu Yib481de92007-09-25 17:54:57 -07001676 __le16 len;
Ben Cahill52969982007-11-29 11:10:11 +08001677
1678 /*
1679 * MPDU or MSDU byte count for next frame.
1680 * Used for fragmentation and bursting, but not 11n aggregation.
1681 * Same as "len", but for next frame. Set to 0 if not applicable.
1682 */
Zhu Yib481de92007-09-25 17:54:57 -07001683 __le16 next_frame_len;
Ben Cahill52969982007-11-29 11:10:11 +08001684
1685 __le32 tx_flags; /* TX_CMD_FLG_* */
1686
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001687 /* uCode may modify this field of the Tx command (in host DRAM!).
Ben Cahill52969982007-11-29 11:10:11 +08001688 * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001689 struct iwl_dram_scratch scratch;
Ben Cahill52969982007-11-29 11:10:11 +08001690
1691 /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
1692 __le32 rate_n_flags; /* RATE_MCS_* */
1693
1694 /* Index of destination station in uCode's station table */
Zhu Yib481de92007-09-25 17:54:57 -07001695 u8 sta_id;
Ben Cahill52969982007-11-29 11:10:11 +08001696
1697 /* Type of security encryption: CCM or TKIP */
1698 u8 sec_ctl; /* TX_CMD_SEC_* */
1699
1700 /*
1701 * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
1702 * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for
1703 * data frames, this field may be used to selectively reduce initial
1704 * rate (via non-0 value) for special frames (e.g. management), while
1705 * still supporting rate scaling for all frames.
1706 */
Zhu Yib481de92007-09-25 17:54:57 -07001707 u8 initial_rate_index;
1708 u8 reserved;
Zhu Yib481de92007-09-25 17:54:57 -07001709 u8 key[16];
Zhu Yib481de92007-09-25 17:54:57 -07001710 __le16 next_frame_flags;
1711 __le16 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -07001712 union {
1713 __le32 life_time;
1714 __le32 attempt;
1715 } stop_time;
Ben Cahill52969982007-11-29 11:10:11 +08001716
1717 /* Host DRAM physical address pointer to "scratch" in this command.
1718 * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */
Zhu Yib481de92007-09-25 17:54:57 -07001719 __le32 dram_lsb_ptr;
1720 u8 dram_msb_ptr;
Ben Cahill52969982007-11-29 11:10:11 +08001721
Zhu Yib481de92007-09-25 17:54:57 -07001722 u8 rts_retry_limit; /*byte 50 */
1723 u8 data_retry_limit; /*byte 51 */
Zhu Yib481de92007-09-25 17:54:57 -07001724 u8 tid_tspec;
Zhu Yib481de92007-09-25 17:54:57 -07001725 union {
1726 __le16 pm_frame_timeout;
1727 __le16 attempt_duration;
1728 } timeout;
Ben Cahill52969982007-11-29 11:10:11 +08001729
1730 /*
1731 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1732 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1733 */
Zhu Yib481de92007-09-25 17:54:57 -07001734 __le16 driver_txop;
Ben Cahill52969982007-11-29 11:10:11 +08001735
1736 /*
1737 * MAC header goes here, followed by 2 bytes padding if MAC header
1738 * length is 26 or 30 bytes, followed by payload data
1739 */
Zhu Yib481de92007-09-25 17:54:57 -07001740 u8 payload[0];
1741 struct ieee80211_hdr hdr[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00001742} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07001743
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001744/* TX command response is sent after *3945* transmission attempts.
Zhu Yib481de92007-09-25 17:54:57 -07001745 *
1746 * NOTES:
1747 *
1748 * TX_STATUS_FAIL_NEXT_FRAG
1749 *
1750 * If the fragment flag in the MAC header for the frame being transmitted
1751 * is set and there is insufficient time to transmit the next frame, the
1752 * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
1753 *
1754 * TX_STATUS_FIFO_UNDERRUN
1755 *
1756 * Indicates the host did not provide bytes to the FIFO fast enough while
1757 * a TX was in progress.
1758 *
1759 * TX_STATUS_FAIL_MGMNT_ABORT
1760 *
1761 * This status is only possible if the ABORT ON MGMT RX parameter was
1762 * set to true with the TX command.
1763 *
1764 * If the MSB of the status parameter is set then an abort sequence is
1765 * required. This sequence consists of the host activating the TX Abort
1766 * control line, and then waiting for the TX Abort command response. This
1767 * indicates that a the device is no longer in a transmit state, and that the
1768 * command FIFO has been cleared. The host must then deactivate the TX Abort
1769 * control line. Receiving is still allowed in this case.
1770 */
1771enum {
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001772 TX_3945_STATUS_SUCCESS = 0x01,
1773 TX_3945_STATUS_DIRECT_DONE = 0x02,
1774 TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82,
1775 TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83,
1776 TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1777 TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85,
1778 TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86,
1779 TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1780 TX_3945_STATUS_FAIL_DEST_PS = 0x88,
1781 TX_3945_STATUS_FAIL_ABORTED = 0x89,
1782 TX_3945_STATUS_FAIL_BT_RETRY = 0x8a,
1783 TX_3945_STATUS_FAIL_STA_INVALID = 0x8b,
1784 TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1785 TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d,
1786 TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
1787 TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1788 TX_3945_STATUS_FAIL_TX_LOCKED = 0x90,
1789 TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1790};
1791
1792/*
1793 * TX command response is sent after *agn* transmission attempts.
1794 *
1795 * both postpone and abort status are expected behavior from uCode. there is
1796 * no special operation required from driver; except for RFKILL_FLUSH,
1797 * which required tx flush host command to flush all the tx frames in queues
1798 */
1799enum {
Zhu Yib481de92007-09-25 17:54:57 -07001800 TX_STATUS_SUCCESS = 0x01,
1801 TX_STATUS_DIRECT_DONE = 0x02,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001802 /* postpone TX */
1803 TX_STATUS_POSTPONE_DELAY = 0x40,
1804 TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
1805 TX_STATUS_POSTPONE_BT_PRIO = 0x42,
1806 TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
1807 TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
1808 /* abort TX */
1809 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
Zhu Yib481de92007-09-25 17:54:57 -07001810 TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
1811 TX_STATUS_FAIL_LONG_LIMIT = 0x83,
1812 TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001813 TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
1814 TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
Zhu Yib481de92007-09-25 17:54:57 -07001815 TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1816 TX_STATUS_FAIL_DEST_PS = 0x88,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001817 TX_STATUS_FAIL_HOST_ABORTED = 0x89,
Zhu Yib481de92007-09-25 17:54:57 -07001818 TX_STATUS_FAIL_BT_RETRY = 0x8a,
1819 TX_STATUS_FAIL_STA_INVALID = 0x8b,
1820 TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1821 TX_STATUS_FAIL_TID_DISABLE = 0x8d,
Wey-Yi Guy04569cb2010-03-31 17:57:28 -07001822 TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
Zhu Yib481de92007-09-25 17:54:57 -07001823 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
Wey-Yi Guy1d270072010-09-07 12:42:20 -07001824 TX_STATUS_FAIL_PASSIVE_NO_RX = 0x90,
1825 TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
Zhu Yib481de92007-09-25 17:54:57 -07001826};
1827
1828#define TX_PACKET_MODE_REGULAR 0x0000
1829#define TX_PACKET_MODE_BURST_SEQ 0x0100
1830#define TX_PACKET_MODE_BURST_FIRST 0x0200
1831
1832enum {
1833 TX_POWER_PA_NOT_ACTIVE = 0x0,
1834};
1835
1836enum {
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001837 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
Zhu Yib481de92007-09-25 17:54:57 -07001838 TX_STATUS_DELAY_MSK = 0x00000040,
1839 TX_STATUS_ABORT_MSK = 0x00000080,
1840 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
1841 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001842 TX_RESERVED = 0x00780000, /* bits 19:22 */
Zhu Yib481de92007-09-25 17:54:57 -07001843 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
1844 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
1845};
1846
1847/* *******************************
Ben Cahill52969982007-11-29 11:10:11 +08001848 * TX aggregation status
Zhu Yib481de92007-09-25 17:54:57 -07001849 ******************************* */
1850
1851enum {
1852 AGG_TX_STATE_TRANSMITTED = 0x00,
1853 AGG_TX_STATE_UNDERRUN_MSK = 0x01,
1854 AGG_TX_STATE_BT_PRIO_MSK = 0x02,
1855 AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1856 AGG_TX_STATE_ABORT_MSK = 0x08,
1857 AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1858 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1859 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
1860 AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1861 AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1862 AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1863 AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1864 AGG_TX_STATE_DELAY_TX_MSK = 0x400
1865};
1866
Wey-Yi Guye1b3fa02010-09-05 10:49:43 -07001867#define AGG_TX_STATUS_MSK 0x00000fff /* bits 0:11 */
1868#define AGG_TX_TRY_MSK 0x0000f000 /* bits 12:15 */
1869
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001870#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
1871 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
1872 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
Zhu Yib481de92007-09-25 17:54:57 -07001873
Ben Cahill52969982007-11-29 11:10:11 +08001874/* # tx attempts for first frame in aggregation */
Zhu Yib481de92007-09-25 17:54:57 -07001875#define AGG_TX_STATE_TRY_CNT_POS 12
1876#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1877
Ben Cahill52969982007-11-29 11:10:11 +08001878/* Command ID and sequence number of Tx command for this frame */
Zhu Yib481de92007-09-25 17:54:57 -07001879#define AGG_TX_STATE_SEQ_NUM_POS 16
1880#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1881
1882/*
1883 * REPLY_TX = 0x1c (response)
Ben Cahill52969982007-11-29 11:10:11 +08001884 *
1885 * This response may be in one of two slightly different formats, indicated
1886 * by the frame_count field:
1887 *
1888 * 1) No aggregation (frame_count == 1). This reports Tx results for
1889 * a single frame. Multiple attempts, at various bit rates, may have
1890 * been made for this frame.
1891 *
1892 * 2) Aggregation (frame_count > 1). This reports Tx results for
1893 * 2 or more frames that used block-acknowledge. All frames were
1894 * transmitted at same rate. Rate scaling may have been used if first
1895 * frame in this new agg block failed in previous agg block(s).
1896 *
1897 * Note that, for aggregation, ACK (block-ack) status is not delivered here;
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001898 * block-ack has not been received by the time the agn device records
1899 * this status.
Ben Cahill52969982007-11-29 11:10:11 +08001900 * This status relates to reasons the tx might have been blocked or aborted
Wey-Yi Guy767d0552010-08-23 07:56:53 -07001901 * within the sending station (this agn device), rather than whether it was
Ben Cahill52969982007-11-29 11:10:11 +08001902 * received successfully by the destination station.
Zhu Yib481de92007-09-25 17:54:57 -07001903 */
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001904struct agg_tx_status {
1905 __le16 status;
1906 __le16 sequence;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001907} __packed;
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001908
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001909struct iwl4965_tx_resp {
Zhu Yib481de92007-09-25 17:54:57 -07001910 u8 frame_count; /* 1 no aggregation, >1 aggregation */
Ben Cahill52969982007-11-29 11:10:11 +08001911 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
1912 u8 failure_rts; /* # failures due to unsuccessful RTS */
1913 u8 failure_frame; /* # failures due to no ACK (unused for agg) */
1914
1915 /* For non-agg: Rate at which frame was successful.
1916 * For agg: Rate at which all frames were transmitted. */
1917 __le32 rate_n_flags; /* RATE_MCS_* */
1918
1919 /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
1920 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1921 __le16 wireless_media_time; /* uSecs */
1922
Zhu Yib481de92007-09-25 17:54:57 -07001923 __le16 reserved;
Ben Cahill52969982007-11-29 11:10:11 +08001924 __le32 pa_power1; /* RF power amplifier measurement (not used) */
Zhu Yib481de92007-09-25 17:54:57 -07001925 __le32 pa_power2;
Ben Cahill52969982007-11-29 11:10:11 +08001926
1927 /*
1928 * For non-agg: frame status TX_STATUS_*
1929 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
1930 * fields follow this one, up to frame_count.
1931 * Bit fields:
1932 * 11- 0: AGG_TX_STATE_* status code
1933 * 15-12: Retry count for 1st frame in aggregation (retries
1934 * occur if tx failed for this frame when it was a
1935 * member of a previous aggregation block). If rate
1936 * scaling is used, retry count indicates the rate
1937 * table entry used for all frames in the new agg.
1938 * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
1939 */
Tomas Winkler25a65722008-06-12 09:47:07 +08001940 union {
1941 __le32 status;
1942 struct agg_tx_status agg_status[0]; /* for each agg frame */
1943 } u;
Eric Dumazetba2d3582010-06-02 18:10:09 +00001944} __packed;
Ron Rindjunskyfe01b472008-01-28 14:07:24 +02001945
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001946/*
1947 * definitions for initial rate index field
Tomas Winklera96a27f2008-10-23 23:48:56 -07001948 * bits [3:0] initial rate index
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001949 * bits [6:4] rate table color, used for the initial rate
1950 * bit-7 invalid rate indication
1951 * i.e. rate was not chosen from rate table
1952 * or rate table color was changed during frame retries
1953 * refer tlc rate info
1954 */
1955
1956#define IWL50_TX_RES_INIT_RATE_INDEX_POS 0
1957#define IWL50_TX_RES_INIT_RATE_INDEX_MSK 0x0f
1958#define IWL50_TX_RES_RATE_TABLE_COLOR_POS 4
1959#define IWL50_TX_RES_RATE_TABLE_COLOR_MSK 0x70
1960#define IWL50_TX_RES_INV_RATE_INDEX_MSK 0x80
1961
1962/* refer to ra_tid */
Wey-Yi Guy898dade2010-09-20 09:12:33 -07001963#define IWLAGN_TX_RES_TID_POS 0
1964#define IWLAGN_TX_RES_TID_MSK 0x0f
1965#define IWLAGN_TX_RES_RA_POS 4
1966#define IWLAGN_TX_RES_RA_MSK 0xf0
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001967
Wey-Yi Guy898dade2010-09-20 09:12:33 -07001968struct iwlagn_tx_resp {
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001969 u8 frame_count; /* 1 no aggregation, >1 aggregation */
1970 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
1971 u8 failure_rts; /* # failures due to unsuccessful RTS */
1972 u8 failure_frame; /* # failures due to no ACK (unused for agg) */
1973
1974 /* For non-agg: Rate at which frame was successful.
1975 * For agg: Rate at which all frames were transmitted. */
1976 __le32 rate_n_flags; /* RATE_MCS_* */
1977
1978 /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
1979 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1980 __le16 wireless_media_time; /* uSecs */
1981
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001982 u8 pa_status; /* RF power amplifier measurement (not used) */
1983 u8 pa_integ_res_a[3];
1984 u8 pa_integ_res_b[3];
1985 u8 pa_integ_res_C[3];
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001986
1987 __le32 tfd_info;
1988 __le16 seq_ctl;
1989 __le16 byte_cnt;
Tomas Winkler3fd07a12008-10-23 23:48:49 -07001990 u8 tlc_info;
1991 u8 ra_tid; /* tid (0:3), sta_id (4:7) */
1992 __le16 frame_ctrl;
Ron Rindjunsky001caff2008-05-29 16:35:07 +08001993 /*
1994 * For non-agg: frame status TX_STATUS_*
1995 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
1996 * fields follow this one, up to frame_count.
1997 * Bit fields:
1998 * 11- 0: AGG_TX_STATE_* status code
1999 * 15-12: Retry count for 1st frame in aggregation (retries
2000 * occur if tx failed for this frame when it was a
2001 * member of a previous aggregation block). If rate
2002 * scaling is used, retry count indicates the rate
2003 * table entry used for all frames in the new agg.
2004 * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
2005 */
2006 struct agg_tx_status status; /* TX status (in aggregation -
2007 * status of 1st frame) */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002008} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002009/*
2010 * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
Ben Cahill52969982007-11-29 11:10:11 +08002011 *
2012 * Reports Block-Acknowledge from recipient station
Zhu Yib481de92007-09-25 17:54:57 -07002013 */
Emmanuel Grumbach653fa4a2008-06-30 17:23:11 +08002014struct iwl_compressed_ba_resp {
Zhu Yib481de92007-09-25 17:54:57 -07002015 __le32 sta_addr_lo32;
2016 __le16 sta_addr_hi16;
2017 __le16 reserved;
Ben Cahill52969982007-11-29 11:10:11 +08002018
2019 /* Index of recipient (BA-sending) station in uCode's station table */
Zhu Yib481de92007-09-25 17:54:57 -07002020 u8 sta_id;
2021 u8 tid;
Ron Rindjunskyfe01b472008-01-28 14:07:24 +02002022 __le16 seq_ctl;
2023 __le64 bitmap;
Zhu Yib481de92007-09-25 17:54:57 -07002024 __le16 scd_flow;
2025 __le16 scd_ssn;
Wey-Yi Guy8829c9e2010-11-10 11:05:38 -08002026 /* following only for 5000 series and up */
2027 u8 txed; /* number of frames sent */
2028 u8 txed_2_done; /* number of frames acked */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002029} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002030
2031/*
2032 * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
Ben Cahill2bdc7032007-11-29 11:10:12 +08002033 *
2034 * See details under "TXPOWER" in iwl-4965-hw.h.
Zhu Yib481de92007-09-25 17:54:57 -07002035 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002036
2037struct iwl3945_txpowertable_cmd {
2038 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
2039 u8 reserved;
2040 __le16 channel;
2041 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002042} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002043
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002044struct iwl4965_txpowertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002045 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
2046 u8 reserved;
2047 __le16 channel;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002048 struct iwl4965_tx_power_db tx_power;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002049} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002050
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002051
2052/**
2053 * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response
2054 *
2055 * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
2056 *
2057 * NOTE: The table of rates passed to the uCode via the
2058 * RATE_SCALE command sets up the corresponding order of
2059 * rates used for all related commands, including rate
2060 * masks, etc.
2061 *
2062 * For example, if you set 9MB (PLCP 0x0f) as the first
2063 * rate in the rate table, the bit mask for that rate
2064 * when passed through ofdm_basic_rates on the REPLY_RXON
2065 * command would be bit 0 (1 << 0)
2066 */
2067struct iwl3945_rate_scaling_info {
2068 __le16 rate_n_flags;
2069 u8 try_cnt;
2070 u8 next_rate_index;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002071} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002072
2073struct iwl3945_rate_scaling_cmd {
2074 u8 table_id;
2075 u8 reserved[3];
2076 struct iwl3945_rate_scaling_info table[IWL_MAX_RATES];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002077} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002078
2079
Zhu Yib481de92007-09-25 17:54:57 -07002080/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
Reinette Chatre8a1b0242008-01-14 17:46:25 -08002081#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0)
Zhu Yib481de92007-09-25 17:54:57 -07002082
Ben Cahill2bdc7032007-11-29 11:10:12 +08002083/* # of EDCA prioritized tx fifos */
Zhu Yib481de92007-09-25 17:54:57 -07002084#define LINK_QUAL_AC_NUM AC_NUM
Ben Cahill2bdc7032007-11-29 11:10:12 +08002085
2086/* # entries in rate scale table to support Tx retries */
Zhu Yib481de92007-09-25 17:54:57 -07002087#define LINK_QUAL_MAX_RETRY_NUM 16
2088
Ben Cahill2bdc7032007-11-29 11:10:12 +08002089/* Tx antenna selection values */
Reinette Chatre8a1b0242008-01-14 17:46:25 -08002090#define LINK_QUAL_ANT_A_MSK (1 << 0)
2091#define LINK_QUAL_ANT_B_MSK (1 << 1)
Zhu Yib481de92007-09-25 17:54:57 -07002092#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
2093
Ben Cahill2bdc7032007-11-29 11:10:12 +08002094
2095/**
Tomas Winkler66c73db2008-04-15 16:01:40 -07002096 * struct iwl_link_qual_general_params
Ben Cahill2bdc7032007-11-29 11:10:12 +08002097 *
2098 * Used in REPLY_TX_LINK_QUALITY_CMD
2099 */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002100struct iwl_link_qual_general_params {
Zhu Yib481de92007-09-25 17:54:57 -07002101 u8 flags;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002102
2103 /* No entries at or above this (driver chosen) index contain MIMO */
Zhu Yib481de92007-09-25 17:54:57 -07002104 u8 mimo_delimiter;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002105
2106 /* Best single antenna to use for single stream (legacy, SISO). */
2107 u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */
2108
2109 /* Best antennas to use for MIMO (unused for 4965, assumes both). */
2110 u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */
2111
2112 /*
2113 * If driver needs to use different initial rates for different
2114 * EDCA QOS access categories (as implemented by tx fifos 0-3),
2115 * this table will set that up, by indicating the indexes in the
2116 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
2117 * Otherwise, driver should set all entries to 0.
2118 *
2119 * Entry usage:
2120 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
2121 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
2122 */
Zhu Yib481de92007-09-25 17:54:57 -07002123 u8 start_rate_index[LINK_QUAL_AC_NUM];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002124} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002125
Wey-Yi Guy13c33a02009-06-03 11:44:11 -07002126#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */
Wey-Yi Guyb15826a2010-07-28 09:18:53 -07002127#define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000)
2128#define LINK_QUAL_AGG_TIME_LIMIT_MIN (100)
Wey-Yi Guy13c33a02009-06-03 11:44:11 -07002129
2130#define LINK_QUAL_AGG_DISABLE_START_DEF (3)
2131#define LINK_QUAL_AGG_DISABLE_START_MAX (255)
2132#define LINK_QUAL_AGG_DISABLE_START_MIN (0)
2133
2134#define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31)
Johannes Bergb623a9f2009-07-01 14:57:59 +02002135#define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63)
Wey-Yi Guy13c33a02009-06-03 11:44:11 -07002136#define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0)
2137
Ben Cahill2bdc7032007-11-29 11:10:12 +08002138/**
Tomas Winkler66c73db2008-04-15 16:01:40 -07002139 * struct iwl_link_qual_agg_params
Ben Cahill2bdc7032007-11-29 11:10:12 +08002140 *
2141 * Used in REPLY_TX_LINK_QUALITY_CMD
2142 */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002143struct iwl_link_qual_agg_params {
Ben Cahill2bdc7032007-11-29 11:10:12 +08002144
Wey-Yi Guy74697012010-07-28 09:18:54 -07002145 /*
2146 *Maximum number of uSec in aggregation.
2147 * default set to 4000 (4 milliseconds) if not configured in .cfg
2148 */
Zhu Yib481de92007-09-25 17:54:57 -07002149 __le16 agg_time_limit;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002150
2151 /*
2152 * Number of Tx retries allowed for a frame, before that frame will
2153 * no longer be considered for the start of an aggregation sequence
2154 * (scheduler will then try to tx it as single frame).
2155 * Driver should set this to 3.
2156 */
Zhu Yib481de92007-09-25 17:54:57 -07002157 u8 agg_dis_start_th;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002158
2159 /*
2160 * Maximum number of frames in aggregation.
2161 * 0 = no limit (default). 1 = no aggregation.
2162 * Other values = max # frames in aggregation.
2163 */
Zhu Yib481de92007-09-25 17:54:57 -07002164 u8 agg_frame_cnt_limit;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002165
Zhu Yib481de92007-09-25 17:54:57 -07002166 __le32 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002167} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002168
2169/*
2170 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
Ben Cahill2bdc7032007-11-29 11:10:12 +08002171 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002172 * For agn devices only; 3945 uses REPLY_RATE_SCALE.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002173 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002174 * Each station in the agn device's internal station table has its own table
2175 * of 16
Ben Cahill2bdc7032007-11-29 11:10:12 +08002176 * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
2177 * an ACK is not received. This command replaces the entire table for
2178 * one station.
2179 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002180 * NOTE: Station must already be in agn device's station table.
2181 * Use REPLY_ADD_STA.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002182 *
2183 * The rate scaling procedures described below work well. Of course, other
2184 * procedures are possible, and may work better for particular environments.
2185 *
2186 *
2187 * FILLING THE RATE TABLE
2188 *
2189 * Given a particular initial rate and mode, as determined by the rate
2190 * scaling algorithm described below, the Linux driver uses the following
2191 * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
2192 * Link Quality command:
2193 *
2194 *
2195 * 1) If using High-throughput (HT) (SISO or MIMO) initial rate:
2196 * a) Use this same initial rate for first 3 entries.
2197 * b) Find next lower available rate using same mode (SISO or MIMO),
2198 * use for next 3 entries. If no lower rate available, switch to
Wey-Yi Guy7aafef12009-08-07 15:41:38 -07002199 * legacy mode (no HT40 channel, no MIMO, no short guard interval).
Ben Cahill2bdc7032007-11-29 11:10:12 +08002200 * c) If using MIMO, set command's mimo_delimiter to number of entries
2201 * using MIMO (3 or 6).
Wey-Yi Guy7aafef12009-08-07 15:41:38 -07002202 * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
Ben Cahill2bdc7032007-11-29 11:10:12 +08002203 * no MIMO, no short guard interval), at the next lower bit rate
2204 * (e.g. if second HT bit rate was 54, try 48 legacy), and follow
2205 * legacy procedure for remaining table entries.
2206 *
2207 * 2) If using legacy initial rate:
2208 * a) Use the initial rate for only one entry.
2209 * b) For each following entry, reduce the rate to next lower available
2210 * rate, until reaching the lowest available rate.
2211 * c) When reducing rate, also switch antenna selection.
2212 * d) Once lowest available rate is reached, repeat this rate until
2213 * rate table is filled (16 entries), switching antenna each entry.
2214 *
2215 *
2216 * ACCUMULATING HISTORY
2217 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002218 * The rate scaling algorithm for agn devices, as implemented in Linux driver,
2219 * uses two sets of frame Tx success history: One for the current/active
2220 * modulation mode, and one for a speculative/search mode that is being
2221 * attempted. If the speculative mode turns out to be more effective (i.e.
2222 * actual transfer rate is better), then the driver continues to use the
2223 * speculative mode as the new current active mode.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002224 *
2225 * Each history set contains, separately for each possible rate, data for a
2226 * sliding window of the 62 most recent tx attempts at that rate. The data
2227 * includes a shifting bitmap of success(1)/failure(0), and sums of successful
2228 * and attempted frames, from which the driver can additionally calculate a
2229 * success ratio (success / attempted) and number of failures
2230 * (attempted - success), and control the size of the window (attempted).
2231 * The driver uses the bit map to remove successes from the success sum, as
2232 * the oldest tx attempts fall out of the window.
2233 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002234 * When the agn device makes multiple tx attempts for a given frame, each
2235 * attempt might be at a different rate, and have different modulation
2236 * characteristics (e.g. antenna, fat channel, short guard interval), as set
2237 * up in the rate scaling table in the Link Quality command. The driver must
2238 * determine which rate table entry was used for each tx attempt, to determine
2239 * which rate-specific history to update, and record only those attempts that
Ben Cahill2bdc7032007-11-29 11:10:12 +08002240 * match the modulation characteristics of the history set.
2241 *
2242 * When using block-ack (aggregation), all frames are transmitted at the same
Tomas Winklera96a27f2008-10-23 23:48:56 -07002243 * rate, since there is no per-attempt acknowledgment from the destination
Ben Cahill2bdc7032007-11-29 11:10:12 +08002244 * station. The Tx response struct iwl_tx_resp indicates the Tx rate in
2245 * rate_n_flags field. After receiving a block-ack, the driver can update
2246 * history for the entire block all at once.
2247 *
2248 *
2249 * FINDING BEST STARTING RATE:
2250 *
2251 * When working with a selected initial modulation mode (see below), the
2252 * driver attempts to find a best initial rate. The initial rate is the
2253 * first entry in the Link Quality command's rate table.
2254 *
2255 * 1) Calculate actual throughput (success ratio * expected throughput, see
2256 * table below) for current initial rate. Do this only if enough frames
2257 * have been attempted to make the value meaningful: at least 6 failed
2258 * tx attempts, or at least 8 successes. If not enough, don't try rate
2259 * scaling yet.
2260 *
2261 * 2) Find available rates adjacent to current initial rate. Available means:
2262 * a) supported by hardware &&
2263 * b) supported by association &&
2264 * c) within any constraints selected by user
2265 *
2266 * 3) Gather measured throughputs for adjacent rates. These might not have
2267 * enough history to calculate a throughput. That's okay, we might try
2268 * using one of them anyway!
2269 *
2270 * 4) Try decreasing rate if, for current rate:
2271 * a) success ratio is < 15% ||
2272 * b) lower adjacent rate has better measured throughput ||
2273 * c) higher adjacent rate has worse throughput, and lower is unmeasured
2274 *
2275 * As a sanity check, if decrease was determined above, leave rate
2276 * unchanged if:
2277 * a) lower rate unavailable
2278 * b) success ratio at current rate > 85% (very good)
2279 * c) current measured throughput is better than expected throughput
2280 * of lower rate (under perfect 100% tx conditions, see table below)
2281 *
2282 * 5) Try increasing rate if, for current rate:
2283 * a) success ratio is < 15% ||
2284 * b) both adjacent rates' throughputs are unmeasured (try it!) ||
2285 * b) higher adjacent rate has better measured throughput ||
2286 * c) lower adjacent rate has worse throughput, and higher is unmeasured
2287 *
2288 * As a sanity check, if increase was determined above, leave rate
2289 * unchanged if:
2290 * a) success ratio at current rate < 70%. This is not particularly
2291 * good performance; higher rate is sure to have poorer success.
2292 *
2293 * 6) Re-evaluate the rate after each tx frame. If working with block-
2294 * acknowledge, history and statistics may be calculated for the entire
2295 * block (including prior history that fits within the history windows),
2296 * before re-evaluation.
2297 *
2298 * FINDING BEST STARTING MODULATION MODE:
2299 *
2300 * After working with a modulation mode for a "while" (and doing rate scaling),
2301 * the driver searches for a new initial mode in an attempt to improve
2302 * throughput. The "while" is measured by numbers of attempted frames:
2303 *
2304 * For legacy mode, search for new mode after:
2305 * 480 successful frames, or 160 failed frames
2306 * For high-throughput modes (SISO or MIMO), search for new mode after:
2307 * 4500 successful frames, or 400 failed frames
2308 *
2309 * Mode switch possibilities are (3 for each mode):
2310 *
2311 * For legacy:
2312 * Change antenna, try SISO (if HT association), try MIMO (if HT association)
2313 * For SISO:
2314 * Change antenna, try MIMO, try shortened guard interval (SGI)
2315 * For MIMO:
2316 * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
2317 *
2318 * When trying a new mode, use the same bit rate as the old/current mode when
2319 * trying antenna switches and shortened guard interval. When switching to
2320 * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
2321 * for which the expected throughput (under perfect conditions) is about the
2322 * same or slightly better than the actual measured throughput delivered by
2323 * the old/current mode.
2324 *
2325 * Actual throughput can be estimated by multiplying the expected throughput
2326 * by the success ratio (successful / attempted tx frames). Frame size is
2327 * not considered in this calculation; it assumes that frame size will average
2328 * out to be fairly consistent over several samples. The following are
2329 * metric values for expected throughput assuming 100% success ratio.
2330 * Only G band has support for CCK rates:
2331 *
2332 * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60
2333 *
2334 * G: 7 13 35 58 40 57 72 98 121 154 177 186 186
2335 * A: 0 0 0 0 40 57 72 98 121 154 177 186 186
2336 * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202
2337 * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211
2338 * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251
2339 * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257
2340 * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257
2341 * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264
2342 * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289
2343 * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293
2344 *
2345 * After the new mode has been tried for a short while (minimum of 6 failed
2346 * frames or 8 successful frames), compare success ratio and actual throughput
2347 * estimate of the new mode with the old. If either is better with the new
2348 * mode, continue to use the new mode.
2349 *
2350 * Continue comparing modes until all 3 possibilities have been tried.
2351 * If moving from legacy to HT, try all 3 possibilities from the new HT
2352 * mode. After trying all 3, a best mode is found. Continue to use this mode
2353 * for the longer "while" described above (e.g. 480 successful frames for
2354 * legacy), and then repeat the search process.
2355 *
Zhu Yib481de92007-09-25 17:54:57 -07002356 */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002357struct iwl_link_quality_cmd {
Ben Cahill2bdc7032007-11-29 11:10:12 +08002358
2359 /* Index of destination/recipient station in uCode's station table */
Zhu Yib481de92007-09-25 17:54:57 -07002360 u8 sta_id;
2361 u8 reserved1;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002362 __le16 control; /* not used */
Tomas Winkler66c73db2008-04-15 16:01:40 -07002363 struct iwl_link_qual_general_params general_params;
2364 struct iwl_link_qual_agg_params agg_params;
Ben Cahill2bdc7032007-11-29 11:10:12 +08002365
2366 /*
2367 * Rate info; when using rate-scaling, Tx command's initial_rate_index
2368 * specifies 1st Tx rate attempted, via index into this table.
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002369 * agn devices works its way through table when retrying Tx.
Ben Cahill2bdc7032007-11-29 11:10:12 +08002370 */
Zhu Yib481de92007-09-25 17:54:57 -07002371 struct {
Ben Cahill2bdc7032007-11-29 11:10:12 +08002372 __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */
Zhu Yib481de92007-09-25 17:54:57 -07002373 } rs_table[LINK_QUAL_MAX_RETRY_NUM];
2374 __le32 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002375} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002376
Wey-Yi Guydab1c162010-01-22 14:22:50 -08002377/*
2378 * BT configuration enable flags:
2379 * bit 0 - 1: BT channel announcement enabled
2380 * 0: disable
2381 * bit 1 - 1: priority of BT device enabled
2382 * 0: disable
2383 * bit 2 - 1: BT 2 wire support enabled
2384 * 0: disable
2385 */
Wey-Yi Guy456d0f72009-10-23 13:42:23 -07002386#define BT_COEX_DISABLE (0x0)
Wey-Yi Guydab1c162010-01-22 14:22:50 -08002387#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0)
2388#define BT_ENABLE_PRIORITY BIT(1)
2389#define BT_ENABLE_2_WIRE BIT(2)
Wey-Yi Guy456d0f72009-10-23 13:42:23 -07002390
Wey-Yi Guy06702a72010-01-22 14:22:51 -08002391#define BT_COEX_DISABLE (0x0)
2392#define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY)
2393
Wey-Yi Guy456d0f72009-10-23 13:42:23 -07002394#define BT_LEAD_TIME_MIN (0x0)
2395#define BT_LEAD_TIME_DEF (0x1E)
2396#define BT_LEAD_TIME_MAX (0xFF)
2397
2398#define BT_MAX_KILL_MIN (0x1)
2399#define BT_MAX_KILL_DEF (0x5)
2400#define BT_MAX_KILL_MAX (0xFF)
2401
Wey-Yi Guy22bf59a2010-08-23 07:57:11 -07002402#define BT_DURATION_LIMIT_DEF 625
2403#define BT_DURATION_LIMIT_MAX 1250
2404#define BT_DURATION_LIMIT_MIN 625
2405
2406#define BT_ON_THRESHOLD_DEF 4
2407#define BT_ON_THRESHOLD_MAX 1000
2408#define BT_ON_THRESHOLD_MIN 1
2409
2410#define BT_FRAG_THRESHOLD_DEF 0
2411#define BT_FRAG_THRESHOLD_MAX 0
2412#define BT_FRAG_THRESHOLD_MIN 0
2413
Wey-Yi Guy95a5ede2010-11-08 14:55:43 -08002414#define BT_AGG_THRESHOLD_DEF 1200
2415#define BT_AGG_THRESHOLD_MAX 8000
2416#define BT_AGG_THRESHOLD_MIN 400
Wey-Yi Guy22bf59a2010-08-23 07:57:11 -07002417
Zhu Yib481de92007-09-25 17:54:57 -07002418/*
2419 * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
Ben Cahill3058f022008-01-14 17:46:17 -08002420 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002421 * 3945 and agn devices support hardware handshake with Bluetooth device on
Ben Cahill3058f022008-01-14 17:46:17 -08002422 * same platform. Bluetooth device alerts wireless device when it will Tx;
Tomas Winklera96a27f2008-10-23 23:48:56 -07002423 * wireless device can delay or kill its own Tx to accommodate.
Zhu Yib481de92007-09-25 17:54:57 -07002424 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002425struct iwl_bt_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002426 u8 flags;
2427 u8 lead_time;
2428 u8 max_kill;
2429 u8 reserved;
2430 __le32 kill_ack_mask;
2431 __le32 kill_cts_mask;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002432} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002433
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002434#define IWLAGN_BT_FLAG_CHANNEL_INHIBITION BIT(0)
Johannes Berg670245e2010-08-23 07:56:55 -07002435
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002436#define IWLAGN_BT_FLAG_COEX_MODE_MASK (BIT(3)|BIT(4)|BIT(5))
2437#define IWLAGN_BT_FLAG_COEX_MODE_SHIFT 3
2438#define IWLAGN_BT_FLAG_COEX_MODE_DISABLED 0
2439#define IWLAGN_BT_FLAG_COEX_MODE_LEGACY_2W 1
2440#define IWLAGN_BT_FLAG_COEX_MODE_3W 2
2441#define IWLAGN_BT_FLAG_COEX_MODE_4W 3
Johannes Berg670245e2010-08-23 07:56:55 -07002442
Wey-Yi Guyeeb1f832010-11-23 10:58:52 -08002443#define IWLAGN_BT_FLAG_UCODE_DEFAULT BIT(6)
2444/* Disable Sync PSPoll on SCO/eSCO */
2445#define IWLAGN_BT_FLAG_SYNC_2_BT_DISABLE BIT(7)
Johannes Berg670245e2010-08-23 07:56:55 -07002446
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002447#define IWLAGN_BT_PRIO_BOOST_MAX 0xFF
2448#define IWLAGN_BT_PRIO_BOOST_MIN 0x00
2449#define IWLAGN_BT_PRIO_BOOST_DEFAULT 0xF0
Johannes Berg670245e2010-08-23 07:56:55 -07002450
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002451#define IWLAGN_BT_MAX_KILL_DEFAULT 5
Johannes Berg670245e2010-08-23 07:56:55 -07002452
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002453#define IWLAGN_BT3_T7_DEFAULT 1
Johannes Berg670245e2010-08-23 07:56:55 -07002454
Wey-Yi Guy05433df2010-11-08 12:37:20 -08002455#define IWLAGN_BT_KILL_ACK_MASK_DEFAULT cpu_to_le32(0xffff0000)
2456#define IWLAGN_BT_KILL_CTS_MASK_DEFAULT cpu_to_le32(0xffff0000)
Wey-Yi Guy506aa152010-11-24 17:25:03 -08002457#define IWLAGN_BT_KILL_ACK_CTS_MASK_SCO cpu_to_le32(0xffffffff)
Johannes Berg670245e2010-08-23 07:56:55 -07002458
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002459#define IWLAGN_BT3_PRIO_SAMPLE_DEFAULT 2
Johannes Berg670245e2010-08-23 07:56:55 -07002460
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002461#define IWLAGN_BT3_T2_DEFAULT 0xc
Johannes Berg670245e2010-08-23 07:56:55 -07002462
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002463#define IWLAGN_BT_VALID_ENABLE_FLAGS cpu_to_le16(BIT(0))
2464#define IWLAGN_BT_VALID_BOOST cpu_to_le16(BIT(1))
2465#define IWLAGN_BT_VALID_MAX_KILL cpu_to_le16(BIT(2))
2466#define IWLAGN_BT_VALID_3W_TIMERS cpu_to_le16(BIT(3))
2467#define IWLAGN_BT_VALID_KILL_ACK_MASK cpu_to_le16(BIT(4))
2468#define IWLAGN_BT_VALID_KILL_CTS_MASK cpu_to_le16(BIT(5))
2469#define IWLAGN_BT_VALID_BT4_TIMES cpu_to_le16(BIT(6))
2470#define IWLAGN_BT_VALID_3W_LUT cpu_to_le16(BIT(7))
Johannes Berg670245e2010-08-23 07:56:55 -07002471
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002472#define IWLAGN_BT_ALL_VALID_MSK (IWLAGN_BT_VALID_ENABLE_FLAGS | \
2473 IWLAGN_BT_VALID_BOOST | \
2474 IWLAGN_BT_VALID_MAX_KILL | \
2475 IWLAGN_BT_VALID_3W_TIMERS | \
2476 IWLAGN_BT_VALID_KILL_ACK_MASK | \
2477 IWLAGN_BT_VALID_KILL_CTS_MASK | \
2478 IWLAGN_BT_VALID_BT4_TIMES | \
2479 IWLAGN_BT_VALID_3W_LUT)
Johannes Berg670245e2010-08-23 07:56:55 -07002480
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002481struct iwlagn_bt_cmd {
Johannes Berg670245e2010-08-23 07:56:55 -07002482 u8 flags;
2483 u8 ledtime; /* unused */
2484 u8 max_kill;
2485 u8 bt3_timer_t7_value;
2486 __le32 kill_ack_mask;
2487 __le32 kill_cts_mask;
2488 u8 bt3_prio_sample_time;
2489 u8 bt3_timer_t2_value;
2490 __le16 bt4_reaction_time; /* unused */
2491 __le32 bt3_lookup_table[12];
2492 __le16 bt4_decision_time; /* unused */
2493 __le16 valid;
2494 u8 prio_boost;
Wey-Yi Guyb345f4d2010-09-13 07:51:03 -07002495 /*
2496 * set IWLAGN_BT_VALID_BOOST to "1" in "valid" bitmask
2497 * if configure the following patterns
2498 */
2499 u8 tx_prio_boost; /* SW boost of WiFi tx priority */
2500 __le16 rx_prio_boost; /* SW boost of WiFi rx priority */
Johannes Berg670245e2010-08-23 07:56:55 -07002501};
2502
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002503#define IWLAGN_BT_SCO_ACTIVE cpu_to_le32(BIT(0))
Johannes Berg9e4afc22010-08-23 07:56:57 -07002504
Wey-Yi Guyb6e116e2010-08-23 07:57:14 -07002505struct iwlagn_bt_sco_cmd {
Johannes Berg9e4afc22010-08-23 07:56:57 -07002506 __le32 flags;
2507};
2508
Zhu Yib481de92007-09-25 17:54:57 -07002509/******************************************************************************
2510 * (6)
2511 * Spectrum Management (802.11h) Commands, Responses, Notifications:
2512 *
2513 *****************************************************************************/
2514
2515/*
2516 * Spectrum Management
2517 */
2518#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
2519 RXON_FILTER_CTL2HOST_MSK | \
2520 RXON_FILTER_ACCEPT_GRP_MSK | \
2521 RXON_FILTER_DIS_DECRYPT_MSK | \
2522 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
2523 RXON_FILTER_ASSOC_MSK | \
2524 RXON_FILTER_BCON_AWARE_MSK)
2525
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002526struct iwl_measure_channel {
Zhu Yib481de92007-09-25 17:54:57 -07002527 __le32 duration; /* measurement duration in extended beacon
2528 * format */
2529 u8 channel; /* channel to measure */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002530 u8 type; /* see enum iwl_measure_type */
Zhu Yib481de92007-09-25 17:54:57 -07002531 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002532} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002533
2534/*
2535 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
2536 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002537struct iwl_spectrum_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002538 __le16 len; /* number of bytes starting from token */
2539 u8 token; /* token id */
2540 u8 id; /* measurement id -- 0 or 1 */
2541 u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
2542 u8 periodic; /* 1 = periodic */
2543 __le16 path_loss_timeout;
2544 __le32 start_time; /* start time in extended beacon format */
2545 __le32 reserved2;
2546 __le32 flags; /* rxon flags */
2547 __le32 filter_flags; /* rxon filter flags */
2548 __le16 channel_count; /* minimum 1, maximum 10 */
2549 __le16 reserved3;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002550 struct iwl_measure_channel channels[10];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002551} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002552
2553/*
2554 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
2555 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002556struct iwl_spectrum_resp {
Zhu Yib481de92007-09-25 17:54:57 -07002557 u8 token;
2558 u8 id; /* id of the prior command replaced, or 0xff */
2559 __le16 status; /* 0 - command will be handled
2560 * 1 - cannot handle (conflicts with another
2561 * measurement) */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002562} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002563
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002564enum iwl_measurement_state {
Zhu Yib481de92007-09-25 17:54:57 -07002565 IWL_MEASUREMENT_START = 0,
2566 IWL_MEASUREMENT_STOP = 1,
2567};
2568
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002569enum iwl_measurement_status {
Zhu Yib481de92007-09-25 17:54:57 -07002570 IWL_MEASUREMENT_OK = 0,
2571 IWL_MEASUREMENT_CONCURRENT = 1,
2572 IWL_MEASUREMENT_CSA_CONFLICT = 2,
2573 IWL_MEASUREMENT_TGH_CONFLICT = 3,
2574 /* 4-5 reserved */
2575 IWL_MEASUREMENT_STOPPED = 6,
2576 IWL_MEASUREMENT_TIMEOUT = 7,
2577 IWL_MEASUREMENT_PERIODIC_FAILED = 8,
2578};
2579
2580#define NUM_ELEMENTS_IN_HISTOGRAM 8
2581
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002582struct iwl_measurement_histogram {
Zhu Yib481de92007-09-25 17:54:57 -07002583 __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
2584 __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002585} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002586
2587/* clear channel availability counters */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002588struct iwl_measurement_cca_counters {
Zhu Yib481de92007-09-25 17:54:57 -07002589 __le32 ofdm;
2590 __le32 cck;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002591} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002592
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002593enum iwl_measure_type {
Zhu Yib481de92007-09-25 17:54:57 -07002594 IWL_MEASURE_BASIC = (1 << 0),
2595 IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
2596 IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
2597 IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
2598 IWL_MEASURE_FRAME = (1 << 4),
2599 /* bits 5:6 are reserved */
2600 IWL_MEASURE_IDLE = (1 << 7),
2601};
2602
2603/*
2604 * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
2605 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002606struct iwl_spectrum_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002607 u8 id; /* measurement id -- 0 or 1 */
2608 u8 token;
2609 u8 channel_index; /* index in measurement channel list */
2610 u8 state; /* 0 - start, 1 - stop */
2611 __le32 start_time; /* lower 32-bits of TSF */
2612 u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
2613 u8 channel;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002614 u8 type; /* see enum iwl_measurement_type */
Zhu Yib481de92007-09-25 17:54:57 -07002615 u8 reserved1;
2616 /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
2617 * valid if applicable for measurement type requested. */
2618 __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
2619 __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
2620 __le32 cca_time; /* channel load time in usecs */
2621 u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
2622 * unidentified */
2623 u8 reserved2[3];
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002624 struct iwl_measurement_histogram histogram;
Zhu Yib481de92007-09-25 17:54:57 -07002625 __le32 stop_time; /* lower 32-bits of TSF */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002626 __le32 status; /* see iwl_measurement_status */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002627} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002628
2629/******************************************************************************
2630 * (7)
2631 * Power Management Commands, Responses, Notifications:
2632 *
2633 *****************************************************************************/
2634
2635/**
Mohamed Abbasca579612008-07-18 13:52:57 +08002636 * struct iwl_powertable_cmd - Power Table Command
Zhu Yib481de92007-09-25 17:54:57 -07002637 * @flags: See below:
2638 *
2639 * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
2640 *
2641 * PM allow:
2642 * bit 0 - '0' Driver not allow power management
2643 * '1' Driver allow PM (use rest of parameters)
Johannes Berge312c242009-08-07 15:41:51 -07002644 *
Zhu Yib481de92007-09-25 17:54:57 -07002645 * uCode send sleep notifications:
2646 * bit 1 - '0' Don't send sleep notification
2647 * '1' send sleep notification (SEND_PM_NOTIFICATION)
Johannes Berge312c242009-08-07 15:41:51 -07002648 *
Zhu Yib481de92007-09-25 17:54:57 -07002649 * Sleep over DTIM
2650 * bit 2 - '0' PM have to walk up every DTIM
2651 * '1' PM could sleep over DTIM till listen Interval.
Johannes Berge312c242009-08-07 15:41:51 -07002652 *
Zhu Yib481de92007-09-25 17:54:57 -07002653 * PCI power managed
Tomas Winklere7b63582008-09-03 11:26:49 +08002654 * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
2655 * '1' !(PCI_CFG_LINK_CTRL & 0x1)
Johannes Berge312c242009-08-07 15:41:51 -07002656 *
2657 * Fast PD
2658 * bit 4 - '1' Put radio to sleep when receiving frame for others
2659 *
Zhu Yib481de92007-09-25 17:54:57 -07002660 * Force sleep Modes
2661 * bit 31/30- '00' use both mac/xtal sleeps
2662 * '01' force Mac sleep
2663 * '10' force xtal sleep
2664 * '11' Illegal set
2665 *
2666 * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
Tomas Winklera96a27f2008-10-23 23:48:56 -07002667 * ucode assume sleep over DTIM is allowed and we don't need to wake up
Zhu Yib481de92007-09-25 17:54:57 -07002668 * for every DTIM.
2669 */
2670#define IWL_POWER_VEC_SIZE 5
2671
Tomas Winkler600c0e12008-12-19 10:37:04 +08002672#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0))
Wey-Yi Guy35162ba2010-11-23 10:58:56 -08002673#define IWL_POWER_POWER_SAVE_ENA_MSK cpu_to_le16(BIT(0))
2674#define IWL_POWER_POWER_MANAGEMENT_ENA_MSK cpu_to_le16(BIT(1))
Tomas Winkler600c0e12008-12-19 10:37:04 +08002675#define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le16(BIT(2))
2676#define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3))
2677#define IWL_POWER_FAST_PD cpu_to_le16(BIT(4))
Wey-Yi Guy97badb02010-11-23 10:58:53 -08002678#define IWL_POWER_BEACON_FILTERING cpu_to_le16(BIT(5))
2679#define IWL_POWER_SHADOW_REG_ENA cpu_to_le16(BIT(6))
2680#define IWL_POWER_CT_KILL_SET cpu_to_le16(BIT(7))
2681#define IWL_POWER_BT_SCO_ENA cpu_to_le16(BIT(8))
Wey-Yi Guy35162ba2010-11-23 10:58:56 -08002682#define IWL_POWER_ADVANCE_PM_ENA_MSK cpu_to_le16(BIT(9))
Tomas Winkler600c0e12008-12-19 10:37:04 +08002683
2684struct iwl3945_powertable_cmd {
2685 __le16 flags;
2686 u8 reserved[2];
2687 __le32 rx_data_timeout;
2688 __le32 tx_data_timeout;
2689 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002690} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002691
Mohamed Abbasca579612008-07-18 13:52:57 +08002692struct iwl_powertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002693 __le16 flags;
Tomas Winkler600c0e12008-12-19 10:37:04 +08002694 u8 keep_alive_seconds; /* 3945 reserved */
2695 u8 debug_flags; /* 3945 reserved */
Zhu Yib481de92007-09-25 17:54:57 -07002696 __le32 rx_data_timeout;
2697 __le32 tx_data_timeout;
2698 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
2699 __le32 keep_alive_beacons;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002700} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002701
2702/*
2703 * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002704 * all devices identical.
Zhu Yib481de92007-09-25 17:54:57 -07002705 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002706struct iwl_sleep_notification {
Zhu Yib481de92007-09-25 17:54:57 -07002707 u8 pm_sleep_mode;
2708 u8 pm_wakeup_src;
2709 __le16 reserved;
2710 __le32 sleep_time;
2711 __le32 tsf_low;
2712 __le32 bcon_timer;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002713} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002714
Wey-Yi Guy767d0552010-08-23 07:56:53 -07002715/* Sleep states. all devices identical. */
Zhu Yib481de92007-09-25 17:54:57 -07002716enum {
2717 IWL_PM_NO_SLEEP = 0,
2718 IWL_PM_SLP_MAC = 1,
2719 IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
2720 IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
2721 IWL_PM_SLP_PHY = 4,
2722 IWL_PM_SLP_REPENT = 5,
2723 IWL_PM_WAKEUP_BY_TIMER = 6,
2724 IWL_PM_WAKEUP_BY_DRIVER = 7,
2725 IWL_PM_WAKEUP_BY_RFKILL = 8,
2726 /* 3 reserved */
2727 IWL_PM_NUM_OF_MODES = 12,
2728};
2729
2730/*
2731 * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
2732 */
2733#define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
2734#define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
2735#define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002736struct iwl_card_state_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002737 __le32 status; /* CARD_STATE_CMD_* request new power state */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002738} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002739
2740/*
2741 * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
2742 */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002743struct iwl_card_state_notif {
Zhu Yib481de92007-09-25 17:54:57 -07002744 __le32 flags;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002745} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002746
2747#define HW_CARD_DISABLED 0x01
2748#define SW_CARD_DISABLED 0x02
Wey-Yi Guy3a41bbd2009-12-10 14:37:24 -08002749#define CT_CARD_DISABLED 0x04
Zhu Yib481de92007-09-25 17:54:57 -07002750#define RXON_CARD_DISABLED 0x10
2751
Emmanuel Grumbach47f4a582008-06-12 09:47:13 +08002752struct iwl_ct_kill_config {
Zhu Yib481de92007-09-25 17:54:57 -07002753 __le32 reserved;
2754 __le32 critical_temperature_M;
2755 __le32 critical_temperature_R;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002756} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002757
Wey-Yi Guy672639d2009-07-24 11:13:01 -07002758/* 1000, and 6x00 */
2759struct iwl_ct_kill_throttling_config {
2760 __le32 critical_temperature_exit;
2761 __le32 reserved;
2762 __le32 critical_temperature_enter;
Eric Dumazetba2d3582010-06-02 18:10:09 +00002763} __packed;
Wey-Yi Guy672639d2009-07-24 11:13:01 -07002764
Zhu Yib481de92007-09-25 17:54:57 -07002765/******************************************************************************
2766 * (8)
2767 * Scan Commands, Responses, Notifications:
2768 *
2769 *****************************************************************************/
2770
Harvey Harrison51e9bf52008-11-26 13:12:52 -08002771#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
2772#define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1)
Tomas Winklerd16dc482008-07-11 11:53:38 +08002773
Ben Cahill3058f022008-01-14 17:46:17 -08002774/**
Tomas Winkler2a421b92008-06-12 09:47:10 +08002775 * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
Ben Cahill3058f022008-01-14 17:46:17 -08002776 *
2777 * One for each channel in the scan list.
2778 * Each channel can independently select:
2779 * 1) SSID for directed active scans
2780 * 2) Txpower setting (for rate specified within Tx command)
2781 * 3) How long to stay on-channel (behavior may be modified by quiet_time,
2782 * quiet_plcp_th, good_CRC_th)
2783 *
2784 * To avoid uCode errors, make sure the following are true (see comments
Tomas Winkler2a421b92008-06-12 09:47:10 +08002785 * under struct iwl_scan_cmd about max_out_time and quiet_time):
Ben Cahill3058f022008-01-14 17:46:17 -08002786 * 1) If using passive_dwell (i.e. passive_dwell != 0):
2787 * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
2788 * 2) quiet_time <= active_dwell
2789 * 3) If restricting off-channel time (i.e. max_out_time !=0):
2790 * passive_dwell < max_out_time
2791 * active_dwell < max_out_time
2792 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002793
2794/* FIXME: rename to AP1, remove tpc */
2795struct iwl3945_scan_channel {
2796 /*
2797 * type is defined as:
2798 * 0:0 1 = active, 0 = passive
2799 * 1:4 SSID direct bit map; if a bit is set, then corresponding
2800 * SSID IE is transmitted in probe request.
2801 * 5:7 reserved
2802 */
2803 u8 type;
2804 u8 channel; /* band is selected by iwl3945_scan_cmd "flags" field */
2805 struct iwl3945_tx_power tpc;
2806 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2807 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002808} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002809
Winkler, Tomas0d210442009-01-23 13:45:21 -08002810/* set number of direct probes u8 type */
2811#define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1))))
2812
Tomas Winkler2a421b92008-06-12 09:47:10 +08002813struct iwl_scan_channel {
Ben Cahill3058f022008-01-14 17:46:17 -08002814 /*
2815 * type is defined as:
2816 * 0:0 1 = active, 0 = passive
Tomas Winklerd16dc482008-07-11 11:53:38 +08002817 * 1:20 SSID direct bit map; if a bit is set, then corresponding
Ben Cahill3058f022008-01-14 17:46:17 -08002818 * SSID IE is transmitted in probe request.
Tomas Winklerd16dc482008-07-11 11:53:38 +08002819 * 21:31 reserved
Zhu Yib481de92007-09-25 17:54:57 -07002820 */
Tomas Winklerd16dc482008-07-11 11:53:38 +08002821 __le32 type;
2822 __le16 channel; /* band is selected by iwl_scan_cmd "flags" field */
Tomas Winklerf53696d2008-06-12 09:47:12 +08002823 u8 tx_gain; /* gain for analog radio */
2824 u8 dsp_atten; /* gain for DSP */
Ben Cahill3058f022008-01-14 17:46:17 -08002825 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2826 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
Eric Dumazetba2d3582010-06-02 18:10:09 +00002827} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002828
Winkler, Tomas0d210442009-01-23 13:45:21 -08002829/* set number of direct probes __le32 type */
2830#define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
2831
Ben Cahill3058f022008-01-14 17:46:17 -08002832/**
Tomas Winkler2a421b92008-06-12 09:47:10 +08002833 * struct iwl_ssid_ie - directed scan network information element
Ben Cahill3058f022008-01-14 17:46:17 -08002834 *
Ben Cahill2a3b7932009-11-06 14:52:59 -08002835 * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in
2836 * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel;
2837 * each channel may select different ssids from among the 20 (4) entries.
2838 * SSID IEs get transmitted in reverse order of entry.
Ben Cahill3058f022008-01-14 17:46:17 -08002839 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002840struct iwl_ssid_ie {
Zhu Yib481de92007-09-25 17:54:57 -07002841 u8 id;
2842 u8 len;
2843 u8 ssid[32];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002844} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002845
Johannes Berg9b3bf062009-04-20 14:36:55 -07002846#define PROBE_OPTION_MAX_3945 4
2847#define PROBE_OPTION_MAX 20
Harvey Harrison51e9bf52008-11-26 13:12:52 -08002848#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
Johannes Berg96ff5642010-04-30 14:42:15 -07002849#define IWL_GOOD_CRC_TH_DISABLED 0
2850#define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
2851#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
Zhu Yib481de92007-09-25 17:54:57 -07002852#define IWL_MAX_SCAN_SIZE 1024
Abhijeet Kolekar89612122010-02-19 11:49:49 -08002853#define IWL_MAX_CMD_SIZE 4096
Zhu Yib481de92007-09-25 17:54:57 -07002854
2855/*
2856 * REPLY_SCAN_CMD = 0x80 (command)
Ben Cahill3058f022008-01-14 17:46:17 -08002857 *
2858 * The hardware scan command is very powerful; the driver can set it up to
2859 * maintain (relatively) normal network traffic while doing a scan in the
2860 * background. The max_out_time and suspend_time control the ratio of how
2861 * long the device stays on an associated network channel ("service channel")
2862 * vs. how long it's away from the service channel, i.e. tuned to other channels
2863 * for scanning.
2864 *
2865 * max_out_time is the max time off-channel (in usec), and suspend_time
2866 * is how long (in "extended beacon" format) that the scan is "suspended"
2867 * after returning to the service channel. That is, suspend_time is the
2868 * time that we stay on the service channel, doing normal work, between
2869 * scan segments. The driver may set these parameters differently to support
2870 * scanning when associated vs. not associated, and light vs. heavy traffic
2871 * loads when associated.
2872 *
2873 * After receiving this command, the device's scan engine does the following;
2874 *
2875 * 1) Sends SCAN_START notification to driver
2876 * 2) Checks to see if it has time to do scan for one channel
2877 * 3) Sends NULL packet, with power-save (PS) bit set to 1,
2878 * to tell AP that we're going off-channel
2879 * 4) Tunes to first channel in scan list, does active or passive scan
2880 * 5) Sends SCAN_RESULT notification to driver
2881 * 6) Checks to see if it has time to do scan on *next* channel in list
2882 * 7) Repeats 4-6 until it no longer has time to scan the next channel
2883 * before max_out_time expires
2884 * 8) Returns to service channel
2885 * 9) Sends NULL packet with PS=0 to tell AP that we're back
2886 * 10) Stays on service channel until suspend_time expires
2887 * 11) Repeats entire process 2-10 until list is complete
2888 * 12) Sends SCAN_COMPLETE notification
2889 *
2890 * For fast, efficient scans, the scan command also has support for staying on
2891 * a channel for just a short time, if doing active scanning and getting no
2892 * responses to the transmitted probe request. This time is controlled by
2893 * quiet_time, and the number of received packets below which a channel is
2894 * considered "quiet" is controlled by quiet_plcp_threshold.
2895 *
2896 * For active scanning on channels that have regulatory restrictions against
2897 * blindly transmitting, the scan can listen before transmitting, to make sure
2898 * that there is already legitimate activity on the channel. If enough
2899 * packets are cleanly received on the channel (controlled by good_CRC_th,
2900 * typical value 1), the scan engine starts transmitting probe requests.
2901 *
2902 * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
2903 *
2904 * To avoid uCode errors, see timing restrictions described under
Tomas Winkler2a421b92008-06-12 09:47:10 +08002905 * struct iwl_scan_channel.
Zhu Yib481de92007-09-25 17:54:57 -07002906 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002907
2908struct iwl3945_scan_cmd {
2909 __le16 len;
2910 u8 reserved0;
2911 u8 channel_count; /* # channels in channel list */
2912 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2913 * (only for active scan) */
2914 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2915 __le16 good_CRC_th; /* passive -> active promotion threshold */
2916 __le16 reserved1;
2917 __le32 max_out_time; /* max usec to be away from associated (service)
2918 * channel */
2919 __le32 suspend_time; /* pause scan this long (in "extended beacon
2920 * format") when returning to service channel:
2921 * 3945; 31:24 # beacons, 19:0 additional usec,
2922 * 4965; 31:22 # beacons, 21:0 additional usec.
2923 */
2924 __le32 flags; /* RXON_FLG_* */
2925 __le32 filter_flags; /* RXON_FILTER_* */
2926
2927 /* For active scans (set to all-0s for passive scans).
2928 * Does not include payload. Must specify Tx rate; no rate scaling. */
2929 struct iwl3945_tx_cmd tx_cmd;
2930
2931 /* For directed active scans (set to all-0s otherwise) */
Johannes Berg9b3bf062009-04-20 14:36:55 -07002932 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002933
2934 /*
2935 * Probe request frame, followed by channel list.
2936 *
2937 * Size of probe request frame is specified by byte count in tx_cmd.
2938 * Channel list follows immediately after probe request frame.
2939 * Number of channels in list is specified by channel_count.
2940 * Each channel in list is of type:
2941 *
2942 * struct iwl3945_scan_channel channels[0];
2943 *
2944 * NOTE: Only one band of channels can be scanned per pass. You
2945 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2946 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
2947 * before requesting another scan.
2948 */
2949 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002950} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08002951
Tomas Winkler2a421b92008-06-12 09:47:10 +08002952struct iwl_scan_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002953 __le16 len;
2954 u8 reserved0;
Ben Cahill3058f022008-01-14 17:46:17 -08002955 u8 channel_count; /* # channels in channel list */
2956 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2957 * (only for active scan) */
2958 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2959 __le16 good_CRC_th; /* passive -> active promotion threshold */
2960 __le16 rx_chain; /* RXON_RX_CHAIN_* */
2961 __le32 max_out_time; /* max usec to be away from associated (service)
2962 * channel */
2963 __le32 suspend_time; /* pause scan this long (in "extended beacon
2964 * format") when returning to service chnl:
2965 * 3945; 31:24 # beacons, 19:0 additional usec,
2966 * 4965; 31:22 # beacons, 21:0 additional usec.
2967 */
2968 __le32 flags; /* RXON_FLG_* */
2969 __le32 filter_flags; /* RXON_FILTER_* */
Zhu Yib481de92007-09-25 17:54:57 -07002970
Ben Cahill3058f022008-01-14 17:46:17 -08002971 /* For active scans (set to all-0s for passive scans).
2972 * Does not include payload. Must specify Tx rate; no rate scaling. */
Tomas Winkler83d527d2008-05-15 13:54:05 +08002973 struct iwl_tx_cmd tx_cmd;
Ben Cahill3058f022008-01-14 17:46:17 -08002974
2975 /* For directed active scans (set to all-0s otherwise) */
Tomas Winkler2a421b92008-06-12 09:47:10 +08002976 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
Zhu Yib481de92007-09-25 17:54:57 -07002977
Zhu Yib481de92007-09-25 17:54:57 -07002978 /*
Ben Cahill3058f022008-01-14 17:46:17 -08002979 * Probe request frame, followed by channel list.
2980 *
2981 * Size of probe request frame is specified by byte count in tx_cmd.
2982 * Channel list follows immediately after probe request frame.
2983 * Number of channels in list is specified by channel_count.
2984 * Each channel in list is of type:
Zhu Yib481de92007-09-25 17:54:57 -07002985 *
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08002986 * struct iwl_scan_channel channels[0];
Zhu Yib481de92007-09-25 17:54:57 -07002987 *
2988 * NOTE: Only one band of channels can be scanned per pass. You
Ben Cahill3058f022008-01-14 17:46:17 -08002989 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2990 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
2991 * before requesting another scan.
Zhu Yib481de92007-09-25 17:54:57 -07002992 */
Ben Cahill3058f022008-01-14 17:46:17 -08002993 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00002994} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07002995
2996/* Can abort will notify by complete notification with abort status. */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08002997#define CAN_ABORT_STATUS cpu_to_le32(0x1)
Zhu Yib481de92007-09-25 17:54:57 -07002998/* complete notification statuses */
2999#define ABORT_STATUS 0x2
3000
3001/*
3002 * REPLY_SCAN_CMD = 0x80 (response)
3003 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08003004struct iwl_scanreq_notification {
Zhu Yib481de92007-09-25 17:54:57 -07003005 __le32 status; /* 1: okay, 2: cannot fulfill request */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003006} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003007
3008/*
3009 * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
3010 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08003011struct iwl_scanstart_notification {
Zhu Yib481de92007-09-25 17:54:57 -07003012 __le32 tsf_low;
3013 __le32 tsf_high;
3014 __le32 beacon_timer;
3015 u8 channel;
3016 u8 band;
3017 u8 reserved[2];
3018 __le32 status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003019} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003020
3021#define SCAN_OWNER_STATUS 0x1;
3022#define MEASURE_OWNER_STATUS 0x2;
3023
Johannes Berg0288d232010-08-23 07:56:54 -07003024#define IWL_PROBE_STATUS_OK 0
3025#define IWL_PROBE_STATUS_TX_FAILED BIT(0)
3026/* error statuses combined with TX_FAILED */
3027#define IWL_PROBE_STATUS_FAIL_TTL BIT(1)
3028#define IWL_PROBE_STATUS_FAIL_BT BIT(2)
3029
Zhu Yib481de92007-09-25 17:54:57 -07003030#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
3031/*
3032 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
3033 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08003034struct iwl_scanresults_notification {
Zhu Yib481de92007-09-25 17:54:57 -07003035 u8 channel;
3036 u8 band;
Johannes Berg0288d232010-08-23 07:56:54 -07003037 u8 probe_status;
3038 u8 num_probe_not_sent; /* not enough time to send */
Zhu Yib481de92007-09-25 17:54:57 -07003039 __le32 tsf_low;
3040 __le32 tsf_high;
3041 __le32 statistics[NUMBER_OF_STATISTICS];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003042} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003043
3044/*
3045 * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
3046 */
Tomas Winkler2a421b92008-06-12 09:47:10 +08003047struct iwl_scancomplete_notification {
Zhu Yib481de92007-09-25 17:54:57 -07003048 u8 scanned_channels;
3049 u8 status;
Wey-Yi Guyf78e5452010-08-23 07:57:15 -07003050 u8 bt_status; /* BT On/Off status */
Zhu Yib481de92007-09-25 17:54:57 -07003051 u8 last_channel;
3052 __le32 tsf_low;
3053 __le32 tsf_high;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003054} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003055
3056
3057/******************************************************************************
3058 * (9)
3059 * IBSS/AP Commands and Notifications:
3060 *
3061 *****************************************************************************/
3062
Johannes Berga85d7cc2010-07-31 08:34:10 -07003063enum iwl_ibss_manager {
3064 IWL_NOT_IBSS_MANAGER = 0,
3065 IWL_IBSS_MANAGER = 1,
3066};
3067
Zhu Yib481de92007-09-25 17:54:57 -07003068/*
3069 * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
3070 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003071
3072struct iwl3945_beacon_notif {
3073 struct iwl3945_tx_resp beacon_notify_hdr;
3074 __le32 low_tsf;
3075 __le32 high_tsf;
3076 __le32 ibss_mgr_status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003077} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003078
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08003079struct iwl4965_beacon_notif {
3080 struct iwl4965_tx_resp beacon_notify_hdr;
Zhu Yib481de92007-09-25 17:54:57 -07003081 __le32 low_tsf;
3082 __le32 high_tsf;
3083 __le32 ibss_mgr_status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003084} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003085
Johannes Berg241887a2011-01-19 11:11:22 -08003086struct iwlagn_beacon_notif {
3087 struct iwlagn_tx_resp beacon_notify_hdr;
3088 __le32 low_tsf;
3089 __le32 high_tsf;
3090 __le32 ibss_mgr_status;
3091} __packed;
3092
Zhu Yib481de92007-09-25 17:54:57 -07003093/*
3094 * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
3095 */
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003096
3097struct iwl3945_tx_beacon_cmd {
3098 struct iwl3945_tx_cmd tx;
3099 __le16 tim_idx;
3100 u8 tim_size;
3101 u8 reserved1;
3102 struct ieee80211_hdr frame[0]; /* beacon frame */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003103} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003104
Tomas Winkler4bf64ef2008-07-18 13:53:03 +08003105struct iwl_tx_beacon_cmd {
Tomas Winkler83d527d2008-05-15 13:54:05 +08003106 struct iwl_tx_cmd tx;
Zhu Yib481de92007-09-25 17:54:57 -07003107 __le16 tim_idx;
3108 u8 tim_size;
3109 u8 reserved1;
3110 struct ieee80211_hdr frame[0]; /* beacon frame */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003111} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003112
3113/******************************************************************************
3114 * (10)
3115 * Statistics Commands and Notifications:
3116 *
3117 *****************************************************************************/
3118
3119#define IWL_TEMP_CONVERT 260
3120
3121#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
3122#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
3123#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
3124
3125/* Used for passing to driver number of successes and failures per rate */
3126struct rate_histogram {
3127 union {
3128 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
3129 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
3130 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
3131 } success;
3132 union {
3133 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
3134 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
3135 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
3136 } failed;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003137} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003138
3139/* statistics command response */
3140
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003141struct iwl39_statistics_rx_phy {
3142 __le32 ina_cnt;
3143 __le32 fina_cnt;
3144 __le32 plcp_err;
3145 __le32 crc32_err;
3146 __le32 overrun_err;
3147 __le32 early_overrun_err;
3148 __le32 crc32_good;
3149 __le32 false_alarm_cnt;
3150 __le32 fina_sync_err_cnt;
3151 __le32 sfd_timeout;
3152 __le32 fina_timeout;
3153 __le32 unresponded_rts;
3154 __le32 rxe_frame_limit_overrun;
3155 __le32 sent_ack_cnt;
3156 __le32 sent_cts_cnt;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003157} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003158
3159struct iwl39_statistics_rx_non_phy {
3160 __le32 bogus_cts; /* CTS received when not expecting CTS */
3161 __le32 bogus_ack; /* ACK received when not expecting ACK */
3162 __le32 non_bssid_frames; /* number of frames with BSSID that
3163 * doesn't belong to the STA BSSID */
3164 __le32 filtered_frames; /* count frames that were dumped in the
3165 * filtering process */
3166 __le32 non_channel_beacons; /* beacons with our bss id but not on
3167 * our serving channel */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003168} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003169
3170struct iwl39_statistics_rx {
3171 struct iwl39_statistics_rx_phy ofdm;
3172 struct iwl39_statistics_rx_phy cck;
3173 struct iwl39_statistics_rx_non_phy general;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003174} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003175
3176struct iwl39_statistics_tx {
3177 __le32 preamble_cnt;
3178 __le32 rx_detected_cnt;
3179 __le32 bt_prio_defer_cnt;
3180 __le32 bt_prio_kill_cnt;
3181 __le32 few_bytes_cnt;
3182 __le32 cts_timeout;
3183 __le32 ack_timeout;
3184 __le32 expected_ack_cnt;
3185 __le32 actual_ack_cnt;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003186} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003187
3188struct statistics_dbg {
3189 __le32 burst_check;
3190 __le32 burst_count;
Wey-Yi Guy7c094c52010-07-06 10:39:32 -07003191 __le32 wait_for_silence_timeout_cnt;
3192 __le32 reserved[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003193} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003194
3195struct iwl39_statistics_div {
3196 __le32 tx_on_a;
3197 __le32 tx_on_b;
3198 __le32 exec_time;
3199 __le32 probe_time;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003200} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003201
3202struct iwl39_statistics_general {
3203 __le32 temperature;
3204 struct statistics_dbg dbg;
3205 __le32 sleep_time;
3206 __le32 slots_out;
3207 __le32 slots_idle;
3208 __le32 ttl_timestamp;
3209 struct iwl39_statistics_div div;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003210} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003211
Zhu Yib481de92007-09-25 17:54:57 -07003212struct statistics_rx_phy {
3213 __le32 ina_cnt;
3214 __le32 fina_cnt;
3215 __le32 plcp_err;
3216 __le32 crc32_err;
3217 __le32 overrun_err;
3218 __le32 early_overrun_err;
3219 __le32 crc32_good;
3220 __le32 false_alarm_cnt;
3221 __le32 fina_sync_err_cnt;
3222 __le32 sfd_timeout;
3223 __le32 fina_timeout;
3224 __le32 unresponded_rts;
3225 __le32 rxe_frame_limit_overrun;
3226 __le32 sent_ack_cnt;
3227 __le32 sent_cts_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07003228 __le32 sent_ba_rsp_cnt;
3229 __le32 dsp_self_kill;
3230 __le32 mh_format_err;
3231 __le32 re_acq_main_rssi_sum;
3232 __le32 reserved3;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003233} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003234
Zhu Yib481de92007-09-25 17:54:57 -07003235struct statistics_rx_ht_phy {
3236 __le32 plcp_err;
3237 __le32 overrun_err;
3238 __le32 early_overrun_err;
3239 __le32 crc32_good;
3240 __le32 crc32_err;
3241 __le32 mh_format_err;
3242 __le32 agg_crc32_good;
3243 __le32 agg_mpdu_cnt;
3244 __le32 agg_cnt;
Wey-Yi Guyf0118a42010-01-08 10:04:42 -08003245 __le32 unsupport_mcs;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003246} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003247
Harvey Harrisonc1b4aa32009-01-29 13:26:44 -08003248#define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1)
Winkler, Tomas34c22cf2008-12-17 16:52:27 +08003249
Zhu Yib481de92007-09-25 17:54:57 -07003250struct statistics_rx_non_phy {
3251 __le32 bogus_cts; /* CTS received when not expecting CTS */
3252 __le32 bogus_ack; /* ACK received when not expecting ACK */
3253 __le32 non_bssid_frames; /* number of frames with BSSID that
3254 * doesn't belong to the STA BSSID */
3255 __le32 filtered_frames; /* count frames that were dumped in the
3256 * filtering process */
3257 __le32 non_channel_beacons; /* beacons with our bss id but not on
3258 * our serving channel */
Zhu Yib481de92007-09-25 17:54:57 -07003259 __le32 channel_beacons; /* beacons with our bss id and in our
3260 * serving channel */
3261 __le32 num_missed_bcon; /* number of missed beacons */
3262 __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
3263 * ADC was in saturation */
3264 __le32 ina_detection_search_time;/* total time (in 0.8us) searched
3265 * for INA */
3266 __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
3267 __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
3268 __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
3269 __le32 interference_data_flag; /* flag for interference data
3270 * availability. 1 when data is
3271 * available. */
Ben Cahill3058f022008-01-14 17:46:17 -08003272 __le32 channel_load; /* counts RX Enable time in uSec */
Zhu Yib481de92007-09-25 17:54:57 -07003273 __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
3274 * and CCK) counter */
3275 __le32 beacon_rssi_a;
3276 __le32 beacon_rssi_b;
3277 __le32 beacon_rssi_c;
3278 __le32 beacon_energy_a;
3279 __le32 beacon_energy_b;
3280 __le32 beacon_energy_c;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003281} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003282
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003283struct statistics_rx_non_phy_bt {
3284 struct statistics_rx_non_phy common;
3285 /* additional stats for bt */
3286 __le32 num_bt_kills;
3287 __le32 reserved[2];
John W. Linvilleda22f792010-07-26 15:04:12 -04003288} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003289
Zhu Yib481de92007-09-25 17:54:57 -07003290struct statistics_rx {
3291 struct statistics_rx_phy ofdm;
3292 struct statistics_rx_phy cck;
3293 struct statistics_rx_non_phy general;
Zhu Yib481de92007-09-25 17:54:57 -07003294 struct statistics_rx_ht_phy ofdm_ht;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003295} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003296
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003297struct statistics_rx_bt {
3298 struct statistics_rx_phy ofdm;
3299 struct statistics_rx_phy cck;
3300 struct statistics_rx_non_phy_bt general;
3301 struct statistics_rx_ht_phy ofdm_ht;
John W. Linvilleda22f792010-07-26 15:04:12 -04003302} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003303
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -07003304/**
3305 * struct statistics_tx_power - current tx power
3306 *
3307 * @ant_a: current tx power on chain a in 1/2 dB step
3308 * @ant_b: current tx power on chain b in 1/2 dB step
3309 * @ant_c: current tx power on chain c in 1/2 dB step
3310 */
3311struct statistics_tx_power {
3312 u8 ant_a;
3313 u8 ant_b;
3314 u8 ant_c;
3315 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003316} __packed;
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -07003317
Zhu Yib481de92007-09-25 17:54:57 -07003318struct statistics_tx_non_phy_agg {
3319 __le32 ba_timeout;
3320 __le32 ba_reschedule_frames;
3321 __le32 scd_query_agg_frame_cnt;
3322 __le32 scd_query_no_agg;
3323 __le32 scd_query_agg;
3324 __le32 scd_query_mismatch;
3325 __le32 frame_not_ready;
3326 __le32 underrun;
3327 __le32 bt_prio_kill;
3328 __le32 rx_ba_rsp_cnt;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003329} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003330
3331struct statistics_tx {
3332 __le32 preamble_cnt;
3333 __le32 rx_detected_cnt;
3334 __le32 bt_prio_defer_cnt;
3335 __le32 bt_prio_kill_cnt;
3336 __le32 few_bytes_cnt;
3337 __le32 cts_timeout;
3338 __le32 ack_timeout;
3339 __le32 expected_ack_cnt;
3340 __le32 actual_ack_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07003341 __le32 dump_msdu_cnt;
3342 __le32 burst_abort_next_frame_mismatch_cnt;
3343 __le32 burst_abort_missing_next_frame_cnt;
3344 __le32 cts_timeout_collision;
3345 __le32 ack_or_ba_timeout_collision;
3346 struct statistics_tx_non_phy_agg agg;
Wey-Yi Guy470356b2010-04-30 11:35:15 -07003347 /*
3348 * "tx_power" are optional parameters provided by uCode,
3349 * 6000 series is the only device provide the information,
3350 * Those are reserved fields for all the other devices
3351 */
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -07003352 struct statistics_tx_power tx_power;
3353 __le32 reserved1;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003354} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003355
Zhu Yib481de92007-09-25 17:54:57 -07003356
3357struct statistics_div {
3358 __le32 tx_on_a;
3359 __le32 tx_on_b;
3360 __le32 exec_time;
3361 __le32 probe_time;
Zhu Yib481de92007-09-25 17:54:57 -07003362 __le32 reserved1;
3363 __le32 reserved2;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003364} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003365
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003366struct statistics_general_common {
Wey-Yi Guyf0118a42010-01-08 10:04:42 -08003367 __le32 temperature; /* radio temperature */
3368 __le32 temperature_m; /* for 5000 and up, this is radio voltage */
Zhu Yib481de92007-09-25 17:54:57 -07003369 struct statistics_dbg dbg;
3370 __le32 sleep_time;
3371 __le32 slots_out;
3372 __le32 slots_idle;
3373 __le32 ttl_timestamp;
3374 struct statistics_div div;
Zhu Yib481de92007-09-25 17:54:57 -07003375 __le32 rx_enable_counter;
Wey-Yi Guy11fc5242010-01-15 13:43:35 -08003376 /*
3377 * num_of_sos_states:
3378 * count the number of times we have to re-tune
3379 * in order to get out of bad PHY status
3380 */
3381 __le32 num_of_sos_states;
John W. Linvilleda22f792010-07-26 15:04:12 -04003382} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003383
3384struct statistics_bt_activity {
3385 /* Tx statistics */
3386 __le32 hi_priority_tx_req_cnt;
3387 __le32 hi_priority_tx_denied_cnt;
3388 __le32 lo_priority_tx_req_cnt;
3389 __le32 lo_priority_tx_denied_cnt;
3390 /* Rx statistics */
3391 __le32 hi_priority_rx_req_cnt;
3392 __le32 hi_priority_rx_denied_cnt;
3393 __le32 lo_priority_rx_req_cnt;
3394 __le32 lo_priority_rx_denied_cnt;
John W. Linvilleda22f792010-07-26 15:04:12 -04003395} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003396
3397struct statistics_general {
3398 struct statistics_general_common common;
3399 __le32 reserved2;
3400 __le32 reserved3;
John W. Linvilleda22f792010-07-26 15:04:12 -04003401} __packed;
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003402
3403struct statistics_general_bt {
3404 struct statistics_general_common common;
3405 struct statistics_bt_activity activity;
Zhu Yib481de92007-09-25 17:54:57 -07003406 __le32 reserved2;
3407 __le32 reserved3;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003408} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003409
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08003410#define UCODE_STATISTICS_CLEAR_MSK (0x1 << 0)
3411#define UCODE_STATISTICS_FREQUENCY_MSK (0x1 << 1)
3412#define UCODE_STATISTICS_NARROW_BAND_MSK (0x1 << 2)
3413
Zhu Yib481de92007-09-25 17:54:57 -07003414/*
3415 * REPLY_STATISTICS_CMD = 0x9c,
Wey-Yi Guy767d0552010-08-23 07:56:53 -07003416 * all devices identical.
Zhu Yib481de92007-09-25 17:54:57 -07003417 *
3418 * This command triggers an immediate response containing uCode statistics.
3419 * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
3420 *
3421 * If the CLEAR_STATS configuration flag is set, uCode will clear its
3422 * internal copy of the statistics (counters) after issuing the response.
3423 * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
3424 *
3425 * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
3426 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
3427 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
3428 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003429#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */
3430#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +08003431struct iwl_statistics_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07003432 __le32 configuration_flags; /* IWL_STATS_CONF_* */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003433} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003434
3435/*
3436 * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
3437 *
3438 * By default, uCode issues this notification after receiving a beacon
3439 * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
3440 * REPLY_STATISTICS_CMD 0x9c, above.
3441 *
3442 * Statistics counters continue to increment beacon after beacon, but are
3443 * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
3444 * 0x9c with CLEAR_STATS bit set (see above).
3445 *
3446 * uCode also issues this notification during scans. uCode clears statistics
3447 * appropriately so that each notification contains statistics for only the
3448 * one channel that has just been scanned.
3449 */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003450#define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2)
Wey-Yi Guy7aafef12009-08-07 15:41:38 -07003451#define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8)
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003452
3453struct iwl3945_notif_statistics {
3454 __le32 flag;
3455 struct iwl39_statistics_rx rx;
3456 struct iwl39_statistics_tx tx;
3457 struct iwl39_statistics_general general;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003458} __packed;
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08003459
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +08003460struct iwl_notif_statistics {
Zhu Yib481de92007-09-25 17:54:57 -07003461 __le32 flag;
3462 struct statistics_rx rx;
3463 struct statistics_tx tx;
3464 struct statistics_general general;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003465} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003466
Wey-Yi Guy325322e2010-07-14 08:07:27 -07003467struct iwl_bt_notif_statistics {
3468 __le32 flag;
3469 struct statistics_rx_bt rx;
3470 struct statistics_tx tx;
3471 struct statistics_general_bt general;
John W. Linvilleda22f792010-07-26 15:04:12 -04003472} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003473
3474/*
3475 * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
Wey-Yi Guya13d2762010-01-22 14:22:42 -08003476 *
3477 * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed
3478 * in regardless of how many missed beacons, which mean when driver receive the
3479 * notification, inside the command, it can find all the beacons information
3480 * which include number of total missed beacons, number of consecutive missed
3481 * beacons, number of beacons received and number of beacons expected to
3482 * receive.
3483 *
3484 * If uCode detected consecutive_missed_beacons > 5, it will reset the radio
3485 * in order to bring the radio/PHY back to working state; which has no relation
3486 * to when driver will perform sensitivity calibration.
3487 *
3488 * Driver should set it own missed_beacon_threshold to decide when to perform
3489 * sensitivity calibration based on number of consecutive missed beacons in
3490 * order to improve overall performance, especially in noisy environment.
3491 *
Zhu Yib481de92007-09-25 17:54:57 -07003492 */
Wey-Yi Guya13d2762010-01-22 14:22:42 -08003493
3494#define IWL_MISSED_BEACON_THRESHOLD_MIN (1)
3495#define IWL_MISSED_BEACON_THRESHOLD_DEF (5)
3496#define IWL_MISSED_BEACON_THRESHOLD_MAX IWL_MISSED_BEACON_THRESHOLD_DEF
Zhu Yib481de92007-09-25 17:54:57 -07003497
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08003498struct iwl_missed_beacon_notif {
Wey-Yi Guya13d2762010-01-22 14:22:42 -08003499 __le32 consecutive_missed_beacons;
Zhu Yib481de92007-09-25 17:54:57 -07003500 __le32 total_missed_becons;
3501 __le32 num_expected_beacons;
3502 __le32 num_recvd_beacons;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003503} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003504
Ben Cahillf7d09d72007-11-29 11:09:51 +08003505
Zhu Yib481de92007-09-25 17:54:57 -07003506/******************************************************************************
3507 * (11)
3508 * Rx Calibration Commands:
3509 *
Ben Cahillf7d09d72007-11-29 11:09:51 +08003510 * With the uCode used for open source drivers, most Tx calibration (except
3511 * for Tx Power) and most Rx calibration is done by uCode during the
3512 * "initialize" phase of uCode boot. Driver must calibrate only:
3513 *
3514 * 1) Tx power (depends on temperature), described elsewhere
3515 * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
3516 * 3) Receiver sensitivity (to optimize signal detection)
3517 *
Zhu Yib481de92007-09-25 17:54:57 -07003518 *****************************************************************************/
3519
Ben Cahillf7d09d72007-11-29 11:09:51 +08003520/**
3521 * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
3522 *
3523 * This command sets up the Rx signal detector for a sensitivity level that
3524 * is high enough to lock onto all signals within the associated network,
3525 * but low enough to ignore signals that are below a certain threshold, so as
3526 * not to have too many "false alarms". False alarms are signals that the
3527 * Rx DSP tries to lock onto, but then discards after determining that they
3528 * are noise.
3529 *
3530 * The optimum number of false alarms is between 5 and 50 per 200 TUs
3531 * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
3532 * time listening, not transmitting). Driver must adjust sensitivity so that
3533 * the ratio of actual false alarms to actual Rx time falls within this range.
3534 *
3535 * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
3536 * received beacon. These provide information to the driver to analyze the
3537 * sensitivity. Don't analyze statistics that come in from scanning, or any
3538 * other non-associated-network source. Pertinent statistics include:
3539 *
3540 * From "general" statistics (struct statistics_rx_non_phy):
3541 *
3542 * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
3543 * Measure of energy of desired signal. Used for establishing a level
3544 * below which the device does not detect signals.
3545 *
3546 * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
3547 * Measure of background noise in silent period after beacon.
3548 *
3549 * channel_load
3550 * uSecs of actual Rx time during beacon period (varies according to
3551 * how much time was spent transmitting).
3552 *
3553 * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
3554 *
3555 * false_alarm_cnt
3556 * Signal locks abandoned early (before phy-level header).
3557 *
3558 * plcp_err
3559 * Signal locks abandoned late (during phy-level header).
3560 *
3561 * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
3562 * beacon to beacon, i.e. each value is an accumulation of all errors
3563 * before and including the latest beacon. Values will wrap around to 0
3564 * after counting up to 2^32 - 1. Driver must differentiate vs.
3565 * previous beacon's values to determine # false alarms in the current
3566 * beacon period.
3567 *
3568 * Total number of false alarms = false_alarms + plcp_errs
3569 *
3570 * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
3571 * (notice that the start points for OFDM are at or close to settings for
3572 * maximum sensitivity):
3573 *
3574 * START / MIN / MAX
3575 * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120
3576 * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210
3577 * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140
3578 * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270
3579 *
3580 * If actual rate of OFDM false alarms (+ plcp_errors) is too high
3581 * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
3582 * by *adding* 1 to all 4 of the table entries above, up to the max for
3583 * each entry. Conversely, if false alarm rate is too low (less than 5
3584 * for each 204.8 msecs listening), *subtract* 1 from each entry to
3585 * increase sensitivity.
3586 *
3587 * For CCK sensitivity, keep track of the following:
3588 *
3589 * 1). 20-beacon history of maximum background noise, indicated by
3590 * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
3591 * 3 receivers. For any given beacon, the "silence reference" is
3592 * the maximum of last 60 samples (20 beacons * 3 receivers).
3593 *
3594 * 2). 10-beacon history of strongest signal level, as indicated
3595 * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
3596 * i.e. the strength of the signal through the best receiver at the
3597 * moment. These measurements are "upside down", with lower values
3598 * for stronger signals, so max energy will be *minimum* value.
3599 *
3600 * Then for any given beacon, the driver must determine the *weakest*
3601 * of the strongest signals; this is the minimum level that needs to be
3602 * successfully detected, when using the best receiver at the moment.
3603 * "Max cck energy" is the maximum (higher value means lower energy!)
3604 * of the last 10 minima. Once this is determined, driver must add
3605 * a little margin by adding "6" to it.
3606 *
3607 * 3). Number of consecutive beacon periods with too few false alarms.
3608 * Reset this to 0 at the first beacon period that falls within the
3609 * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
3610 *
3611 * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
3612 * (notice that the start points for CCK are at maximum sensitivity):
3613 *
3614 * START / MIN / MAX
3615 * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200
3616 * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400
3617 * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100
3618 *
3619 * If actual rate of CCK false alarms (+ plcp_errors) is too high
3620 * (greater than 50 for each 204.8 msecs listening), method for reducing
3621 * sensitivity is:
3622 *
3623 * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3624 * up to max 400.
3625 *
3626 * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
3627 * sensitivity has been reduced a significant amount; bring it up to
3628 * a moderate 161. Otherwise, *add* 3, up to max 200.
3629 *
3630 * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
3631 * sensitivity has been reduced only a moderate or small amount;
3632 * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
3633 * down to min 0. Otherwise (if gain has been significantly reduced),
3634 * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
3635 *
3636 * b) Save a snapshot of the "silence reference".
3637 *
3638 * If actual rate of CCK false alarms (+ plcp_errors) is too low
3639 * (less than 5 for each 204.8 msecs listening), method for increasing
3640 * sensitivity is used only if:
3641 *
3642 * 1a) Previous beacon did not have too many false alarms
3643 * 1b) AND difference between previous "silence reference" and current
3644 * "silence reference" (prev - current) is 2 or more,
3645 * OR 2) 100 or more consecutive beacon periods have had rate of
3646 * less than 5 false alarms per 204.8 milliseconds rx time.
3647 *
3648 * Method for increasing sensitivity:
3649 *
3650 * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
3651 * down to min 125.
3652 *
3653 * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3654 * down to min 200.
3655 *
3656 * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
3657 *
3658 * If actual rate of CCK false alarms (+ plcp_errors) is within good range
3659 * (between 5 and 50 for each 204.8 msecs listening):
3660 *
3661 * 1) Save a snapshot of the silence reference.
3662 *
3663 * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
3664 * give some extra margin to energy threshold by *subtracting* 8
3665 * from value in HD_MIN_ENERGY_CCK_DET_INDEX.
3666 *
3667 * For all cases (too few, too many, good range), make sure that the CCK
3668 * detection threshold (energy) is below the energy level for robust
3669 * detection over the past 10 beacon periods, the "Max cck energy".
3670 * Lower values mean higher energy; this means making sure that the value
3671 * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
3672 *
Ben Cahillf7d09d72007-11-29 11:09:51 +08003673 */
Zhu Yib481de92007-09-25 17:54:57 -07003674
Ben Cahillf7d09d72007-11-29 11:09:51 +08003675/*
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003676 * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
Ben Cahillf7d09d72007-11-29 11:09:51 +08003677 */
3678#define HD_TABLE_SIZE (11) /* number of entries */
3679#define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */
3680#define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
3681#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
3682#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
3683#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
3684#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
3685#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
3686#define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
3687#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
3688#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
3689#define HD_OFDM_ENERGY_TH_IN_INDEX (10)
3690
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07003691/*
3692 * Additional table entries in enhance SENSITIVITY_CMD
3693 */
3694#define HD_INA_NON_SQUARE_DET_OFDM_INDEX (11)
3695#define HD_INA_NON_SQUARE_DET_CCK_INDEX (12)
3696#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_INDEX (13)
3697#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_INDEX (14)
3698#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (15)
3699#define HD_OFDM_NON_SQUARE_DET_SLOPE_INDEX (16)
3700#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_INDEX (17)
3701#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_INDEX (18)
3702#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (19)
3703#define HD_CCK_NON_SQUARE_DET_SLOPE_INDEX (20)
3704#define HD_CCK_NON_SQUARE_DET_INTERCEPT_INDEX (21)
3705#define HD_RESERVED (22)
3706
3707/* number of entries for enhanced tbl */
3708#define ENHANCE_HD_TABLE_SIZE (23)
3709
3710/* number of additional entries for enhanced tbl */
3711#define ENHANCE_HD_TABLE_ENTRIES (ENHANCE_HD_TABLE_SIZE - HD_TABLE_SIZE)
3712
3713#define HD_INA_NON_SQUARE_DET_OFDM_DATA cpu_to_le16(0)
3714#define HD_INA_NON_SQUARE_DET_CCK_DATA cpu_to_le16(0)
3715#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA cpu_to_le16(0)
3716#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(668)
3717#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3718#define HD_OFDM_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(486)
3719#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(37)
3720#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(853)
3721#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
3722#define HD_CCK_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(476)
3723#define HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(99)
3724
3725
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003726/* Control field in struct iwl_sensitivity_cmd */
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003727#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0)
3728#define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1)
Ben Cahillf7d09d72007-11-29 11:09:51 +08003729
3730/**
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003731 * struct iwl_sensitivity_cmd
Ben Cahillf7d09d72007-11-29 11:09:51 +08003732 * @control: (1) updates working table, (0) updates default table
3733 * @table: energy threshold values, use HD_* as index into table
3734 *
3735 * Always use "1" in "control" to update uCode's working table and DSP.
3736 */
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07003737struct iwl_sensitivity_cmd {
Ben Cahillf7d09d72007-11-29 11:09:51 +08003738 __le16 control; /* always use "1" */
3739 __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
Eric Dumazetba2d3582010-06-02 18:10:09 +00003740} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003741
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07003742/*
3743 *
3744 */
3745struct iwl_enhance_sensitivity_cmd {
3746 __le16 control; /* always use "1" */
3747 __le16 enhance_table[ENHANCE_HD_TABLE_SIZE]; /* use HD_* as index */
John W. Linville0e954092010-07-14 10:37:32 -04003748} __packed;
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07003749
Ben Cahillf7d09d72007-11-29 11:09:51 +08003750
3751/**
3752 * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
3753 *
Wey-Yi Guy767d0552010-08-23 07:56:53 -07003754 * This command sets the relative gains of agn device's 3 radio receiver chains.
Ben Cahillf7d09d72007-11-29 11:09:51 +08003755 *
3756 * After the first association, driver should accumulate signal and noise
3757 * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
3758 * beacons from the associated network (don't collect statistics that come
3759 * in from scanning, or any other non-network source).
3760 *
3761 * DISCONNECTED ANTENNA:
3762 *
3763 * Driver should determine which antennas are actually connected, by comparing
3764 * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
3765 * following values over 20 beacons, one accumulator for each of the chains
3766 * a/b/c, from struct statistics_rx_non_phy:
3767 *
3768 * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
3769 *
3770 * Find the strongest signal from among a/b/c. Compare the other two to the
3771 * strongest. If any signal is more than 15 dB (times 20, unless you
3772 * divide the accumulated values by 20) below the strongest, the driver
3773 * considers that antenna to be disconnected, and should not try to use that
3774 * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
3775 * driver should declare the stronger one as connected, and attempt to use it
3776 * (A and B are the only 2 Tx chains!).
3777 *
3778 *
3779 * RX BALANCE:
3780 *
3781 * Driver should balance the 3 receivers (but just the ones that are connected
3782 * to antennas, see above) for gain, by comparing the average signal levels
3783 * detected during the silence after each beacon (background noise).
3784 * Accumulate (add) the following values over 20 beacons, one accumulator for
3785 * each of the chains a/b/c, from struct statistics_rx_non_phy:
3786 *
3787 * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
3788 *
3789 * Find the weakest background noise level from among a/b/c. This Rx chain
3790 * will be the reference, with 0 gain adjustment. Attenuate other channels by
3791 * finding noise difference:
3792 *
3793 * (accum_noise[i] - accum_noise[reference]) / 30
3794 *
3795 * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
3796 * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
3797 * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
3798 * and set bit 2 to indicate "reduce gain". The value for the reference
3799 * (weakest) chain should be "0".
3800 *
3801 * diff_gain_[abc] bit fields:
3802 * 2: (1) reduce gain, (0) increase gain
3803 * 1-0: amount of gain, units of 1.5 dB
3804 */
3805
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003806/* Phy calibration command for series */
Shanyu Zhao642454c2010-09-21 12:06:18 -07003807/* The default calibrate table size if not specified by firmware */
3808#define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003809enum {
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003810 IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7,
3811 IWL_PHY_CALIBRATE_DC_CMD = 8,
3812 IWL_PHY_CALIBRATE_LO_CMD = 9,
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003813 IWL_PHY_CALIBRATE_TX_IQ_CMD = 11,
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003814 IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15,
3815 IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16,
3816 IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17,
Shanyu Zhaobf53f932010-09-21 16:54:01 -07003817 IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD = 18,
3818 IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19,
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003819};
3820
Wey-Yi Guy6a822d02010-07-13 17:13:15 -07003821#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253)
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003822
Harvey Harrison51e9bf52008-11-26 13:12:52 -08003823#define IWL_CALIB_INIT_CFG_ALL cpu_to_le32(0xffffffff)
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003824
Shanyu Zhao6d6a1af2010-09-14 18:13:31 -07003825/* This enum defines the bitmap of various calibrations to enable in both
3826 * init ucode and runtime ucode through CALIBRATION_CFG_CMD.
3827 */
3828enum iwl_ucode_calib_cfg {
3829 IWL_CALIB_CFG_RX_BB_IDX,
3830 IWL_CALIB_CFG_DC_IDX,
3831 IWL_CALIB_CFG_TX_IQ_IDX,
3832 IWL_CALIB_CFG_RX_IQ_IDX,
3833 IWL_CALIB_CFG_NOISE_IDX,
3834 IWL_CALIB_CFG_CRYSTAL_IDX,
3835 IWL_CALIB_CFG_TEMPERATURE_IDX,
3836 IWL_CALIB_CFG_PAPD_IDX,
3837};
3838
3839
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003840struct iwl_calib_cfg_elmnt_s {
3841 __le32 is_enable;
3842 __le32 start;
3843 __le32 send_res;
3844 __le32 apply_res;
3845 __le32 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003846} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003847
3848struct iwl_calib_cfg_status_s {
3849 struct iwl_calib_cfg_elmnt_s once;
3850 struct iwl_calib_cfg_elmnt_s perd;
3851 __le32 flags;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003852} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003853
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003854struct iwl_calib_cfg_cmd {
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003855 struct iwl_calib_cfg_status_s ucd_calib_cfg;
3856 struct iwl_calib_cfg_status_s drv_calib_cfg;
3857 __le32 reserved1;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003858} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003859
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003860struct iwl_calib_hdr {
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003861 u8 op_code;
3862 u8 first_group;
3863 u8 groups_num;
3864 u8 data_valid;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003865} __packed;
Tomas Winkler7c616cb2008-05-29 16:35:05 +08003866
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003867struct iwl_calib_cmd {
3868 struct iwl_calib_hdr hdr;
Tomas Winklerbe5d56e2008-10-08 09:37:27 +08003869 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003870} __packed;
Tomas Winklerbe5d56e2008-10-08 09:37:27 +08003871
Tomas Winkler0d950d82008-11-25 13:36:01 -08003872/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003873struct iwl_calib_diff_gain_cmd {
Tomas Winkler0d950d82008-11-25 13:36:01 -08003874 struct iwl_calib_hdr hdr;
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003875 s8 diff_gain_a; /* see above */
3876 s8 diff_gain_b;
3877 s8 diff_gain_c;
3878 u8 reserved1;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003879} __packed;
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003880
Tomas Winkler0d950d82008-11-25 13:36:01 -08003881struct iwl_calib_xtal_freq_cmd {
3882 struct iwl_calib_hdr hdr;
3883 u8 cap_pin1;
3884 u8 cap_pin2;
3885 u8 pad[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003886} __packed;
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003887
Shanyu Zhaobf53f932010-09-21 16:54:01 -07003888#define DEFAULT_RADIO_SENSOR_OFFSET 2700
3889struct iwl_calib_temperature_offset_cmd {
3890 struct iwl_calib_hdr hdr;
3891 s16 radio_sensor_offset;
3892 s16 reserved;
3893} __packed;
3894
Tomas Winkler0d950d82008-11-25 13:36:01 -08003895/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
3896struct iwl_calib_chain_noise_reset_cmd {
3897 struct iwl_calib_hdr hdr;
3898 u8 data[0];
3899};
3900
3901/* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
Tomas Winklerf69f42a2008-10-23 23:48:52 -07003902struct iwl_calib_chain_noise_gain_cmd {
Tomas Winkler0d950d82008-11-25 13:36:01 -08003903 struct iwl_calib_hdr hdr;
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003904 u8 delta_gain_1;
3905 u8 delta_gain_2;
Tomas Winkler0d950d82008-11-25 13:36:01 -08003906 u8 pad[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +00003907} __packed;
Emmanuel Grumbach33fd5032008-04-24 11:55:30 -07003908
Zhu Yib481de92007-09-25 17:54:57 -07003909/******************************************************************************
3910 * (12)
3911 * Miscellaneous Commands:
3912 *
3913 *****************************************************************************/
3914
3915/*
3916 * LEDs Command & Response
3917 * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
3918 *
3919 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
3920 * this command turns it on or off, or sets up a periodic blinking cycle.
3921 */
Tomas Winklerec1a7462008-07-11 11:53:37 +08003922struct iwl_led_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07003923 __le32 interval; /* "interval" in uSec */
3924 u8 id; /* 1: Activity, 2: Link, 3: Tech */
3925 u8 off; /* # intervals off while blinking;
3926 * "0", with >0 "on" value, turns LED on */
3927 u8 on; /* # intervals on while blinking;
3928 * "0", regardless of "off", turns LED off */
3929 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00003930} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07003931
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003932/*
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07003933 * station priority table entries
3934 * also used as potential "events" value for both
3935 * COEX_MEDIUM_NOTIFICATION and COEX_EVENT_CMD
Ron Rindjunsky9636e582008-05-15 13:54:14 +08003936 */
Wey-Yi Guy1933ac42009-10-30 14:36:18 -07003937
3938/*
3939 * COEX events entry flag masks
3940 * RP - Requested Priority
3941 * WP - Win Medium Priority: priority assigned when the contention has been won
3942 */
3943#define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG (0x1)
3944#define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG (0x2)
3945#define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG (0x4)
3946
3947#define COEX_CU_UNASSOC_IDLE_RP 4
3948#define COEX_CU_UNASSOC_MANUAL_SCAN_RP 4
3949#define COEX_CU_UNASSOC_AUTO_SCAN_RP 4
3950#define COEX_CU_CALIBRATION_RP 4
3951#define COEX_CU_PERIODIC_CALIBRATION_RP 4
3952#define COEX_CU_CONNECTION_ESTAB_RP 4
3953#define COEX_CU_ASSOCIATED_IDLE_RP 4
3954#define COEX_CU_ASSOC_MANUAL_SCAN_RP 4
3955#define COEX_CU_ASSOC_AUTO_SCAN_RP 4
3956#define COEX_CU_ASSOC_ACTIVE_LEVEL_RP 4
3957#define COEX_CU_RF_ON_RP 6
3958#define COEX_CU_RF_OFF_RP 4
3959#define COEX_CU_STAND_ALONE_DEBUG_RP 6
3960#define COEX_CU_IPAN_ASSOC_LEVEL_RP 4
3961#define COEX_CU_RSRVD1_RP 4
3962#define COEX_CU_RSRVD2_RP 4
3963
3964#define COEX_CU_UNASSOC_IDLE_WP 3
3965#define COEX_CU_UNASSOC_MANUAL_SCAN_WP 3
3966#define COEX_CU_UNASSOC_AUTO_SCAN_WP 3
3967#define COEX_CU_CALIBRATION_WP 3
3968#define COEX_CU_PERIODIC_CALIBRATION_WP 3
3969#define COEX_CU_CONNECTION_ESTAB_WP 3
3970#define COEX_CU_ASSOCIATED_IDLE_WP 3
3971#define COEX_CU_ASSOC_MANUAL_SCAN_WP 3
3972#define COEX_CU_ASSOC_AUTO_SCAN_WP 3
3973#define COEX_CU_ASSOC_ACTIVE_LEVEL_WP 3
3974#define COEX_CU_RF_ON_WP 3
3975#define COEX_CU_RF_OFF_WP 3
3976#define COEX_CU_STAND_ALONE_DEBUG_WP 6
3977#define COEX_CU_IPAN_ASSOC_LEVEL_WP 3
3978#define COEX_CU_RSRVD1_WP 3
3979#define COEX_CU_RSRVD2_WP 3
3980
3981#define COEX_UNASSOC_IDLE_FLAGS 0
3982#define COEX_UNASSOC_MANUAL_SCAN_FLAGS \
3983 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3984 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3985#define COEX_UNASSOC_AUTO_SCAN_FLAGS \
3986 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3987 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3988#define COEX_CALIBRATION_FLAGS \
3989 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3990 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3991#define COEX_PERIODIC_CALIBRATION_FLAGS 0
3992/*
3993 * COEX_CONNECTION_ESTAB:
3994 * we need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
3995 */
3996#define COEX_CONNECTION_ESTAB_FLAGS \
3997 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
3998 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
3999 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
4000#define COEX_ASSOCIATED_IDLE_FLAGS 0
4001#define COEX_ASSOC_MANUAL_SCAN_FLAGS \
4002 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
4003 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
4004#define COEX_ASSOC_AUTO_SCAN_FLAGS \
4005 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
4006 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
4007#define COEX_ASSOC_ACTIVE_LEVEL_FLAGS 0
4008#define COEX_RF_ON_FLAGS 0
4009#define COEX_RF_OFF_FLAGS 0
4010#define COEX_STAND_ALONE_DEBUG_FLAGS \
4011 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
4012 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
4013#define COEX_IPAN_ASSOC_LEVEL_FLAGS \
4014 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
4015 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
4016 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
4017#define COEX_RSRVD1_FLAGS 0
4018#define COEX_RSRVD2_FLAGS 0
4019/*
4020 * COEX_CU_RF_ON is the event wrapping all radio ownership.
4021 * We need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
4022 */
4023#define COEX_CU_RF_ON_FLAGS \
4024 (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
4025 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
4026 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
4027
4028
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004029enum {
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004030 /* un-association part */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004031 COEX_UNASSOC_IDLE = 0,
4032 COEX_UNASSOC_MANUAL_SCAN = 1,
4033 COEX_UNASSOC_AUTO_SCAN = 2,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004034 /* calibration */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004035 COEX_CALIBRATION = 3,
4036 COEX_PERIODIC_CALIBRATION = 4,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004037 /* connection */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004038 COEX_CONNECTION_ESTAB = 5,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004039 /* association part */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004040 COEX_ASSOCIATED_IDLE = 6,
4041 COEX_ASSOC_MANUAL_SCAN = 7,
4042 COEX_ASSOC_AUTO_SCAN = 8,
4043 COEX_ASSOC_ACTIVE_LEVEL = 9,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004044 /* RF ON/OFF */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004045 COEX_RF_ON = 10,
4046 COEX_RF_OFF = 11,
4047 COEX_STAND_ALONE_DEBUG = 12,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004048 /* IPAN */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004049 COEX_IPAN_ASSOC_LEVEL = 13,
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004050 /* reserved */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004051 COEX_RSRVD1 = 14,
4052 COEX_RSRVD2 = 15,
4053 COEX_NUM_OF_EVENTS = 16
4054};
4055
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004056/*
4057 * Coexistence WIFI/WIMAX Command
4058 * COEX_PRIORITY_TABLE_CMD = 0x5a
4059 *
4060 */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004061struct iwl_wimax_coex_event_entry {
4062 u8 request_prio;
4063 u8 win_medium_prio;
4064 u8 reserved;
4065 u8 flags;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004066} __packed;
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004067
4068/* COEX flag masks */
4069
Tomas Winklera96a27f2008-10-23 23:48:56 -07004070/* Station table is valid */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004071#define COEX_FLAGS_STA_TABLE_VALID_MSK (0x1)
Tomas Winklera96a27f2008-10-23 23:48:56 -07004072/* UnMask wake up src at unassociated sleep */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004073#define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK (0x4)
Tomas Winklera96a27f2008-10-23 23:48:56 -07004074/* UnMask wake up src at associated sleep */
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004075#define COEX_FLAGS_ASSOC_WA_UNMASK_MSK (0x8)
4076/* Enable CoEx feature. */
4077#define COEX_FLAGS_COEX_ENABLE_MSK (0x80)
4078
4079struct iwl_wimax_coex_cmd {
4080 u8 flags;
4081 u8 reserved[3];
4082 struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
Eric Dumazetba2d3582010-06-02 18:10:09 +00004083} __packed;
Ron Rindjunsky9636e582008-05-15 13:54:14 +08004084
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004085/*
4086 * Coexistence MEDIUM NOTIFICATION
4087 * COEX_MEDIUM_NOTIFICATION = 0x5b
4088 *
4089 * notification from uCode to host to indicate medium changes
4090 *
4091 */
4092/*
4093 * status field
4094 * bit 0 - 2: medium status
4095 * bit 3: medium change indication
4096 * bit 4 - 31: reserved
4097 */
4098/* status option values, (0 - 2 bits) */
4099#define COEX_MEDIUM_BUSY (0x0) /* radio belongs to WiMAX */
4100#define COEX_MEDIUM_ACTIVE (0x1) /* radio belongs to WiFi */
4101#define COEX_MEDIUM_PRE_RELEASE (0x2) /* received radio release */
4102#define COEX_MEDIUM_MSK (0x7)
4103
4104/* send notification status (1 bit) */
4105#define COEX_MEDIUM_CHANGED (0x8)
4106#define COEX_MEDIUM_CHANGED_MSK (0x8)
4107#define COEX_MEDIUM_SHIFT (3)
4108
4109struct iwl_coex_medium_notification {
4110 __le32 status;
4111 __le32 events;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004112} __packed;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004113
4114/*
4115 * Coexistence EVENT Command
4116 * COEX_EVENT_CMD = 0x5c
4117 *
4118 * send from host to uCode for coex event request.
4119 */
4120/* flags options */
4121#define COEX_EVENT_REQUEST_MSK (0x1)
4122
4123struct iwl_coex_event_cmd {
4124 u8 flags;
4125 u8 event;
4126 __le16 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004127} __packed;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004128
4129struct iwl_coex_event_resp {
4130 __le32 status;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004131} __packed;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004132
4133
Zhu Yib481de92007-09-25 17:54:57 -07004134/******************************************************************************
Johannes Berg0288d232010-08-23 07:56:54 -07004135 * Bluetooth Coexistence commands
4136 *
4137 *****************************************************************************/
4138
4139/*
4140 * BT Status notification
Wey-Yi Guyfbba9412010-08-23 07:57:10 -07004141 * REPLY_BT_COEX_PROFILE_NOTIF = 0xce
Johannes Berg0288d232010-08-23 07:56:54 -07004142 */
4143enum iwl_bt_coex_profile_traffic_load {
4144 IWL_BT_COEX_TRAFFIC_LOAD_NONE = 0,
4145 IWL_BT_COEX_TRAFFIC_LOAD_LOW = 1,
4146 IWL_BT_COEX_TRAFFIC_LOAD_HIGH = 2,
4147 IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS = 3,
4148/*
4149 * There are no more even though below is a u8, the
4150 * indication from the BT device only has two bits.
4151 */
4152};
4153
Wey-Yi Guyfbba9412010-08-23 07:57:10 -07004154#define BT_UART_MSG_FRAME1MSGTYPE_POS (0)
4155#define BT_UART_MSG_FRAME1MSGTYPE_MSK \
4156 (0x7 << BT_UART_MSG_FRAME1MSGTYPE_POS)
4157#define BT_UART_MSG_FRAME1SSN_POS (3)
4158#define BT_UART_MSG_FRAME1SSN_MSK \
4159 (0x3 << BT_UART_MSG_FRAME1SSN_POS)
4160#define BT_UART_MSG_FRAME1UPDATEREQ_POS (5)
4161#define BT_UART_MSG_FRAME1UPDATEREQ_MSK \
4162 (0x1 << BT_UART_MSG_FRAME1UPDATEREQ_POS)
4163#define BT_UART_MSG_FRAME1RESERVED_POS (6)
4164#define BT_UART_MSG_FRAME1RESERVED_MSK \
4165 (0x3 << BT_UART_MSG_FRAME1RESERVED_POS)
4166
4167#define BT_UART_MSG_FRAME2OPENCONNECTIONS_POS (0)
4168#define BT_UART_MSG_FRAME2OPENCONNECTIONS_MSK \
4169 (0x3 << BT_UART_MSG_FRAME2OPENCONNECTIONS_POS)
4170#define BT_UART_MSG_FRAME2TRAFFICLOAD_POS (2)
4171#define BT_UART_MSG_FRAME2TRAFFICLOAD_MSK \
4172 (0x3 << BT_UART_MSG_FRAME2TRAFFICLOAD_POS)
4173#define BT_UART_MSG_FRAME2CHLSEQN_POS (4)
4174#define BT_UART_MSG_FRAME2CHLSEQN_MSK \
4175 (0x1 << BT_UART_MSG_FRAME2CHLSEQN_POS)
4176#define BT_UART_MSG_FRAME2INBAND_POS (5)
4177#define BT_UART_MSG_FRAME2INBAND_MSK \
4178 (0x1 << BT_UART_MSG_FRAME2INBAND_POS)
4179#define BT_UART_MSG_FRAME2RESERVED_POS (6)
4180#define BT_UART_MSG_FRAME2RESERVED_MSK \
4181 (0x3 << BT_UART_MSG_FRAME2RESERVED_POS)
4182
4183#define BT_UART_MSG_FRAME3SCOESCO_POS (0)
4184#define BT_UART_MSG_FRAME3SCOESCO_MSK \
4185 (0x1 << BT_UART_MSG_FRAME3SCOESCO_POS)
4186#define BT_UART_MSG_FRAME3SNIFF_POS (1)
4187#define BT_UART_MSG_FRAME3SNIFF_MSK \
4188 (0x1 << BT_UART_MSG_FRAME3SNIFF_POS)
4189#define BT_UART_MSG_FRAME3A2DP_POS (2)
4190#define BT_UART_MSG_FRAME3A2DP_MSK \
4191 (0x1 << BT_UART_MSG_FRAME3A2DP_POS)
4192#define BT_UART_MSG_FRAME3ACL_POS (3)
4193#define BT_UART_MSG_FRAME3ACL_MSK \
4194 (0x1 << BT_UART_MSG_FRAME3ACL_POS)
4195#define BT_UART_MSG_FRAME3MASTER_POS (4)
4196#define BT_UART_MSG_FRAME3MASTER_MSK \
4197 (0x1 << BT_UART_MSG_FRAME3MASTER_POS)
4198#define BT_UART_MSG_FRAME3OBEX_POS (5)
4199#define BT_UART_MSG_FRAME3OBEX_MSK \
4200 (0x1 << BT_UART_MSG_FRAME3OBEX_POS)
4201#define BT_UART_MSG_FRAME3RESERVED_POS (6)
4202#define BT_UART_MSG_FRAME3RESERVED_MSK \
4203 (0x3 << BT_UART_MSG_FRAME3RESERVED_POS)
4204
4205#define BT_UART_MSG_FRAME4IDLEDURATION_POS (0)
4206#define BT_UART_MSG_FRAME4IDLEDURATION_MSK \
4207 (0x3F << BT_UART_MSG_FRAME4IDLEDURATION_POS)
4208#define BT_UART_MSG_FRAME4RESERVED_POS (6)
4209#define BT_UART_MSG_FRAME4RESERVED_MSK \
4210 (0x3 << BT_UART_MSG_FRAME4RESERVED_POS)
4211
4212#define BT_UART_MSG_FRAME5TXACTIVITY_POS (0)
4213#define BT_UART_MSG_FRAME5TXACTIVITY_MSK \
4214 (0x3 << BT_UART_MSG_FRAME5TXACTIVITY_POS)
4215#define BT_UART_MSG_FRAME5RXACTIVITY_POS (2)
4216#define BT_UART_MSG_FRAME5RXACTIVITY_MSK \
4217 (0x3 << BT_UART_MSG_FRAME5RXACTIVITY_POS)
4218#define BT_UART_MSG_FRAME5ESCORETRANSMIT_POS (4)
4219#define BT_UART_MSG_FRAME5ESCORETRANSMIT_MSK \
4220 (0x3 << BT_UART_MSG_FRAME5ESCORETRANSMIT_POS)
4221#define BT_UART_MSG_FRAME5RESERVED_POS (6)
4222#define BT_UART_MSG_FRAME5RESERVED_MSK \
4223 (0x3 << BT_UART_MSG_FRAME5RESERVED_POS)
4224
4225#define BT_UART_MSG_FRAME6SNIFFINTERVAL_POS (0)
4226#define BT_UART_MSG_FRAME6SNIFFINTERVAL_MSK \
4227 (0x1F << BT_UART_MSG_FRAME6SNIFFINTERVAL_POS)
4228#define BT_UART_MSG_FRAME6DISCOVERABLE_POS (5)
4229#define BT_UART_MSG_FRAME6DISCOVERABLE_MSK \
4230 (0x1 << BT_UART_MSG_FRAME6DISCOVERABLE_POS)
4231#define BT_UART_MSG_FRAME6RESERVED_POS (6)
4232#define BT_UART_MSG_FRAME6RESERVED_MSK \
4233 (0x3 << BT_UART_MSG_FRAME6RESERVED_POS)
4234
4235#define BT_UART_MSG_FRAME7SNIFFACTIVITY_POS (0)
4236#define BT_UART_MSG_FRAME7SNIFFACTIVITY_MSK \
4237 (0x7 << BT_UART_MSG_FRAME7SNIFFACTIVITY_POS)
4238#define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS (3)
4239#define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_MSK \
4240 (0x3 << BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS)
4241#define BT_UART_MSG_FRAME7CONNECTABLE_POS (5)
4242#define BT_UART_MSG_FRAME7CONNECTABLE_MSK \
4243 (0x1 << BT_UART_MSG_FRAME7CONNECTABLE_POS)
4244#define BT_UART_MSG_FRAME7RESERVED_POS (6)
4245#define BT_UART_MSG_FRAME7RESERVED_MSK \
4246 (0x3 << BT_UART_MSG_FRAME7RESERVED_POS)
4247
4248
4249struct iwl_bt_uart_msg {
4250 u8 header;
4251 u8 frame1;
4252 u8 frame2;
4253 u8 frame3;
4254 u8 frame4;
4255 u8 frame5;
4256 u8 frame6;
4257 u8 frame7;
4258} __attribute__((packed));
4259
Johannes Berg0288d232010-08-23 07:56:54 -07004260struct iwl_bt_coex_profile_notif {
Wey-Yi Guyfbba9412010-08-23 07:57:10 -07004261 struct iwl_bt_uart_msg last_bt_uart_msg;
Johannes Berg0288d232010-08-23 07:56:54 -07004262 u8 bt_status; /* 0 - off, 1 - on */
4263 u8 bt_traffic_load; /* 0 .. 3? */
4264 u8 bt_ci_compliance; /* 0 - not complied, 1 - complied */
4265 u8 reserved;
4266} __attribute__((packed));
4267
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004268#define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS 0
4269#define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_MSK 0x1
4270#define IWL_BT_COEX_PRIO_TBL_PRIO_POS 1
4271#define IWL_BT_COEX_PRIO_TBL_PRIO_MASK 0x0e
4272#define IWL_BT_COEX_PRIO_TBL_RESERVED_POS 4
4273#define IWL_BT_COEX_PRIO_TBL_RESERVED_MASK 0xf0
4274#define IWL_BT_COEX_PRIO_TBL_PRIO_SHIFT 1
Johannes Berg0288d232010-08-23 07:56:54 -07004275
4276/*
4277 * BT Coexistence Priority table
4278 * REPLY_BT_COEX_PRIO_TABLE = 0xcc
4279 */
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004280enum bt_coex_prio_table_events {
4281 BT_COEX_PRIO_TBL_EVT_INIT_CALIB1 = 0,
4282 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2 = 1,
4283 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW1 = 2,
4284 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW2 = 3, /* DC calib */
4285 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH1 = 4,
4286 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH2 = 5,
4287 BT_COEX_PRIO_TBL_EVT_DTIM = 6,
4288 BT_COEX_PRIO_TBL_EVT_SCAN52 = 7,
4289 BT_COEX_PRIO_TBL_EVT_SCAN24 = 8,
4290 BT_COEX_PRIO_TBL_EVT_RESERVED0 = 9,
4291 BT_COEX_PRIO_TBL_EVT_RESERVED1 = 10,
4292 BT_COEX_PRIO_TBL_EVT_RESERVED2 = 11,
4293 BT_COEX_PRIO_TBL_EVT_RESERVED3 = 12,
4294 BT_COEX_PRIO_TBL_EVT_RESERVED4 = 13,
4295 BT_COEX_PRIO_TBL_EVT_RESERVED5 = 14,
4296 BT_COEX_PRIO_TBL_EVT_RESERVED6 = 15,
4297 /* BT_COEX_PRIO_TBL_EVT_MAX should always be last */
4298 BT_COEX_PRIO_TBL_EVT_MAX,
4299};
4300
4301enum bt_coex_prio_table_priorities {
4302 BT_COEX_PRIO_TBL_DISABLED = 0,
4303 BT_COEX_PRIO_TBL_PRIO_LOW = 1,
4304 BT_COEX_PRIO_TBL_PRIO_HIGH = 2,
4305 BT_COEX_PRIO_TBL_PRIO_BYPASS = 3,
4306 BT_COEX_PRIO_TBL_PRIO_COEX_OFF = 4,
4307 BT_COEX_PRIO_TBL_PRIO_COEX_ON = 5,
4308 BT_COEX_PRIO_TBL_PRIO_RSRVD1 = 6,
4309 BT_COEX_PRIO_TBL_PRIO_RSRVD2 = 7,
4310 BT_COEX_PRIO_TBL_MAX,
4311};
4312
Johannes Berg0288d232010-08-23 07:56:54 -07004313struct iwl_bt_coex_prio_table_cmd {
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004314 u8 prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX];
Johannes Berg0288d232010-08-23 07:56:54 -07004315} __attribute__((packed));
4316
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004317#define IWL_BT_COEX_ENV_CLOSE 0
4318#define IWL_BT_COEX_ENV_OPEN 1
Johannes Berg0288d232010-08-23 07:56:54 -07004319/*
4320 * BT Protection Envelope
4321 * REPLY_BT_COEX_PROT_ENV = 0xcd
4322 */
4323struct iwl_bt_coex_prot_env_cmd {
Wey-Yi Guyaeb4a2e2010-08-23 07:57:05 -07004324 u8 action; /* 0 = closed, 1 = open */
Johannes Berg0288d232010-08-23 07:56:54 -07004325 u8 type; /* 0 .. 15 */
4326 u8 reserved[2];
4327} __attribute__((packed));
4328
4329/******************************************************************************
Zhu Yib481de92007-09-25 17:54:57 -07004330 * (13)
4331 * Union of all expected notifications/responses:
4332 *
4333 *****************************************************************************/
4334
Tomas Winklerdb11d632008-05-05 10:22:33 +08004335struct iwl_rx_packet {
Zhu Yi2f301222009-10-09 17:19:45 +08004336 /*
4337 * The first 4 bytes of the RX frame header contain both the RX frame
4338 * size and some flags.
4339 * Bit fields:
4340 * 31: flag flush RB request
4341 * 30: flag ignore TC (terminal counter) request
4342 * 29: flag fast IRQ request
4343 * 28-14: Reserved
4344 * 13-00: RX frame size
4345 */
Daniel C Halperin396887a2009-08-13 13:31:01 -07004346 __le32 len_n_flags;
Tomas Winkler857485c2008-03-21 13:53:44 -07004347 struct iwl_cmd_header hdr;
Zhu Yib481de92007-09-25 17:54:57 -07004348 union {
Tomas Winkler3d24a9f2008-12-19 10:37:07 +08004349 struct iwl3945_rx_frame rx_frame;
4350 struct iwl3945_tx_resp tx_resp;
4351 struct iwl3945_beacon_notif beacon_status;
4352
Tomas Winkler885ba202008-05-29 16:34:55 +08004353 struct iwl_alive_resp alive_frame;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004354 struct iwl_spectrum_notification spectrum_notif;
4355 struct iwl_csa_notification csa_notif;
Tomas Winkler885ba202008-05-29 16:34:55 +08004356 struct iwl_error_resp err_resp;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004357 struct iwl_card_state_notif card_state_notif;
Tomas Winkler7a999bf2008-05-29 16:35:02 +08004358 struct iwl_add_sta_resp add_sta;
4359 struct iwl_rem_sta_resp rem_sta;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004360 struct iwl_sleep_notification sleep_notif;
4361 struct iwl_spectrum_resp spectrum;
Emmanuel Grumbach8f91aec2008-06-30 17:23:07 +08004362 struct iwl_notif_statistics stats;
Wey-Yi Guy7980fba2010-07-14 08:08:57 -07004363 struct iwl_bt_notif_statistics stats_bt;
Emmanuel Grumbach653fa4a2008-06-30 17:23:11 +08004364 struct iwl_compressed_ba_resp compressed_ba;
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08004365 struct iwl_missed_beacon_notif missed_beacon;
Wey-Yi Guyfe1bcbf2009-10-30 14:36:16 -07004366 struct iwl_coex_medium_notification coex_medium_notif;
4367 struct iwl_coex_event_resp coex_event;
Johannes Berg0288d232010-08-23 07:56:54 -07004368 struct iwl_bt_coex_profile_notif bt_coex_profile_notif;
Zhu Yib481de92007-09-25 17:54:57 -07004369 __le32 status;
4370 u8 raw[0];
4371 } u;
Eric Dumazetba2d3582010-06-02 18:10:09 +00004372} __packed;
Zhu Yib481de92007-09-25 17:54:57 -07004373
Samuel Ortiza3139c52008-12-19 10:37:09 +08004374int iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
Winkler, Tomas8f5c87d2008-12-02 12:13:57 -08004375
Johannes Berg946ba302010-08-23 10:46:48 +02004376/*
4377 * REPLY_WIPAN_PARAMS = 0xb2 (Commands and Notification)
4378 */
4379
Johannes Berg94073912011-01-06 08:07:11 -08004380/*
4381 * Minimum slot time in TU
4382 */
4383#define IWL_MIN_SLOT_TIME 20
4384
Johannes Berg946ba302010-08-23 10:46:48 +02004385/**
4386 * struct iwl_wipan_slot
4387 * @width: Time in TU
4388 * @type:
4389 * 0 - BSS
4390 * 1 - PAN
4391 */
4392struct iwl_wipan_slot {
4393 __le16 width;
4394 u8 type;
4395 u8 reserved;
4396} __packed;
4397
4398#define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_CTS BIT(1) /* reserved */
4399#define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_QUIET BIT(2) /* reserved */
4400#define IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE BIT(3) /* reserved */
4401#define IWL_WIPAN_PARAMS_FLG_FILTER_BEACON_NOTIF BIT(4)
4402#define IWL_WIPAN_PARAMS_FLG_FULL_SLOTTED_MODE BIT(5)
4403
4404/**
4405 * struct iwl_wipan_params_cmd
4406 * @flags:
4407 * bit0: reserved
4408 * bit1: CP leave channel with CTS
4409 * bit2: CP leave channel qith Quiet
4410 * bit3: slotted mode
4411 * 1 - work in slotted mode
4412 * 0 - work in non slotted mode
4413 * bit4: filter beacon notification
4414 * bit5: full tx slotted mode. if this flag is set,
4415 * uCode will perform leaving channel methods in context switch
4416 * also when working in same channel mode
4417 * @num_slots: 1 - 10
4418 */
4419struct iwl_wipan_params_cmd {
4420 __le16 flags;
4421 u8 reserved;
4422 u8 num_slots;
4423 struct iwl_wipan_slot slots[10];
4424} __packed;
4425
4426/*
4427 * REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9
4428 *
4429 * TODO: Figure out what this is used for,
4430 * it can only switch between 2.4 GHz
4431 * channels!!
4432 */
4433
4434struct iwl_wipan_p2p_channel_switch_cmd {
4435 __le16 channel;
4436 __le16 reserved;
4437};
4438
4439/*
4440 * REPLY_WIPAN_NOA_NOTIFICATION = 0xbc
4441 *
4442 * This is used by the device to notify us of the
4443 * NoA schedule it determined so we can forward it
4444 * to userspace for inclusion in probe responses.
4445 *
4446 * In beacons, the NoA schedule is simply appended
4447 * to the frame we give the device.
4448 */
4449
4450struct iwl_wipan_noa_descriptor {
4451 u8 count;
4452 __le32 duration;
4453 __le32 interval;
4454 __le32 starttime;
4455} __packed;
4456
4457struct iwl_wipan_noa_attribute {
4458 u8 id;
4459 __le16 length;
4460 u8 index;
4461 u8 ct_window;
4462 struct iwl_wipan_noa_descriptor descr0, descr1;
4463 u8 reserved;
4464} __packed;
4465
4466struct iwl_wipan_noa_notification {
4467 u32 noa_active;
4468 struct iwl_wipan_noa_attribute noa_attribute;
4469} __packed;
4470
Emmanuel Grumbach6a635782008-10-29 14:05:47 -07004471#endif /* __iwl_commands_h__ */