blob: 5eae24ee19c31da0874fb781d30e78fdeea3c311 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jeff Johnson199e7012016-12-16 14:55:42 -08002 * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wma_main.c
30 *
31 * This file contains wma initialization and FW exchange
32 * related functions.
33 */
34
35/* Header files */
36
37#include "wma.h"
38#include "wma_api.h"
39#include "cds_api.h"
40#include "wmi_unified_api.h"
41#include "wlan_qct_sys.h"
42#include "wni_api.h"
43#include "ani_global.h"
44#include "wmi_unified.h"
Rajeev Kumarda2444c2017-01-10 22:42:07 -080045#include "service_ready_event_handler.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "wni_cfg.h"
47#include "cfg_api.h"
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +053048#if defined(CONFIG_HL_SUPPORT)
49#include "wlan_tgt_def_config_hl.h"
50#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051#include "wlan_tgt_def_config.h"
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +053052#endif
Nirav Shahcbc6d722016-03-01 16:24:53 +053053#include "qdf_nbuf.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053054#include "qdf_types.h"
Anurag Chouhan600c3a02016-03-01 10:33:54 +053055#include "qdf_mem.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056
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"
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -070076#include "wlan_policy_mgr_api.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"
Leo Chang96464902016-10-28 11:10:54 -070081#include "cdp_txrx_misc.h"
Deepak Dhamdhere13230d32016-05-26 00:46:53 -070082#include "wma_nan_datapath.h"
Frank Liu65b17d92016-11-23 15:58:44 +080083#include "wlan_lmac_if_def.h"
84#include "wlan_lmac_if_api.h"
Mukul Sharmac3e7a782017-02-03 12:16:11 +053085#include "target_if.h"
Mukul Sharmadad267e2017-02-04 13:25:34 +053086#include "wlan_global_lmac_if_api.h"
Mukul Sharma3d36c392017-01-18 18:39:12 +053087#include "target_if_pmo.h"
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -070088#include "wma_he.h"
Mukul Sharma6411bb82017-03-01 15:57:07 +053089#include "wlan_pmo_obj_mgmt_api.h"
Frank Liu65b17d92016-11-23 15:58:44 +080090
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080091#include <cdp_txrx_handle.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070092#include <wlan_pmo_ucfg_api.h>
93
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094#define WMA_LOG_COMPLETION_TIMER 10000 /* 10 seconds */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +053096#define WMI_TLV_HEADROOM 128
97
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098static uint32_t g_fw_wlan_feat_caps;
99
100/**
101 * wma_get_fw_wlan_feat_caps() - get fw feature capablity
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700102 * @feature: feature enum value
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 *
104 * Return: true/false
105 */
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700106bool wma_get_fw_wlan_feat_caps(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700108 return (g_fw_wlan_feat_caps & (1 << feature)) ? true : false;
109}
110
111/**
112 * wma_set_fw_wlan_feat_caps() - set fw feature capablity
113 * @feature: feature enum value
114 *
115 * Return: None
116 */
117void wma_set_fw_wlan_feat_caps(enum cap_bitmap feature)
118{
119 g_fw_wlan_feat_caps |= (1 << feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120}
121
122/**
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530123 * wma_service_ready_ext_evt_timeout() - Service ready extended event timeout
124 * @data: Timeout handler data
125 *
126 * This function is called when the FW fails to send WMI_SERVICE_READY_EXT_EVENT
127 * message
128 *
129 * Return: None
130 */
131static void wma_service_ready_ext_evt_timeout(void *data)
132{
133 tp_wma_handle wma_handle;
134
135 WMA_LOGA("%s: Timeout waiting for WMI_SERVICE_READY_EXT_EVENT",
136 __func__);
137
138 wma_handle = (tp_wma_handle) data;
139
140 if (!wma_handle) {
141 WMA_LOGE("%s: Invalid WMA handle", __func__);
142 goto end;
143 }
144
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530145end:
Naveen Rawatac39a102016-10-07 10:58:29 -0700146 /* Assert here. Panic is being called in insmod thread */
147 QDF_ASSERT(0);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530148}
149
150/**
Komal Seelam02d09342016-02-23 18:03:19 +0530151 * wma_get_ini_handle() - API to get WMA ini info handle
152 * @wma: WMA Handle
153 *
154 * Returns the pointer to WMA ini structure.
155 * Return: struct wma_ini_config
156 */
157struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma)
158{
159 if (!wma) {
160 WMA_LOGE("%s: Invalid WMA context\n", __func__);
161 return NULL;
162 }
163
164 return &wma->ini_config;
165}
166
167#define MAX_SUPPORTED_PEERS_REV1_1 14
168#define MAX_SUPPORTED_PEERS_REV1_3 32
169#define MIN_NO_OF_PEERS 1
170
171/**
172 * wma_get_number_of_peers_supported - API to query for number of peers
173 * supported
174 * @wma: WMA Handle
175 *
176 * Return: Max Number of Peers Supported
177 */
178static uint8_t wma_get_number_of_peers_supported(tp_wma_handle wma)
179{
180 struct hif_target_info *tgt_info;
181 struct wma_ini_config *cfg = wma_get_ini_handle(wma);
182 uint8_t max_no_of_peers = cfg ? cfg->max_no_of_peers : MIN_NO_OF_PEERS;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530183 struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF);
Komal Seelam02d09342016-02-23 18:03:19 +0530184
185 if (!scn) {
186 WMA_LOGE("%s: Invalid wma handle", __func__);
187 return 0;
188 }
189
190 tgt_info = hif_get_target_info_handle(scn);
191
192 switch (tgt_info->target_version) {
193 case AR6320_REV1_1_VERSION:
194 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_1)
195 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_1;
196 break;
197 default:
198 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_3)
199 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_3;
200 break;
201 }
202
203 return max_no_of_peers;
204}
205
206/**
bings6b3614e2017-02-21 10:18:36 +0800207 * wma_get_number_of_tids_supported - API to query for number of tids supported
208 * @no_of_peers_supported: Number of peer supported
209 *
210 * Return: Max number of tids supported
211 */
212#if defined(CONFIG_HL_SUPPORT)
213static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported)
214{
215 return 4 * no_of_peers_supported;
216}
217#else
218static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported)
219{
220 return 2 * (no_of_peers_supported + CFG_TGT_NUM_VDEV + 2);
221}
222#endif
223
224/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 * wma_set_default_tgt_config() - set default tgt config
226 * @wma_handle: wma handle
227 *
228 * Return: none
229 */
230static void wma_set_default_tgt_config(tp_wma_handle wma_handle)
231{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232 uint8_t no_of_peers_supported;
233 wmi_resource_config tgt_cfg = {
234 0, /* Filling zero for TLV Tag and Length fields */
235 CFG_TGT_NUM_VDEV,
236 CFG_TGT_NUM_PEERS + CFG_TGT_NUM_VDEV + 2,
237 CFG_TGT_NUM_OFFLOAD_PEERS,
238 CFG_TGT_NUM_OFFLOAD_REORDER_BUFFS,
239 CFG_TGT_NUM_PEER_KEYS,
240 CFG_TGT_NUM_TIDS,
241 CFG_TGT_AST_SKID_LIMIT,
242 CFG_TGT_DEFAULT_TX_CHAIN_MASK,
243 CFG_TGT_DEFAULT_RX_CHAIN_MASK,
244 {CFG_TGT_RX_TIMEOUT_LO_PRI, CFG_TGT_RX_TIMEOUT_LO_PRI,
245 CFG_TGT_RX_TIMEOUT_LO_PRI, CFG_TGT_RX_TIMEOUT_HI_PRI},
246 CFG_TGT_RX_DECAP_MODE,
247 CFG_TGT_DEFAULT_SCAN_MAX_REQS,
248 CFG_TGT_DEFAULT_BMISS_OFFLOAD_MAX_VDEV,
249 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_VDEV,
250 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_PROFILES,
251 CFG_TGT_DEFAULT_NUM_MCAST_GROUPS,
252 CFG_TGT_DEFAULT_NUM_MCAST_TABLE_ELEMS,
253 CFG_TGT_DEFAULT_MCAST2UCAST_MODE,
254 CFG_TGT_DEFAULT_TX_DBG_LOG_SIZE,
255 CFG_TGT_WDS_ENTRIES,
256 CFG_TGT_DEFAULT_DMA_BURST_SIZE,
257 CFG_TGT_DEFAULT_MAC_AGGR_DELIM,
258 CFG_TGT_DEFAULT_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK,
259 CFG_TGT_DEFAULT_VOW_CONFIG,
260 CFG_TGT_DEFAULT_GTK_OFFLOAD_MAX_VDEV,
261 CFG_TGT_NUM_MSDU_DESC,
262 CFG_TGT_MAX_FRAG_TABLE_ENTRIES,
263 CFG_TGT_NUM_TDLS_VDEVS,
264 CFG_TGT_NUM_TDLS_CONN_TABLE_ENTRIES,
265 CFG_TGT_DEFAULT_BEACON_TX_OFFLOAD_MAX_VDEV,
266 CFG_TGT_MAX_MULTICAST_FILTER_ENTRIES,
267 0,
268 0,
269 0,
270 CFG_TGT_NUM_TDLS_CONC_SLEEP_STAS,
271 CFG_TGT_NUM_TDLS_CONC_BUFFER_STAS,
272 0,
273 CFG_TGT_NUM_OCB_VDEVS,
274 CFG_TGT_NUM_OCB_CHANNELS,
275 CFG_TGT_NUM_OCB_SCHEDULES,
276 };
277
Komal Seelam02d09342016-02-23 18:03:19 +0530278 no_of_peers_supported = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 tgt_cfg.num_peers = no_of_peers_supported + CFG_TGT_NUM_VDEV + 2;
bings6b3614e2017-02-21 10:18:36 +0800280 tgt_cfg.num_tids = wma_get_number_of_tids_supported(
281 no_of_peers_supported);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282 tgt_cfg.scan_max_pending_req = wma_handle->max_scan;
283
Nirav Shah20489972016-06-16 19:20:28 +0530284 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(tgt_cfg.flag1, 1);
Yun Park4d968df2016-10-11 11:44:15 -0700285 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(tgt_cfg.flag1,
286 1);
Nirav Shah20489972016-06-16 19:20:28 +0530287
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 WMITLV_SET_HDR(&tgt_cfg.tlv_header,
289 WMITLV_TAG_STRUC_wmi_resource_config,
290 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
291 /* reduce the peer/vdev if CFG_TGT_NUM_MSDU_DESC exceeds 1000 */
292#ifdef PERE_IP_HDR_ALIGNMENT_WAR
293 if (scn->host_80211_enable) {
294 /*
295 * To make the IP header begins at dword aligned address,
296 * we make the decapsulation mode as Native Wifi.
297 */
298 tgt_cfg.rx_decap_mode = CFG_TGT_RX_DECAP_MODE_NWIFI;
299 }
300#endif /* PERE_IP_HDR_ALIGNMENT_WAR */
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700301 if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam())
302 tgt_cfg.rx_decap_mode = CFG_TGT_RX_DECAP_MODE_RAW;
303
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 wma_handle->wlan_resource_config = tgt_cfg;
305}
306
307/**
308 * wma_cli_get_command() - WMA "get" command processor
309 * @vdev_id: virtual device for the command
310 * @param_id: parameter id
311 * @vpdev: parameter category
312 *
313 * Return: parameter value on success, -EINVAL on failure
314 */
315int wma_cli_get_command(int vdev_id, int param_id, int vpdev)
316{
317 int ret = 0;
318 tp_wma_handle wma;
319 struct wma_txrx_node *intr = NULL;
320
Anurag Chouhan6d760662016-02-20 16:05:43 +0530321 wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322
323 if (NULL == wma) {
324 WMA_LOGE("%s: Invalid wma handle", __func__);
325 return -EINVAL;
326 }
327
328 intr = wma->interfaces;
329
330 if (VDEV_CMD == vpdev) {
331 switch (param_id) {
332 case WMI_VDEV_PARAM_NSS:
333 ret = intr[vdev_id].config.nss;
334 break;
335#ifdef QCA_SUPPORT_GTX
336 case WMI_VDEV_PARAM_GTX_HT_MCS:
337 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
338 break;
339 case WMI_VDEV_PARAM_GTX_VHT_MCS:
340 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
341 break;
342 case WMI_VDEV_PARAM_GTX_USR_CFG:
343 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
344 break;
345 case WMI_VDEV_PARAM_GTX_THRE:
346 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
347 break;
348 case WMI_VDEV_PARAM_GTX_MARGIN:
349 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
350 break;
351 case WMI_VDEV_PARAM_GTX_STEP:
352 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
353 break;
354 case WMI_VDEV_PARAM_GTX_MINTPC:
355 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
356 break;
357 case WMI_VDEV_PARAM_GTX_BW_MASK:
358 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
359 break;
360#endif /* QCA_SUPPORT_GTX */
361 case WMI_VDEV_PARAM_LDPC:
362 ret = intr[vdev_id].config.ldpc;
363 break;
364 case WMI_VDEV_PARAM_TX_STBC:
365 ret = intr[vdev_id].config.tx_stbc;
366 break;
367 case WMI_VDEV_PARAM_RX_STBC:
368 ret = intr[vdev_id].config.rx_stbc;
369 break;
370 case WMI_VDEV_PARAM_SGI:
371 ret = intr[vdev_id].config.shortgi;
372 break;
373 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
374 ret = intr[vdev_id].config.rtscts_en;
375 break;
376 case WMI_VDEV_PARAM_CHWIDTH:
377 ret = intr[vdev_id].config.chwidth;
378 break;
379 case WMI_VDEV_PARAM_FIXED_RATE:
380 ret = intr[vdev_id].config.tx_rate;
381 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700382 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -0700383 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700384 ret = wma_get_he_vdev_param(&intr[vdev_id], param_id);
385 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 default:
387 WMA_LOGE("Invalid cli_get vdev command/Not"
388 " yet implemented 0x%x", param_id);
389 return -EINVAL;
390 }
391 } else if (PDEV_CMD == vpdev) {
392 switch (param_id) {
393 case WMI_PDEV_PARAM_ANI_ENABLE:
394 ret = wma->pdevconfig.ani_enable;
395 break;
396 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
397 ret = wma->pdevconfig.ani_poll_len;
398 break;
399 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
400 ret = wma->pdevconfig.ani_listen_len;
401 break;
402 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
403 ret = wma->pdevconfig.ani_ofdm_level;
404 break;
405 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
406 ret = wma->pdevconfig.ani_cck_level;
407 break;
408 case WMI_PDEV_PARAM_DYNAMIC_BW:
409 ret = wma->pdevconfig.cwmenable;
410 break;
411 case WMI_PDEV_PARAM_CTS_CBW:
412 ret = wma->pdevconfig.cts_cbw;
413 break;
414 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
415 ret = wma->pdevconfig.txchainmask;
416 break;
417 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
418 ret = wma->pdevconfig.rxchainmask;
419 break;
420 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
421 ret = wma->pdevconfig.txpow2g;
422 break;
423 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
424 ret = wma->pdevconfig.txpow5g;
425 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426 case WMI_PDEV_PARAM_BURST_ENABLE:
427 ret = wma->pdevconfig.burst_enable;
428 break;
429 case WMI_PDEV_PARAM_BURST_DUR:
430 ret = wma->pdevconfig.burst_dur;
431 break;
432 default:
433 WMA_LOGE("Invalid cli_get pdev command/Not"
434 " yet implemented 0x%x", param_id);
435 return -EINVAL;
436 }
437 } else if (GEN_CMD == vpdev) {
438 switch (param_id) {
439 case GEN_VDEV_PARAM_AMPDU:
440 ret = intr[vdev_id].config.ampdu;
441 break;
442 case GEN_VDEV_PARAM_AMSDU:
443 ret = intr[vdev_id].config.amsdu;
444 break;
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700445 case GEN_VDEV_ROAM_SYNCH_DELAY:
446 ret = intr[vdev_id].roam_synch_delay;
447 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 default:
449 WMA_LOGE("Invalid generic vdev command/Not"
450 " yet implemented 0x%x", param_id);
451 return -EINVAL;
452 }
453 } else if (PPS_CMD == vpdev) {
454 switch (param_id) {
455 case WMI_VDEV_PPS_PAID_MATCH:
456 ret = intr[vdev_id].config.pps_params.paid_match_enable;
457 break;
458 case WMI_VDEV_PPS_GID_MATCH:
459 ret = intr[vdev_id].config.pps_params.gid_match_enable;
460 break;
461 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
462 ret = intr[vdev_id].config.pps_params.tim_clear;
463 break;
464 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
465 ret = intr[vdev_id].config.pps_params.dtim_clear;
466 break;
467 case WMI_VDEV_PPS_EOF_PAD_DELIM:
468 ret = intr[vdev_id].config.pps_params.eof_delim;
469 break;
470 case WMI_VDEV_PPS_MACADDR_MISMATCH:
471 ret = intr[vdev_id].config.pps_params.mac_match;
472 break;
473 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
474 ret = intr[vdev_id].config.pps_params.delim_fail;
475 break;
476 case WMI_VDEV_PPS_GID_NSTS_ZERO:
477 ret = intr[vdev_id].config.pps_params.nsts_zero;
478 break;
479 case WMI_VDEV_PPS_RSSI_CHECK:
480 ret = intr[vdev_id].config.pps_params.rssi_chk;
481 break;
482 default:
483 WMA_LOGE("Invalid pps vdev command/Not"
484 " yet implemented 0x%x", param_id);
485 return -EINVAL;
486 }
487 } else if (QPOWER_CMD == vpdev) {
488 switch (param_id) {
489 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
490 ret = intr[vdev_id].config.qpower_params.
491 max_ps_poll_cnt;
492 break;
493 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
494 ret = intr[vdev_id].config.qpower_params.
495 max_tx_before_wake;
496 break;
497 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
498 ret = intr[vdev_id].config.qpower_params.
499 spec_ps_poll_wake_interval;
500 break;
501 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
502 ret = intr[vdev_id].config.qpower_params.
503 max_spec_nodata_ps_poll;
504 break;
505 default:
506 WMA_LOGE("Invalid generic vdev command/Not"
507 " yet implemented 0x%x", param_id);
508 return -EINVAL;
509 }
510 } else if (GTX_CMD == vpdev) {
511 switch (param_id) {
512 case WMI_VDEV_PARAM_GTX_HT_MCS:
513 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
514 break;
515 case WMI_VDEV_PARAM_GTX_VHT_MCS:
516 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
517 break;
518 case WMI_VDEV_PARAM_GTX_USR_CFG:
519 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
520 break;
521 case WMI_VDEV_PARAM_GTX_THRE:
522 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
523 break;
524 case WMI_VDEV_PARAM_GTX_MARGIN:
525 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
526 break;
527 case WMI_VDEV_PARAM_GTX_STEP:
528 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
529 break;
530 case WMI_VDEV_PARAM_GTX_MINTPC:
531 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
532 break;
533 case WMI_VDEV_PARAM_GTX_BW_MASK:
534 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
535 break;
536 default:
537 WMA_LOGE("Invalid generic vdev command/Not"
538 " yet implemented 0x%x", param_id);
539 return -EINVAL;
540 }
541 }
542 return ret;
543}
544
545/**
546 * wma_cli_set2_command() - WMA "set 2 params" command processor
547 * @vdev_id: virtual device for the command
548 * @param_id: parameter id
549 * @sval1: first parameter value
550 * @sval2: second parameter value
551 * @vpdev: parameter category
552 *
553 * Command handler for set operations which require 2 parameters
554 *
555 * Return: 0 on success, errno on failure
556 */
557int wma_cli_set2_command(int vdev_id, int param_id, int sval1,
558 int sval2, int vpdev)
559{
Rajeev Kumarb60abe42017-01-21 15:39:31 -0800560 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 wma_cli_set_cmd_t *iwcmd;
562
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530563 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564 if (!iwcmd) {
565 WMA_LOGE("%s: Failed alloc memory for iwcmd", __func__);
566 return -ENOMEM;
567 }
568
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530569 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 iwcmd->param_value = sval1;
571 iwcmd->param_sec_value = sval2;
572 iwcmd->param_vdev_id = vdev_id;
573 iwcmd->param_id = param_id;
574 iwcmd->param_vp_dev = vpdev;
575 msg.type = WMA_CLI_SET_CMD;
576 msg.reserved = 0;
577 msg.bodyptr = iwcmd;
578
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530579 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -0800580 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 WMA_LOGP("%s: Failed to post WMA_CLI_SET_CMD msg",
582 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530583 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800584 return -EIO;
585 }
586 return 0;
587}
588
589/**
590 * wma_cli_set_command() - WMA "set" command processor
591 * @vdev_id: virtual device for the command
592 * @param_id: parameter id
593 * @sval: parameter value
594 * @vpdev: parameter category
595 *
596 * Command handler for set operations
597 *
598 * Return: 0 on success, errno on failure
599 */
600int wma_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
601{
602 return wma_cli_set2_command(vdev_id, param_id, sval, 0, vpdev);
603
604}
605
606/**
607 * wma_set_priv_cfg() - set private config parameters
608 * @wma_handle: wma handle
609 * @privcmd: private command
610 *
611 * Return: 0 for success or error code
612 */
613static int32_t wma_set_priv_cfg(tp_wma_handle wma_handle,
614 wma_cli_set_cmd_t *privcmd)
615{
616 int32_t ret = 0;
617
618 switch (privcmd->param_id) {
619 case WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID:
620 ret = wma_set_txrx_fw_stats_level(wma_handle,
621 privcmd->param_vdev_id,
622 privcmd->param_value);
623 break;
624 case WMA_VDEV_TXRX_FWSTATS_RESET_CMDID:
625 ret = wma_txrx_fw_stats_reset(wma_handle,
626 privcmd->param_vdev_id,
627 privcmd->param_value);
628 break;
629 case WMI_STA_SMPS_FORCE_MODE_CMDID:
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800630 ret = wma_set_mimops(wma_handle,
631 privcmd->param_vdev_id,
632 privcmd->param_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 break;
634 case WMI_STA_SMPS_PARAM_CMDID:
635 wma_set_smps_params(wma_handle, privcmd->param_vdev_id,
636 privcmd->param_value);
637 break;
638 case WMA_VDEV_MCC_SET_TIME_LATENCY:
639 {
640 /* Extract first MCC adapter/vdev channel number and latency */
641 uint8_t mcc_channel = privcmd->param_value & 0x000000FF;
642 uint8_t mcc_channel_latency =
643 (privcmd->param_value & 0x0000FF00) >> 8;
644 int ret = -1;
645 WMA_LOGD("%s: Parsed input: Channel #1:%d, latency:%dms",
646 __func__, mcc_channel, mcc_channel_latency);
647 ret = wma_set_mcc_channel_time_latency(wma_handle,
648 mcc_channel,
649 mcc_channel_latency);
650 }
651 break;
652 case WMA_VDEV_MCC_SET_TIME_QUOTA:
653 {
654 /* Extract the MCC 2 adapters/vdevs channel numbers and time
655 * quota value for the first adapter only (which is specified
656 * in iwpriv command.
657 */
658 uint8_t adapter_2_chan_number =
659 privcmd->param_value & 0x000000FF;
660 uint8_t adapter_1_chan_number =
661 (privcmd->param_value & 0x0000FF00) >> 8;
662 uint8_t adapter_1_quota =
663 (privcmd->param_value & 0x00FF0000) >> 16;
664 int ret = -1;
665
666 WMA_LOGD("%s: Parsed input: Channel #1:%d, Channel #2:%d, quota 1:%dms",
667 __func__, adapter_1_chan_number,
668 adapter_2_chan_number, adapter_1_quota);
669
670 ret = wma_set_mcc_channel_time_quota(wma_handle,
671 adapter_1_chan_number,
672 adapter_1_quota,
673 adapter_2_chan_number);
674 }
675 break;
676 case WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE:
677 {
678 wma_handle->wma_ibss_power_save_params.atimWindowLength =
679 privcmd->param_value;
680 WMA_LOGD("%s: IBSS power save ATIM Window = %d",
681 __func__, wma_handle->wma_ibss_power_save_params.
682 atimWindowLength);
683 }
684 break;
685 case WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED:
686 {
687 wma_handle->wma_ibss_power_save_params.isPowerSaveAllowed =
688 privcmd->param_value;
689 WMA_LOGD("%s: IBSS is Power Save Allowed = %d",
690 __func__, wma_handle->wma_ibss_power_save_params.
691 isPowerSaveAllowed);
692 }
693 break;
694 case WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED:
695 {
696 wma_handle->wma_ibss_power_save_params. isPowerCollapseAllowed =
697 privcmd->param_value;
698 WMA_LOGD("%s: IBSS is Power Collapse Allowed = %d",
699 __func__, wma_handle->wma_ibss_power_save_params.
700 isPowerCollapseAllowed);
701 }
702 break;
703 case WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX:
704 {
705 wma_handle->wma_ibss_power_save_params.isAwakeonTxRxEnabled =
706 privcmd->param_value;
707 WMA_LOGD("%s: IBSS Power Save Awake on Tx/Rx Enabled = %d",
708 __func__, wma_handle->wma_ibss_power_save_params.
709 isAwakeonTxRxEnabled);
710 }
711 break;
712 case WMA_VDEV_IBSS_SET_INACTIVITY_TIME:
713 {
714 wma_handle->wma_ibss_power_save_params.inactivityCount =
715 privcmd->param_value;
716 WMA_LOGD("%s: IBSS Power Save Data Inactivity Count = %d",
717 __func__, wma_handle->wma_ibss_power_save_params.
718 inactivityCount);
719 }
720 break;
721 case WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME:
722 {
723 wma_handle->wma_ibss_power_save_params.txSPEndInactivityTime =
724 privcmd->param_value;
725 WMA_LOGD("%s: IBSS Power Save Transmit EOSP inactivity time out = %d",
726 __func__, wma_handle->wma_ibss_power_save_params.
727 txSPEndInactivityTime);
728 }
729 break;
730 case WMA_VDEV_DFS_CONTROL_CMDID:
731 {
732 struct ieee80211com *dfs_ic = wma_handle->dfs_ic;
733 struct ath_dfs *dfs;
734
735 if (!dfs_ic) {
736 ret = -ENOENT;
737 } else {
738 if (dfs_ic->ic_curchan) {
739 WMA_LOGD("%s: Debug cmd: %s received on ch: %d",
740 __func__, "WMA_VDEV_DFS_CONTROL_CMDID",
741 dfs_ic->ic_curchan->ic_ieee);
742
743 if (dfs_ic->ic_curchan->ic_flagext &
744 IEEE80211_CHAN_DFS) {
745 dfs = (struct ath_dfs *)dfs_ic->ic_dfs;
746 dfs->dfs_bangradar = 1;
747 dfs->ath_radar_tasksched = 1;
748 OS_SET_TIMER(&dfs->ath_dfs_task_timer,
749 0);
750 } else {
751 ret = -ENOENT;
752 }
753 } else {
754 ret = -ENOENT;
755 }
756 }
757
758 if (ret == -ENOENT) {
759 WMA_LOGE("%s: Operating channel is not DFS capable,ignoring %s",
760 __func__, "WMA_VDEV_DFS_CONTROL_CMDID");
761 } else if (ret) {
762 WMA_LOGE("%s: Sending command %s failed with %d\n",
763 __func__, "WMA_VDEV_DFS_CONTROL_CMDID",
764 ret);
765 }
766 }
767 break;
768 case WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS:
769 {
770 wma_handle->wma_ibss_power_save_params.ibssPsWarmupTime =
771 privcmd->param_value;
772 WMA_LOGD("%s: IBSS Power Save Warm Up Time in Seconds = %d",
773 __func__, wma_handle->wma_ibss_power_save_params.
774 ibssPsWarmupTime);
775 }
776 break;
777 case WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW:
778 {
779 wma_handle->wma_ibss_power_save_params.ibssPs1RxChainInAtimEnable
780 = privcmd->param_value;
781 WMA_LOGD("%s: IBSS Power Save single RX Chain Enable In ATIM = %d",
782 __func__, wma_handle->wma_ibss_power_save_params.
783 ibssPs1RxChainInAtimEnable);
784 }
785 break;
786
787 case WMA_VDEV_TXRX_GET_IPA_UC_FW_STATS_CMDID:
788 {
Yun Park637d6482016-10-05 10:51:33 -0700789 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800790 struct cdp_pdev *pdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791
Anurag Chouhan6d760662016-02-20 16:05:43 +0530792 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 if (!pdev) {
794 WMA_LOGE("pdev NULL for uc stat");
795 return -EINVAL;
796 }
Yun Park637d6482016-10-05 10:51:33 -0700797 cdp_ipa_get_stat(soc, pdev);
798 }
799 break;
800
801 case WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID:
802 {
803 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
804 struct cdp_pdev *pdev;
805 uint8_t reset_stats = privcmd->param_value;
806
807 WMA_LOGE("%s: reset_stats=%d",
808 "WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID",
809 reset_stats);
810 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
811 if (!pdev) {
812 WMA_LOGE("pdev NULL for uc stat");
813 return -EINVAL;
814 }
815 cdp_ipa_uc_get_share_stats(soc, pdev, reset_stats);
816 }
817 break;
818
819 case WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID:
820 {
821 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
822 struct cdp_pdev *pdev;
823 uint64_t quota_bytes = privcmd->param_value;
824
825 WMA_LOGE("%s: quota_bytes=%llu",
826 "WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID",
827 quota_bytes);
828 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
829 if (!pdev) {
830 WMA_LOGE("pdev NULL for uc stat");
831 return -EINVAL;
832 }
833 cdp_ipa_uc_set_quota(soc, pdev, quota_bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 }
835 break;
836
837 default:
838 WMA_LOGE("Invalid wma config command id:%d", privcmd->param_id);
839 ret = -EINVAL;
840 }
841 return ret;
842}
843
844/**
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -0700845 * wma_set_dtim_period() - set dtim period to FW
846 * @wma: wma handle
847 * @dtim_params: dtim params
848 *
849 * Return: none
850 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -0700851static void wma_set_dtim_period(tp_wma_handle wma,
852 struct set_dtim_params *dtim_params)
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -0700853{
854 QDF_STATUS ret;
855 uint8_t vdev_id = dtim_params->session_id;
856 struct wma_txrx_node *iface =
857 &wma->interfaces[vdev_id];
858
859 WMA_LOGI("%s: set dtim_period %d", __func__,
860 dtim_params->dtim_period);
861 iface->dtimPeriod = dtim_params->dtim_period;
862 ret = wma_vdev_set_param(wma->wmi_handle,
863 vdev_id,
864 WMI_VDEV_PARAM_LISTEN_INTERVAL,
865 dtim_params->dtim_period);
866 if (QDF_IS_STATUS_ERROR(ret))
867 WMA_LOGW("Failed to set listen interval");
868
869}
870/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 * wma_set_modulated_dtim() - function to configure modulated dtim
872 * @wma: wma handle
873 * @privcmd: structure containing parameters
874 *
875 * This function configures the modulated dtim in firmware
876 *
877 * Return: none
878 */
879static void wma_set_modulated_dtim(tp_wma_handle wma,
880 wma_cli_set_cmd_t *privcmd)
881{
882 uint8_t vdev_id = privcmd->param_vdev_id;
883 struct wma_txrx_node *iface =
884 &wma->interfaces[vdev_id];
885 bool prev_dtim_enabled;
886 uint32_t listen_interval;
Govind Singhd76a5b02016-03-08 15:12:14 +0530887 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888
889 iface->alt_modulated_dtim = privcmd->param_value;
890
891 prev_dtim_enabled = iface->alt_modulated_dtim_enabled;
892
893 if (1 != privcmd->param_value)
894 iface->alt_modulated_dtim_enabled = true;
895 else
896 iface->alt_modulated_dtim_enabled = false;
897
898 if ((true == iface->alt_modulated_dtim_enabled) ||
899 (true == prev_dtim_enabled)) {
900
901 listen_interval = iface->alt_modulated_dtim
902 * iface->dtimPeriod;
903
Govind Singhd76a5b02016-03-08 15:12:14 +0530904 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 privcmd->param_vdev_id,
906 WMI_VDEV_PARAM_LISTEN_INTERVAL,
907 listen_interval);
Govind Singhd76a5b02016-03-08 15:12:14 +0530908 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 /* Even if it fails, continue */
910 WMA_LOGW("Failed to set listen interval %d",
911 listen_interval);
912
Govind Singhd76a5b02016-03-08 15:12:14 +0530913 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 privcmd->param_vdev_id,
915 WMI_VDEV_PARAM_DTIM_POLICY ,
916 NORMAL_DTIM);
Govind Singhd76a5b02016-03-08 15:12:14 +0530917 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 WMA_LOGE("Failed to Set to Normal DTIM policy");
919 }
920}
921
922
923/**
924 * wma_process_cli_set_cmd() - set parameters to fw
925 * @wma: wma handle
926 * @privcmd: command
927 *
928 * Return: none
929 */
930static void wma_process_cli_set_cmd(tp_wma_handle wma,
931 wma_cli_set_cmd_t *privcmd)
932{
Govind Singhd76a5b02016-03-08 15:12:14 +0530933 int vid = privcmd->param_vdev_id, pps_val = 0;
934 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 struct wma_txrx_node *intr = wma->interfaces;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530936 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937 struct qpower_params *qparams = &intr[vid].config.qpower_params;
Govind Singhd76a5b02016-03-08 15:12:14 +0530938 struct pdev_params pdev_param;
Leo Chang96464902016-10-28 11:10:54 -0700939 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940
941 WMA_LOGD("wmihandle %p", wma->wmi_handle);
942
943 if (NULL == pMac) {
944 WMA_LOGE("%s: Failed to get pMac", __func__);
945 return;
946 }
947
948 if (privcmd->param_id >= WMI_CMDID_MAX) {
949 /*
950 * This configuration setting is not done using any wmi
951 * command, call appropriate handler.
952 */
953 if (wma_set_priv_cfg(wma, privcmd))
954 WMA_LOGE("Failed to set wma priv congiuration");
955 return;
956 }
957
958 switch (privcmd->param_vp_dev) {
959 case VDEV_CMD:
Bhargav Shaha89d3b42016-04-20 13:04:56 +0530960 if (!wma->interfaces[privcmd->param_vdev_id].is_vdev_valid) {
961 WMA_LOGE("%s Vdev id is not valid", __func__);
962 return ;
963 }
964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
966 privcmd->param_id, privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530967 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 privcmd->param_vdev_id,
969 privcmd->param_id,
970 privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530971 if (QDF_IS_STATUS_ERROR(ret)) {
972 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 ret);
974 return;
975 }
976 break;
977 case PDEV_CMD:
978 WMA_LOGD("pdev pid %d pval %d", privcmd->param_id,
979 privcmd->param_value);
980 if ((privcmd->param_id == WMI_PDEV_PARAM_RX_CHAIN_MASK) ||
981 (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK)) {
982 wma_update_txrx_chainmask(wma->num_rf_chains,
983 &privcmd->param_value);
984 }
Govind Singhd76a5b02016-03-08 15:12:14 +0530985 pdev_param.param_id = privcmd->param_id;
986 pdev_param.param_value = privcmd->param_value;
987 ret = wmi_unified_pdev_param_send(wma->wmi_handle,
988 &pdev_param,
989 WMA_WILDCARD_PDEV_ID);
990 if (QDF_IS_STATUS_ERROR(ret)) {
991 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 ret);
993 return;
994 }
995 break;
996 case GEN_CMD:
997 {
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800998 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 struct wma_txrx_node *intr = wma->interfaces;
1000
1001 vdev = wma_find_vdev_by_id(wma, privcmd->param_vdev_id);
1002 if (!vdev) {
1003 WMA_LOGE("%s:Invalid vdev handle", __func__);
1004 return;
1005 }
1006
1007 WMA_LOGD("gen pid %d pval %d", privcmd->param_id,
1008 privcmd->param_value);
1009
1010 switch (privcmd->param_id) {
1011 case GEN_VDEV_PARAM_AMPDU:
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301012 if (soc) {
1013 ret = cdp_aggr_cfg(soc, vdev,
1014 privcmd->param_value, 0);
1015 if (ret)
1016 WMA_LOGE("cdp_aggr_cfg set ampdu failed ret %d",
1017 ret);
1018 else
1019 intr[privcmd->param_vdev_id].config.
1020 ampdu = privcmd->param_value;
1021 } else {
1022 WMA_LOGE("%s:SOC context is NULL", __func__);
1023 return;
1024 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 break;
1026 case GEN_VDEV_PARAM_AMSDU:
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301027 if (soc) {
1028 ret = cdp_aggr_cfg(soc, vdev, 0,
1029 privcmd->param_value);
1030 if (ret)
1031 WMA_LOGE("cdp_aggr_cfg set amsdu failed ret %d",
1032 ret);
1033 else
1034 intr[privcmd->param_vdev_id].config.
1035 amsdu = privcmd->param_value;
1036 } else {
1037 WMA_LOGE("%s:SOC context is NULL", __func__);
1038 return;
1039 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 case GEN_PARAM_CRASH_INJECT:
Rajeev Kumar0a9901b2015-12-15 15:59:19 -08001042 if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
1043 WMA_LOGE("Crash inject not allowed in FTM mode");
1044 else
1045 ret = wma_crash_inject(wma,
1046 privcmd->param_value,
1047 privcmd->param_sec_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001049 case GEN_PARAM_CAPTURE_TSF:
1050 ret = wma_capture_tsf(wma, privcmd->param_value);
1051 break;
1052 case GEN_PARAM_RESET_TSF_GPIO:
1053 ret = wma_reset_tsf_gpio(wma, privcmd->param_value);
1054 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 case GEN_PARAM_MODULATED_DTIM:
1056 wma_set_modulated_dtim(wma, privcmd);
1057 break;
1058 default:
1059 WMA_LOGE("Invalid param id 0x%x",
1060 privcmd->param_id);
1061 break;
1062 }
1063 break;
1064 }
1065 case DBG_CMD:
1066 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1067 privcmd->param_value);
1068 switch (privcmd->param_id) {
1069 case WMI_DBGLOG_LOG_LEVEL:
1070 ret = dbglog_set_log_lvl(wma->wmi_handle,
1071 privcmd->param_value);
1072 if (ret)
1073 WMA_LOGE("dbglog_set_log_lvl failed ret %d",
1074 ret);
1075 break;
1076 case WMI_DBGLOG_VAP_ENABLE:
1077 ret = dbglog_vap_log_enable(wma->wmi_handle,
1078 privcmd->param_value, true);
1079 if (ret)
1080 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1081 ret);
1082 break;
1083 case WMI_DBGLOG_VAP_DISABLE:
1084 ret = dbglog_vap_log_enable(wma->wmi_handle,
1085 privcmd->param_value, false);
1086 if (ret)
1087 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1088 ret);
1089 break;
1090 case WMI_DBGLOG_MODULE_ENABLE:
1091 ret = dbglog_module_log_enable(wma->wmi_handle,
1092 privcmd->param_value, true);
1093 if (ret)
1094 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1095 ret);
1096 break;
1097 case WMI_DBGLOG_MODULE_DISABLE:
1098 ret = dbglog_module_log_enable(wma->wmi_handle,
1099 privcmd->param_value, false);
1100 if (ret)
1101 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1102 ret);
1103 break;
1104 case WMI_DBGLOG_MOD_LOG_LEVEL:
1105 ret = dbglog_set_mod_log_lvl(wma->wmi_handle,
1106 privcmd->param_value);
1107 if (ret)
1108 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1109 ret);
1110 break;
1111 case WMI_DBGLOG_TYPE:
1112 ret = dbglog_parser_type_init(wma->wmi_handle,
1113 privcmd->param_value);
1114 if (ret)
1115 WMA_LOGE("dbglog_parser_type_init failed ret %d",
1116 ret);
1117 break;
1118 case WMI_DBGLOG_REPORT_ENABLE:
1119 ret = dbglog_report_enable(wma->wmi_handle,
1120 privcmd->param_value);
1121 if (ret)
1122 WMA_LOGE("dbglog_report_enable failed ret %d",
1123 ret);
1124 break;
Govind Singha471e5e2015-10-12 17:11:14 +05301125 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301126 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301127 WMI_WLAN_PROFILE_TRIGGER_CMDID,
1128 privcmd->param_value, 0);
1129 if (ret)
1130 WMA_LOGE("Profile cmd failed for %d ret %d",
1131 WMI_WLAN_PROFILE_TRIGGER_CMDID, ret);
1132 break;
1133 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301134 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301135 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1136 privcmd->param_value,
1137 privcmd->param_sec_value);
1138 if (ret)
1139 WMA_LOGE("Profile cmd failed for %d ret %d",
1140 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1141 ret);
1142 break;
1143 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301144 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301145 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1146 privcmd->param_value,
1147 privcmd->param_sec_value);
1148 if (ret)
1149 WMA_LOGE("Profile cmd failed for %d ret %d",
1150 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1151 ret);
1152 break;
1153 case WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301154 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301155 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1156 0, 0);
1157 if (ret)
1158 WMA_LOGE("Profile cmd failed for %d ret %d",
1159 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1160 ret);
1161 break;
1162 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301163 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301164 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1165 0, 0);
1166 if (ret)
1167 WMA_LOGE("Profile cmd failed for %d ret %d",
1168 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1169 ret);
1170 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171 case WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID:
1172 /* Set the Green AP */
Govind Singhd76a5b02016-03-08 15:12:14 +05301173 ret = wmi_unified_green_ap_ps_send
1174 (wma->wmi_handle, privcmd->param_value,
1175 WMA_WILDCARD_PDEV_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176 if (ret) {
1177 WMA_LOGE("Set GreenAP Failed val %d",
1178 privcmd->param_value);
1179 }
1180 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181
1182 default:
1183 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1184 break;
1185 }
1186 break;
1187 case PPS_CMD:
1188 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1189 privcmd->param_value);
1190 switch (privcmd->param_id) {
1191
1192 case WMI_VDEV_PPS_PAID_MATCH:
1193 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1194 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
1195 intr[vid].config.pps_params.paid_match_enable =
1196 privcmd->param_value;
1197 break;
1198 case WMI_VDEV_PPS_GID_MATCH:
1199 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1200 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
1201 intr[vid].config.pps_params.gid_match_enable =
1202 privcmd->param_value;
1203 break;
1204 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
1205 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1206 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
1207 intr[vid].config.pps_params.tim_clear =
1208 privcmd->param_value;
1209 break;
1210 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
1211 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1212 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
1213 intr[vid].config.pps_params.dtim_clear =
1214 privcmd->param_value;
1215 break;
1216 case WMI_VDEV_PPS_EOF_PAD_DELIM:
1217 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1218 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
1219 intr[vid].config.pps_params.eof_delim =
1220 privcmd->param_value;
1221 break;
1222 case WMI_VDEV_PPS_MACADDR_MISMATCH:
1223 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1224 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
1225 intr[vid].config.pps_params.mac_match =
1226 privcmd->param_value;
1227 break;
1228 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
1229 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1230 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
1231 intr[vid].config.pps_params.delim_fail =
1232 privcmd->param_value;
1233 break;
1234 case WMI_VDEV_PPS_GID_NSTS_ZERO:
1235 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1236 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
1237 intr[vid].config.pps_params.nsts_zero =
1238 privcmd->param_value;
1239 break;
1240 case WMI_VDEV_PPS_RSSI_CHECK:
1241 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1242 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
1243 intr[vid].config.pps_params.rssi_chk =
1244 privcmd->param_value;
1245 break;
1246 case WMI_VDEV_PPS_5G_EBT:
1247 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1248 (PKT_PWR_SAVE_5G_EBT & 0xffff);
1249 intr[vid].config.pps_params.ebt_5g =
1250 privcmd->param_value;
1251 break;
1252 default:
1253 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1254 break;
1255 }
1256 break;
1257
1258 case QPOWER_CMD:
1259 WMA_LOGD("QPOWER CLI CMD pid %d pval %d", privcmd->param_id,
1260 privcmd->param_value);
1261 switch (privcmd->param_id) {
1262 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
1263 WMA_LOGD("QPOWER CLI CMD:Ps Poll Cnt val %d",
1264 privcmd->param_value);
1265 /* Set the QPower Ps Poll Count */
Govind Singhd76a5b02016-03-08 15:12:14 +05301266 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 vid, WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
1268 privcmd->param_value);
1269 if (ret) {
1270 WMA_LOGE("Set Q-PsPollCnt Failed vdevId %d val %d",
1271 vid, privcmd->param_value);
1272 } else {
1273 qparams->max_ps_poll_cnt = privcmd->param_value;
1274 }
1275 break;
1276 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
1277 WMA_LOGD("QPOWER CLI CMD:Max Tx Before wake val %d",
1278 privcmd->param_value);
1279 /* Set the QPower Max Tx Before Wake */
Govind Singhd76a5b02016-03-08 15:12:14 +05301280 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 vid, WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
1282 privcmd->param_value);
1283 if (ret) {
1284 WMA_LOGE("Set Q-MaxTxBefWake Failed vId %d val %d",
1285 vid, privcmd->param_value);
1286 } else {
1287 qparams->max_tx_before_wake =
1288 privcmd->param_value;
1289 }
1290 break;
1291 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
1292 WMA_LOGD("QPOWER CLI CMD:Ps Poll Wake Inv val %d",
1293 privcmd->param_value);
1294 /* Set the QPower Spec Ps Poll Wake Inv */
Govind Singhd76a5b02016-03-08 15:12:14 +05301295 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 vid, WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
1297 privcmd->param_value);
1298 if (ret) {
1299 WMA_LOGE("Set Q-PsPoll WakeIntv Failed vId %d val %d",
1300 vid, privcmd->param_value);
1301 } else {
1302 qparams->spec_ps_poll_wake_interval =
1303 privcmd->param_value;
1304 }
1305 break;
1306 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
1307 WMA_LOGD("QPOWER CLI CMD:Spec NoData Ps Poll val %d",
1308 privcmd->param_value);
1309 /* Set the QPower Spec NoData PsPoll */
Govind Singhd76a5b02016-03-08 15:12:14 +05301310 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 vid, WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
1312 privcmd->param_value);
1313 if (ret) {
1314 WMA_LOGE("Set Q-SpecNoDataPsPoll Failed vId %d val %d",
1315 vid, privcmd->param_value);
1316 } else {
1317 qparams->max_spec_nodata_ps_poll =
1318 privcmd->param_value;
1319 }
1320 break;
1321
1322 default:
1323 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1324 break;
1325 }
1326 break;
1327 case GTX_CMD:
1328 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1329 privcmd->param_id, privcmd->param_value);
1330 switch (privcmd->param_id) {
1331 case WMI_VDEV_PARAM_GTX_HT_MCS:
1332 intr[vid].config.gtx_info.gtxRTMask[0] =
1333 privcmd->param_value;
1334 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1335 privcmd->param_vdev_id,
1336 &intr[vid].config.gtx_info);
1337 break;
1338 case WMI_VDEV_PARAM_GTX_VHT_MCS:
1339 intr[vid].config.gtx_info.gtxRTMask[1] =
1340 privcmd->param_value;
1341 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1342 privcmd->param_vdev_id,
1343 &intr[vid].config.gtx_info);
1344 break;
1345
1346 case WMI_VDEV_PARAM_GTX_USR_CFG:
1347 intr[vid].config.gtx_info.gtxUsrcfg =
1348 privcmd->param_value;
1349 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1350 privcmd->param_vdev_id,
1351 &intr[vid].config.gtx_info);
1352 break;
1353
1354 case WMI_VDEV_PARAM_GTX_THRE:
1355 intr[vid].config.gtx_info.gtxPERThreshold =
1356 privcmd->param_value;
1357 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1358 privcmd->param_vdev_id,
1359 &intr[vid].config.gtx_info);
1360 break;
1361
1362 case WMI_VDEV_PARAM_GTX_MARGIN:
1363 intr[vid].config.gtx_info.gtxPERMargin =
1364 privcmd->param_value;
1365 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1366 privcmd->param_vdev_id,
1367 &intr[vid].config.gtx_info);
1368 break;
1369
1370 case WMI_VDEV_PARAM_GTX_STEP:
1371 intr[vid].config.gtx_info.gtxTPCstep =
1372 privcmd->param_value;
1373 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1374 privcmd->param_vdev_id,
1375 &intr[vid].config.gtx_info);
1376 break;
1377
1378 case WMI_VDEV_PARAM_GTX_MINTPC:
1379 intr[vid].config.gtx_info.gtxTPCMin =
1380 privcmd->param_value;
1381 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1382 privcmd->param_vdev_id,
1383 &intr[vid].config.gtx_info);
1384 break;
1385
1386 case WMI_VDEV_PARAM_GTX_BW_MASK:
1387 intr[vid].config.gtx_info.gtxBWMask =
1388 privcmd->param_value;
1389 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1390 privcmd->param_vdev_id,
1391 &intr[vid].config.gtx_info);
1392 if (ret) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301393 WMA_LOGE("wma_vdev_set_param"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 " failed ret %d", ret);
1395 return;
1396 }
1397 break;
1398 default:
1399 break;
1400 }
1401 break;
1402
1403 default:
1404 WMA_LOGE("Invalid vpdev command id");
1405 }
1406 if (1 == privcmd->param_vp_dev) {
1407 switch (privcmd->param_id) {
1408 case WMI_VDEV_PARAM_NSS:
1409 intr[vid].config.nss = privcmd->param_value;
1410 break;
1411 case WMI_VDEV_PARAM_LDPC:
1412 intr[vid].config.ldpc = privcmd->param_value;
1413 break;
1414 case WMI_VDEV_PARAM_TX_STBC:
1415 intr[vid].config.tx_stbc = privcmd->param_value;
1416 break;
1417 case WMI_VDEV_PARAM_RX_STBC:
1418 intr[vid].config.rx_stbc = privcmd->param_value;
1419 break;
1420 case WMI_VDEV_PARAM_SGI:
1421 intr[vid].config.shortgi = privcmd->param_value;
1422 break;
1423 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
1424 intr[vid].config.rtscts_en = privcmd->param_value;
1425 break;
1426 case WMI_VDEV_PARAM_CHWIDTH:
1427 intr[vid].config.chwidth = privcmd->param_value;
1428 break;
1429 case WMI_VDEV_PARAM_FIXED_RATE:
1430 intr[vid].config.tx_rate = privcmd->param_value;
1431 break;
1432 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE:
1433 intr[vid].config.erx_adjust = privcmd->param_value;
1434 break;
1435 case WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM:
1436 intr[vid].config.erx_bmiss_num = privcmd->param_value;
1437 break;
1438 case WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE:
1439 intr[vid].config.erx_bmiss_cycle = privcmd->param_value;
1440 break;
1441 case WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP:
1442 intr[vid].config.erx_slop_step = privcmd->param_value;
1443 break;
1444 case WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP:
1445 intr[vid].config.erx_init_slop = privcmd->param_value;
1446 break;
1447 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE:
1448 intr[vid].config.erx_adj_pause = privcmd->param_value;
1449 break;
1450 case WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE:
1451 intr[vid].config.erx_dri_sample = privcmd->param_value;
1452 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001453 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001454 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001455 wma_set_he_vdev_param(&intr[vid], privcmd->param_id,
1456 privcmd->param_value);
1457 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 default:
1459 WMA_LOGE("Invalid wma_cli_set vdev command/Not"
1460 " yet implemented 0x%x", privcmd->param_id);
1461 break;
1462 }
1463 } else if (2 == privcmd->param_vp_dev) {
1464 switch (privcmd->param_id) {
1465 case WMI_PDEV_PARAM_ANI_ENABLE:
1466 wma->pdevconfig.ani_enable = privcmd->param_value;
1467 break;
1468 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
1469 wma->pdevconfig.ani_poll_len = privcmd->param_value;
1470 break;
1471 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
1472 wma->pdevconfig.ani_listen_len = privcmd->param_value;
1473 break;
1474 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
1475 wma->pdevconfig.ani_ofdm_level = privcmd->param_value;
1476 break;
1477 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
1478 wma->pdevconfig.ani_cck_level = privcmd->param_value;
1479 break;
1480 case WMI_PDEV_PARAM_DYNAMIC_BW:
1481 wma->pdevconfig.cwmenable = privcmd->param_value;
1482 break;
1483 case WMI_PDEV_PARAM_CTS_CBW:
1484 wma->pdevconfig.cts_cbw = privcmd->param_value;
1485 break;
1486 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
1487 wma->pdevconfig.txchainmask = privcmd->param_value;
1488 break;
1489 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
1490 wma->pdevconfig.rxchainmask = privcmd->param_value;
1491 break;
1492 case WMI_PDEV_PARAM_BURST_ENABLE:
1493 wma->pdevconfig.burst_enable = privcmd->param_value;
1494 if ((wma->pdevconfig.burst_enable == 1) &&
1495 (wma->pdevconfig.burst_dur == 0))
1496 wma->pdevconfig.burst_dur =
1497 WMA_DEFAULT_SIFS_BURST_DURATION;
1498 else if (wma->pdevconfig.burst_enable == 0)
1499 wma->pdevconfig.burst_dur = 0;
1500 break;
1501 case WMI_PDEV_PARAM_BURST_DUR:
1502 wma->pdevconfig.burst_dur = privcmd->param_value;
1503 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
1505 wma->pdevconfig.txpow2g = privcmd->param_value;
1506 if ((pMac->roam.configParam.bandCapability ==
1507 eCSR_BAND_ALL) ||
1508 (pMac->roam.configParam.bandCapability ==
1509 eCSR_BAND_24)) {
1510 if (cfg_set_int(pMac,
1511 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1512 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301513 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1515
1516 } else {
1517 WMA_LOGE("Current band is not 2G");
1518 }
1519 break;
1520 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
1521 wma->pdevconfig.txpow5g = privcmd->param_value;
1522 if ((pMac->roam.configParam.bandCapability ==
1523 eCSR_BAND_ALL) ||
1524 (pMac->roam.configParam.bandCapability ==
1525 eCSR_BAND_5G)) {
1526 if (cfg_set_int(pMac,
1527 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1528 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301529 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1531
1532 } else {
1533 WMA_LOGE("Current band is not 5G");
1534 }
1535 break;
1536 default:
1537 WMA_LOGE("Invalid wma_cli_set pdev command/Not yet implemented 0x%x",
1538 privcmd->param_id);
1539 break;
1540 }
1541 } else if (5 == privcmd->param_vp_dev) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301542 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 privcmd->param_vdev_id,
1544 WMI_VDEV_PARAM_PACKET_POWERSAVE,
1545 pps_val);
1546 if (ret)
1547 WMA_LOGE("Failed to send wmi packet power save cmd");
1548 else
1549 WMA_LOGD("Sent packet power save cmd %d value %x to target",
1550 privcmd->param_id, pps_val);
1551 }
1552}
1553
1554/**
1555 * wma_process_fw_event() - process any fw event
1556 * @wma: wma handle
1557 * @buf: fw event buffer
1558 *
1559 * This function process any fw event to serialize it through mc thread.
1560 *
1561 * Return: none
1562 */
1563static int wma_process_fw_event(tp_wma_handle wma,
1564 wma_process_fw_event_params *buf)
1565{
1566 struct wmi_unified *wmi_handle = (struct wmi_unified *)buf->wmi_handle;
1567
1568 wmi_process_fw_event(wmi_handle, buf->evt_buf);
1569 return 0;
1570}
1571
1572/**
Govind Singhd76a5b02016-03-08 15:12:14 +05301573 * wmi_process_fw_event_tasklet_ctx() - process in tasklet context
1574 * @ctx: handle to wmi
1575 * @ev: wmi event buffer
1576 *
1577 * Event process by below function will be in tasket context,
1578 * need to use this method only for time sensitive functions.
1579 *
1580 * Return: none
1581 */
1582static int wma_process_fw_event_tasklet_ctx(void *ctx, void *ev)
1583{
1584 wmi_process_fw_event(ctx, ev);
1585
1586 return 0;
1587}
1588
1589/**
Manjeet Singhf82ed072016-07-08 11:40:00 +05301590 * wma_process_hal_pwr_dbg_cmd() - send hal pwr dbg cmd to fw.
1591 * @handle: wma handle
1592 * @sir_pwr_dbg_params: unit test command
1593 *
1594 * This function send unit test command to fw.
1595 *
1596 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
1597 */
1598QDF_STATUS wma_process_hal_pwr_dbg_cmd(WMA_HANDLE handle,
1599 struct sir_mac_pwr_dbg_cmd *
1600 sir_pwr_dbg_params)
1601{
1602 tp_wma_handle wma_handle = (tp_wma_handle)handle;
1603 int i;
1604 struct wmi_power_dbg_params wmi_pwr_dbg_params;
1605 QDF_STATUS status;
1606
1607 if (!sir_pwr_dbg_params) {
1608 WMA_LOGE("%s: sir_pwr_dbg_params is null", __func__);
1609 return QDF_STATUS_E_INVAL;
1610 }
1611 wmi_pwr_dbg_params.module_id = sir_pwr_dbg_params->module_id;
1612 wmi_pwr_dbg_params.pdev_id = sir_pwr_dbg_params->pdev_id;
1613 wmi_pwr_dbg_params.num_args = sir_pwr_dbg_params->num_args;
1614
1615 for (i = 0; i < wmi_pwr_dbg_params.num_args; i++)
1616 wmi_pwr_dbg_params.args[i] = sir_pwr_dbg_params->args[i];
1617
1618 status = wmi_unified_send_power_dbg_cmd(wma_handle->wmi_handle,
1619 &wmi_pwr_dbg_params);
1620
1621 return status;
1622}
1623
1624/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 * wma_process_fw_event_handler() - common event handler to serialize
1626 * event processing through mc_thread
Govind Singhd76a5b02016-03-08 15:12:14 +05301627 * @ctx: wmi context
1628 * @ev: event buffer
1629 * @rx_ctx: rx execution context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 *
1631 * Return: 0 on success, errno on failure
1632 */
Govind Singhd76a5b02016-03-08 15:12:14 +05301633static int wma_process_fw_event_mc_thread_ctx(void *ctx, void *ev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634{
1635 wma_process_fw_event_params *params_buf;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001636 struct scheduler_msg cds_msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301638 params_buf = qdf_mem_malloc(sizeof(wma_process_fw_event_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 if (!params_buf) {
1640 WMA_LOGE("%s: Failed alloc memory for params_buf", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301641 qdf_nbuf_free(ev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 return -ENOMEM;
1643 }
1644
Govind Singhd76a5b02016-03-08 15:12:14 +05301645 params_buf->wmi_handle = (struct wmi_unified *)ctx;
1646 params_buf->evt_buf = (wmi_buf_t *)ev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647
1648 cds_msg.type = WMA_PROCESS_FW_EVENT;
1649 cds_msg.bodyptr = params_buf;
1650 cds_msg.bodyval = 0;
1651
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301652 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001653 scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 WMA_LOGP("%s: Failed to post WMA_PROCESS_FW_EVENT msg",
1655 __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301656 qdf_nbuf_free(ev);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301657 qdf_mem_free(params_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001658 return -EFAULT;
1659 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 return 0;
1661
1662}
1663
Govind Singhd76a5b02016-03-08 15:12:14 +05301664/**
1665 * wma_process_fw_event_handler() - common event handler to serialize
1666 * event processing through mc_thread
1667 * @ctx: wmi context
1668 * @ev: event buffer
1669 * @rx_ctx: rx execution context
1670 *
1671 * Return: 0 on success, errno on failure
1672 */
1673int wma_process_fw_event_handler(void *ctx, void *ev, uint8_t rx_ctx)
1674{
1675 int err = 0;
1676
1677 if (rx_ctx == WMA_RX_SERIALIZER_CTX) {
1678 err = wma_process_fw_event_mc_thread_ctx(ctx, ev);
1679 } else if (rx_ctx == WMA_RX_TASKLET_CTX) {
1680 wma_process_fw_event_tasklet_ctx(ctx, ev);
1681 } else {
1682 WMA_LOGE("%s: invalid wmi event execution context", __func__);
1683 qdf_nbuf_free(ev);
1684 }
1685
1686 return err;
1687}
1688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689#ifdef WLAN_FEATURE_NAN
1690/**
1691 * wma_set_nan_enable() - set nan enable flag in WMA handle
1692 * @wma_handle: Pointer to wma handle
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301693 * @cds_cfg: Pointer to CDS Configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 *
1695 * Return: none
1696 */
1697static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301698 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699{
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301700 wma_handle->is_nan_enabled = cds_cfg->is_nan_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001701}
1702#else
1703static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301704 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705{
1706}
1707#endif
1708
1709/**
Komal Seelam02d09342016-02-23 18:03:19 +05301710 * wma_init_max_no_of_peers - API to initialize wma configuration params
1711 * @wma_handle: WMA Handle
1712 * @max_peers: Max Peers supported
1713 *
1714 * Return: void
1715 */
1716static void wma_init_max_no_of_peers(tp_wma_handle wma_handle,
1717 uint16_t max_peers)
1718{
1719 struct wma_ini_config *cfg = wma_get_ini_handle(wma_handle);
1720
Naveen Rawat35804772016-06-27 15:40:28 -07001721 if (cfg == NULL) {
1722 WMA_LOGE("%s: NULL WMA ini handle", __func__);
1723 return;
1724 }
1725
Komal Seelam02d09342016-02-23 18:03:19 +05301726 cfg->max_no_of_peers = max_peers;
1727}
1728
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001729/**
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001730 * wma_cleanup_vdev_resp_queue() - cleanup vdev response queue
1731 * @wma: wma handle
1732 *
1733 * Return: none
1734 */
1735static void wma_cleanup_vdev_resp_queue(tp_wma_handle wma)
1736{
1737 struct wma_target_req *req_msg = NULL;
1738 qdf_list_node_t *node1 = NULL;
1739 QDF_STATUS status;
1740
1741 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1742 if (!qdf_list_size(&wma->vdev_resp_queue)) {
1743 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
1744 WMA_LOGI(FL("request queue maybe empty"));
1745 return;
1746 }
1747
1748 while (qdf_list_peek_front(&wma->vdev_resp_queue, &node1) !=
1749 QDF_STATUS_SUCCESS) {
1750 req_msg = qdf_container_of(node1, struct wma_target_req, node);
1751 status = qdf_list_remove_node(&wma->vdev_resp_queue, node1);
1752 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
1753 if (status != QDF_STATUS_SUCCESS) {
1754 WMA_LOGE(FL("Failed to remove req vdev_id %d type %d"),
1755 req_msg->vdev_id, req_msg->type);
1756 return;
1757 }
1758 qdf_mc_timer_destroy(&req_msg->event_timeout);
1759 qdf_mem_free(req_msg);
1760 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1761 }
1762 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
1763}
1764
1765/**
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001766 * wma_shutdown_notifier_cb - Shutdown notifer call back
1767 * @priv : WMA handle
1768 *
1769 * During recovery, WMA may wait for resume to complete if the crash happens
1770 * while in suspend. This may cause delays in completing the recovery. This call
1771 * back would be called during recovery and the event is completed so that if
1772 * the resume is waiting on FW to respond then it can get out of the wait so
1773 * that recovery thread can start bringing down all the modules.
1774 *
1775 * Return: None
1776 */
1777static void wma_shutdown_notifier_cb(void *priv)
1778{
1779 tp_wma_handle wma_handle = priv;
1780
1781 qdf_event_set(&wma_handle->wma_resume_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001782 wma_cleanup_vdev_resp_queue(wma_handle);
Mukul Sharma4c60a7e2017-03-06 19:42:18 +05301783 pmo_ucfg_psoc_wakeup_host_event_received(wma_handle->psoc);
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001784}
1785
Mukul Sharma5ff3c582016-09-12 15:23:35 +05301786struct wma_version_info g_wmi_version_info;
1787
Komal Seelam02d09342016-02-23 18:03:19 +05301788/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301789 * wma_state_info_dump() - prints state information of wma layer
1790 * @buf: buffer pointer
1791 * @size: size of buffer to be filled
1792 *
1793 * This function is used to dump state information of wma layer
1794 *
1795 * Return: None
1796 */
1797static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
1798{
Dustin Brown9d797d62017-01-11 16:39:12 -08001799 t_wma_handle *wma;
1800 struct sir_vdev_wow_stats *stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301801 uint16_t len = 0;
1802 char *buf = *buf_ptr;
1803 struct wma_txrx_node *iface;
1804 uint8_t vdev_id;
1805
Dustin Brown9d797d62017-01-11 16:39:12 -08001806 wma = cds_get_context(QDF_MODULE_ID_WMA);
1807 if (!wma) {
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301808 WMA_LOGE("%s: WMA context is invald!", __func__);
1809 return;
1810 }
1811
1812 WMA_LOGI("%s: size of buffer: %d", __func__, *size);
1813
Dustin Brown9d797d62017-01-11 16:39:12 -08001814 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
1815 iface = &wma->interfaces[vdev_id];
1816 if (!iface->handle)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301817 continue;
1818
Dustin Brown9d797d62017-01-11 16:39:12 -08001819 stats = &iface->wow_stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301820 len += qdf_scnprintf(buf + len, *size - len,
Dustin Brown9d797d62017-01-11 16:39:12 -08001821 "\n"
1822 "vdev_id %d\n"
1823 "WoW Stats\n"
1824 "\tpno_match %u\n"
1825 "\tpno_complete %u\n"
1826 "\tgscan %u\n"
1827 "\tlow_rssi %u\n"
1828 "\trssi_breach %u\n"
1829 "\tucast %u\n"
1830 "\tbcast %u\n"
1831 "\ticmpv4 %u\n"
1832 "\ticmpv6 %u\n"
1833 "\tipv4_mcast %u\n"
1834 "\tipv6_mcast %u\n"
1835 "\tipv6_mcast_ra %u\n"
1836 "\tipv6_mcast_ns %u\n"
1837 "\tipv6_mcast_na %u\n"
1838 "\toem_response %u\n"
1839 "conn_state %d\n"
1840 "dtimPeriod %d\n"
1841 "chanmode %d\n"
1842 "vht_capable %d\n"
1843 "ht_capable %d\n"
1844 "chan_width %d\n"
1845 "vdev_active %d\n"
1846 "vdev_up %d\n"
1847 "aid %d\n"
1848 "rate_flags %d\n"
1849 "nss %d\n"
1850 "tx_power %d\n"
1851 "max_tx_power %d\n"
1852 "nwType %d\n"
1853 "tx_streams %d\n"
1854 "rx_streams %d\n"
1855 "chain_mask %d\n"
1856 "nss_2g %d\n"
1857 "nss_5g %d",
1858 vdev_id,
1859 stats->pno_match,
1860 stats->pno_complete,
1861 stats->gscan,
1862 stats->low_rssi,
1863 stats->rssi_breach,
1864 stats->ucast,
1865 stats->bcast,
1866 stats->icmpv4,
1867 stats->icmpv6,
1868 stats->ipv4_mcast,
1869 stats->ipv6_mcast,
1870 stats->ipv6_mcast_ra,
1871 stats->ipv6_mcast_ns,
1872 stats->ipv6_mcast_na,
1873 stats->oem_response,
1874 iface->conn_state,
1875 iface->dtimPeriod,
1876 iface->chanmode,
1877 iface->vht_capable,
1878 iface->ht_capable,
1879 iface->chan_width,
1880 iface->vdev_active,
Mukul Sharmaf9047232017-03-02 16:58:56 +05301881 wma_is_vdev_up(vdev_id),
Dustin Brown9d797d62017-01-11 16:39:12 -08001882 iface->aid,
1883 iface->rate_flags,
1884 iface->nss,
1885 iface->tx_power,
1886 iface->max_tx_power,
1887 iface->nwType,
1888 iface->tx_streams,
1889 iface->rx_streams,
1890 iface->chain_mask,
1891 iface->nss_2g,
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301892 iface->nss_5g);
1893 }
1894
1895 *size -= len;
1896 *buf_ptr += len;
1897}
1898
1899/**
1900 * wma_register_debug_callback() - registration function for wma layer
1901 * to print wma state information
1902 */
1903static void wma_register_debug_callback(void)
1904{
1905 qdf_register_debug_callback(QDF_MODULE_ID_WMA, &wma_state_info_dump);
1906}
1907
Frank Liu65b17d92016-11-23 15:58:44 +08001908/**
1909 * wma_register_tx_ops_handler() - register tx_ops of southbound
1910 * @tx_ops: tx_ops pointer in southbound
1911 *
1912 * Return: 0 on success, errno on failure
1913 */
1914static QDF_STATUS
1915wma_register_tx_ops_handler(struct wlan_lmac_if_tx_ops *tx_ops)
1916{
1917 /*
1918 * Assign tx_ops, it's up to UMAC modules to declare and define these
1919 * functions which are used to send wmi command to target.
1920 */
1921
Himanshu Agarwalce716f82016-12-21 19:07:54 +05301922 if (!tx_ops) {
1923 WMA_LOGE("%s: pointer to lmac if tx ops is NULL", __func__);
1924 return QDF_STATUS_E_INVAL;
1925 }
1926
1927 /* mgmt_txrx component's tx ops */
1928 tx_ops->mgmt_txrx_tx_ops.mgmt_tx_send = wma_mgmt_unified_cmd_send;
1929
Frank Liu65b17d92016-11-23 15:58:44 +08001930 return QDF_STATUS_SUCCESS;
1931}
1932
1933/**
1934 * wma_target_if_open() - Attach UMAC modules' interface with wmi layer
1935 * @wma_handle: wma handle
1936 *
1937 * Separate module defines below functions:
1938 * 1. tgt_wmi_<module>_<action> api sends wmi command, assigned to south bound
1939 * tx_ops function pointers;
1940 * 2. module's south dispatcher handles information from lower layer, assigned
1941 * to south bound rx_ops function pointers;
1942 * 3. wmi event handler deals with wmi event, extracts umac needed information,
1943 * and call rx_ops(module's dispatcher). It executes in tasklet context and
1944 * is up to dispatcher to decide the context to reside in tasklet or in
1945 * thread context.
1946 *
1947 * Return: None
1948 */
1949static void wma_target_if_open(tp_wma_handle wma_handle)
1950{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301951 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08001952
1953 if (!psoc)
1954 return;
1955
Mukul Sharmadad267e2017-02-04 13:25:34 +05301956 wlan_global_lmac_if_set_txops_registration_cb(WLAN_DEV_OL,
1957 target_if_register_tx_ops);
1958 wlan_lmac_if_set_umac_txops_registration_cb(
1959 wma_register_tx_ops_handler);
1960 wlan_global_lmac_if_open(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08001961
Frank Liu65b17d92016-11-23 15:58:44 +08001962}
1963
1964/**
1965 * wma_target_if_close() - Detach UMAC modules' interface with wmi layer
1966 * @wma_handle: wma handle
1967 *
1968 * Return: None
1969 */
1970static void wma_target_if_close(tp_wma_handle wma_handle)
1971{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301972 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08001973
1974 if (!psoc)
1975 return;
1976
Mukul Sharmadad267e2017-02-04 13:25:34 +05301977 wlan_global_lmac_if_close(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08001978}
Frank Liu65b17d92016-11-23 15:58:44 +08001979
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301980/**
Mukul Sharmac3e7a782017-02-03 12:16:11 +05301981 * wma_get_psoc_from_scn_handle() - API to get psoc from scn handle
1982 * @scn_handle: opaque wma handle
1983 *
1984 * API to get psoc from scn handle
1985 *
1986 * Return: None
1987 */
1988static struct wlan_objmgr_psoc *wma_get_psoc_from_scn_handle(void *scn_handle)
1989{
1990 tp_wma_handle wma_handle;
1991
1992 if (!scn_handle) {
1993 WMA_LOGE("invalid scn handle");
1994 return NULL;
1995 }
1996 wma_handle = (tp_wma_handle)scn_handle;
1997
1998 return wma_handle->psoc;
1999}
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002000/**
2001 * wma_legacy_service_ready_event_handler() - legacy (ext)service ready handler
2002 * @event_id: event_id
2003 * @handle: wma handle
2004 * @event_data: event data
2005 * @length: event length
2006 *
2007 * Return: 0 for success, negative error code for failure
2008 */
2009static int wma_legacy_service_ready_event_handler(uint32_t event_id,
2010 void *handle,
2011 uint8_t *event_data,
2012 uint32_t length)
2013{
2014 if (wmi_service_ready_event_id == event_id)
2015 return wma_rx_service_ready_event(handle, event_data, length);
2016 else if (wmi_service_ready_ext_event_id == event_id)
2017 return wma_rx_service_ready_ext_event(handle, event_data,
2018 length);
2019 else
2020 QDF_BUG(0);
2021
2022 return 0;
2023}
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302024
2025/**
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002026 * wma_flush_complete_evt_handler() - FW log flush complete event handler
2027 * @handle: WMI handle
2028 * @event: Event recevied from FW
2029 * @len: Length of the event
2030 *
2031 */
2032static int wma_flush_complete_evt_handler(void *handle,
2033 u_int8_t *event,
2034 u_int32_t len)
2035{
2036 QDF_STATUS status;
2037 tp_wma_handle wma = (tp_wma_handle) handle;
2038
2039 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *param_buf;
2040 wmi_debug_mesg_flush_complete_fixed_param *wmi_event;
2041 uint32_t reason_code;
2042
2043 param_buf = (WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *) event;
2044 if (!param_buf) {
2045 WMA_LOGE("Invalid log flush complete event buffer");
2046 return QDF_STATUS_E_FAILURE;
2047 }
2048
2049 wmi_event = param_buf->fixed_param;
2050 reason_code = wmi_event->reserved0;
2051
2052 /*
2053 * reason_code = 0; Flush event in response to flush command
2054 * reason_code = other value; Asynchronous flush event for fatal events
2055 */
2056 if (!reason_code && (cds_is_log_report_in_progress() == false)) {
2057 WMA_LOGE("Received WMI flush event without sending CMD");
2058 return -EINVAL;
2059 } else if (!reason_code && cds_is_log_report_in_progress() == true) {
2060 /* Flush event in response to flush command */
2061 WMA_LOGI("Received WMI flush event in response to flush CMD");
2062 status = qdf_mc_timer_stop(&wma->log_completion_timer);
2063 if (status != QDF_STATUS_SUCCESS)
2064 WMA_LOGE("Failed to stop the log completion timeout");
2065 cds_logging_set_fw_flush_complete();
2066 } else if (reason_code && cds_is_log_report_in_progress() == false) {
2067 /* Asynchronous flush event for fatal events */
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002068 status = cds_set_log_completion(WLAN_LOG_TYPE_FATAL,
2069 WLAN_LOG_INDICATOR_FIRMWARE,
2070 reason_code, false);
2071 if (QDF_STATUS_SUCCESS != status) {
2072 WMA_LOGE("%s: Failed to set log trigger params",
2073 __func__);
2074 return QDF_STATUS_E_FAILURE;
2075 }
2076 cds_logging_set_fw_flush_complete();
2077 return status;
2078 } else {
2079 /* Asynchronous flush event for fatal event,
2080 * but, report in progress already
2081 */
2082 WMA_LOGI("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
2083 __func__, WLAN_LOG_TYPE_FATAL,
2084 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2085 return QDF_STATUS_E_FAILURE;
2086 }
2087 return 0;
2088}
2089
2090/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 * wma_open() - Allocate wma context and initialize it.
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302092 * @psoc: Psoc pointer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 * @cds_context: cds context
2094 * @wma_tgt_cfg_cb: tgt config callback fun
2095 * @radar_ind_cb: dfs radar indication callback
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302096 * @cds_cfg: mac parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 *
2098 * Return: 0 on success, errno on failure
2099 */
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302100QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc, void *cds_context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 wma_tgt_cfg_cb tgt_cfg_cb,
2102 wma_dfs_radar_indication_cb radar_ind_cb,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302103 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104{
2105 tp_wma_handle wma_handle;
2106 HTC_HANDLE htc_handle;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302107 qdf_device_t qdf_dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 void *wmi_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302109 QDF_STATUS qdf_status;
Govind Singhd76a5b02016-03-08 15:12:14 +05302110 struct wmi_rx_ops ops;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07002111 struct policy_mgr_wma_cbacks wma_cbacks;
Govind Singhd76a5b02016-03-08 15:12:14 +05302112
2113 bool use_cookie = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114
2115 WMA_LOGD("%s: Enter", __func__);
2116
Mukul Sharma5ff3c582016-09-12 15:23:35 +05302117 g_wmi_version_info.major = __WMI_VER_MAJOR_;
2118 g_wmi_version_info.minor = __WMI_VER_MINOR_;
2119 g_wmi_version_info.revision = __WMI_REVISION_;
2120
Anurag Chouhan6d760662016-02-20 16:05:43 +05302121 qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
2122 htc_handle = cds_get_context(QDF_MODULE_ID_HTC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123
2124 if (!htc_handle) {
2125 WMA_LOGP("%s: Invalid HTC handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302126 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 }
2128
2129 /* Alloc memory for WMA Context */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302130 qdf_status = cds_alloc_context(cds_context, QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 (void **)&wma_handle,
2132 sizeof(t_wma_handle));
2133
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302134 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 WMA_LOGP("%s: Memory allocation failed for wma_handle",
2136 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302137 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 }
2139
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302140 qdf_mem_zero(wma_handle, sizeof(t_wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141
Anurag Chouhan6d760662016-02-20 16:05:43 +05302142 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143#ifdef FEATURE_WLAN_SCAN_PNO
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302144 qdf_wake_lock_create(&wma_handle->pno_wake_lock, "wlan_pno_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145#endif /* FEATURE_WLAN_SCAN_PNO */
2146#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302147 qdf_wake_lock_create(&wma_handle->extscan_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 "wlan_extscan_wl");
2149#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302150 qdf_wake_lock_create(&wma_handle->wow_wake_lock, "wlan_wow_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151 }
2152
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05302153 qdf_status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_LEGACY_WMA_ID);
2154 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2155 WMA_LOGE("%s: PSOC get_ref fails", __func__);
2156 return qdf_status;
2157 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302158 wma_handle->psoc = psoc;
2159
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002160 /* Open target_if layer and register wma callback */
2161 wma_target_if_open(wma_handle);
2162 target_if_open(wma_get_psoc_from_scn_handle);
2163
Govind Singhd76a5b02016-03-08 15:12:14 +05302164 /* Attach mc_thread context processing function */
2165 ops.wma_process_fw_event_handler_cbk = wma_process_fw_event_handler;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 /* attach the wmi */
Govind Singhd76a5b02016-03-08 15:12:14 +05302167 wmi_handle = wmi_unified_attach(wma_handle, NULL,
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302168 WMI_TLV_TARGET, use_cookie, &ops, psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 if (!wmi_handle) {
2170 WMA_LOGP("%s: failed to attach WMI", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302171 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 goto err_wma_handle;
2173 }
2174
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002175 target_if_register_legacy_service_ready_cb(
2176 wma_legacy_service_ready_event_handler);
2177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178 WMA_LOGA("WMA --> wmi_unified_attach - success");
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302179
2180 /* set the wmi handle (as tgt_if_handle) in psoc */
2181 wlan_psoc_obj_lock(psoc);
2182 wlan_psoc_set_tgt_if_handle(psoc, wmi_handle);
2183 wlan_psoc_obj_unlock(psoc);
2184
Govind Singhd76a5b02016-03-08 15:12:14 +05302185 wmi_unified_register_event_handler(wmi_handle,
2186 WMI_SERVICE_READY_EVENTID,
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002187 init_deinit_service_ready_event_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05302188 WMA_RX_SERIALIZER_CTX);
2189 wmi_unified_register_event_handler(wmi_handle,
2190 WMI_SERVICE_READY_EXT_EVENTID,
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002191 init_deinit_service_ext_ready_event_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05302192 WMA_RX_SERIALIZER_CTX);
2193 wmi_unified_register_event_handler(wmi_handle,
2194 WMI_READY_EVENTID,
2195 wma_rx_ready_event,
2196 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197 /* Save the WMI & HTC handle */
2198 wma_handle->wmi_handle = wmi_handle;
2199 wma_handle->htc_handle = htc_handle;
2200 wma_handle->cds_context = cds_context;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302201 wma_handle->qdf_dev = qdf_dev;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302202 wma_handle->max_scan = cds_cfg->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203
Houston Hoffmanc45db892015-11-13 19:59:25 -08002204 wma_handle->wma_runtime_resume_lock =
2205 qdf_runtime_lock_init("wma_runtime_resume");
2206
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302207 /* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302208 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302209 /* Cap maxStation based on the target version */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302210 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302211 /* Reinitialize max_no_of_peers based on the capped maxStation value */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302212 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 /* initialize default target config */
2215 wma_set_default_tgt_config(wma_handle);
2216
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302217 wma_handle->tx_chain_mask_cck = cds_cfg->tx_chain_mask_cck;
2218 wma_handle->self_gen_frm_pwr = cds_cfg->self_gen_frm_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 /* Allocate dfs_ic and initialize DFS */
2221 wma_handle->dfs_ic = wma_dfs_attach(wma_handle->dfs_ic);
2222 if (wma_handle->dfs_ic == NULL) {
2223 WMA_LOGE("%s: Memory allocation failed for dfs_ic", __func__);
2224 goto err_wmi_handle;
2225 }
2226#if defined(QCA_WIFI_FTM)
Anurag Chouhan6d760662016-02-20 16:05:43 +05302227 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 wma_utf_attach(wma_handle);
2229#endif /* QCA_WIFI_FTM */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302230 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
2231 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302233 cds_cfg->max_bssid = WMA_MAX_SUPPORTED_BSS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234
2235 wma_handle->wlan_resource_config.num_wow_filters =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302236 cds_cfg->max_wow_filters;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 wma_handle->wlan_resource_config.num_keep_alive_pattern =
2238 WMA_MAXNUM_PERIODIC_TX_PTRNS;
2239
2240 /* The current firmware implementation requires the number of
Anurag Chouhanffb21542016-02-17 14:33:03 +05302241 * offload peers should be (number of vdevs + 1).
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 */
2243 wma_handle->wlan_resource_config.num_offload_peers =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302244 cds_cfg->ap_maxoffload_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245
2246 wma_handle->wlan_resource_config.num_offload_reorder_buffs =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302247 cds_cfg->ap_maxoffload_reorderbuffs + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302249 wma_handle->ol_ini_info = cds_cfg->ol_ini_info;
2250 wma_handle->max_station = cds_cfg->max_station;
2251 wma_handle->max_bssid = cds_cfg->max_bssid;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302252 wma_handle->driver_type = cds_cfg->driver_type;
2253 wma_handle->ssdp = cds_cfg->ssdp;
2254 wma_handle->enable_mc_list = cds_cfg->enable_mc_list;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05302255 wma_handle->bpf_packet_filter_enable =
2256 cds_cfg->bpf_packet_filter_enable;
Dustin Brown13995f02017-01-12 15:38:42 -08002257 wma_handle->active_bpf_mode = cds_cfg->active_bpf_mode;
Srinivas Girigowda57b450e2016-10-27 21:00:46 -07002258 wma_handle->link_stats_results = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302260 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
2261 wma_handle->RArateLimitInterval = cds_cfg->ra_ratelimit_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262#endif /* FEATURE_WLAN_RA_FILTERING */
2263#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302264 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265#endif
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302266 wma_set_nan_enable(wma_handle, cds_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 /*
2268 * Indicates if DFS Phyerr filtering offload
2269 * is Enabled/Disabed from ini
2270 */
2271 wma_handle->dfs_phyerr_filter_offload =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302272 cds_cfg->dfs_phyerr_filter_offload;
2273 wma_handle->dfs_pri_multiplier = cds_cfg->dfs_pri_multiplier;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302274 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275 wma_handle->max_bssid);
2276 if (!wma_handle->interfaces) {
2277 WMA_LOGP("%s: failed to allocate interface table", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302278 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 goto err_scn_context;
2280 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302281 qdf_mem_zero(wma_handle->interfaces, sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 wma_handle->max_bssid);
2283 /* Register the debug print event handler */
2284 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302285 WMI_DEBUG_PRINT_EVENTID,
2286 wma_unified_debug_print_event_handler,
2287 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05302288 /* Register profiling event Handler */
2289 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2290 WMI_WLAN_PROFILE_DATA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302291 wma_profile_data_report_event_handler,
2292 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293
2294 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
2295 wma_handle->dfs_radar_indication_cb = radar_ind_cb;
2296 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
2297 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05302298 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07002299 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302301 qdf_status = qdf_event_create(&wma_handle->wma_ready_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302302 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 WMA_LOGP("%s: wma_ready_event initialization failed", __func__);
2304 goto err_event_init;
2305 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302306
Anurag Chouhan210db072016-02-22 18:42:15 +05302307 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302308 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302309 wma_service_ready_ext_evt_timeout,
2310 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302311 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302312 WMA_LOGE("Failed to initialize service ready ext timeout");
2313 goto err_event_init;
2314 }
2315
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302316 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302317 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 WMA_LOGP("%s: target suspend event initialization failed",
2319 __func__);
2320 goto err_event_init;
2321 }
2322
2323 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302324 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
2325 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 WMA_LOGP("%s: failed to init tx_frm_download_comp_event",
2327 __func__);
2328 goto err_event_init;
2329 }
2330
2331 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302332 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
2333 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 WMA_LOGP("%s: failed to init tx_queue_empty_event", __func__);
2335 goto err_event_init;
2336 }
2337
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302338 qdf_status = qdf_event_create(&wma_handle->wma_resume_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302339 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 WMA_LOGP("%s: wma_resume_event initialization failed",
2341 __func__);
2342 goto err_event_init;
2343 }
2344
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002345 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
2346 wma_handle);
2347 if (qdf_status != QDF_STATUS_SUCCESS) {
2348 WMA_LOGP("%s: Shutdown notifier register failed: %d",
2349 __func__, qdf_status);
2350 goto err_event_init;
2351 }
2352
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302353 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302354 if (qdf_status != QDF_STATUS_SUCCESS) {
Houston Hoffmana76591b2015-11-10 16:52:05 -08002355 WMA_LOGP("%s: runtime_suspend event initialization failed",
2356 __func__);
2357 goto err_event_init;
2358 }
2359
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302360 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302361 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 WMA_LOGP("%s: recovery event initialization failed", __func__);
2363 goto err_event_init;
2364 }
2365
Anurag Chouhanffb21542016-02-17 14:33:03 +05302366 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07002367 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302368 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05302369 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302371 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05302372 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
2373 qdf_atomic_init(&wma_handle->scan_id_counter);
Nitesh Shah0f3fce52016-10-13 22:01:41 +05302374 qdf_atomic_init(&wma_handle->num_pending_scans);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375
2376 /* Register vdev start response event handler */
2377 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2378 WMI_VDEV_START_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302379 wma_vdev_start_resp_handler,
2380 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381
2382 /* Register vdev stop response event handler */
2383 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2384 WMI_VDEV_STOPPED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302385 wma_vdev_stop_resp_handler,
2386 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387
2388 /* register for STA kickout function */
2389 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2390 WMI_PEER_STA_KICKOUT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302391 wma_peer_sta_kickout_event_handler,
2392 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393
2394 /* register for stats response event */
2395 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2396 WMI_UPDATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302397 wma_stats_event_handler,
2398 WMA_RX_SERIALIZER_CTX);
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05302399
2400#ifdef WLAN_POWER_DEBUGFS
2401 /* register for Chip Power stats event */
2402 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2403 WMI_PDEV_CHIP_POWER_STATS_EVENTID,
2404 wma_unified_power_debug_stats_event_handler,
2405 WMA_RX_SERIALIZER_CTX);
2406#endif
2407
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 /* register for linkspeed response event */
2409 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2410 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302411 wma_link_speed_event_handler,
2412 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413
2414#ifdef FEATURE_OEM_DATA_SUPPORT
2415 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002416 WMI_OEM_RESPONSE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302417 wma_oem_data_response_handler,
2418 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419#endif /* FEATURE_OEM_DATA_SUPPORT */
2420 /*
2421 * Register appropriate DFS phyerr event handler for
2422 * Phyerror events. Handlers differ for phyerr filtering
2423 * offload enable and disable cases.
2424 */
2425 wma_register_dfs_event_handler(wma_handle);
2426
2427 /* Register peer change event handler */
2428 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2429 WMI_PEER_STATE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302430 wma_peer_state_change_event_handler,
2431 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432
2433 /* Register beacon tx complete event id. The event is required
2434 * for sending channel switch announcement frames
2435 */
2436 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302437 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID,
2438 wma_unified_bcntx_status_event_handler,
2439 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440
2441 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2442 WMI_UPDATE_VDEV_RATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302443 wma_link_status_event_handler,
2444 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002445#ifdef WLAN_FEATURE_LINK_LAYER_STATS
2446 /* Register event handler for processing Link Layer Stats
2447 * response from the FW
2448 */
2449 wma_register_ll_stats_event_handler(wma_handle);
2450
2451#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2452
2453 /*
2454 * Register event handler to receive firmware mem dump
2455 * copy complete indication
2456 */
2457 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2458 WMI_UPDATE_FW_MEM_DUMP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302459 wma_fw_mem_dump_event_handler,
2460 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461
2462 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302463 qdf_status = dbglog_init(wma_handle->wmi_handle);
2464 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 WMA_LOGP("%s: Firmware Dbglog initialization failed", __func__);
2466 goto err_dbglog_init;
2467 }
2468
2469 /*
2470 * Update Powersave mode
2471 * 1 - Legacy Powersave + Deepsleep Disabled
2472 * 2 - QPower + Deepsleep Disabled
2473 * 3 - Legacy Powersave + Deepsleep Enabled
2474 * 4 - QPower + Deepsleep Enabled
2475 */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302476 wma_handle->powersave_mode = cds_cfg->powersave_offload_enabled;
2477 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
2478 wma_handle->staModDtim = cds_cfg->sta_mod_dtim;
2479 wma_handle->staDynamicDtim = cds_cfg->sta_dynamic_dtim;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480
2481 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302482 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 * 0 - Disable both magic pattern match and pattern byte match.
2484 * 1 - Enable magic pattern match on all interfaces.
2485 * 2 - Enable pattern byte match on all interfaces.
2486 * 3 - Enable both magic patter and pattern byte match on
2487 * all interfaces.
2488 */
2489 wma_handle->wow.magic_ptrn_enable =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302490 (cds_cfg->wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 wma_handle->ptrn_match_enable_all_vdev =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302492 (cds_cfg->wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493
2494#ifdef FEATURE_WLAN_TDLS
2495 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2496 WMI_TDLS_PEER_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302497 wma_tdls_event_handler,
2498 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499#endif /* FEATURE_WLAN_TDLS */
2500
2501 /* register for install key completion event */
2502 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302503 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID,
2504 wma_vdev_install_key_complete_event_handler,
2505 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506#ifdef WLAN_FEATURE_NAN
2507 /* register for nan response event */
2508 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2509 WMI_NAN_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302510 wma_nan_rsp_event_handler,
2511 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512#endif /* WLAN_FEATURE_NAN */
2513
2514#ifdef WLAN_FEATURE_STATS_EXT
2515 /* register for extended stats event */
2516 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2517 WMI_STATS_EXT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302518 wma_stats_ext_event_handler,
2519 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520#endif /* WLAN_FEATURE_STATS_EXT */
2521#ifdef FEATURE_WLAN_EXTSCAN
2522 wma_register_extscan_event_handler(wma_handle);
2523#endif /* WLAN_FEATURE_STATS_EXT */
2524
2525 WMA_LOGD("%s: Exit", __func__);
2526
2527#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2528 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2529 WMI_ROAM_SYNCH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302530 wma_roam_synch_event_handler,
2531 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
2533 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2534 WMI_RSSI_BREACH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302535 wma_rssi_breached_event_handler,
2536 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302538 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05302539 "wlan_fw_rsp_wakelock");
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002540 wma_handle->wmi_cmd_rsp_runtime_lock =
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302541 qdf_runtime_lock_init("wlan_fw_rsp_runtime_lock");
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002542
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 /* Register peer assoc conf event handler */
2544 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2545 WMI_PEER_ASSOC_CONF_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302546 wma_peer_assoc_conf_handler,
2547 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002548 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2549 WMI_VDEV_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302550 wma_vdev_delete_handler,
2551 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002552 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2553 WMI_PEER_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302554 wma_peer_delete_handler,
2555 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05302556 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2557 WMI_BPF_CAPABILIY_INFO_EVENTID,
2558 wma_get_bpf_caps_event_handler,
2559 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05302560 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2561 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID,
2562 wma_encrypt_decrypt_msg_handler,
2563 WMA_RX_SERIALIZER_CTX);
Kapil Gupta4f0c0c12017-02-07 15:21:15 +05302564 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2565 WMI_CHAN_INFO_EVENTID,
2566 wma_chan_info_event_handler,
2567 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002568 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2569 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID,
2570 wma_flush_complete_evt_handler,
Rajeev Kumarc3032b82017-02-14 15:56:01 -08002571 WMA_RX_WORK_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002572
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07002573 wma_ndp_register_all_event_handlers(wma_handle);
Frank Liu65b17d92016-11-23 15:58:44 +08002574
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302575 wma_register_debug_callback();
Mukul Sharma6411bb82017-03-01 15:57:07 +05302576 /* Register callback with PMO so PMO can update the vdev pause bitmap*/
2577 pmo_register_pause_bitmap_notifier(wma_handle->psoc,
2578 wma_vdev_update_pause_bitmap);
2579 pmo_register_get_pause_bitmap(wma_handle->psoc,
2580 wma_vdev_get_pause_bitmap);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07002581 wma_cbacks.wma_get_connection_info = wma_get_connection_info;
2582 wma_cbacks.wma_is_service_enabled = wma_is_service_enabled;
2583 qdf_status = policy_mgr_register_wma_cb(wma_handle->psoc, &wma_cbacks);
2584 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2585 WMA_LOGE("Failed to register wma cb with Policy Manager");
2586 }
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302587
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302588 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589
2590err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302591 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
2592 qdf_runtime_lock_deinit(wma_handle->wmi_cmd_rsp_runtime_lock);
2593 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
2594 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595err_event_init:
2596 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
2597 WMI_DEBUG_PRINT_EVENTID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302598 qdf_mem_free(wma_handle->interfaces);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599err_scn_context:
2600 wma_dfs_detach(wma_handle->dfs_ic);
2601#if defined(QCA_WIFI_FTM)
2602 wma_utf_detach(wma_handle);
2603#endif /* QCA_WIFI_FTM */
2604err_wmi_handle:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302605 qdf_mem_free(((p_cds_contextType) cds_context)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 OS_FREE(wmi_handle);
2607
2608err_wma_handle:
2609
Anurag Chouhan6d760662016-02-20 16:05:43 +05302610 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611#ifdef FEATURE_WLAN_SCAN_PNO
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302612 qdf_wake_lock_destroy(&wma_handle->pno_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613#endif /* FEATURE_WLAN_SCAN_PNO */
2614#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302615 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302617 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 }
Houston Hoffmanc45db892015-11-13 19:59:25 -08002619
2620 qdf_runtime_lock_deinit(wma_handle->wma_runtime_resume_lock);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302621 cds_free_context(cds_context, QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622
2623 WMA_LOGD("%s: Exit", __func__);
2624
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302625 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626}
2627
2628/**
2629 * wma_pre_start() - wma pre start
2630 * @cds_ctx: cds context
2631 *
2632 * Return: 0 on success, errno on failure
2633 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302634QDF_STATUS wma_pre_start(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302636 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 A_STATUS status = A_OK;
2638 tp_wma_handle wma_handle;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08002639 struct scheduler_msg wma_msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640
2641 WMA_LOGD("%s: Enter", __func__);
2642
Anurag Chouhan6d760662016-02-20 16:05:43 +05302643 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644
2645 /* Validate the wma_handle */
2646 if (NULL == wma_handle) {
2647 WMA_LOGP("%s: invalid argument", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302648 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 goto end;
2650 }
2651 /* Open endpoint for ctrl path - WMI <--> HTC */
2652 status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
2653 wma_handle->htc_handle);
2654 if (A_OK != status) {
2655 WMA_LOGP("%s: wmi_unified_connect_htc_service", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302656 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 goto end;
2658 }
2659
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08002660 WMA_LOGD("WMA --> wmi_unified_connect_htc_service - success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661
2662 /* Trigger the CFG DOWNLOAD */
2663 wma_msg.type = WNI_CFG_DNLD_REQ;
2664 wma_msg.bodyptr = NULL;
2665 wma_msg.bodyval = 0;
2666
Rajeev Kumarb60abe42017-01-21 15:39:31 -08002667 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &wma_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302668 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 WMA_LOGP("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302670 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302671 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 }
2673end:
2674 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302675 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676}
2677
2678/**
2679 * wma_send_msg() - Send wma message to PE.
2680 * @wma_handle: wma handle
2681 * @msg_type: message type
2682 * @body_ptr: message body ptr
2683 * @body_val: message body value
2684 *
2685 * Return: none
2686 */
2687void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
2688 void *body_ptr, uint32_t body_val)
2689{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002690 struct scheduler_msg msg = { 0 };
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302691 uint32_t status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302692 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 msg.type = msg_type;
2694 msg.bodyval = body_val;
2695 msg.bodyptr = body_ptr;
2696 status = lim_post_msg_api(pMac, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302697 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 if (NULL != body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302699 qdf_mem_free(body_ptr);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302700 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 }
2702 return;
2703}
2704
2705/**
2706 * wma_set_base_macaddr_indicate() - set base mac address in fw
2707 * @wma_handle: wma handle
2708 * @customAddr: base mac address
2709 *
2710 * Return: 0 for success or error code
2711 */
2712static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
2713 tSirMacAddr *customAddr)
2714{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 int err;
2716
Govind Singhf25a0f12016-03-08 16:09:48 +05302717 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
2718 (uint8_t *)customAddr);
2719 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
2722 MAC_ADDR_ARRAY((*customAddr)));
2723
2724 return 0;
2725}
2726
2727/**
2728 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
2729 * @handle: WMA handle
2730 * @event: Event received from FW
2731 * @len: Length of the event
2732 *
2733 * Enables the low frequency events and disables the high frequency
2734 * events. Bit 17 indicates if the event if low/high frequency.
2735 * 1 - high frequency, 0 - low frequency
2736 *
2737 * Return: 0 on successfully enabling/disabling the events
2738 */
2739static int wma_log_supported_evt_handler(void *handle,
2740 uint8_t *event,
2741 uint32_t len)
2742{
2743 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744
Govind Singhf25a0f12016-03-08 16:09:48 +05302745 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
2746 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748
2749 return 0;
2750}
2751
2752/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302753 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 * @handle: WMI handle
2755 * @event: Event recevied from FW
2756 * @len: Length of the event
2757 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302758 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
2759 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
2760 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 *
2762 * Return: Success on receiving valid params from FW
2763 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302764static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 uint8_t *event,
2766 uint32_t len)
2767{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302768 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
2769 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
2770 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771 uint32_t i;
2772 struct sir_set_hw_mode_resp *hw_mode_resp;
2773 tp_wma_handle wma = (tp_wma_handle) handle;
2774
2775 if (!wma) {
2776 WMA_LOGE("%s: Invalid WMA handle", __func__);
2777 /* Since WMA handle itself is NULL, we cannot send fail
2778 * response back to LIM here
2779 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302780 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 }
2782
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302783 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784 if (!hw_mode_resp) {
2785 WMA_LOGI("%s: Memory allocation failed", __func__);
2786 /* Since this memory allocation itself failed, we cannot
2787 * send fail response back to LIM here
2788 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302789 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790 }
2791
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302792 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302794 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 /* Need to send response back to upper layer to free
2796 * active command list
2797 */
2798 goto fail;
2799 }
2800
2801 wmi_event = param_buf->fixed_param;
2802 hw_mode_resp->status = wmi_event->status;
2803 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2804 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
2805
2806 WMA_LOGI("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
2807 __func__, wmi_event->status,
2808 wmi_event->cfgd_hw_mode_index,
2809 wmi_event->num_vdev_mac_entries);
2810 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302811 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812
2813 /* Store the vdev-mac map in WMA and prepare to send to PE */
2814 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302815 uint32_t vdev_id, mac_id, pdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302817 pdev_id = vdev_mac_entry[i].pdev_id;
2818 if (pdev_id == WMI_PDEV_ID_SOC) {
2819 WMA_LOGE("%s: soc level id received for mac id)",
2820 __func__);
2821 QDF_BUG(0);
2822 goto fail;
2823 }
2824 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825
2826 WMA_LOGI("%s: vdev_id:%d mac_id:%d",
2827 __func__, vdev_id, mac_id);
2828
2829 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
2830 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
2831 wma_update_intf_hw_mode_params(vdev_id, mac_id,
2832 wmi_event->cfgd_hw_mode_index);
2833 }
2834
2835 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
2836 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
2837 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2838 } else {
2839 wma->old_hw_mode_index = wma->new_hw_mode_index;
2840 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2841 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07002842 policy_mgr_update_hw_mode_index(wma->psoc,
2843 wmi_event->cfgd_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 }
2845
2846 WMA_LOGI("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
2847 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
2848
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302849 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 (void *) hw_mode_resp, 0);
2851
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302852 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853
2854fail:
2855 WMA_LOGE("%s: Sending fail response to LIM", __func__);
2856 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
2857 hw_mode_resp->cfgd_hw_mode_index = 0;
2858 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302859 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 (void *) hw_mode_resp, 0);
2861
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302862 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863}
2864
2865/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002866 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
2867 *
2868 * @handle: WMA handle
2869 * @fixed_param: Event fixed parameters
2870 * @vdev_mac_entry - vdev mac entry
2871 * @hw_mode_trans_ind - Buffer to store parsed information
2872 *
2873 * Parses fixed_param, vdev_mac_entry and fills in the information into
2874 * hw_mode_trans_ind and wma
2875 *
2876 * Return: None
2877 */
2878void wma_process_pdev_hw_mode_trans_ind(void *handle,
2879 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
2880 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
2881 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
2882{
2883 uint32_t i;
2884 tp_wma_handle wma = (tp_wma_handle) handle;
2885
2886 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
2887 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
2888 hw_mode_trans_ind->num_vdev_mac_entries =
2889 fixed_param->num_vdev_mac_entries;
2890 WMA_LOGI("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
2891 __func__, fixed_param->old_hw_mode_index,
2892 fixed_param->new_hw_mode_index,
2893 fixed_param->num_vdev_mac_entries);
2894
2895 /* Store the vdev-mac map in WMA and send to policy manager */
2896 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
2897 uint32_t vdev_id, mac_id, pdev_id;
2898 vdev_id = vdev_mac_entry[i].vdev_id;
2899 pdev_id = vdev_mac_entry[i].pdev_id;
2900
2901 if (pdev_id == WMI_PDEV_ID_SOC) {
2902 WMA_LOGE("%s: soc level id received for mac id)",
2903 __func__);
2904 QDF_BUG(0);
2905 return;
2906 }
2907
2908 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
2909
2910 WMA_LOGI("%s: vdev_id:%d mac_id:%d",
2911 __func__, vdev_id, mac_id);
2912
2913 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
2914 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
2915 wma_update_intf_hw_mode_params(vdev_id, mac_id,
2916 fixed_param->new_hw_mode_index);
2917 }
2918 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
2919 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07002920 policy_mgr_update_new_hw_mode_index(wma->psoc,
2921 fixed_param->new_hw_mode_index);
2922 policy_mgr_update_old_hw_mode_index(wma->psoc,
2923 fixed_param->old_hw_mode_index);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002924
2925 WMA_LOGI("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
2926 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
2927}
2928
2929/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302930 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 * @handle: WMI handle
2932 * @event: Event recevied from FW
2933 * @len: Length of the event
2934 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302935 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 * asynchronous hardware mode transition. This event notifies the host driver
2937 * that firmware independently changed the hardware mode for some reason, such
2938 * as Coex, LFR 3.0, etc
2939 *
2940 * Return: Success on receiving valid params from FW
2941 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302942static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 uint8_t *event,
2944 uint32_t len)
2945{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302946 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
2947 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
2948 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
2950 tp_wma_handle wma = (tp_wma_handle) handle;
2951
2952 if (!wma) {
2953 /* This is an async event. So, not sending any event to LIM */
2954 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302955 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 }
2957
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302958 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 if (!param_buf) {
2960 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302961 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302962 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 }
2964
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302965 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 if (!hw_mode_trans_ind) {
2967 WMA_LOGI("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302968 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 }
2970
2971 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302973 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002974 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
2975 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05302977 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978 (void *) hw_mode_trans_ind, 0);
2979
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302980 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981}
2982
2983/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302984 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 * @handle: WMI handle
2986 * @event: Event received from FW
2987 * @len: Length of the event
2988 *
2989 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302990 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002991 * the host driver once the firmware has completed a reconfiguration of the Scan
2992 * and FW mode configuration. This changes could include entering or leaving a
2993 * dual mac configuration for either scan and/or more permanent firmware mode.
2994 *
2995 * Return: Success on receiving valid params from FW
2996 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05302997static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 uint8_t *event,
2999 uint32_t len)
3000{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303001 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
3002 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 tp_wma_handle wma = (tp_wma_handle) handle;
3004 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
3005
3006 if (!wma) {
3007 WMA_LOGE("%s: Invalid WMA handle", __func__);
3008 /* Since the WMA handle is NULL, we cannot send resp to LIM.
3009 * So, returning from here.
3010 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303011 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 }
3013
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303014 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 if (!dual_mac_cfg_resp) {
3016 WMA_LOGE("%s: Memory allocation failed", __func__);
3017 /* Since the mem alloc failed, we cannot send resp to LIM.
3018 * So, returning from here.
3019 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303020 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 }
3022
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303023 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 event;
3025 if (!param_buf) {
3026 WMA_LOGE("%s: Invalid event", __func__);
3027 goto fail;
3028 }
3029
3030 wmi_event = param_buf->fixed_param;
3031 WMA_LOGI("%s: status:%d", __func__, wmi_event->status);
3032 dual_mac_cfg_resp->status = wmi_event->status;
3033
3034 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003035 policy_mgr_update_dbs_scan_config(wma->psoc);
3036 policy_mgr_update_dbs_fw_config(wma->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 }
3038
3039 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303040 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 (void *) dual_mac_cfg_resp, 0);
3042
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303043 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044
3045fail:
3046 WMA_LOGE("%s: Sending fail response to LIM", __func__);
3047 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303048 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 (void *) dual_mac_cfg_resp, 0);
3050
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303051 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052
3053}
3054
3055/**
3056 * wma_start() - wma start function.
3057 * Intialize event handlers and timers.
3058 * @cds_ctx: cds context
3059 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303060 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303062QDF_STATUS wma_start(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303064 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 tp_wma_handle wma_handle;
3066 int status;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 WMA_LOGD("%s: Enter", __func__);
3069
Anurag Chouhan6d760662016-02-20 16:05:43 +05303070 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071
3072 /* validate the wma_handle */
3073 if (NULL == wma_handle) {
3074 WMA_LOGP("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303075 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 goto end;
3077 }
Sandeep Puligillad0004212017-02-26 18:34:56 -08003078#ifndef NAPIER_SCAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3080 WMI_SCAN_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303081 wma_scan_event_callback,
3082 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 if (0 != status) {
3084 WMA_LOGP("%s: Failed to register scan callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303085 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 goto end;
3087 }
Sandeep Puligillad0004212017-02-26 18:34:56 -08003088#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3090 WMI_ROAM_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303091 wma_roam_event_callback,
Padma, Santhosh Kumar18169ce2017-03-02 18:04:02 +05303092 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 if (0 != status) {
3094 WMA_LOGP("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303095 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096 goto end;
3097 }
3098
3099 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3100 WMI_WOW_WAKEUP_HOST_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303101 wma_wow_wakeup_host_event,
3102 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 if (status) {
3104 WMA_LOGP("%s: Failed to register wow wakeup host event handler",
3105 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303106 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 goto end;
3108 }
3109
3110 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3111 WMI_PDEV_RESUME_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303112 wma_pdev_resume_event_handler,
3113 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 if (status) {
3115 WMA_LOGP("%s: Failed to register PDEV resume event handler",
3116 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303117 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118 goto end;
3119 }
Abhishek Singhb20db962017-03-03 21:28:46 +05303120#ifndef NAPIER_SCAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121#ifdef FEATURE_WLAN_SCAN_PNO
3122 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3123 WMI_SERVICE_NLO)) {
3124
3125 WMA_LOGD("FW supports pno offload, registering nlo match handler");
3126
3127 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303128 WMI_NLO_MATCH_EVENTID,
3129 wma_nlo_match_evt_handler,
3130 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131 if (status) {
3132 WMA_LOGE("Failed to register nlo match event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303133 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 goto end;
3135 }
3136
3137 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303138 WMI_NLO_SCAN_COMPLETE_EVENTID,
3139 wma_nlo_scan_cmp_evt_handler,
3140 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 if (status) {
3142 WMA_LOGE("Failed to register nlo scan comp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303143 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 goto end;
3145 }
3146 }
3147#endif /* FEATURE_WLAN_SCAN_PNO */
Abhishek Singhb20db962017-03-03 21:28:46 +05303148#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05303150#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
3151 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 WMA_LOGE("MCC TX Pause Event Handler register");
3153 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303154 WMI_TX_PAUSE_EVENTID,
3155 wma_mcc_vdev_tx_pause_evt_handler,
3156 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
3158
3159#ifdef FEATURE_WLAN_CH_AVOID
3160 WMA_LOGD("Registering channel to avoid handler");
3161
3162 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303163 WMI_WLAN_FREQ_AVOID_EVENTID,
3164 wma_channel_avoid_evt_handler,
3165 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 if (status) {
3167 WMA_LOGE("Failed to register channel to avoid event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303168 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 goto end;
3170 }
3171#endif /* FEATURE_WLAN_CH_AVOID */
3172#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
3173 WMA_LOGD("Registering auto shutdown handler");
3174 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303175 WMI_HOST_AUTO_SHUTDOWN_EVENTID,
3176 wma_auto_shutdown_event_handler,
3177 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 if (status) {
3179 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303180 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 goto end;
3182 }
3183#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
3184 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303185 WMI_THERMAL_MGMT_EVENTID,
3186 wma_thermal_mgmt_evt_handler,
3187 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 if (status) {
3189 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303190 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 goto end;
3192 }
3193
3194 status = wma_ocb_register_event_handlers(wma_handle);
3195 if (status) {
3196 WMA_LOGE("Failed to register ocb event handlers");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303197 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 goto end;
3199 }
3200
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303201 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202
3203#ifdef QCA_WIFI_FTM
3204 /*
3205 * Tx mgmt attach requires TXRX context which is not created
3206 * in FTM mode. So skip the TX mgmt attach.
3207 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303208 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 goto end;
3210#endif /* QCA_WIFI_FTM */
3211
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003212 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3213 WMI_SERVICE_RMC)) {
3214
3215 WMA_LOGD("FW supports cesium network, registering event handlers");
3216
3217 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3218 WMI_PEER_INFO_EVENTID,
3219 wma_ibss_peer_info_event_handler,
3220 WMA_RX_SERIALIZER_CTX);
3221 if (status) {
3222 WMA_LOGE("Failed to register ibss peer info event cb");
3223 qdf_status = QDF_STATUS_E_FAILURE;
3224 goto end;
3225 }
3226
3227 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3228 WMI_PEER_TX_FAIL_CNT_THR_EVENTID,
3229 wma_fast_tx_fail_event_handler,
3230 WMA_RX_SERIALIZER_CTX);
3231 if (status) {
3232 WMA_LOGE("Failed to register peer fast tx failure event cb");
3233 qdf_status = QDF_STATUS_E_FAILURE;
3234 goto end;
3235 }
3236 } else {
3237 WMA_LOGE("Target does not support cesium network");
3238 }
3239
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303240 qdf_status = wma_tx_attach(wma_handle);
3241 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 WMA_LOGP("%s: Failed to register tx management", __func__);
3243 goto end;
3244 }
3245
3246 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05303247 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303248 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 wma_log_completion_timeout,
3250 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303251 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 WMA_LOGE("Failed to initialize log completion timeout");
3253 goto end;
3254 }
3255
3256 /* Initialize the get temperature event handler */
3257 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303258 WMI_PDEV_TEMPERATURE_EVENTID,
3259 wma_pdev_temperature_evt_handler,
3260 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303261 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303263 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 goto end;
3265 }
3266
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07003267 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3268 WMI_VDEV_TSF_REPORT_EVENTID,
3269 wma_vdev_tsf_handler,
3270 WMA_RX_SERIALIZER_CTX);
3271 if (0 != status) {
3272 WMA_LOGP("%s: Failed to register tsf callback", __func__);
3273 qdf_status = QDF_STATUS_E_FAILURE;
3274 goto end;
3275 }
3276
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303277 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303279 WMI_PDEV_SET_HW_MODE_RESP_EVENTID,
3280 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303281 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303282 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303284 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 goto end;
3286 }
3287
3288 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
3289 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303290 WMI_PDEV_HW_MODE_TRANSITION_EVENTID,
3291 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303292 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303293 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303295 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 goto end;
3297 }
3298
3299 /* Initialize the set dual mac configuration event handler */
3300 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303301 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID,
3302 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303303 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303304 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303306 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 goto end;
3308 }
3309
Wu Gao9a704f42017-03-10 18:42:11 +08003310#ifndef CONVERGED_P2P_ENABLE
Peng Xu8fdaa492016-06-22 10:20:47 -07003311 /* Initialize the P2P Listen Offload event handler */
3312 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3313 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID,
3314 wma_p2p_lo_event_handler,
3315 WMA_RX_SERIALIZER_CTX);
3316 if (!QDF_IS_STATUS_SUCCESS(status)) {
3317 WMA_LOGE("Failed to register p2p lo event cb");
3318 qdf_status = QDF_STATUS_E_FAILURE;
3319 goto end;
3320 }
Wu Gao9a704f42017-03-10 18:42:11 +08003321#endif
Peng Xu8fdaa492016-06-22 10:20:47 -07003322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323end:
3324 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303325 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326}
3327
3328/**
3329 * wma_stop() - wma stop function.
3330 * cleanup timers and suspend target.
3331 * @cds_ctx: cds context
3332 * @reason: reason for wma_stop.
3333 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303334 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303336QDF_STATUS wma_stop(void *cds_ctx, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337{
3338 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303339 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05303340 int i;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303341 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342
3343 WMA_LOGD("%s: Enter", __func__);
3344
3345 /* validate the wma_handle */
3346 if (NULL == wma_handle) {
3347 WMA_LOGP("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303348 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 goto end;
3350 }
3351#ifdef QCA_WIFI_FTM
3352 /*
3353 * Tx mgmt detach requires TXRX context which is not created
3354 * in FTM mode. So skip the TX mgmt detach.
3355 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303356 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303357 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 goto end;
3359 }
3360#endif /* QCA_WIFI_FTM */
3361
3362 if (wma_handle->ack_work_ctx) {
3363 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303364 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 wma_handle->ack_work_ctx = NULL;
3366 }
3367
3368 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05303369 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303370 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 WMA_LOGE("Failed to destroy the log completion timer");
3372 }
3373
Govind Singhede435f2015-12-01 16:16:36 +05303374 /* clean up ll-queue for all vdev */
3375 for (i = 0; i < wma_handle->max_bssid; i++) {
3376 if (wma_handle->interfaces[i].handle &&
Mukul Sharmaf9047232017-03-02 16:58:56 +05303377 wma_is_vdev_up(i)) {
Leo Chang96464902016-10-28 11:10:54 -07003378 cdp_fc_vdev_flush(
3379 cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003380 wma_handle->
3381 interfaces[i].handle);
Govind Singhede435f2015-12-01 16:16:36 +05303382 }
3383 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303384 qdf_status = wma_tx_detach(wma_handle);
3385 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 WMA_LOGP("%s: Failed to deregister tx management", __func__);
3387 goto end;
3388 }
3389
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390end:
3391 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303392 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393}
3394
3395/**
3396 * wma_cleanup_hold_req() - cleanup hold request queue
3397 * @wma: wma handle
3398 *
3399 * Return: none
3400 */
3401static void wma_cleanup_hold_req(tp_wma_handle wma)
3402{
3403 struct wma_target_req *req_msg = NULL;
Anurag Chouhanffb21542016-02-17 14:33:03 +05303404 qdf_list_node_t *node1 = NULL;
3405 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303407 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303408 if (!qdf_list_size(&wma->wma_hold_req_queue)) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303409 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
Krishna Kumaar Natarajanea08e502015-11-09 16:57:40 -08003410 WMA_LOGI(FL("request queue is empty"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 return;
3412 }
3413
Anurag Chouhanffb21542016-02-17 14:33:03 +05303414 while (QDF_STATUS_SUCCESS !=
3415 qdf_list_peek_front(&wma->wma_hold_req_queue, &node1)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05303416 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303417 status = qdf_list_remove_node(&wma->wma_hold_req_queue, node1);
3418 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303419 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 WMA_LOGE(FL("Failed to remove request for vdev_id %d type %d"),
3421 req_msg->vdev_id, req_msg->type);
3422 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 }
Anurag Chouhan210db072016-02-22 18:42:15 +05303424 qdf_mc_timer_destroy(&req_msg->event_timeout);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303425 qdf_mem_free(req_msg);
Krishna Kumaar Natarajanea08e502015-11-09 16:57:40 -08003426 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303427 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428}
3429
3430/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431 * wma_wmi_service_close() - close wma wmi service interface.
3432 * @cds_ctx: cds context
3433 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303434 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303436QDF_STATUS wma_wmi_service_close(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437{
3438 tp_wma_handle wma_handle;
3439 struct beacon_info *bcn;
3440 int i;
3441
3442 WMA_LOGD("%s: Enter", __func__);
3443
Anurag Chouhan6d760662016-02-20 16:05:43 +05303444 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445
3446 /* validate the wma_handle */
3447 if (NULL == wma_handle) {
3448 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303449 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 }
3451
3452 /* validate the wmi handle */
3453 if (NULL == wma_handle->wmi_handle) {
3454 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303455 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 }
3457
3458 /* dettach the wmi serice */
3459 WMA_LOGD("calling wmi_unified_detach");
3460 wmi_unified_detach(wma_handle->wmi_handle);
3461 wma_handle->wmi_handle = NULL;
3462
3463 for (i = 0; i < wma_handle->max_bssid; i++) {
3464 bcn = wma_handle->interfaces[i].beacon;
3465
3466 if (bcn) {
3467 if (bcn->dma_mapped)
Nirav Shahcbc6d722016-03-01 16:24:53 +05303468 qdf_nbuf_unmap_single(wma_handle->qdf_dev,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303469 bcn->buf, QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +05303470 qdf_nbuf_free(bcn->buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303471 qdf_mem_free(bcn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 wma_handle->interfaces[i].beacon = NULL;
3473 }
3474
3475 if (wma_handle->interfaces[i].handle) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303476 qdf_mem_free(wma_handle->interfaces[i].handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 wma_handle->interfaces[i].handle = NULL;
3478 }
Yue Ma664effc2016-01-12 18:43:54 -08003479
3480 if (wma_handle->interfaces[i].addBssStaContext) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303481 qdf_mem_free(wma_handle->
Yue Ma664effc2016-01-12 18:43:54 -08003482 interfaces[i].addBssStaContext);
3483 wma_handle->interfaces[i].addBssStaContext = NULL;
3484 }
3485
3486 if (wma_handle->interfaces[i].del_staself_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303487 qdf_mem_free(wma_handle->interfaces[i].del_staself_req);
Yue Ma664effc2016-01-12 18:43:54 -08003488 wma_handle->interfaces[i].del_staself_req = NULL;
3489 }
yeshwanth sriram guntuka8dd80382017-01-30 17:04:58 +05303490
3491 if (wma_handle->interfaces[i].stats_rsp) {
3492 qdf_mem_free(wma_handle->interfaces[i].stats_rsp);
3493 wma_handle->interfaces[i].stats_rsp = NULL;
3494 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 }
3496
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303497 qdf_mem_free(wma_handle->interfaces);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 /* free the wma_handle */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303499 cds_free_context(wma_handle->cds_context, QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 wma_handle);
3501
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303502 qdf_mem_free(((p_cds_contextType) cds_ctx)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303504 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505}
3506
Xun Luoa858a472015-11-10 08:24:45 -08003507/**
3508 * wma_wmi_work_close() - close the work queue items associated with WMI
3509 * @cds_ctx: Pointer to cds context
3510 *
3511 * This function closes work queue items associated with WMI, but not fully
3512 * closes WMI service.
3513 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303514 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08003515 * proper error codes.
3516 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303517QDF_STATUS wma_wmi_work_close(void *cds_ctx)
Xun Luoa858a472015-11-10 08:24:45 -08003518{
3519 tp_wma_handle wma_handle;
3520
3521 WMA_LOGD("%s: Enter", __func__);
3522
Anurag Chouhan6d760662016-02-20 16:05:43 +05303523 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08003524
3525 /* validate the wma_handle */
3526 if (NULL == wma_handle) {
3527 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303528 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003529 }
3530
3531 /* validate the wmi handle */
3532 if (NULL == wma_handle->wmi_handle) {
3533 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303534 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003535 }
3536
3537 /* remove the wmi work */
3538 WMA_LOGD("calling wmi_unified_remove_work");
3539 wmi_unified_remove_work(wma_handle->wmi_handle);
3540
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303541 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08003542}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543
Krunal Soni2e48d012016-05-02 16:55:26 -07003544/**
3545 * wma_cleanup_dbs_phy_caps() - release memory allocated for holding ext cap
3546 * @wma_handle: pointer to wma handle
3547 *
3548 * This function releases all the memory created for holding extended
3549 * capabilities per hardware mode and per PHY
3550 *
3551 * Return: void
3552 */
3553static void wma_cleanup_dbs_phy_caps(t_wma_handle *wma_handle)
3554{
3555 if (NULL == wma_handle) {
3556 WMA_LOGE("%s: Invalid wma handle", __func__);
3557 return;
3558 }
3559
3560 if (wma_handle->phy_caps.hw_mode_to_mac_cap_map) {
3561 qdf_mem_free(wma_handle->phy_caps.hw_mode_to_mac_cap_map);
3562 wma_handle->phy_caps.hw_mode_to_mac_cap_map = NULL;
3563 WMA_LOGI("%s: hw_mode_to_mac_cap_map freed", __func__);
3564 }
3565
3566 if (wma_handle->phy_caps.each_hw_mode_cap) {
3567 qdf_mem_free(wma_handle->phy_caps.each_hw_mode_cap);
3568 wma_handle->phy_caps.each_hw_mode_cap = NULL;
3569 WMA_LOGI("%s: each_hw_mode_cap freed", __func__);
3570 }
3571
3572 if (wma_handle->phy_caps.each_phy_cap_per_hwmode) {
3573 qdf_mem_free(wma_handle->phy_caps.each_phy_cap_per_hwmode);
3574 wma_handle->phy_caps.each_phy_cap_per_hwmode = NULL;
3575 WMA_LOGI("%s: each_phy_cap_per_hwmode freed", __func__);
3576 }
3577
3578 if (wma_handle->phy_caps.each_phy_hal_reg_cap) {
3579 qdf_mem_free(wma_handle->phy_caps.each_phy_hal_reg_cap);
3580 wma_handle->phy_caps.each_phy_hal_reg_cap = NULL;
3581 WMA_LOGI("%s: each_phy_hal_reg_cap freed", __func__);
3582 }
3583}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584
3585/**
3586 * wma_close() - wma close function.
3587 * cleanup resources attached with wma.
3588 * @cds_ctx: cds context
3589 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303590 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303592QDF_STATUS wma_close(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593{
3594 tp_wma_handle wma_handle;
3595 uint32_t idx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303596 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597
3598 WMA_LOGD("%s: Enter", __func__);
3599
Anurag Chouhan6d760662016-02-20 16:05:43 +05303600 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601
3602 /* validate the wma_handle */
3603 if (NULL == wma_handle) {
3604 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303605 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 }
3607
3608 /* validate the wmi handle */
3609 if (NULL == wma_handle->wmi_handle) {
3610 WMA_LOGP("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303611 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 }
3613
3614 /* Free DBS list */
3615 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303616 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 wma_handle->hw_mode.hw_mode_list = NULL;
3618 WMA_LOGI("%s: DBS list is freed", __func__);
3619 }
Krunal Soni2e48d012016-05-02 16:55:26 -07003620 wma_cleanup_dbs_phy_caps(wma_handle);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303621 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622#ifdef FEATURE_WLAN_SCAN_PNO
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303623 qdf_wake_lock_destroy(&wma_handle->pno_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624#endif /* FEATURE_WLAN_SCAN_PNO */
3625#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303626 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303628 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 }
3630
3631 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303632 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
3633 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 WMA_LOGP("%s: dbglog_deinit failed", __func__);
3635
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303636 /* close the qdf events */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303637 qdf_event_destroy(&wma_handle->wma_ready_event);
Anurag Chouhan210db072016-02-22 18:42:15 +05303638 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303639 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303640 WMA_LOGP("%s: Failed to destroy service ready ext event timer",
3641 __func__);
3642
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303643 qdf_event_destroy(&wma_handle->target_suspend);
3644 qdf_event_destroy(&wma_handle->wma_resume_event);
3645 qdf_event_destroy(&wma_handle->runtime_suspend);
3646 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08003647 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
3648 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08003649 wma_cleanup_vdev_resp_queue(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303651 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
3652 qdf_runtime_lock_deinit(wma_handle->wmi_cmd_rsp_runtime_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 for (idx = 0; idx < wma_handle->num_mem_chunks; ++idx) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303654 qdf_mem_free_consistent(wma_handle->qdf_dev,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303655 wma_handle->qdf_dev->dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 wma_handle->mem_chunks[idx].len,
3657 wma_handle->mem_chunks[idx].vaddr,
3658 wma_handle->mem_chunks[idx].paddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303659 qdf_get_dma_mem_context(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 (&(wma_handle->mem_chunks[idx])),
3661 memctx));
3662 }
3663
3664#if defined(QCA_WIFI_FTM)
3665 /* Detach UTF and unregister the handler */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303666 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667 wma_utf_detach(wma_handle);
3668#endif /* QCA_WIFI_FTM */
3669
3670 if (NULL != wma_handle->dfs_ic) {
3671 wma_dfs_detach(wma_handle->dfs_ic);
3672 wma_handle->dfs_ic = NULL;
3673 }
3674
3675 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303676 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 wma_handle->pGetRssiReq = NULL;
3678 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07003679
Srinivas Girigowdaad874a82016-10-25 14:08:00 -07003680 if (wma_handle->link_stats_results) {
3681 qdf_mem_free(wma_handle->link_stats_results);
3682 wma_handle->link_stats_results = NULL;
3683 }
3684
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07003685 wma_ndp_unregister_all_event_handlers(wma_handle);
3686
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05303687 wlan_objmgr_psoc_release_ref(wma_handle->psoc, WLAN_LEGACY_WMA_ID);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303688 wma_handle->psoc = NULL;
Mukul Sharmac3e7a782017-02-03 12:16:11 +05303689 target_if_close();
Frank Liu65b17d92016-11-23 15:58:44 +08003690 wma_target_if_close(wma_handle);
3691
Mukul Sharma6411bb82017-03-01 15:57:07 +05303692 pmo_unregister_pause_bitmap_notifier(wma_handle->psoc,
3693 wma_vdev_update_pause_bitmap);
3694 pmo_unregister_get_pause_bitmap(wma_handle->psoc,
3695 wma_vdev_get_pause_bitmap);
3696
3697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303699 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700}
3701
3702/**
3703 * wma_update_fw_config() - update fw configuration
3704 * @wma_handle: wma handle
3705 * @tgt_cap: target capabality
3706 *
3707 * Return: none
3708 */
3709static void wma_update_fw_config(tp_wma_handle wma_handle,
3710 struct wma_target_cap *tgt_cap)
3711{
3712 /*
3713 * tgt_cap contains default target resource configuration
3714 * which can be modified here, if required
3715 */
3716 /* Override the no. of max fragments as per platform configuration */
3717 tgt_cap->wlan_resource_config.max_frag_entries =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303718 QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 wma_handle->max_frag_entry);
3720 wma_handle->max_frag_entry =
3721 tgt_cap->wlan_resource_config.max_frag_entries;
Arun Khandavalli3dd06de2016-08-17 10:20:29 +05303722
3723 /* Update no. of maxWoWFilters depending on BPF service */
3724 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3725 WMI_SERVICE_BPF_OFFLOAD))
3726 tgt_cap->wlan_resource_config.num_wow_filters =
Arun Khandavallid454d422016-08-17 12:47:05 +05303727 WMA_STA_WOW_DEFAULT_PTRN_MAX;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728}
3729
3730/**
3731 * wma_alloc_host_mem_chunk() - allocate host memory
3732 * @wma_handle: wma handle
3733 * @req_id: request id
3734 * @idx: index
3735 * @num_units: number of units
3736 * @unit_len: unit length
3737 *
3738 * allocate a chunk of memory at the index indicated and
3739 * if allocation fail allocate smallest size possiblr and
3740 * return number of units allocated.
3741 *
3742 * Return: number of units or 0 for error.
3743 */
3744static uint32_t wma_alloc_host_mem_chunk(tp_wma_handle wma_handle,
3745 uint32_t req_id, uint32_t idx,
3746 uint32_t num_units, uint32_t unit_len)
3747{
Anurag Chouhan6d760662016-02-20 16:05:43 +05303748 qdf_dma_addr_t paddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749 if (!num_units || !unit_len) {
3750 return 0;
3751 }
3752 wma_handle->mem_chunks[idx].vaddr = NULL;
3753 /** reduce the requested allocation by half until allocation succeeds */
3754 while (wma_handle->mem_chunks[idx].vaddr == NULL && num_units) {
3755 wma_handle->mem_chunks[idx].vaddr =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303756 qdf_mem_alloc_consistent(wma_handle->qdf_dev,
3757 wma_handle->qdf_dev->dev,
3758 num_units * unit_len,
3759 &paddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003760 if (wma_handle->mem_chunks[idx].vaddr == NULL) {
3761 num_units = (num_units >> 1);/* reduce length by half */
3762 } else {
3763 wma_handle->mem_chunks[idx].paddr = paddr;
3764 wma_handle->mem_chunks[idx].len = num_units * unit_len;
3765 wma_handle->mem_chunks[idx].req_id = req_id;
3766 }
3767 }
3768 return num_units;
3769}
3770
3771#define HOST_MEM_SIZE_UNIT 4
3772/**
3773 * wma_alloc_host_mem() - allocate amount of memory requested by FW.
3774 * @wma_handle: wma handle
3775 * @req_id: request id
3776 * @num_units: number of units
3777 * @unit_len: unit length
3778 *
3779 * Return: none
3780 */
3781static void wma_alloc_host_mem(tp_wma_handle wma_handle, uint32_t req_id,
3782 uint32_t num_units, uint32_t unit_len)
3783{
3784 uint32_t remaining_units, allocated_units, idx;
3785
3786 /* adjust the length to nearest multiple of unit size */
3787 unit_len = (unit_len + (HOST_MEM_SIZE_UNIT - 1)) &
3788 (~(HOST_MEM_SIZE_UNIT - 1));
3789 idx = wma_handle->num_mem_chunks;
3790 remaining_units = num_units;
3791 while (remaining_units) {
3792 allocated_units = wma_alloc_host_mem_chunk(wma_handle, req_id,
3793 idx, remaining_units,
3794 unit_len);
3795 if (allocated_units == 0) {
3796 WMA_LOGE("FAILED TO ALLOCATED memory unit len %d"
3797 " units requested %d units allocated %d ",
3798 unit_len, num_units,
3799 (num_units - remaining_units));
3800 wma_handle->num_mem_chunks = idx;
3801 break;
3802 }
3803 remaining_units -= allocated_units;
3804 ++idx;
3805 if (idx == MAX_MEM_CHUNKS) {
3806 WMA_LOGE("RWACHED MAX CHUNK LIMIT for memory units %d"
3807 " unit len %d requested by FW,"
3808 " only allocated %d ",
3809 num_units, unit_len,
3810 (num_units - remaining_units));
3811 wma_handle->num_mem_chunks = idx;
3812 break;
3813 }
3814 }
3815 wma_handle->num_mem_chunks = idx;
3816}
3817
3818/**
3819 * wma_update_target_services() - update target services from wma handle
3820 * @wh: wma handle
3821 * @cfg: target services
3822 *
3823 * Return: none
3824 */
3825static inline void wma_update_target_services(tp_wma_handle wh,
3826 struct wma_tgt_services *cfg)
3827{
3828 /* STA power save */
3829 cfg->sta_power_save = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3830 WMI_SERVICE_STA_PWRSAVE);
3831
3832 /* Enable UAPSD */
3833 cfg->uapsd = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3834 WMI_SERVICE_AP_UAPSD);
3835
3836 /* Update AP DFS service */
3837 cfg->ap_dfs = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3838 WMI_SERVICE_AP_DFS);
3839
3840 /* Enable 11AC */
3841 cfg->en_11ac = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3842 WMI_SERVICE_11AC);
3843 if (cfg->en_11ac)
3844 g_fw_wlan_feat_caps |= (1 << DOT11AC);
3845
3846 /* Proactive ARP response */
3847 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
3848
3849 /* Enable WOW */
3850 g_fw_wlan_feat_caps |= (1 << WOW);
3851
3852 /* ARP offload */
3853 cfg->arp_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3854 WMI_SERVICE_ARPNS_OFFLOAD);
3855
3856 /* Adaptive early-rx */
3857 cfg->early_rx = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3858 WMI_SERVICE_EARLY_RX);
3859#ifdef FEATURE_WLAN_SCAN_PNO
3860 /* PNO offload */
3861 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NLO))
3862 cfg->pno_offload = true;
3863#endif /* FEATURE_WLAN_SCAN_PNO */
3864
3865#ifdef FEATURE_WLAN_EXTSCAN
3866 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_EXTSCAN)) {
3867 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
3868 }
3869#endif /* FEATURE_WLAN_EXTSCAN */
3870 cfg->lte_coex_ant_share = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3871 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT);
3872#ifdef FEATURE_WLAN_TDLS
3873 /* Enable TDLS */
3874 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_TDLS)) {
3875 cfg->en_tdls = 1;
3876 g_fw_wlan_feat_caps |= (1 << TDLS);
3877 }
3878 /* Enable advanced TDLS features */
3879 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3880 WMI_SERVICE_TDLS_OFFCHAN)) {
3881 cfg->en_tdls_offchan = 1;
3882 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
3883 }
3884
3885 cfg->en_tdls_uapsd_buf_sta =
3886 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3887 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA);
3888 cfg->en_tdls_uapsd_sleep_sta =
3889 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3890 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA);
3891#endif /* FEATURE_WLAN_TDLS */
3892 if (WMI_SERVICE_IS_ENABLED
3893 (wh->wmi_service_bitmap, WMI_SERVICE_BEACON_OFFLOAD))
3894 cfg->beacon_offload = true;
mukul sharma72c8b222015-09-04 17:02:01 +05303895 if (WMI_SERVICE_IS_ENABLED
3896 (wh->wmi_service_bitmap, WMI_SERVICE_STA_PMF_OFFLOAD))
3897 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003898#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3899 /* Enable Roam Offload */
3900 cfg->en_roam_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3901 WMI_SERVICE_ROAM_HO_OFFLOAD);
3902#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3903#ifdef WLAN_FEATURE_NAN
3904 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NAN))
3905 g_fw_wlan_feat_caps |= (1 << NAN);
3906#endif /* WLAN_FEATURE_NAN */
3907
3908 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_RTT))
3909 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07003910
3911 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3912 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT)) {
Leo Chang96464902016-10-28 11:10:54 -07003913 cdp_ipa_set_uc_tx_partition_base(
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003914 cds_get_context(QDF_MODULE_ID_SOC),
3915 (struct cdp_cfg *)cds_get_context(QDF_MODULE_ID_CFG),
3916 HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07003917 WMA_LOGI("%s: TX_MSDU_ID_NEW_PARTITION=%d", __func__,
3918 HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
3919 } else {
Leo Chang96464902016-10-28 11:10:54 -07003920 cdp_ipa_set_uc_tx_partition_base(
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003921 cds_get_context(QDF_MODULE_ID_SOC),
3922 (struct cdp_cfg *)cds_get_context(QDF_MODULE_ID_CFG),
3923 HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07003924 WMA_LOGI("%s: TX_MSDU_ID_OLD_PARTITION=%d", __func__,
3925 HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
3926 }
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07003927
3928 wma_he_update_tgt_services(wh, cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929}
3930
3931/**
3932 * wma_update_target_ht_cap() - update ht capabality from wma handle
3933 * @wh: wma handle
3934 * @cfg: ht capabality
3935 *
3936 * Return: none
3937 */
3938static inline void wma_update_target_ht_cap(tp_wma_handle wh,
3939 struct wma_tgt_ht_cap *cfg)
3940{
3941 /* RX STBC */
3942 cfg->ht_rx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_RX_STBC);
3943
3944 /* TX STBC */
3945 cfg->ht_tx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_TX_STBC);
3946
3947 /* MPDU density */
3948 cfg->mpdu_density = wh->ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
3949
3950 /* HT RX LDPC */
3951 cfg->ht_rx_ldpc = !!(wh->ht_cap_info & WMI_HT_CAP_LDPC);
3952
3953 /* HT SGI */
3954 cfg->ht_sgi_20 = !!(wh->ht_cap_info & WMI_HT_CAP_HT20_SGI);
3955
3956 cfg->ht_sgi_40 = !!(wh->ht_cap_info & WMI_HT_CAP_HT40_SGI);
3957
3958 /* RF chains */
3959 cfg->num_rf_chains = wh->num_rf_chains;
3960
Jeff Johnson3fd21822016-11-08 11:30:37 -08003961 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n"
3962 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
3963 "ht_sgi_40 - %d num_rf_chains - %d", __func__, wh->ht_cap_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
3965 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
3966 cfg->num_rf_chains);
3967
3968}
3969
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003970/**
3971 * wma_update_target_vht_cap() - update vht capabality from wma handle
3972 * @wh: wma handle
3973 * @cfg: vht capabality
3974 *
3975 * Return: none
3976 */
3977static inline void wma_update_target_vht_cap(tp_wma_handle wh,
3978 struct wma_tgt_vht_cap *cfg)
3979{
3980
3981 if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
3982 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
3983 else if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
3984 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
3985 else
3986 cfg->vht_max_mpdu = 0;
3987
3988
3989 if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
3990 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
3991 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
3992 } else if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ)
3993 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
3994 else
3995 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
3996
3997 cfg->vht_rx_ldpc = wh->vht_cap_info & WMI_VHT_CAP_RX_LDPC;
3998
3999 cfg->vht_short_gi_80 = wh->vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
4000 cfg->vht_short_gi_160 = wh->vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
4001
4002 cfg->vht_tx_stbc = wh->vht_cap_info & WMI_VHT_CAP_TX_STBC;
4003
4004 cfg->vht_rx_stbc = (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
4005 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
4006 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS) ;
4007
4008 cfg->vht_max_ampdu_len_exp = (wh->vht_cap_info &
4009 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
4010 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4011
4012 cfg->vht_su_bformer = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
4013
4014 cfg->vht_su_bformee = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
4015
4016 cfg->vht_mu_bformer = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
4017
4018 cfg->vht_mu_bformee = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
4019
4020 cfg->vht_txop_ps = wh->vht_cap_info & WMI_VHT_CAP_TXOP_PS;
4021
Jeff Johnson3fd21822016-11-08 11:30:37 -08004022 WMA_LOGD("%s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
4023 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
4024 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
4026 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
4027 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
4028 cfg->vht_max_ampdu_len_exp);
4029}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030
4031/**
Krunal Soniaa664da2016-06-15 23:46:40 -07004032 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
4033 * @wma_handle: pointer to wma_handle
4034 * @ht_cap: given pointer to HT caps which needs to be updated
4035 * @tx_chain: given tx chainmask value
4036 * @rx_chain: given rx chainmask value
4037 * @value: new HT cap info provided in form of bitmask
4038 *
4039 * This function takes the value provided in form of bitmask and decodes
4040 * it. After decoding, what ever value it gets, it takes the union(max) or
4041 * intersection(min) with previously derived values.
4042 *
4043 * Return: none
4044 *
4045 */
4046static void wma_derive_ext_ht_cap(tp_wma_handle wma_handle,
4047 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
4048 uint32_t tx_chain, uint32_t rx_chain)
4049{
4050 struct wma_tgt_ht_cap tmp = {0};
4051
4052 if (NULL == wma_handle || NULL == ht_cap)
4053 return;
4054
Ankit Guptaa5076012016-09-14 11:32:19 -07004055 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07004056 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
4057 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
4058 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
4059 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
4060 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
4061 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
4062 ht_cap->num_rf_chains =
4063 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
4064 wma_get_num_of_setbits_from_bitmask(rx_chain));
4065 } else {
4066 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
4067 (!!(value & WMI_HT_CAP_RX_STBC)));
4068 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
4069 (!!(value & WMI_HT_CAP_TX_STBC)));
4070 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
4071 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
4072 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
4073 (!!(value & WMI_HT_CAP_RX_LDPC)));
4074 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
4075 (!!(value & WMI_HT_CAP_HT20_SGI)));
4076 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
4077 (!!(value & WMI_HT_CAP_HT40_SGI)));
4078 ht_cap->num_rf_chains =
4079 QDF_MAX(ht_cap->num_rf_chains,
4080 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
4081 tx_chain),
4082 wma_get_num_of_setbits_from_bitmask(
4083 rx_chain)));
4084 }
4085}
4086
4087/**
4088 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
4089 * @wma_handle: pointer to wma_handle
4090 * @ht_cap: HT cap structure to be filled
4091 *
4092 * This function loop through each hardware mode and for each hardware mode
4093 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
4094 * HT caps and derives the final cap.
4095 *
4096 * Return: none
4097 *
4098 */
4099static void wma_update_target_ext_ht_cap(tp_wma_handle wma_handle,
4100 struct wma_tgt_ht_cap *ht_cap)
4101{
4102 int i, j = 0, max_mac;
4103 uint32_t ht_2g, ht_5g;
4104 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
4105 struct extended_caps *phy_caps;
4106 WMI_MAC_PHY_CAPABILITIES *mac_cap;
4107
4108 /*
4109 * for legacy device extended cap might not even come, so in that case
4110 * don't overwrite legacy values
4111 */
4112 if (!wma_handle ||
4113 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
4114 WMA_LOGI("%s: No extended HT cap for current SOC", __func__);
4115 return;
4116 }
4117
4118 phy_caps = &wma_handle->phy_caps;
4119 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
4120 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
4121 max_mac = j + 2;
4122 else
4123 max_mac = j + 1;
4124 for ( ; j < max_mac; j++) {
4125 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
4126 ht_2g = mac_cap->ht_cap_info_2G;
4127 ht_5g = mac_cap->ht_cap_info_5G;
4128 if (ht_2g)
4129 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
4130 ht_2g, mac_cap->tx_chain_mask_2G,
4131 mac_cap->rx_chain_mask_2G);
4132 if (ht_5g)
4133 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
4134 ht_5g, mac_cap->tx_chain_mask_5G,
4135 mac_cap->rx_chain_mask_5G);
4136 }
4137 }
4138
Ankit Guptaa5076012016-09-14 11:32:19 -07004139 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004140 sizeof(struct wma_tgt_ht_cap))) {
4141 qdf_mem_copy(ht_cap, &tmp_ht_cap,
4142 sizeof(struct wma_tgt_ht_cap));
4143 }
4144
Jeff Johnson3fd21822016-11-08 11:30:37 -08004145 WMA_LOGI("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n"
4146 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
4147 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07004148 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
4149 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
4150 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
4151 ht_cap->num_rf_chains);
4152}
4153
4154/**
4155 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
4156 * @wma_handle: pointer to wma_handle
4157 * @vht_cap: pointer to given VHT caps to be filled
4158 * @value: new VHT cap info provided in form of bitmask
4159 *
4160 * This function takes the value provided in form of bitmask and decodes
4161 * it. After decoding, what ever value it gets, it takes the union(max) or
4162 * intersection(min) with previously derived values.
4163 *
4164 * Return: none
4165 *
4166 */
4167static void wma_derive_ext_vht_cap(t_wma_handle *wma_handle,
4168 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
4169{
4170 struct wma_tgt_vht_cap tmp_cap = {0};
4171 uint32_t tmp = 0;
4172
4173 if (NULL == wma_handle || NULL == vht_cap)
4174 return;
4175
Ankit Guptaa5076012016-09-14 11:32:19 -07004176 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004177 sizeof(struct wma_tgt_vht_cap))) {
4178 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4179 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4180 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4181 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4182 else
4183 vht_cap->vht_max_mpdu = 0;
4184
4185 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
4186 vht_cap->supp_chan_width =
4187 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4188 vht_cap->supp_chan_width |=
4189 1 << eHT_CHANNEL_WIDTH_160MHZ;
4190 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4191 vht_cap->supp_chan_width =
4192 1 << eHT_CHANNEL_WIDTH_160MHZ;
4193 } else {
4194 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4195 }
4196 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
4197 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
4198 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
4199 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
4200 vht_cap->vht_rx_stbc =
4201 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4202 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4203 (value & WMI_VHT_CAP_RX_STBC_3SS);
4204 vht_cap->vht_max_ampdu_len_exp =
4205 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4206 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4207 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
4208 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
4209 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
4210 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
4211 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
4212 } else {
4213 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4214 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4215 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4216 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4217 else
4218 tmp = 0;
4219 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
4220
4221 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
4222 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
4223 (1 << eHT_CHANNEL_WIDTH_160MHZ);
4224 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4225 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
4226 } else {
4227 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4228 }
4229 vht_cap->supp_chan_width =
4230 QDF_MAX(vht_cap->supp_chan_width, tmp);
4231 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
4232 value & WMI_VHT_CAP_RX_LDPC);
4233 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
4234 value & WMI_VHT_CAP_SGI_80MHZ);
4235 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
4236 value & WMI_VHT_CAP_SGI_160MHZ);
4237 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
4238 value & WMI_VHT_CAP_TX_STBC);
4239 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
4240 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4241 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4242 (value & WMI_VHT_CAP_RX_STBC_3SS));
4243 vht_cap->vht_max_ampdu_len_exp =
4244 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
4245 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4246 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
4247 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
4248 value & WMI_VHT_CAP_SU_BFORMER);
4249 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
4250 value & WMI_VHT_CAP_SU_BFORMEE);
4251 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
4252 value & WMI_VHT_CAP_MU_BFORMER);
4253 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
4254 value & WMI_VHT_CAP_MU_BFORMEE);
4255 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
4256 value & WMI_VHT_CAP_TXOP_PS);
4257 }
4258}
4259
4260/**
4261 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
4262 * @wma_handle: pointer to wma_handle
4263 * @vht_cap: VHT cap structure to be filled
4264 *
4265 * This function loop through each hardware mode and for each hardware mode
4266 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
4267 * VHT caps and derives the final cap.
4268 *
4269 * Return: none
4270 *
4271 */
4272static void wma_update_target_ext_vht_cap(t_wma_handle *wma_handle,
4273 struct wma_tgt_vht_cap *vht_cap)
4274{
4275 int i, j = 0, max_mac;
4276 uint32_t vht_cap_info_2g, vht_cap_info_5g;
4277 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
4278 struct extended_caps *phy_caps;
4279 WMI_MAC_PHY_CAPABILITIES *mac_cap;
4280
4281 /*
4282 * for legacy device extended cap might not even come, so in that case
4283 * don't overwrite legacy values
4284 */
4285 if (!wma_handle ||
4286 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
4287 WMA_LOGI("%s: No extended VHT cap for current SOC", __func__);
4288 return;
4289 }
4290
4291 phy_caps = &wma_handle->phy_caps;
4292 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
4293 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
4294 max_mac = j + 2;
4295 else
4296 max_mac = j + 1;
4297 for ( ; j < max_mac; j++) {
4298 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
4299 vht_cap_info_2g = mac_cap->vht_cap_info_2G;
4300 vht_cap_info_5g = mac_cap->vht_cap_info_5G;
4301 if (vht_cap_info_2g)
4302 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4303 vht_cap_info_2g);
4304 if (vht_cap_info_5g)
4305 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4306 vht_cap_info_5g);
4307 }
4308 }
4309
Ankit Guptaa5076012016-09-14 11:32:19 -07004310 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004311 sizeof(struct wma_tgt_vht_cap))) {
4312 qdf_mem_copy(vht_cap, &tmp_vht_cap,
4313 sizeof(struct wma_tgt_vht_cap));
4314 }
4315
Jeff Johnson3fd21822016-11-08 11:30:37 -08004316 WMA_LOGI("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
4317 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
4318 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07004319 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
4320 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
4321 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
4322 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
4323 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
4324}
4325
4326/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304327 * wma_update_ra_rate_limit() - update wma config
4328 * @wma_handle: wma handle
4329 * @cfg: target config
4330 *
4331 * Return: none
4332 */
4333#ifdef FEATURE_WLAN_RA_FILTERING
4334static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4335 struct wma_tgt_cfg *cfg)
4336{
4337 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
4338}
4339#else
4340static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4341 struct wma_tgt_cfg *cfg)
4342{
4343}
4344#endif
4345
4346/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347 * wma_update_hdd_cfg() - update HDD config
4348 * @wma_handle: wma handle
4349 *
4350 * Return: none
4351 */
4352static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
4353{
4354 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304355 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304357 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07004358
4359 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004360 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
4361 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
4362
4363 switch (wma_handle->phy_capability) {
4364 case WMI_11G_CAPABILITY:
4365 case WMI_11NG_CAPABILITY:
4366 tgt_cfg.band_cap = eCSR_BAND_24;
4367 break;
4368 case WMI_11A_CAPABILITY:
4369 case WMI_11NA_CAPABILITY:
4370 case WMI_11AC_CAPABILITY:
4371 tgt_cfg.band_cap = eCSR_BAND_5G;
4372 break;
4373 case WMI_11AG_CAPABILITY:
4374 case WMI_11NAG_CAPABILITY:
4375 default:
4376 tgt_cfg.band_cap = eCSR_BAND_ALL;
4377 }
4378
4379 tgt_cfg.max_intf_count = wma_handle->wlan_resource_config.num_vdevs;
4380
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304381 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004382 ATH_MAC_LEN);
4383
4384 wma_update_target_services(wma_handle, &tgt_cfg.services);
4385 wma_update_target_ht_cap(wma_handle, &tgt_cfg.ht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004386 wma_update_target_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07004387 /*
4388 * This will overwrite the structure filled by wma_update_target_ht_cap
4389 * and wma_update_target_vht_cap APIs.
4390 */
4391 wma_update_target_ext_ht_cap(wma_handle, &tgt_cfg.ht_cap);
4392 wma_update_target_ext_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004394 wma_update_target_ext_he_cap(wma_handle, &tgt_cfg);
4395
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 tgt_cfg.target_fw_version = wma_handle->target_fw_version;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07004397 tgt_cfg.target_fw_vers_ext = wma_handle->target_fw_vers_ext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398#ifdef WLAN_FEATURE_LPSS
4399 tgt_cfg.lpss_support = wma_handle->lpss_support;
4400#endif /* WLAN_FEATURE_LPSS */
4401 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Rajeev Kumare5a16822016-07-27 13:11:42 -07004402 tgt_cfg.bpf_enabled = wma_handle->bpf_enabled;
Arif Hussain759a0232017-03-20 13:17:18 -07004403 tgt_cfg.dfs_cac_offload = wma_handle->dfs_cac_offload;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304404 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004405 tgt_cfg.fine_time_measurement_cap =
4406 wma_handle->fine_time_measurement_cap;
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05304407 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
4408 - WMI_TLV_HEADROOM;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08004409 wma_setup_egap_support(&tgt_cfg, wma_handle);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004410
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07004411 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07004412 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413}
4414
4415/**
4416 * wma_setup_wmi_init_msg() - fill wmi init message buffer
4417 * @wma_handle: wma handle
4418 * @ev: ready event fixed params
4419 * @param_buf: redy event TLVs
4420 * @len: buffer length
4421 *
4422 * Return: wmi buffer or NULL for error
4423 */
Govind Singhf25a0f12016-03-08 16:09:48 +05304424static int wma_setup_wmi_init_msg(tp_wma_handle wma_handle,
4425 wmi_service_ready_event_fixed_param *ev,
4426 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004427{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 wlan_host_mem_req *ev_mem_reqs;
4429 wmi_abi_version my_vers;
Govind Singhf25a0f12016-03-08 16:09:48 +05304430 wmi_abi_version host_abi_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 int num_whitelist;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 uint16_t idx;
4433 uint32_t num_units;
4434
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 ev_mem_reqs = param_buf->mem_reqs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436
4437 /* allocate memory requested by FW */
4438 if (ev->num_mem_reqs > WMI_MAX_MEM_REQS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304439 QDF_ASSERT(0);
Govind Singhf25a0f12016-03-08 16:09:48 +05304440 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 }
4442
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 for (idx = 0; idx < ev->num_mem_reqs; ++idx) {
4444 num_units = ev_mem_reqs[idx].num_units;
4445 if (ev_mem_reqs[idx].num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4446 /*
4447 * number of units to allocate is number
4448 * of peers, 1 extra for self peer on
4449 * target. this needs to be fied, host
4450 * and target can get out of sync
4451 */
Govind Singhf25a0f12016-03-08 16:09:48 +05304452 num_units = wma_handle->wlan_resource_config.num_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 }
4454 WMA_LOGD
4455 ("idx %d req %d num_units %d num_unit_info %d unit size %d actual units %d ",
4456 idx, ev_mem_reqs[idx].req_id,
4457 ev_mem_reqs[idx].num_units,
4458 ev_mem_reqs[idx].num_unit_info,
4459 ev_mem_reqs[idx].unit_size, num_units);
4460 wma_alloc_host_mem(wma_handle, ev_mem_reqs[idx].req_id,
4461 num_units, ev_mem_reqs[idx].unit_size);
4462 }
Govind Singhf25a0f12016-03-08 16:09:48 +05304463
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304464 qdf_mem_copy(&wma_handle->target_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 &param_buf->fixed_param->fw_abi_vers,
4466 sizeof(wmi_abi_version));
4467 num_whitelist = sizeof(version_whitelist) /
4468 sizeof(wmi_whitelist_version_info);
4469 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
4470 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
4471 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
4472 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
4473 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
4474 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
4475
4476 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
4477 &my_vers,
4478 &param_buf->fixed_param->fw_abi_vers,
Govind Singhf25a0f12016-03-08 16:09:48 +05304479 &host_abi_vers);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480
Govind Singhf25a0f12016-03-08 16:09:48 +05304481 qdf_mem_copy(&wma_handle->final_abi_vers, &host_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 sizeof(wmi_abi_version));
Govind Singhf25a0f12016-03-08 16:09:48 +05304483
4484 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485}
4486
4487/**
4488 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
4489 * @wma_handle: WMA handle
4490 *
4491 * Prints the DBS HW modes sent by the FW as part
4492 * of WMI ready event
4493 *
4494 * Return: None
4495 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004496static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497{
4498 uint32_t i, param;
4499
4500 if (!wma_handle) {
4501 WMA_LOGE("%s: Invalid WMA handle", __func__);
4502 return;
4503 }
4504
4505 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
4506 param = wma_handle->hw_mode.hw_mode_list[i];
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004507 WMA_LOGD("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304509 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
4510 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
4511 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004512 WMA_LOGD("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304514 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
4515 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
4516 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004517 WMA_LOGD("%s:[%d] DBS:%d SBS:%d", __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304518 WMA_HW_MODE_DBS_MODE_GET(param),
4519 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004521 policy_mgr_dump_dbs_hw_mode(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522}
4523
4524/**
4525 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
4526 * @wma_handle: WMA handle
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304527 * @scan_config: Scam mode configuration
4528 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 *
4530 * Enables all the valid bits of concurrent_scan_config_bits and
4531 * fw_mode_config_bits.
4532 *
4533 * Return: None
4534 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004535static void wma_init_scan_fw_mode_config(tp_wma_handle wma_handle,
4536 uint32_t scan_config,
4537 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539 WMA_LOGD("%s: Enter", __func__);
4540
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004541 if (!wma_handle) {
4542 WMA_LOGE("%s: Invalid WMA handle", __func__);
4543 return;
4544 }
4545
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004546 policy_mgr_init_dbs_config(wma_handle->psoc, scan_config, fw_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547}
4548
4549/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304550 * wma_update_ra_limit() - update ra limit based on bpf filter
4551 * enabled or not
4552 * @handle: wma handle
4553 *
4554 * Return: none
4555 */
4556#ifdef FEATURE_WLAN_RA_FILTERING
4557static void wma_update_ra_limit(tp_wma_handle wma_handle)
4558{
4559 if (wma_handle->bpf_enabled)
4560 wma_handle->IsRArateLimitEnabled = false;
4561}
4562#else
4563static void wma_update_ra__limit(tp_wma_handle handle)
4564{
4565}
4566#endif
4567
4568/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 * wma_rx_service_ready_event() - event handler to process
4570 * wmi rx sevice ready event.
4571 * @handle: wma handle
4572 * @cmd_param_info: command params info
4573 *
4574 * Return: none
4575 */
Govind Singhd76a5b02016-03-08 15:12:14 +05304576int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
4577 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 tp_wma_handle wma_handle = (tp_wma_handle) handle;
4580 struct wma_target_cap target_cap;
4581 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
4582 wmi_service_ready_event_fixed_param *ev;
4583 int status;
4584 uint32_t *ev_wlan_dbs_hw_mode_list;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304585 QDF_STATUS ret;
Leo Chang96464902016-10-28 11:10:54 -07004586 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587
4588 WMA_LOGD("%s: Enter", __func__);
4589
4590 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
4591 if (!(handle && param_buf)) {
4592 WMA_LOGP("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304593 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 }
4595
4596 ev = param_buf->fixed_param;
4597 if (!ev) {
4598 WMA_LOGP("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304599 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 }
4601
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004602 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603
4604 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
4605 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
4606 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304607 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 wma_handle->num_dbs_hw_modes);
4609 if (!wma_handle->hw_mode.hw_mode_list) {
4610 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
4611 /* Continuing with the rest of the processing */
4612 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304613 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614 ev_wlan_dbs_hw_mode_list,
4615 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
4616 wma_handle->num_dbs_hw_modes));
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004617 policy_mgr_init_dbs_hw_mode(wma_handle->psoc,
4618 ev->num_dbs_hw_modes, ev_wlan_dbs_hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 wma_dump_dbs_hw_mode(wma_handle);
4620
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304621 /* Initializes the fw_mode and scan_config to zero.
4622 * If ext service ready event is present it will set
4623 * the actual values of these two params.
4624 * This is to ensure that no garbage values would be
4625 * present in the absence of ext service ready event.
4626 */
4627 wma_init_scan_fw_mode_config(wma_handle, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628
4629 wma_handle->phy_capability = ev->phy_capability;
4630 wma_handle->max_frag_entry = ev->max_frag_entry;
4631 wma_handle->num_rf_chains = ev->num_rf_chains;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304632 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633 sizeof(HAL_REG_CAPABILITIES));
4634 wma_handle->ht_cap_info = ev->ht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 wma_handle->vht_cap_info = ev->vht_cap_info;
4636 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 wma_handle->num_rf_chains = ev->num_rf_chains;
4638
4639 wma_handle->target_fw_version = ev->fw_build_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 wma_handle->new_hw_mode_index = ev->default_dbs_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004641 policy_mgr_update_new_hw_mode_index(wma_handle->psoc,
4642 ev->default_dbs_hw_mode_index);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004643 wma_handle->fine_time_measurement_cap = ev->wmi_fw_sub_feat_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644
4645 WMA_LOGD("%s: Firmware default hw mode index : %d",
4646 __func__, ev->default_dbs_hw_mode_index);
4647 WMA_LOGE("%s: Firmware build version : %08x",
4648 __func__, ev->fw_build_vers);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004649 WMA_LOGD(FL("FW fine time meas cap: 0x%x"), ev->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650
4651 if (ev->hw_bd_id) {
4652 wma_handle->hw_bd_id = ev->hw_bd_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304653 qdf_mem_copy(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 ev->hw_bd_info, sizeof(ev->hw_bd_info));
4655
4656 WMA_LOGE("%s: Board version: %x.%x",
4657 __func__,
4658 wma_handle->hw_bd_info[0], wma_handle->hw_bd_info[1]);
4659 } else {
4660 wma_handle->hw_bd_id = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304661 qdf_mem_zero(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662 sizeof(wma_handle->hw_bd_info));
4663 WMA_LOGE("%s: Board version is unknown!", __func__);
4664 }
Rakesh Sunki8641f8a2015-12-10 15:11:19 -08004665 wma_handle->dfs_ic->dfs_hw_bd_id = wma_handle->hw_bd_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666
4667 /* TODO: Recheck below line to dump service ready event */
4668 /* dbg_print_wmi_service_11ac(ev); */
4669
4670 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304671 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672 param_buf->wmi_service_bitmap,
4673 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05304674
Leo Chang96464902016-10-28 11:10:54 -07004675 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(soc,
Nirav Shah22bf44d2015-12-10 15:39:48 +05304676 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4677 WMI_SERVICE_MGMT_TX_WMI));
Leo Chang96464902016-10-28 11:10:54 -07004678 cdp_set_desc_global_pool_size(soc, ev->num_msdu_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679 /* SWBA event handler for beacon transmission */
4680 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4681 WMI_HOST_SWBA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304682 wma_beacon_swba_handler,
4683 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 if (status) {
4685 WMA_LOGE("Failed to register swba beacon event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304686 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 }
4688#ifdef WLAN_FEATURE_LPSS
4689 wma_handle->lpss_support =
4690 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4691 WMI_SERVICE_LPASS);
4692#endif /* WLAN_FEATURE_LPSS */
4693
4694 /*
4695 * This Service bit is added to check for ARP/NS Offload
4696 * support for LL/HL targets
4697 */
4698 wma_handle->ap_arpns_support =
4699 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4700 WMI_SERVICE_AP_ARPNS_OFFLOAD);
4701
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304702 wma_handle->bpf_enabled = (wma_handle->bpf_packet_filter_enable &&
Rajeev Kumare5a16822016-07-27 13:11:42 -07004703 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304704 WMI_SERVICE_BPF_OFFLOAD));
4705 wma_update_ra_limit(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004706 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4707 WMI_SERVICE_CSA_OFFLOAD)) {
4708 WMA_LOGD("%s: FW support CSA offload capability", __func__);
4709 status =
4710 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304711 WMI_CSA_HANDLING_EVENTID,
4712 wma_csa_offload_handler,
4713 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 if (status) {
4715 WMA_LOGE("Failed to register CSA offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304716 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 }
4718 }
4719
4720 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4721 WMI_SERVICE_MGMT_TX_WMI)) {
4722 WMA_LOGE("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723 /*
4724 * Register Tx completion event handler for MGMT Tx over WMI
4725 * case
4726 */
4727 status = wmi_unified_register_event_handler(
4728 wma_handle->wmi_handle,
4729 WMI_MGMT_TX_COMPLETION_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304730 wma_mgmt_tx_completion_handler,
4731 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732 if (status) {
4733 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Govind Singhd76a5b02016-03-08 15:12:14 +05304734 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004735 }
4736
Nirav Shah20489972016-06-16 19:20:28 +05304737 status = wmi_unified_register_event_handler(
4738 wma_handle->wmi_handle,
4739 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID,
4740 wma_mgmt_tx_bundle_completion_handler,
4741 WMA_RX_SERIALIZER_CTX);
4742 if (status) {
4743 WMA_LOGE("Failed to register MGMT over WMI completion handler");
4744 return -EINVAL;
4745 }
4746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 } else {
4748 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
4749 }
4750#ifdef WLAN_FEATURE_GTK_OFFLOAD
4751 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4752 WMI_SERVICE_GTK_OFFLOAD)) {
4753 status =
4754 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma3d36c392017-01-18 18:39:12 +05304755 WMI_GTK_OFFLOAD_STATUS_EVENTID,
4756 target_if_pmo_gtk_offload_status_event,
4757 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758 if (status) {
4759 WMA_LOGE("Failed to register GTK offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304760 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761 }
4762 }
4763#endif /* WLAN_FEATURE_GTK_OFFLOAD */
4764
Wu Gao9a704f42017-03-10 18:42:11 +08004765#ifndef CONVERGED_P2P_ENABLE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4767 WMI_P2P_NOA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304768 wma_p2p_noa_event_handler,
4769 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 if (status) {
4771 WMA_LOGE("Failed to register WMI_P2P_NOA_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05304772 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004773 }
Wu Gao9a704f42017-03-10 18:42:11 +08004774#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304776 WMI_TBTTOFFSET_UPDATE_EVENTID,
4777 wma_tbttoffset_update_event_handler,
4778 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 if (status) {
4780 WMA_LOGE
4781 ("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05304782 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783 }
4784
Govind Singhefc5ccd2016-04-25 11:11:55 +05304785 /* mac_id is replaced with pdev_id in converged firmware to have
4786 * multi-radio support. In order to maintain backward compatibility
4787 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
4788 * in service bitmap from FW and host needs to set use_pdev_id in
4789 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
4790 * service is not set, then host shall not expect MAC ID from FW in
4791 * VDEV START RESPONSE event and host shall use PDEV ID.
4792 */
4793 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4794 WMI_SERVICE_DEPRECATED_REPLACE))
4795 wma_handle->wlan_resource_config.use_pdev_id = true;
4796 else
4797 wma_handle->wlan_resource_config.use_pdev_id = false;
4798
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08004799 /* register the Enhanced Green AP event handler */
4800 wma_register_egap_event_handle(wma_handle);
4801
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802 /* Initialize the log supported event handler */
4803 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4804 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304805 wma_log_supported_evt_handler,
4806 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304807 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004808 WMA_LOGE("Failed to register log supported event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304809 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810 }
4811
Leo Chang96464902016-10-28 11:10:54 -07004812 cdp_mark_first_wakeup_packet(soc,
Himanshu Agarwal19141bb2016-07-20 20:15:48 +05304813 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4814 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET));
Arif Hussain759a0232017-03-20 13:17:18 -07004815 wma_handle->dfs_cac_offload =
4816 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4817 WMI_SERVICE_DFS_PHYERR_OFFLOAD);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07004818 wma_handle->nan_datapath_enabled =
4819 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4820 WMI_SERVICE_NAN_DATA);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304821 qdf_mem_copy(target_cap.wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 param_buf->wmi_service_bitmap,
4823 sizeof(wma_handle->wmi_service_bitmap));
4824 target_cap.wlan_resource_config = wma_handle->wlan_resource_config;
4825 wma_update_fw_config(wma_handle, &target_cap);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304826 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 target_cap.wmi_service_bitmap,
4828 sizeof(wma_handle->wmi_service_bitmap));
4829 wma_handle->wlan_resource_config = target_cap.wlan_resource_config;
4830
Govind Singhf25a0f12016-03-08 16:09:48 +05304831 status = wmi_unified_save_fw_version_cmd(wma_handle->wmi_handle,
4832 param_buf);
4833 if (status != EOK) {
4834 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
4835 return -EINVAL;
4836 }
4837
4838 status = wma_setup_wmi_init_msg(wma_handle, ev, param_buf);
4839 if (status != EOK) {
4840 WMA_LOGE("Failed to setup for wma init command");
Govind Singhd76a5b02016-03-08 15:12:14 +05304841 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 }
4843
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304844 /* A host, which supports WMI_SERVICE_READY_EXT_EVENTID, would need to
4845 * check the WMI_SERVICE_READY message for an "extension" flag, and if
4846 * this flag is set, then hold off on sending the WMI_INIT message until
4847 * WMI_SERVICE_READY_EXT_EVENTID is received.
4848 */
4849 if (!WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4850 WMI_SERVICE_EXT_MSG)) {
4851 /* No service extended message support.
4852 * Send INIT command immediately
4853 */
4854 WMA_LOGA("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05304855 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
4856 &wma_handle->wlan_resource_config,
4857 wma_handle->num_mem_chunks,
4858 wma_handle->mem_chunks, 1);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304859 if (status != EOK) {
4860 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Govind Singhd76a5b02016-03-08 15:12:14 +05304861 return -EINVAL;
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304862 }
4863 } else {
Govind Singhf25a0f12016-03-08 16:09:48 +05304864 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
4865 &wma_handle->wlan_resource_config,
4866 wma_handle->num_mem_chunks,
4867 wma_handle->mem_chunks, 0);
4868 if (status != EOK) {
4869 WMA_LOGE("Failed to save WMI_INIT_CMDID command parameter");
4870 return -EINVAL;
4871 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304872 /* The saved 'buf' will be freed after sending INIT command or
4873 * in other cases as required
4874 */
Anurag Chouhan210db072016-02-22 18:42:15 +05304875 ret = qdf_mc_timer_start(&wma_handle->service_ready_ext_timer,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304876 WMA_SERVICE_READY_EXT_TIMEOUT);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304877 if (!QDF_IS_STATUS_SUCCESS(ret))
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304878 WMA_LOGP("Failed to start the service ready ext timer");
4879
4880 WMA_LOGA("%s: WMA waiting for WMI_SERVICE_READY_EXT_EVENTID",
4881 __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 }
Govind Singhd76a5b02016-03-08 15:12:14 +05304883
4884 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885}
4886
4887/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07004888 * wma_get_phyid_for_given_band() - to get phyid for band
4889 *
4890 * @wma_handle: Pointer to wma handle
4891 * @map: Pointer to map which is derived from hw mode & has mapping between
4892 * hw mode and available PHYs for that hw mode.
4893 * @band: enum value of for 2G or 5G band
4894 * @phyid: Pointer to phyid which needs to be filled
4895 *
4896 * This API looks in to the map to find out which particular phy supports
4897 * provided band and return the idx (also called phyid) of that phy. Caller
4898 * use this phyid to fetch various caps of that phy
4899 *
4900 * Return: QDF_STATUS
4901 */
4902static QDF_STATUS wma_get_phyid_for_given_band(
4903 t_wma_handle * wma_handle,
4904 struct hw_mode_idx_to_mac_cap_idx *map,
4905 enum cds_band_type band, uint8_t *phyid)
4906{
4907 uint8_t idx, i;
4908 WMI_MAC_PHY_CAPABILITIES *cap;
4909
4910 if (!wma_handle) {
4911 WMA_LOGE("Invalid wma handle");
4912 return QDF_STATUS_E_FAILURE;
4913 }
4914
4915 if (!map) {
4916 WMA_LOGE("Invalid given map");
4917 return QDF_STATUS_E_FAILURE;
4918 }
4919 idx = map->mac_cap_idx;
4920 *phyid = idx;
4921
4922 for (i = 0; i < map->num_of_macs; i++) {
4923 cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[idx + i];
4924 if ((band == CDS_BAND_2GHZ) &&
4925 (WLAN_2G_CAPABILITY == cap->supported_bands)) {
4926 *phyid = idx + i;
4927 WMA_LOGI("Select 2G capable phyid[%d]", *phyid);
4928 return QDF_STATUS_SUCCESS;
4929 } else if ((band == CDS_BAND_5GHZ) &&
4930 (WLAN_5G_CAPABILITY == cap->supported_bands)) {
4931 *phyid = idx + i;
4932 WMA_LOGI("Select 5G capable phyid[%d]", *phyid);
4933 return QDF_STATUS_SUCCESS;
4934 }
4935 }
4936 WMA_LOGI("Using default single hw mode phyid[%d]", *phyid);
4937 return QDF_STATUS_SUCCESS;
4938}
4939
4940/**
4941 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
4942 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
4943 * @hw_mode: Provided hardware mode
4944 * @band: Provide band i.e. 2G or 5G
4945 *
4946 * This API finds cap which suitable for provided hw mode and band. If user
4947 * is provides some invalid hw mode then it will automatically falls back to
4948 * default hw mode
4949 *
4950 * Return: QDF_STATUS
4951 */
4952QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
4953 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
4954{
4955 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
4956 struct hw_mode_idx_to_mac_cap_idx *map;
4957 WMI_MAC_PHY_CAPABILITIES *phy_cap;
4958 uint8_t phyid, our_hw_mode = hw_mode;
4959
4960 if (!wma_handle) {
4961 WMA_LOGE("Invalid wma handle");
4962 return QDF_STATUS_E_FAILURE;
4963 }
4964
4965 if (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes) {
4966 WMA_LOGE("Invalid number of hw modes");
4967 return QDF_STATUS_E_FAILURE;
4968 }
4969
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004970 if (!policy_mgr_is_dbs_enable(wma_handle->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -07004971 our_hw_mode = HW_MODE_DBS_NONE;
4972
4973 if (!caps_per_phy) {
4974 WMA_LOGE("Invalid caps pointer");
4975 return QDF_STATUS_E_FAILURE;
4976 }
4977
4978 map = &wma_handle->phy_caps.hw_mode_to_mac_cap_map[our_hw_mode];
4979
4980 if (QDF_STATUS_SUCCESS !=
4981 wma_get_phyid_for_given_band(wma_handle, map, band, &phyid)) {
4982 WMA_LOGE("Invalid phyid");
4983 return QDF_STATUS_E_FAILURE;
4984 }
4985 phy_cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[phyid];
4986
4987 caps_per_phy->ht_2g = phy_cap->ht_cap_info_2G;
4988 caps_per_phy->ht_5g = phy_cap->ht_cap_info_5G;
4989 caps_per_phy->vht_2g = phy_cap->vht_cap_info_2G;
4990 caps_per_phy->vht_5g = phy_cap->vht_cap_info_5G;
4991 caps_per_phy->he_2g = phy_cap->he_cap_info_2G;
4992 caps_per_phy->he_5g = phy_cap->he_cap_info_5G;
4993
4994 return QDF_STATUS_SUCCESS;
4995}
4996
4997/**
4998 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
4999 *
5000 * @channel: Channel number for which it needs to check if rx ldpc is enabled
5001 *
5002 * This API takes channel number as argument and takes default hw mode as DBS
5003 * to check if rx LDPC support is enabled for that channel or no
5004 */
5005bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
5006{
5007 struct wma_caps_per_phy caps_per_phy = {0};
5008 enum cds_band_type band;
5009 bool status;
5010
5011 if (!CDS_IS_CHANNEL_24GHZ(channel))
5012 band = CDS_BAND_5GHZ;
5013 else
5014 band = CDS_BAND_2GHZ;
5015
5016 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
5017 &caps_per_phy,
5018 HW_MODE_DBS, band)) {
5019 return false;
5020 }
5021 if (CDS_IS_CHANNEL_24GHZ(channel))
5022 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
5023 else
5024 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
5025
5026 return status;
5027}
5028
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005029/**
5030 * wma_print_mac_phy_capabilities() - Prints MAC PHY capabilities
5031 * @cap: pointer to WMI_MAC_PHY_CAPABILITIES
5032 * @index: MAC_PHY index
5033 *
5034 * Return: none
5035 */
5036static void wma_print_mac_phy_capabilities(WMI_MAC_PHY_CAPABILITIES *cap,
5037 int index)
5038{
5039 uint32_t mac_2G, mac_5G;
5040 uint32_t phy_2G[WMI_MAX_HECAP_PHY_SIZE];
5041 uint32_t phy_5G[WMI_MAX_HECAP_PHY_SIZE];
5042 wmi_ppe_threshold ppet_2G, ppet_5G;
5043
5044 WMA_LOGI("\t: index [%d]", index);
5045 WMA_LOGI("\t: cap for hw_mode_id[%d]", cap->hw_mode_id);
5046 WMA_LOGI("\t: pdev_id[%d]", cap->pdev_id);
5047 WMA_LOGI("\t: phy_id[%d]", cap->phy_id);
5048 WMA_LOGI("\t: supports_11b[%d]",
5049 WMI_SUPPORT_11B_GET(cap->supported_flags));
5050 WMA_LOGI("\t: supports_11g[%d]",
5051 WMI_SUPPORT_11G_GET(cap->supported_flags));
5052 WMA_LOGI("\t: supports_11a[%d]",
5053 WMI_SUPPORT_11A_GET(cap->supported_flags));
5054 WMA_LOGI("\t: supports_11n[%d]",
5055 WMI_SUPPORT_11N_GET(cap->supported_flags));
5056 WMA_LOGI("\t: supports_11ac[%d]",
5057 WMI_SUPPORT_11AC_GET(cap->supported_flags));
5058 WMA_LOGI("\t: supports_11ax[%d]",
5059 WMI_SUPPORT_11AX_GET(cap->supported_flags));
5060 WMA_LOGI("\t: supported_flags[%d]", cap->supported_flags);
5061 WMA_LOGI("\t: supported_bands[%d]", cap->supported_bands);
5062 WMA_LOGI("\t: ampdu_density[%d]", cap->ampdu_density);
5063 WMA_LOGI("\t: max_bw_supported_2G[%d]", cap->max_bw_supported_2G);
5064 WMA_LOGI("\t: ht_cap_info_2G[%d]", cap->ht_cap_info_2G);
5065 WMA_LOGI("\t: vht_cap_info_2G[%d]", cap->vht_cap_info_2G);
5066 WMA_LOGI("\t: vht_supp_mcs_2G[%d]", cap->vht_supp_mcs_2G);
5067 WMA_LOGI("\t: tx_chain_mask_2G[%d]", cap->tx_chain_mask_2G);
5068 WMA_LOGI("\t: rx_chain_mask_2G[%d]", cap->rx_chain_mask_2G);
5069 WMA_LOGI("\t: max_bw_supported_5G[%d]", cap->max_bw_supported_5G);
5070 WMA_LOGI("\t: ht_cap_info_5G[%d]", cap->ht_cap_info_5G);
5071 WMA_LOGI("\t: vht_cap_info_5G[%d]", cap->vht_cap_info_5G);
5072 WMA_LOGI("\t: vht_supp_mcs_5G[%d]", cap->vht_supp_mcs_5G);
5073 WMA_LOGI("\t: tx_chain_mask_5G[%d]", cap->tx_chain_mask_5G);
5074 WMA_LOGI("\t: rx_chain_mask_5G[%d]", cap->rx_chain_mask_5G);
5075 WMA_LOGI("\t: he_cap_info_2G[%08x]", cap->he_cap_info_2G);
5076 WMA_LOGI("\t: he_supp_mcs_2G[%08x]", cap->he_supp_mcs_2G);
5077 WMA_LOGI("\t: he_cap_info_5G[%08x]", cap->he_cap_info_5G);
5078 WMA_LOGI("\t: he_supp_mcs_5G[%08x]", cap->he_supp_mcs_5G);
5079 mac_2G = cap->he_cap_info_2G;
5080 mac_5G = cap->he_cap_info_5G;
5081 qdf_mem_copy(phy_2G, cap->he_cap_phy_info_2G,
5082 WMI_MAX_HECAP_PHY_SIZE * 4);
5083 qdf_mem_copy(phy_5G, cap->he_cap_phy_info_5G,
5084 WMI_MAX_HECAP_PHY_SIZE * 4);
5085 ppet_2G = cap->he_ppet2G;
5086 ppet_5G = cap->he_ppet5G;
5087
5088 wma_print_he_mac_cap(mac_2G);
5089 wma_print_he_phy_cap(phy_2G);
5090 wma_print_he_ppet(&ppet_2G);
5091 wma_print_he_mac_cap(mac_5G);
5092 wma_print_he_phy_cap(phy_5G);
5093 wma_print_he_ppet(&ppet_5G);
5094}
Krunal Soni0193b6f2016-08-15 15:53:43 -07005095
5096/**
Krunal Soni2e48d012016-05-02 16:55:26 -07005097 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
5098 * @wma_handle: pointer to wma_handle
5099 *
5100 * This function prints all the caps populater per hw mode and per PHY
5101 *
5102 * Return: none
5103 */
5104static void wma_print_populate_soc_caps(t_wma_handle *wma_handle)
5105{
5106 int i, j = 0, max_mac;
5107 WMI_MAC_PHY_CAPABILITIES *tmp;
5108
5109 /* print number of hw modes */
5110 WMA_LOGI("%s: num of hw modes [%d]", __func__,
5111 wma_handle->phy_caps.num_hw_modes.num_hw_modes);
5112 WMA_LOGI("%s: <====== HW mode cap printing starts ======>", __func__);
5113 /* print cap of each hw mode */
5114 for (i = 0; i < wma_handle->phy_caps.num_hw_modes.num_hw_modes; i++) {
5115 WMA_LOGI("====>: hw mode id[%d], phy_id map[%d]",
5116 wma_handle->phy_caps.each_hw_mode_cap[i].hw_mode_id,
5117 wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map);
5118 if (wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map ==
5119 PHY1_PHY2)
5120 max_mac = j + 2;
5121 else
5122 max_mac = j + 1;
5123
5124 for ( ; j < max_mac; j++) {
5125 tmp = &wma_handle->phy_caps.each_phy_cap_per_hwmode[j];
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005126 wma_print_mac_phy_capabilities(tmp, j);
Krunal Soni2e48d012016-05-02 16:55:26 -07005127 }
5128 }
5129 WMA_LOGI("%s: <====== HW mode cap printing ends ======>\n", __func__);
5130}
5131
5132/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305133 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
5134 * in terms of hw_mode_bandwidth
5135 * @width: bandwidth in terms of wmi_channel_width
5136 *
5137 * This function returns the bandwidth in terms of hw_mode_bandwidth.
5138 *
5139 * Return: BW in terms of hw_mode_bandwidth.
5140 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005141static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305142 wmi_channel_width width)
5143{
5144 switch (width) {
5145 case WMI_CHAN_WIDTH_20:
5146 return HW_MODE_20_MHZ;
5147 case WMI_CHAN_WIDTH_40:
5148 return HW_MODE_40_MHZ;
5149 case WMI_CHAN_WIDTH_80:
5150 return HW_MODE_80_MHZ;
5151 case WMI_CHAN_WIDTH_160:
5152 return HW_MODE_160_MHZ;
5153 case WMI_CHAN_WIDTH_80P80:
5154 return HW_MODE_80_PLUS_80_MHZ;
5155 case WMI_CHAN_WIDTH_5:
5156 return HW_MODE_5_MHZ;
5157 case WMI_CHAN_WIDTH_10:
5158 return HW_MODE_10_MHZ;
5159 default:
5160 return HW_MODE_BW_NONE;
5161 }
5162
5163 return HW_MODE_BW_NONE;
5164}
5165
5166/**
5167 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
5168 * supported from the capabilities.
5169 * @caps: PHY capability
5170 * @info: param to store TX-RX stream and BW information
5171 *
5172 * This function will calculate TX-RX stream and bandwidth supported
5173 * as per the PHY capability, and assign to mac_ss_bw_info.
5174 *
5175 * Return: none
5176 */
5177static void wma_get_hw_mode_params(WMI_MAC_PHY_CAPABILITIES *caps,
5178 struct mac_ss_bw_info *info)
5179{
5180 if (!caps) {
5181 WMA_LOGE("%s: Invalid capabilities", __func__);
5182 return;
5183 }
5184
5185 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
5186 QDF_MAX(caps->tx_chain_mask_2G,
5187 caps->tx_chain_mask_5G));
5188 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
5189 QDF_MAX(caps->rx_chain_mask_2G,
5190 caps->rx_chain_mask_5G));
5191 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
5192 QDF_MAX(caps->max_bw_supported_2G,
5193 caps->max_bw_supported_5G));
5194}
5195
5196/**
5197 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
5198 * DBS in hw_mode_list
5199 * @wma_handle: pointer to wma global structure
5200 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
5201 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
5202 * @pos: refers to hw_mode_index
5203 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305204 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305205 *
5206 * This function sets TX-RX stream, bandwidth and DBS mode in
5207 * hw_mode_list.
5208 *
5209 * Return: none
5210 */
5211static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
5212 struct mac_ss_bw_info mac0_ss_bw_info,
5213 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305214 uint32_t pos, uint32_t dbs_mode,
5215 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305216{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305217 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305218 wma_handle->hw_mode.hw_mode_list[pos],
5219 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305220 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305221 wma_handle->hw_mode.hw_mode_list[pos],
5222 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305223 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305224 wma_handle->hw_mode.hw_mode_list[pos],
5225 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305226 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305227 wma_handle->hw_mode.hw_mode_list[pos],
5228 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305229 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305230 wma_handle->hw_mode.hw_mode_list[pos],
5231 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305232 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305233 wma_handle->hw_mode.hw_mode_list[pos],
5234 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305235 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305236 wma_handle->hw_mode.hw_mode_list[pos],
5237 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305238 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305239 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305240 HW_MODE_AGILE_DFS_NONE);
5241 WMA_HW_MODE_SBS_MODE_SET(
5242 wma_handle->hw_mode.hw_mode_list[pos],
5243 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305244}
5245
5246/**
5247 * wma_update_hw_mode_list() - updates hw_mode_list
5248 * @wma_handle: pointer to wma global structure
5249 *
5250 * This function updates hw_mode_list with tx_streams, rx_streams,
5251 * bandwidth, dbs and agile dfs for each hw_mode.
5252 *
5253 * Returns: 0 for success else failure.
5254 */
5255static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle)
5256{
5257 struct extended_caps *phy_caps;
5258 WMI_MAC_PHY_CAPABILITIES *tmp;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305259 uint32_t i, hw_config_type, j = 0;
5260 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305261 struct mac_ss_bw_info mac0_ss_bw_info = {0};
5262 struct mac_ss_bw_info mac1_ss_bw_info = {0};
5263
5264 if (!wma_handle) {
5265 WMA_LOGE("%s: Invalid wma handle", __func__);
5266 return QDF_STATUS_E_FAILURE;
5267 }
5268
5269 phy_caps = &wma_handle->phy_caps;
5270 if (!phy_caps) {
5271 WMA_LOGE("%s: Invalid phy capabilities", __func__);
5272 return QDF_STATUS_SUCCESS;
5273 }
5274
5275 if (!phy_caps->num_hw_modes.num_hw_modes) {
5276 WMA_LOGE("%s: Number of HW modes: %d",
5277 __func__, phy_caps->num_hw_modes.num_hw_modes);
5278 return QDF_STATUS_SUCCESS;
5279 }
5280
5281 /*
5282 * This list was updated as part of service ready event. Re-populate
5283 * HW mode list from the device capabilities.
5284 */
5285 if (wma_handle->hw_mode.hw_mode_list) {
5286 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
5287 wma_handle->hw_mode.hw_mode_list = NULL;
5288 WMA_LOGI("%s: DBS list is freed", __func__);
5289 }
5290
5291 wma_handle->num_dbs_hw_modes = phy_caps->num_hw_modes.num_hw_modes;
5292 wma_handle->hw_mode.hw_mode_list =
5293 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
5294 wma_handle->num_dbs_hw_modes);
5295 if (!wma_handle->hw_mode.hw_mode_list) {
5296 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
5297 return QDF_STATUS_E_FAILURE;
5298 }
5299
5300 WMA_LOGA("%s: Updated HW mode list: Num modes:%d",
5301 __func__, wma_handle->num_dbs_hw_modes);
5302
5303 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5304 /* Update for MAC0 */
5305 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5306 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
5307 hw_config_type =
5308 phy_caps->each_hw_mode_cap[i].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305309 dbs_mode = HW_MODE_DBS_NONE;
5310 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305311 mac1_ss_bw_info.mac_tx_stream = 0;
5312 mac1_ss_bw_info.mac_rx_stream = 0;
5313 mac1_ss_bw_info.mac_bw = 0;
5314
5315 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
5316 if ((hw_config_type == WMI_HW_MODE_DBS) ||
5317 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5318 (hw_config_type == WMI_HW_MODE_SBS)) {
5319 /* Update for MAC1 */
5320 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5321 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305322 if (hw_config_type == WMI_HW_MODE_DBS)
5323 dbs_mode = HW_MODE_DBS;
5324 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5325 (hw_config_type == WMI_HW_MODE_SBS))
5326 sbs_mode = HW_MODE_SBS;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305327 }
5328
5329 /* Updating HW mode list */
5330 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305331 mac1_ss_bw_info, i, dbs_mode,
5332 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305333 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005334
5335 if (QDF_STATUS_SUCCESS !=
5336 policy_mgr_update_hw_mode_list(wma_handle->psoc, phy_caps))
5337 WMA_LOGE("%s: failed to update policy manager", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305338 wma_dump_dbs_hw_mode(wma_handle);
5339 return QDF_STATUS_SUCCESS;
5340}
5341
5342/**
Krunal Soni2e48d012016-05-02 16:55:26 -07005343 * wma_populate_soc_caps() - populate entire SOC's capabilities
5344 * @wma_handle: pointer to wma global structure
5345 * @param_buf: pointer to param of service ready extension event from fw
5346 *
5347 * This API populates all capabilities of entire SOC. For example,
5348 * how many number of hw modes are supported by this SOC, what are the
5349 * capabilities of each phy per hw mode, what are HAL reg capabilities per
5350 * phy.
5351 *
5352 * Return: none
5353 */
5354static void wma_populate_soc_caps(t_wma_handle *wma_handle,
5355 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
5356{
5357 int i, num_of_mac_caps = 0, tmp = 0;
5358 struct extended_caps *phy_caps;
5359 struct hw_mode_idx_to_mac_cap_idx *map;
5360
5361 WMA_LOGD("%s: Enter", __func__);
5362
5363 if (!wma_handle) {
5364 WMA_LOGP("%s: Invalid WMA handle", __func__);
5365 return;
5366 }
5367
5368 if (!param_buf) {
5369 WMA_LOGP("%s: Invalid event", __func__);
5370 return;
5371 }
5372 phy_caps = &wma_handle->phy_caps;
5373
5374 /*
5375 * first thing to do is to get how many number of hw modes are
5376 * supported and populate in wma_handle global structure
5377 */
Krunal Sonifd85ba62016-07-11 08:18:53 -07005378 if (NULL == param_buf->soc_hw_mode_caps) {
5379 WMA_LOGE("%s: Invalid number of hw modes", __func__);
5380 return;
5381 }
5382
Krunal Soni2e48d012016-05-02 16:55:26 -07005383 qdf_mem_copy(&phy_caps->num_hw_modes,
5384 param_buf->soc_hw_mode_caps,
5385 sizeof(WMI_SOC_MAC_PHY_HW_MODE_CAPS));
5386 if (0 == phy_caps->num_hw_modes.num_hw_modes) {
Krunal Sonifd85ba62016-07-11 08:18:53 -07005387 WMA_LOGE("%s: Number of hw modes is zero", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005388 return;
Krunal Soni2e48d012016-05-02 16:55:26 -07005389 }
Krunal Sonifd85ba62016-07-11 08:18:53 -07005390 WMA_LOGI("%s: Given number of hw modes[%d]",
5391 __func__, phy_caps->num_hw_modes.num_hw_modes);
Krunal Soni2e48d012016-05-02 16:55:26 -07005392
5393 /*
5394 * next thing is to allocate the memory to map hw mode to phy/mac caps
5395 */
5396 phy_caps->hw_mode_to_mac_cap_map =
5397 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5398 sizeof(struct hw_mode_idx_to_mac_cap_idx));
5399 if (!phy_caps->hw_mode_to_mac_cap_map) {
5400 WMA_LOGE("%s: Memory allocation failed", __func__);
5401 return;
5402 }
5403
5404 /*
5405 * next thing is to allocate the memory for per hw caps
5406 */
5407 phy_caps->each_hw_mode_cap =
5408 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5409 sizeof(WMI_HW_MODE_CAPABILITIES));
5410 if (!phy_caps->each_hw_mode_cap) {
5411 WMA_LOGE("%s: Memory allocation failed", __func__);
5412 wma_cleanup_dbs_phy_caps(wma_handle);
5413 return;
5414 }
5415 qdf_mem_copy(phy_caps->each_hw_mode_cap,
5416 param_buf->hw_mode_caps,
5417 phy_caps->num_hw_modes.num_hw_modes *
5418 sizeof(WMI_HW_MODE_CAPABILITIES));
5419 /*
5420 * next thing is to count the number of mac cap to populate per
5421 * hw mode and generate map, so that our search can be done
5422 * efficiently which is O(1)
5423 */
5424 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
5425 map = &phy_caps->hw_mode_to_mac_cap_map[i];
5426 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2) {
5427 tmp = num_of_mac_caps;
5428 num_of_mac_caps = num_of_mac_caps + 2;
5429 map->num_of_macs = 2;
5430 } else {
5431 tmp = num_of_mac_caps;
5432 num_of_mac_caps = num_of_mac_caps + 1;
5433 map->num_of_macs = 1;
5434 }
5435 map->mac_cap_idx = tmp;
5436 map->hw_mode_id = phy_caps->each_hw_mode_cap[i].hw_mode_id;
5437 }
5438
5439 /*
5440 * next thing is to populate each phy caps per hw mode
5441 */
5442 phy_caps->each_phy_cap_per_hwmode =
5443 qdf_mem_malloc(num_of_mac_caps *
5444 sizeof(WMI_MAC_PHY_CAPABILITIES));
5445 if (!phy_caps->each_phy_cap_per_hwmode) {
5446 WMA_LOGE("%s: Memory allocation failed", __func__);
5447 wma_cleanup_dbs_phy_caps(wma_handle);
5448 return;
5449 }
5450 qdf_mem_copy(phy_caps->each_phy_cap_per_hwmode,
5451 param_buf->mac_phy_caps,
5452 num_of_mac_caps * sizeof(WMI_MAC_PHY_CAPABILITIES));
5453
5454 /*
5455 * next thing is to populate reg caps per phy
5456 */
5457 qdf_mem_copy(&phy_caps->num_phy_for_hal_reg_cap,
5458 param_buf->soc_hal_reg_caps,
5459 sizeof(WMI_SOC_HAL_REG_CAPABILITIES));
5460 if (phy_caps->num_phy_for_hal_reg_cap.num_phy == 0) {
5461 WMA_LOGE("%s: incorrect number of phys", __func__);
5462 wma_cleanup_dbs_phy_caps(wma_handle);
5463 return;
5464 }
5465 phy_caps->each_phy_hal_reg_cap =
5466 qdf_mem_malloc(phy_caps->num_phy_for_hal_reg_cap.num_phy *
5467 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
5468 if (!phy_caps->each_phy_hal_reg_cap) {
5469 WMA_LOGE("%s: Memory allocation failed", __func__);
5470 wma_cleanup_dbs_phy_caps(wma_handle);
5471 return;
5472 }
5473 qdf_mem_copy(phy_caps->each_phy_hal_reg_cap,
5474 param_buf->hal_reg_caps,
5475 phy_caps->num_phy_for_hal_reg_cap.num_phy *
5476 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
5477 wma_print_populate_soc_caps(wma_handle);
5478 return;
5479}
5480
5481/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005482 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
5483 * @handle: wma handle
5484 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05305485 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 *
5487 * Return: none
5488 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305489int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
5490 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491{
5492 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5493 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
5494 wmi_service_ready_ext_event_fixed_param *ev;
5495 int status;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305496 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497
5498 WMA_LOGD("%s: Enter", __func__);
5499
5500 if (!wma_handle) {
5501 WMA_LOGP("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305502 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503 }
5504
5505 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
5506 if (!param_buf) {
5507 WMA_LOGP("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305508 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509 }
5510
5511 ev = param_buf->fixed_param;
5512 if (!ev) {
5513 WMA_LOGP("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305514 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 }
5516
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005517 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005519 WMA_LOGD("%s: Defaults: scan config:%x FW mode config:%x",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305520 __func__, ev->default_conc_scan_config_bits,
5521 ev->default_fw_config_bits);
5522
Anurag Chouhan210db072016-02-22 18:42:15 +05305523 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305524 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305525 WMA_LOGP("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05305526 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 }
Krunal Soni2e48d012016-05-02 16:55:26 -07005528 wma_populate_soc_caps(wma_handle, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305530 ret = wma_update_hw_mode_list(wma_handle);
5531 if (QDF_IS_STATUS_ERROR(ret)) {
5532 WMA_LOGE("Failed to update hw mode list");
5533 return -EINVAL;
5534 }
5535
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005536 WMA_LOGD("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05305537 status = wmi_unified_send_saved_init_cmd(wma_handle->wmi_handle);
5538 if (status != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 /* In success case, WMI layer will free after getting copy
5540 * engine TX complete interrupt
5541 */
5542 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305544 wma_init_scan_fw_mode_config(wma_handle,
5545 ev->default_conc_scan_config_bits,
5546 ev->default_fw_config_bits);
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07005547 wma_handle->target_fw_vers_ext = ev->fw_build_vers_ext;
Govind Singhd76a5b02016-03-08 15:12:14 +05305548 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549}
5550
5551/**
5552 * wma_rx_ready_event() - event handler to process
5553 * wmi rx ready event.
5554 * @handle: wma handle
5555 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05305556 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557 *
5558 * Return: none
5559 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305560int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
5561 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005562{
5563 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5564 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
5565 wmi_ready_event_fixed_param *ev = NULL;
5566
5567 WMA_LOGD("%s: Enter", __func__);
5568
5569 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
5570 if (!(wma_handle && param_buf)) {
5571 WMA_LOGP("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305572 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05305573 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 }
5575
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005576 WMA_LOGD("WMA <-- WMI_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005577
5578 ev = param_buf->fixed_param;
5579 /* Indicate to the waiting thread that the ready
5580 * event was received */
Naveen Rawat64e477e2016-05-20 10:34:56 -07005581 wma_handle->sub_20_support =
5582 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5583 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 wma_handle->wmi_ready = true;
5585 wma_handle->wlan_init_status = ev->status;
5586
5587 /*
5588 * We need to check the WMI versions and make sure both
5589 * host and fw are compatible.
5590 */
5591 if (!wmi_versions_are_compatible(&wma_handle->final_abi_vers,
5592 &ev->fw_abi_vers)) {
5593 /*
5594 * Error: Our host version and the given firmware version
5595 * are incompatible.
5596 */
5597 WMA_LOGE("%s: Error: Incompatible WMI version."
5598 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x",
5599 __func__,
5600 WMI_VER_GET_MAJOR(wma_handle->final_abi_vers.
5601 abi_version_0),
5602 WMI_VER_GET_MINOR(wma_handle->final_abi_vers.
5603 abi_version_0),
5604 wma_handle->final_abi_vers.abi_version_ns_0,
5605 wma_handle->final_abi_vers.abi_version_ns_1,
5606 wma_handle->final_abi_vers.abi_version_ns_2,
5607 wma_handle->final_abi_vers.abi_version_ns_3,
5608 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
5609 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
5610 ev->fw_abi_vers.abi_version_ns_0,
5611 ev->fw_abi_vers.abi_version_ns_1,
5612 ev->fw_abi_vers.abi_version_ns_2,
5613 ev->fw_abi_vers.abi_version_ns_3);
5614 if (wma_handle->wlan_init_status == WLAN_INIT_STATUS_SUCCESS) {
5615 /* Failed this connection to FW */
5616 wma_handle->wlan_init_status =
5617 WLAN_INIT_STATUS_GEN_FAILED;
5618 }
5619 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305620 qdf_mem_copy(&wma_handle->final_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 sizeof(wmi_abi_version));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305622 qdf_mem_copy(&wma_handle->target_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 sizeof(wmi_abi_version));
5624
5625 /* copy the mac addr */
5626 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
5627 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
5628
5629 wma_update_hdd_cfg(wma_handle);
5630
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305631 qdf_event_set(&wma_handle->wma_ready_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632
5633 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05305634
5635 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636}
5637
5638/**
5639 * wma_setneedshutdown() - setting wma needshutdown flag
5640 * @cds_ctx: cds context
5641 *
5642 * Return: none
5643 */
5644void wma_setneedshutdown(void *cds_ctx)
5645{
5646 tp_wma_handle wma_handle;
5647
5648 WMA_LOGD("%s: Enter", __func__);
5649
Anurag Chouhan6d760662016-02-20 16:05:43 +05305650 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651
5652 if (NULL == wma_handle) {
5653 WMA_LOGP("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305654 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655 return;
5656 }
5657
5658 wma_handle->needShutdown = true;
5659 WMA_LOGD("%s: Exit", __func__);
5660}
5661
5662/**
5663 * wma_needshutdown() - Is wma needs shutdown?
5664 * @cds_ctx: cds context
5665 *
5666 * Return: returns true/false
5667 */
5668bool wma_needshutdown(void *cds_ctx)
5669{
5670 tp_wma_handle wma_handle;
5671
5672 WMA_LOGD("%s: Enter", __func__);
5673
Anurag Chouhan6d760662016-02-20 16:05:43 +05305674 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675
5676 if (NULL == wma_handle) {
5677 WMA_LOGP("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305678 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679 return false;
5680 }
5681
5682 WMA_LOGD("%s: Exit", __func__);
5683 return wma_handle->needShutdown;
5684}
5685
5686/**
5687 * wma_wait_for_ready_event() - wait for wma ready event
5688 * @handle: wma handle
5689 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305690 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305692QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693{
5694 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305695 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696
5697 /* wait until WMI_READY_EVENTID received from FW */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305698 qdf_status = qdf_wait_single_event(&(wma_handle->wma_ready_event),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 WMA_READY_EVENTID_TIMEOUT);
5700
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305701 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 WMA_LOGP("%s: Timeout waiting for ready event from FW",
5703 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305704 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005705 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305706 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707}
5708
5709/**
5710 * wma_set_ppsconfig() - set pps config in fw
5711 * @vdev_id: vdev id
5712 * @pps_param: pps params
5713 * @val : param value
5714 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305715 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305717QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718 int val)
5719{
Anurag Chouhan6d760662016-02-20 16:05:43 +05305720 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721 int ret = -EIO;
5722 uint32_t pps_val;
5723
5724 if (NULL == wma) {
5725 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305726 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727 }
5728
5729 switch (pps_param) {
5730 case WMA_VHT_PPS_PAID_MATCH:
5731 pps_val = ((val << 31) & 0xffff0000) |
5732 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
5733 goto pkt_pwr_save_config;
5734 case WMA_VHT_PPS_GID_MATCH:
5735 pps_val = ((val << 31) & 0xffff0000) |
5736 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
5737 goto pkt_pwr_save_config;
5738 case WMA_VHT_PPS_DELIM_CRC_FAIL:
5739 pps_val = ((val << 31) & 0xffff0000) |
5740 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
5741 goto pkt_pwr_save_config;
5742
5743 /* Enable the code below as and when the functionality
5744 * is supported/added in host.
5745 */
5746#ifdef NOT_YET
5747 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
5748 pps_val = ((val << 31) & 0xffff0000) |
5749 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
5750 goto pkt_pwr_save_config;
5751 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
5752 pps_val = ((val << 31) & 0xffff0000) |
5753 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
5754 goto pkt_pwr_save_config;
5755 case WMA_VHT_PPS_EOF_PAD_DELIM:
5756 pps_val = ((val << 31) & 0xffff0000) |
5757 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
5758 goto pkt_pwr_save_config;
5759 case WMA_VHT_PPS_MACADDR_MISMATCH:
5760 pps_val = ((val << 31) & 0xffff0000) |
5761 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
5762 goto pkt_pwr_save_config;
5763 case WMA_VHT_PPS_GID_NSTS_ZERO:
5764 pps_val = ((val << 31) & 0xffff0000) |
5765 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
5766 goto pkt_pwr_save_config;
5767 case WMA_VHT_PPS_RSSI_CHECK:
5768 pps_val = ((val << 31) & 0xffff0000) |
5769 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
5770 goto pkt_pwr_save_config;
5771#endif /* NOT_YET */
5772pkt_pwr_save_config:
5773 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
5774 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05305775 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776 WMI_VDEV_PARAM_PACKET_POWERSAVE,
5777 pps_val);
5778 break;
5779 default:
5780 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
5781 }
5782
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305783 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784}
5785
5786/**
5787 * wma_process_set_mas() - Function to enable/disable MAS
5788 * @wma: Pointer to WMA handle
5789 * @mas_val: 1-Enable MAS, 0-Disable MAS
5790 *
5791 * This function enables/disables the MAS value
5792 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305793 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005795static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
5796 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005797{
5798 uint32_t val;
5799
5800 if (NULL == wma || NULL == mas_val) {
5801 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305802 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005803 }
5804
5805 val = (*mas_val);
5806
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305807 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
5809 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305810 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811 } else {
5812 WMA_LOGE("%s: Value is %d", __func__, val);
5813 }
5814
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305815 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005816}
5817
5818/**
5819 * wma_process_set_miracast() - Function to set miracast value in WMA
5820 * @wma: Pointer to WMA handle
5821 * @miracast_val: 0-Disabled,1-Source,2-Sink
5822 *
5823 * This function stores the miracast value in WMA
5824 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305825 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005826 *
5827 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005828static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
5829 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005830{
5831 if (NULL == wma || NULL == miracast_val) {
5832 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305833 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834 }
5835
5836 wma->miracast_value = *miracast_val;
5837 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
5838
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305839 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005840}
5841
5842/**
5843 * wma_config_stats_factor() - Function to configure stats avg. factor
5844 * @wma: pointer to WMA handle
5845 * @avg_factor: stats. avg. factor passed down by userspace
5846 *
5847 * This function configures the avg. stats value in firmware
5848 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305849 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 *
5851 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305852static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853 struct sir_stats_avg_factor *avg_factor)
5854{
Govind Singhd76a5b02016-03-08 15:12:14 +05305855 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856
5857 if (NULL == wma || NULL == avg_factor) {
5858 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305859 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860 }
5861
Govind Singhd76a5b02016-03-08 15:12:14 +05305862 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863 avg_factor->vdev_id,
5864 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
5865 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05305866 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
5868 avg_factor->vdev_id);
5869 }
5870
5871 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
5872 avg_factor->stats_avg_factor, avg_factor->vdev_id);
5873
5874 return ret;
5875}
5876
5877/**
5878 * wma_config_guard_time() - Function to set guard time in firmware
5879 * @wma: pointer to WMA handle
5880 * @guard_time: guard time passed down by userspace
5881 *
5882 * This function configures the guard time in firmware
5883 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305884 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885 *
5886 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305887static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888 struct sir_guard_time_request *guard_time)
5889{
Govind Singhd76a5b02016-03-08 15:12:14 +05305890 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891
5892 if (NULL == wma || NULL == guard_time) {
5893 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305894 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895 }
5896
Govind Singhd76a5b02016-03-08 15:12:14 +05305897 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898 guard_time->vdev_id,
5899 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
5900 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05305901 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 WMA_LOGE(" failed to set guard time for vdev_id %d",
5903 guard_time->vdev_id);
5904 }
5905
5906 WMA_LOGD("Set guard time %d for vdev_id %d",
5907 guard_time->guard_time, guard_time->vdev_id);
5908
5909 return ret;
5910}
5911
5912/**
5913 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
5914 * @wma_handle: WMA handle
5915 * @start_log: Start logging related parameters
5916 *
5917 * Send the command to the FW based on which specific logging of diag
5918 * event/log id can be started/stopped
5919 *
5920 * Return: None
5921 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005922static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
5923 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005924{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005925
5926 if (!start_log) {
5927 WMA_LOGE("%s: start_log pointer is NULL", __func__);
5928 return;
5929 }
5930 if (!wma_handle) {
5931 WMA_LOGE("%s: Invalid wma handle", __func__);
5932 return;
5933 }
5934
5935 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
5936 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
5937 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
5938 __func__, start_log->ring_id);
5939 return;
5940 }
5941
Govind Singhf25a0f12016-03-08 16:09:48 +05305942 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
5943 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945 return;
5946}
5947
Poddar, Siddarth176c4362016-10-03 12:25:00 +05305948#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949/**
5950 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
5951 * @wma_handle: WMA handle
5952 * @start_log: Struture containing the start wifi logger params
5953 *
5954 * This function is used to send the WMA commands to start/stop logging
5955 * of per packet statistics
5956 *
5957 * Return: None
5958 *
5959 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005960#ifdef REMOVE_PKT_LOG
5961static void wma_set_wifi_start_packet_stats(void *wma_handle,
5962 struct sir_wifi_start_log *start_log)
5963{
5964 return;
5965}
5966#else
5967static void wma_set_wifi_start_packet_stats(void *wma_handle,
5968 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005969{
Komal Seelam3d202862016-02-24 18:43:24 +05305970 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005971 uint32_t log_state;
5972
5973 if (!start_log) {
5974 WMA_LOGE("%s: start_log pointer is NULL", __func__);
5975 return;
5976 }
5977 if (!wma_handle) {
5978 WMA_LOGE("%s: Invalid wma handle", __func__);
5979 return;
5980 }
5981
5982 /* No need to register for ring IDs other than packet stats */
5983 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
5984 WMA_LOGI("%s: Ring id is not for per packet stats: %d",
5985 __func__, start_log->ring_id);
5986 return;
5987 }
5988
Anurag Chouhan6d760662016-02-20 16:05:43 +05305989 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07005990 if (scn == NULL) {
5991 WMA_LOGE("%s: Invalid HIF handle", __func__);
5992 return;
5993 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994
5995 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05305996 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
5997 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005998
Poddar, Siddarth176c4362016-10-03 12:25:00 +05305999 if (start_log->size != 0) {
6000 pktlog_setsize(scn, start_log->size * MEGABYTE);
6001 return;
Poddar, Siddarthab99a272017-04-10 12:53:26 +05306002 } else if (start_log->is_pktlog_buff_clear == true) {
6003 pktlog_clearbuff(scn, start_log->is_pktlog_buff_clear);
6004 return;
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306005 }
6006
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006008 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306009 start_log->user_triggered,
6010 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006011 WMA_LOGD("%s: Enabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006013 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306014 start_log->user_triggered,
6015 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006016 WMA_LOGD("%s: Disabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 }
6018}
6019#endif
6020
6021/**
6022 * wma_send_flush_logs_to_fw() - Send log flush command to FW
6023 * @wma_handle: WMI handle
6024 *
6025 * This function is used to send the flush command to the FW,
6026 * that will flush the fw logs that are residue in the FW
6027 *
6028 * Return: None
6029 */
6030void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
6031{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306032 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033 int ret;
6034
Govind Singhf25a0f12016-03-08 16:09:48 +05306035 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
6036 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006038
Anurag Chouhan210db072016-02-22 18:42:15 +05306039 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306041 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006042 WMA_LOGE("Failed to start the log completion timer");
6043}
6044
6045/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306046 * wma_update_wep_default_key - To update default key id
6047 * @wma: pointer to wma handler
6048 * @update_def_key: pointer to wep_update_default_key_idx
6049 *
6050 * This function makes a copy of default key index to txrx node
6051 *
6052 * Return: Success
6053 */
6054static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
6055 struct wep_update_default_key_idx *update_def_key)
6056{
6057 struct wma_txrx_node *iface =
6058 &wma->interfaces[update_def_key->session_id];
6059 iface->wep_default_key_idx = update_def_key->default_idx;
6060
6061 return QDF_STATUS_SUCCESS;
6062}
6063
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05306064/**
6065 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
6066 * @wma_handle: WMA handle
6067 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
6068 *
6069 * This function is used to set Tx pkt fail count threshold,
6070 * FW will do disconnect with station once this threshold is reached.
6071 *
6072 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6073 */
6074static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
6075 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
6076{
6077 u_int8_t vdev_id;
6078 u_int32_t tx_fail_disconn_th;
6079 int ret = -EIO;
6080
6081 if (!wma || !wma->wmi_handle) {
6082 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
6083 return QDF_STATUS_E_INVAL;
6084 }
6085 vdev_id = tx_fail_cnt_th->session_id;
6086 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
6087 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
6088 vdev_id, tx_fail_disconn_th);
6089
6090
6091 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6092 WMI_VDEV_PARAM_DISCONNECT_TH,
6093 tx_fail_disconn_th);
6094
6095 if (ret) {
6096 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
6097 return QDF_STATUS_E_FAILURE;
6098 }
6099
6100 return QDF_STATUS_SUCCESS;
6101}
6102
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306103/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306104 * wma_update_short_retry_limit() - Set retry limit for short frames
6105 * @wma_handle: WMA handle
6106 * @short_retry_limit_th: retry limir count for Short frames.
6107 *
6108 * This function is used to configure the transmission retry limit at which
6109 * short frames needs to be retry.
6110 *
6111 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6112 */
6113static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
6114 struct sme_short_retry_limit *short_retry_limit_th)
6115{
6116 uint8_t vdev_id;
6117 uint32_t short_retry_limit;
6118 int ret;
6119
6120 if (!wma || !wma->wmi_handle) {
6121 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
6122 return QDF_STATUS_E_INVAL;
6123 }
6124 vdev_id = short_retry_limit_th->session_id;
6125 short_retry_limit = short_retry_limit_th->short_retry_limit;
6126 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
6127 vdev_id, short_retry_limit);
6128
6129 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6130 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
6131 short_retry_limit);
6132
6133 if (ret) {
6134 WMA_LOGE("Failed to send short limit threshold command");
6135 return QDF_STATUS_E_FAILURE;
6136 }
6137 return QDF_STATUS_SUCCESS;
6138}
6139
6140/**
6141 * wma_update_long_retry_limit() - Set retry limit for long frames
6142 * @wma_handle: WMA handle
6143 * @long_retry_limit_th: retry limir count for long frames
6144 *
6145 * This function is used to configure the transmission retry limit at which
6146 * long frames needs to be retry
6147 *
6148 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6149 */
6150static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
6151 struct sme_long_retry_limit *long_retry_limit_th)
6152{
6153 uint8_t vdev_id;
6154 uint32_t long_retry_limit;
6155 int ret;
6156
6157 if (!wma || !wma->wmi_handle) {
6158 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
6159 return QDF_STATUS_E_INVAL;
6160 }
6161 vdev_id = long_retry_limit_th->session_id;
6162 long_retry_limit = long_retry_limit_th->long_retry_limit;
6163 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
6164 vdev_id, long_retry_limit);
6165
6166 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6167 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
6168 long_retry_limit);
6169
6170 if (ret) {
6171 WMA_LOGE("Failed to send long limit threshold command");
6172 return QDF_STATUS_E_FAILURE;
6173 }
6174
6175 return QDF_STATUS_SUCCESS;
6176}
6177
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05306178/*
6179 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
6180 * @wma_handle: WMA handle
6181 * @sta_inactivity_timer: sme_sta_inactivity_timeout
6182 *
6183 * This function is used to set sta_inactivity_timeout.
6184 * If a station does not send anything in sta_inactivity_timeout seconds, an
6185 * empty data frame is sent to it in order to verify whether it is
6186 * still in range. If this frame is not ACKed, the station will be
6187 * disassociated and then deauthenticated.
6188 *
6189 * Return: None
6190 */
6191void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
6192 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
6193{
6194 uint8_t vdev_id;
6195 uint32_t max_unresponsive_time;
6196 uint32_t min_inactive_time, max_inactive_time;
6197
6198 if (!wma || !wma->wmi_handle) {
6199 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
6200 return;
6201 }
6202 vdev_id = sta_inactivity_timer->session_id;
6203 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
6204 max_inactive_time = max_unresponsive_time * TWO_THIRD;
6205 min_inactive_time = max_unresponsive_time - max_inactive_time;
6206
6207 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6208 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
6209 min_inactive_time))
6210 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
6211
6212 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6213 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
6214 max_inactive_time))
6215 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
6216
6217 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6218 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
6219 max_unresponsive_time))
6220 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
6221
6222 WMA_LOGI("%s:vdev_id:%d min_inactive_time: %u max_inactive_time: %u max_unresponsive_time: %u",
6223 __func__, vdev_id,
6224 min_inactive_time, max_inactive_time,
6225 max_unresponsive_time);
6226}
6227
Yingying Tang95409972016-10-20 15:16:15 +08006228#ifdef WLAN_FEATURE_WOW_PULSE
6229
6230
6231#define WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
6232WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMD_fixed_param
6233
6234
6235#define WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
6236WMITLV_TAG_STRUC_wmi_wow_hostwakeup_gpio_pin_pattern_config_cmd_fixed_param
6237
6238/**
6239* wma_send_wow_pulse_cmd() - send wmi cmd of wow pulse cmd
6240* infomation to fw.
6241* @wma_handle: wma handler
6242* @udp_response: wow_pulse_mode pointer
6243*
6244* Return: Return QDF_STATUS
6245*/
6246static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
6247 struct wow_pulse_mode *wow_pulse_cmd)
6248{
6249 QDF_STATUS status = QDF_STATUS_SUCCESS;
6250 wmi_buf_t buf;
6251 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *cmd;
6252 u_int16_t len;
6253
6254 len = sizeof(*cmd);
6255 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6256 if (!buf) {
6257 WMA_LOGE("wmi_buf_alloc failed");
6258 return QDF_STATUS_E_NOMEM;
6259 }
6260
6261 cmd = (WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *)wmi_buf_data(buf);
6262 qdf_mem_zero(cmd, len);
6263
6264 WMITLV_SET_HDR(&cmd->tlv_header,
6265 WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM,
6266 WMITLV_GET_STRUCT_TLVLEN(
6267 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM));
6268
6269 cmd->enable = wow_pulse_cmd->wow_pulse_enable;
6270 cmd->pin = wow_pulse_cmd->wow_pulse_pin;
6271 cmd->interval_low = wow_pulse_cmd->wow_pulse_interval_low;
6272 cmd->interval_high = wow_pulse_cmd->wow_pulse_interval_high;
6273 cmd->repeat_cnt = WMI_WOW_PULSE_REPEAT_CNT;
6274
6275 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6276 WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID)) {
6277 WMA_LOGE("Failed to send send wow pulse");
6278 wmi_buf_free(buf);
6279 status = QDF_STATUS_E_FAILURE;
6280 }
6281
6282 WMA_LOGD("%s: Exit", __func__);
6283 return status;
6284}
6285
6286#undef WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
6287#undef WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
6288#undef WMI_WOW_PULSE_REPEAT_CNT
6289
6290#else
6291static inline QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
6292 struct wow_pulse_mode *wow_pulse_cmd)
6293{
6294 return QDF_STATUS_E_FAILURE;
6295}
6296#endif
6297
6298
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306299/**
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05306300 * wma_process_power_debug_stats_req() - Process the Chip Power stats collect
6301 * request and pass the Power stats request to Fw
6302 * @wma_handle: WMA handle
6303 *
6304 * Return: QDF_STATUS
6305 */
6306#ifdef WLAN_POWER_DEBUGFS
6307static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
6308{
6309 wmi_pdev_get_chip_power_stats_cmd_fixed_param *cmd;
6310 int32_t len;
6311 wmi_buf_t buf;
6312 uint8_t *buf_ptr;
6313 int ret;
6314
6315 if (!wma_handle) {
6316 WMA_LOGE("%s: input pointer is NULL", __func__);
6317 return QDF_STATUS_E_FAILURE;
6318 }
6319
6320 len = sizeof(*cmd);
6321 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6322 if (!buf) {
6323 WMA_LOGE("%s: Failed allocate wmi buffer", __func__);
6324 return QDF_STATUS_E_NOMEM;
6325 }
6326
6327 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6328 cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr;
6329
6330 WMITLV_SET_HDR(&cmd->tlv_header,
6331 WMITLV_TAG_STRUC_wmi_get_chip_power_stats_cmd_fixed_param,
6332 WMITLV_GET_STRUCT_TLVLEN(
6333 wmi_pdev_get_chip_power_stats_cmd_fixed_param));
6334 cmd->pdev_id = 0;
6335
6336 WMA_LOGD("POWER_DEBUG_STATS - Get Request Params; Pdev id - %d",
6337 cmd->pdev_id);
6338 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6339 WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
6340 if (ret) {
6341 WMA_LOGE("%s: Failed to send power debug stats request",
6342 __func__);
6343 wmi_buf_free(buf);
6344 return QDF_STATUS_E_FAILURE;
6345 }
6346 return QDF_STATUS_SUCCESS;
6347}
6348#else
6349static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
6350{
6351 return QDF_STATUS_SUCCESS;
6352}
6353#endif
6354
6355/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006356 * wma_mc_process_msg() - process wma messages and call appropriate function.
6357 * @cds_context: cds context
6358 * @msg: message
6359 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306360 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006361 */
Rajeev Kumarb60abe42017-01-21 15:39:31 -08006362QDF_STATUS wma_mc_process_msg(void *cds_context, struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006363{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306364 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006365 tp_wma_handle wma_handle;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08006366 struct cdp_vdev *txrx_vdev_handle = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006367 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05306368 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006369
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006370 if (NULL == msg) {
6371 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306372 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306373 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006374 goto end;
6375 }
6376
6377 WMA_LOGD("msg->type = %x %s", msg->type,
6378 mac_trace_get_wma_msg_string(msg->type));
6379
Anurag Chouhan6d760662016-02-20 16:05:43 +05306380 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006381
6382 if (NULL == wma_handle) {
6383 WMA_LOGP("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306384 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306385 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306386 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006387 goto end;
6388 }
6389
6390 switch (msg->type) {
6391
6392 /* Message posted by wmi for all control path related
6393 * FW events to serialize through mc_thread.
6394 */
6395 case WMA_PROCESS_FW_EVENT:
6396 wma_process_fw_event(wma_handle,
6397 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306398 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006399 break;
6400
6401#ifdef FEATURE_WLAN_ESE
6402 case WMA_TSM_STATS_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006403 WMA_LOGD("McThread: WMA_TSM_STATS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006404 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
6405 break;
6406#endif /* FEATURE_WLAN_ESE */
6407 case WNI_CFG_DNLD_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006408 WMA_LOGD("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306409 qdf_status = wma_wni_cfg_dnld(wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05306410 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006411 cds_wma_complete_cback(cds_context);
6412 } else {
6413 WMA_LOGD("config download failure");
6414 }
6415 break;
6416 case WMA_ADD_STA_SELF_REQ:
6417 txrx_vdev_handle =
6418 wma_vdev_attach(wma_handle,
6419 (struct add_sta_self_params *) msg->
6420 bodyptr, 1);
6421 if (!txrx_vdev_handle) {
6422 WMA_LOGE("Failed to attach vdev");
6423 } else {
6424 /* Register with TxRx Module for Data Ack Complete Cb */
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05306425 if (soc) {
6426 cdp_data_tx_cb_set(soc, txrx_vdev_handle,
6427 wma_data_tx_ack_comp_hdlr,
6428 wma_handle);
6429 } else {
6430 WMA_LOGE("%s: SOC context is NULL", __func__);
6431 qdf_status = QDF_STATUS_E_FAILURE;
6432 goto end;
6433 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006434 }
6435 break;
6436 case WMA_DEL_STA_SELF_REQ:
6437 wma_vdev_detach(wma_handle,
6438 (struct del_sta_self_params *) msg->bodyptr, 1);
6439 break;
6440 case WMA_START_SCAN_OFFLOAD_REQ:
6441 wma_start_scan(wma_handle, msg->bodyptr, msg->type);
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_STOP_SCAN_OFFLOAD_REQ:
6445 wma_stop_scan(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306446 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006447 break;
6448 case WMA_UPDATE_CHAN_LIST_REQ:
6449 wma_update_channel_list(wma_handle,
6450 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306451 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006452 break;
6453 case WMA_SET_LINK_STATE:
6454 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
6455 break;
6456 case WMA_CHNL_SWITCH_REQ:
6457 wma_set_channel(wma_handle,
6458 (tpSwitchChannelParams) msg->bodyptr);
6459 break;
6460 case WMA_ADD_BSS_REQ:
6461 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
6462 break;
6463 case WMA_ADD_STA_REQ:
6464 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
6465 break;
6466 case WMA_SET_BSSKEY_REQ:
6467 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
6468 break;
6469 case WMA_SET_STAKEY_REQ:
6470 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
6471 break;
6472 case WMA_DELETE_STA_REQ:
6473 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
6474 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07006475 case WMA_DELETE_BSS_HO_FAIL_REQ:
6476 wma_delete_bss_ho_fail(wma_handle,
6477 (tpDeleteBssParams) msg->bodyptr);
6478 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006479 case WMA_DELETE_BSS_REQ:
6480 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
6481 break;
6482 case WMA_UPDATE_EDCA_PROFILE_IND:
6483 wma_process_update_edca_param_req(wma_handle,
6484 (tEdcaParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306485 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 break;
6487 case WMA_SEND_BEACON_REQ:
6488 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306489 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006490 break;
6491 case WMA_SEND_PROBE_RSP_TMPL:
6492 wma_send_probe_rsp_tmpl(wma_handle,
6493 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306494 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006495 break;
6496 case WMA_CLI_SET_CMD:
6497 wma_process_cli_set_cmd(wma_handle,
6498 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306499 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006500 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07006501 case WMA_SET_PDEV_IE_REQ:
6502 wma_process_set_pdev_ie_req(wma_handle,
6503 (struct set_ie_param *)msg->bodyptr);
6504 qdf_mem_free(msg->bodyptr);
6505 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006506#if !defined(REMOVE_PKT_LOG)
6507 case WMA_PKTLOG_ENABLE_REQ:
6508 wma_pktlog_wmi_send_cmd(wma_handle,
6509 (struct ath_pktlog_wmi_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306510 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006511 break;
6512#endif /* REMOVE_PKT_LOG */
6513#if defined(QCA_WIFI_FTM)
6514 case WMA_FTM_CMD_REQ:
6515 wma_process_ftm_command(wma_handle,
6516 (struct ar6k_testmode_cmd_data *)msg->bodyptr);
6517 break;
6518#endif /* QCA_WIFI_FTM */
6519 case WMA_ENTER_PS_REQ:
6520 wma_enable_sta_ps_mode(wma_handle,
6521 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306522 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006523 break;
6524 case WMA_EXIT_PS_REQ:
6525 wma_disable_sta_ps_mode(wma_handle,
6526 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306527 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006528 break;
6529 case WMA_ENABLE_UAPSD_REQ:
6530 wma_enable_uapsd_mode(wma_handle,
6531 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306532 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006533 break;
6534 case WMA_DISABLE_UAPSD_REQ:
6535 wma_disable_uapsd_mode(wma_handle,
6536 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306537 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006538 break;
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -07006539 case WMA_SET_DTIM_PERIOD:
6540 wma_set_dtim_period(wma_handle,
6541 (struct set_dtim_params *)msg->bodyptr);
6542 qdf_mem_free(msg->bodyptr);
6543 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006544 case WMA_SET_TX_POWER_REQ:
6545 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
6546 break;
6547 case WMA_SET_MAX_TX_POWER_REQ:
6548 wma_set_max_tx_power(wma_handle,
6549 (tpMaxTxPowerParams) msg->bodyptr);
6550 break;
6551 case WMA_SET_KEEP_ALIVE:
6552 wma_set_keepalive_req(wma_handle,
6553 (tSirKeepAliveReq *) msg->bodyptr);
6554 break;
6555#ifdef FEATURE_WLAN_SCAN_PNO
6556 case WMA_SET_PNO_REQ:
6557 wma_config_pno(wma_handle, (tpSirPNOScanReq) msg->bodyptr);
6558 break;
6559
6560 case WMA_SME_SCAN_CACHE_UPDATED:
6561 wma_scan_cache_updated_ind(wma_handle, msg->bodyval);
6562 break;
6563#endif /* FEATURE_WLAN_SCAN_PNO */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08006564#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565 case WMA_SET_PLM_REQ:
6566 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
6567 break;
6568#endif
6569 case WMA_GET_STATISTICS_REQ:
6570 wma_get_stats_req(wma_handle,
6571 (tAniGetPEStatsReq *) msg->bodyptr);
6572 break;
6573
6574 case WMA_CONFIG_PARAM_UPDATE_REQ:
Rajeev Kumar156188e2017-01-21 17:23:52 -08006575 wma_update_cfg_params(wma_handle, msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006576 break;
6577
6578 case WMA_UPDATE_OP_MODE:
6579 wma_process_update_opmode(wma_handle,
6580 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306581 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582 break;
6583 case WMA_UPDATE_RX_NSS:
6584 wma_process_update_rx_nss(wma_handle,
6585 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306586 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006587 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006588 case WMA_UPDATE_MEMBERSHIP:
6589 wma_process_update_membership(wma_handle,
6590 (tUpdateMembership *) msg->bodyptr);
6591 break;
6592 case WMA_UPDATE_USERPOS:
6593 wma_process_update_userpos(wma_handle,
6594 (tUpdateUserPos *) msg->bodyptr);
6595 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006596 case WMA_UPDATE_BEACON_IND:
6597 wma_process_update_beacon_params(wma_handle,
6598 (tUpdateBeaconParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306599 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006600 break;
6601
6602 case WMA_ADD_TS_REQ:
6603 wma_add_ts_req(wma_handle, (tAddTsParams *) msg->bodyptr);
6604 break;
6605
6606 case WMA_DEL_TS_REQ:
6607 wma_del_ts_req(wma_handle, (tDelTsParams *) msg->bodyptr);
6608 break;
6609
6610 case WMA_AGGR_QOS_REQ:
6611 wma_aggr_qos_req(wma_handle, (tAggrAddTsParams *) msg->bodyptr);
6612 break;
6613
6614 case WMA_RECEIVE_FILTER_SET_FILTER_REQ:
6615 wma_process_receive_filter_set_filter_req(wma_handle,
6616 (tSirRcvPktFilterCfgType *) 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
6620 case WMA_RECEIVE_FILTER_CLEAR_FILTER_REQ:
6621 wma_process_receive_filter_clear_filter_req(wma_handle,
6622 (tSirRcvFltPktClearParam *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306623 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006624 break;
6625
6626 case WMA_WOW_ADD_PTRN:
6627 wma_wow_add_pattern(wma_handle,
6628 (struct wow_add_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306629 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006630 break;
6631 case WMA_WOW_DEL_PTRN:
6632 wma_wow_delete_user_pattern(wma_handle,
6633 (struct wow_delete_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306634 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006635 break;
6636 case WMA_WOWL_ENTER_REQ:
6637 wma_wow_enter(wma_handle,
6638 (tpSirHalWowlEnterParams) msg->bodyptr);
6639 break;
6640 case WMA_WOWL_EXIT_REQ:
6641 wma_wow_exit(wma_handle, (tpSirHalWowlExitParams) msg->bodyptr);
6642 break;
Houston Hoffmana76591b2015-11-10 16:52:05 -08006643
6644 case WMA_RUNTIME_PM_SUSPEND_IND:
6645 wma_calculate_and_update_conn_state(wma_handle);
Anurag Chouhan6d760662016-02-20 16:05:43 +05306646 wma_suspend_req(wma_handle, QDF_RUNTIME_SUSPEND);
Houston Hoffmana76591b2015-11-10 16:52:05 -08006647 break;
6648
6649 case WMA_RUNTIME_PM_RESUME_IND:
Anurag Chouhan6d760662016-02-20 16:05:43 +05306650 wma_resume_req(wma_handle, QDF_RUNTIME_SUSPEND);
Houston Hoffmana76591b2015-11-10 16:52:05 -08006651 break;
6652
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006653 case WMA_8023_MULTICAST_LIST_REQ:
6654 wma_process_mcbc_set_filter_req(wma_handle,
6655 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306656 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006657 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006658 case WMA_ROAM_SCAN_OFFLOAD_REQ:
6659 /*
6660 * Main entry point or roaming directives from CSR.
6661 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08006662 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006663 (tSirRoamOffloadScanReq *) msg->bodyptr);
6664 break;
6665
6666 case WMA_RATE_UPDATE_IND:
6667 wma_process_rate_update_indicate(wma_handle,
6668 (tSirRateUpdateInd *) msg->bodyptr);
6669 break;
6670
6671#ifdef FEATURE_WLAN_TDLS
6672 case WMA_UPDATE_FW_TDLS_STATE:
6673 wma_update_fw_tdls_state(wma_handle,
6674 (t_wma_tdls_params *) msg->bodyptr);
6675 break;
6676 case WMA_UPDATE_TDLS_PEER_STATE:
6677 wma_update_tdls_peer_state(wma_handle,
6678 (tTdlsPeerStateParams *) msg->bodyptr);
6679 break;
6680 case WMA_TDLS_SET_OFFCHAN_MODE:
6681 wma_set_tdls_offchan_mode(wma_handle,
6682 (tdls_chan_switch_params *)msg->bodyptr);
6683 break;
6684#endif /* FEATURE_WLAN_TDLS */
6685 case WMA_ADD_PERIODIC_TX_PTRN_IND:
6686 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
6687 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306688 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006689 break;
6690 case WMA_DEL_PERIODIC_TX_PTRN_IND:
6691 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
6692 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306693 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006694 break;
6695 case WMA_TX_POWER_LIMIT:
6696 wma_process_tx_power_limits(wma_handle,
6697 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306698 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006699 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700#ifdef FEATURE_WLAN_CH_AVOID
6701 case WMA_CH_AVOID_UPDATE_REQ:
6702 wma_process_ch_avoid_update_req(wma_handle,
6703 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306704 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006705 break;
6706#endif /* FEATURE_WLAN_CH_AVOID */
6707#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
6708 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
6709 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306710 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006711 break;
6712#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
6713 case WMA_DHCP_START_IND:
6714 case WMA_DHCP_STOP_IND:
6715 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) 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
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08006719 case WMA_IBSS_CESIUM_ENABLE_IND:
6720 wma_process_cesium_enable_ind(wma_handle);
6721 break;
6722 case WMA_GET_IBSS_PEER_INFO_REQ:
6723 wma_process_get_peer_info_req(wma_handle,
6724 (tSirIbssGetPeerInfoReqParams *)
6725 msg->bodyptr);
6726 qdf_mem_free(msg->bodyptr);
6727 break;
6728 case WMA_TX_FAIL_MONITOR_IND:
6729 wma_process_tx_fail_monitor_ind(wma_handle,
6730 (tAniTXFailMonitorInd *) msg->bodyptr);
6731 qdf_mem_free(msg->bodyptr);
6732 break;
6733
6734 case WMA_RMC_ENABLE_IND:
6735 wma_process_rmc_enable_ind(wma_handle);
6736 break;
6737 case WMA_RMC_DISABLE_IND:
6738 wma_process_rmc_disable_ind(wma_handle);
6739 break;
6740 case WMA_RMC_ACTION_PERIOD_IND:
6741 wma_process_rmc_action_period_ind(wma_handle);
6742 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006743 case WMA_INIT_THERMAL_INFO_CMD:
6744 wma_process_init_thermal_info(wma_handle,
6745 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306746 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006747 break;
6748
6749 case WMA_SET_THERMAL_LEVEL:
6750 wma_process_set_thermal_level(wma_handle, msg->bodyval);
6751 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05306752#ifdef CONFIG_HL_SUPPORT
6753 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
6754 wma_process_init_bad_peer_tx_ctl_info(
6755 wma_handle,
6756 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
6757 qdf_mem_free(msg->bodyptr);
6758 break;
6759#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006760 case WMA_SET_P2P_GO_NOA_REQ:
6761 wma_process_set_p2pgo_noa_req(wma_handle,
6762 (tP2pPsParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306763 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006764 break;
6765 case WMA_SET_MIMOPS_REQ:
6766 wma_process_set_mimops_req(wma_handle,
6767 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306768 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006769 break;
6770 case WMA_SET_SAP_INTRABSS_DIS:
6771 wma_set_vdev_intrabss_fwd(wma_handle,
6772 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306773 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006774 break;
6775 case WMA_GET_LINK_SPEED:
6776 wma_get_link_speed(wma_handle, 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_MODEM_POWER_STATE_IND:
6780 wma_notify_modem_power_state(wma_handle,
6781 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306782 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006783 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006784#ifdef WLAN_FEATURE_STATS_EXT
6785 case WMA_STATS_EXT_REQUEST:
6786 wma_stats_ext_req(wma_handle,
6787 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306788 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006789 break;
6790#endif /* WLAN_FEATURE_STATS_EXT */
6791 case WMA_HIDDEN_SSID_VDEV_RESTART:
6792 wma_hidden_ssid_vdev_restart(wma_handle,
6793 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306794 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006795 break;
6796#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
6797 case WMA_WLAN_EXT_WOW:
6798 wma_enable_ext_wow(wma_handle,
6799 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306800 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006801 break;
6802 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
6803 wma_set_app_type1_params_in_fw(wma_handle,
6804 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306805 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006806 break;
6807 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
6808 wma_set_app_type2_params_in_fw(wma_handle,
6809 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306810 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006811 break;
6812#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
6813#ifdef FEATURE_WLAN_EXTSCAN
6814 case WMA_EXTSCAN_START_REQ:
6815 wma_start_extscan(wma_handle,
6816 (tSirWifiScanCmdReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306817 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006818 break;
6819 case WMA_EXTSCAN_STOP_REQ:
6820 wma_stop_extscan(wma_handle,
6821 (tSirExtScanStopReqParams *) 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_EXTSCAN_SET_BSSID_HOTLIST_REQ:
6825 wma_extscan_start_hotlist_monitor(wma_handle,
6826 (tSirExtScanSetBssidHotListReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306827 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006828 break;
6829 case WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
6830 wma_extscan_stop_hotlist_monitor(wma_handle,
6831 (tSirExtScanResetBssidHotlistReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306832 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833 break;
6834 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
6835 wma_extscan_start_change_monitor(wma_handle,
6836 (tSirExtScanSetSigChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306837 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006838 break;
6839 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
6840 wma_extscan_stop_change_monitor(wma_handle,
6841 (tSirExtScanResetSignificantChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306842 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006843 break;
6844 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
6845 wma_extscan_get_cached_results(wma_handle,
6846 (tSirExtScanGetCachedResultsReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306847 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006848 break;
6849 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
6850 wma_extscan_get_capabilities(wma_handle,
6851 (tSirGetExtScanCapabilitiesReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306852 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006853 break;
6854 case WMA_SET_EPNO_LIST_REQ:
6855 wma_set_epno_network_list(wma_handle,
6856 (struct wifi_epno_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306857 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006858 break;
Kapil Gupta5cda2252016-12-29 18:44:26 +05306859 case WMA_SET_PER_ROAM_CONFIG_CMD:
6860 wma_update_per_roam_config(wma_handle,
6861 (struct wmi_per_roam_config_req *)msg->bodyptr);
6862 qdf_mem_free(msg->bodyptr);
6863 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006864 case WMA_SET_PASSPOINT_LIST_REQ:
6865 /* Issue reset passpoint network list first and clear
6866 * the entries */
6867 wma_reset_passpoint_network_list(wma_handle,
6868 (struct wifi_passpoint_req *)msg->bodyptr);
6869
6870 wma_set_passpoint_network_list(wma_handle,
6871 (struct wifi_passpoint_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306872 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006873 break;
6874 case WMA_RESET_PASSPOINT_LIST_REQ:
6875 wma_reset_passpoint_network_list(wma_handle,
6876 (struct wifi_passpoint_req *)msg->bodyptr);
6877 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006878#endif /* FEATURE_WLAN_EXTSCAN */
6879 case WMA_SET_SCAN_MAC_OUI_REQ:
6880 wma_scan_probe_setoui(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306881 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006882 break;
6883#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6884 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
6885 wma_process_ll_stats_clear_req(wma_handle,
6886 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306887 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006888 break;
6889 case WMA_LINK_LAYER_STATS_SET_REQ:
6890 wma_process_ll_stats_set_req(wma_handle,
6891 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306892 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006893 break;
6894 case WMA_LINK_LAYER_STATS_GET_REQ:
6895 wma_process_ll_stats_get_req(wma_handle,
6896 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306897 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006898 break;
6899#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
6900 case SIR_HAL_UNIT_TEST_CMD:
6901 wma_process_unit_test_cmd(wma_handle,
6902 (t_wma_unit_test_cmd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306903 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006904 break;
6905#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006906 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
6907 wma_process_roam_synch_fail(wma_handle,
6908 (struct roam_offload_synch_fail *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306909 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006910 break;
6911 case SIR_HAL_ROAM_INVOKE:
6912 wma_process_roam_invoke(wma_handle,
6913 (struct wma_roam_invoke_cmd *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306914 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006915 break;
6916#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6917#ifdef WLAN_FEATURE_NAN
6918 case WMA_NAN_REQUEST:
6919 wma_nan_req(wma_handle, (tNanRequest *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306920 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006921 break;
6922#endif /* WLAN_FEATURE_NAN */
6923 case SIR_HAL_SET_BASE_MACADDR_IND:
6924 wma_set_base_macaddr_indicate(wma_handle,
6925 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306926 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006927 break;
6928 case WMA_LINK_STATUS_GET_REQ:
6929 wma_process_link_status_req(wma_handle,
6930 (tAniGetLinkStatus *) msg->bodyptr);
6931 break;
6932 case WMA_GET_TEMPERATURE_REQ:
6933 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306934 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006935 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07006936 case WMA_TSF_GPIO_PIN:
6937 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
6938 break;
6939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006940#ifdef DHCP_SERVER_OFFLOAD
6941 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
6942 wma_process_dhcpserver_offload(wma_handle,
6943 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306944 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006945 break;
6946#endif /* DHCP_SERVER_OFFLOAD */
6947#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
6948 case WMA_LED_FLASHING_REQ:
6949 wma_set_led_flashing(wma_handle,
6950 (tSirLedFlashingReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306951 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006952 break;
6953#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
6954 case SIR_HAL_SET_MAS:
6955 wma_process_set_mas(wma_handle,
6956 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306957 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006958 break;
6959 case SIR_HAL_SET_MIRACAST:
6960 wma_process_set_miracast(wma_handle,
6961 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306962 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006963 break;
6964 case SIR_HAL_CONFIG_STATS_FACTOR:
6965 wma_config_stats_factor(wma_handle,
6966 (struct sir_stats_avg_factor *)
6967 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306968 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006969 break;
6970 case SIR_HAL_CONFIG_GUARD_TIME:
6971 wma_config_guard_time(wma_handle,
6972 (struct sir_guard_time_request *)
6973 msg->bodyptr);
6974 case WMA_IPA_OFFLOAD_ENABLE_DISABLE:
6975 wma_ipa_offload_enable_disable(wma_handle,
6976 (struct sir_ipa_offload_enable_disable *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306977 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006978 break;
6979 case SIR_HAL_START_STOP_LOGGING:
6980 wma_set_wifi_start_packet_stats(wma_handle,
6981 (struct sir_wifi_start_log *)msg->bodyptr);
6982 wma_enable_specific_fw_logs(wma_handle,
6983 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306984 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006985 break;
6986 case SIR_HAL_FLUSH_LOG_TO_FW:
6987 wma_send_flush_logs_to_fw(wma_handle);
6988 /* Body ptr is NULL here */
6989 break;
6990 case WMA_SET_RSSI_MONITOR_REQ:
6991 wma_set_rssi_monitoring(wma_handle,
6992 (struct rssi_monitor_req *)msg->bodyptr);
Prakash Dhavali87ddca32016-11-29 17:02:11 -08006993 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006994 break;
6995 case WMA_FW_MEM_DUMP_REQ:
6996 wma_process_fw_mem_dump_req(wma_handle,
6997 (struct fw_dump_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306998 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006999 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307000 case SIR_HAL_PDEV_SET_PCL_TO_FW:
7001 wma_send_pdev_set_pcl_cmd(wma_handle,
7002 (struct wmi_pcl_chan_weights *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307003 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007004 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307005 case SIR_HAL_PDEV_SET_HW_MODE:
7006 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007007 (struct policy_mgr_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307008 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007009 break;
7010 case WMA_OCB_SET_CONFIG_CMD:
7011 wma_ocb_set_config_req(wma_handle,
7012 (struct sir_ocb_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307013 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007014 break;
7015 case WMA_OCB_SET_UTC_TIME_CMD:
7016 wma_ocb_set_utc_time(wma_handle,
7017 (struct sir_ocb_utc *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307018 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007019 break;
7020 case WMA_OCB_START_TIMING_ADVERT_CMD:
7021 wma_ocb_start_timing_advert(wma_handle,
7022 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307023 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007024 break;
7025 case WMA_OCB_STOP_TIMING_ADVERT_CMD:
7026 wma_ocb_stop_timing_advert(wma_handle,
7027 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307028 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007029 break;
7030 case WMA_DCC_CLEAR_STATS_CMD:
7031 wma_dcc_clear_stats(wma_handle,
7032 (struct sir_dcc_clear_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307033 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007034 break;
7035 case WMA_OCB_GET_TSF_TIMER_CMD:
7036 wma_ocb_get_tsf_timer(wma_handle,
7037 (struct sir_ocb_get_tsf_timer *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307038 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007039 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07007040 case WMA_SET_WISA_PARAMS:
7041 wma_set_wisa_params(wma_handle,
7042 (struct sir_wisa_params *)msg->bodyptr);
7043 qdf_mem_free(msg->bodyptr);
7044 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007045 case WMA_DCC_GET_STATS_CMD:
7046 wma_dcc_get_stats(wma_handle,
7047 (struct sir_dcc_get_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307048 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007049 break;
7050 case WMA_DCC_UPDATE_NDL_CMD:
7051 wma_dcc_update_ndl(wma_handle,
7052 (struct sir_dcc_update_ndl *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307053 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007054 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307055 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
7056 wma_send_pdev_set_dual_mac_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007057 (struct sir_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307058 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007059 break;
7060 case WMA_SET_IE_INFO:
7061 wma_process_set_ie_info(wma_handle,
7062 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307063 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007064 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007065 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
7066 wma_send_pdev_set_antenna_mode(wma_handle,
7067 (struct sir_antenna_mode_param *)msg->bodyptr);
7068 qdf_mem_free(msg->bodyptr);
7069 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007070 case WMA_LRO_CONFIG_CMD:
7071 wma_lro_config_cmd(wma_handle,
Dhanashri Atre09828f12016-11-13 10:36:58 -08007072 (struct cdp_lro_hash_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307073 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007074 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08007075 case WMA_GW_PARAM_UPDATE_REQ:
7076 wma_set_gateway_params(wma_handle,
7077 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08007078 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08007079 break;
7080 case WMA_SET_EGAP_CONF_PARAMS:
7081 wma_send_egap_conf_params(wma_handle,
7082 (struct egap_conf_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307083 qdf_mem_free(msg->bodyptr);
Ravi Joshi9e891ba2015-11-09 19:03:46 -08007084 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05307085 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
7086 wma_send_adapt_dwelltime_params(wma_handle,
7087 (struct adaptive_dwelltime_params *)msg->bodyptr);
7088 qdf_mem_free(msg->bodyptr);
7089 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08007090 case WMA_HT40_OBSS_SCAN_IND:
7091 wma_send_ht40_obss_scanind(wma_handle,
7092 (struct obss_ht40_scanind *)msg->bodyptr);
7093 qdf_mem_free(msg->bodyptr);
7094 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07007095 case WMA_ADD_BCN_FILTER_CMDID:
7096 wma_add_beacon_filter(wma_handle, msg->bodyptr);
7097 qdf_mem_free(msg->bodyptr);
7098 break;
7099 case WMA_REMOVE_BCN_FILTER_CMDID:
7100 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
7101 qdf_mem_free(msg->bodyptr);
7102 break;
Arun Khandavalli2476ef52016-04-26 20:19:43 +05307103 case WDA_BPF_GET_CAPABILITIES_REQ:
7104 wma_get_bpf_capabilities(wma_handle);
7105 break;
7106 case WDA_BPF_SET_INSTRUCTIONS_REQ:
7107 wma_set_bpf_instructions(wma_handle, msg->bodyptr);
7108 qdf_mem_free(msg->bodyptr);
7109 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07007110 case SIR_HAL_NDP_INITIATOR_REQ:
7111 wma_handle_ndp_initiator_req(wma_handle, msg->bodyptr);
7112 qdf_mem_free(msg->bodyptr);
7113 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07007114
Abhishek Singh4fef7472016-06-06 11:36:03 -07007115 case SIR_HAL_NDP_RESPONDER_REQ:
7116 wma_handle_ndp_responder_req(wma_handle, msg->bodyptr);
Naveen Rawatf28315c2016-06-29 18:06:02 -07007117 break;
7118
7119 case SIR_HAL_NDP_END_REQ:
7120 wma_handle_ndp_end_req(wma_handle, msg->bodyptr);
Abhishek Singh4fef7472016-06-06 11:36:03 -07007121 qdf_mem_free(msg->bodyptr);
7122 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05307123 case SIR_HAL_POWER_DBG_CMD:
7124 wma_process_hal_pwr_dbg_cmd(wma_handle,
7125 msg->bodyptr);
7126 qdf_mem_free(msg->bodyptr);
7127 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307128 case WMA_UPDATE_WEP_DEFAULT_KEY:
7129 wma_update_wep_default_key(wma_handle,
7130 (struct wep_update_default_key_idx *)msg->bodyptr);
7131 qdf_mem_free(msg->bodyptr);
7132 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05307133 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
7134 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
7135 break;
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05307136 case WMA_ENCRYPT_DECRYPT_MSG:
7137 wma_encrypt_decrypt_msg(wma_handle, msg->bodyptr);
7138 qdf_mem_free(msg->bodyptr);
7139 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307140 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
7141 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
7142 qdf_mem_free(msg->bodyptr);
7143 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307144 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
7145 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
7146 qdf_mem_free(msg->bodyptr);
7147 break;
7148 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
7149 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
7150 qdf_mem_free(msg->bodyptr);
7151 break;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307152 case SIR_HAL_POWER_DEBUG_STATS_REQ:
7153 wma_process_power_debug_stats_req(wma_handle);
7154 break;
Yingying Tang95409972016-10-20 15:16:15 +08007155 case WMA_SET_WOW_PULSE_CMD:
7156 wma_send_wow_pulse_cmd(wma_handle,
7157 (struct wow_pulse_mode *)msg->bodyptr);
7158 qdf_mem_free(msg->bodyptr);
7159 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007160 default:
Dustin Brown86534fb2017-01-24 14:28:20 -08007161 WMA_LOGE("Unhandled WMA message of type %d", msg->type);
7162 if (msg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307163 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007164 }
7165end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307166 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007167}
7168
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007169QDF_STATUS wma_mc_process_handler(struct scheduler_msg *msg)
7170{
7171 void *cds_ctx = cds_get_global_context();
7172
7173 if (cds_ctx == NULL) {
7174 QDF_TRACE(QDF_MODULE_ID_SYS, QDF_TRACE_LEVEL_ERROR,
7175 "CDS context is NULL");
7176 return QDF_STATUS_E_FAILURE;
7177 }
Rajeev Kumar156188e2017-01-21 17:23:52 -08007178 return wma_mc_process_msg(cds_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007179}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007180
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007181/**
7182 * wma_log_completion_timeout() - Log completion timeout
7183 * @data: Timeout handler data
7184 *
7185 * This function is called when log completion timer expires
7186 *
7187 * Return: None
7188 */
7189void wma_log_completion_timeout(void *data)
7190{
7191 tp_wma_handle wma_handle;
7192
7193 WMA_LOGE("%s: Timeout occured for log completion command", __func__);
7194
7195 wma_handle = (tp_wma_handle) data;
7196 if (!wma_handle)
7197 WMA_LOGE("%s: Invalid WMA handle", __func__);
7198
7199 /* Though we did not receive any event from FW,
7200 * we can flush whatever logs we have with us */
7201 cds_logging_set_fw_flush_complete();
7202
7203 return;
7204}
7205
7206/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05307207 * wma_map_pcl_weights() - Map PCL weights
7208 * @pcl_weight: Internal PCL weights
7209 *
7210 * Maps the internal weights of PCL to the weights needed by FW
7211 *
7212 * Return: Mapped channel weight of type wmi_pcl_chan_weight
7213 */
7214static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
7215{
7216 switch (pcl_weight) {
7217 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
7218 return WMI_PCL_WEIGHT_VERY_HIGH;
7219 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
7220 return WMI_PCL_WEIGHT_HIGH;
7221 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
7222 return WMI_PCL_WEIGHT_MEDIUM;
7223 case WEIGHT_OF_NON_PCL_CHANNELS:
7224 return WMI_PCL_WEIGHT_LOW;
7225 default:
7226 return WMI_PCL_WEIGHT_DISALLOW;
7227 }
7228}
7229
7230/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307231 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007232 * @wma_handle: WMA handle
7233 * @msg: PCL structure containing the PCL and the number of channels
7234 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307235 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236 * firmware. The DBS Manager is the consumer of this information in the WLAN
7237 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
7238 * to migrate to a new channel without host driver involvement. An example of
7239 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
7240 * manage the channel selection without firmware involvement.
7241 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307242 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
7243 * channel list. The weights corresponds to the channels sent in
7244 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
7245 * weightage compared to the non PCL channels.
7246 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007247 * Return: Success if the cmd is sent successfully to the firmware
7248 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307249QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
7250 struct wmi_pcl_chan_weights *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307252 uint32_t i;
7253 QDF_STATUS status;
7254
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007255 if (!wma_handle) {
7256 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7257 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307258 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007259 }
7260
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307261 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
7262 msg->saved_chan_list[i] =
7263 wma_handle->saved_chan.channel_list[i];
7264 }
7265
7266 msg->saved_num_chan = wma_handle->saved_chan.num_channels;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007267 status = policy_mgr_get_valid_chan_weights(wma_handle->psoc,
7268 (struct policy_mgr_pcl_chan_weights *)msg);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05307269
7270 for (i = 0; i < msg->saved_num_chan; i++) {
7271 msg->weighed_valid_list[i] =
7272 wma_map_pcl_weights(msg->weighed_valid_list[i]);
7273 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
7274 msg->saved_chan_list[i], i,
7275 msg->weighed_valid_list[i]);
7276 }
7277
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307278 if (!QDF_IS_STATUS_SUCCESS(status)) {
7279 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
7280 return status;
7281 }
7282
7283 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle, msg))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307284 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05307285
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307286 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007287}
7288
7289/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307290 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007291 * @wma_handle: WMA handle
7292 * @msg: Structure containing the following parameters
7293 *
7294 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
7295 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
7296 *
7297 * Provides notification to the WLAN firmware that host driver is requesting a
7298 * HardWare (HW) Mode change. This command is needed to support iHelium in the
7299 * configurations that include the Dual Band Simultaneous (DBS) feature.
7300 *
7301 * Return: Success if the cmd is sent successfully to the firmware
7302 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307303QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007304 struct policy_mgr_hw_mode *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007305{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007306 struct sir_set_hw_mode_resp *param;
7307
7308 if (!wma_handle) {
7309 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7310 __func__);
7311 /* Handle is NULL. Will not be able to send failure
7312 * response as well
7313 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307314 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007315 }
7316
7317 if (!msg) {
7318 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
7319 /* Lets try to free the active command list */
7320 goto fail;
7321 }
7322
Govind Singhf25a0f12016-03-08 16:09:48 +05307323 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
7324 msg->hw_mode_index))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007325 goto fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007326
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307327 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007328fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307329 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007330 if (!param) {
7331 WMA_LOGE("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307332 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007333 }
7334 param->status = SET_HW_MODE_STATUS_ECANCELED;
7335 param->cfgd_hw_mode_index = 0;
7336 param->num_vdev_mac_entries = 0;
7337 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307338 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007339 (void *) param, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307340 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007341}
7342
7343/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307344 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007345 * @wma_handle: WMA handle
7346 * @msg: Dual MAC config parameters
7347 *
7348 * Configures WLAN firmware with the dual MAC features
7349 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307350 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007351 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307352QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007353 struct sir_dual_mac_config *msg)
7354{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307355 QDF_STATUS status;
7356
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007357 if (!wma_handle) {
7358 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7359 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307360 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361 }
7362
7363 if (!msg) {
7364 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307365 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007366 }
7367
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307368 status = wmi_unified_pdev_set_dual_mac_config_cmd(
7369 wma_handle->wmi_handle,
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307370 (struct wmi_dual_mac_config *)msg);
7371 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307372 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307373 __func__, status);
7374 return status;
7375 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007376
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007377 policy_mgr_update_dbs_req_config(wma_handle->psoc,
7378 msg->scan_config, msg->fw_mode_config);
Govind Singhf25a0f12016-03-08 16:09:48 +05307379
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307380 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381}
7382
7383/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007384 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
7385 * @wma_handle: WMA handle
7386 * @msg: Antenna mode parameters
7387 *
7388 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
7389 * modify the number of TX/RX chains from host
7390 *
7391 * Return: QDF_STATUS. 0 on success.
7392 */
7393QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
7394 struct sir_antenna_mode_param *msg)
7395{
7396 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
7397 wmi_buf_t buf;
7398 uint32_t len;
7399 QDF_STATUS status = QDF_STATUS_SUCCESS;
7400 struct sir_antenna_mode_resp *param;
7401
7402 if (!wma_handle) {
7403 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7404 __func__);
7405 return QDF_STATUS_E_NULL_VALUE;
7406 }
7407
7408 if (!msg) {
7409 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
7410 return QDF_STATUS_E_NULL_VALUE;
7411 }
7412
7413 len = sizeof(*cmd);
7414
7415 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7416 if (!buf) {
7417 WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
7418 status = QDF_STATUS_E_NOMEM;
7419 goto resp;
7420 }
7421
7422 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
7423 WMITLV_SET_HDR(&cmd->tlv_header,
7424 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
7425 WMITLV_GET_STRUCT_TLVLEN(
7426 wmi_pdev_set_antenna_mode_cmd_fixed_param));
7427
7428 cmd->pdev_id = WMI_PDEV_ID_SOC;
7429 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
7430 cmd->num_txrx_chains = msg->num_rx_chains;
7431 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
7432
7433 WMA_LOGI("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
7434 __func__, msg->num_tx_chains,
7435 msg->num_rx_chains, cmd->num_txrx_chains);
7436
7437 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7438 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
7439 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_ANTENNA_MODE_CMDID",
7440 __func__);
7441 wmi_buf_free(buf);
7442 status = QDF_STATUS_E_FAILURE;
7443 goto resp;
7444 }
7445 status = QDF_STATUS_SUCCESS;
7446
7447resp:
7448 param = qdf_mem_malloc(sizeof(*param));
7449 if (!param) {
7450 WMA_LOGE("%s: Memory allocation failed", __func__);
7451 return QDF_STATUS_E_NOMEM;
7452 }
7453 param->status = (status) ?
7454 SET_ANTENNA_MODE_STATUS_ECANCELED :
7455 SET_ANTENNA_MODE_STATUS_OK;
7456 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
7457 __func__, param->status);
7458 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
7459 (void *) param, 0);
7460 return status;
7461}
7462
7463/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007464 * wma_crash_inject() - sends command to FW to simulate crash
7465 * @wma_handle: pointer of WMA context
7466 * @type: subtype of the command
7467 * @delay_time_ms: time in milliseconds for FW to delay the crash
7468 *
7469 * This function will send a command to FW in order to simulate different
7470 * kinds of FW crashes.
7471 *
Govind Singhd76a5b02016-03-08 15:12:14 +05307472 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007473 */
Govind Singhd76a5b02016-03-08 15:12:14 +05307474QDF_STATUS wma_crash_inject(tp_wma_handle wma_handle, uint32_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007475 uint32_t delay_time_ms)
7476{
Govind Singhd76a5b02016-03-08 15:12:14 +05307477 struct crash_inject param;
7478 param.type = type;
7479 param.delay_time_ms = delay_time_ms;
7480
7481 return wmi_crash_inject(wma_handle->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007482}
Govind Singhd76a5b02016-03-08 15:12:14 +05307483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007484#if defined(FEATURE_LRO)
7485/**
7486 * wma_lro_init() - sends LRO configuration to FW
7487 * @lro_config: pointer to the config parameters
7488 *
7489 * This function ends LRO configuration to FW.
7490 *
7491 * Return: 0 for success or reasons for failure
7492 */
Dhanashri Atre09828f12016-11-13 10:36:58 -08007493int wma_lro_init(struct cdp_lro_hash_config *lro_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007494{
Rajeev Kumarb60abe42017-01-21 15:39:31 -08007495 struct scheduler_msg msg = {0};
Dhanashri Atre09828f12016-11-13 10:36:58 -08007496 struct cdp_lro_hash_config *iwcmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007497
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307498 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007499 if (!iwcmd) {
7500 WMA_LOGE("memory allocation for WMA_LRO_CONFIG_CMD failed!");
7501 return -ENOMEM;
7502 }
7503
7504 *iwcmd = *lro_config;
7505
7506 msg.type = WMA_LRO_CONFIG_CMD;
7507 msg.reserved = 0;
7508 msg.bodyptr = iwcmd;
7509
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307510 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08007511 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007512 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307513 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007514 return -EAGAIN;
7515 }
7516
7517 WMA_LOGD("sending the LRO configuration to the fw");
7518 return 0;
7519}
7520#endif
Leo Chang96464902016-10-28 11:10:54 -07007521
7522void wma_peer_set_default_routing(void *scn_handle, uint8_t *peer_macaddr,
7523 uint8_t vdev_id, bool hash_based, uint8_t ring_num)
7524{
7525 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7526 struct peer_set_params param;
7527
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307528 if (!wma) {
7529 WMA_LOGE("%s:wma_handle is NULL", __func__);
7530 return;
7531 }
Leo Chang96464902016-10-28 11:10:54 -07007532
7533 /* TODO: Need bit definitions for ring number and hash based routing
7534 * fields in common wmi header file
7535 */
7536 param.param_id = WMI_HOST_PEER_SET_DEFAULT_ROUTING;
7537 param.vdev_id = vdev_id;
7538 param.param_value = ((hash_based) ? 1 : 0) | (ring_num << 1);
Dhanashri Atre09828f12016-11-13 10:36:58 -08007539 WMA_LOGD("%s: param_value 0x%d", __func__, param.param_value);
Leo Chang96464902016-10-28 11:10:54 -07007540 wmi_set_peer_param_send(wma->wmi_handle, peer_macaddr, &param);
7541
7542 return;
7543}
7544
7545int wma_peer_rx_reorder_queue_setup(void *scn_handle,
7546 uint8_t vdev_id, uint8_t *peer_macaddr, qdf_dma_addr_t hw_qdesc,
7547 int tid, uint16_t queue_no)
7548{
7549 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7550 struct rx_reorder_queue_setup_params param;
7551
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307552 if (!wma) {
7553 WMA_LOGE("%s:wma_handle is NULL", __func__);
7554 return QDF_STATUS_E_FAILURE;
7555 }
7556
Leo Chang96464902016-10-28 11:10:54 -07007557 param.tid = tid;
7558 param.vdev_id = vdev_id;
7559 param.peer_macaddr = peer_macaddr;
7560 param.hw_qdesc_paddr_lo = hw_qdesc & 0xffffffff;
7561 param.hw_qdesc_paddr_hi = (uint64_t)hw_qdesc >> 32;
7562 param.queue_no = queue_no;
7563
7564 return wmi_unified_peer_rx_reorder_queue_setup_send(wma->wmi_handle,
7565 &param);
7566}
7567
7568int wma_peer_rx_reorder_queue_remove(void *scn_handle,
7569 uint8_t vdev_id, uint8_t *peer_macaddr, uint32_t peer_tid_bitmap)
7570{
7571 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7572 struct rx_reorder_queue_remove_params param;
7573
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307574 if (!wma) {
7575 WMA_LOGE("%s:wma_handle is NULL", __func__);
7576 return QDF_STATUS_E_FAILURE;
7577 }
7578
Leo Chang96464902016-10-28 11:10:54 -07007579 param.vdev_id = vdev_id;
7580 param.peer_macaddr = peer_macaddr;
7581 param.peer_tid_bitmap = peer_tid_bitmap;
7582
7583 return wmi_unified_peer_rx_reorder_queue_remove_send(wma->wmi_handle,
7584 &param);
7585}
7586
7587