ath10k: add support for firmware newer than 636
[cascardo/linux.git] / drivers / net / wireless / ath / ath10k / wmi.h
1 /*
2  * Copyright (c) 2005-2011 Atheros Communications Inc.
3  * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 #ifndef _WMI_H_
19 #define _WMI_H_
20
21 #include <linux/types.h>
22 #include <net/mac80211.h>
23
24 /*
25  * This file specifies the WMI interface for the Unified Software
26  * Architecture.
27  *
28  * It includes definitions of all the commands and events. Commands are
29  * messages from the host to the target. Events and Replies are messages
30  * from the target to the host.
31  *
32  * Ownership of correctness in regards to WMI commands belongs to the host
33  * driver and the target is not required to validate parameters for value,
34  * proper range, or any other checking.
35  *
36  * Guidelines for extending this interface are below.
37  *
38  * 1. Add new WMI commands ONLY within the specified range - 0x9000 - 0x9fff
39  *
40  * 2. Use ONLY u32 type for defining member variables within WMI
41  *    command/event structures. Do not use u8, u16, bool or
42  *    enum types within these structures.
43  *
44  * 3. DO NOT define bit fields within structures. Implement bit fields
45  *    using masks if necessary. Do not use the programming language's bit
46  *    field definition.
47  *
48  * 4. Define macros for encode/decode of u8, u16 fields within
49  *    the u32 variables. Use these macros for set/get of these fields.
50  *    Try to use this to optimize the structure without bloating it with
51  *    u32 variables for every lower sized field.
52  *
53  * 5. Do not use PACK/UNPACK attributes for the structures as each member
54  *    variable is already 4-byte aligned by virtue of being a u32
55  *    type.
56  *
57  * 6. Comment each parameter part of the WMI command/event structure by
58  *    using the 2 stars at the begining of C comment instead of one star to
59  *    enable HTML document generation using Doxygen.
60  *
61  */
62
63 /* Control Path */
64 struct wmi_cmd_hdr {
65         __le32 cmd_id;
66 } __packed;
67
68 #define WMI_CMD_HDR_CMD_ID_MASK   0x00FFFFFF
69 #define WMI_CMD_HDR_CMD_ID_LSB    0
70 #define WMI_CMD_HDR_PLT_PRIV_MASK 0xFF000000
71 #define WMI_CMD_HDR_PLT_PRIV_LSB  24
72
73 #define HTC_PROTOCOL_VERSION    0x0002
74 #define WMI_PROTOCOL_VERSION    0x0002
75
76 enum wmi_service_id {
77         WMI_SERVICE_BEACON_OFFLOAD = 0,   /* beacon offload */
78         WMI_SERVICE_SCAN_OFFLOAD,         /* scan offload */
79         WMI_SERVICE_ROAM_OFFLOAD,         /* roam offload */
80         WMI_SERVICE_BCN_MISS_OFFLOAD,     /* beacon miss offload */
81         WMI_SERVICE_STA_PWRSAVE,          /* fake sleep + basic power save */
82         WMI_SERVICE_STA_ADVANCED_PWRSAVE, /* uapsd, pspoll, force sleep */
83         WMI_SERVICE_AP_UAPSD,             /* uapsd on AP */
84         WMI_SERVICE_AP_DFS,               /* DFS on AP */
85         WMI_SERVICE_11AC,                 /* supports 11ac */
86         WMI_SERVICE_BLOCKACK,   /* Supports triggering ADDBA/DELBA from host*/
87         WMI_SERVICE_PHYERR,               /* PHY error */
88         WMI_SERVICE_BCN_FILTER,           /* Beacon filter support */
89         WMI_SERVICE_RTT,                  /* RTT (round trip time) support */
90         WMI_SERVICE_RATECTRL,             /* Rate-control */
91         WMI_SERVICE_WOW,                  /* WOW Support */
92         WMI_SERVICE_RATECTRL_CACHE,       /* Rate-control caching */
93         WMI_SERVICE_IRAM_TIDS,            /* TIDs in IRAM */
94         WMI_SERVICE_ARPNS_OFFLOAD,        /* ARP NS Offload support */
95         WMI_SERVICE_NLO,                  /* Network list offload service */
96         WMI_SERVICE_GTK_OFFLOAD,          /* GTK offload */
97         WMI_SERVICE_SCAN_SCH,             /* Scan Scheduler Service */
98         WMI_SERVICE_CSA_OFFLOAD,          /* CSA offload service */
99         WMI_SERVICE_CHATTER,              /* Chatter service */
100         WMI_SERVICE_COEX_FREQAVOID,       /* FW report freq range to avoid */
101         WMI_SERVICE_PACKET_POWER_SAVE,    /* packet power save service */
102         WMI_SERVICE_FORCE_FW_HANG,        /* To test fw recovery mechanism */
103         WMI_SERVICE_GPIO,                 /* GPIO service */
104         WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM, /* Modulated DTIM support */
105         WMI_STA_UAPSD_BASIC_AUTO_TRIG,    /* UAPSD AC Trigger Generation  */
106         WMI_STA_UAPSD_VAR_AUTO_TRIG,      /* -do- */
107         WMI_SERVICE_STA_KEEP_ALIVE,       /* STA keep alive mechanism support */
108         WMI_SERVICE_TX_ENCAP,             /* Packet type for TX encapsulation */
109
110         WMI_SERVICE_LAST,
111         WMI_MAX_SERVICE = 64              /* max service */
112 };
113
114 static inline char *wmi_service_name(int service_id)
115 {
116         switch (service_id) {
117         case WMI_SERVICE_BEACON_OFFLOAD:
118                 return "BEACON_OFFLOAD";
119         case WMI_SERVICE_SCAN_OFFLOAD:
120                 return "SCAN_OFFLOAD";
121         case WMI_SERVICE_ROAM_OFFLOAD:
122                 return "ROAM_OFFLOAD";
123         case WMI_SERVICE_BCN_MISS_OFFLOAD:
124                 return "BCN_MISS_OFFLOAD";
125         case WMI_SERVICE_STA_PWRSAVE:
126                 return "STA_PWRSAVE";
127         case WMI_SERVICE_STA_ADVANCED_PWRSAVE:
128                 return "STA_ADVANCED_PWRSAVE";
129         case WMI_SERVICE_AP_UAPSD:
130                 return "AP_UAPSD";
131         case WMI_SERVICE_AP_DFS:
132                 return "AP_DFS";
133         case WMI_SERVICE_11AC:
134                 return "11AC";
135         case WMI_SERVICE_BLOCKACK:
136                 return "BLOCKACK";
137         case WMI_SERVICE_PHYERR:
138                 return "PHYERR";
139         case WMI_SERVICE_BCN_FILTER:
140                 return "BCN_FILTER";
141         case WMI_SERVICE_RTT:
142                 return "RTT";
143         case WMI_SERVICE_RATECTRL:
144                 return "RATECTRL";
145         case WMI_SERVICE_WOW:
146                 return "WOW";
147         case WMI_SERVICE_RATECTRL_CACHE:
148                 return "RATECTRL CACHE";
149         case WMI_SERVICE_IRAM_TIDS:
150                 return "IRAM TIDS";
151         case WMI_SERVICE_ARPNS_OFFLOAD:
152                 return "ARPNS_OFFLOAD";
153         case WMI_SERVICE_NLO:
154                 return "NLO";
155         case WMI_SERVICE_GTK_OFFLOAD:
156                 return "GTK_OFFLOAD";
157         case WMI_SERVICE_SCAN_SCH:
158                 return "SCAN_SCH";
159         case WMI_SERVICE_CSA_OFFLOAD:
160                 return "CSA_OFFLOAD";
161         case WMI_SERVICE_CHATTER:
162                 return "CHATTER";
163         case WMI_SERVICE_COEX_FREQAVOID:
164                 return "COEX_FREQAVOID";
165         case WMI_SERVICE_PACKET_POWER_SAVE:
166                 return "PACKET_POWER_SAVE";
167         case WMI_SERVICE_FORCE_FW_HANG:
168                 return "FORCE FW HANG";
169         case WMI_SERVICE_GPIO:
170                 return "GPIO";
171         case WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM:
172                 return "MODULATED DTIM";
173         case WMI_STA_UAPSD_BASIC_AUTO_TRIG:
174                 return "BASIC UAPSD";
175         case WMI_STA_UAPSD_VAR_AUTO_TRIG:
176                 return "VAR UAPSD";
177         case WMI_SERVICE_STA_KEEP_ALIVE:
178                 return "STA KEEP ALIVE";
179         case WMI_SERVICE_TX_ENCAP:
180                 return "TX ENCAP";
181         default:
182                 return "UNKNOWN SERVICE\n";
183         }
184 }
185
186
187 #define WMI_SERVICE_BM_SIZE \
188         ((WMI_MAX_SERVICE + sizeof(u32) - 1)/sizeof(u32))
189
190 /* 2 word representation of MAC addr */
191 struct wmi_mac_addr {
192         union {
193                 u8 addr[6];
194                 struct {
195                         u32 word0;
196                         u32 word1;
197                 } __packed;
198         } __packed;
199 } __packed;
200
201 /* macro to convert MAC address from WMI word format to char array */
202 #define WMI_MAC_ADDR_TO_CHAR_ARRAY(pwmi_mac_addr, c_macaddr) do { \
203         (c_macaddr)[0] =  ((pwmi_mac_addr)->word0) & 0xff; \
204         (c_macaddr)[1] = (((pwmi_mac_addr)->word0) >> 8) & 0xff; \
205         (c_macaddr)[2] = (((pwmi_mac_addr)->word0) >> 16) & 0xff; \
206         (c_macaddr)[3] = (((pwmi_mac_addr)->word0) >> 24) & 0xff; \
207         (c_macaddr)[4] =  ((pwmi_mac_addr)->word1) & 0xff; \
208         (c_macaddr)[5] = (((pwmi_mac_addr)->word1) >> 8) & 0xff; \
209         } while (0)
210
211 /*
212  * wmi command groups.
213  */
214 enum wmi_cmd_group {
215         /* 0 to 2 are reserved */
216         WMI_GRP_START = 0x3,
217         WMI_GRP_SCAN = WMI_GRP_START,
218         WMI_GRP_PDEV,
219         WMI_GRP_VDEV,
220         WMI_GRP_PEER,
221         WMI_GRP_MGMT,
222         WMI_GRP_BA_NEG,
223         WMI_GRP_STA_PS,
224         WMI_GRP_DFS,
225         WMI_GRP_ROAM,
226         WMI_GRP_OFL_SCAN,
227         WMI_GRP_P2P,
228         WMI_GRP_AP_PS,
229         WMI_GRP_RATE_CTRL,
230         WMI_GRP_PROFILE,
231         WMI_GRP_SUSPEND,
232         WMI_GRP_BCN_FILTER,
233         WMI_GRP_WOW,
234         WMI_GRP_RTT,
235         WMI_GRP_SPECTRAL,
236         WMI_GRP_STATS,
237         WMI_GRP_ARP_NS_OFL,
238         WMI_GRP_NLO_OFL,
239         WMI_GRP_GTK_OFL,
240         WMI_GRP_CSA_OFL,
241         WMI_GRP_CHATTER,
242         WMI_GRP_TID_ADDBA,
243         WMI_GRP_MISC,
244         WMI_GRP_GPIO,
245 };
246
247 #define WMI_CMD_GRP(grp_id) (((grp_id) << 12) | 0x1)
248 #define WMI_EVT_GRP_START_ID(grp_id) (((grp_id) << 12) | 0x1)
249
250 /* Command IDs and commande events. */
251 enum wmi_cmd_id {
252         WMI_INIT_CMDID = 0x1,
253
254         /* Scan specific commands */
255         WMI_START_SCAN_CMDID = WMI_CMD_GRP(WMI_GRP_SCAN),
256         WMI_STOP_SCAN_CMDID,
257         WMI_SCAN_CHAN_LIST_CMDID,
258         WMI_SCAN_SCH_PRIO_TBL_CMDID,
259
260         /* PDEV (physical device) specific commands */
261         WMI_PDEV_SET_REGDOMAIN_CMDID = WMI_CMD_GRP(WMI_GRP_PDEV),
262         WMI_PDEV_SET_CHANNEL_CMDID,
263         WMI_PDEV_SET_PARAM_CMDID,
264         WMI_PDEV_PKTLOG_ENABLE_CMDID,
265         WMI_PDEV_PKTLOG_DISABLE_CMDID,
266         WMI_PDEV_SET_WMM_PARAMS_CMDID,
267         WMI_PDEV_SET_HT_CAP_IE_CMDID,
268         WMI_PDEV_SET_VHT_CAP_IE_CMDID,
269         WMI_PDEV_SET_DSCP_TID_MAP_CMDID,
270         WMI_PDEV_SET_QUIET_MODE_CMDID,
271         WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID,
272         WMI_PDEV_GET_TPC_CONFIG_CMDID,
273         WMI_PDEV_SET_BASE_MACADDR_CMDID,
274
275         /* VDEV (virtual device) specific commands */
276         WMI_VDEV_CREATE_CMDID = WMI_CMD_GRP(WMI_GRP_VDEV),
277         WMI_VDEV_DELETE_CMDID,
278         WMI_VDEV_START_REQUEST_CMDID,
279         WMI_VDEV_RESTART_REQUEST_CMDID,
280         WMI_VDEV_UP_CMDID,
281         WMI_VDEV_STOP_CMDID,
282         WMI_VDEV_DOWN_CMDID,
283         WMI_VDEV_SET_PARAM_CMDID,
284         WMI_VDEV_INSTALL_KEY_CMDID,
285
286         /* peer specific commands */
287         WMI_PEER_CREATE_CMDID = WMI_CMD_GRP(WMI_GRP_PEER),
288         WMI_PEER_DELETE_CMDID,
289         WMI_PEER_FLUSH_TIDS_CMDID,
290         WMI_PEER_SET_PARAM_CMDID,
291         WMI_PEER_ASSOC_CMDID,
292         WMI_PEER_ADD_WDS_ENTRY_CMDID,
293         WMI_PEER_REMOVE_WDS_ENTRY_CMDID,
294         WMI_PEER_MCAST_GROUP_CMDID,
295
296         /* beacon/management specific commands */
297         WMI_BCN_TX_CMDID = WMI_CMD_GRP(WMI_GRP_MGMT),
298         WMI_PDEV_SEND_BCN_CMDID,
299         WMI_BCN_TMPL_CMDID,
300         WMI_BCN_FILTER_RX_CMDID,
301         WMI_PRB_REQ_FILTER_RX_CMDID,
302         WMI_MGMT_TX_CMDID,
303         WMI_PRB_TMPL_CMDID,
304
305         /* commands to directly control BA negotiation directly from host. */
306         WMI_ADDBA_CLEAR_RESP_CMDID = WMI_CMD_GRP(WMI_GRP_BA_NEG),
307         WMI_ADDBA_SEND_CMDID,
308         WMI_ADDBA_STATUS_CMDID,
309         WMI_DELBA_SEND_CMDID,
310         WMI_ADDBA_SET_RESP_CMDID,
311         WMI_SEND_SINGLEAMSDU_CMDID,
312
313         /* Station power save specific config */
314         WMI_STA_POWERSAVE_MODE_CMDID = WMI_CMD_GRP(WMI_GRP_STA_PS),
315         WMI_STA_POWERSAVE_PARAM_CMDID,
316         WMI_STA_MIMO_PS_MODE_CMDID,
317
318         /** DFS-specific commands */
319         WMI_PDEV_DFS_ENABLE_CMDID = WMI_CMD_GRP(WMI_GRP_DFS),
320         WMI_PDEV_DFS_DISABLE_CMDID,
321
322         /* Roaming specific  commands */
323         WMI_ROAM_SCAN_MODE = WMI_CMD_GRP(WMI_GRP_ROAM),
324         WMI_ROAM_SCAN_RSSI_THRESHOLD,
325         WMI_ROAM_SCAN_PERIOD,
326         WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
327         WMI_ROAM_AP_PROFILE,
328
329         /* offload scan specific commands */
330         WMI_OFL_SCAN_ADD_AP_PROFILE = WMI_CMD_GRP(WMI_GRP_OFL_SCAN),
331         WMI_OFL_SCAN_REMOVE_AP_PROFILE,
332         WMI_OFL_SCAN_PERIOD,
333
334         /* P2P specific commands */
335         WMI_P2P_DEV_SET_DEVICE_INFO = WMI_CMD_GRP(WMI_GRP_P2P),
336         WMI_P2P_DEV_SET_DISCOVERABILITY,
337         WMI_P2P_GO_SET_BEACON_IE,
338         WMI_P2P_GO_SET_PROBE_RESP_IE,
339         WMI_P2P_SET_VENDOR_IE_DATA_CMDID,
340
341         /* AP power save specific config */
342         WMI_AP_PS_PEER_PARAM_CMDID = WMI_CMD_GRP(WMI_GRP_AP_PS),
343         WMI_AP_PS_PEER_UAPSD_COEX_CMDID,
344
345         /* Rate-control specific commands */
346         WMI_PEER_RATE_RETRY_SCHED_CMDID =
347         WMI_CMD_GRP(WMI_GRP_RATE_CTRL),
348
349         /* WLAN Profiling commands. */
350         WMI_WLAN_PROFILE_TRIGGER_CMDID = WMI_CMD_GRP(WMI_GRP_PROFILE),
351         WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
352         WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
353         WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
354         WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
355
356         /* Suspend resume command Ids */
357         WMI_PDEV_SUSPEND_CMDID = WMI_CMD_GRP(WMI_GRP_SUSPEND),
358         WMI_PDEV_RESUME_CMDID,
359
360         /* Beacon filter commands */
361         WMI_ADD_BCN_FILTER_CMDID = WMI_CMD_GRP(WMI_GRP_BCN_FILTER),
362         WMI_RMV_BCN_FILTER_CMDID,
363
364         /* WOW Specific WMI commands*/
365         WMI_WOW_ADD_WAKE_PATTERN_CMDID = WMI_CMD_GRP(WMI_GRP_WOW),
366         WMI_WOW_DEL_WAKE_PATTERN_CMDID,
367         WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
368         WMI_WOW_ENABLE_CMDID,
369         WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
370
371         /* RTT measurement related cmd */
372         WMI_RTT_MEASREQ_CMDID = WMI_CMD_GRP(WMI_GRP_RTT),
373         WMI_RTT_TSF_CMDID,
374
375         /* spectral scan commands */
376         WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID = WMI_CMD_GRP(WMI_GRP_SPECTRAL),
377         WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
378
379         /* F/W stats */
380         WMI_REQUEST_STATS_CMDID = WMI_CMD_GRP(WMI_GRP_STATS),
381
382         /* ARP OFFLOAD REQUEST*/
383         WMI_SET_ARP_NS_OFFLOAD_CMDID = WMI_CMD_GRP(WMI_GRP_ARP_NS_OFL),
384
385         /* NS offload confid*/
386         WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID = WMI_CMD_GRP(WMI_GRP_NLO_OFL),
387
388         /* GTK offload Specific WMI commands*/
389         WMI_GTK_OFFLOAD_CMDID = WMI_CMD_GRP(WMI_GRP_GTK_OFL),
390
391         /* CSA offload Specific WMI commands*/
392         WMI_CSA_OFFLOAD_ENABLE_CMDID = WMI_CMD_GRP(WMI_GRP_CSA_OFL),
393         WMI_CSA_OFFLOAD_CHANSWITCH_CMDID,
394
395         /* Chatter commands*/
396         WMI_CHATTER_SET_MODE_CMDID = WMI_CMD_GRP(WMI_GRP_CHATTER),
397
398         /* addba specific commands */
399         WMI_PEER_TID_ADDBA_CMDID = WMI_CMD_GRP(WMI_GRP_TID_ADDBA),
400         WMI_PEER_TID_DELBA_CMDID,
401
402         /* set station mimo powersave method */
403         WMI_STA_DTIM_PS_METHOD_CMDID,
404         /* Configure the Station UAPSD AC Auto Trigger Parameters */
405         WMI_STA_UAPSD_AUTO_TRIG_CMDID,
406
407         /* STA Keep alive parameter configuration,
408            Requires WMI_SERVICE_STA_KEEP_ALIVE */
409         WMI_STA_KEEPALIVE_CMD,
410
411         /* misc command group */
412         WMI_ECHO_CMDID = WMI_CMD_GRP(WMI_GRP_MISC),
413         WMI_PDEV_UTF_CMDID,
414         WMI_DBGLOG_CFG_CMDID,
415         WMI_PDEV_QVIT_CMDID,
416         WMI_PDEV_FTM_INTG_CMDID,
417         WMI_VDEV_SET_KEEPALIVE_CMDID,
418         WMI_VDEV_GET_KEEPALIVE_CMDID,
419         WMI_FORCE_FW_HANG_CMDID,
420
421         /* GPIO Configuration */
422         WMI_GPIO_CONFIG_CMDID = WMI_CMD_GRP(WMI_GRP_GPIO),
423         WMI_GPIO_OUTPUT_CMDID,
424 };
425
426 enum wmi_event_id {
427         WMI_SERVICE_READY_EVENTID = 0x1,
428         WMI_READY_EVENTID,
429
430         /* Scan specific events */
431         WMI_SCAN_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_SCAN),
432
433         /* PDEV specific events */
434         WMI_PDEV_TPC_CONFIG_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_PDEV),
435         WMI_CHAN_INFO_EVENTID,
436         WMI_PHYERR_EVENTID,
437
438         /* VDEV specific events */
439         WMI_VDEV_START_RESP_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_VDEV),
440         WMI_VDEV_STOPPED_EVENTID,
441         WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID,
442
443         /* peer specific events */
444         WMI_PEER_STA_KICKOUT_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_PEER),
445
446         /* beacon/mgmt specific events */
447         WMI_MGMT_RX_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_MGMT),
448         WMI_HOST_SWBA_EVENTID,
449         WMI_TBTTOFFSET_UPDATE_EVENTID,
450
451         /* ADDBA Related WMI Events*/
452         WMI_TX_DELBA_COMPLETE_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_BA_NEG),
453         WMI_TX_ADDBA_COMPLETE_EVENTID,
454
455         /* Roam event to trigger roaming on host */
456         WMI_ROAM_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_ROAM),
457         WMI_PROFILE_MATCH,
458
459         /* WoW */
460         WMI_WOW_WAKEUP_HOST_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_WOW),
461
462         /* RTT */
463         WMI_RTT_MEASUREMENT_REPORT_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_RTT),
464         WMI_TSF_MEASUREMENT_REPORT_EVENTID,
465         WMI_RTT_ERROR_REPORT_EVENTID,
466
467         /* GTK offload */
468         WMI_GTK_OFFLOAD_STATUS_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_GTK_OFL),
469         WMI_GTK_REKEY_FAIL_EVENTID,
470
471         /* CSA IE received event */
472         WMI_CSA_HANDLING_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_CSA_OFL),
473
474         /* Misc events */
475         WMI_ECHO_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_MISC),
476         WMI_PDEV_UTF_EVENTID,
477         WMI_DEBUG_MESG_EVENTID,
478         WMI_UPDATE_STATS_EVENTID,
479         WMI_DEBUG_PRINT_EVENTID,
480         WMI_DCS_INTERFERENCE_EVENTID,
481         WMI_PDEV_QVIT_EVENTID,
482         WMI_WLAN_PROFILE_DATA_EVENTID,
483         WMI_PDEV_FTM_INTG_EVENTID,
484         WMI_WLAN_FREQ_AVOID_EVENTID,
485         WMI_VDEV_GET_KEEPALIVE_EVENTID,
486
487         /* GPIO Event */
488         WMI_GPIO_INPUT_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_GPIO),
489 };
490
491 enum wmi_phy_mode {
492         MODE_11A        = 0,   /* 11a Mode */
493         MODE_11G        = 1,   /* 11b/g Mode */
494         MODE_11B        = 2,   /* 11b Mode */
495         MODE_11GONLY    = 3,   /* 11g only Mode */
496         MODE_11NA_HT20   = 4,  /* 11a HT20 mode */
497         MODE_11NG_HT20   = 5,  /* 11g HT20 mode */
498         MODE_11NA_HT40   = 6,  /* 11a HT40 mode */
499         MODE_11NG_HT40   = 7,  /* 11g HT40 mode */
500         MODE_11AC_VHT20 = 8,
501         MODE_11AC_VHT40 = 9,
502         MODE_11AC_VHT80 = 10,
503         /*    MODE_11AC_VHT160 = 11, */
504         MODE_11AC_VHT20_2G = 11,
505         MODE_11AC_VHT40_2G = 12,
506         MODE_11AC_VHT80_2G = 13,
507         MODE_UNKNOWN    = 14,
508         MODE_MAX        = 14
509 };
510
511 #define WMI_CHAN_LIST_TAG       0x1
512 #define WMI_SSID_LIST_TAG       0x2
513 #define WMI_BSSID_LIST_TAG      0x3
514 #define WMI_IE_TAG              0x4
515
516 struct wmi_channel {
517         __le32 mhz;
518         __le32 band_center_freq1;
519         __le32 band_center_freq2; /* valid for 11ac, 80plus80 */
520         union {
521                 __le32 flags; /* WMI_CHAN_FLAG_ */
522                 struct {
523                         u8 mode; /* only 6 LSBs */
524                 } __packed;
525         } __packed;
526         union {
527                 __le32 reginfo0;
528                 struct {
529                         u8 min_power;
530                         u8 max_power;
531                         u8 reg_power;
532                         u8 reg_classid;
533                 } __packed;
534         } __packed;
535         union {
536                 __le32 reginfo1;
537                 struct {
538                         u8 antenna_max;
539                 } __packed;
540         } __packed;
541 } __packed;
542
543 struct wmi_channel_arg {
544         u32 freq;
545         u32 band_center_freq1;
546         bool passive;
547         bool allow_ibss;
548         bool allow_ht;
549         bool allow_vht;
550         bool ht40plus;
551         /* note: power unit is 1/4th of dBm */
552         u32 min_power;
553         u32 max_power;
554         u32 max_reg_power;
555         u32 max_antenna_gain;
556         u32 reg_class_id;
557         enum wmi_phy_mode mode;
558 };
559
560 enum wmi_channel_change_cause {
561         WMI_CHANNEL_CHANGE_CAUSE_NONE = 0,
562         WMI_CHANNEL_CHANGE_CAUSE_CSA,
563 };
564
565 #define WMI_CHAN_FLAG_HT40_PLUS      (1 << 6)
566 #define WMI_CHAN_FLAG_PASSIVE        (1 << 7)
567 #define WMI_CHAN_FLAG_ADHOC_ALLOWED  (1 << 8)
568 #define WMI_CHAN_FLAG_AP_DISABLED    (1 << 9)
569 #define WMI_CHAN_FLAG_DFS            (1 << 10)
570 #define WMI_CHAN_FLAG_ALLOW_HT       (1 << 11)
571 #define WMI_CHAN_FLAG_ALLOW_VHT      (1 << 12)
572
573 /* Indicate reason for channel switch */
574 #define WMI_CHANNEL_CHANGE_CAUSE_CSA (1 << 13)
575
576 #define WMI_MAX_SPATIAL_STREAM   3
577
578 /* HT Capabilities*/
579 #define WMI_HT_CAP_ENABLED                0x0001   /* HT Enabled/ disabled */
580 #define WMI_HT_CAP_HT20_SGI       0x0002   /* Short Guard Interval with HT20 */
581 #define WMI_HT_CAP_DYNAMIC_SMPS           0x0004   /* Dynamic MIMO powersave */
582 #define WMI_HT_CAP_TX_STBC                0x0008   /* B3 TX STBC */
583 #define WMI_HT_CAP_TX_STBC_MASK_SHIFT     3
584 #define WMI_HT_CAP_RX_STBC                0x0030   /* B4-B5 RX STBC */
585 #define WMI_HT_CAP_RX_STBC_MASK_SHIFT     4
586 #define WMI_HT_CAP_LDPC                   0x0040   /* LDPC supported */
587 #define WMI_HT_CAP_L_SIG_TXOP_PROT        0x0080   /* L-SIG TXOP Protection */
588 #define WMI_HT_CAP_MPDU_DENSITY           0x0700   /* MPDU Density */
589 #define WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT 8
590 #define WMI_HT_CAP_HT40_SGI               0x0800
591
592 #define WMI_HT_CAP_DEFAULT_ALL (WMI_HT_CAP_ENABLED       | \
593                                 WMI_HT_CAP_HT20_SGI      | \
594                                 WMI_HT_CAP_HT40_SGI      | \
595                                 WMI_HT_CAP_TX_STBC       | \
596                                 WMI_HT_CAP_RX_STBC       | \
597                                 WMI_HT_CAP_LDPC)
598
599
600 /*
601  * WMI_VHT_CAP_* these maps to ieee 802.11ac vht capability information
602  * field. The fields not defined here are not supported, or reserved.
603  * Do not change these masks and if you have to add new one follow the
604  * bitmask as specified by 802.11ac draft.
605  */
606
607 #define WMI_VHT_CAP_MAX_MPDU_LEN_MASK            0x00000003
608 #define WMI_VHT_CAP_RX_LDPC                      0x00000010
609 #define WMI_VHT_CAP_SGI_80MHZ                    0x00000020
610 #define WMI_VHT_CAP_TX_STBC                      0x00000080
611 #define WMI_VHT_CAP_RX_STBC_MASK                 0x00000300
612 #define WMI_VHT_CAP_RX_STBC_MASK_SHIFT           8
613 #define WMI_VHT_CAP_MAX_AMPDU_LEN_EXP            0x03800000
614 #define WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT      23
615 #define WMI_VHT_CAP_RX_FIXED_ANT                 0x10000000
616 #define WMI_VHT_CAP_TX_FIXED_ANT                 0x20000000
617
618 /* The following also refer for max HT AMSDU */
619 #define WMI_VHT_CAP_MAX_MPDU_LEN_3839            0x00000000
620 #define WMI_VHT_CAP_MAX_MPDU_LEN_7935            0x00000001
621 #define WMI_VHT_CAP_MAX_MPDU_LEN_11454           0x00000002
622
623 #define WMI_VHT_CAP_DEFAULT_ALL (WMI_VHT_CAP_MAX_MPDU_LEN_11454  | \
624                                  WMI_VHT_CAP_RX_LDPC             | \
625                                  WMI_VHT_CAP_SGI_80MHZ           | \
626                                  WMI_VHT_CAP_TX_STBC             | \
627                                  WMI_VHT_CAP_RX_STBC_MASK        | \
628                                  WMI_VHT_CAP_MAX_AMPDU_LEN_EXP   | \
629                                  WMI_VHT_CAP_RX_FIXED_ANT        | \
630                                  WMI_VHT_CAP_TX_FIXED_ANT)
631
632 /*
633  * Interested readers refer to Rx/Tx MCS Map definition as defined in
634  * 802.11ac
635  */
636 #define WMI_VHT_MAX_MCS_4_SS_MASK(r, ss)      ((3 & (r)) << (((ss) - 1) << 1))
637 #define WMI_VHT_MAX_SUPP_RATE_MASK           0x1fff0000
638 #define WMI_VHT_MAX_SUPP_RATE_MASK_SHIFT     16
639
640 enum {
641         REGDMN_MODE_11A              = 0x00001, /* 11a channels */
642         REGDMN_MODE_TURBO            = 0x00002, /* 11a turbo-only channels */
643         REGDMN_MODE_11B              = 0x00004, /* 11b channels */
644         REGDMN_MODE_PUREG            = 0x00008, /* 11g channels (OFDM only) */
645         REGDMN_MODE_11G              = 0x00008, /* XXX historical */
646         REGDMN_MODE_108G             = 0x00020, /* 11a+Turbo channels */
647         REGDMN_MODE_108A             = 0x00040, /* 11g+Turbo channels */
648         REGDMN_MODE_XR               = 0x00100, /* XR channels */
649         REGDMN_MODE_11A_HALF_RATE    = 0x00200, /* 11A half rate channels */
650         REGDMN_MODE_11A_QUARTER_RATE = 0x00400, /* 11A quarter rate channels */
651         REGDMN_MODE_11NG_HT20        = 0x00800, /* 11N-G HT20 channels */
652         REGDMN_MODE_11NA_HT20        = 0x01000, /* 11N-A HT20 channels */
653         REGDMN_MODE_11NG_HT40PLUS    = 0x02000, /* 11N-G HT40 + channels */
654         REGDMN_MODE_11NG_HT40MINUS   = 0x04000, /* 11N-G HT40 - channels */
655         REGDMN_MODE_11NA_HT40PLUS    = 0x08000, /* 11N-A HT40 + channels */
656         REGDMN_MODE_11NA_HT40MINUS   = 0x10000, /* 11N-A HT40 - channels */
657         REGDMN_MODE_11AC_VHT20       = 0x20000, /* 5Ghz, VHT20 */
658         REGDMN_MODE_11AC_VHT40PLUS   = 0x40000, /* 5Ghz, VHT40 + channels */
659         REGDMN_MODE_11AC_VHT40MINUS  = 0x80000, /* 5Ghz  VHT40 - channels */
660         REGDMN_MODE_11AC_VHT80       = 0x100000, /* 5Ghz, VHT80 channels */
661         REGDMN_MODE_ALL              = 0xffffffff
662 };
663
664 #define REGDMN_CAP1_CHAN_HALF_RATE        0x00000001
665 #define REGDMN_CAP1_CHAN_QUARTER_RATE     0x00000002
666 #define REGDMN_CAP1_CHAN_HAL49GHZ         0x00000004
667
668 /* regulatory capabilities */
669 #define REGDMN_EEPROM_EEREGCAP_EN_FCC_MIDBAND   0x0040
670 #define REGDMN_EEPROM_EEREGCAP_EN_KK_U1_EVEN    0x0080
671 #define REGDMN_EEPROM_EEREGCAP_EN_KK_U2         0x0100
672 #define REGDMN_EEPROM_EEREGCAP_EN_KK_MIDBAND    0x0200
673 #define REGDMN_EEPROM_EEREGCAP_EN_KK_U1_ODD     0x0400
674 #define REGDMN_EEPROM_EEREGCAP_EN_KK_NEW_11A    0x0800
675
676 struct hal_reg_capabilities {
677         /* regdomain value specified in EEPROM */
678         __le32 eeprom_rd;
679         /*regdomain */
680         __le32 eeprom_rd_ext;
681         /* CAP1 capabilities bit map. */
682         __le32 regcap1;
683         /* REGDMN EEPROM CAP. */
684         __le32 regcap2;
685         /* REGDMN MODE */
686         __le32 wireless_modes;
687         __le32 low_2ghz_chan;
688         __le32 high_2ghz_chan;
689         __le32 low_5ghz_chan;
690         __le32 high_5ghz_chan;
691 } __packed;
692
693 enum wlan_mode_capability {
694         WHAL_WLAN_11A_CAPABILITY   = 0x1,
695         WHAL_WLAN_11G_CAPABILITY   = 0x2,
696         WHAL_WLAN_11AG_CAPABILITY  = 0x3,
697 };
698
699 /* structure used by FW for requesting host memory */
700 struct wlan_host_mem_req {
701         /* ID of the request */
702         __le32 req_id;
703         /* size of the  of each unit */
704         __le32 unit_size;
705         /* flags to  indicate that
706          * the number units is dependent
707          * on number of resources(num vdevs num peers .. etc)
708          */
709         __le32 num_unit_info;
710         /*
711          * actual number of units to allocate . if flags in the num_unit_info
712          * indicate that number of units is tied to number of a particular
713          * resource to allocate then  num_units filed is set to 0 and host
714          * will derive the number units from number of the resources it is
715          * requesting.
716          */
717         __le32 num_units;
718 } __packed;
719
720 #define WMI_SERVICE_IS_ENABLED(wmi_svc_bmap, svc_id) \
721         ((((wmi_svc_bmap)[(svc_id)/(sizeof(u32))]) & \
722         (1 << ((svc_id)%(sizeof(u32))))) != 0)
723
724 /*
725  * The following struct holds optional payload for
726  * wmi_service_ready_event,e.g., 11ac pass some of the
727  * device capability to the host.
728  */
729 struct wmi_service_ready_event {
730         __le32 sw_version;
731         __le32 sw_version_1;
732         __le32 abi_version;
733         /* WMI_PHY_CAPABILITY */
734         __le32 phy_capability;
735         /* Maximum number of frag table entries that SW will populate less 1 */
736         __le32 max_frag_entry;
737         __le32 wmi_service_bitmap[WMI_SERVICE_BM_SIZE];
738         __le32 num_rf_chains;
739         /*
740          * The following field is only valid for service type
741          * WMI_SERVICE_11AC
742          */
743         __le32 ht_cap_info; /* WMI HT Capability */
744         __le32 vht_cap_info; /* VHT capability info field of 802.11ac */
745         __le32 vht_supp_mcs; /* VHT Supported MCS Set field Rx/Tx same */
746         __le32 hw_min_tx_power;
747         __le32 hw_max_tx_power;
748         struct hal_reg_capabilities hal_reg_capabilities;
749         __le32 sys_cap_info;
750         __le32 min_pkt_size_enable; /* Enterprise mode short pkt enable */
751         /*
752          * Max beacon and Probe Response IE offload size
753          * (includes optional P2P IEs)
754          */
755         __le32 max_bcn_ie_size;
756         /*
757          * request to host to allocate a chuck of memory and pss it down to FW
758          * via WM_INIT. FW uses this as FW extesnsion memory for saving its
759          * data structures. Only valid for low latency interfaces like PCIE
760          * where FW can access this memory directly (or) by DMA.
761          */
762         __le32 num_mem_reqs;
763         struct wlan_host_mem_req mem_reqs[1];
764 } __packed;
765
766 /*
767  * status consists of  upper 16 bits fo int status and lower 16 bits of
768  * module ID that retuned status
769  */
770 #define WLAN_INIT_STATUS_SUCCESS   0x0
771 #define WLAN_GET_INIT_STATUS_REASON(status)    ((status) & 0xffff)
772 #define WLAN_GET_INIT_STATUS_MODULE_ID(status) (((status) >> 16) & 0xffff)
773
774 #define WMI_SERVICE_READY_TIMEOUT_HZ (5*HZ)
775 #define WMI_UNIFIED_READY_TIMEOUT_HZ (5*HZ)
776
777 struct wmi_ready_event {
778         __le32 sw_version;
779         __le32 abi_version;
780         struct wmi_mac_addr mac_addr;
781         __le32 status;
782 } __packed;
783
784 struct wmi_resource_config {
785         /* number of virtual devices (VAPs) to support */
786         __le32 num_vdevs;
787
788         /* number of peer nodes to support */
789         __le32 num_peers;
790
791         /*
792          * In offload mode target supports features like WOW, chatter and
793          * other protocol offloads. In order to support them some
794          * functionalities like reorder buffering, PN checking need to be
795          * done in target. This determines maximum number of peers suported
796          * by target in offload mode
797          */
798         __le32 num_offload_peers;
799
800         /* For target-based RX reordering */
801         __le32 num_offload_reorder_bufs;
802
803         /* number of keys per peer */
804         __le32 num_peer_keys;
805
806         /* total number of TX/RX data TIDs */
807         __le32 num_tids;
808
809         /*
810          * max skid for resolving hash collisions
811          *
812          *   The address search table is sparse, so that if two MAC addresses
813          *   result in the same hash value, the second of these conflicting
814          *   entries can slide to the next index in the address search table,
815          *   and use it, if it is unoccupied.  This ast_skid_limit parameter
816          *   specifies the upper bound on how many subsequent indices to search
817          *   over to find an unoccupied space.
818          */
819         __le32 ast_skid_limit;
820
821         /*
822          * the nominal chain mask for transmit
823          *
824          *   The chain mask may be modified dynamically, e.g. to operate AP
825          *   tx with a reduced number of chains if no clients are associated.
826          *   This configuration parameter specifies the nominal chain-mask that
827          *   should be used when not operating with a reduced set of tx chains.
828          */
829         __le32 tx_chain_mask;
830
831         /*
832          * the nominal chain mask for receive
833          *
834          *   The chain mask may be modified dynamically, e.g. for a client
835          *   to use a reduced number of chains for receive if the traffic to
836          *   the client is low enough that it doesn't require downlink MIMO
837          *   or antenna diversity.
838          *   This configuration parameter specifies the nominal chain-mask that
839          *   should be used when not operating with a reduced set of rx chains.
840          */
841         __le32 rx_chain_mask;
842
843         /*
844          * what rx reorder timeout (ms) to use for the AC
845          *
846          *   Each WMM access class (voice, video, best-effort, background) will
847          *   have its own timeout value to dictate how long to wait for missing
848          *   rx MPDUs to arrive before flushing subsequent MPDUs that have
849          *   already been received.
850          *   This parameter specifies the timeout in milliseconds for each
851          *   class.
852          */
853         __le32 rx_timeout_pri_vi;
854         __le32 rx_timeout_pri_vo;
855         __le32 rx_timeout_pri_be;
856         __le32 rx_timeout_pri_bk;
857
858         /*
859          * what mode the rx should decap packets to
860          *
861          *   MAC can decap to RAW (no decap), native wifi or Ethernet types
862          *   THis setting also determines the default TX behavior, however TX
863          *   behavior can be modified on a per VAP basis during VAP init
864          */
865         __le32 rx_decap_mode;
866
867         /* what is the maximum scan requests than can be queued */
868         __le32 scan_max_pending_reqs;
869
870         /* maximum VDEV that could use BMISS offload */
871         __le32 bmiss_offload_max_vdev;
872
873         /* maximum VDEV that could use offload roaming */
874         __le32 roam_offload_max_vdev;
875
876         /* maximum AP profiles that would push to offload roaming */
877         __le32 roam_offload_max_ap_profiles;
878
879         /*
880          * how many groups to use for mcast->ucast conversion
881          *
882          *   The target's WAL maintains a table to hold information regarding
883          *   which peers belong to a given multicast group, so that if
884          *   multicast->unicast conversion is enabled, the target can convert
885          *   multicast tx frames to a series of unicast tx frames, to each
886          *   peer within the multicast group.
887              This num_mcast_groups configuration parameter tells the target how
888          *   many multicast groups to provide storage for within its multicast
889          *   group membership table.
890          */
891         __le32 num_mcast_groups;
892
893         /*
894          * size to alloc for the mcast membership table
895          *
896          *   This num_mcast_table_elems configuration parameter tells the
897          *   target how many peer elements it needs to provide storage for in
898          *   its multicast group membership table.
899          *   These multicast group membership table elements are shared by the
900          *   multicast groups stored within the table.
901          */
902         __le32 num_mcast_table_elems;
903
904         /*
905          * whether/how to do multicast->unicast conversion
906          *
907          *   This configuration parameter specifies whether the target should
908          *   perform multicast --> unicast conversion on transmit, and if so,
909          *   what to do if it finds no entries in its multicast group
910          *   membership table for the multicast IP address in the tx frame.
911          *   Configuration value:
912          *   0 -> Do not perform multicast to unicast conversion.
913          *   1 -> Convert multicast frames to unicast, if the IP multicast
914          *        address from the tx frame is found in the multicast group
915          *        membership table.  If the IP multicast address is not found,
916          *        drop the frame.
917          *   2 -> Convert multicast frames to unicast, if the IP multicast
918          *        address from the tx frame is found in the multicast group
919          *        membership table.  If the IP multicast address is not found,
920          *        transmit the frame as multicast.
921          */
922         __le32 mcast2ucast_mode;
923
924         /*
925          * how much memory to allocate for a tx PPDU dbg log
926          *
927          *   This parameter controls how much memory the target will allocate
928          *   to store a log of tx PPDU meta-information (how large the PPDU
929          *   was, when it was sent, whether it was successful, etc.)
930          */
931         __le32 tx_dbg_log_size;
932
933         /* how many AST entries to be allocated for WDS */
934         __le32 num_wds_entries;
935
936         /*
937          * MAC DMA burst size, e.g., For target PCI limit can be
938          * 0 -default, 1 256B
939          */
940         __le32 dma_burst_size;
941
942         /*
943          * Fixed delimiters to be inserted after every MPDU to
944          * account for interface latency to avoid underrun.
945          */
946         __le32 mac_aggr_delim;
947
948         /*
949          *   determine whether target is responsible for detecting duplicate
950          *   non-aggregate MPDU and timing out stale fragments.
951          *
952          *   A-MPDU reordering is always performed on the target.
953          *
954          *   0: target responsible for frag timeout and dup checking
955          *   1: host responsible for frag timeout and dup checking
956          */
957         __le32 rx_skip_defrag_timeout_dup_detection_check;
958
959         /*
960          * Configuration for VoW :
961          * No of Video Nodes to be supported
962          * and Max no of descriptors for each Video link (node).
963          */
964         __le32 vow_config;
965
966         /* maximum VDEV that could use GTK offload */
967         __le32 gtk_offload_max_vdev;
968
969         /* Number of msdu descriptors target should use */
970         __le32 num_msdu_desc;
971
972         /*
973          * Max. number of Tx fragments per MSDU
974          *  This parameter controls the max number of Tx fragments per MSDU.
975          *  This is sent by the target as part of the WMI_SERVICE_READY event
976          *  and is overriden by the OS shim as required.
977          */
978         __le32 max_frag_entries;
979 } __packed;
980
981 /* strucutre describing host memory chunk. */
982 struct host_memory_chunk {
983         /* id of the request that is passed up in service ready */
984         __le32 req_id;
985         /* the physical address the memory chunk */
986         __le32 ptr;
987         /* size of the chunk */
988         __le32 size;
989 } __packed;
990
991 struct wmi_init_cmd {
992         struct wmi_resource_config resource_config;
993         __le32 num_host_mem_chunks;
994
995         /*
996          * variable number of host memory chunks.
997          * This should be the last element in the structure
998          */
999         struct host_memory_chunk host_mem_chunks[1];
1000 } __packed;
1001
1002 /* TLV for channel list */
1003 struct wmi_chan_list {
1004         __le32 tag; /* WMI_CHAN_LIST_TAG */
1005         __le32 num_chan;
1006         __le32 channel_list[0];
1007 } __packed;
1008
1009 struct wmi_bssid_list {
1010         __le32 tag; /* WMI_BSSID_LIST_TAG */
1011         __le32 num_bssid;
1012         struct wmi_mac_addr bssid_list[0];
1013 } __packed;
1014
1015 struct wmi_ie_data {
1016         __le32 tag; /* WMI_IE_TAG */
1017         __le32 ie_len;
1018         u8 ie_data[0];
1019 } __packed;
1020
1021 struct wmi_ssid {
1022         __le32 ssid_len;
1023         u8 ssid[32];
1024 } __packed;
1025
1026 struct wmi_ssid_list {
1027         __le32 tag; /* WMI_SSID_LIST_TAG */
1028         __le32 num_ssids;
1029         struct wmi_ssid ssids[0];
1030 } __packed;
1031
1032 /* prefix used by scan requestor ids on the host */
1033 #define WMI_HOST_SCAN_REQUESTOR_ID_PREFIX 0xA000
1034
1035 /* prefix used by scan request ids generated on the host */
1036 /* host cycles through the lower 12 bits to generate ids */
1037 #define WMI_HOST_SCAN_REQ_ID_PREFIX 0xA000
1038
1039 #define WLAN_SCAN_PARAMS_MAX_SSID    16
1040 #define WLAN_SCAN_PARAMS_MAX_BSSID   4
1041 #define WLAN_SCAN_PARAMS_MAX_IE_LEN  256
1042
1043 /* Scan priority numbers must be sequential, starting with 0 */
1044 enum wmi_scan_priority {
1045         WMI_SCAN_PRIORITY_VERY_LOW = 0,
1046         WMI_SCAN_PRIORITY_LOW,
1047         WMI_SCAN_PRIORITY_MEDIUM,
1048         WMI_SCAN_PRIORITY_HIGH,
1049         WMI_SCAN_PRIORITY_VERY_HIGH,
1050         WMI_SCAN_PRIORITY_COUNT   /* number of priorities supported */
1051 };
1052
1053 struct wmi_start_scan_cmd {
1054         /* Scan ID */
1055         __le32 scan_id;
1056         /* Scan requestor ID */
1057         __le32 scan_req_id;
1058         /* VDEV id(interface) that is requesting scan */
1059         __le32 vdev_id;
1060         /* Scan Priority, input to scan scheduler */
1061         __le32 scan_priority;
1062         /* Scan events subscription */
1063         __le32 notify_scan_events;
1064         /* dwell time in msec on active channels */
1065         __le32 dwell_time_active;
1066         /* dwell time in msec on passive channels */
1067         __le32 dwell_time_passive;
1068         /*
1069          * min time in msec on the BSS channel,only valid if atleast one
1070          * VDEV is active
1071          */
1072         __le32 min_rest_time;
1073         /*
1074          * max rest time in msec on the BSS channel,only valid if at least
1075          * one VDEV is active
1076          */
1077         /*
1078          * the scanner will rest on the bss channel at least min_rest_time
1079          * after min_rest_time the scanner will start checking for tx/rx
1080          * activity on all VDEVs. if there is no activity the scanner will
1081          * switch to off channel. if there is activity the scanner will let
1082          * the radio on the bss channel until max_rest_time expires.at
1083          * max_rest_time scanner will switch to off channel irrespective of
1084          * activity. activity is determined by the idle_time parameter.
1085          */
1086         __le32 max_rest_time;
1087         /*
1088          * time before sending next set of probe requests.
1089          * The scanner keeps repeating probe requests transmission with
1090          * period specified by repeat_probe_time.
1091          * The number of probe requests specified depends on the ssid_list
1092          * and bssid_list
1093          */
1094         __le32 repeat_probe_time;
1095         /* time in msec between 2 consequetive probe requests with in a set. */
1096         __le32 probe_spacing_time;
1097         /*
1098          * data inactivity time in msec on bss channel that will be used by
1099          * scanner for measuring the inactivity.
1100          */
1101         __le32 idle_time;
1102         /* maximum time in msec allowed for scan  */
1103         __le32 max_scan_time;
1104         /*
1105          * delay in msec before sending first probe request after switching
1106          * to a channel
1107          */
1108         __le32 probe_delay;
1109         /* Scan control flags */
1110         __le32 scan_ctrl_flags;
1111
1112         /* Burst duration time in msecs */
1113         __le32 burst_duration;
1114         /*
1115          * TLV (tag length value )  paramerters follow the scan_cmd structure.
1116          * TLV can contain channel list, bssid list, ssid list and
1117          * ie. the TLV tags are defined above;
1118          */
1119 } __packed;
1120
1121 struct wmi_ssid_arg {
1122         int len;
1123         const u8 *ssid;
1124 };
1125
1126 struct wmi_bssid_arg {
1127         const u8 *bssid;
1128 };
1129
1130 struct wmi_start_scan_arg {
1131         u32 scan_id;
1132         u32 scan_req_id;
1133         u32 vdev_id;
1134         u32 scan_priority;
1135         u32 notify_scan_events;
1136         u32 dwell_time_active;
1137         u32 dwell_time_passive;
1138         u32 min_rest_time;
1139         u32 max_rest_time;
1140         u32 repeat_probe_time;
1141         u32 probe_spacing_time;
1142         u32 idle_time;
1143         u32 max_scan_time;
1144         u32 probe_delay;
1145         u32 scan_ctrl_flags;
1146
1147         u32 ie_len;
1148         u32 n_channels;
1149         u32 n_ssids;
1150         u32 n_bssids;
1151
1152         u8 ie[WLAN_SCAN_PARAMS_MAX_IE_LEN];
1153         u32 channels[64];
1154         struct wmi_ssid_arg ssids[WLAN_SCAN_PARAMS_MAX_SSID];
1155         struct wmi_bssid_arg bssids[WLAN_SCAN_PARAMS_MAX_BSSID];
1156 };
1157
1158 /* scan control flags */
1159
1160 /* passively scan all channels including active channels */
1161 #define WMI_SCAN_FLAG_PASSIVE        0x1
1162 /* add wild card ssid probe request even though ssid_list is specified. */
1163 #define WMI_SCAN_ADD_BCAST_PROBE_REQ 0x2
1164 /* add cck rates to rates/xrate ie for the generated probe request */
1165 #define WMI_SCAN_ADD_CCK_RATES 0x4
1166 /* add ofdm rates to rates/xrate ie for the generated probe request */
1167 #define WMI_SCAN_ADD_OFDM_RATES 0x8
1168 /* To enable indication of Chan load and Noise floor to host */
1169 #define WMI_SCAN_CHAN_STAT_EVENT 0x10
1170 /* Filter Probe request frames  */
1171 #define WMI_SCAN_FILTER_PROBE_REQ 0x20
1172 /* When set, DFS channels will not be scanned */
1173 #define WMI_SCAN_BYPASS_DFS_CHN 0x40
1174 /* Different FW scan engine may choose to bail out on errors.
1175  * Allow the driver to have influence over that. */
1176 #define WMI_SCAN_CONTINUE_ON_ERROR 0x80
1177
1178 /* WMI_SCAN_CLASS_MASK must be the same value as IEEE80211_SCAN_CLASS_MASK */
1179 #define WMI_SCAN_CLASS_MASK 0xFF000000
1180
1181
1182 enum wmi_stop_scan_type {
1183         WMI_SCAN_STOP_ONE       = 0x00000000, /* stop by scan_id */
1184         WMI_SCAN_STOP_VDEV_ALL  = 0x01000000, /* stop by vdev_id */
1185         WMI_SCAN_STOP_ALL       = 0x04000000, /* stop all scans */
1186 };
1187
1188 struct wmi_stop_scan_cmd {
1189         __le32 scan_req_id;
1190         __le32 scan_id;
1191         __le32 req_type;
1192         __le32 vdev_id;
1193 } __packed;
1194
1195 struct wmi_stop_scan_arg {
1196         u32 req_id;
1197         enum wmi_stop_scan_type req_type;
1198         union {
1199                 u32 scan_id;
1200                 u32 vdev_id;
1201         } u;
1202 };
1203
1204 struct wmi_scan_chan_list_cmd {
1205         __le32 num_scan_chans;
1206         struct wmi_channel chan_info[0];
1207 } __packed;
1208
1209 struct wmi_scan_chan_list_arg {
1210         u32 n_channels;
1211         struct wmi_channel_arg *channels;
1212 };
1213
1214 enum wmi_bss_filter {
1215         WMI_BSS_FILTER_NONE = 0,        /* no beacons forwarded */
1216         WMI_BSS_FILTER_ALL,             /* all beacons forwarded */
1217         WMI_BSS_FILTER_PROFILE,         /* only beacons matching profile */
1218         WMI_BSS_FILTER_ALL_BUT_PROFILE, /* all but beacons matching profile */
1219         WMI_BSS_FILTER_CURRENT_BSS,     /* only beacons matching current BSS */
1220         WMI_BSS_FILTER_ALL_BUT_BSS,     /* all but beacons matching BSS */
1221         WMI_BSS_FILTER_PROBED_SSID,     /* beacons matching probed ssid */
1222         WMI_BSS_FILTER_LAST_BSS,        /* marker only */
1223 };
1224
1225 enum wmi_scan_event_type {
1226         WMI_SCAN_EVENT_STARTED         = 0x1,
1227         WMI_SCAN_EVENT_COMPLETED       = 0x2,
1228         WMI_SCAN_EVENT_BSS_CHANNEL     = 0x4,
1229         WMI_SCAN_EVENT_FOREIGN_CHANNEL = 0x8,
1230         WMI_SCAN_EVENT_DEQUEUED        = 0x10,
1231         WMI_SCAN_EVENT_PREEMPTED       = 0x20, /* possibly by high-prio scan */
1232         WMI_SCAN_EVENT_START_FAILED    = 0x40,
1233         WMI_SCAN_EVENT_RESTARTED       = 0x80,
1234         WMI_SCAN_EVENT_MAX             = 0x8000
1235 };
1236
1237 enum wmi_scan_completion_reason {
1238         WMI_SCAN_REASON_COMPLETED,
1239         WMI_SCAN_REASON_CANCELLED,
1240         WMI_SCAN_REASON_PREEMPTED,
1241         WMI_SCAN_REASON_TIMEDOUT,
1242         WMI_SCAN_REASON_MAX,
1243 };
1244
1245 struct wmi_scan_event {
1246         __le32 event_type; /* %WMI_SCAN_EVENT_ */
1247         __le32 reason; /* %WMI_SCAN_REASON_ */
1248         __le32 channel_freq; /* only valid for WMI_SCAN_EVENT_FOREIGN_CHANNEL */
1249         __le32 scan_req_id;
1250         __le32 scan_id;
1251         __le32 vdev_id;
1252 } __packed;
1253
1254 /*
1255  * This defines how much headroom is kept in the
1256  * receive frame between the descriptor and the
1257  * payload, in order for the WMI PHY error and
1258  * management handler to insert header contents.
1259  *
1260  * This is in bytes.
1261  */
1262 #define WMI_MGMT_RX_HDR_HEADROOM    52
1263
1264 /*
1265  * This event will be used for sending scan results
1266  * as well as rx mgmt frames to the host. The rx buffer
1267  * will be sent as part of this WMI event. It would be a
1268  * good idea to pass all the fields in the RX status
1269  * descriptor up to the host.
1270  */
1271 struct wmi_mgmt_rx_hdr_v1 {
1272         __le32 channel;
1273         __le32 snr;
1274         __le32 rate;
1275         __le32 phy_mode;
1276         __le32 buf_len;
1277         __le32 status; /* %WMI_RX_STATUS_ */
1278 } __packed;
1279
1280 struct wmi_mgmt_rx_hdr_v2 {
1281         struct wmi_mgmt_rx_hdr_v1 v1;
1282         __le32 rssi_ctl[4];
1283 } __packed;
1284
1285 struct wmi_mgmt_rx_event_v1 {
1286         struct wmi_mgmt_rx_hdr_v1 hdr;
1287         u8 buf[0];
1288 } __packed;
1289
1290 struct wmi_mgmt_rx_event_v2 {
1291         struct wmi_mgmt_rx_hdr_v2 hdr;
1292         u8 buf[0];
1293 } __packed;
1294
1295 #define WMI_RX_STATUS_OK                        0x00
1296 #define WMI_RX_STATUS_ERR_CRC                   0x01
1297 #define WMI_RX_STATUS_ERR_DECRYPT               0x08
1298 #define WMI_RX_STATUS_ERR_MIC                   0x10
1299 #define WMI_RX_STATUS_ERR_KEY_CACHE_MISS        0x20
1300
1301 struct wmi_single_phyerr_rx_hdr {
1302         /* TSF timestamp */
1303         __le32 tsf_timestamp;
1304
1305         /*
1306          * Current freq1, freq2
1307          *
1308          * [7:0]:    freq1[lo]
1309          * [15:8] :   freq1[hi]
1310          * [23:16]:   freq2[lo]
1311          * [31:24]:   freq2[hi]
1312          */
1313         __le16 freq1;
1314         __le16 freq2;
1315
1316         /*
1317          * Combined RSSI over all chains and channel width for this PHY error
1318          *
1319          * [7:0]: RSSI combined
1320          * [15:8]: Channel width (MHz)
1321          * [23:16]: PHY error code
1322          * [24:16]: reserved (future use)
1323          */
1324         u8 rssi_combined;
1325         u8 chan_width_mhz;
1326         u8 phy_err_code;
1327         u8 rsvd0;
1328
1329         /*
1330          * RSSI on chain 0 through 3
1331          *
1332          * This is formatted the same as the PPDU_START RX descriptor
1333          * field:
1334          *
1335          * [7:0]:   pri20
1336          * [15:8]:  sec20
1337          * [23:16]: sec40
1338          * [31:24]: sec80
1339          */
1340
1341         __le32 rssi_chain0;
1342         __le32 rssi_chain1;
1343         __le32 rssi_chain2;
1344         __le32 rssi_chain3;
1345
1346         /*
1347          * Last calibrated NF value for chain 0 through 3
1348          *
1349          * nf_list_1:
1350          *
1351          * + [15:0] - chain 0
1352          * + [31:16] - chain 1
1353          *
1354          * nf_list_2:
1355          *
1356          * + [15:0] - chain 2
1357          * + [31:16] - chain 3
1358          */
1359         __le32 nf_list_1;
1360         __le32 nf_list_2;
1361
1362
1363         /* Length of the frame */
1364         __le32 buf_len;
1365 } __packed;
1366
1367 struct wmi_single_phyerr_rx_event {
1368         /* Phy error event header */
1369         struct wmi_single_phyerr_rx_hdr hdr;
1370         /* frame buffer */
1371         u8 bufp[0];
1372 } __packed;
1373
1374 struct wmi_comb_phyerr_rx_hdr {
1375         /* Phy error phy error count */
1376         __le32 num_phyerr_events;
1377         __le32 tsf_l32;
1378         __le32 tsf_u32;
1379 } __packed;
1380
1381 struct wmi_comb_phyerr_rx_event {
1382         /* Phy error phy error count */
1383         struct wmi_comb_phyerr_rx_hdr hdr;
1384         /*
1385          * frame buffer - contains multiple payloads in the order:
1386          *                    header - payload, header - payload...
1387          *  (The header is of type: wmi_single_phyerr_rx_hdr)
1388          */
1389         u8 bufp[0];
1390 } __packed;
1391
1392 struct wmi_mgmt_tx_hdr {
1393         __le32 vdev_id;
1394         struct wmi_mac_addr peer_macaddr;
1395         __le32 tx_rate;
1396         __le32 tx_power;
1397         __le32 buf_len;
1398 } __packed;
1399
1400 struct wmi_mgmt_tx_cmd {
1401         struct wmi_mgmt_tx_hdr hdr;
1402         u8 buf[0];
1403 } __packed;
1404
1405 struct wmi_echo_event {
1406         __le32 value;
1407 } __packed;
1408
1409 struct wmi_echo_cmd {
1410         __le32 value;
1411 } __packed;
1412
1413
1414 struct wmi_pdev_set_regdomain_cmd {
1415         __le32 reg_domain;
1416         __le32 reg_domain_2G;
1417         __le32 reg_domain_5G;
1418         __le32 conformance_test_limit_2G;
1419         __le32 conformance_test_limit_5G;
1420 } __packed;
1421
1422 /* Command to set/unset chip in quiet mode */
1423 struct wmi_pdev_set_quiet_cmd {
1424         /* period in TUs */
1425         __le32 period;
1426
1427         /* duration in TUs */
1428         __le32 duration;
1429
1430         /* offset in TUs */
1431         __le32 next_start;
1432
1433         /* enable/disable */
1434         __le32 enabled;
1435 } __packed;
1436
1437
1438 /*
1439  * 802.11g protection mode.
1440  */
1441 enum ath10k_protmode {
1442         ATH10K_PROT_NONE     = 0,    /* no protection */
1443         ATH10K_PROT_CTSONLY  = 1,    /* CTS to self */
1444         ATH10K_PROT_RTSCTS   = 2,    /* RTS-CTS */
1445 };
1446
1447 enum wmi_beacon_gen_mode {
1448         WMI_BEACON_STAGGERED_MODE = 0,
1449         WMI_BEACON_BURST_MODE = 1
1450 };
1451
1452 enum wmi_csa_event_ies_present_flag {
1453         WMI_CSA_IE_PRESENT = 0x00000001,
1454         WMI_XCSA_IE_PRESENT = 0x00000002,
1455         WMI_WBW_IE_PRESENT = 0x00000004,
1456         WMI_CSWARP_IE_PRESENT = 0x00000008,
1457 };
1458
1459 /* wmi CSA receive event from beacon frame */
1460 struct wmi_csa_event {
1461         __le32 i_fc_dur;
1462         /* Bit 0-15: FC */
1463         /* Bit 16-31: DUR */
1464         struct wmi_mac_addr i_addr1;
1465         struct wmi_mac_addr i_addr2;
1466         __le32 csa_ie[2];
1467         __le32 xcsa_ie[2];
1468         __le32 wb_ie[2];
1469         __le32 cswarp_ie;
1470         __le32 ies_present_flag; /* wmi_csa_event_ies_present_flag */
1471 } __packed;
1472
1473 /* the definition of different PDEV parameters */
1474 #define PDEV_DEFAULT_STATS_UPDATE_PERIOD    500
1475 #define VDEV_DEFAULT_STATS_UPDATE_PERIOD    500
1476 #define PEER_DEFAULT_STATS_UPDATE_PERIOD    500
1477
1478 enum wmi_pdev_param {
1479         /* TX chian mask */
1480         WMI_PDEV_PARAM_TX_CHAIN_MASK = 0x1,
1481         /* RX chian mask */
1482         WMI_PDEV_PARAM_RX_CHAIN_MASK,
1483         /* TX power limit for 2G Radio */
1484         WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
1485         /* TX power limit for 5G Radio */
1486         WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
1487         /* TX power scale */
1488         WMI_PDEV_PARAM_TXPOWER_SCALE,
1489         /* Beacon generation mode . 0: host, 1: target   */
1490         WMI_PDEV_PARAM_BEACON_GEN_MODE,
1491         /* Beacon generation mode . 0: staggered 1: bursted   */
1492         WMI_PDEV_PARAM_BEACON_TX_MODE,
1493         /*
1494          * Resource manager off chan mode .
1495          * 0: turn off off chan mode. 1: turn on offchan mode
1496          */
1497         WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
1498         /*
1499          * Protection mode:
1500          * 0: no protection 1:use CTS-to-self 2: use RTS/CTS
1501          */
1502         WMI_PDEV_PARAM_PROTECTION_MODE,
1503         /* Dynamic bandwidth 0: disable 1: enable */
1504         WMI_PDEV_PARAM_DYNAMIC_BW,
1505         /* Non aggregrate/ 11g sw retry threshold.0-disable */
1506         WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
1507         /* aggregrate sw retry threshold. 0-disable*/
1508         WMI_PDEV_PARAM_AGG_SW_RETRY_TH,
1509         /* Station kickout threshold (non of consecutive failures).0-disable */
1510         WMI_PDEV_PARAM_STA_KICKOUT_TH,
1511         /* Aggerate size scaling configuration per AC */
1512         WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING,
1513         /* LTR enable */
1514         WMI_PDEV_PARAM_LTR_ENABLE,
1515         /* LTR latency for BE, in us */
1516         WMI_PDEV_PARAM_LTR_AC_LATENCY_BE,
1517         /* LTR latency for BK, in us */
1518         WMI_PDEV_PARAM_LTR_AC_LATENCY_BK,
1519         /* LTR latency for VI, in us */
1520         WMI_PDEV_PARAM_LTR_AC_LATENCY_VI,
1521         /* LTR latency for VO, in us  */
1522         WMI_PDEV_PARAM_LTR_AC_LATENCY_VO,
1523         /* LTR AC latency timeout, in ms */
1524         WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
1525         /* LTR platform latency override, in us */
1526         WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
1527         /* LTR-RX override, in us */
1528         WMI_PDEV_PARAM_LTR_RX_OVERRIDE,
1529         /* Tx activity timeout for LTR, in us */
1530         WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
1531         /* L1SS state machine enable */
1532         WMI_PDEV_PARAM_L1SS_ENABLE,
1533         /* Deep sleep state machine enable */
1534         WMI_PDEV_PARAM_DSLEEP_ENABLE,
1535         /* RX buffering flush enable */
1536         WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
1537         /* RX buffering matermark */
1538         WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK,
1539         /* RX buffering timeout enable */
1540         WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
1541         /* RX buffering timeout value */
1542         WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
1543         /* pdev level stats update period in ms */
1544         WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
1545         /* vdev level stats update period in ms */
1546         WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
1547         /* peer level stats update period in ms */
1548         WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
1549         /* beacon filter status update period */
1550         WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
1551         /* QOS Mgmt frame protection MFP/PMF 0: disable, 1: enable */
1552         WMI_PDEV_PARAM_PMF_QOS,
1553         /* Access category on which ARP frames are sent */
1554         WMI_PDEV_PARAM_ARP_AC_OVERRIDE,
1555         /* DCS configuration */
1556         WMI_PDEV_PARAM_DCS,
1557         /* Enable/Disable ANI on target */
1558         WMI_PDEV_PARAM_ANI_ENABLE,
1559         /* configure the ANI polling period */
1560         WMI_PDEV_PARAM_ANI_POLL_PERIOD,
1561         /* configure the ANI listening period */
1562         WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
1563         /* configure OFDM immunity level */
1564         WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
1565         /* configure CCK immunity level */
1566         WMI_PDEV_PARAM_ANI_CCK_LEVEL,
1567         /* Enable/Disable CDD for 1x1 STAs in rate control module */
1568         WMI_PDEV_PARAM_DYNTXCHAIN,
1569         /* Enable/Disable proxy STA */
1570         WMI_PDEV_PARAM_PROXY_STA,
1571         /* Enable/Disable low power state when all VDEVs are inactive/idle. */
1572         WMI_PDEV_PARAM_IDLE_PS_CONFIG,
1573         /* Enable/Disable power gating sleep */
1574         WMI_PDEV_PARAM_POWER_GATING_SLEEP,
1575 };
1576
1577 struct wmi_pdev_set_param_cmd {
1578         __le32 param_id;
1579         __le32 param_value;
1580 } __packed;
1581
1582 struct wmi_pdev_get_tpc_config_cmd {
1583         /* parameter   */
1584         __le32 param;
1585 } __packed;
1586
1587 #define WMI_TPC_RATE_MAX                160
1588 #define WMI_TPC_TX_N_CHAIN              4
1589
1590 enum wmi_tpc_config_event_flag {
1591         WMI_TPC_CONFIG_EVENT_FLAG_TABLE_CDD     = 0x1,
1592         WMI_TPC_CONFIG_EVENT_FLAG_TABLE_STBC    = 0x2,
1593         WMI_TPC_CONFIG_EVENT_FLAG_TABLE_TXBF    = 0x4,
1594 };
1595
1596 struct wmi_pdev_tpc_config_event {
1597         __le32 reg_domain;
1598         __le32 chan_freq;
1599         __le32 phy_mode;
1600         __le32 twice_antenna_reduction;
1601         __le32 twice_max_rd_power;
1602         s32 twice_antenna_gain;
1603         __le32 power_limit;
1604         __le32 rate_max;
1605         __le32 num_tx_chain;
1606         __le32 ctl;
1607         __le32 flags;
1608         s8 max_reg_allow_pow[WMI_TPC_TX_N_CHAIN];
1609         s8 max_reg_allow_pow_agcdd[WMI_TPC_TX_N_CHAIN][WMI_TPC_TX_N_CHAIN];
1610         s8 max_reg_allow_pow_agstbc[WMI_TPC_TX_N_CHAIN][WMI_TPC_TX_N_CHAIN];
1611         s8 max_reg_allow_pow_agtxbf[WMI_TPC_TX_N_CHAIN][WMI_TPC_TX_N_CHAIN];
1612         u8 rates_array[WMI_TPC_RATE_MAX];
1613 } __packed;
1614
1615 /* Transmit power scale factor. */
1616 enum wmi_tp_scale {
1617         WMI_TP_SCALE_MAX    = 0,        /* no scaling (default) */
1618         WMI_TP_SCALE_50     = 1,        /* 50% of max (-3 dBm) */
1619         WMI_TP_SCALE_25     = 2,        /* 25% of max (-6 dBm) */
1620         WMI_TP_SCALE_12     = 3,        /* 12% of max (-9 dBm) */
1621         WMI_TP_SCALE_MIN    = 4,        /* min, but still on   */
1622         WMI_TP_SCALE_SIZE   = 5,        /* max num of enum     */
1623 };
1624
1625 struct wmi_set_channel_cmd {
1626         /* channel (only frequency and mode info are used) */
1627         struct wmi_channel chan;
1628 } __packed;
1629
1630 struct wmi_pdev_chanlist_update_event {
1631         /* number of channels */
1632         __le32 num_chan;
1633         /* array of channels */
1634         struct wmi_channel channel_list[1];
1635 } __packed;
1636
1637 #define WMI_MAX_DEBUG_MESG (sizeof(u32) * 32)
1638
1639 struct wmi_debug_mesg_event {
1640         /* message buffer, NULL terminated */
1641         char bufp[WMI_MAX_DEBUG_MESG];
1642 } __packed;
1643
1644 enum {
1645         /* P2P device */
1646         VDEV_SUBTYPE_P2PDEV = 0,
1647         /* P2P client */
1648         VDEV_SUBTYPE_P2PCLI,
1649         /* P2P GO */
1650         VDEV_SUBTYPE_P2PGO,
1651         /* BT3.0 HS */
1652         VDEV_SUBTYPE_BT,
1653 };
1654
1655 struct wmi_pdev_set_channel_cmd {
1656         /* idnore power , only use flags , mode and freq */
1657         struct wmi_channel chan;
1658 } __packed;
1659
1660 /* Customize the DSCP (bit) to TID (0-7) mapping for QOS */
1661 #define WMI_DSCP_MAP_MAX    (64)
1662 struct wmi_pdev_set_dscp_tid_map_cmd {
1663         /* map indicating DSCP to TID conversion */
1664         __le32 dscp_to_tid_map[WMI_DSCP_MAP_MAX];
1665 } __packed;
1666
1667 enum mcast_bcast_rate_id {
1668         WMI_SET_MCAST_RATE,
1669         WMI_SET_BCAST_RATE
1670 };
1671
1672 struct mcast_bcast_rate {
1673         enum mcast_bcast_rate_id rate_id;
1674         __le32 rate;
1675 } __packed;
1676
1677 struct wmi_wmm_params {
1678         __le32 cwmin;
1679         __le32 cwmax;
1680         __le32 aifs;
1681         __le32 txop;
1682         __le32 acm;
1683         __le32 no_ack;
1684 } __packed;
1685
1686 struct wmi_pdev_set_wmm_params {
1687         struct wmi_wmm_params ac_be;
1688         struct wmi_wmm_params ac_bk;
1689         struct wmi_wmm_params ac_vi;
1690         struct wmi_wmm_params ac_vo;
1691 } __packed;
1692
1693 struct wmi_wmm_params_arg {
1694         u32 cwmin;
1695         u32 cwmax;
1696         u32 aifs;
1697         u32 txop;
1698         u32 acm;
1699         u32 no_ack;
1700 };
1701
1702 struct wmi_pdev_set_wmm_params_arg {
1703         struct wmi_wmm_params_arg ac_be;
1704         struct wmi_wmm_params_arg ac_bk;
1705         struct wmi_wmm_params_arg ac_vi;
1706         struct wmi_wmm_params_arg ac_vo;
1707 };
1708
1709 struct wal_dbg_tx_stats {
1710         /* Num HTT cookies queued to dispatch list */
1711         __le32 comp_queued;
1712
1713         /* Num HTT cookies dispatched */
1714         __le32 comp_delivered;
1715
1716         /* Num MSDU queued to WAL */
1717         __le32 msdu_enqued;
1718
1719         /* Num MPDU queue to WAL */
1720         __le32 mpdu_enqued;
1721
1722         /* Num MSDUs dropped by WMM limit */
1723         __le32 wmm_drop;
1724
1725         /* Num Local frames queued */
1726         __le32 local_enqued;
1727
1728         /* Num Local frames done */
1729         __le32 local_freed;
1730
1731         /* Num queued to HW */
1732         __le32 hw_queued;
1733
1734         /* Num PPDU reaped from HW */
1735         __le32 hw_reaped;
1736
1737         /* Num underruns */
1738         __le32 underrun;
1739
1740         /* Num PPDUs cleaned up in TX abort */
1741         __le32 tx_abort;
1742
1743         /* Num MPDUs requed by SW */
1744         __le32 mpdus_requed;
1745
1746         /* excessive retries */
1747         __le32 tx_ko;
1748
1749         /* data hw rate code */
1750         __le32 data_rc;
1751
1752         /* Scheduler self triggers */
1753         __le32 self_triggers;
1754
1755         /* frames dropped due to excessive sw retries */
1756         __le32 sw_retry_failure;
1757
1758         /* illegal rate phy errors  */
1759         __le32 illgl_rate_phy_err;
1760
1761         /* wal pdev continous xretry */
1762         __le32 pdev_cont_xretry;
1763
1764         /* wal pdev continous xretry */
1765         __le32 pdev_tx_timeout;
1766
1767         /* wal pdev resets  */
1768         __le32 pdev_resets;
1769
1770         __le32 phy_underrun;
1771
1772         /* MPDU is more than txop limit */
1773         __le32 txop_ovf;
1774 } __packed;
1775
1776 struct wal_dbg_rx_stats {
1777         /* Cnts any change in ring routing mid-ppdu */
1778         __le32 mid_ppdu_route_change;
1779
1780         /* Total number of statuses processed */
1781         __le32 status_rcvd;
1782
1783         /* Extra frags on rings 0-3 */
1784         __le32 r0_frags;
1785         __le32 r1_frags;
1786         __le32 r2_frags;
1787         __le32 r3_frags;
1788
1789         /* MSDUs / MPDUs delivered to HTT */
1790         __le32 htt_msdus;
1791         __le32 htt_mpdus;
1792
1793         /* MSDUs / MPDUs delivered to local stack */
1794         __le32 loc_msdus;
1795         __le32 loc_mpdus;
1796
1797         /* AMSDUs that have more MSDUs than the status ring size */
1798         __le32 oversize_amsdu;
1799
1800         /* Number of PHY errors */
1801         __le32 phy_errs;
1802
1803         /* Number of PHY errors drops */
1804         __le32 phy_err_drop;
1805
1806         /* Number of mpdu errors - FCS, MIC, ENC etc. */
1807         __le32 mpdu_errs;
1808 } __packed;
1809
1810 struct wal_dbg_peer_stats {
1811         /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */
1812         __le32 dummy;
1813 } __packed;
1814
1815 struct wal_dbg_stats {
1816         struct wal_dbg_tx_stats tx;
1817         struct wal_dbg_rx_stats rx;
1818         struct wal_dbg_peer_stats peer;
1819 } __packed;
1820
1821 enum wmi_stats_id {
1822         WMI_REQUEST_PEER_STAT   = 0x01,
1823         WMI_REQUEST_AP_STAT     = 0x02
1824 };
1825
1826 struct wmi_request_stats_cmd {
1827         __le32 stats_id;
1828
1829         /*
1830          * Space to add parameters like
1831          * peer mac addr
1832          */
1833 } __packed;
1834
1835 /* Suspend option */
1836 enum {
1837         /* suspend */
1838         WMI_PDEV_SUSPEND,
1839
1840         /* suspend and disable all interrupts */
1841         WMI_PDEV_SUSPEND_AND_DISABLE_INTR,
1842 };
1843
1844 struct wmi_pdev_suspend_cmd {
1845         /* suspend option sent to target */
1846         __le32 suspend_opt;
1847 } __packed;
1848
1849 struct wmi_stats_event {
1850         __le32 stats_id; /* %WMI_REQUEST_ */
1851         /*
1852          * number of pdev stats event structures
1853          * (wmi_pdev_stats) 0 or 1
1854          */
1855         __le32 num_pdev_stats;
1856         /*
1857          * number of vdev stats event structures
1858          * (wmi_vdev_stats) 0 or max vdevs
1859          */
1860         __le32 num_vdev_stats;
1861         /*
1862          * number of peer stats event structures
1863          * (wmi_peer_stats) 0 or max peers
1864          */
1865         __le32 num_peer_stats;
1866         __le32 num_bcnflt_stats;
1867         /*
1868          * followed by
1869          *   num_pdev_stats * size of(struct wmi_pdev_stats)
1870          *   num_vdev_stats * size of(struct wmi_vdev_stats)
1871          *   num_peer_stats * size of(struct wmi_peer_stats)
1872          *
1873          *  By having a zero sized array, the pointer to data area
1874          *  becomes available without increasing the struct size
1875          */
1876         u8 data[0];
1877 } __packed;
1878
1879 /*
1880  * PDEV statistics
1881  * TODO: add all PDEV stats here
1882  */
1883 struct wmi_pdev_stats {
1884         __le32 chan_nf;        /* Channel noise floor */
1885         __le32 tx_frame_count; /* TX frame count */
1886         __le32 rx_frame_count; /* RX frame count */
1887         __le32 rx_clear_count; /* rx clear count */
1888         __le32 cycle_count;    /* cycle count */
1889         __le32 phy_err_count;  /* Phy error count */
1890         __le32 chan_tx_pwr;    /* channel tx power */
1891         struct wal_dbg_stats wal; /* WAL dbg stats */
1892 } __packed;
1893
1894 /*
1895  * VDEV statistics
1896  * TODO: add all VDEV stats here
1897  */
1898 struct wmi_vdev_stats {
1899         __le32 vdev_id;
1900 } __packed;
1901
1902 /*
1903  * peer statistics.
1904  * TODO: add more stats
1905  */
1906 struct wmi_peer_stats {
1907         struct wmi_mac_addr peer_macaddr;
1908         __le32 peer_rssi;
1909         __le32 peer_tx_rate;
1910 } __packed;
1911
1912 struct wmi_vdev_create_cmd {
1913         __le32 vdev_id;
1914         __le32 vdev_type;
1915         __le32 vdev_subtype;
1916         struct wmi_mac_addr vdev_macaddr;
1917 } __packed;
1918
1919 enum wmi_vdev_type {
1920         WMI_VDEV_TYPE_AP      = 1,
1921         WMI_VDEV_TYPE_STA     = 2,
1922         WMI_VDEV_TYPE_IBSS    = 3,
1923         WMI_VDEV_TYPE_MONITOR = 4,
1924 };
1925
1926 enum wmi_vdev_subtype {
1927         WMI_VDEV_SUBTYPE_NONE       = 0,
1928         WMI_VDEV_SUBTYPE_P2P_DEVICE = 1,
1929         WMI_VDEV_SUBTYPE_P2P_CLIENT = 2,
1930         WMI_VDEV_SUBTYPE_P2P_GO     = 3,
1931 };
1932
1933 /* values for vdev_subtype */
1934
1935 /* values for vdev_start_request flags */
1936 /*
1937  * Indicates that AP VDEV uses hidden ssid. only valid for
1938  *  AP/GO */
1939 #define WMI_VDEV_START_HIDDEN_SSID  (1<<0)
1940 /*
1941  * Indicates if robust management frame/management frame
1942  *  protection is enabled. For GO/AP vdevs, it indicates that
1943  *  it may support station/client associations with RMF enabled.
1944  *  For STA/client vdevs, it indicates that sta will
1945  *  associate with AP with RMF enabled. */
1946 #define WMI_VDEV_START_PMF_ENABLED  (1<<1)
1947
1948 struct wmi_p2p_noa_descriptor {
1949         __le32 type_count; /* 255: continuous schedule, 0: reserved */
1950         __le32 duration;  /* Absent period duration in micro seconds */
1951         __le32 interval;   /* Absent period interval in micro seconds */
1952         __le32 start_time; /* 32 bit tsf time when in starts */
1953 } __packed;
1954
1955 struct wmi_vdev_start_request_cmd {
1956         /* WMI channel */
1957         struct wmi_channel chan;
1958         /* unique id identifying the VDEV, generated by the caller */
1959         __le32 vdev_id;
1960         /* requestor id identifying the caller module */
1961         __le32 requestor_id;
1962         /* beacon interval from received beacon */
1963         __le32 beacon_interval;
1964         /* DTIM Period from the received beacon */
1965         __le32 dtim_period;
1966         /* Flags */
1967         __le32 flags;
1968         /* ssid field. Only valid for AP/GO/IBSS/BTAmp VDEV type. */
1969         struct wmi_ssid ssid;
1970         /* beacon/probe reponse xmit rate. Applicable for SoftAP. */
1971         __le32 bcn_tx_rate;
1972         /* beacon/probe reponse xmit power. Applicable for SoftAP. */
1973         __le32 bcn_tx_power;
1974         /* number of p2p NOA descriptor(s) from scan entry */
1975         __le32 num_noa_descriptors;
1976         /*
1977          * Disable H/W ack. This used by WMI_VDEV_RESTART_REQUEST_CMDID.
1978          * During CAC, Our HW shouldn't ack ditected frames
1979          */
1980         __le32 disable_hw_ack;
1981         /* actual p2p NOA descriptor from scan entry */
1982         struct wmi_p2p_noa_descriptor noa_descriptors[2];
1983 } __packed;
1984
1985 struct wmi_vdev_restart_request_cmd {
1986         struct wmi_vdev_start_request_cmd vdev_start_request_cmd;
1987 } __packed;
1988
1989 struct wmi_vdev_start_request_arg {
1990         u32 vdev_id;
1991         struct wmi_channel_arg channel;
1992         u32 bcn_intval;
1993         u32 dtim_period;
1994         u8 *ssid;
1995         u32 ssid_len;
1996         u32 bcn_tx_rate;
1997         u32 bcn_tx_power;
1998         bool disable_hw_ack;
1999         bool hidden_ssid;
2000         bool pmf_enabled;
2001 };
2002
2003 struct wmi_vdev_delete_cmd {
2004         /* unique id identifying the VDEV, generated by the caller */
2005         __le32 vdev_id;
2006 } __packed;
2007
2008 struct wmi_vdev_up_cmd {
2009         __le32 vdev_id;
2010         __le32 vdev_assoc_id;
2011         struct wmi_mac_addr vdev_bssid;
2012 } __packed;
2013
2014 struct wmi_vdev_stop_cmd {
2015         __le32 vdev_id;
2016 } __packed;
2017
2018 struct wmi_vdev_down_cmd {
2019         __le32 vdev_id;
2020 } __packed;
2021
2022 struct wmi_vdev_standby_response_cmd {
2023         /* unique id identifying the VDEV, generated by the caller */
2024         __le32 vdev_id;
2025 } __packed;
2026
2027 struct wmi_vdev_resume_response_cmd {
2028         /* unique id identifying the VDEV, generated by the caller */
2029         __le32 vdev_id;
2030 } __packed;
2031
2032 struct wmi_vdev_set_param_cmd {
2033         __le32 vdev_id;
2034         __le32 param_id;
2035         __le32 param_value;
2036 } __packed;
2037
2038 #define WMI_MAX_KEY_INDEX   3
2039 #define WMI_MAX_KEY_LEN     32
2040
2041 #define WMI_KEY_PAIRWISE 0x00
2042 #define WMI_KEY_GROUP    0x01
2043 #define WMI_KEY_TX_USAGE 0x02 /* default tx key - static wep */
2044
2045 struct wmi_key_seq_counter {
2046         __le32 key_seq_counter_l;
2047         __le32 key_seq_counter_h;
2048 } __packed;
2049
2050 #define WMI_CIPHER_NONE     0x0 /* clear key */
2051 #define WMI_CIPHER_WEP      0x1
2052 #define WMI_CIPHER_TKIP     0x2
2053 #define WMI_CIPHER_AES_OCB  0x3
2054 #define WMI_CIPHER_AES_CCM  0x4
2055 #define WMI_CIPHER_WAPI     0x5
2056 #define WMI_CIPHER_CKIP     0x6
2057 #define WMI_CIPHER_AES_CMAC 0x7
2058
2059 struct wmi_vdev_install_key_cmd {
2060         __le32 vdev_id;
2061         struct wmi_mac_addr peer_macaddr;
2062         __le32 key_idx;
2063         __le32 key_flags;
2064         __le32 key_cipher; /* %WMI_CIPHER_ */
2065         struct wmi_key_seq_counter key_rsc_counter;
2066         struct wmi_key_seq_counter key_global_rsc_counter;
2067         struct wmi_key_seq_counter key_tsc_counter;
2068         u8 wpi_key_rsc_counter[16];
2069         u8 wpi_key_tsc_counter[16];
2070         __le32 key_len;
2071         __le32 key_txmic_len;
2072         __le32 key_rxmic_len;
2073
2074         /* contains key followed by tx mic followed by rx mic */
2075         u8 key_data[0];
2076 } __packed;
2077
2078 struct wmi_vdev_install_key_arg {
2079         u32 vdev_id;
2080         const u8 *macaddr;
2081         u32 key_idx;
2082         u32 key_flags;
2083         u32 key_cipher;
2084         u32 key_len;
2085         u32 key_txmic_len;
2086         u32 key_rxmic_len;
2087         const void *key_data;
2088 };
2089
2090 /* Preamble types to be used with VDEV fixed rate configuration */
2091 enum wmi_rate_preamble {
2092         WMI_RATE_PREAMBLE_OFDM,
2093         WMI_RATE_PREAMBLE_CCK,
2094         WMI_RATE_PREAMBLE_HT,
2095         WMI_RATE_PREAMBLE_VHT,
2096 };
2097
2098 /* Value to disable fixed rate setting */
2099 #define WMI_FIXED_RATE_NONE    (0xff)
2100
2101 /* the definition of different VDEV parameters */
2102 enum wmi_vdev_param {
2103         /* RTS Threshold */
2104         WMI_VDEV_PARAM_RTS_THRESHOLD = 0x1,
2105         /* Fragmentation threshold */
2106         WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
2107         /* beacon interval in TUs */
2108         WMI_VDEV_PARAM_BEACON_INTERVAL,
2109         /* Listen interval in TUs */
2110         WMI_VDEV_PARAM_LISTEN_INTERVAL,
2111         /* muticast rate in Mbps */
2112         WMI_VDEV_PARAM_MULTICAST_RATE,
2113         /* management frame rate in Mbps */
2114         WMI_VDEV_PARAM_MGMT_TX_RATE,
2115         /* slot time (long vs short) */
2116         WMI_VDEV_PARAM_SLOT_TIME,
2117         /* preamble (long vs short) */
2118         WMI_VDEV_PARAM_PREAMBLE,
2119         /* SWBA time (time before tbtt in msec) */
2120         WMI_VDEV_PARAM_SWBA_TIME,
2121         /* time period for updating VDEV stats */
2122         WMI_VDEV_STATS_UPDATE_PERIOD,
2123         /* age out time in msec for frames queued for station in power save */
2124         WMI_VDEV_PWRSAVE_AGEOUT_TIME,
2125         /*
2126          * Host SWBA interval (time in msec before tbtt for SWBA event
2127          * generation).
2128          */
2129         WMI_VDEV_HOST_SWBA_INTERVAL,
2130         /* DTIM period (specified in units of num beacon intervals) */
2131         WMI_VDEV_PARAM_DTIM_PERIOD,
2132         /*
2133          * scheduler air time limit for this VDEV. used by off chan
2134          * scheduler.
2135          */
2136         WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
2137         /* enable/dsiable WDS for this VDEV  */
2138         WMI_VDEV_PARAM_WDS,
2139         /* ATIM Window */
2140         WMI_VDEV_PARAM_ATIM_WINDOW,
2141         /* BMISS max */
2142         WMI_VDEV_PARAM_BMISS_COUNT_MAX,
2143         /* BMISS first time */
2144         WMI_VDEV_PARAM_BMISS_FIRST_BCNT,
2145         /* BMISS final time */
2146         WMI_VDEV_PARAM_BMISS_FINAL_BCNT,
2147         /* WMM enables/disabled */
2148         WMI_VDEV_PARAM_FEATURE_WMM,
2149         /* Channel width */
2150         WMI_VDEV_PARAM_CHWIDTH,
2151         /* Channel Offset */
2152         WMI_VDEV_PARAM_CHEXTOFFSET,
2153         /* Disable HT Protection */
2154         WMI_VDEV_PARAM_DISABLE_HTPROTECTION,
2155         /* Quick STA Kickout */
2156         WMI_VDEV_PARAM_STA_QUICKKICKOUT,
2157         /* Rate to be used with Management frames */
2158         WMI_VDEV_PARAM_MGMT_RATE,
2159         /* Protection Mode */
2160         WMI_VDEV_PARAM_PROTECTION_MODE,
2161         /* Fixed rate setting */
2162         WMI_VDEV_PARAM_FIXED_RATE,
2163         /* Short GI Enable/Disable */
2164         WMI_VDEV_PARAM_SGI,
2165         /* Enable LDPC */
2166         WMI_VDEV_PARAM_LDPC,
2167         /* Enable Tx STBC */
2168         WMI_VDEV_PARAM_TX_STBC,
2169         /* Enable Rx STBC */
2170         WMI_VDEV_PARAM_RX_STBC,
2171         /* Intra BSS forwarding  */
2172         WMI_VDEV_PARAM_INTRA_BSS_FWD,
2173         /* Setting Default xmit key for Vdev */
2174         WMI_VDEV_PARAM_DEF_KEYID,
2175         /* NSS width */
2176         WMI_VDEV_PARAM_NSS,
2177         /* Set the custom rate for the broadcast data frames */
2178         WMI_VDEV_PARAM_BCAST_DATA_RATE,
2179         /* Set the custom rate (rate-code) for multicast data frames */
2180         WMI_VDEV_PARAM_MCAST_DATA_RATE,
2181         /* Tx multicast packet indicate Enable/Disable */
2182         WMI_VDEV_PARAM_MCAST_INDICATE,
2183         /* Tx DHCP packet indicate Enable/Disable */
2184         WMI_VDEV_PARAM_DHCP_INDICATE,
2185         /* Enable host inspection of Tx unicast packet to unknown destination */
2186         WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
2187
2188         /* The minimum amount of time AP begins to consider STA inactive */
2189         WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
2190
2191         /*
2192          * An associated STA is considered inactive when there is no recent
2193          * TX/RX activity and no downlink frames are buffered for it. Once a
2194          * STA exceeds the maximum idle inactive time, the AP will send an
2195          * 802.11 data-null as a keep alive to verify the STA is still
2196          * associated. If the STA does ACK the data-null, or if the data-null
2197          * is buffered and the STA does not retrieve it, the STA will be
2198          * considered unresponsive
2199          * (see WMI_VDEV_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS).
2200          */
2201         WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
2202
2203         /*
2204          * An associated STA is considered unresponsive if there is no recent
2205          * TX/RX activity and downlink frames are buffered for it. Once a STA
2206          * exceeds the maximum unresponsive time, the AP will send a
2207          * WMI_STA_KICKOUT event to the host so the STA can be deleted. */
2208         WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
2209
2210         /* Enable NAWDS : MCAST INSPECT Enable, NAWDS Flag set */
2211         WMI_VDEV_PARAM_AP_ENABLE_NAWDS,
2212         /* Enable/Disable RTS-CTS */
2213         WMI_VDEV_PARAM_ENABLE_RTSCTS,
2214         /* Enable TXBFee/er */
2215         WMI_VDEV_PARAM_TXBF,
2216
2217         /* Set packet power save */
2218         WMI_VDEV_PARAM_PACKET_POWERSAVE,
2219
2220         /*
2221          * Drops un-encrypted packets if eceived in an encrypted connection
2222          * otherwise forwards to host.
2223          */
2224         WMI_VDEV_PARAM_DROP_UNENCRY,
2225
2226         /*
2227          * Set the encapsulation type for frames.
2228          */
2229         WMI_VDEV_PARAM_TX_ENCAP_TYPE,
2230 };
2231
2232 /* slot time long */
2233 #define WMI_VDEV_SLOT_TIME_LONG         0x1
2234 /* slot time short */
2235 #define WMI_VDEV_SLOT_TIME_SHORT        0x2
2236 /* preablbe long */
2237 #define WMI_VDEV_PREAMBLE_LONG          0x1
2238 /* preablbe short */
2239 #define WMI_VDEV_PREAMBLE_SHORT         0x2
2240
2241 enum wmi_start_event_param {
2242         WMI_VDEV_RESP_START_EVENT = 0,
2243         WMI_VDEV_RESP_RESTART_EVENT,
2244 };
2245
2246 struct wmi_vdev_start_response_event {
2247         __le32 vdev_id;
2248         __le32 req_id;
2249         __le32 resp_type; /* %WMI_VDEV_RESP_ */
2250         __le32 status;
2251 } __packed;
2252
2253 struct wmi_vdev_standby_req_event {
2254         /* unique id identifying the VDEV, generated by the caller */
2255         __le32 vdev_id;
2256 } __packed;
2257
2258 struct wmi_vdev_resume_req_event {
2259         /* unique id identifying the VDEV, generated by the caller */
2260         __le32 vdev_id;
2261 } __packed;
2262
2263 struct wmi_vdev_stopped_event {
2264         /* unique id identifying the VDEV, generated by the caller */
2265         __le32 vdev_id;
2266 } __packed;
2267
2268 /*
2269  * common structure used for simple events
2270  * (stopped, resume_req, standby response)
2271  */
2272 struct wmi_vdev_simple_event {
2273         /* unique id identifying the VDEV, generated by the caller */
2274         __le32 vdev_id;
2275 } __packed;
2276
2277 /* VDEV start response status codes */
2278 /* VDEV succesfully started */
2279 #define WMI_INIFIED_VDEV_START_RESPONSE_STATUS_SUCCESS  0x0
2280
2281 /* requested VDEV not found */
2282 #define WMI_INIFIED_VDEV_START_RESPONSE_INVALID_VDEVID  0x1
2283
2284 /* unsupported VDEV combination */
2285 #define WMI_INIFIED_VDEV_START_RESPONSE_NOT_SUPPORTED   0x2
2286
2287 /* Beacon processing related command and event structures */
2288 struct wmi_bcn_tx_hdr {
2289         __le32 vdev_id;
2290         __le32 tx_rate;
2291         __le32 tx_power;
2292         __le32 bcn_len;
2293 } __packed;
2294
2295 struct wmi_bcn_tx_cmd {
2296         struct wmi_bcn_tx_hdr hdr;
2297         u8 *bcn[0];
2298 } __packed;
2299
2300 struct wmi_bcn_tx_arg {
2301         u32 vdev_id;
2302         u32 tx_rate;
2303         u32 tx_power;
2304         u32 bcn_len;
2305         const void *bcn;
2306 };
2307
2308 /* Beacon filter */
2309 #define WMI_BCN_FILTER_ALL   0 /* Filter all beacons */
2310 #define WMI_BCN_FILTER_NONE  1 /* Pass all beacons */
2311 #define WMI_BCN_FILTER_RSSI  2 /* Pass Beacons RSSI >= RSSI threshold */
2312 #define WMI_BCN_FILTER_BSSID 3 /* Pass Beacons with matching BSSID */
2313 #define WMI_BCN_FILTER_SSID  4 /* Pass Beacons with matching SSID */
2314
2315 struct wmi_bcn_filter_rx_cmd {
2316         /* Filter ID */
2317         __le32 bcn_filter_id;
2318         /* Filter type - wmi_bcn_filter */
2319         __le32 bcn_filter;
2320         /* Buffer len */
2321         __le32 bcn_filter_len;
2322         /* Filter info (threshold, BSSID, RSSI) */
2323         u8 *bcn_filter_buf;
2324 } __packed;
2325
2326 /* Capabilities and IEs to be passed to firmware */
2327 struct wmi_bcn_prb_info {
2328         /* Capabilities */
2329         __le32 caps;
2330         /* ERP info */
2331         __le32 erp;
2332         /* Advanced capabilities */
2333         /* HT capabilities */
2334         /* HT Info */
2335         /* ibss_dfs */
2336         /* wpa Info */
2337         /* rsn Info */
2338         /* rrm info */
2339         /* ath_ext */
2340         /* app IE */
2341 } __packed;
2342
2343 struct wmi_bcn_tmpl_cmd {
2344         /* unique id identifying the VDEV, generated by the caller */
2345         __le32 vdev_id;
2346         /* TIM IE offset from the beginning of the template. */
2347         __le32 tim_ie_offset;
2348         /* beacon probe capabilities and IEs */
2349         struct wmi_bcn_prb_info bcn_prb_info;
2350         /* beacon buffer length */
2351         __le32 buf_len;
2352         /* variable length data */
2353         u8 data[1];
2354 } __packed;
2355
2356 struct wmi_prb_tmpl_cmd {
2357         /* unique id identifying the VDEV, generated by the caller */
2358         __le32 vdev_id;
2359         /* beacon probe capabilities and IEs */
2360         struct wmi_bcn_prb_info bcn_prb_info;
2361         /* beacon buffer length */
2362         __le32 buf_len;
2363         /* Variable length data */
2364         u8 data[1];
2365 } __packed;
2366
2367 enum wmi_sta_ps_mode {
2368         /* enable power save for the given STA VDEV */
2369         WMI_STA_PS_MODE_DISABLED = 0,
2370         /* disable power save  for a given STA VDEV */
2371         WMI_STA_PS_MODE_ENABLED = 1,
2372 };
2373
2374 struct wmi_sta_powersave_mode_cmd {
2375         /* unique id identifying the VDEV, generated by the caller */
2376         __le32 vdev_id;
2377
2378         /*
2379          * Power save mode
2380          * (see enum wmi_sta_ps_mode)
2381          */
2382         __le32 sta_ps_mode;
2383 } __packed;
2384
2385 enum wmi_csa_offload_en {
2386         WMI_CSA_OFFLOAD_DISABLE = 0,
2387         WMI_CSA_OFFLOAD_ENABLE = 1,
2388 };
2389
2390 struct wmi_csa_offload_enable_cmd {
2391         __le32 vdev_id;
2392         __le32 csa_offload_enable;
2393 } __packed;
2394
2395 struct wmi_csa_offload_chanswitch_cmd {
2396         __le32 vdev_id;
2397         struct wmi_channel chan;
2398 } __packed;
2399
2400 /*
2401  * This parameter controls the policy for retrieving frames from AP while the
2402  * STA is in sleep state.
2403  *
2404  * Only takes affect if the sta_ps_mode is enabled
2405  */
2406 enum wmi_sta_ps_param_rx_wake_policy {
2407         /*
2408          * Wake up when ever there is an  RX activity on the VDEV. In this mode
2409          * the Power save SM(state machine) will come out of sleep by either
2410          * sending null frame (or) a data frame (with PS==0) in response to TIM
2411          * bit set in the received beacon frame from AP.
2412          */
2413         WMI_STA_PS_RX_WAKE_POLICY_WAKE = 0,
2414
2415         /*
2416          * Here the power save state machine will not wakeup in response to TIM
2417          * bit, instead it will send a PSPOLL (or) UASPD trigger based on UAPSD
2418          * configuration setup by WMISET_PS_SET_UAPSD  WMI command.  When all
2419          * access categories are delivery-enabled, the station will send a
2420          * UAPSD trigger frame, otherwise it will send a PS-Poll.
2421          */
2422         WMI_STA_PS_RX_WAKE_POLICY_POLL_UAPSD = 1,
2423 };
2424
2425 /*
2426  * Number of tx frames/beacon  that cause the power save SM to wake up.
2427  *
2428  * Value 1 causes the SM to wake up for every TX. Value 0 has a special
2429  * meaning, It will cause the SM to never wake up. This is useful if you want
2430  * to keep the system to sleep all the time for some kind of test mode . host
2431  * can change this parameter any time.  It will affect at the next tx frame.
2432  */
2433 enum wmi_sta_ps_param_tx_wake_threshold {
2434         WMI_STA_PS_TX_WAKE_THRESHOLD_NEVER = 0,
2435         WMI_STA_PS_TX_WAKE_THRESHOLD_ALWAYS = 1,
2436
2437         /*
2438          * Values greater than one indicate that many TX attempts per beacon
2439          * interval before the STA will wake up
2440          */
2441 };
2442
2443 /*
2444  * The maximum number of PS-Poll frames the FW will send in response to
2445  * traffic advertised in TIM before waking up (by sending a null frame with PS
2446  * = 0). Value 0 has a special meaning: there is no maximum count and the FW
2447  * will send as many PS-Poll as are necessary to retrieve buffered BU. This
2448  * parameter is used when the RX wake policy is
2449  * WMI_STA_PS_RX_WAKE_POLICY_POLL_UAPSD and ignored when the RX wake
2450  * policy is WMI_STA_PS_RX_WAKE_POLICY_WAKE.
2451  */
2452 enum wmi_sta_ps_param_pspoll_count {
2453         WMI_STA_PS_PSPOLL_COUNT_NO_MAX = 0,
2454         /*
2455          * Values greater than 0 indicate the maximum numer of PS-Poll frames
2456          * FW will send before waking up.
2457          */
2458 };
2459
2460 /*
2461  * This will include the delivery and trigger enabled state for every AC.
2462  * This is the negotiated state with AP. The host MLME needs to set this based
2463  * on AP capability and the state Set in the association request by the
2464  * station MLME.Lower 8 bits of the value specify the UAPSD configuration.
2465  */
2466 #define WMI_UAPSD_AC_TYPE_DELI 0
2467 #define WMI_UAPSD_AC_TYPE_TRIG 1
2468
2469 #define WMI_UAPSD_AC_BIT_MASK(ac, type) \
2470         ((type ==  WMI_UAPSD_AC_TYPE_DELI) ? (1<<(ac<<1)) : (1<<((ac<<1)+1)))
2471
2472 enum wmi_sta_ps_param_uapsd {
2473         WMI_STA_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0),
2474         WMI_STA_PS_UAPSD_AC0_TRIGGER_EN  = (1 << 1),
2475         WMI_STA_PS_UAPSD_AC1_DELIVERY_EN = (1 << 2),
2476         WMI_STA_PS_UAPSD_AC1_TRIGGER_EN  = (1 << 3),
2477         WMI_STA_PS_UAPSD_AC2_DELIVERY_EN = (1 << 4),
2478         WMI_STA_PS_UAPSD_AC2_TRIGGER_EN  = (1 << 5),
2479         WMI_STA_PS_UAPSD_AC3_DELIVERY_EN = (1 << 6),
2480         WMI_STA_PS_UAPSD_AC3_TRIGGER_EN  = (1 << 7),
2481 };
2482
2483 enum wmi_sta_powersave_param {
2484         /*
2485          * Controls how frames are retrievd from AP while STA is sleeping
2486          *
2487          * (see enum wmi_sta_ps_param_rx_wake_policy)
2488          */
2489         WMI_STA_PS_PARAM_RX_WAKE_POLICY = 0,
2490
2491         /*
2492          * The STA will go active after this many TX
2493          *
2494          * (see enum wmi_sta_ps_param_tx_wake_threshold)
2495          */
2496         WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD = 1,
2497
2498         /*
2499          * Number of PS-Poll to send before STA wakes up
2500          *
2501          * (see enum wmi_sta_ps_param_pspoll_count)
2502          *
2503          */
2504         WMI_STA_PS_PARAM_PSPOLL_COUNT = 2,
2505
2506         /*
2507          * TX/RX inactivity time in msec before going to sleep.
2508          *
2509          * The power save SM will monitor tx/rx activity on the VDEV, if no
2510          * activity for the specified msec of the parameter the Power save
2511          * SM will go to sleep.
2512          */
2513         WMI_STA_PS_PARAM_INACTIVITY_TIME = 3,
2514
2515         /*
2516          * Set uapsd configuration.
2517          *
2518          * (see enum wmi_sta_ps_param_uapsd)
2519          */
2520         WMI_STA_PS_PARAM_UAPSD = 4,
2521 };
2522
2523 struct wmi_sta_powersave_param_cmd {
2524         __le32 vdev_id;
2525         __le32 param_id; /* %WMI_STA_PS_PARAM_ */
2526         __le32 param_value;
2527 } __packed;
2528
2529 /* No MIMO power save */
2530 #define WMI_STA_MIMO_PS_MODE_DISABLE
2531 /* mimo powersave mode static*/
2532 #define WMI_STA_MIMO_PS_MODE_STATIC
2533 /* mimo powersave mode dynamic */
2534 #define WMI_STA_MIMO_PS_MODE_DYNAMIC
2535
2536 struct wmi_sta_mimo_ps_mode_cmd {
2537         /* unique id identifying the VDEV, generated by the caller */
2538         __le32 vdev_id;
2539         /* mimo powersave mode as defined above */
2540         __le32 mimo_pwrsave_mode;
2541 } __packed;
2542
2543 /* U-APSD configuration of peer station from (re)assoc request and TSPECs */
2544 enum wmi_ap_ps_param_uapsd {
2545         WMI_AP_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0),
2546         WMI_AP_PS_UAPSD_AC0_TRIGGER_EN  = (1 << 1),
2547         WMI_AP_PS_UAPSD_AC1_DELIVERY_EN = (1 << 2),
2548         WMI_AP_PS_UAPSD_AC1_TRIGGER_EN  = (1 << 3),
2549         WMI_AP_PS_UAPSD_AC2_DELIVERY_EN = (1 << 4),
2550         WMI_AP_PS_UAPSD_AC2_TRIGGER_EN  = (1 << 5),
2551         WMI_AP_PS_UAPSD_AC3_DELIVERY_EN = (1 << 6),
2552         WMI_AP_PS_UAPSD_AC3_TRIGGER_EN  = (1 << 7),
2553 };
2554
2555 /* U-APSD maximum service period of peer station */
2556 enum wmi_ap_ps_peer_param_max_sp {
2557         WMI_AP_PS_PEER_PARAM_MAX_SP_UNLIMITED = 0,
2558         WMI_AP_PS_PEER_PARAM_MAX_SP_2 = 1,
2559         WMI_AP_PS_PEER_PARAM_MAX_SP_4 = 2,
2560         WMI_AP_PS_PEER_PARAM_MAX_SP_6 = 3,
2561         MAX_WMI_AP_PS_PEER_PARAM_MAX_SP,
2562 };
2563
2564 /*
2565  * AP power save parameter
2566  * Set a power save specific parameter for a peer station
2567  */
2568 enum wmi_ap_ps_peer_param {
2569         /* Set uapsd configuration for a given peer.
2570          *
2571          * Include the delivery and trigger enabled state for every AC.
2572          * The host  MLME needs to set this based on AP capability and stations
2573          * request Set in the association request  received from the station.
2574          *
2575          * Lower 8 bits of the value specify the UAPSD configuration.
2576          *
2577          * (see enum wmi_ap_ps_param_uapsd)
2578          * The default value is 0.
2579          */
2580         WMI_AP_PS_PEER_PARAM_UAPSD = 0,
2581
2582         /*
2583          * Set the service period for a UAPSD capable station
2584          *
2585          * The service period from wme ie in the (re)assoc request frame.
2586          *
2587          * (see enum wmi_ap_ps_peer_param_max_sp)
2588          */
2589         WMI_AP_PS_PEER_PARAM_MAX_SP = 1,
2590
2591         /* Time in seconds for aging out buffered frames for STA in PS */
2592         WMI_AP_PS_PEER_PARAM_AGEOUT_TIME = 2,
2593 };
2594
2595 struct wmi_ap_ps_peer_cmd {
2596         /* unique id identifying the VDEV, generated by the caller */
2597         __le32 vdev_id;
2598
2599         /* peer MAC address */
2600         struct wmi_mac_addr peer_macaddr;
2601
2602         /* AP powersave param (see enum wmi_ap_ps_peer_param) */
2603         __le32 param_id;
2604
2605         /* AP powersave param value */
2606         __le32 param_value;
2607 } __packed;
2608
2609 /* 128 clients = 4 words */
2610 #define WMI_TIM_BITMAP_ARRAY_SIZE 4
2611
2612 struct wmi_tim_info {
2613         __le32 tim_len;
2614         __le32 tim_mcast;
2615         __le32 tim_bitmap[WMI_TIM_BITMAP_ARRAY_SIZE];
2616         __le32 tim_changed;
2617         __le32 tim_num_ps_pending;
2618 } __packed;
2619
2620 /* Maximum number of NOA Descriptors supported */
2621 #define WMI_P2P_MAX_NOA_DESCRIPTORS 4
2622 #define WMI_P2P_OPPPS_ENABLE_BIT        BIT(0)
2623 #define WMI_P2P_OPPPS_CTWINDOW_OFFSET   1
2624 #define WMI_P2P_NOA_CHANGED_BIT BIT(0)
2625
2626 struct wmi_p2p_noa_info {
2627         /* Bit 0 - Flag to indicate an update in NOA schedule
2628            Bits 7-1 - Reserved */
2629         u8 changed;
2630         /* NOA index */
2631         u8 index;
2632         /* Bit 0 - Opp PS state of the AP
2633            Bits 1-7 - Ctwindow in TUs */
2634         u8 ctwindow_oppps;
2635         /* Number of NOA descriptors */
2636         u8 num_descriptors;
2637
2638         struct wmi_p2p_noa_descriptor descriptors[WMI_P2P_MAX_NOA_DESCRIPTORS];
2639 } __packed;
2640
2641 struct wmi_bcn_info {
2642         struct wmi_tim_info tim_info;
2643         struct wmi_p2p_noa_info p2p_noa_info;
2644 } __packed;
2645
2646 struct wmi_host_swba_event {
2647         __le32 vdev_map;
2648         struct wmi_bcn_info bcn_info[1];
2649 } __packed;
2650
2651 #define WMI_MAX_AP_VDEV 16
2652
2653 struct wmi_tbtt_offset_event {
2654         __le32 vdev_map;
2655         __le32 tbttoffset_list[WMI_MAX_AP_VDEV];
2656 } __packed;
2657
2658
2659 struct wmi_peer_create_cmd {
2660         __le32 vdev_id;
2661         struct wmi_mac_addr peer_macaddr;
2662 } __packed;
2663
2664 struct wmi_peer_delete_cmd {
2665         __le32 vdev_id;
2666         struct wmi_mac_addr peer_macaddr;
2667 } __packed;
2668
2669 struct wmi_peer_flush_tids_cmd {
2670         __le32 vdev_id;
2671         struct wmi_mac_addr peer_macaddr;
2672         __le32 peer_tid_bitmap;
2673 } __packed;
2674
2675 struct wmi_fixed_rate {
2676         /*
2677          * rate mode . 0: disable fixed rate (auto rate)
2678          *   1: legacy (non 11n) rate  specified as ieee rate 2*Mbps
2679          *   2: ht20 11n rate  specified as mcs index
2680          *   3: ht40 11n rate  specified as mcs index
2681          */
2682         __le32  rate_mode;
2683         /*
2684          * 4 rate values for 4 rate series. series 0 is stored in byte 0 (LSB)
2685          * and series 3 is stored at byte 3 (MSB)
2686          */
2687         __le32  rate_series;
2688         /*
2689          * 4 retry counts for 4 rate series. retry count for rate 0 is stored
2690          * in byte 0 (LSB) and retry count for rate 3 is stored at byte 3
2691          * (MSB)
2692          */
2693         __le32  rate_retries;
2694 } __packed;
2695
2696 struct wmi_peer_fixed_rate_cmd {
2697         /* unique id identifying the VDEV, generated by the caller */
2698         __le32 vdev_id;
2699         /* peer MAC address */
2700         struct wmi_mac_addr peer_macaddr;
2701         /* fixed rate */
2702         struct wmi_fixed_rate peer_fixed_rate;
2703 } __packed;
2704
2705 #define WMI_MGMT_TID    17
2706
2707 struct wmi_addba_clear_resp_cmd {
2708         /* unique id identifying the VDEV, generated by the caller */
2709         __le32 vdev_id;
2710         /* peer MAC address */
2711         struct wmi_mac_addr peer_macaddr;
2712 } __packed;
2713
2714 struct wmi_addba_send_cmd {
2715         /* unique id identifying the VDEV, generated by the caller */
2716         __le32 vdev_id;
2717         /* peer MAC address */
2718         struct wmi_mac_addr peer_macaddr;
2719         /* Tid number */
2720         __le32 tid;
2721         /* Buffer/Window size*/
2722         __le32 buffersize;
2723 } __packed;
2724
2725 struct wmi_delba_send_cmd {
2726         /* unique id identifying the VDEV, generated by the caller */
2727         __le32 vdev_id;
2728         /* peer MAC address */
2729         struct wmi_mac_addr peer_macaddr;
2730         /* Tid number */
2731         __le32 tid;
2732         /* Is Initiator */
2733         __le32 initiator;
2734         /* Reason code */
2735         __le32 reasoncode;
2736 } __packed;
2737
2738 struct wmi_addba_setresponse_cmd {
2739         /* unique id identifying the vdev, generated by the caller */
2740         __le32 vdev_id;
2741         /* peer mac address */
2742         struct wmi_mac_addr peer_macaddr;
2743         /* Tid number */
2744         __le32 tid;
2745         /* status code */
2746         __le32 statuscode;
2747 } __packed;
2748
2749 struct wmi_send_singleamsdu_cmd {
2750         /* unique id identifying the vdev, generated by the caller */
2751         __le32 vdev_id;
2752         /* peer mac address */
2753         struct wmi_mac_addr peer_macaddr;
2754         /* Tid number */
2755         __le32 tid;
2756 } __packed;
2757
2758 enum wmi_peer_smps_state {
2759         WMI_PEER_SMPS_PS_NONE = 0x0,
2760         WMI_PEER_SMPS_STATIC  = 0x1,
2761         WMI_PEER_SMPS_DYNAMIC = 0x2
2762 };
2763
2764 enum wmi_peer_param {
2765         WMI_PEER_SMPS_STATE = 0x1, /* see %wmi_peer_smps_state */
2766         WMI_PEER_AMPDU      = 0x2,
2767         WMI_PEER_AUTHORIZE  = 0x3,
2768         WMI_PEER_CHAN_WIDTH = 0x4,
2769         WMI_PEER_NSS        = 0x5,
2770         WMI_PEER_USE_4ADDR  = 0x6
2771 };
2772
2773 struct wmi_peer_set_param_cmd {
2774         __le32 vdev_id;
2775         struct wmi_mac_addr peer_macaddr;
2776         __le32 param_id;
2777         __le32 param_value;
2778 } __packed;
2779
2780 #define MAX_SUPPORTED_RATES 128
2781
2782 struct wmi_rate_set {
2783         /* total number of rates */
2784         __le32 num_rates;
2785         /*
2786          * rates (each 8bit value) packed into a 32 bit word.
2787          * the rates are filled from least significant byte to most
2788          * significant byte.
2789          */
2790         __le32 rates[(MAX_SUPPORTED_RATES/4)+1];
2791 } __packed;
2792
2793 struct wmi_rate_set_arg {
2794         unsigned int num_rates;
2795         u8 rates[MAX_SUPPORTED_RATES];
2796 };
2797
2798 /*
2799  * NOTE: It would bea good idea to represent the Tx MCS
2800  * info in one word and Rx in another word. This is split
2801  * into multiple words for convenience
2802  */
2803 struct wmi_vht_rate_set {
2804         __le32 rx_max_rate; /* Max Rx data rate */
2805         __le32 rx_mcs_set;  /* Negotiated RX VHT rates */
2806         __le32 tx_max_rate; /* Max Tx data rate */
2807         __le32 tx_mcs_set;  /* Negotiated TX VHT rates */
2808 } __packed;
2809
2810 struct wmi_vht_rate_set_arg {
2811         u32 rx_max_rate;
2812         u32 rx_mcs_set;
2813         u32 tx_max_rate;
2814         u32 tx_mcs_set;
2815 };
2816
2817 struct wmi_peer_set_rates_cmd {
2818         /* peer MAC address */
2819         struct wmi_mac_addr peer_macaddr;
2820         /* legacy rate set */
2821         struct wmi_rate_set peer_legacy_rates;
2822         /* ht rate set */
2823         struct wmi_rate_set peer_ht_rates;
2824 } __packed;
2825
2826 struct wmi_peer_set_q_empty_callback_cmd {
2827         /* unique id identifying the VDEV, generated by the caller */
2828         __le32 vdev_id;
2829         /* peer MAC address */
2830         struct wmi_mac_addr peer_macaddr;
2831         __le32 callback_enable;
2832 } __packed;
2833
2834 #define WMI_PEER_AUTH           0x00000001
2835 #define WMI_PEER_QOS            0x00000002
2836 #define WMI_PEER_NEED_PTK_4_WAY 0x00000004
2837 #define WMI_PEER_NEED_GTK_2_WAY 0x00000010
2838 #define WMI_PEER_APSD           0x00000800
2839 #define WMI_PEER_HT             0x00001000
2840 #define WMI_PEER_40MHZ          0x00002000
2841 #define WMI_PEER_STBC           0x00008000
2842 #define WMI_PEER_LDPC           0x00010000
2843 #define WMI_PEER_DYN_MIMOPS     0x00020000
2844 #define WMI_PEER_STATIC_MIMOPS  0x00040000
2845 #define WMI_PEER_SPATIAL_MUX    0x00200000
2846 #define WMI_PEER_VHT            0x02000000
2847 #define WMI_PEER_80MHZ          0x04000000
2848 #define WMI_PEER_PMF            0x08000000
2849
2850 /*
2851  * Peer rate capabilities.
2852  *
2853  * This is of interest to the ratecontrol
2854  * module which resides in the firmware. The bit definitions are
2855  * consistent with that defined in if_athrate.c.
2856  */
2857 #define WMI_RC_DS_FLAG          0x01
2858 #define WMI_RC_CW40_FLAG        0x02
2859 #define WMI_RC_SGI_FLAG         0x04
2860 #define WMI_RC_HT_FLAG          0x08
2861 #define WMI_RC_RTSCTS_FLAG      0x10
2862 #define WMI_RC_TX_STBC_FLAG     0x20
2863 #define WMI_RC_RX_STBC_FLAG     0xC0
2864 #define WMI_RC_RX_STBC_FLAG_S   6
2865 #define WMI_RC_WEP_TKIP_FLAG    0x100
2866 #define WMI_RC_TS_FLAG          0x200
2867 #define WMI_RC_UAPSD_FLAG       0x400
2868
2869 /* Maximum listen interval supported by hw in units of beacon interval */
2870 #define ATH10K_MAX_HW_LISTEN_INTERVAL 5
2871
2872 struct wmi_peer_assoc_complete_cmd {
2873         struct wmi_mac_addr peer_macaddr;
2874         __le32 vdev_id;
2875         __le32 peer_new_assoc; /* 1=assoc, 0=reassoc */
2876         __le32 peer_associd; /* 16 LSBs */
2877         __le32 peer_flags;
2878         __le32 peer_caps; /* 16 LSBs */
2879         __le32 peer_listen_intval;
2880         __le32 peer_ht_caps;
2881         __le32 peer_max_mpdu;
2882         __le32 peer_mpdu_density; /* 0..16 */
2883         __le32 peer_rate_caps;
2884         struct wmi_rate_set peer_legacy_rates;
2885         struct wmi_rate_set peer_ht_rates;
2886         __le32 peer_nss; /* num of spatial streams */
2887         __le32 peer_vht_caps;
2888         __le32 peer_phymode;
2889         struct wmi_vht_rate_set peer_vht_rates;
2890         /* HT Operation Element of the peer. Five bytes packed in 2
2891          *  INT32 array and filled from lsb to msb. */
2892         __le32 peer_ht_info[2];
2893 } __packed;
2894
2895 struct wmi_peer_assoc_complete_arg {
2896         u8 addr[ETH_ALEN];
2897         u32 vdev_id;
2898         bool peer_reassoc;
2899         u16 peer_aid;
2900         u32 peer_flags; /* see %WMI_PEER_ */
2901         u16 peer_caps;
2902         u32 peer_listen_intval;
2903         u32 peer_ht_caps;
2904         u32 peer_max_mpdu;
2905         u32 peer_mpdu_density; /* 0..16 */
2906         u32 peer_rate_caps; /* see %WMI_RC_ */
2907         struct wmi_rate_set_arg peer_legacy_rates;
2908         struct wmi_rate_set_arg peer_ht_rates;
2909         u32 peer_num_spatial_streams;
2910         u32 peer_vht_caps;
2911         enum wmi_phy_mode peer_phymode;
2912         struct wmi_vht_rate_set_arg peer_vht_rates;
2913 };
2914
2915 struct wmi_peer_add_wds_entry_cmd {
2916         /* peer MAC address */
2917         struct wmi_mac_addr peer_macaddr;
2918         /* wds MAC addr */
2919         struct wmi_mac_addr wds_macaddr;
2920 } __packed;
2921
2922 struct wmi_peer_remove_wds_entry_cmd {
2923         /* wds MAC addr */
2924         struct wmi_mac_addr wds_macaddr;
2925 } __packed;
2926
2927 struct wmi_peer_q_empty_callback_event {
2928         /* peer MAC address */
2929         struct wmi_mac_addr peer_macaddr;
2930 } __packed;
2931
2932 /*
2933  * Channel info WMI event
2934  */
2935 struct wmi_chan_info_event {
2936         __le32 err_code;
2937         __le32 freq;
2938         __le32 cmd_flags;
2939         __le32 noise_floor;
2940         __le32 rx_clear_count;
2941         __le32 cycle_count;
2942 } __packed;
2943
2944 #define WMI_CHAN_INFO_FLAG_COMPLETE BIT(0)
2945
2946 /* FIXME: empirically extrapolated */
2947 #define WMI_CHAN_INFO_MSEC(x) ((x) / 76595)
2948
2949 /* Beacon filter wmi command info */
2950 #define BCN_FLT_MAX_SUPPORTED_IES       256
2951 #define BCN_FLT_MAX_ELEMS_IE_LIST       (BCN_FLT_MAX_SUPPORTED_IES / 32)
2952
2953 struct bss_bcn_stats {
2954         __le32 vdev_id;
2955         __le32 bss_bcnsdropped;
2956         __le32 bss_bcnsdelivered;
2957 } __packed;
2958
2959 struct bcn_filter_stats {
2960         __le32 bcns_dropped;
2961         __le32 bcns_delivered;
2962         __le32 activefilters;
2963         struct bss_bcn_stats bss_stats;
2964 } __packed;
2965
2966 struct wmi_add_bcn_filter_cmd {
2967         u32 vdev_id;
2968         u32 ie_map[BCN_FLT_MAX_ELEMS_IE_LIST];
2969 } __packed;
2970
2971 enum wmi_sta_keepalive_method {
2972         WMI_STA_KEEPALIVE_METHOD_NULL_FRAME = 1,
2973         WMI_STA_KEEPALIVE_METHOD_UNSOLICITATED_ARP_RESPONSE = 2,
2974 };
2975
2976 /* note: ip4 addresses are in network byte order, i.e. big endian */
2977 struct wmi_sta_keepalive_arp_resp {
2978         __be32 src_ip4_addr;
2979         __be32 dest_ip4_addr;
2980         struct wmi_mac_addr dest_mac_addr;
2981 } __packed;
2982
2983 struct wmi_sta_keepalive_cmd {
2984         __le32 vdev_id;
2985         __le32 enabled;
2986         __le32 method; /* WMI_STA_KEEPALIVE_METHOD_ */
2987         __le32 interval; /* in seconds */
2988         struct wmi_sta_keepalive_arp_resp arp_resp;
2989 } __packed;
2990
2991 enum wmi_force_fw_hang_type {
2992         WMI_FORCE_FW_HANG_ASSERT = 1,
2993         WMI_FORCE_FW_HANG_NO_DETECT,
2994         WMI_FORCE_FW_HANG_CTRL_EP_FULL,
2995         WMI_FORCE_FW_HANG_EMPTY_POINT,
2996         WMI_FORCE_FW_HANG_STACK_OVERFLOW,
2997         WMI_FORCE_FW_HANG_INFINITE_LOOP,
2998 };
2999
3000 #define WMI_FORCE_FW_HANG_RANDOM_TIME 0xFFFFFFFF
3001
3002 struct wmi_force_fw_hang_cmd {
3003         __le32 type;
3004         __le32 delay_ms;
3005 } __packed;
3006
3007 #define ATH10K_RTS_MAX          2347
3008 #define ATH10K_FRAGMT_THRESHOLD_MIN     540
3009 #define ATH10K_FRAGMT_THRESHOLD_MAX     2346
3010
3011 #define WMI_MAX_EVENT 0x1000
3012 /* Maximum number of pending TXed WMI packets */
3013 #define WMI_MAX_PENDING_TX_COUNT 128
3014 #define WMI_SKB_HEADROOM sizeof(struct wmi_cmd_hdr)
3015
3016 /* By default disable power save for IBSS */
3017 #define ATH10K_DEFAULT_ATIM 0
3018
3019 struct ath10k;
3020 struct ath10k_vif;
3021
3022 int ath10k_wmi_attach(struct ath10k *ar);
3023 void ath10k_wmi_detach(struct ath10k *ar);
3024 int ath10k_wmi_wait_for_service_ready(struct ath10k *ar);
3025 int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar);
3026 void ath10k_wmi_flush_tx(struct ath10k *ar);
3027
3028 int ath10k_wmi_connect_htc_service(struct ath10k *ar);
3029 int ath10k_wmi_pdev_set_channel(struct ath10k *ar,
3030                                 const struct wmi_channel_arg *);
3031 int ath10k_wmi_pdev_suspend_target(struct ath10k *ar);
3032 int ath10k_wmi_pdev_resume_target(struct ath10k *ar);
3033 int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g,
3034                                   u16 rd5g, u16 ctl2g, u16 ctl5g);
3035 int ath10k_wmi_pdev_set_param(struct ath10k *ar, enum wmi_pdev_param id,
3036                               u32 value);
3037 int ath10k_wmi_cmd_init(struct ath10k *ar);
3038 int ath10k_wmi_start_scan(struct ath10k *ar, const struct wmi_start_scan_arg *);
3039 void ath10k_wmi_start_scan_init(struct ath10k *ar, struct wmi_start_scan_arg *);
3040 int ath10k_wmi_stop_scan(struct ath10k *ar,
3041                          const struct wmi_stop_scan_arg *arg);
3042 int ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id,
3043                            enum wmi_vdev_type type,
3044                            enum wmi_vdev_subtype subtype,
3045                            const u8 macaddr[ETH_ALEN]);
3046 int ath10k_wmi_vdev_delete(struct ath10k *ar, u32 vdev_id);
3047 int ath10k_wmi_vdev_start(struct ath10k *ar,
3048                           const struct wmi_vdev_start_request_arg *);
3049 int ath10k_wmi_vdev_restart(struct ath10k *ar,
3050                             const struct wmi_vdev_start_request_arg *);
3051 int ath10k_wmi_vdev_stop(struct ath10k *ar, u32 vdev_id);
3052 int ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
3053                        const u8 *bssid);
3054 int ath10k_wmi_vdev_down(struct ath10k *ar, u32 vdev_id);
3055 int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id,
3056                               enum wmi_vdev_param param_id, u32 param_value);
3057 int ath10k_wmi_vdev_install_key(struct ath10k *ar,
3058                                 const struct wmi_vdev_install_key_arg *arg);
3059 int ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id,
3060                     const u8 peer_addr[ETH_ALEN]);
3061 int ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id,
3062                     const u8 peer_addr[ETH_ALEN]);
3063 int ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id,
3064                    const u8 peer_addr[ETH_ALEN], u32 tid_bitmap);
3065 int ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id,
3066                               const u8 *peer_addr,
3067                               enum wmi_peer_param param_id, u32 param_value);
3068 int ath10k_wmi_peer_assoc(struct ath10k *ar,
3069                           const struct wmi_peer_assoc_complete_arg *arg);
3070 int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
3071                           enum wmi_sta_ps_mode psmode);
3072 int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
3073                                 enum wmi_sta_powersave_param param_id,
3074                                 u32 value);
3075 int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
3076                                enum wmi_ap_ps_peer_param param_id, u32 value);
3077 int ath10k_wmi_scan_chan_list(struct ath10k *ar,
3078                               const struct wmi_scan_chan_list_arg *arg);
3079 int ath10k_wmi_beacon_send(struct ath10k *ar, const struct wmi_bcn_tx_arg *arg);
3080 int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar,
3081                         const struct wmi_pdev_set_wmm_params_arg *arg);
3082 int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id);
3083 int ath10k_wmi_force_fw_hang(struct ath10k *ar,
3084                              enum wmi_force_fw_hang_type type, u32 delay_ms);
3085
3086 #endif /* _WMI_H_ */