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