blob: 1d8fc77cb422be4e04567ab314bfd2d10905e181 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jeff Johnson199e7012016-12-16 14:55:42 -08002 * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
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 * DOC: wma_main.c
30 *
31 * This file contains wma initialization and FW exchange
32 * related functions.
33 */
34
35/* Header files */
36
37#include "wma.h"
38#include "wma_api.h"
39#include "cds_api.h"
40#include "wmi_unified_api.h"
41#include "wlan_qct_sys.h"
42#include "wni_api.h"
43#include "ani_global.h"
44#include "wmi_unified.h"
45#include "wni_cfg.h"
46#include "cfg_api.h"
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +053047#if defined(CONFIG_HL_SUPPORT)
48#include "wlan_tgt_def_config_hl.h"
49#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "wlan_tgt_def_config.h"
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +053051#endif
Nirav Shahcbc6d722016-03-01 16:24:53 +053052#include "qdf_nbuf.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053053#include "qdf_types.h"
Anurag Chouhan600c3a02016-03-01 10:33:54 +053054#include "qdf_mem.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055
56#include "wma_types.h"
57#include "lim_api.h"
58#include "lim_session_utils.h"
59
60#include "cds_utils.h"
61
62#if !defined(REMOVE_PKT_LOG)
63#include "pktlog_ac.h"
64#endif /* REMOVE_PKT_LOG */
65
66#include "dbglog_host.h"
Govind Singhd76a5b02016-03-08 15:12:14 +053067#include "wmi_version_whitelist.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068#include "csr_api.h"
69#include "ol_fw.h"
70
71#include "dfs.h"
72#include "wma_internal.h"
73
74#include "wma_ocb.h"
Chandrasekaran, Manishekar0d814c72015-11-05 10:42:48 +053075#include "cds_concurrency.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080076#include "cdp_txrx_cfg.h"
77#include "cdp_txrx_flow_ctrl_legacy.h"
78#include "cdp_txrx_flow_ctrl_v2.h"
79#include "cdp_txrx_ipa.h"
Leo Chang96464902016-10-28 11:10:54 -070080#include "cdp_txrx_misc.h"
Deepak Dhamdhere13230d32016-05-26 00:46:53 -070081#include "wma_nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082
Frank Liu65b17d92016-11-23 15:58:44 +080083#ifdef WLAN_CONVERGED_INTERFACE
84#include "wlan_lmac_if_def.h"
85#include "wlan_lmac_if_api.h"
86#endif
87
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088#define WMA_LOG_COMPLETION_TIMER 10000 /* 10 seconds */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +053090#define WMI_TLV_HEADROOM 128
91
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092static uint32_t g_fw_wlan_feat_caps;
93
94/**
95 * wma_get_fw_wlan_feat_caps() - get fw feature capablity
96 * @featEnumValue: feature enum value
97 *
98 * Return: true/false
99 */
100uint8_t wma_get_fw_wlan_feat_caps(uint8_t featEnumValue)
101{
102 return (g_fw_wlan_feat_caps & (1 << featEnumValue)) ? true : false;
103}
104
105/**
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530106 * wma_service_ready_ext_evt_timeout() - Service ready extended event timeout
107 * @data: Timeout handler data
108 *
109 * This function is called when the FW fails to send WMI_SERVICE_READY_EXT_EVENT
110 * message
111 *
112 * Return: None
113 */
114static void wma_service_ready_ext_evt_timeout(void *data)
115{
116 tp_wma_handle wma_handle;
117
118 WMA_LOGA("%s: Timeout waiting for WMI_SERVICE_READY_EXT_EVENT",
119 __func__);
120
121 wma_handle = (tp_wma_handle) data;
122
123 if (!wma_handle) {
124 WMA_LOGE("%s: Invalid WMA handle", __func__);
125 goto end;
126 }
127
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530128end:
Naveen Rawatac39a102016-10-07 10:58:29 -0700129 /* Assert here. Panic is being called in insmod thread */
130 QDF_ASSERT(0);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530131}
132
133/**
Komal Seelam02d09342016-02-23 18:03:19 +0530134 * wma_get_ini_handle() - API to get WMA ini info handle
135 * @wma: WMA Handle
136 *
137 * Returns the pointer to WMA ini structure.
138 * Return: struct wma_ini_config
139 */
140struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma)
141{
142 if (!wma) {
143 WMA_LOGE("%s: Invalid WMA context\n", __func__);
144 return NULL;
145 }
146
147 return &wma->ini_config;
148}
149
150#define MAX_SUPPORTED_PEERS_REV1_1 14
151#define MAX_SUPPORTED_PEERS_REV1_3 32
152#define MIN_NO_OF_PEERS 1
153
154/**
155 * wma_get_number_of_peers_supported - API to query for number of peers
156 * supported
157 * @wma: WMA Handle
158 *
159 * Return: Max Number of Peers Supported
160 */
161static uint8_t wma_get_number_of_peers_supported(tp_wma_handle wma)
162{
163 struct hif_target_info *tgt_info;
164 struct wma_ini_config *cfg = wma_get_ini_handle(wma);
165 uint8_t max_no_of_peers = cfg ? cfg->max_no_of_peers : MIN_NO_OF_PEERS;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530166 struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF);
Komal Seelam02d09342016-02-23 18:03:19 +0530167
168 if (!scn) {
169 WMA_LOGE("%s: Invalid wma handle", __func__);
170 return 0;
171 }
172
173 tgt_info = hif_get_target_info_handle(scn);
174
175 switch (tgt_info->target_version) {
176 case AR6320_REV1_1_VERSION:
177 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_1)
178 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_1;
179 break;
180 default:
181 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_3)
182 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_3;
183 break;
184 }
185
186 return max_no_of_peers;
187}
188
189/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800190 * wma_set_default_tgt_config() - set default tgt config
191 * @wma_handle: wma handle
192 *
193 * Return: none
194 */
195static void wma_set_default_tgt_config(tp_wma_handle wma_handle)
196{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197 uint8_t no_of_peers_supported;
198 wmi_resource_config tgt_cfg = {
199 0, /* Filling zero for TLV Tag and Length fields */
200 CFG_TGT_NUM_VDEV,
201 CFG_TGT_NUM_PEERS + CFG_TGT_NUM_VDEV + 2,
202 CFG_TGT_NUM_OFFLOAD_PEERS,
203 CFG_TGT_NUM_OFFLOAD_REORDER_BUFFS,
204 CFG_TGT_NUM_PEER_KEYS,
205 CFG_TGT_NUM_TIDS,
206 CFG_TGT_AST_SKID_LIMIT,
207 CFG_TGT_DEFAULT_TX_CHAIN_MASK,
208 CFG_TGT_DEFAULT_RX_CHAIN_MASK,
209 {CFG_TGT_RX_TIMEOUT_LO_PRI, CFG_TGT_RX_TIMEOUT_LO_PRI,
210 CFG_TGT_RX_TIMEOUT_LO_PRI, CFG_TGT_RX_TIMEOUT_HI_PRI},
211 CFG_TGT_RX_DECAP_MODE,
212 CFG_TGT_DEFAULT_SCAN_MAX_REQS,
213 CFG_TGT_DEFAULT_BMISS_OFFLOAD_MAX_VDEV,
214 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_VDEV,
215 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_PROFILES,
216 CFG_TGT_DEFAULT_NUM_MCAST_GROUPS,
217 CFG_TGT_DEFAULT_NUM_MCAST_TABLE_ELEMS,
218 CFG_TGT_DEFAULT_MCAST2UCAST_MODE,
219 CFG_TGT_DEFAULT_TX_DBG_LOG_SIZE,
220 CFG_TGT_WDS_ENTRIES,
221 CFG_TGT_DEFAULT_DMA_BURST_SIZE,
222 CFG_TGT_DEFAULT_MAC_AGGR_DELIM,
223 CFG_TGT_DEFAULT_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK,
224 CFG_TGT_DEFAULT_VOW_CONFIG,
225 CFG_TGT_DEFAULT_GTK_OFFLOAD_MAX_VDEV,
226 CFG_TGT_NUM_MSDU_DESC,
227 CFG_TGT_MAX_FRAG_TABLE_ENTRIES,
228 CFG_TGT_NUM_TDLS_VDEVS,
229 CFG_TGT_NUM_TDLS_CONN_TABLE_ENTRIES,
230 CFG_TGT_DEFAULT_BEACON_TX_OFFLOAD_MAX_VDEV,
231 CFG_TGT_MAX_MULTICAST_FILTER_ENTRIES,
232 0,
233 0,
234 0,
235 CFG_TGT_NUM_TDLS_CONC_SLEEP_STAS,
236 CFG_TGT_NUM_TDLS_CONC_BUFFER_STAS,
237 0,
238 CFG_TGT_NUM_OCB_VDEVS,
239 CFG_TGT_NUM_OCB_CHANNELS,
240 CFG_TGT_NUM_OCB_SCHEDULES,
241 };
242
Komal Seelam02d09342016-02-23 18:03:19 +0530243 no_of_peers_supported = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 tgt_cfg.num_peers = no_of_peers_supported + CFG_TGT_NUM_VDEV + 2;
245 tgt_cfg.num_tids = (2 * (no_of_peers_supported + CFG_TGT_NUM_VDEV + 2));
246 tgt_cfg.scan_max_pending_req = wma_handle->max_scan;
247
Nirav Shah20489972016-06-16 19:20:28 +0530248 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(tgt_cfg.flag1, 1);
Yun Park4d968df2016-10-11 11:44:15 -0700249 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(tgt_cfg.flag1,
250 1);
Nirav Shah20489972016-06-16 19:20:28 +0530251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 WMITLV_SET_HDR(&tgt_cfg.tlv_header,
253 WMITLV_TAG_STRUC_wmi_resource_config,
254 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
255 /* reduce the peer/vdev if CFG_TGT_NUM_MSDU_DESC exceeds 1000 */
256#ifdef PERE_IP_HDR_ALIGNMENT_WAR
257 if (scn->host_80211_enable) {
258 /*
259 * To make the IP header begins at dword aligned address,
260 * we make the decapsulation mode as Native Wifi.
261 */
262 tgt_cfg.rx_decap_mode = CFG_TGT_RX_DECAP_MODE_NWIFI;
263 }
264#endif /* PERE_IP_HDR_ALIGNMENT_WAR */
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700265 if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam())
266 tgt_cfg.rx_decap_mode = CFG_TGT_RX_DECAP_MODE_RAW;
267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268 wma_handle->wlan_resource_config = tgt_cfg;
269}
270
271/**
272 * wma_cli_get_command() - WMA "get" command processor
273 * @vdev_id: virtual device for the command
274 * @param_id: parameter id
275 * @vpdev: parameter category
276 *
277 * Return: parameter value on success, -EINVAL on failure
278 */
279int wma_cli_get_command(int vdev_id, int param_id, int vpdev)
280{
281 int ret = 0;
282 tp_wma_handle wma;
283 struct wma_txrx_node *intr = NULL;
284
Anurag Chouhan6d760662016-02-20 16:05:43 +0530285 wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286
287 if (NULL == wma) {
288 WMA_LOGE("%s: Invalid wma handle", __func__);
289 return -EINVAL;
290 }
291
292 intr = wma->interfaces;
293
294 if (VDEV_CMD == vpdev) {
295 switch (param_id) {
296 case WMI_VDEV_PARAM_NSS:
297 ret = intr[vdev_id].config.nss;
298 break;
299#ifdef QCA_SUPPORT_GTX
300 case WMI_VDEV_PARAM_GTX_HT_MCS:
301 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
302 break;
303 case WMI_VDEV_PARAM_GTX_VHT_MCS:
304 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
305 break;
306 case WMI_VDEV_PARAM_GTX_USR_CFG:
307 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
308 break;
309 case WMI_VDEV_PARAM_GTX_THRE:
310 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
311 break;
312 case WMI_VDEV_PARAM_GTX_MARGIN:
313 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
314 break;
315 case WMI_VDEV_PARAM_GTX_STEP:
316 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
317 break;
318 case WMI_VDEV_PARAM_GTX_MINTPC:
319 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
320 break;
321 case WMI_VDEV_PARAM_GTX_BW_MASK:
322 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
323 break;
324#endif /* QCA_SUPPORT_GTX */
325 case WMI_VDEV_PARAM_LDPC:
326 ret = intr[vdev_id].config.ldpc;
327 break;
328 case WMI_VDEV_PARAM_TX_STBC:
329 ret = intr[vdev_id].config.tx_stbc;
330 break;
331 case WMI_VDEV_PARAM_RX_STBC:
332 ret = intr[vdev_id].config.rx_stbc;
333 break;
334 case WMI_VDEV_PARAM_SGI:
335 ret = intr[vdev_id].config.shortgi;
336 break;
337 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
338 ret = intr[vdev_id].config.rtscts_en;
339 break;
340 case WMI_VDEV_PARAM_CHWIDTH:
341 ret = intr[vdev_id].config.chwidth;
342 break;
343 case WMI_VDEV_PARAM_FIXED_RATE:
344 ret = intr[vdev_id].config.tx_rate;
345 break;
346 default:
347 WMA_LOGE("Invalid cli_get vdev command/Not"
348 " yet implemented 0x%x", param_id);
349 return -EINVAL;
350 }
351 } else if (PDEV_CMD == vpdev) {
352 switch (param_id) {
353 case WMI_PDEV_PARAM_ANI_ENABLE:
354 ret = wma->pdevconfig.ani_enable;
355 break;
356 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
357 ret = wma->pdevconfig.ani_poll_len;
358 break;
359 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
360 ret = wma->pdevconfig.ani_listen_len;
361 break;
362 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
363 ret = wma->pdevconfig.ani_ofdm_level;
364 break;
365 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
366 ret = wma->pdevconfig.ani_cck_level;
367 break;
368 case WMI_PDEV_PARAM_DYNAMIC_BW:
369 ret = wma->pdevconfig.cwmenable;
370 break;
371 case WMI_PDEV_PARAM_CTS_CBW:
372 ret = wma->pdevconfig.cts_cbw;
373 break;
374 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
375 ret = wma->pdevconfig.txchainmask;
376 break;
377 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
378 ret = wma->pdevconfig.rxchainmask;
379 break;
380 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
381 ret = wma->pdevconfig.txpow2g;
382 break;
383 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
384 ret = wma->pdevconfig.txpow5g;
385 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 case WMI_PDEV_PARAM_BURST_ENABLE:
387 ret = wma->pdevconfig.burst_enable;
388 break;
389 case WMI_PDEV_PARAM_BURST_DUR:
390 ret = wma->pdevconfig.burst_dur;
391 break;
392 default:
393 WMA_LOGE("Invalid cli_get pdev command/Not"
394 " yet implemented 0x%x", param_id);
395 return -EINVAL;
396 }
397 } else if (GEN_CMD == vpdev) {
398 switch (param_id) {
399 case GEN_VDEV_PARAM_AMPDU:
400 ret = intr[vdev_id].config.ampdu;
401 break;
402 case GEN_VDEV_PARAM_AMSDU:
403 ret = intr[vdev_id].config.amsdu;
404 break;
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700405 case GEN_VDEV_ROAM_SYNCH_DELAY:
406 ret = intr[vdev_id].roam_synch_delay;
407 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 default:
409 WMA_LOGE("Invalid generic vdev command/Not"
410 " yet implemented 0x%x", param_id);
411 return -EINVAL;
412 }
413 } else if (PPS_CMD == vpdev) {
414 switch (param_id) {
415 case WMI_VDEV_PPS_PAID_MATCH:
416 ret = intr[vdev_id].config.pps_params.paid_match_enable;
417 break;
418 case WMI_VDEV_PPS_GID_MATCH:
419 ret = intr[vdev_id].config.pps_params.gid_match_enable;
420 break;
421 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
422 ret = intr[vdev_id].config.pps_params.tim_clear;
423 break;
424 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
425 ret = intr[vdev_id].config.pps_params.dtim_clear;
426 break;
427 case WMI_VDEV_PPS_EOF_PAD_DELIM:
428 ret = intr[vdev_id].config.pps_params.eof_delim;
429 break;
430 case WMI_VDEV_PPS_MACADDR_MISMATCH:
431 ret = intr[vdev_id].config.pps_params.mac_match;
432 break;
433 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
434 ret = intr[vdev_id].config.pps_params.delim_fail;
435 break;
436 case WMI_VDEV_PPS_GID_NSTS_ZERO:
437 ret = intr[vdev_id].config.pps_params.nsts_zero;
438 break;
439 case WMI_VDEV_PPS_RSSI_CHECK:
440 ret = intr[vdev_id].config.pps_params.rssi_chk;
441 break;
442 default:
443 WMA_LOGE("Invalid pps vdev command/Not"
444 " yet implemented 0x%x", param_id);
445 return -EINVAL;
446 }
447 } else if (QPOWER_CMD == vpdev) {
448 switch (param_id) {
449 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
450 ret = intr[vdev_id].config.qpower_params.
451 max_ps_poll_cnt;
452 break;
453 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
454 ret = intr[vdev_id].config.qpower_params.
455 max_tx_before_wake;
456 break;
457 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
458 ret = intr[vdev_id].config.qpower_params.
459 spec_ps_poll_wake_interval;
460 break;
461 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
462 ret = intr[vdev_id].config.qpower_params.
463 max_spec_nodata_ps_poll;
464 break;
465 default:
466 WMA_LOGE("Invalid generic vdev command/Not"
467 " yet implemented 0x%x", param_id);
468 return -EINVAL;
469 }
470 } else if (GTX_CMD == vpdev) {
471 switch (param_id) {
472 case WMI_VDEV_PARAM_GTX_HT_MCS:
473 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
474 break;
475 case WMI_VDEV_PARAM_GTX_VHT_MCS:
476 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
477 break;
478 case WMI_VDEV_PARAM_GTX_USR_CFG:
479 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
480 break;
481 case WMI_VDEV_PARAM_GTX_THRE:
482 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
483 break;
484 case WMI_VDEV_PARAM_GTX_MARGIN:
485 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
486 break;
487 case WMI_VDEV_PARAM_GTX_STEP:
488 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
489 break;
490 case WMI_VDEV_PARAM_GTX_MINTPC:
491 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
492 break;
493 case WMI_VDEV_PARAM_GTX_BW_MASK:
494 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
495 break;
496 default:
497 WMA_LOGE("Invalid generic vdev command/Not"
498 " yet implemented 0x%x", param_id);
499 return -EINVAL;
500 }
501 }
502 return ret;
503}
504
505/**
506 * wma_cli_set2_command() - WMA "set 2 params" command processor
507 * @vdev_id: virtual device for the command
508 * @param_id: parameter id
509 * @sval1: first parameter value
510 * @sval2: second parameter value
511 * @vpdev: parameter category
512 *
513 * Command handler for set operations which require 2 parameters
514 *
515 * Return: 0 on success, errno on failure
516 */
517int wma_cli_set2_command(int vdev_id, int param_id, int sval1,
518 int sval2, int vpdev)
519{
520 cds_msg_t msg = { 0 };
521 wma_cli_set_cmd_t *iwcmd;
522
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530523 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800524 if (!iwcmd) {
525 WMA_LOGE("%s: Failed alloc memory for iwcmd", __func__);
526 return -ENOMEM;
527 }
528
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530529 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 iwcmd->param_value = sval1;
531 iwcmd->param_sec_value = sval2;
532 iwcmd->param_vdev_id = vdev_id;
533 iwcmd->param_id = param_id;
534 iwcmd->param_vp_dev = vpdev;
535 msg.type = WMA_CLI_SET_CMD;
536 msg.reserved = 0;
537 msg.bodyptr = iwcmd;
538
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530539 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +0530540 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541 WMA_LOGP("%s: Failed to post WMA_CLI_SET_CMD msg",
542 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530543 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544 return -EIO;
545 }
546 return 0;
547}
548
549/**
550 * wma_cli_set_command() - WMA "set" command processor
551 * @vdev_id: virtual device for the command
552 * @param_id: parameter id
553 * @sval: parameter value
554 * @vpdev: parameter category
555 *
556 * Command handler for set operations
557 *
558 * Return: 0 on success, errno on failure
559 */
560int wma_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
561{
562 return wma_cli_set2_command(vdev_id, param_id, sval, 0, vpdev);
563
564}
565
566/**
567 * wma_set_priv_cfg() - set private config parameters
568 * @wma_handle: wma handle
569 * @privcmd: private command
570 *
571 * Return: 0 for success or error code
572 */
573static int32_t wma_set_priv_cfg(tp_wma_handle wma_handle,
574 wma_cli_set_cmd_t *privcmd)
575{
576 int32_t ret = 0;
577
578 switch (privcmd->param_id) {
579 case WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID:
580 ret = wma_set_txrx_fw_stats_level(wma_handle,
581 privcmd->param_vdev_id,
582 privcmd->param_value);
583 break;
584 case WMA_VDEV_TXRX_FWSTATS_RESET_CMDID:
585 ret = wma_txrx_fw_stats_reset(wma_handle,
586 privcmd->param_vdev_id,
587 privcmd->param_value);
588 break;
589 case WMI_STA_SMPS_FORCE_MODE_CMDID:
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800590 ret = wma_set_mimops(wma_handle,
591 privcmd->param_vdev_id,
592 privcmd->param_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 break;
594 case WMI_STA_SMPS_PARAM_CMDID:
595 wma_set_smps_params(wma_handle, privcmd->param_vdev_id,
596 privcmd->param_value);
597 break;
598 case WMA_VDEV_MCC_SET_TIME_LATENCY:
599 {
600 /* Extract first MCC adapter/vdev channel number and latency */
601 uint8_t mcc_channel = privcmd->param_value & 0x000000FF;
602 uint8_t mcc_channel_latency =
603 (privcmd->param_value & 0x0000FF00) >> 8;
604 int ret = -1;
605 WMA_LOGD("%s: Parsed input: Channel #1:%d, latency:%dms",
606 __func__, mcc_channel, mcc_channel_latency);
607 ret = wma_set_mcc_channel_time_latency(wma_handle,
608 mcc_channel,
609 mcc_channel_latency);
610 }
611 break;
612 case WMA_VDEV_MCC_SET_TIME_QUOTA:
613 {
614 /* Extract the MCC 2 adapters/vdevs channel numbers and time
615 * quota value for the first adapter only (which is specified
616 * in iwpriv command.
617 */
618 uint8_t adapter_2_chan_number =
619 privcmd->param_value & 0x000000FF;
620 uint8_t adapter_1_chan_number =
621 (privcmd->param_value & 0x0000FF00) >> 8;
622 uint8_t adapter_1_quota =
623 (privcmd->param_value & 0x00FF0000) >> 16;
624 int ret = -1;
625
626 WMA_LOGD("%s: Parsed input: Channel #1:%d, Channel #2:%d, quota 1:%dms",
627 __func__, adapter_1_chan_number,
628 adapter_2_chan_number, adapter_1_quota);
629
630 ret = wma_set_mcc_channel_time_quota(wma_handle,
631 adapter_1_chan_number,
632 adapter_1_quota,
633 adapter_2_chan_number);
634 }
635 break;
636 case WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE:
637 {
638 wma_handle->wma_ibss_power_save_params.atimWindowLength =
639 privcmd->param_value;
640 WMA_LOGD("%s: IBSS power save ATIM Window = %d",
641 __func__, wma_handle->wma_ibss_power_save_params.
642 atimWindowLength);
643 }
644 break;
645 case WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED:
646 {
647 wma_handle->wma_ibss_power_save_params.isPowerSaveAllowed =
648 privcmd->param_value;
649 WMA_LOGD("%s: IBSS is Power Save Allowed = %d",
650 __func__, wma_handle->wma_ibss_power_save_params.
651 isPowerSaveAllowed);
652 }
653 break;
654 case WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED:
655 {
656 wma_handle->wma_ibss_power_save_params. isPowerCollapseAllowed =
657 privcmd->param_value;
658 WMA_LOGD("%s: IBSS is Power Collapse Allowed = %d",
659 __func__, wma_handle->wma_ibss_power_save_params.
660 isPowerCollapseAllowed);
661 }
662 break;
663 case WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX:
664 {
665 wma_handle->wma_ibss_power_save_params.isAwakeonTxRxEnabled =
666 privcmd->param_value;
667 WMA_LOGD("%s: IBSS Power Save Awake on Tx/Rx Enabled = %d",
668 __func__, wma_handle->wma_ibss_power_save_params.
669 isAwakeonTxRxEnabled);
670 }
671 break;
672 case WMA_VDEV_IBSS_SET_INACTIVITY_TIME:
673 {
674 wma_handle->wma_ibss_power_save_params.inactivityCount =
675 privcmd->param_value;
676 WMA_LOGD("%s: IBSS Power Save Data Inactivity Count = %d",
677 __func__, wma_handle->wma_ibss_power_save_params.
678 inactivityCount);
679 }
680 break;
681 case WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME:
682 {
683 wma_handle->wma_ibss_power_save_params.txSPEndInactivityTime =
684 privcmd->param_value;
685 WMA_LOGD("%s: IBSS Power Save Transmit EOSP inactivity time out = %d",
686 __func__, wma_handle->wma_ibss_power_save_params.
687 txSPEndInactivityTime);
688 }
689 break;
690 case WMA_VDEV_DFS_CONTROL_CMDID:
691 {
692 struct ieee80211com *dfs_ic = wma_handle->dfs_ic;
693 struct ath_dfs *dfs;
694
695 if (!dfs_ic) {
696 ret = -ENOENT;
697 } else {
698 if (dfs_ic->ic_curchan) {
699 WMA_LOGD("%s: Debug cmd: %s received on ch: %d",
700 __func__, "WMA_VDEV_DFS_CONTROL_CMDID",
701 dfs_ic->ic_curchan->ic_ieee);
702
703 if (dfs_ic->ic_curchan->ic_flagext &
704 IEEE80211_CHAN_DFS) {
705 dfs = (struct ath_dfs *)dfs_ic->ic_dfs;
706 dfs->dfs_bangradar = 1;
707 dfs->ath_radar_tasksched = 1;
708 OS_SET_TIMER(&dfs->ath_dfs_task_timer,
709 0);
710 } else {
711 ret = -ENOENT;
712 }
713 } else {
714 ret = -ENOENT;
715 }
716 }
717
718 if (ret == -ENOENT) {
719 WMA_LOGE("%s: Operating channel is not DFS capable,ignoring %s",
720 __func__, "WMA_VDEV_DFS_CONTROL_CMDID");
721 } else if (ret) {
722 WMA_LOGE("%s: Sending command %s failed with %d\n",
723 __func__, "WMA_VDEV_DFS_CONTROL_CMDID",
724 ret);
725 }
726 }
727 break;
728 case WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS:
729 {
730 wma_handle->wma_ibss_power_save_params.ibssPsWarmupTime =
731 privcmd->param_value;
732 WMA_LOGD("%s: IBSS Power Save Warm Up Time in Seconds = %d",
733 __func__, wma_handle->wma_ibss_power_save_params.
734 ibssPsWarmupTime);
735 }
736 break;
737 case WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW:
738 {
739 wma_handle->wma_ibss_power_save_params.ibssPs1RxChainInAtimEnable
740 = privcmd->param_value;
741 WMA_LOGD("%s: IBSS Power Save single RX Chain Enable In ATIM = %d",
742 __func__, wma_handle->wma_ibss_power_save_params.
743 ibssPs1RxChainInAtimEnable);
744 }
745 break;
746
747 case WMA_VDEV_TXRX_GET_IPA_UC_FW_STATS_CMDID:
748 {
Leo Chang96464902016-10-28 11:10:54 -0700749 void *pdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750
Anurag Chouhan6d760662016-02-20 16:05:43 +0530751 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 if (!pdev) {
753 WMA_LOGE("pdev NULL for uc stat");
754 return -EINVAL;
755 }
Leo Chang96464902016-10-28 11:10:54 -0700756 cdp_ipa_get_stat(cds_get_context(QDF_MODULE_ID_SOC), pdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 }
758 break;
759
760 default:
761 WMA_LOGE("Invalid wma config command id:%d", privcmd->param_id);
762 ret = -EINVAL;
763 }
764 return ret;
765}
766
767/**
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -0700768 * wma_set_dtim_period() - set dtim period to FW
769 * @wma: wma handle
770 * @dtim_params: dtim params
771 *
772 * Return: none
773 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -0700774static void wma_set_dtim_period(tp_wma_handle wma,
775 struct set_dtim_params *dtim_params)
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -0700776{
777 QDF_STATUS ret;
778 uint8_t vdev_id = dtim_params->session_id;
779 struct wma_txrx_node *iface =
780 &wma->interfaces[vdev_id];
781
782 WMA_LOGI("%s: set dtim_period %d", __func__,
783 dtim_params->dtim_period);
784 iface->dtimPeriod = dtim_params->dtim_period;
785 ret = wma_vdev_set_param(wma->wmi_handle,
786 vdev_id,
787 WMI_VDEV_PARAM_LISTEN_INTERVAL,
788 dtim_params->dtim_period);
789 if (QDF_IS_STATUS_ERROR(ret))
790 WMA_LOGW("Failed to set listen interval");
791
792}
793/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 * wma_set_modulated_dtim() - function to configure modulated dtim
795 * @wma: wma handle
796 * @privcmd: structure containing parameters
797 *
798 * This function configures the modulated dtim in firmware
799 *
800 * Return: none
801 */
802static void wma_set_modulated_dtim(tp_wma_handle wma,
803 wma_cli_set_cmd_t *privcmd)
804{
805 uint8_t vdev_id = privcmd->param_vdev_id;
806 struct wma_txrx_node *iface =
807 &wma->interfaces[vdev_id];
808 bool prev_dtim_enabled;
809 uint32_t listen_interval;
Govind Singhd76a5b02016-03-08 15:12:14 +0530810 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811
812 iface->alt_modulated_dtim = privcmd->param_value;
813
814 prev_dtim_enabled = iface->alt_modulated_dtim_enabled;
815
816 if (1 != privcmd->param_value)
817 iface->alt_modulated_dtim_enabled = true;
818 else
819 iface->alt_modulated_dtim_enabled = false;
820
821 if ((true == iface->alt_modulated_dtim_enabled) ||
822 (true == prev_dtim_enabled)) {
823
824 listen_interval = iface->alt_modulated_dtim
825 * iface->dtimPeriod;
826
Govind Singhd76a5b02016-03-08 15:12:14 +0530827 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 privcmd->param_vdev_id,
829 WMI_VDEV_PARAM_LISTEN_INTERVAL,
830 listen_interval);
Govind Singhd76a5b02016-03-08 15:12:14 +0530831 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832 /* Even if it fails, continue */
833 WMA_LOGW("Failed to set listen interval %d",
834 listen_interval);
835
Govind Singhd76a5b02016-03-08 15:12:14 +0530836 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 privcmd->param_vdev_id,
838 WMI_VDEV_PARAM_DTIM_POLICY ,
839 NORMAL_DTIM);
Govind Singhd76a5b02016-03-08 15:12:14 +0530840 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 WMA_LOGE("Failed to Set to Normal DTIM policy");
842 }
843}
844
845
846/**
847 * wma_process_cli_set_cmd() - set parameters to fw
848 * @wma: wma handle
849 * @privcmd: command
850 *
851 * Return: none
852 */
853static void wma_process_cli_set_cmd(tp_wma_handle wma,
854 wma_cli_set_cmd_t *privcmd)
855{
Govind Singhd76a5b02016-03-08 15:12:14 +0530856 int vid = privcmd->param_vdev_id, pps_val = 0;
857 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 struct wma_txrx_node *intr = wma->interfaces;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530859 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860 struct qpower_params *qparams = &intr[vid].config.qpower_params;
Govind Singhd76a5b02016-03-08 15:12:14 +0530861 struct pdev_params pdev_param;
Leo Chang96464902016-10-28 11:10:54 -0700862 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863
864 WMA_LOGD("wmihandle %p", wma->wmi_handle);
865
866 if (NULL == pMac) {
867 WMA_LOGE("%s: Failed to get pMac", __func__);
868 return;
869 }
870
871 if (privcmd->param_id >= WMI_CMDID_MAX) {
872 /*
873 * This configuration setting is not done using any wmi
874 * command, call appropriate handler.
875 */
876 if (wma_set_priv_cfg(wma, privcmd))
877 WMA_LOGE("Failed to set wma priv congiuration");
878 return;
879 }
880
881 switch (privcmd->param_vp_dev) {
882 case VDEV_CMD:
Bhargav Shaha89d3b42016-04-20 13:04:56 +0530883 if (!wma->interfaces[privcmd->param_vdev_id].is_vdev_valid) {
884 WMA_LOGE("%s Vdev id is not valid", __func__);
885 return ;
886 }
887
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
889 privcmd->param_id, privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530890 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 privcmd->param_vdev_id,
892 privcmd->param_id,
893 privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530894 if (QDF_IS_STATUS_ERROR(ret)) {
895 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 ret);
897 return;
898 }
899 break;
900 case PDEV_CMD:
901 WMA_LOGD("pdev pid %d pval %d", privcmd->param_id,
902 privcmd->param_value);
903 if ((privcmd->param_id == WMI_PDEV_PARAM_RX_CHAIN_MASK) ||
904 (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK)) {
905 wma_update_txrx_chainmask(wma->num_rf_chains,
906 &privcmd->param_value);
907 }
Govind Singhd76a5b02016-03-08 15:12:14 +0530908 pdev_param.param_id = privcmd->param_id;
909 pdev_param.param_value = privcmd->param_value;
910 ret = wmi_unified_pdev_param_send(wma->wmi_handle,
911 &pdev_param,
912 WMA_WILDCARD_PDEV_ID);
913 if (QDF_IS_STATUS_ERROR(ret)) {
914 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 ret);
916 return;
917 }
918 break;
919 case GEN_CMD:
920 {
Leo Chang96464902016-10-28 11:10:54 -0700921 void *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922 struct wma_txrx_node *intr = wma->interfaces;
923
924 vdev = wma_find_vdev_by_id(wma, privcmd->param_vdev_id);
925 if (!vdev) {
926 WMA_LOGE("%s:Invalid vdev handle", __func__);
927 return;
928 }
929
930 WMA_LOGD("gen pid %d pval %d", privcmd->param_id,
931 privcmd->param_value);
932
933 switch (privcmd->param_id) {
934 case GEN_VDEV_PARAM_AMPDU:
Nishank Aggarwala13b61d2016-12-01 12:53:58 +0530935 if (soc) {
936 ret = cdp_aggr_cfg(soc, vdev,
937 privcmd->param_value, 0);
938 if (ret)
939 WMA_LOGE("cdp_aggr_cfg set ampdu failed ret %d",
940 ret);
941 else
942 intr[privcmd->param_vdev_id].config.
943 ampdu = privcmd->param_value;
944 } else {
945 WMA_LOGE("%s:SOC context is NULL", __func__);
946 return;
947 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 break;
949 case GEN_VDEV_PARAM_AMSDU:
Nishank Aggarwala13b61d2016-12-01 12:53:58 +0530950 if (soc) {
951 ret = cdp_aggr_cfg(soc, vdev, 0,
952 privcmd->param_value);
953 if (ret)
954 WMA_LOGE("cdp_aggr_cfg set amsdu failed ret %d",
955 ret);
956 else
957 intr[privcmd->param_vdev_id].config.
958 amsdu = privcmd->param_value;
959 } else {
960 WMA_LOGE("%s:SOC context is NULL", __func__);
961 return;
962 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 case GEN_PARAM_CRASH_INJECT:
Rajeev Kumar0a9901b2015-12-15 15:59:19 -0800965 if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
966 WMA_LOGE("Crash inject not allowed in FTM mode");
967 else
968 ret = wma_crash_inject(wma,
969 privcmd->param_value,
970 privcmd->param_sec_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700972 case GEN_PARAM_CAPTURE_TSF:
973 ret = wma_capture_tsf(wma, privcmd->param_value);
974 break;
975 case GEN_PARAM_RESET_TSF_GPIO:
976 ret = wma_reset_tsf_gpio(wma, privcmd->param_value);
977 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 case GEN_PARAM_MODULATED_DTIM:
979 wma_set_modulated_dtim(wma, privcmd);
980 break;
981 default:
982 WMA_LOGE("Invalid param id 0x%x",
983 privcmd->param_id);
984 break;
985 }
986 break;
987 }
988 case DBG_CMD:
989 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
990 privcmd->param_value);
991 switch (privcmd->param_id) {
992 case WMI_DBGLOG_LOG_LEVEL:
993 ret = dbglog_set_log_lvl(wma->wmi_handle,
994 privcmd->param_value);
995 if (ret)
996 WMA_LOGE("dbglog_set_log_lvl failed ret %d",
997 ret);
998 break;
999 case WMI_DBGLOG_VAP_ENABLE:
1000 ret = dbglog_vap_log_enable(wma->wmi_handle,
1001 privcmd->param_value, true);
1002 if (ret)
1003 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1004 ret);
1005 break;
1006 case WMI_DBGLOG_VAP_DISABLE:
1007 ret = dbglog_vap_log_enable(wma->wmi_handle,
1008 privcmd->param_value, false);
1009 if (ret)
1010 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1011 ret);
1012 break;
1013 case WMI_DBGLOG_MODULE_ENABLE:
1014 ret = dbglog_module_log_enable(wma->wmi_handle,
1015 privcmd->param_value, true);
1016 if (ret)
1017 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1018 ret);
1019 break;
1020 case WMI_DBGLOG_MODULE_DISABLE:
1021 ret = dbglog_module_log_enable(wma->wmi_handle,
1022 privcmd->param_value, false);
1023 if (ret)
1024 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1025 ret);
1026 break;
1027 case WMI_DBGLOG_MOD_LOG_LEVEL:
1028 ret = dbglog_set_mod_log_lvl(wma->wmi_handle,
1029 privcmd->param_value);
1030 if (ret)
1031 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1032 ret);
1033 break;
1034 case WMI_DBGLOG_TYPE:
1035 ret = dbglog_parser_type_init(wma->wmi_handle,
1036 privcmd->param_value);
1037 if (ret)
1038 WMA_LOGE("dbglog_parser_type_init failed ret %d",
1039 ret);
1040 break;
1041 case WMI_DBGLOG_REPORT_ENABLE:
1042 ret = dbglog_report_enable(wma->wmi_handle,
1043 privcmd->param_value);
1044 if (ret)
1045 WMA_LOGE("dbglog_report_enable failed ret %d",
1046 ret);
1047 break;
Govind Singha471e5e2015-10-12 17:11:14 +05301048 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301049 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301050 WMI_WLAN_PROFILE_TRIGGER_CMDID,
1051 privcmd->param_value, 0);
1052 if (ret)
1053 WMA_LOGE("Profile cmd failed for %d ret %d",
1054 WMI_WLAN_PROFILE_TRIGGER_CMDID, ret);
1055 break;
1056 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301057 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301058 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1059 privcmd->param_value,
1060 privcmd->param_sec_value);
1061 if (ret)
1062 WMA_LOGE("Profile cmd failed for %d ret %d",
1063 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1064 ret);
1065 break;
1066 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301067 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301068 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1069 privcmd->param_value,
1070 privcmd->param_sec_value);
1071 if (ret)
1072 WMA_LOGE("Profile cmd failed for %d ret %d",
1073 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1074 ret);
1075 break;
1076 case WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301077 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301078 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1079 0, 0);
1080 if (ret)
1081 WMA_LOGE("Profile cmd failed for %d ret %d",
1082 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1083 ret);
1084 break;
1085 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301086 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301087 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1088 0, 0);
1089 if (ret)
1090 WMA_LOGE("Profile cmd failed for %d ret %d",
1091 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1092 ret);
1093 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 case WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID:
1095 /* Set the Green AP */
Govind Singhd76a5b02016-03-08 15:12:14 +05301096 ret = wmi_unified_green_ap_ps_send
1097 (wma->wmi_handle, privcmd->param_value,
1098 WMA_WILDCARD_PDEV_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099 if (ret) {
1100 WMA_LOGE("Set GreenAP Failed val %d",
1101 privcmd->param_value);
1102 }
1103 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104
1105 default:
1106 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1107 break;
1108 }
1109 break;
1110 case PPS_CMD:
1111 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1112 privcmd->param_value);
1113 switch (privcmd->param_id) {
1114
1115 case WMI_VDEV_PPS_PAID_MATCH:
1116 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1117 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
1118 intr[vid].config.pps_params.paid_match_enable =
1119 privcmd->param_value;
1120 break;
1121 case WMI_VDEV_PPS_GID_MATCH:
1122 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1123 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
1124 intr[vid].config.pps_params.gid_match_enable =
1125 privcmd->param_value;
1126 break;
1127 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
1128 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1129 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
1130 intr[vid].config.pps_params.tim_clear =
1131 privcmd->param_value;
1132 break;
1133 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
1134 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1135 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
1136 intr[vid].config.pps_params.dtim_clear =
1137 privcmd->param_value;
1138 break;
1139 case WMI_VDEV_PPS_EOF_PAD_DELIM:
1140 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1141 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
1142 intr[vid].config.pps_params.eof_delim =
1143 privcmd->param_value;
1144 break;
1145 case WMI_VDEV_PPS_MACADDR_MISMATCH:
1146 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1147 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
1148 intr[vid].config.pps_params.mac_match =
1149 privcmd->param_value;
1150 break;
1151 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
1152 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1153 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
1154 intr[vid].config.pps_params.delim_fail =
1155 privcmd->param_value;
1156 break;
1157 case WMI_VDEV_PPS_GID_NSTS_ZERO:
1158 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1159 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
1160 intr[vid].config.pps_params.nsts_zero =
1161 privcmd->param_value;
1162 break;
1163 case WMI_VDEV_PPS_RSSI_CHECK:
1164 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1165 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
1166 intr[vid].config.pps_params.rssi_chk =
1167 privcmd->param_value;
1168 break;
1169 case WMI_VDEV_PPS_5G_EBT:
1170 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1171 (PKT_PWR_SAVE_5G_EBT & 0xffff);
1172 intr[vid].config.pps_params.ebt_5g =
1173 privcmd->param_value;
1174 break;
1175 default:
1176 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1177 break;
1178 }
1179 break;
1180
1181 case QPOWER_CMD:
1182 WMA_LOGD("QPOWER CLI CMD pid %d pval %d", privcmd->param_id,
1183 privcmd->param_value);
1184 switch (privcmd->param_id) {
1185 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
1186 WMA_LOGD("QPOWER CLI CMD:Ps Poll Cnt val %d",
1187 privcmd->param_value);
1188 /* Set the QPower Ps Poll Count */
Govind Singhd76a5b02016-03-08 15:12:14 +05301189 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190 vid, WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
1191 privcmd->param_value);
1192 if (ret) {
1193 WMA_LOGE("Set Q-PsPollCnt Failed vdevId %d val %d",
1194 vid, privcmd->param_value);
1195 } else {
1196 qparams->max_ps_poll_cnt = privcmd->param_value;
1197 }
1198 break;
1199 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
1200 WMA_LOGD("QPOWER CLI CMD:Max Tx Before wake val %d",
1201 privcmd->param_value);
1202 /* Set the QPower Max Tx Before Wake */
Govind Singhd76a5b02016-03-08 15:12:14 +05301203 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 vid, WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
1205 privcmd->param_value);
1206 if (ret) {
1207 WMA_LOGE("Set Q-MaxTxBefWake Failed vId %d val %d",
1208 vid, privcmd->param_value);
1209 } else {
1210 qparams->max_tx_before_wake =
1211 privcmd->param_value;
1212 }
1213 break;
1214 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
1215 WMA_LOGD("QPOWER CLI CMD:Ps Poll Wake Inv val %d",
1216 privcmd->param_value);
1217 /* Set the QPower Spec Ps Poll Wake Inv */
Govind Singhd76a5b02016-03-08 15:12:14 +05301218 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 vid, WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
1220 privcmd->param_value);
1221 if (ret) {
1222 WMA_LOGE("Set Q-PsPoll WakeIntv Failed vId %d val %d",
1223 vid, privcmd->param_value);
1224 } else {
1225 qparams->spec_ps_poll_wake_interval =
1226 privcmd->param_value;
1227 }
1228 break;
1229 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
1230 WMA_LOGD("QPOWER CLI CMD:Spec NoData Ps Poll val %d",
1231 privcmd->param_value);
1232 /* Set the QPower Spec NoData PsPoll */
Govind Singhd76a5b02016-03-08 15:12:14 +05301233 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 vid, WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
1235 privcmd->param_value);
1236 if (ret) {
1237 WMA_LOGE("Set Q-SpecNoDataPsPoll Failed vId %d val %d",
1238 vid, privcmd->param_value);
1239 } else {
1240 qparams->max_spec_nodata_ps_poll =
1241 privcmd->param_value;
1242 }
1243 break;
1244
1245 default:
1246 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1247 break;
1248 }
1249 break;
1250 case GTX_CMD:
1251 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1252 privcmd->param_id, privcmd->param_value);
1253 switch (privcmd->param_id) {
1254 case WMI_VDEV_PARAM_GTX_HT_MCS:
1255 intr[vid].config.gtx_info.gtxRTMask[0] =
1256 privcmd->param_value;
1257 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1258 privcmd->param_vdev_id,
1259 &intr[vid].config.gtx_info);
1260 break;
1261 case WMI_VDEV_PARAM_GTX_VHT_MCS:
1262 intr[vid].config.gtx_info.gtxRTMask[1] =
1263 privcmd->param_value;
1264 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1265 privcmd->param_vdev_id,
1266 &intr[vid].config.gtx_info);
1267 break;
1268
1269 case WMI_VDEV_PARAM_GTX_USR_CFG:
1270 intr[vid].config.gtx_info.gtxUsrcfg =
1271 privcmd->param_value;
1272 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1273 privcmd->param_vdev_id,
1274 &intr[vid].config.gtx_info);
1275 break;
1276
1277 case WMI_VDEV_PARAM_GTX_THRE:
1278 intr[vid].config.gtx_info.gtxPERThreshold =
1279 privcmd->param_value;
1280 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1281 privcmd->param_vdev_id,
1282 &intr[vid].config.gtx_info);
1283 break;
1284
1285 case WMI_VDEV_PARAM_GTX_MARGIN:
1286 intr[vid].config.gtx_info.gtxPERMargin =
1287 privcmd->param_value;
1288 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1289 privcmd->param_vdev_id,
1290 &intr[vid].config.gtx_info);
1291 break;
1292
1293 case WMI_VDEV_PARAM_GTX_STEP:
1294 intr[vid].config.gtx_info.gtxTPCstep =
1295 privcmd->param_value;
1296 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1297 privcmd->param_vdev_id,
1298 &intr[vid].config.gtx_info);
1299 break;
1300
1301 case WMI_VDEV_PARAM_GTX_MINTPC:
1302 intr[vid].config.gtx_info.gtxTPCMin =
1303 privcmd->param_value;
1304 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1305 privcmd->param_vdev_id,
1306 &intr[vid].config.gtx_info);
1307 break;
1308
1309 case WMI_VDEV_PARAM_GTX_BW_MASK:
1310 intr[vid].config.gtx_info.gtxBWMask =
1311 privcmd->param_value;
1312 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1313 privcmd->param_vdev_id,
1314 &intr[vid].config.gtx_info);
1315 if (ret) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301316 WMA_LOGE("wma_vdev_set_param"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 " failed ret %d", ret);
1318 return;
1319 }
1320 break;
1321 default:
1322 break;
1323 }
1324 break;
1325
1326 default:
1327 WMA_LOGE("Invalid vpdev command id");
1328 }
1329 if (1 == privcmd->param_vp_dev) {
1330 switch (privcmd->param_id) {
1331 case WMI_VDEV_PARAM_NSS:
1332 intr[vid].config.nss = privcmd->param_value;
1333 break;
1334 case WMI_VDEV_PARAM_LDPC:
1335 intr[vid].config.ldpc = privcmd->param_value;
1336 break;
1337 case WMI_VDEV_PARAM_TX_STBC:
1338 intr[vid].config.tx_stbc = privcmd->param_value;
1339 break;
1340 case WMI_VDEV_PARAM_RX_STBC:
1341 intr[vid].config.rx_stbc = privcmd->param_value;
1342 break;
1343 case WMI_VDEV_PARAM_SGI:
1344 intr[vid].config.shortgi = privcmd->param_value;
1345 break;
1346 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
1347 intr[vid].config.rtscts_en = privcmd->param_value;
1348 break;
1349 case WMI_VDEV_PARAM_CHWIDTH:
1350 intr[vid].config.chwidth = privcmd->param_value;
1351 break;
1352 case WMI_VDEV_PARAM_FIXED_RATE:
1353 intr[vid].config.tx_rate = privcmd->param_value;
1354 break;
1355 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE:
1356 intr[vid].config.erx_adjust = privcmd->param_value;
1357 break;
1358 case WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM:
1359 intr[vid].config.erx_bmiss_num = privcmd->param_value;
1360 break;
1361 case WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE:
1362 intr[vid].config.erx_bmiss_cycle = privcmd->param_value;
1363 break;
1364 case WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP:
1365 intr[vid].config.erx_slop_step = privcmd->param_value;
1366 break;
1367 case WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP:
1368 intr[vid].config.erx_init_slop = privcmd->param_value;
1369 break;
1370 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE:
1371 intr[vid].config.erx_adj_pause = privcmd->param_value;
1372 break;
1373 case WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE:
1374 intr[vid].config.erx_dri_sample = privcmd->param_value;
1375 break;
1376 default:
1377 WMA_LOGE("Invalid wma_cli_set vdev command/Not"
1378 " yet implemented 0x%x", privcmd->param_id);
1379 break;
1380 }
1381 } else if (2 == privcmd->param_vp_dev) {
1382 switch (privcmd->param_id) {
1383 case WMI_PDEV_PARAM_ANI_ENABLE:
1384 wma->pdevconfig.ani_enable = privcmd->param_value;
1385 break;
1386 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
1387 wma->pdevconfig.ani_poll_len = privcmd->param_value;
1388 break;
1389 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
1390 wma->pdevconfig.ani_listen_len = privcmd->param_value;
1391 break;
1392 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
1393 wma->pdevconfig.ani_ofdm_level = privcmd->param_value;
1394 break;
1395 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
1396 wma->pdevconfig.ani_cck_level = privcmd->param_value;
1397 break;
1398 case WMI_PDEV_PARAM_DYNAMIC_BW:
1399 wma->pdevconfig.cwmenable = privcmd->param_value;
1400 break;
1401 case WMI_PDEV_PARAM_CTS_CBW:
1402 wma->pdevconfig.cts_cbw = privcmd->param_value;
1403 break;
1404 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
1405 wma->pdevconfig.txchainmask = privcmd->param_value;
1406 break;
1407 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
1408 wma->pdevconfig.rxchainmask = privcmd->param_value;
1409 break;
1410 case WMI_PDEV_PARAM_BURST_ENABLE:
1411 wma->pdevconfig.burst_enable = privcmd->param_value;
1412 if ((wma->pdevconfig.burst_enable == 1) &&
1413 (wma->pdevconfig.burst_dur == 0))
1414 wma->pdevconfig.burst_dur =
1415 WMA_DEFAULT_SIFS_BURST_DURATION;
1416 else if (wma->pdevconfig.burst_enable == 0)
1417 wma->pdevconfig.burst_dur = 0;
1418 break;
1419 case WMI_PDEV_PARAM_BURST_DUR:
1420 wma->pdevconfig.burst_dur = privcmd->param_value;
1421 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
1423 wma->pdevconfig.txpow2g = privcmd->param_value;
1424 if ((pMac->roam.configParam.bandCapability ==
1425 eCSR_BAND_ALL) ||
1426 (pMac->roam.configParam.bandCapability ==
1427 eCSR_BAND_24)) {
1428 if (cfg_set_int(pMac,
1429 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1430 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301431 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1433
1434 } else {
1435 WMA_LOGE("Current band is not 2G");
1436 }
1437 break;
1438 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
1439 wma->pdevconfig.txpow5g = privcmd->param_value;
1440 if ((pMac->roam.configParam.bandCapability ==
1441 eCSR_BAND_ALL) ||
1442 (pMac->roam.configParam.bandCapability ==
1443 eCSR_BAND_5G)) {
1444 if (cfg_set_int(pMac,
1445 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1446 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301447 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1449
1450 } else {
1451 WMA_LOGE("Current band is not 5G");
1452 }
1453 break;
1454 default:
1455 WMA_LOGE("Invalid wma_cli_set pdev command/Not yet implemented 0x%x",
1456 privcmd->param_id);
1457 break;
1458 }
1459 } else if (5 == privcmd->param_vp_dev) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301460 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 privcmd->param_vdev_id,
1462 WMI_VDEV_PARAM_PACKET_POWERSAVE,
1463 pps_val);
1464 if (ret)
1465 WMA_LOGE("Failed to send wmi packet power save cmd");
1466 else
1467 WMA_LOGD("Sent packet power save cmd %d value %x to target",
1468 privcmd->param_id, pps_val);
1469 }
1470}
1471
1472/**
1473 * wma_process_fw_event() - process any fw event
1474 * @wma: wma handle
1475 * @buf: fw event buffer
1476 *
1477 * This function process any fw event to serialize it through mc thread.
1478 *
1479 * Return: none
1480 */
1481static int wma_process_fw_event(tp_wma_handle wma,
1482 wma_process_fw_event_params *buf)
1483{
1484 struct wmi_unified *wmi_handle = (struct wmi_unified *)buf->wmi_handle;
1485
1486 wmi_process_fw_event(wmi_handle, buf->evt_buf);
1487 return 0;
1488}
1489
1490/**
Govind Singhd76a5b02016-03-08 15:12:14 +05301491 * wmi_process_fw_event_tasklet_ctx() - process in tasklet context
1492 * @ctx: handle to wmi
1493 * @ev: wmi event buffer
1494 *
1495 * Event process by below function will be in tasket context,
1496 * need to use this method only for time sensitive functions.
1497 *
1498 * Return: none
1499 */
1500static int wma_process_fw_event_tasklet_ctx(void *ctx, void *ev)
1501{
1502 wmi_process_fw_event(ctx, ev);
1503
1504 return 0;
1505}
1506
1507/**
Manjeet Singhf82ed072016-07-08 11:40:00 +05301508 * wma_process_hal_pwr_dbg_cmd() - send hal pwr dbg cmd to fw.
1509 * @handle: wma handle
1510 * @sir_pwr_dbg_params: unit test command
1511 *
1512 * This function send unit test command to fw.
1513 *
1514 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
1515 */
1516QDF_STATUS wma_process_hal_pwr_dbg_cmd(WMA_HANDLE handle,
1517 struct sir_mac_pwr_dbg_cmd *
1518 sir_pwr_dbg_params)
1519{
1520 tp_wma_handle wma_handle = (tp_wma_handle)handle;
1521 int i;
1522 struct wmi_power_dbg_params wmi_pwr_dbg_params;
1523 QDF_STATUS status;
1524
1525 if (!sir_pwr_dbg_params) {
1526 WMA_LOGE("%s: sir_pwr_dbg_params is null", __func__);
1527 return QDF_STATUS_E_INVAL;
1528 }
1529 wmi_pwr_dbg_params.module_id = sir_pwr_dbg_params->module_id;
1530 wmi_pwr_dbg_params.pdev_id = sir_pwr_dbg_params->pdev_id;
1531 wmi_pwr_dbg_params.num_args = sir_pwr_dbg_params->num_args;
1532
1533 for (i = 0; i < wmi_pwr_dbg_params.num_args; i++)
1534 wmi_pwr_dbg_params.args[i] = sir_pwr_dbg_params->args[i];
1535
1536 status = wmi_unified_send_power_dbg_cmd(wma_handle->wmi_handle,
1537 &wmi_pwr_dbg_params);
1538
1539 return status;
1540}
1541
1542/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 * wma_process_fw_event_handler() - common event handler to serialize
1544 * event processing through mc_thread
Govind Singhd76a5b02016-03-08 15:12:14 +05301545 * @ctx: wmi context
1546 * @ev: event buffer
1547 * @rx_ctx: rx execution context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 *
1549 * Return: 0 on success, errno on failure
1550 */
Govind Singhd76a5b02016-03-08 15:12:14 +05301551static int wma_process_fw_event_mc_thread_ctx(void *ctx, void *ev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552{
1553 wma_process_fw_event_params *params_buf;
1554 cds_msg_t cds_msg = { 0 };
1555
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301556 params_buf = qdf_mem_malloc(sizeof(wma_process_fw_event_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 if (!params_buf) {
1558 WMA_LOGE("%s: Failed alloc memory for params_buf", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301559 qdf_nbuf_free(ev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 return -ENOMEM;
1561 }
1562
Govind Singhd76a5b02016-03-08 15:12:14 +05301563 params_buf->wmi_handle = (struct wmi_unified *)ctx;
1564 params_buf->evt_buf = (wmi_buf_t *)ev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565
1566 cds_msg.type = WMA_PROCESS_FW_EVENT;
1567 cds_msg.bodyptr = params_buf;
1568 cds_msg.bodyval = 0;
1569
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301570 if (QDF_STATUS_SUCCESS !=
Krunal Soni66c113f2016-12-21 16:46:47 -08001571 cds_mq_post_message(QDF_MODULE_ID_WMA, &cds_msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 WMA_LOGP("%s: Failed to post WMA_PROCESS_FW_EVENT msg",
1573 __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301574 qdf_nbuf_free(ev);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301575 qdf_mem_free(params_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 return -EFAULT;
1577 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 return 0;
1579
1580}
1581
Govind Singhd76a5b02016-03-08 15:12:14 +05301582/**
1583 * wma_process_fw_event_handler() - common event handler to serialize
1584 * event processing through mc_thread
1585 * @ctx: wmi context
1586 * @ev: event buffer
1587 * @rx_ctx: rx execution context
1588 *
1589 * Return: 0 on success, errno on failure
1590 */
1591int wma_process_fw_event_handler(void *ctx, void *ev, uint8_t rx_ctx)
1592{
1593 int err = 0;
1594
1595 if (rx_ctx == WMA_RX_SERIALIZER_CTX) {
1596 err = wma_process_fw_event_mc_thread_ctx(ctx, ev);
1597 } else if (rx_ctx == WMA_RX_TASKLET_CTX) {
1598 wma_process_fw_event_tasklet_ctx(ctx, ev);
1599 } else {
1600 WMA_LOGE("%s: invalid wmi event execution context", __func__);
1601 qdf_nbuf_free(ev);
1602 }
1603
1604 return err;
1605}
1606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607#ifdef WLAN_FEATURE_NAN
1608/**
1609 * wma_set_nan_enable() - set nan enable flag in WMA handle
1610 * @wma_handle: Pointer to wma handle
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301611 * @cds_cfg: Pointer to CDS Configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 *
1613 * Return: none
1614 */
1615static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301616 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617{
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301618 wma_handle->is_nan_enabled = cds_cfg->is_nan_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619}
1620#else
1621static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301622 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623{
1624}
1625#endif
1626
1627/**
Komal Seelam02d09342016-02-23 18:03:19 +05301628 * wma_init_max_no_of_peers - API to initialize wma configuration params
1629 * @wma_handle: WMA Handle
1630 * @max_peers: Max Peers supported
1631 *
1632 * Return: void
1633 */
1634static void wma_init_max_no_of_peers(tp_wma_handle wma_handle,
1635 uint16_t max_peers)
1636{
1637 struct wma_ini_config *cfg = wma_get_ini_handle(wma_handle);
1638
Naveen Rawat35804772016-06-27 15:40:28 -07001639 if (cfg == NULL) {
1640 WMA_LOGE("%s: NULL WMA ini handle", __func__);
1641 return;
1642 }
1643
Komal Seelam02d09342016-02-23 18:03:19 +05301644 cfg->max_no_of_peers = max_peers;
1645}
1646
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001647/**
1648 * wma_shutdown_notifier_cb - Shutdown notifer call back
1649 * @priv : WMA handle
1650 *
1651 * During recovery, WMA may wait for resume to complete if the crash happens
1652 * while in suspend. This may cause delays in completing the recovery. This call
1653 * back would be called during recovery and the event is completed so that if
1654 * the resume is waiting on FW to respond then it can get out of the wait so
1655 * that recovery thread can start bringing down all the modules.
1656 *
1657 * Return: None
1658 */
1659static void wma_shutdown_notifier_cb(void *priv)
1660{
1661 tp_wma_handle wma_handle = priv;
1662
1663 qdf_event_set(&wma_handle->wma_resume_event);
1664}
1665
Mukul Sharma5ff3c582016-09-12 15:23:35 +05301666struct wma_version_info g_wmi_version_info;
1667
Komal Seelam02d09342016-02-23 18:03:19 +05301668/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301669 * wma_state_info_dump() - prints state information of wma layer
1670 * @buf: buffer pointer
1671 * @size: size of buffer to be filled
1672 *
1673 * This function is used to dump state information of wma layer
1674 *
1675 * Return: None
1676 */
1677static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
1678{
1679 tp_wma_handle wma_handle;
1680 uint16_t len = 0;
1681 char *buf = *buf_ptr;
1682 struct wma_txrx_node *iface;
1683 uint8_t vdev_id;
1684
1685 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
1686 if (!wma_handle) {
1687 WMA_LOGE("%s: WMA context is invald!", __func__);
1688 return;
1689 }
1690
1691 WMA_LOGI("%s: size of buffer: %d", __func__, *size);
1692
1693 len += qdf_scnprintf(buf + len, *size - len,
1694 "\n wow_pno_match_wake_up_count %d",
1695 wma_handle->wow_pno_match_wake_up_count);
1696 len += qdf_scnprintf(buf + len, *size - len,
1697 "\n wow_pno_complete_wake_up_count %d",
1698 wma_handle->wow_pno_complete_wake_up_count);
1699 len += qdf_scnprintf(buf + len, *size - len,
1700 "\n wow_gscan_wake_up_count %d",
1701 wma_handle->wow_gscan_wake_up_count);
1702 len += qdf_scnprintf(buf + len, *size - len,
1703 "\n wow_low_rssi_wake_up_count %d",
1704 wma_handle->wow_low_rssi_wake_up_count);
1705 len += qdf_scnprintf(buf + len, *size - len,
1706 "\n wow_rssi_breach_wake_up_count %d",
1707 wma_handle->wow_rssi_breach_wake_up_count);
1708 len += qdf_scnprintf(buf + len, *size - len,
1709 "\n wow_ucast_wake_up_count %d",
1710 wma_handle->wow_ucast_wake_up_count);
1711 len += qdf_scnprintf(buf + len, *size - len,
1712 "\n wow_bcast_wake_up_count %d",
1713 wma_handle->wow_bcast_wake_up_count);
1714 len += qdf_scnprintf(buf + len, *size - len,
1715 "\n wow_ipv4_mcast_wake_up_count %d",
1716 wma_handle->wow_ipv4_mcast_wake_up_count);
1717 len += qdf_scnprintf(buf + len, *size - len,
1718 "\n wow_ipv6_mcast_ra_stats %d",
1719 wma_handle->wow_ipv6_mcast_ra_stats);
1720 len += qdf_scnprintf(buf + len, *size - len,
1721 "\n wow_ipv6_mcast_ns_stats %d",
1722 wma_handle->wow_ipv6_mcast_ns_stats);
1723 len += qdf_scnprintf(buf + len, *size - len,
1724 "\n wow_ipv6_mcast_na_stats %d",
1725 wma_handle->wow_ipv6_mcast_na_stats);
1726
1727 for (vdev_id = 0; vdev_id < wma_handle->max_bssid; vdev_id++) {
1728 if (!wma_handle->interfaces[vdev_id].handle)
1729 continue;
1730
1731 iface = &wma_handle->interfaces[vdev_id];
1732
1733 len += qdf_scnprintf(buf + len, *size - len,
1734 "\n vdev_id %d",
1735 vdev_id);
1736 len += qdf_scnprintf(buf + len, *size - len,
1737 "\n conn_state %d",
1738 iface->conn_state);
1739 len += qdf_scnprintf(buf + len, *size - len,
1740 "\n dtimPeriod %d",
1741 iface->dtimPeriod);
1742 len += qdf_scnprintf(buf + len, *size - len,
1743 "\n chanmode %d",
1744 iface->chanmode);
1745 len += qdf_scnprintf(buf + len, *size - len,
1746 "\n vht_capable %d",
1747 iface->vht_capable);
1748 len += qdf_scnprintf(buf + len, *size - len,
1749 "\n ht_capable %d",
1750 iface->ht_capable);
1751 len += qdf_scnprintf(buf + len, *size - len,
1752 "\n chan_width %d",
1753 iface->chan_width);
1754 len += qdf_scnprintf(buf + len, *size - len,
1755 "\n vdev_active %d",
1756 iface->vdev_active);
1757 len += qdf_scnprintf(buf + len, *size - len,
1758 "\n vdev_up %d",
1759 iface->vdev_up);
1760 len += qdf_scnprintf(buf + len, *size - len,
1761 "\n aid %d",
1762 iface->aid);
1763 len += qdf_scnprintf(buf + len, *size - len,
1764 "\n rate_flags %d",
1765 iface->rate_flags);
1766 len += qdf_scnprintf(buf + len, *size - len,
1767 "\n nss %d",
1768 iface->nss);
1769 len += qdf_scnprintf(buf + len, *size - len,
1770 "\n tx_power %d",
1771 iface->tx_power);
1772 len += qdf_scnprintf(buf + len, *size - len,
1773 "\n max_tx_power %d",
1774 iface->max_tx_power);
1775 len += qdf_scnprintf(buf + len, *size - len,
1776 "\n nwType %d",
1777 iface->nwType);
1778 len += qdf_scnprintf(buf + len, *size - len,
1779 "\n tx_streams %d",
1780 iface->tx_streams);
1781 len += qdf_scnprintf(buf + len, *size - len,
1782 "\n rx_streams %d",
1783 iface->rx_streams);
1784 len += qdf_scnprintf(buf + len, *size - len,
1785 "\n chain_mask %d",
1786 iface->chain_mask);
1787 len += qdf_scnprintf(buf + len, *size - len,
1788 "\n nss_2g %d",
1789 iface->nss_2g);
1790 len += qdf_scnprintf(buf + len, *size - len,
1791 "\n nss_5g %d",
1792 iface->nss_5g);
1793 }
1794
1795 *size -= len;
1796 *buf_ptr += len;
1797}
1798
1799/**
1800 * wma_register_debug_callback() - registration function for wma layer
1801 * to print wma state information
1802 */
1803static void wma_register_debug_callback(void)
1804{
1805 qdf_register_debug_callback(QDF_MODULE_ID_WMA, &wma_state_info_dump);
1806}
1807
Frank Liu65b17d92016-11-23 15:58:44 +08001808#ifdef WLAN_CONVERGED_INTERFACE
1809/**
1810 * wma_register_tx_ops_handler() - register tx_ops of southbound
1811 * @tx_ops: tx_ops pointer in southbound
1812 *
1813 * Return: 0 on success, errno on failure
1814 */
1815static QDF_STATUS
1816wma_register_tx_ops_handler(struct wlan_lmac_if_tx_ops *tx_ops)
1817{
1818 /*
1819 * Assign tx_ops, it's up to UMAC modules to declare and define these
1820 * functions which are used to send wmi command to target.
1821 */
1822
1823 return QDF_STATUS_SUCCESS;
1824}
1825
1826/**
1827 * wma_target_if_open() - Attach UMAC modules' interface with wmi layer
1828 * @wma_handle: wma handle
1829 *
1830 * Separate module defines below functions:
1831 * 1. tgt_wmi_<module>_<action> api sends wmi command, assigned to south bound
1832 * tx_ops function pointers;
1833 * 2. module's south dispatcher handles information from lower layer, assigned
1834 * to south bound rx_ops function pointers;
1835 * 3. wmi event handler deals with wmi event, extracts umac needed information,
1836 * and call rx_ops(module's dispatcher). It executes in tasklet context and
1837 * is up to dispatcher to decide the context to reside in tasklet or in
1838 * thread context.
1839 *
1840 * Return: None
1841 */
1842static void wma_target_if_open(tp_wma_handle wma_handle)
1843{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301844 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08001845
1846 if (!psoc)
1847 return;
1848
1849 wlan_lmac_if_assign_tx_registration_cb(WLAN_DEV_OL,
1850 wma_register_tx_ops_handler);
1851
1852 wlan_lmac_if_open(psoc);
1853
1854 /* Register WMI event handler */
1855}
1856
1857/**
1858 * wma_target_if_close() - Detach UMAC modules' interface with wmi layer
1859 * @wma_handle: wma handle
1860 *
1861 * Return: None
1862 */
1863static void wma_target_if_close(tp_wma_handle wma_handle)
1864{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301865 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08001866
1867 if (!psoc)
1868 return;
1869
1870 wlan_lmac_if_close(psoc);
1871}
1872#else
1873static void wma_target_if_open(tp_wma_handle wma_handle) {};
1874static void wma_target_if_close(tp_wma_handle wma_handle) {};
1875#endif
1876
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301877/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 * wma_open() - Allocate wma context and initialize it.
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301879 * @psoc: Psoc pointer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 * @cds_context: cds context
1881 * @wma_tgt_cfg_cb: tgt config callback fun
1882 * @radar_ind_cb: dfs radar indication callback
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301883 * @cds_cfg: mac parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 *
1885 * Return: 0 on success, errno on failure
1886 */
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301887QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc, void *cds_context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 wma_tgt_cfg_cb tgt_cfg_cb,
1889 wma_dfs_radar_indication_cb radar_ind_cb,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301890 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891{
1892 tp_wma_handle wma_handle;
1893 HTC_HANDLE htc_handle;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301894 qdf_device_t qdf_dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 void *wmi_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301896 QDF_STATUS qdf_status;
Govind Singhd76a5b02016-03-08 15:12:14 +05301897 struct wmi_rx_ops ops;
1898
1899 bool use_cookie = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900
1901 WMA_LOGD("%s: Enter", __func__);
1902
Mukul Sharma5ff3c582016-09-12 15:23:35 +05301903 g_wmi_version_info.major = __WMI_VER_MAJOR_;
1904 g_wmi_version_info.minor = __WMI_VER_MINOR_;
1905 g_wmi_version_info.revision = __WMI_REVISION_;
1906
Anurag Chouhan6d760662016-02-20 16:05:43 +05301907 qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
1908 htc_handle = cds_get_context(QDF_MODULE_ID_HTC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909
1910 if (!htc_handle) {
1911 WMA_LOGP("%s: Invalid HTC handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301912 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 }
1914
1915 /* Alloc memory for WMA Context */
Anurag Chouhan6d760662016-02-20 16:05:43 +05301916 qdf_status = cds_alloc_context(cds_context, QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 (void **)&wma_handle,
1918 sizeof(t_wma_handle));
1919
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301920 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 WMA_LOGP("%s: Memory allocation failed for wma_handle",
1922 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301923 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 }
1925
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301926 qdf_mem_zero(wma_handle, sizeof(t_wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927
Anurag Chouhan6d760662016-02-20 16:05:43 +05301928 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929#ifdef FEATURE_WLAN_SCAN_PNO
Anurag Chouhana37b5b72016-02-21 14:53:42 +05301930 qdf_wake_lock_create(&wma_handle->pno_wake_lock, "wlan_pno_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931#endif /* FEATURE_WLAN_SCAN_PNO */
1932#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05301933 qdf_wake_lock_create(&wma_handle->extscan_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001934 "wlan_extscan_wl");
1935#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05301936 qdf_wake_lock_create(&wma_handle->wow_wake_lock, "wlan_wow_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 }
1938
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301939 /* Increase psoc ref count once APIs are available in object manager */
1940 wma_handle->psoc = psoc;
1941
Govind Singhd76a5b02016-03-08 15:12:14 +05301942 /* Attach mc_thread context processing function */
1943 ops.wma_process_fw_event_handler_cbk = wma_process_fw_event_handler;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 /* attach the wmi */
Govind Singhd76a5b02016-03-08 15:12:14 +05301945 wmi_handle = wmi_unified_attach(wma_handle, NULL,
1946 WMI_TLV_TARGET, use_cookie, &ops);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 if (!wmi_handle) {
1948 WMA_LOGP("%s: failed to attach WMI", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301949 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 goto err_wma_handle;
1951 }
1952
1953 WMA_LOGA("WMA --> wmi_unified_attach - success");
Govind Singhd76a5b02016-03-08 15:12:14 +05301954 wmi_unified_register_event_handler(wmi_handle,
1955 WMI_SERVICE_READY_EVENTID,
1956 wma_rx_service_ready_event,
1957 WMA_RX_SERIALIZER_CTX);
1958 wmi_unified_register_event_handler(wmi_handle,
1959 WMI_SERVICE_READY_EXT_EVENTID,
1960 wma_rx_service_ready_ext_event,
1961 WMA_RX_SERIALIZER_CTX);
1962 wmi_unified_register_event_handler(wmi_handle,
1963 WMI_READY_EVENTID,
1964 wma_rx_ready_event,
1965 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 /* Save the WMI & HTC handle */
1967 wma_handle->wmi_handle = wmi_handle;
1968 wma_handle->htc_handle = htc_handle;
1969 wma_handle->cds_context = cds_context;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301970 wma_handle->qdf_dev = qdf_dev;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301971 wma_handle->max_scan = cds_cfg->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972
Houston Hoffmanc45db892015-11-13 19:59:25 -08001973 wma_handle->wma_runtime_resume_lock =
1974 qdf_runtime_lock_init("wma_runtime_resume");
1975
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05301976 /* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301977 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05301978 /* Cap maxStation based on the target version */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301979 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05301980 /* Reinitialize max_no_of_peers based on the capped maxStation value */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301981 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05301982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 /* initialize default target config */
1984 wma_set_default_tgt_config(wma_handle);
1985
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301986 wma_handle->tx_chain_mask_cck = cds_cfg->tx_chain_mask_cck;
1987 wma_handle->self_gen_frm_pwr = cds_cfg->self_gen_frm_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 /* Allocate dfs_ic and initialize DFS */
1990 wma_handle->dfs_ic = wma_dfs_attach(wma_handle->dfs_ic);
1991 if (wma_handle->dfs_ic == NULL) {
1992 WMA_LOGE("%s: Memory allocation failed for dfs_ic", __func__);
1993 goto err_wmi_handle;
1994 }
1995#if defined(QCA_WIFI_FTM)
Anurag Chouhan6d760662016-02-20 16:05:43 +05301996 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 wma_utf_attach(wma_handle);
1998#endif /* QCA_WIFI_FTM */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301999 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
2000 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302002 cds_cfg->max_bssid = WMA_MAX_SUPPORTED_BSS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003
2004 wma_handle->wlan_resource_config.num_wow_filters =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302005 cds_cfg->max_wow_filters;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 wma_handle->wlan_resource_config.num_keep_alive_pattern =
2007 WMA_MAXNUM_PERIODIC_TX_PTRNS;
2008
2009 /* The current firmware implementation requires the number of
Anurag Chouhanffb21542016-02-17 14:33:03 +05302010 * offload peers should be (number of vdevs + 1).
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 */
2012 wma_handle->wlan_resource_config.num_offload_peers =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302013 cds_cfg->ap_maxoffload_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014
2015 wma_handle->wlan_resource_config.num_offload_reorder_buffs =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302016 cds_cfg->ap_maxoffload_reorderbuffs + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302018 wma_handle->ol_ini_info = cds_cfg->ol_ini_info;
2019 wma_handle->max_station = cds_cfg->max_station;
2020 wma_handle->max_bssid = cds_cfg->max_bssid;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302021 wma_handle->driver_type = cds_cfg->driver_type;
2022 wma_handle->ssdp = cds_cfg->ssdp;
2023 wma_handle->enable_mc_list = cds_cfg->enable_mc_list;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05302024 wma_handle->bpf_packet_filter_enable =
2025 cds_cfg->bpf_packet_filter_enable;
Srinivas Girigowda57b450e2016-10-27 21:00:46 -07002026 wma_handle->link_stats_results = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302028 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
2029 wma_handle->RArateLimitInterval = cds_cfg->ra_ratelimit_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030#endif /* FEATURE_WLAN_RA_FILTERING */
2031#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302032 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033#endif
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302034 wma_set_nan_enable(wma_handle, cds_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 /*
2036 * Indicates if DFS Phyerr filtering offload
2037 * is Enabled/Disabed from ini
2038 */
2039 wma_handle->dfs_phyerr_filter_offload =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302040 cds_cfg->dfs_phyerr_filter_offload;
2041 wma_handle->dfs_pri_multiplier = cds_cfg->dfs_pri_multiplier;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302042 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 wma_handle->max_bssid);
2044 if (!wma_handle->interfaces) {
2045 WMA_LOGP("%s: failed to allocate interface table", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302046 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 goto err_scn_context;
2048 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302049 qdf_mem_zero(wma_handle->interfaces, sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 wma_handle->max_bssid);
2051 /* Register the debug print event handler */
2052 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302053 WMI_DEBUG_PRINT_EVENTID,
2054 wma_unified_debug_print_event_handler,
2055 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05302056 /* Register profiling event Handler */
2057 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2058 WMI_WLAN_PROFILE_DATA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302059 wma_profile_data_report_event_handler,
2060 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061
2062 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
2063 wma_handle->dfs_radar_indication_cb = radar_ind_cb;
2064 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
2065 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05302066 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07002067 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302069 qdf_status = qdf_event_create(&wma_handle->wma_ready_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302070 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 WMA_LOGP("%s: wma_ready_event initialization failed", __func__);
2072 goto err_event_init;
2073 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302074
Anurag Chouhan210db072016-02-22 18:42:15 +05302075 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302076 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302077 wma_service_ready_ext_evt_timeout,
2078 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302079 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302080 WMA_LOGE("Failed to initialize service ready ext timeout");
2081 goto err_event_init;
2082 }
2083
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302084 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302085 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 WMA_LOGP("%s: target suspend event initialization failed",
2087 __func__);
2088 goto err_event_init;
2089 }
2090
2091 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302092 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
2093 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 WMA_LOGP("%s: failed to init tx_frm_download_comp_event",
2095 __func__);
2096 goto err_event_init;
2097 }
2098
2099 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302100 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
2101 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 WMA_LOGP("%s: failed to init tx_queue_empty_event", __func__);
2103 goto err_event_init;
2104 }
2105
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302106 qdf_status = qdf_event_create(&wma_handle->wma_resume_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302107 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 WMA_LOGP("%s: wma_resume_event initialization failed",
2109 __func__);
2110 goto err_event_init;
2111 }
2112
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002113 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
2114 wma_handle);
2115 if (qdf_status != QDF_STATUS_SUCCESS) {
2116 WMA_LOGP("%s: Shutdown notifier register failed: %d",
2117 __func__, qdf_status);
2118 goto err_event_init;
2119 }
2120
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302121 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302122 if (qdf_status != QDF_STATUS_SUCCESS) {
Houston Hoffmana76591b2015-11-10 16:52:05 -08002123 WMA_LOGP("%s: runtime_suspend event initialization failed",
2124 __func__);
2125 goto err_event_init;
2126 }
2127
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302128 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302129 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 WMA_LOGP("%s: recovery event initialization failed", __func__);
2131 goto err_event_init;
2132 }
2133
Anurag Chouhanffb21542016-02-17 14:33:03 +05302134 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07002135 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302136 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05302137 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302139 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05302140 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
2141 qdf_atomic_init(&wma_handle->scan_id_counter);
Nitesh Shah0f3fce52016-10-13 22:01:41 +05302142 qdf_atomic_init(&wma_handle->num_pending_scans);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143
2144 /* Register vdev start response event handler */
2145 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2146 WMI_VDEV_START_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302147 wma_vdev_start_resp_handler,
2148 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149
2150 /* Register vdev stop response event handler */
2151 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2152 WMI_VDEV_STOPPED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302153 wma_vdev_stop_resp_handler,
2154 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155
2156 /* register for STA kickout function */
2157 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2158 WMI_PEER_STA_KICKOUT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302159 wma_peer_sta_kickout_event_handler,
2160 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161
2162 /* register for stats response event */
2163 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2164 WMI_UPDATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302165 wma_stats_event_handler,
2166 WMA_RX_SERIALIZER_CTX);
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05302167
2168#ifdef WLAN_POWER_DEBUGFS
2169 /* register for Chip Power stats event */
2170 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2171 WMI_PDEV_CHIP_POWER_STATS_EVENTID,
2172 wma_unified_power_debug_stats_event_handler,
2173 WMA_RX_SERIALIZER_CTX);
2174#endif
2175
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 /* register for linkspeed response event */
2177 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2178 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302179 wma_link_speed_event_handler,
2180 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181
2182#ifdef FEATURE_OEM_DATA_SUPPORT
2183 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002184 WMI_OEM_RESPONSE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302185 wma_oem_data_response_handler,
2186 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187#endif /* FEATURE_OEM_DATA_SUPPORT */
2188 /*
2189 * Register appropriate DFS phyerr event handler for
2190 * Phyerror events. Handlers differ for phyerr filtering
2191 * offload enable and disable cases.
2192 */
2193 wma_register_dfs_event_handler(wma_handle);
2194
2195 /* Register peer change event handler */
2196 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2197 WMI_PEER_STATE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302198 wma_peer_state_change_event_handler,
2199 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200
2201 /* Register beacon tx complete event id. The event is required
2202 * for sending channel switch announcement frames
2203 */
2204 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302205 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID,
2206 wma_unified_bcntx_status_event_handler,
2207 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208
2209 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2210 WMI_UPDATE_VDEV_RATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302211 wma_link_status_event_handler,
2212 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213#ifdef WLAN_FEATURE_LINK_LAYER_STATS
2214 /* Register event handler for processing Link Layer Stats
2215 * response from the FW
2216 */
2217 wma_register_ll_stats_event_handler(wma_handle);
2218
2219#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2220
2221 /*
2222 * Register event handler to receive firmware mem dump
2223 * copy complete indication
2224 */
2225 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2226 WMI_UPDATE_FW_MEM_DUMP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302227 wma_fw_mem_dump_event_handler,
2228 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229
2230 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302231 qdf_status = dbglog_init(wma_handle->wmi_handle);
2232 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 WMA_LOGP("%s: Firmware Dbglog initialization failed", __func__);
2234 goto err_dbglog_init;
2235 }
2236
2237 /*
2238 * Update Powersave mode
2239 * 1 - Legacy Powersave + Deepsleep Disabled
2240 * 2 - QPower + Deepsleep Disabled
2241 * 3 - Legacy Powersave + Deepsleep Enabled
2242 * 4 - QPower + Deepsleep Enabled
2243 */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302244 wma_handle->powersave_mode = cds_cfg->powersave_offload_enabled;
2245 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
2246 wma_handle->staModDtim = cds_cfg->sta_mod_dtim;
2247 wma_handle->staDynamicDtim = cds_cfg->sta_dynamic_dtim;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248
2249 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302250 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 * 0 - Disable both magic pattern match and pattern byte match.
2252 * 1 - Enable magic pattern match on all interfaces.
2253 * 2 - Enable pattern byte match on all interfaces.
2254 * 3 - Enable both magic patter and pattern byte match on
2255 * all interfaces.
2256 */
2257 wma_handle->wow.magic_ptrn_enable =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302258 (cds_cfg->wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 wma_handle->ptrn_match_enable_all_vdev =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302260 (cds_cfg->wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261
2262#ifdef FEATURE_WLAN_TDLS
2263 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2264 WMI_TDLS_PEER_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302265 wma_tdls_event_handler,
2266 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267#endif /* FEATURE_WLAN_TDLS */
2268
2269 /* register for install key completion event */
2270 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302271 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID,
2272 wma_vdev_install_key_complete_event_handler,
2273 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274#ifdef WLAN_FEATURE_NAN
2275 /* register for nan response event */
2276 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2277 WMI_NAN_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302278 wma_nan_rsp_event_handler,
2279 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280#endif /* WLAN_FEATURE_NAN */
2281
2282#ifdef WLAN_FEATURE_STATS_EXT
2283 /* register for extended stats event */
2284 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2285 WMI_STATS_EXT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302286 wma_stats_ext_event_handler,
2287 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288#endif /* WLAN_FEATURE_STATS_EXT */
2289#ifdef FEATURE_WLAN_EXTSCAN
2290 wma_register_extscan_event_handler(wma_handle);
2291#endif /* WLAN_FEATURE_STATS_EXT */
2292
2293 WMA_LOGD("%s: Exit", __func__);
2294
2295#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2296 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2297 WMI_ROAM_SYNCH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302298 wma_roam_synch_event_handler,
2299 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
2301 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2302 WMI_RSSI_BREACH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302303 wma_rssi_breached_event_handler,
2304 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302306 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05302307 "wlan_fw_rsp_wakelock");
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002308 wma_handle->wmi_cmd_rsp_runtime_lock =
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302309 qdf_runtime_lock_init("wlan_fw_rsp_runtime_lock");
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311 /* Register peer assoc conf event handler */
2312 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2313 WMI_PEER_ASSOC_CONF_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302314 wma_peer_assoc_conf_handler,
2315 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002316 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2317 WMI_VDEV_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302318 wma_vdev_delete_handler,
2319 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002320 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2321 WMI_PEER_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302322 wma_peer_delete_handler,
2323 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05302324 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2325 WMI_BPF_CAPABILIY_INFO_EVENTID,
2326 wma_get_bpf_caps_event_handler,
2327 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05302328 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2329 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID,
2330 wma_encrypt_decrypt_msg_handler,
2331 WMA_RX_SERIALIZER_CTX);
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07002332 wma_ndp_register_all_event_handlers(wma_handle);
Frank Liu65b17d92016-11-23 15:58:44 +08002333 wma_target_if_open(wma_handle);
2334
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302335 wma_register_debug_callback();
2336
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302337 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002338
2339err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302340 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
2341 qdf_runtime_lock_deinit(wma_handle->wmi_cmd_rsp_runtime_lock);
2342 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
2343 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344err_event_init:
2345 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
2346 WMI_DEBUG_PRINT_EVENTID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302347 qdf_mem_free(wma_handle->interfaces);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348err_scn_context:
2349 wma_dfs_detach(wma_handle->dfs_ic);
2350#if defined(QCA_WIFI_FTM)
2351 wma_utf_detach(wma_handle);
2352#endif /* QCA_WIFI_FTM */
2353err_wmi_handle:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302354 qdf_mem_free(((p_cds_contextType) cds_context)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355 OS_FREE(wmi_handle);
2356
2357err_wma_handle:
2358
Anurag Chouhan6d760662016-02-20 16:05:43 +05302359 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360#ifdef FEATURE_WLAN_SCAN_PNO
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302361 qdf_wake_lock_destroy(&wma_handle->pno_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362#endif /* FEATURE_WLAN_SCAN_PNO */
2363#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302364 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302366 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 }
Houston Hoffmanc45db892015-11-13 19:59:25 -08002368
2369 qdf_runtime_lock_deinit(wma_handle->wma_runtime_resume_lock);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302370 cds_free_context(cds_context, QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371
2372 WMA_LOGD("%s: Exit", __func__);
2373
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302374 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375}
2376
2377/**
2378 * wma_pre_start() - wma pre start
2379 * @cds_ctx: cds context
2380 *
2381 * Return: 0 on success, errno on failure
2382 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302383QDF_STATUS wma_pre_start(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302385 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386 A_STATUS status = A_OK;
2387 tp_wma_handle wma_handle;
2388 cds_msg_t wma_msg = { 0 };
2389
2390 WMA_LOGD("%s: Enter", __func__);
2391
Anurag Chouhan6d760662016-02-20 16:05:43 +05302392 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393
2394 /* Validate the wma_handle */
2395 if (NULL == wma_handle) {
2396 WMA_LOGP("%s: invalid argument", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302397 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 goto end;
2399 }
2400 /* Open endpoint for ctrl path - WMI <--> HTC */
2401 status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
2402 wma_handle->htc_handle);
2403 if (A_OK != status) {
2404 WMA_LOGP("%s: wmi_unified_connect_htc_service", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302405 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 goto end;
2407 }
2408
2409 WMA_LOGA("WMA --> wmi_unified_connect_htc_service - success");
2410
2411 /* Trigger the CFG DOWNLOAD */
2412 wma_msg.type = WNI_CFG_DNLD_REQ;
2413 wma_msg.bodyptr = NULL;
2414 wma_msg.bodyval = 0;
2415
Krunal Soni66c113f2016-12-21 16:46:47 -08002416 qdf_status = cds_mq_post_message(QDF_MODULE_ID_WMA, &wma_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302417 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 WMA_LOGP("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302419 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302420 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 }
2422end:
2423 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302424 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425}
2426
2427/**
2428 * wma_send_msg() - Send wma message to PE.
2429 * @wma_handle: wma handle
2430 * @msg_type: message type
2431 * @body_ptr: message body ptr
2432 * @body_val: message body value
2433 *
2434 * Return: none
2435 */
2436void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
2437 void *body_ptr, uint32_t body_val)
2438{
2439 tSirMsgQ msg = { 0 };
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302440 uint32_t status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302441 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 msg.type = msg_type;
2443 msg.bodyval = body_val;
2444 msg.bodyptr = body_ptr;
2445 status = lim_post_msg_api(pMac, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302446 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 if (NULL != body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302448 qdf_mem_free(body_ptr);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302449 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 }
2451 return;
2452}
2453
2454/**
2455 * wma_set_base_macaddr_indicate() - set base mac address in fw
2456 * @wma_handle: wma handle
2457 * @customAddr: base mac address
2458 *
2459 * Return: 0 for success or error code
2460 */
2461static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
2462 tSirMacAddr *customAddr)
2463{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 int err;
2465
Govind Singhf25a0f12016-03-08 16:09:48 +05302466 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
2467 (uint8_t *)customAddr);
2468 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
2471 MAC_ADDR_ARRAY((*customAddr)));
2472
2473 return 0;
2474}
2475
2476/**
2477 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
2478 * @handle: WMA handle
2479 * @event: Event received from FW
2480 * @len: Length of the event
2481 *
2482 * Enables the low frequency events and disables the high frequency
2483 * events. Bit 17 indicates if the event if low/high frequency.
2484 * 1 - high frequency, 0 - low frequency
2485 *
2486 * Return: 0 on successfully enabling/disabling the events
2487 */
2488static int wma_log_supported_evt_handler(void *handle,
2489 uint8_t *event,
2490 uint32_t len)
2491{
2492 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493
Govind Singhf25a0f12016-03-08 16:09:48 +05302494 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
2495 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497
2498 return 0;
2499}
2500
2501/**
2502 * wma_flush_complete_evt_handler() - FW log flush complete event handler
2503 * @handle: WMI handle
2504 * @event: Event recevied from FW
2505 * @len: Length of the event
2506 *
2507 */
2508static int wma_flush_complete_evt_handler(void *handle,
2509 u_int8_t *event,
2510 u_int32_t len)
2511{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302512 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513 tp_wma_handle wma = (tp_wma_handle) handle;
2514
2515 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *param_buf;
2516 wmi_debug_mesg_flush_complete_fixed_param *wmi_event;
2517 uint32_t reason_code;
2518
2519 param_buf = (WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *) event;
2520 if (!param_buf) {
2521 WMA_LOGE("Invalid log flush complete event buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302522 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 }
2524
2525 wmi_event = param_buf->fixed_param;
2526 reason_code = wmi_event->reserved0;
2527
2528 /*
2529 * reason_code = 0; Flush event in response to flush command
2530 * reason_code = other value; Asynchronous flush event for fatal events
2531 */
2532 if (!reason_code && (cds_is_log_report_in_progress() == false)) {
2533 WMA_LOGE("Received WMI flush event without sending CMD");
2534 return -EINVAL;
2535 } else if (!reason_code && cds_is_log_report_in_progress() == true) {
2536 /* Flush event in response to flush command */
2537 WMA_LOGI("Received WMI flush event in response to flush CMD");
Anurag Chouhan210db072016-02-22 18:42:15 +05302538 status = qdf_mc_timer_stop(&wma->log_completion_timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302539 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 WMA_LOGE("Failed to stop the log completion timeout");
2541 cds_logging_set_fw_flush_complete();
2542 } else if (reason_code && cds_is_log_report_in_progress() == false) {
2543 /* Asynchronous flush event for fatal events */
2544 WMA_LOGE("Received asynchronous WMI flush event: reason=%d",
2545 reason_code);
2546 status = cds_set_log_completion(WLAN_LOG_TYPE_FATAL,
2547 WLAN_LOG_INDICATOR_FIRMWARE,
Abhishek Singh5ea86532016-04-27 14:10:53 +05302548 reason_code, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302549 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 WMA_LOGE("%s: Failed to set log trigger params",
2551 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302552 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553 }
2554 cds_logging_set_fw_flush_complete();
2555 return status;
2556 } else {
2557 /* Asynchronous flush event for fatal event,
2558 * but, report in progress already
2559 */
2560 WMA_LOGI("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
2561 __func__, WLAN_LOG_TYPE_FATAL,
2562 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302563 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 }
2565 return 0;
2566}
2567
2568/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302569 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570 * @handle: WMI handle
2571 * @event: Event recevied from FW
2572 * @len: Length of the event
2573 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302574 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
2575 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
2576 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 *
2578 * Return: Success on receiving valid params from FW
2579 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302580static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 uint8_t *event,
2582 uint32_t len)
2583{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302584 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
2585 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
2586 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 uint32_t i;
2588 struct sir_set_hw_mode_resp *hw_mode_resp;
2589 tp_wma_handle wma = (tp_wma_handle) handle;
2590
2591 if (!wma) {
2592 WMA_LOGE("%s: Invalid WMA handle", __func__);
2593 /* Since WMA handle itself is NULL, we cannot send fail
2594 * response back to LIM here
2595 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302596 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 }
2598
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302599 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 if (!hw_mode_resp) {
2601 WMA_LOGI("%s: Memory allocation failed", __func__);
2602 /* Since this memory allocation itself failed, we cannot
2603 * send fail response back to LIM here
2604 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302605 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 }
2607
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302608 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302610 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 /* Need to send response back to upper layer to free
2612 * active command list
2613 */
2614 goto fail;
2615 }
2616
2617 wmi_event = param_buf->fixed_param;
2618 hw_mode_resp->status = wmi_event->status;
2619 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2620 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
2621
2622 WMA_LOGI("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
2623 __func__, wmi_event->status,
2624 wmi_event->cfgd_hw_mode_index,
2625 wmi_event->num_vdev_mac_entries);
2626 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302627 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628
2629 /* Store the vdev-mac map in WMA and prepare to send to PE */
2630 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302631 uint32_t vdev_id, mac_id, pdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302633 pdev_id = vdev_mac_entry[i].pdev_id;
2634 if (pdev_id == WMI_PDEV_ID_SOC) {
2635 WMA_LOGE("%s: soc level id received for mac id)",
2636 __func__);
2637 QDF_BUG(0);
2638 goto fail;
2639 }
2640 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641
2642 WMA_LOGI("%s: vdev_id:%d mac_id:%d",
2643 __func__, vdev_id, mac_id);
2644
2645 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
2646 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
2647 wma_update_intf_hw_mode_params(vdev_id, mac_id,
2648 wmi_event->cfgd_hw_mode_index);
2649 }
2650
2651 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
2652 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
2653 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2654 } else {
2655 wma->old_hw_mode_index = wma->new_hw_mode_index;
2656 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2657 }
2658 }
2659
2660 WMA_LOGI("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
2661 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
2662
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302663 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 (void *) hw_mode_resp, 0);
2665
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302666 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667
2668fail:
2669 WMA_LOGE("%s: Sending fail response to LIM", __func__);
2670 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
2671 hw_mode_resp->cfgd_hw_mode_index = 0;
2672 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302673 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 (void *) hw_mode_resp, 0);
2675
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302676 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677}
2678
2679/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002680 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
2681 *
2682 * @handle: WMA handle
2683 * @fixed_param: Event fixed parameters
2684 * @vdev_mac_entry - vdev mac entry
2685 * @hw_mode_trans_ind - Buffer to store parsed information
2686 *
2687 * Parses fixed_param, vdev_mac_entry and fills in the information into
2688 * hw_mode_trans_ind and wma
2689 *
2690 * Return: None
2691 */
2692void wma_process_pdev_hw_mode_trans_ind(void *handle,
2693 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
2694 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
2695 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
2696{
2697 uint32_t i;
2698 tp_wma_handle wma = (tp_wma_handle) handle;
2699
2700 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
2701 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
2702 hw_mode_trans_ind->num_vdev_mac_entries =
2703 fixed_param->num_vdev_mac_entries;
2704 WMA_LOGI("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
2705 __func__, fixed_param->old_hw_mode_index,
2706 fixed_param->new_hw_mode_index,
2707 fixed_param->num_vdev_mac_entries);
2708
2709 /* Store the vdev-mac map in WMA and send to policy manager */
2710 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
2711 uint32_t vdev_id, mac_id, pdev_id;
2712 vdev_id = vdev_mac_entry[i].vdev_id;
2713 pdev_id = vdev_mac_entry[i].pdev_id;
2714
2715 if (pdev_id == WMI_PDEV_ID_SOC) {
2716 WMA_LOGE("%s: soc level id received for mac id)",
2717 __func__);
2718 QDF_BUG(0);
2719 return;
2720 }
2721
2722 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
2723
2724 WMA_LOGI("%s: vdev_id:%d mac_id:%d",
2725 __func__, vdev_id, mac_id);
2726
2727 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
2728 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
2729 wma_update_intf_hw_mode_params(vdev_id, mac_id,
2730 fixed_param->new_hw_mode_index);
2731 }
2732 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
2733 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
2734
2735 WMA_LOGI("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
2736 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
2737}
2738
2739/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302740 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741 * @handle: WMI handle
2742 * @event: Event recevied from FW
2743 * @len: Length of the event
2744 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302745 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 * asynchronous hardware mode transition. This event notifies the host driver
2747 * that firmware independently changed the hardware mode for some reason, such
2748 * as Coex, LFR 3.0, etc
2749 *
2750 * Return: Success on receiving valid params from FW
2751 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302752static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002753 uint8_t *event,
2754 uint32_t len)
2755{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302756 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
2757 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
2758 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
2760 tp_wma_handle wma = (tp_wma_handle) handle;
2761
2762 if (!wma) {
2763 /* This is an async event. So, not sending any event to LIM */
2764 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302765 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 }
2767
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302768 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002769 if (!param_buf) {
2770 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302771 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302772 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 }
2774
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302775 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 if (!hw_mode_trans_ind) {
2777 WMA_LOGI("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302778 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 }
2780
2781 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302783 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002784 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
2785 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302787 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 (void *) hw_mode_trans_ind, 0);
2789
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302790 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791}
2792
2793/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302794 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 * @handle: WMI handle
2796 * @event: Event received from FW
2797 * @len: Length of the event
2798 *
2799 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302800 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 * the host driver once the firmware has completed a reconfiguration of the Scan
2802 * and FW mode configuration. This changes could include entering or leaving a
2803 * dual mac configuration for either scan and/or more permanent firmware mode.
2804 *
2805 * Return: Success on receiving valid params from FW
2806 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302807static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 uint8_t *event,
2809 uint32_t len)
2810{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302811 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
2812 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813 tp_wma_handle wma = (tp_wma_handle) handle;
2814 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
2815
2816 if (!wma) {
2817 WMA_LOGE("%s: Invalid WMA handle", __func__);
2818 /* Since the WMA handle is NULL, we cannot send resp to LIM.
2819 * So, returning from here.
2820 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302821 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 }
2823
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302824 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 if (!dual_mac_cfg_resp) {
2826 WMA_LOGE("%s: Memory allocation failed", __func__);
2827 /* Since the mem alloc failed, we cannot send resp to LIM.
2828 * So, returning from here.
2829 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302830 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 }
2832
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302833 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834 event;
2835 if (!param_buf) {
2836 WMA_LOGE("%s: Invalid event", __func__);
2837 goto fail;
2838 }
2839
2840 wmi_event = param_buf->fixed_param;
2841 WMA_LOGI("%s: status:%d", __func__, wmi_event->status);
2842 dual_mac_cfg_resp->status = wmi_event->status;
2843
2844 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
2845 wma->dual_mac_cfg.prev_scan_config =
2846 wma->dual_mac_cfg.cur_scan_config;
2847 wma->dual_mac_cfg.prev_fw_mode_config =
2848 wma->dual_mac_cfg.cur_fw_mode_config;
2849 wma->dual_mac_cfg.cur_scan_config =
2850 wma->dual_mac_cfg.req_scan_config;
2851 wma->dual_mac_cfg.cur_fw_mode_config =
2852 wma->dual_mac_cfg.req_fw_mode_config;
2853 }
2854
2855 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302856 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 (void *) dual_mac_cfg_resp, 0);
2858
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302859 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860
2861fail:
2862 WMA_LOGE("%s: Sending fail response to LIM", __func__);
2863 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302864 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 (void *) dual_mac_cfg_resp, 0);
2866
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302867 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868
2869}
2870
2871/**
2872 * wma_start() - wma start function.
2873 * Intialize event handlers and timers.
2874 * @cds_ctx: cds context
2875 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302876 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302878QDF_STATUS wma_start(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302880 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 tp_wma_handle wma_handle;
2882 int status;
2883 WMA_LOGD("%s: Enter", __func__);
2884
Anurag Chouhan6d760662016-02-20 16:05:43 +05302885 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886
2887 /* validate the wma_handle */
2888 if (NULL == wma_handle) {
2889 WMA_LOGP("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302890 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891 goto end;
2892 }
2893
2894 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
2895 WMI_SCAN_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302896 wma_scan_event_callback,
2897 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 if (0 != status) {
2899 WMA_LOGP("%s: Failed to register scan callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302900 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 goto end;
2902 }
2903
2904 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
2905 WMI_ROAM_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302906 wma_roam_event_callback,
2907 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 if (0 != status) {
2909 WMA_LOGP("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302910 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 goto end;
2912 }
2913
2914 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
2915 WMI_WOW_WAKEUP_HOST_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302916 wma_wow_wakeup_host_event,
2917 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 if (status) {
2919 WMA_LOGP("%s: Failed to register wow wakeup host event handler",
2920 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302921 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 goto end;
2923 }
2924
2925 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
2926 WMI_PDEV_RESUME_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302927 wma_pdev_resume_event_handler,
2928 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 if (status) {
2930 WMA_LOGP("%s: Failed to register PDEV resume event handler",
2931 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302932 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 goto end;
2934 }
2935
2936#ifdef FEATURE_WLAN_SCAN_PNO
2937 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
2938 WMI_SERVICE_NLO)) {
2939
2940 WMA_LOGD("FW supports pno offload, registering nlo match handler");
2941
2942 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302943 WMI_NLO_MATCH_EVENTID,
2944 wma_nlo_match_evt_handler,
2945 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 if (status) {
2947 WMA_LOGE("Failed to register nlo match event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302948 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 goto end;
2950 }
2951
2952 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302953 WMI_NLO_SCAN_COMPLETE_EVENTID,
2954 wma_nlo_scan_cmp_evt_handler,
2955 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 if (status) {
2957 WMA_LOGE("Failed to register nlo scan comp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302958 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 goto end;
2960 }
2961 }
2962#endif /* FEATURE_WLAN_SCAN_PNO */
2963
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05302964#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
2965 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 WMA_LOGE("MCC TX Pause Event Handler register");
2967 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302968 WMI_TX_PAUSE_EVENTID,
2969 wma_mcc_vdev_tx_pause_evt_handler,
2970 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
2972
2973#ifdef FEATURE_WLAN_CH_AVOID
2974 WMA_LOGD("Registering channel to avoid handler");
2975
2976 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302977 WMI_WLAN_FREQ_AVOID_EVENTID,
2978 wma_channel_avoid_evt_handler,
2979 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002980 if (status) {
2981 WMA_LOGE("Failed to register channel to avoid event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302982 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 goto end;
2984 }
2985#endif /* FEATURE_WLAN_CH_AVOID */
2986#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2987 WMA_LOGD("Registering auto shutdown handler");
2988 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302989 WMI_HOST_AUTO_SHUTDOWN_EVENTID,
2990 wma_auto_shutdown_event_handler,
2991 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992 if (status) {
2993 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302994 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 goto end;
2996 }
2997#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
2998 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302999 WMI_THERMAL_MGMT_EVENTID,
3000 wma_thermal_mgmt_evt_handler,
3001 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 if (status) {
3003 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303004 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 goto end;
3006 }
3007
3008 status = wma_ocb_register_event_handlers(wma_handle);
3009 if (status) {
3010 WMA_LOGE("Failed to register ocb event handlers");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303011 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 goto end;
3013 }
3014
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303015 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016
3017#ifdef QCA_WIFI_FTM
3018 /*
3019 * Tx mgmt attach requires TXRX context which is not created
3020 * in FTM mode. So skip the TX mgmt attach.
3021 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303022 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 goto end;
3024#endif /* QCA_WIFI_FTM */
3025
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003026 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3027 WMI_SERVICE_RMC)) {
3028
3029 WMA_LOGD("FW supports cesium network, registering event handlers");
3030
3031 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3032 WMI_PEER_INFO_EVENTID,
3033 wma_ibss_peer_info_event_handler,
3034 WMA_RX_SERIALIZER_CTX);
3035 if (status) {
3036 WMA_LOGE("Failed to register ibss peer info event cb");
3037 qdf_status = QDF_STATUS_E_FAILURE;
3038 goto end;
3039 }
3040
3041 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3042 WMI_PEER_TX_FAIL_CNT_THR_EVENTID,
3043 wma_fast_tx_fail_event_handler,
3044 WMA_RX_SERIALIZER_CTX);
3045 if (status) {
3046 WMA_LOGE("Failed to register peer fast tx failure event cb");
3047 qdf_status = QDF_STATUS_E_FAILURE;
3048 goto end;
3049 }
3050 } else {
3051 WMA_LOGE("Target does not support cesium network");
3052 }
3053
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303054 qdf_status = wma_tx_attach(wma_handle);
3055 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 WMA_LOGP("%s: Failed to register tx management", __func__);
3057 goto end;
3058 }
3059
3060 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05303061 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303062 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 wma_log_completion_timeout,
3064 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303065 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 WMA_LOGE("Failed to initialize log completion timeout");
3067 goto end;
3068 }
3069
3070 /* Initialize the get temperature event handler */
3071 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303072 WMI_PDEV_TEMPERATURE_EVENTID,
3073 wma_pdev_temperature_evt_handler,
3074 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303075 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303077 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 goto end;
3079 }
3080
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07003081 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3082 WMI_VDEV_TSF_REPORT_EVENTID,
3083 wma_vdev_tsf_handler,
3084 WMA_RX_SERIALIZER_CTX);
3085 if (0 != status) {
3086 WMA_LOGP("%s: Failed to register tsf callback", __func__);
3087 qdf_status = QDF_STATUS_E_FAILURE;
3088 goto end;
3089 }
3090
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091 /* Initialize the log flush complete event handler */
3092 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3093 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303094 wma_flush_complete_evt_handler,
3095 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303096 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 WMA_LOGE("Failed to register log flush complete event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303098 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 goto end;
3100 }
3101
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303102 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303104 WMI_PDEV_SET_HW_MODE_RESP_EVENTID,
3105 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303106 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303107 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303109 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 goto end;
3111 }
3112
3113 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
3114 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303115 WMI_PDEV_HW_MODE_TRANSITION_EVENTID,
3116 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303117 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303118 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303120 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 goto end;
3122 }
3123
3124 /* Initialize the set dual mac configuration event handler */
3125 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303126 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID,
3127 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303128 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303129 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303131 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 goto end;
3133 }
3134
Peng Xu8fdaa492016-06-22 10:20:47 -07003135 /* Initialize the P2P Listen Offload event handler */
3136 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3137 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID,
3138 wma_p2p_lo_event_handler,
3139 WMA_RX_SERIALIZER_CTX);
3140 if (!QDF_IS_STATUS_SUCCESS(status)) {
3141 WMA_LOGE("Failed to register p2p lo event cb");
3142 qdf_status = QDF_STATUS_E_FAILURE;
3143 goto end;
3144 }
3145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146end:
3147 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303148 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149}
3150
3151/**
3152 * wma_stop() - wma stop function.
3153 * cleanup timers and suspend target.
3154 * @cds_ctx: cds context
3155 * @reason: reason for wma_stop.
3156 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303157 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303159QDF_STATUS wma_stop(void *cds_ctx, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160{
3161 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303162 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05303163 int i;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303164 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165
3166 WMA_LOGD("%s: Enter", __func__);
3167
3168 /* validate the wma_handle */
3169 if (NULL == wma_handle) {
3170 WMA_LOGP("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303171 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 goto end;
3173 }
3174#ifdef QCA_WIFI_FTM
3175 /*
3176 * Tx mgmt detach requires TXRX context which is not created
3177 * in FTM mode. So skip the TX mgmt detach.
3178 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303179 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303180 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 goto end;
3182 }
3183#endif /* QCA_WIFI_FTM */
3184
3185 if (wma_handle->ack_work_ctx) {
3186 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303187 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 wma_handle->ack_work_ctx = NULL;
3189 }
3190
3191 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05303192 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303193 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 WMA_LOGE("Failed to destroy the log completion timer");
3195 }
3196
Govind Singhede435f2015-12-01 16:16:36 +05303197 /* clean up ll-queue for all vdev */
3198 for (i = 0; i < wma_handle->max_bssid; i++) {
3199 if (wma_handle->interfaces[i].handle &&
3200 wma_handle->interfaces[i].vdev_up) {
Leo Chang96464902016-10-28 11:10:54 -07003201 cdp_fc_vdev_flush(
3202 cds_get_context(QDF_MODULE_ID_SOC),
3203 wma_handle->interfaces[i].handle);
Govind Singhede435f2015-12-01 16:16:36 +05303204 }
3205 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303206 qdf_status = wma_tx_detach(wma_handle);
3207 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 WMA_LOGP("%s: Failed to deregister tx management", __func__);
3209 goto end;
3210 }
3211
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212end:
3213 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303214 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215}
3216
3217/**
3218 * wma_cleanup_hold_req() - cleanup hold request queue
3219 * @wma: wma handle
3220 *
3221 * Return: none
3222 */
3223static void wma_cleanup_hold_req(tp_wma_handle wma)
3224{
3225 struct wma_target_req *req_msg = NULL;
Anurag Chouhanffb21542016-02-17 14:33:03 +05303226 qdf_list_node_t *node1 = NULL;
3227 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303229 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303230 if (!qdf_list_size(&wma->wma_hold_req_queue)) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303231 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
Krishna Kumaar Natarajanea08e502015-11-09 16:57:40 -08003232 WMA_LOGI(FL("request queue is empty"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 return;
3234 }
3235
Anurag Chouhanffb21542016-02-17 14:33:03 +05303236 while (QDF_STATUS_SUCCESS !=
3237 qdf_list_peek_front(&wma->wma_hold_req_queue, &node1)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05303238 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303239 status = qdf_list_remove_node(&wma->wma_hold_req_queue, node1);
3240 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303241 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 WMA_LOGE(FL("Failed to remove request for vdev_id %d type %d"),
3243 req_msg->vdev_id, req_msg->type);
3244 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 }
Anurag Chouhan210db072016-02-22 18:42:15 +05303246 qdf_mc_timer_destroy(&req_msg->event_timeout);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303247 qdf_mem_free(req_msg);
Krishna Kumaar Natarajanea08e502015-11-09 16:57:40 -08003248 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303249 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250}
3251
3252/**
3253 * wma_cleanup_vdev_resp() - cleanup vdev response queue
3254 * @wma: wma handle
3255 *
3256 * Return: none
3257 */
3258static void wma_cleanup_vdev_resp(tp_wma_handle wma)
3259{
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003260 struct wma_target_req *req_msg = NULL;
Anurag Chouhanffb21542016-02-17 14:33:03 +05303261 qdf_list_node_t *node1 = NULL;
3262 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303264 qdf_spin_lock_bh(&wma->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303265 if (!qdf_list_size(&wma->vdev_resp_queue)) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303266 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003267 WMA_LOGI(FL("request queue maybe empty"));
3268 return;
3269 }
3270
Anurag Chouhanffb21542016-02-17 14:33:03 +05303271 while (QDF_STATUS_SUCCESS != qdf_list_peek_front(&wma->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003272 &node1)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05303273 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303274 status = qdf_list_remove_node(&wma->vdev_resp_queue, node1);
3275 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303276 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003277 WMA_LOGE(FL("Failed to remove request for vdev_id %d type %d"),
3278 req_msg->vdev_id, req_msg->type);
3279 return;
3280 }
Anurag Chouhan210db072016-02-22 18:42:15 +05303281 qdf_mc_timer_destroy(&req_msg->event_timeout);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303282 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303284 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285}
3286
3287/**
3288 * wma_wmi_service_close() - close wma wmi service interface.
3289 * @cds_ctx: cds context
3290 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303291 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303293QDF_STATUS wma_wmi_service_close(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294{
3295 tp_wma_handle wma_handle;
3296 struct beacon_info *bcn;
3297 int i;
3298
3299 WMA_LOGD("%s: Enter", __func__);
3300
Anurag Chouhan6d760662016-02-20 16:05:43 +05303301 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302
3303 /* validate the wma_handle */
3304 if (NULL == wma_handle) {
3305 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303306 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 }
3308
3309 /* validate the wmi handle */
3310 if (NULL == wma_handle->wmi_handle) {
3311 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303312 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 }
3314
3315 /* dettach the wmi serice */
3316 WMA_LOGD("calling wmi_unified_detach");
3317 wmi_unified_detach(wma_handle->wmi_handle);
3318 wma_handle->wmi_handle = NULL;
3319
3320 for (i = 0; i < wma_handle->max_bssid; i++) {
3321 bcn = wma_handle->interfaces[i].beacon;
3322
3323 if (bcn) {
3324 if (bcn->dma_mapped)
Nirav Shahcbc6d722016-03-01 16:24:53 +05303325 qdf_nbuf_unmap_single(wma_handle->qdf_dev,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303326 bcn->buf, QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +05303327 qdf_nbuf_free(bcn->buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303328 qdf_mem_free(bcn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 wma_handle->interfaces[i].beacon = NULL;
3330 }
3331
3332 if (wma_handle->interfaces[i].handle) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303333 qdf_mem_free(wma_handle->interfaces[i].handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 wma_handle->interfaces[i].handle = NULL;
3335 }
Yue Ma664effc2016-01-12 18:43:54 -08003336
3337 if (wma_handle->interfaces[i].addBssStaContext) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303338 qdf_mem_free(wma_handle->
Yue Ma664effc2016-01-12 18:43:54 -08003339 interfaces[i].addBssStaContext);
3340 wma_handle->interfaces[i].addBssStaContext = NULL;
3341 }
3342
3343 if (wma_handle->interfaces[i].del_staself_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303344 qdf_mem_free(wma_handle->interfaces[i].del_staself_req);
Yue Ma664effc2016-01-12 18:43:54 -08003345 wma_handle->interfaces[i].del_staself_req = NULL;
3346 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 }
3348
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303349 qdf_mem_free(wma_handle->interfaces);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 /* free the wma_handle */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303351 cds_free_context(wma_handle->cds_context, QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 wma_handle);
3353
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303354 qdf_mem_free(((p_cds_contextType) cds_ctx)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303356 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357}
3358
Xun Luoa858a472015-11-10 08:24:45 -08003359/**
3360 * wma_wmi_work_close() - close the work queue items associated with WMI
3361 * @cds_ctx: Pointer to cds context
3362 *
3363 * This function closes work queue items associated with WMI, but not fully
3364 * closes WMI service.
3365 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303366 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08003367 * proper error codes.
3368 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303369QDF_STATUS wma_wmi_work_close(void *cds_ctx)
Xun Luoa858a472015-11-10 08:24:45 -08003370{
3371 tp_wma_handle wma_handle;
3372
3373 WMA_LOGD("%s: Enter", __func__);
3374
Anurag Chouhan6d760662016-02-20 16:05:43 +05303375 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08003376
3377 /* validate the wma_handle */
3378 if (NULL == wma_handle) {
3379 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303380 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003381 }
3382
3383 /* validate the wmi handle */
3384 if (NULL == wma_handle->wmi_handle) {
3385 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303386 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003387 }
3388
3389 /* remove the wmi work */
3390 WMA_LOGD("calling wmi_unified_remove_work");
3391 wmi_unified_remove_work(wma_handle->wmi_handle);
3392
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303393 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08003394}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395
Krunal Soni2e48d012016-05-02 16:55:26 -07003396/**
3397 * wma_cleanup_dbs_phy_caps() - release memory allocated for holding ext cap
3398 * @wma_handle: pointer to wma handle
3399 *
3400 * This function releases all the memory created for holding extended
3401 * capabilities per hardware mode and per PHY
3402 *
3403 * Return: void
3404 */
3405static void wma_cleanup_dbs_phy_caps(t_wma_handle *wma_handle)
3406{
3407 if (NULL == wma_handle) {
3408 WMA_LOGE("%s: Invalid wma handle", __func__);
3409 return;
3410 }
3411
3412 if (wma_handle->phy_caps.hw_mode_to_mac_cap_map) {
3413 qdf_mem_free(wma_handle->phy_caps.hw_mode_to_mac_cap_map);
3414 wma_handle->phy_caps.hw_mode_to_mac_cap_map = NULL;
3415 WMA_LOGI("%s: hw_mode_to_mac_cap_map freed", __func__);
3416 }
3417
3418 if (wma_handle->phy_caps.each_hw_mode_cap) {
3419 qdf_mem_free(wma_handle->phy_caps.each_hw_mode_cap);
3420 wma_handle->phy_caps.each_hw_mode_cap = NULL;
3421 WMA_LOGI("%s: each_hw_mode_cap freed", __func__);
3422 }
3423
3424 if (wma_handle->phy_caps.each_phy_cap_per_hwmode) {
3425 qdf_mem_free(wma_handle->phy_caps.each_phy_cap_per_hwmode);
3426 wma_handle->phy_caps.each_phy_cap_per_hwmode = NULL;
3427 WMA_LOGI("%s: each_phy_cap_per_hwmode freed", __func__);
3428 }
3429
3430 if (wma_handle->phy_caps.each_phy_hal_reg_cap) {
3431 qdf_mem_free(wma_handle->phy_caps.each_phy_hal_reg_cap);
3432 wma_handle->phy_caps.each_phy_hal_reg_cap = NULL;
3433 WMA_LOGI("%s: each_phy_hal_reg_cap freed", __func__);
3434 }
3435}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436
3437/**
3438 * wma_close() - wma close function.
3439 * cleanup resources attached with wma.
3440 * @cds_ctx: cds context
3441 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303442 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303444QDF_STATUS wma_close(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445{
3446 tp_wma_handle wma_handle;
3447 uint32_t idx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303448 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449
3450 WMA_LOGD("%s: Enter", __func__);
3451
Anurag Chouhan6d760662016-02-20 16:05:43 +05303452 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453
3454 /* validate the wma_handle */
3455 if (NULL == wma_handle) {
3456 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303457 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 }
3459
3460 /* validate the wmi handle */
3461 if (NULL == wma_handle->wmi_handle) {
3462 WMA_LOGP("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303463 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 }
3465
3466 /* Free DBS list */
3467 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303468 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 wma_handle->hw_mode.hw_mode_list = NULL;
3470 WMA_LOGI("%s: DBS list is freed", __func__);
3471 }
Krunal Soni2e48d012016-05-02 16:55:26 -07003472 wma_cleanup_dbs_phy_caps(wma_handle);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303473 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474#ifdef FEATURE_WLAN_SCAN_PNO
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303475 qdf_wake_lock_destroy(&wma_handle->pno_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476#endif /* FEATURE_WLAN_SCAN_PNO */
3477#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303478 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303480 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 }
3482
3483 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303484 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
3485 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 WMA_LOGP("%s: dbglog_deinit failed", __func__);
3487
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303488 /* close the qdf events */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303489 qdf_event_destroy(&wma_handle->wma_ready_event);
Anurag Chouhan210db072016-02-22 18:42:15 +05303490 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303491 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303492 WMA_LOGP("%s: Failed to destroy service ready ext event timer",
3493 __func__);
3494
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303495 qdf_event_destroy(&wma_handle->target_suspend);
3496 qdf_event_destroy(&wma_handle->wma_resume_event);
3497 qdf_event_destroy(&wma_handle->runtime_suspend);
3498 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08003499 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
3500 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 wma_cleanup_vdev_resp(wma_handle);
3502 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303503 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
3504 qdf_runtime_lock_deinit(wma_handle->wmi_cmd_rsp_runtime_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 for (idx = 0; idx < wma_handle->num_mem_chunks; ++idx) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303506 qdf_mem_free_consistent(wma_handle->qdf_dev,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303507 wma_handle->qdf_dev->dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 wma_handle->mem_chunks[idx].len,
3509 wma_handle->mem_chunks[idx].vaddr,
3510 wma_handle->mem_chunks[idx].paddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303511 qdf_get_dma_mem_context(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 (&(wma_handle->mem_chunks[idx])),
3513 memctx));
3514 }
3515
3516#if defined(QCA_WIFI_FTM)
3517 /* Detach UTF and unregister the handler */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303518 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519 wma_utf_detach(wma_handle);
3520#endif /* QCA_WIFI_FTM */
3521
3522 if (NULL != wma_handle->dfs_ic) {
3523 wma_dfs_detach(wma_handle->dfs_ic);
3524 wma_handle->dfs_ic = NULL;
3525 }
3526
3527 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303528 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 wma_handle->pGetRssiReq = NULL;
3530 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07003531
Srinivas Girigowdaad874a82016-10-25 14:08:00 -07003532 if (wma_handle->link_stats_results) {
3533 qdf_mem_free(wma_handle->link_stats_results);
3534 wma_handle->link_stats_results = NULL;
3535 }
3536
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07003537 wma_ndp_unregister_all_event_handlers(wma_handle);
3538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3540 WMI_SERVICE_MGMT_TX_WMI)) {
3541 wmi_desc_pool_deinit(wma_handle);
3542 }
3543
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303544 /* Decrease psoc ref count once APIs are available in object manager */
3545 wma_handle->psoc = NULL;
Frank Liu65b17d92016-11-23 15:58:44 +08003546 wma_target_if_close(wma_handle);
3547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303549 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550}
3551
3552/**
3553 * wma_update_fw_config() - update fw configuration
3554 * @wma_handle: wma handle
3555 * @tgt_cap: target capabality
3556 *
3557 * Return: none
3558 */
3559static void wma_update_fw_config(tp_wma_handle wma_handle,
3560 struct wma_target_cap *tgt_cap)
3561{
3562 /*
3563 * tgt_cap contains default target resource configuration
3564 * which can be modified here, if required
3565 */
3566 /* Override the no. of max fragments as per platform configuration */
3567 tgt_cap->wlan_resource_config.max_frag_entries =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303568 QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 wma_handle->max_frag_entry);
3570 wma_handle->max_frag_entry =
3571 tgt_cap->wlan_resource_config.max_frag_entries;
Arun Khandavalli3dd06de2016-08-17 10:20:29 +05303572
3573 /* Update no. of maxWoWFilters depending on BPF service */
3574 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3575 WMI_SERVICE_BPF_OFFLOAD))
3576 tgt_cap->wlan_resource_config.num_wow_filters =
Arun Khandavallid454d422016-08-17 12:47:05 +05303577 WMA_STA_WOW_DEFAULT_PTRN_MAX;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578}
3579
3580/**
3581 * wma_alloc_host_mem_chunk() - allocate host memory
3582 * @wma_handle: wma handle
3583 * @req_id: request id
3584 * @idx: index
3585 * @num_units: number of units
3586 * @unit_len: unit length
3587 *
3588 * allocate a chunk of memory at the index indicated and
3589 * if allocation fail allocate smallest size possiblr and
3590 * return number of units allocated.
3591 *
3592 * Return: number of units or 0 for error.
3593 */
3594static uint32_t wma_alloc_host_mem_chunk(tp_wma_handle wma_handle,
3595 uint32_t req_id, uint32_t idx,
3596 uint32_t num_units, uint32_t unit_len)
3597{
Anurag Chouhan6d760662016-02-20 16:05:43 +05303598 qdf_dma_addr_t paddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003599 if (!num_units || !unit_len) {
3600 return 0;
3601 }
3602 wma_handle->mem_chunks[idx].vaddr = NULL;
3603 /** reduce the requested allocation by half until allocation succeeds */
3604 while (wma_handle->mem_chunks[idx].vaddr == NULL && num_units) {
3605 wma_handle->mem_chunks[idx].vaddr =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303606 qdf_mem_alloc_consistent(wma_handle->qdf_dev,
3607 wma_handle->qdf_dev->dev,
3608 num_units * unit_len,
3609 &paddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 if (wma_handle->mem_chunks[idx].vaddr == NULL) {
3611 num_units = (num_units >> 1);/* reduce length by half */
3612 } else {
3613 wma_handle->mem_chunks[idx].paddr = paddr;
3614 wma_handle->mem_chunks[idx].len = num_units * unit_len;
3615 wma_handle->mem_chunks[idx].req_id = req_id;
3616 }
3617 }
3618 return num_units;
3619}
3620
3621#define HOST_MEM_SIZE_UNIT 4
3622/**
3623 * wma_alloc_host_mem() - allocate amount of memory requested by FW.
3624 * @wma_handle: wma handle
3625 * @req_id: request id
3626 * @num_units: number of units
3627 * @unit_len: unit length
3628 *
3629 * Return: none
3630 */
3631static void wma_alloc_host_mem(tp_wma_handle wma_handle, uint32_t req_id,
3632 uint32_t num_units, uint32_t unit_len)
3633{
3634 uint32_t remaining_units, allocated_units, idx;
3635
3636 /* adjust the length to nearest multiple of unit size */
3637 unit_len = (unit_len + (HOST_MEM_SIZE_UNIT - 1)) &
3638 (~(HOST_MEM_SIZE_UNIT - 1));
3639 idx = wma_handle->num_mem_chunks;
3640 remaining_units = num_units;
3641 while (remaining_units) {
3642 allocated_units = wma_alloc_host_mem_chunk(wma_handle, req_id,
3643 idx, remaining_units,
3644 unit_len);
3645 if (allocated_units == 0) {
3646 WMA_LOGE("FAILED TO ALLOCATED memory unit len %d"
3647 " units requested %d units allocated %d ",
3648 unit_len, num_units,
3649 (num_units - remaining_units));
3650 wma_handle->num_mem_chunks = idx;
3651 break;
3652 }
3653 remaining_units -= allocated_units;
3654 ++idx;
3655 if (idx == MAX_MEM_CHUNKS) {
3656 WMA_LOGE("RWACHED MAX CHUNK LIMIT for memory units %d"
3657 " unit len %d requested by FW,"
3658 " only allocated %d ",
3659 num_units, unit_len,
3660 (num_units - remaining_units));
3661 wma_handle->num_mem_chunks = idx;
3662 break;
3663 }
3664 }
3665 wma_handle->num_mem_chunks = idx;
3666}
3667
3668/**
3669 * wma_update_target_services() - update target services from wma handle
3670 * @wh: wma handle
3671 * @cfg: target services
3672 *
3673 * Return: none
3674 */
3675static inline void wma_update_target_services(tp_wma_handle wh,
3676 struct wma_tgt_services *cfg)
3677{
3678 /* STA power save */
3679 cfg->sta_power_save = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3680 WMI_SERVICE_STA_PWRSAVE);
3681
3682 /* Enable UAPSD */
3683 cfg->uapsd = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3684 WMI_SERVICE_AP_UAPSD);
3685
3686 /* Update AP DFS service */
3687 cfg->ap_dfs = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3688 WMI_SERVICE_AP_DFS);
3689
3690 /* Enable 11AC */
3691 cfg->en_11ac = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3692 WMI_SERVICE_11AC);
3693 if (cfg->en_11ac)
3694 g_fw_wlan_feat_caps |= (1 << DOT11AC);
3695
3696 /* Proactive ARP response */
3697 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
3698
3699 /* Enable WOW */
3700 g_fw_wlan_feat_caps |= (1 << WOW);
3701
3702 /* ARP offload */
3703 cfg->arp_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3704 WMI_SERVICE_ARPNS_OFFLOAD);
3705
3706 /* Adaptive early-rx */
3707 cfg->early_rx = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3708 WMI_SERVICE_EARLY_RX);
3709#ifdef FEATURE_WLAN_SCAN_PNO
3710 /* PNO offload */
3711 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NLO))
3712 cfg->pno_offload = true;
3713#endif /* FEATURE_WLAN_SCAN_PNO */
3714
3715#ifdef FEATURE_WLAN_EXTSCAN
3716 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_EXTSCAN)) {
3717 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
3718 }
3719#endif /* FEATURE_WLAN_EXTSCAN */
3720 cfg->lte_coex_ant_share = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3721 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT);
3722#ifdef FEATURE_WLAN_TDLS
3723 /* Enable TDLS */
3724 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_TDLS)) {
3725 cfg->en_tdls = 1;
3726 g_fw_wlan_feat_caps |= (1 << TDLS);
3727 }
3728 /* Enable advanced TDLS features */
3729 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3730 WMI_SERVICE_TDLS_OFFCHAN)) {
3731 cfg->en_tdls_offchan = 1;
3732 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
3733 }
3734
3735 cfg->en_tdls_uapsd_buf_sta =
3736 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3737 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA);
3738 cfg->en_tdls_uapsd_sleep_sta =
3739 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3740 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA);
3741#endif /* FEATURE_WLAN_TDLS */
3742 if (WMI_SERVICE_IS_ENABLED
3743 (wh->wmi_service_bitmap, WMI_SERVICE_BEACON_OFFLOAD))
3744 cfg->beacon_offload = true;
mukul sharma72c8b222015-09-04 17:02:01 +05303745 if (WMI_SERVICE_IS_ENABLED
3746 (wh->wmi_service_bitmap, WMI_SERVICE_STA_PMF_OFFLOAD))
3747 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3749 /* Enable Roam Offload */
3750 cfg->en_roam_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3751 WMI_SERVICE_ROAM_HO_OFFLOAD);
3752#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3753#ifdef WLAN_FEATURE_NAN
3754 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NAN))
3755 g_fw_wlan_feat_caps |= (1 << NAN);
3756#endif /* WLAN_FEATURE_NAN */
3757
3758 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_RTT))
3759 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07003760
3761 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3762 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT)) {
Leo Chang96464902016-10-28 11:10:54 -07003763 cdp_ipa_set_uc_tx_partition_base(
3764 cds_get_context(QDF_MODULE_ID_SOC),
3765 cds_get_context(QDF_MODULE_ID_CFG),
Yun Park4d968df2016-10-11 11:44:15 -07003766 HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
3767 WMA_LOGI("%s: TX_MSDU_ID_NEW_PARTITION=%d", __func__,
3768 HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
3769 } else {
Leo Chang96464902016-10-28 11:10:54 -07003770 cdp_ipa_set_uc_tx_partition_base(
3771 cds_get_context(QDF_MODULE_ID_SOC),
3772 cds_get_context(QDF_MODULE_ID_CFG),
Yun Park4d968df2016-10-11 11:44:15 -07003773 HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
3774 WMA_LOGI("%s: TX_MSDU_ID_OLD_PARTITION=%d", __func__,
3775 HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
3776 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777}
3778
3779/**
3780 * wma_update_target_ht_cap() - update ht capabality from wma handle
3781 * @wh: wma handle
3782 * @cfg: ht capabality
3783 *
3784 * Return: none
3785 */
3786static inline void wma_update_target_ht_cap(tp_wma_handle wh,
3787 struct wma_tgt_ht_cap *cfg)
3788{
3789 /* RX STBC */
3790 cfg->ht_rx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_RX_STBC);
3791
3792 /* TX STBC */
3793 cfg->ht_tx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_TX_STBC);
3794
3795 /* MPDU density */
3796 cfg->mpdu_density = wh->ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
3797
3798 /* HT RX LDPC */
3799 cfg->ht_rx_ldpc = !!(wh->ht_cap_info & WMI_HT_CAP_LDPC);
3800
3801 /* HT SGI */
3802 cfg->ht_sgi_20 = !!(wh->ht_cap_info & WMI_HT_CAP_HT20_SGI);
3803
3804 cfg->ht_sgi_40 = !!(wh->ht_cap_info & WMI_HT_CAP_HT40_SGI);
3805
3806 /* RF chains */
3807 cfg->num_rf_chains = wh->num_rf_chains;
3808
Jeff Johnson3fd21822016-11-08 11:30:37 -08003809 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n"
3810 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
3811 "ht_sgi_40 - %d num_rf_chains - %d", __func__, wh->ht_cap_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
3813 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
3814 cfg->num_rf_chains);
3815
3816}
3817
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818/**
3819 * wma_update_target_vht_cap() - update vht capabality from wma handle
3820 * @wh: wma handle
3821 * @cfg: vht capabality
3822 *
3823 * Return: none
3824 */
3825static inline void wma_update_target_vht_cap(tp_wma_handle wh,
3826 struct wma_tgt_vht_cap *cfg)
3827{
3828
3829 if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
3830 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
3831 else if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
3832 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
3833 else
3834 cfg->vht_max_mpdu = 0;
3835
3836
3837 if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
3838 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
3839 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
3840 } else if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ)
3841 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
3842 else
3843 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
3844
3845 cfg->vht_rx_ldpc = wh->vht_cap_info & WMI_VHT_CAP_RX_LDPC;
3846
3847 cfg->vht_short_gi_80 = wh->vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
3848 cfg->vht_short_gi_160 = wh->vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
3849
3850 cfg->vht_tx_stbc = wh->vht_cap_info & WMI_VHT_CAP_TX_STBC;
3851
3852 cfg->vht_rx_stbc = (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
3853 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
3854 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS) ;
3855
3856 cfg->vht_max_ampdu_len_exp = (wh->vht_cap_info &
3857 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
3858 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
3859
3860 cfg->vht_su_bformer = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
3861
3862 cfg->vht_su_bformee = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
3863
3864 cfg->vht_mu_bformer = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
3865
3866 cfg->vht_mu_bformee = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
3867
3868 cfg->vht_txop_ps = wh->vht_cap_info & WMI_VHT_CAP_TXOP_PS;
3869
Jeff Johnson3fd21822016-11-08 11:30:37 -08003870 WMA_LOGD("%s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
3871 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
3872 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
3874 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
3875 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
3876 cfg->vht_max_ampdu_len_exp);
3877}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878
3879/**
Krunal Soniaa664da2016-06-15 23:46:40 -07003880 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
3881 * @wma_handle: pointer to wma_handle
3882 * @ht_cap: given pointer to HT caps which needs to be updated
3883 * @tx_chain: given tx chainmask value
3884 * @rx_chain: given rx chainmask value
3885 * @value: new HT cap info provided in form of bitmask
3886 *
3887 * This function takes the value provided in form of bitmask and decodes
3888 * it. After decoding, what ever value it gets, it takes the union(max) or
3889 * intersection(min) with previously derived values.
3890 *
3891 * Return: none
3892 *
3893 */
3894static void wma_derive_ext_ht_cap(tp_wma_handle wma_handle,
3895 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
3896 uint32_t tx_chain, uint32_t rx_chain)
3897{
3898 struct wma_tgt_ht_cap tmp = {0};
3899
3900 if (NULL == wma_handle || NULL == ht_cap)
3901 return;
3902
Ankit Guptaa5076012016-09-14 11:32:19 -07003903 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07003904 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
3905 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
3906 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
3907 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
3908 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
3909 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
3910 ht_cap->num_rf_chains =
3911 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
3912 wma_get_num_of_setbits_from_bitmask(rx_chain));
3913 } else {
3914 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
3915 (!!(value & WMI_HT_CAP_RX_STBC)));
3916 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
3917 (!!(value & WMI_HT_CAP_TX_STBC)));
3918 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
3919 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
3920 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
3921 (!!(value & WMI_HT_CAP_RX_LDPC)));
3922 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
3923 (!!(value & WMI_HT_CAP_HT20_SGI)));
3924 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
3925 (!!(value & WMI_HT_CAP_HT40_SGI)));
3926 ht_cap->num_rf_chains =
3927 QDF_MAX(ht_cap->num_rf_chains,
3928 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
3929 tx_chain),
3930 wma_get_num_of_setbits_from_bitmask(
3931 rx_chain)));
3932 }
3933}
3934
3935/**
3936 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
3937 * @wma_handle: pointer to wma_handle
3938 * @ht_cap: HT cap structure to be filled
3939 *
3940 * This function loop through each hardware mode and for each hardware mode
3941 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
3942 * HT caps and derives the final cap.
3943 *
3944 * Return: none
3945 *
3946 */
3947static void wma_update_target_ext_ht_cap(tp_wma_handle wma_handle,
3948 struct wma_tgt_ht_cap *ht_cap)
3949{
3950 int i, j = 0, max_mac;
3951 uint32_t ht_2g, ht_5g;
3952 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
3953 struct extended_caps *phy_caps;
3954 WMI_MAC_PHY_CAPABILITIES *mac_cap;
3955
3956 /*
3957 * for legacy device extended cap might not even come, so in that case
3958 * don't overwrite legacy values
3959 */
3960 if (!wma_handle ||
3961 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
3962 WMA_LOGI("%s: No extended HT cap for current SOC", __func__);
3963 return;
3964 }
3965
3966 phy_caps = &wma_handle->phy_caps;
3967 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
3968 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
3969 max_mac = j + 2;
3970 else
3971 max_mac = j + 1;
3972 for ( ; j < max_mac; j++) {
3973 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
3974 ht_2g = mac_cap->ht_cap_info_2G;
3975 ht_5g = mac_cap->ht_cap_info_5G;
3976 if (ht_2g)
3977 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
3978 ht_2g, mac_cap->tx_chain_mask_2G,
3979 mac_cap->rx_chain_mask_2G);
3980 if (ht_5g)
3981 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
3982 ht_5g, mac_cap->tx_chain_mask_5G,
3983 mac_cap->rx_chain_mask_5G);
3984 }
3985 }
3986
Ankit Guptaa5076012016-09-14 11:32:19 -07003987 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07003988 sizeof(struct wma_tgt_ht_cap))) {
3989 qdf_mem_copy(ht_cap, &tmp_ht_cap,
3990 sizeof(struct wma_tgt_ht_cap));
3991 }
3992
Jeff Johnson3fd21822016-11-08 11:30:37 -08003993 WMA_LOGI("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n"
3994 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
3995 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07003996 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
3997 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
3998 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
3999 ht_cap->num_rf_chains);
4000}
4001
4002/**
4003 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
4004 * @wma_handle: pointer to wma_handle
4005 * @vht_cap: pointer to given VHT caps to be filled
4006 * @value: new VHT cap info provided in form of bitmask
4007 *
4008 * This function takes the value provided in form of bitmask and decodes
4009 * it. After decoding, what ever value it gets, it takes the union(max) or
4010 * intersection(min) with previously derived values.
4011 *
4012 * Return: none
4013 *
4014 */
4015static void wma_derive_ext_vht_cap(t_wma_handle *wma_handle,
4016 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
4017{
4018 struct wma_tgt_vht_cap tmp_cap = {0};
4019 uint32_t tmp = 0;
4020
4021 if (NULL == wma_handle || NULL == vht_cap)
4022 return;
4023
Ankit Guptaa5076012016-09-14 11:32:19 -07004024 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004025 sizeof(struct wma_tgt_vht_cap))) {
4026 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4027 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4028 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4029 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4030 else
4031 vht_cap->vht_max_mpdu = 0;
4032
4033 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
4034 vht_cap->supp_chan_width =
4035 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4036 vht_cap->supp_chan_width |=
4037 1 << eHT_CHANNEL_WIDTH_160MHZ;
4038 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4039 vht_cap->supp_chan_width =
4040 1 << eHT_CHANNEL_WIDTH_160MHZ;
4041 } else {
4042 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4043 }
4044 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
4045 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
4046 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
4047 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
4048 vht_cap->vht_rx_stbc =
4049 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4050 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4051 (value & WMI_VHT_CAP_RX_STBC_3SS);
4052 vht_cap->vht_max_ampdu_len_exp =
4053 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4054 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4055 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
4056 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
4057 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
4058 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
4059 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
4060 } else {
4061 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4062 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4063 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4064 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4065 else
4066 tmp = 0;
4067 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
4068
4069 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
4070 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
4071 (1 << eHT_CHANNEL_WIDTH_160MHZ);
4072 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4073 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
4074 } else {
4075 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4076 }
4077 vht_cap->supp_chan_width =
4078 QDF_MAX(vht_cap->supp_chan_width, tmp);
4079 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
4080 value & WMI_VHT_CAP_RX_LDPC);
4081 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
4082 value & WMI_VHT_CAP_SGI_80MHZ);
4083 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
4084 value & WMI_VHT_CAP_SGI_160MHZ);
4085 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
4086 value & WMI_VHT_CAP_TX_STBC);
4087 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
4088 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4089 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4090 (value & WMI_VHT_CAP_RX_STBC_3SS));
4091 vht_cap->vht_max_ampdu_len_exp =
4092 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
4093 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4094 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
4095 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
4096 value & WMI_VHT_CAP_SU_BFORMER);
4097 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
4098 value & WMI_VHT_CAP_SU_BFORMEE);
4099 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
4100 value & WMI_VHT_CAP_MU_BFORMER);
4101 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
4102 value & WMI_VHT_CAP_MU_BFORMEE);
4103 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
4104 value & WMI_VHT_CAP_TXOP_PS);
4105 }
4106}
4107
4108/**
4109 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
4110 * @wma_handle: pointer to wma_handle
4111 * @vht_cap: VHT cap structure to be filled
4112 *
4113 * This function loop through each hardware mode and for each hardware mode
4114 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
4115 * VHT caps and derives the final cap.
4116 *
4117 * Return: none
4118 *
4119 */
4120static void wma_update_target_ext_vht_cap(t_wma_handle *wma_handle,
4121 struct wma_tgt_vht_cap *vht_cap)
4122{
4123 int i, j = 0, max_mac;
4124 uint32_t vht_cap_info_2g, vht_cap_info_5g;
4125 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
4126 struct extended_caps *phy_caps;
4127 WMI_MAC_PHY_CAPABILITIES *mac_cap;
4128
4129 /*
4130 * for legacy device extended cap might not even come, so in that case
4131 * don't overwrite legacy values
4132 */
4133 if (!wma_handle ||
4134 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
4135 WMA_LOGI("%s: No extended VHT cap for current SOC", __func__);
4136 return;
4137 }
4138
4139 phy_caps = &wma_handle->phy_caps;
4140 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
4141 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
4142 max_mac = j + 2;
4143 else
4144 max_mac = j + 1;
4145 for ( ; j < max_mac; j++) {
4146 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
4147 vht_cap_info_2g = mac_cap->vht_cap_info_2G;
4148 vht_cap_info_5g = mac_cap->vht_cap_info_5G;
4149 if (vht_cap_info_2g)
4150 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4151 vht_cap_info_2g);
4152 if (vht_cap_info_5g)
4153 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4154 vht_cap_info_5g);
4155 }
4156 }
4157
Ankit Guptaa5076012016-09-14 11:32:19 -07004158 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004159 sizeof(struct wma_tgt_vht_cap))) {
4160 qdf_mem_copy(vht_cap, &tmp_vht_cap,
4161 sizeof(struct wma_tgt_vht_cap));
4162 }
4163
Jeff Johnson3fd21822016-11-08 11:30:37 -08004164 WMA_LOGI("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
4165 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
4166 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07004167 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
4168 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
4169 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
4170 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
4171 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
4172}
4173
4174/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304175 * wma_update_ra_rate_limit() - update wma config
4176 * @wma_handle: wma handle
4177 * @cfg: target config
4178 *
4179 * Return: none
4180 */
4181#ifdef FEATURE_WLAN_RA_FILTERING
4182static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4183 struct wma_tgt_cfg *cfg)
4184{
4185 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
4186}
4187#else
4188static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4189 struct wma_tgt_cfg *cfg)
4190{
4191}
4192#endif
4193
4194/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 * wma_update_hdd_cfg() - update HDD config
4196 * @wma_handle: wma handle
4197 *
4198 * Return: none
4199 */
4200static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
4201{
4202 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304203 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304205 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07004206
4207 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
4209 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
4210
4211 switch (wma_handle->phy_capability) {
4212 case WMI_11G_CAPABILITY:
4213 case WMI_11NG_CAPABILITY:
4214 tgt_cfg.band_cap = eCSR_BAND_24;
4215 break;
4216 case WMI_11A_CAPABILITY:
4217 case WMI_11NA_CAPABILITY:
4218 case WMI_11AC_CAPABILITY:
4219 tgt_cfg.band_cap = eCSR_BAND_5G;
4220 break;
4221 case WMI_11AG_CAPABILITY:
4222 case WMI_11NAG_CAPABILITY:
4223 default:
4224 tgt_cfg.band_cap = eCSR_BAND_ALL;
4225 }
4226
4227 tgt_cfg.max_intf_count = wma_handle->wlan_resource_config.num_vdevs;
4228
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304229 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230 ATH_MAC_LEN);
4231
4232 wma_update_target_services(wma_handle, &tgt_cfg.services);
4233 wma_update_target_ht_cap(wma_handle, &tgt_cfg.ht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234 wma_update_target_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07004235 /*
4236 * This will overwrite the structure filled by wma_update_target_ht_cap
4237 * and wma_update_target_vht_cap APIs.
4238 */
4239 wma_update_target_ext_ht_cap(wma_handle, &tgt_cfg.ht_cap);
4240 wma_update_target_ext_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241
4242 tgt_cfg.target_fw_version = wma_handle->target_fw_version;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07004243 tgt_cfg.target_fw_vers_ext = wma_handle->target_fw_vers_ext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244#ifdef WLAN_FEATURE_LPSS
4245 tgt_cfg.lpss_support = wma_handle->lpss_support;
4246#endif /* WLAN_FEATURE_LPSS */
4247 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Rajeev Kumare5a16822016-07-27 13:11:42 -07004248 tgt_cfg.bpf_enabled = wma_handle->bpf_enabled;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304249 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004250 tgt_cfg.fine_time_measurement_cap =
4251 wma_handle->fine_time_measurement_cap;
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05304252 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
4253 - WMI_TLV_HEADROOM;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08004254 wma_setup_egap_support(&tgt_cfg, wma_handle);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004255
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07004256 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07004257 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258}
4259
4260/**
4261 * wma_setup_wmi_init_msg() - fill wmi init message buffer
4262 * @wma_handle: wma handle
4263 * @ev: ready event fixed params
4264 * @param_buf: redy event TLVs
4265 * @len: buffer length
4266 *
4267 * Return: wmi buffer or NULL for error
4268 */
Govind Singhf25a0f12016-03-08 16:09:48 +05304269static int wma_setup_wmi_init_msg(tp_wma_handle wma_handle,
4270 wmi_service_ready_event_fixed_param *ev,
4271 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 wlan_host_mem_req *ev_mem_reqs;
4274 wmi_abi_version my_vers;
Govind Singhf25a0f12016-03-08 16:09:48 +05304275 wmi_abi_version host_abi_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 int num_whitelist;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 uint16_t idx;
4278 uint32_t num_units;
4279
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 ev_mem_reqs = param_buf->mem_reqs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281
4282 /* allocate memory requested by FW */
4283 if (ev->num_mem_reqs > WMI_MAX_MEM_REQS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304284 QDF_ASSERT(0);
Govind Singhf25a0f12016-03-08 16:09:48 +05304285 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 }
4287
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288 for (idx = 0; idx < ev->num_mem_reqs; ++idx) {
4289 num_units = ev_mem_reqs[idx].num_units;
4290 if (ev_mem_reqs[idx].num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4291 /*
4292 * number of units to allocate is number
4293 * of peers, 1 extra for self peer on
4294 * target. this needs to be fied, host
4295 * and target can get out of sync
4296 */
Govind Singhf25a0f12016-03-08 16:09:48 +05304297 num_units = wma_handle->wlan_resource_config.num_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298 }
4299 WMA_LOGD
4300 ("idx %d req %d num_units %d num_unit_info %d unit size %d actual units %d ",
4301 idx, ev_mem_reqs[idx].req_id,
4302 ev_mem_reqs[idx].num_units,
4303 ev_mem_reqs[idx].num_unit_info,
4304 ev_mem_reqs[idx].unit_size, num_units);
4305 wma_alloc_host_mem(wma_handle, ev_mem_reqs[idx].req_id,
4306 num_units, ev_mem_reqs[idx].unit_size);
4307 }
Govind Singhf25a0f12016-03-08 16:09:48 +05304308
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304309 qdf_mem_copy(&wma_handle->target_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310 &param_buf->fixed_param->fw_abi_vers,
4311 sizeof(wmi_abi_version));
4312 num_whitelist = sizeof(version_whitelist) /
4313 sizeof(wmi_whitelist_version_info);
4314 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
4315 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
4316 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
4317 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
4318 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
4319 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
4320
4321 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
4322 &my_vers,
4323 &param_buf->fixed_param->fw_abi_vers,
Govind Singhf25a0f12016-03-08 16:09:48 +05304324 &host_abi_vers);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325
Govind Singhf25a0f12016-03-08 16:09:48 +05304326 qdf_mem_copy(&wma_handle->final_abi_vers, &host_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327 sizeof(wmi_abi_version));
Govind Singhf25a0f12016-03-08 16:09:48 +05304328
4329 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004330}
4331
4332/**
4333 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
4334 * @wma_handle: WMA handle
4335 *
4336 * Prints the DBS HW modes sent by the FW as part
4337 * of WMI ready event
4338 *
4339 * Return: None
4340 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004341static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342{
4343 uint32_t i, param;
4344
4345 if (!wma_handle) {
4346 WMA_LOGE("%s: Invalid WMA handle", __func__);
4347 return;
4348 }
4349
4350 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
4351 param = wma_handle->hw_mode.hw_mode_list[i];
4352 WMA_LOGA("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
4353 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304354 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
4355 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
4356 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004357 WMA_LOGA("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
4358 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304359 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
4360 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
4361 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
4362 WMA_LOGA("%s:[%d] DBS:%d SBS:%d", __func__, i,
4363 WMA_HW_MODE_DBS_MODE_GET(param),
4364 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 }
4366}
4367
4368/**
4369 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
4370 * @wma_handle: WMA handle
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304371 * @scan_config: Scam mode configuration
4372 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 *
4374 * Enables all the valid bits of concurrent_scan_config_bits and
4375 * fw_mode_config_bits.
4376 *
4377 * Return: None
4378 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004379static void wma_init_scan_fw_mode_config(tp_wma_handle wma_handle,
4380 uint32_t scan_config,
4381 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004382{
Anurag Chouhan6d760662016-02-20 16:05:43 +05304383 tpAniSirGlobal mac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384
4385 WMA_LOGD("%s: Enter", __func__);
4386
4387 if (!mac) {
4388 WMA_LOGE("%s: Invalid mac handle", __func__);
4389 return;
4390 }
4391
4392 if (!wma_handle) {
4393 WMA_LOGE("%s: Invalid WMA handle", __func__);
4394 return;
4395 }
4396
4397 wma_handle->dual_mac_cfg.cur_scan_config = 0;
4398 wma_handle->dual_mac_cfg.cur_fw_mode_config = 0;
4399
4400 /* If dual mac features are disabled in the INI, we
4401 * need not proceed further
4402 */
4403 if (mac->dual_mac_feature_disable) {
4404 WMA_LOGE("%s: Disabling dual mac capabilities", __func__);
4405 /* All capabilites are initialized to 0. We can return */
4406 goto done;
4407 }
4408
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304409 /* Initialize concurrent_scan_config_bits with default FW value */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304411 wma_handle->dual_mac_cfg.cur_scan_config,
4412 WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_GET(scan_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413 WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304414 wma_handle->dual_mac_cfg.cur_scan_config,
4415 WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_GET(scan_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304417 wma_handle->dual_mac_cfg.cur_scan_config,
4418 WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_GET(scan_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304420 /* Initialize fw_mode_config_bits with default FW value */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 WMI_DBS_FW_MODE_CFG_DBS_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304422 wma_handle->dual_mac_cfg.cur_fw_mode_config,
4423 WMI_DBS_FW_MODE_CFG_DBS_GET(fw_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424 WMI_DBS_FW_MODE_CFG_AGILE_DFS_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304425 wma_handle->dual_mac_cfg.cur_fw_mode_config,
4426 WMI_DBS_FW_MODE_CFG_AGILE_DFS_GET(fw_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004427done:
4428 /* Initialize the previous scan/fw mode config */
4429 wma_handle->dual_mac_cfg.prev_scan_config =
4430 wma_handle->dual_mac_cfg.cur_scan_config;
4431 wma_handle->dual_mac_cfg.prev_fw_mode_config =
4432 wma_handle->dual_mac_cfg.cur_fw_mode_config;
4433
4434 WMA_LOGD("%s: cur_scan_config:%x cur_fw_mode_config:%x",
4435 __func__,
4436 wma_handle->dual_mac_cfg.cur_scan_config,
4437 wma_handle->dual_mac_cfg.cur_fw_mode_config);
4438}
4439
4440/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304441 * wma_update_ra_limit() - update ra limit based on bpf filter
4442 * enabled or not
4443 * @handle: wma handle
4444 *
4445 * Return: none
4446 */
4447#ifdef FEATURE_WLAN_RA_FILTERING
4448static void wma_update_ra_limit(tp_wma_handle wma_handle)
4449{
4450 if (wma_handle->bpf_enabled)
4451 wma_handle->IsRArateLimitEnabled = false;
4452}
4453#else
4454static void wma_update_ra__limit(tp_wma_handle handle)
4455{
4456}
4457#endif
4458
4459/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 * wma_rx_service_ready_event() - event handler to process
4461 * wmi rx sevice ready event.
4462 * @handle: wma handle
4463 * @cmd_param_info: command params info
4464 *
4465 * Return: none
4466 */
Govind Singhd76a5b02016-03-08 15:12:14 +05304467int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
4468 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 tp_wma_handle wma_handle = (tp_wma_handle) handle;
4471 struct wma_target_cap target_cap;
4472 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
4473 wmi_service_ready_event_fixed_param *ev;
4474 int status;
4475 uint32_t *ev_wlan_dbs_hw_mode_list;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304476 QDF_STATUS ret;
Leo Chang96464902016-10-28 11:10:54 -07004477 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478
4479 WMA_LOGD("%s: Enter", __func__);
4480
4481 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
4482 if (!(handle && param_buf)) {
4483 WMA_LOGP("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304484 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 }
4486
4487 ev = param_buf->fixed_param;
4488 if (!ev) {
4489 WMA_LOGP("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304490 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 }
4492
4493 WMA_LOGA("WMA <-- WMI_SERVICE_READY_EVENTID");
4494
4495 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
4496 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
4497 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304498 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 wma_handle->num_dbs_hw_modes);
4500 if (!wma_handle->hw_mode.hw_mode_list) {
4501 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
4502 /* Continuing with the rest of the processing */
4503 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304504 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 ev_wlan_dbs_hw_mode_list,
4506 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
4507 wma_handle->num_dbs_hw_modes));
4508
4509 wma_dump_dbs_hw_mode(wma_handle);
4510
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304511 /* Initializes the fw_mode and scan_config to zero.
4512 * If ext service ready event is present it will set
4513 * the actual values of these two params.
4514 * This is to ensure that no garbage values would be
4515 * present in the absence of ext service ready event.
4516 */
4517 wma_init_scan_fw_mode_config(wma_handle, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518
4519 wma_handle->phy_capability = ev->phy_capability;
4520 wma_handle->max_frag_entry = ev->max_frag_entry;
4521 wma_handle->num_rf_chains = ev->num_rf_chains;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304522 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 sizeof(HAL_REG_CAPABILITIES));
4524 wma_handle->ht_cap_info = ev->ht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 wma_handle->vht_cap_info = ev->vht_cap_info;
4526 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 wma_handle->num_rf_chains = ev->num_rf_chains;
4528
4529 wma_handle->target_fw_version = ev->fw_build_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530 wma_handle->new_hw_mode_index = ev->default_dbs_hw_mode_index;
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004531 wma_handle->fine_time_measurement_cap = ev->wmi_fw_sub_feat_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532
4533 WMA_LOGD("%s: Firmware default hw mode index : %d",
4534 __func__, ev->default_dbs_hw_mode_index);
4535 WMA_LOGE("%s: Firmware build version : %08x",
4536 __func__, ev->fw_build_vers);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004537 WMA_LOGD(FL("FW fine time meas cap: 0x%x"), ev->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538
4539 if (ev->hw_bd_id) {
4540 wma_handle->hw_bd_id = ev->hw_bd_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304541 qdf_mem_copy(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542 ev->hw_bd_info, sizeof(ev->hw_bd_info));
4543
4544 WMA_LOGE("%s: Board version: %x.%x",
4545 __func__,
4546 wma_handle->hw_bd_info[0], wma_handle->hw_bd_info[1]);
4547 } else {
4548 wma_handle->hw_bd_id = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304549 qdf_mem_zero(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550 sizeof(wma_handle->hw_bd_info));
4551 WMA_LOGE("%s: Board version is unknown!", __func__);
4552 }
Rakesh Sunki8641f8a2015-12-10 15:11:19 -08004553 wma_handle->dfs_ic->dfs_hw_bd_id = wma_handle->hw_bd_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554
4555 /* TODO: Recheck below line to dump service ready event */
4556 /* dbg_print_wmi_service_11ac(ev); */
4557
4558 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304559 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 param_buf->wmi_service_bitmap,
4561 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05304562
Leo Chang96464902016-10-28 11:10:54 -07004563 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(soc,
Nirav Shah22bf44d2015-12-10 15:39:48 +05304564 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4565 WMI_SERVICE_MGMT_TX_WMI));
Leo Chang96464902016-10-28 11:10:54 -07004566 cdp_set_desc_global_pool_size(soc, ev->num_msdu_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 /* SWBA event handler for beacon transmission */
4568 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4569 WMI_HOST_SWBA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304570 wma_beacon_swba_handler,
4571 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 if (status) {
4573 WMA_LOGE("Failed to register swba beacon event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304574 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 }
4576#ifdef WLAN_FEATURE_LPSS
4577 wma_handle->lpss_support =
4578 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4579 WMI_SERVICE_LPASS);
4580#endif /* WLAN_FEATURE_LPSS */
4581
4582 /*
4583 * This Service bit is added to check for ARP/NS Offload
4584 * support for LL/HL targets
4585 */
4586 wma_handle->ap_arpns_support =
4587 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4588 WMI_SERVICE_AP_ARPNS_OFFLOAD);
4589
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304590 wma_handle->bpf_enabled = (wma_handle->bpf_packet_filter_enable &&
Rajeev Kumare5a16822016-07-27 13:11:42 -07004591 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304592 WMI_SERVICE_BPF_OFFLOAD));
4593 wma_update_ra_limit(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4595 WMI_SERVICE_CSA_OFFLOAD)) {
4596 WMA_LOGD("%s: FW support CSA offload capability", __func__);
4597 status =
4598 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304599 WMI_CSA_HANDLING_EVENTID,
4600 wma_csa_offload_handler,
4601 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 if (status) {
4603 WMA_LOGE("Failed to register CSA offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304604 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 }
4606 }
4607
4608 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4609 WMI_SERVICE_MGMT_TX_WMI)) {
4610 WMA_LOGE("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
4611 status = wmi_desc_pool_init(wma_handle, WMI_DESC_POOL_MAX);
4612 if (status) {
4613 WMA_LOGE("Failed to initialize wmi descriptor pool");
Govind Singhd76a5b02016-03-08 15:12:14 +05304614 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 }
4616 /*
4617 * Register Tx completion event handler for MGMT Tx over WMI
4618 * case
4619 */
4620 status = wmi_unified_register_event_handler(
4621 wma_handle->wmi_handle,
4622 WMI_MGMT_TX_COMPLETION_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304623 wma_mgmt_tx_completion_handler,
4624 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 if (status) {
4626 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Govind Singhd76a5b02016-03-08 15:12:14 +05304627 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628 }
4629
Nirav Shah20489972016-06-16 19:20:28 +05304630 status = wmi_unified_register_event_handler(
4631 wma_handle->wmi_handle,
4632 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID,
4633 wma_mgmt_tx_bundle_completion_handler,
4634 WMA_RX_SERIALIZER_CTX);
4635 if (status) {
4636 WMA_LOGE("Failed to register MGMT over WMI completion handler");
4637 return -EINVAL;
4638 }
4639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 } else {
4641 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
4642 }
4643#ifdef WLAN_FEATURE_GTK_OFFLOAD
4644 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4645 WMI_SERVICE_GTK_OFFLOAD)) {
4646 status =
4647 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304648 WMI_GTK_OFFLOAD_STATUS_EVENTID,
4649 wma_gtk_offload_status_event,
4650 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 if (status) {
4652 WMA_LOGE("Failed to register GTK offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304653 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 }
4655 }
4656#endif /* WLAN_FEATURE_GTK_OFFLOAD */
4657
4658 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4659 WMI_P2P_NOA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304660 wma_p2p_noa_event_handler,
4661 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662 if (status) {
4663 WMA_LOGE("Failed to register WMI_P2P_NOA_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05304664 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 }
4666 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304667 WMI_TBTTOFFSET_UPDATE_EVENTID,
4668 wma_tbttoffset_update_event_handler,
4669 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 if (status) {
4671 WMA_LOGE
4672 ("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05304673 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 }
4675
Govind Singhefc5ccd2016-04-25 11:11:55 +05304676 /* mac_id is replaced with pdev_id in converged firmware to have
4677 * multi-radio support. In order to maintain backward compatibility
4678 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
4679 * in service bitmap from FW and host needs to set use_pdev_id in
4680 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
4681 * service is not set, then host shall not expect MAC ID from FW in
4682 * VDEV START RESPONSE event and host shall use PDEV ID.
4683 */
4684 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4685 WMI_SERVICE_DEPRECATED_REPLACE))
4686 wma_handle->wlan_resource_config.use_pdev_id = true;
4687 else
4688 wma_handle->wlan_resource_config.use_pdev_id = false;
4689
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08004690 /* register the Enhanced Green AP event handler */
4691 wma_register_egap_event_handle(wma_handle);
4692
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 /* Initialize the log supported event handler */
4694 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4695 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304696 wma_log_supported_evt_handler,
4697 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304698 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 WMA_LOGE("Failed to register log supported event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304700 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701 }
4702
Leo Chang96464902016-10-28 11:10:54 -07004703 cdp_mark_first_wakeup_packet(soc,
Himanshu Agarwal19141bb2016-07-20 20:15:48 +05304704 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4705 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET));
4706
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07004707 wma_handle->nan_datapath_enabled =
4708 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4709 WMI_SERVICE_NAN_DATA);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304710 qdf_mem_copy(target_cap.wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711 param_buf->wmi_service_bitmap,
4712 sizeof(wma_handle->wmi_service_bitmap));
4713 target_cap.wlan_resource_config = wma_handle->wlan_resource_config;
4714 wma_update_fw_config(wma_handle, &target_cap);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304715 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 target_cap.wmi_service_bitmap,
4717 sizeof(wma_handle->wmi_service_bitmap));
4718 wma_handle->wlan_resource_config = target_cap.wlan_resource_config;
4719
Govind Singhf25a0f12016-03-08 16:09:48 +05304720 status = wmi_unified_save_fw_version_cmd(wma_handle->wmi_handle,
4721 param_buf);
4722 if (status != EOK) {
4723 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
4724 return -EINVAL;
4725 }
4726
4727 status = wma_setup_wmi_init_msg(wma_handle, ev, param_buf);
4728 if (status != EOK) {
4729 WMA_LOGE("Failed to setup for wma init command");
Govind Singhd76a5b02016-03-08 15:12:14 +05304730 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731 }
4732
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304733 /* A host, which supports WMI_SERVICE_READY_EXT_EVENTID, would need to
4734 * check the WMI_SERVICE_READY message for an "extension" flag, and if
4735 * this flag is set, then hold off on sending the WMI_INIT message until
4736 * WMI_SERVICE_READY_EXT_EVENTID is received.
4737 */
4738 if (!WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4739 WMI_SERVICE_EXT_MSG)) {
4740 /* No service extended message support.
4741 * Send INIT command immediately
4742 */
4743 WMA_LOGA("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05304744 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
4745 &wma_handle->wlan_resource_config,
4746 wma_handle->num_mem_chunks,
4747 wma_handle->mem_chunks, 1);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304748 if (status != EOK) {
4749 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Govind Singhd76a5b02016-03-08 15:12:14 +05304750 return -EINVAL;
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304751 }
4752 } else {
Govind Singhf25a0f12016-03-08 16:09:48 +05304753 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
4754 &wma_handle->wlan_resource_config,
4755 wma_handle->num_mem_chunks,
4756 wma_handle->mem_chunks, 0);
4757 if (status != EOK) {
4758 WMA_LOGE("Failed to save WMI_INIT_CMDID command parameter");
4759 return -EINVAL;
4760 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304761 /* The saved 'buf' will be freed after sending INIT command or
4762 * in other cases as required
4763 */
Anurag Chouhan210db072016-02-22 18:42:15 +05304764 ret = qdf_mc_timer_start(&wma_handle->service_ready_ext_timer,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304765 WMA_SERVICE_READY_EXT_TIMEOUT);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304766 if (!QDF_IS_STATUS_SUCCESS(ret))
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304767 WMA_LOGP("Failed to start the service ready ext timer");
4768
4769 WMA_LOGA("%s: WMA waiting for WMI_SERVICE_READY_EXT_EVENTID",
4770 __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004771 }
Govind Singhd76a5b02016-03-08 15:12:14 +05304772
4773 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004774}
4775
4776/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07004777 * wma_get_phyid_for_given_band() - to get phyid for band
4778 *
4779 * @wma_handle: Pointer to wma handle
4780 * @map: Pointer to map which is derived from hw mode & has mapping between
4781 * hw mode and available PHYs for that hw mode.
4782 * @band: enum value of for 2G or 5G band
4783 * @phyid: Pointer to phyid which needs to be filled
4784 *
4785 * This API looks in to the map to find out which particular phy supports
4786 * provided band and return the idx (also called phyid) of that phy. Caller
4787 * use this phyid to fetch various caps of that phy
4788 *
4789 * Return: QDF_STATUS
4790 */
4791static QDF_STATUS wma_get_phyid_for_given_band(
4792 t_wma_handle * wma_handle,
4793 struct hw_mode_idx_to_mac_cap_idx *map,
4794 enum cds_band_type band, uint8_t *phyid)
4795{
4796 uint8_t idx, i;
4797 WMI_MAC_PHY_CAPABILITIES *cap;
4798
4799 if (!wma_handle) {
4800 WMA_LOGE("Invalid wma handle");
4801 return QDF_STATUS_E_FAILURE;
4802 }
4803
4804 if (!map) {
4805 WMA_LOGE("Invalid given map");
4806 return QDF_STATUS_E_FAILURE;
4807 }
4808 idx = map->mac_cap_idx;
4809 *phyid = idx;
4810
4811 for (i = 0; i < map->num_of_macs; i++) {
4812 cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[idx + i];
4813 if ((band == CDS_BAND_2GHZ) &&
4814 (WLAN_2G_CAPABILITY == cap->supported_bands)) {
4815 *phyid = idx + i;
4816 WMA_LOGI("Select 2G capable phyid[%d]", *phyid);
4817 return QDF_STATUS_SUCCESS;
4818 } else if ((band == CDS_BAND_5GHZ) &&
4819 (WLAN_5G_CAPABILITY == cap->supported_bands)) {
4820 *phyid = idx + i;
4821 WMA_LOGI("Select 5G capable phyid[%d]", *phyid);
4822 return QDF_STATUS_SUCCESS;
4823 }
4824 }
4825 WMA_LOGI("Using default single hw mode phyid[%d]", *phyid);
4826 return QDF_STATUS_SUCCESS;
4827}
4828
4829/**
4830 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
4831 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
4832 * @hw_mode: Provided hardware mode
4833 * @band: Provide band i.e. 2G or 5G
4834 *
4835 * This API finds cap which suitable for provided hw mode and band. If user
4836 * is provides some invalid hw mode then it will automatically falls back to
4837 * default hw mode
4838 *
4839 * Return: QDF_STATUS
4840 */
4841QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
4842 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
4843{
4844 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
4845 struct hw_mode_idx_to_mac_cap_idx *map;
4846 WMI_MAC_PHY_CAPABILITIES *phy_cap;
4847 uint8_t phyid, our_hw_mode = hw_mode;
4848
4849 if (!wma_handle) {
4850 WMA_LOGE("Invalid wma handle");
4851 return QDF_STATUS_E_FAILURE;
4852 }
4853
4854 if (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes) {
4855 WMA_LOGE("Invalid number of hw modes");
4856 return QDF_STATUS_E_FAILURE;
4857 }
4858
4859 if (!wma_is_dbs_enable())
4860 our_hw_mode = HW_MODE_DBS_NONE;
4861
4862 if (!caps_per_phy) {
4863 WMA_LOGE("Invalid caps pointer");
4864 return QDF_STATUS_E_FAILURE;
4865 }
4866
4867 map = &wma_handle->phy_caps.hw_mode_to_mac_cap_map[our_hw_mode];
4868
4869 if (QDF_STATUS_SUCCESS !=
4870 wma_get_phyid_for_given_band(wma_handle, map, band, &phyid)) {
4871 WMA_LOGE("Invalid phyid");
4872 return QDF_STATUS_E_FAILURE;
4873 }
4874 phy_cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[phyid];
4875
4876 caps_per_phy->ht_2g = phy_cap->ht_cap_info_2G;
4877 caps_per_phy->ht_5g = phy_cap->ht_cap_info_5G;
4878 caps_per_phy->vht_2g = phy_cap->vht_cap_info_2G;
4879 caps_per_phy->vht_5g = phy_cap->vht_cap_info_5G;
4880 caps_per_phy->he_2g = phy_cap->he_cap_info_2G;
4881 caps_per_phy->he_5g = phy_cap->he_cap_info_5G;
4882
4883 return QDF_STATUS_SUCCESS;
4884}
4885
4886/**
4887 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
4888 *
4889 * @channel: Channel number for which it needs to check if rx ldpc is enabled
4890 *
4891 * This API takes channel number as argument and takes default hw mode as DBS
4892 * to check if rx LDPC support is enabled for that channel or no
4893 */
4894bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
4895{
4896 struct wma_caps_per_phy caps_per_phy = {0};
4897 enum cds_band_type band;
4898 bool status;
4899
4900 if (!CDS_IS_CHANNEL_24GHZ(channel))
4901 band = CDS_BAND_5GHZ;
4902 else
4903 band = CDS_BAND_2GHZ;
4904
4905 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
4906 &caps_per_phy,
4907 HW_MODE_DBS, band)) {
4908 return false;
4909 }
4910 if (CDS_IS_CHANNEL_24GHZ(channel))
4911 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
4912 else
4913 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
4914
4915 return status;
4916}
4917
4918
4919/**
Krunal Soni2e48d012016-05-02 16:55:26 -07004920 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
4921 * @wma_handle: pointer to wma_handle
4922 *
4923 * This function prints all the caps populater per hw mode and per PHY
4924 *
4925 * Return: none
4926 */
4927static void wma_print_populate_soc_caps(t_wma_handle *wma_handle)
4928{
4929 int i, j = 0, max_mac;
4930 WMI_MAC_PHY_CAPABILITIES *tmp;
4931
4932 /* print number of hw modes */
4933 WMA_LOGI("%s: num of hw modes [%d]", __func__,
4934 wma_handle->phy_caps.num_hw_modes.num_hw_modes);
4935 WMA_LOGI("%s: <====== HW mode cap printing starts ======>", __func__);
4936 /* print cap of each hw mode */
4937 for (i = 0; i < wma_handle->phy_caps.num_hw_modes.num_hw_modes; i++) {
4938 WMA_LOGI("====>: hw mode id[%d], phy_id map[%d]",
4939 wma_handle->phy_caps.each_hw_mode_cap[i].hw_mode_id,
4940 wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map);
4941 if (wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map ==
4942 PHY1_PHY2)
4943 max_mac = j + 2;
4944 else
4945 max_mac = j + 1;
4946
4947 for ( ; j < max_mac; j++) {
4948 tmp = &wma_handle->phy_caps.each_phy_cap_per_hwmode[j];
4949 WMA_LOGI("\t: index j[%d]", j);
4950 WMA_LOGI("\t: cap for hw_mode_id[%d]", tmp->hw_mode_id);
4951 WMA_LOGI("\t: pdev_id[%d]", tmp->pdev_id);
4952 WMA_LOGI("\t: phy_id[%d]", tmp->phy_id);
4953 WMA_LOGI("\t: supports_11b[%d]",
4954 WMI_SUPPORT_11B_GET(tmp->supported_flags));
4955 WMA_LOGI("\t: supports_11g[%d]",
4956 WMI_SUPPORT_11G_GET(tmp->supported_flags));
4957 WMA_LOGI("\t: supports_11a[%d]",
4958 WMI_SUPPORT_11A_GET(tmp->supported_flags));
4959 WMA_LOGI("\t: supports_11n[%d]",
4960 WMI_SUPPORT_11N_GET(tmp->supported_flags));
4961 WMA_LOGI("\t: supports_11ac[%d]",
4962 WMI_SUPPORT_11AC_GET(tmp->supported_flags));
4963 WMA_LOGI("\t: supports_11ax[%d]",
4964 WMI_SUPPORT_11AX_GET(tmp->supported_flags));
4965 WMA_LOGI("\t: supported_flags[%d]",
4966 tmp->supported_flags);
4967 WMA_LOGI("\t: supported_bands[%d]",
4968 tmp->supported_bands);
4969 WMA_LOGI("\t: ampdu_density[%d]",
4970 tmp->ampdu_density);
4971 WMA_LOGI("\t: max_bw_supported_2G[%d]",
4972 tmp->max_bw_supported_2G);
4973 WMA_LOGI("\t: ht_cap_info_2G[%d]", tmp->ht_cap_info_2G);
4974 WMA_LOGI("\t: vht_cap_info_2G[%d]",
4975 tmp->vht_cap_info_2G);
4976 WMA_LOGI("\t: he_cap_info_2G[%d]", tmp->he_cap_info_2G);
4977 WMA_LOGI("\t: vht_supp_mcs_2G[%d]",
4978 tmp->vht_supp_mcs_2G);
4979 WMA_LOGI("\t: he_supp_mcs_2G[%d]", tmp->he_supp_mcs_2G);
4980 WMA_LOGI("\t: tx_chain_mask_2G[%d]",
4981 tmp->tx_chain_mask_2G);
4982 WMA_LOGI("\t: rx_chain_mask_2G[%d]",
4983 tmp->rx_chain_mask_2G);
4984 WMA_LOGI("\t: max_bw_supported_5G[%d]",
4985 tmp->max_bw_supported_5G);
4986 WMA_LOGI("\t: ht_cap_info_5G[%d]",
4987 tmp->ht_cap_info_5G);
4988 WMA_LOGI("\t: vht_cap_info_5G[%d]",
4989 tmp->vht_cap_info_5G);
4990 WMA_LOGI("\t: he_cap_info_5G[%d]", tmp->he_cap_info_5G);
4991 WMA_LOGI("\t: vht_supp_mcs_5G[%d]",
4992 tmp->vht_supp_mcs_5G);
4993 WMA_LOGI("\t: he_supp_mcs_5G[%d]", tmp->he_supp_mcs_5G);
4994 WMA_LOGI("\t: tx_chain_mask_5G[%d]",
4995 tmp->tx_chain_mask_5G);
4996 WMA_LOGI("\t: rx_chain_mask_5G[%d]",
4997 tmp->rx_chain_mask_5G);
4998 }
4999 }
5000 WMA_LOGI("%s: <====== HW mode cap printing ends ======>\n", __func__);
5001}
5002
5003/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305004 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
5005 * in terms of hw_mode_bandwidth
5006 * @width: bandwidth in terms of wmi_channel_width
5007 *
5008 * This function returns the bandwidth in terms of hw_mode_bandwidth.
5009 *
5010 * Return: BW in terms of hw_mode_bandwidth.
5011 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005012static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305013 wmi_channel_width width)
5014{
5015 switch (width) {
5016 case WMI_CHAN_WIDTH_20:
5017 return HW_MODE_20_MHZ;
5018 case WMI_CHAN_WIDTH_40:
5019 return HW_MODE_40_MHZ;
5020 case WMI_CHAN_WIDTH_80:
5021 return HW_MODE_80_MHZ;
5022 case WMI_CHAN_WIDTH_160:
5023 return HW_MODE_160_MHZ;
5024 case WMI_CHAN_WIDTH_80P80:
5025 return HW_MODE_80_PLUS_80_MHZ;
5026 case WMI_CHAN_WIDTH_5:
5027 return HW_MODE_5_MHZ;
5028 case WMI_CHAN_WIDTH_10:
5029 return HW_MODE_10_MHZ;
5030 default:
5031 return HW_MODE_BW_NONE;
5032 }
5033
5034 return HW_MODE_BW_NONE;
5035}
5036
5037/**
5038 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
5039 * supported from the capabilities.
5040 * @caps: PHY capability
5041 * @info: param to store TX-RX stream and BW information
5042 *
5043 * This function will calculate TX-RX stream and bandwidth supported
5044 * as per the PHY capability, and assign to mac_ss_bw_info.
5045 *
5046 * Return: none
5047 */
5048static void wma_get_hw_mode_params(WMI_MAC_PHY_CAPABILITIES *caps,
5049 struct mac_ss_bw_info *info)
5050{
5051 if (!caps) {
5052 WMA_LOGE("%s: Invalid capabilities", __func__);
5053 return;
5054 }
5055
5056 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
5057 QDF_MAX(caps->tx_chain_mask_2G,
5058 caps->tx_chain_mask_5G));
5059 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
5060 QDF_MAX(caps->rx_chain_mask_2G,
5061 caps->rx_chain_mask_5G));
5062 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
5063 QDF_MAX(caps->max_bw_supported_2G,
5064 caps->max_bw_supported_5G));
5065}
5066
5067/**
5068 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
5069 * DBS in hw_mode_list
5070 * @wma_handle: pointer to wma global structure
5071 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
5072 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
5073 * @pos: refers to hw_mode_index
5074 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305075 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305076 *
5077 * This function sets TX-RX stream, bandwidth and DBS mode in
5078 * hw_mode_list.
5079 *
5080 * Return: none
5081 */
5082static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
5083 struct mac_ss_bw_info mac0_ss_bw_info,
5084 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305085 uint32_t pos, uint32_t dbs_mode,
5086 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305087{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305088 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305089 wma_handle->hw_mode.hw_mode_list[pos],
5090 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305091 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305092 wma_handle->hw_mode.hw_mode_list[pos],
5093 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305094 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305095 wma_handle->hw_mode.hw_mode_list[pos],
5096 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305097 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305098 wma_handle->hw_mode.hw_mode_list[pos],
5099 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305100 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305101 wma_handle->hw_mode.hw_mode_list[pos],
5102 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305103 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305104 wma_handle->hw_mode.hw_mode_list[pos],
5105 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305106 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305107 wma_handle->hw_mode.hw_mode_list[pos],
5108 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305109 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305110 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305111 HW_MODE_AGILE_DFS_NONE);
5112 WMA_HW_MODE_SBS_MODE_SET(
5113 wma_handle->hw_mode.hw_mode_list[pos],
5114 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305115}
5116
5117/**
5118 * wma_update_hw_mode_list() - updates hw_mode_list
5119 * @wma_handle: pointer to wma global structure
5120 *
5121 * This function updates hw_mode_list with tx_streams, rx_streams,
5122 * bandwidth, dbs and agile dfs for each hw_mode.
5123 *
5124 * Returns: 0 for success else failure.
5125 */
5126static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle)
5127{
5128 struct extended_caps *phy_caps;
5129 WMI_MAC_PHY_CAPABILITIES *tmp;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305130 uint32_t i, hw_config_type, j = 0;
5131 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305132 struct mac_ss_bw_info mac0_ss_bw_info = {0};
5133 struct mac_ss_bw_info mac1_ss_bw_info = {0};
5134
5135 if (!wma_handle) {
5136 WMA_LOGE("%s: Invalid wma handle", __func__);
5137 return QDF_STATUS_E_FAILURE;
5138 }
5139
5140 phy_caps = &wma_handle->phy_caps;
5141 if (!phy_caps) {
5142 WMA_LOGE("%s: Invalid phy capabilities", __func__);
5143 return QDF_STATUS_SUCCESS;
5144 }
5145
5146 if (!phy_caps->num_hw_modes.num_hw_modes) {
5147 WMA_LOGE("%s: Number of HW modes: %d",
5148 __func__, phy_caps->num_hw_modes.num_hw_modes);
5149 return QDF_STATUS_SUCCESS;
5150 }
5151
5152 /*
5153 * This list was updated as part of service ready event. Re-populate
5154 * HW mode list from the device capabilities.
5155 */
5156 if (wma_handle->hw_mode.hw_mode_list) {
5157 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
5158 wma_handle->hw_mode.hw_mode_list = NULL;
5159 WMA_LOGI("%s: DBS list is freed", __func__);
5160 }
5161
5162 wma_handle->num_dbs_hw_modes = phy_caps->num_hw_modes.num_hw_modes;
5163 wma_handle->hw_mode.hw_mode_list =
5164 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
5165 wma_handle->num_dbs_hw_modes);
5166 if (!wma_handle->hw_mode.hw_mode_list) {
5167 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
5168 return QDF_STATUS_E_FAILURE;
5169 }
5170
5171 WMA_LOGA("%s: Updated HW mode list: Num modes:%d",
5172 __func__, wma_handle->num_dbs_hw_modes);
5173
5174 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5175 /* Update for MAC0 */
5176 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5177 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
5178 hw_config_type =
5179 phy_caps->each_hw_mode_cap[i].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305180 dbs_mode = HW_MODE_DBS_NONE;
5181 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305182 mac1_ss_bw_info.mac_tx_stream = 0;
5183 mac1_ss_bw_info.mac_rx_stream = 0;
5184 mac1_ss_bw_info.mac_bw = 0;
5185
5186 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
5187 if ((hw_config_type == WMI_HW_MODE_DBS) ||
5188 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5189 (hw_config_type == WMI_HW_MODE_SBS)) {
5190 /* Update for MAC1 */
5191 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5192 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305193 if (hw_config_type == WMI_HW_MODE_DBS)
5194 dbs_mode = HW_MODE_DBS;
5195 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5196 (hw_config_type == WMI_HW_MODE_SBS))
5197 sbs_mode = HW_MODE_SBS;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305198 }
5199
5200 /* Updating HW mode list */
5201 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305202 mac1_ss_bw_info, i, dbs_mode,
5203 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305204 }
5205 wma_dump_dbs_hw_mode(wma_handle);
5206 return QDF_STATUS_SUCCESS;
5207}
5208
5209/**
Krunal Soni2e48d012016-05-02 16:55:26 -07005210 * wma_populate_soc_caps() - populate entire SOC's capabilities
5211 * @wma_handle: pointer to wma global structure
5212 * @param_buf: pointer to param of service ready extension event from fw
5213 *
5214 * This API populates all capabilities of entire SOC. For example,
5215 * how many number of hw modes are supported by this SOC, what are the
5216 * capabilities of each phy per hw mode, what are HAL reg capabilities per
5217 * phy.
5218 *
5219 * Return: none
5220 */
5221static void wma_populate_soc_caps(t_wma_handle *wma_handle,
5222 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
5223{
5224 int i, num_of_mac_caps = 0, tmp = 0;
5225 struct extended_caps *phy_caps;
5226 struct hw_mode_idx_to_mac_cap_idx *map;
5227
5228 WMA_LOGD("%s: Enter", __func__);
5229
5230 if (!wma_handle) {
5231 WMA_LOGP("%s: Invalid WMA handle", __func__);
5232 return;
5233 }
5234
5235 if (!param_buf) {
5236 WMA_LOGP("%s: Invalid event", __func__);
5237 return;
5238 }
5239 phy_caps = &wma_handle->phy_caps;
5240
5241 /*
5242 * first thing to do is to get how many number of hw modes are
5243 * supported and populate in wma_handle global structure
5244 */
Krunal Sonifd85ba62016-07-11 08:18:53 -07005245 if (NULL == param_buf->soc_hw_mode_caps) {
5246 WMA_LOGE("%s: Invalid number of hw modes", __func__);
5247 return;
5248 }
5249
Krunal Soni2e48d012016-05-02 16:55:26 -07005250 qdf_mem_copy(&phy_caps->num_hw_modes,
5251 param_buf->soc_hw_mode_caps,
5252 sizeof(WMI_SOC_MAC_PHY_HW_MODE_CAPS));
5253 if (0 == phy_caps->num_hw_modes.num_hw_modes) {
Krunal Sonifd85ba62016-07-11 08:18:53 -07005254 WMA_LOGE("%s: Number of hw modes is zero", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005255 return;
Krunal Soni2e48d012016-05-02 16:55:26 -07005256 }
Krunal Sonifd85ba62016-07-11 08:18:53 -07005257 WMA_LOGI("%s: Given number of hw modes[%d]",
5258 __func__, phy_caps->num_hw_modes.num_hw_modes);
Krunal Soni2e48d012016-05-02 16:55:26 -07005259
5260 /*
5261 * next thing is to allocate the memory to map hw mode to phy/mac caps
5262 */
5263 phy_caps->hw_mode_to_mac_cap_map =
5264 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5265 sizeof(struct hw_mode_idx_to_mac_cap_idx));
5266 if (!phy_caps->hw_mode_to_mac_cap_map) {
5267 WMA_LOGE("%s: Memory allocation failed", __func__);
5268 return;
5269 }
5270
5271 /*
5272 * next thing is to allocate the memory for per hw caps
5273 */
5274 phy_caps->each_hw_mode_cap =
5275 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5276 sizeof(WMI_HW_MODE_CAPABILITIES));
5277 if (!phy_caps->each_hw_mode_cap) {
5278 WMA_LOGE("%s: Memory allocation failed", __func__);
5279 wma_cleanup_dbs_phy_caps(wma_handle);
5280 return;
5281 }
5282 qdf_mem_copy(phy_caps->each_hw_mode_cap,
5283 param_buf->hw_mode_caps,
5284 phy_caps->num_hw_modes.num_hw_modes *
5285 sizeof(WMI_HW_MODE_CAPABILITIES));
5286 /*
5287 * next thing is to count the number of mac cap to populate per
5288 * hw mode and generate map, so that our search can be done
5289 * efficiently which is O(1)
5290 */
5291 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
5292 map = &phy_caps->hw_mode_to_mac_cap_map[i];
5293 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2) {
5294 tmp = num_of_mac_caps;
5295 num_of_mac_caps = num_of_mac_caps + 2;
5296 map->num_of_macs = 2;
5297 } else {
5298 tmp = num_of_mac_caps;
5299 num_of_mac_caps = num_of_mac_caps + 1;
5300 map->num_of_macs = 1;
5301 }
5302 map->mac_cap_idx = tmp;
5303 map->hw_mode_id = phy_caps->each_hw_mode_cap[i].hw_mode_id;
5304 }
5305
5306 /*
5307 * next thing is to populate each phy caps per hw mode
5308 */
5309 phy_caps->each_phy_cap_per_hwmode =
5310 qdf_mem_malloc(num_of_mac_caps *
5311 sizeof(WMI_MAC_PHY_CAPABILITIES));
5312 if (!phy_caps->each_phy_cap_per_hwmode) {
5313 WMA_LOGE("%s: Memory allocation failed", __func__);
5314 wma_cleanup_dbs_phy_caps(wma_handle);
5315 return;
5316 }
5317 qdf_mem_copy(phy_caps->each_phy_cap_per_hwmode,
5318 param_buf->mac_phy_caps,
5319 num_of_mac_caps * sizeof(WMI_MAC_PHY_CAPABILITIES));
5320
5321 /*
5322 * next thing is to populate reg caps per phy
5323 */
5324 qdf_mem_copy(&phy_caps->num_phy_for_hal_reg_cap,
5325 param_buf->soc_hal_reg_caps,
5326 sizeof(WMI_SOC_HAL_REG_CAPABILITIES));
5327 if (phy_caps->num_phy_for_hal_reg_cap.num_phy == 0) {
5328 WMA_LOGE("%s: incorrect number of phys", __func__);
5329 wma_cleanup_dbs_phy_caps(wma_handle);
5330 return;
5331 }
5332 phy_caps->each_phy_hal_reg_cap =
5333 qdf_mem_malloc(phy_caps->num_phy_for_hal_reg_cap.num_phy *
5334 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
5335 if (!phy_caps->each_phy_hal_reg_cap) {
5336 WMA_LOGE("%s: Memory allocation failed", __func__);
5337 wma_cleanup_dbs_phy_caps(wma_handle);
5338 return;
5339 }
5340 qdf_mem_copy(phy_caps->each_phy_hal_reg_cap,
5341 param_buf->hal_reg_caps,
5342 phy_caps->num_phy_for_hal_reg_cap.num_phy *
5343 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
5344 wma_print_populate_soc_caps(wma_handle);
5345 return;
5346}
5347
5348/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
5350 * @handle: wma handle
5351 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05305352 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 *
5354 * Return: none
5355 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305356int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
5357 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005358{
5359 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5360 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
5361 wmi_service_ready_ext_event_fixed_param *ev;
5362 int status;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305363 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005364
5365 WMA_LOGD("%s: Enter", __func__);
5366
5367 if (!wma_handle) {
5368 WMA_LOGP("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305369 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370 }
5371
5372 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
5373 if (!param_buf) {
5374 WMA_LOGP("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305375 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 }
5377
5378 ev = param_buf->fixed_param;
5379 if (!ev) {
5380 WMA_LOGP("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305381 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 }
5383
5384 WMA_LOGA("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
5385
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305386 WMA_LOGA("%s: Defaults: scan config:%x FW mode config:%x",
5387 __func__, ev->default_conc_scan_config_bits,
5388 ev->default_fw_config_bits);
5389
Anurag Chouhan210db072016-02-22 18:42:15 +05305390 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305391 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305392 WMA_LOGP("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05305393 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 }
Krunal Soni2e48d012016-05-02 16:55:26 -07005395 wma_populate_soc_caps(wma_handle, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005396
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305397 ret = wma_update_hw_mode_list(wma_handle);
5398 if (QDF_IS_STATUS_ERROR(ret)) {
5399 WMA_LOGE("Failed to update hw mode list");
5400 return -EINVAL;
5401 }
5402
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005403 WMA_LOGA("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05305404 status = wmi_unified_send_saved_init_cmd(wma_handle->wmi_handle);
5405 if (status != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406 /* In success case, WMI layer will free after getting copy
5407 * engine TX complete interrupt
5408 */
5409 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305411 wma_init_scan_fw_mode_config(wma_handle,
5412 ev->default_conc_scan_config_bits,
5413 ev->default_fw_config_bits);
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07005414 wma_handle->target_fw_vers_ext = ev->fw_build_vers_ext;
Govind Singhd76a5b02016-03-08 15:12:14 +05305415 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416}
5417
5418/**
5419 * wma_rx_ready_event() - event handler to process
5420 * wmi rx ready event.
5421 * @handle: wma handle
5422 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05305423 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 *
5425 * Return: none
5426 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305427int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
5428 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429{
5430 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5431 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
5432 wmi_ready_event_fixed_param *ev = NULL;
5433
5434 WMA_LOGD("%s: Enter", __func__);
5435
5436 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
5437 if (!(wma_handle && param_buf)) {
5438 WMA_LOGP("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305439 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05305440 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 }
5442
5443 WMA_LOGA("WMA <-- WMI_READY_EVENTID");
5444
5445 ev = param_buf->fixed_param;
5446 /* Indicate to the waiting thread that the ready
5447 * event was received */
Naveen Rawat64e477e2016-05-20 10:34:56 -07005448 wma_handle->sub_20_support =
5449 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5450 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 wma_handle->wmi_ready = true;
5452 wma_handle->wlan_init_status = ev->status;
5453
5454 /*
5455 * We need to check the WMI versions and make sure both
5456 * host and fw are compatible.
5457 */
5458 if (!wmi_versions_are_compatible(&wma_handle->final_abi_vers,
5459 &ev->fw_abi_vers)) {
5460 /*
5461 * Error: Our host version and the given firmware version
5462 * are incompatible.
5463 */
5464 WMA_LOGE("%s: Error: Incompatible WMI version."
5465 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x",
5466 __func__,
5467 WMI_VER_GET_MAJOR(wma_handle->final_abi_vers.
5468 abi_version_0),
5469 WMI_VER_GET_MINOR(wma_handle->final_abi_vers.
5470 abi_version_0),
5471 wma_handle->final_abi_vers.abi_version_ns_0,
5472 wma_handle->final_abi_vers.abi_version_ns_1,
5473 wma_handle->final_abi_vers.abi_version_ns_2,
5474 wma_handle->final_abi_vers.abi_version_ns_3,
5475 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
5476 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
5477 ev->fw_abi_vers.abi_version_ns_0,
5478 ev->fw_abi_vers.abi_version_ns_1,
5479 ev->fw_abi_vers.abi_version_ns_2,
5480 ev->fw_abi_vers.abi_version_ns_3);
5481 if (wma_handle->wlan_init_status == WLAN_INIT_STATUS_SUCCESS) {
5482 /* Failed this connection to FW */
5483 wma_handle->wlan_init_status =
5484 WLAN_INIT_STATUS_GEN_FAILED;
5485 }
5486 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305487 qdf_mem_copy(&wma_handle->final_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488 sizeof(wmi_abi_version));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305489 qdf_mem_copy(&wma_handle->target_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 sizeof(wmi_abi_version));
5491
5492 /* copy the mac addr */
5493 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
5494 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
5495
5496 wma_update_hdd_cfg(wma_handle);
5497
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305498 qdf_event_set(&wma_handle->wma_ready_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499
5500 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05305501
5502 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503}
5504
5505/**
5506 * wma_setneedshutdown() - setting wma needshutdown flag
5507 * @cds_ctx: cds context
5508 *
5509 * Return: none
5510 */
5511void wma_setneedshutdown(void *cds_ctx)
5512{
5513 tp_wma_handle wma_handle;
5514
5515 WMA_LOGD("%s: Enter", __func__);
5516
Anurag Chouhan6d760662016-02-20 16:05:43 +05305517 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518
5519 if (NULL == wma_handle) {
5520 WMA_LOGP("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305521 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 return;
5523 }
5524
5525 wma_handle->needShutdown = true;
5526 WMA_LOGD("%s: Exit", __func__);
5527}
5528
5529/**
5530 * wma_needshutdown() - Is wma needs shutdown?
5531 * @cds_ctx: cds context
5532 *
5533 * Return: returns true/false
5534 */
5535bool wma_needshutdown(void *cds_ctx)
5536{
5537 tp_wma_handle wma_handle;
5538
5539 WMA_LOGD("%s: Enter", __func__);
5540
Anurag Chouhan6d760662016-02-20 16:05:43 +05305541 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542
5543 if (NULL == wma_handle) {
5544 WMA_LOGP("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305545 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546 return false;
5547 }
5548
5549 WMA_LOGD("%s: Exit", __func__);
5550 return wma_handle->needShutdown;
5551}
5552
5553/**
5554 * wma_wait_for_ready_event() - wait for wma ready event
5555 * @handle: wma handle
5556 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305557 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305559QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560{
5561 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305562 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563
5564 /* wait until WMI_READY_EVENTID received from FW */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305565 qdf_status = qdf_wait_single_event(&(wma_handle->wma_ready_event),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005566 WMA_READY_EVENTID_TIMEOUT);
5567
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305568 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 WMA_LOGP("%s: Timeout waiting for ready event from FW",
5570 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305571 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305573 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574}
5575
5576/**
5577 * wma_set_ppsconfig() - set pps config in fw
5578 * @vdev_id: vdev id
5579 * @pps_param: pps params
5580 * @val : param value
5581 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305582 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305584QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585 int val)
5586{
Anurag Chouhan6d760662016-02-20 16:05:43 +05305587 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 int ret = -EIO;
5589 uint32_t pps_val;
5590
5591 if (NULL == wma) {
5592 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305593 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594 }
5595
5596 switch (pps_param) {
5597 case WMA_VHT_PPS_PAID_MATCH:
5598 pps_val = ((val << 31) & 0xffff0000) |
5599 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
5600 goto pkt_pwr_save_config;
5601 case WMA_VHT_PPS_GID_MATCH:
5602 pps_val = ((val << 31) & 0xffff0000) |
5603 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
5604 goto pkt_pwr_save_config;
5605 case WMA_VHT_PPS_DELIM_CRC_FAIL:
5606 pps_val = ((val << 31) & 0xffff0000) |
5607 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
5608 goto pkt_pwr_save_config;
5609
5610 /* Enable the code below as and when the functionality
5611 * is supported/added in host.
5612 */
5613#ifdef NOT_YET
5614 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
5615 pps_val = ((val << 31) & 0xffff0000) |
5616 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
5617 goto pkt_pwr_save_config;
5618 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
5619 pps_val = ((val << 31) & 0xffff0000) |
5620 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
5621 goto pkt_pwr_save_config;
5622 case WMA_VHT_PPS_EOF_PAD_DELIM:
5623 pps_val = ((val << 31) & 0xffff0000) |
5624 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
5625 goto pkt_pwr_save_config;
5626 case WMA_VHT_PPS_MACADDR_MISMATCH:
5627 pps_val = ((val << 31) & 0xffff0000) |
5628 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
5629 goto pkt_pwr_save_config;
5630 case WMA_VHT_PPS_GID_NSTS_ZERO:
5631 pps_val = ((val << 31) & 0xffff0000) |
5632 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
5633 goto pkt_pwr_save_config;
5634 case WMA_VHT_PPS_RSSI_CHECK:
5635 pps_val = ((val << 31) & 0xffff0000) |
5636 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
5637 goto pkt_pwr_save_config;
5638#endif /* NOT_YET */
5639pkt_pwr_save_config:
5640 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
5641 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05305642 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 WMI_VDEV_PARAM_PACKET_POWERSAVE,
5644 pps_val);
5645 break;
5646 default:
5647 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
5648 }
5649
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305650 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651}
5652
5653/**
5654 * wma_process_set_mas() - Function to enable/disable MAS
5655 * @wma: Pointer to WMA handle
5656 * @mas_val: 1-Enable MAS, 0-Disable MAS
5657 *
5658 * This function enables/disables the MAS value
5659 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305660 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005662static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
5663 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664{
5665 uint32_t val;
5666
5667 if (NULL == wma || NULL == mas_val) {
5668 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305669 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 }
5671
5672 val = (*mas_val);
5673
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305674 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
5676 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305677 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 } else {
5679 WMA_LOGE("%s: Value is %d", __func__, val);
5680 }
5681
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305682 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683}
5684
5685/**
5686 * wma_process_set_miracast() - Function to set miracast value in WMA
5687 * @wma: Pointer to WMA handle
5688 * @miracast_val: 0-Disabled,1-Source,2-Sink
5689 *
5690 * This function stores the miracast value in WMA
5691 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305692 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 *
5694 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005695static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
5696 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005697{
5698 if (NULL == wma || NULL == miracast_val) {
5699 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305700 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005701 }
5702
5703 wma->miracast_value = *miracast_val;
5704 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
5705
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305706 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707}
5708
5709/**
5710 * wma_config_stats_factor() - Function to configure stats avg. factor
5711 * @wma: pointer to WMA handle
5712 * @avg_factor: stats. avg. factor passed down by userspace
5713 *
5714 * This function configures the avg. stats value in firmware
5715 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305716 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005717 *
5718 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305719static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720 struct sir_stats_avg_factor *avg_factor)
5721{
Govind Singhd76a5b02016-03-08 15:12:14 +05305722 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005723
5724 if (NULL == wma || NULL == avg_factor) {
5725 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305726 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727 }
5728
Govind Singhd76a5b02016-03-08 15:12:14 +05305729 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005730 avg_factor->vdev_id,
5731 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
5732 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05305733 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
5735 avg_factor->vdev_id);
5736 }
5737
5738 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
5739 avg_factor->stats_avg_factor, avg_factor->vdev_id);
5740
5741 return ret;
5742}
5743
5744/**
5745 * wma_config_guard_time() - Function to set guard time in firmware
5746 * @wma: pointer to WMA handle
5747 * @guard_time: guard time passed down by userspace
5748 *
5749 * This function configures the guard time in firmware
5750 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305751 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752 *
5753 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305754static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 struct sir_guard_time_request *guard_time)
5756{
Govind Singhd76a5b02016-03-08 15:12:14 +05305757 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758
5759 if (NULL == wma || NULL == guard_time) {
5760 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305761 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762 }
5763
Govind Singhd76a5b02016-03-08 15:12:14 +05305764 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765 guard_time->vdev_id,
5766 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
5767 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05305768 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005769 WMA_LOGE(" failed to set guard time for vdev_id %d",
5770 guard_time->vdev_id);
5771 }
5772
5773 WMA_LOGD("Set guard time %d for vdev_id %d",
5774 guard_time->guard_time, guard_time->vdev_id);
5775
5776 return ret;
5777}
5778
5779/**
5780 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
5781 * @wma_handle: WMA handle
5782 * @start_log: Start logging related parameters
5783 *
5784 * Send the command to the FW based on which specific logging of diag
5785 * event/log id can be started/stopped
5786 *
5787 * Return: None
5788 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005789static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
5790 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005792
5793 if (!start_log) {
5794 WMA_LOGE("%s: start_log pointer is NULL", __func__);
5795 return;
5796 }
5797 if (!wma_handle) {
5798 WMA_LOGE("%s: Invalid wma handle", __func__);
5799 return;
5800 }
5801
5802 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
5803 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
5804 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
5805 __func__, start_log->ring_id);
5806 return;
5807 }
5808
Govind Singhf25a0f12016-03-08 16:09:48 +05305809 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
5810 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812 return;
5813}
5814
Poddar, Siddarth176c4362016-10-03 12:25:00 +05305815#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005816/**
5817 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
5818 * @wma_handle: WMA handle
5819 * @start_log: Struture containing the start wifi logger params
5820 *
5821 * This function is used to send the WMA commands to start/stop logging
5822 * of per packet statistics
5823 *
5824 * Return: None
5825 *
5826 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005827#ifdef REMOVE_PKT_LOG
5828static void wma_set_wifi_start_packet_stats(void *wma_handle,
5829 struct sir_wifi_start_log *start_log)
5830{
5831 return;
5832}
5833#else
5834static void wma_set_wifi_start_packet_stats(void *wma_handle,
5835 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836{
Komal Seelam3d202862016-02-24 18:43:24 +05305837 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005838 uint32_t log_state;
5839
5840 if (!start_log) {
5841 WMA_LOGE("%s: start_log pointer is NULL", __func__);
5842 return;
5843 }
5844 if (!wma_handle) {
5845 WMA_LOGE("%s: Invalid wma handle", __func__);
5846 return;
5847 }
5848
5849 /* No need to register for ring IDs other than packet stats */
5850 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
5851 WMA_LOGI("%s: Ring id is not for per packet stats: %d",
5852 __func__, start_log->ring_id);
5853 return;
5854 }
5855
Anurag Chouhan6d760662016-02-20 16:05:43 +05305856 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07005857 if (scn == NULL) {
5858 WMA_LOGE("%s: Invalid HIF handle", __func__);
5859 return;
5860 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005861
5862 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05305863 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
5864 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865
Poddar, Siddarth176c4362016-10-03 12:25:00 +05305866 if (start_log->size != 0) {
5867 pktlog_setsize(scn, start_log->size * MEGABYTE);
5868 return;
5869 }
5870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08005872 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05305873 start_log->user_triggered,
5874 start_log->is_iwpriv_command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005875 WMA_LOGI("%s: Enabling per packet stats", __func__);
5876 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08005877 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05305878 start_log->user_triggered,
5879 start_log->is_iwpriv_command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005880 WMA_LOGI("%s: Disabling per packet stats", __func__);
5881 }
5882}
5883#endif
5884
5885/**
5886 * wma_send_flush_logs_to_fw() - Send log flush command to FW
5887 * @wma_handle: WMI handle
5888 *
5889 * This function is used to send the flush command to the FW,
5890 * that will flush the fw logs that are residue in the FW
5891 *
5892 * Return: None
5893 */
5894void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
5895{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305896 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005897 int ret;
5898
Govind Singhf25a0f12016-03-08 16:09:48 +05305899 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
5900 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005901 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902
Anurag Chouhan210db072016-02-22 18:42:15 +05305903 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005904 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305905 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906 WMA_LOGE("Failed to start the log completion timer");
5907}
5908
5909/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05305910 * wma_update_wep_default_key - To update default key id
5911 * @wma: pointer to wma handler
5912 * @update_def_key: pointer to wep_update_default_key_idx
5913 *
5914 * This function makes a copy of default key index to txrx node
5915 *
5916 * Return: Success
5917 */
5918static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
5919 struct wep_update_default_key_idx *update_def_key)
5920{
5921 struct wma_txrx_node *iface =
5922 &wma->interfaces[update_def_key->session_id];
5923 iface->wep_default_key_idx = update_def_key->default_idx;
5924
5925 return QDF_STATUS_SUCCESS;
5926}
5927
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05305928
5929/**
5930 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
5931 * @wma_handle: WMA handle
5932 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
5933 *
5934 * This function is used to set Tx pkt fail count threshold,
5935 * FW will do disconnect with station once this threshold is reached.
5936 *
5937 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
5938 */
5939static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
5940 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
5941{
5942 u_int8_t vdev_id;
5943 u_int32_t tx_fail_disconn_th;
5944 int ret = -EIO;
5945
5946 if (!wma || !wma->wmi_handle) {
5947 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
5948 return QDF_STATUS_E_INVAL;
5949 }
5950 vdev_id = tx_fail_cnt_th->session_id;
5951 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
5952 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
5953 vdev_id, tx_fail_disconn_th);
5954
5955
5956 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
5957 WMI_VDEV_PARAM_DISCONNECT_TH,
5958 tx_fail_disconn_th);
5959
5960 if (ret) {
5961 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
5962 return QDF_STATUS_E_FAILURE;
5963 }
5964
5965 return QDF_STATUS_SUCCESS;
5966}
5967
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05305968/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05305969 * wma_update_short_retry_limit() - Set retry limit for short frames
5970 * @wma_handle: WMA handle
5971 * @short_retry_limit_th: retry limir count for Short frames.
5972 *
5973 * This function is used to configure the transmission retry limit at which
5974 * short frames needs to be retry.
5975 *
5976 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
5977 */
5978static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
5979 struct sme_short_retry_limit *short_retry_limit_th)
5980{
5981 uint8_t vdev_id;
5982 uint32_t short_retry_limit;
5983 int ret;
5984
5985 if (!wma || !wma->wmi_handle) {
5986 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
5987 return QDF_STATUS_E_INVAL;
5988 }
5989 vdev_id = short_retry_limit_th->session_id;
5990 short_retry_limit = short_retry_limit_th->short_retry_limit;
5991 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
5992 vdev_id, short_retry_limit);
5993
5994 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
5995 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
5996 short_retry_limit);
5997
5998 if (ret) {
5999 WMA_LOGE("Failed to send short limit threshold command");
6000 return QDF_STATUS_E_FAILURE;
6001 }
6002 return QDF_STATUS_SUCCESS;
6003}
6004
6005/**
6006 * wma_update_long_retry_limit() - Set retry limit for long frames
6007 * @wma_handle: WMA handle
6008 * @long_retry_limit_th: retry limir count for long frames
6009 *
6010 * This function is used to configure the transmission retry limit at which
6011 * long frames needs to be retry
6012 *
6013 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6014 */
6015static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
6016 struct sme_long_retry_limit *long_retry_limit_th)
6017{
6018 uint8_t vdev_id;
6019 uint32_t long_retry_limit;
6020 int ret;
6021
6022 if (!wma || !wma->wmi_handle) {
6023 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
6024 return QDF_STATUS_E_INVAL;
6025 }
6026 vdev_id = long_retry_limit_th->session_id;
6027 long_retry_limit = long_retry_limit_th->long_retry_limit;
6028 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
6029 vdev_id, long_retry_limit);
6030
6031 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6032 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
6033 long_retry_limit);
6034
6035 if (ret) {
6036 WMA_LOGE("Failed to send long limit threshold command");
6037 return QDF_STATUS_E_FAILURE;
6038 }
6039
6040 return QDF_STATUS_SUCCESS;
6041}
6042
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05306043/*
6044 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
6045 * @wma_handle: WMA handle
6046 * @sta_inactivity_timer: sme_sta_inactivity_timeout
6047 *
6048 * This function is used to set sta_inactivity_timeout.
6049 * If a station does not send anything in sta_inactivity_timeout seconds, an
6050 * empty data frame is sent to it in order to verify whether it is
6051 * still in range. If this frame is not ACKed, the station will be
6052 * disassociated and then deauthenticated.
6053 *
6054 * Return: None
6055 */
6056void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
6057 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
6058{
6059 uint8_t vdev_id;
6060 uint32_t max_unresponsive_time;
6061 uint32_t min_inactive_time, max_inactive_time;
6062
6063 if (!wma || !wma->wmi_handle) {
6064 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
6065 return;
6066 }
6067 vdev_id = sta_inactivity_timer->session_id;
6068 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
6069 max_inactive_time = max_unresponsive_time * TWO_THIRD;
6070 min_inactive_time = max_unresponsive_time - max_inactive_time;
6071
6072 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6073 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
6074 min_inactive_time))
6075 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
6076
6077 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6078 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
6079 max_inactive_time))
6080 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
6081
6082 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6083 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
6084 max_unresponsive_time))
6085 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
6086
6087 WMA_LOGI("%s:vdev_id:%d min_inactive_time: %u max_inactive_time: %u max_unresponsive_time: %u",
6088 __func__, vdev_id,
6089 min_inactive_time, max_inactive_time,
6090 max_unresponsive_time);
6091}
6092
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306093/**
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05306094 * wma_process_power_debug_stats_req() - Process the Chip Power stats collect
6095 * request and pass the Power stats request to Fw
6096 * @wma_handle: WMA handle
6097 *
6098 * Return: QDF_STATUS
6099 */
6100#ifdef WLAN_POWER_DEBUGFS
6101static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
6102{
6103 wmi_pdev_get_chip_power_stats_cmd_fixed_param *cmd;
6104 int32_t len;
6105 wmi_buf_t buf;
6106 uint8_t *buf_ptr;
6107 int ret;
6108
6109 if (!wma_handle) {
6110 WMA_LOGE("%s: input pointer is NULL", __func__);
6111 return QDF_STATUS_E_FAILURE;
6112 }
6113
6114 len = sizeof(*cmd);
6115 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6116 if (!buf) {
6117 WMA_LOGE("%s: Failed allocate wmi buffer", __func__);
6118 return QDF_STATUS_E_NOMEM;
6119 }
6120
6121 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6122 cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr;
6123
6124 WMITLV_SET_HDR(&cmd->tlv_header,
6125 WMITLV_TAG_STRUC_wmi_get_chip_power_stats_cmd_fixed_param,
6126 WMITLV_GET_STRUCT_TLVLEN(
6127 wmi_pdev_get_chip_power_stats_cmd_fixed_param));
6128 cmd->pdev_id = 0;
6129
6130 WMA_LOGD("POWER_DEBUG_STATS - Get Request Params; Pdev id - %d",
6131 cmd->pdev_id);
6132 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6133 WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
6134 if (ret) {
6135 WMA_LOGE("%s: Failed to send power debug stats request",
6136 __func__);
6137 wmi_buf_free(buf);
6138 return QDF_STATUS_E_FAILURE;
6139 }
6140 return QDF_STATUS_SUCCESS;
6141}
6142#else
6143static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
6144{
6145 return QDF_STATUS_SUCCESS;
6146}
6147#endif
6148
6149/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006150 * wma_mc_process_msg() - process wma messages and call appropriate function.
6151 * @cds_context: cds context
6152 * @msg: message
6153 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306154 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006155 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306156QDF_STATUS wma_mc_process_msg(void *cds_context, cds_msg_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306158 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006159 tp_wma_handle wma_handle;
Leo Chang96464902016-10-28 11:10:54 -07006160 void *txrx_vdev_handle = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006161 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05306162 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006164 if (NULL == msg) {
6165 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306166 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306167 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006168 goto end;
6169 }
6170
6171 WMA_LOGD("msg->type = %x %s", msg->type,
6172 mac_trace_get_wma_msg_string(msg->type));
6173
Anurag Chouhan6d760662016-02-20 16:05:43 +05306174 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175
6176 if (NULL == wma_handle) {
6177 WMA_LOGP("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306178 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306179 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306180 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006181 goto end;
6182 }
6183
6184 switch (msg->type) {
6185
6186 /* Message posted by wmi for all control path related
6187 * FW events to serialize through mc_thread.
6188 */
6189 case WMA_PROCESS_FW_EVENT:
6190 wma_process_fw_event(wma_handle,
6191 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306192 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006193 break;
6194
6195#ifdef FEATURE_WLAN_ESE
6196 case WMA_TSM_STATS_REQ:
6197 WMA_LOGA("McThread: WMA_TSM_STATS_REQ");
6198 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
6199 break;
6200#endif /* FEATURE_WLAN_ESE */
6201 case WNI_CFG_DNLD_REQ:
6202 WMA_LOGA("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306203 qdf_status = wma_wni_cfg_dnld(wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05306204 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006205 cds_wma_complete_cback(cds_context);
6206 } else {
6207 WMA_LOGD("config download failure");
6208 }
6209 break;
6210 case WMA_ADD_STA_SELF_REQ:
6211 txrx_vdev_handle =
6212 wma_vdev_attach(wma_handle,
6213 (struct add_sta_self_params *) msg->
6214 bodyptr, 1);
6215 if (!txrx_vdev_handle) {
6216 WMA_LOGE("Failed to attach vdev");
6217 } else {
6218 /* Register with TxRx Module for Data Ack Complete Cb */
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05306219 if (soc) {
6220 cdp_data_tx_cb_set(soc, txrx_vdev_handle,
6221 wma_data_tx_ack_comp_hdlr,
6222 wma_handle);
6223 } else {
6224 WMA_LOGE("%s: SOC context is NULL", __func__);
6225 qdf_status = QDF_STATUS_E_FAILURE;
6226 goto end;
6227 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006228 }
6229 break;
6230 case WMA_DEL_STA_SELF_REQ:
6231 wma_vdev_detach(wma_handle,
6232 (struct del_sta_self_params *) msg->bodyptr, 1);
6233 break;
6234 case WMA_START_SCAN_OFFLOAD_REQ:
6235 wma_start_scan(wma_handle, msg->bodyptr, msg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306236 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006237 break;
6238 case WMA_STOP_SCAN_OFFLOAD_REQ:
6239 wma_stop_scan(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306240 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006241 break;
6242 case WMA_UPDATE_CHAN_LIST_REQ:
6243 wma_update_channel_list(wma_handle,
6244 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306245 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006246 break;
6247 case WMA_SET_LINK_STATE:
6248 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
6249 break;
6250 case WMA_CHNL_SWITCH_REQ:
6251 wma_set_channel(wma_handle,
6252 (tpSwitchChannelParams) msg->bodyptr);
6253 break;
6254 case WMA_ADD_BSS_REQ:
6255 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
6256 break;
6257 case WMA_ADD_STA_REQ:
6258 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
6259 break;
6260 case WMA_SET_BSSKEY_REQ:
6261 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
6262 break;
6263 case WMA_SET_STAKEY_REQ:
6264 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
6265 break;
6266 case WMA_DELETE_STA_REQ:
6267 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
6268 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07006269 case WMA_DELETE_BSS_HO_FAIL_REQ:
6270 wma_delete_bss_ho_fail(wma_handle,
6271 (tpDeleteBssParams) msg->bodyptr);
6272 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006273 case WMA_DELETE_BSS_REQ:
6274 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
6275 break;
6276 case WMA_UPDATE_EDCA_PROFILE_IND:
6277 wma_process_update_edca_param_req(wma_handle,
6278 (tEdcaParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306279 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006280 break;
6281 case WMA_SEND_BEACON_REQ:
6282 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306283 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006284 break;
6285 case WMA_SEND_PROBE_RSP_TMPL:
6286 wma_send_probe_rsp_tmpl(wma_handle,
6287 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306288 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006289 break;
6290 case WMA_CLI_SET_CMD:
6291 wma_process_cli_set_cmd(wma_handle,
6292 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306293 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006294 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07006295 case WMA_SET_PDEV_IE_REQ:
6296 wma_process_set_pdev_ie_req(wma_handle,
6297 (struct set_ie_param *)msg->bodyptr);
6298 qdf_mem_free(msg->bodyptr);
6299 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006300#if !defined(REMOVE_PKT_LOG)
6301 case WMA_PKTLOG_ENABLE_REQ:
6302 wma_pktlog_wmi_send_cmd(wma_handle,
6303 (struct ath_pktlog_wmi_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306304 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006305 break;
6306#endif /* REMOVE_PKT_LOG */
6307#if defined(QCA_WIFI_FTM)
6308 case WMA_FTM_CMD_REQ:
6309 wma_process_ftm_command(wma_handle,
6310 (struct ar6k_testmode_cmd_data *)msg->bodyptr);
6311 break;
6312#endif /* QCA_WIFI_FTM */
6313 case WMA_ENTER_PS_REQ:
6314 wma_enable_sta_ps_mode(wma_handle,
6315 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306316 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006317 break;
6318 case WMA_EXIT_PS_REQ:
6319 wma_disable_sta_ps_mode(wma_handle,
6320 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306321 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006322 break;
6323 case WMA_ENABLE_UAPSD_REQ:
6324 wma_enable_uapsd_mode(wma_handle,
6325 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306326 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006327 break;
6328 case WMA_DISABLE_UAPSD_REQ:
6329 wma_disable_uapsd_mode(wma_handle,
6330 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306331 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006332 break;
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -07006333 case WMA_SET_DTIM_PERIOD:
6334 wma_set_dtim_period(wma_handle,
6335 (struct set_dtim_params *)msg->bodyptr);
6336 qdf_mem_free(msg->bodyptr);
6337 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006338 case WMA_SET_TX_POWER_REQ:
6339 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
6340 break;
6341 case WMA_SET_MAX_TX_POWER_REQ:
6342 wma_set_max_tx_power(wma_handle,
6343 (tpMaxTxPowerParams) msg->bodyptr);
6344 break;
6345 case WMA_SET_KEEP_ALIVE:
6346 wma_set_keepalive_req(wma_handle,
6347 (tSirKeepAliveReq *) msg->bodyptr);
6348 break;
6349#ifdef FEATURE_WLAN_SCAN_PNO
6350 case WMA_SET_PNO_REQ:
6351 wma_config_pno(wma_handle, (tpSirPNOScanReq) msg->bodyptr);
6352 break;
6353
6354 case WMA_SME_SCAN_CACHE_UPDATED:
6355 wma_scan_cache_updated_ind(wma_handle, msg->bodyval);
6356 break;
6357#endif /* FEATURE_WLAN_SCAN_PNO */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08006358#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359 case WMA_SET_PLM_REQ:
6360 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
6361 break;
6362#endif
6363 case WMA_GET_STATISTICS_REQ:
6364 wma_get_stats_req(wma_handle,
6365 (tAniGetPEStatsReq *) msg->bodyptr);
6366 break;
6367
6368 case WMA_CONFIG_PARAM_UPDATE_REQ:
6369 wma_update_cfg_params(wma_handle, (tSirMsgQ *) msg);
6370 break;
6371
6372 case WMA_UPDATE_OP_MODE:
6373 wma_process_update_opmode(wma_handle,
6374 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306375 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006376 break;
6377 case WMA_UPDATE_RX_NSS:
6378 wma_process_update_rx_nss(wma_handle,
6379 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306380 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006381 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006382 case WMA_UPDATE_MEMBERSHIP:
6383 wma_process_update_membership(wma_handle,
6384 (tUpdateMembership *) msg->bodyptr);
6385 break;
6386 case WMA_UPDATE_USERPOS:
6387 wma_process_update_userpos(wma_handle,
6388 (tUpdateUserPos *) msg->bodyptr);
6389 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006390 case WMA_UPDATE_BEACON_IND:
6391 wma_process_update_beacon_params(wma_handle,
6392 (tUpdateBeaconParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306393 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006394 break;
6395
6396 case WMA_ADD_TS_REQ:
6397 wma_add_ts_req(wma_handle, (tAddTsParams *) msg->bodyptr);
6398 break;
6399
6400 case WMA_DEL_TS_REQ:
6401 wma_del_ts_req(wma_handle, (tDelTsParams *) msg->bodyptr);
6402 break;
6403
6404 case WMA_AGGR_QOS_REQ:
6405 wma_aggr_qos_req(wma_handle, (tAggrAddTsParams *) msg->bodyptr);
6406 break;
6407
6408 case WMA_RECEIVE_FILTER_SET_FILTER_REQ:
6409 wma_process_receive_filter_set_filter_req(wma_handle,
6410 (tSirRcvPktFilterCfgType *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306411 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006412 break;
6413
6414 case WMA_RECEIVE_FILTER_CLEAR_FILTER_REQ:
6415 wma_process_receive_filter_clear_filter_req(wma_handle,
6416 (tSirRcvFltPktClearParam *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306417 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006418 break;
6419
6420 case WMA_WOW_ADD_PTRN:
6421 wma_wow_add_pattern(wma_handle,
6422 (struct wow_add_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306423 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424 break;
6425 case WMA_WOW_DEL_PTRN:
6426 wma_wow_delete_user_pattern(wma_handle,
6427 (struct wow_delete_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306428 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006429 break;
6430 case WMA_WOWL_ENTER_REQ:
6431 wma_wow_enter(wma_handle,
6432 (tpSirHalWowlEnterParams) msg->bodyptr);
6433 break;
6434 case WMA_WOWL_EXIT_REQ:
6435 wma_wow_exit(wma_handle, (tpSirHalWowlExitParams) msg->bodyptr);
6436 break;
Houston Hoffmana76591b2015-11-10 16:52:05 -08006437
6438 case WMA_RUNTIME_PM_SUSPEND_IND:
6439 wma_calculate_and_update_conn_state(wma_handle);
Anurag Chouhan6d760662016-02-20 16:05:43 +05306440 wma_suspend_req(wma_handle, QDF_RUNTIME_SUSPEND);
Houston Hoffmana76591b2015-11-10 16:52:05 -08006441 break;
6442
6443 case WMA_RUNTIME_PM_RESUME_IND:
Anurag Chouhan6d760662016-02-20 16:05:43 +05306444 wma_resume_req(wma_handle, QDF_RUNTIME_SUSPEND);
Houston Hoffmana76591b2015-11-10 16:52:05 -08006445 break;
6446
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006447 case WMA_WLAN_SUSPEND_IND:
Houston Hoffman7260ecb2015-10-05 18:43:07 -07006448 wma_update_conn_state(wma_handle, msg->bodyval);
Anurag Chouhan6d760662016-02-20 16:05:43 +05306449 wma_suspend_req(wma_handle, QDF_SYSTEM_SUSPEND);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006450 break;
6451 case WMA_8023_MULTICAST_LIST_REQ:
6452 wma_process_mcbc_set_filter_req(wma_handle,
6453 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306454 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006455 break;
6456#ifdef WLAN_FEATURE_GTK_OFFLOAD
6457 case WMA_GTK_OFFLOAD_REQ:
6458 wma_process_gtk_offload_req(wma_handle,
6459 (tpSirGtkOffloadParams) msg->bodyptr);
6460 break;
6461
6462 case WMA_GTK_OFFLOAD_GETINFO_REQ:
6463 wma_process_gtk_offload_getinfo_req(wma_handle,
6464 (tpSirGtkOffloadGetInfoRspParams)msg->bodyptr);
6465 break;
6466#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006467 case WMA_SET_HOST_OFFLOAD:
6468 wma_enable_arp_ns_offload(wma_handle,
6469 (tpSirHostOffloadReq) msg->bodyptr,
6470 true);
6471 break;
6472#ifdef WLAN_NS_OFFLOAD
6473 case WMA_SET_NS_OFFLOAD:
6474 wma_enable_arp_ns_offload(wma_handle,
6475 (tpSirHostOffloadReq) msg->bodyptr,
6476 false);
6477 break;
6478#endif /*WLAN_NS_OFFLOAD */
6479 case WMA_ROAM_SCAN_OFFLOAD_REQ:
6480 /*
6481 * Main entry point or roaming directives from CSR.
6482 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08006483 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006484 (tSirRoamOffloadScanReq *) msg->bodyptr);
6485 break;
6486
6487 case WMA_RATE_UPDATE_IND:
6488 wma_process_rate_update_indicate(wma_handle,
6489 (tSirRateUpdateInd *) msg->bodyptr);
6490 break;
6491
6492#ifdef FEATURE_WLAN_TDLS
6493 case WMA_UPDATE_FW_TDLS_STATE:
6494 wma_update_fw_tdls_state(wma_handle,
6495 (t_wma_tdls_params *) msg->bodyptr);
6496 break;
6497 case WMA_UPDATE_TDLS_PEER_STATE:
6498 wma_update_tdls_peer_state(wma_handle,
6499 (tTdlsPeerStateParams *) msg->bodyptr);
6500 break;
6501 case WMA_TDLS_SET_OFFCHAN_MODE:
6502 wma_set_tdls_offchan_mode(wma_handle,
6503 (tdls_chan_switch_params *)msg->bodyptr);
6504 break;
6505#endif /* FEATURE_WLAN_TDLS */
6506 case WMA_ADD_PERIODIC_TX_PTRN_IND:
6507 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
6508 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306509 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006510 break;
6511 case WMA_DEL_PERIODIC_TX_PTRN_IND:
6512 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
6513 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306514 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006515 break;
6516 case WMA_TX_POWER_LIMIT:
6517 wma_process_tx_power_limits(wma_handle,
6518 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306519 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006520 break;
6521#ifdef FEATURE_WLAN_LPHB
6522 case WMA_LPHB_CONF_REQ:
6523 wma_process_lphb_conf_req(wma_handle,
6524 (tSirLPHBReq *) msg->bodyptr);
6525 break;
6526#endif /* FEATURE_WLAN_LPHB */
6527
6528#ifdef FEATURE_WLAN_CH_AVOID
6529 case WMA_CH_AVOID_UPDATE_REQ:
6530 wma_process_ch_avoid_update_req(wma_handle,
6531 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306532 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006533 break;
6534#endif /* FEATURE_WLAN_CH_AVOID */
6535#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
6536 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
6537 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306538 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006539 break;
6540#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
6541 case WMA_DHCP_START_IND:
6542 case WMA_DHCP_STOP_IND:
6543 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306544 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006545 break;
6546
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08006547 case WMA_IBSS_CESIUM_ENABLE_IND:
6548 wma_process_cesium_enable_ind(wma_handle);
6549 break;
6550 case WMA_GET_IBSS_PEER_INFO_REQ:
6551 wma_process_get_peer_info_req(wma_handle,
6552 (tSirIbssGetPeerInfoReqParams *)
6553 msg->bodyptr);
6554 qdf_mem_free(msg->bodyptr);
6555 break;
6556 case WMA_TX_FAIL_MONITOR_IND:
6557 wma_process_tx_fail_monitor_ind(wma_handle,
6558 (tAniTXFailMonitorInd *) msg->bodyptr);
6559 qdf_mem_free(msg->bodyptr);
6560 break;
6561
6562 case WMA_RMC_ENABLE_IND:
6563 wma_process_rmc_enable_ind(wma_handle);
6564 break;
6565 case WMA_RMC_DISABLE_IND:
6566 wma_process_rmc_disable_ind(wma_handle);
6567 break;
6568 case WMA_RMC_ACTION_PERIOD_IND:
6569 wma_process_rmc_action_period_ind(wma_handle);
6570 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006571 case WMA_INIT_THERMAL_INFO_CMD:
6572 wma_process_init_thermal_info(wma_handle,
6573 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306574 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006575 break;
6576
6577 case WMA_SET_THERMAL_LEVEL:
6578 wma_process_set_thermal_level(wma_handle, msg->bodyval);
6579 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05306580#ifdef CONFIG_HL_SUPPORT
6581 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
6582 wma_process_init_bad_peer_tx_ctl_info(
6583 wma_handle,
6584 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
6585 qdf_mem_free(msg->bodyptr);
6586 break;
6587#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006588 case WMA_SET_P2P_GO_NOA_REQ:
6589 wma_process_set_p2pgo_noa_req(wma_handle,
6590 (tP2pPsParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306591 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006592 break;
6593 case WMA_SET_MIMOPS_REQ:
6594 wma_process_set_mimops_req(wma_handle,
6595 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306596 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006597 break;
6598 case WMA_SET_SAP_INTRABSS_DIS:
6599 wma_set_vdev_intrabss_fwd(wma_handle,
6600 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306601 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006602 break;
6603 case WMA_GET_LINK_SPEED:
6604 wma_get_link_speed(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306605 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006606 break;
6607 case WMA_MODEM_POWER_STATE_IND:
6608 wma_notify_modem_power_state(wma_handle,
6609 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306610 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006611 break;
6612 case WMA_WLAN_RESUME_REQ:
Anurag Chouhan6d760662016-02-20 16:05:43 +05306613 wma_resume_req(wma_handle, QDF_SYSTEM_SUSPEND);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006614 break;
6615
6616#ifdef WLAN_FEATURE_STATS_EXT
6617 case WMA_STATS_EXT_REQUEST:
6618 wma_stats_ext_req(wma_handle,
6619 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306620 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006621 break;
6622#endif /* WLAN_FEATURE_STATS_EXT */
6623 case WMA_HIDDEN_SSID_VDEV_RESTART:
6624 wma_hidden_ssid_vdev_restart(wma_handle,
6625 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306626 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006627 break;
6628#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
6629 case WMA_WLAN_EXT_WOW:
6630 wma_enable_ext_wow(wma_handle,
6631 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306632 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006633 break;
6634 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
6635 wma_set_app_type1_params_in_fw(wma_handle,
6636 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306637 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006638 break;
6639 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
6640 wma_set_app_type2_params_in_fw(wma_handle,
6641 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306642 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006643 break;
6644#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
6645#ifdef FEATURE_WLAN_EXTSCAN
6646 case WMA_EXTSCAN_START_REQ:
6647 wma_start_extscan(wma_handle,
6648 (tSirWifiScanCmdReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306649 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006650 break;
6651 case WMA_EXTSCAN_STOP_REQ:
6652 wma_stop_extscan(wma_handle,
6653 (tSirExtScanStopReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306654 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006655 break;
6656 case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:
6657 wma_extscan_start_hotlist_monitor(wma_handle,
6658 (tSirExtScanSetBssidHotListReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306659 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006660 break;
6661 case WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
6662 wma_extscan_stop_hotlist_monitor(wma_handle,
6663 (tSirExtScanResetBssidHotlistReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306664 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006665 break;
6666 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
6667 wma_extscan_start_change_monitor(wma_handle,
6668 (tSirExtScanSetSigChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306669 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670 break;
6671 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
6672 wma_extscan_stop_change_monitor(wma_handle,
6673 (tSirExtScanResetSignificantChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306674 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006675 break;
6676 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
6677 wma_extscan_get_cached_results(wma_handle,
6678 (tSirExtScanGetCachedResultsReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306679 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006680 break;
6681 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
6682 wma_extscan_get_capabilities(wma_handle,
6683 (tSirGetExtScanCapabilitiesReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306684 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006685 break;
6686 case WMA_SET_EPNO_LIST_REQ:
6687 wma_set_epno_network_list(wma_handle,
6688 (struct wifi_epno_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306689 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006690 break;
6691 case WMA_SET_PASSPOINT_LIST_REQ:
6692 /* Issue reset passpoint network list first and clear
6693 * the entries */
6694 wma_reset_passpoint_network_list(wma_handle,
6695 (struct wifi_passpoint_req *)msg->bodyptr);
6696
6697 wma_set_passpoint_network_list(wma_handle,
6698 (struct wifi_passpoint_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306699 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700 break;
6701 case WMA_RESET_PASSPOINT_LIST_REQ:
6702 wma_reset_passpoint_network_list(wma_handle,
6703 (struct wifi_passpoint_req *)msg->bodyptr);
6704 break;
6705 case WMA_EXTSCAN_SET_SSID_HOTLIST_REQ:
6706 wma_set_ssid_hotlist(wma_handle,
6707 (struct sir_set_ssid_hotlist_request *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306708 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006709 break;
6710#endif /* FEATURE_WLAN_EXTSCAN */
6711 case WMA_SET_SCAN_MAC_OUI_REQ:
6712 wma_scan_probe_setoui(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306713 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006714 break;
6715#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6716 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
6717 wma_process_ll_stats_clear_req(wma_handle,
6718 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306719 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006720 break;
6721 case WMA_LINK_LAYER_STATS_SET_REQ:
6722 wma_process_ll_stats_set_req(wma_handle,
6723 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306724 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006725 break;
6726 case WMA_LINK_LAYER_STATS_GET_REQ:
6727 wma_process_ll_stats_get_req(wma_handle,
6728 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306729 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006730 break;
6731#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
6732 case SIR_HAL_UNIT_TEST_CMD:
6733 wma_process_unit_test_cmd(wma_handle,
6734 (t_wma_unit_test_cmd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306735 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006736 break;
6737#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006738 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
6739 wma_process_roam_synch_fail(wma_handle,
6740 (struct roam_offload_synch_fail *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306741 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006742 break;
6743 case SIR_HAL_ROAM_INVOKE:
6744 wma_process_roam_invoke(wma_handle,
6745 (struct wma_roam_invoke_cmd *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306746 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006747 break;
6748#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6749#ifdef WLAN_FEATURE_NAN
6750 case WMA_NAN_REQUEST:
6751 wma_nan_req(wma_handle, (tNanRequest *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306752 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006753 break;
6754#endif /* WLAN_FEATURE_NAN */
6755 case SIR_HAL_SET_BASE_MACADDR_IND:
6756 wma_set_base_macaddr_indicate(wma_handle,
6757 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306758 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006759 break;
6760 case WMA_LINK_STATUS_GET_REQ:
6761 wma_process_link_status_req(wma_handle,
6762 (tAniGetLinkStatus *) msg->bodyptr);
6763 break;
6764 case WMA_GET_TEMPERATURE_REQ:
6765 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306766 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006767 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07006768 case WMA_TSF_GPIO_PIN:
6769 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
6770 break;
6771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006772#ifdef DHCP_SERVER_OFFLOAD
6773 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
6774 wma_process_dhcpserver_offload(wma_handle,
6775 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306776 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006777 break;
6778#endif /* DHCP_SERVER_OFFLOAD */
6779#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
6780 case WMA_LED_FLASHING_REQ:
6781 wma_set_led_flashing(wma_handle,
6782 (tSirLedFlashingReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306783 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006784 break;
6785#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
6786 case SIR_HAL_SET_MAS:
6787 wma_process_set_mas(wma_handle,
6788 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306789 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006790 break;
6791 case SIR_HAL_SET_MIRACAST:
6792 wma_process_set_miracast(wma_handle,
6793 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306794 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006795 break;
6796 case SIR_HAL_CONFIG_STATS_FACTOR:
6797 wma_config_stats_factor(wma_handle,
6798 (struct sir_stats_avg_factor *)
6799 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306800 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006801 break;
6802 case SIR_HAL_CONFIG_GUARD_TIME:
6803 wma_config_guard_time(wma_handle,
6804 (struct sir_guard_time_request *)
6805 msg->bodyptr);
6806 case WMA_IPA_OFFLOAD_ENABLE_DISABLE:
6807 wma_ipa_offload_enable_disable(wma_handle,
6808 (struct sir_ipa_offload_enable_disable *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306809 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006810 break;
6811 case SIR_HAL_START_STOP_LOGGING:
6812 wma_set_wifi_start_packet_stats(wma_handle,
6813 (struct sir_wifi_start_log *)msg->bodyptr);
6814 wma_enable_specific_fw_logs(wma_handle,
6815 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306816 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006817 break;
6818 case SIR_HAL_FLUSH_LOG_TO_FW:
6819 wma_send_flush_logs_to_fw(wma_handle);
6820 /* Body ptr is NULL here */
6821 break;
6822 case WMA_SET_RSSI_MONITOR_REQ:
6823 wma_set_rssi_monitoring(wma_handle,
6824 (struct rssi_monitor_req *)msg->bodyptr);
6825 break;
6826 case WMA_FW_MEM_DUMP_REQ:
6827 wma_process_fw_mem_dump_req(wma_handle,
6828 (struct fw_dump_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306829 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006830 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05306831 case SIR_HAL_PDEV_SET_PCL_TO_FW:
6832 wma_send_pdev_set_pcl_cmd(wma_handle,
6833 (struct wmi_pcl_chan_weights *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306834 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006835 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05306836 case SIR_HAL_PDEV_SET_HW_MODE:
6837 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006838 (struct sir_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306839 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006840 break;
6841 case WMA_OCB_SET_CONFIG_CMD:
6842 wma_ocb_set_config_req(wma_handle,
6843 (struct sir_ocb_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306844 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006845 break;
6846 case WMA_OCB_SET_UTC_TIME_CMD:
6847 wma_ocb_set_utc_time(wma_handle,
6848 (struct sir_ocb_utc *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306849 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006850 break;
6851 case WMA_OCB_START_TIMING_ADVERT_CMD:
6852 wma_ocb_start_timing_advert(wma_handle,
6853 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306854 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006855 break;
6856 case WMA_OCB_STOP_TIMING_ADVERT_CMD:
6857 wma_ocb_stop_timing_advert(wma_handle,
6858 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306859 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006860 break;
6861 case WMA_DCC_CLEAR_STATS_CMD:
6862 wma_dcc_clear_stats(wma_handle,
6863 (struct sir_dcc_clear_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306864 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006865 break;
6866 case WMA_OCB_GET_TSF_TIMER_CMD:
6867 wma_ocb_get_tsf_timer(wma_handle,
6868 (struct sir_ocb_get_tsf_timer *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306869 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006870 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07006871 case WMA_SET_WISA_PARAMS:
6872 wma_set_wisa_params(wma_handle,
6873 (struct sir_wisa_params *)msg->bodyptr);
6874 qdf_mem_free(msg->bodyptr);
6875 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006876 case WMA_DCC_GET_STATS_CMD:
6877 wma_dcc_get_stats(wma_handle,
6878 (struct sir_dcc_get_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306879 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006880 break;
6881 case WMA_DCC_UPDATE_NDL_CMD:
6882 wma_dcc_update_ndl(wma_handle,
6883 (struct sir_dcc_update_ndl *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306884 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006885 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05306886 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
6887 wma_send_pdev_set_dual_mac_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006888 (struct sir_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306889 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006890 break;
6891 case WMA_SET_IE_INFO:
6892 wma_process_set_ie_info(wma_handle,
6893 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306894 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006895 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08006896 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
6897 wma_send_pdev_set_antenna_mode(wma_handle,
6898 (struct sir_antenna_mode_param *)msg->bodyptr);
6899 qdf_mem_free(msg->bodyptr);
6900 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006901 case WMA_LRO_CONFIG_CMD:
6902 wma_lro_config_cmd(wma_handle,
6903 (struct wma_lro_config_cmd_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306904 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006905 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08006906 case WMA_GW_PARAM_UPDATE_REQ:
6907 wma_set_gateway_params(wma_handle,
6908 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08006909 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08006910 break;
6911 case WMA_SET_EGAP_CONF_PARAMS:
6912 wma_send_egap_conf_params(wma_handle,
6913 (struct egap_conf_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306914 qdf_mem_free(msg->bodyptr);
Ravi Joshi9e891ba2015-11-09 19:03:46 -08006915 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05306916 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
6917 wma_send_adapt_dwelltime_params(wma_handle,
6918 (struct adaptive_dwelltime_params *)msg->bodyptr);
6919 qdf_mem_free(msg->bodyptr);
6920 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006921 case WMA_HT40_OBSS_SCAN_IND:
6922 wma_send_ht40_obss_scanind(wma_handle,
6923 (struct obss_ht40_scanind *)msg->bodyptr);
6924 qdf_mem_free(msg->bodyptr);
6925 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07006926 case WMA_ADD_BCN_FILTER_CMDID:
6927 wma_add_beacon_filter(wma_handle, msg->bodyptr);
6928 qdf_mem_free(msg->bodyptr);
6929 break;
6930 case WMA_REMOVE_BCN_FILTER_CMDID:
6931 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
6932 qdf_mem_free(msg->bodyptr);
6933 break;
Arun Khandavalli2476ef52016-04-26 20:19:43 +05306934 case WDA_BPF_GET_CAPABILITIES_REQ:
6935 wma_get_bpf_capabilities(wma_handle);
6936 break;
6937 case WDA_BPF_SET_INSTRUCTIONS_REQ:
6938 wma_set_bpf_instructions(wma_handle, msg->bodyptr);
6939 qdf_mem_free(msg->bodyptr);
6940 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07006941 case SIR_HAL_NDP_INITIATOR_REQ:
6942 wma_handle_ndp_initiator_req(wma_handle, msg->bodyptr);
6943 qdf_mem_free(msg->bodyptr);
6944 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07006945
Abhishek Singh4fef7472016-06-06 11:36:03 -07006946 case SIR_HAL_NDP_RESPONDER_REQ:
6947 wma_handle_ndp_responder_req(wma_handle, msg->bodyptr);
Naveen Rawatf28315c2016-06-29 18:06:02 -07006948 break;
6949
6950 case SIR_HAL_NDP_END_REQ:
6951 wma_handle_ndp_end_req(wma_handle, msg->bodyptr);
Abhishek Singh4fef7472016-06-06 11:36:03 -07006952 qdf_mem_free(msg->bodyptr);
6953 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05306954 case SIR_HAL_POWER_DBG_CMD:
6955 wma_process_hal_pwr_dbg_cmd(wma_handle,
6956 msg->bodyptr);
6957 qdf_mem_free(msg->bodyptr);
6958 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306959 case WMA_UPDATE_WEP_DEFAULT_KEY:
6960 wma_update_wep_default_key(wma_handle,
6961 (struct wep_update_default_key_idx *)msg->bodyptr);
6962 qdf_mem_free(msg->bodyptr);
6963 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05306964 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
6965 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
6966 break;
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05306967 case WMA_ENCRYPT_DECRYPT_MSG:
6968 wma_encrypt_decrypt_msg(wma_handle, msg->bodyptr);
6969 qdf_mem_free(msg->bodyptr);
6970 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05306971 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
6972 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
6973 qdf_mem_free(msg->bodyptr);
6974 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306975 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
6976 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
6977 qdf_mem_free(msg->bodyptr);
6978 break;
6979 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
6980 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
6981 qdf_mem_free(msg->bodyptr);
6982 break;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05306983 case SIR_HAL_POWER_DEBUG_STATS_REQ:
6984 wma_process_power_debug_stats_req(wma_handle);
6985 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006986 default:
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05306987 WMA_LOGD("unknown msg type %x", msg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006988 /* Do Nothing? MSG Body should be freed at here */
6989 if (NULL != msg->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306990 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006991 }
6992 }
6993end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306994 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006995}
6996
Krunal Sonid32c6bc2016-10-18 18:00:21 -07006997QDF_STATUS wma_mc_process_handler(struct scheduler_msg *msg)
6998{
6999 void *cds_ctx = cds_get_global_context();
7000
7001 if (cds_ctx == NULL) {
7002 QDF_TRACE(QDF_MODULE_ID_SYS, QDF_TRACE_LEVEL_ERROR,
7003 "CDS context is NULL");
7004 return QDF_STATUS_E_FAILURE;
7005 }
7006 return wma_mc_process_msg(cds_ctx, (cds_msg_t *)msg);
7007}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007009/**
7010 * wma_log_completion_timeout() - Log completion timeout
7011 * @data: Timeout handler data
7012 *
7013 * This function is called when log completion timer expires
7014 *
7015 * Return: None
7016 */
7017void wma_log_completion_timeout(void *data)
7018{
7019 tp_wma_handle wma_handle;
7020
7021 WMA_LOGE("%s: Timeout occured for log completion command", __func__);
7022
7023 wma_handle = (tp_wma_handle) data;
7024 if (!wma_handle)
7025 WMA_LOGE("%s: Invalid WMA handle", __func__);
7026
7027 /* Though we did not receive any event from FW,
7028 * we can flush whatever logs we have with us */
7029 cds_logging_set_fw_flush_complete();
7030
7031 return;
7032}
7033
7034/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05307035 * wma_map_pcl_weights() - Map PCL weights
7036 * @pcl_weight: Internal PCL weights
7037 *
7038 * Maps the internal weights of PCL to the weights needed by FW
7039 *
7040 * Return: Mapped channel weight of type wmi_pcl_chan_weight
7041 */
7042static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
7043{
7044 switch (pcl_weight) {
7045 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
7046 return WMI_PCL_WEIGHT_VERY_HIGH;
7047 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
7048 return WMI_PCL_WEIGHT_HIGH;
7049 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
7050 return WMI_PCL_WEIGHT_MEDIUM;
7051 case WEIGHT_OF_NON_PCL_CHANNELS:
7052 return WMI_PCL_WEIGHT_LOW;
7053 default:
7054 return WMI_PCL_WEIGHT_DISALLOW;
7055 }
7056}
7057
7058/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307059 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007060 * @wma_handle: WMA handle
7061 * @msg: PCL structure containing the PCL and the number of channels
7062 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307063 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007064 * firmware. The DBS Manager is the consumer of this information in the WLAN
7065 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
7066 * to migrate to a new channel without host driver involvement. An example of
7067 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
7068 * manage the channel selection without firmware involvement.
7069 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307070 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
7071 * channel list. The weights corresponds to the channels sent in
7072 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
7073 * weightage compared to the non PCL channels.
7074 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007075 * Return: Success if the cmd is sent successfully to the firmware
7076 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307077QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
7078 struct wmi_pcl_chan_weights *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007079{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307080 uint32_t i;
7081 QDF_STATUS status;
7082
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007083 if (!wma_handle) {
7084 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7085 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307086 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007087 }
7088
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307089 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
7090 msg->saved_chan_list[i] =
7091 wma_handle->saved_chan.channel_list[i];
7092 }
7093
7094 msg->saved_num_chan = wma_handle->saved_chan.num_channels;
7095 status = cds_get_valid_chan_weights((struct sir_pcl_chan_weights *)msg);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05307096
7097 for (i = 0; i < msg->saved_num_chan; i++) {
7098 msg->weighed_valid_list[i] =
7099 wma_map_pcl_weights(msg->weighed_valid_list[i]);
7100 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
7101 msg->saved_chan_list[i], i,
7102 msg->weighed_valid_list[i]);
7103 }
7104
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307105 if (!QDF_IS_STATUS_SUCCESS(status)) {
7106 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
7107 return status;
7108 }
7109
7110 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle, msg))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307111 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05307112
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307113 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007114}
7115
7116/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307117 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007118 * @wma_handle: WMA handle
7119 * @msg: Structure containing the following parameters
7120 *
7121 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
7122 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
7123 *
7124 * Provides notification to the WLAN firmware that host driver is requesting a
7125 * HardWare (HW) Mode change. This command is needed to support iHelium in the
7126 * configurations that include the Dual Band Simultaneous (DBS) feature.
7127 *
7128 * Return: Success if the cmd is sent successfully to the firmware
7129 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307130QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007131 struct sir_hw_mode *msg)
7132{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007133 struct sir_set_hw_mode_resp *param;
7134
7135 if (!wma_handle) {
7136 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7137 __func__);
7138 /* Handle is NULL. Will not be able to send failure
7139 * response as well
7140 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307141 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007142 }
7143
7144 if (!msg) {
7145 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
7146 /* Lets try to free the active command list */
7147 goto fail;
7148 }
7149
Govind Singhf25a0f12016-03-08 16:09:48 +05307150 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
7151 msg->hw_mode_index))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007152 goto fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007153
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307154 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007155fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307156 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007157 if (!param) {
7158 WMA_LOGE("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307159 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007160 }
7161 param->status = SET_HW_MODE_STATUS_ECANCELED;
7162 param->cfgd_hw_mode_index = 0;
7163 param->num_vdev_mac_entries = 0;
7164 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307165 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007166 (void *) param, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307167 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007168}
7169
7170/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307171 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007172 * @wma_handle: WMA handle
7173 * @msg: Dual MAC config parameters
7174 *
7175 * Configures WLAN firmware with the dual MAC features
7176 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307177 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007178 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307179QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007180 struct sir_dual_mac_config *msg)
7181{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307182 QDF_STATUS status;
7183
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007184 if (!wma_handle) {
7185 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7186 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307187 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007188 }
7189
7190 if (!msg) {
7191 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307192 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007193 }
7194
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307195 status = wmi_unified_pdev_set_dual_mac_config_cmd(
7196 wma_handle->wmi_handle,
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307197 (struct wmi_dual_mac_config *)msg);
7198 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307199 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307200 __func__, status);
7201 return status;
7202 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007203
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307204 wma_handle->dual_mac_cfg.req_scan_config = msg->scan_config;
7205 wma_handle->dual_mac_cfg.req_fw_mode_config = msg->fw_mode_config;
Govind Singhf25a0f12016-03-08 16:09:48 +05307206
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307207 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007208}
7209
7210/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007211 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
7212 * @wma_handle: WMA handle
7213 * @msg: Antenna mode parameters
7214 *
7215 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
7216 * modify the number of TX/RX chains from host
7217 *
7218 * Return: QDF_STATUS. 0 on success.
7219 */
7220QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
7221 struct sir_antenna_mode_param *msg)
7222{
7223 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
7224 wmi_buf_t buf;
7225 uint32_t len;
7226 QDF_STATUS status = QDF_STATUS_SUCCESS;
7227 struct sir_antenna_mode_resp *param;
7228
7229 if (!wma_handle) {
7230 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7231 __func__);
7232 return QDF_STATUS_E_NULL_VALUE;
7233 }
7234
7235 if (!msg) {
7236 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
7237 return QDF_STATUS_E_NULL_VALUE;
7238 }
7239
7240 len = sizeof(*cmd);
7241
7242 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7243 if (!buf) {
7244 WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
7245 status = QDF_STATUS_E_NOMEM;
7246 goto resp;
7247 }
7248
7249 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
7250 WMITLV_SET_HDR(&cmd->tlv_header,
7251 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
7252 WMITLV_GET_STRUCT_TLVLEN(
7253 wmi_pdev_set_antenna_mode_cmd_fixed_param));
7254
7255 cmd->pdev_id = WMI_PDEV_ID_SOC;
7256 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
7257 cmd->num_txrx_chains = msg->num_rx_chains;
7258 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
7259
7260 WMA_LOGI("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
7261 __func__, msg->num_tx_chains,
7262 msg->num_rx_chains, cmd->num_txrx_chains);
7263
7264 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7265 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
7266 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_ANTENNA_MODE_CMDID",
7267 __func__);
7268 wmi_buf_free(buf);
7269 status = QDF_STATUS_E_FAILURE;
7270 goto resp;
7271 }
7272 status = QDF_STATUS_SUCCESS;
7273
7274resp:
7275 param = qdf_mem_malloc(sizeof(*param));
7276 if (!param) {
7277 WMA_LOGE("%s: Memory allocation failed", __func__);
7278 return QDF_STATUS_E_NOMEM;
7279 }
7280 param->status = (status) ?
7281 SET_ANTENNA_MODE_STATUS_ECANCELED :
7282 SET_ANTENNA_MODE_STATUS_OK;
7283 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
7284 __func__, param->status);
7285 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
7286 (void *) param, 0);
7287 return status;
7288}
7289
7290/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007291 * wma_crash_inject() - sends command to FW to simulate crash
7292 * @wma_handle: pointer of WMA context
7293 * @type: subtype of the command
7294 * @delay_time_ms: time in milliseconds for FW to delay the crash
7295 *
7296 * This function will send a command to FW in order to simulate different
7297 * kinds of FW crashes.
7298 *
Govind Singhd76a5b02016-03-08 15:12:14 +05307299 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007300 */
Govind Singhd76a5b02016-03-08 15:12:14 +05307301QDF_STATUS wma_crash_inject(tp_wma_handle wma_handle, uint32_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007302 uint32_t delay_time_ms)
7303{
Govind Singhd76a5b02016-03-08 15:12:14 +05307304 struct crash_inject param;
7305 param.type = type;
7306 param.delay_time_ms = delay_time_ms;
7307
7308 return wmi_crash_inject(wma_handle->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007309}
Govind Singhd76a5b02016-03-08 15:12:14 +05307310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007311#if defined(FEATURE_LRO)
7312/**
7313 * wma_lro_init() - sends LRO configuration to FW
7314 * @lro_config: pointer to the config parameters
7315 *
7316 * This function ends LRO configuration to FW.
7317 *
7318 * Return: 0 for success or reasons for failure
7319 */
7320int wma_lro_init(struct wma_lro_config_cmd_t *lro_config)
7321{
7322 cds_msg_t msg = {0};
7323 struct wma_lro_config_cmd_t *iwcmd;
7324
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307325 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007326 if (!iwcmd) {
7327 WMA_LOGE("memory allocation for WMA_LRO_CONFIG_CMD failed!");
7328 return -ENOMEM;
7329 }
7330
7331 *iwcmd = *lro_config;
7332
7333 msg.type = WMA_LRO_CONFIG_CMD;
7334 msg.reserved = 0;
7335 msg.bodyptr = iwcmd;
7336
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307337 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05307338 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007339 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307340 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007341 return -EAGAIN;
7342 }
7343
7344 WMA_LOGD("sending the LRO configuration to the fw");
7345 return 0;
7346}
7347#endif
Leo Chang96464902016-10-28 11:10:54 -07007348
7349void wma_peer_set_default_routing(void *scn_handle, uint8_t *peer_macaddr,
7350 uint8_t vdev_id, bool hash_based, uint8_t ring_num)
7351{
7352 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7353 struct peer_set_params param;
7354
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307355 if (!wma) {
7356 WMA_LOGE("%s:wma_handle is NULL", __func__);
7357 return;
7358 }
Leo Chang96464902016-10-28 11:10:54 -07007359
7360 /* TODO: Need bit definitions for ring number and hash based routing
7361 * fields in common wmi header file
7362 */
7363 param.param_id = WMI_HOST_PEER_SET_DEFAULT_ROUTING;
7364 param.vdev_id = vdev_id;
7365 param.param_value = ((hash_based) ? 1 : 0) | (ring_num << 1);
7366 wmi_set_peer_param_send(wma->wmi_handle, peer_macaddr, &param);
7367
7368 return;
7369}
7370
7371int wma_peer_rx_reorder_queue_setup(void *scn_handle,
7372 uint8_t vdev_id, uint8_t *peer_macaddr, qdf_dma_addr_t hw_qdesc,
7373 int tid, uint16_t queue_no)
7374{
7375 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7376 struct rx_reorder_queue_setup_params param;
7377
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307378 if (!wma) {
7379 WMA_LOGE("%s:wma_handle is NULL", __func__);
7380 return QDF_STATUS_E_FAILURE;
7381 }
7382
Leo Chang96464902016-10-28 11:10:54 -07007383 param.tid = tid;
7384 param.vdev_id = vdev_id;
7385 param.peer_macaddr = peer_macaddr;
7386 param.hw_qdesc_paddr_lo = hw_qdesc & 0xffffffff;
7387 param.hw_qdesc_paddr_hi = (uint64_t)hw_qdesc >> 32;
7388 param.queue_no = queue_no;
7389
7390 return wmi_unified_peer_rx_reorder_queue_setup_send(wma->wmi_handle,
7391 &param);
7392}
7393
7394int wma_peer_rx_reorder_queue_remove(void *scn_handle,
7395 uint8_t vdev_id, uint8_t *peer_macaddr, uint32_t peer_tid_bitmap)
7396{
7397 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7398 struct rx_reorder_queue_remove_params param;
7399
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307400 if (!wma) {
7401 WMA_LOGE("%s:wma_handle is NULL", __func__);
7402 return QDF_STATUS_E_FAILURE;
7403 }
7404
Leo Chang96464902016-10-28 11:10:54 -07007405 param.vdev_id = vdev_id;
7406 param.peer_macaddr = peer_macaddr;
7407 param.peer_tid_bitmap = peer_tid_bitmap;
7408
7409 return wmi_unified_peer_rx_reorder_queue_remove_send(wma->wmi_handle,
7410 &param);
7411}
7412
7413