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