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