blob: cec1cd5c05c99ced2d2308046086face6d258402 [file] [log] [blame]
Govind Singh6b411b52016-03-06 19:55:02 +05301/*
2 * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * Host WMI unified implementation
30 */
31#include "athdefs.h"
32#include "osapi_linux.h"
33#include "a_types.h"
34#include "a_debug.h"
35#include "ol_if_athvar.h"
36#include "ol_defines.h"
Govind Singhe7d9f3e2016-04-15 13:58:27 +053037#ifndef WMI_NON_TLV_SUPPORT
Govind Singh6b411b52016-03-06 19:55:02 +053038#include "ol_fw.h"
Govind Singhe7d9f3e2016-04-15 13:58:27 +053039#endif
Govind Singh6b411b52016-03-06 19:55:02 +053040#include "htc_api.h"
41#include "htc_api.h"
42#include "dbglog_host.h"
43#include "wmi.h"
44#include "wmi_unified_priv.h"
Govind Singh5eb51532016-03-09 11:34:12 +053045#include "wmi_unified_param.h"
Govind Singh6b411b52016-03-06 19:55:02 +053046
47#define WMI_MIN_HEAD_ROOM 64
48
49#ifdef WMI_INTERFACE_EVENT_LOGGING
50/* WMI commands */
51uint32_t g_wmi_command_buf_idx = 0;
52struct wmi_command_debug wmi_command_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
53
54/* WMI commands TX completed */
55uint32_t g_wmi_command_tx_cmp_buf_idx = 0;
56struct wmi_command_debug
57 wmi_command_tx_cmp_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
58
59/* WMI events when processed */
60uint32_t g_wmi_event_buf_idx = 0;
61struct wmi_event_debug wmi_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
62
63/* WMI events when queued */
64uint32_t g_wmi_rx_event_buf_idx = 0;
65struct wmi_event_debug wmi_rx_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
66
67#define WMI_COMMAND_RECORD(a, b) { \
68 if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_command_buf_idx) \
69 g_wmi_command_buf_idx = 0; \
70 wmi_command_log_buffer[g_wmi_command_buf_idx].command = a; \
Govind Singhb53420c2016-03-09 14:32:57 +053071 qdf_mem_copy(wmi_command_log_buffer[g_wmi_command_buf_idx].data, b, 16); \
Govind Singh6b411b52016-03-06 19:55:02 +053072 wmi_command_log_buffer[g_wmi_command_buf_idx].time = \
Govind Singhb53420c2016-03-09 14:32:57 +053073 qdf_get_log_timestamp(); \
Govind Singh6b411b52016-03-06 19:55:02 +053074 g_wmi_command_buf_idx++; \
75}
76
77#define WMI_COMMAND_TX_CMP_RECORD(a, b) { \
78 if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_command_tx_cmp_buf_idx) \
79 g_wmi_command_tx_cmp_buf_idx = 0; \
80 wmi_command_tx_cmp_log_buffer[g_wmi_command_tx_cmp_buf_idx].command = a; \
Govind Singhb53420c2016-03-09 14:32:57 +053081 qdf_mem_copy(wmi_command_tx_cmp_log_buffer \
Govind Singh6b411b52016-03-06 19:55:02 +053082 [g_wmi_command_tx_cmp_buf_idx].data, b, 16); \
83 wmi_command_tx_cmp_log_buffer[g_wmi_command_tx_cmp_buf_idx].time = \
Govind Singhb53420c2016-03-09 14:32:57 +053084 qdf_get_log_timestamp(); \
Govind Singh6b411b52016-03-06 19:55:02 +053085 g_wmi_command_tx_cmp_buf_idx++; \
86}
87
88#define WMI_EVENT_RECORD(a, b) { \
89 if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_event_buf_idx) \
90 g_wmi_event_buf_idx = 0; \
91 wmi_event_log_buffer[g_wmi_event_buf_idx].event = a; \
Govind Singhb53420c2016-03-09 14:32:57 +053092 qdf_mem_copy(wmi_event_log_buffer[g_wmi_event_buf_idx].data, b, 16); \
Govind Singh6b411b52016-03-06 19:55:02 +053093 wmi_event_log_buffer[g_wmi_event_buf_idx].time = \
Govind Singhb53420c2016-03-09 14:32:57 +053094 qdf_get_log_timestamp(); \
Govind Singh6b411b52016-03-06 19:55:02 +053095 g_wmi_event_buf_idx++; \
96}
97
98#define WMI_RX_EVENT_RECORD(a, b) { \
99 if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_rx_event_buf_idx) \
100 g_wmi_rx_event_buf_idx = 0; \
101 wmi_rx_event_log_buffer[g_wmi_rx_event_buf_idx].event = a; \
Govind Singhb53420c2016-03-09 14:32:57 +0530102 qdf_mem_copy(wmi_rx_event_log_buffer[g_wmi_rx_event_buf_idx].data, b, 16); \
Govind Singh6b411b52016-03-06 19:55:02 +0530103 wmi_rx_event_log_buffer[g_wmi_rx_event_buf_idx].time = \
Govind Singhb53420c2016-03-09 14:32:57 +0530104 qdf_get_log_timestamp(); \
Govind Singh6b411b52016-03-06 19:55:02 +0530105 g_wmi_rx_event_buf_idx++; \
106}
107/* wmi_mgmt commands */
108#define WMI_MGMT_EVENT_DEBUG_MAX_ENTRY (256)
109
110uint32_t g_wmi_mgmt_command_buf_idx = 0;
111struct
112wmi_command_debug wmi_mgmt_command_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
113
114/* wmi_mgmt commands TX completed */
115uint32_t g_wmi_mgmt_command_tx_cmp_buf_idx = 0;
116struct wmi_command_debug
117wmi_mgmt_command_tx_cmp_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
118
119/* wmi_mgmt events when processed */
120uint32_t g_wmi_mgmt_event_buf_idx = 0;
121struct wmi_event_debug
122wmi_mgmt_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
123
124#define WMI_MGMT_COMMAND_RECORD(a, b) { \
125 if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= \
126 g_wmi_mgmt_command_buf_idx) \
127 g_wmi_mgmt_command_buf_idx = 0; \
128 wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].command = a; \
Govind Singhb53420c2016-03-09 14:32:57 +0530129 qdf_mem_copy( \
Govind Singh6b411b52016-03-06 19:55:02 +0530130 wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].data,\
131 b, 16); \
132 wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].time = \
Govind Singhb53420c2016-03-09 14:32:57 +0530133 qdf_get_log_timestamp(); \
Govind Singh6b411b52016-03-06 19:55:02 +0530134 g_wmi_mgmt_command_buf_idx++; \
135}
136
137#define WMI_MGMT_COMMAND_TX_CMP_RECORD(a, b) { \
138 if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= \
139 g_wmi_mgmt_command_tx_cmp_buf_idx) \
140 g_wmi_mgmt_command_tx_cmp_buf_idx = 0; \
141 wmi_mgmt_command_tx_cmp_log_buffer[g_wmi_mgmt_command_tx_cmp_buf_idx].\
142 command = a; \
Govind Singhb53420c2016-03-09 14:32:57 +0530143 qdf_mem_copy(wmi_mgmt_command_tx_cmp_log_buffer \
Govind Singh6b411b52016-03-06 19:55:02 +0530144 [g_wmi_mgmt_command_tx_cmp_buf_idx].data, b, 16); \
145 wmi_mgmt_command_tx_cmp_log_buffer[g_wmi_mgmt_command_tx_cmp_buf_idx].\
146 time =\
Govind Singhb53420c2016-03-09 14:32:57 +0530147 qdf_get_log_timestamp(); \
Govind Singh6b411b52016-03-06 19:55:02 +0530148 g_wmi_mgmt_command_tx_cmp_buf_idx++; \
149}
150
151#define WMI_MGMT_EVENT_RECORD(a, b) { \
152 if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= g_wmi_mgmt_event_buf_idx) \
153 g_wmi_mgmt_event_buf_idx = 0; \
154 wmi_mgmt_event_log_buffer[g_wmi_mgmt_event_buf_idx].event = a; \
Govind Singhb53420c2016-03-09 14:32:57 +0530155 qdf_mem_copy(wmi_mgmt_event_log_buffer[g_wmi_mgmt_event_buf_idx].data,\
Govind Singh6b411b52016-03-06 19:55:02 +0530156 b, 16); \
157 wmi_mgmt_event_log_buffer[g_wmi_mgmt_event_buf_idx].time = \
Govind Singhb53420c2016-03-09 14:32:57 +0530158 qdf_get_log_timestamp(); \
Govind Singh6b411b52016-03-06 19:55:02 +0530159 g_wmi_mgmt_event_buf_idx++; \
160}
161
162#endif /*WMI_INTERFACE_EVENT_LOGGING */
163
Govind Singh6b411b52016-03-06 19:55:02 +0530164int wmi_get_host_credits(wmi_unified_t wmi_handle);
165/* WMI buffer APIs */
166
167#ifdef MEMORY_DEBUG
168wmi_buf_t
169wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len, uint8_t *file_name,
170 uint32_t line_num)
171{
172 wmi_buf_t wmi_buf;
173
174 if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) {
Govind Singhb53420c2016-03-09 14:32:57 +0530175 QDF_ASSERT(0);
Govind Singh6b411b52016-03-06 19:55:02 +0530176 return NULL;
177 }
178
Govind Singhb53420c2016-03-09 14:32:57 +0530179 wmi_buf = qdf_nbuf_alloc_debug(NULL,
Govind Singh6b411b52016-03-06 19:55:02 +0530180 roundup(len + WMI_MIN_HEAD_ROOM, 4),
181 WMI_MIN_HEAD_ROOM, 4, false, file_name,
182 line_num);
183
184 if (!wmi_buf)
185 return NULL;
186
187 /* Clear the wmi buffer */
Govind Singhb53420c2016-03-09 14:32:57 +0530188 OS_MEMZERO(qdf_nbuf_data(wmi_buf), len);
Govind Singh6b411b52016-03-06 19:55:02 +0530189
190 /*
191 * Set the length of the buffer to match the allocation size.
192 */
Govind Singhb53420c2016-03-09 14:32:57 +0530193 qdf_nbuf_set_pktlen(wmi_buf, len);
Govind Singh6b411b52016-03-06 19:55:02 +0530194
195 return wmi_buf;
196}
197
198void wmi_buf_free(wmi_buf_t net_buf)
199{
Govind Singhb53420c2016-03-09 14:32:57 +0530200 qdf_nbuf_free(net_buf);
Govind Singh6b411b52016-03-06 19:55:02 +0530201}
202#else
203wmi_buf_t wmi_buf_alloc(wmi_unified_t wmi_handle, uint16_t len)
204{
205 wmi_buf_t wmi_buf;
206
207 if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) {
Govind Singhb53420c2016-03-09 14:32:57 +0530208 QDF_ASSERT(0);
Govind Singh6b411b52016-03-06 19:55:02 +0530209 return NULL;
210 }
211
Govind Singhb53420c2016-03-09 14:32:57 +0530212 wmi_buf = qdf_nbuf_alloc(NULL, roundup(len + WMI_MIN_HEAD_ROOM, 4),
Govind Singh6b411b52016-03-06 19:55:02 +0530213 WMI_MIN_HEAD_ROOM, 4, false);
214 if (!wmi_buf)
215 return NULL;
216
217 /* Clear the wmi buffer */
Govind Singhb53420c2016-03-09 14:32:57 +0530218 OS_MEMZERO(qdf_nbuf_data(wmi_buf), len);
Govind Singh6b411b52016-03-06 19:55:02 +0530219
220 /*
221 * Set the length of the buffer to match the allocation size.
222 */
Govind Singhb53420c2016-03-09 14:32:57 +0530223 qdf_nbuf_set_pktlen(wmi_buf, len);
Govind Singh6b411b52016-03-06 19:55:02 +0530224 return wmi_buf;
225}
226
227void wmi_buf_free(wmi_buf_t net_buf)
228{
Govind Singhb53420c2016-03-09 14:32:57 +0530229 qdf_nbuf_free(net_buf);
Govind Singh6b411b52016-03-06 19:55:02 +0530230}
231#endif
232
233/**
234 * wmi_get_max_msg_len() - get maximum WMI message length
235 * @wmi_handle: WMI handle.
236 *
237 * This function returns the maximum WMI message length
238 *
239 * Return: maximum WMI message length
240 */
241uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle)
242{
243 return wmi_handle->max_msg_len - WMI_MIN_HEAD_ROOM;
244}
245
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530246#ifndef WMI_NON_TLV_SUPPORT
Govind Singh6b411b52016-03-06 19:55:02 +0530247static uint8_t *get_wmi_cmd_string(WMI_CMD_ID wmi_command)
248{
249 switch (wmi_command) {
250 /* initialize the wlan sub system */
251 CASE_RETURN_STRING(WMI_INIT_CMDID);
252
253 /* Scan specific commands */
254
255 /* start scan request to FW */
256 CASE_RETURN_STRING(WMI_START_SCAN_CMDID);
257 /* stop scan request to FW */
258 CASE_RETURN_STRING(WMI_STOP_SCAN_CMDID);
259 /* full list of channels as defined by the regulatory
260 * that will be used by scanner */
261 CASE_RETURN_STRING(WMI_SCAN_CHAN_LIST_CMDID);
262 /* overwrite default priority table in scan scheduler */
263 CASE_RETURN_STRING(WMI_SCAN_SCH_PRIO_TBL_CMDID);
264 /* This command to adjust the priority and min.max_rest_time
265 * of an on ongoing scan request.
266 */
267 CASE_RETURN_STRING(WMI_SCAN_UPDATE_REQUEST_CMDID);
268
269 /* PDEV(physical device) specific commands */
270 /* set regulatorty ctl id used by FW to determine the exact
271 * ctl power limits */
272 CASE_RETURN_STRING(WMI_PDEV_SET_REGDOMAIN_CMDID);
273 /* set channel. mainly used for supporting monitor mode */
274 CASE_RETURN_STRING(WMI_PDEV_SET_CHANNEL_CMDID);
275 /* set pdev specific parameters */
276 CASE_RETURN_STRING(WMI_PDEV_SET_PARAM_CMDID);
277 /* enable packet log */
278 CASE_RETURN_STRING(WMI_PDEV_PKTLOG_ENABLE_CMDID);
279 /* disable packet log*/
280 CASE_RETURN_STRING(WMI_PDEV_PKTLOG_DISABLE_CMDID);
281 /* set wmm parameters */
282 CASE_RETURN_STRING(WMI_PDEV_SET_WMM_PARAMS_CMDID);
283 /* set HT cap ie that needs to be carried probe requests
284 * HT/VHT channels */
285 CASE_RETURN_STRING(WMI_PDEV_SET_HT_CAP_IE_CMDID);
286 /* set VHT cap ie that needs to be carried on probe
287 * requests on VHT channels */
288 CASE_RETURN_STRING(WMI_PDEV_SET_VHT_CAP_IE_CMDID);
289
290 /* Command to send the DSCP-to-TID map to the target */
291 CASE_RETURN_STRING(WMI_PDEV_SET_DSCP_TID_MAP_CMDID);
292 /* set quiet ie parameters. primarily used in AP mode */
293 CASE_RETURN_STRING(WMI_PDEV_SET_QUIET_MODE_CMDID);
294 /* Enable/Disable Green AP Power Save */
295 CASE_RETURN_STRING(WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID);
296 /* get TPC config for the current operating channel */
297 CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CONFIG_CMDID);
298
299 /* set the base MAC address for the physical device before
300 * a VDEV is created. For firmware that does not support
301 * this feature and this command, the pdev MAC address will
302 * not be changed. */
303 CASE_RETURN_STRING(WMI_PDEV_SET_BASE_MACADDR_CMDID);
304
305 /* eeprom content dump , the same to bdboard data */
306 CASE_RETURN_STRING(WMI_PDEV_DUMP_CMDID);
307
308 /* VDEV(virtual device) specific commands */
309 /* vdev create */
310 CASE_RETURN_STRING(WMI_VDEV_CREATE_CMDID);
311 /* vdev delete */
312 CASE_RETURN_STRING(WMI_VDEV_DELETE_CMDID);
313 /* vdev start request */
314 CASE_RETURN_STRING(WMI_VDEV_START_REQUEST_CMDID);
315 /* vdev restart request (RX only, NO TX, used for CAC period)*/
316 CASE_RETURN_STRING(WMI_VDEV_RESTART_REQUEST_CMDID);
317 /* vdev up request */
318 CASE_RETURN_STRING(WMI_VDEV_UP_CMDID);
319 /* vdev stop request */
320 CASE_RETURN_STRING(WMI_VDEV_STOP_CMDID);
321 /* vdev down request */
322 CASE_RETURN_STRING(WMI_VDEV_DOWN_CMDID);
323 /* set a vdev param */
324 CASE_RETURN_STRING(WMI_VDEV_SET_PARAM_CMDID);
325 /* set a key (used for setting per peer unicast
326 * and per vdev multicast) */
327 CASE_RETURN_STRING(WMI_VDEV_INSTALL_KEY_CMDID);
328
329 /* wnm sleep mode command */
330 CASE_RETURN_STRING(WMI_VDEV_WNM_SLEEPMODE_CMDID);
331 CASE_RETURN_STRING(WMI_VDEV_WMM_ADDTS_CMDID);
332 CASE_RETURN_STRING(WMI_VDEV_WMM_DELTS_CMDID);
333 CASE_RETURN_STRING(WMI_VDEV_SET_WMM_PARAMS_CMDID);
334 CASE_RETURN_STRING(WMI_VDEV_SET_GTX_PARAMS_CMDID);
335 CASE_RETURN_STRING(WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID);
336
337 CASE_RETURN_STRING(WMI_VDEV_PLMREQ_START_CMDID);
338 CASE_RETURN_STRING(WMI_VDEV_PLMREQ_STOP_CMDID);
339 CASE_RETURN_STRING(WMI_VDEV_TSF_TSTAMP_ACTION_CMDID);
340 CASE_RETURN_STRING(WMI_VDEV_SET_IE_CMDID);
341
342 /* peer specific commands */
343
344 /** create a peer */
345 CASE_RETURN_STRING(WMI_PEER_CREATE_CMDID);
346 /** delete a peer */
347 CASE_RETURN_STRING(WMI_PEER_DELETE_CMDID);
348 /** flush specific tid queues of a peer */
349 CASE_RETURN_STRING(WMI_PEER_FLUSH_TIDS_CMDID);
350 /** set a parameter of a peer */
351 CASE_RETURN_STRING(WMI_PEER_SET_PARAM_CMDID);
352 /* set peer to associated state. will cary all parameters
353 * determined during assocication time */
354 CASE_RETURN_STRING(WMI_PEER_ASSOC_CMDID);
355 /* add a wds (4 address ) entry. used only for testing
356 * WDS feature on AP products */
357 CASE_RETURN_STRING(WMI_PEER_ADD_WDS_ENTRY_CMDID);
358 /* remove wds (4 address ) entry. used only for testing WDS
359 * feature on AP products */
360 CASE_RETURN_STRING(WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
361 /* set up mcast info for multicast to unicast conversion */
362 CASE_RETURN_STRING(WMI_PEER_MCAST_GROUP_CMDID);
363 /* request peer info from FW to get PEER_INFO_EVENTID */
364 CASE_RETURN_STRING(WMI_PEER_INFO_REQ_CMDID);
365
366 /* beacon/management specific commands */
367
368 /* transmit beacon by reference. used for transmitting beacon
369 * on low latency interface like pcie */
370 CASE_RETURN_STRING(WMI_BCN_TX_CMDID);
371 /* transmit beacon by value */
372 CASE_RETURN_STRING(WMI_PDEV_SEND_BCN_CMDID);
373 /* set the beacon template. used in beacon offload mode to setup
374 * the common beacon template with the FW to be used by FW to
375 * generate beacons */
376 CASE_RETURN_STRING(WMI_BCN_TMPL_CMDID);
377 /* set beacon filter with FW */
378 CASE_RETURN_STRING(WMI_BCN_FILTER_RX_CMDID);
379 /* enable/disable filtering of probe requests in the firmware */
380 CASE_RETURN_STRING(WMI_PRB_REQ_FILTER_RX_CMDID);
381 /* transmit management frame by value. will be deprecated */
382 CASE_RETURN_STRING(WMI_MGMT_TX_CMDID);
383 /* set the probe response template. used in beacon offload mode
384 * to setup the common probe response template with the FW to
385 * be used by FW to generate probe responses */
386 CASE_RETURN_STRING(WMI_PRB_TMPL_CMDID);
387
388 /* commands to directly control ba negotiation directly from
389 * host. only used in test mode */
390
391 /* turn off FW Auto addba mode and let host control addba */
392 CASE_RETURN_STRING(WMI_ADDBA_CLEAR_RESP_CMDID);
393 /* send add ba request */
394 CASE_RETURN_STRING(WMI_ADDBA_SEND_CMDID);
395 CASE_RETURN_STRING(WMI_ADDBA_STATUS_CMDID);
396 /* send del ba */
397 CASE_RETURN_STRING(WMI_DELBA_SEND_CMDID);
398 /* set add ba response will be used by FW to generate
399 * addba response*/
400 CASE_RETURN_STRING(WMI_ADDBA_SET_RESP_CMDID);
401 /* send single VHT MPDU with AMSDU */
402 CASE_RETURN_STRING(WMI_SEND_SINGLEAMSDU_CMDID);
403
404 /* Station power save specific config */
405 /* enable/disable station powersave */
406 CASE_RETURN_STRING(WMI_STA_POWERSAVE_MODE_CMDID);
407 /* set station power save specific parameter */
408 CASE_RETURN_STRING(WMI_STA_POWERSAVE_PARAM_CMDID);
409 /* set station mimo powersave mode */
410 CASE_RETURN_STRING(WMI_STA_MIMO_PS_MODE_CMDID);
411
412 /* DFS-specific commands */
413 /* enable DFS (radar detection)*/
414 CASE_RETURN_STRING(WMI_PDEV_DFS_ENABLE_CMDID);
415 /* disable DFS (radar detection)*/
416 CASE_RETURN_STRING(WMI_PDEV_DFS_DISABLE_CMDID);
417 /* enable DFS phyerr/parse filter offload */
418 CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_ENA_CMDID);
419 /* enable DFS phyerr/parse filter offload */
420 CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_DIS_CMDID);
421
422 /* Roaming specific commands */
423 /* set roam scan mode */
424 CASE_RETURN_STRING(WMI_ROAM_SCAN_MODE);
425 /* set roam scan rssi threshold below which roam
426 * scan is enabled */
427 CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_THRESHOLD);
428 /* set roam scan period for periodic roam scan mode */
429 CASE_RETURN_STRING(WMI_ROAM_SCAN_PERIOD);
430 /* set roam scan trigger rssi change threshold */
431 CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
432 /* set roam AP profile */
433 CASE_RETURN_STRING(WMI_ROAM_AP_PROFILE);
434 /* set channel list for roam scans */
435 CASE_RETURN_STRING(WMI_ROAM_CHAN_LIST);
436 /* offload scan specific commands */
437 /* set offload scan AP profile */
438 CASE_RETURN_STRING(WMI_OFL_SCAN_ADD_AP_PROFILE);
439 /* remove offload scan AP profile */
440 CASE_RETURN_STRING(WMI_OFL_SCAN_REMOVE_AP_PROFILE);
441 /* set offload scan period */
442 CASE_RETURN_STRING(WMI_OFL_SCAN_PERIOD);
443
444 /* P2P specific commands */
445 /* set P2P device info. FW will used by FW to create P2P IE
446 * to be carried in probe response generated during p2p listen
447 * and for p2p discoverability */
448 CASE_RETURN_STRING(WMI_P2P_DEV_SET_DEVICE_INFO);
449 /* enable/disable p2p discoverability on STA/AP VDEVs */
450 CASE_RETURN_STRING(WMI_P2P_DEV_SET_DISCOVERABILITY);
451 /* set p2p ie to be carried in beacons generated by FW for GO */
452 CASE_RETURN_STRING(WMI_P2P_GO_SET_BEACON_IE);
453 /* set p2p ie to be carried in probe response frames generated
454 * by FW for GO */
455 CASE_RETURN_STRING(WMI_P2P_GO_SET_PROBE_RESP_IE);
456 /* set the vendor specific p2p ie data.
457 * FW will use this to parse the P2P NoA
458 * attribute in the beacons/probe responses received.
459 */
460 CASE_RETURN_STRING(WMI_P2P_SET_VENDOR_IE_DATA_CMDID);
461 /* set the configure of p2p find offload */
462 CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_CONFIG_CMDID);
463 /* set the vendor specific p2p ie data for p2p find offload */
464 CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_APPIE_CMDID);
465 /* set the BSSID/device name pattern of p2p find offload */
466 CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_PATTERN_CMDID);
467 /* set OppPS related parameters **/
468 CASE_RETURN_STRING(WMI_P2P_SET_OPPPS_PARAM_CMDID);
469
470 /* AP power save specific config
471 * set AP power save specific param */
472 CASE_RETURN_STRING(WMI_AP_PS_PEER_PARAM_CMDID);
473 /* set AP UAPSD coex pecific param */
474 CASE_RETURN_STRING(WMI_AP_PS_PEER_UAPSD_COEX_CMDID);
475
476 /* Rate-control specific commands */
477 CASE_RETURN_STRING(WMI_PEER_RATE_RETRY_SCHED_CMDID);
478
479 /* WLAN Profiling commands. */
480 CASE_RETURN_STRING(WMI_WLAN_PROFILE_TRIGGER_CMDID);
481 CASE_RETURN_STRING(WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
482 CASE_RETURN_STRING(WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
483 CASE_RETURN_STRING(WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
484 CASE_RETURN_STRING(WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID);
485
486 /* Suspend resume command Ids */
487 CASE_RETURN_STRING(WMI_PDEV_SUSPEND_CMDID);
488 CASE_RETURN_STRING(WMI_PDEV_RESUME_CMDID);
489
490 /* Beacon filter commands */
491 /* add a beacon filter */
492 CASE_RETURN_STRING(WMI_ADD_BCN_FILTER_CMDID);
493 /* remove a beacon filter */
494 CASE_RETURN_STRING(WMI_RMV_BCN_FILTER_CMDID);
495
496 /* WOW Specific WMI commands */
497 /* add pattern for awake */
498 CASE_RETURN_STRING(WMI_WOW_ADD_WAKE_PATTERN_CMDID);
499 /* deleta a wake pattern */
500 CASE_RETURN_STRING(WMI_WOW_DEL_WAKE_PATTERN_CMDID);
501 /* enable/deisable wake event */
502 CASE_RETURN_STRING(WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
503 /* enable WOW */
504 CASE_RETURN_STRING(WMI_WOW_ENABLE_CMDID);
505 /* host woke up from sleep event to FW. Generated in response
506 * to WOW Hardware event */
507 CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
508
509 /* RTT measurement related cmd */
510 /* reques to make an RTT measurement */
511 CASE_RETURN_STRING(WMI_RTT_MEASREQ_CMDID);
512 /* reques to report a tsf measurement */
513 CASE_RETURN_STRING(WMI_RTT_TSF_CMDID);
514
515 /* spectral scan command */
516 /* configure spectral scan */
517 CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
518 /* enable/disable spectral scan and trigger */
519 CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
520
521 /* F/W stats */
522 /* one time request for stats */
523 CASE_RETURN_STRING(WMI_REQUEST_STATS_CMDID);
524 /* Push MCC Adaptive Scheduler Stats to Firmware */
525 CASE_RETURN_STRING(WMI_MCC_SCHED_TRAFFIC_STATS_CMDID);
526
527 /* ARP OFFLOAD REQUEST*/
528 CASE_RETURN_STRING(WMI_SET_ARP_NS_OFFLOAD_CMDID);
529
530 /* Proactive ARP Response Add Pattern Command*/
531 CASE_RETURN_STRING(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID);
532
533 /* Proactive ARP Response Del Pattern Command*/
534 CASE_RETURN_STRING(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID);
535
536 /* NS offload confid*/
537 CASE_RETURN_STRING(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
538
539 /* GTK offload Specific WMI commands */
540 CASE_RETURN_STRING(WMI_GTK_OFFLOAD_CMDID);
541
542 /* CSA offload Specific WMI commands */
543 /* csa offload enable */
544 CASE_RETURN_STRING(WMI_CSA_OFFLOAD_ENABLE_CMDID);
545 /* chan switch command */
546 CASE_RETURN_STRING(WMI_CSA_OFFLOAD_CHANSWITCH_CMDID);
547
548 /* Chatter commands */
549 /* Change chatter mode of operation */
550 CASE_RETURN_STRING(WMI_CHATTER_SET_MODE_CMDID);
551 /* chatter add coalescing filter command */
552 CASE_RETURN_STRING(WMI_CHATTER_ADD_COALESCING_FILTER_CMDID);
553 /* chatter delete coalescing filter command */
554 CASE_RETURN_STRING(WMI_CHATTER_DELETE_COALESCING_FILTER_CMDID);
555 /* chatter coalecing query command */
556 CASE_RETURN_STRING(WMI_CHATTER_COALESCING_QUERY_CMDID);
557
558 /* addba specific commands */
559 /* start the aggregation on this TID */
560 CASE_RETURN_STRING(WMI_PEER_TID_ADDBA_CMDID);
561 /* stop the aggregation on this TID */
562 CASE_RETURN_STRING(WMI_PEER_TID_DELBA_CMDID);
563
564 /* set station mimo powersave method */
565 CASE_RETURN_STRING(WMI_STA_DTIM_PS_METHOD_CMDID);
566 /* Configure the Station UAPSD AC Auto Trigger Parameters */
567 CASE_RETURN_STRING(WMI_STA_UAPSD_AUTO_TRIG_CMDID);
568 /* Configure the Keep Alive Parameters */
569 CASE_RETURN_STRING(WMI_STA_KEEPALIVE_CMDID);
570
571 /* Request ssn from target for a sta/tid pair */
572 CASE_RETURN_STRING(WMI_BA_REQ_SSN_CMDID);
573 /* misc command group */
574 /* echo command mainly used for testing */
575 CASE_RETURN_STRING(WMI_ECHO_CMDID);
576
577 /* !!IMPORTANT!!
578 * If you need to add a new WMI command to the CASE_RETURN_STRING(WMI_GRP_MISC sub-group,
579 * please make sure you add it BEHIND CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID);
580 * as we MUST have a fixed value here to maintain compatibility between
581 * UTF and the ART2 driver
582 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530583 /* UTF WMI commands */
Govind Singh6b411b52016-03-06 19:55:02 +0530584 CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID);
585
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530586 /* set debug log config */
Govind Singh6b411b52016-03-06 19:55:02 +0530587 CASE_RETURN_STRING(WMI_DBGLOG_CFG_CMDID);
588 /* QVIT specific command id */
589 CASE_RETURN_STRING(WMI_PDEV_QVIT_CMDID);
590 /* Factory Testing Mode request command
591 * used for integrated chipsets */
592 CASE_RETURN_STRING(WMI_PDEV_FTM_INTG_CMDID);
593 /* set and get keepalive parameters command */
594 CASE_RETURN_STRING(WMI_VDEV_SET_KEEPALIVE_CMDID);
595 CASE_RETURN_STRING(WMI_VDEV_GET_KEEPALIVE_CMDID);
596 /* For fw recovery test command */
597 CASE_RETURN_STRING(WMI_FORCE_FW_HANG_CMDID);
598 /* Set Mcast/Bdcast filter */
599 CASE_RETURN_STRING(WMI_SET_MCASTBCAST_FILTER_CMDID);
600 /* set thermal management params */
601 CASE_RETURN_STRING(WMI_THERMAL_MGMT_CMDID);
602 CASE_RETURN_STRING(WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
603 CASE_RETURN_STRING(WMI_LRO_CONFIG_CMDID);
604 CASE_RETURN_STRING(WMI_TRANSFER_DATA_TO_FLASH_CMDID);
Sreelakshmi Konamki57a2c042016-04-14 18:04:17 +0530605 CASE_RETURN_STRING(WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
Anurag Chouhan25689392016-04-18 17:10:41 +0530606 CASE_RETURN_STRING(WMI_VDEV_WISA_CMDID);
Anurag Chouhan7dd65542016-04-18 17:27:12 +0530607 CASE_RETURN_STRING(WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
Anurag Chouhanb4a65bc2016-04-21 16:26:34 +0530608 CASE_RETURN_STRING(WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Govind Singh6b411b52016-03-06 19:55:02 +0530609 CASE_RETURN_STRING(WMI_MAWC_SENSOR_REPORT_IND_CMDID);
610 CASE_RETURN_STRING(WMI_ROAM_CONFIGURE_MAWC_CMDID);
611 CASE_RETURN_STRING(WMI_NLO_CONFIGURE_MAWC_CMDID);
612 CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_MAWC_CMDID);
613 /* GPIO Configuration */
614 CASE_RETURN_STRING(WMI_GPIO_CONFIG_CMDID);
615 CASE_RETURN_STRING(WMI_GPIO_OUTPUT_CMDID);
616
617 /* Txbf configuration command */
618 CASE_RETURN_STRING(WMI_TXBF_CMDID);
619
620 /* FWTEST Commands */
621 CASE_RETURN_STRING(WMI_FWTEST_VDEV_MCC_SET_TBTT_MODE_CMDID);
622 /* set NoA descs */
623 CASE_RETURN_STRING(WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
624
625 /* TDLS Configuration */
626 /* enable/disable TDLS */
627 CASE_RETURN_STRING(WMI_TDLS_SET_STATE_CMDID);
628 /* set tdls peer state */
629 CASE_RETURN_STRING(WMI_TDLS_PEER_UPDATE_CMDID);
630
631 /* Resmgr Configuration */
632 /* Adaptive OCS is enabled by default in the FW.
633 * This command is used to disable FW based adaptive OCS.
634 */
635 CASE_RETURN_STRING
636 (WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
637 /* set the requested channel time quota for the home channels */
638 CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
639 /* set the requested latency for the home channels */
640 CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
641
642 /* STA SMPS Configuration */
643 /* force SMPS mode */
644 CASE_RETURN_STRING(WMI_STA_SMPS_FORCE_MODE_CMDID);
645 /* set SMPS parameters */
646 CASE_RETURN_STRING(WMI_STA_SMPS_PARAM_CMDID);
647
648 /* Wlan HB commands */
649 /* enalbe/disable wlan HB */
650 CASE_RETURN_STRING(WMI_HB_SET_ENABLE_CMDID);
651 /* set tcp parameters for wlan HB */
652 CASE_RETURN_STRING(WMI_HB_SET_TCP_PARAMS_CMDID);
653 /* set tcp pkt filter for wlan HB */
654 CASE_RETURN_STRING(WMI_HB_SET_TCP_PKT_FILTER_CMDID);
655 /* set udp parameters for wlan HB */
656 CASE_RETURN_STRING(WMI_HB_SET_UDP_PARAMS_CMDID);
657 /* set udp pkt filter for wlan HB */
658 CASE_RETURN_STRING(WMI_HB_SET_UDP_PKT_FILTER_CMDID);
659
660 /* Wlan RMC commands*/
661 /* enable/disable RMC */
662 CASE_RETURN_STRING(WMI_RMC_SET_MODE_CMDID);
663 /* configure action frame period */
664 CASE_RETURN_STRING(WMI_RMC_SET_ACTION_PERIOD_CMDID);
665 /* For debug/future enhancement purposes only,
666 * configures/finetunes RMC algorithms */
667 CASE_RETURN_STRING(WMI_RMC_CONFIG_CMDID);
668
669 /* WLAN MHF offload commands */
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530670 /* enable/disable MHF offload */
Govind Singh6b411b52016-03-06 19:55:02 +0530671 CASE_RETURN_STRING(WMI_MHF_OFFLOAD_SET_MODE_CMDID);
672 /* Plumb routing table for MHF offload */
673 CASE_RETURN_STRING(WMI_MHF_OFFLOAD_PLUMB_ROUTING_TBL_CMDID);
674
675 /* location scan commands */
676 /* start batch scan */
677 CASE_RETURN_STRING(WMI_BATCH_SCAN_ENABLE_CMDID);
678 /* stop batch scan */
679 CASE_RETURN_STRING(WMI_BATCH_SCAN_DISABLE_CMDID);
680 /* get batch scan result */
681 CASE_RETURN_STRING(WMI_BATCH_SCAN_TRIGGER_RESULT_CMDID);
682 /* OEM related cmd */
683 CASE_RETURN_STRING(WMI_OEM_REQ_CMDID);
684 CASE_RETURN_STRING(WMI_OEM_REQUEST_CMDID);
685 /* NAN request cmd */
686 CASE_RETURN_STRING(WMI_NAN_CMDID);
687 /* Modem power state cmd */
688 CASE_RETURN_STRING(WMI_MODEM_POWER_STATE_CMDID);
689 CASE_RETURN_STRING(WMI_REQUEST_STATS_EXT_CMDID);
690 CASE_RETURN_STRING(WMI_OBSS_SCAN_ENABLE_CMDID);
691 CASE_RETURN_STRING(WMI_OBSS_SCAN_DISABLE_CMDID);
692 CASE_RETURN_STRING(WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID);
693 CASE_RETURN_STRING(WMI_ROAM_SCAN_CMD);
694 CASE_RETURN_STRING(WMI_PDEV_SET_LED_CONFIG_CMDID);
695 CASE_RETURN_STRING(WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
696 CASE_RETURN_STRING(WMI_CHAN_AVOID_UPDATE_CMDID);
Sreelakshmi Konamki084f3d32016-04-14 17:46:26 +0530697 CASE_RETURN_STRING(WMI_COEX_CONFIG_CMDID);
Govind Singh6b411b52016-03-06 19:55:02 +0530698 CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_KEEPALIVE_CMDID);
699 CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_KEEPALIVE_CMDID);
700 CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_WAKE_PATTERN_CMDID);
701 CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_WAKE_PATTERN_CMDID);
702 CASE_RETURN_STRING(WMI_REQUEST_LINK_STATS_CMDID);
703 CASE_RETURN_STRING(WMI_START_LINK_STATS_CMDID);
704 CASE_RETURN_STRING(WMI_CLEAR_LINK_STATS_CMDID);
705 CASE_RETURN_STRING(WMI_GET_FW_MEM_DUMP_CMDID);
706 CASE_RETURN_STRING(WMI_LPI_MGMT_SNOOPING_CONFIG_CMDID);
707 CASE_RETURN_STRING(WMI_LPI_START_SCAN_CMDID);
708 CASE_RETURN_STRING(WMI_LPI_STOP_SCAN_CMDID);
709 CASE_RETURN_STRING(WMI_EXTSCAN_START_CMDID);
710 CASE_RETURN_STRING(WMI_EXTSCAN_STOP_CMDID);
711 CASE_RETURN_STRING
712 (WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID);
713 CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID);
714 CASE_RETURN_STRING(WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID);
715 CASE_RETURN_STRING(WMI_EXTSCAN_GET_WLAN_CHANGE_RESULTS_CMDID);
716 CASE_RETURN_STRING(WMI_EXTSCAN_SET_CAPABILITIES_CMDID);
717 CASE_RETURN_STRING(WMI_EXTSCAN_GET_CAPABILITIES_CMDID);
718 CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID);
719 CASE_RETURN_STRING(WMI_ROAM_SYNCH_COMPLETE);
720 CASE_RETURN_STRING(WMI_D0_WOW_ENABLE_DISABLE_CMDID);
721 CASE_RETURN_STRING(WMI_EXTWOW_ENABLE_CMDID);
722 CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
723 CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
724 CASE_RETURN_STRING(WMI_UNIT_TEST_CMDID);
725 CASE_RETURN_STRING(WMI_ROAM_SET_RIC_REQUEST_CMDID);
726 CASE_RETURN_STRING(WMI_PDEV_GET_TEMPERATURE_CMDID);
727 CASE_RETURN_STRING(WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
728 CASE_RETURN_STRING(WMI_TPC_CHAINMASK_CONFIG_CMDID);
729 CASE_RETURN_STRING(WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID);
730 CASE_RETURN_STRING(WMI_SCAN_PROB_REQ_OUI_CMDID);
731 CASE_RETURN_STRING(WMI_TDLS_SET_OFFCHAN_MODE_CMDID);
732 CASE_RETURN_STRING(WMI_PDEV_SET_LED_FLASHING_CMDID);
733 CASE_RETURN_STRING(WMI_MDNS_OFFLOAD_ENABLE_CMDID);
734 CASE_RETURN_STRING(WMI_MDNS_SET_FQDN_CMDID);
735 CASE_RETURN_STRING(WMI_MDNS_SET_RESPONSE_CMDID);
736 CASE_RETURN_STRING(WMI_MDNS_GET_STATS_CMDID);
737 CASE_RETURN_STRING(WMI_ROAM_INVOKE_CMDID);
738 CASE_RETURN_STRING(WMI_SET_ANTENNA_DIVERSITY_CMDID);
739 CASE_RETURN_STRING(WMI_SAP_OFL_ENABLE_CMDID);
740 CASE_RETURN_STRING(WMI_APFIND_CMDID);
741 CASE_RETURN_STRING(WMI_PASSPOINT_LIST_CONFIG_CMDID);
742 CASE_RETURN_STRING(WMI_OCB_SET_SCHED_CMDID);
743 CASE_RETURN_STRING(WMI_OCB_SET_CONFIG_CMDID);
744 CASE_RETURN_STRING(WMI_OCB_SET_UTC_TIME_CMDID);
745 CASE_RETURN_STRING(WMI_OCB_START_TIMING_ADVERT_CMDID);
746 CASE_RETURN_STRING(WMI_OCB_STOP_TIMING_ADVERT_CMDID);
747 CASE_RETURN_STRING(WMI_OCB_GET_TSF_TIMER_CMDID);
748 CASE_RETURN_STRING(WMI_DCC_GET_STATS_CMDID);
749 CASE_RETURN_STRING(WMI_DCC_CLEAR_STATS_CMDID);
750 CASE_RETURN_STRING(WMI_DCC_UPDATE_NDL_CMDID);
751 CASE_RETURN_STRING(WMI_ROAM_FILTER_CMDID);
752 CASE_RETURN_STRING(WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
753 CASE_RETURN_STRING(WMI_DEBUG_MESG_FLUSH_CMDID);
754 CASE_RETURN_STRING(WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
755 CASE_RETURN_STRING(WMI_SOC_SET_PCL_CMDID);
756 CASE_RETURN_STRING(WMI_SOC_SET_HW_MODE_CMDID);
757 CASE_RETURN_STRING(WMI_SOC_SET_DUAL_MAC_CONFIG_CMDID);
758 CASE_RETURN_STRING(WMI_WOW_ENABLE_ICMPV6_NA_FLT_CMDID);
759 CASE_RETURN_STRING(WMI_DIAG_EVENT_LOG_CONFIG_CMDID);
760 CASE_RETURN_STRING(WMI_PACKET_FILTER_CONFIG_CMDID);
761 CASE_RETURN_STRING(WMI_PACKET_FILTER_ENABLE_CMDID);
762 CASE_RETURN_STRING(WMI_SAP_SET_BLACKLIST_PARAM_CMDID);
763 CASE_RETURN_STRING(WMI_WOW_UDP_SVC_OFLD_CMDID);
764 CASE_RETURN_STRING(WMI_MGMT_TX_SEND_CMDID);
765 CASE_RETURN_STRING(WMI_SOC_SET_ANTENNA_MODE_CMDID);
766 CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID);
767 CASE_RETURN_STRING(WMI_AP_PS_EGAP_PARAM_CMDID);
768 CASE_RETURN_STRING(WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID);
769 CASE_RETURN_STRING(WMI_BPF_GET_CAPABILITY_CMDID);
770 CASE_RETURN_STRING(WMI_BPF_GET_VDEV_STATS_CMDID);
771 CASE_RETURN_STRING(WMI_BPF_SET_VDEV_INSTRUCTIONS_CMDID);
772 CASE_RETURN_STRING(WMI_BPF_DEL_VDEV_INSTRUCTIONS_CMDID);
Govind Singh8b1466e2016-03-16 16:27:50 +0530773 CASE_RETURN_STRING(WMI_NDI_GET_CAP_REQ_CMDID);
774 CASE_RETURN_STRING(WMI_NDP_INITIATOR_REQ_CMDID);
775 CASE_RETURN_STRING(WMI_NDP_RESPONDER_REQ_CMDID);
776 CASE_RETURN_STRING(WMI_NDP_END_REQ_CMDID);
777 CASE_RETURN_STRING(WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
778 CASE_RETURN_STRING(WMI_PEER_ADD_PROXY_STA_ENTRY_CMDID);
779 CASE_RETURN_STRING(WMI_PDEV_FIPS_CMDID);
780 CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_ENABLE_CMDID);
781 CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
782 CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID);
783 CASE_RETURN_STRING(WMI_PDEV_SET_CTL_TABLE_CMDID);
784 CASE_RETURN_STRING(WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID);
785 CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CMDID);
786 CASE_RETURN_STRING(WMI_MIB_STATS_ENABLE_CMDID);
787 CASE_RETURN_STRING(WMI_PDEV_GET_ANI_CCK_CONFIG_CMDID);
788 CASE_RETURN_STRING(WMI_PDEV_GET_ANI_OFDM_CONFIG_CMDID);
789 CASE_RETURN_STRING(WMI_VDEV_RATEMASK_CMDID);
790 CASE_RETURN_STRING(WMI_VDEV_ATF_REQUEST_CMDID);
791 CASE_RETURN_STRING(WMI_VDEV_SET_DSCP_TID_MAP_CMDID);
792 CASE_RETURN_STRING(WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID);
793 CASE_RETURN_STRING(WMI_VDEV_SET_QUIET_MODE_CMDID);
794 CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
795 CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
796 CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
797 CASE_RETURN_STRING(WMI_PEER_ATF_REQUEST_CMDID);
798 CASE_RETURN_STRING(WMI_FWTEST_CMDID);
799 CASE_RETURN_STRING(WMI_QBOOST_CFG_CMDID);
800 CASE_RETURN_STRING(WMI_PDEV_GET_NFCAL_POWER_CMDID);
801 CASE_RETURN_STRING(WMI_PDEV_SET_PCL_CMDID);
802 CASE_RETURN_STRING(WMI_PDEV_SET_HW_MODE_CMDID);
803 CASE_RETURN_STRING(WMI_PDEV_SET_MAC_CONFIG_CMDID);
804 CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_MODE_CMDID);
805 CASE_RETURN_STRING(WMI_ROAM_SET_MBO_PARAM_CMDID);
Naveen Rawat8cf610b2016-04-14 20:10:15 -0700806 CASE_RETURN_STRING(WMI_CHAN_AVOID_RPT_ALLOW_CMDID);
Sandeep Puligillacc28f4e2016-04-16 13:35:09 +0530807 CASE_RETURN_STRING(WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
Krishna Kumaar Natarajanc285c102016-04-16 14:09:58 +0530808 CASE_RETURN_STRING(WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID);
Krishna Kumaar Natarajan0d2a1bd2016-04-16 16:47:07 +0530809 CASE_RETURN_STRING(WMI_PDEV_WAL_POWER_DEBUG_CMDID);
Govind Singh6b411b52016-03-06 19:55:02 +0530810 }
811
812 return "Invalid WMI cmd";
813}
814
815#ifdef QCA_WIFI_3_0_EMU
816static inline void wma_log_cmd_id(WMI_CMD_ID cmd_id)
817{
Govind Singhb53420c2016-03-09 14:32:57 +0530818 WMI_LOGE("Send WMI command:%s command_id:%d",
Govind Singh6b411b52016-03-06 19:55:02 +0530819 get_wmi_cmd_string(cmd_id), cmd_id);
820}
821#else
822static inline void wma_log_cmd_id(WMI_CMD_ID cmd_id)
823{
Govind Singhb53420c2016-03-09 14:32:57 +0530824 WMI_LOGD("Send WMI command:%s command_id:%d",
Govind Singh6b411b52016-03-06 19:55:02 +0530825 get_wmi_cmd_string(cmd_id), cmd_id);
826}
827#endif
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530828#endif
Govind Singh6b411b52016-03-06 19:55:02 +0530829
830/**
Govind Singhd52faac2016-03-09 12:03:29 +0530831 * wmi_is_runtime_pm_cmd() - check if a cmd is from suspend resume sequence
Govind Singh6b411b52016-03-06 19:55:02 +0530832 * @cmd: command to check
833 *
834 * Return: true if the command is part of the suspend resume sequence.
835 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530836#ifndef WMI_NON_TLV_SUPPORT
Govind Singhd52faac2016-03-09 12:03:29 +0530837static bool wmi_is_runtime_pm_cmd(WMI_CMD_ID cmd_id)
Govind Singh6b411b52016-03-06 19:55:02 +0530838{
839 switch (cmd_id) {
840 case WMI_WOW_ENABLE_CMDID:
841 case WMI_PDEV_SUSPEND_CMDID:
842 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
843 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
844 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
845 case WMI_PDEV_RESUME_CMDID:
846 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
847 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
848 return true;
849
850 default:
851 return false;
852 }
853}
854
855/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530856 * wmi_is_pm_resume_cmd() - check if a cmd is part of the resume sequence
857 * @cmd_id: command to check
858 *
859 * Return: true if the command is part of the resume sequence.
860 */
861static bool wmi_is_pm_resume_cmd(WMI_CMD_ID cmd_id)
862{
863 switch (cmd_id) {
864 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
865 case WMI_PDEV_RESUME_CMDID:
866 return true;
867
868 default:
869 return false;
870 }
871}
872#else
873static bool wmi_is_runtime_pm_cmd(WMI_CMD_ID cmd_id)
874{
875 return false;
876}
877static bool wmi_is_pm_resume_cmd(WMI_CMD_ID cmd_id)
878{
879 return false;
880}
881#endif
882
883/**
Govind Singh6b411b52016-03-06 19:55:02 +0530884 * wmi_unified_cmd_send() - WMI command API
885 * @wmi_handle: handle to wmi
886 * @buf: wmi buf
887 * @len: wmi buffer length
888 * @cmd_id: wmi command id
889 *
890 * Return: 0 on success
891 */
Govind Singhc458f382016-02-04 18:42:30 +0530892int wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, uint32_t len,
Govind Singh6b411b52016-03-06 19:55:02 +0530893 WMI_CMD_ID cmd_id)
894{
895 HTC_PACKET *pkt;
896 A_STATUS status;
Govind Singhd52faac2016-03-09 12:03:29 +0530897 uint16_t htc_tag = 0;
Govind Singh6b411b52016-03-06 19:55:02 +0530898
899 if (wmi_get_runtime_pm_inprogress(wmi_handle)) {
900 if (wmi_is_runtime_pm_cmd(cmd_id))
901 htc_tag = HTC_TX_PACKET_TAG_AUTO_PM;
Govind Singhb53420c2016-03-09 14:32:57 +0530902 } else if (qdf_atomic_read(&wmi_handle->is_target_suspended) &&
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530903 (!wmi_is_pm_resume_cmd(cmd_id))) {
Govind Singhb53420c2016-03-09 14:32:57 +0530904 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530905 "%s: Target is suspended", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +0530906 QDF_ASSERT(0);
Govind Singh67922e82016-04-01 16:48:57 +0530907 return QDF_STATUS_E_BUSY;
Govind Singh6b411b52016-03-06 19:55:02 +0530908 }
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530909 if (wmi_handle->wmi_stopinprogress) {
910 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
911 "WMI stop in progress\n");
912 return -EINVAL;
913 }
Govind Singh6b411b52016-03-06 19:55:02 +0530914
915 /* Do sanity check on the TLV parameter structure */
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530916#ifndef WMI_NON_TLV_SUPPORT
917 if (wmi_handle->target_type == WMI_TLV_TARGET) {
Govind Singhb53420c2016-03-09 14:32:57 +0530918 void *buf_ptr = (void *)qdf_nbuf_data(buf);
Govind Singh6b411b52016-03-06 19:55:02 +0530919
920 if (wmitlv_check_command_tlv_params(NULL, buf_ptr, len, cmd_id)
921 != 0) {
Govind Singhb53420c2016-03-09 14:32:57 +0530922 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530923 "\nERROR: %s: Invalid WMI Param Buffer for Cmd:%d",
Govind Singh6b411b52016-03-06 19:55:02 +0530924 __func__, cmd_id);
Govind Singh67922e82016-04-01 16:48:57 +0530925 return QDF_STATUS_E_INVAL;
Govind Singh6b411b52016-03-06 19:55:02 +0530926 }
927 }
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530928#endif
Govind Singh6b411b52016-03-06 19:55:02 +0530929
Govind Singhb53420c2016-03-09 14:32:57 +0530930 if (qdf_nbuf_push_head(buf, sizeof(WMI_CMD_HDR)) == NULL) {
931 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530932 "%s, Failed to send cmd %x, no memory",
933 __func__, cmd_id);
Govind Singh67922e82016-04-01 16:48:57 +0530934 return QDF_STATUS_E_NOMEM;
Govind Singh6b411b52016-03-06 19:55:02 +0530935 }
936
Govind Singhb53420c2016-03-09 14:32:57 +0530937 WMI_SET_FIELD(qdf_nbuf_data(buf), WMI_CMD_HDR, COMMANDID, cmd_id);
Govind Singh6b411b52016-03-06 19:55:02 +0530938
Govind Singhb53420c2016-03-09 14:32:57 +0530939 qdf_atomic_inc(&wmi_handle->pending_cmds);
940 if (qdf_atomic_read(&wmi_handle->pending_cmds) >= WMI_MAX_CMDS) {
941 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530942 "\n%s: hostcredits = %d", __func__,
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530943 wmi_get_host_credits(wmi_handle));
Govind Singh6b411b52016-03-06 19:55:02 +0530944 htc_dump_counter_info(wmi_handle->htc_handle);
Govind Singhb53420c2016-03-09 14:32:57 +0530945 qdf_atomic_dec(&wmi_handle->pending_cmds);
946 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530947 "%s: MAX 1024 WMI Pending cmds reached.", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +0530948 QDF_BUG(0);
Govind Singh67922e82016-04-01 16:48:57 +0530949 return QDF_STATUS_E_BUSY;
Govind Singh6b411b52016-03-06 19:55:02 +0530950 }
951
Govind Singhb53420c2016-03-09 14:32:57 +0530952 pkt = qdf_mem_malloc(sizeof(*pkt));
Govind Singh6b411b52016-03-06 19:55:02 +0530953 if (!pkt) {
Govind Singhb53420c2016-03-09 14:32:57 +0530954 qdf_atomic_dec(&wmi_handle->pending_cmds);
955 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530956 "%s, Failed to alloc htc packet %x, no memory",
957 __func__, cmd_id);
Govind Singh67922e82016-04-01 16:48:57 +0530958 return QDF_STATUS_E_NOMEM;
Govind Singh6b411b52016-03-06 19:55:02 +0530959 }
960
961 SET_HTC_PACKET_INFO_TX(pkt,
962 NULL,
Govind Singhb53420c2016-03-09 14:32:57 +0530963 qdf_nbuf_data(buf), len + sizeof(WMI_CMD_HDR),
Govind Singh6b411b52016-03-06 19:55:02 +0530964 wmi_handle->wmi_endpoint_id, htc_tag);
965
966 SET_HTC_PACKET_NET_BUF_CONTEXT(pkt, buf);
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530967#ifndef WMI_NON_TLV_SUPPORT
Govind Singh6b411b52016-03-06 19:55:02 +0530968 wma_log_cmd_id(cmd_id);
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530969#endif
Govind Singh6b411b52016-03-06 19:55:02 +0530970
971#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +0530972 qdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +0530973 /*Record 16 bytes of WMI cmd data - exclude TLV and WMI headers */
974 if (cmd_id == WMI_MGMT_TX_SEND_CMDID) {
975 WMI_MGMT_COMMAND_RECORD(cmd_id,
Govind Singhb53420c2016-03-09 14:32:57 +0530976 ((uint32_t *)qdf_nbuf_data(buf) + 2));
Govind Singh6b411b52016-03-06 19:55:02 +0530977 } else {
Govind Singhb53420c2016-03-09 14:32:57 +0530978 WMI_COMMAND_RECORD(cmd_id, ((uint32_t *) qdf_nbuf_data(buf) +
Govind Singh6b411b52016-03-06 19:55:02 +0530979 2));
980 }
981
Govind Singhb53420c2016-03-09 14:32:57 +0530982 qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +0530983#endif
984
985 status = htc_send_pkt(wmi_handle->htc_handle, pkt);
986
987 if (A_OK != status) {
Govind Singhb53420c2016-03-09 14:32:57 +0530988 qdf_atomic_dec(&wmi_handle->pending_cmds);
989 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530990 "%s %d, htc_send_pkt failed", __func__, __LINE__);
Govind Singh6b411b52016-03-06 19:55:02 +0530991 }
992 if (status)
Govind Singhb53420c2016-03-09 14:32:57 +0530993 return QDF_STATUS_E_FAILURE;
Govind Singh6b411b52016-03-06 19:55:02 +0530994
Govind Singhb53420c2016-03-09 14:32:57 +0530995 return QDF_STATUS_SUCCESS;
Govind Singh6b411b52016-03-06 19:55:02 +0530996}
997
998/**
999 * wmi_unified_get_event_handler_ix() - gives event handler's index
1000 * @wmi_handle: handle to wmi
1001 * @event_id: wmi event id
1002 *
1003 * Return: event handler's index
1004 */
1005int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle,
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301006 uint32_t event_id)
Govind Singh6b411b52016-03-06 19:55:02 +05301007{
1008 uint32_t idx = 0;
1009 int32_t invalid_idx = -1;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301010
Govind Singh6b411b52016-03-06 19:55:02 +05301011 for (idx = 0; (idx < wmi_handle->max_event_idx &&
1012 idx < WMI_UNIFIED_MAX_EVENT); ++idx) {
1013 if (wmi_handle->event_id[idx] == event_id &&
1014 wmi_handle->event_handler[idx] != NULL) {
1015 return idx;
1016 }
1017 }
1018
1019 return invalid_idx;
1020}
1021
1022/**
1023 * wmi_unified_register_event_handler() - register wmi event handler
1024 * @wmi_handle: handle to wmi
1025 * @event_id: wmi event id
1026 * @handler_func: wmi event handler function
Govind Singhd52faac2016-03-09 12:03:29 +05301027 * @rx_ctx: rx execution context for wmi rx events
Govind Singh6b411b52016-03-06 19:55:02 +05301028 *
1029 * Return: 0 on success
1030 */
1031int wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301032 uint32_t event_id,
Govind Singhd52faac2016-03-09 12:03:29 +05301033 wmi_unified_event_handler handler_func,
1034 uint8_t rx_ctx)
Govind Singh6b411b52016-03-06 19:55:02 +05301035{
1036 uint32_t idx = 0;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301037 uint32_t evt_id;
Govind Singh6b411b52016-03-06 19:55:02 +05301038
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301039#ifdef WMI_TLV_AND_NON_TLV_SUPPORT
1040 if (event_id >= wmi_events_max ||
1041 wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
1042 qdf_print("%s: Event id %d is unavailable\n",
1043 __func__, event_id);
1044 return QDF_STATUS_E_FAILURE;
1045 }
1046 evt_id = wmi_handle->wmi_events[event_id];
1047#else
1048 evt_id = event_id;
1049#endif
1050 if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) {
1051 qdf_print("%s : event handler already registered 0x%x\n",
1052 __func__, evt_id);
Govind Singhb53420c2016-03-09 14:32:57 +05301053 return QDF_STATUS_E_FAILURE;
Govind Singh6b411b52016-03-06 19:55:02 +05301054 }
1055 if (wmi_handle->max_event_idx == WMI_UNIFIED_MAX_EVENT) {
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301056 qdf_print("%s : no more event handlers 0x%x\n",
1057 __func__, evt_id);
Govind Singhb53420c2016-03-09 14:32:57 +05301058 return QDF_STATUS_E_FAILURE;
Govind Singh6b411b52016-03-06 19:55:02 +05301059 }
1060 idx = wmi_handle->max_event_idx;
1061 wmi_handle->event_handler[idx] = handler_func;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301062 wmi_handle->event_id[idx] = evt_id;
Govind Singh813fdac2016-03-12 09:26:52 +05301063 qdf_spin_lock_bh(&wmi_handle->ctx_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301064 wmi_handle->ctx[idx] = rx_ctx;
Govind Singh813fdac2016-03-12 09:26:52 +05301065 qdf_spin_unlock_bh(&wmi_handle->ctx_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301066 wmi_handle->max_event_idx++;
1067
1068 return 0;
1069}
1070
1071/**
1072 * wmi_unified_unregister_event_handler() - unregister wmi event handler
1073 * @wmi_handle: handle to wmi
1074 * @event_id: wmi event id
1075 *
1076 * Return: 0 on success
1077 */
1078int wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle,
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301079 uint32_t event_id)
Govind Singh6b411b52016-03-06 19:55:02 +05301080{
1081 uint32_t idx = 0;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301082 uint32_t evt_id;
Govind Singh6b411b52016-03-06 19:55:02 +05301083
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301084#ifdef WMI_TLV_AND_NON_TLV_SUPPORT
1085 if (event_id >= wmi_events_max ||
1086 wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
1087 qdf_print("%s: Event id %d is unavailable\n",
1088 __func__, event_id);
1089 return QDF_STATUS_E_FAILURE;
1090 }
1091 evt_id = wmi_handle->wmi_events[event_id];
1092#else
1093 evt_id = event_id;
1094#endif
1095
1096 idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id);
Govind Singh6b411b52016-03-06 19:55:02 +05301097 if (idx == -1) {
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301098 qdf_print("%s : event handler is not registered: evt id 0x%x\n",
1099 __func__, evt_id);
Govind Singhb53420c2016-03-09 14:32:57 +05301100 return QDF_STATUS_E_FAILURE;
Govind Singh6b411b52016-03-06 19:55:02 +05301101 }
1102 wmi_handle->event_handler[idx] = NULL;
1103 wmi_handle->event_id[idx] = 0;
1104 --wmi_handle->max_event_idx;
1105 wmi_handle->event_handler[idx] =
1106 wmi_handle->event_handler[wmi_handle->max_event_idx];
1107 wmi_handle->event_id[idx] =
1108 wmi_handle->event_id[wmi_handle->max_event_idx];
1109
1110 return 0;
1111}
1112
1113/**
Govind Singhd52faac2016-03-09 12:03:29 +05301114 * wmi_process_fw_event_default_ctx() - process in default caller context
Govind Singh6b411b52016-03-06 19:55:02 +05301115 * @wmi_handle: handle to wmi
1116 * @htc_packet: pointer to htc packet
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301117 * @exec_ctx: execution context for wmi fw event
Govind Singh6b411b52016-03-06 19:55:02 +05301118 *
Govind Singhd52faac2016-03-09 12:03:29 +05301119 * Event process by below function will be in default caller context.
1120 * wmi internally provides rx work thread processing context.
Govind Singh6b411b52016-03-06 19:55:02 +05301121 *
1122 * Return: none
1123 */
Govind Singhd52faac2016-03-09 12:03:29 +05301124static void wmi_process_fw_event_default_ctx(struct wmi_unified *wmi_handle,
1125 HTC_PACKET *htc_packet, uint8_t exec_ctx)
Govind Singh6b411b52016-03-06 19:55:02 +05301126{
1127 wmi_buf_t evt_buf;
1128 evt_buf = (wmi_buf_t) htc_packet->pPktContext;
1129
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301130#ifdef WMI_NON_TLV_SUPPORT
1131 wmi_handle->rx_ops.wma_process_fw_event_handler_cbk
1132 (wmi_handle->scn_handle, evt_buf, exec_ctx);
1133#else
Govind Singh5eb51532016-03-09 11:34:12 +05301134 wmi_handle->rx_ops.wma_process_fw_event_handler_cbk(wmi_handle,
Govind Singhd52faac2016-03-09 12:03:29 +05301135 evt_buf, exec_ctx);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301136#endif
Govind Singhd52faac2016-03-09 12:03:29 +05301137
Govind Singh6b411b52016-03-06 19:55:02 +05301138 return;
1139}
1140
1141/**
1142 * wmi_process_fw_event_worker_thread_ctx() - process in worker thread context
1143 * @wmi_handle: handle to wmi
1144 * @htc_packet: pointer to htc packet
1145 *
1146 * Event process by below function will be in worker thread context.
1147 * Use this method for events which are not critical and not
1148 * handled in protocol stack.
1149 *
1150 * Return: none
1151 */
1152static void wmi_process_fw_event_worker_thread_ctx
1153 (struct wmi_unified *wmi_handle, HTC_PACKET *htc_packet)
1154{
1155 wmi_buf_t evt_buf;
1156 uint32_t id;
1157 uint8_t *data;
1158
1159 evt_buf = (wmi_buf_t) htc_packet->pPktContext;
Govind Singhb53420c2016-03-09 14:32:57 +05301160 id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
1161 data = qdf_nbuf_data(evt_buf);
Govind Singh6b411b52016-03-06 19:55:02 +05301162
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301163#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +05301164 qdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301165 /* Exclude 4 bytes of TLV header */
1166 WMI_RX_EVENT_RECORD(id, ((uint8_t *) data + 4));
Govind Singhb53420c2016-03-09 14:32:57 +05301167 qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301168#endif
Govind Singhb53420c2016-03-09 14:32:57 +05301169 qdf_spin_lock_bh(&wmi_handle->eventq_lock);
1170 qdf_nbuf_queue_add(&wmi_handle->event_queue, evt_buf);
1171 qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301172 schedule_work(&wmi_handle->rx_event_work);
1173 return;
1174}
1175
1176/**
Govind Singhd52faac2016-03-09 12:03:29 +05301177 * wmi_control_rx() - process fw events callbacks
Govind Singh6b411b52016-03-06 19:55:02 +05301178 * @ctx: handle to wmi
1179 * @htc_packet: pointer to htc packet
1180 *
Govind Singh6b411b52016-03-06 19:55:02 +05301181 * Return: none
1182 */
1183void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet)
1184{
1185 struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx;
1186 wmi_buf_t evt_buf;
1187 uint32_t id;
Govind Singhd52faac2016-03-09 12:03:29 +05301188 uint32_t idx = 0;
1189 enum wmi_rx_exec_ctx exec_ctx;
Govind Singh6b411b52016-03-06 19:55:02 +05301190
1191 evt_buf = (wmi_buf_t) htc_packet->pPktContext;
Govind Singhb53420c2016-03-09 14:32:57 +05301192 id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
Govind Singhd52faac2016-03-09 12:03:29 +05301193 idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
Govind Singhb53420c2016-03-09 14:32:57 +05301194 if (qdf_unlikely(idx == A_ERROR)) {
1195 qdf_print
Govind Singhd52faac2016-03-09 12:03:29 +05301196 ("%s :event handler is not registered: event id 0x%x\n",
1197 __func__, id);
Govind Singhb53420c2016-03-09 14:32:57 +05301198 qdf_nbuf_free(evt_buf);
Govind Singhd52faac2016-03-09 12:03:29 +05301199 return;
1200 }
Govind Singh813fdac2016-03-12 09:26:52 +05301201 qdf_spin_lock_bh(&wmi_handle->ctx_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301202 exec_ctx = wmi_handle->ctx[idx];
Govind Singh813fdac2016-03-12 09:26:52 +05301203 qdf_spin_unlock_bh(&wmi_handle->ctx_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301204
1205 if (exec_ctx == WMI_RX_WORK_CTX) {
Govind Singh6b411b52016-03-06 19:55:02 +05301206 wmi_process_fw_event_worker_thread_ctx
1207 (wmi_handle, htc_packet);
Govind Singhd52faac2016-03-09 12:03:29 +05301208 } else if (exec_ctx > WMI_RX_WORK_CTX) {
1209 wmi_process_fw_event_default_ctx
1210 (wmi_handle, htc_packet, exec_ctx);
1211 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05301212 qdf_print("%s :Invalid event context %d\n", __func__, exec_ctx);
1213 qdf_nbuf_free(evt_buf);
Govind Singh6b411b52016-03-06 19:55:02 +05301214 }
Govind Singhd52faac2016-03-09 12:03:29 +05301215
Govind Singh6b411b52016-03-06 19:55:02 +05301216}
1217
1218/**
1219 * wmi_process_fw_event() - process any fw event
1220 * @wmi_handle: wmi handle
1221 * @evt_buf: fw event buffer
1222 *
Govind Singhd52faac2016-03-09 12:03:29 +05301223 * This function process fw event in caller context
Govind Singh6b411b52016-03-06 19:55:02 +05301224 *
1225 * Return: none
1226 */
1227void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
1228{
1229 __wmi_control_rx(wmi_handle, evt_buf);
1230}
1231
1232/**
1233 * __wmi_control_rx() - process serialize wmi event callback
1234 * @wmi_handle: wmi handle
1235 * @evt_buf: fw event buffer
1236 *
1237 * Return: none
1238 */
1239void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
1240{
1241 uint32_t id;
1242 uint8_t *data;
1243 uint32_t len;
1244 void *wmi_cmd_struct_ptr = NULL;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301245#ifndef WMI_NON_TLV_SUPPORT
Govind Singh6b411b52016-03-06 19:55:02 +05301246 int tlv_ok_status = 0;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301247#endif
Govind Singhd52faac2016-03-09 12:03:29 +05301248 uint32_t idx = 0;
Govind Singh6b411b52016-03-06 19:55:02 +05301249
Govind Singhb53420c2016-03-09 14:32:57 +05301250 id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
Govind Singh6b411b52016-03-06 19:55:02 +05301251
Govind Singhb53420c2016-03-09 14:32:57 +05301252 if (qdf_nbuf_pull_head(evt_buf, sizeof(WMI_CMD_HDR)) == NULL)
Govind Singh6b411b52016-03-06 19:55:02 +05301253 goto end;
1254
Govind Singhb53420c2016-03-09 14:32:57 +05301255 data = qdf_nbuf_data(evt_buf);
1256 len = qdf_nbuf_len(evt_buf);
Govind Singh6b411b52016-03-06 19:55:02 +05301257
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301258#ifndef WMI_NON_TLV_SUPPORT
1259 if (wmi_handle->target_type == WMI_TLV_TARGET) {
1260 /* Validate and pad(if necessary) the TLVs */
1261 tlv_ok_status =
1262 wmitlv_check_and_pad_event_tlvs(wmi_handle->scn_handle,
Govind Singh6b411b52016-03-06 19:55:02 +05301263 data, len, id,
1264 &wmi_cmd_struct_ptr);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301265 if (tlv_ok_status != 0) {
1266 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
1267 "%s: Error: id=0x%d, wmitlv check status=%d\n",
1268 __func__, id, tlv_ok_status);
1269 goto end;
1270 }
Govind Singh6b411b52016-03-06 19:55:02 +05301271 }
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301272#endif
Govind Singh6b411b52016-03-06 19:55:02 +05301273
Govind Singhd52faac2016-03-09 12:03:29 +05301274 idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
1275 if (idx == A_ERROR) {
Govind Singhb53420c2016-03-09 14:32:57 +05301276 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +05301277 "%s : event handler is not registered: event id 0x%x\n",
1278 __func__, id);
Govind Singh6b411b52016-03-06 19:55:02 +05301279 goto end;
1280 }
Govind Singhd52faac2016-03-09 12:03:29 +05301281#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +05301282 qdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301283 /* Exclude 4 bytes of TLV header */
1284 if (id == WMI_MGMT_TX_COMPLETION_EVENTID) {
1285 WMI_MGMT_EVENT_RECORD(id, ((uint8_t *) data + 4));
1286 } else {
1287 WMI_EVENT_RECORD(id, ((uint8_t *) data + 4));
Govind Singh6b411b52016-03-06 19:55:02 +05301288 }
Govind Singhb53420c2016-03-09 14:32:57 +05301289 qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301290#endif
1291 /* Call the WMI registered event handler */
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301292 if (wmi_handle->target_type == WMI_TLV_TARGET)
1293 wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
1294 wmi_cmd_struct_ptr, len);
1295 else
1296 wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
1297 data, len);
Govind Singhd52faac2016-03-09 12:03:29 +05301298
Govind Singh6b411b52016-03-06 19:55:02 +05301299end:
Govind Singhd52faac2016-03-09 12:03:29 +05301300 /* Free event buffer and allocated event tlv */
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301301#ifndef WMI_NON_TLV_SUPPORT
1302 if (wmi_handle->target_type == WMI_TLV_TARGET)
1303 wmitlv_free_allocated_event_tlvs(id, &wmi_cmd_struct_ptr);
1304#endif
Govind Singhb53420c2016-03-09 14:32:57 +05301305 qdf_nbuf_free(evt_buf);
Govind Singhd52faac2016-03-09 12:03:29 +05301306
Govind Singh6b411b52016-03-06 19:55:02 +05301307}
1308
1309/**
1310 * wmi_rx_event_work() - process rx event in rx work queue context
1311 * @work: rx work queue struct
1312 *
1313 * This function process any fw event to serialize it through rx worker thread.
1314 *
1315 * Return: none
1316 */
1317void wmi_rx_event_work(struct work_struct *work)
1318{
1319 struct wmi_unified *wmi = container_of(work, struct wmi_unified,
1320 rx_event_work);
1321 wmi_buf_t buf;
1322
Govind Singhb53420c2016-03-09 14:32:57 +05301323 qdf_spin_lock_bh(&wmi->eventq_lock);
1324 buf = qdf_nbuf_queue_remove(&wmi->event_queue);
1325 qdf_spin_unlock_bh(&wmi->eventq_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301326 while (buf) {
1327 __wmi_control_rx(wmi, buf);
Govind Singhb53420c2016-03-09 14:32:57 +05301328 qdf_spin_lock_bh(&wmi->eventq_lock);
1329 buf = qdf_nbuf_queue_remove(&wmi->event_queue);
1330 qdf_spin_unlock_bh(&wmi->eventq_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301331 }
1332}
1333
Govind Singh6b411b52016-03-06 19:55:02 +05301334#ifdef FEATURE_RUNTIME_PM
1335/**
1336 * wmi_runtime_pm_init() - initialize runtime pm wmi variables
1337 * @wmi_handle: wmi context
1338 */
Govind Singhd52faac2016-03-09 12:03:29 +05301339static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
Govind Singh6b411b52016-03-06 19:55:02 +05301340{
Govind Singhb53420c2016-03-09 14:32:57 +05301341 qdf_atomic_init(&wmi_handle->runtime_pm_inprogress);
Govind Singh6b411b52016-03-06 19:55:02 +05301342}
Govind Singhd52faac2016-03-09 12:03:29 +05301343
1344/**
1345 * wmi_set_runtime_pm_inprogress() - set runtime pm progress flag
1346 * @wmi_handle: wmi context
1347 * @val: runtime pm progress flag
1348 */
1349void wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, A_BOOL val)
1350{
Govind Singhb53420c2016-03-09 14:32:57 +05301351 qdf_atomic_set(&wmi_handle->runtime_pm_inprogress, val);
Govind Singhd52faac2016-03-09 12:03:29 +05301352}
1353
1354/**
1355 * wmi_get_runtime_pm_inprogress() - get runtime pm progress flag
1356 * @wmi_handle: wmi context
1357 */
1358inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle)
1359{
Govind Singhb53420c2016-03-09 14:32:57 +05301360 return qdf_atomic_read(&wmi_handle->runtime_pm_inprogress);
Govind Singhd52faac2016-03-09 12:03:29 +05301361}
Govind Singh6b411b52016-03-06 19:55:02 +05301362#else
Govind Singhd52faac2016-03-09 12:03:29 +05301363static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
Govind Singh6b411b52016-03-06 19:55:02 +05301364{
1365}
1366#endif
1367
1368/**
1369 * wmi_unified_attach() - attach for unified WMI
Govind Singhc458f382016-02-04 18:42:30 +05301370 * @scn_handle: handle to SCN
1371 * @osdev: OS device context
1372 * @target_type: TLV or not-TLV based target
1373 * @use_cookie: cookie based allocation enabled/disabled
1374 * @ops: umac rx callbacks
Govind Singh6b411b52016-03-06 19:55:02 +05301375 *
1376 * @Return: wmi handle.
1377 */
Govind Singhc458f382016-02-04 18:42:30 +05301378void *wmi_unified_attach(void *scn_handle,
1379 osdev_t osdev, enum wmi_target_type target_type,
Govind Singh5eb51532016-03-09 11:34:12 +05301380 bool use_cookie, struct wmi_rx_ops *rx_ops)
Govind Singh6b411b52016-03-06 19:55:02 +05301381{
1382 struct wmi_unified *wmi_handle;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301383
1384#ifndef WMI_NON_TLV_SUPPORT
Govind Singh6b411b52016-03-06 19:55:02 +05301385 wmi_handle =
1386 (struct wmi_unified *)os_malloc(NULL,
1387 sizeof(struct wmi_unified),
1388 GFP_ATOMIC);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301389#else
1390 wmi_handle =
1391 (struct wmi_unified *) qdf_mem_malloc(
1392 sizeof(struct wmi_unified));
1393#endif
Govind Singh6b411b52016-03-06 19:55:02 +05301394 if (wmi_handle == NULL) {
Govind Singhb53420c2016-03-09 14:32:57 +05301395 qdf_print("allocation of wmi handle failed %zu\n",
Govind Singhd52faac2016-03-09 12:03:29 +05301396 sizeof(struct wmi_unified));
Govind Singh6b411b52016-03-06 19:55:02 +05301397 return NULL;
1398 }
1399 OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified));
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301400 wmi_handle->scn_handle = scn_handle;
Govind Singhb53420c2016-03-09 14:32:57 +05301401 qdf_atomic_init(&wmi_handle->pending_cmds);
1402 qdf_atomic_init(&wmi_handle->is_target_suspended);
Govind Singh6b411b52016-03-06 19:55:02 +05301403 wmi_runtime_pm_init(wmi_handle);
Govind Singhb53420c2016-03-09 14:32:57 +05301404 qdf_spinlock_create(&wmi_handle->eventq_lock);
1405 qdf_nbuf_queue_init(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301406 INIT_WORK(&wmi_handle->rx_event_work, wmi_rx_event_work);
Govind Singh6b411b52016-03-06 19:55:02 +05301407#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +05301408 qdf_spinlock_create(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301409#endif
Govind Singhc458f382016-02-04 18:42:30 +05301410 /* Attach mc_thread context processing function */
Govind Singh5eb51532016-03-09 11:34:12 +05301411 wmi_handle->rx_ops.wma_process_fw_event_handler_cbk =
1412 rx_ops->wma_process_fw_event_handler_cbk;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301413 wmi_handle->target_type = target_type;
Govind Singhc458f382016-02-04 18:42:30 +05301414 if (target_type == WMI_TLV_TARGET)
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301415 wmi_tlv_attach(wmi_handle);
Govind Singhc458f382016-02-04 18:42:30 +05301416 else
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301417 wmi_non_tlv_attach(wmi_handle);
Govind Singhc458f382016-02-04 18:42:30 +05301418 /* Assign target cookie capablity */
1419 wmi_handle->use_cookie = use_cookie;
1420 wmi_handle->osdev = osdev;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301421 wmi_handle->wmi_stopinprogress = 0;
Govind Singh813fdac2016-03-12 09:26:52 +05301422 qdf_spinlock_create(&wmi_handle->ctx_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301423
1424 return wmi_handle;
1425}
1426
1427/**
1428 * wmi_unified_detach() - detach for unified WMI
1429 *
1430 * @wmi_handle : handle to wmi.
1431 *
1432 * @Return: none.
1433 */
1434void wmi_unified_detach(struct wmi_unified *wmi_handle)
1435{
1436 wmi_buf_t buf;
1437
Govind Singhb53420c2016-03-09 14:32:57 +05301438 cancel_work_sync(&wmi_handle->rx_event_work);
1439 qdf_spin_lock_bh(&wmi_handle->eventq_lock);
1440 buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301441 while (buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301442 qdf_nbuf_free(buf);
1443 buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301444 }
Govind Singhb53420c2016-03-09 14:32:57 +05301445 qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
Govind Singh813fdac2016-03-12 09:26:52 +05301446 qdf_spinlock_destroy(&wmi_handle->ctx_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301447 if (wmi_handle != NULL) {
1448 OS_FREE(wmi_handle);
1449 wmi_handle = NULL;
1450 }
1451}
1452
1453/**
1454 * wmi_unified_remove_work() - detach for WMI work
1455 * @wmi_handle: handle to WMI
1456 *
1457 * A function that does not fully detach WMI, but just remove work
1458 * queue items associated with it. This is used to make sure that
1459 * before any other processing code that may destroy related contexts
1460 * (HTC, etc), work queue processing on WMI has already been stopped.
1461 *
1462 * Return: None
1463 */
1464void
1465wmi_unified_remove_work(struct wmi_unified *wmi_handle)
1466{
1467 wmi_buf_t buf;
1468
Govind Singhb53420c2016-03-09 14:32:57 +05301469 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh6b411b52016-03-06 19:55:02 +05301470 "Enter: %s", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05301471 cancel_work_sync(&wmi_handle->rx_event_work);
1472 qdf_spin_lock_bh(&wmi_handle->eventq_lock);
1473 buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301474 while (buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301475 qdf_nbuf_free(buf);
1476 buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301477 }
Govind Singhb53420c2016-03-09 14:32:57 +05301478 qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
1479 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh6b411b52016-03-06 19:55:02 +05301480 "Done: %s", __func__);
1481}
1482
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301483/**
1484 * wmi_htc_tx_complete() - Process htc tx completion
1485 *
1486 * @ctx: handle to wmi
1487 * @htc_packet: pointer to htc packet
1488 *
1489 * @Return: none.
1490 */
Govind Singh6b411b52016-03-06 19:55:02 +05301491void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt)
1492{
1493 struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx;
1494 wmi_buf_t wmi_cmd_buf = GET_HTC_PACKET_NET_BUF_CONTEXT(htc_pkt);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301495
Govind Singh6b411b52016-03-06 19:55:02 +05301496#ifdef WMI_INTERFACE_EVENT_LOGGING
1497 uint32_t cmd_id;
1498#endif
1499
1500 ASSERT(wmi_cmd_buf);
1501#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +05301502 cmd_id = WMI_GET_FIELD(qdf_nbuf_data(wmi_cmd_buf),
Govind Singh6b411b52016-03-06 19:55:02 +05301503 WMI_CMD_HDR, COMMANDID);
1504
1505#ifdef QCA_WIFI_3_0_EMU
Govind Singhb53420c2016-03-09 14:32:57 +05301506 qdf_print
Govind Singh6b411b52016-03-06 19:55:02 +05301507 ("\nSent WMI command:%s command_id:0x%x over dma and recieved tx complete interupt\n",
1508 get_wmi_cmd_string(cmd_id), cmd_id);
1509#endif
1510
Govind Singhb53420c2016-03-09 14:32:57 +05301511 qdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301512 /* Record 16 bytes of WMI cmd tx complete data
1513 - exclude TLV and WMI headers */
1514 if (cmd_id == WMI_MGMT_TX_SEND_CMDID) {
1515 WMI_MGMT_COMMAND_TX_CMP_RECORD(cmd_id,
Govind Singhb53420c2016-03-09 14:32:57 +05301516 ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) + 2));
Govind Singh6b411b52016-03-06 19:55:02 +05301517 } else {
1518 WMI_COMMAND_TX_CMP_RECORD(cmd_id,
Govind Singhb53420c2016-03-09 14:32:57 +05301519 ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) + 2));
Govind Singh6b411b52016-03-06 19:55:02 +05301520 }
1521
Govind Singhb53420c2016-03-09 14:32:57 +05301522 qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301523#endif
Govind Singhb53420c2016-03-09 14:32:57 +05301524 qdf_nbuf_free(wmi_cmd_buf);
1525 qdf_mem_free(htc_pkt);
1526 qdf_atomic_dec(&wmi_handle->pending_cmds);
Govind Singh6b411b52016-03-06 19:55:02 +05301527}
1528
1529/**
1530 * wmi_get_host_credits() - WMI API to get updated host_credits
1531 *
1532 * @wmi_handle: handle to WMI.
1533 *
1534 * @Return: updated host_credits.
1535 */
1536int
1537wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle,
1538 void *htc_handle)
1539{
1540
1541 int status;
1542 HTC_SERVICE_CONNECT_RESP response;
1543 HTC_SERVICE_CONNECT_REQ connect;
1544
1545 OS_MEMZERO(&connect, sizeof(connect));
1546 OS_MEMZERO(&response, sizeof(response));
1547
1548 /* meta data is unused for now */
1549 connect.pMetaData = NULL;
1550 connect.MetaDataLength = 0;
1551 /* these fields are the same for all service endpoints */
1552 connect.EpCallbacks.pContext = wmi_handle;
1553 connect.EpCallbacks.EpTxCompleteMultiple =
1554 NULL /* Control path completion ar6000_tx_complete */;
1555 connect.EpCallbacks.EpRecv = wmi_control_rx /* Control path rx */;
1556 connect.EpCallbacks.EpRecvRefill = NULL /* ar6000_rx_refill */;
1557 connect.EpCallbacks.EpSendFull = NULL /* ar6000_tx_queue_full */;
1558 connect.EpCallbacks.EpTxComplete =
1559 wmi_htc_tx_complete /* ar6000_tx_queue_full */;
1560
1561 /* connect to control service */
1562 connect.service_id = WMI_CONTROL_SVC;
1563 status = htc_connect_service(htc_handle, &connect,
1564 &response);
1565
1566 if (status != EOK) {
Govind Singhb53420c2016-03-09 14:32:57 +05301567 qdf_print
Govind Singh6b411b52016-03-06 19:55:02 +05301568 ("Failed to connect to WMI CONTROL service status:%d \n",
1569 status);
1570 return status;
1571 }
1572 wmi_handle->wmi_endpoint_id = response.Endpoint;
1573 wmi_handle->htc_handle = htc_handle;
1574 wmi_handle->max_msg_len = response.MaxMsgLength;
1575
1576 return EOK;
1577}
1578
1579/**
1580 * wmi_get_host_credits() - WMI API to get updated host_credits
1581 *
1582 * @wmi_handle: handle to WMI.
1583 *
1584 * @Return: updated host_credits.
1585 */
1586int wmi_get_host_credits(wmi_unified_t wmi_handle)
1587{
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301588 int host_credits = 0;
Govind Singh6b411b52016-03-06 19:55:02 +05301589
1590 htc_get_control_endpoint_tx_host_credits(wmi_handle->htc_handle,
1591 &host_credits);
1592 return host_credits;
1593}
1594
1595/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301596 * wmi_get_pending_cmds() - WMI API to get WMI Pending Commands in the HTC
1597 * queue
Govind Singh6b411b52016-03-06 19:55:02 +05301598 *
1599 * @wmi_handle: handle to WMI.
1600 *
1601 * @Return: Pending Commands in the HTC queue.
1602 */
1603int wmi_get_pending_cmds(wmi_unified_t wmi_handle)
1604{
Govind Singhb53420c2016-03-09 14:32:57 +05301605 return qdf_atomic_read(&wmi_handle->pending_cmds);
Govind Singh6b411b52016-03-06 19:55:02 +05301606}
1607
1608/**
1609 * wmi_set_target_suspend() - WMI API to set target suspend state
1610 *
1611 * @wmi_handle: handle to WMI.
1612 * @val: suspend state boolean.
1613 *
1614 * @Return: none.
1615 */
1616void wmi_set_target_suspend(wmi_unified_t wmi_handle, A_BOOL val)
1617{
Govind Singhb53420c2016-03-09 14:32:57 +05301618 qdf_atomic_set(&wmi_handle->is_target_suspended, val);
Govind Singh6b411b52016-03-06 19:55:02 +05301619}
1620
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301621#ifdef WMI_NON_TLV_SUPPORT
1622/**
1623 * API to flush all the previous packets associated with the wmi endpoint
1624 *
1625 * @param wmi_handle : handle to WMI.
1626 */
1627void
1628wmi_flush_endpoint(wmi_unified_t wmi_handle)
1629{
1630 htc_flush_endpoint(wmi_handle->htc_handle,
1631 wmi_handle->wmi_endpoint_id, 0);
1632}
1633
1634/**
1635 * generic function to block unified WMI command
1636 * @param wmi_handle : handle to WMI.
1637 * @return 0 on success and -ve on failure.
1638 */
1639int
1640wmi_stop(wmi_unified_t wmi_handle)
1641{
1642 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
1643 "WMI Stop\n");
1644 wmi_handle->wmi_stopinprogress = 1;
1645 return 0;
1646}
1647#endif