[PATCH] libertas: monitor mode support for OLPC firmware
[safe/jmp/linux-2.6] / drivers / net / wireless / libertas / hostcmd.h
1 /*
2  * This file contains the function prototypes, data structure
3  * and defines for all the host/station commands
4  */
5 #ifndef __HOSTCMD__H
6 #define __HOSTCMD__H
7
8 #include <linux/wireless.h>
9 #include "11d.h"
10 #include "types.h"
11
12 /* 802.11-related definitions */
13
14 /* TxPD descriptor */
15 struct txpd {
16         /* Current Tx packet status */
17         __le32 tx_status;
18         /* Tx control */
19         __le32 tx_control;
20         __le32 tx_packet_location;
21         /* Tx packet length */
22         __le16 tx_packet_length;
23         /* First 2 byte of destination MAC address */
24         u8 tx_dest_addr_high[2];
25         /* Last 4 byte of destination MAC address */
26         u8 tx_dest_addr_low[4];
27         /* Pkt Priority */
28         u8 priority;
29         /* Pkt Trasnit Power control */
30         u8 powermgmt;
31         /* Amount of time the packet has been queued in the driver (units = 2ms) */
32         u8 pktdelay_2ms;
33         /* reserved */
34         u8 reserved1;
35 };
36
37 /* RxPD Descriptor */
38 struct rxpd {
39         /* Current Rx packet status */
40         __le16 status;
41
42         /* SNR */
43         u8 snr;
44
45         /* Tx control */
46         u8 rx_control;
47
48         /* Pkt length */
49         __le16 pkt_len;
50
51         /* Noise Floor */
52         u8 nf;
53
54         /* Rx Packet Rate */
55         u8 rx_rate;
56
57         /* Pkt addr */
58         __le32 pkt_ptr;
59
60         /* Next Rx RxPD addr */
61         __le32 next_rxpd_ptr;
62
63         /* Pkt Priority */
64         u8 priority;
65         u8 reserved[3];
66 };
67
68 struct cmd_ctrl_node {
69         /* CMD link list */
70         struct list_head list;
71         u32 status;
72         /* CMD ID */
73         u32 cmd_oid;
74         /*CMD wait option: wait for finish or no wait */
75         u16 wait_option;
76         /* command parameter */
77         void *pdata_buf;
78         /*command data */
79         u8 *bufvirtualaddr;
80         u16 cmdflags;
81         /* wait queue */
82         u16 cmdwaitqwoken;
83         wait_queue_head_t cmdwait_q;
84 };
85
86 /* Generic structure to hold all key types. */
87 struct enc_key {
88         u16 len;
89         u16 flags;  /* KEY_INFO_* from wlan_defs.h */
90         u16 type; /* KEY_TYPE_* from wlan_defs.h */
91         u8 key[32];
92 };
93
94 /* wlan_offset_value */
95 struct wlan_offset_value {
96         u32 offset;
97         u32 value;
98 };
99
100 /* Define general data structure */
101 /* cmd_DS_GEN */
102 struct cmd_ds_gen {
103         __le16 command;
104         __le16 size;
105         __le16 seqnum;
106         __le16 result;
107 };
108
109 #define S_DS_GEN sizeof(struct cmd_ds_gen)
110 /*
111  * Define data structure for CMD_GET_HW_SPEC
112  * This structure defines the response for the GET_HW_SPEC command
113  */
114 struct cmd_ds_get_hw_spec {
115         /* HW Interface version number */
116         __le16 hwifversion;
117         /* HW version number */
118         __le16 version;
119         /* Max number of TxPD FW can handle */
120         __le16 nr_txpd;
121         /* Max no of Multicast address */
122         __le16 nr_mcast_adr;
123         /* MAC address */
124         u8 permanentaddr[6];
125
126         /* region Code */
127         __le16 regioncode;
128
129         /* Number of antenna used */
130         __le16 nr_antenna;
131
132         /* FW release number, example 1,2,3,4 = 3.2.1p4 */
133         u8 fwreleasenumber[4];
134
135         /* Base Address of TxPD queue */
136         __le32 wcb_base;
137         /* Read Pointer of RxPd queue */
138         __le32 rxpd_rdptr;
139
140         /* Write Pointer of RxPd queue */
141         __le32 rxpd_wrptr;
142
143         /*FW/HW capability */
144         __le32 fwcapinfo;
145 } __attribute__ ((packed));
146
147 struct cmd_ds_802_11_reset {
148         __le16 action;
149 };
150
151 struct cmd_ds_802_11_subscribe_event {
152         __le16 action;
153         __le16 events;
154 };
155
156 /*
157  * This scan handle Country Information IE(802.11d compliant)
158  * Define data structure for CMD_802_11_SCAN
159  */
160 struct cmd_ds_802_11_scan {
161         u8 bsstype;
162         u8 bssid[ETH_ALEN];
163         u8 tlvbuffer[1];
164 #if 0
165         mrvlietypes_ssidparamset_t ssidParamSet;
166         mrvlietypes_chanlistparamset_t ChanListParamSet;
167         mrvlietypes_ratesparamset_t OpRateSet;
168 #endif
169 };
170
171 struct cmd_ds_802_11_scan_rsp {
172         __le16 bssdescriptsize;
173         u8 nr_sets;
174         u8 bssdesc_and_tlvbuffer[1];
175 };
176
177 struct cmd_ds_802_11_get_log {
178         __le32 mcasttxframe;
179         __le32 failed;
180         __le32 retry;
181         __le32 multiretry;
182         __le32 framedup;
183         __le32 rtssuccess;
184         __le32 rtsfailure;
185         __le32 ackfailure;
186         __le32 rxfrag;
187         __le32 mcastrxframe;
188         __le32 fcserror;
189         __le32 txframe;
190         __le32 wepundecryptable;
191 };
192
193 struct cmd_ds_mac_control {
194         __le16 action;
195         __le16 reserved;
196 };
197
198 struct cmd_ds_mac_multicast_adr {
199         __le16 action;
200         __le16 nr_of_adrs;
201         u8 maclist[ETH_ALEN * MRVDRV_MAX_MULTICAST_LIST_SIZE];
202 };
203
204 struct cmd_ds_802_11_authenticate {
205         u8 macaddr[ETH_ALEN];
206         u8 authtype;
207         u8 reserved[10];
208 };
209
210 struct cmd_ds_802_11_deauthenticate {
211         u8 macaddr[6];
212         __le16 reasoncode;
213 };
214
215 struct cmd_ds_802_11_associate {
216         u8 peerstaaddr[6];
217         __le16 capability;
218         __le16 listeninterval;
219         __le16 bcnperiod;
220         u8 dtimperiod;
221
222 #if 0
223         mrvlietypes_ssidparamset_t ssidParamSet;
224         mrvlietypes_phyparamset_t phyparamset;
225         mrvlietypes_ssparamset_t ssparamset;
226         mrvlietypes_ratesparamset_t ratesParamSet;
227 #endif
228 } __attribute__ ((packed));
229
230 struct cmd_ds_802_11_disassociate {
231         u8 destmacaddr[6];
232         __le16 reasoncode;
233 };
234
235 struct cmd_ds_802_11_associate_rsp {
236         struct ieeetypes_assocrsp assocRsp;
237 };
238
239 struct cmd_ds_802_11_ad_hoc_result {
240         u8 pad[3];
241         u8 bssid[ETH_ALEN];
242 };
243
244 struct cmd_ds_802_11_set_wep {
245         /* ACT_ADD, ACT_REMOVE or ACT_ENABLE */
246         __le16 action;
247
248         /* key Index selected for Tx */
249         __le16 keyindex;
250
251         /* 40, 128bit or TXWEP */
252         u8 keytype[4];
253         u8 keymaterial[4][16];
254 };
255
256 struct cmd_ds_802_3_get_stat {
257         __le32 xmitok;
258         __le32 rcvok;
259         __le32 xmiterror;
260         __le32 rcverror;
261         __le32 rcvnobuffer;
262         __le32 rcvcrcerror;
263 };
264
265 struct cmd_ds_802_11_get_stat {
266         __le32 txfragmentcnt;
267         __le32 mcasttxframecnt;
268         __le32 failedcnt;
269         __le32 retrycnt;
270         __le32 Multipleretrycnt;
271         __le32 rtssuccesscnt;
272         __le32 rtsfailurecnt;
273         __le32 ackfailurecnt;
274         __le32 frameduplicatecnt;
275         __le32 rxfragmentcnt;
276         __le32 mcastrxframecnt;
277         __le32 fcserrorcnt;
278         __le32 bcasttxframecnt;
279         __le32 bcastrxframecnt;
280         __le32 txbeacon;
281         __le32 rxbeacon;
282         __le32 wepundecryptable;
283 };
284
285 struct cmd_ds_802_11_snmp_mib {
286         __le16 querytype;
287         __le16 oid;
288         __le16 bufsize;
289         u8 value[128];
290 };
291
292 struct cmd_ds_mac_reg_map {
293         __le16 buffersize;
294         u8 regmap[128];
295         __le16 reserved;
296 };
297
298 struct cmd_ds_bbp_reg_map {
299         __le16 buffersize;
300         u8 regmap[128];
301         __le16 reserved;
302 };
303
304 struct cmd_ds_rf_reg_map {
305         __le16 buffersize;
306         u8 regmap[64];
307         __le16 reserved;
308 };
309
310 struct cmd_ds_mac_reg_access {
311         __le16 action;
312         __le16 offset;
313         __le32 value;
314 };
315
316 struct cmd_ds_bbp_reg_access {
317         __le16 action;
318         __le16 offset;
319         u8 value;
320         u8 reserved[3];
321 };
322
323 struct cmd_ds_rf_reg_access {
324         __le16 action;
325         __le16 offset;
326         u8 value;
327         u8 reserved[3];
328 };
329
330 struct cmd_ds_802_11_radio_control {
331         __le16 action;
332         __le16 control;
333 };
334
335 struct cmd_ds_802_11_sleep_params {
336         /* ACT_GET/ACT_SET */
337         __le16 action;
338
339         /* Sleep clock error in ppm */
340         __le16 error;
341
342         /* Wakeup offset in usec */
343         __le16 offset;
344
345         /* Clock stabilization time in usec */
346         __le16 stabletime;
347
348         /* control periodic calibration */
349         u8 calcontrol;
350
351         /* control the use of external sleep clock */
352         u8 externalsleepclk;
353
354         /* reserved field, should be set to zero */
355         __le16 reserved;
356 };
357
358 struct cmd_ds_802_11_inactivity_timeout {
359         /* ACT_GET/ACT_SET */
360         __le16 action;
361
362         /* Inactivity timeout in msec */
363         __le16 timeout;
364 };
365
366 struct cmd_ds_802_11_rf_channel {
367         __le16 action;
368         __le16 currentchannel;
369         __le16 rftype;
370         __le16 reserved;
371         u8 channellist[32];
372 };
373
374 struct cmd_ds_802_11_rssi {
375         /* weighting factor */
376         __le16 N;
377
378         __le16 reserved_0;
379         __le16 reserved_1;
380         __le16 reserved_2;
381 };
382
383 struct cmd_ds_802_11_rssi_rsp {
384         __le16 SNR;
385         __le16 noisefloor;
386         __le16 avgSNR;
387         __le16 avgnoisefloor;
388 };
389
390 struct cmd_ds_802_11_mac_address {
391         __le16 action;
392         u8 macadd[ETH_ALEN];
393 };
394
395 struct cmd_ds_802_11_rf_tx_power {
396         __le16 action;
397         __le16 currentlevel;
398 };
399
400 struct cmd_ds_802_11_rf_antenna {
401         __le16 action;
402
403         /* Number of antennas or 0xffff(diversity) */
404         __le16 antennamode;
405
406 };
407
408 struct cmd_ds_802_11_monitor_mode {
409         u16 action;
410         u16 mode;
411 };
412
413 struct cmd_ds_802_11_ps_mode {
414         __le16 action;
415         __le16 nullpktinterval;
416         __le16 multipledtim;
417         __le16 reserved;
418         __le16 locallisteninterval;
419 };
420
421 struct PS_CMD_ConfirmSleep {
422         __le16 command;
423         __le16 size;
424         __le16 seqnum;
425         __le16 result;
426
427         __le16 action;
428         __le16 reserved1;
429         __le16 multipledtim;
430         __le16 reserved;
431         __le16 locallisteninterval;
432 };
433
434 struct cmd_ds_802_11_data_rate {
435         __le16 action;
436         __le16 reserved;
437         u8 rates[MAX_RATES];
438 };
439
440 struct cmd_ds_802_11_rate_adapt_rateset {
441         __le16 action;
442         __le16 enablehwauto;
443         __le16 bitmap;
444 };
445
446 struct cmd_ds_802_11_ad_hoc_start {
447         u8 ssid[IW_ESSID_MAX_SIZE];
448         u8 bsstype;
449         __le16 beaconperiod;
450         u8 dtimperiod;
451         union IEEEtypes_ssparamset ssparamset;
452         union ieeetypes_phyparamset phyparamset;
453         __le16 probedelay;
454         __le16 capability;
455         u8 rates[MAX_RATES];
456         u8 tlv_memory_size_pad[100];
457 } __attribute__ ((packed));
458
459 struct adhoc_bssdesc {
460         u8 bssid[6];
461         u8 ssid[32];
462         u8 type;
463         __le16 beaconperiod;
464         u8 dtimperiod;
465         __le64 timestamp;
466         __le64 localtime;
467         union ieeetypes_phyparamset phyparamset;
468         union IEEEtypes_ssparamset ssparamset;
469         __le16 capability;
470         u8 rates[MAX_RATES];
471
472         /* DO NOT ADD ANY FIELDS TO THIS STRUCTURE. It is used below in the
473          * Adhoc join command and will cause a binary layout mismatch with
474          * the firmware
475          */
476 } __attribute__ ((packed));
477
478 struct cmd_ds_802_11_ad_hoc_join {
479         struct adhoc_bssdesc bss;
480         __le16 failtimeout;
481         __le16 probedelay;
482
483 } __attribute__ ((packed));
484
485 struct cmd_ds_802_11_enable_rsn {
486         __le16 action;
487         __le16 enable;
488 } __attribute__ ((packed));
489
490 struct MrvlIEtype_keyParamSet {
491         /* type ID */
492         __le16 type;
493
494         /* length of Payload */
495         __le16 length;
496
497         /* type of key: WEP=0, TKIP=1, AES=2 */
498         __le16 keytypeid;
499
500         /* key control Info specific to a keytypeid */
501         __le16 keyinfo;
502
503         /* length of key */
504         __le16 keylen;
505
506         /* key material of size keylen */
507         u8 key[32];
508 };
509
510 struct cmd_ds_802_11_key_material {
511         __le16 action;
512         struct MrvlIEtype_keyParamSet keyParamSet[2];
513 } __attribute__ ((packed));
514
515 struct cmd_ds_802_11_eeprom_access {
516         __le16 action;
517
518         /* multiple 4 */
519         __le16 offset;
520         __le16 bytecount;
521         u8 value;
522 } __attribute__ ((packed));
523
524 struct cmd_ds_802_11_tpc_cfg {
525         __le16 action;
526         u8 enable;
527         s8 P0;
528         s8 P1;
529         s8 P2;
530         u8 usesnr;
531 } __attribute__ ((packed));
532
533 struct cmd_ds_802_11_led_ctrl {
534         __le16 action;
535         __le16 numled;
536         u8 data[256];
537 } __attribute__ ((packed));
538
539 struct cmd_ds_802_11_pwr_cfg {
540         __le16 action;
541         u8 enable;
542         s8 PA_P0;
543         s8 PA_P1;
544         s8 PA_P2;
545 } __attribute__ ((packed));
546
547 struct cmd_ds_802_11_afc {
548         __le16 afc_auto;
549         union {
550                 struct {
551                         __le16 threshold;
552                         __le16 period;
553                 };
554                 struct {
555                         __le16 timing_offset; /* signed */
556                         __le16 carrier_offset; /* signed */
557                 };
558         };
559 } __attribute__ ((packed));
560
561 struct cmd_tx_rate_query {
562         __le16 txrate;
563 } __attribute__ ((packed));
564
565 struct cmd_ds_get_tsf {
566         __le64 tsfvalue;
567 } __attribute__ ((packed));
568
569 struct cmd_ds_bt_access {
570         __le16 action;
571         __le32 id;
572         u8 addr1[ETH_ALEN];
573         u8 addr2[ETH_ALEN];
574 } __attribute__ ((packed));
575
576 struct cmd_ds_fwt_access {
577         __le16 action;
578         __le32 id;
579         u8 valid;
580         u8 da[ETH_ALEN];
581         u8 dir;
582         u8 ra[ETH_ALEN];
583         __le32 ssn;
584         __le32 dsn;
585         __le32 metric;
586         u8 rate;
587         u8 hopcount;
588         u8 ttl;
589         __le32 expiration;
590         u8 sleepmode;
591         __le32 snr;
592         __le32 references;
593         u8 prec[ETH_ALEN];
594 } __attribute__ ((packed));
595
596 struct cmd_ds_mesh_access {
597         __le16 action;
598         __le32 data[32];        /* last position reserved */
599 } __attribute__ ((packed));
600
601 /* Number of stats counters returned by the firmware */
602 #define MESH_STATS_NUM 8
603
604 struct cmd_ds_command {
605         /* command header */
606         __le16 command;
607         __le16 size;
608         __le16 seqnum;
609         __le16 result;
610
611         /* command Body */
612         union {
613                 struct cmd_ds_get_hw_spec hwspec;
614                 struct cmd_ds_802_11_ps_mode psmode;
615                 struct cmd_ds_802_11_scan scan;
616                 struct cmd_ds_802_11_scan_rsp scanresp;
617                 struct cmd_ds_mac_control macctrl;
618                 struct cmd_ds_802_11_associate associate;
619                 struct cmd_ds_802_11_deauthenticate deauth;
620                 struct cmd_ds_802_11_set_wep wep;
621                 struct cmd_ds_802_11_ad_hoc_start ads;
622                 struct cmd_ds_802_11_reset reset;
623                 struct cmd_ds_802_11_ad_hoc_result result;
624                 struct cmd_ds_802_11_get_log glog;
625                 struct cmd_ds_802_11_authenticate auth;
626                 struct cmd_ds_802_11_get_stat gstat;
627                 struct cmd_ds_802_3_get_stat gstat_8023;
628                 struct cmd_ds_802_11_snmp_mib smib;
629                 struct cmd_ds_802_11_rf_tx_power txp;
630                 struct cmd_ds_802_11_rf_antenna rant;
631                 struct cmd_ds_802_11_monitor_mode monitor;
632                 struct cmd_ds_802_11_data_rate drate;
633                 struct cmd_ds_802_11_rate_adapt_rateset rateset;
634                 struct cmd_ds_mac_multicast_adr madr;
635                 struct cmd_ds_802_11_ad_hoc_join adj;
636                 struct cmd_ds_802_11_radio_control radio;
637                 struct cmd_ds_802_11_rf_channel rfchannel;
638                 struct cmd_ds_802_11_rssi rssi;
639                 struct cmd_ds_802_11_rssi_rsp rssirsp;
640                 struct cmd_ds_802_11_disassociate dassociate;
641                 struct cmd_ds_802_11_mac_address macadd;
642                 struct cmd_ds_802_11_enable_rsn enbrsn;
643                 struct cmd_ds_802_11_key_material keymaterial;
644                 struct cmd_ds_mac_reg_access macreg;
645                 struct cmd_ds_bbp_reg_access bbpreg;
646                 struct cmd_ds_rf_reg_access rfreg;
647                 struct cmd_ds_802_11_eeprom_access rdeeprom;
648
649                 struct cmd_ds_802_11d_domain_info domaininfo;
650                 struct cmd_ds_802_11d_domain_info domaininforesp;
651
652                 struct cmd_ds_802_11_sleep_params sleep_params;
653                 struct cmd_ds_802_11_inactivity_timeout inactivity_timeout;
654                 struct cmd_ds_802_11_tpc_cfg tpccfg;
655                 struct cmd_ds_802_11_pwr_cfg pwrcfg;
656                 struct cmd_ds_802_11_afc afc;
657                 struct cmd_ds_802_11_led_ctrl ledgpio;
658
659                 struct cmd_tx_rate_query txrate;
660                 struct cmd_ds_bt_access bt;
661                 struct cmd_ds_fwt_access fwt;
662                 struct cmd_ds_mesh_access mesh;
663                 struct cmd_ds_get_tsf gettsf;
664                 struct cmd_ds_802_11_subscribe_event subscribe_event;
665         } params;
666 } __attribute__ ((packed));
667
668 #endif