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