blob: 048421511988afb12892bc7f9951d07f90d5d85c [file] [log] [blame]
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080063
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +020064#ifndef __il_commands_h__
65#define __il_commands_h__
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080066
Stanislaw Gruszka99412002011-08-31 13:53:04 +020067#include <linux/ieee80211.h>
68
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +020069struct il_priv;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080070
71/* uCode version contains 4 values: Major/Minor/API/Serial */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +020072#define IL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24)
73#define IL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16)
74#define IL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8)
75#define IL_UCODE_SERIAL(ver) ((ver) & 0x000000FF)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080076
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080077/* Tx rates */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +020078#define IL_CCK_RATES 4
79#define IL_OFDM_RATES 8
80#define IL_MAX_RATES (IL_CCK_RATES + IL_OFDM_RATES)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080081
82enum {
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +020083 N_ALIVE = 0x1,
84 N_ERROR = 0x2,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080085
86 /* RXON and QOS commands */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +020087 C_RXON = 0x10,
88 C_RXON_ASSOC = 0x11,
89 C_QOS_PARAM = 0x13,
90 C_RXON_TIMING = 0x14,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080091
92 /* Multi-Station support */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +020093 C_ADD_STA = 0x18,
94 C_REM_STA = 0x19,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080095
96 /* Security */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +020097 C_WEPKEY = 0x20,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080098
99 /* RX, TX, LEDs */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100100 N_3945_RX = 0x1b, /* 3945 only */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200101 C_TX = 0x1c,
102 C_RATE_SCALE = 0x47, /* 3945 only */
103 C_LEDS = 0x48,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100104 C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800105
106 /* 802.11h related */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200107 C_CHANNEL_SWITCH = 0x72,
108 N_CHANNEL_SWITCH = 0x73,
109 C_SPECTRUM_MEASUREMENT = 0x74,
110 N_SPECTRUM_MEASUREMENT = 0x75,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800111
112 /* Power Management */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200113 C_POWER_TBL = 0x77,
114 N_PM_SLEEP = 0x7A,
115 N_PM_DEBUG_STATS = 0x7B,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800116
117 /* Scan commands and notifications */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200118 C_SCAN = 0x80,
119 C_SCAN_ABORT = 0x81,
120 N_SCAN_START = 0x82,
121 N_SCAN_RESULTS = 0x83,
122 N_SCAN_COMPLETE = 0x84,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800123
124 /* IBSS/AP commands */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200125 N_BEACON = 0x90,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100126 C_TX_BEACON = 0x91,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800127
128 /* Miscellaneous commands */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200129 C_TX_PWR_TBL = 0x97,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800130
131 /* Bluetooth device coexistence config command */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200132 C_BT_CONFIG = 0x9b,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800133
134 /* Statistics */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200135 C_STATS = 0x9c,
136 N_STATS = 0x9d,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800137
138 /* RF-KILL commands and notifications */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200139 N_CARD_STATE = 0xa1,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800140
141 /* Missed beacons notification */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200142 N_MISSED_BEACONS = 0xa2,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800143
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200144 C_CT_KILL_CONFIG = 0xa4,
145 C_SENSITIVITY = 0xa8,
146 C_PHY_CALIBRATION = 0xb0,
147 N_RX_PHY = 0xc0,
148 N_RX_MPDU = 0xc1,
149 N_RX = 0xc3,
150 N_COMPRESSED_BA = 0xc5,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800151
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200152 IL_CN_MAX = 0xff
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800153};
154
155/******************************************************************************
156 * (0)
157 * Commonly used structures and definitions:
158 * Command header, rate_n_flags, txpower
159 *
160 *****************************************************************************/
161
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200162/* il_cmd_header flags value */
163#define IL_CMD_FAILED_MSK 0x40
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800164
165#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f)
166#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8)
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +0200167#define SEQ_TO_IDX(s) ((s) & 0xff)
168#define IDX_TO_SEQ(i) ((i) & 0xff)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800169#define SEQ_HUGE_FRAME cpu_to_le16(0x4000)
170#define SEQ_RX_FRAME cpu_to_le16(0x8000)
171
172/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200173 * struct il_cmd_header
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800174 *
175 * This header format appears in the beginning of each command sent from the
176 * driver, and each response/notification received from uCode.
177 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200178struct il_cmd_header {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100179 u8 cmd; /* Command ID: C_RXON, etc. */
180 u8 flags; /* 0:5 reserved, 6 abort, 7 internal */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800181 /*
182 * The driver sets up the sequence number to values of its choosing.
183 * uCode does not use this value, but passes it back to the driver
184 * when sending the response to each driver-originated command, so
185 * the driver can match the response to the command. Since the values
186 * don't get used by uCode, the driver may set up an arbitrary format.
187 *
188 * There is one exception: uCode sets bit 15 when it originates
189 * the response/notification, i.e. when the response/notification
190 * is not a direct response to a command sent by the driver. For
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200191 * example, uCode issues N_3945_RX when it sends a received frame
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800192 * to the driver; it is not a direct response to any driver command.
193 *
194 * The Linux driver uses the following format:
195 *
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100196 * 0:7 tfd idx - position within TX queue
197 * 8:12 TX queue id
198 * 13 reserved
199 * 14 huge - driver sets this to indicate command is in the
200 * 'huge' storage at the end of the command buffers
201 * 15 unsolicited RX or uCode-originated notification
202 */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800203 __le16 sequence;
204
205 /* command or response/notification data follows immediately */
206 u8 data[0];
207} __packed;
208
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800209/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200210 * struct il3945_tx_power
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800211 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200212 * Used in C_TX_PWR_TBL, C_SCAN, C_CHANNEL_SWITCH
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800213 *
214 * Each entry contains two values:
215 * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
216 * linear value that multiplies the output of the digital signal processor,
217 * before being sent to the analog radio.
218 * 2) Radio gain. This sets the analog gain of the radio Tx path.
219 * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
220 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200221 * Driver obtains values from struct il3945_tx_power power_gain_table[][].
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800222 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200223struct il3945_tx_power {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800224 u8 tx_gain; /* gain for analog radio */
225 u8 dsp_atten; /* gain for DSP */
226} __packed;
227
228/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200229 * struct il3945_power_per_rate
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800230 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200231 * Used in C_TX_PWR_TBL, C_CHANNEL_SWITCH
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800232 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200233struct il3945_power_per_rate {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800234 u8 rate; /* plcp */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200235 struct il3945_tx_power tpc;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800236 u8 reserved;
237} __packed;
238
239/**
240 * iwl4965 rate_n_flags bit fields
241 *
242 * rate_n_flags format is used in following iwl4965 commands:
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200243 * N_RX (response only)
244 * N_RX_MPDU (response only)
245 * C_TX (both command and response)
246 * C_TX_LINK_QUALITY_CMD
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800247 *
248 * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
249 * 2-0: 0) 6 Mbps
250 * 1) 12 Mbps
251 * 2) 18 Mbps
252 * 3) 24 Mbps
253 * 4) 36 Mbps
254 * 5) 48 Mbps
255 * 6) 54 Mbps
256 * 7) 60 Mbps
257 *
258 * 4-3: 0) Single stream (SISO)
259 * 1) Dual stream (MIMO)
260 * 2) Triple stream (MIMO)
261 *
262 * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
263 *
264 * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
265 * 3-0: 0xD) 6 Mbps
266 * 0xF) 9 Mbps
267 * 0x5) 12 Mbps
268 * 0x7) 18 Mbps
269 * 0x9) 24 Mbps
270 * 0xB) 36 Mbps
271 * 0x1) 48 Mbps
272 * 0x3) 54 Mbps
273 *
274 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
275 * 6-0: 10) 1 Mbps
276 * 20) 2 Mbps
277 * 55) 5.5 Mbps
278 * 110) 11 Mbps
279 */
280#define RATE_MCS_CODE_MSK 0x7
281#define RATE_MCS_SPATIAL_POS 3
282#define RATE_MCS_SPATIAL_MSK 0x18
283#define RATE_MCS_HT_DUP_POS 5
284#define RATE_MCS_HT_DUP_MSK 0x20
285
286/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
287#define RATE_MCS_FLAGS_POS 8
288#define RATE_MCS_HT_POS 8
289#define RATE_MCS_HT_MSK 0x100
290
291/* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */
292#define RATE_MCS_CCK_POS 9
293#define RATE_MCS_CCK_MSK 0x200
294
295/* Bit 10: (1) Use Green Field preamble */
296#define RATE_MCS_GF_POS 10
297#define RATE_MCS_GF_MSK 0x400
298
299/* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */
300#define RATE_MCS_HT40_POS 11
301#define RATE_MCS_HT40_MSK 0x800
302
303/* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */
304#define RATE_MCS_DUP_POS 12
305#define RATE_MCS_DUP_MSK 0x1000
306
307/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
308#define RATE_MCS_SGI_POS 13
309#define RATE_MCS_SGI_MSK 0x2000
310
311/**
312 * rate_n_flags Tx antenna masks
313 * 4965 has 2 transmitters
314 * bit14:16
315 */
316#define RATE_MCS_ANT_POS 14
317#define RATE_MCS_ANT_A_MSK 0x04000
318#define RATE_MCS_ANT_B_MSK 0x08000
319#define RATE_MCS_ANT_C_MSK 0x10000
320#define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK)
321#define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK)
322#define RATE_ANT_NUM 3
323
Stanislaw Gruszka3b98c7f2011-08-26 16:29:35 +0200324#define POWER_TBL_NUM_ENTRIES 33
325#define POWER_TBL_NUM_HT_OFDM_ENTRIES 32
326#define POWER_TBL_CCK_ENTRY 32
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800327
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200328#define IL_PWR_NUM_HT_OFDM_ENTRIES 24
329#define IL_PWR_CCK_ENTRIES 2
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800330
331/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200332 * union il4965_tx_power_dual_stream
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800333 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200334 * Host format used for C_TX_PWR_TBL, C_CHANNEL_SWITCH
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800335 * Use __le32 version (struct tx_power_dual_stream) when building command.
336 *
337 * Driver provides radio gain and DSP attenuation settings to device in pairs,
338 * one value for each transmitter chain. The first value is for transmitter A,
339 * second for transmitter B.
340 *
341 * For SISO bit rates, both values in a pair should be identical.
342 * For MIMO rates, one value may be different from the other,
343 * in order to balance the Tx output between the two transmitters.
344 *
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200345 * See more details in doc for TXPOWER in 4965.h.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800346 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200347union il4965_tx_power_dual_stream {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800348 struct {
349 u8 radio_tx_gain[2];
350 u8 dsp_predis_atten[2];
351 } s;
352 u32 dw;
353};
354
355/**
356 * struct tx_power_dual_stream
357 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200358 * Table entries in C_TX_PWR_TBL, C_CHANNEL_SWITCH
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800359 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200360 * Same format as il_tx_power_dual_stream, but __le32
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800361 */
362struct tx_power_dual_stream {
363 __le32 dw;
364} __packed;
365
366/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200367 * struct il4965_tx_power_db
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800368 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200369 * Entire table within C_TX_PWR_TBL, C_CHANNEL_SWITCH
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800370 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200371struct il4965_tx_power_db {
Stanislaw Gruszka3b98c7f2011-08-26 16:29:35 +0200372 struct tx_power_dual_stream power_tbl[POWER_TBL_NUM_ENTRIES];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800373} __packed;
374
375/******************************************************************************
376 * (0a)
377 * Alive and Error Commands & Responses:
378 *
379 *****************************************************************************/
380
381#define UCODE_VALID_OK cpu_to_le32(0x1)
382#define INITIALIZE_SUBTYPE (9)
383
384/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200385 * ("Initialize") N_ALIVE = 0x1 (response only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800386 *
387 * uCode issues this "initialize alive" notification once the initialization
388 * uCode image has completed its work, and is ready to load the runtime image.
389 * This is the *first* "alive" notification that the driver will receive after
390 * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
391 *
392 * See comments documenting "BSM" (bootstrap state machine).
393 *
394 * For 4965, this notification contains important calibration data for
395 * calculating txpower settings:
396 *
397 * 1) Power supply voltage indication. The voltage sensor outputs higher
398 * values for lower voltage, and vice verse.
399 *
400 * 2) Temperature measurement parameters, for each of two channel widths
401 * (20 MHz and 40 MHz) supported by the radios. Temperature sensing
402 * is done via one of the receiver chains, and channel width influences
403 * the results.
404 *
405 * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation,
406 * for each of 5 frequency ranges.
407 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200408struct il_init_alive_resp {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800409 u8 ucode_minor;
410 u8 ucode_major;
411 __le16 reserved1;
412 u8 sw_rev[8];
413 u8 ver_type;
414 u8 ver_subtype; /* "9" for initialize alive */
415 __le16 reserved2;
416 __le32 log_event_table_ptr;
417 __le32 error_event_table_ptr;
418 __le32 timestamp;
419 __le32 is_valid;
420
421 /* calibration values from "initialize" uCode */
422 __le32 voltage; /* signed, higher value is lower voltage */
423 __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for HT40 */
424 __le32 therm_r2[2]; /* signed */
425 __le32 therm_r3[2]; /* signed */
426 __le32 therm_r4[2]; /* signed */
427 __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups,
428 * 2 Tx chains */
429} __packed;
430
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800431/**
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200432 * N_ALIVE = 0x1 (response only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800433 *
434 * uCode issues this "alive" notification once the runtime image is ready
435 * to receive commands from the driver. This is the *second* "alive"
436 * notification that the driver will receive after rebooting uCode;
437 * this "alive" is indicated by subtype field != 9.
438 *
439 * See comments documenting "BSM" (bootstrap state machine).
440 *
441 * This response includes two pointers to structures within the device's
442 * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
443 *
444 * 1) log_event_table_ptr indicates base of the event log. This traces
445 * a 256-entry history of uCode execution within a circular buffer.
446 * Its header format is:
447 *
448 * __le32 log_size; log capacity (in number of entries)
449 * __le32 type; (1) timestamp with each entry, (0) no timestamp
450 * __le32 wraps; # times uCode has wrapped to top of circular buffer
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100451 * __le32 write_idx; next circular buffer entry that uCode would fill
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800452 *
453 * The header is followed by the circular buffer of log entries. Entries
454 * with timestamps have the following format:
455 *
456 * __le32 event_id; range 0 - 1500
457 * __le32 timestamp; low 32 bits of TSF (of network, if associated)
458 * __le32 data; event_id-specific data value
459 *
460 * Entries without timestamps contain only event_id and data.
461 *
462 *
463 * 2) error_event_table_ptr indicates base of the error log. This contains
464 * information about any uCode error that occurs. For 4965, the format
465 * of the error log is:
466 *
467 * __le32 valid; (nonzero) valid, (0) log is empty
468 * __le32 error_id; type of error
469 * __le32 pc; program counter
470 * __le32 blink1; branch link
471 * __le32 blink2; branch link
472 * __le32 ilink1; interrupt link
473 * __le32 ilink2; interrupt link
474 * __le32 data1; error-specific data
475 * __le32 data2; error-specific data
476 * __le32 line; source code line of error
477 * __le32 bcon_time; beacon timer
478 * __le32 tsf_low; network timestamp function timer
479 * __le32 tsf_hi; network timestamp function timer
480 * __le32 gp1; GP1 timer register
481 * __le32 gp2; GP2 timer register
482 * __le32 gp3; GP3 timer register
483 * __le32 ucode_ver; uCode version
484 * __le32 hw_ver; HW Silicon version
485 * __le32 brd_ver; HW board version
486 * __le32 log_pc; log program counter
487 * __le32 frame_ptr; frame pointer
488 * __le32 stack_ptr; stack pointer
489 * __le32 hcmd; last host command
490 * __le32 isr0; isr status register LMPM_NIC_ISR0: rxtx_flag
491 * __le32 isr1; isr status register LMPM_NIC_ISR1: host_flag
492 * __le32 isr2; isr status register LMPM_NIC_ISR2: enc_flag
493 * __le32 isr3; isr status register LMPM_NIC_ISR3: time_flag
494 * __le32 isr4; isr status register LMPM_NIC_ISR4: wico interrupt
495 * __le32 isr_pref; isr status register LMPM_NIC_PREF_STAT
496 * __le32 wait_event; wait event() caller address
497 * __le32 l2p_control; L2pControlField
498 * __le32 l2p_duration; L2pDurationField
499 * __le32 l2p_mhvalid; L2pMhValidBits
500 * __le32 l2p_addr_match; L2pAddrMatchStat
501 * __le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL)
502 * __le32 u_timestamp; indicate when the date and time of the compilation
503 * __le32 reserved;
504 *
505 * The Linux driver can print both logs to the system log when a uCode error
506 * occurs.
507 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200508struct il_alive_resp {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800509 u8 ucode_minor;
510 u8 ucode_major;
511 __le16 reserved1;
512 u8 sw_rev[8];
513 u8 ver_type;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100514 u8 ver_subtype; /* not "9" for runtime alive */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800515 __le16 reserved2;
516 __le32 log_event_table_ptr; /* SRAM address for event log */
517 __le32 error_event_table_ptr; /* SRAM address for error log */
518 __le32 timestamp;
519 __le32 is_valid;
520} __packed;
521
522/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200523 * N_ERROR = 0x2 (response only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800524 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200525struct il_error_resp {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800526 __le32 error_type;
527 u8 cmd_id;
528 u8 reserved1;
529 __le16 bad_cmd_seq_num;
530 __le32 error_info;
531 __le64 timestamp;
532} __packed;
533
534/******************************************************************************
535 * (1)
536 * RXON Commands & Responses:
537 *
538 *****************************************************************************/
539
540/*
541 * Rx config defines & structure
542 */
543/* rx_config device types */
544enum {
545 RXON_DEV_TYPE_AP = 1,
546 RXON_DEV_TYPE_ESS = 3,
547 RXON_DEV_TYPE_IBSS = 4,
548 RXON_DEV_TYPE_SNIFFER = 6,
549};
550
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800551#define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0)
552#define RXON_RX_CHAIN_DRIVER_FORCE_POS (0)
553#define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1)
554#define RXON_RX_CHAIN_VALID_POS (1)
555#define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4)
556#define RXON_RX_CHAIN_FORCE_SEL_POS (4)
557#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7)
558#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
559#define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10)
560#define RXON_RX_CHAIN_CNT_POS (10)
561#define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12)
562#define RXON_RX_CHAIN_MIMO_CNT_POS (12)
563#define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14)
564#define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
565
566/* rx_config flags */
567/* band & modulation selection */
568#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0)
569#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1)
570/* auto detection enable */
571#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2)
572/* TGg protection when tx */
573#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3)
574/* cck short slot & preamble */
575#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4)
576#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5)
577/* antenna selection */
578#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7)
579#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00)
580#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
581#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
582/* radar detection enable */
583#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12)
584#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13)
585/* rx response to host with 8-byte TSF
586* (according to ON_AIR deassertion) */
587#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15)
588
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800589/* HT flags */
590#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
591#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22)
592
593#define RXON_FLG_HT_OPERATING_MODE_POS (23)
594
595#define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23)
596#define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23)
597
598#define RXON_FLG_CHANNEL_MODE_POS (25)
599#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25)
600
601/* channel mode */
602enum {
603 CHANNEL_MODE_LEGACY = 0,
604 CHANNEL_MODE_PURE_40 = 1,
605 CHANNEL_MODE_MIXED = 2,
606 CHANNEL_MODE_RESERVED = 3,
607};
608#define RXON_FLG_CHANNEL_MODE_LEGACY \
609 cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
610#define RXON_FLG_CHANNEL_MODE_PURE_40 \
611 cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
612#define RXON_FLG_CHANNEL_MODE_MIXED \
613 cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
614
615/* CTS to self (if spec allows) flag */
616#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30)
617
618/* rx_config filter flags */
619/* accept all data frames */
620#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0)
621/* pass control & management to host */
622#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1)
623/* accept multi-cast */
624#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2)
625/* don't decrypt uni-cast frames */
626#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3)
627/* don't decrypt multi-cast frames */
628#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
629/* STA is associated */
630#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5)
631/* transfer to host non bssid beacons in associated state */
632#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6)
633
634/**
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200635 * C_RXON = 0x10 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800636 *
637 * RXON tunes the radio tuner to a service channel, and sets up a number
638 * of parameters that are used primarily for Rx, but also for Tx operations.
639 *
640 * NOTE: When tuning to a new channel, driver must set the
641 * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent
642 * info within the device, including the station tables, tx retry
643 * rate tables, and txpower tables. Driver must build a new station
644 * table and txpower table before transmitting anything on the RXON
645 * channel.
646 *
647 * NOTE: All RXONs wipe clean the internal txpower table. Driver must
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200648 * issue a new C_TX_PWR_TBL after each C_RXON (0x10),
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800649 * regardless of whether RXON_FILTER_ASSOC_MSK is set.
650 */
651
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200652struct il3945_rxon_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800653 u8 node_addr[6];
654 __le16 reserved1;
655 u8 bssid_addr[6];
656 __le16 reserved2;
657 u8 wlap_bssid_addr[6];
658 __le16 reserved3;
659 u8 dev_type;
660 u8 air_propagation;
661 __le16 reserved4;
662 u8 ofdm_basic_rates;
663 u8 cck_basic_rates;
664 __le16 assoc_id;
665 __le32 flags;
666 __le32 filter_flags;
667 __le16 channel;
668 __le16 reserved5;
669} __packed;
670
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200671struct il4965_rxon_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800672 u8 node_addr[6];
673 __le16 reserved1;
674 u8 bssid_addr[6];
675 __le16 reserved2;
676 u8 wlap_bssid_addr[6];
677 __le16 reserved3;
678 u8 dev_type;
679 u8 air_propagation;
680 __le16 rx_chain;
681 u8 ofdm_basic_rates;
682 u8 cck_basic_rates;
683 __le16 assoc_id;
684 __le32 flags;
685 __le32 filter_flags;
686 __le16 channel;
687 u8 ofdm_ht_single_stream_basic_rates;
688 u8 ofdm_ht_dual_stream_basic_rates;
689} __packed;
690
691/* Create a common rxon cmd which will be typecast into the 3945 or 4965
692 * specific rxon cmd, depending on where it is called from.
693 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200694struct il_rxon_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800695 u8 node_addr[6];
696 __le16 reserved1;
697 u8 bssid_addr[6];
698 __le16 reserved2;
699 u8 wlap_bssid_addr[6];
700 __le16 reserved3;
701 u8 dev_type;
702 u8 air_propagation;
703 __le16 rx_chain;
704 u8 ofdm_basic_rates;
705 u8 cck_basic_rates;
706 __le16 assoc_id;
707 __le32 flags;
708 __le32 filter_flags;
709 __le16 channel;
710 u8 ofdm_ht_single_stream_basic_rates;
711 u8 ofdm_ht_dual_stream_basic_rates;
712 u8 reserved4;
713 u8 reserved5;
714} __packed;
715
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800716/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200717 * C_RXON_ASSOC = 0x11 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800718 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200719struct il3945_rxon_assoc_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800720 __le32 flags;
721 __le32 filter_flags;
722 u8 ofdm_basic_rates;
723 u8 cck_basic_rates;
724 __le16 reserved;
725} __packed;
726
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200727struct il4965_rxon_assoc_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800728 __le32 flags;
729 __le32 filter_flags;
730 u8 ofdm_basic_rates;
731 u8 cck_basic_rates;
732 u8 ofdm_ht_single_stream_basic_rates;
733 u8 ofdm_ht_dual_stream_basic_rates;
734 __le16 rx_chain_select_flags;
735 __le16 reserved;
736} __packed;
737
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200738#define IL_CONN_MAX_LISTEN_INTERVAL 10
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100739#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */
740#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800741
742/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200743 * C_RXON_TIMING = 0x14 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800744 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200745struct il_rxon_time_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800746 __le64 timestamp;
747 __le16 beacon_interval;
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +0200748 __le16 atim_win;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800749 __le32 beacon_init_val;
750 __le16 listen_interval;
751 u8 dtim_period;
752 u8 delta_cp_bss_tbtts;
753} __packed;
754
755/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200756 * C_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800757 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200758struct il3945_channel_switch_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800759 u8 band;
760 u8 expect_beacon;
761 __le16 channel;
762 __le32 rxon_flags;
763 __le32 rxon_filter_flags;
764 __le32 switch_time;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200765 struct il3945_power_per_rate power[IL_MAX_RATES];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800766} __packed;
767
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200768struct il4965_channel_switch_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800769 u8 band;
770 u8 expect_beacon;
771 __le16 channel;
772 __le32 rxon_flags;
773 __le32 rxon_filter_flags;
774 __le32 switch_time;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200775 struct il4965_tx_power_db tx_power;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800776} __packed;
777
778/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200779 * N_CHANNEL_SWITCH = 0x73 (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800780 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200781struct il_csa_notification {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800782 __le16 band;
783 __le16 channel;
784 __le32 status; /* 0 - OK, 1 - fail */
785} __packed;
786
787/******************************************************************************
788 * (2)
789 * Quality-of-Service (QOS) Commands & Responses:
790 *
791 *****************************************************************************/
792
793/**
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200794 * struct il_ac_qos -- QOS timing params for C_QOS_PARAM
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200795 * One for each of 4 EDCA access categories in struct il_qosparam_cmd
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800796 *
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +0200797 * @cw_min: Contention win, start value in numbers of slots.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800798 * Should be a power-of-2, minus 1. Device's default is 0x0f.
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +0200799 * @cw_max: Contention win, max value in numbers of slots.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800800 * Should be a power-of-2, minus 1. Device's default is 0x3f.
801 * @aifsn: Number of slots in Arbitration Interframe Space (before
802 * performing random backoff timing prior to Tx). Device default 1.
803 * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
804 *
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +0200805 * Device will automatically increase contention win by (2*CW) + 1 for each
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800806 * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
807 * value, to cap the CW value.
808 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200809struct il_ac_qos {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800810 __le16 cw_min;
811 __le16 cw_max;
812 u8 aifsn;
813 u8 reserved1;
814 __le16 edca_txop;
815} __packed;
816
817/* QoS flags defines */
818#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01)
819#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02)
820#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10)
821
822/* Number of Access Categories (AC) (EDCA), queues 0..3 */
823#define AC_NUM 4
824
825/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200826 * C_QOS_PARAM = 0x13 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800827 *
828 * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
829 * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
830 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200831struct il_qosparam_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800832 __le32 qos_flags;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200833 struct il_ac_qos ac[AC_NUM];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800834} __packed;
835
836/******************************************************************************
837 * (3)
838 * Add/Modify Stations Commands & Responses:
839 *
840 *****************************************************************************/
841/*
842 * Multi station support
843 */
844
845/* Special, dedicated locations within device's station table */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200846#define IL_AP_ID 0
847#define IL_STA_ID 2
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100848#define IL3945_BROADCAST_ID 24
849#define IL3945_STATION_COUNT 25
850#define IL4965_BROADCAST_ID 31
851#define IL4965_STATION_COUNT 32
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800852
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100853#define IL_STATION_COUNT 32 /* MAX(3945,4965) */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200854#define IL_INVALID_STATION 255
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800855
856#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2)
857#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8)
858#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17)
859#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18)
860#define STA_FLG_MAX_AGG_SIZE_POS (19)
861#define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19)
862#define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21)
863#define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22)
864#define STA_FLG_AGG_MPDU_DENSITY_POS (23)
865#define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23)
866
867/* Use in mode field. 1: modify existing entry, 0: add new station entry */
868#define STA_CONTROL_MODIFY_MSK 0x01
869
870/* key flags __le16*/
871#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007)
872#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000)
873#define STA_KEY_FLG_WEP cpu_to_le16(0x0001)
874#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002)
875#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003)
876
877#define STA_KEY_FLG_KEYID_POS 8
878#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800)
879/* wep key is either from global key (0) or from station info array (1) */
880#define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008)
881
882/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
883#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000)
884#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
885#define STA_KEY_MAX_NUM 8
886
887/* Flags indicate whether to modify vs. don't change various station params */
888#define STA_MODIFY_KEY_MASK 0x01
889#define STA_MODIFY_TID_DISABLE_TX 0x02
890#define STA_MODIFY_TX_RATE_MSK 0x04
891#define STA_MODIFY_ADDBA_TID_MSK 0x08
892#define STA_MODIFY_DELBA_TID_MSK 0x10
893#define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20
894
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100895/* Receiver address (actually, Rx station's idx into station table),
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800896 * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
897#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid))
898
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200899struct il4965_keyinfo {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800900 __le16 key_flags;
901 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
902 u8 reserved1;
903 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
904 u8 key_offset;
905 u8 reserved2;
906 u8 key[16]; /* 16-byte unicast decryption key */
907} __packed;
908
909/**
910 * struct sta_id_modify
911 * @addr[ETH_ALEN]: station's MAC address
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100912 * @sta_id: idx of station in uCode's station table
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800913 * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
914 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100915 * Driver selects unused table idx when adding new station,
916 * or the idx to a pre-existing station entry when modifying that station.
917 * Some idxes have special purposes (IL_AP_ID, idx 0, is for AP).
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800918 *
919 * modify_mask flags select which parameters to modify vs. leave alone.
920 */
921struct sta_id_modify {
922 u8 addr[ETH_ALEN];
923 __le16 reserved1;
924 u8 sta_id;
925 u8 modify_mask;
926 __le16 reserved2;
927} __packed;
928
929/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200930 * C_ADD_STA = 0x18 (command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800931 *
932 * The device contains an internal table of per-station information,
933 * with info on security keys, aggregation parameters, and Tx rates for
934 * initial Tx attempt and any retries (4965 devices uses
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200935 * C_TX_LINK_QUALITY_CMD,
936 * 3945 uses C_RATE_SCALE to set up rate tables).
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800937 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200938 * C_ADD_STA sets up the table entry for one station, either creating
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800939 * a new entry, or modifying a pre-existing one.
940 *
941 * NOTE: RXON command (without "associated" bit set) wipes the station table
942 * clean. Moving into RF_KILL state does this also. Driver must set up
943 * new station table before transmitting anything on the RXON channel
944 * (except active scans or active measurements; those commands carry
945 * their own txpower/rate setup data).
946 *
947 * When getting started on a new channel, driver must set up the
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200948 * IL_BROADCAST_ID entry (last entry in the table). For a client
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800949 * station in a BSS, once an AP is selected, driver sets up the AP STA
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200950 * in the IL_AP_ID entry (1st entry in the table). BROADCAST and AP
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800951 * are all that are needed for a BSS client station. If the device is
952 * used as AP, or in an IBSS network, driver must set up station table
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100953 * entries for all STAs in network, starting with idx IL_STA_ID.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800954 */
955
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200956struct il3945_addsta_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800957 u8 mode; /* 1: modify existing, 0: add new station */
958 u8 reserved[3];
959 struct sta_id_modify sta;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200960 struct il4965_keyinfo key;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100961 __le32 station_flags; /* STA_FLG_* */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800962 __le32 station_flags_msk; /* STA_FLG_* */
963
964 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
965 * corresponding to bit (e.g. bit 5 controls TID 5).
966 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
967 __le16 tid_disable_tx;
968
969 __le16 rate_n_flags;
970
971 /* TID for which to add block-ack support.
972 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
973 u8 add_immediate_ba_tid;
974
975 /* TID for which to remove block-ack support.
976 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
977 u8 remove_immediate_ba_tid;
978
979 /* Starting Sequence Number for added block-ack support.
980 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
981 __le16 add_immediate_ba_ssn;
982} __packed;
983
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200984struct il4965_addsta_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800985 u8 mode; /* 1: modify existing, 0: add new station */
986 u8 reserved[3];
987 struct sta_id_modify sta;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200988 struct il4965_keyinfo key;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100989 __le32 station_flags; /* STA_FLG_* */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800990 __le32 station_flags_msk; /* STA_FLG_* */
991
992 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
993 * corresponding to bit (e.g. bit 5 controls TID 5).
994 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
995 __le16 tid_disable_tx;
996
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100997 __le16 reserved1;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800998
999 /* TID for which to add block-ack support.
1000 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1001 u8 add_immediate_ba_tid;
1002
1003 /* TID for which to remove block-ack support.
1004 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1005 u8 remove_immediate_ba_tid;
1006
1007 /* Starting Sequence Number for added block-ack support.
1008 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1009 __le16 add_immediate_ba_ssn;
1010
1011 /*
1012 * Number of packets OK to transmit to station even though
1013 * it is asleep -- used to synchronise PS-poll and u-APSD
1014 * responses while ucode keeps track of STA sleep state.
1015 */
1016 __le16 sleep_tx_count;
1017
1018 __le16 reserved2;
1019} __packed;
1020
1021/* Wrapper struct for 3945 and 4965 addsta_cmd structures */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001022struct il_addsta_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001023 u8 mode; /* 1: modify existing, 0: add new station */
1024 u8 reserved[3];
1025 struct sta_id_modify sta;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001026 struct il4965_keyinfo key;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001027 __le32 station_flags; /* STA_FLG_* */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001028 __le32 station_flags_msk; /* STA_FLG_* */
1029
1030 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1031 * corresponding to bit (e.g. bit 5 controls TID 5).
1032 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1033 __le16 tid_disable_tx;
1034
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001035 __le16 rate_n_flags; /* 3945 only */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001036
1037 /* TID for which to add block-ack support.
1038 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1039 u8 add_immediate_ba_tid;
1040
1041 /* TID for which to remove block-ack support.
1042 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1043 u8 remove_immediate_ba_tid;
1044
1045 /* Starting Sequence Number for added block-ack support.
1046 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1047 __le16 add_immediate_ba_ssn;
1048
1049 /*
1050 * Number of packets OK to transmit to station even though
1051 * it is asleep -- used to synchronise PS-poll and u-APSD
1052 * responses while ucode keeps track of STA sleep state.
1053 */
1054 __le16 sleep_tx_count;
1055
1056 __le16 reserved2;
1057} __packed;
1058
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001059#define ADD_STA_SUCCESS_MSK 0x1
Stanislaw Gruszka3b98c7f2011-08-26 16:29:35 +02001060#define ADD_STA_NO_ROOM_IN_TBL 0x2
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001061#define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4
1062#define ADD_STA_MODIFY_NON_EXIST_STA 0x8
1063/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001064 * C_ADD_STA = 0x18 (response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001065 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001066struct il_add_sta_resp {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001067 u8 status; /* ADD_STA_* */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001068} __packed;
1069
1070#define REM_STA_SUCCESS_MSK 0x1
1071/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001072 * C_REM_STA = 0x19 (response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001073 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001074struct il_rem_sta_resp {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001075 u8 status;
1076} __packed;
1077
1078/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001079 * C_REM_STA = 0x19 (command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001080 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001081struct il_rem_sta_cmd {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001082 u8 num_sta; /* number of removed stations */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001083 u8 reserved[3];
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001084 u8 addr[ETH_ALEN]; /* MAC addr of the first station */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001085 u8 reserved2[2];
1086} __packed;
1087
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001088#define IL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0))
1089#define IL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1))
1090#define IL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2))
1091#define IL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3))
1092#define IL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001093
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001094#define IL_DROP_SINGLE 0
1095#define IL_DROP_SELECTED 1
1096#define IL_DROP_ALL 2
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001097
1098/*
1099 * REPLY_WEP_KEY = 0x20
1100 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001101struct il_wep_key {
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01001102 u8 key_idx;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001103 u8 key_offset;
1104 u8 reserved1[2];
1105 u8 key_size;
1106 u8 reserved2[3];
1107 u8 key[16];
1108} __packed;
1109
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001110struct il_wep_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001111 u8 num_keys;
1112 u8 global_key_type;
1113 u8 flags;
1114 u8 reserved;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001115 struct il_wep_key key[0];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001116} __packed;
1117
1118#define WEP_KEY_WEP_TYPE 1
1119#define WEP_KEYS_MAX 4
1120#define WEP_INVALID_OFFSET 0xff
1121#define WEP_KEY_LEN_64 5
1122#define WEP_KEY_LEN_128 13
1123
1124/******************************************************************************
1125 * (4)
1126 * Rx Responses:
1127 *
1128 *****************************************************************************/
1129
1130#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0)
1131#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1)
1132
1133#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0)
1134#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1)
1135#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2)
1136#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3)
Christian Lamparter00bcd0d2013-01-26 22:19:35 +01001137#define RX_RES_PHY_FLAGS_ANTENNA_MSK 0x70
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001138#define RX_RES_PHY_FLAGS_ANTENNA_POS 4
Christian Lamparter0255bed2013-01-18 23:47:19 +01001139#define RX_RES_PHY_FLAGS_AGG_MSK cpu_to_le16(1 << 7)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001140
1141#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
1142#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
1143#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
1144#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
1145#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
1146#define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8)
1147
1148#define RX_RES_STATUS_STATION_FOUND (1<<6)
1149#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7)
1150
1151#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
1152#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
1153#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
1154#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
1155#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
1156
1157#define RX_MPDU_RES_STATUS_ICV_OK (0x20)
1158#define RX_MPDU_RES_STATUS_MIC_OK (0x40)
1159#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7)
1160#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800)
1161
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001162struct il3945_rx_frame_stats {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001163 u8 phy_count;
1164 u8 id;
1165 u8 rssi;
1166 u8 agc;
1167 __le16 sig_avg;
1168 __le16 noise_diff;
1169 u8 payload[0];
1170} __packed;
1171
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001172struct il3945_rx_frame_hdr {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001173 __le16 channel;
1174 __le16 phy_flags;
1175 u8 reserved1;
1176 u8 rate;
1177 __le16 len;
1178 u8 payload[0];
1179} __packed;
1180
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001181struct il3945_rx_frame_end {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001182 __le32 status;
1183 __le64 timestamp;
1184 __le32 beacon_timestamp;
1185} __packed;
1186
1187/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001188 * N_3945_RX = 0x1b (response only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001189 *
1190 * NOTE: DO NOT dereference from casts to this structure
1191 * It is provided only for calculating minimum data set size.
1192 * The actual offsets of the hdr and end are dynamic based on
1193 * stats.phy_count
1194 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001195struct il3945_rx_frame {
1196 struct il3945_rx_frame_stats stats;
1197 struct il3945_rx_frame_hdr hdr;
1198 struct il3945_rx_frame_end end;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001199} __packed;
1200
Stanislaw Gruszkad3175162011-11-15 11:25:42 +01001201#define IL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame))
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001202
1203/* Fixed (non-configurable) rx data from phy */
1204
Stanislaw Gruszkad3175162011-11-15 11:25:42 +01001205#define IL49_RX_RES_PHY_CNT 14
1206#define IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
1207#define IL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
1208#define IL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
1209#define IL49_AGC_DB_POS (7)
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001210struct il4965_rx_non_cfg_phy {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001211 __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
1212 __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
1213 u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
1214 u8 pad[0];
1215} __packed;
1216
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001217/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001218 * N_RX = 0xc3 (response only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001219 * Used only for legacy (non 11n) frames.
1220 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001221struct il_rx_phy_res {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001222 u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001223 u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
1224 u8 stat_id; /* configurable DSP phy data set ID */
1225 u8 reserved1;
1226 __le64 timestamp; /* TSF at on air rise */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001227 __le32 beacon_time_stamp; /* beacon at on-air rise */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001228 __le16 phy_flags; /* general phy flags: band, modulation, ... */
1229 __le16 channel; /* channel number */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001230 u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001231 __le32 rate_n_flags; /* RATE_MCS_* */
1232 __le16 byte_count; /* frame's byte-count */
1233 __le16 frame_time; /* frame's time on the air */
1234} __packed;
1235
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001236struct il_rx_mpdu_res_start {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001237 __le16 byte_count;
1238 __le16 reserved;
1239} __packed;
1240
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001241/******************************************************************************
1242 * (5)
1243 * Tx Commands & Responses:
1244 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001245 * Driver must place each C_TX command into one of the prioritized Tx
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001246 * queues in host DRAM, shared between driver and device (see comments for
1247 * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode
1248 * are preparing to transmit, the device pulls the Tx command over the PCI
1249 * bus via one of the device's Tx DMA channels, to fill an internal FIFO
1250 * from which data will be transmitted.
1251 *
1252 * uCode handles all timing and protocol related to control frames
1253 * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler
1254 * handle reception of block-acks; uCode updates the host driver via
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001255 * N_COMPRESSED_BA.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001256 *
1257 * uCode handles retrying Tx when an ACK is expected but not received.
1258 * This includes trying lower data rates than the one requested in the Tx
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001259 * command, as set up by the C_RATE_SCALE (for 3945) or
1260 * C_TX_LINK_QUALITY_CMD (4965).
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001261 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001262 * Driver sets up transmit power for various rates via C_TX_PWR_TBL.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001263 * This command must be executed after every RXON command, before Tx can occur.
1264 *****************************************************************************/
1265
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001266/* C_TX Tx flags field */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001267
1268/*
1269 * 1: Use Request-To-Send protocol before this frame.
1270 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK.
1271 */
1272#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
1273
1274/*
1275 * 1: Transmit Clear-To-Send to self before this frame.
1276 * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
1277 * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK.
1278 */
1279#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
1280
1281/* 1: Expect ACK from receiving station
1282 * 0: Don't expect ACK (MAC header's duration field s/b 0)
1283 * Set this for unicast frames, but not broadcast/multicast. */
1284#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
1285
1286/* For 4965 devices:
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001287 * 1: Use rate scale table (see C_TX_LINK_QUALITY_CMD).
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01001288 * Tx command's initial_rate_idx indicates first rate to try;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001289 * uCode walks through table for additional Tx attempts.
1290 * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
1291 * This rate will be used for all Tx attempts; it will not be scaled. */
1292#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
1293
1294/* 1: Expect immediate block-ack.
1295 * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */
1296#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6)
1297
1298/*
1299 * 1: Frame requires full Tx-Op protection.
1300 * Set this if either RTS or CTS Tx Flag gets set.
1301 */
1302#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
1303
1304/* Tx antenna selection field; used only for 3945, reserved (0) for 4965 devices.
1305 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
1306#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
1307#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
1308#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
1309
1310/* 1: uCode overrides sequence control field in MAC header.
1311 * 0: Driver provides sequence control field in MAC header.
1312 * Set this for management frames, non-QOS data frames, non-unicast frames,
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001313 * and also in Tx command embedded in C_SCAN for active scans. */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001314#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
1315
1316/* 1: This frame is non-last MPDU; more fragments are coming.
1317 * 0: Last fragment, or not using fragmentation. */
1318#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
1319
1320/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
1321 * 0: No TSF required in outgoing frame.
1322 * Set this for transmitting beacons and probe responses. */
1323#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
1324
1325/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
1326 * alignment of frame's payload data field.
1327 * 0: No pad
1328 * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
1329 * field (but not both). Driver must align frame data (i.e. data following
1330 * MAC header) to DWORD boundary. */
1331#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
1332
1333/* accelerate aggregation support
1334 * 0 - no CCMP encryption; 1 - CCMP encryption */
1335#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
1336
1337/* HCCA-AP - disable duration overwriting. */
1338#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
1339
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001340/*
1341 * TX command security control
1342 */
1343#define TX_CMD_SEC_WEP 0x01
1344#define TX_CMD_SEC_CCM 0x02
1345#define TX_CMD_SEC_TKIP 0x03
1346#define TX_CMD_SEC_MSK 0x03
1347#define TX_CMD_SEC_SHIFT 6
1348#define TX_CMD_SEC_KEY128 0x08
1349
1350/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001351 * C_TX = 0x1c (command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001352 */
1353
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001354struct il3945_tx_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001355 /*
1356 * MPDU byte count:
1357 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1358 * + 8 byte IV for CCM or TKIP (not used for WEP)
1359 * + Data payload
1360 * + 8-byte MIC (not used for CCM/WEP)
1361 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1362 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1363 * Range: 14-2342 bytes.
1364 */
1365 __le16 len;
1366
1367 /*
1368 * MPDU or MSDU byte count for next frame.
1369 * Used for fragmentation and bursting, but not 11n aggregation.
1370 * Same as "len", but for next frame. Set to 0 if not applicable.
1371 */
1372 __le16 next_frame_len;
1373
1374 __le32 tx_flags; /* TX_CMD_FLG_* */
1375
1376 u8 rate;
1377
1378 /* Index of recipient station in uCode's station table */
1379 u8 sta_id;
1380 u8 tid_tspec;
1381 u8 sec_ctl;
1382 u8 key[16];
1383 union {
1384 u8 byte[8];
1385 __le16 word[4];
1386 __le32 dw[2];
1387 } tkip_mic;
1388 __le32 next_frame_info;
1389 union {
1390 __le32 life_time;
1391 __le32 attempt;
1392 } stop_time;
1393 u8 supp_rates[2];
1394 u8 rts_retry_limit; /*byte 50 */
1395 u8 data_retry_limit; /*byte 51 */
1396 union {
1397 __le16 pm_frame_timeout;
1398 __le16 attempt_duration;
1399 } timeout;
1400
1401 /*
1402 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1403 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1404 */
1405 __le16 driver_txop;
1406
1407 /*
1408 * MAC header goes here, followed by 2 bytes padding if MAC header
1409 * length is 26 or 30 bytes, followed by payload data
1410 */
1411 u8 payload[0];
1412 struct ieee80211_hdr hdr[0];
1413} __packed;
1414
1415/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001416 * C_TX = 0x1c (response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001417 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001418struct il3945_tx_resp {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001419 u8 failure_rts;
1420 u8 failure_frame;
1421 u8 bt_kill_count;
1422 u8 rate;
1423 __le32 wireless_media_time;
1424 __le32 status; /* TX status */
1425} __packed;
1426
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001427/*
1428 * 4965 uCode updates these Tx attempt count values in host DRAM.
1429 * Used for managing Tx retries when expecting block-acks.
1430 * Driver should set these fields to 0.
1431 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001432struct il_dram_scratch {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001433 u8 try_cnt; /* Tx attempts */
1434 u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */
1435 __le16 reserved;
1436} __packed;
1437
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001438struct il_tx_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001439 /*
1440 * MPDU byte count:
1441 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1442 * + 8 byte IV for CCM or TKIP (not used for WEP)
1443 * + Data payload
1444 * + 8-byte MIC (not used for CCM/WEP)
1445 * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
1446 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1447 * Range: 14-2342 bytes.
1448 */
1449 __le16 len;
1450
1451 /*
1452 * MPDU or MSDU byte count for next frame.
1453 * Used for fragmentation and bursting, but not 11n aggregation.
1454 * Same as "len", but for next frame. Set to 0 if not applicable.
1455 */
1456 __le16 next_frame_len;
1457
1458 __le32 tx_flags; /* TX_CMD_FLG_* */
1459
1460 /* uCode may modify this field of the Tx command (in host DRAM!).
1461 * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001462 struct il_dram_scratch scratch;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001463
1464 /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
1465 __le32 rate_n_flags; /* RATE_MCS_* */
1466
1467 /* Index of destination station in uCode's station table */
1468 u8 sta_id;
1469
1470 /* Type of security encryption: CCM or TKIP */
1471 u8 sec_ctl; /* TX_CMD_SEC_* */
1472
1473 /*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001474 * Index into rate table (see C_TX_LINK_QUALITY_CMD) for initial
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001475 * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for
1476 * data frames, this field may be used to selectively reduce initial
1477 * rate (via non-0 value) for special frames (e.g. management), while
1478 * still supporting rate scaling for all frames.
1479 */
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01001480 u8 initial_rate_idx;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001481 u8 reserved;
1482 u8 key[16];
1483 __le16 next_frame_flags;
1484 __le16 reserved2;
1485 union {
1486 __le32 life_time;
1487 __le32 attempt;
1488 } stop_time;
1489
1490 /* Host DRAM physical address pointer to "scratch" in this command.
1491 * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */
1492 __le32 dram_lsb_ptr;
1493 u8 dram_msb_ptr;
1494
1495 u8 rts_retry_limit; /*byte 50 */
1496 u8 data_retry_limit; /*byte 51 */
1497 u8 tid_tspec;
1498 union {
1499 __le16 pm_frame_timeout;
1500 __le16 attempt_duration;
1501 } timeout;
1502
1503 /*
1504 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1505 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1506 */
1507 __le16 driver_txop;
1508
1509 /*
1510 * MAC header goes here, followed by 2 bytes padding if MAC header
1511 * length is 26 or 30 bytes, followed by payload data
1512 */
1513 u8 payload[0];
1514 struct ieee80211_hdr hdr[0];
1515} __packed;
1516
1517/* TX command response is sent after *3945* transmission attempts.
1518 *
1519 * NOTES:
1520 *
1521 * TX_STATUS_FAIL_NEXT_FRAG
1522 *
1523 * If the fragment flag in the MAC header for the frame being transmitted
1524 * is set and there is insufficient time to transmit the next frame, the
1525 * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
1526 *
1527 * TX_STATUS_FIFO_UNDERRUN
1528 *
1529 * Indicates the host did not provide bytes to the FIFO fast enough while
1530 * a TX was in progress.
1531 *
1532 * TX_STATUS_FAIL_MGMNT_ABORT
1533 *
1534 * This status is only possible if the ABORT ON MGMT RX parameter was
1535 * set to true with the TX command.
1536 *
1537 * If the MSB of the status parameter is set then an abort sequence is
1538 * required. This sequence consists of the host activating the TX Abort
1539 * control line, and then waiting for the TX Abort command response. This
1540 * indicates that a the device is no longer in a transmit state, and that the
1541 * command FIFO has been cleared. The host must then deactivate the TX Abort
1542 * control line. Receiving is still allowed in this case.
1543 */
1544enum {
1545 TX_3945_STATUS_SUCCESS = 0x01,
1546 TX_3945_STATUS_DIRECT_DONE = 0x02,
1547 TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82,
1548 TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83,
1549 TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1550 TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85,
1551 TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86,
1552 TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1553 TX_3945_STATUS_FAIL_DEST_PS = 0x88,
1554 TX_3945_STATUS_FAIL_ABORTED = 0x89,
1555 TX_3945_STATUS_FAIL_BT_RETRY = 0x8a,
1556 TX_3945_STATUS_FAIL_STA_INVALID = 0x8b,
1557 TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1558 TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d,
1559 TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
1560 TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1561 TX_3945_STATUS_FAIL_TX_LOCKED = 0x90,
1562 TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1563};
1564
1565/*
1566 * TX command response is sent after *4965* transmission attempts.
1567 *
1568 * both postpone and abort status are expected behavior from uCode. there is
1569 * no special operation required from driver; except for RFKILL_FLUSH,
1570 * which required tx flush host command to flush all the tx frames in queues
1571 */
1572enum {
1573 TX_STATUS_SUCCESS = 0x01,
1574 TX_STATUS_DIRECT_DONE = 0x02,
1575 /* postpone TX */
1576 TX_STATUS_POSTPONE_DELAY = 0x40,
1577 TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
1578 TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
1579 TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
1580 /* abort TX */
1581 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
1582 TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
1583 TX_STATUS_FAIL_LONG_LIMIT = 0x83,
1584 TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1585 TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
1586 TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
1587 TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1588 TX_STATUS_FAIL_DEST_PS = 0x88,
1589 TX_STATUS_FAIL_HOST_ABORTED = 0x89,
1590 TX_STATUS_FAIL_BT_RETRY = 0x8a,
1591 TX_STATUS_FAIL_STA_INVALID = 0x8b,
1592 TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1593 TX_STATUS_FAIL_TID_DISABLE = 0x8d,
1594 TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
1595 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1596 TX_STATUS_FAIL_PASSIVE_NO_RX = 0x90,
1597 TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1598};
1599
1600#define TX_PACKET_MODE_REGULAR 0x0000
1601#define TX_PACKET_MODE_BURST_SEQ 0x0100
1602#define TX_PACKET_MODE_BURST_FIRST 0x0200
1603
1604enum {
1605 TX_POWER_PA_NOT_ACTIVE = 0x0,
1606};
1607
1608enum {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001609 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001610 TX_STATUS_DELAY_MSK = 0x00000040,
1611 TX_STATUS_ABORT_MSK = 0x00000080,
1612 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
1613 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001614 TX_RESERVED = 0x00780000, /* bits 19:22 */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001615 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
1616 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
1617};
1618
1619/* *******************************
1620 * TX aggregation status
1621 ******************************* */
1622
1623enum {
1624 AGG_TX_STATE_TRANSMITTED = 0x00,
1625 AGG_TX_STATE_UNDERRUN_MSK = 0x01,
1626 AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1627 AGG_TX_STATE_ABORT_MSK = 0x08,
1628 AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1629 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1630 AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1631 AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1632 AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1633 AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1634 AGG_TX_STATE_DELAY_TX_MSK = 0x400
1635};
1636
1637#define AGG_TX_STATUS_MSK 0x00000fff /* bits 0:11 */
1638#define AGG_TX_TRY_MSK 0x0000f000 /* bits 12:15 */
1639
1640#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
1641 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK)
1642
1643/* # tx attempts for first frame in aggregation */
1644#define AGG_TX_STATE_TRY_CNT_POS 12
1645#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1646
1647/* Command ID and sequence number of Tx command for this frame */
1648#define AGG_TX_STATE_SEQ_NUM_POS 16
1649#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1650
1651/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001652 * C_TX = 0x1c (response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001653 *
1654 * This response may be in one of two slightly different formats, indicated
1655 * by the frame_count field:
1656 *
1657 * 1) No aggregation (frame_count == 1). This reports Tx results for
1658 * a single frame. Multiple attempts, at various bit rates, may have
1659 * been made for this frame.
1660 *
1661 * 2) Aggregation (frame_count > 1). This reports Tx results for
1662 * 2 or more frames that used block-acknowledge. All frames were
1663 * transmitted at same rate. Rate scaling may have been used if first
1664 * frame in this new agg block failed in previous agg block(s).
1665 *
1666 * Note that, for aggregation, ACK (block-ack) status is not delivered here;
1667 * block-ack has not been received by the time the 4965 device records
1668 * this status.
1669 * This status relates to reasons the tx might have been blocked or aborted
1670 * within the sending station (this 4965 device), rather than whether it was
1671 * received successfully by the destination station.
1672 */
1673struct agg_tx_status {
1674 __le16 status;
1675 __le16 sequence;
1676} __packed;
1677
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001678struct il4965_tx_resp {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001679 u8 frame_count; /* 1 no aggregation, >1 aggregation */
1680 u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
1681 u8 failure_rts; /* # failures due to unsuccessful RTS */
1682 u8 failure_frame; /* # failures due to no ACK (unused for agg) */
1683
1684 /* For non-agg: Rate at which frame was successful.
1685 * For agg: Rate at which all frames were transmitted. */
1686 __le32 rate_n_flags; /* RATE_MCS_* */
1687
1688 /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
1689 * For agg: RTS + CTS + aggregation tx time + block-ack time. */
1690 __le16 wireless_media_time; /* uSecs */
1691
1692 __le16 reserved;
1693 __le32 pa_power1; /* RF power amplifier measurement (not used) */
1694 __le32 pa_power2;
1695
1696 /*
1697 * For non-agg: frame status TX_STATUS_*
1698 * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
1699 * fields follow this one, up to frame_count.
1700 * Bit fields:
1701 * 11- 0: AGG_TX_STATE_* status code
1702 * 15-12: Retry count for 1st frame in aggregation (retries
1703 * occur if tx failed for this frame when it was a
1704 * member of a previous aggregation block). If rate
1705 * scaling is used, retry count indicates the rate
1706 * table entry used for all frames in the new agg.
1707 * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
1708 */
1709 union {
1710 __le32 status;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001711 struct agg_tx_status agg_status[0]; /* for each agg frame */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001712 } u;
1713} __packed;
1714
1715/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001716 * N_COMPRESSED_BA = 0xc5 (response only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001717 *
1718 * Reports Block-Acknowledge from recipient station
1719 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001720struct il_compressed_ba_resp {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001721 __le32 sta_addr_lo32;
1722 __le16 sta_addr_hi16;
1723 __le16 reserved;
1724
1725 /* Index of recipient (BA-sending) station in uCode's station table */
1726 u8 sta_id;
1727 u8 tid;
1728 __le16 seq_ctl;
1729 __le64 bitmap;
1730 __le16 scd_flow;
1731 __le16 scd_ssn;
1732} __packed;
1733
1734/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001735 * C_TX_PWR_TBL = 0x97 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001736 *
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +02001737 * See details under "TXPOWER" in 4965.h.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001738 */
1739
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001740struct il3945_txpowertable_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001741 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
1742 u8 reserved;
1743 __le16 channel;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001744 struct il3945_power_per_rate power[IL_MAX_RATES];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001745} __packed;
1746
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001747struct il4965_txpowertable_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001748 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
1749 u8 reserved;
1750 __le16 channel;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001751 struct il4965_tx_power_db tx_power;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001752} __packed;
1753
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001754/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001755 * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001756 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001757 * C_RATE_SCALE = 0x47 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001758 *
1759 * NOTE: The table of rates passed to the uCode via the
1760 * RATE_SCALE command sets up the corresponding order of
1761 * rates used for all related commands, including rate
1762 * masks, etc.
1763 *
1764 * For example, if you set 9MB (PLCP 0x0f) as the first
1765 * rate in the rate table, the bit mask for that rate
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001766 * when passed through ofdm_basic_rates on the C_RXON
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001767 * command would be bit 0 (1 << 0)
1768 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001769struct il3945_rate_scaling_info {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001770 __le16 rate_n_flags;
1771 u8 try_cnt;
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01001772 u8 next_rate_idx;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001773} __packed;
1774
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001775struct il3945_rate_scaling_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001776 u8 table_id;
1777 u8 reserved[3];
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001778 struct il3945_rate_scaling_info table[IL_MAX_RATES];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001779} __packed;
1780
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001781/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
1782#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0)
1783
1784/* # of EDCA prioritized tx fifos */
1785#define LINK_QUAL_AC_NUM AC_NUM
1786
1787/* # entries in rate scale table to support Tx retries */
1788#define LINK_QUAL_MAX_RETRY_NUM 16
1789
1790/* Tx antenna selection values */
1791#define LINK_QUAL_ANT_A_MSK (1 << 0)
1792#define LINK_QUAL_ANT_B_MSK (1 << 1)
1793#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
1794
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001795/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001796 * struct il_link_qual_general_params
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001797 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001798 * Used in C_TX_LINK_QUALITY_CMD
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001799 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001800struct il_link_qual_general_params {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001801 u8 flags;
1802
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01001803 /* No entries at or above this (driver chosen) idx contain MIMO */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001804 u8 mimo_delimiter;
1805
1806 /* Best single antenna to use for single stream (legacy, SISO). */
1807 u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */
1808
1809 /* Best antennas to use for MIMO (unused for 4965, assumes both). */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001810 u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001811
1812 /*
1813 * If driver needs to use different initial rates for different
1814 * EDCA QOS access categories (as implemented by tx fifos 0-3),
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01001815 * this table will set that up, by indicating the idxes in the
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001816 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
1817 * Otherwise, driver should set all entries to 0.
1818 *
1819 * Entry usage:
1820 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
1821 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
1822 */
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01001823 u8 start_rate_idx[LINK_QUAL_AC_NUM];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001824} __packed;
1825
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001826#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001827#define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000)
1828#define LINK_QUAL_AGG_TIME_LIMIT_MIN (100)
1829
1830#define LINK_QUAL_AGG_DISABLE_START_DEF (3)
1831#define LINK_QUAL_AGG_DISABLE_START_MAX (255)
1832#define LINK_QUAL_AGG_DISABLE_START_MIN (0)
1833
1834#define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31)
1835#define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63)
1836#define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0)
1837
1838/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001839 * struct il_link_qual_agg_params
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001840 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001841 * Used in C_TX_LINK_QUALITY_CMD
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001842 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001843struct il_link_qual_agg_params {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001844
1845 /*
1846 *Maximum number of uSec in aggregation.
1847 * default set to 4000 (4 milliseconds) if not configured in .cfg
1848 */
1849 __le16 agg_time_limit;
1850
1851 /*
1852 * Number of Tx retries allowed for a frame, before that frame will
1853 * no longer be considered for the start of an aggregation sequence
1854 * (scheduler will then try to tx it as single frame).
1855 * Driver should set this to 3.
1856 */
1857 u8 agg_dis_start_th;
1858
1859 /*
1860 * Maximum number of frames in aggregation.
1861 * 0 = no limit (default). 1 = no aggregation.
1862 * Other values = max # frames in aggregation.
1863 */
1864 u8 agg_frame_cnt_limit;
1865
1866 __le32 reserved;
1867} __packed;
1868
1869/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001870 * C_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001871 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001872 * For 4965 devices only; 3945 uses C_RATE_SCALE.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001873 *
1874 * Each station in the 4965 device's internal station table has its own table
1875 * of 16
1876 * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
1877 * an ACK is not received. This command replaces the entire table for
1878 * one station.
1879 *
1880 * NOTE: Station must already be in 4965 device's station table.
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02001881 * Use C_ADD_STA.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001882 *
1883 * The rate scaling procedures described below work well. Of course, other
1884 * procedures are possible, and may work better for particular environments.
1885 *
1886 *
Stanislaw Gruszka3b98c7f2011-08-26 16:29:35 +02001887 * FILLING THE RATE TBL
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001888 *
1889 * Given a particular initial rate and mode, as determined by the rate
1890 * scaling algorithm described below, the Linux driver uses the following
1891 * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
1892 * Link Quality command:
1893 *
1894 *
1895 * 1) If using High-throughput (HT) (SISO or MIMO) initial rate:
1896 * a) Use this same initial rate for first 3 entries.
1897 * b) Find next lower available rate using same mode (SISO or MIMO),
1898 * use for next 3 entries. If no lower rate available, switch to
1899 * legacy mode (no HT40 channel, no MIMO, no short guard interval).
1900 * c) If using MIMO, set command's mimo_delimiter to number of entries
1901 * using MIMO (3 or 6).
1902 * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
1903 * no MIMO, no short guard interval), at the next lower bit rate
1904 * (e.g. if second HT bit rate was 54, try 48 legacy), and follow
1905 * legacy procedure for remaining table entries.
1906 *
1907 * 2) If using legacy initial rate:
1908 * a) Use the initial rate for only one entry.
1909 * b) For each following entry, reduce the rate to next lower available
1910 * rate, until reaching the lowest available rate.
1911 * c) When reducing rate, also switch antenna selection.
1912 * d) Once lowest available rate is reached, repeat this rate until
1913 * rate table is filled (16 entries), switching antenna each entry.
1914 *
1915 *
1916 * ACCUMULATING HISTORY
1917 *
1918 * The rate scaling algorithm for 4965 devices, as implemented in Linux driver,
1919 * uses two sets of frame Tx success history: One for the current/active
1920 * modulation mode, and one for a speculative/search mode that is being
1921 * attempted. If the speculative mode turns out to be more effective (i.e.
1922 * actual transfer rate is better), then the driver continues to use the
1923 * speculative mode as the new current active mode.
1924 *
1925 * Each history set contains, separately for each possible rate, data for a
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +02001926 * sliding win of the 62 most recent tx attempts at that rate. The data
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001927 * includes a shifting bitmap of success(1)/failure(0), and sums of successful
1928 * and attempted frames, from which the driver can additionally calculate a
1929 * success ratio (success / attempted) and number of failures
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +02001930 * (attempted - success), and control the size of the win (attempted).
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001931 * The driver uses the bit map to remove successes from the success sum, as
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +02001932 * the oldest tx attempts fall out of the win.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001933 *
1934 * When the 4965 device makes multiple tx attempts for a given frame, each
1935 * attempt might be at a different rate, and have different modulation
1936 * characteristics (e.g. antenna, fat channel, short guard interval), as set
1937 * up in the rate scaling table in the Link Quality command. The driver must
1938 * determine which rate table entry was used for each tx attempt, to determine
1939 * which rate-specific history to update, and record only those attempts that
1940 * match the modulation characteristics of the history set.
1941 *
1942 * When using block-ack (aggregation), all frames are transmitted at the same
1943 * rate, since there is no per-attempt acknowledgment from the destination
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001944 * station. The Tx response struct il_tx_resp indicates the Tx rate in
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001945 * rate_n_flags field. After receiving a block-ack, the driver can update
1946 * history for the entire block all at once.
1947 *
1948 *
1949 * FINDING BEST STARTING RATE:
1950 *
1951 * When working with a selected initial modulation mode (see below), the
1952 * driver attempts to find a best initial rate. The initial rate is the
1953 * first entry in the Link Quality command's rate table.
1954 *
1955 * 1) Calculate actual throughput (success ratio * expected throughput, see
1956 * table below) for current initial rate. Do this only if enough frames
1957 * have been attempted to make the value meaningful: at least 6 failed
1958 * tx attempts, or at least 8 successes. If not enough, don't try rate
1959 * scaling yet.
1960 *
1961 * 2) Find available rates adjacent to current initial rate. Available means:
1962 * a) supported by hardware &&
1963 * b) supported by association &&
1964 * c) within any constraints selected by user
1965 *
1966 * 3) Gather measured throughputs for adjacent rates. These might not have
1967 * enough history to calculate a throughput. That's okay, we might try
1968 * using one of them anyway!
1969 *
1970 * 4) Try decreasing rate if, for current rate:
1971 * a) success ratio is < 15% ||
1972 * b) lower adjacent rate has better measured throughput ||
1973 * c) higher adjacent rate has worse throughput, and lower is unmeasured
1974 *
1975 * As a sanity check, if decrease was determined above, leave rate
1976 * unchanged if:
1977 * a) lower rate unavailable
1978 * b) success ratio at current rate > 85% (very good)
1979 * c) current measured throughput is better than expected throughput
1980 * of lower rate (under perfect 100% tx conditions, see table below)
1981 *
1982 * 5) Try increasing rate if, for current rate:
1983 * a) success ratio is < 15% ||
1984 * b) both adjacent rates' throughputs are unmeasured (try it!) ||
1985 * b) higher adjacent rate has better measured throughput ||
1986 * c) lower adjacent rate has worse throughput, and higher is unmeasured
1987 *
1988 * As a sanity check, if increase was determined above, leave rate
1989 * unchanged if:
1990 * a) success ratio at current rate < 70%. This is not particularly
1991 * good performance; higher rate is sure to have poorer success.
1992 *
1993 * 6) Re-evaluate the rate after each tx frame. If working with block-
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02001994 * acknowledge, history and stats may be calculated for the entire
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +02001995 * block (including prior history that fits within the history wins),
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001996 * before re-evaluation.
1997 *
1998 * FINDING BEST STARTING MODULATION MODE:
1999 *
2000 * After working with a modulation mode for a "while" (and doing rate scaling),
2001 * the driver searches for a new initial mode in an attempt to improve
2002 * throughput. The "while" is measured by numbers of attempted frames:
2003 *
2004 * For legacy mode, search for new mode after:
2005 * 480 successful frames, or 160 failed frames
2006 * For high-throughput modes (SISO or MIMO), search for new mode after:
2007 * 4500 successful frames, or 400 failed frames
2008 *
2009 * Mode switch possibilities are (3 for each mode):
2010 *
2011 * For legacy:
2012 * Change antenna, try SISO (if HT association), try MIMO (if HT association)
2013 * For SISO:
2014 * Change antenna, try MIMO, try shortened guard interval (SGI)
2015 * For MIMO:
2016 * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
2017 *
2018 * When trying a new mode, use the same bit rate as the old/current mode when
2019 * trying antenna switches and shortened guard interval. When switching to
2020 * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
2021 * for which the expected throughput (under perfect conditions) is about the
2022 * same or slightly better than the actual measured throughput delivered by
2023 * the old/current mode.
2024 *
2025 * Actual throughput can be estimated by multiplying the expected throughput
2026 * by the success ratio (successful / attempted tx frames). Frame size is
2027 * not considered in this calculation; it assumes that frame size will average
2028 * out to be fairly consistent over several samples. The following are
2029 * metric values for expected throughput assuming 100% success ratio.
2030 * Only G band has support for CCK rates:
2031 *
2032 * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60
2033 *
2034 * G: 7 13 35 58 40 57 72 98 121 154 177 186 186
2035 * A: 0 0 0 0 40 57 72 98 121 154 177 186 186
2036 * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202
2037 * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211
2038 * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251
2039 * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257
2040 * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257
2041 * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264
2042 * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289
2043 * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293
2044 *
2045 * After the new mode has been tried for a short while (minimum of 6 failed
2046 * frames or 8 successful frames), compare success ratio and actual throughput
2047 * estimate of the new mode with the old. If either is better with the new
2048 * mode, continue to use the new mode.
2049 *
2050 * Continue comparing modes until all 3 possibilities have been tried.
2051 * If moving from legacy to HT, try all 3 possibilities from the new HT
2052 * mode. After trying all 3, a best mode is found. Continue to use this mode
2053 * for the longer "while" described above (e.g. 480 successful frames for
2054 * legacy), and then repeat the search process.
2055 *
2056 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002057struct il_link_quality_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002058
2059 /* Index of destination/recipient station in uCode's station table */
2060 u8 sta_id;
2061 u8 reserved1;
2062 __le16 control; /* not used */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002063 struct il_link_qual_general_params general_params;
2064 struct il_link_qual_agg_params agg_params;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002065
2066 /*
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01002067 * Rate info; when using rate-scaling, Tx command's initial_rate_idx
2068 * specifies 1st Tx rate attempted, via idx into this table.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002069 * 4965 devices works its way through table when retrying Tx.
2070 */
2071 struct {
Stanislaw Gruszka2eb05812011-08-26 16:07:43 +02002072 __le32 rate_n_flags; /* RATE_MCS_*, RATE_* */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002073 } rs_table[LINK_QUAL_MAX_RETRY_NUM];
2074 __le32 reserved2;
2075} __packed;
2076
2077/*
2078 * BT configuration enable flags:
2079 * bit 0 - 1: BT channel announcement enabled
2080 * 0: disable
2081 * bit 1 - 1: priority of BT device enabled
2082 * 0: disable
2083 */
2084#define BT_COEX_DISABLE (0x0)
2085#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0)
2086#define BT_ENABLE_PRIORITY BIT(1)
2087
2088#define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY)
2089
2090#define BT_LEAD_TIME_DEF (0x1E)
2091
2092#define BT_MAX_KILL_DEF (0x5)
2093
2094/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002095 * C_BT_CONFIG = 0x9b (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002096 *
2097 * 3945 and 4965 devices support hardware handshake with Bluetooth device on
2098 * same platform. Bluetooth device alerts wireless device when it will Tx;
2099 * wireless device can delay or kill its own Tx to accommodate.
2100 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002101struct il_bt_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002102 u8 flags;
2103 u8 lead_time;
2104 u8 max_kill;
2105 u8 reserved;
2106 __le32 kill_ack_mask;
2107 __le32 kill_cts_mask;
2108} __packed;
2109
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002110/******************************************************************************
2111 * (6)
2112 * Spectrum Management (802.11h) Commands, Responses, Notifications:
2113 *
2114 *****************************************************************************/
2115
2116/*
2117 * Spectrum Management
2118 */
2119#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
2120 RXON_FILTER_CTL2HOST_MSK | \
2121 RXON_FILTER_ACCEPT_GRP_MSK | \
2122 RXON_FILTER_DIS_DECRYPT_MSK | \
2123 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
2124 RXON_FILTER_ASSOC_MSK | \
2125 RXON_FILTER_BCON_AWARE_MSK)
2126
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002127struct il_measure_channel {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002128 __le32 duration; /* measurement duration in extended beacon
2129 * format */
2130 u8 channel; /* channel to measure */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002131 u8 type; /* see enum il_measure_type */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002132 __le16 reserved;
2133} __packed;
2134
2135/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002136 * C_SPECTRUM_MEASUREMENT = 0x74 (command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002137 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002138struct il_spectrum_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002139 __le16 len; /* number of bytes starting from token */
2140 u8 token; /* token id */
2141 u8 id; /* measurement id -- 0 or 1 */
2142 u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
2143 u8 periodic; /* 1 = periodic */
2144 __le16 path_loss_timeout;
2145 __le32 start_time; /* start time in extended beacon format */
2146 __le32 reserved2;
2147 __le32 flags; /* rxon flags */
2148 __le32 filter_flags; /* rxon filter flags */
2149 __le16 channel_count; /* minimum 1, maximum 10 */
2150 __le16 reserved3;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002151 struct il_measure_channel channels[10];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002152} __packed;
2153
2154/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002155 * C_SPECTRUM_MEASUREMENT = 0x74 (response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002156 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002157struct il_spectrum_resp {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002158 u8 token;
2159 u8 id; /* id of the prior command replaced, or 0xff */
2160 __le16 status; /* 0 - command will be handled
2161 * 1 - cannot handle (conflicts with another
2162 * measurement) */
2163} __packed;
2164
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002165enum il_measurement_state {
2166 IL_MEASUREMENT_START = 0,
2167 IL_MEASUREMENT_STOP = 1,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002168};
2169
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002170enum il_measurement_status {
2171 IL_MEASUREMENT_OK = 0,
2172 IL_MEASUREMENT_CONCURRENT = 1,
2173 IL_MEASUREMENT_CSA_CONFLICT = 2,
2174 IL_MEASUREMENT_TGH_CONFLICT = 3,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002175 /* 4-5 reserved */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002176 IL_MEASUREMENT_STOPPED = 6,
2177 IL_MEASUREMENT_TIMEOUT = 7,
2178 IL_MEASUREMENT_PERIODIC_FAILED = 8,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002179};
2180
2181#define NUM_ELEMENTS_IN_HISTOGRAM 8
2182
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002183struct il_measurement_histogram {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002184 __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
2185 __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
2186} __packed;
2187
2188/* clear channel availability counters */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002189struct il_measurement_cca_counters {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002190 __le32 ofdm;
2191 __le32 cck;
2192} __packed;
2193
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002194enum il_measure_type {
2195 IL_MEASURE_BASIC = (1 << 0),
2196 IL_MEASURE_CHANNEL_LOAD = (1 << 1),
2197 IL_MEASURE_HISTOGRAM_RPI = (1 << 2),
2198 IL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
2199 IL_MEASURE_FRAME = (1 << 4),
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002200 /* bits 5:6 are reserved */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002201 IL_MEASURE_IDLE = (1 << 7),
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002202};
2203
2204/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002205 * N_SPECTRUM_MEASUREMENT = 0x75 (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002206 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002207struct il_spectrum_notification {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002208 u8 id; /* measurement id -- 0 or 1 */
2209 u8 token;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002210 u8 channel_idx; /* idx in measurement channel list */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002211 u8 state; /* 0 - start, 1 - stop */
2212 __le32 start_time; /* lower 32-bits of TSF */
2213 u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
2214 u8 channel;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002215 u8 type; /* see enum il_measurement_type */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002216 u8 reserved1;
2217 /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
2218 * valid if applicable for measurement type requested. */
2219 __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
2220 __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
2221 __le32 cca_time; /* channel load time in usecs */
2222 u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
2223 * unidentified */
2224 u8 reserved2[3];
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002225 struct il_measurement_histogram histogram;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002226 __le32 stop_time; /* lower 32-bits of TSF */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002227 __le32 status; /* see il_measurement_status */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002228} __packed;
2229
2230/******************************************************************************
2231 * (7)
2232 * Power Management Commands, Responses, Notifications:
2233 *
2234 *****************************************************************************/
2235
2236/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002237 * struct il_powertable_cmd - Power Table Command
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002238 * @flags: See below:
2239 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002240 * C_POWER_TBL = 0x77 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002241 *
2242 * PM allow:
2243 * bit 0 - '0' Driver not allow power management
2244 * '1' Driver allow PM (use rest of parameters)
2245 *
2246 * uCode send sleep notifications:
2247 * bit 1 - '0' Don't send sleep notification
2248 * '1' send sleep notification (SEND_PM_NOTIFICATION)
2249 *
2250 * Sleep over DTIM
2251 * bit 2 - '0' PM have to walk up every DTIM
2252 * '1' PM could sleep over DTIM till listen Interval.
2253 *
2254 * PCI power managed
2255 * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
2256 * '1' !(PCI_CFG_LINK_CTRL & 0x1)
2257 *
2258 * Fast PD
2259 * bit 4 - '1' Put radio to sleep when receiving frame for others
2260 *
2261 * Force sleep Modes
2262 * bit 31/30- '00' use both mac/xtal sleeps
2263 * '01' force Mac sleep
2264 * '10' force xtal sleep
2265 * '11' Illegal set
2266 *
Stanislaw Gruszka3b98c7f2011-08-26 16:29:35 +02002267 * NOTE: if sleep_interval[SLEEP_INTRVL_TBL_SIZE-1] > DTIM period then
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002268 * ucode assume sleep over DTIM is allowed and we don't need to wake up
2269 * for every DTIM.
2270 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002271#define IL_POWER_VEC_SIZE 5
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002272
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002273#define IL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0))
2274#define IL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3))
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002275
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002276struct il3945_powertable_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002277 __le16 flags;
2278 u8 reserved[2];
2279 __le32 rx_data_timeout;
2280 __le32 tx_data_timeout;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002281 __le32 sleep_interval[IL_POWER_VEC_SIZE];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002282} __packed;
2283
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002284struct il_powertable_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002285 __le16 flags;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002286 u8 keep_alive_seconds; /* 3945 reserved */
2287 u8 debug_flags; /* 3945 reserved */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002288 __le32 rx_data_timeout;
2289 __le32 tx_data_timeout;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002290 __le32 sleep_interval[IL_POWER_VEC_SIZE];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002291 __le32 keep_alive_beacons;
2292} __packed;
2293
2294/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002295 * N_PM_SLEEP = 0x7A (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002296 * all devices identical.
2297 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002298struct il_sleep_notification {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002299 u8 pm_sleep_mode;
2300 u8 pm_wakeup_src;
2301 __le16 reserved;
2302 __le32 sleep_time;
2303 __le32 tsf_low;
2304 __le32 bcon_timer;
2305} __packed;
2306
2307/* Sleep states. all devices identical. */
2308enum {
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002309 IL_PM_NO_SLEEP = 0,
2310 IL_PM_SLP_MAC = 1,
2311 IL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
2312 IL_PM_SLP_FULL_MAC_CARD_STATE = 3,
2313 IL_PM_SLP_PHY = 4,
2314 IL_PM_SLP_REPENT = 5,
2315 IL_PM_WAKEUP_BY_TIMER = 6,
2316 IL_PM_WAKEUP_BY_DRIVER = 7,
2317 IL_PM_WAKEUP_BY_RFKILL = 8,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002318 /* 3 reserved */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002319 IL_PM_NUM_OF_MODES = 12,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002320};
2321
2322/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002323 * N_CARD_STATE = 0xa1 (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002324 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002325struct il_card_state_notif {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002326 __le32 flags;
2327} __packed;
2328
2329#define HW_CARD_DISABLED 0x01
2330#define SW_CARD_DISABLED 0x02
2331#define CT_CARD_DISABLED 0x04
2332#define RXON_CARD_DISABLED 0x10
2333
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002334struct il_ct_kill_config {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002335 __le32 reserved;
2336 __le32 critical_temperature_M;
2337 __le32 critical_temperature_R;
2338} __packed;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002339
2340/******************************************************************************
2341 * (8)
2342 * Scan Commands, Responses, Notifications:
2343 *
2344 *****************************************************************************/
2345
2346#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
2347#define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1)
2348
2349/**
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002350 * struct il_scan_channel - entry in C_SCAN channel table
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002351 *
2352 * One for each channel in the scan list.
2353 * Each channel can independently select:
2354 * 1) SSID for directed active scans
2355 * 2) Txpower setting (for rate specified within Tx command)
2356 * 3) How long to stay on-channel (behavior may be modified by quiet_time,
2357 * quiet_plcp_th, good_CRC_th)
2358 *
2359 * To avoid uCode errors, make sure the following are true (see comments
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002360 * under struct il_scan_cmd about max_out_time and quiet_time):
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002361 * 1) If using passive_dwell (i.e. passive_dwell != 0):
2362 * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
2363 * 2) quiet_time <= active_dwell
2364 * 3) If restricting off-channel time (i.e. max_out_time !=0):
2365 * passive_dwell < max_out_time
2366 * active_dwell < max_out_time
2367 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002368struct il3945_scan_channel {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002369 /*
2370 * type is defined as:
2371 * 0:0 1 = active, 0 = passive
2372 * 1:4 SSID direct bit map; if a bit is set, then corresponding
2373 * SSID IE is transmitted in probe request.
2374 * 5:7 reserved
2375 */
2376 u8 type;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002377 u8 channel; /* band is selected by il3945_scan_cmd "flags" field */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002378 struct il3945_tx_power tpc;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002379 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2380 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
2381} __packed;
2382
2383/* set number of direct probes u8 type */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +01002384#define IL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1))))
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002385
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002386struct il_scan_channel {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002387 /*
2388 * type is defined as:
2389 * 0:0 1 = active, 0 = passive
2390 * 1:20 SSID direct bit map; if a bit is set, then corresponding
2391 * SSID IE is transmitted in probe request.
2392 * 21:31 reserved
2393 */
2394 __le32 type;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002395 __le16 channel; /* band is selected by il_scan_cmd "flags" field */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002396 u8 tx_gain; /* gain for analog radio */
2397 u8 dsp_atten; /* gain for DSP */
2398 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
2399 __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
2400} __packed;
2401
2402/* set number of direct probes __le32 type */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002403#define IL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002404
2405/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002406 * struct il_ssid_ie - directed scan network information element
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002407 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002408 * Up to 20 of these may appear in C_SCAN (Note: Only 4 are in
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002409 * 3945 SCAN api), selected by "type" bit field in struct il_scan_channel;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002410 * each channel may select different ssids from among the 20 (4) entries.
2411 * SSID IEs get transmitted in reverse order of entry.
2412 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002413struct il_ssid_ie {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002414 u8 id;
2415 u8 len;
2416 u8 ssid[32];
2417} __packed;
2418
2419#define PROBE_OPTION_MAX_3945 4
2420#define PROBE_OPTION_MAX 20
2421#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002422#define IL_GOOD_CRC_TH_DISABLED 0
2423#define IL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
2424#define IL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
2425#define IL_MAX_SCAN_SIZE 1024
2426#define IL_MAX_CMD_SIZE 4096
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002427
2428/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002429 * C_SCAN = 0x80 (command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002430 *
2431 * The hardware scan command is very powerful; the driver can set it up to
2432 * maintain (relatively) normal network traffic while doing a scan in the
2433 * background. The max_out_time and suspend_time control the ratio of how
2434 * long the device stays on an associated network channel ("service channel")
2435 * vs. how long it's away from the service channel, i.e. tuned to other channels
2436 * for scanning.
2437 *
2438 * max_out_time is the max time off-channel (in usec), and suspend_time
2439 * is how long (in "extended beacon" format) that the scan is "suspended"
2440 * after returning to the service channel. That is, suspend_time is the
2441 * time that we stay on the service channel, doing normal work, between
2442 * scan segments. The driver may set these parameters differently to support
2443 * scanning when associated vs. not associated, and light vs. heavy traffic
2444 * loads when associated.
2445 *
2446 * After receiving this command, the device's scan engine does the following;
2447 *
2448 * 1) Sends SCAN_START notification to driver
2449 * 2) Checks to see if it has time to do scan for one channel
2450 * 3) Sends NULL packet, with power-save (PS) bit set to 1,
2451 * to tell AP that we're going off-channel
2452 * 4) Tunes to first channel in scan list, does active or passive scan
2453 * 5) Sends SCAN_RESULT notification to driver
2454 * 6) Checks to see if it has time to do scan on *next* channel in list
2455 * 7) Repeats 4-6 until it no longer has time to scan the next channel
2456 * before max_out_time expires
2457 * 8) Returns to service channel
2458 * 9) Sends NULL packet with PS=0 to tell AP that we're back
2459 * 10) Stays on service channel until suspend_time expires
2460 * 11) Repeats entire process 2-10 until list is complete
2461 * 12) Sends SCAN_COMPLETE notification
2462 *
2463 * For fast, efficient scans, the scan command also has support for staying on
2464 * a channel for just a short time, if doing active scanning and getting no
2465 * responses to the transmitted probe request. This time is controlled by
2466 * quiet_time, and the number of received packets below which a channel is
2467 * considered "quiet" is controlled by quiet_plcp_threshold.
2468 *
2469 * For active scanning on channels that have regulatory restrictions against
2470 * blindly transmitting, the scan can listen before transmitting, to make sure
2471 * that there is already legitimate activity on the channel. If enough
2472 * packets are cleanly received on the channel (controlled by good_CRC_th,
2473 * typical value 1), the scan engine starts transmitting probe requests.
2474 *
2475 * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
2476 *
2477 * To avoid uCode errors, see timing restrictions described under
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002478 * struct il_scan_channel.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002479 */
2480
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002481struct il3945_scan_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002482 __le16 len;
2483 u8 reserved0;
2484 u8 channel_count; /* # channels in channel list */
2485 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2486 * (only for active scan) */
2487 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2488 __le16 good_CRC_th; /* passive -> active promotion threshold */
2489 __le16 reserved1;
2490 __le32 max_out_time; /* max usec to be away from associated (service)
2491 * channel */
2492 __le32 suspend_time; /* pause scan this long (in "extended beacon
2493 * format") when returning to service channel:
2494 * 3945; 31:24 # beacons, 19:0 additional usec,
2495 * 4965; 31:22 # beacons, 21:0 additional usec.
2496 */
2497 __le32 flags; /* RXON_FLG_* */
2498 __le32 filter_flags; /* RXON_FILTER_* */
2499
2500 /* For active scans (set to all-0s for passive scans).
2501 * Does not include payload. Must specify Tx rate; no rate scaling. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002502 struct il3945_tx_cmd tx_cmd;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002503
2504 /* For directed active scans (set to all-0s otherwise) */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002505 struct il_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002506
2507 /*
2508 * Probe request frame, followed by channel list.
2509 *
2510 * Size of probe request frame is specified by byte count in tx_cmd.
2511 * Channel list follows immediately after probe request frame.
2512 * Number of channels in list is specified by channel_count.
2513 * Each channel in list is of type:
2514 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002515 * struct il3945_scan_channel channels[0];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002516 *
2517 * NOTE: Only one band of channels can be scanned per pass. You
2518 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002519 * for one scan to complete (i.e. receive N_SCAN_COMPLETE)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002520 * before requesting another scan.
2521 */
2522 u8 data[0];
2523} __packed;
2524
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002525struct il_scan_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002526 __le16 len;
2527 u8 reserved0;
2528 u8 channel_count; /* # channels in channel list */
2529 __le16 quiet_time; /* dwell only this # millisecs on quiet channel
2530 * (only for active scan) */
2531 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
2532 __le16 good_CRC_th; /* passive -> active promotion threshold */
2533 __le16 rx_chain; /* RXON_RX_CHAIN_* */
2534 __le32 max_out_time; /* max usec to be away from associated (service)
2535 * channel */
2536 __le32 suspend_time; /* pause scan this long (in "extended beacon
2537 * format") when returning to service chnl:
2538 * 3945; 31:24 # beacons, 19:0 additional usec,
2539 * 4965; 31:22 # beacons, 21:0 additional usec.
2540 */
2541 __le32 flags; /* RXON_FLG_* */
2542 __le32 filter_flags; /* RXON_FILTER_* */
2543
2544 /* For active scans (set to all-0s for passive scans).
2545 * Does not include payload. Must specify Tx rate; no rate scaling. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002546 struct il_tx_cmd tx_cmd;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002547
2548 /* For directed active scans (set to all-0s otherwise) */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002549 struct il_ssid_ie direct_scan[PROBE_OPTION_MAX];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002550
2551 /*
2552 * Probe request frame, followed by channel list.
2553 *
2554 * Size of probe request frame is specified by byte count in tx_cmd.
2555 * Channel list follows immediately after probe request frame.
2556 * Number of channels in list is specified by channel_count.
2557 * Each channel in list is of type:
2558 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002559 * struct il_scan_channel channels[0];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002560 *
2561 * NOTE: Only one band of channels can be scanned per pass. You
2562 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002563 * for one scan to complete (i.e. receive N_SCAN_COMPLETE)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002564 * before requesting another scan.
2565 */
2566 u8 data[0];
2567} __packed;
2568
2569/* Can abort will notify by complete notification with abort status. */
2570#define CAN_ABORT_STATUS cpu_to_le32(0x1)
2571/* complete notification statuses */
2572#define ABORT_STATUS 0x2
2573
2574/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002575 * C_SCAN = 0x80 (response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002576 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002577struct il_scanreq_notification {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002578 __le32 status; /* 1: okay, 2: cannot fulfill request */
2579} __packed;
2580
2581/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002582 * N_SCAN_START = 0x82 (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002583 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002584struct il_scanstart_notification {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002585 __le32 tsf_low;
2586 __le32 tsf_high;
2587 __le32 beacon_timer;
2588 u8 channel;
2589 u8 band;
2590 u8 reserved[2];
2591 __le32 status;
2592} __packed;
2593
Phil Carmody497888c2011-07-14 15:07:13 +03002594#define SCAN_OWNER_STATUS 0x1
2595#define MEASURE_OWNER_STATUS 0x2
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002596
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002597#define IL_PROBE_STATUS_OK 0
2598#define IL_PROBE_STATUS_TX_FAILED BIT(0)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002599/* error statuses combined with TX_FAILED */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002600#define IL_PROBE_STATUS_FAIL_TTL BIT(1)
2601#define IL_PROBE_STATUS_FAIL_BT BIT(2)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002602
Stanislaw Gruszkadb7746f2011-11-15 13:11:50 +01002603#define NUMBER_OF_STATS 1 /* first __le32 is good CRC */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002604/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002605 * N_SCAN_RESULTS = 0x83 (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002606 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002607struct il_scanresults_notification {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002608 u8 channel;
2609 u8 band;
2610 u8 probe_status;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002611 u8 num_probe_not_sent; /* not enough time to send */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002612 __le32 tsf_low;
2613 __le32 tsf_high;
Stanislaw Gruszkadb7746f2011-11-15 13:11:50 +01002614 __le32 stats[NUMBER_OF_STATS];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002615} __packed;
2616
2617/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002618 * N_SCAN_COMPLETE = 0x84 (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002619 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002620struct il_scancomplete_notification {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002621 u8 scanned_channels;
2622 u8 status;
2623 u8 last_channel;
2624 __le32 tsf_low;
2625 __le32 tsf_high;
2626} __packed;
2627
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002628/******************************************************************************
2629 * (9)
2630 * IBSS/AP Commands and Notifications:
2631 *
2632 *****************************************************************************/
2633
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002634enum il_ibss_manager {
2635 IL_NOT_IBSS_MANAGER = 0,
2636 IL_IBSS_MANAGER = 1,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002637};
2638
2639/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002640 * N_BEACON = 0x90 (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002641 */
2642
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002643struct il3945_beacon_notif {
2644 struct il3945_tx_resp beacon_notify_hdr;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002645 __le32 low_tsf;
2646 __le32 high_tsf;
2647 __le32 ibss_mgr_status;
2648} __packed;
2649
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002650struct il4965_beacon_notif {
2651 struct il4965_tx_resp beacon_notify_hdr;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002652 __le32 low_tsf;
2653 __le32 high_tsf;
2654 __le32 ibss_mgr_status;
2655} __packed;
2656
2657/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002658 * C_TX_BEACON= 0x91 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002659 */
2660
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002661struct il3945_tx_beacon_cmd {
2662 struct il3945_tx_cmd tx;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002663 __le16 tim_idx;
2664 u8 tim_size;
2665 u8 reserved1;
2666 struct ieee80211_hdr frame[0]; /* beacon frame */
2667} __packed;
2668
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002669struct il_tx_beacon_cmd {
2670 struct il_tx_cmd tx;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002671 __le16 tim_idx;
2672 u8 tim_size;
2673 u8 reserved1;
2674 struct ieee80211_hdr frame[0]; /* beacon frame */
2675} __packed;
2676
2677/******************************************************************************
2678 * (10)
2679 * Statistics Commands and Notifications:
2680 *
2681 *****************************************************************************/
2682
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002683#define IL_TEMP_CONVERT 260
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002684
2685#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
2686#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
2687#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
2688
2689/* Used for passing to driver number of successes and failures per rate */
2690struct rate_histogram {
2691 union {
2692 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
2693 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
2694 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
2695 } success;
2696 union {
2697 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
2698 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
2699 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
2700 } failed;
2701} __packed;
2702
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002703/* stats command response */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002704
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002705struct iwl39_stats_rx_phy {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002706 __le32 ina_cnt;
2707 __le32 fina_cnt;
2708 __le32 plcp_err;
2709 __le32 crc32_err;
2710 __le32 overrun_err;
2711 __le32 early_overrun_err;
2712 __le32 crc32_good;
2713 __le32 false_alarm_cnt;
2714 __le32 fina_sync_err_cnt;
2715 __le32 sfd_timeout;
2716 __le32 fina_timeout;
2717 __le32 unresponded_rts;
2718 __le32 rxe_frame_limit_overrun;
2719 __le32 sent_ack_cnt;
2720 __le32 sent_cts_cnt;
2721} __packed;
2722
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002723struct iwl39_stats_rx_non_phy {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002724 __le32 bogus_cts; /* CTS received when not expecting CTS */
2725 __le32 bogus_ack; /* ACK received when not expecting ACK */
2726 __le32 non_bssid_frames; /* number of frames with BSSID that
2727 * doesn't belong to the STA BSSID */
2728 __le32 filtered_frames; /* count frames that were dumped in the
2729 * filtering process */
2730 __le32 non_channel_beacons; /* beacons with our bss id but not on
2731 * our serving channel */
2732} __packed;
2733
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002734struct iwl39_stats_rx {
2735 struct iwl39_stats_rx_phy ofdm;
2736 struct iwl39_stats_rx_phy cck;
2737 struct iwl39_stats_rx_non_phy general;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002738} __packed;
2739
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002740struct iwl39_stats_tx {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002741 __le32 preamble_cnt;
2742 __le32 rx_detected_cnt;
2743 __le32 bt_prio_defer_cnt;
2744 __le32 bt_prio_kill_cnt;
2745 __le32 few_bytes_cnt;
2746 __le32 cts_timeout;
2747 __le32 ack_timeout;
2748 __le32 expected_ack_cnt;
2749 __le32 actual_ack_cnt;
2750} __packed;
2751
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002752struct stats_dbg {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002753 __le32 burst_check;
2754 __le32 burst_count;
2755 __le32 wait_for_silence_timeout_cnt;
2756 __le32 reserved[3];
2757} __packed;
2758
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002759struct iwl39_stats_div {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002760 __le32 tx_on_a;
2761 __le32 tx_on_b;
2762 __le32 exec_time;
2763 __le32 probe_time;
2764} __packed;
2765
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002766struct iwl39_stats_general {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002767 __le32 temperature;
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002768 struct stats_dbg dbg;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002769 __le32 sleep_time;
2770 __le32 slots_out;
2771 __le32 slots_idle;
2772 __le32 ttl_timestamp;
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002773 struct iwl39_stats_div div;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002774} __packed;
2775
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002776struct stats_rx_phy {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002777 __le32 ina_cnt;
2778 __le32 fina_cnt;
2779 __le32 plcp_err;
2780 __le32 crc32_err;
2781 __le32 overrun_err;
2782 __le32 early_overrun_err;
2783 __le32 crc32_good;
2784 __le32 false_alarm_cnt;
2785 __le32 fina_sync_err_cnt;
2786 __le32 sfd_timeout;
2787 __le32 fina_timeout;
2788 __le32 unresponded_rts;
2789 __le32 rxe_frame_limit_overrun;
2790 __le32 sent_ack_cnt;
2791 __le32 sent_cts_cnt;
2792 __le32 sent_ba_rsp_cnt;
2793 __le32 dsp_self_kill;
2794 __le32 mh_format_err;
2795 __le32 re_acq_main_rssi_sum;
2796 __le32 reserved3;
2797} __packed;
2798
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002799struct stats_rx_ht_phy {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002800 __le32 plcp_err;
2801 __le32 overrun_err;
2802 __le32 early_overrun_err;
2803 __le32 crc32_good;
2804 __le32 crc32_err;
2805 __le32 mh_format_err;
2806 __le32 agg_crc32_good;
2807 __le32 agg_mpdu_cnt;
2808 __le32 agg_cnt;
2809 __le32 unsupport_mcs;
2810} __packed;
2811
2812#define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1)
2813
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002814struct stats_rx_non_phy {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002815 __le32 bogus_cts; /* CTS received when not expecting CTS */
2816 __le32 bogus_ack; /* ACK received when not expecting ACK */
2817 __le32 non_bssid_frames; /* number of frames with BSSID that
2818 * doesn't belong to the STA BSSID */
2819 __le32 filtered_frames; /* count frames that were dumped in the
2820 * filtering process */
2821 __le32 non_channel_beacons; /* beacons with our bss id but not on
2822 * our serving channel */
2823 __le32 channel_beacons; /* beacons with our bss id and in our
2824 * serving channel */
2825 __le32 num_missed_bcon; /* number of missed beacons */
2826 __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
2827 * ADC was in saturation */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002828 __le32 ina_detection_search_time; /* total time (in 0.8us) searched
2829 * for INA */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002830 __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
2831 __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
2832 __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
2833 __le32 interference_data_flag; /* flag for interference data
2834 * availability. 1 when data is
2835 * available. */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002836 __le32 channel_load; /* counts RX Enable time in uSec */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002837 __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
2838 * and CCK) counter */
2839 __le32 beacon_rssi_a;
2840 __le32 beacon_rssi_b;
2841 __le32 beacon_rssi_c;
2842 __le32 beacon_energy_a;
2843 __le32 beacon_energy_b;
2844 __le32 beacon_energy_c;
2845} __packed;
2846
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002847struct stats_rx {
2848 struct stats_rx_phy ofdm;
2849 struct stats_rx_phy cck;
2850 struct stats_rx_non_phy general;
2851 struct stats_rx_ht_phy ofdm_ht;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002852} __packed;
2853
2854/**
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002855 * struct stats_tx_power - current tx power
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002856 *
2857 * @ant_a: current tx power on chain a in 1/2 dB step
2858 * @ant_b: current tx power on chain b in 1/2 dB step
2859 * @ant_c: current tx power on chain c in 1/2 dB step
2860 */
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002861struct stats_tx_power {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002862 u8 ant_a;
2863 u8 ant_b;
2864 u8 ant_c;
2865 u8 reserved;
2866} __packed;
2867
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002868struct stats_tx_non_phy_agg {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002869 __le32 ba_timeout;
2870 __le32 ba_reschedule_frames;
2871 __le32 scd_query_agg_frame_cnt;
2872 __le32 scd_query_no_agg;
2873 __le32 scd_query_agg;
2874 __le32 scd_query_mismatch;
2875 __le32 frame_not_ready;
2876 __le32 underrun;
2877 __le32 bt_prio_kill;
2878 __le32 rx_ba_rsp_cnt;
2879} __packed;
2880
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002881struct stats_tx {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002882 __le32 preamble_cnt;
2883 __le32 rx_detected_cnt;
2884 __le32 bt_prio_defer_cnt;
2885 __le32 bt_prio_kill_cnt;
2886 __le32 few_bytes_cnt;
2887 __le32 cts_timeout;
2888 __le32 ack_timeout;
2889 __le32 expected_ack_cnt;
2890 __le32 actual_ack_cnt;
2891 __le32 dump_msdu_cnt;
2892 __le32 burst_abort_next_frame_mismatch_cnt;
2893 __le32 burst_abort_missing_next_frame_cnt;
2894 __le32 cts_timeout_collision;
2895 __le32 ack_or_ba_timeout_collision;
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002896 struct stats_tx_non_phy_agg agg;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002897
2898 __le32 reserved1;
2899} __packed;
2900
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002901struct stats_div {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002902 __le32 tx_on_a;
2903 __le32 tx_on_b;
2904 __le32 exec_time;
2905 __le32 probe_time;
2906 __le32 reserved1;
2907 __le32 reserved2;
2908} __packed;
2909
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002910struct stats_general_common {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002911 __le32 temperature; /* radio temperature */
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002912 struct stats_dbg dbg;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002913 __le32 sleep_time;
2914 __le32 slots_out;
2915 __le32 slots_idle;
2916 __le32 ttl_timestamp;
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002917 struct stats_div div;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002918 __le32 rx_enable_counter;
2919 /*
2920 * num_of_sos_states:
2921 * count the number of times we have to re-tune
2922 * in order to get out of bad PHY status
2923 */
2924 __le32 num_of_sos_states;
2925} __packed;
2926
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002927struct stats_general {
2928 struct stats_general_common common;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002929 __le32 reserved2;
2930 __le32 reserved3;
2931} __packed;
2932
Stanislaw Gruszkadb7746f2011-11-15 13:11:50 +01002933#define UCODE_STATS_CLEAR_MSK (0x1 << 0)
2934#define UCODE_STATS_FREQUENCY_MSK (0x1 << 1)
2935#define UCODE_STATS_NARROW_BAND_MSK (0x1 << 2)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002936
2937/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002938 * C_STATS = 0x9c,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002939 * all devices identical.
2940 *
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002941 * This command triggers an immediate response containing uCode stats.
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002942 * The response is in the same format as N_STATS 0x9d, below.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002943 *
2944 * If the CLEAR_STATS configuration flag is set, uCode will clear its
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002945 * internal copy of the stats (counters) after issuing the response.
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002946 * This flag does not affect N_STATSs after beacons (see below).
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002947 *
2948 * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002949 * N_STATSs after received beacons (see below). This flag
2950 * does not affect the response to the C_STATS 0x9c itself.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002951 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002952#define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002953#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2) /* see above */
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002954struct il_stats_cmd {
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002955 __le32 configuration_flags; /* IL_STATS_CONF_* */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002956} __packed;
2957
2958/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002959 * N_STATS = 0x9d (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002960 *
2961 * By default, uCode issues this notification after receiving a beacon
2962 * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002963 * C_STATS 0x9c, above.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002964 *
2965 * Statistics counters continue to increment beacon after beacon, but are
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002966 * cleared when changing channels or when driver issues C_STATS
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002967 * 0x9c with CLEAR_STATS bit set (see above).
2968 *
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002969 * uCode also issues this notification during scans. uCode clears stats
2970 * appropriately so that each notification contains stats for only the
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002971 * one channel that has just been scanned.
2972 */
Stanislaw Gruszkadb7746f2011-11-15 13:11:50 +01002973#define STATS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2)
2974#define STATS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002975
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002976struct il3945_notif_stats {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002977 __le32 flag;
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002978 struct iwl39_stats_rx rx;
2979 struct iwl39_stats_tx tx;
2980 struct iwl39_stats_general general;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002981} __packed;
2982
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002983struct il_notif_stats {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002984 __le32 flag;
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02002985 struct stats_rx rx;
2986 struct stats_tx tx;
2987 struct stats_general general;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002988} __packed;
2989
2990/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002991 * N_MISSED_BEACONS = 0xa2 (notification only, not a command)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002992 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02002993 * uCode send N_MISSED_BEACONS to driver when detect beacon missed
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002994 * in regardless of how many missed beacons, which mean when driver receive the
2995 * notification, inside the command, it can find all the beacons information
2996 * which include number of total missed beacons, number of consecutive missed
2997 * beacons, number of beacons received and number of beacons expected to
2998 * receive.
2999 *
3000 * If uCode detected consecutive_missed_beacons > 5, it will reset the radio
3001 * in order to bring the radio/PHY back to working state; which has no relation
3002 * to when driver will perform sensitivity calibration.
3003 *
3004 * Driver should set it own missed_beacon_threshold to decide when to perform
3005 * sensitivity calibration based on number of consecutive missed beacons in
3006 * order to improve overall performance, especially in noisy environment.
3007 *
3008 */
3009
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003010#define IL_MISSED_BEACON_THRESHOLD_MIN (1)
3011#define IL_MISSED_BEACON_THRESHOLD_DEF (5)
3012#define IL_MISSED_BEACON_THRESHOLD_MAX IL_MISSED_BEACON_THRESHOLD_DEF
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003013
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003014struct il_missed_beacon_notif {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003015 __le32 consecutive_missed_beacons;
3016 __le32 total_missed_becons;
3017 __le32 num_expected_beacons;
3018 __le32 num_recvd_beacons;
3019} __packed;
3020
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003021/******************************************************************************
3022 * (11)
3023 * Rx Calibration Commands:
3024 *
3025 * With the uCode used for open source drivers, most Tx calibration (except
3026 * for Tx Power) and most Rx calibration is done by uCode during the
3027 * "initialize" phase of uCode boot. Driver must calibrate only:
3028 *
3029 * 1) Tx power (depends on temperature), described elsewhere
3030 * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
3031 * 3) Receiver sensitivity (to optimize signal detection)
3032 *
3033 *****************************************************************************/
3034
3035/**
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02003036 * C_SENSITIVITY = 0xa8 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003037 *
3038 * This command sets up the Rx signal detector for a sensitivity level that
3039 * is high enough to lock onto all signals within the associated network,
3040 * but low enough to ignore signals that are below a certain threshold, so as
3041 * not to have too many "false alarms". False alarms are signals that the
3042 * Rx DSP tries to lock onto, but then discards after determining that they
3043 * are noise.
3044 *
3045 * The optimum number of false alarms is between 5 and 50 per 200 TUs
3046 * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
3047 * time listening, not transmitting). Driver must adjust sensitivity so that
3048 * the ratio of actual false alarms to actual Rx time falls within this range.
3049 *
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02003050 * While associated, uCode delivers N_STATSs after each
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003051 * received beacon. These provide information to the driver to analyze the
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02003052 * sensitivity. Don't analyze stats that come in from scanning, or any
3053 * other non-associated-network source. Pertinent stats include:
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003054 *
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02003055 * From "general" stats (struct stats_rx_non_phy):
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003056 *
3057 * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
3058 * Measure of energy of desired signal. Used for establishing a level
3059 * below which the device does not detect signals.
3060 *
3061 * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
3062 * Measure of background noise in silent period after beacon.
3063 *
3064 * channel_load
3065 * uSecs of actual Rx time during beacon period (varies according to
3066 * how much time was spent transmitting).
3067 *
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02003068 * From "cck" and "ofdm" stats (struct stats_rx_phy), separately:
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003069 *
3070 * false_alarm_cnt
3071 * Signal locks abandoned early (before phy-level header).
3072 *
3073 * plcp_err
3074 * Signal locks abandoned late (during phy-level header).
3075 *
3076 * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
3077 * beacon to beacon, i.e. each value is an accumulation of all errors
3078 * before and including the latest beacon. Values will wrap around to 0
3079 * after counting up to 2^32 - 1. Driver must differentiate vs.
3080 * previous beacon's values to determine # false alarms in the current
3081 * beacon period.
3082 *
3083 * Total number of false alarms = false_alarms + plcp_errs
3084 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003085 * For OFDM, adjust the following table entries in struct il_sensitivity_cmd
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003086 * (notice that the start points for OFDM are at or close to settings for
3087 * maximum sensitivity):
3088 *
3089 * START / MIN / MAX
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003090 * HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX 90 / 85 / 120
3091 * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX 170 / 170 / 210
3092 * HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX 105 / 105 / 140
3093 * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX 220 / 220 / 270
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003094 *
3095 * If actual rate of OFDM false alarms (+ plcp_errors) is too high
3096 * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
3097 * by *adding* 1 to all 4 of the table entries above, up to the max for
3098 * each entry. Conversely, if false alarm rate is too low (less than 5
3099 * for each 204.8 msecs listening), *subtract* 1 from each entry to
3100 * increase sensitivity.
3101 *
3102 * For CCK sensitivity, keep track of the following:
3103 *
3104 * 1). 20-beacon history of maximum background noise, indicated by
3105 * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
3106 * 3 receivers. For any given beacon, the "silence reference" is
3107 * the maximum of last 60 samples (20 beacons * 3 receivers).
3108 *
3109 * 2). 10-beacon history of strongest signal level, as indicated
3110 * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
3111 * i.e. the strength of the signal through the best receiver at the
3112 * moment. These measurements are "upside down", with lower values
3113 * for stronger signals, so max energy will be *minimum* value.
3114 *
3115 * Then for any given beacon, the driver must determine the *weakest*
3116 * of the strongest signals; this is the minimum level that needs to be
3117 * successfully detected, when using the best receiver at the moment.
3118 * "Max cck energy" is the maximum (higher value means lower energy!)
3119 * of the last 10 minima. Once this is determined, driver must add
3120 * a little margin by adding "6" to it.
3121 *
3122 * 3). Number of consecutive beacon periods with too few false alarms.
3123 * Reset this to 0 at the first beacon period that falls within the
3124 * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
3125 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003126 * Then, adjust the following CCK table entries in struct il_sensitivity_cmd
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003127 * (notice that the start points for CCK are at maximum sensitivity):
3128 *
3129 * START / MIN / MAX
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003130 * HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX 125 / 125 / 200
3131 * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX 200 / 200 / 400
3132 * HD_MIN_ENERGY_CCK_DET_IDX 100 / 0 / 100
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003133 *
3134 * If actual rate of CCK false alarms (+ plcp_errors) is too high
3135 * (greater than 50 for each 204.8 msecs listening), method for reducing
3136 * sensitivity is:
3137 *
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003138 * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003139 * up to max 400.
3140 *
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003141 * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is < 160,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003142 * sensitivity has been reduced a significant amount; bring it up to
3143 * a moderate 161. Otherwise, *add* 3, up to max 200.
3144 *
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003145 * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is > 160,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003146 * sensitivity has been reduced only a moderate or small amount;
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003147 * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_IDX,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003148 * down to min 0. Otherwise (if gain has been significantly reduced),
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003149 * don't change the HD_MIN_ENERGY_CCK_DET_IDX value.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003150 *
3151 * b) Save a snapshot of the "silence reference".
3152 *
3153 * If actual rate of CCK false alarms (+ plcp_errors) is too low
3154 * (less than 5 for each 204.8 msecs listening), method for increasing
3155 * sensitivity is used only if:
3156 *
3157 * 1a) Previous beacon did not have too many false alarms
3158 * 1b) AND difference between previous "silence reference" and current
3159 * "silence reference" (prev - current) is 2 or more,
3160 * OR 2) 100 or more consecutive beacon periods have had rate of
3161 * less than 5 false alarms per 204.8 milliseconds rx time.
3162 *
3163 * Method for increasing sensitivity:
3164 *
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003165 * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003166 * down to min 125.
3167 *
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003168 * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003169 * down to min 200.
3170 *
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003171 * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_IDX, up to max 100.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003172 *
3173 * If actual rate of CCK false alarms (+ plcp_errors) is within good range
3174 * (between 5 and 50 for each 204.8 msecs listening):
3175 *
3176 * 1) Save a snapshot of the silence reference.
3177 *
3178 * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
3179 * give some extra margin to energy threshold by *subtracting* 8
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003180 * from value in HD_MIN_ENERGY_CCK_DET_IDX.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003181 *
3182 * For all cases (too few, too many, good range), make sure that the CCK
3183 * detection threshold (energy) is below the energy level for robust
3184 * detection over the past 10 beacon periods, the "Max cck energy".
3185 * Lower values mean higher energy; this means making sure that the value
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003186 * in HD_MIN_ENERGY_CCK_DET_IDX is at or *above* "Max cck energy".
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003187 *
3188 */
3189
3190/*
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02003191 * Table entries in C_SENSITIVITY (struct il_sensitivity_cmd)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003192 */
Stanislaw Gruszka3b98c7f2011-08-26 16:29:35 +02003193#define HD_TBL_SIZE (11) /* number of entries */
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01003194#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */
Stanislaw Gruszka2d09b062011-08-26 16:10:40 +02003195#define HD_MIN_ENERGY_OFDM_DET_IDX (1)
3196#define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2)
3197#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3)
3198#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX (4)
3199#define HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX (5)
3200#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX (6)
3201#define HD_BARKER_CORR_TH_ADD_MIN_IDX (7)
3202#define HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX (8)
3203#define HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX (9)
3204#define HD_OFDM_ENERGY_TH_IN_IDX (10)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003205
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003206/* Control field in struct il_sensitivity_cmd */
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02003207#define C_SENSITIVITY_CONTROL_DEFAULT_TBL cpu_to_le16(0)
3208#define C_SENSITIVITY_CONTROL_WORK_TBL cpu_to_le16(1)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003209
3210/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003211 * struct il_sensitivity_cmd
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003212 * @control: (1) updates working table, (0) updates default table
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +01003213 * @table: energy threshold values, use HD_* as idx into table
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003214 *
3215 * Always use "1" in "control" to update uCode's working table and DSP.
3216 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003217struct il_sensitivity_cmd {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003218 __le16 control; /* always use "1" */
Stanislaw Gruszka3b98c7f2011-08-26 16:29:35 +02003219 __le16 table[HD_TBL_SIZE]; /* use HD_* as idx */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003220} __packed;
3221
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003222/**
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02003223 * C_PHY_CALIBRATION = 0xb0 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003224 *
3225 * This command sets the relative gains of 4965 device's 3 radio receiver chains.
3226 *
3227 * After the first association, driver should accumulate signal and noise
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02003228 * stats from the N_STATSs that follow the first 20
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02003229 * beacons from the associated network (don't collect stats that come
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003230 * in from scanning, or any other non-network source).
3231 *
3232 * DISCONNECTED ANTENNA:
3233 *
3234 * Driver should determine which antennas are actually connected, by comparing
3235 * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
3236 * following values over 20 beacons, one accumulator for each of the chains
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02003237 * a/b/c, from struct stats_rx_non_phy:
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003238 *
3239 * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
3240 *
3241 * Find the strongest signal from among a/b/c. Compare the other two to the
3242 * strongest. If any signal is more than 15 dB (times 20, unless you
3243 * divide the accumulated values by 20) below the strongest, the driver
3244 * considers that antenna to be disconnected, and should not try to use that
3245 * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
3246 * driver should declare the stronger one as connected, and attempt to use it
3247 * (A and B are the only 2 Tx chains!).
3248 *
3249 *
3250 * RX BALANCE:
3251 *
3252 * Driver should balance the 3 receivers (but just the ones that are connected
3253 * to antennas, see above) for gain, by comparing the average signal levels
3254 * detected during the silence after each beacon (background noise).
3255 * Accumulate (add) the following values over 20 beacons, one accumulator for
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02003256 * each of the chains a/b/c, from struct stats_rx_non_phy:
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003257 *
3258 * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
3259 *
3260 * Find the weakest background noise level from among a/b/c. This Rx chain
3261 * will be the reference, with 0 gain adjustment. Attenuate other channels by
3262 * finding noise difference:
3263 *
3264 * (accum_noise[i] - accum_noise[reference]) / 30
3265 *
3266 * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003267 * For use in diff_gain_[abc] fields of struct il_calibration_cmd, the
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003268 * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
3269 * and set bit 2 to indicate "reduce gain". The value for the reference
3270 * (weakest) chain should be "0".
3271 *
3272 * diff_gain_[abc] bit fields:
3273 * 2: (1) reduce gain, (0) increase gain
3274 * 1-0: amount of gain, units of 1.5 dB
3275 */
3276
3277/* Phy calibration command for series */
3278/* The default calibrate table size if not specified by firmware */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003279#define IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003280enum {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003281 IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7,
3282 IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19,
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003283};
3284
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003285#define IL_MAX_PHY_CALIBRATE_TBL_SIZE (253)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003286
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003287struct il_calib_hdr {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003288 u8 op_code;
3289 u8 first_group;
3290 u8 groups_num;
3291 u8 data_valid;
3292} __packed;
3293
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003294/* IL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
3295struct il_calib_diff_gain_cmd {
3296 struct il_calib_hdr hdr;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003297 s8 diff_gain_a; /* see above */
3298 s8 diff_gain_b;
3299 s8 diff_gain_c;
3300 u8 reserved1;
3301} __packed;
3302
3303/******************************************************************************
3304 * (12)
3305 * Miscellaneous Commands:
3306 *
3307 *****************************************************************************/
3308
3309/*
3310 * LEDs Command & Response
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +02003311 * C_LEDS = 0x48 (command, has simple generic response)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003312 *
3313 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
3314 * this command turns it on or off, or sets up a periodic blinking cycle.
3315 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003316struct il_led_cmd {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003317 __le32 interval; /* "interval" in uSec */
3318 u8 id; /* 1: Activity, 2: Link, 3: Tech */
3319 u8 off; /* # intervals off while blinking;
3320 * "0", with >0 "on" value, turns LED on */
3321 u8 on; /* # intervals on while blinking;
3322 * "0", regardless of "off", turns LED off */
3323 u8 reserved;
3324} __packed;
3325
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003326/******************************************************************************
3327 * (13)
3328 * Union of all expected notifications/responses:
3329 *
3330 *****************************************************************************/
3331
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02003332#define IL_RX_FRAME_SIZE_MSK 0x00003fff
3333
Stanislaw Gruszkadcae1c62011-08-26 14:36:21 +02003334struct il_rx_pkt {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003335 /*
3336 * The first 4 bytes of the RX frame header contain both the RX frame
3337 * size and some flags.
3338 * Bit fields:
3339 * 31: flag flush RB request
3340 * 30: flag ignore TC (terminal counter) request
3341 * 29: flag fast IRQ request
3342 * 28-14: Reserved
3343 * 13-00: RX frame size
3344 */
3345 __le32 len_n_flags;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003346 struct il_cmd_header hdr;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003347 union {
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003348 struct il3945_rx_frame rx_frame;
3349 struct il3945_tx_resp tx_resp;
3350 struct il3945_beacon_notif beacon_status;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003351
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003352 struct il_alive_resp alive_frame;
3353 struct il_spectrum_notification spectrum_notif;
3354 struct il_csa_notification csa_notif;
3355 struct il_error_resp err_resp;
3356 struct il_card_state_notif card_state_notif;
3357 struct il_add_sta_resp add_sta;
3358 struct il_rem_sta_resp rem_sta;
3359 struct il_sleep_notification sleep_notif;
3360 struct il_spectrum_resp spectrum;
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +02003361 struct il_notif_stats stats;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003362 struct il_compressed_ba_resp compressed_ba;
3363 struct il_missed_beacon_notif missed_beacon;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08003364 __le32 status;
3365 u8 raw[0];
3366 } u;
3367} __packed;
3368
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003369#endif /* __il_commands_h__ */