libertas: convert adhoc operations to direct commands
[pandora-kernel.git] / 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 _LBS_HOSTCMD_H
6 #define _LBS_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_header {
69         __le16 command;
70         __le16 size;
71         __le16 seqnum;
72         __le16 result;
73 } __attribute__ ((packed));
74
75 struct cmd_ctrl_node {
76         struct list_head list;
77         int result;
78         /* command response */
79         int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *);
80         unsigned long callback_arg;
81         /* command data */
82         struct cmd_header *cmdbuf;
83         /* wait queue */
84         u16 cmdwaitqwoken;
85         wait_queue_head_t cmdwait_q;
86 };
87
88 /* Generic structure to hold all key types. */
89 struct enc_key {
90         u16 len;
91         u16 flags;  /* KEY_INFO_* from defs.h */
92         u16 type; /* KEY_TYPE_* from defs.h */
93         u8 key[32];
94 };
95
96 /* lbs_offset_value */
97 struct lbs_offset_value {
98         u32 offset;
99         u32 value;
100 };
101
102 /* Define general data structure */
103 /* cmd_DS_GEN */
104 struct cmd_ds_gen {
105         __le16 command;
106         __le16 size;
107         __le16 seqnum;
108         __le16 result;
109         void *cmdresp[0];
110 };
111
112 #define S_DS_GEN sizeof(struct cmd_ds_gen)
113
114
115 /*
116  * Define data structure for CMD_GET_HW_SPEC
117  * This structure defines the response for the GET_HW_SPEC command
118  */
119 struct cmd_ds_get_hw_spec {
120         struct cmd_header hdr;
121
122         /* HW Interface version number */
123         __le16 hwifversion;
124         /* HW version number */
125         __le16 version;
126         /* Max number of TxPD FW can handle */
127         __le16 nr_txpd;
128         /* Max no of Multicast address */
129         __le16 nr_mcast_adr;
130         /* MAC address */
131         u8 permanentaddr[6];
132
133         /* region Code */
134         __le16 regioncode;
135
136         /* Number of antenna used */
137         __le16 nr_antenna;
138
139         /* FW release number, example 0x01030304 = 2.3.4p1 */
140         __le32 fwrelease;
141
142         /* Base Address of TxPD queue */
143         __le32 wcb_base;
144         /* Read Pointer of RxPd queue */
145         __le32 rxpd_rdptr;
146
147         /* Write Pointer of RxPd queue */
148         __le32 rxpd_wrptr;
149
150         /*FW/HW capability */
151         __le32 fwcapinfo;
152 } __attribute__ ((packed));
153
154 struct cmd_ds_802_11_reset {
155         __le16 action;
156 };
157
158 struct cmd_ds_802_11_subscribe_event {
159         struct cmd_header hdr;
160
161         __le16 action;
162         __le16 events;
163
164         /* A TLV to the CMD_802_11_SUBSCRIBE_EVENT command can contain a
165          * number of TLVs. From the v5.1 manual, those TLVs would add up to
166          * 40 bytes. However, future firmware might add additional TLVs, so I
167          * bump this up a bit.
168          */
169         uint8_t tlv[128];
170 };
171
172 /*
173  * This scan handle Country Information IE(802.11d compliant)
174  * Define data structure for CMD_802_11_SCAN
175  */
176 struct cmd_ds_802_11_scan {
177         struct cmd_header hdr;
178
179         uint8_t bsstype;
180         uint8_t bssid[ETH_ALEN];
181         uint8_t tlvbuffer[0];
182 #if 0
183         mrvlietypes_ssidparamset_t ssidParamSet;
184         mrvlietypes_chanlistparamset_t ChanListParamSet;
185         mrvlietypes_ratesparamset_t OpRateSet;
186 #endif
187 };
188
189 struct cmd_ds_802_11_scan_rsp {
190         struct cmd_header hdr;
191
192         __le16 bssdescriptsize;
193         uint8_t nr_sets;
194         uint8_t bssdesc_and_tlvbuffer[0];
195 };
196
197 struct cmd_ds_802_11_get_log {
198         struct cmd_header hdr;
199
200         __le32 mcasttxframe;
201         __le32 failed;
202         __le32 retry;
203         __le32 multiretry;
204         __le32 framedup;
205         __le32 rtssuccess;
206         __le32 rtsfailure;
207         __le32 ackfailure;
208         __le32 rxfrag;
209         __le32 mcastrxframe;
210         __le32 fcserror;
211         __le32 txframe;
212         __le32 wepundecryptable;
213 };
214
215 struct cmd_ds_mac_control {
216         struct cmd_header hdr;
217         __le16 action;
218         u16 reserved;
219 };
220
221 struct cmd_ds_mac_multicast_adr {
222         struct cmd_header hdr;
223         __le16 action;
224         __le16 nr_of_adrs;
225         u8 maclist[ETH_ALEN * MRVDRV_MAX_MULTICAST_LIST_SIZE];
226 };
227
228 struct cmd_ds_802_11_authenticate {
229         u8 macaddr[ETH_ALEN];
230         u8 authtype;
231         u8 reserved[10];
232 };
233
234 struct cmd_ds_802_11_deauthenticate {
235         struct cmd_header hdr;
236
237         u8 macaddr[ETH_ALEN];
238         __le16 reasoncode;
239 };
240
241 struct cmd_ds_802_11_associate {
242         u8 peerstaaddr[6];
243         __le16 capability;
244         __le16 listeninterval;
245         __le16 bcnperiod;
246         u8 dtimperiod;
247
248 #if 0
249         mrvlietypes_ssidparamset_t ssidParamSet;
250         mrvlietypes_phyparamset_t phyparamset;
251         mrvlietypes_ssparamset_t ssparamset;
252         mrvlietypes_ratesparamset_t ratesParamSet;
253 #endif
254 } __attribute__ ((packed));
255
256 struct cmd_ds_802_11_associate_rsp {
257         struct ieeetypes_assocrsp assocRsp;
258 };
259
260 struct cmd_ds_802_11_set_wep {
261         struct cmd_header hdr;
262
263         /* ACT_ADD, ACT_REMOVE or ACT_ENABLE */
264         __le16 action;
265
266         /* key Index selected for Tx */
267         __le16 keyindex;
268
269         /* 40, 128bit or TXWEP */
270         uint8_t keytype[4];
271         uint8_t keymaterial[4][16];
272 };
273
274 struct cmd_ds_802_3_get_stat {
275         __le32 xmitok;
276         __le32 rcvok;
277         __le32 xmiterror;
278         __le32 rcverror;
279         __le32 rcvnobuffer;
280         __le32 rcvcrcerror;
281 };
282
283 struct cmd_ds_802_11_get_stat {
284         __le32 txfragmentcnt;
285         __le32 mcasttxframecnt;
286         __le32 failedcnt;
287         __le32 retrycnt;
288         __le32 Multipleretrycnt;
289         __le32 rtssuccesscnt;
290         __le32 rtsfailurecnt;
291         __le32 ackfailurecnt;
292         __le32 frameduplicatecnt;
293         __le32 rxfragmentcnt;
294         __le32 mcastrxframecnt;
295         __le32 fcserrorcnt;
296         __le32 bcasttxframecnt;
297         __le32 bcastrxframecnt;
298         __le32 txbeacon;
299         __le32 rxbeacon;
300         __le32 wepundecryptable;
301 };
302
303 struct cmd_ds_802_11_snmp_mib {
304         __le16 querytype;
305         __le16 oid;
306         __le16 bufsize;
307         u8 value[128];
308 };
309
310 struct cmd_ds_mac_reg_map {
311         __le16 buffersize;
312         u8 regmap[128];
313         __le16 reserved;
314 };
315
316 struct cmd_ds_bbp_reg_map {
317         __le16 buffersize;
318         u8 regmap[128];
319         __le16 reserved;
320 };
321
322 struct cmd_ds_rf_reg_map {
323         __le16 buffersize;
324         u8 regmap[64];
325         __le16 reserved;
326 };
327
328 struct cmd_ds_mac_reg_access {
329         __le16 action;
330         __le16 offset;
331         __le32 value;
332 };
333
334 struct cmd_ds_bbp_reg_access {
335         __le16 action;
336         __le16 offset;
337         u8 value;
338         u8 reserved[3];
339 };
340
341 struct cmd_ds_rf_reg_access {
342         __le16 action;
343         __le16 offset;
344         u8 value;
345         u8 reserved[3];
346 };
347
348 struct cmd_ds_802_11_radio_control {
349         struct cmd_header hdr;
350
351         __le16 action;
352         __le16 control;
353 };
354
355 struct cmd_ds_802_11_beacon_control {
356         __le16 action;
357         __le16 beacon_enable;
358         __le16 beacon_period;
359 };
360
361 struct cmd_ds_802_11_sleep_params {
362         struct cmd_header hdr;
363
364         /* ACT_GET/ACT_SET */
365         __le16 action;
366
367         /* Sleep clock error in ppm */
368         __le16 error;
369
370         /* Wakeup offset in usec */
371         __le16 offset;
372
373         /* Clock stabilization time in usec */
374         __le16 stabletime;
375
376         /* control periodic calibration */
377         uint8_t calcontrol;
378
379         /* control the use of external sleep clock */
380         uint8_t externalsleepclk;
381
382         /* reserved field, should be set to zero */
383         __le16 reserved;
384 };
385
386 struct cmd_ds_802_11_inactivity_timeout {
387         struct cmd_header hdr;
388
389         /* ACT_GET/ACT_SET */
390         __le16 action;
391
392         /* Inactivity timeout in msec */
393         __le16 timeout;
394 };
395
396 struct cmd_ds_802_11_rf_channel {
397         struct cmd_header hdr;
398
399         __le16 action;
400         __le16 channel;
401         __le16 rftype;      /* unused */
402         __le16 reserved;    /* unused */
403         u8 channellist[32]; /* unused */
404 };
405
406 struct cmd_ds_802_11_rssi {
407         /* weighting factor */
408         __le16 N;
409
410         __le16 reserved_0;
411         __le16 reserved_1;
412         __le16 reserved_2;
413 };
414
415 struct cmd_ds_802_11_rssi_rsp {
416         __le16 SNR;
417         __le16 noisefloor;
418         __le16 avgSNR;
419         __le16 avgnoisefloor;
420 };
421
422 struct cmd_ds_802_11_mac_address {
423         struct cmd_header hdr;
424
425         __le16 action;
426         u8 macadd[ETH_ALEN];
427 };
428
429 struct cmd_ds_802_11_rf_tx_power {
430         struct cmd_header hdr;
431
432         __le16 action;
433         __le16 curlevel;
434         s8 maxlevel;
435         s8 minlevel;
436 };
437
438 struct cmd_ds_802_11_rf_antenna {
439         __le16 action;
440
441         /* Number of antennas or 0xffff(diversity) */
442         __le16 antennamode;
443
444 };
445
446 struct cmd_ds_802_11_monitor_mode {
447         __le16 action;
448         __le16 mode;
449 };
450
451 struct cmd_ds_set_boot2_ver {
452         struct cmd_header hdr;
453
454         __le16 action;
455         __le16 version;
456 };
457
458 struct cmd_ds_802_11_fw_wake_method {
459         struct cmd_header hdr;
460
461         __le16 action;
462         __le16 method;
463 };
464
465 struct cmd_ds_802_11_sleep_period {
466         struct cmd_header hdr;
467
468         __le16 action;
469         __le16 period;
470 };
471
472 struct cmd_ds_802_11_ps_mode {
473         __le16 action;
474         __le16 nullpktinterval;
475         __le16 multipledtim;
476         __le16 reserved;
477         __le16 locallisteninterval;
478 };
479
480 struct cmd_confirm_sleep {
481         struct cmd_header hdr;
482
483         __le16 action;
484         __le16 nullpktinterval;
485         __le16 multipledtim;
486         __le16 reserved;
487         __le16 locallisteninterval;
488 };
489
490 struct cmd_ds_802_11_data_rate {
491         struct cmd_header hdr;
492
493         __le16 action;
494         __le16 reserved;
495         u8 rates[MAX_RATES];
496 };
497
498 struct cmd_ds_802_11_rate_adapt_rateset {
499         struct cmd_header hdr;
500         __le16 action;
501         __le16 enablehwauto;
502         __le16 bitmap;
503 };
504
505 struct cmd_ds_802_11_ad_hoc_start {
506         struct cmd_header hdr;
507
508         u8 ssid[IW_ESSID_MAX_SIZE];
509         u8 bsstype;
510         __le16 beaconperiod;
511         u8 dtimperiod;   /* Reserved on v9 and later */
512         union IEEEtypes_ssparamset ssparamset;
513         union ieeetypes_phyparamset phyparamset;
514         __le16 probedelay;
515         __le16 capability;
516         u8 rates[MAX_RATES];
517         u8 tlv_memory_size_pad[100];
518 } __attribute__ ((packed));
519
520 struct cmd_ds_802_11_ad_hoc_result {
521         struct cmd_header hdr;
522
523         u8 pad[3];
524         u8 bssid[ETH_ALEN];
525 };
526
527 struct adhoc_bssdesc {
528         u8 bssid[ETH_ALEN];
529         u8 ssid[IW_ESSID_MAX_SIZE];
530         u8 type;
531         __le16 beaconperiod;
532         u8 dtimperiod;
533         __le64 timestamp;
534         __le64 localtime;
535         union ieeetypes_phyparamset phyparamset;
536         union IEEEtypes_ssparamset ssparamset;
537         __le16 capability;
538         u8 rates[MAX_RATES];
539
540         /* DO NOT ADD ANY FIELDS TO THIS STRUCTURE. It is used below in the
541          * Adhoc join command and will cause a binary layout mismatch with
542          * the firmware
543          */
544 } __attribute__ ((packed));
545
546 struct cmd_ds_802_11_ad_hoc_join {
547         struct cmd_header hdr;
548
549         struct adhoc_bssdesc bss;
550         __le16 failtimeout;   /* Reserved on v9 and later */
551         __le16 probedelay;    /* Reserved on v9 and later */
552 } __attribute__ ((packed));
553
554 struct cmd_ds_802_11_ad_hoc_stop {
555         struct cmd_header hdr;
556 } __attribute__ ((packed));
557
558 struct cmd_ds_802_11_enable_rsn {
559         struct cmd_header hdr;
560
561         __le16 action;
562         __le16 enable;
563 } __attribute__ ((packed));
564
565 struct MrvlIEtype_keyParamSet {
566         /* type ID */
567         __le16 type;
568
569         /* length of Payload */
570         __le16 length;
571
572         /* type of key: WEP=0, TKIP=1, AES=2 */
573         __le16 keytypeid;
574
575         /* key control Info specific to a keytypeid */
576         __le16 keyinfo;
577
578         /* length of key */
579         __le16 keylen;
580
581         /* key material of size keylen */
582         u8 key[32];
583 };
584
585 struct cmd_ds_host_sleep {
586         struct cmd_header hdr;
587         __le32 criteria;
588         uint8_t gpio;
589         uint8_t gap;
590 } __attribute__ ((packed));
591
592 struct cmd_ds_802_11_key_material {
593         struct cmd_header hdr;
594
595         __le16 action;
596         struct MrvlIEtype_keyParamSet keyParamSet[2];
597 } __attribute__ ((packed));
598
599 struct cmd_ds_802_11_eeprom_access {
600         struct cmd_header hdr;
601         __le16 action;
602         __le16 offset;
603         __le16 len;
604         /* firmware says it returns a maximum of 20 bytes */
605 #define LBS_EEPROM_READ_LEN 20
606         u8 value[LBS_EEPROM_READ_LEN];
607 } __attribute__ ((packed));
608
609 struct cmd_ds_802_11_tpc_cfg {
610         __le16 action;
611         u8 enable;
612         s8 P0;
613         s8 P1;
614         s8 P2;
615         u8 usesnr;
616 } __attribute__ ((packed));
617
618 struct cmd_ds_802_11_led_ctrl {
619         __le16 action;
620         __le16 numled;
621         u8 data[256];
622 } __attribute__ ((packed));
623
624 struct cmd_ds_802_11_afc {
625         __le16 afc_auto;
626         union {
627                 struct {
628                         __le16 threshold;
629                         __le16 period;
630                 };
631                 struct {
632                         __le16 timing_offset; /* signed */
633                         __le16 carrier_offset; /* signed */
634                 };
635         };
636 } __attribute__ ((packed));
637
638 struct cmd_tx_rate_query {
639         __le16 txrate;
640 } __attribute__ ((packed));
641
642 struct cmd_ds_get_tsf {
643         __le64 tsfvalue;
644 } __attribute__ ((packed));
645
646 struct cmd_ds_bt_access {
647         __le16 action;
648         __le32 id;
649         u8 addr1[ETH_ALEN];
650         u8 addr2[ETH_ALEN];
651 } __attribute__ ((packed));
652
653 struct cmd_ds_fwt_access {
654         __le16 action;
655         __le32 id;
656         u8 valid;
657         u8 da[ETH_ALEN];
658         u8 dir;
659         u8 ra[ETH_ALEN];
660         __le32 ssn;
661         __le32 dsn;
662         __le32 metric;
663         u8 rate;
664         u8 hopcount;
665         u8 ttl;
666         __le32 expiration;
667         u8 sleepmode;
668         __le32 snr;
669         __le32 references;
670         u8 prec[ETH_ALEN];
671 } __attribute__ ((packed));
672
673
674 struct cmd_ds_mesh_config {
675         struct cmd_header hdr;
676
677         __le16 action;
678         __le16 channel;
679         __le16 type;
680         __le16 length;
681         u8 data[128];   /* last position reserved */
682 } __attribute__ ((packed));
683
684
685 struct cmd_ds_mesh_access {
686         struct cmd_header hdr;
687
688         __le16 action;
689         __le32 data[32];        /* last position reserved */
690 } __attribute__ ((packed));
691
692 /* Number of stats counters returned by the firmware */
693 #define MESH_STATS_NUM 8
694
695 struct cmd_ds_command {
696         /* command header */
697         __le16 command;
698         __le16 size;
699         __le16 seqnum;
700         __le16 result;
701
702         /* command Body */
703         union {
704                 struct cmd_ds_802_11_ps_mode psmode;
705                 struct cmd_ds_802_11_associate associate;
706                 struct cmd_ds_802_11_reset reset;
707                 struct cmd_ds_802_11_authenticate auth;
708                 struct cmd_ds_802_11_get_stat gstat;
709                 struct cmd_ds_802_3_get_stat gstat_8023;
710                 struct cmd_ds_802_11_snmp_mib smib;
711                 struct cmd_ds_802_11_rf_antenna rant;
712                 struct cmd_ds_802_11_monitor_mode monitor;
713                 struct cmd_ds_802_11_rssi rssi;
714                 struct cmd_ds_802_11_rssi_rsp rssirsp;
715                 struct cmd_ds_mac_reg_access macreg;
716                 struct cmd_ds_bbp_reg_access bbpreg;
717                 struct cmd_ds_rf_reg_access rfreg;
718
719                 struct cmd_ds_802_11d_domain_info domaininfo;
720                 struct cmd_ds_802_11d_domain_info domaininforesp;
721
722                 struct cmd_ds_802_11_tpc_cfg tpccfg;
723                 struct cmd_ds_802_11_afc afc;
724                 struct cmd_ds_802_11_led_ctrl ledgpio;
725
726                 struct cmd_tx_rate_query txrate;
727                 struct cmd_ds_bt_access bt;
728                 struct cmd_ds_fwt_access fwt;
729                 struct cmd_ds_get_tsf gettsf;
730                 struct cmd_ds_802_11_beacon_control bcn_ctrl;
731         } params;
732 } __attribute__ ((packed));
733
734 #endif