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