blob: f9f9f39937706dcfd58774bc0aedce525d053293 [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
949
950/**
951 * wma_process_cli_set_cmd() - set parameters to fw
952 * @wma: wma handle
953 * @privcmd: command
954 *
955 * Return: none
956 */
957static void wma_process_cli_set_cmd(tp_wma_handle wma,
958 wma_cli_set_cmd_t *privcmd)
959{
Govind Singhd76a5b02016-03-08 15:12:14 +0530960 int vid = privcmd->param_vdev_id, pps_val = 0;
961 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 struct wma_txrx_node *intr = wma->interfaces;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530963 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 struct qpower_params *qparams = &intr[vid].config.qpower_params;
Govind Singhd76a5b02016-03-08 15:12:14 +0530965 struct pdev_params pdev_param;
Leo Chang96464902016-10-28 11:10:54 -0700966 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967
968 WMA_LOGD("wmihandle %p", wma->wmi_handle);
969
970 if (NULL == pMac) {
971 WMA_LOGE("%s: Failed to get pMac", __func__);
972 return;
973 }
974
975 if (privcmd->param_id >= WMI_CMDID_MAX) {
976 /*
977 * This configuration setting is not done using any wmi
978 * command, call appropriate handler.
979 */
980 if (wma_set_priv_cfg(wma, privcmd))
981 WMA_LOGE("Failed to set wma priv congiuration");
982 return;
983 }
984
985 switch (privcmd->param_vp_dev) {
986 case VDEV_CMD:
Bhargav Shaha89d3b42016-04-20 13:04:56 +0530987 if (!wma->interfaces[privcmd->param_vdev_id].is_vdev_valid) {
988 WMA_LOGE("%s Vdev id is not valid", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700989 return;
Bhargav Shaha89d3b42016-04-20 13:04:56 +0530990 }
991
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
993 privcmd->param_id, privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530994 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 privcmd->param_vdev_id,
996 privcmd->param_id,
997 privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530998 if (QDF_IS_STATUS_ERROR(ret)) {
999 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000 ret);
1001 return;
1002 }
1003 break;
1004 case PDEV_CMD:
1005 WMA_LOGD("pdev pid %d pval %d", privcmd->param_id,
1006 privcmd->param_value);
1007 if ((privcmd->param_id == WMI_PDEV_PARAM_RX_CHAIN_MASK) ||
1008 (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK)) {
Jiachao Wu08719b02017-07-05 13:05:34 +08001009 if (QDF_STATUS_SUCCESS !=
1010 wma_check_txrx_chainmask(
1011 wma->num_rf_chains,
1012 privcmd->param_value)) {
1013 WMA_LOGD("Chainmask value is invalid");
1014 return;
1015 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016 }
Govind Singhd76a5b02016-03-08 15:12:14 +05301017 pdev_param.param_id = privcmd->param_id;
1018 pdev_param.param_value = privcmd->param_value;
1019 ret = wmi_unified_pdev_param_send(wma->wmi_handle,
1020 &pdev_param,
1021 WMA_WILDCARD_PDEV_ID);
1022 if (QDF_IS_STATUS_ERROR(ret)) {
1023 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 ret);
1025 return;
1026 }
1027 break;
1028 case GEN_CMD:
1029 {
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001030 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 struct wma_txrx_node *intr = wma->interfaces;
1032
1033 vdev = wma_find_vdev_by_id(wma, privcmd->param_vdev_id);
1034 if (!vdev) {
1035 WMA_LOGE("%s:Invalid vdev handle", __func__);
1036 return;
1037 }
1038
1039 WMA_LOGD("gen pid %d pval %d", privcmd->param_id,
1040 privcmd->param_value);
1041
1042 switch (privcmd->param_id) {
1043 case GEN_VDEV_PARAM_AMPDU:
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301044 if (soc) {
1045 ret = cdp_aggr_cfg(soc, vdev,
1046 privcmd->param_value, 0);
1047 if (ret)
1048 WMA_LOGE("cdp_aggr_cfg set ampdu failed ret %d",
1049 ret);
1050 else
1051 intr[privcmd->param_vdev_id].config.
1052 ampdu = privcmd->param_value;
1053 } else {
1054 WMA_LOGE("%s:SOC context is NULL", __func__);
1055 return;
1056 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 break;
1058 case GEN_VDEV_PARAM_AMSDU:
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001059 /*
1060 * Firmware currently does not support set operation
1061 * for AMSDU. It may cause crash if the configuration
1062 * is sent to firmware.
1063 * Firmware enhancement will advertise a service bit
1064 * to enable AMSDU configuration through WMI. Then
1065 * add the WMI command to configure AMSDU parameter.
1066 * For the older chipset that does not advertise the
1067 * service bit, enable the following legacy code:
1068 * ol_txrx_aggr_cfg(vdev, 0, privcmd->param_value);
1069 * intr[privcmd->param_vdev_id].config.amsdu =
1070 * privcmd->param_value;
1071 */
1072 WMA_LOGE("SET GEN_VDEV_PARAM_AMSDU command is currently not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 case GEN_PARAM_CRASH_INJECT:
Rajeev Kumar0a9901b2015-12-15 15:59:19 -08001075 if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
1076 WMA_LOGE("Crash inject not allowed in FTM mode");
1077 else
1078 ret = wma_crash_inject(wma,
1079 privcmd->param_value,
1080 privcmd->param_sec_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001082 case GEN_PARAM_CAPTURE_TSF:
1083 ret = wma_capture_tsf(wma, privcmd->param_value);
1084 break;
1085 case GEN_PARAM_RESET_TSF_GPIO:
1086 ret = wma_reset_tsf_gpio(wma, privcmd->param_value);
1087 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 case GEN_PARAM_MODULATED_DTIM:
1089 wma_set_modulated_dtim(wma, privcmd);
1090 break;
1091 default:
1092 WMA_LOGE("Invalid param id 0x%x",
1093 privcmd->param_id);
1094 break;
1095 }
1096 break;
1097 }
1098 case DBG_CMD:
1099 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1100 privcmd->param_value);
1101 switch (privcmd->param_id) {
1102 case WMI_DBGLOG_LOG_LEVEL:
1103 ret = dbglog_set_log_lvl(wma->wmi_handle,
1104 privcmd->param_value);
1105 if (ret)
1106 WMA_LOGE("dbglog_set_log_lvl failed ret %d",
1107 ret);
1108 break;
1109 case WMI_DBGLOG_VAP_ENABLE:
1110 ret = dbglog_vap_log_enable(wma->wmi_handle,
1111 privcmd->param_value, true);
1112 if (ret)
1113 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1114 ret);
1115 break;
1116 case WMI_DBGLOG_VAP_DISABLE:
1117 ret = dbglog_vap_log_enable(wma->wmi_handle,
1118 privcmd->param_value, false);
1119 if (ret)
1120 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1121 ret);
1122 break;
1123 case WMI_DBGLOG_MODULE_ENABLE:
1124 ret = dbglog_module_log_enable(wma->wmi_handle,
1125 privcmd->param_value, true);
1126 if (ret)
1127 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1128 ret);
1129 break;
1130 case WMI_DBGLOG_MODULE_DISABLE:
1131 ret = dbglog_module_log_enable(wma->wmi_handle,
1132 privcmd->param_value, false);
1133 if (ret)
1134 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1135 ret);
1136 break;
1137 case WMI_DBGLOG_MOD_LOG_LEVEL:
1138 ret = dbglog_set_mod_log_lvl(wma->wmi_handle,
1139 privcmd->param_value);
1140 if (ret)
1141 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1142 ret);
1143 break;
1144 case WMI_DBGLOG_TYPE:
1145 ret = dbglog_parser_type_init(wma->wmi_handle,
1146 privcmd->param_value);
1147 if (ret)
1148 WMA_LOGE("dbglog_parser_type_init failed ret %d",
1149 ret);
1150 break;
1151 case WMI_DBGLOG_REPORT_ENABLE:
1152 ret = dbglog_report_enable(wma->wmi_handle,
1153 privcmd->param_value);
1154 if (ret)
1155 WMA_LOGE("dbglog_report_enable failed ret %d",
1156 ret);
1157 break;
Govind Singha471e5e2015-10-12 17:11:14 +05301158 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301159 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301160 WMI_WLAN_PROFILE_TRIGGER_CMDID,
1161 privcmd->param_value, 0);
1162 if (ret)
1163 WMA_LOGE("Profile cmd failed for %d ret %d",
1164 WMI_WLAN_PROFILE_TRIGGER_CMDID, ret);
1165 break;
1166 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301167 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301168 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1169 privcmd->param_value,
1170 privcmd->param_sec_value);
1171 if (ret)
1172 WMA_LOGE("Profile cmd failed for %d ret %d",
1173 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1174 ret);
1175 break;
1176 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301177 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301178 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1179 privcmd->param_value,
1180 privcmd->param_sec_value);
1181 if (ret)
1182 WMA_LOGE("Profile cmd failed for %d ret %d",
1183 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1184 ret);
1185 break;
1186 case WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301187 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301188 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1189 0, 0);
1190 if (ret)
1191 WMA_LOGE("Profile cmd failed for %d ret %d",
1192 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1193 ret);
1194 break;
1195 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301196 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301197 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1198 0, 0);
1199 if (ret)
1200 WMA_LOGE("Profile cmd failed for %d ret %d",
1201 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1202 ret);
1203 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 case WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID:
1205 /* Set the Green AP */
Govind Singhd76a5b02016-03-08 15:12:14 +05301206 ret = wmi_unified_green_ap_ps_send
1207 (wma->wmi_handle, privcmd->param_value,
1208 WMA_WILDCARD_PDEV_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 if (ret) {
1210 WMA_LOGE("Set GreenAP Failed val %d",
1211 privcmd->param_value);
1212 }
1213 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214
1215 default:
1216 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1217 break;
1218 }
1219 break;
1220 case PPS_CMD:
1221 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1222 privcmd->param_value);
1223 switch (privcmd->param_id) {
1224
1225 case WMI_VDEV_PPS_PAID_MATCH:
1226 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1227 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
1228 intr[vid].config.pps_params.paid_match_enable =
1229 privcmd->param_value;
1230 break;
1231 case WMI_VDEV_PPS_GID_MATCH:
1232 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1233 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
1234 intr[vid].config.pps_params.gid_match_enable =
1235 privcmd->param_value;
1236 break;
1237 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
1238 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1239 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
1240 intr[vid].config.pps_params.tim_clear =
1241 privcmd->param_value;
1242 break;
1243 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
1244 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1245 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
1246 intr[vid].config.pps_params.dtim_clear =
1247 privcmd->param_value;
1248 break;
1249 case WMI_VDEV_PPS_EOF_PAD_DELIM:
1250 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1251 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
1252 intr[vid].config.pps_params.eof_delim =
1253 privcmd->param_value;
1254 break;
1255 case WMI_VDEV_PPS_MACADDR_MISMATCH:
1256 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1257 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
1258 intr[vid].config.pps_params.mac_match =
1259 privcmd->param_value;
1260 break;
1261 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
1262 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1263 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
1264 intr[vid].config.pps_params.delim_fail =
1265 privcmd->param_value;
1266 break;
1267 case WMI_VDEV_PPS_GID_NSTS_ZERO:
1268 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1269 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
1270 intr[vid].config.pps_params.nsts_zero =
1271 privcmd->param_value;
1272 break;
1273 case WMI_VDEV_PPS_RSSI_CHECK:
1274 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1275 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
1276 intr[vid].config.pps_params.rssi_chk =
1277 privcmd->param_value;
1278 break;
1279 case WMI_VDEV_PPS_5G_EBT:
1280 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1281 (PKT_PWR_SAVE_5G_EBT & 0xffff);
1282 intr[vid].config.pps_params.ebt_5g =
1283 privcmd->param_value;
1284 break;
1285 default:
1286 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1287 break;
1288 }
1289 break;
1290
1291 case QPOWER_CMD:
1292 WMA_LOGD("QPOWER CLI CMD pid %d pval %d", privcmd->param_id,
1293 privcmd->param_value);
1294 switch (privcmd->param_id) {
1295 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
1296 WMA_LOGD("QPOWER CLI CMD:Ps Poll Cnt val %d",
1297 privcmd->param_value);
1298 /* Set the QPower Ps Poll Count */
Govind Singhd76a5b02016-03-08 15:12:14 +05301299 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 vid, WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
1301 privcmd->param_value);
1302 if (ret) {
1303 WMA_LOGE("Set Q-PsPollCnt Failed vdevId %d val %d",
1304 vid, privcmd->param_value);
1305 } else {
1306 qparams->max_ps_poll_cnt = privcmd->param_value;
1307 }
1308 break;
1309 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
1310 WMA_LOGD("QPOWER CLI CMD:Max Tx Before wake val %d",
1311 privcmd->param_value);
1312 /* Set the QPower Max Tx Before Wake */
Govind Singhd76a5b02016-03-08 15:12:14 +05301313 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 vid, WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
1315 privcmd->param_value);
1316 if (ret) {
1317 WMA_LOGE("Set Q-MaxTxBefWake Failed vId %d val %d",
1318 vid, privcmd->param_value);
1319 } else {
1320 qparams->max_tx_before_wake =
1321 privcmd->param_value;
1322 }
1323 break;
1324 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
1325 WMA_LOGD("QPOWER CLI CMD:Ps Poll Wake Inv val %d",
1326 privcmd->param_value);
1327 /* Set the QPower Spec Ps Poll Wake Inv */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001328 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1329 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 privcmd->param_value);
1331 if (ret) {
1332 WMA_LOGE("Set Q-PsPoll WakeIntv Failed vId %d val %d",
1333 vid, privcmd->param_value);
1334 } else {
1335 qparams->spec_ps_poll_wake_interval =
1336 privcmd->param_value;
1337 }
1338 break;
1339 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
1340 WMA_LOGD("QPOWER CLI CMD:Spec NoData Ps Poll val %d",
1341 privcmd->param_value);
1342 /* Set the QPower Spec NoData PsPoll */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001343 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1344 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345 privcmd->param_value);
1346 if (ret) {
1347 WMA_LOGE("Set Q-SpecNoDataPsPoll Failed vId %d val %d",
1348 vid, privcmd->param_value);
1349 } else {
1350 qparams->max_spec_nodata_ps_poll =
1351 privcmd->param_value;
1352 }
1353 break;
1354
1355 default:
1356 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1357 break;
1358 }
1359 break;
1360 case GTX_CMD:
1361 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1362 privcmd->param_id, privcmd->param_value);
1363 switch (privcmd->param_id) {
1364 case WMI_VDEV_PARAM_GTX_HT_MCS:
1365 intr[vid].config.gtx_info.gtxRTMask[0] =
1366 privcmd->param_value;
1367 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1368 privcmd->param_vdev_id,
1369 &intr[vid].config.gtx_info);
1370 break;
1371 case WMI_VDEV_PARAM_GTX_VHT_MCS:
1372 intr[vid].config.gtx_info.gtxRTMask[1] =
1373 privcmd->param_value;
1374 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1375 privcmd->param_vdev_id,
1376 &intr[vid].config.gtx_info);
1377 break;
1378
1379 case WMI_VDEV_PARAM_GTX_USR_CFG:
1380 intr[vid].config.gtx_info.gtxUsrcfg =
1381 privcmd->param_value;
1382 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1383 privcmd->param_vdev_id,
1384 &intr[vid].config.gtx_info);
1385 break;
1386
1387 case WMI_VDEV_PARAM_GTX_THRE:
1388 intr[vid].config.gtx_info.gtxPERThreshold =
1389 privcmd->param_value;
1390 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1391 privcmd->param_vdev_id,
1392 &intr[vid].config.gtx_info);
1393 break;
1394
1395 case WMI_VDEV_PARAM_GTX_MARGIN:
1396 intr[vid].config.gtx_info.gtxPERMargin =
1397 privcmd->param_value;
1398 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1399 privcmd->param_vdev_id,
1400 &intr[vid].config.gtx_info);
1401 break;
1402
1403 case WMI_VDEV_PARAM_GTX_STEP:
1404 intr[vid].config.gtx_info.gtxTPCstep =
1405 privcmd->param_value;
1406 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1407 privcmd->param_vdev_id,
1408 &intr[vid].config.gtx_info);
1409 break;
1410
1411 case WMI_VDEV_PARAM_GTX_MINTPC:
1412 intr[vid].config.gtx_info.gtxTPCMin =
1413 privcmd->param_value;
1414 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1415 privcmd->param_vdev_id,
1416 &intr[vid].config.gtx_info);
1417 break;
1418
1419 case WMI_VDEV_PARAM_GTX_BW_MASK:
1420 intr[vid].config.gtx_info.gtxBWMask =
1421 privcmd->param_value;
1422 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1423 privcmd->param_vdev_id,
1424 &intr[vid].config.gtx_info);
1425 if (ret) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001426 WMA_LOGE("wma_vdev_set_param failed ret %d",
1427 ret);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 return;
1429 }
1430 break;
1431 default:
1432 break;
1433 }
1434 break;
1435
1436 default:
1437 WMA_LOGE("Invalid vpdev command id");
1438 }
1439 if (1 == privcmd->param_vp_dev) {
1440 switch (privcmd->param_id) {
1441 case WMI_VDEV_PARAM_NSS:
1442 intr[vid].config.nss = privcmd->param_value;
1443 break;
1444 case WMI_VDEV_PARAM_LDPC:
1445 intr[vid].config.ldpc = privcmd->param_value;
1446 break;
1447 case WMI_VDEV_PARAM_TX_STBC:
1448 intr[vid].config.tx_stbc = privcmd->param_value;
1449 break;
1450 case WMI_VDEV_PARAM_RX_STBC:
1451 intr[vid].config.rx_stbc = privcmd->param_value;
1452 break;
1453 case WMI_VDEV_PARAM_SGI:
1454 intr[vid].config.shortgi = privcmd->param_value;
1455 break;
1456 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
1457 intr[vid].config.rtscts_en = privcmd->param_value;
1458 break;
1459 case WMI_VDEV_PARAM_CHWIDTH:
1460 intr[vid].config.chwidth = privcmd->param_value;
1461 break;
1462 case WMI_VDEV_PARAM_FIXED_RATE:
1463 intr[vid].config.tx_rate = privcmd->param_value;
1464 break;
1465 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE:
1466 intr[vid].config.erx_adjust = privcmd->param_value;
1467 break;
1468 case WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM:
1469 intr[vid].config.erx_bmiss_num = privcmd->param_value;
1470 break;
1471 case WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE:
1472 intr[vid].config.erx_bmiss_cycle = privcmd->param_value;
1473 break;
1474 case WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP:
1475 intr[vid].config.erx_slop_step = privcmd->param_value;
1476 break;
1477 case WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP:
1478 intr[vid].config.erx_init_slop = privcmd->param_value;
1479 break;
1480 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE:
1481 intr[vid].config.erx_adj_pause = privcmd->param_value;
1482 break;
1483 case WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE:
1484 intr[vid].config.erx_dri_sample = privcmd->param_value;
1485 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001486 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001487 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001488 wma_set_he_vdev_param(&intr[vid], privcmd->param_id,
1489 privcmd->param_value);
1490 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001492 WMA_LOGE("Invalid wma_cli_set vdev command/Not yet implemented 0x%x",
1493 privcmd->param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494 break;
1495 }
1496 } else if (2 == privcmd->param_vp_dev) {
1497 switch (privcmd->param_id) {
1498 case WMI_PDEV_PARAM_ANI_ENABLE:
1499 wma->pdevconfig.ani_enable = privcmd->param_value;
1500 break;
1501 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
1502 wma->pdevconfig.ani_poll_len = privcmd->param_value;
1503 break;
1504 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
1505 wma->pdevconfig.ani_listen_len = privcmd->param_value;
1506 break;
1507 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
1508 wma->pdevconfig.ani_ofdm_level = privcmd->param_value;
1509 break;
1510 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
1511 wma->pdevconfig.ani_cck_level = privcmd->param_value;
1512 break;
1513 case WMI_PDEV_PARAM_DYNAMIC_BW:
1514 wma->pdevconfig.cwmenable = privcmd->param_value;
1515 break;
1516 case WMI_PDEV_PARAM_CTS_CBW:
1517 wma->pdevconfig.cts_cbw = privcmd->param_value;
1518 break;
1519 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
1520 wma->pdevconfig.txchainmask = privcmd->param_value;
1521 break;
1522 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
1523 wma->pdevconfig.rxchainmask = privcmd->param_value;
1524 break;
1525 case WMI_PDEV_PARAM_BURST_ENABLE:
1526 wma->pdevconfig.burst_enable = privcmd->param_value;
1527 if ((wma->pdevconfig.burst_enable == 1) &&
1528 (wma->pdevconfig.burst_dur == 0))
1529 wma->pdevconfig.burst_dur =
1530 WMA_DEFAULT_SIFS_BURST_DURATION;
1531 else if (wma->pdevconfig.burst_enable == 0)
1532 wma->pdevconfig.burst_dur = 0;
1533 break;
1534 case WMI_PDEV_PARAM_BURST_DUR:
1535 wma->pdevconfig.burst_dur = privcmd->param_value;
1536 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
1538 wma->pdevconfig.txpow2g = privcmd->param_value;
1539 if ((pMac->roam.configParam.bandCapability ==
1540 eCSR_BAND_ALL) ||
1541 (pMac->roam.configParam.bandCapability ==
1542 eCSR_BAND_24)) {
1543 if (cfg_set_int(pMac,
1544 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1545 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301546 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1548
1549 } else {
1550 WMA_LOGE("Current band is not 2G");
1551 }
1552 break;
1553 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
1554 wma->pdevconfig.txpow5g = privcmd->param_value;
1555 if ((pMac->roam.configParam.bandCapability ==
1556 eCSR_BAND_ALL) ||
1557 (pMac->roam.configParam.bandCapability ==
1558 eCSR_BAND_5G)) {
1559 if (cfg_set_int(pMac,
1560 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1561 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301562 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1564
1565 } else {
1566 WMA_LOGE("Current band is not 5G");
1567 }
1568 break;
1569 default:
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001570 WMA_LOGD("Invalid wma_cli_set pdev command/Not yet implemented 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 privcmd->param_id);
1572 break;
1573 }
1574 } else if (5 == privcmd->param_vp_dev) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301575 ret = wma_vdev_set_param(wma->wmi_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001576 privcmd->param_vdev_id,
1577 WMI_VDEV_PARAM_PACKET_POWERSAVE,
1578 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 if (ret)
1580 WMA_LOGE("Failed to send wmi packet power save cmd");
1581 else
1582 WMA_LOGD("Sent packet power save cmd %d value %x to target",
1583 privcmd->param_id, pps_val);
1584 }
1585}
1586
1587/**
1588 * wma_process_fw_event() - process any fw event
1589 * @wma: wma handle
1590 * @buf: fw event buffer
1591 *
1592 * This function process any fw event to serialize it through mc thread.
1593 *
1594 * Return: none
1595 */
1596static int wma_process_fw_event(tp_wma_handle wma,
1597 wma_process_fw_event_params *buf)
1598{
1599 struct wmi_unified *wmi_handle = (struct wmi_unified *)buf->wmi_handle;
1600
1601 wmi_process_fw_event(wmi_handle, buf->evt_buf);
1602 return 0;
1603}
1604
1605/**
Govind Singhd76a5b02016-03-08 15:12:14 +05301606 * wmi_process_fw_event_tasklet_ctx() - process in tasklet context
1607 * @ctx: handle to wmi
1608 * @ev: wmi event buffer
1609 *
1610 * Event process by below function will be in tasket context,
1611 * need to use this method only for time sensitive functions.
1612 *
1613 * Return: none
1614 */
1615static int wma_process_fw_event_tasklet_ctx(void *ctx, void *ev)
1616{
1617 wmi_process_fw_event(ctx, ev);
1618
1619 return 0;
1620}
1621
1622/**
Manjeet Singhf82ed072016-07-08 11:40:00 +05301623 * wma_process_hal_pwr_dbg_cmd() - send hal pwr dbg cmd to fw.
1624 * @handle: wma handle
1625 * @sir_pwr_dbg_params: unit test command
1626 *
1627 * This function send unit test command to fw.
1628 *
1629 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
1630 */
1631QDF_STATUS wma_process_hal_pwr_dbg_cmd(WMA_HANDLE handle,
1632 struct sir_mac_pwr_dbg_cmd *
1633 sir_pwr_dbg_params)
1634{
1635 tp_wma_handle wma_handle = (tp_wma_handle)handle;
1636 int i;
1637 struct wmi_power_dbg_params wmi_pwr_dbg_params;
1638 QDF_STATUS status;
1639
1640 if (!sir_pwr_dbg_params) {
1641 WMA_LOGE("%s: sir_pwr_dbg_params is null", __func__);
1642 return QDF_STATUS_E_INVAL;
1643 }
1644 wmi_pwr_dbg_params.module_id = sir_pwr_dbg_params->module_id;
1645 wmi_pwr_dbg_params.pdev_id = sir_pwr_dbg_params->pdev_id;
1646 wmi_pwr_dbg_params.num_args = sir_pwr_dbg_params->num_args;
1647
1648 for (i = 0; i < wmi_pwr_dbg_params.num_args; i++)
1649 wmi_pwr_dbg_params.args[i] = sir_pwr_dbg_params->args[i];
1650
1651 status = wmi_unified_send_power_dbg_cmd(wma_handle->wmi_handle,
1652 &wmi_pwr_dbg_params);
1653
1654 return status;
1655}
1656
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001657static void wma_discard_fw_event(struct scheduler_msg *msg)
1658{
1659 switch (msg->type) {
1660 case WMA_PROCESS_FW_EVENT:
1661 qdf_nbuf_free(((wma_process_fw_event_params *)msg->bodyptr)
1662 ->evt_buf);
1663 break;
Abhishek Singhcaf6a652017-07-06 17:35:42 +05301664 case WMA_SET_LINK_STATE:
1665 qdf_mem_free(((tpLinkStateParams) msg->bodyptr)->callbackArg);
1666 break;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001667 }
1668 if (msg->bodyptr)
1669 qdf_mem_free(msg->bodyptr);
1670 msg->bodyptr = NULL;
1671 msg->bodyval = 0;
1672 msg->type = 0;
1673}
1674
Manjeet Singhf82ed072016-07-08 11:40:00 +05301675/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 * wma_process_fw_event_handler() - common event handler to serialize
1677 * event processing through mc_thread
Govind Singhd76a5b02016-03-08 15:12:14 +05301678 * @ctx: wmi context
1679 * @ev: event buffer
1680 * @rx_ctx: rx execution context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 *
1682 * Return: 0 on success, errno on failure
1683 */
Govind Singhd76a5b02016-03-08 15:12:14 +05301684static int wma_process_fw_event_mc_thread_ctx(void *ctx, void *ev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685{
1686 wma_process_fw_event_params *params_buf;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001687 struct scheduler_msg cds_msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301689 params_buf = qdf_mem_malloc(sizeof(wma_process_fw_event_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 if (!params_buf) {
1691 WMA_LOGE("%s: Failed alloc memory for params_buf", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301692 qdf_nbuf_free(ev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 return -ENOMEM;
1694 }
1695
Govind Singhd76a5b02016-03-08 15:12:14 +05301696 params_buf->wmi_handle = (struct wmi_unified *)ctx;
1697 params_buf->evt_buf = (wmi_buf_t *)ev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698
1699 cds_msg.type = WMA_PROCESS_FW_EVENT;
1700 cds_msg.bodyptr = params_buf;
1701 cds_msg.bodyval = 0;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001702 cds_msg.flush_callback = wma_discard_fw_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301704 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001705 scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001706 WMA_LOGE("%s: Failed to post WMA_PROCESS_FW_EVENT msg",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301708 qdf_nbuf_free(ev);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301709 qdf_mem_free(params_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 return -EFAULT;
1711 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 return 0;
1713
1714}
1715
Govind Singhd76a5b02016-03-08 15:12:14 +05301716/**
1717 * wma_process_fw_event_handler() - common event handler to serialize
1718 * event processing through mc_thread
1719 * @ctx: wmi context
1720 * @ev: event buffer
1721 * @rx_ctx: rx execution context
1722 *
1723 * Return: 0 on success, errno on failure
1724 */
1725int wma_process_fw_event_handler(void *ctx, void *ev, uint8_t rx_ctx)
1726{
1727 int err = 0;
1728
1729 if (rx_ctx == WMA_RX_SERIALIZER_CTX) {
1730 err = wma_process_fw_event_mc_thread_ctx(ctx, ev);
1731 } else if (rx_ctx == WMA_RX_TASKLET_CTX) {
1732 wma_process_fw_event_tasklet_ctx(ctx, ev);
1733 } else {
1734 WMA_LOGE("%s: invalid wmi event execution context", __func__);
1735 qdf_nbuf_free(ev);
1736 }
1737
1738 return err;
1739}
1740
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741#ifdef WLAN_FEATURE_NAN
1742/**
1743 * wma_set_nan_enable() - set nan enable flag in WMA handle
1744 * @wma_handle: Pointer to wma handle
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301745 * @cds_cfg: Pointer to CDS Configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 *
1747 * Return: none
1748 */
1749static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301750 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751{
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301752 wma_handle->is_nan_enabled = cds_cfg->is_nan_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753}
1754#else
1755static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301756 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757{
1758}
1759#endif
1760
1761/**
Komal Seelam02d09342016-02-23 18:03:19 +05301762 * wma_init_max_no_of_peers - API to initialize wma configuration params
1763 * @wma_handle: WMA Handle
1764 * @max_peers: Max Peers supported
1765 *
1766 * Return: void
1767 */
1768static void wma_init_max_no_of_peers(tp_wma_handle wma_handle,
1769 uint16_t max_peers)
1770{
1771 struct wma_ini_config *cfg = wma_get_ini_handle(wma_handle);
1772
Naveen Rawat35804772016-06-27 15:40:28 -07001773 if (cfg == NULL) {
1774 WMA_LOGE("%s: NULL WMA ini handle", __func__);
1775 return;
1776 }
1777
Komal Seelam02d09342016-02-23 18:03:19 +05301778 cfg->max_no_of_peers = max_peers;
1779}
1780
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001781/**
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001782 * wma_cleanup_vdev_resp_queue() - cleanup vdev response queue
1783 * @wma: wma handle
1784 *
1785 * Return: none
1786 */
1787static void wma_cleanup_vdev_resp_queue(tp_wma_handle wma)
1788{
1789 struct wma_target_req *req_msg = NULL;
1790 qdf_list_node_t *node1 = NULL;
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001791
1792 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1793 if (!qdf_list_size(&wma->vdev_resp_queue)) {
1794 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08001795 WMA_LOGD(FL("request queue maybe empty"));
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001796 return;
1797 }
1798
Wu Gao1eabdb62017-07-08 15:08:14 +08001799 while (qdf_list_remove_front(&wma->vdev_resp_queue, &node1) ==
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001800 QDF_STATUS_SUCCESS) {
1801 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001802 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Abhishek Singhc614ec42017-04-25 16:17:34 +05301803 qdf_mc_timer_stop(&req_msg->event_timeout);
1804 wma_vdev_resp_timer(req_msg);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001805 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1806 }
1807 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
1808}
1809
1810/**
Abhishek Singhc614ec42017-04-25 16:17:34 +05301811 * wma_cleanup_hold_req() - cleanup hold request queue
1812 * @wma: wma handle
1813 *
1814 * Return: none
1815 */
1816static void wma_cleanup_hold_req(tp_wma_handle wma)
1817{
1818 struct wma_target_req *req_msg = NULL;
1819 qdf_list_node_t *node1 = NULL;
1820
1821 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
1822 if (!qdf_list_size(&wma->wma_hold_req_queue)) {
1823 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1824 WMA_LOGD(FL("request queue is empty"));
1825 return;
1826 }
1827
1828 while (QDF_STATUS_SUCCESS ==
Wu Gao1eabdb62017-07-08 15:08:14 +08001829 qdf_list_remove_front(&wma->wma_hold_req_queue, &node1)) {
Abhishek Singhc614ec42017-04-25 16:17:34 +05301830 req_msg = qdf_container_of(node1, struct wma_target_req, node);
1831 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1832 /* Cleanup timeout handler */
1833 qdf_mc_timer_stop(&req_msg->event_timeout);
1834 qdf_mc_timer_destroy(&req_msg->event_timeout);
1835 wma_hold_req_timer(req_msg);
1836 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
1837 }
1838 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1839}
1840
1841/**
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001842 * wma_shutdown_notifier_cb - Shutdown notifer call back
1843 * @priv : WMA handle
1844 *
1845 * During recovery, WMA may wait for resume to complete if the crash happens
1846 * while in suspend. This may cause delays in completing the recovery. This call
1847 * back would be called during recovery and the event is completed so that if
1848 * the resume is waiting on FW to respond then it can get out of the wait so
1849 * that recovery thread can start bringing down all the modules.
1850 *
1851 * Return: None
1852 */
1853static void wma_shutdown_notifier_cb(void *priv)
1854{
1855 tp_wma_handle wma_handle = priv;
1856
1857 qdf_event_set(&wma_handle->wma_resume_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001858 wma_cleanup_vdev_resp_queue(wma_handle);
Abhishek Singhc614ec42017-04-25 16:17:34 +05301859 wma_cleanup_hold_req(wma_handle);
Mukul Sharma4c60a7e2017-03-06 19:42:18 +05301860 pmo_ucfg_psoc_wakeup_host_event_received(wma_handle->psoc);
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001861}
1862
Mukul Sharma5ff3c582016-09-12 15:23:35 +05301863struct wma_version_info g_wmi_version_info;
1864
Komal Seelam02d09342016-02-23 18:03:19 +05301865/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301866 * wma_state_info_dump() - prints state information of wma layer
1867 * @buf: buffer pointer
1868 * @size: size of buffer to be filled
1869 *
1870 * This function is used to dump state information of wma layer
1871 *
1872 * Return: None
1873 */
1874static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
1875{
Dustin Brown9d797d62017-01-11 16:39:12 -08001876 t_wma_handle *wma;
1877 struct sir_vdev_wow_stats *stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301878 uint16_t len = 0;
1879 char *buf = *buf_ptr;
1880 struct wma_txrx_node *iface;
1881 uint8_t vdev_id;
1882
Dustin Brown9d797d62017-01-11 16:39:12 -08001883 wma = cds_get_context(QDF_MODULE_ID_WMA);
1884 if (!wma) {
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301885 WMA_LOGE("%s: WMA context is invald!", __func__);
1886 return;
1887 }
1888
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001889 WMA_LOGE("%s: size of buffer: %d", __func__, *size);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301890
Dustin Brown9d797d62017-01-11 16:39:12 -08001891 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
1892 iface = &wma->interfaces[vdev_id];
1893 if (!iface->handle)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301894 continue;
1895
Dustin Brown9d797d62017-01-11 16:39:12 -08001896 stats = &iface->wow_stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301897 len += qdf_scnprintf(buf + len, *size - len,
Dustin Brown9d797d62017-01-11 16:39:12 -08001898 "\n"
1899 "vdev_id %d\n"
1900 "WoW Stats\n"
1901 "\tpno_match %u\n"
1902 "\tpno_complete %u\n"
1903 "\tgscan %u\n"
1904 "\tlow_rssi %u\n"
1905 "\trssi_breach %u\n"
1906 "\tucast %u\n"
1907 "\tbcast %u\n"
1908 "\ticmpv4 %u\n"
1909 "\ticmpv6 %u\n"
1910 "\tipv4_mcast %u\n"
1911 "\tipv6_mcast %u\n"
1912 "\tipv6_mcast_ra %u\n"
1913 "\tipv6_mcast_ns %u\n"
1914 "\tipv6_mcast_na %u\n"
1915 "\toem_response %u\n"
1916 "conn_state %d\n"
1917 "dtimPeriod %d\n"
1918 "chanmode %d\n"
1919 "vht_capable %d\n"
1920 "ht_capable %d\n"
1921 "chan_width %d\n"
1922 "vdev_active %d\n"
1923 "vdev_up %d\n"
1924 "aid %d\n"
1925 "rate_flags %d\n"
1926 "nss %d\n"
1927 "tx_power %d\n"
1928 "max_tx_power %d\n"
1929 "nwType %d\n"
1930 "tx_streams %d\n"
1931 "rx_streams %d\n"
1932 "chain_mask %d\n"
1933 "nss_2g %d\n"
1934 "nss_5g %d",
1935 vdev_id,
1936 stats->pno_match,
1937 stats->pno_complete,
1938 stats->gscan,
1939 stats->low_rssi,
1940 stats->rssi_breach,
1941 stats->ucast,
1942 stats->bcast,
1943 stats->icmpv4,
1944 stats->icmpv6,
1945 stats->ipv4_mcast,
1946 stats->ipv6_mcast,
1947 stats->ipv6_mcast_ra,
1948 stats->ipv6_mcast_ns,
1949 stats->ipv6_mcast_na,
1950 stats->oem_response,
1951 iface->conn_state,
1952 iface->dtimPeriod,
1953 iface->chanmode,
1954 iface->vht_capable,
1955 iface->ht_capable,
1956 iface->chan_width,
1957 iface->vdev_active,
Mukul Sharmaf9047232017-03-02 16:58:56 +05301958 wma_is_vdev_up(vdev_id),
Dustin Brown9d797d62017-01-11 16:39:12 -08001959 iface->aid,
1960 iface->rate_flags,
1961 iface->nss,
1962 iface->tx_power,
1963 iface->max_tx_power,
1964 iface->nwType,
1965 iface->tx_streams,
1966 iface->rx_streams,
1967 iface->chain_mask,
1968 iface->nss_2g,
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301969 iface->nss_5g);
1970 }
1971
1972 *size -= len;
1973 *buf_ptr += len;
1974}
1975
1976/**
1977 * wma_register_debug_callback() - registration function for wma layer
1978 * to print wma state information
1979 */
1980static void wma_register_debug_callback(void)
1981{
1982 qdf_register_debug_callback(QDF_MODULE_ID_WMA, &wma_state_info_dump);
1983}
1984
Frank Liu65b17d92016-11-23 15:58:44 +08001985/**
1986 * wma_register_tx_ops_handler() - register tx_ops of southbound
1987 * @tx_ops: tx_ops pointer in southbound
1988 *
1989 * Return: 0 on success, errno on failure
1990 */
1991static QDF_STATUS
1992wma_register_tx_ops_handler(struct wlan_lmac_if_tx_ops *tx_ops)
1993{
1994 /*
1995 * Assign tx_ops, it's up to UMAC modules to declare and define these
1996 * functions which are used to send wmi command to target.
1997 */
1998
Himanshu Agarwalce716f82016-12-21 19:07:54 +05301999 if (!tx_ops) {
2000 WMA_LOGE("%s: pointer to lmac if tx ops is NULL", __func__);
2001 return QDF_STATUS_E_INVAL;
2002 }
2003
2004 /* mgmt_txrx component's tx ops */
2005 tx_ops->mgmt_txrx_tx_ops.mgmt_tx_send = wma_mgmt_unified_cmd_send;
2006
Frank Liu65b17d92016-11-23 15:58:44 +08002007 return QDF_STATUS_SUCCESS;
2008}
2009
2010/**
2011 * wma_target_if_open() - Attach UMAC modules' interface with wmi layer
2012 * @wma_handle: wma handle
2013 *
2014 * Separate module defines below functions:
2015 * 1. tgt_wmi_<module>_<action> api sends wmi command, assigned to south bound
2016 * tx_ops function pointers;
2017 * 2. module's south dispatcher handles information from lower layer, assigned
2018 * to south bound rx_ops function pointers;
2019 * 3. wmi event handler deals with wmi event, extracts umac needed information,
2020 * and call rx_ops(module's dispatcher). It executes in tasklet context and
2021 * is up to dispatcher to decide the context to reside in tasklet or in
2022 * thread context.
2023 *
2024 * Return: None
2025 */
2026static void wma_target_if_open(tp_wma_handle wma_handle)
2027{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302028 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002029
2030 if (!psoc)
2031 return;
2032
Mukul Sharmadad267e2017-02-04 13:25:34 +05302033 wlan_global_lmac_if_set_txops_registration_cb(WLAN_DEV_OL,
2034 target_if_register_tx_ops);
2035 wlan_lmac_if_set_umac_txops_registration_cb(
2036 wma_register_tx_ops_handler);
2037 wlan_global_lmac_if_open(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002038
Frank Liu65b17d92016-11-23 15:58:44 +08002039}
2040
2041/**
2042 * wma_target_if_close() - Detach UMAC modules' interface with wmi layer
2043 * @wma_handle: wma handle
2044 *
2045 * Return: None
2046 */
2047static void wma_target_if_close(tp_wma_handle wma_handle)
2048{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302049 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002050
2051 if (!psoc)
2052 return;
2053
Mukul Sharmadad267e2017-02-04 13:25:34 +05302054 wlan_global_lmac_if_close(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002055}
Frank Liu65b17d92016-11-23 15:58:44 +08002056
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302057/**
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302058 * wma_get_psoc_from_scn_handle() - API to get psoc from scn handle
2059 * @scn_handle: opaque wma handle
2060 *
2061 * API to get psoc from scn handle
2062 *
2063 * Return: None
2064 */
2065static struct wlan_objmgr_psoc *wma_get_psoc_from_scn_handle(void *scn_handle)
2066{
2067 tp_wma_handle wma_handle;
2068
2069 if (!scn_handle) {
2070 WMA_LOGE("invalid scn handle");
2071 return NULL;
2072 }
2073 wma_handle = (tp_wma_handle)scn_handle;
2074
2075 return wma_handle->psoc;
2076}
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002077/**
2078 * wma_legacy_service_ready_event_handler() - legacy (ext)service ready handler
2079 * @event_id: event_id
2080 * @handle: wma handle
2081 * @event_data: event data
2082 * @length: event length
2083 *
2084 * Return: 0 for success, negative error code for failure
2085 */
2086static int wma_legacy_service_ready_event_handler(uint32_t event_id,
2087 void *handle,
2088 uint8_t *event_data,
2089 uint32_t length)
2090{
2091 if (wmi_service_ready_event_id == event_id)
2092 return wma_rx_service_ready_event(handle, event_data, length);
2093 else if (wmi_service_ready_ext_event_id == event_id)
2094 return wma_rx_service_ready_ext_event(handle, event_data,
2095 length);
2096 else
2097 QDF_BUG(0);
2098
2099 return 0;
2100}
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302101
2102/**
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002103 * wma_flush_complete_evt_handler() - FW log flush complete event handler
2104 * @handle: WMI handle
2105 * @event: Event recevied from FW
2106 * @len: Length of the event
2107 *
2108 */
2109static int wma_flush_complete_evt_handler(void *handle,
2110 u_int8_t *event,
2111 u_int32_t len)
2112{
2113 QDF_STATUS status;
2114 tp_wma_handle wma = (tp_wma_handle) handle;
2115
2116 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *param_buf;
2117 wmi_debug_mesg_flush_complete_fixed_param *wmi_event;
2118 uint32_t reason_code;
2119
2120 param_buf = (WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *) event;
2121 if (!param_buf) {
2122 WMA_LOGE("Invalid log flush complete event buffer");
2123 return QDF_STATUS_E_FAILURE;
2124 }
2125
2126 wmi_event = param_buf->fixed_param;
2127 reason_code = wmi_event->reserved0;
2128
2129 /*
2130 * reason_code = 0; Flush event in response to flush command
2131 * reason_code = other value; Asynchronous flush event for fatal events
2132 */
2133 if (!reason_code && (cds_is_log_report_in_progress() == false)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002134 WMA_LOGD("Received WMI flush event without sending CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002135 return -EINVAL;
2136 } else if (!reason_code && cds_is_log_report_in_progress() == true) {
2137 /* Flush event in response to flush command */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002138 WMA_LOGD("Received WMI flush event in response to flush CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002139 status = qdf_mc_timer_stop(&wma->log_completion_timer);
2140 if (status != QDF_STATUS_SUCCESS)
2141 WMA_LOGE("Failed to stop the log completion timeout");
2142 cds_logging_set_fw_flush_complete();
2143 } else if (reason_code && cds_is_log_report_in_progress() == false) {
2144 /* Asynchronous flush event for fatal events */
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002145 status = cds_set_log_completion(WLAN_LOG_TYPE_FATAL,
2146 WLAN_LOG_INDICATOR_FIRMWARE,
2147 reason_code, false);
2148 if (QDF_STATUS_SUCCESS != status) {
2149 WMA_LOGE("%s: Failed to set log trigger params",
2150 __func__);
2151 return QDF_STATUS_E_FAILURE;
2152 }
2153 cds_logging_set_fw_flush_complete();
2154 return status;
2155 } else {
2156 /* Asynchronous flush event for fatal event,
2157 * but, report in progress already
2158 */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002159 WMA_LOGD("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002160 __func__, WLAN_LOG_TYPE_FATAL,
2161 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2162 return QDF_STATUS_E_FAILURE;
2163 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07002164 /* Asynchronous flush event for fatal event,
2165 * but, report in progress already
2166 */
2167 WMA_LOGW("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
2168 __func__, WLAN_LOG_TYPE_FATAL,
2169 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2170 return QDF_STATUS_E_FAILURE;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002171}
2172
2173/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174 * wma_open() - Allocate wma context and initialize it.
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302175 * @psoc: Psoc pointer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 * @cds_context: cds context
2177 * @wma_tgt_cfg_cb: tgt config callback fun
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302178 * @cds_cfg: mac parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 *
2180 * Return: 0 on success, errno on failure
2181 */
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302182QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc, void *cds_context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 wma_tgt_cfg_cb tgt_cfg_cb,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302184 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185{
2186 tp_wma_handle wma_handle;
2187 HTC_HANDLE htc_handle;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302188 qdf_device_t qdf_dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 void *wmi_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302190 QDF_STATUS qdf_status;
Govind Singhd76a5b02016-03-08 15:12:14 +05302191 struct wmi_rx_ops ops;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07002192 struct policy_mgr_wma_cbacks wma_cbacks;
Frank Liu00d73fe2017-05-19 22:11:28 +08002193 struct target_psoc_info *tgt_psoc_info;
Govind Singhd76a5b02016-03-08 15:12:14 +05302194
2195 bool use_cookie = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196
2197 WMA_LOGD("%s: Enter", __func__);
2198
Mukul Sharma5ff3c582016-09-12 15:23:35 +05302199 g_wmi_version_info.major = __WMI_VER_MAJOR_;
2200 g_wmi_version_info.minor = __WMI_VER_MINOR_;
2201 g_wmi_version_info.revision = __WMI_REVISION_;
2202
Anurag Chouhan6d760662016-02-20 16:05:43 +05302203 qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
2204 htc_handle = cds_get_context(QDF_MODULE_ID_HTC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205
2206 if (!htc_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002207 WMA_LOGE("%s: Invalid HTC handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302208 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 }
2210
2211 /* Alloc memory for WMA Context */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302212 qdf_status = cds_alloc_context(cds_context, QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 (void **)&wma_handle,
2214 sizeof(t_wma_handle));
2215
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302216 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002217 WMA_LOGE("%s: Memory allocation failed for wma_handle",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302219 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 }
2221
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302222 qdf_mem_zero(wma_handle, sizeof(t_wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223
Frank Liu00d73fe2017-05-19 22:11:28 +08002224 tgt_psoc_info = qdf_mem_malloc(sizeof(*tgt_psoc_info));
2225 if (!tgt_psoc_info) {
2226 WMA_LOGE("%s: failed to allocate mem for tgt info", __func__);
2227 return QDF_STATUS_E_NOMEM;
2228 }
2229
Anurag Chouhan6d760662016-02-20 16:05:43 +05302230 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302232 qdf_wake_lock_create(&wma_handle->extscan_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 "wlan_extscan_wl");
2234#endif /* FEATURE_WLAN_EXTSCAN */
Mukul Sharmae44d0542017-05-23 21:50:56 +05302235 qdf_wake_lock_create(&wma_handle->wow_wake_lock,
2236 "wlan_wow_wl");
2237 qdf_wake_lock_create(&wma_handle->wow_auth_req_wl,
2238 "wlan_auth_req_wl");
2239 qdf_wake_lock_create(&wma_handle->wow_assoc_req_wl,
2240 "wlan_assoc_req_wl");
2241 qdf_wake_lock_create(&wma_handle->wow_deauth_rec_wl,
2242 "wlan_deauth_rec_wl");
2243 qdf_wake_lock_create(&wma_handle->wow_disassoc_rec_wl,
2244 "wlan_disassoc_rec_wl");
2245 qdf_wake_lock_create(&wma_handle->wow_ap_assoc_lost_wl,
2246 "wlan_ap_assoc_lost_wl");
2247 qdf_wake_lock_create(&wma_handle->wow_auto_shutdown_wl,
2248 "wlan_auto_shutdown_wl");
2249 qdf_wake_lock_create(&wma_handle->roam_ho_wl,
2250 "wlan_roam_ho_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 }
2252
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05302253 qdf_status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_LEGACY_WMA_ID);
2254 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2255 WMA_LOGE("%s: PSOC get_ref fails", __func__);
Frank Liu00d73fe2017-05-19 22:11:28 +08002256 qdf_mem_free(tgt_psoc_info);
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05302257 return qdf_status;
2258 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302259 wma_handle->psoc = psoc;
2260
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002261 /* Open target_if layer and register wma callback */
2262 wma_target_if_open(wma_handle);
2263 target_if_open(wma_get_psoc_from_scn_handle);
2264
Govind Singhd76a5b02016-03-08 15:12:14 +05302265 /* Attach mc_thread context processing function */
2266 ops.wma_process_fw_event_handler_cbk = wma_process_fw_event_handler;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 /* attach the wmi */
Govind Singhd76a5b02016-03-08 15:12:14 +05302268 wmi_handle = wmi_unified_attach(wma_handle, NULL,
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302269 WMI_TLV_TARGET, use_cookie, &ops, psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 if (!wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002271 WMA_LOGE("%s: failed to attach WMI", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302272 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 goto err_wma_handle;
2274 }
2275
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002276 target_if_register_legacy_service_ready_cb(
2277 wma_legacy_service_ready_event_handler);
2278
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 WMA_LOGA("WMA --> wmi_unified_attach - success");
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302280
Frank Liu00d73fe2017-05-19 22:11:28 +08002281 /* store the wmi handle in tgt_if_handle */
2282 tgt_psoc_info->wmi_handle = wmi_handle;
2283
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302284 wlan_psoc_obj_lock(psoc);
Frank Liu00d73fe2017-05-19 22:11:28 +08002285 wlan_psoc_set_tgt_if_handle(psoc, tgt_psoc_info);
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05302286 wlan_psoc_obj_unlock(psoc);
2287
Govind Singhd76a5b02016-03-08 15:12:14 +05302288 wmi_unified_register_event_handler(wmi_handle,
2289 WMI_SERVICE_READY_EVENTID,
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002290 init_deinit_service_ready_event_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05302291 WMA_RX_SERIALIZER_CTX);
2292 wmi_unified_register_event_handler(wmi_handle,
2293 WMI_SERVICE_READY_EXT_EVENTID,
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002294 init_deinit_service_ext_ready_event_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05302295 WMA_RX_SERIALIZER_CTX);
2296 wmi_unified_register_event_handler(wmi_handle,
2297 WMI_READY_EVENTID,
2298 wma_rx_ready_event,
2299 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 /* Save the WMI & HTC handle */
2301 wma_handle->wmi_handle = wmi_handle;
2302 wma_handle->htc_handle = htc_handle;
2303 wma_handle->cds_context = cds_context;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302304 wma_handle->qdf_dev = qdf_dev;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302305 wma_handle->max_scan = cds_cfg->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302307 /* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302308 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302309 /* Cap maxStation based on the target version */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302310 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302311 /* Reinitialize max_no_of_peers based on the capped maxStation value */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302312 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05302313
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 /* initialize default target config */
2315 wma_set_default_tgt_config(wma_handle);
2316
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302317 wma_handle->tx_chain_mask_cck = cds_cfg->tx_chain_mask_cck;
2318 wma_handle->self_gen_frm_pwr = cds_cfg->self_gen_frm_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320#if defined(QCA_WIFI_FTM)
Anurag Chouhan6d760662016-02-20 16:05:43 +05302321 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322 wma_utf_attach(wma_handle);
2323#endif /* QCA_WIFI_FTM */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302324 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
2325 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302327 cds_cfg->max_bssid = WMA_MAX_SUPPORTED_BSS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328
2329 wma_handle->wlan_resource_config.num_wow_filters =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302330 cds_cfg->max_wow_filters;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 wma_handle->wlan_resource_config.num_keep_alive_pattern =
2332 WMA_MAXNUM_PERIODIC_TX_PTRNS;
2333
2334 /* The current firmware implementation requires the number of
Anurag Chouhanffb21542016-02-17 14:33:03 +05302335 * offload peers should be (number of vdevs + 1).
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 */
2337 wma_handle->wlan_resource_config.num_offload_peers =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302338 cds_cfg->ap_maxoffload_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339
2340 wma_handle->wlan_resource_config.num_offload_reorder_buffs =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302341 cds_cfg->ap_maxoffload_reorderbuffs + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302343 wma_handle->ol_ini_info = cds_cfg->ol_ini_info;
2344 wma_handle->max_station = cds_cfg->max_station;
2345 wma_handle->max_bssid = cds_cfg->max_bssid;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302346 wma_handle->driver_type = cds_cfg->driver_type;
2347 wma_handle->ssdp = cds_cfg->ssdp;
2348 wma_handle->enable_mc_list = cds_cfg->enable_mc_list;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05302349 wma_handle->bpf_packet_filter_enable =
2350 cds_cfg->bpf_packet_filter_enable;
Hanumanth Reddy Pothulae87621b2017-04-12 20:53:35 +05302351 wma_handle->active_uc_bpf_mode = cds_cfg->active_uc_bpf_mode;
2352 wma_handle->active_mc_bc_bpf_mode = cds_cfg->active_mc_bc_bpf_mode;
Srinivas Girigowda57b450e2016-10-27 21:00:46 -07002353 wma_handle->link_stats_results = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302355 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
2356 wma_handle->RArateLimitInterval = cds_cfg->ra_ratelimit_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357#endif /* FEATURE_WLAN_RA_FILTERING */
2358#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302359 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360#endif
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302361 wma_set_nan_enable(wma_handle, cds_cfg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302362 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 wma_handle->max_bssid);
2364 if (!wma_handle->interfaces) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002365 WMA_LOGE("%s: failed to allocate interface table", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302366 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 goto err_scn_context;
2368 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302369 qdf_mem_zero(wma_handle->interfaces, sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 wma_handle->max_bssid);
2371 /* Register the debug print event handler */
2372 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302373 WMI_DEBUG_PRINT_EVENTID,
2374 wma_unified_debug_print_event_handler,
2375 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05302376 /* Register profiling event Handler */
2377 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2378 WMI_WLAN_PROFILE_DATA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302379 wma_profile_data_report_event_handler,
2380 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381
2382 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
2384 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05302385 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07002386 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302388 qdf_status = qdf_event_create(&wma_handle->wma_ready_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302389 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002390 WMA_LOGE("%s: wma_ready_event initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 goto err_event_init;
2392 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302393
Anurag Chouhan210db072016-02-22 18:42:15 +05302394 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302395 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302396 wma_service_ready_ext_evt_timeout,
2397 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302398 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05302399 WMA_LOGE("Failed to initialize service ready ext timeout");
2400 goto err_event_init;
2401 }
2402
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302403 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302404 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002405 WMA_LOGE("%s: target suspend event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 __func__);
2407 goto err_event_init;
2408 }
2409
2410 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302411 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
2412 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002413 WMA_LOGE("%s: failed to init tx_frm_download_comp_event",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 __func__);
2415 goto err_event_init;
2416 }
2417
2418 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302419 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
2420 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002421 WMA_LOGE("%s: failed to init tx_queue_empty_event", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422 goto err_event_init;
2423 }
2424
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302425 qdf_status = qdf_event_create(&wma_handle->wma_resume_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302426 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002427 WMA_LOGE("%s: wma_resume_event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 __func__);
2429 goto err_event_init;
2430 }
2431
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002432 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
2433 wma_handle);
2434 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002435 WMA_LOGE("%s: Shutdown notifier register failed: %d",
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002436 __func__, qdf_status);
2437 goto err_event_init;
2438 }
2439
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302440 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302441 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002442 WMA_LOGE("%s: runtime_suspend event initialization failed",
Houston Hoffmana76591b2015-11-10 16:52:05 -08002443 __func__);
2444 goto err_event_init;
2445 }
2446
Anurag Chouhandf2b2682016-02-29 14:15:27 +05302447 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302448 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002449 WMA_LOGE("%s: recovery event initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 goto err_event_init;
2451 }
2452
Anurag Chouhanffb21542016-02-17 14:33:03 +05302453 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07002454 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302455 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05302456 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302458 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05302459 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
2460 qdf_atomic_init(&wma_handle->scan_id_counter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461
2462 /* Register vdev start response event handler */
2463 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2464 WMI_VDEV_START_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302465 wma_vdev_start_resp_handler,
2466 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467
2468 /* Register vdev stop response event handler */
2469 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2470 WMI_VDEV_STOPPED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302471 wma_vdev_stop_resp_handler,
2472 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473
2474 /* register for STA kickout function */
2475 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2476 WMI_PEER_STA_KICKOUT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302477 wma_peer_sta_kickout_event_handler,
2478 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479
2480 /* register for stats response event */
2481 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2482 WMI_UPDATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302483 wma_stats_event_handler,
2484 WMA_RX_SERIALIZER_CTX);
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05302485
Will Huanga9814592017-05-24 15:47:58 +08002486 /* register for peer info response event */
2487 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2488 WMI_PEER_STATS_INFO_EVENTID,
2489 wma_peer_info_event_handler,
2490 WMA_RX_SERIALIZER_CTX);
2491
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05302492#ifdef WLAN_POWER_DEBUGFS
2493 /* register for Chip Power stats event */
2494 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2495 WMI_PDEV_CHIP_POWER_STATS_EVENTID,
2496 wma_unified_power_debug_stats_event_handler,
2497 WMA_RX_SERIALIZER_CTX);
2498#endif
2499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 /* register for linkspeed response event */
2501 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2502 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302503 wma_link_speed_event_handler,
2504 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505
2506#ifdef FEATURE_OEM_DATA_SUPPORT
2507 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002508 WMI_OEM_RESPONSE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302509 wma_oem_data_response_handler,
2510 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511#endif /* FEATURE_OEM_DATA_SUPPORT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512
2513 /* Register peer change event handler */
2514 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2515 WMI_PEER_STATE_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302516 wma_peer_state_change_event_handler,
2517 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518
2519 /* Register beacon tx complete event id. The event is required
2520 * for sending channel switch announcement frames
2521 */
2522 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302523 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID,
2524 wma_unified_bcntx_status_event_handler,
2525 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526
2527 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2528 WMI_UPDATE_VDEV_RATE_STATS_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302529 wma_link_status_event_handler,
2530 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531#ifdef WLAN_FEATURE_LINK_LAYER_STATS
2532 /* Register event handler for processing Link Layer Stats
2533 * response from the FW
2534 */
2535 wma_register_ll_stats_event_handler(wma_handle);
2536
2537#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2538
2539 /*
2540 * Register event handler to receive firmware mem dump
2541 * copy complete indication
2542 */
2543 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2544 WMI_UPDATE_FW_MEM_DUMP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302545 wma_fw_mem_dump_event_handler,
2546 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547
2548 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302549 qdf_status = dbglog_init(wma_handle->wmi_handle);
2550 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002551 WMA_LOGE("%s: Firmware Dbglog initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 goto err_dbglog_init;
2553 }
2554
2555 /*
2556 * Update Powersave mode
2557 * 1 - Legacy Powersave + Deepsleep Disabled
2558 * 2 - QPower + Deepsleep Disabled
2559 * 3 - Legacy Powersave + Deepsleep Enabled
2560 * 4 - QPower + Deepsleep Enabled
2561 */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302562 wma_handle->powersave_mode = cds_cfg->powersave_offload_enabled;
2563 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
2564 wma_handle->staModDtim = cds_cfg->sta_mod_dtim;
2565 wma_handle->staDynamicDtim = cds_cfg->sta_dynamic_dtim;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566
2567 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302568 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 * 0 - Disable both magic pattern match and pattern byte match.
2570 * 1 - Enable magic pattern match on all interfaces.
2571 * 2 - Enable pattern byte match on all interfaces.
2572 * 3 - Enable both magic patter and pattern byte match on
2573 * all interfaces.
2574 */
2575 wma_handle->wow.magic_ptrn_enable =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302576 (cds_cfg->wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 wma_handle->ptrn_match_enable_all_vdev =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05302578 (cds_cfg->wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579
Frank Liud4b2fa02017-03-29 11:46:48 +08002580#if defined(FEATURE_WLAN_TDLS) && !defined(CONVERGED_TDLS_ENABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2582 WMI_TDLS_PEER_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302583 wma_tdls_event_handler,
2584 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585#endif /* FEATURE_WLAN_TDLS */
2586
2587 /* register for install key completion event */
2588 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05302589 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID,
2590 wma_vdev_install_key_complete_event_handler,
2591 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592#ifdef WLAN_FEATURE_NAN
2593 /* register for nan response event */
2594 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2595 WMI_NAN_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302596 wma_nan_rsp_event_handler,
2597 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598#endif /* WLAN_FEATURE_NAN */
2599
2600#ifdef WLAN_FEATURE_STATS_EXT
2601 /* register for extended stats event */
2602 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2603 WMI_STATS_EXT_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302604 wma_stats_ext_event_handler,
2605 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606#endif /* WLAN_FEATURE_STATS_EXT */
2607#ifdef FEATURE_WLAN_EXTSCAN
2608 wma_register_extscan_event_handler(wma_handle);
2609#endif /* WLAN_FEATURE_STATS_EXT */
2610
2611 WMA_LOGD("%s: Exit", __func__);
2612
2613#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2614 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2615 WMI_ROAM_SYNCH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302616 wma_roam_synch_event_handler,
2617 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
2619 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2620 WMI_RSSI_BREACH_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302621 wma_rssi_breached_event_handler,
2622 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302624 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05302625 "wlan_fw_rsp_wakelock");
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002626 wma_handle->wmi_cmd_rsp_runtime_lock =
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302627 qdf_runtime_lock_init("wlan_fw_rsp_runtime_lock");
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 /* Register peer assoc conf event handler */
2630 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2631 WMI_PEER_ASSOC_CONF_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302632 wma_peer_assoc_conf_handler,
2633 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002634 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2635 WMI_VDEV_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302636 wma_vdev_delete_handler,
2637 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08002638 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2639 WMI_PEER_DELETE_RESP_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05302640 wma_peer_delete_handler,
2641 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05302642 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2643 WMI_BPF_CAPABILIY_INFO_EVENTID,
2644 wma_get_bpf_caps_event_handler,
2645 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05302646 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2647 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID,
2648 wma_encrypt_decrypt_msg_handler,
2649 WMA_RX_SERIALIZER_CTX);
Kapil Gupta4f0c0c12017-02-07 15:21:15 +05302650 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2651 WMI_CHAN_INFO_EVENTID,
2652 wma_chan_info_event_handler,
2653 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002654 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2655 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID,
2656 wma_flush_complete_evt_handler,
Rajeev Kumarc3032b82017-02-14 15:56:01 -08002657 WMA_RX_WORK_CTX);
lifeng66831662017-05-19 16:01:35 +08002658 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2659 WMI_REPORT_RX_AGGR_FAILURE_EVENTID,
2660 wma_rx_aggr_failure_event_handler,
2661 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002662
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05302663 wma_handle->ito_repeat_count = cds_cfg->ito_repeat_count;
2664
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05302665 /* Register PWR_SAVE_FAIL event only in case of recovery(1) */
2666 if (cds_cfg->auto_power_save_fail_mode) {
2667 wmi_unified_register_event_handler(wma_handle->wmi_handle,
2668 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID,
2669 wma_chip_power_save_failure_detected_handler,
2670 WMA_RX_WORK_CTX);
2671 }
2672
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07002673 wma_ndp_register_all_event_handlers(wma_handle);
Frank Liu65b17d92016-11-23 15:58:44 +08002674
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302675 wma_register_debug_callback();
Mukul Sharma6411bb82017-03-01 15:57:07 +05302676 /* Register callback with PMO so PMO can update the vdev pause bitmap*/
2677 pmo_register_pause_bitmap_notifier(wma_handle->psoc,
2678 wma_vdev_update_pause_bitmap);
2679 pmo_register_get_pause_bitmap(wma_handle->psoc,
2680 wma_vdev_get_pause_bitmap);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05302681 pmo_register_is_device_in_low_pwr_mode(wma_handle->psoc,
2682 wma_vdev_is_device_in_low_pwr_mode);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07002683 wma_cbacks.wma_get_connection_info = wma_get_connection_info;
2684 wma_cbacks.wma_is_service_enabled = wma_is_service_enabled;
2685 qdf_status = policy_mgr_register_wma_cb(wma_handle->psoc, &wma_cbacks);
2686 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2687 WMA_LOGE("Failed to register wma cb with Policy Manager");
2688 }
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302689
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302690 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002691
2692err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302693 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
2694 qdf_runtime_lock_deinit(wma_handle->wmi_cmd_rsp_runtime_lock);
2695 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
2696 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697err_event_init:
2698 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
2699 WMI_DEBUG_PRINT_EVENTID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302700 qdf_mem_free(wma_handle->interfaces);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701err_scn_context:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702#if defined(QCA_WIFI_FTM)
2703 wma_utf_detach(wma_handle);
2704#endif /* QCA_WIFI_FTM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302705 qdf_mem_free(((p_cds_contextType) cds_context)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 OS_FREE(wmi_handle);
2707
2708err_wma_handle:
Frank Liu00d73fe2017-05-19 22:11:28 +08002709 qdf_mem_free(tgt_psoc_info);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302710 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302712 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302714 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05302715 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
2716 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
2717 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
2718 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
2719 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
2720 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
2721 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 }
Houston Hoffmanc45db892015-11-13 19:59:25 -08002723
Anurag Chouhan6d760662016-02-20 16:05:43 +05302724 cds_free_context(cds_context, QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725
2726 WMA_LOGD("%s: Exit", __func__);
2727
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302728 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729}
2730
2731/**
2732 * wma_pre_start() - wma pre start
2733 * @cds_ctx: cds context
2734 *
2735 * Return: 0 on success, errno on failure
2736 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302737QDF_STATUS wma_pre_start(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302739 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 A_STATUS status = A_OK;
2741 tp_wma_handle wma_handle;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08002742 struct scheduler_msg wma_msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743
2744 WMA_LOGD("%s: Enter", __func__);
2745
Anurag Chouhan6d760662016-02-20 16:05:43 +05302746 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747
2748 /* Validate the wma_handle */
2749 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002750 WMA_LOGE("%s: invalid argument", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302751 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752 goto end;
2753 }
2754 /* Open endpoint for ctrl path - WMI <--> HTC */
2755 status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
2756 wma_handle->htc_handle);
2757 if (A_OK != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002758 WMA_LOGE("%s: wmi_unified_connect_htc_service", __func__);
Nachiket Kukade8003d252017-03-30 15:55:58 +05302759
2760 if (!cds_is_fw_down())
2761 QDF_BUG(0);
2762
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302763 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 goto end;
2765 }
2766
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08002767 WMA_LOGD("WMA --> wmi_unified_connect_htc_service - success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768
2769 /* Trigger the CFG DOWNLOAD */
2770 wma_msg.type = WNI_CFG_DNLD_REQ;
2771 wma_msg.bodyptr = NULL;
2772 wma_msg.bodyval = 0;
2773
Rajeev Kumarb60abe42017-01-21 15:39:31 -08002774 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &wma_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302775 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002776 WMA_LOGE("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302777 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302778 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 }
2780end:
2781 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302782 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783}
2784
2785/**
2786 * wma_send_msg() - Send wma message to PE.
2787 * @wma_handle: wma handle
2788 * @msg_type: message type
2789 * @body_ptr: message body ptr
2790 * @body_val: message body value
2791 *
2792 * Return: none
2793 */
2794void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
2795 void *body_ptr, uint32_t body_val)
2796{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002797 struct scheduler_msg msg = { 0 };
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302798 uint32_t status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302799 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07002800
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 msg.type = msg_type;
2802 msg.bodyval = body_val;
2803 msg.bodyptr = body_ptr;
2804 status = lim_post_msg_api(pMac, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302805 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 if (NULL != body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302807 qdf_mem_free(body_ptr);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302808 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810}
2811
2812/**
2813 * wma_set_base_macaddr_indicate() - set base mac address in fw
2814 * @wma_handle: wma handle
2815 * @customAddr: base mac address
2816 *
2817 * Return: 0 for success or error code
2818 */
2819static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
2820 tSirMacAddr *customAddr)
2821{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 int err;
2823
Govind Singhf25a0f12016-03-08 16:09:48 +05302824 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
2825 (uint8_t *)customAddr);
2826 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
2829 MAC_ADDR_ARRAY((*customAddr)));
2830
2831 return 0;
2832}
2833
2834/**
2835 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
2836 * @handle: WMA handle
2837 * @event: Event received from FW
2838 * @len: Length of the event
2839 *
2840 * Enables the low frequency events and disables the high frequency
2841 * events. Bit 17 indicates if the event if low/high frequency.
2842 * 1 - high frequency, 0 - low frequency
2843 *
2844 * Return: 0 on successfully enabling/disabling the events
2845 */
2846static int wma_log_supported_evt_handler(void *handle,
2847 uint8_t *event,
2848 uint32_t len)
2849{
2850 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851
Govind Singhf25a0f12016-03-08 16:09:48 +05302852 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
2853 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855
2856 return 0;
2857}
2858
2859/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302860 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 * @handle: WMI handle
2862 * @event: Event recevied from FW
2863 * @len: Length of the event
2864 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302865 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
2866 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
2867 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868 *
2869 * Return: Success on receiving valid params from FW
2870 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302871static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 uint8_t *event,
2873 uint32_t len)
2874{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302875 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
2876 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
2877 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 uint32_t i;
2879 struct sir_set_hw_mode_resp *hw_mode_resp;
2880 tp_wma_handle wma = (tp_wma_handle) handle;
2881
2882 if (!wma) {
2883 WMA_LOGE("%s: Invalid WMA handle", __func__);
2884 /* Since WMA handle itself is NULL, we cannot send fail
2885 * response back to LIM here
2886 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302887 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888 }
Krunal Sonicebcc292017-06-14 19:59:20 -07002889 wma_release_wmi_resp_wakelock(wma);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302890 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891 if (!hw_mode_resp) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002892 WMA_LOGE("%s: Memory allocation failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 /* Since this memory allocation itself failed, we cannot
2894 * send fail response back to LIM here
2895 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302896 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 }
2898
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302899 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302901 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 /* Need to send response back to upper layer to free
2903 * active command list
2904 */
2905 goto fail;
2906 }
2907
2908 wmi_event = param_buf->fixed_param;
2909 hw_mode_resp->status = wmi_event->status;
2910 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2911 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
2912
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002913 WMA_LOGE("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 __func__, wmi_event->status,
2915 wmi_event->cfgd_hw_mode_index,
2916 wmi_event->num_vdev_mac_entries);
2917 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302918 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919
2920 /* Store the vdev-mac map in WMA and prepare to send to PE */
2921 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302922 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07002923
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302925 pdev_id = vdev_mac_entry[i].pdev_id;
2926 if (pdev_id == WMI_PDEV_ID_SOC) {
2927 WMA_LOGE("%s: soc level id received for mac id)",
2928 __func__);
2929 QDF_BUG(0);
2930 goto fail;
2931 }
2932 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002934 WMA_LOGE("%s: vdev_id:%d mac_id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 __func__, vdev_id, mac_id);
2936
2937 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
2938 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
2939 wma_update_intf_hw_mode_params(vdev_id, mac_id,
2940 wmi_event->cfgd_hw_mode_index);
2941 }
2942
2943 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
2944 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
2945 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2946 } else {
2947 wma->old_hw_mode_index = wma->new_hw_mode_index;
2948 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
2949 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07002950 policy_mgr_update_hw_mode_index(wma->psoc,
2951 wmi_event->cfgd_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 }
2953
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002954 WMA_LOGE("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
2956
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302957 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 (void *) hw_mode_resp, 0);
2959
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302960 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961
2962fail:
2963 WMA_LOGE("%s: Sending fail response to LIM", __func__);
2964 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
2965 hw_mode_resp->cfgd_hw_mode_index = 0;
2966 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05302967 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 (void *) hw_mode_resp, 0);
2969
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302970 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971}
2972
2973/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002974 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
2975 *
2976 * @handle: WMA handle
2977 * @fixed_param: Event fixed parameters
2978 * @vdev_mac_entry - vdev mac entry
2979 * @hw_mode_trans_ind - Buffer to store parsed information
2980 *
2981 * Parses fixed_param, vdev_mac_entry and fills in the information into
2982 * hw_mode_trans_ind and wma
2983 *
2984 * Return: None
2985 */
2986void wma_process_pdev_hw_mode_trans_ind(void *handle,
2987 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
2988 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
2989 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
2990{
2991 uint32_t i;
2992 tp_wma_handle wma = (tp_wma_handle) handle;
2993
2994 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
2995 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
2996 hw_mode_trans_ind->num_vdev_mac_entries =
2997 fixed_param->num_vdev_mac_entries;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002998 WMA_LOGE("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002999 __func__, fixed_param->old_hw_mode_index,
3000 fixed_param->new_hw_mode_index,
3001 fixed_param->num_vdev_mac_entries);
3002
3003 /* Store the vdev-mac map in WMA and send to policy manager */
3004 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
3005 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003006
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003007 vdev_id = vdev_mac_entry[i].vdev_id;
3008 pdev_id = vdev_mac_entry[i].pdev_id;
3009
3010 if (pdev_id == WMI_PDEV_ID_SOC) {
3011 WMA_LOGE("%s: soc level id received for mac id)",
3012 __func__);
3013 QDF_BUG(0);
3014 return;
3015 }
3016
3017 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
3018
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003019 WMA_LOGE("%s: vdev_id:%d mac_id:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003020 __func__, vdev_id, mac_id);
3021
3022 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
3023 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
3024 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3025 fixed_param->new_hw_mode_index);
3026 }
3027 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
3028 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003029 policy_mgr_update_new_hw_mode_index(wma->psoc,
3030 fixed_param->new_hw_mode_index);
3031 policy_mgr_update_old_hw_mode_index(wma->psoc,
3032 fixed_param->old_hw_mode_index);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003033
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003034 WMA_LOGE("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003035 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3036}
3037
3038/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303039 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 * @handle: WMI handle
3041 * @event: Event recevied from FW
3042 * @len: Length of the event
3043 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303044 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 * asynchronous hardware mode transition. This event notifies the host driver
3046 * that firmware independently changed the hardware mode for some reason, such
3047 * as Coex, LFR 3.0, etc
3048 *
3049 * Return: Success on receiving valid params from FW
3050 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303051static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 uint8_t *event,
3053 uint32_t len)
3054{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303055 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
3056 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
3057 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
3059 tp_wma_handle wma = (tp_wma_handle) handle;
3060
3061 if (!wma) {
3062 /* This is an async event. So, not sending any event to LIM */
3063 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303064 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 }
3066
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303067 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 if (!param_buf) {
3069 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303070 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303071 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 }
3073
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303074 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003075 if (!hw_mode_trans_ind) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003076 WMA_LOGE("%s: Memory allocation failed", __func__);
3077 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 }
3079
3080 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303082 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003083 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
3084 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303086 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 (void *) hw_mode_trans_ind, 0);
3088
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303089 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090}
3091
3092/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303093 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 * @handle: WMI handle
3095 * @event: Event received from FW
3096 * @len: Length of the event
3097 *
3098 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303099 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 * the host driver once the firmware has completed a reconfiguration of the Scan
3101 * and FW mode configuration. This changes could include entering or leaving a
3102 * dual mac configuration for either scan and/or more permanent firmware mode.
3103 *
3104 * Return: Success on receiving valid params from FW
3105 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303106static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 uint8_t *event,
3108 uint32_t len)
3109{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303110 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
3111 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112 tp_wma_handle wma = (tp_wma_handle) handle;
3113 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
3114
3115 if (!wma) {
3116 WMA_LOGE("%s: Invalid WMA handle", __func__);
3117 /* Since the WMA handle is NULL, we cannot send resp to LIM.
3118 * So, returning from here.
3119 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303120 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 }
3122
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303123 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 if (!dual_mac_cfg_resp) {
3125 WMA_LOGE("%s: Memory allocation failed", __func__);
3126 /* Since the mem alloc failed, we cannot send resp to LIM.
3127 * So, returning from here.
3128 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303129 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 }
3131
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303132 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 event;
3134 if (!param_buf) {
3135 WMA_LOGE("%s: Invalid event", __func__);
3136 goto fail;
3137 }
3138
3139 wmi_event = param_buf->fixed_param;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003140 WMA_LOGD("%s: status:%d", __func__, wmi_event->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 dual_mac_cfg_resp->status = wmi_event->status;
3142
3143 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003144 policy_mgr_update_dbs_scan_config(wma->psoc);
3145 policy_mgr_update_dbs_fw_config(wma->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 }
3147
3148 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303149 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150 (void *) dual_mac_cfg_resp, 0);
3151
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303152 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153
3154fail:
3155 WMA_LOGE("%s: Sending fail response to LIM", __func__);
3156 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303157 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 (void *) dual_mac_cfg_resp, 0);
3159
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303160 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161
3162}
3163
3164/**
3165 * wma_start() - wma start function.
3166 * Intialize event handlers and timers.
3167 * @cds_ctx: cds context
3168 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303169 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303171QDF_STATUS wma_start(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303173 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 tp_wma_handle wma_handle;
3175 int status;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003176
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 WMA_LOGD("%s: Enter", __func__);
3178
Anurag Chouhan6d760662016-02-20 16:05:43 +05303179 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 /* validate the wma_handle */
3181 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003182 WMA_LOGE("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303183 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 goto end;
3185 }
Sandeep Puligillad0004212017-02-26 18:34:56 -08003186#ifndef NAPIER_SCAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3188 WMI_SCAN_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303189 wma_scan_event_callback,
3190 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003192 WMA_LOGE("%s: Failed to register scan callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303193 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 goto end;
3195 }
Sandeep Puligillad0004212017-02-26 18:34:56 -08003196#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3198 WMI_ROAM_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303199 wma_roam_event_callback,
Padma, Santhosh Kumar18169ce2017-03-02 18:04:02 +05303200 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003202 WMA_LOGE("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303203 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 goto end;
3205 }
3206
3207 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3208 WMI_WOW_WAKEUP_HOST_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303209 wma_wow_wakeup_host_event,
3210 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003212 WMA_LOGE("%s: Failed to register wow wakeup host event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303214 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 goto end;
3216 }
3217
3218 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3219 WMI_PDEV_RESUME_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05303220 wma_pdev_resume_event_handler,
3221 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003223 WMA_LOGE("%s: Failed to register PDEV resume event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303225 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 goto end;
3227 }
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05303228#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
3229 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08003230 WMA_LOGD("MCC TX Pause Event Handler register");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303232 WMI_TX_PAUSE_EVENTID,
3233 wma_mcc_vdev_tx_pause_evt_handler,
3234 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
3236
3237#ifdef FEATURE_WLAN_CH_AVOID
3238 WMA_LOGD("Registering channel to avoid handler");
3239
3240 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303241 WMI_WLAN_FREQ_AVOID_EVENTID,
3242 wma_channel_avoid_evt_handler,
3243 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 if (status) {
3245 WMA_LOGE("Failed to register channel to avoid event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303246 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247 goto end;
3248 }
3249#endif /* FEATURE_WLAN_CH_AVOID */
3250#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
3251 WMA_LOGD("Registering auto shutdown handler");
3252 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303253 WMI_HOST_AUTO_SHUTDOWN_EVENTID,
3254 wma_auto_shutdown_event_handler,
3255 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 if (status) {
3257 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303258 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 goto end;
3260 }
3261#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
3262 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303263 WMI_THERMAL_MGMT_EVENTID,
3264 wma_thermal_mgmt_evt_handler,
3265 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 if (status) {
3267 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303268 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 goto end;
3270 }
3271
3272 status = wma_ocb_register_event_handlers(wma_handle);
3273 if (status) {
3274 WMA_LOGE("Failed to register ocb event handlers");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303275 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 goto end;
3277 }
3278
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303279 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280
3281#ifdef QCA_WIFI_FTM
3282 /*
3283 * Tx mgmt attach requires TXRX context which is not created
3284 * in FTM mode. So skip the TX mgmt attach.
3285 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303286 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 goto end;
3288#endif /* QCA_WIFI_FTM */
3289
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003290 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3291 WMI_SERVICE_RMC)) {
3292
3293 WMA_LOGD("FW supports cesium network, registering event handlers");
3294
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003295 status = wmi_unified_register_event_handler(
3296 wma_handle->wmi_handle,
3297 WMI_PEER_INFO_EVENTID,
3298 wma_ibss_peer_info_event_handler,
3299 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003300 if (status) {
3301 WMA_LOGE("Failed to register ibss peer info event cb");
3302 qdf_status = QDF_STATUS_E_FAILURE;
3303 goto end;
3304 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003305 status = wmi_unified_register_event_handler(
3306 wma_handle->wmi_handle,
3307 WMI_PEER_TX_FAIL_CNT_THR_EVENTID,
3308 wma_fast_tx_fail_event_handler,
3309 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003310 if (status) {
3311 WMA_LOGE("Failed to register peer fast tx failure event cb");
3312 qdf_status = QDF_STATUS_E_FAILURE;
3313 goto end;
3314 }
3315 } else {
3316 WMA_LOGE("Target does not support cesium network");
3317 }
3318
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303319 qdf_status = wma_tx_attach(wma_handle);
3320 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003321 WMA_LOGE("%s: Failed to register tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 goto end;
3323 }
3324
3325 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05303326 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303327 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 wma_log_completion_timeout,
3329 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303330 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331 WMA_LOGE("Failed to initialize log completion timeout");
3332 goto end;
3333 }
3334
Jeff Johnson6136fb92017-03-30 15:21:49 -07003335 status = wma_fips_register_event_handlers(wma_handle);
3336 if (!QDF_IS_STATUS_SUCCESS(status)) {
3337 WMA_LOGE("Failed to register FIPS event handler");
3338 qdf_status = QDF_STATUS_E_FAILURE;
3339 goto end;
3340 }
3341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 /* Initialize the get temperature event handler */
3343 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05303344 WMI_PDEV_TEMPERATURE_EVENTID,
3345 wma_pdev_temperature_evt_handler,
3346 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303347 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303349 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 goto end;
3351 }
3352
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07003353 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3354 WMI_VDEV_TSF_REPORT_EVENTID,
3355 wma_vdev_tsf_handler,
3356 WMA_RX_SERIALIZER_CTX);
3357 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003358 WMA_LOGE("%s: Failed to register tsf callback", __func__);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07003359 qdf_status = QDF_STATUS_E_FAILURE;
3360 goto end;
3361 }
3362
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303363 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303365 WMI_PDEV_SET_HW_MODE_RESP_EVENTID,
3366 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303367 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303368 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303370 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 goto end;
3372 }
3373
3374 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
3375 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303376 WMI_PDEV_HW_MODE_TRANSITION_EVENTID,
3377 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303378 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303379 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303381 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 goto end;
3383 }
3384
3385 /* Initialize the set dual mac configuration event handler */
3386 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05303387 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID,
3388 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05303389 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303390 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303392 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393 goto end;
3394 }
3395
Wu Gao9a704f42017-03-10 18:42:11 +08003396#ifndef CONVERGED_P2P_ENABLE
Peng Xu8fdaa492016-06-22 10:20:47 -07003397 /* Initialize the P2P Listen Offload event handler */
3398 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3399 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID,
3400 wma_p2p_lo_event_handler,
3401 WMA_RX_SERIALIZER_CTX);
3402 if (!QDF_IS_STATUS_SUCCESS(status)) {
3403 WMA_LOGE("Failed to register p2p lo event cb");
3404 qdf_status = QDF_STATUS_E_FAILURE;
3405 goto end;
3406 }
Wu Gao9a704f42017-03-10 18:42:11 +08003407#endif
Peng Xu8fdaa492016-06-22 10:20:47 -07003408
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05303409 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
3410 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID,
3411 wma_wlan_bt_activity_evt_handler,
3412 WMA_RX_SERIALIZER_CTX);
3413 if (!QDF_IS_STATUS_SUCCESS(status)) {
3414 WMA_LOGE("Failed to register coex bt activity event handler");
3415 qdf_status = QDF_STATUS_E_FAILURE;
3416 goto end;
3417 }
3418
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419end:
3420 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303421 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422}
3423
3424/**
3425 * wma_stop() - wma stop function.
3426 * cleanup timers and suspend target.
3427 * @cds_ctx: cds context
3428 * @reason: reason for wma_stop.
3429 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303430 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303432QDF_STATUS wma_stop(void *cds_ctx, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433{
3434 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303435 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05303436 int i;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003437
Anurag Chouhan6d760662016-02-20 16:05:43 +05303438 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 WMA_LOGD("%s: Enter", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 /* validate the wma_handle */
3441 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003442 WMA_LOGE("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303443 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 goto end;
3445 }
3446#ifdef QCA_WIFI_FTM
3447 /*
3448 * Tx mgmt detach requires TXRX context which is not created
3449 * in FTM mode. So skip the TX mgmt detach.
3450 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303451 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303452 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 goto end;
3454 }
3455#endif /* QCA_WIFI_FTM */
3456
3457 if (wma_handle->ack_work_ctx) {
3458 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303459 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 wma_handle->ack_work_ctx = NULL;
3461 }
3462
3463 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05303464 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003465 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 WMA_LOGE("Failed to destroy the log completion timer");
Govind Singhede435f2015-12-01 16:16:36 +05303467 /* clean up ll-queue for all vdev */
3468 for (i = 0; i < wma_handle->max_bssid; i++) {
3469 if (wma_handle->interfaces[i].handle &&
Mukul Sharmaf9047232017-03-02 16:58:56 +05303470 wma_is_vdev_up(i)) {
Leo Chang96464902016-10-28 11:10:54 -07003471 cdp_fc_vdev_flush(
3472 cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003473 wma_handle->
3474 interfaces[i].handle);
Govind Singhede435f2015-12-01 16:16:36 +05303475 }
3476 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303477 qdf_status = wma_tx_detach(wma_handle);
3478 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003479 WMA_LOGE("%s: Failed to deregister tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 goto end;
3481 }
3482
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483end:
3484 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303485 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486}
3487
3488/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 * wma_wmi_service_close() - close wma wmi service interface.
3490 * @cds_ctx: cds context
3491 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303492 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303494QDF_STATUS wma_wmi_service_close(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495{
3496 tp_wma_handle wma_handle;
3497 struct beacon_info *bcn;
3498 int i;
3499
3500 WMA_LOGD("%s: Enter", __func__);
3501
Anurag Chouhan6d760662016-02-20 16:05:43 +05303502 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503
3504 /* validate the wma_handle */
3505 if (NULL == wma_handle) {
3506 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303507 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 }
3509
3510 /* validate the wmi handle */
3511 if (NULL == wma_handle->wmi_handle) {
3512 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303513 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 }
3515
3516 /* dettach the wmi serice */
3517 WMA_LOGD("calling wmi_unified_detach");
3518 wmi_unified_detach(wma_handle->wmi_handle);
3519 wma_handle->wmi_handle = NULL;
3520
3521 for (i = 0; i < wma_handle->max_bssid; i++) {
3522 bcn = wma_handle->interfaces[i].beacon;
3523
3524 if (bcn) {
3525 if (bcn->dma_mapped)
Nirav Shahcbc6d722016-03-01 16:24:53 +05303526 qdf_nbuf_unmap_single(wma_handle->qdf_dev,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303527 bcn->buf, QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +05303528 qdf_nbuf_free(bcn->buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303529 qdf_mem_free(bcn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 wma_handle->interfaces[i].beacon = NULL;
3531 }
3532
3533 if (wma_handle->interfaces[i].handle) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303534 qdf_mem_free(wma_handle->interfaces[i].handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 wma_handle->interfaces[i].handle = NULL;
3536 }
Yue Ma664effc2016-01-12 18:43:54 -08003537
3538 if (wma_handle->interfaces[i].addBssStaContext) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303539 qdf_mem_free(wma_handle->
Yue Ma664effc2016-01-12 18:43:54 -08003540 interfaces[i].addBssStaContext);
3541 wma_handle->interfaces[i].addBssStaContext = NULL;
3542 }
3543
3544 if (wma_handle->interfaces[i].del_staself_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303545 qdf_mem_free(wma_handle->interfaces[i].del_staself_req);
Yue Ma664effc2016-01-12 18:43:54 -08003546 wma_handle->interfaces[i].del_staself_req = NULL;
3547 }
yeshwanth sriram guntuka8dd80382017-01-30 17:04:58 +05303548
3549 if (wma_handle->interfaces[i].stats_rsp) {
3550 qdf_mem_free(wma_handle->interfaces[i].stats_rsp);
3551 wma_handle->interfaces[i].stats_rsp = NULL;
3552 }
Abhishek Singh7e5e9342017-04-12 18:22:07 +05303553
3554 if (wma_handle->interfaces[i].psnr_req) {
3555 qdf_mem_free(wma_handle->
3556 interfaces[i].psnr_req);
3557 wma_handle->interfaces[i].psnr_req = NULL;
3558 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 }
3560
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303561 qdf_mem_free(wma_handle->interfaces);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 /* free the wma_handle */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303563 cds_free_context(wma_handle->cds_context, QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 wma_handle);
3565
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303566 qdf_mem_free(((p_cds_contextType) cds_ctx)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303568 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569}
3570
Xun Luoa858a472015-11-10 08:24:45 -08003571/**
3572 * wma_wmi_work_close() - close the work queue items associated with WMI
3573 * @cds_ctx: Pointer to cds context
3574 *
3575 * This function closes work queue items associated with WMI, but not fully
3576 * closes WMI service.
3577 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303578 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08003579 * proper error codes.
3580 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303581QDF_STATUS wma_wmi_work_close(void *cds_ctx)
Xun Luoa858a472015-11-10 08:24:45 -08003582{
3583 tp_wma_handle wma_handle;
3584
3585 WMA_LOGD("%s: Enter", __func__);
3586
Anurag Chouhan6d760662016-02-20 16:05:43 +05303587 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08003588
3589 /* validate the wma_handle */
3590 if (NULL == wma_handle) {
3591 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303592 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003593 }
3594
3595 /* validate the wmi handle */
3596 if (NULL == wma_handle->wmi_handle) {
3597 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303598 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08003599 }
3600
3601 /* remove the wmi work */
3602 WMA_LOGD("calling wmi_unified_remove_work");
3603 wmi_unified_remove_work(wma_handle->wmi_handle);
3604
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303605 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08003606}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607
Krunal Soni2e48d012016-05-02 16:55:26 -07003608/**
3609 * wma_cleanup_dbs_phy_caps() - release memory allocated for holding ext cap
3610 * @wma_handle: pointer to wma handle
3611 *
3612 * This function releases all the memory created for holding extended
3613 * capabilities per hardware mode and per PHY
3614 *
3615 * Return: void
3616 */
3617static void wma_cleanup_dbs_phy_caps(t_wma_handle *wma_handle)
3618{
3619 if (NULL == wma_handle) {
3620 WMA_LOGE("%s: Invalid wma handle", __func__);
3621 return;
3622 }
3623
3624 if (wma_handle->phy_caps.hw_mode_to_mac_cap_map) {
3625 qdf_mem_free(wma_handle->phy_caps.hw_mode_to_mac_cap_map);
3626 wma_handle->phy_caps.hw_mode_to_mac_cap_map = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003627 WMA_LOGD("%s: hw_mode_to_mac_cap_map freed", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07003628 }
3629
3630 if (wma_handle->phy_caps.each_hw_mode_cap) {
3631 qdf_mem_free(wma_handle->phy_caps.each_hw_mode_cap);
3632 wma_handle->phy_caps.each_hw_mode_cap = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003633 WMA_LOGD("%s: each_hw_mode_cap freed", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07003634 }
3635
3636 if (wma_handle->phy_caps.each_phy_cap_per_hwmode) {
3637 qdf_mem_free(wma_handle->phy_caps.each_phy_cap_per_hwmode);
3638 wma_handle->phy_caps.each_phy_cap_per_hwmode = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003639 WMA_LOGD("%s: each_phy_cap_per_hwmode freed", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07003640 }
3641
3642 if (wma_handle->phy_caps.each_phy_hal_reg_cap) {
3643 qdf_mem_free(wma_handle->phy_caps.each_phy_hal_reg_cap);
3644 wma_handle->phy_caps.each_phy_hal_reg_cap = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003645 WMA_LOGD("%s: each_phy_hal_reg_cap freed", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07003646 }
3647}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648
3649/**
3650 * wma_close() - wma close function.
3651 * cleanup resources attached with wma.
3652 * @cds_ctx: cds context
3653 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303654 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303656QDF_STATUS wma_close(void *cds_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657{
3658 tp_wma_handle wma_handle;
3659 uint32_t idx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303660 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Frank Liu00d73fe2017-05-19 22:11:28 +08003661 struct target_psoc_info *tgt_psoc_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662
3663 WMA_LOGD("%s: Enter", __func__);
3664
Anurag Chouhan6d760662016-02-20 16:05:43 +05303665 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666
3667 /* validate the wma_handle */
3668 if (NULL == wma_handle) {
3669 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303670 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 }
3672
3673 /* validate the wmi handle */
3674 if (NULL == wma_handle->wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003675 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303676 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 }
3678
3679 /* Free DBS list */
3680 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303681 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003683 WMA_LOGD("%s: DBS list is freed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 }
Krunal Soni2e48d012016-05-02 16:55:26 -07003685 wma_cleanup_dbs_phy_caps(wma_handle);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303686 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303688 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303690 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05303691 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
3692 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
3693 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
3694 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
3695 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
3696 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
3697 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 }
3699
3700 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303701 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
3702 if (qdf_status != QDF_STATUS_SUCCESS)
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003703 WMA_LOGE("%s: dbglog_deinit failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303705 /* close the qdf events */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303706 qdf_event_destroy(&wma_handle->wma_ready_event);
Anurag Chouhan210db072016-02-22 18:42:15 +05303707 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303708 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003709 WMA_LOGE("%s: Failed to destroy service ready ext event timer",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303710 __func__);
3711
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303712 qdf_event_destroy(&wma_handle->target_suspend);
3713 qdf_event_destroy(&wma_handle->wma_resume_event);
3714 qdf_event_destroy(&wma_handle->runtime_suspend);
3715 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08003716 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
3717 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08003718 wma_cleanup_vdev_resp_queue(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303720 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
3721 qdf_runtime_lock_deinit(wma_handle->wmi_cmd_rsp_runtime_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 for (idx = 0; idx < wma_handle->num_mem_chunks; ++idx) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303723 qdf_mem_free_consistent(wma_handle->qdf_dev,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303724 wma_handle->qdf_dev->dev,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003725 wma_handle->mem_chunks[idx].len,
3726 wma_handle->mem_chunks[idx].vaddr,
3727 wma_handle->mem_chunks[idx].paddr,
3728 qdf_get_dma_mem_context(
3729 (&(wma_handle->mem_chunks[idx])),
3730 memctx));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 }
3732
3733#if defined(QCA_WIFI_FTM)
3734 /* Detach UTF and unregister the handler */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303735 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736 wma_utf_detach(wma_handle);
3737#endif /* QCA_WIFI_FTM */
3738
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303740 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741 wma_handle->pGetRssiReq = NULL;
3742 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07003743
yeshwanth sriram guntuka584c2332017-07-29 12:50:25 +05303744 wma_unified_radio_tx_mem_free(wma_handle);
Srinivas Girigowdaad874a82016-10-25 14:08:00 -07003745
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07003746 wma_ndp_unregister_all_event_handlers(wma_handle);
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -07003747 if (wma_handle->pdev) {
3748 wlan_objmgr_pdev_release_ref(wma_handle->pdev,
3749 WLAN_LEGACY_WMA_ID);
3750 wma_handle->pdev = NULL;
3751 }
Frank Liu00d73fe2017-05-19 22:11:28 +08003752
3753 tgt_psoc_info = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
3754 if (tgt_psoc_info) {
3755 qdf_mem_free(tgt_psoc_info);
3756 wlan_psoc_set_tgt_if_handle(wma_handle->psoc, NULL);
3757 }
3758
Mukul Sharma6411bb82017-03-01 15:57:07 +05303759 pmo_unregister_pause_bitmap_notifier(wma_handle->psoc,
3760 wma_vdev_update_pause_bitmap);
3761 pmo_unregister_get_pause_bitmap(wma_handle->psoc,
3762 wma_vdev_get_pause_bitmap);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303763 pmo_unregister_is_device_in_low_pwr_mode(wma_handle->psoc,
3764 wma_vdev_is_device_in_low_pwr_mode);
Mukul Sharma6411bb82017-03-01 15:57:07 +05303765
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303766 wlan_objmgr_psoc_release_ref(wma_handle->psoc, WLAN_LEGACY_WMA_ID);
3767 wma_handle->psoc = NULL;
3768 target_if_close();
3769 wma_target_if_close(wma_handle);
Mukul Sharma6411bb82017-03-01 15:57:07 +05303770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303772 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003773}
3774
3775/**
3776 * wma_update_fw_config() - update fw configuration
3777 * @wma_handle: wma handle
3778 * @tgt_cap: target capabality
3779 *
3780 * Return: none
3781 */
3782static void wma_update_fw_config(tp_wma_handle wma_handle,
3783 struct wma_target_cap *tgt_cap)
3784{
3785 /*
3786 * tgt_cap contains default target resource configuration
3787 * which can be modified here, if required
3788 */
3789 /* Override the no. of max fragments as per platform configuration */
3790 tgt_cap->wlan_resource_config.max_frag_entries =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303791 QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 wma_handle->max_frag_entry);
3793 wma_handle->max_frag_entry =
3794 tgt_cap->wlan_resource_config.max_frag_entries;
Arun Khandavalli3dd06de2016-08-17 10:20:29 +05303795
3796 /* Update no. of maxWoWFilters depending on BPF service */
3797 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
3798 WMI_SERVICE_BPF_OFFLOAD))
3799 tgt_cap->wlan_resource_config.num_wow_filters =
Arun Khandavallid454d422016-08-17 12:47:05 +05303800 WMA_STA_WOW_DEFAULT_PTRN_MAX;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801}
3802
3803/**
3804 * wma_alloc_host_mem_chunk() - allocate host memory
3805 * @wma_handle: wma handle
3806 * @req_id: request id
3807 * @idx: index
3808 * @num_units: number of units
3809 * @unit_len: unit length
3810 *
3811 * allocate a chunk of memory at the index indicated and
3812 * if allocation fail allocate smallest size possiblr and
3813 * return number of units allocated.
3814 *
3815 * Return: number of units or 0 for error.
3816 */
3817static uint32_t wma_alloc_host_mem_chunk(tp_wma_handle wma_handle,
3818 uint32_t req_id, uint32_t idx,
3819 uint32_t num_units, uint32_t unit_len)
3820{
Anurag Chouhan6d760662016-02-20 16:05:43 +05303821 qdf_dma_addr_t paddr;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003822
3823 if (!num_units || !unit_len)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825 wma_handle->mem_chunks[idx].vaddr = NULL;
3826 /** reduce the requested allocation by half until allocation succeeds */
3827 while (wma_handle->mem_chunks[idx].vaddr == NULL && num_units) {
3828 wma_handle->mem_chunks[idx].vaddr =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303829 qdf_mem_alloc_consistent(wma_handle->qdf_dev,
3830 wma_handle->qdf_dev->dev,
3831 num_units * unit_len,
3832 &paddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833 if (wma_handle->mem_chunks[idx].vaddr == NULL) {
3834 num_units = (num_units >> 1);/* reduce length by half */
3835 } else {
3836 wma_handle->mem_chunks[idx].paddr = paddr;
3837 wma_handle->mem_chunks[idx].len = num_units * unit_len;
3838 wma_handle->mem_chunks[idx].req_id = req_id;
3839 }
3840 }
3841 return num_units;
3842}
3843
3844#define HOST_MEM_SIZE_UNIT 4
3845/**
3846 * wma_alloc_host_mem() - allocate amount of memory requested by FW.
3847 * @wma_handle: wma handle
3848 * @req_id: request id
3849 * @num_units: number of units
3850 * @unit_len: unit length
3851 *
3852 * Return: none
3853 */
3854static void wma_alloc_host_mem(tp_wma_handle wma_handle, uint32_t req_id,
3855 uint32_t num_units, uint32_t unit_len)
3856{
3857 uint32_t remaining_units, allocated_units, idx;
3858
3859 /* adjust the length to nearest multiple of unit size */
3860 unit_len = (unit_len + (HOST_MEM_SIZE_UNIT - 1)) &
3861 (~(HOST_MEM_SIZE_UNIT - 1));
3862 idx = wma_handle->num_mem_chunks;
3863 remaining_units = num_units;
3864 while (remaining_units) {
3865 allocated_units = wma_alloc_host_mem_chunk(wma_handle, req_id,
3866 idx, remaining_units,
3867 unit_len);
3868 if (allocated_units == 0) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003869 WMA_LOGE("FAILED TO ALLOCATED memory unit len %d units requested %d units allocated %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 unit_len, num_units,
3871 (num_units - remaining_units));
3872 wma_handle->num_mem_chunks = idx;
3873 break;
3874 }
3875 remaining_units -= allocated_units;
3876 ++idx;
3877 if (idx == MAX_MEM_CHUNKS) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003878 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 -08003879 num_units, unit_len,
3880 (num_units - remaining_units));
3881 wma_handle->num_mem_chunks = idx;
3882 break;
3883 }
3884 }
3885 wma_handle->num_mem_chunks = idx;
3886}
3887
3888/**
Yun Parkb4f591d2017-03-29 15:51:01 -07003889 * wma_set_tx_partition_base() - set TX MSDU ID partition base for IPA
3890 * @value: TX MSDU ID partition base
3891 *
3892 * Return: none
3893 */
3894#ifdef IPA_OFFLOAD
3895static void wma_set_tx_partition_base(uint32_t value)
3896{
3897 cdp_ipa_set_uc_tx_partition_base(
3898 cds_get_context(QDF_MODULE_ID_SOC),
3899 (struct cdp_cfg *)cds_get_context(QDF_MODULE_ID_CFG),
3900 value);
3901 WMA_LOGD("%s: TX_MSDU_ID_PARTITION=%d", __func__,
3902 value);
3903}
3904#else
3905static void wma_set_tx_partition_base(uint32_t value)
3906{
3907}
3908#endif
3909
3910/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911 * wma_update_target_services() - update target services from wma handle
3912 * @wh: wma handle
3913 * @cfg: target services
3914 *
3915 * Return: none
3916 */
3917static inline void wma_update_target_services(tp_wma_handle wh,
3918 struct wma_tgt_services *cfg)
3919{
3920 /* STA power save */
3921 cfg->sta_power_save = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3922 WMI_SERVICE_STA_PWRSAVE);
3923
3924 /* Enable UAPSD */
3925 cfg->uapsd = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3926 WMI_SERVICE_AP_UAPSD);
3927
3928 /* Update AP DFS service */
3929 cfg->ap_dfs = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3930 WMI_SERVICE_AP_DFS);
3931
3932 /* Enable 11AC */
3933 cfg->en_11ac = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3934 WMI_SERVICE_11AC);
3935 if (cfg->en_11ac)
3936 g_fw_wlan_feat_caps |= (1 << DOT11AC);
3937
3938 /* Proactive ARP response */
3939 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
3940
3941 /* Enable WOW */
3942 g_fw_wlan_feat_caps |= (1 << WOW);
3943
3944 /* ARP offload */
3945 cfg->arp_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3946 WMI_SERVICE_ARPNS_OFFLOAD);
3947
3948 /* Adaptive early-rx */
3949 cfg->early_rx = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3950 WMI_SERVICE_EARLY_RX);
3951#ifdef FEATURE_WLAN_SCAN_PNO
3952 /* PNO offload */
3953 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NLO))
3954 cfg->pno_offload = true;
3955#endif /* FEATURE_WLAN_SCAN_PNO */
3956
3957#ifdef FEATURE_WLAN_EXTSCAN
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003958 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_EXTSCAN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003960#endif /* FEATURE_WLAN_EXTSCAN */
3961 cfg->lte_coex_ant_share = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3962 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT);
3963#ifdef FEATURE_WLAN_TDLS
3964 /* Enable TDLS */
3965 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_TDLS)) {
3966 cfg->en_tdls = 1;
3967 g_fw_wlan_feat_caps |= (1 << TDLS);
3968 }
3969 /* Enable advanced TDLS features */
3970 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3971 WMI_SERVICE_TDLS_OFFCHAN)) {
3972 cfg->en_tdls_offchan = 1;
3973 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
3974 }
3975
3976 cfg->en_tdls_uapsd_buf_sta =
3977 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3978 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA);
3979 cfg->en_tdls_uapsd_sleep_sta =
3980 WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
3981 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA);
3982#endif /* FEATURE_WLAN_TDLS */
3983 if (WMI_SERVICE_IS_ENABLED
3984 (wh->wmi_service_bitmap, WMI_SERVICE_BEACON_OFFLOAD))
3985 cfg->beacon_offload = true;
mukul sharma72c8b222015-09-04 17:02:01 +05303986 if (WMI_SERVICE_IS_ENABLED
3987 (wh->wmi_service_bitmap, WMI_SERVICE_STA_PMF_OFFLOAD))
3988 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3990 /* Enable Roam Offload */
3991 cfg->en_roam_offload = WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003992 WMI_SERVICE_ROAM_HO_OFFLOAD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3994#ifdef WLAN_FEATURE_NAN
3995 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_NAN))
3996 g_fw_wlan_feat_caps |= (1 << NAN);
3997#endif /* WLAN_FEATURE_NAN */
3998
3999 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap, WMI_SERVICE_RTT))
4000 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07004001
4002 if (WMI_SERVICE_IS_ENABLED(wh->wmi_service_bitmap,
4003 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT)) {
Yun Parkb4f591d2017-03-29 15:51:01 -07004004 wma_set_tx_partition_base(HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004005 } else {
Yun Parkb4f591d2017-03-29 15:51:01 -07004006 wma_set_tx_partition_base(HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004007 }
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004008
4009 wma_he_update_tgt_services(wh, cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010}
4011
4012/**
4013 * wma_update_target_ht_cap() - update ht capabality from wma handle
4014 * @wh: wma handle
4015 * @cfg: ht capabality
4016 *
4017 * Return: none
4018 */
4019static inline void wma_update_target_ht_cap(tp_wma_handle wh,
4020 struct wma_tgt_ht_cap *cfg)
4021{
4022 /* RX STBC */
4023 cfg->ht_rx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_RX_STBC);
4024
4025 /* TX STBC */
4026 cfg->ht_tx_stbc = !!(wh->ht_cap_info & WMI_HT_CAP_TX_STBC);
4027
4028 /* MPDU density */
4029 cfg->mpdu_density = wh->ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
4030
4031 /* HT RX LDPC */
4032 cfg->ht_rx_ldpc = !!(wh->ht_cap_info & WMI_HT_CAP_LDPC);
4033
4034 /* HT SGI */
4035 cfg->ht_sgi_20 = !!(wh->ht_cap_info & WMI_HT_CAP_HT20_SGI);
4036
4037 cfg->ht_sgi_40 = !!(wh->ht_cap_info & WMI_HT_CAP_HT40_SGI);
4038
4039 /* RF chains */
4040 cfg->num_rf_chains = wh->num_rf_chains;
4041
Jeff Johnson3fd21822016-11-08 11:30:37 -08004042 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n"
4043 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
4044 "ht_sgi_40 - %d num_rf_chains - %d", __func__, wh->ht_cap_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
4046 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
4047 cfg->num_rf_chains);
4048
4049}
4050
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051/**
4052 * wma_update_target_vht_cap() - update vht capabality from wma handle
4053 * @wh: wma handle
4054 * @cfg: vht capabality
4055 *
4056 * Return: none
4057 */
4058static inline void wma_update_target_vht_cap(tp_wma_handle wh,
4059 struct wma_tgt_vht_cap *cfg)
4060{
4061
4062 if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4063 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4064 else if (wh->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4065 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4066 else
4067 cfg->vht_max_mpdu = 0;
4068
4069
4070 if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
4071 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4072 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
4073 } else if (wh->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ)
4074 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
4075 else
4076 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4077
4078 cfg->vht_rx_ldpc = wh->vht_cap_info & WMI_VHT_CAP_RX_LDPC;
4079
4080 cfg->vht_short_gi_80 = wh->vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
4081 cfg->vht_short_gi_160 = wh->vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
4082
4083 cfg->vht_tx_stbc = wh->vht_cap_info & WMI_VHT_CAP_TX_STBC;
4084
4085 cfg->vht_rx_stbc = (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
4086 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004087 (wh->vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088
4089 cfg->vht_max_ampdu_len_exp = (wh->vht_cap_info &
4090 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
4091 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4092
4093 cfg->vht_su_bformer = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
4094
4095 cfg->vht_su_bformee = wh->vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
4096
4097 cfg->vht_mu_bformer = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
4098
4099 cfg->vht_mu_bformee = wh->vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
4100
4101 cfg->vht_txop_ps = wh->vht_cap_info & WMI_VHT_CAP_TXOP_PS;
4102
Jeff Johnson3fd21822016-11-08 11:30:37 -08004103 WMA_LOGD("%s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
4104 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
4105 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
4107 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
4108 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
4109 cfg->vht_max_ampdu_len_exp);
4110}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111
4112/**
Krunal Soniaa664da2016-06-15 23:46:40 -07004113 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
4114 * @wma_handle: pointer to wma_handle
4115 * @ht_cap: given pointer to HT caps which needs to be updated
4116 * @tx_chain: given tx chainmask value
4117 * @rx_chain: given rx chainmask value
4118 * @value: new HT cap info provided in form of bitmask
4119 *
4120 * This function takes the value provided in form of bitmask and decodes
4121 * it. After decoding, what ever value it gets, it takes the union(max) or
4122 * intersection(min) with previously derived values.
4123 *
4124 * Return: none
4125 *
4126 */
4127static void wma_derive_ext_ht_cap(tp_wma_handle wma_handle,
4128 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
4129 uint32_t tx_chain, uint32_t rx_chain)
4130{
4131 struct wma_tgt_ht_cap tmp = {0};
4132
4133 if (NULL == wma_handle || NULL == ht_cap)
4134 return;
4135
Ankit Guptaa5076012016-09-14 11:32:19 -07004136 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07004137 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
4138 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
4139 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
4140 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
4141 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
4142 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
4143 ht_cap->num_rf_chains =
4144 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
4145 wma_get_num_of_setbits_from_bitmask(rx_chain));
4146 } else {
4147 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
4148 (!!(value & WMI_HT_CAP_RX_STBC)));
4149 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
4150 (!!(value & WMI_HT_CAP_TX_STBC)));
4151 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
4152 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
4153 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
4154 (!!(value & WMI_HT_CAP_RX_LDPC)));
4155 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
4156 (!!(value & WMI_HT_CAP_HT20_SGI)));
4157 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
4158 (!!(value & WMI_HT_CAP_HT40_SGI)));
4159 ht_cap->num_rf_chains =
4160 QDF_MAX(ht_cap->num_rf_chains,
4161 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
4162 tx_chain),
4163 wma_get_num_of_setbits_from_bitmask(
4164 rx_chain)));
4165 }
4166}
4167
4168/**
4169 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
4170 * @wma_handle: pointer to wma_handle
4171 * @ht_cap: HT cap structure to be filled
4172 *
4173 * This function loop through each hardware mode and for each hardware mode
4174 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
4175 * HT caps and derives the final cap.
4176 *
4177 * Return: none
4178 *
4179 */
4180static void wma_update_target_ext_ht_cap(tp_wma_handle wma_handle,
4181 struct wma_tgt_ht_cap *ht_cap)
4182{
4183 int i, j = 0, max_mac;
4184 uint32_t ht_2g, ht_5g;
4185 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
4186 struct extended_caps *phy_caps;
4187 WMI_MAC_PHY_CAPABILITIES *mac_cap;
4188
4189 /*
4190 * for legacy device extended cap might not even come, so in that case
4191 * don't overwrite legacy values
4192 */
4193 if (!wma_handle ||
4194 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004195 WMA_LOGD("%s: No extended HT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07004196 return;
4197 }
4198
4199 phy_caps = &wma_handle->phy_caps;
4200 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
4201 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
4202 max_mac = j + 2;
4203 else
4204 max_mac = j + 1;
4205 for ( ; j < max_mac; j++) {
4206 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
4207 ht_2g = mac_cap->ht_cap_info_2G;
4208 ht_5g = mac_cap->ht_cap_info_5G;
4209 if (ht_2g)
4210 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
4211 ht_2g, mac_cap->tx_chain_mask_2G,
4212 mac_cap->rx_chain_mask_2G);
4213 if (ht_5g)
4214 wma_derive_ext_ht_cap(wma_handle, &tmp_ht_cap,
4215 ht_5g, mac_cap->tx_chain_mask_5G,
4216 mac_cap->rx_chain_mask_5G);
4217 }
4218 }
4219
Ankit Guptaa5076012016-09-14 11:32:19 -07004220 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004221 sizeof(struct wma_tgt_ht_cap))) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004222 qdf_mem_copy(ht_cap, &tmp_ht_cap,
4223 sizeof(struct wma_tgt_ht_cap));
Krunal Soniaa664da2016-06-15 23:46:40 -07004224 }
4225
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004226 WMA_LOGD("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08004227 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
4228 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07004229 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
4230 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
4231 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
4232 ht_cap->num_rf_chains);
4233}
4234
4235/**
4236 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
4237 * @wma_handle: pointer to wma_handle
4238 * @vht_cap: pointer to given VHT caps to be filled
4239 * @value: new VHT cap info provided in form of bitmask
4240 *
4241 * This function takes the value provided in form of bitmask and decodes
4242 * it. After decoding, what ever value it gets, it takes the union(max) or
4243 * intersection(min) with previously derived values.
4244 *
4245 * Return: none
4246 *
4247 */
4248static void wma_derive_ext_vht_cap(t_wma_handle *wma_handle,
4249 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
4250{
4251 struct wma_tgt_vht_cap tmp_cap = {0};
4252 uint32_t tmp = 0;
4253
4254 if (NULL == wma_handle || NULL == vht_cap)
4255 return;
4256
Ankit Guptaa5076012016-09-14 11:32:19 -07004257 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004258 sizeof(struct wma_tgt_vht_cap))) {
4259 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4260 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4261 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4262 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4263 else
4264 vht_cap->vht_max_mpdu = 0;
4265
4266 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
4267 vht_cap->supp_chan_width =
4268 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4269 vht_cap->supp_chan_width |=
4270 1 << eHT_CHANNEL_WIDTH_160MHZ;
4271 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4272 vht_cap->supp_chan_width =
4273 1 << eHT_CHANNEL_WIDTH_160MHZ;
4274 } else {
4275 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4276 }
4277 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
4278 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
4279 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
4280 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
4281 vht_cap->vht_rx_stbc =
4282 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4283 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4284 (value & WMI_VHT_CAP_RX_STBC_3SS);
4285 vht_cap->vht_max_ampdu_len_exp =
4286 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4287 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4288 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
4289 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
4290 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
4291 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
4292 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
4293 } else {
4294 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
4295 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
4296 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
4297 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4298 else
4299 tmp = 0;
4300 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
4301
4302 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
4303 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
4304 (1 << eHT_CHANNEL_WIDTH_160MHZ);
4305 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
4306 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
4307 } else {
4308 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
4309 }
4310 vht_cap->supp_chan_width =
4311 QDF_MAX(vht_cap->supp_chan_width, tmp);
4312 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
4313 value & WMI_VHT_CAP_RX_LDPC);
4314 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
4315 value & WMI_VHT_CAP_SGI_80MHZ);
4316 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
4317 value & WMI_VHT_CAP_SGI_160MHZ);
4318 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
4319 value & WMI_VHT_CAP_TX_STBC);
4320 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
4321 (value & WMI_VHT_CAP_RX_STBC_1SS) |
4322 (value & WMI_VHT_CAP_RX_STBC_2SS) |
4323 (value & WMI_VHT_CAP_RX_STBC_3SS));
4324 vht_cap->vht_max_ampdu_len_exp =
4325 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
4326 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
4327 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
4328 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
4329 value & WMI_VHT_CAP_SU_BFORMER);
4330 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
4331 value & WMI_VHT_CAP_SU_BFORMEE);
4332 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
4333 value & WMI_VHT_CAP_MU_BFORMER);
4334 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
4335 value & WMI_VHT_CAP_MU_BFORMEE);
4336 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
4337 value & WMI_VHT_CAP_TXOP_PS);
4338 }
4339}
4340
4341/**
4342 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
4343 * @wma_handle: pointer to wma_handle
4344 * @vht_cap: VHT cap structure to be filled
4345 *
4346 * This function loop through each hardware mode and for each hardware mode
4347 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
4348 * VHT caps and derives the final cap.
4349 *
4350 * Return: none
4351 *
4352 */
4353static void wma_update_target_ext_vht_cap(t_wma_handle *wma_handle,
4354 struct wma_tgt_vht_cap *vht_cap)
4355{
4356 int i, j = 0, max_mac;
4357 uint32_t vht_cap_info_2g, vht_cap_info_5g;
4358 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
4359 struct extended_caps *phy_caps;
4360 WMI_MAC_PHY_CAPABILITIES *mac_cap;
4361
4362 /*
4363 * for legacy device extended cap might not even come, so in that case
4364 * don't overwrite legacy values
4365 */
4366 if (!wma_handle ||
4367 (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004368 WMA_LOGD("%s: No extended VHT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07004369 return;
4370 }
4371
4372 phy_caps = &wma_handle->phy_caps;
4373 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
4374 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2)
4375 max_mac = j + 2;
4376 else
4377 max_mac = j + 1;
4378 for ( ; j < max_mac; j++) {
4379 mac_cap = &phy_caps->each_phy_cap_per_hwmode[j];
4380 vht_cap_info_2g = mac_cap->vht_cap_info_2G;
4381 vht_cap_info_5g = mac_cap->vht_cap_info_5G;
4382 if (vht_cap_info_2g)
4383 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4384 vht_cap_info_2g);
4385 if (vht_cap_info_5g)
4386 wma_derive_ext_vht_cap(wma_handle, &tmp_vht_cap,
4387 vht_cap_info_5g);
4388 }
4389 }
4390
Ankit Guptaa5076012016-09-14 11:32:19 -07004391 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07004392 sizeof(struct wma_tgt_vht_cap))) {
4393 qdf_mem_copy(vht_cap, &tmp_vht_cap,
4394 sizeof(struct wma_tgt_vht_cap));
4395 }
4396
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004397 WMA_LOGD("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08004398 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
4399 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07004400 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
4401 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
4402 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
4403 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
4404 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
4405}
4406
4407/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304408 * wma_update_ra_rate_limit() - update wma config
4409 * @wma_handle: wma handle
4410 * @cfg: target config
4411 *
4412 * Return: none
4413 */
4414#ifdef FEATURE_WLAN_RA_FILTERING
4415static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4416 struct wma_tgt_cfg *cfg)
4417{
4418 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
4419}
4420#else
4421static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
4422 struct wma_tgt_cfg *cfg)
4423{
4424}
4425#endif
4426
4427/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 * wma_update_hdd_cfg() - update HDD config
4429 * @wma_handle: wma handle
4430 *
4431 * Return: none
4432 */
4433static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
4434{
4435 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304436 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304438 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07004439
4440 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
4442 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
4443
4444 switch (wma_handle->phy_capability) {
4445 case WMI_11G_CAPABILITY:
4446 case WMI_11NG_CAPABILITY:
4447 tgt_cfg.band_cap = eCSR_BAND_24;
4448 break;
4449 case WMI_11A_CAPABILITY:
4450 case WMI_11NA_CAPABILITY:
4451 case WMI_11AC_CAPABILITY:
4452 tgt_cfg.band_cap = eCSR_BAND_5G;
4453 break;
4454 case WMI_11AG_CAPABILITY:
4455 case WMI_11NAG_CAPABILITY:
4456 default:
4457 tgt_cfg.band_cap = eCSR_BAND_ALL;
4458 }
4459
4460 tgt_cfg.max_intf_count = wma_handle->wlan_resource_config.num_vdevs;
4461
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304462 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 ATH_MAC_LEN);
4464
4465 wma_update_target_services(wma_handle, &tgt_cfg.services);
4466 wma_update_target_ht_cap(wma_handle, &tgt_cfg.ht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 wma_update_target_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07004468 /*
4469 * This will overwrite the structure filled by wma_update_target_ht_cap
4470 * and wma_update_target_vht_cap APIs.
4471 */
4472 wma_update_target_ext_ht_cap(wma_handle, &tgt_cfg.ht_cap);
4473 wma_update_target_ext_vht_cap(wma_handle, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004474
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004475 wma_update_target_ext_he_cap(wma_handle, &tgt_cfg);
4476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 tgt_cfg.target_fw_version = wma_handle->target_fw_version;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07004478 tgt_cfg.target_fw_vers_ext = wma_handle->target_fw_vers_ext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479#ifdef WLAN_FEATURE_LPSS
4480 tgt_cfg.lpss_support = wma_handle->lpss_support;
4481#endif /* WLAN_FEATURE_LPSS */
4482 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Rajeev Kumare5a16822016-07-27 13:11:42 -07004483 tgt_cfg.bpf_enabled = wma_handle->bpf_enabled;
Arif Hussain759a0232017-03-20 13:17:18 -07004484 tgt_cfg.dfs_cac_offload = wma_handle->dfs_cac_offload;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304485 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004486 tgt_cfg.fine_time_measurement_cap =
4487 wma_handle->fine_time_measurement_cap;
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05304488 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
4489 - WMI_TLV_HEADROOM;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08004490 wma_setup_egap_support(&tgt_cfg, wma_handle);
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05304491 tgt_cfg.tx_bfee_8ss_enabled = wma_handle->tx_bfee_8ss_enabled;
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07004492 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07004493 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494}
4495
4496/**
4497 * wma_setup_wmi_init_msg() - fill wmi init message buffer
4498 * @wma_handle: wma handle
4499 * @ev: ready event fixed params
4500 * @param_buf: redy event TLVs
4501 * @len: buffer length
4502 *
4503 * Return: wmi buffer or NULL for error
4504 */
Govind Singhf25a0f12016-03-08 16:09:48 +05304505static int wma_setup_wmi_init_msg(tp_wma_handle wma_handle,
4506 wmi_service_ready_event_fixed_param *ev,
4507 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 wlan_host_mem_req *ev_mem_reqs;
4510 wmi_abi_version my_vers;
Govind Singhf25a0f12016-03-08 16:09:48 +05304511 wmi_abi_version host_abi_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 int num_whitelist;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 uint16_t idx;
4514 uint32_t num_units;
4515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516 ev_mem_reqs = param_buf->mem_reqs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517
4518 /* allocate memory requested by FW */
4519 if (ev->num_mem_reqs > WMI_MAX_MEM_REQS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304520 QDF_ASSERT(0);
Govind Singhf25a0f12016-03-08 16:09:48 +05304521 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 }
4523
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 for (idx = 0; idx < ev->num_mem_reqs; ++idx) {
4525 num_units = ev_mem_reqs[idx].num_units;
4526 if (ev_mem_reqs[idx].num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4527 /*
4528 * number of units to allocate is number
4529 * of peers, 1 extra for self peer on
4530 * target. this needs to be fied, host
4531 * and target can get out of sync
4532 */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004533 num_units = wma_handle->wlan_resource_config.num_peers +
4534 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004536 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 -08004537 idx, ev_mem_reqs[idx].req_id,
4538 ev_mem_reqs[idx].num_units,
4539 ev_mem_reqs[idx].num_unit_info,
4540 ev_mem_reqs[idx].unit_size, num_units);
4541 wma_alloc_host_mem(wma_handle, ev_mem_reqs[idx].req_id,
4542 num_units, ev_mem_reqs[idx].unit_size);
4543 }
Govind Singhf25a0f12016-03-08 16:09:48 +05304544
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304545 qdf_mem_copy(&wma_handle->target_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546 &param_buf->fixed_param->fw_abi_vers,
4547 sizeof(wmi_abi_version));
4548 num_whitelist = sizeof(version_whitelist) /
4549 sizeof(wmi_whitelist_version_info);
4550 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
4551 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
4552 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
4553 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
4554 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
4555 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
4556
4557 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
4558 &my_vers,
4559 &param_buf->fixed_param->fw_abi_vers,
Govind Singhf25a0f12016-03-08 16:09:48 +05304560 &host_abi_vers);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561
Govind Singhf25a0f12016-03-08 16:09:48 +05304562 qdf_mem_copy(&wma_handle->final_abi_vers, &host_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 sizeof(wmi_abi_version));
Govind Singhf25a0f12016-03-08 16:09:48 +05304564
4565 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566}
4567
4568/**
4569 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
4570 * @wma_handle: WMA handle
4571 *
4572 * Prints the DBS HW modes sent by the FW as part
4573 * of WMI ready event
4574 *
4575 * Return: None
4576 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004577static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578{
4579 uint32_t i, param;
4580
4581 if (!wma_handle) {
4582 WMA_LOGE("%s: Invalid WMA handle", __func__);
4583 return;
4584 }
4585
4586 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
4587 param = wma_handle->hw_mode.hw_mode_list[i];
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004588 WMA_LOGD("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304590 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
4591 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
4592 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004593 WMA_LOGD("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304595 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
4596 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
4597 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004598 WMA_LOGD("%s:[%d] DBS:%d SBS:%d", __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05304599 WMA_HW_MODE_DBS_MODE_GET(param),
4600 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004602 policy_mgr_dump_dbs_hw_mode(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603}
4604
4605/**
4606 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
4607 * @wma_handle: WMA handle
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304608 * @scan_config: Scam mode configuration
4609 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 *
4611 * Enables all the valid bits of concurrent_scan_config_bits and
4612 * fw_mode_config_bits.
4613 *
4614 * Return: None
4615 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07004616static void wma_init_scan_fw_mode_config(tp_wma_handle wma_handle,
4617 uint32_t scan_config,
4618 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 WMA_LOGD("%s: Enter", __func__);
4621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 if (!wma_handle) {
4623 WMA_LOGE("%s: Invalid WMA handle", __func__);
4624 return;
4625 }
4626
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004627 policy_mgr_init_dbs_config(wma_handle->psoc, scan_config, fw_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628}
4629
4630/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304631 * wma_update_ra_limit() - update ra limit based on bpf filter
4632 * enabled or not
4633 * @handle: wma handle
4634 *
4635 * Return: none
4636 */
4637#ifdef FEATURE_WLAN_RA_FILTERING
4638static void wma_update_ra_limit(tp_wma_handle wma_handle)
4639{
4640 if (wma_handle->bpf_enabled)
4641 wma_handle->IsRArateLimitEnabled = false;
4642}
4643#else
4644static void wma_update_ra__limit(tp_wma_handle handle)
4645{
4646}
4647#endif
4648
4649/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 * wma_rx_service_ready_event() - event handler to process
4651 * wmi rx sevice ready event.
4652 * @handle: wma handle
4653 * @cmd_param_info: command params info
4654 *
4655 * Return: none
4656 */
Govind Singhd76a5b02016-03-08 15:12:14 +05304657int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
4658 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 tp_wma_handle wma_handle = (tp_wma_handle) handle;
4661 struct wma_target_cap target_cap;
4662 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
4663 wmi_service_ready_event_fixed_param *ev;
4664 int status;
4665 uint32_t *ev_wlan_dbs_hw_mode_list;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304666 QDF_STATUS ret;
Leo Chang96464902016-10-28 11:10:54 -07004667 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668
4669 WMA_LOGD("%s: Enter", __func__);
4670
4671 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
4672 if (!(handle && param_buf)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004673 WMA_LOGE("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304674 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 }
4676
4677 ev = param_buf->fixed_param;
4678 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004679 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05304680 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 }
4682
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08004683 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684
4685 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
4686 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
4687 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304688 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004689 wma_handle->num_dbs_hw_modes);
4690 if (!wma_handle->hw_mode.hw_mode_list) {
4691 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
4692 /* Continuing with the rest of the processing */
4693 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304694 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 ev_wlan_dbs_hw_mode_list,
4696 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
4697 wma_handle->num_dbs_hw_modes));
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004698 policy_mgr_init_dbs_hw_mode(wma_handle->psoc,
4699 ev->num_dbs_hw_modes, ev_wlan_dbs_hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 wma_dump_dbs_hw_mode(wma_handle);
4701
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304702 /* Initializes the fw_mode and scan_config to zero.
4703 * If ext service ready event is present it will set
4704 * the actual values of these two params.
4705 * This is to ensure that no garbage values would be
4706 * present in the absence of ext service ready event.
4707 */
4708 wma_init_scan_fw_mode_config(wma_handle, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709
4710 wma_handle->phy_capability = ev->phy_capability;
4711 wma_handle->max_frag_entry = ev->max_frag_entry;
4712 wma_handle->num_rf_chains = ev->num_rf_chains;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304713 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 sizeof(HAL_REG_CAPABILITIES));
4715 wma_handle->ht_cap_info = ev->ht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 wma_handle->vht_cap_info = ev->vht_cap_info;
4717 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 wma_handle->num_rf_chains = ev->num_rf_chains;
4719
4720 wma_handle->target_fw_version = ev->fw_build_vers;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 wma_handle->new_hw_mode_index = ev->default_dbs_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004722 policy_mgr_update_new_hw_mode_index(wma_handle->psoc,
4723 ev->default_dbs_hw_mode_index);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08004724 wma_handle->fine_time_measurement_cap = ev->wmi_fw_sub_feat_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725
4726 WMA_LOGD("%s: Firmware default hw mode index : %d",
4727 __func__, ev->default_dbs_hw_mode_index);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004728 WMA_LOGI("%s: Firmware build version : %08x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 __func__, ev->fw_build_vers);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004730 WMA_LOGD("FW fine time meas cap: 0x%x", ev->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731
4732 if (ev->hw_bd_id) {
4733 wma_handle->hw_bd_id = ev->hw_bd_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304734 qdf_mem_copy(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004735 ev->hw_bd_info, sizeof(ev->hw_bd_info));
4736
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004737 WMA_LOGI("%s: Board version: %x.%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004738 __func__,
4739 wma_handle->hw_bd_info[0], wma_handle->hw_bd_info[1]);
4740 } else {
4741 wma_handle->hw_bd_id = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304742 qdf_mem_zero(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743 sizeof(wma_handle->hw_bd_info));
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004744 WMA_LOGW("%s: Board version is unknown!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 }
4746
4747 /* TODO: Recheck below line to dump service ready event */
4748 /* dbg_print_wmi_service_11ac(ev); */
4749
4750 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304751 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752 param_buf->wmi_service_bitmap,
4753 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05304754
Leo Chang96464902016-10-28 11:10:54 -07004755 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(soc,
Nirav Shah22bf44d2015-12-10 15:39:48 +05304756 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4757 WMI_SERVICE_MGMT_TX_WMI));
Leo Chang96464902016-10-28 11:10:54 -07004758 cdp_set_desc_global_pool_size(soc, ev->num_msdu_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 /* SWBA event handler for beacon transmission */
4760 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4761 WMI_HOST_SWBA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304762 wma_beacon_swba_handler,
4763 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 if (status) {
4765 WMA_LOGE("Failed to register swba beacon event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304766 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767 }
4768#ifdef WLAN_FEATURE_LPSS
4769 wma_handle->lpss_support =
4770 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4771 WMI_SERVICE_LPASS);
4772#endif /* WLAN_FEATURE_LPSS */
4773
4774 /*
4775 * This Service bit is added to check for ARP/NS Offload
4776 * support for LL/HL targets
4777 */
4778 wma_handle->ap_arpns_support =
4779 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4780 WMI_SERVICE_AP_ARPNS_OFFLOAD);
4781
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304782 wma_handle->bpf_enabled = (wma_handle->bpf_packet_filter_enable &&
Rajeev Kumare5a16822016-07-27 13:11:42 -07004783 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05304784 WMI_SERVICE_BPF_OFFLOAD));
4785 wma_update_ra_limit(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4787 WMI_SERVICE_CSA_OFFLOAD)) {
4788 WMA_LOGD("%s: FW support CSA offload capability", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004789 status = wmi_unified_register_event_handler(
4790 wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304791 WMI_CSA_HANDLING_EVENTID,
4792 wma_csa_offload_handler,
4793 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 if (status) {
4795 WMA_LOGE("Failed to register CSA offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304796 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797 }
4798 }
4799
4800 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4801 WMI_SERVICE_MGMT_TX_WMI)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004802 WMA_LOGD("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004803 /*
4804 * Register Tx completion event handler for MGMT Tx over WMI
4805 * case
4806 */
4807 status = wmi_unified_register_event_handler(
4808 wma_handle->wmi_handle,
4809 WMI_MGMT_TX_COMPLETION_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304810 wma_mgmt_tx_completion_handler,
4811 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004812 if (status) {
4813 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Govind Singhd76a5b02016-03-08 15:12:14 +05304814 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815 }
4816
Nirav Shah20489972016-06-16 19:20:28 +05304817 status = wmi_unified_register_event_handler(
4818 wma_handle->wmi_handle,
4819 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID,
4820 wma_mgmt_tx_bundle_completion_handler,
4821 WMA_RX_SERIALIZER_CTX);
4822 if (status) {
4823 WMA_LOGE("Failed to register MGMT over WMI completion handler");
4824 return -EINVAL;
4825 }
4826
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 } else {
4828 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
4829 }
4830#ifdef WLAN_FEATURE_GTK_OFFLOAD
4831 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4832 WMI_SERVICE_GTK_OFFLOAD)) {
4833 status =
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004834 wmi_unified_register_event_handler(
4835 wma_handle->wmi_handle,
Mukul Sharma3d36c392017-01-18 18:39:12 +05304836 WMI_GTK_OFFLOAD_STATUS_EVENTID,
4837 target_if_pmo_gtk_offload_status_event,
4838 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839 if (status) {
4840 WMA_LOGE("Failed to register GTK offload event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304841 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 }
4843 }
4844#endif /* WLAN_FEATURE_GTK_OFFLOAD */
4845
Wu Gao9a704f42017-03-10 18:42:11 +08004846#ifndef CONVERGED_P2P_ENABLE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4848 WMI_P2P_NOA_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304849 wma_p2p_noa_event_handler,
4850 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 if (status) {
4852 WMA_LOGE("Failed to register WMI_P2P_NOA_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05304853 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004854 }
Wu Gao9a704f42017-03-10 18:42:11 +08004855#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
Govind Singhd76a5b02016-03-08 15:12:14 +05304857 WMI_TBTTOFFSET_UPDATE_EVENTID,
4858 wma_tbttoffset_update_event_handler,
4859 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 if (status) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004861 WMA_LOGE("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Govind Singhd76a5b02016-03-08 15:12:14 +05304862 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 }
4864
Govind Singhefc5ccd2016-04-25 11:11:55 +05304865 /* mac_id is replaced with pdev_id in converged firmware to have
4866 * multi-radio support. In order to maintain backward compatibility
4867 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
4868 * in service bitmap from FW and host needs to set use_pdev_id in
4869 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
4870 * service is not set, then host shall not expect MAC ID from FW in
4871 * VDEV START RESPONSE event and host shall use PDEV ID.
4872 */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004873 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
Govind Singhefc5ccd2016-04-25 11:11:55 +05304874 WMI_SERVICE_DEPRECATED_REPLACE))
4875 wma_handle->wlan_resource_config.use_pdev_id = true;
4876 else
4877 wma_handle->wlan_resource_config.use_pdev_id = false;
4878
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05304879 wma_handle->wlan_resource_config.max_num_dbs_scan_duty_cycle =
4880 CDS_DBS_SCAN_CLIENTS_MAX;
4881
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08004882 /* register the Enhanced Green AP event handler */
4883 wma_register_egap_event_handle(wma_handle);
4884
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 /* Initialize the log supported event handler */
4886 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4887 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID,
Govind Singhd76a5b02016-03-08 15:12:14 +05304888 wma_log_supported_evt_handler,
4889 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304890 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891 WMA_LOGE("Failed to register log supported event cb");
Govind Singhd76a5b02016-03-08 15:12:14 +05304892 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893 }
4894
Leo Chang96464902016-10-28 11:10:54 -07004895 cdp_mark_first_wakeup_packet(soc,
Himanshu Agarwal19141bb2016-07-20 20:15:48 +05304896 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4897 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET));
Arif Hussain759a0232017-03-20 13:17:18 -07004898 wma_handle->dfs_cac_offload =
4899 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4900 WMI_SERVICE_DFS_PHYERR_OFFLOAD);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07004901 wma_handle->nan_datapath_enabled =
4902 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4903 WMI_SERVICE_NAN_DATA);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304904 qdf_mem_copy(target_cap.wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905 param_buf->wmi_service_bitmap,
4906 sizeof(wma_handle->wmi_service_bitmap));
4907 target_cap.wlan_resource_config = wma_handle->wlan_resource_config;
4908 wma_update_fw_config(wma_handle, &target_cap);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304909 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004910 target_cap.wmi_service_bitmap,
4911 sizeof(wma_handle->wmi_service_bitmap));
4912 wma_handle->wlan_resource_config = target_cap.wlan_resource_config;
4913
Govind Singhf25a0f12016-03-08 16:09:48 +05304914 status = wmi_unified_save_fw_version_cmd(wma_handle->wmi_handle,
4915 param_buf);
4916 if (status != EOK) {
4917 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
4918 return -EINVAL;
4919 }
4920
4921 status = wma_setup_wmi_init_msg(wma_handle, ev, param_buf);
4922 if (status != EOK) {
4923 WMA_LOGE("Failed to setup for wma init command");
Govind Singhd76a5b02016-03-08 15:12:14 +05304924 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925 }
4926
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304927 /* A host, which supports WMI_SERVICE_READY_EXT_EVENTID, would need to
4928 * check the WMI_SERVICE_READY message for an "extension" flag, and if
4929 * this flag is set, then hold off on sending the WMI_INIT message until
4930 * WMI_SERVICE_READY_EXT_EVENTID is received.
4931 */
4932 if (!WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4933 WMI_SERVICE_EXT_MSG)) {
4934 /* No service extended message support.
4935 * Send INIT command immediately
4936 */
4937 WMA_LOGA("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05304938 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
4939 &wma_handle->wlan_resource_config,
4940 wma_handle->num_mem_chunks,
4941 wma_handle->mem_chunks, 1);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304942 if (status != EOK) {
4943 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Govind Singhd76a5b02016-03-08 15:12:14 +05304944 return -EINVAL;
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304945 }
4946 } else {
Govind Singhf25a0f12016-03-08 16:09:48 +05304947 status = wmi_unified_send_init_cmd(wma_handle->wmi_handle,
4948 &wma_handle->wlan_resource_config,
4949 wma_handle->num_mem_chunks,
4950 wma_handle->mem_chunks, 0);
4951 if (status != EOK) {
4952 WMA_LOGE("Failed to save WMI_INIT_CMDID command parameter");
4953 return -EINVAL;
4954 }
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304955 /* The saved 'buf' will be freed after sending INIT command or
4956 * in other cases as required
4957 */
Anurag Chouhan210db072016-02-22 18:42:15 +05304958 ret = qdf_mc_timer_start(&wma_handle->service_ready_ext_timer,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304959 WMA_SERVICE_READY_EXT_TIMEOUT);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304960 if (!QDF_IS_STATUS_SUCCESS(ret))
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004961 WMA_LOGE("Failed to start the service ready ext timer");
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304962
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004963 WMA_LOGD("%s: WMA waiting for WMI_SERVICE_READY_EXT_EVENTID",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304964 __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004965 }
Govind Singhd76a5b02016-03-08 15:12:14 +05304966
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05304967 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
4968 WMI_SERVICE_8SS_TX_BFEE))
4969 wma_handle->tx_bfee_8ss_enabled = true;
4970 else
4971 wma_handle->tx_bfee_8ss_enabled = false;
4972
Govind Singhd76a5b02016-03-08 15:12:14 +05304973 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974}
4975
4976/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07004977 * wma_get_phyid_for_given_band() - to get phyid for band
4978 *
4979 * @wma_handle: Pointer to wma handle
4980 * @map: Pointer to map which is derived from hw mode & has mapping between
4981 * hw mode and available PHYs for that hw mode.
4982 * @band: enum value of for 2G or 5G band
4983 * @phyid: Pointer to phyid which needs to be filled
4984 *
4985 * This API looks in to the map to find out which particular phy supports
4986 * provided band and return the idx (also called phyid) of that phy. Caller
4987 * use this phyid to fetch various caps of that phy
4988 *
4989 * Return: QDF_STATUS
4990 */
4991static QDF_STATUS wma_get_phyid_for_given_band(
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004992 tp_wma_handle wma_handle,
Krunal Soni0193b6f2016-08-15 15:53:43 -07004993 struct hw_mode_idx_to_mac_cap_idx *map,
4994 enum cds_band_type band, uint8_t *phyid)
4995{
4996 uint8_t idx, i;
4997 WMI_MAC_PHY_CAPABILITIES *cap;
4998
4999 if (!wma_handle) {
5000 WMA_LOGE("Invalid wma handle");
5001 return QDF_STATUS_E_FAILURE;
5002 }
5003
5004 if (!map) {
5005 WMA_LOGE("Invalid given map");
5006 return QDF_STATUS_E_FAILURE;
5007 }
5008 idx = map->mac_cap_idx;
5009 *phyid = idx;
5010
5011 for (i = 0; i < map->num_of_macs; i++) {
5012 cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[idx + i];
5013 if ((band == CDS_BAND_2GHZ) &&
5014 (WLAN_2G_CAPABILITY == cap->supported_bands)) {
5015 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005016 WMA_LOGD("Select 2G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005017 return QDF_STATUS_SUCCESS;
5018 } else if ((band == CDS_BAND_5GHZ) &&
5019 (WLAN_5G_CAPABILITY == cap->supported_bands)) {
5020 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005021 WMA_LOGD("Select 5G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005022 return QDF_STATUS_SUCCESS;
5023 }
5024 }
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005025 WMA_LOGD("Using default single hw mode phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005026 return QDF_STATUS_SUCCESS;
5027}
5028
5029/**
5030 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
5031 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
5032 * @hw_mode: Provided hardware mode
5033 * @band: Provide band i.e. 2G or 5G
5034 *
5035 * This API finds cap which suitable for provided hw mode and band. If user
5036 * is provides some invalid hw mode then it will automatically falls back to
5037 * default hw mode
5038 *
5039 * Return: QDF_STATUS
5040 */
5041QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
5042 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
5043{
5044 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
5045 struct hw_mode_idx_to_mac_cap_idx *map;
5046 WMI_MAC_PHY_CAPABILITIES *phy_cap;
5047 uint8_t phyid, our_hw_mode = hw_mode;
5048
5049 if (!wma_handle) {
5050 WMA_LOGE("Invalid wma handle");
5051 return QDF_STATUS_E_FAILURE;
5052 }
5053
5054 if (0 == wma_handle->phy_caps.num_hw_modes.num_hw_modes) {
5055 WMA_LOGE("Invalid number of hw modes");
5056 return QDF_STATUS_E_FAILURE;
5057 }
5058
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005059 if (!policy_mgr_is_dbs_enable(wma_handle->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -07005060 our_hw_mode = HW_MODE_DBS_NONE;
5061
5062 if (!caps_per_phy) {
5063 WMA_LOGE("Invalid caps pointer");
5064 return QDF_STATUS_E_FAILURE;
5065 }
5066
5067 map = &wma_handle->phy_caps.hw_mode_to_mac_cap_map[our_hw_mode];
5068
5069 if (QDF_STATUS_SUCCESS !=
5070 wma_get_phyid_for_given_band(wma_handle, map, band, &phyid)) {
5071 WMA_LOGE("Invalid phyid");
5072 return QDF_STATUS_E_FAILURE;
5073 }
5074 phy_cap = &wma_handle->phy_caps.each_phy_cap_per_hwmode[phyid];
5075
5076 caps_per_phy->ht_2g = phy_cap->ht_cap_info_2G;
5077 caps_per_phy->ht_5g = phy_cap->ht_cap_info_5G;
5078 caps_per_phy->vht_2g = phy_cap->vht_cap_info_2G;
5079 caps_per_phy->vht_5g = phy_cap->vht_cap_info_5G;
5080 caps_per_phy->he_2g = phy_cap->he_cap_info_2G;
5081 caps_per_phy->he_5g = phy_cap->he_cap_info_5G;
5082
5083 return QDF_STATUS_SUCCESS;
5084}
5085
5086/**
5087 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
5088 *
5089 * @channel: Channel number for which it needs to check if rx ldpc is enabled
5090 *
5091 * This API takes channel number as argument and takes default hw mode as DBS
5092 * to check if rx LDPC support is enabled for that channel or no
5093 */
5094bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
5095{
5096 struct wma_caps_per_phy caps_per_phy = {0};
5097 enum cds_band_type band;
5098 bool status;
5099
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005100 if (!WLAN_REG_IS_24GHZ_CH(channel))
Krunal Soni0193b6f2016-08-15 15:53:43 -07005101 band = CDS_BAND_5GHZ;
5102 else
5103 band = CDS_BAND_2GHZ;
5104
5105 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
5106 &caps_per_phy,
5107 HW_MODE_DBS, band)) {
5108 return false;
5109 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005110 if (WLAN_REG_IS_24GHZ_CH(channel))
Krunal Soni0193b6f2016-08-15 15:53:43 -07005111 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
5112 else
5113 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
5114
5115 return status;
5116}
5117
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005118/**
5119 * wma_print_mac_phy_capabilities() - Prints MAC PHY capabilities
5120 * @cap: pointer to WMI_MAC_PHY_CAPABILITIES
5121 * @index: MAC_PHY index
5122 *
5123 * Return: none
5124 */
5125static void wma_print_mac_phy_capabilities(WMI_MAC_PHY_CAPABILITIES *cap,
5126 int index)
5127{
5128 uint32_t mac_2G, mac_5G;
5129 uint32_t phy_2G[WMI_MAX_HECAP_PHY_SIZE];
5130 uint32_t phy_5G[WMI_MAX_HECAP_PHY_SIZE];
5131 wmi_ppe_threshold ppet_2G, ppet_5G;
5132
5133 WMA_LOGI("\t: index [%d]", index);
5134 WMA_LOGI("\t: cap for hw_mode_id[%d]", cap->hw_mode_id);
5135 WMA_LOGI("\t: pdev_id[%d]", cap->pdev_id);
5136 WMA_LOGI("\t: phy_id[%d]", cap->phy_id);
5137 WMA_LOGI("\t: supports_11b[%d]",
5138 WMI_SUPPORT_11B_GET(cap->supported_flags));
5139 WMA_LOGI("\t: supports_11g[%d]",
5140 WMI_SUPPORT_11G_GET(cap->supported_flags));
5141 WMA_LOGI("\t: supports_11a[%d]",
5142 WMI_SUPPORT_11A_GET(cap->supported_flags));
5143 WMA_LOGI("\t: supports_11n[%d]",
5144 WMI_SUPPORT_11N_GET(cap->supported_flags));
5145 WMA_LOGI("\t: supports_11ac[%d]",
5146 WMI_SUPPORT_11AC_GET(cap->supported_flags));
5147 WMA_LOGI("\t: supports_11ax[%d]",
5148 WMI_SUPPORT_11AX_GET(cap->supported_flags));
5149 WMA_LOGI("\t: supported_flags[%d]", cap->supported_flags);
5150 WMA_LOGI("\t: supported_bands[%d]", cap->supported_bands);
5151 WMA_LOGI("\t: ampdu_density[%d]", cap->ampdu_density);
5152 WMA_LOGI("\t: max_bw_supported_2G[%d]", cap->max_bw_supported_2G);
5153 WMA_LOGI("\t: ht_cap_info_2G[%d]", cap->ht_cap_info_2G);
5154 WMA_LOGI("\t: vht_cap_info_2G[%d]", cap->vht_cap_info_2G);
5155 WMA_LOGI("\t: vht_supp_mcs_2G[%d]", cap->vht_supp_mcs_2G);
5156 WMA_LOGI("\t: tx_chain_mask_2G[%d]", cap->tx_chain_mask_2G);
5157 WMA_LOGI("\t: rx_chain_mask_2G[%d]", cap->rx_chain_mask_2G);
5158 WMA_LOGI("\t: max_bw_supported_5G[%d]", cap->max_bw_supported_5G);
5159 WMA_LOGI("\t: ht_cap_info_5G[%d]", cap->ht_cap_info_5G);
5160 WMA_LOGI("\t: vht_cap_info_5G[%d]", cap->vht_cap_info_5G);
5161 WMA_LOGI("\t: vht_supp_mcs_5G[%d]", cap->vht_supp_mcs_5G);
5162 WMA_LOGI("\t: tx_chain_mask_5G[%d]", cap->tx_chain_mask_5G);
5163 WMA_LOGI("\t: rx_chain_mask_5G[%d]", cap->rx_chain_mask_5G);
5164 WMA_LOGI("\t: he_cap_info_2G[%08x]", cap->he_cap_info_2G);
5165 WMA_LOGI("\t: he_supp_mcs_2G[%08x]", cap->he_supp_mcs_2G);
5166 WMA_LOGI("\t: he_cap_info_5G[%08x]", cap->he_cap_info_5G);
5167 WMA_LOGI("\t: he_supp_mcs_5G[%08x]", cap->he_supp_mcs_5G);
5168 mac_2G = cap->he_cap_info_2G;
5169 mac_5G = cap->he_cap_info_5G;
5170 qdf_mem_copy(phy_2G, cap->he_cap_phy_info_2G,
5171 WMI_MAX_HECAP_PHY_SIZE * 4);
5172 qdf_mem_copy(phy_5G, cap->he_cap_phy_info_5G,
5173 WMI_MAX_HECAP_PHY_SIZE * 4);
5174 ppet_2G = cap->he_ppet2G;
5175 ppet_5G = cap->he_ppet5G;
5176
5177 wma_print_he_mac_cap(mac_2G);
5178 wma_print_he_phy_cap(phy_2G);
5179 wma_print_he_ppet(&ppet_2G);
5180 wma_print_he_mac_cap(mac_5G);
5181 wma_print_he_phy_cap(phy_5G);
5182 wma_print_he_ppet(&ppet_5G);
5183}
Krunal Soni0193b6f2016-08-15 15:53:43 -07005184
5185/**
Krunal Soni2e48d012016-05-02 16:55:26 -07005186 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
5187 * @wma_handle: pointer to wma_handle
5188 *
5189 * This function prints all the caps populater per hw mode and per PHY
5190 *
5191 * Return: none
5192 */
5193static void wma_print_populate_soc_caps(t_wma_handle *wma_handle)
5194{
5195 int i, j = 0, max_mac;
5196 WMI_MAC_PHY_CAPABILITIES *tmp;
5197
5198 /* print number of hw modes */
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005199 WMA_LOGD("%s: num of hw modes [%d]", __func__,
Krunal Soni2e48d012016-05-02 16:55:26 -07005200 wma_handle->phy_caps.num_hw_modes.num_hw_modes);
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005201 WMA_LOGD("%s: <====== HW mode cap printing starts ======>", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005202 /* print cap of each hw mode */
5203 for (i = 0; i < wma_handle->phy_caps.num_hw_modes.num_hw_modes; i++) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005204 WMA_LOGD("====>: hw mode id[%d], phy_id map[%d]",
Krunal Soni2e48d012016-05-02 16:55:26 -07005205 wma_handle->phy_caps.each_hw_mode_cap[i].hw_mode_id,
5206 wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map);
5207 if (wma_handle->phy_caps.each_hw_mode_cap[i].phy_id_map ==
5208 PHY1_PHY2)
5209 max_mac = j + 2;
5210 else
5211 max_mac = j + 1;
5212
5213 for ( ; j < max_mac; j++) {
5214 tmp = &wma_handle->phy_caps.each_phy_cap_per_hwmode[j];
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005215 wma_print_mac_phy_capabilities(tmp, j);
Krunal Soni2e48d012016-05-02 16:55:26 -07005216 }
5217 }
5218 WMA_LOGI("%s: <====== HW mode cap printing ends ======>\n", __func__);
5219}
5220
5221/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305222 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
5223 * in terms of hw_mode_bandwidth
5224 * @width: bandwidth in terms of wmi_channel_width
5225 *
5226 * This function returns the bandwidth in terms of hw_mode_bandwidth.
5227 *
5228 * Return: BW in terms of hw_mode_bandwidth.
5229 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005230static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305231 wmi_channel_width width)
5232{
5233 switch (width) {
5234 case WMI_CHAN_WIDTH_20:
5235 return HW_MODE_20_MHZ;
5236 case WMI_CHAN_WIDTH_40:
5237 return HW_MODE_40_MHZ;
5238 case WMI_CHAN_WIDTH_80:
5239 return HW_MODE_80_MHZ;
5240 case WMI_CHAN_WIDTH_160:
5241 return HW_MODE_160_MHZ;
5242 case WMI_CHAN_WIDTH_80P80:
5243 return HW_MODE_80_PLUS_80_MHZ;
5244 case WMI_CHAN_WIDTH_5:
5245 return HW_MODE_5_MHZ;
5246 case WMI_CHAN_WIDTH_10:
5247 return HW_MODE_10_MHZ;
5248 default:
5249 return HW_MODE_BW_NONE;
5250 }
5251
5252 return HW_MODE_BW_NONE;
5253}
5254
5255/**
5256 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
5257 * supported from the capabilities.
5258 * @caps: PHY capability
5259 * @info: param to store TX-RX stream and BW information
5260 *
5261 * This function will calculate TX-RX stream and bandwidth supported
5262 * as per the PHY capability, and assign to mac_ss_bw_info.
5263 *
5264 * Return: none
5265 */
5266static void wma_get_hw_mode_params(WMI_MAC_PHY_CAPABILITIES *caps,
5267 struct mac_ss_bw_info *info)
5268{
5269 if (!caps) {
5270 WMA_LOGE("%s: Invalid capabilities", __func__);
5271 return;
5272 }
5273
5274 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
5275 QDF_MAX(caps->tx_chain_mask_2G,
5276 caps->tx_chain_mask_5G));
5277 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
5278 QDF_MAX(caps->rx_chain_mask_2G,
5279 caps->rx_chain_mask_5G));
5280 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
5281 QDF_MAX(caps->max_bw_supported_2G,
5282 caps->max_bw_supported_5G));
5283}
5284
5285/**
5286 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
5287 * DBS in hw_mode_list
5288 * @wma_handle: pointer to wma global structure
5289 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
5290 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
5291 * @pos: refers to hw_mode_index
5292 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305293 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305294 *
5295 * This function sets TX-RX stream, bandwidth and DBS mode in
5296 * hw_mode_list.
5297 *
5298 * Return: none
5299 */
5300static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
5301 struct mac_ss_bw_info mac0_ss_bw_info,
5302 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305303 uint32_t pos, uint32_t dbs_mode,
5304 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305305{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305306 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305307 wma_handle->hw_mode.hw_mode_list[pos],
5308 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305309 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305310 wma_handle->hw_mode.hw_mode_list[pos],
5311 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305312 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305313 wma_handle->hw_mode.hw_mode_list[pos],
5314 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305315 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305316 wma_handle->hw_mode.hw_mode_list[pos],
5317 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305318 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305319 wma_handle->hw_mode.hw_mode_list[pos],
5320 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305321 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305322 wma_handle->hw_mode.hw_mode_list[pos],
5323 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305324 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305325 wma_handle->hw_mode.hw_mode_list[pos],
5326 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305327 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305328 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305329 HW_MODE_AGILE_DFS_NONE);
5330 WMA_HW_MODE_SBS_MODE_SET(
5331 wma_handle->hw_mode.hw_mode_list[pos],
5332 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305333}
5334
5335/**
5336 * wma_update_hw_mode_list() - updates hw_mode_list
5337 * @wma_handle: pointer to wma global structure
5338 *
5339 * This function updates hw_mode_list with tx_streams, rx_streams,
5340 * bandwidth, dbs and agile dfs for each hw_mode.
5341 *
5342 * Returns: 0 for success else failure.
5343 */
5344static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle)
5345{
5346 struct extended_caps *phy_caps;
5347 WMI_MAC_PHY_CAPABILITIES *tmp;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305348 uint32_t i, hw_config_type, j = 0;
5349 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305350 struct mac_ss_bw_info mac0_ss_bw_info = {0};
5351 struct mac_ss_bw_info mac1_ss_bw_info = {0};
5352
5353 if (!wma_handle) {
5354 WMA_LOGE("%s: Invalid wma handle", __func__);
5355 return QDF_STATUS_E_FAILURE;
5356 }
5357
5358 phy_caps = &wma_handle->phy_caps;
5359 if (!phy_caps) {
5360 WMA_LOGE("%s: Invalid phy capabilities", __func__);
5361 return QDF_STATUS_SUCCESS;
5362 }
5363
5364 if (!phy_caps->num_hw_modes.num_hw_modes) {
5365 WMA_LOGE("%s: Number of HW modes: %d",
5366 __func__, phy_caps->num_hw_modes.num_hw_modes);
5367 return QDF_STATUS_SUCCESS;
5368 }
5369
5370 /*
5371 * This list was updated as part of service ready event. Re-populate
5372 * HW mode list from the device capabilities.
5373 */
5374 if (wma_handle->hw_mode.hw_mode_list) {
5375 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
5376 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005377 WMA_LOGD("%s: DBS list is freed", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305378 }
5379
5380 wma_handle->num_dbs_hw_modes = phy_caps->num_hw_modes.num_hw_modes;
5381 wma_handle->hw_mode.hw_mode_list =
5382 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
5383 wma_handle->num_dbs_hw_modes);
5384 if (!wma_handle->hw_mode.hw_mode_list) {
5385 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
5386 return QDF_STATUS_E_FAILURE;
5387 }
5388
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005389 WMA_LOGD("%s: Updated HW mode list: Num modes:%d",
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305390 __func__, wma_handle->num_dbs_hw_modes);
5391
5392 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5393 /* Update for MAC0 */
5394 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5395 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
5396 hw_config_type =
5397 phy_caps->each_hw_mode_cap[i].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305398 dbs_mode = HW_MODE_DBS_NONE;
5399 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305400 mac1_ss_bw_info.mac_tx_stream = 0;
5401 mac1_ss_bw_info.mac_rx_stream = 0;
5402 mac1_ss_bw_info.mac_bw = 0;
5403
5404 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
5405 if ((hw_config_type == WMI_HW_MODE_DBS) ||
5406 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5407 (hw_config_type == WMI_HW_MODE_SBS)) {
5408 /* Update for MAC1 */
5409 tmp = &phy_caps->each_phy_cap_per_hwmode[j++];
5410 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305411 if (hw_config_type == WMI_HW_MODE_DBS)
5412 dbs_mode = HW_MODE_DBS;
5413 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
5414 (hw_config_type == WMI_HW_MODE_SBS))
5415 sbs_mode = HW_MODE_SBS;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305416 }
5417
5418 /* Updating HW mode list */
5419 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305420 mac1_ss_bw_info, i, dbs_mode,
5421 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305422 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005423
5424 if (QDF_STATUS_SUCCESS !=
5425 policy_mgr_update_hw_mode_list(wma_handle->psoc, phy_caps))
5426 WMA_LOGE("%s: failed to update policy manager", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305427 wma_dump_dbs_hw_mode(wma_handle);
5428 return QDF_STATUS_SUCCESS;
5429}
5430
Naveen Rawat4efe41b2017-04-29 16:23:14 -07005431static void wma_init_wifi_pos_dma_rings(t_wma_handle *wma_handle,
5432 uint8_t num_mac, void *buf)
5433{
5434 struct hif_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
5435 void *hal_soc = hif_get_hal_handle(hif_ctx);
5436
5437 wifi_pos_init_cir_cfr_rings(wma_handle->psoc, hal_soc, num_mac, buf);
5438}
5439
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305440/**
Krunal Soni2e48d012016-05-02 16:55:26 -07005441 * wma_populate_soc_caps() - populate entire SOC's capabilities
5442 * @wma_handle: pointer to wma global structure
5443 * @param_buf: pointer to param of service ready extension event from fw
5444 *
5445 * This API populates all capabilities of entire SOC. For example,
5446 * how many number of hw modes are supported by this SOC, what are the
5447 * capabilities of each phy per hw mode, what are HAL reg capabilities per
5448 * phy.
5449 *
5450 * Return: none
5451 */
5452static void wma_populate_soc_caps(t_wma_handle *wma_handle,
5453 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
5454{
5455 int i, num_of_mac_caps = 0, tmp = 0;
5456 struct extended_caps *phy_caps;
5457 struct hw_mode_idx_to_mac_cap_idx *map;
5458
5459 WMA_LOGD("%s: Enter", __func__);
5460
5461 if (!wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005462 WMA_LOGE("%s: Invalid WMA handle", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005463 return;
5464 }
5465
5466 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005467 WMA_LOGE("%s: Invalid event", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005468 return;
5469 }
5470 phy_caps = &wma_handle->phy_caps;
5471
5472 /*
5473 * first thing to do is to get how many number of hw modes are
5474 * supported and populate in wma_handle global structure
5475 */
Krunal Sonifd85ba62016-07-11 08:18:53 -07005476 if (NULL == param_buf->soc_hw_mode_caps) {
5477 WMA_LOGE("%s: Invalid number of hw modes", __func__);
5478 return;
5479 }
5480
Krunal Soni2e48d012016-05-02 16:55:26 -07005481 qdf_mem_copy(&phy_caps->num_hw_modes,
5482 param_buf->soc_hw_mode_caps,
5483 sizeof(WMI_SOC_MAC_PHY_HW_MODE_CAPS));
5484 if (0 == phy_caps->num_hw_modes.num_hw_modes) {
Krunal Sonifd85ba62016-07-11 08:18:53 -07005485 WMA_LOGE("%s: Number of hw modes is zero", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07005486 return;
Krunal Soni2e48d012016-05-02 16:55:26 -07005487 }
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005488 WMA_LOGD("%s: Given number of hw modes[%d]",
Krunal Sonifd85ba62016-07-11 08:18:53 -07005489 __func__, phy_caps->num_hw_modes.num_hw_modes);
Krunal Soni2e48d012016-05-02 16:55:26 -07005490
5491 /*
5492 * next thing is to allocate the memory to map hw mode to phy/mac caps
5493 */
5494 phy_caps->hw_mode_to_mac_cap_map =
5495 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5496 sizeof(struct hw_mode_idx_to_mac_cap_idx));
5497 if (!phy_caps->hw_mode_to_mac_cap_map) {
5498 WMA_LOGE("%s: Memory allocation failed", __func__);
5499 return;
5500 }
5501
5502 /*
5503 * next thing is to allocate the memory for per hw caps
5504 */
5505 phy_caps->each_hw_mode_cap =
5506 qdf_mem_malloc(phy_caps->num_hw_modes.num_hw_modes *
5507 sizeof(WMI_HW_MODE_CAPABILITIES));
5508 if (!phy_caps->each_hw_mode_cap) {
5509 WMA_LOGE("%s: Memory allocation failed", __func__);
5510 wma_cleanup_dbs_phy_caps(wma_handle);
5511 return;
5512 }
5513 qdf_mem_copy(phy_caps->each_hw_mode_cap,
5514 param_buf->hw_mode_caps,
5515 phy_caps->num_hw_modes.num_hw_modes *
5516 sizeof(WMI_HW_MODE_CAPABILITIES));
5517 /*
5518 * next thing is to count the number of mac cap to populate per
5519 * hw mode and generate map, so that our search can be done
5520 * efficiently which is O(1)
5521 */
5522 for (i = 0; i < phy_caps->num_hw_modes.num_hw_modes; i++) {
5523 map = &phy_caps->hw_mode_to_mac_cap_map[i];
5524 if (phy_caps->each_hw_mode_cap[i].phy_id_map == PHY1_PHY2) {
5525 tmp = num_of_mac_caps;
5526 num_of_mac_caps = num_of_mac_caps + 2;
5527 map->num_of_macs = 2;
5528 } else {
5529 tmp = num_of_mac_caps;
5530 num_of_mac_caps = num_of_mac_caps + 1;
5531 map->num_of_macs = 1;
5532 }
5533 map->mac_cap_idx = tmp;
5534 map->hw_mode_id = phy_caps->each_hw_mode_cap[i].hw_mode_id;
5535 }
5536
5537 /*
5538 * next thing is to populate each phy caps per hw mode
5539 */
5540 phy_caps->each_phy_cap_per_hwmode =
5541 qdf_mem_malloc(num_of_mac_caps *
5542 sizeof(WMI_MAC_PHY_CAPABILITIES));
5543 if (!phy_caps->each_phy_cap_per_hwmode) {
5544 WMA_LOGE("%s: Memory allocation failed", __func__);
5545 wma_cleanup_dbs_phy_caps(wma_handle);
5546 return;
5547 }
5548 qdf_mem_copy(phy_caps->each_phy_cap_per_hwmode,
5549 param_buf->mac_phy_caps,
5550 num_of_mac_caps * sizeof(WMI_MAC_PHY_CAPABILITIES));
5551
5552 /*
5553 * next thing is to populate reg caps per phy
5554 */
5555 qdf_mem_copy(&phy_caps->num_phy_for_hal_reg_cap,
5556 param_buf->soc_hal_reg_caps,
5557 sizeof(WMI_SOC_HAL_REG_CAPABILITIES));
5558 if (phy_caps->num_phy_for_hal_reg_cap.num_phy == 0) {
5559 WMA_LOGE("%s: incorrect number of phys", __func__);
5560 wma_cleanup_dbs_phy_caps(wma_handle);
5561 return;
5562 }
5563 phy_caps->each_phy_hal_reg_cap =
5564 qdf_mem_malloc(phy_caps->num_phy_for_hal_reg_cap.num_phy *
5565 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
5566 if (!phy_caps->each_phy_hal_reg_cap) {
5567 WMA_LOGE("%s: Memory allocation failed", __func__);
5568 wma_cleanup_dbs_phy_caps(wma_handle);
5569 return;
5570 }
5571 qdf_mem_copy(phy_caps->each_phy_hal_reg_cap,
5572 param_buf->hal_reg_caps,
5573 phy_caps->num_phy_for_hal_reg_cap.num_phy *
5574 sizeof(WMI_HAL_REG_CAPABILITIES_EXT));
Naveen Rawat4efe41b2017-04-29 16:23:14 -07005575
5576 wma_init_wifi_pos_dma_rings(wma_handle,
5577 param_buf->num_oem_dma_ring_caps,
5578 param_buf->oem_dma_ring_caps);
5579
Krunal Soni2e48d012016-05-02 16:55:26 -07005580 wma_print_populate_soc_caps(wma_handle);
Krunal Soni2e48d012016-05-02 16:55:26 -07005581}
5582
5583/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
5585 * @handle: wma handle
5586 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05305587 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 *
5589 * Return: none
5590 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305591int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
5592 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593{
5594 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5595 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
5596 wmi_service_ready_ext_event_fixed_param *ev;
5597 int status;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305598 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005599
5600 WMA_LOGD("%s: Enter", __func__);
5601
5602 if (!wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005603 WMA_LOGE("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305604 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605 }
5606
5607 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
5608 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005609 WMA_LOGE("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305610 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 }
5612
5613 ev = param_buf->fixed_param;
5614 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005615 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305616 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617 }
5618
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005619 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005621 WMA_LOGD("%s: Defaults: scan config:%x FW mode config:%x",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305622 __func__, ev->default_conc_scan_config_bits,
5623 ev->default_fw_config_bits);
5624
Anurag Chouhan210db072016-02-22 18:42:15 +05305625 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305626 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005627 WMA_LOGE("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05305628 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005629 }
Krunal Soni2e48d012016-05-02 16:55:26 -07005630 wma_populate_soc_caps(wma_handle, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005631
Nitesh Shah877ad5d2016-09-22 19:27:58 +05305632 ret = wma_update_hw_mode_list(wma_handle);
5633 if (QDF_IS_STATUS_ERROR(ret)) {
5634 WMA_LOGE("Failed to update hw mode list");
5635 return -EINVAL;
5636 }
5637
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005638 WMA_LOGD("WMA --> WMI_INIT_CMDID");
Govind Singhf25a0f12016-03-08 16:09:48 +05305639 status = wmi_unified_send_saved_init_cmd(wma_handle->wmi_handle);
5640 if (status != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005641 /* In success case, WMI layer will free after getting copy
5642 * engine TX complete interrupt
5643 */
5644 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305646 wma_init_scan_fw_mode_config(wma_handle,
5647 ev->default_conc_scan_config_bits,
5648 ev->default_fw_config_bits);
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07005649 wma_handle->target_fw_vers_ext = ev->fw_build_vers_ext;
Govind Singhd76a5b02016-03-08 15:12:14 +05305650 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651}
5652
5653/**
5654 * wma_rx_ready_event() - event handler to process
5655 * wmi rx ready event.
5656 * @handle: wma handle
5657 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05305658 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 *
5660 * Return: none
5661 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305662int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
5663 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664{
5665 tp_wma_handle wma_handle = (tp_wma_handle) handle;
5666 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
5667 wmi_ready_event_fixed_param *ev = NULL;
5668
5669 WMA_LOGD("%s: Enter", __func__);
5670
5671 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
5672 if (!(wma_handle && param_buf)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005673 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305674 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05305675 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005676 }
5677
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005678 WMA_LOGD("WMA <-- WMI_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679
5680 ev = param_buf->fixed_param;
5681 /* Indicate to the waiting thread that the ready
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005682 * event was received
5683 */
Naveen Rawat64e477e2016-05-20 10:34:56 -07005684 wma_handle->sub_20_support =
5685 WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5686 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005687 wma_handle->wmi_ready = true;
5688 wma_handle->wlan_init_status = ev->status;
5689
5690 /*
5691 * We need to check the WMI versions and make sure both
5692 * host and fw are compatible.
5693 */
5694 if (!wmi_versions_are_compatible(&wma_handle->final_abi_vers,
5695 &ev->fw_abi_vers)) {
5696 /*
5697 * Error: Our host version and the given firmware version
5698 * are incompatible.
5699 */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005700 WMA_LOGE("%s: Error: Incompatible WMI version.", __func__);
5701 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 -08005702 __func__,
5703 WMI_VER_GET_MAJOR(wma_handle->final_abi_vers.
5704 abi_version_0),
5705 WMI_VER_GET_MINOR(wma_handle->final_abi_vers.
5706 abi_version_0),
5707 wma_handle->final_abi_vers.abi_version_ns_0,
5708 wma_handle->final_abi_vers.abi_version_ns_1,
5709 wma_handle->final_abi_vers.abi_version_ns_2,
5710 wma_handle->final_abi_vers.abi_version_ns_3,
5711 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
5712 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
5713 ev->fw_abi_vers.abi_version_ns_0,
5714 ev->fw_abi_vers.abi_version_ns_1,
5715 ev->fw_abi_vers.abi_version_ns_2,
5716 ev->fw_abi_vers.abi_version_ns_3);
5717 if (wma_handle->wlan_init_status == WLAN_INIT_STATUS_SUCCESS) {
5718 /* Failed this connection to FW */
5719 wma_handle->wlan_init_status =
5720 WLAN_INIT_STATUS_GEN_FAILED;
5721 }
5722 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305723 qdf_mem_copy(&wma_handle->final_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724 sizeof(wmi_abi_version));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305725 qdf_mem_copy(&wma_handle->target_abi_vers, &ev->fw_abi_vers,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 sizeof(wmi_abi_version));
5727
5728 /* copy the mac addr */
5729 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
5730 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
5731
5732 wma_update_hdd_cfg(wma_handle);
5733
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305734 qdf_event_set(&wma_handle->wma_ready_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005735
5736 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05305737
5738 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005739}
5740
5741/**
5742 * wma_setneedshutdown() - setting wma needshutdown flag
5743 * @cds_ctx: cds context
5744 *
5745 * Return: none
5746 */
5747void wma_setneedshutdown(void *cds_ctx)
5748{
5749 tp_wma_handle wma_handle;
5750
5751 WMA_LOGD("%s: Enter", __func__);
5752
Anurag Chouhan6d760662016-02-20 16:05:43 +05305753 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005754
5755 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005756 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305757 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 return;
5759 }
5760
5761 wma_handle->needShutdown = true;
5762 WMA_LOGD("%s: Exit", __func__);
5763}
5764
5765/**
5766 * wma_needshutdown() - Is wma needs shutdown?
5767 * @cds_ctx: cds context
5768 *
5769 * Return: returns true/false
5770 */
5771bool wma_needshutdown(void *cds_ctx)
5772{
5773 tp_wma_handle wma_handle;
5774
5775 WMA_LOGD("%s: Enter", __func__);
5776
Anurag Chouhan6d760662016-02-20 16:05:43 +05305777 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778
5779 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005780 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305781 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 return false;
5783 }
5784
5785 WMA_LOGD("%s: Exit", __func__);
5786 return wma_handle->needShutdown;
5787}
5788
5789/**
5790 * wma_wait_for_ready_event() - wait for wma ready event
5791 * @handle: wma handle
5792 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305793 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305795QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005796{
5797 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305798 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799
5800 /* wait until WMI_READY_EVENTID received from FW */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05305801 qdf_status = qdf_wait_single_event(&(wma_handle->wma_ready_event),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 WMA_READY_EVENTID_TIMEOUT);
5803
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305804 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005805 WMA_LOGE("%s: Timeout waiting for ready event from FW",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305807 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305809 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005810}
5811
5812/**
5813 * wma_set_ppsconfig() - set pps config in fw
5814 * @vdev_id: vdev id
5815 * @pps_param: pps params
5816 * @val : param value
5817 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305818 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005819 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305820QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821 int val)
5822{
Anurag Chouhan6d760662016-02-20 16:05:43 +05305823 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005824 int ret = -EIO;
5825 uint32_t pps_val;
5826
5827 if (NULL == wma) {
5828 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305829 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005830 }
5831
5832 switch (pps_param) {
5833 case WMA_VHT_PPS_PAID_MATCH:
5834 pps_val = ((val << 31) & 0xffff0000) |
5835 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
5836 goto pkt_pwr_save_config;
5837 case WMA_VHT_PPS_GID_MATCH:
5838 pps_val = ((val << 31) & 0xffff0000) |
5839 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
5840 goto pkt_pwr_save_config;
5841 case WMA_VHT_PPS_DELIM_CRC_FAIL:
5842 pps_val = ((val << 31) & 0xffff0000) |
5843 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
5844 goto pkt_pwr_save_config;
5845
5846 /* Enable the code below as and when the functionality
5847 * is supported/added in host.
5848 */
5849#ifdef NOT_YET
5850 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
5851 pps_val = ((val << 31) & 0xffff0000) |
5852 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
5853 goto pkt_pwr_save_config;
5854 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
5855 pps_val = ((val << 31) & 0xffff0000) |
5856 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
5857 goto pkt_pwr_save_config;
5858 case WMA_VHT_PPS_EOF_PAD_DELIM:
5859 pps_val = ((val << 31) & 0xffff0000) |
5860 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
5861 goto pkt_pwr_save_config;
5862 case WMA_VHT_PPS_MACADDR_MISMATCH:
5863 pps_val = ((val << 31) & 0xffff0000) |
5864 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
5865 goto pkt_pwr_save_config;
5866 case WMA_VHT_PPS_GID_NSTS_ZERO:
5867 pps_val = ((val << 31) & 0xffff0000) |
5868 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
5869 goto pkt_pwr_save_config;
5870 case WMA_VHT_PPS_RSSI_CHECK:
5871 pps_val = ((val << 31) & 0xffff0000) |
5872 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
5873 goto pkt_pwr_save_config;
5874#endif /* NOT_YET */
5875pkt_pwr_save_config:
5876 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
5877 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05305878 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005879 WMI_VDEV_PARAM_PACKET_POWERSAVE,
5880 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005881 break;
5882 default:
5883 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
5884 }
5885
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305886 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005887}
5888
5889/**
5890 * wma_process_set_mas() - Function to enable/disable MAS
5891 * @wma: Pointer to WMA handle
5892 * @mas_val: 1-Enable MAS, 0-Disable MAS
5893 *
5894 * This function enables/disables the MAS value
5895 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305896 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005897 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005898static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
5899 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005900{
5901 uint32_t val;
5902
5903 if (NULL == wma || NULL == mas_val) {
5904 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305905 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906 }
5907
5908 val = (*mas_val);
5909
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305910 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005911 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
5912 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305913 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005914 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005915 WMA_LOGE("%s: Value is %d", __func__, val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305916 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005917}
5918
5919/**
5920 * wma_process_set_miracast() - Function to set miracast value in WMA
5921 * @wma: Pointer to WMA handle
5922 * @miracast_val: 0-Disabled,1-Source,2-Sink
5923 *
5924 * This function stores the miracast value in WMA
5925 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305926 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005927 *
5928 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005929static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
5930 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005931{
5932 if (NULL == wma || NULL == miracast_val) {
5933 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305934 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005935 }
5936
5937 wma->miracast_value = *miracast_val;
5938 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
5939
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305940 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941}
5942
5943/**
5944 * wma_config_stats_factor() - Function to configure stats avg. factor
5945 * @wma: pointer to WMA handle
5946 * @avg_factor: stats. avg. factor passed down by userspace
5947 *
5948 * This function configures the avg. stats value in firmware
5949 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305950 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 *
5952 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305953static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954 struct sir_stats_avg_factor *avg_factor)
5955{
Govind Singhd76a5b02016-03-08 15:12:14 +05305956 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957
5958 if (NULL == wma || NULL == avg_factor) {
5959 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305960 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 }
5962
Govind Singhd76a5b02016-03-08 15:12:14 +05305963 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964 avg_factor->vdev_id,
5965 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
5966 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05305967 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005968 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
5969 avg_factor->vdev_id);
5970 }
5971
5972 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
5973 avg_factor->stats_avg_factor, avg_factor->vdev_id);
5974
5975 return ret;
5976}
5977
5978/**
5979 * wma_config_guard_time() - Function to set guard time in firmware
5980 * @wma: pointer to WMA handle
5981 * @guard_time: guard time passed down by userspace
5982 *
5983 * This function configures the guard time in firmware
5984 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305985 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986 *
5987 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305988static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005989 struct sir_guard_time_request *guard_time)
5990{
Govind Singhd76a5b02016-03-08 15:12:14 +05305991 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005992
5993 if (NULL == wma || NULL == guard_time) {
5994 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305995 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005996 }
5997
Govind Singhd76a5b02016-03-08 15:12:14 +05305998 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 guard_time->vdev_id,
6000 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
6001 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05306002 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 WMA_LOGE(" failed to set guard time for vdev_id %d",
6004 guard_time->vdev_id);
6005 }
6006
6007 WMA_LOGD("Set guard time %d for vdev_id %d",
6008 guard_time->guard_time, guard_time->vdev_id);
6009
6010 return ret;
6011}
6012
6013/**
6014 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
6015 * @wma_handle: WMA handle
6016 * @start_log: Start logging related parameters
6017 *
6018 * Send the command to the FW based on which specific logging of diag
6019 * event/log id can be started/stopped
6020 *
6021 * Return: None
6022 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006023static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
6024 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006026
6027 if (!start_log) {
6028 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6029 return;
6030 }
6031 if (!wma_handle) {
6032 WMA_LOGE("%s: Invalid wma handle", __func__);
6033 return;
6034 }
6035
6036 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
6037 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
6038 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
6039 __func__, start_log->ring_id);
6040 return;
6041 }
6042
Govind Singhf25a0f12016-03-08 16:09:48 +05306043 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
6044 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045}
6046
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306047#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048/**
6049 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
6050 * @wma_handle: WMA handle
6051 * @start_log: Struture containing the start wifi logger params
6052 *
6053 * This function is used to send the WMA commands to start/stop logging
6054 * of per packet statistics
6055 *
6056 * Return: None
6057 *
6058 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006059#ifdef REMOVE_PKT_LOG
6060static void wma_set_wifi_start_packet_stats(void *wma_handle,
6061 struct sir_wifi_start_log *start_log)
6062{
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006063}
6064#else
6065static void wma_set_wifi_start_packet_stats(void *wma_handle,
6066 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067{
Komal Seelam3d202862016-02-24 18:43:24 +05306068 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069 uint32_t log_state;
6070
6071 if (!start_log) {
6072 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6073 return;
6074 }
6075 if (!wma_handle) {
6076 WMA_LOGE("%s: Invalid wma handle", __func__);
6077 return;
6078 }
6079
6080 /* No need to register for ring IDs other than packet stats */
6081 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006082 WMA_LOGD("%s: Ring id is not for per packet stats: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006083 __func__, start_log->ring_id);
6084 return;
6085 }
6086
Anurag Chouhan6d760662016-02-20 16:05:43 +05306087 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07006088 if (scn == NULL) {
6089 WMA_LOGE("%s: Invalid HIF handle", __func__);
6090 return;
6091 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092
6093 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05306094 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
6095 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006096
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306097 if (start_log->size != 0) {
6098 pktlog_setsize(scn, start_log->size * MEGABYTE);
6099 return;
Poddar, Siddarthab99a272017-04-10 12:53:26 +05306100 } else if (start_log->is_pktlog_buff_clear == true) {
6101 pktlog_clearbuff(scn, start_log->is_pktlog_buff_clear);
6102 return;
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306103 }
6104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006105 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006106 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306107 start_log->user_triggered,
6108 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006109 WMA_LOGD("%s: Enabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006111 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306112 start_log->user_triggered,
6113 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006114 WMA_LOGD("%s: Disabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006115 }
6116}
6117#endif
6118
6119/**
6120 * wma_send_flush_logs_to_fw() - Send log flush command to FW
6121 * @wma_handle: WMI handle
6122 *
6123 * This function is used to send the flush command to the FW,
6124 * that will flush the fw logs that are residue in the FW
6125 *
6126 * Return: None
6127 */
6128void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
6129{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306130 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131 int ret;
6132
Govind Singhf25a0f12016-03-08 16:09:48 +05306133 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
6134 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006135 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006136
Anurag Chouhan210db072016-02-22 18:42:15 +05306137 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006138 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306139 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006140 WMA_LOGE("Failed to start the log completion timer");
6141}
6142
6143/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306144 * wma_update_wep_default_key - To update default key id
6145 * @wma: pointer to wma handler
6146 * @update_def_key: pointer to wep_update_default_key_idx
6147 *
6148 * This function makes a copy of default key index to txrx node
6149 *
6150 * Return: Success
6151 */
6152static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
6153 struct wep_update_default_key_idx *update_def_key)
6154{
6155 struct wma_txrx_node *iface =
6156 &wma->interfaces[update_def_key->session_id];
6157 iface->wep_default_key_idx = update_def_key->default_idx;
6158
6159 return QDF_STATUS_SUCCESS;
6160}
6161
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05306162/**
6163 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
6164 * @wma_handle: WMA handle
6165 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
6166 *
6167 * This function is used to set Tx pkt fail count threshold,
6168 * FW will do disconnect with station once this threshold is reached.
6169 *
6170 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6171 */
6172static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006173 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05306174{
6175 u_int8_t vdev_id;
6176 u_int32_t tx_fail_disconn_th;
6177 int ret = -EIO;
6178
6179 if (!wma || !wma->wmi_handle) {
6180 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
6181 return QDF_STATUS_E_INVAL;
6182 }
6183 vdev_id = tx_fail_cnt_th->session_id;
6184 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
6185 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
6186 vdev_id, tx_fail_disconn_th);
6187
6188
6189 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6190 WMI_VDEV_PARAM_DISCONNECT_TH,
6191 tx_fail_disconn_th);
6192
6193 if (ret) {
6194 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
6195 return QDF_STATUS_E_FAILURE;
6196 }
6197
6198 return QDF_STATUS_SUCCESS;
6199}
6200
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306201/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306202 * wma_update_short_retry_limit() - Set retry limit for short frames
6203 * @wma_handle: WMA handle
6204 * @short_retry_limit_th: retry limir count for Short frames.
6205 *
6206 * This function is used to configure the transmission retry limit at which
6207 * short frames needs to be retry.
6208 *
6209 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6210 */
6211static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
6212 struct sme_short_retry_limit *short_retry_limit_th)
6213{
6214 uint8_t vdev_id;
6215 uint32_t short_retry_limit;
6216 int ret;
6217
6218 if (!wma || !wma->wmi_handle) {
6219 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
6220 return QDF_STATUS_E_INVAL;
6221 }
6222 vdev_id = short_retry_limit_th->session_id;
6223 short_retry_limit = short_retry_limit_th->short_retry_limit;
6224 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
6225 vdev_id, short_retry_limit);
6226
6227 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6228 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
6229 short_retry_limit);
6230
6231 if (ret) {
6232 WMA_LOGE("Failed to send short limit threshold command");
6233 return QDF_STATUS_E_FAILURE;
6234 }
6235 return QDF_STATUS_SUCCESS;
6236}
6237
6238/**
6239 * wma_update_long_retry_limit() - Set retry limit for long frames
6240 * @wma_handle: WMA handle
6241 * @long_retry_limit_th: retry limir count for long frames
6242 *
6243 * This function is used to configure the transmission retry limit at which
6244 * long frames needs to be retry
6245 *
6246 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
6247 */
6248static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
6249 struct sme_long_retry_limit *long_retry_limit_th)
6250{
6251 uint8_t vdev_id;
6252 uint32_t long_retry_limit;
6253 int ret;
6254
6255 if (!wma || !wma->wmi_handle) {
6256 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
6257 return QDF_STATUS_E_INVAL;
6258 }
6259 vdev_id = long_retry_limit_th->session_id;
6260 long_retry_limit = long_retry_limit_th->long_retry_limit;
6261 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
6262 vdev_id, long_retry_limit);
6263
6264 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
6265 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
6266 long_retry_limit);
6267
6268 if (ret) {
6269 WMA_LOGE("Failed to send long limit threshold command");
6270 return QDF_STATUS_E_FAILURE;
6271 }
6272
6273 return QDF_STATUS_SUCCESS;
6274}
6275
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05306276/*
6277 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
6278 * @wma_handle: WMA handle
6279 * @sta_inactivity_timer: sme_sta_inactivity_timeout
6280 *
6281 * This function is used to set sta_inactivity_timeout.
6282 * If a station does not send anything in sta_inactivity_timeout seconds, an
6283 * empty data frame is sent to it in order to verify whether it is
6284 * still in range. If this frame is not ACKed, the station will be
6285 * disassociated and then deauthenticated.
6286 *
6287 * Return: None
6288 */
6289void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
6290 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
6291{
6292 uint8_t vdev_id;
6293 uint32_t max_unresponsive_time;
6294 uint32_t min_inactive_time, max_inactive_time;
6295
6296 if (!wma || !wma->wmi_handle) {
6297 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
6298 return;
6299 }
6300 vdev_id = sta_inactivity_timer->session_id;
6301 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
6302 max_inactive_time = max_unresponsive_time * TWO_THIRD;
6303 min_inactive_time = max_unresponsive_time - max_inactive_time;
6304
6305 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6306 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
6307 min_inactive_time))
6308 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
6309
6310 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6311 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
6312 max_inactive_time))
6313 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
6314
6315 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
6316 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
6317 max_unresponsive_time))
6318 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
6319
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006320 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 +05306321 __func__, vdev_id,
6322 min_inactive_time, max_inactive_time,
6323 max_unresponsive_time);
6324}
6325
Yingying Tang95409972016-10-20 15:16:15 +08006326#ifdef WLAN_FEATURE_WOW_PULSE
6327
6328
6329#define WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
6330WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMD_fixed_param
6331
6332
6333#define WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
6334WMITLV_TAG_STRUC_wmi_wow_hostwakeup_gpio_pin_pattern_config_cmd_fixed_param
6335
6336/**
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006337 * wma_send_wow_pulse_cmd() - send wmi cmd of wow pulse cmd
6338 * information to fw.
6339 * @wma_handle: wma handler
6340 * @udp_response: wow_pulse_mode pointer
6341 *
6342 * Return: Return QDF_STATUS
6343 */
Yingying Tang95409972016-10-20 15:16:15 +08006344static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
6345 struct wow_pulse_mode *wow_pulse_cmd)
6346{
6347 QDF_STATUS status = QDF_STATUS_SUCCESS;
6348 wmi_buf_t buf;
6349 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *cmd;
6350 u_int16_t len;
6351
6352 len = sizeof(*cmd);
6353 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6354 if (!buf) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006355 WMA_LOGE("wmi_buf_alloc failed");
6356 return QDF_STATUS_E_NOMEM;
Yingying Tang95409972016-10-20 15:16:15 +08006357 }
6358
6359 cmd = (WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *)wmi_buf_data(buf);
6360 qdf_mem_zero(cmd, len);
6361
6362 WMITLV_SET_HDR(&cmd->tlv_header,
6363 WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM,
6364 WMITLV_GET_STRUCT_TLVLEN(
6365 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM));
6366
6367 cmd->enable = wow_pulse_cmd->wow_pulse_enable;
6368 cmd->pin = wow_pulse_cmd->wow_pulse_pin;
6369 cmd->interval_low = wow_pulse_cmd->wow_pulse_interval_low;
6370 cmd->interval_high = wow_pulse_cmd->wow_pulse_interval_high;
6371 cmd->repeat_cnt = WMI_WOW_PULSE_REPEAT_CNT;
6372
6373 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6374 WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID)) {
6375 WMA_LOGE("Failed to send send wow pulse");
6376 wmi_buf_free(buf);
6377 status = QDF_STATUS_E_FAILURE;
6378 }
6379
6380 WMA_LOGD("%s: Exit", __func__);
6381 return status;
6382}
6383
6384#undef WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
6385#undef WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
6386#undef WMI_WOW_PULSE_REPEAT_CNT
6387
6388#else
6389static inline QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
6390 struct wow_pulse_mode *wow_pulse_cmd)
6391{
6392 return QDF_STATUS_E_FAILURE;
6393}
6394#endif
6395
6396
Agrawal Ashishda3e9502016-09-21 17:43:51 +05306397/**
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05306398 * wma_process_power_debug_stats_req() - Process the Chip Power stats collect
6399 * request and pass the Power stats request to Fw
6400 * @wma_handle: WMA handle
6401 *
6402 * Return: QDF_STATUS
6403 */
6404#ifdef WLAN_POWER_DEBUGFS
6405static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
6406{
6407 wmi_pdev_get_chip_power_stats_cmd_fixed_param *cmd;
6408 int32_t len;
6409 wmi_buf_t buf;
6410 uint8_t *buf_ptr;
6411 int ret;
6412
6413 if (!wma_handle) {
6414 WMA_LOGE("%s: input pointer is NULL", __func__);
6415 return QDF_STATUS_E_FAILURE;
6416 }
6417
6418 len = sizeof(*cmd);
6419 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6420 if (!buf) {
6421 WMA_LOGE("%s: Failed allocate wmi buffer", __func__);
6422 return QDF_STATUS_E_NOMEM;
6423 }
6424
6425 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6426 cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr;
6427
6428 WMITLV_SET_HDR(&cmd->tlv_header,
6429 WMITLV_TAG_STRUC_wmi_get_chip_power_stats_cmd_fixed_param,
6430 WMITLV_GET_STRUCT_TLVLEN(
6431 wmi_pdev_get_chip_power_stats_cmd_fixed_param));
6432 cmd->pdev_id = 0;
6433
6434 WMA_LOGD("POWER_DEBUG_STATS - Get Request Params; Pdev id - %d",
6435 cmd->pdev_id);
6436 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6437 WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
6438 if (ret) {
6439 WMA_LOGE("%s: Failed to send power debug stats request",
6440 __func__);
6441 wmi_buf_free(buf);
6442 return QDF_STATUS_E_FAILURE;
6443 }
6444 return QDF_STATUS_SUCCESS;
6445}
6446#else
6447static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
6448{
6449 return QDF_STATUS_SUCCESS;
6450}
6451#endif
6452
lifeng66831662017-05-19 16:01:35 +08006453QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle,
6454 struct sir_set_rx_reorder_timeout_val *reorder_timeout)
6455{
6456 wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *cmd;
6457 uint32_t len;
6458 wmi_buf_t buf;
6459 int ret;
6460
6461 if (!reorder_timeout) {
6462 WMA_LOGE(FL("invalid pointer"));
6463 return QDF_STATUS_E_INVAL;
6464 }
6465
6466 if (!wma_handle) {
6467 WMA_LOGE(FL("WMA context is invald!"));
6468 return QDF_STATUS_E_INVAL;
6469 }
6470 len = sizeof(*cmd);
6471 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6472
6473 if (!buf) {
6474 WMA_LOGE(FL("Failed allocate wmi buffer"));
6475 return QDF_STATUS_E_NOMEM;
6476 }
6477 cmd = (wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *)
6478 wmi_buf_data(buf);
6479
6480 WMITLV_SET_HDR(&cmd->tlv_header,
6481 WMITLV_TAG_STRUC_wmi_pdev_set_reorder_timeout_val_cmd_fixed_param,
6482 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_reorder_timeout_val_cmd_fixed_param));
6483
6484 memcpy(cmd->rx_timeout_pri, reorder_timeout->rx_timeout_pri,
6485 sizeof(reorder_timeout->rx_timeout_pri));
6486
6487 WMA_LOGD("rx aggr record timeout: VO: %d, VI: %d, BE: %d, BK: %d",
6488 cmd->rx_timeout_pri[0], cmd->rx_timeout_pri[1],
6489 cmd->rx_timeout_pri[2], cmd->rx_timeout_pri[3]);
6490
6491 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6492 WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID);
6493 if (ret) {
6494 WMA_LOGE(FL("Failed to send aggregation timeout"));
6495 wmi_buf_free(buf);
6496 return QDF_STATUS_E_FAILURE;
6497 }
6498
6499 return QDF_STATUS_SUCCESS;
6500}
6501
6502QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle,
6503 struct sir_peer_set_rx_blocksize *peer_rx_blocksize)
6504{
6505 wmi_peer_set_rx_blocksize_cmd_fixed_param *cmd;
6506 int32_t len;
6507 wmi_buf_t buf;
6508 u_int8_t *buf_ptr;
6509 int ret;
6510
6511 if (!peer_rx_blocksize) {
6512 WMA_LOGE(FL("invalid pointer"));
6513 return QDF_STATUS_E_INVAL;
6514 }
6515
6516 if (!wma_handle) {
6517 WMA_LOGE(FL(" WMA context is invald!"));
6518 return QDF_STATUS_E_INVAL;
6519 }
6520
6521 len = sizeof(*cmd);
6522 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
6523
6524 if (!buf) {
6525 WMA_LOGE(FL("Failed allocate wmi buffer"));
6526 return QDF_STATUS_E_NOMEM;
6527 }
6528
6529 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6530 cmd = (wmi_peer_set_rx_blocksize_cmd_fixed_param *) buf_ptr;
6531
6532 WMITLV_SET_HDR(&cmd->tlv_header,
6533 WMITLV_TAG_STRUC_wmi_peer_set_rx_blocksize_cmd_fixed_param,
6534 WMITLV_GET_STRUCT_TLVLEN(wmi_peer_set_rx_blocksize_cmd_fixed_param));
6535
6536 cmd->vdev_id = peer_rx_blocksize->vdev_id;
6537 cmd->rx_block_ack_win_limit =
6538 peer_rx_blocksize->rx_block_ack_win_limit;
6539 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_rx_blocksize->peer_macaddr.bytes,
6540 &cmd->peer_macaddr);
6541
6542 WMA_LOGD("rx aggr blocksize: %d", cmd->rx_block_ack_win_limit);
6543
6544 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
6545 WMI_PEER_SET_RX_BLOCKSIZE_CMDID);
6546 if (ret) {
6547 WMA_LOGE(FL("Failed to send aggregation size command"));
6548 wmi_buf_free(buf);
6549 return QDF_STATUS_E_FAILURE;
6550 }
6551
6552 return QDF_STATUS_SUCCESS;
6553}
6554
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05306555/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006556 * wma_mc_process_msg() - process wma messages and call appropriate function.
6557 * @cds_context: cds context
6558 * @msg: message
6559 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306560 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006561 */
Rajeev Kumarb60abe42017-01-21 15:39:31 -08006562QDF_STATUS wma_mc_process_msg(void *cds_context, struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006563{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306564 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565 tp_wma_handle wma_handle;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08006566 struct cdp_vdev *txrx_vdev_handle = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006567 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05306568 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006569
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006570 if (NULL == msg) {
6571 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306572 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306573 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006574 goto end;
6575 }
6576
6577 WMA_LOGD("msg->type = %x %s", msg->type,
6578 mac_trace_get_wma_msg_string(msg->type));
6579
Anurag Chouhan6d760662016-02-20 16:05:43 +05306580 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006581
6582 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006583 WMA_LOGE("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306584 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306585 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306586 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006587 goto end;
6588 }
6589
6590 switch (msg->type) {
6591
6592 /* Message posted by wmi for all control path related
6593 * FW events to serialize through mc_thread.
6594 */
6595 case WMA_PROCESS_FW_EVENT:
6596 wma_process_fw_event(wma_handle,
6597 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306598 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006599 break;
6600
6601#ifdef FEATURE_WLAN_ESE
6602 case WMA_TSM_STATS_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006603 WMA_LOGD("McThread: WMA_TSM_STATS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006604 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
6605 break;
6606#endif /* FEATURE_WLAN_ESE */
6607 case WNI_CFG_DNLD_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006608 WMA_LOGD("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306609 qdf_status = wma_wni_cfg_dnld(wma_handle);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006610 if (QDF_IS_STATUS_SUCCESS(qdf_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006611 cds_wma_complete_cback(cds_context);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006612 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006613 WMA_LOGD("config download failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006614 break;
6615 case WMA_ADD_STA_SELF_REQ:
6616 txrx_vdev_handle =
6617 wma_vdev_attach(wma_handle,
6618 (struct add_sta_self_params *) msg->
6619 bodyptr, 1);
6620 if (!txrx_vdev_handle) {
6621 WMA_LOGE("Failed to attach vdev");
6622 } else {
6623 /* Register with TxRx Module for Data Ack Complete Cb */
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05306624 if (soc) {
6625 cdp_data_tx_cb_set(soc, txrx_vdev_handle,
6626 wma_data_tx_ack_comp_hdlr,
6627 wma_handle);
6628 } else {
6629 WMA_LOGE("%s: SOC context is NULL", __func__);
6630 qdf_status = QDF_STATUS_E_FAILURE;
6631 goto end;
6632 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006633 }
6634 break;
6635 case WMA_DEL_STA_SELF_REQ:
6636 wma_vdev_detach(wma_handle,
6637 (struct del_sta_self_params *) msg->bodyptr, 1);
6638 break;
6639 case WMA_START_SCAN_OFFLOAD_REQ:
6640 wma_start_scan(wma_handle, msg->bodyptr, msg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306641 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006642 break;
6643 case WMA_STOP_SCAN_OFFLOAD_REQ:
6644 wma_stop_scan(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306645 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006646 break;
6647 case WMA_UPDATE_CHAN_LIST_REQ:
6648 wma_update_channel_list(wma_handle,
6649 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306650 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006651 break;
6652 case WMA_SET_LINK_STATE:
6653 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
6654 break;
6655 case WMA_CHNL_SWITCH_REQ:
6656 wma_set_channel(wma_handle,
6657 (tpSwitchChannelParams) msg->bodyptr);
6658 break;
6659 case WMA_ADD_BSS_REQ:
6660 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
6661 break;
6662 case WMA_ADD_STA_REQ:
6663 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
6664 break;
6665 case WMA_SET_BSSKEY_REQ:
6666 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
6667 break;
6668 case WMA_SET_STAKEY_REQ:
6669 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
6670 break;
6671 case WMA_DELETE_STA_REQ:
6672 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
6673 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07006674 case WMA_DELETE_BSS_HO_FAIL_REQ:
6675 wma_delete_bss_ho_fail(wma_handle,
6676 (tpDeleteBssParams) msg->bodyptr);
6677 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006678 case WMA_DELETE_BSS_REQ:
6679 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
6680 break;
6681 case WMA_UPDATE_EDCA_PROFILE_IND:
6682 wma_process_update_edca_param_req(wma_handle,
6683 (tEdcaParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306684 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006685 break;
6686 case WMA_SEND_BEACON_REQ:
6687 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306688 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006689 break;
6690 case WMA_SEND_PROBE_RSP_TMPL:
6691 wma_send_probe_rsp_tmpl(wma_handle,
6692 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306693 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006694 break;
6695 case WMA_CLI_SET_CMD:
6696 wma_process_cli_set_cmd(wma_handle,
6697 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306698 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006699 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07006700 case WMA_SET_PDEV_IE_REQ:
6701 wma_process_set_pdev_ie_req(wma_handle,
6702 (struct set_ie_param *)msg->bodyptr);
6703 qdf_mem_free(msg->bodyptr);
6704 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006705#if !defined(REMOVE_PKT_LOG)
6706 case WMA_PKTLOG_ENABLE_REQ:
6707 wma_pktlog_wmi_send_cmd(wma_handle,
6708 (struct ath_pktlog_wmi_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306709 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006710 break;
6711#endif /* REMOVE_PKT_LOG */
6712#if defined(QCA_WIFI_FTM)
6713 case WMA_FTM_CMD_REQ:
6714 wma_process_ftm_command(wma_handle,
6715 (struct ar6k_testmode_cmd_data *)msg->bodyptr);
6716 break;
6717#endif /* QCA_WIFI_FTM */
6718 case WMA_ENTER_PS_REQ:
6719 wma_enable_sta_ps_mode(wma_handle,
6720 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306721 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006722 break;
6723 case WMA_EXIT_PS_REQ:
6724 wma_disable_sta_ps_mode(wma_handle,
6725 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306726 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006727 break;
6728 case WMA_ENABLE_UAPSD_REQ:
6729 wma_enable_uapsd_mode(wma_handle,
6730 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306731 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006732 break;
6733 case WMA_DISABLE_UAPSD_REQ:
6734 wma_disable_uapsd_mode(wma_handle,
6735 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306736 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006737 break;
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -07006738 case WMA_SET_DTIM_PERIOD:
6739 wma_set_dtim_period(wma_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006740 (struct set_dtim_params *)msg->bodyptr);
Kiran Kumar Lokere92fe7592016-09-14 20:15:45 -07006741 qdf_mem_free(msg->bodyptr);
6742 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006743 case WMA_SET_TX_POWER_REQ:
6744 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
6745 break;
6746 case WMA_SET_MAX_TX_POWER_REQ:
6747 wma_set_max_tx_power(wma_handle,
6748 (tpMaxTxPowerParams) msg->bodyptr);
6749 break;
6750 case WMA_SET_KEEP_ALIVE:
6751 wma_set_keepalive_req(wma_handle,
6752 (tSirKeepAliveReq *) msg->bodyptr);
6753 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08006754#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006755 case WMA_SET_PLM_REQ:
6756 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
6757 break;
6758#endif
6759 case WMA_GET_STATISTICS_REQ:
6760 wma_get_stats_req(wma_handle,
6761 (tAniGetPEStatsReq *) msg->bodyptr);
6762 break;
6763
6764 case WMA_CONFIG_PARAM_UPDATE_REQ:
Rajeev Kumar156188e2017-01-21 17:23:52 -08006765 wma_update_cfg_params(wma_handle, msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006766 break;
6767
6768 case WMA_UPDATE_OP_MODE:
6769 wma_process_update_opmode(wma_handle,
6770 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306771 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006772 break;
6773 case WMA_UPDATE_RX_NSS:
6774 wma_process_update_rx_nss(wma_handle,
6775 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306776 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006777 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006778 case WMA_UPDATE_MEMBERSHIP:
6779 wma_process_update_membership(wma_handle,
6780 (tUpdateMembership *) msg->bodyptr);
6781 break;
6782 case WMA_UPDATE_USERPOS:
6783 wma_process_update_userpos(wma_handle,
6784 (tUpdateUserPos *) msg->bodyptr);
6785 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006786 case WMA_UPDATE_BEACON_IND:
6787 wma_process_update_beacon_params(wma_handle,
6788 (tUpdateBeaconParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306789 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006790 break;
6791
6792 case WMA_ADD_TS_REQ:
6793 wma_add_ts_req(wma_handle, (tAddTsParams *) msg->bodyptr);
6794 break;
6795
6796 case WMA_DEL_TS_REQ:
6797 wma_del_ts_req(wma_handle, (tDelTsParams *) msg->bodyptr);
6798 break;
6799
6800 case WMA_AGGR_QOS_REQ:
6801 wma_aggr_qos_req(wma_handle, (tAggrAddTsParams *) msg->bodyptr);
6802 break;
6803
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006804 case WMA_WOW_ADD_PTRN:
6805 wma_wow_add_pattern(wma_handle,
6806 (struct wow_add_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306807 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006808 break;
6809 case WMA_WOW_DEL_PTRN:
6810 wma_wow_delete_user_pattern(wma_handle,
6811 (struct wow_delete_pattern *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306812 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006813 break;
6814 case WMA_WOWL_ENTER_REQ:
6815 wma_wow_enter(wma_handle,
6816 (tpSirHalWowlEnterParams) msg->bodyptr);
6817 break;
6818 case WMA_WOWL_EXIT_REQ:
6819 wma_wow_exit(wma_handle, (tpSirHalWowlExitParams) msg->bodyptr);
6820 break;
Houston Hoffmana76591b2015-11-10 16:52:05 -08006821
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006822 case WMA_8023_MULTICAST_LIST_REQ:
6823 wma_process_mcbc_set_filter_req(wma_handle,
6824 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306825 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006826 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006827 case WMA_ROAM_SCAN_OFFLOAD_REQ:
6828 /*
6829 * Main entry point or roaming directives from CSR.
6830 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08006831 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006832 (tSirRoamOffloadScanReq *) msg->bodyptr);
6833 break;
6834
6835 case WMA_RATE_UPDATE_IND:
6836 wma_process_rate_update_indicate(wma_handle,
6837 (tSirRateUpdateInd *) msg->bodyptr);
6838 break;
6839
6840#ifdef FEATURE_WLAN_TDLS
6841 case WMA_UPDATE_FW_TDLS_STATE:
6842 wma_update_fw_tdls_state(wma_handle,
6843 (t_wma_tdls_params *) msg->bodyptr);
6844 break;
6845 case WMA_UPDATE_TDLS_PEER_STATE:
6846 wma_update_tdls_peer_state(wma_handle,
6847 (tTdlsPeerStateParams *) msg->bodyptr);
6848 break;
6849 case WMA_TDLS_SET_OFFCHAN_MODE:
6850 wma_set_tdls_offchan_mode(wma_handle,
6851 (tdls_chan_switch_params *)msg->bodyptr);
6852 break;
6853#endif /* FEATURE_WLAN_TDLS */
6854 case WMA_ADD_PERIODIC_TX_PTRN_IND:
6855 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
6856 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306857 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006858 break;
6859 case WMA_DEL_PERIODIC_TX_PTRN_IND:
6860 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
6861 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306862 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006863 break;
6864 case WMA_TX_POWER_LIMIT:
6865 wma_process_tx_power_limits(wma_handle,
6866 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306867 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006868 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006869#ifdef FEATURE_WLAN_CH_AVOID
6870 case WMA_CH_AVOID_UPDATE_REQ:
6871 wma_process_ch_avoid_update_req(wma_handle,
6872 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306873 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006874 break;
6875#endif /* FEATURE_WLAN_CH_AVOID */
6876#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
6877 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
6878 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306879 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006880 break;
6881#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
6882 case WMA_DHCP_START_IND:
6883 case WMA_DHCP_STOP_IND:
6884 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306885 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006886 break;
6887
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08006888 case WMA_IBSS_CESIUM_ENABLE_IND:
6889 wma_process_cesium_enable_ind(wma_handle);
6890 break;
6891 case WMA_GET_IBSS_PEER_INFO_REQ:
6892 wma_process_get_peer_info_req(wma_handle,
6893 (tSirIbssGetPeerInfoReqParams *)
6894 msg->bodyptr);
6895 qdf_mem_free(msg->bodyptr);
6896 break;
6897 case WMA_TX_FAIL_MONITOR_IND:
6898 wma_process_tx_fail_monitor_ind(wma_handle,
6899 (tAniTXFailMonitorInd *) msg->bodyptr);
6900 qdf_mem_free(msg->bodyptr);
6901 break;
6902
6903 case WMA_RMC_ENABLE_IND:
6904 wma_process_rmc_enable_ind(wma_handle);
6905 break;
6906 case WMA_RMC_DISABLE_IND:
6907 wma_process_rmc_disable_ind(wma_handle);
6908 break;
6909 case WMA_RMC_ACTION_PERIOD_IND:
6910 wma_process_rmc_action_period_ind(wma_handle);
6911 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006912 case WMA_INIT_THERMAL_INFO_CMD:
6913 wma_process_init_thermal_info(wma_handle,
6914 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306915 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006916 break;
6917
6918 case WMA_SET_THERMAL_LEVEL:
6919 wma_process_set_thermal_level(wma_handle, msg->bodyval);
6920 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05306921#ifdef CONFIG_HL_SUPPORT
6922 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
6923 wma_process_init_bad_peer_tx_ctl_info(
6924 wma_handle,
6925 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
6926 qdf_mem_free(msg->bodyptr);
6927 break;
6928#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006929 case WMA_SET_P2P_GO_NOA_REQ:
6930 wma_process_set_p2pgo_noa_req(wma_handle,
6931 (tP2pPsParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306932 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006933 break;
6934 case WMA_SET_MIMOPS_REQ:
6935 wma_process_set_mimops_req(wma_handle,
6936 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306937 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006938 break;
6939 case WMA_SET_SAP_INTRABSS_DIS:
6940 wma_set_vdev_intrabss_fwd(wma_handle,
6941 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306942 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006943 break;
Will Huanga9814592017-05-24 15:47:58 +08006944 case WMA_GET_PEER_INFO:
6945 wma_get_peer_info(wma_handle, msg->bodyptr);
6946 qdf_mem_free(msg->bodyptr);
6947 break;
6948 case WMA_GET_PEER_INFO_EXT:
6949 wma_get_peer_info_ext(wma_handle, msg->bodyptr);
6950 qdf_mem_free(msg->bodyptr);
6951 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006952 case WMA_MODEM_POWER_STATE_IND:
6953 wma_notify_modem_power_state(wma_handle,
6954 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306955 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006956 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006957#ifdef WLAN_FEATURE_STATS_EXT
6958 case WMA_STATS_EXT_REQUEST:
6959 wma_stats_ext_req(wma_handle,
6960 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306961 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006962 break;
6963#endif /* WLAN_FEATURE_STATS_EXT */
6964 case WMA_HIDDEN_SSID_VDEV_RESTART:
6965 wma_hidden_ssid_vdev_restart(wma_handle,
6966 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006967 break;
6968#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
6969 case WMA_WLAN_EXT_WOW:
6970 wma_enable_ext_wow(wma_handle,
6971 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306972 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973 break;
6974 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
6975 wma_set_app_type1_params_in_fw(wma_handle,
6976 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306977 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006978 break;
6979 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
6980 wma_set_app_type2_params_in_fw(wma_handle,
6981 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306982 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006983 break;
6984#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
6985#ifdef FEATURE_WLAN_EXTSCAN
6986 case WMA_EXTSCAN_START_REQ:
6987 wma_start_extscan(wma_handle,
6988 (tSirWifiScanCmdReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306989 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006990 break;
6991 case WMA_EXTSCAN_STOP_REQ:
6992 wma_stop_extscan(wma_handle,
6993 (tSirExtScanStopReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306994 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006995 break;
6996 case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:
6997 wma_extscan_start_hotlist_monitor(wma_handle,
6998 (tSirExtScanSetBssidHotListReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306999 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007000 break;
7001 case WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
7002 wma_extscan_stop_hotlist_monitor(wma_handle,
7003 (tSirExtScanResetBssidHotlistReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307004 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007005 break;
7006 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
7007 wma_extscan_start_change_monitor(wma_handle,
7008 (tSirExtScanSetSigChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307009 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007010 break;
7011 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
7012 wma_extscan_stop_change_monitor(wma_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007013 (tSirExtScanResetSignificantChangeReqParams *)
7014 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307015 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007016 break;
7017 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
7018 wma_extscan_get_cached_results(wma_handle,
7019 (tSirExtScanGetCachedResultsReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307020 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007021 break;
7022 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
7023 wma_extscan_get_capabilities(wma_handle,
7024 (tSirGetExtScanCapabilitiesReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307025 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007026 break;
7027 case WMA_SET_EPNO_LIST_REQ:
7028 wma_set_epno_network_list(wma_handle,
7029 (struct wifi_epno_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307030 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007031 break;
Kapil Gupta5cda2252016-12-29 18:44:26 +05307032 case WMA_SET_PER_ROAM_CONFIG_CMD:
7033 wma_update_per_roam_config(wma_handle,
7034 (struct wmi_per_roam_config_req *)msg->bodyptr);
7035 qdf_mem_free(msg->bodyptr);
7036 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007037 case WMA_SET_PASSPOINT_LIST_REQ:
7038 /* Issue reset passpoint network list first and clear
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007039 * the entries
7040 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007041 wma_reset_passpoint_network_list(wma_handle,
7042 (struct wifi_passpoint_req *)msg->bodyptr);
7043
7044 wma_set_passpoint_network_list(wma_handle,
7045 (struct wifi_passpoint_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307046 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007047 break;
7048 case WMA_RESET_PASSPOINT_LIST_REQ:
7049 wma_reset_passpoint_network_list(wma_handle,
7050 (struct wifi_passpoint_req *)msg->bodyptr);
7051 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007052#endif /* FEATURE_WLAN_EXTSCAN */
7053 case WMA_SET_SCAN_MAC_OUI_REQ:
7054 wma_scan_probe_setoui(wma_handle, 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#ifdef WLAN_FEATURE_LINK_LAYER_STATS
7058 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
7059 wma_process_ll_stats_clear_req(wma_handle,
7060 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307061 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007062 break;
7063 case WMA_LINK_LAYER_STATS_SET_REQ:
7064 wma_process_ll_stats_set_req(wma_handle,
7065 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307066 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007067 break;
7068 case WMA_LINK_LAYER_STATS_GET_REQ:
7069 wma_process_ll_stats_get_req(wma_handle,
7070 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307071 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007072 break;
Zhang Qian73c348a2017-03-13 16:15:55 +08007073 case WDA_LINK_LAYER_STATS_SET_THRESHOLD:
7074 wma_config_stats_ext_threshold(wma_handle,
7075 (struct sir_ll_ext_stats_threshold *)msg->bodyptr);
7076 qdf_mem_free(msg->bodyptr);
7077 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007078#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
7079 case SIR_HAL_UNIT_TEST_CMD:
7080 wma_process_unit_test_cmd(wma_handle,
7081 (t_wma_unit_test_cmd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307082 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007083 break;
7084#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007085 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
7086 wma_process_roam_synch_fail(wma_handle,
7087 (struct roam_offload_synch_fail *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307088 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089 break;
7090 case SIR_HAL_ROAM_INVOKE:
7091 wma_process_roam_invoke(wma_handle,
7092 (struct wma_roam_invoke_cmd *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307093 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007094 break;
7095#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
7096#ifdef WLAN_FEATURE_NAN
7097 case WMA_NAN_REQUEST:
7098 wma_nan_req(wma_handle, (tNanRequest *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307099 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007100 break;
7101#endif /* WLAN_FEATURE_NAN */
7102 case SIR_HAL_SET_BASE_MACADDR_IND:
7103 wma_set_base_macaddr_indicate(wma_handle,
7104 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307105 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007106 break;
7107 case WMA_LINK_STATUS_GET_REQ:
7108 wma_process_link_status_req(wma_handle,
7109 (tAniGetLinkStatus *) msg->bodyptr);
7110 break;
7111 case WMA_GET_TEMPERATURE_REQ:
7112 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307113 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007114 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07007115 case WMA_TSF_GPIO_PIN:
7116 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
7117 break;
7118
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007119#ifdef DHCP_SERVER_OFFLOAD
7120 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
7121 wma_process_dhcpserver_offload(wma_handle,
7122 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307123 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007124 break;
7125#endif /* DHCP_SERVER_OFFLOAD */
7126#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
7127 case WMA_LED_FLASHING_REQ:
7128 wma_set_led_flashing(wma_handle,
7129 (tSirLedFlashingReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307130 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007131 break;
7132#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
7133 case SIR_HAL_SET_MAS:
7134 wma_process_set_mas(wma_handle,
7135 (uint32_t *)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 SIR_HAL_SET_MIRACAST:
7139 wma_process_set_miracast(wma_handle,
7140 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307141 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007142 break;
7143 case SIR_HAL_CONFIG_STATS_FACTOR:
7144 wma_config_stats_factor(wma_handle,
7145 (struct sir_stats_avg_factor *)
7146 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307147 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007148 break;
7149 case SIR_HAL_CONFIG_GUARD_TIME:
7150 wma_config_guard_time(wma_handle,
7151 (struct sir_guard_time_request *)
7152 msg->bodyptr);
7153 case WMA_IPA_OFFLOAD_ENABLE_DISABLE:
7154 wma_ipa_offload_enable_disable(wma_handle,
7155 (struct sir_ipa_offload_enable_disable *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307156 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007157 break;
7158 case SIR_HAL_START_STOP_LOGGING:
7159 wma_set_wifi_start_packet_stats(wma_handle,
7160 (struct sir_wifi_start_log *)msg->bodyptr);
7161 wma_enable_specific_fw_logs(wma_handle,
7162 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307163 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007164 break;
7165 case SIR_HAL_FLUSH_LOG_TO_FW:
7166 wma_send_flush_logs_to_fw(wma_handle);
7167 /* Body ptr is NULL here */
7168 break;
7169 case WMA_SET_RSSI_MONITOR_REQ:
7170 wma_set_rssi_monitoring(wma_handle,
7171 (struct rssi_monitor_req *)msg->bodyptr);
Prakash Dhavali87ddca32016-11-29 17:02:11 -08007172 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007173 break;
7174 case WMA_FW_MEM_DUMP_REQ:
7175 wma_process_fw_mem_dump_req(wma_handle,
7176 (struct fw_dump_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307177 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007178 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307179 case SIR_HAL_PDEV_SET_PCL_TO_FW:
7180 wma_send_pdev_set_pcl_cmd(wma_handle,
7181 (struct wmi_pcl_chan_weights *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307182 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007183 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307184 case SIR_HAL_PDEV_SET_HW_MODE:
7185 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007186 (struct policy_mgr_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307187 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007188 break;
7189 case WMA_OCB_SET_CONFIG_CMD:
7190 wma_ocb_set_config_req(wma_handle,
7191 (struct sir_ocb_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307192 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007193 break;
7194 case WMA_OCB_SET_UTC_TIME_CMD:
7195 wma_ocb_set_utc_time(wma_handle,
7196 (struct sir_ocb_utc *)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 case WMA_OCB_START_TIMING_ADVERT_CMD:
7200 wma_ocb_start_timing_advert(wma_handle,
7201 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307202 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007203 break;
7204 case WMA_OCB_STOP_TIMING_ADVERT_CMD:
7205 wma_ocb_stop_timing_advert(wma_handle,
7206 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307207 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007208 break;
7209 case WMA_DCC_CLEAR_STATS_CMD:
7210 wma_dcc_clear_stats(wma_handle,
7211 (struct sir_dcc_clear_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307212 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007213 break;
7214 case WMA_OCB_GET_TSF_TIMER_CMD:
7215 wma_ocb_get_tsf_timer(wma_handle,
7216 (struct sir_ocb_get_tsf_timer *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307217 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007218 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07007219 case WMA_SET_WISA_PARAMS:
7220 wma_set_wisa_params(wma_handle,
7221 (struct sir_wisa_params *)msg->bodyptr);
7222 qdf_mem_free(msg->bodyptr);
7223 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007224 case WMA_DCC_GET_STATS_CMD:
7225 wma_dcc_get_stats(wma_handle,
7226 (struct sir_dcc_get_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307227 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007228 break;
7229 case WMA_DCC_UPDATE_NDL_CMD:
7230 wma_dcc_update_ndl(wma_handle,
7231 (struct sir_dcc_update_ndl *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307232 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007233 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307234 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
7235 wma_send_pdev_set_dual_mac_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236 (struct sir_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307237 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007238 break;
7239 case WMA_SET_IE_INFO:
7240 wma_process_set_ie_info(wma_handle,
7241 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307242 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007243 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007244 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
7245 wma_send_pdev_set_antenna_mode(wma_handle,
7246 (struct sir_antenna_mode_param *)msg->bodyptr);
7247 qdf_mem_free(msg->bodyptr);
7248 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007249 case WMA_LRO_CONFIG_CMD:
7250 wma_lro_config_cmd(wma_handle,
Dhanashri Atre09828f12016-11-13 10:36:58 -08007251 (struct cdp_lro_hash_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307252 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007253 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08007254 case WMA_GW_PARAM_UPDATE_REQ:
7255 wma_set_gateway_params(wma_handle,
7256 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08007257 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08007258 break;
7259 case WMA_SET_EGAP_CONF_PARAMS:
7260 wma_send_egap_conf_params(wma_handle,
7261 (struct egap_conf_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307262 qdf_mem_free(msg->bodyptr);
Ravi Joshi9e891ba2015-11-09 19:03:46 -08007263 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05307264 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
7265 wma_send_adapt_dwelltime_params(wma_handle,
7266 (struct adaptive_dwelltime_params *)msg->bodyptr);
7267 qdf_mem_free(msg->bodyptr);
7268 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08007269 case WMA_HT40_OBSS_SCAN_IND:
7270 wma_send_ht40_obss_scanind(wma_handle,
7271 (struct obss_ht40_scanind *)msg->bodyptr);
7272 qdf_mem_free(msg->bodyptr);
7273 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07007274 case WMA_ADD_BCN_FILTER_CMDID:
7275 wma_add_beacon_filter(wma_handle, msg->bodyptr);
7276 qdf_mem_free(msg->bodyptr);
7277 break;
7278 case WMA_REMOVE_BCN_FILTER_CMDID:
7279 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
7280 qdf_mem_free(msg->bodyptr);
7281 break;
Arun Khandavalli2476ef52016-04-26 20:19:43 +05307282 case WDA_BPF_GET_CAPABILITIES_REQ:
7283 wma_get_bpf_capabilities(wma_handle);
7284 break;
7285 case WDA_BPF_SET_INSTRUCTIONS_REQ:
7286 wma_set_bpf_instructions(wma_handle, msg->bodyptr);
7287 qdf_mem_free(msg->bodyptr);
7288 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07007289 case SIR_HAL_NDP_INITIATOR_REQ:
7290 wma_handle_ndp_initiator_req(wma_handle, msg->bodyptr);
7291 qdf_mem_free(msg->bodyptr);
7292 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07007293
Abhishek Singh4fef7472016-06-06 11:36:03 -07007294 case SIR_HAL_NDP_RESPONDER_REQ:
7295 wma_handle_ndp_responder_req(wma_handle, msg->bodyptr);
Naveen Rawatf28315c2016-06-29 18:06:02 -07007296 break;
7297
7298 case SIR_HAL_NDP_END_REQ:
7299 wma_handle_ndp_end_req(wma_handle, msg->bodyptr);
Abhishek Singh4fef7472016-06-06 11:36:03 -07007300 qdf_mem_free(msg->bodyptr);
7301 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05307302 case SIR_HAL_POWER_DBG_CMD:
7303 wma_process_hal_pwr_dbg_cmd(wma_handle,
7304 msg->bodyptr);
7305 qdf_mem_free(msg->bodyptr);
7306 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307307 case WMA_UPDATE_WEP_DEFAULT_KEY:
7308 wma_update_wep_default_key(wma_handle,
7309 (struct wep_update_default_key_idx *)msg->bodyptr);
7310 qdf_mem_free(msg->bodyptr);
7311 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05307312 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
7313 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
7314 break;
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05307315 case WMA_ENCRYPT_DECRYPT_MSG:
7316 wma_encrypt_decrypt_msg(wma_handle, msg->bodyptr);
7317 qdf_mem_free(msg->bodyptr);
7318 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307319 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
7320 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
7321 qdf_mem_free(msg->bodyptr);
7322 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307323 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
7324 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
7325 qdf_mem_free(msg->bodyptr);
7326 break;
7327 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
7328 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
7329 qdf_mem_free(msg->bodyptr);
7330 break;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307331 case SIR_HAL_POWER_DEBUG_STATS_REQ:
7332 wma_process_power_debug_stats_req(wma_handle);
7333 break;
Yingying Tang95409972016-10-20 15:16:15 +08007334 case WMA_SET_WOW_PULSE_CMD:
7335 wma_send_wow_pulse_cmd(wma_handle,
7336 (struct wow_pulse_mode *)msg->bodyptr);
7337 qdf_mem_free(msg->bodyptr);
7338 break;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05307339 case WMA_SET_DBS_SCAN_SEL_CONF_PARAMS:
7340 wma_send_dbs_scan_selection_params(wma_handle,
7341 (struct wmi_dbs_scan_sel_params *)msg->bodyptr);
7342 qdf_mem_free(msg->bodyptr);
7343 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007344 default:
Dustin Brown86534fb2017-01-24 14:28:20 -08007345 WMA_LOGE("Unhandled WMA message of type %d", msg->type);
7346 if (msg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307347 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007348 }
7349end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307350 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007351}
7352
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007353QDF_STATUS wma_mc_process_handler(struct scheduler_msg *msg)
7354{
7355 void *cds_ctx = cds_get_global_context();
7356
7357 if (cds_ctx == NULL) {
7358 QDF_TRACE(QDF_MODULE_ID_SYS, QDF_TRACE_LEVEL_ERROR,
7359 "CDS context is NULL");
7360 return QDF_STATUS_E_FAILURE;
7361 }
Rajeev Kumar156188e2017-01-21 17:23:52 -08007362 return wma_mc_process_msg(cds_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007363}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07007364
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007365/**
7366 * wma_log_completion_timeout() - Log completion timeout
7367 * @data: Timeout handler data
7368 *
7369 * This function is called when log completion timer expires
7370 *
7371 * Return: None
7372 */
7373void wma_log_completion_timeout(void *data)
7374{
7375 tp_wma_handle wma_handle;
7376
7377 WMA_LOGE("%s: Timeout occured for log completion command", __func__);
7378
7379 wma_handle = (tp_wma_handle) data;
7380 if (!wma_handle)
7381 WMA_LOGE("%s: Invalid WMA handle", __func__);
7382
7383 /* Though we did not receive any event from FW,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007384 * we can flush whatever logs we have with us
7385 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007386 cds_logging_set_fw_flush_complete();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007387}
7388
7389/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05307390 * wma_map_pcl_weights() - Map PCL weights
7391 * @pcl_weight: Internal PCL weights
7392 *
7393 * Maps the internal weights of PCL to the weights needed by FW
7394 *
7395 * Return: Mapped channel weight of type wmi_pcl_chan_weight
7396 */
7397static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
7398{
7399 switch (pcl_weight) {
7400 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
7401 return WMI_PCL_WEIGHT_VERY_HIGH;
7402 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
7403 return WMI_PCL_WEIGHT_HIGH;
7404 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
7405 return WMI_PCL_WEIGHT_MEDIUM;
7406 case WEIGHT_OF_NON_PCL_CHANNELS:
7407 return WMI_PCL_WEIGHT_LOW;
7408 default:
7409 return WMI_PCL_WEIGHT_DISALLOW;
7410 }
7411}
7412
7413/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307414 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007415 * @wma_handle: WMA handle
7416 * @msg: PCL structure containing the PCL and the number of channels
7417 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307418 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007419 * firmware. The DBS Manager is the consumer of this information in the WLAN
7420 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
7421 * to migrate to a new channel without host driver involvement. An example of
7422 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
7423 * manage the channel selection without firmware involvement.
7424 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307425 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
7426 * channel list. The weights corresponds to the channels sent in
7427 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
7428 * weightage compared to the non PCL channels.
7429 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430 * Return: Success if the cmd is sent successfully to the firmware
7431 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307432QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
7433 struct wmi_pcl_chan_weights *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007434{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307435 uint32_t i;
7436 QDF_STATUS status;
7437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007438 if (!wma_handle) {
7439 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7440 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307441 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442 }
7443
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307444 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
7445 msg->saved_chan_list[i] =
7446 wma_handle->saved_chan.channel_list[i];
7447 }
7448
7449 msg->saved_num_chan = wma_handle->saved_chan.num_channels;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007450 status = policy_mgr_get_valid_chan_weights(wma_handle->psoc,
7451 (struct policy_mgr_pcl_chan_weights *)msg);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05307452
7453 for (i = 0; i < msg->saved_num_chan; i++) {
7454 msg->weighed_valid_list[i] =
7455 wma_map_pcl_weights(msg->weighed_valid_list[i]);
7456 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
7457 msg->saved_chan_list[i], i,
7458 msg->weighed_valid_list[i]);
7459 }
7460
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05307461 if (!QDF_IS_STATUS_SUCCESS(status)) {
7462 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
7463 return status;
7464 }
7465
7466 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle, msg))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307467 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05307468
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307469 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007470}
7471
7472/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307473 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007474 * @wma_handle: WMA handle
7475 * @msg: Structure containing the following parameters
7476 *
7477 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
7478 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
7479 *
7480 * Provides notification to the WLAN firmware that host driver is requesting a
7481 * HardWare (HW) Mode change. This command is needed to support iHelium in the
7482 * configurations that include the Dual Band Simultaneous (DBS) feature.
7483 *
7484 * Return: Success if the cmd is sent successfully to the firmware
7485 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307486QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007487 struct policy_mgr_hw_mode *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007488{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007489 struct sir_set_hw_mode_resp *param;
7490
7491 if (!wma_handle) {
7492 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7493 __func__);
7494 /* Handle is NULL. Will not be able to send failure
7495 * response as well
7496 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307497 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007498 }
7499
7500 if (!msg) {
7501 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
7502 /* Lets try to free the active command list */
7503 goto fail;
7504 }
7505
Krunal Sonicebcc292017-06-14 19:59:20 -07007506 wma_acquire_wmi_resp_wakelock(wma_handle,
7507 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT);
Govind Singhf25a0f12016-03-08 16:09:48 +05307508 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
Krunal Sonicebcc292017-06-14 19:59:20 -07007509 msg->hw_mode_index)) {
7510 wma_release_wmi_resp_wakelock(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007511 goto fail;
Krunal Sonicebcc292017-06-14 19:59:20 -07007512 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007513
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307514 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007515fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307516 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007517 if (!param) {
7518 WMA_LOGE("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307519 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007520 }
7521 param->status = SET_HW_MODE_STATUS_ECANCELED;
7522 param->cfgd_hw_mode_index = 0;
7523 param->num_vdev_mac_entries = 0;
7524 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05307525 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007526 (void *) param, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307527 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007528}
7529
7530/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307531 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007532 * @wma_handle: WMA handle
7533 * @msg: Dual MAC config parameters
7534 *
7535 * Configures WLAN firmware with the dual MAC features
7536 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307537 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007538 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307539QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007540 struct sir_dual_mac_config *msg)
7541{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307542 QDF_STATUS status;
7543
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007544 if (!wma_handle) {
7545 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7546 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307547 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007548 }
7549
7550 if (!msg) {
7551 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307552 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007553 }
7554
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307555 status = wmi_unified_pdev_set_dual_mac_config_cmd(
7556 wma_handle->wmi_handle,
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307557 (struct wmi_dual_mac_config *)msg);
7558 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05307559 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05307560 __func__, status);
7561 return status;
7562 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07007563 policy_mgr_update_dbs_req_config(wma_handle->psoc,
7564 msg->scan_config, msg->fw_mode_config);
Govind Singhf25a0f12016-03-08 16:09:48 +05307565
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307566 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007567}
7568
7569/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007570 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
7571 * @wma_handle: WMA handle
7572 * @msg: Antenna mode parameters
7573 *
7574 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
7575 * modify the number of TX/RX chains from host
7576 *
7577 * Return: QDF_STATUS. 0 on success.
7578 */
7579QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
7580 struct sir_antenna_mode_param *msg)
7581{
7582 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
7583 wmi_buf_t buf;
7584 uint32_t len;
7585 QDF_STATUS status = QDF_STATUS_SUCCESS;
7586 struct sir_antenna_mode_resp *param;
7587
7588 if (!wma_handle) {
7589 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
7590 __func__);
7591 return QDF_STATUS_E_NULL_VALUE;
7592 }
7593
7594 if (!msg) {
7595 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
7596 return QDF_STATUS_E_NULL_VALUE;
7597 }
7598
7599 len = sizeof(*cmd);
7600
7601 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7602 if (!buf) {
7603 WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
7604 status = QDF_STATUS_E_NOMEM;
7605 goto resp;
7606 }
7607
7608 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
7609 WMITLV_SET_HDR(&cmd->tlv_header,
7610 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
7611 WMITLV_GET_STRUCT_TLVLEN(
7612 wmi_pdev_set_antenna_mode_cmd_fixed_param));
7613
7614 cmd->pdev_id = WMI_PDEV_ID_SOC;
7615 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
7616 cmd->num_txrx_chains = msg->num_rx_chains;
7617 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
7618
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007619 WMA_LOGD("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
Archana Ramachandrana20ef812015-11-13 16:12:13 -08007620 __func__, msg->num_tx_chains,
7621 msg->num_rx_chains, cmd->num_txrx_chains);
7622
7623 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7624 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
7625 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_ANTENNA_MODE_CMDID",
7626 __func__);
7627 wmi_buf_free(buf);
7628 status = QDF_STATUS_E_FAILURE;
7629 goto resp;
7630 }
7631 status = QDF_STATUS_SUCCESS;
7632
7633resp:
7634 param = qdf_mem_malloc(sizeof(*param));
7635 if (!param) {
7636 WMA_LOGE("%s: Memory allocation failed", __func__);
7637 return QDF_STATUS_E_NOMEM;
7638 }
7639 param->status = (status) ?
7640 SET_ANTENNA_MODE_STATUS_ECANCELED :
7641 SET_ANTENNA_MODE_STATUS_OK;
7642 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
7643 __func__, param->status);
7644 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
7645 (void *) param, 0);
7646 return status;
7647}
7648
7649/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007650 * wma_crash_inject() - sends command to FW to simulate crash
7651 * @wma_handle: pointer of WMA context
7652 * @type: subtype of the command
7653 * @delay_time_ms: time in milliseconds for FW to delay the crash
7654 *
7655 * This function will send a command to FW in order to simulate different
7656 * kinds of FW crashes.
7657 *
Govind Singhd76a5b02016-03-08 15:12:14 +05307658 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007659 */
Govind Singhd76a5b02016-03-08 15:12:14 +05307660QDF_STATUS wma_crash_inject(tp_wma_handle wma_handle, uint32_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007661 uint32_t delay_time_ms)
7662{
Govind Singhd76a5b02016-03-08 15:12:14 +05307663 struct crash_inject param;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007664
Govind Singhd76a5b02016-03-08 15:12:14 +05307665 param.type = type;
7666 param.delay_time_ms = delay_time_ms;
Govind Singhd76a5b02016-03-08 15:12:14 +05307667 return wmi_crash_inject(wma_handle->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007668}
Govind Singhd76a5b02016-03-08 15:12:14 +05307669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007670#if defined(FEATURE_LRO)
7671/**
7672 * wma_lro_init() - sends LRO configuration to FW
7673 * @lro_config: pointer to the config parameters
7674 *
7675 * This function ends LRO configuration to FW.
7676 *
7677 * Return: 0 for success or reasons for failure
7678 */
Dhanashri Atre09828f12016-11-13 10:36:58 -08007679int wma_lro_init(struct cdp_lro_hash_config *lro_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007680{
Rajeev Kumarb60abe42017-01-21 15:39:31 -08007681 struct scheduler_msg msg = {0};
Dhanashri Atre09828f12016-11-13 10:36:58 -08007682 struct cdp_lro_hash_config *iwcmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007683
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307684 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007685 if (!iwcmd) {
7686 WMA_LOGE("memory allocation for WMA_LRO_CONFIG_CMD failed!");
7687 return -ENOMEM;
7688 }
7689
7690 *iwcmd = *lro_config;
7691
7692 msg.type = WMA_LRO_CONFIG_CMD;
7693 msg.reserved = 0;
7694 msg.bodyptr = iwcmd;
7695
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307696 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08007697 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007698 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307699 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007700 return -EAGAIN;
7701 }
7702
7703 WMA_LOGD("sending the LRO configuration to the fw");
7704 return 0;
7705}
7706#endif
Leo Chang96464902016-10-28 11:10:54 -07007707
7708void wma_peer_set_default_routing(void *scn_handle, uint8_t *peer_macaddr,
7709 uint8_t vdev_id, bool hash_based, uint8_t ring_num)
7710{
7711 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7712 struct peer_set_params param;
7713
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307714 if (!wma) {
7715 WMA_LOGE("%s:wma_handle is NULL", __func__);
7716 return;
7717 }
Leo Chang96464902016-10-28 11:10:54 -07007718
7719 /* TODO: Need bit definitions for ring number and hash based routing
7720 * fields in common wmi header file
7721 */
7722 param.param_id = WMI_HOST_PEER_SET_DEFAULT_ROUTING;
7723 param.vdev_id = vdev_id;
7724 param.param_value = ((hash_based) ? 1 : 0) | (ring_num << 1);
Dhanashri Atre09828f12016-11-13 10:36:58 -08007725 WMA_LOGD("%s: param_value 0x%d", __func__, param.param_value);
Leo Chang96464902016-10-28 11:10:54 -07007726 wmi_set_peer_param_send(wma->wmi_handle, peer_macaddr, &param);
7727
7728 return;
7729}
7730
7731int wma_peer_rx_reorder_queue_setup(void *scn_handle,
7732 uint8_t vdev_id, uint8_t *peer_macaddr, qdf_dma_addr_t hw_qdesc,
7733 int tid, uint16_t queue_no)
7734{
7735 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7736 struct rx_reorder_queue_setup_params param;
7737
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307738 if (!wma) {
7739 WMA_LOGE("%s:wma_handle is NULL", __func__);
7740 return QDF_STATUS_E_FAILURE;
7741 }
7742
Leo Chang96464902016-10-28 11:10:54 -07007743 param.tid = tid;
7744 param.vdev_id = vdev_id;
7745 param.peer_macaddr = peer_macaddr;
7746 param.hw_qdesc_paddr_lo = hw_qdesc & 0xffffffff;
7747 param.hw_qdesc_paddr_hi = (uint64_t)hw_qdesc >> 32;
7748 param.queue_no = queue_no;
7749
7750 return wmi_unified_peer_rx_reorder_queue_setup_send(wma->wmi_handle,
7751 &param);
7752}
7753
7754int wma_peer_rx_reorder_queue_remove(void *scn_handle,
7755 uint8_t vdev_id, uint8_t *peer_macaddr, uint32_t peer_tid_bitmap)
7756{
7757 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7758 struct rx_reorder_queue_remove_params param;
7759
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307760 if (!wma) {
7761 WMA_LOGE("%s:wma_handle is NULL", __func__);
7762 return QDF_STATUS_E_FAILURE;
7763 }
7764
Leo Chang96464902016-10-28 11:10:54 -07007765 param.vdev_id = vdev_id;
7766 param.peer_macaddr = peer_macaddr;
7767 param.peer_tid_bitmap = peer_tid_bitmap;
7768
7769 return wmi_unified_peer_rx_reorder_queue_remove_send(wma->wmi_handle,
7770 &param);
7771}
7772
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +05307773QDF_STATUS wma_configure_smps_params(uint32_t vdev_id, uint32_t param_id,
7774 uint32_t param_val)
7775{
7776 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7777 int smps_cmd_value;
7778 int status = QDF_STATUS_E_INVAL;
7779
7780 if (!wma) {
7781 WMA_LOGE("%s: Failed to get wma", __func__);
7782 return status;
7783 }
7784
7785 smps_cmd_value = param_id << WMI_SMPS_PARAM_VALUE_S;
7786 smps_cmd_value = smps_cmd_value | param_val;
7787
7788 status = wma_set_smps_params(wma, vdev_id, smps_cmd_value);
7789 if (status)
7790 WMA_LOGE("Failed to set SMPS Param");
7791
7792 return status;
7793}
7794
Leo Chang96464902016-10-28 11:10:54 -07007795
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07007796void wma_ipa_uc_stat_request(wma_cli_set_cmd_t *privcmd)
7797{
7798 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
7799
Sreelakshmi Konamki7a574082017-05-15 16:53:45 +05307800 if (!wma) {
7801 WMA_LOGE("%s: Failed to get wma", __func__);
7802 return;
7803 }
7804
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07007805 if (wma_set_priv_cfg(wma, privcmd))
7806 WMA_LOGE("Failed to set wma priv congiuration");
7807}