blob: 9de8d7f6efa3a2a6af910b44853c4a753f9b3a61 [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
11 * it under the terms of version 2 of the GNU Geeral Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * 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 *****************************************************************************/
63
64#ifndef __iwl_commands_h__
65#define __iwl_commands_h__
66
67enum {
68 REPLY_ALIVE = 0x1,
69 REPLY_ERROR = 0x2,
70
71 /* RXON and QOS commands */
72 REPLY_RXON = 0x10,
73 REPLY_RXON_ASSOC = 0x11,
74 REPLY_QOS_PARAM = 0x13,
75 REPLY_RXON_TIMING = 0x14,
76
77 /* Multi-Station support */
78 REPLY_ADD_STA = 0x18,
79 REPLY_REMOVE_STA = 0x19, /* not used */
80 REPLY_REMOVE_ALL_STA = 0x1a, /* not used */
81
82 /* RX, TX, LEDs */
83#if IWL == 3945
84 REPLY_3945_RX = 0x1b, /* 3945 only */
85#endif
86 REPLY_TX = 0x1c,
87 REPLY_RATE_SCALE = 0x47, /* 3945 only */
88 REPLY_LEDS_CMD = 0x48,
89 REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* 4965 only */
90
91 /* 802.11h related */
92 RADAR_NOTIFICATION = 0x70, /* not used */
93 REPLY_QUIET_CMD = 0x71, /* not used */
94 REPLY_CHANNEL_SWITCH = 0x72,
95 CHANNEL_SWITCH_NOTIFICATION = 0x73,
96 REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
97 SPECTRUM_MEASURE_NOTIFICATION = 0x75,
98
99 /* Power Management */
100 POWER_TABLE_CMD = 0x77,
101 PM_SLEEP_NOTIFICATION = 0x7A,
102 PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
103
104 /* Scan commands and notifications */
105 REPLY_SCAN_CMD = 0x80,
106 REPLY_SCAN_ABORT_CMD = 0x81,
107 SCAN_START_NOTIFICATION = 0x82,
108 SCAN_RESULTS_NOTIFICATION = 0x83,
109 SCAN_COMPLETE_NOTIFICATION = 0x84,
110
111 /* IBSS/AP commands */
112 BEACON_NOTIFICATION = 0x90,
113 REPLY_TX_BEACON = 0x91,
114 WHO_IS_AWAKE_NOTIFICATION = 0x94, /* not used */
115
116 /* Miscellaneous commands */
117 QUIET_NOTIFICATION = 0x96, /* not used */
118 REPLY_TX_PWR_TABLE_CMD = 0x97,
119 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
120
121 /* BT config command */
122 REPLY_BT_CONFIG = 0x9b,
123
124 /* 4965 Statistics */
125 REPLY_STATISTICS_CMD = 0x9c,
126 STATISTICS_NOTIFICATION = 0x9d,
127
128 /* RF-KILL commands and notifications */
129 REPLY_CARD_STATE_CMD = 0xa0,
130 CARD_STATE_NOTIFICATION = 0xa1,
131
132 /* Missed beacons notification */
133 MISSED_BEACONS_NOTIFICATION = 0xa2,
134
135#if IWL == 4965
136 REPLY_CT_KILL_CONFIG_CMD = 0xa4,
137 SENSITIVITY_CMD = 0xa8,
138 REPLY_PHY_CALIBRATION_CMD = 0xb0,
139 REPLY_RX_PHY_CMD = 0xc0,
140 REPLY_RX_MPDU_CMD = 0xc1,
141 REPLY_4965_RX = 0xc3,
142 REPLY_COMPRESSED_BA = 0xc5,
143#endif
144 REPLY_MAX = 0xff
145};
146
147/******************************************************************************
148 * (0)
149 * Header
150 *
151 *****************************************************************************/
152
153#define IWL_CMD_FAILED_MSK 0x40
154
155struct iwl_cmd_header {
156 u8 cmd;
157 u8 flags;
158 /* We have 15 LSB to use as we please (MSB indicates
159 * a frame Rx'd from the HW). We encode the following
160 * information into the sequence field:
161 *
162 * 0:7 index in fifo
163 * 8:13 fifo selection
164 * 14:14 bit indicating if this packet references the 'extra'
165 * storage at the end of the memory queue
166 * 15:15 (Rx indication)
167 *
168 */
169 __le16 sequence;
170
171 /* command data follows immediately */
172 u8 data[0];
173} __attribute__ ((packed));
174
175/******************************************************************************
176 * (0a)
177 * Alive and Error Commands & Responses:
178 *
179 *****************************************************************************/
180
181#define UCODE_VALID_OK __constant_cpu_to_le32(0x1)
182#define INITIALIZE_SUBTYPE (9)
183
184/*
185 * REPLY_ALIVE = 0x1 (response only, not a command)
186 */
187struct iwl_alive_resp {
188 u8 ucode_minor;
189 u8 ucode_major;
190 __le16 reserved1;
191 u8 sw_rev[8];
192 u8 ver_type;
193 u8 ver_subtype;
194 __le16 reserved2;
195 __le32 log_event_table_ptr;
196 __le32 error_event_table_ptr;
197 __le32 timestamp;
198 __le32 is_valid;
199} __attribute__ ((packed));
200
201struct iwl_init_alive_resp {
202 u8 ucode_minor;
203 u8 ucode_major;
204 __le16 reserved1;
205 u8 sw_rev[8];
206 u8 ver_type;
207 u8 ver_subtype;
208 __le16 reserved2;
209 __le32 log_event_table_ptr;
210 __le32 error_event_table_ptr;
211 __le32 timestamp;
212 __le32 is_valid;
213
214#if IWL == 4965
215 /* calibration values from "initialize" uCode */
216 __le32 voltage; /* signed */
217 __le32 therm_r1[2]; /* signed 1st for normal, 2nd for FAT channel */
218 __le32 therm_r2[2]; /* signed */
219 __le32 therm_r3[2]; /* signed */
220 __le32 therm_r4[2]; /* signed */
221 __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups,
222 * 2 Tx chains */
223#endif
224} __attribute__ ((packed));
225
226union tsf {
227 u8 byte[8];
228 __le16 word[4];
229 __le32 dw[2];
230};
231
232/*
233 * REPLY_ERROR = 0x2 (response only, not a command)
234 */
235struct iwl_error_resp {
236 __le32 error_type;
237 u8 cmd_id;
238 u8 reserved1;
239 __le16 bad_cmd_seq_num;
240#if IWL == 3945
241 __le16 reserved2;
242#endif
243 __le32 error_info;
244 union tsf timestamp;
245} __attribute__ ((packed));
246
247/******************************************************************************
248 * (1)
249 * RXON Commands & Responses:
250 *
251 *****************************************************************************/
252
253/*
254 * Rx config defines & structure
255 */
256/* rx_config device types */
257enum {
258 RXON_DEV_TYPE_AP = 1,
259 RXON_DEV_TYPE_ESS = 3,
260 RXON_DEV_TYPE_IBSS = 4,
261 RXON_DEV_TYPE_SNIFFER = 6,
262};
263
264/* rx_config flags */
265/* band & modulation selection */
266#define RXON_FLG_BAND_24G_MSK __constant_cpu_to_le32(1 << 0)
267#define RXON_FLG_CCK_MSK __constant_cpu_to_le32(1 << 1)
268/* auto detection enable */
269#define RXON_FLG_AUTO_DETECT_MSK __constant_cpu_to_le32(1 << 2)
270/* TGg protection when tx */
271#define RXON_FLG_TGG_PROTECT_MSK __constant_cpu_to_le32(1 << 3)
272/* cck short slot & preamble */
273#define RXON_FLG_SHORT_SLOT_MSK __constant_cpu_to_le32(1 << 4)
274#define RXON_FLG_SHORT_PREAMBLE_MSK __constant_cpu_to_le32(1 << 5)
275/* antenna selection */
276#define RXON_FLG_DIS_DIV_MSK __constant_cpu_to_le32(1 << 7)
277#define RXON_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0x0f00)
278#define RXON_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
279#define RXON_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
280/* radar detection enable */
281#define RXON_FLG_RADAR_DETECT_MSK __constant_cpu_to_le32(1 << 12)
282#define RXON_FLG_TGJ_NARROW_BAND_MSK __constant_cpu_to_le32(1 << 13)
283/* rx response to host with 8-byte TSF
284* (according to ON_AIR deassertion) */
285#define RXON_FLG_TSF2HOST_MSK __constant_cpu_to_le32(1 << 15)
286
287/* rx_config filter flags */
288/* accept all data frames */
289#define RXON_FILTER_PROMISC_MSK __constant_cpu_to_le32(1 << 0)
290/* pass control & management to host */
291#define RXON_FILTER_CTL2HOST_MSK __constant_cpu_to_le32(1 << 1)
292/* accept multi-cast */
293#define RXON_FILTER_ACCEPT_GRP_MSK __constant_cpu_to_le32(1 << 2)
294/* don't decrypt uni-cast frames */
295#define RXON_FILTER_DIS_DECRYPT_MSK __constant_cpu_to_le32(1 << 3)
296/* don't decrypt multi-cast frames */
297#define RXON_FILTER_DIS_GRP_DECRYPT_MSK __constant_cpu_to_le32(1 << 4)
298/* STA is associated */
299#define RXON_FILTER_ASSOC_MSK __constant_cpu_to_le32(1 << 5)
300/* transfer to host non bssid beacons in associated state */
301#define RXON_FILTER_BCON_AWARE_MSK __constant_cpu_to_le32(1 << 6)
302
303/*
304 * REPLY_RXON = 0x10 (command, has simple generic response)
305 */
306struct iwl_rxon_cmd {
307 u8 node_addr[6];
308 __le16 reserved1;
309 u8 bssid_addr[6];
310 __le16 reserved2;
311 u8 wlap_bssid_addr[6];
312 __le16 reserved3;
313 u8 dev_type;
314 u8 air_propagation;
315#if IWL == 3945
316 __le16 reserved4;
317#elif IWL == 4965
318 __le16 rx_chain;
319#endif
320 u8 ofdm_basic_rates;
321 u8 cck_basic_rates;
322 __le16 assoc_id;
323 __le32 flags;
324 __le32 filter_flags;
325 __le16 channel;
326#if IWL == 3945
327 __le16 reserved5;
328#elif IWL == 4965
329 u8 ofdm_ht_single_stream_basic_rates;
330 u8 ofdm_ht_dual_stream_basic_rates;
331#endif
332} __attribute__ ((packed));
333
334/*
335 * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
336 */
337struct iwl_rxon_assoc_cmd {
338 __le32 flags;
339 __le32 filter_flags;
340 u8 ofdm_basic_rates;
341 u8 cck_basic_rates;
342#if IWL == 4965
343 u8 ofdm_ht_single_stream_basic_rates;
344 u8 ofdm_ht_dual_stream_basic_rates;
345 __le16 rx_chain_select_flags;
346#endif
347 __le16 reserved;
348} __attribute__ ((packed));
349
350/*
351 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
352 */
353struct iwl_rxon_time_cmd {
354 union tsf timestamp;
355 __le16 beacon_interval;
356 __le16 atim_window;
357 __le32 beacon_init_val;
358 __le16 listen_interval;
359 __le16 reserved;
360} __attribute__ ((packed));
361
362struct iwl_tx_power {
363 u8 tx_gain; /* gain for analog radio */
364 u8 dsp_atten; /* gain for DSP */
365} __attribute__ ((packed));
366
367#if IWL == 3945
368struct iwl_power_per_rate {
369 u8 rate; /* plcp */
370 struct iwl_tx_power tpc;
371 u8 reserved;
372} __attribute__ ((packed));
373
374#elif IWL == 4965
375#define POWER_TABLE_NUM_ENTRIES 33
376#define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
377#define POWER_TABLE_CCK_ENTRY 32
378struct tx_power_dual_stream {
379 __le32 dw;
380} __attribute__ ((packed));
381
382struct iwl_tx_power_db {
383 struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
384} __attribute__ ((packed));
385#endif
386
387/*
388 * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
389 */
390struct iwl_channel_switch_cmd {
391 u8 band;
392 u8 expect_beacon;
393 __le16 channel;
394 __le32 rxon_flags;
395 __le32 rxon_filter_flags;
396 __le32 switch_time;
397#if IWL == 3945
398 struct iwl_power_per_rate power[IWL_MAX_RATES];
399#elif IWL == 4965
400 struct iwl_tx_power_db tx_power;
401#endif
402} __attribute__ ((packed));
403
404/*
405 * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
406 */
407struct iwl_csa_notification {
408 __le16 band;
409 __le16 channel;
410 __le32 status; /* 0 - OK, 1 - fail */
411} __attribute__ ((packed));
412
413/******************************************************************************
414 * (2)
415 * Quality-of-Service (QOS) Commands & Responses:
416 *
417 *****************************************************************************/
418struct iwl_ac_qos {
419 __le16 cw_min;
420 __le16 cw_max;
421 u8 aifsn;
422 u8 reserved1;
423 __le16 edca_txop;
424} __attribute__ ((packed));
425
426/* QoS flags defines */
427#define QOS_PARAM_FLG_UPDATE_EDCA_MSK __constant_cpu_to_le32(0x01)
428#define QOS_PARAM_FLG_TGN_MSK __constant_cpu_to_le32(0x02)
429#define QOS_PARAM_FLG_TXOP_TYPE_MSK __constant_cpu_to_le32(0x10)
430
431/*
432 * TXFIFO Queue number defines
433 */
434/* number of Access categories (AC) (EDCA), queues 0..3 */
435#define AC_NUM 4
436
437/*
438 * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
439 */
440struct iwl_qosparam_cmd {
441 __le32 qos_flags;
442 struct iwl_ac_qos ac[AC_NUM];
443} __attribute__ ((packed));
444
445/******************************************************************************
446 * (3)
447 * Add/Modify Stations Commands & Responses:
448 *
449 *****************************************************************************/
450/*
451 * Multi station support
452 */
453#define IWL_AP_ID 0
454#define IWL_MULTICAST_ID 1
455#define IWL_STA_ID 2
456
457#define IWL3945_BROADCAST_ID 24
458#define IWL3945_STATION_COUNT 25
459
460#define IWL4965_BROADCAST_ID 31
461#define IWL4965_STATION_COUNT 32
462
463#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
464#define IWL_INVALID_STATION 255
465
466#if IWL == 3945
467#define STA_FLG_TX_RATE_MSK __constant_cpu_to_le32(1<<2);
468#endif
469#define STA_FLG_PWR_SAVE_MSK __constant_cpu_to_le32(1<<8);
470
471#define STA_CONTROL_MODIFY_MSK 0x01
472
473/* key flags __le16*/
474#define STA_KEY_FLG_ENCRYPT_MSK __constant_cpu_to_le16(0x7)
475#define STA_KEY_FLG_NO_ENC __constant_cpu_to_le16(0x0)
476#define STA_KEY_FLG_WEP __constant_cpu_to_le16(0x1)
477#define STA_KEY_FLG_CCMP __constant_cpu_to_le16(0x2)
478#define STA_KEY_FLG_TKIP __constant_cpu_to_le16(0x3)
479
480#define STA_KEY_FLG_KEYID_POS 8
481#define STA_KEY_FLG_INVALID __constant_cpu_to_le16(0x0800)
482
483/* modify flags */
484#define STA_MODIFY_KEY_MASK 0x01
485#define STA_MODIFY_TID_DISABLE_TX 0x02
486#define STA_MODIFY_TX_RATE_MSK 0x04
487#define STA_MODIFY_ADDBA_TID_MSK 0x08
488#define STA_MODIFY_DELBA_TID_MSK 0x10
489#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid))
490
491/*
492 * Antenna masks:
493 * bit14:15 01 B inactive, A active
494 * 10 B active, A inactive
495 * 11 Both active
496 */
497#define RATE_MCS_ANT_A_POS 14
498#define RATE_MCS_ANT_B_POS 15
499#define RATE_MCS_ANT_A_MSK 0x4000
500#define RATE_MCS_ANT_B_MSK 0x8000
501#define RATE_MCS_ANT_AB_MSK 0xc000
502
503struct iwl_keyinfo {
504 __le16 key_flags;
505 u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
506 u8 reserved1;
507 __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
508 __le16 reserved2;
509 u8 key[16]; /* 16-byte unicast decryption key */
510} __attribute__ ((packed));
511
512struct sta_id_modify {
513 u8 addr[ETH_ALEN];
514 __le16 reserved1;
515 u8 sta_id;
516 u8 modify_mask;
517 __le16 reserved2;
518} __attribute__ ((packed));
519
520/*
521 * REPLY_ADD_STA = 0x18 (command)
522 */
523struct iwl_addsta_cmd {
524 u8 mode;
525 u8 reserved[3];
526 struct sta_id_modify sta;
527 struct iwl_keyinfo key;
528 __le32 station_flags;
529 __le32 station_flags_msk;
530 __le16 tid_disable_tx;
531#if IWL == 3945
532 __le16 rate_n_flags;
533#else
534 __le16 reserved1;
535#endif
536 u8 add_immediate_ba_tid;
537 u8 remove_immediate_ba_tid;
538 __le16 add_immediate_ba_ssn;
539#if IWL == 4965
540 __le32 reserved2;
541#endif
542} __attribute__ ((packed));
543
544/*
545 * REPLY_ADD_STA = 0x18 (response)
546 */
547struct iwl_add_sta_resp {
548 u8 status;
549} __attribute__ ((packed));
550
551#define ADD_STA_SUCCESS_MSK 0x1
552
553/******************************************************************************
554 * (4)
555 * Rx Responses:
556 *
557 *****************************************************************************/
558
559struct iwl_rx_frame_stats {
560 u8 phy_count;
561 u8 id;
562 u8 rssi;
563 u8 agc;
564 __le16 sig_avg;
565 __le16 noise_diff;
566 u8 payload[0];
567} __attribute__ ((packed));
568
569struct iwl_rx_frame_hdr {
570 __le16 channel;
571 __le16 phy_flags;
572 u8 reserved1;
573 u8 rate;
574 __le16 len;
575 u8 payload[0];
576} __attribute__ ((packed));
577
578#define RX_RES_STATUS_NO_CRC32_ERROR __constant_cpu_to_le32(1 << 0)
579#define RX_RES_STATUS_NO_RXE_OVERFLOW __constant_cpu_to_le32(1 << 1)
580
581#define RX_RES_PHY_FLAGS_BAND_24_MSK __constant_cpu_to_le16(1 << 0)
582#define RX_RES_PHY_FLAGS_MOD_CCK_MSK __constant_cpu_to_le16(1 << 1)
583#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK __constant_cpu_to_le16(1 << 2)
584#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK __constant_cpu_to_le16(1 << 3)
585#define RX_RES_PHY_FLAGS_ANTENNA_MSK __constant_cpu_to_le16(0xf0)
586
587#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
588#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
589#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
590#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
591#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
592
593#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
594#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
595#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
596#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
597#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
598
599struct iwl_rx_frame_end {
600 __le32 status;
601 __le64 timestamp;
602 __le32 beacon_timestamp;
603} __attribute__ ((packed));
604
605/*
606 * REPLY_3945_RX = 0x1b (response only, not a command)
607 *
608 * NOTE: DO NOT dereference from casts to this structure
609 * It is provided only for calculating minimum data set size.
610 * The actual offsets of the hdr and end are dynamic based on
611 * stats.phy_count
612 */
613struct iwl_rx_frame {
614 struct iwl_rx_frame_stats stats;
615 struct iwl_rx_frame_hdr hdr;
616 struct iwl_rx_frame_end end;
617} __attribute__ ((packed));
618
619/* Fixed (non-configurable) rx data from phy */
620#define RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
621#define RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
622#define IWL_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
623#define IWL_AGC_DB_POS (7)
624struct iwl4965_rx_non_cfg_phy {
625 __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
626 __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
627 u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
628 u8 pad[0];
629} __attribute__ ((packed));
630
631/*
632 * REPLY_4965_RX = 0xc3 (response only, not a command)
633 * Used only for legacy (non 11n) frames.
634 */
635#define RX_RES_PHY_CNT 14
636struct iwl4965_rx_phy_res {
637 u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
638 u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
639 u8 stat_id; /* configurable DSP phy data set ID */
640 u8 reserved1;
641 __le64 timestamp; /* TSF at on air rise */
642 __le32 beacon_time_stamp; /* beacon at on-air rise */
643 __le16 phy_flags; /* general phy flags: band, modulation, ... */
644 __le16 channel; /* channel number */
645 __le16 non_cfg_phy[RX_RES_PHY_CNT]; /* upto 14 phy entries */
646 __le32 reserved2;
647 __le32 rate_n_flags;
648 __le16 byte_count; /* frame's byte-count */
649 __le16 reserved3;
650} __attribute__ ((packed));
651
652struct iwl4965_rx_mpdu_res_start {
653 __le16 byte_count;
654 __le16 reserved;
655} __attribute__ ((packed));
656
657
658/******************************************************************************
659 * (5)
660 * Tx Commands & Responses:
661 *
662 *****************************************************************************/
663
664/* Tx flags */
665#define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1)
666#define TX_CMD_FLG_CTS_MSK __constant_cpu_to_le32(1 << 2)
667#define TX_CMD_FLG_ACK_MSK __constant_cpu_to_le32(1 << 3)
668#define TX_CMD_FLG_STA_RATE_MSK __constant_cpu_to_le32(1 << 4)
669#define TX_CMD_FLG_IMM_BA_RSP_MASK __constant_cpu_to_le32(1 << 6)
670#define TX_CMD_FLG_FULL_TXOP_PROT_MSK __constant_cpu_to_le32(1 << 7)
671#define TX_CMD_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0xf00)
672#define TX_CMD_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
673#define TX_CMD_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
674
675/* ucode ignores BT priority for this frame */
676#define TX_CMD_FLG_BT_DIS_MSK __constant_cpu_to_le32(1 << 12)
677
678/* ucode overrides sequence control */
679#define TX_CMD_FLG_SEQ_CTL_MSK __constant_cpu_to_le32(1 << 13)
680
681/* signal that this frame is non-last MPDU */
682#define TX_CMD_FLG_MORE_FRAG_MSK __constant_cpu_to_le32(1 << 14)
683
684/* calculate TSF in outgoing frame */
685#define TX_CMD_FLG_TSF_MSK __constant_cpu_to_le32(1 << 16)
686
687/* activate TX calibration. */
688#define TX_CMD_FLG_CALIB_MSK __constant_cpu_to_le32(1 << 17)
689
690/* signals that 2 bytes pad was inserted
691 after the MAC header */
692#define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20)
693
694/* HCCA-AP - disable duration overwriting. */
695#define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25)
696
697/*
698 * TX command security control
699 */
700#define TX_CMD_SEC_WEP 0x01
701#define TX_CMD_SEC_CCM 0x02
702#define TX_CMD_SEC_TKIP 0x03
703#define TX_CMD_SEC_MSK 0x03
704#define TX_CMD_SEC_SHIFT 6
705#define TX_CMD_SEC_KEY128 0x08
706
707/*
708 * TX command Frame life time
709 */
710
711struct iwl_dram_scratch {
712 u8 try_cnt;
713 u8 bt_kill_cnt;
714 __le16 reserved;
715} __attribute__ ((packed));
716
717/*
718 * REPLY_TX = 0x1c (command)
719 */
720struct iwl_tx_cmd {
721 __le16 len;
722 __le16 next_frame_len;
723 __le32 tx_flags;
724#if IWL == 3945
725 u8 rate;
726 u8 sta_id;
727 u8 tid_tspec;
728#elif IWL == 4965
729 struct iwl_dram_scratch scratch;
730 __le32 rate_n_flags;
731 u8 sta_id;
732#endif
733 u8 sec_ctl;
734#if IWL == 4965
735 u8 initial_rate_index;
736 u8 reserved;
737#endif
738 u8 key[16];
739#if IWL == 3945
740 union {
741 u8 byte[8];
742 __le16 word[4];
743 __le32 dw[2];
744 } tkip_mic;
745 __le32 next_frame_info;
746#elif IWL == 4965
747 __le16 next_frame_flags;
748 __le16 reserved2;
749#endif
750 union {
751 __le32 life_time;
752 __le32 attempt;
753 } stop_time;
754#if IWL == 3945
755 u8 supp_rates[2];
756#elif IWL == 4965
757 __le32 dram_lsb_ptr;
758 u8 dram_msb_ptr;
759#endif
760 u8 rts_retry_limit; /*byte 50 */
761 u8 data_retry_limit; /*byte 51 */
762#if IWL == 4965
763 u8 tid_tspec;
764#endif
765 union {
766 __le16 pm_frame_timeout;
767 __le16 attempt_duration;
768 } timeout;
769 __le16 driver_txop;
770 u8 payload[0];
771 struct ieee80211_hdr hdr[0];
772} __attribute__ ((packed));
773
774/* TX command response is sent after *all* transmission attempts.
775 *
776 * NOTES:
777 *
778 * TX_STATUS_FAIL_NEXT_FRAG
779 *
780 * If the fragment flag in the MAC header for the frame being transmitted
781 * is set and there is insufficient time to transmit the next frame, the
782 * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
783 *
784 * TX_STATUS_FIFO_UNDERRUN
785 *
786 * Indicates the host did not provide bytes to the FIFO fast enough while
787 * a TX was in progress.
788 *
789 * TX_STATUS_FAIL_MGMNT_ABORT
790 *
791 * This status is only possible if the ABORT ON MGMT RX parameter was
792 * set to true with the TX command.
793 *
794 * If the MSB of the status parameter is set then an abort sequence is
795 * required. This sequence consists of the host activating the TX Abort
796 * control line, and then waiting for the TX Abort command response. This
797 * indicates that a the device is no longer in a transmit state, and that the
798 * command FIFO has been cleared. The host must then deactivate the TX Abort
799 * control line. Receiving is still allowed in this case.
800 */
801enum {
802 TX_STATUS_SUCCESS = 0x01,
803 TX_STATUS_DIRECT_DONE = 0x02,
804 TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
805 TX_STATUS_FAIL_LONG_LIMIT = 0x83,
806 TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
807 TX_STATUS_FAIL_MGMNT_ABORT = 0x85,
808 TX_STATUS_FAIL_NEXT_FRAG = 0x86,
809 TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
810 TX_STATUS_FAIL_DEST_PS = 0x88,
811 TX_STATUS_FAIL_ABORTED = 0x89,
812 TX_STATUS_FAIL_BT_RETRY = 0x8a,
813 TX_STATUS_FAIL_STA_INVALID = 0x8b,
814 TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
815 TX_STATUS_FAIL_TID_DISABLE = 0x8d,
816 TX_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
817 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
818 TX_STATUS_FAIL_TX_LOCKED = 0x90,
819 TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
820};
821
822#define TX_PACKET_MODE_REGULAR 0x0000
823#define TX_PACKET_MODE_BURST_SEQ 0x0100
824#define TX_PACKET_MODE_BURST_FIRST 0x0200
825
826enum {
827 TX_POWER_PA_NOT_ACTIVE = 0x0,
828};
829
830enum {
831 TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
832 TX_STATUS_DELAY_MSK = 0x00000040,
833 TX_STATUS_ABORT_MSK = 0x00000080,
834 TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
835 TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
836 TX_RESERVED = 0x00780000, /* bits 19:22 */
837 TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
838 TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
839};
840
841/* *******************************
842 * TX aggregation state
843 ******************************* */
844
845enum {
846 AGG_TX_STATE_TRANSMITTED = 0x00,
847 AGG_TX_STATE_UNDERRUN_MSK = 0x01,
848 AGG_TX_STATE_BT_PRIO_MSK = 0x02,
849 AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
850 AGG_TX_STATE_ABORT_MSK = 0x08,
851 AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
852 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
853 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
854 AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
855 AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
856 AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
857 AGG_TX_STATE_DUMP_TX_MSK = 0x200,
858 AGG_TX_STATE_DELAY_TX_MSK = 0x400
859};
860
861#define AGG_TX_STATE_LAST_SENT_MSK \
862(AGG_TX_STATE_LAST_SENT_TTL_MSK | \
863 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
864 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
865
866#define AGG_TX_STATE_TRY_CNT_POS 12
867#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
868
869#define AGG_TX_STATE_SEQ_NUM_POS 16
870#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
871
872/*
873 * REPLY_TX = 0x1c (response)
874 */
875#if IWL == 4965
876struct iwl_tx_resp {
877 u8 frame_count; /* 1 no aggregation, >1 aggregation */
878 u8 bt_kill_count;
879 u8 failure_rts;
880 u8 failure_frame;
881 __le32 rate_n_flags;
882 __le16 wireless_media_time;
883 __le16 reserved;
884 __le32 pa_power1;
885 __le32 pa_power2;
886 __le32 status; /* TX status (for aggregation status of 1st frame) */
887} __attribute__ ((packed));
888
889#elif IWL == 3945
890struct iwl_tx_resp {
891 u8 failure_rts;
892 u8 failure_frame;
893 u8 bt_kill_count;
894 u8 rate;
895 __le32 wireless_media_time;
896 __le32 status; /* TX status (for aggregation status of 1st frame) */
897} __attribute__ ((packed));
898#endif
899
900/*
901 * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
902 */
903struct iwl_compressed_ba_resp {
904 __le32 sta_addr_lo32;
905 __le16 sta_addr_hi16;
906 __le16 reserved;
907 u8 sta_id;
908 u8 tid;
909 __le16 ba_seq_ctl;
910 __le32 ba_bitmap0;
911 __le32 ba_bitmap1;
912 __le16 scd_flow;
913 __le16 scd_ssn;
914} __attribute__ ((packed));
915
916/*
917 * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
918 */
919struct iwl_txpowertable_cmd {
920 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
921 u8 reserved;
922 __le16 channel;
923#if IWL == 3945
924 struct iwl_power_per_rate power[IWL_MAX_RATES];
925#elif IWL == 4965
926 struct iwl_tx_power_db tx_power;
927#endif
928} __attribute__ ((packed));
929
930#if IWL == 3945
931struct iwl_rate_scaling_info {
932 __le16 rate_n_flags;
933 u8 try_cnt;
934 u8 next_rate_index;
935} __attribute__ ((packed));
936
937/**
938 * struct iwl_rate_scaling_cmd - Rate Scaling Command & Response
939 *
940 * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
941 *
942 * NOTE: The table of rates passed to the uCode via the
943 * RATE_SCALE command sets up the corresponding order of
944 * rates used for all related commands, including rate
945 * masks, etc.
946 *
947 * For example, if you set 9MB (PLCP 0x0f) as the first
948 * rate in the rate table, the bit mask for that rate
949 * when passed through ofdm_basic_rates on the REPLY_RXON
950 * command would be bit 0 (1<<0)
951 */
952struct iwl_rate_scaling_cmd {
953 u8 table_id;
954 u8 reserved[3];
955 struct iwl_rate_scaling_info table[IWL_MAX_RATES];
956} __attribute__ ((packed));
957
958#elif IWL == 4965
959
960/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
961#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1<<0)
962
963#define LINK_QUAL_AC_NUM AC_NUM
964#define LINK_QUAL_MAX_RETRY_NUM 16
965
966#define LINK_QUAL_ANT_A_MSK (1<<0)
967#define LINK_QUAL_ANT_B_MSK (1<<1)
968#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
969
970struct iwl_link_qual_general_params {
971 u8 flags;
972 u8 mimo_delimiter;
973 u8 single_stream_ant_msk;
974 u8 dual_stream_ant_msk;
975 u8 start_rate_index[LINK_QUAL_AC_NUM];
976} __attribute__ ((packed));
977
978struct iwl_link_qual_agg_params {
979 __le16 agg_time_limit;
980 u8 agg_dis_start_th;
981 u8 agg_frame_cnt_limit;
982 __le32 reserved;
983} __attribute__ ((packed));
984
985/*
986 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
987 */
988struct iwl_link_quality_cmd {
989 u8 sta_id;
990 u8 reserved1;
991 __le16 control;
992 struct iwl_link_qual_general_params general_params;
993 struct iwl_link_qual_agg_params agg_params;
994 struct {
995 __le32 rate_n_flags;
996 } rs_table[LINK_QUAL_MAX_RETRY_NUM];
997 __le32 reserved2;
998} __attribute__ ((packed));
999#endif
1000
1001/*
1002 * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
1003 */
1004struct iwl_bt_cmd {
1005 u8 flags;
1006 u8 lead_time;
1007 u8 max_kill;
1008 u8 reserved;
1009 __le32 kill_ack_mask;
1010 __le32 kill_cts_mask;
1011} __attribute__ ((packed));
1012
1013/******************************************************************************
1014 * (6)
1015 * Spectrum Management (802.11h) Commands, Responses, Notifications:
1016 *
1017 *****************************************************************************/
1018
1019/*
1020 * Spectrum Management
1021 */
1022#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
1023 RXON_FILTER_CTL2HOST_MSK | \
1024 RXON_FILTER_ACCEPT_GRP_MSK | \
1025 RXON_FILTER_DIS_DECRYPT_MSK | \
1026 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
1027 RXON_FILTER_ASSOC_MSK | \
1028 RXON_FILTER_BCON_AWARE_MSK)
1029
1030struct iwl_measure_channel {
1031 __le32 duration; /* measurement duration in extended beacon
1032 * format */
1033 u8 channel; /* channel to measure */
1034 u8 type; /* see enum iwl_measure_type */
1035 __le16 reserved;
1036} __attribute__ ((packed));
1037
1038/*
1039 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
1040 */
1041struct iwl_spectrum_cmd {
1042 __le16 len; /* number of bytes starting from token */
1043 u8 token; /* token id */
1044 u8 id; /* measurement id -- 0 or 1 */
1045 u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
1046 u8 periodic; /* 1 = periodic */
1047 __le16 path_loss_timeout;
1048 __le32 start_time; /* start time in extended beacon format */
1049 __le32 reserved2;
1050 __le32 flags; /* rxon flags */
1051 __le32 filter_flags; /* rxon filter flags */
1052 __le16 channel_count; /* minimum 1, maximum 10 */
1053 __le16 reserved3;
1054 struct iwl_measure_channel channels[10];
1055} __attribute__ ((packed));
1056
1057/*
1058 * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
1059 */
1060struct iwl_spectrum_resp {
1061 u8 token;
1062 u8 id; /* id of the prior command replaced, or 0xff */
1063 __le16 status; /* 0 - command will be handled
1064 * 1 - cannot handle (conflicts with another
1065 * measurement) */
1066} __attribute__ ((packed));
1067
1068enum iwl_measurement_state {
1069 IWL_MEASUREMENT_START = 0,
1070 IWL_MEASUREMENT_STOP = 1,
1071};
1072
1073enum iwl_measurement_status {
1074 IWL_MEASUREMENT_OK = 0,
1075 IWL_MEASUREMENT_CONCURRENT = 1,
1076 IWL_MEASUREMENT_CSA_CONFLICT = 2,
1077 IWL_MEASUREMENT_TGH_CONFLICT = 3,
1078 /* 4-5 reserved */
1079 IWL_MEASUREMENT_STOPPED = 6,
1080 IWL_MEASUREMENT_TIMEOUT = 7,
1081 IWL_MEASUREMENT_PERIODIC_FAILED = 8,
1082};
1083
1084#define NUM_ELEMENTS_IN_HISTOGRAM 8
1085
1086struct iwl_measurement_histogram {
1087 __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
1088 __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
1089} __attribute__ ((packed));
1090
1091/* clear channel availability counters */
1092struct iwl_measurement_cca_counters {
1093 __le32 ofdm;
1094 __le32 cck;
1095} __attribute__ ((packed));
1096
1097enum iwl_measure_type {
1098 IWL_MEASURE_BASIC = (1 << 0),
1099 IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
1100 IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
1101 IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
1102 IWL_MEASURE_FRAME = (1 << 4),
1103 /* bits 5:6 are reserved */
1104 IWL_MEASURE_IDLE = (1 << 7),
1105};
1106
1107/*
1108 * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
1109 */
1110struct iwl_spectrum_notification {
1111 u8 id; /* measurement id -- 0 or 1 */
1112 u8 token;
1113 u8 channel_index; /* index in measurement channel list */
1114 u8 state; /* 0 - start, 1 - stop */
1115 __le32 start_time; /* lower 32-bits of TSF */
1116 u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
1117 u8 channel;
1118 u8 type; /* see enum iwl_measurement_type */
1119 u8 reserved1;
1120 /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
1121 * valid if applicable for measurement type requested. */
1122 __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
1123 __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
1124 __le32 cca_time; /* channel load time in usecs */
1125 u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
1126 * unidentified */
1127 u8 reserved2[3];
1128 struct iwl_measurement_histogram histogram;
1129 __le32 stop_time; /* lower 32-bits of TSF */
1130 __le32 status; /* see iwl_measurement_status */
1131} __attribute__ ((packed));
1132
1133/******************************************************************************
1134 * (7)
1135 * Power Management Commands, Responses, Notifications:
1136 *
1137 *****************************************************************************/
1138
1139/**
1140 * struct iwl_powertable_cmd - Power Table Command
1141 * @flags: See below:
1142 *
1143 * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
1144 *
1145 * PM allow:
1146 * bit 0 - '0' Driver not allow power management
1147 * '1' Driver allow PM (use rest of parameters)
1148 * uCode send sleep notifications:
1149 * bit 1 - '0' Don't send sleep notification
1150 * '1' send sleep notification (SEND_PM_NOTIFICATION)
1151 * Sleep over DTIM
1152 * bit 2 - '0' PM have to walk up every DTIM
1153 * '1' PM could sleep over DTIM till listen Interval.
1154 * PCI power managed
1155 * bit 3 - '0' (PCI_LINK_CTRL & 0x1)
1156 * '1' !(PCI_LINK_CTRL & 0x1)
1157 * Force sleep Modes
1158 * bit 31/30- '00' use both mac/xtal sleeps
1159 * '01' force Mac sleep
1160 * '10' force xtal sleep
1161 * '11' Illegal set
1162 *
1163 * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
1164 * ucode assume sleep over DTIM is allowed and we don't need to wakeup
1165 * for every DTIM.
1166 */
1167#define IWL_POWER_VEC_SIZE 5
1168
1169
1170#if IWL == 3945
1171
1172#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK __constant_cpu_to_le32(1<<0)
1173#define IWL_POWER_SLEEP_OVER_DTIM_MSK __constant_cpu_to_le32(1<<2)
1174#define IWL_POWER_PCI_PM_MSK __constant_cpu_to_le32(1<<3)
1175struct iwl_powertable_cmd {
1176 __le32 flags;
1177 __le32 rx_data_timeout;
1178 __le32 tx_data_timeout;
1179 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
1180} __attribute__((packed));
1181
1182#elif IWL == 4965
1183
1184#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK __constant_cpu_to_le16(1<<0)
1185#define IWL_POWER_SLEEP_OVER_DTIM_MSK __constant_cpu_to_le16(1<<2)
1186#define IWL_POWER_PCI_PM_MSK __constant_cpu_to_le16(1<<3)
1187
1188struct iwl_powertable_cmd {
1189 __le16 flags;
1190 u8 keep_alive_seconds;
1191 u8 debug_flags;
1192 __le32 rx_data_timeout;
1193 __le32 tx_data_timeout;
1194 __le32 sleep_interval[IWL_POWER_VEC_SIZE];
1195 __le32 keep_alive_beacons;
1196} __attribute__ ((packed));
1197#endif
1198
1199/*
1200 * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
1201 * 3945 and 4965 identical.
1202 */
1203struct iwl_sleep_notification {
1204 u8 pm_sleep_mode;
1205 u8 pm_wakeup_src;
1206 __le16 reserved;
1207 __le32 sleep_time;
1208 __le32 tsf_low;
1209 __le32 bcon_timer;
1210} __attribute__ ((packed));
1211
1212/* Sleep states. 3945 and 4965 identical. */
1213enum {
1214 IWL_PM_NO_SLEEP = 0,
1215 IWL_PM_SLP_MAC = 1,
1216 IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
1217 IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
1218 IWL_PM_SLP_PHY = 4,
1219 IWL_PM_SLP_REPENT = 5,
1220 IWL_PM_WAKEUP_BY_TIMER = 6,
1221 IWL_PM_WAKEUP_BY_DRIVER = 7,
1222 IWL_PM_WAKEUP_BY_RFKILL = 8,
1223 /* 3 reserved */
1224 IWL_PM_NUM_OF_MODES = 12,
1225};
1226
1227/*
1228 * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
1229 */
1230#define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
1231#define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
1232#define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
1233struct iwl_card_state_cmd {
1234 __le32 status; /* CARD_STATE_CMD_* request new power state */
1235} __attribute__ ((packed));
1236
1237/*
1238 * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
1239 */
1240struct iwl_card_state_notif {
1241 __le32 flags;
1242} __attribute__ ((packed));
1243
1244#define HW_CARD_DISABLED 0x01
1245#define SW_CARD_DISABLED 0x02
1246#define RF_CARD_DISABLED 0x04
1247#define RXON_CARD_DISABLED 0x10
1248
1249struct iwl_ct_kill_config {
1250 __le32 reserved;
1251 __le32 critical_temperature_M;
1252 __le32 critical_temperature_R;
1253} __attribute__ ((packed));
1254
1255/******************************************************************************
1256 * (8)
1257 * Scan Commands, Responses, Notifications:
1258 *
1259 *****************************************************************************/
1260
1261struct iwl_scan_channel {
1262 /* type is defined as:
1263 * 0:0 active (0 - passive)
1264 * 1:4 SSID direct
1265 * If 1 is set then corresponding SSID IE is transmitted in probe
1266 * 5:7 reserved
1267 */
1268 u8 type;
1269 u8 channel;
1270 struct iwl_tx_power tpc;
1271 __le16 active_dwell;
1272 __le16 passive_dwell;
1273} __attribute__ ((packed));
1274
1275struct iwl_ssid_ie {
1276 u8 id;
1277 u8 len;
1278 u8 ssid[32];
1279} __attribute__ ((packed));
1280
1281#define PROBE_OPTION_MAX 0x4
1282#define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF)
1283#define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1)
1284#define IWL_MAX_SCAN_SIZE 1024
1285
1286/*
1287 * REPLY_SCAN_CMD = 0x80 (command)
1288 */
1289struct iwl_scan_cmd {
1290 __le16 len;
1291 u8 reserved0;
1292 u8 channel_count;
1293 __le16 quiet_time; /* dwell only this long on quiet chnl
1294 * (active scan) */
1295 __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
1296 __le16 good_CRC_th; /* passive -> active promotion threshold */
1297#if IWL == 3945
1298 __le16 reserved1;
1299#elif IWL == 4965
1300 __le16 rx_chain;
1301#endif
1302 __le32 max_out_time; /* max usec to be out of associated (service)
1303 * chnl */
1304 __le32 suspend_time; /* pause scan this long when returning to svc
1305 * chnl.
1306 * 3945 -- 31:24 # beacons, 19:0 additional usec,
1307 * 4965 -- 31:22 # beacons, 21:0 additional usec.
1308 */
1309 __le32 flags;
1310 __le32 filter_flags;
1311
1312 struct iwl_tx_cmd tx_cmd;
1313 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
1314
1315 u8 data[0];
1316 /*
1317 * The channels start after the probe request payload and are of type:
1318 *
1319 * struct iwl_scan_channel channels[0];
1320 *
1321 * NOTE: Only one band of channels can be scanned per pass. You
1322 * can not mix 2.4GHz channels and 5.2GHz channels and must
1323 * request a scan multiple times (not concurrently)
1324 *
1325 */
1326} __attribute__ ((packed));
1327
1328/* Can abort will notify by complete notification with abort status. */
1329#define CAN_ABORT_STATUS __constant_cpu_to_le32(0x1)
1330/* complete notification statuses */
1331#define ABORT_STATUS 0x2
1332
1333/*
1334 * REPLY_SCAN_CMD = 0x80 (response)
1335 */
1336struct iwl_scanreq_notification {
1337 __le32 status; /* 1: okay, 2: cannot fulfill request */
1338} __attribute__ ((packed));
1339
1340/*
1341 * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
1342 */
1343struct iwl_scanstart_notification {
1344 __le32 tsf_low;
1345 __le32 tsf_high;
1346 __le32 beacon_timer;
1347 u8 channel;
1348 u8 band;
1349 u8 reserved[2];
1350 __le32 status;
1351} __attribute__ ((packed));
1352
1353#define SCAN_OWNER_STATUS 0x1;
1354#define MEASURE_OWNER_STATUS 0x2;
1355
1356#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
1357/*
1358 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
1359 */
1360struct iwl_scanresults_notification {
1361 u8 channel;
1362 u8 band;
1363 u8 reserved[2];
1364 __le32 tsf_low;
1365 __le32 tsf_high;
1366 __le32 statistics[NUMBER_OF_STATISTICS];
1367} __attribute__ ((packed));
1368
1369/*
1370 * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
1371 */
1372struct iwl_scancomplete_notification {
1373 u8 scanned_channels;
1374 u8 status;
1375 u8 reserved;
1376 u8 last_channel;
1377 __le32 tsf_low;
1378 __le32 tsf_high;
1379} __attribute__ ((packed));
1380
1381
1382/******************************************************************************
1383 * (9)
1384 * IBSS/AP Commands and Notifications:
1385 *
1386 *****************************************************************************/
1387
1388/*
1389 * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
1390 */
1391struct iwl_beacon_notif {
1392 struct iwl_tx_resp beacon_notify_hdr;
1393 __le32 low_tsf;
1394 __le32 high_tsf;
1395 __le32 ibss_mgr_status;
1396} __attribute__ ((packed));
1397
1398/*
1399 * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
1400 */
1401struct iwl_tx_beacon_cmd {
1402 struct iwl_tx_cmd tx;
1403 __le16 tim_idx;
1404 u8 tim_size;
1405 u8 reserved1;
1406 struct ieee80211_hdr frame[0]; /* beacon frame */
1407} __attribute__ ((packed));
1408
1409/******************************************************************************
1410 * (10)
1411 * Statistics Commands and Notifications:
1412 *
1413 *****************************************************************************/
1414
1415#define IWL_TEMP_CONVERT 260
1416
1417#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
1418#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
1419#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
1420
1421/* Used for passing to driver number of successes and failures per rate */
1422struct rate_histogram {
1423 union {
1424 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
1425 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
1426 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
1427 } success;
1428 union {
1429 __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
1430 __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
1431 __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
1432 } failed;
1433} __attribute__ ((packed));
1434
1435/* statistics command response */
1436
1437struct statistics_rx_phy {
1438 __le32 ina_cnt;
1439 __le32 fina_cnt;
1440 __le32 plcp_err;
1441 __le32 crc32_err;
1442 __le32 overrun_err;
1443 __le32 early_overrun_err;
1444 __le32 crc32_good;
1445 __le32 false_alarm_cnt;
1446 __le32 fina_sync_err_cnt;
1447 __le32 sfd_timeout;
1448 __le32 fina_timeout;
1449 __le32 unresponded_rts;
1450 __le32 rxe_frame_limit_overrun;
1451 __le32 sent_ack_cnt;
1452 __le32 sent_cts_cnt;
1453#if IWL == 4965
1454 __le32 sent_ba_rsp_cnt;
1455 __le32 dsp_self_kill;
1456 __le32 mh_format_err;
1457 __le32 re_acq_main_rssi_sum;
1458 __le32 reserved3;
1459#endif
1460} __attribute__ ((packed));
1461
1462#if IWL == 4965
1463struct statistics_rx_ht_phy {
1464 __le32 plcp_err;
1465 __le32 overrun_err;
1466 __le32 early_overrun_err;
1467 __le32 crc32_good;
1468 __le32 crc32_err;
1469 __le32 mh_format_err;
1470 __le32 agg_crc32_good;
1471 __le32 agg_mpdu_cnt;
1472 __le32 agg_cnt;
1473 __le32 reserved2;
1474} __attribute__ ((packed));
1475#endif
1476
1477struct statistics_rx_non_phy {
1478 __le32 bogus_cts; /* CTS received when not expecting CTS */
1479 __le32 bogus_ack; /* ACK received when not expecting ACK */
1480 __le32 non_bssid_frames; /* number of frames with BSSID that
1481 * doesn't belong to the STA BSSID */
1482 __le32 filtered_frames; /* count frames that were dumped in the
1483 * filtering process */
1484 __le32 non_channel_beacons; /* beacons with our bss id but not on
1485 * our serving channel */
1486#if IWL == 4965
1487 __le32 channel_beacons; /* beacons with our bss id and in our
1488 * serving channel */
1489 __le32 num_missed_bcon; /* number of missed beacons */
1490 __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
1491 * ADC was in saturation */
1492 __le32 ina_detection_search_time;/* total time (in 0.8us) searched
1493 * for INA */
1494 __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
1495 __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
1496 __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
1497 __le32 interference_data_flag; /* flag for interference data
1498 * availability. 1 when data is
1499 * available. */
1500 __le32 channel_load; /* counts RX Enable time */
1501 __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
1502 * and CCK) counter */
1503 __le32 beacon_rssi_a;
1504 __le32 beacon_rssi_b;
1505 __le32 beacon_rssi_c;
1506 __le32 beacon_energy_a;
1507 __le32 beacon_energy_b;
1508 __le32 beacon_energy_c;
1509#endif
1510} __attribute__ ((packed));
1511
1512struct statistics_rx {
1513 struct statistics_rx_phy ofdm;
1514 struct statistics_rx_phy cck;
1515 struct statistics_rx_non_phy general;
1516#if IWL == 4965
1517 struct statistics_rx_ht_phy ofdm_ht;
1518#endif
1519} __attribute__ ((packed));
1520
1521#if IWL == 4965
1522struct statistics_tx_non_phy_agg {
1523 __le32 ba_timeout;
1524 __le32 ba_reschedule_frames;
1525 __le32 scd_query_agg_frame_cnt;
1526 __le32 scd_query_no_agg;
1527 __le32 scd_query_agg;
1528 __le32 scd_query_mismatch;
1529 __le32 frame_not_ready;
1530 __le32 underrun;
1531 __le32 bt_prio_kill;
1532 __le32 rx_ba_rsp_cnt;
1533 __le32 reserved2;
1534 __le32 reserved3;
1535} __attribute__ ((packed));
1536#endif
1537
1538struct statistics_tx {
1539 __le32 preamble_cnt;
1540 __le32 rx_detected_cnt;
1541 __le32 bt_prio_defer_cnt;
1542 __le32 bt_prio_kill_cnt;
1543 __le32 few_bytes_cnt;
1544 __le32 cts_timeout;
1545 __le32 ack_timeout;
1546 __le32 expected_ack_cnt;
1547 __le32 actual_ack_cnt;
1548#if IWL == 4965
1549 __le32 dump_msdu_cnt;
1550 __le32 burst_abort_next_frame_mismatch_cnt;
1551 __le32 burst_abort_missing_next_frame_cnt;
1552 __le32 cts_timeout_collision;
1553 __le32 ack_or_ba_timeout_collision;
1554 struct statistics_tx_non_phy_agg agg;
1555#endif
1556} __attribute__ ((packed));
1557
1558struct statistics_dbg {
1559 __le32 burst_check;
1560 __le32 burst_count;
1561 __le32 reserved[4];
1562} __attribute__ ((packed));
1563
1564struct statistics_div {
1565 __le32 tx_on_a;
1566 __le32 tx_on_b;
1567 __le32 exec_time;
1568 __le32 probe_time;
1569#if IWL == 4965
1570 __le32 reserved1;
1571 __le32 reserved2;
1572#endif
1573} __attribute__ ((packed));
1574
1575struct statistics_general {
1576 __le32 temperature;
1577#if IWL == 4965
1578 __le32 temperature_m;
1579#endif
1580 struct statistics_dbg dbg;
1581 __le32 sleep_time;
1582 __le32 slots_out;
1583 __le32 slots_idle;
1584 __le32 ttl_timestamp;
1585 struct statistics_div div;
1586#if IWL == 4965
1587 __le32 rx_enable_counter;
1588 __le32 reserved1;
1589 __le32 reserved2;
1590 __le32 reserved3;
1591#endif
1592} __attribute__ ((packed));
1593
1594/*
1595 * REPLY_STATISTICS_CMD = 0x9c,
1596 * 3945 and 4965 identical.
1597 *
1598 * This command triggers an immediate response containing uCode statistics.
1599 * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
1600 *
1601 * If the CLEAR_STATS configuration flag is set, uCode will clear its
1602 * internal copy of the statistics (counters) after issuing the response.
1603 * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
1604 *
1605 * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
1606 * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
1607 * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
1608 */
1609#define IWL_STATS_CONF_CLEAR_STATS __constant_cpu_to_le32(0x1) /* see above */
1610#define IWL_STATS_CONF_DISABLE_NOTIF __constant_cpu_to_le32(0x2)/* see above */
1611struct iwl_statistics_cmd {
1612 __le32 configuration_flags; /* IWL_STATS_CONF_* */
1613} __attribute__ ((packed));
1614
1615/*
1616 * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
1617 *
1618 * By default, uCode issues this notification after receiving a beacon
1619 * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
1620 * REPLY_STATISTICS_CMD 0x9c, above.
1621 *
1622 * Statistics counters continue to increment beacon after beacon, but are
1623 * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
1624 * 0x9c with CLEAR_STATS bit set (see above).
1625 *
1626 * uCode also issues this notification during scans. uCode clears statistics
1627 * appropriately so that each notification contains statistics for only the
1628 * one channel that has just been scanned.
1629 */
1630#define STATISTICS_REPLY_FLG_BAND_24G_MSK __constant_cpu_to_le32(0x2)
1631#define STATISTICS_REPLY_FLG_FAT_MODE_MSK __constant_cpu_to_le32(0x8)
1632struct iwl_notif_statistics {
1633 __le32 flag;
1634 struct statistics_rx rx;
1635 struct statistics_tx tx;
1636 struct statistics_general general;
1637} __attribute__ ((packed));
1638
1639
1640/*
1641 * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
1642 */
1643/* if ucode missed CONSECUTIVE_MISSED_BCONS_TH beacons in a row,
1644 * then this notification will be sent. */
1645#define CONSECUTIVE_MISSED_BCONS_TH 20
1646
1647struct iwl_missed_beacon_notif {
1648 __le32 consequtive_missed_beacons;
1649 __le32 total_missed_becons;
1650 __le32 num_expected_beacons;
1651 __le32 num_recvd_beacons;
1652} __attribute__ ((packed));
1653
1654/******************************************************************************
1655 * (11)
1656 * Rx Calibration Commands:
1657 *
1658 *****************************************************************************/
1659
1660#define PHY_CALIBRATE_DIFF_GAIN_CMD (7)
1661#define HD_TABLE_SIZE (11)
1662
1663struct iwl_sensitivity_cmd {
1664 __le16 control;
1665 __le16 table[HD_TABLE_SIZE];
1666} __attribute__ ((packed));
1667
1668struct iwl_calibration_cmd {
1669 u8 opCode;
1670 u8 flags;
1671 __le16 reserved;
1672 s8 diff_gain_a;
1673 s8 diff_gain_b;
1674 s8 diff_gain_c;
1675 u8 reserved1;
1676} __attribute__ ((packed));
1677
1678/******************************************************************************
1679 * (12)
1680 * Miscellaneous Commands:
1681 *
1682 *****************************************************************************/
1683
1684/*
1685 * LEDs Command & Response
1686 * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
1687 *
1688 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
1689 * this command turns it on or off, or sets up a periodic blinking cycle.
1690 */
1691struct iwl_led_cmd {
1692 __le32 interval; /* "interval" in uSec */
1693 u8 id; /* 1: Activity, 2: Link, 3: Tech */
1694 u8 off; /* # intervals off while blinking;
1695 * "0", with >0 "on" value, turns LED on */
1696 u8 on; /* # intervals on while blinking;
1697 * "0", regardless of "off", turns LED off */
1698 u8 reserved;
1699} __attribute__ ((packed));
1700
1701/******************************************************************************
1702 * (13)
1703 * Union of all expected notifications/responses:
1704 *
1705 *****************************************************************************/
1706
1707struct iwl_rx_packet {
1708 __le32 len;
1709 struct iwl_cmd_header hdr;
1710 union {
1711 struct iwl_alive_resp alive_frame;
1712 struct iwl_rx_frame rx_frame;
1713 struct iwl_tx_resp tx_resp;
1714 struct iwl_spectrum_notification spectrum_notif;
1715 struct iwl_csa_notification csa_notif;
1716 struct iwl_error_resp err_resp;
1717 struct iwl_card_state_notif card_state_notif;
1718 struct iwl_beacon_notif beacon_status;
1719 struct iwl_add_sta_resp add_sta;
1720 struct iwl_sleep_notification sleep_notif;
1721 struct iwl_spectrum_resp spectrum;
1722 struct iwl_notif_statistics stats;
1723#if IWL == 4965
1724 struct iwl_compressed_ba_resp compressed_ba;
1725 struct iwl_missed_beacon_notif missed_beacon;
1726#endif
1727 __le32 status;
1728 u8 raw[0];
1729 } u;
1730} __attribute__ ((packed));
1731
1732#define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl_rx_frame))
1733
1734#endif /* __iwl_commands_h__ */