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