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