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