Merge branch 'for-linus' of git://neil.brown.name/md
[linux-2.6] / drivers / net / wireless / iwmc3200wifi / lmac.h
1 /*
2  * Intel Wireless Multicomm 3200 WiFi driver
3  *
4  * Copyright (C) 2009 Intel Corporation. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  *   * Redistributions of source code must retain the above copyright
11  *     notice, this list of conditions and the following disclaimer.
12  *   * Redistributions in binary form must reproduce the above copyright
13  *     notice, this list of conditions and the following disclaimer in
14  *     the documentation and/or other materials provided with the
15  *     distribution.
16  *   * Neither the name of Intel Corporation nor the names of its
17  *     contributors may be used to endorse or promote products derived
18  *     from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  *
33  * Intel Corporation <ilw@linux.intel.com>
34  * Samuel Ortiz <samuel.ortiz@intel.com>
35  * Zhu Yi <yi.zhu@intel.com>
36  *
37  */
38
39 #ifndef __IWM_LMAC_H__
40 #define __IWM_LMAC_H__
41
42 struct iwm_lmac_hdr {
43         u8 id;
44         u8 flags;
45         __le16 seq_num;
46 } __attribute__ ((packed));
47
48 /* LMAC commands */
49 #define CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_AFTER_MSK  0x1
50
51 struct iwm_lmac_cal_cfg_elt {
52         __le32 enable; /* 1 means LMAC needs to do something */
53         __le32 start;  /* 1 to start calibration, 0 to stop */
54         __le32 send_res; /* 1 for sending back results */
55         __le32 apply_res; /* 1 for applying calibration results to HW */
56         __le32 reserved;
57 } __attribute__ ((packed));
58
59 struct iwm_lmac_cal_cfg_status {
60         struct iwm_lmac_cal_cfg_elt init;
61         struct iwm_lmac_cal_cfg_elt periodic;
62         __le32 flags; /* CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_AFTER_MSK */
63 } __attribute__ ((packed));
64
65 struct iwm_lmac_cal_cfg_cmd {
66         struct iwm_lmac_cal_cfg_status ucode_cfg;
67         struct iwm_lmac_cal_cfg_status driver_cfg;
68         __le32 reserved;
69 } __attribute__ ((packed));
70
71 struct iwm_lmac_cal_cfg_resp {
72         __le32 status;
73 } __attribute__ ((packed));
74
75 #define IWM_CARD_STATE_SW_HW_ENABLED    0x00
76 #define IWM_CARD_STATE_HW_DISABLED      0x01
77 #define IWM_CARD_STATE_SW_DISABLED      0x02
78 #define IWM_CARD_STATE_CTKILL_DISABLED  0x04
79 #define IWM_CARD_STATE_IS_RXON          0x10
80
81 struct iwm_lmac_card_state {
82         __le32 flags;
83 } __attribute__ ((packed));
84
85 /**
86  * COEX_PRIORITY_TABLE_CMD
87  *
88  * Priority entry for each state
89  * Will keep two tables, for STA and WIPAN
90  */
91 enum {
92         /* UN-ASSOCIATION PART */
93         COEX_UNASSOC_IDLE = 0,
94         COEX_UNASSOC_MANUAL_SCAN,
95         COEX_UNASSOC_AUTO_SCAN,
96
97         /* CALIBRATION */
98         COEX_CALIBRATION,
99         COEX_PERIODIC_CALIBRATION,
100
101         /* CONNECTION */
102         COEX_CONNECTION_ESTAB,
103
104         /* ASSOCIATION PART */
105         COEX_ASSOCIATED_IDLE,
106         COEX_ASSOC_MANUAL_SCAN,
107         COEX_ASSOC_AUTO_SCAN,
108         COEX_ASSOC_ACTIVE_LEVEL,
109
110         /* RF ON/OFF */
111         COEX_RF_ON,
112         COEX_RF_OFF,
113         COEX_STAND_ALONE_DEBUG,
114
115         /* IPNN */
116         COEX_IPAN_ASSOC_LEVEL,
117
118         /* RESERVED */
119         COEX_RSRVD1,
120         COEX_RSRVD2,
121
122         COEX_EVENTS_NUM
123 };
124
125 #define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK      0x1
126 #define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK      0x2
127 #define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_MSK        0x4
128
129 struct coex_event {
130         u8 req_prio;
131         u8 win_med_prio;
132         u8 reserved;
133         u8 flags;
134 } __attribute__ ((packed));
135
136 #define COEX_FLAGS_STA_TABLE_VALID_MSK          0x1
137 #define COEX_FLAGS_UNASSOC_WAKEUP_UMASK_MSK     0x4
138 #define COEX_FLAGS_ASSOC_WAKEUP_UMASK_MSK       0x8
139 #define COEX_FLAGS_COEX_ENABLE_MSK              0x80
140
141 struct iwm_coex_prio_table_cmd {
142         u8 flags;
143         u8 reserved[3];
144         struct coex_event sta_prio[COEX_EVENTS_NUM];
145 } __attribute__ ((packed));
146
147 /* Coexistence definitions
148  *
149  * Constants to fill in the Priorities' Tables
150  * RP - Requested Priority
151  * WP - Win Medium Priority: priority assigned when the contention has been won
152  * FLAGS - Combination of COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK and
153  *         COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK
154  */
155
156 #define COEX_UNASSOC_IDLE_FLAGS         0
157 #define COEX_UNASSOC_MANUAL_SCAN_FLAGS  (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
158                                          COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
159 #define COEX_UNASSOC_AUTO_SCAN_FLAGS    (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
160                                          COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
161 #define COEX_CALIBRATION_FLAGS          (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
162                                          COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
163 #define COEX_PERIODIC_CALIBRATION_FLAGS 0
164 /* COEX_CONNECTION_ESTAB: we need DELAY_MEDIUM_FREE_NTFY to let WiMAX
165  * disconnect from network. */
166 #define COEX_CONNECTION_ESTAB_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
167                                      COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK | \
168                                      COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_MSK)
169 #define COEX_ASSOCIATED_IDLE_FLAGS      0
170 #define COEX_ASSOC_MANUAL_SCAN_FLAGS    (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
171                                          COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
172 #define COEX_ASSOC_AUTO_SCAN_FLAGS      (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
173                                          COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
174 #define COEX_ASSOC_ACTIVE_LEVEL_FLAGS   0
175 #define COEX_RF_ON_FLAGS                0
176 #define COEX_RF_OFF_FLAGS               0
177 #define COEX_STAND_ALONE_DEBUG_FLAGS    (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
178                                          COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK)
179 #define COEX_IPAN_ASSOC_LEVEL_FLAGS (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
180                                      COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK | \
181                                      COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_MSK)
182 #define COEX_RSRVD1_FLAGS               0
183 #define COEX_RSRVD2_FLAGS               0
184 /* XOR_RF_ON is the event wrapping all radio ownership. We need
185  * DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network. */
186 #define COEX_XOR_RF_ON_FLAGS        (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_MSK | \
187                                      COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_MSK | \
188                                      COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_MSK)
189
190 /* LMAC OP CODES */
191 #define REPLY_PAD                       0x0
192 #define REPLY_ALIVE                     0x1
193 #define REPLY_ERROR                     0x2
194 #define REPLY_ECHO                      0x3
195 #define REPLY_HALT                      0x6
196
197 /* RXON state commands */
198 #define REPLY_RX_ON                     0x10
199 #define REPLY_RX_ON_ASSOC               0x11
200 #define REPLY_RX_OFF                    0x12
201 #define REPLY_QOS_PARAM                 0x13
202 #define REPLY_RX_ON_TIMING              0x14
203 #define REPLY_INTERNAL_QOS_PARAM        0x15
204 #define REPLY_RX_INT_TIMEOUT_CNFG       0x16
205 #define REPLY_NULL                      0x17
206
207 /* Multi-Station support */
208 #define REPLY_ADD_STA                   0x18
209 #define REPLY_REMOVE_STA                0x19
210 #define REPLY_RESET_ALL_STA             0x1a
211
212 /* RX, TX */
213 #define REPLY_ALM_RX                    0x1b
214 #define REPLY_TX                        0x1c
215 #define REPLY_TXFIFO_FLUSH              0x1e
216
217 /* MISC commands */
218 #define REPLY_MGMT_MCAST_KEY            0x1f
219 #define REPLY_WEPKEY                    0x20
220 #define REPLY_INIT_IV                   0x21
221 #define REPLY_WRITE_MIB                 0x22
222 #define REPLY_READ_MIB                  0x23
223 #define REPLY_RADIO_FE                  0x24
224 #define REPLY_TXFIFO_CFG                0x25
225 #define REPLY_WRITE_READ                0x26
226 #define REPLY_INSTALL_SEC_KEY           0x27
227
228
229 #define REPLY_RATE_SCALE                0x47
230 #define REPLY_LEDS_CMD                  0x48
231 #define REPLY_TX_LINK_QUALITY_CMD       0x4e
232 #define REPLY_ANA_MIB_OVERRIDE_CMD      0x4f
233 #define REPLY_WRITE2REG_CMD             0x50
234
235 /* winfi-wifi coexistence */
236 #define COEX_PRIORITY_TABLE_CMD         0x5a
237 #define COEX_MEDIUM_NOTIFICATION        0x5b
238 #define COEX_EVENT_CMD                  0x5c
239
240 /* more Protocol and Protocol-test commands */
241 #define REPLY_MAX_SLEEP_TIME_CMD        0x61
242 #define CALIBRATION_CFG_CMD             0x65
243 #define CALIBRATION_RES_NOTIFICATION    0x66
244 #define CALIBRATION_COMPLETE_NOTIFICATION       0x67
245
246 /* Measurements */
247 #define REPLY_QUIET_CMD                 0x71
248 #define REPLY_CHANNEL_SWITCH            0x72
249 #define CHANNEL_SWITCH_NOTIFICATION     0x73
250
251 #define REPLY_SPECTRUM_MEASUREMENT_CMD  0x74
252 #define SPECTRUM_MEASURE_NOTIFICATION   0x75
253 #define REPLY_MEASUREMENT_ABORT_CMD     0x76
254
255 /* Power Management */
256 #define POWER_TABLE_CMD                 0x77
257 #define SAVE_RESTORE_ADRESS_CMD         0x78
258 #define REPLY_WATERMARK_CMD             0x79
259 #define PM_DEBUG_STATISTIC_NOTIFIC      0x7B
260 #define PD_FLUSH_N_NOTIFICATION         0x7C
261
262 /* Scan commands and notifications */
263 #define REPLY_SCAN_REQUEST_CMD          0x80
264 #define REPLY_SCAN_ABORT_CMD            0x81
265 #define SCAN_START_NOTIFICATION         0x82
266 #define SCAN_RESULTS_NOTIFICATION       0x83
267 #define SCAN_COMPLETE_NOTIFICATION      0x84
268
269 /* Continuous TX commands */
270 #define REPLY_CONT_TX_CMD               0x85
271 #define END_OF_CONT_TX_NOTIFICATION     0x86
272
273 /* Timer/Eeprom commands */
274 #define TIMER_CMD                       0x87
275 #define EEPROM_WRITE_CMD                0x88
276
277 /* PAPD commands */
278 #define FEEDBACK_REQUEST_NOTIFICATION   0x8b
279 #define REPLY_CW_CMD                    0x8c
280
281 /* IBSS/AP commands Continue */
282 #define BEACON_NOTIFICATION             0x90
283 #define REPLY_TX_BEACON                 0x91
284 #define REPLY_REQUEST_ATIM              0x93
285 #define WHO_IS_AWAKE_NOTIFICATION       0x94
286 #define TX_PWR_DBM_LIMIT_CMD            0x95
287 #define QUIET_NOTIFICATION              0x96
288 #define TX_PWR_TABLE_CMD                0x97
289 #define TX_ANT_CONFIGURATION_CMD        0x98
290 #define MEASURE_ABORT_NOTIFICATION      0x99
291 #define REPLY_CALIBRATION_TUNE          0x9a
292
293 /* bt config command */
294 #define REPLY_BT_CONFIG                 0x9b
295 #define REPLY_STATISTICS_CMD            0x9c
296 #define STATISTICS_NOTIFICATION         0x9d
297
298 /* RF-KILL commands and notifications */
299 #define REPLY_CARD_STATE_CMD            0xa0
300 #define CARD_STATE_NOTIFICATION         0xa1
301
302 /* Missed beacons notification */
303 #define MISSED_BEACONS_NOTIFICATION     0xa2
304 #define MISSED_BEACONS_NOTIFICATION_TH_CMD      0xa3
305
306 #define REPLY_CT_KILL_CONFIG_CMD        0xa4
307
308 /* HD commands and notifications */
309 #define REPLY_HD_PARAMS_CMD             0xa6
310 #define HD_PARAMS_NOTIFICATION          0xa7
311 #define SENSITIVITY_CMD                 0xa8
312 #define U_APSD_PARAMS_CMD               0xa9
313 #define NOISY_PLATFORM_CMD              0xaa
314 #define ILLEGAL_CMD                     0xac
315 #define REPLY_PHY_CALIBRATION_CMD       0xb0
316 #define REPLAY_RX_GAIN_CALIB_CMD        0xb1
317
318 /* WiPAN commands */
319 #define REPLY_WIPAN_PARAMS_CMD          0xb2
320 #define REPLY_WIPAN_RX_ON_CMD           0xb3
321 #define REPLY_WIPAN_RX_ON_TIMING        0xb4
322 #define REPLY_WIPAN_TX_PWR_TABLE_CMD    0xb5
323 #define REPLY_WIPAN_RXON_ASSOC_CMD      0xb6
324 #define REPLY_WIPAN_QOS_PARAM           0xb7
325 #define WIPAN_REPLY_WEPKEY              0xb8
326
327 /* BeamForming commands */
328 #define BEAMFORMER_CFG_CMD              0xba
329 #define BEAMFORMEE_NOTIFICATION         0xbb
330
331 /* TGn new Commands */
332 #define REPLY_RX_PHY_CMD                0xc0
333 #define REPLY_RX_MPDU_CMD               0xc1
334 #define REPLY_MULTICAST_HASH            0xc2
335 #define REPLY_KDR_RX                    0xc3
336 #define REPLY_RX_DSP_EXT_INFO           0xc4
337 #define REPLY_COMPRESSED_BA             0xc5
338
339 /* PNC commands */
340 #define PNC_CONFIG_CMD                  0xc8
341 #define PNC_UPDATE_TABLE_CMD            0xc9
342 #define XVT_GENERAL_CTRL_CMD            0xca
343 #define REPLY_LEGACY_RADIO_FE           0xdd
344
345 /* WoWLAN commands */
346 #define WOWLAN_PATTERNS                 0xe0
347 #define WOWLAN_WAKEUP_FILTER            0xe1
348 #define WOWLAN_TSC_RSC_PARAM            0xe2
349 #define WOWLAN_TKIP_PARAM               0xe3
350 #define WOWLAN_KEK_KCK_MATERIAL         0xe4
351 #define WOWLAN_GET_STATUSES             0xe5
352 #define WOWLAN_TX_POWER_PER_DB          0xe6
353 #define REPLY_WOWLAN_GET_STATUSES       WOWLAN_GET_STATUSES
354
355 #define REPLY_DEBUG_CMD                 0xf0
356 #define REPLY_DSP_DEBUG_CMD             0xf1
357 #define REPLY_DEBUG_MONITOR_CMD         0xf2
358 #define REPLY_DEBUG_XVT_CMD             0xf3
359 #define REPLY_DEBUG_DC_CALIB            0xf4
360 #define REPLY_DYNAMIC_BP                0xf5
361
362 /* General purpose Commands */
363 #define REPLY_GP1_CMD                   0xfa
364 #define REPLY_GP2_CMD                   0xfb
365 #define REPLY_GP3_CMD                   0xfc
366 #define REPLY_GP4_CMD                   0xfd
367 #define REPLY_REPLAY_WRAPPER            0xfe
368 #define REPLY_FRAME_DURATION_CALC_CMD   0xff
369
370 #define LMAC_COMMAND_ID_MAX             0xff
371 #define LMAC_COMMAND_ID_NUM             (LMAC_COMMAND_ID_MAX + 1)
372
373
374 /* Calibration */
375
376 enum {
377         PHY_CALIBRATE_DC_CMD                    = 0,
378         PHY_CALIBRATE_LO_CMD                    = 1,
379         PHY_CALIBRATE_RX_BB_CMD                 = 2,
380         PHY_CALIBRATE_TX_IQ_CMD                 = 3,
381         PHY_CALIBRATE_RX_IQ_CMD                 = 4,
382         PHY_CALIBRATION_NOISE_CMD               = 5,
383         PHY_CALIBRATE_AGC_TABLE_CMD             = 6,
384         PHY_CALIBRATE_CRYSTAL_FRQ_CMD           = 7,
385         PHY_CALIBRATE_OPCODES_NUM,
386         SHILOH_PHY_CALIBRATE_DC_CMD             = 8,
387         SHILOH_PHY_CALIBRATE_LO_CMD             = 9,
388         SHILOH_PHY_CALIBRATE_RX_BB_CMD          = 10,
389         SHILOH_PHY_CALIBRATE_TX_IQ_CMD          = 11,
390         SHILOH_PHY_CALIBRATE_RX_IQ_CMD          = 12,
391         SHILOH_PHY_CALIBRATION_NOISE_CMD        = 13,
392         SHILOH_PHY_CALIBRATE_AGC_TABLE_CMD      = 14,
393         SHILOH_PHY_CALIBRATE_CRYSTAL_FRQ_CMD    = 15,
394         SHILOH_PHY_CALIBRATE_BASE_BAND_CMD      = 16,
395         SHILOH_PHY_CALIBRATE_TXIQ_PERIODIC_CMD  = 17,
396         CALIBRATION_CMD_NUM,
397 };
398
399 struct iwm_lmac_calib_hdr {
400         u8 opcode;
401         u8 first_grp;
402         u8 grp_num;
403         u8 all_data_valid;
404 } __attribute__ ((packed));
405
406 #define IWM_LMAC_CALIB_FREQ_GROUPS_NR   7
407 #define IWM_CALIB_FREQ_GROUPS_NR        5
408 #define IWM_CALIB_DC_MODES_NR           12
409
410 struct iwm_calib_rxiq_entry {
411         u16 ptam_postdist_ars;
412         u16 ptam_postdist_arc;
413 } __attribute__ ((packed));
414
415 struct iwm_calib_rxiq_group {
416         struct iwm_calib_rxiq_entry mode[IWM_CALIB_DC_MODES_NR];
417 } __attribute__ ((packed));
418
419 struct iwm_lmac_calib_rxiq {
420         struct iwm_calib_rxiq_group group[IWM_LMAC_CALIB_FREQ_GROUPS_NR];
421 } __attribute__ ((packed));
422
423 struct iwm_calib_rxiq {
424         struct iwm_lmac_calib_hdr hdr;
425         struct iwm_calib_rxiq_group group[IWM_CALIB_FREQ_GROUPS_NR];
426 } __attribute__ ((packed));
427
428 #define LMAC_STA_ID_SEED        0x0f
429 #define LMAC_STA_ID_POS         0
430
431 #define LMAC_STA_COLOR_SEED     0x7
432 #define LMAC_STA_COLOR_POS      4
433
434 struct iwm_lmac_power_report {
435         u8 pa_status;
436         u8 pa_integ_res_A[3];
437         u8 pa_integ_res_B[3];
438         u8 pa_integ_res_C[3];
439 } __attribute__ ((packed));
440
441 struct iwm_lmac_tx_resp {
442         u8 frame_cnt; /* 1-no aggregation, greater then 1 - aggregation */
443         u8 bt_kill_cnt;
444         __le16 retry_cnt;
445         __le32 initial_tx_rate;
446         __le16 wireless_media_time;
447         struct iwm_lmac_power_report power_report;
448         __le32 tfd_info;
449         __le16 seq_ctl;
450         __le16 byte_cnt;
451         u8 tlc_rate_info;
452         u8 ra_tid;
453         __le16 frame_ctl;
454         __le32 status;
455 } __attribute__ ((packed));
456
457 #endif