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