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