blob: 4885971a1536c2b2731eeccb1d581becf388d177 [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-3945-commands.h) only for uCode API definitions.
65 * Please use iwl-3945-hw.h for hardware-related definitions.
66 * Please use iwl-3945.h for driver implementation definitions.
67 */
Zhu Yib481de92007-09-25 17:54:57 -070068
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080069#ifndef __iwl_3945_commands_h__
70#define __iwl_3945_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_3945_RX = 0x1b, /* 3945 only */
Zhu Yib481de92007-09-25 17:54:57 -070089 REPLY_TX = 0x1c,
90 REPLY_RATE_SCALE = 0x47, /* 3945 only */
91 REPLY_LEDS_CMD = 0x48,
92 REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* 4965 only */
93
94 /* 802.11h related */
95 RADAR_NOTIFICATION = 0x70, /* not used */
96 REPLY_QUIET_CMD = 0x71, /* not used */
97 REPLY_CHANNEL_SWITCH = 0x72,
98 CHANNEL_SWITCH_NOTIFICATION = 0x73,
99 REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
100 SPECTRUM_MEASURE_NOTIFICATION = 0x75,
101
102 /* Power Management */
103 POWER_TABLE_CMD = 0x77,
104 PM_SLEEP_NOTIFICATION = 0x7A,
105 PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
106
107 /* Scan commands and notifications */
108 REPLY_SCAN_CMD = 0x80,
109 REPLY_SCAN_ABORT_CMD = 0x81,
110 SCAN_START_NOTIFICATION = 0x82,
111 SCAN_RESULTS_NOTIFICATION = 0x83,
112 SCAN_COMPLETE_NOTIFICATION = 0x84,
113
114 /* IBSS/AP commands */
115 BEACON_NOTIFICATION = 0x90,
116 REPLY_TX_BEACON = 0x91,
117 WHO_IS_AWAKE_NOTIFICATION = 0x94, /* not used */
118
119 /* Miscellaneous commands */
120 QUIET_NOTIFICATION = 0x96, /* not used */
121 REPLY_TX_PWR_TABLE_CMD = 0x97,
122 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
123
Ben Cahill075416c2007-11-29 11:10:08 +0800124 /* Bluetooth device coexistance config command */
Zhu Yib481de92007-09-25 17:54:57 -0700125 REPLY_BT_CONFIG = 0x9b,
126
Ben Cahill80cc0c32007-11-29 11:10:09 +0800127 /* Statistics */
Zhu Yib481de92007-09-25 17:54:57 -0700128 REPLY_STATISTICS_CMD = 0x9c,
129 STATISTICS_NOTIFICATION = 0x9d,
130
131 /* RF-KILL commands and notifications */
132 REPLY_CARD_STATE_CMD = 0xa0,
133 CARD_STATE_NOTIFICATION = 0xa1,
134
135 /* Missed beacons notification */
136 MISSED_BEACONS_NOTIFICATION = 0xa2,
137
Zhu Yib481de92007-09-25 17:54:57 -0700138 REPLY_MAX = 0xff
139};
140
141/******************************************************************************
142 * (0)
Ben Cahill80cc0c32007-11-29 11:10:09 +0800143 * Commonly used structures and definitions:
144 * Command header, txpower
Zhu Yib481de92007-09-25 17:54:57 -0700145 *
146 *****************************************************************************/
147
Ben Cahill075416c2007-11-29 11:10:08 +0800148/* iwl3945_cmd_header flags value */
Zhu Yib481de92007-09-25 17:54:57 -0700149#define IWL_CMD_FAILED_MSK 0x40
150
Ben Cahill075416c2007-11-29 11:10:08 +0800151/**
152 * struct iwl3945_cmd_header
153 *
154 * This header format appears in the beginning of each command sent from the
155 * driver, and each response/notification received from uCode.
156 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800157struct iwl3945_cmd_header {
Ben Cahill075416c2007-11-29 11:10:08 +0800158 u8 cmd; /* Command ID: REPLY_RXON, etc. */
159 u8 flags; /* IWL_CMD_* */
160 /*
161 * The driver sets up the sequence number to values of its chosing.
162 * uCode does not use this value, but passes it back to the driver
163 * when sending the response to each driver-originated command, so
164 * the driver can match the response to the command. Since the values
165 * don't get used by uCode, the driver may set up an arbitrary format.
Zhu Yib481de92007-09-25 17:54:57 -0700166 *
Ben Cahill075416c2007-11-29 11:10:08 +0800167 * There is one exception: uCode sets bit 15 when it originates
168 * the response/notification, i.e. when the response/notification
169 * is not a direct response to a command sent by the driver. For
170 * example, uCode issues REPLY_3945_RX when it sends a received frame
171 * to the driver; it is not a direct response to any driver command.
Zhu Yib481de92007-09-25 17:54:57 -0700172 *
Ben Cahill075416c2007-11-29 11:10:08 +0800173 * The Linux driver uses the following format:
174 *
175 * 0:7 index/position within Tx queue
176 * 8:13 Tx queue selection
177 * 14:14 driver sets this to indicate command is in the 'huge'
178 * storage at the end of the command buffers, i.e. scan cmd
179 * 15:15 uCode sets this in uCode-originated response/notification
Zhu Yib481de92007-09-25 17:54:57 -0700180 */
181 __le16 sequence;
182
Ben Cahill075416c2007-11-29 11:10:08 +0800183 /* command or response/notification data follows immediately */
Zhu Yib481de92007-09-25 17:54:57 -0700184 u8 data[0];
185} __attribute__ ((packed));
186
Ben Cahill80cc0c32007-11-29 11:10:09 +0800187/**
188 * struct iwl3945_tx_power
189 *
190 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH
191 *
192 * Each entry contains two values:
193 * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
194 * linear value that multiplies the output of the digital signal processor,
195 * before being sent to the analog radio.
196 * 2) Radio gain. This sets the analog gain of the radio Tx path.
197 * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
198 *
199 * Driver obtains values from struct iwl3945_tx_power power_gain_table[][].
200 */
201struct iwl3945_tx_power {
202 u8 tx_gain; /* gain for analog radio */
203 u8 dsp_atten; /* gain for DSP */
204} __attribute__ ((packed));
205
206/**
207 * struct iwl3945_power_per_rate
208 *
209 * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
210 */
211struct iwl3945_power_per_rate {
212 u8 rate; /* plcp */
213 struct iwl3945_tx_power tpc;
214 u8 reserved;
215} __attribute__ ((packed));
216
Zhu Yib481de92007-09-25 17:54:57 -0700217/******************************************************************************
218 * (0a)
219 * Alive and Error Commands & Responses:
220 *
221 *****************************************************************************/
222
223#define UCODE_VALID_OK __constant_cpu_to_le32(0x1)
224#define INITIALIZE_SUBTYPE (9)
225
226/*
Ben Cahill075416c2007-11-29 11:10:08 +0800227 * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command)
228 *
229 * uCode issues this "initialize alive" notification once the initialization
230 * uCode image has completed its work, and is ready to load the runtime image.
231 * This is the *first* "alive" notification that the driver will receive after
232 * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
233 *
234 * See comments documenting "BSM" (bootstrap state machine).
Zhu Yib481de92007-09-25 17:54:57 -0700235 */
Ben Cahill075416c2007-11-29 11:10:08 +0800236struct iwl3945_init_alive_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700237 u8 ucode_minor;
238 u8 ucode_major;
239 __le16 reserved1;
240 u8 sw_rev[8];
241 u8 ver_type;
Ben Cahill075416c2007-11-29 11:10:08 +0800242 u8 ver_subtype; /* "9" for initialize alive */
Zhu Yib481de92007-09-25 17:54:57 -0700243 __le16 reserved2;
244 __le32 log_event_table_ptr;
245 __le32 error_event_table_ptr;
246 __le32 timestamp;
247 __le32 is_valid;
248} __attribute__ ((packed));
249
Ben Cahill075416c2007-11-29 11:10:08 +0800250
251/**
252 * REPLY_ALIVE = 0x1 (response only, not a command)
253 *
254 * uCode issues this "alive" notification once the runtime image is ready
255 * to receive commands from the driver. This is the *second* "alive"
256 * notification that the driver will receive after rebooting uCode;
257 * this "alive" is indicated by subtype field != 9.
258 *
259 * See comments documenting "BSM" (bootstrap state machine).
260 *
261 * This response includes two pointers to structures within the device's
262 * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
263 *
264 * 1) log_event_table_ptr indicates base of the event log. This traces
265 * a 256-entry history of uCode execution within a circular buffer.
266 *
267 * 2) error_event_table_ptr indicates base of the error log. This contains
268 * information about any uCode error that occurs.
269 *
270 * The Linux driver can print both logs to the system log when a uCode error
271 * occurs.
272 */
273struct iwl3945_alive_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700274 u8 ucode_minor;
275 u8 ucode_major;
276 __le16 reserved1;
277 u8 sw_rev[8];
278 u8 ver_type;
Ben Cahill075416c2007-11-29 11:10:08 +0800279 u8 ver_subtype; /* not "9" for runtime alive */
Zhu Yib481de92007-09-25 17:54:57 -0700280 __le16 reserved2;
Ben Cahill075416c2007-11-29 11:10:08 +0800281 __le32 log_event_table_ptr; /* SRAM address for event log */
282 __le32 error_event_table_ptr; /* SRAM address for error log */
Zhu Yib481de92007-09-25 17:54:57 -0700283 __le32 timestamp;
284 __le32 is_valid;
Zhu Yib481de92007-09-25 17:54:57 -0700285} __attribute__ ((packed));
286
287union tsf {
288 u8 byte[8];
289 __le16 word[4];
290 __le32 dw[2];
291};
292
293/*
294 * REPLY_ERROR = 0x2 (response only, not a command)
295 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800296struct iwl3945_error_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700297 __le32 error_type;
298 u8 cmd_id;
299 u8 reserved1;
300 __le16 bad_cmd_seq_num;
Zhu Yib481de92007-09-25 17:54:57 -0700301 __le16 reserved2;
Zhu Yib481de92007-09-25 17:54:57 -0700302 __le32 error_info;
303 union tsf timestamp;
304} __attribute__ ((packed));
305
306/******************************************************************************
307 * (1)
308 * RXON Commands & Responses:
309 *
310 *****************************************************************************/
311
312/*
313 * Rx config defines & structure
314 */
315/* rx_config device types */
316enum {
317 RXON_DEV_TYPE_AP = 1,
318 RXON_DEV_TYPE_ESS = 3,
319 RXON_DEV_TYPE_IBSS = 4,
320 RXON_DEV_TYPE_SNIFFER = 6,
321};
322
323/* rx_config flags */
324/* band & modulation selection */
325#define RXON_FLG_BAND_24G_MSK __constant_cpu_to_le32(1 << 0)
326#define RXON_FLG_CCK_MSK __constant_cpu_to_le32(1 << 1)
327/* auto detection enable */
328#define RXON_FLG_AUTO_DETECT_MSK __constant_cpu_to_le32(1 << 2)
329/* TGg protection when tx */
330#define RXON_FLG_TGG_PROTECT_MSK __constant_cpu_to_le32(1 << 3)
331/* cck short slot & preamble */
332#define RXON_FLG_SHORT_SLOT_MSK __constant_cpu_to_le32(1 << 4)
333#define RXON_FLG_SHORT_PREAMBLE_MSK __constant_cpu_to_le32(1 << 5)
334/* antenna selection */
335#define RXON_FLG_DIS_DIV_MSK __constant_cpu_to_le32(1 << 7)
336#define RXON_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0x0f00)
337#define RXON_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
338#define RXON_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
339/* radar detection enable */
340#define RXON_FLG_RADAR_DETECT_MSK __constant_cpu_to_le32(1 << 12)
341#define RXON_FLG_TGJ_NARROW_BAND_MSK __constant_cpu_to_le32(1 << 13)
342/* rx response to host with 8-byte TSF
343* (according to ON_AIR deassertion) */
344#define RXON_FLG_TSF2HOST_MSK __constant_cpu_to_le32(1 << 15)
345
346/* rx_config filter flags */
347/* accept all data frames */
348#define RXON_FILTER_PROMISC_MSK __constant_cpu_to_le32(1 << 0)
349/* pass control & management to host */
350#define RXON_FILTER_CTL2HOST_MSK __constant_cpu_to_le32(1 << 1)
351/* accept multi-cast */
352#define RXON_FILTER_ACCEPT_GRP_MSK __constant_cpu_to_le32(1 << 2)
353/* don't decrypt uni-cast frames */
354#define RXON_FILTER_DIS_DECRYPT_MSK __constant_cpu_to_le32(1 << 3)
355/* don't decrypt multi-cast frames */
356#define RXON_FILTER_DIS_GRP_DECRYPT_MSK __constant_cpu_to_le32(1 << 4)
357/* STA is associated */
358#define RXON_FILTER_ASSOC_MSK __constant_cpu_to_le32(1 << 5)
359/* transfer to host non bssid beacons in associated state */
360#define RXON_FILTER_BCON_AWARE_MSK __constant_cpu_to_le32(1 << 6)
361
Ben Cahill80cc0c32007-11-29 11:10:09 +0800362/**
Zhu Yib481de92007-09-25 17:54:57 -0700363 * REPLY_RXON = 0x10 (command, has simple generic response)
Ben Cahill80cc0c32007-11-29 11:10:09 +0800364 *
365 * RXON tunes the radio tuner to a service channel, and sets up a number
366 * of parameters that are used primarily for Rx, but also for Tx operations.
367 *
368 * NOTE: When tuning to a new channel, driver must set the
369 * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent
370 * info within the device, including the station tables, tx retry
371 * rate tables, and txpower tables. Driver must build a new station
372 * table and txpower table before transmitting anything on the RXON
373 * channel.
374 *
375 * NOTE: All RXONs wipe clean the internal txpower table. Driver must
376 * issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
377 * regardless of whether RXON_FILTER_ASSOC_MSK is set.
Zhu Yib481de92007-09-25 17:54:57 -0700378 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800379struct iwl3945_rxon_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700380 u8 node_addr[6];
381 __le16 reserved1;
382 u8 bssid_addr[6];
383 __le16 reserved2;
384 u8 wlap_bssid_addr[6];
385 __le16 reserved3;
386 u8 dev_type;
387 u8 air_propagation;
Zhu Yib481de92007-09-25 17:54:57 -0700388 __le16 reserved4;
Zhu Yib481de92007-09-25 17:54:57 -0700389 u8 ofdm_basic_rates;
390 u8 cck_basic_rates;
391 __le16 assoc_id;
392 __le32 flags;
393 __le32 filter_flags;
394 __le16 channel;
Zhu Yib481de92007-09-25 17:54:57 -0700395 __le16 reserved5;
Zhu Yib481de92007-09-25 17:54:57 -0700396} __attribute__ ((packed));
397
398/*
399 * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
400 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800401struct iwl3945_rxon_assoc_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700402 __le32 flags;
403 __le32 filter_flags;
404 u8 ofdm_basic_rates;
405 u8 cck_basic_rates;
Zhu Yib481de92007-09-25 17:54:57 -0700406 __le16 reserved;
407} __attribute__ ((packed));
408
409/*
410 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
411 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800412struct iwl3945_rxon_time_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700413 union tsf timestamp;
414 __le16 beacon_interval;
415 __le16 atim_window;
416 __le32 beacon_init_val;
417 __le16 listen_interval;
418 __le16 reserved;
419} __attribute__ ((packed));
420
Zhu Yib481de92007-09-25 17:54:57 -0700421/*
422 * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
423 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800424struct iwl3945_channel_switch_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700425 u8 band;
426 u8 expect_beacon;
427 __le16 channel;
428 __le32 rxon_flags;
429 __le32 rxon_filter_flags;
430 __le32 switch_time;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800431 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
Zhu Yib481de92007-09-25 17:54:57 -0700432} __attribute__ ((packed));
433
434/*
435 * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
436 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800437struct iwl3945_csa_notification {
Zhu Yib481de92007-09-25 17:54:57 -0700438 __le16 band;
439 __le16 channel;
440 __le32 status; /* 0 - OK, 1 - fail */
441} __attribute__ ((packed));
442
443/******************************************************************************
444 * (2)
445 * Quality-of-Service (QOS) Commands & Responses:
446 *
447 *****************************************************************************/
Ben Cahill2054a002007-11-29 11:10:10 +0800448
449/**
450 * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
451 * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
452 *
453 * @cw_min: Contention window, start value in numbers of slots.
454 * Should be a power-of-2, minus 1. Device's default is 0x0f.
455 * @cw_max: Contention window, max value in numbers of slots.
456 * Should be a power-of-2, minus 1. Device's default is 0x3f.
457 * @aifsn: Number of slots in Arbitration Interframe Space (before
458 * performing random backoff timing prior to Tx). Device default 1.
459 * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
460 *
461 * Device will automatically increase contention window by (2*CW) + 1 for each
462 * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
463 * value, to cap the CW value.
464 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800465struct iwl3945_ac_qos {
Zhu Yib481de92007-09-25 17:54:57 -0700466 __le16 cw_min;
467 __le16 cw_max;
468 u8 aifsn;
469 u8 reserved1;
470 __le16 edca_txop;
471} __attribute__ ((packed));
472
473/* QoS flags defines */
474#define QOS_PARAM_FLG_UPDATE_EDCA_MSK __constant_cpu_to_le32(0x01)
475#define QOS_PARAM_FLG_TGN_MSK __constant_cpu_to_le32(0x02)
476#define QOS_PARAM_FLG_TXOP_TYPE_MSK __constant_cpu_to_le32(0x10)
477
Ben Cahill2054a002007-11-29 11:10:10 +0800478/* Number of Access Categories (AC) (EDCA), queues 0..3 */
Zhu Yib481de92007-09-25 17:54:57 -0700479#define AC_NUM 4
480
481/*
482 * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
Ben Cahill2054a002007-11-29 11:10:10 +0800483 *
484 * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
485 * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
Zhu Yib481de92007-09-25 17:54:57 -0700486 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800487struct iwl3945_qosparam_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700488 __le32 qos_flags;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800489 struct iwl3945_ac_qos ac[AC_NUM];
Zhu Yib481de92007-09-25 17:54:57 -0700490} __attribute__ ((packed));
491
492/******************************************************************************
493 * (3)
494 * Add/Modify Stations Commands & Responses:
495 *
496 *****************************************************************************/
497/*
498 * Multi station support
499 */
Ben Cahill2054a002007-11-29 11:10:10 +0800500
501/* Special, dedicated locations within device's station table */
Zhu Yib481de92007-09-25 17:54:57 -0700502#define IWL_AP_ID 0
503#define IWL_MULTICAST_ID 1
504#define IWL_STA_ID 2
Zhu Yib481de92007-09-25 17:54:57 -0700505#define IWL3945_BROADCAST_ID 24
506#define IWL3945_STATION_COUNT 25
507
Zhu Yib481de92007-09-25 17:54:57 -0700508#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
509#define IWL_INVALID_STATION 255
510
Zhu Yib481de92007-09-25 17:54:57 -0700511#define STA_FLG_TX_RATE_MSK __constant_cpu_to_le32(1<<2);
Zhu Yib481de92007-09-25 17:54:57 -0700512#define STA_FLG_PWR_SAVE_MSK __constant_cpu_to_le32(1<<8);
513
Ben Cahill2054a002007-11-29 11:10:10 +0800514/* Use in mode field. 1: modify existing entry, 0: add new station entry */
Zhu Yib481de92007-09-25 17:54:57 -0700515#define STA_CONTROL_MODIFY_MSK 0x01
516
517/* key flags __le16*/
518#define STA_KEY_FLG_ENCRYPT_MSK __constant_cpu_to_le16(0x7)
519#define STA_KEY_FLG_NO_ENC __constant_cpu_to_le16(0x0)
520#define STA_KEY_FLG_WEP __constant_cpu_to_le16(0x1)
521#define STA_KEY_FLG_CCMP __constant_cpu_to_le16(0x2)
522#define STA_KEY_FLG_TKIP __constant_cpu_to_le16(0x3)
523
524#define STA_KEY_FLG_KEYID_POS 8
525#define STA_KEY_FLG_INVALID __constant_cpu_to_le16(0x0800)
526
Ben Cahill2054a002007-11-29 11:10:10 +0800527/* Flags indicate whether to modify vs. don't change various station params */
Zhu Yib481de92007-09-25 17:54:57 -0700528#define STA_MODIFY_KEY_MASK 0x01
529#define STA_MODIFY_TID_DISABLE_TX 0x02
530#define STA_MODIFY_TX_RATE_MSK 0x04
Zhu Yib481de92007-09-25 17:54:57 -0700531
532/*
533 * Antenna masks:
534 * bit14:15 01 B inactive, A active
535 * 10 B active, A inactive
536 * 11 Both active
537 */
538#define RATE_MCS_ANT_A_POS 14
539#define RATE_MCS_ANT_B_POS 15
540#define RATE_MCS_ANT_A_MSK 0x4000
541#define RATE_MCS_ANT_B_MSK 0x8000
542#define RATE_MCS_ANT_AB_MSK 0xc000
543
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800544struct iwl3945_keyinfo {
Zhu Yib481de92007-09-25 17:54:57 -0700545 __le16 key_flags;
546 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
547 u8 reserved1;
548 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
549 __le16 reserved2;
550 u8 key[16]; /* 16-byte unicast decryption key */
551} __attribute__ ((packed));
552
Ben Cahill2054a002007-11-29 11:10:10 +0800553/**
554 * struct sta_id_modify
555 * @addr[ETH_ALEN]: station's MAC address
556 * @sta_id: index of station in uCode's station table
557 * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
558 *
559 * Driver selects unused table index when adding new station,
560 * or the index to a pre-existing station entry when modifying that station.
561 * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
562 *
563 * modify_mask flags select which parameters to modify vs. leave alone.
564 */
Zhu Yib481de92007-09-25 17:54:57 -0700565struct sta_id_modify {
566 u8 addr[ETH_ALEN];
567 __le16 reserved1;
568 u8 sta_id;
569 u8 modify_mask;
570 __le16 reserved2;
571} __attribute__ ((packed));
572
573/*
574 * REPLY_ADD_STA = 0x18 (command)
Ben Cahill2054a002007-11-29 11:10:10 +0800575 *
576 * The device contains an internal table of per-station information,
577 * with info on security keys, aggregation parameters, and Tx rates for
578 * initial Tx attempt and any retries (4965 uses REPLY_TX_LINK_QUALITY_CMD,
579 * 3945 uses REPLY_RATE_SCALE to set up rate tables).
580 *
581 * REPLY_ADD_STA sets up the table entry for one station, either creating
582 * a new entry, or modifying a pre-existing one.
583 *
584 * NOTE: RXON command (without "associated" bit set) wipes the station table
585 * clean. Moving into RF_KILL state does this also. Driver must set up
586 * new station table before transmitting anything on the RXON channel
587 * (except active scans or active measurements; those commands carry
588 * their own txpower/rate setup data).
589 *
590 * When getting started on a new channel, driver must set up the
591 * IWL_BROADCAST_ID entry (last entry in the table). For a client
592 * station in a BSS, once an AP is selected, driver sets up the AP STA
593 * in the IWL_AP_ID entry (1st entry in the table). BROADCAST and AP
594 * are all that are needed for a BSS client station. If the device is
595 * used as AP, or in an IBSS network, driver must set up station table
596 * entries for all STAs in network, starting with index IWL_STA_ID.
Zhu Yib481de92007-09-25 17:54:57 -0700597 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800598struct iwl3945_addsta_cmd {
Ben Cahill2054a002007-11-29 11:10:10 +0800599 u8 mode; /* 1: modify existing, 0: add new station */
Zhu Yib481de92007-09-25 17:54:57 -0700600 u8 reserved[3];
601 struct sta_id_modify sta;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800602 struct iwl3945_keyinfo key;
Ben Cahill2054a002007-11-29 11:10:10 +0800603 __le32 station_flags; /* STA_FLG_* */
604 __le32 station_flags_msk; /* STA_FLG_* */
605
606 /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
607 * corresponding to bit (e.g. bit 5 controls TID 5).
608 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -0700609 __le16 tid_disable_tx;
Ben Cahill2054a002007-11-29 11:10:10 +0800610
Zhu Yib481de92007-09-25 17:54:57 -0700611 __le16 rate_n_flags;
Ben Cahill2054a002007-11-29 11:10:10 +0800612
613 /* TID for which to add block-ack support.
614 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -0700615 u8 add_immediate_ba_tid;
Ben Cahill2054a002007-11-29 11:10:10 +0800616
617 /* TID for which to remove block-ack support.
618 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -0700619 u8 remove_immediate_ba_tid;
Ben Cahill2054a002007-11-29 11:10:10 +0800620
621 /* Starting Sequence Number for added block-ack support.
622 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
Zhu Yib481de92007-09-25 17:54:57 -0700623 __le16 add_immediate_ba_ssn;
Zhu Yib481de92007-09-25 17:54:57 -0700624} __attribute__ ((packed));
625
Ben Cahill2054a002007-11-29 11:10:10 +0800626#define ADD_STA_SUCCESS_MSK 0x1
627#define ADD_STA_NO_ROOM_IN_TABLE 0x2
628#define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4
Zhu Yib481de92007-09-25 17:54:57 -0700629/*
630 * REPLY_ADD_STA = 0x18 (response)
631 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800632struct iwl3945_add_sta_resp {
Ben Cahill2054a002007-11-29 11:10:10 +0800633 u8 status; /* ADD_STA_* */
Zhu Yib481de92007-09-25 17:54:57 -0700634} __attribute__ ((packed));
635
Zhu Yib481de92007-09-25 17:54:57 -0700636
637/******************************************************************************
638 * (4)
639 * Rx Responses:
640 *
641 *****************************************************************************/
642
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800643struct iwl3945_rx_frame_stats {
Zhu Yib481de92007-09-25 17:54:57 -0700644 u8 phy_count;
645 u8 id;
646 u8 rssi;
647 u8 agc;
648 __le16 sig_avg;
649 __le16 noise_diff;
650 u8 payload[0];
651} __attribute__ ((packed));
652
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800653struct iwl3945_rx_frame_hdr {
Zhu Yib481de92007-09-25 17:54:57 -0700654 __le16 channel;
655 __le16 phy_flags;
656 u8 reserved1;
657 u8 rate;
658 __le16 len;
659 u8 payload[0];
660} __attribute__ ((packed));
661
662#define RX_RES_STATUS_NO_CRC32_ERROR __constant_cpu_to_le32(1 << 0)
663#define RX_RES_STATUS_NO_RXE_OVERFLOW __constant_cpu_to_le32(1 << 1)
664
665#define RX_RES_PHY_FLAGS_BAND_24_MSK __constant_cpu_to_le16(1 << 0)
666#define RX_RES_PHY_FLAGS_MOD_CCK_MSK __constant_cpu_to_le16(1 << 1)
667#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK __constant_cpu_to_le16(1 << 2)
668#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK __constant_cpu_to_le16(1 << 3)
669#define RX_RES_PHY_FLAGS_ANTENNA_MSK __constant_cpu_to_le16(0xf0)
670
671#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
672#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
673#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
674#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
675#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
676
677#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
678#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
679#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
680#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
681#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
682
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800683struct iwl3945_rx_frame_end {
Zhu Yib481de92007-09-25 17:54:57 -0700684 __le32 status;
685 __le64 timestamp;
686 __le32 beacon_timestamp;
687} __attribute__ ((packed));
688
689/*
690 * REPLY_3945_RX = 0x1b (response only, not a command)
691 *
692 * NOTE: DO NOT dereference from casts to this structure
693 * It is provided only for calculating minimum data set size.
694 * The actual offsets of the hdr and end are dynamic based on
695 * stats.phy_count
696 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800697struct iwl3945_rx_frame {
698 struct iwl3945_rx_frame_stats stats;
699 struct iwl3945_rx_frame_hdr hdr;
700 struct iwl3945_rx_frame_end end;
Zhu Yib481de92007-09-25 17:54:57 -0700701} __attribute__ ((packed));
702
703/* Fixed (non-configurable) rx data from phy */
704#define RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
705#define RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
706#define IWL_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
707#define IWL_AGC_DB_POS (7)
708struct iwl4965_rx_non_cfg_phy {
709 __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
710 __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
711 u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
712 u8 pad[0];
713} __attribute__ ((packed));
714
715/*
716 * REPLY_4965_RX = 0xc3 (response only, not a command)
717 * Used only for legacy (non 11n) frames.
718 */
719#define RX_RES_PHY_CNT 14
720struct iwl4965_rx_phy_res {
721 u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
722 u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
723 u8 stat_id; /* configurable DSP phy data set ID */
724 u8 reserved1;
725 __le64 timestamp; /* TSF at on air rise */
726 __le32 beacon_time_stamp; /* beacon at on-air rise */
727 __le16 phy_flags; /* general phy flags: band, modulation, ... */
728 __le16 channel; /* channel number */
729 __le16 non_cfg_phy[RX_RES_PHY_CNT]; /* upto 14 phy entries */
730 __le32 reserved2;
731 __le32 rate_n_flags;
732 __le16 byte_count; /* frame's byte-count */
733 __le16 reserved3;
734} __attribute__ ((packed));
735
736struct iwl4965_rx_mpdu_res_start {
737 __le16 byte_count;
738 __le16 reserved;
739} __attribute__ ((packed));
740
741
742/******************************************************************************
743 * (5)
744 * Tx Commands & Responses:
745 *
746 *****************************************************************************/
747
748/* Tx flags */
749#define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1)
750#define TX_CMD_FLG_CTS_MSK __constant_cpu_to_le32(1 << 2)
751#define TX_CMD_FLG_ACK_MSK __constant_cpu_to_le32(1 << 3)
752#define TX_CMD_FLG_STA_RATE_MSK __constant_cpu_to_le32(1 << 4)
753#define TX_CMD_FLG_IMM_BA_RSP_MASK __constant_cpu_to_le32(1 << 6)
754#define TX_CMD_FLG_FULL_TXOP_PROT_MSK __constant_cpu_to_le32(1 << 7)
755#define TX_CMD_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0xf00)
756#define TX_CMD_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
757#define TX_CMD_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
758
759/* ucode ignores BT priority for this frame */
760#define TX_CMD_FLG_BT_DIS_MSK __constant_cpu_to_le32(1 << 12)
761
762/* ucode overrides sequence control */
763#define TX_CMD_FLG_SEQ_CTL_MSK __constant_cpu_to_le32(1 << 13)
764
765/* signal that this frame is non-last MPDU */
766#define TX_CMD_FLG_MORE_FRAG_MSK __constant_cpu_to_le32(1 << 14)
767
768/* calculate TSF in outgoing frame */
769#define TX_CMD_FLG_TSF_MSK __constant_cpu_to_le32(1 << 16)
770
771/* activate TX calibration. */
772#define TX_CMD_FLG_CALIB_MSK __constant_cpu_to_le32(1 << 17)
773
774/* signals that 2 bytes pad was inserted
775 after the MAC header */
776#define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20)
777
778/* HCCA-AP - disable duration overwriting. */
779#define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25)
780
781/*
782 * TX command security control
783 */
784#define TX_CMD_SEC_WEP 0x01
785#define TX_CMD_SEC_CCM 0x02
786#define TX_CMD_SEC_TKIP 0x03
787#define TX_CMD_SEC_MSK 0x03
788#define TX_CMD_SEC_SHIFT 6
789#define TX_CMD_SEC_KEY128 0x08
790
791/*
792 * TX command Frame life time
793 */
794
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800795struct iwl3945_dram_scratch {
Zhu Yib481de92007-09-25 17:54:57 -0700796 u8 try_cnt;
797 u8 bt_kill_cnt;
798 __le16 reserved;
799} __attribute__ ((packed));
800
801/*
802 * REPLY_TX = 0x1c (command)
803 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800804struct iwl3945_tx_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700805 __le16 len;
806 __le16 next_frame_len;
807 __le32 tx_flags;
Zhu Yib481de92007-09-25 17:54:57 -0700808 u8 rate;
809 u8 sta_id;
810 u8 tid_tspec;
Zhu Yib481de92007-09-25 17:54:57 -0700811 u8 sec_ctl;
Zhu Yib481de92007-09-25 17:54:57 -0700812 u8 key[16];
Zhu Yib481de92007-09-25 17:54:57 -0700813 union {
814 u8 byte[8];
815 __le16 word[4];
816 __le32 dw[2];
817 } tkip_mic;
818 __le32 next_frame_info;
Zhu Yib481de92007-09-25 17:54:57 -0700819 union {
820 __le32 life_time;
821 __le32 attempt;
822 } stop_time;
Zhu Yib481de92007-09-25 17:54:57 -0700823 u8 supp_rates[2];
Zhu Yib481de92007-09-25 17:54:57 -0700824 u8 rts_retry_limit; /*byte 50 */
825 u8 data_retry_limit; /*byte 51 */
Zhu Yib481de92007-09-25 17:54:57 -0700826 union {
827 __le16 pm_frame_timeout;
828 __le16 attempt_duration;
829 } timeout;
830 __le16 driver_txop;
831 u8 payload[0];
832 struct ieee80211_hdr hdr[0];
833} __attribute__ ((packed));
834
835/* TX command response is sent after *all* transmission attempts.
836 *
837 * NOTES:
838 *
839 * TX_STATUS_FAIL_NEXT_FRAG
840 *
841 * If the fragment flag in the MAC header for the frame being transmitted
842 * is set and there is insufficient time to transmit the next frame, the
843 * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
844 *
845 * TX_STATUS_FIFO_UNDERRUN
846 *
847 * Indicates the host did not provide bytes to the FIFO fast enough while
848 * a TX was in progress.
849 *
850 * TX_STATUS_FAIL_MGMNT_ABORT
851 *
852 * This status is only possible if the ABORT ON MGMT RX parameter was
853 * set to true with the TX command.
854 *
855 * If the MSB of the status parameter is set then an abort sequence is
856 * required. This sequence consists of the host activating the TX Abort
857 * control line, and then waiting for the TX Abort command response. This
858 * indicates that a the device is no longer in a transmit state, and that the
859 * command FIFO has been cleared. The host must then deactivate the TX Abort
860 * control line. Receiving is still allowed in this case.
861 */
862enum {
863 TX_STATUS_SUCCESS = 0x01,
864 TX_STATUS_DIRECT_DONE = 0x02,
865 TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
866 TX_STATUS_FAIL_LONG_LIMIT = 0x83,
867 TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
868 TX_STATUS_FAIL_MGMNT_ABORT = 0x85,
869 TX_STATUS_FAIL_NEXT_FRAG = 0x86,
870 TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
871 TX_STATUS_FAIL_DEST_PS = 0x88,
872 TX_STATUS_FAIL_ABORTED = 0x89,
873 TX_STATUS_FAIL_BT_RETRY = 0x8a,
874 TX_STATUS_FAIL_STA_INVALID = 0x8b,
875 TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
876 TX_STATUS_FAIL_TID_DISABLE = 0x8d,
877 TX_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
878 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
879 TX_STATUS_FAIL_TX_LOCKED = 0x90,
880 TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
881};
882
883#define TX_PACKET_MODE_REGULAR 0x0000
884#define TX_PACKET_MODE_BURST_SEQ 0x0100
885#define TX_PACKET_MODE_BURST_FIRST 0x0200
886
887enum {
888 TX_POWER_PA_NOT_ACTIVE = 0x0,
889};
890
891enum {
892 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
893 TX_STATUS_DELAY_MSK = 0x00000040,
894 TX_STATUS_ABORT_MSK = 0x00000080,
895 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
896 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
897 TX_RESERVED = 0x00780000, /* bits 19:22 */
898 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
899 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
900};
901
902/* *******************************
903 * TX aggregation state
904 ******************************* */
905
906enum {
907 AGG_TX_STATE_TRANSMITTED = 0x00,
908 AGG_TX_STATE_UNDERRUN_MSK = 0x01,
909 AGG_TX_STATE_BT_PRIO_MSK = 0x02,
910 AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
911 AGG_TX_STATE_ABORT_MSK = 0x08,
912 AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
913 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
914 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
915 AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
916 AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
917 AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
918 AGG_TX_STATE_DUMP_TX_MSK = 0x200,
919 AGG_TX_STATE_DELAY_TX_MSK = 0x400
920};
921
922#define AGG_TX_STATE_LAST_SENT_MSK \
923(AGG_TX_STATE_LAST_SENT_TTL_MSK | \
924 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
925 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
926
927#define AGG_TX_STATE_TRY_CNT_POS 12
928#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
929
930#define AGG_TX_STATE_SEQ_NUM_POS 16
931#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
932
933/*
934 * REPLY_TX = 0x1c (response)
935 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800936struct iwl3945_tx_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700937 u8 failure_rts;
938 u8 failure_frame;
939 u8 bt_kill_count;
940 u8 rate;
941 __le32 wireless_media_time;
942 __le32 status; /* TX status (for aggregation status of 1st frame) */
943} __attribute__ ((packed));
Zhu Yib481de92007-09-25 17:54:57 -0700944
945/*
946 * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
947 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800948struct iwl3945_compressed_ba_resp {
Zhu Yib481de92007-09-25 17:54:57 -0700949 __le32 sta_addr_lo32;
950 __le16 sta_addr_hi16;
951 __le16 reserved;
952 u8 sta_id;
953 u8 tid;
954 __le16 ba_seq_ctl;
955 __le32 ba_bitmap0;
956 __le32 ba_bitmap1;
957 __le16 scd_flow;
958 __le16 scd_ssn;
959} __attribute__ ((packed));
960
961/*
962 * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
963 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800964struct iwl3945_txpowertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700965 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
966 u8 reserved;
967 __le16 channel;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800968 struct iwl3945_power_per_rate power[IWL_MAX_RATES];
Zhu Yib481de92007-09-25 17:54:57 -0700969} __attribute__ ((packed));
970
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800971struct iwl3945_rate_scaling_info {
Zhu Yib481de92007-09-25 17:54:57 -0700972 __le16 rate_n_flags;
973 u8 try_cnt;
974 u8 next_rate_index;
975} __attribute__ ((packed));
976
977/**
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800978 * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response
Zhu Yib481de92007-09-25 17:54:57 -0700979 *
980 * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
981 *
982 * NOTE: The table of rates passed to the uCode via the
983 * RATE_SCALE command sets up the corresponding order of
984 * rates used for all related commands, including rate
985 * masks, etc.
986 *
987 * For example, if you set 9MB (PLCP 0x0f) as the first
988 * rate in the rate table, the bit mask for that rate
989 * when passed through ofdm_basic_rates on the REPLY_RXON
990 * command would be bit 0 (1<<0)
991 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800992struct iwl3945_rate_scaling_cmd {
Zhu Yib481de92007-09-25 17:54:57 -0700993 u8 table_id;
994 u8 reserved[3];
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800995 struct iwl3945_rate_scaling_info table[IWL_MAX_RATES];
Zhu Yib481de92007-09-25 17:54:57 -0700996} __attribute__ ((packed));
997
Zhu Yib481de92007-09-25 17:54:57 -0700998/*
999 * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
1000 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001001struct iwl3945_bt_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001002 u8 flags;
1003 u8 lead_time;
1004 u8 max_kill;
1005 u8 reserved;
1006 __le32 kill_ack_mask;
1007 __le32 kill_cts_mask;
1008} __attribute__ ((packed));
1009
1010/******************************************************************************
1011 * (6)
1012 * Spectrum Management (802.11h) Commands, Responses, Notifications:
1013 *
1014 *****************************************************************************/
1015
1016/*
1017 * Spectrum Management
1018 */
1019#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
1020 RXON_FILTER_CTL2HOST_MSK | \
1021 RXON_FILTER_ACCEPT_GRP_MSK | \
1022 RXON_FILTER_DIS_DECRYPT_MSK | \
1023 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
1024 RXON_FILTER_ASSOC_MSK | \
1025 RXON_FILTER_BCON_AWARE_MSK)
1026
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001027struct iwl3945_measure_channel {
Zhu Yib481de92007-09-25 17:54:57 -07001028 __le32 duration; /* measurement duration in extended beacon
1029 * format */
1030 u8 channel; /* channel to measure */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001031 u8 type; /* see enum iwl3945_measure_type */
Zhu Yib481de92007-09-25 17:54:57 -07001032 __le16 reserved;
1033} __attribute__ ((packed));
1034
1035/*
1036 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
1037 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001038struct iwl3945_spectrum_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001039 __le16 len; /* number of bytes starting from token */
1040 u8 token; /* token id */
1041 u8 id; /* measurement id -- 0 or 1 */
1042 u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
1043 u8 periodic; /* 1 = periodic */
1044 __le16 path_loss_timeout;
1045 __le32 start_time; /* start time in extended beacon format */
1046 __le32 reserved2;
1047 __le32 flags; /* rxon flags */
1048 __le32 filter_flags; /* rxon filter flags */
1049 __le16 channel_count; /* minimum 1, maximum 10 */
1050 __le16 reserved3;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001051 struct iwl3945_measure_channel channels[10];
Zhu Yib481de92007-09-25 17:54:57 -07001052} __attribute__ ((packed));
1053
1054/*
1055 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
1056 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001057struct iwl3945_spectrum_resp {
Zhu Yib481de92007-09-25 17:54:57 -07001058 u8 token;
1059 u8 id; /* id of the prior command replaced, or 0xff */
1060 __le16 status; /* 0 - command will be handled
1061 * 1 - cannot handle (conflicts with another
1062 * measurement) */
1063} __attribute__ ((packed));
1064
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001065enum iwl3945_measurement_state {
Zhu Yib481de92007-09-25 17:54:57 -07001066 IWL_MEASUREMENT_START = 0,
1067 IWL_MEASUREMENT_STOP = 1,
1068};
1069
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001070enum iwl3945_measurement_status {
Zhu Yib481de92007-09-25 17:54:57 -07001071 IWL_MEASUREMENT_OK = 0,
1072 IWL_MEASUREMENT_CONCURRENT = 1,
1073 IWL_MEASUREMENT_CSA_CONFLICT = 2,
1074 IWL_MEASUREMENT_TGH_CONFLICT = 3,
1075 /* 4-5 reserved */
1076 IWL_MEASUREMENT_STOPPED = 6,
1077 IWL_MEASUREMENT_TIMEOUT = 7,
1078 IWL_MEASUREMENT_PERIODIC_FAILED = 8,
1079};
1080
1081#define NUM_ELEMENTS_IN_HISTOGRAM 8
1082
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001083struct iwl3945_measurement_histogram {
Zhu Yib481de92007-09-25 17:54:57 -07001084 __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
1085 __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
1086} __attribute__ ((packed));
1087
1088/* clear channel availability counters */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001089struct iwl3945_measurement_cca_counters {
Zhu Yib481de92007-09-25 17:54:57 -07001090 __le32 ofdm;
1091 __le32 cck;
1092} __attribute__ ((packed));
1093
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001094enum iwl3945_measure_type {
Zhu Yib481de92007-09-25 17:54:57 -07001095 IWL_MEASURE_BASIC = (1 << 0),
1096 IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
1097 IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
1098 IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
1099 IWL_MEASURE_FRAME = (1 << 4),
1100 /* bits 5:6 are reserved */
1101 IWL_MEASURE_IDLE = (1 << 7),
1102};
1103
1104/*
1105 * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
1106 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001107struct iwl3945_spectrum_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001108 u8 id; /* measurement id -- 0 or 1 */
1109 u8 token;
1110 u8 channel_index; /* index in measurement channel list */
1111 u8 state; /* 0 - start, 1 - stop */
1112 __le32 start_time; /* lower 32-bits of TSF */
1113 u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
1114 u8 channel;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001115 u8 type; /* see enum iwl3945_measurement_type */
Zhu Yib481de92007-09-25 17:54:57 -07001116 u8 reserved1;
1117 /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
1118 * valid if applicable for measurement type requested. */
1119 __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
1120 __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
1121 __le32 cca_time; /* channel load time in usecs */
1122 u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
1123 * unidentified */
1124 u8 reserved2[3];
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001125 struct iwl3945_measurement_histogram histogram;
Zhu Yib481de92007-09-25 17:54:57 -07001126 __le32 stop_time; /* lower 32-bits of TSF */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001127 __le32 status; /* see iwl3945_measurement_status */
Zhu Yib481de92007-09-25 17:54:57 -07001128} __attribute__ ((packed));
1129
1130/******************************************************************************
1131 * (7)
1132 * Power Management Commands, Responses, Notifications:
1133 *
1134 *****************************************************************************/
1135
1136/**
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001137 * struct iwl3945_powertable_cmd - Power Table Command
Zhu Yib481de92007-09-25 17:54:57 -07001138 * @flags: See below:
1139 *
1140 * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
1141 *
1142 * PM allow:
1143 * bit 0 - '0' Driver not allow power management
1144 * '1' Driver allow PM (use rest of parameters)
1145 * uCode send sleep notifications:
1146 * bit 1 - '0' Don't send sleep notification
1147 * '1' send sleep notification (SEND_PM_NOTIFICATION)
1148 * Sleep over DTIM
1149 * bit 2 - '0' PM have to walk up every DTIM
1150 * '1' PM could sleep over DTIM till listen Interval.
1151 * PCI power managed
1152 * bit 3 - '0' (PCI_LINK_CTRL & 0x1)
1153 * '1' !(PCI_LINK_CTRL & 0x1)
1154 * Force sleep Modes
1155 * bit 31/30- '00' use both mac/xtal sleeps
1156 * '01' force Mac sleep
1157 * '10' force xtal sleep
1158 * '11' Illegal set
1159 *
1160 * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
1161 * ucode assume sleep over DTIM is allowed and we don't need to wakeup
1162 * for every DTIM.
1163 */
1164#define IWL_POWER_VEC_SIZE 5
1165
Zhu Yib481de92007-09-25 17:54:57 -07001166#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK __constant_cpu_to_le32(1<<0)
1167#define IWL_POWER_SLEEP_OVER_DTIM_MSK __constant_cpu_to_le32(1<<2)
1168#define IWL_POWER_PCI_PM_MSK __constant_cpu_to_le32(1<<3)
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001169struct iwl3945_powertable_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001170 __le32 flags;
1171 __le32 rx_data_timeout;
1172 __le32 tx_data_timeout;
1173 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
1174} __attribute__((packed));
1175
Zhu Yib481de92007-09-25 17:54:57 -07001176/*
1177 * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
1178 * 3945 and 4965 identical.
1179 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001180struct iwl3945_sleep_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001181 u8 pm_sleep_mode;
1182 u8 pm_wakeup_src;
1183 __le16 reserved;
1184 __le32 sleep_time;
1185 __le32 tsf_low;
1186 __le32 bcon_timer;
1187} __attribute__ ((packed));
1188
1189/* Sleep states. 3945 and 4965 identical. */
1190enum {
1191 IWL_PM_NO_SLEEP = 0,
1192 IWL_PM_SLP_MAC = 1,
1193 IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
1194 IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
1195 IWL_PM_SLP_PHY = 4,
1196 IWL_PM_SLP_REPENT = 5,
1197 IWL_PM_WAKEUP_BY_TIMER = 6,
1198 IWL_PM_WAKEUP_BY_DRIVER = 7,
1199 IWL_PM_WAKEUP_BY_RFKILL = 8,
1200 /* 3 reserved */
1201 IWL_PM_NUM_OF_MODES = 12,
1202};
1203
1204/*
1205 * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
1206 */
1207#define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
1208#define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
1209#define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001210struct iwl3945_card_state_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001211 __le32 status; /* CARD_STATE_CMD_* request new power state */
1212} __attribute__ ((packed));
1213
1214/*
1215 * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
1216 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001217struct iwl3945_card_state_notif {
Zhu Yib481de92007-09-25 17:54:57 -07001218 __le32 flags;
1219} __attribute__ ((packed));
1220
1221#define HW_CARD_DISABLED 0x01
1222#define SW_CARD_DISABLED 0x02
1223#define RF_CARD_DISABLED 0x04
1224#define RXON_CARD_DISABLED 0x10
1225
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001226struct iwl3945_ct_kill_config {
Zhu Yib481de92007-09-25 17:54:57 -07001227 __le32 reserved;
1228 __le32 critical_temperature_M;
1229 __le32 critical_temperature_R;
1230} __attribute__ ((packed));
1231
1232/******************************************************************************
1233 * (8)
1234 * Scan Commands, Responses, Notifications:
1235 *
1236 *****************************************************************************/
1237
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001238struct iwl3945_scan_channel {
Zhu Yib481de92007-09-25 17:54:57 -07001239 /* type is defined as:
1240 * 0:0 active (0 - passive)
1241 * 1:4 SSID direct
1242 * If 1 is set then corresponding SSID IE is transmitted in probe
1243 * 5:7 reserved
1244 */
1245 u8 type;
1246 u8 channel;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001247 struct iwl3945_tx_power tpc;
Zhu Yib481de92007-09-25 17:54:57 -07001248 __le16 active_dwell;
1249 __le16 passive_dwell;
1250} __attribute__ ((packed));
1251
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001252struct iwl3945_ssid_ie {
Zhu Yib481de92007-09-25 17:54:57 -07001253 u8 id;
1254 u8 len;
1255 u8 ssid[32];
1256} __attribute__ ((packed));
1257
1258#define PROBE_OPTION_MAX 0x4
1259#define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF)
1260#define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1)
1261#define IWL_MAX_SCAN_SIZE 1024
1262
1263/*
1264 * REPLY_SCAN_CMD = 0x80 (command)
1265 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001266struct iwl3945_scan_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001267 __le16 len;
1268 u8 reserved0;
1269 u8 channel_count;
1270 __le16 quiet_time; /* dwell only this long on quiet chnl
1271 * (active scan) */
1272 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
1273 __le16 good_CRC_th; /* passive -> active promotion threshold */
Zhu Yib481de92007-09-25 17:54:57 -07001274 __le16 reserved1;
Zhu Yib481de92007-09-25 17:54:57 -07001275 __le32 max_out_time; /* max usec to be out of associated (service)
1276 * chnl */
1277 __le32 suspend_time; /* pause scan this long when returning to svc
1278 * chnl.
1279 * 3945 -- 31:24 # beacons, 19:0 additional usec,
1280 * 4965 -- 31:22 # beacons, 21:0 additional usec.
1281 */
1282 __le32 flags;
1283 __le32 filter_flags;
1284
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001285 struct iwl3945_tx_cmd tx_cmd;
1286 struct iwl3945_ssid_ie direct_scan[PROBE_OPTION_MAX];
Zhu Yib481de92007-09-25 17:54:57 -07001287
1288 u8 data[0];
1289 /*
1290 * The channels start after the probe request payload and are of type:
1291 *
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001292 * struct iwl3945_scan_channel channels[0];
Zhu Yib481de92007-09-25 17:54:57 -07001293 *
1294 * NOTE: Only one band of channels can be scanned per pass. You
1295 * can not mix 2.4GHz channels and 5.2GHz channels and must
1296 * request a scan multiple times (not concurrently)
1297 *
1298 */
1299} __attribute__ ((packed));
1300
1301/* Can abort will notify by complete notification with abort status. */
1302#define CAN_ABORT_STATUS __constant_cpu_to_le32(0x1)
1303/* complete notification statuses */
1304#define ABORT_STATUS 0x2
1305
1306/*
1307 * REPLY_SCAN_CMD = 0x80 (response)
1308 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001309struct iwl3945_scanreq_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001310 __le32 status; /* 1: okay, 2: cannot fulfill request */
1311} __attribute__ ((packed));
1312
1313/*
1314 * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
1315 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001316struct iwl3945_scanstart_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001317 __le32 tsf_low;
1318 __le32 tsf_high;
1319 __le32 beacon_timer;
1320 u8 channel;
1321 u8 band;
1322 u8 reserved[2];
1323 __le32 status;
1324} __attribute__ ((packed));
1325
1326#define SCAN_OWNER_STATUS 0x1;
1327#define MEASURE_OWNER_STATUS 0x2;
1328
1329#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
1330/*
1331 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
1332 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001333struct iwl3945_scanresults_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001334 u8 channel;
1335 u8 band;
1336 u8 reserved[2];
1337 __le32 tsf_low;
1338 __le32 tsf_high;
1339 __le32 statistics[NUMBER_OF_STATISTICS];
1340} __attribute__ ((packed));
1341
1342/*
1343 * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
1344 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001345struct iwl3945_scancomplete_notification {
Zhu Yib481de92007-09-25 17:54:57 -07001346 u8 scanned_channels;
1347 u8 status;
1348 u8 reserved;
1349 u8 last_channel;
1350 __le32 tsf_low;
1351 __le32 tsf_high;
1352} __attribute__ ((packed));
1353
1354
1355/******************************************************************************
1356 * (9)
1357 * IBSS/AP Commands and Notifications:
1358 *
1359 *****************************************************************************/
1360
1361/*
1362 * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
1363 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001364struct iwl3945_beacon_notif {
1365 struct iwl3945_tx_resp beacon_notify_hdr;
Zhu Yib481de92007-09-25 17:54:57 -07001366 __le32 low_tsf;
1367 __le32 high_tsf;
1368 __le32 ibss_mgr_status;
1369} __attribute__ ((packed));
1370
1371/*
1372 * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
1373 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001374struct iwl3945_tx_beacon_cmd {
1375 struct iwl3945_tx_cmd tx;
Zhu Yib481de92007-09-25 17:54:57 -07001376 __le16 tim_idx;
1377 u8 tim_size;
1378 u8 reserved1;
1379 struct ieee80211_hdr frame[0]; /* beacon frame */
1380} __attribute__ ((packed));
1381
1382/******************************************************************************
1383 * (10)
1384 * Statistics Commands and Notifications:
1385 *
1386 *****************************************************************************/
1387
1388#define IWL_TEMP_CONVERT 260
1389
1390#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
1391#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
1392#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
1393
1394/* Used for passing to driver number of successes and failures per rate */
1395struct rate_histogram {
1396 union {
1397 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
1398 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
1399 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
1400 } success;
1401 union {
1402 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
1403 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
1404 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
1405 } failed;
1406} __attribute__ ((packed));
1407
1408/* statistics command response */
1409
1410struct statistics_rx_phy {
1411 __le32 ina_cnt;
1412 __le32 fina_cnt;
1413 __le32 plcp_err;
1414 __le32 crc32_err;
1415 __le32 overrun_err;
1416 __le32 early_overrun_err;
1417 __le32 crc32_good;
1418 __le32 false_alarm_cnt;
1419 __le32 fina_sync_err_cnt;
1420 __le32 sfd_timeout;
1421 __le32 fina_timeout;
1422 __le32 unresponded_rts;
1423 __le32 rxe_frame_limit_overrun;
1424 __le32 sent_ack_cnt;
1425 __le32 sent_cts_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07001426} __attribute__ ((packed));
1427
Zhu Yib481de92007-09-25 17:54:57 -07001428struct statistics_rx_non_phy {
1429 __le32 bogus_cts; /* CTS received when not expecting CTS */
1430 __le32 bogus_ack; /* ACK received when not expecting ACK */
1431 __le32 non_bssid_frames; /* number of frames with BSSID that
1432 * doesn't belong to the STA BSSID */
1433 __le32 filtered_frames; /* count frames that were dumped in the
1434 * filtering process */
1435 __le32 non_channel_beacons; /* beacons with our bss id but not on
1436 * our serving channel */
Zhu Yib481de92007-09-25 17:54:57 -07001437} __attribute__ ((packed));
1438
1439struct statistics_rx {
1440 struct statistics_rx_phy ofdm;
1441 struct statistics_rx_phy cck;
1442 struct statistics_rx_non_phy general;
Zhu Yib481de92007-09-25 17:54:57 -07001443} __attribute__ ((packed));
1444
Zhu Yib481de92007-09-25 17:54:57 -07001445struct statistics_tx {
1446 __le32 preamble_cnt;
1447 __le32 rx_detected_cnt;
1448 __le32 bt_prio_defer_cnt;
1449 __le32 bt_prio_kill_cnt;
1450 __le32 few_bytes_cnt;
1451 __le32 cts_timeout;
1452 __le32 ack_timeout;
1453 __le32 expected_ack_cnt;
1454 __le32 actual_ack_cnt;
Zhu Yib481de92007-09-25 17:54:57 -07001455} __attribute__ ((packed));
1456
1457struct statistics_dbg {
1458 __le32 burst_check;
1459 __le32 burst_count;
1460 __le32 reserved[4];
1461} __attribute__ ((packed));
1462
1463struct statistics_div {
1464 __le32 tx_on_a;
1465 __le32 tx_on_b;
1466 __le32 exec_time;
1467 __le32 probe_time;
Zhu Yib481de92007-09-25 17:54:57 -07001468} __attribute__ ((packed));
1469
1470struct statistics_general {
1471 __le32 temperature;
Zhu Yib481de92007-09-25 17:54:57 -07001472 struct statistics_dbg dbg;
1473 __le32 sleep_time;
1474 __le32 slots_out;
1475 __le32 slots_idle;
1476 __le32 ttl_timestamp;
1477 struct statistics_div div;
Zhu Yib481de92007-09-25 17:54:57 -07001478} __attribute__ ((packed));
1479
1480/*
1481 * REPLY_STATISTICS_CMD = 0x9c,
1482 * 3945 and 4965 identical.
1483 *
1484 * This command triggers an immediate response containing uCode statistics.
1485 * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
1486 *
1487 * If the CLEAR_STATS configuration flag is set, uCode will clear its
1488 * internal copy of the statistics (counters) after issuing the response.
1489 * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
1490 *
1491 * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
1492 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
1493 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
1494 */
1495#define IWL_STATS_CONF_CLEAR_STATS __constant_cpu_to_le32(0x1) /* see above */
1496#define IWL_STATS_CONF_DISABLE_NOTIF __constant_cpu_to_le32(0x2)/* see above */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001497struct iwl3945_statistics_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001498 __le32 configuration_flags; /* IWL_STATS_CONF_* */
1499} __attribute__ ((packed));
1500
1501/*
1502 * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
1503 *
1504 * By default, uCode issues this notification after receiving a beacon
1505 * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
1506 * REPLY_STATISTICS_CMD 0x9c, above.
1507 *
1508 * Statistics counters continue to increment beacon after beacon, but are
1509 * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
1510 * 0x9c with CLEAR_STATS bit set (see above).
1511 *
1512 * uCode also issues this notification during scans. uCode clears statistics
1513 * appropriately so that each notification contains statistics for only the
1514 * one channel that has just been scanned.
1515 */
1516#define STATISTICS_REPLY_FLG_BAND_24G_MSK __constant_cpu_to_le32(0x2)
1517#define STATISTICS_REPLY_FLG_FAT_MODE_MSK __constant_cpu_to_le32(0x8)
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001518struct iwl3945_notif_statistics {
Zhu Yib481de92007-09-25 17:54:57 -07001519 __le32 flag;
1520 struct statistics_rx rx;
1521 struct statistics_tx tx;
1522 struct statistics_general general;
1523} __attribute__ ((packed));
1524
1525
1526/*
1527 * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
1528 */
1529/* if ucode missed CONSECUTIVE_MISSED_BCONS_TH beacons in a row,
1530 * then this notification will be sent. */
1531#define CONSECUTIVE_MISSED_BCONS_TH 20
1532
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001533struct iwl3945_missed_beacon_notif {
Zhu Yib481de92007-09-25 17:54:57 -07001534 __le32 consequtive_missed_beacons;
1535 __le32 total_missed_becons;
1536 __le32 num_expected_beacons;
1537 __le32 num_recvd_beacons;
1538} __attribute__ ((packed));
1539
1540/******************************************************************************
1541 * (11)
1542 * Rx Calibration Commands:
1543 *
1544 *****************************************************************************/
1545
1546#define PHY_CALIBRATE_DIFF_GAIN_CMD (7)
1547#define HD_TABLE_SIZE (11)
1548
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001549struct iwl3945_sensitivity_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001550 __le16 control;
1551 __le16 table[HD_TABLE_SIZE];
1552} __attribute__ ((packed));
1553
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001554struct iwl3945_calibration_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001555 u8 opCode;
1556 u8 flags;
1557 __le16 reserved;
1558 s8 diff_gain_a;
1559 s8 diff_gain_b;
1560 s8 diff_gain_c;
1561 u8 reserved1;
1562} __attribute__ ((packed));
1563
1564/******************************************************************************
1565 * (12)
1566 * Miscellaneous Commands:
1567 *
1568 *****************************************************************************/
1569
1570/*
1571 * LEDs Command & Response
1572 * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
1573 *
1574 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
1575 * this command turns it on or off, or sets up a periodic blinking cycle.
1576 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001577struct iwl3945_led_cmd {
Zhu Yib481de92007-09-25 17:54:57 -07001578 __le32 interval; /* "interval" in uSec */
1579 u8 id; /* 1: Activity, 2: Link, 3: Tech */
1580 u8 off; /* # intervals off while blinking;
1581 * "0", with >0 "on" value, turns LED on */
1582 u8 on; /* # intervals on while blinking;
1583 * "0", regardless of "off", turns LED off */
1584 u8 reserved;
1585} __attribute__ ((packed));
1586
1587/******************************************************************************
1588 * (13)
1589 * Union of all expected notifications/responses:
1590 *
1591 *****************************************************************************/
1592
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001593struct iwl3945_rx_packet {
Zhu Yib481de92007-09-25 17:54:57 -07001594 __le32 len;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001595 struct iwl3945_cmd_header hdr;
Zhu Yib481de92007-09-25 17:54:57 -07001596 union {
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001597 struct iwl3945_alive_resp alive_frame;
1598 struct iwl3945_rx_frame rx_frame;
1599 struct iwl3945_tx_resp tx_resp;
1600 struct iwl3945_spectrum_notification spectrum_notif;
1601 struct iwl3945_csa_notification csa_notif;
1602 struct iwl3945_error_resp err_resp;
1603 struct iwl3945_card_state_notif card_state_notif;
1604 struct iwl3945_beacon_notif beacon_status;
1605 struct iwl3945_add_sta_resp add_sta;
1606 struct iwl3945_sleep_notification sleep_notif;
1607 struct iwl3945_spectrum_resp spectrum;
1608 struct iwl3945_notif_statistics stats;
Zhu Yib481de92007-09-25 17:54:57 -07001609 __le32 status;
1610 u8 raw[0];
1611 } u;
1612} __attribute__ ((packed));
1613
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001614#define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl3945_rx_frame))
Zhu Yib481de92007-09-25 17:54:57 -07001615
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001616#endif /* __iwl3945_3945_commands_h__ */