Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[sfrench/cifs-2.6.git] / drivers / net / wireless / ath / ath10k / wmi.h
1 /*
2  * Copyright (c) 2005-2011 Atheros Communications Inc.
3  * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
4  * Copyright (c) 2018, The Linux Foundation. All rights reserved.
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18
19 #ifndef _WMI_H_
20 #define _WMI_H_
21
22 #include <linux/types.h>
23 #include <net/mac80211.h>
24
25 /*
26  * This file specifies the WMI interface for the Unified Software
27  * Architecture.
28  *
29  * It includes definitions of all the commands and events. Commands are
30  * messages from the host to the target. Events and Replies are messages
31  * from the target to the host.
32  *
33  * Ownership of correctness in regards to WMI commands belongs to the host
34  * driver and the target is not required to validate parameters for value,
35  * proper range, or any other checking.
36  *
37  * Guidelines for extending this interface are below.
38  *
39  * 1. Add new WMI commands ONLY within the specified range - 0x9000 - 0x9fff
40  *
41  * 2. Use ONLY u32 type for defining member variables within WMI
42  *    command/event structures. Do not use u8, u16, bool or
43  *    enum types within these structures.
44  *
45  * 3. DO NOT define bit fields within structures. Implement bit fields
46  *    using masks if necessary. Do not use the programming language's bit
47  *    field definition.
48  *
49  * 4. Define macros for encode/decode of u8, u16 fields within
50  *    the u32 variables. Use these macros for set/get of these fields.
51  *    Try to use this to optimize the structure without bloating it with
52  *    u32 variables for every lower sized field.
53  *
54  * 5. Do not use PACK/UNPACK attributes for the structures as each member
55  *    variable is already 4-byte aligned by virtue of being a u32
56  *    type.
57  *
58  * 6. Comment each parameter part of the WMI command/event structure by
59  *    using the 2 stars at the beginning of C comment instead of one star to
60  *    enable HTML document generation using Doxygen.
61  *
62  */
63
64 /* Control Path */
65 struct wmi_cmd_hdr {
66         __le32 cmd_id;
67 } __packed;
68
69 #define WMI_CMD_HDR_CMD_ID_MASK   0x00FFFFFF
70 #define WMI_CMD_HDR_CMD_ID_LSB    0
71 #define WMI_CMD_HDR_PLT_PRIV_MASK 0xFF000000
72 #define WMI_CMD_HDR_PLT_PRIV_LSB  24
73
74 #define HTC_PROTOCOL_VERSION    0x0002
75 #define WMI_PROTOCOL_VERSION    0x0002
76
77 /*
78  * There is no signed version of __le32, so for a temporary solution come
79  * up with our own version. The idea is from fs/ntfs/endian.h.
80  *
81  * Use a_ prefix so that it doesn't conflict if we get proper support to
82  * linux/types.h.
83  */
84 typedef __s32 __bitwise a_sle32;
85
86 static inline a_sle32 a_cpu_to_sle32(s32 val)
87 {
88         return (__force a_sle32)cpu_to_le32(val);
89 }
90
91 static inline s32 a_sle32_to_cpu(a_sle32 val)
92 {
93         return le32_to_cpu((__force __le32)val);
94 }
95
96 enum wmi_service {
97         WMI_SERVICE_BEACON_OFFLOAD = 0,
98         WMI_SERVICE_SCAN_OFFLOAD,
99         WMI_SERVICE_ROAM_OFFLOAD,
100         WMI_SERVICE_BCN_MISS_OFFLOAD,
101         WMI_SERVICE_STA_PWRSAVE,
102         WMI_SERVICE_STA_ADVANCED_PWRSAVE,
103         WMI_SERVICE_AP_UAPSD,
104         WMI_SERVICE_AP_DFS,
105         WMI_SERVICE_11AC,
106         WMI_SERVICE_BLOCKACK,
107         WMI_SERVICE_PHYERR,
108         WMI_SERVICE_BCN_FILTER,
109         WMI_SERVICE_RTT,
110         WMI_SERVICE_RATECTRL,
111         WMI_SERVICE_WOW,
112         WMI_SERVICE_RATECTRL_CACHE,
113         WMI_SERVICE_IRAM_TIDS,
114         WMI_SERVICE_ARPNS_OFFLOAD,
115         WMI_SERVICE_NLO,
116         WMI_SERVICE_GTK_OFFLOAD,
117         WMI_SERVICE_SCAN_SCH,
118         WMI_SERVICE_CSA_OFFLOAD,
119         WMI_SERVICE_CHATTER,
120         WMI_SERVICE_COEX_FREQAVOID,
121         WMI_SERVICE_PACKET_POWER_SAVE,
122         WMI_SERVICE_FORCE_FW_HANG,
123         WMI_SERVICE_GPIO,
124         WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM,
125         WMI_SERVICE_STA_UAPSD_BASIC_AUTO_TRIG,
126         WMI_SERVICE_STA_UAPSD_VAR_AUTO_TRIG,
127         WMI_SERVICE_STA_KEEP_ALIVE,
128         WMI_SERVICE_TX_ENCAP,
129         WMI_SERVICE_BURST,
130         WMI_SERVICE_SMART_ANTENNA_SW_SUPPORT,
131         WMI_SERVICE_SMART_ANTENNA_HW_SUPPORT,
132         WMI_SERVICE_ROAM_SCAN_OFFLOAD,
133         WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC,
134         WMI_SERVICE_EARLY_RX,
135         WMI_SERVICE_STA_SMPS,
136         WMI_SERVICE_FWTEST,
137         WMI_SERVICE_STA_WMMAC,
138         WMI_SERVICE_TDLS,
139         WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE,
140         WMI_SERVICE_ADAPTIVE_OCS,
141         WMI_SERVICE_BA_SSN_SUPPORT,
142         WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE,
143         WMI_SERVICE_WLAN_HB,
144         WMI_SERVICE_LTE_ANT_SHARE_SUPPORT,
145         WMI_SERVICE_BATCH_SCAN,
146         WMI_SERVICE_QPOWER,
147         WMI_SERVICE_PLMREQ,
148         WMI_SERVICE_THERMAL_MGMT,
149         WMI_SERVICE_RMC,
150         WMI_SERVICE_MHF_OFFLOAD,
151         WMI_SERVICE_COEX_SAR,
152         WMI_SERVICE_BCN_TXRATE_OVERRIDE,
153         WMI_SERVICE_NAN,
154         WMI_SERVICE_L1SS_STAT,
155         WMI_SERVICE_ESTIMATE_LINKSPEED,
156         WMI_SERVICE_OBSS_SCAN,
157         WMI_SERVICE_TDLS_OFFCHAN,
158         WMI_SERVICE_TDLS_UAPSD_BUFFER_STA,
159         WMI_SERVICE_TDLS_UAPSD_SLEEP_STA,
160         WMI_SERVICE_IBSS_PWRSAVE,
161         WMI_SERVICE_LPASS,
162         WMI_SERVICE_EXTSCAN,
163         WMI_SERVICE_D0WOW,
164         WMI_SERVICE_HSOFFLOAD,
165         WMI_SERVICE_ROAM_HO_OFFLOAD,
166         WMI_SERVICE_RX_FULL_REORDER,
167         WMI_SERVICE_DHCP_OFFLOAD,
168         WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT,
169         WMI_SERVICE_MDNS_OFFLOAD,
170         WMI_SERVICE_SAP_AUTH_OFFLOAD,
171         WMI_SERVICE_ATF,
172         WMI_SERVICE_COEX_GPIO,
173         WMI_SERVICE_ENHANCED_PROXY_STA,
174         WMI_SERVICE_TT,
175         WMI_SERVICE_PEER_CACHING,
176         WMI_SERVICE_AUX_SPECTRAL_INTF,
177         WMI_SERVICE_AUX_CHAN_LOAD_INTF,
178         WMI_SERVICE_BSS_CHANNEL_INFO_64,
179         WMI_SERVICE_EXT_RES_CFG_SUPPORT,
180         WMI_SERVICE_MESH_11S,
181         WMI_SERVICE_MESH_NON_11S,
182         WMI_SERVICE_PEER_STATS,
183         WMI_SERVICE_RESTRT_CHNL_SUPPORT,
184         WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT,
185         WMI_SERVICE_TX_MODE_PUSH_ONLY,
186         WMI_SERVICE_TX_MODE_PUSH_PULL,
187         WMI_SERVICE_TX_MODE_DYNAMIC,
188         WMI_SERVICE_VDEV_RX_FILTER,
189         WMI_SERVICE_BTCOEX,
190         WMI_SERVICE_CHECK_CAL_VERSION,
191         WMI_SERVICE_DBGLOG_WARN2,
192         WMI_SERVICE_BTCOEX_DUTY_CYCLE,
193         WMI_SERVICE_4_WIRE_COEX_SUPPORT,
194         WMI_SERVICE_EXTENDED_NSS_SUPPORT,
195         WMI_SERVICE_PROG_GPIO_BAND_SELECT,
196         WMI_SERVICE_SMART_LOGGING_SUPPORT,
197         WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE,
198         WMI_SERVICE_TDLS_EXPLICIT_MODE_ONLY,
199         WMI_SERVICE_MGMT_TX_WMI,
200         WMI_SERVICE_TDLS_WIDER_BANDWIDTH,
201         WMI_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS,
202         WMI_SERVICE_HOST_DFS_CHECK_SUPPORT,
203         WMI_SERVICE_TPC_STATS_FINAL,
204         WMI_SERVICE_RESET_CHIP,
205         WMI_SERVICE_SPOOF_MAC_SUPPORT,
206
207         /* keep last */
208         WMI_SERVICE_MAX,
209 };
210
211 enum wmi_10x_service {
212         WMI_10X_SERVICE_BEACON_OFFLOAD = 0,
213         WMI_10X_SERVICE_SCAN_OFFLOAD,
214         WMI_10X_SERVICE_ROAM_OFFLOAD,
215         WMI_10X_SERVICE_BCN_MISS_OFFLOAD,
216         WMI_10X_SERVICE_STA_PWRSAVE,
217         WMI_10X_SERVICE_STA_ADVANCED_PWRSAVE,
218         WMI_10X_SERVICE_AP_UAPSD,
219         WMI_10X_SERVICE_AP_DFS,
220         WMI_10X_SERVICE_11AC,
221         WMI_10X_SERVICE_BLOCKACK,
222         WMI_10X_SERVICE_PHYERR,
223         WMI_10X_SERVICE_BCN_FILTER,
224         WMI_10X_SERVICE_RTT,
225         WMI_10X_SERVICE_RATECTRL,
226         WMI_10X_SERVICE_WOW,
227         WMI_10X_SERVICE_RATECTRL_CACHE,
228         WMI_10X_SERVICE_IRAM_TIDS,
229         WMI_10X_SERVICE_BURST,
230
231         /* introduced in 10.2 */
232         WMI_10X_SERVICE_SMART_ANTENNA_SW_SUPPORT,
233         WMI_10X_SERVICE_FORCE_FW_HANG,
234         WMI_10X_SERVICE_SMART_ANTENNA_HW_SUPPORT,
235         WMI_10X_SERVICE_ATF,
236         WMI_10X_SERVICE_COEX_GPIO,
237         WMI_10X_SERVICE_AUX_SPECTRAL_INTF,
238         WMI_10X_SERVICE_AUX_CHAN_LOAD_INTF,
239         WMI_10X_SERVICE_BSS_CHANNEL_INFO_64,
240         WMI_10X_SERVICE_MESH,
241         WMI_10X_SERVICE_EXT_RES_CFG_SUPPORT,
242         WMI_10X_SERVICE_PEER_STATS,
243         WMI_10X_SERVICE_RESET_CHIP,
244         WMI_10X_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS,
245 };
246
247 enum wmi_main_service {
248         WMI_MAIN_SERVICE_BEACON_OFFLOAD = 0,
249         WMI_MAIN_SERVICE_SCAN_OFFLOAD,
250         WMI_MAIN_SERVICE_ROAM_OFFLOAD,
251         WMI_MAIN_SERVICE_BCN_MISS_OFFLOAD,
252         WMI_MAIN_SERVICE_STA_PWRSAVE,
253         WMI_MAIN_SERVICE_STA_ADVANCED_PWRSAVE,
254         WMI_MAIN_SERVICE_AP_UAPSD,
255         WMI_MAIN_SERVICE_AP_DFS,
256         WMI_MAIN_SERVICE_11AC,
257         WMI_MAIN_SERVICE_BLOCKACK,
258         WMI_MAIN_SERVICE_PHYERR,
259         WMI_MAIN_SERVICE_BCN_FILTER,
260         WMI_MAIN_SERVICE_RTT,
261         WMI_MAIN_SERVICE_RATECTRL,
262         WMI_MAIN_SERVICE_WOW,
263         WMI_MAIN_SERVICE_RATECTRL_CACHE,
264         WMI_MAIN_SERVICE_IRAM_TIDS,
265         WMI_MAIN_SERVICE_ARPNS_OFFLOAD,
266         WMI_MAIN_SERVICE_NLO,
267         WMI_MAIN_SERVICE_GTK_OFFLOAD,
268         WMI_MAIN_SERVICE_SCAN_SCH,
269         WMI_MAIN_SERVICE_CSA_OFFLOAD,
270         WMI_MAIN_SERVICE_CHATTER,
271         WMI_MAIN_SERVICE_COEX_FREQAVOID,
272         WMI_MAIN_SERVICE_PACKET_POWER_SAVE,
273         WMI_MAIN_SERVICE_FORCE_FW_HANG,
274         WMI_MAIN_SERVICE_GPIO,
275         WMI_MAIN_SERVICE_STA_DTIM_PS_MODULATED_DTIM,
276         WMI_MAIN_SERVICE_STA_UAPSD_BASIC_AUTO_TRIG,
277         WMI_MAIN_SERVICE_STA_UAPSD_VAR_AUTO_TRIG,
278         WMI_MAIN_SERVICE_STA_KEEP_ALIVE,
279         WMI_MAIN_SERVICE_TX_ENCAP,
280 };
281
282 enum wmi_10_4_service {
283         WMI_10_4_SERVICE_BEACON_OFFLOAD = 0,
284         WMI_10_4_SERVICE_SCAN_OFFLOAD,
285         WMI_10_4_SERVICE_ROAM_OFFLOAD,
286         WMI_10_4_SERVICE_BCN_MISS_OFFLOAD,
287         WMI_10_4_SERVICE_STA_PWRSAVE,
288         WMI_10_4_SERVICE_STA_ADVANCED_PWRSAVE,
289         WMI_10_4_SERVICE_AP_UAPSD,
290         WMI_10_4_SERVICE_AP_DFS,
291         WMI_10_4_SERVICE_11AC,
292         WMI_10_4_SERVICE_BLOCKACK,
293         WMI_10_4_SERVICE_PHYERR,
294         WMI_10_4_SERVICE_BCN_FILTER,
295         WMI_10_4_SERVICE_RTT,
296         WMI_10_4_SERVICE_RATECTRL,
297         WMI_10_4_SERVICE_WOW,
298         WMI_10_4_SERVICE_RATECTRL_CACHE,
299         WMI_10_4_SERVICE_IRAM_TIDS,
300         WMI_10_4_SERVICE_BURST,
301         WMI_10_4_SERVICE_SMART_ANTENNA_SW_SUPPORT,
302         WMI_10_4_SERVICE_GTK_OFFLOAD,
303         WMI_10_4_SERVICE_SCAN_SCH,
304         WMI_10_4_SERVICE_CSA_OFFLOAD,
305         WMI_10_4_SERVICE_CHATTER,
306         WMI_10_4_SERVICE_COEX_FREQAVOID,
307         WMI_10_4_SERVICE_PACKET_POWER_SAVE,
308         WMI_10_4_SERVICE_FORCE_FW_HANG,
309         WMI_10_4_SERVICE_SMART_ANTENNA_HW_SUPPORT,
310         WMI_10_4_SERVICE_GPIO,
311         WMI_10_4_SERVICE_STA_UAPSD_BASIC_AUTO_TRIG,
312         WMI_10_4_SERVICE_STA_UAPSD_VAR_AUTO_TRIG,
313         WMI_10_4_SERVICE_STA_KEEP_ALIVE,
314         WMI_10_4_SERVICE_TX_ENCAP,
315         WMI_10_4_SERVICE_AP_PS_DETECT_OUT_OF_SYNC,
316         WMI_10_4_SERVICE_EARLY_RX,
317         WMI_10_4_SERVICE_ENHANCED_PROXY_STA,
318         WMI_10_4_SERVICE_TT,
319         WMI_10_4_SERVICE_ATF,
320         WMI_10_4_SERVICE_PEER_CACHING,
321         WMI_10_4_SERVICE_COEX_GPIO,
322         WMI_10_4_SERVICE_AUX_SPECTRAL_INTF,
323         WMI_10_4_SERVICE_AUX_CHAN_LOAD_INTF,
324         WMI_10_4_SERVICE_BSS_CHANNEL_INFO_64,
325         WMI_10_4_SERVICE_EXT_RES_CFG_SUPPORT,
326         WMI_10_4_SERVICE_MESH_NON_11S,
327         WMI_10_4_SERVICE_RESTRT_CHNL_SUPPORT,
328         WMI_10_4_SERVICE_PEER_STATS,
329         WMI_10_4_SERVICE_MESH_11S,
330         WMI_10_4_SERVICE_PERIODIC_CHAN_STAT_SUPPORT,
331         WMI_10_4_SERVICE_TX_MODE_PUSH_ONLY,
332         WMI_10_4_SERVICE_TX_MODE_PUSH_PULL,
333         WMI_10_4_SERVICE_TX_MODE_DYNAMIC,
334         WMI_10_4_SERVICE_VDEV_RX_FILTER,
335         WMI_10_4_SERVICE_BTCOEX,
336         WMI_10_4_SERVICE_CHECK_CAL_VERSION,
337         WMI_10_4_SERVICE_DBGLOG_WARN2,
338         WMI_10_4_SERVICE_BTCOEX_DUTY_CYCLE,
339         WMI_10_4_SERVICE_4_WIRE_COEX_SUPPORT,
340         WMI_10_4_SERVICE_EXTENDED_NSS_SUPPORT,
341         WMI_10_4_SERVICE_PROG_GPIO_BAND_SELECT,
342         WMI_10_4_SERVICE_SMART_LOGGING_SUPPORT,
343         WMI_10_4_SERVICE_TDLS,
344         WMI_10_4_SERVICE_TDLS_OFFCHAN,
345         WMI_10_4_SERVICE_TDLS_UAPSD_BUFFER_STA,
346         WMI_10_4_SERVICE_TDLS_UAPSD_SLEEP_STA,
347         WMI_10_4_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE,
348         WMI_10_4_SERVICE_TDLS_EXPLICIT_MODE_ONLY,
349         WMI_10_4_SERVICE_TDLS_WIDER_BANDWIDTH,
350         WMI_10_4_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS,
351         WMI_10_4_SERVICE_HOST_DFS_CHECK_SUPPORT,
352         WMI_10_4_SERVICE_TPC_STATS_FINAL,
353 };
354
355 static inline char *wmi_service_name(int service_id)
356 {
357 #define SVCSTR(x) case x: return #x
358
359         switch (service_id) {
360         SVCSTR(WMI_SERVICE_BEACON_OFFLOAD);
361         SVCSTR(WMI_SERVICE_SCAN_OFFLOAD);
362         SVCSTR(WMI_SERVICE_ROAM_OFFLOAD);
363         SVCSTR(WMI_SERVICE_BCN_MISS_OFFLOAD);
364         SVCSTR(WMI_SERVICE_STA_PWRSAVE);
365         SVCSTR(WMI_SERVICE_STA_ADVANCED_PWRSAVE);
366         SVCSTR(WMI_SERVICE_AP_UAPSD);
367         SVCSTR(WMI_SERVICE_AP_DFS);
368         SVCSTR(WMI_SERVICE_11AC);
369         SVCSTR(WMI_SERVICE_BLOCKACK);
370         SVCSTR(WMI_SERVICE_PHYERR);
371         SVCSTR(WMI_SERVICE_BCN_FILTER);
372         SVCSTR(WMI_SERVICE_RTT);
373         SVCSTR(WMI_SERVICE_RATECTRL);
374         SVCSTR(WMI_SERVICE_WOW);
375         SVCSTR(WMI_SERVICE_RATECTRL_CACHE);
376         SVCSTR(WMI_SERVICE_IRAM_TIDS);
377         SVCSTR(WMI_SERVICE_ARPNS_OFFLOAD);
378         SVCSTR(WMI_SERVICE_NLO);
379         SVCSTR(WMI_SERVICE_GTK_OFFLOAD);
380         SVCSTR(WMI_SERVICE_SCAN_SCH);
381         SVCSTR(WMI_SERVICE_CSA_OFFLOAD);
382         SVCSTR(WMI_SERVICE_CHATTER);
383         SVCSTR(WMI_SERVICE_COEX_FREQAVOID);
384         SVCSTR(WMI_SERVICE_PACKET_POWER_SAVE);
385         SVCSTR(WMI_SERVICE_FORCE_FW_HANG);
386         SVCSTR(WMI_SERVICE_GPIO);
387         SVCSTR(WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM);
388         SVCSTR(WMI_SERVICE_STA_UAPSD_BASIC_AUTO_TRIG);
389         SVCSTR(WMI_SERVICE_STA_UAPSD_VAR_AUTO_TRIG);
390         SVCSTR(WMI_SERVICE_STA_KEEP_ALIVE);
391         SVCSTR(WMI_SERVICE_TX_ENCAP);
392         SVCSTR(WMI_SERVICE_BURST);
393         SVCSTR(WMI_SERVICE_SMART_ANTENNA_SW_SUPPORT);
394         SVCSTR(WMI_SERVICE_SMART_ANTENNA_HW_SUPPORT);
395         SVCSTR(WMI_SERVICE_ROAM_SCAN_OFFLOAD);
396         SVCSTR(WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC);
397         SVCSTR(WMI_SERVICE_EARLY_RX);
398         SVCSTR(WMI_SERVICE_STA_SMPS);
399         SVCSTR(WMI_SERVICE_FWTEST);
400         SVCSTR(WMI_SERVICE_STA_WMMAC);
401         SVCSTR(WMI_SERVICE_TDLS);
402         SVCSTR(WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE);
403         SVCSTR(WMI_SERVICE_ADAPTIVE_OCS);
404         SVCSTR(WMI_SERVICE_BA_SSN_SUPPORT);
405         SVCSTR(WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE);
406         SVCSTR(WMI_SERVICE_WLAN_HB);
407         SVCSTR(WMI_SERVICE_LTE_ANT_SHARE_SUPPORT);
408         SVCSTR(WMI_SERVICE_BATCH_SCAN);
409         SVCSTR(WMI_SERVICE_QPOWER);
410         SVCSTR(WMI_SERVICE_PLMREQ);
411         SVCSTR(WMI_SERVICE_THERMAL_MGMT);
412         SVCSTR(WMI_SERVICE_RMC);
413         SVCSTR(WMI_SERVICE_MHF_OFFLOAD);
414         SVCSTR(WMI_SERVICE_COEX_SAR);
415         SVCSTR(WMI_SERVICE_BCN_TXRATE_OVERRIDE);
416         SVCSTR(WMI_SERVICE_NAN);
417         SVCSTR(WMI_SERVICE_L1SS_STAT);
418         SVCSTR(WMI_SERVICE_ESTIMATE_LINKSPEED);
419         SVCSTR(WMI_SERVICE_OBSS_SCAN);
420         SVCSTR(WMI_SERVICE_TDLS_OFFCHAN);
421         SVCSTR(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA);
422         SVCSTR(WMI_SERVICE_TDLS_UAPSD_SLEEP_STA);
423         SVCSTR(WMI_SERVICE_IBSS_PWRSAVE);
424         SVCSTR(WMI_SERVICE_LPASS);
425         SVCSTR(WMI_SERVICE_EXTSCAN);
426         SVCSTR(WMI_SERVICE_D0WOW);
427         SVCSTR(WMI_SERVICE_HSOFFLOAD);
428         SVCSTR(WMI_SERVICE_ROAM_HO_OFFLOAD);
429         SVCSTR(WMI_SERVICE_RX_FULL_REORDER);
430         SVCSTR(WMI_SERVICE_DHCP_OFFLOAD);
431         SVCSTR(WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT);
432         SVCSTR(WMI_SERVICE_MDNS_OFFLOAD);
433         SVCSTR(WMI_SERVICE_SAP_AUTH_OFFLOAD);
434         SVCSTR(WMI_SERVICE_ATF);
435         SVCSTR(WMI_SERVICE_COEX_GPIO);
436         SVCSTR(WMI_SERVICE_ENHANCED_PROXY_STA);
437         SVCSTR(WMI_SERVICE_TT);
438         SVCSTR(WMI_SERVICE_PEER_CACHING);
439         SVCSTR(WMI_SERVICE_AUX_SPECTRAL_INTF);
440         SVCSTR(WMI_SERVICE_AUX_CHAN_LOAD_INTF);
441         SVCSTR(WMI_SERVICE_BSS_CHANNEL_INFO_64);
442         SVCSTR(WMI_SERVICE_EXT_RES_CFG_SUPPORT);
443         SVCSTR(WMI_SERVICE_MESH_11S);
444         SVCSTR(WMI_SERVICE_MESH_NON_11S);
445         SVCSTR(WMI_SERVICE_PEER_STATS);
446         SVCSTR(WMI_SERVICE_RESTRT_CHNL_SUPPORT);
447         SVCSTR(WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT);
448         SVCSTR(WMI_SERVICE_TX_MODE_PUSH_ONLY);
449         SVCSTR(WMI_SERVICE_TX_MODE_PUSH_PULL);
450         SVCSTR(WMI_SERVICE_TX_MODE_DYNAMIC);
451         SVCSTR(WMI_SERVICE_VDEV_RX_FILTER);
452         SVCSTR(WMI_SERVICE_CHECK_CAL_VERSION);
453         SVCSTR(WMI_SERVICE_DBGLOG_WARN2);
454         SVCSTR(WMI_SERVICE_BTCOEX_DUTY_CYCLE);
455         SVCSTR(WMI_SERVICE_4_WIRE_COEX_SUPPORT);
456         SVCSTR(WMI_SERVICE_EXTENDED_NSS_SUPPORT);
457         SVCSTR(WMI_SERVICE_PROG_GPIO_BAND_SELECT);
458         SVCSTR(WMI_SERVICE_SMART_LOGGING_SUPPORT);
459         SVCSTR(WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE);
460         SVCSTR(WMI_SERVICE_TDLS_EXPLICIT_MODE_ONLY);
461         SVCSTR(WMI_SERVICE_TDLS_WIDER_BANDWIDTH);
462         SVCSTR(WMI_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS);
463         SVCSTR(WMI_SERVICE_HOST_DFS_CHECK_SUPPORT);
464         SVCSTR(WMI_SERVICE_TPC_STATS_FINAL);
465         default:
466                 return NULL;
467         }
468
469 #undef SVCSTR
470 }
471
472 #define WMI_SERVICE_IS_ENABLED(wmi_svc_bmap, svc_id, len) \
473         ((svc_id) < (len) && \
474          __le32_to_cpu((wmi_svc_bmap)[(svc_id) / (sizeof(u32))]) & \
475          BIT((svc_id) % (sizeof(u32))))
476
477 /* This extension is required to accommodate new services, current limit
478  * for wmi_services is 64 as target is using only 4-bits of each 32-bit
479  * wmi_service word. Extending this to make use of remaining unused bits
480  * for new services.
481  */
482 #define WMI_EXT_SERVICE_IS_ENABLED(wmi_svc_bmap, svc_id, len) \
483         ((svc_id) >= (len) && \
484         __le32_to_cpu((wmi_svc_bmap)[((svc_id) - (len)) / 28]) & \
485         BIT(((((svc_id) - (len)) % 28) & 0x1f) + 4))
486
487 #define SVCMAP(x, y, len) \
488         do { \
489                 if ((WMI_SERVICE_IS_ENABLED((in), (x), (len))) || \
490                     (WMI_EXT_SERVICE_IS_ENABLED((in), (x), (len)))) \
491                         __set_bit(y, out); \
492         } while (0)
493
494 static inline void wmi_10x_svc_map(const __le32 *in, unsigned long *out,
495                                    size_t len)
496 {
497         SVCMAP(WMI_10X_SERVICE_BEACON_OFFLOAD,
498                WMI_SERVICE_BEACON_OFFLOAD, len);
499         SVCMAP(WMI_10X_SERVICE_SCAN_OFFLOAD,
500                WMI_SERVICE_SCAN_OFFLOAD, len);
501         SVCMAP(WMI_10X_SERVICE_ROAM_OFFLOAD,
502                WMI_SERVICE_ROAM_OFFLOAD, len);
503         SVCMAP(WMI_10X_SERVICE_BCN_MISS_OFFLOAD,
504                WMI_SERVICE_BCN_MISS_OFFLOAD, len);
505         SVCMAP(WMI_10X_SERVICE_STA_PWRSAVE,
506                WMI_SERVICE_STA_PWRSAVE, len);
507         SVCMAP(WMI_10X_SERVICE_STA_ADVANCED_PWRSAVE,
508                WMI_SERVICE_STA_ADVANCED_PWRSAVE, len);
509         SVCMAP(WMI_10X_SERVICE_AP_UAPSD,
510                WMI_SERVICE_AP_UAPSD, len);
511         SVCMAP(WMI_10X_SERVICE_AP_DFS,
512                WMI_SERVICE_AP_DFS, len);
513         SVCMAP(WMI_10X_SERVICE_11AC,
514                WMI_SERVICE_11AC, len);
515         SVCMAP(WMI_10X_SERVICE_BLOCKACK,
516                WMI_SERVICE_BLOCKACK, len);
517         SVCMAP(WMI_10X_SERVICE_PHYERR,
518                WMI_SERVICE_PHYERR, len);
519         SVCMAP(WMI_10X_SERVICE_BCN_FILTER,
520                WMI_SERVICE_BCN_FILTER, len);
521         SVCMAP(WMI_10X_SERVICE_RTT,
522                WMI_SERVICE_RTT, len);
523         SVCMAP(WMI_10X_SERVICE_RATECTRL,
524                WMI_SERVICE_RATECTRL, len);
525         SVCMAP(WMI_10X_SERVICE_WOW,
526                WMI_SERVICE_WOW, len);
527         SVCMAP(WMI_10X_SERVICE_RATECTRL_CACHE,
528                WMI_SERVICE_RATECTRL_CACHE, len);
529         SVCMAP(WMI_10X_SERVICE_IRAM_TIDS,
530                WMI_SERVICE_IRAM_TIDS, len);
531         SVCMAP(WMI_10X_SERVICE_BURST,
532                WMI_SERVICE_BURST, len);
533         SVCMAP(WMI_10X_SERVICE_SMART_ANTENNA_SW_SUPPORT,
534                WMI_SERVICE_SMART_ANTENNA_SW_SUPPORT, len);
535         SVCMAP(WMI_10X_SERVICE_FORCE_FW_HANG,
536                WMI_SERVICE_FORCE_FW_HANG, len);
537         SVCMAP(WMI_10X_SERVICE_SMART_ANTENNA_HW_SUPPORT,
538                WMI_SERVICE_SMART_ANTENNA_HW_SUPPORT, len);
539         SVCMAP(WMI_10X_SERVICE_ATF,
540                WMI_SERVICE_ATF, len);
541         SVCMAP(WMI_10X_SERVICE_COEX_GPIO,
542                WMI_SERVICE_COEX_GPIO, len);
543         SVCMAP(WMI_10X_SERVICE_AUX_SPECTRAL_INTF,
544                WMI_SERVICE_AUX_SPECTRAL_INTF, len);
545         SVCMAP(WMI_10X_SERVICE_AUX_CHAN_LOAD_INTF,
546                WMI_SERVICE_AUX_CHAN_LOAD_INTF, len);
547         SVCMAP(WMI_10X_SERVICE_BSS_CHANNEL_INFO_64,
548                WMI_SERVICE_BSS_CHANNEL_INFO_64, len);
549         SVCMAP(WMI_10X_SERVICE_MESH,
550                WMI_SERVICE_MESH_11S, len);
551         SVCMAP(WMI_10X_SERVICE_EXT_RES_CFG_SUPPORT,
552                WMI_SERVICE_EXT_RES_CFG_SUPPORT, len);
553         SVCMAP(WMI_10X_SERVICE_PEER_STATS,
554                WMI_SERVICE_PEER_STATS, len);
555         SVCMAP(WMI_10X_SERVICE_RESET_CHIP,
556                WMI_SERVICE_RESET_CHIP, len);
557         SVCMAP(WMI_10X_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS,
558                WMI_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS, len);
559 }
560
561 static inline void wmi_main_svc_map(const __le32 *in, unsigned long *out,
562                                     size_t len)
563 {
564         SVCMAP(WMI_MAIN_SERVICE_BEACON_OFFLOAD,
565                WMI_SERVICE_BEACON_OFFLOAD, len);
566         SVCMAP(WMI_MAIN_SERVICE_SCAN_OFFLOAD,
567                WMI_SERVICE_SCAN_OFFLOAD, len);
568         SVCMAP(WMI_MAIN_SERVICE_ROAM_OFFLOAD,
569                WMI_SERVICE_ROAM_OFFLOAD, len);
570         SVCMAP(WMI_MAIN_SERVICE_BCN_MISS_OFFLOAD,
571                WMI_SERVICE_BCN_MISS_OFFLOAD, len);
572         SVCMAP(WMI_MAIN_SERVICE_STA_PWRSAVE,
573                WMI_SERVICE_STA_PWRSAVE, len);
574         SVCMAP(WMI_MAIN_SERVICE_STA_ADVANCED_PWRSAVE,
575                WMI_SERVICE_STA_ADVANCED_PWRSAVE, len);
576         SVCMAP(WMI_MAIN_SERVICE_AP_UAPSD,
577                WMI_SERVICE_AP_UAPSD, len);
578         SVCMAP(WMI_MAIN_SERVICE_AP_DFS,
579                WMI_SERVICE_AP_DFS, len);
580         SVCMAP(WMI_MAIN_SERVICE_11AC,
581                WMI_SERVICE_11AC, len);
582         SVCMAP(WMI_MAIN_SERVICE_BLOCKACK,
583                WMI_SERVICE_BLOCKACK, len);
584         SVCMAP(WMI_MAIN_SERVICE_PHYERR,
585                WMI_SERVICE_PHYERR, len);
586         SVCMAP(WMI_MAIN_SERVICE_BCN_FILTER,
587                WMI_SERVICE_BCN_FILTER, len);
588         SVCMAP(WMI_MAIN_SERVICE_RTT,
589                WMI_SERVICE_RTT, len);
590         SVCMAP(WMI_MAIN_SERVICE_RATECTRL,
591                WMI_SERVICE_RATECTRL, len);
592         SVCMAP(WMI_MAIN_SERVICE_WOW,
593                WMI_SERVICE_WOW, len);
594         SVCMAP(WMI_MAIN_SERVICE_RATECTRL_CACHE,
595                WMI_SERVICE_RATECTRL_CACHE, len);
596         SVCMAP(WMI_MAIN_SERVICE_IRAM_TIDS,
597                WMI_SERVICE_IRAM_TIDS, len);
598         SVCMAP(WMI_MAIN_SERVICE_ARPNS_OFFLOAD,
599                WMI_SERVICE_ARPNS_OFFLOAD, len);
600         SVCMAP(WMI_MAIN_SERVICE_NLO,
601                WMI_SERVICE_NLO, len);
602         SVCMAP(WMI_MAIN_SERVICE_GTK_OFFLOAD,
603                WMI_SERVICE_GTK_OFFLOAD, len);
604         SVCMAP(WMI_MAIN_SERVICE_SCAN_SCH,
605                WMI_SERVICE_SCAN_SCH, len);
606         SVCMAP(WMI_MAIN_SERVICE_CSA_OFFLOAD,
607                WMI_SERVICE_CSA_OFFLOAD, len);
608         SVCMAP(WMI_MAIN_SERVICE_CHATTER,
609                WMI_SERVICE_CHATTER, len);
610         SVCMAP(WMI_MAIN_SERVICE_COEX_FREQAVOID,
611                WMI_SERVICE_COEX_FREQAVOID, len);
612         SVCMAP(WMI_MAIN_SERVICE_PACKET_POWER_SAVE,
613                WMI_SERVICE_PACKET_POWER_SAVE, len);
614         SVCMAP(WMI_MAIN_SERVICE_FORCE_FW_HANG,
615                WMI_SERVICE_FORCE_FW_HANG, len);
616         SVCMAP(WMI_MAIN_SERVICE_GPIO,
617                WMI_SERVICE_GPIO, len);
618         SVCMAP(WMI_MAIN_SERVICE_STA_DTIM_PS_MODULATED_DTIM,
619                WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM, len);
620         SVCMAP(WMI_MAIN_SERVICE_STA_UAPSD_BASIC_AUTO_TRIG,
621                WMI_SERVICE_STA_UAPSD_BASIC_AUTO_TRIG, len);
622         SVCMAP(WMI_MAIN_SERVICE_STA_UAPSD_VAR_AUTO_TRIG,
623                WMI_SERVICE_STA_UAPSD_VAR_AUTO_TRIG, len);
624         SVCMAP(WMI_MAIN_SERVICE_STA_KEEP_ALIVE,
625                WMI_SERVICE_STA_KEEP_ALIVE, len);
626         SVCMAP(WMI_MAIN_SERVICE_TX_ENCAP,
627                WMI_SERVICE_TX_ENCAP, len);
628 }
629
630 static inline void wmi_10_4_svc_map(const __le32 *in, unsigned long *out,
631                                     size_t len)
632 {
633         SVCMAP(WMI_10_4_SERVICE_BEACON_OFFLOAD,
634                WMI_SERVICE_BEACON_OFFLOAD, len);
635         SVCMAP(WMI_10_4_SERVICE_SCAN_OFFLOAD,
636                WMI_SERVICE_SCAN_OFFLOAD, len);
637         SVCMAP(WMI_10_4_SERVICE_ROAM_OFFLOAD,
638                WMI_SERVICE_ROAM_OFFLOAD, len);
639         SVCMAP(WMI_10_4_SERVICE_BCN_MISS_OFFLOAD,
640                WMI_SERVICE_BCN_MISS_OFFLOAD, len);
641         SVCMAP(WMI_10_4_SERVICE_STA_PWRSAVE,
642                WMI_SERVICE_STA_PWRSAVE, len);
643         SVCMAP(WMI_10_4_SERVICE_STA_ADVANCED_PWRSAVE,
644                WMI_SERVICE_STA_ADVANCED_PWRSAVE, len);
645         SVCMAP(WMI_10_4_SERVICE_AP_UAPSD,
646                WMI_SERVICE_AP_UAPSD, len);
647         SVCMAP(WMI_10_4_SERVICE_AP_DFS,
648                WMI_SERVICE_AP_DFS, len);
649         SVCMAP(WMI_10_4_SERVICE_11AC,
650                WMI_SERVICE_11AC, len);
651         SVCMAP(WMI_10_4_SERVICE_BLOCKACK,
652                WMI_SERVICE_BLOCKACK, len);
653         SVCMAP(WMI_10_4_SERVICE_PHYERR,
654                WMI_SERVICE_PHYERR, len);
655         SVCMAP(WMI_10_4_SERVICE_BCN_FILTER,
656                WMI_SERVICE_BCN_FILTER, len);
657         SVCMAP(WMI_10_4_SERVICE_RTT,
658                WMI_SERVICE_RTT, len);
659         SVCMAP(WMI_10_4_SERVICE_RATECTRL,
660                WMI_SERVICE_RATECTRL, len);
661         SVCMAP(WMI_10_4_SERVICE_WOW,
662                WMI_SERVICE_WOW, len);
663         SVCMAP(WMI_10_4_SERVICE_RATECTRL_CACHE,
664                WMI_SERVICE_RATECTRL_CACHE, len);
665         SVCMAP(WMI_10_4_SERVICE_IRAM_TIDS,
666                WMI_SERVICE_IRAM_TIDS, len);
667         SVCMAP(WMI_10_4_SERVICE_BURST,
668                WMI_SERVICE_BURST, len);
669         SVCMAP(WMI_10_4_SERVICE_SMART_ANTENNA_SW_SUPPORT,
670                WMI_SERVICE_SMART_ANTENNA_SW_SUPPORT, len);
671         SVCMAP(WMI_10_4_SERVICE_GTK_OFFLOAD,
672                WMI_SERVICE_GTK_OFFLOAD, len);
673         SVCMAP(WMI_10_4_SERVICE_SCAN_SCH,
674                WMI_SERVICE_SCAN_SCH, len);
675         SVCMAP(WMI_10_4_SERVICE_CSA_OFFLOAD,
676                WMI_SERVICE_CSA_OFFLOAD, len);
677         SVCMAP(WMI_10_4_SERVICE_CHATTER,
678                WMI_SERVICE_CHATTER, len);
679         SVCMAP(WMI_10_4_SERVICE_COEX_FREQAVOID,
680                WMI_SERVICE_COEX_FREQAVOID, len);
681         SVCMAP(WMI_10_4_SERVICE_PACKET_POWER_SAVE,
682                WMI_SERVICE_PACKET_POWER_SAVE, len);
683         SVCMAP(WMI_10_4_SERVICE_FORCE_FW_HANG,
684                WMI_SERVICE_FORCE_FW_HANG, len);
685         SVCMAP(WMI_10_4_SERVICE_SMART_ANTENNA_HW_SUPPORT,
686                WMI_SERVICE_SMART_ANTENNA_HW_SUPPORT, len);
687         SVCMAP(WMI_10_4_SERVICE_GPIO,
688                WMI_SERVICE_GPIO, len);
689         SVCMAP(WMI_10_4_SERVICE_STA_UAPSD_BASIC_AUTO_TRIG,
690                WMI_SERVICE_STA_UAPSD_BASIC_AUTO_TRIG, len);
691         SVCMAP(WMI_10_4_SERVICE_STA_UAPSD_VAR_AUTO_TRIG,
692                WMI_SERVICE_STA_UAPSD_VAR_AUTO_TRIG, len);
693         SVCMAP(WMI_10_4_SERVICE_STA_KEEP_ALIVE,
694                WMI_SERVICE_STA_KEEP_ALIVE, len);
695         SVCMAP(WMI_10_4_SERVICE_TX_ENCAP,
696                WMI_SERVICE_TX_ENCAP, len);
697         SVCMAP(WMI_10_4_SERVICE_AP_PS_DETECT_OUT_OF_SYNC,
698                WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC, len);
699         SVCMAP(WMI_10_4_SERVICE_EARLY_RX,
700                WMI_SERVICE_EARLY_RX, len);
701         SVCMAP(WMI_10_4_SERVICE_ENHANCED_PROXY_STA,
702                WMI_SERVICE_ENHANCED_PROXY_STA, len);
703         SVCMAP(WMI_10_4_SERVICE_TT,
704                WMI_SERVICE_TT, len);
705         SVCMAP(WMI_10_4_SERVICE_ATF,
706                WMI_SERVICE_ATF, len);
707         SVCMAP(WMI_10_4_SERVICE_PEER_CACHING,
708                WMI_SERVICE_PEER_CACHING, len);
709         SVCMAP(WMI_10_4_SERVICE_COEX_GPIO,
710                WMI_SERVICE_COEX_GPIO, len);
711         SVCMAP(WMI_10_4_SERVICE_AUX_SPECTRAL_INTF,
712                WMI_SERVICE_AUX_SPECTRAL_INTF, len);
713         SVCMAP(WMI_10_4_SERVICE_AUX_CHAN_LOAD_INTF,
714                WMI_SERVICE_AUX_CHAN_LOAD_INTF, len);
715         SVCMAP(WMI_10_4_SERVICE_BSS_CHANNEL_INFO_64,
716                WMI_SERVICE_BSS_CHANNEL_INFO_64, len);
717         SVCMAP(WMI_10_4_SERVICE_EXT_RES_CFG_SUPPORT,
718                WMI_SERVICE_EXT_RES_CFG_SUPPORT, len);
719         SVCMAP(WMI_10_4_SERVICE_MESH_NON_11S,
720                WMI_SERVICE_MESH_NON_11S, len);
721         SVCMAP(WMI_10_4_SERVICE_RESTRT_CHNL_SUPPORT,
722                WMI_SERVICE_RESTRT_CHNL_SUPPORT, len);
723         SVCMAP(WMI_10_4_SERVICE_PEER_STATS,
724                WMI_SERVICE_PEER_STATS, len);
725         SVCMAP(WMI_10_4_SERVICE_MESH_11S,
726                WMI_SERVICE_MESH_11S, len);
727         SVCMAP(WMI_10_4_SERVICE_PERIODIC_CHAN_STAT_SUPPORT,
728                WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT, len);
729         SVCMAP(WMI_10_4_SERVICE_TX_MODE_PUSH_ONLY,
730                WMI_SERVICE_TX_MODE_PUSH_ONLY, len);
731         SVCMAP(WMI_10_4_SERVICE_TX_MODE_PUSH_PULL,
732                WMI_SERVICE_TX_MODE_PUSH_PULL, len);
733         SVCMAP(WMI_10_4_SERVICE_TX_MODE_DYNAMIC,
734                WMI_SERVICE_TX_MODE_DYNAMIC, len);
735         SVCMAP(WMI_10_4_SERVICE_VDEV_RX_FILTER,
736                WMI_SERVICE_VDEV_RX_FILTER, len);
737         SVCMAP(WMI_10_4_SERVICE_BTCOEX,
738                WMI_SERVICE_BTCOEX, len);
739         SVCMAP(WMI_10_4_SERVICE_CHECK_CAL_VERSION,
740                WMI_SERVICE_CHECK_CAL_VERSION, len);
741         SVCMAP(WMI_10_4_SERVICE_DBGLOG_WARN2,
742                WMI_SERVICE_DBGLOG_WARN2, len);
743         SVCMAP(WMI_10_4_SERVICE_BTCOEX_DUTY_CYCLE,
744                WMI_SERVICE_BTCOEX_DUTY_CYCLE, len);
745         SVCMAP(WMI_10_4_SERVICE_4_WIRE_COEX_SUPPORT,
746                WMI_SERVICE_4_WIRE_COEX_SUPPORT, len);
747         SVCMAP(WMI_10_4_SERVICE_EXTENDED_NSS_SUPPORT,
748                WMI_SERVICE_EXTENDED_NSS_SUPPORT, len);
749         SVCMAP(WMI_10_4_SERVICE_PROG_GPIO_BAND_SELECT,
750                WMI_SERVICE_PROG_GPIO_BAND_SELECT, len);
751         SVCMAP(WMI_10_4_SERVICE_SMART_LOGGING_SUPPORT,
752                WMI_SERVICE_SMART_LOGGING_SUPPORT, len);
753         SVCMAP(WMI_10_4_SERVICE_TDLS,
754                WMI_SERVICE_TDLS, len);
755         SVCMAP(WMI_10_4_SERVICE_TDLS_OFFCHAN,
756                WMI_SERVICE_TDLS_OFFCHAN, len);
757         SVCMAP(WMI_10_4_SERVICE_TDLS_UAPSD_BUFFER_STA,
758                WMI_SERVICE_TDLS_UAPSD_BUFFER_STA, len);
759         SVCMAP(WMI_10_4_SERVICE_TDLS_UAPSD_SLEEP_STA,
760                WMI_SERVICE_TDLS_UAPSD_SLEEP_STA, len);
761         SVCMAP(WMI_10_4_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE,
762                WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE, len);
763         SVCMAP(WMI_10_4_SERVICE_TDLS_EXPLICIT_MODE_ONLY,
764                WMI_SERVICE_TDLS_EXPLICIT_MODE_ONLY, len);
765         SVCMAP(WMI_10_4_SERVICE_TDLS_WIDER_BANDWIDTH,
766                WMI_SERVICE_TDLS_WIDER_BANDWIDTH, len);
767         SVCMAP(WMI_10_4_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS,
768                WMI_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS, len);
769         SVCMAP(WMI_10_4_SERVICE_HOST_DFS_CHECK_SUPPORT,
770                WMI_SERVICE_HOST_DFS_CHECK_SUPPORT, len);
771         SVCMAP(WMI_10_4_SERVICE_TPC_STATS_FINAL,
772                WMI_SERVICE_TPC_STATS_FINAL, len);
773 }
774
775 #undef SVCMAP
776
777 /* 2 word representation of MAC addr */
778 struct wmi_mac_addr {
779         union {
780                 u8 addr[6];
781                 struct {
782                         u32 word0;
783                         u32 word1;
784                 } __packed;
785         } __packed;
786 } __packed;
787
788 struct wmi_cmd_map {
789         u32 init_cmdid;
790         u32 start_scan_cmdid;
791         u32 stop_scan_cmdid;
792         u32 scan_chan_list_cmdid;
793         u32 scan_sch_prio_tbl_cmdid;
794         u32 scan_prob_req_oui_cmdid;
795         u32 pdev_set_regdomain_cmdid;
796         u32 pdev_set_channel_cmdid;
797         u32 pdev_set_param_cmdid;
798         u32 pdev_pktlog_enable_cmdid;
799         u32 pdev_pktlog_disable_cmdid;
800         u32 pdev_set_wmm_params_cmdid;
801         u32 pdev_set_ht_cap_ie_cmdid;
802         u32 pdev_set_vht_cap_ie_cmdid;
803         u32 pdev_set_dscp_tid_map_cmdid;
804         u32 pdev_set_quiet_mode_cmdid;
805         u32 pdev_green_ap_ps_enable_cmdid;
806         u32 pdev_get_tpc_config_cmdid;
807         u32 pdev_set_base_macaddr_cmdid;
808         u32 vdev_create_cmdid;
809         u32 vdev_delete_cmdid;
810         u32 vdev_start_request_cmdid;
811         u32 vdev_restart_request_cmdid;
812         u32 vdev_up_cmdid;
813         u32 vdev_stop_cmdid;
814         u32 vdev_down_cmdid;
815         u32 vdev_set_param_cmdid;
816         u32 vdev_install_key_cmdid;
817         u32 peer_create_cmdid;
818         u32 peer_delete_cmdid;
819         u32 peer_flush_tids_cmdid;
820         u32 peer_set_param_cmdid;
821         u32 peer_assoc_cmdid;
822         u32 peer_add_wds_entry_cmdid;
823         u32 peer_remove_wds_entry_cmdid;
824         u32 peer_mcast_group_cmdid;
825         u32 bcn_tx_cmdid;
826         u32 pdev_send_bcn_cmdid;
827         u32 bcn_tmpl_cmdid;
828         u32 bcn_filter_rx_cmdid;
829         u32 prb_req_filter_rx_cmdid;
830         u32 mgmt_tx_cmdid;
831         u32 mgmt_tx_send_cmdid;
832         u32 prb_tmpl_cmdid;
833         u32 addba_clear_resp_cmdid;
834         u32 addba_send_cmdid;
835         u32 addba_status_cmdid;
836         u32 delba_send_cmdid;
837         u32 addba_set_resp_cmdid;
838         u32 send_singleamsdu_cmdid;
839         u32 sta_powersave_mode_cmdid;
840         u32 sta_powersave_param_cmdid;
841         u32 sta_mimo_ps_mode_cmdid;
842         u32 pdev_dfs_enable_cmdid;
843         u32 pdev_dfs_disable_cmdid;
844         u32 roam_scan_mode;
845         u32 roam_scan_rssi_threshold;
846         u32 roam_scan_period;
847         u32 roam_scan_rssi_change_threshold;
848         u32 roam_ap_profile;
849         u32 ofl_scan_add_ap_profile;
850         u32 ofl_scan_remove_ap_profile;
851         u32 ofl_scan_period;
852         u32 p2p_dev_set_device_info;
853         u32 p2p_dev_set_discoverability;
854         u32 p2p_go_set_beacon_ie;
855         u32 p2p_go_set_probe_resp_ie;
856         u32 p2p_set_vendor_ie_data_cmdid;
857         u32 ap_ps_peer_param_cmdid;
858         u32 ap_ps_peer_uapsd_coex_cmdid;
859         u32 peer_rate_retry_sched_cmdid;
860         u32 wlan_profile_trigger_cmdid;
861         u32 wlan_profile_set_hist_intvl_cmdid;
862         u32 wlan_profile_get_profile_data_cmdid;
863         u32 wlan_profile_enable_profile_id_cmdid;
864         u32 wlan_profile_list_profile_id_cmdid;
865         u32 pdev_suspend_cmdid;
866         u32 pdev_resume_cmdid;
867         u32 add_bcn_filter_cmdid;
868         u32 rmv_bcn_filter_cmdid;
869         u32 wow_add_wake_pattern_cmdid;
870         u32 wow_del_wake_pattern_cmdid;
871         u32 wow_enable_disable_wake_event_cmdid;
872         u32 wow_enable_cmdid;
873         u32 wow_hostwakeup_from_sleep_cmdid;
874         u32 rtt_measreq_cmdid;
875         u32 rtt_tsf_cmdid;
876         u32 vdev_spectral_scan_configure_cmdid;
877         u32 vdev_spectral_scan_enable_cmdid;
878         u32 request_stats_cmdid;
879         u32 set_arp_ns_offload_cmdid;
880         u32 network_list_offload_config_cmdid;
881         u32 gtk_offload_cmdid;
882         u32 csa_offload_enable_cmdid;
883         u32 csa_offload_chanswitch_cmdid;
884         u32 chatter_set_mode_cmdid;
885         u32 peer_tid_addba_cmdid;
886         u32 peer_tid_delba_cmdid;
887         u32 sta_dtim_ps_method_cmdid;
888         u32 sta_uapsd_auto_trig_cmdid;
889         u32 sta_keepalive_cmd;
890         u32 echo_cmdid;
891         u32 pdev_utf_cmdid;
892         u32 dbglog_cfg_cmdid;
893         u32 pdev_qvit_cmdid;
894         u32 pdev_ftm_intg_cmdid;
895         u32 vdev_set_keepalive_cmdid;
896         u32 vdev_get_keepalive_cmdid;
897         u32 force_fw_hang_cmdid;
898         u32 gpio_config_cmdid;
899         u32 gpio_output_cmdid;
900         u32 pdev_get_temperature_cmdid;
901         u32 vdev_set_wmm_params_cmdid;
902         u32 tdls_set_state_cmdid;
903         u32 tdls_peer_update_cmdid;
904         u32 adaptive_qcs_cmdid;
905         u32 scan_update_request_cmdid;
906         u32 vdev_standby_response_cmdid;
907         u32 vdev_resume_response_cmdid;
908         u32 wlan_peer_caching_add_peer_cmdid;
909         u32 wlan_peer_caching_evict_peer_cmdid;
910         u32 wlan_peer_caching_restore_peer_cmdid;
911         u32 wlan_peer_caching_print_all_peers_info_cmdid;
912         u32 peer_update_wds_entry_cmdid;
913         u32 peer_add_proxy_sta_entry_cmdid;
914         u32 rtt_keepalive_cmdid;
915         u32 oem_req_cmdid;
916         u32 nan_cmdid;
917         u32 vdev_ratemask_cmdid;
918         u32 qboost_cfg_cmdid;
919         u32 pdev_smart_ant_enable_cmdid;
920         u32 pdev_smart_ant_set_rx_antenna_cmdid;
921         u32 peer_smart_ant_set_tx_antenna_cmdid;
922         u32 peer_smart_ant_set_train_info_cmdid;
923         u32 peer_smart_ant_set_node_config_ops_cmdid;
924         u32 pdev_set_antenna_switch_table_cmdid;
925         u32 pdev_set_ctl_table_cmdid;
926         u32 pdev_set_mimogain_table_cmdid;
927         u32 pdev_ratepwr_table_cmdid;
928         u32 pdev_ratepwr_chainmsk_table_cmdid;
929         u32 pdev_fips_cmdid;
930         u32 tt_set_conf_cmdid;
931         u32 fwtest_cmdid;
932         u32 vdev_atf_request_cmdid;
933         u32 peer_atf_request_cmdid;
934         u32 pdev_get_ani_cck_config_cmdid;
935         u32 pdev_get_ani_ofdm_config_cmdid;
936         u32 pdev_reserve_ast_entry_cmdid;
937         u32 pdev_get_nfcal_power_cmdid;
938         u32 pdev_get_tpc_cmdid;
939         u32 pdev_get_ast_info_cmdid;
940         u32 vdev_set_dscp_tid_map_cmdid;
941         u32 pdev_get_info_cmdid;
942         u32 vdev_get_info_cmdid;
943         u32 vdev_filter_neighbor_rx_packets_cmdid;
944         u32 mu_cal_start_cmdid;
945         u32 set_cca_params_cmdid;
946         u32 pdev_bss_chan_info_request_cmdid;
947         u32 pdev_enable_adaptive_cca_cmdid;
948         u32 ext_resource_cfg_cmdid;
949         u32 vdev_set_ie_cmdid;
950         u32 set_lteu_config_cmdid;
951         u32 atf_ssid_grouping_request_cmdid;
952         u32 peer_atf_ext_request_cmdid;
953         u32 set_periodic_channel_stats_cfg_cmdid;
954         u32 peer_bwf_request_cmdid;
955         u32 btcoex_cfg_cmdid;
956         u32 peer_tx_mu_txmit_count_cmdid;
957         u32 peer_tx_mu_txmit_rstcnt_cmdid;
958         u32 peer_gid_userpos_list_cmdid;
959         u32 pdev_check_cal_version_cmdid;
960         u32 coex_version_cfg_cmid;
961         u32 pdev_get_rx_filter_cmdid;
962         u32 pdev_extended_nss_cfg_cmdid;
963         u32 vdev_set_scan_nac_rssi_cmdid;
964         u32 prog_gpio_band_select_cmdid;
965         u32 config_smart_logging_cmdid;
966         u32 debug_fatal_condition_cmdid;
967         u32 get_tsf_timer_cmdid;
968         u32 pdev_get_tpc_table_cmdid;
969         u32 vdev_sifs_trigger_time_cmdid;
970         u32 pdev_wds_entry_list_cmdid;
971         u32 tdls_set_offchan_mode_cmdid;
972         u32 radar_found_cmdid;
973 };
974
975 /*
976  * wmi command groups.
977  */
978 enum wmi_cmd_group {
979         /* 0 to 2 are reserved */
980         WMI_GRP_START = 0x3,
981         WMI_GRP_SCAN = WMI_GRP_START,
982         WMI_GRP_PDEV,
983         WMI_GRP_VDEV,
984         WMI_GRP_PEER,
985         WMI_GRP_MGMT,
986         WMI_GRP_BA_NEG,
987         WMI_GRP_STA_PS,
988         WMI_GRP_DFS,
989         WMI_GRP_ROAM,
990         WMI_GRP_OFL_SCAN,
991         WMI_GRP_P2P,
992         WMI_GRP_AP_PS,
993         WMI_GRP_RATE_CTRL,
994         WMI_GRP_PROFILE,
995         WMI_GRP_SUSPEND,
996         WMI_GRP_BCN_FILTER,
997         WMI_GRP_WOW,
998         WMI_GRP_RTT,
999         WMI_GRP_SPECTRAL,
1000         WMI_GRP_STATS,
1001         WMI_GRP_ARP_NS_OFL,
1002         WMI_GRP_NLO_OFL,
1003         WMI_GRP_GTK_OFL,
1004         WMI_GRP_CSA_OFL,
1005         WMI_GRP_CHATTER,
1006         WMI_GRP_TID_ADDBA,
1007         WMI_GRP_MISC,
1008         WMI_GRP_GPIO,
1009 };
1010
1011 #define WMI_CMD_GRP(grp_id) (((grp_id) << 12) | 0x1)
1012 #define WMI_EVT_GRP_START_ID(grp_id) (((grp_id) << 12) | 0x1)
1013
1014 #define WMI_CMD_UNSUPPORTED 0
1015
1016 /* Command IDs and command events for MAIN FW. */
1017 enum wmi_cmd_id {
1018         WMI_INIT_CMDID = 0x1,
1019
1020         /* Scan specific commands */
1021         WMI_START_SCAN_CMDID = WMI_CMD_GRP(WMI_GRP_SCAN),
1022         WMI_STOP_SCAN_CMDID,
1023         WMI_SCAN_CHAN_LIST_CMDID,
1024         WMI_SCAN_SCH_PRIO_TBL_CMDID,
1025
1026         /* PDEV (physical device) specific commands */
1027         WMI_PDEV_SET_REGDOMAIN_CMDID = WMI_CMD_GRP(WMI_GRP_PDEV),
1028         WMI_PDEV_SET_CHANNEL_CMDID,
1029         WMI_PDEV_SET_PARAM_CMDID,
1030         WMI_PDEV_PKTLOG_ENABLE_CMDID,
1031         WMI_PDEV_PKTLOG_DISABLE_CMDID,
1032         WMI_PDEV_SET_WMM_PARAMS_CMDID,
1033         WMI_PDEV_SET_HT_CAP_IE_CMDID,
1034         WMI_PDEV_SET_VHT_CAP_IE_CMDID,
1035         WMI_PDEV_SET_DSCP_TID_MAP_CMDID,
1036         WMI_PDEV_SET_QUIET_MODE_CMDID,
1037         WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID,
1038         WMI_PDEV_GET_TPC_CONFIG_CMDID,
1039         WMI_PDEV_SET_BASE_MACADDR_CMDID,
1040
1041         /* VDEV (virtual device) specific commands */
1042         WMI_VDEV_CREATE_CMDID = WMI_CMD_GRP(WMI_GRP_VDEV),
1043         WMI_VDEV_DELETE_CMDID,
1044         WMI_VDEV_START_REQUEST_CMDID,
1045         WMI_VDEV_RESTART_REQUEST_CMDID,
1046         WMI_VDEV_UP_CMDID,
1047         WMI_VDEV_STOP_CMDID,
1048         WMI_VDEV_DOWN_CMDID,
1049         WMI_VDEV_SET_PARAM_CMDID,
1050         WMI_VDEV_INSTALL_KEY_CMDID,
1051
1052         /* peer specific commands */
1053         WMI_PEER_CREATE_CMDID = WMI_CMD_GRP(WMI_GRP_PEER),
1054         WMI_PEER_DELETE_CMDID,
1055         WMI_PEER_FLUSH_TIDS_CMDID,
1056         WMI_PEER_SET_PARAM_CMDID,
1057         WMI_PEER_ASSOC_CMDID,
1058         WMI_PEER_ADD_WDS_ENTRY_CMDID,
1059         WMI_PEER_REMOVE_WDS_ENTRY_CMDID,
1060         WMI_PEER_MCAST_GROUP_CMDID,
1061
1062         /* beacon/management specific commands */
1063         WMI_BCN_TX_CMDID = WMI_CMD_GRP(WMI_GRP_MGMT),
1064         WMI_PDEV_SEND_BCN_CMDID,
1065         WMI_BCN_TMPL_CMDID,
1066         WMI_BCN_FILTER_RX_CMDID,
1067         WMI_PRB_REQ_FILTER_RX_CMDID,
1068         WMI_MGMT_TX_CMDID,
1069         WMI_PRB_TMPL_CMDID,
1070
1071         /* commands to directly control BA negotiation directly from host. */
1072         WMI_ADDBA_CLEAR_RESP_CMDID = WMI_CMD_GRP(WMI_GRP_BA_NEG),
1073         WMI_ADDBA_SEND_CMDID,
1074         WMI_ADDBA_STATUS_CMDID,
1075         WMI_DELBA_SEND_CMDID,
1076         WMI_ADDBA_SET_RESP_CMDID,
1077         WMI_SEND_SINGLEAMSDU_CMDID,
1078
1079         /* Station power save specific config */
1080         WMI_STA_POWERSAVE_MODE_CMDID = WMI_CMD_GRP(WMI_GRP_STA_PS),
1081         WMI_STA_POWERSAVE_PARAM_CMDID,
1082         WMI_STA_MIMO_PS_MODE_CMDID,
1083
1084         /** DFS-specific commands */
1085         WMI_PDEV_DFS_ENABLE_CMDID = WMI_CMD_GRP(WMI_GRP_DFS),
1086         WMI_PDEV_DFS_DISABLE_CMDID,
1087
1088         /* Roaming specific  commands */
1089         WMI_ROAM_SCAN_MODE = WMI_CMD_GRP(WMI_GRP_ROAM),
1090         WMI_ROAM_SCAN_RSSI_THRESHOLD,
1091         WMI_ROAM_SCAN_PERIOD,
1092         WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
1093         WMI_ROAM_AP_PROFILE,
1094
1095         /* offload scan specific commands */
1096         WMI_OFL_SCAN_ADD_AP_PROFILE = WMI_CMD_GRP(WMI_GRP_OFL_SCAN),
1097         WMI_OFL_SCAN_REMOVE_AP_PROFILE,
1098         WMI_OFL_SCAN_PERIOD,
1099
1100         /* P2P specific commands */
1101         WMI_P2P_DEV_SET_DEVICE_INFO = WMI_CMD_GRP(WMI_GRP_P2P),
1102         WMI_P2P_DEV_SET_DISCOVERABILITY,
1103         WMI_P2P_GO_SET_BEACON_IE,
1104         WMI_P2P_GO_SET_PROBE_RESP_IE,
1105         WMI_P2P_SET_VENDOR_IE_DATA_CMDID,
1106
1107         /* AP power save specific config */
1108         WMI_AP_PS_PEER_PARAM_CMDID = WMI_CMD_GRP(WMI_GRP_AP_PS),
1109         WMI_AP_PS_PEER_UAPSD_COEX_CMDID,
1110
1111         /* Rate-control specific commands */
1112         WMI_PEER_RATE_RETRY_SCHED_CMDID =
1113         WMI_CMD_GRP(WMI_GRP_RATE_CTRL),
1114
1115         /* WLAN Profiling commands. */
1116         WMI_WLAN_PROFILE_TRIGGER_CMDID = WMI_CMD_GRP(WMI_GRP_PROFILE),
1117         WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1118         WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1119         WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1120         WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1121
1122         /* Suspend resume command Ids */
1123         WMI_PDEV_SUSPEND_CMDID = WMI_CMD_GRP(WMI_GRP_SUSPEND),
1124         WMI_PDEV_RESUME_CMDID,
1125
1126         /* Beacon filter commands */
1127         WMI_ADD_BCN_FILTER_CMDID = WMI_CMD_GRP(WMI_GRP_BCN_FILTER),
1128         WMI_RMV_BCN_FILTER_CMDID,
1129
1130         /* WOW Specific WMI commands*/
1131         WMI_WOW_ADD_WAKE_PATTERN_CMDID = WMI_CMD_GRP(WMI_GRP_WOW),
1132         WMI_WOW_DEL_WAKE_PATTERN_CMDID,
1133         WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
1134         WMI_WOW_ENABLE_CMDID,
1135         WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
1136
1137         /* RTT measurement related cmd */
1138         WMI_RTT_MEASREQ_CMDID = WMI_CMD_GRP(WMI_GRP_RTT),
1139         WMI_RTT_TSF_CMDID,
1140
1141         /* spectral scan commands */
1142         WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID = WMI_CMD_GRP(WMI_GRP_SPECTRAL),
1143         WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
1144
1145         /* F/W stats */
1146         WMI_REQUEST_STATS_CMDID = WMI_CMD_GRP(WMI_GRP_STATS),
1147
1148         /* ARP OFFLOAD REQUEST*/
1149         WMI_SET_ARP_NS_OFFLOAD_CMDID = WMI_CMD_GRP(WMI_GRP_ARP_NS_OFL),
1150
1151         /* NS offload confid*/
1152         WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID = WMI_CMD_GRP(WMI_GRP_NLO_OFL),
1153
1154         /* GTK offload Specific WMI commands*/
1155         WMI_GTK_OFFLOAD_CMDID = WMI_CMD_GRP(WMI_GRP_GTK_OFL),
1156
1157         /* CSA offload Specific WMI commands*/
1158         WMI_CSA_OFFLOAD_ENABLE_CMDID = WMI_CMD_GRP(WMI_GRP_CSA_OFL),
1159         WMI_CSA_OFFLOAD_CHANSWITCH_CMDID,
1160
1161         /* Chatter commands*/
1162         WMI_CHATTER_SET_MODE_CMDID = WMI_CMD_GRP(WMI_GRP_CHATTER),
1163
1164         /* addba specific commands */
1165         WMI_PEER_TID_ADDBA_CMDID = WMI_CMD_GRP(WMI_GRP_TID_ADDBA),
1166         WMI_PEER_TID_DELBA_CMDID,
1167
1168         /* set station mimo powersave method */
1169         WMI_STA_DTIM_PS_METHOD_CMDID,
1170         /* Configure the Station UAPSD AC Auto Trigger Parameters */
1171         WMI_STA_UAPSD_AUTO_TRIG_CMDID,
1172
1173         /* STA Keep alive parameter configuration,
1174          * Requires WMI_SERVICE_STA_KEEP_ALIVE
1175          */
1176         WMI_STA_KEEPALIVE_CMD,
1177
1178         /* misc command group */
1179         WMI_ECHO_CMDID = WMI_CMD_GRP(WMI_GRP_MISC),
1180         WMI_PDEV_UTF_CMDID,
1181         WMI_DBGLOG_CFG_CMDID,
1182         WMI_PDEV_QVIT_CMDID,
1183         WMI_PDEV_FTM_INTG_CMDID,
1184         WMI_VDEV_SET_KEEPALIVE_CMDID,
1185         WMI_VDEV_GET_KEEPALIVE_CMDID,
1186         WMI_FORCE_FW_HANG_CMDID,
1187
1188         /* GPIO Configuration */
1189         WMI_GPIO_CONFIG_CMDID = WMI_CMD_GRP(WMI_GRP_GPIO),
1190         WMI_GPIO_OUTPUT_CMDID,
1191 };
1192
1193 enum wmi_event_id {
1194         WMI_SERVICE_READY_EVENTID = 0x1,
1195         WMI_READY_EVENTID,
1196         WMI_SERVICE_AVAILABLE_EVENTID,
1197
1198         /* Scan specific events */
1199         WMI_SCAN_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_SCAN),
1200
1201         /* PDEV specific events */
1202         WMI_PDEV_TPC_CONFIG_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_PDEV),
1203         WMI_CHAN_INFO_EVENTID,
1204         WMI_PHYERR_EVENTID,
1205
1206         /* VDEV specific events */
1207         WMI_VDEV_START_RESP_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_VDEV),
1208         WMI_VDEV_STOPPED_EVENTID,
1209         WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID,
1210
1211         /* peer specific events */
1212         WMI_PEER_STA_KICKOUT_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_PEER),
1213
1214         /* beacon/mgmt specific events */
1215         WMI_MGMT_RX_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_MGMT),
1216         WMI_HOST_SWBA_EVENTID,
1217         WMI_TBTTOFFSET_UPDATE_EVENTID,
1218
1219         /* ADDBA Related WMI Events*/
1220         WMI_TX_DELBA_COMPLETE_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_BA_NEG),
1221         WMI_TX_ADDBA_COMPLETE_EVENTID,
1222
1223         /* Roam event to trigger roaming on host */
1224         WMI_ROAM_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_ROAM),
1225         WMI_PROFILE_MATCH,
1226
1227         /* WoW */
1228         WMI_WOW_WAKEUP_HOST_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_WOW),
1229
1230         /* RTT */
1231         WMI_RTT_MEASUREMENT_REPORT_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_RTT),
1232         WMI_TSF_MEASUREMENT_REPORT_EVENTID,
1233         WMI_RTT_ERROR_REPORT_EVENTID,
1234
1235         /* GTK offload */
1236         WMI_GTK_OFFLOAD_STATUS_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_GTK_OFL),
1237         WMI_GTK_REKEY_FAIL_EVENTID,
1238
1239         /* CSA IE received event */
1240         WMI_CSA_HANDLING_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_CSA_OFL),
1241
1242         /* Misc events */
1243         WMI_ECHO_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_MISC),
1244         WMI_PDEV_UTF_EVENTID,
1245         WMI_DEBUG_MESG_EVENTID,
1246         WMI_UPDATE_STATS_EVENTID,
1247         WMI_DEBUG_PRINT_EVENTID,
1248         WMI_DCS_INTERFERENCE_EVENTID,
1249         WMI_PDEV_QVIT_EVENTID,
1250         WMI_WLAN_PROFILE_DATA_EVENTID,
1251         WMI_PDEV_FTM_INTG_EVENTID,
1252         WMI_WLAN_FREQ_AVOID_EVENTID,
1253         WMI_VDEV_GET_KEEPALIVE_EVENTID,
1254
1255         /* GPIO Event */
1256         WMI_GPIO_INPUT_EVENTID = WMI_EVT_GRP_START_ID(WMI_GRP_GPIO),
1257 };
1258
1259 /* Command IDs and command events for 10.X firmware */
1260 enum wmi_10x_cmd_id {
1261         WMI_10X_START_CMDID = 0x9000,
1262         WMI_10X_END_CMDID = 0x9FFF,
1263
1264         /* initialize the wlan sub system */
1265         WMI_10X_INIT_CMDID,
1266
1267         /* Scan specific commands */
1268
1269         WMI_10X_START_SCAN_CMDID = WMI_10X_START_CMDID,
1270         WMI_10X_STOP_SCAN_CMDID,
1271         WMI_10X_SCAN_CHAN_LIST_CMDID,
1272         WMI_10X_ECHO_CMDID,
1273
1274         /* PDEV(physical device) specific commands */
1275         WMI_10X_PDEV_SET_REGDOMAIN_CMDID,
1276         WMI_10X_PDEV_SET_CHANNEL_CMDID,
1277         WMI_10X_PDEV_SET_PARAM_CMDID,
1278         WMI_10X_PDEV_PKTLOG_ENABLE_CMDID,
1279         WMI_10X_PDEV_PKTLOG_DISABLE_CMDID,
1280         WMI_10X_PDEV_SET_WMM_PARAMS_CMDID,
1281         WMI_10X_PDEV_SET_HT_CAP_IE_CMDID,
1282         WMI_10X_PDEV_SET_VHT_CAP_IE_CMDID,
1283         WMI_10X_PDEV_SET_BASE_MACADDR_CMDID,
1284         WMI_10X_PDEV_SET_DSCP_TID_MAP_CMDID,
1285         WMI_10X_PDEV_SET_QUIET_MODE_CMDID,
1286         WMI_10X_PDEV_GREEN_AP_PS_ENABLE_CMDID,
1287         WMI_10X_PDEV_GET_TPC_CONFIG_CMDID,
1288
1289         /* VDEV(virtual device) specific commands */
1290         WMI_10X_VDEV_CREATE_CMDID,
1291         WMI_10X_VDEV_DELETE_CMDID,
1292         WMI_10X_VDEV_START_REQUEST_CMDID,
1293         WMI_10X_VDEV_RESTART_REQUEST_CMDID,
1294         WMI_10X_VDEV_UP_CMDID,
1295         WMI_10X_VDEV_STOP_CMDID,
1296         WMI_10X_VDEV_DOWN_CMDID,
1297         WMI_10X_VDEV_STANDBY_RESPONSE_CMDID,
1298         WMI_10X_VDEV_RESUME_RESPONSE_CMDID,
1299         WMI_10X_VDEV_SET_PARAM_CMDID,
1300         WMI_10X_VDEV_INSTALL_KEY_CMDID,
1301
1302         /* peer specific commands */
1303         WMI_10X_PEER_CREATE_CMDID,
1304         WMI_10X_PEER_DELETE_CMDID,
1305         WMI_10X_PEER_FLUSH_TIDS_CMDID,
1306         WMI_10X_PEER_SET_PARAM_CMDID,
1307         WMI_10X_PEER_ASSOC_CMDID,
1308         WMI_10X_PEER_ADD_WDS_ENTRY_CMDID,
1309         WMI_10X_PEER_REMOVE_WDS_ENTRY_CMDID,
1310         WMI_10X_PEER_MCAST_GROUP_CMDID,
1311
1312         /* beacon/management specific commands */
1313
1314         WMI_10X_BCN_TX_CMDID,
1315         WMI_10X_BCN_PRB_TMPL_CMDID,
1316         WMI_10X_BCN_FILTER_RX_CMDID,
1317         WMI_10X_PRB_REQ_FILTER_RX_CMDID,
1318         WMI_10X_MGMT_TX_CMDID,
1319
1320         /* commands to directly control ba negotiation directly from host. */
1321         WMI_10X_ADDBA_CLEAR_RESP_CMDID,
1322         WMI_10X_ADDBA_SEND_CMDID,
1323         WMI_10X_ADDBA_STATUS_CMDID,
1324         WMI_10X_DELBA_SEND_CMDID,
1325         WMI_10X_ADDBA_SET_RESP_CMDID,
1326         WMI_10X_SEND_SINGLEAMSDU_CMDID,
1327
1328         /* Station power save specific config */
1329         WMI_10X_STA_POWERSAVE_MODE_CMDID,
1330         WMI_10X_STA_POWERSAVE_PARAM_CMDID,
1331         WMI_10X_STA_MIMO_PS_MODE_CMDID,
1332
1333         /* set debug log config */
1334         WMI_10X_DBGLOG_CFG_CMDID,
1335
1336         /* DFS-specific commands */
1337         WMI_10X_PDEV_DFS_ENABLE_CMDID,
1338         WMI_10X_PDEV_DFS_DISABLE_CMDID,
1339
1340         /* QVIT specific command id */
1341         WMI_10X_PDEV_QVIT_CMDID,
1342
1343         /* Offload Scan and Roaming related  commands */
1344         WMI_10X_ROAM_SCAN_MODE,
1345         WMI_10X_ROAM_SCAN_RSSI_THRESHOLD,
1346         WMI_10X_ROAM_SCAN_PERIOD,
1347         WMI_10X_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
1348         WMI_10X_ROAM_AP_PROFILE,
1349         WMI_10X_OFL_SCAN_ADD_AP_PROFILE,
1350         WMI_10X_OFL_SCAN_REMOVE_AP_PROFILE,
1351         WMI_10X_OFL_SCAN_PERIOD,
1352
1353         /* P2P specific commands */
1354         WMI_10X_P2P_DEV_SET_DEVICE_INFO,
1355         WMI_10X_P2P_DEV_SET_DISCOVERABILITY,
1356         WMI_10X_P2P_GO_SET_BEACON_IE,
1357         WMI_10X_P2P_GO_SET_PROBE_RESP_IE,
1358
1359         /* AP power save specific config */
1360         WMI_10X_AP_PS_PEER_PARAM_CMDID,
1361         WMI_10X_AP_PS_PEER_UAPSD_COEX_CMDID,
1362
1363         /* Rate-control specific commands */
1364         WMI_10X_PEER_RATE_RETRY_SCHED_CMDID,
1365
1366         /* WLAN Profiling commands. */
1367         WMI_10X_WLAN_PROFILE_TRIGGER_CMDID,
1368         WMI_10X_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1369         WMI_10X_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1370         WMI_10X_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1371         WMI_10X_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1372
1373         /* Suspend resume command Ids */
1374         WMI_10X_PDEV_SUSPEND_CMDID,
1375         WMI_10X_PDEV_RESUME_CMDID,
1376
1377         /* Beacon filter commands */
1378         WMI_10X_ADD_BCN_FILTER_CMDID,
1379         WMI_10X_RMV_BCN_FILTER_CMDID,
1380
1381         /* WOW Specific WMI commands*/
1382         WMI_10X_WOW_ADD_WAKE_PATTERN_CMDID,
1383         WMI_10X_WOW_DEL_WAKE_PATTERN_CMDID,
1384         WMI_10X_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
1385         WMI_10X_WOW_ENABLE_CMDID,
1386         WMI_10X_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
1387
1388         /* RTT measurement related cmd */
1389         WMI_10X_RTT_MEASREQ_CMDID,
1390         WMI_10X_RTT_TSF_CMDID,
1391
1392         /* transmit beacon by value */
1393         WMI_10X_PDEV_SEND_BCN_CMDID,
1394
1395         /* F/W stats */
1396         WMI_10X_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
1397         WMI_10X_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
1398         WMI_10X_REQUEST_STATS_CMDID,
1399
1400         /* GPIO Configuration */
1401         WMI_10X_GPIO_CONFIG_CMDID,
1402         WMI_10X_GPIO_OUTPUT_CMDID,
1403
1404         WMI_10X_PDEV_UTF_CMDID = WMI_10X_END_CMDID - 1,
1405 };
1406
1407 enum wmi_10x_event_id {
1408         WMI_10X_SERVICE_READY_EVENTID = 0x8000,
1409         WMI_10X_READY_EVENTID,
1410         WMI_10X_START_EVENTID = 0x9000,
1411         WMI_10X_END_EVENTID = 0x9FFF,
1412
1413         /* Scan specific events */
1414         WMI_10X_SCAN_EVENTID = WMI_10X_START_EVENTID,
1415         WMI_10X_ECHO_EVENTID,
1416         WMI_10X_DEBUG_MESG_EVENTID,
1417         WMI_10X_UPDATE_STATS_EVENTID,
1418
1419         /* Instantaneous RSSI event */
1420         WMI_10X_INST_RSSI_STATS_EVENTID,
1421
1422         /* VDEV specific events */
1423         WMI_10X_VDEV_START_RESP_EVENTID,
1424         WMI_10X_VDEV_STANDBY_REQ_EVENTID,
1425         WMI_10X_VDEV_RESUME_REQ_EVENTID,
1426         WMI_10X_VDEV_STOPPED_EVENTID,
1427
1428         /* peer  specific events */
1429         WMI_10X_PEER_STA_KICKOUT_EVENTID,
1430
1431         /* beacon/mgmt specific events */
1432         WMI_10X_HOST_SWBA_EVENTID,
1433         WMI_10X_TBTTOFFSET_UPDATE_EVENTID,
1434         WMI_10X_MGMT_RX_EVENTID,
1435
1436         /* Channel stats event */
1437         WMI_10X_CHAN_INFO_EVENTID,
1438
1439         /* PHY Error specific WMI event */
1440         WMI_10X_PHYERR_EVENTID,
1441
1442         /* Roam event to trigger roaming on host */
1443         WMI_10X_ROAM_EVENTID,
1444
1445         /* matching AP found from list of profiles */
1446         WMI_10X_PROFILE_MATCH,
1447
1448         /* debug print message used for tracing FW code while debugging */
1449         WMI_10X_DEBUG_PRINT_EVENTID,
1450         /* VI spoecific event */
1451         WMI_10X_PDEV_QVIT_EVENTID,
1452         /* FW code profile data in response to profile request */
1453         WMI_10X_WLAN_PROFILE_DATA_EVENTID,
1454
1455         /*RTT related event ID*/
1456         WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID,
1457         WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID,
1458         WMI_10X_RTT_ERROR_REPORT_EVENTID,
1459
1460         WMI_10X_WOW_WAKEUP_HOST_EVENTID,
1461         WMI_10X_DCS_INTERFERENCE_EVENTID,
1462
1463         /* TPC config for the current operating channel */
1464         WMI_10X_PDEV_TPC_CONFIG_EVENTID,
1465
1466         WMI_10X_GPIO_INPUT_EVENTID,
1467         WMI_10X_PDEV_UTF_EVENTID = WMI_10X_END_EVENTID - 1,
1468 };
1469
1470 enum wmi_10_2_cmd_id {
1471         WMI_10_2_START_CMDID = 0x9000,
1472         WMI_10_2_END_CMDID = 0x9FFF,
1473         WMI_10_2_INIT_CMDID,
1474         WMI_10_2_START_SCAN_CMDID = WMI_10_2_START_CMDID,
1475         WMI_10_2_STOP_SCAN_CMDID,
1476         WMI_10_2_SCAN_CHAN_LIST_CMDID,
1477         WMI_10_2_ECHO_CMDID,
1478         WMI_10_2_PDEV_SET_REGDOMAIN_CMDID,
1479         WMI_10_2_PDEV_SET_CHANNEL_CMDID,
1480         WMI_10_2_PDEV_SET_PARAM_CMDID,
1481         WMI_10_2_PDEV_PKTLOG_ENABLE_CMDID,
1482         WMI_10_2_PDEV_PKTLOG_DISABLE_CMDID,
1483         WMI_10_2_PDEV_SET_WMM_PARAMS_CMDID,
1484         WMI_10_2_PDEV_SET_HT_CAP_IE_CMDID,
1485         WMI_10_2_PDEV_SET_VHT_CAP_IE_CMDID,
1486         WMI_10_2_PDEV_SET_BASE_MACADDR_CMDID,
1487         WMI_10_2_PDEV_SET_QUIET_MODE_CMDID,
1488         WMI_10_2_PDEV_GREEN_AP_PS_ENABLE_CMDID,
1489         WMI_10_2_PDEV_GET_TPC_CONFIG_CMDID,
1490         WMI_10_2_VDEV_CREATE_CMDID,
1491         WMI_10_2_VDEV_DELETE_CMDID,
1492         WMI_10_2_VDEV_START_REQUEST_CMDID,
1493         WMI_10_2_VDEV_RESTART_REQUEST_CMDID,
1494         WMI_10_2_VDEV_UP_CMDID,
1495         WMI_10_2_VDEV_STOP_CMDID,
1496         WMI_10_2_VDEV_DOWN_CMDID,
1497         WMI_10_2_VDEV_STANDBY_RESPONSE_CMDID,
1498         WMI_10_2_VDEV_RESUME_RESPONSE_CMDID,
1499         WMI_10_2_VDEV_SET_PARAM_CMDID,
1500         WMI_10_2_VDEV_INSTALL_KEY_CMDID,
1501         WMI_10_2_VDEV_SET_DSCP_TID_MAP_CMDID,
1502         WMI_10_2_PEER_CREATE_CMDID,
1503         WMI_10_2_PEER_DELETE_CMDID,
1504         WMI_10_2_PEER_FLUSH_TIDS_CMDID,
1505         WMI_10_2_PEER_SET_PARAM_CMDID,
1506         WMI_10_2_PEER_ASSOC_CMDID,
1507         WMI_10_2_PEER_ADD_WDS_ENTRY_CMDID,
1508         WMI_10_2_PEER_UPDATE_WDS_ENTRY_CMDID,
1509         WMI_10_2_PEER_REMOVE_WDS_ENTRY_CMDID,
1510         WMI_10_2_PEER_MCAST_GROUP_CMDID,
1511         WMI_10_2_BCN_TX_CMDID,
1512         WMI_10_2_BCN_PRB_TMPL_CMDID,
1513         WMI_10_2_BCN_FILTER_RX_CMDID,
1514         WMI_10_2_PRB_REQ_FILTER_RX_CMDID,
1515         WMI_10_2_MGMT_TX_CMDID,
1516         WMI_10_2_ADDBA_CLEAR_RESP_CMDID,
1517         WMI_10_2_ADDBA_SEND_CMDID,
1518         WMI_10_2_ADDBA_STATUS_CMDID,
1519         WMI_10_2_DELBA_SEND_CMDID,
1520         WMI_10_2_ADDBA_SET_RESP_CMDID,
1521         WMI_10_2_SEND_SINGLEAMSDU_CMDID,
1522         WMI_10_2_STA_POWERSAVE_MODE_CMDID,
1523         WMI_10_2_STA_POWERSAVE_PARAM_CMDID,
1524         WMI_10_2_STA_MIMO_PS_MODE_CMDID,
1525         WMI_10_2_DBGLOG_CFG_CMDID,
1526         WMI_10_2_PDEV_DFS_ENABLE_CMDID,
1527         WMI_10_2_PDEV_DFS_DISABLE_CMDID,
1528         WMI_10_2_PDEV_QVIT_CMDID,
1529         WMI_10_2_ROAM_SCAN_MODE,
1530         WMI_10_2_ROAM_SCAN_RSSI_THRESHOLD,
1531         WMI_10_2_ROAM_SCAN_PERIOD,
1532         WMI_10_2_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
1533         WMI_10_2_ROAM_AP_PROFILE,
1534         WMI_10_2_OFL_SCAN_ADD_AP_PROFILE,
1535         WMI_10_2_OFL_SCAN_REMOVE_AP_PROFILE,
1536         WMI_10_2_OFL_SCAN_PERIOD,
1537         WMI_10_2_P2P_DEV_SET_DEVICE_INFO,
1538         WMI_10_2_P2P_DEV_SET_DISCOVERABILITY,
1539         WMI_10_2_P2P_GO_SET_BEACON_IE,
1540         WMI_10_2_P2P_GO_SET_PROBE_RESP_IE,
1541         WMI_10_2_AP_PS_PEER_PARAM_CMDID,
1542         WMI_10_2_AP_PS_PEER_UAPSD_COEX_CMDID,
1543         WMI_10_2_PEER_RATE_RETRY_SCHED_CMDID,
1544         WMI_10_2_WLAN_PROFILE_TRIGGER_CMDID,
1545         WMI_10_2_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1546         WMI_10_2_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1547         WMI_10_2_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1548         WMI_10_2_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1549         WMI_10_2_PDEV_SUSPEND_CMDID,
1550         WMI_10_2_PDEV_RESUME_CMDID,
1551         WMI_10_2_ADD_BCN_FILTER_CMDID,
1552         WMI_10_2_RMV_BCN_FILTER_CMDID,
1553         WMI_10_2_WOW_ADD_WAKE_PATTERN_CMDID,
1554         WMI_10_2_WOW_DEL_WAKE_PATTERN_CMDID,
1555         WMI_10_2_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
1556         WMI_10_2_WOW_ENABLE_CMDID,
1557         WMI_10_2_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
1558         WMI_10_2_RTT_MEASREQ_CMDID,
1559         WMI_10_2_RTT_TSF_CMDID,
1560         WMI_10_2_RTT_KEEPALIVE_CMDID,
1561         WMI_10_2_PDEV_SEND_BCN_CMDID,
1562         WMI_10_2_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
1563         WMI_10_2_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
1564         WMI_10_2_REQUEST_STATS_CMDID,
1565         WMI_10_2_GPIO_CONFIG_CMDID,
1566         WMI_10_2_GPIO_OUTPUT_CMDID,
1567         WMI_10_2_VDEV_RATEMASK_CMDID,
1568         WMI_10_2_PDEV_SMART_ANT_ENABLE_CMDID,
1569         WMI_10_2_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID,
1570         WMI_10_2_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID,
1571         WMI_10_2_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID,
1572         WMI_10_2_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID,
1573         WMI_10_2_FORCE_FW_HANG_CMDID,
1574         WMI_10_2_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID,
1575         WMI_10_2_PDEV_SET_CTL_TABLE_CMDID,
1576         WMI_10_2_PDEV_SET_MIMOGAIN_TABLE_CMDID,
1577         WMI_10_2_PDEV_RATEPWR_TABLE_CMDID,
1578         WMI_10_2_PDEV_RATEPWR_CHAINMSK_TABLE_CMDID,
1579         WMI_10_2_PDEV_GET_INFO,
1580         WMI_10_2_VDEV_GET_INFO,
1581         WMI_10_2_VDEV_ATF_REQUEST_CMDID,
1582         WMI_10_2_PEER_ATF_REQUEST_CMDID,
1583         WMI_10_2_PDEV_GET_TEMPERATURE_CMDID,
1584         WMI_10_2_MU_CAL_START_CMDID,
1585         WMI_10_2_SET_LTEU_CONFIG_CMDID,
1586         WMI_10_2_SET_CCA_PARAMS,
1587         WMI_10_2_PDEV_BSS_CHAN_INFO_REQUEST_CMDID,
1588         WMI_10_2_PDEV_UTF_CMDID = WMI_10_2_END_CMDID - 1,
1589 };
1590
1591 enum wmi_10_2_event_id {
1592         WMI_10_2_SERVICE_READY_EVENTID = 0x8000,
1593         WMI_10_2_READY_EVENTID,
1594         WMI_10_2_DEBUG_MESG_EVENTID,
1595         WMI_10_2_START_EVENTID = 0x9000,
1596         WMI_10_2_END_EVENTID = 0x9FFF,
1597         WMI_10_2_SCAN_EVENTID = WMI_10_2_START_EVENTID,
1598         WMI_10_2_ECHO_EVENTID,
1599         WMI_10_2_UPDATE_STATS_EVENTID,
1600         WMI_10_2_INST_RSSI_STATS_EVENTID,
1601         WMI_10_2_VDEV_START_RESP_EVENTID,
1602         WMI_10_2_VDEV_STANDBY_REQ_EVENTID,
1603         WMI_10_2_VDEV_RESUME_REQ_EVENTID,
1604         WMI_10_2_VDEV_STOPPED_EVENTID,
1605         WMI_10_2_PEER_STA_KICKOUT_EVENTID,
1606         WMI_10_2_HOST_SWBA_EVENTID,
1607         WMI_10_2_TBTTOFFSET_UPDATE_EVENTID,
1608         WMI_10_2_MGMT_RX_EVENTID,
1609         WMI_10_2_CHAN_INFO_EVENTID,
1610         WMI_10_2_PHYERR_EVENTID,
1611         WMI_10_2_ROAM_EVENTID,
1612         WMI_10_2_PROFILE_MATCH,
1613         WMI_10_2_DEBUG_PRINT_EVENTID,
1614         WMI_10_2_PDEV_QVIT_EVENTID,
1615         WMI_10_2_WLAN_PROFILE_DATA_EVENTID,
1616         WMI_10_2_RTT_MEASUREMENT_REPORT_EVENTID,
1617         WMI_10_2_TSF_MEASUREMENT_REPORT_EVENTID,
1618         WMI_10_2_RTT_ERROR_REPORT_EVENTID,
1619         WMI_10_2_RTT_KEEPALIVE_EVENTID,
1620         WMI_10_2_WOW_WAKEUP_HOST_EVENTID,
1621         WMI_10_2_DCS_INTERFERENCE_EVENTID,
1622         WMI_10_2_PDEV_TPC_CONFIG_EVENTID,
1623         WMI_10_2_GPIO_INPUT_EVENTID,
1624         WMI_10_2_PEER_RATECODE_LIST_EVENTID,
1625         WMI_10_2_GENERIC_BUFFER_EVENTID,
1626         WMI_10_2_MCAST_BUF_RELEASE_EVENTID,
1627         WMI_10_2_MCAST_LIST_AGEOUT_EVENTID,
1628         WMI_10_2_WDS_PEER_EVENTID,
1629         WMI_10_2_PEER_STA_PS_STATECHG_EVENTID,
1630         WMI_10_2_PDEV_TEMPERATURE_EVENTID,
1631         WMI_10_2_MU_REPORT_EVENTID,
1632         WMI_10_2_PDEV_BSS_CHAN_INFO_EVENTID,
1633         WMI_10_2_PDEV_UTF_EVENTID = WMI_10_2_END_EVENTID - 1,
1634 };
1635
1636 enum wmi_10_4_cmd_id {
1637         WMI_10_4_START_CMDID = 0x9000,
1638         WMI_10_4_END_CMDID = 0x9FFF,
1639         WMI_10_4_INIT_CMDID,
1640         WMI_10_4_START_SCAN_CMDID = WMI_10_4_START_CMDID,
1641         WMI_10_4_STOP_SCAN_CMDID,
1642         WMI_10_4_SCAN_CHAN_LIST_CMDID,
1643         WMI_10_4_SCAN_SCH_PRIO_TBL_CMDID,
1644         WMI_10_4_SCAN_UPDATE_REQUEST_CMDID,
1645         WMI_10_4_ECHO_CMDID,
1646         WMI_10_4_PDEV_SET_REGDOMAIN_CMDID,
1647         WMI_10_4_PDEV_SET_CHANNEL_CMDID,
1648         WMI_10_4_PDEV_SET_PARAM_CMDID,
1649         WMI_10_4_PDEV_PKTLOG_ENABLE_CMDID,
1650         WMI_10_4_PDEV_PKTLOG_DISABLE_CMDID,
1651         WMI_10_4_PDEV_SET_WMM_PARAMS_CMDID,
1652         WMI_10_4_PDEV_SET_HT_CAP_IE_CMDID,
1653         WMI_10_4_PDEV_SET_VHT_CAP_IE_CMDID,
1654         WMI_10_4_PDEV_SET_BASE_MACADDR_CMDID,
1655         WMI_10_4_PDEV_SET_DSCP_TID_MAP_CMDID,
1656         WMI_10_4_PDEV_SET_QUIET_MODE_CMDID,
1657         WMI_10_4_PDEV_GREEN_AP_PS_ENABLE_CMDID,
1658         WMI_10_4_PDEV_GET_TPC_CONFIG_CMDID,
1659         WMI_10_4_VDEV_CREATE_CMDID,
1660         WMI_10_4_VDEV_DELETE_CMDID,
1661         WMI_10_4_VDEV_START_REQUEST_CMDID,
1662         WMI_10_4_VDEV_RESTART_REQUEST_CMDID,
1663         WMI_10_4_VDEV_UP_CMDID,
1664         WMI_10_4_VDEV_STOP_CMDID,
1665         WMI_10_4_VDEV_DOWN_CMDID,
1666         WMI_10_4_VDEV_STANDBY_RESPONSE_CMDID,
1667         WMI_10_4_VDEV_RESUME_RESPONSE_CMDID,
1668         WMI_10_4_VDEV_SET_PARAM_CMDID,
1669         WMI_10_4_VDEV_INSTALL_KEY_CMDID,
1670         WMI_10_4_WLAN_PEER_CACHING_ADD_PEER_CMDID,
1671         WMI_10_4_WLAN_PEER_CACHING_EVICT_PEER_CMDID,
1672         WMI_10_4_WLAN_PEER_CACHING_RESTORE_PEER_CMDID,
1673         WMI_10_4_WLAN_PEER_CACHING_PRINT_ALL_PEERS_INFO_CMDID,
1674         WMI_10_4_PEER_CREATE_CMDID,
1675         WMI_10_4_PEER_DELETE_CMDID,
1676         WMI_10_4_PEER_FLUSH_TIDS_CMDID,
1677         WMI_10_4_PEER_SET_PARAM_CMDID,
1678         WMI_10_4_PEER_ASSOC_CMDID,
1679         WMI_10_4_PEER_ADD_WDS_ENTRY_CMDID,
1680         WMI_10_4_PEER_UPDATE_WDS_ENTRY_CMDID,
1681         WMI_10_4_PEER_REMOVE_WDS_ENTRY_CMDID,
1682         WMI_10_4_PEER_ADD_PROXY_STA_ENTRY_CMDID,
1683         WMI_10_4_PEER_MCAST_GROUP_CMDID,
1684         WMI_10_4_BCN_TX_CMDID,
1685         WMI_10_4_PDEV_SEND_BCN_CMDID,
1686         WMI_10_4_BCN_PRB_TMPL_CMDID,
1687         WMI_10_4_BCN_FILTER_RX_CMDID,
1688         WMI_10_4_PRB_REQ_FILTER_RX_CMDID,
1689         WMI_10_4_MGMT_TX_CMDID,
1690         WMI_10_4_PRB_TMPL_CMDID,
1691         WMI_10_4_ADDBA_CLEAR_RESP_CMDID,
1692         WMI_10_4_ADDBA_SEND_CMDID,
1693         WMI_10_4_ADDBA_STATUS_CMDID,
1694         WMI_10_4_DELBA_SEND_CMDID,
1695         WMI_10_4_ADDBA_SET_RESP_CMDID,
1696         WMI_10_4_SEND_SINGLEAMSDU_CMDID,
1697         WMI_10_4_STA_POWERSAVE_MODE_CMDID,
1698         WMI_10_4_STA_POWERSAVE_PARAM_CMDID,
1699         WMI_10_4_STA_MIMO_PS_MODE_CMDID,
1700         WMI_10_4_DBGLOG_CFG_CMDID,
1701         WMI_10_4_PDEV_DFS_ENABLE_CMDID,
1702         WMI_10_4_PDEV_DFS_DISABLE_CMDID,
1703         WMI_10_4_PDEV_QVIT_CMDID,
1704         WMI_10_4_ROAM_SCAN_MODE,
1705         WMI_10_4_ROAM_SCAN_RSSI_THRESHOLD,
1706         WMI_10_4_ROAM_SCAN_PERIOD,
1707         WMI_10_4_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
1708         WMI_10_4_ROAM_AP_PROFILE,
1709         WMI_10_4_OFL_SCAN_ADD_AP_PROFILE,
1710         WMI_10_4_OFL_SCAN_REMOVE_AP_PROFILE,
1711         WMI_10_4_OFL_SCAN_PERIOD,
1712         WMI_10_4_P2P_DEV_SET_DEVICE_INFO,
1713         WMI_10_4_P2P_DEV_SET_DISCOVERABILITY,
1714         WMI_10_4_P2P_GO_SET_BEACON_IE,
1715         WMI_10_4_P2P_GO_SET_PROBE_RESP_IE,
1716         WMI_10_4_P2P_SET_VENDOR_IE_DATA_CMDID,
1717         WMI_10_4_AP_PS_PEER_PARAM_CMDID,
1718         WMI_10_4_AP_PS_PEER_UAPSD_COEX_CMDID,
1719         WMI_10_4_PEER_RATE_RETRY_SCHED_CMDID,
1720         WMI_10_4_WLAN_PROFILE_TRIGGER_CMDID,
1721         WMI_10_4_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1722         WMI_10_4_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1723         WMI_10_4_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1724         WMI_10_4_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1725         WMI_10_4_PDEV_SUSPEND_CMDID,
1726         WMI_10_4_PDEV_RESUME_CMDID,
1727         WMI_10_4_ADD_BCN_FILTER_CMDID,
1728         WMI_10_4_RMV_BCN_FILTER_CMDID,
1729         WMI_10_4_WOW_ADD_WAKE_PATTERN_CMDID,
1730         WMI_10_4_WOW_DEL_WAKE_PATTERN_CMDID,
1731         WMI_10_4_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
1732         WMI_10_4_WOW_ENABLE_CMDID,
1733         WMI_10_4_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
1734         WMI_10_4_RTT_MEASREQ_CMDID,
1735         WMI_10_4_RTT_TSF_CMDID,
1736         WMI_10_4_RTT_KEEPALIVE_CMDID,
1737         WMI_10_4_OEM_REQ_CMDID,
1738         WMI_10_4_NAN_CMDID,
1739         WMI_10_4_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
1740         WMI_10_4_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
1741         WMI_10_4_REQUEST_STATS_CMDID,
1742         WMI_10_4_GPIO_CONFIG_CMDID,
1743         WMI_10_4_GPIO_OUTPUT_CMDID,
1744         WMI_10_4_VDEV_RATEMASK_CMDID,
1745         WMI_10_4_CSA_OFFLOAD_ENABLE_CMDID,
1746         WMI_10_4_GTK_OFFLOAD_CMDID,
1747         WMI_10_4_QBOOST_CFG_CMDID,
1748         WMI_10_4_CSA_OFFLOAD_CHANSWITCH_CMDID,
1749         WMI_10_4_PDEV_SMART_ANT_ENABLE_CMDID,
1750         WMI_10_4_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID,
1751         WMI_10_4_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID,
1752         WMI_10_4_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID,
1753         WMI_10_4_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID,
1754         WMI_10_4_VDEV_SET_KEEPALIVE_CMDID,
1755         WMI_10_4_VDEV_GET_KEEPALIVE_CMDID,
1756         WMI_10_4_FORCE_FW_HANG_CMDID,
1757         WMI_10_4_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID,
1758         WMI_10_4_PDEV_SET_CTL_TABLE_CMDID,
1759         WMI_10_4_PDEV_SET_MIMOGAIN_TABLE_CMDID,
1760         WMI_10_4_PDEV_RATEPWR_TABLE_CMDID,
1761         WMI_10_4_PDEV_RATEPWR_CHAINMSK_TABLE_CMDID,
1762         WMI_10_4_PDEV_FIPS_CMDID,
1763         WMI_10_4_TT_SET_CONF_CMDID,
1764         WMI_10_4_FWTEST_CMDID,
1765         WMI_10_4_VDEV_ATF_REQUEST_CMDID,
1766         WMI_10_4_PEER_ATF_REQUEST_CMDID,
1767         WMI_10_4_PDEV_GET_ANI_CCK_CONFIG_CMDID,
1768         WMI_10_4_PDEV_GET_ANI_OFDM_CONFIG_CMDID,
1769         WMI_10_4_PDEV_RESERVE_AST_ENTRY_CMDID,
1770         WMI_10_4_PDEV_GET_NFCAL_POWER_CMDID,
1771         WMI_10_4_PDEV_GET_TPC_CMDID,
1772         WMI_10_4_PDEV_GET_AST_INFO_CMDID,
1773         WMI_10_4_VDEV_SET_DSCP_TID_MAP_CMDID,
1774         WMI_10_4_PDEV_GET_TEMPERATURE_CMDID,
1775         WMI_10_4_PDEV_GET_INFO_CMDID,
1776         WMI_10_4_VDEV_GET_INFO_CMDID,
1777         WMI_10_4_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID,
1778         WMI_10_4_MU_CAL_START_CMDID,
1779         WMI_10_4_SET_CCA_PARAMS_CMDID,
1780         WMI_10_4_PDEV_BSS_CHAN_INFO_REQUEST_CMDID,
1781         WMI_10_4_EXT_RESOURCE_CFG_CMDID,
1782         WMI_10_4_VDEV_SET_IE_CMDID,
1783         WMI_10_4_SET_LTEU_CONFIG_CMDID,
1784         WMI_10_4_ATF_SSID_GROUPING_REQUEST_CMDID,
1785         WMI_10_4_PEER_ATF_EXT_REQUEST_CMDID,
1786         WMI_10_4_SET_PERIODIC_CHANNEL_STATS_CONFIG,
1787         WMI_10_4_PEER_BWF_REQUEST_CMDID,
1788         WMI_10_4_BTCOEX_CFG_CMDID,
1789         WMI_10_4_PEER_TX_MU_TXMIT_COUNT_CMDID,
1790         WMI_10_4_PEER_TX_MU_TXMIT_RSTCNT_CMDID,
1791         WMI_10_4_PEER_GID_USERPOS_LIST_CMDID,
1792         WMI_10_4_PDEV_CHECK_CAL_VERSION_CMDID,
1793         WMI_10_4_COEX_VERSION_CFG_CMID,
1794         WMI_10_4_PDEV_GET_RX_FILTER_CMDID,
1795         WMI_10_4_PDEV_EXTENDED_NSS_CFG_CMDID,
1796         WMI_10_4_VDEV_SET_SCAN_NAC_RSSI_CMDID,
1797         WMI_10_4_PROG_GPIO_BAND_SELECT_CMDID,
1798         WMI_10_4_CONFIG_SMART_LOGGING_CMDID,
1799         WMI_10_4_DEBUG_FATAL_CONDITION_CMDID,
1800         WMI_10_4_GET_TSF_TIMER_CMDID,
1801         WMI_10_4_PDEV_GET_TPC_TABLE_CMDID,
1802         WMI_10_4_VDEV_SIFS_TRIGGER_TIME_CMDID,
1803         WMI_10_4_PDEV_WDS_ENTRY_LIST_CMDID,
1804         WMI_10_4_TDLS_SET_STATE_CMDID,
1805         WMI_10_4_TDLS_PEER_UPDATE_CMDID,
1806         WMI_10_4_TDLS_SET_OFFCHAN_MODE_CMDID,
1807         WMI_10_4_PDEV_SEND_FD_CMDID,
1808         WMI_10_4_ENABLE_FILS_CMDID,
1809         WMI_10_4_PDEV_SET_BRIDGE_MACADDR_CMDID,
1810         WMI_10_4_ATF_GROUP_WMM_AC_CONFIG_REQUEST_CMDID,
1811         WMI_10_4_RADAR_FOUND_CMDID,
1812         WMI_10_4_PDEV_UTF_CMDID = WMI_10_4_END_CMDID - 1,
1813 };
1814
1815 enum wmi_10_4_event_id {
1816         WMI_10_4_SERVICE_READY_EVENTID = 0x8000,
1817         WMI_10_4_READY_EVENTID,
1818         WMI_10_4_DEBUG_MESG_EVENTID,
1819         WMI_10_4_START_EVENTID = 0x9000,
1820         WMI_10_4_END_EVENTID = 0x9FFF,
1821         WMI_10_4_SCAN_EVENTID = WMI_10_4_START_EVENTID,
1822         WMI_10_4_ECHO_EVENTID,
1823         WMI_10_4_UPDATE_STATS_EVENTID,
1824         WMI_10_4_INST_RSSI_STATS_EVENTID,
1825         WMI_10_4_VDEV_START_RESP_EVENTID,
1826         WMI_10_4_VDEV_STANDBY_REQ_EVENTID,
1827         WMI_10_4_VDEV_RESUME_REQ_EVENTID,
1828         WMI_10_4_VDEV_STOPPED_EVENTID,
1829         WMI_10_4_PEER_STA_KICKOUT_EVENTID,
1830         WMI_10_4_HOST_SWBA_EVENTID,
1831         WMI_10_4_TBTTOFFSET_UPDATE_EVENTID,
1832         WMI_10_4_MGMT_RX_EVENTID,
1833         WMI_10_4_CHAN_INFO_EVENTID,
1834         WMI_10_4_PHYERR_EVENTID,
1835         WMI_10_4_ROAM_EVENTID,
1836         WMI_10_4_PROFILE_MATCH,
1837         WMI_10_4_DEBUG_PRINT_EVENTID,
1838         WMI_10_4_PDEV_QVIT_EVENTID,
1839         WMI_10_4_WLAN_PROFILE_DATA_EVENTID,
1840         WMI_10_4_RTT_MEASUREMENT_REPORT_EVENTID,
1841         WMI_10_4_TSF_MEASUREMENT_REPORT_EVENTID,
1842         WMI_10_4_RTT_ERROR_REPORT_EVENTID,
1843         WMI_10_4_RTT_KEEPALIVE_EVENTID,
1844         WMI_10_4_OEM_CAPABILITY_EVENTID,
1845         WMI_10_4_OEM_MEASUREMENT_REPORT_EVENTID,
1846         WMI_10_4_OEM_ERROR_REPORT_EVENTID,
1847         WMI_10_4_NAN_EVENTID,
1848         WMI_10_4_WOW_WAKEUP_HOST_EVENTID,
1849         WMI_10_4_GTK_OFFLOAD_STATUS_EVENTID,
1850         WMI_10_4_GTK_REKEY_FAIL_EVENTID,
1851         WMI_10_4_DCS_INTERFERENCE_EVENTID,
1852         WMI_10_4_PDEV_TPC_CONFIG_EVENTID,
1853         WMI_10_4_CSA_HANDLING_EVENTID,
1854         WMI_10_4_GPIO_INPUT_EVENTID,
1855         WMI_10_4_PEER_RATECODE_LIST_EVENTID,
1856         WMI_10_4_GENERIC_BUFFER_EVENTID,
1857         WMI_10_4_MCAST_BUF_RELEASE_EVENTID,
1858         WMI_10_4_MCAST_LIST_AGEOUT_EVENTID,
1859         WMI_10_4_VDEV_GET_KEEPALIVE_EVENTID,
1860         WMI_10_4_WDS_PEER_EVENTID,
1861         WMI_10_4_PEER_STA_PS_STATECHG_EVENTID,
1862         WMI_10_4_PDEV_FIPS_EVENTID,
1863         WMI_10_4_TT_STATS_EVENTID,
1864         WMI_10_4_PDEV_CHANNEL_HOPPING_EVENTID,
1865         WMI_10_4_PDEV_ANI_CCK_LEVEL_EVENTID,
1866         WMI_10_4_PDEV_ANI_OFDM_LEVEL_EVENTID,
1867         WMI_10_4_PDEV_RESERVE_AST_ENTRY_EVENTID,
1868         WMI_10_4_PDEV_NFCAL_POWER_EVENTID,
1869         WMI_10_4_PDEV_TPC_EVENTID,
1870         WMI_10_4_PDEV_GET_AST_INFO_EVENTID,
1871         WMI_10_4_PDEV_TEMPERATURE_EVENTID,
1872         WMI_10_4_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID,
1873         WMI_10_4_PDEV_BSS_CHAN_INFO_EVENTID,
1874         WMI_10_4_MU_REPORT_EVENTID,
1875         WMI_10_4_TX_DATA_TRAFFIC_CTRL_EVENTID,
1876         WMI_10_4_PEER_TX_MU_TXMIT_COUNT_EVENTID,
1877         WMI_10_4_PEER_GID_USERPOS_LIST_EVENTID,
1878         WMI_10_4_PDEV_CHECK_CAL_VERSION_EVENTID,
1879         WMI_10_4_ATF_PEER_STATS_EVENTID,
1880         WMI_10_4_PDEV_GET_RX_FILTER_EVENTID,
1881         WMI_10_4_NAC_RSSI_EVENTID,
1882         WMI_10_4_DEBUG_FATAL_CONDITION_EVENTID,
1883         WMI_10_4_GET_TSF_TIMER_RESP_EVENTID,
1884         WMI_10_4_PDEV_TPC_TABLE_EVENTID,
1885         WMI_10_4_PDEV_WDS_ENTRY_LIST_EVENTID,
1886         WMI_10_4_TDLS_PEER_EVENTID,
1887         WMI_10_4_HOST_SWFDA_EVENTID,
1888         WMI_10_4_ESP_ESTIMATE_EVENTID,
1889         WMI_10_4_DFS_STATUS_CHECK_EVENTID,
1890         WMI_10_4_PDEV_UTF_EVENTID = WMI_10_4_END_EVENTID - 1,
1891 };
1892
1893 enum wmi_phy_mode {
1894         MODE_11A        = 0,   /* 11a Mode */
1895         MODE_11G        = 1,   /* 11b/g Mode */
1896         MODE_11B        = 2,   /* 11b Mode */
1897         MODE_11GONLY    = 3,   /* 11g only Mode */
1898         MODE_11NA_HT20   = 4,  /* 11a HT20 mode */
1899         MODE_11NG_HT20   = 5,  /* 11g HT20 mode */
1900         MODE_11NA_HT40   = 6,  /* 11a HT40 mode */
1901         MODE_11NG_HT40   = 7,  /* 11g HT40 mode */
1902         MODE_11AC_VHT20 = 8,
1903         MODE_11AC_VHT40 = 9,
1904         MODE_11AC_VHT80 = 10,
1905         /*    MODE_11AC_VHT160 = 11, */
1906         MODE_11AC_VHT20_2G = 11,
1907         MODE_11AC_VHT40_2G = 12,
1908         MODE_11AC_VHT80_2G = 13,
1909         MODE_11AC_VHT80_80 = 14,
1910         MODE_11AC_VHT160 = 15,
1911         MODE_UNKNOWN    = 16,
1912         MODE_MAX        = 16
1913 };
1914
1915 static inline const char *ath10k_wmi_phymode_str(enum wmi_phy_mode mode)
1916 {
1917         switch (mode) {
1918         case MODE_11A:
1919                 return "11a";
1920         case MODE_11G:
1921                 return "11g";
1922         case MODE_11B:
1923                 return "11b";
1924         case MODE_11GONLY:
1925                 return "11gonly";
1926         case MODE_11NA_HT20:
1927                 return "11na-ht20";
1928         case MODE_11NG_HT20:
1929                 return "11ng-ht20";
1930         case MODE_11NA_HT40:
1931                 return "11na-ht40";
1932         case MODE_11NG_HT40:
1933                 return "11ng-ht40";
1934         case MODE_11AC_VHT20:
1935                 return "11ac-vht20";
1936         case MODE_11AC_VHT40:
1937                 return "11ac-vht40";
1938         case MODE_11AC_VHT80:
1939                 return "11ac-vht80";
1940         case MODE_11AC_VHT160:
1941                 return "11ac-vht160";
1942         case MODE_11AC_VHT80_80:
1943                 return "11ac-vht80+80";
1944         case MODE_11AC_VHT20_2G:
1945                 return "11ac-vht20-2g";
1946         case MODE_11AC_VHT40_2G:
1947                 return "11ac-vht40-2g";
1948         case MODE_11AC_VHT80_2G:
1949                 return "11ac-vht80-2g";
1950         case MODE_UNKNOWN:
1951                 /* skip */
1952                 break;
1953
1954                 /* no default handler to allow compiler to check that the
1955                  * enum is fully handled
1956                  */
1957         };
1958
1959         return "<unknown>";
1960 }
1961
1962 #define WMI_CHAN_LIST_TAG       0x1
1963 #define WMI_SSID_LIST_TAG       0x2
1964 #define WMI_BSSID_LIST_TAG      0x3
1965 #define WMI_IE_TAG              0x4
1966
1967 struct wmi_channel {
1968         __le32 mhz;
1969         __le32 band_center_freq1;
1970         __le32 band_center_freq2; /* valid for 11ac, 80plus80 */
1971         union {
1972                 __le32 flags; /* WMI_CHAN_FLAG_ */
1973                 struct {
1974                         u8 mode; /* only 6 LSBs */
1975                 } __packed;
1976         } __packed;
1977         union {
1978                 __le32 reginfo0;
1979                 struct {
1980                         /* note: power unit is 0.5 dBm */
1981                         u8 min_power;
1982                         u8 max_power;
1983                         u8 reg_power;
1984                         u8 reg_classid;
1985                 } __packed;
1986         } __packed;
1987         union {
1988                 __le32 reginfo1;
1989                 struct {
1990                         u8 antenna_max;
1991                         u8 max_tx_power;
1992                 } __packed;
1993         } __packed;
1994 } __packed;
1995
1996 struct wmi_channel_arg {
1997         u32 freq;
1998         u32 band_center_freq1;
1999         u32 band_center_freq2;
2000         bool passive;
2001         bool allow_ibss;
2002         bool allow_ht;
2003         bool allow_vht;
2004         bool ht40plus;
2005         bool chan_radar;
2006         /* note: power unit is 0.5 dBm */
2007         u32 min_power;
2008         u32 max_power;
2009         u32 max_reg_power;
2010         u32 max_antenna_gain;
2011         u32 reg_class_id;
2012         enum wmi_phy_mode mode;
2013 };
2014
2015 enum wmi_channel_change_cause {
2016         WMI_CHANNEL_CHANGE_CAUSE_NONE = 0,
2017         WMI_CHANNEL_CHANGE_CAUSE_CSA,
2018 };
2019
2020 #define WMI_CHAN_FLAG_HT40_PLUS      (1 << 6)
2021 #define WMI_CHAN_FLAG_PASSIVE        (1 << 7)
2022 #define WMI_CHAN_FLAG_ADHOC_ALLOWED  (1 << 8)
2023 #define WMI_CHAN_FLAG_AP_DISABLED    (1 << 9)
2024 #define WMI_CHAN_FLAG_DFS            (1 << 10)
2025 #define WMI_CHAN_FLAG_ALLOW_HT       (1 << 11)
2026 #define WMI_CHAN_FLAG_ALLOW_VHT      (1 << 12)
2027
2028 /* Indicate reason for channel switch */
2029 #define WMI_CHANNEL_CHANGE_CAUSE_CSA (1 << 13)
2030
2031 #define WMI_MAX_SPATIAL_STREAM        3 /* default max ss */
2032
2033 /* HT Capabilities*/
2034 #define WMI_HT_CAP_ENABLED                0x0001   /* HT Enabled/ disabled */
2035 #define WMI_HT_CAP_HT20_SGI       0x0002   /* Short Guard Interval with HT20 */
2036 #define WMI_HT_CAP_DYNAMIC_SMPS           0x0004   /* Dynamic MIMO powersave */
2037 #define WMI_HT_CAP_TX_STBC                0x0008   /* B3 TX STBC */
2038 #define WMI_HT_CAP_TX_STBC_MASK_SHIFT     3
2039 #define WMI_HT_CAP_RX_STBC                0x0030   /* B4-B5 RX STBC */
2040 #define WMI_HT_CAP_RX_STBC_MASK_SHIFT     4
2041 #define WMI_HT_CAP_LDPC                   0x0040   /* LDPC supported */
2042 #define WMI_HT_CAP_L_SIG_TXOP_PROT        0x0080   /* L-SIG TXOP Protection */
2043 #define WMI_HT_CAP_MPDU_DENSITY           0x0700   /* MPDU Density */
2044 #define WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT 8
2045 #define WMI_HT_CAP_HT40_SGI               0x0800
2046
2047 #define WMI_HT_CAP_DEFAULT_ALL (WMI_HT_CAP_ENABLED       | \
2048                                 WMI_HT_CAP_HT20_SGI      | \
2049                                 WMI_HT_CAP_HT40_SGI      | \
2050                                 WMI_HT_CAP_TX_STBC       | \
2051                                 WMI_HT_CAP_RX_STBC       | \
2052                                 WMI_HT_CAP_LDPC)
2053
2054 /*
2055  * WMI_VHT_CAP_* these maps to ieee 802.11ac vht capability information
2056  * field. The fields not defined here are not supported, or reserved.
2057  * Do not change these masks and if you have to add new one follow the
2058  * bitmask as specified by 802.11ac draft.
2059  */
2060
2061 #define WMI_VHT_CAP_MAX_MPDU_LEN_MASK            0x00000003
2062 #define WMI_VHT_CAP_RX_LDPC                      0x00000010
2063 #define WMI_VHT_CAP_SGI_80MHZ                    0x00000020
2064 #define WMI_VHT_CAP_SGI_160MHZ                   0x00000040
2065 #define WMI_VHT_CAP_TX_STBC                      0x00000080
2066 #define WMI_VHT_CAP_RX_STBC_MASK                 0x00000300
2067 #define WMI_VHT_CAP_RX_STBC_MASK_SHIFT           8
2068 #define WMI_VHT_CAP_SU_BFER                      0x00000800
2069 #define WMI_VHT_CAP_SU_BFEE                      0x00001000
2070 #define WMI_VHT_CAP_MAX_CS_ANT_MASK              0x0000E000
2071 #define WMI_VHT_CAP_MAX_CS_ANT_MASK_SHIFT        13
2072 #define WMI_VHT_CAP_MAX_SND_DIM_MASK             0x00070000
2073 #define WMI_VHT_CAP_MAX_SND_DIM_MASK_SHIFT       16
2074 #define WMI_VHT_CAP_MU_BFER                      0x00080000
2075 #define WMI_VHT_CAP_MU_BFEE                      0x00100000
2076 #define WMI_VHT_CAP_MAX_AMPDU_LEN_EXP            0x03800000
2077 #define WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT      23
2078 #define WMI_VHT_CAP_RX_FIXED_ANT                 0x10000000
2079 #define WMI_VHT_CAP_TX_FIXED_ANT                 0x20000000
2080
2081 /* The following also refer for max HT AMSDU */
2082 #define WMI_VHT_CAP_MAX_MPDU_LEN_3839            0x00000000
2083 #define WMI_VHT_CAP_MAX_MPDU_LEN_7935            0x00000001
2084 #define WMI_VHT_CAP_MAX_MPDU_LEN_11454           0x00000002
2085
2086 #define WMI_VHT_CAP_DEFAULT_ALL (WMI_VHT_CAP_MAX_MPDU_LEN_11454  | \
2087                                  WMI_VHT_CAP_RX_LDPC             | \
2088                                  WMI_VHT_CAP_SGI_80MHZ           | \
2089                                  WMI_VHT_CAP_TX_STBC             | \
2090                                  WMI_VHT_CAP_RX_STBC_MASK        | \
2091                                  WMI_VHT_CAP_MAX_AMPDU_LEN_EXP   | \
2092                                  WMI_VHT_CAP_RX_FIXED_ANT        | \
2093                                  WMI_VHT_CAP_TX_FIXED_ANT)
2094
2095 /*
2096  * Interested readers refer to Rx/Tx MCS Map definition as defined in
2097  * 802.11ac
2098  */
2099 #define WMI_VHT_MAX_MCS_4_SS_MASK(r, ss)      ((3 & (r)) << (((ss) - 1) << 1))
2100 #define WMI_VHT_MAX_SUPP_RATE_MASK           0x1fff0000
2101 #define WMI_VHT_MAX_SUPP_RATE_MASK_SHIFT     16
2102
2103 enum {
2104         REGDMN_MODE_11A              = 0x00001, /* 11a channels */
2105         REGDMN_MODE_TURBO            = 0x00002, /* 11a turbo-only channels */
2106         REGDMN_MODE_11B              = 0x00004, /* 11b channels */
2107         REGDMN_MODE_PUREG            = 0x00008, /* 11g channels (OFDM only) */
2108         REGDMN_MODE_11G              = 0x00008, /* XXX historical */
2109         REGDMN_MODE_108G             = 0x00020, /* 11a+Turbo channels */
2110         REGDMN_MODE_108A             = 0x00040, /* 11g+Turbo channels */
2111         REGDMN_MODE_XR               = 0x00100, /* XR channels */
2112         REGDMN_MODE_11A_HALF_RATE    = 0x00200, /* 11A half rate channels */
2113         REGDMN_MODE_11A_QUARTER_RATE = 0x00400, /* 11A quarter rate channels */
2114         REGDMN_MODE_11NG_HT20        = 0x00800, /* 11N-G HT20 channels */
2115         REGDMN_MODE_11NA_HT20        = 0x01000, /* 11N-A HT20 channels */
2116         REGDMN_MODE_11NG_HT40PLUS    = 0x02000, /* 11N-G HT40 + channels */
2117         REGDMN_MODE_11NG_HT40MINUS   = 0x04000, /* 11N-G HT40 - channels */
2118         REGDMN_MODE_11NA_HT40PLUS    = 0x08000, /* 11N-A HT40 + channels */
2119         REGDMN_MODE_11NA_HT40MINUS   = 0x10000, /* 11N-A HT40 - channels */
2120         REGDMN_MODE_11AC_VHT20       = 0x20000, /* 5Ghz, VHT20 */
2121         REGDMN_MODE_11AC_VHT40PLUS   = 0x40000, /* 5Ghz, VHT40 + channels */
2122         REGDMN_MODE_11AC_VHT40MINUS  = 0x80000, /* 5Ghz  VHT40 - channels */
2123         REGDMN_MODE_11AC_VHT80       = 0x100000, /* 5Ghz, VHT80 channels */
2124         REGDMN_MODE_11AC_VHT160      = 0x200000,     /* 5Ghz, VHT160 channels */
2125         REGDMN_MODE_11AC_VHT80_80    = 0x400000,     /* 5Ghz, VHT80+80 channels */
2126         REGDMN_MODE_ALL              = 0xffffffff
2127 };
2128
2129 #define REGDMN_CAP1_CHAN_HALF_RATE        0x00000001
2130 #define REGDMN_CAP1_CHAN_QUARTER_RATE     0x00000002
2131 #define REGDMN_CAP1_CHAN_HAL49GHZ         0x00000004
2132
2133 /* regulatory capabilities */
2134 #define REGDMN_EEPROM_EEREGCAP_EN_FCC_MIDBAND   0x0040
2135 #define REGDMN_EEPROM_EEREGCAP_EN_KK_U1_EVEN    0x0080
2136 #define REGDMN_EEPROM_EEREGCAP_EN_KK_U2         0x0100
2137 #define REGDMN_EEPROM_EEREGCAP_EN_KK_MIDBAND    0x0200
2138 #define REGDMN_EEPROM_EEREGCAP_EN_KK_U1_ODD     0x0400
2139 #define REGDMN_EEPROM_EEREGCAP_EN_KK_NEW_11A    0x0800
2140
2141 struct hal_reg_capabilities {
2142         /* regdomain value specified in EEPROM */
2143         __le32 eeprom_rd;
2144         /*regdomain */
2145         __le32 eeprom_rd_ext;
2146         /* CAP1 capabilities bit map. */
2147         __le32 regcap1;
2148         /* REGDMN EEPROM CAP. */
2149         __le32 regcap2;
2150         /* REGDMN MODE */
2151         __le32 wireless_modes;
2152         __le32 low_2ghz_chan;
2153         __le32 high_2ghz_chan;
2154         __le32 low_5ghz_chan;
2155         __le32 high_5ghz_chan;
2156 } __packed;
2157
2158 enum wlan_mode_capability {
2159         WHAL_WLAN_11A_CAPABILITY   = 0x1,
2160         WHAL_WLAN_11G_CAPABILITY   = 0x2,
2161         WHAL_WLAN_11AG_CAPABILITY  = 0x3,
2162 };
2163
2164 /* structure used by FW for requesting host memory */
2165 struct wlan_host_mem_req {
2166         /* ID of the request */
2167         __le32 req_id;
2168         /* size of the  of each unit */
2169         __le32 unit_size;
2170         /* flags to  indicate that
2171          * the number units is dependent
2172          * on number of resources(num vdevs num peers .. etc)
2173          */
2174         __le32 num_unit_info;
2175         /*
2176          * actual number of units to allocate . if flags in the num_unit_info
2177          * indicate that number of units is tied to number of a particular
2178          * resource to allocate then  num_units filed is set to 0 and host
2179          * will derive the number units from number of the resources it is
2180          * requesting.
2181          */
2182         __le32 num_units;
2183 } __packed;
2184
2185 /*
2186  * The following struct holds optional payload for
2187  * wmi_service_ready_event,e.g., 11ac pass some of the
2188  * device capability to the host.
2189  */
2190 struct wmi_service_ready_event {
2191         __le32 sw_version;
2192         __le32 sw_version_1;
2193         __le32 abi_version;
2194         /* WMI_PHY_CAPABILITY */
2195         __le32 phy_capability;
2196         /* Maximum number of frag table entries that SW will populate less 1 */
2197         __le32 max_frag_entry;
2198         __le32 wmi_service_bitmap[16];
2199         __le32 num_rf_chains;
2200         /*
2201          * The following field is only valid for service type
2202          * WMI_SERVICE_11AC
2203          */
2204         __le32 ht_cap_info; /* WMI HT Capability */
2205         __le32 vht_cap_info; /* VHT capability info field of 802.11ac */
2206         __le32 vht_supp_mcs; /* VHT Supported MCS Set field Rx/Tx same */
2207         __le32 hw_min_tx_power;
2208         __le32 hw_max_tx_power;
2209         struct hal_reg_capabilities hal_reg_capabilities;
2210         __le32 sys_cap_info;
2211         __le32 min_pkt_size_enable; /* Enterprise mode short pkt enable */
2212         /*
2213          * Max beacon and Probe Response IE offload size
2214          * (includes optional P2P IEs)
2215          */
2216         __le32 max_bcn_ie_size;
2217         /*
2218          * request to host to allocate a chuck of memory and pss it down to FW
2219          * via WM_INIT. FW uses this as FW extesnsion memory for saving its
2220          * data structures. Only valid for low latency interfaces like PCIE
2221          * where FW can access this memory directly (or) by DMA.
2222          */
2223         __le32 num_mem_reqs;
2224         struct wlan_host_mem_req mem_reqs[0];
2225 } __packed;
2226
2227 /* This is the definition from 10.X firmware branch */
2228 struct wmi_10x_service_ready_event {
2229         __le32 sw_version;
2230         __le32 abi_version;
2231
2232         /* WMI_PHY_CAPABILITY */
2233         __le32 phy_capability;
2234
2235         /* Maximum number of frag table entries that SW will populate less 1 */
2236         __le32 max_frag_entry;
2237         __le32 wmi_service_bitmap[16];
2238         __le32 num_rf_chains;
2239
2240         /*
2241          * The following field is only valid for service type
2242          * WMI_SERVICE_11AC
2243          */
2244         __le32 ht_cap_info; /* WMI HT Capability */
2245         __le32 vht_cap_info; /* VHT capability info field of 802.11ac */
2246         __le32 vht_supp_mcs; /* VHT Supported MCS Set field Rx/Tx same */
2247         __le32 hw_min_tx_power;
2248         __le32 hw_max_tx_power;
2249
2250         struct hal_reg_capabilities hal_reg_capabilities;
2251
2252         __le32 sys_cap_info;
2253         __le32 min_pkt_size_enable; /* Enterprise mode short pkt enable */
2254
2255         /*
2256          * request to host to allocate a chuck of memory and pss it down to FW
2257          * via WM_INIT. FW uses this as FW extesnsion memory for saving its
2258          * data structures. Only valid for low latency interfaces like PCIE
2259          * where FW can access this memory directly (or) by DMA.
2260          */
2261         __le32 num_mem_reqs;
2262
2263         struct wlan_host_mem_req mem_reqs[0];
2264 } __packed;
2265
2266 #define WMI_SERVICE_READY_TIMEOUT_HZ (5 * HZ)
2267 #define WMI_UNIFIED_READY_TIMEOUT_HZ (5 * HZ)
2268
2269 struct wmi_ready_event {
2270         __le32 sw_version;
2271         __le32 abi_version;
2272         struct wmi_mac_addr mac_addr;
2273         __le32 status;
2274 } __packed;
2275
2276 struct wmi_resource_config {
2277         /* number of virtual devices (VAPs) to support */
2278         __le32 num_vdevs;
2279
2280         /* number of peer nodes to support */
2281         __le32 num_peers;
2282
2283         /*
2284          * In offload mode target supports features like WOW, chatter and
2285          * other protocol offloads. In order to support them some
2286          * functionalities like reorder buffering, PN checking need to be
2287          * done in target. This determines maximum number of peers supported
2288          * by target in offload mode
2289          */
2290         __le32 num_offload_peers;
2291
2292         /* For target-based RX reordering */
2293         __le32 num_offload_reorder_bufs;
2294
2295         /* number of keys per peer */
2296         __le32 num_peer_keys;
2297
2298         /* total number of TX/RX data TIDs */
2299         __le32 num_tids;
2300
2301         /*
2302          * max skid for resolving hash collisions
2303          *
2304          *   The address search table is sparse, so that if two MAC addresses
2305          *   result in the same hash value, the second of these conflicting
2306          *   entries can slide to the next index in the address search table,
2307          *   and use it, if it is unoccupied.  This ast_skid_limit parameter
2308          *   specifies the upper bound on how many subsequent indices to search
2309          *   over to find an unoccupied space.
2310          */
2311         __le32 ast_skid_limit;
2312
2313         /*
2314          * the nominal chain mask for transmit
2315          *
2316          *   The chain mask may be modified dynamically, e.g. to operate AP
2317          *   tx with a reduced number of chains if no clients are associated.
2318          *   This configuration parameter specifies the nominal chain-mask that
2319          *   should be used when not operating with a reduced set of tx chains.
2320          */
2321         __le32 tx_chain_mask;
2322
2323         /*
2324          * the nominal chain mask for receive
2325          *
2326          *   The chain mask may be modified dynamically, e.g. for a client
2327          *   to use a reduced number of chains for receive if the traffic to
2328          *   the client is low enough that it doesn't require downlink MIMO
2329          *   or antenna diversity.
2330          *   This configuration parameter specifies the nominal chain-mask that
2331          *   should be used when not operating with a reduced set of rx chains.
2332          */
2333         __le32 rx_chain_mask;
2334
2335         /*
2336          * what rx reorder timeout (ms) to use for the AC
2337          *
2338          *   Each WMM access class (voice, video, best-effort, background) will
2339          *   have its own timeout value to dictate how long to wait for missing
2340          *   rx MPDUs to arrive before flushing subsequent MPDUs that have
2341          *   already been received.
2342          *   This parameter specifies the timeout in milliseconds for each
2343          *   class.
2344          */
2345         __le32 rx_timeout_pri_vi;
2346         __le32 rx_timeout_pri_vo;
2347         __le32 rx_timeout_pri_be;
2348         __le32 rx_timeout_pri_bk;
2349
2350         /*
2351          * what mode the rx should decap packets to
2352          *
2353          *   MAC can decap to RAW (no decap), native wifi or Ethernet types
2354          *   THis setting also determines the default TX behavior, however TX
2355          *   behavior can be modified on a per VAP basis during VAP init
2356          */
2357         __le32 rx_decap_mode;
2358
2359         /* what is the maximum number of scan requests that can be queued */
2360         __le32 scan_max_pending_reqs;
2361
2362         /* maximum VDEV that could use BMISS offload */
2363         __le32 bmiss_offload_max_vdev;
2364
2365         /* maximum VDEV that could use offload roaming */
2366         __le32 roam_offload_max_vdev;
2367
2368         /* maximum AP profiles that would push to offload roaming */
2369         __le32 roam_offload_max_ap_profiles;
2370
2371         /*
2372          * how many groups to use for mcast->ucast conversion
2373          *
2374          *   The target's WAL maintains a table to hold information regarding
2375          *   which peers belong to a given multicast group, so that if
2376          *   multicast->unicast conversion is enabled, the target can convert
2377          *   multicast tx frames to a series of unicast tx frames, to each
2378          *   peer within the multicast group.
2379              This num_mcast_groups configuration parameter tells the target how
2380          *   many multicast groups to provide storage for within its multicast
2381          *   group membership table.
2382          */
2383         __le32 num_mcast_groups;
2384
2385         /*
2386          * size to alloc for the mcast membership table
2387          *
2388          *   This num_mcast_table_elems configuration parameter tells the
2389          *   target how many peer elements it needs to provide storage for in
2390          *   its multicast group membership table.
2391          *   These multicast group membership table elements are shared by the
2392          *   multicast groups stored within the table.
2393          */
2394         __le32 num_mcast_table_elems;
2395
2396         /*
2397          * whether/how to do multicast->unicast conversion
2398          *
2399          *   This configuration parameter specifies whether the target should
2400          *   perform multicast --> unicast conversion on transmit, and if so,
2401          *   what to do if it finds no entries in its multicast group
2402          *   membership table for the multicast IP address in the tx frame.
2403          *   Configuration value:
2404          *   0 -> Do not perform multicast to unicast conversion.
2405          *   1 -> Convert multicast frames to unicast, if the IP multicast
2406          *        address from the tx frame is found in the multicast group
2407          *        membership table.  If the IP multicast address is not found,
2408          *        drop the frame.
2409          *   2 -> Convert multicast frames to unicast, if the IP multicast
2410          *        address from the tx frame is found in the multicast group
2411          *        membership table.  If the IP multicast address is not found,
2412          *        transmit the frame as multicast.
2413          */
2414         __le32 mcast2ucast_mode;
2415
2416         /*
2417          * how much memory to allocate for a tx PPDU dbg log
2418          *
2419          *   This parameter controls how much memory the target will allocate
2420          *   to store a log of tx PPDU meta-information (how large the PPDU
2421          *   was, when it was sent, whether it was successful, etc.)
2422          */
2423         __le32 tx_dbg_log_size;
2424
2425         /* how many AST entries to be allocated for WDS */
2426         __le32 num_wds_entries;
2427
2428         /*
2429          * MAC DMA burst size, e.g., For target PCI limit can be
2430          * 0 -default, 1 256B
2431          */
2432         __le32 dma_burst_size;
2433
2434         /*
2435          * Fixed delimiters to be inserted after every MPDU to
2436          * account for interface latency to avoid underrun.
2437          */
2438         __le32 mac_aggr_delim;
2439
2440         /*
2441          *   determine whether target is responsible for detecting duplicate
2442          *   non-aggregate MPDU and timing out stale fragments.
2443          *
2444          *   A-MPDU reordering is always performed on the target.
2445          *
2446          *   0: target responsible for frag timeout and dup checking
2447          *   1: host responsible for frag timeout and dup checking
2448          */
2449         __le32 rx_skip_defrag_timeout_dup_detection_check;
2450
2451         /*
2452          * Configuration for VoW :
2453          * No of Video Nodes to be supported
2454          * and Max no of descriptors for each Video link (node).
2455          */
2456         __le32 vow_config;
2457
2458         /* maximum VDEV that could use GTK offload */
2459         __le32 gtk_offload_max_vdev;
2460
2461         /* Number of msdu descriptors target should use */
2462         __le32 num_msdu_desc;
2463
2464         /*
2465          * Max. number of Tx fragments per MSDU
2466          *  This parameter controls the max number of Tx fragments per MSDU.
2467          *  This is sent by the target as part of the WMI_SERVICE_READY event
2468          *  and is overridden by the OS shim as required.
2469          */
2470         __le32 max_frag_entries;
2471 } __packed;
2472
2473 struct wmi_resource_config_10x {
2474         /* number of virtual devices (VAPs) to support */
2475         __le32 num_vdevs;
2476
2477         /* number of peer nodes to support */
2478         __le32 num_peers;
2479
2480         /* number of keys per peer */
2481         __le32 num_peer_keys;
2482
2483         /* total number of TX/RX data TIDs */
2484         __le32 num_tids;
2485
2486         /*
2487          * max skid for resolving hash collisions
2488          *
2489          *   The address search table is sparse, so that if two MAC addresses
2490          *   result in the same hash value, the second of these conflicting
2491          *   entries can slide to the next index in the address search table,
2492          *   and use it, if it is unoccupied.  This ast_skid_limit parameter
2493          *   specifies the upper bound on how many subsequent indices to search
2494          *   over to find an unoccupied space.
2495          */
2496         __le32 ast_skid_limit;
2497
2498         /*
2499          * the nominal chain mask for transmit
2500          *
2501          *   The chain mask may be modified dynamically, e.g. to operate AP
2502          *   tx with a reduced number of chains if no clients are associated.
2503          *   This configuration parameter specifies the nominal chain-mask that
2504          *   should be used when not operating with a reduced set of tx chains.
2505          */
2506         __le32 tx_chain_mask;
2507
2508         /*
2509          * the nominal chain mask for receive
2510          *
2511          *   The chain mask may be modified dynamically, e.g. for a client
2512          *   to use a reduced number of chains for receive if the traffic to
2513          *   the client is low enough that it doesn't require downlink MIMO
2514          *   or antenna diversity.
2515          *   This configuration parameter specifies the nominal chain-mask that
2516          *   should be used when not operating with a reduced set of rx chains.
2517          */
2518         __le32 rx_chain_mask;
2519
2520         /*
2521          * what rx reorder timeout (ms) to use for the AC
2522          *
2523          *   Each WMM access class (voice, video, best-effort, background) will
2524          *   have its own timeout value to dictate how long to wait for missing
2525          *   rx MPDUs to arrive before flushing subsequent MPDUs that have
2526          *   already been received.
2527          *   This parameter specifies the timeout in milliseconds for each
2528          *   class.
2529          */
2530         __le32 rx_timeout_pri_vi;
2531         __le32 rx_timeout_pri_vo;
2532         __le32 rx_timeout_pri_be;
2533         __le32 rx_timeout_pri_bk;
2534
2535         /*
2536          * what mode the rx should decap packets to
2537          *
2538          *   MAC can decap to RAW (no decap), native wifi or Ethernet types
2539          *   THis setting also determines the default TX behavior, however TX
2540          *   behavior can be modified on a per VAP basis during VAP init
2541          */
2542         __le32 rx_decap_mode;
2543
2544         /* what is the maximum number of scan requests that can be queued */
2545         __le32 scan_max_pending_reqs;
2546
2547         /* maximum VDEV that could use BMISS offload */
2548         __le32 bmiss_offload_max_vdev;
2549
2550         /* maximum VDEV that could use offload roaming */
2551         __le32 roam_offload_max_vdev;
2552
2553         /* maximum AP profiles that would push to offload roaming */
2554         __le32 roam_offload_max_ap_profiles;
2555
2556         /*
2557          * how many groups to use for mcast->ucast conversion
2558          *
2559          *   The target's WAL maintains a table to hold information regarding
2560          *   which peers belong to a given multicast group, so that if
2561          *   multicast->unicast conversion is enabled, the target can convert
2562          *   multicast tx frames to a series of unicast tx frames, to each
2563          *   peer within the multicast group.
2564              This num_mcast_groups configuration parameter tells the target how
2565          *   many multicast groups to provide storage for within its multicast
2566          *   group membership table.
2567          */
2568         __le32 num_mcast_groups;
2569
2570         /*
2571          * size to alloc for the mcast membership table
2572          *
2573          *   This num_mcast_table_elems configuration parameter tells the
2574          *   target how many peer elements it needs to provide storage for in
2575          *   its multicast group membership table.
2576          *   These multicast group membership table elements are shared by the
2577          *   multicast groups stored within the table.
2578          */
2579         __le32 num_mcast_table_elems;
2580
2581         /*
2582          * whether/how to do multicast->unicast conversion
2583          *
2584          *   This configuration parameter specifies whether the target should
2585          *   perform multicast --> unicast conversion on transmit, and if so,
2586          *   what to do if it finds no entries in its multicast group
2587          *   membership table for the multicast IP address in the tx frame.
2588          *   Configuration value:
2589          *   0 -> Do not perform multicast to unicast conversion.
2590          *   1 -> Convert multicast frames to unicast, if the IP multicast
2591          *        address from the tx frame is found in the multicast group
2592          *        membership table.  If the IP multicast address is not found,
2593          *        drop the frame.
2594          *   2 -> Convert multicast frames to unicast, if the IP multicast
2595          *        address from the tx frame is found in the multicast group
2596          *        membership table.  If the IP multicast address is not found,
2597          *        transmit the frame as multicast.
2598          */
2599         __le32 mcast2ucast_mode;
2600
2601         /*
2602          * how much memory to allocate for a tx PPDU dbg log
2603          *
2604          *   This parameter controls how much memory the target will allocate
2605          *   to store a log of tx PPDU meta-information (how large the PPDU
2606          *   was, when it was sent, whether it was successful, etc.)
2607          */
2608         __le32 tx_dbg_log_size;
2609
2610         /* how many AST entries to be allocated for WDS */
2611         __le32 num_wds_entries;
2612
2613         /*
2614          * MAC DMA burst size, e.g., For target PCI limit can be
2615          * 0 -default, 1 256B
2616          */
2617         __le32 dma_burst_size;
2618
2619         /*
2620          * Fixed delimiters to be inserted after every MPDU to
2621          * account for interface latency to avoid underrun.
2622          */
2623         __le32 mac_aggr_delim;
2624
2625         /*
2626          *   determine whether target is responsible for detecting duplicate
2627          *   non-aggregate MPDU and timing out stale fragments.
2628          *
2629          *   A-MPDU reordering is always performed on the target.
2630          *
2631          *   0: target responsible for frag timeout and dup checking
2632          *   1: host responsible for frag timeout and dup checking
2633          */
2634         __le32 rx_skip_defrag_timeout_dup_detection_check;
2635
2636         /*
2637          * Configuration for VoW :
2638          * No of Video Nodes to be supported
2639          * and Max no of descriptors for each Video link (node).
2640          */
2641         __le32 vow_config;
2642
2643         /* Number of msdu descriptors target should use */
2644         __le32 num_msdu_desc;
2645
2646         /*
2647          * Max. number of Tx fragments per MSDU
2648          *  This parameter controls the max number of Tx fragments per MSDU.
2649          *  This is sent by the target as part of the WMI_SERVICE_READY event
2650          *  and is overridden by the OS shim as required.
2651          */
2652         __le32 max_frag_entries;
2653 } __packed;
2654
2655 enum wmi_10_2_feature_mask {
2656         WMI_10_2_RX_BATCH_MODE = BIT(0),
2657         WMI_10_2_ATF_CONFIG    = BIT(1),
2658         WMI_10_2_COEX_GPIO     = BIT(3),
2659         WMI_10_2_BSS_CHAN_INFO = BIT(6),
2660         WMI_10_2_PEER_STATS    = BIT(7),
2661 };
2662
2663 struct wmi_resource_config_10_2 {
2664         struct wmi_resource_config_10x common;
2665         __le32 max_peer_ext_stats;
2666         __le32 smart_ant_cap; /* 0-disable, 1-enable */
2667         __le32 bk_min_free;
2668         __le32 be_min_free;
2669         __le32 vi_min_free;
2670         __le32 vo_min_free;
2671         __le32 feature_mask;
2672 } __packed;
2673
2674 #define NUM_UNITS_IS_NUM_VDEVS         BIT(0)
2675 #define NUM_UNITS_IS_NUM_PEERS         BIT(1)
2676 #define NUM_UNITS_IS_NUM_ACTIVE_PEERS  BIT(2)
2677
2678 struct wmi_resource_config_10_4 {
2679         /* Number of virtual devices (VAPs) to support */
2680         __le32 num_vdevs;
2681
2682         /* Number of peer nodes to support */
2683         __le32 num_peers;
2684
2685         /* Number of active peer nodes to support */
2686         __le32 num_active_peers;
2687
2688         /* In offload mode, target supports features like WOW, chatter and other
2689          * protocol offloads. In order to support them some functionalities like
2690          * reorder buffering, PN checking need to be done in target.
2691          * This determines maximum number of peers supported by target in
2692          * offload mode.
2693          */
2694         __le32 num_offload_peers;
2695
2696         /* Number of reorder buffers available for doing target based reorder
2697          * Rx reorder buffering
2698          */
2699         __le32 num_offload_reorder_buffs;
2700
2701         /* Number of keys per peer */
2702         __le32 num_peer_keys;
2703
2704         /* Total number of TX/RX data TIDs */
2705         __le32 num_tids;
2706
2707         /* Max skid for resolving hash collisions.
2708          * The address search table is sparse, so that if two MAC addresses
2709          * result in the same hash value, the second of these conflicting
2710          * entries can slide to the next index in the address search table,
2711          * and use it, if it is unoccupied.  This ast_skid_limit parameter
2712          * specifies the upper bound on how many subsequent indices to search
2713          * over to find an unoccupied space.
2714          */
2715         __le32 ast_skid_limit;
2716
2717         /* The nominal chain mask for transmit.
2718          * The chain mask may be modified dynamically, e.g. to operate AP tx
2719          * with a reduced number of chains if no clients are associated.
2720          * This configuration parameter specifies the nominal chain-mask that
2721          * should be used when not operating with a reduced set of tx chains.
2722          */
2723         __le32 tx_chain_mask;
2724
2725         /* The nominal chain mask for receive.
2726          * The chain mask may be modified dynamically, e.g. for a client to use
2727          * a reduced number of chains for receive if the traffic to the client
2728          * is low enough that it doesn't require downlink MIMO or antenna
2729          * diversity. This configuration parameter specifies the nominal
2730          * chain-mask that should be used when not operating with a reduced
2731          * set of rx chains.
2732          */
2733         __le32 rx_chain_mask;
2734
2735         /* What rx reorder timeout (ms) to use for the AC.
2736          * Each WMM access class (voice, video, best-effort, background) will
2737          * have its own timeout value to dictate how long to wait for missing
2738          * rx MPDUs to arrive before flushing subsequent MPDUs that have already
2739          * been received. This parameter specifies the timeout in milliseconds
2740          * for each class.
2741          */
2742         __le32 rx_timeout_pri[4];
2743
2744         /* What mode the rx should decap packets to.
2745          * MAC can decap to RAW (no decap), native wifi or Ethernet types.
2746          * This setting also determines the default TX behavior, however TX
2747          * behavior can be modified on a per VAP basis during VAP init
2748          */
2749         __le32 rx_decap_mode;
2750
2751         __le32 scan_max_pending_req;
2752
2753         __le32 bmiss_offload_max_vdev;
2754
2755         __le32 roam_offload_max_vdev;
2756
2757         __le32 roam_offload_max_ap_profiles;
2758
2759         /* How many groups to use for mcast->ucast conversion.
2760          * The target's WAL maintains a table to hold information regarding
2761          * which peers belong to a given multicast group, so that if
2762          * multicast->unicast conversion is enabled, the target can convert
2763          * multicast tx frames to a series of unicast tx frames, to each peer
2764          * within the multicast group. This num_mcast_groups configuration
2765          * parameter tells the target how many multicast groups to provide
2766          * storage for within its multicast group membership table.
2767          */
2768         __le32 num_mcast_groups;
2769
2770         /* Size to alloc for the mcast membership table.
2771          * This num_mcast_table_elems configuration parameter tells the target
2772          * how many peer elements it needs to provide storage for in its
2773          * multicast group membership table. These multicast group membership
2774          * table elements are shared by the multicast groups stored within
2775          * the table.
2776          */
2777         __le32 num_mcast_table_elems;
2778
2779         /* Whether/how to do multicast->unicast conversion.
2780          * This configuration parameter specifies whether the target should
2781          * perform multicast --> unicast conversion on transmit, and if so,
2782          * what to do if it finds no entries in its multicast group membership
2783          * table for the multicast IP address in the tx frame.
2784          * Configuration value:
2785          * 0 -> Do not perform multicast to unicast conversion.
2786          * 1 -> Convert multicast frames to unicast, if the IP multicast address
2787          *      from the tx frame is found in the multicast group membership
2788          *      table.  If the IP multicast address is not found, drop the frame
2789          * 2 -> Convert multicast frames to unicast, if the IP multicast address
2790          *      from the tx frame is found in the multicast group membership
2791          *      table.  If the IP multicast address is not found, transmit the
2792          *      frame as multicast.
2793          */
2794         __le32 mcast2ucast_mode;
2795
2796         /* How much memory to allocate for a tx PPDU dbg log.
2797          * This parameter controls how much memory the target will allocate to
2798          * store a log of tx PPDU meta-information (how large the PPDU was,
2799          * when it was sent, whether it was successful, etc.)
2800          */
2801         __le32 tx_dbg_log_size;
2802
2803         /* How many AST entries to be allocated for WDS */
2804         __le32 num_wds_entries;
2805
2806         /* MAC DMA burst size. 0 -default, 1 -256B */
2807         __le32 dma_burst_size;
2808
2809         /* Fixed delimiters to be inserted after every MPDU to account for
2810          * interface latency to avoid underrun.
2811          */
2812         __le32 mac_aggr_delim;
2813
2814         /* Determine whether target is responsible for detecting duplicate
2815          * non-aggregate MPDU and timing out stale fragments. A-MPDU reordering
2816          * is always performed on the target.
2817          *
2818          * 0: target responsible for frag timeout and dup checking
2819          * 1: host responsible for frag timeout and dup checking
2820          */
2821         __le32 rx_skip_defrag_timeout_dup_detection_check;
2822
2823         /* Configuration for VoW : No of Video nodes to be supported and max
2824          * no of descriptors for each video link (node).
2825          */
2826         __le32 vow_config;
2827
2828         /* Maximum vdev that could use gtk offload */
2829         __le32 gtk_offload_max_vdev;
2830
2831         /* Number of msdu descriptors target should use */
2832         __le32 num_msdu_desc;
2833
2834         /* Max number of tx fragments per MSDU.
2835          * This parameter controls the max number of tx fragments per MSDU.
2836          * This will passed by target as part of the WMI_SERVICE_READY event
2837          * and is overridden by the OS shim as required.
2838          */
2839         __le32 max_frag_entries;
2840
2841         /* Max number of extended peer stats.
2842          * This parameter controls the max number of peers for which extended
2843          * statistics are supported by target
2844          */
2845         __le32 max_peer_ext_stats;
2846
2847         /* Smart antenna capabilities information.
2848          * 1 - Smart antenna is enabled
2849          * 0 - Smart antenna is disabled
2850          * In future this can contain smart antenna specific capabilities.
2851          */
2852         __le32 smart_ant_cap;
2853
2854         /* User can configure the buffers allocated for each AC (BE, BK, VI, VO)
2855          * during init.
2856          */
2857         __le32 bk_minfree;
2858         __le32 be_minfree;
2859         __le32 vi_minfree;
2860         __le32 vo_minfree;
2861
2862         /* Rx batch mode capability.
2863          * 1 - Rx batch mode enabled
2864          * 0 - Rx batch mode disabled
2865          */
2866         __le32 rx_batchmode;
2867
2868         /* Thermal throttling capability.
2869          * 1 - Capable of thermal throttling
2870          * 0 - Not capable of thermal throttling
2871          */
2872         __le32 tt_support;
2873
2874         /* ATF configuration.
2875          * 1  - Enable ATF
2876          * 0  - Disable ATF
2877          */
2878         __le32 atf_config;
2879
2880         /* Configure padding to manage IP header un-alignment
2881          * 1  - Enable padding
2882          * 0  - Disable padding
2883          */
2884         __le32 iphdr_pad_config;
2885
2886         /* qwrap configuration (bits 15-0)
2887          * 1  - This is qwrap configuration
2888          * 0  - This is not qwrap
2889          *
2890          * Bits 31-16 is alloc_frag_desc_for_data_pkt (1 enables, 0 disables)
2891          * In order to get ack-RSSI reporting and to specify the tx-rate for
2892          * individual frames, this option must be enabled.  This uses an extra
2893          * 4 bytes per tx-msdu descriptor, so don't enable it unless you need it.
2894          */
2895         __le32 qwrap_config;
2896 } __packed;
2897
2898 enum wmi_coex_version {
2899         WMI_NO_COEX_VERSION_SUPPORT     = 0,
2900         /* 3 wire coex support*/
2901         WMI_COEX_VERSION_1              = 1,
2902         /* 2.5 wire coex support*/
2903         WMI_COEX_VERSION_2              = 2,
2904         /* 2.5 wire coex with duty cycle support */
2905         WMI_COEX_VERSION_3              = 3,
2906         /* 4 wire coex support*/
2907         WMI_COEX_VERSION_4              = 4,
2908 };
2909
2910 /**
2911  * enum wmi_10_4_feature_mask - WMI 10.4 feature enable/disable flags
2912  * @WMI_10_4_LTEU_SUPPORT: LTEU config
2913  * @WMI_10_4_COEX_GPIO_SUPPORT: COEX GPIO config
2914  * @WMI_10_4_AUX_RADIO_SPECTRAL_INTF: AUX Radio Enhancement for spectral scan
2915  * @WMI_10_4_AUX_RADIO_CHAN_LOAD_INTF: AUX Radio Enhancement for chan load scan
2916  * @WMI_10_4_BSS_CHANNEL_INFO_64: BSS channel info stats
2917  * @WMI_10_4_PEER_STATS: Per station stats
2918  * @WMI_10_4_VDEV_STATS: Per vdev stats
2919  * @WMI_10_4_TDLS: Implicit TDLS support in firmware enable/disable
2920  * @WMI_10_4_TDLS_OFFCHAN: TDLS offchannel support enable/disable
2921  * @WMI_10_4_TDLS_UAPSD_BUFFER_STA: TDLS buffer sta support enable/disable
2922  * @WMI_10_4_TDLS_UAPSD_SLEEP_STA: TDLS sleep sta support enable/disable
2923  * @WMI_10_4_TDLS_CONN_TRACKER_IN_HOST_MODE: TDLS connection tracker in host
2924  *      enable/disable
2925  * @WMI_10_4_TDLS_EXPLICIT_MODE_ONLY:Explicit TDLS mode enable/disable
2926  */
2927 enum wmi_10_4_feature_mask {
2928         WMI_10_4_LTEU_SUPPORT                   = BIT(0),
2929         WMI_10_4_COEX_GPIO_SUPPORT              = BIT(1),
2930         WMI_10_4_AUX_RADIO_SPECTRAL_INTF        = BIT(2),
2931         WMI_10_4_AUX_RADIO_CHAN_LOAD_INTF       = BIT(3),
2932         WMI_10_4_BSS_CHANNEL_INFO_64            = BIT(4),
2933         WMI_10_4_PEER_STATS                     = BIT(5),
2934         WMI_10_4_VDEV_STATS                     = BIT(6),
2935         WMI_10_4_TDLS                           = BIT(7),
2936         WMI_10_4_TDLS_OFFCHAN                   = BIT(8),
2937         WMI_10_4_TDLS_UAPSD_BUFFER_STA          = BIT(9),
2938         WMI_10_4_TDLS_UAPSD_SLEEP_STA           = BIT(10),
2939         WMI_10_4_TDLS_CONN_TRACKER_IN_HOST_MODE = BIT(11),
2940         WMI_10_4_TDLS_EXPLICIT_MODE_ONLY        = BIT(12),
2941
2942 };
2943
2944 struct wmi_ext_resource_config_10_4_cmd {
2945         /* contains enum wmi_host_platform_type */
2946         __le32 host_platform_config;
2947         /* see enum wmi_10_4_feature_mask */
2948         __le32 fw_feature_bitmap;
2949         /* WLAN priority GPIO number */
2950         __le32 wlan_gpio_priority;
2951         /* see enum wmi_coex_version */
2952         __le32 coex_version;
2953         /* COEX GPIO config */
2954         __le32 coex_gpio_pin1;
2955         __le32 coex_gpio_pin2;
2956         __le32 coex_gpio_pin3;
2957         /* number of vdevs allowed to perform tdls */
2958         __le32 num_tdls_vdevs;
2959         /* number of peers to track per TDLS vdev */
2960         __le32 num_tdls_conn_table_entries;
2961         /* number of tdls sleep sta supported */
2962         __le32 max_tdls_concurrent_sleep_sta;
2963         /* number of tdls buffer sta supported */
2964         __le32 max_tdls_concurrent_buffer_sta;
2965 };
2966
2967 /* structure describing host memory chunk. */
2968 struct host_memory_chunk {
2969         /* id of the request that is passed up in service ready */
2970         __le32 req_id;
2971         /* the physical address the memory chunk */
2972         __le32 ptr;
2973         /* size of the chunk */
2974         __le32 size;
2975 } __packed;
2976
2977 struct wmi_host_mem_chunks {
2978         __le32 count;
2979         /* some fw revisions require at least 1 chunk regardless of count */
2980         struct host_memory_chunk items[1];
2981 } __packed;
2982
2983 struct wmi_init_cmd {
2984         struct wmi_resource_config resource_config;
2985         struct wmi_host_mem_chunks mem_chunks;
2986 } __packed;
2987
2988 /* _10x structure is from 10.X FW API */
2989 struct wmi_init_cmd_10x {
2990         struct wmi_resource_config_10x resource_config;
2991         struct wmi_host_mem_chunks mem_chunks;
2992 } __packed;
2993
2994 struct wmi_init_cmd_10_2 {
2995         struct wmi_resource_config_10_2 resource_config;
2996         struct wmi_host_mem_chunks mem_chunks;
2997 } __packed;
2998
2999 struct wmi_init_cmd_10_4 {
3000         struct wmi_resource_config_10_4 resource_config;
3001         struct wmi_host_mem_chunks mem_chunks;
3002 } __packed;
3003
3004 struct wmi_chan_list_entry {
3005         __le16 freq;
3006         u8 phy_mode; /* valid for 10.2 only */
3007         u8 reserved;
3008 } __packed;
3009
3010 /* TLV for channel list */
3011 struct wmi_chan_list {
3012         __le32 tag; /* WMI_CHAN_LIST_TAG */
3013         __le32 num_chan;
3014         struct wmi_chan_list_entry channel_list[0];
3015 } __packed;
3016
3017 struct wmi_bssid_list {
3018         __le32 tag; /* WMI_BSSID_LIST_TAG */
3019         __le32 num_bssid;
3020         struct wmi_mac_addr bssid_list[0];
3021 } __packed;
3022
3023 struct wmi_ie_data {
3024         __le32 tag; /* WMI_IE_TAG */
3025         __le32 ie_len;
3026         u8 ie_data[0];
3027 } __packed;
3028
3029 struct wmi_ssid {
3030         __le32 ssid_len;
3031         u8 ssid[32];
3032 } __packed;
3033
3034 struct wmi_ssid_list {
3035         __le32 tag; /* WMI_SSID_LIST_TAG */
3036         __le32 num_ssids;
3037         struct wmi_ssid ssids[0];
3038 } __packed;
3039
3040 /* prefix used by scan requestor ids on the host */
3041 #define WMI_HOST_SCAN_REQUESTOR_ID_PREFIX 0xA000
3042
3043 /* prefix used by scan request ids generated on the host */
3044 /* host cycles through the lower 12 bits to generate ids */
3045 #define WMI_HOST_SCAN_REQ_ID_PREFIX 0xA000
3046
3047 #define WLAN_SCAN_PARAMS_MAX_SSID    16
3048 #define WLAN_SCAN_PARAMS_MAX_BSSID   4
3049 #define WLAN_SCAN_PARAMS_MAX_IE_LEN  256
3050
3051 /* Values lower than this may be refused by some firmware revisions with a scan
3052  * completion with a timedout reason.
3053  */
3054 #define WMI_SCAN_CHAN_MIN_TIME_MSEC 40
3055
3056 /* Scan priority numbers must be sequential, starting with 0 */
3057 enum wmi_scan_priority {
3058         WMI_SCAN_PRIORITY_VERY_LOW = 0,
3059         WMI_SCAN_PRIORITY_LOW,
3060         WMI_SCAN_PRIORITY_MEDIUM,
3061         WMI_SCAN_PRIORITY_HIGH,
3062         WMI_SCAN_PRIORITY_VERY_HIGH,
3063         WMI_SCAN_PRIORITY_COUNT   /* number of priorities supported */
3064 };
3065
3066 struct wmi_start_scan_common {
3067         /* Scan ID */
3068         __le32 scan_id;
3069         /* Scan requestor ID */
3070         __le32 scan_req_id;
3071         /* VDEV id(interface) that is requesting scan */
3072         __le32 vdev_id;
3073         /* Scan Priority, input to scan scheduler */
3074         __le32 scan_priority;
3075         /* Scan events subscription */
3076         __le32 notify_scan_events;
3077         /* dwell time in msec on active channels */
3078         __le32 dwell_time_active;
3079         /* dwell time in msec on passive channels */
3080         __le32 dwell_time_passive;
3081         /*
3082          * min time in msec on the BSS channel,only valid if atleast one
3083          * VDEV is active
3084          */
3085         __le32 min_rest_time;
3086         /*
3087          * max rest time in msec on the BSS channel,only valid if at least
3088          * one VDEV is active
3089          */
3090         /*
3091          * the scanner will rest on the bss channel at least min_rest_time
3092          * after min_rest_time the scanner will start checking for tx/rx
3093          * activity on all VDEVs. if there is no activity the scanner will
3094          * switch to off channel. if there is activity the scanner will let
3095          * the radio on the bss channel until max_rest_time expires.at
3096          * max_rest_time scanner will switch to off channel irrespective of
3097          * activity. activity is determined by the idle_time parameter.
3098          */
3099         __le32 max_rest_time;
3100         /*
3101          * time before sending next set of probe requests.
3102          * The scanner keeps repeating probe requests transmission with
3103          * period specified by repeat_probe_time.
3104          * The number of probe requests specified depends on the ssid_list
3105          * and bssid_list
3106          */
3107         __le32 repeat_probe_time;
3108         /* time in msec between 2 consequetive probe requests with in a set. */
3109         __le32 probe_spacing_time;
3110         /*
3111          * data inactivity time in msec on bss channel that will be used by
3112          * scanner for measuring the inactivity.
3113          */
3114         __le32 idle_time;
3115         /* maximum time in msec allowed for scan  */
3116         __le32 max_scan_time;
3117         /*
3118          * delay in msec before sending first probe request after switching
3119          * to a channel
3120          */
3121         __le32 probe_delay;
3122         /* Scan control flags */
3123         __le32 scan_ctrl_flags;
3124 } __packed;
3125
3126 struct wmi_start_scan_tlvs {
3127         /* TLV parameters. These includes channel list, ssid list, bssid list,
3128          * extra ies.
3129          */
3130         u8 tlvs[0];
3131 } __packed;
3132
3133 struct wmi_start_scan_cmd {
3134         struct wmi_start_scan_common common;
3135         __le32 burst_duration_ms;
3136         struct wmi_start_scan_tlvs tlvs;
3137 } __packed;
3138
3139 /* This is the definition from 10.X firmware branch */
3140 struct wmi_10x_start_scan_cmd {
3141         struct wmi_start_scan_common common;
3142         struct wmi_start_scan_tlvs tlvs;
3143 } __packed;
3144
3145 struct wmi_ssid_arg {
3146         int len;
3147         const u8 *ssid;
3148 };
3149
3150 struct wmi_bssid_arg {
3151         const u8 *bssid;
3152 };
3153
3154 struct wmi_start_scan_arg {
3155         u32 scan_id;
3156         u32 scan_req_id;
3157         u32 vdev_id;
3158         u32 scan_priority;
3159         u32 notify_scan_events;
3160         u32 dwell_time_active;
3161         u32 dwell_time_passive;
3162         u32 min_rest_time;
3163         u32 max_rest_time;
3164         u32 repeat_probe_time;
3165         u32 probe_spacing_time;
3166         u32 idle_time;
3167         u32 max_scan_time;
3168         u32 probe_delay;
3169         u32 scan_ctrl_flags;
3170         u32 burst_duration_ms;
3171
3172         u32 ie_len;
3173         u32 n_channels;
3174         u32 n_ssids;
3175         u32 n_bssids;
3176
3177         u8 ie[WLAN_SCAN_PARAMS_MAX_IE_LEN];
3178         u16 channels[64];
3179         struct wmi_ssid_arg ssids[WLAN_SCAN_PARAMS_MAX_SSID];
3180         struct wmi_bssid_arg bssids[WLAN_SCAN_PARAMS_MAX_BSSID];
3181         struct wmi_mac_addr mac_addr;
3182         struct wmi_mac_addr mac_mask;
3183 };
3184
3185 /* scan control flags */
3186
3187 /* passively scan all channels including active channels */
3188 #define WMI_SCAN_FLAG_PASSIVE        0x1
3189 /* add wild card ssid probe request even though ssid_list is specified. */
3190 #define WMI_SCAN_ADD_BCAST_PROBE_REQ 0x2
3191 /* add cck rates to rates/xrate ie for the generated probe request */
3192 #define WMI_SCAN_ADD_CCK_RATES 0x4
3193 /* add ofdm rates to rates/xrate ie for the generated probe request */
3194 #define WMI_SCAN_ADD_OFDM_RATES 0x8
3195 /* To enable indication of Chan load and Noise floor to host */
3196 #define WMI_SCAN_CHAN_STAT_EVENT 0x10
3197 /* Filter Probe request frames  */
3198 #define WMI_SCAN_FILTER_PROBE_REQ 0x20
3199 /* When set, DFS channels will not be scanned */
3200 #define WMI_SCAN_BYPASS_DFS_CHN 0x40
3201 /* Different FW scan engine may choose to bail out on errors.
3202  * Allow the driver to have influence over that.
3203  */
3204 #define WMI_SCAN_CONTINUE_ON_ERROR 0x80
3205
3206 /* Use random MAC address for TA for Probe Request frame and add
3207  * OUI specified by WMI_SCAN_PROB_REQ_OUI_CMDID to the Probe Request frame.
3208  * if OUI is not set by WMI_SCAN_PROB_REQ_OUI_CMDID then the flag is ignored.
3209  */
3210 #define WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ   0x1000
3211
3212 /* WMI_SCAN_CLASS_MASK must be the same value as IEEE80211_SCAN_CLASS_MASK */
3213 #define WMI_SCAN_CLASS_MASK 0xFF000000
3214
3215 enum wmi_stop_scan_type {
3216         WMI_SCAN_STOP_ONE       = 0x00000000, /* stop by scan_id */
3217         WMI_SCAN_STOP_VDEV_ALL  = 0x01000000, /* stop by vdev_id */
3218         WMI_SCAN_STOP_ALL       = 0x04000000, /* stop all scans */
3219 };
3220
3221 struct wmi_stop_scan_cmd {
3222         __le32 scan_req_id;
3223         __le32 scan_id;
3224         __le32 req_type;
3225         __le32 vdev_id;
3226 } __packed;
3227
3228 struct wmi_stop_scan_arg {
3229         u32 req_id;
3230         enum wmi_stop_scan_type req_type;
3231         union {
3232                 u32 scan_id;
3233                 u32 vdev_id;
3234         } u;
3235 };
3236
3237 struct wmi_scan_chan_list_cmd {
3238         __le32 num_scan_chans;
3239         struct wmi_channel chan_info[0];
3240 } __packed;
3241
3242 struct wmi_scan_chan_list_arg {
3243         u32 n_channels;
3244         struct wmi_channel_arg *channels;
3245 };
3246
3247 enum wmi_bss_filter {
3248         WMI_BSS_FILTER_NONE = 0,        /* no beacons forwarded */
3249         WMI_BSS_FILTER_ALL,             /* all beacons forwarded */
3250         WMI_BSS_FILTER_PROFILE,         /* only beacons matching profile */
3251         WMI_BSS_FILTER_ALL_BUT_PROFILE, /* all but beacons matching profile */
3252         WMI_BSS_FILTER_CURRENT_BSS,     /* only beacons matching current BSS */
3253         WMI_BSS_FILTER_ALL_BUT_BSS,     /* all but beacons matching BSS */
3254         WMI_BSS_FILTER_PROBED_SSID,     /* beacons matching probed ssid */
3255         WMI_BSS_FILTER_LAST_BSS,        /* marker only */
3256 };
3257
3258 enum wmi_scan_event_type {
3259         WMI_SCAN_EVENT_STARTED              = BIT(0),
3260         WMI_SCAN_EVENT_COMPLETED            = BIT(1),
3261         WMI_SCAN_EVENT_BSS_CHANNEL          = BIT(2),
3262         WMI_SCAN_EVENT_FOREIGN_CHANNEL      = BIT(3),
3263         WMI_SCAN_EVENT_DEQUEUED             = BIT(4),
3264         /* possibly by high-prio scan */
3265         WMI_SCAN_EVENT_PREEMPTED            = BIT(5),
3266         WMI_SCAN_EVENT_START_FAILED         = BIT(6),
3267         WMI_SCAN_EVENT_RESTARTED            = BIT(7),
3268         WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT = BIT(8),
3269         WMI_SCAN_EVENT_MAX                  = BIT(15),
3270 };
3271
3272 enum wmi_scan_completion_reason {
3273         WMI_SCAN_REASON_COMPLETED,
3274         WMI_SCAN_REASON_CANCELLED,
3275         WMI_SCAN_REASON_PREEMPTED,
3276         WMI_SCAN_REASON_TIMEDOUT,
3277         WMI_SCAN_REASON_INTERNAL_FAILURE,
3278         WMI_SCAN_REASON_MAX,
3279 };
3280
3281 struct wmi_scan_event {
3282         __le32 event_type; /* %WMI_SCAN_EVENT_ */
3283         __le32 reason; /* %WMI_SCAN_REASON_ */
3284         __le32 channel_freq; /* only valid for WMI_SCAN_EVENT_FOREIGN_CHANNEL */
3285         __le32 scan_req_id;
3286         __le32 scan_id;
3287         __le32 vdev_id;
3288 } __packed;
3289
3290 /*
3291  * This defines how much headroom is kept in the
3292  * receive frame between the descriptor and the
3293  * payload, in order for the WMI PHY error and
3294  * management handler to insert header contents.
3295  *
3296  * This is in bytes.
3297  */
3298 #define WMI_MGMT_RX_HDR_HEADROOM    52
3299
3300 /*
3301  * This event will be used for sending scan results
3302  * as well as rx mgmt frames to the host. The rx buffer
3303  * will be sent as part of this WMI event. It would be a
3304  * good idea to pass all the fields in the RX status
3305  * descriptor up to the host.
3306  */
3307 struct wmi_mgmt_rx_hdr_v1 {
3308         __le32 channel;
3309         __le32 snr;
3310         __le32 rate;
3311         __le32 phy_mode;
3312         __le32 buf_len;
3313         __le32 status; /* %WMI_RX_STATUS_ */
3314 } __packed;
3315
3316 struct wmi_mgmt_rx_hdr_v2 {
3317         struct wmi_mgmt_rx_hdr_v1 v1;
3318         __le32 rssi_ctl[4];
3319 } __packed;
3320
3321 struct wmi_mgmt_rx_event_v1 {
3322         struct wmi_mgmt_rx_hdr_v1 hdr;
3323         u8 buf[0];
3324 } __packed;
3325
3326 struct wmi_mgmt_rx_event_v2 {
3327         struct wmi_mgmt_rx_hdr_v2 hdr;
3328         u8 buf[0];
3329 } __packed;
3330
3331 struct wmi_10_4_mgmt_rx_hdr {
3332         __le32 channel;
3333         __le32 snr;
3334             u8 rssi_ctl[4];
3335         __le32 rate;
3336         __le32 phy_mode;
3337         __le32 buf_len;
3338         __le32 status;
3339 } __packed;
3340
3341 struct wmi_10_4_mgmt_rx_event {
3342         struct wmi_10_4_mgmt_rx_hdr hdr;
3343         u8 buf[0];
3344 } __packed;
3345
3346 struct wmi_mgmt_rx_ext_info {
3347         __le64 rx_mac_timestamp;
3348 } __packed __aligned(4);
3349
3350 #define WMI_RX_STATUS_OK                        0x00
3351 #define WMI_RX_STATUS_ERR_CRC                   0x01
3352 #define WMI_RX_STATUS_ERR_DECRYPT               0x08
3353 #define WMI_RX_STATUS_ERR_MIC                   0x10
3354 #define WMI_RX_STATUS_ERR_KEY_CACHE_MISS        0x20
3355 /* Extension data at the end of mgmt frame */
3356 #define WMI_RX_STATUS_EXT_INFO          0x40
3357
3358 #define PHY_ERROR_GEN_SPECTRAL_SCAN             0x26
3359 #define PHY_ERROR_GEN_FALSE_RADAR_EXT           0x24
3360 #define PHY_ERROR_GEN_RADAR                     0x05
3361
3362 #define PHY_ERROR_10_4_RADAR_MASK               0x4
3363 #define PHY_ERROR_10_4_SPECTRAL_SCAN_MASK       0x4000000
3364
3365 enum phy_err_type {
3366         PHY_ERROR_UNKNOWN,
3367         PHY_ERROR_SPECTRAL_SCAN,
3368         PHY_ERROR_FALSE_RADAR_EXT,
3369         PHY_ERROR_RADAR
3370 };
3371
3372 struct wmi_phyerr {
3373         __le32 tsf_timestamp;
3374         __le16 freq1;
3375         __le16 freq2;
3376         u8 rssi_combined;
3377         u8 chan_width_mhz;
3378         u8 phy_err_code;
3379         u8 rsvd0;
3380         __le32 rssi_chains[4];
3381         __le16 nf_chains[4];
3382         __le32 buf_len;
3383         u8 buf[0];
3384 } __packed;
3385
3386 struct wmi_phyerr_event {
3387         __le32 num_phyerrs;
3388         __le32 tsf_l32;
3389         __le32 tsf_u32;
3390         struct wmi_phyerr phyerrs[0];
3391 } __packed;
3392
3393 struct wmi_10_4_phyerr_event {
3394         __le32 tsf_l32;
3395         __le32 tsf_u32;
3396         __le16 freq1;
3397         __le16 freq2;
3398         u8 rssi_combined;
3399         u8 chan_width_mhz;
3400         u8 phy_err_code;
3401         u8 rsvd0;
3402         __le32 rssi_chains[4];
3403         __le16 nf_chains[4];
3404         __le32 phy_err_mask[2];
3405         __le32 tsf_timestamp;
3406         __le32 buf_len;
3407         u8 buf[0];
3408 } __packed;
3409
3410 struct wmi_radar_found_info {
3411         __le32 pri_min;
3412         __le32 pri_max;
3413         __le32 width_min;
3414         __le32 width_max;
3415         __le32 sidx_min;
3416         __le32 sidx_max;
3417 } __packed;
3418
3419 enum wmi_radar_confirmation_status {
3420         /* Detected radar was due to SW pulses */
3421         WMI_SW_RADAR_DETECTED    = 0,
3422
3423         WMI_RADAR_DETECTION_FAIL = 1,
3424
3425         /* Real radar detected */
3426         WMI_HW_RADAR_DETECTED    = 2,
3427 };
3428
3429 #define PHYERR_TLV_SIG                          0xBB
3430 #define PHYERR_TLV_TAG_SEARCH_FFT_REPORT        0xFB
3431 #define PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY      0xF8
3432 #define PHYERR_TLV_TAG_SPECTRAL_SUMMARY_REPORT  0xF9
3433
3434 struct phyerr_radar_report {
3435         __le32 reg0; /* RADAR_REPORT_REG0_* */
3436         __le32 reg1; /* RADAR_REPORT_REG1_* */
3437 } __packed;
3438
3439 #define RADAR_REPORT_REG0_PULSE_IS_CHIRP_MASK           0x80000000
3440 #define RADAR_REPORT_REG0_PULSE_IS_CHIRP_LSB            31
3441
3442 #define RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH_MASK       0x40000000
3443 #define RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH_LSB        30
3444
3445 #define RADAR_REPORT_REG0_AGC_TOTAL_GAIN_MASK           0x3FF00000
3446 #define RADAR_REPORT_REG0_AGC_TOTAL_GAIN_LSB            20
3447
3448 #define RADAR_REPORT_REG0_PULSE_DELTA_DIFF_MASK         0x000F0000
3449 #define RADAR_REPORT_REG0_PULSE_DELTA_DIFF_LSB          16
3450
3451 #define RADAR_REPORT_REG0_PULSE_DELTA_PEAK_MASK         0x0000FC00
3452 #define RADAR_REPORT_REG0_PULSE_DELTA_PEAK_LSB          10
3453
3454 #define RADAR_REPORT_REG0_PULSE_SIDX_MASK               0x000003FF
3455 #define RADAR_REPORT_REG0_PULSE_SIDX_LSB                0
3456
3457 #define RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID_MASK     0x80000000
3458 #define RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID_LSB      31
3459
3460 #define RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN_MASK        0x7F000000
3461 #define RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN_LSB         24
3462
3463 #define RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK_MASK       0x00FF0000
3464 #define RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK_LSB        16
3465
3466 #define RADAR_REPORT_REG1_PULSE_TSF_OFFSET_MASK         0x0000FF00
3467 #define RADAR_REPORT_REG1_PULSE_TSF_OFFSET_LSB          8
3468
3469 #define RADAR_REPORT_REG1_PULSE_DUR_MASK                0x000000FF
3470 #define RADAR_REPORT_REG1_PULSE_DUR_LSB                 0
3471
3472 struct phyerr_fft_report {
3473         __le32 reg0; /* SEARCH_FFT_REPORT_REG0_ * */
3474         __le32 reg1; /* SEARCH_FFT_REPORT_REG1_ * */
3475 } __packed;
3476
3477 #define SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB_MASK       0xFF800000
3478 #define SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB_LSB        23
3479
3480 #define SEARCH_FFT_REPORT_REG0_BASE_PWR_DB_MASK         0x007FC000
3481 #define SEARCH_FFT_REPORT_REG0_BASE_PWR_DB_LSB          14
3482
3483 #define SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX_MASK         0x00003000
3484 #define SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX_LSB          12
3485
3486 #define SEARCH_FFT_REPORT_REG0_PEAK_SIDX_MASK           0x00000FFF
3487 #define SEARCH_FFT_REPORT_REG0_PEAK_SIDX_LSB            0
3488
3489 #define SEARCH_FFT_REPORT_REG1_RELPWR_DB_MASK           0xFC000000
3490 #define SEARCH_FFT_REPORT_REG1_RELPWR_DB_LSB            26
3491
3492 #define SEARCH_FFT_REPORT_REG1_AVGPWR_DB_MASK           0x03FC0000
3493 #define SEARCH_FFT_REPORT_REG1_AVGPWR_DB_LSB            18
3494
3495 #define SEARCH_FFT_REPORT_REG1_PEAK_MAG_MASK            0x0003FF00
3496 #define SEARCH_FFT_REPORT_REG1_PEAK_MAG_LSB             8
3497
3498 #define SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB_MASK     0x000000FF
3499 #define SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB_LSB      0
3500
3501 struct phyerr_tlv {
3502         __le16 len;
3503         u8 tag;
3504         u8 sig;
3505 } __packed;
3506
3507 #define DFS_RSSI_POSSIBLY_FALSE                 50
3508 #define DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE       40
3509
3510 struct wmi_mgmt_tx_hdr {
3511         __le32 vdev_id;
3512         struct wmi_mac_addr peer_macaddr;
3513         __le32 tx_rate;
3514         __le32 tx_power;
3515         __le32 buf_len;
3516 } __packed;
3517
3518 struct wmi_mgmt_tx_cmd {
3519         struct wmi_mgmt_tx_hdr hdr;
3520         u8 buf[0];
3521 } __packed;
3522
3523 struct wmi_echo_event {
3524         __le32 value;
3525 } __packed;
3526
3527 struct wmi_echo_cmd {
3528         __le32 value;
3529 } __packed;
3530
3531 struct wmi_pdev_set_regdomain_cmd {
3532         __le32 reg_domain;
3533         __le32 reg_domain_2G;
3534         __le32 reg_domain_5G;
3535         __le32 conformance_test_limit_2G;
3536         __le32 conformance_test_limit_5G;
3537 } __packed;
3538
3539 enum wmi_dfs_region {
3540         /* Uninitialized dfs domain */
3541         WMI_UNINIT_DFS_DOMAIN = 0,
3542
3543         /* FCC3 dfs domain */
3544         WMI_FCC_DFS_DOMAIN = 1,
3545
3546         /* ETSI dfs domain */
3547         WMI_ETSI_DFS_DOMAIN = 2,
3548
3549         /*Japan dfs domain */
3550         WMI_MKK4_DFS_DOMAIN = 3,
3551 };
3552
3553 struct wmi_pdev_set_regdomain_cmd_10x {
3554         __le32 reg_domain;
3555         __le32 reg_domain_2G;
3556         __le32 reg_domain_5G;
3557         __le32 conformance_test_limit_2G;
3558         __le32 conformance_test_limit_5G;
3559
3560         /* dfs domain from wmi_dfs_region */
3561         __le32 dfs_domain;
3562 } __packed;
3563
3564 /* Command to set/unset chip in quiet mode */
3565 struct wmi_pdev_set_quiet_cmd {
3566         /* period in TUs */
3567         __le32 period;
3568
3569         /* duration in TUs */
3570         __le32 duration;
3571
3572         /* offset in TUs */
3573         __le32 next_start;
3574
3575         /* enable/disable */
3576         __le32 enabled;
3577 } __packed;
3578
3579 /*
3580  * 802.11g protection mode.
3581  */
3582 enum ath10k_protmode {
3583         ATH10K_PROT_NONE     = 0,    /* no protection */
3584         ATH10K_PROT_CTSONLY  = 1,    /* CTS to self */
3585         ATH10K_PROT_RTSCTS   = 2,    /* RTS-CTS */
3586 };
3587
3588 enum wmi_rtscts_profile {
3589         WMI_RTSCTS_FOR_NO_RATESERIES = 0,
3590         WMI_RTSCTS_FOR_SECOND_RATESERIES,
3591         WMI_RTSCTS_ACROSS_SW_RETRIES
3592 };
3593
3594 #define WMI_RTSCTS_ENABLED              1
3595 #define WMI_RTSCTS_SET_MASK             0x0f
3596 #define WMI_RTSCTS_SET_LSB              0
3597
3598 #define WMI_RTSCTS_PROFILE_MASK         0xf0
3599 #define WMI_RTSCTS_PROFILE_LSB          4
3600
3601 enum wmi_beacon_gen_mode {
3602         WMI_BEACON_STAGGERED_MODE = 0,
3603         WMI_BEACON_BURST_MODE = 1
3604 };
3605
3606 enum wmi_csa_event_ies_present_flag {
3607         WMI_CSA_IE_PRESENT = 0x00000001,
3608         WMI_XCSA_IE_PRESENT = 0x00000002,
3609         WMI_WBW_IE_PRESENT = 0x00000004,
3610         WMI_CSWARP_IE_PRESENT = 0x00000008,
3611 };
3612
3613 /* wmi CSA receive event from beacon frame */
3614 struct wmi_csa_event {
3615         __le32 i_fc_dur;
3616         /* Bit 0-15: FC */
3617         /* Bit 16-31: DUR */
3618         struct wmi_mac_addr i_addr1;
3619         struct wmi_mac_addr i_addr2;
3620         __le32 csa_ie[2];
3621         __le32 xcsa_ie[2];
3622         __le32 wb_ie[2];
3623         __le32 cswarp_ie;
3624         __le32 ies_present_flag; /* wmi_csa_event_ies_present_flag */
3625 } __packed;
3626
3627 /* the definition of different PDEV parameters */
3628 #define PDEV_DEFAULT_STATS_UPDATE_PERIOD    500
3629 #define VDEV_DEFAULT_STATS_UPDATE_PERIOD    500
3630 #define PEER_DEFAULT_STATS_UPDATE_PERIOD    500
3631
3632 struct wmi_pdev_param_map {
3633         u32 tx_chain_mask;
3634         u32 rx_chain_mask;
3635         u32 txpower_limit2g;
3636         u32 txpower_limit5g;
3637         u32 txpower_scale;
3638         u32 beacon_gen_mode;
3639         u32 beacon_tx_mode;
3640         u32 resmgr_offchan_mode;
3641         u32 protection_mode;
3642         u32 dynamic_bw;
3643         u32 non_agg_sw_retry_th;
3644         u32 agg_sw_retry_th;
3645         u32 sta_kickout_th;
3646         u32 ac_aggrsize_scaling;
3647         u32 ltr_enable;
3648         u32 ltr_ac_latency_be;
3649         u32 ltr_ac_latency_bk;
3650         u32 ltr_ac_latency_vi;
3651         u32 ltr_ac_latency_vo;
3652         u32 ltr_ac_latency_timeout;
3653         u32 ltr_sleep_override;
3654         u32 ltr_rx_override;
3655         u32 ltr_tx_activity_timeout;
3656         u32 l1ss_enable;
3657         u32 dsleep_enable;
3658         u32 pcielp_txbuf_flush;
3659         u32 pcielp_txbuf_watermark;
3660         u32 pcielp_txbuf_tmo_en;
3661         u32 pcielp_txbuf_tmo_value;
3662         u32 pdev_stats_update_period;
3663         u32 vdev_stats_update_period;
3664         u32 peer_stats_update_period;
3665         u32 bcnflt_stats_update_period;
3666         u32 pmf_qos;
3667         u32 arp_ac_override;
3668         u32 dcs;
3669         u32 ani_enable;
3670         u32 ani_poll_period;
3671         u32 ani_listen_period;
3672         u32 ani_ofdm_level;
3673         u32 ani_cck_level;
3674         u32 dyntxchain;
3675         u32 proxy_sta;
3676         u32 idle_ps_config;
3677         u32 power_gating_sleep;
3678         u32 fast_channel_reset;
3679         u32 burst_dur;
3680         u32 burst_enable;
3681         u32 cal_period;
3682         u32 aggr_burst;
3683         u32 rx_decap_mode;
3684         u32 smart_antenna_default_antenna;
3685         u32 igmpmld_override;
3686         u32 igmpmld_tid;
3687         u32 antenna_gain;
3688         u32 rx_filter;
3689         u32 set_mcast_to_ucast_tid;
3690         u32 proxy_sta_mode;
3691         u32 set_mcast2ucast_mode;
3692         u32 set_mcast2ucast_buffer;
3693         u32 remove_mcast2ucast_buffer;
3694         u32 peer_sta_ps_statechg_enable;
3695         u32 igmpmld_ac_override;
3696         u32 block_interbss;
3697         u32 set_disable_reset_cmdid;
3698         u32 set_msdu_ttl_cmdid;
3699         u32 set_ppdu_duration_cmdid;
3700         u32 txbf_sound_period_cmdid;
3701         u32 set_promisc_mode_cmdid;
3702         u32 set_burst_mode_cmdid;
3703         u32 en_stats;
3704         u32 mu_group_policy;
3705         u32 noise_detection;
3706         u32 noise_threshold;
3707         u32 dpd_enable;
3708         u32 set_mcast_bcast_echo;
3709         u32 atf_strict_sch;
3710         u32 atf_sched_duration;
3711         u32 ant_plzn;
3712         u32 mgmt_retry_limit;
3713         u32 sensitivity_level;
3714         u32 signed_txpower_2g;
3715         u32 signed_txpower_5g;
3716         u32 enable_per_tid_amsdu;
3717         u32 enable_per_tid_ampdu;
3718         u32 cca_threshold;
3719         u32 rts_fixed_rate;
3720         u32 pdev_reset;
3721         u32 wapi_mbssid_offset;
3722         u32 arp_srcaddr;
3723         u32 arp_dstaddr;
3724         u32 enable_btcoex;
3725 };
3726
3727 #define WMI_PDEV_PARAM_UNSUPPORTED 0
3728
3729 enum wmi_pdev_param {
3730         /* TX chain mask */
3731         WMI_PDEV_PARAM_TX_CHAIN_MASK = 0x1,
3732         /* RX chain mask */
3733         WMI_PDEV_PARAM_RX_CHAIN_MASK,
3734         /* TX power limit for 2G Radio */
3735         WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
3736         /* TX power limit for 5G Radio */
3737         WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
3738         /* TX power scale */
3739         WMI_PDEV_PARAM_TXPOWER_SCALE,
3740         /* Beacon generation mode . 0: host, 1: target   */
3741         WMI_PDEV_PARAM_BEACON_GEN_MODE,
3742         /* Beacon generation mode . 0: staggered 1: bursted   */
3743         WMI_PDEV_PARAM_BEACON_TX_MODE,
3744         /*
3745          * Resource manager off chan mode .
3746          * 0: turn off off chan mode. 1: turn on offchan mode
3747          */
3748         WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
3749         /*
3750          * Protection mode:
3751          * 0: no protection 1:use CTS-to-self 2: use RTS/CTS
3752          */
3753         WMI_PDEV_PARAM_PROTECTION_MODE,
3754         /*
3755          * Dynamic bandwidth - 0: disable, 1: enable
3756          *
3757          * When enabled HW rate control tries different bandwidths when
3758          * retransmitting frames.
3759          */
3760         WMI_PDEV_PARAM_DYNAMIC_BW,
3761         /* Non aggregrate/ 11g sw retry threshold.0-disable */
3762         WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
3763         /* aggregrate sw retry threshold. 0-disable*/
3764         WMI_PDEV_PARAM_AGG_SW_RETRY_TH,
3765         /* Station kickout threshold (non of consecutive failures).0-disable */
3766         WMI_PDEV_PARAM_STA_KICKOUT_TH,
3767         /* Aggerate size scaling configuration per AC */
3768         WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING,
3769         /* LTR enable */
3770         WMI_PDEV_PARAM_LTR_ENABLE,
3771         /* LTR latency for BE, in us */
3772         WMI_PDEV_PARAM_LTR_AC_LATENCY_BE,
3773         /* LTR latency for BK, in us */
3774         WMI_PDEV_PARAM_LTR_AC_LATENCY_BK,
3775         /* LTR latency for VI, in us */
3776         WMI_PDEV_PARAM_LTR_AC_LATENCY_VI,
3777         /* LTR latency for VO, in us  */
3778         WMI_PDEV_PARAM_LTR_AC_LATENCY_VO,
3779         /* LTR AC latency timeout, in ms */
3780         WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
3781         /* LTR platform latency override, in us */
3782         WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
3783         /* LTR-RX override, in us */
3784         WMI_PDEV_PARAM_LTR_RX_OVERRIDE,
3785         /* Tx activity timeout for LTR, in us */
3786         WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
3787         /* L1SS state machine enable */
3788         WMI_PDEV_PARAM_L1SS_ENABLE,
3789         /* Deep sleep state machine enable */
3790         WMI_PDEV_PARAM_DSLEEP_ENABLE,
3791         /* RX buffering flush enable */
3792         WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
3793         /* RX buffering matermark */
3794         WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK,
3795         /* RX buffering timeout enable */
3796         WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
3797         /* RX buffering timeout value */
3798         WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
3799         /* pdev level stats update period in ms */
3800         WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
3801         /* vdev level stats update period in ms */
3802         WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
3803         /* peer level stats update period in ms */
3804         WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
3805         /* beacon filter status update period */
3806         WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
3807         /* QOS Mgmt frame protection MFP/PMF 0: disable, 1: enable */
3808         WMI_PDEV_PARAM_PMF_QOS,
3809         /* Access category on which ARP frames are sent */
3810         WMI_PDEV_PARAM_ARP_AC_OVERRIDE,
3811         /* DCS configuration */
3812         WMI_PDEV_PARAM_DCS,
3813         /* Enable/Disable ANI on target */
3814         WMI_PDEV_PARAM_ANI_ENABLE,
3815         /* configure the ANI polling period */
3816         WMI_PDEV_PARAM_ANI_POLL_PERIOD,
3817         /* configure the ANI listening period */
3818         WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
3819         /* configure OFDM immunity level */
3820         WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
3821         /* configure CCK immunity level */
3822         WMI_PDEV_PARAM_ANI_CCK_LEVEL,
3823         /* Enable/Disable CDD for 1x1 STAs in rate control module */
3824         WMI_PDEV_PARAM_DYNTXCHAIN,
3825         /* Enable/Disable proxy STA */
3826         WMI_PDEV_PARAM_PROXY_STA,
3827         /* Enable/Disable low power state when all VDEVs are inactive/idle. */
3828         WMI_PDEV_PARAM_IDLE_PS_CONFIG,
3829         /* Enable/Disable power gating sleep */
3830         WMI_PDEV_PARAM_POWER_GATING_SLEEP,
3831 };
3832
3833 enum wmi_10x_pdev_param {
3834         /* TX chian mask */
3835         WMI_10X_PDEV_PARAM_TX_CHAIN_MASK = 0x1,
3836         /* RX chian mask */
3837         WMI_10X_PDEV_PARAM_RX_CHAIN_MASK,
3838         /* TX power limit for 2G Radio */
3839         WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G,
3840         /* TX power limit for 5G Radio */
3841         WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G,
3842         /* TX power scale */
3843         WMI_10X_PDEV_PARAM_TXPOWER_SCALE,
3844         /* Beacon generation mode . 0: host, 1: target   */
3845         WMI_10X_PDEV_PARAM_BEACON_GEN_MODE,
3846         /* Beacon generation mode . 0: staggered 1: bursted   */
3847         WMI_10X_PDEV_PARAM_BEACON_TX_MODE,
3848         /*
3849          * Resource manager off chan mode .
3850          * 0: turn off off chan mode. 1: turn on offchan mode
3851          */
3852         WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
3853         /*
3854          * Protection mode:
3855          * 0: no protection 1:use CTS-to-self 2: use RTS/CTS
3856          */
3857         WMI_10X_PDEV_PARAM_PROTECTION_MODE,
3858         /* Dynamic bandwidth 0: disable 1: enable */
3859         WMI_10X_PDEV_PARAM_DYNAMIC_BW,
3860         /* Non aggregrate/ 11g sw retry threshold.0-disable */
3861         WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
3862         /* aggregrate sw retry threshold. 0-disable*/
3863         WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH,
3864         /* Station kickout threshold (non of consecutive failures).0-disable */
3865         WMI_10X_PDEV_PARAM_STA_KICKOUT_TH,
3866         /* Aggerate size scaling configuration per AC */
3867         WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING,
3868         /* LTR enable */
3869         WMI_10X_PDEV_PARAM_LTR_ENABLE,
3870         /* LTR latency for BE, in us */
3871         WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE,
3872         /* LTR latency for BK, in us */
3873         WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK,
3874         /* LTR latency for VI, in us */
3875         WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI,
3876         /* LTR latency for VO, in us  */
3877         WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO,
3878         /* LTR AC latency timeout, in ms */
3879         WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
3880         /* LTR platform latency override, in us */
3881         WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
3882         /* LTR-RX override, in us */
3883         WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE,
3884         /* Tx activity timeout for LTR, in us */
3885         WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
3886         /* L1SS state machine enable */
3887         WMI_10X_PDEV_PARAM_L1SS_ENABLE,
3888         /* Deep sleep state machine enable */
3889         WMI_10X_PDEV_PARAM_DSLEEP_ENABLE,
3890         /* pdev level stats update period in ms */
3891         WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
3892         /* vdev level stats update period in ms */
3893         WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
3894         /* peer level stats update period in ms */
3895         WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
3896         /* beacon filter status update period */
3897         WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
3898         /* QOS Mgmt frame protection MFP/PMF 0: disable, 1: enable */
3899         WMI_10X_PDEV_PARAM_PMF_QOS,
3900         /* Access category on which ARP and DHCP frames are sent */
3901         WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE,
3902         /* DCS configuration */
3903         WMI_10X_PDEV_PARAM_DCS,
3904         /* Enable/Disable ANI on target */
3905         WMI_10X_PDEV_PARAM_ANI_ENABLE,
3906         /* configure the ANI polling period */
3907         WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD,
3908         /* configure the ANI listening period */
3909         WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD,
3910         /* configure OFDM immunity level */
3911         WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL,
3912         /* configure CCK immunity level */
3913         WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL,
3914         /* Enable/Disable CDD for 1x1 STAs in rate control module */
3915         WMI_10X_PDEV_PARAM_DYNTXCHAIN,
3916         /* Enable/Disable Fast channel reset*/
3917         WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET,
3918         /* Set Bursting DUR */
3919         WMI_10X_PDEV_PARAM_BURST_DUR,
3920         /* Set Bursting Enable*/
3921         WMI_10X_PDEV_PARAM_BURST_ENABLE,
3922
3923         /* following are available as of firmware 10.2 */
3924         WMI_10X_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA,
3925         WMI_10X_PDEV_PARAM_IGMPMLD_OVERRIDE,
3926         WMI_10X_PDEV_PARAM_IGMPMLD_TID,
3927         WMI_10X_PDEV_PARAM_ANTENNA_GAIN,
3928         WMI_10X_PDEV_PARAM_RX_DECAP_MODE,
3929         WMI_10X_PDEV_PARAM_RX_FILTER,
3930         WMI_10X_PDEV_PARAM_SET_MCAST_TO_UCAST_TID,
3931         WMI_10X_PDEV_PARAM_PROXY_STA_MODE,
3932         WMI_10X_PDEV_PARAM_SET_MCAST2UCAST_MODE,
3933         WMI_10X_PDEV_PARAM_SET_MCAST2UCAST_BUFFER,
3934         WMI_10X_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER,
3935         WMI_10X_PDEV_PARAM_PEER_STA_PS_STATECHG_ENABLE,
3936         WMI_10X_PDEV_PARAM_RTS_FIXED_RATE,
3937         WMI_10X_PDEV_PARAM_CAL_PERIOD
3938 };
3939
3940 enum wmi_10_4_pdev_param {
3941         WMI_10_4_PDEV_PARAM_TX_CHAIN_MASK = 0x1,
3942         WMI_10_4_PDEV_PARAM_RX_CHAIN_MASK,
3943         WMI_10_4_PDEV_PARAM_TXPOWER_LIMIT2G,
3944         WMI_10_4_PDEV_PARAM_TXPOWER_LIMIT5G,
3945         WMI_10_4_PDEV_PARAM_TXPOWER_SCALE,
3946         WMI_10_4_PDEV_PARAM_BEACON_GEN_MODE,
3947         WMI_10_4_PDEV_PARAM_BEACON_TX_MODE,
3948         WMI_10_4_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
3949         WMI_10_4_PDEV_PARAM_PROTECTION_MODE,
3950         WMI_10_4_PDEV_PARAM_DYNAMIC_BW,
3951         WMI_10_4_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
3952         WMI_10_4_PDEV_PARAM_AGG_SW_RETRY_TH,
3953         WMI_10_4_PDEV_PARAM_STA_KICKOUT_TH,
3954         WMI_10_4_PDEV_PARAM_AC_AGGRSIZE_SCALING,
3955         WMI_10_4_PDEV_PARAM_LTR_ENABLE,
3956         WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_BE,
3957         WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_BK,
3958         WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_VI,
3959         WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_VO,
3960         WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
3961         WMI_10_4_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
3962         WMI_10_4_PDEV_PARAM_LTR_RX_OVERRIDE,
3963         WMI_10_4_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
3964         WMI_10_4_PDEV_PARAM_L1SS_ENABLE,
3965         WMI_10_4_PDEV_PARAM_DSLEEP_ENABLE,
3966         WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
3967         WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_WATERMARK,
3968         WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
3969         WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
3970         WMI_10_4_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
3971         WMI_10_4_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
3972         WMI_10_4_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
3973         WMI_10_4_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
3974         WMI_10_4_PDEV_PARAM_PMF_QOS,
3975         WMI_10_4_PDEV_PARAM_ARP_AC_OVERRIDE,
3976         WMI_10_4_PDEV_PARAM_DCS,
3977         WMI_10_4_PDEV_PARAM_ANI_ENABLE,
3978         WMI_10_4_PDEV_PARAM_ANI_POLL_PERIOD,
3979         WMI_10_4_PDEV_PARAM_ANI_LISTEN_PERIOD,
3980         WMI_10_4_PDEV_PARAM_ANI_OFDM_LEVEL,
3981         WMI_10_4_PDEV_PARAM_ANI_CCK_LEVEL,
3982         WMI_10_4_PDEV_PARAM_DYNTXCHAIN,
3983         WMI_10_4_PDEV_PARAM_PROXY_STA,
3984         WMI_10_4_PDEV_PARAM_IDLE_PS_CONFIG,
3985         WMI_10_4_PDEV_PARAM_POWER_GATING_SLEEP,
3986         WMI_10_4_PDEV_PARAM_AGGR_BURST,
3987         WMI_10_4_PDEV_PARAM_RX_DECAP_MODE,
3988         WMI_10_4_PDEV_PARAM_FAST_CHANNEL_RESET,
3989         WMI_10_4_PDEV_PARAM_BURST_DUR,
3990         WMI_10_4_PDEV_PARAM_BURST_ENABLE,
3991         WMI_10_4_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA,
3992         WMI_10_4_PDEV_PARAM_IGMPMLD_OVERRIDE,
3993         WMI_10_4_PDEV_PARAM_IGMPMLD_TID,
3994         WMI_10_4_PDEV_PARAM_ANTENNA_GAIN,
3995         WMI_10_4_PDEV_PARAM_RX_FILTER,
3996         WMI_10_4_PDEV_SET_MCAST_TO_UCAST_TID,
3997         WMI_10_4_PDEV_PARAM_PROXY_STA_MODE,
3998         WMI_10_4_PDEV_PARAM_SET_MCAST2UCAST_MODE,
3999         WMI_10_4_PDEV_PARAM_SET_MCAST2UCAST_BUFFER,
4000         WMI_10_4_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER,
4001         WMI_10_4_PDEV_PEER_STA_PS_STATECHG_ENABLE,
4002         WMI_10_4_PDEV_PARAM_IGMPMLD_AC_OVERRIDE,
4003         WMI_10_4_PDEV_PARAM_BLOCK_INTERBSS,
4004         WMI_10_4_PDEV_PARAM_SET_DISABLE_RESET_CMDID,
4005         WMI_10_4_PDEV_PARAM_SET_MSDU_TTL_CMDID,
4006         WMI_10_4_PDEV_PARAM_SET_PPDU_DURATION_CMDID,
4007         WMI_10_4_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID,
4008         WMI_10_4_PDEV_PARAM_SET_PROMISC_MODE_CMDID,
4009         WMI_10_4_PDEV_PARAM_SET_BURST_MODE_CMDID,
4010         WMI_10_4_PDEV_PARAM_EN_STATS,
4011         WMI_10_4_PDEV_PARAM_MU_GROUP_POLICY,
4012         WMI_10_4_PDEV_PARAM_NOISE_DETECTION,
4013         WMI_10_4_PDEV_PARAM_NOISE_THRESHOLD,
4014         WMI_10_4_PDEV_PARAM_DPD_ENABLE,
4015         WMI_10_4_PDEV_PARAM_SET_MCAST_BCAST_ECHO,
4016         WMI_10_4_PDEV_PARAM_ATF_STRICT_SCH,
4017         WMI_10_4_PDEV_PARAM_ATF_SCHED_DURATION,
4018         WMI_10_4_PDEV_PARAM_ANT_PLZN,
4019         WMI_10_4_PDEV_PARAM_MGMT_RETRY_LIMIT,
4020         WMI_10_4_PDEV_PARAM_SENSITIVITY_LEVEL,
4021         WMI_10_4_PDEV_PARAM_SIGNED_TXPOWER_2G,
4022         WMI_10_4_PDEV_PARAM_SIGNED_TXPOWER_5G,
4023         WMI_10_4_PDEV_PARAM_ENABLE_PER_TID_AMSDU,
4024         WMI_10_4_PDEV_PARAM_ENABLE_PER_TID_AMPDU,
4025         WMI_10_4_PDEV_PARAM_CCA_THRESHOLD,
4026         WMI_10_4_PDEV_PARAM_RTS_FIXED_RATE,
4027         WMI_10_4_PDEV_PARAM_CAL_PERIOD,
4028         WMI_10_4_PDEV_PARAM_PDEV_RESET,
4029         WMI_10_4_PDEV_PARAM_WAPI_MBSSID_OFFSET,
4030         WMI_10_4_PDEV_PARAM_ARP_SRCADDR,
4031         WMI_10_4_PDEV_PARAM_ARP_DSTADDR,
4032         WMI_10_4_PDEV_PARAM_TXPOWER_DECR_DB,
4033         WMI_10_4_PDEV_PARAM_RX_BATCHMODE,
4034         WMI_10_4_PDEV_PARAM_PACKET_AGGR_DELAY,
4035         WMI_10_4_PDEV_PARAM_ATF_OBSS_NOISE_SCH,
4036         WMI_10_4_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR,
4037         WMI_10_4_PDEV_PARAM_CUST_TXPOWER_SCALE,
4038         WMI_10_4_PDEV_PARAM_ATF_DYNAMIC_ENABLE,
4039         WMI_10_4_PDEV_PARAM_ATF_SSID_GROUP_POLICY,
4040         WMI_10_4_PDEV_PARAM_ENABLE_BTCOEX,
4041 };
4042
4043 struct wmi_pdev_set_param_cmd {
4044         __le32 param_id;
4045         __le32 param_value;
4046 } __packed;
4047
4048 /* valid period is 1 ~ 60000ms, unit in millisecond */
4049 #define WMI_PDEV_PARAM_CAL_PERIOD_MAX 60000
4050
4051 struct wmi_pdev_get_tpc_config_cmd {
4052         /* parameter   */
4053         __le32 param;
4054 } __packed;
4055
4056 #define WMI_TPC_CONFIG_PARAM            1
4057 #define WMI_TPC_FINAL_RATE_MAX          240
4058 #define WMI_TPC_TX_N_CHAIN              4
4059 #define WMI_TPC_RATE_MAX               (WMI_TPC_TX_N_CHAIN * 65)
4060 #define WMI_TPC_PREAM_TABLE_MAX         10
4061 #define WMI_TPC_FLAG                    3
4062 #define WMI_TPC_BUF_SIZE                10
4063 #define WMI_TPC_BEAMFORMING             2
4064
4065 enum wmi_tpc_table_type {
4066         WMI_TPC_TABLE_TYPE_CDD = 0,
4067         WMI_TPC_TABLE_TYPE_STBC = 1,
4068         WMI_TPC_TABLE_TYPE_TXBF = 2,
4069 };
4070
4071 enum wmi_tpc_config_event_flag {
4072         WMI_TPC_CONFIG_EVENT_FLAG_TABLE_CDD     = 0x1,
4073         WMI_TPC_CONFIG_EVENT_FLAG_TABLE_STBC    = 0x2,
4074         WMI_TPC_CONFIG_EVENT_FLAG_TABLE_TXBF    = 0x4,
4075 };
4076
4077 struct wmi_pdev_tpc_config_event {
4078         __le32 reg_domain;
4079         __le32 chan_freq;
4080         __le32 phy_mode;
4081         __le32 twice_antenna_reduction;
4082         __le32 twice_max_rd_power;
4083         a_sle32 twice_antenna_gain;
4084         __le32 power_limit;
4085         __le32 rate_max;
4086         __le32 num_tx_chain;
4087         __le32 ctl;
4088         __le32 flags;
4089         s8 max_reg_allow_pow[WMI_TPC_TX_N_CHAIN];
4090         s8 max_reg_allow_pow_agcdd[WMI_TPC_TX_N_CHAIN][WMI_TPC_TX_N_CHAIN];
4091         s8 max_reg_allow_pow_agstbc[WMI_TPC_TX_N_CHAIN][WMI_TPC_TX_N_CHAIN];
4092         s8 max_reg_allow_pow_agtxbf[WMI_TPC_TX_N_CHAIN][WMI_TPC_TX_N_CHAIN];
4093         u8 rates_array[WMI_TPC_RATE_MAX];
4094 } __packed;
4095
4096 /* Transmit power scale factor. */
4097 enum wmi_tp_scale {
4098         WMI_TP_SCALE_MAX    = 0,        /* no scaling (default) */
4099         WMI_TP_SCALE_50     = 1,        /* 50% of max (-3 dBm) */
4100         WMI_TP_SCALE_25     = 2,        /* 25% of max (-6 dBm) */
4101         WMI_TP_SCALE_12     = 3,        /* 12% of max (-9 dBm) */
4102         WMI_TP_SCALE_MIN    = 4,        /* min, but still on   */
4103         WMI_TP_SCALE_SIZE   = 5,        /* max num of enum     */
4104 };
4105
4106 struct wmi_pdev_tpc_final_table_event {
4107         __le32 reg_domain;
4108         __le32 chan_freq;
4109         __le32 phy_mode;
4110         __le32 twice_antenna_reduction;
4111         __le32 twice_max_rd_power;
4112         a_sle32 twice_antenna_gain;
4113         __le32 power_limit;
4114         __le32 rate_max;
4115         __le32 num_tx_chain;
4116         __le32 ctl;
4117         __le32 flags;
4118         s8 max_reg_allow_pow[WMI_TPC_TX_N_CHAIN];
4119         s8 max_reg_allow_pow_agcdd[WMI_TPC_TX_N_CHAIN][WMI_TPC_TX_N_CHAIN];
4120         s8 max_reg_allow_pow_agstbc[WMI_TPC_TX_N_CHAIN][WMI_TPC_TX_N_CHAIN];
4121         s8 max_reg_allow_pow_agtxbf[WMI_TPC_TX_N_CHAIN][WMI_TPC_TX_N_CHAIN];
4122         u8 rates_array[WMI_TPC_FINAL_RATE_MAX];
4123         u8 ctl_power_table[WMI_TPC_BEAMFORMING][WMI_TPC_TX_N_CHAIN]
4124            [WMI_TPC_TX_N_CHAIN];
4125 } __packed;
4126
4127 struct wmi_pdev_get_tpc_table_cmd {
4128         __le32 param;
4129 } __packed;
4130
4131 enum wmi_tpc_pream_2ghz {
4132         WMI_TPC_PREAM_2GHZ_CCK = 0,
4133         WMI_TPC_PREAM_2GHZ_OFDM,
4134         WMI_TPC_PREAM_2GHZ_HT20,
4135         WMI_TPC_PREAM_2GHZ_HT40,
4136         WMI_TPC_PREAM_2GHZ_VHT20,
4137         WMI_TPC_PREAM_2GHZ_VHT40,
4138         WMI_TPC_PREAM_2GHZ_VHT80,
4139 };
4140
4141 enum wmi_tpc_pream_5ghz {
4142         WMI_TPC_PREAM_5GHZ_OFDM = 1,
4143         WMI_TPC_PREAM_5GHZ_HT20,
4144         WMI_TPC_PREAM_5GHZ_HT40,
4145         WMI_TPC_PREAM_5GHZ_VHT20,
4146         WMI_TPC_PREAM_5GHZ_VHT40,
4147         WMI_TPC_PREAM_5GHZ_VHT80,
4148         WMI_TPC_PREAM_5GHZ_HTCUP,
4149 };
4150
4151 struct wmi_pdev_chanlist_update_event {
4152         /* number of channels */
4153         __le32 num_chan;
4154         /* array of channels */
4155         struct wmi_channel channel_list[1];
4156 } __packed;
4157
4158 #define WMI_MAX_DEBUG_MESG (sizeof(u32) * 32)
4159
4160 struct wmi_debug_mesg_event {
4161         /* message buffer, NULL terminated */
4162         char bufp[WMI_MAX_DEBUG_MESG];
4163 } __packed;
4164
4165 enum {
4166         /* P2P device */
4167         VDEV_SUBTYPE_P2PDEV = 0,
4168         /* P2P client */
4169         VDEV_SUBTYPE_P2PCLI,
4170         /* P2P GO */
4171         VDEV_SUBTYPE_P2PGO,
4172         /* BT3.0 HS */
4173         VDEV_SUBTYPE_BT,
4174 };
4175
4176 struct wmi_pdev_set_channel_cmd {
4177         /* idnore power , only use flags , mode and freq */
4178         struct wmi_channel chan;
4179 } __packed;
4180
4181 struct wmi_pdev_pktlog_enable_cmd {
4182         __le32 ev_bitmap;
4183 } __packed;
4184
4185 /* Customize the DSCP (bit) to TID (0-7) mapping for QOS */
4186 #define WMI_DSCP_MAP_MAX    (64)
4187 struct wmi_pdev_set_dscp_tid_map_cmd {
4188         /* map indicating DSCP to TID conversion */
4189         __le32 dscp_to_tid_map[WMI_DSCP_MAP_MAX];
4190 } __packed;
4191
4192 enum mcast_bcast_rate_id {
4193         WMI_SET_MCAST_RATE,
4194         WMI_SET_BCAST_RATE
4195 };
4196
4197 struct mcast_bcast_rate {
4198         enum mcast_bcast_rate_id rate_id;
4199         __le32 rate;
4200 } __packed;
4201
4202 struct wmi_wmm_params {
4203         __le32 cwmin;
4204         __le32 cwmax;
4205         __le32 aifs;
4206         __le32 txop;
4207         __le32 acm;
4208         __le32 no_ack;
4209 } __packed;
4210
4211 struct wmi_pdev_set_wmm_params {
4212         struct wmi_wmm_params ac_be;
4213         struct wmi_wmm_params ac_bk;
4214         struct wmi_wmm_params ac_vi;
4215         struct wmi_wmm_params ac_vo;
4216 } __packed;
4217
4218 struct wmi_wmm_params_arg {
4219         u32 cwmin;
4220         u32 cwmax;
4221         u32 aifs;
4222         u32 txop;
4223         u32 acm;
4224         u32 no_ack;
4225 };
4226
4227 struct wmi_wmm_params_all_arg {
4228         struct wmi_wmm_params_arg ac_be;
4229         struct wmi_wmm_params_arg ac_bk;
4230         struct wmi_wmm_params_arg ac_vi;
4231         struct wmi_wmm_params_arg ac_vo;
4232 };
4233
4234 struct wmi_pdev_stats_tx {
4235         /* Num HTT cookies queued to dispatch list */
4236         __le32 comp_queued;
4237
4238         /* Num HTT cookies dispatched */
4239         __le32 comp_delivered;
4240
4241         /* Num MSDU queued to WAL */
4242         __le32 msdu_enqued;
4243
4244         /* Num MPDU queue to WAL */
4245         __le32 mpdu_enqued;
4246
4247         /* Num MSDUs dropped by WMM limit */
4248         __le32 wmm_drop;
4249
4250         /* Num Local frames queued */
4251         __le32 local_enqued;
4252
4253         /* Num Local frames done */
4254         __le32 local_freed;
4255
4256         /* Num queued to HW */
4257         __le32 hw_queued;
4258
4259         /* Num PPDU reaped from HW */
4260         __le32 hw_reaped;
4261
4262         /* Num underruns */
4263         __le32 underrun;
4264
4265         /* Num PPDUs cleaned up in TX abort */
4266         __le32 tx_abort;
4267
4268         /* Num MPDUs requed by SW */
4269         __le32 mpdus_requed;
4270
4271         /* excessive retries */
4272         __le32 tx_ko;
4273
4274         /* data hw rate code */
4275         __le32 data_rc;
4276
4277         /* Scheduler self triggers */
4278         __le32 self_triggers;
4279
4280         /* frames dropped due to excessive sw retries */
4281         __le32 sw_retry_failure;
4282
4283         /* illegal rate phy errors  */
4284         __le32 illgl_rate_phy_err;
4285
4286         /* wal pdev continuous xretry */
4287         __le32 pdev_cont_xretry;
4288
4289         /* wal pdev continous xretry */
4290         __le32 pdev_tx_timeout;
4291
4292         /* wal pdev resets  */
4293         __le32 pdev_resets;
4294
4295         /* frames dropped due to non-availability of stateless TIDs */
4296         __le32 stateless_tid_alloc_failure;
4297
4298         __le32 phy_underrun;
4299
4300         /* MPDU is more than txop limit */
4301         __le32 txop_ovf;
4302 } __packed;
4303
4304 struct wmi_10_4_pdev_stats_tx {
4305         /* Num HTT cookies queued to dispatch list */
4306         __le32 comp_queued;
4307
4308         /* Num HTT cookies dispatched */
4309         __le32 comp_delivered;
4310
4311         /* Num MSDU queued to WAL */
4312         __le32 msdu_enqued;
4313
4314         /* Num MPDU queue to WAL */
4315         __le32 mpdu_enqued;
4316
4317         /* Num MSDUs dropped by WMM limit */
4318         __le32 wmm_drop;
4319
4320         /* Num Local frames queued */
4321         __le32 local_enqued;
4322
4323         /* Num Local frames done */
4324         __le32 local_freed;
4325
4326         /* Num queued to HW */
4327         __le32 hw_queued;
4328
4329         /* Num PPDU reaped from HW */
4330         __le32 hw_reaped;
4331
4332         /* Num underruns */
4333         __le32 underrun;
4334
4335         /* HW Paused. */
4336         __le32  hw_paused;
4337
4338         /* Num PPDUs cleaned up in TX abort */
4339         __le32 tx_abort;
4340
4341         /* Num MPDUs requed by SW */
4342         __le32 mpdus_requed;
4343
4344         /* excessive retries */
4345         __le32 tx_ko;
4346
4347         /* data hw rate code */
4348         __le32 data_rc;
4349
4350         /* Scheduler self triggers */
4351         __le32 self_triggers;
4352
4353         /* frames dropped due to excessive sw retries */
4354         __le32 sw_retry_failure;
4355
4356         /* illegal rate phy errors  */
4357         __le32 illgl_rate_phy_err;
4358
4359         /* wal pdev continuous xretry */
4360         __le32 pdev_cont_xretry;
4361
4362         /* wal pdev tx timeouts */
4363         __le32 pdev_tx_timeout;
4364
4365         /* wal pdev resets  */
4366         __le32 pdev_resets;
4367
4368         /* frames dropped due to non-availability of stateless TIDs */
4369         __le32 stateless_tid_alloc_failure;
4370
4371         __le32 phy_underrun;
4372
4373         /* MPDU is more than txop limit */
4374         __le32 txop_ovf;
4375
4376         /* Number of Sequences posted */
4377         __le32 seq_posted;
4378
4379         /* Number of Sequences failed queueing */
4380         __le32 seq_failed_queueing;
4381
4382         /* Number of Sequences completed */
4383         __le32 seq_completed;
4384
4385         /* Number of Sequences restarted */
4386         __le32 seq_restarted;
4387
4388         /* Number of MU Sequences posted */
4389         __le32 mu_seq_posted;
4390
4391         /* Num MPDUs flushed by SW, HWPAUSED,SW TXABORT(Reset,channel change) */
4392         __le32 mpdus_sw_flush;
4393
4394         /* Num MPDUs filtered by HW, all filter condition (TTL expired) */
4395         __le32 mpdus_hw_filter;
4396
4397         /* Num MPDUs truncated by PDG
4398          * (TXOP, TBTT, PPDU_duration based on rate, dyn_bw)
4399          */
4400         __le32 mpdus_truncated;
4401
4402         /* Num MPDUs that was tried but didn't receive ACK or BA */
4403         __le32 mpdus_ack_failed;
4404
4405         /* Num MPDUs that was dropped due to expiry. */
4406         __le32 mpdus_expired;
4407 } __packed;
4408
4409 struct wmi_pdev_stats_rx {
4410         /* Cnts any change in ring routing mid-ppdu */
4411         __le32 mid_ppdu_route_change;
4412
4413         /* Total number of statuses processed */
4414         __le32 status_rcvd;
4415
4416         /* Extra frags on rings 0-3 */
4417         __le32 r0_frags;
4418         __le32 r1_frags;
4419         __le32 r2_frags;
4420         __le32 r3_frags;
4421
4422         /* MSDUs / MPDUs delivered to HTT */
4423         __le32 htt_msdus;
4424         __le32 htt_mpdus;
4425
4426         /* MSDUs / MPDUs delivered to local stack */
4427         __le32 loc_msdus;
4428         __le32 loc_mpdus;
4429
4430         /* AMSDUs that have more MSDUs than the status ring size */
4431         __le32 oversize_amsdu;
4432
4433         /* Number of PHY errors */
4434         __le32 phy_errs;
4435
4436         /* Number of PHY errors drops */
4437         __le32 phy_err_drop;
4438
4439         /* Number of mpdu errors - FCS, MIC, ENC etc. */
4440         __le32 mpdu_errs;
4441 } __packed;
4442
4443 struct wmi_pdev_stats_peer {
4444         /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */
4445         __le32 dummy;
4446 } __packed;
4447
4448 enum wmi_stats_id {
4449         WMI_STAT_PEER = BIT(0),
4450         WMI_STAT_AP = BIT(1),
4451         WMI_STAT_PDEV = BIT(2),
4452         WMI_STAT_VDEV = BIT(3),
4453         WMI_STAT_BCNFLT = BIT(4),
4454         WMI_STAT_VDEV_RATE = BIT(5),
4455 };
4456
4457 enum wmi_10_4_stats_id {
4458         WMI_10_4_STAT_PEER              = BIT(0),
4459         WMI_10_4_STAT_AP                = BIT(1),
4460         WMI_10_4_STAT_INST              = BIT(2),
4461         WMI_10_4_STAT_PEER_EXTD         = BIT(3),
4462         WMI_10_4_STAT_VDEV_EXTD         = BIT(4),
4463 };
4464
4465 struct wlan_inst_rssi_args {
4466         __le16 cfg_retry_count;
4467         __le16 retry_count;
4468 };
4469
4470 struct wmi_request_stats_cmd {
4471         __le32 stats_id;
4472
4473         __le32 vdev_id;
4474
4475         /* peer MAC address */
4476         struct wmi_mac_addr peer_macaddr;
4477
4478         /* Instantaneous RSSI arguments */
4479         struct wlan_inst_rssi_args inst_rssi_args;
4480 } __packed;
4481
4482 /* Suspend option */
4483 enum {
4484         /* suspend */
4485         WMI_PDEV_SUSPEND,
4486
4487         /* suspend and disable all interrupts */
4488         WMI_PDEV_SUSPEND_AND_DISABLE_INTR,
4489 };
4490
4491 struct wmi_pdev_suspend_cmd {
4492         /* suspend option sent to target */
4493         __le32 suspend_opt;
4494 } __packed;
4495
4496 struct wmi_stats_event {
4497         __le32 stats_id; /* WMI_STAT_ */
4498         /*
4499          * number of pdev stats event structures
4500          * (wmi_pdev_stats) 0 or 1
4501          */
4502         __le32 num_pdev_stats;
4503         /*
4504          * number of vdev stats event structures
4505          * (wmi_vdev_stats) 0 or max vdevs
4506          */
4507         __le32 num_vdev_stats;
4508         /*
4509          * number of peer stats event structures
4510          * (wmi_peer_stats) 0 or max peers
4511          */
4512         __le32 num_peer_stats;
4513         __le32 num_bcnflt_stats;
4514         /*
4515          * followed by
4516          *   num_pdev_stats * size of(struct wmi_pdev_stats)
4517          *   num_vdev_stats * size of(struct wmi_vdev_stats)
4518          *   num_peer_stats * size of(struct wmi_peer_stats)
4519          *
4520          *  By having a zero sized array, the pointer to data area
4521          *  becomes available without increasing the struct size
4522          */
4523         u8 data[0];
4524 } __packed;
4525
4526 struct wmi_10_2_stats_event {
4527         __le32 stats_id; /* %WMI_REQUEST_ */
4528         __le32 num_pdev_stats;
4529         __le32 num_pdev_ext_stats;
4530         __le32 num_vdev_stats;
4531         __le32 num_peer_stats;
4532         __le32 num_bcnflt_stats;
4533         u8 data[0];
4534 } __packed;
4535
4536 /*
4537  * PDEV statistics
4538  * TODO: add all PDEV stats here
4539  */
4540 struct wmi_pdev_stats_base {
4541         __le32 chan_nf;
4542         __le32 tx_frame_count; /* Cycles spent transmitting frames */
4543         __le32 rx_frame_count; /* Cycles spent receiving frames */
4544         __le32 rx_clear_count; /* Total channel busy time, evidently */
4545         __le32 cycle_count; /* Total on-channel time */
4546         __le32 phy_err_count;
4547         __le32 chan_tx_pwr;
4548 } __packed;
4549
4550 struct wmi_pdev_stats {
4551         struct wmi_pdev_stats_base base;
4552         struct wmi_pdev_stats_tx tx;
4553         struct wmi_pdev_stats_rx rx;
4554         struct wmi_pdev_stats_peer peer;
4555 } __packed;
4556
4557 struct wmi_pdev_stats_extra {
4558         __le32 ack_rx_bad;
4559         __le32 rts_bad;
4560         __le32 rts_good;
4561         __le32 fcs_bad;
4562         __le32 no_beacons;
4563         __le32 mib_int_count;
4564 } __packed;
4565
4566 struct wmi_10x_pdev_stats {
4567         struct wmi_pdev_stats_base base;
4568         struct wmi_pdev_stats_tx tx;
4569         struct wmi_pdev_stats_rx rx;
4570         struct wmi_pdev_stats_peer peer;
4571         struct wmi_pdev_stats_extra extra;
4572 } __packed;
4573
4574 struct wmi_pdev_stats_mem {
4575         __le32 dram_free;
4576         __le32 iram_free;
4577 } __packed;
4578
4579 struct wmi_10_2_pdev_stats {
4580         struct wmi_pdev_stats_base base;
4581         struct wmi_pdev_stats_tx tx;
4582         __le32 mc_drop;
4583         struct wmi_pdev_stats_rx rx;
4584         __le32 pdev_rx_timeout;
4585         struct wmi_pdev_stats_mem mem;
4586         struct wmi_pdev_stats_peer peer;
4587         struct wmi_pdev_stats_extra extra;
4588 } __packed;
4589
4590 struct wmi_10_4_pdev_stats {
4591         struct wmi_pdev_stats_base base;
4592         struct wmi_10_4_pdev_stats_tx tx;
4593         struct wmi_pdev_stats_rx rx;
4594         __le32 rx_ovfl_errs;
4595         struct wmi_pdev_stats_mem mem;
4596         __le32 sram_free_size;
4597         struct wmi_pdev_stats_extra extra;
4598 } __packed;
4599
4600 /*
4601  * VDEV statistics
4602  */
4603
4604 #define WMI_VDEV_STATS_FTM_COUNT_VALID  BIT(31)
4605 #define WMI_VDEV_STATS_FTM_COUNT_LSB    0
4606 #define WMI_VDEV_STATS_FTM_COUNT_MASK   0x7fffffff
4607
4608 struct wmi_vdev_stats {
4609         __le32 vdev_id;
4610 } __packed;
4611
4612 struct wmi_vdev_stats_extd {
4613         __le32 vdev_id;
4614         __le32 ppdu_aggr_cnt;
4615         __le32 ppdu_noack;
4616         __le32 mpdu_queued;
4617         __le32 ppdu_nonaggr_cnt;
4618         __le32 mpdu_sw_requeued;
4619         __le32 mpdu_suc_retry;
4620         __le32 mpdu_suc_multitry;
4621         __le32 mpdu_fail_retry;
4622         __le32 tx_ftm_suc;
4623         __le32 tx_ftm_suc_retry;
4624         __le32 tx_ftm_fail;
4625         __le32 rx_ftmr_cnt;
4626         __le32 rx_ftmr_dup_cnt;
4627         __le32 rx_iftmr_cnt;
4628         __le32 rx_iftmr_dup_cnt;
4629         __le32 reserved[6];
4630 } __packed;
4631
4632 /*
4633  * peer statistics.
4634  * TODO: add more stats
4635  */
4636 struct wmi_peer_stats {
4637         struct wmi_mac_addr peer_macaddr;
4638         __le32 peer_rssi;
4639         __le32 peer_tx_rate;
4640 } __packed;
4641
4642 struct wmi_10x_peer_stats {
4643         struct wmi_peer_stats old;
4644         __le32 peer_rx_rate;
4645 } __packed;
4646
4647 struct wmi_10_2_peer_stats {
4648         struct wmi_peer_stats old;
4649         __le32 peer_rx_rate;
4650         __le32 current_per;
4651         __le32 retries;
4652         __le32 tx_rate_count;
4653         __le32 max_4ms_frame_len;
4654         __le32 total_sub_frames;
4655         __le32 tx_bytes;
4656         __le32 num_pkt_loss_overflow[4];
4657         __le32 num_pkt_loss_excess_retry[4];
4658 } __packed;
4659
4660 struct wmi_10_2_4_peer_stats {
4661         struct wmi_10_2_peer_stats common;
4662         __le32 peer_rssi_changed;
4663 } __packed;
4664
4665 struct wmi_10_2_4_ext_peer_stats {
4666         struct wmi_10_2_peer_stats common;
4667         __le32 peer_rssi_changed;
4668         __le32 rx_duration;
4669 } __packed;
4670
4671 struct wmi_10_4_peer_stats {
4672         struct wmi_mac_addr peer_macaddr;
4673         __le32 peer_rssi;
4674         __le32 peer_rssi_seq_num;
4675         __le32 peer_tx_rate;
4676         __le32 peer_rx_rate;
4677         __le32 current_per;
4678         __le32 retries;
4679         __le32 tx_rate_count;
4680         __le32 max_4ms_frame_len;
4681         __le32 total_sub_frames;
4682         __le32 tx_bytes;
4683         __le32 num_pkt_loss_overflow[4];
4684         __le32 num_pkt_loss_excess_retry[4];
4685         __le32 peer_rssi_changed;
4686 } __packed;
4687
4688 struct wmi_10_4_peer_extd_stats {
4689         struct wmi_mac_addr peer_macaddr;
4690         __le32 inactive_time;
4691         __le32 peer_chain_rssi;
4692         __le32 rx_duration;
4693         __le32 reserved[10];
4694 } __packed;
4695
4696 struct wmi_10_4_bss_bcn_stats {
4697         __le32 vdev_id;
4698         __le32 bss_bcns_dropped;
4699         __le32 bss_bcn_delivered;
4700 } __packed;
4701
4702 struct wmi_10_4_bss_bcn_filter_stats {
4703         __le32 bcns_dropped;
4704         __le32 bcns_delivered;
4705         __le32 active_filters;
4706         struct wmi_10_4_bss_bcn_stats bss_stats;
4707 } __packed;
4708
4709 struct wmi_10_2_pdev_ext_stats {
4710         __le32 rx_rssi_comb;
4711         __le32 rx_rssi[4];
4712         __le32 rx_mcs[10];
4713         __le32 tx_mcs[10];
4714         __le32 ack_rssi;
4715 } __packed;
4716
4717 struct wmi_vdev_create_cmd {
4718         __le32 vdev_id;
4719         __le32 vdev_type;
4720         __le32 vdev_subtype;
4721         struct wmi_mac_addr vdev_macaddr;
4722 } __packed;
4723
4724 enum wmi_vdev_type {
4725         WMI_VDEV_TYPE_AP      = 1,
4726         WMI_VDEV_TYPE_STA     = 2,
4727         WMI_VDEV_TYPE_IBSS    = 3,
4728         WMI_VDEV_TYPE_MONITOR = 4,
4729 };
4730
4731 enum wmi_vdev_subtype {
4732         WMI_VDEV_SUBTYPE_NONE,
4733         WMI_VDEV_SUBTYPE_P2P_DEVICE,
4734         WMI_VDEV_SUBTYPE_P2P_CLIENT,
4735         WMI_VDEV_SUBTYPE_P2P_GO,
4736         WMI_VDEV_SUBTYPE_PROXY_STA,
4737         WMI_VDEV_SUBTYPE_MESH_11S,
4738         WMI_VDEV_SUBTYPE_MESH_NON_11S,
4739 };
4740
4741 enum wmi_vdev_subtype_legacy {
4742         WMI_VDEV_SUBTYPE_LEGACY_NONE      = 0,
4743         WMI_VDEV_SUBTYPE_LEGACY_P2P_DEV   = 1,
4744         WMI_VDEV_SUBTYPE_LEGACY_P2P_CLI   = 2,
4745         WMI_VDEV_SUBTYPE_LEGACY_P2P_GO    = 3,
4746         WMI_VDEV_SUBTYPE_LEGACY_PROXY_STA = 4,
4747 };
4748
4749 enum wmi_vdev_subtype_10_2_4 {
4750         WMI_VDEV_SUBTYPE_10_2_4_NONE      = 0,
4751         WMI_VDEV_SUBTYPE_10_2_4_P2P_DEV   = 1,
4752         WMI_VDEV_SUBTYPE_10_2_4_P2P_CLI   = 2,
4753         WMI_VDEV_SUBTYPE_10_2_4_P2P_GO    = 3,
4754         WMI_VDEV_SUBTYPE_10_2_4_PROXY_STA = 4,
4755         WMI_VDEV_SUBTYPE_10_2_4_MESH_11S  = 5,
4756 };
4757
4758 enum wmi_vdev_subtype_10_4 {
4759         WMI_VDEV_SUBTYPE_10_4_NONE         = 0,
4760         WMI_VDEV_SUBTYPE_10_4_P2P_DEV      = 1,
4761         WMI_VDEV_SUBTYPE_10_4_P2P_CLI      = 2,
4762         WMI_VDEV_SUBTYPE_10_4_P2P_GO       = 3,
4763         WMI_VDEV_SUBTYPE_10_4_PROXY_STA    = 4,
4764         WMI_VDEV_SUBTYPE_10_4_MESH_NON_11S = 5,
4765         WMI_VDEV_SUBTYPE_10_4_MESH_11S     = 6,
4766 };
4767
4768 /* values for vdev_subtype */
4769
4770 /* values for vdev_start_request flags */
4771 /*
4772  * Indicates that AP VDEV uses hidden ssid. only valid for
4773  *  AP/GO
4774  */
4775 #define WMI_VDEV_START_HIDDEN_SSID  (1 << 0)
4776 /*
4777  * Indicates if robust management frame/management frame
4778  *  protection is enabled. For GO/AP vdevs, it indicates that
4779  *  it may support station/client associations with RMF enabled.
4780  *  For STA/client vdevs, it indicates that sta will
4781  *  associate with AP with RMF enabled.
4782  */
4783 #define WMI_VDEV_START_PMF_ENABLED  (1 << 1)
4784
4785 struct wmi_p2p_noa_descriptor {
4786         __le32 type_count; /* 255: continuous schedule, 0: reserved */
4787         __le32 duration;  /* Absent period duration in micro seconds */
4788         __le32 interval;   /* Absent period interval in micro seconds */
4789         __le32 start_time; /* 32 bit tsf time when in starts */
4790 } __packed;
4791
4792 struct wmi_vdev_start_request_cmd {
4793         /* WMI channel */
4794         struct wmi_channel chan;
4795         /* unique id identifying the VDEV, generated by the caller */
4796         __le32 vdev_id;
4797         /* requestor id identifying the caller module */
4798         __le32 requestor_id;
4799         /* beacon interval from received beacon */
4800         __le32 beacon_interval;
4801         /* DTIM Period from the received beacon */
4802         __le32 dtim_period;
4803         /* Flags */
4804         __le32 flags;
4805         /* ssid field. Only valid for AP/GO/IBSS/BTAmp VDEV type. */
4806         struct wmi_ssid ssid;
4807         /* beacon/probe response xmit rate. Applicable for SoftAP. */
4808         __le32 bcn_tx_rate;
4809         /* beacon/probe response xmit power. Applicable for SoftAP. */
4810         __le32 bcn_tx_power;
4811         /* number of p2p NOA descriptor(s) from scan entry */
4812         __le32 num_noa_descriptors;
4813         /*
4814          * Disable H/W ack. This used by WMI_VDEV_RESTART_REQUEST_CMDID.
4815          * During CAC, Our HW shouldn't ack ditected frames
4816          */
4817         __le32 disable_hw_ack;
4818         /* actual p2p NOA descriptor from scan entry */
4819         struct wmi_p2p_noa_descriptor noa_descriptors[2];
4820 } __packed;
4821
4822 struct wmi_vdev_restart_request_cmd {
4823         struct wmi_vdev_start_request_cmd vdev_start_request_cmd;
4824 } __packed;
4825
4826 struct wmi_vdev_start_request_arg {
4827         u32 vdev_id;
4828         struct wmi_channel_arg channel;
4829         u32 bcn_intval;
4830         u32 dtim_period;
4831         u8 *ssid;
4832         u32 ssid_len;
4833         u32 bcn_tx_rate;
4834         u32 bcn_tx_power;
4835         bool disable_hw_ack;
4836         bool hidden_ssid;
4837         bool pmf_enabled;
4838 };
4839
4840 struct wmi_vdev_delete_cmd {
4841         /* unique id identifying the VDEV, generated by the caller */
4842         __le32 vdev_id;
4843 } __packed;
4844
4845 struct wmi_vdev_up_cmd {
4846         __le32 vdev_id;
4847         __le32 vdev_assoc_id;
4848         struct wmi_mac_addr vdev_bssid;
4849 } __packed;
4850
4851 struct wmi_vdev_stop_cmd {
4852         __le32 vdev_id;
4853 } __packed;
4854
4855 struct wmi_vdev_down_cmd {
4856         __le32 vdev_id;
4857 } __packed;
4858
4859 struct wmi_vdev_standby_response_cmd {
4860         /* unique id identifying the VDEV, generated by the caller */
4861         __le32 vdev_id;
4862 } __packed;
4863
4864 struct wmi_vdev_resume_response_cmd {
4865         /* unique id identifying the VDEV, generated by the caller */
4866         __le32 vdev_id;
4867 } __packed;
4868
4869 struct wmi_vdev_set_param_cmd {
4870         __le32 vdev_id;
4871         __le32 param_id;
4872         __le32 param_value;
4873 } __packed;
4874
4875 #define WMI_MAX_KEY_INDEX   3
4876 #define WMI_MAX_KEY_LEN     32
4877
4878 #define WMI_KEY_PAIRWISE 0x00
4879 #define WMI_KEY_GROUP    0x01
4880 #define WMI_KEY_TX_USAGE 0x02 /* default tx key - static wep */
4881
4882 struct wmi_key_seq_counter {
4883         __le32 key_seq_counter_l;
4884         __le32 key_seq_counter_h;
4885 } __packed;
4886
4887 #define WMI_CIPHER_NONE     0x0 /* clear key */
4888 #define WMI_CIPHER_WEP      0x1
4889 #define WMI_CIPHER_TKIP     0x2
4890 #define WMI_CIPHER_AES_OCB  0x3
4891 #define WMI_CIPHER_AES_CCM  0x4
4892 #define WMI_CIPHER_WAPI     0x5
4893 #define WMI_CIPHER_CKIP     0x6
4894 #define WMI_CIPHER_AES_CMAC 0x7
4895 #define WMI_CIPHER_AES_GCM  0x8
4896
4897 struct wmi_vdev_install_key_cmd {
4898         __le32 vdev_id;
4899         struct wmi_mac_addr peer_macaddr;
4900         __le32 key_idx;
4901         __le32 key_flags;
4902         __le32 key_cipher; /* %WMI_CIPHER_ */
4903         struct wmi_key_seq_counter key_rsc_counter;
4904         struct wmi_key_seq_counter key_global_rsc_counter;
4905         struct wmi_key_seq_counter key_tsc_counter;
4906         u8 wpi_key_rsc_counter[16];
4907         u8 wpi_key_tsc_counter[16];
4908         __le32 key_len;
4909         __le32 key_txmic_len;
4910         __le32 key_rxmic_len;
4911
4912         /* contains key followed by tx mic followed by rx mic */
4913         u8 key_data[0];
4914 } __packed;
4915
4916 struct wmi_vdev_install_key_arg {
4917         u32 vdev_id;
4918         const u8 *macaddr;
4919         u32 key_idx;
4920         u32 key_flags;
4921         u32 key_cipher;
4922         u32 key_len;
4923         u32 key_txmic_len;
4924         u32 key_rxmic_len;
4925         const void *key_data;
4926 };
4927
4928 /*
4929  * vdev fixed rate format:
4930  * - preamble - b7:b6 - see WMI_RATE_PREMABLE_
4931  * - nss      - b5:b4 - ss number (0 mean 1ss)
4932  * - rate_mcs - b3:b0 - as below
4933  *    CCK:  0 - 11Mbps, 1 - 5,5Mbps, 2 - 2Mbps, 3 - 1Mbps,
4934  *          4 - 11Mbps (s), 5 - 5,5Mbps (s), 6 - 2Mbps (s)
4935  *    OFDM: 0 - 48Mbps, 1 - 24Mbps, 2 - 12Mbps, 3 - 6Mbps,
4936  *          4 - 54Mbps, 5 - 36Mbps, 6 - 18Mbps, 7 - 9Mbps
4937  *    HT/VHT: MCS index
4938  */
4939
4940 /* Preamble types to be used with VDEV fixed rate configuration */
4941 enum wmi_rate_preamble {
4942         WMI_RATE_PREAMBLE_OFDM,
4943         WMI_RATE_PREAMBLE_CCK,
4944         WMI_RATE_PREAMBLE_HT,
4945         WMI_RATE_PREAMBLE_VHT,
4946 };
4947
4948 #define ATH10K_HW_NSS(rate)             (1 + (((rate) >> 4) & 0x3))
4949 #define ATH10K_HW_PREAMBLE(rate)        (((rate) >> 6) & 0x3)
4950 #define ATH10K_HW_MCS_RATE(rate)        ((rate) & 0xf)
4951 #define ATH10K_HW_LEGACY_RATE(rate)     ((rate) & 0x3f)
4952 #define ATH10K_HW_BW(flags)             (((flags) >> 3) & 0x3)
4953 #define ATH10K_HW_GI(flags)             (((flags) >> 5) & 0x1)
4954 #define ATH10K_HW_RATECODE(rate, nss, preamble) \
4955         (((preamble) << 6) | ((nss) << 4) | (rate))
4956
4957 #define VHT_MCS_NUM     10
4958 #define VHT_BW_NUM      4
4959 #define VHT_NSS_NUM     4
4960
4961 /* Value to disable fixed rate setting */
4962 #define WMI_FIXED_RATE_NONE    (0xff)
4963
4964 struct wmi_vdev_param_map {
4965         u32 rts_threshold;
4966         u32 fragmentation_threshold;
4967         u32 beacon_interval;
4968         u32 listen_interval;
4969         u32 multicast_rate;
4970         u32 mgmt_tx_rate;
4971         u32 slot_time;
4972         u32 preamble;
4973         u32 swba_time;
4974         u32 wmi_vdev_stats_update_period;
4975         u32 wmi_vdev_pwrsave_ageout_time;
4976         u32 wmi_vdev_host_swba_interval;
4977         u32 dtim_period;
4978         u32 wmi_vdev_oc_scheduler_air_time_limit;
4979         u32 wds;
4980         u32 atim_window;
4981         u32 bmiss_count_max;
4982         u32 bmiss_first_bcnt;
4983         u32 bmiss_final_bcnt;
4984         u32 feature_wmm;
4985         u32 chwidth;
4986         u32 chextoffset;
4987         u32 disable_htprotection;
4988         u32 sta_quickkickout;
4989         u32 mgmt_rate;
4990         u32 protection_mode;
4991         u32 fixed_rate;
4992         u32 sgi;
4993         u32 ldpc;
4994         u32 tx_stbc;
4995         u32 rx_stbc;
4996         u32 intra_bss_fwd;
4997         u32 def_keyid;
4998         u32 nss;
4999         u32 bcast_data_rate;
5000         u32 mcast_data_rate;
5001         u32 mcast_indicate;
5002         u32 dhcp_indicate;
5003         u32 unknown_dest_indicate;
5004         u32 ap_keepalive_min_idle_inactive_time_secs;
5005         u32 ap_keepalive_max_idle_inactive_time_secs;
5006         u32 ap_keepalive_max_unresponsive_time_secs;
5007         u32 ap_enable_nawds;
5008         u32 mcast2ucast_set;
5009         u32 enable_rtscts;
5010         u32 txbf;
5011         u32 packet_powersave;
5012         u32 drop_unencry;
5013         u32 tx_encap_type;
5014         u32 ap_detect_out_of_sync_sleeping_sta_time_secs;
5015         u32 rc_num_retries;
5016         u32 cabq_maxdur;
5017         u32 mfptest_set;
5018         u32 rts_fixed_rate;
5019         u32 vht_sgimask;
5020         u32 vht80_ratemask;
5021         u32 early_rx_adjust_enable;
5022         u32 early_rx_tgt_bmiss_num;
5023         u32 early_rx_bmiss_sample_cycle;
5024         u32 early_rx_slop_step;
5025         u32 early_rx_init_slop;
5026         u32 early_rx_adjust_pause;
5027         u32 proxy_sta;
5028         u32 meru_vc;
5029         u32 rx_decap_type;
5030         u32 bw_nss_ratemask;
5031         u32 inc_tsf;
5032         u32 dec_tsf;
5033 };
5034
5035 #define WMI_VDEV_PARAM_UNSUPPORTED 0
5036
5037 /* the definition of different VDEV parameters */
5038 enum wmi_vdev_param {
5039         /* RTS Threshold */
5040         WMI_VDEV_PARAM_RTS_THRESHOLD = 0x1,
5041         /* Fragmentation threshold */
5042         WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
5043         /* beacon interval in TUs */
5044         WMI_VDEV_PARAM_BEACON_INTERVAL,
5045         /* Listen interval in TUs */
5046         WMI_VDEV_PARAM_LISTEN_INTERVAL,
5047         /* multicast rate in Mbps */
5048         WMI_VDEV_PARAM_MULTICAST_RATE,
5049         /* management frame rate in Mbps */
5050         WMI_VDEV_PARAM_MGMT_TX_RATE,
5051         /* slot time (long vs short) */
5052         WMI_VDEV_PARAM_SLOT_TIME,
5053         /* preamble (long vs short) */
5054         WMI_VDEV_PARAM_PREAMBLE,
5055         /* SWBA time (time before tbtt in msec) */
5056         WMI_VDEV_PARAM_SWBA_TIME,
5057         /* time period for updating VDEV stats */
5058         WMI_VDEV_STATS_UPDATE_PERIOD,
5059         /* age out time in msec for frames queued for station in power save */
5060         WMI_VDEV_PWRSAVE_AGEOUT_TIME,
5061         /*
5062          * Host SWBA interval (time in msec before tbtt for SWBA event
5063          * generation).
5064          */
5065         WMI_VDEV_HOST_SWBA_INTERVAL,
5066         /* DTIM period (specified in units of num beacon intervals) */
5067         WMI_VDEV_PARAM_DTIM_PERIOD,
5068         /*
5069          * scheduler air time limit for this VDEV. used by off chan
5070          * scheduler.
5071          */
5072         WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
5073         /* enable/dsiable WDS for this VDEV  */
5074         WMI_VDEV_PARAM_WDS,
5075         /* ATIM Window */
5076         WMI_VDEV_PARAM_ATIM_WINDOW,
5077         /* BMISS max */
5078         WMI_VDEV_PARAM_BMISS_COUNT_MAX,
5079         /* BMISS first time */
5080         WMI_VDEV_PARAM_BMISS_FIRST_BCNT,
5081         /* BMISS final time */
5082         WMI_VDEV_PARAM_BMISS_FINAL_BCNT,
5083         /* WMM enables/disabled */
5084         WMI_VDEV_PARAM_FEATURE_WMM,
5085         /* Channel width */
5086         WMI_VDEV_PARAM_CHWIDTH,
5087         /* Channel Offset */
5088         WMI_VDEV_PARAM_CHEXTOFFSET,
5089         /* Disable HT Protection */
5090         WMI_VDEV_PARAM_DISABLE_HTPROTECTION,
5091         /* Quick STA Kickout */
5092         WMI_VDEV_PARAM_STA_QUICKKICKOUT,
5093         /* Rate to be used with Management frames */
5094         WMI_VDEV_PARAM_MGMT_RATE,
5095         /* Protection Mode */
5096         WMI_VDEV_PARAM_PROTECTION_MODE,
5097         /* Fixed rate setting */
5098         WMI_VDEV_PARAM_FIXED_RATE,
5099         /* Short GI Enable/Disable */
5100         WMI_VDEV_PARAM_SGI,
5101         /* Enable LDPC */
5102         WMI_VDEV_PARAM_LDPC,
5103         /* Enable Tx STBC */
5104         WMI_VDEV_PARAM_TX_STBC,
5105         /* Enable Rx STBC */
5106         WMI_VDEV_PARAM_RX_STBC,
5107         /* Intra BSS forwarding  */
5108         WMI_VDEV_PARAM_INTRA_BSS_FWD,
5109         /* Setting Default xmit key for Vdev */
5110         WMI_VDEV_PARAM_DEF_KEYID,
5111         /* NSS width */
5112         WMI_VDEV_PARAM_NSS,
5113         /* Set the custom rate for the broadcast data frames */
5114         WMI_VDEV_PARAM_BCAST_DATA_RATE,
5115         /* Set the custom rate (rate-code) for multicast data frames */
5116         WMI_VDEV_PARAM_MCAST_DATA_RATE,
5117         /* Tx multicast packet indicate Enable/Disable */
5118         WMI_VDEV_PARAM_MCAST_INDICATE,
5119         /* Tx DHCP packet indicate Enable/Disable */
5120         WMI_VDEV_PARAM_DHCP_INDICATE,
5121         /* Enable host inspection of Tx unicast packet to unknown destination */
5122         WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
5123
5124         /* The minimum amount of time AP begins to consider STA inactive */
5125         WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
5126
5127         /*
5128          * An associated STA is considered inactive when there is no recent
5129          * TX/RX activity and no downlink frames are buffered for it. Once a
5130          * STA exceeds the maximum idle inactive time, the AP will send an
5131          * 802.11 data-null as a keep alive to verify the STA is still
5132          * associated. If the STA does ACK the data-null, or if the data-null
5133          * is buffered and the STA does not retrieve it, the STA will be
5134          * considered unresponsive
5135          * (see WMI_VDEV_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS).
5136          */
5137         WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
5138
5139         /*
5140          * An associated STA is considered unresponsive if there is no recent
5141          * TX/RX activity and downlink frames are buffered for it. Once a STA
5142          * exceeds the maximum unresponsive time, the AP will send a
5143          * WMI_STA_KICKOUT event to the host so the STA can be deleted.
5144          */
5145         WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
5146
5147         /* Enable NAWDS : MCAST INSPECT Enable, NAWDS Flag set */
5148         WMI_VDEV_PARAM_AP_ENABLE_NAWDS,
5149         /* Enable/Disable RTS-CTS */
5150         WMI_VDEV_PARAM_ENABLE_RTSCTS,
5151         /* Enable TXBFee/er */
5152         WMI_VDEV_PARAM_TXBF,
5153
5154         /* Set packet power save */
5155         WMI_VDEV_PARAM_PACKET_POWERSAVE,
5156
5157         /*
5158          * Drops un-encrypted packets if eceived in an encrypted connection
5159          * otherwise forwards to host.
5160          */
5161         WMI_VDEV_PARAM_DROP_UNENCRY,
5162
5163         /*
5164          * Set the encapsulation type for frames.
5165          */
5166         WMI_VDEV_PARAM_TX_ENCAP_TYPE,
5167 };
5168
5169 /* the definition of different VDEV parameters */
5170 enum wmi_10x_vdev_param {
5171         /* RTS Threshold */
5172         WMI_10X_VDEV_PARAM_RTS_THRESHOLD = 0x1,
5173         /* Fragmentation threshold */
5174         WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
5175         /* beacon interval in TUs */
5176         WMI_10X_VDEV_PARAM_BEACON_INTERVAL,
5177         /* Listen interval in TUs */
5178         WMI_10X_VDEV_PARAM_LISTEN_INTERVAL,
5179         /* multicast rate in Mbps */
5180         WMI_10X_VDEV_PARAM_MULTICAST_RATE,
5181         /* management frame rate in Mbps */
5182         WMI_10X_VDEV_PARAM_MGMT_TX_RATE,
5183         /* slot time (long vs short) */
5184         WMI_10X_VDEV_PARAM_SLOT_TIME,
5185         /* preamble (long vs short) */
5186         WMI_10X_VDEV_PARAM_PREAMBLE,
5187         /* SWBA time (time before tbtt in msec) */
5188         WMI_10X_VDEV_PARAM_SWBA_TIME,
5189         /* time period for updating VDEV stats */
5190         WMI_10X_VDEV_STATS_UPDATE_PERIOD,
5191         /* age out time in msec for frames queued for station in power save */
5192         WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME,
5193         /*
5194          * Host SWBA interval (time in msec before tbtt for SWBA event
5195          * generation).
5196          */
5197         WMI_10X_VDEV_HOST_SWBA_INTERVAL,
5198         /* DTIM period (specified in units of num beacon intervals) */
5199         WMI_10X_VDEV_PARAM_DTIM_PERIOD,
5200         /*
5201          * scheduler air time limit for this VDEV. used by off chan
5202          * scheduler.
5203          */
5204         WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
5205         /* enable/dsiable WDS for this VDEV  */
5206         WMI_10X_VDEV_PARAM_WDS,
5207         /* ATIM Window */
5208         WMI_10X_VDEV_PARAM_ATIM_WINDOW,
5209         /* BMISS max */
5210         WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX,
5211         /* WMM enables/disabled */
5212         WMI_10X_VDEV_PARAM_FEATURE_WMM,
5213         /* Channel width */
5214         WMI_10X_VDEV_PARAM_CHWIDTH,
5215         /* Channel Offset */
5216         WMI_10X_VDEV_PARAM_CHEXTOFFSET,
5217         /* Disable HT Protection */
5218         WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION,
5219         /* Quick STA Kickout */
5220         WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT,
5221         /* Rate to be used with Management frames */
5222         WMI_10X_VDEV_PARAM_MGMT_RATE,
5223         /* Protection Mode */
5224         WMI_10X_VDEV_PARAM_PROTECTION_MODE,
5225         /* Fixed rate setting */
5226         WMI_10X_VDEV_PARAM_FIXED_RATE,
5227         /* Short GI Enable/Disable */
5228         WMI_10X_VDEV_PARAM_SGI,
5229         /* Enable LDPC */
5230         WMI_10X_VDEV_PARAM_LDPC,
5231         /* Enable Tx STBC */
5232         WMI_10X_VDEV_PARAM_TX_STBC,
5233         /* Enable Rx STBC */
5234         WMI_10X_VDEV_PARAM_RX_STBC,
5235         /* Intra BSS forwarding  */
5236         WMI_10X_VDEV_PARAM_INTRA_BSS_FWD,
5237         /* Setting Default xmit key for Vdev */
5238         WMI_10X_VDEV_PARAM_DEF_KEYID,
5239         /* NSS width */
5240         WMI_10X_VDEV_PARAM_NSS,
5241         /* Set the custom rate for the broadcast data frames */
5242         WMI_10X_VDEV_PARAM_BCAST_DATA_RATE,
5243         /* Set the custom rate (rate-code) for multicast data frames */
5244         WMI_10X_VDEV_PARAM_MCAST_DATA_RATE,
5245         /* Tx multicast packet indicate Enable/Disable */
5246         WMI_10X_VDEV_PARAM_MCAST_INDICATE,
5247         /* Tx DHCP packet indicate Enable/Disable */
5248         WMI_10X_VDEV_PARAM_DHCP_INDICATE,
5249         /* Enable host inspection of Tx unicast packet to unknown destination */
5250         WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
5251
5252         /* The minimum amount of time AP begins to consider STA inactive */
5253         WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
5254
5255         /*
5256          * An associated STA is considered inactive when there is no recent
5257          * TX/RX activity and no downlink frames are buffered for it. Once a
5258          * STA exceeds the maximum idle inactive time, the AP will send an
5259          * 802.11 data-null as a keep alive to verify the STA is still
5260          * associated. If the STA does ACK the data-null, or if the data-null
5261          * is buffered and the STA does not retrieve it, the STA will be
5262          * considered unresponsive
5263          * (see WMI_10X_VDEV_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS).
5264          */
5265         WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
5266
5267         /*
5268          * An associated STA is considered unresponsive if there is no recent
5269          * TX/RX activity and downlink frames are buffered for it. Once a STA
5270          * exceeds the maximum unresponsive time, the AP will send a
5271          * WMI_10X_STA_KICKOUT event to the host so the STA can be deleted.
5272          */
5273         WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
5274
5275         /* Enable NAWDS : MCAST INSPECT Enable, NAWDS Flag set */
5276         WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS,
5277
5278         WMI_10X_VDEV_PARAM_MCAST2UCAST_SET,
5279         /* Enable/Disable RTS-CTS */
5280         WMI_10X_VDEV_PARAM_ENABLE_RTSCTS,
5281
5282         WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
5283
5284         /* following are available as of firmware 10.2 */
5285         WMI_10X_VDEV_PARAM_TX_ENCAP_TYPE,
5286         WMI_10X_VDEV_PARAM_CABQ_MAXDUR,
5287         WMI_10X_VDEV_PARAM_MFPTEST_SET,
5288         WMI_10X_VDEV_PARAM_RTS_FIXED_RATE,
5289         WMI_10X_VDEV_PARAM_VHT_SGIMASK,
5290         WMI_10X_VDEV_PARAM_VHT80_RATEMASK,
5291         WMI_10X_VDEV_PARAM_TSF_INCREMENT,
5292 };
5293
5294 enum wmi_10_4_vdev_param {
5295         WMI_10_4_VDEV_PARAM_RTS_THRESHOLD = 0x1,
5296         WMI_10_4_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
5297         WMI_10_4_VDEV_PARAM_BEACON_INTERVAL,
5298         WMI_10_4_VDEV_PARAM_LISTEN_INTERVAL,
5299         WMI_10_4_VDEV_PARAM_MULTICAST_RATE,
5300         WMI_10_4_VDEV_PARAM_MGMT_TX_RATE,
5301         WMI_10_4_VDEV_PARAM_SLOT_TIME,
5302         WMI_10_4_VDEV_PARAM_PREAMBLE,
5303         WMI_10_4_VDEV_PARAM_SWBA_TIME,
5304         WMI_10_4_VDEV_STATS_UPDATE_PERIOD,
5305         WMI_10_4_VDEV_PWRSAVE_AGEOUT_TIME,
5306         WMI_10_4_VDEV_HOST_SWBA_INTERVAL,
5307         WMI_10_4_VDEV_PARAM_DTIM_PERIOD,
5308         WMI_10_4_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
5309         WMI_10_4_VDEV_PARAM_WDS,
5310         WMI_10_4_VDEV_PARAM_ATIM_WINDOW,
5311         WMI_10_4_VDEV_PARAM_BMISS_COUNT_MAX,
5312         WMI_10_4_VDEV_PARAM_BMISS_FIRST_BCNT,
5313         WMI_10_4_VDEV_PARAM_BMISS_FINAL_BCNT,
5314         WMI_10_4_VDEV_PARAM_FEATURE_WMM,
5315         WMI_10_4_VDEV_PARAM_CHWIDTH,
5316         WMI_10_4_VDEV_PARAM_CHEXTOFFSET,
5317         WMI_10_4_VDEV_PARAM_DISABLE_HTPROTECTION,
5318         WMI_10_4_VDEV_PARAM_STA_QUICKKICKOUT,
5319         WMI_10_4_VDEV_PARAM_MGMT_RATE,
5320         WMI_10_4_VDEV_PARAM_PROTECTION_MODE,
5321         WMI_10_4_VDEV_PARAM_FIXED_RATE,
5322         WMI_10_4_VDEV_PARAM_SGI,
5323         WMI_10_4_VDEV_PARAM_LDPC,
5324         WMI_10_4_VDEV_PARAM_TX_STBC,
5325         WMI_10_4_VDEV_PARAM_RX_STBC,
5326         WMI_10_4_VDEV_PARAM_INTRA_BSS_FWD,
5327         WMI_10_4_VDEV_PARAM_DEF_KEYID,
5328         WMI_10_4_VDEV_PARAM_NSS,
5329         WMI_10_4_VDEV_PARAM_BCAST_DATA_RATE,
5330         WMI_10_4_VDEV_PARAM_MCAST_DATA_RATE,
5331         WMI_10_4_VDEV_PARAM_MCAST_INDICATE,
5332         WMI_10_4_VDEV_PARAM_DHCP_INDICATE,
5333         WMI_10_4_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
5334         WMI_10_4_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
5335         WMI_10_4_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
5336         WMI_10_4_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
5337         WMI_10_4_VDEV_PARAM_AP_ENABLE_NAWDS,
5338         WMI_10_4_VDEV_PARAM_MCAST2UCAST_SET,
5339         WMI_10_4_VDEV_PARAM_ENABLE_RTSCTS,
5340         WMI_10_4_VDEV_PARAM_RC_NUM_RETRIES,
5341         WMI_10_4_VDEV_PARAM_TXBF,
5342         WMI_10_4_VDEV_PARAM_PACKET_POWERSAVE,
5343         WMI_10_4_VDEV_PARAM_DROP_UNENCRY,
5344         WMI_10_4_VDEV_PARAM_TX_ENCAP_TYPE,
5345         WMI_10_4_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
5346         WMI_10_4_VDEV_PARAM_CABQ_MAXDUR,
5347         WMI_10_4_VDEV_PARAM_MFPTEST_SET,
5348         WMI_10_4_VDEV_PARAM_RTS_FIXED_RATE,
5349         WMI_10_4_VDEV_PARAM_VHT_SGIMASK,
5350         WMI_10_4_VDEV_PARAM_VHT80_RATEMASK,
5351         WMI_10_4_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
5352         WMI_10_4_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
5353         WMI_10_4_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
5354         WMI_10_4_VDEV_PARAM_EARLY_RX_SLOP_STEP,
5355         WMI_10_4_VDEV_PARAM_EARLY_RX_INIT_SLOP,
5356         WMI_10_4_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
5357         WMI_10_4_VDEV_PARAM_PROXY_STA,
5358         WMI_10_4_VDEV_PARAM_MERU_VC,
5359         WMI_10_4_VDEV_PARAM_RX_DECAP_TYPE,
5360         WMI_10_4_VDEV_PARAM_BW_NSS_RATEMASK,
5361         WMI_10_4_VDEV_PARAM_SENSOR_AP,
5362         WMI_10_4_VDEV_PARAM_BEACON_RATE,
5363         WMI_10_4_VDEV_PARAM_DTIM_ENABLE_CTS,
5364         WMI_10_4_VDEV_PARAM_STA_KICKOUT,
5365         WMI_10_4_VDEV_PARAM_CAPABILITIES,
5366         WMI_10_4_VDEV_PARAM_TSF_INCREMENT,
5367         WMI_10_4_VDEV_PARAM_RX_FILTER,
5368         WMI_10_4_VDEV_PARAM_MGMT_TX_POWER,
5369         WMI_10_4_VDEV_PARAM_ATF_SSID_SCHED_POLICY,
5370         WMI_10_4_VDEV_PARAM_DISABLE_DYN_BW_RTS,
5371         WMI_10_4_VDEV_PARAM_TSF_DECREMENT,
5372 };
5373
5374 #define WMI_VDEV_PARAM_TXBF_SU_TX_BFEE BIT(0)
5375 #define WMI_VDEV_PARAM_TXBF_MU_TX_BFEE BIT(1)
5376 #define WMI_VDEV_PARAM_TXBF_SU_TX_BFER BIT(2)
5377 #define WMI_VDEV_PARAM_TXBF_MU_TX_BFER BIT(3)
5378
5379 #define WMI_TXBF_STS_CAP_OFFSET_LSB     4
5380 #define WMI_TXBF_STS_CAP_OFFSET_MASK    0x70
5381 #define WMI_TXBF_CONF_IMPLICIT_BF       BIT(7)
5382 #define WMI_BF_SOUND_DIM_OFFSET_LSB     8
5383 #define WMI_BF_SOUND_DIM_OFFSET_MASK    0xf00
5384
5385 /* slot time long */
5386 #define WMI_VDEV_SLOT_TIME_LONG         0x1
5387 /* slot time short */
5388 #define WMI_VDEV_SLOT_TIME_SHORT        0x2
5389 /* preablbe long */
5390 #define WMI_VDEV_PREAMBLE_LONG          0x1
5391 /* preablbe short */
5392 #define WMI_VDEV_PREAMBLE_SHORT         0x2
5393
5394 enum wmi_start_event_param {
5395         WMI_VDEV_RESP_START_EVENT = 0,
5396         WMI_VDEV_RESP_RESTART_EVENT,
5397 };
5398
5399 struct wmi_vdev_start_response_event {
5400         __le32 vdev_id;
5401         __le32 req_id;
5402         __le32 resp_type; /* %WMI_VDEV_RESP_ */
5403         __le32 status;
5404 } __packed;
5405
5406 struct wmi_vdev_standby_req_event {
5407         /* unique id identifying the VDEV, generated by the caller */
5408         __le32 vdev_id;
5409 } __packed;
5410
5411 struct wmi_vdev_resume_req_event {
5412         /* unique id identifying the VDEV, generated by the caller */
5413         __le32 vdev_id;
5414 } __packed;
5415
5416 struct wmi_vdev_stopped_event {
5417         /* unique id identifying the VDEV, generated by the caller */
5418         __le32 vdev_id;
5419 } __packed;
5420
5421 /*
5422  * common structure used for simple events
5423  * (stopped, resume_req, standby response)
5424  */
5425 struct wmi_vdev_simple_event {
5426         /* unique id identifying the VDEV, generated by the caller */
5427         __le32 vdev_id;
5428 } __packed;
5429
5430 /* VDEV start response status codes */
5431 /* VDEV successfully started */
5432 #define WMI_INIFIED_VDEV_START_RESPONSE_STATUS_SUCCESS  0x0
5433
5434 /* requested VDEV not found */
5435 #define WMI_INIFIED_VDEV_START_RESPONSE_INVALID_VDEVID  0x1
5436
5437 /* unsupported VDEV combination */
5438 #define WMI_INIFIED_VDEV_START_RESPONSE_NOT_SUPPORTED   0x2
5439
5440 /* TODO: please add more comments if you have in-depth information */
5441 struct wmi_vdev_spectral_conf_cmd {
5442         __le32 vdev_id;
5443
5444         /* number of fft samples to send (0 for infinite) */
5445         __le32 scan_count;
5446         __le32 scan_period;
5447         __le32 scan_priority;
5448
5449         /* number of bins in the FFT: 2^(fft_size - bin_scale) */
5450         __le32 scan_fft_size;
5451         __le32 scan_gc_ena;
5452         __le32 scan_restart_ena;
5453         __le32 scan_noise_floor_ref;
5454         __le32 scan_init_delay;
5455         __le32 scan_nb_tone_thr;
5456         __le32 scan_str_bin_thr;
5457         __le32 scan_wb_rpt_mode;
5458         __le32 scan_rssi_rpt_mode;
5459         __le32 scan_rssi_thr;
5460         __le32 scan_pwr_format;
5461
5462         /* rpt_mode: Format of FFT report to software for spectral scan
5463          * triggered FFTs:
5464          *      0: No FFT report (only spectral scan summary report)
5465          *      1: 2-dword summary of metrics for each completed FFT + spectral
5466          *         scan summary report
5467          *      2: 2-dword summary of metrics for each completed FFT +
5468          *         1x- oversampled bins(in-band) per FFT + spectral scan summary
5469          *         report
5470          *      3: 2-dword summary of metrics for each completed FFT +
5471          *         2x- oversampled bins (all) per FFT + spectral scan summary
5472          */
5473         __le32 scan_rpt_mode;
5474         __le32 scan_bin_scale;
5475         __le32 scan_dbm_adj;
5476         __le32 scan_chn_mask;
5477 } __packed;
5478
5479 struct wmi_vdev_spectral_conf_arg {
5480         u32 vdev_id;
5481         u32 scan_count;
5482         u32 scan_period;
5483         u32 scan_priority;
5484         u32 scan_fft_size;
5485         u32 scan_gc_ena;
5486         u32 scan_restart_ena;
5487         u32 scan_noise_floor_ref;
5488         u32 scan_init_delay;
5489         u32 scan_nb_tone_thr;
5490         u32 scan_str_bin_thr;
5491         u32 scan_wb_rpt_mode;
5492         u32 scan_rssi_rpt_mode;
5493         u32 scan_rssi_thr;
5494         u32 scan_pwr_format;
5495         u32 scan_rpt_mode;
5496         u32 scan_bin_scale;
5497         u32 scan_dbm_adj;
5498         u32 scan_chn_mask;
5499 };
5500
5501 #define WMI_SPECTRAL_ENABLE_DEFAULT              0
5502 #define WMI_SPECTRAL_COUNT_DEFAULT               0
5503 #define WMI_SPECTRAL_PERIOD_DEFAULT             35
5504 #define WMI_SPECTRAL_PRIORITY_DEFAULT            1
5505 #define WMI_SPECTRAL_FFT_SIZE_DEFAULT            7
5506 #define WMI_SPECTRAL_GC_ENA_DEFAULT              1
5507 #define WMI_SPECTRAL_RESTART_ENA_DEFAULT         0
5508 #define WMI_SPECTRAL_NOISE_FLOOR_REF_DEFAULT   -96
5509 #define WMI_SPECTRAL_INIT_DELAY_DEFAULT         80
5510 #define WMI_SPECTRAL_NB_TONE_THR_DEFAULT        12
5511 #define WMI_SPECTRAL_STR_BIN_THR_DEFAULT         8
5512 #define WMI_SPECTRAL_WB_RPT_MODE_DEFAULT         0
5513 #define WMI_SPECTRAL_RSSI_RPT_MODE_DEFAULT       0
5514 #define WMI_SPECTRAL_RSSI_THR_DEFAULT         0xf0
5515 #define WMI_SPECTRAL_PWR_FORMAT_DEFAULT          0
5516 #define WMI_SPECTRAL_RPT_MODE_DEFAULT            2
5517 #define WMI_SPECTRAL_BIN_SCALE_DEFAULT           1
5518 #define WMI_SPECTRAL_DBM_ADJ_DEFAULT             1
5519 #define WMI_SPECTRAL_CHN_MASK_DEFAULT            1
5520
5521 struct wmi_vdev_spectral_enable_cmd {
5522         __le32 vdev_id;
5523         __le32 trigger_cmd;
5524         __le32 enable_cmd;
5525 } __packed;
5526
5527 #define WMI_SPECTRAL_TRIGGER_CMD_TRIGGER  1
5528 #define WMI_SPECTRAL_TRIGGER_CMD_CLEAR    2
5529 #define WMI_SPECTRAL_ENABLE_CMD_ENABLE    1
5530 #define WMI_SPECTRAL_ENABLE_CMD_DISABLE   2
5531
5532 /* Beacon processing related command and event structures */
5533 struct wmi_bcn_tx_hdr {
5534         __le32 vdev_id;
5535         __le32 tx_rate;
5536         __le32 tx_power;
5537         __le32 bcn_len;
5538 } __packed;
5539
5540 struct wmi_bcn_tx_cmd {
5541         struct wmi_bcn_tx_hdr hdr;
5542         u8 *bcn[0];
5543 } __packed;
5544
5545 struct wmi_bcn_tx_arg {
5546         u32 vdev_id;
5547         u32 tx_rate;
5548         u32 tx_power;
5549         u32 bcn_len;
5550         const void *bcn;
5551 };
5552
5553 enum wmi_bcn_tx_ref_flags {
5554         WMI_BCN_TX_REF_FLAG_DTIM_ZERO = 0x1,
5555         WMI_BCN_TX_REF_FLAG_DELIVER_CAB = 0x2,
5556 };
5557
5558 /* TODO: It is unclear why "no antenna" works while any other seemingly valid
5559  * chainmask yields no beacons on the air at all.
5560  */
5561 #define WMI_BCN_TX_REF_DEF_ANTENNA 0
5562
5563 struct wmi_bcn_tx_ref_cmd {
5564         __le32 vdev_id;
5565         __le32 data_len;
5566         /* physical address of the frame - dma pointer */
5567         __le32 data_ptr;
5568         /* id for host to track */
5569         __le32 msdu_id;
5570         /* frame ctrl to setup PPDU desc */
5571         __le32 frame_control;
5572         /* to control CABQ traffic: WMI_BCN_TX_REF_FLAG_ */
5573         __le32 flags;
5574         /* introduced in 10.2 */
5575         __le32 antenna_mask;
5576 } __packed;
5577
5578 /* Beacon filter */
5579 #define WMI_BCN_FILTER_ALL   0 /* Filter all beacons */
5580 #define WMI_BCN_FILTER_NONE  1 /* Pass all beacons */
5581 #define WMI_BCN_FILTER_RSSI  2 /* Pass Beacons RSSI >= RSSI threshold */
5582 #define WMI_BCN_FILTER_BSSID 3 /* Pass Beacons with matching BSSID */
5583 #define WMI_BCN_FILTER_SSID  4 /* Pass Beacons with matching SSID */
5584
5585 struct wmi_bcn_filter_rx_cmd {
5586         /* Filter ID */
5587         __le32 bcn_filter_id;
5588         /* Filter type - wmi_bcn_filter */
5589         __le32 bcn_filter;
5590         /* Buffer len */
5591         __le32 bcn_filter_len;
5592         /* Filter info (threshold, BSSID, RSSI) */
5593         u8 *bcn_filter_buf;
5594 } __packed;
5595
5596 /* Capabilities and IEs to be passed to firmware */
5597 struct wmi_bcn_prb_info {
5598         /* Capabilities */
5599         __le32 caps;
5600         /* ERP info */
5601         __le32 erp;
5602         /* Advanced capabilities */
5603         /* HT capabilities */
5604         /* HT Info */
5605         /* ibss_dfs */
5606         /* wpa Info */
5607         /* rsn Info */
5608         /* rrm info */
5609         /* ath_ext */
5610         /* app IE */
5611 } __packed;
5612
5613 struct wmi_bcn_tmpl_cmd {
5614         /* unique id identifying the VDEV, generated by the caller */
5615         __le32 vdev_id;
5616         /* TIM IE offset from the beginning of the template. */
5617         __le32 tim_ie_offset;
5618         /* beacon probe capabilities and IEs */
5619         struct wmi_bcn_prb_info bcn_prb_info;
5620         /* beacon buffer length */
5621         __le32 buf_len;
5622         /* variable length data */
5623         u8 data[1];
5624 } __packed;
5625
5626 struct wmi_prb_tmpl_cmd {
5627         /* unique id identifying the VDEV, generated by the caller */
5628         __le32 vdev_id;
5629         /* beacon probe capabilities and IEs */
5630         struct wmi_bcn_prb_info bcn_prb_info;
5631         /* beacon buffer length */
5632         __le32 buf_len;
5633         /* Variable length data */
5634         u8 data[1];
5635 } __packed;
5636
5637 enum wmi_sta_ps_mode {
5638         /* enable power save for the given STA VDEV */
5639         WMI_STA_PS_MODE_DISABLED = 0,
5640         /* disable power save  for a given STA VDEV */
5641         WMI_STA_PS_MODE_ENABLED = 1,
5642 };
5643
5644 struct wmi_sta_powersave_mode_cmd {
5645         /* unique id identifying the VDEV, generated by the caller */
5646         __le32 vdev_id;
5647
5648         /*
5649          * Power save mode
5650          * (see enum wmi_sta_ps_mode)
5651          */
5652         __le32 sta_ps_mode;
5653 } __packed;
5654
5655 enum wmi_csa_offload_en {
5656         WMI_CSA_OFFLOAD_DISABLE = 0,
5657         WMI_CSA_OFFLOAD_ENABLE = 1,
5658 };
5659
5660 struct wmi_csa_offload_enable_cmd {
5661         __le32 vdev_id;
5662         __le32 csa_offload_enable;
5663 } __packed;
5664
5665 struct wmi_csa_offload_chanswitch_cmd {
5666         __le32 vdev_id;
5667         struct wmi_channel chan;
5668 } __packed;
5669
5670 /*
5671  * This parameter controls the policy for retrieving frames from AP while the
5672  * STA is in sleep state.
5673  *
5674  * Only takes affect if the sta_ps_mode is enabled
5675  */
5676 enum wmi_sta_ps_param_rx_wake_policy {
5677         /*
5678          * Wake up when ever there is an  RX activity on the VDEV. In this mode
5679          * the Power save SM(state machine) will come out of sleep by either
5680          * sending null frame (or) a data frame (with PS==0) in response to TIM
5681          * bit set in the received beacon frame from AP.
5682          */
5683         WMI_STA_PS_RX_WAKE_POLICY_WAKE = 0,
5684
5685         /*
5686          * Here the power save state machine will not wakeup in response to TIM
5687          * bit, instead it will send a PSPOLL (or) UASPD trigger based on UAPSD
5688          * configuration setup by WMISET_PS_SET_UAPSD  WMI command.  When all
5689          * access categories are delivery-enabled, the station will send a
5690          * UAPSD trigger frame, otherwise it will send a PS-Poll.
5691          */
5692         WMI_STA_PS_RX_WAKE_POLICY_POLL_UAPSD = 1,
5693 };
5694
5695 /*
5696  * Number of tx frames/beacon  that cause the power save SM to wake up.
5697  *
5698  * Value 1 causes the SM to wake up for every TX. Value 0 has a special
5699  * meaning, It will cause the SM to never wake up. This is useful if you want
5700  * to keep the system to sleep all the time for some kind of test mode . host
5701  * can change this parameter any time.  It will affect at the next tx frame.
5702  */
5703 enum wmi_sta_ps_param_tx_wake_threshold {
5704         WMI_STA_PS_TX_WAKE_THRESHOLD_NEVER = 0,
5705         WMI_STA_PS_TX_WAKE_THRESHOLD_ALWAYS = 1,
5706
5707         /*
5708          * Values greater than one indicate that many TX attempts per beacon
5709          * interval before the STA will wake up
5710          */
5711 };
5712
5713 /*
5714  * The maximum number of PS-Poll frames the FW will send in response to
5715  * traffic advertised in TIM before waking up (by sending a null frame with PS
5716  * = 0). Value 0 has a special meaning: there is no maximum count and the FW
5717  * will send as many PS-Poll as are necessary to retrieve buffered BU. This
5718  * parameter is used when the RX wake policy is
5719  * WMI_STA_PS_RX_WAKE_POLICY_POLL_UAPSD and ignored when the RX wake
5720  * policy is WMI_STA_PS_RX_WAKE_POLICY_WAKE.
5721  */
5722 enum wmi_sta_ps_param_pspoll_count {
5723         WMI_STA_PS_PSPOLL_COUNT_NO_MAX = 0,
5724         /*
5725          * Values greater than 0 indicate the maximum numer of PS-Poll frames
5726          * FW will send before waking up.
5727          */
5728
5729         /* When u-APSD is enabled the firmware will be very reluctant to exit
5730          * STA PS. This could result in very poor Rx performance with STA doing
5731          * PS-Poll for each and every buffered frame. This value is a bit
5732          * arbitrary.
5733          */
5734         WMI_STA_PS_PSPOLL_COUNT_UAPSD = 3,
5735 };
5736
5737 /*
5738  * This will include the delivery and trigger enabled state for every AC.
5739  * This is the negotiated state with AP. The host MLME needs to set this based
5740  * on AP capability and the state Set in the association request by the
5741  * station MLME.Lower 8 bits of the value specify the UAPSD configuration.
5742  */
5743 #define WMI_UAPSD_AC_TYPE_DELI 0
5744 #define WMI_UAPSD_AC_TYPE_TRIG 1
5745
5746 #define WMI_UAPSD_AC_BIT_MASK(ac, type) \
5747         (type == WMI_UAPSD_AC_TYPE_DELI ? 1 << (ac << 1) : 1 << ((ac << 1) + 1))
5748
5749 enum wmi_sta_ps_param_uapsd {
5750         WMI_STA_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0),
5751         WMI_STA_PS_UAPSD_AC0_TRIGGER_EN  = (1 << 1),
5752         WMI_STA_PS_UAPSD_AC1_DELIVERY_EN = (1 << 2),
5753         WMI_STA_PS_UAPSD_AC1_TRIGGER_EN  = (1 << 3),
5754         WMI_STA_PS_UAPSD_AC2_DELIVERY_EN = (1 << 4),
5755         WMI_STA_PS_UAPSD_AC2_TRIGGER_EN  = (1 << 5),
5756         WMI_STA_PS_UAPSD_AC3_DELIVERY_EN = (1 << 6),
5757         WMI_STA_PS_UAPSD_AC3_TRIGGER_EN  = (1 << 7),
5758 };
5759
5760 #define WMI_STA_UAPSD_MAX_INTERVAL_MSEC UINT_MAX
5761
5762 struct wmi_sta_uapsd_auto_trig_param {
5763         __le32 wmm_ac;
5764         __le32 user_priority;
5765         __le32 service_interval;
5766         __le32 suspend_interval;
5767         __le32 delay_interval;
5768 };
5769
5770 struct wmi_sta_uapsd_auto_trig_cmd_fixed_param {
5771         __le32 vdev_id;
5772         struct wmi_mac_addr peer_macaddr;
5773         __le32 num_ac;
5774 };
5775
5776 struct wmi_sta_uapsd_auto_trig_arg {
5777         u32 wmm_ac;
5778         u32 user_priority;
5779         u32 service_interval;
5780         u32 suspend_interval;
5781         u32 delay_interval;
5782 };
5783
5784 enum wmi_sta_powersave_param {
5785         /*
5786          * Controls how frames are retrievd from AP while STA is sleeping
5787          *
5788          * (see enum wmi_sta_ps_param_rx_wake_policy)
5789          */
5790         WMI_STA_PS_PARAM_RX_WAKE_POLICY = 0,
5791
5792         /*
5793          * The STA will go active after this many TX
5794          *
5795          * (see enum wmi_sta_ps_param_tx_wake_threshold)
5796          */
5797         WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD = 1,
5798
5799         /*
5800          * Number of PS-Poll to send before STA wakes up
5801          *
5802          * (see enum wmi_sta_ps_param_pspoll_count)
5803          *
5804          */
5805         WMI_STA_PS_PARAM_PSPOLL_COUNT = 2,
5806
5807         /*
5808          * TX/RX inactivity time in msec before going to sleep.
5809          *
5810          * The power save SM will monitor tx/rx activity on the VDEV, if no
5811          * activity for the specified msec of the parameter the Power save
5812          * SM will go to sleep.
5813          */
5814         WMI_STA_PS_PARAM_INACTIVITY_TIME = 3,
5815
5816         /*
5817          * Set uapsd configuration.
5818          *
5819          * (see enum wmi_sta_ps_param_uapsd)
5820          */
5821         WMI_STA_PS_PARAM_UAPSD = 4,
5822 };
5823
5824 struct wmi_sta_powersave_param_cmd {
5825         __le32 vdev_id;
5826         __le32 param_id; /* %WMI_STA_PS_PARAM_ */
5827         __le32 param_value;
5828 } __packed;
5829
5830 /* No MIMO power save */
5831 #define WMI_STA_MIMO_PS_MODE_DISABLE
5832 /* mimo powersave mode static*/
5833 #define WMI_STA_MIMO_PS_MODE_STATIC
5834 /* mimo powersave mode dynamic */
5835 #define WMI_STA_MIMO_PS_MODE_DYNAMIC
5836
5837 struct wmi_sta_mimo_ps_mode_cmd {
5838         /* unique id identifying the VDEV, generated by the caller */
5839         __le32 vdev_id;
5840         /* mimo powersave mode as defined above */
5841         __le32 mimo_pwrsave_mode;
5842 } __packed;
5843
5844 /* U-APSD configuration of peer station from (re)assoc request and TSPECs */
5845 enum wmi_ap_ps_param_uapsd {
5846         WMI_AP_PS_UAPSD_AC0_DELIVERY_EN = (1 << 0),
5847         WMI_AP_PS_UAPSD_AC0_TRIGGER_EN  = (1 << 1),
5848         WMI_AP_PS_UAPSD_AC1_DELIVERY_EN = (1 << 2),
5849         WMI_AP_PS_UAPSD_AC1_TRIGGER_EN  = (1 << 3),
5850         WMI_AP_PS_UAPSD_AC2_DELIVERY_EN = (1 << 4),
5851         WMI_AP_PS_UAPSD_AC2_TRIGGER_EN  = (1 << 5),
5852         WMI_AP_PS_UAPSD_AC3_DELIVERY_EN = (1 << 6),
5853         WMI_AP_PS_UAPSD_AC3_TRIGGER_EN  = (1 << 7),
5854 };
5855
5856 /* U-APSD maximum service period of peer station */
5857 enum wmi_ap_ps_peer_param_max_sp {
5858         WMI_AP_PS_PEER_PARAM_MAX_SP_UNLIMITED = 0,
5859         WMI_AP_PS_PEER_PARAM_MAX_SP_2 = 1,
5860         WMI_AP_PS_PEER_PARAM_MAX_SP_4 = 2,
5861         WMI_AP_PS_PEER_PARAM_MAX_SP_6 = 3,
5862         MAX_WMI_AP_PS_PEER_PARAM_MAX_SP,
5863 };
5864
5865 /*
5866  * AP power save parameter
5867  * Set a power save specific parameter for a peer station
5868  */
5869 enum wmi_ap_ps_peer_param {
5870         /* Set uapsd configuration for a given peer.
5871          *
5872          * Include the delivery and trigger enabled state for every AC.
5873          * The host  MLME needs to set this based on AP capability and stations
5874          * request Set in the association request  received from the station.
5875          *
5876          * Lower 8 bits of the value specify the UAPSD configuration.
5877          *
5878          * (see enum wmi_ap_ps_param_uapsd)
5879          * The default value is 0.
5880          */
5881         WMI_AP_PS_PEER_PARAM_UAPSD = 0,
5882
5883         /*
5884          * Set the service period for a UAPSD capable station
5885          *
5886          * The service period from wme ie in the (re)assoc request frame.
5887          *
5888          * (see enum wmi_ap_ps_peer_param_max_sp)
5889          */
5890         WMI_AP_PS_PEER_PARAM_MAX_SP = 1,
5891
5892         /* Time in seconds for aging out buffered frames for STA in PS */
5893         WMI_AP_PS_PEER_PARAM_AGEOUT_TIME = 2,
5894 };
5895
5896 struct wmi_ap_ps_peer_cmd {
5897         /* unique id identifying the VDEV, generated by the caller */
5898         __le32 vdev_id;
5899
5900         /* peer MAC address */
5901         struct wmi_mac_addr peer_macaddr;
5902
5903         /* AP powersave param (see enum wmi_ap_ps_peer_param) */
5904         __le32 param_id;
5905
5906         /* AP powersave param value */
5907         __le32 param_value;
5908 } __packed;
5909
5910 /* 128 clients = 4 words */
5911 #define WMI_TIM_BITMAP_ARRAY_SIZE 4
5912
5913 struct wmi_tim_info {
5914         __le32 tim_len;
5915         __le32 tim_mcast;
5916         __le32 tim_bitmap[WMI_TIM_BITMAP_ARRAY_SIZE];
5917         __le32 tim_changed;
5918         __le32 tim_num_ps_pending;
5919 } __packed;
5920
5921 struct wmi_tim_info_arg {
5922         __le32 tim_len;
5923         __le32 tim_mcast;
5924         const __le32 *tim_bitmap;
5925         __le32 tim_changed;
5926         __le32 tim_num_ps_pending;
5927 } __packed;
5928
5929 /* Maximum number of NOA Descriptors supported */
5930 #define WMI_P2P_MAX_NOA_DESCRIPTORS 4
5931 #define WMI_P2P_OPPPS_ENABLE_BIT        BIT(0)
5932 #define WMI_P2P_OPPPS_CTWINDOW_OFFSET   1
5933 #define WMI_P2P_NOA_CHANGED_BIT BIT(0)
5934
5935 struct wmi_p2p_noa_info {
5936         /* Bit 0 - Flag to indicate an update in NOA schedule
5937          * Bits 7-1 - Reserved
5938          */
5939         u8 changed;
5940         /* NOA index */
5941         u8 index;
5942         /* Bit 0 - Opp PS state of the AP
5943          * Bits 1-7 - Ctwindow in TUs
5944          */
5945         u8 ctwindow_oppps;
5946         /* Number of NOA descriptors */
5947         u8 num_descriptors;
5948
5949         struct wmi_p2p_noa_descriptor descriptors[WMI_P2P_MAX_NOA_DESCRIPTORS];
5950 } __packed;
5951
5952 struct wmi_bcn_info {
5953         struct wmi_tim_info tim_info;
5954         struct wmi_p2p_noa_info p2p_noa_info;
5955 } __packed;
5956
5957 struct wmi_host_swba_event {
5958         __le32 vdev_map;
5959         struct wmi_bcn_info bcn_info[0];
5960 } __packed;
5961
5962 struct wmi_10_2_4_bcn_info {
5963         struct wmi_tim_info tim_info;
5964         /* The 10.2.4 FW doesn't have p2p NOA info */
5965 } __packed;
5966
5967 struct wmi_10_2_4_host_swba_event {
5968         __le32 vdev_map;
5969         struct wmi_10_2_4_bcn_info bcn_info[0];
5970 } __packed;
5971
5972 /* 16 words = 512 client + 1 word = for guard */
5973 #define WMI_10_4_TIM_BITMAP_ARRAY_SIZE 17
5974
5975 struct wmi_10_4_tim_info {
5976         __le32 tim_len;
5977         __le32 tim_mcast;
5978         __le32 tim_bitmap[WMI_10_4_TIM_BITMAP_ARRAY_SIZE];
5979         __le32 tim_changed;
5980         __le32 tim_num_ps_pending;
5981 } __packed;
5982
5983 #define WMI_10_4_P2P_MAX_NOA_DESCRIPTORS 1
5984
5985 struct wmi_10_4_p2p_noa_info {
5986         /* Bit 0 - Flag to indicate an update in NOA schedule
5987          * Bits 7-1 - Reserved
5988          */
5989         u8 changed;
5990         /* NOA index */
5991         u8 index;
5992         /* Bit 0 - Opp PS state of the AP
5993          * Bits 1-7 - Ctwindow in TUs
5994          */
5995         u8 ctwindow_oppps;
5996         /* Number of NOA descriptors */
5997         u8 num_descriptors;
5998
5999         struct wmi_p2p_noa_descriptor
6000                 noa_descriptors[WMI_10_4_P2P_MAX_NOA_DESCRIPTORS];
6001 } __packed;
6002
6003 struct wmi_10_4_bcn_info {
6004         struct wmi_10_4_tim_info tim_info;
6005         struct wmi_10_4_p2p_noa_info p2p_noa_info;
6006 } __packed;
6007
6008 struct wmi_10_4_host_swba_event {
6009         __le32 vdev_map;
6010         struct wmi_10_4_bcn_info bcn_info[0];
6011 } __packed;
6012
6013 #define WMI_MAX_AP_VDEV 16
6014
6015 struct wmi_tbtt_offset_event {
6016         __le32 vdev_map;
6017         __le32 tbttoffset_list[WMI_MAX_AP_VDEV];
6018 } __packed;
6019
6020 struct wmi_peer_create_cmd {
6021         __le32 vdev_id;
6022         struct wmi_mac_addr peer_macaddr;
6023         __le32 peer_type;
6024 } __packed;
6025
6026 enum wmi_peer_type {
6027         WMI_PEER_TYPE_DEFAULT = 0,
6028         WMI_PEER_TYPE_BSS = 1,
6029         WMI_PEER_TYPE_TDLS = 2,
6030 };
6031
6032 struct wmi_peer_delete_cmd {
6033         __le32 vdev_id;
6034         struct wmi_mac_addr peer_macaddr;
6035 } __packed;
6036
6037 struct wmi_peer_flush_tids_cmd {
6038         __le32 vdev_id;
6039         struct wmi_mac_addr peer_macaddr;
6040         __le32 peer_tid_bitmap;
6041 } __packed;
6042
6043 struct wmi_fixed_rate {
6044         /*
6045          * rate mode . 0: disable fixed rate (auto rate)
6046          *   1: legacy (non 11n) rate  specified as ieee rate 2*Mbps
6047          *   2: ht20 11n rate  specified as mcs index
6048          *   3: ht40 11n rate  specified as mcs index
6049          */
6050         __le32  rate_mode;
6051         /*
6052          * 4 rate values for 4 rate series. series 0 is stored in byte 0 (LSB)
6053          * and series 3 is stored at byte 3 (MSB)
6054          */
6055         __le32  rate_series;
6056         /*
6057          * 4 retry counts for 4 rate series. retry count for rate 0 is stored
6058          * in byte 0 (LSB) and retry count for rate 3 is stored at byte 3
6059          * (MSB)
6060          */
6061         __le32  rate_retries;
6062 } __packed;
6063
6064 struct wmi_peer_fixed_rate_cmd {
6065         /* unique id identifying the VDEV, generated by the caller */
6066         __le32 vdev_id;
6067         /* peer MAC address */
6068         struct wmi_mac_addr peer_macaddr;
6069         /* fixed rate */
6070         struct wmi_fixed_rate peer_fixed_rate;
6071 } __packed;
6072
6073 #define WMI_MGMT_TID    17
6074
6075 struct wmi_addba_clear_resp_cmd {
6076         /* unique id identifying the VDEV, generated by the caller */
6077         __le32 vdev_id;
6078         /* peer MAC address */
6079         struct wmi_mac_addr peer_macaddr;
6080 } __packed;
6081
6082 struct wmi_addba_send_cmd {
6083         /* unique id identifying the VDEV, generated by the caller */
6084         __le32 vdev_id;
6085         /* peer MAC address */
6086         struct wmi_mac_addr peer_macaddr;
6087         /* Tid number */
6088         __le32 tid;
6089         /* Buffer/Window size*/
6090         __le32 buffersize;
6091 } __packed;
6092
6093 struct wmi_delba_send_cmd {
6094         /* unique id identifying the VDEV, generated by the caller */
6095         __le32 vdev_id;
6096         /* peer MAC address */
6097         struct wmi_mac_addr peer_macaddr;
6098         /* Tid number */
6099         __le32 tid;
6100         /* Is Initiator */
6101         __le32 initiator;
6102         /* Reason code */
6103         __le32 reasoncode;
6104 } __packed;
6105
6106 struct wmi_addba_setresponse_cmd {
6107         /* unique id identifying the vdev, generated by the caller */
6108         __le32 vdev_id;
6109         /* peer mac address */
6110         struct wmi_mac_addr peer_macaddr;
6111         /* Tid number */
6112         __le32 tid;
6113         /* status code */
6114         __le32 statuscode;
6115 } __packed;
6116
6117 struct wmi_send_singleamsdu_cmd {
6118         /* unique id identifying the vdev, generated by the caller */
6119         __le32 vdev_id;
6120         /* peer mac address */
6121         struct wmi_mac_addr peer_macaddr;
6122         /* Tid number */
6123         __le32 tid;
6124 } __packed;
6125
6126 enum wmi_peer_smps_state {
6127         WMI_PEER_SMPS_PS_NONE = 0x0,
6128         WMI_PEER_SMPS_STATIC  = 0x1,
6129         WMI_PEER_SMPS_DYNAMIC = 0x2
6130 };
6131
6132 enum wmi_peer_chwidth {
6133         WMI_PEER_CHWIDTH_20MHZ = 0,
6134         WMI_PEER_CHWIDTH_40MHZ = 1,
6135         WMI_PEER_CHWIDTH_80MHZ = 2,
6136         WMI_PEER_CHWIDTH_160MHZ = 3,
6137 };
6138
6139 enum wmi_peer_param {
6140         WMI_PEER_SMPS_STATE = 0x1, /* see %wmi_peer_smps_state */
6141         WMI_PEER_AMPDU      = 0x2,
6142         WMI_PEER_AUTHORIZE  = 0x3,
6143         WMI_PEER_CHAN_WIDTH = 0x4,
6144         WMI_PEER_NSS        = 0x5,
6145         WMI_PEER_USE_4ADDR  = 0x6,
6146         WMI_PEER_DEBUG      = 0xa,
6147         WMI_PEER_PHYMODE    = 0xd,
6148         WMI_PEER_DUMMY_VAR  = 0xff, /* dummy parameter for STA PS workaround */
6149 };
6150
6151 struct wmi_peer_set_param_cmd {
6152         __le32 vdev_id;
6153         struct wmi_mac_addr peer_macaddr;
6154         __le32 param_id;
6155         __le32 param_value;
6156 } __packed;
6157
6158 #define MAX_SUPPORTED_RATES 128
6159
6160 struct wmi_rate_set {
6161         /* total number of rates */
6162         __le32 num_rates;
6163         /*
6164          * rates (each 8bit value) packed into a 32 bit word.
6165          * the rates are filled from least significant byte to most
6166          * significant byte.
6167          */
6168         __le32 rates[(MAX_SUPPORTED_RATES / 4) + 1];
6169 } __packed;
6170
6171 struct wmi_rate_set_arg {
6172         unsigned int num_rates;
6173         u8 rates[MAX_SUPPORTED_RATES];
6174 };
6175
6176 /*
6177  * NOTE: It would bea good idea to represent the Tx MCS
6178  * info in one word and Rx in another word. This is split
6179  * into multiple words for convenience
6180  */
6181 struct wmi_vht_rate_set {
6182         __le32 rx_max_rate; /* Max Rx data rate */
6183         __le32 rx_mcs_set;  /* Negotiated RX VHT rates */
6184         __le32 tx_max_rate; /* Max Tx data rate */
6185         __le32 tx_mcs_set;  /* Negotiated TX VHT rates */
6186 } __packed;
6187
6188 struct wmi_vht_rate_set_arg {
6189         u32 rx_max_rate;
6190         u32 rx_mcs_set;
6191         u32 tx_max_rate;
6192         u32 tx_mcs_set;
6193 };
6194
6195 struct wmi_peer_set_rates_cmd {
6196         /* peer MAC address */
6197         struct wmi_mac_addr peer_macaddr;
6198         /* legacy rate set */
6199         struct wmi_rate_set peer_legacy_rates;
6200         /* ht rate set */
6201         struct wmi_rate_set peer_ht_rates;
6202 } __packed;
6203
6204 struct wmi_peer_set_q_empty_callback_cmd {
6205         /* unique id identifying the VDEV, generated by the caller */
6206         __le32 vdev_id;
6207         /* peer MAC address */
6208         struct wmi_mac_addr peer_macaddr;
6209         __le32 callback_enable;
6210 } __packed;
6211
6212 struct wmi_peer_flags_map {
6213         u32 auth;
6214         u32 qos;
6215         u32 need_ptk_4_way;
6216         u32 need_gtk_2_way;
6217         u32 apsd;
6218         u32 ht;
6219         u32 bw40;
6220         u32 stbc;
6221         u32 ldbc;
6222         u32 dyn_mimops;
6223         u32 static_mimops;
6224         u32 spatial_mux;
6225         u32 vht;
6226         u32 bw80;
6227         u32 vht_2g;
6228         u32 pmf;
6229         u32 bw160;
6230 };
6231
6232 enum wmi_peer_flags {
6233         WMI_PEER_AUTH = 0x00000001,
6234         WMI_PEER_QOS = 0x00000002,
6235         WMI_PEER_NEED_PTK_4_WAY = 0x00000004,
6236         WMI_PEER_NEED_GTK_2_WAY = 0x00000010,
6237         WMI_PEER_APSD = 0x00000800,
6238         WMI_PEER_HT = 0x00001000,
6239         WMI_PEER_40MHZ = 0x00002000,
6240         WMI_PEER_STBC = 0x00008000,
6241         WMI_PEER_LDPC = 0x00010000,
6242         WMI_PEER_DYN_MIMOPS = 0x00020000,
6243         WMI_PEER_STATIC_MIMOPS = 0x00040000,
6244         WMI_PEER_SPATIAL_MUX = 0x00200000,
6245         WMI_PEER_VHT = 0x02000000,
6246         WMI_PEER_80MHZ = 0x04000000,
6247         WMI_PEER_VHT_2G = 0x08000000,
6248         WMI_PEER_PMF = 0x10000000,
6249         WMI_PEER_160MHZ = 0x20000000
6250 };
6251
6252 enum wmi_10x_peer_flags {
6253         WMI_10X_PEER_AUTH = 0x00000001,
6254         WMI_10X_PEER_QOS = 0x00000002,
6255         WMI_10X_PEER_NEED_PTK_4_WAY = 0x00000004,
6256         WMI_10X_PEER_NEED_GTK_2_WAY = 0x00000010,
6257         WMI_10X_PEER_APSD = 0x00000800,
6258         WMI_10X_PEER_HT = 0x00001000,
6259         WMI_10X_PEER_40MHZ = 0x00002000,
6260         WMI_10X_PEER_STBC = 0x00008000,
6261         WMI_10X_PEER_LDPC = 0x00010000,
6262         WMI_10X_PEER_DYN_MIMOPS = 0x00020000,
6263         WMI_10X_PEER_STATIC_MIMOPS = 0x00040000,
6264         WMI_10X_PEER_SPATIAL_MUX = 0x00200000,
6265         WMI_10X_PEER_VHT = 0x02000000,
6266         WMI_10X_PEER_80MHZ = 0x04000000,
6267         WMI_10X_PEER_160MHZ = 0x20000000
6268 };
6269
6270 enum wmi_10_2_peer_flags {
6271         WMI_10_2_PEER_AUTH = 0x00000001,
6272         WMI_10_2_PEER_QOS = 0x00000002,
6273         WMI_10_2_PEER_NEED_PTK_4_WAY = 0x00000004,
6274         WMI_10_2_PEER_NEED_GTK_2_WAY = 0x00000010,
6275         WMI_10_2_PEER_APSD = 0x00000800,
6276         WMI_10_2_PEER_HT = 0x00001000,
6277         WMI_10_2_PEER_40MHZ = 0x00002000,
6278         WMI_10_2_PEER_STBC = 0x00008000,
6279         WMI_10_2_PEER_LDPC = 0x00010000,
6280         WMI_10_2_PEER_DYN_MIMOPS = 0x00020000,
6281         WMI_10_2_PEER_STATIC_MIMOPS = 0x00040000,
6282         WMI_10_2_PEER_SPATIAL_MUX = 0x00200000,
6283         WMI_10_2_PEER_VHT = 0x02000000,
6284         WMI_10_2_PEER_80MHZ = 0x04000000,
6285         WMI_10_2_PEER_VHT_2G = 0x08000000,
6286         WMI_10_2_PEER_PMF = 0x10000000,
6287         WMI_10_2_PEER_160MHZ = 0x20000000
6288 };
6289
6290 /*
6291  * Peer rate capabilities.
6292  *
6293  * This is of interest to the ratecontrol
6294  * module which resides in the firmware. The bit definitions are
6295  * consistent with that defined in if_athrate.c.
6296  */
6297 #define WMI_RC_DS_FLAG          0x01
6298 #define WMI_RC_CW40_FLAG        0x02
6299 #define WMI_RC_SGI_FLAG         0x04
6300 #define WMI_RC_HT_FLAG          0x08
6301 #define WMI_RC_RTSCTS_FLAG      0x10
6302 #define WMI_RC_TX_STBC_FLAG     0x20
6303 #define WMI_RC_RX_STBC_FLAG     0xC0
6304 #define WMI_RC_RX_STBC_FLAG_S   6
6305 #define WMI_RC_WEP_TKIP_FLAG    0x100
6306 #define WMI_RC_TS_FLAG          0x200
6307 #define WMI_RC_UAPSD_FLAG       0x400
6308
6309 /* Maximum listen interval supported by hw in units of beacon interval */
6310 #define ATH10K_MAX_HW_LISTEN_INTERVAL 5
6311
6312 struct wmi_common_peer_assoc_complete_cmd {
6313         struct wmi_mac_addr peer_macaddr;
6314         __le32 vdev_id;
6315         __le32 peer_new_assoc; /* 1=assoc, 0=reassoc */
6316         __le32 peer_associd; /* 16 LSBs */
6317         __le32 peer_flags;
6318         __le32 peer_caps; /* 16 LSBs */
6319         __le32 peer_listen_intval;
6320         __le32 peer_ht_caps;
6321         __le32 peer_max_mpdu;
6322         __le32 peer_mpdu_density; /* 0..16 */
6323         __le32 peer_rate_caps;
6324         struct wmi_rate_set peer_legacy_rates;
6325         struct wmi_rate_set peer_ht_rates;
6326         __le32 peer_nss; /* num of spatial streams */
6327         __le32 peer_vht_caps;
6328         __le32 peer_phymode;
6329         struct wmi_vht_rate_set peer_vht_rates;
6330 };
6331
6332 struct wmi_main_peer_assoc_complete_cmd {
6333         struct wmi_common_peer_assoc_complete_cmd cmd;
6334
6335         /* HT Operation Element of the peer. Five bytes packed in 2
6336          *  INT32 array and filled from lsb to msb.
6337          */
6338         __le32 peer_ht_info[2];
6339 } __packed;
6340
6341 struct wmi_10_1_peer_assoc_complete_cmd {
6342         struct wmi_common_peer_assoc_complete_cmd cmd;
6343 } __packed;
6344
6345 #define WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX_LSB 0
6346 #define WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX_MASK 0x0f
6347 #define WMI_PEER_ASSOC_INFO0_MAX_NSS_LSB 4
6348 #define WMI_PEER_ASSOC_INFO0_MAX_NSS_MASK 0xf0
6349
6350 struct wmi_10_2_peer_assoc_complete_cmd {
6351         struct wmi_common_peer_assoc_complete_cmd cmd;
6352         __le32 info0; /* WMI_PEER_ASSOC_INFO0_ */
6353 } __packed;
6354
6355 #define PEER_BW_RXNSS_OVERRIDE_OFFSET  31
6356
6357 struct wmi_10_4_peer_assoc_complete_cmd {
6358         struct wmi_10_2_peer_assoc_complete_cmd cmd;
6359         __le32 peer_bw_rxnss_override;
6360 } __packed;
6361
6362 struct wmi_peer_assoc_complete_arg {
6363         u8 addr[ETH_ALEN];
6364         u32 vdev_id;
6365         bool peer_reassoc;
6366         u16 peer_aid;
6367         u32 peer_flags; /* see %WMI_PEER_ */
6368         u16 peer_caps;
6369         u32 peer_listen_intval;
6370         u32 peer_ht_caps;
6371         u32 peer_max_mpdu;
6372         u32 peer_mpdu_density; /* 0..16 */
6373         u32 peer_rate_caps; /* see %WMI_RC_ */
6374         struct wmi_rate_set_arg peer_legacy_rates;
6375         struct wmi_rate_set_arg peer_ht_rates;
6376         u32 peer_num_spatial_streams;
6377         u32 peer_vht_caps;
6378         enum wmi_phy_mode peer_phymode;
6379         struct wmi_vht_rate_set_arg peer_vht_rates;
6380         u32 peer_bw_rxnss_override;
6381 };
6382
6383 struct wmi_peer_add_wds_entry_cmd {
6384         /* peer MAC address */
6385         struct wmi_mac_addr peer_macaddr;
6386         /* wds MAC addr */
6387         struct wmi_mac_addr wds_macaddr;
6388 } __packed;
6389
6390 struct wmi_peer_remove_wds_entry_cmd {
6391         /* wds MAC addr */
6392         struct wmi_mac_addr wds_macaddr;
6393 } __packed;
6394
6395 struct wmi_peer_q_empty_callback_event {
6396         /* peer MAC address */
6397         struct wmi_mac_addr peer_macaddr;
6398 } __packed;
6399
6400 /*
6401  * Channel info WMI event
6402  */
6403 struct wmi_chan_info_event {
6404         __le32 err_code;
6405         __le32 freq;
6406         __le32 cmd_flags;
6407         __le32 noise_floor;
6408         __le32 rx_clear_count;
6409         __le32 cycle_count;
6410 } __packed;
6411
6412 struct wmi_10_4_chan_info_event {
6413         __le32 err_code;
6414         __le32 freq;
6415         __le32 cmd_flags;
6416         __le32 noise_floor;
6417         __le32 rx_clear_count;
6418         __le32 cycle_count;
6419         __le32 chan_tx_pwr_range;
6420         __le32 chan_tx_pwr_tp;
6421         __le32 rx_frame_count;
6422 } __packed;
6423
6424 struct wmi_peer_sta_kickout_event {
6425         struct wmi_mac_addr peer_macaddr;
6426 } __packed;
6427
6428 #define WMI_CHAN_INFO_FLAG_COMPLETE BIT(0)
6429 #define WMI_CHAN_INFO_FLAG_PRE_COMPLETE BIT(1)
6430
6431 /* Beacon filter wmi command info */
6432 #define BCN_FLT_MAX_SUPPORTED_IES       256
6433 #define BCN_FLT_MAX_ELEMS_IE_LIST       (BCN_FLT_MAX_SUPPORTED_IES / 32)
6434
6435 struct bss_bcn_stats {
6436         __le32 vdev_id;
6437         __le32 bss_bcnsdropped;
6438         __le32 bss_bcnsdelivered;
6439 } __packed;
6440
6441 struct bcn_filter_stats {
6442         __le32 bcns_dropped;
6443         __le32 bcns_delivered;
6444         __le32 activefilters;
6445         struct bss_bcn_stats bss_stats;
6446 } __packed;
6447
6448 struct wmi_add_bcn_filter_cmd {
6449         u32 vdev_id;
6450         u32 ie_map[BCN_FLT_MAX_ELEMS_IE_LIST];
6451 } __packed;
6452
6453 enum wmi_sta_keepalive_method {
6454         WMI_STA_KEEPALIVE_METHOD_NULL_FRAME = 1,
6455         WMI_STA_KEEPALIVE_METHOD_UNSOLICITATED_ARP_RESPONSE = 2,
6456 };
6457
6458 #define WMI_STA_KEEPALIVE_INTERVAL_DISABLE 0
6459
6460 /* Firmware crashes if keepalive interval exceeds this limit */
6461 #define WMI_STA_KEEPALIVE_INTERVAL_MAX_SECONDS 0xffff
6462
6463 /* note: ip4 addresses are in network byte order, i.e. big endian */
6464 struct wmi_sta_keepalive_arp_resp {
6465         __be32 src_ip4_addr;
6466         __be32 dest_ip4_addr;
6467         struct wmi_mac_addr dest_mac_addr;
6468 } __packed;
6469
6470 struct wmi_sta_keepalive_cmd {
6471         __le32 vdev_id;
6472         __le32 enabled;
6473         __le32 method; /* WMI_STA_KEEPALIVE_METHOD_ */
6474         __le32 interval; /* in seconds */
6475         struct wmi_sta_keepalive_arp_resp arp_resp;
6476 } __packed;
6477
6478 struct wmi_sta_keepalive_arg {
6479         u32 vdev_id;
6480         u32 enabled;
6481         u32 method;
6482         u32 interval;
6483         __be32 src_ip4_addr;
6484         __be32 dest_ip4_addr;
6485         const u8 dest_mac_addr[ETH_ALEN];
6486 };
6487
6488 enum wmi_force_fw_hang_type {
6489         WMI_FORCE_FW_HANG_ASSERT = 1,
6490         WMI_FORCE_FW_HANG_NO_DETECT,
6491         WMI_FORCE_FW_HANG_CTRL_EP_FULL,
6492         WMI_FORCE_FW_HANG_EMPTY_POINT,
6493         WMI_FORCE_FW_HANG_STACK_OVERFLOW,
6494         WMI_FORCE_FW_HANG_INFINITE_LOOP,
6495 };
6496
6497 #define WMI_FORCE_FW_HANG_RANDOM_TIME 0xFFFFFFFF
6498
6499 struct wmi_force_fw_hang_cmd {
6500         __le32 type;
6501         __le32 delay_ms;
6502 } __packed;
6503
6504 enum ath10k_dbglog_level {
6505         ATH10K_DBGLOG_LEVEL_VERBOSE = 0,
6506         ATH10K_DBGLOG_LEVEL_INFO = 1,
6507         ATH10K_DBGLOG_LEVEL_WARN = 2,
6508         ATH10K_DBGLOG_LEVEL_ERR = 3,
6509 };
6510
6511 /* VAP ids to enable dbglog */
6512 #define ATH10K_DBGLOG_CFG_VAP_LOG_LSB           0
6513 #define ATH10K_DBGLOG_CFG_VAP_LOG_MASK          0x0000ffff
6514
6515 /* to enable dbglog in the firmware */
6516 #define ATH10K_DBGLOG_CFG_REPORTING_ENABLE_LSB  16
6517 #define ATH10K_DBGLOG_CFG_REPORTING_ENABLE_MASK 0x00010000
6518
6519 /* timestamp resolution */
6520 #define ATH10K_DBGLOG_CFG_RESOLUTION_LSB        17
6521 #define ATH10K_DBGLOG_CFG_RESOLUTION_MASK       0x000E0000
6522
6523 /* number of queued messages before sending them to the host */
6524 #define ATH10K_DBGLOG_CFG_REPORT_SIZE_LSB       20
6525 #define ATH10K_DBGLOG_CFG_REPORT_SIZE_MASK      0x0ff00000
6526
6527 /*
6528  * Log levels to enable. This defines the minimum level to enable, this is
6529  * not a bitmask. See enum ath10k_dbglog_level for the values.
6530  */
6531 #define ATH10K_DBGLOG_CFG_LOG_LVL_LSB           28
6532 #define ATH10K_DBGLOG_CFG_LOG_LVL_MASK          0x70000000
6533
6534 /*
6535  * Note: this is a cleaned up version of a struct firmware uses. For
6536  * example, config_valid was hidden inside an array.
6537  */
6538 struct wmi_dbglog_cfg_cmd {
6539         /* bitmask to hold mod id config*/
6540         __le32 module_enable;
6541
6542         /* see ATH10K_DBGLOG_CFG_ */
6543         __le32 config_enable;
6544
6545         /* mask of module id bits to be changed */
6546         __le32 module_valid;
6547
6548         /* mask of config bits to be changed, see ATH10K_DBGLOG_CFG_ */
6549         __le32 config_valid;
6550 } __packed;
6551
6552 struct wmi_10_4_dbglog_cfg_cmd {
6553         /* bitmask to hold mod id config*/
6554         __le64 module_enable;
6555
6556         /* see ATH10K_DBGLOG_CFG_ */
6557         __le32 config_enable;
6558
6559         /* mask of module id bits to be changed */
6560         __le64 module_valid;
6561
6562         /* mask of config bits to be changed, see ATH10K_DBGLOG_CFG_ */
6563         __le32 config_valid;
6564 } __packed;
6565
6566 enum wmi_roam_reason {
6567         WMI_ROAM_REASON_BETTER_AP = 1,
6568         WMI_ROAM_REASON_BEACON_MISS = 2,
6569         WMI_ROAM_REASON_LOW_RSSI = 3,
6570         WMI_ROAM_REASON_SUITABLE_AP_FOUND = 4,
6571         WMI_ROAM_REASON_HO_FAILED = 5,
6572
6573         /* keep last */
6574         WMI_ROAM_REASON_MAX,
6575 };
6576
6577 struct wmi_roam_ev {
6578         __le32 vdev_id;
6579         __le32 reason;
6580 } __packed;
6581
6582 #define ATH10K_FRAGMT_THRESHOLD_MIN     540
6583 #define ATH10K_FRAGMT_THRESHOLD_MAX     2346
6584
6585 #define WMI_MAX_EVENT 0x1000
6586 /* Maximum number of pending TXed WMI packets */
6587 #define WMI_SKB_HEADROOM sizeof(struct wmi_cmd_hdr)
6588
6589 /* By default disable power save for IBSS */
6590 #define ATH10K_DEFAULT_ATIM 0
6591
6592 #define WMI_MAX_MEM_REQS 16
6593
6594 struct wmi_scan_ev_arg {
6595         __le32 event_type; /* %WMI_SCAN_EVENT_ */
6596         __le32 reason; /* %WMI_SCAN_REASON_ */
6597         __le32 channel_freq; /* only valid for WMI_SCAN_EVENT_FOREIGN_CHANNEL */
6598         __le32 scan_req_id;
6599         __le32 scan_id;
6600         __le32 vdev_id;
6601 };
6602
6603 struct wmi_mgmt_rx_ev_arg {
6604         __le32 channel;
6605         __le32 snr;
6606         __le32 rate;
6607         __le32 phy_mode;
6608         __le32 buf_len;
6609         __le32 status; /* %WMI_RX_STATUS_ */
6610         struct wmi_mgmt_rx_ext_info ext_info;
6611 };
6612
6613 struct wmi_ch_info_ev_arg {
6614         __le32 err_code;
6615         __le32 freq;
6616         __le32 cmd_flags;
6617         __le32 noise_floor;
6618         __le32 rx_clear_count;
6619         __le32 cycle_count;
6620         __le32 chan_tx_pwr_range;
6621         __le32 chan_tx_pwr_tp;
6622         __le32 rx_frame_count;
6623 };
6624
6625 struct wmi_vdev_start_ev_arg {
6626         __le32 vdev_id;
6627         __le32 req_id;
6628         __le32 resp_type; /* %WMI_VDEV_RESP_ */
6629         __le32 status;
6630 };
6631
6632 struct wmi_peer_kick_ev_arg {
6633         const u8 *mac_addr;
6634 };
6635
6636 struct wmi_swba_ev_arg {
6637         __le32 vdev_map;
6638         struct wmi_tim_info_arg tim_info[WMI_MAX_AP_VDEV];
6639         const struct wmi_p2p_noa_info *noa_info[WMI_MAX_AP_VDEV];
6640 };
6641
6642 struct wmi_phyerr_ev_arg {
6643         u32 tsf_timestamp;
6644         u16 freq1;
6645         u16 freq2;
6646         u8 rssi_combined;
6647         u8 chan_width_mhz;
6648         u8 phy_err_code;
6649         u16 nf_chains[4];
6650         u32 buf_len;
6651         const u8 *buf;
6652         u8 hdr_len;
6653 };
6654
6655 struct wmi_phyerr_hdr_arg {
6656         u32 num_phyerrs;
6657         u32 tsf_l32;
6658         u32 tsf_u32;
6659         u32 buf_len;
6660         const void *phyerrs;
6661 };
6662
6663 struct wmi_dfs_status_ev_arg {
6664         u32 status;
6665 };
6666
6667 struct wmi_svc_rdy_ev_arg {
6668         __le32 min_tx_power;
6669         __le32 max_tx_power;
6670         __le32 ht_cap;
6671         __le32 vht_cap;
6672         __le32 sw_ver0;
6673         __le32 sw_ver1;
6674         __le32 fw_build;
6675         __le32 phy_capab;
6676         __le32 num_rf_chains;
6677         __le32 eeprom_rd;
6678         __le32 num_mem_reqs;
6679         __le32 low_5ghz_chan;
6680         __le32 high_5ghz_chan;
6681         const __le32 *service_map;
6682         size_t service_map_len;
6683         const struct wlan_host_mem_req *mem_reqs[WMI_MAX_MEM_REQS];
6684 };
6685
6686 struct wmi_svc_avail_ev_arg {
6687         __le32 service_map_ext_len;
6688         const __le32 *service_map_ext;
6689 };
6690
6691 struct wmi_rdy_ev_arg {
6692         __le32 sw_version;
6693         __le32 abi_version;
6694         __le32 status;
6695         const u8 *mac_addr;
6696 };
6697
6698 struct wmi_roam_ev_arg {
6699         __le32 vdev_id;
6700         __le32 reason;
6701         __le32 rssi;
6702 };
6703
6704 struct wmi_echo_ev_arg {
6705         __le32 value;
6706 };
6707
6708 struct wmi_pdev_temperature_event {
6709         /* temperature value in Celcius degree */
6710         __le32 temperature;
6711 } __packed;
6712
6713 struct wmi_pdev_bss_chan_info_event {
6714         __le32 freq;
6715         __le32 noise_floor;
6716         __le64 cycle_busy;
6717         __le64 cycle_total;
6718         __le64 cycle_tx;
6719         __le64 cycle_rx;
6720         __le64 cycle_rx_bss;
6721         __le32 reserved;
6722 } __packed;
6723
6724 /* WOW structures */
6725 enum wmi_wow_wakeup_event {
6726         WOW_BMISS_EVENT = 0,
6727         WOW_BETTER_AP_EVENT,
6728         WOW_DEAUTH_RECVD_EVENT,
6729         WOW_MAGIC_PKT_RECVD_EVENT,
6730         WOW_GTK_ERR_EVENT,
6731         WOW_FOURWAY_HSHAKE_EVENT,
6732         WOW_EAPOL_RECVD_EVENT,
6733         WOW_NLO_DETECTED_EVENT,
6734         WOW_DISASSOC_RECVD_EVENT,
6735         WOW_PATTERN_MATCH_EVENT,
6736         WOW_CSA_IE_EVENT,
6737         WOW_PROBE_REQ_WPS_IE_EVENT,
6738         WOW_AUTH_REQ_EVENT,
6739         WOW_ASSOC_REQ_EVENT,
6740         WOW_HTT_EVENT,
6741         WOW_RA_MATCH_EVENT,
6742         WOW_HOST_AUTO_SHUTDOWN_EVENT,
6743         WOW_IOAC_MAGIC_EVENT,
6744         WOW_IOAC_SHORT_EVENT,
6745         WOW_IOAC_EXTEND_EVENT,
6746         WOW_IOAC_TIMER_EVENT,
6747         WOW_DFS_PHYERR_RADAR_EVENT,
6748         WOW_BEACON_EVENT,
6749         WOW_CLIENT_KICKOUT_EVENT,
6750         WOW_EVENT_MAX,
6751 };
6752
6753 #define C2S(x) case x: return #x
6754
6755 static inline const char *wow_wakeup_event(enum wmi_wow_wakeup_event ev)
6756 {
6757         switch (ev) {
6758         C2S(WOW_BMISS_EVENT);
6759         C2S(WOW_BETTER_AP_EVENT);
6760         C2S(WOW_DEAUTH_RECVD_EVENT);
6761         C2S(WOW_MAGIC_PKT_RECVD_EVENT);
6762         C2S(WOW_GTK_ERR_EVENT);
6763         C2S(WOW_FOURWAY_HSHAKE_EVENT);
6764         C2S(WOW_EAPOL_RECVD_EVENT);
6765         C2S(WOW_NLO_DETECTED_EVENT);
6766         C2S(WOW_DISASSOC_RECVD_EVENT);
6767         C2S(WOW_PATTERN_MATCH_EVENT);
6768         C2S(WOW_CSA_IE_EVENT);
6769         C2S(WOW_PROBE_REQ_WPS_IE_EVENT);
6770         C2S(WOW_AUTH_REQ_EVENT);
6771         C2S(WOW_ASSOC_REQ_EVENT);
6772         C2S(WOW_HTT_EVENT);
6773         C2S(WOW_RA_MATCH_EVENT);
6774         C2S(WOW_HOST_AUTO_SHUTDOWN_EVENT);
6775         C2S(WOW_IOAC_MAGIC_EVENT);
6776         C2S(WOW_IOAC_SHORT_EVENT);
6777         C2S(WOW_IOAC_EXTEND_EVENT);
6778         C2S(WOW_IOAC_TIMER_EVENT);
6779         C2S(WOW_DFS_PHYERR_RADAR_EVENT);
6780         C2S(WOW_BEACON_EVENT);
6781         C2S(WOW_CLIENT_KICKOUT_EVENT);
6782         C2S(WOW_EVENT_MAX);
6783         default:
6784                 return NULL;
6785         }
6786 }
6787
6788 enum wmi_wow_wake_reason {
6789         WOW_REASON_UNSPECIFIED = -1,
6790         WOW_REASON_NLOD = 0,
6791         WOW_REASON_AP_ASSOC_LOST,
6792         WOW_REASON_LOW_RSSI,
6793         WOW_REASON_DEAUTH_RECVD,
6794         WOW_REASON_DISASSOC_RECVD,
6795         WOW_REASON_GTK_HS_ERR,
6796         WOW_REASON_EAP_REQ,
6797         WOW_REASON_FOURWAY_HS_RECV,
6798         WOW_REASON_TIMER_INTR_RECV,
6799         WOW_REASON_PATTERN_MATCH_FOUND,
6800         WOW_REASON_RECV_MAGIC_PATTERN,
6801         WOW_REASON_P2P_DISC,
6802         WOW_REASON_WLAN_HB,
6803         WOW_REASON_CSA_EVENT,
6804         WOW_REASON_PROBE_REQ_WPS_IE_RECV,
6805         WOW_REASON_AUTH_REQ_RECV,
6806         WOW_REASON_ASSOC_REQ_RECV,
6807         WOW_REASON_HTT_EVENT,
6808         WOW_REASON_RA_MATCH,
6809         WOW_REASON_HOST_AUTO_SHUTDOWN,
6810         WOW_REASON_IOAC_MAGIC_EVENT,
6811         WOW_REASON_IOAC_SHORT_EVENT,
6812         WOW_REASON_IOAC_EXTEND_EVENT,
6813         WOW_REASON_IOAC_TIMER_EVENT,
6814         WOW_REASON_ROAM_HO,
6815         WOW_REASON_DFS_PHYERR_RADADR_EVENT,
6816         WOW_REASON_BEACON_RECV,
6817         WOW_REASON_CLIENT_KICKOUT_EVENT,
6818         WOW_REASON_DEBUG_TEST = 0xFF,
6819 };
6820
6821 static inline const char *wow_reason(enum wmi_wow_wake_reason reason)
6822 {
6823         switch (reason) {
6824         C2S(WOW_REASON_UNSPECIFIED);
6825         C2S(WOW_REASON_NLOD);
6826         C2S(WOW_REASON_AP_ASSOC_LOST);
6827         C2S(WOW_REASON_LOW_RSSI);
6828         C2S(WOW_REASON_DEAUTH_RECVD);
6829         C2S(WOW_REASON_DISASSOC_RECVD);
6830         C2S(WOW_REASON_GTK_HS_ERR);
6831         C2S(WOW_REASON_EAP_REQ);
6832         C2S(WOW_REASON_FOURWAY_HS_RECV);
6833         C2S(WOW_REASON_TIMER_INTR_RECV);
6834         C2S(WOW_REASON_PATTERN_MATCH_FOUND);
6835         C2S(WOW_REASON_RECV_MAGIC_PATTERN);
6836         C2S(WOW_REASON_P2P_DISC);
6837         C2S(WOW_REASON_WLAN_HB);
6838         C2S(WOW_REASON_CSA_EVENT);
6839         C2S(WOW_REASON_PROBE_REQ_WPS_IE_RECV);
6840         C2S(WOW_REASON_AUTH_REQ_RECV);
6841         C2S(WOW_REASON_ASSOC_REQ_RECV);
6842         C2S(WOW_REASON_HTT_EVENT);
6843         C2S(WOW_REASON_RA_MATCH);
6844         C2S(WOW_REASON_HOST_AUTO_SHUTDOWN);
6845         C2S(WOW_REASON_IOAC_MAGIC_EVENT);
6846         C2S(WOW_REASON_IOAC_SHORT_EVENT);
6847         C2S(WOW_REASON_IOAC_EXTEND_EVENT);
6848         C2S(WOW_REASON_IOAC_TIMER_EVENT);
6849         C2S(WOW_REASON_ROAM_HO);
6850         C2S(WOW_REASON_DFS_PHYERR_RADADR_EVENT);
6851         C2S(WOW_REASON_BEACON_RECV);
6852         C2S(WOW_REASON_CLIENT_KICKOUT_EVENT);
6853         C2S(WOW_REASON_DEBUG_TEST);
6854         default:
6855                 return NULL;
6856         }
6857 }
6858
6859 #undef C2S
6860
6861 struct wmi_wow_ev_arg {
6862         u32 vdev_id;
6863         u32 flag;
6864         enum wmi_wow_wake_reason wake_reason;
6865         u32 data_len;
6866 };
6867
6868 #define WOW_MIN_PATTERN_SIZE    1
6869 #define WOW_MAX_PATTERN_SIZE    148
6870 #define WOW_MAX_PKT_OFFSET      128
6871 #define WOW_HDR_LEN     (sizeof(struct ieee80211_hdr_3addr) + \
6872         sizeof(struct rfc1042_hdr))
6873 #define WOW_MAX_REDUCE  (WOW_HDR_LEN - sizeof(struct ethhdr) - \
6874         offsetof(struct ieee80211_hdr_3addr, addr1))
6875
6876 enum wmi_tdls_state {
6877         WMI_TDLS_DISABLE,
6878         WMI_TDLS_ENABLE_PASSIVE,
6879         WMI_TDLS_ENABLE_ACTIVE,
6880         WMI_TDLS_ENABLE_ACTIVE_EXTERNAL_CONTROL,
6881 };
6882
6883 enum wmi_tdls_peer_state {
6884         WMI_TDLS_PEER_STATE_PEERING,
6885         WMI_TDLS_PEER_STATE_CONNECTED,
6886         WMI_TDLS_PEER_STATE_TEARDOWN,
6887 };
6888
6889 struct wmi_tdls_peer_update_cmd_arg {
6890         u32 vdev_id;
6891         enum wmi_tdls_peer_state peer_state;
6892         u8 addr[ETH_ALEN];
6893 };
6894
6895 #define WMI_TDLS_MAX_SUPP_OPER_CLASSES 32
6896
6897 #define WMI_TDLS_PEER_SP_MASK   0x60
6898 #define WMI_TDLS_PEER_SP_LSB    5
6899
6900 enum wmi_tdls_options {
6901         WMI_TDLS_OFFCHAN_EN = BIT(0),
6902         WMI_TDLS_BUFFER_STA_EN = BIT(1),
6903         WMI_TDLS_SLEEP_STA_EN = BIT(2),
6904 };
6905
6906 enum {
6907         WMI_TDLS_PEER_QOS_AC_VO = BIT(0),
6908         WMI_TDLS_PEER_QOS_AC_VI = BIT(1),
6909         WMI_TDLS_PEER_QOS_AC_BK = BIT(2),
6910         WMI_TDLS_PEER_QOS_AC_BE = BIT(3),
6911 };
6912
6913 struct wmi_tdls_peer_capab_arg {
6914         u8 peer_uapsd_queues;
6915         u8 peer_max_sp;
6916         u32 buff_sta_support;
6917         u32 off_chan_support;
6918         u32 peer_curr_operclass;
6919         u32 self_curr_operclass;
6920         u32 peer_chan_len;
6921         u32 peer_operclass_len;
6922         u8 peer_operclass[WMI_TDLS_MAX_SUPP_OPER_CLASSES];
6923         u32 is_peer_responder;
6924         u32 pref_offchan_num;
6925         u32 pref_offchan_bw;
6926 };
6927
6928 struct wmi_10_4_tdls_set_state_cmd {
6929         __le32 vdev_id;
6930         __le32 state;
6931         __le32 notification_interval_ms;
6932         __le32 tx_discovery_threshold;
6933         __le32 tx_teardown_threshold;
6934         __le32 rssi_teardown_threshold;
6935         __le32 rssi_delta;
6936         __le32 tdls_options;
6937         __le32 tdls_peer_traffic_ind_window;
6938         __le32 tdls_peer_traffic_response_timeout_ms;
6939         __le32 tdls_puapsd_mask;
6940         __le32 tdls_puapsd_inactivity_time_ms;
6941         __le32 tdls_puapsd_rx_frame_threshold;
6942         __le32 teardown_notification_ms;
6943         __le32 tdls_peer_kickout_threshold;
6944 } __packed;
6945
6946 struct wmi_tdls_peer_capabilities {
6947         __le32 peer_qos;
6948         __le32 buff_sta_support;
6949         __le32 off_chan_support;
6950         __le32 peer_curr_operclass;
6951         __le32 self_curr_operclass;
6952         __le32 peer_chan_len;
6953         __le32 peer_operclass_len;
6954         u8 peer_operclass[WMI_TDLS_MAX_SUPP_OPER_CLASSES];
6955         __le32 is_peer_responder;
6956         __le32 pref_offchan_num;
6957         __le32 pref_offchan_bw;
6958         struct wmi_channel peer_chan_list[1];
6959 } __packed;
6960
6961 struct wmi_10_4_tdls_peer_update_cmd {
6962         __le32 vdev_id;
6963         struct wmi_mac_addr peer_macaddr;
6964         __le32 peer_state;
6965         __le32 reserved[4];
6966         struct wmi_tdls_peer_capabilities peer_capab;
6967 } __packed;
6968
6969 enum wmi_tdls_peer_reason {
6970         WMI_TDLS_TEARDOWN_REASON_TX,
6971         WMI_TDLS_TEARDOWN_REASON_RSSI,
6972         WMI_TDLS_TEARDOWN_REASON_SCAN,
6973         WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE,
6974         WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT,
6975         WMI_TDLS_TEARDOWN_REASON_BAD_PTR,
6976         WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE,
6977         WMI_TDLS_ENTER_BUF_STA,
6978         WMI_TDLS_EXIT_BUF_STA,
6979         WMI_TDLS_ENTER_BT_BUSY_MODE,
6980         WMI_TDLS_EXIT_BT_BUSY_MODE,
6981         WMI_TDLS_SCAN_STARTED_EVENT,
6982         WMI_TDLS_SCAN_COMPLETED_EVENT,
6983 };
6984
6985 enum wmi_tdls_peer_notification {
6986         WMI_TDLS_SHOULD_DISCOVER,
6987         WMI_TDLS_SHOULD_TEARDOWN,
6988         WMI_TDLS_PEER_DISCONNECTED,
6989         WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION,
6990 };
6991
6992 struct wmi_tdls_peer_event {
6993         struct wmi_mac_addr peer_macaddr;
6994         /* see enum wmi_tdls_peer_notification*/
6995         __le32 peer_status;
6996         /* see enum wmi_tdls_peer_reason */
6997         __le32 peer_reason;
6998         __le32 vdev_id;
6999 } __packed;
7000
7001 enum wmi_txbf_conf {
7002         WMI_TXBF_CONF_UNSUPPORTED,
7003         WMI_TXBF_CONF_BEFORE_ASSOC,
7004         WMI_TXBF_CONF_AFTER_ASSOC,
7005 };
7006
7007 #define WMI_CCA_DETECT_LEVEL_AUTO       0
7008 #define WMI_CCA_DETECT_MARGIN_AUTO      0
7009
7010 struct wmi_pdev_set_adaptive_cca_params {
7011         __le32 enable;
7012         __le32 cca_detect_level;
7013         __le32 cca_detect_margin;
7014 } __packed;
7015
7016 enum wmi_host_platform_type {
7017         WMI_HOST_PLATFORM_HIGH_PERF,
7018         WMI_HOST_PLATFORM_LOW_PERF,
7019 };
7020
7021 enum wmi_bss_survey_req_type {
7022         WMI_BSS_SURVEY_REQ_TYPE_READ = 1,
7023         WMI_BSS_SURVEY_REQ_TYPE_READ_CLEAR,
7024 };
7025
7026 struct wmi_pdev_chan_info_req_cmd {
7027         __le32 type;
7028         __le32 reserved;
7029 } __packed;
7030
7031 struct ath10k;
7032 struct ath10k_vif;
7033 struct ath10k_fw_stats_pdev;
7034 struct ath10k_fw_stats_peer;
7035 struct ath10k_fw_stats;
7036
7037 int ath10k_wmi_attach(struct ath10k *ar);
7038 void ath10k_wmi_detach(struct ath10k *ar);
7039 void ath10k_wmi_free_host_mem(struct ath10k *ar);
7040 int ath10k_wmi_wait_for_service_ready(struct ath10k *ar);
7041 int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar);
7042
7043 struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len);
7044 int ath10k_wmi_connect(struct ath10k *ar);
7045
7046 struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len);
7047 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
7048 int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb,
7049                                u32 cmd_id);
7050 void ath10k_wmi_start_scan_init(struct ath10k *ar, struct wmi_start_scan_arg *arg);
7051
7052 void ath10k_wmi_pull_pdev_stats_base(const struct wmi_pdev_stats_base *src,
7053                                      struct ath10k_fw_stats_pdev *dst);
7054 void ath10k_wmi_pull_pdev_stats_tx(const struct wmi_pdev_stats_tx *src,
7055                                    struct ath10k_fw_stats_pdev *dst);
7056 void ath10k_wmi_pull_pdev_stats_rx(const struct wmi_pdev_stats_rx *src,
7057                                    struct ath10k_fw_stats_pdev *dst);
7058 void ath10k_wmi_pull_pdev_stats_extra(const struct wmi_pdev_stats_extra *src,
7059                                       struct ath10k_fw_stats_pdev *dst);
7060 void ath10k_wmi_pull_peer_stats(const struct wmi_peer_stats *src,
7061                                 struct ath10k_fw_stats_peer *dst);
7062 void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar,
7063                                     struct wmi_host_mem_chunks *chunks);
7064 void ath10k_wmi_put_start_scan_common(struct wmi_start_scan_common *cmn,
7065                                       const struct wmi_start_scan_arg *arg);
7066 void ath10k_wmi_set_wmm_param(struct wmi_wmm_params *params,
7067                               const struct wmi_wmm_params_arg *arg);
7068 void ath10k_wmi_put_wmi_channel(struct wmi_channel *ch,
7069                                 const struct wmi_channel_arg *arg);
7070 int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg);
7071
7072 int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb);
7073 int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb);
7074 void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb);
7075 void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb);
7076 int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb);
7077 void ath10k_wmi_event_update_stats(struct ath10k *ar, struct sk_buff *skb);
7078 void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, struct sk_buff *skb);
7079 void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, struct sk_buff *skb);
7080 void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, struct sk_buff *skb);
7081 void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb);
7082 void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, struct sk_buff *skb);
7083 void ath10k_wmi_event_dfs(struct ath10k *ar,
7084                           struct wmi_phyerr_ev_arg *phyerr, u64 tsf);
7085 void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
7086                                     struct wmi_phyerr_ev_arg *phyerr,
7087                                     u64 tsf);
7088 void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb);
7089 void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb);
7090 void ath10k_wmi_event_profile_match(struct ath10k *ar, struct sk_buff *skb);
7091 void ath10k_wmi_event_debug_print(struct ath10k *ar, struct sk_buff *skb);
7092 void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb);
7093 void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, struct sk_buff *skb);
7094 void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar,
7095                                              struct sk_buff *skb);
7096 void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar,
7097                                              struct sk_buff *skb);
7098 void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, struct sk_buff *skb);
7099 void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb);
7100 void ath10k_wmi_event_dcs_interference(struct ath10k *ar, struct sk_buff *skb);
7101 void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, struct sk_buff *skb);
7102 void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, struct sk_buff *skb);
7103 void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar,
7104                                          struct sk_buff *skb);
7105 void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, struct sk_buff *skb);
7106 void ath10k_wmi_event_delba_complete(struct ath10k *ar, struct sk_buff *skb);
7107 void ath10k_wmi_event_addba_complete(struct ath10k *ar, struct sk_buff *skb);
7108 void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar,
7109                                                 struct sk_buff *skb);
7110 void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, struct sk_buff *skb);
7111 void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, struct sk_buff *skb);
7112 void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, struct sk_buff *skb);
7113 void ath10k_wmi_event_service_ready(struct ath10k *ar, struct sk_buff *skb);
7114 int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb);
7115 void ath10k_wmi_event_service_available(struct ath10k *ar, struct sk_buff *skb);
7116 int ath10k_wmi_op_pull_phyerr_ev(struct ath10k *ar, const void *phyerr_buf,
7117                                  int left_len, struct wmi_phyerr_ev_arg *arg);
7118 void ath10k_wmi_main_op_fw_stats_fill(struct ath10k *ar,
7119                                       struct ath10k_fw_stats *fw_stats,
7120                                       char *buf);
7121 void ath10k_wmi_10x_op_fw_stats_fill(struct ath10k *ar,
7122                                      struct ath10k_fw_stats *fw_stats,
7123                                      char *buf);
7124 size_t ath10k_wmi_fw_stats_num_peers(struct list_head *head);
7125 size_t ath10k_wmi_fw_stats_num_vdevs(struct list_head *head);
7126 void ath10k_wmi_10_4_op_fw_stats_fill(struct ath10k *ar,
7127                                       struct ath10k_fw_stats *fw_stats,
7128                                       char *buf);
7129 int ath10k_wmi_op_get_vdev_subtype(struct ath10k *ar,
7130                                    enum wmi_vdev_subtype subtype);
7131 int ath10k_wmi_barrier(struct ath10k *ar);
7132 void ath10k_wmi_tpc_config_get_rate_code(u8 *rate_code, u16 *pream_table,
7133                                          u32 num_tx_chain);
7134 void ath10k_wmi_event_tpc_final_table(struct ath10k *ar, struct sk_buff *skb);
7135
7136 #endif /* _WMI_H_ */