blob: bde3aa018bba1ca7ded081836880b4b76bbaf5bb [file] [log] [blame]
Zhu Yib481de92007-09-25 17:54:57 -07001/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
Ian Schram01ebd062007-10-25 17:15:22 +080011 * it under the terms of version 2 of the GNU General Public License as
Zhu Yib481de92007-09-25 17:54:57 -070012 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * James P. Ketrenos <ipw2100-admin@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 - 2007 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 *****************************************************************************/
Ben Cahillfcd427b2007-11-29 11:10:00 +080063/*
64 * Please use this file (iwl-4965-commands.h) only for uCode API definitions.
65 * Please use iwl-4965-hw.h for hardware-related definitions.
66 * Please use iwl-4965.h for driver implementation definitions.
67 */
Zhu Yib481de92007-09-25 17:54:57 -070068
Christoph Hellwigbb8c0932008-01-27 16:41:47 -080069#ifndef __iwl4965_commands_h__
70#define __iwl4965_commands_h__
Zhu Yib481de92007-09-25 17:54:57 -070071
72enum {
73 REPLY_ALIVE = 0x1,
74 REPLY_ERROR = 0x2,
75
76 /* RXON and QOS commands */
77 REPLY_RXON = 0x10,
78 REPLY_RXON_ASSOC = 0x11,
79 REPLY_QOS_PARAM = 0x13,
80 REPLY_RXON_TIMING = 0x14,
81
82 /* Multi-Station support */
83 REPLY_ADD_STA = 0x18,
84 REPLY_REMOVE_STA = 0x19, /* not used */
85 REPLY_REMOVE_ALL_STA = 0x1a, /* not used */
86
87 /* RX, TX, LEDs */
Zhu Yib481de92007-09-25 17:54:57 -070088 REPLY_TX = 0x1c,
89 REPLY_RATE_SCALE = 0x47, /* 3945 only */
90 REPLY_LEDS_CMD = 0x48,
91 REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* 4965 only */
92
93 /* 802.11h related */
94 RADAR_NOTIFICATION = 0x70, /* not used */
95 REPLY_QUIET_CMD = 0x71, /* not used */
96 REPLY_CHANNEL_SWITCH = 0x72,
97 CHANNEL_SWITCH_NOTIFICATION = 0x73,
98 REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
99 SPECTRUM_MEASURE_NOTIFICATION = 0x75,
100
101 /* Power Management */
102 POWER_TABLE_CMD = 0x77,
103 PM_SLEEP_NOTIFICATION = 0x7A,
104 PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
105
106 /* Scan commands and notifications */
107 REPLY_SCAN_CMD = 0x80,
108 REPLY_SCAN_ABORT_CMD = 0x81,
109 SCAN_START_NOTIFICATION = 0x82,
110 SCAN_RESULTS_NOTIFICATION = 0x83,
111 SCAN_COMPLETE_NOTIFICATION = 0x84,
112
113 /* IBSS/AP commands */
114 BEACON_NOTIFICATION = 0x90,
115 REPLY_TX_BEACON = 0x91,
116 WHO_IS_AWAKE_NOTIFICATION = 0x94, /* not used */
117
118 /* Miscellaneous commands */
119 QUIET_NOTIFICATION = 0x96, /* not used */
120 REPLY_TX_PWR_TABLE_CMD = 0x97,
121 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
122
Ben Cahill075416c2007-11-29 11:10:08 +0800123 /* Bluetooth device coexistance config command */
Zhu Yib481de92007-09-25 17:54:57 -0700124 REPLY_BT_CONFIG = 0x9b,
125
126 /* 4965 Statistics */
127 REPLY_STATISTICS_CMD = 0x9c,
128 STATISTICS_NOTIFICATION = 0x9d,
129
130 /* RF-KILL commands and notifications */
131 REPLY_CARD_STATE_CMD = 0xa0,
132 CARD_STATE_NOTIFICATION = 0xa1,
133
134 /* Missed beacons notification */
135 MISSED_BEACONS_NOTIFICATION = 0xa2,
136
Zhu Yib481de92007-09-25 17:54:57 -0700137 REPLY_CT_KILL_CONFIG_CMD = 0xa4,
138 SENSITIVITY_CMD = 0xa8,
139 REPLY_PHY_CALIBRATION_CMD = 0xb0,
140 REPLY_RX_PHY_CMD = 0xc0,
141 REPLY_RX_MPDU_CMD = 0xc1,
142 REPLY_4965_RX = 0xc3,
143 REPLY_COMPRESSED_BA = 0xc5,
Zhu Yib481de92007-09-25 17:54:57 -0700144 REPLY_MAX = 0xff
145};
146
147/******************************************************************************
148 * (0)
Ben Cahillabceddb2007-11-29 11:09:50 +0800149 * Commonly used structures and definitions:
150 * Command header, rate_n_flags
Zhu Yib481de92007-09-25 17:54:57 -0700151 *
152 *****************************************************************************/
153
Ben Cahill075416c2007-11-29 11:10:08 +0800154/* iwl4965_cmd_header flags value */
Zhu Yib481de92007-09-25 17:54:57 -0700155#define IWL_CMD_FAILED_MSK 0x40
156
Ben Cahill075416c2007-11-29 11:10:08 +0800157/**
158 * struct iwl4965_cmd_header
159 *
160 * This header format appears in the beginning of each command sent from the
161 * driver, and each response/notification received from uCode.
162 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800163struct iwl4965_cmd_header {
Ben Cahill075416c2007-11-29 11:10:08 +0800164 u8 cmd; /* Command ID: REPLY_RXON, etc. */
165 u8 flags; /* IWL_CMD_* */
166 /*
167 * The driver sets up the sequence number to values of its chosing.
168 * uCode does not use this value, but passes it back to the driver
169 * when sending the response to each driver-originated command, so
170 * the driver can match the response to the command. Since the values
171 * don't get used by uCode, the driver may set up an arbitrary format.
Zhu Yib481de92007-09-25 17:54:57 -0700172 *
Ben Cahill075416c2007-11-29 11:10:08 +0800173 * There is one exception: uCode sets bit 15 when it originates
174 * the response/notification, i.e. when the response/notification
175 * is not a direct response to a command sent by the driver. For
176 * example, uCode issues REPLY_3945_RX when it sends a received frame
177 * to the driver; it is not a direct response to any driver command.
Zhu Yib481de92007-09-25 17:54:57 -0700178 *
Ben Cahill075416c2007-11-29 11:10:08 +0800179 * The Linux driver uses the following format:
180 *
181 * 0:7 index/position within Tx queue
182 * 8:13 Tx queue selection
183 * 14:14 driver sets this to indicate command is in the 'huge'
184 * storage at the end of the command buffers, i.e. scan cmd
185 * 15:15 uCode sets this in uCode-originated response/notification
Zhu Yib481de92007-09-25 17:54:57 -0700186 */
187 __le16 sequence;
188
Ben Cahill075416c2007-11-29 11:10:08 +0800189 /* command or response/notification data follows immediately */
Zhu Yib481de92007-09-25 17:54:57 -0700190 u8 data[0];
191} __attribute__ ((packed));
192
Ben Cahillabceddb2007-11-29 11:09:50 +0800193/**
194 * 4965 rate_n_flags bit fields
195 *
196 * rate_n_flags format is used in following 4965 commands:
197 * REPLY_4965_RX (response only)
198 * REPLY_TX (both command and response)
199 * REPLY_TX_LINK_QUALITY_CMD
200 *
201 * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
202 * 2-0: 0) 6 Mbps
203 * 1) 12 Mbps
204 * 2) 18 Mbps
205 * 3) 24 Mbps
206 * 4) 36 Mbps
207 * 5) 48 Mbps
208 * 6) 54 Mbps
209 * 7) 60 Mbps
210 *
211 * 3: 0) Single stream (SISO)
212 * 1) Dual stream (MIMO)
213 *
214 * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps FAT duplicate data
215 *
216 * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
217 * 3-0: 0xD) 6 Mbps
218 * 0xF) 9 Mbps
219 * 0x5) 12 Mbps
220 * 0x7) 18 Mbps
221 * 0x9) 24 Mbps
222 * 0xB) 36 Mbps
223 * 0x1) 48 Mbps
224 * 0x3) 54 Mbps
225 *
226 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
227 * 3-0: 10) 1 Mbps
228 * 20) 2 Mbps
229 * 55) 5.5 Mbps
230 * 110) 11 Mbps
231 */
232#define RATE_MCS_CODE_MSK 0x7
233#define RATE_MCS_MIMO_POS 3
234#define RATE_MCS_MIMO_MSK 0x8
235#define RATE_MCS_HT_DUP_POS 5
236#define RATE_MCS_HT_DUP_MSK 0x20
237
Ben Cahill075416c2007-11-29 11:10:08 +0800238/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
Ben Cahillabceddb2007-11-29 11:09:50 +0800239#define RATE_MCS_FLAGS_POS 8
240#define RATE_MCS_HT_POS 8
241#define RATE_MCS_HT_MSK 0x100
242
Ben Cahill075416c2007-11-29 11:10:08 +0800243/* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */
Ben Cahillabceddb2007-11-29 11:09:50 +0800244#define RATE_MCS_CCK_POS 9
245#define RATE_MCS_CCK_MSK 0x200
246
Ben Cahill075416c2007-11-29 11:10:08 +0800247/* Bit 10: (1) Use Green Field preamble */
Ben Cahillabceddb2007-11-29 11:09:50 +0800248#define RATE_MCS_GF_POS 10
249#define RATE_MCS_GF_MSK 0x400
250
Ben Cahill075416c2007-11-29 11:10:08 +0800251/* Bit 11: (1) Use 40Mhz FAT chnl width, (0) use 20 MHz legacy chnl width */
Ben Cahillabceddb2007-11-29 11:09:50 +0800252#define RATE_MCS_FAT_POS 11
253#define RATE_MCS_FAT_MSK 0x800
254
Ben Cahill075416c2007-11-29 11:10:08 +0800255/* Bit 12: (1) Duplicate data on both 20MHz chnls. FAT (bit 11) must be set. */
Ben Cahillabceddb2007-11-29 11:09:50 +0800256#define RATE_MCS_DUP_POS 12
257#define RATE_MCS_DUP_MSK 0x1000
258
Ben Cahill075416c2007-11-29 11:10:08 +0800259/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
Ben Cahillabceddb2007-11-29 11:09:50 +0800260#define RATE_MCS_SGI_POS 13
261#define RATE_MCS_SGI_MSK 0x2000
262
263/**
264 * rate_n_flags Tx antenna masks (4965 has 2 transmitters):
265 * bit14:15 01 B inactive, A active
266 * 10 B active, A inactive
267 * 11 Both active
268 */
269#define RATE_MCS_ANT_A_POS 14
270#define RATE_MCS_ANT_B_POS 15
271#define RATE_MCS_ANT_A_MSK 0x4000
272#define RATE_MCS_ANT_B_MSK 0x8000
273#define RATE_MCS_ANT_AB_MSK 0xc000
274
275
Zhu Yib481de92007-09-25 17:54:57 -0700276/******************************************************************************
277 * (0a)
278 * Alive and Error Commands & Responses:
279 *
280 *****************************************************************************/
281
282#define UCODE_VALID_OK __constant_cpu_to_le32(0x1)
283#define INITIALIZE_SUBTYPE (9)
284
285/*
Ben Cahill075416c2007-11-29 11:10:08 +0800286 * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command)
287 *
288 * uCode issues this "initialize alive" notification once the initialization
289 * uCode image has completed its work, and is ready to load the runtime image.
290 * This is the *first* "alive" notification that the driver will receive after
291 * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
292 *
293 * See comments documenting "BSM" (bootstrap state machine).
294 *
295 * For 4965, this notification contains important calibration data for
296 * calculating txpower settings:
297 *
298 * 1) Power supply voltage indication. The voltage sensor outputs higher
299 * values for lower voltage, and vice versa.
300 *
301 * 2) Temperature measurement parameters, for each of two channel widths
302 * (20 MHz and 40 MHz) supported by the radios. Temperature sensing
303 * is done via one of the receiver chains, and channel width influences
304 * the results.
305 *
306 * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation,
307 * for each of 5 frequency ranges.
Zhu Yib481de92007-09-25 17:54:57 -0700308 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800309struct iwl4965_init_alive_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700310 u8 ucode_minor;
311 u8 ucode_major;
312 __le16 reserved1;
313 u8 sw_rev[8];
314 u8 ver_type;
Ben Cahill075416c2007-11-29 11:10:08 +0800315 u8 ver_subtype; /* "9" for initialize alive */
Zhu Yib481de92007-09-25 17:54:57 -0700316 __le16 reserved2;
317 __le32 log_event_table_ptr;
318 __le32 error_event_table_ptr;
319 __le32 timestamp;
320 __le32 is_valid;
321
Zhu Yib481de92007-09-25 17:54:57 -0700322 /* calibration values from "initialize" uCode */
Ben Cahill075416c2007-11-29 11:10:08 +0800323 __le32 voltage; /* signed, higher value is lower voltage */
324 __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for FAT channel*/
Zhu Yib481de92007-09-25 17:54:57 -0700325 __le32 therm_r2[2]; /* signed */
326 __le32 therm_r3[2]; /* signed */
327 __le32 therm_r4[2]; /* signed */
328 __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups,
329 * 2 Tx chains */
Zhu Yib481de92007-09-25 17:54:57 -0700330} __attribute__ ((packed));
331
Ben Cahill075416c2007-11-29 11:10:08 +0800332
333/**
334 * REPLY_ALIVE = 0x1 (response only, not a command)
335 *
336 * uCode issues this "alive" notification once the runtime image is ready
337 * to receive commands from the driver. This is the *second* "alive"
338 * notification that the driver will receive after rebooting uCode;
339 * this "alive" is indicated by subtype field != 9.
340 *
341 * See comments documenting "BSM" (bootstrap state machine).
342 *
343 * This response includes two pointers to structures within the device's
344 * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
345 *
346 * 1) log_event_table_ptr indicates base of the event log. This traces
347 * a 256-entry history of uCode execution within a circular buffer.
348 * Its header format is:
349 *
350 * __le32 log_size; log capacity (in number of entries)
351 * __le32 type; (1) timestamp with each entry, (0) no timestamp
352 * __le32 wraps; # times uCode has wrapped to top of circular buffer
353 * __le32 write_index; next circular buffer entry that uCode would fill
354 *
355 * The header is followed by the circular buffer of log entries. Entries
356 * with timestamps have the following format:
357 *
358 * __le32 event_id; range 0 - 1500
359 * __le32 timestamp; low 32 bits of TSF (of network, if associated)
360 * __le32 data; event_id-specific data value
361 *
362 * Entries without timestamps contain only event_id and data.
363 *
364 * 2) error_event_table_ptr indicates base of the error log. This contains
365 * information about any uCode error that occurs. For 4965, the format
366 * of the error log is:
367 *
368 * __le32 valid; (nonzero) valid, (0) log is empty
369 * __le32 error_id; type of error
370 * __le32 pc; program counter
371 * __le32 blink1; branch link
372 * __le32 blink2; branch link
373 * __le32 ilink1; interrupt link
374 * __le32 ilink2; interrupt link
375 * __le32 data1; error-specific data
376 * __le32 data2; error-specific data
377 * __le32 line; source code line of error
378 * __le32 bcon_time; beacon timer
379 * __le32 tsf_low; network timestamp function timer
380 * __le32 tsf_hi; network timestamp function timer
381 *
382 * The Linux driver can print both logs to the system log when a uCode error
383 * occurs.
384 */
385struct iwl4965_alive_resp {
386 u8 ucode_minor;
387 u8 ucode_major;
388 __le16 reserved1;
389 u8 sw_rev[8];
390 u8 ver_type;
391 u8 ver_subtype; /* not "9" for runtime alive */
392 __le16 reserved2;
393 __le32 log_event_table_ptr; /* SRAM address for event log */
394 __le32 error_event_table_ptr; /* SRAM address for error log */
395 __le32 timestamp;
396 __le32 is_valid;
397} __attribute__ ((packed));
398
399
Zhu Yib481de92007-09-25 17:54:57 -0700400union tsf {
401 u8 byte[8];
402 __le16 word[4];
403 __le32 dw[2];
404};
405
406/*
407 * REPLY_ERROR = 0x2 (response only, not a command)
408 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800409struct iwl4965_error_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700410 __le32 error_type;
411 u8 cmd_id;
412 u8 reserved1;
413 __le16 bad_cmd_seq_num;
Zhu Yib481de92007-09-25 17:54:57 -0700414 __le32 error_info;
415 union tsf timestamp;
416} __attribute__ ((packed));
417
418/******************************************************************************
419 * (1)
420 * RXON Commands & Responses:
421 *
422 *****************************************************************************/
423
424/*
425 * Rx config defines & structure
426 */
427/* rx_config device types */
428enum {
429 RXON_DEV_TYPE_AP = 1,
430 RXON_DEV_TYPE_ESS = 3,
431 RXON_DEV_TYPE_IBSS = 4,
432 RXON_DEV_TYPE_SNIFFER = 6,
433};
434
Ben Cahill14519a02007-11-29 11:09:59 +0800435
436#define RXON_RX_CHAIN_DRIVER_FORCE_MSK __constant_cpu_to_le16(0x1<<0)
437#define RXON_RX_CHAIN_VALID_MSK __constant_cpu_to_le16(0x7<<1)
438#define RXON_RX_CHAIN_VALID_POS (1)
439#define RXON_RX_CHAIN_FORCE_SEL_MSK __constant_cpu_to_le16(0x7<<4)
440#define RXON_RX_CHAIN_FORCE_SEL_POS (4)
441#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK __constant_cpu_to_le16(0x7<<7)
442#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
443#define RXON_RX_CHAIN_CNT_MSK __constant_cpu_to_le16(0x3<<10)
444#define RXON_RX_CHAIN_CNT_POS (10)
445#define RXON_RX_CHAIN_MIMO_CNT_MSK __constant_cpu_to_le16(0x3<<12)
446#define RXON_RX_CHAIN_MIMO_CNT_POS (12)
447#define RXON_RX_CHAIN_MIMO_FORCE_MSK __constant_cpu_to_le16(0x1<<14)
448#define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
449
Zhu Yib481de92007-09-25 17:54:57 -0700450/* rx_config flags */
451/* band & modulation selection */
452#define RXON_FLG_BAND_24G_MSK __constant_cpu_to_le32(1 << 0)
453#define RXON_FLG_CCK_MSK __constant_cpu_to_le32(1 << 1)
454/* auto detection enable */
455#define RXON_FLG_AUTO_DETECT_MSK __constant_cpu_to_le32(1 << 2)
456/* TGg protection when tx */
457#define RXON_FLG_TGG_PROTECT_MSK __constant_cpu_to_le32(1 << 3)
458/* cck short slot & preamble */
459#define RXON_FLG_SHORT_SLOT_MSK __constant_cpu_to_le32(1 << 4)
460#define RXON_FLG_SHORT_PREAMBLE_MSK __constant_cpu_to_le32(1 << 5)
461/* antenna selection */
462#define RXON_FLG_DIS_DIV_MSK __constant_cpu_to_le32(1 << 7)
463#define RXON_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0x0f00)
464#define RXON_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
465#define RXON_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
466/* radar detection enable */
467#define RXON_FLG_RADAR_DETECT_MSK __constant_cpu_to_le32(1 << 12)
468#define RXON_FLG_TGJ_NARROW_BAND_MSK __constant_cpu_to_le32(1 << 13)
469/* rx response to host with 8-byte TSF
470* (according to ON_AIR deassertion) */
471#define RXON_FLG_TSF2HOST_MSK __constant_cpu_to_le32(1 << 15)
472
Ben Cahill14519a02007-11-29 11:09:59 +0800473
474/* HT flags */
475#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
476#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK __constant_cpu_to_le32(0x1<<22)
477
478#define RXON_FLG_HT_OPERATING_MODE_POS (23)
479
480#define RXON_FLG_HT_PROT_MSK __constant_cpu_to_le32(0x1<<23)
481#define RXON_FLG_FAT_PROT_MSK __constant_cpu_to_le32(0x2<<23)
482
483#define RXON_FLG_CHANNEL_MODE_POS (25)
484#define RXON_FLG_CHANNEL_MODE_MSK __constant_cpu_to_le32(0x3<<25)
485#define RXON_FLG_CHANNEL_MODE_PURE_40_MSK __constant_cpu_to_le32(0x1<<25)
486#define RXON_FLG_CHANNEL_MODE_MIXED_MSK __constant_cpu_to_le32(0x2<<25)
487
Zhu Yib481de92007-09-25 17:54:57 -0700488/* rx_config filter flags */
489/* accept all data frames */
490#define RXON_FILTER_PROMISC_MSK __constant_cpu_to_le32(1 << 0)
491/* pass control & management to host */
492#define RXON_FILTER_CTL2HOST_MSK __constant_cpu_to_le32(1 << 1)
493/* accept multi-cast */
494#define RXON_FILTER_ACCEPT_GRP_MSK __constant_cpu_to_le32(1 << 2)
495/* don't decrypt uni-cast frames */
496#define RXON_FILTER_DIS_DECRYPT_MSK __constant_cpu_to_le32(1 << 3)
497/* don't decrypt multi-cast frames */
498#define RXON_FILTER_DIS_GRP_DECRYPT_MSK __constant_cpu_to_le32(1 << 4)
499/* STA is associated */
500#define RXON_FILTER_ASSOC_MSK __constant_cpu_to_le32(1 << 5)
501/* transfer to host non bssid beacons in associated state */
502#define RXON_FILTER_BCON_AWARE_MSK __constant_cpu_to_le32(1 << 6)
503
504/*
505 * REPLY_RXON = 0x10 (command, has simple generic response)
506 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800507struct iwl4965_rxon_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700508 u8 node_addr[6];
509 __le16 reserved1;
510 u8 bssid_addr[6];
511 __le16 reserved2;
512 u8 wlap_bssid_addr[6];
513 __le16 reserved3;
514 u8 dev_type;
515 u8 air_propagation;
Zhu Yib481de92007-09-25 17:54:57 -0700516 __le16 rx_chain;
Zhu Yib481de92007-09-25 17:54:57 -0700517 u8 ofdm_basic_rates;
518 u8 cck_basic_rates;
519 __le16 assoc_id;
520 __le32 flags;
521 __le32 filter_flags;
522 __le16 channel;
Zhu Yib481de92007-09-25 17:54:57 -0700523 u8 ofdm_ht_single_stream_basic_rates;
524 u8 ofdm_ht_dual_stream_basic_rates;
Zhu Yib481de92007-09-25 17:54:57 -0700525} __attribute__ ((packed));
526
527/*
528 * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
529 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800530struct iwl4965_rxon_assoc_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700531 __le32 flags;
532 __le32 filter_flags;
533 u8 ofdm_basic_rates;
534 u8 cck_basic_rates;
Zhu Yib481de92007-09-25 17:54:57 -0700535 u8 ofdm_ht_single_stream_basic_rates;
536 u8 ofdm_ht_dual_stream_basic_rates;
537 __le16 rx_chain_select_flags;
Zhu Yib481de92007-09-25 17:54:57 -0700538 __le16 reserved;
539} __attribute__ ((packed));
540
541/*
542 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
543 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800544struct iwl4965_rxon_time_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700545 union tsf timestamp;
546 __le16 beacon_interval;
547 __le16 atim_window;
548 __le32 beacon_init_val;
549 __le16 listen_interval;
550 __le16 reserved;
551} __attribute__ ((packed));
552
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800553struct iwl4965_tx_power {
Zhu Yib481de92007-09-25 17:54:57 -0700554 u8 tx_gain; /* gain for analog radio */
555 u8 dsp_atten; /* gain for DSP */
556} __attribute__ ((packed));
557
Zhu Yib481de92007-09-25 17:54:57 -0700558#define POWER_TABLE_NUM_ENTRIES 33
559#define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
560#define POWER_TABLE_CCK_ENTRY 32
Ben Cahill14519a02007-11-29 11:09:59 +0800561
562union iwl4965_tx_power_dual_stream {
563 struct {
564 u8 radio_tx_gain[2];
565 u8 dsp_predis_atten[2];
566 } s;
567 u32 dw;
568};
569
Zhu Yib481de92007-09-25 17:54:57 -0700570struct tx_power_dual_stream {
571 __le32 dw;
572} __attribute__ ((packed));
573
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800574struct iwl4965_tx_power_db {
Zhu Yib481de92007-09-25 17:54:57 -0700575 struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
576} __attribute__ ((packed));
Zhu Yib481de92007-09-25 17:54:57 -0700577
578/*
579 * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
580 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800581struct iwl4965_channel_switch_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700582 u8 band;
583 u8 expect_beacon;
584 __le16 channel;
585 __le32 rxon_flags;
586 __le32 rxon_filter_flags;
587 __le32 switch_time;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800588 struct iwl4965_tx_power_db tx_power;
Zhu Yib481de92007-09-25 17:54:57 -0700589} __attribute__ ((packed));
590
591/*
592 * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
593 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800594struct iwl4965_csa_notification {
Zhu Yib481de92007-09-25 17:54:57 -0700595 __le16 band;
596 __le16 channel;
597 __le32 status; /* 0 - OK, 1 - fail */
598} __attribute__ ((packed));
599
600/******************************************************************************
601 * (2)
602 * Quality-of-Service (QOS) Commands & Responses:
603 *
604 *****************************************************************************/
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800605struct iwl4965_ac_qos {
Zhu Yib481de92007-09-25 17:54:57 -0700606 __le16 cw_min;
607 __le16 cw_max;
608 u8 aifsn;
609 u8 reserved1;
610 __le16 edca_txop;
611} __attribute__ ((packed));
612
613/* QoS flags defines */
614#define QOS_PARAM_FLG_UPDATE_EDCA_MSK __constant_cpu_to_le32(0x01)
615#define QOS_PARAM_FLG_TGN_MSK __constant_cpu_to_le32(0x02)
616#define QOS_PARAM_FLG_TXOP_TYPE_MSK __constant_cpu_to_le32(0x10)
617
618/*
619 * TXFIFO Queue number defines
620 */
621/* number of Access categories (AC) (EDCA), queues 0..3 */
622#define AC_NUM 4
623
624/*
625 * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
626 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800627struct iwl4965_qosparam_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700628 __le32 qos_flags;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800629 struct iwl4965_ac_qos ac[AC_NUM];
Zhu Yib481de92007-09-25 17:54:57 -0700630} __attribute__ ((packed));
631
632/******************************************************************************
633 * (3)
634 * Add/Modify Stations Commands & Responses:
635 *
636 *****************************************************************************/
637/*
638 * Multi station support
639 */
640#define IWL_AP_ID 0
641#define IWL_MULTICAST_ID 1
642#define IWL_STA_ID 2
643
644#define IWL3945_BROADCAST_ID 24
645#define IWL3945_STATION_COUNT 25
646
647#define IWL4965_BROADCAST_ID 31
648#define IWL4965_STATION_COUNT 32
649
650#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
651#define IWL_INVALID_STATION 255
652
Zhu Yib481de92007-09-25 17:54:57 -0700653#define STA_FLG_PWR_SAVE_MSK __constant_cpu_to_le32(1<<8);
Ben Cahill74093dd2007-11-29 11:09:53 +0800654#define STA_FLG_RTS_MIMO_PROT_MSK __constant_cpu_to_le32(1 << 17)
655#define STA_FLG_AGG_MPDU_8US_MSK __constant_cpu_to_le32(1 << 18)
656#define STA_FLG_MAX_AGG_SIZE_POS (19)
657#define STA_FLG_MAX_AGG_SIZE_MSK __constant_cpu_to_le32(3 << 19)
658#define STA_FLG_FAT_EN_MSK __constant_cpu_to_le32(1 << 21)
659#define STA_FLG_MIMO_DIS_MSK __constant_cpu_to_le32(1 << 22)
660#define STA_FLG_AGG_MPDU_DENSITY_POS (23)
661#define STA_FLG_AGG_MPDU_DENSITY_MSK __constant_cpu_to_le32(7 << 23)
Zhu Yib481de92007-09-25 17:54:57 -0700662
663#define STA_CONTROL_MODIFY_MSK 0x01
664
665/* key flags __le16*/
666#define STA_KEY_FLG_ENCRYPT_MSK __constant_cpu_to_le16(0x7)
667#define STA_KEY_FLG_NO_ENC __constant_cpu_to_le16(0x0)
668#define STA_KEY_FLG_WEP __constant_cpu_to_le16(0x1)
669#define STA_KEY_FLG_CCMP __constant_cpu_to_le16(0x2)
670#define STA_KEY_FLG_TKIP __constant_cpu_to_le16(0x3)
671
672#define STA_KEY_FLG_KEYID_POS 8
673#define STA_KEY_FLG_INVALID __constant_cpu_to_le16(0x0800)
674
675/* modify flags */
676#define STA_MODIFY_KEY_MASK 0x01
677#define STA_MODIFY_TID_DISABLE_TX 0x02
678#define STA_MODIFY_TX_RATE_MSK 0x04
679#define STA_MODIFY_ADDBA_TID_MSK 0x08
680#define STA_MODIFY_DELBA_TID_MSK 0x10
681#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid))
682
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800683struct iwl4965_keyinfo {
Zhu Yib481de92007-09-25 17:54:57 -0700684 __le16 key_flags;
685 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
686 u8 reserved1;
687 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
688 __le16 reserved2;
689 u8 key[16]; /* 16-byte unicast decryption key */
690} __attribute__ ((packed));
691
692struct sta_id_modify {
693 u8 addr[ETH_ALEN];
694 __le16 reserved1;
695 u8 sta_id;
696 u8 modify_mask;
697 __le16 reserved2;
698} __attribute__ ((packed));
699
700/*
701 * REPLY_ADD_STA = 0x18 (command)
702 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800703struct iwl4965_addsta_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700704 u8 mode;
705 u8 reserved[3];
706 struct sta_id_modify sta;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800707 struct iwl4965_keyinfo key;
Zhu Yib481de92007-09-25 17:54:57 -0700708 __le32 station_flags;
709 __le32 station_flags_msk;
710 __le16 tid_disable_tx;
Zhu Yib481de92007-09-25 17:54:57 -0700711 __le16 reserved1;
Zhu Yib481de92007-09-25 17:54:57 -0700712 u8 add_immediate_ba_tid;
713 u8 remove_immediate_ba_tid;
714 __le16 add_immediate_ba_ssn;
Zhu Yib481de92007-09-25 17:54:57 -0700715 __le32 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -0700716} __attribute__ ((packed));
717
718/*
719 * REPLY_ADD_STA = 0x18 (response)
720 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800721struct iwl4965_add_sta_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700722 u8 status;
723} __attribute__ ((packed));
724
725#define ADD_STA_SUCCESS_MSK 0x1
726
727/******************************************************************************
728 * (4)
729 * Rx Responses:
730 *
731 *****************************************************************************/
732
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800733struct iwl4965_rx_frame_stats {
Zhu Yib481de92007-09-25 17:54:57 -0700734 u8 phy_count;
735 u8 id;
736 u8 rssi;
737 u8 agc;
738 __le16 sig_avg;
739 __le16 noise_diff;
740 u8 payload[0];
741} __attribute__ ((packed));
742
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800743struct iwl4965_rx_frame_hdr {
Zhu Yib481de92007-09-25 17:54:57 -0700744 __le16 channel;
745 __le16 phy_flags;
746 u8 reserved1;
747 u8 rate;
748 __le16 len;
749 u8 payload[0];
750} __attribute__ ((packed));
751
752#define RX_RES_STATUS_NO_CRC32_ERROR __constant_cpu_to_le32(1 << 0)
753#define RX_RES_STATUS_NO_RXE_OVERFLOW __constant_cpu_to_le32(1 << 1)
754
755#define RX_RES_PHY_FLAGS_BAND_24_MSK __constant_cpu_to_le16(1 << 0)
756#define RX_RES_PHY_FLAGS_MOD_CCK_MSK __constant_cpu_to_le16(1 << 1)
757#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK __constant_cpu_to_le16(1 << 2)
758#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK __constant_cpu_to_le16(1 << 3)
759#define RX_RES_PHY_FLAGS_ANTENNA_MSK __constant_cpu_to_le16(0xf0)
760
761#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
762#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
763#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
764#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
765#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
766
767#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
768#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
769#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
770#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
771#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
772
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800773struct iwl4965_rx_frame_end {
Zhu Yib481de92007-09-25 17:54:57 -0700774 __le32 status;
775 __le64 timestamp;
776 __le32 beacon_timestamp;
777} __attribute__ ((packed));
778
779/*
780 * REPLY_3945_RX = 0x1b (response only, not a command)
781 *
782 * NOTE: DO NOT dereference from casts to this structure
783 * It is provided only for calculating minimum data set size.
784 * The actual offsets of the hdr and end are dynamic based on
785 * stats.phy_count
786 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800787struct iwl4965_rx_frame {
788 struct iwl4965_rx_frame_stats stats;
789 struct iwl4965_rx_frame_hdr hdr;
790 struct iwl4965_rx_frame_end end;
Zhu Yib481de92007-09-25 17:54:57 -0700791} __attribute__ ((packed));
792
793/* Fixed (non-configurable) rx data from phy */
794#define RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
795#define RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
796#define IWL_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
797#define IWL_AGC_DB_POS (7)
798struct iwl4965_rx_non_cfg_phy {
799 __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
800 __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
801 u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
802 u8 pad[0];
803} __attribute__ ((packed));
804
805/*
806 * REPLY_4965_RX = 0xc3 (response only, not a command)
807 * Used only for legacy (non 11n) frames.
808 */
809#define RX_RES_PHY_CNT 14
810struct iwl4965_rx_phy_res {
811 u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
812 u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
813 u8 stat_id; /* configurable DSP phy data set ID */
814 u8 reserved1;
815 __le64 timestamp; /* TSF at on air rise */
816 __le32 beacon_time_stamp; /* beacon at on-air rise */
817 __le16 phy_flags; /* general phy flags: band, modulation, ... */
818 __le16 channel; /* channel number */
819 __le16 non_cfg_phy[RX_RES_PHY_CNT]; /* upto 14 phy entries */
820 __le32 reserved2;
821 __le32 rate_n_flags;
822 __le16 byte_count; /* frame's byte-count */
823 __le16 reserved3;
824} __attribute__ ((packed));
825
826struct iwl4965_rx_mpdu_res_start {
827 __le16 byte_count;
828 __le16 reserved;
829} __attribute__ ((packed));
830
831
832/******************************************************************************
833 * (5)
834 * Tx Commands & Responses:
835 *
836 *****************************************************************************/
837
838/* Tx flags */
839#define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1)
840#define TX_CMD_FLG_CTS_MSK __constant_cpu_to_le32(1 << 2)
841#define TX_CMD_FLG_ACK_MSK __constant_cpu_to_le32(1 << 3)
842#define TX_CMD_FLG_STA_RATE_MSK __constant_cpu_to_le32(1 << 4)
843#define TX_CMD_FLG_IMM_BA_RSP_MASK __constant_cpu_to_le32(1 << 6)
844#define TX_CMD_FLG_FULL_TXOP_PROT_MSK __constant_cpu_to_le32(1 << 7)
845#define TX_CMD_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0xf00)
846#define TX_CMD_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
847#define TX_CMD_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
848
849/* ucode ignores BT priority for this frame */
850#define TX_CMD_FLG_BT_DIS_MSK __constant_cpu_to_le32(1 << 12)
851
852/* ucode overrides sequence control */
853#define TX_CMD_FLG_SEQ_CTL_MSK __constant_cpu_to_le32(1 << 13)
854
855/* signal that this frame is non-last MPDU */
856#define TX_CMD_FLG_MORE_FRAG_MSK __constant_cpu_to_le32(1 << 14)
857
858/* calculate TSF in outgoing frame */
859#define TX_CMD_FLG_TSF_MSK __constant_cpu_to_le32(1 << 16)
860
861/* activate TX calibration. */
862#define TX_CMD_FLG_CALIB_MSK __constant_cpu_to_le32(1 << 17)
863
864/* signals that 2 bytes pad was inserted
865 after the MAC header */
866#define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20)
867
868/* HCCA-AP - disable duration overwriting. */
869#define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25)
870
871/*
872 * TX command security control
873 */
874#define TX_CMD_SEC_WEP 0x01
875#define TX_CMD_SEC_CCM 0x02
876#define TX_CMD_SEC_TKIP 0x03
877#define TX_CMD_SEC_MSK 0x03
878#define TX_CMD_SEC_SHIFT 6
879#define TX_CMD_SEC_KEY128 0x08
880
881/*
882 * TX command Frame life time
883 */
884
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800885struct iwl4965_dram_scratch {
Zhu Yib481de92007-09-25 17:54:57 -0700886 u8 try_cnt;
887 u8 bt_kill_cnt;
888 __le16 reserved;
889} __attribute__ ((packed));
890
891/*
892 * REPLY_TX = 0x1c (command)
893 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800894struct iwl4965_tx_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700895 __le16 len;
896 __le16 next_frame_len;
897 __le32 tx_flags;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800898 struct iwl4965_dram_scratch scratch;
Zhu Yib481de92007-09-25 17:54:57 -0700899 __le32 rate_n_flags;
900 u8 sta_id;
Zhu Yib481de92007-09-25 17:54:57 -0700901 u8 sec_ctl;
Zhu Yib481de92007-09-25 17:54:57 -0700902 u8 initial_rate_index;
903 u8 reserved;
Zhu Yib481de92007-09-25 17:54:57 -0700904 u8 key[16];
Zhu Yib481de92007-09-25 17:54:57 -0700905 __le16 next_frame_flags;
906 __le16 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -0700907 union {
908 __le32 life_time;
909 __le32 attempt;
910 } stop_time;
Zhu Yib481de92007-09-25 17:54:57 -0700911 __le32 dram_lsb_ptr;
912 u8 dram_msb_ptr;
Zhu Yib481de92007-09-25 17:54:57 -0700913 u8 rts_retry_limit; /*byte 50 */
914 u8 data_retry_limit; /*byte 51 */
Zhu Yib481de92007-09-25 17:54:57 -0700915 u8 tid_tspec;
Zhu Yib481de92007-09-25 17:54:57 -0700916 union {
917 __le16 pm_frame_timeout;
918 __le16 attempt_duration;
919 } timeout;
920 __le16 driver_txop;
921 u8 payload[0];
922 struct ieee80211_hdr hdr[0];
923} __attribute__ ((packed));
924
925/* TX command response is sent after *all* transmission attempts.
926 *
927 * NOTES:
928 *
929 * TX_STATUS_FAIL_NEXT_FRAG
930 *
931 * If the fragment flag in the MAC header for the frame being transmitted
932 * is set and there is insufficient time to transmit the next frame, the
933 * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
934 *
935 * TX_STATUS_FIFO_UNDERRUN
936 *
937 * Indicates the host did not provide bytes to the FIFO fast enough while
938 * a TX was in progress.
939 *
940 * TX_STATUS_FAIL_MGMNT_ABORT
941 *
942 * This status is only possible if the ABORT ON MGMT RX parameter was
943 * set to true with the TX command.
944 *
945 * If the MSB of the status parameter is set then an abort sequence is
946 * required. This sequence consists of the host activating the TX Abort
947 * control line, and then waiting for the TX Abort command response. This
948 * indicates that a the device is no longer in a transmit state, and that the
949 * command FIFO has been cleared. The host must then deactivate the TX Abort
950 * control line. Receiving is still allowed in this case.
951 */
952enum {
953 TX_STATUS_SUCCESS = 0x01,
954 TX_STATUS_DIRECT_DONE = 0x02,
955 TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
956 TX_STATUS_FAIL_LONG_LIMIT = 0x83,
957 TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
958 TX_STATUS_FAIL_MGMNT_ABORT = 0x85,
959 TX_STATUS_FAIL_NEXT_FRAG = 0x86,
960 TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
961 TX_STATUS_FAIL_DEST_PS = 0x88,
962 TX_STATUS_FAIL_ABORTED = 0x89,
963 TX_STATUS_FAIL_BT_RETRY = 0x8a,
964 TX_STATUS_FAIL_STA_INVALID = 0x8b,
965 TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
966 TX_STATUS_FAIL_TID_DISABLE = 0x8d,
967 TX_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
968 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
969 TX_STATUS_FAIL_TX_LOCKED = 0x90,
970 TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
971};
972
973#define TX_PACKET_MODE_REGULAR 0x0000
974#define TX_PACKET_MODE_BURST_SEQ 0x0100
975#define TX_PACKET_MODE_BURST_FIRST 0x0200
976
977enum {
978 TX_POWER_PA_NOT_ACTIVE = 0x0,
979};
980
981enum {
982 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
983 TX_STATUS_DELAY_MSK = 0x00000040,
984 TX_STATUS_ABORT_MSK = 0x00000080,
985 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
986 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
987 TX_RESERVED = 0x00780000, /* bits 19:22 */
988 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
989 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
990};
991
992/* *******************************
993 * TX aggregation state
994 ******************************* */
995
996enum {
997 AGG_TX_STATE_TRANSMITTED = 0x00,
998 AGG_TX_STATE_UNDERRUN_MSK = 0x01,
999 AGG_TX_STATE_BT_PRIO_MSK = 0x02,
1000 AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1001 AGG_TX_STATE_ABORT_MSK = 0x08,
1002 AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1003 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1004 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
1005 AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1006 AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1007 AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1008 AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1009 AGG_TX_STATE_DELAY_TX_MSK = 0x400
1010};
1011
1012#define AGG_TX_STATE_LAST_SENT_MSK \
1013(AGG_TX_STATE_LAST_SENT_TTL_MSK | \
1014 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
1015 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
1016
1017#define AGG_TX_STATE_TRY_CNT_POS 12
1018#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1019
1020#define AGG_TX_STATE_SEQ_NUM_POS 16
1021#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1022
1023/*
1024 * REPLY_TX = 0x1c (response)
1025 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001026struct iwl4965_tx_resp {
Zhu Yib481de92007-09-25 17:54:57 -07001027 u8 frame_count; /* 1 no aggregation, >1 aggregation */
1028 u8 bt_kill_count;
1029 u8 failure_rts;
1030 u8 failure_frame;
1031 __le32 rate_n_flags;
1032 __le16 wireless_media_time;
1033 __le16 reserved;
1034 __le32 pa_power1;
1035 __le32 pa_power2;
1036 __le32 status; /* TX status (for aggregation status of 1st frame) */
1037} __attribute__ ((packed));
1038
Zhu Yib481de92007-09-25 17:54:57 -07001039/*
1040 * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
1041 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001042struct iwl4965_compressed_ba_resp {
Zhu Yib481de92007-09-25 17:54:57 -07001043 __le32 sta_addr_lo32;
1044 __le16 sta_addr_hi16;
1045 __le16 reserved;
1046 u8 sta_id;
1047 u8 tid;
1048 __le16 ba_seq_ctl;
1049 __le32 ba_bitmap0;
1050 __le32 ba_bitmap1;
1051 __le16 scd_flow;
1052 __le16 scd_ssn;
1053} __attribute__ ((packed));
1054
1055/*
1056 * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
1057 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001058struct iwl4965_txpowertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001059 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
1060 u8 reserved;
1061 __le16 channel;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001062 struct iwl4965_tx_power_db tx_power;
Zhu Yib481de92007-09-25 17:54:57 -07001063} __attribute__ ((packed));
1064
Zhu Yib481de92007-09-25 17:54:57 -07001065/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
1066#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1<<0)
1067
1068#define LINK_QUAL_AC_NUM AC_NUM
1069#define LINK_QUAL_MAX_RETRY_NUM 16
1070
1071#define LINK_QUAL_ANT_A_MSK (1<<0)
1072#define LINK_QUAL_ANT_B_MSK (1<<1)
1073#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
1074
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001075struct iwl4965_link_qual_general_params {
Zhu Yib481de92007-09-25 17:54:57 -07001076 u8 flags;
1077 u8 mimo_delimiter;
1078 u8 single_stream_ant_msk;
1079 u8 dual_stream_ant_msk;
1080 u8 start_rate_index[LINK_QUAL_AC_NUM];
1081} __attribute__ ((packed));
1082
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001083struct iwl4965_link_qual_agg_params {
Zhu Yib481de92007-09-25 17:54:57 -07001084 __le16 agg_time_limit;
1085 u8 agg_dis_start_th;
1086 u8 agg_frame_cnt_limit;
1087 __le32 reserved;
1088} __attribute__ ((packed));
1089
1090/*
1091 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
1092 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001093struct iwl4965_link_quality_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001094 u8 sta_id;
1095 u8 reserved1;
1096 __le16 control;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001097 struct iwl4965_link_qual_general_params general_params;
1098 struct iwl4965_link_qual_agg_params agg_params;
Zhu Yib481de92007-09-25 17:54:57 -07001099 struct {
1100 __le32 rate_n_flags;
1101 } rs_table[LINK_QUAL_MAX_RETRY_NUM];
1102 __le32 reserved2;
1103} __attribute__ ((packed));
Zhu Yib481de92007-09-25 17:54:57 -07001104
1105/*
1106 * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
1107 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001108struct iwl4965_bt_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001109 u8 flags;
1110 u8 lead_time;
1111 u8 max_kill;
1112 u8 reserved;
1113 __le32 kill_ack_mask;
1114 __le32 kill_cts_mask;
1115} __attribute__ ((packed));
1116
1117/******************************************************************************
1118 * (6)
1119 * Spectrum Management (802.11h) Commands, Responses, Notifications:
1120 *
1121 *****************************************************************************/
1122
1123/*
1124 * Spectrum Management
1125 */
1126#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
1127 RXON_FILTER_CTL2HOST_MSK | \
1128 RXON_FILTER_ACCEPT_GRP_MSK | \
1129 RXON_FILTER_DIS_DECRYPT_MSK | \
1130 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
1131 RXON_FILTER_ASSOC_MSK | \
1132 RXON_FILTER_BCON_AWARE_MSK)
1133
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001134struct iwl4965_measure_channel {
Zhu Yib481de92007-09-25 17:54:57 -07001135 __le32 duration; /* measurement duration in extended beacon
1136 * format */
1137 u8 channel; /* channel to measure */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001138 u8 type; /* see enum iwl4965_measure_type */
Zhu Yib481de92007-09-25 17:54:57 -07001139 __le16 reserved;
1140} __attribute__ ((packed));
1141
1142/*
1143 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
1144 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001145struct iwl4965_spectrum_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001146 __le16 len; /* number of bytes starting from token */
1147 u8 token; /* token id */
1148 u8 id; /* measurement id -- 0 or 1 */
1149 u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
1150 u8 periodic; /* 1 = periodic */
1151 __le16 path_loss_timeout;
1152 __le32 start_time; /* start time in extended beacon format */
1153 __le32 reserved2;
1154 __le32 flags; /* rxon flags */
1155 __le32 filter_flags; /* rxon filter flags */
1156 __le16 channel_count; /* minimum 1, maximum 10 */
1157 __le16 reserved3;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001158 struct iwl4965_measure_channel channels[10];
Zhu Yib481de92007-09-25 17:54:57 -07001159} __attribute__ ((packed));
1160
1161/*
1162 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
1163 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001164struct iwl4965_spectrum_resp {
Zhu Yib481de92007-09-25 17:54:57 -07001165 u8 token;
1166 u8 id; /* id of the prior command replaced, or 0xff */
1167 __le16 status; /* 0 - command will be handled
1168 * 1 - cannot handle (conflicts with another
1169 * measurement) */
1170} __attribute__ ((packed));
1171
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001172enum iwl4965_measurement_state {
Zhu Yib481de92007-09-25 17:54:57 -07001173 IWL_MEASUREMENT_START = 0,
1174 IWL_MEASUREMENT_STOP = 1,
1175};
1176
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001177enum iwl4965_measurement_status {
Zhu Yib481de92007-09-25 17:54:57 -07001178 IWL_MEASUREMENT_OK = 0,
1179 IWL_MEASUREMENT_CONCURRENT = 1,
1180 IWL_MEASUREMENT_CSA_CONFLICT = 2,
1181 IWL_MEASUREMENT_TGH_CONFLICT = 3,
1182 /* 4-5 reserved */
1183 IWL_MEASUREMENT_STOPPED = 6,
1184 IWL_MEASUREMENT_TIMEOUT = 7,
1185 IWL_MEASUREMENT_PERIODIC_FAILED = 8,
1186};
1187
1188#define NUM_ELEMENTS_IN_HISTOGRAM 8
1189
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001190struct iwl4965_measurement_histogram {
Zhu Yib481de92007-09-25 17:54:57 -07001191 __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
1192 __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
1193} __attribute__ ((packed));
1194
1195/* clear channel availability counters */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001196struct iwl4965_measurement_cca_counters {
Zhu Yib481de92007-09-25 17:54:57 -07001197 __le32 ofdm;
1198 __le32 cck;
1199} __attribute__ ((packed));
1200
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001201enum iwl4965_measure_type {
Zhu Yib481de92007-09-25 17:54:57 -07001202 IWL_MEASURE_BASIC = (1 << 0),
1203 IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
1204 IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
1205 IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
1206 IWL_MEASURE_FRAME = (1 << 4),
1207 /* bits 5:6 are reserved */
1208 IWL_MEASURE_IDLE = (1 << 7),
1209};
1210
1211/*
1212 * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
1213 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001214struct iwl4965_spectrum_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001215 u8 id; /* measurement id -- 0 or 1 */
1216 u8 token;
1217 u8 channel_index; /* index in measurement channel list */
1218 u8 state; /* 0 - start, 1 - stop */
1219 __le32 start_time; /* lower 32-bits of TSF */
1220 u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
1221 u8 channel;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001222 u8 type; /* see enum iwl4965_measurement_type */
Zhu Yib481de92007-09-25 17:54:57 -07001223 u8 reserved1;
1224 /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
1225 * valid if applicable for measurement type requested. */
1226 __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
1227 __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
1228 __le32 cca_time; /* channel load time in usecs */
1229 u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
1230 * unidentified */
1231 u8 reserved2[3];
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001232 struct iwl4965_measurement_histogram histogram;
Zhu Yib481de92007-09-25 17:54:57 -07001233 __le32 stop_time; /* lower 32-bits of TSF */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001234 __le32 status; /* see iwl4965_measurement_status */
Zhu Yib481de92007-09-25 17:54:57 -07001235} __attribute__ ((packed));
1236
1237/******************************************************************************
1238 * (7)
1239 * Power Management Commands, Responses, Notifications:
1240 *
1241 *****************************************************************************/
1242
1243/**
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001244 * struct iwl4965_powertable_cmd - Power Table Command
Zhu Yib481de92007-09-25 17:54:57 -07001245 * @flags: See below:
1246 *
1247 * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
1248 *
1249 * PM allow:
1250 * bit 0 - '0' Driver not allow power management
1251 * '1' Driver allow PM (use rest of parameters)
1252 * uCode send sleep notifications:
1253 * bit 1 - '0' Don't send sleep notification
1254 * '1' send sleep notification (SEND_PM_NOTIFICATION)
1255 * Sleep over DTIM
1256 * bit 2 - '0' PM have to walk up every DTIM
1257 * '1' PM could sleep over DTIM till listen Interval.
1258 * PCI power managed
1259 * bit 3 - '0' (PCI_LINK_CTRL & 0x1)
1260 * '1' !(PCI_LINK_CTRL & 0x1)
1261 * Force sleep Modes
1262 * bit 31/30- '00' use both mac/xtal sleeps
1263 * '01' force Mac sleep
1264 * '10' force xtal sleep
1265 * '11' Illegal set
1266 *
1267 * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
1268 * ucode assume sleep over DTIM is allowed and we don't need to wakeup
1269 * for every DTIM.
1270 */
1271#define IWL_POWER_VEC_SIZE 5
1272
Zhu Yib481de92007-09-25 17:54:57 -07001273#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK __constant_cpu_to_le16(1<<0)
1274#define IWL_POWER_SLEEP_OVER_DTIM_MSK __constant_cpu_to_le16(1<<2)
1275#define IWL_POWER_PCI_PM_MSK __constant_cpu_to_le16(1<<3)
1276
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001277struct iwl4965_powertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001278 __le16 flags;
1279 u8 keep_alive_seconds;
1280 u8 debug_flags;
1281 __le32 rx_data_timeout;
1282 __le32 tx_data_timeout;
1283 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
1284 __le32 keep_alive_beacons;
1285} __attribute__ ((packed));
Zhu Yib481de92007-09-25 17:54:57 -07001286
1287/*
1288 * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
1289 * 3945 and 4965 identical.
1290 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001291struct iwl4965_sleep_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001292 u8 pm_sleep_mode;
1293 u8 pm_wakeup_src;
1294 __le16 reserved;
1295 __le32 sleep_time;
1296 __le32 tsf_low;
1297 __le32 bcon_timer;
1298} __attribute__ ((packed));
1299
1300/* Sleep states. 3945 and 4965 identical. */
1301enum {
1302 IWL_PM_NO_SLEEP = 0,
1303 IWL_PM_SLP_MAC = 1,
1304 IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
1305 IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
1306 IWL_PM_SLP_PHY = 4,
1307 IWL_PM_SLP_REPENT = 5,
1308 IWL_PM_WAKEUP_BY_TIMER = 6,
1309 IWL_PM_WAKEUP_BY_DRIVER = 7,
1310 IWL_PM_WAKEUP_BY_RFKILL = 8,
1311 /* 3 reserved */
1312 IWL_PM_NUM_OF_MODES = 12,
1313};
1314
1315/*
1316 * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
1317 */
1318#define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
1319#define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
1320#define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001321struct iwl4965_card_state_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001322 __le32 status; /* CARD_STATE_CMD_* request new power state */
1323} __attribute__ ((packed));
1324
1325/*
1326 * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
1327 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001328struct iwl4965_card_state_notif {
Zhu Yib481de92007-09-25 17:54:57 -07001329 __le32 flags;
1330} __attribute__ ((packed));
1331
1332#define HW_CARD_DISABLED 0x01
1333#define SW_CARD_DISABLED 0x02
1334#define RF_CARD_DISABLED 0x04
1335#define RXON_CARD_DISABLED 0x10
1336
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001337struct iwl4965_ct_kill_config {
Zhu Yib481de92007-09-25 17:54:57 -07001338 __le32 reserved;
1339 __le32 critical_temperature_M;
1340 __le32 critical_temperature_R;
1341} __attribute__ ((packed));
1342
1343/******************************************************************************
1344 * (8)
1345 * Scan Commands, Responses, Notifications:
1346 *
1347 *****************************************************************************/
1348
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001349struct iwl4965_scan_channel {
Zhu Yib481de92007-09-25 17:54:57 -07001350 /* type is defined as:
1351 * 0:0 active (0 - passive)
1352 * 1:4 SSID direct
1353 * If 1 is set then corresponding SSID IE is transmitted in probe
1354 * 5:7 reserved
1355 */
1356 u8 type;
1357 u8 channel;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001358 struct iwl4965_tx_power tpc;
Zhu Yib481de92007-09-25 17:54:57 -07001359 __le16 active_dwell;
1360 __le16 passive_dwell;
1361} __attribute__ ((packed));
1362
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001363struct iwl4965_ssid_ie {
Zhu Yib481de92007-09-25 17:54:57 -07001364 u8 id;
1365 u8 len;
1366 u8 ssid[32];
1367} __attribute__ ((packed));
1368
1369#define PROBE_OPTION_MAX 0x4
1370#define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF)
1371#define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1)
1372#define IWL_MAX_SCAN_SIZE 1024
1373
1374/*
1375 * REPLY_SCAN_CMD = 0x80 (command)
1376 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001377struct iwl4965_scan_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001378 __le16 len;
1379 u8 reserved0;
1380 u8 channel_count;
1381 __le16 quiet_time; /* dwell only this long on quiet chnl
1382 * (active scan) */
1383 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
1384 __le16 good_CRC_th; /* passive -> active promotion threshold */
Zhu Yib481de92007-09-25 17:54:57 -07001385 __le16 rx_chain;
Zhu Yib481de92007-09-25 17:54:57 -07001386 __le32 max_out_time; /* max usec to be out of associated (service)
1387 * chnl */
1388 __le32 suspend_time; /* pause scan this long when returning to svc
1389 * chnl.
1390 * 3945 -- 31:24 # beacons, 19:0 additional usec,
1391 * 4965 -- 31:22 # beacons, 21:0 additional usec.
1392 */
1393 __le32 flags;
1394 __le32 filter_flags;
1395
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001396 struct iwl4965_tx_cmd tx_cmd;
1397 struct iwl4965_ssid_ie direct_scan[PROBE_OPTION_MAX];
Zhu Yib481de92007-09-25 17:54:57 -07001398
1399 u8 data[0];
1400 /*
1401 * The channels start after the probe request payload and are of type:
1402 *
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001403 * struct iwl4965_scan_channel channels[0];
Zhu Yib481de92007-09-25 17:54:57 -07001404 *
1405 * NOTE: Only one band of channels can be scanned per pass. You
1406 * can not mix 2.4GHz channels and 5.2GHz channels and must
1407 * request a scan multiple times (not concurrently)
1408 *
1409 */
1410} __attribute__ ((packed));
1411
1412/* Can abort will notify by complete notification with abort status. */
1413#define CAN_ABORT_STATUS __constant_cpu_to_le32(0x1)
1414/* complete notification statuses */
1415#define ABORT_STATUS 0x2
1416
1417/*
1418 * REPLY_SCAN_CMD = 0x80 (response)
1419 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001420struct iwl4965_scanreq_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001421 __le32 status; /* 1: okay, 2: cannot fulfill request */
1422} __attribute__ ((packed));
1423
1424/*
1425 * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
1426 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001427struct iwl4965_scanstart_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001428 __le32 tsf_low;
1429 __le32 tsf_high;
1430 __le32 beacon_timer;
1431 u8 channel;
1432 u8 band;
1433 u8 reserved[2];
1434 __le32 status;
1435} __attribute__ ((packed));
1436
1437#define SCAN_OWNER_STATUS 0x1;
1438#define MEASURE_OWNER_STATUS 0x2;
1439
1440#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
1441/*
1442 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
1443 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001444struct iwl4965_scanresults_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001445 u8 channel;
1446 u8 band;
1447 u8 reserved[2];
1448 __le32 tsf_low;
1449 __le32 tsf_high;
1450 __le32 statistics[NUMBER_OF_STATISTICS];
1451} __attribute__ ((packed));
1452
1453/*
1454 * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
1455 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001456struct iwl4965_scancomplete_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001457 u8 scanned_channels;
1458 u8 status;
1459 u8 reserved;
1460 u8 last_channel;
1461 __le32 tsf_low;
1462 __le32 tsf_high;
1463} __attribute__ ((packed));
1464
1465
1466/******************************************************************************
1467 * (9)
1468 * IBSS/AP Commands and Notifications:
1469 *
1470 *****************************************************************************/
1471
1472/*
1473 * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
1474 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001475struct iwl4965_beacon_notif {
1476 struct iwl4965_tx_resp beacon_notify_hdr;
Zhu Yib481de92007-09-25 17:54:57 -07001477 __le32 low_tsf;
1478 __le32 high_tsf;
1479 __le32 ibss_mgr_status;
1480} __attribute__ ((packed));
1481
1482/*
1483 * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
1484 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001485struct iwl4965_tx_beacon_cmd {
1486 struct iwl4965_tx_cmd tx;
Zhu Yib481de92007-09-25 17:54:57 -07001487 __le16 tim_idx;
1488 u8 tim_size;
1489 u8 reserved1;
1490 struct ieee80211_hdr frame[0]; /* beacon frame */
1491} __attribute__ ((packed));
1492
1493/******************************************************************************
1494 * (10)
1495 * Statistics Commands and Notifications:
1496 *
1497 *****************************************************************************/
1498
1499#define IWL_TEMP_CONVERT 260
1500
1501#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
1502#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
1503#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
1504
1505/* Used for passing to driver number of successes and failures per rate */
1506struct rate_histogram {
1507 union {
1508 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
1509 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
1510 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
1511 } success;
1512 union {
1513 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
1514 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
1515 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
1516 } failed;
1517} __attribute__ ((packed));
1518
1519/* statistics command response */
1520
1521struct statistics_rx_phy {
1522 __le32 ina_cnt;
1523 __le32 fina_cnt;
1524 __le32 plcp_err;
1525 __le32 crc32_err;
1526 __le32 overrun_err;
1527 __le32 early_overrun_err;
1528 __le32 crc32_good;
1529 __le32 false_alarm_cnt;
1530 __le32 fina_sync_err_cnt;
1531 __le32 sfd_timeout;
1532 __le32 fina_timeout;
1533 __le32 unresponded_rts;
1534 __le32 rxe_frame_limit_overrun;
1535 __le32 sent_ack_cnt;
1536 __le32 sent_cts_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07001537 __le32 sent_ba_rsp_cnt;
1538 __le32 dsp_self_kill;
1539 __le32 mh_format_err;
1540 __le32 re_acq_main_rssi_sum;
1541 __le32 reserved3;
Zhu Yib481de92007-09-25 17:54:57 -07001542} __attribute__ ((packed));
1543
Zhu Yib481de92007-09-25 17:54:57 -07001544struct statistics_rx_ht_phy {
1545 __le32 plcp_err;
1546 __le32 overrun_err;
1547 __le32 early_overrun_err;
1548 __le32 crc32_good;
1549 __le32 crc32_err;
1550 __le32 mh_format_err;
1551 __le32 agg_crc32_good;
1552 __le32 agg_mpdu_cnt;
1553 __le32 agg_cnt;
1554 __le32 reserved2;
1555} __attribute__ ((packed));
Zhu Yib481de92007-09-25 17:54:57 -07001556
1557struct statistics_rx_non_phy {
1558 __le32 bogus_cts; /* CTS received when not expecting CTS */
1559 __le32 bogus_ack; /* ACK received when not expecting ACK */
1560 __le32 non_bssid_frames; /* number of frames with BSSID that
1561 * doesn't belong to the STA BSSID */
1562 __le32 filtered_frames; /* count frames that were dumped in the
1563 * filtering process */
1564 __le32 non_channel_beacons; /* beacons with our bss id but not on
1565 * our serving channel */
Zhu Yib481de92007-09-25 17:54:57 -07001566 __le32 channel_beacons; /* beacons with our bss id and in our
1567 * serving channel */
1568 __le32 num_missed_bcon; /* number of missed beacons */
1569 __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
1570 * ADC was in saturation */
1571 __le32 ina_detection_search_time;/* total time (in 0.8us) searched
1572 * for INA */
1573 __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
1574 __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
1575 __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
1576 __le32 interference_data_flag; /* flag for interference data
1577 * availability. 1 when data is
1578 * available. */
1579 __le32 channel_load; /* counts RX Enable time */
1580 __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
1581 * and CCK) counter */
1582 __le32 beacon_rssi_a;
1583 __le32 beacon_rssi_b;
1584 __le32 beacon_rssi_c;
1585 __le32 beacon_energy_a;
1586 __le32 beacon_energy_b;
1587 __le32 beacon_energy_c;
Zhu Yib481de92007-09-25 17:54:57 -07001588} __attribute__ ((packed));
1589
1590struct statistics_rx {
1591 struct statistics_rx_phy ofdm;
1592 struct statistics_rx_phy cck;
1593 struct statistics_rx_non_phy general;
Zhu Yib481de92007-09-25 17:54:57 -07001594 struct statistics_rx_ht_phy ofdm_ht;
Zhu Yib481de92007-09-25 17:54:57 -07001595} __attribute__ ((packed));
1596
Zhu Yib481de92007-09-25 17:54:57 -07001597struct statistics_tx_non_phy_agg {
1598 __le32 ba_timeout;
1599 __le32 ba_reschedule_frames;
1600 __le32 scd_query_agg_frame_cnt;
1601 __le32 scd_query_no_agg;
1602 __le32 scd_query_agg;
1603 __le32 scd_query_mismatch;
1604 __le32 frame_not_ready;
1605 __le32 underrun;
1606 __le32 bt_prio_kill;
1607 __le32 rx_ba_rsp_cnt;
1608 __le32 reserved2;
1609 __le32 reserved3;
1610} __attribute__ ((packed));
Zhu Yib481de92007-09-25 17:54:57 -07001611
1612struct statistics_tx {
1613 __le32 preamble_cnt;
1614 __le32 rx_detected_cnt;
1615 __le32 bt_prio_defer_cnt;
1616 __le32 bt_prio_kill_cnt;
1617 __le32 few_bytes_cnt;
1618 __le32 cts_timeout;
1619 __le32 ack_timeout;
1620 __le32 expected_ack_cnt;
1621 __le32 actual_ack_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07001622 __le32 dump_msdu_cnt;
1623 __le32 burst_abort_next_frame_mismatch_cnt;
1624 __le32 burst_abort_missing_next_frame_cnt;
1625 __le32 cts_timeout_collision;
1626 __le32 ack_or_ba_timeout_collision;
1627 struct statistics_tx_non_phy_agg agg;
Zhu Yib481de92007-09-25 17:54:57 -07001628} __attribute__ ((packed));
1629
1630struct statistics_dbg {
1631 __le32 burst_check;
1632 __le32 burst_count;
1633 __le32 reserved[4];
1634} __attribute__ ((packed));
1635
1636struct statistics_div {
1637 __le32 tx_on_a;
1638 __le32 tx_on_b;
1639 __le32 exec_time;
1640 __le32 probe_time;
Zhu Yib481de92007-09-25 17:54:57 -07001641 __le32 reserved1;
1642 __le32 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -07001643} __attribute__ ((packed));
1644
1645struct statistics_general {
1646 __le32 temperature;
Zhu Yib481de92007-09-25 17:54:57 -07001647 __le32 temperature_m;
Zhu Yib481de92007-09-25 17:54:57 -07001648 struct statistics_dbg dbg;
1649 __le32 sleep_time;
1650 __le32 slots_out;
1651 __le32 slots_idle;
1652 __le32 ttl_timestamp;
1653 struct statistics_div div;
Zhu Yib481de92007-09-25 17:54:57 -07001654 __le32 rx_enable_counter;
1655 __le32 reserved1;
1656 __le32 reserved2;
1657 __le32 reserved3;
Zhu Yib481de92007-09-25 17:54:57 -07001658} __attribute__ ((packed));
1659
1660/*
1661 * REPLY_STATISTICS_CMD = 0x9c,
1662 * 3945 and 4965 identical.
1663 *
1664 * This command triggers an immediate response containing uCode statistics.
1665 * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
1666 *
1667 * If the CLEAR_STATS configuration flag is set, uCode will clear its
1668 * internal copy of the statistics (counters) after issuing the response.
1669 * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
1670 *
1671 * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
1672 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
1673 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
1674 */
1675#define IWL_STATS_CONF_CLEAR_STATS __constant_cpu_to_le32(0x1) /* see above */
1676#define IWL_STATS_CONF_DISABLE_NOTIF __constant_cpu_to_le32(0x2)/* see above */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001677struct iwl4965_statistics_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001678 __le32 configuration_flags; /* IWL_STATS_CONF_* */
1679} __attribute__ ((packed));
1680
1681/*
1682 * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
1683 *
1684 * By default, uCode issues this notification after receiving a beacon
1685 * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
1686 * REPLY_STATISTICS_CMD 0x9c, above.
1687 *
1688 * Statistics counters continue to increment beacon after beacon, but are
1689 * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
1690 * 0x9c with CLEAR_STATS bit set (see above).
1691 *
1692 * uCode also issues this notification during scans. uCode clears statistics
1693 * appropriately so that each notification contains statistics for only the
1694 * one channel that has just been scanned.
1695 */
1696#define STATISTICS_REPLY_FLG_BAND_24G_MSK __constant_cpu_to_le32(0x2)
1697#define STATISTICS_REPLY_FLG_FAT_MODE_MSK __constant_cpu_to_le32(0x8)
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001698struct iwl4965_notif_statistics {
Zhu Yib481de92007-09-25 17:54:57 -07001699 __le32 flag;
1700 struct statistics_rx rx;
1701 struct statistics_tx tx;
1702 struct statistics_general general;
1703} __attribute__ ((packed));
1704
1705
1706/*
1707 * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
1708 */
1709/* if ucode missed CONSECUTIVE_MISSED_BCONS_TH beacons in a row,
1710 * then this notification will be sent. */
1711#define CONSECUTIVE_MISSED_BCONS_TH 20
1712
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001713struct iwl4965_missed_beacon_notif {
Zhu Yib481de92007-09-25 17:54:57 -07001714 __le32 consequtive_missed_beacons;
1715 __le32 total_missed_becons;
1716 __le32 num_expected_beacons;
1717 __le32 num_recvd_beacons;
1718} __attribute__ ((packed));
1719
Ben Cahillf7d09d72007-11-29 11:09:51 +08001720
Zhu Yib481de92007-09-25 17:54:57 -07001721/******************************************************************************
1722 * (11)
1723 * Rx Calibration Commands:
1724 *
Ben Cahillf7d09d72007-11-29 11:09:51 +08001725 * With the uCode used for open source drivers, most Tx calibration (except
1726 * for Tx Power) and most Rx calibration is done by uCode during the
1727 * "initialize" phase of uCode boot. Driver must calibrate only:
1728 *
1729 * 1) Tx power (depends on temperature), described elsewhere
1730 * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
1731 * 3) Receiver sensitivity (to optimize signal detection)
1732 *
Zhu Yib481de92007-09-25 17:54:57 -07001733 *****************************************************************************/
1734
Ben Cahillf7d09d72007-11-29 11:09:51 +08001735/**
1736 * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
1737 *
1738 * This command sets up the Rx signal detector for a sensitivity level that
1739 * is high enough to lock onto all signals within the associated network,
1740 * but low enough to ignore signals that are below a certain threshold, so as
1741 * not to have too many "false alarms". False alarms are signals that the
1742 * Rx DSP tries to lock onto, but then discards after determining that they
1743 * are noise.
1744 *
1745 * The optimum number of false alarms is between 5 and 50 per 200 TUs
1746 * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
1747 * time listening, not transmitting). Driver must adjust sensitivity so that
1748 * the ratio of actual false alarms to actual Rx time falls within this range.
1749 *
1750 * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
1751 * received beacon. These provide information to the driver to analyze the
1752 * sensitivity. Don't analyze statistics that come in from scanning, or any
1753 * other non-associated-network source. Pertinent statistics include:
1754 *
1755 * From "general" statistics (struct statistics_rx_non_phy):
1756 *
1757 * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
1758 * Measure of energy of desired signal. Used for establishing a level
1759 * below which the device does not detect signals.
1760 *
1761 * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
1762 * Measure of background noise in silent period after beacon.
1763 *
1764 * channel_load
1765 * uSecs of actual Rx time during beacon period (varies according to
1766 * how much time was spent transmitting).
1767 *
1768 * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
1769 *
1770 * false_alarm_cnt
1771 * Signal locks abandoned early (before phy-level header).
1772 *
1773 * plcp_err
1774 * Signal locks abandoned late (during phy-level header).
1775 *
1776 * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
1777 * beacon to beacon, i.e. each value is an accumulation of all errors
1778 * before and including the latest beacon. Values will wrap around to 0
1779 * after counting up to 2^32 - 1. Driver must differentiate vs.
1780 * previous beacon's values to determine # false alarms in the current
1781 * beacon period.
1782 *
1783 * Total number of false alarms = false_alarms + plcp_errs
1784 *
1785 * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
1786 * (notice that the start points for OFDM are at or close to settings for
1787 * maximum sensitivity):
1788 *
1789 * START / MIN / MAX
1790 * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120
1791 * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210
1792 * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140
1793 * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270
1794 *
1795 * If actual rate of OFDM false alarms (+ plcp_errors) is too high
1796 * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
1797 * by *adding* 1 to all 4 of the table entries above, up to the max for
1798 * each entry. Conversely, if false alarm rate is too low (less than 5
1799 * for each 204.8 msecs listening), *subtract* 1 from each entry to
1800 * increase sensitivity.
1801 *
1802 * For CCK sensitivity, keep track of the following:
1803 *
1804 * 1). 20-beacon history of maximum background noise, indicated by
1805 * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
1806 * 3 receivers. For any given beacon, the "silence reference" is
1807 * the maximum of last 60 samples (20 beacons * 3 receivers).
1808 *
1809 * 2). 10-beacon history of strongest signal level, as indicated
1810 * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
1811 * i.e. the strength of the signal through the best receiver at the
1812 * moment. These measurements are "upside down", with lower values
1813 * for stronger signals, so max energy will be *minimum* value.
1814 *
1815 * Then for any given beacon, the driver must determine the *weakest*
1816 * of the strongest signals; this is the minimum level that needs to be
1817 * successfully detected, when using the best receiver at the moment.
1818 * "Max cck energy" is the maximum (higher value means lower energy!)
1819 * of the last 10 minima. Once this is determined, driver must add
1820 * a little margin by adding "6" to it.
1821 *
1822 * 3). Number of consecutive beacon periods with too few false alarms.
1823 * Reset this to 0 at the first beacon period that falls within the
1824 * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
1825 *
1826 * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
1827 * (notice that the start points for CCK are at maximum sensitivity):
1828 *
1829 * START / MIN / MAX
1830 * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200
1831 * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400
1832 * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100
1833 *
1834 * If actual rate of CCK false alarms (+ plcp_errors) is too high
1835 * (greater than 50 for each 204.8 msecs listening), method for reducing
1836 * sensitivity is:
1837 *
1838 * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
1839 * up to max 400.
1840 *
1841 * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
1842 * sensitivity has been reduced a significant amount; bring it up to
1843 * a moderate 161. Otherwise, *add* 3, up to max 200.
1844 *
1845 * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
1846 * sensitivity has been reduced only a moderate or small amount;
1847 * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
1848 * down to min 0. Otherwise (if gain has been significantly reduced),
1849 * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
1850 *
1851 * b) Save a snapshot of the "silence reference".
1852 *
1853 * If actual rate of CCK false alarms (+ plcp_errors) is too low
1854 * (less than 5 for each 204.8 msecs listening), method for increasing
1855 * sensitivity is used only if:
1856 *
1857 * 1a) Previous beacon did not have too many false alarms
1858 * 1b) AND difference between previous "silence reference" and current
1859 * "silence reference" (prev - current) is 2 or more,
1860 * OR 2) 100 or more consecutive beacon periods have had rate of
1861 * less than 5 false alarms per 204.8 milliseconds rx time.
1862 *
1863 * Method for increasing sensitivity:
1864 *
1865 * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
1866 * down to min 125.
1867 *
1868 * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
1869 * down to min 200.
1870 *
1871 * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
1872 *
1873 * If actual rate of CCK false alarms (+ plcp_errors) is within good range
1874 * (between 5 and 50 for each 204.8 msecs listening):
1875 *
1876 * 1) Save a snapshot of the silence reference.
1877 *
1878 * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
1879 * give some extra margin to energy threshold by *subtracting* 8
1880 * from value in HD_MIN_ENERGY_CCK_DET_INDEX.
1881 *
1882 * For all cases (too few, too many, good range), make sure that the CCK
1883 * detection threshold (energy) is below the energy level for robust
1884 * detection over the past 10 beacon periods, the "Max cck energy".
1885 * Lower values mean higher energy; this means making sure that the value
1886 * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
1887 *
1888 * Driver should set the following entries to fixed values:
1889 *
1890 * HD_MIN_ENERGY_OFDM_DET_INDEX 100
1891 * HD_BARKER_CORR_TH_ADD_MIN_INDEX 190
1892 * HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX 390
1893 * HD_OFDM_ENERGY_TH_IN_INDEX 62
1894 */
Zhu Yib481de92007-09-25 17:54:57 -07001895
Ben Cahillf7d09d72007-11-29 11:09:51 +08001896/*
1897 * Table entries in SENSITIVITY_CMD (struct iwl4965_sensitivity_cmd)
1898 */
1899#define HD_TABLE_SIZE (11) /* number of entries */
1900#define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */
1901#define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
1902#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
1903#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
1904#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
1905#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
1906#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
1907#define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
1908#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
1909#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
1910#define HD_OFDM_ENERGY_TH_IN_INDEX (10)
1911
1912/* Control field in struct iwl4965_sensitivity_cmd */
1913#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE __constant_cpu_to_le16(0)
1914#define SENSITIVITY_CMD_CONTROL_WORK_TABLE __constant_cpu_to_le16(1)
1915
1916/**
1917 * struct iwl4965_sensitivity_cmd
1918 * @control: (1) updates working table, (0) updates default table
1919 * @table: energy threshold values, use HD_* as index into table
1920 *
1921 * Always use "1" in "control" to update uCode's working table and DSP.
1922 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001923struct iwl4965_sensitivity_cmd {
Ben Cahillf7d09d72007-11-29 11:09:51 +08001924 __le16 control; /* always use "1" */
1925 __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
Zhu Yib481de92007-09-25 17:54:57 -07001926} __attribute__ ((packed));
1927
Ben Cahillf7d09d72007-11-29 11:09:51 +08001928
1929/**
1930 * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
1931 *
1932 * This command sets the relative gains of 4965's 3 radio receiver chains.
1933 *
1934 * After the first association, driver should accumulate signal and noise
1935 * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
1936 * beacons from the associated network (don't collect statistics that come
1937 * in from scanning, or any other non-network source).
1938 *
1939 * DISCONNECTED ANTENNA:
1940 *
1941 * Driver should determine which antennas are actually connected, by comparing
1942 * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
1943 * following values over 20 beacons, one accumulator for each of the chains
1944 * a/b/c, from struct statistics_rx_non_phy:
1945 *
1946 * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
1947 *
1948 * Find the strongest signal from among a/b/c. Compare the other two to the
1949 * strongest. If any signal is more than 15 dB (times 20, unless you
1950 * divide the accumulated values by 20) below the strongest, the driver
1951 * considers that antenna to be disconnected, and should not try to use that
1952 * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
1953 * driver should declare the stronger one as connected, and attempt to use it
1954 * (A and B are the only 2 Tx chains!).
1955 *
1956 *
1957 * RX BALANCE:
1958 *
1959 * Driver should balance the 3 receivers (but just the ones that are connected
1960 * to antennas, see above) for gain, by comparing the average signal levels
1961 * detected during the silence after each beacon (background noise).
1962 * Accumulate (add) the following values over 20 beacons, one accumulator for
1963 * each of the chains a/b/c, from struct statistics_rx_non_phy:
1964 *
1965 * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
1966 *
1967 * Find the weakest background noise level from among a/b/c. This Rx chain
1968 * will be the reference, with 0 gain adjustment. Attenuate other channels by
1969 * finding noise difference:
1970 *
1971 * (accum_noise[i] - accum_noise[reference]) / 30
1972 *
1973 * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
1974 * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
1975 * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
1976 * and set bit 2 to indicate "reduce gain". The value for the reference
1977 * (weakest) chain should be "0".
1978 *
1979 * diff_gain_[abc] bit fields:
1980 * 2: (1) reduce gain, (0) increase gain
1981 * 1-0: amount of gain, units of 1.5 dB
1982 */
1983
1984/* "Differential Gain" opcode used in REPLY_PHY_CALIBRATION_CMD. */
1985#define PHY_CALIBRATE_DIFF_GAIN_CMD (7)
1986
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001987struct iwl4965_calibration_cmd {
Ben Cahillf7d09d72007-11-29 11:09:51 +08001988 u8 opCode; /* PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
1989 u8 flags; /* not used */
Zhu Yib481de92007-09-25 17:54:57 -07001990 __le16 reserved;
Ben Cahillf7d09d72007-11-29 11:09:51 +08001991 s8 diff_gain_a; /* see above */
Zhu Yib481de92007-09-25 17:54:57 -07001992 s8 diff_gain_b;
1993 s8 diff_gain_c;
1994 u8 reserved1;
1995} __attribute__ ((packed));
1996
1997/******************************************************************************
1998 * (12)
1999 * Miscellaneous Commands:
2000 *
2001 *****************************************************************************/
2002
2003/*
2004 * LEDs Command & Response
2005 * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
2006 *
2007 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
2008 * this command turns it on or off, or sets up a periodic blinking cycle.
2009 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002010struct iwl4965_led_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07002011 __le32 interval; /* "interval" in uSec */
2012 u8 id; /* 1: Activity, 2: Link, 3: Tech */
2013 u8 off; /* # intervals off while blinking;
2014 * "0", with >0 "on" value, turns LED on */
2015 u8 on; /* # intervals on while blinking;
2016 * "0", regardless of "off", turns LED off */
2017 u8 reserved;
2018} __attribute__ ((packed));
2019
2020/******************************************************************************
2021 * (13)
2022 * Union of all expected notifications/responses:
2023 *
2024 *****************************************************************************/
2025
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002026struct iwl4965_rx_packet {
Zhu Yib481de92007-09-25 17:54:57 -07002027 __le32 len;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002028 struct iwl4965_cmd_header hdr;
Zhu Yib481de92007-09-25 17:54:57 -07002029 union {
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002030 struct iwl4965_alive_resp alive_frame;
2031 struct iwl4965_rx_frame rx_frame;
2032 struct iwl4965_tx_resp tx_resp;
2033 struct iwl4965_spectrum_notification spectrum_notif;
2034 struct iwl4965_csa_notification csa_notif;
2035 struct iwl4965_error_resp err_resp;
2036 struct iwl4965_card_state_notif card_state_notif;
2037 struct iwl4965_beacon_notif beacon_status;
2038 struct iwl4965_add_sta_resp add_sta;
2039 struct iwl4965_sleep_notification sleep_notif;
2040 struct iwl4965_spectrum_resp spectrum;
2041 struct iwl4965_notif_statistics stats;
2042 struct iwl4965_compressed_ba_resp compressed_ba;
2043 struct iwl4965_missed_beacon_notif missed_beacon;
Zhu Yib481de92007-09-25 17:54:57 -07002044 __le32 status;
2045 u8 raw[0];
2046 } u;
2047} __attribute__ ((packed));
2048
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002049#define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl4965_rx_frame))
Zhu Yib481de92007-09-25 17:54:57 -07002050
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08002051#endif /* __iwl4965_commands_h__ */