p54: generate channel list dynamically
[safe/jmp/linux-2.6] / drivers / net / wireless / p54 / lmac.h
1 /*
2  * LMAC Interface specific definitions for mac80211 Prism54 drivers
3  *
4  * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
5  * Copyright (c) 2007 - 2009, Christian Lamparter <chunkeey@web.de>
6  *
7  * Based on:
8  * - the islsm (softmac prism54) driver, which is:
9  *   Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
10  *
11  * - LMAC API interface header file for STLC4560 (lmac_longbow.h)
12  *   Copyright (C) 2007 Conexant Systems, Inc.
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License version 2 as
16  * published by the Free Software Foundation.
17  */
18
19 #ifndef LMAC_H
20 #define LMAC_H
21
22 enum p54_control_frame_types {
23         P54_CONTROL_TYPE_SETUP = 0,
24         P54_CONTROL_TYPE_SCAN,
25         P54_CONTROL_TYPE_TRAP,
26         P54_CONTROL_TYPE_DCFINIT,
27         P54_CONTROL_TYPE_RX_KEYCACHE,
28         P54_CONTROL_TYPE_TIM,
29         P54_CONTROL_TYPE_PSM,
30         P54_CONTROL_TYPE_TXCANCEL,
31         P54_CONTROL_TYPE_TXDONE,
32         P54_CONTROL_TYPE_BURST,
33         P54_CONTROL_TYPE_STAT_READBACK,
34         P54_CONTROL_TYPE_BBP,
35         P54_CONTROL_TYPE_EEPROM_READBACK,
36         P54_CONTROL_TYPE_LED,
37         P54_CONTROL_TYPE_GPIO,
38         P54_CONTROL_TYPE_TIMER,
39         P54_CONTROL_TYPE_MODULATION,
40         P54_CONTROL_TYPE_SYNTH_CONFIG,
41         P54_CONTROL_TYPE_DETECTOR_VALUE,
42         P54_CONTROL_TYPE_XBOW_SYNTH_CFG,
43         P54_CONTROL_TYPE_CCE_QUIET,
44         P54_CONTROL_TYPE_PSM_STA_UNLOCK,
45         P54_CONTROL_TYPE_PCS,
46         P54_CONTROL_TYPE_BT_BALANCER = 28,
47         P54_CONTROL_TYPE_GROUP_ADDRESS_TABLE = 30,
48         P54_CONTROL_TYPE_ARPTABLE = 31,
49         P54_CONTROL_TYPE_BT_OPTIONS = 35,
50 };
51
52 #define P54_HDR_FLAG_CONTROL            BIT(15)
53 #define P54_HDR_FLAG_CONTROL_OPSET      (BIT(15) + BIT(0))
54 #define P54_HDR_FLAG_DATA_ALIGN         BIT(14)
55
56 #define P54_HDR_FLAG_DATA_OUT_PROMISC           BIT(0)
57 #define P54_HDR_FLAG_DATA_OUT_TIMESTAMP         BIT(1)
58 #define P54_HDR_FLAG_DATA_OUT_SEQNR             BIT(2)
59 #define P54_HDR_FLAG_DATA_OUT_BIT3              BIT(3)
60 #define P54_HDR_FLAG_DATA_OUT_BURST             BIT(4)
61 #define P54_HDR_FLAG_DATA_OUT_NOCANCEL          BIT(5)
62 #define P54_HDR_FLAG_DATA_OUT_CLEARTIM          BIT(6)
63 #define P54_HDR_FLAG_DATA_OUT_HITCHHIKE         BIT(7)
64 #define P54_HDR_FLAG_DATA_OUT_COMPRESS          BIT(8)
65 #define P54_HDR_FLAG_DATA_OUT_CONCAT            BIT(9)
66 #define P54_HDR_FLAG_DATA_OUT_PCS_ACCEPT        BIT(10)
67 #define P54_HDR_FLAG_DATA_OUT_WAITEOSP          BIT(11)
68
69 #define P54_HDR_FLAG_DATA_IN_FCS_GOOD           BIT(0)
70 #define P54_HDR_FLAG_DATA_IN_MATCH_MAC          BIT(1)
71 #define P54_HDR_FLAG_DATA_IN_MCBC               BIT(2)
72 #define P54_HDR_FLAG_DATA_IN_BEACON             BIT(3)
73 #define P54_HDR_FLAG_DATA_IN_MATCH_BSS          BIT(4)
74 #define P54_HDR_FLAG_DATA_IN_BCAST_BSS          BIT(5)
75 #define P54_HDR_FLAG_DATA_IN_DATA               BIT(6)
76 #define P54_HDR_FLAG_DATA_IN_TRUNCATED          BIT(7)
77 #define P54_HDR_FLAG_DATA_IN_BIT8               BIT(8)
78 #define P54_HDR_FLAG_DATA_IN_TRANSPARENT        BIT(9)
79
80 struct p54_hdr {
81         __le16 flags;
82         __le16 len;
83         __le32 req_id;
84         __le16 type;    /* enum p54_control_frame_types */
85         u8 rts_tries;
86         u8 tries;
87         u8 data[0];
88 } __packed;
89
90 #define GET_REQ_ID(skb)                                                 \
91         (((struct p54_hdr *) ((struct sk_buff *) skb)->data)->req_id)   \
92
93 #define FREE_AFTER_TX(skb)                                              \
94         ((((struct p54_hdr *) ((struct sk_buff *) skb)->data)->         \
95         flags) == cpu_to_le16(P54_HDR_FLAG_CONTROL_OPSET))
96
97 #define IS_DATA_FRAME(skb)                                              \
98         (!((((struct p54_hdr *) ((struct sk_buff *) skb)->data)->       \
99         flags) & cpu_to_le16(P54_HDR_FLAG_CONTROL)))
100
101 /*
102  * shared interface ID definitions
103  * The interface ID is a unique identification of a specific interface.
104  * The following values are reserved: 0x0000, 0x0002, 0x0012, 0x0014, 0x0015
105  */
106 #define IF_ID_ISL36356A                 0x0001  /* ISL36356A <-> Firmware */
107 #define IF_ID_MVC                       0x0003  /* MAC Virtual Coprocessor */
108 #define IF_ID_DEBUG                     0x0008  /* PolDebug Interface */
109 #define IF_ID_PRODUCT                   0x0009
110 #define IF_ID_OEM                       0x000a
111 #define IF_ID_PCI3877                   0x000b  /* 3877 <-> Host PCI */
112 #define IF_ID_ISL37704C                 0x000c  /* ISL37704C <-> Fw */
113 #define IF_ID_ISL39000                  0x000f  /* ISL39000 <-> Fw */
114 #define IF_ID_ISL39300A                 0x0010  /* ISL39300A <-> Fw */
115 #define IF_ID_ISL37700_UAP              0x0016  /* ISL37700 uAP Fw <-> Fw */
116 #define IF_ID_ISL39000_UAP              0x0017  /* ISL39000 uAP Fw <-> Fw */
117 #define IF_ID_LMAC                      0x001a  /* Interface exposed by LMAC */
118
119 struct exp_if {
120         __le16 role;
121         __le16 if_id;
122         __le16 variant;
123         __le16 btm_compat;
124         __le16 top_compat;
125 } __packed;
126
127 struct dep_if {
128         __le16 role;
129         __le16 if_id;
130         __le16 variant;
131 } __packed;
132
133 /* driver <-> lmac definitions */
134 struct p54_eeprom_lm86 {
135         union {
136                 struct {
137                         __le16 offset;
138                         __le16 len;
139                         u8 data[0];
140                 } __packed v1;
141                 struct {
142                         __le32 offset;
143                         __le16 len;
144                         u8 magic2;
145                         u8 pad;
146                         u8 magic[4];
147                         u8 data[0];
148                 } __packed v2;
149         }  __packed;
150 } __packed;
151
152 enum p54_rx_decrypt_status {
153         P54_DECRYPT_NONE = 0,
154         P54_DECRYPT_OK,
155         P54_DECRYPT_NOKEY,
156         P54_DECRYPT_NOMICHAEL,
157         P54_DECRYPT_NOCKIPMIC,
158         P54_DECRYPT_FAIL_WEP,
159         P54_DECRYPT_FAIL_TKIP,
160         P54_DECRYPT_FAIL_MICHAEL,
161         P54_DECRYPT_FAIL_CKIPKP,
162         P54_DECRYPT_FAIL_CKIPMIC,
163         P54_DECRYPT_FAIL_AESCCMP
164 };
165
166 struct p54_rx_data {
167         __le16 flags;
168         __le16 len;
169         __le16 freq;
170         u8 antenna;
171         u8 rate;
172         u8 rssi;
173         u8 quality;
174         u8 decrypt_status;
175         u8 rssi_raw;
176         __le32 tsf32;
177         __le32 unalloc0;
178         u8 align[0];
179 } __packed;
180
181 enum p54_trap_type {
182         P54_TRAP_SCAN = 0,
183         P54_TRAP_TIMER,
184         P54_TRAP_BEACON_TX,
185         P54_TRAP_FAA_RADIO_ON,
186         P54_TRAP_FAA_RADIO_OFF,
187         P54_TRAP_RADAR,
188         P54_TRAP_NO_BEACON,
189         P54_TRAP_TBTT,
190         P54_TRAP_SCO_ENTER,
191         P54_TRAP_SCO_EXIT
192 };
193
194 struct p54_trap {
195         __le16 event;
196         __le16 frequency;
197 } __packed;
198
199 enum p54_frame_sent_status {
200         P54_TX_OK = 0,
201         P54_TX_FAILED,
202         P54_TX_PSM,
203         P54_TX_PSM_CANCELLED = 4
204 };
205
206 struct p54_frame_sent {
207         u8 status;
208         u8 tries;
209         u8 ack_rssi;
210         u8 quality;
211         __le16 seq;
212         u8 antenna;
213         u8 padding;
214 } __packed;
215
216 enum p54_tx_data_crypt {
217         P54_CRYPTO_NONE = 0,
218         P54_CRYPTO_WEP,
219         P54_CRYPTO_TKIP,
220         P54_CRYPTO_TKIPMICHAEL,
221         P54_CRYPTO_CCX_WEPMIC,
222         P54_CRYPTO_CCX_KPMIC,
223         P54_CRYPTO_CCX_KP,
224         P54_CRYPTO_AESCCMP
225 };
226
227 enum p54_tx_data_queue {
228         P54_QUEUE_BEACON        = 0,
229         P54_QUEUE_FWSCAN        = 1,
230         P54_QUEUE_MGMT          = 2,
231         P54_QUEUE_CAB           = 3,
232         P54_QUEUE_DATA          = 4,
233
234         P54_QUEUE_AC_NUM        = 4,
235         P54_QUEUE_AC_VO         = 4,
236         P54_QUEUE_AC_VI         = 5,
237         P54_QUEUE_AC_BE         = 6,
238         P54_QUEUE_AC_BK         = 7,
239
240         /* keep last */
241         P54_QUEUE_NUM           = 8,
242 };
243
244 #define IS_QOS_QUEUE(n) (n >= P54_QUEUE_DATA)
245
246 struct p54_tx_data {
247         u8 rateset[8];
248         u8 rts_rate_idx;
249         u8 crypt_offset;
250         u8 key_type;
251         u8 key_len;
252         u8 key[16];
253         u8 hw_queue;
254         u8 backlog;
255         __le16 durations[4];
256         u8 tx_antenna;
257         union {
258                 struct {
259                         u8 cts_rate;
260                         __le16 output_power;
261                 } __packed longbow;
262                 struct {
263                         u8 output_power;
264                         u8 cts_rate;
265                         u8 unalloc;
266                 } __packed normal;
267         } __packed;
268         u8 unalloc2[2];
269         u8 align[0];
270 } __packed;
271
272 /* unit is ms */
273 #define P54_TX_FRAME_LIFETIME 2000
274 #define P54_TX_TIMEOUT 4000
275 #define P54_STATISTICS_UPDATE 5000
276
277 #define P54_FILTER_TYPE_NONE            0
278 #define P54_FILTER_TYPE_STATION         BIT(0)
279 #define P54_FILTER_TYPE_IBSS            BIT(1)
280 #define P54_FILTER_TYPE_AP              BIT(2)
281 #define P54_FILTER_TYPE_TRANSPARENT     BIT(3)
282 #define P54_FILTER_TYPE_PROMISCUOUS     BIT(4)
283 #define P54_FILTER_TYPE_HIBERNATE       BIT(5)
284 #define P54_FILTER_TYPE_NOACK           BIT(6)
285 #define P54_FILTER_TYPE_RX_DISABLED     BIT(7)
286
287 struct p54_setup_mac {
288         __le16 mac_mode;
289         u8 mac_addr[ETH_ALEN];
290         u8 bssid[ETH_ALEN];
291         u8 rx_antenna;
292         u8 rx_align;
293         union {
294                 struct {
295                         __le32 basic_rate_mask;
296                         u8 rts_rates[8];
297                         __le32 rx_addr;
298                         __le16 max_rx;
299                         __le16 rxhw;
300                         __le16 wakeup_timer;
301                         __le16 unalloc0;
302                 } __packed v1;
303                 struct {
304                         __le32 rx_addr;
305                         __le16 max_rx;
306                         __le16 rxhw;
307                         __le16 timer;
308                         __le16 truncate;
309                         __le32 basic_rate_mask;
310                         u8 sbss_offset;
311                         u8 mcast_window;
312                         u8 rx_rssi_threshold;
313                         u8 rx_ed_threshold;
314                         __le32 ref_clock;
315                         __le16 lpf_bandwidth;
316                         __le16 osc_start_delay;
317                 } __packed v2;
318         } __packed;
319 } __packed;
320
321 #define P54_SETUP_V1_LEN 40
322 #define P54_SETUP_V2_LEN (sizeof(struct p54_setup_mac))
323
324 #define P54_SCAN_EXIT   BIT(0)
325 #define P54_SCAN_TRAP   BIT(1)
326 #define P54_SCAN_ACTIVE BIT(2)
327 #define P54_SCAN_FILTER BIT(3)
328
329 struct p54_scan_head {
330         __le16 mode;
331         __le16 dwell;
332         u8 scan_params[20];
333         __le16 freq;
334 } __packed;
335
336 struct p54_pa_curve_data_sample {
337         u8 rf_power;
338         u8 pa_detector;
339         u8 data_barker;
340         u8 data_bpsk;
341         u8 data_qpsk;
342         u8 data_16qam;
343         u8 data_64qam;
344         u8 padding;
345 } __packed;
346
347 struct p54_scan_body {
348         u8 pa_points_per_curve;
349         u8 val_barker;
350         u8 val_bpsk;
351         u8 val_qpsk;
352         u8 val_16qam;
353         u8 val_64qam;
354         struct p54_pa_curve_data_sample curve_data[8];
355         u8 dup_bpsk;
356         u8 dup_qpsk;
357         u8 dup_16qam;
358         u8 dup_64qam;
359 } __packed;
360
361 /*
362  * Warning: Longbow's structures are bogus.
363  */
364 struct p54_channel_output_limit_longbow {
365         __le16 rf_power_points[12];
366 } __packed;
367
368 struct p54_pa_curve_data_sample_longbow {
369         __le16 rf_power;
370         __le16 pa_detector;
371         struct {
372                 __le16 data[4];
373         } points[3] __packed;
374 } __packed;
375
376 struct p54_scan_body_longbow {
377         struct p54_channel_output_limit_longbow power_limits;
378         struct p54_pa_curve_data_sample_longbow curve_data[8];
379         __le16 unkn[6];         /* maybe more power_limits or rate_mask */
380 } __packed;
381
382 union p54_scan_body_union {
383         struct p54_scan_body normal;
384         struct p54_scan_body_longbow longbow;
385 } __packed;
386
387 struct p54_scan_tail_rate {
388         __le32 basic_rate_mask;
389         u8 rts_rates[8];
390 } __packed;
391
392 struct p54_led {
393         __le16 flags;
394         __le16 mask[2];
395         __le16 delay[2];
396 } __packed;
397
398 struct p54_edcf {
399         u8 flags;
400         u8 slottime;
401         u8 sifs;
402         u8 eofpad;
403         struct p54_edcf_queue_param queue[8];
404         u8 mapping[4];
405         __le16 frameburst;
406         __le16 round_trip_delay;
407 } __packed;
408
409 struct p54_statistics {
410         __le32 rx_success;
411         __le32 rx_bad_fcs;
412         __le32 rx_abort;
413         __le32 rx_abort_phy;
414         __le32 rts_success;
415         __le32 rts_fail;
416         __le32 tsf32;
417         __le32 airtime;
418         __le32 noise;
419         __le32 sample_noise[8];
420         __le32 sample_cca;
421         __le32 sample_tx;
422 } __packed;
423
424 struct p54_xbow_synth {
425         __le16 magic1;
426         __le16 magic2;
427         __le16 freq;
428         u32 padding[5];
429 } __packed;
430
431 struct p54_timer {
432         __le32 interval;
433 } __packed;
434
435 struct p54_keycache {
436         u8 entry;
437         u8 key_id;
438         u8 mac[ETH_ALEN];
439         u8 padding[2];
440         u8 key_type;
441         u8 key_len;
442         u8 key[24];
443 } __packed;
444
445 struct p54_burst {
446         u8 flags;
447         u8 queue;
448         u8 backlog;
449         u8 pad;
450         __le16 durations[32];
451 } __packed;
452
453 struct p54_psm_interval {
454         __le16 interval;
455         __le16 periods;
456 } __packed;
457
458 #define P54_PSM_CAM                     0
459 #define P54_PSM                         BIT(0)
460 #define P54_PSM_DTIM                    BIT(1)
461 #define P54_PSM_MCBC                    BIT(2)
462 #define P54_PSM_CHECKSUM                BIT(3)
463 #define P54_PSM_SKIP_MORE_DATA          BIT(4)
464 #define P54_PSM_BEACON_TIMEOUT          BIT(5)
465 #define P54_PSM_HFOSLEEP                BIT(6)
466 #define P54_PSM_AUTOSWITCH_SLEEP        BIT(7)
467 #define P54_PSM_LPIT                    BIT(8)
468 #define P54_PSM_BF_UCAST_SKIP           BIT(9)
469 #define P54_PSM_BF_MCAST_SKIP           BIT(10)
470
471 struct p54_psm {
472         __le16 mode;
473         __le16 aid;
474         struct p54_psm_interval intervals[4];
475         u8 beacon_rssi_skip_max;
476         u8 rssi_delta_threshold;
477         u8 nr;
478         u8 exclude[1];
479 } __packed;
480
481 #define MC_FILTER_ADDRESS_NUM 4
482
483 struct p54_group_address_table {
484         __le16 filter_enable;
485         __le16 num_address;
486         u8 mac_list[MC_FILTER_ADDRESS_NUM][ETH_ALEN];
487 } __packed;
488
489 struct p54_txcancel {
490         __le32 req_id;
491 } __packed;
492
493 struct p54_sta_unlock {
494         u8 addr[ETH_ALEN];
495         u16 padding;
496 } __packed;
497
498 #define P54_TIM_CLEAR BIT(15)
499 struct p54_tim {
500         u8 count;
501         u8 padding[3];
502         __le16 entry[8];
503 } __packed;
504
505 struct p54_cce_quiet {
506         __le32 period;
507 } __packed;
508
509 struct p54_bt_balancer {
510         __le16 prio_thresh;
511         __le16 acl_thresh;
512 } __packed;
513
514 struct p54_arp_table {
515         __le16 filter_enable;
516         u8 ipv4_addr[4];
517 } __packed;
518
519 /* LED control */
520 int p54_set_leds(struct p54_common *priv);
521 int p54_init_leds(struct p54_common *priv);
522 void p54_unregister_leds(struct p54_common *priv);
523
524 /* xmit functions */
525 int p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb);
526 int p54_tx_cancel(struct p54_common *priv, __le32 req_id);
527 void p54_tx(struct p54_common *priv, struct sk_buff *skb);
528
529 /* synth/phy configuration */
530 int p54_init_xbow_synth(struct p54_common *priv);
531 int p54_scan(struct p54_common *priv, u16 mode, u16 dwell);
532
533 /* MAC */
534 int p54_sta_unlock(struct p54_common *priv, u8 *addr);
535 int p54_update_beacon_tim(struct p54_common *priv, u16 aid, bool set);
536 int p54_setup_mac(struct p54_common *priv);
537 int p54_set_ps(struct p54_common *priv);
538 int p54_fetch_statistics(struct p54_common *priv);
539
540 /* e/v DCF setup */
541 int p54_set_edcf(struct p54_common *priv);
542
543 /* cryptographic engine */
544 int p54_upload_key(struct p54_common *priv, u8 algo, int slot,
545                    u8 idx, u8 len, u8 *addr, u8* key);
546
547 /* eeprom */
548 int p54_download_eeprom(struct p54_common *priv, void *buf,
549                         u16 offset, u16 len);
550
551 /* utility */
552 u8 *p54_find_ie(struct sk_buff *skb, u8 ie);
553
554 #endif /* LMAC_H */