blob: 0ebb7cb1e3d1b0d1c1c3e2a3159249575a4ea9c8 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Amar Singhal4c3fbb42018-01-02 13:20:28 -08002 * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**
20 * DOC: wma_main.c
21 *
22 * This file contains wma initialization and FW exchange
23 * related functions.
24 */
25
26/* Header files */
27
28#include "wma.h"
29#include "wma_api.h"
30#include "cds_api.h"
31#include "wmi_unified_api.h"
32#include "wlan_qct_sys.h"
33#include "wni_api.h"
34#include "ani_global.h"
35#include "wmi_unified.h"
36#include "wni_cfg.h"
37#include "cfg_api.h"
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +053038#if defined(CONFIG_HL_SUPPORT)
39#include "wlan_tgt_def_config_hl.h"
40#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080041#include "wlan_tgt_def_config.h"
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +053042#endif
Nirav Shahcbc6d722016-03-01 16:24:53 +053043#include "qdf_nbuf.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053044#include "qdf_types.h"
Anurag Chouhan600c3a02016-03-01 10:33:54 +053045#include "qdf_mem.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "wma_types.h"
47#include "lim_api.h"
48#include "lim_session_utils.h"
49
50#include "cds_utils.h"
51
52#if !defined(REMOVE_PKT_LOG)
53#include "pktlog_ac.h"
54#endif /* REMOVE_PKT_LOG */
55
56#include "dbglog_host.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057#include "csr_api.h"
58#include "ol_fw.h"
59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060#include "wma_internal.h"
61
62#include "wma_ocb.h"
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -070063#include "wlan_policy_mgr_api.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080064#include "cdp_txrx_cfg.h"
65#include "cdp_txrx_flow_ctrl_legacy.h"
66#include "cdp_txrx_flow_ctrl_v2.h"
67#include "cdp_txrx_ipa.h"
Leo Chang96464902016-10-28 11:10:54 -070068#include "cdp_txrx_misc.h"
Jeff Johnson6136fb92017-03-30 15:21:49 -070069#include "wma_fips_api.h"
Deepak Dhamdhere13230d32016-05-26 00:46:53 -070070#include "wma_nan_datapath.h"
Frank Liu65b17d92016-11-23 15:58:44 +080071#include "wlan_lmac_if_def.h"
72#include "wlan_lmac_if_api.h"
Mukul Sharmac3e7a782017-02-03 12:16:11 +053073#include "target_if.h"
Mukul Sharmadad267e2017-02-04 13:25:34 +053074#include "wlan_global_lmac_if_api.h"
Mukul Sharma3d36c392017-01-18 18:39:12 +053075#include "target_if_pmo.h"
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -070076#include "wma_he.h"
Mukul Sharma6411bb82017-03-01 15:57:07 +053077#include "wlan_pmo_obj_mgmt_api.h"
Frank Liu65b17d92016-11-23 15:58:44 +080078
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070079#include "wlan_reg_tgt_api.h"
80#include "wlan_reg_services_api.h"
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080081#include <cdp_txrx_handle.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070082#include <wlan_pmo_ucfg_api.h>
Naveen Rawat4efe41b2017-04-29 16:23:14 -070083#include "wifi_pos_api.h"
84#include "hif_main.h"
Sandeep Puligilla063a4342018-01-10 02:50:14 -080085#include <target_if_spectral.h>
86#include <wlan_spectral_utils_api.h>
Arunk Khandavallia6305a32018-01-25 11:19:18 +053087#include "init_event_handler.h"
Sourav Mohapatracf632572018-04-02 11:01:35 +053088#include "init_deinit_lmac.h"
Himanshu Agarwalceb9faa2018-01-24 22:30:05 +053089#include "target_if_green_ap.h"
Arunk Khandavalli10af7282018-02-05 16:55:48 +053090#include "service_ready_param.h"
Naveen Rawat3ff5cff2018-01-29 14:31:16 -080091#include "wlan_cp_stats_mc_ucfg_api.h"
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070092
Agrawal Ashishb0aa0752017-04-21 19:31:10 +053093#define WMA_LOG_COMPLETION_TIMER 3000 /* 3 seconds */
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +053094#define WMI_TLV_HEADROOM 128
gaurank kathpalia85f8a612018-02-21 18:55:24 +053095
96#define WMA_FW_TIME_SYNC_TIMER 60000 /* 1 min */
97
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -070098uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099static uint32_t g_fw_wlan_feat_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100/**
101 * wma_get_fw_wlan_feat_caps() - get fw feature capablity
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700102 * @feature: feature enum value
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 *
104 * Return: true/false
105 */
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700106bool wma_get_fw_wlan_feat_caps(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700108 return (g_fw_wlan_feat_caps & (1 << feature)) ? true : false;
109}
110
111/**
112 * wma_set_fw_wlan_feat_caps() - set fw feature capablity
113 * @feature: feature enum value
114 *
115 * Return: None
116 */
117void wma_set_fw_wlan_feat_caps(enum cap_bitmap feature)
118{
119 g_fw_wlan_feat_caps |= (1 << feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120}
121
122/**
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530123 * wma_service_ready_ext_evt_timeout() - Service ready extended event timeout
124 * @data: Timeout handler data
125 *
126 * This function is called when the FW fails to send WMI_SERVICE_READY_EXT_EVENT
127 * message
128 *
129 * Return: None
130 */
131static void wma_service_ready_ext_evt_timeout(void *data)
132{
133 tp_wma_handle wma_handle;
134
135 WMA_LOGA("%s: Timeout waiting for WMI_SERVICE_READY_EXT_EVENT",
136 __func__);
137
138 wma_handle = (tp_wma_handle) data;
139
140 if (!wma_handle) {
141 WMA_LOGE("%s: Invalid WMA handle", __func__);
142 goto end;
143 }
144
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530145end:
Naveen Rawatac39a102016-10-07 10:58:29 -0700146 /* Assert here. Panic is being called in insmod thread */
147 QDF_ASSERT(0);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530148}
149
150/**
Komal Seelam02d09342016-02-23 18:03:19 +0530151 * wma_get_ini_handle() - API to get WMA ini info handle
152 * @wma: WMA Handle
153 *
154 * Returns the pointer to WMA ini structure.
155 * Return: struct wma_ini_config
156 */
157struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma)
158{
159 if (!wma) {
160 WMA_LOGE("%s: Invalid WMA context\n", __func__);
161 return NULL;
162 }
163
164 return &wma->ini_config;
165}
166
167#define MAX_SUPPORTED_PEERS_REV1_1 14
168#define MAX_SUPPORTED_PEERS_REV1_3 32
169#define MIN_NO_OF_PEERS 1
170
171/**
172 * wma_get_number_of_peers_supported - API to query for number of peers
173 * supported
174 * @wma: WMA Handle
175 *
176 * Return: Max Number of Peers Supported
177 */
178static uint8_t wma_get_number_of_peers_supported(tp_wma_handle wma)
179{
Komal Seelam02d09342016-02-23 18:03:19 +0530180 struct wma_ini_config *cfg = wma_get_ini_handle(wma);
181 uint8_t max_no_of_peers = cfg ? cfg->max_no_of_peers : MIN_NO_OF_PEERS;
Komal Seelam02d09342016-02-23 18:03:19 +0530182
183 return max_no_of_peers;
184}
185
186/**
bings6b3614e2017-02-21 10:18:36 +0800187 * wma_get_number_of_tids_supported - API to query for number of tids supported
188 * @no_of_peers_supported: Number of peer supported
189 *
190 * Return: Max number of tids supported
191 */
192#if defined(CONFIG_HL_SUPPORT)
Rachit Kankane0106e382018-05-16 18:59:28 +0530193static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported,
194 uint8_t num_vdevs)
bings6b3614e2017-02-21 10:18:36 +0800195{
196 return 4 * no_of_peers_supported;
197}
198#else
Rachit Kankane0106e382018-05-16 18:59:28 +0530199static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported,
200 uint8_t num_vdevs)
bings6b3614e2017-02-21 10:18:36 +0800201{
Rachit Kankane0106e382018-05-16 18:59:28 +0530202 return 2 * (no_of_peers_supported + num_vdevs + 2);
bings6b3614e2017-02-21 10:18:36 +0800203}
204#endif
205
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530206#ifdef PERE_IP_HDR_ALIGNMENT_WAR
207static void wma_reset_rx_decap_mode(target_resource_config *tgt_cfg)
208{
209 /*
210 * To make the IP header begins at dword aligned address,
211 * we make the decapsulation mode as Native Wifi.
212 */
213 tgt_cfg->rx_decap_mode = CFG_TGT_RX_DECAP_MODE_NWIFI;
214}
215#else
216static void wma_reset_rx_decap_mode(target_resource_config *tgt_cfg)
217{
218}
219
220#endif
Rachit Kankane0106e382018-05-16 18:59:28 +0530221
222#ifndef NUM_OF_ADDITIONAL_FW_PEERS
223#define NUM_OF_ADDITIONAL_FW_PEERS 2
224#endif
bings6b3614e2017-02-21 10:18:36 +0800225/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226 * wma_set_default_tgt_config() - set default tgt config
227 * @wma_handle: wma handle
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530228 * @tgt_cfg: Resource config given to target
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 *
230 * Return: none
231 */
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530232static void wma_set_default_tgt_config(tp_wma_handle wma_handle,
Rachit Kankane0106e382018-05-16 18:59:28 +0530233 target_resource_config *tgt_cfg,
234 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 uint8_t no_of_peers_supported;
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530237
Rachit Kankane0106e382018-05-16 18:59:28 +0530238 no_of_peers_supported = wma_get_number_of_peers_supported(wma_handle);
239
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530240 qdf_mem_zero(tgt_cfg, sizeof(target_resource_config));
Rachit Kankane0106e382018-05-16 18:59:28 +0530241 tgt_cfg->num_vdevs = cds_cfg->num_vdevs;
242 tgt_cfg->num_peers = no_of_peers_supported +
243 cds_cfg->num_vdevs +
244 NUM_OF_ADDITIONAL_FW_PEERS;
245 /* The current firmware implementation requires the number of
246 * offload peers should be (number of vdevs + 1).
247 */
248 tgt_cfg->num_offload_peers = cds_cfg->ap_maxoffload_peers + 1;
249 tgt_cfg->num_offload_reorder_buffs =
250 cds_cfg->ap_maxoffload_reorderbuffs + 1;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530251 tgt_cfg->num_peer_keys = CFG_TGT_NUM_PEER_KEYS;
Rachit Kankane0106e382018-05-16 18:59:28 +0530252 tgt_cfg->num_tids = wma_get_number_of_tids_supported(
253 no_of_peers_supported, cds_cfg->num_vdevs);
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530254 tgt_cfg->ast_skid_limit = CFG_TGT_AST_SKID_LIMIT;
255 tgt_cfg->tx_chain_mask = CFG_TGT_DEFAULT_TX_CHAIN_MASK;
256 tgt_cfg->rx_chain_mask = CFG_TGT_DEFAULT_RX_CHAIN_MASK;
257 tgt_cfg->rx_timeout_pri[0] = CFG_TGT_RX_TIMEOUT_LO_PRI;
258 tgt_cfg->rx_timeout_pri[1] = CFG_TGT_RX_TIMEOUT_LO_PRI;
259 tgt_cfg->rx_timeout_pri[2] = CFG_TGT_RX_TIMEOUT_LO_PRI;
260 tgt_cfg->rx_timeout_pri[3] = CFG_TGT_RX_TIMEOUT_HI_PRI;
261 tgt_cfg->rx_decap_mode = CFG_TGT_RX_DECAP_MODE;
Rachit Kankane0106e382018-05-16 18:59:28 +0530262 tgt_cfg->scan_max_pending_req = wma_handle->max_scan;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530263 tgt_cfg->bmiss_offload_max_vdev =
264 CFG_TGT_DEFAULT_BMISS_OFFLOAD_MAX_VDEV;
265 tgt_cfg->roam_offload_max_vdev = CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_VDEV;
266 tgt_cfg->roam_offload_max_ap_profiles =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530267 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_PROFILES;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530268 tgt_cfg->num_mcast_groups = CFG_TGT_DEFAULT_NUM_MCAST_GROUPS;
269 tgt_cfg->num_mcast_table_elems = CFG_TGT_DEFAULT_NUM_MCAST_TABLE_ELEMS;
270 tgt_cfg->mcast2ucast_mode = CFG_TGT_DEFAULT_MCAST2UCAST_MODE;
271 tgt_cfg->tx_dbg_log_size = CFG_TGT_DEFAULT_TX_DBG_LOG_SIZE;
272 tgt_cfg->num_wds_entries = CFG_TGT_WDS_ENTRIES;
273 tgt_cfg->dma_burst_size = CFG_TGT_DEFAULT_DMA_BURST_SIZE;
274 tgt_cfg->mac_aggr_delim = CFG_TGT_DEFAULT_MAC_AGGR_DELIM;
275 tgt_cfg->rx_skip_defrag_timeout_dup_detection_check =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 CFG_TGT_DEFAULT_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK,
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530277 tgt_cfg->vow_config = CFG_TGT_DEFAULT_VOW_CONFIG;
278 tgt_cfg->gtk_offload_max_vdev = CFG_TGT_DEFAULT_GTK_OFFLOAD_MAX_VDEV;
279 tgt_cfg->num_msdu_desc = CFG_TGT_NUM_MSDU_DESC;
280 tgt_cfg->max_frag_entries = CFG_TGT_MAX_FRAG_TABLE_ENTRIES;
281 tgt_cfg->num_tdls_vdevs = CFG_TGT_NUM_TDLS_VDEVS;
282 tgt_cfg->num_tdls_conn_table_entries =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530283 CFG_TGT_NUM_TDLS_CONN_TABLE_ENTRIES;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530284 tgt_cfg->beacon_tx_offload_max_vdev =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530285 CFG_TGT_DEFAULT_BEACON_TX_OFFLOAD_MAX_VDEV;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530286 tgt_cfg->num_multicast_filter_entries =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530287 CFG_TGT_MAX_MULTICAST_FILTER_ENTRIES;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530288 tgt_cfg->num_wow_filters = 0;
Rachit Kankane0106e382018-05-16 18:59:28 +0530289 tgt_cfg->num_keep_alive_pattern = WMA_MAXNUM_PERIODIC_TX_PTRNS;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530290 tgt_cfg->keep_alive_pattern_size = 0;
291 tgt_cfg->max_tdls_concurrent_sleep_sta =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530292 CFG_TGT_NUM_TDLS_CONC_SLEEP_STAS;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530293 tgt_cfg->max_tdls_concurrent_buffer_sta =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530294 CFG_TGT_NUM_TDLS_CONC_BUFFER_STAS;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530295 tgt_cfg->wmi_send_separate = 0;
296 tgt_cfg->num_ocb_vdevs = CFG_TGT_NUM_OCB_VDEVS;
297 tgt_cfg->num_ocb_channels = CFG_TGT_NUM_OCB_CHANNELS;
298 tgt_cfg->num_ocb_schedules = CFG_TGT_NUM_OCB_SCHEDULES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530301 tgt_cfg->mgmt_comp_evt_bundle_support = true;
302 tgt_cfg->tx_msdu_new_partition_id_support = true;
Nirav Shah20489972016-06-16 19:20:28 +0530303
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 /* reduce the peer/vdev if CFG_TGT_NUM_MSDU_DESC exceeds 1000 */
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530305 wma_reset_rx_decap_mode(tgt_cfg);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700306
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530307 if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE)
308 tgt_cfg->rx_decap_mode = CFG_TGT_RX_DECAP_MODE_RAW;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309}
310
311/**
312 * wma_cli_get_command() - WMA "get" command processor
313 * @vdev_id: virtual device for the command
314 * @param_id: parameter id
315 * @vpdev: parameter category
316 *
317 * Return: parameter value on success, -EINVAL on failure
318 */
319int wma_cli_get_command(int vdev_id, int param_id, int vpdev)
320{
321 int ret = 0;
322 tp_wma_handle wma;
323 struct wma_txrx_node *intr = NULL;
324
Anurag Chouhan6d760662016-02-20 16:05:43 +0530325 wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326
327 if (NULL == wma) {
328 WMA_LOGE("%s: Invalid wma handle", __func__);
329 return -EINVAL;
330 }
331
332 intr = wma->interfaces;
333
334 if (VDEV_CMD == vpdev) {
335 switch (param_id) {
336 case WMI_VDEV_PARAM_NSS:
337 ret = intr[vdev_id].config.nss;
338 break;
339#ifdef QCA_SUPPORT_GTX
340 case WMI_VDEV_PARAM_GTX_HT_MCS:
341 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
342 break;
343 case WMI_VDEV_PARAM_GTX_VHT_MCS:
344 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
345 break;
346 case WMI_VDEV_PARAM_GTX_USR_CFG:
347 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
348 break;
349 case WMI_VDEV_PARAM_GTX_THRE:
350 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
351 break;
352 case WMI_VDEV_PARAM_GTX_MARGIN:
353 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
354 break;
355 case WMI_VDEV_PARAM_GTX_STEP:
356 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
357 break;
358 case WMI_VDEV_PARAM_GTX_MINTPC:
359 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
360 break;
361 case WMI_VDEV_PARAM_GTX_BW_MASK:
362 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
363 break;
364#endif /* QCA_SUPPORT_GTX */
365 case WMI_VDEV_PARAM_LDPC:
366 ret = intr[vdev_id].config.ldpc;
367 break;
368 case WMI_VDEV_PARAM_TX_STBC:
369 ret = intr[vdev_id].config.tx_stbc;
370 break;
371 case WMI_VDEV_PARAM_RX_STBC:
372 ret = intr[vdev_id].config.rx_stbc;
373 break;
374 case WMI_VDEV_PARAM_SGI:
375 ret = intr[vdev_id].config.shortgi;
376 break;
377 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
378 ret = intr[vdev_id].config.rtscts_en;
379 break;
380 case WMI_VDEV_PARAM_CHWIDTH:
381 ret = intr[vdev_id].config.chwidth;
382 break;
383 case WMI_VDEV_PARAM_FIXED_RATE:
384 ret = intr[vdev_id].config.tx_rate;
385 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700386 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -0700387 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700388 ret = wma_get_he_vdev_param(&intr[vdev_id], param_id);
389 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700391 WMA_LOGE("Invalid cli_get vdev command/Not yet implemented 0x%x",
392 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393 return -EINVAL;
394 }
395 } else if (PDEV_CMD == vpdev) {
396 switch (param_id) {
397 case WMI_PDEV_PARAM_ANI_ENABLE:
398 ret = wma->pdevconfig.ani_enable;
399 break;
400 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
401 ret = wma->pdevconfig.ani_poll_len;
402 break;
403 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
404 ret = wma->pdevconfig.ani_listen_len;
405 break;
406 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
407 ret = wma->pdevconfig.ani_ofdm_level;
408 break;
409 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
410 ret = wma->pdevconfig.ani_cck_level;
411 break;
412 case WMI_PDEV_PARAM_DYNAMIC_BW:
413 ret = wma->pdevconfig.cwmenable;
414 break;
415 case WMI_PDEV_PARAM_CTS_CBW:
416 ret = wma->pdevconfig.cts_cbw;
417 break;
418 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
419 ret = wma->pdevconfig.txchainmask;
420 break;
421 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
422 ret = wma->pdevconfig.rxchainmask;
423 break;
424 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
425 ret = wma->pdevconfig.txpow2g;
426 break;
427 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
428 ret = wma->pdevconfig.txpow5g;
429 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700431 WMA_LOGE("Invalid cli_get pdev command/Not yet implemented 0x%x",
432 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433 return -EINVAL;
434 }
435 } else if (GEN_CMD == vpdev) {
436 switch (param_id) {
437 case GEN_VDEV_PARAM_AMPDU:
438 ret = intr[vdev_id].config.ampdu;
439 break;
440 case GEN_VDEV_PARAM_AMSDU:
441 ret = intr[vdev_id].config.amsdu;
442 break;
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700443 case GEN_VDEV_ROAM_SYNCH_DELAY:
444 ret = intr[vdev_id].roam_synch_delay;
445 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700447 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
448 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 return -EINVAL;
450 }
451 } else if (PPS_CMD == vpdev) {
452 switch (param_id) {
453 case WMI_VDEV_PPS_PAID_MATCH:
454 ret = intr[vdev_id].config.pps_params.paid_match_enable;
455 break;
456 case WMI_VDEV_PPS_GID_MATCH:
457 ret = intr[vdev_id].config.pps_params.gid_match_enable;
458 break;
459 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
460 ret = intr[vdev_id].config.pps_params.tim_clear;
461 break;
462 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
463 ret = intr[vdev_id].config.pps_params.dtim_clear;
464 break;
465 case WMI_VDEV_PPS_EOF_PAD_DELIM:
466 ret = intr[vdev_id].config.pps_params.eof_delim;
467 break;
468 case WMI_VDEV_PPS_MACADDR_MISMATCH:
469 ret = intr[vdev_id].config.pps_params.mac_match;
470 break;
471 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
472 ret = intr[vdev_id].config.pps_params.delim_fail;
473 break;
474 case WMI_VDEV_PPS_GID_NSTS_ZERO:
475 ret = intr[vdev_id].config.pps_params.nsts_zero;
476 break;
477 case WMI_VDEV_PPS_RSSI_CHECK:
478 ret = intr[vdev_id].config.pps_params.rssi_chk;
479 break;
480 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700481 WMA_LOGE("Invalid pps vdev command/Not yet implemented 0x%x",
482 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 return -EINVAL;
484 }
485 } else if (QPOWER_CMD == vpdev) {
486 switch (param_id) {
487 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
488 ret = intr[vdev_id].config.qpower_params.
489 max_ps_poll_cnt;
490 break;
491 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
492 ret = intr[vdev_id].config.qpower_params.
493 max_tx_before_wake;
494 break;
495 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
496 ret = intr[vdev_id].config.qpower_params.
497 spec_ps_poll_wake_interval;
498 break;
499 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
500 ret = intr[vdev_id].config.qpower_params.
501 max_spec_nodata_ps_poll;
502 break;
503 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700504 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
505 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 return -EINVAL;
507 }
508 } else if (GTX_CMD == vpdev) {
509 switch (param_id) {
510 case WMI_VDEV_PARAM_GTX_HT_MCS:
511 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
512 break;
513 case WMI_VDEV_PARAM_GTX_VHT_MCS:
514 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
515 break;
516 case WMI_VDEV_PARAM_GTX_USR_CFG:
517 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
518 break;
519 case WMI_VDEV_PARAM_GTX_THRE:
520 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
521 break;
522 case WMI_VDEV_PARAM_GTX_MARGIN:
523 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
524 break;
525 case WMI_VDEV_PARAM_GTX_STEP:
526 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
527 break;
528 case WMI_VDEV_PARAM_GTX_MINTPC:
529 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
530 break;
531 case WMI_VDEV_PARAM_GTX_BW_MASK:
532 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
533 break;
534 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700535 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
536 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537 return -EINVAL;
538 }
539 }
540 return ret;
541}
542
543/**
544 * wma_cli_set2_command() - WMA "set 2 params" command processor
545 * @vdev_id: virtual device for the command
546 * @param_id: parameter id
547 * @sval1: first parameter value
548 * @sval2: second parameter value
549 * @vpdev: parameter category
550 *
551 * Command handler for set operations which require 2 parameters
552 *
553 * Return: 0 on success, errno on failure
554 */
555int wma_cli_set2_command(int vdev_id, int param_id, int sval1,
556 int sval2, int vpdev)
557{
Rajeev Kumarb60abe42017-01-21 15:39:31 -0800558 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800559 wma_cli_set_cmd_t *iwcmd;
560
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530561 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 if (!iwcmd) {
563 WMA_LOGE("%s: Failed alloc memory for iwcmd", __func__);
564 return -ENOMEM;
565 }
566
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530567 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 iwcmd->param_value = sval1;
569 iwcmd->param_sec_value = sval2;
570 iwcmd->param_vdev_id = vdev_id;
571 iwcmd->param_id = param_id;
572 iwcmd->param_vp_dev = vpdev;
573 msg.type = WMA_CLI_SET_CMD;
574 msg.reserved = 0;
575 msg.bodyptr = iwcmd;
576
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530577 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -0800578 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -0700579 WMA_LOGE("%s: Failed to post WMA_CLI_SET_CMD msg",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530581 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 return -EIO;
583 }
584 return 0;
585}
586
587/**
588 * wma_cli_set_command() - WMA "set" command processor
589 * @vdev_id: virtual device for the command
590 * @param_id: parameter id
591 * @sval: parameter value
592 * @vpdev: parameter category
593 *
594 * Command handler for set operations
595 *
596 * Return: 0 on success, errno on failure
597 */
598int wma_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
599{
600 return wma_cli_set2_command(vdev_id, param_id, sval, 0, vpdev);
601
602}
603
Krunal Soniaadaa272017-10-04 16:42:55 -0700604QDF_STATUS wma_form_unit_test_cmd_and_send(uint32_t vdev_id,
605 uint32_t module_id, uint32_t arg_count, uint32_t *arg)
606{
607 struct wmi_unit_test_cmd *unit_test_args;
608 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
609 uint32_t i;
610 QDF_STATUS status;
611
612 WMA_LOGD(FL("enter"));
613 if (arg_count >= WMA_MAX_NUM_ARGS) {
614 WMA_LOGE(FL("arg_count is crossed the boundary"));
615 return QDF_STATUS_E_FAILURE;
616 }
617 if (!wma_handle || !wma_handle->wmi_handle) {
618 WMA_LOGE(FL("Invalid WMA/WMI handle"));
619 return QDF_STATUS_E_FAILURE;
620 }
621 unit_test_args = qdf_mem_malloc(sizeof(*unit_test_args));
622 if (NULL == unit_test_args) {
623 WMA_LOGE(FL("qdf_mem_malloc failed for unit_test_args"));
624 return QDF_STATUS_E_NOMEM;
625 }
626 unit_test_args->vdev_id = vdev_id;
627 unit_test_args->module_id = module_id;
628 unit_test_args->num_args = arg_count;
629 for (i = 0; i < arg_count; i++)
630 unit_test_args->args[i] = arg[i];
631
632 status = wmi_unified_unit_test_cmd(wma_handle->wmi_handle,
633 unit_test_args);
634 qdf_mem_free(unit_test_args);
635 WMA_LOGD(FL("exit"));
636
637 return status;
638}
639
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -0800640static void wma_process_send_addba_req(tp_wma_handle wma_handle,
641 struct send_add_ba_req *send_addba)
642{
643 QDF_STATUS status;
644
645 if (!wma_handle || !wma_handle->wmi_handle) {
646 WMA_LOGE(FL("Invalid WMA/WMI handle"));
647 qdf_mem_free(send_addba);
648 return;
649 }
650
651 status = wmi_unified_addba_send_cmd_send(wma_handle->wmi_handle,
652 send_addba->mac_addr,
653 &send_addba->param);
654 if (QDF_STATUS_SUCCESS != status) {
655 WMA_LOGE(FL("Failed to process WMA_SEND_ADDBA_REQ"));
656 }
657 WMA_LOGD(FL("sent ADDBA req to" MAC_ADDRESS_STR "tid %d buff_size %d"),
658 MAC_ADDR_ARRAY(send_addba->mac_addr),
659 send_addba->param.tidno,
660 send_addba->param.buffersize);
661
662 qdf_mem_free(send_addba);
663}
664
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665/**
Yun Parkb4f591d2017-03-29 15:51:01 -0700666 * wma_ipa_get_stat() - get IPA data path stats from FW
667 *
668 * Return: 0 on success, errno on failure
669 */
670#ifdef IPA_OFFLOAD
671static int wma_ipa_get_stat(void)
672{
673 struct cdp_pdev *pdev;
674
675 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
676 if (!pdev) {
677 WMA_LOGE("pdev NULL for uc stat");
678 return -EINVAL;
679 }
680 cdp_ipa_get_stat(cds_get_context(QDF_MODULE_ID_SOC), pdev);
681
682 return 0;
683}
684#else
685static int wma_ipa_get_stat(void)
686{
687 return 0;
688}
689#endif
690
691/**
692 * wma_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
693 * @privcmd: private command
694 *
695 * Return: 0 on success, errno on failure
696 */
697#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
698static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
699{
700 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
701 struct cdp_pdev *pdev;
702 uint8_t reset_stats = privcmd->param_value;
703
704 WMA_LOGD("%s: reset_stats=%d",
705 "WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID",
706 reset_stats);
707 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
708 if (!pdev) {
709 WMA_LOGE("pdev NULL for uc get share stats");
710 return -EINVAL;
711 }
712 cdp_ipa_uc_get_share_stats(soc, pdev, reset_stats);
713
714 return 0;
715}
716#else
717static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
718{
719 return 0;
720}
721#endif
722
723/**
724 * wma_ipa_uc_set_quota() - set quota limit to FW
725 * @privcmd: private command
726 *
727 * Return: 0 on success, errno on failure
728 */
729#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
730static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
731{
732 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
733 struct cdp_pdev *pdev;
734 uint64_t quota_bytes = privcmd->param_sec_value;
735
736 quota_bytes <<= 32;
737 quota_bytes |= privcmd->param_value;
738
739 WMA_LOGD("%s: quota_bytes=%llu",
740 "WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID",
741 quota_bytes);
742 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
743 if (!pdev) {
744 WMA_LOGE("pdev NULL for uc set quota");
745 return -EINVAL;
746 }
747 cdp_ipa_uc_set_quota(soc, pdev, quota_bytes);
748
749 return 0;
750}
751#else
752static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
753{
754 return 0;
755}
756#endif
757
758/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759 * wma_set_priv_cfg() - set private config parameters
760 * @wma_handle: wma handle
761 * @privcmd: private command
762 *
763 * Return: 0 for success or error code
764 */
765static int32_t wma_set_priv_cfg(tp_wma_handle wma_handle,
766 wma_cli_set_cmd_t *privcmd)
767{
768 int32_t ret = 0;
769
770 switch (privcmd->param_id) {
771 case WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID:
772 ret = wma_set_txrx_fw_stats_level(wma_handle,
773 privcmd->param_vdev_id,
774 privcmd->param_value);
775 break;
776 case WMA_VDEV_TXRX_FWSTATS_RESET_CMDID:
777 ret = wma_txrx_fw_stats_reset(wma_handle,
778 privcmd->param_vdev_id,
779 privcmd->param_value);
780 break;
781 case WMI_STA_SMPS_FORCE_MODE_CMDID:
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800782 ret = wma_set_mimops(wma_handle,
783 privcmd->param_vdev_id,
784 privcmd->param_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 break;
786 case WMI_STA_SMPS_PARAM_CMDID:
787 wma_set_smps_params(wma_handle, privcmd->param_vdev_id,
788 privcmd->param_value);
789 break;
790 case WMA_VDEV_MCC_SET_TIME_LATENCY:
791 {
792 /* Extract first MCC adapter/vdev channel number and latency */
793 uint8_t mcc_channel = privcmd->param_value & 0x000000FF;
794 uint8_t mcc_channel_latency =
795 (privcmd->param_value & 0x0000FF00) >> 8;
796 int ret = -1;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 WMA_LOGD("%s: Parsed input: Channel #1:%d, latency:%dms",
799 __func__, mcc_channel, mcc_channel_latency);
800 ret = wma_set_mcc_channel_time_latency(wma_handle,
801 mcc_channel,
802 mcc_channel_latency);
803 }
804 break;
805 case WMA_VDEV_MCC_SET_TIME_QUOTA:
806 {
807 /* Extract the MCC 2 adapters/vdevs channel numbers and time
808 * quota value for the first adapter only (which is specified
809 * in iwpriv command.
810 */
811 uint8_t adapter_2_chan_number =
812 privcmd->param_value & 0x000000FF;
813 uint8_t adapter_1_chan_number =
814 (privcmd->param_value & 0x0000FF00) >> 8;
815 uint8_t adapter_1_quota =
816 (privcmd->param_value & 0x00FF0000) >> 16;
817 int ret = -1;
818
819 WMA_LOGD("%s: Parsed input: Channel #1:%d, Channel #2:%d, quota 1:%dms",
820 __func__, adapter_1_chan_number,
821 adapter_2_chan_number, adapter_1_quota);
822
823 ret = wma_set_mcc_channel_time_quota(wma_handle,
824 adapter_1_chan_number,
825 adapter_1_quota,
826 adapter_2_chan_number);
827 }
828 break;
829 case WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE:
830 {
831 wma_handle->wma_ibss_power_save_params.atimWindowLength =
832 privcmd->param_value;
833 WMA_LOGD("%s: IBSS power save ATIM Window = %d",
834 __func__, wma_handle->wma_ibss_power_save_params.
835 atimWindowLength);
836 }
837 break;
838 case WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED:
839 {
840 wma_handle->wma_ibss_power_save_params.isPowerSaveAllowed =
841 privcmd->param_value;
842 WMA_LOGD("%s: IBSS is Power Save Allowed = %d",
843 __func__, wma_handle->wma_ibss_power_save_params.
844 isPowerSaveAllowed);
845 }
846 break;
847 case WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED:
848 {
849 wma_handle->wma_ibss_power_save_params. isPowerCollapseAllowed =
850 privcmd->param_value;
851 WMA_LOGD("%s: IBSS is Power Collapse Allowed = %d",
852 __func__, wma_handle->wma_ibss_power_save_params.
853 isPowerCollapseAllowed);
854 }
855 break;
856 case WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX:
857 {
858 wma_handle->wma_ibss_power_save_params.isAwakeonTxRxEnabled =
859 privcmd->param_value;
860 WMA_LOGD("%s: IBSS Power Save Awake on Tx/Rx Enabled = %d",
861 __func__, wma_handle->wma_ibss_power_save_params.
862 isAwakeonTxRxEnabled);
863 }
864 break;
865 case WMA_VDEV_IBSS_SET_INACTIVITY_TIME:
866 {
867 wma_handle->wma_ibss_power_save_params.inactivityCount =
868 privcmd->param_value;
869 WMA_LOGD("%s: IBSS Power Save Data Inactivity Count = %d",
870 __func__, wma_handle->wma_ibss_power_save_params.
871 inactivityCount);
872 }
873 break;
874 case WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME:
875 {
876 wma_handle->wma_ibss_power_save_params.txSPEndInactivityTime =
877 privcmd->param_value;
878 WMA_LOGD("%s: IBSS Power Save Transmit EOSP inactivity time out = %d",
879 __func__, wma_handle->wma_ibss_power_save_params.
880 txSPEndInactivityTime);
881 }
882 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 case WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS:
884 {
885 wma_handle->wma_ibss_power_save_params.ibssPsWarmupTime =
886 privcmd->param_value;
887 WMA_LOGD("%s: IBSS Power Save Warm Up Time in Seconds = %d",
888 __func__, wma_handle->wma_ibss_power_save_params.
889 ibssPsWarmupTime);
890 }
891 break;
892 case WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW:
893 {
894 wma_handle->wma_ibss_power_save_params.ibssPs1RxChainInAtimEnable
895 = privcmd->param_value;
896 WMA_LOGD("%s: IBSS Power Save single RX Chain Enable In ATIM = %d",
897 __func__, wma_handle->wma_ibss_power_save_params.
898 ibssPs1RxChainInAtimEnable);
899 }
900 break;
901
902 case WMA_VDEV_TXRX_GET_IPA_UC_FW_STATS_CMDID:
903 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700904 wma_ipa_get_stat();
Yun Park637d6482016-10-05 10:51:33 -0700905 }
906 break;
907
908 case WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID:
909 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700910 wma_ipa_uc_get_share_stats(privcmd);
Yun Park637d6482016-10-05 10:51:33 -0700911 }
912 break;
913
914 case WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID:
915 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700916 wma_ipa_uc_set_quota(privcmd);
Yun Park327e7812017-02-14 15:18:10 -0800917
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 }
919 break;
920
921 default:
922 WMA_LOGE("Invalid wma config command id:%d", privcmd->param_id);
923 ret = -EINVAL;
924 }
925 return ret;
926}
927
928/**
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -0800929 * wma_set_dtim_period() - set dtim period to FW
930 * @wma: wma handle
931 * @dtim_params: dtim params
932 *
933 * Return: none
934 */
935static void wma_set_dtim_period(tp_wma_handle wma,
936 struct set_dtim_params *dtim_params)
937{
938 struct wma_txrx_node *iface =
939 &wma->interfaces[dtim_params->session_id];
940 if (!wma_is_vdev_valid(dtim_params->session_id)) {
941 WMA_LOGE("%s: invalid VDEV", __func__);
942 return;
943 }
944 WMA_LOGD("%s: set dtim_period %d", __func__,
945 dtim_params->dtim_period);
946 iface->dtimPeriod = dtim_params->dtim_period;
947
948}
949/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 * wma_set_modulated_dtim() - function to configure modulated dtim
951 * @wma: wma handle
952 * @privcmd: structure containing parameters
953 *
954 * This function configures the modulated dtim in firmware
955 *
956 * Return: none
957 */
958static void wma_set_modulated_dtim(tp_wma_handle wma,
959 wma_cli_set_cmd_t *privcmd)
960{
961 uint8_t vdev_id = privcmd->param_vdev_id;
962 struct wma_txrx_node *iface =
963 &wma->interfaces[vdev_id];
964 bool prev_dtim_enabled;
965 uint32_t listen_interval;
Govind Singhd76a5b02016-03-08 15:12:14 +0530966 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967
968 iface->alt_modulated_dtim = privcmd->param_value;
969
970 prev_dtim_enabled = iface->alt_modulated_dtim_enabled;
971
972 if (1 != privcmd->param_value)
973 iface->alt_modulated_dtim_enabled = true;
974 else
975 iface->alt_modulated_dtim_enabled = false;
976
977 if ((true == iface->alt_modulated_dtim_enabled) ||
978 (true == prev_dtim_enabled)) {
979
980 listen_interval = iface->alt_modulated_dtim
981 * iface->dtimPeriod;
982
Govind Singhd76a5b02016-03-08 15:12:14 +0530983 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 privcmd->param_vdev_id,
985 WMI_VDEV_PARAM_LISTEN_INTERVAL,
986 listen_interval);
Govind Singhd76a5b02016-03-08 15:12:14 +0530987 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 /* Even if it fails, continue */
989 WMA_LOGW("Failed to set listen interval %d",
990 listen_interval);
991
Govind Singhd76a5b02016-03-08 15:12:14 +0530992 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 privcmd->param_vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700994 WMI_VDEV_PARAM_DTIM_POLICY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 NORMAL_DTIM);
Govind Singhd76a5b02016-03-08 15:12:14 +0530996 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997 WMA_LOGE("Failed to Set to Normal DTIM policy");
998 }
999}
1000
Mukul Sharma6398b252017-05-01 17:58:12 +05301001/**
1002 * wma_override_listen_interval() - function to override static/ini based LI
1003 * @wma: wma handle
1004 * @privcmd: structure containing parameters
1005 *
1006 * This function override static/ini based LI in firmware
1007 *
1008 * Return: none
1009 */
1010static void wma_override_listen_interval(tp_wma_handle wma,
1011 wma_cli_set_cmd_t *privcmd)
1012{
1013 uint8_t vdev_id = privcmd->param_vdev_id;
1014 struct wma_txrx_node *iface =
1015 &wma->interfaces[vdev_id];
1016 u32 old_override_li, new_override_li, listen_interval;
1017 struct sAniSirGlobal *mac;
1018 QDF_STATUS ret;
1019
1020 mac = cds_get_context(QDF_MODULE_ID_PE);
1021 if (!mac) {
1022 WMA_LOGE(FL("Failed to get mac context"));
1023 return;
1024 }
1025
1026 old_override_li = iface->override_li;
1027 new_override_li = privcmd->param_value;
1028 iface->override_li = new_override_li;
1029
1030 if (new_override_li &&
1031 (new_override_li != old_override_li)) {
1032 listen_interval = new_override_li;
1033 } else if (!new_override_li &&
1034 (new_override_li != old_override_li)) {
1035 /* Configure default LI as we do on resume */
Jeff Johnsone88dd752018-06-07 22:57:54 -07001036 ret = wlan_cfg_get_int(mac, WNI_CFG_LISTEN_INTERVAL,
1037 &listen_interval);
1038 if (ret != QDF_STATUS_SUCCESS) {
Mukul Sharma6398b252017-05-01 17:58:12 +05301039 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_ERROR,
1040 "Failed to get value for listen interval");
1041 listen_interval = POWERSAVE_DEFAULT_LISTEN_INTERVAL;
1042 }
1043 } else {
1044 return;
1045 }
1046
1047 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
1048 WMI_VDEV_PARAM_LISTEN_INTERVAL,
1049 listen_interval);
1050 if (QDF_IS_STATUS_ERROR(ret)) {
1051 /* Even it fails continue Fw will take default LI */
1052 WMA_LOGE("Failed to Set Listen Interval vdevId %d",
1053 vdev_id);
1054 }
1055 WMA_LOGD("%s: Set Listen Interval vdevId %d Listen Intv %d",
1056 __func__, vdev_id, listen_interval);
1057 ret = wma_vdev_set_param(wma->wmi_handle,
1058 privcmd->param_vdev_id,
1059 WMI_VDEV_PARAM_DTIM_POLICY,
1060 NORMAL_DTIM);
1061 if (QDF_IS_STATUS_ERROR(ret))
1062 WMA_LOGE("Failed to Set to Normal DTIM policy");
1063
1064}
1065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066
1067/**
1068 * wma_process_cli_set_cmd() - set parameters to fw
1069 * @wma: wma handle
1070 * @privcmd: command
1071 *
1072 * Return: none
1073 */
1074static void wma_process_cli_set_cmd(tp_wma_handle wma,
1075 wma_cli_set_cmd_t *privcmd)
1076{
Govind Singhd76a5b02016-03-08 15:12:14 +05301077 int vid = privcmd->param_vdev_id, pps_val = 0;
1078 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079 struct wma_txrx_node *intr = wma->interfaces;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301080 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 struct qpower_params *qparams = &intr[vid].config.qpower_params;
Govind Singhd76a5b02016-03-08 15:12:14 +05301082 struct pdev_params pdev_param;
Leo Chang96464902016-10-28 11:10:54 -07001083 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05301084 struct target_psoc_info *tgt_hdl;
Kiran Kumar Lokere9f881ae2018-03-07 18:59:30 -08001085 struct sir_set_tx_rx_aggregation_size aggr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086
Jeff Johnsonadba3962017-09-18 08:12:35 -07001087 WMA_LOGD("wmihandle %pK", wma->wmi_handle);
Arif Hussain0e246802018-05-01 18:13:44 -07001088 qdf_mem_zero(&aggr, sizeof(aggr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089
1090 if (NULL == pMac) {
1091 WMA_LOGE("%s: Failed to get pMac", __func__);
1092 return;
1093 }
1094
Arunk Khandavalli2462f462018-01-25 14:41:02 +05301095 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma->psoc);
1096 if (!tgt_hdl) {
1097 WMA_LOGE("%s: target psoc info is NULL", __func__);
1098 return;
1099 }
1100
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 if (privcmd->param_id >= WMI_CMDID_MAX) {
1102 /*
1103 * This configuration setting is not done using any wmi
1104 * command, call appropriate handler.
1105 */
1106 if (wma_set_priv_cfg(wma, privcmd))
1107 WMA_LOGE("Failed to set wma priv congiuration");
1108 return;
1109 }
1110
1111 switch (privcmd->param_vp_dev) {
1112 case VDEV_CMD:
Bhargav Shaha89d3b42016-04-20 13:04:56 +05301113 if (!wma->interfaces[privcmd->param_vdev_id].is_vdev_valid) {
1114 WMA_LOGE("%s Vdev id is not valid", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001115 return;
Bhargav Shaha89d3b42016-04-20 13:04:56 +05301116 }
1117
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001118 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1119 privcmd->param_id, privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +05301120 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 privcmd->param_vdev_id,
1122 privcmd->param_id,
1123 privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +05301124 if (QDF_IS_STATUS_ERROR(ret)) {
1125 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126 ret);
1127 return;
1128 }
1129 break;
1130 case PDEV_CMD:
1131 WMA_LOGD("pdev pid %d pval %d", privcmd->param_id,
1132 privcmd->param_value);
1133 if ((privcmd->param_id == WMI_PDEV_PARAM_RX_CHAIN_MASK) ||
1134 (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK)) {
Jiachao Wu08719b02017-07-05 13:05:34 +08001135 if (QDF_STATUS_SUCCESS !=
1136 wma_check_txrx_chainmask(
Arunk Khandavalli2462f462018-01-25 14:41:02 +05301137 target_if_get_num_rf_chains(tgt_hdl),
Jiachao Wu08719b02017-07-05 13:05:34 +08001138 privcmd->param_value)) {
1139 WMA_LOGD("Chainmask value is invalid");
1140 return;
1141 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142 }
Govind Singhd76a5b02016-03-08 15:12:14 +05301143 pdev_param.param_id = privcmd->param_id;
1144 pdev_param.param_value = privcmd->param_value;
1145 ret = wmi_unified_pdev_param_send(wma->wmi_handle,
1146 &pdev_param,
1147 WMA_WILDCARD_PDEV_ID);
1148 if (QDF_IS_STATUS_ERROR(ret)) {
1149 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 ret);
1151 return;
1152 }
1153 break;
1154 case GEN_CMD:
1155 {
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001156 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157 struct wma_txrx_node *intr = wma->interfaces;
1158
1159 vdev = wma_find_vdev_by_id(wma, privcmd->param_vdev_id);
1160 if (!vdev) {
1161 WMA_LOGE("%s:Invalid vdev handle", __func__);
1162 return;
1163 }
1164
1165 WMA_LOGD("gen pid %d pval %d", privcmd->param_id,
1166 privcmd->param_value);
1167
1168 switch (privcmd->param_id) {
Arif Hussain0e246802018-05-01 18:13:44 -07001169 case GEN_VDEV_PARAM_AMSDU:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 case GEN_VDEV_PARAM_AMPDU:
Lin Baic1351142018-05-17 11:50:01 +08001171 if (!soc) {
1172 WMA_LOGE("%s:SOC context is NULL", __func__);
1173 return;
1174 }
1175
1176 if (privcmd->param_id == GEN_VDEV_PARAM_AMPDU) {
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301177 ret = cdp_aggr_cfg(soc, vdev,
1178 privcmd->param_value, 0);
1179 if (ret)
1180 WMA_LOGE("cdp_aggr_cfg set ampdu failed ret %d",
1181 ret);
1182 else
1183 intr[privcmd->param_vdev_id].config.
1184 ampdu = privcmd->param_value;
Arif Hussain0e246802018-05-01 18:13:44 -07001185
Lin Baic1351142018-05-17 11:50:01 +08001186 aggr.aggr_type =
1187 WMI_VDEV_CUSTOM_AGGR_TYPE_AMPDU;
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301188 } else {
Lin Baic1351142018-05-17 11:50:01 +08001189 aggr.aggr_type =
1190 WMI_VDEV_CUSTOM_AGGR_TYPE_AMSDU;
1191 }
1192
1193 aggr.vdev_id = vid;
1194 aggr.tx_aggregation_size = privcmd->param_value;
1195 aggr.rx_aggregation_size = privcmd->param_value;
1196
1197 ret = wma_set_tx_rx_aggregation_size(&aggr);
1198 if (QDF_IS_STATUS_ERROR(ret)) {
1199 WMA_LOGE("set_aggr_size failed ret %d", ret);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301200 return;
1201 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 case GEN_PARAM_CRASH_INJECT:
Rajeev Kumar0a9901b2015-12-15 15:59:19 -08001204 if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
1205 WMA_LOGE("Crash inject not allowed in FTM mode");
1206 else
1207 ret = wma_crash_inject(wma,
1208 privcmd->param_value,
1209 privcmd->param_sec_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001211 case GEN_PARAM_CAPTURE_TSF:
1212 ret = wma_capture_tsf(wma, privcmd->param_value);
1213 break;
1214 case GEN_PARAM_RESET_TSF_GPIO:
1215 ret = wma_reset_tsf_gpio(wma, privcmd->param_value);
1216 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 case GEN_PARAM_MODULATED_DTIM:
1218 wma_set_modulated_dtim(wma, privcmd);
1219 break;
Mukul Sharma6398b252017-05-01 17:58:12 +05301220 case GEN_PARAM_LISTEN_INTERVAL:
1221 wma_override_listen_interval(wma, privcmd);
1222 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 default:
1224 WMA_LOGE("Invalid param id 0x%x",
1225 privcmd->param_id);
1226 break;
1227 }
1228 break;
1229 }
1230 case DBG_CMD:
1231 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1232 privcmd->param_value);
1233 switch (privcmd->param_id) {
1234 case WMI_DBGLOG_LOG_LEVEL:
1235 ret = dbglog_set_log_lvl(wma->wmi_handle,
1236 privcmd->param_value);
1237 if (ret)
1238 WMA_LOGE("dbglog_set_log_lvl failed ret %d",
1239 ret);
1240 break;
1241 case WMI_DBGLOG_VAP_ENABLE:
1242 ret = dbglog_vap_log_enable(wma->wmi_handle,
1243 privcmd->param_value, true);
1244 if (ret)
1245 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1246 ret);
1247 break;
1248 case WMI_DBGLOG_VAP_DISABLE:
1249 ret = dbglog_vap_log_enable(wma->wmi_handle,
1250 privcmd->param_value, false);
1251 if (ret)
1252 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1253 ret);
1254 break;
1255 case WMI_DBGLOG_MODULE_ENABLE:
1256 ret = dbglog_module_log_enable(wma->wmi_handle,
1257 privcmd->param_value, true);
1258 if (ret)
1259 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1260 ret);
1261 break;
1262 case WMI_DBGLOG_MODULE_DISABLE:
1263 ret = dbglog_module_log_enable(wma->wmi_handle,
1264 privcmd->param_value, false);
1265 if (ret)
1266 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1267 ret);
1268 break;
1269 case WMI_DBGLOG_MOD_LOG_LEVEL:
1270 ret = dbglog_set_mod_log_lvl(wma->wmi_handle,
1271 privcmd->param_value);
1272 if (ret)
1273 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1274 ret);
1275 break;
1276 case WMI_DBGLOG_TYPE:
1277 ret = dbglog_parser_type_init(wma->wmi_handle,
1278 privcmd->param_value);
1279 if (ret)
1280 WMA_LOGE("dbglog_parser_type_init failed ret %d",
1281 ret);
1282 break;
1283 case WMI_DBGLOG_REPORT_ENABLE:
1284 ret = dbglog_report_enable(wma->wmi_handle,
1285 privcmd->param_value);
1286 if (ret)
1287 WMA_LOGE("dbglog_report_enable failed ret %d",
1288 ret);
1289 break;
Govind Singha471e5e2015-10-12 17:11:14 +05301290 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301291 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301292 WMI_WLAN_PROFILE_TRIGGER_CMDID,
1293 privcmd->param_value, 0);
1294 if (ret)
1295 WMA_LOGE("Profile cmd failed for %d ret %d",
1296 WMI_WLAN_PROFILE_TRIGGER_CMDID, ret);
1297 break;
1298 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301299 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301300 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1301 privcmd->param_value,
1302 privcmd->param_sec_value);
1303 if (ret)
1304 WMA_LOGE("Profile cmd failed for %d ret %d",
1305 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1306 ret);
1307 break;
1308 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301309 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301310 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1311 privcmd->param_value,
1312 privcmd->param_sec_value);
1313 if (ret)
1314 WMA_LOGE("Profile cmd failed for %d ret %d",
1315 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1316 ret);
1317 break;
1318 case WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301319 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301320 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1321 0, 0);
1322 if (ret)
1323 WMA_LOGE("Profile cmd failed for %d ret %d",
1324 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1325 ret);
1326 break;
1327 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301328 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301329 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1330 0, 0);
1331 if (ret)
1332 WMA_LOGE("Profile cmd failed for %d ret %d",
1333 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1334 ret);
1335 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 case WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID:
1337 /* Set the Green AP */
Govind Singhd76a5b02016-03-08 15:12:14 +05301338 ret = wmi_unified_green_ap_ps_send
1339 (wma->wmi_handle, privcmd->param_value,
1340 WMA_WILDCARD_PDEV_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 if (ret) {
1342 WMA_LOGE("Set GreenAP Failed val %d",
1343 privcmd->param_value);
1344 }
1345 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346
1347 default:
1348 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1349 break;
1350 }
1351 break;
1352 case PPS_CMD:
1353 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1354 privcmd->param_value);
1355 switch (privcmd->param_id) {
1356
1357 case WMI_VDEV_PPS_PAID_MATCH:
1358 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1359 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
1360 intr[vid].config.pps_params.paid_match_enable =
1361 privcmd->param_value;
1362 break;
1363 case WMI_VDEV_PPS_GID_MATCH:
1364 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1365 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
1366 intr[vid].config.pps_params.gid_match_enable =
1367 privcmd->param_value;
1368 break;
1369 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
1370 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1371 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
1372 intr[vid].config.pps_params.tim_clear =
1373 privcmd->param_value;
1374 break;
1375 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
1376 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1377 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
1378 intr[vid].config.pps_params.dtim_clear =
1379 privcmd->param_value;
1380 break;
1381 case WMI_VDEV_PPS_EOF_PAD_DELIM:
1382 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1383 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
1384 intr[vid].config.pps_params.eof_delim =
1385 privcmd->param_value;
1386 break;
1387 case WMI_VDEV_PPS_MACADDR_MISMATCH:
1388 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1389 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
1390 intr[vid].config.pps_params.mac_match =
1391 privcmd->param_value;
1392 break;
1393 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
1394 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1395 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
1396 intr[vid].config.pps_params.delim_fail =
1397 privcmd->param_value;
1398 break;
1399 case WMI_VDEV_PPS_GID_NSTS_ZERO:
1400 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1401 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
1402 intr[vid].config.pps_params.nsts_zero =
1403 privcmd->param_value;
1404 break;
1405 case WMI_VDEV_PPS_RSSI_CHECK:
1406 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1407 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
1408 intr[vid].config.pps_params.rssi_chk =
1409 privcmd->param_value;
1410 break;
1411 case WMI_VDEV_PPS_5G_EBT:
1412 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1413 (PKT_PWR_SAVE_5G_EBT & 0xffff);
1414 intr[vid].config.pps_params.ebt_5g =
1415 privcmd->param_value;
1416 break;
1417 default:
1418 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1419 break;
1420 }
1421 break;
1422
1423 case QPOWER_CMD:
1424 WMA_LOGD("QPOWER CLI CMD pid %d pval %d", privcmd->param_id,
1425 privcmd->param_value);
1426 switch (privcmd->param_id) {
1427 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
1428 WMA_LOGD("QPOWER CLI CMD:Ps Poll Cnt val %d",
1429 privcmd->param_value);
1430 /* Set the QPower Ps Poll Count */
Govind Singhd76a5b02016-03-08 15:12:14 +05301431 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 vid, WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
1433 privcmd->param_value);
1434 if (ret) {
1435 WMA_LOGE("Set Q-PsPollCnt Failed vdevId %d val %d",
1436 vid, privcmd->param_value);
1437 } else {
1438 qparams->max_ps_poll_cnt = privcmd->param_value;
1439 }
1440 break;
1441 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
1442 WMA_LOGD("QPOWER CLI CMD:Max Tx Before wake val %d",
1443 privcmd->param_value);
1444 /* Set the QPower Max Tx Before Wake */
Govind Singhd76a5b02016-03-08 15:12:14 +05301445 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 vid, WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
1447 privcmd->param_value);
1448 if (ret) {
1449 WMA_LOGE("Set Q-MaxTxBefWake Failed vId %d val %d",
1450 vid, privcmd->param_value);
1451 } else {
1452 qparams->max_tx_before_wake =
1453 privcmd->param_value;
1454 }
1455 break;
1456 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
1457 WMA_LOGD("QPOWER CLI CMD:Ps Poll Wake Inv val %d",
1458 privcmd->param_value);
1459 /* Set the QPower Spec Ps Poll Wake Inv */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001460 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1461 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 privcmd->param_value);
1463 if (ret) {
1464 WMA_LOGE("Set Q-PsPoll WakeIntv Failed vId %d val %d",
1465 vid, privcmd->param_value);
1466 } else {
1467 qparams->spec_ps_poll_wake_interval =
1468 privcmd->param_value;
1469 }
1470 break;
1471 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
1472 WMA_LOGD("QPOWER CLI CMD:Spec NoData Ps Poll val %d",
1473 privcmd->param_value);
1474 /* Set the QPower Spec NoData PsPoll */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001475 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1476 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001477 privcmd->param_value);
1478 if (ret) {
1479 WMA_LOGE("Set Q-SpecNoDataPsPoll Failed vId %d val %d",
1480 vid, privcmd->param_value);
1481 } else {
1482 qparams->max_spec_nodata_ps_poll =
1483 privcmd->param_value;
1484 }
1485 break;
1486
1487 default:
1488 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1489 break;
1490 }
1491 break;
1492 case GTX_CMD:
1493 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1494 privcmd->param_id, privcmd->param_value);
1495 switch (privcmd->param_id) {
1496 case WMI_VDEV_PARAM_GTX_HT_MCS:
1497 intr[vid].config.gtx_info.gtxRTMask[0] =
1498 privcmd->param_value;
1499 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1500 privcmd->param_vdev_id,
1501 &intr[vid].config.gtx_info);
1502 break;
1503 case WMI_VDEV_PARAM_GTX_VHT_MCS:
1504 intr[vid].config.gtx_info.gtxRTMask[1] =
1505 privcmd->param_value;
1506 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1507 privcmd->param_vdev_id,
1508 &intr[vid].config.gtx_info);
1509 break;
1510
1511 case WMI_VDEV_PARAM_GTX_USR_CFG:
1512 intr[vid].config.gtx_info.gtxUsrcfg =
1513 privcmd->param_value;
1514 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1515 privcmd->param_vdev_id,
1516 &intr[vid].config.gtx_info);
1517 break;
1518
1519 case WMI_VDEV_PARAM_GTX_THRE:
1520 intr[vid].config.gtx_info.gtxPERThreshold =
1521 privcmd->param_value;
1522 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1523 privcmd->param_vdev_id,
1524 &intr[vid].config.gtx_info);
1525 break;
1526
1527 case WMI_VDEV_PARAM_GTX_MARGIN:
1528 intr[vid].config.gtx_info.gtxPERMargin =
1529 privcmd->param_value;
1530 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1531 privcmd->param_vdev_id,
1532 &intr[vid].config.gtx_info);
1533 break;
1534
1535 case WMI_VDEV_PARAM_GTX_STEP:
1536 intr[vid].config.gtx_info.gtxTPCstep =
1537 privcmd->param_value;
1538 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1539 privcmd->param_vdev_id,
1540 &intr[vid].config.gtx_info);
1541 break;
1542
1543 case WMI_VDEV_PARAM_GTX_MINTPC:
1544 intr[vid].config.gtx_info.gtxTPCMin =
1545 privcmd->param_value;
1546 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1547 privcmd->param_vdev_id,
1548 &intr[vid].config.gtx_info);
1549 break;
1550
1551 case WMI_VDEV_PARAM_GTX_BW_MASK:
1552 intr[vid].config.gtx_info.gtxBWMask =
1553 privcmd->param_value;
1554 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1555 privcmd->param_vdev_id,
1556 &intr[vid].config.gtx_info);
1557 if (ret) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001558 WMA_LOGE("wma_vdev_set_param failed ret %d",
1559 ret);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 return;
1561 }
1562 break;
1563 default:
1564 break;
1565 }
1566 break;
1567
1568 default:
1569 WMA_LOGE("Invalid vpdev command id");
1570 }
1571 if (1 == privcmd->param_vp_dev) {
1572 switch (privcmd->param_id) {
1573 case WMI_VDEV_PARAM_NSS:
1574 intr[vid].config.nss = privcmd->param_value;
1575 break;
1576 case WMI_VDEV_PARAM_LDPC:
1577 intr[vid].config.ldpc = privcmd->param_value;
1578 break;
1579 case WMI_VDEV_PARAM_TX_STBC:
1580 intr[vid].config.tx_stbc = privcmd->param_value;
1581 break;
1582 case WMI_VDEV_PARAM_RX_STBC:
1583 intr[vid].config.rx_stbc = privcmd->param_value;
1584 break;
1585 case WMI_VDEV_PARAM_SGI:
1586 intr[vid].config.shortgi = privcmd->param_value;
1587 break;
1588 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
1589 intr[vid].config.rtscts_en = privcmd->param_value;
1590 break;
1591 case WMI_VDEV_PARAM_CHWIDTH:
1592 intr[vid].config.chwidth = privcmd->param_value;
1593 break;
1594 case WMI_VDEV_PARAM_FIXED_RATE:
1595 intr[vid].config.tx_rate = privcmd->param_value;
1596 break;
1597 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE:
1598 intr[vid].config.erx_adjust = privcmd->param_value;
1599 break;
1600 case WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM:
1601 intr[vid].config.erx_bmiss_num = privcmd->param_value;
1602 break;
1603 case WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE:
1604 intr[vid].config.erx_bmiss_cycle = privcmd->param_value;
1605 break;
1606 case WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP:
1607 intr[vid].config.erx_slop_step = privcmd->param_value;
1608 break;
1609 case WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP:
1610 intr[vid].config.erx_init_slop = privcmd->param_value;
1611 break;
1612 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE:
1613 intr[vid].config.erx_adj_pause = privcmd->param_value;
1614 break;
1615 case WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE:
1616 intr[vid].config.erx_dri_sample = privcmd->param_value;
1617 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001618 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001619 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001620 wma_set_he_vdev_param(&intr[vid], privcmd->param_id,
1621 privcmd->param_value);
1622 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001624 WMA_LOGE("Invalid wma_cli_set vdev command/Not yet implemented 0x%x",
1625 privcmd->param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 break;
1627 }
1628 } else if (2 == privcmd->param_vp_dev) {
1629 switch (privcmd->param_id) {
1630 case WMI_PDEV_PARAM_ANI_ENABLE:
1631 wma->pdevconfig.ani_enable = privcmd->param_value;
1632 break;
1633 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
1634 wma->pdevconfig.ani_poll_len = privcmd->param_value;
1635 break;
1636 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
1637 wma->pdevconfig.ani_listen_len = privcmd->param_value;
1638 break;
1639 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
1640 wma->pdevconfig.ani_ofdm_level = privcmd->param_value;
1641 break;
1642 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
1643 wma->pdevconfig.ani_cck_level = privcmd->param_value;
1644 break;
1645 case WMI_PDEV_PARAM_DYNAMIC_BW:
1646 wma->pdevconfig.cwmenable = privcmd->param_value;
1647 break;
1648 case WMI_PDEV_PARAM_CTS_CBW:
1649 wma->pdevconfig.cts_cbw = privcmd->param_value;
1650 break;
1651 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
1652 wma->pdevconfig.txchainmask = privcmd->param_value;
1653 break;
1654 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
1655 wma->pdevconfig.rxchainmask = privcmd->param_value;
1656 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
1658 wma->pdevconfig.txpow2g = privcmd->param_value;
1659 if ((pMac->roam.configParam.bandCapability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001660 BAND_ALL) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 (pMac->roam.configParam.bandCapability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001662 BAND_2G)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 if (cfg_set_int(pMac,
1664 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1665 privcmd->param_value) !=
Jeff Johnsone88dd752018-06-07 22:57:54 -07001666 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1668
1669 } else {
1670 WMA_LOGE("Current band is not 2G");
1671 }
1672 break;
1673 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
1674 wma->pdevconfig.txpow5g = privcmd->param_value;
1675 if ((pMac->roam.configParam.bandCapability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001676 BAND_ALL) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 (pMac->roam.configParam.bandCapability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001678 BAND_5G)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 if (cfg_set_int(pMac,
1680 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1681 privcmd->param_value) !=
Jeff Johnsone88dd752018-06-07 22:57:54 -07001682 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1684
1685 } else {
1686 WMA_LOGE("Current band is not 5G");
1687 }
1688 break;
1689 default:
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001690 WMA_LOGD("Invalid wma_cli_set pdev command/Not yet implemented 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 privcmd->param_id);
1692 break;
1693 }
1694 } else if (5 == privcmd->param_vp_dev) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301695 ret = wma_vdev_set_param(wma->wmi_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001696 privcmd->param_vdev_id,
1697 WMI_VDEV_PARAM_PACKET_POWERSAVE,
1698 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 if (ret)
1700 WMA_LOGE("Failed to send wmi packet power save cmd");
1701 else
1702 WMA_LOGD("Sent packet power save cmd %d value %x to target",
1703 privcmd->param_id, pps_val);
1704 }
1705}
1706
Dustin Brown05557182017-10-12 14:44:49 -07001707uint32_t wma_critical_events_in_flight(void)
1708{
1709 t_wma_handle *wma;
1710
1711 wma = cds_get_context(QDF_MODULE_ID_WMA);
1712 if (!wma)
1713 return 0;
1714
1715 return qdf_atomic_read(&wma->critical_events_in_flight);
1716}
1717
1718static bool wma_event_is_critical(uint32_t event_id)
1719{
1720 switch (event_id) {
1721 case WMI_ROAM_SYNCH_EVENTID:
1722 return true;
1723 default:
1724 return false;
1725 }
1726}
1727
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728/**
1729 * wma_process_fw_event() - process any fw event
1730 * @wma: wma handle
1731 * @buf: fw event buffer
1732 *
1733 * This function process any fw event to serialize it through mc thread.
1734 *
1735 * Return: none
1736 */
1737static int wma_process_fw_event(tp_wma_handle wma,
1738 wma_process_fw_event_params *buf)
1739{
1740 struct wmi_unified *wmi_handle = (struct wmi_unified *)buf->wmi_handle;
Dustin Brown05557182017-10-12 14:44:49 -07001741 uint32_t event_id = WMI_GET_FIELD(qdf_nbuf_data(buf->evt_buf),
1742 WMI_CMD_HDR, COMMANDID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743
1744 wmi_process_fw_event(wmi_handle, buf->evt_buf);
Dustin Brown05557182017-10-12 14:44:49 -07001745
1746 if (wma_event_is_critical(event_id))
1747 qdf_atomic_dec(&wma->critical_events_in_flight);
1748
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 return 0;
1750}
1751
1752/**
Govind Singhd76a5b02016-03-08 15:12:14 +05301753 * wmi_process_fw_event_tasklet_ctx() - process in tasklet context
1754 * @ctx: handle to wmi
1755 * @ev: wmi event buffer
1756 *
1757 * Event process by below function will be in tasket context,
1758 * need to use this method only for time sensitive functions.
1759 *
1760 * Return: none
1761 */
1762static int wma_process_fw_event_tasklet_ctx(void *ctx, void *ev)
1763{
1764 wmi_process_fw_event(ctx, ev);
1765
1766 return 0;
1767}
1768
1769/**
Manjeet Singhf82ed072016-07-08 11:40:00 +05301770 * wma_process_hal_pwr_dbg_cmd() - send hal pwr dbg cmd to fw.
1771 * @handle: wma handle
1772 * @sir_pwr_dbg_params: unit test command
1773 *
1774 * This function send unit test command to fw.
1775 *
1776 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
1777 */
1778QDF_STATUS wma_process_hal_pwr_dbg_cmd(WMA_HANDLE handle,
1779 struct sir_mac_pwr_dbg_cmd *
1780 sir_pwr_dbg_params)
1781{
1782 tp_wma_handle wma_handle = (tp_wma_handle)handle;
1783 int i;
1784 struct wmi_power_dbg_params wmi_pwr_dbg_params;
1785 QDF_STATUS status;
1786
1787 if (!sir_pwr_dbg_params) {
1788 WMA_LOGE("%s: sir_pwr_dbg_params is null", __func__);
1789 return QDF_STATUS_E_INVAL;
1790 }
1791 wmi_pwr_dbg_params.module_id = sir_pwr_dbg_params->module_id;
1792 wmi_pwr_dbg_params.pdev_id = sir_pwr_dbg_params->pdev_id;
1793 wmi_pwr_dbg_params.num_args = sir_pwr_dbg_params->num_args;
1794
1795 for (i = 0; i < wmi_pwr_dbg_params.num_args; i++)
1796 wmi_pwr_dbg_params.args[i] = sir_pwr_dbg_params->args[i];
1797
1798 status = wmi_unified_send_power_dbg_cmd(wma_handle->wmi_handle,
1799 &wmi_pwr_dbg_params);
1800
1801 return status;
1802}
1803
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001804static void wma_discard_fw_event(struct scheduler_msg *msg)
1805{
Will Huang9323e852018-02-02 17:55:15 +08001806 if (!msg->bodyptr)
1807 return;
1808
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001809 switch (msg->type) {
1810 case WMA_PROCESS_FW_EVENT:
1811 qdf_nbuf_free(((wma_process_fw_event_params *)msg->bodyptr)
1812 ->evt_buf);
1813 break;
Abhishek Singhcaf6a652017-07-06 17:35:42 +05301814 case WMA_SET_LINK_STATE:
1815 qdf_mem_free(((tpLinkStateParams) msg->bodyptr)->callbackArg);
1816 break;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001817 }
Will Huang9323e852018-02-02 17:55:15 +08001818
1819 qdf_mem_free(msg->bodyptr);
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001820 msg->bodyptr = NULL;
1821 msg->bodyval = 0;
1822 msg->type = 0;
1823}
1824
Manjeet Singhf82ed072016-07-08 11:40:00 +05301825/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 * wma_process_fw_event_handler() - common event handler to serialize
1827 * event processing through mc_thread
Govind Singhd76a5b02016-03-08 15:12:14 +05301828 * @ctx: wmi context
1829 * @ev: event buffer
1830 * @rx_ctx: rx execution context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 *
1832 * Return: 0 on success, errno on failure
1833 */
Govind Singhd76a5b02016-03-08 15:12:14 +05301834static int wma_process_fw_event_mc_thread_ctx(void *ctx, void *ev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835{
1836 wma_process_fw_event_params *params_buf;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001837 struct scheduler_msg cds_msg = { 0 };
Dustin Brown05557182017-10-12 14:44:49 -07001838 tp_wma_handle wma;
1839 uint32_t event_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301841 params_buf = qdf_mem_malloc(sizeof(wma_process_fw_event_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 if (!params_buf) {
1843 WMA_LOGE("%s: Failed alloc memory for params_buf", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301844 qdf_nbuf_free(ev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 return -ENOMEM;
1846 }
1847
Govind Singhd76a5b02016-03-08 15:12:14 +05301848 params_buf->wmi_handle = (struct wmi_unified *)ctx;
1849 params_buf->evt_buf = (wmi_buf_t *)ev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850
Dustin Brown05557182017-10-12 14:44:49 -07001851 wma = cds_get_context(QDF_MODULE_ID_WMA);
1852 event_id = WMI_GET_FIELD(qdf_nbuf_data(params_buf->evt_buf),
1853 WMI_CMD_HDR, COMMANDID);
1854 if (wma && wma_event_is_critical(event_id))
1855 qdf_atomic_inc(&wma->critical_events_in_flight);
1856
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 cds_msg.type = WMA_PROCESS_FW_EVENT;
1858 cds_msg.bodyptr = params_buf;
1859 cds_msg.bodyval = 0;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001860 cds_msg.flush_callback = wma_discard_fw_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301862 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001863 scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001864 WMA_LOGE("%s: Failed to post WMA_PROCESS_FW_EVENT msg",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301866 qdf_nbuf_free(ev);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301867 qdf_mem_free(params_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 return -EFAULT;
1869 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 return 0;
1871
1872}
1873
Govind Singhd76a5b02016-03-08 15:12:14 +05301874/**
1875 * wma_process_fw_event_handler() - common event handler to serialize
1876 * event processing through mc_thread
1877 * @ctx: wmi context
1878 * @ev: event buffer
1879 * @rx_ctx: rx execution context
1880 *
1881 * Return: 0 on success, errno on failure
1882 */
1883int wma_process_fw_event_handler(void *ctx, void *ev, uint8_t rx_ctx)
1884{
1885 int err = 0;
1886
1887 if (rx_ctx == WMA_RX_SERIALIZER_CTX) {
1888 err = wma_process_fw_event_mc_thread_ctx(ctx, ev);
1889 } else if (rx_ctx == WMA_RX_TASKLET_CTX) {
1890 wma_process_fw_event_tasklet_ctx(ctx, ev);
1891 } else {
1892 WMA_LOGE("%s: invalid wmi event execution context", __func__);
1893 qdf_nbuf_free(ev);
1894 }
1895
1896 return err;
1897}
1898
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899#ifdef WLAN_FEATURE_NAN
1900/**
1901 * wma_set_nan_enable() - set nan enable flag in WMA handle
1902 * @wma_handle: Pointer to wma handle
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301903 * @cds_cfg: Pointer to CDS Configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904 *
1905 * Return: none
1906 */
1907static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301908 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909{
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301910 wma_handle->is_nan_enabled = cds_cfg->is_nan_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911}
1912#else
1913static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301914 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915{
1916}
1917#endif
1918
1919/**
Komal Seelam02d09342016-02-23 18:03:19 +05301920 * wma_init_max_no_of_peers - API to initialize wma configuration params
1921 * @wma_handle: WMA Handle
1922 * @max_peers: Max Peers supported
1923 *
1924 * Return: void
1925 */
Rachit Kankane0106e382018-05-16 18:59:28 +05301926static uint8_t wma_init_max_no_of_peers(tp_wma_handle wma_handle,
Komal Seelam02d09342016-02-23 18:03:19 +05301927 uint16_t max_peers)
1928{
1929 struct wma_ini_config *cfg = wma_get_ini_handle(wma_handle);
Rachit Kankane0106e382018-05-16 18:59:28 +05301930 struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF);
1931 uint32_t tgt_version = hif_get_target_info_handle(scn)->target_version;
1932 uint8_t max_no_of_peers;
1933 uint8_t max_supported_peers = (tgt_version == AR6320_REV1_1_VERSION) ?
1934 MAX_SUPPORTED_PEERS_REV1_1 : MAX_SUPPORTED_PEERS_REV1_3;
Komal Seelam02d09342016-02-23 18:03:19 +05301935
Naveen Rawat35804772016-06-27 15:40:28 -07001936 if (cfg == NULL) {
1937 WMA_LOGE("%s: NULL WMA ini handle", __func__);
Rachit Kankane0106e382018-05-16 18:59:28 +05301938 return 0;
Naveen Rawat35804772016-06-27 15:40:28 -07001939 }
1940
Rachit Kankane0106e382018-05-16 18:59:28 +05301941 max_no_of_peers = (max_peers > max_supported_peers) ?
1942 max_supported_peers : max_peers;
1943 cfg->max_no_of_peers = max_no_of_peers;
1944 return max_no_of_peers;
Komal Seelam02d09342016-02-23 18:03:19 +05301945}
1946
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001947/**
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001948 * wma_cleanup_vdev_resp_queue() - cleanup vdev response queue
1949 * @wma: wma handle
1950 *
1951 * Return: none
1952 */
1953static void wma_cleanup_vdev_resp_queue(tp_wma_handle wma)
1954{
1955 struct wma_target_req *req_msg = NULL;
1956 qdf_list_node_t *node1 = NULL;
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001957
1958 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1959 if (!qdf_list_size(&wma->vdev_resp_queue)) {
1960 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08001961 WMA_LOGD(FL("request queue maybe empty"));
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001962 return;
1963 }
1964
Sandeep Puligilla5ac6bd22017-10-17 12:33:56 -07001965 WMA_LOGD(FL("Cleaning up vdev resp queue"));
1966
Wu Gao30f65eb2017-08-09 19:56:10 +08001967 /* peek front, and then cleanup it in wma_vdev_resp_timer */
1968 while (qdf_list_peek_front(&wma->vdev_resp_queue, &node1) ==
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001969 QDF_STATUS_SUCCESS) {
1970 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001971 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Abhishek Singhc614ec42017-04-25 16:17:34 +05301972 qdf_mc_timer_stop(&req_msg->event_timeout);
1973 wma_vdev_resp_timer(req_msg);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001974 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1975 }
1976 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
1977}
1978
1979/**
Abhishek Singhc614ec42017-04-25 16:17:34 +05301980 * wma_cleanup_hold_req() - cleanup hold request queue
1981 * @wma: wma handle
1982 *
1983 * Return: none
1984 */
1985static void wma_cleanup_hold_req(tp_wma_handle wma)
1986{
1987 struct wma_target_req *req_msg = NULL;
1988 qdf_list_node_t *node1 = NULL;
1989
1990 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
1991 if (!qdf_list_size(&wma->wma_hold_req_queue)) {
1992 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1993 WMA_LOGD(FL("request queue is empty"));
1994 return;
1995 }
1996
Wu Gao30f65eb2017-08-09 19:56:10 +08001997 /* peek front, and then cleanup it in wma_hold_req_timer */
Abhishek Singhc614ec42017-04-25 16:17:34 +05301998 while (QDF_STATUS_SUCCESS ==
Wu Gao30f65eb2017-08-09 19:56:10 +08001999 qdf_list_peek_front(&wma->wma_hold_req_queue, &node1)) {
Abhishek Singhc614ec42017-04-25 16:17:34 +05302000 req_msg = qdf_container_of(node1, struct wma_target_req, node);
2001 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
2002 /* Cleanup timeout handler */
2003 qdf_mc_timer_stop(&req_msg->event_timeout);
Abhishek Singhc614ec42017-04-25 16:17:34 +05302004 wma_hold_req_timer(req_msg);
2005 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
2006 }
2007 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
2008}
2009
2010/**
Abhishek Singh0ac37442018-05-02 21:07:57 +05302011 * wma_cleanup_vdev_resp_and_hold_req() - cleaunup the vdev resp and hold req
2012 * queue
2013 * @msg :scheduler msg
2014 *
2015 * Return: QDF_STATUS
2016 */
2017static QDF_STATUS
2018wma_cleanup_vdev_resp_and_hold_req(struct scheduler_msg *msg)
2019{
2020 if (!msg || !msg->bodyptr) {
2021 WMA_LOGE(FL("msg or body pointer is NULL"));
2022 return QDF_STATUS_E_INVAL;
2023 }
2024
2025 wma_cleanup_vdev_resp_queue(msg->bodyptr);
2026 wma_cleanup_hold_req(msg->bodyptr);
2027
2028 return QDF_STATUS_SUCCESS;
2029}
2030
2031/**
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002032 * wma_shutdown_notifier_cb - Shutdown notifer call back
2033 * @priv : WMA handle
2034 *
2035 * During recovery, WMA may wait for resume to complete if the crash happens
2036 * while in suspend. This may cause delays in completing the recovery. This call
2037 * back would be called during recovery and the event is completed so that if
2038 * the resume is waiting on FW to respond then it can get out of the wait so
2039 * that recovery thread can start bringing down all the modules.
2040 *
2041 * Return: None
2042 */
2043static void wma_shutdown_notifier_cb(void *priv)
2044{
2045 tp_wma_handle wma_handle = priv;
Abhishek Singh0ac37442018-05-02 21:07:57 +05302046 struct scheduler_msg msg = { 0 };
2047 QDF_STATUS status;
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002048
2049 qdf_event_set(&wma_handle->wma_resume_event);
Mukul Sharma4c60a7e2017-03-06 19:42:18 +05302050 pmo_ucfg_psoc_wakeup_host_event_received(wma_handle->psoc);
Abhishek Singh0ac37442018-05-02 21:07:57 +05302051
2052 msg.bodyptr = priv;
2053 msg.callback = wma_cleanup_vdev_resp_and_hold_req;
2054 status = scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &msg);
2055 if (QDF_IS_STATUS_ERROR(status))
2056 WMA_LOGE(FL("Failed to post SYS_MSG_ID_CLEAN_VDEV_RSP_QUEUE"));
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002057}
2058
Mukul Sharma5ff3c582016-09-12 15:23:35 +05302059struct wma_version_info g_wmi_version_info;
2060
Wen Gong3f003382018-05-14 14:26:37 +08002061#ifdef WLAN_FEATURE_MEMDUMP_ENABLE
Komal Seelam02d09342016-02-23 18:03:19 +05302062/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302063 * wma_state_info_dump() - prints state information of wma layer
2064 * @buf: buffer pointer
2065 * @size: size of buffer to be filled
2066 *
2067 * This function is used to dump state information of wma layer
2068 *
2069 * Return: None
2070 */
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002071#ifdef QCA_SUPPORT_CP_STATS
2072static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
2073{
2074 uint8_t vdev_id;
2075 uint16_t len = 0;
2076 t_wma_handle *wma;
2077 char *buf = *buf_ptr;
2078 struct wma_txrx_node *iface;
2079 struct wake_lock_stats stats;
2080 struct wlan_objmgr_vdev *vdev;
2081
2082 wma = cds_get_context(QDF_MODULE_ID_WMA);
2083 if (!wma) {
2084 WMA_LOGE("%s: WMA context is invald!", __func__);
2085 return;
2086 }
2087
2088 WMA_LOGE("%s: size of buffer: %d", __func__, *size);
2089
2090 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
2091 iface = &wma->interfaces[vdev_id];
2092 if (!iface->handle)
2093 continue;
2094
2095 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(wma->psoc,
2096 vdev_id, WLAN_LEGACY_WMA_ID);
Yeshwanth Sriram Guntuka0e6f4462018-05-07 17:33:43 +05302097 if (vdev == NULL)
2098 continue;
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002099 ucfg_mc_cp_stats_get_vdev_wake_lock_stats(vdev, &stats);
2100 len += qdf_scnprintf(buf + len, *size - len,
2101 "\n"
2102 "vdev_id %d\n"
2103 "WoW Stats\n"
2104 "\tpno_match %u\n"
2105 "\tpno_complete %u\n"
2106 "\tgscan %u\n"
2107 "\tlow_rssi %u\n"
2108 "\trssi_breach %u\n"
2109 "\tucast %u\n"
2110 "\tbcast %u\n"
2111 "\ticmpv4 %u\n"
2112 "\ticmpv6 %u\n"
2113 "\tipv4_mcast %u\n"
2114 "\tipv6_mcast %u\n"
2115 "\tipv6_mcast_ra %u\n"
2116 "\tipv6_mcast_ns %u\n"
2117 "\tipv6_mcast_na %u\n"
2118 "\toem_response %u\n"
2119 "conn_state %d\n"
2120 "dtimPeriod %d\n"
2121 "chanmode %d\n"
2122 "vht_capable %d\n"
2123 "ht_capable %d\n"
2124 "chan_width %d\n"
2125 "vdev_active %d\n"
2126 "vdev_up %d\n"
2127 "aid %d\n"
2128 "rate_flags %d\n"
2129 "nss %d\n"
2130 "tx_power %d\n"
2131 "max_tx_power %d\n"
2132 "nwType %d\n"
2133 "tx_streams %d\n"
2134 "rx_streams %d\n"
2135 "chain_mask %d\n"
2136 "nss_2g %d\n"
2137 "nss_5g %d",
2138 vdev_id,
2139 stats.pno_match_wake_up_count,
2140 stats.pno_complete_wake_up_count,
2141 stats.gscan_wake_up_count,
2142 stats.low_rssi_wake_up_count,
2143 stats.rssi_breach_wake_up_count,
2144 stats.ucast_wake_up_count,
2145 stats.bcast_wake_up_count,
2146 stats.icmpv4_count,
2147 stats.icmpv6_count,
2148 stats.ipv4_mcast_wake_up_count,
2149 stats.ipv6_mcast_wake_up_count,
2150 stats.ipv6_mcast_ra_stats,
2151 stats.ipv6_mcast_ns_stats,
2152 stats.ipv6_mcast_na_stats,
2153 stats.oem_response_wake_up_count,
2154 iface->conn_state,
2155 iface->dtimPeriod,
2156 iface->chanmode,
2157 iface->vht_capable,
2158 iface->ht_capable,
2159 iface->chan_width,
2160 iface->vdev_active,
2161 wma_is_vdev_up(vdev_id),
2162 iface->aid,
2163 iface->rate_flags,
2164 iface->nss,
2165 iface->tx_power,
2166 iface->max_tx_power,
2167 iface->nwType,
2168 iface->tx_streams,
2169 iface->rx_streams,
2170 iface->chain_mask,
2171 iface->nss_2g,
2172 iface->nss_5g);
Yeshwanth Sriram Guntuka0e6f4462018-05-07 17:33:43 +05302173 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_WMA_ID);
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002174 }
2175
2176 *size -= len;
2177 *buf_ptr += len;
2178}
2179#else /* QCA_SUPPORT_CP_STATS */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302180static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
2181{
Dustin Brown9d797d62017-01-11 16:39:12 -08002182 t_wma_handle *wma;
2183 struct sir_vdev_wow_stats *stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302184 uint16_t len = 0;
2185 char *buf = *buf_ptr;
2186 struct wma_txrx_node *iface;
2187 uint8_t vdev_id;
2188
Dustin Brown9d797d62017-01-11 16:39:12 -08002189 wma = cds_get_context(QDF_MODULE_ID_WMA);
2190 if (!wma) {
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302191 WMA_LOGE("%s: WMA context is invald!", __func__);
2192 return;
2193 }
2194
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002195 WMA_LOGE("%s: size of buffer: %d", __func__, *size);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302196
Dustin Brown9d797d62017-01-11 16:39:12 -08002197 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
2198 iface = &wma->interfaces[vdev_id];
2199 if (!iface->handle)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302200 continue;
2201
Dustin Brown9d797d62017-01-11 16:39:12 -08002202 stats = &iface->wow_stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302203 len += qdf_scnprintf(buf + len, *size - len,
Dustin Brown9d797d62017-01-11 16:39:12 -08002204 "\n"
2205 "vdev_id %d\n"
2206 "WoW Stats\n"
2207 "\tpno_match %u\n"
2208 "\tpno_complete %u\n"
2209 "\tgscan %u\n"
2210 "\tlow_rssi %u\n"
2211 "\trssi_breach %u\n"
2212 "\tucast %u\n"
2213 "\tbcast %u\n"
2214 "\ticmpv4 %u\n"
2215 "\ticmpv6 %u\n"
2216 "\tipv4_mcast %u\n"
2217 "\tipv6_mcast %u\n"
2218 "\tipv6_mcast_ra %u\n"
2219 "\tipv6_mcast_ns %u\n"
2220 "\tipv6_mcast_na %u\n"
2221 "\toem_response %u\n"
2222 "conn_state %d\n"
2223 "dtimPeriod %d\n"
2224 "chanmode %d\n"
2225 "vht_capable %d\n"
2226 "ht_capable %d\n"
2227 "chan_width %d\n"
2228 "vdev_active %d\n"
2229 "vdev_up %d\n"
2230 "aid %d\n"
2231 "rate_flags %d\n"
2232 "nss %d\n"
2233 "tx_power %d\n"
2234 "max_tx_power %d\n"
2235 "nwType %d\n"
2236 "tx_streams %d\n"
2237 "rx_streams %d\n"
2238 "chain_mask %d\n"
2239 "nss_2g %d\n"
2240 "nss_5g %d",
2241 vdev_id,
2242 stats->pno_match,
2243 stats->pno_complete,
2244 stats->gscan,
2245 stats->low_rssi,
2246 stats->rssi_breach,
2247 stats->ucast,
2248 stats->bcast,
2249 stats->icmpv4,
2250 stats->icmpv6,
2251 stats->ipv4_mcast,
2252 stats->ipv6_mcast,
2253 stats->ipv6_mcast_ra,
2254 stats->ipv6_mcast_ns,
2255 stats->ipv6_mcast_na,
2256 stats->oem_response,
2257 iface->conn_state,
2258 iface->dtimPeriod,
2259 iface->chanmode,
2260 iface->vht_capable,
2261 iface->ht_capable,
2262 iface->chan_width,
2263 iface->vdev_active,
Mukul Sharmaf9047232017-03-02 16:58:56 +05302264 wma_is_vdev_up(vdev_id),
Dustin Brown9d797d62017-01-11 16:39:12 -08002265 iface->aid,
2266 iface->rate_flags,
2267 iface->nss,
2268 iface->tx_power,
2269 iface->max_tx_power,
2270 iface->nwType,
2271 iface->tx_streams,
2272 iface->rx_streams,
2273 iface->chain_mask,
2274 iface->nss_2g,
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302275 iface->nss_5g);
2276 }
2277
2278 *size -= len;
2279 *buf_ptr += len;
2280}
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002281#endif /* QCA_SUPPORT_CP_STATS */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302282
2283/**
2284 * wma_register_debug_callback() - registration function for wma layer
2285 * to print wma state information
2286 */
2287static void wma_register_debug_callback(void)
2288{
2289 qdf_register_debug_callback(QDF_MODULE_ID_WMA, &wma_state_info_dump);
2290}
Wen Gong3f003382018-05-14 14:26:37 +08002291#else /* WLAN_FEATURE_MEMDUMP_ENABLE */
Wen Gongaa6d55d2018-04-26 16:33:21 +08002292static void wma_register_debug_callback(void)
2293{
2294}
Wen Gong3f003382018-05-14 14:26:37 +08002295#endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
Frank Liu65b17d92016-11-23 15:58:44 +08002296/**
2297 * wma_register_tx_ops_handler() - register tx_ops of southbound
2298 * @tx_ops: tx_ops pointer in southbound
2299 *
2300 * Return: 0 on success, errno on failure
2301 */
2302static QDF_STATUS
2303wma_register_tx_ops_handler(struct wlan_lmac_if_tx_ops *tx_ops)
2304{
2305 /*
2306 * Assign tx_ops, it's up to UMAC modules to declare and define these
2307 * functions which are used to send wmi command to target.
2308 */
2309
Himanshu Agarwalce716f82016-12-21 19:07:54 +05302310 if (!tx_ops) {
2311 WMA_LOGE("%s: pointer to lmac if tx ops is NULL", __func__);
2312 return QDF_STATUS_E_INVAL;
2313 }
2314
2315 /* mgmt_txrx component's tx ops */
2316 tx_ops->mgmt_txrx_tx_ops.mgmt_tx_send = wma_mgmt_unified_cmd_send;
2317
Frank Liu65b17d92016-11-23 15:58:44 +08002318 return QDF_STATUS_SUCCESS;
2319}
2320
2321/**
2322 * wma_target_if_open() - Attach UMAC modules' interface with wmi layer
2323 * @wma_handle: wma handle
2324 *
2325 * Separate module defines below functions:
2326 * 1. tgt_wmi_<module>_<action> api sends wmi command, assigned to south bound
2327 * tx_ops function pointers;
2328 * 2. module's south dispatcher handles information from lower layer, assigned
2329 * to south bound rx_ops function pointers;
2330 * 3. wmi event handler deals with wmi event, extracts umac needed information,
2331 * and call rx_ops(module's dispatcher). It executes in tasklet context and
2332 * is up to dispatcher to decide the context to reside in tasklet or in
2333 * thread context.
2334 *
2335 * Return: None
2336 */
2337static void wma_target_if_open(tp_wma_handle wma_handle)
2338{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302339 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002340
2341 if (!psoc)
2342 return;
2343
Mukul Sharmadad267e2017-02-04 13:25:34 +05302344 wlan_global_lmac_if_set_txops_registration_cb(WLAN_DEV_OL,
2345 target_if_register_tx_ops);
2346 wlan_lmac_if_set_umac_txops_registration_cb(
2347 wma_register_tx_ops_handler);
2348 wlan_global_lmac_if_open(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002349
Frank Liu65b17d92016-11-23 15:58:44 +08002350}
2351
2352/**
2353 * wma_target_if_close() - Detach UMAC modules' interface with wmi layer
2354 * @wma_handle: wma handle
2355 *
2356 * Return: None
2357 */
2358static void wma_target_if_close(tp_wma_handle wma_handle)
2359{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302360 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002361
2362 if (!psoc)
2363 return;
2364
Mukul Sharmadad267e2017-02-04 13:25:34 +05302365 wlan_global_lmac_if_close(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002366}
Frank Liu65b17d92016-11-23 15:58:44 +08002367
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302368/**
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302369 * wma_get_psoc_from_scn_handle() - API to get psoc from scn handle
2370 * @scn_handle: opaque wma handle
2371 *
2372 * API to get psoc from scn handle
2373 *
2374 * Return: None
2375 */
2376static struct wlan_objmgr_psoc *wma_get_psoc_from_scn_handle(void *scn_handle)
2377{
2378 tp_wma_handle wma_handle;
2379
2380 if (!scn_handle) {
2381 WMA_LOGE("invalid scn handle");
2382 return NULL;
2383 }
2384 wma_handle = (tp_wma_handle)scn_handle;
2385
2386 return wma_handle->psoc;
2387}
Himanshu Agarwal2228e072018-01-24 17:42:17 +05302388
2389/**
2390 * wma_get_pdev_from_scn_handle() - API to get pdev from scn handle
2391 * @scn_handle: opaque wma handle
2392 *
2393 * API to get pdev from scn handle
2394 *
2395 * Return: None
2396 */
2397static struct wlan_objmgr_pdev *wma_get_pdev_from_scn_handle(void *scn_handle)
2398{
2399 tp_wma_handle wma_handle;
2400
2401 if (!scn_handle) {
2402 WMA_LOGE("invalid scn handle");
2403 return NULL;
2404 }
2405 wma_handle = (tp_wma_handle)scn_handle;
2406
2407 return wma_handle->pdev;
2408}
2409
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002410/**
2411 * wma_legacy_service_ready_event_handler() - legacy (ext)service ready handler
2412 * @event_id: event_id
2413 * @handle: wma handle
2414 * @event_data: event data
2415 * @length: event length
2416 *
2417 * Return: 0 for success, negative error code for failure
2418 */
2419static int wma_legacy_service_ready_event_handler(uint32_t event_id,
2420 void *handle,
2421 uint8_t *event_data,
2422 uint32_t length)
2423{
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302424 switch (event_id) {
2425 case wmi_service_ready_event_id:
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002426 return wma_rx_service_ready_event(handle, event_data, length);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302427 case wmi_service_ready_ext_event_id:
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002428 return wma_rx_service_ready_ext_event(handle, event_data,
2429 length);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302430 case wmi_ready_event_id:
2431 return wma_rx_ready_event(handle, event_data, length);
2432 default:
2433 WMA_LOGE("Legacy callback invoked with invalid event_id:%d",
2434 event_id);
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002435 QDF_BUG(0);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302436 }
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002437
2438 return 0;
2439}
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302440
2441/**
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002442 * wma_flush_complete_evt_handler() - FW log flush complete event handler
2443 * @handle: WMI handle
2444 * @event: Event recevied from FW
2445 * @len: Length of the event
2446 *
2447 */
2448static int wma_flush_complete_evt_handler(void *handle,
2449 u_int8_t *event,
2450 u_int32_t len)
2451{
2452 QDF_STATUS status;
2453 tp_wma_handle wma = (tp_wma_handle) handle;
2454
2455 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *param_buf;
2456 wmi_debug_mesg_flush_complete_fixed_param *wmi_event;
Poddar, Siddarthc2c08142017-09-13 17:49:56 +05302457 wmi_debug_mesg_fw_data_stall_param *data_stall_event;
2458 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2459 uint8_t *buf_ptr;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002460 uint32_t reason_code;
2461
2462 param_buf = (WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *) event;
2463 if (!param_buf) {
2464 WMA_LOGE("Invalid log flush complete event buffer");
2465 return QDF_STATUS_E_FAILURE;
2466 }
2467
2468 wmi_event = param_buf->fixed_param;
2469 reason_code = wmi_event->reserved0;
Rajeev Kumardcce8092018-05-02 15:48:17 -07002470 WMA_LOGD("Received reason code %d from FW", reason_code);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002471
Poddar, Siddarthc2c08142017-09-13 17:49:56 +05302472 buf_ptr = (uint8_t *)wmi_event;
2473 buf_ptr = buf_ptr + sizeof(wmi_debug_mesg_flush_complete_fixed_param) +
2474 WMI_TLV_HDR_SIZE;
2475 data_stall_event = (wmi_debug_mesg_fw_data_stall_param *) buf_ptr;
2476
2477 if (((data_stall_event->tlv_header & 0xFFFF0000) >> 16 ==
2478 WMITLV_TAG_STRUC_wmi_debug_mesg_fw_data_stall_param)) {
2479 /**
2480 * Log data stall info received from FW:
2481 *
2482 * Possible data stall recovery types:
2483 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_DISCONNECT
2484 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_MAC_PHY_RESET
2485 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_PDR
2486 *
2487 * Possible data stall event types:
2488 * WLAN_DBG_DATA_STALL_VDEV_PAUSE
2489 * WLAN_DBG_DATA_STALL_HWSCHED_CMD_FILTER
2490 * WLAN_DBG_DATA_STALL_HWSCHED_CMD_FLUSH
2491 * WLAN_DBG_DATA_STALL_RX_REFILL_FAILED
2492 * WLAN_DBG_DATA_STALL_RX_FCS_LEN_ERROR
2493 *
2494 * reason_code1:
2495 * The information stored in reason_code1 varies based on the
2496 * data stall type values:
2497 *
2498 * data_stall_type | reason_code1
2499 * -----------------------------------------------------
2500 * HWSCHED_CMD_FLUSH | flush req reason (0-40)
2501 * RX_REFILL_FAILED | ring_id (0-7)
2502 * RX_FCS_LEN_ERROR | exact error type
2503 *
2504 * reasone_code2:
2505 * on which tid/hwq stall happened
2506 *
2507 */
2508 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
2509 "Data Stall event:");
2510 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
2511 "data_stall_type: %x vdev_id_bitmap: %x reason_code1: %x reason_code2: %x recovery_type: %x ",
2512 data_stall_event->data_stall_type,
2513 data_stall_event->vdev_id_bitmap,
2514 data_stall_event->reason_code1,
2515 data_stall_event->reason_code2,
2516 data_stall_event->recovery_type);
2517
2518 cdp_post_data_stall_event(soc,
2519 DATA_STALL_LOG_INDICATOR_FIRMWARE,
2520 data_stall_event->data_stall_type,
2521 0XFF,
2522 data_stall_event->vdev_id_bitmap,
2523 data_stall_event->recovery_type);
2524 }
2525
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002526 /*
2527 * reason_code = 0; Flush event in response to flush command
2528 * reason_code = other value; Asynchronous flush event for fatal events
2529 */
2530 if (!reason_code && (cds_is_log_report_in_progress() == false)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002531 WMA_LOGD("Received WMI flush event without sending CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002532 return -EINVAL;
2533 } else if (!reason_code && cds_is_log_report_in_progress() == true) {
2534 /* Flush event in response to flush command */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002535 WMA_LOGD("Received WMI flush event in response to flush CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002536 status = qdf_mc_timer_stop(&wma->log_completion_timer);
2537 if (status != QDF_STATUS_SUCCESS)
2538 WMA_LOGE("Failed to stop the log completion timeout");
2539 cds_logging_set_fw_flush_complete();
Zhu Jianminb639e9b2017-10-26 19:09:12 +08002540 return QDF_STATUS_SUCCESS;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002541 } else if (reason_code && cds_is_log_report_in_progress() == false) {
2542 /* Asynchronous flush event for fatal events */
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002543 status = cds_set_log_completion(WLAN_LOG_TYPE_FATAL,
2544 WLAN_LOG_INDICATOR_FIRMWARE,
2545 reason_code, false);
2546 if (QDF_STATUS_SUCCESS != status) {
2547 WMA_LOGE("%s: Failed to set log trigger params",
2548 __func__);
2549 return QDF_STATUS_E_FAILURE;
2550 }
2551 cds_logging_set_fw_flush_complete();
2552 return status;
2553 } else {
2554 /* Asynchronous flush event for fatal event,
2555 * but, report in progress already
2556 */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002557 WMA_LOGD("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002558 __func__, WLAN_LOG_TYPE_FATAL,
2559 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2560 return QDF_STATUS_E_FAILURE;
2561 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07002562 /* Asynchronous flush event for fatal event,
2563 * but, report in progress already
2564 */
2565 WMA_LOGW("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
2566 __func__, WLAN_LOG_TYPE_FATAL,
2567 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2568 return QDF_STATUS_E_FAILURE;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002569}
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07002570
2571#ifdef WLAN_CONV_SPECTRAL_ENABLE
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002572/**
2573 * wma_extract_single_phyerr_spectral() - extract single phy error from event
2574 * @handle: wma handle
2575 * @param evt_buf: pointer to event buffer
2576 * @param datalen: data length of event buffer
2577 * @param buf_offset: Pointer to hold value of current event buffer offset
2578 * post extraction
2579 * @param phyerr: Pointer to hold phyerr
2580 *
2581 * Return: QDF_STATUS
2582 */
2583static QDF_STATUS wma_extract_single_phyerr_spectral(void *handle,
2584 void *evt_buf,
2585 uint16_t datalen, uint16_t *buf_offset,
2586 wmi_host_phyerr_t *phyerr)
2587{
2588 wmi_single_phyerr_rx_event *ev;
2589 int n = *buf_offset;
2590
2591 ev = (wmi_single_phyerr_rx_event *)((uint8_t *)evt_buf + n);
2592
2593 if (n < datalen) {
2594 /* ensure there's at least space for the header */
2595 if ((datalen - n) < sizeof(ev->hdr)) {
2596 WMA_LOGE("%s: not enough space? (datalen=%d, n=%d, hdr=%zu bytes",
2597 __func__, datalen, n, sizeof(ev->hdr));
2598 return QDF_STATUS_E_FAILURE;
2599 }
2600
2601 phyerr->bufp = ev->bufp;
2602 phyerr->buf_len = ev->hdr.buf_len;
2603
2604 /*
2605 * Sanity check the buffer length of the event against
2606 * what we currently have.
2607 *
2608 * Since buf_len is 32 bits, we check if it overflows
2609 * a large 32 bit value. It's not 0x7fffffff because
2610 * we increase n by (buf_len + sizeof(hdr)), which would
2611 * in itself cause n to overflow.
2612 *
2613 * If "int" is 64 bits then this becomes a moot point.
2614 */
2615 if (ev->hdr.buf_len > 0x7f000000) {
2616 WMA_LOGE("%s: buf_len is garbage? (0x%x)",
2617 __func__, ev->hdr.buf_len);
2618 return QDF_STATUS_E_FAILURE;
2619 }
2620 if (n + ev->hdr.buf_len > datalen) {
2621 WMA_LOGE("%s: buf_len exceeds available space n=%d, buf_len=%d, datalen=%d",
2622 __func__, n, ev->hdr.buf_len, datalen);
2623 return QDF_STATUS_E_FAILURE;
2624 }
2625
2626 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
2627 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
2628
2629#ifdef DEBUG_SPECTRAL_SCAN
2630 WMA_LOGD("%s: len=%d, tsf=0x%08x, rssi = 0x%x/0x%x/0x%x/0x%x, comb rssi = 0x%x, phycode=%d",
2631 __func__,
2632 ev->hdr.buf_len,
2633 ev->hdr.tsf_timestamp,
2634 ev->hdr.rssi_chain0,
2635 ev->hdr.rssi_chain1,
2636 ev->hdr.rssi_chain2,
2637 ev->hdr.rssi_chain3,
2638 WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr),
2639 phyerr->phy_err_code);
2640
2641 /*
2642 * For now, unroll this loop - the chain 'value' field isn't
2643 * a variable but glued together into a macro field definition.
2644 * Grr. :-)
2645 */
2646 WMA_LOGD("%s: chain 0: raw=0x%08x; pri20=%d sec20=%d sec40=%d sec80=%d",
2647 __func__,
2648 ev->hdr.rssi_chain0,
2649 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, PRI20),
2650 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC20),
2651 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC40),
2652 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC80));
2653
2654 WMA_LOGD("%s: chain 1: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2655 __func__,
2656 ev->hdr.rssi_chain1,
2657 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, PRI20),
2658 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC20),
2659 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC40),
2660 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC80));
2661
2662 WMA_LOGD("%s: chain 2: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2663 __func__,
2664 ev->hdr.rssi_chain2,
2665 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, PRI20),
2666 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC20),
2667 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC40),
2668 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC80));
2669
2670 WMA_LOGD("%s: chain 3: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2671 __func__,
2672 ev->hdr.rssi_chain3,
2673 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, PRI20),
2674 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC20),
2675 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC40),
2676 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC80));
2677
2678
2679 WMA_LOGD("%s: freq_info_1=0x%08x, freq_info_2=0x%08x",
2680 __func__, ev->hdr.freq_info_1, ev->hdr.freq_info_2);
2681
2682 /*
2683 * The NF chain values are signed and are negative - hence
2684 * the cast evilness.
2685 */
2686 WMA_LOGD("%s: nfval[1]=0x%08x, nfval[2]=0x%08x, nf=%d/%d/%d/%d, freq1=%d, freq2=%d, cw=%d",
2687 __func__,
2688 ev->hdr.nf_list_1,
2689 ev->hdr.nf_list_2,
2690 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 0),
2691 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 1),
2692 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 2),
2693 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 3),
2694 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 1),
2695 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 2),
2696 WMI_UNIFIED_CHWIDTH_GET(&ev->hdr));
2697#endif
2698
2699 /*
2700 * If required, pass spectral events to the spectral module
2701 */
2702 if (ev->hdr.buf_len > 0) {
2703
2704 /* Initialize the NF values to Zero. */
2705 phyerr->rf_info.noise_floor[0] =
2706 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 0);
2707 phyerr->rf_info.noise_floor[1] =
2708 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 1);
2709 phyerr->rf_info.noise_floor[2] =
2710 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 2);
2711 phyerr->rf_info.noise_floor[3] =
2712 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 3);
2713
2714 /* populate the rf info */
2715 phyerr->rf_info.rssi_comb =
2716 WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
2717
2718 /* Need to unroll loop due to macro
2719 * constraints chain 0
2720 */
2721 phyerr->rf_info.pc_rssi_info[0].rssi_pri20 =
2722 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, PRI20);
2723 phyerr->rf_info.pc_rssi_info[0].rssi_sec20 =
2724 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC20);
2725 phyerr->rf_info.pc_rssi_info[0].rssi_sec40 =
2726 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC40);
2727 phyerr->rf_info.pc_rssi_info[0].rssi_sec80 =
2728 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC80);
2729
2730 /* chain 1 */
2731 phyerr->rf_info.pc_rssi_info[1].rssi_pri20 =
2732 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, PRI20);
2733 phyerr->rf_info.pc_rssi_info[1].rssi_sec20 =
2734 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC20);
2735 phyerr->rf_info.pc_rssi_info[1].rssi_sec40 =
2736 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC40);
2737 phyerr->rf_info.pc_rssi_info[1].rssi_sec80 =
2738 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC80);
2739
2740 /* chain 2 */
2741 phyerr->rf_info.pc_rssi_info[2].rssi_pri20 =
2742 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, PRI20);
2743 phyerr->rf_info.pc_rssi_info[2].rssi_sec20 =
2744 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC20);
2745 phyerr->rf_info.pc_rssi_info[2].rssi_sec40 =
2746 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC40);
2747 phyerr->rf_info.pc_rssi_info[2].rssi_sec80 =
2748 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC80);
2749
2750 /* chain 3 */
2751 phyerr->rf_info.pc_rssi_info[3].rssi_pri20 =
2752 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, PRI20);
2753 phyerr->rf_info.pc_rssi_info[3].rssi_sec20 =
2754 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC20);
2755 phyerr->rf_info.pc_rssi_info[3].rssi_sec40 =
2756 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC40);
2757 phyerr->rf_info.pc_rssi_info[3].rssi_sec80 =
2758 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC80);
2759
2760 phyerr->chan_info.center_freq1 =
2761 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 1);
2762 phyerr->chan_info.center_freq2 =
2763 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 2);
2764
2765 }
2766
2767 /*
2768 * Advance the buffer pointer to the next PHY error.
2769 * buflen is the length of this payload, so we need to
2770 * advance past the current header _AND_ the payload.
2771 */
2772 n += sizeof(*ev) + ev->hdr.buf_len;
2773 }
2774 *buf_offset += n;
2775
2776 return QDF_STATUS_SUCCESS;
2777}
2778
2779/**
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002780 * spectral_phyerr_event_handler() - spectral phyerr event handler
2781 * @handle: wma handle
2782 * @data: data buffer
2783 * @datalen: buffer length
2784 *
2785 * Return: QDF_STATUS
2786 */
2787static QDF_STATUS spectral_phyerr_event_handler(void *handle,
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07002788 uint8_t *data,
2789 uint32_t datalen)
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002790{
2791 tp_wma_handle wma = (tp_wma_handle) handle;
2792 QDF_STATUS status = QDF_STATUS_SUCCESS;
2793 uint16_t buf_offset, event_buf_len = 0;
2794 wmi_single_phyerr_rx_event *ev;
2795 wmi_host_phyerr_t phyerr;
2796 struct target_if_spectral_rfqual_info rfqual_info;
2797 struct target_if_spectral_chan_info chan_info;
2798 struct target_if_spectral_acs_stats acs_stats;
2799
2800 if (NULL == wma) {
2801 WMA_LOGE("%s:wma handle is NULL", __func__);
2802 return QDF_STATUS_E_FAILURE;
2803 }
2804
2805 memset(&phyerr, 0, sizeof(wmi_host_phyerr_t));
Arif Hussaind54b62c2018-03-01 13:31:37 -08002806 status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
2807 &buf_offset, &phyerr);
2808 if (QDF_IS_STATUS_ERROR(status)) {
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002809 WMA_LOGE("%s: extract comb phyerr failed", __func__);
2810 return QDF_STATUS_E_FAILURE;
2811 }
2812
2813 ev = (wmi_single_phyerr_rx_event *)phyerr.bufp;
2814 event_buf_len = phyerr.buf_len;
2815 /* Loop over the bufp, extracting out phyerrors */
2816 buf_offset = 0;
2817 while (buf_offset < event_buf_len) {
2818 if (wma_extract_single_phyerr_spectral(handle, ev,
2819 event_buf_len, &buf_offset, &phyerr)) {
2820 WMA_LOGE("%s: extract single phy err failed", __func__);
2821 return QDF_STATUS_E_FAILURE;
2822 }
2823
2824 if (phyerr.buf_len > 0) {
2825 if (sizeof(phyerr.rf_info) > sizeof(rfqual_info))
2826 qdf_mem_copy(&rfqual_info, &phyerr.rf_info,
2827 sizeof(rfqual_info));
2828 else
2829 qdf_mem_copy(&rfqual_info, &phyerr.rf_info,
2830 sizeof(phyerr.rf_info));
2831
2832 if (sizeof(phyerr.chan_info) > sizeof(chan_info))
2833 qdf_mem_copy(&chan_info, &phyerr.chan_info,
2834 sizeof(chan_info));
2835 else
2836 qdf_mem_copy(&chan_info, &phyerr.chan_info,
2837 sizeof(phyerr.chan_info));
2838
2839 target_if_spectral_process_phyerr(wma->pdev, phyerr.bufp,
2840 phyerr.buf_len,
2841 &rfqual_info,
2842 &chan_info,
2843 phyerr.tsf64,
2844 &acs_stats);
2845 }
2846 }
2847
2848 return status;
2849}
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07002850#else
2851static QDF_STATUS spectral_phyerr_event_handler(void *handle,
2852 uint8_t *data, uint32_t datalen)
2853{
2854 return QDF_STATUS_SUCCESS;
2855}
2856#endif
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002857
Arif Hussainf63f7a32017-08-22 12:49:42 -07002858/**
Arif Hussaind54b62c2018-03-01 13:31:37 -08002859 * dfs_phyerr_event_handler() - dfs phyerr event handler
2860 * @handle: wma handle
2861 * @data: data buffer
2862 * @datalen: buffer length
2863 * @fulltsf: 64 bit event TSF
2864 *
2865 * Function to process DFS phy errors.
2866 *
2867 * Return: QDF_STATUS
2868 */
2869static QDF_STATUS dfs_phyerr_event_handler(tp_wma_handle handle,
2870 uint8_t *data,
2871 uint32_t datalen,
2872 uint64_t fulltsf)
2873{
2874 QDF_STATUS status = QDF_STATUS_SUCCESS;
2875 struct wlan_lmac_if_dfs_rx_ops *dfs_rx_ops;
2876 wmi_host_phyerr_t phyerr;
2877 int8_t rssi_comb;
2878 uint16_t buf_offset;
2879
2880 if (!handle->psoc) {
2881 WMA_LOGE("%s: psoc is null", __func__);
2882 return QDF_STATUS_E_INVAL;
2883 }
2884
2885 dfs_rx_ops = wlan_lmac_if_get_dfs_rx_ops(handle->psoc);
2886 if (!dfs_rx_ops) {
2887 WMA_LOGE("%s: dfs_rx_ops is null", __func__);
2888 return QDF_STATUS_E_INVAL;
2889 }
2890
2891 if (!dfs_rx_ops->dfs_process_phyerr) {
2892 WMA_LOGE("%s: dfs_process_phyerr handler is null", __func__);
2893 return QDF_STATUS_E_INVAL;
2894 }
2895
2896 if (!handle->pdev) {
2897 WMA_LOGE("%s: pdev is null", __func__);
2898 return -EINVAL;
2899 }
2900
2901 buf_offset = 0;
2902 while (buf_offset < datalen) {
2903 status = wmi_extract_single_phyerr(handle->wmi_handle, data, datalen,
2904 &buf_offset, &phyerr);
2905 if (QDF_IS_STATUS_ERROR(status)) {
2906 /* wmi_extract_single_phyerr has logs */
2907 return status;
2908 }
2909
2910 rssi_comb = phyerr.rf_info.rssi_comb & 0xFF;
2911 if (phyerr.buf_len > 0)
2912 dfs_rx_ops->dfs_process_phyerr(handle->pdev,
2913 &phyerr.bufp[0],
2914 phyerr.buf_len,
2915 rssi_comb,
2916 rssi_comb,
2917 phyerr.tsf_timestamp,
2918 fulltsf);
2919 }
2920
2921 return QDF_STATUS_SUCCESS;
2922}
2923
2924/**
Arif Hussainf63f7a32017-08-22 12:49:42 -07002925 * wma_unified_phyerr_rx_event_handler() - phyerr event handler
2926 * @handle: wma handle
2927 * @data: data buffer
2928 * @datalen: buffer length
2929 *
2930 * WMI Handler for WMI_PHYERR_EVENTID event from firmware.
2931 * This handler is currently handling DFS and spectral scan
2932 * phy errors.
2933 *
2934 * Return: 0 for success, other value for failure
2935 */
2936static int wma_unified_phyerr_rx_event_handler(void *handle,
Arif Hussaind54b62c2018-03-01 13:31:37 -08002937 uint8_t *data,
2938 uint32_t datalen)
2939{
Arif Hussainf63f7a32017-08-22 12:49:42 -07002940 /* phyerr handling is moved to cmn project
2941 * As WIN still uses handler registration in non-cmn code.
2942 * need complete testing of non offloaded DFS code before we enable
2943 * it in cmn code.
2944 **/
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002945 tp_wma_handle wma = (tp_wma_handle) handle;
2946 QDF_STATUS status = QDF_STATUS_SUCCESS;
2947 wmi_host_phyerr_t phyerr;
2948 uint16_t buf_offset = 0;
2949
Arif Hussaind54b62c2018-03-01 13:31:37 -08002950 if (!wma) {
2951 WMA_LOGE("%s: wma handle is null", __func__);
2952 return -EINVAL;
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002953 }
2954
2955 /* sanity check on data length */
Arif Hussaind54b62c2018-03-01 13:31:37 -08002956 status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
2957 &buf_offset, &phyerr);
2958 if (QDF_IS_STATUS_ERROR(status)) {
2959 WMA_LOGE("%s: extract phyerr failed: %d", __func__, status);
2960 return qdf_status_to_os_return(status);
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002961 }
2962
2963 /* handle different PHY Error conditions */
2964 if (((phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_RADAR |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002965 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT |
2966 WMI_PHY_ERROR_MASK0_SPECTRAL_SCAN)) == 0)) {
2967 WMA_LOGD("%s: Unknown phy error event", __func__);
2968 return -EINVAL;
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002969 }
2970
2971 /* Handle Spectral or DFS PHY Error */
2972 if (phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_RADAR |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002973 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT)) {
2974 if (wma->is_dfs_offloaded) {
2975 WMA_LOGD("%s: Unexpected phy error, dfs offloaded",
2976 __func__);
2977 return -EINVAL;
2978 }
2979 status = dfs_phyerr_event_handler(wma,
2980 phyerr.bufp,
2981 phyerr.buf_len,
2982 phyerr.tsf64);
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002983 } else if (phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_SPECTRAL_SCAN |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002984 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT)) {
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002985 status = spectral_phyerr_event_handler(wma, data, datalen);
2986 }
Arif Hussaind54b62c2018-03-01 13:31:37 -08002987
2988 return qdf_status_to_os_return(status);
Arif Hussainf63f7a32017-08-22 12:49:42 -07002989}
2990
Dustin Brownec2c92e2017-07-26 11:13:49 -07002991void wma_vdev_init(struct wma_txrx_node *vdev)
2992{
2993 qdf_wake_lock_create(&vdev->vdev_start_wakelock, "vdev_start");
2994 qdf_wake_lock_create(&vdev->vdev_stop_wakelock, "vdev_stop");
Rajeev Kumar155a3e42017-10-10 15:31:17 -07002995 qdf_wake_lock_create(&vdev->vdev_set_key_wakelock, "vdev_set_key");
Naveen Rawatd7734142017-10-27 10:02:40 -07002996 vdev->is_waiting_for_key = false;
Dustin Brownec2c92e2017-07-26 11:13:49 -07002997}
2998
2999void wma_vdev_deinit(struct wma_txrx_node *vdev)
3000{
3001 qdf_wake_lock_destroy(&vdev->vdev_start_wakelock);
3002 qdf_wake_lock_destroy(&vdev->vdev_stop_wakelock);
Rajeev Kumar155a3e42017-10-10 15:31:17 -07003003 qdf_wake_lock_destroy(&vdev->vdev_set_key_wakelock);
Naveen Rawatd7734142017-10-27 10:02:40 -07003004 vdev->is_waiting_for_key = false;
Dustin Brownec2c92e2017-07-26 11:13:49 -07003005}
3006
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08003007/**
3008 * wma_wmi_stop() - generic function to block WMI commands
3009 * @return: None
3010 */
3011void wma_wmi_stop(void)
3012{
3013 tp_wma_handle wma_handle;
3014
3015 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
3016 if (wma_handle == NULL) {
3017 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
3018 "wma_handle is NULL\n");
3019 return;
3020 }
3021 wmi_stop(wma_handle->wmi_handle);
3022}
3023
Naveen Rawate8b1b822018-01-30 09:46:16 -08003024#ifdef QCA_SUPPORT_CP_STATS
3025static void wma_register_stats_events(wmi_unified_t wmi_handle) {}
3026#else
3027static void wma_register_stats_events(wmi_unified_t wmi_handle)
3028{
3029 wmi_unified_register_event_handler(wmi_handle,
3030 wmi_update_stats_event_id,
3031 wma_stats_event_handler,
3032 WMA_RX_SERIALIZER_CTX);
3033}
3034#endif
3035
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08003036/**
3037 * wma_open() - Allocate wma context and initialize it.
3038 * @cds_context: cds context
3039 * @wma_tgt_cfg_cb: tgt config callback fun
3040 * @radar_ind_cb: dfs radar indication callback
3041 * @cds_cfg: mac parameters
3042 *
3043 * Return: 0 on success, errno on failure
3044 */
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003045QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 wma_tgt_cfg_cb tgt_cfg_cb,
bings482bae22018-01-17 16:25:31 +08003047 struct cds_config_info *cds_cfg,
3048 uint32_t target_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049{
3050 tp_wma_handle wma_handle;
3051 HTC_HANDLE htc_handle;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303052 qdf_device_t qdf_dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 void *wmi_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303054 QDF_STATUS qdf_status;
Lin Bai04f603e2018-03-19 11:01:06 +08003055 struct wmi_unified_attach_params *params;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003056 struct policy_mgr_wma_cbacks wma_cbacks;
Frank Liu00d73fe2017-05-19 22:11:28 +08003057 struct target_psoc_info *tgt_psoc_info;
Dustin Brownec2c92e2017-07-26 11:13:49 -07003058 int i;
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003059 void *cds_context;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303060 target_resource_config *wlan_res_cfg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061
3062 WMA_LOGD("%s: Enter", __func__);
3063
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003064 cds_context = cds_get_global_context();
3065 if (!cds_context) {
3066 WMA_LOGE("%s: Invalid CDS context", __func__);
3067 return QDF_STATUS_E_INVAL;
3068 }
3069
Mukul Sharma5ff3c582016-09-12 15:23:35 +05303070 g_wmi_version_info.major = __WMI_VER_MAJOR_;
3071 g_wmi_version_info.minor = __WMI_VER_MINOR_;
3072 g_wmi_version_info.revision = __WMI_REVISION_;
3073
Anurag Chouhan6d760662016-02-20 16:05:43 +05303074 qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
3075 htc_handle = cds_get_context(QDF_MODULE_ID_HTC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076
3077 if (!htc_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003078 WMA_LOGE("%s: Invalid HTC handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303079 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080 }
3081
3082 /* Alloc memory for WMA Context */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003083 qdf_status = cds_alloc_context(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084 (void **)&wma_handle,
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003085 sizeof(*wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303087 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003088 WMA_LOGE("%s: Memory allocation failed for wma_handle",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303090 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091 }
3092
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303093 qdf_mem_zero(wma_handle, sizeof(t_wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303095 if (target_if_alloc_psoc_tgt_info(psoc)) {
3096 WMA_LOGE("%s target psoc info allocation failed", __func__);
3097 qdf_status = QDF_STATUS_E_NOMEM;
3098 goto err_free_wma_handle;
Frank Liu00d73fe2017-05-19 22:11:28 +08003099 }
3100
Anurag Chouhan6d760662016-02-20 16:05:43 +05303101 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303103 qdf_wake_lock_create(&wma_handle->extscan_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 "wlan_extscan_wl");
3105#endif /* FEATURE_WLAN_EXTSCAN */
Mukul Sharmae44d0542017-05-23 21:50:56 +05303106 qdf_wake_lock_create(&wma_handle->wow_wake_lock,
3107 "wlan_wow_wl");
3108 qdf_wake_lock_create(&wma_handle->wow_auth_req_wl,
3109 "wlan_auth_req_wl");
3110 qdf_wake_lock_create(&wma_handle->wow_assoc_req_wl,
3111 "wlan_assoc_req_wl");
3112 qdf_wake_lock_create(&wma_handle->wow_deauth_rec_wl,
3113 "wlan_deauth_rec_wl");
3114 qdf_wake_lock_create(&wma_handle->wow_disassoc_rec_wl,
3115 "wlan_disassoc_rec_wl");
3116 qdf_wake_lock_create(&wma_handle->wow_ap_assoc_lost_wl,
3117 "wlan_ap_assoc_lost_wl");
3118 qdf_wake_lock_create(&wma_handle->wow_auto_shutdown_wl,
3119 "wlan_auto_shutdown_wl");
3120 qdf_wake_lock_create(&wma_handle->roam_ho_wl,
3121 "wlan_roam_ho_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 }
3123
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05303124 qdf_status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_LEGACY_WMA_ID);
3125 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3126 WMA_LOGE("%s: PSOC get_ref fails", __func__);
Zhu Jianminf9e2e2d2018-05-30 16:20:24 +08003127 goto err_get_psoc_ref;
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05303128 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303129 wma_handle->psoc = psoc;
3130
Rajeev Kumarda2444c2017-01-10 22:42:07 -08003131 /* Open target_if layer and register wma callback */
3132 wma_target_if_open(wma_handle);
3133 target_if_open(wma_get_psoc_from_scn_handle);
3134
Lin Bai04f603e2018-03-19 11:01:06 +08003135 /*
3136 * Allocate locally used params with its rx_ops member,
3137 * and free it immediately after used.
3138 */
3139 params = qdf_mem_malloc(sizeof(*params) + sizeof(struct wmi_rx_ops));
3140 if (!params) {
3141 WMA_LOGE("%s: failed to allocate attach params", __func__);
3142 qdf_status = QDF_STATUS_E_NOMEM;
3143 goto err_wma_handle;
3144 }
3145
3146 params->rx_ops = (struct wmi_rx_ops *)(params + 1);
3147 params->osdev = NULL;
3148 params->target_type = WMI_TLV_TARGET;
3149 params->use_cookie = false;
3150 params->psoc = psoc;
3151 params->max_commands = WMI_MAX_CMDS;
Govind Singhd76a5b02016-03-08 15:12:14 +05303152 /* Attach mc_thread context processing function */
Lin Bai04f603e2018-03-19 11:01:06 +08003153 params->rx_ops->wma_process_fw_event_handler_cbk =
3154 wma_process_fw_event_handler;
Surabhi Vishnoi75b1a812018-02-09 12:07:16 +05303155
Himanshu Agarwal88b16a42018-02-06 15:10:59 +05303156 /* initialize tlv attach */
3157 wmi_tlv_init();
Surabhi Vishnoi75b1a812018-02-09 12:07:16 +05303158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 /* attach the wmi */
Lin Bai04f603e2018-03-19 11:01:06 +08003160 wmi_handle = wmi_unified_attach(wma_handle, params);
3161 qdf_mem_free(params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 if (!wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003163 WMA_LOGE("%s: failed to attach WMI", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303164 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 goto err_wma_handle;
3166 }
3167
Rajeev Kumarda2444c2017-01-10 22:42:07 -08003168 target_if_register_legacy_service_ready_cb(
3169 wma_legacy_service_ready_event_handler);
3170
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171 WMA_LOGA("WMA --> wmi_unified_attach - success");
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05303172
Frank Liu00d73fe2017-05-19 22:11:28 +08003173 /* store the wmi handle in tgt_if_handle */
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303174 tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05303175
bings6b413662018-02-06 17:51:36 +08003176 target_psoc_set_target_type(tgt_psoc_info, target_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 /* Save the WMI & HTC handle */
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303178 target_psoc_set_wmi_hdl(tgt_psoc_info, wmi_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 wma_handle->wmi_handle = wmi_handle;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303180 target_psoc_set_htc_hdl(tgt_psoc_info, htc_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 wma_handle->cds_context = cds_context;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303182 wma_handle->qdf_dev = qdf_dev;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303183 wma_handle->max_scan = cds_cfg->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303185 /* Register Converged Event handlers */
3186 init_deinit_register_tgt_psoc_ev_handlers(psoc);
3187
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303188 /* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
Rachit Kankane0106e382018-05-16 18:59:28 +05303189 cds_cfg->max_station = wma_init_max_no_of_peers(wma_handle,
3190 cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 /* initialize default target config */
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303193 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_psoc_info);
Arif Hussaind15902c2018-03-02 00:08:29 -08003194 if (!wlan_res_cfg) {
3195 WMA_LOGE("%s: wlan_res_cfg is null", __func__);
3196 qdf_status = QDF_STATUS_E_NOMEM;
3197 goto err_wma_handle;
3198 }
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303199
Rachit Kankane0106e382018-05-16 18:59:28 +05303200 wma_set_default_tgt_config(wma_handle, wlan_res_cfg, cds_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303202 wma_handle->tx_chain_mask_cck = cds_cfg->tx_chain_mask_cck;
3203 wma_handle->self_gen_frm_pwr = cds_cfg->self_gen_frm_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303205 cds_cfg->max_bssid = WMA_MAX_SUPPORTED_BSS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303207 wma_handle->max_station = cds_cfg->max_station;
3208 wma_handle->max_bssid = cds_cfg->max_bssid;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303209 wma_handle->driver_type = cds_cfg->driver_type;
3210 wma_handle->ssdp = cds_cfg->ssdp;
3211 wma_handle->enable_mc_list = cds_cfg->enable_mc_list;
Nachiket Kukadee547a482018-05-22 16:43:30 +05303212 wma_handle->apf_packet_filter_enable =
3213 cds_cfg->apf_packet_filter_enable;
3214 wma_handle->active_uc_apf_mode = cds_cfg->active_uc_apf_mode;
3215 wma_handle->active_mc_bc_apf_mode = cds_cfg->active_mc_bc_apf_mode;
Srinivas Girigowda57b450e2016-10-27 21:00:46 -07003216 wma_handle->link_stats_results = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303218 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
3219 wma_handle->RArateLimitInterval = cds_cfg->ra_ratelimit_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220#endif /* FEATURE_WLAN_RA_FILTERING */
3221#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303222 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223#endif
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303224 wma_set_nan_enable(wma_handle, cds_cfg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303225 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 wma_handle->max_bssid);
3227 if (!wma_handle->interfaces) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003228 WMA_LOGE("%s: failed to allocate interface table", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303229 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 goto err_scn_context;
3231 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003232
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003233 for (i = 0; i < wma_handle->max_bssid; ++i) {
Dustin Brownec2c92e2017-07-26 11:13:49 -07003234 wma_vdev_init(&wma_handle->interfaces[i]);
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003235 wma_handle->interfaces[i].delay_before_vdev_stop =
3236 cds_cfg->delay_before_vdev_stop;
3237 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 /* Register the debug print event handler */
3239 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303240 wmi_debug_print_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303241 wma_unified_debug_print_event_handler,
3242 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05303243 /* Register profiling event Handler */
3244 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303245 wmi_wlan_profile_data_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303246 wma_profile_data_report_event_handler,
3247 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248
3249 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
3251 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05303252 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07003253 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254
Anurag Chouhan210db072016-02-22 18:42:15 +05303255 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303256 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303257 wma_service_ready_ext_evt_timeout,
3258 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303259 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303260 WMA_LOGE("Failed to initialize service ready ext timeout");
3261 goto err_event_init;
3262 }
3263
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303264 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303265 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003266 WMA_LOGE("%s: target suspend event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 __func__);
3268 goto err_event_init;
3269 }
3270
3271 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303272 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
3273 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003274 WMA_LOGE("%s: failed to init tx_frm_download_comp_event",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 __func__);
3276 goto err_event_init;
3277 }
3278
3279 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303280 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
3281 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003282 WMA_LOGE("%s: failed to init tx_queue_empty_event", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 goto err_event_init;
3284 }
3285
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303286 qdf_status = qdf_event_create(&wma_handle->wma_resume_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303287 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003288 WMA_LOGE("%s: wma_resume_event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 __func__);
3290 goto err_event_init;
3291 }
3292
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003293 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
3294 wma_handle);
3295 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003296 WMA_LOGE("%s: Shutdown notifier register failed: %d",
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003297 __func__, qdf_status);
3298 goto err_event_init;
3299 }
3300
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303301 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303302 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003303 WMA_LOGE("%s: runtime_suspend event initialization failed",
Houston Hoffmana76591b2015-11-10 16:52:05 -08003304 __func__);
3305 goto err_event_init;
3306 }
3307
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303308 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303309 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003310 WMA_LOGE("%s: recovery event initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311 goto err_event_init;
3312 }
3313
Anurag Chouhanffb21542016-02-17 14:33:03 +05303314 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003315 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303316 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303317 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303319 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05303320 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
3321 qdf_atomic_init(&wma_handle->scan_id_counter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322
3323 /* Register vdev start response event handler */
3324 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303325 wmi_vdev_start_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303326 wma_vdev_start_resp_handler,
3327 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328
3329 /* Register vdev stop response event handler */
3330 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303331 wmi_vdev_stopped_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303332 wma_vdev_stop_resp_handler,
3333 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334
3335 /* register for STA kickout function */
3336 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303337 wmi_peer_sta_kickout_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303338 wma_peer_sta_kickout_event_handler,
3339 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340
Naveen Rawate8b1b822018-01-30 09:46:16 -08003341 /* register for stats event */
3342 wma_register_stats_events(wma_handle->wmi_handle);
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303343
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303344 /* register for stats response event */
3345 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303346 wmi_get_arp_stats_req_id,
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303347 wma_get_arp_stats_handler,
3348 WMA_RX_SERIALIZER_CTX);
3349
Will Huanga9814592017-05-24 15:47:58 +08003350 /* register for peer info response event */
3351 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303352 wmi_peer_stats_info_event_id,
Will Huanga9814592017-05-24 15:47:58 +08003353 wma_peer_info_event_handler,
3354 WMA_RX_SERIALIZER_CTX);
3355
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303356#ifdef WLAN_POWER_DEBUGFS
3357 /* register for Chip Power stats event */
3358 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303359 wmi_pdev_chip_power_stats_event_id,
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303360 wma_unified_power_debug_stats_event_handler,
3361 WMA_RX_SERIALIZER_CTX);
3362#endif
3363
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364 /* register for linkspeed response event */
3365 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303366 wmi_peer_estimated_linkspeed_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303367 wma_link_speed_event_handler,
3368 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369
3370#ifdef FEATURE_OEM_DATA_SUPPORT
3371 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303372 wmi_oem_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303373 wma_oem_data_response_handler,
3374 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375#endif /* FEATURE_OEM_DATA_SUPPORT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376
3377 /* Register peer change event handler */
3378 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303379 wmi_peer_state_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303380 wma_peer_state_change_event_handler,
3381 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382
3383 /* Register beacon tx complete event id. The event is required
3384 * for sending channel switch announcement frames
3385 */
3386 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303387 wmi_offload_bcn_tx_status_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303388 wma_unified_bcntx_status_event_handler,
3389 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390
3391 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303392 wmi_update_vdev_rate_stats_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303393 wma_link_status_event_handler,
3394 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395#ifdef WLAN_FEATURE_LINK_LAYER_STATS
3396 /* Register event handler for processing Link Layer Stats
3397 * response from the FW
3398 */
3399 wma_register_ll_stats_event_handler(wma_handle);
3400
3401#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
3402
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +05303403 wmi_set_tgt_assert(wma_handle->wmi_handle,
3404 cds_cfg->force_target_assert_enabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303406 qdf_status = dbglog_init(wma_handle->wmi_handle);
3407 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003408 WMA_LOGE("%s: Firmware Dbglog initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 goto err_dbglog_init;
3410 }
3411
3412 /*
3413 * Update Powersave mode
3414 * 1 - Legacy Powersave + Deepsleep Disabled
3415 * 2 - QPower + Deepsleep Disabled
3416 * 3 - Legacy Powersave + Deepsleep Enabled
3417 * 4 - QPower + Deepsleep Enabled
3418 */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303419 wma_handle->powersave_mode = cds_cfg->powersave_offload_enabled;
3420 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
3421 wma_handle->staModDtim = cds_cfg->sta_mod_dtim;
3422 wma_handle->staDynamicDtim = cds_cfg->sta_dynamic_dtim;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423
3424 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303425 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 * 0 - Disable both magic pattern match and pattern byte match.
3427 * 1 - Enable magic pattern match on all interfaces.
3428 * 2 - Enable pattern byte match on all interfaces.
3429 * 3 - Enable both magic patter and pattern byte match on
3430 * all interfaces.
3431 */
3432 wma_handle->wow.magic_ptrn_enable =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303433 (cds_cfg->wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 wma_handle->ptrn_match_enable_all_vdev =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303435 (cds_cfg->wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437 /* register for install key completion event */
3438 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303439 wmi_vdev_install_key_complete_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303440 wma_vdev_install_key_complete_event_handler,
3441 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442#ifdef WLAN_FEATURE_NAN
3443 /* register for nan response event */
3444 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303445 wmi_nan_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303446 wma_nan_rsp_event_handler,
3447 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448#endif /* WLAN_FEATURE_NAN */
3449
3450#ifdef WLAN_FEATURE_STATS_EXT
3451 /* register for extended stats event */
3452 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303453 wmi_stats_ext_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303454 wma_stats_ext_event_handler,
3455 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456#endif /* WLAN_FEATURE_STATS_EXT */
3457#ifdef FEATURE_WLAN_EXTSCAN
3458 wma_register_extscan_event_handler(wma_handle);
3459#endif /* WLAN_FEATURE_STATS_EXT */
3460
3461 WMA_LOGD("%s: Exit", __func__);
3462
3463#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3464 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303465 wmi_roam_synch_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303466 wma_roam_synch_event_handler,
3467 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303468 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303469 wmi_roam_synch_frame_event_id,
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303470 wma_roam_synch_frame_event_handler,
3471 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3473 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303474 wmi_rssi_breach_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303475 wma_rssi_breached_event_handler,
3476 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303478 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05303479 "wlan_fw_rsp_wakelock");
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003480 qdf_runtime_lock_init(&wma_handle->wmi_cmd_rsp_runtime_lock);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 /* Register peer assoc conf event handler */
3483 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303484 wmi_peer_assoc_conf_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303485 wma_peer_assoc_conf_handler,
3486 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003487 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303488 wmi_vdev_delete_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303489 wma_vdev_delete_handler,
3490 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003491 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303492 wmi_peer_delete_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303493 wma_peer_delete_handler,
3494 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05303495 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Nachiket Kukadee547a482018-05-22 16:43:30 +05303496 wmi_apf_capability_info_event_id,
3497 wma_get_apf_caps_event_handler,
Arun Khandavalli2476ef52016-04-26 20:19:43 +05303498 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05303499 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303500 wmi_chan_info_event_id,
Kapil Gupta4f0c0c12017-02-07 15:21:15 +05303501 wma_chan_info_event_handler,
3502 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003503 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303504 wmi_dbg_mesg_flush_complete_event_id,
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003505 wma_flush_complete_evt_handler,
Rajeev Kumarc3032b82017-02-14 15:56:01 -08003506 WMA_RX_WORK_CTX);
lifeng66831662017-05-19 16:01:35 +08003507 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303508 wmi_report_rx_aggr_failure_event_id,
lifeng66831662017-05-19 16:01:35 +08003509 wma_rx_aggr_failure_event_handler,
3510 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003511
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303512 wma_handle->ito_repeat_count = cds_cfg->ito_repeat_count;
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07003513 wma_handle->bandcapability = cds_cfg->bandcapability;
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303514
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303515 /* Register PWR_SAVE_FAIL event only in case of recovery(1) */
Hanumanth Reddy Pothulaab395952017-09-05 19:12:26 +05303516 if (cds_cfg->auto_power_save_fail_mode ==
3517 PMO_FW_TO_SEND_WOW_IND_ON_PWR_FAILURE) {
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303518 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303519 wmi_pdev_chip_pwr_save_failure_detect_event_id,
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303520 wma_chip_power_save_failure_detected_handler,
3521 WMA_RX_WORK_CTX);
3522 }
3523
lifengd217d192017-05-09 19:44:16 +08003524 wmi_unified_register_event_handler(wma_handle->wmi_handle,
lifengfe6c3e22018-04-03 12:10:04 +08003525 wmi_pdev_div_rssi_antid_event_id,
3526 wma_pdev_div_info_evt_handler,
lifengd217d192017-05-09 19:44:16 +08003527 WMA_RX_WORK_CTX);
3528
Frank Liu65b17d92016-11-23 15:58:44 +08003529
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303530 wma_register_debug_callback();
Mukul Sharma6411bb82017-03-01 15:57:07 +05303531 /* Register callback with PMO so PMO can update the vdev pause bitmap*/
3532 pmo_register_pause_bitmap_notifier(wma_handle->psoc,
3533 wma_vdev_update_pause_bitmap);
3534 pmo_register_get_pause_bitmap(wma_handle->psoc,
3535 wma_vdev_get_pause_bitmap);
Will Huangad015772018-06-15 11:27:50 +08003536 pmo_register_get_vdev_dp_handle(wma_handle->psoc,
3537 wma_vdev_get_vdev_dp_handle);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303538 pmo_register_is_device_in_low_pwr_mode(wma_handle->psoc,
3539 wma_vdev_is_device_in_low_pwr_mode);
Mukul Sharma44746042018-05-24 17:30:52 +05303540 pmo_register_get_cfg_int_callback(wma_handle->psoc,
3541 wma_vdev_get_cfg_int);
Nachiket Kukade37b4e6d2018-06-01 18:44:42 +05303542 pmo_register_get_dtim_period_callback(wma_handle->psoc,
3543 wma_vdev_get_dtim_period);
3544 pmo_register_get_beacon_interval_callback(wma_handle->psoc,
3545 wma_vdev_get_beacon_interval);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003546 wma_cbacks.wma_get_connection_info = wma_get_connection_info;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003547 qdf_status = policy_mgr_register_wma_cb(wma_handle->psoc, &wma_cbacks);
3548 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
3549 WMA_LOGE("Failed to register wma cb with Policy Manager");
3550 }
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303551
Arif Hussainf63f7a32017-08-22 12:49:42 -07003552 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303553 wmi_phyerr_event_id,
Arif Hussainf63f7a32017-08-22 12:49:42 -07003554 wma_unified_phyerr_rx_event_handler,
3555 WMA_RX_WORK_CTX);
3556
Arif Hussainee10f902017-12-27 16:30:17 -08003557 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3558 wmi_sap_obss_detection_report_event_id,
3559 wma_vdev_obss_detection_info_handler,
3560 WMA_RX_SERIALIZER_CTX);
3561
Arif Hussain05fb4872018-01-03 16:02:55 -08003562 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3563 wmi_obss_color_collision_report_event_id,
3564 wma_vdev_bss_color_collision_info_handler,
3565 WMA_RX_WORK_CTX);
3566
Varun Reddy Yeturud33033f2018-06-11 10:58:30 -07003567#ifdef WLAN_SUPPORT_TWT
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -07003568 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3569 wmi_twt_enable_complete_event_id,
3570 wma_twt_en_complete_event_handler,
3571 WMA_RX_SERIALIZER_CTX);
3572#endif
3573
Arif Hussain05fb4872018-01-03 16:02:55 -08003574
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303575 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576
3577err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303578 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003579 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303580 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
3581 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582err_event_init:
3583 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303584 wmi_debug_print_event_id);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003585
3586 for (i = 0; i < wma_handle->max_bssid; ++i)
3587 wma_vdev_deinit(&wma_handle->interfaces[i]);
3588
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303589 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003590
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591err_scn_context:
Jeff Johnson2b6982c2018-05-29 14:56:11 -07003592 qdf_mem_free(((struct cds_context *) cds_context)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 OS_FREE(wmi_handle);
3594
3595err_wma_handle:
wadesong78cb3c22018-05-07 15:18:53 +08003596 target_if_close();
Zhu Jianminf9e2e2d2018-05-30 16:20:24 +08003597 wlan_objmgr_psoc_release_ref(psoc, WLAN_LEGACY_WMA_ID);
3598err_get_psoc_ref:
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303599 target_if_free_psoc_tgt_info(psoc);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303600 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303602 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303604 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05303605 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
3606 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
3607 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
3608 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
3609 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
3610 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
3611 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303613err_free_wma_handle:
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003614 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615
3616 WMA_LOGD("%s: Exit", __func__);
3617
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303618 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619}
3620
3621/**
3622 * wma_pre_start() - wma pre start
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 *
3624 * Return: 0 on success, errno on failure
3625 */
Jeff Johnson8ad89c62017-09-13 08:55:55 -07003626QDF_STATUS wma_pre_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303628 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 tp_wma_handle wma_handle;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08003630 struct scheduler_msg wma_msg = { 0 };
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303631 void *htc_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632
3633 WMA_LOGD("%s: Enter", __func__);
3634
Anurag Chouhan6d760662016-02-20 16:05:43 +05303635 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636
3637 /* Validate the wma_handle */
3638 if (NULL == wma_handle) {
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303639 WMA_LOGE("%s: invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303640 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 goto end;
3642 }
Nachiket Kukade8003d252017-03-30 15:55:58 +05303643
Sourav Mohapatracf632572018-04-02 11:01:35 +05303644 htc_handle = lmac_get_htc_hdl(wma_handle->psoc);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303645 if (!htc_handle) {
3646 WMA_LOGE("%s: invalid htc handle", __func__);
3647 qdf_status = QDF_STATUS_E_INVAL;
3648 goto end;
3649 }
3650
3651 /* Open endpoint for ctrl path - WMI <--> HTC */
3652 qdf_status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
3653 htc_handle);
3654 if (qdf_status != QDF_STATUS_SUCCESS) {
3655 WMA_LOGE("%s: wmi_unified_connect_htc_service", __func__);
Nachiket Kukade8003d252017-03-30 15:55:58 +05303656 if (!cds_is_fw_down())
3657 QDF_BUG(0);
3658
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303659 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 goto end;
3661 }
3662
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08003663 WMA_LOGD("WMA --> wmi_unified_connect_htc_service - success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664
3665 /* Trigger the CFG DOWNLOAD */
3666 wma_msg.type = WNI_CFG_DNLD_REQ;
3667 wma_msg.bodyptr = NULL;
3668 wma_msg.bodyval = 0;
3669
Rajeev Kumarb60abe42017-01-21 15:39:31 -08003670 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &wma_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303671 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003672 WMA_LOGE("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303673 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303674 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 }
3676end:
3677 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303678 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679}
3680
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303681void wma_send_msg_by_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3682 void *body_ptr, uint32_t body_val, bool is_high_priority)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683{
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303684 struct scheduler_msg msg = {0};
3685 QDF_STATUS status;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 msg.type = msg_type;
3688 msg.bodyval = body_val;
3689 msg.bodyptr = body_ptr;
Will Huang9323e852018-02-02 17:55:15 +08003690 msg.flush_callback = wma_discard_fw_event;
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303691
3692 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE,
3693 &msg, is_high_priority);
3694 if (!QDF_IS_STATUS_SUCCESS(status)) {
3695 WMA_LOGE("Failed to post msg %d to PE", msg_type);
3696 if (body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303697 qdf_mem_free(body_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699}
3700
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303701
3702void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
3703 void *body_ptr, uint32_t body_val)
3704{
3705 wma_send_msg_by_priority(wma_handle, msg_type,
3706 body_ptr, body_val, false);
3707}
3708
3709void wma_send_msg_high_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3710 void *body_ptr, uint32_t body_val)
3711{
3712 wma_send_msg_by_priority(wma_handle, msg_type,
3713 body_ptr, body_val, true);
3714}
3715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716/**
3717 * wma_set_base_macaddr_indicate() - set base mac address in fw
3718 * @wma_handle: wma handle
3719 * @customAddr: base mac address
3720 *
3721 * Return: 0 for success or error code
3722 */
3723static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
3724 tSirMacAddr *customAddr)
3725{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726 int err;
3727
Govind Singhf25a0f12016-03-08 16:09:48 +05303728 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
3729 (uint8_t *)customAddr);
3730 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
3733 MAC_ADDR_ARRAY((*customAddr)));
3734
3735 return 0;
3736}
3737
3738/**
3739 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
3740 * @handle: WMA handle
3741 * @event: Event received from FW
3742 * @len: Length of the event
3743 *
3744 * Enables the low frequency events and disables the high frequency
3745 * events. Bit 17 indicates if the event if low/high frequency.
3746 * 1 - high frequency, 0 - low frequency
3747 *
3748 * Return: 0 on successfully enabling/disabling the events
3749 */
3750static int wma_log_supported_evt_handler(void *handle,
3751 uint8_t *event,
3752 uint32_t len)
3753{
3754 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755
Govind Singhf25a0f12016-03-08 16:09:48 +05303756 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
3757 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759
3760 return 0;
3761}
3762
3763/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303764 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 * @handle: WMI handle
3766 * @event: Event recevied from FW
3767 * @len: Length of the event
3768 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303769 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
3770 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
3771 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772 *
Dustin Brownec2c92e2017-07-26 11:13:49 -07003773 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303775static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003776 uint8_t *event,
3777 uint32_t len)
3778{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303779 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
3780 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
3781 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 uint32_t i;
3783 struct sir_set_hw_mode_resp *hw_mode_resp;
3784 tp_wma_handle wma = (tp_wma_handle) handle;
3785
3786 if (!wma) {
3787 WMA_LOGE("%s: Invalid WMA handle", __func__);
3788 /* Since WMA handle itself is NULL, we cannot send fail
3789 * response back to LIM here
3790 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303791 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003793
3794 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -08003795 wma_remove_req(wma, 0, WMA_PDEV_SET_HW_MODE_RESP);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003796
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303797 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798 if (!hw_mode_resp) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003799 WMA_LOGE("%s: Memory allocation failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 /* Since this memory allocation itself failed, we cannot
3801 * send fail response back to LIM here
3802 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303803 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 }
3805
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303806 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303808 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 /* Need to send response back to upper layer to free
3810 * active command list
3811 */
3812 goto fail;
3813 }
Krunal Soni50a05542017-10-03 19:39:48 -07003814 if (param_buf->fixed_param->num_vdev_mac_entries >=
3815 MAX_VDEV_SUPPORTED) {
3816 WMA_LOGE("num_vdev_mac_entries crossed max value");
3817 goto fail;
3818 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819
3820 wmi_event = param_buf->fixed_param;
Abhinav Kumara03659c2017-12-28 15:18:07 +05303821 if (wmi_event->num_vdev_mac_entries >
3822 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
3823 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
3824 wmi_event->num_vdev_mac_entries);
3825 goto fail;
3826 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827 hw_mode_resp->status = wmi_event->status;
3828 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3829 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
3830
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003831 WMA_LOGD("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832 __func__, wmi_event->status,
3833 wmi_event->cfgd_hw_mode_index,
3834 wmi_event->num_vdev_mac_entries);
3835 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303836 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837
3838 /* Store the vdev-mac map in WMA and prepare to send to PE */
3839 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303840 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003842 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303843 pdev_id = vdev_mac_entry[i].pdev_id;
3844 if (pdev_id == WMI_PDEV_ID_SOC) {
3845 WMA_LOGE("%s: soc level id received for mac id)",
3846 __func__);
3847 QDF_BUG(0);
3848 goto fail;
3849 }
Pragaspathi Thilagaraj0092b672018-05-23 17:08:45 +05303850 if (vdev_id >= wma->max_bssid) {
3851 WMA_LOGE("%s: vdev_id: %d is invalid, max_bssid: %d",
3852 __func__, vdev_id, wma->max_bssid);
3853 goto fail;
3854 }
3855
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303856 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003857
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003858 WMA_LOGD("%s: vdev_id:%d mac_id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859 __func__, vdev_id, mac_id);
3860
3861 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
3862 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
3863 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3864 wmi_event->cfgd_hw_mode_index);
3865 }
3866
3867 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
3868 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
3869 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3870 } else {
3871 wma->old_hw_mode_index = wma->new_hw_mode_index;
3872 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3873 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003874 policy_mgr_update_hw_mode_index(wma->psoc,
3875 wmi_event->cfgd_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 }
3877
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003878 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3880
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303881 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882 (void *) hw_mode_resp, 0);
3883
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303884 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885
3886fail:
3887 WMA_LOGE("%s: Sending fail response to LIM", __func__);
3888 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
3889 hw_mode_resp->cfgd_hw_mode_index = 0;
3890 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303891 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 (void *) hw_mode_resp, 0);
3893
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303894 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895}
3896
3897/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003898 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
3899 *
3900 * @handle: WMA handle
3901 * @fixed_param: Event fixed parameters
3902 * @vdev_mac_entry - vdev mac entry
3903 * @hw_mode_trans_ind - Buffer to store parsed information
3904 *
3905 * Parses fixed_param, vdev_mac_entry and fills in the information into
3906 * hw_mode_trans_ind and wma
3907 *
3908 * Return: None
3909 */
3910void wma_process_pdev_hw_mode_trans_ind(void *handle,
3911 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
3912 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
3913 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
3914{
3915 uint32_t i;
3916 tp_wma_handle wma = (tp_wma_handle) handle;
gaurank kathpaliad2967a72018-05-01 12:35:14 +05303917 if (fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
3918 WMA_LOGE("Number of Vdev mac entries %d exceeded"
3919 " max vdev supported %d",
3920 fixed_param->num_vdev_mac_entries,
3921 MAX_VDEV_SUPPORTED);
3922 return;
3923 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003924 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
3925 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
3926 hw_mode_trans_ind->num_vdev_mac_entries =
3927 fixed_param->num_vdev_mac_entries;
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003928 WMA_LOGD("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003929 __func__, fixed_param->old_hw_mode_index,
3930 fixed_param->new_hw_mode_index,
3931 fixed_param->num_vdev_mac_entries);
3932
3933 /* Store the vdev-mac map in WMA and send to policy manager */
3934 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
3935 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003936
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003937 vdev_id = vdev_mac_entry[i].vdev_id;
3938 pdev_id = vdev_mac_entry[i].pdev_id;
3939
3940 if (pdev_id == WMI_PDEV_ID_SOC) {
3941 WMA_LOGE("%s: soc level id received for mac id)",
3942 __func__);
3943 QDF_BUG(0);
3944 return;
3945 }
Pragaspathi Thilagaraj0092b672018-05-23 17:08:45 +05303946 if (vdev_id >= wma->max_bssid) {
3947 WMA_LOGE("%s: vdev_id: %d is invalid, max_bssid: %d",
3948 __func__, vdev_id, wma->max_bssid);
3949 return;
3950 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003951
3952 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
3953
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003954 WMA_LOGE("%s: vdev_id:%d mac_id:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003955 __func__, vdev_id, mac_id);
3956
3957 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
3958 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
3959 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3960 fixed_param->new_hw_mode_index);
3961 }
3962 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
3963 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003964 policy_mgr_update_new_hw_mode_index(wma->psoc,
3965 fixed_param->new_hw_mode_index);
3966 policy_mgr_update_old_hw_mode_index(wma->psoc,
3967 fixed_param->old_hw_mode_index);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003968
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003969 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003970 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3971}
3972
3973/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303974 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 * @handle: WMI handle
3976 * @event: Event recevied from FW
3977 * @len: Length of the event
3978 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303979 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980 * asynchronous hardware mode transition. This event notifies the host driver
3981 * that firmware independently changed the hardware mode for some reason, such
3982 * as Coex, LFR 3.0, etc
3983 *
3984 * Return: Success on receiving valid params from FW
3985 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303986static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 uint8_t *event,
3988 uint32_t len)
3989{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303990 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
3991 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
3992 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
3994 tp_wma_handle wma = (tp_wma_handle) handle;
3995
3996 if (!wma) {
3997 /* This is an async event. So, not sending any event to LIM */
3998 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303999 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000 }
4001
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304002 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 if (!param_buf) {
4004 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304005 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304006 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 }
4008
Arif Hussain34f72062017-10-04 17:25:24 -07004009 if (param_buf->fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
4010 WMA_LOGE("num_vdev_mac_entries: %d crossed max value: %d",
4011 param_buf->fixed_param->num_vdev_mac_entries,
4012 MAX_VDEV_SUPPORTED);
4013 return QDF_STATUS_E_FAILURE;
4014 }
4015
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304016 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 if (!hw_mode_trans_ind) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004018 WMA_LOGE("%s: Memory allocation failed", __func__);
4019 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020 }
4021
4022 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304024 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Abhinav Kumara03659c2017-12-28 15:18:07 +05304025 if (wmi_event->num_vdev_mac_entries >
4026 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
4027 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
4028 wmi_event->num_vdev_mac_entries);
4029 qdf_mem_free(hw_mode_trans_ind);
4030 return -EINVAL;
4031 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004032 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
4033 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304035 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 (void *) hw_mode_trans_ind, 0);
4037
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304038 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039}
4040
4041/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304042 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 * @handle: WMI handle
4044 * @event: Event received from FW
4045 * @len: Length of the event
4046 *
4047 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304048 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 * the host driver once the firmware has completed a reconfiguration of the Scan
4050 * and FW mode configuration. This changes could include entering or leaving a
4051 * dual mac configuration for either scan and/or more permanent firmware mode.
4052 *
4053 * Return: Success on receiving valid params from FW
4054 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304055static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 uint8_t *event,
4057 uint32_t len)
4058{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304059 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
4060 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 tp_wma_handle wma = (tp_wma_handle) handle;
4062 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
4063
4064 if (!wma) {
4065 WMA_LOGE("%s: Invalid WMA handle", __func__);
4066 /* Since the WMA handle is NULL, we cannot send resp to LIM.
4067 * So, returning from here.
4068 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304069 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 }
Krunal Sonia5ccb802017-07-03 12:59:40 -07004071 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304072 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 if (!dual_mac_cfg_resp) {
4074 WMA_LOGE("%s: Memory allocation failed", __func__);
4075 /* Since the mem alloc failed, we cannot send resp to LIM.
4076 * So, returning from here.
4077 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304078 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 }
4080
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304081 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 event;
4083 if (!param_buf) {
4084 WMA_LOGE("%s: Invalid event", __func__);
4085 goto fail;
4086 }
4087
4088 wmi_event = param_buf->fixed_param;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004089 WMA_LOGD("%s: status:%d", __func__, wmi_event->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 dual_mac_cfg_resp->status = wmi_event->status;
4091
4092 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004093 policy_mgr_update_dbs_scan_config(wma->psoc);
4094 policy_mgr_update_dbs_fw_config(wma->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095 }
4096
4097 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304098 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 (void *) dual_mac_cfg_resp, 0);
4100
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304101 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102
4103fail:
4104 WMA_LOGE("%s: Sending fail response to LIM", __func__);
4105 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304106 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 (void *) dual_mac_cfg_resp, 0);
4108
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304109 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110
4111}
4112
4113/**
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304114 * wma_send_time_stamp_sync_cmd() - timer callback send timestamp to
4115 * firmware to sync with host.
4116 * @wma_handle: wma handle
4117 *
4118 * Return: void
4119 */
4120static void wma_send_time_stamp_sync_cmd(void *data)
4121{
4122 tp_wma_handle wma_handle;
4123 QDF_STATUS qdf_status;
4124
4125 wma_handle = (tp_wma_handle) data;
4126
4127 wmi_send_time_stamp_sync_cmd_tlv(wma_handle->wmi_handle);
4128
4129 /* Start/Restart the timer */
4130 qdf_status = qdf_mc_timer_start(&wma_handle->wma_fw_time_sync_timer,
4131 WMA_FW_TIME_SYNC_TIMER);
4132 if (QDF_IS_STATUS_ERROR(qdf_status))
4133 WMA_LOGE("Failed to start the firmware time sync timer");
4134}
4135
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07004136#ifdef WLAN_CONV_SPECTRAL_ENABLE
4137static void wma_register_spectral_cmds(tp_wma_handle wma_handle)
4138{
4139 struct wmi_spectral_cmd_ops cmd_ops;
4140
4141 cmd_ops.wmi_spectral_configure_cmd_send =
4142 wmi_unified_vdev_spectral_configure_cmd_send;
4143 cmd_ops.wmi_spectral_enable_cmd_send =
4144 wmi_unified_vdev_spectral_enable_cmd_send;
4145 wlan_register_wmi_spectral_cmd_ops(wma_handle->pdev, &cmd_ops);
4146}
4147#else
4148static void wma_register_spectral_cmds(tp_wma_handle wma_handle)
4149{
4150}
4151#endif
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304152/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 * wma_start() - wma start function.
Jeff Johnsonc97816c2018-05-12 17:13:23 -07004154 * Initialize event handlers and timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304156 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 */
Jeff Johnsond4892552017-09-13 08:41:31 -07004158QDF_STATUS wma_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304160 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 tp_wma_handle wma_handle;
4162 int status;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304163 struct wmi_unified *wmi_handle;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07004164
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 WMA_LOGD("%s: Enter", __func__);
4166
Anurag Chouhan6d760662016-02-20 16:05:43 +05304167 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 /* validate the wma_handle */
4169 if (NULL == wma_handle) {
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304170 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304171 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 goto end;
4173 }
Sandeep Puligillad698bf52017-09-15 16:07:02 -07004174
Sourav Mohapatracf632572018-04-02 11:01:35 +05304175 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304176 if (!wmi_handle) {
4177 WMA_LOGE("%s: Invalid wmi handle", __func__);
4178 qdf_status = QDF_STATUS_E_INVAL;
4179 goto end;
4180 }
4181
4182 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304183 wmi_roam_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304184 wma_roam_event_callback,
Padma, Santhosh Kumar18169ce2017-03-02 18:04:02 +05304185 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004187 WMA_LOGE("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304188 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 goto end;
4190 }
4191
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304192 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304193 wmi_wow_wakeup_host_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304194 wma_wow_wakeup_host_event,
4195 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004197 WMA_LOGE("%s: Failed to register wow wakeup host event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304199 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 goto end;
4201 }
4202
Will Huang3cd2b7c2017-11-17 13:16:56 +08004203 if (wma_d0_wow_is_supported()) {
4204 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304205 wmi_handle,
Will Huang9adefff2017-12-15 14:50:03 +08004206 wmi_d0_wow_disable_ack_event_id,
Will Huang3cd2b7c2017-11-17 13:16:56 +08004207 wma_d0_wow_disable_ack_event,
4208 WMA_RX_TASKLET_CTX);
4209 if (status) {
4210 WMA_LOGE("%s: Failed to register d0wow disable ack"
4211 " event handler", __func__);
4212 qdf_status = QDF_STATUS_E_FAILURE;
4213 goto end;
4214 }
4215 }
4216
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304217 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304218 wmi_pdev_resume_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304219 wma_pdev_resume_event_handler,
4220 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004222 WMA_LOGE("%s: Failed to register PDEV resume event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304224 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 goto end;
4226 }
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05304227#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
4228 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004229 WMA_LOGD("MCC TX Pause Event Handler register");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304230 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304231 wmi_tx_pause_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304232 wma_mcc_vdev_tx_pause_evt_handler,
4233 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
4235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
4237 WMA_LOGD("Registering auto shutdown handler");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304238 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304239 wmi_host_auto_shutdown_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304240 wma_auto_shutdown_event_handler,
4241 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004242 if (status) {
4243 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304244 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 goto end;
4246 }
4247#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304248 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304249 wmi_thermal_mgmt_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304250 wma_thermal_mgmt_evt_handler,
4251 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252 if (status) {
4253 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304254 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 goto end;
4256 }
4257
Zhang Qian47e22ce2018-01-04 15:38:38 +08004258 status = wma_ocb_register_callbacks(wma_handle);
4259 if (!QDF_IS_STATUS_SUCCESS(status)) {
4260 WMA_LOGE("Failed to register OCB callbacks");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304261 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262 goto end;
4263 }
4264
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304265 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266
4267#ifdef QCA_WIFI_FTM
4268 /*
4269 * Tx mgmt attach requires TXRX context which is not created
4270 * in FTM mode. So skip the TX mgmt attach.
4271 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304272 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 goto end;
4274#endif /* QCA_WIFI_FTM */
4275
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304276 if (wmi_service_enabled(wmi_handle, wmi_service_rmc)) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004277
4278 WMA_LOGD("FW supports cesium network, registering event handlers");
4279
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004280 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304281 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304282 wmi_peer_info_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004283 wma_ibss_peer_info_event_handler,
4284 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004285 if (status) {
4286 WMA_LOGE("Failed to register ibss peer info event cb");
4287 qdf_status = QDF_STATUS_E_FAILURE;
4288 goto end;
4289 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004290 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304291 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304292 wmi_peer_tx_fail_cnt_thr_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004293 wma_fast_tx_fail_event_handler,
4294 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004295 if (status) {
4296 WMA_LOGE("Failed to register peer fast tx failure event cb");
4297 qdf_status = QDF_STATUS_E_FAILURE;
4298 goto end;
4299 }
4300 } else {
4301 WMA_LOGE("Target does not support cesium network");
4302 }
4303
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304304 qdf_status = wma_tx_attach(wma_handle);
4305 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004306 WMA_LOGE("%s: Failed to register tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 goto end;
4308 }
4309
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304310 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4311 /* Initialize firmware time stamp sync timer */
4312 qdf_status =
4313 qdf_mc_timer_init(&wma_handle->wma_fw_time_sync_timer,
4314 QDF_TIMER_TYPE_SW,
4315 wma_send_time_stamp_sync_cmd,
4316 wma_handle);
4317 if (QDF_IS_STATUS_ERROR(qdf_status))
4318 WMA_LOGE(FL("Failed to initialize firmware time stamp sync timer"));
4319 /* Start firmware time stamp sync timer */
4320 wma_send_time_stamp_sync_cmd(wma_handle);
4321 }
4322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05304324 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304325 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004326 wma_log_completion_timeout,
4327 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304328 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 WMA_LOGE("Failed to initialize log completion timeout");
4330 goto end;
4331 }
4332
Jeff Johnson6136fb92017-03-30 15:21:49 -07004333 status = wma_fips_register_event_handlers(wma_handle);
4334 if (!QDF_IS_STATUS_SUCCESS(status)) {
4335 WMA_LOGE("Failed to register FIPS event handler");
4336 qdf_status = QDF_STATUS_E_FAILURE;
4337 goto end;
4338 }
4339
Jeff Johnsonf0e54b02017-12-18 15:22:25 -08004340 status = wma_sar_register_event_handlers(wma_handle);
4341 if (!QDF_IS_STATUS_SUCCESS(status)) {
4342 WMA_LOGE("Failed to register SAR event handlers");
4343 qdf_status = QDF_STATUS_E_FAILURE;
4344 goto end;
4345 }
4346
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347 /* Initialize the get temperature event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304348 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304349 wmi_pdev_temperature_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304350 wma_pdev_temperature_evt_handler,
4351 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304352 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304354 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004355 goto end;
4356 }
4357
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304358 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304359 wmi_vdev_tsf_report_event_id,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004360 wma_vdev_tsf_handler,
4361 WMA_RX_SERIALIZER_CTX);
4362 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004363 WMA_LOGE("%s: Failed to register tsf callback", __func__);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004364 qdf_status = QDF_STATUS_E_FAILURE;
4365 goto end;
4366 }
4367
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304368 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304369 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304370 wmi_pdev_set_hw_mode_rsp_event_id,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304371 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304372 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304373 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304375 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 goto end;
4377 }
4378
4379 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304380 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304381 wmi_pdev_hw_mode_transition_event_id,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304382 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304383 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304384 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304386 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 goto end;
4388 }
4389
4390 /* Initialize the set dual mac configuration event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304391 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304392 wmi_pdev_set_mac_config_resp_event_id,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304393 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304394 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304395 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304397 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 goto end;
4399 }
4400
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304401 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304402 wmi_coex_bt_activity_event_id,
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304403 wma_wlan_bt_activity_evt_handler,
4404 WMA_RX_SERIALIZER_CTX);
4405 if (!QDF_IS_STATUS_SUCCESS(status)) {
4406 WMA_LOGE("Failed to register coex bt activity event handler");
4407 qdf_status = QDF_STATUS_E_FAILURE;
4408 goto end;
4409 }
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07004410 wma_register_spectral_cmds(wma_handle);
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412end:
4413 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304414 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415}
4416
4417/**
4418 * wma_stop() - wma stop function.
4419 * cleanup timers and suspend target.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 * @reason: reason for wma_stop.
4421 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304422 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 */
Jeff Johnsonacc1cc72017-09-13 08:47:49 -07004424QDF_STATUS wma_stop(uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425{
4426 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304427 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05304428 int i;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004429
Anurag Chouhan6d760662016-02-20 16:05:43 +05304430 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 WMA_LOGD("%s: Enter", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 /* validate the wma_handle */
4433 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004434 WMA_LOGE("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304435 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 goto end;
4437 }
4438#ifdef QCA_WIFI_FTM
4439 /*
4440 * Tx mgmt detach requires TXRX context which is not created
4441 * in FTM mode. So skip the TX mgmt detach.
4442 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304443 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304444 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 goto end;
4446 }
4447#endif /* QCA_WIFI_FTM */
4448
4449 if (wma_handle->ack_work_ctx) {
4450 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304451 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 wma_handle->ack_work_ctx = NULL;
4453 }
4454
4455 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05304456 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004457 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 WMA_LOGE("Failed to destroy the log completion timer");
Govind Singhede435f2015-12-01 16:16:36 +05304459 /* clean up ll-queue for all vdev */
4460 for (i = 0; i < wma_handle->max_bssid; i++) {
4461 if (wma_handle->interfaces[i].handle &&
Mukul Sharmaf9047232017-03-02 16:58:56 +05304462 wma_is_vdev_up(i)) {
Leo Chang96464902016-10-28 11:10:54 -07004463 cdp_fc_vdev_flush(
4464 cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08004465 wma_handle->
4466 interfaces[i].handle);
Govind Singhede435f2015-12-01 16:16:36 +05304467 }
4468 }
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304469
4470 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4471 /* Destroy firmware time stamp sync timer */
4472 qdf_status = qdf_mc_timer_destroy(
4473 &wma_handle->wma_fw_time_sync_timer);
4474 if (QDF_IS_STATUS_ERROR(qdf_status))
4475 WMA_LOGE(FL("Failed to destroy the fw time sync timer"));
4476 }
4477
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304478 qdf_status = wma_tx_detach(wma_handle);
4479 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004480 WMA_LOGE("%s: Failed to deregister tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 goto end;
4482 }
4483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004484end:
4485 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304486 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487}
4488
4489/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 * wma_wmi_service_close() - close wma wmi service interface.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304492 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 */
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004494QDF_STATUS wma_wmi_service_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495{
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004496 void *cds_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 tp_wma_handle wma_handle;
4498 struct beacon_info *bcn;
4499 int i;
4500
4501 WMA_LOGD("%s: Enter", __func__);
4502
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004503 cds_ctx = cds_get_global_context();
4504 if (!cds_ctx) {
4505 WMA_LOGE("%s: Invalid CDS context", __func__);
4506 return QDF_STATUS_E_INVAL;
4507 }
4508
Anurag Chouhan6d760662016-02-20 16:05:43 +05304509 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510
4511 /* validate the wma_handle */
4512 if (NULL == wma_handle) {
4513 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304514 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 }
4516
4517 /* validate the wmi handle */
4518 if (NULL == wma_handle->wmi_handle) {
4519 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304520 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521 }
4522
4523 /* dettach the wmi serice */
4524 WMA_LOGD("calling wmi_unified_detach");
4525 wmi_unified_detach(wma_handle->wmi_handle);
4526 wma_handle->wmi_handle = NULL;
4527
4528 for (i = 0; i < wma_handle->max_bssid; i++) {
4529 bcn = wma_handle->interfaces[i].beacon;
4530
4531 if (bcn) {
4532 if (bcn->dma_mapped)
Nirav Shahcbc6d722016-03-01 16:24:53 +05304533 qdf_nbuf_unmap_single(wma_handle->qdf_dev,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304534 bcn->buf, QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +05304535 qdf_nbuf_free(bcn->buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304536 qdf_mem_free(bcn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 wma_handle->interfaces[i].beacon = NULL;
4538 }
4539
4540 if (wma_handle->interfaces[i].handle) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304541 qdf_mem_free(wma_handle->interfaces[i].handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542 wma_handle->interfaces[i].handle = NULL;
4543 }
Yue Ma664effc2016-01-12 18:43:54 -08004544
4545 if (wma_handle->interfaces[i].addBssStaContext) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304546 qdf_mem_free(wma_handle->
Yue Ma664effc2016-01-12 18:43:54 -08004547 interfaces[i].addBssStaContext);
4548 wma_handle->interfaces[i].addBssStaContext = NULL;
4549 }
4550
4551 if (wma_handle->interfaces[i].del_staself_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304552 qdf_mem_free(wma_handle->interfaces[i].del_staself_req);
Yue Ma664effc2016-01-12 18:43:54 -08004553 wma_handle->interfaces[i].del_staself_req = NULL;
4554 }
yeshwanth sriram guntuka8dd80382017-01-30 17:04:58 +05304555
4556 if (wma_handle->interfaces[i].stats_rsp) {
4557 qdf_mem_free(wma_handle->interfaces[i].stats_rsp);
4558 wma_handle->interfaces[i].stats_rsp = NULL;
4559 }
Abhishek Singh7e5e9342017-04-12 18:22:07 +05304560
4561 if (wma_handle->interfaces[i].psnr_req) {
4562 qdf_mem_free(wma_handle->
4563 interfaces[i].psnr_req);
4564 wma_handle->interfaces[i].psnr_req = NULL;
4565 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07004566
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05304567 if (wma_handle->interfaces[i].rcpi_req) {
4568 qdf_mem_free(wma_handle->
4569 interfaces[i].rcpi_req);
4570 wma_handle->interfaces[i].rcpi_req = NULL;
4571 }
4572
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05304573 if (wma_handle->interfaces[i].roam_synch_frame_ind.
4574 bcn_probe_rsp) {
4575 qdf_mem_free(wma_handle->interfaces[i].
4576 roam_synch_frame_ind.bcn_probe_rsp);
4577 wma_handle->interfaces[i].roam_synch_frame_ind.
4578 bcn_probe_rsp = NULL;
4579 }
4580
4581 if (wma_handle->interfaces[i].roam_synch_frame_ind.
4582 reassoc_req) {
4583 qdf_mem_free(wma_handle->interfaces[i].
4584 roam_synch_frame_ind.reassoc_req);
4585 wma_handle->interfaces[i].roam_synch_frame_ind.
4586 reassoc_req = NULL;
4587 }
4588
4589 if (wma_handle->interfaces[i].roam_synch_frame_ind.
4590 reassoc_rsp) {
4591 qdf_mem_free(wma_handle->interfaces[i].
4592 roam_synch_frame_ind.reassoc_rsp);
4593 wma_handle->interfaces[i].roam_synch_frame_ind.
4594 reassoc_rsp = NULL;
4595 }
4596
Dustin Brownec2c92e2017-07-26 11:13:49 -07004597 wma_vdev_deinit(&wma_handle->interfaces[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 }
4599
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304600 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07004601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 /* free the wma_handle */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07004603 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604
Jeff Johnson2b6982c2018-05-29 14:56:11 -07004605 qdf_mem_free(((struct cds_context *) cds_ctx)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304607 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608}
4609
Xun Luoa858a472015-11-10 08:24:45 -08004610/**
4611 * wma_wmi_work_close() - close the work queue items associated with WMI
Xun Luoa858a472015-11-10 08:24:45 -08004612 *
4613 * This function closes work queue items associated with WMI, but not fully
4614 * closes WMI service.
4615 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304616 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08004617 * proper error codes.
4618 */
Jeff Johnson6b8473d2017-09-13 09:20:53 -07004619QDF_STATUS wma_wmi_work_close(void)
Xun Luoa858a472015-11-10 08:24:45 -08004620{
4621 tp_wma_handle wma_handle;
4622
4623 WMA_LOGD("%s: Enter", __func__);
4624
Anurag Chouhan6d760662016-02-20 16:05:43 +05304625 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08004626
4627 /* validate the wma_handle */
4628 if (NULL == wma_handle) {
4629 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304630 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004631 }
4632
4633 /* validate the wmi handle */
4634 if (NULL == wma_handle->wmi_handle) {
4635 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304636 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004637 }
4638
4639 /* remove the wmi work */
4640 WMA_LOGD("calling wmi_unified_remove_work");
4641 wmi_unified_remove_work(wma_handle->wmi_handle);
4642
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304643 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08004644}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645
Krunal Soni2e48d012016-05-02 16:55:26 -07004646/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 * wma_close() - wma close function.
4648 * cleanup resources attached with wma.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304650 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 */
Jeff Johnson542da352017-09-13 09:17:28 -07004652QDF_STATUS wma_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653{
4654 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304655 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656
4657 WMA_LOGD("%s: Enter", __func__);
4658
Anurag Chouhan6d760662016-02-20 16:05:43 +05304659 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660
4661 /* validate the wma_handle */
4662 if (NULL == wma_handle) {
4663 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304664 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 }
4666
4667 /* validate the wmi handle */
4668 if (NULL == wma_handle->wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004669 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304670 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 }
4672
4673 /* Free DBS list */
4674 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304675 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004677 WMA_LOGD("%s: DBS list is freed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05304679
Anurag Chouhan6d760662016-02-20 16:05:43 +05304680 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304682 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004683#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304684 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05304685 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
4686 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
4687 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
4688 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
4689 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
4690 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
4691 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004692 }
4693
4694 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304695 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
4696 if (qdf_status != QDF_STATUS_SUCCESS)
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004697 WMA_LOGE("%s: dbglog_deinit failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698
Anurag Chouhan210db072016-02-22 18:42:15 +05304699 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304700 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004701 WMA_LOGE("%s: Failed to destroy service ready ext event timer",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304702 __func__);
4703
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304704 qdf_event_destroy(&wma_handle->target_suspend);
4705 qdf_event_destroy(&wma_handle->wma_resume_event);
4706 qdf_event_destroy(&wma_handle->runtime_suspend);
4707 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08004708 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
4709 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08004710 wma_cleanup_vdev_resp_queue(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304712 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08004713 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Poddar, Siddarth2fb98072017-07-19 14:58:30 +05304714 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
4715 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304718 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 wma_handle->pGetRssiReq = NULL;
4720 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07004721
yeshwanth sriram guntuka584c2332017-07-29 12:50:25 +05304722 wma_unified_radio_tx_mem_free(wma_handle);
Srinivas Girigowdaad874a82016-10-25 14:08:00 -07004723
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -07004724 if (wma_handle->pdev) {
4725 wlan_objmgr_pdev_release_ref(wma_handle->pdev,
4726 WLAN_LEGACY_WMA_ID);
4727 wma_handle->pdev = NULL;
4728 }
Frank Liu00d73fe2017-05-19 22:11:28 +08004729
Nachiket Kukade37b4e6d2018-06-01 18:44:42 +05304730 pmo_unregister_get_beacon_interval_callback(wma_handle->psoc);
4731 pmo_unregister_get_dtim_period_callback(wma_handle->psoc);
Mukul Sharma44746042018-05-24 17:30:52 +05304732 pmo_unregister_get_cfg_int_callback(wma_handle->psoc);
4733 pmo_unregister_is_device_in_low_pwr_mode(wma_handle->psoc);
4734 pmo_unregister_get_pause_bitmap(wma_handle->psoc);
4735 pmo_unregister_pause_bitmap_notifier(wma_handle->psoc);
Will Huangad015772018-06-15 11:27:50 +08004736 pmo_unregister_get_vdev_dp_handle(wma_handle->psoc);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304737
Arunk Khandavallia6305a32018-01-25 11:19:18 +05304738 target_if_free_psoc_tgt_info(wma_handle->psoc);
4739
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05304740 wlan_objmgr_psoc_release_ref(wma_handle->psoc, WLAN_LEGACY_WMA_ID);
4741 wma_handle->psoc = NULL;
4742 target_if_close();
4743 wma_target_if_close(wma_handle);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304746 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747}
4748
4749/**
4750 * wma_update_fw_config() - update fw configuration
Dustin Brownb9987af2018-03-01 17:15:11 -08004751 * @psoc: psoc to query configuration from
4752 * @tgt_hdl: target capability info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 *
4754 * Return: none
4755 */
Dustin Brownb9987af2018-03-01 17:15:11 -08004756static void wma_update_fw_config(struct wlan_objmgr_psoc *psoc,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304757 struct target_psoc_info *tgt_hdl)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758{
Dustin Brownb9987af2018-03-01 17:15:11 -08004759 target_resource_config *cfg = &tgt_hdl->info.wlan_res_cfg;
4760
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761 /* Override the no. of max fragments as per platform configuration */
Dustin Brownb9987af2018-03-01 17:15:11 -08004762 cfg->max_frag_entries = QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304763 target_if_get_max_frag_entry(tgt_hdl));
Dustin Brownb9987af2018-03-01 17:15:11 -08004764 target_if_set_max_frag_entry(tgt_hdl, cfg->max_frag_entries);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304765
Dustin Brownb9987af2018-03-01 17:15:11 -08004766 cfg->num_wow_filters = ucfg_pmo_get_num_wow_filters(psoc);
Nachiket Kukadee547a482018-05-22 16:43:30 +05304767 cfg->apf_instruction_size = ucfg_pmo_get_apf_instruction_size(psoc);
Dustin Brown67d69eb2018-03-02 11:11:34 -08004768 cfg->num_packet_filters = ucfg_pmo_get_num_packet_filters(psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004769}
4770
4771/**
Yun Parkb4f591d2017-03-29 15:51:01 -07004772 * wma_set_tx_partition_base() - set TX MSDU ID partition base for IPA
4773 * @value: TX MSDU ID partition base
4774 *
4775 * Return: none
4776 */
4777#ifdef IPA_OFFLOAD
4778static void wma_set_tx_partition_base(uint32_t value)
4779{
4780 cdp_ipa_set_uc_tx_partition_base(
4781 cds_get_context(QDF_MODULE_ID_SOC),
4782 (struct cdp_cfg *)cds_get_context(QDF_MODULE_ID_CFG),
4783 value);
4784 WMA_LOGD("%s: TX_MSDU_ID_PARTITION=%d", __func__,
4785 value);
4786}
4787#else
4788static void wma_set_tx_partition_base(uint32_t value)
4789{
4790}
4791#endif
4792
4793/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 * wma_update_target_services() - update target services from wma handle
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304795 * @wmi_handle: Unified wmi handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004796 * @cfg: target services
4797 *
4798 * Return: none
4799 */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304800static inline void wma_update_target_services(struct wmi_unified *wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004801 struct wma_tgt_services *cfg)
4802{
4803 /* STA power save */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304804 cfg->sta_power_save = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304805 wmi_service_sta_pwrsave);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806
4807 /* Enable UAPSD */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304808 cfg->uapsd = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304809 wmi_service_ap_uapsd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810
4811 /* Update AP DFS service */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304812 cfg->ap_dfs = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304813 wmi_service_ap_dfs);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814
4815 /* Enable 11AC */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304816 cfg->en_11ac = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304817 wmi_service_11ac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004818 if (cfg->en_11ac)
4819 g_fw_wlan_feat_caps |= (1 << DOT11AC);
4820
4821 /* Proactive ARP response */
4822 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
4823
4824 /* Enable WOW */
4825 g_fw_wlan_feat_caps |= (1 << WOW);
4826
4827 /* ARP offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304828 cfg->arp_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304829 wmi_service_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830
4831 /* Adaptive early-rx */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304832 cfg->early_rx = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304833 wmi_service_early_rx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004834#ifdef FEATURE_WLAN_SCAN_PNO
4835 /* PNO offload */
Rajeev Kumar617aadd2018-05-31 16:36:13 -07004836 if (wmi_service_enabled(wmi_handle, wmi_service_nlo)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837 cfg->pno_offload = true;
Rajeev Kumar617aadd2018-05-31 16:36:13 -07004838 g_fw_wlan_feat_caps |= (1 << PNO);
4839 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840#endif /* FEATURE_WLAN_SCAN_PNO */
4841
4842#ifdef FEATURE_WLAN_EXTSCAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304843 if (wmi_service_enabled(wmi_handle, wmi_service_extscan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004844 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845#endif /* FEATURE_WLAN_EXTSCAN */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304846 cfg->lte_coex_ant_share = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304847 wmi_service_lte_ant_share_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004848#ifdef FEATURE_WLAN_TDLS
4849 /* Enable TDLS */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304850 if (wmi_service_enabled(wmi_handle, wmi_service_tdls)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 cfg->en_tdls = 1;
4852 g_fw_wlan_feat_caps |= (1 << TDLS);
4853 }
4854 /* Enable advanced TDLS features */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304855 if (wmi_service_enabled(wmi_handle, wmi_service_tdls_offchan)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856 cfg->en_tdls_offchan = 1;
4857 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
4858 }
4859
4860 cfg->en_tdls_uapsd_buf_sta =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304861 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304862 wmi_service_tdls_uapsd_buffer_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 cfg->en_tdls_uapsd_sleep_sta =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304864 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304865 wmi_service_tdls_uapsd_sleep_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866#endif /* FEATURE_WLAN_TDLS */
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304867 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304868 (wmi_handle, wmi_service_beacon_offload))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869 cfg->beacon_offload = true;
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304870 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304871 (wmi_handle, wmi_service_sta_pmf_offload))
mukul sharma72c8b222015-09-04 17:02:01 +05304872 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4874 /* Enable Roam Offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304875 cfg->en_roam_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304876 wmi_service_roam_ho_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4878#ifdef WLAN_FEATURE_NAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304879 if (wmi_service_enabled(wmi_handle, wmi_service_nan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 g_fw_wlan_feat_caps |= (1 << NAN);
4881#endif /* WLAN_FEATURE_NAN */
4882
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304883 if (wmi_service_enabled(wmi_handle, wmi_service_rtt))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07004885
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304886 if (wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304887 wmi_service_tx_msdu_id_new_partition_support)) {
Yun Parkb4f591d2017-03-29 15:51:01 -07004888 wma_set_tx_partition_base(HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004889 } else {
Yun Parkb4f591d2017-03-29 15:51:01 -07004890 wma_set_tx_partition_base(HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004891 }
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004892
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304893 wma_he_update_tgt_services(wmi_handle, cfg);
Will Huang496b36c2017-07-11 16:38:50 +08004894
4895 cfg->get_peer_info_enabled =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304896 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304897 wmi_service_peer_stats_info);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304898 if (wmi_service_enabled(wmi_handle, wmi_service_fils_support))
Vignesh Viswanathan731186f2017-09-18 13:47:37 +05304899 cfg->is_fils_roaming_supported = true;
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004900
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304901 if (wmi_service_enabled(wmi_handle, wmi_service_mawc_support))
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004902 cfg->is_fw_mawc_capable = true;
4903
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304904 if (wmi_service_enabled(wmi_handle,
4905 wmi_service_11k_neighbour_report_support))
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304906 cfg->is_11k_offload_supported = true;
Varun Reddy Yeturu4b54ec82018-05-30 16:00:38 -07004907
4908 if (wmi_service_enabled(wmi_handle, wmi_service_twt_requestor))
4909 cfg->twt_requestor = true;
4910 if (wmi_service_enabled(wmi_handle, wmi_service_twt_responder))
4911 cfg->twt_responder = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912}
4913
4914/**
4915 * wma_update_target_ht_cap() - update ht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304916 * @tgt_hdl: pointer to structure target_psoc_info
4917 * @cfg: ht capability
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 *
4919 * Return: none
4920 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304921static inline void
4922wma_update_target_ht_cap(struct target_psoc_info *tgt_hdl,
4923 struct wma_tgt_ht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304925 int ht_cap_info;
4926
4927 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004928 /* RX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304929 cfg->ht_rx_stbc = !!(ht_cap_info & WMI_HT_CAP_RX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004930
4931 /* TX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304932 cfg->ht_tx_stbc = !!(ht_cap_info & WMI_HT_CAP_TX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933
4934 /* MPDU density */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304935 cfg->mpdu_density = ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936
4937 /* HT RX LDPC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304938 cfg->ht_rx_ldpc = !!(ht_cap_info & WMI_HT_CAP_LDPC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939
4940 /* HT SGI */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304941 cfg->ht_sgi_20 = !!(ht_cap_info & WMI_HT_CAP_HT20_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304943 cfg->ht_sgi_40 = !!(ht_cap_info & WMI_HT_CAP_HT40_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944
4945 /* RF chains */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304946 cfg->num_rf_chains = target_if_get_num_rf_chains(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947
Jeff Johnson3fd21822016-11-08 11:30:37 -08004948 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n"
4949 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304950 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
4951 ht_cap_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
4953 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
4954 cfg->num_rf_chains);
4955
4956}
4957
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958/**
4959 * wma_update_target_vht_cap() - update vht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304960 * @tgt_hdl: pointer to structure target_psoc_info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 * @cfg: vht capabality
4962 *
4963 * Return: none
4964 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304965static inline void
4966wma_update_target_vht_cap(struct target_psoc_info *tgt_hdl,
4967 struct wma_tgt_vht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304969 int vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304971 if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004972 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304973 else if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4975 else
4976 cfg->vht_max_mpdu = 0;
4977
4978
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304979 if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4981 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304982 } else if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004983 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304984 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304986 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304988 cfg->vht_rx_ldpc = vht_cap_info & WMI_VHT_CAP_RX_LDPC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304990 cfg->vht_short_gi_80 = vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
4991 cfg->vht_short_gi_160 = vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004992
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304993 cfg->vht_tx_stbc = vht_cap_info & WMI_VHT_CAP_TX_STBC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304995 cfg->vht_rx_stbc =
4996 (vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
4997 (vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
4998 (vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004999
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305000 cfg->vht_max_ampdu_len_exp = (vht_cap_info &
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
5002 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
5003
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305004 cfg->vht_su_bformer = vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305006 cfg->vht_su_bformee = vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305008 cfg->vht_mu_bformer = vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005009
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305010 cfg->vht_mu_bformee = vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305012 cfg->vht_txop_ps = vht_cap_info & WMI_VHT_CAP_TXOP_PS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013
Jeff Johnson3fd21822016-11-08 11:30:37 -08005014 WMA_LOGD("%s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
5015 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
5016 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
5018 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
5019 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
5020 cfg->vht_max_ampdu_len_exp);
5021}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022
5023/**
Krunal Sonica50b452017-08-04 22:24:59 -07005024 * wma_update_supported_bands() - update supported bands from service ready ext
Krunal Sonica50b452017-08-04 22:24:59 -07005025 * @supported_bands: Supported band given by FW through service ready ext params
5026 * @new_supported_bands: New supported band which needs to be updated by
5027 * this API which WMA layer understands
5028 *
5029 * This API will convert FW given supported band to enum which WMA layer
5030 * understands
5031 *
5032 * Return: QDF_STATUS
5033 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305034static QDF_STATUS wma_update_supported_bands(
Krunal Sonica50b452017-08-04 22:24:59 -07005035 WLAN_BAND_CAPABILITY supported_bands,
5036 WMI_PHY_CAPABILITY *new_supported_bands)
5037{
5038 QDF_STATUS status = QDF_STATUS_SUCCESS;
5039
Krunal Sonica50b452017-08-04 22:24:59 -07005040 if (!new_supported_bands) {
5041 WMA_LOGE("%s: NULL new supported band variable", __func__);
5042 return QDF_STATUS_E_FAILURE;
5043 }
5044 switch (supported_bands) {
5045 case WLAN_2G_CAPABILITY:
5046 *new_supported_bands |= WMI_11G_CAPABILITY;
5047 break;
5048 case WLAN_5G_CAPABILITY:
5049 *new_supported_bands |= WMI_11A_CAPABILITY;
5050 break;
5051 default:
5052 WMA_LOGE("%s: wrong supported band", __func__);
5053 status = QDF_STATUS_E_FAILURE;
5054 break;
5055 }
5056 return status;
5057}
5058
5059/**
Krunal Soniaa664da2016-06-15 23:46:40 -07005060 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005061 * @ht_cap: given pointer to HT caps which needs to be updated
5062 * @tx_chain: given tx chainmask value
5063 * @rx_chain: given rx chainmask value
5064 * @value: new HT cap info provided in form of bitmask
5065 *
5066 * This function takes the value provided in form of bitmask and decodes
5067 * it. After decoding, what ever value it gets, it takes the union(max) or
5068 * intersection(min) with previously derived values.
5069 *
5070 * Return: none
5071 *
5072 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305073static void wma_derive_ext_ht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005074 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
5075 uint32_t tx_chain, uint32_t rx_chain)
5076{
5077 struct wma_tgt_ht_cap tmp = {0};
5078
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305079 if (ht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005080 return;
5081
Ankit Guptaa5076012016-09-14 11:32:19 -07005082 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07005083 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
5084 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
5085 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
5086 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
5087 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
5088 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
5089 ht_cap->num_rf_chains =
5090 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
5091 wma_get_num_of_setbits_from_bitmask(rx_chain));
5092 } else {
5093 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
5094 (!!(value & WMI_HT_CAP_RX_STBC)));
5095 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
5096 (!!(value & WMI_HT_CAP_TX_STBC)));
5097 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
5098 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
5099 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
5100 (!!(value & WMI_HT_CAP_RX_LDPC)));
5101 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
5102 (!!(value & WMI_HT_CAP_HT20_SGI)));
5103 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
5104 (!!(value & WMI_HT_CAP_HT40_SGI)));
5105 ht_cap->num_rf_chains =
5106 QDF_MAX(ht_cap->num_rf_chains,
5107 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
5108 tx_chain),
5109 wma_get_num_of_setbits_from_bitmask(
5110 rx_chain)));
5111 }
5112}
5113
5114/**
5115 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305116 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005117 * @ht_cap: HT cap structure to be filled
5118 *
5119 * This function loop through each hardware mode and for each hardware mode
5120 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5121 * HT caps and derives the final cap.
5122 *
5123 * Return: none
5124 *
5125 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305126static void wma_update_target_ext_ht_cap(struct target_psoc_info *tgt_hdl,
5127 struct wma_tgt_ht_cap *ht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005128{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005129 int i, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005130 uint32_t ht_2g, ht_5g;
5131 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305132 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5133 int num_hw_modes;
Krunal Soniaa664da2016-06-15 23:46:40 -07005134
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005135 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305136 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5137 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005138 /*
5139 * for legacy device extended cap might not even come, so in that case
5140 * don't overwrite legacy values
5141 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305142 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005143 WMA_LOGD("%s: No extended HT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005144 return;
5145 }
5146
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005147 for (i = 0; i < total_mac_phy_cnt; i++) {
5148 ht_2g = mac_phy_cap[i].ht_cap_info_2G;
5149 ht_5g = mac_phy_cap[i].ht_cap_info_5G;
5150 if (ht_2g)
5151 wma_derive_ext_ht_cap(&tmp_ht_cap,
5152 ht_2g,
5153 mac_phy_cap[i].tx_chain_mask_2G,
5154 mac_phy_cap[i].rx_chain_mask_2G);
5155 if (ht_5g)
5156 wma_derive_ext_ht_cap(&tmp_ht_cap,
5157 ht_5g,
5158 mac_phy_cap[i].tx_chain_mask_5G,
5159 mac_phy_cap[i].rx_chain_mask_5G);
Krunal Soniaa664da2016-06-15 23:46:40 -07005160 }
5161
Ankit Guptaa5076012016-09-14 11:32:19 -07005162 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005163 sizeof(struct wma_tgt_ht_cap))) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005164 qdf_mem_copy(ht_cap, &tmp_ht_cap,
5165 sizeof(struct wma_tgt_ht_cap));
Krunal Soniaa664da2016-06-15 23:46:40 -07005166 }
5167
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005168 WMA_LOGD("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005169 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
5170 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005171 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
5172 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
5173 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
5174 ht_cap->num_rf_chains);
5175}
5176
5177/**
5178 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005179 * @vht_cap: pointer to given VHT caps to be filled
5180 * @value: new VHT cap info provided in form of bitmask
5181 *
5182 * This function takes the value provided in form of bitmask and decodes
5183 * it. After decoding, what ever value it gets, it takes the union(max) or
5184 * intersection(min) with previously derived values.
5185 *
5186 * Return: none
5187 *
5188 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305189static void wma_derive_ext_vht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005190 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
5191{
5192 struct wma_tgt_vht_cap tmp_cap = {0};
5193 uint32_t tmp = 0;
5194
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305195 if (vht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005196 return;
5197
Ankit Guptaa5076012016-09-14 11:32:19 -07005198 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005199 sizeof(struct wma_tgt_vht_cap))) {
5200 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5201 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5202 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5203 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5204 else
5205 vht_cap->vht_max_mpdu = 0;
5206
5207 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
5208 vht_cap->supp_chan_width =
5209 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
5210 vht_cap->supp_chan_width |=
5211 1 << eHT_CHANNEL_WIDTH_160MHZ;
5212 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5213 vht_cap->supp_chan_width =
5214 1 << eHT_CHANNEL_WIDTH_160MHZ;
5215 } else {
5216 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5217 }
5218 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
5219 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
5220 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
5221 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
5222 vht_cap->vht_rx_stbc =
5223 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5224 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5225 (value & WMI_VHT_CAP_RX_STBC_3SS);
5226 vht_cap->vht_max_ampdu_len_exp =
5227 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5228 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
5229 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
5230 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
5231 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
5232 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
5233 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
5234 } else {
5235 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5236 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5237 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5238 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5239 else
5240 tmp = 0;
5241 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
5242
5243 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
5244 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
5245 (1 << eHT_CHANNEL_WIDTH_160MHZ);
5246 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5247 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
5248 } else {
5249 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5250 }
5251 vht_cap->supp_chan_width =
5252 QDF_MAX(vht_cap->supp_chan_width, tmp);
5253 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
5254 value & WMI_VHT_CAP_RX_LDPC);
5255 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
5256 value & WMI_VHT_CAP_SGI_80MHZ);
5257 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
5258 value & WMI_VHT_CAP_SGI_160MHZ);
5259 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
5260 value & WMI_VHT_CAP_TX_STBC);
5261 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
5262 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5263 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5264 (value & WMI_VHT_CAP_RX_STBC_3SS));
5265 vht_cap->vht_max_ampdu_len_exp =
5266 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
5267 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5268 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
5269 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
5270 value & WMI_VHT_CAP_SU_BFORMER);
5271 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
5272 value & WMI_VHT_CAP_SU_BFORMEE);
5273 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
5274 value & WMI_VHT_CAP_MU_BFORMER);
5275 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
5276 value & WMI_VHT_CAP_MU_BFORMEE);
5277 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
5278 value & WMI_VHT_CAP_TXOP_PS);
5279 }
5280}
5281
5282/**
5283 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305284 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005285 * @vht_cap: VHT cap structure to be filled
5286 *
5287 * This function loop through each hardware mode and for each hardware mode
5288 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5289 * VHT caps and derives the final cap.
5290 *
5291 * Return: none
5292 *
5293 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305294static void wma_update_target_ext_vht_cap(struct target_psoc_info *tgt_hdl,
5295 struct wma_tgt_vht_cap *vht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005296{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005297 int i, num_hw_modes, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005298 uint32_t vht_cap_info_2g, vht_cap_info_5g;
5299 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305300 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5301
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005302 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305303 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5304 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005305
5306 /*
5307 * for legacy device extended cap might not even come, so in that case
5308 * don't overwrite legacy values
5309 */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005310 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005311 WMA_LOGD("%s: No extended VHT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005312 return;
5313 }
5314
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005315 for (i = 0; i < total_mac_phy_cnt; i++) {
5316 vht_cap_info_2g = mac_phy_cap[i].vht_cap_info_2G;
5317 vht_cap_info_5g = mac_phy_cap[i].vht_cap_info_5G;
5318 if (vht_cap_info_2g)
5319 wma_derive_ext_vht_cap(&tmp_vht_cap,
5320 vht_cap_info_2g);
5321 if (vht_cap_info_5g)
5322 wma_derive_ext_vht_cap(&tmp_vht_cap,
5323 vht_cap_info_5g);
Krunal Soniaa664da2016-06-15 23:46:40 -07005324 }
5325
Ankit Guptaa5076012016-09-14 11:32:19 -07005326 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005327 sizeof(struct wma_tgt_vht_cap))) {
5328 qdf_mem_copy(vht_cap, &tmp_vht_cap,
5329 sizeof(struct wma_tgt_vht_cap));
5330 }
5331
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005332 WMA_LOGD("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005333 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
5334 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005335 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
5336 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
5337 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
5338 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
5339 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
5340}
5341
5342/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305343 * wma_update_ra_rate_limit() - update wma config
5344 * @wma_handle: wma handle
5345 * @cfg: target config
5346 *
5347 * Return: none
5348 */
5349#ifdef FEATURE_WLAN_RA_FILTERING
5350static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5351 struct wma_tgt_cfg *cfg)
5352{
5353 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
5354}
5355#else
5356static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5357 struct wma_tgt_cfg *cfg)
5358{
5359}
5360#endif
5361
5362/**
Krunal Sonica50b452017-08-04 22:24:59 -07005363 * wma_update_hdd_band_cap() - update band cap which hdd understands
5364 * @supported_band: supported band which has been given by FW
5365 * @tgt_cfg: target configuration to be updated
5366 *
5367 * Convert WMA given supported band to enum which HDD understands
5368 *
5369 * Return: None
5370 */
5371static void wma_update_hdd_band_cap(WMI_PHY_CAPABILITY supported_band,
5372 struct wma_tgt_cfg *tgt_cfg)
5373{
5374 switch (supported_band) {
5375 case WMI_11G_CAPABILITY:
5376 case WMI_11NG_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005377 tgt_cfg->band_cap = BAND_2G;
Krunal Sonica50b452017-08-04 22:24:59 -07005378 break;
5379 case WMI_11A_CAPABILITY:
5380 case WMI_11NA_CAPABILITY:
5381 case WMI_11AC_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005382 tgt_cfg->band_cap = BAND_5G;
Krunal Sonica50b452017-08-04 22:24:59 -07005383 break;
5384 case WMI_11AG_CAPABILITY:
5385 case WMI_11NAG_CAPABILITY:
5386 default:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005387 tgt_cfg->band_cap = BAND_ALL;
Krunal Sonica50b452017-08-04 22:24:59 -07005388 }
5389}
5390
5391/**
Arif Hussainee10f902017-12-27 16:30:17 -08005392 * wma_update_obss_detection_support() - update obss detection offload support
5393 * @wh: wma handle
5394 * @tgt_cfg: target configuration to be updated
5395 *
5396 * Update obss detection offload support based on service bit.
5397 *
5398 * Return: None
5399 */
5400static void wma_update_obss_detection_support(tp_wma_handle wh,
5401 struct wma_tgt_cfg *tgt_cfg)
5402{
Arif Hussain05fb4872018-01-03 16:02:55 -08005403 if (wmi_service_enabled(wh->wmi_handle,
5404 wmi_service_ap_obss_detection_offload))
Arif Hussainee10f902017-12-27 16:30:17 -08005405 tgt_cfg->obss_detection_offloaded = true;
5406 else
5407 tgt_cfg->obss_detection_offloaded = false;
5408}
5409
5410/**
Arif Hussain05fb4872018-01-03 16:02:55 -08005411 * wma_update_obss_color_collision_support() - update obss color collision
5412 * offload support
5413 * @wh: wma handle
5414 * @tgt_cfg: target configuration to be updated
5415 *
5416 * Update obss color collision offload support based on service bit.
5417 *
5418 * Return: None
5419 */
5420static void wma_update_obss_color_collision_support(tp_wma_handle wh,
5421 struct wma_tgt_cfg *tgt_cfg)
5422{
5423 if (wmi_service_enabled(wh->wmi_handle, wmi_service_bss_color_offload))
5424 tgt_cfg->obss_color_collision_offloaded = true;
5425 else
5426 tgt_cfg->obss_color_collision_offloaded = false;
5427}
5428
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005429#ifdef WLAN_SUPPORT_GREEN_AP
5430static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5431{
5432 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5433 WMI_SERVICE_EGAP))
5434 target_if_green_ap_register_egap_event_handler(
5435 wma_handle->pdev);
5436
5437}
5438#else
5439static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5440{
5441}
5442#endif
5443
Arif Hussain05fb4872018-01-03 16:02:55 -08005444/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 * wma_update_hdd_cfg() - update HDD config
5446 * @wma_handle: wma handle
5447 *
5448 * Return: none
5449 */
5450static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
5451{
5452 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05305453 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305454 target_resource_config *wlan_res_cfg;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305455 struct wlan_psoc_host_service_ext_param *service_ext_param;
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305456 struct target_psoc_info *tgt_hdl;
5457 struct wmi_unified *wmi_handle;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305458
5459 WMA_LOGD("%s: Enter", __func__);
5460
5461 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5462 if (!tgt_hdl) {
5463 WMA_LOGE("%s: target psoc info is NULL", __func__);
5464 return;
5465 }
5466
5467 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
Arif Hussaind15902c2018-03-02 00:08:29 -08005468 if (!wlan_res_cfg) {
5469 WMA_LOGE("%s: wlan_res_cfg is null", __func__);
5470 return;
5471 }
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305472 service_ext_param =
5473 target_psoc_get_service_ext_param(tgt_hdl);
Sourav Mohapatracf632572018-04-02 11:01:35 +05305474 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305475 if (!wmi_handle) {
5476 WMA_LOGE("%s: wmi handle is NULL", __func__);
5477 return;
5478 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305480 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07005481
5482 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
5484 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
5485
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305486 tgt_cfg.max_intf_count = wlan_res_cfg->num_vdevs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305488 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489 ATH_MAC_LEN);
5490
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305491 wma_update_target_services(wmi_handle, &tgt_cfg.services);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305492 wma_update_target_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5493 wma_update_target_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07005494 /*
5495 * This will overwrite the structure filled by wma_update_target_ht_cap
5496 * and wma_update_target_vht_cap APIs.
5497 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305498 wma_update_target_ext_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5499 wma_update_target_ext_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305501 wma_update_target_ext_he_cap(tgt_hdl, &tgt_cfg);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005502
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305503 tgt_cfg.target_fw_version = target_if_get_fw_version(tgt_hdl);
5504 if (service_ext_param)
5505 tgt_cfg.target_fw_vers_ext =
5506 service_ext_param->fw_build_vers_ext;
5507
Ryan Hsuc6918552018-05-16 13:29:59 -07005508 tgt_cfg.hw_bd_id = wma_handle->hw_bd_id;
5509 tgt_cfg.hw_bd_info.bdf_version = wma_handle->hw_bd_info[BDF_VERSION];
5510 tgt_cfg.hw_bd_info.ref_design_id =
5511 wma_handle->hw_bd_info[REF_DESIGN_ID];
5512 tgt_cfg.hw_bd_info.customer_id = wma_handle->hw_bd_info[CUSTOMER_ID];
5513 tgt_cfg.hw_bd_info.project_id = wma_handle->hw_bd_info[PROJECT_ID];
5514 tgt_cfg.hw_bd_info.board_data_rev =
5515 wma_handle->hw_bd_info[BOARD_DATA_REV];
5516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517#ifdef WLAN_FEATURE_LPSS
5518 tgt_cfg.lpss_support = wma_handle->lpss_support;
5519#endif /* WLAN_FEATURE_LPSS */
5520 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Nachiket Kukadee547a482018-05-22 16:43:30 +05305521 tgt_cfg.apf_enabled = wma_handle->apf_enabled;
Arif Hussaind54b62c2018-03-01 13:31:37 -08005522 tgt_cfg.dfs_cac_offload = wma_handle->is_dfs_offloaded;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305523 tgt_cfg.rcpi_enabled = wma_handle->rcpi_enabled;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305524 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05305525 wma_update_hdd_band_cap(target_if_get_phy_capability(tgt_hdl),
5526 &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08005527 tgt_cfg.fine_time_measurement_cap =
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305528 target_if_get_wmi_fw_sub_feat_caps(tgt_hdl);
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05305529 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
5530 - WMI_TLV_HEADROOM;
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05305531 tgt_cfg.tx_bfee_8ss_enabled = wma_handle->tx_bfee_8ss_enabled;
Arif Hussainee10f902017-12-27 16:30:17 -08005532 wma_update_obss_detection_support(wma_handle, &tgt_cfg);
Arif Hussain05fb4872018-01-03 16:02:55 -08005533 wma_update_obss_color_collision_support(wma_handle, &tgt_cfg);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07005534 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07005535 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Himanshu Agarwal2228e072018-01-24 17:42:17 +05305536 target_if_store_pdev_target_if_ctx(wma_get_pdev_from_scn_handle);
Nachiket Kukade7dda8c22018-03-12 19:59:43 +05305537 target_pdev_set_wmi_handle(wma_handle->pdev->tgt_if_handle,
5538 wma_handle->wmi_handle);
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005539 wma_green_ap_register_handlers(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540}
5541
5542/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
5544 * @wma_handle: WMA handle
5545 *
5546 * Prints the DBS HW modes sent by the FW as part
5547 * of WMI ready event
5548 *
5549 * Return: None
5550 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005551static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552{
5553 uint32_t i, param;
5554
5555 if (!wma_handle) {
5556 WMA_LOGE("%s: Invalid WMA handle", __func__);
5557 return;
5558 }
5559
5560 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5561 param = wma_handle->hw_mode.hw_mode_list[i];
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005562 WMA_LOGD("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305564 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
5565 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
5566 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005567 WMA_LOGD("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305569 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
5570 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
5571 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005572 WMA_LOGD("%s:[%d] DBS:%d SBS:%d", __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305573 WMA_HW_MODE_DBS_MODE_GET(param),
5574 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005576 policy_mgr_dump_dbs_hw_mode(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005577}
5578
5579/**
5580 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305581 * @psoc: Object manager psoc
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305582 * @scan_config: Scam mode configuration
5583 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 *
5585 * Enables all the valid bits of concurrent_scan_config_bits and
5586 * fw_mode_config_bits.
5587 *
5588 * Return: None
5589 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305590static void wma_init_scan_fw_mode_config(struct wlan_objmgr_psoc *psoc,
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005591 uint32_t scan_config,
5592 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594 WMA_LOGD("%s: Enter", __func__);
5595
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305596 if (!psoc) {
5597 WMA_LOGE("%s: obj psoc is NULL", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005598 return;
5599 }
5600
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305601 policy_mgr_init_dbs_config(psoc, scan_config, fw_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602}
5603
5604/**
Nachiket Kukadee547a482018-05-22 16:43:30 +05305605 * wma_update_ra_limit() - update ra limit based on apf filter
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305606 * enabled or not
5607 * @handle: wma handle
5608 *
5609 * Return: none
5610 */
5611#ifdef FEATURE_WLAN_RA_FILTERING
5612static void wma_update_ra_limit(tp_wma_handle wma_handle)
5613{
Nachiket Kukadee547a482018-05-22 16:43:30 +05305614 if (wma_handle->apf_enabled)
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305615 wma_handle->IsRArateLimitEnabled = false;
5616}
5617#else
5618static void wma_update_ra__limit(tp_wma_handle handle)
5619{
5620}
5621#endif
5622
Dustin Brown06259e52018-02-28 16:00:02 -08005623static void wma_set_pmo_caps(struct wlan_objmgr_psoc *psoc)
5624{
5625 QDF_STATUS status;
5626 struct pmo_device_caps caps;
5627
5628 caps.arp_ns_offload =
5629 wma_is_service_enabled(wmi_service_arpns_offload);
5630 caps.apf =
Nachiket Kukadee547a482018-05-22 16:43:30 +05305631 wma_is_service_enabled(wmi_service_apf_offload);
Dustin Brown06259e52018-02-28 16:00:02 -08005632 caps.packet_filter =
5633 wma_is_service_enabled(wmi_service_packet_filter_offload);
5634 caps.unified_wow =
5635 wma_is_service_enabled(wmi_service_unified_wow_capability);
5636
5637 status = ucfg_pmo_psoc_set_caps(psoc, &caps);
5638 if (QDF_IS_STATUS_ERROR(status))
5639 WMA_LOGE("Failed to set PMO capabilities; status:%d", status);
5640}
5641
5642static void wma_set_component_caps(struct wlan_objmgr_psoc *psoc)
5643{
5644 wma_set_pmo_caps(psoc);
5645}
5646
Mukul Sharma44746042018-05-24 17:30:52 +05305647#if defined(WLAN_FEATURE_GTK_OFFLOAD) && defined(WLAN_POWER_MANAGEMENT_OFFLOAD)
5648static QDF_STATUS wma_register_gtk_offload_event(tp_wma_handle wma_handle)
5649{
5650 QDF_STATUS status = QDF_STATUS_E_FAILURE;
5651
5652 if (!wma_handle) {
5653 WMA_LOGE("%s: wma_handle passed is NULL", __func__);
5654 return QDF_STATUS_E_FAILURE;
5655 }
5656
5657 if (wmi_service_enabled(wma_handle->wmi_handle,
5658 wmi_service_gtk_offload)) {
5659 status = wmi_unified_register_event_handler(
5660 wma_handle->wmi_handle,
5661 wmi_gtk_offload_status_event_id,
5662 target_if_pmo_gtk_offload_status_event,
5663 WMA_RX_WORK_CTX);
5664 }
5665 return status;
5666}
5667#else
5668static QDF_STATUS wma_register_gtk_offload_event(tp_wma_handle wma_handle)
5669{
5670 return QDF_STATUS_SUCCESS;
5671}
5672#endif /* WLAN_FEATURE_GTK_OFFLOAD && WLAN_POWER_MANAGEMENT_OFFLOAD */
5673
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305674/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675 * wma_rx_service_ready_event() - event handler to process
5676 * wmi rx sevice ready event.
5677 * @handle: wma handle
5678 * @cmd_param_info: command params info
5679 *
5680 * Return: none
5681 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305682int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005683 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005685 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005686 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
5687 wmi_service_ready_event_fixed_param *ev;
Dustin Brown7678b6c2018-03-07 13:00:52 -08005688 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005689 uint32_t *ev_wlan_dbs_hw_mode_list;
Leo Chang96464902016-10-28 11:10:54 -07005690 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305691 struct target_psoc_info *tgt_hdl;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305692 struct wlan_psoc_target_capability_info *tgt_cap_info;
5693 target_resource_config *wlan_res_cfg;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305694 struct wmi_unified *wmi_handle;
5695 uint32_t *service_bitmap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696
5697 WMA_LOGD("%s: Enter", __func__);
5698
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305699 if (!handle) {
5700 WMA_LOGE("%s: wma_handle passed is NULL", __func__);
5701 return -EINVAL;
5702 }
5703
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305704 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5705 if (!tgt_hdl) {
5706 WMA_LOGE("%s: target psoc info is NULL", __func__);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305707 return -EINVAL;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305708 }
5709
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305710 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
5711 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305712 service_bitmap = target_psoc_get_service_bitmap(tgt_hdl);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305713
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305715 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005716 WMA_LOGE("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305717 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718 }
5719
5720 ev = param_buf->fixed_param;
5721 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005722 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305723 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724 }
5725
Sourav Mohapatracf632572018-04-02 11:01:35 +05305726 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305727 if (!wmi_handle) {
5728 WMA_LOGE("%s: wmi handle is NULL", __func__);
5729 return -EINVAL;
5730 }
5731
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005732 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005733
Amar Singhal7b038ca2017-10-04 13:38:39 -07005734 if (ev->num_dbs_hw_modes > param_buf->num_wlan_dbs_hw_mode_list) {
5735 WMA_LOGE("FW dbs_hw_mode entry %d more than value %d in TLV hdr",
5736 ev->num_dbs_hw_modes,
5737 param_buf->num_wlan_dbs_hw_mode_list);
5738 return -EINVAL;
5739 }
5740
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005741 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
5742 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
5743 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305744 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005745 wma_handle->num_dbs_hw_modes);
5746 if (!wma_handle->hw_mode.hw_mode_list) {
5747 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
5748 /* Continuing with the rest of the processing */
5749 }
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305750
5751 if (wma_handle->hw_mode.hw_mode_list)
5752 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
5753 ev_wlan_dbs_hw_mode_list,
5754 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
5755 wma_handle->num_dbs_hw_modes));
5756
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005757 policy_mgr_init_dbs_hw_mode(wma_handle->psoc,
5758 ev->num_dbs_hw_modes, ev_wlan_dbs_hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759 wma_dump_dbs_hw_mode(wma_handle);
5760
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305761 /* Initializes the fw_mode and scan_config to zero.
5762 * If ext service ready event is present it will set
5763 * the actual values of these two params.
5764 * This is to ensure that no garbage values would be
5765 * present in the absence of ext service ready event.
5766 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305767 wma_init_scan_fw_mode_config(wma_handle->psoc, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305769 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305770 sizeof(HAL_REG_CAPABILITIES));
5771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005772 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305774 wma_handle->new_hw_mode_index = tgt_cap_info->default_dbs_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005775 policy_mgr_update_new_hw_mode_index(wma_handle->psoc,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305776 tgt_cap_info->default_dbs_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005777
5778 WMA_LOGD("%s: Firmware default hw mode index : %d",
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305779 __func__, tgt_cap_info->default_dbs_hw_mode_index);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005780 WMA_LOGI("%s: Firmware build version : %08x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781 __func__, ev->fw_build_vers);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305782 WMA_LOGD("FW fine time meas cap: 0x%x",
5783 tgt_cap_info->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784
Ryan Hsuc6918552018-05-16 13:29:59 -07005785 wma_handle->hw_bd_id = ev->hw_bd_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005786
Ryan Hsuc6918552018-05-16 13:29:59 -07005787 wma_handle->hw_bd_info[BDF_VERSION] =
5788 WMI_GET_BDF_VERSION(ev->hw_bd_info);
5789 wma_handle->hw_bd_info[REF_DESIGN_ID] =
5790 WMI_GET_REF_DESIGN(ev->hw_bd_info);
5791 wma_handle->hw_bd_info[CUSTOMER_ID] =
5792 WMI_GET_CUSTOMER_ID(ev->hw_bd_info);
5793 wma_handle->hw_bd_info[PROJECT_ID] =
5794 WMI_GET_PROJECT_ID(ev->hw_bd_info);
5795 wma_handle->hw_bd_info[BOARD_DATA_REV] =
5796 WMI_GET_BOARD_DATA_REV(ev->hw_bd_info);
5797
5798 WMA_LOGI("%s: Board id: %x, Board version: %x %x %x %x %x",
5799 __func__, wma_handle->hw_bd_id,
5800 wma_handle->hw_bd_info[BDF_VERSION],
5801 wma_handle->hw_bd_info[REF_DESIGN_ID],
5802 wma_handle->hw_bd_info[CUSTOMER_ID],
5803 wma_handle->hw_bd_info[PROJECT_ID],
5804 wma_handle->hw_bd_info[BOARD_DATA_REV]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305807 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305808 service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05305810
Leo Chang96464902016-10-28 11:10:54 -07005811 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(soc,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005812 wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi));
Leo Chang96464902016-10-28 11:10:54 -07005813 cdp_set_desc_global_pool_size(soc, ev->num_msdu_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005814 /* SWBA event handler for beacon transmission */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305815 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305816 wmi_host_swba_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305817 wma_beacon_swba_handler,
5818 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005819 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 WMA_LOGE("Failed to register swba beacon event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305821 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822 }
5823#ifdef WLAN_FEATURE_LPSS
5824 wma_handle->lpss_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005825 wmi_service_enabled(wmi_handle, wmi_service_lpass);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005826#endif /* WLAN_FEATURE_LPSS */
5827
5828 /*
5829 * This Service bit is added to check for ARP/NS Offload
5830 * support for LL/HL targets
5831 */
5832 wma_handle->ap_arpns_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005833 wmi_service_enabled(wmi_handle, wmi_service_ap_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834
Nachiket Kukadee547a482018-05-22 16:43:30 +05305835 wma_handle->apf_enabled = (wma_handle->apf_packet_filter_enable &&
5836 wmi_service_enabled(wmi_handle, wmi_service_apf_offload));
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305837 wma_update_ra_limit(wma_handle);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005838
5839 if (wmi_service_enabled(wmi_handle, wmi_service_csa_offload)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005840 WMA_LOGD("%s: FW support CSA offload capability", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005841 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305842 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305843 wmi_csa_handling_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305844 wma_csa_offload_handler,
5845 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005846 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847 WMA_LOGE("Failed to register CSA offload event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305848 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 }
5850 }
5851
Dustin Brown7678b6c2018-03-07 13:00:52 -08005852 if (wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005853 WMA_LOGD("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005854 /*
5855 * Register Tx completion event handler for MGMT Tx over WMI
5856 * case
5857 */
5858 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305859 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305860 wmi_mgmt_tx_completion_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305861 wma_mgmt_tx_completion_handler,
5862 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005863 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005864 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305865 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005866 }
5867
Nirav Shah20489972016-06-16 19:20:28 +05305868 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305869 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305870 wmi_mgmt_tx_bundle_completion_event_id,
Nirav Shah20489972016-06-16 19:20:28 +05305871 wma_mgmt_tx_bundle_completion_handler,
5872 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005873 if (QDF_IS_STATUS_ERROR(status)) {
Nirav Shah20489972016-06-16 19:20:28 +05305874 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305875 goto free_hw_mode_list;
Nirav Shah20489972016-06-16 19:20:28 +05305876 }
5877
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878 } else {
5879 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
5880 }
Dustin Brown7678b6c2018-03-07 13:00:52 -08005881
Mukul Sharma44746042018-05-24 17:30:52 +05305882 status = wma_register_gtk_offload_event(wma_handle);
5883 if (QDF_IS_STATUS_ERROR(status)) {
5884 WMA_LOGE("Failed to register GTK offload event cb");
5885 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005886 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005887
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305888 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305889 wmi_tbttoffset_update_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305890 wma_tbttoffset_update_event_handler,
5891 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005892 if (QDF_IS_STATUS_ERROR(status)) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005893 WMA_LOGE("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305894 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895 }
5896
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305897 if (wmi_service_enabled(wma_handle->wmi_handle,
5898 wmi_service_rcpi_support)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305899 /* register for rcpi response event */
5900 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305901 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305902 wmi_update_rcpi_event_id,
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305903 wma_rcpi_event_handler,
5904 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005905 if (QDF_IS_STATUS_ERROR(status)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305906 WMA_LOGE("Failed to register RCPI event handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305907 goto free_hw_mode_list;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305908 }
5909 wma_handle->rcpi_enabled = true;
5910 }
5911
Govind Singhefc5ccd2016-04-25 11:11:55 +05305912 /* mac_id is replaced with pdev_id in converged firmware to have
5913 * multi-radio support. In order to maintain backward compatibility
5914 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
5915 * in service bitmap from FW and host needs to set use_pdev_id in
5916 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
5917 * service is not set, then host shall not expect MAC ID from FW in
5918 * VDEV START RESPONSE event and host shall use PDEV ID.
5919 */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305920 if (wmi_service_enabled(wmi_handle, wmi_service_deprecated_replace))
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305921 wlan_res_cfg->use_pdev_id = true;
Govind Singhefc5ccd2016-04-25 11:11:55 +05305922 else
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305923 wlan_res_cfg->use_pdev_id = false;
Govind Singhefc5ccd2016-04-25 11:11:55 +05305924
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305925 wlan_res_cfg->max_num_dbs_scan_duty_cycle = CDS_DBS_SCAN_CLIENTS_MAX;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05305926
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005927 /* Initialize the log supported event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305928 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305929 wmi_diag_event_id_log_supported_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305930 wma_log_supported_evt_handler,
5931 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005932 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 WMA_LOGE("Failed to register log supported event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305934 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005935 }
5936
Leo Chang96464902016-10-28 11:10:54 -07005937 cdp_mark_first_wakeup_packet(soc,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305938 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305939 wmi_service_mark_first_wakeup_packet));
Arif Hussaind54b62c2018-03-01 13:31:37 -08005940 wma_handle->is_dfs_offloaded =
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305941 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305942 wmi_service_dfs_phyerr_offload);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07005943 wma_handle->nan_datapath_enabled =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305944 wmi_service_enabled(wma_handle->wmi_handle,
5945 wmi_service_nan_data);
Dustin Brown06259e52018-02-28 16:00:02 -08005946
5947 wma_set_component_caps(wma_handle->psoc);
5948
Dustin Brownb9987af2018-03-01 17:15:11 -08005949 wma_update_fw_config(wma_handle->psoc, tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005950
Dustin Brown7678b6c2018-03-07 13:00:52 -08005951 status = wmi_unified_save_fw_version_cmd(wmi_handle, param_buf);
5952 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhf25a0f12016-03-08 16:09:48 +05305953 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305954 goto free_hw_mode_list;
Govind Singhf25a0f12016-03-08 16:09:48 +05305955 }
5956
Zhu Jianmin2d87a1c2018-05-31 11:22:23 +08005957 if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) {
5958 status = qdf_mc_timer_start(
5959 &wma_handle->service_ready_ext_timer,
5960 WMA_SERVICE_READY_EXT_TIMEOUT);
5961 if (QDF_IS_STATUS_ERROR(status))
5962 WMA_LOGE("Failed to start the service ready ext timer");
5963 }
Dustin Brown7678b6c2018-03-07 13:00:52 -08005964 wma_handle->tx_bfee_8ss_enabled =
5965 wmi_service_enabled(wmi_handle, wmi_service_8ss_tx_bfee);
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05305966
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305967 target_psoc_set_num_radios(tgt_hdl, 1);
5968
Govind Singhd76a5b02016-03-08 15:12:14 +05305969 return 0;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305970
5971free_hw_mode_list:
5972 if (wma_handle->hw_mode.hw_mode_list) {
5973 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
5974 wma_handle->hw_mode.hw_mode_list = NULL;
5975 WMA_LOGD("%s: DBS list is freed", __func__);
5976 }
5977
5978 return -EINVAL;
5979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005980}
5981
5982/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07005983 * wma_get_phyid_for_given_band() - to get phyid for band
5984 *
5985 * @wma_handle: Pointer to wma handle
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305986* @tgt_hdl: target psoc information
Krunal Soni0193b6f2016-08-15 15:53:43 -07005987 * @band: enum value of for 2G or 5G band
5988 * @phyid: Pointer to phyid which needs to be filled
5989 *
5990 * This API looks in to the map to find out which particular phy supports
5991 * provided band and return the idx (also called phyid) of that phy. Caller
5992 * use this phyid to fetch various caps of that phy
5993 *
5994 * Return: QDF_STATUS
5995 */
5996static QDF_STATUS wma_get_phyid_for_given_band(
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005997 tp_wma_handle wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305998 struct target_psoc_info *tgt_hdl,
Krunal Soni0193b6f2016-08-15 15:53:43 -07005999 enum cds_band_type band, uint8_t *phyid)
6000{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306001 uint8_t idx, i, num_radios;
6002 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006003
6004 if (!wma_handle) {
6005 WMA_LOGE("Invalid wma handle");
6006 return QDF_STATUS_E_FAILURE;
6007 }
6008
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306009 idx = 0;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006010 *phyid = idx;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306011 num_radios = target_psoc_get_num_radios(tgt_hdl);
6012 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006013
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306014 for (i = 0; i < num_radios; i++) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006015 if ((band == CDS_BAND_2GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306016 (WLAN_2G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006017 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006018 WMA_LOGD("Select 2G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006019 return QDF_STATUS_SUCCESS;
6020 } else if ((band == CDS_BAND_5GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306021 (WLAN_5G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006022 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006023 WMA_LOGD("Select 5G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006024 return QDF_STATUS_SUCCESS;
6025 }
6026 }
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006027 WMA_LOGD("Using default single hw mode phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006028 return QDF_STATUS_SUCCESS;
6029}
6030
6031/**
6032 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
6033 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
6034 * @hw_mode: Provided hardware mode
6035 * @band: Provide band i.e. 2G or 5G
6036 *
6037 * This API finds cap which suitable for provided hw mode and band. If user
6038 * is provides some invalid hw mode then it will automatically falls back to
6039 * default hw mode
6040 *
6041 * Return: QDF_STATUS
6042 */
6043QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
6044 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
6045{
6046 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306047 struct target_psoc_info *tgt_hdl;
6048 int ht_cap_info, vht_cap_info;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306049 uint8_t phyid, our_hw_mode = hw_mode, num_hw_modes;
6050 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006051
6052 if (!wma_handle) {
6053 WMA_LOGE("Invalid wma handle");
6054 return QDF_STATUS_E_FAILURE;
6055 }
6056
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306057 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6058 if (!tgt_hdl) {
6059 WMA_LOGE("%s: target psoc info is NULL", __func__);
6060 return -EINVAL;
6061 }
6062
6063 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
6064 vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306065 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6066 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306067
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306068 if (!num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08006069 WMA_LOGD("Invalid number of hw modes, use legacy HT/VHT caps");
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306070 caps_per_phy->ht_2g = ht_cap_info;
6071 caps_per_phy->ht_5g = ht_cap_info;
6072 caps_per_phy->vht_2g = vht_cap_info;
6073 caps_per_phy->vht_5g = vht_cap_info;
jiad080abce2017-08-08 15:17:39 +08006074 /* legacy platform doesn't support HE IE */
6075 caps_per_phy->he_2g = 0;
6076 caps_per_phy->he_5g = 0;
6077
6078 return QDF_STATUS_SUCCESS;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006079 }
6080
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006081 if (!policy_mgr_is_dbs_enable(wma_handle->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006082 our_hw_mode = HW_MODE_DBS_NONE;
6083
6084 if (!caps_per_phy) {
6085 WMA_LOGE("Invalid caps pointer");
6086 return QDF_STATUS_E_FAILURE;
6087 }
6088
Krunal Soni0193b6f2016-08-15 15:53:43 -07006089 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306090 wma_get_phyid_for_given_band(wma_handle, tgt_hdl, band, &phyid)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006091 WMA_LOGE("Invalid phyid");
6092 return QDF_STATUS_E_FAILURE;
6093 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006094
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306095 caps_per_phy->ht_2g = mac_phy_cap[phyid].ht_cap_info_2G;
6096 caps_per_phy->ht_5g = mac_phy_cap[phyid].ht_cap_info_5G;
6097 caps_per_phy->vht_2g = mac_phy_cap[phyid].vht_cap_info_2G;
6098 caps_per_phy->vht_5g = mac_phy_cap[phyid].vht_cap_info_5G;
6099 caps_per_phy->he_2g = mac_phy_cap[phyid].he_cap_info_2G;
6100 caps_per_phy->he_5g = mac_phy_cap[phyid].he_cap_info_5G;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006101
Naveen Rawat98322472018-03-06 10:29:42 -08006102 caps_per_phy->tx_chain_mask_2G = mac_phy_cap->tx_chain_mask_2G;
6103 caps_per_phy->rx_chain_mask_2G = mac_phy_cap->rx_chain_mask_2G;
6104 caps_per_phy->tx_chain_mask_5G = mac_phy_cap->tx_chain_mask_5G;
6105 caps_per_phy->rx_chain_mask_5G = mac_phy_cap->rx_chain_mask_5G;
6106
Krunal Soni0193b6f2016-08-15 15:53:43 -07006107 return QDF_STATUS_SUCCESS;
6108}
6109
6110/**
6111 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
6112 *
6113 * @channel: Channel number for which it needs to check if rx ldpc is enabled
6114 *
6115 * This API takes channel number as argument and takes default hw mode as DBS
6116 * to check if rx LDPC support is enabled for that channel or no
6117 */
6118bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
6119{
jiad080abce2017-08-08 15:17:39 +08006120 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306121 struct target_psoc_info *tgt_hdl;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006122 struct wma_caps_per_phy caps_per_phy = {0};
6123 enum cds_band_type band;
6124 bool status;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306125 uint8_t num_hw_modes;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006126
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006127 if (!wma_handle) {
6128 WMA_LOGE("Invalid wma handle");
6129 return false;
6130 }
6131
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306132 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6133 if (!tgt_hdl) {
6134 WMA_LOGE("Target handle is NULL");
6135 return QDF_STATUS_E_FAILURE;
6136 }
6137
6138 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6139
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006140 if (!WLAN_REG_IS_24GHZ_CH(channel))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006141 band = CDS_BAND_5GHZ;
6142 else
6143 band = CDS_BAND_2GHZ;
6144
6145 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
6146 &caps_per_phy,
6147 HW_MODE_DBS, band)) {
6148 return false;
6149 }
jiad080abce2017-08-08 15:17:39 +08006150
6151 /*
6152 * Legacy platforms like Rome set WMI_HT_CAP_LDPC to specify RX LDPC
6153 * capability. But new platforms like Helium set WMI_HT_CAP_RX_LDPC
6154 * instead.
6155 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306156 if (0 == num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08006157 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_LDPC));
6158 } else {
6159 if (WLAN_REG_IS_24GHZ_CH(channel))
6160 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
6161 else
6162 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
6163 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006164
6165 return status;
6166}
6167
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006168/**
6169 * wma_print_mac_phy_capabilities() - Prints MAC PHY capabilities
6170 * @cap: pointer to WMI_MAC_PHY_CAPABILITIES
6171 * @index: MAC_PHY index
6172 *
6173 * Return: none
6174 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306175static void wma_print_mac_phy_capabilities(struct wlan_psoc_host_mac_phy_caps
6176 *cap, int index)
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006177{
6178 uint32_t mac_2G, mac_5G;
6179 uint32_t phy_2G[WMI_MAX_HECAP_PHY_SIZE];
6180 uint32_t phy_5G[WMI_MAX_HECAP_PHY_SIZE];
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306181 struct wlan_psoc_host_ppe_threshold ppet_2G, ppet_5G;
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006182
6183 WMA_LOGI("\t: index [%d]", index);
6184 WMA_LOGI("\t: cap for hw_mode_id[%d]", cap->hw_mode_id);
6185 WMA_LOGI("\t: pdev_id[%d]", cap->pdev_id);
6186 WMA_LOGI("\t: phy_id[%d]", cap->phy_id);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306187 WMA_LOGI("\t: supports_11b[%d]", cap->supports_11b);
6188 WMA_LOGI("\t: supports_11g[%d]", cap->supports_11g);
6189 WMA_LOGI("\t: supports_11a[%d]", cap->supports_11a);
6190 WMA_LOGI("\t: supports_11n[%d]", cap->supports_11n);
6191 WMA_LOGI("\t: supports_11ac[%d]", cap->supports_11ac);
6192 WMA_LOGI("\t: supports_11ax[%d]", cap->supports_11ax);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006193 WMA_LOGI("\t: supported_bands[%d]", cap->supported_bands);
6194 WMA_LOGI("\t: ampdu_density[%d]", cap->ampdu_density);
6195 WMA_LOGI("\t: max_bw_supported_2G[%d]", cap->max_bw_supported_2G);
6196 WMA_LOGI("\t: ht_cap_info_2G[%d]", cap->ht_cap_info_2G);
6197 WMA_LOGI("\t: vht_cap_info_2G[%d]", cap->vht_cap_info_2G);
6198 WMA_LOGI("\t: vht_supp_mcs_2G[%d]", cap->vht_supp_mcs_2G);
6199 WMA_LOGI("\t: tx_chain_mask_2G[%d]", cap->tx_chain_mask_2G);
6200 WMA_LOGI("\t: rx_chain_mask_2G[%d]", cap->rx_chain_mask_2G);
6201 WMA_LOGI("\t: max_bw_supported_5G[%d]", cap->max_bw_supported_5G);
6202 WMA_LOGI("\t: ht_cap_info_5G[%d]", cap->ht_cap_info_5G);
6203 WMA_LOGI("\t: vht_cap_info_5G[%d]", cap->vht_cap_info_5G);
6204 WMA_LOGI("\t: vht_supp_mcs_5G[%d]", cap->vht_supp_mcs_5G);
6205 WMA_LOGI("\t: tx_chain_mask_5G[%d]", cap->tx_chain_mask_5G);
6206 WMA_LOGI("\t: rx_chain_mask_5G[%d]", cap->rx_chain_mask_5G);
6207 WMA_LOGI("\t: he_cap_info_2G[%08x]", cap->he_cap_info_2G);
6208 WMA_LOGI("\t: he_supp_mcs_2G[%08x]", cap->he_supp_mcs_2G);
6209 WMA_LOGI("\t: he_cap_info_5G[%08x]", cap->he_cap_info_5G);
6210 WMA_LOGI("\t: he_supp_mcs_5G[%08x]", cap->he_supp_mcs_5G);
6211 mac_2G = cap->he_cap_info_2G;
6212 mac_5G = cap->he_cap_info_5G;
6213 qdf_mem_copy(phy_2G, cap->he_cap_phy_info_2G,
6214 WMI_MAX_HECAP_PHY_SIZE * 4);
6215 qdf_mem_copy(phy_5G, cap->he_cap_phy_info_5G,
6216 WMI_MAX_HECAP_PHY_SIZE * 4);
6217 ppet_2G = cap->he_ppet2G;
6218 ppet_5G = cap->he_ppet5G;
6219
6220 wma_print_he_mac_cap(mac_2G);
6221 wma_print_he_phy_cap(phy_2G);
6222 wma_print_he_ppet(&ppet_2G);
6223 wma_print_he_mac_cap(mac_5G);
6224 wma_print_he_phy_cap(phy_5G);
6225 wma_print_he_ppet(&ppet_5G);
6226}
Krunal Soni0193b6f2016-08-15 15:53:43 -07006227
6228/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006229 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306230 * @tgt_info: target related info
Krunal Soni2e48d012016-05-02 16:55:26 -07006231 *
6232 * This function prints all the caps populater per hw mode and per PHY
6233 *
6234 * Return: none
6235 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306236static void wma_print_populate_soc_caps(struct target_psoc_info *tgt_hdl)
Krunal Soni2e48d012016-05-02 16:55:26 -07006237{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006238 int i, num_hw_modes, total_mac_phy_cnt;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306239 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap, *tmp;
6240
6241 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006242 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006243
6244 /* print number of hw modes */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306245 WMA_LOGD("%s: num of hw modes [%d]", __func__, num_hw_modes);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006246 WMA_LOGD("%s: num mac_phy_cnt [%d]", __func__, total_mac_phy_cnt);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306247 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006248 WMA_LOGD("%s: <====== HW mode cap printing starts ======>", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07006249 /* print cap of each hw mode */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006250 for (i = 0; i < total_mac_phy_cnt; i++) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006251 WMA_LOGD("====>: hw mode id[%d], phy_id map[%d]",
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006252 mac_phy_cap[i].hw_mode_id,
6253 mac_phy_cap[i].phy_id);
6254 tmp = &mac_phy_cap[i];
6255 wma_print_mac_phy_capabilities(tmp, i);
Krunal Soni2e48d012016-05-02 16:55:26 -07006256 }
6257 WMA_LOGI("%s: <====== HW mode cap printing ends ======>\n", __func__);
6258}
6259
6260/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306261 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
6262 * in terms of hw_mode_bandwidth
6263 * @width: bandwidth in terms of wmi_channel_width
6264 *
6265 * This function returns the bandwidth in terms of hw_mode_bandwidth.
6266 *
6267 * Return: BW in terms of hw_mode_bandwidth.
6268 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006269static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306270 wmi_channel_width width)
6271{
6272 switch (width) {
6273 case WMI_CHAN_WIDTH_20:
6274 return HW_MODE_20_MHZ;
6275 case WMI_CHAN_WIDTH_40:
6276 return HW_MODE_40_MHZ;
6277 case WMI_CHAN_WIDTH_80:
6278 return HW_MODE_80_MHZ;
6279 case WMI_CHAN_WIDTH_160:
6280 return HW_MODE_160_MHZ;
6281 case WMI_CHAN_WIDTH_80P80:
6282 return HW_MODE_80_PLUS_80_MHZ;
6283 case WMI_CHAN_WIDTH_5:
6284 return HW_MODE_5_MHZ;
6285 case WMI_CHAN_WIDTH_10:
6286 return HW_MODE_10_MHZ;
6287 default:
6288 return HW_MODE_BW_NONE;
6289 }
6290
6291 return HW_MODE_BW_NONE;
6292}
6293
6294/**
6295 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
6296 * supported from the capabilities.
6297 * @caps: PHY capability
6298 * @info: param to store TX-RX stream and BW information
6299 *
6300 * This function will calculate TX-RX stream and bandwidth supported
6301 * as per the PHY capability, and assign to mac_ss_bw_info.
6302 *
6303 * Return: none
6304 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306305static void wma_get_hw_mode_params(struct wlan_psoc_host_mac_phy_caps *caps,
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306306 struct mac_ss_bw_info *info)
6307{
6308 if (!caps) {
6309 WMA_LOGE("%s: Invalid capabilities", __func__);
6310 return;
6311 }
6312
6313 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
6314 QDF_MAX(caps->tx_chain_mask_2G,
6315 caps->tx_chain_mask_5G));
6316 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
6317 QDF_MAX(caps->rx_chain_mask_2G,
6318 caps->rx_chain_mask_5G));
6319 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
6320 QDF_MAX(caps->max_bw_supported_2G,
6321 caps->max_bw_supported_5G));
6322}
6323
6324/**
6325 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
6326 * DBS in hw_mode_list
6327 * @wma_handle: pointer to wma global structure
6328 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
6329 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
6330 * @pos: refers to hw_mode_index
6331 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306332 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306333 *
6334 * This function sets TX-RX stream, bandwidth and DBS mode in
6335 * hw_mode_list.
6336 *
6337 * Return: none
6338 */
6339static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
6340 struct mac_ss_bw_info mac0_ss_bw_info,
6341 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306342 uint32_t pos, uint32_t dbs_mode,
6343 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306344{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306345 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306346 wma_handle->hw_mode.hw_mode_list[pos],
6347 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306348 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306349 wma_handle->hw_mode.hw_mode_list[pos],
6350 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306351 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306352 wma_handle->hw_mode.hw_mode_list[pos],
6353 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306354 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306355 wma_handle->hw_mode.hw_mode_list[pos],
6356 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306357 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306358 wma_handle->hw_mode.hw_mode_list[pos],
6359 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306360 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306361 wma_handle->hw_mode.hw_mode_list[pos],
6362 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306363 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306364 wma_handle->hw_mode.hw_mode_list[pos],
6365 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306366 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306367 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306368 HW_MODE_AGILE_DFS_NONE);
6369 WMA_HW_MODE_SBS_MODE_SET(
6370 wma_handle->hw_mode.hw_mode_list[pos],
6371 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306372}
6373
6374/**
6375 * wma_update_hw_mode_list() - updates hw_mode_list
6376 * @wma_handle: pointer to wma global structure
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306377 * @tgt_hdl - target psoc information
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306378 *
6379 * This function updates hw_mode_list with tx_streams, rx_streams,
6380 * bandwidth, dbs and agile dfs for each hw_mode.
6381 *
6382 * Returns: 0 for success else failure.
6383 */
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306384static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle,
6385 struct target_psoc_info *tgt_hdl)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306386{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306387 struct wlan_psoc_host_mac_phy_caps *tmp, *mac_phy_cap;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306388 uint32_t i, hw_config_type, j = 0;
6389 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306390 struct mac_ss_bw_info mac0_ss_bw_info = {0};
6391 struct mac_ss_bw_info mac1_ss_bw_info = {0};
Krunal Sonica50b452017-08-04 22:24:59 -07006392 WMI_PHY_CAPABILITY new_supported_band = 0;
6393 bool supported_band_update_failure = false;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306394 struct wlan_psoc_target_capability_info *tgt_cap_info;
6395 int num_hw_modes;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306396
6397 if (!wma_handle) {
6398 WMA_LOGE("%s: Invalid wma handle", __func__);
6399 return QDF_STATUS_E_FAILURE;
6400 }
6401
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306402 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6403 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
6404 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306405 /*
6406 * This list was updated as part of service ready event. Re-populate
6407 * HW mode list from the device capabilities.
6408 */
6409 if (wma_handle->hw_mode.hw_mode_list) {
6410 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
6411 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006412 WMA_LOGD("%s: DBS list is freed", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306413 }
6414
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306415 wma_handle->hw_mode.hw_mode_list =
6416 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306417 num_hw_modes);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306418 if (!wma_handle->hw_mode.hw_mode_list) {
6419 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
6420 return QDF_STATUS_E_FAILURE;
6421 }
6422
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08006423 WMA_LOGD("%s: Updated HW mode list: Num modes:%d",
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306424 __func__, num_hw_modes);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306425
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306426 for (i = 0; i < num_hw_modes; i++) {
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306427 /* Update for MAC0 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306428 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306429 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306430 hw_config_type = mac_phy_cap[j].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306431 dbs_mode = HW_MODE_DBS_NONE;
6432 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306433 mac1_ss_bw_info.mac_tx_stream = 0;
6434 mac1_ss_bw_info.mac_rx_stream = 0;
6435 mac1_ss_bw_info.mac_bw = 0;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306436 if (wma_update_supported_bands(tmp->supported_bands,
6437 &new_supported_band)
6438 != QDF_STATUS_SUCCESS)
Krunal Sonica50b452017-08-04 22:24:59 -07006439 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306440
6441 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
6442 if ((hw_config_type == WMI_HW_MODE_DBS) ||
6443 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6444 (hw_config_type == WMI_HW_MODE_SBS)) {
6445 /* Update for MAC1 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306446 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306447 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306448 if (hw_config_type == WMI_HW_MODE_DBS)
6449 dbs_mode = HW_MODE_DBS;
6450 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6451 (hw_config_type == WMI_HW_MODE_SBS))
6452 sbs_mode = HW_MODE_SBS;
Krunal Sonica50b452017-08-04 22:24:59 -07006453 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306454 wma_update_supported_bands(tmp->supported_bands,
Krunal Sonica50b452017-08-04 22:24:59 -07006455 &new_supported_band))
6456 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306457 }
6458
6459 /* Updating HW mode list */
6460 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306461 mac1_ss_bw_info, i, dbs_mode,
6462 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306463 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006464
Krunal Sonica50b452017-08-04 22:24:59 -07006465 /* overwrite phy_capability which we got from service ready event */
6466 if (!supported_band_update_failure) {
6467 WMA_LOGD("%s: updating supported band from old[%d] to new[%d]",
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306468 __func__, target_if_get_phy_capability(tgt_hdl),
Krunal Sonica50b452017-08-04 22:24:59 -07006469 new_supported_band);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306470 target_if_set_phy_capability(tgt_hdl, new_supported_band);
Krunal Sonica50b452017-08-04 22:24:59 -07006471 }
6472
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006473 if (QDF_STATUS_SUCCESS !=
Krunal Sonica50b452017-08-04 22:24:59 -07006474 policy_mgr_update_hw_mode_list(wma_handle->psoc,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306475 tgt_hdl))
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006476 WMA_LOGE("%s: failed to update policy manager", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306477 wma_dump_dbs_hw_mode(wma_handle);
6478 return QDF_STATUS_SUCCESS;
6479}
6480
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006481static void wma_init_wifi_pos_dma_rings(t_wma_handle *wma_handle,
6482 uint8_t num_mac, void *buf)
6483{
6484 struct hif_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006485 void *hal_soc;
6486
6487 if (!hif_ctx) {
6488 WMA_LOGE("invalid hif context");
6489 return;
6490 }
6491
6492 hal_soc = hif_get_hal_handle(hif_ctx);
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006493
6494 wifi_pos_init_cir_cfr_rings(wma_handle->psoc, hal_soc, num_mac, buf);
6495}
6496
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306497/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006498 * wma_populate_soc_caps() - populate entire SOC's capabilities
6499 * @wma_handle: pointer to wma global structure
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306500 * @tgt_hdl: target psoc information
Krunal Soni2e48d012016-05-02 16:55:26 -07006501 * @param_buf: pointer to param of service ready extension event from fw
6502 *
6503 * This API populates all capabilities of entire SOC. For example,
6504 * how many number of hw modes are supported by this SOC, what are the
6505 * capabilities of each phy per hw mode, what are HAL reg capabilities per
6506 * phy.
6507 *
6508 * Return: none
6509 */
6510static void wma_populate_soc_caps(t_wma_handle *wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306511 struct target_psoc_info *tgt_hdl,
Krunal Soni2e48d012016-05-02 16:55:26 -07006512 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
6513{
Krunal Soni2e48d012016-05-02 16:55:26 -07006514
6515 WMA_LOGD("%s: Enter", __func__);
6516
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006517 wma_init_wifi_pos_dma_rings(wma_handle,
6518 param_buf->num_oem_dma_ring_caps,
6519 param_buf->oem_dma_ring_caps);
6520
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306521 wma_print_populate_soc_caps(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006522}
6523
6524/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006525 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
6526 * @handle: wma handle
6527 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05306528 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006529 *
6530 * Return: none
6531 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306532int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
6533 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006534{
6535 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6536 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
6537 wmi_service_ready_ext_event_fixed_param *ev;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306538 QDF_STATUS ret;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306539 struct target_psoc_info *tgt_hdl;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306540 uint32_t conc_scan_config_bits, fw_config_bits;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306541
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006542 WMA_LOGD("%s: Enter", __func__);
6543
6544 if (!wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006545 WMA_LOGE("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306546 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006547 }
6548
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306549 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6550 if (!tgt_hdl) {
6551 WMA_LOGE("%s: target psoc info is NULL", __func__);
6552 return -EINVAL;
6553 }
6554
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006555 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
6556 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006557 WMA_LOGE("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306558 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006559 }
6560
6561 ev = param_buf->fixed_param;
6562 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006563 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306564 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565 }
6566
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006567 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006568
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306569 fw_config_bits = target_if_get_fw_config_bits(tgt_hdl);
6570 conc_scan_config_bits = target_if_get_conc_scan_config_bits(tgt_hdl);
6571
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006572 WMA_LOGD("%s: Defaults: scan config:%x FW mode config:%x",
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306573 __func__, conc_scan_config_bits, fw_config_bits);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05306574
Anurag Chouhan210db072016-02-22 18:42:15 +05306575 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05306576 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006577 WMA_LOGE("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05306578 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006579 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306580 wma_populate_soc_caps(wma_handle, tgt_hdl, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006581
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306582 ret = wma_update_hw_mode_list(wma_handle, tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306583 if (QDF_IS_STATUS_ERROR(ret)) {
6584 WMA_LOGE("Failed to update hw mode list");
6585 return -EINVAL;
6586 }
6587
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006588 WMA_LOGD("WMA --> WMI_INIT_CMDID");
Mukul Sharmab10c8c72017-11-02 17:25:59 +05306589
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306590 wma_init_scan_fw_mode_config(wma_handle->psoc, conc_scan_config_bits,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306591 fw_config_bits);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306592
6593 target_psoc_set_num_radios(tgt_hdl, 1);
Govind Singhd76a5b02016-03-08 15:12:14 +05306594 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006595}
6596
6597/**
6598 * wma_rx_ready_event() - event handler to process
6599 * wmi rx ready event.
6600 * @handle: wma handle
6601 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05306602 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006603 *
6604 * Return: none
6605 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306606int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
6607 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006608{
6609 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6610 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
6611 wmi_ready_event_fixed_param *ev = NULL;
6612
6613 WMA_LOGD("%s: Enter", __func__);
6614
6615 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
6616 if (!(wma_handle && param_buf)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006617 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306618 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05306619 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006620 }
6621
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006622 WMA_LOGD("WMA <-- WMI_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006623
6624 ev = param_buf->fixed_param;
6625 /* Indicate to the waiting thread that the ready
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006626 * event was received
6627 */
Naveen Rawat64e477e2016-05-20 10:34:56 -07006628 wma_handle->sub_20_support =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306629 wmi_service_enabled(wma_handle->wmi_handle,
6630 wmi_service_half_rate_quarter_rate_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006631 wma_handle->wmi_ready = true;
6632 wma_handle->wlan_init_status = ev->status;
6633
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006634 /* copy the mac addr */
6635 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
6636 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006637 wma_update_hdd_cfg(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006638 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05306639
6640 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006641}
6642
6643/**
6644 * wma_setneedshutdown() - setting wma needshutdown flag
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006645 *
6646 * Return: none
6647 */
Jeff Johnson1f8d0a02017-09-13 08:09:05 -07006648void wma_setneedshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006649{
6650 tp_wma_handle wma_handle;
6651
6652 WMA_LOGD("%s: Enter", __func__);
6653
Anurag Chouhan6d760662016-02-20 16:05:43 +05306654 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006655
6656 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006657 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306658 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006659 return;
6660 }
6661
6662 wma_handle->needShutdown = true;
6663 WMA_LOGD("%s: Exit", __func__);
6664}
6665
6666/**
6667 * wma_needshutdown() - Is wma needs shutdown?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006668 *
6669 * Return: returns true/false
6670 */
Jeff Johnson1b5404e2017-09-13 08:04:46 -07006671bool wma_needshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006672{
6673 tp_wma_handle wma_handle;
6674
6675 WMA_LOGD("%s: Enter", __func__);
6676
Anurag Chouhan6d760662016-02-20 16:05:43 +05306677 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006678
6679 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006680 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306681 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006682 return false;
6683 }
6684
6685 WMA_LOGD("%s: Exit", __func__);
6686 return wma_handle->needShutdown;
6687}
6688
6689/**
6690 * wma_wait_for_ready_event() - wait for wma ready event
6691 * @handle: wma handle
6692 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306693 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006694 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306695QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006696{
6697 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306698 QDF_STATUS qdf_status;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306699 struct target_psoc_info *tgt_hdl;
6700 int timeleft;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006701
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306702 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6703 if (!tgt_hdl) {
6704 WMA_LOGE("%s: target psoc info is NULL", __func__);
6705 return QDF_STATUS_E_INVAL;
6706 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006707
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306708 timeleft = qdf_wait_queue_timeout(
6709 tgt_hdl->info.event_queue,
6710 ((tgt_hdl->info.wmi_service_ready) &&
6711 (tgt_hdl->info.wmi_ready)),
6712 WMA_READY_EVENTID_TIMEOUT);
6713 if (!timeleft) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006714 WMA_LOGE("%s: Timeout waiting for ready event from FW",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006715 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306716 qdf_status = QDF_STATUS_E_FAILURE;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306717 } else {
6718 WMA_LOGI("%s Ready event received from FW", __func__);
6719 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006720 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306721
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306722 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006723}
6724
6725/**
6726 * wma_set_ppsconfig() - set pps config in fw
6727 * @vdev_id: vdev id
6728 * @pps_param: pps params
6729 * @val : param value
6730 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306731 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006732 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306733QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006734 int val)
6735{
Anurag Chouhan6d760662016-02-20 16:05:43 +05306736 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006737 int ret = -EIO;
6738 uint32_t pps_val;
6739
6740 if (NULL == wma) {
6741 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306742 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006743 }
6744
6745 switch (pps_param) {
6746 case WMA_VHT_PPS_PAID_MATCH:
6747 pps_val = ((val << 31) & 0xffff0000) |
6748 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
6749 goto pkt_pwr_save_config;
6750 case WMA_VHT_PPS_GID_MATCH:
6751 pps_val = ((val << 31) & 0xffff0000) |
6752 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
6753 goto pkt_pwr_save_config;
6754 case WMA_VHT_PPS_DELIM_CRC_FAIL:
6755 pps_val = ((val << 31) & 0xffff0000) |
6756 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
6757 goto pkt_pwr_save_config;
6758
6759 /* Enable the code below as and when the functionality
6760 * is supported/added in host.
6761 */
6762#ifdef NOT_YET
6763 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
6764 pps_val = ((val << 31) & 0xffff0000) |
6765 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
6766 goto pkt_pwr_save_config;
6767 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
6768 pps_val = ((val << 31) & 0xffff0000) |
6769 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
6770 goto pkt_pwr_save_config;
6771 case WMA_VHT_PPS_EOF_PAD_DELIM:
6772 pps_val = ((val << 31) & 0xffff0000) |
6773 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
6774 goto pkt_pwr_save_config;
6775 case WMA_VHT_PPS_MACADDR_MISMATCH:
6776 pps_val = ((val << 31) & 0xffff0000) |
6777 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
6778 goto pkt_pwr_save_config;
6779 case WMA_VHT_PPS_GID_NSTS_ZERO:
6780 pps_val = ((val << 31) & 0xffff0000) |
6781 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
6782 goto pkt_pwr_save_config;
6783 case WMA_VHT_PPS_RSSI_CHECK:
6784 pps_val = ((val << 31) & 0xffff0000) |
6785 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
6786 goto pkt_pwr_save_config;
6787#endif /* NOT_YET */
6788pkt_pwr_save_config:
6789 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
6790 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05306791 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006792 WMI_VDEV_PARAM_PACKET_POWERSAVE,
6793 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794 break;
6795 default:
6796 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
6797 }
6798
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306799 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006800}
6801
6802/**
6803 * wma_process_set_mas() - Function to enable/disable MAS
6804 * @wma: Pointer to WMA handle
6805 * @mas_val: 1-Enable MAS, 0-Disable MAS
6806 *
6807 * This function enables/disables the MAS value
6808 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306809 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006810 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006811static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
6812 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006813{
6814 uint32_t val;
6815
6816 if (NULL == wma || NULL == mas_val) {
6817 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306818 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006819 }
6820
6821 val = (*mas_val);
6822
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306823 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006824 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
6825 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306826 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006827 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006828 WMA_LOGE("%s: Value is %d", __func__, val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306829 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006830}
6831
6832/**
6833 * wma_process_set_miracast() - Function to set miracast value in WMA
6834 * @wma: Pointer to WMA handle
6835 * @miracast_val: 0-Disabled,1-Source,2-Sink
6836 *
6837 * This function stores the miracast value in WMA
6838 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306839 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006840 *
6841 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006842static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
6843 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006844{
6845 if (NULL == wma || NULL == miracast_val) {
6846 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306847 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006848 }
6849
6850 wma->miracast_value = *miracast_val;
6851 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
6852
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306853 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006854}
6855
6856/**
6857 * wma_config_stats_factor() - Function to configure stats avg. factor
6858 * @wma: pointer to WMA handle
6859 * @avg_factor: stats. avg. factor passed down by userspace
6860 *
6861 * This function configures the avg. stats value in firmware
6862 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306863 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006864 *
6865 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306866static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006867 struct sir_stats_avg_factor *avg_factor)
6868{
Govind Singhd76a5b02016-03-08 15:12:14 +05306869 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006870
6871 if (NULL == wma || NULL == avg_factor) {
6872 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306873 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006874 }
6875
Govind Singhd76a5b02016-03-08 15:12:14 +05306876 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006877 avg_factor->vdev_id,
6878 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
6879 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05306880 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006881 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
6882 avg_factor->vdev_id);
6883 }
6884
6885 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
6886 avg_factor->stats_avg_factor, avg_factor->vdev_id);
6887
6888 return ret;
6889}
6890
6891/**
6892 * wma_config_guard_time() - Function to set guard time in firmware
6893 * @wma: pointer to WMA handle
6894 * @guard_time: guard time passed down by userspace
6895 *
6896 * This function configures the guard time in firmware
6897 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306898 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899 *
6900 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306901static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006902 struct sir_guard_time_request *guard_time)
6903{
Govind Singhd76a5b02016-03-08 15:12:14 +05306904 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006905
6906 if (NULL == wma || NULL == guard_time) {
6907 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306908 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006909 }
6910
Govind Singhd76a5b02016-03-08 15:12:14 +05306911 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006912 guard_time->vdev_id,
6913 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
6914 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05306915 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006916 WMA_LOGE(" failed to set guard time for vdev_id %d",
6917 guard_time->vdev_id);
6918 }
6919
6920 WMA_LOGD("Set guard time %d for vdev_id %d",
6921 guard_time->guard_time, guard_time->vdev_id);
6922
6923 return ret;
6924}
6925
6926/**
6927 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
6928 * @wma_handle: WMA handle
6929 * @start_log: Start logging related parameters
6930 *
6931 * Send the command to the FW based on which specific logging of diag
6932 * event/log id can be started/stopped
6933 *
6934 * Return: None
6935 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006936static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
6937 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006938{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006939
6940 if (!start_log) {
6941 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6942 return;
6943 }
6944 if (!wma_handle) {
6945 WMA_LOGE("%s: Invalid wma handle", __func__);
6946 return;
6947 }
6948
6949 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
6950 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
6951 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
6952 __func__, start_log->ring_id);
6953 return;
6954 }
6955
Govind Singhf25a0f12016-03-08 16:09:48 +05306956 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
6957 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006958}
6959
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306960#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006961/**
6962 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
6963 * @wma_handle: WMA handle
6964 * @start_log: Struture containing the start wifi logger params
6965 *
6966 * This function is used to send the WMA commands to start/stop logging
6967 * of per packet statistics
6968 *
6969 * Return: None
6970 *
6971 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006972#ifdef REMOVE_PKT_LOG
6973static void wma_set_wifi_start_packet_stats(void *wma_handle,
6974 struct sir_wifi_start_log *start_log)
6975{
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006976}
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07006977
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006978#else
6979static void wma_set_wifi_start_packet_stats(void *wma_handle,
6980 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006981{
Komal Seelam3d202862016-02-24 18:43:24 +05306982 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006983 uint32_t log_state;
6984
6985 if (!start_log) {
6986 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6987 return;
6988 }
6989 if (!wma_handle) {
6990 WMA_LOGE("%s: Invalid wma handle", __func__);
6991 return;
6992 }
6993
6994 /* No need to register for ring IDs other than packet stats */
6995 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006996 WMA_LOGD("%s: Ring id is not for per packet stats: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006997 __func__, start_log->ring_id);
6998 return;
6999 }
7000
Anurag Chouhan6d760662016-02-20 16:05:43 +05307001 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07007002 if (scn == NULL) {
7003 WMA_LOGE("%s: Invalid HIF handle", __func__);
7004 return;
7005 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007006
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007007#ifdef HELIUMPLUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007008 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05307009 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
Venkata Sharath Chandra Manchala29965172018-01-18 14:17:29 -08007010 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007011#else
7012 log_state = ATH_PKTLOG_LITE_T2H | ATH_PKTLOG_LITE_RX;
7013#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05307014 if (start_log->size != 0) {
7015 pktlog_setsize(scn, start_log->size * MEGABYTE);
7016 return;
Poddar, Siddarthab99a272017-04-10 12:53:26 +05307017 } else if (start_log->is_pktlog_buff_clear == true) {
7018 pktlog_clearbuff(scn, start_log->is_pktlog_buff_clear);
7019 return;
Poddar, Siddarth176c4362016-10-03 12:25:00 +05307020 }
7021
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007022 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08007023 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05307024 start_log->user_triggered,
7025 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007026 WMA_LOGD("%s: Enabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007027 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08007028 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05307029 start_log->user_triggered,
7030 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007031 WMA_LOGD("%s: Disabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007032 }
7033}
7034#endif
7035
7036/**
7037 * wma_send_flush_logs_to_fw() - Send log flush command to FW
7038 * @wma_handle: WMI handle
7039 *
7040 * This function is used to send the flush command to the FW,
7041 * that will flush the fw logs that are residue in the FW
7042 *
7043 * Return: None
7044 */
7045void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
7046{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307047 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007048 int ret;
7049
Govind Singhf25a0f12016-03-08 16:09:48 +05307050 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
7051 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007052 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007053
Anurag Chouhan210db072016-02-22 18:42:15 +05307054 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007055 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307056 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007057 WMA_LOGE("Failed to start the log completion timer");
7058}
7059
7060/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307061 * wma_update_wep_default_key - To update default key id
7062 * @wma: pointer to wma handler
7063 * @update_def_key: pointer to wep_update_default_key_idx
7064 *
7065 * This function makes a copy of default key index to txrx node
7066 *
7067 * Return: Success
7068 */
7069static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
7070 struct wep_update_default_key_idx *update_def_key)
7071{
7072 struct wma_txrx_node *iface =
7073 &wma->interfaces[update_def_key->session_id];
7074 iface->wep_default_key_idx = update_def_key->default_idx;
7075
7076 return QDF_STATUS_SUCCESS;
7077}
7078
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307079/**
7080 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
7081 * @wma_handle: WMA handle
7082 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
7083 *
7084 * This function is used to set Tx pkt fail count threshold,
7085 * FW will do disconnect with station once this threshold is reached.
7086 *
7087 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7088 */
7089static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007090 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307091{
7092 u_int8_t vdev_id;
7093 u_int32_t tx_fail_disconn_th;
7094 int ret = -EIO;
7095
7096 if (!wma || !wma->wmi_handle) {
7097 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
7098 return QDF_STATUS_E_INVAL;
7099 }
7100 vdev_id = tx_fail_cnt_th->session_id;
7101 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
7102 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7103 vdev_id, tx_fail_disconn_th);
7104
7105
7106 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7107 WMI_VDEV_PARAM_DISCONNECT_TH,
7108 tx_fail_disconn_th);
7109
7110 if (ret) {
7111 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
7112 return QDF_STATUS_E_FAILURE;
7113 }
7114
7115 return QDF_STATUS_SUCCESS;
7116}
7117
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307118/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307119 * wma_update_short_retry_limit() - Set retry limit for short frames
7120 * @wma_handle: WMA handle
7121 * @short_retry_limit_th: retry limir count for Short frames.
7122 *
7123 * This function is used to configure the transmission retry limit at which
7124 * short frames needs to be retry.
7125 *
7126 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7127 */
7128static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
7129 struct sme_short_retry_limit *short_retry_limit_th)
7130{
7131 uint8_t vdev_id;
7132 uint32_t short_retry_limit;
7133 int ret;
7134
7135 if (!wma || !wma->wmi_handle) {
7136 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
7137 return QDF_STATUS_E_INVAL;
7138 }
7139 vdev_id = short_retry_limit_th->session_id;
7140 short_retry_limit = short_retry_limit_th->short_retry_limit;
7141 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
7142 vdev_id, short_retry_limit);
7143
7144 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7145 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
7146 short_retry_limit);
7147
7148 if (ret) {
7149 WMA_LOGE("Failed to send short limit threshold command");
7150 return QDF_STATUS_E_FAILURE;
7151 }
7152 return QDF_STATUS_SUCCESS;
7153}
7154
7155/**
7156 * wma_update_long_retry_limit() - Set retry limit for long frames
7157 * @wma_handle: WMA handle
7158 * @long_retry_limit_th: retry limir count for long frames
7159 *
7160 * This function is used to configure the transmission retry limit at which
7161 * long frames needs to be retry
7162 *
7163 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7164 */
7165static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
7166 struct sme_long_retry_limit *long_retry_limit_th)
7167{
7168 uint8_t vdev_id;
7169 uint32_t long_retry_limit;
7170 int ret;
7171
7172 if (!wma || !wma->wmi_handle) {
7173 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
7174 return QDF_STATUS_E_INVAL;
7175 }
7176 vdev_id = long_retry_limit_th->session_id;
7177 long_retry_limit = long_retry_limit_th->long_retry_limit;
7178 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7179 vdev_id, long_retry_limit);
7180
7181 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7182 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
7183 long_retry_limit);
7184
7185 if (ret) {
7186 WMA_LOGE("Failed to send long limit threshold command");
7187 return QDF_STATUS_E_FAILURE;
7188 }
7189
7190 return QDF_STATUS_SUCCESS;
7191}
7192
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05307193/*
7194 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
7195 * @wma_handle: WMA handle
7196 * @sta_inactivity_timer: sme_sta_inactivity_timeout
7197 *
7198 * This function is used to set sta_inactivity_timeout.
7199 * If a station does not send anything in sta_inactivity_timeout seconds, an
7200 * empty data frame is sent to it in order to verify whether it is
7201 * still in range. If this frame is not ACKed, the station will be
7202 * disassociated and then deauthenticated.
7203 *
7204 * Return: None
7205 */
7206void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
7207 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
7208{
7209 uint8_t vdev_id;
7210 uint32_t max_unresponsive_time;
7211 uint32_t min_inactive_time, max_inactive_time;
7212
7213 if (!wma || !wma->wmi_handle) {
7214 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
7215 return;
7216 }
7217 vdev_id = sta_inactivity_timer->session_id;
7218 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
7219 max_inactive_time = max_unresponsive_time * TWO_THIRD;
7220 min_inactive_time = max_unresponsive_time - max_inactive_time;
7221
7222 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7223 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
7224 min_inactive_time))
7225 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
7226
7227 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7228 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
7229 max_inactive_time))
7230 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
7231
7232 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7233 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
7234 max_unresponsive_time))
7235 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
7236
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007237 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 +05307238 __func__, vdev_id,
7239 min_inactive_time, max_inactive_time,
7240 max_unresponsive_time);
7241}
7242
Yingying Tang95409972016-10-20 15:16:15 +08007243#ifdef WLAN_FEATURE_WOW_PULSE
7244
7245
7246#define WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7247WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMD_fixed_param
7248
7249
7250#define WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7251WMITLV_TAG_STRUC_wmi_wow_hostwakeup_gpio_pin_pattern_config_cmd_fixed_param
7252
7253/**
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007254 * wma_send_wow_pulse_cmd() - send wmi cmd of wow pulse cmd
7255 * information to fw.
7256 * @wma_handle: wma handler
7257 * @udp_response: wow_pulse_mode pointer
7258 *
7259 * Return: Return QDF_STATUS
7260 */
Yingying Tang95409972016-10-20 15:16:15 +08007261static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7262 struct wow_pulse_mode *wow_pulse_cmd)
7263{
7264 QDF_STATUS status = QDF_STATUS_SUCCESS;
7265 wmi_buf_t buf;
7266 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *cmd;
7267 u_int16_t len;
7268
7269 len = sizeof(*cmd);
7270 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7271 if (!buf) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007272 WMA_LOGE("wmi_buf_alloc failed");
7273 return QDF_STATUS_E_NOMEM;
Yingying Tang95409972016-10-20 15:16:15 +08007274 }
7275
7276 cmd = (WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *)wmi_buf_data(buf);
7277 qdf_mem_zero(cmd, len);
7278
7279 WMITLV_SET_HDR(&cmd->tlv_header,
7280 WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM,
7281 WMITLV_GET_STRUCT_TLVLEN(
7282 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM));
7283
7284 cmd->enable = wow_pulse_cmd->wow_pulse_enable;
7285 cmd->pin = wow_pulse_cmd->wow_pulse_pin;
7286 cmd->interval_low = wow_pulse_cmd->wow_pulse_interval_low;
7287 cmd->interval_high = wow_pulse_cmd->wow_pulse_interval_high;
7288 cmd->repeat_cnt = WMI_WOW_PULSE_REPEAT_CNT;
7289
7290 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7291 WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID)) {
7292 WMA_LOGE("Failed to send send wow pulse");
7293 wmi_buf_free(buf);
7294 status = QDF_STATUS_E_FAILURE;
7295 }
7296
7297 WMA_LOGD("%s: Exit", __func__);
7298 return status;
7299}
7300
7301#undef WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7302#undef WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7303#undef WMI_WOW_PULSE_REPEAT_CNT
7304
7305#else
7306static inline QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7307 struct wow_pulse_mode *wow_pulse_cmd)
7308{
7309 return QDF_STATUS_E_FAILURE;
7310}
7311#endif
7312
7313
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307314/**
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307315 * wma_process_power_debug_stats_req() - Process the Chip Power stats collect
7316 * request and pass the Power stats request to Fw
7317 * @wma_handle: WMA handle
7318 *
7319 * Return: QDF_STATUS
7320 */
7321#ifdef WLAN_POWER_DEBUGFS
7322static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7323{
7324 wmi_pdev_get_chip_power_stats_cmd_fixed_param *cmd;
7325 int32_t len;
7326 wmi_buf_t buf;
7327 uint8_t *buf_ptr;
7328 int ret;
7329
7330 if (!wma_handle) {
7331 WMA_LOGE("%s: input pointer is NULL", __func__);
7332 return QDF_STATUS_E_FAILURE;
7333 }
7334
7335 len = sizeof(*cmd);
7336 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7337 if (!buf) {
7338 WMA_LOGE("%s: Failed allocate wmi buffer", __func__);
7339 return QDF_STATUS_E_NOMEM;
7340 }
7341
7342 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7343 cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr;
7344
7345 WMITLV_SET_HDR(&cmd->tlv_header,
7346 WMITLV_TAG_STRUC_wmi_get_chip_power_stats_cmd_fixed_param,
7347 WMITLV_GET_STRUCT_TLVLEN(
7348 wmi_pdev_get_chip_power_stats_cmd_fixed_param));
7349 cmd->pdev_id = 0;
7350
7351 WMA_LOGD("POWER_DEBUG_STATS - Get Request Params; Pdev id - %d",
7352 cmd->pdev_id);
7353 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7354 WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
7355 if (ret) {
7356 WMA_LOGE("%s: Failed to send power debug stats request",
7357 __func__);
7358 wmi_buf_free(buf);
7359 return QDF_STATUS_E_FAILURE;
7360 }
7361 return QDF_STATUS_SUCCESS;
7362}
7363#else
7364static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7365{
7366 return QDF_STATUS_SUCCESS;
7367}
7368#endif
7369
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307370/**
7371 * wma_set_arp_req_stats() - process set arp stats request command to fw
7372 * @wma_handle: WMA handle
7373 * @req_buf: set srp stats request buffer
7374 *
7375 * Return: None
7376 */
7377static void wma_set_arp_req_stats(WMA_HANDLE handle,
7378 struct set_arp_stats_params *req_buf)
7379{
7380 int status;
7381 struct set_arp_stats *arp_stats;
7382 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7383
7384 if (!wma_handle || !wma_handle->wmi_handle) {
7385 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7386 __func__);
7387 return;
7388 }
Yeshwanth Sriram Guntukad5aae7f2017-11-27 14:33:51 +05307389 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7390 WMA_LOGE("vdev id not active or not valid");
7391 return;
7392 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307393
7394 arp_stats = (struct set_arp_stats *)req_buf;
7395 status = wmi_unified_set_arp_stats_req(wma_handle->wmi_handle,
7396 arp_stats);
7397 if (status != EOK)
7398 WMA_LOGE("%s: failed to set arp stats to FW",
7399 __func__);
7400}
7401
7402/**
7403 * wma_get_arp_req_stats() - process get arp stats request command to fw
7404 * @wma_handle: WMA handle
7405 * @req_buf: get srp stats request buffer
7406 *
7407 * Return: None
7408 */
7409static void wma_get_arp_req_stats(WMA_HANDLE handle,
7410 struct get_arp_stats_params *req_buf)
7411{
7412 int status;
7413 struct get_arp_stats *arp_stats;
7414 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7415
7416 if (!wma_handle || !wma_handle->wmi_handle) {
7417 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7418 __func__);
7419 return;
7420 }
Yeshwanth Sriram Guntuka3e4d96f2017-12-19 14:09:04 +05307421 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7422 WMA_LOGE("vdev id not active or not valid");
7423 return;
7424 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307425
7426 arp_stats = (struct get_arp_stats *)req_buf;
7427 status = wmi_unified_get_arp_stats_req(wma_handle->wmi_handle,
7428 arp_stats);
7429 if (status != EOK)
7430 WMA_LOGE("%s: failed to send get arp stats to FW",
7431 __func__);
7432}
7433
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307434/**
7435 * wma_set_del_pmkid_cache() - API to set/delete PMKID cache entry in fw
7436 * @handle: WMA handle
7437 * @pmk_cache: PMK cache entry
7438 *
7439 * Return: None
7440 */
7441static void wma_set_del_pmkid_cache(WMA_HANDLE handle,
7442 struct wmi_unified_pmk_cache *pmk_cache)
7443{
7444 int status;
7445 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7446
7447 if (!wma_handle || !wma_handle->wmi_handle) {
7448 WMA_LOGE("WMA is closed, cannot send set del pmkid");
7449 return;
7450 }
7451
7452 status = wmi_unified_set_del_pmkid_cache(wma_handle->wmi_handle,
7453 pmk_cache);
7454 if (status != EOK)
7455 WMA_LOGE("failed to send set/del pmkid cmd to fw");
7456}
7457
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307458/**
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307459 * wma_send_invoke_neighbor_report() - API to send invoke neighbor report
7460 * command to fw
7461 *
7462 * @handle: WMA handle
7463 * @params: Pointer to invoke neighbor report params
7464 *
7465 * Return: None
7466 */
7467static
7468void wma_send_invoke_neighbor_report(WMA_HANDLE handle,
7469 struct wmi_invoke_neighbor_report_params *params)
7470{
7471 QDF_STATUS status;
7472 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7473
7474 if (!wma_handle || !wma_handle->wmi_handle) {
7475 WMA_LOGE("WMA is closed, cannot send invoke neighbor report");
7476 return;
7477 }
7478
7479 status = wmi_unified_invoke_neighbor_report_cmd(wma_handle->wmi_handle,
7480 params);
7481
7482 if (status != QDF_STATUS_SUCCESS)
7483 WMA_LOGE("failed to send invoke neighbor report command");
7484}
7485
lifeng66831662017-05-19 16:01:35 +08007486QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle,
7487 struct sir_set_rx_reorder_timeout_val *reorder_timeout)
7488{
7489 wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *cmd;
7490 uint32_t len;
7491 wmi_buf_t buf;
7492 int ret;
7493
7494 if (!reorder_timeout) {
7495 WMA_LOGE(FL("invalid pointer"));
7496 return QDF_STATUS_E_INVAL;
7497 }
7498
7499 if (!wma_handle) {
7500 WMA_LOGE(FL("WMA context is invald!"));
7501 return QDF_STATUS_E_INVAL;
7502 }
7503 len = sizeof(*cmd);
7504 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7505
7506 if (!buf) {
7507 WMA_LOGE(FL("Failed allocate wmi buffer"));
7508 return QDF_STATUS_E_NOMEM;
7509 }
7510 cmd = (wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *)
7511 wmi_buf_data(buf);
7512
7513 WMITLV_SET_HDR(&cmd->tlv_header,
7514 WMITLV_TAG_STRUC_wmi_pdev_set_reorder_timeout_val_cmd_fixed_param,
7515 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_reorder_timeout_val_cmd_fixed_param));
7516
7517 memcpy(cmd->rx_timeout_pri, reorder_timeout->rx_timeout_pri,
7518 sizeof(reorder_timeout->rx_timeout_pri));
7519
7520 WMA_LOGD("rx aggr record timeout: VO: %d, VI: %d, BE: %d, BK: %d",
7521 cmd->rx_timeout_pri[0], cmd->rx_timeout_pri[1],
7522 cmd->rx_timeout_pri[2], cmd->rx_timeout_pri[3]);
7523
7524 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7525 WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID);
7526 if (ret) {
7527 WMA_LOGE(FL("Failed to send aggregation timeout"));
7528 wmi_buf_free(buf);
7529 return QDF_STATUS_E_FAILURE;
7530 }
7531
7532 return QDF_STATUS_SUCCESS;
7533}
7534
7535QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle,
7536 struct sir_peer_set_rx_blocksize *peer_rx_blocksize)
7537{
7538 wmi_peer_set_rx_blocksize_cmd_fixed_param *cmd;
7539 int32_t len;
7540 wmi_buf_t buf;
7541 u_int8_t *buf_ptr;
7542 int ret;
7543
7544 if (!peer_rx_blocksize) {
7545 WMA_LOGE(FL("invalid pointer"));
7546 return QDF_STATUS_E_INVAL;
7547 }
7548
7549 if (!wma_handle) {
7550 WMA_LOGE(FL(" WMA context is invald!"));
7551 return QDF_STATUS_E_INVAL;
7552 }
7553
7554 len = sizeof(*cmd);
7555 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7556
7557 if (!buf) {
7558 WMA_LOGE(FL("Failed allocate wmi buffer"));
7559 return QDF_STATUS_E_NOMEM;
7560 }
7561
7562 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7563 cmd = (wmi_peer_set_rx_blocksize_cmd_fixed_param *) buf_ptr;
7564
7565 WMITLV_SET_HDR(&cmd->tlv_header,
7566 WMITLV_TAG_STRUC_wmi_peer_set_rx_blocksize_cmd_fixed_param,
7567 WMITLV_GET_STRUCT_TLVLEN(wmi_peer_set_rx_blocksize_cmd_fixed_param));
7568
7569 cmd->vdev_id = peer_rx_blocksize->vdev_id;
7570 cmd->rx_block_ack_win_limit =
7571 peer_rx_blocksize->rx_block_ack_win_limit;
7572 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_rx_blocksize->peer_macaddr.bytes,
7573 &cmd->peer_macaddr);
7574
7575 WMA_LOGD("rx aggr blocksize: %d", cmd->rx_block_ack_win_limit);
7576
7577 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7578 WMI_PEER_SET_RX_BLOCKSIZE_CMDID);
7579 if (ret) {
7580 WMA_LOGE(FL("Failed to send aggregation size command"));
7581 wmi_buf_free(buf);
7582 return QDF_STATUS_E_FAILURE;
7583 }
7584
7585 return QDF_STATUS_SUCCESS;
7586}
7587
lifengd217d192017-05-09 19:44:16 +08007588QDF_STATUS wma_get_chain_rssi(tp_wma_handle wma_handle,
7589 struct get_chain_rssi_req_params *req_params)
7590{
lifengfe6c3e22018-04-03 12:10:04 +08007591 wmi_pdev_div_get_rssi_antid_fixed_param *cmd;
lifengd217d192017-05-09 19:44:16 +08007592 wmi_buf_t wmi_buf;
lifengfe6c3e22018-04-03 12:10:04 +08007593 uint32_t len = sizeof(wmi_pdev_div_get_rssi_antid_fixed_param);
lifengd217d192017-05-09 19:44:16 +08007594 u_int8_t *buf_ptr;
7595
7596 if (!wma_handle) {
7597 WMA_LOGE(FL("WMA is closed, can not issue cmd"));
7598 return QDF_STATUS_E_INVAL;
7599 }
7600
7601 wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7602 if (!wmi_buf) {
7603 WMA_LOGE(FL("wmi_buf_alloc failed"));
7604 return QDF_STATUS_E_NOMEM;
7605 }
7606
7607 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7608
lifengfe6c3e22018-04-03 12:10:04 +08007609 cmd = (wmi_pdev_div_get_rssi_antid_fixed_param *)buf_ptr;
lifengd217d192017-05-09 19:44:16 +08007610 WMITLV_SET_HDR(&cmd->tlv_header,
lifengfe6c3e22018-04-03 12:10:04 +08007611 WMITLV_TAG_STRUC_wmi_pdev_div_get_rssi_antid_fixed_param,
lifengd217d192017-05-09 19:44:16 +08007612 WMITLV_GET_STRUCT_TLVLEN(
lifengfe6c3e22018-04-03 12:10:04 +08007613 wmi_pdev_div_get_rssi_antid_fixed_param));
7614 cmd->pdev_id = 0;
lifengd217d192017-05-09 19:44:16 +08007615 WMI_CHAR_ARRAY_TO_MAC_ADDR(req_params->peer_macaddr.bytes,
lifengfe6c3e22018-04-03 12:10:04 +08007616 &cmd->macaddr);
lifengd217d192017-05-09 19:44:16 +08007617
7618 if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len,
lifengfe6c3e22018-04-03 12:10:04 +08007619 WMI_PDEV_DIV_GET_RSSI_ANTID_CMDID)) {
lifengd217d192017-05-09 19:44:16 +08007620 WMA_LOGE(FL("failed to send get chain rssi command"));
7621 wmi_buf_free(wmi_buf);
7622 return QDF_STATUS_E_FAILURE;
7623 }
7624
7625 return QDF_STATUS_SUCCESS;
7626}
7627
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307628#if defined(WLAN_FEATURE_FILS_SK)
7629/**
7630 * wma_roam_scan_send_hlp() - API to send HLP IE info to fw
7631 * @wma_handle: WMA handle
7632 * @req: HLP params
7633 *
7634 * Return: QDF_STATUS
7635 */
7636static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7637 struct hlp_params *req)
7638{
7639 struct hlp_params *params;
7640 QDF_STATUS status;
7641
7642 params = qdf_mem_malloc(sizeof(*params));
7643 if (!params) {
7644 WMA_LOGE("%s : Memory allocation failed", __func__);
7645 return QDF_STATUS_E_NOMEM;
7646 }
7647
7648 params->vdev_id = req->vdev_id;
7649 params->hlp_ie_len = req->hlp_ie_len;
7650 qdf_mem_copy(params->hlp_ie, req->hlp_ie, req->hlp_ie_len);
7651 status = wmi_unified_roam_send_hlp_cmd(wma_handle->wmi_handle, params);
7652
7653 WMA_LOGD("Send HLP status %d vdev id %d", status, params->vdev_id);
7654 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
7655 params->hlp_ie, 10);
7656
7657 qdf_mem_free(params);
7658 return status;
7659}
7660#else
7661static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7662 struct hlp_params *req)
7663{
7664 return QDF_STATUS_SUCCESS;
7665}
7666#endif
7667
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307668/**
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307669 * wma_process_set_limit_off_chan() - set limit off chanel parameters
7670 * @wma_handle: pointer to wma handle
7671 * @param: pointer to sir_limit_off_chan
7672 *
7673 * Return: QDF_STATUS_SUCCESS for success or error code.
7674 */
7675static QDF_STATUS wma_process_limit_off_chan(tp_wma_handle wma_handle,
7676 struct sir_limit_off_chan *param)
7677{
7678 int32_t err;
7679 struct wmi_limit_off_chan_param limit_off_chan_param;
7680
Rajeev Kumar752d64e2017-10-05 16:32:58 -07007681 if (param->vdev_id >= wma_handle->max_bssid) {
7682 WMA_LOGE(FL("Invalid vdev_id: %d"), param->vdev_id);
7683 return QDF_STATUS_E_INVAL;
7684 }
7685 if (!wma_is_vdev_up(param->vdev_id)) {
7686 WMA_LOGE("vdev %d is not up skipping limit_off_chan_param",
7687 param->vdev_id);
7688 return QDF_STATUS_E_INVAL;
7689 }
7690
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307691 limit_off_chan_param.vdev_id = param->vdev_id;
7692 limit_off_chan_param.status = param->is_tos_active;
7693 limit_off_chan_param.max_offchan_time = param->max_off_chan_time;
7694 limit_off_chan_param.rest_time = param->rest_time;
7695 limit_off_chan_param.skip_dfs_chans = param->skip_dfs_chans;
7696
7697 err = wmi_unified_send_limit_off_chan_cmd(wma_handle->wmi_handle,
7698 &limit_off_chan_param);
7699 if (err) {
7700 WMA_LOGE("\n failed to set limit off chan cmd");
7701 return QDF_STATUS_E_FAILURE;
7702 }
7703
7704 return QDF_STATUS_SUCCESS;
7705}
7706
Arif Hussain05fb4872018-01-03 16:02:55 -08007707static QDF_STATUS wma_process_obss_color_collision_req(tp_wma_handle wma_handle,
7708 struct wmi_obss_color_collision_cfg_param *cfg)
7709{
7710 QDF_STATUS status;
7711
7712 if (cfg->vdev_id >= wma_handle->max_bssid) {
7713 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7714 return QDF_STATUS_E_INVAL;
7715 }
7716 if (!wma_is_vdev_up(cfg->vdev_id)) {
7717 WMA_LOGE("vdev %d is not up skipping obss color collision req",
7718 cfg->vdev_id);
7719 return QDF_STATUS_E_INVAL;
7720 }
7721
7722 status = wmi_unified_send_obss_color_collision_cfg_cmd(wma_handle->
7723 wmi_handle, cfg);
7724 if (QDF_IS_STATUS_ERROR(status))
7725 WMA_LOGE("Failed to send obss color collision cfg");
7726
7727 return status;
7728}
7729
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307730/**
Arif Hussainee10f902017-12-27 16:30:17 -08007731 * wma_send_obss_detection_cfg() - send obss detection cfg to firmware
7732 * @wma_handle: pointer to wma handle
7733 * @cfg: obss detection configuration
7734 *
7735 * Send obss detection configuration to firmware.
7736 *
7737 * Return: None
7738 */
7739static void wma_send_obss_detection_cfg(tp_wma_handle wma_handle,
7740 struct wmi_obss_detection_cfg_param
7741 *cfg)
7742{
7743 QDF_STATUS status;
7744
7745 if (cfg->vdev_id >= wma_handle->max_bssid) {
7746 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7747 return;
7748 }
7749 if (!wma_is_vdev_up(cfg->vdev_id)) {
7750 WMA_LOGE("vdev %d is not up skipping obss detection req",
7751 cfg->vdev_id);
7752 return;
7753 }
7754
7755 status = wmi_unified_send_obss_detection_cfg_cmd(wma_handle->wmi_handle,
7756 cfg);
7757 if (QDF_IS_STATUS_ERROR(status))
7758 WMA_LOGE("Failed to send obss detection cfg");
7759
7760 return;
7761}
7762
7763/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007764 * wma_mc_process_msg() - process wma messages and call appropriate function.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007765 * @msg: message
7766 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307767 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007768 */
Jeff Johnson5be42ab2017-09-13 09:10:39 -07007769static QDF_STATUS wma_mc_process_msg(struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007770{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307771 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007772 tp_wma_handle wma_handle;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08007773 struct cdp_vdev *txrx_vdev_handle = NULL;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07007774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007775 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307776 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007778 if (NULL == msg) {
7779 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307780 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307781 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007782 goto end;
7783 }
7784
7785 WMA_LOGD("msg->type = %x %s", msg->type,
7786 mac_trace_get_wma_msg_string(msg->type));
7787
Anurag Chouhan6d760662016-02-20 16:05:43 +05307788 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007789
7790 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007791 WMA_LOGE("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307792 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307793 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307794 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007795 goto end;
7796 }
7797
7798 switch (msg->type) {
7799
7800 /* Message posted by wmi for all control path related
7801 * FW events to serialize through mc_thread.
7802 */
7803 case WMA_PROCESS_FW_EVENT:
7804 wma_process_fw_event(wma_handle,
7805 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307806 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007807 break;
7808
7809#ifdef FEATURE_WLAN_ESE
7810 case WMA_TSM_STATS_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007811 WMA_LOGD("McThread: WMA_TSM_STATS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007812 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
7813 break;
7814#endif /* FEATURE_WLAN_ESE */
7815 case WNI_CFG_DNLD_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007816 WMA_LOGD("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307817 qdf_status = wma_wni_cfg_dnld(wma_handle);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007818 if (QDF_IS_STATUS_SUCCESS(qdf_status))
Jeff Johnsonf7ab8142017-09-13 09:04:23 -07007819 cds_wma_complete_cback();
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007820 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007821 WMA_LOGD("config download failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007822 break;
7823 case WMA_ADD_STA_SELF_REQ:
7824 txrx_vdev_handle =
7825 wma_vdev_attach(wma_handle,
7826 (struct add_sta_self_params *) msg->
7827 bodyptr, 1);
7828 if (!txrx_vdev_handle) {
7829 WMA_LOGE("Failed to attach vdev");
7830 } else {
7831 /* Register with TxRx Module for Data Ack Complete Cb */
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307832 if (soc) {
7833 cdp_data_tx_cb_set(soc, txrx_vdev_handle,
7834 wma_data_tx_ack_comp_hdlr,
7835 wma_handle);
7836 } else {
7837 WMA_LOGE("%s: SOC context is NULL", __func__);
7838 qdf_status = QDF_STATUS_E_FAILURE;
7839 goto end;
7840 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007841 }
7842 break;
7843 case WMA_DEL_STA_SELF_REQ:
7844 wma_vdev_detach(wma_handle,
7845 (struct del_sta_self_params *) msg->bodyptr, 1);
7846 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007847 case WMA_UPDATE_CHAN_LIST_REQ:
7848 wma_update_channel_list(wma_handle,
7849 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307850 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007851 break;
7852 case WMA_SET_LINK_STATE:
7853 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
7854 break;
7855 case WMA_CHNL_SWITCH_REQ:
7856 wma_set_channel(wma_handle,
7857 (tpSwitchChannelParams) msg->bodyptr);
7858 break;
7859 case WMA_ADD_BSS_REQ:
7860 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
7861 break;
7862 case WMA_ADD_STA_REQ:
7863 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
7864 break;
7865 case WMA_SET_BSSKEY_REQ:
7866 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
7867 break;
7868 case WMA_SET_STAKEY_REQ:
7869 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
7870 break;
7871 case WMA_DELETE_STA_REQ:
7872 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
7873 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07007874 case WMA_DELETE_BSS_HO_FAIL_REQ:
7875 wma_delete_bss_ho_fail(wma_handle,
7876 (tpDeleteBssParams) msg->bodyptr);
7877 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007878 case WMA_DELETE_BSS_REQ:
7879 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
7880 break;
7881 case WMA_UPDATE_EDCA_PROFILE_IND:
7882 wma_process_update_edca_param_req(wma_handle,
7883 (tEdcaParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307884 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007885 break;
7886 case WMA_SEND_BEACON_REQ:
7887 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307888 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007889 break;
7890 case WMA_SEND_PROBE_RSP_TMPL:
7891 wma_send_probe_rsp_tmpl(wma_handle,
7892 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307893 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007894 break;
7895 case WMA_CLI_SET_CMD:
7896 wma_process_cli_set_cmd(wma_handle,
7897 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307898 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007899 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07007900 case WMA_SET_PDEV_IE_REQ:
7901 wma_process_set_pdev_ie_req(wma_handle,
7902 (struct set_ie_param *)msg->bodyptr);
7903 qdf_mem_free(msg->bodyptr);
7904 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007905#if !defined(REMOVE_PKT_LOG)
7906 case WMA_PKTLOG_ENABLE_REQ:
7907 wma_pktlog_wmi_send_cmd(wma_handle,
7908 (struct ath_pktlog_wmi_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307909 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007910 break;
7911#endif /* REMOVE_PKT_LOG */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007912 case WMA_ENTER_PS_REQ:
7913 wma_enable_sta_ps_mode(wma_handle,
7914 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307915 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007916 break;
7917 case WMA_EXIT_PS_REQ:
7918 wma_disable_sta_ps_mode(wma_handle,
7919 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307920 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007921 break;
7922 case WMA_ENABLE_UAPSD_REQ:
7923 wma_enable_uapsd_mode(wma_handle,
7924 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307925 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007926 break;
7927 case WMA_DISABLE_UAPSD_REQ:
7928 wma_disable_uapsd_mode(wma_handle,
7929 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307930 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007931 break;
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08007932 case WMA_SET_DTIM_PERIOD:
7933 wma_set_dtim_period(wma_handle,
7934 (struct set_dtim_params *)msg->bodyptr);
7935 qdf_mem_free(msg->bodyptr);
7936 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007937 case WMA_SET_TX_POWER_REQ:
7938 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
7939 break;
7940 case WMA_SET_MAX_TX_POWER_REQ:
7941 wma_set_max_tx_power(wma_handle,
7942 (tpMaxTxPowerParams) msg->bodyptr);
7943 break;
7944 case WMA_SET_KEEP_ALIVE:
7945 wma_set_keepalive_req(wma_handle,
7946 (tSirKeepAliveReq *) msg->bodyptr);
7947 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08007948#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007949 case WMA_SET_PLM_REQ:
7950 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
7951 break;
7952#endif
7953 case WMA_GET_STATISTICS_REQ:
7954 wma_get_stats_req(wma_handle,
7955 (tAniGetPEStatsReq *) msg->bodyptr);
7956 break;
7957
7958 case WMA_CONFIG_PARAM_UPDATE_REQ:
Rajeev Kumar156188e2017-01-21 17:23:52 -08007959 wma_update_cfg_params(wma_handle, msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007960 break;
7961
7962 case WMA_UPDATE_OP_MODE:
7963 wma_process_update_opmode(wma_handle,
7964 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307965 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007966 break;
7967 case WMA_UPDATE_RX_NSS:
7968 wma_process_update_rx_nss(wma_handle,
7969 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307970 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007971 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007972 case WMA_UPDATE_MEMBERSHIP:
7973 wma_process_update_membership(wma_handle,
7974 (tUpdateMembership *) msg->bodyptr);
7975 break;
7976 case WMA_UPDATE_USERPOS:
7977 wma_process_update_userpos(wma_handle,
7978 (tUpdateUserPos *) msg->bodyptr);
7979 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007980 case WMA_UPDATE_BEACON_IND:
7981 wma_process_update_beacon_params(wma_handle,
7982 (tUpdateBeaconParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307983 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007984 break;
7985
7986 case WMA_ADD_TS_REQ:
7987 wma_add_ts_req(wma_handle, (tAddTsParams *) msg->bodyptr);
7988 break;
7989
7990 case WMA_DEL_TS_REQ:
7991 wma_del_ts_req(wma_handle, (tDelTsParams *) msg->bodyptr);
7992 break;
7993
7994 case WMA_AGGR_QOS_REQ:
7995 wma_aggr_qos_req(wma_handle, (tAggrAddTsParams *) msg->bodyptr);
7996 break;
7997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007998 case WMA_8023_MULTICAST_LIST_REQ:
7999 wma_process_mcbc_set_filter_req(wma_handle,
8000 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308001 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008002 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008003 case WMA_ROAM_SCAN_OFFLOAD_REQ:
8004 /*
8005 * Main entry point or roaming directives from CSR.
8006 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08008007 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008008 (tSirRoamOffloadScanReq *) msg->bodyptr);
8009 break;
8010
8011 case WMA_RATE_UPDATE_IND:
8012 wma_process_rate_update_indicate(wma_handle,
8013 (tSirRateUpdateInd *) msg->bodyptr);
8014 break;
8015
8016#ifdef FEATURE_WLAN_TDLS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008017 case WMA_UPDATE_TDLS_PEER_STATE:
8018 wma_update_tdls_peer_state(wma_handle,
8019 (tTdlsPeerStateParams *) msg->bodyptr);
8020 break;
8021 case WMA_TDLS_SET_OFFCHAN_MODE:
8022 wma_set_tdls_offchan_mode(wma_handle,
8023 (tdls_chan_switch_params *)msg->bodyptr);
8024 break;
8025#endif /* FEATURE_WLAN_TDLS */
8026 case WMA_ADD_PERIODIC_TX_PTRN_IND:
8027 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
8028 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308029 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008030 break;
8031 case WMA_DEL_PERIODIC_TX_PTRN_IND:
8032 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
8033 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308034 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008035 break;
8036 case WMA_TX_POWER_LIMIT:
8037 wma_process_tx_power_limits(wma_handle,
8038 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308039 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008040 break;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08008041 case WMA_SEND_ADDBA_REQ:
8042 wma_process_send_addba_req(wma_handle,
8043 (struct send_add_ba_req *)msg->bodyptr);
8044 break;
8045
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008046#ifdef FEATURE_WLAN_CH_AVOID
8047 case WMA_CH_AVOID_UPDATE_REQ:
8048 wma_process_ch_avoid_update_req(wma_handle,
8049 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308050 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008051 break;
8052#endif /* FEATURE_WLAN_CH_AVOID */
8053#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
8054 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
8055 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308056 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008057 break;
8058#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
8059 case WMA_DHCP_START_IND:
8060 case WMA_DHCP_STOP_IND:
8061 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308062 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008063 break;
8064
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008065 case WMA_IBSS_CESIUM_ENABLE_IND:
8066 wma_process_cesium_enable_ind(wma_handle);
8067 break;
8068 case WMA_GET_IBSS_PEER_INFO_REQ:
8069 wma_process_get_peer_info_req(wma_handle,
8070 (tSirIbssGetPeerInfoReqParams *)
8071 msg->bodyptr);
8072 qdf_mem_free(msg->bodyptr);
8073 break;
8074 case WMA_TX_FAIL_MONITOR_IND:
8075 wma_process_tx_fail_monitor_ind(wma_handle,
8076 (tAniTXFailMonitorInd *) msg->bodyptr);
8077 qdf_mem_free(msg->bodyptr);
8078 break;
8079
8080 case WMA_RMC_ENABLE_IND:
8081 wma_process_rmc_enable_ind(wma_handle);
8082 break;
8083 case WMA_RMC_DISABLE_IND:
8084 wma_process_rmc_disable_ind(wma_handle);
8085 break;
8086 case WMA_RMC_ACTION_PERIOD_IND:
8087 wma_process_rmc_action_period_ind(wma_handle);
8088 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008089 case WMA_INIT_THERMAL_INFO_CMD:
8090 wma_process_init_thermal_info(wma_handle,
8091 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308092 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008093 break;
8094
8095 case WMA_SET_THERMAL_LEVEL:
8096 wma_process_set_thermal_level(wma_handle, msg->bodyval);
8097 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05308098#ifdef CONFIG_HL_SUPPORT
8099 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
8100 wma_process_init_bad_peer_tx_ctl_info(
8101 wma_handle,
8102 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
8103 qdf_mem_free(msg->bodyptr);
8104 break;
8105#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008106 case WMA_SET_MIMOPS_REQ:
8107 wma_process_set_mimops_req(wma_handle,
8108 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308109 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008110 break;
8111 case WMA_SET_SAP_INTRABSS_DIS:
8112 wma_set_vdev_intrabss_fwd(wma_handle,
8113 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308114 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008115 break;
Will Huanga9814592017-05-24 15:47:58 +08008116 case WMA_GET_PEER_INFO:
8117 wma_get_peer_info(wma_handle, msg->bodyptr);
8118 qdf_mem_free(msg->bodyptr);
8119 break;
8120 case WMA_GET_PEER_INFO_EXT:
8121 wma_get_peer_info_ext(wma_handle, msg->bodyptr);
8122 qdf_mem_free(msg->bodyptr);
8123 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008124 case WMA_MODEM_POWER_STATE_IND:
8125 wma_notify_modem_power_state(wma_handle,
8126 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308127 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008128 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008129#ifdef WLAN_FEATURE_STATS_EXT
8130 case WMA_STATS_EXT_REQUEST:
8131 wma_stats_ext_req(wma_handle,
8132 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308133 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008134 break;
8135#endif /* WLAN_FEATURE_STATS_EXT */
8136 case WMA_HIDDEN_SSID_VDEV_RESTART:
8137 wma_hidden_ssid_vdev_restart(wma_handle,
8138 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008139 break;
8140#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
8141 case WMA_WLAN_EXT_WOW:
8142 wma_enable_ext_wow(wma_handle,
8143 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308144 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008145 break;
8146 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
8147 wma_set_app_type1_params_in_fw(wma_handle,
8148 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308149 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008150 break;
8151 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
8152 wma_set_app_type2_params_in_fw(wma_handle,
8153 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308154 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008155 break;
8156#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
8157#ifdef FEATURE_WLAN_EXTSCAN
8158 case WMA_EXTSCAN_START_REQ:
8159 wma_start_extscan(wma_handle,
8160 (tSirWifiScanCmdReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308161 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008162 break;
8163 case WMA_EXTSCAN_STOP_REQ:
8164 wma_stop_extscan(wma_handle,
8165 (tSirExtScanStopReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308166 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008167 break;
8168 case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:
8169 wma_extscan_start_hotlist_monitor(wma_handle,
8170 (tSirExtScanSetBssidHotListReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308171 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008172 break;
8173 case WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
8174 wma_extscan_stop_hotlist_monitor(wma_handle,
8175 (tSirExtScanResetBssidHotlistReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308176 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008177 break;
8178 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
8179 wma_extscan_start_change_monitor(wma_handle,
8180 (tSirExtScanSetSigChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308181 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182 break;
8183 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
8184 wma_extscan_stop_change_monitor(wma_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008185 (tSirExtScanResetSignificantChangeReqParams *)
8186 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308187 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008188 break;
8189 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
8190 wma_extscan_get_cached_results(wma_handle,
8191 (tSirExtScanGetCachedResultsReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308192 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008193 break;
8194 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
8195 wma_extscan_get_capabilities(wma_handle,
8196 (tSirGetExtScanCapabilitiesReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308197 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008198 break;
8199 case WMA_SET_EPNO_LIST_REQ:
8200 wma_set_epno_network_list(wma_handle,
8201 (struct wifi_epno_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308202 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008203 break;
Kapil Gupta5cda2252016-12-29 18:44:26 +05308204 case WMA_SET_PER_ROAM_CONFIG_CMD:
8205 wma_update_per_roam_config(wma_handle,
8206 (struct wmi_per_roam_config_req *)msg->bodyptr);
8207 qdf_mem_free(msg->bodyptr);
8208 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008209 case WMA_SET_PASSPOINT_LIST_REQ:
8210 /* Issue reset passpoint network list first and clear
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008211 * the entries
8212 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008213 wma_reset_passpoint_network_list(wma_handle,
8214 (struct wifi_passpoint_req *)msg->bodyptr);
8215
8216 wma_set_passpoint_network_list(wma_handle,
8217 (struct wifi_passpoint_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308218 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008219 break;
8220 case WMA_RESET_PASSPOINT_LIST_REQ:
8221 wma_reset_passpoint_network_list(wma_handle,
8222 (struct wifi_passpoint_req *)msg->bodyptr);
8223 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008224#endif /* FEATURE_WLAN_EXTSCAN */
8225 case WMA_SET_SCAN_MAC_OUI_REQ:
8226 wma_scan_probe_setoui(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308227 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008228 break;
8229#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8230 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
8231 wma_process_ll_stats_clear_req(wma_handle,
8232 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308233 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008234 break;
8235 case WMA_LINK_LAYER_STATS_SET_REQ:
8236 wma_process_ll_stats_set_req(wma_handle,
8237 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308238 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008239 break;
8240 case WMA_LINK_LAYER_STATS_GET_REQ:
8241 wma_process_ll_stats_get_req(wma_handle,
8242 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308243 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008244 break;
Zhang Qian73c348a2017-03-13 16:15:55 +08008245 case WDA_LINK_LAYER_STATS_SET_THRESHOLD:
8246 wma_config_stats_ext_threshold(wma_handle,
8247 (struct sir_ll_ext_stats_threshold *)msg->bodyptr);
8248 qdf_mem_free(msg->bodyptr);
8249 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008250#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008251#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008252 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
8253 wma_process_roam_synch_fail(wma_handle,
8254 (struct roam_offload_synch_fail *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308255 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008256 break;
8257 case SIR_HAL_ROAM_INVOKE:
8258 wma_process_roam_invoke(wma_handle,
8259 (struct wma_roam_invoke_cmd *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308260 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008261 break;
8262#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
8263#ifdef WLAN_FEATURE_NAN
8264 case WMA_NAN_REQUEST:
8265 wma_nan_req(wma_handle, (tNanRequest *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308266 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008267 break;
8268#endif /* WLAN_FEATURE_NAN */
8269 case SIR_HAL_SET_BASE_MACADDR_IND:
8270 wma_set_base_macaddr_indicate(wma_handle,
8271 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308272 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008273 break;
8274 case WMA_LINK_STATUS_GET_REQ:
8275 wma_process_link_status_req(wma_handle,
8276 (tAniGetLinkStatus *) msg->bodyptr);
8277 break;
8278 case WMA_GET_TEMPERATURE_REQ:
8279 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308280 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008281 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07008282 case WMA_TSF_GPIO_PIN:
8283 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
8284 break;
8285
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008286#ifdef DHCP_SERVER_OFFLOAD
8287 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
8288 wma_process_dhcpserver_offload(wma_handle,
8289 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308290 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008291 break;
8292#endif /* DHCP_SERVER_OFFLOAD */
8293#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8294 case WMA_LED_FLASHING_REQ:
Jeff Johnson5a6b6602017-10-04 14:44:30 -07008295 wma_set_led_flashing(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308296 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008297 break;
8298#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
8299 case SIR_HAL_SET_MAS:
8300 wma_process_set_mas(wma_handle,
8301 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308302 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008303 break;
8304 case SIR_HAL_SET_MIRACAST:
8305 wma_process_set_miracast(wma_handle,
8306 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308307 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008308 break;
8309 case SIR_HAL_CONFIG_STATS_FACTOR:
8310 wma_config_stats_factor(wma_handle,
8311 (struct sir_stats_avg_factor *)
8312 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308313 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008314 break;
8315 case SIR_HAL_CONFIG_GUARD_TIME:
8316 wma_config_guard_time(wma_handle,
8317 (struct sir_guard_time_request *)
8318 msg->bodyptr);
Vignesh Viswanathan9fa8fef2017-12-12 14:45:38 +05308319 qdf_mem_free(msg->bodyptr);
8320 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008321 case SIR_HAL_START_STOP_LOGGING:
8322 wma_set_wifi_start_packet_stats(wma_handle,
8323 (struct sir_wifi_start_log *)msg->bodyptr);
8324 wma_enable_specific_fw_logs(wma_handle,
8325 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308326 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008327 break;
8328 case SIR_HAL_FLUSH_LOG_TO_FW:
8329 wma_send_flush_logs_to_fw(wma_handle);
8330 /* Body ptr is NULL here */
8331 break;
8332 case WMA_SET_RSSI_MONITOR_REQ:
8333 wma_set_rssi_monitoring(wma_handle,
8334 (struct rssi_monitor_req *)msg->bodyptr);
Prakash Dhavali87ddca32016-11-29 17:02:11 -08008335 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008336 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308337 case SIR_HAL_PDEV_SET_PCL_TO_FW:
8338 wma_send_pdev_set_pcl_cmd(wma_handle,
8339 (struct wmi_pcl_chan_weights *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308340 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008341 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308342 case SIR_HAL_PDEV_SET_HW_MODE:
8343 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008344 (struct policy_mgr_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308345 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008346 break;
8347 case WMA_OCB_SET_CONFIG_CMD:
8348 wma_ocb_set_config_req(wma_handle,
8349 (struct sir_ocb_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308350 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008351 break;
8352 case WMA_OCB_SET_UTC_TIME_CMD:
8353 wma_ocb_set_utc_time(wma_handle,
8354 (struct sir_ocb_utc *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308355 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008356 break;
8357 case WMA_OCB_START_TIMING_ADVERT_CMD:
8358 wma_ocb_start_timing_advert(wma_handle,
8359 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308360 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008361 break;
8362 case WMA_OCB_STOP_TIMING_ADVERT_CMD:
8363 wma_ocb_stop_timing_advert(wma_handle,
8364 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308365 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008366 break;
8367 case WMA_DCC_CLEAR_STATS_CMD:
8368 wma_dcc_clear_stats(wma_handle,
8369 (struct sir_dcc_clear_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308370 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008371 break;
8372 case WMA_OCB_GET_TSF_TIMER_CMD:
8373 wma_ocb_get_tsf_timer(wma_handle,
8374 (struct sir_ocb_get_tsf_timer *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308375 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008376 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07008377 case WMA_SET_WISA_PARAMS:
8378 wma_set_wisa_params(wma_handle,
8379 (struct sir_wisa_params *)msg->bodyptr);
8380 qdf_mem_free(msg->bodyptr);
8381 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008382 case WMA_DCC_GET_STATS_CMD:
8383 wma_dcc_get_stats(wma_handle,
8384 (struct sir_dcc_get_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308385 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008386 break;
8387 case WMA_DCC_UPDATE_NDL_CMD:
8388 wma_dcc_update_ndl(wma_handle,
8389 (struct sir_dcc_update_ndl *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308390 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008391 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308392 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
8393 wma_send_pdev_set_dual_mac_config(wma_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008394 (struct policy_mgr_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308395 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008396 break;
8397 case WMA_SET_IE_INFO:
8398 wma_process_set_ie_info(wma_handle,
8399 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308400 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008401 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008402 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
8403 wma_send_pdev_set_antenna_mode(wma_handle,
8404 (struct sir_antenna_mode_param *)msg->bodyptr);
8405 qdf_mem_free(msg->bodyptr);
8406 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008407 case WMA_LRO_CONFIG_CMD:
8408 wma_lro_config_cmd(wma_handle,
Dhanashri Atre09828f12016-11-13 10:36:58 -08008409 (struct cdp_lro_hash_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308410 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008411 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08008412 case WMA_GW_PARAM_UPDATE_REQ:
8413 wma_set_gateway_params(wma_handle,
8414 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08008415 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08008416 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05308417 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
8418 wma_send_adapt_dwelltime_params(wma_handle,
8419 (struct adaptive_dwelltime_params *)msg->bodyptr);
8420 qdf_mem_free(msg->bodyptr);
8421 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08008422 case WMA_HT40_OBSS_SCAN_IND:
8423 wma_send_ht40_obss_scanind(wma_handle,
8424 (struct obss_ht40_scanind *)msg->bodyptr);
8425 qdf_mem_free(msg->bodyptr);
8426 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07008427 case WMA_ADD_BCN_FILTER_CMDID:
8428 wma_add_beacon_filter(wma_handle, msg->bodyptr);
8429 qdf_mem_free(msg->bodyptr);
8430 break;
8431 case WMA_REMOVE_BCN_FILTER_CMDID:
8432 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
8433 qdf_mem_free(msg->bodyptr);
8434 break;
Nachiket Kukadee547a482018-05-22 16:43:30 +05308435 case WDA_APF_GET_CAPABILITIES_REQ:
8436 wma_get_apf_capabilities(wma_handle);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05308437 break;
Nachiket Kukadee547a482018-05-22 16:43:30 +05308438 case WDA_APF_SET_INSTRUCTIONS_REQ:
8439 wma_set_apf_instructions(wma_handle, msg->bodyptr);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05308440 qdf_mem_free(msg->bodyptr);
8441 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05308442 case SIR_HAL_POWER_DBG_CMD:
8443 wma_process_hal_pwr_dbg_cmd(wma_handle,
8444 msg->bodyptr);
8445 qdf_mem_free(msg->bodyptr);
8446 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05308447 case WMA_UPDATE_WEP_DEFAULT_KEY:
8448 wma_update_wep_default_key(wma_handle,
8449 (struct wep_update_default_key_idx *)msg->bodyptr);
8450 qdf_mem_free(msg->bodyptr);
8451 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05308452 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
8453 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
8454 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05308455 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
8456 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
8457 qdf_mem_free(msg->bodyptr);
8458 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05308459 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
8460 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
8461 qdf_mem_free(msg->bodyptr);
8462 break;
8463 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
8464 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
8465 qdf_mem_free(msg->bodyptr);
8466 break;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05308467 case SIR_HAL_POWER_DEBUG_STATS_REQ:
8468 wma_process_power_debug_stats_req(wma_handle);
8469 break;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05308470 case WMA_GET_RCPI_REQ:
8471 wma_get_rcpi_req(wma_handle,
8472 (struct sme_rcpi_req *)msg->bodyptr);
8473 qdf_mem_free(msg->bodyptr);
8474 break;
Yingying Tang95409972016-10-20 15:16:15 +08008475 case WMA_SET_WOW_PULSE_CMD:
8476 wma_send_wow_pulse_cmd(wma_handle,
8477 (struct wow_pulse_mode *)msg->bodyptr);
8478 qdf_mem_free(msg->bodyptr);
8479 break;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05308480 case WMA_SET_DBS_SCAN_SEL_CONF_PARAMS:
8481 wma_send_dbs_scan_selection_params(wma_handle,
8482 (struct wmi_dbs_scan_sel_params *)msg->bodyptr);
8483 qdf_mem_free(msg->bodyptr);
8484 break;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05308485 case WMA_SET_ARP_STATS_REQ:
8486 wma_set_arp_req_stats(wma_handle,
8487 (struct set_arp_stats_params *)msg->bodyptr);
8488 qdf_mem_free(msg->bodyptr);
8489 break;
8490 case WMA_GET_ARP_STATS_REQ:
8491 wma_get_arp_req_stats(wma_handle,
8492 (struct get_arp_stats_params *)msg->bodyptr);
8493 qdf_mem_free(msg->bodyptr);
8494 break;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308495 case SIR_HAL_SET_DEL_PMKID_CACHE:
8496 wma_set_del_pmkid_cache(wma_handle,
8497 (struct wmi_unified_pmk_cache *) msg->bodyptr);
8498 qdf_mem_free(msg->bodyptr);
8499 break;
8500 case SIR_HAL_HLP_IE_INFO:
8501 wma_roam_scan_send_hlp(wma_handle,
8502 (struct hlp_params *)msg->bodyptr);
8503 qdf_mem_free(msg->bodyptr);
8504 break;
Ganesh Kondabattini35739572017-06-21 16:26:39 +05308505 case WMA_SET_LIMIT_OFF_CHAN:
8506 wma_process_limit_off_chan(wma_handle, msg->bodyptr);
8507 qdf_mem_free(msg->bodyptr);
8508 break;
Arif Hussainee10f902017-12-27 16:30:17 -08008509 case WMA_OBSS_DETECTION_REQ:
8510 wma_send_obss_detection_cfg(wma_handle, msg->bodyptr);
8511 qdf_mem_free(msg->bodyptr);
8512 break;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05308513 case WMA_INVOKE_NEIGHBOR_REPORT:
8514 wma_send_invoke_neighbor_report(wma_handle, msg->bodyptr);
8515 qdf_mem_free(msg->bodyptr);
8516 break;
Arif Hussain05fb4872018-01-03 16:02:55 -08008517 case WMA_OBSS_COLOR_COLLISION_REQ:
8518 wma_process_obss_color_collision_req(wma_handle, msg->bodyptr);
8519 qdf_mem_free(msg->bodyptr);
8520 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008521 default:
Dustin Brown86534fb2017-01-24 14:28:20 -08008522 WMA_LOGE("Unhandled WMA message of type %d", msg->type);
8523 if (msg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308524 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008525 }
8526end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308527 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008528}
8529
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008530QDF_STATUS wma_mc_process_handler(struct scheduler_msg *msg)
8531{
Jeff Johnson5be42ab2017-09-13 09:10:39 -07008532 return wma_mc_process_msg(msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008533}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008535/**
8536 * wma_log_completion_timeout() - Log completion timeout
8537 * @data: Timeout handler data
8538 *
8539 * This function is called when log completion timer expires
8540 *
8541 * Return: None
8542 */
8543void wma_log_completion_timeout(void *data)
8544{
8545 tp_wma_handle wma_handle;
8546
Jeff Johnson11d7c9d2018-05-06 15:44:09 -07008547 WMA_LOGE("%s: Timeout occurred for log completion command", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008548
8549 wma_handle = (tp_wma_handle) data;
8550 if (!wma_handle)
8551 WMA_LOGE("%s: Invalid WMA handle", __func__);
8552
8553 /* Though we did not receive any event from FW,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008554 * we can flush whatever logs we have with us
8555 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008556 cds_logging_set_fw_flush_complete();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008557}
8558
8559/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308560 * wma_map_pcl_weights() - Map PCL weights
8561 * @pcl_weight: Internal PCL weights
8562 *
8563 * Maps the internal weights of PCL to the weights needed by FW
8564 *
8565 * Return: Mapped channel weight of type wmi_pcl_chan_weight
8566 */
8567static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
8568{
8569 switch (pcl_weight) {
8570 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
8571 return WMI_PCL_WEIGHT_VERY_HIGH;
8572 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
8573 return WMI_PCL_WEIGHT_HIGH;
8574 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
8575 return WMI_PCL_WEIGHT_MEDIUM;
8576 case WEIGHT_OF_NON_PCL_CHANNELS:
8577 return WMI_PCL_WEIGHT_LOW;
8578 default:
8579 return WMI_PCL_WEIGHT_DISALLOW;
8580 }
8581}
8582
8583/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308584 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008585 * @wma_handle: WMA handle
8586 * @msg: PCL structure containing the PCL and the number of channels
8587 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308588 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008589 * firmware. The DBS Manager is the consumer of this information in the WLAN
8590 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
8591 * to migrate to a new channel without host driver involvement. An example of
8592 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
8593 * manage the channel selection without firmware involvement.
8594 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308595 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
8596 * channel list. The weights corresponds to the channels sent in
8597 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
8598 * weightage compared to the non PCL channels.
8599 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008600 * Return: Success if the cmd is sent successfully to the firmware
8601 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308602QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
8603 struct wmi_pcl_chan_weights *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008604{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308605 uint32_t i;
8606 QDF_STATUS status;
8607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008608 if (!wma_handle) {
8609 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8610 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308611 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008612 }
8613
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308614 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
8615 msg->saved_chan_list[i] =
8616 wma_handle->saved_chan.channel_list[i];
8617 }
8618
8619 msg->saved_num_chan = wma_handle->saved_chan.num_channels;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008620 status = policy_mgr_get_valid_chan_weights(wma_handle->psoc,
8621 (struct policy_mgr_pcl_chan_weights *)msg);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308622
8623 for (i = 0; i < msg->saved_num_chan; i++) {
8624 msg->weighed_valid_list[i] =
8625 wma_map_pcl_weights(msg->weighed_valid_list[i]);
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008626 /* Dont allow roaming on 2G when 5G_ONLY configured */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008627 if ((wma_handle->bandcapability == BAND_5G) &&
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008628 (msg->saved_chan_list[i] <= MAX_24GHZ_CHANNEL)) {
8629 msg->weighed_valid_list[i] =
8630 WEIGHT_OF_DISALLOWED_CHANNELS;
8631 }
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308632 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
8633 msg->saved_chan_list[i], i,
8634 msg->weighed_valid_list[i]);
8635 }
8636
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308637 if (!QDF_IS_STATUS_SUCCESS(status)) {
8638 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
8639 return status;
8640 }
8641
8642 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle, msg))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308643 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05308644
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308645 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008646}
8647
8648/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308649 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008650 * @wma_handle: WMA handle
8651 * @msg: Structure containing the following parameters
8652 *
8653 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
8654 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
8655 *
8656 * Provides notification to the WLAN firmware that host driver is requesting a
8657 * HardWare (HW) Mode change. This command is needed to support iHelium in the
8658 * configurations that include the Dual Band Simultaneous (DBS) feature.
8659 *
8660 * Return: Success if the cmd is sent successfully to the firmware
8661 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308662QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008663 struct policy_mgr_hw_mode *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008664{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008665 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008666 struct wma_target_req *timeout_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008667
8668 if (!wma_handle) {
8669 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8670 __func__);
8671 /* Handle is NULL. Will not be able to send failure
8672 * response as well
8673 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308674 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008675 }
8676
8677 if (!msg) {
8678 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
8679 /* Lets try to free the active command list */
8680 goto fail;
8681 }
8682
Dustin Brownec2c92e2017-07-26 11:13:49 -07008683 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8684 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT);
Govind Singhf25a0f12016-03-08 16:09:48 +05308685 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008686 msg->hw_mode_index)) {
8687 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008688 goto fail;
Krunal Sonicebcc292017-06-14 19:59:20 -07008689 }
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008690 timeout_msg = wma_fill_hold_req(wma_handle, 0,
8691 SIR_HAL_PDEV_SET_HW_MODE,
8692 WMA_PDEV_SET_HW_MODE_RESP, NULL,
8693 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT - 1);
8694 if (!timeout_msg) {
8695 WMA_LOGE("Failed to allocate request for SIR_HAL_PDEV_SET_HW_MODE");
8696 wma_remove_req(wma_handle, 0, WMA_PDEV_SET_HW_MODE_RESP);
8697 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008698
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308699 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008700fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308701 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008702 if (!param) {
8703 WMA_LOGE("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308704 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008705 }
8706 param->status = SET_HW_MODE_STATUS_ECANCELED;
8707 param->cfgd_hw_mode_index = 0;
8708 param->num_vdev_mac_entries = 0;
8709 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308710 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008711 (void *) param, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308712 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008713}
8714
8715/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308716 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008717 * @wma_handle: WMA handle
8718 * @msg: Dual MAC config parameters
8719 *
8720 * Configures WLAN firmware with the dual MAC features
8721 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308722 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008723 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308724QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008725 struct policy_mgr_dual_mac_config *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008726{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308727 QDF_STATUS status;
8728
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008729 if (!wma_handle) {
8730 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8731 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308732 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008733 }
8734
8735 if (!msg) {
8736 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308737 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008738 }
8739
Krunal Sonia5ccb802017-07-03 12:59:40 -07008740 /*
8741 * aquire the wake lock here and release it in response handler function
8742 * In error condition, release the wake lock right away
8743 */
8744 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8745 WMA_VDEV_PLCY_MGR_CMD_TIMEOUT);
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308746 status = wmi_unified_pdev_set_dual_mac_config_cmd(
8747 wma_handle->wmi_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008748 (struct policy_mgr_dual_mac_config *)msg);
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308749 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308750 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308751 __func__, status);
Krunal Sonia5ccb802017-07-03 12:59:40 -07008752 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308753 return status;
8754 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008755 policy_mgr_update_dbs_req_config(wma_handle->psoc,
8756 msg->scan_config, msg->fw_mode_config);
Govind Singhf25a0f12016-03-08 16:09:48 +05308757
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308758 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008759}
8760
8761/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008762 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
8763 * @wma_handle: WMA handle
8764 * @msg: Antenna mode parameters
8765 *
8766 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
8767 * modify the number of TX/RX chains from host
8768 *
8769 * Return: QDF_STATUS. 0 on success.
8770 */
8771QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
8772 struct sir_antenna_mode_param *msg)
8773{
8774 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
8775 wmi_buf_t buf;
8776 uint32_t len;
8777 QDF_STATUS status = QDF_STATUS_SUCCESS;
8778 struct sir_antenna_mode_resp *param;
8779
8780 if (!wma_handle) {
8781 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8782 __func__);
8783 return QDF_STATUS_E_NULL_VALUE;
8784 }
8785
8786 if (!msg) {
8787 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
8788 return QDF_STATUS_E_NULL_VALUE;
8789 }
8790
8791 len = sizeof(*cmd);
8792
8793 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
8794 if (!buf) {
8795 WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
8796 status = QDF_STATUS_E_NOMEM;
8797 goto resp;
8798 }
8799
8800 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
8801 WMITLV_SET_HDR(&cmd->tlv_header,
8802 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
8803 WMITLV_GET_STRUCT_TLVLEN(
8804 wmi_pdev_set_antenna_mode_cmd_fixed_param));
8805
8806 cmd->pdev_id = WMI_PDEV_ID_SOC;
8807 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
8808 cmd->num_txrx_chains = msg->num_rx_chains;
8809 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
8810
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07008811 WMA_LOGD("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008812 __func__, msg->num_tx_chains,
8813 msg->num_rx_chains, cmd->num_txrx_chains);
8814
8815 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
8816 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
8817 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_ANTENNA_MODE_CMDID",
8818 __func__);
8819 wmi_buf_free(buf);
8820 status = QDF_STATUS_E_FAILURE;
8821 goto resp;
8822 }
8823 status = QDF_STATUS_SUCCESS;
8824
8825resp:
8826 param = qdf_mem_malloc(sizeof(*param));
8827 if (!param) {
8828 WMA_LOGE("%s: Memory allocation failed", __func__);
8829 return QDF_STATUS_E_NOMEM;
8830 }
8831 param->status = (status) ?
8832 SET_ANTENNA_MODE_STATUS_ECANCELED :
8833 SET_ANTENNA_MODE_STATUS_OK;
8834 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
8835 __func__, param->status);
8836 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
8837 (void *) param, 0);
8838 return status;
8839}
8840
8841/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008842 * wma_crash_inject() - sends command to FW to simulate crash
8843 * @wma_handle: pointer of WMA context
8844 * @type: subtype of the command
8845 * @delay_time_ms: time in milliseconds for FW to delay the crash
8846 *
8847 * This function will send a command to FW in order to simulate different
8848 * kinds of FW crashes.
8849 *
Govind Singhd76a5b02016-03-08 15:12:14 +05308850 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008851 */
Yu Wang46082dc2017-09-19 12:25:38 +08008852QDF_STATUS wma_crash_inject(WMA_HANDLE wma_handle, uint32_t type,
8853 uint32_t delay_time_ms)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008854{
Govind Singhd76a5b02016-03-08 15:12:14 +05308855 struct crash_inject param;
Yu Wang46082dc2017-09-19 12:25:38 +08008856 tp_wma_handle wma = (tp_wma_handle)wma_handle;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008857
Govind Singhd76a5b02016-03-08 15:12:14 +05308858 param.type = type;
8859 param.delay_time_ms = delay_time_ms;
Yu Wang46082dc2017-09-19 12:25:38 +08008860 return wmi_crash_inject(wma->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008861}
Govind Singhd76a5b02016-03-08 15:12:14 +05308862
Manjunathappa Prakash7b0ad462018-04-15 00:37:16 -07008863#ifdef RECEIVE_OFFLOAD
Dhanashri Atre09828f12016-11-13 10:36:58 -08008864int wma_lro_init(struct cdp_lro_hash_config *lro_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008865{
Rajeev Kumarb60abe42017-01-21 15:39:31 -08008866 struct scheduler_msg msg = {0};
Dhanashri Atre09828f12016-11-13 10:36:58 -08008867 struct cdp_lro_hash_config *iwcmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008868
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308869 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870 if (!iwcmd) {
8871 WMA_LOGE("memory allocation for WMA_LRO_CONFIG_CMD failed!");
8872 return -ENOMEM;
8873 }
8874
8875 *iwcmd = *lro_config;
8876
8877 msg.type = WMA_LRO_CONFIG_CMD;
8878 msg.reserved = 0;
8879 msg.bodyptr = iwcmd;
8880
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308881 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08008882 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008883 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308884 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008885 return -EAGAIN;
8886 }
8887
8888 WMA_LOGD("sending the LRO configuration to the fw");
8889 return 0;
8890}
8891#endif
Leo Chang96464902016-10-28 11:10:54 -07008892
8893void wma_peer_set_default_routing(void *scn_handle, uint8_t *peer_macaddr,
8894 uint8_t vdev_id, bool hash_based, uint8_t ring_num)
8895{
8896 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8897 struct peer_set_params param;
8898
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308899 if (!wma) {
8900 WMA_LOGE("%s:wma_handle is NULL", __func__);
8901 return;
8902 }
Leo Chang96464902016-10-28 11:10:54 -07008903
8904 /* TODO: Need bit definitions for ring number and hash based routing
8905 * fields in common wmi header file
8906 */
8907 param.param_id = WMI_HOST_PEER_SET_DEFAULT_ROUTING;
8908 param.vdev_id = vdev_id;
8909 param.param_value = ((hash_based) ? 1 : 0) | (ring_num << 1);
Jeff Johnsonf7ca9642017-10-10 16:11:49 -07008910 WMA_LOGD("%s: param_value 0x%x", __func__, param.param_value);
Leo Chang96464902016-10-28 11:10:54 -07008911 wmi_set_peer_param_send(wma->wmi_handle, peer_macaddr, &param);
Leo Chang96464902016-10-28 11:10:54 -07008912}
8913
8914int wma_peer_rx_reorder_queue_setup(void *scn_handle,
8915 uint8_t vdev_id, uint8_t *peer_macaddr, qdf_dma_addr_t hw_qdesc,
8916 int tid, uint16_t queue_no)
8917{
8918 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8919 struct rx_reorder_queue_setup_params param;
8920
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308921 if (!wma) {
8922 WMA_LOGE("%s:wma_handle is NULL", __func__);
8923 return QDF_STATUS_E_FAILURE;
8924 }
8925
Leo Chang96464902016-10-28 11:10:54 -07008926 param.tid = tid;
8927 param.vdev_id = vdev_id;
8928 param.peer_macaddr = peer_macaddr;
8929 param.hw_qdesc_paddr_lo = hw_qdesc & 0xffffffff;
8930 param.hw_qdesc_paddr_hi = (uint64_t)hw_qdesc >> 32;
8931 param.queue_no = queue_no;
8932
8933 return wmi_unified_peer_rx_reorder_queue_setup_send(wma->wmi_handle,
8934 &param);
8935}
8936
8937int wma_peer_rx_reorder_queue_remove(void *scn_handle,
8938 uint8_t vdev_id, uint8_t *peer_macaddr, uint32_t peer_tid_bitmap)
8939{
8940 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8941 struct rx_reorder_queue_remove_params param;
8942
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308943 if (!wma) {
8944 WMA_LOGE("%s:wma_handle is NULL", __func__);
8945 return QDF_STATUS_E_FAILURE;
8946 }
8947
Leo Chang96464902016-10-28 11:10:54 -07008948 param.vdev_id = vdev_id;
8949 param.peer_macaddr = peer_macaddr;
8950 param.peer_tid_bitmap = peer_tid_bitmap;
8951
8952 return wmi_unified_peer_rx_reorder_queue_remove_send(wma->wmi_handle,
8953 &param);
8954}
8955
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +05308956QDF_STATUS wma_configure_smps_params(uint32_t vdev_id, uint32_t param_id,
8957 uint32_t param_val)
8958{
8959 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8960 int smps_cmd_value;
8961 int status = QDF_STATUS_E_INVAL;
8962
8963 if (!wma) {
8964 WMA_LOGE("%s: Failed to get wma", __func__);
8965 return status;
8966 }
8967
8968 smps_cmd_value = param_id << WMI_SMPS_PARAM_VALUE_S;
8969 smps_cmd_value = smps_cmd_value | param_val;
8970
8971 status = wma_set_smps_params(wma, vdev_id, smps_cmd_value);
8972 if (status)
8973 WMA_LOGE("Failed to set SMPS Param");
8974
8975 return status;
8976}
8977
Leo Chang96464902016-10-28 11:10:54 -07008978
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07008979void wma_ipa_uc_stat_request(wma_cli_set_cmd_t *privcmd)
8980{
8981 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8982
Sreelakshmi Konamki7a574082017-05-15 16:53:45 +05308983 if (!wma) {
8984 WMA_LOGE("%s: Failed to get wma", __func__);
8985 return;
8986 }
8987
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07008988 if (wma_set_priv_cfg(wma, privcmd))
8989 WMA_LOGE("Failed to set wma priv congiuration");
8990}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +05308991
8992/**
8993 * wma_config_bmiss_bcnt_params() - set bmiss config parameters
8994 * @vdev_id: virtual device for the command
8995 * @first_cnt: bmiss first value
8996 * @final_cnt: bmiss final value
8997 *
8998 * Return: QDF_STATUS_SUCCESS or non-zero on failure
8999 */
9000QDF_STATUS wma_config_bmiss_bcnt_params(uint32_t vdev_id, uint32_t first_cnt,
9001 uint32_t final_cnt)
9002{
9003 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
9004 int status = QDF_STATUS_E_INVAL;
9005
9006 if (!wma_handle) {
9007 WMA_LOGE("%s: Failed to get wma", __func__);
9008 return status;
9009 }
9010
9011 status = wma_roam_scan_bmiss_cnt(wma_handle, first_cnt, final_cnt,
9012 vdev_id);
9013
9014 if (status)
9015 WMA_LOGE("Failed to set Bmiss Param");
9016
9017 return status;
9018}
9019