blob: c14d8b7377652cdeeb7564f6f3d8127b4c1847d9 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002 * Copyright (c) 2013-2016 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#include "ol_txrx_peer_find.h"
56
57#include "wma_types.h"
58#include "lim_api.h"
59#include "lim_session_utils.h"
60
61#include "cds_utils.h"
62
63#if !defined(REMOVE_PKT_LOG)
64#include "pktlog_ac.h"
65#endif /* REMOVE_PKT_LOG */
66
67#include "dbglog_host.h"
Govind Singhd76a5b02016-03-08 15:12:14 +053068#include "wmi_version_whitelist.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069#include "csr_api.h"
70#include "ol_fw.h"
71
72#include "dfs.h"
73#include "wma_internal.h"
74
75#include "wma_ocb.h"
Chandrasekaran, Manishekar0d814c72015-11-05 10:42:48 +053076#include "cds_concurrency.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080077#include "cdp_txrx_cfg.h"
78#include "cdp_txrx_flow_ctrl_legacy.h"
79#include "cdp_txrx_flow_ctrl_v2.h"
80#include "cdp_txrx_ipa.h"
Deepak Dhamdhere13230d32016-05-26 00:46:53 -070081#include "wma_nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082
83#define WMA_LOG_COMPLETION_TIMER 10000 /* 10 seconds */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +053085#define WMI_TLV_HEADROOM 128
86
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087static uint32_t g_fw_wlan_feat_caps;
88
89/**
90 * wma_get_fw_wlan_feat_caps() - get fw feature capablity
91 * @featEnumValue: feature enum value
92 *
93 * Return: true/false
94 */
95uint8_t wma_get_fw_wlan_feat_caps(uint8_t featEnumValue)
96{
97 return (g_fw_wlan_feat_caps & (1 << featEnumValue)) ? true : false;
98}
99
100/**
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530101 * wma_service_ready_ext_evt_timeout() - Service ready extended event timeout
102 * @data: Timeout handler data
103 *
104 * This function is called when the FW fails to send WMI_SERVICE_READY_EXT_EVENT
105 * message
106 *
107 * Return: None
108 */
109static void wma_service_ready_ext_evt_timeout(void *data)
110{
111 tp_wma_handle wma_handle;
112
113 WMA_LOGA("%s: Timeout waiting for WMI_SERVICE_READY_EXT_EVENT",
114 __func__);
115
116 wma_handle = (tp_wma_handle) data;
117
118 if (!wma_handle) {
119 WMA_LOGE("%s: Invalid WMA handle", __func__);
120 goto end;
121 }
122
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530123end:
Naveen Rawatac39a102016-10-07 10:58:29 -0700124 /* Assert here. Panic is being called in insmod thread */
125 QDF_ASSERT(0);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530126}
127
128/**
Komal Seelam02d09342016-02-23 18:03:19 +0530129 * wma_get_ini_handle() - API to get WMA ini info handle
130 * @wma: WMA Handle
131 *
132 * Returns the pointer to WMA ini structure.
133 * Return: struct wma_ini_config
134 */
135struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma)
136{
137 if (!wma) {
138 WMA_LOGE("%s: Invalid WMA context\n", __func__);
139 return NULL;
140 }
141
142 return &wma->ini_config;
143}
144
145#define MAX_SUPPORTED_PEERS_REV1_1 14
146#define MAX_SUPPORTED_PEERS_REV1_3 32
147#define MIN_NO_OF_PEERS 1
148
149/**
150 * wma_get_number_of_peers_supported - API to query for number of peers
151 * supported
152 * @wma: WMA Handle
153 *
154 * Return: Max Number of Peers Supported
155 */
156static uint8_t wma_get_number_of_peers_supported(tp_wma_handle wma)
157{
158 struct hif_target_info *tgt_info;
159 struct wma_ini_config *cfg = wma_get_ini_handle(wma);
160 uint8_t max_no_of_peers = cfg ? cfg->max_no_of_peers : MIN_NO_OF_PEERS;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530161 struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF);
Komal Seelam02d09342016-02-23 18:03:19 +0530162
163 if (!scn) {
164 WMA_LOGE("%s: Invalid wma handle", __func__);
165 return 0;
166 }
167
168 tgt_info = hif_get_target_info_handle(scn);
169
170 switch (tgt_info->target_version) {
171 case AR6320_REV1_1_VERSION:
172 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_1)
173 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_1;
174 break;
175 default:
176 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_3)
177 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_3;
178 break;
179 }
180
181 return max_no_of_peers;
182}
183
184/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185 * wma_set_default_tgt_config() - set default tgt config
186 * @wma_handle: wma handle
187 *
188 * Return: none
189 */
190static void wma_set_default_tgt_config(tp_wma_handle wma_handle)
191{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800192 uint8_t no_of_peers_supported;
193 wmi_resource_config tgt_cfg = {
194 0, /* Filling zero for TLV Tag and Length fields */
195 CFG_TGT_NUM_VDEV,
196 CFG_TGT_NUM_PEERS + CFG_TGT_NUM_VDEV + 2,
197 CFG_TGT_NUM_OFFLOAD_PEERS,
198 CFG_TGT_NUM_OFFLOAD_REORDER_BUFFS,
199 CFG_TGT_NUM_PEER_KEYS,
200 CFG_TGT_NUM_TIDS,
201 CFG_TGT_AST_SKID_LIMIT,
202 CFG_TGT_DEFAULT_TX_CHAIN_MASK,
203 CFG_TGT_DEFAULT_RX_CHAIN_MASK,
204 {CFG_TGT_RX_TIMEOUT_LO_PRI, CFG_TGT_RX_TIMEOUT_LO_PRI,
205 CFG_TGT_RX_TIMEOUT_LO_PRI, CFG_TGT_RX_TIMEOUT_HI_PRI},
206 CFG_TGT_RX_DECAP_MODE,
207 CFG_TGT_DEFAULT_SCAN_MAX_REQS,
208 CFG_TGT_DEFAULT_BMISS_OFFLOAD_MAX_VDEV,
209 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_VDEV,
210 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_PROFILES,
211 CFG_TGT_DEFAULT_NUM_MCAST_GROUPS,
212 CFG_TGT_DEFAULT_NUM_MCAST_TABLE_ELEMS,
213 CFG_TGT_DEFAULT_MCAST2UCAST_MODE,
214 CFG_TGT_DEFAULT_TX_DBG_LOG_SIZE,
215 CFG_TGT_WDS_ENTRIES,
216 CFG_TGT_DEFAULT_DMA_BURST_SIZE,
217 CFG_TGT_DEFAULT_MAC_AGGR_DELIM,
218 CFG_TGT_DEFAULT_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK,
219 CFG_TGT_DEFAULT_VOW_CONFIG,
220 CFG_TGT_DEFAULT_GTK_OFFLOAD_MAX_VDEV,
221 CFG_TGT_NUM_MSDU_DESC,
222 CFG_TGT_MAX_FRAG_TABLE_ENTRIES,
223 CFG_TGT_NUM_TDLS_VDEVS,
224 CFG_TGT_NUM_TDLS_CONN_TABLE_ENTRIES,
225 CFG_TGT_DEFAULT_BEACON_TX_OFFLOAD_MAX_VDEV,
226 CFG_TGT_MAX_MULTICAST_FILTER_ENTRIES,
227 0,
228 0,
229 0,
230 CFG_TGT_NUM_TDLS_CONC_SLEEP_STAS,
231 CFG_TGT_NUM_TDLS_CONC_BUFFER_STAS,
232 0,
233 CFG_TGT_NUM_OCB_VDEVS,
234 CFG_TGT_NUM_OCB_CHANNELS,
235 CFG_TGT_NUM_OCB_SCHEDULES,
236 };
237
Komal Seelam02d09342016-02-23 18:03:19 +0530238 no_of_peers_supported = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239 tgt_cfg.num_peers = no_of_peers_supported + CFG_TGT_NUM_VDEV + 2;
240 tgt_cfg.num_tids = (2 * (no_of_peers_supported + CFG_TGT_NUM_VDEV + 2));
241 tgt_cfg.scan_max_pending_req = wma_handle->max_scan;
242
Nirav Shah20489972016-06-16 19:20:28 +0530243 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(tgt_cfg.flag1, 1);
Yun Park4d968df2016-10-11 11:44:15 -0700244 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(tgt_cfg.flag1,
245 1);
Nirav Shah20489972016-06-16 19:20:28 +0530246
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 WMITLV_SET_HDR(&tgt_cfg.tlv_header,
248 WMITLV_TAG_STRUC_wmi_resource_config,
249 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
250 /* reduce the peer/vdev if CFG_TGT_NUM_MSDU_DESC exceeds 1000 */
251#ifdef PERE_IP_HDR_ALIGNMENT_WAR
252 if (scn->host_80211_enable) {
253 /*
254 * To make the IP header begins at dword aligned address,
255 * we make the decapsulation mode as Native Wifi.
256 */
257 tgt_cfg.rx_decap_mode = CFG_TGT_RX_DECAP_MODE_NWIFI;
258 }
259#endif /* PERE_IP_HDR_ALIGNMENT_WAR */
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700260 if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam())
261 tgt_cfg.rx_decap_mode = CFG_TGT_RX_DECAP_MODE_RAW;
262
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263 wma_handle->wlan_resource_config = tgt_cfg;
264}
265
266/**
267 * wma_cli_get_command() - WMA "get" command processor
268 * @vdev_id: virtual device for the command
269 * @param_id: parameter id
270 * @vpdev: parameter category
271 *
272 * Return: parameter value on success, -EINVAL on failure
273 */
274int wma_cli_get_command(int vdev_id, int param_id, int vpdev)
275{
276 int ret = 0;
277 tp_wma_handle wma;
278 struct wma_txrx_node *intr = NULL;
279
Anurag Chouhan6d760662016-02-20 16:05:43 +0530280 wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281
282 if (NULL == wma) {
283 WMA_LOGE("%s: Invalid wma handle", __func__);
284 return -EINVAL;
285 }
286
287 intr = wma->interfaces;
288
289 if (VDEV_CMD == vpdev) {
290 switch (param_id) {
291 case WMI_VDEV_PARAM_NSS:
292 ret = intr[vdev_id].config.nss;
293 break;
294#ifdef QCA_SUPPORT_GTX
295 case WMI_VDEV_PARAM_GTX_HT_MCS:
296 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
297 break;
298 case WMI_VDEV_PARAM_GTX_VHT_MCS:
299 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
300 break;
301 case WMI_VDEV_PARAM_GTX_USR_CFG:
302 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
303 break;
304 case WMI_VDEV_PARAM_GTX_THRE:
305 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
306 break;
307 case WMI_VDEV_PARAM_GTX_MARGIN:
308 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
309 break;
310 case WMI_VDEV_PARAM_GTX_STEP:
311 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
312 break;
313 case WMI_VDEV_PARAM_GTX_MINTPC:
314 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
315 break;
316 case WMI_VDEV_PARAM_GTX_BW_MASK:
317 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
318 break;
319#endif /* QCA_SUPPORT_GTX */
320 case WMI_VDEV_PARAM_LDPC:
321 ret = intr[vdev_id].config.ldpc;
322 break;
323 case WMI_VDEV_PARAM_TX_STBC:
324 ret = intr[vdev_id].config.tx_stbc;
325 break;
326 case WMI_VDEV_PARAM_RX_STBC:
327 ret = intr[vdev_id].config.rx_stbc;
328 break;
329 case WMI_VDEV_PARAM_SGI:
330 ret = intr[vdev_id].config.shortgi;
331 break;
332 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
333 ret = intr[vdev_id].config.rtscts_en;
334 break;
335 case WMI_VDEV_PARAM_CHWIDTH:
336 ret = intr[vdev_id].config.chwidth;
337 break;
338 case WMI_VDEV_PARAM_FIXED_RATE:
339 ret = intr[vdev_id].config.tx_rate;
340 break;
341 default:
342 WMA_LOGE("Invalid cli_get vdev command/Not"
343 " yet implemented 0x%x", param_id);
344 return -EINVAL;
345 }
346 } else if (PDEV_CMD == vpdev) {
347 switch (param_id) {
348 case WMI_PDEV_PARAM_ANI_ENABLE:
349 ret = wma->pdevconfig.ani_enable;
350 break;
351 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
352 ret = wma->pdevconfig.ani_poll_len;
353 break;
354 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
355 ret = wma->pdevconfig.ani_listen_len;
356 break;
357 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
358 ret = wma->pdevconfig.ani_ofdm_level;
359 break;
360 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
361 ret = wma->pdevconfig.ani_cck_level;
362 break;
363 case WMI_PDEV_PARAM_DYNAMIC_BW:
364 ret = wma->pdevconfig.cwmenable;
365 break;
366 case WMI_PDEV_PARAM_CTS_CBW:
367 ret = wma->pdevconfig.cts_cbw;
368 break;
369 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
370 ret = wma->pdevconfig.txchainmask;
371 break;
372 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
373 ret = wma->pdevconfig.rxchainmask;
374 break;
375 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
376 ret = wma->pdevconfig.txpow2g;
377 break;
378 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
379 ret = wma->pdevconfig.txpow5g;
380 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 case WMI_PDEV_PARAM_BURST_ENABLE:
382 ret = wma->pdevconfig.burst_enable;
383 break;
384 case WMI_PDEV_PARAM_BURST_DUR:
385 ret = wma->pdevconfig.burst_dur;
386 break;
387 default:
388 WMA_LOGE("Invalid cli_get pdev command/Not"
389 " yet implemented 0x%x", param_id);
390 return -EINVAL;
391 }
392 } else if (GEN_CMD == vpdev) {
393 switch (param_id) {
394 case GEN_VDEV_PARAM_AMPDU:
395 ret = intr[vdev_id].config.ampdu;
396 break;
397 case GEN_VDEV_PARAM_AMSDU:
398 ret = intr[vdev_id].config.amsdu;
399 break;
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700400 case GEN_VDEV_ROAM_SYNCH_DELAY:
401 ret = intr[vdev_id].roam_synch_delay;
402 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403 default:
404 WMA_LOGE("Invalid generic vdev command/Not"
405 " yet implemented 0x%x", param_id);
406 return -EINVAL;
407 }
408 } else if (PPS_CMD == vpdev) {
409 switch (param_id) {
410 case WMI_VDEV_PPS_PAID_MATCH:
411 ret = intr[vdev_id].config.pps_params.paid_match_enable;
412 break;
413 case WMI_VDEV_PPS_GID_MATCH:
414 ret = intr[vdev_id].config.pps_params.gid_match_enable;
415 break;
416 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
417 ret = intr[vdev_id].config.pps_params.tim_clear;
418 break;
419 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
420 ret = intr[vdev_id].config.pps_params.dtim_clear;
421 break;
422 case WMI_VDEV_PPS_EOF_PAD_DELIM:
423 ret = intr[vdev_id].config.pps_params.eof_delim;
424 break;
425 case WMI_VDEV_PPS_MACADDR_MISMATCH:
426 ret = intr[vdev_id].config.pps_params.mac_match;
427 break;
428 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
429 ret = intr[vdev_id].config.pps_params.delim_fail;
430 break;
431 case WMI_VDEV_PPS_GID_NSTS_ZERO:
432 ret = intr[vdev_id].config.pps_params.nsts_zero;
433 break;
434 case WMI_VDEV_PPS_RSSI_CHECK:
435 ret = intr[vdev_id].config.pps_params.rssi_chk;
436 break;
437 default:
438 WMA_LOGE("Invalid pps vdev command/Not"
439 " yet implemented 0x%x", param_id);
440 return -EINVAL;
441 }
442 } else if (QPOWER_CMD == vpdev) {
443 switch (param_id) {
444 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
445 ret = intr[vdev_id].config.qpower_params.
446 max_ps_poll_cnt;
447 break;
448 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
449 ret = intr[vdev_id].config.qpower_params.
450 max_tx_before_wake;
451 break;
452 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
453 ret = intr[vdev_id].config.qpower_params.
454 spec_ps_poll_wake_interval;
455 break;
456 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
457 ret = intr[vdev_id].config.qpower_params.
458 max_spec_nodata_ps_poll;
459 break;
460 default:
461 WMA_LOGE("Invalid generic vdev command/Not"
462 " yet implemented 0x%x", param_id);
463 return -EINVAL;
464 }
465 } else if (GTX_CMD == vpdev) {
466 switch (param_id) {
467 case WMI_VDEV_PARAM_GTX_HT_MCS:
468 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
469 break;
470 case WMI_VDEV_PARAM_GTX_VHT_MCS:
471 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
472 break;
473 case WMI_VDEV_PARAM_GTX_USR_CFG:
474 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
475 break;
476 case WMI_VDEV_PARAM_GTX_THRE:
477 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
478 break;
479 case WMI_VDEV_PARAM_GTX_MARGIN:
480 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
481 break;
482 case WMI_VDEV_PARAM_GTX_STEP:
483 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
484 break;
485 case WMI_VDEV_PARAM_GTX_MINTPC:
486 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
487 break;
488 case WMI_VDEV_PARAM_GTX_BW_MASK:
489 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
490 break;
491 default:
492 WMA_LOGE("Invalid generic vdev command/Not"
493 " yet implemented 0x%x", param_id);
494 return -EINVAL;
495 }
496 }
497 return ret;
498}
499
500/**
501 * wma_cli_set2_command() - WMA "set 2 params" command processor
502 * @vdev_id: virtual device for the command
503 * @param_id: parameter id
504 * @sval1: first parameter value
505 * @sval2: second parameter value
506 * @vpdev: parameter category
507 *
508 * Command handler for set operations which require 2 parameters
509 *
510 * Return: 0 on success, errno on failure
511 */
512int wma_cli_set2_command(int vdev_id, int param_id, int sval1,
513 int sval2, int vpdev)
514{
515 cds_msg_t msg = { 0 };
516 wma_cli_set_cmd_t *iwcmd;
517
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530518 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 if (!iwcmd) {
520 WMA_LOGE("%s: Failed alloc memory for iwcmd", __func__);
521 return -ENOMEM;
522 }
523
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530524 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 iwcmd->param_value = sval1;
526 iwcmd->param_sec_value = sval2;
527 iwcmd->param_vdev_id = vdev_id;
528 iwcmd->param_id = param_id;
529 iwcmd->param_vp_dev = vpdev;
530 msg.type = WMA_CLI_SET_CMD;
531 msg.reserved = 0;
532 msg.bodyptr = iwcmd;
533
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530534 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +0530535 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 WMA_LOGP("%s: Failed to post WMA_CLI_SET_CMD msg",
537 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530538 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539 return -EIO;
540 }
541 return 0;
542}
543
544/**
545 * wma_cli_set_command() - WMA "set" command processor
546 * @vdev_id: virtual device for the command
547 * @param_id: parameter id
548 * @sval: parameter value
549 * @vpdev: parameter category
550 *
551 * Command handler for set operations
552 *
553 * Return: 0 on success, errno on failure
554 */
555int wma_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
556{
557 return wma_cli_set2_command(vdev_id, param_id, sval, 0, vpdev);
558
559}
560
561/**
562 * wma_set_priv_cfg() - set private config parameters
563 * @wma_handle: wma handle
564 * @privcmd: private command
565 *
566 * Return: 0 for success or error code
567 */
568static int32_t wma_set_priv_cfg(tp_wma_handle wma_handle,
569 wma_cli_set_cmd_t *privcmd)
570{
571 int32_t ret = 0;
572
573 switch (privcmd->param_id) {
574 case WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID:
575 ret = wma_set_txrx_fw_stats_level(wma_handle,
576 privcmd->param_vdev_id,
577 privcmd->param_value);
578 break;
579 case WMA_VDEV_TXRX_FWSTATS_RESET_CMDID:
580 ret = wma_txrx_fw_stats_reset(wma_handle,
581 privcmd->param_vdev_id,
582 privcmd->param_value);
583 break;
584 case WMI_STA_SMPS_FORCE_MODE_CMDID:
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800585 ret = wma_set_mimops(wma_handle,
586 privcmd->param_vdev_id,
587 privcmd->param_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588 break;
589 case WMI_STA_SMPS_PARAM_CMDID:
590 wma_set_smps_params(wma_handle, privcmd->param_vdev_id,
591 privcmd->param_value);
592 break;
593 case WMA_VDEV_MCC_SET_TIME_LATENCY:
594 {
595 /* Extract first MCC adapter/vdev channel number and latency */
596 uint8_t mcc_channel = privcmd->param_value & 0x000000FF;
597 uint8_t mcc_channel_latency =
598 (privcmd->param_value & 0x0000FF00) >> 8;
599 int ret = -1;
600 WMA_LOGD("%s: Parsed input: Channel #1:%d, latency:%dms",
601 __func__, mcc_channel, mcc_channel_latency);
602 ret = wma_set_mcc_channel_time_latency(wma_handle,
603 mcc_channel,
604 mcc_channel_latency);
605 }
606 break;
607 case WMA_VDEV_MCC_SET_TIME_QUOTA:
608 {
609 /* Extract the MCC 2 adapters/vdevs channel numbers and time
610 * quota value for the first adapter only (which is specified
611 * in iwpriv command.
612 */
613 uint8_t adapter_2_chan_number =
614 privcmd->param_value & 0x000000FF;
615 uint8_t adapter_1_chan_number =
616 (privcmd->param_value & 0x0000FF00) >> 8;
617 uint8_t adapter_1_quota =
618 (privcmd->param_value & 0x00FF0000) >> 16;
619 int ret = -1;
620
621 WMA_LOGD("%s: Parsed input: Channel #1:%d, Channel #2:%d, quota 1:%dms",
622 __func__, adapter_1_chan_number,
623 adapter_2_chan_number, adapter_1_quota);
624
625 ret = wma_set_mcc_channel_time_quota(wma_handle,
626 adapter_1_chan_number,
627 adapter_1_quota,
628 adapter_2_chan_number);
629 }
630 break;
631 case WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE:
632 {
633 wma_handle->wma_ibss_power_save_params.atimWindowLength =
634 privcmd->param_value;
635 WMA_LOGD("%s: IBSS power save ATIM Window = %d",
636 __func__, wma_handle->wma_ibss_power_save_params.
637 atimWindowLength);
638 }
639 break;
640 case WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED:
641 {
642 wma_handle->wma_ibss_power_save_params.isPowerSaveAllowed =
643 privcmd->param_value;
644 WMA_LOGD("%s: IBSS is Power Save Allowed = %d",
645 __func__, wma_handle->wma_ibss_power_save_params.
646 isPowerSaveAllowed);
647 }
648 break;
649 case WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED:
650 {
651 wma_handle->wma_ibss_power_save_params. isPowerCollapseAllowed =
652 privcmd->param_value;
653 WMA_LOGD("%s: IBSS is Power Collapse Allowed = %d",
654 __func__, wma_handle->wma_ibss_power_save_params.
655 isPowerCollapseAllowed);
656 }
657 break;
658 case WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX:
659 {
660 wma_handle->wma_ibss_power_save_params.isAwakeonTxRxEnabled =
661 privcmd->param_value;
662 WMA_LOGD("%s: IBSS Power Save Awake on Tx/Rx Enabled = %d",
663 __func__, wma_handle->wma_ibss_power_save_params.
664 isAwakeonTxRxEnabled);
665 }
666 break;
667 case WMA_VDEV_IBSS_SET_INACTIVITY_TIME:
668 {
669 wma_handle->wma_ibss_power_save_params.inactivityCount =
670 privcmd->param_value;
671 WMA_LOGD("%s: IBSS Power Save Data Inactivity Count = %d",
672 __func__, wma_handle->wma_ibss_power_save_params.
673 inactivityCount);
674 }
675 break;
676 case WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME:
677 {
678 wma_handle->wma_ibss_power_save_params.txSPEndInactivityTime =
679 privcmd->param_value;
680 WMA_LOGD("%s: IBSS Power Save Transmit EOSP inactivity time out = %d",
681 __func__, wma_handle->wma_ibss_power_save_params.
682 txSPEndInactivityTime);
683 }
684 break;
685 case WMA_VDEV_DFS_CONTROL_CMDID:
686 {
687 struct ieee80211com *dfs_ic = wma_handle->dfs_ic;
688 struct ath_dfs *dfs;
689
690 if (!dfs_ic) {
691 ret = -ENOENT;
692 } else {
693 if (dfs_ic->ic_curchan) {
694 WMA_LOGD("%s: Debug cmd: %s received on ch: %d",
695 __func__, "WMA_VDEV_DFS_CONTROL_CMDID",
696 dfs_ic->ic_curchan->ic_ieee);
697
698 if (dfs_ic->ic_curchan->ic_flagext &
699 IEEE80211_CHAN_DFS) {
700 dfs = (struct ath_dfs *)dfs_ic->ic_dfs;
701 dfs->dfs_bangradar = 1;
702 dfs->ath_radar_tasksched = 1;
703 OS_SET_TIMER(&dfs->ath_dfs_task_timer,
704 0);
705 } else {
706 ret = -ENOENT;
707 }
708 } else {
709 ret = -ENOENT;
710 }
711 }
712
713 if (ret == -ENOENT) {
714 WMA_LOGE("%s: Operating channel is not DFS capable,ignoring %s",
715 __func__, "WMA_VDEV_DFS_CONTROL_CMDID");
716 } else if (ret) {
717 WMA_LOGE("%s: Sending command %s failed with %d\n",
718 __func__, "WMA_VDEV_DFS_CONTROL_CMDID",
719 ret);
720 }
721 }
722 break;
723 case WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS:
724 {
725 wma_handle->wma_ibss_power_save_params.ibssPsWarmupTime =
726 privcmd->param_value;
727 WMA_LOGD("%s: IBSS Power Save Warm Up Time in Seconds = %d",
728 __func__, wma_handle->wma_ibss_power_save_params.
729 ibssPsWarmupTime);
730 }
731 break;
732 case WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW:
733 {
734 wma_handle->wma_ibss_power_save_params.ibssPs1RxChainInAtimEnable
735 = privcmd->param_value;
736 WMA_LOGD("%s: IBSS Power Save single RX Chain Enable In ATIM = %d",
737 __func__, wma_handle->wma_ibss_power_save_params.
738 ibssPs1RxChainInAtimEnable);
739 }
740 break;
741
742 case WMA_VDEV_TXRX_GET_IPA_UC_FW_STATS_CMDID:
743 {
744 ol_txrx_pdev_handle pdev;
745
Anurag Chouhan6d760662016-02-20 16:05:43 +0530746 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747 if (!pdev) {
748 WMA_LOGE("pdev NULL for uc stat");
749 return -EINVAL;
750 }
751 ol_txrx_ipa_uc_get_stat(pdev);
752 }
753 break;
754
755 default:
756 WMA_LOGE("Invalid wma config command id:%d", privcmd->param_id);
757 ret = -EINVAL;
758 }
759 return ret;
760}
761
762/**
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -0700763 * wma_set_dtim_period() - set dtim period to FW
764 * @wma: wma handle
765 * @dtim_params: dtim params
766 *
767 * Return: none
768 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -0700769static void wma_set_dtim_period(tp_wma_handle wma,
770 struct set_dtim_params *dtim_params)
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -0700771{
772 QDF_STATUS ret;
773 uint8_t vdev_id = dtim_params->session_id;
774 struct wma_txrx_node *iface =
775 &wma->interfaces[vdev_id];
776
777 WMA_LOGI("%s: set dtim_period %d", __func__,
778 dtim_params->dtim_period);
779 iface->dtimPeriod = dtim_params->dtim_period;
780 ret = wma_vdev_set_param(wma->wmi_handle,
781 vdev_id,
782 WMI_VDEV_PARAM_LISTEN_INTERVAL,
783 dtim_params->dtim_period);
784 if (QDF_IS_STATUS_ERROR(ret))
785 WMA_LOGW("Failed to set listen interval");
786
787}
788/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789 * wma_set_modulated_dtim() - function to configure modulated dtim
790 * @wma: wma handle
791 * @privcmd: structure containing parameters
792 *
793 * This function configures the modulated dtim in firmware
794 *
795 * Return: none
796 */
797static void wma_set_modulated_dtim(tp_wma_handle wma,
798 wma_cli_set_cmd_t *privcmd)
799{
800 uint8_t vdev_id = privcmd->param_vdev_id;
801 struct wma_txrx_node *iface =
802 &wma->interfaces[vdev_id];
803 bool prev_dtim_enabled;
804 uint32_t listen_interval;
Govind Singhd76a5b02016-03-08 15:12:14 +0530805 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806
807 iface->alt_modulated_dtim = privcmd->param_value;
808
809 prev_dtim_enabled = iface->alt_modulated_dtim_enabled;
810
811 if (1 != privcmd->param_value)
812 iface->alt_modulated_dtim_enabled = true;
813 else
814 iface->alt_modulated_dtim_enabled = false;
815
816 if ((true == iface->alt_modulated_dtim_enabled) ||
817 (true == prev_dtim_enabled)) {
818
819 listen_interval = iface->alt_modulated_dtim
820 * iface->dtimPeriod;
821
Govind Singhd76a5b02016-03-08 15:12:14 +0530822 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 privcmd->param_vdev_id,
824 WMI_VDEV_PARAM_LISTEN_INTERVAL,
825 listen_interval);
Govind Singhd76a5b02016-03-08 15:12:14 +0530826 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 /* Even if it fails, continue */
828 WMA_LOGW("Failed to set listen interval %d",
829 listen_interval);
830
Govind Singhd76a5b02016-03-08 15:12:14 +0530831 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832 privcmd->param_vdev_id,
833 WMI_VDEV_PARAM_DTIM_POLICY ,
834 NORMAL_DTIM);
Govind Singhd76a5b02016-03-08 15:12:14 +0530835 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 WMA_LOGE("Failed to Set to Normal DTIM policy");
837 }
838}
839
840
841/**
842 * wma_process_cli_set_cmd() - set parameters to fw
843 * @wma: wma handle
844 * @privcmd: command
845 *
846 * Return: none
847 */
848static void wma_process_cli_set_cmd(tp_wma_handle wma,
849 wma_cli_set_cmd_t *privcmd)
850{
Govind Singhd76a5b02016-03-08 15:12:14 +0530851 int vid = privcmd->param_vdev_id, pps_val = 0;
852 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 struct wma_txrx_node *intr = wma->interfaces;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530854 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855 struct qpower_params *qparams = &intr[vid].config.qpower_params;
Govind Singhd76a5b02016-03-08 15:12:14 +0530856 struct pdev_params pdev_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857
858 WMA_LOGD("wmihandle %p", wma->wmi_handle);
859
860 if (NULL == pMac) {
861 WMA_LOGE("%s: Failed to get pMac", __func__);
862 return;
863 }
864
865 if (privcmd->param_id >= WMI_CMDID_MAX) {
866 /*
867 * This configuration setting is not done using any wmi
868 * command, call appropriate handler.
869 */
870 if (wma_set_priv_cfg(wma, privcmd))
871 WMA_LOGE("Failed to set wma priv congiuration");
872 return;
873 }
874
875 switch (privcmd->param_vp_dev) {
876 case VDEV_CMD:
Bhargav Shaha89d3b42016-04-20 13:04:56 +0530877 if (!wma->interfaces[privcmd->param_vdev_id].is_vdev_valid) {
878 WMA_LOGE("%s Vdev id is not valid", __func__);
879 return ;
880 }
881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
883 privcmd->param_id, privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530884 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 privcmd->param_vdev_id,
886 privcmd->param_id,
887 privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530888 if (QDF_IS_STATUS_ERROR(ret)) {
889 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 ret);
891 return;
892 }
893 break;
894 case PDEV_CMD:
895 WMA_LOGD("pdev pid %d pval %d", privcmd->param_id,
896 privcmd->param_value);
897 if ((privcmd->param_id == WMI_PDEV_PARAM_RX_CHAIN_MASK) ||
898 (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK)) {
899 wma_update_txrx_chainmask(wma->num_rf_chains,
900 &privcmd->param_value);
901 }
Govind Singhd76a5b02016-03-08 15:12:14 +0530902 pdev_param.param_id = privcmd->param_id;
903 pdev_param.param_value = privcmd->param_value;
904 ret = wmi_unified_pdev_param_send(wma->wmi_handle,
905 &pdev_param,
906 WMA_WILDCARD_PDEV_ID);
907 if (QDF_IS_STATUS_ERROR(ret)) {
908 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 ret);
910 return;
911 }
912 break;
913 case GEN_CMD:
914 {
915 ol_txrx_vdev_handle vdev = NULL;
916 struct wma_txrx_node *intr = wma->interfaces;
917
918 vdev = wma_find_vdev_by_id(wma, privcmd->param_vdev_id);
919 if (!vdev) {
920 WMA_LOGE("%s:Invalid vdev handle", __func__);
921 return;
922 }
923
924 WMA_LOGD("gen pid %d pval %d", privcmd->param_id,
925 privcmd->param_value);
926
927 switch (privcmd->param_id) {
928 case GEN_VDEV_PARAM_AMPDU:
929 ret = ol_txrx_aggr_cfg(vdev, privcmd->param_value, 0);
930 if (ret)
931 WMA_LOGE("ol_txrx_aggr_cfg set ampdu failed ret %d",
932 ret);
933 else
934 intr[privcmd->param_vdev_id].config.ampdu =
935 privcmd->param_value;
936 break;
937 case GEN_VDEV_PARAM_AMSDU:
938 ret = ol_txrx_aggr_cfg(vdev, 0, privcmd->param_value);
939 if (ret)
940 WMA_LOGE("ol_txrx_aggr_cfg set amsdu failed ret %d",
941 ret);
942 else
943 intr[privcmd->param_vdev_id].config.
944 amsdu = privcmd->param_value;
945 break;
946 case GEN_PARAM_DUMP_AGC_START:
947 htc_dump(wma->htc_handle, AGC_DUMP, true);
948 break;
949 case GEN_PARAM_DUMP_AGC:
950 htc_dump(wma->htc_handle, AGC_DUMP, false);
951 break;
952 case GEN_PARAM_DUMP_CHANINFO_START:
953 htc_dump(wma->htc_handle, CHAN_DUMP, true);
954 break;
955 case GEN_PARAM_DUMP_CHANINFO:
956 htc_dump(wma->htc_handle, CHAN_DUMP, false);
957 break;
958 case GEN_PARAM_DUMP_WATCHDOG:
959 htc_dump(wma->htc_handle, WD_DUMP, false);
960 break;
961 case GEN_PARAM_CRASH_INJECT:
Rajeev Kumar0a9901b2015-12-15 15:59:19 -0800962 if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
963 WMA_LOGE("Crash inject not allowed in FTM mode");
964 else
965 ret = wma_crash_inject(wma,
966 privcmd->param_value,
967 privcmd->param_sec_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700969 case GEN_PARAM_CAPTURE_TSF:
970 ret = wma_capture_tsf(wma, privcmd->param_value);
971 break;
972 case GEN_PARAM_RESET_TSF_GPIO:
973 ret = wma_reset_tsf_gpio(wma, privcmd->param_value);
974 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
976 case GEN_PARAM_DUMP_PCIE_ACCESS_LOG:
977 htc_dump(wma->htc_handle, PCIE_DUMP, false);
978 break;
979#endif /* CONFIG_ATH_PCIE_ACCESS_DEBUG */
980 case GEN_PARAM_MODULATED_DTIM:
981 wma_set_modulated_dtim(wma, privcmd);
982 break;
983 default:
984 WMA_LOGE("Invalid param id 0x%x",
985 privcmd->param_id);
986 break;
987 }
988 break;
989 }
990 case DBG_CMD:
991 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
992 privcmd->param_value);
993 switch (privcmd->param_id) {
994 case WMI_DBGLOG_LOG_LEVEL:
995 ret = dbglog_set_log_lvl(wma->wmi_handle,
996 privcmd->param_value);
997 if (ret)
998 WMA_LOGE("dbglog_set_log_lvl failed ret %d",
999 ret);
1000 break;
1001 case WMI_DBGLOG_VAP_ENABLE:
1002 ret = dbglog_vap_log_enable(wma->wmi_handle,
1003 privcmd->param_value, true);
1004 if (ret)
1005 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1006 ret);
1007 break;
1008 case WMI_DBGLOG_VAP_DISABLE:
1009 ret = dbglog_vap_log_enable(wma->wmi_handle,
1010 privcmd->param_value, false);
1011 if (ret)
1012 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1013 ret);
1014 break;
1015 case WMI_DBGLOG_MODULE_ENABLE:
1016 ret = dbglog_module_log_enable(wma->wmi_handle,
1017 privcmd->param_value, true);
1018 if (ret)
1019 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1020 ret);
1021 break;
1022 case WMI_DBGLOG_MODULE_DISABLE:
1023 ret = dbglog_module_log_enable(wma->wmi_handle,
1024 privcmd->param_value, false);
1025 if (ret)
1026 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1027 ret);
1028 break;
1029 case WMI_DBGLOG_MOD_LOG_LEVEL:
1030 ret = dbglog_set_mod_log_lvl(wma->wmi_handle,
1031 privcmd->param_value);
1032 if (ret)
1033 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1034 ret);
1035 break;
1036 case WMI_DBGLOG_TYPE:
1037 ret = dbglog_parser_type_init(wma->wmi_handle,
1038 privcmd->param_value);
1039 if (ret)
1040 WMA_LOGE("dbglog_parser_type_init failed ret %d",
1041 ret);
1042 break;
1043 case WMI_DBGLOG_REPORT_ENABLE:
1044 ret = dbglog_report_enable(wma->wmi_handle,
1045 privcmd->param_value);
1046 if (ret)
1047 WMA_LOGE("dbglog_report_enable failed ret %d",
1048 ret);
1049 break;
Govind Singha471e5e2015-10-12 17:11:14 +05301050 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301051 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301052 WMI_WLAN_PROFILE_TRIGGER_CMDID,
1053 privcmd->param_value, 0);
1054 if (ret)
1055 WMA_LOGE("Profile cmd failed for %d ret %d",
1056 WMI_WLAN_PROFILE_TRIGGER_CMDID, ret);
1057 break;
1058 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301059 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301060 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1061 privcmd->param_value,
1062 privcmd->param_sec_value);
1063 if (ret)
1064 WMA_LOGE("Profile cmd failed for %d ret %d",
1065 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1066 ret);
1067 break;
1068 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301069 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301070 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1071 privcmd->param_value,
1072 privcmd->param_sec_value);
1073 if (ret)
1074 WMA_LOGE("Profile cmd failed for %d ret %d",
1075 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1076 ret);
1077 break;
1078 case WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301079 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301080 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1081 0, 0);
1082 if (ret)
1083 WMA_LOGE("Profile cmd failed for %d ret %d",
1084 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1085 ret);
1086 break;
1087 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301088 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301089 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1090 0, 0);
1091 if (ret)
1092 WMA_LOGE("Profile cmd failed for %d ret %d",
1093 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1094 ret);
1095 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 case WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID:
1097 /* Set the Green AP */
Govind Singhd76a5b02016-03-08 15:12:14 +05301098 ret = wmi_unified_green_ap_ps_send
1099 (wma->wmi_handle, privcmd->param_value,
1100 WMA_WILDCARD_PDEV_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 if (ret) {
1102 WMA_LOGE("Set GreenAP Failed val %d",
1103 privcmd->param_value);
1104 }
1105 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106
1107 default:
1108 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1109 break;
1110 }
1111 break;
1112 case PPS_CMD:
1113 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1114 privcmd->param_value);
1115 switch (privcmd->param_id) {
1116
1117 case WMI_VDEV_PPS_PAID_MATCH:
1118 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1119 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
1120 intr[vid].config.pps_params.paid_match_enable =
1121 privcmd->param_value;
1122 break;
1123 case WMI_VDEV_PPS_GID_MATCH:
1124 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1125 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
1126 intr[vid].config.pps_params.gid_match_enable =
1127 privcmd->param_value;
1128 break;
1129 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
1130 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1131 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
1132 intr[vid].config.pps_params.tim_clear =
1133 privcmd->param_value;
1134 break;
1135 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
1136 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1137 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
1138 intr[vid].config.pps_params.dtim_clear =
1139 privcmd->param_value;
1140 break;
1141 case WMI_VDEV_PPS_EOF_PAD_DELIM:
1142 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1143 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
1144 intr[vid].config.pps_params.eof_delim =
1145 privcmd->param_value;
1146 break;
1147 case WMI_VDEV_PPS_MACADDR_MISMATCH:
1148 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1149 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
1150 intr[vid].config.pps_params.mac_match =
1151 privcmd->param_value;
1152 break;
1153 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
1154 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1155 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
1156 intr[vid].config.pps_params.delim_fail =
1157 privcmd->param_value;
1158 break;
1159 case WMI_VDEV_PPS_GID_NSTS_ZERO:
1160 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1161 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
1162 intr[vid].config.pps_params.nsts_zero =
1163 privcmd->param_value;
1164 break;
1165 case WMI_VDEV_PPS_RSSI_CHECK:
1166 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1167 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
1168 intr[vid].config.pps_params.rssi_chk =
1169 privcmd->param_value;
1170 break;
1171 case WMI_VDEV_PPS_5G_EBT:
1172 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1173 (PKT_PWR_SAVE_5G_EBT & 0xffff);
1174 intr[vid].config.pps_params.ebt_5g =
1175 privcmd->param_value;
1176 break;
1177 default:
1178 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1179 break;
1180 }
1181 break;
1182
1183 case QPOWER_CMD:
1184 WMA_LOGD("QPOWER CLI CMD pid %d pval %d", privcmd->param_id,
1185 privcmd->param_value);
1186 switch (privcmd->param_id) {
1187 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
1188 WMA_LOGD("QPOWER CLI CMD:Ps Poll Cnt val %d",
1189 privcmd->param_value);
1190 /* Set the QPower Ps Poll Count */
Govind Singhd76a5b02016-03-08 15:12:14 +05301191 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 vid, WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
1193 privcmd->param_value);
1194 if (ret) {
1195 WMA_LOGE("Set Q-PsPollCnt Failed vdevId %d val %d",
1196 vid, privcmd->param_value);
1197 } else {
1198 qparams->max_ps_poll_cnt = privcmd->param_value;
1199 }
1200 break;
1201 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
1202 WMA_LOGD("QPOWER CLI CMD:Max Tx Before wake val %d",
1203 privcmd->param_value);
1204 /* Set the QPower Max Tx Before Wake */
Govind Singhd76a5b02016-03-08 15:12:14 +05301205 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206 vid, WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
1207 privcmd->param_value);
1208 if (ret) {
1209 WMA_LOGE("Set Q-MaxTxBefWake Failed vId %d val %d",
1210 vid, privcmd->param_value);
1211 } else {
1212 qparams->max_tx_before_wake =
1213 privcmd->param_value;
1214 }
1215 break;
1216 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
1217 WMA_LOGD("QPOWER CLI CMD:Ps Poll Wake Inv val %d",
1218 privcmd->param_value);
1219 /* Set the QPower Spec Ps Poll Wake Inv */
Govind Singhd76a5b02016-03-08 15:12:14 +05301220 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 vid, WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
1222 privcmd->param_value);
1223 if (ret) {
1224 WMA_LOGE("Set Q-PsPoll WakeIntv Failed vId %d val %d",
1225 vid, privcmd->param_value);
1226 } else {
1227 qparams->spec_ps_poll_wake_interval =
1228 privcmd->param_value;
1229 }
1230 break;
1231 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
1232 WMA_LOGD("QPOWER CLI CMD:Spec NoData Ps Poll val %d",
1233 privcmd->param_value);
1234 /* Set the QPower Spec NoData PsPoll */
Govind Singhd76a5b02016-03-08 15:12:14 +05301235 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 vid, WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
1237 privcmd->param_value);
1238 if (ret) {
1239 WMA_LOGE("Set Q-SpecNoDataPsPoll Failed vId %d val %d",
1240 vid, privcmd->param_value);
1241 } else {
1242 qparams->max_spec_nodata_ps_poll =
1243 privcmd->param_value;
1244 }
1245 break;
1246
1247 default:
1248 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1249 break;
1250 }
1251 break;
1252 case GTX_CMD:
1253 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1254 privcmd->param_id, privcmd->param_value);
1255 switch (privcmd->param_id) {
1256 case WMI_VDEV_PARAM_GTX_HT_MCS:
1257 intr[vid].config.gtx_info.gtxRTMask[0] =
1258 privcmd->param_value;
1259 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1260 privcmd->param_vdev_id,
1261 &intr[vid].config.gtx_info);
1262 break;
1263 case WMI_VDEV_PARAM_GTX_VHT_MCS:
1264 intr[vid].config.gtx_info.gtxRTMask[1] =
1265 privcmd->param_value;
1266 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1267 privcmd->param_vdev_id,
1268 &intr[vid].config.gtx_info);
1269 break;
1270
1271 case WMI_VDEV_PARAM_GTX_USR_CFG:
1272 intr[vid].config.gtx_info.gtxUsrcfg =
1273 privcmd->param_value;
1274 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1275 privcmd->param_vdev_id,
1276 &intr[vid].config.gtx_info);
1277 break;
1278
1279 case WMI_VDEV_PARAM_GTX_THRE:
1280 intr[vid].config.gtx_info.gtxPERThreshold =
1281 privcmd->param_value;
1282 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1283 privcmd->param_vdev_id,
1284 &intr[vid].config.gtx_info);
1285 break;
1286
1287 case WMI_VDEV_PARAM_GTX_MARGIN:
1288 intr[vid].config.gtx_info.gtxPERMargin =
1289 privcmd->param_value;
1290 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1291 privcmd->param_vdev_id,
1292 &intr[vid].config.gtx_info);
1293 break;
1294
1295 case WMI_VDEV_PARAM_GTX_STEP:
1296 intr[vid].config.gtx_info.gtxTPCstep =
1297 privcmd->param_value;
1298 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1299 privcmd->param_vdev_id,
1300 &intr[vid].config.gtx_info);
1301 break;
1302
1303 case WMI_VDEV_PARAM_GTX_MINTPC:
1304 intr[vid].config.gtx_info.gtxTPCMin =
1305 privcmd->param_value;
1306 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1307 privcmd->param_vdev_id,
1308 &intr[vid].config.gtx_info);
1309 break;
1310
1311 case WMI_VDEV_PARAM_GTX_BW_MASK:
1312 intr[vid].config.gtx_info.gtxBWMask =
1313 privcmd->param_value;
1314 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1315 privcmd->param_vdev_id,
1316 &intr[vid].config.gtx_info);
1317 if (ret) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301318 WMA_LOGE("wma_vdev_set_param"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319 " failed ret %d", ret);
1320 return;
1321 }
1322 break;
1323 default:
1324 break;
1325 }
1326 break;
1327
1328 default:
1329 WMA_LOGE("Invalid vpdev command id");
1330 }
1331 if (1 == privcmd->param_vp_dev) {
1332 switch (privcmd->param_id) {
1333 case WMI_VDEV_PARAM_NSS:
1334 intr[vid].config.nss = privcmd->param_value;
1335 break;
1336 case WMI_VDEV_PARAM_LDPC:
1337 intr[vid].config.ldpc = privcmd->param_value;
1338 break;
1339 case WMI_VDEV_PARAM_TX_STBC:
1340 intr[vid].config.tx_stbc = privcmd->param_value;
1341 break;
1342 case WMI_VDEV_PARAM_RX_STBC:
1343 intr[vid].config.rx_stbc = privcmd->param_value;
1344 break;
1345 case WMI_VDEV_PARAM_SGI:
1346 intr[vid].config.shortgi = privcmd->param_value;
1347 break;
1348 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
1349 intr[vid].config.rtscts_en = privcmd->param_value;
1350 break;
1351 case WMI_VDEV_PARAM_CHWIDTH:
1352 intr[vid].config.chwidth = privcmd->param_value;
1353 break;
1354 case WMI_VDEV_PARAM_FIXED_RATE:
1355 intr[vid].config.tx_rate = privcmd->param_value;
1356 break;
1357 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE:
1358 intr[vid].config.erx_adjust = privcmd->param_value;
1359 break;
1360 case WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM:
1361 intr[vid].config.erx_bmiss_num = privcmd->param_value;
1362 break;
1363 case WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE:
1364 intr[vid].config.erx_bmiss_cycle = privcmd->param_value;
1365 break;
1366 case WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP:
1367 intr[vid].config.erx_slop_step = privcmd->param_value;
1368 break;
1369 case WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP:
1370 intr[vid].config.erx_init_slop = privcmd->param_value;
1371 break;
1372 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE:
1373 intr[vid].config.erx_adj_pause = privcmd->param_value;
1374 break;
1375 case WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE:
1376 intr[vid].config.erx_dri_sample = privcmd->param_value;
1377 break;
1378 default:
1379 WMA_LOGE("Invalid wma_cli_set vdev command/Not"
1380 " yet implemented 0x%x", privcmd->param_id);
1381 break;
1382 }
1383 } else if (2 == privcmd->param_vp_dev) {
1384 switch (privcmd->param_id) {
1385 case WMI_PDEV_PARAM_ANI_ENABLE:
1386 wma->pdevconfig.ani_enable = privcmd->param_value;
1387 break;
1388 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
1389 wma->pdevconfig.ani_poll_len = privcmd->param_value;
1390 break;
1391 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
1392 wma->pdevconfig.ani_listen_len = privcmd->param_value;
1393 break;
1394 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
1395 wma->pdevconfig.ani_ofdm_level = privcmd->param_value;
1396 break;
1397 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
1398 wma->pdevconfig.ani_cck_level = privcmd->param_value;
1399 break;
1400 case WMI_PDEV_PARAM_DYNAMIC_BW:
1401 wma->pdevconfig.cwmenable = privcmd->param_value;
1402 break;
1403 case WMI_PDEV_PARAM_CTS_CBW:
1404 wma->pdevconfig.cts_cbw = privcmd->param_value;
1405 break;
1406 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
1407 wma->pdevconfig.txchainmask = privcmd->param_value;
1408 break;
1409 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
1410 wma->pdevconfig.rxchainmask = privcmd->param_value;
1411 break;
1412 case WMI_PDEV_PARAM_BURST_ENABLE:
1413 wma->pdevconfig.burst_enable = privcmd->param_value;
1414 if ((wma->pdevconfig.burst_enable == 1) &&
1415 (wma->pdevconfig.burst_dur == 0))
1416 wma->pdevconfig.burst_dur =
1417 WMA_DEFAULT_SIFS_BURST_DURATION;
1418 else if (wma->pdevconfig.burst_enable == 0)
1419 wma->pdevconfig.burst_dur = 0;
1420 break;
1421 case WMI_PDEV_PARAM_BURST_DUR:
1422 wma->pdevconfig.burst_dur = privcmd->param_value;
1423 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
1425 wma->pdevconfig.txpow2g = privcmd->param_value;
1426 if ((pMac->roam.configParam.bandCapability ==
1427 eCSR_BAND_ALL) ||
1428 (pMac->roam.configParam.bandCapability ==
1429 eCSR_BAND_24)) {
1430 if (cfg_set_int(pMac,
1431 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1432 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301433 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1435
1436 } else {
1437 WMA_LOGE("Current band is not 2G");
1438 }
1439 break;
1440 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
1441 wma->pdevconfig.txpow5g = privcmd->param_value;
1442 if ((pMac->roam.configParam.bandCapability ==
1443 eCSR_BAND_ALL) ||
1444 (pMac->roam.configParam.bandCapability ==
1445 eCSR_BAND_5G)) {
1446 if (cfg_set_int(pMac,
1447 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1448 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301449 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1451
1452 } else {
1453 WMA_LOGE("Current band is not 5G");
1454 }
1455 break;
1456 default:
1457 WMA_LOGE("Invalid wma_cli_set pdev command/Not yet implemented 0x%x",
1458 privcmd->param_id);
1459 break;
1460 }
1461 } else if (5 == privcmd->param_vp_dev) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301462 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 privcmd->param_vdev_id,
1464 WMI_VDEV_PARAM_PACKET_POWERSAVE,
1465 pps_val);
1466 if (ret)
1467 WMA_LOGE("Failed to send wmi packet power save cmd");
1468 else
1469 WMA_LOGD("Sent packet power save cmd %d value %x to target",
1470 privcmd->param_id, pps_val);
1471 }
1472}
1473
1474/**
1475 * wma_process_fw_event() - process any fw event
1476 * @wma: wma handle
1477 * @buf: fw event buffer
1478 *
1479 * This function process any fw event to serialize it through mc thread.
1480 *
1481 * Return: none
1482 */
1483static int wma_process_fw_event(tp_wma_handle wma,
1484 wma_process_fw_event_params *buf)
1485{
1486 struct wmi_unified *wmi_handle = (struct wmi_unified *)buf->wmi_handle;
1487
1488 wmi_process_fw_event(wmi_handle, buf->evt_buf);
1489 return 0;
1490}
1491
1492/**
Govind Singhd76a5b02016-03-08 15:12:14 +05301493 * wmi_process_fw_event_tasklet_ctx() - process in tasklet context
1494 * @ctx: handle to wmi
1495 * @ev: wmi event buffer
1496 *
1497 * Event process by below function will be in tasket context,
1498 * need to use this method only for time sensitive functions.
1499 *
1500 * Return: none
1501 */
1502static int wma_process_fw_event_tasklet_ctx(void *ctx, void *ev)
1503{
1504 wmi_process_fw_event(ctx, ev);
1505
1506 return 0;
1507}
1508
1509/**
Manjeet Singhf82ed072016-07-08 11:40:00 +05301510 * wma_process_hal_pwr_dbg_cmd() - send hal pwr dbg cmd to fw.
1511 * @handle: wma handle
1512 * @sir_pwr_dbg_params: unit test command
1513 *
1514 * This function send unit test command to fw.
1515 *
1516 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
1517 */
1518QDF_STATUS wma_process_hal_pwr_dbg_cmd(WMA_HANDLE handle,
1519 struct sir_mac_pwr_dbg_cmd *
1520 sir_pwr_dbg_params)
1521{
1522 tp_wma_handle wma_handle = (tp_wma_handle)handle;
1523 int i;
1524 struct wmi_power_dbg_params wmi_pwr_dbg_params;
1525 QDF_STATUS status;
1526
1527 if (!sir_pwr_dbg_params) {
1528 WMA_LOGE("%s: sir_pwr_dbg_params is null", __func__);
1529 return QDF_STATUS_E_INVAL;
1530 }
1531 wmi_pwr_dbg_params.module_id = sir_pwr_dbg_params->module_id;
1532 wmi_pwr_dbg_params.pdev_id = sir_pwr_dbg_params->pdev_id;
1533 wmi_pwr_dbg_params.num_args = sir_pwr_dbg_params->num_args;
1534
1535 for (i = 0; i < wmi_pwr_dbg_params.num_args; i++)
1536 wmi_pwr_dbg_params.args[i] = sir_pwr_dbg_params->args[i];
1537
1538 status = wmi_unified_send_power_dbg_cmd(wma_handle->wmi_handle,
1539 &wmi_pwr_dbg_params);
1540
1541 return status;
1542}
1543
1544/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 * wma_process_fw_event_handler() - common event handler to serialize
1546 * event processing through mc_thread
Govind Singhd76a5b02016-03-08 15:12:14 +05301547 * @ctx: wmi context
1548 * @ev: event buffer
1549 * @rx_ctx: rx execution context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 *
1551 * Return: 0 on success, errno on failure
1552 */
Govind Singhd76a5b02016-03-08 15:12:14 +05301553static int wma_process_fw_event_mc_thread_ctx(void *ctx, void *ev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554{
1555 wma_process_fw_event_params *params_buf;
1556 cds_msg_t cds_msg = { 0 };
1557
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301558 params_buf = qdf_mem_malloc(sizeof(wma_process_fw_event_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 if (!params_buf) {
1560 WMA_LOGE("%s: Failed alloc memory for params_buf", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301561 qdf_nbuf_free(ev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 return -ENOMEM;
1563 }
1564
Govind Singhd76a5b02016-03-08 15:12:14 +05301565 params_buf->wmi_handle = (struct wmi_unified *)ctx;
1566 params_buf->evt_buf = (wmi_buf_t *)ev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567
1568 cds_msg.type = WMA_PROCESS_FW_EVENT;
1569 cds_msg.bodyptr = params_buf;
1570 cds_msg.bodyval = 0;
1571
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301572 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 cds_mq_post_message(CDS_MQ_ID_WMA, &cds_msg)) {
1574 WMA_LOGP("%s: Failed to post WMA_PROCESS_FW_EVENT msg",
1575 __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301576 qdf_nbuf_free(ev);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301577 qdf_mem_free(params_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 return -EFAULT;
1579 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 return 0;
1581
1582}
1583
Govind Singhd76a5b02016-03-08 15:12:14 +05301584/**
1585 * wma_process_fw_event_handler() - common event handler to serialize
1586 * event processing through mc_thread
1587 * @ctx: wmi context
1588 * @ev: event buffer
1589 * @rx_ctx: rx execution context
1590 *
1591 * Return: 0 on success, errno on failure
1592 */
1593int wma_process_fw_event_handler(void *ctx, void *ev, uint8_t rx_ctx)
1594{
1595 int err = 0;
1596
1597 if (rx_ctx == WMA_RX_SERIALIZER_CTX) {
1598 err = wma_process_fw_event_mc_thread_ctx(ctx, ev);
1599 } else if (rx_ctx == WMA_RX_TASKLET_CTX) {
1600 wma_process_fw_event_tasklet_ctx(ctx, ev);
1601 } else {
1602 WMA_LOGE("%s: invalid wmi event execution context", __func__);
1603 qdf_nbuf_free(ev);
1604 }
1605
1606 return err;
1607}
1608
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609#ifdef QCA_LL_TX_FLOW_CONTROL_V2
1610/**
1611 * ol_cfg_set_flow_control_parameters() - set flow control parameters
1612 * @olCfg: cfg parameters
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301613 * @cds_cfg: CDS Configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 *
1615 * Return: none
1616 */
1617static
1618void ol_cfg_set_flow_control_parameters(struct txrx_pdev_cfg_param_t *olCfg,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301619 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620{
1621 olCfg->tx_flow_start_queue_offset =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301622 cds_cfg->tx_flow_start_queue_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 olCfg->tx_flow_stop_queue_th =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301624 cds_cfg->tx_flow_stop_queue_th;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625}
1626#else
1627static
1628void ol_cfg_set_flow_control_parameters(struct txrx_pdev_cfg_param_t *olCfg,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301629 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630{
1631 return;
1632}
1633#endif
1634
1635#ifdef WLAN_FEATURE_NAN
1636/**
1637 * wma_set_nan_enable() - set nan enable flag in WMA handle
1638 * @wma_handle: Pointer to wma handle
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301639 * @cds_cfg: Pointer to CDS Configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 *
1641 * Return: none
1642 */
1643static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301644 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645{
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301646 wma_handle->is_nan_enabled = cds_cfg->is_nan_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647}
1648#else
1649static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301650 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651{
1652}
1653#endif
1654
1655/**
Komal Seelam02d09342016-02-23 18:03:19 +05301656 * wma_init_max_no_of_peers - API to initialize wma configuration params
1657 * @wma_handle: WMA Handle
1658 * @max_peers: Max Peers supported
1659 *
1660 * Return: void
1661 */
1662static void wma_init_max_no_of_peers(tp_wma_handle wma_handle,
1663 uint16_t max_peers)
1664{
1665 struct wma_ini_config *cfg = wma_get_ini_handle(wma_handle);
1666
Naveen Rawat35804772016-06-27 15:40:28 -07001667 if (cfg == NULL) {
1668 WMA_LOGE("%s: NULL WMA ini handle", __func__);
1669 return;
1670 }
1671
Komal Seelam02d09342016-02-23 18:03:19 +05301672 cfg->max_no_of_peers = max_peers;
1673}
1674
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001675/**
1676 * wma_shutdown_notifier_cb - Shutdown notifer call back
1677 * @priv : WMA handle
1678 *
1679 * During recovery, WMA may wait for resume to complete if the crash happens
1680 * while in suspend. This may cause delays in completing the recovery. This call
1681 * back would be called during recovery and the event is completed so that if
1682 * the resume is waiting on FW to respond then it can get out of the wait so
1683 * that recovery thread can start bringing down all the modules.
1684 *
1685 * Return: None
1686 */
1687static void wma_shutdown_notifier_cb(void *priv)
1688{
1689 tp_wma_handle wma_handle = priv;
1690
1691 qdf_event_set(&wma_handle->wma_resume_event);
1692}
1693
Mukul Sharma5ff3c582016-09-12 15:23:35 +05301694struct wma_version_info g_wmi_version_info;
1695
Komal Seelam02d09342016-02-23 18:03:19 +05301696/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301697 * wma_state_info_dump() - prints state information of wma layer
1698 * @buf: buffer pointer
1699 * @size: size of buffer to be filled
1700 *
1701 * This function is used to dump state information of wma layer
1702 *
1703 * Return: None
1704 */
1705static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
1706{
1707 tp_wma_handle wma_handle;
1708 uint16_t len = 0;
1709 char *buf = *buf_ptr;
1710 struct wma_txrx_node *iface;
1711 uint8_t vdev_id;
1712
1713 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
1714 if (!wma_handle) {
1715 WMA_LOGE("%s: WMA context is invald!", __func__);
1716 return;
1717 }
1718
1719 WMA_LOGI("%s: size of buffer: %d", __func__, *size);
1720
1721 len += qdf_scnprintf(buf + len, *size - len,
1722 "\n wow_pno_match_wake_up_count %d",
1723 wma_handle->wow_pno_match_wake_up_count);
1724 len += qdf_scnprintf(buf + len, *size - len,
1725 "\n wow_pno_complete_wake_up_count %d",
1726 wma_handle->wow_pno_complete_wake_up_count);
1727 len += qdf_scnprintf(buf + len, *size - len,
1728 "\n wow_gscan_wake_up_count %d",
1729 wma_handle->wow_gscan_wake_up_count);
1730 len += qdf_scnprintf(buf + len, *size - len,
1731 "\n wow_low_rssi_wake_up_count %d",
1732 wma_handle->wow_low_rssi_wake_up_count);
1733 len += qdf_scnprintf(buf + len, *size - len,
1734 "\n wow_rssi_breach_wake_up_count %d",
1735 wma_handle->wow_rssi_breach_wake_up_count);
1736 len += qdf_scnprintf(buf + len, *size - len,
1737 "\n wow_ucast_wake_up_count %d",
1738 wma_handle->wow_ucast_wake_up_count);
1739 len += qdf_scnprintf(buf + len, *size - len,
1740 "\n wow_bcast_wake_up_count %d",
1741 wma_handle->wow_bcast_wake_up_count);
1742 len += qdf_scnprintf(buf + len, *size - len,
1743 "\n wow_ipv4_mcast_wake_up_count %d",
1744 wma_handle->wow_ipv4_mcast_wake_up_count);
1745 len += qdf_scnprintf(buf + len, *size - len,
1746 "\n wow_ipv6_mcast_ra_stats %d",
1747 wma_handle->wow_ipv6_mcast_ra_stats);
1748 len += qdf_scnprintf(buf + len, *size - len,
1749 "\n wow_ipv6_mcast_ns_stats %d",
1750 wma_handle->wow_ipv6_mcast_ns_stats);
1751 len += qdf_scnprintf(buf + len, *size - len,
1752 "\n wow_ipv6_mcast_na_stats %d",
1753 wma_handle->wow_ipv6_mcast_na_stats);
1754
1755 for (vdev_id = 0; vdev_id < wma_handle->max_bssid; vdev_id++) {
1756 if (!wma_handle->interfaces[vdev_id].handle)
1757 continue;
1758
1759 iface = &wma_handle->interfaces[vdev_id];
1760
1761 len += qdf_scnprintf(buf + len, *size - len,
1762 "\n vdev_id %d",
1763 vdev_id);
1764 len += qdf_scnprintf(buf + len, *size - len,
1765 "\n conn_state %d",
1766 iface->conn_state);
1767 len += qdf_scnprintf(buf + len, *size - len,
1768 "\n dtimPeriod %d",
1769 iface->dtimPeriod);
1770 len += qdf_scnprintf(buf + len, *size - len,
1771 "\n chanmode %d",
1772 iface->chanmode);
1773 len += qdf_scnprintf(buf + len, *size - len,
1774 "\n vht_capable %d",
1775 iface->vht_capable);
1776 len += qdf_scnprintf(buf + len, *size - len,
1777 "\n ht_capable %d",
1778 iface->ht_capable);
1779 len += qdf_scnprintf(buf + len, *size - len,
1780 "\n chan_width %d",
1781 iface->chan_width);
1782 len += qdf_scnprintf(buf + len, *size - len,
1783 "\n vdev_active %d",
1784 iface->vdev_active);
1785 len += qdf_scnprintf(buf + len, *size - len,
1786 "\n vdev_up %d",
1787 iface->vdev_up);
1788 len += qdf_scnprintf(buf + len, *size - len,
1789 "\n aid %d",
1790 iface->aid);
1791 len += qdf_scnprintf(buf + len, *size - len,
1792 "\n rate_flags %d",
1793 iface->rate_flags);
1794 len += qdf_scnprintf(buf + len, *size - len,
1795 "\n nss %d",
1796 iface->nss);
1797 len += qdf_scnprintf(buf + len, *size - len,
1798 "\n tx_power %d",
1799 iface->tx_power);
1800 len += qdf_scnprintf(buf + len, *size - len,
1801 "\n max_tx_power %d",
1802 iface->max_tx_power);
1803 len += qdf_scnprintf(buf + len, *size - len,
1804 "\n nwType %d",
1805 iface->nwType);
1806 len += qdf_scnprintf(buf + len, *size - len,
1807 "\n tx_streams %d",
1808 iface->tx_streams);
1809 len += qdf_scnprintf(buf + len, *size - len,
1810 "\n rx_streams %d",
1811 iface->rx_streams);
1812 len += qdf_scnprintf(buf + len, *size - len,
1813 "\n chain_mask %d",
1814 iface->chain_mask);
1815 len += qdf_scnprintf(buf + len, *size - len,
1816 "\n nss_2g %d",
1817 iface->nss_2g);
1818 len += qdf_scnprintf(buf + len, *size - len,
1819 "\n nss_5g %d",
1820 iface->nss_5g);
1821 }
1822
1823 *size -= len;
1824 *buf_ptr += len;
1825}
1826
1827/**
1828 * wma_register_debug_callback() - registration function for wma layer
1829 * to print wma state information
1830 */
1831static void wma_register_debug_callback(void)
1832{
1833 qdf_register_debug_callback(QDF_MODULE_ID_WMA, &wma_state_info_dump);
1834}
1835
1836/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 * wma_open() - Allocate wma context and initialize it.
1838 * @cds_context: cds context
1839 * @wma_tgt_cfg_cb: tgt config callback fun
1840 * @radar_ind_cb: dfs radar indication callback
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301841 * @cds_cfg: mac parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 *
1843 * Return: 0 on success, errno on failure
1844 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301845QDF_STATUS wma_open(void *cds_context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 wma_tgt_cfg_cb tgt_cfg_cb,
1847 wma_dfs_radar_indication_cb radar_ind_cb,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301848 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849{
1850 tp_wma_handle wma_handle;
1851 HTC_HANDLE htc_handle;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301852 qdf_device_t qdf_dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 void *wmi_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301854 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 struct txrx_pdev_cfg_param_t olCfg = { 0 };
Govind Singhd76a5b02016-03-08 15:12:14 +05301856 struct wmi_rx_ops ops;
1857
1858 bool use_cookie = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859
1860 WMA_LOGD("%s: Enter", __func__);
1861
Mukul Sharma5ff3c582016-09-12 15:23:35 +05301862 g_wmi_version_info.major = __WMI_VER_MAJOR_;
1863 g_wmi_version_info.minor = __WMI_VER_MINOR_;
1864 g_wmi_version_info.revision = __WMI_REVISION_;
1865
Anurag Chouhan6d760662016-02-20 16:05:43 +05301866 qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
1867 htc_handle = cds_get_context(QDF_MODULE_ID_HTC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868
1869 if (!htc_handle) {
1870 WMA_LOGP("%s: Invalid HTC handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301871 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 }
1873
1874 /* Alloc memory for WMA Context */
Anurag Chouhan6d760662016-02-20 16:05:43 +05301875 qdf_status = cds_alloc_context(cds_context, QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 (void **)&wma_handle,
1877 sizeof(t_wma_handle));
1878
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301879 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 WMA_LOGP("%s: Memory allocation failed for wma_handle",
1881 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301882 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 }
1884
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301885 qdf_mem_zero(wma_handle, sizeof(t_wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886
Anurag Chouhan6d760662016-02-20 16:05:43 +05301887 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888#ifdef FEATURE_WLAN_SCAN_PNO
Anurag Chouhana37b5b72016-02-21 14:53:42 +05301889 qdf_wake_lock_create(&wma_handle->pno_wake_lock, "wlan_pno_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890#endif /* FEATURE_WLAN_SCAN_PNO */
1891#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05301892 qdf_wake_lock_create(&wma_handle->extscan_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 "wlan_extscan_wl");
1894#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05301895 qdf_wake_lock_create(&wma_handle->wow_wake_lock, "wlan_wow_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 }
1897
Govind Singhd76a5b02016-03-08 15:12:14 +05301898 /* Attach mc_thread context processing function */
1899 ops.wma_process_fw_event_handler_cbk = wma_process_fw_event_handler;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 /* attach the wmi */
Govind Singhd76a5b02016-03-08 15:12:14 +05301901 wmi_handle = wmi_unified_attach(wma_handle, NULL,
1902 WMI_TLV_TARGET, use_cookie, &ops);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 if (!wmi_handle) {
1904 WMA_LOGP("%s: failed to attach WMI", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301905 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 goto err_wma_handle;
1907 }
1908
1909 WMA_LOGA("WMA --> wmi_unified_attach - success");
Govind Singhd76a5b02016-03-08 15:12:14 +05301910 wmi_unified_register_event_handler(wmi_handle,
1911 WMI_SERVICE_READY_EVENTID,
1912 wma_rx_service_ready_event,
1913 WMA_RX_SERIALIZER_CTX);
1914 wmi_unified_register_event_handler(wmi_handle,
1915 WMI_SERVICE_READY_EXT_EVENTID,
1916 wma_rx_service_ready_ext_event,
1917 WMA_RX_SERIALIZER_CTX);
1918 wmi_unified_register_event_handler(wmi_handle,
1919 WMI_READY_EVENTID,
1920 wma_rx_ready_event,
1921 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 /* Save the WMI & HTC handle */
1923 wma_handle->wmi_handle = wmi_handle;
1924 wma_handle->htc_handle = htc_handle;
1925 wma_handle->cds_context = cds_context;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301926 wma_handle->qdf_dev = qdf_dev;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301927 wma_handle->max_scan = cds_cfg->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928
Houston Hoffmanc45db892015-11-13 19:59:25 -08001929 wma_handle->wma_runtime_resume_lock =
1930 qdf_runtime_lock_init("wma_runtime_resume");
1931
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05301932 /* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301933 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05301934 /* Cap maxStation based on the target version */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301935 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05301936 /* Reinitialize max_no_of_peers based on the capped maxStation value */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301937 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05301938
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 /* initialize default target config */
1940 wma_set_default_tgt_config(wma_handle);
1941
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301942 olCfg.is_uc_offload_enabled = cds_cfg->uc_offload_enabled;
1943 olCfg.uc_tx_buffer_count = cds_cfg->uc_txbuf_count;
1944 olCfg.uc_tx_buffer_size = cds_cfg->uc_txbuf_size;
1945 olCfg.uc_rx_indication_ring_count = cds_cfg->uc_rxind_ringcount;
1946 olCfg.uc_tx_partition_base = cds_cfg->uc_tx_partition_base;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947
1948
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301949 wma_handle->tx_chain_mask_cck = cds_cfg->tx_chain_mask_cck;
1950 wma_handle->self_gen_frm_pwr = cds_cfg->self_gen_frm_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951
1952 /* Allocate cfg handle */
1953
1954 /* RX Full reorder should enable for PCIe, ROME3.X project only now
1955 * MDM should enable later, schedule TBD
1956 * HL also sdould be enabled, schedule TBD
1957 */
1958#ifdef WLAN_FEATURE_RX_FULL_REORDER_OL
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301959 olCfg.is_full_reorder_offload = cds_cfg->reorder_offload;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960#else
1961 olCfg.is_full_reorder_offload = 0;
1962#endif /* WLAN_FEATURE_RX_FULL_REORDER_OL */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301963 olCfg.enable_rxthread = cds_cfg->enable_rxthread;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 olCfg.ip_tcp_udp_checksum_offload =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301965 cds_cfg->ip_tcp_udp_checksum_offload;
1966 olCfg.ce_classify_enabled = cds_cfg->ce_classify_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301968 ol_cfg_set_flow_control_parameters(&olCfg, cds_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969
1970 ((p_cds_contextType) cds_context)->cfg_ctx =
Anurag Chouhandf2b2682016-02-29 14:15:27 +05301971 ol_pdev_cfg_attach(((p_cds_contextType) cds_context)->qdf_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 olCfg);
1973 if (!(((p_cds_contextType) cds_context)->cfg_ctx)) {
1974 WMA_LOGP("%s: failed to init cfg handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301975 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976 goto err_wmi_handle;
1977 }
1978
1979 /* adjust the cfg_ctx default value based on setting */
1980 ol_set_cfg_rx_fwd_disabled((ol_pdev_handle)
1981 ((p_cds_contextType) cds_context)->cfg_ctx,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301982 (uint8_t) cds_cfg->ap_disable_intrabss_fwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983
Manjunathappa Prakashfff753c2016-09-01 19:34:56 -07001984 /* Configure Receive flow steering */
1985 ol_set_cfg_flow_steering((ol_pdev_handle)
1986 ((p_cds_contextType)cds_context)->cfg_ctx,
1987 cds_cfg->flow_steering_enabled);
1988
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 /* adjust the packet log enable default value based on CFG INI setting */
1990 ol_set_cfg_packet_log_enabled((ol_pdev_handle)
1991 ((p_cds_contextType) cds_context)->
1992 cfg_ctx,
1993 (uint8_t)cds_is_packet_log_enabled());
1994
1995 /* Allocate dfs_ic and initialize DFS */
1996 wma_handle->dfs_ic = wma_dfs_attach(wma_handle->dfs_ic);
1997 if (wma_handle->dfs_ic == NULL) {
1998 WMA_LOGE("%s: Memory allocation failed for dfs_ic", __func__);
1999 goto err_wmi_handle;
2000 }
2001#if defined(QCA_WIFI_FTM)
Anurag Chouhan6d760662016-02-20 16:05:43 +05302002 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 wma_utf_attach(wma_handle);
2004#endif /* QCA_WIFI_FTM */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302005 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
2006 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302008 cds_cfg->max_bssid = WMA_MAX_SUPPORTED_BSS;
2009 cds_cfg->frame_xln_reqd = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010
2011 wma_handle->wlan_resource_config.num_wow_filters =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302012 cds_cfg->max_wow_filters;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 wma_handle->wlan_resource_config.num_keep_alive_pattern =
2014 WMA_MAXNUM_PERIODIC_TX_PTRNS;
2015
2016 /* The current firmware implementation requires the number of
Anurag Chouhanffb21542016-02-17 14:33:03 +05302017 * offload peers should be (number of vdevs + 1).
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 */
2019 wma_handle->wlan_resource_config.num_offload_peers =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302020 cds_cfg->ap_maxoffload_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021
2022 wma_handle->wlan_resource_config.num_offload_reorder_buffs =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302023 cds_cfg->ap_maxoffload_reorderbuffs + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302025 wma_handle->ol_ini_info = cds_cfg->ol_ini_info;
2026 wma_handle->max_station = cds_cfg->max_station;
2027 wma_handle->max_bssid = cds_cfg->max_bssid;
2028 wma_handle->frame_xln_reqd = cds_cfg->frame_xln_reqd;
2029 wma_handle->driver_type = cds_cfg->driver_type;
2030 wma_handle->ssdp = cds_cfg->ssdp;
2031 wma_handle->enable_mc_list = cds_cfg->enable_mc_list;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05302032 wma_handle->bpf_packet_filter_enable =
2033 cds_cfg->bpf_packet_filter_enable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302035 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
2036 wma_handle->RArateLimitInterval = cds_cfg->ra_ratelimit_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037#endif /* FEATURE_WLAN_RA_FILTERING */
2038#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302039 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040#endif
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302041 wma_set_nan_enable(wma_handle, cds_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 /*
2043 * Indicates if DFS Phyerr filtering offload
2044 * is Enabled/Disabed from ini
2045 */
2046 wma_handle->dfs_phyerr_filter_offload =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302047 cds_cfg->dfs_phyerr_filter_offload;
2048 wma_handle->dfs_pri_multiplier = cds_cfg->dfs_pri_multiplier;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302049 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 wma_handle->max_bssid);
2051 if (!wma_handle->interfaces) {
2052 WMA_LOGP("%s: failed to allocate interface table", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302053 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 goto err_scn_context;
2055 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302056 qdf_mem_zero(wma_handle->interfaces, sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057 wma_handle->max_bssid);
2058 /* Register the debug print event handler */
2059 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302060 WMI_DEBUG_PRINT_EVENTID,
2061 wma_unified_debug_print_event_handler,
2062 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05302063 /* Register profiling event Handler */
2064 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2065 WMI_WLAN_PROFILE_DATA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302066 wma_profile_data_report_event_handler,
2067 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068
2069 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
2070 wma_handle->dfs_radar_indication_cb = radar_ind_cb;
2071 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
2072 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05302073 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07002074 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302076 qdf_status = qdf_event_create(&wma_handle->wma_ready_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302077 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 WMA_LOGP("%s: wma_ready_event initialization failed", __func__);
2079 goto err_event_init;
2080 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302081
Anurag Chouhan210db072016-02-22 18:42:15 +05302082 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302083 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302084 wma_service_ready_ext_evt_timeout,
2085 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302086 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302087 WMA_LOGE("Failed to initialize service ready ext timeout");
2088 goto err_event_init;
2089 }
2090
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302091 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302092 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 WMA_LOGP("%s: target suspend event initialization failed",
2094 __func__);
2095 goto err_event_init;
2096 }
2097
2098 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302099 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
2100 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 WMA_LOGP("%s: failed to init tx_frm_download_comp_event",
2102 __func__);
2103 goto err_event_init;
2104 }
2105
2106 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302107 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
2108 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 WMA_LOGP("%s: failed to init tx_queue_empty_event", __func__);
2110 goto err_event_init;
2111 }
2112
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302113 qdf_status = qdf_event_create(&wma_handle->wma_resume_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302114 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 WMA_LOGP("%s: wma_resume_event initialization failed",
2116 __func__);
2117 goto err_event_init;
2118 }
2119
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002120 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
2121 wma_handle);
2122 if (qdf_status != QDF_STATUS_SUCCESS) {
2123 WMA_LOGP("%s: Shutdown notifier register failed: %d",
2124 __func__, qdf_status);
2125 goto err_event_init;
2126 }
2127
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302128 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302129 if (qdf_status != QDF_STATUS_SUCCESS) {
Houston Hoffmana76591b2015-11-10 16:52:05 -08002130 WMA_LOGP("%s: runtime_suspend event initialization failed",
2131 __func__);
2132 goto err_event_init;
2133 }
2134
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302135 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302136 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 WMA_LOGP("%s: recovery event initialization failed", __func__);
2138 goto err_event_init;
2139 }
2140
Anurag Chouhanffb21542016-02-17 14:33:03 +05302141 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07002142 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302143 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05302144 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302146 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05302147 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
2148 qdf_atomic_init(&wma_handle->scan_id_counter);
Nitesh Shah0f3fce52016-10-13 22:01:41 +05302149 qdf_atomic_init(&wma_handle->num_pending_scans);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150
2151 /* Register vdev start response event handler */
2152 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2153 WMI_VDEV_START_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302154 wma_vdev_start_resp_handler,
2155 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156
2157 /* Register vdev stop response event handler */
2158 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2159 WMI_VDEV_STOPPED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302160 wma_vdev_stop_resp_handler,
2161 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162
2163 /* register for STA kickout function */
2164 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2165 WMI_PEER_STA_KICKOUT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302166 wma_peer_sta_kickout_event_handler,
2167 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168
2169 /* register for stats response event */
2170 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2171 WMI_UPDATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302172 wma_stats_event_handler,
2173 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174 /* register for linkspeed response event */
2175 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2176 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302177 wma_link_speed_event_handler,
2178 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179
2180#ifdef FEATURE_OEM_DATA_SUPPORT
2181 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002182 WMI_OEM_RESPONSE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302183 wma_oem_data_response_handler,
2184 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185#endif /* FEATURE_OEM_DATA_SUPPORT */
2186 /*
2187 * Register appropriate DFS phyerr event handler for
2188 * Phyerror events. Handlers differ for phyerr filtering
2189 * offload enable and disable cases.
2190 */
2191 wma_register_dfs_event_handler(wma_handle);
2192
2193 /* Register peer change event handler */
2194 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2195 WMI_PEER_STATE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302196 wma_peer_state_change_event_handler,
2197 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198
2199 /* Register beacon tx complete event id. The event is required
2200 * for sending channel switch announcement frames
2201 */
2202 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302203 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID,
2204 wma_unified_bcntx_status_event_handler,
2205 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206
2207 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2208 WMI_UPDATE_VDEV_RATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302209 wma_link_status_event_handler,
2210 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211#ifdef WLAN_FEATURE_LINK_LAYER_STATS
2212 /* Register event handler for processing Link Layer Stats
2213 * response from the FW
2214 */
2215 wma_register_ll_stats_event_handler(wma_handle);
2216
2217#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2218
2219 /*
2220 * Register event handler to receive firmware mem dump
2221 * copy complete indication
2222 */
2223 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2224 WMI_UPDATE_FW_MEM_DUMP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302225 wma_fw_mem_dump_event_handler,
2226 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227
2228 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302229 qdf_status = dbglog_init(wma_handle->wmi_handle);
2230 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 WMA_LOGP("%s: Firmware Dbglog initialization failed", __func__);
2232 goto err_dbglog_init;
2233 }
2234
2235 /*
2236 * Update Powersave mode
2237 * 1 - Legacy Powersave + Deepsleep Disabled
2238 * 2 - QPower + Deepsleep Disabled
2239 * 3 - Legacy Powersave + Deepsleep Enabled
2240 * 4 - QPower + Deepsleep Enabled
2241 */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302242 wma_handle->powersave_mode = cds_cfg->powersave_offload_enabled;
2243 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
2244 wma_handle->staModDtim = cds_cfg->sta_mod_dtim;
2245 wma_handle->staDynamicDtim = cds_cfg->sta_dynamic_dtim;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246
2247 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302248 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 * 0 - Disable both magic pattern match and pattern byte match.
2250 * 1 - Enable magic pattern match on all interfaces.
2251 * 2 - Enable pattern byte match on all interfaces.
2252 * 3 - Enable both magic patter and pattern byte match on
2253 * all interfaces.
2254 */
2255 wma_handle->wow.magic_ptrn_enable =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302256 (cds_cfg->wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 wma_handle->ptrn_match_enable_all_vdev =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302258 (cds_cfg->wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259
2260#ifdef FEATURE_WLAN_TDLS
2261 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2262 WMI_TDLS_PEER_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302263 wma_tdls_event_handler,
2264 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265#endif /* FEATURE_WLAN_TDLS */
2266
2267 /* register for install key completion event */
2268 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302269 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID,
2270 wma_vdev_install_key_complete_event_handler,
2271 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272#ifdef WLAN_FEATURE_NAN
2273 /* register for nan response event */
2274 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2275 WMI_NAN_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302276 wma_nan_rsp_event_handler,
2277 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278#endif /* WLAN_FEATURE_NAN */
2279
2280#ifdef WLAN_FEATURE_STATS_EXT
2281 /* register for extended stats event */
2282 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2283 WMI_STATS_EXT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302284 wma_stats_ext_event_handler,
2285 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286#endif /* WLAN_FEATURE_STATS_EXT */
2287#ifdef FEATURE_WLAN_EXTSCAN
2288 wma_register_extscan_event_handler(wma_handle);
2289#endif /* WLAN_FEATURE_STATS_EXT */
2290
2291 WMA_LOGD("%s: Exit", __func__);
2292
2293#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2294 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2295 WMI_ROAM_SYNCH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302296 wma_roam_synch_event_handler,
2297 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
2299 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2300 WMI_RSSI_BREACH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302301 wma_rssi_breached_event_handler,
2302 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302304 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05302305 "wlan_fw_rsp_wakelock");
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002306 wma_handle->wmi_cmd_rsp_runtime_lock =
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302307 qdf_runtime_lock_init("wlan_fw_rsp_runtime_lock");
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002308
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 /* Register peer assoc conf event handler */
2310 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2311 WMI_PEER_ASSOC_CONF_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302312 wma_peer_assoc_conf_handler,
2313 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002314 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2315 WMI_VDEV_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302316 wma_vdev_delete_handler,
2317 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002318 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2319 WMI_PEER_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302320 wma_peer_delete_handler,
2321 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05302322 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2323 WMI_BPF_CAPABILIY_INFO_EVENTID,
2324 wma_get_bpf_caps_event_handler,
2325 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05302326 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2327 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID,
2328 wma_encrypt_decrypt_msg_handler,
2329 WMA_RX_SERIALIZER_CTX);
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07002330 wma_ndp_register_all_event_handlers(wma_handle);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302331 wma_register_debug_callback();
2332
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302333 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334
2335err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302336 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
2337 qdf_runtime_lock_deinit(wma_handle->wmi_cmd_rsp_runtime_lock);
2338 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
2339 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340err_event_init:
2341 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
2342 WMI_DEBUG_PRINT_EVENTID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302343 qdf_mem_free(wma_handle->interfaces);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344err_scn_context:
2345 wma_dfs_detach(wma_handle->dfs_ic);
2346#if defined(QCA_WIFI_FTM)
2347 wma_utf_detach(wma_handle);
2348#endif /* QCA_WIFI_FTM */
2349err_wmi_handle:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302350 qdf_mem_free(((p_cds_contextType) cds_context)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 OS_FREE(wmi_handle);
2352
2353err_wma_handle:
2354
Anurag Chouhan6d760662016-02-20 16:05:43 +05302355 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356#ifdef FEATURE_WLAN_SCAN_PNO
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302357 qdf_wake_lock_destroy(&wma_handle->pno_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358#endif /* FEATURE_WLAN_SCAN_PNO */
2359#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302360 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302362 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 }
Houston Hoffmanc45db892015-11-13 19:59:25 -08002364
2365 qdf_runtime_lock_deinit(wma_handle->wma_runtime_resume_lock);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302366 cds_free_context(cds_context, QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367
2368 WMA_LOGD("%s: Exit", __func__);
2369
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302370 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371}
2372
2373/**
2374 * wma_pre_start() - wma pre start
2375 * @cds_ctx: cds context
2376 *
2377 * Return: 0 on success, errno on failure
2378 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302379QDF_STATUS wma_pre_start(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302381 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382 A_STATUS status = A_OK;
2383 tp_wma_handle wma_handle;
2384 cds_msg_t wma_msg = { 0 };
2385
2386 WMA_LOGD("%s: Enter", __func__);
2387
Anurag Chouhan6d760662016-02-20 16:05:43 +05302388 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389
2390 /* Validate the wma_handle */
2391 if (NULL == wma_handle) {
2392 WMA_LOGP("%s: invalid argument", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302393 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 goto end;
2395 }
2396 /* Open endpoint for ctrl path - WMI <--> HTC */
2397 status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
2398 wma_handle->htc_handle);
2399 if (A_OK != status) {
2400 WMA_LOGP("%s: wmi_unified_connect_htc_service", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302401 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402 goto end;
2403 }
2404
2405 WMA_LOGA("WMA --> wmi_unified_connect_htc_service - success");
2406
2407 /* Trigger the CFG DOWNLOAD */
2408 wma_msg.type = WNI_CFG_DNLD_REQ;
2409 wma_msg.bodyptr = NULL;
2410 wma_msg.bodyval = 0;
2411
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302412 qdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &wma_msg);
2413 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 WMA_LOGP("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302415 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302416 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 }
2418end:
2419 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302420 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421}
2422
2423/**
2424 * wma_send_msg() - Send wma message to PE.
2425 * @wma_handle: wma handle
2426 * @msg_type: message type
2427 * @body_ptr: message body ptr
2428 * @body_val: message body value
2429 *
2430 * Return: none
2431 */
2432void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
2433 void *body_ptr, uint32_t body_val)
2434{
2435 tSirMsgQ msg = { 0 };
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302436 uint32_t status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302437 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 msg.type = msg_type;
2439 msg.bodyval = body_val;
2440 msg.bodyptr = body_ptr;
2441 status = lim_post_msg_api(pMac, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302442 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 if (NULL != body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302444 qdf_mem_free(body_ptr);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302445 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 }
2447 return;
2448}
2449
2450/**
2451 * wma_set_base_macaddr_indicate() - set base mac address in fw
2452 * @wma_handle: wma handle
2453 * @customAddr: base mac address
2454 *
2455 * Return: 0 for success or error code
2456 */
2457static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
2458 tSirMacAddr *customAddr)
2459{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 int err;
2461
Govind Singhf25a0f12016-03-08 16:09:48 +05302462 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
2463 (uint8_t *)customAddr);
2464 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
2467 MAC_ADDR_ARRAY((*customAddr)));
2468
2469 return 0;
2470}
2471
2472/**
2473 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
2474 * @handle: WMA handle
2475 * @event: Event received from FW
2476 * @len: Length of the event
2477 *
2478 * Enables the low frequency events and disables the high frequency
2479 * events. Bit 17 indicates if the event if low/high frequency.
2480 * 1 - high frequency, 0 - low frequency
2481 *
2482 * Return: 0 on successfully enabling/disabling the events
2483 */
2484static int wma_log_supported_evt_handler(void *handle,
2485 uint8_t *event,
2486 uint32_t len)
2487{
2488 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489
Govind Singhf25a0f12016-03-08 16:09:48 +05302490 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
2491 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493
2494 return 0;
2495}
2496
2497/**
2498 * wma_flush_complete_evt_handler() - FW log flush complete event handler
2499 * @handle: WMI handle
2500 * @event: Event recevied from FW
2501 * @len: Length of the event
2502 *
2503 */
2504static int wma_flush_complete_evt_handler(void *handle,
2505 u_int8_t *event,
2506 u_int32_t len)
2507{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302508 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 tp_wma_handle wma = (tp_wma_handle) handle;
2510
2511 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *param_buf;
2512 wmi_debug_mesg_flush_complete_fixed_param *wmi_event;
2513 uint32_t reason_code;
2514
2515 param_buf = (WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *) event;
2516 if (!param_buf) {
2517 WMA_LOGE("Invalid log flush complete event buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302518 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519 }
2520
2521 wmi_event = param_buf->fixed_param;
2522 reason_code = wmi_event->reserved0;
2523
2524 /*
2525 * reason_code = 0; Flush event in response to flush command
2526 * reason_code = other value; Asynchronous flush event for fatal events
2527 */
2528 if (!reason_code && (cds_is_log_report_in_progress() == false)) {
2529 WMA_LOGE("Received WMI flush event without sending CMD");
2530 return -EINVAL;
2531 } else if (!reason_code && cds_is_log_report_in_progress() == true) {
2532 /* Flush event in response to flush command */
2533 WMA_LOGI("Received WMI flush event in response to flush CMD");
Anurag Chouhan210db072016-02-22 18:42:15 +05302534 status = qdf_mc_timer_stop(&wma->log_completion_timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302535 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 WMA_LOGE("Failed to stop the log completion timeout");
2537 cds_logging_set_fw_flush_complete();
2538 } else if (reason_code && cds_is_log_report_in_progress() == false) {
2539 /* Asynchronous flush event for fatal events */
2540 WMA_LOGE("Received asynchronous WMI flush event: reason=%d",
2541 reason_code);
2542 status = cds_set_log_completion(WLAN_LOG_TYPE_FATAL,
2543 WLAN_LOG_INDICATOR_FIRMWARE,
Abhishek Singh5ea86532016-04-27 14:10:53 +05302544 reason_code, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302545 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 WMA_LOGE("%s: Failed to set log trigger params",
2547 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302548 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 }
2550 cds_logging_set_fw_flush_complete();
2551 return status;
2552 } else {
2553 /* Asynchronous flush event for fatal event,
2554 * but, report in progress already
2555 */
2556 WMA_LOGI("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
2557 __func__, WLAN_LOG_TYPE_FATAL,
2558 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302559 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 }
2561 return 0;
2562}
2563
2564/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302565 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566 * @handle: WMI handle
2567 * @event: Event recevied from FW
2568 * @len: Length of the event
2569 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302570 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
2571 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
2572 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573 *
2574 * Return: Success on receiving valid params from FW
2575 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302576static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 uint8_t *event,
2578 uint32_t len)
2579{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302580 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
2581 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
2582 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583 uint32_t i;
2584 struct sir_set_hw_mode_resp *hw_mode_resp;
2585 tp_wma_handle wma = (tp_wma_handle) handle;
2586
2587 if (!wma) {
2588 WMA_LOGE("%s: Invalid WMA handle", __func__);
2589 /* Since WMA handle itself is NULL, we cannot send fail
2590 * response back to LIM here
2591 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302592 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 }
2594
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302595 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 if (!hw_mode_resp) {
2597 WMA_LOGI("%s: Memory allocation failed", __func__);
2598 /* Since this memory allocation itself failed, we cannot
2599 * send fail response back to LIM here
2600 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302601 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 }
2603
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302604 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302606 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 /* Need to send response back to upper layer to free
2608 * active command list
2609 */
2610 goto fail;
2611 }
2612
2613 wmi_event = param_buf->fixed_param;
2614 hw_mode_resp->status = wmi_event->status;
2615 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2616 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
2617
2618 WMA_LOGI("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
2619 __func__, wmi_event->status,
2620 wmi_event->cfgd_hw_mode_index,
2621 wmi_event->num_vdev_mac_entries);
2622 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302623 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624
2625 /* Store the vdev-mac map in WMA and prepare to send to PE */
2626 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302627 uint32_t vdev_id, mac_id, pdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302629 pdev_id = vdev_mac_entry[i].pdev_id;
2630 if (pdev_id == WMI_PDEV_ID_SOC) {
2631 WMA_LOGE("%s: soc level id received for mac id)",
2632 __func__);
2633 QDF_BUG(0);
2634 goto fail;
2635 }
2636 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637
2638 WMA_LOGI("%s: vdev_id:%d mac_id:%d",
2639 __func__, vdev_id, mac_id);
2640
2641 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
2642 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
2643 wma_update_intf_hw_mode_params(vdev_id, mac_id,
2644 wmi_event->cfgd_hw_mode_index);
2645 }
2646
2647 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
2648 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
2649 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2650 } else {
2651 wma->old_hw_mode_index = wma->new_hw_mode_index;
2652 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2653 }
2654 }
2655
2656 WMA_LOGI("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
2657 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
2658
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302659 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 (void *) hw_mode_resp, 0);
2661
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302662 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663
2664fail:
2665 WMA_LOGE("%s: Sending fail response to LIM", __func__);
2666 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
2667 hw_mode_resp->cfgd_hw_mode_index = 0;
2668 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302669 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 (void *) hw_mode_resp, 0);
2671
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302672 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673}
2674
2675/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002676 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
2677 *
2678 * @handle: WMA handle
2679 * @fixed_param: Event fixed parameters
2680 * @vdev_mac_entry - vdev mac entry
2681 * @hw_mode_trans_ind - Buffer to store parsed information
2682 *
2683 * Parses fixed_param, vdev_mac_entry and fills in the information into
2684 * hw_mode_trans_ind and wma
2685 *
2686 * Return: None
2687 */
2688void wma_process_pdev_hw_mode_trans_ind(void *handle,
2689 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
2690 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
2691 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
2692{
2693 uint32_t i;
2694 tp_wma_handle wma = (tp_wma_handle) handle;
2695
2696 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
2697 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
2698 hw_mode_trans_ind->num_vdev_mac_entries =
2699 fixed_param->num_vdev_mac_entries;
2700 WMA_LOGI("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
2701 __func__, fixed_param->old_hw_mode_index,
2702 fixed_param->new_hw_mode_index,
2703 fixed_param->num_vdev_mac_entries);
2704
2705 /* Store the vdev-mac map in WMA and send to policy manager */
2706 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
2707 uint32_t vdev_id, mac_id, pdev_id;
2708 vdev_id = vdev_mac_entry[i].vdev_id;
2709 pdev_id = vdev_mac_entry[i].pdev_id;
2710
2711 if (pdev_id == WMI_PDEV_ID_SOC) {
2712 WMA_LOGE("%s: soc level id received for mac id)",
2713 __func__);
2714 QDF_BUG(0);
2715 return;
2716 }
2717
2718 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
2719
2720 WMA_LOGI("%s: vdev_id:%d mac_id:%d",
2721 __func__, vdev_id, mac_id);
2722
2723 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
2724 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
2725 wma_update_intf_hw_mode_params(vdev_id, mac_id,
2726 fixed_param->new_hw_mode_index);
2727 }
2728 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
2729 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
2730
2731 WMA_LOGI("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
2732 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
2733}
2734
2735/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302736 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 * @handle: WMI handle
2738 * @event: Event recevied from FW
2739 * @len: Length of the event
2740 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302741 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742 * asynchronous hardware mode transition. This event notifies the host driver
2743 * that firmware independently changed the hardware mode for some reason, such
2744 * as Coex, LFR 3.0, etc
2745 *
2746 * Return: Success on receiving valid params from FW
2747 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302748static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 uint8_t *event,
2750 uint32_t len)
2751{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302752 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
2753 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
2754 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
2756 tp_wma_handle wma = (tp_wma_handle) handle;
2757
2758 if (!wma) {
2759 /* This is an async event. So, not sending any event to LIM */
2760 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302761 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 }
2763
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302764 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 if (!param_buf) {
2766 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302767 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302768 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002769 }
2770
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302771 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002772 if (!hw_mode_trans_ind) {
2773 WMA_LOGI("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302774 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 }
2776
2777 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302779 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002780 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
2781 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302783 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784 (void *) hw_mode_trans_ind, 0);
2785
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302786 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787}
2788
2789/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302790 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 * @handle: WMI handle
2792 * @event: Event received from FW
2793 * @len: Length of the event
2794 *
2795 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302796 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 * the host driver once the firmware has completed a reconfiguration of the Scan
2798 * and FW mode configuration. This changes could include entering or leaving a
2799 * dual mac configuration for either scan and/or more permanent firmware mode.
2800 *
2801 * Return: Success on receiving valid params from FW
2802 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302803static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 uint8_t *event,
2805 uint32_t len)
2806{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302807 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
2808 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 tp_wma_handle wma = (tp_wma_handle) handle;
2810 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
2811
2812 if (!wma) {
2813 WMA_LOGE("%s: Invalid WMA handle", __func__);
2814 /* Since the WMA handle is NULL, we cannot send resp to LIM.
2815 * So, returning from here.
2816 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302817 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 }
2819
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302820 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 if (!dual_mac_cfg_resp) {
2822 WMA_LOGE("%s: Memory allocation failed", __func__);
2823 /* Since the mem alloc failed, we cannot send resp to LIM.
2824 * So, returning from here.
2825 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302826 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 }
2828
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302829 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 event;
2831 if (!param_buf) {
2832 WMA_LOGE("%s: Invalid event", __func__);
2833 goto fail;
2834 }
2835
2836 wmi_event = param_buf->fixed_param;
2837 WMA_LOGI("%s: status:%d", __func__, wmi_event->status);
2838 dual_mac_cfg_resp->status = wmi_event->status;
2839
2840 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
2841 wma->dual_mac_cfg.prev_scan_config =
2842 wma->dual_mac_cfg.cur_scan_config;
2843 wma->dual_mac_cfg.prev_fw_mode_config =
2844 wma->dual_mac_cfg.cur_fw_mode_config;
2845 wma->dual_mac_cfg.cur_scan_config =
2846 wma->dual_mac_cfg.req_scan_config;
2847 wma->dual_mac_cfg.cur_fw_mode_config =
2848 wma->dual_mac_cfg.req_fw_mode_config;
2849 }
2850
2851 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302852 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 (void *) dual_mac_cfg_resp, 0);
2854
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302855 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856
2857fail:
2858 WMA_LOGE("%s: Sending fail response to LIM", __func__);
2859 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302860 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 (void *) dual_mac_cfg_resp, 0);
2862
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302863 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864
2865}
2866
2867/**
2868 * wma_start() - wma start function.
2869 * Intialize event handlers and timers.
2870 * @cds_ctx: cds context
2871 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302872 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302874QDF_STATUS wma_start(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302876 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 tp_wma_handle wma_handle;
2878 int status;
2879 WMA_LOGD("%s: Enter", __func__);
2880
Anurag Chouhan6d760662016-02-20 16:05:43 +05302881 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882
2883 /* validate the wma_handle */
2884 if (NULL == wma_handle) {
2885 WMA_LOGP("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302886 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 goto end;
2888 }
2889
2890 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
2891 WMI_SCAN_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302892 wma_scan_event_callback,
2893 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 if (0 != status) {
2895 WMA_LOGP("%s: Failed to register scan callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302896 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 goto end;
2898 }
2899
2900 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
2901 WMI_ROAM_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302902 wma_roam_event_callback,
2903 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 if (0 != status) {
2905 WMA_LOGP("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302906 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 goto end;
2908 }
2909
2910 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
2911 WMI_WOW_WAKEUP_HOST_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302912 wma_wow_wakeup_host_event,
2913 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 if (status) {
2915 WMA_LOGP("%s: Failed to register wow wakeup host event handler",
2916 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302917 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 goto end;
2919 }
2920
2921 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
2922 WMI_PDEV_RESUME_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302923 wma_pdev_resume_event_handler,
2924 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925 if (status) {
2926 WMA_LOGP("%s: Failed to register PDEV resume event handler",
2927 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302928 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 goto end;
2930 }
2931
2932#ifdef FEATURE_WLAN_SCAN_PNO
2933 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
2934 WMI_SERVICE_NLO)) {
2935
2936 WMA_LOGD("FW supports pno offload, registering nlo match handler");
2937
2938 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302939 WMI_NLO_MATCH_EVENTID,
2940 wma_nlo_match_evt_handler,
2941 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 if (status) {
2943 WMA_LOGE("Failed to register nlo match event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302944 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 goto end;
2946 }
2947
2948 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302949 WMI_NLO_SCAN_COMPLETE_EVENTID,
2950 wma_nlo_scan_cmp_evt_handler,
2951 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 if (status) {
2953 WMA_LOGE("Failed to register nlo scan comp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302954 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 goto end;
2956 }
2957 }
2958#endif /* FEATURE_WLAN_SCAN_PNO */
2959
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05302960#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
2961 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 WMA_LOGE("MCC TX Pause Event Handler register");
2963 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302964 WMI_TX_PAUSE_EVENTID,
2965 wma_mcc_vdev_tx_pause_evt_handler,
2966 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
2968
2969#ifdef FEATURE_WLAN_CH_AVOID
2970 WMA_LOGD("Registering channel to avoid handler");
2971
2972 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302973 WMI_WLAN_FREQ_AVOID_EVENTID,
2974 wma_channel_avoid_evt_handler,
2975 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 if (status) {
2977 WMA_LOGE("Failed to register channel to avoid event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302978 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 goto end;
2980 }
2981#endif /* FEATURE_WLAN_CH_AVOID */
2982#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2983 WMA_LOGD("Registering auto shutdown handler");
2984 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302985 WMI_HOST_AUTO_SHUTDOWN_EVENTID,
2986 wma_auto_shutdown_event_handler,
2987 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 if (status) {
2989 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302990 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002991 goto end;
2992 }
2993#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
2994 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302995 WMI_THERMAL_MGMT_EVENTID,
2996 wma_thermal_mgmt_evt_handler,
2997 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 if (status) {
2999 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303000 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 goto end;
3002 }
3003
3004 status = wma_ocb_register_event_handlers(wma_handle);
3005 if (status) {
3006 WMA_LOGE("Failed to register ocb event handlers");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303007 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 goto end;
3009 }
3010
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303011 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012
3013#ifdef QCA_WIFI_FTM
3014 /*
3015 * Tx mgmt attach requires TXRX context which is not created
3016 * in FTM mode. So skip the TX mgmt attach.
3017 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303018 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 goto end;
3020#endif /* QCA_WIFI_FTM */
3021
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003022 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3023 WMI_SERVICE_RMC)) {
3024
3025 WMA_LOGD("FW supports cesium network, registering event handlers");
3026
3027 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3028 WMI_PEER_INFO_EVENTID,
3029 wma_ibss_peer_info_event_handler,
3030 WMA_RX_SERIALIZER_CTX);
3031 if (status) {
3032 WMA_LOGE("Failed to register ibss peer info event cb");
3033 qdf_status = QDF_STATUS_E_FAILURE;
3034 goto end;
3035 }
3036
3037 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3038 WMI_PEER_TX_FAIL_CNT_THR_EVENTID,
3039 wma_fast_tx_fail_event_handler,
3040 WMA_RX_SERIALIZER_CTX);
3041 if (status) {
3042 WMA_LOGE("Failed to register peer fast tx failure event cb");
3043 qdf_status = QDF_STATUS_E_FAILURE;
3044 goto end;
3045 }
3046 } else {
3047 WMA_LOGE("Target does not support cesium network");
3048 }
3049
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303050 qdf_status = wma_tx_attach(wma_handle);
3051 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 WMA_LOGP("%s: Failed to register tx management", __func__);
3053 goto end;
3054 }
3055
3056 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05303057 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303058 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 wma_log_completion_timeout,
3060 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303061 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 WMA_LOGE("Failed to initialize log completion timeout");
3063 goto end;
3064 }
3065
3066 /* Initialize the get temperature event handler */
3067 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303068 WMI_PDEV_TEMPERATURE_EVENTID,
3069 wma_pdev_temperature_evt_handler,
3070 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303071 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303073 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 goto end;
3075 }
3076
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07003077 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3078 WMI_VDEV_TSF_REPORT_EVENTID,
3079 wma_vdev_tsf_handler,
3080 WMA_RX_SERIALIZER_CTX);
3081 if (0 != status) {
3082 WMA_LOGP("%s: Failed to register tsf callback", __func__);
3083 qdf_status = QDF_STATUS_E_FAILURE;
3084 goto end;
3085 }
3086
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 /* Initialize the log flush complete event handler */
3088 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3089 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303090 wma_flush_complete_evt_handler,
3091 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303092 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 WMA_LOGE("Failed to register log flush complete event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303094 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 goto end;
3096 }
3097
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303098 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303100 WMI_PDEV_SET_HW_MODE_RESP_EVENTID,
3101 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303102 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303103 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303105 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 goto end;
3107 }
3108
3109 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
3110 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303111 WMI_PDEV_HW_MODE_TRANSITION_EVENTID,
3112 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303113 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303114 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303116 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 goto end;
3118 }
3119
3120 /* Initialize the set dual mac configuration event handler */
3121 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303122 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID,
3123 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303124 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303125 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303127 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 goto end;
3129 }
3130
Peng Xu8fdaa492016-06-22 10:20:47 -07003131 /* Initialize the P2P Listen Offload event handler */
3132 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3133 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID,
3134 wma_p2p_lo_event_handler,
3135 WMA_RX_SERIALIZER_CTX);
3136 if (!QDF_IS_STATUS_SUCCESS(status)) {
3137 WMA_LOGE("Failed to register p2p lo event cb");
3138 qdf_status = QDF_STATUS_E_FAILURE;
3139 goto end;
3140 }
3141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142end:
3143 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303144 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145}
3146
3147/**
3148 * wma_stop() - wma stop function.
3149 * cleanup timers and suspend target.
3150 * @cds_ctx: cds context
3151 * @reason: reason for wma_stop.
3152 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303153 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303155QDF_STATUS wma_stop(void *cds_ctx, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156{
3157 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303158 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05303159 int i;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303160 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161
3162 WMA_LOGD("%s: Enter", __func__);
3163
3164 /* validate the wma_handle */
3165 if (NULL == wma_handle) {
3166 WMA_LOGP("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303167 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 goto end;
3169 }
3170#ifdef QCA_WIFI_FTM
3171 /*
3172 * Tx mgmt detach requires TXRX context which is not created
3173 * in FTM mode. So skip the TX mgmt detach.
3174 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303175 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303176 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 goto end;
3178 }
3179#endif /* QCA_WIFI_FTM */
3180
3181 if (wma_handle->ack_work_ctx) {
3182 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303183 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 wma_handle->ack_work_ctx = NULL;
3185 }
3186
3187 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05303188 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303189 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 WMA_LOGE("Failed to destroy the log completion timer");
3191 }
3192
3193 /* There's no need suspend target which is already down during SSR. */
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003194 if (!cds_is_driver_recovering()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195#ifdef HIF_USB
3196 /* Suspend the target and enable interrupt */
3197 if (wma_suspend_target(wma_handle, 0))
3198 WMA_LOGE("Failed to suspend target");
3199#else
3200 /* Suspend the target and disable interrupt */
3201 if (wma_suspend_target(wma_handle, 1))
3202 WMA_LOGE("Failed to suspend target");
3203#endif /* HIF_USB */
3204 }
3205
Govind Singhede435f2015-12-01 16:16:36 +05303206 /* clean up ll-queue for all vdev */
3207 for (i = 0; i < wma_handle->max_bssid; i++) {
3208 if (wma_handle->interfaces[i].handle &&
3209 wma_handle->interfaces[i].vdev_up) {
3210 ol_txrx_vdev_flush(wma_handle->interfaces[i].handle);
3211 }
3212 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303213 qdf_status = wma_tx_detach(wma_handle);
3214 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 WMA_LOGP("%s: Failed to deregister tx management", __func__);
3216 goto end;
3217 }
3218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219end:
3220 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303221 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222}
3223
3224/**
3225 * wma_cleanup_hold_req() - cleanup hold request queue
3226 * @wma: wma handle
3227 *
3228 * Return: none
3229 */
3230static void wma_cleanup_hold_req(tp_wma_handle wma)
3231{
3232 struct wma_target_req *req_msg = NULL;
Anurag Chouhanffb21542016-02-17 14:33:03 +05303233 qdf_list_node_t *node1 = NULL;
3234 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303236 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303237 if (!qdf_list_size(&wma->wma_hold_req_queue)) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303238 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
Krishna Kumaar Natarajanea08e502015-11-09 16:57:40 -08003239 WMA_LOGI(FL("request queue is empty"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 return;
3241 }
3242
Anurag Chouhanffb21542016-02-17 14:33:03 +05303243 while (QDF_STATUS_SUCCESS !=
3244 qdf_list_peek_front(&wma->wma_hold_req_queue, &node1)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05303245 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303246 status = qdf_list_remove_node(&wma->wma_hold_req_queue, node1);
3247 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303248 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 WMA_LOGE(FL("Failed to remove request for vdev_id %d type %d"),
3250 req_msg->vdev_id, req_msg->type);
3251 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 }
Anurag Chouhan210db072016-02-22 18:42:15 +05303253 qdf_mc_timer_destroy(&req_msg->event_timeout);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303254 qdf_mem_free(req_msg);
Krishna Kumaar Natarajanea08e502015-11-09 16:57:40 -08003255 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303256 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257}
3258
3259/**
3260 * wma_cleanup_vdev_resp() - cleanup vdev response queue
3261 * @wma: wma handle
3262 *
3263 * Return: none
3264 */
3265static void wma_cleanup_vdev_resp(tp_wma_handle wma)
3266{
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003267 struct wma_target_req *req_msg = NULL;
Anurag Chouhanffb21542016-02-17 14:33:03 +05303268 qdf_list_node_t *node1 = NULL;
3269 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303271 qdf_spin_lock_bh(&wma->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303272 if (!qdf_list_size(&wma->vdev_resp_queue)) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303273 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003274 WMA_LOGI(FL("request queue maybe empty"));
3275 return;
3276 }
3277
Anurag Chouhanffb21542016-02-17 14:33:03 +05303278 while (QDF_STATUS_SUCCESS != qdf_list_peek_front(&wma->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003279 &node1)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05303280 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303281 status = qdf_list_remove_node(&wma->vdev_resp_queue, node1);
3282 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303283 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003284 WMA_LOGE(FL("Failed to remove request for vdev_id %d type %d"),
3285 req_msg->vdev_id, req_msg->type);
3286 return;
3287 }
Anurag Chouhan210db072016-02-22 18:42:15 +05303288 qdf_mc_timer_destroy(&req_msg->event_timeout);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303289 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303291 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292}
3293
3294/**
3295 * wma_wmi_service_close() - close wma wmi service interface.
3296 * @cds_ctx: cds context
3297 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303298 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303300QDF_STATUS wma_wmi_service_close(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301{
3302 tp_wma_handle wma_handle;
3303 struct beacon_info *bcn;
3304 int i;
3305
3306 WMA_LOGD("%s: Enter", __func__);
3307
Anurag Chouhan6d760662016-02-20 16:05:43 +05303308 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309
3310 /* validate the wma_handle */
3311 if (NULL == wma_handle) {
3312 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303313 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 }
3315
3316 /* validate the wmi handle */
3317 if (NULL == wma_handle->wmi_handle) {
3318 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303319 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 }
3321
3322 /* dettach the wmi serice */
3323 WMA_LOGD("calling wmi_unified_detach");
3324 wmi_unified_detach(wma_handle->wmi_handle);
3325 wma_handle->wmi_handle = NULL;
3326
3327 for (i = 0; i < wma_handle->max_bssid; i++) {
3328 bcn = wma_handle->interfaces[i].beacon;
3329
3330 if (bcn) {
3331 if (bcn->dma_mapped)
Nirav Shahcbc6d722016-03-01 16:24:53 +05303332 qdf_nbuf_unmap_single(wma_handle->qdf_dev,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303333 bcn->buf, QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +05303334 qdf_nbuf_free(bcn->buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303335 qdf_mem_free(bcn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 wma_handle->interfaces[i].beacon = NULL;
3337 }
3338
3339 if (wma_handle->interfaces[i].handle) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303340 qdf_mem_free(wma_handle->interfaces[i].handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 wma_handle->interfaces[i].handle = NULL;
3342 }
Yue Ma664effc2016-01-12 18:43:54 -08003343
3344 if (wma_handle->interfaces[i].addBssStaContext) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303345 qdf_mem_free(wma_handle->
Yue Ma664effc2016-01-12 18:43:54 -08003346 interfaces[i].addBssStaContext);
3347 wma_handle->interfaces[i].addBssStaContext = NULL;
3348 }
3349
3350 if (wma_handle->interfaces[i].del_staself_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303351 qdf_mem_free(wma_handle->interfaces[i].del_staself_req);
Yue Ma664effc2016-01-12 18:43:54 -08003352 wma_handle->interfaces[i].del_staself_req = NULL;
3353 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354 }
3355
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303356 qdf_mem_free(wma_handle->interfaces);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 /* free the wma_handle */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303358 cds_free_context(wma_handle->cds_context, QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 wma_handle);
3360
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303361 qdf_mem_free(((p_cds_contextType) cds_ctx)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303363 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364}
3365
Xun Luoa858a472015-11-10 08:24:45 -08003366/**
3367 * wma_wmi_work_close() - close the work queue items associated with WMI
3368 * @cds_ctx: Pointer to cds context
3369 *
3370 * This function closes work queue items associated with WMI, but not fully
3371 * closes WMI service.
3372 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303373 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08003374 * proper error codes.
3375 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303376QDF_STATUS wma_wmi_work_close(void *cds_ctx)
Xun Luoa858a472015-11-10 08:24:45 -08003377{
3378 tp_wma_handle wma_handle;
3379
3380 WMA_LOGD("%s: Enter", __func__);
3381
Anurag Chouhan6d760662016-02-20 16:05:43 +05303382 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08003383
3384 /* validate the wma_handle */
3385 if (NULL == wma_handle) {
3386 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303387 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003388 }
3389
3390 /* validate the wmi handle */
3391 if (NULL == wma_handle->wmi_handle) {
3392 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303393 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003394 }
3395
3396 /* remove the wmi work */
3397 WMA_LOGD("calling wmi_unified_remove_work");
3398 wmi_unified_remove_work(wma_handle->wmi_handle);
3399
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303400 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08003401}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402
Krunal Soni2e48d012016-05-02 16:55:26 -07003403/**
3404 * wma_cleanup_dbs_phy_caps() - release memory allocated for holding ext cap
3405 * @wma_handle: pointer to wma handle
3406 *
3407 * This function releases all the memory created for holding extended
3408 * capabilities per hardware mode and per PHY
3409 *
3410 * Return: void
3411 */
3412static void wma_cleanup_dbs_phy_caps(t_wma_handle *wma_handle)
3413{
3414 if (NULL == wma_handle) {
3415 WMA_LOGE("%s: Invalid wma handle", __func__);
3416 return;
3417 }
3418
3419 if (wma_handle->phy_caps.hw_mode_to_mac_cap_map) {
3420 qdf_mem_free(wma_handle->phy_caps.hw_mode_to_mac_cap_map);
3421 wma_handle->phy_caps.hw_mode_to_mac_cap_map = NULL;
3422 WMA_LOGI("%s: hw_mode_to_mac_cap_map freed", __func__);
3423 }
3424
3425 if (wma_handle->phy_caps.each_hw_mode_cap) {
3426 qdf_mem_free(wma_handle->phy_caps.each_hw_mode_cap);
3427 wma_handle->phy_caps.each_hw_mode_cap = NULL;
3428 WMA_LOGI("%s: each_hw_mode_cap freed", __func__);
3429 }
3430
3431 if (wma_handle->phy_caps.each_phy_cap_per_hwmode) {
3432 qdf_mem_free(wma_handle->phy_caps.each_phy_cap_per_hwmode);
3433 wma_handle->phy_caps.each_phy_cap_per_hwmode = NULL;
3434 WMA_LOGI("%s: each_phy_cap_per_hwmode freed", __func__);
3435 }
3436
3437 if (wma_handle->phy_caps.each_phy_hal_reg_cap) {
3438 qdf_mem_free(wma_handle->phy_caps.each_phy_hal_reg_cap);
3439 wma_handle->phy_caps.each_phy_hal_reg_cap = NULL;
3440 WMA_LOGI("%s: each_phy_hal_reg_cap freed", __func__);
3441 }
3442}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443
3444/**
3445 * wma_close() - wma close function.
3446 * cleanup resources attached with wma.
3447 * @cds_ctx: cds context
3448 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303449 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303451QDF_STATUS wma_close(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452{
3453 tp_wma_handle wma_handle;
3454 uint32_t idx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303455 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456
3457 WMA_LOGD("%s: Enter", __func__);
3458
Anurag Chouhan6d760662016-02-20 16:05:43 +05303459 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460
3461 /* validate the wma_handle */
3462 if (NULL == wma_handle) {
3463 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303464 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 }
3466
3467 /* validate the wmi handle */
3468 if (NULL == wma_handle->wmi_handle) {
3469 WMA_LOGP("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303470 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 }
3472
3473 /* Free DBS list */
3474 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303475 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 wma_handle->hw_mode.hw_mode_list = NULL;
3477 WMA_LOGI("%s: DBS list is freed", __func__);
3478 }
Krunal Soni2e48d012016-05-02 16:55:26 -07003479 wma_cleanup_dbs_phy_caps(wma_handle);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303480 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481#ifdef FEATURE_WLAN_SCAN_PNO
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303482 qdf_wake_lock_destroy(&wma_handle->pno_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483#endif /* FEATURE_WLAN_SCAN_PNO */
3484#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303485 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303487 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 }
3489
3490 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303491 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
3492 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 WMA_LOGP("%s: dbglog_deinit failed", __func__);
3494
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303495 /* close the qdf events */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303496 qdf_event_destroy(&wma_handle->wma_ready_event);
Anurag Chouhan210db072016-02-22 18:42:15 +05303497 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303498 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303499 WMA_LOGP("%s: Failed to destroy service ready ext event timer",
3500 __func__);
3501
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303502 qdf_event_destroy(&wma_handle->target_suspend);
3503 qdf_event_destroy(&wma_handle->wma_resume_event);
3504 qdf_event_destroy(&wma_handle->runtime_suspend);
3505 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08003506 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
3507 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 wma_cleanup_vdev_resp(wma_handle);
3509 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303510 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
3511 qdf_runtime_lock_deinit(wma_handle->wmi_cmd_rsp_runtime_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 for (idx = 0; idx < wma_handle->num_mem_chunks; ++idx) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303513 qdf_mem_free_consistent(wma_handle->qdf_dev,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303514 wma_handle->qdf_dev->dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 wma_handle->mem_chunks[idx].len,
3516 wma_handle->mem_chunks[idx].vaddr,
3517 wma_handle->mem_chunks[idx].paddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303518 qdf_get_dma_mem_context(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519 (&(wma_handle->mem_chunks[idx])),
3520 memctx));
3521 }
3522
3523#if defined(QCA_WIFI_FTM)
3524 /* Detach UTF and unregister the handler */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303525 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 wma_utf_detach(wma_handle);
3527#endif /* QCA_WIFI_FTM */
3528
3529 if (NULL != wma_handle->dfs_ic) {
3530 wma_dfs_detach(wma_handle->dfs_ic);
3531 wma_handle->dfs_ic = NULL;
3532 }
3533
3534 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303535 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536 wma_handle->pGetRssiReq = NULL;
3537 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07003538
3539 wma_ndp_unregister_all_event_handlers(wma_handle);
3540
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3542 WMI_SERVICE_MGMT_TX_WMI)) {
3543 wmi_desc_pool_deinit(wma_handle);
3544 }
3545
3546 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303547 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548}
3549
3550/**
3551 * wma_update_fw_config() - update fw configuration
3552 * @wma_handle: wma handle
3553 * @tgt_cap: target capabality
3554 *
3555 * Return: none
3556 */
3557static void wma_update_fw_config(tp_wma_handle wma_handle,
3558 struct wma_target_cap *tgt_cap)
3559{
3560 /*
3561 * tgt_cap contains default target resource configuration
3562 * which can be modified here, if required
3563 */
3564 /* Override the no. of max fragments as per platform configuration */
3565 tgt_cap->wlan_resource_config.max_frag_entries =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303566 QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 wma_handle->max_frag_entry);
3568 wma_handle->max_frag_entry =
3569 tgt_cap->wlan_resource_config.max_frag_entries;
Arun Khandavalli3dd06de2016-08-17 10:20:29 +05303570
3571 /* Update no. of maxWoWFilters depending on BPF service */
3572 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3573 WMI_SERVICE_BPF_OFFLOAD))
3574 tgt_cap->wlan_resource_config.num_wow_filters =
Arun Khandavallid454d422016-08-17 12:47:05 +05303575 WMA_STA_WOW_DEFAULT_PTRN_MAX;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576}
3577
3578/**
3579 * wma_alloc_host_mem_chunk() - allocate host memory
3580 * @wma_handle: wma handle
3581 * @req_id: request id
3582 * @idx: index
3583 * @num_units: number of units
3584 * @unit_len: unit length
3585 *
3586 * allocate a chunk of memory at the index indicated and
3587 * if allocation fail allocate smallest size possiblr and
3588 * return number of units allocated.
3589 *
3590 * Return: number of units or 0 for error.
3591 */
3592static uint32_t wma_alloc_host_mem_chunk(tp_wma_handle wma_handle,
3593 uint32_t req_id, uint32_t idx,
3594 uint32_t num_units, uint32_t unit_len)
3595{
Anurag Chouhan6d760662016-02-20 16:05:43 +05303596 qdf_dma_addr_t paddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 if (!num_units || !unit_len) {
3598 return 0;
3599 }
3600 wma_handle->mem_chunks[idx].vaddr = NULL;
3601 /** reduce the requested allocation by half until allocation succeeds */
3602 while (wma_handle->mem_chunks[idx].vaddr == NULL && num_units) {
3603 wma_handle->mem_chunks[idx].vaddr =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303604 qdf_mem_alloc_consistent(wma_handle->qdf_dev,
3605 wma_handle->qdf_dev->dev,
3606 num_units * unit_len,
3607 &paddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 if (wma_handle->mem_chunks[idx].vaddr == NULL) {
3609 num_units = (num_units >> 1);/* reduce length by half */
3610 } else {
3611 wma_handle->mem_chunks[idx].paddr = paddr;
3612 wma_handle->mem_chunks[idx].len = num_units * unit_len;
3613 wma_handle->mem_chunks[idx].req_id = req_id;
3614 }
3615 }
3616 return num_units;
3617}
3618
3619#define HOST_MEM_SIZE_UNIT 4
3620/**
3621 * wma_alloc_host_mem() - allocate amount of memory requested by FW.
3622 * @wma_handle: wma handle
3623 * @req_id: request id
3624 * @num_units: number of units
3625 * @unit_len: unit length
3626 *
3627 * Return: none
3628 */
3629static void wma_alloc_host_mem(tp_wma_handle wma_handle, uint32_t req_id,
3630 uint32_t num_units, uint32_t unit_len)
3631{
3632 uint32_t remaining_units, allocated_units, idx;
3633
3634 /* adjust the length to nearest multiple of unit size */
3635 unit_len = (unit_len + (HOST_MEM_SIZE_UNIT - 1)) &
3636 (~(HOST_MEM_SIZE_UNIT - 1));
3637 idx = wma_handle->num_mem_chunks;
3638 remaining_units = num_units;
3639 while (remaining_units) {
3640 allocated_units = wma_alloc_host_mem_chunk(wma_handle, req_id,
3641 idx, remaining_units,
3642 unit_len);
3643 if (allocated_units == 0) {
3644 WMA_LOGE("FAILED TO ALLOCATED memory unit len %d"
3645 " units requested %d units allocated %d ",
3646 unit_len, num_units,
3647 (num_units - remaining_units));
3648 wma_handle->num_mem_chunks = idx;
3649 break;
3650 }
3651 remaining_units -= allocated_units;
3652 ++idx;
3653 if (idx == MAX_MEM_CHUNKS) {
3654 WMA_LOGE("RWACHED MAX CHUNK LIMIT for memory units %d"
3655 " unit len %d requested by FW,"
3656 " only allocated %d ",
3657 num_units, unit_len,
3658 (num_units - remaining_units));
3659 wma_handle->num_mem_chunks = idx;
3660 break;
3661 }
3662 }
3663 wma_handle->num_mem_chunks = idx;
3664}
3665
3666/**
3667 * wma_update_target_services() - update target services from wma handle
3668 * @wh: wma handle
3669 * @cfg: target services
3670 *
3671 * Return: none
3672 */
3673static inline void wma_update_target_services(tp_wma_handle wh,
3674 struct wma_tgt_services *cfg)
3675{
3676 /* STA power save */
3677 cfg->sta_power_save = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3678 WMI_SERVICE_STA_PWRSAVE);
3679
3680 /* Enable UAPSD */
3681 cfg->uapsd = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3682 WMI_SERVICE_AP_UAPSD);
3683
3684 /* Update AP DFS service */
3685 cfg->ap_dfs = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3686 WMI_SERVICE_AP_DFS);
3687
3688 /* Enable 11AC */
3689 cfg->en_11ac = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3690 WMI_SERVICE_11AC);
3691 if (cfg->en_11ac)
3692 g_fw_wlan_feat_caps |= (1 << DOT11AC);
3693
3694 /* Proactive ARP response */
3695 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
3696
3697 /* Enable WOW */
3698 g_fw_wlan_feat_caps |= (1 << WOW);
3699
3700 /* ARP offload */
3701 cfg->arp_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3702 WMI_SERVICE_ARPNS_OFFLOAD);
3703
3704 /* Adaptive early-rx */
3705 cfg->early_rx = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3706 WMI_SERVICE_EARLY_RX);
3707#ifdef FEATURE_WLAN_SCAN_PNO
3708 /* PNO offload */
3709 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NLO))
3710 cfg->pno_offload = true;
3711#endif /* FEATURE_WLAN_SCAN_PNO */
3712
3713#ifdef FEATURE_WLAN_EXTSCAN
3714 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_EXTSCAN)) {
3715 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
3716 }
3717#endif /* FEATURE_WLAN_EXTSCAN */
3718 cfg->lte_coex_ant_share = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3719 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT);
3720#ifdef FEATURE_WLAN_TDLS
3721 /* Enable TDLS */
3722 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_TDLS)) {
3723 cfg->en_tdls = 1;
3724 g_fw_wlan_feat_caps |= (1 << TDLS);
3725 }
3726 /* Enable advanced TDLS features */
3727 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3728 WMI_SERVICE_TDLS_OFFCHAN)) {
3729 cfg->en_tdls_offchan = 1;
3730 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
3731 }
3732
3733 cfg->en_tdls_uapsd_buf_sta =
3734 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3735 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA);
3736 cfg->en_tdls_uapsd_sleep_sta =
3737 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3738 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA);
3739#endif /* FEATURE_WLAN_TDLS */
3740 if (WMI_SERVICE_IS_ENABLED
3741 (wh->wmi_service_bitmap, WMI_SERVICE_BEACON_OFFLOAD))
3742 cfg->beacon_offload = true;
mukul sharma72c8b222015-09-04 17:02:01 +05303743 if (WMI_SERVICE_IS_ENABLED
3744 (wh->wmi_service_bitmap, WMI_SERVICE_STA_PMF_OFFLOAD))
3745 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3747 /* Enable Roam Offload */
3748 cfg->en_roam_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3749 WMI_SERVICE_ROAM_HO_OFFLOAD);
3750#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3751#ifdef WLAN_FEATURE_NAN
3752 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NAN))
3753 g_fw_wlan_feat_caps |= (1 << NAN);
3754#endif /* WLAN_FEATURE_NAN */
3755
3756 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_RTT))
3757 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07003758
3759 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3760 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT)) {
3761 ol_cfg_set_ipa_uc_tx_partition_base((ol_pdev_handle)
3762 ((p_cds_contextType) wh->cds_context)->cfg_ctx,
3763 HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
3764 WMA_LOGI("%s: TX_MSDU_ID_NEW_PARTITION=%d", __func__,
3765 HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
3766 } else {
3767 ol_cfg_set_ipa_uc_tx_partition_base((ol_pdev_handle)
3768 ((p_cds_contextType) wh->cds_context)->cfg_ctx,
3769 HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
3770 WMA_LOGI("%s: TX_MSDU_ID_OLD_PARTITION=%d", __func__,
3771 HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
3772 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003773}
3774
3775/**
3776 * wma_update_target_ht_cap() - update ht capabality from wma handle
3777 * @wh: wma handle
3778 * @cfg: ht capabality
3779 *
3780 * Return: none
3781 */
3782static inline void wma_update_target_ht_cap(tp_wma_handle wh,
3783 struct wma_tgt_ht_cap *cfg)
3784{
3785 /* RX STBC */
3786 cfg->ht_rx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_RX_STBC);
3787
3788 /* TX STBC */
3789 cfg->ht_tx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_TX_STBC);
3790
3791 /* MPDU density */
3792 cfg->mpdu_density = wh->ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
3793
3794 /* HT RX LDPC */
3795 cfg->ht_rx_ldpc = !!(wh->ht_cap_info & WMI_HT_CAP_LDPC);
3796
3797 /* HT SGI */
3798 cfg->ht_sgi_20 = !!(wh->ht_cap_info & WMI_HT_CAP_HT20_SGI);
3799
3800 cfg->ht_sgi_40 = !!(wh->ht_cap_info & WMI_HT_CAP_HT40_SGI);
3801
3802 /* RF chains */
3803 cfg->num_rf_chains = wh->num_rf_chains;
3804
3805 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n\
3806 mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n\
3807 ht_sgi_40 - %d num_rf_chains - %d ", __func__, wh->ht_cap_info,
3808 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
3809 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
3810 cfg->num_rf_chains);
3811
3812}
3813
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814/**
3815 * wma_update_target_vht_cap() - update vht capabality from wma handle
3816 * @wh: wma handle
3817 * @cfg: vht capabality
3818 *
3819 * Return: none
3820 */
3821static inline void wma_update_target_vht_cap(tp_wma_handle wh,
3822 struct wma_tgt_vht_cap *cfg)
3823{
3824
3825 if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
3826 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
3827 else if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
3828 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
3829 else
3830 cfg->vht_max_mpdu = 0;
3831
3832
3833 if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
3834 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
3835 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
3836 } else if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ)
3837 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
3838 else
3839 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
3840
3841 cfg->vht_rx_ldpc = wh->vht_cap_info & WMI_VHT_CAP_RX_LDPC;
3842
3843 cfg->vht_short_gi_80 = wh->vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
3844 cfg->vht_short_gi_160 = wh->vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
3845
3846 cfg->vht_tx_stbc = wh->vht_cap_info & WMI_VHT_CAP_TX_STBC;
3847
3848 cfg->vht_rx_stbc = (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
3849 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
3850 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS) ;
3851
3852 cfg->vht_max_ampdu_len_exp = (wh->vht_cap_info &
3853 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
3854 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
3855
3856 cfg->vht_su_bformer = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
3857
3858 cfg->vht_su_bformee = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
3859
3860 cfg->vht_mu_bformer = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
3861
3862 cfg->vht_mu_bformee = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
3863
3864 cfg->vht_txop_ps = wh->vht_cap_info & WMI_VHT_CAP_TXOP_PS;
3865
3866 WMA_LOGD(" %s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n \
3867 short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n \
3868 su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
3869 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
3870 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
3871 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
3872 cfg->vht_max_ampdu_len_exp);
3873}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874
3875/**
Krunal Soniaa664da2016-06-15 23:46:40 -07003876 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
3877 * @wma_handle: pointer to wma_handle
3878 * @ht_cap: given pointer to HT caps which needs to be updated
3879 * @tx_chain: given tx chainmask value
3880 * @rx_chain: given rx chainmask value
3881 * @value: new HT cap info provided in form of bitmask
3882 *
3883 * This function takes the value provided in form of bitmask and decodes
3884 * it. After decoding, what ever value it gets, it takes the union(max) or
3885 * intersection(min) with previously derived values.
3886 *
3887 * Return: none
3888 *
3889 */
3890static void wma_derive_ext_ht_cap(tp_wma_handle wma_handle,
3891 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
3892 uint32_t tx_chain, uint32_t rx_chain)
3893{
3894 struct wma_tgt_ht_cap tmp = {0};
3895
3896 if (NULL == wma_handle || NULL == ht_cap)
3897 return;
3898
Ankit Guptaa5076012016-09-14 11:32:19 -07003899 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07003900 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
3901 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
3902 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
3903 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
3904 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
3905 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
3906 ht_cap->num_rf_chains =
3907 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
3908 wma_get_num_of_setbits_from_bitmask(rx_chain));
3909 } else {
3910 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
3911 (!!(value & WMI_HT_CAP_RX_STBC)));
3912 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
3913 (!!(value & WMI_HT_CAP_TX_STBC)));
3914 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
3915 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
3916 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
3917 (!!(value & WMI_HT_CAP_RX_LDPC)));
3918 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
3919 (!!(value & WMI_HT_CAP_HT20_SGI)));
3920 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
3921 (!!(value & WMI_HT_CAP_HT40_SGI)));
3922 ht_cap->num_rf_chains =
3923 QDF_MAX(ht_cap->num_rf_chains,
3924 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
3925 tx_chain),
3926 wma_get_num_of_setbits_from_bitmask(
3927 rx_chain)));
3928 }
3929}
3930
3931/**
3932 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
3933 * @wma_handle: pointer to wma_handle
3934 * @ht_cap: HT cap structure to be filled
3935 *
3936 * This function loop through each hardware mode and for each hardware mode
3937 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
3938 * HT caps and derives the final cap.
3939 *
3940 * Return: none
3941 *
3942 */
3943static void wma_update_target_ext_ht_cap(tp_wma_handle wma_handle,
3944 struct wma_tgt_ht_cap *ht_cap)
3945{
3946 int i, j = 0, max_mac;
3947 uint32_t ht_2g, ht_5g;
3948 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
3949 struct extended_caps *phy_caps;
3950 WMI_MAC_PHY_CAPABILITIES *mac_cap;
3951
3952 /*
3953 * for legacy device extended cap might not even come, so in that case
3954 * don't overwrite legacy values
3955 */
3956 if (!wma_handle ||
3957 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
3958 WMA_LOGI("%s: No extended HT cap for current SOC", __func__);
3959 return;
3960 }
3961
3962 phy_caps = &wma_handle->phy_caps;
3963 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
3964 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
3965 max_mac = j + 2;
3966 else
3967 max_mac = j + 1;
3968 for ( ; j < max_mac; j++) {
3969 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
3970 ht_2g = mac_cap->ht_cap_info_2G;
3971 ht_5g = mac_cap->ht_cap_info_5G;
3972 if (ht_2g)
3973 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
3974 ht_2g, mac_cap->tx_chain_mask_2G,
3975 mac_cap->rx_chain_mask_2G);
3976 if (ht_5g)
3977 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
3978 ht_5g, mac_cap->tx_chain_mask_5G,
3979 mac_cap->rx_chain_mask_5G);
3980 }
3981 }
3982
Ankit Guptaa5076012016-09-14 11:32:19 -07003983 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07003984 sizeof(struct wma_tgt_ht_cap))) {
3985 qdf_mem_copy(ht_cap, &tmp_ht_cap,
3986 sizeof(struct wma_tgt_ht_cap));
3987 }
3988
3989 WMA_LOGI("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n\
3990 mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n\
3991 ht_sgi_40 - %d num_rf_chains - %d ", __func__,
3992 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
3993 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
3994 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
3995 ht_cap->num_rf_chains);
3996}
3997
3998/**
3999 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
4000 * @wma_handle: pointer to wma_handle
4001 * @vht_cap: pointer to given VHT caps to be filled
4002 * @value: new VHT cap info provided in form of bitmask
4003 *
4004 * This function takes the value provided in form of bitmask and decodes
4005 * it. After decoding, what ever value it gets, it takes the union(max) or
4006 * intersection(min) with previously derived values.
4007 *
4008 * Return: none
4009 *
4010 */
4011static void wma_derive_ext_vht_cap(t_wma_handle *wma_handle,
4012 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
4013{
4014 struct wma_tgt_vht_cap tmp_cap = {0};
4015 uint32_t tmp = 0;
4016
4017 if (NULL == wma_handle || NULL == vht_cap)
4018 return;
4019
Ankit Guptaa5076012016-09-14 11:32:19 -07004020 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004021 sizeof(struct wma_tgt_vht_cap))) {
4022 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4023 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4024 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4025 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4026 else
4027 vht_cap->vht_max_mpdu = 0;
4028
4029 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
4030 vht_cap->supp_chan_width =
4031 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4032 vht_cap->supp_chan_width |=
4033 1 << eHT_CHANNEL_WIDTH_160MHZ;
4034 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4035 vht_cap->supp_chan_width =
4036 1 << eHT_CHANNEL_WIDTH_160MHZ;
4037 } else {
4038 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4039 }
4040 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
4041 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
4042 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
4043 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
4044 vht_cap->vht_rx_stbc =
4045 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4046 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4047 (value & WMI_VHT_CAP_RX_STBC_3SS);
4048 vht_cap->vht_max_ampdu_len_exp =
4049 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4050 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4051 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
4052 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
4053 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
4054 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
4055 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
4056 } else {
4057 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4058 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4059 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4060 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4061 else
4062 tmp = 0;
4063 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
4064
4065 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
4066 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
4067 (1 << eHT_CHANNEL_WIDTH_160MHZ);
4068 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4069 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
4070 } else {
4071 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4072 }
4073 vht_cap->supp_chan_width =
4074 QDF_MAX(vht_cap->supp_chan_width, tmp);
4075 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
4076 value & WMI_VHT_CAP_RX_LDPC);
4077 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
4078 value & WMI_VHT_CAP_SGI_80MHZ);
4079 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
4080 value & WMI_VHT_CAP_SGI_160MHZ);
4081 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
4082 value & WMI_VHT_CAP_TX_STBC);
4083 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
4084 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4085 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4086 (value & WMI_VHT_CAP_RX_STBC_3SS));
4087 vht_cap->vht_max_ampdu_len_exp =
4088 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
4089 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4090 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
4091 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
4092 value & WMI_VHT_CAP_SU_BFORMER);
4093 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
4094 value & WMI_VHT_CAP_SU_BFORMEE);
4095 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
4096 value & WMI_VHT_CAP_MU_BFORMER);
4097 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
4098 value & WMI_VHT_CAP_MU_BFORMEE);
4099 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
4100 value & WMI_VHT_CAP_TXOP_PS);
4101 }
4102}
4103
4104/**
4105 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
4106 * @wma_handle: pointer to wma_handle
4107 * @vht_cap: VHT cap structure to be filled
4108 *
4109 * This function loop through each hardware mode and for each hardware mode
4110 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
4111 * VHT caps and derives the final cap.
4112 *
4113 * Return: none
4114 *
4115 */
4116static void wma_update_target_ext_vht_cap(t_wma_handle *wma_handle,
4117 struct wma_tgt_vht_cap *vht_cap)
4118{
4119 int i, j = 0, max_mac;
4120 uint32_t vht_cap_info_2g, vht_cap_info_5g;
4121 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
4122 struct extended_caps *phy_caps;
4123 WMI_MAC_PHY_CAPABILITIES *mac_cap;
4124
4125 /*
4126 * for legacy device extended cap might not even come, so in that case
4127 * don't overwrite legacy values
4128 */
4129 if (!wma_handle ||
4130 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
4131 WMA_LOGI("%s: No extended VHT cap for current SOC", __func__);
4132 return;
4133 }
4134
4135 phy_caps = &wma_handle->phy_caps;
4136 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
4137 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
4138 max_mac = j + 2;
4139 else
4140 max_mac = j + 1;
4141 for ( ; j < max_mac; j++) {
4142 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
4143 vht_cap_info_2g = mac_cap->vht_cap_info_2G;
4144 vht_cap_info_5g = mac_cap->vht_cap_info_5G;
4145 if (vht_cap_info_2g)
4146 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4147 vht_cap_info_2g);
4148 if (vht_cap_info_5g)
4149 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4150 vht_cap_info_5g);
4151 }
4152 }
4153
Ankit Guptaa5076012016-09-14 11:32:19 -07004154 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004155 sizeof(struct wma_tgt_vht_cap))) {
4156 qdf_mem_copy(vht_cap, &tmp_vht_cap,
4157 sizeof(struct wma_tgt_vht_cap));
4158 }
4159
4160 WMA_LOGI("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n \
4161 short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n \
4162 su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
4163 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
4164 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
4165 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
4166 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
4167 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
4168}
4169
4170/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304171 * wma_update_ra_rate_limit() - update wma config
4172 * @wma_handle: wma handle
4173 * @cfg: target config
4174 *
4175 * Return: none
4176 */
4177#ifdef FEATURE_WLAN_RA_FILTERING
4178static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4179 struct wma_tgt_cfg *cfg)
4180{
4181 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
4182}
4183#else
4184static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4185 struct wma_tgt_cfg *cfg)
4186{
4187}
4188#endif
4189
4190/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 * wma_update_hdd_cfg() - update HDD config
4192 * @wma_handle: wma handle
4193 *
4194 * Return: none
4195 */
4196static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
4197{
4198 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304199 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304201 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07004202
4203 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
4205 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
4206
4207 switch (wma_handle->phy_capability) {
4208 case WMI_11G_CAPABILITY:
4209 case WMI_11NG_CAPABILITY:
4210 tgt_cfg.band_cap = eCSR_BAND_24;
4211 break;
4212 case WMI_11A_CAPABILITY:
4213 case WMI_11NA_CAPABILITY:
4214 case WMI_11AC_CAPABILITY:
4215 tgt_cfg.band_cap = eCSR_BAND_5G;
4216 break;
4217 case WMI_11AG_CAPABILITY:
4218 case WMI_11NAG_CAPABILITY:
4219 default:
4220 tgt_cfg.band_cap = eCSR_BAND_ALL;
4221 }
4222
4223 tgt_cfg.max_intf_count = wma_handle->wlan_resource_config.num_vdevs;
4224
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304225 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 ATH_MAC_LEN);
4227
4228 wma_update_target_services(wma_handle, &tgt_cfg.services);
4229 wma_update_target_ht_cap(wma_handle, &tgt_cfg.ht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230 wma_update_target_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07004231 /*
4232 * This will overwrite the structure filled by wma_update_target_ht_cap
4233 * and wma_update_target_vht_cap APIs.
4234 */
4235 wma_update_target_ext_ht_cap(wma_handle, &tgt_cfg.ht_cap);
4236 wma_update_target_ext_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237
4238 tgt_cfg.target_fw_version = wma_handle->target_fw_version;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07004239 tgt_cfg.target_fw_vers_ext = wma_handle->target_fw_vers_ext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240#ifdef WLAN_FEATURE_LPSS
4241 tgt_cfg.lpss_support = wma_handle->lpss_support;
4242#endif /* WLAN_FEATURE_LPSS */
4243 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Rajeev Kumare5a16822016-07-27 13:11:42 -07004244 tgt_cfg.bpf_enabled = wma_handle->bpf_enabled;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304245 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004246 tgt_cfg.fine_time_measurement_cap =
4247 wma_handle->fine_time_measurement_cap;
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05304248 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
4249 - WMI_TLV_HEADROOM;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08004250 wma_setup_egap_support(&tgt_cfg, wma_handle);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004251
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07004252 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07004253 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254}
4255
4256/**
4257 * wma_setup_wmi_init_msg() - fill wmi init message buffer
4258 * @wma_handle: wma handle
4259 * @ev: ready event fixed params
4260 * @param_buf: redy event TLVs
4261 * @len: buffer length
4262 *
4263 * Return: wmi buffer or NULL for error
4264 */
Govind Singhf25a0f12016-03-08 16:09:48 +05304265static int wma_setup_wmi_init_msg(tp_wma_handle wma_handle,
4266 wmi_service_ready_event_fixed_param *ev,
4267 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 wlan_host_mem_req *ev_mem_reqs;
4270 wmi_abi_version my_vers;
Govind Singhf25a0f12016-03-08 16:09:48 +05304271 wmi_abi_version host_abi_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 int num_whitelist;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 uint16_t idx;
4274 uint32_t num_units;
4275
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 ev_mem_reqs = param_buf->mem_reqs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277
4278 /* allocate memory requested by FW */
4279 if (ev->num_mem_reqs > WMI_MAX_MEM_REQS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304280 QDF_ASSERT(0);
Govind Singhf25a0f12016-03-08 16:09:48 +05304281 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 }
4283
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 for (idx = 0; idx < ev->num_mem_reqs; ++idx) {
4285 num_units = ev_mem_reqs[idx].num_units;
4286 if (ev_mem_reqs[idx].num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4287 /*
4288 * number of units to allocate is number
4289 * of peers, 1 extra for self peer on
4290 * target. this needs to be fied, host
4291 * and target can get out of sync
4292 */
Govind Singhf25a0f12016-03-08 16:09:48 +05304293 num_units = wma_handle->wlan_resource_config.num_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 }
4295 WMA_LOGD
4296 ("idx %d req %d num_units %d num_unit_info %d unit size %d actual units %d ",
4297 idx, ev_mem_reqs[idx].req_id,
4298 ev_mem_reqs[idx].num_units,
4299 ev_mem_reqs[idx].num_unit_info,
4300 ev_mem_reqs[idx].unit_size, num_units);
4301 wma_alloc_host_mem(wma_handle, ev_mem_reqs[idx].req_id,
4302 num_units, ev_mem_reqs[idx].unit_size);
4303 }
Govind Singhf25a0f12016-03-08 16:09:48 +05304304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304305 qdf_mem_copy(&wma_handle->target_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306 &param_buf->fixed_param->fw_abi_vers,
4307 sizeof(wmi_abi_version));
4308 num_whitelist = sizeof(version_whitelist) /
4309 sizeof(wmi_whitelist_version_info);
4310 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
4311 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
4312 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
4313 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
4314 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
4315 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
4316
4317 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
4318 &my_vers,
4319 &param_buf->fixed_param->fw_abi_vers,
Govind Singhf25a0f12016-03-08 16:09:48 +05304320 &host_abi_vers);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004321
Govind Singhf25a0f12016-03-08 16:09:48 +05304322 qdf_mem_copy(&wma_handle->final_abi_vers, &host_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 sizeof(wmi_abi_version));
Govind Singhf25a0f12016-03-08 16:09:48 +05304324
4325 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004326}
4327
4328/**
4329 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
4330 * @wma_handle: WMA handle
4331 *
4332 * Prints the DBS HW modes sent by the FW as part
4333 * of WMI ready event
4334 *
4335 * Return: None
4336 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004337static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338{
4339 uint32_t i, param;
4340
4341 if (!wma_handle) {
4342 WMA_LOGE("%s: Invalid WMA handle", __func__);
4343 return;
4344 }
4345
4346 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
4347 param = wma_handle->hw_mode.hw_mode_list[i];
4348 WMA_LOGA("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
4349 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304350 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
4351 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
4352 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 WMA_LOGA("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
4354 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304355 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
4356 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
4357 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
4358 WMA_LOGA("%s:[%d] DBS:%d SBS:%d", __func__, i,
4359 WMA_HW_MODE_DBS_MODE_GET(param),
4360 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004361 }
4362}
4363
4364/**
4365 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
4366 * @wma_handle: WMA handle
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304367 * @scan_config: Scam mode configuration
4368 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 *
4370 * Enables all the valid bits of concurrent_scan_config_bits and
4371 * fw_mode_config_bits.
4372 *
4373 * Return: None
4374 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004375static void wma_init_scan_fw_mode_config(tp_wma_handle wma_handle,
4376 uint32_t scan_config,
4377 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378{
Anurag Chouhan6d760662016-02-20 16:05:43 +05304379 tpAniSirGlobal mac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380
4381 WMA_LOGD("%s: Enter", __func__);
4382
4383 if (!mac) {
4384 WMA_LOGE("%s: Invalid mac handle", __func__);
4385 return;
4386 }
4387
4388 if (!wma_handle) {
4389 WMA_LOGE("%s: Invalid WMA handle", __func__);
4390 return;
4391 }
4392
4393 wma_handle->dual_mac_cfg.cur_scan_config = 0;
4394 wma_handle->dual_mac_cfg.cur_fw_mode_config = 0;
4395
4396 /* If dual mac features are disabled in the INI, we
4397 * need not proceed further
4398 */
4399 if (mac->dual_mac_feature_disable) {
4400 WMA_LOGE("%s: Disabling dual mac capabilities", __func__);
4401 /* All capabilites are initialized to 0. We can return */
4402 goto done;
4403 }
4404
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304405 /* Initialize concurrent_scan_config_bits with default FW value */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304407 wma_handle->dual_mac_cfg.cur_scan_config,
4408 WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_GET(scan_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304410 wma_handle->dual_mac_cfg.cur_scan_config,
4411 WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_GET(scan_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304413 wma_handle->dual_mac_cfg.cur_scan_config,
4414 WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_GET(scan_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304416 /* Initialize fw_mode_config_bits with default FW value */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 WMI_DBS_FW_MODE_CFG_DBS_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304418 wma_handle->dual_mac_cfg.cur_fw_mode_config,
4419 WMI_DBS_FW_MODE_CFG_DBS_GET(fw_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 WMI_DBS_FW_MODE_CFG_AGILE_DFS_SET(
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304421 wma_handle->dual_mac_cfg.cur_fw_mode_config,
4422 WMI_DBS_FW_MODE_CFG_AGILE_DFS_GET(fw_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423done:
4424 /* Initialize the previous scan/fw mode config */
4425 wma_handle->dual_mac_cfg.prev_scan_config =
4426 wma_handle->dual_mac_cfg.cur_scan_config;
4427 wma_handle->dual_mac_cfg.prev_fw_mode_config =
4428 wma_handle->dual_mac_cfg.cur_fw_mode_config;
4429
4430 WMA_LOGD("%s: cur_scan_config:%x cur_fw_mode_config:%x",
4431 __func__,
4432 wma_handle->dual_mac_cfg.cur_scan_config,
4433 wma_handle->dual_mac_cfg.cur_fw_mode_config);
4434}
4435
4436/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304437 * wma_update_ra_limit() - update ra limit based on bpf filter
4438 * enabled or not
4439 * @handle: wma handle
4440 *
4441 * Return: none
4442 */
4443#ifdef FEATURE_WLAN_RA_FILTERING
4444static void wma_update_ra_limit(tp_wma_handle wma_handle)
4445{
4446 if (wma_handle->bpf_enabled)
4447 wma_handle->IsRArateLimitEnabled = false;
4448}
4449#else
4450static void wma_update_ra__limit(tp_wma_handle handle)
4451{
4452}
4453#endif
4454
4455/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456 * wma_rx_service_ready_event() - event handler to process
4457 * wmi rx sevice ready event.
4458 * @handle: wma handle
4459 * @cmd_param_info: command params info
4460 *
4461 * Return: none
4462 */
Govind Singhd76a5b02016-03-08 15:12:14 +05304463int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
4464 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 tp_wma_handle wma_handle = (tp_wma_handle) handle;
4467 struct wma_target_cap target_cap;
4468 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
4469 wmi_service_ready_event_fixed_param *ev;
4470 int status;
4471 uint32_t *ev_wlan_dbs_hw_mode_list;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304472 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473
4474 WMA_LOGD("%s: Enter", __func__);
4475
4476 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
4477 if (!(handle && param_buf)) {
4478 WMA_LOGP("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304479 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 }
4481
4482 ev = param_buf->fixed_param;
4483 if (!ev) {
4484 WMA_LOGP("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304485 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 }
4487
4488 WMA_LOGA("WMA <-- WMI_SERVICE_READY_EVENTID");
4489
4490 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
4491 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
4492 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304493 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 wma_handle->num_dbs_hw_modes);
4495 if (!wma_handle->hw_mode.hw_mode_list) {
4496 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
4497 /* Continuing with the rest of the processing */
4498 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304499 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500 ev_wlan_dbs_hw_mode_list,
4501 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
4502 wma_handle->num_dbs_hw_modes));
4503
4504 wma_dump_dbs_hw_mode(wma_handle);
4505
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304506 /* Initializes the fw_mode and scan_config to zero.
4507 * If ext service ready event is present it will set
4508 * the actual values of these two params.
4509 * This is to ensure that no garbage values would be
4510 * present in the absence of ext service ready event.
4511 */
4512 wma_init_scan_fw_mode_config(wma_handle, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513
4514 wma_handle->phy_capability = ev->phy_capability;
4515 wma_handle->max_frag_entry = ev->max_frag_entry;
4516 wma_handle->num_rf_chains = ev->num_rf_chains;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304517 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 sizeof(HAL_REG_CAPABILITIES));
4519 wma_handle->ht_cap_info = ev->ht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 wma_handle->vht_cap_info = ev->vht_cap_info;
4521 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 wma_handle->num_rf_chains = ev->num_rf_chains;
4523
4524 wma_handle->target_fw_version = ev->fw_build_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 wma_handle->new_hw_mode_index = ev->default_dbs_hw_mode_index;
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004526 wma_handle->fine_time_measurement_cap = ev->wmi_fw_sub_feat_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527
4528 WMA_LOGD("%s: Firmware default hw mode index : %d",
4529 __func__, ev->default_dbs_hw_mode_index);
4530 WMA_LOGE("%s: Firmware build version : %08x",
4531 __func__, ev->fw_build_vers);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004532 WMA_LOGD(FL("FW fine time meas cap: 0x%x"), ev->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533
4534 if (ev->hw_bd_id) {
4535 wma_handle->hw_bd_id = ev->hw_bd_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304536 qdf_mem_copy(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 ev->hw_bd_info, sizeof(ev->hw_bd_info));
4538
4539 WMA_LOGE("%s: Board version: %x.%x",
4540 __func__,
4541 wma_handle->hw_bd_info[0], wma_handle->hw_bd_info[1]);
4542 } else {
4543 wma_handle->hw_bd_id = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304544 qdf_mem_zero(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 sizeof(wma_handle->hw_bd_info));
4546 WMA_LOGE("%s: Board version is unknown!", __func__);
4547 }
Rakesh Sunki8641f8a2015-12-10 15:11:19 -08004548 wma_handle->dfs_ic->dfs_hw_bd_id = wma_handle->hw_bd_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549
4550 /* TODO: Recheck below line to dump service ready event */
4551 /* dbg_print_wmi_service_11ac(ev); */
4552
4553 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304554 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 param_buf->wmi_service_bitmap,
4556 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05304557
4558 ol_tx_set_is_mgmt_over_wmi_enabled(
4559 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4560 WMI_SERVICE_MGMT_TX_WMI));
Nirav Shah2ae038d2015-12-23 20:36:11 +05304561 ol_tx_set_desc_global_pool_size(ev->num_msdu_desc);
Nirav Shah22bf44d2015-12-10 15:39:48 +05304562
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 /* SWBA event handler for beacon transmission */
4564 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4565 WMI_HOST_SWBA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304566 wma_beacon_swba_handler,
4567 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 if (status) {
4569 WMA_LOGE("Failed to register swba beacon event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304570 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 }
4572#ifdef WLAN_FEATURE_LPSS
4573 wma_handle->lpss_support =
4574 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4575 WMI_SERVICE_LPASS);
4576#endif /* WLAN_FEATURE_LPSS */
4577
4578 /*
4579 * This Service bit is added to check for ARP/NS Offload
4580 * support for LL/HL targets
4581 */
4582 wma_handle->ap_arpns_support =
4583 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4584 WMI_SERVICE_AP_ARPNS_OFFLOAD);
4585
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304586 wma_handle->bpf_enabled = (wma_handle->bpf_packet_filter_enable &&
Rajeev Kumare5a16822016-07-27 13:11:42 -07004587 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304588 WMI_SERVICE_BPF_OFFLOAD));
4589 wma_update_ra_limit(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004590 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4591 WMI_SERVICE_CSA_OFFLOAD)) {
4592 WMA_LOGD("%s: FW support CSA offload capability", __func__);
4593 status =
4594 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304595 WMI_CSA_HANDLING_EVENTID,
4596 wma_csa_offload_handler,
4597 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 if (status) {
4599 WMA_LOGE("Failed to register CSA offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304600 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 }
4602 }
4603
4604 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4605 WMI_SERVICE_MGMT_TX_WMI)) {
4606 WMA_LOGE("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
4607 status = wmi_desc_pool_init(wma_handle, WMI_DESC_POOL_MAX);
4608 if (status) {
4609 WMA_LOGE("Failed to initialize wmi descriptor pool");
Govind Singhd76a5b02016-03-08 15:12:14 +05304610 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 }
4612 /*
4613 * Register Tx completion event handler for MGMT Tx over WMI
4614 * case
4615 */
4616 status = wmi_unified_register_event_handler(
4617 wma_handle->wmi_handle,
4618 WMI_MGMT_TX_COMPLETION_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304619 wma_mgmt_tx_completion_handler,
4620 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 if (status) {
4622 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Govind Singhd76a5b02016-03-08 15:12:14 +05304623 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624 }
4625
Nirav Shah20489972016-06-16 19:20:28 +05304626 status = wmi_unified_register_event_handler(
4627 wma_handle->wmi_handle,
4628 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID,
4629 wma_mgmt_tx_bundle_completion_handler,
4630 WMA_RX_SERIALIZER_CTX);
4631 if (status) {
4632 WMA_LOGE("Failed to register MGMT over WMI completion handler");
4633 return -EINVAL;
4634 }
4635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 } else {
4637 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
4638 }
4639#ifdef WLAN_FEATURE_GTK_OFFLOAD
4640 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4641 WMI_SERVICE_GTK_OFFLOAD)) {
4642 status =
4643 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304644 WMI_GTK_OFFLOAD_STATUS_EVENTID,
4645 wma_gtk_offload_status_event,
4646 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 if (status) {
4648 WMA_LOGE("Failed to register GTK offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304649 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 }
4651 }
4652#endif /* WLAN_FEATURE_GTK_OFFLOAD */
4653
4654 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4655 WMI_P2P_NOA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304656 wma_p2p_noa_event_handler,
4657 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 if (status) {
4659 WMA_LOGE("Failed to register WMI_P2P_NOA_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05304660 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661 }
4662 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304663 WMI_TBTTOFFSET_UPDATE_EVENTID,
4664 wma_tbttoffset_update_event_handler,
4665 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 if (status) {
4667 WMA_LOGE
4668 ("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05304669 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 }
4671
Govind Singhefc5ccd2016-04-25 11:11:55 +05304672 /* mac_id is replaced with pdev_id in converged firmware to have
4673 * multi-radio support. In order to maintain backward compatibility
4674 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
4675 * in service bitmap from FW and host needs to set use_pdev_id in
4676 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
4677 * service is not set, then host shall not expect MAC ID from FW in
4678 * VDEV START RESPONSE event and host shall use PDEV ID.
4679 */
4680 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4681 WMI_SERVICE_DEPRECATED_REPLACE))
4682 wma_handle->wlan_resource_config.use_pdev_id = true;
4683 else
4684 wma_handle->wlan_resource_config.use_pdev_id = false;
4685
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08004686 /* register the Enhanced Green AP event handler */
4687 wma_register_egap_event_handle(wma_handle);
4688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004689 /* Initialize the log supported event handler */
4690 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4691 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304692 wma_log_supported_evt_handler,
4693 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304694 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 WMA_LOGE("Failed to register log supported event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304696 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004697 }
4698
Himanshu Agarwal19141bb2016-07-20 20:15:48 +05304699 ol_tx_mark_first_wakeup_packet(
4700 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4701 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET));
4702
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07004703 wma_handle->nan_datapath_enabled =
4704 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4705 WMI_SERVICE_NAN_DATA);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304706 qdf_mem_copy(target_cap.wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 param_buf->wmi_service_bitmap,
4708 sizeof(wma_handle->wmi_service_bitmap));
4709 target_cap.wlan_resource_config = wma_handle->wlan_resource_config;
4710 wma_update_fw_config(wma_handle, &target_cap);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304711 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 target_cap.wmi_service_bitmap,
4713 sizeof(wma_handle->wmi_service_bitmap));
4714 wma_handle->wlan_resource_config = target_cap.wlan_resource_config;
4715
Govind Singhf25a0f12016-03-08 16:09:48 +05304716 status = wmi_unified_save_fw_version_cmd(wma_handle->wmi_handle,
4717 param_buf);
4718 if (status != EOK) {
4719 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
4720 return -EINVAL;
4721 }
4722
4723 status = wma_setup_wmi_init_msg(wma_handle, ev, param_buf);
4724 if (status != EOK) {
4725 WMA_LOGE("Failed to setup for wma init command");
Govind Singhd76a5b02016-03-08 15:12:14 +05304726 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 }
4728
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304729 /* A host, which supports WMI_SERVICE_READY_EXT_EVENTID, would need to
4730 * check the WMI_SERVICE_READY message for an "extension" flag, and if
4731 * this flag is set, then hold off on sending the WMI_INIT message until
4732 * WMI_SERVICE_READY_EXT_EVENTID is received.
4733 */
4734 if (!WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4735 WMI_SERVICE_EXT_MSG)) {
4736 /* No service extended message support.
4737 * Send INIT command immediately
4738 */
4739 WMA_LOGA("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05304740 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
4741 &wma_handle->wlan_resource_config,
4742 wma_handle->num_mem_chunks,
4743 wma_handle->mem_chunks, 1);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304744 if (status != EOK) {
4745 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Govind Singhd76a5b02016-03-08 15:12:14 +05304746 return -EINVAL;
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304747 }
4748 } else {
Govind Singhf25a0f12016-03-08 16:09:48 +05304749 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
4750 &wma_handle->wlan_resource_config,
4751 wma_handle->num_mem_chunks,
4752 wma_handle->mem_chunks, 0);
4753 if (status != EOK) {
4754 WMA_LOGE("Failed to save WMI_INIT_CMDID command parameter");
4755 return -EINVAL;
4756 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304757 /* The saved 'buf' will be freed after sending INIT command or
4758 * in other cases as required
4759 */
Anurag Chouhan210db072016-02-22 18:42:15 +05304760 ret = qdf_mc_timer_start(&wma_handle->service_ready_ext_timer,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304761 WMA_SERVICE_READY_EXT_TIMEOUT);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304762 if (!QDF_IS_STATUS_SUCCESS(ret))
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304763 WMA_LOGP("Failed to start the service ready ext timer");
4764
4765 WMA_LOGA("%s: WMA waiting for WMI_SERVICE_READY_EXT_EVENTID",
4766 __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767 }
Govind Singhd76a5b02016-03-08 15:12:14 +05304768
4769 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770}
4771
4772/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07004773 * wma_get_phyid_for_given_band() - to get phyid for band
4774 *
4775 * @wma_handle: Pointer to wma handle
4776 * @map: Pointer to map which is derived from hw mode & has mapping between
4777 * hw mode and available PHYs for that hw mode.
4778 * @band: enum value of for 2G or 5G band
4779 * @phyid: Pointer to phyid which needs to be filled
4780 *
4781 * This API looks in to the map to find out which particular phy supports
4782 * provided band and return the idx (also called phyid) of that phy. Caller
4783 * use this phyid to fetch various caps of that phy
4784 *
4785 * Return: QDF_STATUS
4786 */
4787static QDF_STATUS wma_get_phyid_for_given_band(
4788 t_wma_handle * wma_handle,
4789 struct hw_mode_idx_to_mac_cap_idx *map,
4790 enum cds_band_type band, uint8_t *phyid)
4791{
4792 uint8_t idx, i;
4793 WMI_MAC_PHY_CAPABILITIES *cap;
4794
4795 if (!wma_handle) {
4796 WMA_LOGE("Invalid wma handle");
4797 return QDF_STATUS_E_FAILURE;
4798 }
4799
4800 if (!map) {
4801 WMA_LOGE("Invalid given map");
4802 return QDF_STATUS_E_FAILURE;
4803 }
4804 idx = map->mac_cap_idx;
4805 *phyid = idx;
4806
4807 for (i = 0; i < map->num_of_macs; i++) {
4808 cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[idx + i];
4809 if ((band == CDS_BAND_2GHZ) &&
4810 (WLAN_2G_CAPABILITY == cap->supported_bands)) {
4811 *phyid = idx + i;
4812 WMA_LOGI("Select 2G capable phyid[%d]", *phyid);
4813 return QDF_STATUS_SUCCESS;
4814 } else if ((band == CDS_BAND_5GHZ) &&
4815 (WLAN_5G_CAPABILITY == cap->supported_bands)) {
4816 *phyid = idx + i;
4817 WMA_LOGI("Select 5G capable phyid[%d]", *phyid);
4818 return QDF_STATUS_SUCCESS;
4819 }
4820 }
4821 WMA_LOGI("Using default single hw mode phyid[%d]", *phyid);
4822 return QDF_STATUS_SUCCESS;
4823}
4824
4825/**
4826 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
4827 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
4828 * @hw_mode: Provided hardware mode
4829 * @band: Provide band i.e. 2G or 5G
4830 *
4831 * This API finds cap which suitable for provided hw mode and band. If user
4832 * is provides some invalid hw mode then it will automatically falls back to
4833 * default hw mode
4834 *
4835 * Return: QDF_STATUS
4836 */
4837QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
4838 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
4839{
4840 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
4841 struct hw_mode_idx_to_mac_cap_idx *map;
4842 WMI_MAC_PHY_CAPABILITIES *phy_cap;
4843 uint8_t phyid, our_hw_mode = hw_mode;
4844
4845 if (!wma_handle) {
4846 WMA_LOGE("Invalid wma handle");
4847 return QDF_STATUS_E_FAILURE;
4848 }
4849
4850 if (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes) {
4851 WMA_LOGE("Invalid number of hw modes");
4852 return QDF_STATUS_E_FAILURE;
4853 }
4854
4855 if (!wma_is_dbs_enable())
4856 our_hw_mode = HW_MODE_DBS_NONE;
4857
4858 if (!caps_per_phy) {
4859 WMA_LOGE("Invalid caps pointer");
4860 return QDF_STATUS_E_FAILURE;
4861 }
4862
4863 map = &wma_handle->phy_caps.hw_mode_to_mac_cap_map[our_hw_mode];
4864
4865 if (QDF_STATUS_SUCCESS !=
4866 wma_get_phyid_for_given_band(wma_handle, map, band, &phyid)) {
4867 WMA_LOGE("Invalid phyid");
4868 return QDF_STATUS_E_FAILURE;
4869 }
4870 phy_cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[phyid];
4871
4872 caps_per_phy->ht_2g = phy_cap->ht_cap_info_2G;
4873 caps_per_phy->ht_5g = phy_cap->ht_cap_info_5G;
4874 caps_per_phy->vht_2g = phy_cap->vht_cap_info_2G;
4875 caps_per_phy->vht_5g = phy_cap->vht_cap_info_5G;
4876 caps_per_phy->he_2g = phy_cap->he_cap_info_2G;
4877 caps_per_phy->he_5g = phy_cap->he_cap_info_5G;
4878
4879 return QDF_STATUS_SUCCESS;
4880}
4881
4882/**
4883 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
4884 *
4885 * @channel: Channel number for which it needs to check if rx ldpc is enabled
4886 *
4887 * This API takes channel number as argument and takes default hw mode as DBS
4888 * to check if rx LDPC support is enabled for that channel or no
4889 */
4890bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
4891{
4892 struct wma_caps_per_phy caps_per_phy = {0};
4893 enum cds_band_type band;
4894 bool status;
4895
4896 if (!CDS_IS_CHANNEL_24GHZ(channel))
4897 band = CDS_BAND_5GHZ;
4898 else
4899 band = CDS_BAND_2GHZ;
4900
4901 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
4902 &caps_per_phy,
4903 HW_MODE_DBS, band)) {
4904 return false;
4905 }
4906 if (CDS_IS_CHANNEL_24GHZ(channel))
4907 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
4908 else
4909 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
4910
4911 return status;
4912}
4913
4914
4915/**
Krunal Soni2e48d012016-05-02 16:55:26 -07004916 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
4917 * @wma_handle: pointer to wma_handle
4918 *
4919 * This function prints all the caps populater per hw mode and per PHY
4920 *
4921 * Return: none
4922 */
4923static void wma_print_populate_soc_caps(t_wma_handle *wma_handle)
4924{
4925 int i, j = 0, max_mac;
4926 WMI_MAC_PHY_CAPABILITIES *tmp;
4927
4928 /* print number of hw modes */
4929 WMA_LOGI("%s: num of hw modes [%d]", __func__,
4930 wma_handle->phy_caps.num_hw_modes.num_hw_modes);
4931 WMA_LOGI("%s: <====== HW mode cap printing starts ======>", __func__);
4932 /* print cap of each hw mode */
4933 for (i = 0; i < wma_handle->phy_caps.num_hw_modes.num_hw_modes; i++) {
4934 WMA_LOGI("====>: hw mode id[%d], phy_id map[%d]",
4935 wma_handle->phy_caps.each_hw_mode_cap[i].hw_mode_id,
4936 wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map);
4937 if (wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map ==
4938 PHY1_PHY2)
4939 max_mac = j + 2;
4940 else
4941 max_mac = j + 1;
4942
4943 for ( ; j < max_mac; j++) {
4944 tmp = &wma_handle->phy_caps.each_phy_cap_per_hwmode[j];
4945 WMA_LOGI("\t: index j[%d]", j);
4946 WMA_LOGI("\t: cap for hw_mode_id[%d]", tmp->hw_mode_id);
4947 WMA_LOGI("\t: pdev_id[%d]", tmp->pdev_id);
4948 WMA_LOGI("\t: phy_id[%d]", tmp->phy_id);
4949 WMA_LOGI("\t: supports_11b[%d]",
4950 WMI_SUPPORT_11B_GET(tmp->supported_flags));
4951 WMA_LOGI("\t: supports_11g[%d]",
4952 WMI_SUPPORT_11G_GET(tmp->supported_flags));
4953 WMA_LOGI("\t: supports_11a[%d]",
4954 WMI_SUPPORT_11A_GET(tmp->supported_flags));
4955 WMA_LOGI("\t: supports_11n[%d]",
4956 WMI_SUPPORT_11N_GET(tmp->supported_flags));
4957 WMA_LOGI("\t: supports_11ac[%d]",
4958 WMI_SUPPORT_11AC_GET(tmp->supported_flags));
4959 WMA_LOGI("\t: supports_11ax[%d]",
4960 WMI_SUPPORT_11AX_GET(tmp->supported_flags));
4961 WMA_LOGI("\t: supported_flags[%d]",
4962 tmp->supported_flags);
4963 WMA_LOGI("\t: supported_bands[%d]",
4964 tmp->supported_bands);
4965 WMA_LOGI("\t: ampdu_density[%d]",
4966 tmp->ampdu_density);
4967 WMA_LOGI("\t: max_bw_supported_2G[%d]",
4968 tmp->max_bw_supported_2G);
4969 WMA_LOGI("\t: ht_cap_info_2G[%d]", tmp->ht_cap_info_2G);
4970 WMA_LOGI("\t: vht_cap_info_2G[%d]",
4971 tmp->vht_cap_info_2G);
4972 WMA_LOGI("\t: he_cap_info_2G[%d]", tmp->he_cap_info_2G);
4973 WMA_LOGI("\t: vht_supp_mcs_2G[%d]",
4974 tmp->vht_supp_mcs_2G);
4975 WMA_LOGI("\t: he_supp_mcs_2G[%d]", tmp->he_supp_mcs_2G);
4976 WMA_LOGI("\t: tx_chain_mask_2G[%d]",
4977 tmp->tx_chain_mask_2G);
4978 WMA_LOGI("\t: rx_chain_mask_2G[%d]",
4979 tmp->rx_chain_mask_2G);
4980 WMA_LOGI("\t: max_bw_supported_5G[%d]",
4981 tmp->max_bw_supported_5G);
4982 WMA_LOGI("\t: ht_cap_info_5G[%d]",
4983 tmp->ht_cap_info_5G);
4984 WMA_LOGI("\t: vht_cap_info_5G[%d]",
4985 tmp->vht_cap_info_5G);
4986 WMA_LOGI("\t: he_cap_info_5G[%d]", tmp->he_cap_info_5G);
4987 WMA_LOGI("\t: vht_supp_mcs_5G[%d]",
4988 tmp->vht_supp_mcs_5G);
4989 WMA_LOGI("\t: he_supp_mcs_5G[%d]", tmp->he_supp_mcs_5G);
4990 WMA_LOGI("\t: tx_chain_mask_5G[%d]",
4991 tmp->tx_chain_mask_5G);
4992 WMA_LOGI("\t: rx_chain_mask_5G[%d]",
4993 tmp->rx_chain_mask_5G);
4994 }
4995 }
4996 WMA_LOGI("%s: <====== HW mode cap printing ends ======>\n", __func__);
4997}
4998
4999/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305000 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
5001 * in terms of hw_mode_bandwidth
5002 * @width: bandwidth in terms of wmi_channel_width
5003 *
5004 * This function returns the bandwidth in terms of hw_mode_bandwidth.
5005 *
5006 * Return: BW in terms of hw_mode_bandwidth.
5007 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005008static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305009 wmi_channel_width width)
5010{
5011 switch (width) {
5012 case WMI_CHAN_WIDTH_20:
5013 return HW_MODE_20_MHZ;
5014 case WMI_CHAN_WIDTH_40:
5015 return HW_MODE_40_MHZ;
5016 case WMI_CHAN_WIDTH_80:
5017 return HW_MODE_80_MHZ;
5018 case WMI_CHAN_WIDTH_160:
5019 return HW_MODE_160_MHZ;
5020 case WMI_CHAN_WIDTH_80P80:
5021 return HW_MODE_80_PLUS_80_MHZ;
5022 case WMI_CHAN_WIDTH_5:
5023 return HW_MODE_5_MHZ;
5024 case WMI_CHAN_WIDTH_10:
5025 return HW_MODE_10_MHZ;
5026 default:
5027 return HW_MODE_BW_NONE;
5028 }
5029
5030 return HW_MODE_BW_NONE;
5031}
5032
5033/**
5034 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
5035 * supported from the capabilities.
5036 * @caps: PHY capability
5037 * @info: param to store TX-RX stream and BW information
5038 *
5039 * This function will calculate TX-RX stream and bandwidth supported
5040 * as per the PHY capability, and assign to mac_ss_bw_info.
5041 *
5042 * Return: none
5043 */
5044static void wma_get_hw_mode_params(WMI_MAC_PHY_CAPABILITIES *caps,
5045 struct mac_ss_bw_info *info)
5046{
5047 if (!caps) {
5048 WMA_LOGE("%s: Invalid capabilities", __func__);
5049 return;
5050 }
5051
5052 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
5053 QDF_MAX(caps->tx_chain_mask_2G,
5054 caps->tx_chain_mask_5G));
5055 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
5056 QDF_MAX(caps->rx_chain_mask_2G,
5057 caps->rx_chain_mask_5G));
5058 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
5059 QDF_MAX(caps->max_bw_supported_2G,
5060 caps->max_bw_supported_5G));
5061}
5062
5063/**
5064 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
5065 * DBS in hw_mode_list
5066 * @wma_handle: pointer to wma global structure
5067 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
5068 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
5069 * @pos: refers to hw_mode_index
5070 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305071 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305072 *
5073 * This function sets TX-RX stream, bandwidth and DBS mode in
5074 * hw_mode_list.
5075 *
5076 * Return: none
5077 */
5078static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
5079 struct mac_ss_bw_info mac0_ss_bw_info,
5080 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305081 uint32_t pos, uint32_t dbs_mode,
5082 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305083{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305084 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305085 wma_handle->hw_mode.hw_mode_list[pos],
5086 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305087 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305088 wma_handle->hw_mode.hw_mode_list[pos],
5089 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305090 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305091 wma_handle->hw_mode.hw_mode_list[pos],
5092 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305093 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305094 wma_handle->hw_mode.hw_mode_list[pos],
5095 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305096 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305097 wma_handle->hw_mode.hw_mode_list[pos],
5098 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305099 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305100 wma_handle->hw_mode.hw_mode_list[pos],
5101 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305102 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305103 wma_handle->hw_mode.hw_mode_list[pos],
5104 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305105 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305106 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305107 HW_MODE_AGILE_DFS_NONE);
5108 WMA_HW_MODE_SBS_MODE_SET(
5109 wma_handle->hw_mode.hw_mode_list[pos],
5110 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305111}
5112
5113/**
5114 * wma_update_hw_mode_list() - updates hw_mode_list
5115 * @wma_handle: pointer to wma global structure
5116 *
5117 * This function updates hw_mode_list with tx_streams, rx_streams,
5118 * bandwidth, dbs and agile dfs for each hw_mode.
5119 *
5120 * Returns: 0 for success else failure.
5121 */
5122static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle)
5123{
5124 struct extended_caps *phy_caps;
5125 WMI_MAC_PHY_CAPABILITIES *tmp;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305126 uint32_t i, hw_config_type, j = 0;
5127 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305128 struct mac_ss_bw_info mac0_ss_bw_info = {0};
5129 struct mac_ss_bw_info mac1_ss_bw_info = {0};
5130
5131 if (!wma_handle) {
5132 WMA_LOGE("%s: Invalid wma handle", __func__);
5133 return QDF_STATUS_E_FAILURE;
5134 }
5135
5136 phy_caps = &wma_handle->phy_caps;
5137 if (!phy_caps) {
5138 WMA_LOGE("%s: Invalid phy capabilities", __func__);
5139 return QDF_STATUS_SUCCESS;
5140 }
5141
5142 if (!phy_caps->num_hw_modes.num_hw_modes) {
5143 WMA_LOGE("%s: Number of HW modes: %d",
5144 __func__, phy_caps->num_hw_modes.num_hw_modes);
5145 return QDF_STATUS_SUCCESS;
5146 }
5147
5148 /*
5149 * This list was updated as part of service ready event. Re-populate
5150 * HW mode list from the device capabilities.
5151 */
5152 if (wma_handle->hw_mode.hw_mode_list) {
5153 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
5154 wma_handle->hw_mode.hw_mode_list = NULL;
5155 WMA_LOGI("%s: DBS list is freed", __func__);
5156 }
5157
5158 wma_handle->num_dbs_hw_modes = phy_caps->num_hw_modes.num_hw_modes;
5159 wma_handle->hw_mode.hw_mode_list =
5160 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
5161 wma_handle->num_dbs_hw_modes);
5162 if (!wma_handle->hw_mode.hw_mode_list) {
5163 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
5164 return QDF_STATUS_E_FAILURE;
5165 }
5166
5167 WMA_LOGA("%s: Updated HW mode list: Num modes:%d",
5168 __func__, wma_handle->num_dbs_hw_modes);
5169
5170 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5171 /* Update for MAC0 */
5172 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5173 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
5174 hw_config_type =
5175 phy_caps->each_hw_mode_cap[i].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305176 dbs_mode = HW_MODE_DBS_NONE;
5177 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305178 mac1_ss_bw_info.mac_tx_stream = 0;
5179 mac1_ss_bw_info.mac_rx_stream = 0;
5180 mac1_ss_bw_info.mac_bw = 0;
5181
5182 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
5183 if ((hw_config_type == WMI_HW_MODE_DBS) ||
5184 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5185 (hw_config_type == WMI_HW_MODE_SBS)) {
5186 /* Update for MAC1 */
5187 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5188 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305189 if (hw_config_type == WMI_HW_MODE_DBS)
5190 dbs_mode = HW_MODE_DBS;
5191 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5192 (hw_config_type == WMI_HW_MODE_SBS))
5193 sbs_mode = HW_MODE_SBS;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305194 }
5195
5196 /* Updating HW mode list */
5197 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305198 mac1_ss_bw_info, i, dbs_mode,
5199 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305200 }
5201 wma_dump_dbs_hw_mode(wma_handle);
5202 return QDF_STATUS_SUCCESS;
5203}
5204
5205/**
Krunal Soni2e48d012016-05-02 16:55:26 -07005206 * wma_populate_soc_caps() - populate entire SOC's capabilities
5207 * @wma_handle: pointer to wma global structure
5208 * @param_buf: pointer to param of service ready extension event from fw
5209 *
5210 * This API populates all capabilities of entire SOC. For example,
5211 * how many number of hw modes are supported by this SOC, what are the
5212 * capabilities of each phy per hw mode, what are HAL reg capabilities per
5213 * phy.
5214 *
5215 * Return: none
5216 */
5217static void wma_populate_soc_caps(t_wma_handle *wma_handle,
5218 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
5219{
5220 int i, num_of_mac_caps = 0, tmp = 0;
5221 struct extended_caps *phy_caps;
5222 struct hw_mode_idx_to_mac_cap_idx *map;
5223
5224 WMA_LOGD("%s: Enter", __func__);
5225
5226 if (!wma_handle) {
5227 WMA_LOGP("%s: Invalid WMA handle", __func__);
5228 return;
5229 }
5230
5231 if (!param_buf) {
5232 WMA_LOGP("%s: Invalid event", __func__);
5233 return;
5234 }
5235 phy_caps = &wma_handle->phy_caps;
5236
5237 /*
5238 * first thing to do is to get how many number of hw modes are
5239 * supported and populate in wma_handle global structure
5240 */
Krunal Sonifd85ba62016-07-11 08:18:53 -07005241 if (NULL == param_buf->soc_hw_mode_caps) {
5242 WMA_LOGE("%s: Invalid number of hw modes", __func__);
5243 return;
5244 }
5245
Krunal Soni2e48d012016-05-02 16:55:26 -07005246 qdf_mem_copy(&phy_caps->num_hw_modes,
5247 param_buf->soc_hw_mode_caps,
5248 sizeof(WMI_SOC_MAC_PHY_HW_MODE_CAPS));
5249 if (0 == phy_caps->num_hw_modes.num_hw_modes) {
Krunal Sonifd85ba62016-07-11 08:18:53 -07005250 WMA_LOGE("%s: Number of hw modes is zero", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005251 return;
Krunal Soni2e48d012016-05-02 16:55:26 -07005252 }
Krunal Sonifd85ba62016-07-11 08:18:53 -07005253 WMA_LOGI("%s: Given number of hw modes[%d]",
5254 __func__, phy_caps->num_hw_modes.num_hw_modes);
Krunal Soni2e48d012016-05-02 16:55:26 -07005255
5256 /*
5257 * next thing is to allocate the memory to map hw mode to phy/mac caps
5258 */
5259 phy_caps->hw_mode_to_mac_cap_map =
5260 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5261 sizeof(struct hw_mode_idx_to_mac_cap_idx));
5262 if (!phy_caps->hw_mode_to_mac_cap_map) {
5263 WMA_LOGE("%s: Memory allocation failed", __func__);
5264 return;
5265 }
5266
5267 /*
5268 * next thing is to allocate the memory for per hw caps
5269 */
5270 phy_caps->each_hw_mode_cap =
5271 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5272 sizeof(WMI_HW_MODE_CAPABILITIES));
5273 if (!phy_caps->each_hw_mode_cap) {
5274 WMA_LOGE("%s: Memory allocation failed", __func__);
5275 wma_cleanup_dbs_phy_caps(wma_handle);
5276 return;
5277 }
5278 qdf_mem_copy(phy_caps->each_hw_mode_cap,
5279 param_buf->hw_mode_caps,
5280 phy_caps->num_hw_modes.num_hw_modes *
5281 sizeof(WMI_HW_MODE_CAPABILITIES));
5282 /*
5283 * next thing is to count the number of mac cap to populate per
5284 * hw mode and generate map, so that our search can be done
5285 * efficiently which is O(1)
5286 */
5287 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
5288 map = &phy_caps->hw_mode_to_mac_cap_map[i];
5289 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2) {
5290 tmp = num_of_mac_caps;
5291 num_of_mac_caps = num_of_mac_caps + 2;
5292 map->num_of_macs = 2;
5293 } else {
5294 tmp = num_of_mac_caps;
5295 num_of_mac_caps = num_of_mac_caps + 1;
5296 map->num_of_macs = 1;
5297 }
5298 map->mac_cap_idx = tmp;
5299 map->hw_mode_id = phy_caps->each_hw_mode_cap[i].hw_mode_id;
5300 }
5301
5302 /*
5303 * next thing is to populate each phy caps per hw mode
5304 */
5305 phy_caps->each_phy_cap_per_hwmode =
5306 qdf_mem_malloc(num_of_mac_caps *
5307 sizeof(WMI_MAC_PHY_CAPABILITIES));
5308 if (!phy_caps->each_phy_cap_per_hwmode) {
5309 WMA_LOGE("%s: Memory allocation failed", __func__);
5310 wma_cleanup_dbs_phy_caps(wma_handle);
5311 return;
5312 }
5313 qdf_mem_copy(phy_caps->each_phy_cap_per_hwmode,
5314 param_buf->mac_phy_caps,
5315 num_of_mac_caps * sizeof(WMI_MAC_PHY_CAPABILITIES));
5316
5317 /*
5318 * next thing is to populate reg caps per phy
5319 */
5320 qdf_mem_copy(&phy_caps->num_phy_for_hal_reg_cap,
5321 param_buf->soc_hal_reg_caps,
5322 sizeof(WMI_SOC_HAL_REG_CAPABILITIES));
5323 if (phy_caps->num_phy_for_hal_reg_cap.num_phy == 0) {
5324 WMA_LOGE("%s: incorrect number of phys", __func__);
5325 wma_cleanup_dbs_phy_caps(wma_handle);
5326 return;
5327 }
5328 phy_caps->each_phy_hal_reg_cap =
5329 qdf_mem_malloc(phy_caps->num_phy_for_hal_reg_cap.num_phy *
5330 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
5331 if (!phy_caps->each_phy_hal_reg_cap) {
5332 WMA_LOGE("%s: Memory allocation failed", __func__);
5333 wma_cleanup_dbs_phy_caps(wma_handle);
5334 return;
5335 }
5336 qdf_mem_copy(phy_caps->each_phy_hal_reg_cap,
5337 param_buf->hal_reg_caps,
5338 phy_caps->num_phy_for_hal_reg_cap.num_phy *
5339 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
5340 wma_print_populate_soc_caps(wma_handle);
5341 return;
5342}
5343
5344/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
5346 * @handle: wma handle
5347 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05305348 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 *
5350 * Return: none
5351 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305352int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
5353 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354{
5355 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5356 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
5357 wmi_service_ready_ext_event_fixed_param *ev;
5358 int status;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305359 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360
5361 WMA_LOGD("%s: Enter", __func__);
5362
5363 if (!wma_handle) {
5364 WMA_LOGP("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305365 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 }
5367
5368 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
5369 if (!param_buf) {
5370 WMA_LOGP("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305371 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372 }
5373
5374 ev = param_buf->fixed_param;
5375 if (!ev) {
5376 WMA_LOGP("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305377 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378 }
5379
5380 WMA_LOGA("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
5381
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305382 WMA_LOGA("%s: Defaults: scan config:%x FW mode config:%x",
5383 __func__, ev->default_conc_scan_config_bits,
5384 ev->default_fw_config_bits);
5385
Anurag Chouhan210db072016-02-22 18:42:15 +05305386 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305387 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305388 WMA_LOGP("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05305389 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390 }
Krunal Soni2e48d012016-05-02 16:55:26 -07005391 wma_populate_soc_caps(wma_handle, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305393 ret = wma_update_hw_mode_list(wma_handle);
5394 if (QDF_IS_STATUS_ERROR(ret)) {
5395 WMA_LOGE("Failed to update hw mode list");
5396 return -EINVAL;
5397 }
5398
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 WMA_LOGA("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05305400 status = wmi_unified_send_saved_init_cmd(wma_handle->wmi_handle);
5401 if (status != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 /* In success case, WMI layer will free after getting copy
5403 * engine TX complete interrupt
5404 */
5405 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305407 wma_init_scan_fw_mode_config(wma_handle,
5408 ev->default_conc_scan_config_bits,
5409 ev->default_fw_config_bits);
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07005410 wma_handle->target_fw_vers_ext = ev->fw_build_vers_ext;
Govind Singhd76a5b02016-03-08 15:12:14 +05305411 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412}
5413
5414/**
5415 * wma_rx_ready_event() - event handler to process
5416 * wmi rx ready event.
5417 * @handle: wma handle
5418 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05305419 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005420 *
5421 * Return: none
5422 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305423int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
5424 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005425{
5426 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5427 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
5428 wmi_ready_event_fixed_param *ev = NULL;
5429
5430 WMA_LOGD("%s: Enter", __func__);
5431
5432 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
5433 if (!(wma_handle && param_buf)) {
5434 WMA_LOGP("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305435 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05305436 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005437 }
5438
5439 WMA_LOGA("WMA <-- WMI_READY_EVENTID");
5440
5441 ev = param_buf->fixed_param;
5442 /* Indicate to the waiting thread that the ready
5443 * event was received */
Naveen Rawat64e477e2016-05-20 10:34:56 -07005444 wma_handle->sub_20_support =
5445 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5446 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 wma_handle->wmi_ready = true;
5448 wma_handle->wlan_init_status = ev->status;
5449
5450 /*
5451 * We need to check the WMI versions and make sure both
5452 * host and fw are compatible.
5453 */
5454 if (!wmi_versions_are_compatible(&wma_handle->final_abi_vers,
5455 &ev->fw_abi_vers)) {
5456 /*
5457 * Error: Our host version and the given firmware version
5458 * are incompatible.
5459 */
5460 WMA_LOGE("%s: Error: Incompatible WMI version."
5461 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x",
5462 __func__,
5463 WMI_VER_GET_MAJOR(wma_handle->final_abi_vers.
5464 abi_version_0),
5465 WMI_VER_GET_MINOR(wma_handle->final_abi_vers.
5466 abi_version_0),
5467 wma_handle->final_abi_vers.abi_version_ns_0,
5468 wma_handle->final_abi_vers.abi_version_ns_1,
5469 wma_handle->final_abi_vers.abi_version_ns_2,
5470 wma_handle->final_abi_vers.abi_version_ns_3,
5471 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
5472 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
5473 ev->fw_abi_vers.abi_version_ns_0,
5474 ev->fw_abi_vers.abi_version_ns_1,
5475 ev->fw_abi_vers.abi_version_ns_2,
5476 ev->fw_abi_vers.abi_version_ns_3);
5477 if (wma_handle->wlan_init_status == WLAN_INIT_STATUS_SUCCESS) {
5478 /* Failed this connection to FW */
5479 wma_handle->wlan_init_status =
5480 WLAN_INIT_STATUS_GEN_FAILED;
5481 }
5482 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305483 qdf_mem_copy(&wma_handle->final_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005484 sizeof(wmi_abi_version));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305485 qdf_mem_copy(&wma_handle->target_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 sizeof(wmi_abi_version));
5487
5488 /* copy the mac addr */
5489 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
5490 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
5491
5492 wma_update_hdd_cfg(wma_handle);
5493
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305494 qdf_event_set(&wma_handle->wma_ready_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495
5496 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05305497
5498 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499}
5500
5501/**
5502 * wma_setneedshutdown() - setting wma needshutdown flag
5503 * @cds_ctx: cds context
5504 *
5505 * Return: none
5506 */
5507void wma_setneedshutdown(void *cds_ctx)
5508{
5509 tp_wma_handle wma_handle;
5510
5511 WMA_LOGD("%s: Enter", __func__);
5512
Anurag Chouhan6d760662016-02-20 16:05:43 +05305513 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514
5515 if (NULL == wma_handle) {
5516 WMA_LOGP("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305517 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518 return;
5519 }
5520
5521 wma_handle->needShutdown = true;
5522 WMA_LOGD("%s: Exit", __func__);
5523}
5524
5525/**
5526 * wma_needshutdown() - Is wma needs shutdown?
5527 * @cds_ctx: cds context
5528 *
5529 * Return: returns true/false
5530 */
5531bool wma_needshutdown(void *cds_ctx)
5532{
5533 tp_wma_handle wma_handle;
5534
5535 WMA_LOGD("%s: Enter", __func__);
5536
Anurag Chouhan6d760662016-02-20 16:05:43 +05305537 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538
5539 if (NULL == wma_handle) {
5540 WMA_LOGP("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305541 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542 return false;
5543 }
5544
5545 WMA_LOGD("%s: Exit", __func__);
5546 return wma_handle->needShutdown;
5547}
5548
5549/**
5550 * wma_wait_for_ready_event() - wait for wma ready event
5551 * @handle: wma handle
5552 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305553 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305555QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556{
5557 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305558 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559
5560 /* wait until WMI_READY_EVENTID received from FW */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305561 qdf_status = qdf_wait_single_event(&(wma_handle->wma_ready_event),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005562 WMA_READY_EVENTID_TIMEOUT);
5563
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305564 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 WMA_LOGP("%s: Timeout waiting for ready event from FW",
5566 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305567 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305569 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570}
5571
5572/**
5573 * wma_set_ppsconfig() - set pps config in fw
5574 * @vdev_id: vdev id
5575 * @pps_param: pps params
5576 * @val : param value
5577 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305578 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005579 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305580QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005581 int val)
5582{
Anurag Chouhan6d760662016-02-20 16:05:43 +05305583 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 int ret = -EIO;
5585 uint32_t pps_val;
5586
5587 if (NULL == wma) {
5588 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305589 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005590 }
5591
5592 switch (pps_param) {
5593 case WMA_VHT_PPS_PAID_MATCH:
5594 pps_val = ((val << 31) & 0xffff0000) |
5595 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
5596 goto pkt_pwr_save_config;
5597 case WMA_VHT_PPS_GID_MATCH:
5598 pps_val = ((val << 31) & 0xffff0000) |
5599 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
5600 goto pkt_pwr_save_config;
5601 case WMA_VHT_PPS_DELIM_CRC_FAIL:
5602 pps_val = ((val << 31) & 0xffff0000) |
5603 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
5604 goto pkt_pwr_save_config;
5605
5606 /* Enable the code below as and when the functionality
5607 * is supported/added in host.
5608 */
5609#ifdef NOT_YET
5610 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
5611 pps_val = ((val << 31) & 0xffff0000) |
5612 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
5613 goto pkt_pwr_save_config;
5614 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
5615 pps_val = ((val << 31) & 0xffff0000) |
5616 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
5617 goto pkt_pwr_save_config;
5618 case WMA_VHT_PPS_EOF_PAD_DELIM:
5619 pps_val = ((val << 31) & 0xffff0000) |
5620 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
5621 goto pkt_pwr_save_config;
5622 case WMA_VHT_PPS_MACADDR_MISMATCH:
5623 pps_val = ((val << 31) & 0xffff0000) |
5624 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
5625 goto pkt_pwr_save_config;
5626 case WMA_VHT_PPS_GID_NSTS_ZERO:
5627 pps_val = ((val << 31) & 0xffff0000) |
5628 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
5629 goto pkt_pwr_save_config;
5630 case WMA_VHT_PPS_RSSI_CHECK:
5631 pps_val = ((val << 31) & 0xffff0000) |
5632 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
5633 goto pkt_pwr_save_config;
5634#endif /* NOT_YET */
5635pkt_pwr_save_config:
5636 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
5637 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05305638 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 WMI_VDEV_PARAM_PACKET_POWERSAVE,
5640 pps_val);
5641 break;
5642 default:
5643 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
5644 }
5645
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305646 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647}
5648
5649/**
5650 * wma_process_set_mas() - Function to enable/disable MAS
5651 * @wma: Pointer to WMA handle
5652 * @mas_val: 1-Enable MAS, 0-Disable MAS
5653 *
5654 * This function enables/disables the MAS value
5655 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305656 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005658static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
5659 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660{
5661 uint32_t val;
5662
5663 if (NULL == wma || NULL == mas_val) {
5664 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305665 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005666 }
5667
5668 val = (*mas_val);
5669
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305670 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
5672 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305673 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674 } else {
5675 WMA_LOGE("%s: Value is %d", __func__, val);
5676 }
5677
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305678 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679}
5680
5681/**
5682 * wma_process_set_miracast() - Function to set miracast value in WMA
5683 * @wma: Pointer to WMA handle
5684 * @miracast_val: 0-Disabled,1-Source,2-Sink
5685 *
5686 * This function stores the miracast value in WMA
5687 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305688 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005689 *
5690 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005691static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
5692 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693{
5694 if (NULL == wma || NULL == miracast_val) {
5695 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305696 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005697 }
5698
5699 wma->miracast_value = *miracast_val;
5700 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
5701
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305702 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005703}
5704
5705/**
5706 * wma_config_stats_factor() - Function to configure stats avg. factor
5707 * @wma: pointer to WMA handle
5708 * @avg_factor: stats. avg. factor passed down by userspace
5709 *
5710 * This function configures the avg. stats value in firmware
5711 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305712 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 *
5714 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305715static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 struct sir_stats_avg_factor *avg_factor)
5717{
Govind Singhd76a5b02016-03-08 15:12:14 +05305718 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005719
5720 if (NULL == wma || NULL == avg_factor) {
5721 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305722 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005723 }
5724
Govind Singhd76a5b02016-03-08 15:12:14 +05305725 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 avg_factor->vdev_id,
5727 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
5728 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05305729 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005730 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
5731 avg_factor->vdev_id);
5732 }
5733
5734 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
5735 avg_factor->stats_avg_factor, avg_factor->vdev_id);
5736
5737 return ret;
5738}
5739
5740/**
5741 * wma_config_guard_time() - Function to set guard time in firmware
5742 * @wma: pointer to WMA handle
5743 * @guard_time: guard time passed down by userspace
5744 *
5745 * This function configures the guard time in firmware
5746 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305747 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 *
5749 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305750static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005751 struct sir_guard_time_request *guard_time)
5752{
Govind Singhd76a5b02016-03-08 15:12:14 +05305753 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005754
5755 if (NULL == wma || NULL == guard_time) {
5756 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305757 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 }
5759
Govind Singhd76a5b02016-03-08 15:12:14 +05305760 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005761 guard_time->vdev_id,
5762 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
5763 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05305764 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765 WMA_LOGE(" failed to set guard time for vdev_id %d",
5766 guard_time->vdev_id);
5767 }
5768
5769 WMA_LOGD("Set guard time %d for vdev_id %d",
5770 guard_time->guard_time, guard_time->vdev_id);
5771
5772 return ret;
5773}
5774
5775/**
5776 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
5777 * @wma_handle: WMA handle
5778 * @start_log: Start logging related parameters
5779 *
5780 * Send the command to the FW based on which specific logging of diag
5781 * event/log id can be started/stopped
5782 *
5783 * Return: None
5784 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005785static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
5786 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788
5789 if (!start_log) {
5790 WMA_LOGE("%s: start_log pointer is NULL", __func__);
5791 return;
5792 }
5793 if (!wma_handle) {
5794 WMA_LOGE("%s: Invalid wma handle", __func__);
5795 return;
5796 }
5797
5798 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
5799 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
5800 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
5801 __func__, start_log->ring_id);
5802 return;
5803 }
5804
Govind Singhf25a0f12016-03-08 16:09:48 +05305805 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
5806 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 return;
5809}
5810
Poddar, Siddarth176c4362016-10-03 12:25:00 +05305811#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812/**
5813 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
5814 * @wma_handle: WMA handle
5815 * @start_log: Struture containing the start wifi logger params
5816 *
5817 * This function is used to send the WMA commands to start/stop logging
5818 * of per packet statistics
5819 *
5820 * Return: None
5821 *
5822 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005823#ifdef REMOVE_PKT_LOG
5824static void wma_set_wifi_start_packet_stats(void *wma_handle,
5825 struct sir_wifi_start_log *start_log)
5826{
5827 return;
5828}
5829#else
5830static void wma_set_wifi_start_packet_stats(void *wma_handle,
5831 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832{
Komal Seelam3d202862016-02-24 18:43:24 +05305833 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834 uint32_t log_state;
5835
5836 if (!start_log) {
5837 WMA_LOGE("%s: start_log pointer is NULL", __func__);
5838 return;
5839 }
5840 if (!wma_handle) {
5841 WMA_LOGE("%s: Invalid wma handle", __func__);
5842 return;
5843 }
5844
5845 /* No need to register for ring IDs other than packet stats */
5846 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
5847 WMA_LOGI("%s: Ring id is not for per packet stats: %d",
5848 __func__, start_log->ring_id);
5849 return;
5850 }
5851
Anurag Chouhan6d760662016-02-20 16:05:43 +05305852 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07005853 if (scn == NULL) {
5854 WMA_LOGE("%s: Invalid HIF handle", __func__);
5855 return;
5856 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857
5858 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05305859 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
5860 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005861
Poddar, Siddarth176c4362016-10-03 12:25:00 +05305862 if (start_log->size != 0) {
5863 pktlog_setsize(scn, start_log->size * MEGABYTE);
5864 return;
5865 }
5866
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08005868 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05305869 start_log->user_triggered,
5870 start_log->is_iwpriv_command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871 WMA_LOGI("%s: Enabling per packet stats", __func__);
5872 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08005873 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05305874 start_log->user_triggered,
5875 start_log->is_iwpriv_command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005876 WMA_LOGI("%s: Disabling per packet stats", __func__);
5877 }
5878}
5879#endif
5880
5881/**
5882 * wma_send_flush_logs_to_fw() - Send log flush command to FW
5883 * @wma_handle: WMI handle
5884 *
5885 * This function is used to send the flush command to the FW,
5886 * that will flush the fw logs that are residue in the FW
5887 *
5888 * Return: None
5889 */
5890void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
5891{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305892 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893 int ret;
5894
Govind Singhf25a0f12016-03-08 16:09:48 +05305895 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
5896 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005897 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898
Anurag Chouhan210db072016-02-22 18:42:15 +05305899 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005900 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305901 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 WMA_LOGE("Failed to start the log completion timer");
5903}
5904
5905/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05305906 * wma_update_wep_default_key - To update default key id
5907 * @wma: pointer to wma handler
5908 * @update_def_key: pointer to wep_update_default_key_idx
5909 *
5910 * This function makes a copy of default key index to txrx node
5911 *
5912 * Return: Success
5913 */
5914static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
5915 struct wep_update_default_key_idx *update_def_key)
5916{
5917 struct wma_txrx_node *iface =
5918 &wma->interfaces[update_def_key->session_id];
5919 iface->wep_default_key_idx = update_def_key->default_idx;
5920
5921 return QDF_STATUS_SUCCESS;
5922}
5923
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05305924
5925/**
5926 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
5927 * @wma_handle: WMA handle
5928 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
5929 *
5930 * This function is used to set Tx pkt fail count threshold,
5931 * FW will do disconnect with station once this threshold is reached.
5932 *
5933 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
5934 */
5935static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
5936 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
5937{
5938 u_int8_t vdev_id;
5939 u_int32_t tx_fail_disconn_th;
5940 int ret = -EIO;
5941
5942 if (!wma || !wma->wmi_handle) {
5943 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
5944 return QDF_STATUS_E_INVAL;
5945 }
5946 vdev_id = tx_fail_cnt_th->session_id;
5947 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
5948 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
5949 vdev_id, tx_fail_disconn_th);
5950
5951
5952 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
5953 WMI_VDEV_PARAM_DISCONNECT_TH,
5954 tx_fail_disconn_th);
5955
5956 if (ret) {
5957 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
5958 return QDF_STATUS_E_FAILURE;
5959 }
5960
5961 return QDF_STATUS_SUCCESS;
5962}
5963
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05305964/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05305965 * wma_update_short_retry_limit() - Set retry limit for short frames
5966 * @wma_handle: WMA handle
5967 * @short_retry_limit_th: retry limir count for Short frames.
5968 *
5969 * This function is used to configure the transmission retry limit at which
5970 * short frames needs to be retry.
5971 *
5972 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
5973 */
5974static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
5975 struct sme_short_retry_limit *short_retry_limit_th)
5976{
5977 uint8_t vdev_id;
5978 uint32_t short_retry_limit;
5979 int ret;
5980
5981 if (!wma || !wma->wmi_handle) {
5982 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
5983 return QDF_STATUS_E_INVAL;
5984 }
5985 vdev_id = short_retry_limit_th->session_id;
5986 short_retry_limit = short_retry_limit_th->short_retry_limit;
5987 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
5988 vdev_id, short_retry_limit);
5989
5990 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
5991 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
5992 short_retry_limit);
5993
5994 if (ret) {
5995 WMA_LOGE("Failed to send short limit threshold command");
5996 return QDF_STATUS_E_FAILURE;
5997 }
5998 return QDF_STATUS_SUCCESS;
5999}
6000
6001/**
6002 * wma_update_long_retry_limit() - Set retry limit for long frames
6003 * @wma_handle: WMA handle
6004 * @long_retry_limit_th: retry limir count for long frames
6005 *
6006 * This function is used to configure the transmission retry limit at which
6007 * long frames needs to be retry
6008 *
6009 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6010 */
6011static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
6012 struct sme_long_retry_limit *long_retry_limit_th)
6013{
6014 uint8_t vdev_id;
6015 uint32_t long_retry_limit;
6016 int ret;
6017
6018 if (!wma || !wma->wmi_handle) {
6019 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
6020 return QDF_STATUS_E_INVAL;
6021 }
6022 vdev_id = long_retry_limit_th->session_id;
6023 long_retry_limit = long_retry_limit_th->long_retry_limit;
6024 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
6025 vdev_id, long_retry_limit);
6026
6027 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6028 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
6029 long_retry_limit);
6030
6031 if (ret) {
6032 WMA_LOGE("Failed to send long limit threshold command");
6033 return QDF_STATUS_E_FAILURE;
6034 }
6035
6036 return QDF_STATUS_SUCCESS;
6037}
6038
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05306039/*
6040 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
6041 * @wma_handle: WMA handle
6042 * @sta_inactivity_timer: sme_sta_inactivity_timeout
6043 *
6044 * This function is used to set sta_inactivity_timeout.
6045 * If a station does not send anything in sta_inactivity_timeout seconds, an
6046 * empty data frame is sent to it in order to verify whether it is
6047 * still in range. If this frame is not ACKed, the station will be
6048 * disassociated and then deauthenticated.
6049 *
6050 * Return: None
6051 */
6052void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
6053 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
6054{
6055 uint8_t vdev_id;
6056 uint32_t max_unresponsive_time;
6057 uint32_t min_inactive_time, max_inactive_time;
6058
6059 if (!wma || !wma->wmi_handle) {
6060 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
6061 return;
6062 }
6063 vdev_id = sta_inactivity_timer->session_id;
6064 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
6065 max_inactive_time = max_unresponsive_time * TWO_THIRD;
6066 min_inactive_time = max_unresponsive_time - max_inactive_time;
6067
6068 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6069 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
6070 min_inactive_time))
6071 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
6072
6073 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6074 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
6075 max_inactive_time))
6076 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
6077
6078 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6079 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
6080 max_unresponsive_time))
6081 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
6082
6083 WMA_LOGI("%s:vdev_id:%d min_inactive_time: %u max_inactive_time: %u max_unresponsive_time: %u",
6084 __func__, vdev_id,
6085 min_inactive_time, max_inactive_time,
6086 max_unresponsive_time);
6087}
6088
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306089/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006090 * wma_mc_process_msg() - process wma messages and call appropriate function.
6091 * @cds_context: cds context
6092 * @msg: message
6093 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306094 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006095 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306096QDF_STATUS wma_mc_process_msg(void *cds_context, cds_msg_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306098 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099 tp_wma_handle wma_handle;
6100 ol_txrx_vdev_handle txrx_vdev_handle = NULL;
6101 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
6102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006103 if (NULL == msg) {
6104 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306105 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306106 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006107 goto end;
6108 }
6109
6110 WMA_LOGD("msg->type = %x %s", msg->type,
6111 mac_trace_get_wma_msg_string(msg->type));
6112
Anurag Chouhan6d760662016-02-20 16:05:43 +05306113 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006114
6115 if (NULL == wma_handle) {
6116 WMA_LOGP("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306117 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306118 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306119 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 goto end;
6121 }
6122
6123 switch (msg->type) {
6124
6125 /* Message posted by wmi for all control path related
6126 * FW events to serialize through mc_thread.
6127 */
6128 case WMA_PROCESS_FW_EVENT:
6129 wma_process_fw_event(wma_handle,
6130 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306131 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006132 break;
6133
6134#ifdef FEATURE_WLAN_ESE
6135 case WMA_TSM_STATS_REQ:
6136 WMA_LOGA("McThread: WMA_TSM_STATS_REQ");
6137 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
6138 break;
6139#endif /* FEATURE_WLAN_ESE */
6140 case WNI_CFG_DNLD_REQ:
6141 WMA_LOGA("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306142 qdf_status = wma_wni_cfg_dnld(wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05306143 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006144 cds_wma_complete_cback(cds_context);
6145 } else {
6146 WMA_LOGD("config download failure");
6147 }
6148 break;
6149 case WMA_ADD_STA_SELF_REQ:
6150 txrx_vdev_handle =
6151 wma_vdev_attach(wma_handle,
6152 (struct add_sta_self_params *) msg->
6153 bodyptr, 1);
6154 if (!txrx_vdev_handle) {
6155 WMA_LOGE("Failed to attach vdev");
6156 } else {
6157 /* Register with TxRx Module for Data Ack Complete Cb */
6158 ol_txrx_data_tx_cb_set(txrx_vdev_handle,
6159 wma_data_tx_ack_comp_hdlr,
6160 wma_handle);
6161 }
6162 break;
6163 case WMA_DEL_STA_SELF_REQ:
6164 wma_vdev_detach(wma_handle,
6165 (struct del_sta_self_params *) msg->bodyptr, 1);
6166 break;
6167 case WMA_START_SCAN_OFFLOAD_REQ:
6168 wma_start_scan(wma_handle, msg->bodyptr, msg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306169 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006170 break;
6171 case WMA_STOP_SCAN_OFFLOAD_REQ:
6172 wma_stop_scan(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306173 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006174 break;
6175 case WMA_UPDATE_CHAN_LIST_REQ:
6176 wma_update_channel_list(wma_handle,
6177 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306178 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006179 break;
6180 case WMA_SET_LINK_STATE:
6181 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
6182 break;
6183 case WMA_CHNL_SWITCH_REQ:
6184 wma_set_channel(wma_handle,
6185 (tpSwitchChannelParams) msg->bodyptr);
6186 break;
6187 case WMA_ADD_BSS_REQ:
6188 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
6189 break;
6190 case WMA_ADD_STA_REQ:
6191 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
6192 break;
6193 case WMA_SET_BSSKEY_REQ:
6194 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
6195 break;
6196 case WMA_SET_STAKEY_REQ:
6197 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
6198 break;
6199 case WMA_DELETE_STA_REQ:
6200 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
6201 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07006202 case WMA_DELETE_BSS_HO_FAIL_REQ:
6203 wma_delete_bss_ho_fail(wma_handle,
6204 (tpDeleteBssParams) msg->bodyptr);
6205 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006206 case WMA_DELETE_BSS_REQ:
6207 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
6208 break;
6209 case WMA_UPDATE_EDCA_PROFILE_IND:
6210 wma_process_update_edca_param_req(wma_handle,
6211 (tEdcaParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306212 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006213 break;
6214 case WMA_SEND_BEACON_REQ:
6215 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306216 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006217 break;
6218 case WMA_SEND_PROBE_RSP_TMPL:
6219 wma_send_probe_rsp_tmpl(wma_handle,
6220 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306221 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222 break;
6223 case WMA_CLI_SET_CMD:
6224 wma_process_cli_set_cmd(wma_handle,
6225 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306226 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006227 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07006228 case WMA_SET_PDEV_IE_REQ:
6229 wma_process_set_pdev_ie_req(wma_handle,
6230 (struct set_ie_param *)msg->bodyptr);
6231 qdf_mem_free(msg->bodyptr);
6232 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233#if !defined(REMOVE_PKT_LOG)
6234 case WMA_PKTLOG_ENABLE_REQ:
6235 wma_pktlog_wmi_send_cmd(wma_handle,
6236 (struct ath_pktlog_wmi_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306237 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006238 break;
6239#endif /* REMOVE_PKT_LOG */
6240#if defined(QCA_WIFI_FTM)
6241 case WMA_FTM_CMD_REQ:
6242 wma_process_ftm_command(wma_handle,
6243 (struct ar6k_testmode_cmd_data *)msg->bodyptr);
6244 break;
6245#endif /* QCA_WIFI_FTM */
6246 case WMA_ENTER_PS_REQ:
6247 wma_enable_sta_ps_mode(wma_handle,
6248 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306249 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006250 break;
6251 case WMA_EXIT_PS_REQ:
6252 wma_disable_sta_ps_mode(wma_handle,
6253 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306254 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006255 break;
6256 case WMA_ENABLE_UAPSD_REQ:
6257 wma_enable_uapsd_mode(wma_handle,
6258 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306259 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006260 break;
6261 case WMA_DISABLE_UAPSD_REQ:
6262 wma_disable_uapsd_mode(wma_handle,
6263 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306264 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265 break;
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -07006266 case WMA_SET_DTIM_PERIOD:
6267 wma_set_dtim_period(wma_handle,
6268 (struct set_dtim_params *)msg->bodyptr);
6269 qdf_mem_free(msg->bodyptr);
6270 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006271 case WMA_SET_TX_POWER_REQ:
6272 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
6273 break;
6274 case WMA_SET_MAX_TX_POWER_REQ:
6275 wma_set_max_tx_power(wma_handle,
6276 (tpMaxTxPowerParams) msg->bodyptr);
6277 break;
6278 case WMA_SET_KEEP_ALIVE:
6279 wma_set_keepalive_req(wma_handle,
6280 (tSirKeepAliveReq *) msg->bodyptr);
6281 break;
6282#ifdef FEATURE_WLAN_SCAN_PNO
6283 case WMA_SET_PNO_REQ:
6284 wma_config_pno(wma_handle, (tpSirPNOScanReq) msg->bodyptr);
6285 break;
6286
6287 case WMA_SME_SCAN_CACHE_UPDATED:
6288 wma_scan_cache_updated_ind(wma_handle, msg->bodyval);
6289 break;
6290#endif /* FEATURE_WLAN_SCAN_PNO */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08006291#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292 case WMA_SET_PLM_REQ:
6293 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
6294 break;
6295#endif
6296 case WMA_GET_STATISTICS_REQ:
6297 wma_get_stats_req(wma_handle,
6298 (tAniGetPEStatsReq *) msg->bodyptr);
6299 break;
6300
6301 case WMA_CONFIG_PARAM_UPDATE_REQ:
6302 wma_update_cfg_params(wma_handle, (tSirMsgQ *) msg);
6303 break;
6304
6305 case WMA_UPDATE_OP_MODE:
6306 wma_process_update_opmode(wma_handle,
6307 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306308 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006309 break;
6310 case WMA_UPDATE_RX_NSS:
6311 wma_process_update_rx_nss(wma_handle,
6312 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306313 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006314 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315 case WMA_UPDATE_MEMBERSHIP:
6316 wma_process_update_membership(wma_handle,
6317 (tUpdateMembership *) msg->bodyptr);
6318 break;
6319 case WMA_UPDATE_USERPOS:
6320 wma_process_update_userpos(wma_handle,
6321 (tUpdateUserPos *) msg->bodyptr);
6322 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006323 case WMA_UPDATE_BEACON_IND:
6324 wma_process_update_beacon_params(wma_handle,
6325 (tUpdateBeaconParams *) 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
6329 case WMA_ADD_TS_REQ:
6330 wma_add_ts_req(wma_handle, (tAddTsParams *) msg->bodyptr);
6331 break;
6332
6333 case WMA_DEL_TS_REQ:
6334 wma_del_ts_req(wma_handle, (tDelTsParams *) msg->bodyptr);
6335 break;
6336
6337 case WMA_AGGR_QOS_REQ:
6338 wma_aggr_qos_req(wma_handle, (tAggrAddTsParams *) msg->bodyptr);
6339 break;
6340
6341 case WMA_RECEIVE_FILTER_SET_FILTER_REQ:
6342 wma_process_receive_filter_set_filter_req(wma_handle,
6343 (tSirRcvPktFilterCfgType *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306344 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006345 break;
6346
6347 case WMA_RECEIVE_FILTER_CLEAR_FILTER_REQ:
6348 wma_process_receive_filter_clear_filter_req(wma_handle,
6349 (tSirRcvFltPktClearParam *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306350 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006351 break;
6352
6353 case WMA_WOW_ADD_PTRN:
6354 wma_wow_add_pattern(wma_handle,
6355 (struct wow_add_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306356 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006357 break;
6358 case WMA_WOW_DEL_PTRN:
6359 wma_wow_delete_user_pattern(wma_handle,
6360 (struct wow_delete_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306361 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006362 break;
6363 case WMA_WOWL_ENTER_REQ:
6364 wma_wow_enter(wma_handle,
6365 (tpSirHalWowlEnterParams) msg->bodyptr);
6366 break;
6367 case WMA_WOWL_EXIT_REQ:
6368 wma_wow_exit(wma_handle, (tpSirHalWowlExitParams) msg->bodyptr);
6369 break;
Houston Hoffmana76591b2015-11-10 16:52:05 -08006370
6371 case WMA_RUNTIME_PM_SUSPEND_IND:
6372 wma_calculate_and_update_conn_state(wma_handle);
Anurag Chouhan6d760662016-02-20 16:05:43 +05306373 wma_suspend_req(wma_handle, QDF_RUNTIME_SUSPEND);
Houston Hoffmana76591b2015-11-10 16:52:05 -08006374 break;
6375
6376 case WMA_RUNTIME_PM_RESUME_IND:
Anurag Chouhan6d760662016-02-20 16:05:43 +05306377 wma_resume_req(wma_handle, QDF_RUNTIME_SUSPEND);
Houston Hoffmana76591b2015-11-10 16:52:05 -08006378 break;
6379
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006380 case WMA_WLAN_SUSPEND_IND:
Houston Hoffman7260ecb2015-10-05 18:43:07 -07006381 wma_update_conn_state(wma_handle, msg->bodyval);
Anurag Chouhan6d760662016-02-20 16:05:43 +05306382 wma_suspend_req(wma_handle, QDF_SYSTEM_SUSPEND);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006383 break;
6384 case WMA_8023_MULTICAST_LIST_REQ:
6385 wma_process_mcbc_set_filter_req(wma_handle,
6386 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306387 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006388 break;
6389#ifdef WLAN_FEATURE_GTK_OFFLOAD
6390 case WMA_GTK_OFFLOAD_REQ:
6391 wma_process_gtk_offload_req(wma_handle,
6392 (tpSirGtkOffloadParams) msg->bodyptr);
6393 break;
6394
6395 case WMA_GTK_OFFLOAD_GETINFO_REQ:
6396 wma_process_gtk_offload_getinfo_req(wma_handle,
6397 (tpSirGtkOffloadGetInfoRspParams)msg->bodyptr);
6398 break;
6399#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006400 case WMA_SET_HOST_OFFLOAD:
6401 wma_enable_arp_ns_offload(wma_handle,
6402 (tpSirHostOffloadReq) msg->bodyptr,
6403 true);
6404 break;
6405#ifdef WLAN_NS_OFFLOAD
6406 case WMA_SET_NS_OFFLOAD:
6407 wma_enable_arp_ns_offload(wma_handle,
6408 (tpSirHostOffloadReq) msg->bodyptr,
6409 false);
6410 break;
6411#endif /*WLAN_NS_OFFLOAD */
6412 case WMA_ROAM_SCAN_OFFLOAD_REQ:
6413 /*
6414 * Main entry point or roaming directives from CSR.
6415 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08006416 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006417 (tSirRoamOffloadScanReq *) msg->bodyptr);
6418 break;
6419
6420 case WMA_RATE_UPDATE_IND:
6421 wma_process_rate_update_indicate(wma_handle,
6422 (tSirRateUpdateInd *) msg->bodyptr);
6423 break;
6424
6425#ifdef FEATURE_WLAN_TDLS
6426 case WMA_UPDATE_FW_TDLS_STATE:
6427 wma_update_fw_tdls_state(wma_handle,
6428 (t_wma_tdls_params *) msg->bodyptr);
6429 break;
6430 case WMA_UPDATE_TDLS_PEER_STATE:
6431 wma_update_tdls_peer_state(wma_handle,
6432 (tTdlsPeerStateParams *) msg->bodyptr);
6433 break;
6434 case WMA_TDLS_SET_OFFCHAN_MODE:
6435 wma_set_tdls_offchan_mode(wma_handle,
6436 (tdls_chan_switch_params *)msg->bodyptr);
6437 break;
6438#endif /* FEATURE_WLAN_TDLS */
6439 case WMA_ADD_PERIODIC_TX_PTRN_IND:
6440 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
6441 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306442 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006443 break;
6444 case WMA_DEL_PERIODIC_TX_PTRN_IND:
6445 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
6446 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306447 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006448 break;
6449 case WMA_TX_POWER_LIMIT:
6450 wma_process_tx_power_limits(wma_handle,
6451 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306452 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006453 break;
6454#ifdef FEATURE_WLAN_LPHB
6455 case WMA_LPHB_CONF_REQ:
6456 wma_process_lphb_conf_req(wma_handle,
6457 (tSirLPHBReq *) msg->bodyptr);
6458 break;
6459#endif /* FEATURE_WLAN_LPHB */
6460
6461#ifdef FEATURE_WLAN_CH_AVOID
6462 case WMA_CH_AVOID_UPDATE_REQ:
6463 wma_process_ch_avoid_update_req(wma_handle,
6464 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306465 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006466 break;
6467#endif /* FEATURE_WLAN_CH_AVOID */
6468#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
6469 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
6470 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306471 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006472 break;
6473#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
6474 case WMA_DHCP_START_IND:
6475 case WMA_DHCP_STOP_IND:
6476 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306477 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006478 break;
6479
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08006480 case WMA_IBSS_CESIUM_ENABLE_IND:
6481 wma_process_cesium_enable_ind(wma_handle);
6482 break;
6483 case WMA_GET_IBSS_PEER_INFO_REQ:
6484 wma_process_get_peer_info_req(wma_handle,
6485 (tSirIbssGetPeerInfoReqParams *)
6486 msg->bodyptr);
6487 qdf_mem_free(msg->bodyptr);
6488 break;
6489 case WMA_TX_FAIL_MONITOR_IND:
6490 wma_process_tx_fail_monitor_ind(wma_handle,
6491 (tAniTXFailMonitorInd *) msg->bodyptr);
6492 qdf_mem_free(msg->bodyptr);
6493 break;
6494
6495 case WMA_RMC_ENABLE_IND:
6496 wma_process_rmc_enable_ind(wma_handle);
6497 break;
6498 case WMA_RMC_DISABLE_IND:
6499 wma_process_rmc_disable_ind(wma_handle);
6500 break;
6501 case WMA_RMC_ACTION_PERIOD_IND:
6502 wma_process_rmc_action_period_ind(wma_handle);
6503 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006504 case WMA_INIT_THERMAL_INFO_CMD:
6505 wma_process_init_thermal_info(wma_handle,
6506 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306507 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006508 break;
6509
6510 case WMA_SET_THERMAL_LEVEL:
6511 wma_process_set_thermal_level(wma_handle, msg->bodyval);
6512 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05306513#ifdef CONFIG_HL_SUPPORT
6514 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
6515 wma_process_init_bad_peer_tx_ctl_info(
6516 wma_handle,
6517 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
6518 qdf_mem_free(msg->bodyptr);
6519 break;
6520#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006521 case WMA_SET_P2P_GO_NOA_REQ:
6522 wma_process_set_p2pgo_noa_req(wma_handle,
6523 (tP2pPsParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306524 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006525 break;
6526 case WMA_SET_MIMOPS_REQ:
6527 wma_process_set_mimops_req(wma_handle,
6528 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306529 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006530 break;
6531 case WMA_SET_SAP_INTRABSS_DIS:
6532 wma_set_vdev_intrabss_fwd(wma_handle,
6533 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306534 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006535 break;
6536 case WMA_GET_LINK_SPEED:
6537 wma_get_link_speed(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 case WMA_MODEM_POWER_STATE_IND:
6541 wma_notify_modem_power_state(wma_handle,
6542 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306543 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006544 break;
6545 case WMA_WLAN_RESUME_REQ:
Anurag Chouhan6d760662016-02-20 16:05:43 +05306546 wma_resume_req(wma_handle, QDF_SYSTEM_SUSPEND);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006547 break;
6548
6549#ifdef WLAN_FEATURE_STATS_EXT
6550 case WMA_STATS_EXT_REQUEST:
6551 wma_stats_ext_req(wma_handle,
6552 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306553 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006554 break;
6555#endif /* WLAN_FEATURE_STATS_EXT */
6556 case WMA_HIDDEN_SSID_VDEV_RESTART:
6557 wma_hidden_ssid_vdev_restart(wma_handle,
6558 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306559 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006560 break;
6561#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
6562 case WMA_WLAN_EXT_WOW:
6563 wma_enable_ext_wow(wma_handle,
6564 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306565 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006566 break;
6567 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
6568 wma_set_app_type1_params_in_fw(wma_handle,
6569 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306570 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006571 break;
6572 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
6573 wma_set_app_type2_params_in_fw(wma_handle,
6574 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306575 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006576 break;
6577#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
6578#ifdef FEATURE_WLAN_EXTSCAN
6579 case WMA_EXTSCAN_START_REQ:
6580 wma_start_extscan(wma_handle,
6581 (tSirWifiScanCmdReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306582 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006583 break;
6584 case WMA_EXTSCAN_STOP_REQ:
6585 wma_stop_extscan(wma_handle,
6586 (tSirExtScanStopReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306587 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006588 break;
6589 case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:
6590 wma_extscan_start_hotlist_monitor(wma_handle,
6591 (tSirExtScanSetBssidHotListReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306592 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006593 break;
6594 case WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
6595 wma_extscan_stop_hotlist_monitor(wma_handle,
6596 (tSirExtScanResetBssidHotlistReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306597 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006598 break;
6599 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
6600 wma_extscan_start_change_monitor(wma_handle,
6601 (tSirExtScanSetSigChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306602 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006603 break;
6604 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
6605 wma_extscan_stop_change_monitor(wma_handle,
6606 (tSirExtScanResetSignificantChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306607 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006608 break;
6609 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
6610 wma_extscan_get_cached_results(wma_handle,
6611 (tSirExtScanGetCachedResultsReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306612 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006613 break;
6614 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
6615 wma_extscan_get_capabilities(wma_handle,
6616 (tSirGetExtScanCapabilitiesReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306617 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006618 break;
6619 case WMA_SET_EPNO_LIST_REQ:
6620 wma_set_epno_network_list(wma_handle,
6621 (struct wifi_epno_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306622 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006623 break;
6624 case WMA_SET_PASSPOINT_LIST_REQ:
6625 /* Issue reset passpoint network list first and clear
6626 * the entries */
6627 wma_reset_passpoint_network_list(wma_handle,
6628 (struct wifi_passpoint_req *)msg->bodyptr);
6629
6630 wma_set_passpoint_network_list(wma_handle,
6631 (struct wifi_passpoint_req *)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_RESET_PASSPOINT_LIST_REQ:
6635 wma_reset_passpoint_network_list(wma_handle,
6636 (struct wifi_passpoint_req *)msg->bodyptr);
6637 break;
6638 case WMA_EXTSCAN_SET_SSID_HOTLIST_REQ:
6639 wma_set_ssid_hotlist(wma_handle,
6640 (struct sir_set_ssid_hotlist_request *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306641 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006642 break;
6643#endif /* FEATURE_WLAN_EXTSCAN */
6644 case WMA_SET_SCAN_MAC_OUI_REQ:
6645 wma_scan_probe_setoui(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306646 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006647 break;
6648#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6649 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
6650 wma_process_ll_stats_clear_req(wma_handle,
6651 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306652 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006653 break;
6654 case WMA_LINK_LAYER_STATS_SET_REQ:
6655 wma_process_ll_stats_set_req(wma_handle,
6656 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306657 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006658 break;
6659 case WMA_LINK_LAYER_STATS_GET_REQ:
6660 wma_process_ll_stats_get_req(wma_handle,
6661 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306662 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006663 break;
6664#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
6665 case SIR_HAL_UNIT_TEST_CMD:
6666 wma_process_unit_test_cmd(wma_handle,
6667 (t_wma_unit_test_cmd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306668 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006669 break;
6670#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006671 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
6672 wma_process_roam_synch_fail(wma_handle,
6673 (struct roam_offload_synch_fail *)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 SIR_HAL_ROAM_INVOKE:
6677 wma_process_roam_invoke(wma_handle,
6678 (struct wma_roam_invoke_cmd *)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#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6682#ifdef WLAN_FEATURE_NAN
6683 case WMA_NAN_REQUEST:
6684 wma_nan_req(wma_handle, (tNanRequest *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306685 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006686 break;
6687#endif /* WLAN_FEATURE_NAN */
6688 case SIR_HAL_SET_BASE_MACADDR_IND:
6689 wma_set_base_macaddr_indicate(wma_handle,
6690 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306691 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006692 break;
6693 case WMA_LINK_STATUS_GET_REQ:
6694 wma_process_link_status_req(wma_handle,
6695 (tAniGetLinkStatus *) msg->bodyptr);
6696 break;
6697 case WMA_GET_TEMPERATURE_REQ:
6698 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306699 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07006701 case WMA_TSF_GPIO_PIN:
6702 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
6703 break;
6704
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006705#ifdef DHCP_SERVER_OFFLOAD
6706 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
6707 wma_process_dhcpserver_offload(wma_handle,
6708 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306709 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006710 break;
6711#endif /* DHCP_SERVER_OFFLOAD */
6712#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
6713 case WMA_LED_FLASHING_REQ:
6714 wma_set_led_flashing(wma_handle,
6715 (tSirLedFlashingReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306716 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006717 break;
6718#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
6719 case SIR_HAL_SET_MAS:
6720 wma_process_set_mas(wma_handle,
6721 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306722 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006723 break;
6724 case SIR_HAL_SET_MIRACAST:
6725 wma_process_set_miracast(wma_handle,
6726 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306727 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006728 break;
6729 case SIR_HAL_CONFIG_STATS_FACTOR:
6730 wma_config_stats_factor(wma_handle,
6731 (struct sir_stats_avg_factor *)
6732 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306733 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006734 break;
6735 case SIR_HAL_CONFIG_GUARD_TIME:
6736 wma_config_guard_time(wma_handle,
6737 (struct sir_guard_time_request *)
6738 msg->bodyptr);
6739 case WMA_IPA_OFFLOAD_ENABLE_DISABLE:
6740 wma_ipa_offload_enable_disable(wma_handle,
6741 (struct sir_ipa_offload_enable_disable *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306742 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006743 break;
6744 case SIR_HAL_START_STOP_LOGGING:
6745 wma_set_wifi_start_packet_stats(wma_handle,
6746 (struct sir_wifi_start_log *)msg->bodyptr);
6747 wma_enable_specific_fw_logs(wma_handle,
6748 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306749 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006750 break;
6751 case SIR_HAL_FLUSH_LOG_TO_FW:
6752 wma_send_flush_logs_to_fw(wma_handle);
6753 /* Body ptr is NULL here */
6754 break;
6755 case WMA_SET_RSSI_MONITOR_REQ:
6756 wma_set_rssi_monitoring(wma_handle,
6757 (struct rssi_monitor_req *)msg->bodyptr);
6758 break;
6759 case WMA_FW_MEM_DUMP_REQ:
6760 wma_process_fw_mem_dump_req(wma_handle,
6761 (struct fw_dump_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306762 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006763 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05306764 case SIR_HAL_PDEV_SET_PCL_TO_FW:
6765 wma_send_pdev_set_pcl_cmd(wma_handle,
6766 (struct wmi_pcl_chan_weights *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306767 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006768 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05306769 case SIR_HAL_PDEV_SET_HW_MODE:
6770 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006771 (struct sir_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306772 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006773 break;
6774 case WMA_OCB_SET_CONFIG_CMD:
6775 wma_ocb_set_config_req(wma_handle,
6776 (struct sir_ocb_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306777 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006778 break;
6779 case WMA_OCB_SET_UTC_TIME_CMD:
6780 wma_ocb_set_utc_time(wma_handle,
6781 (struct sir_ocb_utc *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306782 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006783 break;
6784 case WMA_OCB_START_TIMING_ADVERT_CMD:
6785 wma_ocb_start_timing_advert(wma_handle,
6786 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306787 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006788 break;
6789 case WMA_OCB_STOP_TIMING_ADVERT_CMD:
6790 wma_ocb_stop_timing_advert(wma_handle,
6791 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306792 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006793 break;
6794 case WMA_DCC_CLEAR_STATS_CMD:
6795 wma_dcc_clear_stats(wma_handle,
6796 (struct sir_dcc_clear_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306797 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006798 break;
6799 case WMA_OCB_GET_TSF_TIMER_CMD:
6800 wma_ocb_get_tsf_timer(wma_handle,
6801 (struct sir_ocb_get_tsf_timer *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306802 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006803 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07006804 case WMA_SET_WISA_PARAMS:
6805 wma_set_wisa_params(wma_handle,
6806 (struct sir_wisa_params *)msg->bodyptr);
6807 qdf_mem_free(msg->bodyptr);
6808 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809 case WMA_DCC_GET_STATS_CMD:
6810 wma_dcc_get_stats(wma_handle,
6811 (struct sir_dcc_get_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306812 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006813 break;
6814 case WMA_DCC_UPDATE_NDL_CMD:
6815 wma_dcc_update_ndl(wma_handle,
6816 (struct sir_dcc_update_ndl *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306817 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006818 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05306819 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
6820 wma_send_pdev_set_dual_mac_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006821 (struct sir_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306822 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006823 break;
6824 case WMA_SET_IE_INFO:
6825 wma_process_set_ie_info(wma_handle,
6826 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306827 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006828 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08006829 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
6830 wma_send_pdev_set_antenna_mode(wma_handle,
6831 (struct sir_antenna_mode_param *)msg->bodyptr);
6832 qdf_mem_free(msg->bodyptr);
6833 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006834 case WMA_LRO_CONFIG_CMD:
6835 wma_lro_config_cmd(wma_handle,
6836 (struct wma_lro_config_cmd_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306837 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006838 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08006839 case WMA_GW_PARAM_UPDATE_REQ:
6840 wma_set_gateway_params(wma_handle,
6841 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08006842 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08006843 break;
6844 case WMA_SET_EGAP_CONF_PARAMS:
6845 wma_send_egap_conf_params(wma_handle,
6846 (struct egap_conf_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306847 qdf_mem_free(msg->bodyptr);
Ravi Joshi9e891ba2015-11-09 19:03:46 -08006848 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05306849 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
6850 wma_send_adapt_dwelltime_params(wma_handle,
6851 (struct adaptive_dwelltime_params *)msg->bodyptr);
6852 qdf_mem_free(msg->bodyptr);
6853 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006854 case WMA_HT40_OBSS_SCAN_IND:
6855 wma_send_ht40_obss_scanind(wma_handle,
6856 (struct obss_ht40_scanind *)msg->bodyptr);
6857 qdf_mem_free(msg->bodyptr);
6858 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07006859 case WMA_ADD_BCN_FILTER_CMDID:
6860 wma_add_beacon_filter(wma_handle, msg->bodyptr);
6861 qdf_mem_free(msg->bodyptr);
6862 break;
6863 case WMA_REMOVE_BCN_FILTER_CMDID:
6864 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
6865 qdf_mem_free(msg->bodyptr);
6866 break;
Arun Khandavalli2476ef52016-04-26 20:19:43 +05306867 case WDA_BPF_GET_CAPABILITIES_REQ:
6868 wma_get_bpf_capabilities(wma_handle);
6869 break;
6870 case WDA_BPF_SET_INSTRUCTIONS_REQ:
6871 wma_set_bpf_instructions(wma_handle, msg->bodyptr);
6872 qdf_mem_free(msg->bodyptr);
6873 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07006874 case SIR_HAL_NDP_INITIATOR_REQ:
6875 wma_handle_ndp_initiator_req(wma_handle, msg->bodyptr);
6876 qdf_mem_free(msg->bodyptr);
6877 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07006878
Abhishek Singh4fef7472016-06-06 11:36:03 -07006879 case SIR_HAL_NDP_RESPONDER_REQ:
6880 wma_handle_ndp_responder_req(wma_handle, msg->bodyptr);
Naveen Rawatf28315c2016-06-29 18:06:02 -07006881 break;
6882
6883 case SIR_HAL_NDP_END_REQ:
6884 wma_handle_ndp_end_req(wma_handle, msg->bodyptr);
Abhishek Singh4fef7472016-06-06 11:36:03 -07006885 qdf_mem_free(msg->bodyptr);
6886 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05306887 case SIR_HAL_POWER_DBG_CMD:
6888 wma_process_hal_pwr_dbg_cmd(wma_handle,
6889 msg->bodyptr);
6890 qdf_mem_free(msg->bodyptr);
6891 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306892 case WMA_UPDATE_WEP_DEFAULT_KEY:
6893 wma_update_wep_default_key(wma_handle,
6894 (struct wep_update_default_key_idx *)msg->bodyptr);
6895 qdf_mem_free(msg->bodyptr);
6896 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05306897 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
6898 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
6899 break;
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05306900 case WMA_ENCRYPT_DECRYPT_MSG:
6901 wma_encrypt_decrypt_msg(wma_handle, msg->bodyptr);
6902 qdf_mem_free(msg->bodyptr);
6903 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05306904 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
6905 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
6906 qdf_mem_free(msg->bodyptr);
6907 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306908 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
6909 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
6910 qdf_mem_free(msg->bodyptr);
6911 break;
6912 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
6913 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
6914 qdf_mem_free(msg->bodyptr);
6915 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006916 default:
6917 WMA_LOGD("unknow msg type %x", msg->type);
6918 /* Do Nothing? MSG Body should be freed at here */
6919 if (NULL != msg->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306920 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006921 }
6922 }
6923end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306924 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006925}
6926
6927/**
6928 * wma_log_completion_timeout() - Log completion timeout
6929 * @data: Timeout handler data
6930 *
6931 * This function is called when log completion timer expires
6932 *
6933 * Return: None
6934 */
6935void wma_log_completion_timeout(void *data)
6936{
6937 tp_wma_handle wma_handle;
6938
6939 WMA_LOGE("%s: Timeout occured for log completion command", __func__);
6940
6941 wma_handle = (tp_wma_handle) data;
6942 if (!wma_handle)
6943 WMA_LOGE("%s: Invalid WMA handle", __func__);
6944
6945 /* Though we did not receive any event from FW,
6946 * we can flush whatever logs we have with us */
6947 cds_logging_set_fw_flush_complete();
6948
6949 return;
6950}
6951
6952/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05306953 * wma_map_pcl_weights() - Map PCL weights
6954 * @pcl_weight: Internal PCL weights
6955 *
6956 * Maps the internal weights of PCL to the weights needed by FW
6957 *
6958 * Return: Mapped channel weight of type wmi_pcl_chan_weight
6959 */
6960static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
6961{
6962 switch (pcl_weight) {
6963 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
6964 return WMI_PCL_WEIGHT_VERY_HIGH;
6965 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
6966 return WMI_PCL_WEIGHT_HIGH;
6967 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
6968 return WMI_PCL_WEIGHT_MEDIUM;
6969 case WEIGHT_OF_NON_PCL_CHANNELS:
6970 return WMI_PCL_WEIGHT_LOW;
6971 default:
6972 return WMI_PCL_WEIGHT_DISALLOW;
6973 }
6974}
6975
6976/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05306977 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006978 * @wma_handle: WMA handle
6979 * @msg: PCL structure containing the PCL and the number of channels
6980 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05306981 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006982 * firmware. The DBS Manager is the consumer of this information in the WLAN
6983 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
6984 * to migrate to a new channel without host driver involvement. An example of
6985 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
6986 * manage the channel selection without firmware involvement.
6987 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05306988 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
6989 * channel list. The weights corresponds to the channels sent in
6990 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
6991 * weightage compared to the non PCL channels.
6992 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006993 * Return: Success if the cmd is sent successfully to the firmware
6994 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05306995QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
6996 struct wmi_pcl_chan_weights *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006997{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05306998 uint32_t i;
6999 QDF_STATUS status;
7000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007001 if (!wma_handle) {
7002 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7003 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307004 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007005 }
7006
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307007 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
7008 msg->saved_chan_list[i] =
7009 wma_handle->saved_chan.channel_list[i];
7010 }
7011
7012 msg->saved_num_chan = wma_handle->saved_chan.num_channels;
7013 status = cds_get_valid_chan_weights((struct sir_pcl_chan_weights *)msg);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05307014
7015 for (i = 0; i < msg->saved_num_chan; i++) {
7016 msg->weighed_valid_list[i] =
7017 wma_map_pcl_weights(msg->weighed_valid_list[i]);
7018 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
7019 msg->saved_chan_list[i], i,
7020 msg->weighed_valid_list[i]);
7021 }
7022
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307023 if (!QDF_IS_STATUS_SUCCESS(status)) {
7024 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
7025 return status;
7026 }
7027
7028 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle, msg))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307029 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05307030
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307031 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007032}
7033
7034/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307035 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007036 * @wma_handle: WMA handle
7037 * @msg: Structure containing the following parameters
7038 *
7039 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
7040 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
7041 *
7042 * Provides notification to the WLAN firmware that host driver is requesting a
7043 * HardWare (HW) Mode change. This command is needed to support iHelium in the
7044 * configurations that include the Dual Band Simultaneous (DBS) feature.
7045 *
7046 * Return: Success if the cmd is sent successfully to the firmware
7047 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307048QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007049 struct sir_hw_mode *msg)
7050{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007051 struct sir_set_hw_mode_resp *param;
7052
7053 if (!wma_handle) {
7054 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7055 __func__);
7056 /* Handle is NULL. Will not be able to send failure
7057 * response as well
7058 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307059 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007060 }
7061
7062 if (!msg) {
7063 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
7064 /* Lets try to free the active command list */
7065 goto fail;
7066 }
7067
Govind Singhf25a0f12016-03-08 16:09:48 +05307068 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
7069 msg->hw_mode_index))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007070 goto fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007071
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307072 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007073fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307074 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007075 if (!param) {
7076 WMA_LOGE("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307077 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007078 }
7079 param->status = SET_HW_MODE_STATUS_ECANCELED;
7080 param->cfgd_hw_mode_index = 0;
7081 param->num_vdev_mac_entries = 0;
7082 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307083 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007084 (void *) param, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307085 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086}
7087
7088/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307089 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007090 * @wma_handle: WMA handle
7091 * @msg: Dual MAC config parameters
7092 *
7093 * Configures WLAN firmware with the dual MAC features
7094 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307095 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007096 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307097QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007098 struct sir_dual_mac_config *msg)
7099{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307100 QDF_STATUS status;
7101
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007102 if (!wma_handle) {
7103 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7104 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307105 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007106 }
7107
7108 if (!msg) {
7109 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307110 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007111 }
7112
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307113 status = wmi_unified_pdev_set_dual_mac_config_cmd(
7114 wma_handle->wmi_handle,
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307115 (struct wmi_dual_mac_config *)msg);
7116 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307117 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307118 __func__, status);
7119 return status;
7120 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007121
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307122 wma_handle->dual_mac_cfg.req_scan_config = msg->scan_config;
7123 wma_handle->dual_mac_cfg.req_fw_mode_config = msg->fw_mode_config;
Govind Singhf25a0f12016-03-08 16:09:48 +05307124
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307125 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007126}
7127
7128/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007129 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
7130 * @wma_handle: WMA handle
7131 * @msg: Antenna mode parameters
7132 *
7133 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
7134 * modify the number of TX/RX chains from host
7135 *
7136 * Return: QDF_STATUS. 0 on success.
7137 */
7138QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
7139 struct sir_antenna_mode_param *msg)
7140{
7141 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
7142 wmi_buf_t buf;
7143 uint32_t len;
7144 QDF_STATUS status = QDF_STATUS_SUCCESS;
7145 struct sir_antenna_mode_resp *param;
7146
7147 if (!wma_handle) {
7148 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7149 __func__);
7150 return QDF_STATUS_E_NULL_VALUE;
7151 }
7152
7153 if (!msg) {
7154 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
7155 return QDF_STATUS_E_NULL_VALUE;
7156 }
7157
7158 len = sizeof(*cmd);
7159
7160 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7161 if (!buf) {
7162 WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
7163 status = QDF_STATUS_E_NOMEM;
7164 goto resp;
7165 }
7166
7167 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
7168 WMITLV_SET_HDR(&cmd->tlv_header,
7169 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
7170 WMITLV_GET_STRUCT_TLVLEN(
7171 wmi_pdev_set_antenna_mode_cmd_fixed_param));
7172
7173 cmd->pdev_id = WMI_PDEV_ID_SOC;
7174 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
7175 cmd->num_txrx_chains = msg->num_rx_chains;
7176 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
7177
7178 WMA_LOGI("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
7179 __func__, msg->num_tx_chains,
7180 msg->num_rx_chains, cmd->num_txrx_chains);
7181
7182 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7183 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
7184 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_ANTENNA_MODE_CMDID",
7185 __func__);
7186 wmi_buf_free(buf);
7187 status = QDF_STATUS_E_FAILURE;
7188 goto resp;
7189 }
7190 status = QDF_STATUS_SUCCESS;
7191
7192resp:
7193 param = qdf_mem_malloc(sizeof(*param));
7194 if (!param) {
7195 WMA_LOGE("%s: Memory allocation failed", __func__);
7196 return QDF_STATUS_E_NOMEM;
7197 }
7198 param->status = (status) ?
7199 SET_ANTENNA_MODE_STATUS_ECANCELED :
7200 SET_ANTENNA_MODE_STATUS_OK;
7201 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
7202 __func__, param->status);
7203 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
7204 (void *) param, 0);
7205 return status;
7206}
7207
7208/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007209 * wma_crash_inject() - sends command to FW to simulate crash
7210 * @wma_handle: pointer of WMA context
7211 * @type: subtype of the command
7212 * @delay_time_ms: time in milliseconds for FW to delay the crash
7213 *
7214 * This function will send a command to FW in order to simulate different
7215 * kinds of FW crashes.
7216 *
Govind Singhd76a5b02016-03-08 15:12:14 +05307217 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007218 */
Govind Singhd76a5b02016-03-08 15:12:14 +05307219QDF_STATUS wma_crash_inject(tp_wma_handle wma_handle, uint32_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220 uint32_t delay_time_ms)
7221{
Govind Singhd76a5b02016-03-08 15:12:14 +05307222 struct crash_inject param;
7223 param.type = type;
7224 param.delay_time_ms = delay_time_ms;
7225
7226 return wmi_crash_inject(wma_handle->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007227}
Govind Singhd76a5b02016-03-08 15:12:14 +05307228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007229#if defined(FEATURE_LRO)
7230/**
7231 * wma_lro_init() - sends LRO configuration to FW
7232 * @lro_config: pointer to the config parameters
7233 *
7234 * This function ends LRO configuration to FW.
7235 *
7236 * Return: 0 for success or reasons for failure
7237 */
7238int wma_lro_init(struct wma_lro_config_cmd_t *lro_config)
7239{
7240 cds_msg_t msg = {0};
7241 struct wma_lro_config_cmd_t *iwcmd;
7242
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307243 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007244 if (!iwcmd) {
7245 WMA_LOGE("memory allocation for WMA_LRO_CONFIG_CMD failed!");
7246 return -ENOMEM;
7247 }
7248
7249 *iwcmd = *lro_config;
7250
7251 msg.type = WMA_LRO_CONFIG_CMD;
7252 msg.reserved = 0;
7253 msg.bodyptr = iwcmd;
7254
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307255 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05307256 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007257 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307258 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007259 return -EAGAIN;
7260 }
7261
7262 WMA_LOGD("sending the LRO configuration to the fw");
7263 return 0;
7264}
7265#endif