GNU Linux-libre 5.19-rc6-gnu
[releases.git] / drivers / net / wireless / marvell / libertas / host.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * This file function prototypes, data structure
4  * and  definitions for all the host/station commands
5  */
6
7 #ifndef _LBS_HOST_H_
8 #define _LBS_HOST_H_
9
10 #include "types.h"
11 #include "defs.h"
12
13 #define DEFAULT_AD_HOC_CHANNEL                  6
14
15 #define CMD_OPTION_WAITFORRSP                   0x0002
16
17 /* Host command IDs */
18
19 /*
20  * Return command are almost always the same as the host command, but with
21  * bit 15 set high.  There are a few exceptions, though...
22  */
23 #define CMD_RET(cmd)                            (0x8000 | cmd)
24
25 /* Return command convention exceptions: */
26 #define CMD_RET_802_11_ASSOCIATE                0x8012
27
28 /* Command codes */
29 #define CMD_GET_HW_SPEC                         0x0003
30 #define CMD_EEPROM_UPDATE                       0x0004
31 #define CMD_802_11_RESET                        0x0005
32 #define CMD_802_11_SCAN                         0x0006
33 #define CMD_802_11_GET_LOG                      0x000b
34 #define CMD_MAC_MULTICAST_ADR                   0x0010
35 #define CMD_802_11_AUTHENTICATE                 0x0011
36 #define CMD_802_11_EEPROM_ACCESS                0x0059
37 #define CMD_802_11_ASSOCIATE                    0x0050
38 #define CMD_802_11_SET_WEP                      0x0013
39 #define CMD_802_11_GET_STAT                     0x0014
40 #define CMD_802_3_GET_STAT                      0x0015
41 #define CMD_802_11_SNMP_MIB                     0x0016
42 #define CMD_MAC_REG_MAP                         0x0017
43 #define CMD_BBP_REG_MAP                         0x0018
44 #define CMD_MAC_REG_ACCESS                      0x0019
45 #define CMD_BBP_REG_ACCESS                      0x001a
46 #define CMD_RF_REG_ACCESS                       0x001b
47 #define CMD_802_11_RADIO_CONTROL                0x001c
48 #define CMD_802_11_RF_CHANNEL                   0x001d
49 #define CMD_802_11_RF_TX_POWER                  0x001e
50 #define CMD_802_11_RSSI                         0x001f
51 #define CMD_802_11_RF_ANTENNA                   0x0020
52 #define CMD_802_11_PS_MODE                      0x0021
53 #define CMD_802_11_DATA_RATE                    0x0022
54 #define CMD_RF_REG_MAP                          0x0023
55 #define CMD_802_11_DEAUTHENTICATE               0x0024
56 #define CMD_802_11_REASSOCIATE                  0x0025
57 #define CMD_MAC_CONTROL                         0x0028
58 #define CMD_802_11_AD_HOC_START                 0x002b
59 #define CMD_802_11_AD_HOC_JOIN                  0x002c
60 #define CMD_802_11_QUERY_TKIP_REPLY_CNTRS       0x002e
61 #define CMD_802_11_ENABLE_RSN                   0x002f
62 #define CMD_802_11_SET_AFC                      0x003c
63 #define CMD_802_11_GET_AFC                      0x003d
64 #define CMD_802_11_DEEP_SLEEP                   0x003e
65 #define CMD_802_11_AD_HOC_STOP                  0x0040
66 #define CMD_802_11_HOST_SLEEP_CFG               0x0043
67 #define CMD_802_11_WAKEUP_CONFIRM               0x0044
68 #define CMD_802_11_HOST_SLEEP_ACTIVATE          0x0045
69 #define CMD_802_11_BEACON_STOP                  0x0049
70 #define CMD_802_11_MAC_ADDRESS                  0x004d
71 #define CMD_802_11_LED_GPIO_CTRL                0x004e
72 #define CMD_802_11_BAND_CONFIG                  0x0058
73 #define CMD_GSPI_BUS_CONFIG                     0x005a
74 #define CMD_802_11D_DOMAIN_INFO                 0x005b
75 #define CMD_802_11_KEY_MATERIAL                 0x005e
76 #define CMD_802_11_SLEEP_PARAMS                 0x0066
77 #define CMD_802_11_INACTIVITY_TIMEOUT           0x0067
78 #define CMD_802_11_SLEEP_PERIOD                 0x0068
79 #define CMD_802_11_TPC_CFG                      0x0072
80 #define CMD_802_11_PA_CFG                       0x0073
81 #define CMD_802_11_FW_WAKE_METHOD               0x0074
82 #define CMD_802_11_SUBSCRIBE_EVENT              0x0075
83 #define CMD_802_11_RATE_ADAPT_RATESET           0x0076
84 #define CMD_802_11_TX_RATE_QUERY                0x007f
85 #define CMD_GET_TSF                             0x0080
86 #define CMD_BT_ACCESS                           0x0087
87 #define CMD_FWT_ACCESS                          0x0095
88 #define CMD_802_11_MONITOR_MODE                 0x0098
89 #define CMD_MESH_ACCESS                         0x009b
90 #define CMD_MESH_CONFIG_OLD                     0x00a3
91 #define CMD_MESH_CONFIG                         0x00ac
92 #define CMD_SET_BOOT2_VER                       0x00a5
93 #define CMD_FUNC_INIT                           0x00a9
94 #define CMD_FUNC_SHUTDOWN                       0x00aa
95 #define CMD_802_11_BEACON_CTRL                  0x00b0
96
97 /* For the IEEE Power Save */
98 #define PS_MODE_ACTION_ENTER_PS                 0x0030
99 #define PS_MODE_ACTION_EXIT_PS                  0x0031
100 #define PS_MODE_ACTION_SLEEP_CONFIRMED          0x0034
101
102 #define CMD_ENABLE_RSN                          0x0001
103 #define CMD_DISABLE_RSN                         0x0000
104
105 #define CMD_ACT_GET                             0x0000
106 #define CMD_ACT_SET                             0x0001
107
108 /* Define action or option for CMD_802_11_SET_WEP */
109 #define CMD_ACT_ADD                             0x0002
110 #define CMD_ACT_REMOVE                          0x0004
111
112 #define CMD_TYPE_WEP_40_BIT                     0x01
113 #define CMD_TYPE_WEP_104_BIT                    0x02
114
115 #define CMD_NUM_OF_WEP_KEYS                     4
116
117 #define CMD_WEP_KEY_INDEX_MASK                  0x3fff
118
119 /* Define action or option for CMD_802_11_SCAN */
120 #define CMD_BSS_TYPE_BSS                        0x0001
121 #define CMD_BSS_TYPE_IBSS                       0x0002
122 #define CMD_BSS_TYPE_ANY                        0x0003
123
124 /* Define action or option for CMD_802_11_SCAN */
125 #define CMD_SCAN_TYPE_ACTIVE                    0x0000
126 #define CMD_SCAN_TYPE_PASSIVE                   0x0001
127
128 #define CMD_SCAN_RADIO_TYPE_BG                  0
129
130 #define CMD_SCAN_PROBE_DELAY_TIME               0
131
132 /* Define action or option for CMD_MAC_CONTROL */
133 #define CMD_ACT_MAC_RX_ON                       0x0001
134 #define CMD_ACT_MAC_TX_ON                       0x0002
135 #define CMD_ACT_MAC_LOOPBACK_ON                 0x0004
136 #define CMD_ACT_MAC_WEP_ENABLE                  0x0008
137 #define CMD_ACT_MAC_INT_ENABLE                  0x0010
138 #define CMD_ACT_MAC_MULTICAST_ENABLE            0x0020
139 #define CMD_ACT_MAC_BROADCAST_ENABLE            0x0040
140 #define CMD_ACT_MAC_PROMISCUOUS_ENABLE          0x0080
141 #define CMD_ACT_MAC_ALL_MULTICAST_ENABLE        0x0100
142 #define CMD_ACT_MAC_STRICT_PROTECTION_ENABLE    0x0400
143
144 /* Event flags for CMD_802_11_SUBSCRIBE_EVENT */
145 #define CMD_SUBSCRIBE_RSSI_LOW                  0x0001
146 #define CMD_SUBSCRIBE_SNR_LOW                   0x0002
147 #define CMD_SUBSCRIBE_FAILCOUNT                 0x0004
148 #define CMD_SUBSCRIBE_BCNMISS                   0x0008
149 #define CMD_SUBSCRIBE_RSSI_HIGH                 0x0010
150 #define CMD_SUBSCRIBE_SNR_HIGH                  0x0020
151
152 #define RADIO_PREAMBLE_LONG                     0x00
153 #define RADIO_PREAMBLE_SHORT                    0x02
154 #define RADIO_PREAMBLE_AUTO                     0x04
155
156 /* Define action or option for CMD_802_11_RF_CHANNEL */
157 #define CMD_OPT_802_11_RF_CHANNEL_GET           0x00
158 #define CMD_OPT_802_11_RF_CHANNEL_SET           0x01
159
160 /* Define action or option for CMD_802_11_DATA_RATE */
161 #define CMD_ACT_SET_TX_AUTO                     0x0000
162 #define CMD_ACT_SET_TX_FIX_RATE                 0x0001
163 #define CMD_ACT_GET_TX_RATE                     0x0002
164
165 /* Options for CMD_802_11_FW_WAKE_METHOD */
166 #define CMD_WAKE_METHOD_UNCHANGED               0x0000
167 #define CMD_WAKE_METHOD_COMMAND_INT             0x0001
168 #define CMD_WAKE_METHOD_GPIO                    0x0002
169
170 /* Object IDs for CMD_802_11_SNMP_MIB */
171 #define SNMP_MIB_OID_BSS_TYPE                   0x0000
172 #define SNMP_MIB_OID_OP_RATE_SET                0x0001
173 #define SNMP_MIB_OID_BEACON_PERIOD              0x0002  /* Reserved on v9+ */
174 #define SNMP_MIB_OID_DTIM_PERIOD                0x0003  /* Reserved on v9+ */
175 #define SNMP_MIB_OID_ASSOC_TIMEOUT              0x0004  /* Reserved on v9+ */
176 #define SNMP_MIB_OID_RTS_THRESHOLD              0x0005
177 #define SNMP_MIB_OID_SHORT_RETRY_LIMIT          0x0006
178 #define SNMP_MIB_OID_LONG_RETRY_LIMIT           0x0007
179 #define SNMP_MIB_OID_FRAG_THRESHOLD             0x0008
180 #define SNMP_MIB_OID_11D_ENABLE                 0x0009
181 #define SNMP_MIB_OID_11H_ENABLE                 0x000A
182
183 /* Define action or option for CMD_BT_ACCESS */
184 enum cmd_bt_access_opts {
185         /* The bt commands start at 5 instead of 1 because the old dft commands
186          * are mapped to 1-4.  These old commands are no longer maintained and
187          * should not be called.
188          */
189         CMD_ACT_BT_ACCESS_ADD = 5,
190         CMD_ACT_BT_ACCESS_DEL,
191         CMD_ACT_BT_ACCESS_LIST,
192         CMD_ACT_BT_ACCESS_RESET,
193         CMD_ACT_BT_ACCESS_SET_INVERT,
194         CMD_ACT_BT_ACCESS_GET_INVERT
195 };
196
197 /* Define action or option for CMD_FWT_ACCESS */
198 enum cmd_fwt_access_opts {
199         CMD_ACT_FWT_ACCESS_ADD = 1,
200         CMD_ACT_FWT_ACCESS_DEL,
201         CMD_ACT_FWT_ACCESS_LOOKUP,
202         CMD_ACT_FWT_ACCESS_LIST,
203         CMD_ACT_FWT_ACCESS_LIST_ROUTE,
204         CMD_ACT_FWT_ACCESS_LIST_NEIGHBOR,
205         CMD_ACT_FWT_ACCESS_RESET,
206         CMD_ACT_FWT_ACCESS_CLEANUP,
207         CMD_ACT_FWT_ACCESS_TIME,
208 };
209
210 /* Define action or option for CMD_802_11_HOST_SLEEP_CFG */
211 enum cmd_wol_cfg_opts {
212         CMD_ACT_ACTION_NONE = 0,
213         CMD_ACT_SET_WOL_RULE,
214         CMD_ACT_GET_WOL_RULE,
215         CMD_ACT_RESET_WOL_RULE,
216 };
217
218 /* Define action or option for CMD_MESH_ACCESS */
219 enum cmd_mesh_access_opts {
220         CMD_ACT_MESH_GET_TTL = 1,
221         CMD_ACT_MESH_SET_TTL,
222         CMD_ACT_MESH_GET_STATS,
223         CMD_ACT_MESH_GET_ANYCAST,
224         CMD_ACT_MESH_SET_ANYCAST,
225         CMD_ACT_MESH_SET_LINK_COSTS,
226         CMD_ACT_MESH_GET_LINK_COSTS,
227         CMD_ACT_MESH_SET_BCAST_RATE,
228         CMD_ACT_MESH_GET_BCAST_RATE,
229         CMD_ACT_MESH_SET_RREQ_DELAY,
230         CMD_ACT_MESH_GET_RREQ_DELAY,
231         CMD_ACT_MESH_SET_ROUTE_EXP,
232         CMD_ACT_MESH_GET_ROUTE_EXP,
233         CMD_ACT_MESH_SET_AUTOSTART_ENABLED,
234         CMD_ACT_MESH_GET_AUTOSTART_ENABLED,
235         CMD_ACT_MESH_SET_GET_PRB_RSP_LIMIT = 17,
236 };
237
238 /* Define actions and types for CMD_MESH_CONFIG */
239 enum cmd_mesh_config_actions {
240         CMD_ACT_MESH_CONFIG_STOP = 0,
241         CMD_ACT_MESH_CONFIG_START,
242         CMD_ACT_MESH_CONFIG_SET,
243         CMD_ACT_MESH_CONFIG_GET,
244 };
245
246 enum cmd_mesh_config_types {
247         CMD_TYPE_MESH_SET_BOOTFLAG = 1,
248         CMD_TYPE_MESH_SET_BOOTTIME,
249         CMD_TYPE_MESH_SET_DEF_CHANNEL,
250         CMD_TYPE_MESH_SET_MESH_IE,
251         CMD_TYPE_MESH_GET_DEFAULTS,
252         CMD_TYPE_MESH_GET_MESH_IE, /* GET_DEFAULTS is superset of GET_MESHIE */
253 };
254
255 /* Card Event definition */
256 #define MACREG_INT_CODE_TX_PPA_FREE             0
257 #define MACREG_INT_CODE_TX_DMA_DONE             1
258 #define MACREG_INT_CODE_LINK_LOST_W_SCAN        2
259 #define MACREG_INT_CODE_LINK_LOST_NO_SCAN       3
260 #define MACREG_INT_CODE_LINK_SENSED             4
261 #define MACREG_INT_CODE_CMD_FINISHED            5
262 #define MACREG_INT_CODE_MIB_CHANGED             6
263 #define MACREG_INT_CODE_INIT_DONE               7
264 #define MACREG_INT_CODE_DEAUTHENTICATED         8
265 #define MACREG_INT_CODE_DISASSOCIATED           9
266 #define MACREG_INT_CODE_PS_AWAKE                10
267 #define MACREG_INT_CODE_PS_SLEEP                11
268 #define MACREG_INT_CODE_MIC_ERR_MULTICAST       13
269 #define MACREG_INT_CODE_MIC_ERR_UNICAST         14
270 #define MACREG_INT_CODE_WM_AWAKE                15
271 #define MACREG_INT_CODE_DEEP_SLEEP_AWAKE        16
272 #define MACREG_INT_CODE_ADHOC_BCN_LOST          17
273 #define MACREG_INT_CODE_HOST_AWAKE              18
274 #define MACREG_INT_CODE_STOP_TX                 19
275 #define MACREG_INT_CODE_START_TX                20
276 #define MACREG_INT_CODE_CHANNEL_SWITCH          21
277 #define MACREG_INT_CODE_MEASUREMENT_RDY         22
278 #define MACREG_INT_CODE_WMM_CHANGE              23
279 #define MACREG_INT_CODE_BG_SCAN_REPORT          24
280 #define MACREG_INT_CODE_RSSI_LOW                25
281 #define MACREG_INT_CODE_SNR_LOW                 26
282 #define MACREG_INT_CODE_MAX_FAIL                27
283 #define MACREG_INT_CODE_RSSI_HIGH               28
284 #define MACREG_INT_CODE_SNR_HIGH                29
285 #define MACREG_INT_CODE_MESH_AUTO_STARTED       35
286 #define MACREG_INT_CODE_FIRMWARE_READY          48
287
288
289 /* 802.11-related definitions */
290
291 /* TxPD descriptor */
292 struct txpd {
293         /* union to cope up with later FW revisions */
294         union {
295                 /* Current Tx packet status */
296                 __le32 tx_status;
297                 struct {
298                         /* BSS type: client, AP, etc. */
299                         u8 bss_type;
300                         /* BSS number */
301                         u8 bss_num;
302                         /* Reserved */
303                         __le16 reserved;
304                 } bss;
305         } u;
306         /* Tx control */
307         __le32 tx_control;
308         __le32 tx_packet_location;
309         /* Tx packet length */
310         __le16 tx_packet_length;
311         struct_group_attr(tx_dest_addr, __packed,
312                 /* First 2 byte of destination MAC address */
313                 u8 tx_dest_addr_high[2];
314                 /* Last 4 byte of destination MAC address */
315                 u8 tx_dest_addr_low[4];
316         );
317         /* Pkt Priority */
318         u8 priority;
319         /* Pkt Trasnit Power control */
320         u8 powermgmt;
321         /* Amount of time the packet has been queued (units = 2ms) */
322         u8 pktdelay_2ms;
323         /* reserved */
324         u8 reserved1;
325 } __packed;
326
327 /* RxPD Descriptor */
328 struct rxpd {
329         /* union to cope up with later FW revisions */
330         union {
331                 /* Current Rx packet status */
332                 __le16 status;
333                 struct {
334                         /* BSS type: client, AP, etc. */
335                         u8 bss_type;
336                         /* BSS number */
337                         u8 bss_num;
338                 } __packed bss;
339         } __packed u;
340
341         /* SNR */
342         u8 snr;
343
344         /* Tx control */
345         u8 rx_control;
346
347         /* Pkt length */
348         __le16 pkt_len;
349
350         /* Noise Floor */
351         u8 nf;
352
353         /* Rx Packet Rate */
354         u8 rx_rate;
355
356         /* Pkt addr */
357         __le32 pkt_ptr;
358
359         /* Next Rx RxPD addr */
360         __le32 next_rxpd_ptr;
361
362         /* Pkt Priority */
363         u8 priority;
364         u8 reserved[3];
365 } __packed;
366
367 struct cmd_header {
368         __le16 command;
369         __le16 size;
370         __le16 seqnum;
371         __le16 result;
372 } __packed;
373
374 /* Generic structure to hold all key types. */
375 struct enc_key {
376         u16 len;
377         u16 flags;  /* KEY_INFO_* from defs.h */
378         u16 type; /* KEY_TYPE_* from defs.h */
379         u8 key[32];
380 };
381
382 /* lbs_offset_value */
383 struct lbs_offset_value {
384         u32 offset;
385         u32 value;
386 } __packed;
387
388 #define MAX_11D_TRIPLETS        83
389
390 struct mrvl_ie_domain_param_set {
391         struct mrvl_ie_header header;
392
393         u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
394         struct ieee80211_country_ie_triplet triplet[MAX_11D_TRIPLETS];
395 } __packed;
396
397 struct cmd_ds_802_11d_domain_info {
398         struct cmd_header hdr;
399
400         __le16 action;
401         struct mrvl_ie_domain_param_set domain;
402 } __packed;
403
404 /*
405  * Define data structure for CMD_GET_HW_SPEC
406  * This structure defines the response for the GET_HW_SPEC command
407  */
408 struct cmd_ds_get_hw_spec {
409         struct cmd_header hdr;
410
411         /* HW Interface version number */
412         __le16 hwifversion;
413         /* HW version number */
414         __le16 version;
415         /* Max number of TxPD FW can handle */
416         __le16 nr_txpd;
417         /* Max no of Multicast address */
418         __le16 nr_mcast_adr;
419         /* MAC address */
420         u8 permanentaddr[6];
421
422         /* region Code */
423         __le16 regioncode;
424
425         /* Number of antenna used */
426         __le16 nr_antenna;
427
428         /* FW release number, example 0x01030304 = 2.3.4p1 */
429         __le32 fwrelease;
430
431         /* Base Address of TxPD queue */
432         __le32 wcb_base;
433         /* Read Pointer of RxPd queue */
434         __le32 rxpd_rdptr;
435
436         /* Write Pointer of RxPd queue */
437         __le32 rxpd_wrptr;
438
439         /*FW/HW capability */
440         __le32 fwcapinfo;
441 } __packed;
442
443 struct cmd_ds_802_11_subscribe_event {
444         struct cmd_header hdr;
445
446         __le16 action;
447         __le16 events;
448
449         /* A TLV to the CMD_802_11_SUBSCRIBE_EVENT command can contain a
450          * number of TLVs. From the v5.1 manual, those TLVs would add up to
451          * 40 bytes. However, future firmware might add additional TLVs, so I
452          * bump this up a bit.
453          */
454         uint8_t tlv[128];
455 } __packed;
456
457 /*
458  * This scan handle Country Information IE(802.11d compliant)
459  * Define data structure for CMD_802_11_SCAN
460  */
461 struct cmd_ds_802_11_scan {
462         struct cmd_header hdr;
463
464         uint8_t bsstype;
465         uint8_t bssid[ETH_ALEN];
466         uint8_t tlvbuffer[];
467 } __packed;
468
469 struct cmd_ds_802_11_scan_rsp {
470         struct cmd_header hdr;
471
472         __le16 bssdescriptsize;
473         uint8_t nr_sets;
474         uint8_t bssdesc_and_tlvbuffer[];
475 } __packed;
476
477 struct cmd_ds_802_11_get_log {
478         struct cmd_header hdr;
479
480         __le32 mcasttxframe;
481         __le32 failed;
482         __le32 retry;
483         __le32 multiretry;
484         __le32 framedup;
485         __le32 rtssuccess;
486         __le32 rtsfailure;
487         __le32 ackfailure;
488         __le32 rxfrag;
489         __le32 mcastrxframe;
490         __le32 fcserror;
491         __le32 txframe;
492         __le32 wepundecryptable;
493 } __packed;
494
495 struct cmd_ds_mac_control {
496         struct cmd_header hdr;
497         __le16 action;
498         u16 reserved;
499 } __packed;
500
501 struct cmd_ds_mac_multicast_adr {
502         struct cmd_header hdr;
503         __le16 action;
504         __le16 nr_of_adrs;
505         u8 maclist[ETH_ALEN * MRVDRV_MAX_MULTICAST_LIST_SIZE];
506 } __packed;
507
508 struct cmd_ds_802_11_authenticate {
509         struct cmd_header hdr;
510
511         u8 bssid[ETH_ALEN];
512         u8 authtype;
513         u8 reserved[10];
514 } __packed;
515
516 struct cmd_ds_802_11_deauthenticate {
517         struct cmd_header hdr;
518
519         u8 macaddr[ETH_ALEN];
520         __le16 reasoncode;
521 } __packed;
522
523 struct cmd_ds_802_11_associate {
524         struct cmd_header hdr;
525
526         u8 bssid[6];
527         __le16 capability;
528         __le16 listeninterval;
529         __le16 bcnperiod;
530         u8 dtimperiod;
531         /* 512 permitted - enough for required and most optional IEs */
532         u8 iebuf[];
533 } __packed;
534
535 struct cmd_ds_802_11_associate_response {
536         struct cmd_header hdr;
537
538         __le16 capability;
539         __le16 statuscode;
540         __le16 aid;
541         /* max 512 */
542         u8 iebuf[];
543 } __packed;
544
545 struct cmd_ds_802_11_set_wep {
546         struct cmd_header hdr;
547
548         /* ACT_ADD, ACT_REMOVE or ACT_ENABLE */
549         __le16 action;
550
551         /* key Index selected for Tx */
552         __le16 keyindex;
553
554         /* 40, 128bit or TXWEP */
555         uint8_t keytype[4];
556         uint8_t keymaterial[4][16];
557 } __packed;
558
559 struct cmd_ds_802_11_snmp_mib {
560         struct cmd_header hdr;
561
562         __le16 action;
563         __le16 oid;
564         __le16 bufsize;
565         u8 value[128];
566 } __packed;
567
568 struct cmd_ds_reg_access {
569         struct cmd_header hdr;
570
571         __le16 action;
572         __le16 offset;
573         union {
574                 u8 bbp_rf;  /* for BBP and RF registers */
575                 __le32 mac; /* for MAC registers */
576         } value;
577 } __packed;
578
579 struct cmd_ds_802_11_radio_control {
580         struct cmd_header hdr;
581
582         __le16 action;
583         __le16 control;
584 } __packed;
585
586 struct cmd_ds_802_11_beacon_control {
587         struct cmd_header hdr;
588
589         __le16 action;
590         __le16 beacon_enable;
591         __le16 beacon_period;
592 } __packed;
593
594 struct cmd_ds_802_11_sleep_params {
595         struct cmd_header hdr;
596
597         /* ACT_GET/ACT_SET */
598         __le16 action;
599
600         /* Sleep clock error in ppm */
601         __le16 error;
602
603         /* Wakeup offset in usec */
604         __le16 offset;
605
606         /* Clock stabilization time in usec */
607         __le16 stabletime;
608
609         /* control periodic calibration */
610         uint8_t calcontrol;
611
612         /* control the use of external sleep clock */
613         uint8_t externalsleepclk;
614
615         /* reserved field, should be set to zero */
616         __le16 reserved;
617 } __packed;
618
619 struct cmd_ds_802_11_rf_channel {
620         struct cmd_header hdr;
621
622         __le16 action;
623         __le16 channel;
624         __le16 rftype;      /* unused */
625         __le16 reserved;    /* unused */
626         u8 channellist[32]; /* unused */
627 } __packed;
628
629 struct cmd_ds_802_11_rssi {
630         struct cmd_header hdr;
631
632         /*
633          * request:  number of beacons (N) to average the SNR and NF over
634          * response: SNR of most recent beacon
635          */
636         __le16 n_or_snr;
637
638         /*
639          * The following fields are only set in the response.
640          * In the request these are reserved and should be set to 0.
641          */
642         __le16 nf;       /* most recent beacon noise floor */
643         __le16 avg_snr;  /* average SNR weighted by N from request */
644         __le16 avg_nf;   /* average noise floor weighted by N from request */
645 } __packed;
646
647 struct cmd_ds_802_11_mac_address {
648         struct cmd_header hdr;
649
650         __le16 action;
651         u8 macadd[ETH_ALEN];
652 } __packed;
653
654 struct cmd_ds_802_11_rf_tx_power {
655         struct cmd_header hdr;
656
657         __le16 action;
658         __le16 curlevel;
659         s8 maxlevel;
660         s8 minlevel;
661 } __packed;
662
663 /* MONITOR_MODE only exists in OLPC v5 firmware */
664 struct cmd_ds_802_11_monitor_mode {
665         struct cmd_header hdr;
666
667         __le16 action;
668         __le16 mode;
669 } __packed;
670
671 struct cmd_ds_set_boot2_ver {
672         struct cmd_header hdr;
673
674         __le16 action;
675         __le16 version;
676 } __packed;
677
678 struct cmd_ds_802_11_fw_wake_method {
679         struct cmd_header hdr;
680
681         __le16 action;
682         __le16 method;
683 } __packed;
684
685 struct cmd_ds_802_11_ps_mode {
686         struct cmd_header hdr;
687
688         __le16 action;
689
690         /*
691          * Interval for keepalive in PS mode:
692          * 0x0000 = don't change
693          * 0x001E = firmware default
694          * 0xFFFF = disable
695          */
696         __le16 nullpktinterval;
697
698         /*
699          * Number of DTIM intervals to wake up for:
700          * 0 = don't change
701          * 1 = firmware default
702          * 5 = max
703          */
704         __le16 multipledtim;
705
706         __le16 reserved;
707         __le16 locallisteninterval;
708
709         /*
710          * AdHoc awake period (FW v9+ only):
711          * 0 = don't change
712          * 1 = always awake (IEEE standard behavior)
713          * 2 - 31 = sleep for (n - 1) periods and awake for 1 period
714          * 32 - 254 = invalid
715          * 255 = sleep at each ATIM
716          */
717         __le16 adhoc_awake_period;
718 } __packed;
719
720 struct cmd_confirm_sleep {
721         struct cmd_header hdr;
722
723         __le16 action;
724         __le16 nullpktinterval;
725         __le16 multipledtim;
726         __le16 reserved;
727         __le16 locallisteninterval;
728 } __packed;
729
730 struct cmd_ds_802_11_data_rate {
731         struct cmd_header hdr;
732
733         __le16 action;
734         __le16 reserved;
735         u8 rates[MAX_RATES];
736 } __packed;
737
738 struct cmd_ds_802_11_rate_adapt_rateset {
739         struct cmd_header hdr;
740         __le16 action;
741         __le16 enablehwauto;
742         __le16 bitmap;
743 } __packed;
744
745 struct cmd_ds_802_11_ad_hoc_start {
746         struct cmd_header hdr;
747
748         u8 ssid[IEEE80211_MAX_SSID_LEN];
749         u8 bsstype;
750         __le16 beaconperiod;
751         u8 dtimperiod;   /* Reserved on v9 and later */
752         struct ieee_ie_ibss_param_set ibss;
753         u8 reserved1[4];
754         struct ieee_ie_ds_param_set ds;
755         u8 reserved2[4];
756         __le16 probedelay;  /* Reserved on v9 and later */
757         __le16 capability;
758         u8 rates[MAX_RATES];
759         u8 tlv_memory_size_pad[100];
760 } __packed;
761
762 struct cmd_ds_802_11_ad_hoc_result {
763         struct cmd_header hdr;
764
765         u8 pad[3];
766         u8 bssid[ETH_ALEN];
767 } __packed;
768
769 struct adhoc_bssdesc {
770         u8 bssid[ETH_ALEN];
771         u8 ssid[IEEE80211_MAX_SSID_LEN];
772         u8 type;
773         __le16 beaconperiod;
774         u8 dtimperiod;
775         __le64 timestamp;
776         __le64 localtime;
777         struct ieee_ie_ds_param_set ds;
778         u8 reserved1[4];
779         struct ieee_ie_ibss_param_set ibss;
780         u8 reserved2[4];
781         __le16 capability;
782         u8 rates[MAX_RATES];
783
784         /*
785          * DO NOT ADD ANY FIELDS TO THIS STRUCTURE. It is used below in the
786          * Adhoc join command and will cause a binary layout mismatch with
787          * the firmware
788          */
789 } __packed;
790
791 struct cmd_ds_802_11_ad_hoc_join {
792         struct cmd_header hdr;
793
794         struct adhoc_bssdesc bss;
795         __le16 failtimeout;   /* Reserved on v9 and later */
796         __le16 probedelay;    /* Reserved on v9 and later */
797 } __packed;
798
799 struct cmd_ds_802_11_ad_hoc_stop {
800         struct cmd_header hdr;
801 } __packed;
802
803 struct cmd_ds_802_11_enable_rsn {
804         struct cmd_header hdr;
805
806         __le16 action;
807         __le16 enable;
808 } __packed;
809
810 struct MrvlIEtype_keyParamSet {
811         /* type ID */
812         __le16 type;
813
814         /* length of Payload */
815         __le16 length;
816
817         /* type of key: WEP=0, TKIP=1, AES=2 */
818         __le16 keytypeid;
819
820         /* key control Info specific to a keytypeid */
821         __le16 keyinfo;
822
823         /* length of key */
824         __le16 keylen;
825
826         /* key material of size keylen */
827         u8 key[32];
828 } __packed;
829
830 #define MAX_WOL_RULES           16
831
832 struct host_wol_rule {
833         uint8_t rule_no;
834         uint8_t rule_ops;
835         __le16 sig_offset;
836         __le16 sig_length;
837         __le16 reserve;
838         __be32 sig_mask;
839         __be32 signature;
840 } __packed;
841
842 struct wol_config {
843         uint8_t action;
844         uint8_t pattern;
845         uint8_t no_rules_in_cmd;
846         uint8_t result;
847         struct host_wol_rule rule[MAX_WOL_RULES];
848 } __packed;
849
850 struct cmd_ds_host_sleep {
851         struct cmd_header hdr;
852         __le32 criteria;
853         uint8_t gpio;
854         uint16_t gap;
855         struct wol_config wol_conf;
856 } __packed;
857
858
859
860 struct cmd_ds_802_11_key_material {
861         struct cmd_header hdr;
862
863         __le16 action;
864         struct MrvlIEtype_keyParamSet keyParamSet[2];
865 } __packed;
866
867 struct cmd_ds_802_11_eeprom_access {
868         struct cmd_header hdr;
869         __le16 action;
870         __le16 offset;
871         __le16 len;
872         /* firmware says it returns a maximum of 20 bytes */
873 #define LBS_EEPROM_READ_LEN 20
874         u8 value[LBS_EEPROM_READ_LEN];
875 } __packed;
876
877 struct cmd_ds_802_11_tpc_cfg {
878         struct cmd_header hdr;
879
880         __le16 action;
881         uint8_t enable;
882         int8_t P0;
883         int8_t P1;
884         int8_t P2;
885         uint8_t usesnr;
886 } __packed;
887
888
889 struct cmd_ds_802_11_pa_cfg {
890         struct cmd_header hdr;
891
892         __le16 action;
893         uint8_t enable;
894         int8_t P0;
895         int8_t P1;
896         int8_t P2;
897 } __packed;
898
899
900 struct cmd_ds_802_11_led_ctrl {
901         struct cmd_header hdr;
902
903         __le16 action;
904         __le16 numled;
905         u8 data[256];
906 } __packed;
907
908 /* Automatic Frequency Control */
909 struct cmd_ds_802_11_afc {
910         struct cmd_header hdr;
911
912         __le16 afc_auto;
913         union {
914                 struct {
915                         __le16 threshold;
916                         __le16 period;
917                 };
918                 struct {
919                         __le16 timing_offset; /* signed */
920                         __le16 carrier_offset; /* signed */
921                 };
922         };
923 } __packed;
924
925 struct cmd_tx_rate_query {
926         __le16 txrate;
927 } __packed;
928
929 struct cmd_ds_get_tsf {
930         __le64 tsfvalue;
931 } __packed;
932
933 struct cmd_ds_bt_access {
934         struct cmd_header hdr;
935
936         __le16 action;
937         __le32 id;
938         u8 addr1[ETH_ALEN];
939         u8 addr2[ETH_ALEN];
940 } __packed;
941
942 struct cmd_ds_fwt_access {
943         struct cmd_header hdr;
944
945         __le16 action;
946         __le32 id;
947         u8 valid;
948         u8 da[ETH_ALEN];
949         u8 dir;
950         u8 ra[ETH_ALEN];
951         __le32 ssn;
952         __le32 dsn;
953         __le32 metric;
954         u8 rate;
955         u8 hopcount;
956         u8 ttl;
957         __le32 expiration;
958         u8 sleepmode;
959         __le32 snr;
960         __le32 references;
961         u8 prec[ETH_ALEN];
962 } __packed;
963
964 struct cmd_ds_mesh_config {
965         struct cmd_header hdr;
966
967         __le16 action;
968         __le16 channel;
969         __le16 type;
970         __le16 length;
971         u8 data[128];   /* last position reserved */
972 } __packed;
973
974 struct cmd_ds_mesh_access {
975         struct cmd_header hdr;
976
977         __le16 action;
978         __le32 data[32];        /* last position reserved */
979 } __packed;
980
981 /* Number of stats counters returned by the firmware */
982 #define MESH_STATS_NUM 8
983 #endif