blob: a138ae742215fadf31b2f474d0874ab5d1c03750 [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);
Govind Singh6b411b52016-03-06 19:55:02 +0530606 CASE_RETURN_STRING(WMI_MAWC_SENSOR_REPORT_IND_CMDID);
607 CASE_RETURN_STRING(WMI_ROAM_CONFIGURE_MAWC_CMDID);
608 CASE_RETURN_STRING(WMI_NLO_CONFIGURE_MAWC_CMDID);
609 CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_MAWC_CMDID);
610 /* GPIO Configuration */
611 CASE_RETURN_STRING(WMI_GPIO_CONFIG_CMDID);
612 CASE_RETURN_STRING(WMI_GPIO_OUTPUT_CMDID);
613
614 /* Txbf configuration command */
615 CASE_RETURN_STRING(WMI_TXBF_CMDID);
616
617 /* FWTEST Commands */
618 CASE_RETURN_STRING(WMI_FWTEST_VDEV_MCC_SET_TBTT_MODE_CMDID);
619 /* set NoA descs */
620 CASE_RETURN_STRING(WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
621
622 /* TDLS Configuration */
623 /* enable/disable TDLS */
624 CASE_RETURN_STRING(WMI_TDLS_SET_STATE_CMDID);
625 /* set tdls peer state */
626 CASE_RETURN_STRING(WMI_TDLS_PEER_UPDATE_CMDID);
627
628 /* Resmgr Configuration */
629 /* Adaptive OCS is enabled by default in the FW.
630 * This command is used to disable FW based adaptive OCS.
631 */
632 CASE_RETURN_STRING
633 (WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
634 /* set the requested channel time quota for the home channels */
635 CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
636 /* set the requested latency for the home channels */
637 CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
638
639 /* STA SMPS Configuration */
640 /* force SMPS mode */
641 CASE_RETURN_STRING(WMI_STA_SMPS_FORCE_MODE_CMDID);
642 /* set SMPS parameters */
643 CASE_RETURN_STRING(WMI_STA_SMPS_PARAM_CMDID);
644
645 /* Wlan HB commands */
646 /* enalbe/disable wlan HB */
647 CASE_RETURN_STRING(WMI_HB_SET_ENABLE_CMDID);
648 /* set tcp parameters for wlan HB */
649 CASE_RETURN_STRING(WMI_HB_SET_TCP_PARAMS_CMDID);
650 /* set tcp pkt filter for wlan HB */
651 CASE_RETURN_STRING(WMI_HB_SET_TCP_PKT_FILTER_CMDID);
652 /* set udp parameters for wlan HB */
653 CASE_RETURN_STRING(WMI_HB_SET_UDP_PARAMS_CMDID);
654 /* set udp pkt filter for wlan HB */
655 CASE_RETURN_STRING(WMI_HB_SET_UDP_PKT_FILTER_CMDID);
656
657 /* Wlan RMC commands*/
658 /* enable/disable RMC */
659 CASE_RETURN_STRING(WMI_RMC_SET_MODE_CMDID);
660 /* configure action frame period */
661 CASE_RETURN_STRING(WMI_RMC_SET_ACTION_PERIOD_CMDID);
662 /* For debug/future enhancement purposes only,
663 * configures/finetunes RMC algorithms */
664 CASE_RETURN_STRING(WMI_RMC_CONFIG_CMDID);
665
666 /* WLAN MHF offload commands */
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530667 /* enable/disable MHF offload */
Govind Singh6b411b52016-03-06 19:55:02 +0530668 CASE_RETURN_STRING(WMI_MHF_OFFLOAD_SET_MODE_CMDID);
669 /* Plumb routing table for MHF offload */
670 CASE_RETURN_STRING(WMI_MHF_OFFLOAD_PLUMB_ROUTING_TBL_CMDID);
671
672 /* location scan commands */
673 /* start batch scan */
674 CASE_RETURN_STRING(WMI_BATCH_SCAN_ENABLE_CMDID);
675 /* stop batch scan */
676 CASE_RETURN_STRING(WMI_BATCH_SCAN_DISABLE_CMDID);
677 /* get batch scan result */
678 CASE_RETURN_STRING(WMI_BATCH_SCAN_TRIGGER_RESULT_CMDID);
679 /* OEM related cmd */
680 CASE_RETURN_STRING(WMI_OEM_REQ_CMDID);
681 CASE_RETURN_STRING(WMI_OEM_REQUEST_CMDID);
682 /* NAN request cmd */
683 CASE_RETURN_STRING(WMI_NAN_CMDID);
684 /* Modem power state cmd */
685 CASE_RETURN_STRING(WMI_MODEM_POWER_STATE_CMDID);
686 CASE_RETURN_STRING(WMI_REQUEST_STATS_EXT_CMDID);
687 CASE_RETURN_STRING(WMI_OBSS_SCAN_ENABLE_CMDID);
688 CASE_RETURN_STRING(WMI_OBSS_SCAN_DISABLE_CMDID);
689 CASE_RETURN_STRING(WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID);
690 CASE_RETURN_STRING(WMI_ROAM_SCAN_CMD);
691 CASE_RETURN_STRING(WMI_PDEV_SET_LED_CONFIG_CMDID);
692 CASE_RETURN_STRING(WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
693 CASE_RETURN_STRING(WMI_CHAN_AVOID_UPDATE_CMDID);
Sreelakshmi Konamki084f3d32016-04-14 17:46:26 +0530694 CASE_RETURN_STRING(WMI_COEX_CONFIG_CMDID);
Govind Singh6b411b52016-03-06 19:55:02 +0530695 CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_KEEPALIVE_CMDID);
696 CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_KEEPALIVE_CMDID);
697 CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_WAKE_PATTERN_CMDID);
698 CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_WAKE_PATTERN_CMDID);
699 CASE_RETURN_STRING(WMI_REQUEST_LINK_STATS_CMDID);
700 CASE_RETURN_STRING(WMI_START_LINK_STATS_CMDID);
701 CASE_RETURN_STRING(WMI_CLEAR_LINK_STATS_CMDID);
702 CASE_RETURN_STRING(WMI_GET_FW_MEM_DUMP_CMDID);
703 CASE_RETURN_STRING(WMI_LPI_MGMT_SNOOPING_CONFIG_CMDID);
704 CASE_RETURN_STRING(WMI_LPI_START_SCAN_CMDID);
705 CASE_RETURN_STRING(WMI_LPI_STOP_SCAN_CMDID);
706 CASE_RETURN_STRING(WMI_EXTSCAN_START_CMDID);
707 CASE_RETURN_STRING(WMI_EXTSCAN_STOP_CMDID);
708 CASE_RETURN_STRING
709 (WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID);
710 CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID);
711 CASE_RETURN_STRING(WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID);
712 CASE_RETURN_STRING(WMI_EXTSCAN_GET_WLAN_CHANGE_RESULTS_CMDID);
713 CASE_RETURN_STRING(WMI_EXTSCAN_SET_CAPABILITIES_CMDID);
714 CASE_RETURN_STRING(WMI_EXTSCAN_GET_CAPABILITIES_CMDID);
715 CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID);
716 CASE_RETURN_STRING(WMI_ROAM_SYNCH_COMPLETE);
717 CASE_RETURN_STRING(WMI_D0_WOW_ENABLE_DISABLE_CMDID);
718 CASE_RETURN_STRING(WMI_EXTWOW_ENABLE_CMDID);
719 CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
720 CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
721 CASE_RETURN_STRING(WMI_UNIT_TEST_CMDID);
722 CASE_RETURN_STRING(WMI_ROAM_SET_RIC_REQUEST_CMDID);
723 CASE_RETURN_STRING(WMI_PDEV_GET_TEMPERATURE_CMDID);
724 CASE_RETURN_STRING(WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
725 CASE_RETURN_STRING(WMI_TPC_CHAINMASK_CONFIG_CMDID);
726 CASE_RETURN_STRING(WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID);
727 CASE_RETURN_STRING(WMI_SCAN_PROB_REQ_OUI_CMDID);
728 CASE_RETURN_STRING(WMI_TDLS_SET_OFFCHAN_MODE_CMDID);
729 CASE_RETURN_STRING(WMI_PDEV_SET_LED_FLASHING_CMDID);
730 CASE_RETURN_STRING(WMI_MDNS_OFFLOAD_ENABLE_CMDID);
731 CASE_RETURN_STRING(WMI_MDNS_SET_FQDN_CMDID);
732 CASE_RETURN_STRING(WMI_MDNS_SET_RESPONSE_CMDID);
733 CASE_RETURN_STRING(WMI_MDNS_GET_STATS_CMDID);
734 CASE_RETURN_STRING(WMI_ROAM_INVOKE_CMDID);
735 CASE_RETURN_STRING(WMI_SET_ANTENNA_DIVERSITY_CMDID);
736 CASE_RETURN_STRING(WMI_SAP_OFL_ENABLE_CMDID);
737 CASE_RETURN_STRING(WMI_APFIND_CMDID);
738 CASE_RETURN_STRING(WMI_PASSPOINT_LIST_CONFIG_CMDID);
739 CASE_RETURN_STRING(WMI_OCB_SET_SCHED_CMDID);
740 CASE_RETURN_STRING(WMI_OCB_SET_CONFIG_CMDID);
741 CASE_RETURN_STRING(WMI_OCB_SET_UTC_TIME_CMDID);
742 CASE_RETURN_STRING(WMI_OCB_START_TIMING_ADVERT_CMDID);
743 CASE_RETURN_STRING(WMI_OCB_STOP_TIMING_ADVERT_CMDID);
744 CASE_RETURN_STRING(WMI_OCB_GET_TSF_TIMER_CMDID);
745 CASE_RETURN_STRING(WMI_DCC_GET_STATS_CMDID);
746 CASE_RETURN_STRING(WMI_DCC_CLEAR_STATS_CMDID);
747 CASE_RETURN_STRING(WMI_DCC_UPDATE_NDL_CMDID);
748 CASE_RETURN_STRING(WMI_ROAM_FILTER_CMDID);
749 CASE_RETURN_STRING(WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
750 CASE_RETURN_STRING(WMI_DEBUG_MESG_FLUSH_CMDID);
751 CASE_RETURN_STRING(WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
752 CASE_RETURN_STRING(WMI_SOC_SET_PCL_CMDID);
753 CASE_RETURN_STRING(WMI_SOC_SET_HW_MODE_CMDID);
754 CASE_RETURN_STRING(WMI_SOC_SET_DUAL_MAC_CONFIG_CMDID);
755 CASE_RETURN_STRING(WMI_WOW_ENABLE_ICMPV6_NA_FLT_CMDID);
756 CASE_RETURN_STRING(WMI_DIAG_EVENT_LOG_CONFIG_CMDID);
757 CASE_RETURN_STRING(WMI_PACKET_FILTER_CONFIG_CMDID);
758 CASE_RETURN_STRING(WMI_PACKET_FILTER_ENABLE_CMDID);
759 CASE_RETURN_STRING(WMI_SAP_SET_BLACKLIST_PARAM_CMDID);
760 CASE_RETURN_STRING(WMI_WOW_UDP_SVC_OFLD_CMDID);
761 CASE_RETURN_STRING(WMI_MGMT_TX_SEND_CMDID);
762 CASE_RETURN_STRING(WMI_SOC_SET_ANTENNA_MODE_CMDID);
763 CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID);
764 CASE_RETURN_STRING(WMI_AP_PS_EGAP_PARAM_CMDID);
765 CASE_RETURN_STRING(WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID);
766 CASE_RETURN_STRING(WMI_BPF_GET_CAPABILITY_CMDID);
767 CASE_RETURN_STRING(WMI_BPF_GET_VDEV_STATS_CMDID);
768 CASE_RETURN_STRING(WMI_BPF_SET_VDEV_INSTRUCTIONS_CMDID);
769 CASE_RETURN_STRING(WMI_BPF_DEL_VDEV_INSTRUCTIONS_CMDID);
Govind Singh8b1466e2016-03-16 16:27:50 +0530770 CASE_RETURN_STRING(WMI_NDI_GET_CAP_REQ_CMDID);
771 CASE_RETURN_STRING(WMI_NDP_INITIATOR_REQ_CMDID);
772 CASE_RETURN_STRING(WMI_NDP_RESPONDER_REQ_CMDID);
773 CASE_RETURN_STRING(WMI_NDP_END_REQ_CMDID);
774 CASE_RETURN_STRING(WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
775 CASE_RETURN_STRING(WMI_PEER_ADD_PROXY_STA_ENTRY_CMDID);
776 CASE_RETURN_STRING(WMI_PDEV_FIPS_CMDID);
777 CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_ENABLE_CMDID);
778 CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
779 CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID);
780 CASE_RETURN_STRING(WMI_PDEV_SET_CTL_TABLE_CMDID);
781 CASE_RETURN_STRING(WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID);
782 CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CMDID);
783 CASE_RETURN_STRING(WMI_MIB_STATS_ENABLE_CMDID);
784 CASE_RETURN_STRING(WMI_PDEV_GET_ANI_CCK_CONFIG_CMDID);
785 CASE_RETURN_STRING(WMI_PDEV_GET_ANI_OFDM_CONFIG_CMDID);
786 CASE_RETURN_STRING(WMI_VDEV_RATEMASK_CMDID);
787 CASE_RETURN_STRING(WMI_VDEV_ATF_REQUEST_CMDID);
788 CASE_RETURN_STRING(WMI_VDEV_SET_DSCP_TID_MAP_CMDID);
789 CASE_RETURN_STRING(WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID);
790 CASE_RETURN_STRING(WMI_VDEV_SET_QUIET_MODE_CMDID);
791 CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
792 CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
793 CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
794 CASE_RETURN_STRING(WMI_PEER_ATF_REQUEST_CMDID);
795 CASE_RETURN_STRING(WMI_FWTEST_CMDID);
796 CASE_RETURN_STRING(WMI_QBOOST_CFG_CMDID);
797 CASE_RETURN_STRING(WMI_PDEV_GET_NFCAL_POWER_CMDID);
798 CASE_RETURN_STRING(WMI_PDEV_SET_PCL_CMDID);
799 CASE_RETURN_STRING(WMI_PDEV_SET_HW_MODE_CMDID);
800 CASE_RETURN_STRING(WMI_PDEV_SET_MAC_CONFIG_CMDID);
801 CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_MODE_CMDID);
802 CASE_RETURN_STRING(WMI_ROAM_SET_MBO_PARAM_CMDID);
Naveen Rawat8cf610b2016-04-14 20:10:15 -0700803 CASE_RETURN_STRING(WMI_CHAN_AVOID_RPT_ALLOW_CMDID);
Sandeep Puligillacc28f4e2016-04-16 13:35:09 +0530804 CASE_RETURN_STRING(WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
Krishna Kumaar Natarajanc285c102016-04-16 14:09:58 +0530805 CASE_RETURN_STRING(WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID);
Krishna Kumaar Natarajan0d2a1bd2016-04-16 16:47:07 +0530806 CASE_RETURN_STRING(WMI_PDEV_WAL_POWER_DEBUG_CMDID);
Govind Singh6b411b52016-03-06 19:55:02 +0530807 }
808
809 return "Invalid WMI cmd";
810}
811
812#ifdef QCA_WIFI_3_0_EMU
813static inline void wma_log_cmd_id(WMI_CMD_ID cmd_id)
814{
Govind Singhb53420c2016-03-09 14:32:57 +0530815 WMI_LOGE("Send WMI command:%s command_id:%d",
Govind Singh6b411b52016-03-06 19:55:02 +0530816 get_wmi_cmd_string(cmd_id), cmd_id);
817}
818#else
819static inline void wma_log_cmd_id(WMI_CMD_ID cmd_id)
820{
Govind Singhb53420c2016-03-09 14:32:57 +0530821 WMI_LOGD("Send WMI command:%s command_id:%d",
Govind Singh6b411b52016-03-06 19:55:02 +0530822 get_wmi_cmd_string(cmd_id), cmd_id);
823}
824#endif
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530825#endif
Govind Singh6b411b52016-03-06 19:55:02 +0530826
827/**
Govind Singhd52faac2016-03-09 12:03:29 +0530828 * wmi_is_runtime_pm_cmd() - check if a cmd is from suspend resume sequence
Govind Singh6b411b52016-03-06 19:55:02 +0530829 * @cmd: command to check
830 *
831 * Return: true if the command is part of the suspend resume sequence.
832 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530833#ifndef WMI_NON_TLV_SUPPORT
Govind Singhd52faac2016-03-09 12:03:29 +0530834static bool wmi_is_runtime_pm_cmd(WMI_CMD_ID cmd_id)
Govind Singh6b411b52016-03-06 19:55:02 +0530835{
836 switch (cmd_id) {
837 case WMI_WOW_ENABLE_CMDID:
838 case WMI_PDEV_SUSPEND_CMDID:
839 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
840 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
841 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
842 case WMI_PDEV_RESUME_CMDID:
843 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
844 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
845 return true;
846
847 default:
848 return false;
849 }
850}
851
852/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530853 * wmi_is_pm_resume_cmd() - check if a cmd is part of the resume sequence
854 * @cmd_id: command to check
855 *
856 * Return: true if the command is part of the resume sequence.
857 */
858static bool wmi_is_pm_resume_cmd(WMI_CMD_ID cmd_id)
859{
860 switch (cmd_id) {
861 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
862 case WMI_PDEV_RESUME_CMDID:
863 return true;
864
865 default:
866 return false;
867 }
868}
869#else
870static bool wmi_is_runtime_pm_cmd(WMI_CMD_ID cmd_id)
871{
872 return false;
873}
874static bool wmi_is_pm_resume_cmd(WMI_CMD_ID cmd_id)
875{
876 return false;
877}
878#endif
879
880/**
Govind Singh6b411b52016-03-06 19:55:02 +0530881 * wmi_unified_cmd_send() - WMI command API
882 * @wmi_handle: handle to wmi
883 * @buf: wmi buf
884 * @len: wmi buffer length
885 * @cmd_id: wmi command id
886 *
887 * Return: 0 on success
888 */
Govind Singhc458f382016-02-04 18:42:30 +0530889int wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, uint32_t len,
Govind Singh6b411b52016-03-06 19:55:02 +0530890 WMI_CMD_ID cmd_id)
891{
892 HTC_PACKET *pkt;
893 A_STATUS status;
Govind Singhd52faac2016-03-09 12:03:29 +0530894 uint16_t htc_tag = 0;
Govind Singh6b411b52016-03-06 19:55:02 +0530895
896 if (wmi_get_runtime_pm_inprogress(wmi_handle)) {
897 if (wmi_is_runtime_pm_cmd(cmd_id))
898 htc_tag = HTC_TX_PACKET_TAG_AUTO_PM;
Govind Singhb53420c2016-03-09 14:32:57 +0530899 } else if (qdf_atomic_read(&wmi_handle->is_target_suspended) &&
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530900 (!wmi_is_pm_resume_cmd(cmd_id))) {
Govind Singhb53420c2016-03-09 14:32:57 +0530901 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530902 "%s: Target is suspended", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +0530903 QDF_ASSERT(0);
Govind Singh67922e82016-04-01 16:48:57 +0530904 return QDF_STATUS_E_BUSY;
Govind Singh6b411b52016-03-06 19:55:02 +0530905 }
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530906 if (wmi_handle->wmi_stopinprogress) {
907 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
908 "WMI stop in progress\n");
909 return -EINVAL;
910 }
Govind Singh6b411b52016-03-06 19:55:02 +0530911
912 /* Do sanity check on the TLV parameter structure */
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530913#ifndef WMI_NON_TLV_SUPPORT
914 if (wmi_handle->target_type == WMI_TLV_TARGET) {
Govind Singhb53420c2016-03-09 14:32:57 +0530915 void *buf_ptr = (void *)qdf_nbuf_data(buf);
Govind Singh6b411b52016-03-06 19:55:02 +0530916
917 if (wmitlv_check_command_tlv_params(NULL, buf_ptr, len, cmd_id)
918 != 0) {
Govind Singhb53420c2016-03-09 14:32:57 +0530919 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530920 "\nERROR: %s: Invalid WMI Param Buffer for Cmd:%d",
Govind Singh6b411b52016-03-06 19:55:02 +0530921 __func__, cmd_id);
Govind Singh67922e82016-04-01 16:48:57 +0530922 return QDF_STATUS_E_INVAL;
Govind Singh6b411b52016-03-06 19:55:02 +0530923 }
924 }
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530925#endif
Govind Singh6b411b52016-03-06 19:55:02 +0530926
Govind Singhb53420c2016-03-09 14:32:57 +0530927 if (qdf_nbuf_push_head(buf, sizeof(WMI_CMD_HDR)) == NULL) {
928 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530929 "%s, Failed to send cmd %x, no memory",
930 __func__, cmd_id);
Govind Singh67922e82016-04-01 16:48:57 +0530931 return QDF_STATUS_E_NOMEM;
Govind Singh6b411b52016-03-06 19:55:02 +0530932 }
933
Govind Singhb53420c2016-03-09 14:32:57 +0530934 WMI_SET_FIELD(qdf_nbuf_data(buf), WMI_CMD_HDR, COMMANDID, cmd_id);
Govind Singh6b411b52016-03-06 19:55:02 +0530935
Govind Singhb53420c2016-03-09 14:32:57 +0530936 qdf_atomic_inc(&wmi_handle->pending_cmds);
937 if (qdf_atomic_read(&wmi_handle->pending_cmds) >= WMI_MAX_CMDS) {
938 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530939 "\n%s: hostcredits = %d", __func__,
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530940 wmi_get_host_credits(wmi_handle));
Govind Singh6b411b52016-03-06 19:55:02 +0530941 htc_dump_counter_info(wmi_handle->htc_handle);
Govind Singhb53420c2016-03-09 14:32:57 +0530942 qdf_atomic_dec(&wmi_handle->pending_cmds);
943 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530944 "%s: MAX 1024 WMI Pending cmds reached.", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +0530945 QDF_BUG(0);
Govind Singh67922e82016-04-01 16:48:57 +0530946 return QDF_STATUS_E_BUSY;
Govind Singh6b411b52016-03-06 19:55:02 +0530947 }
948
Govind Singhb53420c2016-03-09 14:32:57 +0530949 pkt = qdf_mem_malloc(sizeof(*pkt));
Govind Singh6b411b52016-03-06 19:55:02 +0530950 if (!pkt) {
Govind Singhb53420c2016-03-09 14:32:57 +0530951 qdf_atomic_dec(&wmi_handle->pending_cmds);
952 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530953 "%s, Failed to alloc htc packet %x, no memory",
954 __func__, cmd_id);
Govind Singh67922e82016-04-01 16:48:57 +0530955 return QDF_STATUS_E_NOMEM;
Govind Singh6b411b52016-03-06 19:55:02 +0530956 }
957
958 SET_HTC_PACKET_INFO_TX(pkt,
959 NULL,
Govind Singhb53420c2016-03-09 14:32:57 +0530960 qdf_nbuf_data(buf), len + sizeof(WMI_CMD_HDR),
Govind Singh6b411b52016-03-06 19:55:02 +0530961 wmi_handle->wmi_endpoint_id, htc_tag);
962
963 SET_HTC_PACKET_NET_BUF_CONTEXT(pkt, buf);
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530964#ifndef WMI_NON_TLV_SUPPORT
Govind Singh6b411b52016-03-06 19:55:02 +0530965 wma_log_cmd_id(cmd_id);
Govind Singhe7d9f3e2016-04-15 13:58:27 +0530966#endif
Govind Singh6b411b52016-03-06 19:55:02 +0530967
968#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +0530969 qdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +0530970 /*Record 16 bytes of WMI cmd data - exclude TLV and WMI headers */
971 if (cmd_id == WMI_MGMT_TX_SEND_CMDID) {
972 WMI_MGMT_COMMAND_RECORD(cmd_id,
Govind Singhb53420c2016-03-09 14:32:57 +0530973 ((uint32_t *)qdf_nbuf_data(buf) + 2));
Govind Singh6b411b52016-03-06 19:55:02 +0530974 } else {
Govind Singhb53420c2016-03-09 14:32:57 +0530975 WMI_COMMAND_RECORD(cmd_id, ((uint32_t *) qdf_nbuf_data(buf) +
Govind Singh6b411b52016-03-06 19:55:02 +0530976 2));
977 }
978
Govind Singhb53420c2016-03-09 14:32:57 +0530979 qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +0530980#endif
981
982 status = htc_send_pkt(wmi_handle->htc_handle, pkt);
983
984 if (A_OK != status) {
Govind Singhb53420c2016-03-09 14:32:57 +0530985 qdf_atomic_dec(&wmi_handle->pending_cmds);
986 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +0530987 "%s %d, htc_send_pkt failed", __func__, __LINE__);
Govind Singh6b411b52016-03-06 19:55:02 +0530988 }
989 if (status)
Govind Singhb53420c2016-03-09 14:32:57 +0530990 return QDF_STATUS_E_FAILURE;
Govind Singh6b411b52016-03-06 19:55:02 +0530991
Govind Singhb53420c2016-03-09 14:32:57 +0530992 return QDF_STATUS_SUCCESS;
Govind Singh6b411b52016-03-06 19:55:02 +0530993}
994
995/**
996 * wmi_unified_get_event_handler_ix() - gives event handler's index
997 * @wmi_handle: handle to wmi
998 * @event_id: wmi event id
999 *
1000 * Return: event handler's index
1001 */
1002int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle,
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301003 uint32_t event_id)
Govind Singh6b411b52016-03-06 19:55:02 +05301004{
1005 uint32_t idx = 0;
1006 int32_t invalid_idx = -1;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301007
Govind Singh6b411b52016-03-06 19:55:02 +05301008 for (idx = 0; (idx < wmi_handle->max_event_idx &&
1009 idx < WMI_UNIFIED_MAX_EVENT); ++idx) {
1010 if (wmi_handle->event_id[idx] == event_id &&
1011 wmi_handle->event_handler[idx] != NULL) {
1012 return idx;
1013 }
1014 }
1015
1016 return invalid_idx;
1017}
1018
1019/**
1020 * wmi_unified_register_event_handler() - register wmi event handler
1021 * @wmi_handle: handle to wmi
1022 * @event_id: wmi event id
1023 * @handler_func: wmi event handler function
Govind Singhd52faac2016-03-09 12:03:29 +05301024 * @rx_ctx: rx execution context for wmi rx events
Govind Singh6b411b52016-03-06 19:55:02 +05301025 *
1026 * Return: 0 on success
1027 */
1028int wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301029 uint32_t event_id,
Govind Singhd52faac2016-03-09 12:03:29 +05301030 wmi_unified_event_handler handler_func,
1031 uint8_t rx_ctx)
Govind Singh6b411b52016-03-06 19:55:02 +05301032{
1033 uint32_t idx = 0;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301034 uint32_t evt_id;
Govind Singh6b411b52016-03-06 19:55:02 +05301035
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301036#ifdef WMI_TLV_AND_NON_TLV_SUPPORT
1037 if (event_id >= wmi_events_max ||
1038 wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
1039 qdf_print("%s: Event id %d is unavailable\n",
1040 __func__, event_id);
1041 return QDF_STATUS_E_FAILURE;
1042 }
1043 evt_id = wmi_handle->wmi_events[event_id];
1044#else
1045 evt_id = event_id;
1046#endif
1047 if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) {
1048 qdf_print("%s : event handler already registered 0x%x\n",
1049 __func__, evt_id);
Govind Singhb53420c2016-03-09 14:32:57 +05301050 return QDF_STATUS_E_FAILURE;
Govind Singh6b411b52016-03-06 19:55:02 +05301051 }
1052 if (wmi_handle->max_event_idx == WMI_UNIFIED_MAX_EVENT) {
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301053 qdf_print("%s : no more event handlers 0x%x\n",
1054 __func__, evt_id);
Govind Singhb53420c2016-03-09 14:32:57 +05301055 return QDF_STATUS_E_FAILURE;
Govind Singh6b411b52016-03-06 19:55:02 +05301056 }
1057 idx = wmi_handle->max_event_idx;
1058 wmi_handle->event_handler[idx] = handler_func;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301059 wmi_handle->event_id[idx] = evt_id;
Govind Singh813fdac2016-03-12 09:26:52 +05301060 qdf_spin_lock_bh(&wmi_handle->ctx_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301061 wmi_handle->ctx[idx] = rx_ctx;
Govind Singh813fdac2016-03-12 09:26:52 +05301062 qdf_spin_unlock_bh(&wmi_handle->ctx_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301063 wmi_handle->max_event_idx++;
1064
1065 return 0;
1066}
1067
1068/**
1069 * wmi_unified_unregister_event_handler() - unregister wmi event handler
1070 * @wmi_handle: handle to wmi
1071 * @event_id: wmi event id
1072 *
1073 * Return: 0 on success
1074 */
1075int wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle,
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301076 uint32_t event_id)
Govind Singh6b411b52016-03-06 19:55:02 +05301077{
1078 uint32_t idx = 0;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301079 uint32_t evt_id;
Govind Singh6b411b52016-03-06 19:55:02 +05301080
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301081#ifdef WMI_TLV_AND_NON_TLV_SUPPORT
1082 if (event_id >= wmi_events_max ||
1083 wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
1084 qdf_print("%s: Event id %d is unavailable\n",
1085 __func__, event_id);
1086 return QDF_STATUS_E_FAILURE;
1087 }
1088 evt_id = wmi_handle->wmi_events[event_id];
1089#else
1090 evt_id = event_id;
1091#endif
1092
1093 idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id);
Govind Singh6b411b52016-03-06 19:55:02 +05301094 if (idx == -1) {
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301095 qdf_print("%s : event handler is not registered: evt id 0x%x\n",
1096 __func__, evt_id);
Govind Singhb53420c2016-03-09 14:32:57 +05301097 return QDF_STATUS_E_FAILURE;
Govind Singh6b411b52016-03-06 19:55:02 +05301098 }
1099 wmi_handle->event_handler[idx] = NULL;
1100 wmi_handle->event_id[idx] = 0;
1101 --wmi_handle->max_event_idx;
1102 wmi_handle->event_handler[idx] =
1103 wmi_handle->event_handler[wmi_handle->max_event_idx];
1104 wmi_handle->event_id[idx] =
1105 wmi_handle->event_id[wmi_handle->max_event_idx];
1106
1107 return 0;
1108}
1109
1110/**
Govind Singhd52faac2016-03-09 12:03:29 +05301111 * wmi_process_fw_event_default_ctx() - process in default caller context
Govind Singh6b411b52016-03-06 19:55:02 +05301112 * @wmi_handle: handle to wmi
1113 * @htc_packet: pointer to htc packet
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301114 * @exec_ctx: execution context for wmi fw event
Govind Singh6b411b52016-03-06 19:55:02 +05301115 *
Govind Singhd52faac2016-03-09 12:03:29 +05301116 * Event process by below function will be in default caller context.
1117 * wmi internally provides rx work thread processing context.
Govind Singh6b411b52016-03-06 19:55:02 +05301118 *
1119 * Return: none
1120 */
Govind Singhd52faac2016-03-09 12:03:29 +05301121static void wmi_process_fw_event_default_ctx(struct wmi_unified *wmi_handle,
1122 HTC_PACKET *htc_packet, uint8_t exec_ctx)
Govind Singh6b411b52016-03-06 19:55:02 +05301123{
1124 wmi_buf_t evt_buf;
1125 evt_buf = (wmi_buf_t) htc_packet->pPktContext;
1126
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301127#ifdef WMI_NON_TLV_SUPPORT
1128 wmi_handle->rx_ops.wma_process_fw_event_handler_cbk
1129 (wmi_handle->scn_handle, evt_buf, exec_ctx);
1130#else
Govind Singh5eb51532016-03-09 11:34:12 +05301131 wmi_handle->rx_ops.wma_process_fw_event_handler_cbk(wmi_handle,
Govind Singhd52faac2016-03-09 12:03:29 +05301132 evt_buf, exec_ctx);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301133#endif
Govind Singhd52faac2016-03-09 12:03:29 +05301134
Govind Singh6b411b52016-03-06 19:55:02 +05301135 return;
1136}
1137
1138/**
1139 * wmi_process_fw_event_worker_thread_ctx() - process in worker thread context
1140 * @wmi_handle: handle to wmi
1141 * @htc_packet: pointer to htc packet
1142 *
1143 * Event process by below function will be in worker thread context.
1144 * Use this method for events which are not critical and not
1145 * handled in protocol stack.
1146 *
1147 * Return: none
1148 */
1149static void wmi_process_fw_event_worker_thread_ctx
1150 (struct wmi_unified *wmi_handle, HTC_PACKET *htc_packet)
1151{
1152 wmi_buf_t evt_buf;
1153 uint32_t id;
1154 uint8_t *data;
1155
1156 evt_buf = (wmi_buf_t) htc_packet->pPktContext;
Govind Singhb53420c2016-03-09 14:32:57 +05301157 id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
1158 data = qdf_nbuf_data(evt_buf);
Govind Singh6b411b52016-03-06 19:55:02 +05301159
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301160#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +05301161 qdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301162 /* Exclude 4 bytes of TLV header */
1163 WMI_RX_EVENT_RECORD(id, ((uint8_t *) data + 4));
Govind Singhb53420c2016-03-09 14:32:57 +05301164 qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301165#endif
Govind Singhb53420c2016-03-09 14:32:57 +05301166 qdf_spin_lock_bh(&wmi_handle->eventq_lock);
1167 qdf_nbuf_queue_add(&wmi_handle->event_queue, evt_buf);
1168 qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301169 schedule_work(&wmi_handle->rx_event_work);
1170 return;
1171}
1172
1173/**
Govind Singhd52faac2016-03-09 12:03:29 +05301174 * wmi_control_rx() - process fw events callbacks
Govind Singh6b411b52016-03-06 19:55:02 +05301175 * @ctx: handle to wmi
1176 * @htc_packet: pointer to htc packet
1177 *
Govind Singh6b411b52016-03-06 19:55:02 +05301178 * Return: none
1179 */
1180void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet)
1181{
1182 struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx;
1183 wmi_buf_t evt_buf;
1184 uint32_t id;
Govind Singhd52faac2016-03-09 12:03:29 +05301185 uint32_t idx = 0;
1186 enum wmi_rx_exec_ctx exec_ctx;
Govind Singh6b411b52016-03-06 19:55:02 +05301187
1188 evt_buf = (wmi_buf_t) htc_packet->pPktContext;
Govind Singhb53420c2016-03-09 14:32:57 +05301189 id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
Govind Singhd52faac2016-03-09 12:03:29 +05301190 idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
Govind Singhb53420c2016-03-09 14:32:57 +05301191 if (qdf_unlikely(idx == A_ERROR)) {
1192 qdf_print
Govind Singhd52faac2016-03-09 12:03:29 +05301193 ("%s :event handler is not registered: event id 0x%x\n",
1194 __func__, id);
Govind Singhb53420c2016-03-09 14:32:57 +05301195 qdf_nbuf_free(evt_buf);
Govind Singhd52faac2016-03-09 12:03:29 +05301196 return;
1197 }
Govind Singh813fdac2016-03-12 09:26:52 +05301198 qdf_spin_lock_bh(&wmi_handle->ctx_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301199 exec_ctx = wmi_handle->ctx[idx];
Govind Singh813fdac2016-03-12 09:26:52 +05301200 qdf_spin_unlock_bh(&wmi_handle->ctx_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301201
1202 if (exec_ctx == WMI_RX_WORK_CTX) {
Govind Singh6b411b52016-03-06 19:55:02 +05301203 wmi_process_fw_event_worker_thread_ctx
1204 (wmi_handle, htc_packet);
Govind Singhd52faac2016-03-09 12:03:29 +05301205 } else if (exec_ctx > WMI_RX_WORK_CTX) {
1206 wmi_process_fw_event_default_ctx
1207 (wmi_handle, htc_packet, exec_ctx);
1208 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05301209 qdf_print("%s :Invalid event context %d\n", __func__, exec_ctx);
1210 qdf_nbuf_free(evt_buf);
Govind Singh6b411b52016-03-06 19:55:02 +05301211 }
Govind Singhd52faac2016-03-09 12:03:29 +05301212
Govind Singh6b411b52016-03-06 19:55:02 +05301213}
1214
1215/**
1216 * wmi_process_fw_event() - process any fw event
1217 * @wmi_handle: wmi handle
1218 * @evt_buf: fw event buffer
1219 *
Govind Singhd52faac2016-03-09 12:03:29 +05301220 * This function process fw event in caller context
Govind Singh6b411b52016-03-06 19:55:02 +05301221 *
1222 * Return: none
1223 */
1224void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
1225{
1226 __wmi_control_rx(wmi_handle, evt_buf);
1227}
1228
1229/**
1230 * __wmi_control_rx() - process serialize wmi event callback
1231 * @wmi_handle: wmi handle
1232 * @evt_buf: fw event buffer
1233 *
1234 * Return: none
1235 */
1236void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
1237{
1238 uint32_t id;
1239 uint8_t *data;
1240 uint32_t len;
1241 void *wmi_cmd_struct_ptr = NULL;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301242#ifndef WMI_NON_TLV_SUPPORT
Govind Singh6b411b52016-03-06 19:55:02 +05301243 int tlv_ok_status = 0;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301244#endif
Govind Singhd52faac2016-03-09 12:03:29 +05301245 uint32_t idx = 0;
Govind Singh6b411b52016-03-06 19:55:02 +05301246
Govind Singhb53420c2016-03-09 14:32:57 +05301247 id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
Govind Singh6b411b52016-03-06 19:55:02 +05301248
Govind Singhb53420c2016-03-09 14:32:57 +05301249 if (qdf_nbuf_pull_head(evt_buf, sizeof(WMI_CMD_HDR)) == NULL)
Govind Singh6b411b52016-03-06 19:55:02 +05301250 goto end;
1251
Govind Singhb53420c2016-03-09 14:32:57 +05301252 data = qdf_nbuf_data(evt_buf);
1253 len = qdf_nbuf_len(evt_buf);
Govind Singh6b411b52016-03-06 19:55:02 +05301254
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301255#ifndef WMI_NON_TLV_SUPPORT
1256 if (wmi_handle->target_type == WMI_TLV_TARGET) {
1257 /* Validate and pad(if necessary) the TLVs */
1258 tlv_ok_status =
1259 wmitlv_check_and_pad_event_tlvs(wmi_handle->scn_handle,
Govind Singh6b411b52016-03-06 19:55:02 +05301260 data, len, id,
1261 &wmi_cmd_struct_ptr);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301262 if (tlv_ok_status != 0) {
1263 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
1264 "%s: Error: id=0x%d, wmitlv check status=%d\n",
1265 __func__, id, tlv_ok_status);
1266 goto end;
1267 }
Govind Singh6b411b52016-03-06 19:55:02 +05301268 }
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301269#endif
Govind Singh6b411b52016-03-06 19:55:02 +05301270
Govind Singhd52faac2016-03-09 12:03:29 +05301271 idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
1272 if (idx == A_ERROR) {
Govind Singhb53420c2016-03-09 14:32:57 +05301273 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
Govind Singhd52faac2016-03-09 12:03:29 +05301274 "%s : event handler is not registered: event id 0x%x\n",
1275 __func__, id);
Govind Singh6b411b52016-03-06 19:55:02 +05301276 goto end;
1277 }
Govind Singhd52faac2016-03-09 12:03:29 +05301278#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +05301279 qdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301280 /* Exclude 4 bytes of TLV header */
1281 if (id == WMI_MGMT_TX_COMPLETION_EVENTID) {
1282 WMI_MGMT_EVENT_RECORD(id, ((uint8_t *) data + 4));
1283 } else {
1284 WMI_EVENT_RECORD(id, ((uint8_t *) data + 4));
Govind Singh6b411b52016-03-06 19:55:02 +05301285 }
Govind Singhb53420c2016-03-09 14:32:57 +05301286 qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
Govind Singhd52faac2016-03-09 12:03:29 +05301287#endif
1288 /* Call the WMI registered event handler */
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301289 if (wmi_handle->target_type == WMI_TLV_TARGET)
1290 wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
1291 wmi_cmd_struct_ptr, len);
1292 else
1293 wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
1294 data, len);
Govind Singhd52faac2016-03-09 12:03:29 +05301295
Govind Singh6b411b52016-03-06 19:55:02 +05301296end:
Govind Singhd52faac2016-03-09 12:03:29 +05301297 /* Free event buffer and allocated event tlv */
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301298#ifndef WMI_NON_TLV_SUPPORT
1299 if (wmi_handle->target_type == WMI_TLV_TARGET)
1300 wmitlv_free_allocated_event_tlvs(id, &wmi_cmd_struct_ptr);
1301#endif
Govind Singhb53420c2016-03-09 14:32:57 +05301302 qdf_nbuf_free(evt_buf);
Govind Singhd52faac2016-03-09 12:03:29 +05301303
Govind Singh6b411b52016-03-06 19:55:02 +05301304}
1305
1306/**
1307 * wmi_rx_event_work() - process rx event in rx work queue context
1308 * @work: rx work queue struct
1309 *
1310 * This function process any fw event to serialize it through rx worker thread.
1311 *
1312 * Return: none
1313 */
1314void wmi_rx_event_work(struct work_struct *work)
1315{
1316 struct wmi_unified *wmi = container_of(work, struct wmi_unified,
1317 rx_event_work);
1318 wmi_buf_t buf;
1319
Govind Singhb53420c2016-03-09 14:32:57 +05301320 qdf_spin_lock_bh(&wmi->eventq_lock);
1321 buf = qdf_nbuf_queue_remove(&wmi->event_queue);
1322 qdf_spin_unlock_bh(&wmi->eventq_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301323 while (buf) {
1324 __wmi_control_rx(wmi, buf);
Govind Singhb53420c2016-03-09 14:32:57 +05301325 qdf_spin_lock_bh(&wmi->eventq_lock);
1326 buf = qdf_nbuf_queue_remove(&wmi->event_queue);
1327 qdf_spin_unlock_bh(&wmi->eventq_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301328 }
1329}
1330
Govind Singh6b411b52016-03-06 19:55:02 +05301331#ifdef FEATURE_RUNTIME_PM
1332/**
1333 * wmi_runtime_pm_init() - initialize runtime pm wmi variables
1334 * @wmi_handle: wmi context
1335 */
Govind Singhd52faac2016-03-09 12:03:29 +05301336static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
Govind Singh6b411b52016-03-06 19:55:02 +05301337{
Govind Singhb53420c2016-03-09 14:32:57 +05301338 qdf_atomic_init(&wmi_handle->runtime_pm_inprogress);
Govind Singh6b411b52016-03-06 19:55:02 +05301339}
Govind Singhd52faac2016-03-09 12:03:29 +05301340
1341/**
1342 * wmi_set_runtime_pm_inprogress() - set runtime pm progress flag
1343 * @wmi_handle: wmi context
1344 * @val: runtime pm progress flag
1345 */
1346void wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, A_BOOL val)
1347{
Govind Singhb53420c2016-03-09 14:32:57 +05301348 qdf_atomic_set(&wmi_handle->runtime_pm_inprogress, val);
Govind Singhd52faac2016-03-09 12:03:29 +05301349}
1350
1351/**
1352 * wmi_get_runtime_pm_inprogress() - get runtime pm progress flag
1353 * @wmi_handle: wmi context
1354 */
1355inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle)
1356{
Govind Singhb53420c2016-03-09 14:32:57 +05301357 return qdf_atomic_read(&wmi_handle->runtime_pm_inprogress);
Govind Singhd52faac2016-03-09 12:03:29 +05301358}
Govind Singh6b411b52016-03-06 19:55:02 +05301359#else
Govind Singhd52faac2016-03-09 12:03:29 +05301360static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
Govind Singh6b411b52016-03-06 19:55:02 +05301361{
1362}
1363#endif
1364
1365/**
1366 * wmi_unified_attach() - attach for unified WMI
Govind Singhc458f382016-02-04 18:42:30 +05301367 * @scn_handle: handle to SCN
1368 * @osdev: OS device context
1369 * @target_type: TLV or not-TLV based target
1370 * @use_cookie: cookie based allocation enabled/disabled
1371 * @ops: umac rx callbacks
Govind Singh6b411b52016-03-06 19:55:02 +05301372 *
1373 * @Return: wmi handle.
1374 */
Govind Singhc458f382016-02-04 18:42:30 +05301375void *wmi_unified_attach(void *scn_handle,
1376 osdev_t osdev, enum wmi_target_type target_type,
Govind Singh5eb51532016-03-09 11:34:12 +05301377 bool use_cookie, struct wmi_rx_ops *rx_ops)
Govind Singh6b411b52016-03-06 19:55:02 +05301378{
1379 struct wmi_unified *wmi_handle;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301380
1381#ifndef WMI_NON_TLV_SUPPORT
Govind Singh6b411b52016-03-06 19:55:02 +05301382 wmi_handle =
1383 (struct wmi_unified *)os_malloc(NULL,
1384 sizeof(struct wmi_unified),
1385 GFP_ATOMIC);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301386#else
1387 wmi_handle =
1388 (struct wmi_unified *) qdf_mem_malloc(
1389 sizeof(struct wmi_unified));
1390#endif
Govind Singh6b411b52016-03-06 19:55:02 +05301391 if (wmi_handle == NULL) {
Govind Singhb53420c2016-03-09 14:32:57 +05301392 qdf_print("allocation of wmi handle failed %zu\n",
Govind Singhd52faac2016-03-09 12:03:29 +05301393 sizeof(struct wmi_unified));
Govind Singh6b411b52016-03-06 19:55:02 +05301394 return NULL;
1395 }
1396 OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified));
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301397 wmi_handle->scn_handle = scn_handle;
Govind Singhb53420c2016-03-09 14:32:57 +05301398 qdf_atomic_init(&wmi_handle->pending_cmds);
1399 qdf_atomic_init(&wmi_handle->is_target_suspended);
Govind Singh6b411b52016-03-06 19:55:02 +05301400 wmi_runtime_pm_init(wmi_handle);
Govind Singhb53420c2016-03-09 14:32:57 +05301401 qdf_spinlock_create(&wmi_handle->eventq_lock);
1402 qdf_nbuf_queue_init(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301403#ifdef CONFIG_CNSS
1404 cnss_init_work(&wmi_handle->rx_event_work, wmi_rx_event_work);
1405#else
1406 INIT_WORK(&wmi_handle->rx_event_work, wmi_rx_event_work);
1407#endif
1408#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +05301409 qdf_spinlock_create(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301410#endif
Govind Singhc458f382016-02-04 18:42:30 +05301411 /* Attach mc_thread context processing function */
Govind Singh5eb51532016-03-09 11:34:12 +05301412 wmi_handle->rx_ops.wma_process_fw_event_handler_cbk =
1413 rx_ops->wma_process_fw_event_handler_cbk;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301414 wmi_handle->target_type = target_type;
Govind Singhc458f382016-02-04 18:42:30 +05301415 if (target_type == WMI_TLV_TARGET)
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301416 wmi_tlv_attach(wmi_handle);
Govind Singhc458f382016-02-04 18:42:30 +05301417 else
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301418 wmi_non_tlv_attach(wmi_handle);
Govind Singhc458f382016-02-04 18:42:30 +05301419 /* Assign target cookie capablity */
1420 wmi_handle->use_cookie = use_cookie;
1421 wmi_handle->osdev = osdev;
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301422 wmi_handle->wmi_stopinprogress = 0;
Govind Singh813fdac2016-03-12 09:26:52 +05301423 qdf_spinlock_create(&wmi_handle->ctx_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301424
1425 return wmi_handle;
1426}
1427
1428/**
1429 * wmi_unified_detach() - detach for unified WMI
1430 *
1431 * @wmi_handle : handle to wmi.
1432 *
1433 * @Return: none.
1434 */
1435void wmi_unified_detach(struct wmi_unified *wmi_handle)
1436{
1437 wmi_buf_t buf;
1438
Govind Singhb53420c2016-03-09 14:32:57 +05301439 cancel_work_sync(&wmi_handle->rx_event_work);
1440 qdf_spin_lock_bh(&wmi_handle->eventq_lock);
1441 buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301442 while (buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301443 qdf_nbuf_free(buf);
1444 buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301445 }
Govind Singhb53420c2016-03-09 14:32:57 +05301446 qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
Govind Singh813fdac2016-03-12 09:26:52 +05301447 qdf_spinlock_destroy(&wmi_handle->ctx_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301448 if (wmi_handle != NULL) {
1449 OS_FREE(wmi_handle);
1450 wmi_handle = NULL;
1451 }
1452}
1453
1454/**
1455 * wmi_unified_remove_work() - detach for WMI work
1456 * @wmi_handle: handle to WMI
1457 *
1458 * A function that does not fully detach WMI, but just remove work
1459 * queue items associated with it. This is used to make sure that
1460 * before any other processing code that may destroy related contexts
1461 * (HTC, etc), work queue processing on WMI has already been stopped.
1462 *
1463 * Return: None
1464 */
1465void
1466wmi_unified_remove_work(struct wmi_unified *wmi_handle)
1467{
1468 wmi_buf_t buf;
1469
Govind Singhb53420c2016-03-09 14:32:57 +05301470 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh6b411b52016-03-06 19:55:02 +05301471 "Enter: %s", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05301472 cancel_work_sync(&wmi_handle->rx_event_work);
1473 qdf_spin_lock_bh(&wmi_handle->eventq_lock);
1474 buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301475 while (buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301476 qdf_nbuf_free(buf);
1477 buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
Govind Singh6b411b52016-03-06 19:55:02 +05301478 }
Govind Singhb53420c2016-03-09 14:32:57 +05301479 qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
1480 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Govind Singh6b411b52016-03-06 19:55:02 +05301481 "Done: %s", __func__);
1482}
1483
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301484/**
1485 * wmi_htc_tx_complete() - Process htc tx completion
1486 *
1487 * @ctx: handle to wmi
1488 * @htc_packet: pointer to htc packet
1489 *
1490 * @Return: none.
1491 */
Govind Singh6b411b52016-03-06 19:55:02 +05301492void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt)
1493{
1494 struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx;
1495 wmi_buf_t wmi_cmd_buf = GET_HTC_PACKET_NET_BUF_CONTEXT(htc_pkt);
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301496
Govind Singh6b411b52016-03-06 19:55:02 +05301497#ifdef WMI_INTERFACE_EVENT_LOGGING
1498 uint32_t cmd_id;
1499#endif
1500
1501 ASSERT(wmi_cmd_buf);
1502#ifdef WMI_INTERFACE_EVENT_LOGGING
Govind Singhb53420c2016-03-09 14:32:57 +05301503 cmd_id = WMI_GET_FIELD(qdf_nbuf_data(wmi_cmd_buf),
Govind Singh6b411b52016-03-06 19:55:02 +05301504 WMI_CMD_HDR, COMMANDID);
1505
1506#ifdef QCA_WIFI_3_0_EMU
Govind Singhb53420c2016-03-09 14:32:57 +05301507 qdf_print
Govind Singh6b411b52016-03-06 19:55:02 +05301508 ("\nSent WMI command:%s command_id:0x%x over dma and recieved tx complete interupt\n",
1509 get_wmi_cmd_string(cmd_id), cmd_id);
1510#endif
1511
Govind Singhb53420c2016-03-09 14:32:57 +05301512 qdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301513 /* Record 16 bytes of WMI cmd tx complete data
1514 - exclude TLV and WMI headers */
1515 if (cmd_id == WMI_MGMT_TX_SEND_CMDID) {
1516 WMI_MGMT_COMMAND_TX_CMP_RECORD(cmd_id,
Govind Singhb53420c2016-03-09 14:32:57 +05301517 ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) + 2));
Govind Singh6b411b52016-03-06 19:55:02 +05301518 } else {
1519 WMI_COMMAND_TX_CMP_RECORD(cmd_id,
Govind Singhb53420c2016-03-09 14:32:57 +05301520 ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) + 2));
Govind Singh6b411b52016-03-06 19:55:02 +05301521 }
1522
Govind Singhb53420c2016-03-09 14:32:57 +05301523 qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
Govind Singh6b411b52016-03-06 19:55:02 +05301524#endif
Govind Singhb53420c2016-03-09 14:32:57 +05301525 qdf_nbuf_free(wmi_cmd_buf);
1526 qdf_mem_free(htc_pkt);
1527 qdf_atomic_dec(&wmi_handle->pending_cmds);
Govind Singh6b411b52016-03-06 19:55:02 +05301528}
1529
1530/**
1531 * wmi_get_host_credits() - WMI API to get updated host_credits
1532 *
1533 * @wmi_handle: handle to WMI.
1534 *
1535 * @Return: updated host_credits.
1536 */
1537int
1538wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle,
1539 void *htc_handle)
1540{
1541
1542 int status;
1543 HTC_SERVICE_CONNECT_RESP response;
1544 HTC_SERVICE_CONNECT_REQ connect;
1545
1546 OS_MEMZERO(&connect, sizeof(connect));
1547 OS_MEMZERO(&response, sizeof(response));
1548
1549 /* meta data is unused for now */
1550 connect.pMetaData = NULL;
1551 connect.MetaDataLength = 0;
1552 /* these fields are the same for all service endpoints */
1553 connect.EpCallbacks.pContext = wmi_handle;
1554 connect.EpCallbacks.EpTxCompleteMultiple =
1555 NULL /* Control path completion ar6000_tx_complete */;
1556 connect.EpCallbacks.EpRecv = wmi_control_rx /* Control path rx */;
1557 connect.EpCallbacks.EpRecvRefill = NULL /* ar6000_rx_refill */;
1558 connect.EpCallbacks.EpSendFull = NULL /* ar6000_tx_queue_full */;
1559 connect.EpCallbacks.EpTxComplete =
1560 wmi_htc_tx_complete /* ar6000_tx_queue_full */;
1561
1562 /* connect to control service */
1563 connect.service_id = WMI_CONTROL_SVC;
1564 status = htc_connect_service(htc_handle, &connect,
1565 &response);
1566
1567 if (status != EOK) {
Govind Singhb53420c2016-03-09 14:32:57 +05301568 qdf_print
Govind Singh6b411b52016-03-06 19:55:02 +05301569 ("Failed to connect to WMI CONTROL service status:%d \n",
1570 status);
1571 return status;
1572 }
1573 wmi_handle->wmi_endpoint_id = response.Endpoint;
1574 wmi_handle->htc_handle = htc_handle;
1575 wmi_handle->max_msg_len = response.MaxMsgLength;
1576
1577 return EOK;
1578}
1579
1580/**
1581 * wmi_get_host_credits() - WMI API to get updated host_credits
1582 *
1583 * @wmi_handle: handle to WMI.
1584 *
1585 * @Return: updated host_credits.
1586 */
1587int wmi_get_host_credits(wmi_unified_t wmi_handle)
1588{
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301589 int host_credits = 0;
Govind Singh6b411b52016-03-06 19:55:02 +05301590
1591 htc_get_control_endpoint_tx_host_credits(wmi_handle->htc_handle,
1592 &host_credits);
1593 return host_credits;
1594}
1595
1596/**
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301597 * wmi_get_pending_cmds() - WMI API to get WMI Pending Commands in the HTC
1598 * queue
Govind Singh6b411b52016-03-06 19:55:02 +05301599 *
1600 * @wmi_handle: handle to WMI.
1601 *
1602 * @Return: Pending Commands in the HTC queue.
1603 */
1604int wmi_get_pending_cmds(wmi_unified_t wmi_handle)
1605{
Govind Singhb53420c2016-03-09 14:32:57 +05301606 return qdf_atomic_read(&wmi_handle->pending_cmds);
Govind Singh6b411b52016-03-06 19:55:02 +05301607}
1608
1609/**
1610 * wmi_set_target_suspend() - WMI API to set target suspend state
1611 *
1612 * @wmi_handle: handle to WMI.
1613 * @val: suspend state boolean.
1614 *
1615 * @Return: none.
1616 */
1617void wmi_set_target_suspend(wmi_unified_t wmi_handle, A_BOOL val)
1618{
Govind Singhb53420c2016-03-09 14:32:57 +05301619 qdf_atomic_set(&wmi_handle->is_target_suspended, val);
Govind Singh6b411b52016-03-06 19:55:02 +05301620}
1621
Govind Singhe7d9f3e2016-04-15 13:58:27 +05301622#ifdef WMI_NON_TLV_SUPPORT
1623/**
1624 * API to flush all the previous packets associated with the wmi endpoint
1625 *
1626 * @param wmi_handle : handle to WMI.
1627 */
1628void
1629wmi_flush_endpoint(wmi_unified_t wmi_handle)
1630{
1631 htc_flush_endpoint(wmi_handle->htc_handle,
1632 wmi_handle->wmi_endpoint_id, 0);
1633}
1634
1635/**
1636 * generic function to block unified WMI command
1637 * @param wmi_handle : handle to WMI.
1638 * @return 0 on success and -ve on failure.
1639 */
1640int
1641wmi_stop(wmi_unified_t wmi_handle)
1642{
1643 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
1644 "WMI Stop\n");
1645 wmi_handle->wmi_stopinprogress = 1;
1646 return 0;
1647}
1648#endif