blob: 5dfc60b431399ed902eef824502c0bf8813aa188 [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
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072#include "wma_internal.h"
73
74#include "wma_ocb.h"
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -070075#include "wlan_policy_mgr_api.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080076#include "cdp_txrx_cfg.h"
77#include "cdp_txrx_flow_ctrl_legacy.h"
78#include "cdp_txrx_flow_ctrl_v2.h"
79#include "cdp_txrx_ipa.h"
Leo Chang96464902016-10-28 11:10:54 -070080#include "cdp_txrx_misc.h"
Jeff Johnson6136fb92017-03-30 15:21:49 -070081#include "wma_fips_api.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
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070091#include "wlan_reg_tgt_api.h"
92#include "wlan_reg_services_api.h"
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080093#include <cdp_txrx_handle.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070094#include <wlan_pmo_ucfg_api.h>
Naveen Rawat4efe41b2017-04-29 16:23:14 -070095#include "wifi_pos_api.h"
96#include "hif_main.h"
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070097
Agrawal Ashishb0aa0752017-04-21 19:31:10 +053098#define WMA_LOG_COMPLETION_TIMER 3000 /* 3 seconds */
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +053099#define WMI_TLV_HEADROOM 128
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700100uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101static uint32_t g_fw_wlan_feat_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102/**
103 * wma_get_fw_wlan_feat_caps() - get fw feature capablity
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700104 * @feature: feature enum value
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800105 *
106 * Return: true/false
107 */
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700108bool wma_get_fw_wlan_feat_caps(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700110 return (g_fw_wlan_feat_caps & (1 << feature)) ? true : false;
111}
112
113/**
114 * wma_set_fw_wlan_feat_caps() - set fw feature capablity
115 * @feature: feature enum value
116 *
117 * Return: None
118 */
119void wma_set_fw_wlan_feat_caps(enum cap_bitmap feature)
120{
121 g_fw_wlan_feat_caps |= (1 << feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122}
123
124/**
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530125 * wma_service_ready_ext_evt_timeout() - Service ready extended event timeout
126 * @data: Timeout handler data
127 *
128 * This function is called when the FW fails to send WMI_SERVICE_READY_EXT_EVENT
129 * message
130 *
131 * Return: None
132 */
133static void wma_service_ready_ext_evt_timeout(void *data)
134{
135 tp_wma_handle wma_handle;
136
137 WMA_LOGA("%s: Timeout waiting for WMI_SERVICE_READY_EXT_EVENT",
138 __func__);
139
140 wma_handle = (tp_wma_handle) data;
141
142 if (!wma_handle) {
143 WMA_LOGE("%s: Invalid WMA handle", __func__);
144 goto end;
145 }
146
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530147end:
Naveen Rawatac39a102016-10-07 10:58:29 -0700148 /* Assert here. Panic is being called in insmod thread */
149 QDF_ASSERT(0);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530150}
151
152/**
Komal Seelam02d09342016-02-23 18:03:19 +0530153 * wma_get_ini_handle() - API to get WMA ini info handle
154 * @wma: WMA Handle
155 *
156 * Returns the pointer to WMA ini structure.
157 * Return: struct wma_ini_config
158 */
159struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma)
160{
161 if (!wma) {
162 WMA_LOGE("%s: Invalid WMA context\n", __func__);
163 return NULL;
164 }
165
166 return &wma->ini_config;
167}
168
169#define MAX_SUPPORTED_PEERS_REV1_1 14
170#define MAX_SUPPORTED_PEERS_REV1_3 32
171#define MIN_NO_OF_PEERS 1
172
173/**
174 * wma_get_number_of_peers_supported - API to query for number of peers
175 * supported
176 * @wma: WMA Handle
177 *
178 * Return: Max Number of Peers Supported
179 */
180static uint8_t wma_get_number_of_peers_supported(tp_wma_handle wma)
181{
182 struct hif_target_info *tgt_info;
183 struct wma_ini_config *cfg = wma_get_ini_handle(wma);
184 uint8_t max_no_of_peers = cfg ? cfg->max_no_of_peers : MIN_NO_OF_PEERS;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530185 struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF);
Komal Seelam02d09342016-02-23 18:03:19 +0530186
187 if (!scn) {
188 WMA_LOGE("%s: Invalid wma handle", __func__);
189 return 0;
190 }
191
192 tgt_info = hif_get_target_info_handle(scn);
193
194 switch (tgt_info->target_version) {
195 case AR6320_REV1_1_VERSION:
196 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_1)
197 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_1;
198 break;
199 default:
200 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_3)
201 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_3;
202 break;
203 }
204
205 return max_no_of_peers;
206}
207
208/**
bings6b3614e2017-02-21 10:18:36 +0800209 * wma_get_number_of_tids_supported - API to query for number of tids supported
210 * @no_of_peers_supported: Number of peer supported
211 *
212 * Return: Max number of tids supported
213 */
214#if defined(CONFIG_HL_SUPPORT)
215static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported)
216{
217 return 4 * no_of_peers_supported;
218}
219#else
220static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported)
221{
222 return 2 * (no_of_peers_supported + CFG_TGT_NUM_VDEV + 2);
223}
224#endif
225
226/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 * wma_set_default_tgt_config() - set default tgt config
228 * @wma_handle: wma handle
229 *
230 * Return: none
231 */
232static void wma_set_default_tgt_config(tp_wma_handle wma_handle)
233{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 uint8_t no_of_peers_supported;
235 wmi_resource_config tgt_cfg = {
236 0, /* Filling zero for TLV Tag and Length fields */
237 CFG_TGT_NUM_VDEV,
238 CFG_TGT_NUM_PEERS + CFG_TGT_NUM_VDEV + 2,
239 CFG_TGT_NUM_OFFLOAD_PEERS,
240 CFG_TGT_NUM_OFFLOAD_REORDER_BUFFS,
241 CFG_TGT_NUM_PEER_KEYS,
242 CFG_TGT_NUM_TIDS,
243 CFG_TGT_AST_SKID_LIMIT,
244 CFG_TGT_DEFAULT_TX_CHAIN_MASK,
245 CFG_TGT_DEFAULT_RX_CHAIN_MASK,
246 {CFG_TGT_RX_TIMEOUT_LO_PRI, CFG_TGT_RX_TIMEOUT_LO_PRI,
247 CFG_TGT_RX_TIMEOUT_LO_PRI, CFG_TGT_RX_TIMEOUT_HI_PRI},
248 CFG_TGT_RX_DECAP_MODE,
249 CFG_TGT_DEFAULT_SCAN_MAX_REQS,
250 CFG_TGT_DEFAULT_BMISS_OFFLOAD_MAX_VDEV,
251 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_VDEV,
252 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_PROFILES,
253 CFG_TGT_DEFAULT_NUM_MCAST_GROUPS,
254 CFG_TGT_DEFAULT_NUM_MCAST_TABLE_ELEMS,
255 CFG_TGT_DEFAULT_MCAST2UCAST_MODE,
256 CFG_TGT_DEFAULT_TX_DBG_LOG_SIZE,
257 CFG_TGT_WDS_ENTRIES,
258 CFG_TGT_DEFAULT_DMA_BURST_SIZE,
259 CFG_TGT_DEFAULT_MAC_AGGR_DELIM,
260 CFG_TGT_DEFAULT_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK,
261 CFG_TGT_DEFAULT_VOW_CONFIG,
262 CFG_TGT_DEFAULT_GTK_OFFLOAD_MAX_VDEV,
263 CFG_TGT_NUM_MSDU_DESC,
264 CFG_TGT_MAX_FRAG_TABLE_ENTRIES,
265 CFG_TGT_NUM_TDLS_VDEVS,
266 CFG_TGT_NUM_TDLS_CONN_TABLE_ENTRIES,
267 CFG_TGT_DEFAULT_BEACON_TX_OFFLOAD_MAX_VDEV,
268 CFG_TGT_MAX_MULTICAST_FILTER_ENTRIES,
269 0,
270 0,
271 0,
272 CFG_TGT_NUM_TDLS_CONC_SLEEP_STAS,
273 CFG_TGT_NUM_TDLS_CONC_BUFFER_STAS,
274 0,
275 CFG_TGT_NUM_OCB_VDEVS,
276 CFG_TGT_NUM_OCB_CHANNELS,
277 CFG_TGT_NUM_OCB_SCHEDULES,
278 };
279
Komal Seelam02d09342016-02-23 18:03:19 +0530280 no_of_peers_supported = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 tgt_cfg.num_peers = no_of_peers_supported + CFG_TGT_NUM_VDEV + 2;
bings6b3614e2017-02-21 10:18:36 +0800282 tgt_cfg.num_tids = wma_get_number_of_tids_supported(
283 no_of_peers_supported);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 tgt_cfg.scan_max_pending_req = wma_handle->max_scan;
285
Nirav Shah20489972016-06-16 19:20:28 +0530286 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(tgt_cfg.flag1, 1);
Yun Park4d968df2016-10-11 11:44:15 -0700287 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(tgt_cfg.flag1,
288 1);
Nirav Shah20489972016-06-16 19:20:28 +0530289
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800290 WMITLV_SET_HDR(&tgt_cfg.tlv_header,
291 WMITLV_TAG_STRUC_wmi_resource_config,
292 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
293 /* reduce the peer/vdev if CFG_TGT_NUM_MSDU_DESC exceeds 1000 */
294#ifdef PERE_IP_HDR_ALIGNMENT_WAR
295 if (scn->host_80211_enable) {
296 /*
297 * To make the IP header begins at dword aligned address,
298 * we make the decapsulation mode as Native Wifi.
299 */
300 tgt_cfg.rx_decap_mode = CFG_TGT_RX_DECAP_MODE_NWIFI;
301 }
302#endif /* PERE_IP_HDR_ALIGNMENT_WAR */
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700303 if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam())
304 tgt_cfg.rx_decap_mode = CFG_TGT_RX_DECAP_MODE_RAW;
305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 wma_handle->wlan_resource_config = tgt_cfg;
307}
308
309/**
310 * wma_cli_get_command() - WMA "get" command processor
311 * @vdev_id: virtual device for the command
312 * @param_id: parameter id
313 * @vpdev: parameter category
314 *
315 * Return: parameter value on success, -EINVAL on failure
316 */
317int wma_cli_get_command(int vdev_id, int param_id, int vpdev)
318{
319 int ret = 0;
320 tp_wma_handle wma;
321 struct wma_txrx_node *intr = NULL;
322
Anurag Chouhan6d760662016-02-20 16:05:43 +0530323 wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800324
325 if (NULL == wma) {
326 WMA_LOGE("%s: Invalid wma handle", __func__);
327 return -EINVAL;
328 }
329
330 intr = wma->interfaces;
331
332 if (VDEV_CMD == vpdev) {
333 switch (param_id) {
334 case WMI_VDEV_PARAM_NSS:
335 ret = intr[vdev_id].config.nss;
336 break;
337#ifdef QCA_SUPPORT_GTX
338 case WMI_VDEV_PARAM_GTX_HT_MCS:
339 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
340 break;
341 case WMI_VDEV_PARAM_GTX_VHT_MCS:
342 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
343 break;
344 case WMI_VDEV_PARAM_GTX_USR_CFG:
345 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
346 break;
347 case WMI_VDEV_PARAM_GTX_THRE:
348 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
349 break;
350 case WMI_VDEV_PARAM_GTX_MARGIN:
351 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
352 break;
353 case WMI_VDEV_PARAM_GTX_STEP:
354 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
355 break;
356 case WMI_VDEV_PARAM_GTX_MINTPC:
357 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
358 break;
359 case WMI_VDEV_PARAM_GTX_BW_MASK:
360 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
361 break;
362#endif /* QCA_SUPPORT_GTX */
363 case WMI_VDEV_PARAM_LDPC:
364 ret = intr[vdev_id].config.ldpc;
365 break;
366 case WMI_VDEV_PARAM_TX_STBC:
367 ret = intr[vdev_id].config.tx_stbc;
368 break;
369 case WMI_VDEV_PARAM_RX_STBC:
370 ret = intr[vdev_id].config.rx_stbc;
371 break;
372 case WMI_VDEV_PARAM_SGI:
373 ret = intr[vdev_id].config.shortgi;
374 break;
375 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
376 ret = intr[vdev_id].config.rtscts_en;
377 break;
378 case WMI_VDEV_PARAM_CHWIDTH:
379 ret = intr[vdev_id].config.chwidth;
380 break;
381 case WMI_VDEV_PARAM_FIXED_RATE:
382 ret = intr[vdev_id].config.tx_rate;
383 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700384 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -0700385 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700386 ret = wma_get_he_vdev_param(&intr[vdev_id], param_id);
387 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700389 WMA_LOGE("Invalid cli_get vdev command/Not yet implemented 0x%x",
390 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391 return -EINVAL;
392 }
393 } else if (PDEV_CMD == vpdev) {
394 switch (param_id) {
395 case WMI_PDEV_PARAM_ANI_ENABLE:
396 ret = wma->pdevconfig.ani_enable;
397 break;
398 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
399 ret = wma->pdevconfig.ani_poll_len;
400 break;
401 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
402 ret = wma->pdevconfig.ani_listen_len;
403 break;
404 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
405 ret = wma->pdevconfig.ani_ofdm_level;
406 break;
407 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
408 ret = wma->pdevconfig.ani_cck_level;
409 break;
410 case WMI_PDEV_PARAM_DYNAMIC_BW:
411 ret = wma->pdevconfig.cwmenable;
412 break;
413 case WMI_PDEV_PARAM_CTS_CBW:
414 ret = wma->pdevconfig.cts_cbw;
415 break;
416 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
417 ret = wma->pdevconfig.txchainmask;
418 break;
419 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
420 ret = wma->pdevconfig.rxchainmask;
421 break;
422 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
423 ret = wma->pdevconfig.txpow2g;
424 break;
425 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
426 ret = wma->pdevconfig.txpow5g;
427 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 case WMI_PDEV_PARAM_BURST_ENABLE:
429 ret = wma->pdevconfig.burst_enable;
430 break;
431 case WMI_PDEV_PARAM_BURST_DUR:
432 ret = wma->pdevconfig.burst_dur;
433 break;
434 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700435 WMA_LOGE("Invalid cli_get pdev command/Not yet implemented 0x%x",
436 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 return -EINVAL;
438 }
439 } else if (GEN_CMD == vpdev) {
440 switch (param_id) {
441 case GEN_VDEV_PARAM_AMPDU:
442 ret = intr[vdev_id].config.ampdu;
443 break;
444 case GEN_VDEV_PARAM_AMSDU:
445 ret = intr[vdev_id].config.amsdu;
446 break;
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700447 case GEN_VDEV_ROAM_SYNCH_DELAY:
448 ret = intr[vdev_id].roam_synch_delay;
449 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700451 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
452 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453 return -EINVAL;
454 }
455 } else if (PPS_CMD == vpdev) {
456 switch (param_id) {
457 case WMI_VDEV_PPS_PAID_MATCH:
458 ret = intr[vdev_id].config.pps_params.paid_match_enable;
459 break;
460 case WMI_VDEV_PPS_GID_MATCH:
461 ret = intr[vdev_id].config.pps_params.gid_match_enable;
462 break;
463 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
464 ret = intr[vdev_id].config.pps_params.tim_clear;
465 break;
466 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
467 ret = intr[vdev_id].config.pps_params.dtim_clear;
468 break;
469 case WMI_VDEV_PPS_EOF_PAD_DELIM:
470 ret = intr[vdev_id].config.pps_params.eof_delim;
471 break;
472 case WMI_VDEV_PPS_MACADDR_MISMATCH:
473 ret = intr[vdev_id].config.pps_params.mac_match;
474 break;
475 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
476 ret = intr[vdev_id].config.pps_params.delim_fail;
477 break;
478 case WMI_VDEV_PPS_GID_NSTS_ZERO:
479 ret = intr[vdev_id].config.pps_params.nsts_zero;
480 break;
481 case WMI_VDEV_PPS_RSSI_CHECK:
482 ret = intr[vdev_id].config.pps_params.rssi_chk;
483 break;
484 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700485 WMA_LOGE("Invalid pps vdev command/Not yet implemented 0x%x",
486 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487 return -EINVAL;
488 }
489 } else if (QPOWER_CMD == vpdev) {
490 switch (param_id) {
491 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
492 ret = intr[vdev_id].config.qpower_params.
493 max_ps_poll_cnt;
494 break;
495 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
496 ret = intr[vdev_id].config.qpower_params.
497 max_tx_before_wake;
498 break;
499 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
500 ret = intr[vdev_id].config.qpower_params.
501 spec_ps_poll_wake_interval;
502 break;
503 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
504 ret = intr[vdev_id].config.qpower_params.
505 max_spec_nodata_ps_poll;
506 break;
507 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700508 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
509 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 return -EINVAL;
511 }
512 } else if (GTX_CMD == vpdev) {
513 switch (param_id) {
514 case WMI_VDEV_PARAM_GTX_HT_MCS:
515 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
516 break;
517 case WMI_VDEV_PARAM_GTX_VHT_MCS:
518 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
519 break;
520 case WMI_VDEV_PARAM_GTX_USR_CFG:
521 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
522 break;
523 case WMI_VDEV_PARAM_GTX_THRE:
524 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
525 break;
526 case WMI_VDEV_PARAM_GTX_MARGIN:
527 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
528 break;
529 case WMI_VDEV_PARAM_GTX_STEP:
530 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
531 break;
532 case WMI_VDEV_PARAM_GTX_MINTPC:
533 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
534 break;
535 case WMI_VDEV_PARAM_GTX_BW_MASK:
536 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
537 break;
538 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700539 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
540 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541 return -EINVAL;
542 }
543 }
544 return ret;
545}
546
547/**
548 * wma_cli_set2_command() - WMA "set 2 params" command processor
549 * @vdev_id: virtual device for the command
550 * @param_id: parameter id
551 * @sval1: first parameter value
552 * @sval2: second parameter value
553 * @vpdev: parameter category
554 *
555 * Command handler for set operations which require 2 parameters
556 *
557 * Return: 0 on success, errno on failure
558 */
559int wma_cli_set2_command(int vdev_id, int param_id, int sval1,
560 int sval2, int vpdev)
561{
Rajeev Kumarb60abe42017-01-21 15:39:31 -0800562 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563 wma_cli_set_cmd_t *iwcmd;
564
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530565 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566 if (!iwcmd) {
567 WMA_LOGE("%s: Failed alloc memory for iwcmd", __func__);
568 return -ENOMEM;
569 }
570
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530571 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800572 iwcmd->param_value = sval1;
573 iwcmd->param_sec_value = sval2;
574 iwcmd->param_vdev_id = vdev_id;
575 iwcmd->param_id = param_id;
576 iwcmd->param_vp_dev = vpdev;
577 msg.type = WMA_CLI_SET_CMD;
578 msg.reserved = 0;
579 msg.bodyptr = iwcmd;
580
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530581 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -0800582 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -0700583 WMA_LOGE("%s: Failed to post WMA_CLI_SET_CMD msg",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800584 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530585 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 return -EIO;
587 }
588 return 0;
589}
590
591/**
592 * wma_cli_set_command() - WMA "set" command processor
593 * @vdev_id: virtual device for the command
594 * @param_id: parameter id
595 * @sval: parameter value
596 * @vpdev: parameter category
597 *
598 * Command handler for set operations
599 *
600 * Return: 0 on success, errno on failure
601 */
602int wma_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
603{
604 return wma_cli_set2_command(vdev_id, param_id, sval, 0, vpdev);
605
606}
607
608/**
Yun Parkb4f591d2017-03-29 15:51:01 -0700609 * wma_ipa_get_stat() - get IPA data path stats from FW
610 *
611 * Return: 0 on success, errno on failure
612 */
613#ifdef IPA_OFFLOAD
614static int wma_ipa_get_stat(void)
615{
616 struct cdp_pdev *pdev;
617
618 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
619 if (!pdev) {
620 WMA_LOGE("pdev NULL for uc stat");
621 return -EINVAL;
622 }
623 cdp_ipa_get_stat(cds_get_context(QDF_MODULE_ID_SOC), pdev);
624
625 return 0;
626}
627#else
628static int wma_ipa_get_stat(void)
629{
630 return 0;
631}
632#endif
633
634/**
635 * wma_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
636 * @privcmd: private command
637 *
638 * Return: 0 on success, errno on failure
639 */
640#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
641static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
642{
643 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
644 struct cdp_pdev *pdev;
645 uint8_t reset_stats = privcmd->param_value;
646
647 WMA_LOGD("%s: reset_stats=%d",
648 "WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID",
649 reset_stats);
650 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
651 if (!pdev) {
652 WMA_LOGE("pdev NULL for uc get share stats");
653 return -EINVAL;
654 }
655 cdp_ipa_uc_get_share_stats(soc, pdev, reset_stats);
656
657 return 0;
658}
659#else
660static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
661{
662 return 0;
663}
664#endif
665
666/**
667 * wma_ipa_uc_set_quota() - set quota limit to FW
668 * @privcmd: private command
669 *
670 * Return: 0 on success, errno on failure
671 */
672#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
673static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
674{
675 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
676 struct cdp_pdev *pdev;
677 uint64_t quota_bytes = privcmd->param_sec_value;
678
679 quota_bytes <<= 32;
680 quota_bytes |= privcmd->param_value;
681
682 WMA_LOGD("%s: quota_bytes=%llu",
683 "WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID",
684 quota_bytes);
685 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
686 if (!pdev) {
687 WMA_LOGE("pdev NULL for uc set quota");
688 return -EINVAL;
689 }
690 cdp_ipa_uc_set_quota(soc, pdev, quota_bytes);
691
692 return 0;
693}
694#else
695static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
696{
697 return 0;
698}
699#endif
700
701/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 * wma_set_priv_cfg() - set private config parameters
703 * @wma_handle: wma handle
704 * @privcmd: private command
705 *
706 * Return: 0 for success or error code
707 */
708static int32_t wma_set_priv_cfg(tp_wma_handle wma_handle,
709 wma_cli_set_cmd_t *privcmd)
710{
711 int32_t ret = 0;
712
713 switch (privcmd->param_id) {
714 case WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID:
715 ret = wma_set_txrx_fw_stats_level(wma_handle,
716 privcmd->param_vdev_id,
717 privcmd->param_value);
718 break;
719 case WMA_VDEV_TXRX_FWSTATS_RESET_CMDID:
720 ret = wma_txrx_fw_stats_reset(wma_handle,
721 privcmd->param_vdev_id,
722 privcmd->param_value);
723 break;
724 case WMI_STA_SMPS_FORCE_MODE_CMDID:
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800725 ret = wma_set_mimops(wma_handle,
726 privcmd->param_vdev_id,
727 privcmd->param_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 break;
729 case WMI_STA_SMPS_PARAM_CMDID:
730 wma_set_smps_params(wma_handle, privcmd->param_vdev_id,
731 privcmd->param_value);
732 break;
733 case WMA_VDEV_MCC_SET_TIME_LATENCY:
734 {
735 /* Extract first MCC adapter/vdev channel number and latency */
736 uint8_t mcc_channel = privcmd->param_value & 0x000000FF;
737 uint8_t mcc_channel_latency =
738 (privcmd->param_value & 0x0000FF00) >> 8;
739 int ret = -1;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700740
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 WMA_LOGD("%s: Parsed input: Channel #1:%d, latency:%dms",
742 __func__, mcc_channel, mcc_channel_latency);
743 ret = wma_set_mcc_channel_time_latency(wma_handle,
744 mcc_channel,
745 mcc_channel_latency);
746 }
747 break;
748 case WMA_VDEV_MCC_SET_TIME_QUOTA:
749 {
750 /* Extract the MCC 2 adapters/vdevs channel numbers and time
751 * quota value for the first adapter only (which is specified
752 * in iwpriv command.
753 */
754 uint8_t adapter_2_chan_number =
755 privcmd->param_value & 0x000000FF;
756 uint8_t adapter_1_chan_number =
757 (privcmd->param_value & 0x0000FF00) >> 8;
758 uint8_t adapter_1_quota =
759 (privcmd->param_value & 0x00FF0000) >> 16;
760 int ret = -1;
761
762 WMA_LOGD("%s: Parsed input: Channel #1:%d, Channel #2:%d, quota 1:%dms",
763 __func__, adapter_1_chan_number,
764 adapter_2_chan_number, adapter_1_quota);
765
766 ret = wma_set_mcc_channel_time_quota(wma_handle,
767 adapter_1_chan_number,
768 adapter_1_quota,
769 adapter_2_chan_number);
770 }
771 break;
772 case WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE:
773 {
774 wma_handle->wma_ibss_power_save_params.atimWindowLength =
775 privcmd->param_value;
776 WMA_LOGD("%s: IBSS power save ATIM Window = %d",
777 __func__, wma_handle->wma_ibss_power_save_params.
778 atimWindowLength);
779 }
780 break;
781 case WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED:
782 {
783 wma_handle->wma_ibss_power_save_params.isPowerSaveAllowed =
784 privcmd->param_value;
785 WMA_LOGD("%s: IBSS is Power Save Allowed = %d",
786 __func__, wma_handle->wma_ibss_power_save_params.
787 isPowerSaveAllowed);
788 }
789 break;
790 case WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED:
791 {
792 wma_handle->wma_ibss_power_save_params. isPowerCollapseAllowed =
793 privcmd->param_value;
794 WMA_LOGD("%s: IBSS is Power Collapse Allowed = %d",
795 __func__, wma_handle->wma_ibss_power_save_params.
796 isPowerCollapseAllowed);
797 }
798 break;
799 case WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX:
800 {
801 wma_handle->wma_ibss_power_save_params.isAwakeonTxRxEnabled =
802 privcmd->param_value;
803 WMA_LOGD("%s: IBSS Power Save Awake on Tx/Rx Enabled = %d",
804 __func__, wma_handle->wma_ibss_power_save_params.
805 isAwakeonTxRxEnabled);
806 }
807 break;
808 case WMA_VDEV_IBSS_SET_INACTIVITY_TIME:
809 {
810 wma_handle->wma_ibss_power_save_params.inactivityCount =
811 privcmd->param_value;
812 WMA_LOGD("%s: IBSS Power Save Data Inactivity Count = %d",
813 __func__, wma_handle->wma_ibss_power_save_params.
814 inactivityCount);
815 }
816 break;
817 case WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME:
818 {
819 wma_handle->wma_ibss_power_save_params.txSPEndInactivityTime =
820 privcmd->param_value;
821 WMA_LOGD("%s: IBSS Power Save Transmit EOSP inactivity time out = %d",
822 __func__, wma_handle->wma_ibss_power_save_params.
823 txSPEndInactivityTime);
824 }
825 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 case WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS:
827 {
828 wma_handle->wma_ibss_power_save_params.ibssPsWarmupTime =
829 privcmd->param_value;
830 WMA_LOGD("%s: IBSS Power Save Warm Up Time in Seconds = %d",
831 __func__, wma_handle->wma_ibss_power_save_params.
832 ibssPsWarmupTime);
833 }
834 break;
835 case WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW:
836 {
837 wma_handle->wma_ibss_power_save_params.ibssPs1RxChainInAtimEnable
838 = privcmd->param_value;
839 WMA_LOGD("%s: IBSS Power Save single RX Chain Enable In ATIM = %d",
840 __func__, wma_handle->wma_ibss_power_save_params.
841 ibssPs1RxChainInAtimEnable);
842 }
843 break;
844
845 case WMA_VDEV_TXRX_GET_IPA_UC_FW_STATS_CMDID:
846 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700847 wma_ipa_get_stat();
Yun Park637d6482016-10-05 10:51:33 -0700848 }
849 break;
850
851 case WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID:
852 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700853 wma_ipa_uc_get_share_stats(privcmd);
Yun Park637d6482016-10-05 10:51:33 -0700854 }
855 break;
856
857 case WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID:
858 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700859 wma_ipa_uc_set_quota(privcmd);
Yun Park327e7812017-02-14 15:18:10 -0800860
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 }
862 break;
863
864 default:
865 WMA_LOGE("Invalid wma config command id:%d", privcmd->param_id);
866 ret = -EINVAL;
867 }
868 return ret;
869}
870
871/**
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -0700872 * wma_set_dtim_period() - set dtim period to FW
873 * @wma: wma handle
874 * @dtim_params: dtim params
875 *
876 * Return: none
877 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -0700878static void wma_set_dtim_period(tp_wma_handle wma,
879 struct set_dtim_params *dtim_params)
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -0700880{
881 QDF_STATUS ret;
882 uint8_t vdev_id = dtim_params->session_id;
883 struct wma_txrx_node *iface =
884 &wma->interfaces[vdev_id];
885
Srinivas Girigowdaf1472122017-03-09 15:44:12 -0800886 WMA_LOGD("%s: set dtim_period %d", __func__,
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -0700887 dtim_params->dtim_period);
888 iface->dtimPeriod = dtim_params->dtim_period;
889 ret = wma_vdev_set_param(wma->wmi_handle,
890 vdev_id,
891 WMI_VDEV_PARAM_LISTEN_INTERVAL,
892 dtim_params->dtim_period);
893 if (QDF_IS_STATUS_ERROR(ret))
894 WMA_LOGW("Failed to set listen interval");
895
896}
897/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 * wma_set_modulated_dtim() - function to configure modulated dtim
899 * @wma: wma handle
900 * @privcmd: structure containing parameters
901 *
902 * This function configures the modulated dtim in firmware
903 *
904 * Return: none
905 */
906static void wma_set_modulated_dtim(tp_wma_handle wma,
907 wma_cli_set_cmd_t *privcmd)
908{
909 uint8_t vdev_id = privcmd->param_vdev_id;
910 struct wma_txrx_node *iface =
911 &wma->interfaces[vdev_id];
912 bool prev_dtim_enabled;
913 uint32_t listen_interval;
Govind Singhd76a5b02016-03-08 15:12:14 +0530914 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915
916 iface->alt_modulated_dtim = privcmd->param_value;
917
918 prev_dtim_enabled = iface->alt_modulated_dtim_enabled;
919
920 if (1 != privcmd->param_value)
921 iface->alt_modulated_dtim_enabled = true;
922 else
923 iface->alt_modulated_dtim_enabled = false;
924
925 if ((true == iface->alt_modulated_dtim_enabled) ||
926 (true == prev_dtim_enabled)) {
927
928 listen_interval = iface->alt_modulated_dtim
929 * iface->dtimPeriod;
930
Govind Singhd76a5b02016-03-08 15:12:14 +0530931 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 privcmd->param_vdev_id,
933 WMI_VDEV_PARAM_LISTEN_INTERVAL,
934 listen_interval);
Govind Singhd76a5b02016-03-08 15:12:14 +0530935 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 /* Even if it fails, continue */
937 WMA_LOGW("Failed to set listen interval %d",
938 listen_interval);
939
Govind Singhd76a5b02016-03-08 15:12:14 +0530940 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 privcmd->param_vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700942 WMI_VDEV_PARAM_DTIM_POLICY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 NORMAL_DTIM);
Govind Singhd76a5b02016-03-08 15:12:14 +0530944 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945 WMA_LOGE("Failed to Set to Normal DTIM policy");
946 }
947}
948
Mukul Sharma6398b252017-05-01 17:58:12 +0530949/**
950 * wma_override_listen_interval() - function to override static/ini based LI
951 * @wma: wma handle
952 * @privcmd: structure containing parameters
953 *
954 * This function override static/ini based LI in firmware
955 *
956 * Return: none
957 */
958static void wma_override_listen_interval(tp_wma_handle wma,
959 wma_cli_set_cmd_t *privcmd)
960{
961 uint8_t vdev_id = privcmd->param_vdev_id;
962 struct wma_txrx_node *iface =
963 &wma->interfaces[vdev_id];
964 u32 old_override_li, new_override_li, listen_interval;
965 struct sAniSirGlobal *mac;
966 QDF_STATUS ret;
967
968 mac = cds_get_context(QDF_MODULE_ID_PE);
969 if (!mac) {
970 WMA_LOGE(FL("Failed to get mac context"));
971 return;
972 }
973
974 old_override_li = iface->override_li;
975 new_override_li = privcmd->param_value;
976 iface->override_li = new_override_li;
977
978 if (new_override_li &&
979 (new_override_li != old_override_li)) {
980 listen_interval = new_override_li;
981 } else if (!new_override_li &&
982 (new_override_li != old_override_li)) {
983 /* Configure default LI as we do on resume */
984 if ((wlan_cfg_get_int(mac, WNI_CFG_LISTEN_INTERVAL,
985 &listen_interval) != eSIR_SUCCESS)) {
986 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_ERROR,
987 "Failed to get value for listen interval");
988 listen_interval = POWERSAVE_DEFAULT_LISTEN_INTERVAL;
989 }
990 } else {
991 return;
992 }
993
994 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
995 WMI_VDEV_PARAM_LISTEN_INTERVAL,
996 listen_interval);
997 if (QDF_IS_STATUS_ERROR(ret)) {
998 /* Even it fails continue Fw will take default LI */
999 WMA_LOGE("Failed to Set Listen Interval vdevId %d",
1000 vdev_id);
1001 }
1002 WMA_LOGD("%s: Set Listen Interval vdevId %d Listen Intv %d",
1003 __func__, vdev_id, listen_interval);
1004 ret = wma_vdev_set_param(wma->wmi_handle,
1005 privcmd->param_vdev_id,
1006 WMI_VDEV_PARAM_DTIM_POLICY,
1007 NORMAL_DTIM);
1008 if (QDF_IS_STATUS_ERROR(ret))
1009 WMA_LOGE("Failed to Set to Normal DTIM policy");
1010
1011}
1012
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013
1014/**
1015 * wma_process_cli_set_cmd() - set parameters to fw
1016 * @wma: wma handle
1017 * @privcmd: command
1018 *
1019 * Return: none
1020 */
1021static void wma_process_cli_set_cmd(tp_wma_handle wma,
1022 wma_cli_set_cmd_t *privcmd)
1023{
Govind Singhd76a5b02016-03-08 15:12:14 +05301024 int vid = privcmd->param_vdev_id, pps_val = 0;
1025 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 struct wma_txrx_node *intr = wma->interfaces;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301027 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 struct qpower_params *qparams = &intr[vid].config.qpower_params;
Govind Singhd76a5b02016-03-08 15:12:14 +05301029 struct pdev_params pdev_param;
Leo Chang96464902016-10-28 11:10:54 -07001030 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031
Jeff Johnsonadba3962017-09-18 08:12:35 -07001032 WMA_LOGD("wmihandle %pK", wma->wmi_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033
1034 if (NULL == pMac) {
1035 WMA_LOGE("%s: Failed to get pMac", __func__);
1036 return;
1037 }
1038
1039 if (privcmd->param_id >= WMI_CMDID_MAX) {
1040 /*
1041 * This configuration setting is not done using any wmi
1042 * command, call appropriate handler.
1043 */
1044 if (wma_set_priv_cfg(wma, privcmd))
1045 WMA_LOGE("Failed to set wma priv congiuration");
1046 return;
1047 }
1048
1049 switch (privcmd->param_vp_dev) {
1050 case VDEV_CMD:
Bhargav Shaha89d3b42016-04-20 13:04:56 +05301051 if (!wma->interfaces[privcmd->param_vdev_id].is_vdev_valid) {
1052 WMA_LOGE("%s Vdev id is not valid", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001053 return;
Bhargav Shaha89d3b42016-04-20 13:04:56 +05301054 }
1055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1057 privcmd->param_id, privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +05301058 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 privcmd->param_vdev_id,
1060 privcmd->param_id,
1061 privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +05301062 if (QDF_IS_STATUS_ERROR(ret)) {
1063 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 ret);
1065 return;
1066 }
1067 break;
1068 case PDEV_CMD:
1069 WMA_LOGD("pdev pid %d pval %d", privcmd->param_id,
1070 privcmd->param_value);
1071 if ((privcmd->param_id == WMI_PDEV_PARAM_RX_CHAIN_MASK) ||
1072 (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK)) {
Jiachao Wu08719b02017-07-05 13:05:34 +08001073 if (QDF_STATUS_SUCCESS !=
1074 wma_check_txrx_chainmask(
1075 wma->num_rf_chains,
1076 privcmd->param_value)) {
1077 WMA_LOGD("Chainmask value is invalid");
1078 return;
1079 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 }
Govind Singhd76a5b02016-03-08 15:12:14 +05301081 pdev_param.param_id = privcmd->param_id;
1082 pdev_param.param_value = privcmd->param_value;
1083 ret = wmi_unified_pdev_param_send(wma->wmi_handle,
1084 &pdev_param,
1085 WMA_WILDCARD_PDEV_ID);
1086 if (QDF_IS_STATUS_ERROR(ret)) {
1087 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 ret);
1089 return;
1090 }
1091 break;
1092 case GEN_CMD:
1093 {
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001094 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 struct wma_txrx_node *intr = wma->interfaces;
1096
1097 vdev = wma_find_vdev_by_id(wma, privcmd->param_vdev_id);
1098 if (!vdev) {
1099 WMA_LOGE("%s:Invalid vdev handle", __func__);
1100 return;
1101 }
1102
1103 WMA_LOGD("gen pid %d pval %d", privcmd->param_id,
1104 privcmd->param_value);
1105
1106 switch (privcmd->param_id) {
1107 case GEN_VDEV_PARAM_AMPDU:
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301108 if (soc) {
1109 ret = cdp_aggr_cfg(soc, vdev,
1110 privcmd->param_value, 0);
1111 if (ret)
1112 WMA_LOGE("cdp_aggr_cfg set ampdu failed ret %d",
1113 ret);
1114 else
1115 intr[privcmd->param_vdev_id].config.
1116 ampdu = privcmd->param_value;
1117 } else {
1118 WMA_LOGE("%s:SOC context is NULL", __func__);
1119 return;
1120 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 break;
1122 case GEN_VDEV_PARAM_AMSDU:
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001123 /*
1124 * Firmware currently does not support set operation
1125 * for AMSDU. It may cause crash if the configuration
1126 * is sent to firmware.
1127 * Firmware enhancement will advertise a service bit
1128 * to enable AMSDU configuration through WMI. Then
1129 * add the WMI command to configure AMSDU parameter.
1130 * For the older chipset that does not advertise the
1131 * service bit, enable the following legacy code:
1132 * ol_txrx_aggr_cfg(vdev, 0, privcmd->param_value);
1133 * intr[privcmd->param_vdev_id].config.amsdu =
1134 * privcmd->param_value;
1135 */
1136 WMA_LOGE("SET GEN_VDEV_PARAM_AMSDU command is currently not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 case GEN_PARAM_CRASH_INJECT:
Rajeev Kumar0a9901b2015-12-15 15:59:19 -08001139 if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
1140 WMA_LOGE("Crash inject not allowed in FTM mode");
1141 else
1142 ret = wma_crash_inject(wma,
1143 privcmd->param_value,
1144 privcmd->param_sec_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001146 case GEN_PARAM_CAPTURE_TSF:
1147 ret = wma_capture_tsf(wma, privcmd->param_value);
1148 break;
1149 case GEN_PARAM_RESET_TSF_GPIO:
1150 ret = wma_reset_tsf_gpio(wma, privcmd->param_value);
1151 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 case GEN_PARAM_MODULATED_DTIM:
1153 wma_set_modulated_dtim(wma, privcmd);
1154 break;
Mukul Sharma6398b252017-05-01 17:58:12 +05301155 case GEN_PARAM_LISTEN_INTERVAL:
1156 wma_override_listen_interval(wma, privcmd);
1157 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 default:
1159 WMA_LOGE("Invalid param id 0x%x",
1160 privcmd->param_id);
1161 break;
1162 }
1163 break;
1164 }
1165 case DBG_CMD:
1166 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1167 privcmd->param_value);
1168 switch (privcmd->param_id) {
1169 case WMI_DBGLOG_LOG_LEVEL:
1170 ret = dbglog_set_log_lvl(wma->wmi_handle,
1171 privcmd->param_value);
1172 if (ret)
1173 WMA_LOGE("dbglog_set_log_lvl failed ret %d",
1174 ret);
1175 break;
1176 case WMI_DBGLOG_VAP_ENABLE:
1177 ret = dbglog_vap_log_enable(wma->wmi_handle,
1178 privcmd->param_value, true);
1179 if (ret)
1180 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1181 ret);
1182 break;
1183 case WMI_DBGLOG_VAP_DISABLE:
1184 ret = dbglog_vap_log_enable(wma->wmi_handle,
1185 privcmd->param_value, false);
1186 if (ret)
1187 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1188 ret);
1189 break;
1190 case WMI_DBGLOG_MODULE_ENABLE:
1191 ret = dbglog_module_log_enable(wma->wmi_handle,
1192 privcmd->param_value, true);
1193 if (ret)
1194 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1195 ret);
1196 break;
1197 case WMI_DBGLOG_MODULE_DISABLE:
1198 ret = dbglog_module_log_enable(wma->wmi_handle,
1199 privcmd->param_value, false);
1200 if (ret)
1201 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1202 ret);
1203 break;
1204 case WMI_DBGLOG_MOD_LOG_LEVEL:
1205 ret = dbglog_set_mod_log_lvl(wma->wmi_handle,
1206 privcmd->param_value);
1207 if (ret)
1208 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1209 ret);
1210 break;
1211 case WMI_DBGLOG_TYPE:
1212 ret = dbglog_parser_type_init(wma->wmi_handle,
1213 privcmd->param_value);
1214 if (ret)
1215 WMA_LOGE("dbglog_parser_type_init failed ret %d",
1216 ret);
1217 break;
1218 case WMI_DBGLOG_REPORT_ENABLE:
1219 ret = dbglog_report_enable(wma->wmi_handle,
1220 privcmd->param_value);
1221 if (ret)
1222 WMA_LOGE("dbglog_report_enable failed ret %d",
1223 ret);
1224 break;
Govind Singha471e5e2015-10-12 17:11:14 +05301225 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301226 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301227 WMI_WLAN_PROFILE_TRIGGER_CMDID,
1228 privcmd->param_value, 0);
1229 if (ret)
1230 WMA_LOGE("Profile cmd failed for %d ret %d",
1231 WMI_WLAN_PROFILE_TRIGGER_CMDID, ret);
1232 break;
1233 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301234 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301235 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1236 privcmd->param_value,
1237 privcmd->param_sec_value);
1238 if (ret)
1239 WMA_LOGE("Profile cmd failed for %d ret %d",
1240 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1241 ret);
1242 break;
1243 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301244 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301245 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1246 privcmd->param_value,
1247 privcmd->param_sec_value);
1248 if (ret)
1249 WMA_LOGE("Profile cmd failed for %d ret %d",
1250 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1251 ret);
1252 break;
1253 case WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301254 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301255 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1256 0, 0);
1257 if (ret)
1258 WMA_LOGE("Profile cmd failed for %d ret %d",
1259 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1260 ret);
1261 break;
1262 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301263 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301264 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1265 0, 0);
1266 if (ret)
1267 WMA_LOGE("Profile cmd failed for %d ret %d",
1268 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1269 ret);
1270 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 case WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID:
1272 /* Set the Green AP */
Govind Singhd76a5b02016-03-08 15:12:14 +05301273 ret = wmi_unified_green_ap_ps_send
1274 (wma->wmi_handle, privcmd->param_value,
1275 WMA_WILDCARD_PDEV_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 if (ret) {
1277 WMA_LOGE("Set GreenAP Failed val %d",
1278 privcmd->param_value);
1279 }
1280 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281
1282 default:
1283 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1284 break;
1285 }
1286 break;
1287 case PPS_CMD:
1288 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1289 privcmd->param_value);
1290 switch (privcmd->param_id) {
1291
1292 case WMI_VDEV_PPS_PAID_MATCH:
1293 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1294 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
1295 intr[vid].config.pps_params.paid_match_enable =
1296 privcmd->param_value;
1297 break;
1298 case WMI_VDEV_PPS_GID_MATCH:
1299 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1300 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
1301 intr[vid].config.pps_params.gid_match_enable =
1302 privcmd->param_value;
1303 break;
1304 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
1305 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1306 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
1307 intr[vid].config.pps_params.tim_clear =
1308 privcmd->param_value;
1309 break;
1310 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
1311 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1312 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
1313 intr[vid].config.pps_params.dtim_clear =
1314 privcmd->param_value;
1315 break;
1316 case WMI_VDEV_PPS_EOF_PAD_DELIM:
1317 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1318 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
1319 intr[vid].config.pps_params.eof_delim =
1320 privcmd->param_value;
1321 break;
1322 case WMI_VDEV_PPS_MACADDR_MISMATCH:
1323 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1324 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
1325 intr[vid].config.pps_params.mac_match =
1326 privcmd->param_value;
1327 break;
1328 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
1329 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1330 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
1331 intr[vid].config.pps_params.delim_fail =
1332 privcmd->param_value;
1333 break;
1334 case WMI_VDEV_PPS_GID_NSTS_ZERO:
1335 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1336 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
1337 intr[vid].config.pps_params.nsts_zero =
1338 privcmd->param_value;
1339 break;
1340 case WMI_VDEV_PPS_RSSI_CHECK:
1341 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1342 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
1343 intr[vid].config.pps_params.rssi_chk =
1344 privcmd->param_value;
1345 break;
1346 case WMI_VDEV_PPS_5G_EBT:
1347 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1348 (PKT_PWR_SAVE_5G_EBT & 0xffff);
1349 intr[vid].config.pps_params.ebt_5g =
1350 privcmd->param_value;
1351 break;
1352 default:
1353 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1354 break;
1355 }
1356 break;
1357
1358 case QPOWER_CMD:
1359 WMA_LOGD("QPOWER CLI CMD pid %d pval %d", privcmd->param_id,
1360 privcmd->param_value);
1361 switch (privcmd->param_id) {
1362 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
1363 WMA_LOGD("QPOWER CLI CMD:Ps Poll Cnt val %d",
1364 privcmd->param_value);
1365 /* Set the QPower Ps Poll Count */
Govind Singhd76a5b02016-03-08 15:12:14 +05301366 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 vid, WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
1368 privcmd->param_value);
1369 if (ret) {
1370 WMA_LOGE("Set Q-PsPollCnt Failed vdevId %d val %d",
1371 vid, privcmd->param_value);
1372 } else {
1373 qparams->max_ps_poll_cnt = privcmd->param_value;
1374 }
1375 break;
1376 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
1377 WMA_LOGD("QPOWER CLI CMD:Max Tx Before wake val %d",
1378 privcmd->param_value);
1379 /* Set the QPower Max Tx Before Wake */
Govind Singhd76a5b02016-03-08 15:12:14 +05301380 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 vid, WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
1382 privcmd->param_value);
1383 if (ret) {
1384 WMA_LOGE("Set Q-MaxTxBefWake Failed vId %d val %d",
1385 vid, privcmd->param_value);
1386 } else {
1387 qparams->max_tx_before_wake =
1388 privcmd->param_value;
1389 }
1390 break;
1391 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
1392 WMA_LOGD("QPOWER CLI CMD:Ps Poll Wake Inv val %d",
1393 privcmd->param_value);
1394 /* Set the QPower Spec Ps Poll Wake Inv */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001395 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1396 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 privcmd->param_value);
1398 if (ret) {
1399 WMA_LOGE("Set Q-PsPoll WakeIntv Failed vId %d val %d",
1400 vid, privcmd->param_value);
1401 } else {
1402 qparams->spec_ps_poll_wake_interval =
1403 privcmd->param_value;
1404 }
1405 break;
1406 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
1407 WMA_LOGD("QPOWER CLI CMD:Spec NoData Ps Poll val %d",
1408 privcmd->param_value);
1409 /* Set the QPower Spec NoData PsPoll */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001410 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1411 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412 privcmd->param_value);
1413 if (ret) {
1414 WMA_LOGE("Set Q-SpecNoDataPsPoll Failed vId %d val %d",
1415 vid, privcmd->param_value);
1416 } else {
1417 qparams->max_spec_nodata_ps_poll =
1418 privcmd->param_value;
1419 }
1420 break;
1421
1422 default:
1423 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1424 break;
1425 }
1426 break;
1427 case GTX_CMD:
1428 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1429 privcmd->param_id, privcmd->param_value);
1430 switch (privcmd->param_id) {
1431 case WMI_VDEV_PARAM_GTX_HT_MCS:
1432 intr[vid].config.gtx_info.gtxRTMask[0] =
1433 privcmd->param_value;
1434 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1435 privcmd->param_vdev_id,
1436 &intr[vid].config.gtx_info);
1437 break;
1438 case WMI_VDEV_PARAM_GTX_VHT_MCS:
1439 intr[vid].config.gtx_info.gtxRTMask[1] =
1440 privcmd->param_value;
1441 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1442 privcmd->param_vdev_id,
1443 &intr[vid].config.gtx_info);
1444 break;
1445
1446 case WMI_VDEV_PARAM_GTX_USR_CFG:
1447 intr[vid].config.gtx_info.gtxUsrcfg =
1448 privcmd->param_value;
1449 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1450 privcmd->param_vdev_id,
1451 &intr[vid].config.gtx_info);
1452 break;
1453
1454 case WMI_VDEV_PARAM_GTX_THRE:
1455 intr[vid].config.gtx_info.gtxPERThreshold =
1456 privcmd->param_value;
1457 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1458 privcmd->param_vdev_id,
1459 &intr[vid].config.gtx_info);
1460 break;
1461
1462 case WMI_VDEV_PARAM_GTX_MARGIN:
1463 intr[vid].config.gtx_info.gtxPERMargin =
1464 privcmd->param_value;
1465 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1466 privcmd->param_vdev_id,
1467 &intr[vid].config.gtx_info);
1468 break;
1469
1470 case WMI_VDEV_PARAM_GTX_STEP:
1471 intr[vid].config.gtx_info.gtxTPCstep =
1472 privcmd->param_value;
1473 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1474 privcmd->param_vdev_id,
1475 &intr[vid].config.gtx_info);
1476 break;
1477
1478 case WMI_VDEV_PARAM_GTX_MINTPC:
1479 intr[vid].config.gtx_info.gtxTPCMin =
1480 privcmd->param_value;
1481 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1482 privcmd->param_vdev_id,
1483 &intr[vid].config.gtx_info);
1484 break;
1485
1486 case WMI_VDEV_PARAM_GTX_BW_MASK:
1487 intr[vid].config.gtx_info.gtxBWMask =
1488 privcmd->param_value;
1489 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1490 privcmd->param_vdev_id,
1491 &intr[vid].config.gtx_info);
1492 if (ret) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001493 WMA_LOGE("wma_vdev_set_param failed ret %d",
1494 ret);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495 return;
1496 }
1497 break;
1498 default:
1499 break;
1500 }
1501 break;
1502
1503 default:
1504 WMA_LOGE("Invalid vpdev command id");
1505 }
1506 if (1 == privcmd->param_vp_dev) {
1507 switch (privcmd->param_id) {
1508 case WMI_VDEV_PARAM_NSS:
1509 intr[vid].config.nss = privcmd->param_value;
1510 break;
1511 case WMI_VDEV_PARAM_LDPC:
1512 intr[vid].config.ldpc = privcmd->param_value;
1513 break;
1514 case WMI_VDEV_PARAM_TX_STBC:
1515 intr[vid].config.tx_stbc = privcmd->param_value;
1516 break;
1517 case WMI_VDEV_PARAM_RX_STBC:
1518 intr[vid].config.rx_stbc = privcmd->param_value;
1519 break;
1520 case WMI_VDEV_PARAM_SGI:
1521 intr[vid].config.shortgi = privcmd->param_value;
1522 break;
1523 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
1524 intr[vid].config.rtscts_en = privcmd->param_value;
1525 break;
1526 case WMI_VDEV_PARAM_CHWIDTH:
1527 intr[vid].config.chwidth = privcmd->param_value;
1528 break;
1529 case WMI_VDEV_PARAM_FIXED_RATE:
1530 intr[vid].config.tx_rate = privcmd->param_value;
1531 break;
1532 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE:
1533 intr[vid].config.erx_adjust = privcmd->param_value;
1534 break;
1535 case WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM:
1536 intr[vid].config.erx_bmiss_num = privcmd->param_value;
1537 break;
1538 case WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE:
1539 intr[vid].config.erx_bmiss_cycle = privcmd->param_value;
1540 break;
1541 case WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP:
1542 intr[vid].config.erx_slop_step = privcmd->param_value;
1543 break;
1544 case WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP:
1545 intr[vid].config.erx_init_slop = privcmd->param_value;
1546 break;
1547 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE:
1548 intr[vid].config.erx_adj_pause = privcmd->param_value;
1549 break;
1550 case WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE:
1551 intr[vid].config.erx_dri_sample = privcmd->param_value;
1552 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001553 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001554 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001555 wma_set_he_vdev_param(&intr[vid], privcmd->param_id,
1556 privcmd->param_value);
1557 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001559 WMA_LOGE("Invalid wma_cli_set vdev command/Not yet implemented 0x%x",
1560 privcmd->param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561 break;
1562 }
1563 } else if (2 == privcmd->param_vp_dev) {
1564 switch (privcmd->param_id) {
1565 case WMI_PDEV_PARAM_ANI_ENABLE:
1566 wma->pdevconfig.ani_enable = privcmd->param_value;
1567 break;
1568 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
1569 wma->pdevconfig.ani_poll_len = privcmd->param_value;
1570 break;
1571 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
1572 wma->pdevconfig.ani_listen_len = privcmd->param_value;
1573 break;
1574 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
1575 wma->pdevconfig.ani_ofdm_level = privcmd->param_value;
1576 break;
1577 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
1578 wma->pdevconfig.ani_cck_level = privcmd->param_value;
1579 break;
1580 case WMI_PDEV_PARAM_DYNAMIC_BW:
1581 wma->pdevconfig.cwmenable = privcmd->param_value;
1582 break;
1583 case WMI_PDEV_PARAM_CTS_CBW:
1584 wma->pdevconfig.cts_cbw = privcmd->param_value;
1585 break;
1586 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
1587 wma->pdevconfig.txchainmask = privcmd->param_value;
1588 break;
1589 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
1590 wma->pdevconfig.rxchainmask = privcmd->param_value;
1591 break;
1592 case WMI_PDEV_PARAM_BURST_ENABLE:
1593 wma->pdevconfig.burst_enable = privcmd->param_value;
1594 if ((wma->pdevconfig.burst_enable == 1) &&
1595 (wma->pdevconfig.burst_dur == 0))
1596 wma->pdevconfig.burst_dur =
1597 WMA_DEFAULT_SIFS_BURST_DURATION;
1598 else if (wma->pdevconfig.burst_enable == 0)
1599 wma->pdevconfig.burst_dur = 0;
1600 break;
1601 case WMI_PDEV_PARAM_BURST_DUR:
1602 wma->pdevconfig.burst_dur = privcmd->param_value;
1603 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
1605 wma->pdevconfig.txpow2g = privcmd->param_value;
1606 if ((pMac->roam.configParam.bandCapability ==
1607 eCSR_BAND_ALL) ||
1608 (pMac->roam.configParam.bandCapability ==
1609 eCSR_BAND_24)) {
1610 if (cfg_set_int(pMac,
1611 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1612 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301613 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1615
1616 } else {
1617 WMA_LOGE("Current band is not 2G");
1618 }
1619 break;
1620 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
1621 wma->pdevconfig.txpow5g = privcmd->param_value;
1622 if ((pMac->roam.configParam.bandCapability ==
1623 eCSR_BAND_ALL) ||
1624 (pMac->roam.configParam.bandCapability ==
1625 eCSR_BAND_5G)) {
1626 if (cfg_set_int(pMac,
1627 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1628 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301629 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1631
1632 } else {
1633 WMA_LOGE("Current band is not 5G");
1634 }
1635 break;
1636 default:
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001637 WMA_LOGD("Invalid wma_cli_set pdev command/Not yet implemented 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 privcmd->param_id);
1639 break;
1640 }
1641 } else if (5 == privcmd->param_vp_dev) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301642 ret = wma_vdev_set_param(wma->wmi_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001643 privcmd->param_vdev_id,
1644 WMI_VDEV_PARAM_PACKET_POWERSAVE,
1645 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 if (ret)
1647 WMA_LOGE("Failed to send wmi packet power save cmd");
1648 else
1649 WMA_LOGD("Sent packet power save cmd %d value %x to target",
1650 privcmd->param_id, pps_val);
1651 }
1652}
1653
1654/**
1655 * wma_process_fw_event() - process any fw event
1656 * @wma: wma handle
1657 * @buf: fw event buffer
1658 *
1659 * This function process any fw event to serialize it through mc thread.
1660 *
1661 * Return: none
1662 */
1663static int wma_process_fw_event(tp_wma_handle wma,
1664 wma_process_fw_event_params *buf)
1665{
1666 struct wmi_unified *wmi_handle = (struct wmi_unified *)buf->wmi_handle;
1667
1668 wmi_process_fw_event(wmi_handle, buf->evt_buf);
1669 return 0;
1670}
1671
1672/**
Govind Singhd76a5b02016-03-08 15:12:14 +05301673 * wmi_process_fw_event_tasklet_ctx() - process in tasklet context
1674 * @ctx: handle to wmi
1675 * @ev: wmi event buffer
1676 *
1677 * Event process by below function will be in tasket context,
1678 * need to use this method only for time sensitive functions.
1679 *
1680 * Return: none
1681 */
1682static int wma_process_fw_event_tasklet_ctx(void *ctx, void *ev)
1683{
1684 wmi_process_fw_event(ctx, ev);
1685
1686 return 0;
1687}
1688
1689/**
Manjeet Singhf82ed072016-07-08 11:40:00 +05301690 * wma_process_hal_pwr_dbg_cmd() - send hal pwr dbg cmd to fw.
1691 * @handle: wma handle
1692 * @sir_pwr_dbg_params: unit test command
1693 *
1694 * This function send unit test command to fw.
1695 *
1696 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
1697 */
1698QDF_STATUS wma_process_hal_pwr_dbg_cmd(WMA_HANDLE handle,
1699 struct sir_mac_pwr_dbg_cmd *
1700 sir_pwr_dbg_params)
1701{
1702 tp_wma_handle wma_handle = (tp_wma_handle)handle;
1703 int i;
1704 struct wmi_power_dbg_params wmi_pwr_dbg_params;
1705 QDF_STATUS status;
1706
1707 if (!sir_pwr_dbg_params) {
1708 WMA_LOGE("%s: sir_pwr_dbg_params is null", __func__);
1709 return QDF_STATUS_E_INVAL;
1710 }
1711 wmi_pwr_dbg_params.module_id = sir_pwr_dbg_params->module_id;
1712 wmi_pwr_dbg_params.pdev_id = sir_pwr_dbg_params->pdev_id;
1713 wmi_pwr_dbg_params.num_args = sir_pwr_dbg_params->num_args;
1714
1715 for (i = 0; i < wmi_pwr_dbg_params.num_args; i++)
1716 wmi_pwr_dbg_params.args[i] = sir_pwr_dbg_params->args[i];
1717
1718 status = wmi_unified_send_power_dbg_cmd(wma_handle->wmi_handle,
1719 &wmi_pwr_dbg_params);
1720
1721 return status;
1722}
1723
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001724static void wma_discard_fw_event(struct scheduler_msg *msg)
1725{
1726 switch (msg->type) {
1727 case WMA_PROCESS_FW_EVENT:
1728 qdf_nbuf_free(((wma_process_fw_event_params *)msg->bodyptr)
1729 ->evt_buf);
1730 break;
Abhishek Singhcaf6a652017-07-06 17:35:42 +05301731 case WMA_SET_LINK_STATE:
1732 qdf_mem_free(((tpLinkStateParams) msg->bodyptr)->callbackArg);
1733 break;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001734 }
1735 if (msg->bodyptr)
1736 qdf_mem_free(msg->bodyptr);
1737 msg->bodyptr = NULL;
1738 msg->bodyval = 0;
1739 msg->type = 0;
1740}
1741
Manjeet Singhf82ed072016-07-08 11:40:00 +05301742/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 * wma_process_fw_event_handler() - common event handler to serialize
1744 * event processing through mc_thread
Govind Singhd76a5b02016-03-08 15:12:14 +05301745 * @ctx: wmi context
1746 * @ev: event buffer
1747 * @rx_ctx: rx execution context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 *
1749 * Return: 0 on success, errno on failure
1750 */
Govind Singhd76a5b02016-03-08 15:12:14 +05301751static int wma_process_fw_event_mc_thread_ctx(void *ctx, void *ev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001752{
1753 wma_process_fw_event_params *params_buf;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001754 struct scheduler_msg cds_msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301756 params_buf = qdf_mem_malloc(sizeof(wma_process_fw_event_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 if (!params_buf) {
1758 WMA_LOGE("%s: Failed alloc memory for params_buf", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301759 qdf_nbuf_free(ev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 return -ENOMEM;
1761 }
1762
Govind Singhd76a5b02016-03-08 15:12:14 +05301763 params_buf->wmi_handle = (struct wmi_unified *)ctx;
1764 params_buf->evt_buf = (wmi_buf_t *)ev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765
1766 cds_msg.type = WMA_PROCESS_FW_EVENT;
1767 cds_msg.bodyptr = params_buf;
1768 cds_msg.bodyval = 0;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001769 cds_msg.flush_callback = wma_discard_fw_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301771 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001772 scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001773 WMA_LOGE("%s: Failed to post WMA_PROCESS_FW_EVENT msg",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301775 qdf_nbuf_free(ev);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301776 qdf_mem_free(params_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 return -EFAULT;
1778 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 return 0;
1780
1781}
1782
Govind Singhd76a5b02016-03-08 15:12:14 +05301783/**
1784 * wma_process_fw_event_handler() - common event handler to serialize
1785 * event processing through mc_thread
1786 * @ctx: wmi context
1787 * @ev: event buffer
1788 * @rx_ctx: rx execution context
1789 *
1790 * Return: 0 on success, errno on failure
1791 */
1792int wma_process_fw_event_handler(void *ctx, void *ev, uint8_t rx_ctx)
1793{
1794 int err = 0;
1795
1796 if (rx_ctx == WMA_RX_SERIALIZER_CTX) {
1797 err = wma_process_fw_event_mc_thread_ctx(ctx, ev);
1798 } else if (rx_ctx == WMA_RX_TASKLET_CTX) {
1799 wma_process_fw_event_tasklet_ctx(ctx, ev);
1800 } else {
1801 WMA_LOGE("%s: invalid wmi event execution context", __func__);
1802 qdf_nbuf_free(ev);
1803 }
1804
1805 return err;
1806}
1807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808#ifdef WLAN_FEATURE_NAN
1809/**
1810 * wma_set_nan_enable() - set nan enable flag in WMA handle
1811 * @wma_handle: Pointer to wma handle
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301812 * @cds_cfg: Pointer to CDS Configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 *
1814 * Return: none
1815 */
1816static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301817 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818{
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301819 wma_handle->is_nan_enabled = cds_cfg->is_nan_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820}
1821#else
1822static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301823 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824{
1825}
1826#endif
1827
1828/**
Komal Seelam02d09342016-02-23 18:03:19 +05301829 * wma_init_max_no_of_peers - API to initialize wma configuration params
1830 * @wma_handle: WMA Handle
1831 * @max_peers: Max Peers supported
1832 *
1833 * Return: void
1834 */
1835static void wma_init_max_no_of_peers(tp_wma_handle wma_handle,
1836 uint16_t max_peers)
1837{
1838 struct wma_ini_config *cfg = wma_get_ini_handle(wma_handle);
1839
Naveen Rawat35804772016-06-27 15:40:28 -07001840 if (cfg == NULL) {
1841 WMA_LOGE("%s: NULL WMA ini handle", __func__);
1842 return;
1843 }
1844
Komal Seelam02d09342016-02-23 18:03:19 +05301845 cfg->max_no_of_peers = max_peers;
1846}
1847
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001848/**
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001849 * wma_cleanup_vdev_resp_queue() - cleanup vdev response queue
1850 * @wma: wma handle
1851 *
1852 * Return: none
1853 */
1854static void wma_cleanup_vdev_resp_queue(tp_wma_handle wma)
1855{
1856 struct wma_target_req *req_msg = NULL;
1857 qdf_list_node_t *node1 = NULL;
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001858
1859 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1860 if (!qdf_list_size(&wma->vdev_resp_queue)) {
1861 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08001862 WMA_LOGD(FL("request queue maybe empty"));
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001863 return;
1864 }
1865
Wu Gao30f65eb2017-08-09 19:56:10 +08001866 /* peek front, and then cleanup it in wma_vdev_resp_timer */
1867 while (qdf_list_peek_front(&wma->vdev_resp_queue, &node1) ==
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001868 QDF_STATUS_SUCCESS) {
1869 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001870 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Abhishek Singhc614ec42017-04-25 16:17:34 +05301871 qdf_mc_timer_stop(&req_msg->event_timeout);
1872 wma_vdev_resp_timer(req_msg);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001873 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1874 }
1875 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
1876}
1877
1878/**
Abhishek Singhc614ec42017-04-25 16:17:34 +05301879 * wma_cleanup_hold_req() - cleanup hold request queue
1880 * @wma: wma handle
1881 *
1882 * Return: none
1883 */
1884static void wma_cleanup_hold_req(tp_wma_handle wma)
1885{
1886 struct wma_target_req *req_msg = NULL;
1887 qdf_list_node_t *node1 = NULL;
1888
1889 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
1890 if (!qdf_list_size(&wma->wma_hold_req_queue)) {
1891 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1892 WMA_LOGD(FL("request queue is empty"));
1893 return;
1894 }
1895
Wu Gao30f65eb2017-08-09 19:56:10 +08001896 /* peek front, and then cleanup it in wma_hold_req_timer */
Abhishek Singhc614ec42017-04-25 16:17:34 +05301897 while (QDF_STATUS_SUCCESS ==
Wu Gao30f65eb2017-08-09 19:56:10 +08001898 qdf_list_peek_front(&wma->wma_hold_req_queue, &node1)) {
Abhishek Singhc614ec42017-04-25 16:17:34 +05301899 req_msg = qdf_container_of(node1, struct wma_target_req, node);
1900 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1901 /* Cleanup timeout handler */
1902 qdf_mc_timer_stop(&req_msg->event_timeout);
Abhishek Singhc614ec42017-04-25 16:17:34 +05301903 wma_hold_req_timer(req_msg);
1904 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
1905 }
1906 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1907}
1908
1909/**
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001910 * wma_shutdown_notifier_cb - Shutdown notifer call back
1911 * @priv : WMA handle
1912 *
1913 * During recovery, WMA may wait for resume to complete if the crash happens
1914 * while in suspend. This may cause delays in completing the recovery. This call
1915 * back would be called during recovery and the event is completed so that if
1916 * the resume is waiting on FW to respond then it can get out of the wait so
1917 * that recovery thread can start bringing down all the modules.
1918 *
1919 * Return: None
1920 */
1921static void wma_shutdown_notifier_cb(void *priv)
1922{
1923 tp_wma_handle wma_handle = priv;
1924
1925 qdf_event_set(&wma_handle->wma_resume_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001926 wma_cleanup_vdev_resp_queue(wma_handle);
Abhishek Singhc614ec42017-04-25 16:17:34 +05301927 wma_cleanup_hold_req(wma_handle);
Mukul Sharma4c60a7e2017-03-06 19:42:18 +05301928 pmo_ucfg_psoc_wakeup_host_event_received(wma_handle->psoc);
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001929}
1930
Mukul Sharma5ff3c582016-09-12 15:23:35 +05301931struct wma_version_info g_wmi_version_info;
1932
Komal Seelam02d09342016-02-23 18:03:19 +05301933/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301934 * wma_state_info_dump() - prints state information of wma layer
1935 * @buf: buffer pointer
1936 * @size: size of buffer to be filled
1937 *
1938 * This function is used to dump state information of wma layer
1939 *
1940 * Return: None
1941 */
1942static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
1943{
Dustin Brown9d797d62017-01-11 16:39:12 -08001944 t_wma_handle *wma;
1945 struct sir_vdev_wow_stats *stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301946 uint16_t len = 0;
1947 char *buf = *buf_ptr;
1948 struct wma_txrx_node *iface;
1949 uint8_t vdev_id;
1950
Dustin Brown9d797d62017-01-11 16:39:12 -08001951 wma = cds_get_context(QDF_MODULE_ID_WMA);
1952 if (!wma) {
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301953 WMA_LOGE("%s: WMA context is invald!", __func__);
1954 return;
1955 }
1956
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001957 WMA_LOGE("%s: size of buffer: %d", __func__, *size);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301958
Dustin Brown9d797d62017-01-11 16:39:12 -08001959 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
1960 iface = &wma->interfaces[vdev_id];
1961 if (!iface->handle)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301962 continue;
1963
Dustin Brown9d797d62017-01-11 16:39:12 -08001964 stats = &iface->wow_stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301965 len += qdf_scnprintf(buf + len, *size - len,
Dustin Brown9d797d62017-01-11 16:39:12 -08001966 "\n"
1967 "vdev_id %d\n"
1968 "WoW Stats\n"
1969 "\tpno_match %u\n"
1970 "\tpno_complete %u\n"
1971 "\tgscan %u\n"
1972 "\tlow_rssi %u\n"
1973 "\trssi_breach %u\n"
1974 "\tucast %u\n"
1975 "\tbcast %u\n"
1976 "\ticmpv4 %u\n"
1977 "\ticmpv6 %u\n"
1978 "\tipv4_mcast %u\n"
1979 "\tipv6_mcast %u\n"
1980 "\tipv6_mcast_ra %u\n"
1981 "\tipv6_mcast_ns %u\n"
1982 "\tipv6_mcast_na %u\n"
1983 "\toem_response %u\n"
1984 "conn_state %d\n"
1985 "dtimPeriod %d\n"
1986 "chanmode %d\n"
1987 "vht_capable %d\n"
1988 "ht_capable %d\n"
1989 "chan_width %d\n"
1990 "vdev_active %d\n"
1991 "vdev_up %d\n"
1992 "aid %d\n"
1993 "rate_flags %d\n"
1994 "nss %d\n"
1995 "tx_power %d\n"
1996 "max_tx_power %d\n"
1997 "nwType %d\n"
1998 "tx_streams %d\n"
1999 "rx_streams %d\n"
2000 "chain_mask %d\n"
2001 "nss_2g %d\n"
2002 "nss_5g %d",
2003 vdev_id,
2004 stats->pno_match,
2005 stats->pno_complete,
2006 stats->gscan,
2007 stats->low_rssi,
2008 stats->rssi_breach,
2009 stats->ucast,
2010 stats->bcast,
2011 stats->icmpv4,
2012 stats->icmpv6,
2013 stats->ipv4_mcast,
2014 stats->ipv6_mcast,
2015 stats->ipv6_mcast_ra,
2016 stats->ipv6_mcast_ns,
2017 stats->ipv6_mcast_na,
2018 stats->oem_response,
2019 iface->conn_state,
2020 iface->dtimPeriod,
2021 iface->chanmode,
2022 iface->vht_capable,
2023 iface->ht_capable,
2024 iface->chan_width,
2025 iface->vdev_active,
Mukul Sharmaf9047232017-03-02 16:58:56 +05302026 wma_is_vdev_up(vdev_id),
Dustin Brown9d797d62017-01-11 16:39:12 -08002027 iface->aid,
2028 iface->rate_flags,
2029 iface->nss,
2030 iface->tx_power,
2031 iface->max_tx_power,
2032 iface->nwType,
2033 iface->tx_streams,
2034 iface->rx_streams,
2035 iface->chain_mask,
2036 iface->nss_2g,
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302037 iface->nss_5g);
2038 }
2039
2040 *size -= len;
2041 *buf_ptr += len;
2042}
2043
2044/**
2045 * wma_register_debug_callback() - registration function for wma layer
2046 * to print wma state information
2047 */
2048static void wma_register_debug_callback(void)
2049{
2050 qdf_register_debug_callback(QDF_MODULE_ID_WMA, &wma_state_info_dump);
2051}
2052
Frank Liu65b17d92016-11-23 15:58:44 +08002053/**
2054 * wma_register_tx_ops_handler() - register tx_ops of southbound
2055 * @tx_ops: tx_ops pointer in southbound
2056 *
2057 * Return: 0 on success, errno on failure
2058 */
2059static QDF_STATUS
2060wma_register_tx_ops_handler(struct wlan_lmac_if_tx_ops *tx_ops)
2061{
2062 /*
2063 * Assign tx_ops, it's up to UMAC modules to declare and define these
2064 * functions which are used to send wmi command to target.
2065 */
2066
Himanshu Agarwalce716f82016-12-21 19:07:54 +05302067 if (!tx_ops) {
2068 WMA_LOGE("%s: pointer to lmac if tx ops is NULL", __func__);
2069 return QDF_STATUS_E_INVAL;
2070 }
2071
2072 /* mgmt_txrx component's tx ops */
2073 tx_ops->mgmt_txrx_tx_ops.mgmt_tx_send = wma_mgmt_unified_cmd_send;
2074
Frank Liu65b17d92016-11-23 15:58:44 +08002075 return QDF_STATUS_SUCCESS;
2076}
2077
2078/**
2079 * wma_target_if_open() - Attach UMAC modules' interface with wmi layer
2080 * @wma_handle: wma handle
2081 *
2082 * Separate module defines below functions:
2083 * 1. tgt_wmi_<module>_<action> api sends wmi command, assigned to south bound
2084 * tx_ops function pointers;
2085 * 2. module's south dispatcher handles information from lower layer, assigned
2086 * to south bound rx_ops function pointers;
2087 * 3. wmi event handler deals with wmi event, extracts umac needed information,
2088 * and call rx_ops(module's dispatcher). It executes in tasklet context and
2089 * is up to dispatcher to decide the context to reside in tasklet or in
2090 * thread context.
2091 *
2092 * Return: None
2093 */
2094static void wma_target_if_open(tp_wma_handle wma_handle)
2095{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302096 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002097
2098 if (!psoc)
2099 return;
2100
Mukul Sharmadad267e2017-02-04 13:25:34 +05302101 wlan_global_lmac_if_set_txops_registration_cb(WLAN_DEV_OL,
2102 target_if_register_tx_ops);
2103 wlan_lmac_if_set_umac_txops_registration_cb(
2104 wma_register_tx_ops_handler);
2105 wlan_global_lmac_if_open(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002106
Frank Liu65b17d92016-11-23 15:58:44 +08002107}
2108
2109/**
2110 * wma_target_if_close() - Detach UMAC modules' interface with wmi layer
2111 * @wma_handle: wma handle
2112 *
2113 * Return: None
2114 */
2115static void wma_target_if_close(tp_wma_handle wma_handle)
2116{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302117 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002118
2119 if (!psoc)
2120 return;
2121
Mukul Sharmadad267e2017-02-04 13:25:34 +05302122 wlan_global_lmac_if_close(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002123}
Frank Liu65b17d92016-11-23 15:58:44 +08002124
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302125/**
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302126 * wma_get_psoc_from_scn_handle() - API to get psoc from scn handle
2127 * @scn_handle: opaque wma handle
2128 *
2129 * API to get psoc from scn handle
2130 *
2131 * Return: None
2132 */
2133static struct wlan_objmgr_psoc *wma_get_psoc_from_scn_handle(void *scn_handle)
2134{
2135 tp_wma_handle wma_handle;
2136
2137 if (!scn_handle) {
2138 WMA_LOGE("invalid scn handle");
2139 return NULL;
2140 }
2141 wma_handle = (tp_wma_handle)scn_handle;
2142
2143 return wma_handle->psoc;
2144}
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002145/**
2146 * wma_legacy_service_ready_event_handler() - legacy (ext)service ready handler
2147 * @event_id: event_id
2148 * @handle: wma handle
2149 * @event_data: event data
2150 * @length: event length
2151 *
2152 * Return: 0 for success, negative error code for failure
2153 */
2154static int wma_legacy_service_ready_event_handler(uint32_t event_id,
2155 void *handle,
2156 uint8_t *event_data,
2157 uint32_t length)
2158{
2159 if (wmi_service_ready_event_id == event_id)
2160 return wma_rx_service_ready_event(handle, event_data, length);
2161 else if (wmi_service_ready_ext_event_id == event_id)
2162 return wma_rx_service_ready_ext_event(handle, event_data,
2163 length);
2164 else
2165 QDF_BUG(0);
2166
2167 return 0;
2168}
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302169
2170/**
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002171 * wma_flush_complete_evt_handler() - FW log flush complete event handler
2172 * @handle: WMI handle
2173 * @event: Event recevied from FW
2174 * @len: Length of the event
2175 *
2176 */
2177static int wma_flush_complete_evt_handler(void *handle,
2178 u_int8_t *event,
2179 u_int32_t len)
2180{
2181 QDF_STATUS status;
2182 tp_wma_handle wma = (tp_wma_handle) handle;
2183
2184 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *param_buf;
2185 wmi_debug_mesg_flush_complete_fixed_param *wmi_event;
2186 uint32_t reason_code;
2187
2188 param_buf = (WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *) event;
2189 if (!param_buf) {
2190 WMA_LOGE("Invalid log flush complete event buffer");
2191 return QDF_STATUS_E_FAILURE;
2192 }
2193
2194 wmi_event = param_buf->fixed_param;
2195 reason_code = wmi_event->reserved0;
2196
2197 /*
2198 * reason_code = 0; Flush event in response to flush command
2199 * reason_code = other value; Asynchronous flush event for fatal events
2200 */
2201 if (!reason_code && (cds_is_log_report_in_progress() == false)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002202 WMA_LOGD("Received WMI flush event without sending CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002203 return -EINVAL;
2204 } else if (!reason_code && cds_is_log_report_in_progress() == true) {
2205 /* Flush event in response to flush command */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002206 WMA_LOGD("Received WMI flush event in response to flush CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002207 status = qdf_mc_timer_stop(&wma->log_completion_timer);
2208 if (status != QDF_STATUS_SUCCESS)
2209 WMA_LOGE("Failed to stop the log completion timeout");
2210 cds_logging_set_fw_flush_complete();
2211 } else if (reason_code && cds_is_log_report_in_progress() == false) {
2212 /* Asynchronous flush event for fatal events */
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002213 status = cds_set_log_completion(WLAN_LOG_TYPE_FATAL,
2214 WLAN_LOG_INDICATOR_FIRMWARE,
2215 reason_code, false);
2216 if (QDF_STATUS_SUCCESS != status) {
2217 WMA_LOGE("%s: Failed to set log trigger params",
2218 __func__);
2219 return QDF_STATUS_E_FAILURE;
2220 }
2221 cds_logging_set_fw_flush_complete();
2222 return status;
2223 } else {
2224 /* Asynchronous flush event for fatal event,
2225 * but, report in progress already
2226 */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002227 WMA_LOGD("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002228 __func__, WLAN_LOG_TYPE_FATAL,
2229 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2230 return QDF_STATUS_E_FAILURE;
2231 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07002232 /* Asynchronous flush event for fatal event,
2233 * but, report in progress already
2234 */
2235 WMA_LOGW("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
2236 __func__, WLAN_LOG_TYPE_FATAL,
2237 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2238 return QDF_STATUS_E_FAILURE;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002239}
2240
Arif Hussainf63f7a32017-08-22 12:49:42 -07002241/**
2242 * wma_unified_phyerr_rx_event_handler() - phyerr event handler
2243 * @handle: wma handle
2244 * @data: data buffer
2245 * @datalen: buffer length
2246 *
2247 * WMI Handler for WMI_PHYERR_EVENTID event from firmware.
2248 * This handler is currently handling DFS and spectral scan
2249 * phy errors.
2250 *
2251 * Return: 0 for success, other value for failure
2252 */
2253static int wma_unified_phyerr_rx_event_handler(void *handle,
2254 uint8_t *data, uint32_t datalen) {
2255 /* phyerr handling is moved to cmn project
2256 * As WIN still uses handler registration in non-cmn code.
2257 * need complete testing of non offloaded DFS code before we enable
2258 * it in cmn code.
2259 **/
2260 return QDF_STATUS_SUCCESS;
2261}
2262
Dustin Brownec2c92e2017-07-26 11:13:49 -07002263void wma_vdev_init(struct wma_txrx_node *vdev)
2264{
2265 qdf_wake_lock_create(&vdev->vdev_start_wakelock, "vdev_start");
2266 qdf_wake_lock_create(&vdev->vdev_stop_wakelock, "vdev_stop");
2267}
2268
2269void wma_vdev_deinit(struct wma_txrx_node *vdev)
2270{
2271 qdf_wake_lock_destroy(&vdev->vdev_start_wakelock);
2272 qdf_wake_lock_destroy(&vdev->vdev_stop_wakelock);
2273}
2274
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002275/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 * wma_open() - Allocate wma context and initialize it.
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302277 * @psoc: Psoc pointer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278 * @wma_tgt_cfg_cb: tgt config callback fun
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302279 * @cds_cfg: mac parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 *
2281 * Return: 0 on success, errno on failure
2282 */
Jeff Johnsonff6addf2017-09-13 10:06:03 -07002283QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 wma_tgt_cfg_cb tgt_cfg_cb,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302285 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286{
2287 tp_wma_handle wma_handle;
2288 HTC_HANDLE htc_handle;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302289 qdf_device_t qdf_dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 void *wmi_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302291 QDF_STATUS qdf_status;
Govind Singhd76a5b02016-03-08 15:12:14 +05302292 struct wmi_rx_ops ops;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07002293 struct policy_mgr_wma_cbacks wma_cbacks;
Frank Liu00d73fe2017-05-19 22:11:28 +08002294 struct target_psoc_info *tgt_psoc_info;
Govind Singhd76a5b02016-03-08 15:12:14 +05302295 bool use_cookie = false;
Dustin Brownec2c92e2017-07-26 11:13:49 -07002296 int i;
Jeff Johnsonff6addf2017-09-13 10:06:03 -07002297 void *cds_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298
2299 WMA_LOGD("%s: Enter", __func__);
2300
Jeff Johnsonff6addf2017-09-13 10:06:03 -07002301 cds_context = cds_get_global_context();
2302 if (!cds_context) {
2303 WMA_LOGE("%s: Invalid CDS context", __func__);
2304 return QDF_STATUS_E_INVAL;
2305 }
2306
Mukul Sharma5ff3c582016-09-12 15:23:35 +05302307 g_wmi_version_info.major = __WMI_VER_MAJOR_;
2308 g_wmi_version_info.minor = __WMI_VER_MINOR_;
2309 g_wmi_version_info.revision = __WMI_REVISION_;
2310
Anurag Chouhan6d760662016-02-20 16:05:43 +05302311 qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
2312 htc_handle = cds_get_context(QDF_MODULE_ID_HTC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313
2314 if (!htc_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002315 WMA_LOGE("%s: Invalid HTC handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302316 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 }
2318
2319 /* Alloc memory for WMA Context */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07002320 qdf_status = cds_alloc_context(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 (void **)&wma_handle,
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07002322 sizeof(*wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302324 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002325 WMA_LOGE("%s: Memory allocation failed for wma_handle",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302327 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328 }
2329
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302330 qdf_mem_zero(wma_handle, sizeof(t_wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331
Frank Liu00d73fe2017-05-19 22:11:28 +08002332 tgt_psoc_info = qdf_mem_malloc(sizeof(*tgt_psoc_info));
2333 if (!tgt_psoc_info) {
2334 WMA_LOGE("%s: failed to allocate mem for tgt info", __func__);
2335 return QDF_STATUS_E_NOMEM;
2336 }
2337
Anurag Chouhan6d760662016-02-20 16:05:43 +05302338 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302340 qdf_wake_lock_create(&wma_handle->extscan_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 "wlan_extscan_wl");
2342#endif /* FEATURE_WLAN_EXTSCAN */
Mukul Sharmae44d0542017-05-23 21:50:56 +05302343 qdf_wake_lock_create(&wma_handle->wow_wake_lock,
2344 "wlan_wow_wl");
2345 qdf_wake_lock_create(&wma_handle->wow_auth_req_wl,
2346 "wlan_auth_req_wl");
2347 qdf_wake_lock_create(&wma_handle->wow_assoc_req_wl,
2348 "wlan_assoc_req_wl");
2349 qdf_wake_lock_create(&wma_handle->wow_deauth_rec_wl,
2350 "wlan_deauth_rec_wl");
2351 qdf_wake_lock_create(&wma_handle->wow_disassoc_rec_wl,
2352 "wlan_disassoc_rec_wl");
2353 qdf_wake_lock_create(&wma_handle->wow_ap_assoc_lost_wl,
2354 "wlan_ap_assoc_lost_wl");
2355 qdf_wake_lock_create(&wma_handle->wow_auto_shutdown_wl,
2356 "wlan_auto_shutdown_wl");
2357 qdf_wake_lock_create(&wma_handle->roam_ho_wl,
2358 "wlan_roam_ho_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359 }
2360
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05302361 qdf_status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_LEGACY_WMA_ID);
2362 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2363 WMA_LOGE("%s: PSOC get_ref fails", __func__);
Frank Liu00d73fe2017-05-19 22:11:28 +08002364 qdf_mem_free(tgt_psoc_info);
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05302365 return qdf_status;
2366 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302367 wma_handle->psoc = psoc;
2368
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002369 /* Open target_if layer and register wma callback */
2370 wma_target_if_open(wma_handle);
2371 target_if_open(wma_get_psoc_from_scn_handle);
2372
Govind Singhd76a5b02016-03-08 15:12:14 +05302373 /* Attach mc_thread context processing function */
2374 ops.wma_process_fw_event_handler_cbk = wma_process_fw_event_handler;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 /* attach the wmi */
Govind Singhd76a5b02016-03-08 15:12:14 +05302376 wmi_handle = wmi_unified_attach(wma_handle, NULL,
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302377 WMI_TLV_TARGET, use_cookie, &ops, psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 if (!wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002379 WMA_LOGE("%s: failed to attach WMI", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302380 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 goto err_wma_handle;
2382 }
2383
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002384 target_if_register_legacy_service_ready_cb(
2385 wma_legacy_service_ready_event_handler);
2386
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 WMA_LOGA("WMA --> wmi_unified_attach - success");
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302388
Frank Liu00d73fe2017-05-19 22:11:28 +08002389 /* store the wmi handle in tgt_if_handle */
2390 tgt_psoc_info->wmi_handle = wmi_handle;
2391
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302392 wlan_psoc_obj_lock(psoc);
Frank Liu00d73fe2017-05-19 22:11:28 +08002393 wlan_psoc_set_tgt_if_handle(psoc, tgt_psoc_info);
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302394 wlan_psoc_obj_unlock(psoc);
2395
Govind Singhd76a5b02016-03-08 15:12:14 +05302396 wmi_unified_register_event_handler(wmi_handle,
2397 WMI_SERVICE_READY_EVENTID,
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002398 init_deinit_service_ready_event_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05302399 WMA_RX_SERIALIZER_CTX);
2400 wmi_unified_register_event_handler(wmi_handle,
2401 WMI_SERVICE_READY_EXT_EVENTID,
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002402 init_deinit_service_ext_ready_event_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05302403 WMA_RX_SERIALIZER_CTX);
2404 wmi_unified_register_event_handler(wmi_handle,
2405 WMI_READY_EVENTID,
2406 wma_rx_ready_event,
2407 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 /* Save the WMI & HTC handle */
2409 wma_handle->wmi_handle = wmi_handle;
2410 wma_handle->htc_handle = htc_handle;
2411 wma_handle->cds_context = cds_context;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302412 wma_handle->qdf_dev = qdf_dev;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302413 wma_handle->max_scan = cds_cfg->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302415 /* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302416 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302417 /* Cap maxStation based on the target version */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302418 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302419 /* Reinitialize max_no_of_peers based on the capped maxStation value */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302420 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302421
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422 /* initialize default target config */
2423 wma_set_default_tgt_config(wma_handle);
2424
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302425 wma_handle->tx_chain_mask_cck = cds_cfg->tx_chain_mask_cck;
2426 wma_handle->self_gen_frm_pwr = cds_cfg->self_gen_frm_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428#if defined(QCA_WIFI_FTM)
Anurag Chouhan6d760662016-02-20 16:05:43 +05302429 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 wma_utf_attach(wma_handle);
2431#endif /* QCA_WIFI_FTM */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302432 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
2433 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302435 cds_cfg->max_bssid = WMA_MAX_SUPPORTED_BSS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436
2437 wma_handle->wlan_resource_config.num_wow_filters =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302438 cds_cfg->max_wow_filters;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 wma_handle->wlan_resource_config.num_keep_alive_pattern =
2440 WMA_MAXNUM_PERIODIC_TX_PTRNS;
2441
2442 /* The current firmware implementation requires the number of
Anurag Chouhanffb21542016-02-17 14:33:03 +05302443 * offload peers should be (number of vdevs + 1).
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 */
2445 wma_handle->wlan_resource_config.num_offload_peers =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302446 cds_cfg->ap_maxoffload_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447
2448 wma_handle->wlan_resource_config.num_offload_reorder_buffs =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302449 cds_cfg->ap_maxoffload_reorderbuffs + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302451 wma_handle->ol_ini_info = cds_cfg->ol_ini_info;
2452 wma_handle->max_station = cds_cfg->max_station;
2453 wma_handle->max_bssid = cds_cfg->max_bssid;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302454 wma_handle->driver_type = cds_cfg->driver_type;
2455 wma_handle->ssdp = cds_cfg->ssdp;
2456 wma_handle->enable_mc_list = cds_cfg->enable_mc_list;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05302457 wma_handle->bpf_packet_filter_enable =
2458 cds_cfg->bpf_packet_filter_enable;
Hanumanth Reddy Pothulae87621b2017-04-12 20:53:35 +05302459 wma_handle->active_uc_bpf_mode = cds_cfg->active_uc_bpf_mode;
2460 wma_handle->active_mc_bc_bpf_mode = cds_cfg->active_mc_bc_bpf_mode;
Srinivas Girigowda57b450e2016-10-27 21:00:46 -07002461 wma_handle->link_stats_results = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302463 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
2464 wma_handle->RArateLimitInterval = cds_cfg->ra_ratelimit_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465#endif /* FEATURE_WLAN_RA_FILTERING */
2466#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302467 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468#endif
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302469 wma_set_nan_enable(wma_handle, cds_cfg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302470 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 wma_handle->max_bssid);
2472 if (!wma_handle->interfaces) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002473 WMA_LOGE("%s: failed to allocate interface table", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302474 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 goto err_scn_context;
2476 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07002477
2478 for (i = 0; i < wma_handle->max_bssid; ++i)
2479 wma_vdev_init(&wma_handle->interfaces[i]);
2480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 /* Register the debug print event handler */
2482 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302483 WMI_DEBUG_PRINT_EVENTID,
2484 wma_unified_debug_print_event_handler,
2485 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05302486 /* Register profiling event Handler */
2487 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2488 WMI_WLAN_PROFILE_DATA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302489 wma_profile_data_report_event_handler,
2490 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491
2492 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
2494 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05302495 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07002496 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302498 qdf_status = qdf_event_create(&wma_handle->wma_ready_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302499 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002500 WMA_LOGE("%s: wma_ready_event initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 goto err_event_init;
2502 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302503
Anurag Chouhan210db072016-02-22 18:42:15 +05302504 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302505 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302506 wma_service_ready_ext_evt_timeout,
2507 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302508 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302509 WMA_LOGE("Failed to initialize service ready ext timeout");
2510 goto err_event_init;
2511 }
2512
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302513 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302514 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002515 WMA_LOGE("%s: target suspend event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 __func__);
2517 goto err_event_init;
2518 }
2519
2520 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302521 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
2522 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002523 WMA_LOGE("%s: failed to init tx_frm_download_comp_event",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524 __func__);
2525 goto err_event_init;
2526 }
2527
2528 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302529 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
2530 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002531 WMA_LOGE("%s: failed to init tx_queue_empty_event", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 goto err_event_init;
2533 }
2534
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302535 qdf_status = qdf_event_create(&wma_handle->wma_resume_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302536 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002537 WMA_LOGE("%s: wma_resume_event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 __func__);
2539 goto err_event_init;
2540 }
2541
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002542 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
2543 wma_handle);
2544 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002545 WMA_LOGE("%s: Shutdown notifier register failed: %d",
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002546 __func__, qdf_status);
2547 goto err_event_init;
2548 }
2549
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302550 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302551 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002552 WMA_LOGE("%s: runtime_suspend event initialization failed",
Houston Hoffmana76591b2015-11-10 16:52:05 -08002553 __func__);
2554 goto err_event_init;
2555 }
2556
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302557 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302558 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002559 WMA_LOGE("%s: recovery event initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 goto err_event_init;
2561 }
2562
Anurag Chouhanffb21542016-02-17 14:33:03 +05302563 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07002564 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302565 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05302566 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302568 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05302569 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
2570 qdf_atomic_init(&wma_handle->scan_id_counter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571
2572 /* Register vdev start response event handler */
2573 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2574 WMI_VDEV_START_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302575 wma_vdev_start_resp_handler,
2576 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577
2578 /* Register vdev stop response event handler */
2579 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2580 WMI_VDEV_STOPPED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302581 wma_vdev_stop_resp_handler,
2582 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583
2584 /* register for STA kickout function */
2585 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2586 WMI_PEER_STA_KICKOUT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302587 wma_peer_sta_kickout_event_handler,
2588 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589
2590 /* register for stats response event */
2591 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2592 WMI_UPDATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302593 wma_stats_event_handler,
2594 WMA_RX_SERIALIZER_CTX);
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05302595
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05302596 /* register for stats response event */
2597 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2598 WMI_VDEV_GET_ARP_STAT_EVENTID,
2599 wma_get_arp_stats_handler,
2600 WMA_RX_SERIALIZER_CTX);
2601
Will Huanga9814592017-05-24 15:47:58 +08002602 /* register for peer info response event */
2603 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2604 WMI_PEER_STATS_INFO_EVENTID,
2605 wma_peer_info_event_handler,
2606 WMA_RX_SERIALIZER_CTX);
2607
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05302608#ifdef WLAN_POWER_DEBUGFS
2609 /* register for Chip Power stats event */
2610 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2611 WMI_PDEV_CHIP_POWER_STATS_EVENTID,
2612 wma_unified_power_debug_stats_event_handler,
2613 WMA_RX_SERIALIZER_CTX);
2614#endif
2615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 /* register for linkspeed response event */
2617 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2618 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302619 wma_link_speed_event_handler,
2620 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621
2622#ifdef FEATURE_OEM_DATA_SUPPORT
2623 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002624 WMI_OEM_RESPONSE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302625 wma_oem_data_response_handler,
2626 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627#endif /* FEATURE_OEM_DATA_SUPPORT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628
2629 /* Register peer change event handler */
2630 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2631 WMI_PEER_STATE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302632 wma_peer_state_change_event_handler,
2633 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634
2635 /* Register beacon tx complete event id. The event is required
2636 * for sending channel switch announcement frames
2637 */
2638 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302639 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID,
2640 wma_unified_bcntx_status_event_handler,
2641 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642
2643 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2644 WMI_UPDATE_VDEV_RATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302645 wma_link_status_event_handler,
2646 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647#ifdef WLAN_FEATURE_LINK_LAYER_STATS
2648 /* Register event handler for processing Link Layer Stats
2649 * response from the FW
2650 */
2651 wma_register_ll_stats_event_handler(wma_handle);
2652
2653#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2654
2655 /*
2656 * Register event handler to receive firmware mem dump
2657 * copy complete indication
2658 */
2659 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2660 WMI_UPDATE_FW_MEM_DUMP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302661 wma_fw_mem_dump_event_handler,
2662 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +05302664 wmi_set_tgt_assert(wma_handle->wmi_handle,
2665 cds_cfg->force_target_assert_enabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302667 qdf_status = dbglog_init(wma_handle->wmi_handle);
2668 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002669 WMA_LOGE("%s: Firmware Dbglog initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 goto err_dbglog_init;
2671 }
2672
2673 /*
2674 * Update Powersave mode
2675 * 1 - Legacy Powersave + Deepsleep Disabled
2676 * 2 - QPower + Deepsleep Disabled
2677 * 3 - Legacy Powersave + Deepsleep Enabled
2678 * 4 - QPower + Deepsleep Enabled
2679 */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302680 wma_handle->powersave_mode = cds_cfg->powersave_offload_enabled;
2681 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
2682 wma_handle->staModDtim = cds_cfg->sta_mod_dtim;
2683 wma_handle->staDynamicDtim = cds_cfg->sta_dynamic_dtim;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684
2685 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302686 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 * 0 - Disable both magic pattern match and pattern byte match.
2688 * 1 - Enable magic pattern match on all interfaces.
2689 * 2 - Enable pattern byte match on all interfaces.
2690 * 3 - Enable both magic patter and pattern byte match on
2691 * all interfaces.
2692 */
2693 wma_handle->wow.magic_ptrn_enable =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302694 (cds_cfg->wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 wma_handle->ptrn_match_enable_all_vdev =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302696 (cds_cfg->wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697
Frank Liud4b2fa02017-03-29 11:46:48 +08002698#if defined(FEATURE_WLAN_TDLS) && !defined(CONVERGED_TDLS_ENABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2700 WMI_TDLS_PEER_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302701 wma_tdls_event_handler,
2702 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703#endif /* FEATURE_WLAN_TDLS */
2704
2705 /* register for install key completion event */
2706 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302707 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID,
2708 wma_vdev_install_key_complete_event_handler,
2709 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710#ifdef WLAN_FEATURE_NAN
2711 /* register for nan response event */
2712 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2713 WMI_NAN_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302714 wma_nan_rsp_event_handler,
2715 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716#endif /* WLAN_FEATURE_NAN */
2717
2718#ifdef WLAN_FEATURE_STATS_EXT
2719 /* register for extended stats event */
2720 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2721 WMI_STATS_EXT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302722 wma_stats_ext_event_handler,
2723 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724#endif /* WLAN_FEATURE_STATS_EXT */
2725#ifdef FEATURE_WLAN_EXTSCAN
2726 wma_register_extscan_event_handler(wma_handle);
2727#endif /* WLAN_FEATURE_STATS_EXT */
2728
2729 WMA_LOGD("%s: Exit", __func__);
2730
2731#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2732 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2733 WMI_ROAM_SYNCH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302734 wma_roam_synch_event_handler,
2735 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
2737 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2738 WMI_RSSI_BREACH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302739 wma_rssi_breached_event_handler,
2740 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302742 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05302743 "wlan_fw_rsp_wakelock");
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08002744 qdf_runtime_lock_init(&wma_handle->wmi_cmd_rsp_runtime_lock);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002745
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 /* Register peer assoc conf event handler */
2747 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2748 WMI_PEER_ASSOC_CONF_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302749 wma_peer_assoc_conf_handler,
2750 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002751 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2752 WMI_VDEV_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302753 wma_vdev_delete_handler,
2754 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002755 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2756 WMI_PEER_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302757 wma_peer_delete_handler,
2758 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05302759 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2760 WMI_BPF_CAPABILIY_INFO_EVENTID,
2761 wma_get_bpf_caps_event_handler,
2762 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05302763 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2764 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID,
2765 wma_encrypt_decrypt_msg_handler,
2766 WMA_RX_SERIALIZER_CTX);
Kapil Gupta4f0c0c12017-02-07 15:21:15 +05302767 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2768 WMI_CHAN_INFO_EVENTID,
2769 wma_chan_info_event_handler,
2770 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002771 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2772 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID,
2773 wma_flush_complete_evt_handler,
Rajeev Kumarc3032b82017-02-14 15:56:01 -08002774 WMA_RX_WORK_CTX);
lifeng66831662017-05-19 16:01:35 +08002775 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2776 WMI_REPORT_RX_AGGR_FAILURE_EVENTID,
2777 wma_rx_aggr_failure_event_handler,
2778 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002779
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05302780 wma_handle->ito_repeat_count = cds_cfg->ito_repeat_count;
2781
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05302782 /* Register PWR_SAVE_FAIL event only in case of recovery(1) */
2783 if (cds_cfg->auto_power_save_fail_mode) {
2784 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2785 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID,
2786 wma_chip_power_save_failure_detected_handler,
2787 WMA_RX_WORK_CTX);
2788 }
2789
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07002790 wma_ndp_register_all_event_handlers(wma_handle);
lifengd217d192017-05-09 19:44:16 +08002791 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2792 WMI_PEER_ANTDIV_INFO_EVENTID,
2793 wma_peer_ant_info_evt_handler,
2794 WMA_RX_WORK_CTX);
2795
Frank Liu65b17d92016-11-23 15:58:44 +08002796
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302797 wma_register_debug_callback();
Mukul Sharma6411bb82017-03-01 15:57:07 +05302798 /* Register callback with PMO so PMO can update the vdev pause bitmap*/
2799 pmo_register_pause_bitmap_notifier(wma_handle->psoc,
2800 wma_vdev_update_pause_bitmap);
2801 pmo_register_get_pause_bitmap(wma_handle->psoc,
2802 wma_vdev_get_pause_bitmap);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05302803 pmo_register_is_device_in_low_pwr_mode(wma_handle->psoc,
2804 wma_vdev_is_device_in_low_pwr_mode);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07002805 wma_cbacks.wma_get_connection_info = wma_get_connection_info;
2806 wma_cbacks.wma_is_service_enabled = wma_is_service_enabled;
2807 qdf_status = policy_mgr_register_wma_cb(wma_handle->psoc, &wma_cbacks);
2808 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2809 WMA_LOGE("Failed to register wma cb with Policy Manager");
2810 }
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302811
Arif Hussainf63f7a32017-08-22 12:49:42 -07002812 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2813 WMI_PHYERR_EVENTID,
2814 wma_unified_phyerr_rx_event_handler,
2815 WMA_RX_WORK_CTX);
2816
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302817 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818
2819err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302820 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08002821 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302822 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
2823 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824err_event_init:
2825 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
2826 WMI_DEBUG_PRINT_EVENTID);
Dustin Brownec2c92e2017-07-26 11:13:49 -07002827
2828 for (i = 0; i < wma_handle->max_bssid; ++i)
2829 wma_vdev_deinit(&wma_handle->interfaces[i]);
2830
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302831 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07002832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833err_scn_context:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834#if defined(QCA_WIFI_FTM)
2835 wma_utf_detach(wma_handle);
2836#endif /* QCA_WIFI_FTM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302837 qdf_mem_free(((p_cds_contextType) cds_context)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002838 OS_FREE(wmi_handle);
2839
2840err_wma_handle:
Frank Liu00d73fe2017-05-19 22:11:28 +08002841 qdf_mem_free(tgt_psoc_info);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302842 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302844 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302846 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05302847 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
2848 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
2849 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
2850 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
2851 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
2852 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
2853 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 }
Houston Hoffmanc45db892015-11-13 19:59:25 -08002855
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07002856 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857
2858 WMA_LOGD("%s: Exit", __func__);
2859
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302860 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861}
2862
2863/**
2864 * wma_pre_start() - wma pre start
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 *
2866 * Return: 0 on success, errno on failure
2867 */
Jeff Johnson8ad89c62017-09-13 08:55:55 -07002868QDF_STATUS wma_pre_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302870 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 A_STATUS status = A_OK;
2872 tp_wma_handle wma_handle;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08002873 struct scheduler_msg wma_msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874
2875 WMA_LOGD("%s: Enter", __func__);
2876
Anurag Chouhan6d760662016-02-20 16:05:43 +05302877 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878
2879 /* Validate the wma_handle */
2880 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002881 WMA_LOGE("%s: invalid argument", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302882 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 goto end;
2884 }
2885 /* Open endpoint for ctrl path - WMI <--> HTC */
2886 status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
2887 wma_handle->htc_handle);
2888 if (A_OK != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002889 WMA_LOGE("%s: wmi_unified_connect_htc_service", __func__);
Nachiket Kukade8003d252017-03-30 15:55:58 +05302890
2891 if (!cds_is_fw_down())
2892 QDF_BUG(0);
2893
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302894 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 goto end;
2896 }
2897
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08002898 WMA_LOGD("WMA --> wmi_unified_connect_htc_service - success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899
2900 /* Trigger the CFG DOWNLOAD */
2901 wma_msg.type = WNI_CFG_DNLD_REQ;
2902 wma_msg.bodyptr = NULL;
2903 wma_msg.bodyval = 0;
2904
Rajeev Kumarb60abe42017-01-21 15:39:31 -08002905 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &wma_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302906 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002907 WMA_LOGE("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302908 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302909 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910 }
2911end:
2912 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302913 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914}
2915
Abhishek Singh2d775fd2017-08-18 10:51:33 +05302916void wma_send_msg_by_priority(tp_wma_handle wma_handle, uint16_t msg_type,
2917 void *body_ptr, uint32_t body_val, bool is_high_priority)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918{
Abhishek Singh2d775fd2017-08-18 10:51:33 +05302919 struct scheduler_msg msg = {0};
2920 QDF_STATUS status;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07002921
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 msg.type = msg_type;
2923 msg.bodyval = body_val;
2924 msg.bodyptr = body_ptr;
Abhishek Singh2d775fd2017-08-18 10:51:33 +05302925
2926 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE,
2927 &msg, is_high_priority);
2928 if (!QDF_IS_STATUS_SUCCESS(status)) {
2929 WMA_LOGE("Failed to post msg %d to PE", msg_type);
2930 if (body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302931 qdf_mem_free(body_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933}
2934
Abhishek Singh2d775fd2017-08-18 10:51:33 +05302935
2936void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
2937 void *body_ptr, uint32_t body_val)
2938{
2939 wma_send_msg_by_priority(wma_handle, msg_type,
2940 body_ptr, body_val, false);
2941}
2942
2943void wma_send_msg_high_priority(tp_wma_handle wma_handle, uint16_t msg_type,
2944 void *body_ptr, uint32_t body_val)
2945{
2946 wma_send_msg_by_priority(wma_handle, msg_type,
2947 body_ptr, body_val, true);
2948}
2949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950/**
2951 * wma_set_base_macaddr_indicate() - set base mac address in fw
2952 * @wma_handle: wma handle
2953 * @customAddr: base mac address
2954 *
2955 * Return: 0 for success or error code
2956 */
2957static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
2958 tSirMacAddr *customAddr)
2959{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 int err;
2961
Govind Singhf25a0f12016-03-08 16:09:48 +05302962 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
2963 (uint8_t *)customAddr);
2964 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
2967 MAC_ADDR_ARRAY((*customAddr)));
2968
2969 return 0;
2970}
2971
2972/**
2973 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
2974 * @handle: WMA handle
2975 * @event: Event received from FW
2976 * @len: Length of the event
2977 *
2978 * Enables the low frequency events and disables the high frequency
2979 * events. Bit 17 indicates if the event if low/high frequency.
2980 * 1 - high frequency, 0 - low frequency
2981 *
2982 * Return: 0 on successfully enabling/disabling the events
2983 */
2984static int wma_log_supported_evt_handler(void *handle,
2985 uint8_t *event,
2986 uint32_t len)
2987{
2988 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989
Govind Singhf25a0f12016-03-08 16:09:48 +05302990 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
2991 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993
2994 return 0;
2995}
2996
2997/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302998 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002999 * @handle: WMI handle
3000 * @event: Event recevied from FW
3001 * @len: Length of the event
3002 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303003 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
3004 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
3005 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006 *
Dustin Brownec2c92e2017-07-26 11:13:49 -07003007 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303009static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 uint8_t *event,
3011 uint32_t len)
3012{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303013 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
3014 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
3015 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 uint32_t i;
3017 struct sir_set_hw_mode_resp *hw_mode_resp;
3018 tp_wma_handle wma = (tp_wma_handle) handle;
3019
3020 if (!wma) {
3021 WMA_LOGE("%s: Invalid WMA handle", __func__);
3022 /* Since WMA handle itself is NULL, we cannot send fail
3023 * response back to LIM here
3024 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303025 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003027
3028 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
3029
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303030 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031 if (!hw_mode_resp) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003032 WMA_LOGE("%s: Memory allocation failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 /* Since this memory allocation itself failed, we cannot
3034 * send fail response back to LIM here
3035 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303036 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 }
3038
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303039 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303041 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 /* Need to send response back to upper layer to free
3043 * active command list
3044 */
3045 goto fail;
3046 }
3047
3048 wmi_event = param_buf->fixed_param;
3049 hw_mode_resp->status = wmi_event->status;
3050 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3051 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
3052
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003053 WMA_LOGE("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 __func__, wmi_event->status,
3055 wmi_event->cfgd_hw_mode_index,
3056 wmi_event->num_vdev_mac_entries);
3057 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303058 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059
3060 /* Store the vdev-mac map in WMA and prepare to send to PE */
3061 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303062 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303065 pdev_id = vdev_mac_entry[i].pdev_id;
3066 if (pdev_id == WMI_PDEV_ID_SOC) {
3067 WMA_LOGE("%s: soc level id received for mac id)",
3068 __func__);
3069 QDF_BUG(0);
3070 goto fail;
3071 }
3072 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003074 WMA_LOGE("%s: vdev_id:%d mac_id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003075 __func__, vdev_id, mac_id);
3076
3077 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
3078 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
3079 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3080 wmi_event->cfgd_hw_mode_index);
3081 }
3082
3083 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
3084 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
3085 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3086 } else {
3087 wma->old_hw_mode_index = wma->new_hw_mode_index;
3088 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3089 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003090 policy_mgr_update_hw_mode_index(wma->psoc,
3091 wmi_event->cfgd_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 }
3093
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003094 WMA_LOGE("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3096
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303097 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 (void *) hw_mode_resp, 0);
3099
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303100 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101
3102fail:
3103 WMA_LOGE("%s: Sending fail response to LIM", __func__);
3104 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
3105 hw_mode_resp->cfgd_hw_mode_index = 0;
3106 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303107 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108 (void *) hw_mode_resp, 0);
3109
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303110 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111}
3112
3113/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003114 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
3115 *
3116 * @handle: WMA handle
3117 * @fixed_param: Event fixed parameters
3118 * @vdev_mac_entry - vdev mac entry
3119 * @hw_mode_trans_ind - Buffer to store parsed information
3120 *
3121 * Parses fixed_param, vdev_mac_entry and fills in the information into
3122 * hw_mode_trans_ind and wma
3123 *
3124 * Return: None
3125 */
3126void wma_process_pdev_hw_mode_trans_ind(void *handle,
3127 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
3128 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
3129 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
3130{
3131 uint32_t i;
3132 tp_wma_handle wma = (tp_wma_handle) handle;
3133
3134 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
3135 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
3136 hw_mode_trans_ind->num_vdev_mac_entries =
3137 fixed_param->num_vdev_mac_entries;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003138 WMA_LOGE("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003139 __func__, fixed_param->old_hw_mode_index,
3140 fixed_param->new_hw_mode_index,
3141 fixed_param->num_vdev_mac_entries);
3142
3143 /* Store the vdev-mac map in WMA and send to policy manager */
3144 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
3145 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003146
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003147 vdev_id = vdev_mac_entry[i].vdev_id;
3148 pdev_id = vdev_mac_entry[i].pdev_id;
3149
3150 if (pdev_id == WMI_PDEV_ID_SOC) {
3151 WMA_LOGE("%s: soc level id received for mac id)",
3152 __func__);
3153 QDF_BUG(0);
3154 return;
3155 }
3156
3157 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
3158
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003159 WMA_LOGE("%s: vdev_id:%d mac_id:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003160 __func__, vdev_id, mac_id);
3161
3162 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
3163 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
3164 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3165 fixed_param->new_hw_mode_index);
3166 }
3167 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
3168 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003169 policy_mgr_update_new_hw_mode_index(wma->psoc,
3170 fixed_param->new_hw_mode_index);
3171 policy_mgr_update_old_hw_mode_index(wma->psoc,
3172 fixed_param->old_hw_mode_index);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003173
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003174 WMA_LOGE("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003175 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3176}
3177
3178/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303179 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 * @handle: WMI handle
3181 * @event: Event recevied from FW
3182 * @len: Length of the event
3183 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303184 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 * asynchronous hardware mode transition. This event notifies the host driver
3186 * that firmware independently changed the hardware mode for some reason, such
3187 * as Coex, LFR 3.0, etc
3188 *
3189 * Return: Success on receiving valid params from FW
3190 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303191static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 uint8_t *event,
3193 uint32_t len)
3194{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303195 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
3196 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
3197 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
3199 tp_wma_handle wma = (tp_wma_handle) handle;
3200
3201 if (!wma) {
3202 /* This is an async event. So, not sending any event to LIM */
3203 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303204 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 }
3206
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303207 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 if (!param_buf) {
3209 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303210 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303211 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212 }
3213
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303214 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 if (!hw_mode_trans_ind) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003216 WMA_LOGE("%s: Memory allocation failed", __func__);
3217 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 }
3219
3220 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303222 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003223 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
3224 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303226 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 (void *) hw_mode_trans_ind, 0);
3228
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303229 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230}
3231
3232/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303233 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 * @handle: WMI handle
3235 * @event: Event received from FW
3236 * @len: Length of the event
3237 *
3238 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303239 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 * the host driver once the firmware has completed a reconfiguration of the Scan
3241 * and FW mode configuration. This changes could include entering or leaving a
3242 * dual mac configuration for either scan and/or more permanent firmware mode.
3243 *
3244 * Return: Success on receiving valid params from FW
3245 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303246static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247 uint8_t *event,
3248 uint32_t len)
3249{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303250 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
3251 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 tp_wma_handle wma = (tp_wma_handle) handle;
3253 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
3254
3255 if (!wma) {
3256 WMA_LOGE("%s: Invalid WMA handle", __func__);
3257 /* Since the WMA handle is NULL, we cannot send resp to LIM.
3258 * So, returning from here.
3259 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303260 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 }
3262
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303263 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 if (!dual_mac_cfg_resp) {
3265 WMA_LOGE("%s: Memory allocation failed", __func__);
3266 /* Since the mem alloc failed, we cannot send resp to LIM.
3267 * So, returning from here.
3268 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303269 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 }
3271
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303272 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 event;
3274 if (!param_buf) {
3275 WMA_LOGE("%s: Invalid event", __func__);
3276 goto fail;
3277 }
3278
3279 wmi_event = param_buf->fixed_param;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003280 WMA_LOGD("%s: status:%d", __func__, wmi_event->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 dual_mac_cfg_resp->status = wmi_event->status;
3282
3283 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003284 policy_mgr_update_dbs_scan_config(wma->psoc);
3285 policy_mgr_update_dbs_fw_config(wma->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 }
3287
3288 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303289 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 (void *) dual_mac_cfg_resp, 0);
3291
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303292 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293
3294fail:
3295 WMA_LOGE("%s: Sending fail response to LIM", __func__);
3296 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303297 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 (void *) dual_mac_cfg_resp, 0);
3299
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303300 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301
3302}
3303
3304/**
3305 * wma_start() - wma start function.
3306 * Intialize event handlers and timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303308 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 */
Jeff Johnsond4892552017-09-13 08:41:31 -07003310QDF_STATUS wma_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303312 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 tp_wma_handle wma_handle;
3314 int status;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003315
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 WMA_LOGD("%s: Enter", __func__);
3317
Anurag Chouhan6d760662016-02-20 16:05:43 +05303318 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 /* validate the wma_handle */
3320 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003321 WMA_LOGE("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303322 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 goto end;
3324 }
Sandeep Puligillad698bf52017-09-15 16:07:02 -07003325
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3327 WMI_ROAM_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303328 wma_roam_event_callback,
Padma, Santhosh Kumar18169ce2017-03-02 18:04:02 +05303329 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003331 WMA_LOGE("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303332 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 goto end;
3334 }
3335
3336 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3337 WMI_WOW_WAKEUP_HOST_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303338 wma_wow_wakeup_host_event,
3339 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003341 WMA_LOGE("%s: Failed to register wow wakeup host event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303343 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 goto end;
3345 }
3346
3347 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3348 WMI_PDEV_RESUME_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303349 wma_pdev_resume_event_handler,
3350 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003352 WMA_LOGE("%s: Failed to register PDEV resume event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303354 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355 goto end;
3356 }
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05303357#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
3358 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08003359 WMA_LOGD("MCC TX Pause Event Handler register");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303361 WMI_TX_PAUSE_EVENTID,
3362 wma_mcc_vdev_tx_pause_evt_handler,
3363 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
3365
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
3367 WMA_LOGD("Registering auto shutdown handler");
3368 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303369 WMI_HOST_AUTO_SHUTDOWN_EVENTID,
3370 wma_auto_shutdown_event_handler,
3371 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372 if (status) {
3373 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303374 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 goto end;
3376 }
3377#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
3378 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303379 WMI_THERMAL_MGMT_EVENTID,
3380 wma_thermal_mgmt_evt_handler,
3381 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 if (status) {
3383 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303384 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 goto end;
3386 }
3387
3388 status = wma_ocb_register_event_handlers(wma_handle);
3389 if (status) {
3390 WMA_LOGE("Failed to register ocb event handlers");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303391 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 goto end;
3393 }
3394
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303395 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396
3397#ifdef QCA_WIFI_FTM
3398 /*
3399 * Tx mgmt attach requires TXRX context which is not created
3400 * in FTM mode. So skip the TX mgmt attach.
3401 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303402 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 goto end;
3404#endif /* QCA_WIFI_FTM */
3405
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003406 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3407 WMI_SERVICE_RMC)) {
3408
3409 WMA_LOGD("FW supports cesium network, registering event handlers");
3410
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003411 status = wmi_unified_register_event_handler(
3412 wma_handle->wmi_handle,
3413 WMI_PEER_INFO_EVENTID,
3414 wma_ibss_peer_info_event_handler,
3415 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003416 if (status) {
3417 WMA_LOGE("Failed to register ibss peer info event cb");
3418 qdf_status = QDF_STATUS_E_FAILURE;
3419 goto end;
3420 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003421 status = wmi_unified_register_event_handler(
3422 wma_handle->wmi_handle,
3423 WMI_PEER_TX_FAIL_CNT_THR_EVENTID,
3424 wma_fast_tx_fail_event_handler,
3425 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003426 if (status) {
3427 WMA_LOGE("Failed to register peer fast tx failure event cb");
3428 qdf_status = QDF_STATUS_E_FAILURE;
3429 goto end;
3430 }
3431 } else {
3432 WMA_LOGE("Target does not support cesium network");
3433 }
3434
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303435 qdf_status = wma_tx_attach(wma_handle);
3436 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003437 WMA_LOGE("%s: Failed to register tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 goto end;
3439 }
3440
3441 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05303442 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303443 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 wma_log_completion_timeout,
3445 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303446 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 WMA_LOGE("Failed to initialize log completion timeout");
3448 goto end;
3449 }
3450
Jeff Johnson6136fb92017-03-30 15:21:49 -07003451 status = wma_fips_register_event_handlers(wma_handle);
3452 if (!QDF_IS_STATUS_SUCCESS(status)) {
3453 WMA_LOGE("Failed to register FIPS event handler");
3454 qdf_status = QDF_STATUS_E_FAILURE;
3455 goto end;
3456 }
3457
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 /* Initialize the get temperature event handler */
3459 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303460 WMI_PDEV_TEMPERATURE_EVENTID,
3461 wma_pdev_temperature_evt_handler,
3462 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303463 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303465 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 goto end;
3467 }
3468
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07003469 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3470 WMI_VDEV_TSF_REPORT_EVENTID,
3471 wma_vdev_tsf_handler,
3472 WMA_RX_SERIALIZER_CTX);
3473 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003474 WMA_LOGE("%s: Failed to register tsf callback", __func__);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07003475 qdf_status = QDF_STATUS_E_FAILURE;
3476 goto end;
3477 }
3478
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303479 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303481 WMI_PDEV_SET_HW_MODE_RESP_EVENTID,
3482 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303483 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303484 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303486 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 goto end;
3488 }
3489
3490 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
3491 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303492 WMI_PDEV_HW_MODE_TRANSITION_EVENTID,
3493 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303494 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303495 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303497 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 goto end;
3499 }
3500
3501 /* Initialize the set dual mac configuration event handler */
3502 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303503 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID,
3504 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303505 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303506 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003507 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303508 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509 goto end;
3510 }
3511
Wu Gao9a704f42017-03-10 18:42:11 +08003512#ifndef CONVERGED_P2P_ENABLE
Peng Xu8fdaa492016-06-22 10:20:47 -07003513 /* Initialize the P2P Listen Offload event handler */
3514 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3515 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID,
3516 wma_p2p_lo_event_handler,
3517 WMA_RX_SERIALIZER_CTX);
3518 if (!QDF_IS_STATUS_SUCCESS(status)) {
3519 WMA_LOGE("Failed to register p2p lo event cb");
3520 qdf_status = QDF_STATUS_E_FAILURE;
3521 goto end;
3522 }
Wu Gao9a704f42017-03-10 18:42:11 +08003523#endif
Peng Xu8fdaa492016-06-22 10:20:47 -07003524
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05303525 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3526 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID,
3527 wma_wlan_bt_activity_evt_handler,
3528 WMA_RX_SERIALIZER_CTX);
3529 if (!QDF_IS_STATUS_SUCCESS(status)) {
3530 WMA_LOGE("Failed to register coex bt activity event handler");
3531 qdf_status = QDF_STATUS_E_FAILURE;
3532 goto end;
3533 }
3534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535end:
3536 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303537 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538}
3539
3540/**
3541 * wma_stop() - wma stop function.
3542 * cleanup timers and suspend target.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 * @reason: reason for wma_stop.
3544 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303545 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 */
Jeff Johnsonacc1cc72017-09-13 08:47:49 -07003547QDF_STATUS wma_stop(uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548{
3549 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303550 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05303551 int i;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003552
Anurag Chouhan6d760662016-02-20 16:05:43 +05303553 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 WMA_LOGD("%s: Enter", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555 /* validate the wma_handle */
3556 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003557 WMA_LOGE("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303558 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 goto end;
3560 }
3561#ifdef QCA_WIFI_FTM
3562 /*
3563 * Tx mgmt detach requires TXRX context which is not created
3564 * in FTM mode. So skip the TX mgmt detach.
3565 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303566 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303567 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 goto end;
3569 }
3570#endif /* QCA_WIFI_FTM */
3571
3572 if (wma_handle->ack_work_ctx) {
3573 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303574 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575 wma_handle->ack_work_ctx = NULL;
3576 }
3577
3578 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05303579 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003580 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581 WMA_LOGE("Failed to destroy the log completion timer");
Govind Singhede435f2015-12-01 16:16:36 +05303582 /* clean up ll-queue for all vdev */
3583 for (i = 0; i < wma_handle->max_bssid; i++) {
3584 if (wma_handle->interfaces[i].handle &&
Mukul Sharmaf9047232017-03-02 16:58:56 +05303585 wma_is_vdev_up(i)) {
Leo Chang96464902016-10-28 11:10:54 -07003586 cdp_fc_vdev_flush(
3587 cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003588 wma_handle->
3589 interfaces[i].handle);
Govind Singhede435f2015-12-01 16:16:36 +05303590 }
3591 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303592 qdf_status = wma_tx_detach(wma_handle);
3593 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003594 WMA_LOGE("%s: Failed to deregister tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 goto end;
3596 }
3597
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598end:
3599 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303600 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601}
3602
3603/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 * wma_wmi_service_close() - close wma wmi service interface.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303606 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 */
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07003608QDF_STATUS wma_wmi_service_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609{
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07003610 void *cds_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 tp_wma_handle wma_handle;
3612 struct beacon_info *bcn;
3613 int i;
3614
3615 WMA_LOGD("%s: Enter", __func__);
3616
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07003617 cds_ctx = cds_get_global_context();
3618 if (!cds_ctx) {
3619 WMA_LOGE("%s: Invalid CDS context", __func__);
3620 return QDF_STATUS_E_INVAL;
3621 }
3622
Anurag Chouhan6d760662016-02-20 16:05:43 +05303623 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624
3625 /* validate the wma_handle */
3626 if (NULL == wma_handle) {
3627 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303628 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 }
3630
3631 /* validate the wmi handle */
3632 if (NULL == wma_handle->wmi_handle) {
3633 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303634 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635 }
3636
3637 /* dettach the wmi serice */
3638 WMA_LOGD("calling wmi_unified_detach");
3639 wmi_unified_detach(wma_handle->wmi_handle);
3640 wma_handle->wmi_handle = NULL;
3641
3642 for (i = 0; i < wma_handle->max_bssid; i++) {
3643 bcn = wma_handle->interfaces[i].beacon;
3644
3645 if (bcn) {
3646 if (bcn->dma_mapped)
Nirav Shahcbc6d722016-03-01 16:24:53 +05303647 qdf_nbuf_unmap_single(wma_handle->qdf_dev,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303648 bcn->buf, QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +05303649 qdf_nbuf_free(bcn->buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303650 qdf_mem_free(bcn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 wma_handle->interfaces[i].beacon = NULL;
3652 }
3653
3654 if (wma_handle->interfaces[i].handle) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303655 qdf_mem_free(wma_handle->interfaces[i].handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 wma_handle->interfaces[i].handle = NULL;
3657 }
Yue Ma664effc2016-01-12 18:43:54 -08003658
3659 if (wma_handle->interfaces[i].addBssStaContext) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303660 qdf_mem_free(wma_handle->
Yue Ma664effc2016-01-12 18:43:54 -08003661 interfaces[i].addBssStaContext);
3662 wma_handle->interfaces[i].addBssStaContext = NULL;
3663 }
3664
3665 if (wma_handle->interfaces[i].del_staself_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303666 qdf_mem_free(wma_handle->interfaces[i].del_staself_req);
Yue Ma664effc2016-01-12 18:43:54 -08003667 wma_handle->interfaces[i].del_staself_req = NULL;
3668 }
yeshwanth sriram guntuka8dd80382017-01-30 17:04:58 +05303669
3670 if (wma_handle->interfaces[i].stats_rsp) {
3671 qdf_mem_free(wma_handle->interfaces[i].stats_rsp);
3672 wma_handle->interfaces[i].stats_rsp = NULL;
3673 }
Abhishek Singh7e5e9342017-04-12 18:22:07 +05303674
3675 if (wma_handle->interfaces[i].psnr_req) {
3676 qdf_mem_free(wma_handle->
3677 interfaces[i].psnr_req);
3678 wma_handle->interfaces[i].psnr_req = NULL;
3679 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003680
3681 wma_vdev_deinit(&wma_handle->interfaces[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 }
3683
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303684 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686 /* free the wma_handle */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003687 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303689 qdf_mem_free(((p_cds_contextType) cds_ctx)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303691 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692}
3693
Xun Luoa858a472015-11-10 08:24:45 -08003694/**
3695 * wma_wmi_work_close() - close the work queue items associated with WMI
Xun Luoa858a472015-11-10 08:24:45 -08003696 *
3697 * This function closes work queue items associated with WMI, but not fully
3698 * closes WMI service.
3699 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303700 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08003701 * proper error codes.
3702 */
Jeff Johnson6b8473d2017-09-13 09:20:53 -07003703QDF_STATUS wma_wmi_work_close(void)
Xun Luoa858a472015-11-10 08:24:45 -08003704{
3705 tp_wma_handle wma_handle;
3706
3707 WMA_LOGD("%s: Enter", __func__);
3708
Anurag Chouhan6d760662016-02-20 16:05:43 +05303709 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08003710
3711 /* validate the wma_handle */
3712 if (NULL == wma_handle) {
3713 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303714 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003715 }
3716
3717 /* validate the wmi handle */
3718 if (NULL == wma_handle->wmi_handle) {
3719 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303720 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003721 }
3722
3723 /* remove the wmi work */
3724 WMA_LOGD("calling wmi_unified_remove_work");
3725 wmi_unified_remove_work(wma_handle->wmi_handle);
3726
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303727 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08003728}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729
Krunal Soni2e48d012016-05-02 16:55:26 -07003730/**
3731 * wma_cleanup_dbs_phy_caps() - release memory allocated for holding ext cap
3732 * @wma_handle: pointer to wma handle
3733 *
3734 * This function releases all the memory created for holding extended
3735 * capabilities per hardware mode and per PHY
3736 *
3737 * Return: void
3738 */
3739static void wma_cleanup_dbs_phy_caps(t_wma_handle *wma_handle)
3740{
3741 if (NULL == wma_handle) {
3742 WMA_LOGE("%s: Invalid wma handle", __func__);
3743 return;
3744 }
3745
3746 if (wma_handle->phy_caps.hw_mode_to_mac_cap_map) {
3747 qdf_mem_free(wma_handle->phy_caps.hw_mode_to_mac_cap_map);
3748 wma_handle->phy_caps.hw_mode_to_mac_cap_map = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003749 WMA_LOGD("%s: hw_mode_to_mac_cap_map freed", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07003750 }
3751
3752 if (wma_handle->phy_caps.each_hw_mode_cap) {
3753 qdf_mem_free(wma_handle->phy_caps.each_hw_mode_cap);
3754 wma_handle->phy_caps.each_hw_mode_cap = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003755 WMA_LOGD("%s: each_hw_mode_cap freed", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07003756 }
3757
3758 if (wma_handle->phy_caps.each_phy_cap_per_hwmode) {
3759 qdf_mem_free(wma_handle->phy_caps.each_phy_cap_per_hwmode);
3760 wma_handle->phy_caps.each_phy_cap_per_hwmode = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003761 WMA_LOGD("%s: each_phy_cap_per_hwmode freed", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07003762 }
3763
3764 if (wma_handle->phy_caps.each_phy_hal_reg_cap) {
3765 qdf_mem_free(wma_handle->phy_caps.each_phy_hal_reg_cap);
3766 wma_handle->phy_caps.each_phy_hal_reg_cap = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003767 WMA_LOGD("%s: each_phy_hal_reg_cap freed", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07003768 }
3769}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003770
3771/**
3772 * wma_close() - wma close function.
3773 * cleanup resources attached with wma.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303775 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003776 */
Jeff Johnson542da352017-09-13 09:17:28 -07003777QDF_STATUS wma_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778{
3779 tp_wma_handle wma_handle;
3780 uint32_t idx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303781 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Frank Liu00d73fe2017-05-19 22:11:28 +08003782 struct target_psoc_info *tgt_psoc_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783
3784 WMA_LOGD("%s: Enter", __func__);
3785
Anurag Chouhan6d760662016-02-20 16:05:43 +05303786 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787
3788 /* validate the wma_handle */
3789 if (NULL == wma_handle) {
3790 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303791 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 }
3793
3794 /* validate the wmi handle */
3795 if (NULL == wma_handle->wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003796 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303797 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798 }
3799
3800 /* Free DBS list */
3801 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303802 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003804 WMA_LOGD("%s: DBS list is freed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805 }
Krunal Soni2e48d012016-05-02 16:55:26 -07003806 wma_cleanup_dbs_phy_caps(wma_handle);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303807 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303809 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303811 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05303812 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
3813 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
3814 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
3815 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
3816 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
3817 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
3818 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 }
3820
3821 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303822 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
3823 if (qdf_status != QDF_STATUS_SUCCESS)
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003824 WMA_LOGE("%s: dbglog_deinit failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303826 /* close the qdf events */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303827 qdf_event_destroy(&wma_handle->wma_ready_event);
Anurag Chouhan210db072016-02-22 18:42:15 +05303828 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303829 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003830 WMA_LOGE("%s: Failed to destroy service ready ext event timer",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303831 __func__);
3832
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303833 qdf_event_destroy(&wma_handle->target_suspend);
3834 qdf_event_destroy(&wma_handle->wma_resume_event);
3835 qdf_event_destroy(&wma_handle->runtime_suspend);
3836 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08003837 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
3838 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08003839 wma_cleanup_vdev_resp_queue(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303841 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003842 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Poddar, Siddarth2fb98072017-07-19 14:58:30 +05303843 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
3844 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845 for (idx = 0; idx < wma_handle->num_mem_chunks; ++idx) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303846 qdf_mem_free_consistent(wma_handle->qdf_dev,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303847 wma_handle->qdf_dev->dev,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003848 wma_handle->mem_chunks[idx].len,
3849 wma_handle->mem_chunks[idx].vaddr,
3850 wma_handle->mem_chunks[idx].paddr,
3851 qdf_get_dma_mem_context(
3852 (&(wma_handle->mem_chunks[idx])),
3853 memctx));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 }
3855
3856#if defined(QCA_WIFI_FTM)
3857 /* Detach UTF and unregister the handler */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303858 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859 wma_utf_detach(wma_handle);
3860#endif /* QCA_WIFI_FTM */
3861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303863 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864 wma_handle->pGetRssiReq = NULL;
3865 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07003866
yeshwanth sriram guntuka584c2332017-07-29 12:50:25 +05303867 wma_unified_radio_tx_mem_free(wma_handle);
Srinivas Girigowdaad874a82016-10-25 14:08:00 -07003868
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07003869 wma_ndp_unregister_all_event_handlers(wma_handle);
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -07003870 if (wma_handle->pdev) {
3871 wlan_objmgr_pdev_release_ref(wma_handle->pdev,
3872 WLAN_LEGACY_WMA_ID);
3873 wma_handle->pdev = NULL;
3874 }
Frank Liu00d73fe2017-05-19 22:11:28 +08003875
3876 tgt_psoc_info = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
3877 if (tgt_psoc_info) {
3878 qdf_mem_free(tgt_psoc_info);
3879 wlan_psoc_set_tgt_if_handle(wma_handle->psoc, NULL);
3880 }
3881
Mukul Sharma6411bb82017-03-01 15:57:07 +05303882 pmo_unregister_pause_bitmap_notifier(wma_handle->psoc,
3883 wma_vdev_update_pause_bitmap);
3884 pmo_unregister_get_pause_bitmap(wma_handle->psoc,
3885 wma_vdev_get_pause_bitmap);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303886 pmo_unregister_is_device_in_low_pwr_mode(wma_handle->psoc,
3887 wma_vdev_is_device_in_low_pwr_mode);
Mukul Sharma6411bb82017-03-01 15:57:07 +05303888
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303889 wlan_objmgr_psoc_release_ref(wma_handle->psoc, WLAN_LEGACY_WMA_ID);
3890 wma_handle->psoc = NULL;
3891 target_if_close();
3892 wma_target_if_close(wma_handle);
Mukul Sharma6411bb82017-03-01 15:57:07 +05303893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303895 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896}
3897
3898/**
3899 * wma_update_fw_config() - update fw configuration
3900 * @wma_handle: wma handle
3901 * @tgt_cap: target capabality
3902 *
3903 * Return: none
3904 */
3905static void wma_update_fw_config(tp_wma_handle wma_handle,
3906 struct wma_target_cap *tgt_cap)
3907{
3908 /*
3909 * tgt_cap contains default target resource configuration
3910 * which can be modified here, if required
3911 */
3912 /* Override the no. of max fragments as per platform configuration */
3913 tgt_cap->wlan_resource_config.max_frag_entries =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303914 QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 wma_handle->max_frag_entry);
3916 wma_handle->max_frag_entry =
3917 tgt_cap->wlan_resource_config.max_frag_entries;
Arun Khandavalli3dd06de2016-08-17 10:20:29 +05303918
3919 /* Update no. of maxWoWFilters depending on BPF service */
3920 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3921 WMI_SERVICE_BPF_OFFLOAD))
3922 tgt_cap->wlan_resource_config.num_wow_filters =
Arun Khandavallid454d422016-08-17 12:47:05 +05303923 WMA_STA_WOW_DEFAULT_PTRN_MAX;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924}
3925
3926/**
3927 * wma_alloc_host_mem_chunk() - allocate host memory
3928 * @wma_handle: wma handle
3929 * @req_id: request id
3930 * @idx: index
3931 * @num_units: number of units
3932 * @unit_len: unit length
3933 *
3934 * allocate a chunk of memory at the index indicated and
3935 * if allocation fail allocate smallest size possiblr and
3936 * return number of units allocated.
3937 *
3938 * Return: number of units or 0 for error.
3939 */
3940static uint32_t wma_alloc_host_mem_chunk(tp_wma_handle wma_handle,
3941 uint32_t req_id, uint32_t idx,
3942 uint32_t num_units, uint32_t unit_len)
3943{
Anurag Chouhan6d760662016-02-20 16:05:43 +05303944 qdf_dma_addr_t paddr;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003945
3946 if (!num_units || !unit_len)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948 wma_handle->mem_chunks[idx].vaddr = NULL;
3949 /** reduce the requested allocation by half until allocation succeeds */
3950 while (wma_handle->mem_chunks[idx].vaddr == NULL && num_units) {
3951 wma_handle->mem_chunks[idx].vaddr =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303952 qdf_mem_alloc_consistent(wma_handle->qdf_dev,
3953 wma_handle->qdf_dev->dev,
3954 num_units * unit_len,
3955 &paddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003956 if (wma_handle->mem_chunks[idx].vaddr == NULL) {
3957 num_units = (num_units >> 1);/* reduce length by half */
3958 } else {
3959 wma_handle->mem_chunks[idx].paddr = paddr;
3960 wma_handle->mem_chunks[idx].len = num_units * unit_len;
3961 wma_handle->mem_chunks[idx].req_id = req_id;
3962 }
3963 }
3964 return num_units;
3965}
3966
3967#define HOST_MEM_SIZE_UNIT 4
3968/**
3969 * wma_alloc_host_mem() - allocate amount of memory requested by FW.
3970 * @wma_handle: wma handle
3971 * @req_id: request id
3972 * @num_units: number of units
3973 * @unit_len: unit length
3974 *
3975 * Return: none
3976 */
3977static void wma_alloc_host_mem(tp_wma_handle wma_handle, uint32_t req_id,
3978 uint32_t num_units, uint32_t unit_len)
3979{
3980 uint32_t remaining_units, allocated_units, idx;
3981
3982 /* adjust the length to nearest multiple of unit size */
3983 unit_len = (unit_len + (HOST_MEM_SIZE_UNIT - 1)) &
3984 (~(HOST_MEM_SIZE_UNIT - 1));
3985 idx = wma_handle->num_mem_chunks;
3986 remaining_units = num_units;
3987 while (remaining_units) {
3988 allocated_units = wma_alloc_host_mem_chunk(wma_handle, req_id,
3989 idx, remaining_units,
3990 unit_len);
3991 if (allocated_units == 0) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003992 WMA_LOGE("FAILED TO ALLOCATED memory unit len %d units requested %d units allocated %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 unit_len, num_units,
3994 (num_units - remaining_units));
3995 wma_handle->num_mem_chunks = idx;
3996 break;
3997 }
3998 remaining_units -= allocated_units;
3999 ++idx;
4000 if (idx == MAX_MEM_CHUNKS) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004001 WMA_LOGE("RWACHED MAX CHUNK LIMIT for memory units %d unit len %d requested by FW, only allocated %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002 num_units, unit_len,
4003 (num_units - remaining_units));
4004 wma_handle->num_mem_chunks = idx;
4005 break;
4006 }
4007 }
4008 wma_handle->num_mem_chunks = idx;
4009}
4010
4011/**
Yun Parkb4f591d2017-03-29 15:51:01 -07004012 * wma_set_tx_partition_base() - set TX MSDU ID partition base for IPA
4013 * @value: TX MSDU ID partition base
4014 *
4015 * Return: none
4016 */
4017#ifdef IPA_OFFLOAD
4018static void wma_set_tx_partition_base(uint32_t value)
4019{
4020 cdp_ipa_set_uc_tx_partition_base(
4021 cds_get_context(QDF_MODULE_ID_SOC),
4022 (struct cdp_cfg *)cds_get_context(QDF_MODULE_ID_CFG),
4023 value);
4024 WMA_LOGD("%s: TX_MSDU_ID_PARTITION=%d", __func__,
4025 value);
4026}
4027#else
4028static void wma_set_tx_partition_base(uint32_t value)
4029{
4030}
4031#endif
4032
4033/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 * wma_update_target_services() - update target services from wma handle
4035 * @wh: wma handle
4036 * @cfg: target services
4037 *
4038 * Return: none
4039 */
4040static inline void wma_update_target_services(tp_wma_handle wh,
4041 struct wma_tgt_services *cfg)
4042{
4043 /* STA power save */
4044 cfg->sta_power_save = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4045 WMI_SERVICE_STA_PWRSAVE);
4046
4047 /* Enable UAPSD */
4048 cfg->uapsd = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4049 WMI_SERVICE_AP_UAPSD);
4050
4051 /* Update AP DFS service */
4052 cfg->ap_dfs = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4053 WMI_SERVICE_AP_DFS);
4054
4055 /* Enable 11AC */
4056 cfg->en_11ac = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4057 WMI_SERVICE_11AC);
4058 if (cfg->en_11ac)
4059 g_fw_wlan_feat_caps |= (1 << DOT11AC);
4060
4061 /* Proactive ARP response */
4062 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
4063
4064 /* Enable WOW */
4065 g_fw_wlan_feat_caps |= (1 << WOW);
4066
4067 /* ARP offload */
4068 cfg->arp_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4069 WMI_SERVICE_ARPNS_OFFLOAD);
4070
4071 /* Adaptive early-rx */
4072 cfg->early_rx = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4073 WMI_SERVICE_EARLY_RX);
4074#ifdef FEATURE_WLAN_SCAN_PNO
4075 /* PNO offload */
4076 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NLO))
4077 cfg->pno_offload = true;
4078#endif /* FEATURE_WLAN_SCAN_PNO */
4079
4080#ifdef FEATURE_WLAN_EXTSCAN
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004081 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_EXTSCAN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083#endif /* FEATURE_WLAN_EXTSCAN */
4084 cfg->lte_coex_ant_share = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4085 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT);
4086#ifdef FEATURE_WLAN_TDLS
4087 /* Enable TDLS */
4088 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_TDLS)) {
4089 cfg->en_tdls = 1;
4090 g_fw_wlan_feat_caps |= (1 << TDLS);
4091 }
4092 /* Enable advanced TDLS features */
4093 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4094 WMI_SERVICE_TDLS_OFFCHAN)) {
4095 cfg->en_tdls_offchan = 1;
4096 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
4097 }
4098
4099 cfg->en_tdls_uapsd_buf_sta =
4100 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4101 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA);
4102 cfg->en_tdls_uapsd_sleep_sta =
4103 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4104 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA);
4105#endif /* FEATURE_WLAN_TDLS */
4106 if (WMI_SERVICE_IS_ENABLED
4107 (wh->wmi_service_bitmap, WMI_SERVICE_BEACON_OFFLOAD))
4108 cfg->beacon_offload = true;
mukul sharma72c8b222015-09-04 17:02:01 +05304109 if (WMI_SERVICE_IS_ENABLED
4110 (wh->wmi_service_bitmap, WMI_SERVICE_STA_PMF_OFFLOAD))
4111 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4113 /* Enable Roam Offload */
4114 cfg->en_roam_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004115 WMI_SERVICE_ROAM_HO_OFFLOAD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4117#ifdef WLAN_FEATURE_NAN
4118 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NAN))
4119 g_fw_wlan_feat_caps |= (1 << NAN);
4120#endif /* WLAN_FEATURE_NAN */
4121
4122 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_RTT))
4123 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07004124
4125 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4126 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT)) {
Yun Parkb4f591d2017-03-29 15:51:01 -07004127 wma_set_tx_partition_base(HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004128 } else {
Yun Parkb4f591d2017-03-29 15:51:01 -07004129 wma_set_tx_partition_base(HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004130 }
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004131
4132 wma_he_update_tgt_services(wh, cfg);
Will Huang496b36c2017-07-11 16:38:50 +08004133
4134 cfg->get_peer_info_enabled =
4135 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4136 WMI_SERVICE_PEER_STATS_INFO);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137}
4138
4139/**
4140 * wma_update_target_ht_cap() - update ht capabality from wma handle
4141 * @wh: wma handle
4142 * @cfg: ht capabality
4143 *
4144 * Return: none
4145 */
4146static inline void wma_update_target_ht_cap(tp_wma_handle wh,
4147 struct wma_tgt_ht_cap *cfg)
4148{
4149 /* RX STBC */
4150 cfg->ht_rx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_RX_STBC);
4151
4152 /* TX STBC */
4153 cfg->ht_tx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_TX_STBC);
4154
4155 /* MPDU density */
4156 cfg->mpdu_density = wh->ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
4157
4158 /* HT RX LDPC */
4159 cfg->ht_rx_ldpc = !!(wh->ht_cap_info & WMI_HT_CAP_LDPC);
4160
4161 /* HT SGI */
4162 cfg->ht_sgi_20 = !!(wh->ht_cap_info & WMI_HT_CAP_HT20_SGI);
4163
4164 cfg->ht_sgi_40 = !!(wh->ht_cap_info & WMI_HT_CAP_HT40_SGI);
4165
4166 /* RF chains */
4167 cfg->num_rf_chains = wh->num_rf_chains;
4168
Jeff Johnson3fd21822016-11-08 11:30:37 -08004169 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n"
4170 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
4171 "ht_sgi_40 - %d num_rf_chains - %d", __func__, wh->ht_cap_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
4173 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
4174 cfg->num_rf_chains);
4175
4176}
4177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178/**
4179 * wma_update_target_vht_cap() - update vht capabality from wma handle
4180 * @wh: wma handle
4181 * @cfg: vht capabality
4182 *
4183 * Return: none
4184 */
4185static inline void wma_update_target_vht_cap(tp_wma_handle wh,
4186 struct wma_tgt_vht_cap *cfg)
4187{
4188
4189 if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4190 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4191 else if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4192 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4193 else
4194 cfg->vht_max_mpdu = 0;
4195
4196
4197 if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
4198 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4199 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
4200 } else if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ)
4201 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
4202 else
4203 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4204
4205 cfg->vht_rx_ldpc = wh->vht_cap_info & WMI_VHT_CAP_RX_LDPC;
4206
4207 cfg->vht_short_gi_80 = wh->vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
4208 cfg->vht_short_gi_160 = wh->vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
4209
4210 cfg->vht_tx_stbc = wh->vht_cap_info & WMI_VHT_CAP_TX_STBC;
4211
4212 cfg->vht_rx_stbc = (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
4213 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004214 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215
4216 cfg->vht_max_ampdu_len_exp = (wh->vht_cap_info &
4217 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
4218 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4219
4220 cfg->vht_su_bformer = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
4221
4222 cfg->vht_su_bformee = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
4223
4224 cfg->vht_mu_bformer = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
4225
4226 cfg->vht_mu_bformee = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
4227
4228 cfg->vht_txop_ps = wh->vht_cap_info & WMI_VHT_CAP_TXOP_PS;
4229
Jeff Johnson3fd21822016-11-08 11:30:37 -08004230 WMA_LOGD("%s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
4231 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
4232 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
4234 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
4235 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
4236 cfg->vht_max_ampdu_len_exp);
4237}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238
4239/**
Krunal Sonica50b452017-08-04 22:24:59 -07004240 * wma_update_supported_bands() - update supported bands from service ready ext
4241 * @wma_handle: pointer to wma handle
4242 * @supported_bands: Supported band given by FW through service ready ext params
4243 * @new_supported_bands: New supported band which needs to be updated by
4244 * this API which WMA layer understands
4245 *
4246 * This API will convert FW given supported band to enum which WMA layer
4247 * understands
4248 *
4249 * Return: QDF_STATUS
4250 */
4251static QDF_STATUS wma_update_supported_bands(t_wma_handle *wma_handle,
4252 WLAN_BAND_CAPABILITY supported_bands,
4253 WMI_PHY_CAPABILITY *new_supported_bands)
4254{
4255 QDF_STATUS status = QDF_STATUS_SUCCESS;
4256
4257 if (!wma_handle) {
4258 WMA_LOGE("%s: NULL wma_handle", __func__);
4259 return QDF_STATUS_E_FAILURE;
4260 }
4261 if (!new_supported_bands) {
4262 WMA_LOGE("%s: NULL new supported band variable", __func__);
4263 return QDF_STATUS_E_FAILURE;
4264 }
4265 switch (supported_bands) {
4266 case WLAN_2G_CAPABILITY:
4267 *new_supported_bands |= WMI_11G_CAPABILITY;
4268 break;
4269 case WLAN_5G_CAPABILITY:
4270 *new_supported_bands |= WMI_11A_CAPABILITY;
4271 break;
4272 default:
4273 WMA_LOGE("%s: wrong supported band", __func__);
4274 status = QDF_STATUS_E_FAILURE;
4275 break;
4276 }
4277 return status;
4278}
4279
4280/**
Krunal Soniaa664da2016-06-15 23:46:40 -07004281 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
4282 * @wma_handle: pointer to wma_handle
4283 * @ht_cap: given pointer to HT caps which needs to be updated
4284 * @tx_chain: given tx chainmask value
4285 * @rx_chain: given rx chainmask value
4286 * @value: new HT cap info provided in form of bitmask
4287 *
4288 * This function takes the value provided in form of bitmask and decodes
4289 * it. After decoding, what ever value it gets, it takes the union(max) or
4290 * intersection(min) with previously derived values.
4291 *
4292 * Return: none
4293 *
4294 */
4295static void wma_derive_ext_ht_cap(tp_wma_handle wma_handle,
4296 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
4297 uint32_t tx_chain, uint32_t rx_chain)
4298{
4299 struct wma_tgt_ht_cap tmp = {0};
4300
4301 if (NULL == wma_handle || NULL == ht_cap)
4302 return;
4303
Ankit Guptaa5076012016-09-14 11:32:19 -07004304 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07004305 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
4306 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
4307 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
4308 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
4309 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
4310 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
4311 ht_cap->num_rf_chains =
4312 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
4313 wma_get_num_of_setbits_from_bitmask(rx_chain));
4314 } else {
4315 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
4316 (!!(value & WMI_HT_CAP_RX_STBC)));
4317 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
4318 (!!(value & WMI_HT_CAP_TX_STBC)));
4319 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
4320 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
4321 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
4322 (!!(value & WMI_HT_CAP_RX_LDPC)));
4323 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
4324 (!!(value & WMI_HT_CAP_HT20_SGI)));
4325 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
4326 (!!(value & WMI_HT_CAP_HT40_SGI)));
4327 ht_cap->num_rf_chains =
4328 QDF_MAX(ht_cap->num_rf_chains,
4329 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
4330 tx_chain),
4331 wma_get_num_of_setbits_from_bitmask(
4332 rx_chain)));
4333 }
4334}
4335
4336/**
4337 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
4338 * @wma_handle: pointer to wma_handle
4339 * @ht_cap: HT cap structure to be filled
4340 *
4341 * This function loop through each hardware mode and for each hardware mode
4342 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
4343 * HT caps and derives the final cap.
4344 *
4345 * Return: none
4346 *
4347 */
4348static void wma_update_target_ext_ht_cap(tp_wma_handle wma_handle,
4349 struct wma_tgt_ht_cap *ht_cap)
4350{
4351 int i, j = 0, max_mac;
4352 uint32_t ht_2g, ht_5g;
4353 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
4354 struct extended_caps *phy_caps;
4355 WMI_MAC_PHY_CAPABILITIES *mac_cap;
4356
4357 /*
4358 * for legacy device extended cap might not even come, so in that case
4359 * don't overwrite legacy values
4360 */
4361 if (!wma_handle ||
4362 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004363 WMA_LOGD("%s: No extended HT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07004364 return;
4365 }
4366
4367 phy_caps = &wma_handle->phy_caps;
4368 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
4369 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
4370 max_mac = j + 2;
4371 else
4372 max_mac = j + 1;
4373 for ( ; j < max_mac; j++) {
4374 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
4375 ht_2g = mac_cap->ht_cap_info_2G;
4376 ht_5g = mac_cap->ht_cap_info_5G;
4377 if (ht_2g)
4378 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
4379 ht_2g, mac_cap->tx_chain_mask_2G,
4380 mac_cap->rx_chain_mask_2G);
4381 if (ht_5g)
4382 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
4383 ht_5g, mac_cap->tx_chain_mask_5G,
4384 mac_cap->rx_chain_mask_5G);
4385 }
4386 }
4387
Ankit Guptaa5076012016-09-14 11:32:19 -07004388 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004389 sizeof(struct wma_tgt_ht_cap))) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004390 qdf_mem_copy(ht_cap, &tmp_ht_cap,
4391 sizeof(struct wma_tgt_ht_cap));
Krunal Soniaa664da2016-06-15 23:46:40 -07004392 }
4393
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004394 WMA_LOGD("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08004395 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
4396 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07004397 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
4398 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
4399 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
4400 ht_cap->num_rf_chains);
4401}
4402
4403/**
4404 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
4405 * @wma_handle: pointer to wma_handle
4406 * @vht_cap: pointer to given VHT caps to be filled
4407 * @value: new VHT cap info provided in form of bitmask
4408 *
4409 * This function takes the value provided in form of bitmask and decodes
4410 * it. After decoding, what ever value it gets, it takes the union(max) or
4411 * intersection(min) with previously derived values.
4412 *
4413 * Return: none
4414 *
4415 */
4416static void wma_derive_ext_vht_cap(t_wma_handle *wma_handle,
4417 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
4418{
4419 struct wma_tgt_vht_cap tmp_cap = {0};
4420 uint32_t tmp = 0;
4421
4422 if (NULL == wma_handle || NULL == vht_cap)
4423 return;
4424
Ankit Guptaa5076012016-09-14 11:32:19 -07004425 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004426 sizeof(struct wma_tgt_vht_cap))) {
4427 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4428 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4429 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4430 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4431 else
4432 vht_cap->vht_max_mpdu = 0;
4433
4434 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
4435 vht_cap->supp_chan_width =
4436 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4437 vht_cap->supp_chan_width |=
4438 1 << eHT_CHANNEL_WIDTH_160MHZ;
4439 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4440 vht_cap->supp_chan_width =
4441 1 << eHT_CHANNEL_WIDTH_160MHZ;
4442 } else {
4443 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4444 }
4445 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
4446 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
4447 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
4448 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
4449 vht_cap->vht_rx_stbc =
4450 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4451 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4452 (value & WMI_VHT_CAP_RX_STBC_3SS);
4453 vht_cap->vht_max_ampdu_len_exp =
4454 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4455 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4456 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
4457 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
4458 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
4459 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
4460 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
4461 } else {
4462 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4463 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4464 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4465 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4466 else
4467 tmp = 0;
4468 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
4469
4470 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
4471 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
4472 (1 << eHT_CHANNEL_WIDTH_160MHZ);
4473 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4474 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
4475 } else {
4476 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4477 }
4478 vht_cap->supp_chan_width =
4479 QDF_MAX(vht_cap->supp_chan_width, tmp);
4480 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
4481 value & WMI_VHT_CAP_RX_LDPC);
4482 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
4483 value & WMI_VHT_CAP_SGI_80MHZ);
4484 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
4485 value & WMI_VHT_CAP_SGI_160MHZ);
4486 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
4487 value & WMI_VHT_CAP_TX_STBC);
4488 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
4489 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4490 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4491 (value & WMI_VHT_CAP_RX_STBC_3SS));
4492 vht_cap->vht_max_ampdu_len_exp =
4493 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
4494 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4495 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
4496 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
4497 value & WMI_VHT_CAP_SU_BFORMER);
4498 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
4499 value & WMI_VHT_CAP_SU_BFORMEE);
4500 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
4501 value & WMI_VHT_CAP_MU_BFORMER);
4502 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
4503 value & WMI_VHT_CAP_MU_BFORMEE);
4504 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
4505 value & WMI_VHT_CAP_TXOP_PS);
4506 }
4507}
4508
4509/**
4510 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
4511 * @wma_handle: pointer to wma_handle
4512 * @vht_cap: VHT cap structure to be filled
4513 *
4514 * This function loop through each hardware mode and for each hardware mode
4515 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
4516 * VHT caps and derives the final cap.
4517 *
4518 * Return: none
4519 *
4520 */
4521static void wma_update_target_ext_vht_cap(t_wma_handle *wma_handle,
4522 struct wma_tgt_vht_cap *vht_cap)
4523{
4524 int i, j = 0, max_mac;
4525 uint32_t vht_cap_info_2g, vht_cap_info_5g;
4526 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
4527 struct extended_caps *phy_caps;
4528 WMI_MAC_PHY_CAPABILITIES *mac_cap;
4529
4530 /*
4531 * for legacy device extended cap might not even come, so in that case
4532 * don't overwrite legacy values
4533 */
4534 if (!wma_handle ||
4535 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004536 WMA_LOGD("%s: No extended VHT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07004537 return;
4538 }
4539
4540 phy_caps = &wma_handle->phy_caps;
4541 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
4542 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
4543 max_mac = j + 2;
4544 else
4545 max_mac = j + 1;
4546 for ( ; j < max_mac; j++) {
4547 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
4548 vht_cap_info_2g = mac_cap->vht_cap_info_2G;
4549 vht_cap_info_5g = mac_cap->vht_cap_info_5G;
4550 if (vht_cap_info_2g)
4551 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4552 vht_cap_info_2g);
4553 if (vht_cap_info_5g)
4554 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4555 vht_cap_info_5g);
4556 }
4557 }
4558
Ankit Guptaa5076012016-09-14 11:32:19 -07004559 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004560 sizeof(struct wma_tgt_vht_cap))) {
4561 qdf_mem_copy(vht_cap, &tmp_vht_cap,
4562 sizeof(struct wma_tgt_vht_cap));
4563 }
4564
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004565 WMA_LOGD("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08004566 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
4567 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07004568 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
4569 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
4570 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
4571 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
4572 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
4573}
4574
4575/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304576 * wma_update_ra_rate_limit() - update wma config
4577 * @wma_handle: wma handle
4578 * @cfg: target config
4579 *
4580 * Return: none
4581 */
4582#ifdef FEATURE_WLAN_RA_FILTERING
4583static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4584 struct wma_tgt_cfg *cfg)
4585{
4586 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
4587}
4588#else
4589static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4590 struct wma_tgt_cfg *cfg)
4591{
4592}
4593#endif
4594
4595/**
Krunal Sonica50b452017-08-04 22:24:59 -07004596 * wma_update_hdd_band_cap() - update band cap which hdd understands
4597 * @supported_band: supported band which has been given by FW
4598 * @tgt_cfg: target configuration to be updated
4599 *
4600 * Convert WMA given supported band to enum which HDD understands
4601 *
4602 * Return: None
4603 */
4604static void wma_update_hdd_band_cap(WMI_PHY_CAPABILITY supported_band,
4605 struct wma_tgt_cfg *tgt_cfg)
4606{
4607 switch (supported_band) {
4608 case WMI_11G_CAPABILITY:
4609 case WMI_11NG_CAPABILITY:
4610 tgt_cfg->band_cap = eCSR_BAND_24;
4611 break;
4612 case WMI_11A_CAPABILITY:
4613 case WMI_11NA_CAPABILITY:
4614 case WMI_11AC_CAPABILITY:
4615 tgt_cfg->band_cap = eCSR_BAND_5G;
4616 break;
4617 case WMI_11AG_CAPABILITY:
4618 case WMI_11NAG_CAPABILITY:
4619 default:
4620 tgt_cfg->band_cap = eCSR_BAND_ALL;
4621 }
4622}
4623
4624/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 * wma_update_hdd_cfg() - update HDD config
4626 * @wma_handle: wma handle
4627 *
4628 * Return: none
4629 */
4630static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
4631{
4632 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304633 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304635 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07004636
4637 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
4639 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
4640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 tgt_cfg.max_intf_count = wma_handle->wlan_resource_config.num_vdevs;
4642
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304643 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 ATH_MAC_LEN);
4645
4646 wma_update_target_services(wma_handle, &tgt_cfg.services);
4647 wma_update_target_ht_cap(wma_handle, &tgt_cfg.ht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 wma_update_target_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07004649 /*
4650 * This will overwrite the structure filled by wma_update_target_ht_cap
4651 * and wma_update_target_vht_cap APIs.
4652 */
4653 wma_update_target_ext_ht_cap(wma_handle, &tgt_cfg.ht_cap);
4654 wma_update_target_ext_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004656 wma_update_target_ext_he_cap(wma_handle, &tgt_cfg);
4657
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 tgt_cfg.target_fw_version = wma_handle->target_fw_version;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07004659 tgt_cfg.target_fw_vers_ext = wma_handle->target_fw_vers_ext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660#ifdef WLAN_FEATURE_LPSS
4661 tgt_cfg.lpss_support = wma_handle->lpss_support;
4662#endif /* WLAN_FEATURE_LPSS */
4663 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Rajeev Kumare5a16822016-07-27 13:11:42 -07004664 tgt_cfg.bpf_enabled = wma_handle->bpf_enabled;
Arif Hussain759a0232017-03-20 13:17:18 -07004665 tgt_cfg.dfs_cac_offload = wma_handle->dfs_cac_offload;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304666 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Krunal Sonica50b452017-08-04 22:24:59 -07004667 wma_update_hdd_band_cap(wma_handle->phy_capability, &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004668 tgt_cfg.fine_time_measurement_cap =
4669 wma_handle->fine_time_measurement_cap;
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05304670 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
4671 - WMI_TLV_HEADROOM;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08004672 wma_setup_egap_support(&tgt_cfg, wma_handle);
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05304673 tgt_cfg.tx_bfee_8ss_enabled = wma_handle->tx_bfee_8ss_enabled;
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07004674 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07004675 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676}
4677
4678/**
4679 * wma_setup_wmi_init_msg() - fill wmi init message buffer
4680 * @wma_handle: wma handle
4681 * @ev: ready event fixed params
4682 * @param_buf: redy event TLVs
4683 * @len: buffer length
4684 *
4685 * Return: wmi buffer or NULL for error
4686 */
Govind Singhf25a0f12016-03-08 16:09:48 +05304687static int wma_setup_wmi_init_msg(tp_wma_handle wma_handle,
4688 wmi_service_ready_event_fixed_param *ev,
4689 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691 wlan_host_mem_req *ev_mem_reqs;
4692 wmi_abi_version my_vers;
Govind Singhf25a0f12016-03-08 16:09:48 +05304693 wmi_abi_version host_abi_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 int num_whitelist;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 uint16_t idx;
4696 uint32_t num_units;
4697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 ev_mem_reqs = param_buf->mem_reqs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699
4700 /* allocate memory requested by FW */
4701 if (ev->num_mem_reqs > WMI_MAX_MEM_REQS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304702 QDF_ASSERT(0);
Govind Singhf25a0f12016-03-08 16:09:48 +05304703 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 }
4705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004706 for (idx = 0; idx < ev->num_mem_reqs; ++idx) {
4707 num_units = ev_mem_reqs[idx].num_units;
4708 if (ev_mem_reqs[idx].num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4709 /*
4710 * number of units to allocate is number
4711 * of peers, 1 extra for self peer on
4712 * target. this needs to be fied, host
4713 * and target can get out of sync
4714 */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004715 num_units = wma_handle->wlan_resource_config.num_peers +
4716 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004718 WMA_LOGD("idx %d req %d num_units %d num_unit_info %d unit size %d actual units %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 idx, ev_mem_reqs[idx].req_id,
4720 ev_mem_reqs[idx].num_units,
4721 ev_mem_reqs[idx].num_unit_info,
4722 ev_mem_reqs[idx].unit_size, num_units);
4723 wma_alloc_host_mem(wma_handle, ev_mem_reqs[idx].req_id,
4724 num_units, ev_mem_reqs[idx].unit_size);
4725 }
Govind Singhf25a0f12016-03-08 16:09:48 +05304726
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304727 qdf_mem_copy(&wma_handle->target_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004728 &param_buf->fixed_param->fw_abi_vers,
4729 sizeof(wmi_abi_version));
4730 num_whitelist = sizeof(version_whitelist) /
4731 sizeof(wmi_whitelist_version_info);
4732 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
4733 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
4734 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
4735 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
4736 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
4737 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
4738
4739 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
4740 &my_vers,
4741 &param_buf->fixed_param->fw_abi_vers,
Govind Singhf25a0f12016-03-08 16:09:48 +05304742 &host_abi_vers);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743
Govind Singhf25a0f12016-03-08 16:09:48 +05304744 qdf_mem_copy(&wma_handle->final_abi_vers, &host_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 sizeof(wmi_abi_version));
Govind Singhf25a0f12016-03-08 16:09:48 +05304746
4747 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748}
4749
4750/**
4751 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
4752 * @wma_handle: WMA handle
4753 *
4754 * Prints the DBS HW modes sent by the FW as part
4755 * of WMI ready event
4756 *
4757 * Return: None
4758 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004759static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760{
4761 uint32_t i, param;
4762
4763 if (!wma_handle) {
4764 WMA_LOGE("%s: Invalid WMA handle", __func__);
4765 return;
4766 }
4767
4768 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
4769 param = wma_handle->hw_mode.hw_mode_list[i];
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004770 WMA_LOGD("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004771 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304772 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
4773 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
4774 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004775 WMA_LOGD("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304777 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
4778 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
4779 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004780 WMA_LOGD("%s:[%d] DBS:%d SBS:%d", __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304781 WMA_HW_MODE_DBS_MODE_GET(param),
4782 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004784 policy_mgr_dump_dbs_hw_mode(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785}
4786
4787/**
4788 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
4789 * @wma_handle: WMA handle
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304790 * @scan_config: Scam mode configuration
4791 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004792 *
4793 * Enables all the valid bits of concurrent_scan_config_bits and
4794 * fw_mode_config_bits.
4795 *
4796 * Return: None
4797 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004798static void wma_init_scan_fw_mode_config(tp_wma_handle wma_handle,
4799 uint32_t scan_config,
4800 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004801{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802 WMA_LOGD("%s: Enter", __func__);
4803
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004804 if (!wma_handle) {
4805 WMA_LOGE("%s: Invalid WMA handle", __func__);
4806 return;
4807 }
4808
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004809 policy_mgr_init_dbs_config(wma_handle->psoc, scan_config, fw_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810}
4811
4812/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304813 * wma_update_ra_limit() - update ra limit based on bpf filter
4814 * enabled or not
4815 * @handle: wma handle
4816 *
4817 * Return: none
4818 */
4819#ifdef FEATURE_WLAN_RA_FILTERING
4820static void wma_update_ra_limit(tp_wma_handle wma_handle)
4821{
4822 if (wma_handle->bpf_enabled)
4823 wma_handle->IsRArateLimitEnabled = false;
4824}
4825#else
4826static void wma_update_ra__limit(tp_wma_handle handle)
4827{
4828}
4829#endif
4830
4831/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 * wma_rx_service_ready_event() - event handler to process
4833 * wmi rx sevice ready event.
4834 * @handle: wma handle
4835 * @cmd_param_info: command params info
4836 *
4837 * Return: none
4838 */
Govind Singhd76a5b02016-03-08 15:12:14 +05304839int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
4840 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 tp_wma_handle wma_handle = (tp_wma_handle) handle;
4843 struct wma_target_cap target_cap;
4844 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
4845 wmi_service_ready_event_fixed_param *ev;
4846 int status;
4847 uint32_t *ev_wlan_dbs_hw_mode_list;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304848 QDF_STATUS ret;
Leo Chang96464902016-10-28 11:10:54 -07004849 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850
4851 WMA_LOGD("%s: Enter", __func__);
4852
4853 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
4854 if (!(handle && param_buf)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004855 WMA_LOGE("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304856 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004857 }
4858
4859 ev = param_buf->fixed_param;
4860 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004861 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304862 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 }
4864
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004865 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866
4867 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
4868 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
4869 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304870 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 wma_handle->num_dbs_hw_modes);
4872 if (!wma_handle->hw_mode.hw_mode_list) {
4873 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
4874 /* Continuing with the rest of the processing */
4875 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304876 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877 ev_wlan_dbs_hw_mode_list,
4878 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
4879 wma_handle->num_dbs_hw_modes));
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004880 policy_mgr_init_dbs_hw_mode(wma_handle->psoc,
4881 ev->num_dbs_hw_modes, ev_wlan_dbs_hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 wma_dump_dbs_hw_mode(wma_handle);
4883
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304884 /* Initializes the fw_mode and scan_config to zero.
4885 * If ext service ready event is present it will set
4886 * the actual values of these two params.
4887 * This is to ensure that no garbage values would be
4888 * present in the absence of ext service ready event.
4889 */
4890 wma_init_scan_fw_mode_config(wma_handle, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891
4892 wma_handle->phy_capability = ev->phy_capability;
4893 wma_handle->max_frag_entry = ev->max_frag_entry;
4894 wma_handle->num_rf_chains = ev->num_rf_chains;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304895 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896 sizeof(HAL_REG_CAPABILITIES));
4897 wma_handle->ht_cap_info = ev->ht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004898 wma_handle->vht_cap_info = ev->vht_cap_info;
4899 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 wma_handle->num_rf_chains = ev->num_rf_chains;
4901
4902 wma_handle->target_fw_version = ev->fw_build_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 wma_handle->new_hw_mode_index = ev->default_dbs_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004904 policy_mgr_update_new_hw_mode_index(wma_handle->psoc,
4905 ev->default_dbs_hw_mode_index);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004906 wma_handle->fine_time_measurement_cap = ev->wmi_fw_sub_feat_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907
4908 WMA_LOGD("%s: Firmware default hw mode index : %d",
4909 __func__, ev->default_dbs_hw_mode_index);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004910 WMA_LOGI("%s: Firmware build version : %08x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 __func__, ev->fw_build_vers);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004912 WMA_LOGD("FW fine time meas cap: 0x%x", ev->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913
4914 if (ev->hw_bd_id) {
4915 wma_handle->hw_bd_id = ev->hw_bd_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304916 qdf_mem_copy(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 ev->hw_bd_info, sizeof(ev->hw_bd_info));
4918
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004919 WMA_LOGI("%s: Board version: %x.%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 __func__,
4921 wma_handle->hw_bd_info[0], wma_handle->hw_bd_info[1]);
4922 } else {
4923 wma_handle->hw_bd_id = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304924 qdf_mem_zero(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925 sizeof(wma_handle->hw_bd_info));
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004926 WMA_LOGW("%s: Board version is unknown!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 }
4928
4929 /* TODO: Recheck below line to dump service ready event */
4930 /* dbg_print_wmi_service_11ac(ev); */
4931
4932 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304933 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934 param_buf->wmi_service_bitmap,
4935 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05304936
Leo Chang96464902016-10-28 11:10:54 -07004937 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(soc,
Nirav Shah22bf44d2015-12-10 15:39:48 +05304938 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4939 WMI_SERVICE_MGMT_TX_WMI));
Leo Chang96464902016-10-28 11:10:54 -07004940 cdp_set_desc_global_pool_size(soc, ev->num_msdu_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 /* SWBA event handler for beacon transmission */
4942 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4943 WMI_HOST_SWBA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304944 wma_beacon_swba_handler,
4945 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 if (status) {
4947 WMA_LOGE("Failed to register swba beacon event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304948 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949 }
4950#ifdef WLAN_FEATURE_LPSS
4951 wma_handle->lpss_support =
4952 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4953 WMI_SERVICE_LPASS);
4954#endif /* WLAN_FEATURE_LPSS */
4955
4956 /*
4957 * This Service bit is added to check for ARP/NS Offload
4958 * support for LL/HL targets
4959 */
4960 wma_handle->ap_arpns_support =
4961 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4962 WMI_SERVICE_AP_ARPNS_OFFLOAD);
4963
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304964 wma_handle->bpf_enabled = (wma_handle->bpf_packet_filter_enable &&
Rajeev Kumare5a16822016-07-27 13:11:42 -07004965 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304966 WMI_SERVICE_BPF_OFFLOAD));
4967 wma_update_ra_limit(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4969 WMI_SERVICE_CSA_OFFLOAD)) {
4970 WMA_LOGD("%s: FW support CSA offload capability", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004971 status = wmi_unified_register_event_handler(
4972 wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304973 WMI_CSA_HANDLING_EVENTID,
4974 wma_csa_offload_handler,
4975 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 if (status) {
4977 WMA_LOGE("Failed to register CSA offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304978 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 }
4980 }
4981
4982 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4983 WMI_SERVICE_MGMT_TX_WMI)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004984 WMA_LOGD("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 /*
4986 * Register Tx completion event handler for MGMT Tx over WMI
4987 * case
4988 */
4989 status = wmi_unified_register_event_handler(
4990 wma_handle->wmi_handle,
4991 WMI_MGMT_TX_COMPLETION_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304992 wma_mgmt_tx_completion_handler,
4993 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994 if (status) {
4995 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Govind Singhd76a5b02016-03-08 15:12:14 +05304996 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004997 }
4998
Nirav Shah20489972016-06-16 19:20:28 +05304999 status = wmi_unified_register_event_handler(
5000 wma_handle->wmi_handle,
5001 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID,
5002 wma_mgmt_tx_bundle_completion_handler,
5003 WMA_RX_SERIALIZER_CTX);
5004 if (status) {
5005 WMA_LOGE("Failed to register MGMT over WMI completion handler");
5006 return -EINVAL;
5007 }
5008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005009 } else {
5010 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
5011 }
5012#ifdef WLAN_FEATURE_GTK_OFFLOAD
5013 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5014 WMI_SERVICE_GTK_OFFLOAD)) {
5015 status =
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005016 wmi_unified_register_event_handler(
5017 wma_handle->wmi_handle,
Mukul Sharma3d36c392017-01-18 18:39:12 +05305018 WMI_GTK_OFFLOAD_STATUS_EVENTID,
5019 target_if_pmo_gtk_offload_status_event,
5020 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005021 if (status) {
5022 WMA_LOGE("Failed to register GTK offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05305023 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005024 }
5025 }
5026#endif /* WLAN_FEATURE_GTK_OFFLOAD */
5027
Wu Gao9a704f42017-03-10 18:42:11 +08005028#ifndef CONVERGED_P2P_ENABLE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005029 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
5030 WMI_P2P_NOA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05305031 wma_p2p_noa_event_handler,
5032 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 if (status) {
5034 WMA_LOGE("Failed to register WMI_P2P_NOA_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05305035 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 }
Wu Gao9a704f42017-03-10 18:42:11 +08005037#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05305039 WMI_TBTTOFFSET_UPDATE_EVENTID,
5040 wma_tbttoffset_update_event_handler,
5041 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005042 if (status) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005043 WMA_LOGE("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05305044 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005045 }
5046
Govind Singhefc5ccd2016-04-25 11:11:55 +05305047 /* mac_id is replaced with pdev_id in converged firmware to have
5048 * multi-radio support. In order to maintain backward compatibility
5049 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
5050 * in service bitmap from FW and host needs to set use_pdev_id in
5051 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
5052 * service is not set, then host shall not expect MAC ID from FW in
5053 * VDEV START RESPONSE event and host shall use PDEV ID.
5054 */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005055 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
Govind Singhefc5ccd2016-04-25 11:11:55 +05305056 WMI_SERVICE_DEPRECATED_REPLACE))
5057 wma_handle->wlan_resource_config.use_pdev_id = true;
5058 else
5059 wma_handle->wlan_resource_config.use_pdev_id = false;
5060
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05305061 wma_handle->wlan_resource_config.max_num_dbs_scan_duty_cycle =
5062 CDS_DBS_SCAN_CLIENTS_MAX;
5063
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08005064 /* register the Enhanced Green AP event handler */
5065 wma_register_egap_event_handle(wma_handle);
5066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005067 /* Initialize the log supported event handler */
5068 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
5069 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05305070 wma_log_supported_evt_handler,
5071 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305072 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073 WMA_LOGE("Failed to register log supported event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05305074 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 }
5076
Leo Chang96464902016-10-28 11:10:54 -07005077 cdp_mark_first_wakeup_packet(soc,
Himanshu Agarwal19141bb2016-07-20 20:15:48 +05305078 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5079 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET));
Arif Hussain759a0232017-03-20 13:17:18 -07005080 wma_handle->dfs_cac_offload =
5081 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5082 WMI_SERVICE_DFS_PHYERR_OFFLOAD);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07005083 wma_handle->nan_datapath_enabled =
5084 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5085 WMI_SERVICE_NAN_DATA);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305086 qdf_mem_copy(target_cap.wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 param_buf->wmi_service_bitmap,
5088 sizeof(wma_handle->wmi_service_bitmap));
5089 target_cap.wlan_resource_config = wma_handle->wlan_resource_config;
5090 wma_update_fw_config(wma_handle, &target_cap);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305091 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005092 target_cap.wmi_service_bitmap,
5093 sizeof(wma_handle->wmi_service_bitmap));
5094 wma_handle->wlan_resource_config = target_cap.wlan_resource_config;
5095
Govind Singhf25a0f12016-03-08 16:09:48 +05305096 status = wmi_unified_save_fw_version_cmd(wma_handle->wmi_handle,
5097 param_buf);
5098 if (status != EOK) {
5099 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
5100 return -EINVAL;
5101 }
5102
5103 status = wma_setup_wmi_init_msg(wma_handle, ev, param_buf);
5104 if (status != EOK) {
5105 WMA_LOGE("Failed to setup for wma init command");
Govind Singhd76a5b02016-03-08 15:12:14 +05305106 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005107 }
5108
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305109 /* A host, which supports WMI_SERVICE_READY_EXT_EVENTID, would need to
5110 * check the WMI_SERVICE_READY message for an "extension" flag, and if
5111 * this flag is set, then hold off on sending the WMI_INIT message until
5112 * WMI_SERVICE_READY_EXT_EVENTID is received.
5113 */
5114 if (!WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5115 WMI_SERVICE_EXT_MSG)) {
5116 /* No service extended message support.
5117 * Send INIT command immediately
5118 */
5119 WMA_LOGA("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05305120 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
5121 &wma_handle->wlan_resource_config,
5122 wma_handle->num_mem_chunks,
5123 wma_handle->mem_chunks, 1);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305124 if (status != EOK) {
5125 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Govind Singhd76a5b02016-03-08 15:12:14 +05305126 return -EINVAL;
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305127 }
5128 } else {
Govind Singhf25a0f12016-03-08 16:09:48 +05305129 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
5130 &wma_handle->wlan_resource_config,
5131 wma_handle->num_mem_chunks,
5132 wma_handle->mem_chunks, 0);
5133 if (status != EOK) {
5134 WMA_LOGE("Failed to save WMI_INIT_CMDID command parameter");
5135 return -EINVAL;
5136 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305137 /* The saved 'buf' will be freed after sending INIT command or
5138 * in other cases as required
5139 */
Anurag Chouhan210db072016-02-22 18:42:15 +05305140 ret = qdf_mc_timer_start(&wma_handle->service_ready_ext_timer,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305141 WMA_SERVICE_READY_EXT_TIMEOUT);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305142 if (!QDF_IS_STATUS_SUCCESS(ret))
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005143 WMA_LOGE("Failed to start the service ready ext timer");
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305144
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005145 WMA_LOGD("%s: WMA waiting for WMI_SERVICE_READY_EXT_EVENTID",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305146 __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 }
Govind Singhd76a5b02016-03-08 15:12:14 +05305148
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05305149 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5150 WMI_SERVICE_8SS_TX_BFEE))
5151 wma_handle->tx_bfee_8ss_enabled = true;
5152 else
5153 wma_handle->tx_bfee_8ss_enabled = false;
5154
Govind Singhd76a5b02016-03-08 15:12:14 +05305155 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156}
5157
5158/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07005159 * wma_get_phyid_for_given_band() - to get phyid for band
5160 *
5161 * @wma_handle: Pointer to wma handle
5162 * @map: Pointer to map which is derived from hw mode & has mapping between
5163 * hw mode and available PHYs for that hw mode.
5164 * @band: enum value of for 2G or 5G band
5165 * @phyid: Pointer to phyid which needs to be filled
5166 *
5167 * This API looks in to the map to find out which particular phy supports
5168 * provided band and return the idx (also called phyid) of that phy. Caller
5169 * use this phyid to fetch various caps of that phy
5170 *
5171 * Return: QDF_STATUS
5172 */
5173static QDF_STATUS wma_get_phyid_for_given_band(
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005174 tp_wma_handle wma_handle,
Krunal Soni0193b6f2016-08-15 15:53:43 -07005175 struct hw_mode_idx_to_mac_cap_idx *map,
5176 enum cds_band_type band, uint8_t *phyid)
5177{
5178 uint8_t idx, i;
5179 WMI_MAC_PHY_CAPABILITIES *cap;
5180
5181 if (!wma_handle) {
5182 WMA_LOGE("Invalid wma handle");
5183 return QDF_STATUS_E_FAILURE;
5184 }
5185
5186 if (!map) {
5187 WMA_LOGE("Invalid given map");
5188 return QDF_STATUS_E_FAILURE;
5189 }
5190 idx = map->mac_cap_idx;
5191 *phyid = idx;
5192
5193 for (i = 0; i < map->num_of_macs; i++) {
5194 cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[idx + i];
5195 if ((band == CDS_BAND_2GHZ) &&
5196 (WLAN_2G_CAPABILITY == cap->supported_bands)) {
5197 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005198 WMA_LOGD("Select 2G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005199 return QDF_STATUS_SUCCESS;
5200 } else if ((band == CDS_BAND_5GHZ) &&
5201 (WLAN_5G_CAPABILITY == cap->supported_bands)) {
5202 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005203 WMA_LOGD("Select 5G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005204 return QDF_STATUS_SUCCESS;
5205 }
5206 }
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005207 WMA_LOGD("Using default single hw mode phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005208 return QDF_STATUS_SUCCESS;
5209}
5210
5211/**
5212 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
5213 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
5214 * @hw_mode: Provided hardware mode
5215 * @band: Provide band i.e. 2G or 5G
5216 *
5217 * This API finds cap which suitable for provided hw mode and band. If user
5218 * is provides some invalid hw mode then it will automatically falls back to
5219 * default hw mode
5220 *
5221 * Return: QDF_STATUS
5222 */
5223QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
5224 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
5225{
5226 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
5227 struct hw_mode_idx_to_mac_cap_idx *map;
5228 WMI_MAC_PHY_CAPABILITIES *phy_cap;
5229 uint8_t phyid, our_hw_mode = hw_mode;
5230
5231 if (!wma_handle) {
5232 WMA_LOGE("Invalid wma handle");
5233 return QDF_STATUS_E_FAILURE;
5234 }
5235
5236 if (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes) {
5237 WMA_LOGE("Invalid number of hw modes");
5238 return QDF_STATUS_E_FAILURE;
5239 }
5240
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005241 if (!policy_mgr_is_dbs_enable(wma_handle->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -07005242 our_hw_mode = HW_MODE_DBS_NONE;
5243
5244 if (!caps_per_phy) {
5245 WMA_LOGE("Invalid caps pointer");
5246 return QDF_STATUS_E_FAILURE;
5247 }
5248
5249 map = &wma_handle->phy_caps.hw_mode_to_mac_cap_map[our_hw_mode];
5250
5251 if (QDF_STATUS_SUCCESS !=
5252 wma_get_phyid_for_given_band(wma_handle, map, band, &phyid)) {
5253 WMA_LOGE("Invalid phyid");
5254 return QDF_STATUS_E_FAILURE;
5255 }
5256 phy_cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[phyid];
5257
5258 caps_per_phy->ht_2g = phy_cap->ht_cap_info_2G;
5259 caps_per_phy->ht_5g = phy_cap->ht_cap_info_5G;
5260 caps_per_phy->vht_2g = phy_cap->vht_cap_info_2G;
5261 caps_per_phy->vht_5g = phy_cap->vht_cap_info_5G;
5262 caps_per_phy->he_2g = phy_cap->he_cap_info_2G;
5263 caps_per_phy->he_5g = phy_cap->he_cap_info_5G;
5264
5265 return QDF_STATUS_SUCCESS;
5266}
5267
5268/**
5269 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
5270 *
5271 * @channel: Channel number for which it needs to check if rx ldpc is enabled
5272 *
5273 * This API takes channel number as argument and takes default hw mode as DBS
5274 * to check if rx LDPC support is enabled for that channel or no
5275 */
5276bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
5277{
5278 struct wma_caps_per_phy caps_per_phy = {0};
5279 enum cds_band_type band;
5280 bool status;
5281
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005282 if (!WLAN_REG_IS_24GHZ_CH(channel))
Krunal Soni0193b6f2016-08-15 15:53:43 -07005283 band = CDS_BAND_5GHZ;
5284 else
5285 band = CDS_BAND_2GHZ;
5286
5287 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
5288 &caps_per_phy,
5289 HW_MODE_DBS, band)) {
5290 return false;
5291 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005292 if (WLAN_REG_IS_24GHZ_CH(channel))
Krunal Soni0193b6f2016-08-15 15:53:43 -07005293 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
5294 else
5295 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
5296
5297 return status;
5298}
5299
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005300/**
5301 * wma_print_mac_phy_capabilities() - Prints MAC PHY capabilities
5302 * @cap: pointer to WMI_MAC_PHY_CAPABILITIES
5303 * @index: MAC_PHY index
5304 *
5305 * Return: none
5306 */
5307static void wma_print_mac_phy_capabilities(WMI_MAC_PHY_CAPABILITIES *cap,
5308 int index)
5309{
5310 uint32_t mac_2G, mac_5G;
5311 uint32_t phy_2G[WMI_MAX_HECAP_PHY_SIZE];
5312 uint32_t phy_5G[WMI_MAX_HECAP_PHY_SIZE];
5313 wmi_ppe_threshold ppet_2G, ppet_5G;
5314
5315 WMA_LOGI("\t: index [%d]", index);
5316 WMA_LOGI("\t: cap for hw_mode_id[%d]", cap->hw_mode_id);
5317 WMA_LOGI("\t: pdev_id[%d]", cap->pdev_id);
5318 WMA_LOGI("\t: phy_id[%d]", cap->phy_id);
5319 WMA_LOGI("\t: supports_11b[%d]",
5320 WMI_SUPPORT_11B_GET(cap->supported_flags));
5321 WMA_LOGI("\t: supports_11g[%d]",
5322 WMI_SUPPORT_11G_GET(cap->supported_flags));
5323 WMA_LOGI("\t: supports_11a[%d]",
5324 WMI_SUPPORT_11A_GET(cap->supported_flags));
5325 WMA_LOGI("\t: supports_11n[%d]",
5326 WMI_SUPPORT_11N_GET(cap->supported_flags));
5327 WMA_LOGI("\t: supports_11ac[%d]",
5328 WMI_SUPPORT_11AC_GET(cap->supported_flags));
5329 WMA_LOGI("\t: supports_11ax[%d]",
5330 WMI_SUPPORT_11AX_GET(cap->supported_flags));
5331 WMA_LOGI("\t: supported_flags[%d]", cap->supported_flags);
5332 WMA_LOGI("\t: supported_bands[%d]", cap->supported_bands);
5333 WMA_LOGI("\t: ampdu_density[%d]", cap->ampdu_density);
5334 WMA_LOGI("\t: max_bw_supported_2G[%d]", cap->max_bw_supported_2G);
5335 WMA_LOGI("\t: ht_cap_info_2G[%d]", cap->ht_cap_info_2G);
5336 WMA_LOGI("\t: vht_cap_info_2G[%d]", cap->vht_cap_info_2G);
5337 WMA_LOGI("\t: vht_supp_mcs_2G[%d]", cap->vht_supp_mcs_2G);
5338 WMA_LOGI("\t: tx_chain_mask_2G[%d]", cap->tx_chain_mask_2G);
5339 WMA_LOGI("\t: rx_chain_mask_2G[%d]", cap->rx_chain_mask_2G);
5340 WMA_LOGI("\t: max_bw_supported_5G[%d]", cap->max_bw_supported_5G);
5341 WMA_LOGI("\t: ht_cap_info_5G[%d]", cap->ht_cap_info_5G);
5342 WMA_LOGI("\t: vht_cap_info_5G[%d]", cap->vht_cap_info_5G);
5343 WMA_LOGI("\t: vht_supp_mcs_5G[%d]", cap->vht_supp_mcs_5G);
5344 WMA_LOGI("\t: tx_chain_mask_5G[%d]", cap->tx_chain_mask_5G);
5345 WMA_LOGI("\t: rx_chain_mask_5G[%d]", cap->rx_chain_mask_5G);
5346 WMA_LOGI("\t: he_cap_info_2G[%08x]", cap->he_cap_info_2G);
5347 WMA_LOGI("\t: he_supp_mcs_2G[%08x]", cap->he_supp_mcs_2G);
5348 WMA_LOGI("\t: he_cap_info_5G[%08x]", cap->he_cap_info_5G);
5349 WMA_LOGI("\t: he_supp_mcs_5G[%08x]", cap->he_supp_mcs_5G);
5350 mac_2G = cap->he_cap_info_2G;
5351 mac_5G = cap->he_cap_info_5G;
5352 qdf_mem_copy(phy_2G, cap->he_cap_phy_info_2G,
5353 WMI_MAX_HECAP_PHY_SIZE * 4);
5354 qdf_mem_copy(phy_5G, cap->he_cap_phy_info_5G,
5355 WMI_MAX_HECAP_PHY_SIZE * 4);
5356 ppet_2G = cap->he_ppet2G;
5357 ppet_5G = cap->he_ppet5G;
5358
5359 wma_print_he_mac_cap(mac_2G);
5360 wma_print_he_phy_cap(phy_2G);
5361 wma_print_he_ppet(&ppet_2G);
5362 wma_print_he_mac_cap(mac_5G);
5363 wma_print_he_phy_cap(phy_5G);
5364 wma_print_he_ppet(&ppet_5G);
5365}
Krunal Soni0193b6f2016-08-15 15:53:43 -07005366
5367/**
Krunal Soni2e48d012016-05-02 16:55:26 -07005368 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
5369 * @wma_handle: pointer to wma_handle
5370 *
5371 * This function prints all the caps populater per hw mode and per PHY
5372 *
5373 * Return: none
5374 */
5375static void wma_print_populate_soc_caps(t_wma_handle *wma_handle)
5376{
5377 int i, j = 0, max_mac;
5378 WMI_MAC_PHY_CAPABILITIES *tmp;
5379
5380 /* print number of hw modes */
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005381 WMA_LOGD("%s: num of hw modes [%d]", __func__,
Krunal Soni2e48d012016-05-02 16:55:26 -07005382 wma_handle->phy_caps.num_hw_modes.num_hw_modes);
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005383 WMA_LOGD("%s: <====== HW mode cap printing starts ======>", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005384 /* print cap of each hw mode */
5385 for (i = 0; i < wma_handle->phy_caps.num_hw_modes.num_hw_modes; i++) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005386 WMA_LOGD("====>: hw mode id[%d], phy_id map[%d]",
Krunal Soni2e48d012016-05-02 16:55:26 -07005387 wma_handle->phy_caps.each_hw_mode_cap[i].hw_mode_id,
5388 wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map);
5389 if (wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map ==
5390 PHY1_PHY2)
5391 max_mac = j + 2;
5392 else
5393 max_mac = j + 1;
5394
5395 for ( ; j < max_mac; j++) {
5396 tmp = &wma_handle->phy_caps.each_phy_cap_per_hwmode[j];
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005397 wma_print_mac_phy_capabilities(tmp, j);
Krunal Soni2e48d012016-05-02 16:55:26 -07005398 }
5399 }
5400 WMA_LOGI("%s: <====== HW mode cap printing ends ======>\n", __func__);
5401}
5402
5403/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305404 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
5405 * in terms of hw_mode_bandwidth
5406 * @width: bandwidth in terms of wmi_channel_width
5407 *
5408 * This function returns the bandwidth in terms of hw_mode_bandwidth.
5409 *
5410 * Return: BW in terms of hw_mode_bandwidth.
5411 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005412static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305413 wmi_channel_width width)
5414{
5415 switch (width) {
5416 case WMI_CHAN_WIDTH_20:
5417 return HW_MODE_20_MHZ;
5418 case WMI_CHAN_WIDTH_40:
5419 return HW_MODE_40_MHZ;
5420 case WMI_CHAN_WIDTH_80:
5421 return HW_MODE_80_MHZ;
5422 case WMI_CHAN_WIDTH_160:
5423 return HW_MODE_160_MHZ;
5424 case WMI_CHAN_WIDTH_80P80:
5425 return HW_MODE_80_PLUS_80_MHZ;
5426 case WMI_CHAN_WIDTH_5:
5427 return HW_MODE_5_MHZ;
5428 case WMI_CHAN_WIDTH_10:
5429 return HW_MODE_10_MHZ;
5430 default:
5431 return HW_MODE_BW_NONE;
5432 }
5433
5434 return HW_MODE_BW_NONE;
5435}
5436
5437/**
5438 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
5439 * supported from the capabilities.
5440 * @caps: PHY capability
5441 * @info: param to store TX-RX stream and BW information
5442 *
5443 * This function will calculate TX-RX stream and bandwidth supported
5444 * as per the PHY capability, and assign to mac_ss_bw_info.
5445 *
5446 * Return: none
5447 */
5448static void wma_get_hw_mode_params(WMI_MAC_PHY_CAPABILITIES *caps,
5449 struct mac_ss_bw_info *info)
5450{
5451 if (!caps) {
5452 WMA_LOGE("%s: Invalid capabilities", __func__);
5453 return;
5454 }
5455
5456 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
5457 QDF_MAX(caps->tx_chain_mask_2G,
5458 caps->tx_chain_mask_5G));
5459 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
5460 QDF_MAX(caps->rx_chain_mask_2G,
5461 caps->rx_chain_mask_5G));
5462 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
5463 QDF_MAX(caps->max_bw_supported_2G,
5464 caps->max_bw_supported_5G));
5465}
5466
5467/**
5468 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
5469 * DBS in hw_mode_list
5470 * @wma_handle: pointer to wma global structure
5471 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
5472 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
5473 * @pos: refers to hw_mode_index
5474 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305475 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305476 *
5477 * This function sets TX-RX stream, bandwidth and DBS mode in
5478 * hw_mode_list.
5479 *
5480 * Return: none
5481 */
5482static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
5483 struct mac_ss_bw_info mac0_ss_bw_info,
5484 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305485 uint32_t pos, uint32_t dbs_mode,
5486 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305487{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305488 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305489 wma_handle->hw_mode.hw_mode_list[pos],
5490 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305491 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305492 wma_handle->hw_mode.hw_mode_list[pos],
5493 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305494 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305495 wma_handle->hw_mode.hw_mode_list[pos],
5496 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305497 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305498 wma_handle->hw_mode.hw_mode_list[pos],
5499 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305500 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305501 wma_handle->hw_mode.hw_mode_list[pos],
5502 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305503 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305504 wma_handle->hw_mode.hw_mode_list[pos],
5505 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305506 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305507 wma_handle->hw_mode.hw_mode_list[pos],
5508 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305509 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305510 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305511 HW_MODE_AGILE_DFS_NONE);
5512 WMA_HW_MODE_SBS_MODE_SET(
5513 wma_handle->hw_mode.hw_mode_list[pos],
5514 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305515}
5516
5517/**
5518 * wma_update_hw_mode_list() - updates hw_mode_list
5519 * @wma_handle: pointer to wma global structure
5520 *
5521 * This function updates hw_mode_list with tx_streams, rx_streams,
5522 * bandwidth, dbs and agile dfs for each hw_mode.
5523 *
5524 * Returns: 0 for success else failure.
5525 */
5526static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle)
5527{
5528 struct extended_caps *phy_caps;
5529 WMI_MAC_PHY_CAPABILITIES *tmp;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305530 uint32_t i, hw_config_type, j = 0;
5531 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305532 struct mac_ss_bw_info mac0_ss_bw_info = {0};
5533 struct mac_ss_bw_info mac1_ss_bw_info = {0};
Krunal Sonica50b452017-08-04 22:24:59 -07005534 WMI_PHY_CAPABILITY new_supported_band = 0;
5535 bool supported_band_update_failure = false;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305536
5537 if (!wma_handle) {
5538 WMA_LOGE("%s: Invalid wma handle", __func__);
5539 return QDF_STATUS_E_FAILURE;
5540 }
5541
5542 phy_caps = &wma_handle->phy_caps;
5543 if (!phy_caps) {
5544 WMA_LOGE("%s: Invalid phy capabilities", __func__);
5545 return QDF_STATUS_SUCCESS;
5546 }
5547
5548 if (!phy_caps->num_hw_modes.num_hw_modes) {
5549 WMA_LOGE("%s: Number of HW modes: %d",
5550 __func__, phy_caps->num_hw_modes.num_hw_modes);
5551 return QDF_STATUS_SUCCESS;
5552 }
5553
5554 /*
5555 * This list was updated as part of service ready event. Re-populate
5556 * HW mode list from the device capabilities.
5557 */
5558 if (wma_handle->hw_mode.hw_mode_list) {
5559 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
5560 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005561 WMA_LOGD("%s: DBS list is freed", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305562 }
5563
5564 wma_handle->num_dbs_hw_modes = phy_caps->num_hw_modes.num_hw_modes;
5565 wma_handle->hw_mode.hw_mode_list =
5566 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
5567 wma_handle->num_dbs_hw_modes);
5568 if (!wma_handle->hw_mode.hw_mode_list) {
5569 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
5570 return QDF_STATUS_E_FAILURE;
5571 }
5572
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005573 WMA_LOGD("%s: Updated HW mode list: Num modes:%d",
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305574 __func__, wma_handle->num_dbs_hw_modes);
5575
5576 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5577 /* Update for MAC0 */
5578 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5579 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
5580 hw_config_type =
5581 phy_caps->each_hw_mode_cap[i].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305582 dbs_mode = HW_MODE_DBS_NONE;
5583 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305584 mac1_ss_bw_info.mac_tx_stream = 0;
5585 mac1_ss_bw_info.mac_rx_stream = 0;
5586 mac1_ss_bw_info.mac_bw = 0;
Krunal Sonica50b452017-08-04 22:24:59 -07005587 if (QDF_STATUS_SUCCESS != wma_update_supported_bands(wma_handle,
5588 tmp->supported_bands,
5589 &new_supported_band))
5590 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305591
5592 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
5593 if ((hw_config_type == WMI_HW_MODE_DBS) ||
5594 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5595 (hw_config_type == WMI_HW_MODE_SBS)) {
5596 /* Update for MAC1 */
5597 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5598 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305599 if (hw_config_type == WMI_HW_MODE_DBS)
5600 dbs_mode = HW_MODE_DBS;
5601 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5602 (hw_config_type == WMI_HW_MODE_SBS))
5603 sbs_mode = HW_MODE_SBS;
Krunal Sonica50b452017-08-04 22:24:59 -07005604 if (QDF_STATUS_SUCCESS !=
5605 wma_update_supported_bands(wma_handle,
5606 tmp->supported_bands,
5607 &new_supported_band))
5608 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305609 }
5610
5611 /* Updating HW mode list */
5612 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305613 mac1_ss_bw_info, i, dbs_mode,
5614 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305615 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005616
Krunal Sonica50b452017-08-04 22:24:59 -07005617 /* overwrite phy_capability which we got from service ready event */
5618 if (!supported_band_update_failure) {
5619 WMA_LOGD("%s: updating supported band from old[%d] to new[%d]",
5620 __func__, wma_handle->phy_capability,
5621 new_supported_band);
5622 wma_handle->phy_capability = new_supported_band;
5623 }
5624
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005625 if (QDF_STATUS_SUCCESS !=
Krunal Sonica50b452017-08-04 22:24:59 -07005626 policy_mgr_update_hw_mode_list(wma_handle->psoc,
5627 phy_caps))
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005628 WMA_LOGE("%s: failed to update policy manager", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305629 wma_dump_dbs_hw_mode(wma_handle);
5630 return QDF_STATUS_SUCCESS;
5631}
5632
Naveen Rawat4efe41b2017-04-29 16:23:14 -07005633static void wma_init_wifi_pos_dma_rings(t_wma_handle *wma_handle,
5634 uint8_t num_mac, void *buf)
5635{
5636 struct hif_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
5637 void *hal_soc = hif_get_hal_handle(hif_ctx);
5638
5639 wifi_pos_init_cir_cfr_rings(wma_handle->psoc, hal_soc, num_mac, buf);
5640}
5641
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305642/**
Krunal Soni2e48d012016-05-02 16:55:26 -07005643 * wma_populate_soc_caps() - populate entire SOC's capabilities
5644 * @wma_handle: pointer to wma global structure
5645 * @param_buf: pointer to param of service ready extension event from fw
5646 *
5647 * This API populates all capabilities of entire SOC. For example,
5648 * how many number of hw modes are supported by this SOC, what are the
5649 * capabilities of each phy per hw mode, what are HAL reg capabilities per
5650 * phy.
5651 *
5652 * Return: none
5653 */
5654static void wma_populate_soc_caps(t_wma_handle *wma_handle,
5655 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
5656{
5657 int i, num_of_mac_caps = 0, tmp = 0;
5658 struct extended_caps *phy_caps;
5659 struct hw_mode_idx_to_mac_cap_idx *map;
5660
5661 WMA_LOGD("%s: Enter", __func__);
5662
5663 if (!wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005664 WMA_LOGE("%s: Invalid WMA handle", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005665 return;
5666 }
5667
5668 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005669 WMA_LOGE("%s: Invalid event", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005670 return;
5671 }
5672 phy_caps = &wma_handle->phy_caps;
5673
5674 /*
5675 * first thing to do is to get how many number of hw modes are
5676 * supported and populate in wma_handle global structure
5677 */
Krunal Sonifd85ba62016-07-11 08:18:53 -07005678 if (NULL == param_buf->soc_hw_mode_caps) {
5679 WMA_LOGE("%s: Invalid number of hw modes", __func__);
5680 return;
5681 }
5682
Krunal Soni2e48d012016-05-02 16:55:26 -07005683 qdf_mem_copy(&phy_caps->num_hw_modes,
5684 param_buf->soc_hw_mode_caps,
5685 sizeof(WMI_SOC_MAC_PHY_HW_MODE_CAPS));
5686 if (0 == phy_caps->num_hw_modes.num_hw_modes) {
Krunal Sonifd85ba62016-07-11 08:18:53 -07005687 WMA_LOGE("%s: Number of hw modes is zero", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005688 return;
Krunal Soni2e48d012016-05-02 16:55:26 -07005689 }
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005690 WMA_LOGD("%s: Given number of hw modes[%d]",
Krunal Sonifd85ba62016-07-11 08:18:53 -07005691 __func__, phy_caps->num_hw_modes.num_hw_modes);
Krunal Soni2e48d012016-05-02 16:55:26 -07005692
5693 /*
5694 * next thing is to allocate the memory to map hw mode to phy/mac caps
5695 */
5696 phy_caps->hw_mode_to_mac_cap_map =
5697 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5698 sizeof(struct hw_mode_idx_to_mac_cap_idx));
5699 if (!phy_caps->hw_mode_to_mac_cap_map) {
5700 WMA_LOGE("%s: Memory allocation failed", __func__);
5701 return;
5702 }
5703
5704 /*
5705 * next thing is to allocate the memory for per hw caps
5706 */
5707 phy_caps->each_hw_mode_cap =
5708 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5709 sizeof(WMI_HW_MODE_CAPABILITIES));
5710 if (!phy_caps->each_hw_mode_cap) {
5711 WMA_LOGE("%s: Memory allocation failed", __func__);
5712 wma_cleanup_dbs_phy_caps(wma_handle);
5713 return;
5714 }
5715 qdf_mem_copy(phy_caps->each_hw_mode_cap,
5716 param_buf->hw_mode_caps,
5717 phy_caps->num_hw_modes.num_hw_modes *
5718 sizeof(WMI_HW_MODE_CAPABILITIES));
5719 /*
5720 * next thing is to count the number of mac cap to populate per
5721 * hw mode and generate map, so that our search can be done
5722 * efficiently which is O(1)
5723 */
5724 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
5725 map = &phy_caps->hw_mode_to_mac_cap_map[i];
5726 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2) {
5727 tmp = num_of_mac_caps;
5728 num_of_mac_caps = num_of_mac_caps + 2;
5729 map->num_of_macs = 2;
5730 } else {
5731 tmp = num_of_mac_caps;
5732 num_of_mac_caps = num_of_mac_caps + 1;
5733 map->num_of_macs = 1;
5734 }
5735 map->mac_cap_idx = tmp;
5736 map->hw_mode_id = phy_caps->each_hw_mode_cap[i].hw_mode_id;
5737 }
5738
5739 /*
5740 * next thing is to populate each phy caps per hw mode
5741 */
5742 phy_caps->each_phy_cap_per_hwmode =
5743 qdf_mem_malloc(num_of_mac_caps *
5744 sizeof(WMI_MAC_PHY_CAPABILITIES));
5745 if (!phy_caps->each_phy_cap_per_hwmode) {
5746 WMA_LOGE("%s: Memory allocation failed", __func__);
5747 wma_cleanup_dbs_phy_caps(wma_handle);
5748 return;
5749 }
5750 qdf_mem_copy(phy_caps->each_phy_cap_per_hwmode,
5751 param_buf->mac_phy_caps,
5752 num_of_mac_caps * sizeof(WMI_MAC_PHY_CAPABILITIES));
5753
5754 /*
5755 * next thing is to populate reg caps per phy
5756 */
5757 qdf_mem_copy(&phy_caps->num_phy_for_hal_reg_cap,
5758 param_buf->soc_hal_reg_caps,
5759 sizeof(WMI_SOC_HAL_REG_CAPABILITIES));
5760 if (phy_caps->num_phy_for_hal_reg_cap.num_phy == 0) {
5761 WMA_LOGE("%s: incorrect number of phys", __func__);
5762 wma_cleanup_dbs_phy_caps(wma_handle);
5763 return;
5764 }
5765 phy_caps->each_phy_hal_reg_cap =
5766 qdf_mem_malloc(phy_caps->num_phy_for_hal_reg_cap.num_phy *
5767 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
5768 if (!phy_caps->each_phy_hal_reg_cap) {
5769 WMA_LOGE("%s: Memory allocation failed", __func__);
5770 wma_cleanup_dbs_phy_caps(wma_handle);
5771 return;
5772 }
5773 qdf_mem_copy(phy_caps->each_phy_hal_reg_cap,
5774 param_buf->hal_reg_caps,
5775 phy_caps->num_phy_for_hal_reg_cap.num_phy *
5776 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
Naveen Rawat4efe41b2017-04-29 16:23:14 -07005777
5778 wma_init_wifi_pos_dma_rings(wma_handle,
5779 param_buf->num_oem_dma_ring_caps,
5780 param_buf->oem_dma_ring_caps);
5781
Krunal Soni2e48d012016-05-02 16:55:26 -07005782 wma_print_populate_soc_caps(wma_handle);
Krunal Soni2e48d012016-05-02 16:55:26 -07005783}
5784
5785/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005786 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
5787 * @handle: wma handle
5788 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05305789 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 *
5791 * Return: none
5792 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305793int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
5794 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005795{
5796 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5797 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
5798 wmi_service_ready_ext_event_fixed_param *ev;
5799 int status;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305800 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005801
5802 WMA_LOGD("%s: Enter", __func__);
5803
5804 if (!wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005805 WMA_LOGE("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305806 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005807 }
5808
5809 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
5810 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005811 WMA_LOGE("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305812 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 }
5814
5815 ev = param_buf->fixed_param;
5816 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005817 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305818 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005819 }
5820
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005821 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005823 WMA_LOGD("%s: Defaults: scan config:%x FW mode config:%x",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305824 __func__, ev->default_conc_scan_config_bits,
5825 ev->default_fw_config_bits);
5826
Anurag Chouhan210db072016-02-22 18:42:15 +05305827 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305828 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005829 WMA_LOGE("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05305830 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005831 }
Krunal Soni2e48d012016-05-02 16:55:26 -07005832 wma_populate_soc_caps(wma_handle, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005833
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305834 ret = wma_update_hw_mode_list(wma_handle);
5835 if (QDF_IS_STATUS_ERROR(ret)) {
5836 WMA_LOGE("Failed to update hw mode list");
5837 return -EINVAL;
5838 }
5839
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005840 WMA_LOGD("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05305841 status = wmi_unified_send_saved_init_cmd(wma_handle->wmi_handle);
5842 if (status != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005843 /* In success case, WMI layer will free after getting copy
5844 * engine TX complete interrupt
5845 */
5846 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305848 wma_init_scan_fw_mode_config(wma_handle,
5849 ev->default_conc_scan_config_bits,
5850 ev->default_fw_config_bits);
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07005851 wma_handle->target_fw_vers_ext = ev->fw_build_vers_ext;
Govind Singhd76a5b02016-03-08 15:12:14 +05305852 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853}
5854
5855/**
5856 * wma_rx_ready_event() - event handler to process
5857 * wmi rx ready event.
5858 * @handle: wma handle
5859 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05305860 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005861 *
5862 * Return: none
5863 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305864int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
5865 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005866{
5867 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5868 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
5869 wmi_ready_event_fixed_param *ev = NULL;
5870
5871 WMA_LOGD("%s: Enter", __func__);
5872
5873 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
5874 if (!(wma_handle && param_buf)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005875 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305876 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05305877 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878 }
5879
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005880 WMA_LOGD("WMA <-- WMI_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005881
5882 ev = param_buf->fixed_param;
5883 /* Indicate to the waiting thread that the ready
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005884 * event was received
5885 */
Naveen Rawat64e477e2016-05-20 10:34:56 -07005886 wma_handle->sub_20_support =
5887 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5888 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 wma_handle->wmi_ready = true;
5890 wma_handle->wlan_init_status = ev->status;
5891
5892 /*
5893 * We need to check the WMI versions and make sure both
5894 * host and fw are compatible.
5895 */
5896 if (!wmi_versions_are_compatible(&wma_handle->final_abi_vers,
5897 &ev->fw_abi_vers)) {
5898 /*
5899 * Error: Our host version and the given firmware version
5900 * are incompatible.
5901 */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005902 WMA_LOGE("%s: Error: Incompatible WMI version.", __func__);
5903 WMA_LOGE("%s: Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005904 __func__,
5905 WMI_VER_GET_MAJOR(wma_handle->final_abi_vers.
5906 abi_version_0),
5907 WMI_VER_GET_MINOR(wma_handle->final_abi_vers.
5908 abi_version_0),
5909 wma_handle->final_abi_vers.abi_version_ns_0,
5910 wma_handle->final_abi_vers.abi_version_ns_1,
5911 wma_handle->final_abi_vers.abi_version_ns_2,
5912 wma_handle->final_abi_vers.abi_version_ns_3,
5913 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
5914 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
5915 ev->fw_abi_vers.abi_version_ns_0,
5916 ev->fw_abi_vers.abi_version_ns_1,
5917 ev->fw_abi_vers.abi_version_ns_2,
5918 ev->fw_abi_vers.abi_version_ns_3);
5919 if (wma_handle->wlan_init_status == WLAN_INIT_STATUS_SUCCESS) {
5920 /* Failed this connection to FW */
5921 wma_handle->wlan_init_status =
5922 WLAN_INIT_STATUS_GEN_FAILED;
5923 }
5924 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305925 qdf_mem_copy(&wma_handle->final_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005926 sizeof(wmi_abi_version));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305927 qdf_mem_copy(&wma_handle->target_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928 sizeof(wmi_abi_version));
5929
5930 /* copy the mac addr */
5931 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
5932 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
5933
5934 wma_update_hdd_cfg(wma_handle);
5935
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305936 qdf_event_set(&wma_handle->wma_ready_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005937
5938 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05305939
5940 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941}
5942
5943/**
5944 * wma_setneedshutdown() - setting wma needshutdown flag
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945 *
5946 * Return: none
5947 */
Jeff Johnson1f8d0a02017-09-13 08:09:05 -07005948void wma_setneedshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949{
5950 tp_wma_handle wma_handle;
5951
5952 WMA_LOGD("%s: Enter", __func__);
5953
Anurag Chouhan6d760662016-02-20 16:05:43 +05305954 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005955
5956 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005957 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305958 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005959 return;
5960 }
5961
5962 wma_handle->needShutdown = true;
5963 WMA_LOGD("%s: Exit", __func__);
5964}
5965
5966/**
5967 * wma_needshutdown() - Is wma needs shutdown?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005968 *
5969 * Return: returns true/false
5970 */
Jeff Johnson1b5404e2017-09-13 08:04:46 -07005971bool wma_needshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972{
5973 tp_wma_handle wma_handle;
5974
5975 WMA_LOGD("%s: Enter", __func__);
5976
Anurag Chouhan6d760662016-02-20 16:05:43 +05305977 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005978
5979 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005980 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305981 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 return false;
5983 }
5984
5985 WMA_LOGD("%s: Exit", __func__);
5986 return wma_handle->needShutdown;
5987}
5988
5989/**
5990 * wma_wait_for_ready_event() - wait for wma ready event
5991 * @handle: wma handle
5992 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305993 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305995QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005996{
5997 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305998 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999
6000 /* wait until WMI_READY_EVENTID received from FW */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05306001 qdf_status = qdf_wait_single_event(&(wma_handle->wma_ready_event),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006002 WMA_READY_EVENTID_TIMEOUT);
6003
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306004 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006005 WMA_LOGE("%s: Timeout waiting for ready event from FW",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006006 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306007 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306009 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010}
6011
6012/**
6013 * wma_set_ppsconfig() - set pps config in fw
6014 * @vdev_id: vdev id
6015 * @pps_param: pps params
6016 * @val : param value
6017 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306018 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006019 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306020QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021 int val)
6022{
Anurag Chouhan6d760662016-02-20 16:05:43 +05306023 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024 int ret = -EIO;
6025 uint32_t pps_val;
6026
6027 if (NULL == wma) {
6028 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306029 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006030 }
6031
6032 switch (pps_param) {
6033 case WMA_VHT_PPS_PAID_MATCH:
6034 pps_val = ((val << 31) & 0xffff0000) |
6035 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
6036 goto pkt_pwr_save_config;
6037 case WMA_VHT_PPS_GID_MATCH:
6038 pps_val = ((val << 31) & 0xffff0000) |
6039 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
6040 goto pkt_pwr_save_config;
6041 case WMA_VHT_PPS_DELIM_CRC_FAIL:
6042 pps_val = ((val << 31) & 0xffff0000) |
6043 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
6044 goto pkt_pwr_save_config;
6045
6046 /* Enable the code below as and when the functionality
6047 * is supported/added in host.
6048 */
6049#ifdef NOT_YET
6050 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
6051 pps_val = ((val << 31) & 0xffff0000) |
6052 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
6053 goto pkt_pwr_save_config;
6054 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
6055 pps_val = ((val << 31) & 0xffff0000) |
6056 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
6057 goto pkt_pwr_save_config;
6058 case WMA_VHT_PPS_EOF_PAD_DELIM:
6059 pps_val = ((val << 31) & 0xffff0000) |
6060 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
6061 goto pkt_pwr_save_config;
6062 case WMA_VHT_PPS_MACADDR_MISMATCH:
6063 pps_val = ((val << 31) & 0xffff0000) |
6064 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
6065 goto pkt_pwr_save_config;
6066 case WMA_VHT_PPS_GID_NSTS_ZERO:
6067 pps_val = ((val << 31) & 0xffff0000) |
6068 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
6069 goto pkt_pwr_save_config;
6070 case WMA_VHT_PPS_RSSI_CHECK:
6071 pps_val = ((val << 31) & 0xffff0000) |
6072 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
6073 goto pkt_pwr_save_config;
6074#endif /* NOT_YET */
6075pkt_pwr_save_config:
6076 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
6077 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05306078 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006079 WMI_VDEV_PARAM_PACKET_POWERSAVE,
6080 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 break;
6082 default:
6083 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
6084 }
6085
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306086 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006087}
6088
6089/**
6090 * wma_process_set_mas() - Function to enable/disable MAS
6091 * @wma: Pointer to WMA handle
6092 * @mas_val: 1-Enable MAS, 0-Disable MAS
6093 *
6094 * This function enables/disables the MAS value
6095 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306096 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006098static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
6099 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006100{
6101 uint32_t val;
6102
6103 if (NULL == wma || NULL == mas_val) {
6104 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306105 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006106 }
6107
6108 val = (*mas_val);
6109
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306110 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006111 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
6112 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306113 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006114 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006115 WMA_LOGE("%s: Value is %d", __func__, val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306116 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006117}
6118
6119/**
6120 * wma_process_set_miracast() - Function to set miracast value in WMA
6121 * @wma: Pointer to WMA handle
6122 * @miracast_val: 0-Disabled,1-Source,2-Sink
6123 *
6124 * This function stores the miracast value in WMA
6125 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306126 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006127 *
6128 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006129static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
6130 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131{
6132 if (NULL == wma || NULL == miracast_val) {
6133 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306134 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006135 }
6136
6137 wma->miracast_value = *miracast_val;
6138 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
6139
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306140 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006141}
6142
6143/**
6144 * wma_config_stats_factor() - Function to configure stats avg. factor
6145 * @wma: pointer to WMA handle
6146 * @avg_factor: stats. avg. factor passed down by userspace
6147 *
6148 * This function configures the avg. stats value in firmware
6149 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306150 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006151 *
6152 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306153static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006154 struct sir_stats_avg_factor *avg_factor)
6155{
Govind Singhd76a5b02016-03-08 15:12:14 +05306156 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157
6158 if (NULL == wma || NULL == avg_factor) {
6159 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306160 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006161 }
6162
Govind Singhd76a5b02016-03-08 15:12:14 +05306163 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006164 avg_factor->vdev_id,
6165 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
6166 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05306167 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006168 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
6169 avg_factor->vdev_id);
6170 }
6171
6172 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
6173 avg_factor->stats_avg_factor, avg_factor->vdev_id);
6174
6175 return ret;
6176}
6177
6178/**
6179 * wma_config_guard_time() - Function to set guard time in firmware
6180 * @wma: pointer to WMA handle
6181 * @guard_time: guard time passed down by userspace
6182 *
6183 * This function configures the guard time in firmware
6184 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306185 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 *
6187 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306188static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006189 struct sir_guard_time_request *guard_time)
6190{
Govind Singhd76a5b02016-03-08 15:12:14 +05306191 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006192
6193 if (NULL == wma || NULL == guard_time) {
6194 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306195 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006196 }
6197
Govind Singhd76a5b02016-03-08 15:12:14 +05306198 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199 guard_time->vdev_id,
6200 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
6201 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05306202 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 WMA_LOGE(" failed to set guard time for vdev_id %d",
6204 guard_time->vdev_id);
6205 }
6206
6207 WMA_LOGD("Set guard time %d for vdev_id %d",
6208 guard_time->guard_time, guard_time->vdev_id);
6209
6210 return ret;
6211}
6212
6213/**
6214 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
6215 * @wma_handle: WMA handle
6216 * @start_log: Start logging related parameters
6217 *
6218 * Send the command to the FW based on which specific logging of diag
6219 * event/log id can be started/stopped
6220 *
6221 * Return: None
6222 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006223static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
6224 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006225{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006226
6227 if (!start_log) {
6228 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6229 return;
6230 }
6231 if (!wma_handle) {
6232 WMA_LOGE("%s: Invalid wma handle", __func__);
6233 return;
6234 }
6235
6236 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
6237 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
6238 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
6239 __func__, start_log->ring_id);
6240 return;
6241 }
6242
Govind Singhf25a0f12016-03-08 16:09:48 +05306243 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
6244 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006245}
6246
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306247#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006248/**
6249 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
6250 * @wma_handle: WMA handle
6251 * @start_log: Struture containing the start wifi logger params
6252 *
6253 * This function is used to send the WMA commands to start/stop logging
6254 * of per packet statistics
6255 *
6256 * Return: None
6257 *
6258 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006259#ifdef REMOVE_PKT_LOG
6260static void wma_set_wifi_start_packet_stats(void *wma_handle,
6261 struct sir_wifi_start_log *start_log)
6262{
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006263}
6264#else
6265static void wma_set_wifi_start_packet_stats(void *wma_handle,
6266 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006267{
Komal Seelam3d202862016-02-24 18:43:24 +05306268 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006269 uint32_t log_state;
6270
6271 if (!start_log) {
6272 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6273 return;
6274 }
6275 if (!wma_handle) {
6276 WMA_LOGE("%s: Invalid wma handle", __func__);
6277 return;
6278 }
6279
6280 /* No need to register for ring IDs other than packet stats */
6281 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006282 WMA_LOGD("%s: Ring id is not for per packet stats: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006283 __func__, start_log->ring_id);
6284 return;
6285 }
6286
Anurag Chouhan6d760662016-02-20 16:05:43 +05306287 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07006288 if (scn == NULL) {
6289 WMA_LOGE("%s: Invalid HIF handle", __func__);
6290 return;
6291 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292
6293 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05306294 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
6295 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006296
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306297 if (start_log->size != 0) {
6298 pktlog_setsize(scn, start_log->size * MEGABYTE);
6299 return;
Poddar, Siddarthab99a272017-04-10 12:53:26 +05306300 } else if (start_log->is_pktlog_buff_clear == true) {
6301 pktlog_clearbuff(scn, start_log->is_pktlog_buff_clear);
6302 return;
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306303 }
6304
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006305 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006306 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306307 start_log->user_triggered,
6308 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006309 WMA_LOGD("%s: Enabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006310 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006311 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306312 start_log->user_triggered,
6313 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006314 WMA_LOGD("%s: Disabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315 }
6316}
6317#endif
6318
6319/**
6320 * wma_send_flush_logs_to_fw() - Send log flush command to FW
6321 * @wma_handle: WMI handle
6322 *
6323 * This function is used to send the flush command to the FW,
6324 * that will flush the fw logs that are residue in the FW
6325 *
6326 * Return: None
6327 */
6328void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
6329{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306330 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006331 int ret;
6332
Govind Singhf25a0f12016-03-08 16:09:48 +05306333 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
6334 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006335 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006336
Anurag Chouhan210db072016-02-22 18:42:15 +05306337 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006338 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306339 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006340 WMA_LOGE("Failed to start the log completion timer");
6341}
6342
6343/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306344 * wma_update_wep_default_key - To update default key id
6345 * @wma: pointer to wma handler
6346 * @update_def_key: pointer to wep_update_default_key_idx
6347 *
6348 * This function makes a copy of default key index to txrx node
6349 *
6350 * Return: Success
6351 */
6352static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
6353 struct wep_update_default_key_idx *update_def_key)
6354{
6355 struct wma_txrx_node *iface =
6356 &wma->interfaces[update_def_key->session_id];
6357 iface->wep_default_key_idx = update_def_key->default_idx;
6358
6359 return QDF_STATUS_SUCCESS;
6360}
6361
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05306362/**
6363 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
6364 * @wma_handle: WMA handle
6365 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
6366 *
6367 * This function is used to set Tx pkt fail count threshold,
6368 * FW will do disconnect with station once this threshold is reached.
6369 *
6370 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6371 */
6372static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006373 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05306374{
6375 u_int8_t vdev_id;
6376 u_int32_t tx_fail_disconn_th;
6377 int ret = -EIO;
6378
6379 if (!wma || !wma->wmi_handle) {
6380 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
6381 return QDF_STATUS_E_INVAL;
6382 }
6383 vdev_id = tx_fail_cnt_th->session_id;
6384 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
6385 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
6386 vdev_id, tx_fail_disconn_th);
6387
6388
6389 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6390 WMI_VDEV_PARAM_DISCONNECT_TH,
6391 tx_fail_disconn_th);
6392
6393 if (ret) {
6394 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
6395 return QDF_STATUS_E_FAILURE;
6396 }
6397
6398 return QDF_STATUS_SUCCESS;
6399}
6400
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306401/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306402 * wma_update_short_retry_limit() - Set retry limit for short frames
6403 * @wma_handle: WMA handle
6404 * @short_retry_limit_th: retry limir count for Short frames.
6405 *
6406 * This function is used to configure the transmission retry limit at which
6407 * short frames needs to be retry.
6408 *
6409 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6410 */
6411static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
6412 struct sme_short_retry_limit *short_retry_limit_th)
6413{
6414 uint8_t vdev_id;
6415 uint32_t short_retry_limit;
6416 int ret;
6417
6418 if (!wma || !wma->wmi_handle) {
6419 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
6420 return QDF_STATUS_E_INVAL;
6421 }
6422 vdev_id = short_retry_limit_th->session_id;
6423 short_retry_limit = short_retry_limit_th->short_retry_limit;
6424 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
6425 vdev_id, short_retry_limit);
6426
6427 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6428 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
6429 short_retry_limit);
6430
6431 if (ret) {
6432 WMA_LOGE("Failed to send short limit threshold command");
6433 return QDF_STATUS_E_FAILURE;
6434 }
6435 return QDF_STATUS_SUCCESS;
6436}
6437
6438/**
6439 * wma_update_long_retry_limit() - Set retry limit for long frames
6440 * @wma_handle: WMA handle
6441 * @long_retry_limit_th: retry limir count for long frames
6442 *
6443 * This function is used to configure the transmission retry limit at which
6444 * long frames needs to be retry
6445 *
6446 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6447 */
6448static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
6449 struct sme_long_retry_limit *long_retry_limit_th)
6450{
6451 uint8_t vdev_id;
6452 uint32_t long_retry_limit;
6453 int ret;
6454
6455 if (!wma || !wma->wmi_handle) {
6456 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
6457 return QDF_STATUS_E_INVAL;
6458 }
6459 vdev_id = long_retry_limit_th->session_id;
6460 long_retry_limit = long_retry_limit_th->long_retry_limit;
6461 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
6462 vdev_id, long_retry_limit);
6463
6464 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6465 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
6466 long_retry_limit);
6467
6468 if (ret) {
6469 WMA_LOGE("Failed to send long limit threshold command");
6470 return QDF_STATUS_E_FAILURE;
6471 }
6472
6473 return QDF_STATUS_SUCCESS;
6474}
6475
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05306476/*
6477 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
6478 * @wma_handle: WMA handle
6479 * @sta_inactivity_timer: sme_sta_inactivity_timeout
6480 *
6481 * This function is used to set sta_inactivity_timeout.
6482 * If a station does not send anything in sta_inactivity_timeout seconds, an
6483 * empty data frame is sent to it in order to verify whether it is
6484 * still in range. If this frame is not ACKed, the station will be
6485 * disassociated and then deauthenticated.
6486 *
6487 * Return: None
6488 */
6489void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
6490 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
6491{
6492 uint8_t vdev_id;
6493 uint32_t max_unresponsive_time;
6494 uint32_t min_inactive_time, max_inactive_time;
6495
6496 if (!wma || !wma->wmi_handle) {
6497 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
6498 return;
6499 }
6500 vdev_id = sta_inactivity_timer->session_id;
6501 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
6502 max_inactive_time = max_unresponsive_time * TWO_THIRD;
6503 min_inactive_time = max_unresponsive_time - max_inactive_time;
6504
6505 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6506 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
6507 min_inactive_time))
6508 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
6509
6510 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6511 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
6512 max_inactive_time))
6513 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
6514
6515 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6516 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
6517 max_unresponsive_time))
6518 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
6519
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006520 WMA_LOGD("%s:vdev_id:%d min_inactive_time: %u max_inactive_time: %u max_unresponsive_time: %u",
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05306521 __func__, vdev_id,
6522 min_inactive_time, max_inactive_time,
6523 max_unresponsive_time);
6524}
6525
Yingying Tang95409972016-10-20 15:16:15 +08006526#ifdef WLAN_FEATURE_WOW_PULSE
6527
6528
6529#define WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
6530WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMD_fixed_param
6531
6532
6533#define WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
6534WMITLV_TAG_STRUC_wmi_wow_hostwakeup_gpio_pin_pattern_config_cmd_fixed_param
6535
6536/**
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006537 * wma_send_wow_pulse_cmd() - send wmi cmd of wow pulse cmd
6538 * information to fw.
6539 * @wma_handle: wma handler
6540 * @udp_response: wow_pulse_mode pointer
6541 *
6542 * Return: Return QDF_STATUS
6543 */
Yingying Tang95409972016-10-20 15:16:15 +08006544static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
6545 struct wow_pulse_mode *wow_pulse_cmd)
6546{
6547 QDF_STATUS status = QDF_STATUS_SUCCESS;
6548 wmi_buf_t buf;
6549 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *cmd;
6550 u_int16_t len;
6551
6552 len = sizeof(*cmd);
6553 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6554 if (!buf) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006555 WMA_LOGE("wmi_buf_alloc failed");
6556 return QDF_STATUS_E_NOMEM;
Yingying Tang95409972016-10-20 15:16:15 +08006557 }
6558
6559 cmd = (WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *)wmi_buf_data(buf);
6560 qdf_mem_zero(cmd, len);
6561
6562 WMITLV_SET_HDR(&cmd->tlv_header,
6563 WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM,
6564 WMITLV_GET_STRUCT_TLVLEN(
6565 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM));
6566
6567 cmd->enable = wow_pulse_cmd->wow_pulse_enable;
6568 cmd->pin = wow_pulse_cmd->wow_pulse_pin;
6569 cmd->interval_low = wow_pulse_cmd->wow_pulse_interval_low;
6570 cmd->interval_high = wow_pulse_cmd->wow_pulse_interval_high;
6571 cmd->repeat_cnt = WMI_WOW_PULSE_REPEAT_CNT;
6572
6573 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6574 WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID)) {
6575 WMA_LOGE("Failed to send send wow pulse");
6576 wmi_buf_free(buf);
6577 status = QDF_STATUS_E_FAILURE;
6578 }
6579
6580 WMA_LOGD("%s: Exit", __func__);
6581 return status;
6582}
6583
6584#undef WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
6585#undef WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
6586#undef WMI_WOW_PULSE_REPEAT_CNT
6587
6588#else
6589static inline QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
6590 struct wow_pulse_mode *wow_pulse_cmd)
6591{
6592 return QDF_STATUS_E_FAILURE;
6593}
6594#endif
6595
6596
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306597/**
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05306598 * wma_process_power_debug_stats_req() - Process the Chip Power stats collect
6599 * request and pass the Power stats request to Fw
6600 * @wma_handle: WMA handle
6601 *
6602 * Return: QDF_STATUS
6603 */
6604#ifdef WLAN_POWER_DEBUGFS
6605static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
6606{
6607 wmi_pdev_get_chip_power_stats_cmd_fixed_param *cmd;
6608 int32_t len;
6609 wmi_buf_t buf;
6610 uint8_t *buf_ptr;
6611 int ret;
6612
6613 if (!wma_handle) {
6614 WMA_LOGE("%s: input pointer is NULL", __func__);
6615 return QDF_STATUS_E_FAILURE;
6616 }
6617
6618 len = sizeof(*cmd);
6619 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6620 if (!buf) {
6621 WMA_LOGE("%s: Failed allocate wmi buffer", __func__);
6622 return QDF_STATUS_E_NOMEM;
6623 }
6624
6625 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6626 cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr;
6627
6628 WMITLV_SET_HDR(&cmd->tlv_header,
6629 WMITLV_TAG_STRUC_wmi_get_chip_power_stats_cmd_fixed_param,
6630 WMITLV_GET_STRUCT_TLVLEN(
6631 wmi_pdev_get_chip_power_stats_cmd_fixed_param));
6632 cmd->pdev_id = 0;
6633
6634 WMA_LOGD("POWER_DEBUG_STATS - Get Request Params; Pdev id - %d",
6635 cmd->pdev_id);
6636 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6637 WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
6638 if (ret) {
6639 WMA_LOGE("%s: Failed to send power debug stats request",
6640 __func__);
6641 wmi_buf_free(buf);
6642 return QDF_STATUS_E_FAILURE;
6643 }
6644 return QDF_STATUS_SUCCESS;
6645}
6646#else
6647static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
6648{
6649 return QDF_STATUS_SUCCESS;
6650}
6651#endif
6652
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05306653/**
6654 * wma_set_arp_req_stats() - process set arp stats request command to fw
6655 * @wma_handle: WMA handle
6656 * @req_buf: set srp stats request buffer
6657 *
6658 * Return: None
6659 */
6660static void wma_set_arp_req_stats(WMA_HANDLE handle,
6661 struct set_arp_stats_params *req_buf)
6662{
6663 int status;
6664 struct set_arp_stats *arp_stats;
6665 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6666
6667 if (!wma_handle || !wma_handle->wmi_handle) {
6668 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
6669 __func__);
6670 return;
6671 }
6672
6673 arp_stats = (struct set_arp_stats *)req_buf;
6674 status = wmi_unified_set_arp_stats_req(wma_handle->wmi_handle,
6675 arp_stats);
6676 if (status != EOK)
6677 WMA_LOGE("%s: failed to set arp stats to FW",
6678 __func__);
6679}
6680
6681/**
6682 * wma_get_arp_req_stats() - process get arp stats request command to fw
6683 * @wma_handle: WMA handle
6684 * @req_buf: get srp stats request buffer
6685 *
6686 * Return: None
6687 */
6688static void wma_get_arp_req_stats(WMA_HANDLE handle,
6689 struct get_arp_stats_params *req_buf)
6690{
6691 int status;
6692 struct get_arp_stats *arp_stats;
6693 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6694
6695 if (!wma_handle || !wma_handle->wmi_handle) {
6696 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
6697 __func__);
6698 return;
6699 }
6700
6701 arp_stats = (struct get_arp_stats *)req_buf;
6702 status = wmi_unified_get_arp_stats_req(wma_handle->wmi_handle,
6703 arp_stats);
6704 if (status != EOK)
6705 WMA_LOGE("%s: failed to send get arp stats to FW",
6706 __func__);
6707}
6708
lifeng66831662017-05-19 16:01:35 +08006709QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle,
6710 struct sir_set_rx_reorder_timeout_val *reorder_timeout)
6711{
6712 wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *cmd;
6713 uint32_t len;
6714 wmi_buf_t buf;
6715 int ret;
6716
6717 if (!reorder_timeout) {
6718 WMA_LOGE(FL("invalid pointer"));
6719 return QDF_STATUS_E_INVAL;
6720 }
6721
6722 if (!wma_handle) {
6723 WMA_LOGE(FL("WMA context is invald!"));
6724 return QDF_STATUS_E_INVAL;
6725 }
6726 len = sizeof(*cmd);
6727 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6728
6729 if (!buf) {
6730 WMA_LOGE(FL("Failed allocate wmi buffer"));
6731 return QDF_STATUS_E_NOMEM;
6732 }
6733 cmd = (wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *)
6734 wmi_buf_data(buf);
6735
6736 WMITLV_SET_HDR(&cmd->tlv_header,
6737 WMITLV_TAG_STRUC_wmi_pdev_set_reorder_timeout_val_cmd_fixed_param,
6738 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_reorder_timeout_val_cmd_fixed_param));
6739
6740 memcpy(cmd->rx_timeout_pri, reorder_timeout->rx_timeout_pri,
6741 sizeof(reorder_timeout->rx_timeout_pri));
6742
6743 WMA_LOGD("rx aggr record timeout: VO: %d, VI: %d, BE: %d, BK: %d",
6744 cmd->rx_timeout_pri[0], cmd->rx_timeout_pri[1],
6745 cmd->rx_timeout_pri[2], cmd->rx_timeout_pri[3]);
6746
6747 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6748 WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID);
6749 if (ret) {
6750 WMA_LOGE(FL("Failed to send aggregation timeout"));
6751 wmi_buf_free(buf);
6752 return QDF_STATUS_E_FAILURE;
6753 }
6754
6755 return QDF_STATUS_SUCCESS;
6756}
6757
6758QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle,
6759 struct sir_peer_set_rx_blocksize *peer_rx_blocksize)
6760{
6761 wmi_peer_set_rx_blocksize_cmd_fixed_param *cmd;
6762 int32_t len;
6763 wmi_buf_t buf;
6764 u_int8_t *buf_ptr;
6765 int ret;
6766
6767 if (!peer_rx_blocksize) {
6768 WMA_LOGE(FL("invalid pointer"));
6769 return QDF_STATUS_E_INVAL;
6770 }
6771
6772 if (!wma_handle) {
6773 WMA_LOGE(FL(" WMA context is invald!"));
6774 return QDF_STATUS_E_INVAL;
6775 }
6776
6777 len = sizeof(*cmd);
6778 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6779
6780 if (!buf) {
6781 WMA_LOGE(FL("Failed allocate wmi buffer"));
6782 return QDF_STATUS_E_NOMEM;
6783 }
6784
6785 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6786 cmd = (wmi_peer_set_rx_blocksize_cmd_fixed_param *) buf_ptr;
6787
6788 WMITLV_SET_HDR(&cmd->tlv_header,
6789 WMITLV_TAG_STRUC_wmi_peer_set_rx_blocksize_cmd_fixed_param,
6790 WMITLV_GET_STRUCT_TLVLEN(wmi_peer_set_rx_blocksize_cmd_fixed_param));
6791
6792 cmd->vdev_id = peer_rx_blocksize->vdev_id;
6793 cmd->rx_block_ack_win_limit =
6794 peer_rx_blocksize->rx_block_ack_win_limit;
6795 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_rx_blocksize->peer_macaddr.bytes,
6796 &cmd->peer_macaddr);
6797
6798 WMA_LOGD("rx aggr blocksize: %d", cmd->rx_block_ack_win_limit);
6799
6800 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6801 WMI_PEER_SET_RX_BLOCKSIZE_CMDID);
6802 if (ret) {
6803 WMA_LOGE(FL("Failed to send aggregation size command"));
6804 wmi_buf_free(buf);
6805 return QDF_STATUS_E_FAILURE;
6806 }
6807
6808 return QDF_STATUS_SUCCESS;
6809}
6810
lifengd217d192017-05-09 19:44:16 +08006811QDF_STATUS wma_get_chain_rssi(tp_wma_handle wma_handle,
6812 struct get_chain_rssi_req_params *req_params)
6813{
6814 wmi_peer_antdiv_info_req_cmd_fixed_param *cmd;
6815 wmi_buf_t wmi_buf;
6816 uint32_t len = sizeof(wmi_peer_antdiv_info_req_cmd_fixed_param);
6817 u_int8_t *buf_ptr;
6818
6819 if (!wma_handle) {
6820 WMA_LOGE(FL("WMA is closed, can not issue cmd"));
6821 return QDF_STATUS_E_INVAL;
6822 }
6823
6824 wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6825 if (!wmi_buf) {
6826 WMA_LOGE(FL("wmi_buf_alloc failed"));
6827 return QDF_STATUS_E_NOMEM;
6828 }
6829
6830 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
6831
6832 cmd = (wmi_peer_antdiv_info_req_cmd_fixed_param *)buf_ptr;
6833 WMITLV_SET_HDR(&cmd->tlv_header,
6834 WMITLV_TAG_STRUC_wmi_peer_antdiv_info_req_cmd_fixed_param,
6835 WMITLV_GET_STRUCT_TLVLEN(
6836 wmi_peer_antdiv_info_req_cmd_fixed_param));
6837 cmd->vdev_id = req_params->session_id;
6838 WMI_CHAR_ARRAY_TO_MAC_ADDR(req_params->peer_macaddr.bytes,
6839 &cmd->peer_mac_address);
6840
6841 if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len,
6842 WMI_PEER_ANTDIV_INFO_REQ_CMDID)) {
6843 WMA_LOGE(FL("failed to send get chain rssi command"));
6844 wmi_buf_free(wmi_buf);
6845 return QDF_STATUS_E_FAILURE;
6846 }
6847
6848 return QDF_STATUS_SUCCESS;
6849}
6850
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05306851/**
Ganesh Kondabattini35739572017-06-21 16:26:39 +05306852 * wma_process_set_limit_off_chan() - set limit off chanel parameters
6853 * @wma_handle: pointer to wma handle
6854 * @param: pointer to sir_limit_off_chan
6855 *
6856 * Return: QDF_STATUS_SUCCESS for success or error code.
6857 */
6858static QDF_STATUS wma_process_limit_off_chan(tp_wma_handle wma_handle,
6859 struct sir_limit_off_chan *param)
6860{
6861 int32_t err;
6862 struct wmi_limit_off_chan_param limit_off_chan_param;
6863
6864 limit_off_chan_param.vdev_id = param->vdev_id;
6865 limit_off_chan_param.status = param->is_tos_active;
6866 limit_off_chan_param.max_offchan_time = param->max_off_chan_time;
6867 limit_off_chan_param.rest_time = param->rest_time;
6868 limit_off_chan_param.skip_dfs_chans = param->skip_dfs_chans;
6869
6870 err = wmi_unified_send_limit_off_chan_cmd(wma_handle->wmi_handle,
6871 &limit_off_chan_param);
6872 if (err) {
6873 WMA_LOGE("\n failed to set limit off chan cmd");
6874 return QDF_STATUS_E_FAILURE;
6875 }
6876
6877 return QDF_STATUS_SUCCESS;
6878}
6879
6880/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006881 * wma_mc_process_msg() - process wma messages and call appropriate function.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006882 * @msg: message
6883 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306884 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006885 */
Jeff Johnson5be42ab2017-09-13 09:10:39 -07006886static QDF_STATUS wma_mc_process_msg(struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006887{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306888 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006889 tp_wma_handle wma_handle;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08006890 struct cdp_vdev *txrx_vdev_handle = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006891 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05306892 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006894 if (NULL == msg) {
6895 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306896 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306897 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006898 goto end;
6899 }
6900
6901 WMA_LOGD("msg->type = %x %s", msg->type,
6902 mac_trace_get_wma_msg_string(msg->type));
6903
Anurag Chouhan6d760662016-02-20 16:05:43 +05306904 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006905
6906 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006907 WMA_LOGE("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306908 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306909 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306910 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006911 goto end;
6912 }
6913
6914 switch (msg->type) {
6915
6916 /* Message posted by wmi for all control path related
6917 * FW events to serialize through mc_thread.
6918 */
6919 case WMA_PROCESS_FW_EVENT:
6920 wma_process_fw_event(wma_handle,
6921 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306922 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006923 break;
6924
6925#ifdef FEATURE_WLAN_ESE
6926 case WMA_TSM_STATS_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006927 WMA_LOGD("McThread: WMA_TSM_STATS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006928 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
6929 break;
6930#endif /* FEATURE_WLAN_ESE */
6931 case WNI_CFG_DNLD_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006932 WMA_LOGD("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306933 qdf_status = wma_wni_cfg_dnld(wma_handle);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006934 if (QDF_IS_STATUS_SUCCESS(qdf_status))
Jeff Johnsonf7ab8142017-09-13 09:04:23 -07006935 cds_wma_complete_cback();
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006936 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006937 WMA_LOGD("config download failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006938 break;
6939 case WMA_ADD_STA_SELF_REQ:
6940 txrx_vdev_handle =
6941 wma_vdev_attach(wma_handle,
6942 (struct add_sta_self_params *) msg->
6943 bodyptr, 1);
6944 if (!txrx_vdev_handle) {
6945 WMA_LOGE("Failed to attach vdev");
6946 } else {
6947 /* Register with TxRx Module for Data Ack Complete Cb */
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05306948 if (soc) {
6949 cdp_data_tx_cb_set(soc, txrx_vdev_handle,
6950 wma_data_tx_ack_comp_hdlr,
6951 wma_handle);
6952 } else {
6953 WMA_LOGE("%s: SOC context is NULL", __func__);
6954 qdf_status = QDF_STATUS_E_FAILURE;
6955 goto end;
6956 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006957 }
6958 break;
6959 case WMA_DEL_STA_SELF_REQ:
6960 wma_vdev_detach(wma_handle,
6961 (struct del_sta_self_params *) msg->bodyptr, 1);
6962 break;
6963 case WMA_START_SCAN_OFFLOAD_REQ:
6964 wma_start_scan(wma_handle, msg->bodyptr, msg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306965 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006966 break;
6967 case WMA_STOP_SCAN_OFFLOAD_REQ:
6968 wma_stop_scan(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306969 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006970 break;
6971 case WMA_UPDATE_CHAN_LIST_REQ:
6972 wma_update_channel_list(wma_handle,
6973 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306974 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006975 break;
6976 case WMA_SET_LINK_STATE:
6977 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
6978 break;
6979 case WMA_CHNL_SWITCH_REQ:
6980 wma_set_channel(wma_handle,
6981 (tpSwitchChannelParams) msg->bodyptr);
6982 break;
6983 case WMA_ADD_BSS_REQ:
6984 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
6985 break;
6986 case WMA_ADD_STA_REQ:
6987 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
6988 break;
6989 case WMA_SET_BSSKEY_REQ:
6990 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
6991 break;
6992 case WMA_SET_STAKEY_REQ:
6993 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
6994 break;
6995 case WMA_DELETE_STA_REQ:
6996 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
6997 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07006998 case WMA_DELETE_BSS_HO_FAIL_REQ:
6999 wma_delete_bss_ho_fail(wma_handle,
7000 (tpDeleteBssParams) msg->bodyptr);
7001 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007002 case WMA_DELETE_BSS_REQ:
7003 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
7004 break;
7005 case WMA_UPDATE_EDCA_PROFILE_IND:
7006 wma_process_update_edca_param_req(wma_handle,
7007 (tEdcaParams *) 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_SEND_BEACON_REQ:
7011 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307012 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007013 break;
7014 case WMA_SEND_PROBE_RSP_TMPL:
7015 wma_send_probe_rsp_tmpl(wma_handle,
7016 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307017 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007018 break;
7019 case WMA_CLI_SET_CMD:
7020 wma_process_cli_set_cmd(wma_handle,
7021 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307022 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007023 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07007024 case WMA_SET_PDEV_IE_REQ:
7025 wma_process_set_pdev_ie_req(wma_handle,
7026 (struct set_ie_param *)msg->bodyptr);
7027 qdf_mem_free(msg->bodyptr);
7028 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007029#if !defined(REMOVE_PKT_LOG)
7030 case WMA_PKTLOG_ENABLE_REQ:
7031 wma_pktlog_wmi_send_cmd(wma_handle,
7032 (struct ath_pktlog_wmi_params *)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#endif /* REMOVE_PKT_LOG */
7036#if defined(QCA_WIFI_FTM)
7037 case WMA_FTM_CMD_REQ:
7038 wma_process_ftm_command(wma_handle,
7039 (struct ar6k_testmode_cmd_data *)msg->bodyptr);
7040 break;
7041#endif /* QCA_WIFI_FTM */
7042 case WMA_ENTER_PS_REQ:
7043 wma_enable_sta_ps_mode(wma_handle,
7044 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307045 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007046 break;
7047 case WMA_EXIT_PS_REQ:
7048 wma_disable_sta_ps_mode(wma_handle,
7049 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307050 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007051 break;
7052 case WMA_ENABLE_UAPSD_REQ:
7053 wma_enable_uapsd_mode(wma_handle,
7054 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307055 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007056 break;
7057 case WMA_DISABLE_UAPSD_REQ:
7058 wma_disable_uapsd_mode(wma_handle,
7059 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307060 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007061 break;
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -07007062 case WMA_SET_DTIM_PERIOD:
7063 wma_set_dtim_period(wma_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007064 (struct set_dtim_params *)msg->bodyptr);
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -07007065 qdf_mem_free(msg->bodyptr);
7066 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007067 case WMA_SET_TX_POWER_REQ:
7068 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
7069 break;
7070 case WMA_SET_MAX_TX_POWER_REQ:
7071 wma_set_max_tx_power(wma_handle,
7072 (tpMaxTxPowerParams) msg->bodyptr);
7073 break;
7074 case WMA_SET_KEEP_ALIVE:
7075 wma_set_keepalive_req(wma_handle,
7076 (tSirKeepAliveReq *) msg->bodyptr);
7077 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08007078#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007079 case WMA_SET_PLM_REQ:
7080 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
7081 break;
7082#endif
7083 case WMA_GET_STATISTICS_REQ:
7084 wma_get_stats_req(wma_handle,
7085 (tAniGetPEStatsReq *) msg->bodyptr);
7086 break;
7087
7088 case WMA_CONFIG_PARAM_UPDATE_REQ:
Rajeev Kumar156188e2017-01-21 17:23:52 -08007089 wma_update_cfg_params(wma_handle, msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007090 break;
7091
7092 case WMA_UPDATE_OP_MODE:
7093 wma_process_update_opmode(wma_handle,
7094 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307095 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007096 break;
7097 case WMA_UPDATE_RX_NSS:
7098 wma_process_update_rx_nss(wma_handle,
7099 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307100 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007101 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007102 case WMA_UPDATE_MEMBERSHIP:
7103 wma_process_update_membership(wma_handle,
7104 (tUpdateMembership *) msg->bodyptr);
7105 break;
7106 case WMA_UPDATE_USERPOS:
7107 wma_process_update_userpos(wma_handle,
7108 (tUpdateUserPos *) msg->bodyptr);
7109 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007110 case WMA_UPDATE_BEACON_IND:
7111 wma_process_update_beacon_params(wma_handle,
7112 (tUpdateBeaconParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307113 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007114 break;
7115
7116 case WMA_ADD_TS_REQ:
7117 wma_add_ts_req(wma_handle, (tAddTsParams *) msg->bodyptr);
7118 break;
7119
7120 case WMA_DEL_TS_REQ:
7121 wma_del_ts_req(wma_handle, (tDelTsParams *) msg->bodyptr);
7122 break;
7123
7124 case WMA_AGGR_QOS_REQ:
7125 wma_aggr_qos_req(wma_handle, (tAggrAddTsParams *) msg->bodyptr);
7126 break;
7127
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007128 case WMA_WOW_ADD_PTRN:
7129 wma_wow_add_pattern(wma_handle,
7130 (struct wow_add_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307131 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007132 break;
7133 case WMA_WOW_DEL_PTRN:
7134 wma_wow_delete_user_pattern(wma_handle,
7135 (struct wow_delete_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307136 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007137 break;
7138 case WMA_WOWL_ENTER_REQ:
7139 wma_wow_enter(wma_handle,
7140 (tpSirHalWowlEnterParams) msg->bodyptr);
7141 break;
7142 case WMA_WOWL_EXIT_REQ:
7143 wma_wow_exit(wma_handle, (tpSirHalWowlExitParams) msg->bodyptr);
7144 break;
Houston Hoffmana76591b2015-11-10 16:52:05 -08007145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007146 case WMA_8023_MULTICAST_LIST_REQ:
7147 wma_process_mcbc_set_filter_req(wma_handle,
7148 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307149 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007150 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007151 case WMA_ROAM_SCAN_OFFLOAD_REQ:
7152 /*
7153 * Main entry point or roaming directives from CSR.
7154 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08007155 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007156 (tSirRoamOffloadScanReq *) msg->bodyptr);
7157 break;
7158
7159 case WMA_RATE_UPDATE_IND:
7160 wma_process_rate_update_indicate(wma_handle,
7161 (tSirRateUpdateInd *) msg->bodyptr);
7162 break;
7163
7164#ifdef FEATURE_WLAN_TDLS
7165 case WMA_UPDATE_FW_TDLS_STATE:
7166 wma_update_fw_tdls_state(wma_handle,
7167 (t_wma_tdls_params *) msg->bodyptr);
7168 break;
7169 case WMA_UPDATE_TDLS_PEER_STATE:
7170 wma_update_tdls_peer_state(wma_handle,
7171 (tTdlsPeerStateParams *) msg->bodyptr);
7172 break;
7173 case WMA_TDLS_SET_OFFCHAN_MODE:
7174 wma_set_tdls_offchan_mode(wma_handle,
7175 (tdls_chan_switch_params *)msg->bodyptr);
7176 break;
7177#endif /* FEATURE_WLAN_TDLS */
7178 case WMA_ADD_PERIODIC_TX_PTRN_IND:
7179 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
7180 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307181 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007182 break;
7183 case WMA_DEL_PERIODIC_TX_PTRN_IND:
7184 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
7185 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307186 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007187 break;
7188 case WMA_TX_POWER_LIMIT:
7189 wma_process_tx_power_limits(wma_handle,
7190 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307191 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007192 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007193#ifdef FEATURE_WLAN_CH_AVOID
7194 case WMA_CH_AVOID_UPDATE_REQ:
7195 wma_process_ch_avoid_update_req(wma_handle,
7196 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307197 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007198 break;
7199#endif /* FEATURE_WLAN_CH_AVOID */
7200#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
7201 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
7202 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307203 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007204 break;
7205#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
7206 case WMA_DHCP_START_IND:
7207 case WMA_DHCP_STOP_IND:
7208 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307209 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007210 break;
7211
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007212 case WMA_IBSS_CESIUM_ENABLE_IND:
7213 wma_process_cesium_enable_ind(wma_handle);
7214 break;
7215 case WMA_GET_IBSS_PEER_INFO_REQ:
7216 wma_process_get_peer_info_req(wma_handle,
7217 (tSirIbssGetPeerInfoReqParams *)
7218 msg->bodyptr);
7219 qdf_mem_free(msg->bodyptr);
7220 break;
7221 case WMA_TX_FAIL_MONITOR_IND:
7222 wma_process_tx_fail_monitor_ind(wma_handle,
7223 (tAniTXFailMonitorInd *) msg->bodyptr);
7224 qdf_mem_free(msg->bodyptr);
7225 break;
7226
7227 case WMA_RMC_ENABLE_IND:
7228 wma_process_rmc_enable_ind(wma_handle);
7229 break;
7230 case WMA_RMC_DISABLE_IND:
7231 wma_process_rmc_disable_ind(wma_handle);
7232 break;
7233 case WMA_RMC_ACTION_PERIOD_IND:
7234 wma_process_rmc_action_period_ind(wma_handle);
7235 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236 case WMA_INIT_THERMAL_INFO_CMD:
7237 wma_process_init_thermal_info(wma_handle,
7238 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307239 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007240 break;
7241
7242 case WMA_SET_THERMAL_LEVEL:
7243 wma_process_set_thermal_level(wma_handle, msg->bodyval);
7244 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05307245#ifdef CONFIG_HL_SUPPORT
7246 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
7247 wma_process_init_bad_peer_tx_ctl_info(
7248 wma_handle,
7249 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
7250 qdf_mem_free(msg->bodyptr);
7251 break;
7252#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007253 case WMA_SET_P2P_GO_NOA_REQ:
7254 wma_process_set_p2pgo_noa_req(wma_handle,
7255 (tP2pPsParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307256 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007257 break;
7258 case WMA_SET_MIMOPS_REQ:
7259 wma_process_set_mimops_req(wma_handle,
7260 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307261 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007262 break;
7263 case WMA_SET_SAP_INTRABSS_DIS:
7264 wma_set_vdev_intrabss_fwd(wma_handle,
7265 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307266 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007267 break;
Will Huanga9814592017-05-24 15:47:58 +08007268 case WMA_GET_PEER_INFO:
7269 wma_get_peer_info(wma_handle, msg->bodyptr);
7270 qdf_mem_free(msg->bodyptr);
7271 break;
7272 case WMA_GET_PEER_INFO_EXT:
7273 wma_get_peer_info_ext(wma_handle, msg->bodyptr);
7274 qdf_mem_free(msg->bodyptr);
7275 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007276 case WMA_MODEM_POWER_STATE_IND:
7277 wma_notify_modem_power_state(wma_handle,
7278 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307279 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007280 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007281#ifdef WLAN_FEATURE_STATS_EXT
7282 case WMA_STATS_EXT_REQUEST:
7283 wma_stats_ext_req(wma_handle,
7284 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307285 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007286 break;
7287#endif /* WLAN_FEATURE_STATS_EXT */
7288 case WMA_HIDDEN_SSID_VDEV_RESTART:
7289 wma_hidden_ssid_vdev_restart(wma_handle,
7290 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007291 break;
7292#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
7293 case WMA_WLAN_EXT_WOW:
7294 wma_enable_ext_wow(wma_handle,
7295 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307296 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007297 break;
7298 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
7299 wma_set_app_type1_params_in_fw(wma_handle,
7300 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307301 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007302 break;
7303 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
7304 wma_set_app_type2_params_in_fw(wma_handle,
7305 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307306 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007307 break;
7308#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
7309#ifdef FEATURE_WLAN_EXTSCAN
7310 case WMA_EXTSCAN_START_REQ:
7311 wma_start_extscan(wma_handle,
7312 (tSirWifiScanCmdReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307313 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007314 break;
7315 case WMA_EXTSCAN_STOP_REQ:
7316 wma_stop_extscan(wma_handle,
7317 (tSirExtScanStopReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307318 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007319 break;
7320 case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:
7321 wma_extscan_start_hotlist_monitor(wma_handle,
7322 (tSirExtScanSetBssidHotListReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307323 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007324 break;
7325 case WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
7326 wma_extscan_stop_hotlist_monitor(wma_handle,
7327 (tSirExtScanResetBssidHotlistReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307328 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007329 break;
7330 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
7331 wma_extscan_start_change_monitor(wma_handle,
7332 (tSirExtScanSetSigChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307333 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007334 break;
7335 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
7336 wma_extscan_stop_change_monitor(wma_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007337 (tSirExtScanResetSignificantChangeReqParams *)
7338 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307339 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007340 break;
7341 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
7342 wma_extscan_get_cached_results(wma_handle,
7343 (tSirExtScanGetCachedResultsReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307344 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007345 break;
7346 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
7347 wma_extscan_get_capabilities(wma_handle,
7348 (tSirGetExtScanCapabilitiesReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307349 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007350 break;
7351 case WMA_SET_EPNO_LIST_REQ:
7352 wma_set_epno_network_list(wma_handle,
7353 (struct wifi_epno_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307354 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007355 break;
Kapil Gupta5cda2252016-12-29 18:44:26 +05307356 case WMA_SET_PER_ROAM_CONFIG_CMD:
7357 wma_update_per_roam_config(wma_handle,
7358 (struct wmi_per_roam_config_req *)msg->bodyptr);
7359 qdf_mem_free(msg->bodyptr);
7360 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361 case WMA_SET_PASSPOINT_LIST_REQ:
7362 /* Issue reset passpoint network list first and clear
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007363 * the entries
7364 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007365 wma_reset_passpoint_network_list(wma_handle,
7366 (struct wifi_passpoint_req *)msg->bodyptr);
7367
7368 wma_set_passpoint_network_list(wma_handle,
7369 (struct wifi_passpoint_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307370 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007371 break;
7372 case WMA_RESET_PASSPOINT_LIST_REQ:
7373 wma_reset_passpoint_network_list(wma_handle,
7374 (struct wifi_passpoint_req *)msg->bodyptr);
7375 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007376#endif /* FEATURE_WLAN_EXTSCAN */
7377 case WMA_SET_SCAN_MAC_OUI_REQ:
7378 wma_scan_probe_setoui(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307379 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007380 break;
7381#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7382 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
7383 wma_process_ll_stats_clear_req(wma_handle,
7384 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307385 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007386 break;
7387 case WMA_LINK_LAYER_STATS_SET_REQ:
7388 wma_process_ll_stats_set_req(wma_handle,
7389 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307390 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007391 break;
7392 case WMA_LINK_LAYER_STATS_GET_REQ:
7393 wma_process_ll_stats_get_req(wma_handle,
7394 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307395 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007396 break;
Zhang Qian73c348a2017-03-13 16:15:55 +08007397 case WDA_LINK_LAYER_STATS_SET_THRESHOLD:
7398 wma_config_stats_ext_threshold(wma_handle,
7399 (struct sir_ll_ext_stats_threshold *)msg->bodyptr);
7400 qdf_mem_free(msg->bodyptr);
7401 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007402#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
7403 case SIR_HAL_UNIT_TEST_CMD:
7404 wma_process_unit_test_cmd(wma_handle,
7405 (t_wma_unit_test_cmd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307406 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007407 break;
7408#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007409 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
7410 wma_process_roam_synch_fail(wma_handle,
7411 (struct roam_offload_synch_fail *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307412 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007413 break;
7414 case SIR_HAL_ROAM_INVOKE:
7415 wma_process_roam_invoke(wma_handle,
7416 (struct wma_roam_invoke_cmd *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307417 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007418 break;
7419#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
7420#ifdef WLAN_FEATURE_NAN
7421 case WMA_NAN_REQUEST:
7422 wma_nan_req(wma_handle, (tNanRequest *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307423 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007424 break;
7425#endif /* WLAN_FEATURE_NAN */
7426 case SIR_HAL_SET_BASE_MACADDR_IND:
7427 wma_set_base_macaddr_indicate(wma_handle,
7428 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307429 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430 break;
7431 case WMA_LINK_STATUS_GET_REQ:
7432 wma_process_link_status_req(wma_handle,
7433 (tAniGetLinkStatus *) msg->bodyptr);
7434 break;
7435 case WMA_GET_TEMPERATURE_REQ:
7436 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307437 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007438 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07007439 case WMA_TSF_GPIO_PIN:
7440 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
7441 break;
7442
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007443#ifdef DHCP_SERVER_OFFLOAD
7444 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
7445 wma_process_dhcpserver_offload(wma_handle,
7446 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307447 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007448 break;
7449#endif /* DHCP_SERVER_OFFLOAD */
7450#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
7451 case WMA_LED_FLASHING_REQ:
7452 wma_set_led_flashing(wma_handle,
7453 (tSirLedFlashingReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307454 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007455 break;
7456#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
7457 case SIR_HAL_SET_MAS:
7458 wma_process_set_mas(wma_handle,
7459 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307460 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007461 break;
7462 case SIR_HAL_SET_MIRACAST:
7463 wma_process_set_miracast(wma_handle,
7464 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307465 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007466 break;
7467 case SIR_HAL_CONFIG_STATS_FACTOR:
7468 wma_config_stats_factor(wma_handle,
7469 (struct sir_stats_avg_factor *)
7470 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307471 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007472 break;
7473 case SIR_HAL_CONFIG_GUARD_TIME:
7474 wma_config_guard_time(wma_handle,
7475 (struct sir_guard_time_request *)
7476 msg->bodyptr);
7477 case WMA_IPA_OFFLOAD_ENABLE_DISABLE:
7478 wma_ipa_offload_enable_disable(wma_handle,
7479 (struct sir_ipa_offload_enable_disable *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307480 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007481 break;
7482 case SIR_HAL_START_STOP_LOGGING:
7483 wma_set_wifi_start_packet_stats(wma_handle,
7484 (struct sir_wifi_start_log *)msg->bodyptr);
7485 wma_enable_specific_fw_logs(wma_handle,
7486 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307487 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007488 break;
7489 case SIR_HAL_FLUSH_LOG_TO_FW:
7490 wma_send_flush_logs_to_fw(wma_handle);
7491 /* Body ptr is NULL here */
7492 break;
7493 case WMA_SET_RSSI_MONITOR_REQ:
7494 wma_set_rssi_monitoring(wma_handle,
7495 (struct rssi_monitor_req *)msg->bodyptr);
Prakash Dhavali87ddca32016-11-29 17:02:11 -08007496 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007497 break;
7498 case WMA_FW_MEM_DUMP_REQ:
7499 wma_process_fw_mem_dump_req(wma_handle,
7500 (struct fw_dump_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307501 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007502 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307503 case SIR_HAL_PDEV_SET_PCL_TO_FW:
7504 wma_send_pdev_set_pcl_cmd(wma_handle,
7505 (struct wmi_pcl_chan_weights *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307506 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007507 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307508 case SIR_HAL_PDEV_SET_HW_MODE:
7509 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007510 (struct policy_mgr_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307511 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007512 break;
7513 case WMA_OCB_SET_CONFIG_CMD:
7514 wma_ocb_set_config_req(wma_handle,
7515 (struct sir_ocb_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307516 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007517 break;
7518 case WMA_OCB_SET_UTC_TIME_CMD:
7519 wma_ocb_set_utc_time(wma_handle,
7520 (struct sir_ocb_utc *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307521 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007522 break;
7523 case WMA_OCB_START_TIMING_ADVERT_CMD:
7524 wma_ocb_start_timing_advert(wma_handle,
7525 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307526 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007527 break;
7528 case WMA_OCB_STOP_TIMING_ADVERT_CMD:
7529 wma_ocb_stop_timing_advert(wma_handle,
7530 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307531 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007532 break;
7533 case WMA_DCC_CLEAR_STATS_CMD:
7534 wma_dcc_clear_stats(wma_handle,
7535 (struct sir_dcc_clear_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307536 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007537 break;
7538 case WMA_OCB_GET_TSF_TIMER_CMD:
7539 wma_ocb_get_tsf_timer(wma_handle,
7540 (struct sir_ocb_get_tsf_timer *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307541 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007542 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07007543 case WMA_SET_WISA_PARAMS:
7544 wma_set_wisa_params(wma_handle,
7545 (struct sir_wisa_params *)msg->bodyptr);
7546 qdf_mem_free(msg->bodyptr);
7547 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007548 case WMA_DCC_GET_STATS_CMD:
7549 wma_dcc_get_stats(wma_handle,
7550 (struct sir_dcc_get_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307551 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007552 break;
7553 case WMA_DCC_UPDATE_NDL_CMD:
7554 wma_dcc_update_ndl(wma_handle,
7555 (struct sir_dcc_update_ndl *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307556 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007557 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307558 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
7559 wma_send_pdev_set_dual_mac_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007560 (struct sir_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307561 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007562 break;
7563 case WMA_SET_IE_INFO:
7564 wma_process_set_ie_info(wma_handle,
7565 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307566 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007567 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007568 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
7569 wma_send_pdev_set_antenna_mode(wma_handle,
7570 (struct sir_antenna_mode_param *)msg->bodyptr);
7571 qdf_mem_free(msg->bodyptr);
7572 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007573 case WMA_LRO_CONFIG_CMD:
7574 wma_lro_config_cmd(wma_handle,
Dhanashri Atre09828f12016-11-13 10:36:58 -08007575 (struct cdp_lro_hash_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307576 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007577 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08007578 case WMA_GW_PARAM_UPDATE_REQ:
7579 wma_set_gateway_params(wma_handle,
7580 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08007581 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08007582 break;
7583 case WMA_SET_EGAP_CONF_PARAMS:
7584 wma_send_egap_conf_params(wma_handle,
7585 (struct egap_conf_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307586 qdf_mem_free(msg->bodyptr);
Ravi Joshi9e891ba2015-11-09 19:03:46 -08007587 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05307588 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
7589 wma_send_adapt_dwelltime_params(wma_handle,
7590 (struct adaptive_dwelltime_params *)msg->bodyptr);
7591 qdf_mem_free(msg->bodyptr);
7592 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08007593 case WMA_HT40_OBSS_SCAN_IND:
7594 wma_send_ht40_obss_scanind(wma_handle,
7595 (struct obss_ht40_scanind *)msg->bodyptr);
7596 qdf_mem_free(msg->bodyptr);
7597 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07007598 case WMA_ADD_BCN_FILTER_CMDID:
7599 wma_add_beacon_filter(wma_handle, msg->bodyptr);
7600 qdf_mem_free(msg->bodyptr);
7601 break;
7602 case WMA_REMOVE_BCN_FILTER_CMDID:
7603 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
7604 qdf_mem_free(msg->bodyptr);
7605 break;
Arun Khandavalli2476ef52016-04-26 20:19:43 +05307606 case WDA_BPF_GET_CAPABILITIES_REQ:
7607 wma_get_bpf_capabilities(wma_handle);
7608 break;
7609 case WDA_BPF_SET_INSTRUCTIONS_REQ:
7610 wma_set_bpf_instructions(wma_handle, msg->bodyptr);
7611 qdf_mem_free(msg->bodyptr);
7612 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07007613 case SIR_HAL_NDP_INITIATOR_REQ:
7614 wma_handle_ndp_initiator_req(wma_handle, msg->bodyptr);
7615 qdf_mem_free(msg->bodyptr);
7616 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07007617
Abhishek Singh4fef7472016-06-06 11:36:03 -07007618 case SIR_HAL_NDP_RESPONDER_REQ:
7619 wma_handle_ndp_responder_req(wma_handle, msg->bodyptr);
Naveen Rawatf28315c2016-06-29 18:06:02 -07007620 break;
7621
7622 case SIR_HAL_NDP_END_REQ:
7623 wma_handle_ndp_end_req(wma_handle, msg->bodyptr);
Abhishek Singh4fef7472016-06-06 11:36:03 -07007624 qdf_mem_free(msg->bodyptr);
7625 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05307626 case SIR_HAL_POWER_DBG_CMD:
7627 wma_process_hal_pwr_dbg_cmd(wma_handle,
7628 msg->bodyptr);
7629 qdf_mem_free(msg->bodyptr);
7630 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307631 case WMA_UPDATE_WEP_DEFAULT_KEY:
7632 wma_update_wep_default_key(wma_handle,
7633 (struct wep_update_default_key_idx *)msg->bodyptr);
7634 qdf_mem_free(msg->bodyptr);
7635 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05307636 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
7637 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
7638 break;
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05307639 case WMA_ENCRYPT_DECRYPT_MSG:
7640 wma_encrypt_decrypt_msg(wma_handle, msg->bodyptr);
7641 qdf_mem_free(msg->bodyptr);
7642 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307643 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
7644 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
7645 qdf_mem_free(msg->bodyptr);
7646 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307647 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
7648 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
7649 qdf_mem_free(msg->bodyptr);
7650 break;
7651 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
7652 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
7653 qdf_mem_free(msg->bodyptr);
7654 break;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307655 case SIR_HAL_POWER_DEBUG_STATS_REQ:
7656 wma_process_power_debug_stats_req(wma_handle);
7657 break;
Yingying Tang95409972016-10-20 15:16:15 +08007658 case WMA_SET_WOW_PULSE_CMD:
7659 wma_send_wow_pulse_cmd(wma_handle,
7660 (struct wow_pulse_mode *)msg->bodyptr);
7661 qdf_mem_free(msg->bodyptr);
7662 break;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05307663 case WMA_SET_DBS_SCAN_SEL_CONF_PARAMS:
7664 wma_send_dbs_scan_selection_params(wma_handle,
7665 (struct wmi_dbs_scan_sel_params *)msg->bodyptr);
7666 qdf_mem_free(msg->bodyptr);
7667 break;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307668 case WMA_SET_ARP_STATS_REQ:
7669 wma_set_arp_req_stats(wma_handle,
7670 (struct set_arp_stats_params *)msg->bodyptr);
7671 qdf_mem_free(msg->bodyptr);
7672 break;
7673 case WMA_GET_ARP_STATS_REQ:
7674 wma_get_arp_req_stats(wma_handle,
7675 (struct get_arp_stats_params *)msg->bodyptr);
7676 qdf_mem_free(msg->bodyptr);
7677 break;
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307678 case WMA_SET_LIMIT_OFF_CHAN:
7679 wma_process_limit_off_chan(wma_handle, msg->bodyptr);
7680 qdf_mem_free(msg->bodyptr);
7681 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007682 default:
Dustin Brown86534fb2017-01-24 14:28:20 -08007683 WMA_LOGE("Unhandled WMA message of type %d", msg->type);
7684 if (msg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307685 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007686 }
7687end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307688 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007689}
7690
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007691QDF_STATUS wma_mc_process_handler(struct scheduler_msg *msg)
7692{
Jeff Johnson5be42ab2017-09-13 09:10:39 -07007693 return wma_mc_process_msg(msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007694}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007696/**
7697 * wma_log_completion_timeout() - Log completion timeout
7698 * @data: Timeout handler data
7699 *
7700 * This function is called when log completion timer expires
7701 *
7702 * Return: None
7703 */
7704void wma_log_completion_timeout(void *data)
7705{
7706 tp_wma_handle wma_handle;
7707
7708 WMA_LOGE("%s: Timeout occured for log completion command", __func__);
7709
7710 wma_handle = (tp_wma_handle) data;
7711 if (!wma_handle)
7712 WMA_LOGE("%s: Invalid WMA handle", __func__);
7713
7714 /* Though we did not receive any event from FW,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007715 * we can flush whatever logs we have with us
7716 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007717 cds_logging_set_fw_flush_complete();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007718}
7719
7720/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05307721 * wma_map_pcl_weights() - Map PCL weights
7722 * @pcl_weight: Internal PCL weights
7723 *
7724 * Maps the internal weights of PCL to the weights needed by FW
7725 *
7726 * Return: Mapped channel weight of type wmi_pcl_chan_weight
7727 */
7728static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
7729{
7730 switch (pcl_weight) {
7731 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
7732 return WMI_PCL_WEIGHT_VERY_HIGH;
7733 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
7734 return WMI_PCL_WEIGHT_HIGH;
7735 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
7736 return WMI_PCL_WEIGHT_MEDIUM;
7737 case WEIGHT_OF_NON_PCL_CHANNELS:
7738 return WMI_PCL_WEIGHT_LOW;
7739 default:
7740 return WMI_PCL_WEIGHT_DISALLOW;
7741 }
7742}
7743
7744/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307745 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007746 * @wma_handle: WMA handle
7747 * @msg: PCL structure containing the PCL and the number of channels
7748 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307749 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007750 * firmware. The DBS Manager is the consumer of this information in the WLAN
7751 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
7752 * to migrate to a new channel without host driver involvement. An example of
7753 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
7754 * manage the channel selection without firmware involvement.
7755 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307756 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
7757 * channel list. The weights corresponds to the channels sent in
7758 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
7759 * weightage compared to the non PCL channels.
7760 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007761 * Return: Success if the cmd is sent successfully to the firmware
7762 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307763QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
7764 struct wmi_pcl_chan_weights *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007765{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307766 uint32_t i;
7767 QDF_STATUS status;
7768
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007769 if (!wma_handle) {
7770 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7771 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307772 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007773 }
7774
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307775 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
7776 msg->saved_chan_list[i] =
7777 wma_handle->saved_chan.channel_list[i];
7778 }
7779
7780 msg->saved_num_chan = wma_handle->saved_chan.num_channels;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007781 status = policy_mgr_get_valid_chan_weights(wma_handle->psoc,
7782 (struct policy_mgr_pcl_chan_weights *)msg);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05307783
7784 for (i = 0; i < msg->saved_num_chan; i++) {
7785 msg->weighed_valid_list[i] =
7786 wma_map_pcl_weights(msg->weighed_valid_list[i]);
7787 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
7788 msg->saved_chan_list[i], i,
7789 msg->weighed_valid_list[i]);
7790 }
7791
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307792 if (!QDF_IS_STATUS_SUCCESS(status)) {
7793 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
7794 return status;
7795 }
7796
7797 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle, msg))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307798 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05307799
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307800 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007801}
7802
7803/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307804 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007805 * @wma_handle: WMA handle
7806 * @msg: Structure containing the following parameters
7807 *
7808 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
7809 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
7810 *
7811 * Provides notification to the WLAN firmware that host driver is requesting a
7812 * HardWare (HW) Mode change. This command is needed to support iHelium in the
7813 * configurations that include the Dual Band Simultaneous (DBS) feature.
7814 *
7815 * Return: Success if the cmd is sent successfully to the firmware
7816 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307817QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07007818 struct policy_mgr_hw_mode *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007819{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007820 struct sir_set_hw_mode_resp *param;
7821
7822 if (!wma_handle) {
7823 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7824 __func__);
7825 /* Handle is NULL. Will not be able to send failure
7826 * response as well
7827 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307828 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007829 }
7830
7831 if (!msg) {
7832 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
7833 /* Lets try to free the active command list */
7834 goto fail;
7835 }
7836
Dustin Brownec2c92e2017-07-26 11:13:49 -07007837 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
7838 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT);
Govind Singhf25a0f12016-03-08 16:09:48 +05307839 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07007840 msg->hw_mode_index)) {
7841 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007842 goto fail;
Krunal Sonicebcc292017-06-14 19:59:20 -07007843 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007844
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307845 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007846fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307847 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007848 if (!param) {
7849 WMA_LOGE("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307850 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007851 }
7852 param->status = SET_HW_MODE_STATUS_ECANCELED;
7853 param->cfgd_hw_mode_index = 0;
7854 param->num_vdev_mac_entries = 0;
7855 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307856 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007857 (void *) param, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307858 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007859}
7860
7861/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307862 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007863 * @wma_handle: WMA handle
7864 * @msg: Dual MAC config parameters
7865 *
7866 * Configures WLAN firmware with the dual MAC features
7867 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307868 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007869 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307870QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007871 struct sir_dual_mac_config *msg)
7872{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307873 QDF_STATUS status;
7874
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007875 if (!wma_handle) {
7876 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7877 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307878 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007879 }
7880
7881 if (!msg) {
7882 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307883 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007884 }
7885
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307886 status = wmi_unified_pdev_set_dual_mac_config_cmd(
7887 wma_handle->wmi_handle,
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307888 (struct wmi_dual_mac_config *)msg);
7889 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307890 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307891 __func__, status);
7892 return status;
7893 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007894 policy_mgr_update_dbs_req_config(wma_handle->psoc,
7895 msg->scan_config, msg->fw_mode_config);
Govind Singhf25a0f12016-03-08 16:09:48 +05307896
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307897 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007898}
7899
7900/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007901 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
7902 * @wma_handle: WMA handle
7903 * @msg: Antenna mode parameters
7904 *
7905 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
7906 * modify the number of TX/RX chains from host
7907 *
7908 * Return: QDF_STATUS. 0 on success.
7909 */
7910QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
7911 struct sir_antenna_mode_param *msg)
7912{
7913 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
7914 wmi_buf_t buf;
7915 uint32_t len;
7916 QDF_STATUS status = QDF_STATUS_SUCCESS;
7917 struct sir_antenna_mode_resp *param;
7918
7919 if (!wma_handle) {
7920 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7921 __func__);
7922 return QDF_STATUS_E_NULL_VALUE;
7923 }
7924
7925 if (!msg) {
7926 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
7927 return QDF_STATUS_E_NULL_VALUE;
7928 }
7929
7930 len = sizeof(*cmd);
7931
7932 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7933 if (!buf) {
7934 WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
7935 status = QDF_STATUS_E_NOMEM;
7936 goto resp;
7937 }
7938
7939 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
7940 WMITLV_SET_HDR(&cmd->tlv_header,
7941 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
7942 WMITLV_GET_STRUCT_TLVLEN(
7943 wmi_pdev_set_antenna_mode_cmd_fixed_param));
7944
7945 cmd->pdev_id = WMI_PDEV_ID_SOC;
7946 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
7947 cmd->num_txrx_chains = msg->num_rx_chains;
7948 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
7949
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007950 WMA_LOGD("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007951 __func__, msg->num_tx_chains,
7952 msg->num_rx_chains, cmd->num_txrx_chains);
7953
7954 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7955 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
7956 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_ANTENNA_MODE_CMDID",
7957 __func__);
7958 wmi_buf_free(buf);
7959 status = QDF_STATUS_E_FAILURE;
7960 goto resp;
7961 }
7962 status = QDF_STATUS_SUCCESS;
7963
7964resp:
7965 param = qdf_mem_malloc(sizeof(*param));
7966 if (!param) {
7967 WMA_LOGE("%s: Memory allocation failed", __func__);
7968 return QDF_STATUS_E_NOMEM;
7969 }
7970 param->status = (status) ?
7971 SET_ANTENNA_MODE_STATUS_ECANCELED :
7972 SET_ANTENNA_MODE_STATUS_OK;
7973 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
7974 __func__, param->status);
7975 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
7976 (void *) param, 0);
7977 return status;
7978}
7979
7980/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007981 * wma_crash_inject() - sends command to FW to simulate crash
7982 * @wma_handle: pointer of WMA context
7983 * @type: subtype of the command
7984 * @delay_time_ms: time in milliseconds for FW to delay the crash
7985 *
7986 * This function will send a command to FW in order to simulate different
7987 * kinds of FW crashes.
7988 *
Govind Singhd76a5b02016-03-08 15:12:14 +05307989 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007990 */
Yu Wang46082dc2017-09-19 12:25:38 +08007991QDF_STATUS wma_crash_inject(WMA_HANDLE wma_handle, uint32_t type,
7992 uint32_t delay_time_ms)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007993{
Govind Singhd76a5b02016-03-08 15:12:14 +05307994 struct crash_inject param;
Yu Wang46082dc2017-09-19 12:25:38 +08007995 tp_wma_handle wma = (tp_wma_handle)wma_handle;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007996
Govind Singhd76a5b02016-03-08 15:12:14 +05307997 param.type = type;
7998 param.delay_time_ms = delay_time_ms;
Yu Wang46082dc2017-09-19 12:25:38 +08007999 return wmi_crash_inject(wma->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008000}
Govind Singhd76a5b02016-03-08 15:12:14 +05308001
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008002#if defined(FEATURE_LRO)
8003/**
8004 * wma_lro_init() - sends LRO configuration to FW
8005 * @lro_config: pointer to the config parameters
8006 *
8007 * This function ends LRO configuration to FW.
8008 *
8009 * Return: 0 for success or reasons for failure
8010 */
Dhanashri Atre09828f12016-11-13 10:36:58 -08008011int wma_lro_init(struct cdp_lro_hash_config *lro_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008012{
Rajeev Kumarb60abe42017-01-21 15:39:31 -08008013 struct scheduler_msg msg = {0};
Dhanashri Atre09828f12016-11-13 10:36:58 -08008014 struct cdp_lro_hash_config *iwcmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008015
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308016 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008017 if (!iwcmd) {
8018 WMA_LOGE("memory allocation for WMA_LRO_CONFIG_CMD failed!");
8019 return -ENOMEM;
8020 }
8021
8022 *iwcmd = *lro_config;
8023
8024 msg.type = WMA_LRO_CONFIG_CMD;
8025 msg.reserved = 0;
8026 msg.bodyptr = iwcmd;
8027
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308028 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08008029 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008030 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308031 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008032 return -EAGAIN;
8033 }
8034
8035 WMA_LOGD("sending the LRO configuration to the fw");
8036 return 0;
8037}
8038#endif
Leo Chang96464902016-10-28 11:10:54 -07008039
8040void wma_peer_set_default_routing(void *scn_handle, uint8_t *peer_macaddr,
8041 uint8_t vdev_id, bool hash_based, uint8_t ring_num)
8042{
8043 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8044 struct peer_set_params param;
8045
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308046 if (!wma) {
8047 WMA_LOGE("%s:wma_handle is NULL", __func__);
8048 return;
8049 }
Leo Chang96464902016-10-28 11:10:54 -07008050
8051 /* TODO: Need bit definitions for ring number and hash based routing
8052 * fields in common wmi header file
8053 */
8054 param.param_id = WMI_HOST_PEER_SET_DEFAULT_ROUTING;
8055 param.vdev_id = vdev_id;
8056 param.param_value = ((hash_based) ? 1 : 0) | (ring_num << 1);
Dhanashri Atre09828f12016-11-13 10:36:58 -08008057 WMA_LOGD("%s: param_value 0x%d", __func__, param.param_value);
Leo Chang96464902016-10-28 11:10:54 -07008058 wmi_set_peer_param_send(wma->wmi_handle, peer_macaddr, &param);
8059
8060 return;
8061}
8062
8063int wma_peer_rx_reorder_queue_setup(void *scn_handle,
8064 uint8_t vdev_id, uint8_t *peer_macaddr, qdf_dma_addr_t hw_qdesc,
8065 int tid, uint16_t queue_no)
8066{
8067 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8068 struct rx_reorder_queue_setup_params param;
8069
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308070 if (!wma) {
8071 WMA_LOGE("%s:wma_handle is NULL", __func__);
8072 return QDF_STATUS_E_FAILURE;
8073 }
8074
Leo Chang96464902016-10-28 11:10:54 -07008075 param.tid = tid;
8076 param.vdev_id = vdev_id;
8077 param.peer_macaddr = peer_macaddr;
8078 param.hw_qdesc_paddr_lo = hw_qdesc & 0xffffffff;
8079 param.hw_qdesc_paddr_hi = (uint64_t)hw_qdesc >> 32;
8080 param.queue_no = queue_no;
8081
8082 return wmi_unified_peer_rx_reorder_queue_setup_send(wma->wmi_handle,
8083 &param);
8084}
8085
8086int wma_peer_rx_reorder_queue_remove(void *scn_handle,
8087 uint8_t vdev_id, uint8_t *peer_macaddr, uint32_t peer_tid_bitmap)
8088{
8089 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8090 struct rx_reorder_queue_remove_params param;
8091
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308092 if (!wma) {
8093 WMA_LOGE("%s:wma_handle is NULL", __func__);
8094 return QDF_STATUS_E_FAILURE;
8095 }
8096
Leo Chang96464902016-10-28 11:10:54 -07008097 param.vdev_id = vdev_id;
8098 param.peer_macaddr = peer_macaddr;
8099 param.peer_tid_bitmap = peer_tid_bitmap;
8100
8101 return wmi_unified_peer_rx_reorder_queue_remove_send(wma->wmi_handle,
8102 &param);
8103}
8104
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +05308105QDF_STATUS wma_configure_smps_params(uint32_t vdev_id, uint32_t param_id,
8106 uint32_t param_val)
8107{
8108 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8109 int smps_cmd_value;
8110 int status = QDF_STATUS_E_INVAL;
8111
8112 if (!wma) {
8113 WMA_LOGE("%s: Failed to get wma", __func__);
8114 return status;
8115 }
8116
8117 smps_cmd_value = param_id << WMI_SMPS_PARAM_VALUE_S;
8118 smps_cmd_value = smps_cmd_value | param_val;
8119
8120 status = wma_set_smps_params(wma, vdev_id, smps_cmd_value);
8121 if (status)
8122 WMA_LOGE("Failed to set SMPS Param");
8123
8124 return status;
8125}
8126
Leo Chang96464902016-10-28 11:10:54 -07008127
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07008128void wma_ipa_uc_stat_request(wma_cli_set_cmd_t *privcmd)
8129{
8130 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8131
Sreelakshmi Konamki7a574082017-05-15 16:53:45 +05308132 if (!wma) {
8133 WMA_LOGE("%s: Failed to get wma", __func__);
8134 return;
8135 }
8136
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07008137 if (wma_set_priv_cfg(wma, privcmd))
8138 WMA_LOGE("Failed to set wma priv congiuration");
8139}