blob: e84ab4f263d2d5e359af16abb5c637ddad32c791 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Harprit Chhabada98225f62018-12-11 15:29:55 -08002 * Copyright (c) 2013-2019 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"
Manikandan Mohandcd0fdf2018-08-02 18:13:37 -070092#include "cfg_nan_api.h"
Pragaspathi Thilagaraj00bd8bc2018-08-18 01:23:01 +053093#include "wlan_mlme_api.h"
Wu Gao51a63562018-11-08 16:29:10 +080094#include "wlan_mlme_ucfg_api.h"
Alok Kumar02301292018-11-28 18:10:34 +053095#include "cfg_ucfg_api.h"
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070096
Agrawal Ashishb0aa0752017-04-21 19:31:10 +053097#define WMA_LOG_COMPLETION_TIMER 3000 /* 3 seconds */
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +053098#define WMI_TLV_HEADROOM 128
gaurank kathpalia85f8a612018-02-21 18:55:24 +053099
100#define WMA_FW_TIME_SYNC_TIMER 60000 /* 1 min */
101
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700102uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103static uint32_t g_fw_wlan_feat_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800104/**
105 * wma_get_fw_wlan_feat_caps() - get fw feature capablity
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700106 * @feature: feature enum value
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107 *
108 * Return: true/false
109 */
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700110bool wma_get_fw_wlan_feat_caps(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700112 return (g_fw_wlan_feat_caps & (1 << feature)) ? true : false;
113}
114
115/**
116 * wma_set_fw_wlan_feat_caps() - set fw feature capablity
117 * @feature: feature enum value
118 *
119 * Return: None
120 */
121void wma_set_fw_wlan_feat_caps(enum cap_bitmap feature)
122{
123 g_fw_wlan_feat_caps |= (1 << feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800124}
125
126/**
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530127 * wma_service_ready_ext_evt_timeout() - Service ready extended event timeout
128 * @data: Timeout handler data
129 *
130 * This function is called when the FW fails to send WMI_SERVICE_READY_EXT_EVENT
131 * message
132 *
133 * Return: None
134 */
135static void wma_service_ready_ext_evt_timeout(void *data)
136{
137 tp_wma_handle wma_handle;
138
139 WMA_LOGA("%s: Timeout waiting for WMI_SERVICE_READY_EXT_EVENT",
140 __func__);
141
142 wma_handle = (tp_wma_handle) data;
143
144 if (!wma_handle) {
145 WMA_LOGE("%s: Invalid WMA handle", __func__);
146 goto end;
147 }
148
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530149end:
Naveen Rawatac39a102016-10-07 10:58:29 -0700150 /* Assert here. Panic is being called in insmod thread */
151 QDF_ASSERT(0);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530152}
153
154/**
Komal Seelam02d09342016-02-23 18:03:19 +0530155 * wma_get_ini_handle() - API to get WMA ini info handle
156 * @wma: WMA Handle
157 *
158 * Returns the pointer to WMA ini structure.
159 * Return: struct wma_ini_config
160 */
161struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma)
162{
163 if (!wma) {
164 WMA_LOGE("%s: Invalid WMA context\n", __func__);
165 return NULL;
166 }
167
168 return &wma->ini_config;
169}
170
171#define MAX_SUPPORTED_PEERS_REV1_1 14
172#define MAX_SUPPORTED_PEERS_REV1_3 32
173#define MIN_NO_OF_PEERS 1
174
175/**
176 * wma_get_number_of_peers_supported - API to query for number of peers
177 * supported
178 * @wma: WMA Handle
179 *
180 * Return: Max Number of Peers Supported
181 */
182static uint8_t wma_get_number_of_peers_supported(tp_wma_handle wma)
183{
Komal Seelam02d09342016-02-23 18:03:19 +0530184 struct wma_ini_config *cfg = wma_get_ini_handle(wma);
185 uint8_t max_no_of_peers = cfg ? cfg->max_no_of_peers : MIN_NO_OF_PEERS;
Komal Seelam02d09342016-02-23 18:03:19 +0530186
187 return max_no_of_peers;
188}
189
190/**
bings6b3614e2017-02-21 10:18:36 +0800191 * wma_get_number_of_tids_supported - API to query for number of tids supported
192 * @no_of_peers_supported: Number of peer supported
193 *
194 * Return: Max number of tids supported
195 */
196#if defined(CONFIG_HL_SUPPORT)
Rachit Kankane0106e382018-05-16 18:59:28 +0530197static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported,
198 uint8_t num_vdevs)
bings6b3614e2017-02-21 10:18:36 +0800199{
200 return 4 * no_of_peers_supported;
201}
202#else
Rachit Kankane0106e382018-05-16 18:59:28 +0530203static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported,
204 uint8_t num_vdevs)
bings6b3614e2017-02-21 10:18:36 +0800205{
Rachit Kankane0106e382018-05-16 18:59:28 +0530206 return 2 * (no_of_peers_supported + num_vdevs + 2);
bings6b3614e2017-02-21 10:18:36 +0800207}
208#endif
209
Rachit Kankane0106e382018-05-16 18:59:28 +0530210#ifndef NUM_OF_ADDITIONAL_FW_PEERS
211#define NUM_OF_ADDITIONAL_FW_PEERS 2
212#endif
bings6b3614e2017-02-21 10:18:36 +0800213/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214 * wma_set_default_tgt_config() - set default tgt config
215 * @wma_handle: wma handle
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530216 * @tgt_cfg: Resource config given to target
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217 *
218 * Return: none
219 */
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530220static void wma_set_default_tgt_config(tp_wma_handle wma_handle,
Rachit Kankane0106e382018-05-16 18:59:28 +0530221 target_resource_config *tgt_cfg,
222 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 uint8_t no_of_peers_supported;
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530225
Rachit Kankane0106e382018-05-16 18:59:28 +0530226 no_of_peers_supported = wma_get_number_of_peers_supported(wma_handle);
227
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530228 qdf_mem_zero(tgt_cfg, sizeof(target_resource_config));
Rachit Kankane0106e382018-05-16 18:59:28 +0530229 tgt_cfg->num_vdevs = cds_cfg->num_vdevs;
230 tgt_cfg->num_peers = no_of_peers_supported +
231 cds_cfg->num_vdevs +
232 NUM_OF_ADDITIONAL_FW_PEERS;
233 /* The current firmware implementation requires the number of
234 * offload peers should be (number of vdevs + 1).
235 */
236 tgt_cfg->num_offload_peers = cds_cfg->ap_maxoffload_peers + 1;
237 tgt_cfg->num_offload_reorder_buffs =
238 cds_cfg->ap_maxoffload_reorderbuffs + 1;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530239 tgt_cfg->num_peer_keys = CFG_TGT_NUM_PEER_KEYS;
Rachit Kankane0106e382018-05-16 18:59:28 +0530240 tgt_cfg->num_tids = wma_get_number_of_tids_supported(
241 no_of_peers_supported, cds_cfg->num_vdevs);
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530242 tgt_cfg->ast_skid_limit = CFG_TGT_AST_SKID_LIMIT;
243 tgt_cfg->tx_chain_mask = CFG_TGT_DEFAULT_TX_CHAIN_MASK;
244 tgt_cfg->rx_chain_mask = CFG_TGT_DEFAULT_RX_CHAIN_MASK;
245 tgt_cfg->rx_timeout_pri[0] = CFG_TGT_RX_TIMEOUT_LO_PRI;
246 tgt_cfg->rx_timeout_pri[1] = CFG_TGT_RX_TIMEOUT_LO_PRI;
247 tgt_cfg->rx_timeout_pri[2] = CFG_TGT_RX_TIMEOUT_LO_PRI;
248 tgt_cfg->rx_timeout_pri[3] = CFG_TGT_RX_TIMEOUT_HI_PRI;
249 tgt_cfg->rx_decap_mode = CFG_TGT_RX_DECAP_MODE;
Rachit Kankane0106e382018-05-16 18:59:28 +0530250 tgt_cfg->scan_max_pending_req = wma_handle->max_scan;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530251 tgt_cfg->bmiss_offload_max_vdev =
252 CFG_TGT_DEFAULT_BMISS_OFFLOAD_MAX_VDEV;
253 tgt_cfg->roam_offload_max_vdev = CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_VDEV;
254 tgt_cfg->roam_offload_max_ap_profiles =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530255 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_PROFILES;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530256 tgt_cfg->num_mcast_groups = CFG_TGT_DEFAULT_NUM_MCAST_GROUPS;
257 tgt_cfg->num_mcast_table_elems = CFG_TGT_DEFAULT_NUM_MCAST_TABLE_ELEMS;
258 tgt_cfg->mcast2ucast_mode = CFG_TGT_DEFAULT_MCAST2UCAST_MODE;
259 tgt_cfg->tx_dbg_log_size = CFG_TGT_DEFAULT_TX_DBG_LOG_SIZE;
260 tgt_cfg->num_wds_entries = CFG_TGT_WDS_ENTRIES;
261 tgt_cfg->dma_burst_size = CFG_TGT_DEFAULT_DMA_BURST_SIZE;
262 tgt_cfg->mac_aggr_delim = CFG_TGT_DEFAULT_MAC_AGGR_DELIM;
263 tgt_cfg->rx_skip_defrag_timeout_dup_detection_check =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264 CFG_TGT_DEFAULT_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK,
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530265 tgt_cfg->vow_config = CFG_TGT_DEFAULT_VOW_CONFIG;
266 tgt_cfg->gtk_offload_max_vdev = CFG_TGT_DEFAULT_GTK_OFFLOAD_MAX_VDEV;
267 tgt_cfg->num_msdu_desc = CFG_TGT_NUM_MSDU_DESC;
268 tgt_cfg->max_frag_entries = CFG_TGT_MAX_FRAG_TABLE_ENTRIES;
269 tgt_cfg->num_tdls_vdevs = CFG_TGT_NUM_TDLS_VDEVS;
270 tgt_cfg->num_tdls_conn_table_entries =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530271 CFG_TGT_NUM_TDLS_CONN_TABLE_ENTRIES;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530272 tgt_cfg->beacon_tx_offload_max_vdev =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530273 CFG_TGT_DEFAULT_BEACON_TX_OFFLOAD_MAX_VDEV;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530274 tgt_cfg->num_multicast_filter_entries =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530275 CFG_TGT_MAX_MULTICAST_FILTER_ENTRIES;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530276 tgt_cfg->num_wow_filters = 0;
Rachit Kankane0106e382018-05-16 18:59:28 +0530277 tgt_cfg->num_keep_alive_pattern = WMA_MAXNUM_PERIODIC_TX_PTRNS;
jsreekumac44b922018-06-12 20:18:39 +0530278 tgt_cfg->num_max_sta_vdevs = CFG_TGT_DEFAULT_MAX_STA_VDEVS;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530279 tgt_cfg->keep_alive_pattern_size = 0;
280 tgt_cfg->max_tdls_concurrent_sleep_sta =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530281 CFG_TGT_NUM_TDLS_CONC_SLEEP_STAS;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530282 tgt_cfg->max_tdls_concurrent_buffer_sta =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530283 CFG_TGT_NUM_TDLS_CONC_BUFFER_STAS;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530284 tgt_cfg->wmi_send_separate = 0;
285 tgt_cfg->num_ocb_vdevs = CFG_TGT_NUM_OCB_VDEVS;
286 tgt_cfg->num_ocb_channels = CFG_TGT_NUM_OCB_CHANNELS;
287 tgt_cfg->num_ocb_schedules = CFG_TGT_NUM_OCB_SCHEDULES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530290 tgt_cfg->mgmt_comp_evt_bundle_support = true;
291 tgt_cfg->tx_msdu_new_partition_id_support = true;
Nirav Shah20489972016-06-16 19:20:28 +0530292
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530293 if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE)
294 tgt_cfg->rx_decap_mode = CFG_TGT_RX_DECAP_MODE_RAW;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295}
296
297/**
298 * wma_cli_get_command() - WMA "get" command processor
299 * @vdev_id: virtual device for the command
300 * @param_id: parameter id
301 * @vpdev: parameter category
302 *
303 * Return: parameter value on success, -EINVAL on failure
304 */
305int wma_cli_get_command(int vdev_id, int param_id, int vpdev)
306{
307 int ret = 0;
308 tp_wma_handle wma;
309 struct wma_txrx_node *intr = NULL;
310
Anurag Chouhan6d760662016-02-20 16:05:43 +0530311 wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312
313 if (NULL == wma) {
314 WMA_LOGE("%s: Invalid wma handle", __func__);
315 return -EINVAL;
316 }
317
318 intr = wma->interfaces;
319
320 if (VDEV_CMD == vpdev) {
321 switch (param_id) {
322 case WMI_VDEV_PARAM_NSS:
323 ret = intr[vdev_id].config.nss;
324 break;
325#ifdef QCA_SUPPORT_GTX
326 case WMI_VDEV_PARAM_GTX_HT_MCS:
327 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
328 break;
329 case WMI_VDEV_PARAM_GTX_VHT_MCS:
330 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
331 break;
332 case WMI_VDEV_PARAM_GTX_USR_CFG:
333 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
334 break;
335 case WMI_VDEV_PARAM_GTX_THRE:
336 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
337 break;
338 case WMI_VDEV_PARAM_GTX_MARGIN:
339 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
340 break;
341 case WMI_VDEV_PARAM_GTX_STEP:
342 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
343 break;
344 case WMI_VDEV_PARAM_GTX_MINTPC:
345 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
346 break;
347 case WMI_VDEV_PARAM_GTX_BW_MASK:
348 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
349 break;
350#endif /* QCA_SUPPORT_GTX */
351 case WMI_VDEV_PARAM_LDPC:
352 ret = intr[vdev_id].config.ldpc;
353 break;
354 case WMI_VDEV_PARAM_TX_STBC:
355 ret = intr[vdev_id].config.tx_stbc;
356 break;
357 case WMI_VDEV_PARAM_RX_STBC:
358 ret = intr[vdev_id].config.rx_stbc;
359 break;
360 case WMI_VDEV_PARAM_SGI:
361 ret = intr[vdev_id].config.shortgi;
362 break;
363 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
364 ret = intr[vdev_id].config.rtscts_en;
365 break;
366 case WMI_VDEV_PARAM_CHWIDTH:
367 ret = intr[vdev_id].config.chwidth;
368 break;
369 case WMI_VDEV_PARAM_FIXED_RATE:
370 ret = intr[vdev_id].config.tx_rate;
371 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700372 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -0700373 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700374 ret = wma_get_he_vdev_param(&intr[vdev_id], param_id);
375 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700377 WMA_LOGE("Invalid cli_get vdev command/Not yet implemented 0x%x",
378 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 return -EINVAL;
380 }
381 } else if (PDEV_CMD == vpdev) {
382 switch (param_id) {
383 case WMI_PDEV_PARAM_ANI_ENABLE:
384 ret = wma->pdevconfig.ani_enable;
385 break;
386 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
387 ret = wma->pdevconfig.ani_poll_len;
388 break;
389 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
390 ret = wma->pdevconfig.ani_listen_len;
391 break;
392 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
393 ret = wma->pdevconfig.ani_ofdm_level;
394 break;
395 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
396 ret = wma->pdevconfig.ani_cck_level;
397 break;
398 case WMI_PDEV_PARAM_DYNAMIC_BW:
399 ret = wma->pdevconfig.cwmenable;
400 break;
401 case WMI_PDEV_PARAM_CTS_CBW:
402 ret = wma->pdevconfig.cts_cbw;
403 break;
404 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
405 ret = wma->pdevconfig.txchainmask;
406 break;
407 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
408 ret = wma->pdevconfig.rxchainmask;
409 break;
410 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
411 ret = wma->pdevconfig.txpow2g;
412 break;
413 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
414 ret = wma->pdevconfig.txpow5g;
415 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700417 WMA_LOGE("Invalid cli_get pdev command/Not yet implemented 0x%x",
418 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800419 return -EINVAL;
420 }
421 } else if (GEN_CMD == vpdev) {
422 switch (param_id) {
423 case GEN_VDEV_PARAM_AMPDU:
424 ret = intr[vdev_id].config.ampdu;
425 break;
426 case GEN_VDEV_PARAM_AMSDU:
427 ret = intr[vdev_id].config.amsdu;
428 break;
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700429 case GEN_VDEV_ROAM_SYNCH_DELAY:
430 ret = intr[vdev_id].roam_synch_delay;
431 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700433 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
434 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 return -EINVAL;
436 }
437 } else if (PPS_CMD == vpdev) {
438 switch (param_id) {
439 case WMI_VDEV_PPS_PAID_MATCH:
440 ret = intr[vdev_id].config.pps_params.paid_match_enable;
441 break;
442 case WMI_VDEV_PPS_GID_MATCH:
443 ret = intr[vdev_id].config.pps_params.gid_match_enable;
444 break;
445 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
446 ret = intr[vdev_id].config.pps_params.tim_clear;
447 break;
448 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
449 ret = intr[vdev_id].config.pps_params.dtim_clear;
450 break;
451 case WMI_VDEV_PPS_EOF_PAD_DELIM:
452 ret = intr[vdev_id].config.pps_params.eof_delim;
453 break;
454 case WMI_VDEV_PPS_MACADDR_MISMATCH:
455 ret = intr[vdev_id].config.pps_params.mac_match;
456 break;
457 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
458 ret = intr[vdev_id].config.pps_params.delim_fail;
459 break;
460 case WMI_VDEV_PPS_GID_NSTS_ZERO:
461 ret = intr[vdev_id].config.pps_params.nsts_zero;
462 break;
463 case WMI_VDEV_PPS_RSSI_CHECK:
464 ret = intr[vdev_id].config.pps_params.rssi_chk;
465 break;
466 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700467 WMA_LOGE("Invalid pps vdev command/Not yet implemented 0x%x",
468 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469 return -EINVAL;
470 }
471 } else if (QPOWER_CMD == vpdev) {
472 switch (param_id) {
473 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
474 ret = intr[vdev_id].config.qpower_params.
475 max_ps_poll_cnt;
476 break;
477 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
478 ret = intr[vdev_id].config.qpower_params.
479 max_tx_before_wake;
480 break;
481 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
482 ret = intr[vdev_id].config.qpower_params.
483 spec_ps_poll_wake_interval;
484 break;
485 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
486 ret = intr[vdev_id].config.qpower_params.
487 max_spec_nodata_ps_poll;
488 break;
489 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700490 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
491 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 return -EINVAL;
493 }
494 } else if (GTX_CMD == vpdev) {
495 switch (param_id) {
496 case WMI_VDEV_PARAM_GTX_HT_MCS:
497 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
498 break;
499 case WMI_VDEV_PARAM_GTX_VHT_MCS:
500 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
501 break;
502 case WMI_VDEV_PARAM_GTX_USR_CFG:
503 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
504 break;
505 case WMI_VDEV_PARAM_GTX_THRE:
506 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
507 break;
508 case WMI_VDEV_PARAM_GTX_MARGIN:
509 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
510 break;
511 case WMI_VDEV_PARAM_GTX_STEP:
512 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
513 break;
514 case WMI_VDEV_PARAM_GTX_MINTPC:
515 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
516 break;
517 case WMI_VDEV_PARAM_GTX_BW_MASK:
518 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
519 break;
520 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700521 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
522 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523 return -EINVAL;
524 }
525 }
526 return ret;
527}
528
529/**
530 * wma_cli_set2_command() - WMA "set 2 params" command processor
531 * @vdev_id: virtual device for the command
532 * @param_id: parameter id
533 * @sval1: first parameter value
534 * @sval2: second parameter value
535 * @vpdev: parameter category
536 *
537 * Command handler for set operations which require 2 parameters
538 *
539 * Return: 0 on success, errno on failure
540 */
541int wma_cli_set2_command(int vdev_id, int param_id, int sval1,
542 int sval2, int vpdev)
543{
Rajeev Kumarb60abe42017-01-21 15:39:31 -0800544 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 wma_cli_set_cmd_t *iwcmd;
546
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530547 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Arif Hussain157263f2018-10-03 13:07:15 -0700548 if (!iwcmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549 return -ENOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530551 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800552 iwcmd->param_value = sval1;
553 iwcmd->param_sec_value = sval2;
554 iwcmd->param_vdev_id = vdev_id;
555 iwcmd->param_id = param_id;
556 iwcmd->param_vp_dev = vpdev;
557 msg.type = WMA_CLI_SET_CMD;
558 msg.reserved = 0;
559 msg.bodyptr = iwcmd;
560
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530561 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia00861f02018-08-28 19:16:12 +0530562 scheduler_post_message(QDF_MODULE_ID_WMA,
563 QDF_MODULE_ID_WMA,
564 QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -0700565 WMA_LOGE("%s: Failed to post WMA_CLI_SET_CMD msg",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530567 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 return -EIO;
569 }
570 return 0;
571}
572
573/**
574 * wma_cli_set_command() - WMA "set" command processor
575 * @vdev_id: virtual device for the command
576 * @param_id: parameter id
577 * @sval: parameter value
578 * @vpdev: parameter category
579 *
580 * Command handler for set operations
581 *
582 * Return: 0 on success, errno on failure
583 */
584int wma_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
585{
586 return wma_cli_set2_command(vdev_id, param_id, sval, 0, vpdev);
587
588}
589
Krunal Soniaadaa272017-10-04 16:42:55 -0700590QDF_STATUS wma_form_unit_test_cmd_and_send(uint32_t vdev_id,
591 uint32_t module_id, uint32_t arg_count, uint32_t *arg)
592{
593 struct wmi_unit_test_cmd *unit_test_args;
594 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
595 uint32_t i;
596 QDF_STATUS status;
597
598 WMA_LOGD(FL("enter"));
Sourav Mohapatraea7210b2018-11-16 16:58:52 +0530599 if (arg_count > WMA_MAX_NUM_ARGS) {
Krunal Soniaadaa272017-10-04 16:42:55 -0700600 WMA_LOGE(FL("arg_count is crossed the boundary"));
601 return QDF_STATUS_E_FAILURE;
602 }
603 if (!wma_handle || !wma_handle->wmi_handle) {
604 WMA_LOGE(FL("Invalid WMA/WMI handle"));
605 return QDF_STATUS_E_FAILURE;
606 }
607 unit_test_args = qdf_mem_malloc(sizeof(*unit_test_args));
Arif Hussain157263f2018-10-03 13:07:15 -0700608 if (!unit_test_args)
Krunal Soniaadaa272017-10-04 16:42:55 -0700609 return QDF_STATUS_E_NOMEM;
Arif Hussain157263f2018-10-03 13:07:15 -0700610
Krunal Soniaadaa272017-10-04 16:42:55 -0700611 unit_test_args->vdev_id = vdev_id;
612 unit_test_args->module_id = module_id;
613 unit_test_args->num_args = arg_count;
614 for (i = 0; i < arg_count; i++)
615 unit_test_args->args[i] = arg[i];
616
617 status = wmi_unified_unit_test_cmd(wma_handle->wmi_handle,
618 unit_test_args);
619 qdf_mem_free(unit_test_args);
620 WMA_LOGD(FL("exit"));
621
622 return status;
623}
624
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -0800625static void wma_process_send_addba_req(tp_wma_handle wma_handle,
626 struct send_add_ba_req *send_addba)
627{
628 QDF_STATUS status;
629
630 if (!wma_handle || !wma_handle->wmi_handle) {
631 WMA_LOGE(FL("Invalid WMA/WMI handle"));
632 qdf_mem_free(send_addba);
633 return;
634 }
635
636 status = wmi_unified_addba_send_cmd_send(wma_handle->wmi_handle,
637 send_addba->mac_addr,
638 &send_addba->param);
639 if (QDF_STATUS_SUCCESS != status) {
640 WMA_LOGE(FL("Failed to process WMA_SEND_ADDBA_REQ"));
641 }
642 WMA_LOGD(FL("sent ADDBA req to" MAC_ADDRESS_STR "tid %d buff_size %d"),
643 MAC_ADDR_ARRAY(send_addba->mac_addr),
644 send_addba->param.tidno,
645 send_addba->param.buffersize);
646
647 qdf_mem_free(send_addba);
648}
649
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650/**
Yun Parkb4f591d2017-03-29 15:51:01 -0700651 * wma_ipa_get_stat() - get IPA data path stats from FW
652 *
653 * Return: 0 on success, errno on failure
654 */
655#ifdef IPA_OFFLOAD
656static int wma_ipa_get_stat(void)
657{
658 struct cdp_pdev *pdev;
659
660 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
661 if (!pdev) {
662 WMA_LOGE("pdev NULL for uc stat");
663 return -EINVAL;
664 }
665 cdp_ipa_get_stat(cds_get_context(QDF_MODULE_ID_SOC), pdev);
666
667 return 0;
668}
669#else
670static int wma_ipa_get_stat(void)
671{
672 return 0;
673}
674#endif
675
676/**
677 * wma_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
678 * @privcmd: private command
679 *
680 * Return: 0 on success, errno on failure
681 */
682#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
683static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
684{
685 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
686 struct cdp_pdev *pdev;
687 uint8_t reset_stats = privcmd->param_value;
688
689 WMA_LOGD("%s: reset_stats=%d",
690 "WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID",
691 reset_stats);
692 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
693 if (!pdev) {
694 WMA_LOGE("pdev NULL for uc get share stats");
695 return -EINVAL;
696 }
697 cdp_ipa_uc_get_share_stats(soc, pdev, reset_stats);
698
699 return 0;
700}
701#else
702static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
703{
704 return 0;
705}
706#endif
707
708/**
709 * wma_ipa_uc_set_quota() - set quota limit to FW
710 * @privcmd: private command
711 *
712 * Return: 0 on success, errno on failure
713 */
714#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
715static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
716{
717 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
718 struct cdp_pdev *pdev;
719 uint64_t quota_bytes = privcmd->param_sec_value;
720
721 quota_bytes <<= 32;
722 quota_bytes |= privcmd->param_value;
723
724 WMA_LOGD("%s: quota_bytes=%llu",
725 "WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID",
726 quota_bytes);
727 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
728 if (!pdev) {
729 WMA_LOGE("pdev NULL for uc set quota");
730 return -EINVAL;
731 }
732 cdp_ipa_uc_set_quota(soc, pdev, quota_bytes);
733
734 return 0;
735}
736#else
737static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
738{
739 return 0;
740}
741#endif
742
743/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 * wma_set_priv_cfg() - set private config parameters
745 * @wma_handle: wma handle
746 * @privcmd: private command
747 *
748 * Return: 0 for success or error code
749 */
750static int32_t wma_set_priv_cfg(tp_wma_handle wma_handle,
751 wma_cli_set_cmd_t *privcmd)
752{
753 int32_t ret = 0;
754
755 switch (privcmd->param_id) {
756 case WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID:
757 ret = wma_set_txrx_fw_stats_level(wma_handle,
758 privcmd->param_vdev_id,
759 privcmd->param_value);
760 break;
761 case WMA_VDEV_TXRX_FWSTATS_RESET_CMDID:
762 ret = wma_txrx_fw_stats_reset(wma_handle,
763 privcmd->param_vdev_id,
764 privcmd->param_value);
765 break;
766 case WMI_STA_SMPS_FORCE_MODE_CMDID:
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800767 ret = wma_set_mimops(wma_handle,
768 privcmd->param_vdev_id,
769 privcmd->param_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770 break;
771 case WMI_STA_SMPS_PARAM_CMDID:
772 wma_set_smps_params(wma_handle, privcmd->param_vdev_id,
773 privcmd->param_value);
774 break;
775 case WMA_VDEV_MCC_SET_TIME_LATENCY:
776 {
777 /* Extract first MCC adapter/vdev channel number and latency */
778 uint8_t mcc_channel = privcmd->param_value & 0x000000FF;
779 uint8_t mcc_channel_latency =
780 (privcmd->param_value & 0x0000FF00) >> 8;
781 int ret = -1;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783 WMA_LOGD("%s: Parsed input: Channel #1:%d, latency:%dms",
784 __func__, mcc_channel, mcc_channel_latency);
785 ret = wma_set_mcc_channel_time_latency(wma_handle,
786 mcc_channel,
787 mcc_channel_latency);
788 }
789 break;
790 case WMA_VDEV_MCC_SET_TIME_QUOTA:
791 {
792 /* Extract the MCC 2 adapters/vdevs channel numbers and time
793 * quota value for the first adapter only (which is specified
794 * in iwpriv command.
795 */
796 uint8_t adapter_2_chan_number =
797 privcmd->param_value & 0x000000FF;
798 uint8_t adapter_1_chan_number =
799 (privcmd->param_value & 0x0000FF00) >> 8;
800 uint8_t adapter_1_quota =
801 (privcmd->param_value & 0x00FF0000) >> 16;
802 int ret = -1;
803
804 WMA_LOGD("%s: Parsed input: Channel #1:%d, Channel #2:%d, quota 1:%dms",
805 __func__, adapter_1_chan_number,
806 adapter_2_chan_number, adapter_1_quota);
807
808 ret = wma_set_mcc_channel_time_quota(wma_handle,
809 adapter_1_chan_number,
810 adapter_1_quota,
811 adapter_2_chan_number);
812 }
813 break;
814 case WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE:
815 {
816 wma_handle->wma_ibss_power_save_params.atimWindowLength =
817 privcmd->param_value;
818 WMA_LOGD("%s: IBSS power save ATIM Window = %d",
819 __func__, wma_handle->wma_ibss_power_save_params.
820 atimWindowLength);
821 }
822 break;
823 case WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED:
824 {
825 wma_handle->wma_ibss_power_save_params.isPowerSaveAllowed =
826 privcmd->param_value;
827 WMA_LOGD("%s: IBSS is Power Save Allowed = %d",
828 __func__, wma_handle->wma_ibss_power_save_params.
829 isPowerSaveAllowed);
830 }
831 break;
832 case WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED:
833 {
834 wma_handle->wma_ibss_power_save_params. isPowerCollapseAllowed =
835 privcmd->param_value;
836 WMA_LOGD("%s: IBSS is Power Collapse Allowed = %d",
837 __func__, wma_handle->wma_ibss_power_save_params.
838 isPowerCollapseAllowed);
839 }
840 break;
841 case WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX:
842 {
843 wma_handle->wma_ibss_power_save_params.isAwakeonTxRxEnabled =
844 privcmd->param_value;
845 WMA_LOGD("%s: IBSS Power Save Awake on Tx/Rx Enabled = %d",
846 __func__, wma_handle->wma_ibss_power_save_params.
847 isAwakeonTxRxEnabled);
848 }
849 break;
850 case WMA_VDEV_IBSS_SET_INACTIVITY_TIME:
851 {
852 wma_handle->wma_ibss_power_save_params.inactivityCount =
853 privcmd->param_value;
854 WMA_LOGD("%s: IBSS Power Save Data Inactivity Count = %d",
855 __func__, wma_handle->wma_ibss_power_save_params.
856 inactivityCount);
857 }
858 break;
859 case WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME:
860 {
861 wma_handle->wma_ibss_power_save_params.txSPEndInactivityTime =
862 privcmd->param_value;
863 WMA_LOGD("%s: IBSS Power Save Transmit EOSP inactivity time out = %d",
864 __func__, wma_handle->wma_ibss_power_save_params.
865 txSPEndInactivityTime);
866 }
867 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 case WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS:
869 {
870 wma_handle->wma_ibss_power_save_params.ibssPsWarmupTime =
871 privcmd->param_value;
872 WMA_LOGD("%s: IBSS Power Save Warm Up Time in Seconds = %d",
873 __func__, wma_handle->wma_ibss_power_save_params.
874 ibssPsWarmupTime);
875 }
876 break;
877 case WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW:
878 {
879 wma_handle->wma_ibss_power_save_params.ibssPs1RxChainInAtimEnable
880 = privcmd->param_value;
881 WMA_LOGD("%s: IBSS Power Save single RX Chain Enable In ATIM = %d",
882 __func__, wma_handle->wma_ibss_power_save_params.
883 ibssPs1RxChainInAtimEnable);
884 }
885 break;
886
887 case WMA_VDEV_TXRX_GET_IPA_UC_FW_STATS_CMDID:
888 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700889 wma_ipa_get_stat();
Yun Park637d6482016-10-05 10:51:33 -0700890 }
891 break;
892
893 case WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID:
894 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700895 wma_ipa_uc_get_share_stats(privcmd);
Yun Park637d6482016-10-05 10:51:33 -0700896 }
897 break;
898
899 case WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID:
900 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700901 wma_ipa_uc_set_quota(privcmd);
Yun Park327e7812017-02-14 15:18:10 -0800902
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 }
904 break;
905
906 default:
907 WMA_LOGE("Invalid wma config command id:%d", privcmd->param_id);
908 ret = -EINVAL;
909 }
910 return ret;
911}
912
913/**
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -0800914 * wma_set_dtim_period() - set dtim period to FW
915 * @wma: wma handle
916 * @dtim_params: dtim params
917 *
918 * Return: none
919 */
920static void wma_set_dtim_period(tp_wma_handle wma,
921 struct set_dtim_params *dtim_params)
922{
923 struct wma_txrx_node *iface =
924 &wma->interfaces[dtim_params->session_id];
925 if (!wma_is_vdev_valid(dtim_params->session_id)) {
926 WMA_LOGE("%s: invalid VDEV", __func__);
927 return;
928 }
929 WMA_LOGD("%s: set dtim_period %d", __func__,
930 dtim_params->dtim_period);
931 iface->dtimPeriod = dtim_params->dtim_period;
932
933}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934
935/**
936 * wma_process_cli_set_cmd() - set parameters to fw
937 * @wma: wma handle
938 * @privcmd: command
939 *
940 * Return: none
941 */
942static void wma_process_cli_set_cmd(tp_wma_handle wma,
943 wma_cli_set_cmd_t *privcmd)
944{
Govind Singhd76a5b02016-03-08 15:12:14 +0530945 int vid = privcmd->param_vdev_id, pps_val = 0;
946 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 struct wma_txrx_node *intr = wma->interfaces;
Jeff Johnson9f18aa72018-12-02 12:05:12 -0800948 struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949 struct qpower_params *qparams = &intr[vid].config.qpower_params;
Govind Singhd76a5b02016-03-08 15:12:14 +0530950 struct pdev_params pdev_param;
Leo Chang96464902016-10-28 11:10:54 -0700951 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Arunk Khandavalli2462f462018-01-25 14:41:02 +0530952 struct target_psoc_info *tgt_hdl;
Kiran Kumar Lokere9f881ae2018-03-07 18:59:30 -0800953 struct sir_set_tx_rx_aggregation_size aggr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954
Jeff Johnsonadba3962017-09-18 08:12:35 -0700955 WMA_LOGD("wmihandle %pK", wma->wmi_handle);
Arif Hussain0e246802018-05-01 18:13:44 -0700956 qdf_mem_zero(&aggr, sizeof(aggr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957
Jeff Johnsonfe8dc692018-11-22 08:45:13 -0800958 if (NULL == mac) {
959 WMA_LOGE("%s: Failed to get mac", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 return;
961 }
962
Arunk Khandavalli2462f462018-01-25 14:41:02 +0530963 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma->psoc);
964 if (!tgt_hdl) {
965 WMA_LOGE("%s: target psoc info is NULL", __func__);
966 return;
967 }
968
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 if (privcmd->param_id >= WMI_CMDID_MAX) {
970 /*
971 * This configuration setting is not done using any wmi
972 * command, call appropriate handler.
973 */
974 if (wma_set_priv_cfg(wma, privcmd))
975 WMA_LOGE("Failed to set wma priv congiuration");
976 return;
977 }
978
979 switch (privcmd->param_vp_dev) {
980 case VDEV_CMD:
Pragaspathi Thilagarajf81a8f02018-08-15 21:44:07 +0530981 if (!wma_is_vdev_valid(privcmd->param_vdev_id)) {
Bhargav Shaha89d3b42016-04-20 13:04:56 +0530982 WMA_LOGE("%s Vdev id is not valid", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700983 return;
Bhargav Shaha89d3b42016-04-20 13:04:56 +0530984 }
985
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
987 privcmd->param_id, privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530988 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 privcmd->param_vdev_id,
990 privcmd->param_id,
991 privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +0530992 if (QDF_IS_STATUS_ERROR(ret)) {
993 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994 ret);
995 return;
996 }
997 break;
998 case PDEV_CMD:
999 WMA_LOGD("pdev pid %d pval %d", privcmd->param_id,
1000 privcmd->param_value);
1001 if ((privcmd->param_id == WMI_PDEV_PARAM_RX_CHAIN_MASK) ||
1002 (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK)) {
Jiachao Wu08719b02017-07-05 13:05:34 +08001003 if (QDF_STATUS_SUCCESS !=
1004 wma_check_txrx_chainmask(
Arunk Khandavalli2462f462018-01-25 14:41:02 +05301005 target_if_get_num_rf_chains(tgt_hdl),
Jiachao Wu08719b02017-07-05 13:05:34 +08001006 privcmd->param_value)) {
1007 WMA_LOGD("Chainmask value is invalid");
1008 return;
1009 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 }
Govind Singhd76a5b02016-03-08 15:12:14 +05301011 pdev_param.param_id = privcmd->param_id;
1012 pdev_param.param_value = privcmd->param_value;
1013 ret = wmi_unified_pdev_param_send(wma->wmi_handle,
1014 &pdev_param,
1015 WMA_WILDCARD_PDEV_ID);
1016 if (QDF_IS_STATUS_ERROR(ret)) {
1017 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 ret);
1019 return;
1020 }
1021 break;
1022 case GEN_CMD:
1023 {
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001024 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 struct wma_txrx_node *intr = wma->interfaces;
1026
1027 vdev = wma_find_vdev_by_id(wma, privcmd->param_vdev_id);
1028 if (!vdev) {
1029 WMA_LOGE("%s:Invalid vdev handle", __func__);
1030 return;
1031 }
1032
1033 WMA_LOGD("gen pid %d pval %d", privcmd->param_id,
1034 privcmd->param_value);
1035
1036 switch (privcmd->param_id) {
Arif Hussain0e246802018-05-01 18:13:44 -07001037 case GEN_VDEV_PARAM_AMSDU:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 case GEN_VDEV_PARAM_AMPDU:
Lin Baic1351142018-05-17 11:50:01 +08001039 if (!soc) {
1040 WMA_LOGE("%s:SOC context is NULL", __func__);
1041 return;
1042 }
1043
1044 if (privcmd->param_id == GEN_VDEV_PARAM_AMPDU) {
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301045 ret = cdp_aggr_cfg(soc, vdev,
1046 privcmd->param_value, 0);
1047 if (ret)
1048 WMA_LOGE("cdp_aggr_cfg set ampdu failed ret %d",
1049 ret);
1050 else
1051 intr[privcmd->param_vdev_id].config.
1052 ampdu = privcmd->param_value;
Arif Hussain0e246802018-05-01 18:13:44 -07001053
Lin Baic1351142018-05-17 11:50:01 +08001054 aggr.aggr_type =
1055 WMI_VDEV_CUSTOM_AGGR_TYPE_AMPDU;
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301056 } else {
Lin Baic1351142018-05-17 11:50:01 +08001057 aggr.aggr_type =
1058 WMI_VDEV_CUSTOM_AGGR_TYPE_AMSDU;
1059 }
1060
1061 aggr.vdev_id = vid;
1062 aggr.tx_aggregation_size = privcmd->param_value;
1063 aggr.rx_aggregation_size = privcmd->param_value;
1064
1065 ret = wma_set_tx_rx_aggregation_size(&aggr);
1066 if (QDF_IS_STATUS_ERROR(ret)) {
1067 WMA_LOGE("set_aggr_size failed ret %d", ret);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301068 return;
1069 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 case GEN_PARAM_CRASH_INJECT:
Rajeev Kumar0a9901b2015-12-15 15:59:19 -08001072 if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
1073 WMA_LOGE("Crash inject not allowed in FTM mode");
1074 else
1075 ret = wma_crash_inject(wma,
1076 privcmd->param_value,
1077 privcmd->param_sec_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001079 case GEN_PARAM_CAPTURE_TSF:
1080 ret = wma_capture_tsf(wma, privcmd->param_value);
1081 break;
1082 case GEN_PARAM_RESET_TSF_GPIO:
1083 ret = wma_reset_tsf_gpio(wma, privcmd->param_value);
1084 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 default:
1086 WMA_LOGE("Invalid param id 0x%x",
1087 privcmd->param_id);
1088 break;
1089 }
1090 break;
1091 }
1092 case DBG_CMD:
1093 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1094 privcmd->param_value);
1095 switch (privcmd->param_id) {
1096 case WMI_DBGLOG_LOG_LEVEL:
1097 ret = dbglog_set_log_lvl(wma->wmi_handle,
1098 privcmd->param_value);
1099 if (ret)
1100 WMA_LOGE("dbglog_set_log_lvl failed ret %d",
1101 ret);
1102 break;
1103 case WMI_DBGLOG_VAP_ENABLE:
1104 ret = dbglog_vap_log_enable(wma->wmi_handle,
1105 privcmd->param_value, true);
1106 if (ret)
1107 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1108 ret);
1109 break;
1110 case WMI_DBGLOG_VAP_DISABLE:
1111 ret = dbglog_vap_log_enable(wma->wmi_handle,
1112 privcmd->param_value, false);
1113 if (ret)
1114 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1115 ret);
1116 break;
1117 case WMI_DBGLOG_MODULE_ENABLE:
1118 ret = dbglog_module_log_enable(wma->wmi_handle,
1119 privcmd->param_value, true);
1120 if (ret)
1121 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1122 ret);
1123 break;
1124 case WMI_DBGLOG_MODULE_DISABLE:
1125 ret = dbglog_module_log_enable(wma->wmi_handle,
1126 privcmd->param_value, false);
1127 if (ret)
1128 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1129 ret);
1130 break;
1131 case WMI_DBGLOG_MOD_LOG_LEVEL:
1132 ret = dbglog_set_mod_log_lvl(wma->wmi_handle,
1133 privcmd->param_value);
1134 if (ret)
1135 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1136 ret);
1137 break;
1138 case WMI_DBGLOG_TYPE:
1139 ret = dbglog_parser_type_init(wma->wmi_handle,
1140 privcmd->param_value);
1141 if (ret)
1142 WMA_LOGE("dbglog_parser_type_init failed ret %d",
1143 ret);
1144 break;
1145 case WMI_DBGLOG_REPORT_ENABLE:
1146 ret = dbglog_report_enable(wma->wmi_handle,
1147 privcmd->param_value);
1148 if (ret)
1149 WMA_LOGE("dbglog_report_enable failed ret %d",
1150 ret);
1151 break;
Govind Singha471e5e2015-10-12 17:11:14 +05301152 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301153 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301154 WMI_WLAN_PROFILE_TRIGGER_CMDID,
1155 privcmd->param_value, 0);
1156 if (ret)
1157 WMA_LOGE("Profile cmd failed for %d ret %d",
1158 WMI_WLAN_PROFILE_TRIGGER_CMDID, ret);
1159 break;
1160 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301161 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301162 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1163 privcmd->param_value,
1164 privcmd->param_sec_value);
1165 if (ret)
1166 WMA_LOGE("Profile cmd failed for %d ret %d",
1167 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1168 ret);
1169 break;
1170 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301171 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301172 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1173 privcmd->param_value,
1174 privcmd->param_sec_value);
1175 if (ret)
1176 WMA_LOGE("Profile cmd failed for %d ret %d",
1177 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1178 ret);
1179 break;
1180 case WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301181 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301182 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1183 0, 0);
1184 if (ret)
1185 WMA_LOGE("Profile cmd failed for %d ret %d",
1186 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1187 ret);
1188 break;
1189 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301190 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301191 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1192 0, 0);
1193 if (ret)
1194 WMA_LOGE("Profile cmd failed for %d ret %d",
1195 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1196 ret);
1197 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 case WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID:
1199 /* Set the Green AP */
Govind Singhd76a5b02016-03-08 15:12:14 +05301200 ret = wmi_unified_green_ap_ps_send
1201 (wma->wmi_handle, privcmd->param_value,
1202 WMA_WILDCARD_PDEV_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 if (ret) {
1204 WMA_LOGE("Set GreenAP Failed val %d",
1205 privcmd->param_value);
1206 }
1207 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208
1209 default:
1210 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1211 break;
1212 }
1213 break;
1214 case PPS_CMD:
1215 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1216 privcmd->param_value);
1217 switch (privcmd->param_id) {
1218
1219 case WMI_VDEV_PPS_PAID_MATCH:
1220 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1221 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
1222 intr[vid].config.pps_params.paid_match_enable =
1223 privcmd->param_value;
1224 break;
1225 case WMI_VDEV_PPS_GID_MATCH:
1226 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1227 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
1228 intr[vid].config.pps_params.gid_match_enable =
1229 privcmd->param_value;
1230 break;
1231 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
1232 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1233 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
1234 intr[vid].config.pps_params.tim_clear =
1235 privcmd->param_value;
1236 break;
1237 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
1238 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1239 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
1240 intr[vid].config.pps_params.dtim_clear =
1241 privcmd->param_value;
1242 break;
1243 case WMI_VDEV_PPS_EOF_PAD_DELIM:
1244 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1245 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
1246 intr[vid].config.pps_params.eof_delim =
1247 privcmd->param_value;
1248 break;
1249 case WMI_VDEV_PPS_MACADDR_MISMATCH:
1250 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1251 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
1252 intr[vid].config.pps_params.mac_match =
1253 privcmd->param_value;
1254 break;
1255 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
1256 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1257 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
1258 intr[vid].config.pps_params.delim_fail =
1259 privcmd->param_value;
1260 break;
1261 case WMI_VDEV_PPS_GID_NSTS_ZERO:
1262 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1263 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
1264 intr[vid].config.pps_params.nsts_zero =
1265 privcmd->param_value;
1266 break;
1267 case WMI_VDEV_PPS_RSSI_CHECK:
1268 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1269 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
1270 intr[vid].config.pps_params.rssi_chk =
1271 privcmd->param_value;
1272 break;
1273 case WMI_VDEV_PPS_5G_EBT:
1274 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1275 (PKT_PWR_SAVE_5G_EBT & 0xffff);
1276 intr[vid].config.pps_params.ebt_5g =
1277 privcmd->param_value;
1278 break;
1279 default:
1280 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1281 break;
1282 }
1283 break;
1284
1285 case QPOWER_CMD:
1286 WMA_LOGD("QPOWER CLI CMD pid %d pval %d", privcmd->param_id,
1287 privcmd->param_value);
1288 switch (privcmd->param_id) {
1289 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
1290 WMA_LOGD("QPOWER CLI CMD:Ps Poll Cnt val %d",
1291 privcmd->param_value);
1292 /* Set the QPower Ps Poll Count */
Govind Singhd76a5b02016-03-08 15:12:14 +05301293 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 vid, WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
1295 privcmd->param_value);
1296 if (ret) {
1297 WMA_LOGE("Set Q-PsPollCnt Failed vdevId %d val %d",
1298 vid, privcmd->param_value);
1299 } else {
1300 qparams->max_ps_poll_cnt = privcmd->param_value;
1301 }
1302 break;
1303 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
1304 WMA_LOGD("QPOWER CLI CMD:Max Tx Before wake val %d",
1305 privcmd->param_value);
1306 /* Set the QPower Max Tx Before Wake */
Govind Singhd76a5b02016-03-08 15:12:14 +05301307 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 vid, WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
1309 privcmd->param_value);
1310 if (ret) {
1311 WMA_LOGE("Set Q-MaxTxBefWake Failed vId %d val %d",
1312 vid, privcmd->param_value);
1313 } else {
1314 qparams->max_tx_before_wake =
1315 privcmd->param_value;
1316 }
1317 break;
1318 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
1319 WMA_LOGD("QPOWER CLI CMD:Ps Poll Wake Inv val %d",
1320 privcmd->param_value);
1321 /* Set the QPower Spec Ps Poll Wake Inv */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001322 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1323 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 privcmd->param_value);
1325 if (ret) {
1326 WMA_LOGE("Set Q-PsPoll WakeIntv Failed vId %d val %d",
1327 vid, privcmd->param_value);
1328 } else {
1329 qparams->spec_ps_poll_wake_interval =
1330 privcmd->param_value;
1331 }
1332 break;
1333 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
1334 WMA_LOGD("QPOWER CLI CMD:Spec NoData Ps Poll val %d",
1335 privcmd->param_value);
1336 /* Set the QPower Spec NoData PsPoll */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001337 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1338 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 privcmd->param_value);
1340 if (ret) {
1341 WMA_LOGE("Set Q-SpecNoDataPsPoll Failed vId %d val %d",
1342 vid, privcmd->param_value);
1343 } else {
1344 qparams->max_spec_nodata_ps_poll =
1345 privcmd->param_value;
1346 }
1347 break;
1348
1349 default:
1350 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1351 break;
1352 }
1353 break;
1354 case GTX_CMD:
1355 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1356 privcmd->param_id, privcmd->param_value);
1357 switch (privcmd->param_id) {
1358 case WMI_VDEV_PARAM_GTX_HT_MCS:
1359 intr[vid].config.gtx_info.gtxRTMask[0] =
1360 privcmd->param_value;
1361 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1362 privcmd->param_vdev_id,
1363 &intr[vid].config.gtx_info);
1364 break;
1365 case WMI_VDEV_PARAM_GTX_VHT_MCS:
1366 intr[vid].config.gtx_info.gtxRTMask[1] =
1367 privcmd->param_value;
1368 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1369 privcmd->param_vdev_id,
1370 &intr[vid].config.gtx_info);
1371 break;
1372
1373 case WMI_VDEV_PARAM_GTX_USR_CFG:
1374 intr[vid].config.gtx_info.gtxUsrcfg =
1375 privcmd->param_value;
1376 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1377 privcmd->param_vdev_id,
1378 &intr[vid].config.gtx_info);
1379 break;
1380
1381 case WMI_VDEV_PARAM_GTX_THRE:
1382 intr[vid].config.gtx_info.gtxPERThreshold =
1383 privcmd->param_value;
1384 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1385 privcmd->param_vdev_id,
1386 &intr[vid].config.gtx_info);
1387 break;
1388
1389 case WMI_VDEV_PARAM_GTX_MARGIN:
1390 intr[vid].config.gtx_info.gtxPERMargin =
1391 privcmd->param_value;
1392 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1393 privcmd->param_vdev_id,
1394 &intr[vid].config.gtx_info);
1395 break;
1396
1397 case WMI_VDEV_PARAM_GTX_STEP:
1398 intr[vid].config.gtx_info.gtxTPCstep =
1399 privcmd->param_value;
1400 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1401 privcmd->param_vdev_id,
1402 &intr[vid].config.gtx_info);
1403 break;
1404
1405 case WMI_VDEV_PARAM_GTX_MINTPC:
1406 intr[vid].config.gtx_info.gtxTPCMin =
1407 privcmd->param_value;
1408 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1409 privcmd->param_vdev_id,
1410 &intr[vid].config.gtx_info);
1411 break;
1412
1413 case WMI_VDEV_PARAM_GTX_BW_MASK:
1414 intr[vid].config.gtx_info.gtxBWMask =
1415 privcmd->param_value;
1416 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1417 privcmd->param_vdev_id,
1418 &intr[vid].config.gtx_info);
1419 if (ret) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001420 WMA_LOGE("wma_vdev_set_param failed ret %d",
1421 ret);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 return;
1423 }
1424 break;
1425 default:
1426 break;
1427 }
1428 break;
1429
1430 default:
1431 WMA_LOGE("Invalid vpdev command id");
1432 }
1433 if (1 == privcmd->param_vp_dev) {
1434 switch (privcmd->param_id) {
1435 case WMI_VDEV_PARAM_NSS:
1436 intr[vid].config.nss = privcmd->param_value;
1437 break;
1438 case WMI_VDEV_PARAM_LDPC:
1439 intr[vid].config.ldpc = privcmd->param_value;
1440 break;
1441 case WMI_VDEV_PARAM_TX_STBC:
1442 intr[vid].config.tx_stbc = privcmd->param_value;
1443 break;
1444 case WMI_VDEV_PARAM_RX_STBC:
1445 intr[vid].config.rx_stbc = privcmd->param_value;
1446 break;
1447 case WMI_VDEV_PARAM_SGI:
1448 intr[vid].config.shortgi = privcmd->param_value;
1449 break;
1450 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
1451 intr[vid].config.rtscts_en = privcmd->param_value;
1452 break;
1453 case WMI_VDEV_PARAM_CHWIDTH:
1454 intr[vid].config.chwidth = privcmd->param_value;
1455 break;
1456 case WMI_VDEV_PARAM_FIXED_RATE:
1457 intr[vid].config.tx_rate = privcmd->param_value;
1458 break;
1459 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE:
1460 intr[vid].config.erx_adjust = privcmd->param_value;
1461 break;
1462 case WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM:
1463 intr[vid].config.erx_bmiss_num = privcmd->param_value;
1464 break;
1465 case WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE:
1466 intr[vid].config.erx_bmiss_cycle = privcmd->param_value;
1467 break;
1468 case WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP:
1469 intr[vid].config.erx_slop_step = privcmd->param_value;
1470 break;
1471 case WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP:
1472 intr[vid].config.erx_init_slop = privcmd->param_value;
1473 break;
1474 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE:
1475 intr[vid].config.erx_adj_pause = privcmd->param_value;
1476 break;
1477 case WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE:
1478 intr[vid].config.erx_dri_sample = privcmd->param_value;
1479 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001480 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001481 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001482 wma_set_he_vdev_param(&intr[vid], privcmd->param_id,
1483 privcmd->param_value);
1484 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 default:
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05301486 WMA_LOGD("Invalid wma_cli_set vdev command/Not yet implemented 0x%x",
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001487 privcmd->param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 break;
1489 }
1490 } else if (2 == privcmd->param_vp_dev) {
1491 switch (privcmd->param_id) {
1492 case WMI_PDEV_PARAM_ANI_ENABLE:
1493 wma->pdevconfig.ani_enable = privcmd->param_value;
1494 break;
1495 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
1496 wma->pdevconfig.ani_poll_len = privcmd->param_value;
1497 break;
1498 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
1499 wma->pdevconfig.ani_listen_len = privcmd->param_value;
1500 break;
1501 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
1502 wma->pdevconfig.ani_ofdm_level = privcmd->param_value;
1503 break;
1504 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
1505 wma->pdevconfig.ani_cck_level = privcmd->param_value;
1506 break;
1507 case WMI_PDEV_PARAM_DYNAMIC_BW:
1508 wma->pdevconfig.cwmenable = privcmd->param_value;
1509 break;
1510 case WMI_PDEV_PARAM_CTS_CBW:
1511 wma->pdevconfig.cts_cbw = privcmd->param_value;
1512 break;
1513 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
1514 wma->pdevconfig.txchainmask = privcmd->param_value;
1515 break;
1516 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
1517 wma->pdevconfig.rxchainmask = privcmd->param_value;
1518 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
1520 wma->pdevconfig.txpow2g = privcmd->param_value;
Jeff Johnsonfe8dc692018-11-22 08:45:13 -08001521 if ((mac->mlme_cfg->gen.band_capability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001522 BAND_ALL) ||
Jeff Johnsonfe8dc692018-11-22 08:45:13 -08001523 (mac->mlme_cfg->gen.band_capability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001524 BAND_2G)) {
Jeff Johnsonfe8dc692018-11-22 08:45:13 -08001525 if (cfg_set_int(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1527 privcmd->param_value) !=
Jeff Johnsone88dd752018-06-07 22:57:54 -07001528 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1530
1531 } else {
1532 WMA_LOGE("Current band is not 2G");
1533 }
1534 break;
1535 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
1536 wma->pdevconfig.txpow5g = privcmd->param_value;
Jeff Johnsonfe8dc692018-11-22 08:45:13 -08001537 if ((mac->mlme_cfg->gen.band_capability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001538 BAND_ALL) ||
Jeff Johnsonfe8dc692018-11-22 08:45:13 -08001539 (mac->mlme_cfg->gen.band_capability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001540 BAND_5G)) {
Jeff Johnsonfe8dc692018-11-22 08:45:13 -08001541 if (cfg_set_int(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1543 privcmd->param_value) !=
Jeff Johnsone88dd752018-06-07 22:57:54 -07001544 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1546
1547 } else {
1548 WMA_LOGE("Current band is not 5G");
1549 }
1550 break;
1551 default:
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001552 WMA_LOGD("Invalid wma_cli_set pdev command/Not yet implemented 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 privcmd->param_id);
1554 break;
1555 }
1556 } else if (5 == privcmd->param_vp_dev) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301557 ret = wma_vdev_set_param(wma->wmi_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001558 privcmd->param_vdev_id,
1559 WMI_VDEV_PARAM_PACKET_POWERSAVE,
1560 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561 if (ret)
1562 WMA_LOGE("Failed to send wmi packet power save cmd");
1563 else
1564 WMA_LOGD("Sent packet power save cmd %d value %x to target",
1565 privcmd->param_id, pps_val);
1566 }
1567}
1568
Dustin Brown05557182017-10-12 14:44:49 -07001569uint32_t wma_critical_events_in_flight(void)
1570{
1571 t_wma_handle *wma;
1572
1573 wma = cds_get_context(QDF_MODULE_ID_WMA);
1574 if (!wma)
1575 return 0;
1576
1577 return qdf_atomic_read(&wma->critical_events_in_flight);
1578}
1579
1580static bool wma_event_is_critical(uint32_t event_id)
1581{
1582 switch (event_id) {
1583 case WMI_ROAM_SYNCH_EVENTID:
1584 return true;
1585 default:
1586 return false;
1587 }
1588}
1589
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590/**
1591 * wma_process_fw_event() - process any fw event
1592 * @wma: wma handle
1593 * @buf: fw event buffer
1594 *
1595 * This function process any fw event to serialize it through mc thread.
1596 *
1597 * Return: none
1598 */
1599static int wma_process_fw_event(tp_wma_handle wma,
1600 wma_process_fw_event_params *buf)
1601{
1602 struct wmi_unified *wmi_handle = (struct wmi_unified *)buf->wmi_handle;
Dustin Brown05557182017-10-12 14:44:49 -07001603 uint32_t event_id = WMI_GET_FIELD(qdf_nbuf_data(buf->evt_buf),
1604 WMI_CMD_HDR, COMMANDID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605
1606 wmi_process_fw_event(wmi_handle, buf->evt_buf);
Dustin Brown05557182017-10-12 14:44:49 -07001607
1608 if (wma_event_is_critical(event_id))
1609 qdf_atomic_dec(&wma->critical_events_in_flight);
1610
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 return 0;
1612}
1613
1614/**
Govind Singhd76a5b02016-03-08 15:12:14 +05301615 * wmi_process_fw_event_tasklet_ctx() - process in tasklet context
1616 * @ctx: handle to wmi
1617 * @ev: wmi event buffer
1618 *
1619 * Event process by below function will be in tasket context,
1620 * need to use this method only for time sensitive functions.
1621 *
1622 * Return: none
1623 */
1624static int wma_process_fw_event_tasklet_ctx(void *ctx, void *ev)
1625{
1626 wmi_process_fw_event(ctx, ev);
1627
1628 return 0;
1629}
1630
1631/**
Manjeet Singhf82ed072016-07-08 11:40:00 +05301632 * wma_process_hal_pwr_dbg_cmd() - send hal pwr dbg cmd to fw.
1633 * @handle: wma handle
1634 * @sir_pwr_dbg_params: unit test command
1635 *
1636 * This function send unit test command to fw.
1637 *
1638 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
1639 */
1640QDF_STATUS wma_process_hal_pwr_dbg_cmd(WMA_HANDLE handle,
1641 struct sir_mac_pwr_dbg_cmd *
1642 sir_pwr_dbg_params)
1643{
1644 tp_wma_handle wma_handle = (tp_wma_handle)handle;
1645 int i;
1646 struct wmi_power_dbg_params wmi_pwr_dbg_params;
1647 QDF_STATUS status;
1648
1649 if (!sir_pwr_dbg_params) {
1650 WMA_LOGE("%s: sir_pwr_dbg_params is null", __func__);
1651 return QDF_STATUS_E_INVAL;
1652 }
1653 wmi_pwr_dbg_params.module_id = sir_pwr_dbg_params->module_id;
1654 wmi_pwr_dbg_params.pdev_id = sir_pwr_dbg_params->pdev_id;
1655 wmi_pwr_dbg_params.num_args = sir_pwr_dbg_params->num_args;
1656
1657 for (i = 0; i < wmi_pwr_dbg_params.num_args; i++)
1658 wmi_pwr_dbg_params.args[i] = sir_pwr_dbg_params->args[i];
1659
1660 status = wmi_unified_send_power_dbg_cmd(wma_handle->wmi_handle,
1661 &wmi_pwr_dbg_params);
1662
1663 return status;
1664}
1665
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001666static void wma_discard_fw_event(struct scheduler_msg *msg)
1667{
Will Huang9323e852018-02-02 17:55:15 +08001668 if (!msg->bodyptr)
1669 return;
1670
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001671 switch (msg->type) {
1672 case WMA_PROCESS_FW_EVENT:
1673 qdf_nbuf_free(((wma_process_fw_event_params *)msg->bodyptr)
1674 ->evt_buf);
1675 break;
Abhishek Singhcaf6a652017-07-06 17:35:42 +05301676 case WMA_SET_LINK_STATE:
1677 qdf_mem_free(((tpLinkStateParams) msg->bodyptr)->callbackArg);
1678 break;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001679 }
Will Huang9323e852018-02-02 17:55:15 +08001680
1681 qdf_mem_free(msg->bodyptr);
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001682 msg->bodyptr = NULL;
1683 msg->bodyval = 0;
1684 msg->type = 0;
1685}
1686
gaurank kathpalia748c7272018-10-24 22:05:15 +05301687QDF_STATUS
1688wma_vdev_nss_chain_params_send(uint8_t vdev_id,
1689 struct wlan_mlme_nss_chains *user_cfg)
1690{
1691 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
gaurank kathpalia2fc3b892018-11-14 13:48:44 +05301692 struct vdev_nss_chains vdev_user_cfg;
gaurank kathpalia748c7272018-10-24 22:05:15 +05301693 if (!wma_handle) {
1694 WMA_LOGE("%s: wma_handle is NULL", __func__);
1695 return QDF_STATUS_E_FAILURE;
1696 }
1697
gaurank kathpalia2fc3b892018-11-14 13:48:44 +05301698 vdev_user_cfg.disable_rx_mrc[NSS_CHAINS_BAND_2GHZ] =
1699 user_cfg->disable_rx_mrc[NSS_CHAINS_BAND_2GHZ];
1700 vdev_user_cfg.disable_tx_mrc[NSS_CHAINS_BAND_2GHZ] =
1701 user_cfg->disable_tx_mrc[NSS_CHAINS_BAND_2GHZ];
1702 vdev_user_cfg.disable_rx_mrc[NSS_CHAINS_BAND_5GHZ] =
1703 user_cfg->disable_rx_mrc[NSS_CHAINS_BAND_5GHZ];
1704 vdev_user_cfg.disable_tx_mrc[NSS_CHAINS_BAND_5GHZ] =
1705 user_cfg->disable_tx_mrc[NSS_CHAINS_BAND_5GHZ];
1706
1707 vdev_user_cfg.num_rx_chains[NSS_CHAINS_BAND_2GHZ]
1708 = user_cfg->num_rx_chains[NSS_CHAINS_BAND_2GHZ];
1709 vdev_user_cfg.num_tx_chains[NSS_CHAINS_BAND_2GHZ]
1710 = user_cfg->num_tx_chains[NSS_CHAINS_BAND_2GHZ];
1711 vdev_user_cfg.num_rx_chains[NSS_CHAINS_BAND_5GHZ] =
1712 user_cfg->num_rx_chains[NSS_CHAINS_BAND_5GHZ];
1713 vdev_user_cfg.num_tx_chains[NSS_CHAINS_BAND_5GHZ] =
1714 user_cfg->num_tx_chains[NSS_CHAINS_BAND_5GHZ];
1715
1716 vdev_user_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ] =
1717 user_cfg->rx_nss[NSS_CHAINS_BAND_2GHZ];
1718 vdev_user_cfg.tx_nss[NSS_CHAINS_BAND_2GHZ] =
1719 user_cfg->tx_nss[NSS_CHAINS_BAND_2GHZ];
1720 vdev_user_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ] =
1721 user_cfg->rx_nss[NSS_CHAINS_BAND_5GHZ];
1722 vdev_user_cfg.tx_nss[NSS_CHAINS_BAND_5GHZ] =
1723 user_cfg->tx_nss[NSS_CHAINS_BAND_5GHZ];
1724
1725 vdev_user_cfg.num_tx_chains_11a = user_cfg->num_tx_chains_11a;
1726 vdev_user_cfg.num_tx_chains_11b = user_cfg->num_tx_chains_11b;
1727 vdev_user_cfg.num_tx_chains_11g = user_cfg->num_tx_chains_11g;
1728
gaurank kathpalia748c7272018-10-24 22:05:15 +05301729 return wmi_unified_vdev_nss_chain_params_send(wma_handle->wmi_handle,
1730 vdev_id,
gaurank kathpalia2fc3b892018-11-14 13:48:44 +05301731 &vdev_user_cfg);
gaurank kathpalia748c7272018-10-24 22:05:15 +05301732}
1733
Manjeet Singhf82ed072016-07-08 11:40:00 +05301734/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 * wma_process_fw_event_handler() - common event handler to serialize
1736 * event processing through mc_thread
Govind Singhd76a5b02016-03-08 15:12:14 +05301737 * @ctx: wmi context
1738 * @ev: event buffer
1739 * @rx_ctx: rx execution context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 *
1741 * Return: 0 on success, errno on failure
1742 */
Govind Singhd76a5b02016-03-08 15:12:14 +05301743static int wma_process_fw_event_mc_thread_ctx(void *ctx, void *ev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744{
1745 wma_process_fw_event_params *params_buf;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001746 struct scheduler_msg cds_msg = { 0 };
Dustin Brown05557182017-10-12 14:44:49 -07001747 tp_wma_handle wma;
1748 uint32_t event_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301750 params_buf = qdf_mem_malloc(sizeof(wma_process_fw_event_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 if (!params_buf) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301752 qdf_nbuf_free(ev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 return -ENOMEM;
1754 }
1755
Govind Singhd76a5b02016-03-08 15:12:14 +05301756 params_buf->wmi_handle = (struct wmi_unified *)ctx;
Amar Singhal0cb9a5c2018-07-18 12:31:06 -07001757 params_buf->evt_buf = ev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758
Dustin Brown05557182017-10-12 14:44:49 -07001759 wma = cds_get_context(QDF_MODULE_ID_WMA);
1760 event_id = WMI_GET_FIELD(qdf_nbuf_data(params_buf->evt_buf),
1761 WMI_CMD_HDR, COMMANDID);
1762 if (wma && wma_event_is_critical(event_id))
1763 qdf_atomic_inc(&wma->critical_events_in_flight);
1764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 cds_msg.type = WMA_PROCESS_FW_EVENT;
1766 cds_msg.bodyptr = params_buf;
1767 cds_msg.bodyval = 0;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001768 cds_msg.flush_callback = wma_discard_fw_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301770 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia00861f02018-08-28 19:16:12 +05301771 scheduler_post_message(QDF_MODULE_ID_WMA,
1772 QDF_MODULE_ID_WMA,
1773 QDF_MODULE_ID_WMA, &cds_msg)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001774 WMA_LOGE("%s: Failed to post WMA_PROCESS_FW_EVENT msg",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301776 qdf_nbuf_free(ev);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301777 qdf_mem_free(params_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 return -EFAULT;
1779 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 return 0;
1781
1782}
1783
Govind Singhd76a5b02016-03-08 15:12:14 +05301784/**
1785 * wma_process_fw_event_handler() - common event handler to serialize
1786 * event processing through mc_thread
1787 * @ctx: wmi context
1788 * @ev: event buffer
1789 * @rx_ctx: rx execution context
1790 *
1791 * Return: 0 on success, errno on failure
1792 */
Amar Singhal4228c392018-06-26 15:09:58 -07001793int wma_process_fw_event_handler(void *ctx, void *htc_packet, uint8_t rx_ctx)
Govind Singhd76a5b02016-03-08 15:12:14 +05301794{
1795 int err = 0;
Amar Singhal4228c392018-06-26 15:09:58 -07001796 ol_scn_t scn_handle;
1797 struct wlan_objmgr_psoc *psoc;
1798 struct target_psoc_info *tgt_hdl;
1799 wmi_buf_t evt_buf;
1800 bool is_wmi_ready = false;
1801
1802 evt_buf = (wmi_buf_t) ((HTC_PACKET *)htc_packet)->pPktContext;
1803
1804 scn_handle = ((wmi_unified_t)ctx)->scn_handle;
1805
1806 psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
1807 if (!psoc) {
1808 WMA_LOGE("psoc is null");
1809 return err;
1810 }
1811
Amar Singhal0cb9a5c2018-07-18 12:31:06 -07001812 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
Amar Singhal4228c392018-06-26 15:09:58 -07001813 if (!tgt_hdl) {
1814 WMA_LOGE("target_psoc_info is null");
1815 return err;
1816 }
1817
1818 is_wmi_ready = target_psoc_get_wmi_ready(tgt_hdl);
1819 if (!is_wmi_ready) {
Amar Singhal0cb9a5c2018-07-18 12:31:06 -07001820 WMA_LOGD("fw event recvd before ready event processed");
1821 WMA_LOGD("therefore use worker thread");
Amar Singhal4228c392018-06-26 15:09:58 -07001822 wmi_process_fw_event_worker_thread_ctx(ctx, htc_packet);
1823 return err;
1824 }
Govind Singhd76a5b02016-03-08 15:12:14 +05301825
1826 if (rx_ctx == WMA_RX_SERIALIZER_CTX) {
Amar Singhal4228c392018-06-26 15:09:58 -07001827 err = wma_process_fw_event_mc_thread_ctx(ctx, evt_buf);
Govind Singhd76a5b02016-03-08 15:12:14 +05301828 } else if (rx_ctx == WMA_RX_TASKLET_CTX) {
Amar Singhal4228c392018-06-26 15:09:58 -07001829 wma_process_fw_event_tasklet_ctx(ctx, evt_buf);
Govind Singhd76a5b02016-03-08 15:12:14 +05301830 } else {
1831 WMA_LOGE("%s: invalid wmi event execution context", __func__);
Amar Singhal4228c392018-06-26 15:09:58 -07001832 qdf_nbuf_free(evt_buf);
Govind Singhd76a5b02016-03-08 15:12:14 +05301833 }
1834
1835 return err;
1836}
1837
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838/**
Komal Seelam02d09342016-02-23 18:03:19 +05301839 * wma_init_max_no_of_peers - API to initialize wma configuration params
1840 * @wma_handle: WMA Handle
1841 * @max_peers: Max Peers supported
1842 *
1843 * Return: void
1844 */
Rachit Kankane0106e382018-05-16 18:59:28 +05301845static uint8_t wma_init_max_no_of_peers(tp_wma_handle wma_handle,
Komal Seelam02d09342016-02-23 18:03:19 +05301846 uint16_t max_peers)
1847{
1848 struct wma_ini_config *cfg = wma_get_ini_handle(wma_handle);
Rachit Kankane0106e382018-05-16 18:59:28 +05301849 struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF);
1850 uint32_t tgt_version = hif_get_target_info_handle(scn)->target_version;
1851 uint8_t max_no_of_peers;
1852 uint8_t max_supported_peers = (tgt_version == AR6320_REV1_1_VERSION) ?
1853 MAX_SUPPORTED_PEERS_REV1_1 : MAX_SUPPORTED_PEERS_REV1_3;
Komal Seelam02d09342016-02-23 18:03:19 +05301854
Naveen Rawat35804772016-06-27 15:40:28 -07001855 if (cfg == NULL) {
1856 WMA_LOGE("%s: NULL WMA ini handle", __func__);
Rachit Kankane0106e382018-05-16 18:59:28 +05301857 return 0;
Naveen Rawat35804772016-06-27 15:40:28 -07001858 }
1859
Rachit Kankane0106e382018-05-16 18:59:28 +05301860 max_no_of_peers = (max_peers > max_supported_peers) ?
1861 max_supported_peers : max_peers;
1862 cfg->max_no_of_peers = max_no_of_peers;
1863 return max_no_of_peers;
Komal Seelam02d09342016-02-23 18:03:19 +05301864}
1865
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001866/**
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001867 * wma_cleanup_vdev_resp_queue() - cleanup vdev response queue
1868 * @wma: wma handle
1869 *
1870 * Return: none
1871 */
1872static void wma_cleanup_vdev_resp_queue(tp_wma_handle wma)
1873{
1874 struct wma_target_req *req_msg = NULL;
1875 qdf_list_node_t *node1 = NULL;
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001876
1877 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1878 if (!qdf_list_size(&wma->vdev_resp_queue)) {
1879 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08001880 WMA_LOGD(FL("request queue maybe empty"));
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001881 return;
1882 }
1883
Sandeep Puligilla5ac6bd22017-10-17 12:33:56 -07001884 WMA_LOGD(FL("Cleaning up vdev resp queue"));
1885
Wu Gao30f65eb2017-08-09 19:56:10 +08001886 /* peek front, and then cleanup it in wma_vdev_resp_timer */
1887 while (qdf_list_peek_front(&wma->vdev_resp_queue, &node1) ==
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001888 QDF_STATUS_SUCCESS) {
1889 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001890 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Abhishek Singhc614ec42017-04-25 16:17:34 +05301891 qdf_mc_timer_stop(&req_msg->event_timeout);
1892 wma_vdev_resp_timer(req_msg);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001893 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1894 }
1895 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
1896}
1897
1898/**
Abhishek Singhc614ec42017-04-25 16:17:34 +05301899 * wma_cleanup_hold_req() - cleanup hold request queue
1900 * @wma: wma handle
1901 *
1902 * Return: none
1903 */
1904static void wma_cleanup_hold_req(tp_wma_handle wma)
1905{
1906 struct wma_target_req *req_msg = NULL;
1907 qdf_list_node_t *node1 = NULL;
1908
1909 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
1910 if (!qdf_list_size(&wma->wma_hold_req_queue)) {
1911 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1912 WMA_LOGD(FL("request queue is empty"));
1913 return;
1914 }
1915
Wu Gao30f65eb2017-08-09 19:56:10 +08001916 /* peek front, and then cleanup it in wma_hold_req_timer */
Abhishek Singhc614ec42017-04-25 16:17:34 +05301917 while (QDF_STATUS_SUCCESS ==
Wu Gao30f65eb2017-08-09 19:56:10 +08001918 qdf_list_peek_front(&wma->wma_hold_req_queue, &node1)) {
Abhishek Singhc614ec42017-04-25 16:17:34 +05301919 req_msg = qdf_container_of(node1, struct wma_target_req, node);
1920 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1921 /* Cleanup timeout handler */
1922 qdf_mc_timer_stop(&req_msg->event_timeout);
Abhishek Singhc614ec42017-04-25 16:17:34 +05301923 wma_hold_req_timer(req_msg);
1924 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
1925 }
1926 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
1927}
1928
1929/**
Abhishek Singh0ac37442018-05-02 21:07:57 +05301930 * wma_cleanup_vdev_resp_and_hold_req() - cleaunup the vdev resp and hold req
1931 * queue
1932 * @msg :scheduler msg
1933 *
1934 * Return: QDF_STATUS
1935 */
1936static QDF_STATUS
1937wma_cleanup_vdev_resp_and_hold_req(struct scheduler_msg *msg)
1938{
1939 if (!msg || !msg->bodyptr) {
1940 WMA_LOGE(FL("msg or body pointer is NULL"));
1941 return QDF_STATUS_E_INVAL;
1942 }
1943
1944 wma_cleanup_vdev_resp_queue(msg->bodyptr);
1945 wma_cleanup_hold_req(msg->bodyptr);
1946
1947 return QDF_STATUS_SUCCESS;
1948}
1949
1950/**
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001951 * wma_shutdown_notifier_cb - Shutdown notifer call back
1952 * @priv : WMA handle
1953 *
1954 * During recovery, WMA may wait for resume to complete if the crash happens
1955 * while in suspend. This may cause delays in completing the recovery. This call
1956 * back would be called during recovery and the event is completed so that if
1957 * the resume is waiting on FW to respond then it can get out of the wait so
1958 * that recovery thread can start bringing down all the modules.
1959 *
1960 * Return: None
1961 */
1962static void wma_shutdown_notifier_cb(void *priv)
1963{
1964 tp_wma_handle wma_handle = priv;
Abhishek Singh0ac37442018-05-02 21:07:57 +05301965 struct scheduler_msg msg = { 0 };
1966 QDF_STATUS status;
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001967
Wu Gaod7dd6e42018-10-16 17:22:56 +08001968 ucfg_pmo_psoc_wakeup_host_event_received(wma_handle->psoc);
Rajeev Kumar64beb9f2018-10-10 11:23:51 -07001969 wmi_stop(wma_handle->wmi_handle);
Abhishek Singh0ac37442018-05-02 21:07:57 +05301970
1971 msg.bodyptr = priv;
1972 msg.callback = wma_cleanup_vdev_resp_and_hold_req;
gaurank kathpalia00861f02018-08-28 19:16:12 +05301973 status = scheduler_post_message(QDF_MODULE_ID_WMA,
1974 QDF_MODULE_ID_WMA,
1975 QDF_MODULE_ID_TARGET_IF, &msg);
Abhishek Singh0ac37442018-05-02 21:07:57 +05301976 if (QDF_IS_STATUS_ERROR(status))
1977 WMA_LOGE(FL("Failed to post SYS_MSG_ID_CLEAN_VDEV_RSP_QUEUE"));
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001978}
1979
Mukul Sharma5ff3c582016-09-12 15:23:35 +05301980struct wma_version_info g_wmi_version_info;
1981
Wen Gong3f003382018-05-14 14:26:37 +08001982#ifdef WLAN_FEATURE_MEMDUMP_ENABLE
Komal Seelam02d09342016-02-23 18:03:19 +05301983/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05301984 * wma_state_info_dump() - prints state information of wma layer
1985 * @buf: buffer pointer
1986 * @size: size of buffer to be filled
1987 *
1988 * This function is used to dump state information of wma layer
1989 *
1990 * Return: None
1991 */
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08001992#ifdef QCA_SUPPORT_CP_STATS
1993static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
1994{
1995 uint8_t vdev_id;
1996 uint16_t len = 0;
1997 t_wma_handle *wma;
1998 char *buf = *buf_ptr;
1999 struct wma_txrx_node *iface;
2000 struct wake_lock_stats stats;
2001 struct wlan_objmgr_vdev *vdev;
2002
2003 wma = cds_get_context(QDF_MODULE_ID_WMA);
2004 if (!wma) {
2005 WMA_LOGE("%s: WMA context is invald!", __func__);
2006 return;
2007 }
2008
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05302009 WMA_LOGD("%s: size of buffer: %d", __func__, *size);
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002010
2011 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
2012 iface = &wma->interfaces[vdev_id];
2013 if (!iface->handle)
2014 continue;
2015
2016 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(wma->psoc,
2017 vdev_id, WLAN_LEGACY_WMA_ID);
Yeshwanth Sriram Guntuka0e6f4462018-05-07 17:33:43 +05302018 if (vdev == NULL)
2019 continue;
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002020 ucfg_mc_cp_stats_get_vdev_wake_lock_stats(vdev, &stats);
2021 len += qdf_scnprintf(buf + len, *size - len,
2022 "\n"
2023 "vdev_id %d\n"
2024 "WoW Stats\n"
2025 "\tpno_match %u\n"
2026 "\tpno_complete %u\n"
2027 "\tgscan %u\n"
2028 "\tlow_rssi %u\n"
2029 "\trssi_breach %u\n"
2030 "\tucast %u\n"
2031 "\tbcast %u\n"
2032 "\ticmpv4 %u\n"
2033 "\ticmpv6 %u\n"
2034 "\tipv4_mcast %u\n"
2035 "\tipv6_mcast %u\n"
2036 "\tipv6_mcast_ra %u\n"
2037 "\tipv6_mcast_ns %u\n"
2038 "\tipv6_mcast_na %u\n"
2039 "\toem_response %u\n"
2040 "conn_state %d\n"
2041 "dtimPeriod %d\n"
2042 "chanmode %d\n"
2043 "vht_capable %d\n"
2044 "ht_capable %d\n"
2045 "chan_width %d\n"
2046 "vdev_active %d\n"
2047 "vdev_up %d\n"
2048 "aid %d\n"
2049 "rate_flags %d\n"
2050 "nss %d\n"
2051 "tx_power %d\n"
2052 "max_tx_power %d\n"
2053 "nwType %d\n"
2054 "tx_streams %d\n"
2055 "rx_streams %d\n"
2056 "chain_mask %d\n"
2057 "nss_2g %d\n"
2058 "nss_5g %d",
2059 vdev_id,
2060 stats.pno_match_wake_up_count,
2061 stats.pno_complete_wake_up_count,
2062 stats.gscan_wake_up_count,
2063 stats.low_rssi_wake_up_count,
2064 stats.rssi_breach_wake_up_count,
2065 stats.ucast_wake_up_count,
2066 stats.bcast_wake_up_count,
2067 stats.icmpv4_count,
2068 stats.icmpv6_count,
2069 stats.ipv4_mcast_wake_up_count,
2070 stats.ipv6_mcast_wake_up_count,
2071 stats.ipv6_mcast_ra_stats,
2072 stats.ipv6_mcast_ns_stats,
2073 stats.ipv6_mcast_na_stats,
2074 stats.oem_response_wake_up_count,
2075 iface->conn_state,
2076 iface->dtimPeriod,
2077 iface->chanmode,
2078 iface->vht_capable,
2079 iface->ht_capable,
2080 iface->chan_width,
2081 iface->vdev_active,
2082 wma_is_vdev_up(vdev_id),
2083 iface->aid,
2084 iface->rate_flags,
2085 iface->nss,
2086 iface->tx_power,
2087 iface->max_tx_power,
2088 iface->nwType,
2089 iface->tx_streams,
2090 iface->rx_streams,
2091 iface->chain_mask,
2092 iface->nss_2g,
2093 iface->nss_5g);
Yeshwanth Sriram Guntuka0e6f4462018-05-07 17:33:43 +05302094 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_WMA_ID);
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002095 }
2096
2097 *size -= len;
2098 *buf_ptr += len;
2099}
2100#else /* QCA_SUPPORT_CP_STATS */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302101static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
2102{
Dustin Brown9d797d62017-01-11 16:39:12 -08002103 t_wma_handle *wma;
2104 struct sir_vdev_wow_stats *stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302105 uint16_t len = 0;
2106 char *buf = *buf_ptr;
2107 struct wma_txrx_node *iface;
2108 uint8_t vdev_id;
2109
Dustin Brown9d797d62017-01-11 16:39:12 -08002110 wma = cds_get_context(QDF_MODULE_ID_WMA);
2111 if (!wma) {
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302112 WMA_LOGE("%s: WMA context is invald!", __func__);
2113 return;
2114 }
2115
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002116 WMA_LOGE("%s: size of buffer: %d", __func__, *size);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302117
Dustin Brown9d797d62017-01-11 16:39:12 -08002118 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
2119 iface = &wma->interfaces[vdev_id];
2120 if (!iface->handle)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302121 continue;
2122
Dustin Brown9d797d62017-01-11 16:39:12 -08002123 stats = &iface->wow_stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302124 len += qdf_scnprintf(buf + len, *size - len,
Dustin Brown9d797d62017-01-11 16:39:12 -08002125 "\n"
2126 "vdev_id %d\n"
2127 "WoW Stats\n"
2128 "\tpno_match %u\n"
2129 "\tpno_complete %u\n"
2130 "\tgscan %u\n"
2131 "\tlow_rssi %u\n"
2132 "\trssi_breach %u\n"
2133 "\tucast %u\n"
2134 "\tbcast %u\n"
2135 "\ticmpv4 %u\n"
2136 "\ticmpv6 %u\n"
2137 "\tipv4_mcast %u\n"
2138 "\tipv6_mcast %u\n"
2139 "\tipv6_mcast_ra %u\n"
2140 "\tipv6_mcast_ns %u\n"
2141 "\tipv6_mcast_na %u\n"
2142 "\toem_response %u\n"
2143 "conn_state %d\n"
2144 "dtimPeriod %d\n"
2145 "chanmode %d\n"
2146 "vht_capable %d\n"
2147 "ht_capable %d\n"
2148 "chan_width %d\n"
2149 "vdev_active %d\n"
2150 "vdev_up %d\n"
2151 "aid %d\n"
2152 "rate_flags %d\n"
2153 "nss %d\n"
2154 "tx_power %d\n"
2155 "max_tx_power %d\n"
2156 "nwType %d\n"
2157 "tx_streams %d\n"
2158 "rx_streams %d\n"
2159 "chain_mask %d\n"
2160 "nss_2g %d\n"
2161 "nss_5g %d",
2162 vdev_id,
2163 stats->pno_match,
2164 stats->pno_complete,
2165 stats->gscan,
2166 stats->low_rssi,
2167 stats->rssi_breach,
2168 stats->ucast,
2169 stats->bcast,
2170 stats->icmpv4,
2171 stats->icmpv6,
2172 stats->ipv4_mcast,
2173 stats->ipv6_mcast,
2174 stats->ipv6_mcast_ra,
2175 stats->ipv6_mcast_ns,
2176 stats->ipv6_mcast_na,
2177 stats->oem_response,
2178 iface->conn_state,
2179 iface->dtimPeriod,
2180 iface->chanmode,
2181 iface->vht_capable,
2182 iface->ht_capable,
2183 iface->chan_width,
2184 iface->vdev_active,
Mukul Sharmaf9047232017-03-02 16:58:56 +05302185 wma_is_vdev_up(vdev_id),
Dustin Brown9d797d62017-01-11 16:39:12 -08002186 iface->aid,
2187 iface->rate_flags,
2188 iface->nss,
2189 iface->tx_power,
2190 iface->max_tx_power,
2191 iface->nwType,
2192 iface->tx_streams,
2193 iface->rx_streams,
2194 iface->chain_mask,
2195 iface->nss_2g,
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302196 iface->nss_5g);
2197 }
2198
2199 *size -= len;
2200 *buf_ptr += len;
2201}
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002202#endif /* QCA_SUPPORT_CP_STATS */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302203
2204/**
2205 * wma_register_debug_callback() - registration function for wma layer
2206 * to print wma state information
2207 */
2208static void wma_register_debug_callback(void)
2209{
2210 qdf_register_debug_callback(QDF_MODULE_ID_WMA, &wma_state_info_dump);
2211}
Wen Gong3f003382018-05-14 14:26:37 +08002212#else /* WLAN_FEATURE_MEMDUMP_ENABLE */
Wen Gongaa6d55d2018-04-26 16:33:21 +08002213static void wma_register_debug_callback(void)
2214{
2215}
Wen Gong3f003382018-05-14 14:26:37 +08002216#endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
Frank Liu65b17d92016-11-23 15:58:44 +08002217/**
2218 * wma_register_tx_ops_handler() - register tx_ops of southbound
2219 * @tx_ops: tx_ops pointer in southbound
2220 *
2221 * Return: 0 on success, errno on failure
2222 */
2223static QDF_STATUS
2224wma_register_tx_ops_handler(struct wlan_lmac_if_tx_ops *tx_ops)
2225{
2226 /*
2227 * Assign tx_ops, it's up to UMAC modules to declare and define these
2228 * functions which are used to send wmi command to target.
2229 */
2230
Himanshu Agarwalce716f82016-12-21 19:07:54 +05302231 if (!tx_ops) {
2232 WMA_LOGE("%s: pointer to lmac if tx ops is NULL", __func__);
2233 return QDF_STATUS_E_INVAL;
2234 }
2235
2236 /* mgmt_txrx component's tx ops */
2237 tx_ops->mgmt_txrx_tx_ops.mgmt_tx_send = wma_mgmt_unified_cmd_send;
2238
Sravan Kumar Kairam0fbaefe2018-09-10 16:57:50 +05302239 /* mgmt txrx component nbuf op for nbuf dma unmap */
2240 tx_ops->mgmt_txrx_tx_ops.tx_drain_nbuf_op = wma_mgmt_nbuf_unmap_cb;
2241
Frank Liu65b17d92016-11-23 15:58:44 +08002242 return QDF_STATUS_SUCCESS;
2243}
2244
2245/**
2246 * wma_target_if_open() - Attach UMAC modules' interface with wmi layer
2247 * @wma_handle: wma handle
2248 *
2249 * Separate module defines below functions:
2250 * 1. tgt_wmi_<module>_<action> api sends wmi command, assigned to south bound
2251 * tx_ops function pointers;
2252 * 2. module's south dispatcher handles information from lower layer, assigned
2253 * to south bound rx_ops function pointers;
2254 * 3. wmi event handler deals with wmi event, extracts umac needed information,
2255 * and call rx_ops(module's dispatcher). It executes in tasklet context and
2256 * is up to dispatcher to decide the context to reside in tasklet or in
2257 * thread context.
2258 *
2259 * Return: None
2260 */
2261static void wma_target_if_open(tp_wma_handle wma_handle)
2262{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302263 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002264
2265 if (!psoc)
2266 return;
2267
Mukul Sharmadad267e2017-02-04 13:25:34 +05302268 wlan_global_lmac_if_set_txops_registration_cb(WLAN_DEV_OL,
2269 target_if_register_tx_ops);
2270 wlan_lmac_if_set_umac_txops_registration_cb(
2271 wma_register_tx_ops_handler);
2272 wlan_global_lmac_if_open(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002273
Frank Liu65b17d92016-11-23 15:58:44 +08002274}
2275
2276/**
2277 * wma_target_if_close() - Detach UMAC modules' interface with wmi layer
2278 * @wma_handle: wma handle
2279 *
2280 * Return: None
2281 */
2282static void wma_target_if_close(tp_wma_handle wma_handle)
2283{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302284 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002285
2286 if (!psoc)
2287 return;
2288
Mukul Sharmadad267e2017-02-04 13:25:34 +05302289 wlan_global_lmac_if_close(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002290}
Frank Liu65b17d92016-11-23 15:58:44 +08002291
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302292/**
Himanshu Agarwal2228e072018-01-24 17:42:17 +05302293 * wma_get_pdev_from_scn_handle() - API to get pdev from scn handle
2294 * @scn_handle: opaque wma handle
2295 *
2296 * API to get pdev from scn handle
2297 *
2298 * Return: None
2299 */
2300static struct wlan_objmgr_pdev *wma_get_pdev_from_scn_handle(void *scn_handle)
2301{
2302 tp_wma_handle wma_handle;
2303
2304 if (!scn_handle) {
2305 WMA_LOGE("invalid scn handle");
2306 return NULL;
2307 }
2308 wma_handle = (tp_wma_handle)scn_handle;
2309
2310 return wma_handle->pdev;
2311}
2312
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002313/**
2314 * wma_legacy_service_ready_event_handler() - legacy (ext)service ready handler
2315 * @event_id: event_id
2316 * @handle: wma handle
2317 * @event_data: event data
2318 * @length: event length
2319 *
2320 * Return: 0 for success, negative error code for failure
2321 */
2322static int wma_legacy_service_ready_event_handler(uint32_t event_id,
2323 void *handle,
2324 uint8_t *event_data,
2325 uint32_t length)
2326{
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302327 switch (event_id) {
2328 case wmi_service_ready_event_id:
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002329 return wma_rx_service_ready_event(handle, event_data, length);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302330 case wmi_service_ready_ext_event_id:
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002331 return wma_rx_service_ready_ext_event(handle, event_data,
2332 length);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302333 case wmi_ready_event_id:
2334 return wma_rx_ready_event(handle, event_data, length);
2335 default:
2336 WMA_LOGE("Legacy callback invoked with invalid event_id:%d",
2337 event_id);
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002338 QDF_BUG(0);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302339 }
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002340
2341 return 0;
2342}
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302343
2344/**
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002345 * wma_flush_complete_evt_handler() - FW log flush complete event handler
2346 * @handle: WMI handle
2347 * @event: Event recevied from FW
2348 * @len: Length of the event
2349 *
2350 */
2351static int wma_flush_complete_evt_handler(void *handle,
2352 u_int8_t *event,
2353 u_int32_t len)
2354{
2355 QDF_STATUS status;
2356 tp_wma_handle wma = (tp_wma_handle) handle;
2357
2358 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *param_buf;
2359 wmi_debug_mesg_flush_complete_fixed_param *wmi_event;
Poddar, Siddarthc2c08142017-09-13 17:49:56 +05302360 wmi_debug_mesg_fw_data_stall_param *data_stall_event;
2361 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2362 uint8_t *buf_ptr;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002363 uint32_t reason_code;
2364
2365 param_buf = (WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *) event;
2366 if (!param_buf) {
2367 WMA_LOGE("Invalid log flush complete event buffer");
2368 return QDF_STATUS_E_FAILURE;
2369 }
2370
2371 wmi_event = param_buf->fixed_param;
2372 reason_code = wmi_event->reserved0;
Rajeev Kumardcce8092018-05-02 15:48:17 -07002373 WMA_LOGD("Received reason code %d from FW", reason_code);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002374
Poddar, Siddarthc2c08142017-09-13 17:49:56 +05302375 buf_ptr = (uint8_t *)wmi_event;
2376 buf_ptr = buf_ptr + sizeof(wmi_debug_mesg_flush_complete_fixed_param) +
2377 WMI_TLV_HDR_SIZE;
2378 data_stall_event = (wmi_debug_mesg_fw_data_stall_param *) buf_ptr;
2379
2380 if (((data_stall_event->tlv_header & 0xFFFF0000) >> 16 ==
2381 WMITLV_TAG_STRUC_wmi_debug_mesg_fw_data_stall_param)) {
2382 /**
2383 * Log data stall info received from FW:
2384 *
2385 * Possible data stall recovery types:
2386 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_DISCONNECT
2387 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_MAC_PHY_RESET
2388 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_PDR
2389 *
2390 * Possible data stall event types:
2391 * WLAN_DBG_DATA_STALL_VDEV_PAUSE
2392 * WLAN_DBG_DATA_STALL_HWSCHED_CMD_FILTER
2393 * WLAN_DBG_DATA_STALL_HWSCHED_CMD_FLUSH
2394 * WLAN_DBG_DATA_STALL_RX_REFILL_FAILED
2395 * WLAN_DBG_DATA_STALL_RX_FCS_LEN_ERROR
2396 *
2397 * reason_code1:
2398 * The information stored in reason_code1 varies based on the
2399 * data stall type values:
2400 *
2401 * data_stall_type | reason_code1
2402 * -----------------------------------------------------
2403 * HWSCHED_CMD_FLUSH | flush req reason (0-40)
2404 * RX_REFILL_FAILED | ring_id (0-7)
2405 * RX_FCS_LEN_ERROR | exact error type
2406 *
2407 * reasone_code2:
2408 * on which tid/hwq stall happened
2409 *
2410 */
2411 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
2412 "Data Stall event:");
2413 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
2414 "data_stall_type: %x vdev_id_bitmap: %x reason_code1: %x reason_code2: %x recovery_type: %x ",
2415 data_stall_event->data_stall_type,
2416 data_stall_event->vdev_id_bitmap,
2417 data_stall_event->reason_code1,
2418 data_stall_event->reason_code2,
2419 data_stall_event->recovery_type);
2420
2421 cdp_post_data_stall_event(soc,
2422 DATA_STALL_LOG_INDICATOR_FIRMWARE,
2423 data_stall_event->data_stall_type,
2424 0XFF,
2425 data_stall_event->vdev_id_bitmap,
2426 data_stall_event->recovery_type);
2427 }
2428
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002429 /*
2430 * reason_code = 0; Flush event in response to flush command
2431 * reason_code = other value; Asynchronous flush event for fatal events
2432 */
2433 if (!reason_code && (cds_is_log_report_in_progress() == false)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002434 WMA_LOGD("Received WMI flush event without sending CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002435 return -EINVAL;
2436 } else if (!reason_code && cds_is_log_report_in_progress() == true) {
2437 /* Flush event in response to flush command */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002438 WMA_LOGD("Received WMI flush event in response to flush CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002439 status = qdf_mc_timer_stop(&wma->log_completion_timer);
2440 if (status != QDF_STATUS_SUCCESS)
2441 WMA_LOGE("Failed to stop the log completion timeout");
2442 cds_logging_set_fw_flush_complete();
Zhu Jianminb639e9b2017-10-26 19:09:12 +08002443 return QDF_STATUS_SUCCESS;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002444 } else if (reason_code && cds_is_log_report_in_progress() == false) {
2445 /* Asynchronous flush event for fatal events */
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002446 status = cds_set_log_completion(WLAN_LOG_TYPE_FATAL,
2447 WLAN_LOG_INDICATOR_FIRMWARE,
2448 reason_code, false);
2449 if (QDF_STATUS_SUCCESS != status) {
2450 WMA_LOGE("%s: Failed to set log trigger params",
2451 __func__);
2452 return QDF_STATUS_E_FAILURE;
2453 }
2454 cds_logging_set_fw_flush_complete();
2455 return status;
2456 } else {
2457 /* Asynchronous flush event for fatal event,
2458 * but, report in progress already
2459 */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002460 WMA_LOGD("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002461 __func__, WLAN_LOG_TYPE_FATAL,
2462 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2463 return QDF_STATUS_E_FAILURE;
2464 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07002465 /* Asynchronous flush event for fatal event,
2466 * but, report in progress already
2467 */
2468 WMA_LOGW("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
2469 __func__, WLAN_LOG_TYPE_FATAL,
2470 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2471 return QDF_STATUS_E_FAILURE;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002472}
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07002473
2474#ifdef WLAN_CONV_SPECTRAL_ENABLE
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002475/**
2476 * wma_extract_single_phyerr_spectral() - extract single phy error from event
2477 * @handle: wma handle
2478 * @param evt_buf: pointer to event buffer
2479 * @param datalen: data length of event buffer
2480 * @param buf_offset: Pointer to hold value of current event buffer offset
2481 * post extraction
2482 * @param phyerr: Pointer to hold phyerr
2483 *
2484 * Return: QDF_STATUS
2485 */
2486static QDF_STATUS wma_extract_single_phyerr_spectral(void *handle,
2487 void *evt_buf,
2488 uint16_t datalen, uint16_t *buf_offset,
2489 wmi_host_phyerr_t *phyerr)
2490{
2491 wmi_single_phyerr_rx_event *ev;
2492 int n = *buf_offset;
2493
2494 ev = (wmi_single_phyerr_rx_event *)((uint8_t *)evt_buf + n);
2495
2496 if (n < datalen) {
2497 /* ensure there's at least space for the header */
2498 if ((datalen - n) < sizeof(ev->hdr)) {
2499 WMA_LOGE("%s: not enough space? (datalen=%d, n=%d, hdr=%zu bytes",
2500 __func__, datalen, n, sizeof(ev->hdr));
2501 return QDF_STATUS_E_FAILURE;
2502 }
2503
2504 phyerr->bufp = ev->bufp;
2505 phyerr->buf_len = ev->hdr.buf_len;
2506
2507 /*
2508 * Sanity check the buffer length of the event against
2509 * what we currently have.
2510 *
2511 * Since buf_len is 32 bits, we check if it overflows
2512 * a large 32 bit value. It's not 0x7fffffff because
2513 * we increase n by (buf_len + sizeof(hdr)), which would
2514 * in itself cause n to overflow.
2515 *
2516 * If "int" is 64 bits then this becomes a moot point.
2517 */
2518 if (ev->hdr.buf_len > 0x7f000000) {
2519 WMA_LOGE("%s: buf_len is garbage? (0x%x)",
2520 __func__, ev->hdr.buf_len);
2521 return QDF_STATUS_E_FAILURE;
2522 }
2523 if (n + ev->hdr.buf_len > datalen) {
2524 WMA_LOGE("%s: buf_len exceeds available space n=%d, buf_len=%d, datalen=%d",
2525 __func__, n, ev->hdr.buf_len, datalen);
2526 return QDF_STATUS_E_FAILURE;
2527 }
2528
2529 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
2530 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
2531
2532#ifdef DEBUG_SPECTRAL_SCAN
2533 WMA_LOGD("%s: len=%d, tsf=0x%08x, rssi = 0x%x/0x%x/0x%x/0x%x, comb rssi = 0x%x, phycode=%d",
2534 __func__,
2535 ev->hdr.buf_len,
2536 ev->hdr.tsf_timestamp,
2537 ev->hdr.rssi_chain0,
2538 ev->hdr.rssi_chain1,
2539 ev->hdr.rssi_chain2,
2540 ev->hdr.rssi_chain3,
2541 WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr),
2542 phyerr->phy_err_code);
2543
2544 /*
2545 * For now, unroll this loop - the chain 'value' field isn't
2546 * a variable but glued together into a macro field definition.
2547 * Grr. :-)
2548 */
2549 WMA_LOGD("%s: chain 0: raw=0x%08x; pri20=%d sec20=%d sec40=%d sec80=%d",
2550 __func__,
2551 ev->hdr.rssi_chain0,
2552 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, PRI20),
2553 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC20),
2554 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC40),
2555 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC80));
2556
2557 WMA_LOGD("%s: chain 1: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2558 __func__,
2559 ev->hdr.rssi_chain1,
2560 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, PRI20),
2561 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC20),
2562 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC40),
2563 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC80));
2564
2565 WMA_LOGD("%s: chain 2: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2566 __func__,
2567 ev->hdr.rssi_chain2,
2568 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, PRI20),
2569 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC20),
2570 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC40),
2571 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC80));
2572
2573 WMA_LOGD("%s: chain 3: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2574 __func__,
2575 ev->hdr.rssi_chain3,
2576 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, PRI20),
2577 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC20),
2578 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC40),
2579 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC80));
2580
2581
2582 WMA_LOGD("%s: freq_info_1=0x%08x, freq_info_2=0x%08x",
2583 __func__, ev->hdr.freq_info_1, ev->hdr.freq_info_2);
2584
2585 /*
2586 * The NF chain values are signed and are negative - hence
2587 * the cast evilness.
2588 */
2589 WMA_LOGD("%s: nfval[1]=0x%08x, nfval[2]=0x%08x, nf=%d/%d/%d/%d, freq1=%d, freq2=%d, cw=%d",
2590 __func__,
2591 ev->hdr.nf_list_1,
2592 ev->hdr.nf_list_2,
2593 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 0),
2594 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 1),
2595 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 2),
2596 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 3),
2597 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 1),
2598 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 2),
2599 WMI_UNIFIED_CHWIDTH_GET(&ev->hdr));
2600#endif
2601
2602 /*
2603 * If required, pass spectral events to the spectral module
2604 */
2605 if (ev->hdr.buf_len > 0) {
2606
2607 /* Initialize the NF values to Zero. */
2608 phyerr->rf_info.noise_floor[0] =
2609 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 0);
2610 phyerr->rf_info.noise_floor[1] =
2611 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 1);
2612 phyerr->rf_info.noise_floor[2] =
2613 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 2);
2614 phyerr->rf_info.noise_floor[3] =
2615 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 3);
2616
2617 /* populate the rf info */
2618 phyerr->rf_info.rssi_comb =
2619 WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
2620
2621 /* Need to unroll loop due to macro
2622 * constraints chain 0
2623 */
2624 phyerr->rf_info.pc_rssi_info[0].rssi_pri20 =
2625 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, PRI20);
2626 phyerr->rf_info.pc_rssi_info[0].rssi_sec20 =
2627 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC20);
2628 phyerr->rf_info.pc_rssi_info[0].rssi_sec40 =
2629 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC40);
2630 phyerr->rf_info.pc_rssi_info[0].rssi_sec80 =
2631 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC80);
2632
2633 /* chain 1 */
2634 phyerr->rf_info.pc_rssi_info[1].rssi_pri20 =
2635 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, PRI20);
2636 phyerr->rf_info.pc_rssi_info[1].rssi_sec20 =
2637 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC20);
2638 phyerr->rf_info.pc_rssi_info[1].rssi_sec40 =
2639 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC40);
2640 phyerr->rf_info.pc_rssi_info[1].rssi_sec80 =
2641 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC80);
2642
2643 /* chain 2 */
2644 phyerr->rf_info.pc_rssi_info[2].rssi_pri20 =
2645 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, PRI20);
2646 phyerr->rf_info.pc_rssi_info[2].rssi_sec20 =
2647 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC20);
2648 phyerr->rf_info.pc_rssi_info[2].rssi_sec40 =
2649 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC40);
2650 phyerr->rf_info.pc_rssi_info[2].rssi_sec80 =
2651 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC80);
2652
2653 /* chain 3 */
2654 phyerr->rf_info.pc_rssi_info[3].rssi_pri20 =
2655 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, PRI20);
2656 phyerr->rf_info.pc_rssi_info[3].rssi_sec20 =
2657 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC20);
2658 phyerr->rf_info.pc_rssi_info[3].rssi_sec40 =
2659 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC40);
2660 phyerr->rf_info.pc_rssi_info[3].rssi_sec80 =
2661 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC80);
2662
2663 phyerr->chan_info.center_freq1 =
2664 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 1);
2665 phyerr->chan_info.center_freq2 =
2666 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 2);
2667
2668 }
2669
2670 /*
2671 * Advance the buffer pointer to the next PHY error.
2672 * buflen is the length of this payload, so we need to
2673 * advance past the current header _AND_ the payload.
2674 */
2675 n += sizeof(*ev) + ev->hdr.buf_len;
2676 }
2677 *buf_offset += n;
2678
2679 return QDF_STATUS_SUCCESS;
2680}
2681
2682/**
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002683 * spectral_phyerr_event_handler() - spectral phyerr event handler
2684 * @handle: wma handle
2685 * @data: data buffer
2686 * @datalen: buffer length
2687 *
2688 * Return: QDF_STATUS
2689 */
2690static QDF_STATUS spectral_phyerr_event_handler(void *handle,
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07002691 uint8_t *data,
2692 uint32_t datalen)
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002693{
2694 tp_wma_handle wma = (tp_wma_handle) handle;
2695 QDF_STATUS status = QDF_STATUS_SUCCESS;
2696 uint16_t buf_offset, event_buf_len = 0;
2697 wmi_single_phyerr_rx_event *ev;
2698 wmi_host_phyerr_t phyerr;
2699 struct target_if_spectral_rfqual_info rfqual_info;
2700 struct target_if_spectral_chan_info chan_info;
2701 struct target_if_spectral_acs_stats acs_stats;
2702
2703 if (NULL == wma) {
2704 WMA_LOGE("%s:wma handle is NULL", __func__);
2705 return QDF_STATUS_E_FAILURE;
2706 }
2707
2708 memset(&phyerr, 0, sizeof(wmi_host_phyerr_t));
Arif Hussaind54b62c2018-03-01 13:31:37 -08002709 status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
2710 &buf_offset, &phyerr);
2711 if (QDF_IS_STATUS_ERROR(status)) {
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002712 WMA_LOGE("%s: extract comb phyerr failed", __func__);
2713 return QDF_STATUS_E_FAILURE;
2714 }
2715
2716 ev = (wmi_single_phyerr_rx_event *)phyerr.bufp;
2717 event_buf_len = phyerr.buf_len;
2718 /* Loop over the bufp, extracting out phyerrors */
2719 buf_offset = 0;
2720 while (buf_offset < event_buf_len) {
2721 if (wma_extract_single_phyerr_spectral(handle, ev,
2722 event_buf_len, &buf_offset, &phyerr)) {
2723 WMA_LOGE("%s: extract single phy err failed", __func__);
2724 return QDF_STATUS_E_FAILURE;
2725 }
2726
2727 if (phyerr.buf_len > 0) {
2728 if (sizeof(phyerr.rf_info) > sizeof(rfqual_info))
2729 qdf_mem_copy(&rfqual_info, &phyerr.rf_info,
2730 sizeof(rfqual_info));
2731 else
2732 qdf_mem_copy(&rfqual_info, &phyerr.rf_info,
2733 sizeof(phyerr.rf_info));
2734
2735 if (sizeof(phyerr.chan_info) > sizeof(chan_info))
2736 qdf_mem_copy(&chan_info, &phyerr.chan_info,
2737 sizeof(chan_info));
2738 else
2739 qdf_mem_copy(&chan_info, &phyerr.chan_info,
2740 sizeof(phyerr.chan_info));
2741
2742 target_if_spectral_process_phyerr(wma->pdev, phyerr.bufp,
2743 phyerr.buf_len,
2744 &rfqual_info,
2745 &chan_info,
2746 phyerr.tsf64,
2747 &acs_stats);
2748 }
2749 }
2750
2751 return status;
2752}
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07002753#else
Chaoli Zhou5d6bad12018-06-13 14:29:33 +08002754static QDF_STATUS
2755wma_extract_single_phyerr_spectral(void *handle, void *evt_buf,
2756 uint16_t datalen,
2757 uint16_t *buf_offset,
2758 wmi_host_phyerr_t *phyerr)
2759{
2760 return QDF_STATUS_SUCCESS;
2761}
2762
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07002763static QDF_STATUS spectral_phyerr_event_handler(void *handle,
2764 uint8_t *data, uint32_t datalen)
2765{
2766 return QDF_STATUS_SUCCESS;
2767}
2768#endif
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002769
Arif Hussainf63f7a32017-08-22 12:49:42 -07002770/**
Arif Hussaind54b62c2018-03-01 13:31:37 -08002771 * dfs_phyerr_event_handler() - dfs phyerr event handler
2772 * @handle: wma handle
2773 * @data: data buffer
2774 * @datalen: buffer length
2775 * @fulltsf: 64 bit event TSF
2776 *
2777 * Function to process DFS phy errors.
2778 *
2779 * Return: QDF_STATUS
2780 */
2781static QDF_STATUS dfs_phyerr_event_handler(tp_wma_handle handle,
2782 uint8_t *data,
2783 uint32_t datalen,
2784 uint64_t fulltsf)
2785{
2786 QDF_STATUS status = QDF_STATUS_SUCCESS;
2787 struct wlan_lmac_if_dfs_rx_ops *dfs_rx_ops;
2788 wmi_host_phyerr_t phyerr;
2789 int8_t rssi_comb;
2790 uint16_t buf_offset;
2791
2792 if (!handle->psoc) {
2793 WMA_LOGE("%s: psoc is null", __func__);
2794 return QDF_STATUS_E_INVAL;
2795 }
2796
2797 dfs_rx_ops = wlan_lmac_if_get_dfs_rx_ops(handle->psoc);
2798 if (!dfs_rx_ops) {
2799 WMA_LOGE("%s: dfs_rx_ops is null", __func__);
2800 return QDF_STATUS_E_INVAL;
2801 }
2802
2803 if (!dfs_rx_ops->dfs_process_phyerr) {
2804 WMA_LOGE("%s: dfs_process_phyerr handler is null", __func__);
2805 return QDF_STATUS_E_INVAL;
2806 }
2807
2808 if (!handle->pdev) {
2809 WMA_LOGE("%s: pdev is null", __func__);
2810 return -EINVAL;
2811 }
2812
2813 buf_offset = 0;
2814 while (buf_offset < datalen) {
2815 status = wmi_extract_single_phyerr(handle->wmi_handle, data, datalen,
2816 &buf_offset, &phyerr);
2817 if (QDF_IS_STATUS_ERROR(status)) {
2818 /* wmi_extract_single_phyerr has logs */
2819 return status;
2820 }
2821
2822 rssi_comb = phyerr.rf_info.rssi_comb & 0xFF;
2823 if (phyerr.buf_len > 0)
2824 dfs_rx_ops->dfs_process_phyerr(handle->pdev,
2825 &phyerr.bufp[0],
2826 phyerr.buf_len,
2827 rssi_comb,
2828 rssi_comb,
2829 phyerr.tsf_timestamp,
2830 fulltsf);
2831 }
2832
2833 return QDF_STATUS_SUCCESS;
2834}
2835
2836/**
Arif Hussainf63f7a32017-08-22 12:49:42 -07002837 * wma_unified_phyerr_rx_event_handler() - phyerr event handler
2838 * @handle: wma handle
2839 * @data: data buffer
2840 * @datalen: buffer length
2841 *
2842 * WMI Handler for WMI_PHYERR_EVENTID event from firmware.
2843 * This handler is currently handling DFS and spectral scan
2844 * phy errors.
2845 *
2846 * Return: 0 for success, other value for failure
2847 */
2848static int wma_unified_phyerr_rx_event_handler(void *handle,
Arif Hussaind54b62c2018-03-01 13:31:37 -08002849 uint8_t *data,
2850 uint32_t datalen)
2851{
Arif Hussainf63f7a32017-08-22 12:49:42 -07002852 /* phyerr handling is moved to cmn project
2853 * As WIN still uses handler registration in non-cmn code.
2854 * need complete testing of non offloaded DFS code before we enable
2855 * it in cmn code.
2856 **/
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002857 tp_wma_handle wma = (tp_wma_handle) handle;
2858 QDF_STATUS status = QDF_STATUS_SUCCESS;
2859 wmi_host_phyerr_t phyerr;
2860 uint16_t buf_offset = 0;
Chaoli Zhou5d6bad12018-06-13 14:29:33 +08002861 wmi_single_phyerr_rx_event *ev;
2862 uint16_t event_buf_len = 0;
2863 wmi_host_phyerr_t phyerr2;
2864 bool spectralscan = false;
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002865
Arif Hussaind54b62c2018-03-01 13:31:37 -08002866 if (!wma) {
2867 WMA_LOGE("%s: wma handle is null", __func__);
2868 return -EINVAL;
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002869 }
2870
2871 /* sanity check on data length */
Arif Hussaind54b62c2018-03-01 13:31:37 -08002872 status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
2873 &buf_offset, &phyerr);
2874 if (QDF_IS_STATUS_ERROR(status)) {
2875 WMA_LOGE("%s: extract phyerr failed: %d", __func__, status);
2876 return qdf_status_to_os_return(status);
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002877 }
Chaoli Zhou5d6bad12018-06-13 14:29:33 +08002878 ev = (wmi_single_phyerr_rx_event *)phyerr.bufp;
2879 event_buf_len = phyerr.buf_len;
2880 /* Loop over the bufp, extracting out phyerrors */
2881 buf_offset = 0;
2882 while (ev && (buf_offset < event_buf_len)) {
2883 if (wma_extract_single_phyerr_spectral(handle, ev,
2884 event_buf_len,
2885 &buf_offset,
2886 &phyerr2)) {
2887 WMA_LOGE("%s: extract single phy err failed", __func__);
2888 return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
2889 }
2890 if ((buf_offset != 0) && (phyerr2.phy_err_code == 0x26 ||
2891 phyerr2.phy_err_code == 0x24)) {
2892 spectralscan = true;
2893 } else {
2894 break;
2895 }
2896 }
2897 if (spectralscan) {
2898 status = spectral_phyerr_event_handler(wma, data, datalen);
2899 return qdf_status_to_os_return(status);
2900 }
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002901 /* handle different PHY Error conditions */
2902 if (((phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_RADAR |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002903 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT |
2904 WMI_PHY_ERROR_MASK0_SPECTRAL_SCAN)) == 0)) {
2905 WMA_LOGD("%s: Unknown phy error event", __func__);
2906 return -EINVAL;
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002907 }
2908
2909 /* Handle Spectral or DFS PHY Error */
2910 if (phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_RADAR |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002911 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT)) {
2912 if (wma->is_dfs_offloaded) {
2913 WMA_LOGD("%s: Unexpected phy error, dfs offloaded",
2914 __func__);
2915 return -EINVAL;
2916 }
2917 status = dfs_phyerr_event_handler(wma,
2918 phyerr.bufp,
2919 phyerr.buf_len,
2920 phyerr.tsf64);
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002921 } else if (phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_SPECTRAL_SCAN |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002922 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT)) {
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002923 status = spectral_phyerr_event_handler(wma, data, datalen);
2924 }
Arif Hussaind54b62c2018-03-01 13:31:37 -08002925
2926 return qdf_status_to_os_return(status);
Arif Hussainf63f7a32017-08-22 12:49:42 -07002927}
2928
Dustin Brownec2c92e2017-07-26 11:13:49 -07002929void wma_vdev_init(struct wma_txrx_node *vdev)
2930{
2931 qdf_wake_lock_create(&vdev->vdev_start_wakelock, "vdev_start");
2932 qdf_wake_lock_create(&vdev->vdev_stop_wakelock, "vdev_stop");
Rajeev Kumar155a3e42017-10-10 15:31:17 -07002933 qdf_wake_lock_create(&vdev->vdev_set_key_wakelock, "vdev_set_key");
Naveen Rawatd7734142017-10-27 10:02:40 -07002934 vdev->is_waiting_for_key = false;
Dustin Brownec2c92e2017-07-26 11:13:49 -07002935}
2936
2937void wma_vdev_deinit(struct wma_txrx_node *vdev)
2938{
Abhinav Kumar0a846132018-08-09 11:49:46 +05302939 struct beacon_info *bcn;
2940 tp_wma_handle wma_handle;
2941
2942 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
2943 /* validate the wma_handle */
2944 if (!wma_handle) {
2945 WMA_LOGE("%s: Invalid wma handle", __func__);
2946 return;
2947 }
2948
2949 bcn = vdev->beacon;
2950 if (bcn) {
2951 if (bcn->dma_mapped)
2952 qdf_nbuf_unmap_single(wma_handle->qdf_dev,
2953 bcn->buf, QDF_DMA_TO_DEVICE);
2954 qdf_nbuf_free(bcn->buf);
2955 qdf_mem_free(bcn);
2956 vdev->beacon = NULL;
2957 }
2958
2959 if (vdev->handle) {
2960 qdf_mem_free(vdev->handle);
2961 vdev->handle = NULL;
2962 }
2963
2964 if (vdev->addBssStaContext) {
2965 qdf_mem_free(vdev->addBssStaContext);
2966 vdev->addBssStaContext = NULL;
2967 }
2968
2969 if (vdev->staKeyParams) {
2970 qdf_mem_free(vdev->staKeyParams);
2971 vdev->staKeyParams = NULL;
2972 }
2973
2974 if (vdev->del_staself_req) {
2975 qdf_mem_free(vdev->del_staself_req);
2976 vdev->del_staself_req = NULL;
2977 }
2978
2979 if (vdev->stats_rsp) {
2980 qdf_mem_free(vdev->stats_rsp);
2981 vdev->stats_rsp = NULL;
2982 }
2983
2984 if (vdev->psnr_req) {
2985 qdf_mem_free(vdev->psnr_req);
2986 vdev->psnr_req = NULL;
2987 }
2988
2989 if (vdev->rcpi_req) {
2990 qdf_mem_free(vdev->rcpi_req);
2991 vdev->rcpi_req = NULL;
2992 }
2993
Rajeev Kumar Sirasanagandla4f20b672018-03-12 13:52:50 +05302994 if (vdev->roam_scan_stats_req) {
2995 struct sir_roam_scan_stats *req;
2996
2997 req = vdev->roam_scan_stats_req;
2998 vdev->roam_scan_stats_req = NULL;
2999 qdf_mem_free(req);
3000 }
3001
Abhinav Kumar0a846132018-08-09 11:49:46 +05303002 if (vdev->roam_synch_frame_ind.bcn_probe_rsp) {
3003 qdf_mem_free(vdev->roam_synch_frame_ind.bcn_probe_rsp);
3004 vdev->roam_synch_frame_ind.bcn_probe_rsp = NULL;
3005 }
3006
3007 if (vdev->roam_synch_frame_ind.reassoc_req) {
3008 qdf_mem_free(vdev->roam_synch_frame_ind.reassoc_req);
3009 vdev->roam_synch_frame_ind.reassoc_req = NULL;
3010 }
3011
3012 if (vdev->roam_synch_frame_ind.reassoc_rsp) {
3013 qdf_mem_free(vdev->roam_synch_frame_ind.reassoc_rsp);
3014 vdev->roam_synch_frame_ind.reassoc_rsp = NULL;
3015 }
3016
Dustin Brownec2c92e2017-07-26 11:13:49 -07003017 qdf_wake_lock_destroy(&vdev->vdev_start_wakelock);
3018 qdf_wake_lock_destroy(&vdev->vdev_stop_wakelock);
Rajeev Kumar155a3e42017-10-10 15:31:17 -07003019 qdf_wake_lock_destroy(&vdev->vdev_set_key_wakelock);
Naveen Rawatd7734142017-10-27 10:02:40 -07003020 vdev->is_waiting_for_key = false;
Dustin Brownec2c92e2017-07-26 11:13:49 -07003021}
3022
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08003023/**
3024 * wma_wmi_stop() - generic function to block WMI commands
3025 * @return: None
3026 */
3027void wma_wmi_stop(void)
3028{
3029 tp_wma_handle wma_handle;
3030
3031 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Pragaspathi Thilagarajbc5a34b2018-10-09 18:35:45 +05303032 if ((!wma_handle) || (!wma_handle->wmi_handle)) {
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08003033 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
Pragaspathi Thilagarajbc5a34b2018-10-09 18:35:45 +05303034 "wma_handle or wmi_handle is NULL\n");
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08003035 return;
3036 }
3037 wmi_stop(wma_handle->wmi_handle);
3038}
3039
Naveen Rawate8b1b822018-01-30 09:46:16 -08003040#ifdef QCA_SUPPORT_CP_STATS
3041static void wma_register_stats_events(wmi_unified_t wmi_handle) {}
3042#else
3043static void wma_register_stats_events(wmi_unified_t wmi_handle)
3044{
3045 wmi_unified_register_event_handler(wmi_handle,
3046 wmi_update_stats_event_id,
3047 wma_stats_event_handler,
3048 WMA_RX_SERIALIZER_CTX);
3049}
3050#endif
3051
Harprit Chhabada98225f62018-12-11 15:29:55 -08003052#ifdef CONFIG_WMI_BCN_OFFLOAD
3053static QDF_STATUS
3054wma_register_swba_events(wmi_unified_t wmi_handle)
3055{
3056 QDF_STATUS status;
3057
3058 status = wmi_unified_register_event_handler(wmi_handle,
3059 wmi_host_swba_event_id,
3060 wma_beacon_swba_handler,
3061 WMA_RX_SERIALIZER_CTX);
3062
3063 return status;
3064}
3065#else
3066static QDF_STATUS wma_register_swba_events(wmi_unified_t wmi_handle)
3067{
3068 return QDF_STATUS_SUCCESS;
3069}
3070#endif
3071
Nachiket Kukade177b5b02018-05-22 20:52:17 +05303072#ifdef FEATURE_WLAN_APF
3073static void wma_register_apf_events(tp_wma_handle wma_handle)
3074{
3075 if (!wma_handle) {
3076 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
3077 "wma_handle is NULL\n");
3078 return;
3079 }
3080
3081 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3082 wmi_apf_capability_info_event_id,
3083 wma_get_apf_caps_event_handler,
3084 WMA_RX_SERIALIZER_CTX);
3085 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3086 wmi_apf_get_vdev_work_memory_resp_event_id,
3087 wma_apf_read_work_memory_event_handler,
3088 WMA_RX_SERIALIZER_CTX);
3089}
3090#else /* FEATURE_WLAN_APF */
3091static void wma_register_apf_events(tp_wma_handle wma_handle)
3092{
3093}
3094#endif /* FEATURE_WLAN_APF */
3095
Arif Hussain49698112018-07-31 00:32:50 -07003096struct wlan_objmgr_psoc *wma_get_psoc_from_scn_handle(void *scn_handle)
3097{
3098 tp_wma_handle wma_handle;
3099
3100 if (!scn_handle) {
3101 WMA_LOGE("invalid scn handle");
3102 return NULL;
3103 }
3104 wma_handle = (tp_wma_handle)scn_handle;
3105
3106 return wma_handle->psoc;
3107}
3108
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08003109/**
Ashish Kumar Dhanotiyacd311c82018-09-14 10:55:10 +05303110 * wma_get_phy_mode_cb() - Callback to get current PHY Mode.
3111 * @chan: channel number
3112 * @chan_width: maximum channel width possible
3113 * @phy_mode: PHY Mode
3114 *
3115 * Return: None
3116 */
3117static void wma_get_phy_mode_cb(uint8_t chan, uint32_t chan_width,
3118 uint32_t *phy_mode)
3119{
3120 uint32_t dot11_mode;
Jeff Johnson009c40f2018-11-05 09:54:37 -08003121 struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
Ashish Kumar Dhanotiyacd311c82018-09-14 10:55:10 +05303122
3123 if (!mac) {
3124 wma_err("MAC context is NULL");
3125 *phy_mode = MODE_UNKNOWN;
3126 return;
3127 }
3128
gaurank kathpalia1be77fa2019-01-04 13:32:09 +05303129 dot11_mode = mac->mlme_cfg->dot11_mode.dot11_mode;
Ashish Kumar Dhanotiyacd311c82018-09-14 10:55:10 +05303130 *phy_mode = wma_chan_phy_mode(chan, chan_width, dot11_mode);
3131}
3132
3133/**
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08003134 * wma_open() - Allocate wma context and initialize it.
3135 * @cds_context: cds context
3136 * @wma_tgt_cfg_cb: tgt config callback fun
3137 * @radar_ind_cb: dfs radar indication callback
3138 * @cds_cfg: mac parameters
3139 *
3140 * Return: 0 on success, errno on failure
3141 */
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003142QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 wma_tgt_cfg_cb tgt_cfg_cb,
bings482bae22018-01-17 16:25:31 +08003144 struct cds_config_info *cds_cfg,
3145 uint32_t target_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146{
3147 tp_wma_handle wma_handle;
3148 HTC_HANDLE htc_handle;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303149 qdf_device_t qdf_dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150 void *wmi_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303151 QDF_STATUS qdf_status;
Lin Bai04f603e2018-03-19 11:01:06 +08003152 struct wmi_unified_attach_params *params;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003153 struct policy_mgr_wma_cbacks wma_cbacks;
Frank Liu00d73fe2017-05-19 22:11:28 +08003154 struct target_psoc_info *tgt_psoc_info;
Dustin Brownec2c92e2017-07-26 11:13:49 -07003155 int i;
Pragaspathi Thilagaraj00bd8bc2018-08-18 01:23:01 +05303156 bool val = 0;
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003157 void *cds_context;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303158 target_resource_config *wlan_res_cfg;
Wu Gao66454f12018-09-26 19:55:41 +08003159 enum pmo_wow_enable_type wow_enable;
Wu Gao51a63562018-11-08 16:29:10 +08003160 uint8_t delay_before_vdev_stop;
lifeng0b46ae52018-12-13 09:42:27 +08003161 uint32_t self_gen_frm_pwr = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162
3163 WMA_LOGD("%s: Enter", __func__);
3164
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003165 cds_context = cds_get_global_context();
3166 if (!cds_context) {
3167 WMA_LOGE("%s: Invalid CDS context", __func__);
3168 return QDF_STATUS_E_INVAL;
3169 }
3170
Mukul Sharma5ff3c582016-09-12 15:23:35 +05303171 g_wmi_version_info.major = __WMI_VER_MAJOR_;
3172 g_wmi_version_info.minor = __WMI_VER_MINOR_;
3173 g_wmi_version_info.revision = __WMI_REVISION_;
3174
Anurag Chouhan6d760662016-02-20 16:05:43 +05303175 qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
3176 htc_handle = cds_get_context(QDF_MODULE_ID_HTC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177
3178 if (!htc_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003179 WMA_LOGE("%s: Invalid HTC handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303180 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 }
3182
3183 /* Alloc memory for WMA Context */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003184 qdf_status = cds_alloc_context(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 (void **)&wma_handle,
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003186 sizeof(*wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303188 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003189 WMA_LOGE("%s: Memory allocation failed for wma_handle",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303191 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 }
3193
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303194 qdf_mem_zero(wma_handle, sizeof(t_wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303196 if (target_if_alloc_psoc_tgt_info(psoc)) {
3197 WMA_LOGE("%s target psoc info allocation failed", __func__);
3198 qdf_status = QDF_STATUS_E_NOMEM;
3199 goto err_free_wma_handle;
Frank Liu00d73fe2017-05-19 22:11:28 +08003200 }
3201
Anurag Chouhan6d760662016-02-20 16:05:43 +05303202 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303204 qdf_wake_lock_create(&wma_handle->extscan_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 "wlan_extscan_wl");
3206#endif /* FEATURE_WLAN_EXTSCAN */
Mukul Sharmae44d0542017-05-23 21:50:56 +05303207 qdf_wake_lock_create(&wma_handle->wow_wake_lock,
3208 "wlan_wow_wl");
3209 qdf_wake_lock_create(&wma_handle->wow_auth_req_wl,
3210 "wlan_auth_req_wl");
3211 qdf_wake_lock_create(&wma_handle->wow_assoc_req_wl,
3212 "wlan_assoc_req_wl");
3213 qdf_wake_lock_create(&wma_handle->wow_deauth_rec_wl,
3214 "wlan_deauth_rec_wl");
3215 qdf_wake_lock_create(&wma_handle->wow_disassoc_rec_wl,
3216 "wlan_disassoc_rec_wl");
3217 qdf_wake_lock_create(&wma_handle->wow_ap_assoc_lost_wl,
3218 "wlan_ap_assoc_lost_wl");
3219 qdf_wake_lock_create(&wma_handle->wow_auto_shutdown_wl,
3220 "wlan_auto_shutdown_wl");
3221 qdf_wake_lock_create(&wma_handle->roam_ho_wl,
3222 "wlan_roam_ho_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 }
3224
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05303225 qdf_status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_LEGACY_WMA_ID);
3226 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3227 WMA_LOGE("%s: PSOC get_ref fails", __func__);
Zhu Jianminf9e2e2d2018-05-30 16:20:24 +08003228 goto err_get_psoc_ref;
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05303229 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303230 wma_handle->psoc = psoc;
3231
Rajeev Kumarda2444c2017-01-10 22:42:07 -08003232 wma_target_if_open(wma_handle);
Rajeev Kumarda2444c2017-01-10 22:42:07 -08003233
Lin Bai04f603e2018-03-19 11:01:06 +08003234 /*
3235 * Allocate locally used params with its rx_ops member,
3236 * and free it immediately after used.
3237 */
3238 params = qdf_mem_malloc(sizeof(*params) + sizeof(struct wmi_rx_ops));
3239 if (!params) {
Lin Bai04f603e2018-03-19 11:01:06 +08003240 qdf_status = QDF_STATUS_E_NOMEM;
3241 goto err_wma_handle;
3242 }
3243
3244 params->rx_ops = (struct wmi_rx_ops *)(params + 1);
3245 params->osdev = NULL;
3246 params->target_type = WMI_TLV_TARGET;
3247 params->use_cookie = false;
3248 params->psoc = psoc;
3249 params->max_commands = WMI_MAX_CMDS;
Govind Singhd76a5b02016-03-08 15:12:14 +05303250 /* Attach mc_thread context processing function */
Lin Bai04f603e2018-03-19 11:01:06 +08003251 params->rx_ops->wma_process_fw_event_handler_cbk =
3252 wma_process_fw_event_handler;
Surabhi Vishnoi75b1a812018-02-09 12:07:16 +05303253
Himanshu Agarwal88b16a42018-02-06 15:10:59 +05303254 /* initialize tlv attach */
3255 wmi_tlv_init();
Surabhi Vishnoi75b1a812018-02-09 12:07:16 +05303256
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 /* attach the wmi */
Lin Bai04f603e2018-03-19 11:01:06 +08003258 wmi_handle = wmi_unified_attach(wma_handle, params);
3259 qdf_mem_free(params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 if (!wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003261 WMA_LOGE("%s: failed to attach WMI", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303262 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 goto err_wma_handle;
3264 }
3265
Rajeev Kumarda2444c2017-01-10 22:42:07 -08003266 target_if_register_legacy_service_ready_cb(
3267 wma_legacy_service_ready_event_handler);
3268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 WMA_LOGA("WMA --> wmi_unified_attach - success");
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05303270
Frank Liu00d73fe2017-05-19 22:11:28 +08003271 /* store the wmi handle in tgt_if_handle */
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303272 tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05303273
bings6b413662018-02-06 17:51:36 +08003274 target_psoc_set_target_type(tgt_psoc_info, target_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 /* Save the WMI & HTC handle */
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303276 target_psoc_set_wmi_hdl(tgt_psoc_info, wmi_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 wma_handle->wmi_handle = wmi_handle;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303278 target_psoc_set_htc_hdl(tgt_psoc_info, htc_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 wma_handle->cds_context = cds_context;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303280 wma_handle->qdf_dev = qdf_dev;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303281 wma_handle->max_scan = cds_cfg->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303283 /* Register Converged Event handlers */
3284 init_deinit_register_tgt_psoc_ev_handlers(psoc);
3285
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303286 /* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
Rachit Kankane0106e382018-05-16 18:59:28 +05303287 cds_cfg->max_station = wma_init_max_no_of_peers(wma_handle,
3288 cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303289
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 /* initialize default target config */
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303291 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_psoc_info);
Arif Hussaind15902c2018-03-02 00:08:29 -08003292 if (!wlan_res_cfg) {
3293 WMA_LOGE("%s: wlan_res_cfg is null", __func__);
3294 qdf_status = QDF_STATUS_E_NOMEM;
3295 goto err_wma_handle;
3296 }
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303297
Rachit Kankane0106e382018-05-16 18:59:28 +05303298 wma_set_default_tgt_config(wma_handle, wlan_res_cfg, cds_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299
Pragaspathi Thilagaraj00bd8bc2018-08-18 01:23:01 +05303300 qdf_status = wlan_mlme_get_tx_chainmask_cck(psoc, &val);
3301 if (qdf_status != QDF_STATUS_SUCCESS) {
3302 WMA_LOGE("%s: Failed to get tx_chainmask_cck", __func__);
3303 qdf_status = QDF_STATUS_E_FAILURE;
3304 goto err_wma_handle;
3305 }
3306 wma_handle->tx_chain_mask_cck = val;
lifeng0b46ae52018-12-13 09:42:27 +08003307
3308 qdf_status = wlan_mlme_get_self_gen_frm_pwr(psoc, &self_gen_frm_pwr);
3309 if (qdf_status != QDF_STATUS_SUCCESS)
3310 WMA_LOGE("%s: Failed to get self_gen_frm_pwr", __func__);
3311 wma_handle->self_gen_frm_pwr = self_gen_frm_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303313 cds_cfg->max_bssid = WMA_MAX_SUPPORTED_BSS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303315 wma_handle->max_station = cds_cfg->max_station;
3316 wma_handle->max_bssid = cds_cfg->max_bssid;
Wu Gao66454f12018-09-26 19:55:41 +08003317 wma_handle->ssdp = ucfg_pmo_is_ssdp_enabled(wma_handle->psoc);
3318 wma_handle->enable_mc_list =
3319 ucfg_pmo_is_mc_addr_list_enabled(wma_handle->psoc);
Wu Gao9d117fb2019-01-10 21:52:31 +08003320 wma_handle->active_uc_apf_mode =
3321 ucfg_pmo_get_active_uc_apf_mode(wma_handle->psoc);
3322 wma_handle->active_mc_bc_apf_mode =
3323 ucfg_pmo_get_active_mc_bc_apf_mode(wma_handle->psoc);
Srinivas Girigowda57b450e2016-10-27 21:00:46 -07003324 wma_handle->link_stats_results = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303326 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327#endif /* FEATURE_WLAN_RA_FILTERING */
3328#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303329 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303331 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 wma_handle->max_bssid);
3333 if (!wma_handle->interfaces) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303334 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 goto err_scn_context;
3336 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003337
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003338 for (i = 0; i < wma_handle->max_bssid; ++i) {
Dustin Brownec2c92e2017-07-26 11:13:49 -07003339 wma_vdev_init(&wma_handle->interfaces[i]);
Wu Gao51a63562018-11-08 16:29:10 +08003340 ucfg_mlme_get_delay_before_vdev_stop(wma_handle->psoc,
3341 &delay_before_vdev_stop);
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003342 wma_handle->interfaces[i].delay_before_vdev_stop =
Wu Gao51a63562018-11-08 16:29:10 +08003343 delay_before_vdev_stop;
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003344 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 /* Register the debug print event handler */
3346 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303347 wmi_debug_print_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303348 wma_unified_debug_print_event_handler,
3349 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05303350 /* Register profiling event Handler */
3351 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303352 wmi_wlan_profile_data_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303353 wma_profile_data_report_event_handler,
3354 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355
3356 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
3358 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05303359 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07003360 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361
Anurag Chouhan210db072016-02-22 18:42:15 +05303362 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303363 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303364 wma_service_ready_ext_evt_timeout,
3365 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303366 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303367 WMA_LOGE("Failed to initialize service ready ext timeout");
3368 goto err_event_init;
3369 }
3370
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303371 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303372 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003373 WMA_LOGE("%s: target suspend event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 __func__);
3375 goto err_event_init;
3376 }
3377
3378 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303379 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
3380 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003381 WMA_LOGE("%s: failed to init tx_frm_download_comp_event",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 __func__);
3383 goto err_event_init;
3384 }
3385
3386 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303387 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
3388 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003389 WMA_LOGE("%s: failed to init tx_queue_empty_event", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390 goto err_event_init;
3391 }
3392
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003393 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
3394 wma_handle);
3395 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003396 WMA_LOGE("%s: Shutdown notifier register failed: %d",
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003397 __func__, qdf_status);
3398 goto err_event_init;
3399 }
3400
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303401 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303402 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003403 WMA_LOGE("%s: runtime_suspend event initialization failed",
Houston Hoffmana76591b2015-11-10 16:52:05 -08003404 __func__);
3405 goto err_event_init;
3406 }
3407
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303408 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303409 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003410 WMA_LOGE("%s: recovery event initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 goto err_event_init;
3412 }
3413
Anurag Chouhanffb21542016-02-17 14:33:03 +05303414 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003415 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303416 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303417 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303419 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05303420 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421
3422 /* Register vdev start response event handler */
3423 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303424 wmi_vdev_start_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303425 wma_vdev_start_resp_handler,
3426 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427
3428 /* Register vdev stop response event handler */
3429 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303430 wmi_vdev_stopped_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303431 wma_vdev_stop_resp_handler,
3432 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433
3434 /* register for STA kickout function */
3435 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303436 wmi_peer_sta_kickout_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303437 wma_peer_sta_kickout_event_handler,
3438 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439
Naveen Rawate8b1b822018-01-30 09:46:16 -08003440 /* register for stats event */
3441 wma_register_stats_events(wma_handle->wmi_handle);
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303442
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303443 /* register for stats response event */
3444 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303445 wmi_get_arp_stats_req_id,
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303446 wma_get_arp_stats_handler,
3447 WMA_RX_SERIALIZER_CTX);
3448
Will Huanga9814592017-05-24 15:47:58 +08003449 /* register for peer info response event */
3450 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303451 wmi_peer_stats_info_event_id,
Will Huanga9814592017-05-24 15:47:58 +08003452 wma_peer_info_event_handler,
3453 WMA_RX_SERIALIZER_CTX);
3454
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303455#ifdef WLAN_POWER_DEBUGFS
3456 /* register for Chip Power stats event */
3457 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303458 wmi_pdev_chip_power_stats_event_id,
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303459 wma_unified_power_debug_stats_event_handler,
3460 WMA_RX_SERIALIZER_CTX);
3461#endif
Arunk Khandavallica56d4b2018-11-29 15:46:00 +05303462#ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
3463 /* register for beacon stats event */
3464 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3465 wmi_vdev_bcn_reception_stats_event_id,
3466 wma_unified_beacon_debug_stats_event_handler,
3467 WMA_RX_SERIALIZER_CTX);
3468#endif
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 /* register for linkspeed response event */
3471 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303472 wmi_peer_estimated_linkspeed_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303473 wma_link_speed_event_handler,
3474 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475
3476#ifdef FEATURE_OEM_DATA_SUPPORT
3477 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303478 wmi_oem_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303479 wma_oem_data_response_handler,
3480 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481#endif /* FEATURE_OEM_DATA_SUPPORT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482
3483 /* Register peer change event handler */
3484 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303485 wmi_peer_state_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303486 wma_peer_state_change_event_handler,
3487 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488
3489 /* Register beacon tx complete event id. The event is required
3490 * for sending channel switch announcement frames
3491 */
3492 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303493 wmi_offload_bcn_tx_status_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303494 wma_unified_bcntx_status_event_handler,
3495 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496
3497 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303498 wmi_update_vdev_rate_stats_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303499 wma_link_status_event_handler,
3500 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar Sirasanagandla4f20b672018-03-12 13:52:50 +05303501
3502 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3503 wmi_roam_scan_stats_event_id,
3504 wma_roam_scan_stats_event_handler,
3505 WMA_RX_SERIALIZER_CTX);
3506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003507#ifdef WLAN_FEATURE_LINK_LAYER_STATS
3508 /* Register event handler for processing Link Layer Stats
3509 * response from the FW
3510 */
3511 wma_register_ll_stats_event_handler(wma_handle);
3512
3513#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
3514
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +05303515 wmi_set_tgt_assert(wma_handle->wmi_handle,
3516 cds_cfg->force_target_assert_enabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303518 qdf_status = dbglog_init(wma_handle->wmi_handle);
3519 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003520 WMA_LOGE("%s: Firmware Dbglog initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 goto err_dbglog_init;
3522 }
3523
3524 /*
3525 * Update Powersave mode
3526 * 1 - Legacy Powersave + Deepsleep Disabled
3527 * 2 - QPower + Deepsleep Disabled
3528 * 3 - Legacy Powersave + Deepsleep Enabled
3529 * 4 - QPower + Deepsleep Enabled
3530 */
Wu Gao66454f12018-09-26 19:55:41 +08003531 wma_handle->powersave_mode =
3532 ucfg_pmo_power_save_offload_enabled(wma_handle->psoc);
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303533 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
Wu Gao66454f12018-09-26 19:55:41 +08003534 wma_handle->staModDtim = ucfg_pmo_get_sta_mod_dtim(wma_handle->psoc);
3535 wma_handle->staDynamicDtim =
3536 ucfg_pmo_get_sta_dynamic_dtim(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537
3538 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303539 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 * 0 - Disable both magic pattern match and pattern byte match.
3541 * 1 - Enable magic pattern match on all interfaces.
3542 * 2 - Enable pattern byte match on all interfaces.
3543 * 3 - Enable both magic patter and pattern byte match on
3544 * all interfaces.
3545 */
Wu Gao66454f12018-09-26 19:55:41 +08003546 wow_enable = ucfg_pmo_get_wow_enable(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547 wma_handle->wow.magic_ptrn_enable =
Wu Gao66454f12018-09-26 19:55:41 +08003548 (wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 wma_handle->ptrn_match_enable_all_vdev =
Wu Gao66454f12018-09-26 19:55:41 +08003550 (wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 /* register for install key completion event */
3553 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303554 wmi_vdev_install_key_complete_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303555 wma_vdev_install_key_complete_event_handler,
3556 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557
3558#ifdef WLAN_FEATURE_STATS_EXT
3559 /* register for extended stats event */
3560 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303561 wmi_stats_ext_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303562 wma_stats_ext_event_handler,
3563 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564#endif /* WLAN_FEATURE_STATS_EXT */
3565#ifdef FEATURE_WLAN_EXTSCAN
3566 wma_register_extscan_event_handler(wma_handle);
3567#endif /* WLAN_FEATURE_STATS_EXT */
3568
3569 WMA_LOGD("%s: Exit", __func__);
3570
3571#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3572 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303573 wmi_roam_synch_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303574 wma_roam_synch_event_handler,
3575 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303576 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303577 wmi_roam_synch_frame_event_id,
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303578 wma_roam_synch_frame_event_handler,
3579 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3581 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303582 wmi_rssi_breach_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303583 wma_rssi_breached_event_handler,
3584 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303586 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05303587 "wlan_fw_rsp_wakelock");
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003588 qdf_runtime_lock_init(&wma_handle->wmi_cmd_rsp_runtime_lock);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003589
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 /* Register peer assoc conf event handler */
3591 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303592 wmi_peer_assoc_conf_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303593 wma_peer_assoc_conf_handler,
3594 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003595 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303596 wmi_vdev_delete_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303597 wma_vdev_delete_handler,
3598 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003599 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303600 wmi_peer_delete_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303601 wma_peer_delete_handler,
3602 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05303603 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303604 wmi_chan_info_event_id,
Kapil Gupta4f0c0c12017-02-07 15:21:15 +05303605 wma_chan_info_event_handler,
3606 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003607 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303608 wmi_dbg_mesg_flush_complete_event_id,
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003609 wma_flush_complete_evt_handler,
Rajeev Kumarc3032b82017-02-14 15:56:01 -08003610 WMA_RX_WORK_CTX);
lifeng66831662017-05-19 16:01:35 +08003611 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303612 wmi_report_rx_aggr_failure_event_id,
lifeng66831662017-05-19 16:01:35 +08003613 wma_rx_aggr_failure_event_handler,
3614 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003615
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303616 wma_handle->ito_repeat_count = cds_cfg->ito_repeat_count;
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07003617 wma_handle->bandcapability = cds_cfg->bandcapability;
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303618
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303619 /* Register PWR_SAVE_FAIL event only in case of recovery(1) */
Wu Gao66454f12018-09-26 19:55:41 +08003620 if (ucfg_pmo_get_auto_power_fail_mode(wma_handle->psoc) ==
Hanumanth Reddy Pothulaab395952017-09-05 19:12:26 +05303621 PMO_FW_TO_SEND_WOW_IND_ON_PWR_FAILURE) {
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303622 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303623 wmi_pdev_chip_pwr_save_failure_detect_event_id,
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303624 wma_chip_power_save_failure_detected_handler,
3625 WMA_RX_WORK_CTX);
3626 }
3627
lifengd217d192017-05-09 19:44:16 +08003628 wmi_unified_register_event_handler(wma_handle->wmi_handle,
lifengfe6c3e22018-04-03 12:10:04 +08003629 wmi_pdev_div_rssi_antid_event_id,
3630 wma_pdev_div_info_evt_handler,
lifengd217d192017-05-09 19:44:16 +08003631 WMA_RX_WORK_CTX);
3632
Frank Liu65b17d92016-11-23 15:58:44 +08003633
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303634 wma_register_debug_callback();
Ashish Kumar Dhanotiyacd311c82018-09-14 10:55:10 +05303635 wifi_pos_register_get_phy_mode_cb(wma_handle->psoc,
3636 wma_get_phy_mode_cb);
3637
Mukul Sharma6411bb82017-03-01 15:57:07 +05303638 /* Register callback with PMO so PMO can update the vdev pause bitmap*/
3639 pmo_register_pause_bitmap_notifier(wma_handle->psoc,
3640 wma_vdev_update_pause_bitmap);
3641 pmo_register_get_pause_bitmap(wma_handle->psoc,
3642 wma_vdev_get_pause_bitmap);
Will Huangad015772018-06-15 11:27:50 +08003643 pmo_register_get_vdev_dp_handle(wma_handle->psoc,
3644 wma_vdev_get_vdev_dp_handle);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303645 pmo_register_is_device_in_low_pwr_mode(wma_handle->psoc,
3646 wma_vdev_is_device_in_low_pwr_mode);
Mukul Sharma44746042018-05-24 17:30:52 +05303647 pmo_register_get_cfg_int_callback(wma_handle->psoc,
3648 wma_vdev_get_cfg_int);
Nachiket Kukade37b4e6d2018-06-01 18:44:42 +05303649 pmo_register_get_dtim_period_callback(wma_handle->psoc,
3650 wma_vdev_get_dtim_period);
3651 pmo_register_get_beacon_interval_callback(wma_handle->psoc,
3652 wma_vdev_get_beacon_interval);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003653 wma_cbacks.wma_get_connection_info = wma_get_connection_info;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003654 qdf_status = policy_mgr_register_wma_cb(wma_handle->psoc, &wma_cbacks);
3655 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
3656 WMA_LOGE("Failed to register wma cb with Policy Manager");
3657 }
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303658
Arif Hussainf63f7a32017-08-22 12:49:42 -07003659 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303660 wmi_phyerr_event_id,
Arif Hussainf63f7a32017-08-22 12:49:42 -07003661 wma_unified_phyerr_rx_event_handler,
3662 WMA_RX_WORK_CTX);
3663
Arif Hussainee10f902017-12-27 16:30:17 -08003664 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3665 wmi_sap_obss_detection_report_event_id,
3666 wma_vdev_obss_detection_info_handler,
3667 WMA_RX_SERIALIZER_CTX);
3668
Arif Hussain05fb4872018-01-03 16:02:55 -08003669 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3670 wmi_obss_color_collision_report_event_id,
3671 wma_vdev_bss_color_collision_info_handler,
3672 WMA_RX_WORK_CTX);
3673
Varun Reddy Yeturud33033f2018-06-11 10:58:30 -07003674#ifdef WLAN_SUPPORT_TWT
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -07003675 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3676 wmi_twt_enable_complete_event_id,
3677 wma_twt_en_complete_event_handler,
3678 WMA_RX_SERIALIZER_CTX);
3679#endif
3680
Nachiket Kukade177b5b02018-05-22 20:52:17 +05303681 wma_register_apf_events(wma_handle);
Arif Hussain05fb4872018-01-03 16:02:55 -08003682
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303683 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684
3685err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303686 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003687 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303688 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
3689 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690err_event_init:
3691 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303692 wmi_debug_print_event_id);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003693
3694 for (i = 0; i < wma_handle->max_bssid; ++i)
3695 wma_vdev_deinit(&wma_handle->interfaces[i]);
3696
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303697 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699err_scn_context:
Jeff Johnson2b6982c2018-05-29 14:56:11 -07003700 qdf_mem_free(((struct cds_context *) cds_context)->cfg_ctx);
Rajeev Kumarfe6e62f2018-10-22 16:18:41 -07003701 ((struct cds_context *)cds_context)->cfg_ctx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702 OS_FREE(wmi_handle);
3703
3704err_wma_handle:
Zhu Jianminf9e2e2d2018-05-30 16:20:24 +08003705 wlan_objmgr_psoc_release_ref(psoc, WLAN_LEGACY_WMA_ID);
3706err_get_psoc_ref:
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303707 target_if_free_psoc_tgt_info(psoc);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303708 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303710 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303712 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05303713 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
3714 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
3715 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
3716 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
3717 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
3718 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
3719 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303721err_free_wma_handle:
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003722 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723
3724 WMA_LOGD("%s: Exit", __func__);
3725
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303726 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727}
3728
3729/**
3730 * wma_pre_start() - wma pre start
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 *
3732 * Return: 0 on success, errno on failure
3733 */
Jeff Johnson8ad89c62017-09-13 08:55:55 -07003734QDF_STATUS wma_pre_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003735{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303736 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 tp_wma_handle wma_handle;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08003738 struct scheduler_msg wma_msg = { 0 };
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303739 void *htc_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003740
3741 WMA_LOGD("%s: Enter", __func__);
3742
Anurag Chouhan6d760662016-02-20 16:05:43 +05303743 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744
3745 /* Validate the wma_handle */
3746 if (NULL == wma_handle) {
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303747 WMA_LOGE("%s: invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303748 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749 goto end;
3750 }
Nachiket Kukade8003d252017-03-30 15:55:58 +05303751
Sourav Mohapatracf632572018-04-02 11:01:35 +05303752 htc_handle = lmac_get_htc_hdl(wma_handle->psoc);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303753 if (!htc_handle) {
3754 WMA_LOGE("%s: invalid htc handle", __func__);
3755 qdf_status = QDF_STATUS_E_INVAL;
3756 goto end;
3757 }
3758
3759 /* Open endpoint for ctrl path - WMI <--> HTC */
3760 qdf_status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
3761 htc_handle);
3762 if (qdf_status != QDF_STATUS_SUCCESS) {
3763 WMA_LOGE("%s: wmi_unified_connect_htc_service", __func__);
Nachiket Kukade8003d252017-03-30 15:55:58 +05303764 if (!cds_is_fw_down())
3765 QDF_BUG(0);
3766
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303767 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003768 goto end;
3769 }
3770
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08003771 WMA_LOGD("WMA --> wmi_unified_connect_htc_service - success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772
3773 /* Trigger the CFG DOWNLOAD */
3774 wma_msg.type = WNI_CFG_DNLD_REQ;
3775 wma_msg.bodyptr = NULL;
3776 wma_msg.bodyval = 0;
3777
gaurank kathpalia00861f02018-08-28 19:16:12 +05303778 qdf_status = scheduler_post_message(QDF_MODULE_ID_WMA,
3779 QDF_MODULE_ID_WMA,
3780 QDF_MODULE_ID_WMA, &wma_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303781 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003782 WMA_LOGE("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303783 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303784 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 }
3786end:
3787 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303788 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789}
3790
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303791void wma_send_msg_by_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3792 void *body_ptr, uint32_t body_val, bool is_high_priority)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793{
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303794 struct scheduler_msg msg = {0};
3795 QDF_STATUS status;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 msg.type = msg_type;
3798 msg.bodyval = body_val;
3799 msg.bodyptr = body_ptr;
Will Huang9323e852018-02-02 17:55:15 +08003800 msg.flush_callback = wma_discard_fw_event;
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303801
3802 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE,
3803 &msg, is_high_priority);
3804 if (!QDF_IS_STATUS_SUCCESS(status)) {
3805 WMA_LOGE("Failed to post msg %d to PE", msg_type);
3806 if (body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303807 qdf_mem_free(body_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809}
3810
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303811
3812void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
3813 void *body_ptr, uint32_t body_val)
3814{
3815 wma_send_msg_by_priority(wma_handle, msg_type,
3816 body_ptr, body_val, false);
3817}
3818
3819void wma_send_msg_high_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3820 void *body_ptr, uint32_t body_val)
3821{
3822 wma_send_msg_by_priority(wma_handle, msg_type,
3823 body_ptr, body_val, true);
3824}
3825
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826/**
3827 * wma_set_base_macaddr_indicate() - set base mac address in fw
3828 * @wma_handle: wma handle
3829 * @customAddr: base mac address
3830 *
3831 * Return: 0 for success or error code
3832 */
3833static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
3834 tSirMacAddr *customAddr)
3835{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003836 int err;
3837
Govind Singhf25a0f12016-03-08 16:09:48 +05303838 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
3839 (uint8_t *)customAddr);
3840 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003842 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
3843 MAC_ADDR_ARRAY((*customAddr)));
3844
3845 return 0;
3846}
3847
3848/**
3849 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
3850 * @handle: WMA handle
3851 * @event: Event received from FW
3852 * @len: Length of the event
3853 *
3854 * Enables the low frequency events and disables the high frequency
3855 * events. Bit 17 indicates if the event if low/high frequency.
3856 * 1 - high frequency, 0 - low frequency
3857 *
3858 * Return: 0 on successfully enabling/disabling the events
3859 */
3860static int wma_log_supported_evt_handler(void *handle,
3861 uint8_t *event,
3862 uint32_t len)
3863{
3864 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865
Govind Singhf25a0f12016-03-08 16:09:48 +05303866 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
3867 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869
3870 return 0;
3871}
3872
3873/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303874 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875 * @handle: WMI handle
3876 * @event: Event recevied from FW
3877 * @len: Length of the event
3878 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303879 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
3880 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
3881 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882 *
Dustin Brownec2c92e2017-07-26 11:13:49 -07003883 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303885static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886 uint8_t *event,
3887 uint32_t len)
3888{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303889 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
3890 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
3891 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 uint32_t i;
3893 struct sir_set_hw_mode_resp *hw_mode_resp;
3894 tp_wma_handle wma = (tp_wma_handle) handle;
3895
3896 if (!wma) {
3897 WMA_LOGE("%s: Invalid WMA handle", __func__);
3898 /* Since WMA handle itself is NULL, we cannot send fail
3899 * response back to LIM here
3900 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303901 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003902 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003903
3904 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -08003905 wma_remove_req(wma, 0, WMA_PDEV_SET_HW_MODE_RESP);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003906
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303907 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 if (!hw_mode_resp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909 /* Since this memory allocation itself failed, we cannot
3910 * send fail response back to LIM here
3911 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303912 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 }
3914
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303915 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303917 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 /* Need to send response back to upper layer to free
3919 * active command list
3920 */
3921 goto fail;
3922 }
Krunal Soni50a05542017-10-03 19:39:48 -07003923 if (param_buf->fixed_param->num_vdev_mac_entries >=
3924 MAX_VDEV_SUPPORTED) {
3925 WMA_LOGE("num_vdev_mac_entries crossed max value");
3926 goto fail;
3927 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928
3929 wmi_event = param_buf->fixed_param;
Abhinav Kumara03659c2017-12-28 15:18:07 +05303930 if (wmi_event->num_vdev_mac_entries >
3931 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
3932 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
3933 wmi_event->num_vdev_mac_entries);
3934 goto fail;
3935 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 hw_mode_resp->status = wmi_event->status;
3937 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3938 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
3939
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003940 WMA_LOGD("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 __func__, wmi_event->status,
3942 wmi_event->cfgd_hw_mode_index,
3943 wmi_event->num_vdev_mac_entries);
3944 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303945 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946
3947 /* Store the vdev-mac map in WMA and prepare to send to PE */
3948 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303949 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003950
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003951 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303952 pdev_id = vdev_mac_entry[i].pdev_id;
3953 if (pdev_id == WMI_PDEV_ID_SOC) {
3954 WMA_LOGE("%s: soc level id received for mac id)",
Tushnim Bhattacharyyac23d56c2018-10-05 14:11:43 -07003955 __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303956 goto fail;
3957 }
Pragaspathi Thilagaraj0092b672018-05-23 17:08:45 +05303958 if (vdev_id >= wma->max_bssid) {
3959 WMA_LOGE("%s: vdev_id: %d is invalid, max_bssid: %d",
3960 __func__, vdev_id, wma->max_bssid);
3961 goto fail;
3962 }
3963
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303964 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003966 WMA_LOGD("%s: vdev_id:%d mac_id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 __func__, vdev_id, mac_id);
3968
3969 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
3970 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
3971 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3972 wmi_event->cfgd_hw_mode_index);
3973 }
3974
3975 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
3976 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
3977 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3978 } else {
3979 wma->old_hw_mode_index = wma->new_hw_mode_index;
3980 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3981 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003982 policy_mgr_update_hw_mode_index(wma->psoc,
3983 wmi_event->cfgd_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003984 }
3985
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003986 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3988
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303989 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 (void *) hw_mode_resp, 0);
3991
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303992 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993
3994fail:
3995 WMA_LOGE("%s: Sending fail response to LIM", __func__);
3996 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
3997 hw_mode_resp->cfgd_hw_mode_index = 0;
3998 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303999 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000 (void *) hw_mode_resp, 0);
4001
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304002 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003}
4004
4005/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004006 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
4007 *
4008 * @handle: WMA handle
4009 * @fixed_param: Event fixed parameters
4010 * @vdev_mac_entry - vdev mac entry
4011 * @hw_mode_trans_ind - Buffer to store parsed information
4012 *
4013 * Parses fixed_param, vdev_mac_entry and fills in the information into
4014 * hw_mode_trans_ind and wma
4015 *
4016 * Return: None
4017 */
4018void wma_process_pdev_hw_mode_trans_ind(void *handle,
4019 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
4020 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
4021 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
4022{
4023 uint32_t i;
4024 tp_wma_handle wma = (tp_wma_handle) handle;
Harprit Chhabada3cfca962018-12-04 13:41:31 -08004025
gaurank kathpaliad2967a72018-05-01 12:35:14 +05304026 if (fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
4027 WMA_LOGE("Number of Vdev mac entries %d exceeded"
4028 " max vdev supported %d",
4029 fixed_param->num_vdev_mac_entries,
4030 MAX_VDEV_SUPPORTED);
4031 return;
4032 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004033 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
4034 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
4035 hw_mode_trans_ind->num_vdev_mac_entries =
4036 fixed_param->num_vdev_mac_entries;
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08004037 WMA_LOGD("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004038 __func__, fixed_param->old_hw_mode_index,
4039 fixed_param->new_hw_mode_index,
4040 fixed_param->num_vdev_mac_entries);
4041
Harprit Chhabada3cfca962018-12-04 13:41:31 -08004042 if (!vdev_mac_entry) {
4043 WMA_LOGE("Invalid vdev_mac_entry");
4044 return;
4045 }
4046
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004047 /* Store the vdev-mac map in WMA and send to policy manager */
4048 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
4049 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004050
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004051 vdev_id = vdev_mac_entry[i].vdev_id;
4052 pdev_id = vdev_mac_entry[i].pdev_id;
4053
4054 if (pdev_id == WMI_PDEV_ID_SOC) {
4055 WMA_LOGE("%s: soc level id received for mac id)",
Tushnim Bhattacharyyac23d56c2018-10-05 14:11:43 -07004056 __func__);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004057 return;
4058 }
Pragaspathi Thilagaraj0092b672018-05-23 17:08:45 +05304059 if (vdev_id >= wma->max_bssid) {
4060 WMA_LOGE("%s: vdev_id: %d is invalid, max_bssid: %d",
4061 __func__, vdev_id, wma->max_bssid);
4062 return;
4063 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004064
4065 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
4066
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004067 WMA_LOGE("%s: vdev_id:%d mac_id:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004068 __func__, vdev_id, mac_id);
4069
4070 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
4071 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
4072 wma_update_intf_hw_mode_params(vdev_id, mac_id,
4073 fixed_param->new_hw_mode_index);
4074 }
4075 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
4076 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004077 policy_mgr_update_new_hw_mode_index(wma->psoc,
4078 fixed_param->new_hw_mode_index);
4079 policy_mgr_update_old_hw_mode_index(wma->psoc,
4080 fixed_param->old_hw_mode_index);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004081
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08004082 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004083 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
4084}
4085
4086/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304087 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 * @handle: WMI handle
4089 * @event: Event recevied from FW
4090 * @len: Length of the event
4091 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304092 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 * asynchronous hardware mode transition. This event notifies the host driver
4094 * that firmware independently changed the hardware mode for some reason, such
4095 * as Coex, LFR 3.0, etc
4096 *
4097 * Return: Success on receiving valid params from FW
4098 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304099static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 uint8_t *event,
4101 uint32_t len)
4102{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304103 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
4104 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
4105 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
4107 tp_wma_handle wma = (tp_wma_handle) handle;
4108
4109 if (!wma) {
4110 /* This is an async event. So, not sending any event to LIM */
4111 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304112 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 }
4114
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304115 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 if (!param_buf) {
4117 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304118 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304119 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 }
4121
Arif Hussain34f72062017-10-04 17:25:24 -07004122 if (param_buf->fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
4123 WMA_LOGE("num_vdev_mac_entries: %d crossed max value: %d",
4124 param_buf->fixed_param->num_vdev_mac_entries,
4125 MAX_VDEV_SUPPORTED);
4126 return QDF_STATUS_E_FAILURE;
4127 }
4128
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304129 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Arif Hussain157263f2018-10-03 13:07:15 -07004130 if (!hw_mode_trans_ind)
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004131 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132
4133 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304135 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Abhinav Kumara03659c2017-12-28 15:18:07 +05304136 if (wmi_event->num_vdev_mac_entries >
4137 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
4138 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
4139 wmi_event->num_vdev_mac_entries);
4140 qdf_mem_free(hw_mode_trans_ind);
4141 return -EINVAL;
4142 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004143 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
4144 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304146 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 (void *) hw_mode_trans_ind, 0);
4148
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304149 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150}
4151
4152/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304153 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 * @handle: WMI handle
4155 * @event: Event received from FW
4156 * @len: Length of the event
4157 *
4158 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304159 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 * the host driver once the firmware has completed a reconfiguration of the Scan
4161 * and FW mode configuration. This changes could include entering or leaving a
4162 * dual mac configuration for either scan and/or more permanent firmware mode.
4163 *
4164 * Return: Success on receiving valid params from FW
4165 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304166static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 uint8_t *event,
4168 uint32_t len)
4169{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304170 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
4171 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 tp_wma_handle wma = (tp_wma_handle) handle;
4173 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
4174
4175 if (!wma) {
4176 WMA_LOGE("%s: Invalid WMA handle", __func__);
4177 /* Since the WMA handle is NULL, we cannot send resp to LIM.
4178 * So, returning from here.
4179 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304180 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 }
Krunal Sonia5ccb802017-07-03 12:59:40 -07004182 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Abhishek Singhd93a0b22018-10-30 17:04:56 +05304183 wma_remove_req(wma, 0, WMA_PDEV_MAC_CFG_RESP);
4184
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304185 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Arif Hussain157263f2018-10-03 13:07:15 -07004186 if (!dual_mac_cfg_resp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 /* Since the mem alloc failed, we cannot send resp to LIM.
4188 * So, returning from here.
4189 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304190 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304192 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193 event;
4194 if (!param_buf) {
4195 WMA_LOGE("%s: Invalid event", __func__);
4196 goto fail;
4197 }
4198
4199 wmi_event = param_buf->fixed_param;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004200 WMA_LOGD("%s: status:%d", __func__, wmi_event->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 dual_mac_cfg_resp->status = wmi_event->status;
4202
4203 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004204 policy_mgr_update_dbs_scan_config(wma->psoc);
4205 policy_mgr_update_dbs_fw_config(wma->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 }
4207
4208 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304209 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 (void *) dual_mac_cfg_resp, 0);
4211
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304212 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213
4214fail:
4215 WMA_LOGE("%s: Sending fail response to LIM", __func__);
4216 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304217 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 (void *) dual_mac_cfg_resp, 0);
4219
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304220 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221
4222}
4223
4224/**
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304225 * wma_send_time_stamp_sync_cmd() - timer callback send timestamp to
4226 * firmware to sync with host.
4227 * @wma_handle: wma handle
4228 *
4229 * Return: void
4230 */
4231static void wma_send_time_stamp_sync_cmd(void *data)
4232{
4233 tp_wma_handle wma_handle;
4234 QDF_STATUS qdf_status;
4235
4236 wma_handle = (tp_wma_handle) data;
4237
4238 wmi_send_time_stamp_sync_cmd_tlv(wma_handle->wmi_handle);
4239
4240 /* Start/Restart the timer */
4241 qdf_status = qdf_mc_timer_start(&wma_handle->wma_fw_time_sync_timer,
4242 WMA_FW_TIME_SYNC_TIMER);
4243 if (QDF_IS_STATUS_ERROR(qdf_status))
4244 WMA_LOGE("Failed to start the firmware time sync timer");
4245}
4246
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07004247#ifdef WLAN_CONV_SPECTRAL_ENABLE
4248static void wma_register_spectral_cmds(tp_wma_handle wma_handle)
4249{
4250 struct wmi_spectral_cmd_ops cmd_ops;
4251
4252 cmd_ops.wmi_spectral_configure_cmd_send =
4253 wmi_unified_vdev_spectral_configure_cmd_send;
4254 cmd_ops.wmi_spectral_enable_cmd_send =
4255 wmi_unified_vdev_spectral_enable_cmd_send;
4256 wlan_register_wmi_spectral_cmd_ops(wma_handle->pdev, &cmd_ops);
4257}
4258#else
4259static void wma_register_spectral_cmds(tp_wma_handle wma_handle)
4260{
4261}
4262#endif
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304263/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 * wma_start() - wma start function.
Jeff Johnsonc97816c2018-05-12 17:13:23 -07004265 * Initialize event handlers and timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304267 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 */
Jeff Johnsond4892552017-09-13 08:41:31 -07004269QDF_STATUS wma_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304271 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 tp_wma_handle wma_handle;
4273 int status;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304274 struct wmi_unified *wmi_handle;
Ke Huangae49ad02018-11-27 10:53:11 +08004275 struct mac_context *mac = NULL;
4276 uint32_t cfg_val;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07004277
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278 WMA_LOGD("%s: Enter", __func__);
4279
Anurag Chouhan6d760662016-02-20 16:05:43 +05304280 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 /* validate the wma_handle */
4282 if (NULL == wma_handle) {
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304283 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304284 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004285 goto end;
4286 }
Sandeep Puligillad698bf52017-09-15 16:07:02 -07004287
Sourav Mohapatracf632572018-04-02 11:01:35 +05304288 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304289 if (!wmi_handle) {
4290 WMA_LOGE("%s: Invalid wmi handle", __func__);
4291 qdf_status = QDF_STATUS_E_INVAL;
4292 goto end;
4293 }
4294
Ke Huangae49ad02018-11-27 10:53:11 +08004295 mac = cds_get_context(QDF_MODULE_ID_PE);
4296 if (!mac) {
4297 WMA_LOGE("%s: Invalid mac context", __func__);
4298 goto end;
4299 }
4300
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304301 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304302 wmi_roam_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304303 wma_roam_event_callback,
Padma, Santhosh Kumar18169ce2017-03-02 18:04:02 +05304304 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004306 WMA_LOGE("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304307 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 goto end;
4309 }
4310
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304311 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304312 wmi_wow_wakeup_host_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304313 wma_wow_wakeup_host_event,
4314 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004316 WMA_LOGE("%s: Failed to register wow wakeup host event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304318 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 goto end;
4320 }
4321
Will Huang3cd2b7c2017-11-17 13:16:56 +08004322 if (wma_d0_wow_is_supported()) {
4323 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304324 wmi_handle,
Will Huang9adefff2017-12-15 14:50:03 +08004325 wmi_d0_wow_disable_ack_event_id,
Will Huang3cd2b7c2017-11-17 13:16:56 +08004326 wma_d0_wow_disable_ack_event,
4327 WMA_RX_TASKLET_CTX);
4328 if (status) {
4329 WMA_LOGE("%s: Failed to register d0wow disable ack"
4330 " event handler", __func__);
4331 qdf_status = QDF_STATUS_E_FAILURE;
4332 goto end;
4333 }
4334 }
4335
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304336 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304337 wmi_pdev_resume_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304338 wma_pdev_resume_event_handler,
4339 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004340 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004341 WMA_LOGE("%s: Failed to register PDEV resume event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304343 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 goto end;
4345 }
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05304346#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
4347 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004348 WMA_LOGD("MCC TX Pause Event Handler register");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304349 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304350 wmi_tx_pause_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304351 wma_mcc_vdev_tx_pause_evt_handler,
4352 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
4354
Kabilan Kannancaa85502018-04-13 18:04:58 -07004355 WMA_LOGD("Registering SAR2 response handler");
4356 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4357 wmi_wlan_sar2_result_event_id,
4358 wma_sar_rsp_evt_handler,
4359 WMA_RX_SERIALIZER_CTX);
4360 if (status) {
4361 WMA_LOGE("Failed to register sar response event cb");
4362 qdf_status = QDF_STATUS_E_FAILURE;
4363 goto end;
4364 }
4365
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
4367 WMA_LOGD("Registering auto shutdown handler");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304368 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304369 wmi_host_auto_shutdown_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304370 wma_auto_shutdown_event_handler,
4371 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004372 if (status) {
4373 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304374 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 goto end;
4376 }
4377#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304378 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304379 wmi_thermal_mgmt_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304380 wma_thermal_mgmt_evt_handler,
4381 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004382 if (status) {
4383 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304384 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385 goto end;
4386 }
4387
Zhang Qian47e22ce2018-01-04 15:38:38 +08004388 status = wma_ocb_register_callbacks(wma_handle);
4389 if (!QDF_IS_STATUS_SUCCESS(status)) {
4390 WMA_LOGE("Failed to register OCB callbacks");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304391 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004392 goto end;
4393 }
4394
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304395 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396
4397#ifdef QCA_WIFI_FTM
4398 /*
4399 * Tx mgmt attach requires TXRX context which is not created
4400 * in FTM mode. So skip the TX mgmt attach.
4401 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304402 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 goto end;
4404#endif /* QCA_WIFI_FTM */
4405
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304406 if (wmi_service_enabled(wmi_handle, wmi_service_rmc)) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004407
4408 WMA_LOGD("FW supports cesium network, registering event handlers");
4409
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004410 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304411 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304412 wmi_peer_info_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004413 wma_ibss_peer_info_event_handler,
4414 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004415 if (status) {
4416 WMA_LOGE("Failed to register ibss peer info event cb");
4417 qdf_status = QDF_STATUS_E_FAILURE;
4418 goto end;
4419 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004420 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304421 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304422 wmi_peer_tx_fail_cnt_thr_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004423 wma_fast_tx_fail_event_handler,
4424 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004425 if (status) {
4426 WMA_LOGE("Failed to register peer fast tx failure event cb");
4427 qdf_status = QDF_STATUS_E_FAILURE;
4428 goto end;
4429 }
4430 } else {
4431 WMA_LOGE("Target does not support cesium network");
4432 }
4433
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304434 qdf_status = wma_tx_attach(wma_handle);
4435 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004436 WMA_LOGE("%s: Failed to register tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 goto end;
4438 }
4439
Ke Huangae49ad02018-11-27 10:53:11 +08004440 if (wlan_cfg_get_int(mac, WNI_CFG_REMOVE_TIME_SYNC_CMD,
4441 &cfg_val) == QDF_STATUS_SUCCESS) {
4442 if (cfg_val == 0 && cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4443 /* Initialize firmware time stamp sync timer */
4444 qdf_status =
4445 qdf_mc_timer_init(
4446 &wma_handle->wma_fw_time_sync_timer,
4447 QDF_TIMER_TYPE_SW,
4448 wma_send_time_stamp_sync_cmd,
4449 wma_handle);
4450 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4451 WMA_LOGE("Failed to init fw time sync timer");
4452 goto end;
4453 }
4454
4455 /* Start firmware time stamp sync timer */
4456 wma_send_time_stamp_sync_cmd(wma_handle);
Lin Bai5dc8ddb2018-08-23 17:46:34 +08004457 }
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304458 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05304460 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304461 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462 wma_log_completion_timeout,
4463 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304464 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 WMA_LOGE("Failed to initialize log completion timeout");
4466 goto end;
4467 }
4468
Jeff Johnson6136fb92017-03-30 15:21:49 -07004469 status = wma_fips_register_event_handlers(wma_handle);
4470 if (!QDF_IS_STATUS_SUCCESS(status)) {
4471 WMA_LOGE("Failed to register FIPS event handler");
4472 qdf_status = QDF_STATUS_E_FAILURE;
4473 goto end;
4474 }
4475
Jeff Johnsonf0e54b02017-12-18 15:22:25 -08004476 status = wma_sar_register_event_handlers(wma_handle);
4477 if (!QDF_IS_STATUS_SUCCESS(status)) {
4478 WMA_LOGE("Failed to register SAR event handlers");
4479 qdf_status = QDF_STATUS_E_FAILURE;
4480 goto end;
4481 }
4482
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 /* Initialize the get temperature event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304484 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304485 wmi_pdev_temperature_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304486 wma_pdev_temperature_evt_handler,
4487 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304488 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304490 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 goto end;
4492 }
4493
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304494 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304495 wmi_vdev_tsf_report_event_id,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004496 wma_vdev_tsf_handler,
4497 WMA_RX_SERIALIZER_CTX);
4498 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004499 WMA_LOGE("%s: Failed to register tsf callback", __func__);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004500 qdf_status = QDF_STATUS_E_FAILURE;
4501 goto end;
4502 }
4503
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304504 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304505 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304506 wmi_pdev_set_hw_mode_rsp_event_id,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304507 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304508 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304509 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304511 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 goto end;
4513 }
4514
4515 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304516 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304517 wmi_pdev_hw_mode_transition_event_id,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304518 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304519 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304520 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304522 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 goto end;
4524 }
4525
4526 /* Initialize the set dual mac configuration event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304527 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304528 wmi_pdev_set_mac_config_resp_event_id,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304529 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304530 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304531 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304533 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 goto end;
4535 }
4536
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304537 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304538 wmi_coex_bt_activity_event_id,
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304539 wma_wlan_bt_activity_evt_handler,
4540 WMA_RX_SERIALIZER_CTX);
4541 if (!QDF_IS_STATUS_SUCCESS(status)) {
4542 WMA_LOGE("Failed to register coex bt activity event handler");
4543 qdf_status = QDF_STATUS_E_FAILURE;
4544 goto end;
4545 }
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07004546 wma_register_spectral_cmds(wma_handle);
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548end:
4549 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304550 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551}
4552
Jeff Johnson62cd6802018-07-20 12:38:25 -07004553QDF_STATUS wma_stop(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554{
4555 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304556 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05304557 int i;
Ke Huangae49ad02018-11-27 10:53:11 +08004558 struct mac_context *mac = NULL;
4559 uint32_t cfg_val;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004560
Anurag Chouhan6d760662016-02-20 16:05:43 +05304561 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 WMA_LOGD("%s: Enter", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 /* validate the wma_handle */
4564 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004565 WMA_LOGE("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304566 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 goto end;
4568 }
Ke Huangae49ad02018-11-27 10:53:11 +08004569 mac = cds_get_context(QDF_MODULE_ID_PE);
4570 if (!mac) {
4571 WMA_LOGE("%s: Invalid mac context", __func__);
4572 goto end;
4573 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574#ifdef QCA_WIFI_FTM
4575 /*
4576 * Tx mgmt detach requires TXRX context which is not created
4577 * in FTM mode. So skip the TX mgmt detach.
4578 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304579 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304580 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 goto end;
4582 }
4583#endif /* QCA_WIFI_FTM */
4584
4585 if (wma_handle->ack_work_ctx) {
4586 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304587 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 wma_handle->ack_work_ctx = NULL;
4589 }
4590
4591 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05304592 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004593 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 WMA_LOGE("Failed to destroy the log completion timer");
Govind Singhede435f2015-12-01 16:16:36 +05304595 /* clean up ll-queue for all vdev */
4596 for (i = 0; i < wma_handle->max_bssid; i++) {
4597 if (wma_handle->interfaces[i].handle &&
Mukul Sharmaf9047232017-03-02 16:58:56 +05304598 wma_is_vdev_up(i)) {
Leo Chang96464902016-10-28 11:10:54 -07004599 cdp_fc_vdev_flush(
4600 cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08004601 wma_handle->
4602 interfaces[i].handle);
Govind Singhede435f2015-12-01 16:16:36 +05304603 }
4604 }
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304605
Ke Huangae49ad02018-11-27 10:53:11 +08004606 if (wlan_cfg_get_int(mac, WNI_CFG_REMOVE_TIME_SYNC_CMD,
4607 &cfg_val) == QDF_STATUS_SUCCESS) {
4608 if (cfg_val == 0 && cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4609 /* Destroy firmware time stamp sync timer */
4610 qdf_status = qdf_mc_timer_destroy(
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304611 &wma_handle->wma_fw_time_sync_timer);
Ke Huangae49ad02018-11-27 10:53:11 +08004612 if (QDF_IS_STATUS_ERROR(qdf_status))
4613 WMA_LOGE("Failed to destory fw sync timer");
4614 }
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304615 }
4616
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304617 qdf_status = wma_tx_detach(wma_handle);
4618 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004619 WMA_LOGE("%s: Failed to deregister tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 goto end;
4621 }
4622
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623end:
4624 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304625 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626}
4627
4628/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 * wma_wmi_service_close() - close wma wmi service interface.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304631 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 */
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004633QDF_STATUS wma_wmi_service_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634{
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004635 void *cds_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 tp_wma_handle wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 int i;
4638
4639 WMA_LOGD("%s: Enter", __func__);
4640
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004641 cds_ctx = cds_get_global_context();
4642 if (!cds_ctx) {
4643 WMA_LOGE("%s: Invalid CDS context", __func__);
4644 return QDF_STATUS_E_INVAL;
4645 }
4646
Anurag Chouhan6d760662016-02-20 16:05:43 +05304647 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648
4649 /* validate the wma_handle */
4650 if (NULL == wma_handle) {
4651 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304652 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 }
4654
4655 /* validate the wmi handle */
4656 if (NULL == wma_handle->wmi_handle) {
4657 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304658 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659 }
4660
4661 /* dettach the wmi serice */
4662 WMA_LOGD("calling wmi_unified_detach");
4663 wmi_unified_detach(wma_handle->wmi_handle);
4664 wma_handle->wmi_handle = NULL;
4665
4666 for (i = 0; i < wma_handle->max_bssid; i++) {
Dustin Brownec2c92e2017-07-26 11:13:49 -07004667 wma_vdev_deinit(&wma_handle->interfaces[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668 }
4669
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304670 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07004671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672 /* free the wma_handle */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07004673 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674
hangtiane52fa912018-11-26 15:44:38 +08004675 if (((struct cds_context *)cds_ctx)->cfg_ctx)
4676 qdf_mem_free(((struct cds_context *)cds_ctx)->cfg_ctx);
Rajeev Kumarfe6e62f2018-10-22 16:18:41 -07004677 ((struct cds_context *)cds_ctx)->cfg_ctx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304679 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680}
4681
Xun Luoa858a472015-11-10 08:24:45 -08004682/**
4683 * wma_wmi_work_close() - close the work queue items associated with WMI
Xun Luoa858a472015-11-10 08:24:45 -08004684 *
4685 * This function closes work queue items associated with WMI, but not fully
4686 * closes WMI service.
4687 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304688 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08004689 * proper error codes.
4690 */
Jeff Johnson6b8473d2017-09-13 09:20:53 -07004691QDF_STATUS wma_wmi_work_close(void)
Xun Luoa858a472015-11-10 08:24:45 -08004692{
4693 tp_wma_handle wma_handle;
4694
4695 WMA_LOGD("%s: Enter", __func__);
4696
Anurag Chouhan6d760662016-02-20 16:05:43 +05304697 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08004698
4699 /* validate the wma_handle */
4700 if (NULL == wma_handle) {
4701 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304702 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004703 }
4704
4705 /* validate the wmi handle */
4706 if (NULL == wma_handle->wmi_handle) {
4707 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304708 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004709 }
4710
4711 /* remove the wmi work */
4712 WMA_LOGD("calling wmi_unified_remove_work");
4713 wmi_unified_remove_work(wma_handle->wmi_handle);
4714
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304715 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08004716}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717
Krunal Soni2e48d012016-05-02 16:55:26 -07004718/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 * wma_close() - wma close function.
4720 * cleanup resources attached with wma.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304722 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723 */
Jeff Johnson542da352017-09-13 09:17:28 -07004724QDF_STATUS wma_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725{
4726 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304727 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004728
4729 WMA_LOGD("%s: Enter", __func__);
4730
Anurag Chouhan6d760662016-02-20 16:05:43 +05304731 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732
4733 /* validate the wma_handle */
4734 if (NULL == wma_handle) {
4735 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304736 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004737 }
4738
4739 /* validate the wmi handle */
4740 if (NULL == wma_handle->wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004741 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304742 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743 }
4744
4745 /* Free DBS list */
4746 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304747 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004749 WMA_LOGD("%s: DBS list is freed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004750 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05304751
Anurag Chouhan6d760662016-02-20 16:05:43 +05304752 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304754 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304756 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05304757 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
4758 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
4759 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
4760 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
4761 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
4762 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
4763 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 }
4765
4766 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304767 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
4768 if (qdf_status != QDF_STATUS_SUCCESS)
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004769 WMA_LOGE("%s: dbglog_deinit failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770
Anurag Chouhan210db072016-02-22 18:42:15 +05304771 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304772 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004773 WMA_LOGE("%s: Failed to destroy service ready ext event timer",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304774 __func__);
4775
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304776 qdf_event_destroy(&wma_handle->target_suspend);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304777 qdf_event_destroy(&wma_handle->runtime_suspend);
4778 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08004779 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
4780 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08004781 wma_cleanup_vdev_resp_queue(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304783 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08004784 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Poddar, Siddarth2fb98072017-07-19 14:58:30 +05304785 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
4786 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004788 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304789 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004790 wma_handle->pGetRssiReq = NULL;
4791 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07004792
yeshwanth sriram guntuka584c2332017-07-29 12:50:25 +05304793 wma_unified_radio_tx_mem_free(wma_handle);
Srinivas Girigowdaad874a82016-10-25 14:08:00 -07004794
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -07004795 if (wma_handle->pdev) {
4796 wlan_objmgr_pdev_release_ref(wma_handle->pdev,
4797 WLAN_LEGACY_WMA_ID);
4798 wma_handle->pdev = NULL;
4799 }
Frank Liu00d73fe2017-05-19 22:11:28 +08004800
Nachiket Kukade37b4e6d2018-06-01 18:44:42 +05304801 pmo_unregister_get_beacon_interval_callback(wma_handle->psoc);
4802 pmo_unregister_get_dtim_period_callback(wma_handle->psoc);
Mukul Sharma44746042018-05-24 17:30:52 +05304803 pmo_unregister_get_cfg_int_callback(wma_handle->psoc);
4804 pmo_unregister_is_device_in_low_pwr_mode(wma_handle->psoc);
4805 pmo_unregister_get_pause_bitmap(wma_handle->psoc);
4806 pmo_unregister_pause_bitmap_notifier(wma_handle->psoc);
Will Huangad015772018-06-15 11:27:50 +08004807 pmo_unregister_get_vdev_dp_handle(wma_handle->psoc);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304808
Arunk Khandavallia6305a32018-01-25 11:19:18 +05304809 target_if_free_psoc_tgt_info(wma_handle->psoc);
4810
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05304811 wlan_objmgr_psoc_release_ref(wma_handle->psoc, WLAN_LEGACY_WMA_ID);
4812 wma_handle->psoc = NULL;
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05304813 wma_target_if_close(wma_handle);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304814
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304816 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817}
4818
4819/**
4820 * wma_update_fw_config() - update fw configuration
Dustin Brownb9987af2018-03-01 17:15:11 -08004821 * @psoc: psoc to query configuration from
4822 * @tgt_hdl: target capability info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004823 *
4824 * Return: none
4825 */
Dustin Brownb9987af2018-03-01 17:15:11 -08004826static void wma_update_fw_config(struct wlan_objmgr_psoc *psoc,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304827 struct target_psoc_info *tgt_hdl)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828{
Dustin Brownb9987af2018-03-01 17:15:11 -08004829 target_resource_config *cfg = &tgt_hdl->info.wlan_res_cfg;
4830
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 /* Override the no. of max fragments as per platform configuration */
Dustin Brownb9987af2018-03-01 17:15:11 -08004832 cfg->max_frag_entries = QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304833 target_if_get_max_frag_entry(tgt_hdl));
Dustin Brownb9987af2018-03-01 17:15:11 -08004834 target_if_set_max_frag_entry(tgt_hdl, cfg->max_frag_entries);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304835
Dustin Brownb9987af2018-03-01 17:15:11 -08004836 cfg->num_wow_filters = ucfg_pmo_get_num_wow_filters(psoc);
Nachiket Kukadee547a482018-05-22 16:43:30 +05304837 cfg->apf_instruction_size = ucfg_pmo_get_apf_instruction_size(psoc);
Dustin Brown67d69eb2018-03-02 11:11:34 -08004838 cfg->num_packet_filters = ucfg_pmo_get_num_packet_filters(psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839}
4840
4841/**
Yun Parkb4f591d2017-03-29 15:51:01 -07004842 * wma_set_tx_partition_base() - set TX MSDU ID partition base for IPA
4843 * @value: TX MSDU ID partition base
4844 *
4845 * Return: none
4846 */
4847#ifdef IPA_OFFLOAD
4848static void wma_set_tx_partition_base(uint32_t value)
4849{
4850 cdp_ipa_set_uc_tx_partition_base(
4851 cds_get_context(QDF_MODULE_ID_SOC),
4852 (struct cdp_cfg *)cds_get_context(QDF_MODULE_ID_CFG),
4853 value);
4854 WMA_LOGD("%s: TX_MSDU_ID_PARTITION=%d", __func__,
4855 value);
4856}
4857#else
4858static void wma_set_tx_partition_base(uint32_t value)
4859{
4860}
4861#endif
4862
4863/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 * wma_update_target_services() - update target services from wma handle
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304865 * @wmi_handle: Unified wmi handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866 * @cfg: target services
4867 *
4868 * Return: none
4869 */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304870static inline void wma_update_target_services(struct wmi_unified *wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 struct wma_tgt_services *cfg)
4872{
4873 /* STA power save */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304874 cfg->sta_power_save = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304875 wmi_service_sta_pwrsave);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004876
4877 /* Enable UAPSD */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304878 cfg->uapsd = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304879 wmi_service_ap_uapsd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880
4881 /* Update AP DFS service */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304882 cfg->ap_dfs = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304883 wmi_service_ap_dfs);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884
4885 /* Enable 11AC */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304886 cfg->en_11ac = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304887 wmi_service_11ac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888 if (cfg->en_11ac)
4889 g_fw_wlan_feat_caps |= (1 << DOT11AC);
4890
4891 /* Proactive ARP response */
4892 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
4893
4894 /* Enable WOW */
4895 g_fw_wlan_feat_caps |= (1 << WOW);
4896
4897 /* ARP offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304898 cfg->arp_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304899 wmi_service_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900
4901 /* Adaptive early-rx */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304902 cfg->early_rx = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304903 wmi_service_early_rx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904#ifdef FEATURE_WLAN_SCAN_PNO
4905 /* PNO offload */
Rajeev Kumar617aadd2018-05-31 16:36:13 -07004906 if (wmi_service_enabled(wmi_handle, wmi_service_nlo)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 cfg->pno_offload = true;
Rajeev Kumar617aadd2018-05-31 16:36:13 -07004908 g_fw_wlan_feat_caps |= (1 << PNO);
4909 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004910#endif /* FEATURE_WLAN_SCAN_PNO */
4911
4912#ifdef FEATURE_WLAN_EXTSCAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304913 if (wmi_service_enabled(wmi_handle, wmi_service_extscan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004915#endif /* FEATURE_WLAN_EXTSCAN */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304916 cfg->lte_coex_ant_share = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304917 wmi_service_lte_ant_share_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918#ifdef FEATURE_WLAN_TDLS
4919 /* Enable TDLS */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304920 if (wmi_service_enabled(wmi_handle, wmi_service_tdls)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 cfg->en_tdls = 1;
4922 g_fw_wlan_feat_caps |= (1 << TDLS);
4923 }
4924 /* Enable advanced TDLS features */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304925 if (wmi_service_enabled(wmi_handle, wmi_service_tdls_offchan)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 cfg->en_tdls_offchan = 1;
4927 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
4928 }
4929
4930 cfg->en_tdls_uapsd_buf_sta =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304931 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304932 wmi_service_tdls_uapsd_buffer_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 cfg->en_tdls_uapsd_sleep_sta =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304934 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304935 wmi_service_tdls_uapsd_sleep_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936#endif /* FEATURE_WLAN_TDLS */
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304937 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304938 (wmi_handle, wmi_service_beacon_offload))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 cfg->beacon_offload = true;
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304940 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304941 (wmi_handle, wmi_service_sta_pmf_offload))
mukul sharma72c8b222015-09-04 17:02:01 +05304942 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004943#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4944 /* Enable Roam Offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304945 cfg->en_roam_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304946 wmi_service_roam_ho_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4948#ifdef WLAN_FEATURE_NAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304949 if (wmi_service_enabled(wmi_handle, wmi_service_nan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 g_fw_wlan_feat_caps |= (1 << NAN);
4951#endif /* WLAN_FEATURE_NAN */
4952
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304953 if (wmi_service_enabled(wmi_handle, wmi_service_rtt))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07004955
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304956 if (wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304957 wmi_service_tx_msdu_id_new_partition_support)) {
Yun Parkb4f591d2017-03-29 15:51:01 -07004958 wma_set_tx_partition_base(HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004959 } else {
Yun Parkb4f591d2017-03-29 15:51:01 -07004960 wma_set_tx_partition_base(HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004961 }
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004962
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304963 wma_he_update_tgt_services(wmi_handle, cfg);
Will Huang496b36c2017-07-11 16:38:50 +08004964
4965 cfg->get_peer_info_enabled =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304966 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304967 wmi_service_peer_stats_info);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304968 if (wmi_service_enabled(wmi_handle, wmi_service_fils_support))
Vignesh Viswanathan731186f2017-09-18 13:47:37 +05304969 cfg->is_fils_roaming_supported = true;
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004970
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304971 if (wmi_service_enabled(wmi_handle, wmi_service_mawc_support))
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004972 cfg->is_fw_mawc_capable = true;
4973
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304974 if (wmi_service_enabled(wmi_handle,
4975 wmi_service_11k_neighbour_report_support))
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304976 cfg->is_11k_offload_supported = true;
Varun Reddy Yeturu4b54ec82018-05-30 16:00:38 -07004977
4978 if (wmi_service_enabled(wmi_handle, wmi_service_twt_requestor))
4979 cfg->twt_requestor = true;
4980 if (wmi_service_enabled(wmi_handle, wmi_service_twt_responder))
4981 cfg->twt_responder = true;
Liangwei Dong0da14262018-07-03 03:30:23 -04004982 if (wmi_service_enabled(wmi_handle, wmi_service_obss_scan))
4983 cfg->obss_scan_offload = true;
Arunk Khandavallica56d4b2018-11-29 15:46:00 +05304984 if (wmi_service_enabled(wmi_handle, wmi_service_beacon_reception_stats))
4985 cfg->bcn_reception_stats = true;
Sourav Mohapatrac457ae62018-12-06 15:19:41 +05304986
4987 if (wmi_service_enabled(wmi_handle, wmi_service_vdev_latency_config))
4988 g_fw_wlan_feat_caps |= (1 << VDEV_LATENCY_CONFIG);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989}
4990
4991/**
4992 * wma_update_target_ht_cap() - update ht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304993 * @tgt_hdl: pointer to structure target_psoc_info
4994 * @cfg: ht capability
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004995 *
4996 * Return: none
4997 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304998static inline void
4999wma_update_target_ht_cap(struct target_psoc_info *tgt_hdl,
5000 struct wma_tgt_ht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305002 int ht_cap_info;
5003
5004 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005 /* RX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305006 cfg->ht_rx_stbc = !!(ht_cap_info & WMI_HT_CAP_RX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007
5008 /* TX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305009 cfg->ht_tx_stbc = !!(ht_cap_info & WMI_HT_CAP_TX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010
5011 /* MPDU density */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305012 cfg->mpdu_density = ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013
5014 /* HT RX LDPC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305015 cfg->ht_rx_ldpc = !!(ht_cap_info & WMI_HT_CAP_LDPC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005016
5017 /* HT SGI */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305018 cfg->ht_sgi_20 = !!(ht_cap_info & WMI_HT_CAP_HT20_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305020 cfg->ht_sgi_40 = !!(ht_cap_info & WMI_HT_CAP_HT40_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005021
5022 /* RF chains */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305023 cfg->num_rf_chains = target_if_get_num_rf_chains(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005024
Jeff Johnson3fd21822016-11-08 11:30:37 -08005025 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n"
5026 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305027 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
5028 ht_cap_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005029 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
5030 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
5031 cfg->num_rf_chains);
5032
5033}
5034
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035/**
5036 * wma_update_target_vht_cap() - update vht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305037 * @tgt_hdl: pointer to structure target_psoc_info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 * @cfg: vht capabality
5039 *
5040 * Return: none
5041 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305042static inline void
5043wma_update_target_vht_cap(struct target_psoc_info *tgt_hdl,
5044 struct wma_tgt_vht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005045{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305046 int vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005047
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305048 if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005049 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305050 else if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005051 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5052 else
5053 cfg->vht_max_mpdu = 0;
5054
5055
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305056 if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005057 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
5058 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305059 } else if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305061 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005062 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305063 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005064
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305065 cfg->vht_rx_ldpc = vht_cap_info & WMI_VHT_CAP_RX_LDPC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005066
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305067 cfg->vht_short_gi_80 = vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
5068 cfg->vht_short_gi_160 = vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305070 cfg->vht_tx_stbc = vht_cap_info & WMI_VHT_CAP_TX_STBC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005071
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305072 cfg->vht_rx_stbc =
5073 (vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
5074 (vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
5075 (vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305077 cfg->vht_max_ampdu_len_exp = (vht_cap_info &
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
5079 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
5080
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305081 cfg->vht_su_bformer = vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305083 cfg->vht_su_bformee = vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305085 cfg->vht_mu_bformer = vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305087 cfg->vht_mu_bformee = vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005088
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305089 cfg->vht_txop_ps = vht_cap_info & WMI_VHT_CAP_TXOP_PS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090
Jeff Johnson3fd21822016-11-08 11:30:37 -08005091 WMA_LOGD("%s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
5092 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
5093 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
5095 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
5096 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
5097 cfg->vht_max_ampdu_len_exp);
5098}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099
5100/**
Krunal Sonica50b452017-08-04 22:24:59 -07005101 * wma_update_supported_bands() - update supported bands from service ready ext
Krunal Sonica50b452017-08-04 22:24:59 -07005102 * @supported_bands: Supported band given by FW through service ready ext params
5103 * @new_supported_bands: New supported band which needs to be updated by
5104 * this API which WMA layer understands
5105 *
5106 * This API will convert FW given supported band to enum which WMA layer
5107 * understands
5108 *
5109 * Return: QDF_STATUS
5110 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305111static QDF_STATUS wma_update_supported_bands(
Krunal Sonica50b452017-08-04 22:24:59 -07005112 WLAN_BAND_CAPABILITY supported_bands,
5113 WMI_PHY_CAPABILITY *new_supported_bands)
5114{
5115 QDF_STATUS status = QDF_STATUS_SUCCESS;
5116
Krunal Sonica50b452017-08-04 22:24:59 -07005117 if (!new_supported_bands) {
5118 WMA_LOGE("%s: NULL new supported band variable", __func__);
5119 return QDF_STATUS_E_FAILURE;
5120 }
5121 switch (supported_bands) {
5122 case WLAN_2G_CAPABILITY:
5123 *new_supported_bands |= WMI_11G_CAPABILITY;
5124 break;
5125 case WLAN_5G_CAPABILITY:
5126 *new_supported_bands |= WMI_11A_CAPABILITY;
5127 break;
5128 default:
5129 WMA_LOGE("%s: wrong supported band", __func__);
5130 status = QDF_STATUS_E_FAILURE;
5131 break;
5132 }
5133 return status;
5134}
5135
5136/**
Krunal Soniaa664da2016-06-15 23:46:40 -07005137 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005138 * @ht_cap: given pointer to HT caps which needs to be updated
5139 * @tx_chain: given tx chainmask value
5140 * @rx_chain: given rx chainmask value
5141 * @value: new HT cap info provided in form of bitmask
5142 *
5143 * This function takes the value provided in form of bitmask and decodes
5144 * it. After decoding, what ever value it gets, it takes the union(max) or
5145 * intersection(min) with previously derived values.
5146 *
5147 * Return: none
5148 *
5149 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305150static void wma_derive_ext_ht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005151 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
5152 uint32_t tx_chain, uint32_t rx_chain)
5153{
5154 struct wma_tgt_ht_cap tmp = {0};
5155
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305156 if (ht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005157 return;
5158
Ankit Guptaa5076012016-09-14 11:32:19 -07005159 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07005160 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
5161 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
5162 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
5163 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
5164 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
5165 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
5166 ht_cap->num_rf_chains =
5167 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
5168 wma_get_num_of_setbits_from_bitmask(rx_chain));
5169 } else {
5170 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
5171 (!!(value & WMI_HT_CAP_RX_STBC)));
5172 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
5173 (!!(value & WMI_HT_CAP_TX_STBC)));
5174 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
5175 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
5176 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
5177 (!!(value & WMI_HT_CAP_RX_LDPC)));
5178 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
5179 (!!(value & WMI_HT_CAP_HT20_SGI)));
5180 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
5181 (!!(value & WMI_HT_CAP_HT40_SGI)));
5182 ht_cap->num_rf_chains =
5183 QDF_MAX(ht_cap->num_rf_chains,
5184 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
5185 tx_chain),
5186 wma_get_num_of_setbits_from_bitmask(
5187 rx_chain)));
5188 }
5189}
5190
5191/**
5192 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305193 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005194 * @ht_cap: HT cap structure to be filled
5195 *
5196 * This function loop through each hardware mode and for each hardware mode
5197 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5198 * HT caps and derives the final cap.
5199 *
5200 * Return: none
5201 *
5202 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305203static void wma_update_target_ext_ht_cap(struct target_psoc_info *tgt_hdl,
5204 struct wma_tgt_ht_cap *ht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005205{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005206 int i, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005207 uint32_t ht_2g, ht_5g;
5208 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305209 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5210 int num_hw_modes;
Krunal Soniaa664da2016-06-15 23:46:40 -07005211
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005212 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305213 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5214 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005215 /*
5216 * for legacy device extended cap might not even come, so in that case
5217 * don't overwrite legacy values
5218 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305219 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005220 WMA_LOGD("%s: No extended HT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005221 return;
5222 }
5223
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005224 for (i = 0; i < total_mac_phy_cnt; i++) {
5225 ht_2g = mac_phy_cap[i].ht_cap_info_2G;
5226 ht_5g = mac_phy_cap[i].ht_cap_info_5G;
5227 if (ht_2g)
5228 wma_derive_ext_ht_cap(&tmp_ht_cap,
5229 ht_2g,
5230 mac_phy_cap[i].tx_chain_mask_2G,
5231 mac_phy_cap[i].rx_chain_mask_2G);
5232 if (ht_5g)
5233 wma_derive_ext_ht_cap(&tmp_ht_cap,
5234 ht_5g,
5235 mac_phy_cap[i].tx_chain_mask_5G,
5236 mac_phy_cap[i].rx_chain_mask_5G);
Krunal Soniaa664da2016-06-15 23:46:40 -07005237 }
5238
Ankit Guptaa5076012016-09-14 11:32:19 -07005239 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005240 sizeof(struct wma_tgt_ht_cap))) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005241 qdf_mem_copy(ht_cap, &tmp_ht_cap,
5242 sizeof(struct wma_tgt_ht_cap));
Krunal Soniaa664da2016-06-15 23:46:40 -07005243 }
5244
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005245 WMA_LOGD("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005246 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
5247 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005248 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
5249 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
5250 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
5251 ht_cap->num_rf_chains);
5252}
5253
5254/**
5255 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005256 * @vht_cap: pointer to given VHT caps to be filled
5257 * @value: new VHT cap info provided in form of bitmask
5258 *
5259 * This function takes the value provided in form of bitmask and decodes
5260 * it. After decoding, what ever value it gets, it takes the union(max) or
5261 * intersection(min) with previously derived values.
5262 *
5263 * Return: none
5264 *
5265 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305266static void wma_derive_ext_vht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005267 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
5268{
5269 struct wma_tgt_vht_cap tmp_cap = {0};
5270 uint32_t tmp = 0;
5271
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305272 if (vht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005273 return;
5274
Ankit Guptaa5076012016-09-14 11:32:19 -07005275 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005276 sizeof(struct wma_tgt_vht_cap))) {
5277 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5278 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5279 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5280 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5281 else
5282 vht_cap->vht_max_mpdu = 0;
5283
5284 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
5285 vht_cap->supp_chan_width =
5286 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
5287 vht_cap->supp_chan_width |=
5288 1 << eHT_CHANNEL_WIDTH_160MHZ;
5289 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5290 vht_cap->supp_chan_width =
5291 1 << eHT_CHANNEL_WIDTH_160MHZ;
5292 } else {
5293 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5294 }
5295 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
5296 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
5297 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
5298 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
5299 vht_cap->vht_rx_stbc =
5300 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5301 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5302 (value & WMI_VHT_CAP_RX_STBC_3SS);
5303 vht_cap->vht_max_ampdu_len_exp =
5304 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5305 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
5306 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
5307 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
5308 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
5309 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
5310 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
5311 } else {
5312 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5313 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5314 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5315 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5316 else
5317 tmp = 0;
5318 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
5319
5320 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
5321 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
5322 (1 << eHT_CHANNEL_WIDTH_160MHZ);
5323 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5324 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
5325 } else {
5326 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5327 }
5328 vht_cap->supp_chan_width =
5329 QDF_MAX(vht_cap->supp_chan_width, tmp);
5330 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
5331 value & WMI_VHT_CAP_RX_LDPC);
5332 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
5333 value & WMI_VHT_CAP_SGI_80MHZ);
5334 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
5335 value & WMI_VHT_CAP_SGI_160MHZ);
5336 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
5337 value & WMI_VHT_CAP_TX_STBC);
5338 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
5339 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5340 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5341 (value & WMI_VHT_CAP_RX_STBC_3SS));
5342 vht_cap->vht_max_ampdu_len_exp =
5343 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
5344 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5345 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
5346 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
5347 value & WMI_VHT_CAP_SU_BFORMER);
5348 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
5349 value & WMI_VHT_CAP_SU_BFORMEE);
5350 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
5351 value & WMI_VHT_CAP_MU_BFORMER);
5352 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
5353 value & WMI_VHT_CAP_MU_BFORMEE);
5354 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
5355 value & WMI_VHT_CAP_TXOP_PS);
5356 }
5357}
5358
5359/**
5360 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305361 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005362 * @vht_cap: VHT cap structure to be filled
5363 *
5364 * This function loop through each hardware mode and for each hardware mode
5365 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5366 * VHT caps and derives the final cap.
5367 *
5368 * Return: none
5369 *
5370 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305371static void wma_update_target_ext_vht_cap(struct target_psoc_info *tgt_hdl,
5372 struct wma_tgt_vht_cap *vht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005373{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005374 int i, num_hw_modes, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005375 uint32_t vht_cap_info_2g, vht_cap_info_5g;
5376 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305377 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5378
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005379 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305380 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5381 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005382
5383 /*
5384 * for legacy device extended cap might not even come, so in that case
5385 * don't overwrite legacy values
5386 */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005387 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005388 WMA_LOGD("%s: No extended VHT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005389 return;
5390 }
5391
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005392 for (i = 0; i < total_mac_phy_cnt; i++) {
5393 vht_cap_info_2g = mac_phy_cap[i].vht_cap_info_2G;
5394 vht_cap_info_5g = mac_phy_cap[i].vht_cap_info_5G;
5395 if (vht_cap_info_2g)
5396 wma_derive_ext_vht_cap(&tmp_vht_cap,
5397 vht_cap_info_2g);
5398 if (vht_cap_info_5g)
5399 wma_derive_ext_vht_cap(&tmp_vht_cap,
5400 vht_cap_info_5g);
Krunal Soniaa664da2016-06-15 23:46:40 -07005401 }
5402
Ankit Guptaa5076012016-09-14 11:32:19 -07005403 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005404 sizeof(struct wma_tgt_vht_cap))) {
5405 qdf_mem_copy(vht_cap, &tmp_vht_cap,
5406 sizeof(struct wma_tgt_vht_cap));
5407 }
5408
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005409 WMA_LOGD("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005410 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
5411 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005412 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
5413 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
5414 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
5415 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
5416 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
5417}
5418
5419/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305420 * wma_update_ra_rate_limit() - update wma config
5421 * @wma_handle: wma handle
5422 * @cfg: target config
5423 *
5424 * Return: none
5425 */
5426#ifdef FEATURE_WLAN_RA_FILTERING
5427static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5428 struct wma_tgt_cfg *cfg)
5429{
5430 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
5431}
5432#else
5433static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5434 struct wma_tgt_cfg *cfg)
5435{
5436}
5437#endif
5438
Jeff Johnson0918f242018-07-17 18:52:17 -07005439static void
5440wma_update_sar_version(struct wlan_psoc_host_service_ext_param *param,
5441 struct wma_tgt_cfg *cfg)
5442{
5443 cfg->sar_version = param ? param->sar_version : SAR_VERSION_1;
5444}
5445
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305446/**
Krunal Sonica50b452017-08-04 22:24:59 -07005447 * wma_update_hdd_band_cap() - update band cap which hdd understands
5448 * @supported_band: supported band which has been given by FW
5449 * @tgt_cfg: target configuration to be updated
5450 *
5451 * Convert WMA given supported band to enum which HDD understands
5452 *
5453 * Return: None
5454 */
5455static void wma_update_hdd_band_cap(WMI_PHY_CAPABILITY supported_band,
5456 struct wma_tgt_cfg *tgt_cfg)
5457{
5458 switch (supported_band) {
5459 case WMI_11G_CAPABILITY:
5460 case WMI_11NG_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005461 tgt_cfg->band_cap = BAND_2G;
Krunal Sonica50b452017-08-04 22:24:59 -07005462 break;
5463 case WMI_11A_CAPABILITY:
5464 case WMI_11NA_CAPABILITY:
5465 case WMI_11AC_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005466 tgt_cfg->band_cap = BAND_5G;
Krunal Sonica50b452017-08-04 22:24:59 -07005467 break;
5468 case WMI_11AG_CAPABILITY:
5469 case WMI_11NAG_CAPABILITY:
5470 default:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005471 tgt_cfg->band_cap = BAND_ALL;
Krunal Sonica50b452017-08-04 22:24:59 -07005472 }
5473}
5474
5475/**
Arif Hussainee10f902017-12-27 16:30:17 -08005476 * wma_update_obss_detection_support() - update obss detection offload support
5477 * @wh: wma handle
5478 * @tgt_cfg: target configuration to be updated
5479 *
5480 * Update obss detection offload support based on service bit.
5481 *
5482 * Return: None
5483 */
5484static void wma_update_obss_detection_support(tp_wma_handle wh,
5485 struct wma_tgt_cfg *tgt_cfg)
5486{
Arif Hussain05fb4872018-01-03 16:02:55 -08005487 if (wmi_service_enabled(wh->wmi_handle,
5488 wmi_service_ap_obss_detection_offload))
Arif Hussainee10f902017-12-27 16:30:17 -08005489 tgt_cfg->obss_detection_offloaded = true;
5490 else
5491 tgt_cfg->obss_detection_offloaded = false;
5492}
5493
5494/**
Arif Hussain05fb4872018-01-03 16:02:55 -08005495 * wma_update_obss_color_collision_support() - update obss color collision
5496 * offload support
5497 * @wh: wma handle
5498 * @tgt_cfg: target configuration to be updated
5499 *
5500 * Update obss color collision offload support based on service bit.
5501 *
5502 * Return: None
5503 */
5504static void wma_update_obss_color_collision_support(tp_wma_handle wh,
5505 struct wma_tgt_cfg *tgt_cfg)
5506{
5507 if (wmi_service_enabled(wh->wmi_handle, wmi_service_bss_color_offload))
5508 tgt_cfg->obss_color_collision_offloaded = true;
5509 else
5510 tgt_cfg->obss_color_collision_offloaded = false;
5511}
5512
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005513#ifdef WLAN_SUPPORT_GREEN_AP
5514static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5515{
5516 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5517 WMI_SERVICE_EGAP))
5518 target_if_green_ap_register_egap_event_handler(
5519 wma_handle->pdev);
5520
5521}
5522#else
5523static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5524{
5525}
5526#endif
5527
Nachiket Kukade85aa3782018-11-02 20:12:34 +05305528#ifdef WLAN_FEATURE_NAN
5529static void wma_update_nan_target_caps(tp_wma_handle wma_handle,
5530 struct wma_tgt_cfg *tgt_cfg)
5531{
5532 if (wmi_service_enabled(wma_handle->wmi_handle,
5533 wmi_service_nan_disable_support))
5534 tgt_cfg->nan_caps.nan_disable_supported = 1;
5535
5536 if (wmi_service_enabled(wma_handle->wmi_handle,
5537 wmi_service_nan_dbs_support))
5538 tgt_cfg->nan_caps.nan_dbs_supported = 1;
5539
5540 if (wmi_service_enabled(wma_handle->wmi_handle,
5541 wmi_service_ndi_dbs_support))
5542 tgt_cfg->nan_caps.ndi_dbs_supported = 1;
5543
5544 if (wmi_service_enabled(wma_handle->wmi_handle,
5545 wmi_service_nan_sap_support))
5546 tgt_cfg->nan_caps.nan_sap_supported = 1;
5547
5548 if (wmi_service_enabled(wma_handle->wmi_handle,
5549 wmi_service_ndi_sap_support))
5550 tgt_cfg->nan_caps.ndi_sap_supported = 1;
5551}
5552#else
5553static void wma_update_nan_target_caps(tp_wma_handle wma_handle,
5554 struct wma_tgt_cfg *tgt_cfg)
5555{
5556}
5557#endif
5558
Arif Hussain05fb4872018-01-03 16:02:55 -08005559/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560 * wma_update_hdd_cfg() - update HDD config
5561 * @wma_handle: wma handle
5562 *
5563 * Return: none
5564 */
5565static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
5566{
5567 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05305568 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305569 target_resource_config *wlan_res_cfg;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305570 struct wlan_psoc_host_service_ext_param *service_ext_param;
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305571 struct target_psoc_info *tgt_hdl;
5572 struct wmi_unified *wmi_handle;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305573
5574 WMA_LOGD("%s: Enter", __func__);
5575
5576 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5577 if (!tgt_hdl) {
5578 WMA_LOGE("%s: target psoc info is NULL", __func__);
5579 return;
5580 }
5581
5582 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
Arif Hussaind15902c2018-03-02 00:08:29 -08005583 if (!wlan_res_cfg) {
5584 WMA_LOGE("%s: wlan_res_cfg is null", __func__);
5585 return;
5586 }
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305587 service_ext_param =
5588 target_psoc_get_service_ext_param(tgt_hdl);
Sourav Mohapatracf632572018-04-02 11:01:35 +05305589 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305590 if (!wmi_handle) {
5591 WMA_LOGE("%s: wmi handle is NULL", __func__);
5592 return;
5593 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305595 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07005596
5597 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005598 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
5599 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
5600
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305601 tgt_cfg.max_intf_count = wlan_res_cfg->num_vdevs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305603 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604 ATH_MAC_LEN);
5605
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305606 wma_update_target_services(wmi_handle, &tgt_cfg.services);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305607 wma_update_target_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5608 wma_update_target_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07005609 /*
5610 * This will overwrite the structure filled by wma_update_target_ht_cap
5611 * and wma_update_target_vht_cap APIs.
5612 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305613 wma_update_target_ext_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5614 wma_update_target_ext_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305616 wma_update_target_ext_he_cap(tgt_hdl, &tgt_cfg);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005617
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305618 tgt_cfg.target_fw_version = target_if_get_fw_version(tgt_hdl);
5619 if (service_ext_param)
5620 tgt_cfg.target_fw_vers_ext =
5621 service_ext_param->fw_build_vers_ext;
5622
Ryan Hsuc6918552018-05-16 13:29:59 -07005623 tgt_cfg.hw_bd_id = wma_handle->hw_bd_id;
5624 tgt_cfg.hw_bd_info.bdf_version = wma_handle->hw_bd_info[BDF_VERSION];
5625 tgt_cfg.hw_bd_info.ref_design_id =
5626 wma_handle->hw_bd_info[REF_DESIGN_ID];
5627 tgt_cfg.hw_bd_info.customer_id = wma_handle->hw_bd_info[CUSTOMER_ID];
5628 tgt_cfg.hw_bd_info.project_id = wma_handle->hw_bd_info[PROJECT_ID];
5629 tgt_cfg.hw_bd_info.board_data_rev =
5630 wma_handle->hw_bd_info[BOARD_DATA_REV];
5631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632#ifdef WLAN_FEATURE_LPSS
5633 tgt_cfg.lpss_support = wma_handle->lpss_support;
5634#endif /* WLAN_FEATURE_LPSS */
5635 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Arif Hussaind54b62c2018-03-01 13:31:37 -08005636 tgt_cfg.dfs_cac_offload = wma_handle->is_dfs_offloaded;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305637 tgt_cfg.rcpi_enabled = wma_handle->rcpi_enabled;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305638 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05305639 wma_update_hdd_band_cap(target_if_get_phy_capability(tgt_hdl),
5640 &tgt_cfg);
Jeff Johnson0918f242018-07-17 18:52:17 -07005641 wma_update_sar_version(service_ext_param, &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08005642 tgt_cfg.fine_time_measurement_cap =
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305643 target_if_get_wmi_fw_sub_feat_caps(tgt_hdl);
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05305644 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
5645 - WMI_TLV_HEADROOM;
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05305646 tgt_cfg.tx_bfee_8ss_enabled = wma_handle->tx_bfee_8ss_enabled;
gaurank kathpalia5fcefa92018-10-24 15:03:15 +05305647 tgt_cfg.dynamic_nss_chains_support =
5648 wma_handle->dynamic_nss_chains_support;
Arif Hussainee10f902017-12-27 16:30:17 -08005649 wma_update_obss_detection_support(wma_handle, &tgt_cfg);
Arif Hussain05fb4872018-01-03 16:02:55 -08005650 wma_update_obss_color_collision_support(wma_handle, &tgt_cfg);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07005651 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Nachiket Kukade85aa3782018-11-02 20:12:34 +05305652 wma_update_nan_target_caps(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07005653 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Himanshu Agarwal2228e072018-01-24 17:42:17 +05305654 target_if_store_pdev_target_if_ctx(wma_get_pdev_from_scn_handle);
Nachiket Kukade7dda8c22018-03-12 19:59:43 +05305655 target_pdev_set_wmi_handle(wma_handle->pdev->tgt_if_handle,
5656 wma_handle->wmi_handle);
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005657 wma_green_ap_register_handlers(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658}
5659
5660/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
5662 * @wma_handle: WMA handle
5663 *
5664 * Prints the DBS HW modes sent by the FW as part
5665 * of WMI ready event
5666 *
5667 * Return: None
5668 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005669static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670{
5671 uint32_t i, param;
5672
5673 if (!wma_handle) {
5674 WMA_LOGE("%s: Invalid WMA handle", __func__);
5675 return;
5676 }
5677
5678 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5679 param = wma_handle->hw_mode.hw_mode_list[i];
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005680 WMA_LOGD("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305682 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
5683 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
5684 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005685 WMA_LOGD("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005686 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305687 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
5688 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
5689 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005690 WMA_LOGD("%s:[%d] DBS:%d SBS:%d", __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305691 WMA_HW_MODE_DBS_MODE_GET(param),
5692 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005694 policy_mgr_dump_dbs_hw_mode(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005695}
5696
5697/**
5698 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305699 * @psoc: Object manager psoc
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305700 * @scan_config: Scam mode configuration
5701 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 *
5703 * Enables all the valid bits of concurrent_scan_config_bits and
5704 * fw_mode_config_bits.
5705 *
5706 * Return: None
5707 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305708static void wma_init_scan_fw_mode_config(struct wlan_objmgr_psoc *psoc,
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005709 uint32_t scan_config,
5710 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005712 WMA_LOGD("%s: Enter", __func__);
5713
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305714 if (!psoc) {
5715 WMA_LOGE("%s: obj psoc is NULL", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 return;
5717 }
5718
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305719 policy_mgr_init_dbs_config(psoc, scan_config, fw_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720}
5721
5722/**
Nachiket Kukadee547a482018-05-22 16:43:30 +05305723 * wma_update_ra_limit() - update ra limit based on apf filter
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305724 * enabled or not
5725 * @handle: wma handle
5726 *
5727 * Return: none
5728 */
5729#ifdef FEATURE_WLAN_RA_FILTERING
5730static void wma_update_ra_limit(tp_wma_handle wma_handle)
5731{
Wu Gao66454f12018-09-26 19:55:41 +08005732 if (ucfg_pmo_is_apf_enabled(wma_handle->psoc))
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305733 wma_handle->IsRArateLimitEnabled = false;
5734}
5735#else
Wu Gao66454f12018-09-26 19:55:41 +08005736static void wma_update_ra_limit(tp_wma_handle handle)
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305737{
5738}
5739#endif
5740
Dustin Brown06259e52018-02-28 16:00:02 -08005741static void wma_set_pmo_caps(struct wlan_objmgr_psoc *psoc)
5742{
5743 QDF_STATUS status;
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305744 tp_wma_handle wma;
Dustin Brown06259e52018-02-28 16:00:02 -08005745 struct pmo_device_caps caps;
5746
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305747 wma = cds_get_context(QDF_MODULE_ID_WMA);
Arif Hussaineec28b52018-08-21 17:21:28 -07005748 if (!wma) {
5749 WMA_LOGE("%s: wma handler is null", __func__);
5750 return;
5751 }
5752
Dustin Brown06259e52018-02-28 16:00:02 -08005753 caps.arp_ns_offload =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305754 wmi_service_enabled(wma->wmi_handle, wmi_service_arpns_offload);
Dustin Brown06259e52018-02-28 16:00:02 -08005755 caps.apf =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305756 wmi_service_enabled(wma->wmi_handle, wmi_service_apf_offload);
Dustin Brown06259e52018-02-28 16:00:02 -08005757 caps.packet_filter =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305758 wmi_service_enabled(wma->wmi_handle,
5759 wmi_service_packet_filter_offload);
Dustin Brown06259e52018-02-28 16:00:02 -08005760 caps.unified_wow =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305761 wmi_service_enabled(wma->wmi_handle,
5762 wmi_service_unified_wow_capability);
Nachiket Kukade4b7c8e02018-06-01 22:53:06 +05305763 caps.li_offload =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305764 wmi_service_enabled(wma->wmi_handle,
5765 wmi_service_listen_interval_offload_support
5766 );
Dustin Brown06259e52018-02-28 16:00:02 -08005767
5768 status = ucfg_pmo_psoc_set_caps(psoc, &caps);
5769 if (QDF_IS_STATUS_ERROR(status))
5770 WMA_LOGE("Failed to set PMO capabilities; status:%d", status);
5771}
5772
5773static void wma_set_component_caps(struct wlan_objmgr_psoc *psoc)
5774{
5775 wma_set_pmo_caps(psoc);
5776}
5777
Mukul Sharma44746042018-05-24 17:30:52 +05305778#if defined(WLAN_FEATURE_GTK_OFFLOAD) && defined(WLAN_POWER_MANAGEMENT_OFFLOAD)
5779static QDF_STATUS wma_register_gtk_offload_event(tp_wma_handle wma_handle)
5780{
5781 QDF_STATUS status = QDF_STATUS_E_FAILURE;
5782
5783 if (!wma_handle) {
5784 WMA_LOGE("%s: wma_handle passed is NULL", __func__);
5785 return QDF_STATUS_E_FAILURE;
5786 }
5787
5788 if (wmi_service_enabled(wma_handle->wmi_handle,
5789 wmi_service_gtk_offload)) {
5790 status = wmi_unified_register_event_handler(
5791 wma_handle->wmi_handle,
5792 wmi_gtk_offload_status_event_id,
5793 target_if_pmo_gtk_offload_status_event,
5794 WMA_RX_WORK_CTX);
5795 }
5796 return status;
5797}
5798#else
5799static QDF_STATUS wma_register_gtk_offload_event(tp_wma_handle wma_handle)
5800{
5801 return QDF_STATUS_SUCCESS;
5802}
5803#endif /* WLAN_FEATURE_GTK_OFFLOAD && WLAN_POWER_MANAGEMENT_OFFLOAD */
5804
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305805/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806 * wma_rx_service_ready_event() - event handler to process
5807 * wmi rx sevice ready event.
5808 * @handle: wma handle
5809 * @cmd_param_info: command params info
5810 *
5811 * Return: none
5812 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305813int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005814 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005815{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005816 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005817 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
5818 wmi_service_ready_event_fixed_param *ev;
Dustin Brown7678b6c2018-03-07 13:00:52 -08005819 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 uint32_t *ev_wlan_dbs_hw_mode_list;
Leo Chang96464902016-10-28 11:10:54 -07005821 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305822 struct target_psoc_info *tgt_hdl;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305823 struct wlan_psoc_target_capability_info *tgt_cap_info;
5824 target_resource_config *wlan_res_cfg;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305825 struct wmi_unified *wmi_handle;
5826 uint32_t *service_bitmap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827
5828 WMA_LOGD("%s: Enter", __func__);
5829
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305830 if (!handle) {
5831 WMA_LOGE("%s: wma_handle passed is NULL", __func__);
5832 return -EINVAL;
5833 }
5834
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305835 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5836 if (!tgt_hdl) {
5837 WMA_LOGE("%s: target psoc info is NULL", __func__);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305838 return -EINVAL;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305839 }
5840
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305841 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
5842 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305843 service_bitmap = target_psoc_get_service_bitmap(tgt_hdl);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305844
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305846 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005847 WMA_LOGE("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305848 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 }
5850
5851 ev = param_buf->fixed_param;
5852 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005853 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305854 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005855 }
5856
Sourav Mohapatracf632572018-04-02 11:01:35 +05305857 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305858 if (!wmi_handle) {
5859 WMA_LOGE("%s: wmi handle is NULL", __func__);
5860 return -EINVAL;
5861 }
5862
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005863 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005864
Amar Singhal7b038ca2017-10-04 13:38:39 -07005865 if (ev->num_dbs_hw_modes > param_buf->num_wlan_dbs_hw_mode_list) {
5866 WMA_LOGE("FW dbs_hw_mode entry %d more than value %d in TLV hdr",
5867 ev->num_dbs_hw_modes,
5868 param_buf->num_wlan_dbs_hw_mode_list);
5869 return -EINVAL;
5870 }
5871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005872 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
5873 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
Arif Hussain157263f2018-10-03 13:07:15 -07005874
5875 /* Continuing with the rest of the processing,
5876 * even if memory allocation fails
5877 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305879 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005880 wma_handle->num_dbs_hw_modes);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305881
5882 if (wma_handle->hw_mode.hw_mode_list)
5883 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
5884 ev_wlan_dbs_hw_mode_list,
5885 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
5886 wma_handle->num_dbs_hw_modes));
5887
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005888 policy_mgr_init_dbs_hw_mode(wma_handle->psoc,
5889 ev->num_dbs_hw_modes, ev_wlan_dbs_hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005890 wma_dump_dbs_hw_mode(wma_handle);
5891
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305892 /* Initializes the fw_mode and scan_config to zero.
5893 * If ext service ready event is present it will set
5894 * the actual values of these two params.
5895 * This is to ensure that no garbage values would be
5896 * present in the absence of ext service ready event.
5897 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305898 wma_init_scan_fw_mode_config(wma_handle->psoc, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305900 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305901 sizeof(HAL_REG_CAPABILITIES));
5902
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005904
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305905 wma_handle->new_hw_mode_index = tgt_cap_info->default_dbs_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005906 policy_mgr_update_new_hw_mode_index(wma_handle->psoc,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305907 tgt_cap_info->default_dbs_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908
5909 WMA_LOGD("%s: Firmware default hw mode index : %d",
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305910 __func__, tgt_cap_info->default_dbs_hw_mode_index);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005911 WMA_LOGI("%s: Firmware build version : %08x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005912 __func__, ev->fw_build_vers);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305913 WMA_LOGD("FW fine time meas cap: 0x%x",
5914 tgt_cap_info->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005915
Ryan Hsuc6918552018-05-16 13:29:59 -07005916 wma_handle->hw_bd_id = ev->hw_bd_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005917
Ryan Hsuc6918552018-05-16 13:29:59 -07005918 wma_handle->hw_bd_info[BDF_VERSION] =
5919 WMI_GET_BDF_VERSION(ev->hw_bd_info);
5920 wma_handle->hw_bd_info[REF_DESIGN_ID] =
5921 WMI_GET_REF_DESIGN(ev->hw_bd_info);
5922 wma_handle->hw_bd_info[CUSTOMER_ID] =
5923 WMI_GET_CUSTOMER_ID(ev->hw_bd_info);
5924 wma_handle->hw_bd_info[PROJECT_ID] =
5925 WMI_GET_PROJECT_ID(ev->hw_bd_info);
5926 wma_handle->hw_bd_info[BOARD_DATA_REV] =
5927 WMI_GET_BOARD_DATA_REV(ev->hw_bd_info);
5928
5929 WMA_LOGI("%s: Board id: %x, Board version: %x %x %x %x %x",
5930 __func__, wma_handle->hw_bd_id,
5931 wma_handle->hw_bd_info[BDF_VERSION],
5932 wma_handle->hw_bd_info[REF_DESIGN_ID],
5933 wma_handle->hw_bd_info[CUSTOMER_ID],
5934 wma_handle->hw_bd_info[PROJECT_ID],
5935 wma_handle->hw_bd_info[BOARD_DATA_REV]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005937 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305938 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305939 service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005940 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05305941
Leo Chang96464902016-10-28 11:10:54 -07005942 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(soc,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005943 wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi));
Leo Chang96464902016-10-28 11:10:54 -07005944 cdp_set_desc_global_pool_size(soc, ev->num_msdu_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945 /* SWBA event handler for beacon transmission */
Harprit Chhabada98225f62018-12-11 15:29:55 -08005946 status = wma_register_swba_events(wma_handle->wmi_handle);
5947
Dustin Brown7678b6c2018-03-07 13:00:52 -08005948 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949 WMA_LOGE("Failed to register swba beacon event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305950 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 }
5952#ifdef WLAN_FEATURE_LPSS
5953 wma_handle->lpss_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005954 wmi_service_enabled(wmi_handle, wmi_service_lpass);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005955#endif /* WLAN_FEATURE_LPSS */
5956
5957 /*
5958 * This Service bit is added to check for ARP/NS Offload
5959 * support for LL/HL targets
5960 */
5961 wma_handle->ap_arpns_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005962 wmi_service_enabled(wmi_handle, wmi_service_ap_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005963
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305964 wma_update_ra_limit(wma_handle);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005965
5966 if (wmi_service_enabled(wmi_handle, wmi_service_csa_offload)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967 WMA_LOGD("%s: FW support CSA offload capability", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005968 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305969 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305970 wmi_csa_handling_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305971 wma_csa_offload_handler,
5972 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005973 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005974 WMA_LOGE("Failed to register CSA offload event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305975 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005976 }
5977 }
5978
Dustin Brown7678b6c2018-03-07 13:00:52 -08005979 if (wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005980 WMA_LOGD("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005981 /*
5982 * Register Tx completion event handler for MGMT Tx over WMI
5983 * case
5984 */
5985 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305986 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305987 wmi_mgmt_tx_completion_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305988 wma_mgmt_tx_completion_handler,
5989 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005990 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305992 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005993 }
5994
Nirav Shah20489972016-06-16 19:20:28 +05305995 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305996 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305997 wmi_mgmt_tx_bundle_completion_event_id,
Nirav Shah20489972016-06-16 19:20:28 +05305998 wma_mgmt_tx_bundle_completion_handler,
5999 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08006000 if (QDF_IS_STATUS_ERROR(status)) {
Nirav Shah20489972016-06-16 19:20:28 +05306001 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306002 goto free_hw_mode_list;
Nirav Shah20489972016-06-16 19:20:28 +05306003 }
6004
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005 } else {
6006 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
6007 }
Dustin Brown7678b6c2018-03-07 13:00:52 -08006008
Mukul Sharma44746042018-05-24 17:30:52 +05306009 status = wma_register_gtk_offload_event(wma_handle);
6010 if (QDF_IS_STATUS_ERROR(status)) {
6011 WMA_LOGE("Failed to register GTK offload event cb");
6012 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006014
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306015 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05306016 wmi_tbttoffset_update_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05306017 wma_tbttoffset_update_event_handler,
6018 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08006019 if (QDF_IS_STATUS_ERROR(status)) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006020 WMA_LOGE("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306021 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022 }
6023
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306024 if (wmi_service_enabled(wma_handle->wmi_handle,
6025 wmi_service_rcpi_support)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05306026 /* register for rcpi response event */
6027 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306028 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05306029 wmi_update_rcpi_event_id,
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05306030 wma_rcpi_event_handler,
6031 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08006032 if (QDF_IS_STATUS_ERROR(status)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05306033 WMA_LOGE("Failed to register RCPI event handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306034 goto free_hw_mode_list;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05306035 }
6036 wma_handle->rcpi_enabled = true;
6037 }
6038
Govind Singhefc5ccd2016-04-25 11:11:55 +05306039 /* mac_id is replaced with pdev_id in converged firmware to have
6040 * multi-radio support. In order to maintain backward compatibility
6041 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
6042 * in service bitmap from FW and host needs to set use_pdev_id in
6043 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
6044 * service is not set, then host shall not expect MAC ID from FW in
6045 * VDEV START RESPONSE event and host shall use PDEV ID.
6046 */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306047 if (wmi_service_enabled(wmi_handle, wmi_service_deprecated_replace))
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306048 wlan_res_cfg->use_pdev_id = true;
Govind Singhefc5ccd2016-04-25 11:11:55 +05306049 else
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306050 wlan_res_cfg->use_pdev_id = false;
Govind Singhefc5ccd2016-04-25 11:11:55 +05306051
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306052 wlan_res_cfg->max_num_dbs_scan_duty_cycle = CDS_DBS_SCAN_CLIENTS_MAX;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05306053
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006054 /* Initialize the log supported event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306055 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05306056 wmi_diag_event_id_log_supported_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05306057 wma_log_supported_evt_handler,
6058 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08006059 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 WMA_LOGE("Failed to register log supported event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306061 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062 }
6063
Leo Chang96464902016-10-28 11:10:54 -07006064 cdp_mark_first_wakeup_packet(soc,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306065 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306066 wmi_service_mark_first_wakeup_packet));
Arif Hussaind54b62c2018-03-01 13:31:37 -08006067 wma_handle->is_dfs_offloaded =
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306068 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306069 wmi_service_dfs_phyerr_offload);
Arif Hussaindb6e4e92018-06-01 16:39:15 -07006070
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07006071 wma_handle->nan_datapath_enabled =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306072 wmi_service_enabled(wma_handle->wmi_handle,
6073 wmi_service_nan_data);
Dustin Brown06259e52018-02-28 16:00:02 -08006074
6075 wma_set_component_caps(wma_handle->psoc);
6076
Dustin Brownb9987af2018-03-01 17:15:11 -08006077 wma_update_fw_config(wma_handle->psoc, tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006078
Dustin Brown7678b6c2018-03-07 13:00:52 -08006079 status = wmi_unified_save_fw_version_cmd(wmi_handle, param_buf);
6080 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhf25a0f12016-03-08 16:09:48 +05306081 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306082 goto free_hw_mode_list;
Govind Singhf25a0f12016-03-08 16:09:48 +05306083 }
6084
Zhu Jianmin2d87a1c2018-05-31 11:22:23 +08006085 if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) {
6086 status = qdf_mc_timer_start(
6087 &wma_handle->service_ready_ext_timer,
6088 WMA_SERVICE_READY_EXT_TIMEOUT);
6089 if (QDF_IS_STATUS_ERROR(status))
6090 WMA_LOGE("Failed to start the service ready ext timer");
6091 }
Dustin Brown7678b6c2018-03-07 13:00:52 -08006092 wma_handle->tx_bfee_8ss_enabled =
6093 wmi_service_enabled(wmi_handle, wmi_service_8ss_tx_bfee);
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05306094
gaurank kathpalia5fcefa92018-10-24 15:03:15 +05306095 wma_handle->dynamic_nss_chains_support = wmi_service_enabled(wmi_handle,
6096 wmi_service_per_vdev_chain_support);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306097 target_psoc_set_num_radios(tgt_hdl, 1);
6098
Govind Singhd76a5b02016-03-08 15:12:14 +05306099 return 0;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306100
6101free_hw_mode_list:
6102 if (wma_handle->hw_mode.hw_mode_list) {
6103 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
6104 wma_handle->hw_mode.hw_mode_list = NULL;
6105 WMA_LOGD("%s: DBS list is freed", __func__);
6106 }
6107
6108 return -EINVAL;
6109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110}
6111
6112/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07006113 * wma_get_phyid_for_given_band() - to get phyid for band
6114 *
6115 * @wma_handle: Pointer to wma handle
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306116* @tgt_hdl: target psoc information
Krunal Soni0193b6f2016-08-15 15:53:43 -07006117 * @band: enum value of for 2G or 5G band
6118 * @phyid: Pointer to phyid which needs to be filled
6119 *
6120 * This API looks in to the map to find out which particular phy supports
6121 * provided band and return the idx (also called phyid) of that phy. Caller
6122 * use this phyid to fetch various caps of that phy
6123 *
6124 * Return: QDF_STATUS
6125 */
6126static QDF_STATUS wma_get_phyid_for_given_band(
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006127 tp_wma_handle wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306128 struct target_psoc_info *tgt_hdl,
Krunal Soni0193b6f2016-08-15 15:53:43 -07006129 enum cds_band_type band, uint8_t *phyid)
6130{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306131 uint8_t idx, i, num_radios;
6132 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006133
6134 if (!wma_handle) {
6135 WMA_LOGE("Invalid wma handle");
6136 return QDF_STATUS_E_FAILURE;
6137 }
6138
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306139 idx = 0;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006140 *phyid = idx;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306141 num_radios = target_psoc_get_num_radios(tgt_hdl);
6142 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006143
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306144 for (i = 0; i < num_radios; i++) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006145 if ((band == CDS_BAND_2GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306146 (WLAN_2G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006147 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006148 WMA_LOGD("Select 2G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006149 return QDF_STATUS_SUCCESS;
6150 } else if ((band == CDS_BAND_5GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306151 (WLAN_5G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006152 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006153 WMA_LOGD("Select 5G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006154 return QDF_STATUS_SUCCESS;
6155 }
6156 }
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006157 WMA_LOGD("Using default single hw mode phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006158 return QDF_STATUS_SUCCESS;
6159}
6160
6161/**
6162 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
6163 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
6164 * @hw_mode: Provided hardware mode
6165 * @band: Provide band i.e. 2G or 5G
6166 *
6167 * This API finds cap which suitable for provided hw mode and band. If user
6168 * is provides some invalid hw mode then it will automatically falls back to
6169 * default hw mode
6170 *
6171 * Return: QDF_STATUS
6172 */
6173QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
6174 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
6175{
6176 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306177 struct target_psoc_info *tgt_hdl;
6178 int ht_cap_info, vht_cap_info;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306179 uint8_t phyid, our_hw_mode = hw_mode, num_hw_modes;
6180 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006181
6182 if (!wma_handle) {
6183 WMA_LOGE("Invalid wma handle");
6184 return QDF_STATUS_E_FAILURE;
6185 }
6186
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306187 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6188 if (!tgt_hdl) {
6189 WMA_LOGE("%s: target psoc info is NULL", __func__);
6190 return -EINVAL;
6191 }
6192
6193 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
6194 vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306195 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6196 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306197
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306198 if (!num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08006199 WMA_LOGD("Invalid number of hw modes, use legacy HT/VHT caps");
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306200 caps_per_phy->ht_2g = ht_cap_info;
6201 caps_per_phy->ht_5g = ht_cap_info;
6202 caps_per_phy->vht_2g = vht_cap_info;
6203 caps_per_phy->vht_5g = vht_cap_info;
jiad080abce2017-08-08 15:17:39 +08006204 /* legacy platform doesn't support HE IE */
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006205 caps_per_phy->he_2g[0] = 0;
6206 caps_per_phy->he_2g[1] = 0;
6207 caps_per_phy->he_5g[0] = 0;
6208 caps_per_phy->he_5g[1] = 0;
jiad080abce2017-08-08 15:17:39 +08006209
6210 return QDF_STATUS_SUCCESS;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006211 }
6212
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006213 if (!policy_mgr_is_dbs_enable(wma_handle->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006214 our_hw_mode = HW_MODE_DBS_NONE;
6215
6216 if (!caps_per_phy) {
6217 WMA_LOGE("Invalid caps pointer");
6218 return QDF_STATUS_E_FAILURE;
6219 }
6220
Krunal Soni0193b6f2016-08-15 15:53:43 -07006221 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306222 wma_get_phyid_for_given_band(wma_handle, tgt_hdl, band, &phyid)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006223 WMA_LOGE("Invalid phyid");
6224 return QDF_STATUS_E_FAILURE;
6225 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006226
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306227 caps_per_phy->ht_2g = mac_phy_cap[phyid].ht_cap_info_2G;
6228 caps_per_phy->ht_5g = mac_phy_cap[phyid].ht_cap_info_5G;
6229 caps_per_phy->vht_2g = mac_phy_cap[phyid].vht_cap_info_2G;
6230 caps_per_phy->vht_5g = mac_phy_cap[phyid].vht_cap_info_5G;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006231 qdf_mem_copy(caps_per_phy->he_2g, mac_phy_cap[phyid].he_cap_info_2G,
6232 sizeof(caps_per_phy->he_2g));
6233 qdf_mem_copy(caps_per_phy->he_5g, mac_phy_cap[phyid].he_cap_info_5G,
6234 sizeof(caps_per_phy->he_5g));
Krunal Soni0193b6f2016-08-15 15:53:43 -07006235
Naveen Rawat98322472018-03-06 10:29:42 -08006236 caps_per_phy->tx_chain_mask_2G = mac_phy_cap->tx_chain_mask_2G;
6237 caps_per_phy->rx_chain_mask_2G = mac_phy_cap->rx_chain_mask_2G;
6238 caps_per_phy->tx_chain_mask_5G = mac_phy_cap->tx_chain_mask_5G;
6239 caps_per_phy->rx_chain_mask_5G = mac_phy_cap->rx_chain_mask_5G;
6240
Krunal Soni0193b6f2016-08-15 15:53:43 -07006241 return QDF_STATUS_SUCCESS;
6242}
6243
6244/**
6245 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
6246 *
6247 * @channel: Channel number for which it needs to check if rx ldpc is enabled
6248 *
6249 * This API takes channel number as argument and takes default hw mode as DBS
6250 * to check if rx LDPC support is enabled for that channel or no
6251 */
6252bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
6253{
jiad080abce2017-08-08 15:17:39 +08006254 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306255 struct target_psoc_info *tgt_hdl;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006256 struct wma_caps_per_phy caps_per_phy = {0};
6257 enum cds_band_type band;
6258 bool status;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306259 uint8_t num_hw_modes;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006260
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006261 if (!wma_handle) {
6262 WMA_LOGE("Invalid wma handle");
6263 return false;
6264 }
6265
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306266 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6267 if (!tgt_hdl) {
6268 WMA_LOGE("Target handle is NULL");
6269 return QDF_STATUS_E_FAILURE;
6270 }
6271
6272 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6273
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006274 if (!WLAN_REG_IS_24GHZ_CH(channel))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006275 band = CDS_BAND_5GHZ;
6276 else
6277 band = CDS_BAND_2GHZ;
6278
6279 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
6280 &caps_per_phy,
6281 HW_MODE_DBS, band)) {
6282 return false;
6283 }
jiad080abce2017-08-08 15:17:39 +08006284
6285 /*
6286 * Legacy platforms like Rome set WMI_HT_CAP_LDPC to specify RX LDPC
6287 * capability. But new platforms like Helium set WMI_HT_CAP_RX_LDPC
6288 * instead.
6289 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306290 if (0 == num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08006291 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_LDPC));
6292 } else {
6293 if (WLAN_REG_IS_24GHZ_CH(channel))
6294 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
6295 else
6296 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
6297 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006298
6299 return status;
6300}
6301
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006302/**
6303 * wma_print_mac_phy_capabilities() - Prints MAC PHY capabilities
6304 * @cap: pointer to WMI_MAC_PHY_CAPABILITIES
6305 * @index: MAC_PHY index
6306 *
6307 * Return: none
6308 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306309static void wma_print_mac_phy_capabilities(struct wlan_psoc_host_mac_phy_caps
6310 *cap, int index)
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006311{
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006312 uint32_t mac_2G[PSOC_HOST_MAX_MAC_SIZE];
6313 uint32_t mac_5G[PSOC_HOST_MAX_MAC_SIZE];
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006314 uint32_t phy_2G[WMI_MAX_HECAP_PHY_SIZE];
6315 uint32_t phy_5G[WMI_MAX_HECAP_PHY_SIZE];
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306316 struct wlan_psoc_host_ppe_threshold ppet_2G, ppet_5G;
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006317
Dustin Brown576eea42018-06-21 12:38:21 -07006318 WMA_LOGD("\t: index [%d]", index);
6319 WMA_LOGD("\t: cap for hw_mode_id[%d]", cap->hw_mode_id);
6320 WMA_LOGD("\t: pdev_id[%d]", cap->pdev_id);
6321 WMA_LOGD("\t: phy_id[%d]", cap->phy_id);
6322 WMA_LOGD("\t: supports_11b[%d]", cap->supports_11b);
6323 WMA_LOGD("\t: supports_11g[%d]", cap->supports_11g);
6324 WMA_LOGD("\t: supports_11a[%d]", cap->supports_11a);
6325 WMA_LOGD("\t: supports_11n[%d]", cap->supports_11n);
6326 WMA_LOGD("\t: supports_11ac[%d]", cap->supports_11ac);
6327 WMA_LOGD("\t: supports_11ax[%d]", cap->supports_11ax);
6328 WMA_LOGD("\t: supported_bands[%d]", cap->supported_bands);
6329 WMA_LOGD("\t: ampdu_density[%d]", cap->ampdu_density);
6330 WMA_LOGD("\t: max_bw_supported_2G[%d]", cap->max_bw_supported_2G);
6331 WMA_LOGD("\t: ht_cap_info_2G[%d]", cap->ht_cap_info_2G);
6332 WMA_LOGD("\t: vht_cap_info_2G[%d]", cap->vht_cap_info_2G);
6333 WMA_LOGD("\t: vht_supp_mcs_2G[%d]", cap->vht_supp_mcs_2G);
6334 WMA_LOGD("\t: tx_chain_mask_2G[%d]", cap->tx_chain_mask_2G);
6335 WMA_LOGD("\t: rx_chain_mask_2G[%d]", cap->rx_chain_mask_2G);
6336 WMA_LOGD("\t: max_bw_supported_5G[%d]", cap->max_bw_supported_5G);
6337 WMA_LOGD("\t: ht_cap_info_5G[%d]", cap->ht_cap_info_5G);
6338 WMA_LOGD("\t: vht_cap_info_5G[%d]", cap->vht_cap_info_5G);
6339 WMA_LOGD("\t: vht_supp_mcs_5G[%d]", cap->vht_supp_mcs_5G);
6340 WMA_LOGD("\t: tx_chain_mask_5G[%d]", cap->tx_chain_mask_5G);
6341 WMA_LOGD("\t: rx_chain_mask_5G[%d]", cap->rx_chain_mask_5G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006342 WMA_LOGD("\t: he_cap_info_2G[0][%08x]", cap->he_cap_info_2G[0]);
6343 WMA_LOGD("\t: he_cap_info_2G[1][%08x]", cap->he_cap_info_2G[1]);
Dustin Brown576eea42018-06-21 12:38:21 -07006344 WMA_LOGD("\t: he_supp_mcs_2G[%08x]", cap->he_supp_mcs_2G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006345 WMA_LOGD("\t: he_cap_info_5G[0][%08x]", cap->he_cap_info_5G[0]);
6346 WMA_LOGD("\t: he_cap_info_5G[1][%08x]", cap->he_cap_info_5G[1]);
Dustin Brown576eea42018-06-21 12:38:21 -07006347 WMA_LOGD("\t: he_supp_mcs_5G[%08x]", cap->he_supp_mcs_5G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006348 qdf_mem_copy(mac_2G, cap->he_cap_info_2G, sizeof(mac_2G));
6349 qdf_mem_copy(mac_5G, cap->he_cap_info_5G, sizeof(mac_5G));
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006350 qdf_mem_copy(phy_2G, cap->he_cap_phy_info_2G,
6351 WMI_MAX_HECAP_PHY_SIZE * 4);
6352 qdf_mem_copy(phy_5G, cap->he_cap_phy_info_5G,
6353 WMI_MAX_HECAP_PHY_SIZE * 4);
6354 ppet_2G = cap->he_ppet2G;
6355 ppet_5G = cap->he_ppet5G;
6356
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006357 wma_print_he_mac_cap_w1(mac_2G[0]);
6358 wma_print_he_mac_cap_w2(mac_2G[1]);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006359 wma_print_he_phy_cap(phy_2G);
6360 wma_print_he_ppet(&ppet_2G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006361 wma_print_he_mac_cap_w1(mac_5G[0]);
6362 wma_print_he_mac_cap_w1(mac_5G[1]);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006363 wma_print_he_phy_cap(phy_5G);
6364 wma_print_he_ppet(&ppet_5G);
6365}
Krunal Soni0193b6f2016-08-15 15:53:43 -07006366
6367/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006368 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306369 * @tgt_info: target related info
Krunal Soni2e48d012016-05-02 16:55:26 -07006370 *
6371 * This function prints all the caps populater per hw mode and per PHY
6372 *
6373 * Return: none
6374 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306375static void wma_print_populate_soc_caps(struct target_psoc_info *tgt_hdl)
Krunal Soni2e48d012016-05-02 16:55:26 -07006376{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006377 int i, num_hw_modes, total_mac_phy_cnt;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306378 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap, *tmp;
6379
6380 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006381 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006382
6383 /* print number of hw modes */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306384 WMA_LOGD("%s: num of hw modes [%d]", __func__, num_hw_modes);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006385 WMA_LOGD("%s: num mac_phy_cnt [%d]", __func__, total_mac_phy_cnt);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306386 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006387 WMA_LOGD("%s: <====== HW mode cap printing starts ======>", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07006388 /* print cap of each hw mode */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006389 for (i = 0; i < total_mac_phy_cnt; i++) {
Lin Bai772fbaf2018-07-04 14:20:55 +08006390 WMA_LOGD("====>: hw mode id[%d], phy id[%d]",
6391 mac_phy_cap[i].hw_mode_id,
6392 mac_phy_cap[i].phy_id);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006393 tmp = &mac_phy_cap[i];
6394 wma_print_mac_phy_capabilities(tmp, i);
Krunal Soni2e48d012016-05-02 16:55:26 -07006395 }
Dustin Brown576eea42018-06-21 12:38:21 -07006396 WMA_LOGD("%s: <====== HW mode cap printing ends ======>\n", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07006397}
6398
6399/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306400 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
6401 * in terms of hw_mode_bandwidth
6402 * @width: bandwidth in terms of wmi_channel_width
6403 *
6404 * This function returns the bandwidth in terms of hw_mode_bandwidth.
6405 *
6406 * Return: BW in terms of hw_mode_bandwidth.
6407 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006408static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306409 wmi_channel_width width)
6410{
6411 switch (width) {
6412 case WMI_CHAN_WIDTH_20:
6413 return HW_MODE_20_MHZ;
6414 case WMI_CHAN_WIDTH_40:
6415 return HW_MODE_40_MHZ;
6416 case WMI_CHAN_WIDTH_80:
6417 return HW_MODE_80_MHZ;
6418 case WMI_CHAN_WIDTH_160:
6419 return HW_MODE_160_MHZ;
6420 case WMI_CHAN_WIDTH_80P80:
6421 return HW_MODE_80_PLUS_80_MHZ;
6422 case WMI_CHAN_WIDTH_5:
6423 return HW_MODE_5_MHZ;
6424 case WMI_CHAN_WIDTH_10:
6425 return HW_MODE_10_MHZ;
6426 default:
6427 return HW_MODE_BW_NONE;
6428 }
6429
6430 return HW_MODE_BW_NONE;
6431}
6432
6433/**
6434 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
6435 * supported from the capabilities.
6436 * @caps: PHY capability
6437 * @info: param to store TX-RX stream and BW information
6438 *
6439 * This function will calculate TX-RX stream and bandwidth supported
6440 * as per the PHY capability, and assign to mac_ss_bw_info.
6441 *
6442 * Return: none
6443 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306444static void wma_get_hw_mode_params(struct wlan_psoc_host_mac_phy_caps *caps,
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306445 struct mac_ss_bw_info *info)
6446{
6447 if (!caps) {
6448 WMA_LOGE("%s: Invalid capabilities", __func__);
6449 return;
6450 }
6451
6452 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
6453 QDF_MAX(caps->tx_chain_mask_2G,
6454 caps->tx_chain_mask_5G));
6455 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
6456 QDF_MAX(caps->rx_chain_mask_2G,
6457 caps->rx_chain_mask_5G));
6458 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
6459 QDF_MAX(caps->max_bw_supported_2G,
6460 caps->max_bw_supported_5G));
6461}
6462
6463/**
6464 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
6465 * DBS in hw_mode_list
6466 * @wma_handle: pointer to wma global structure
6467 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
6468 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
6469 * @pos: refers to hw_mode_index
6470 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306471 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306472 *
6473 * This function sets TX-RX stream, bandwidth and DBS mode in
6474 * hw_mode_list.
6475 *
6476 * Return: none
6477 */
6478static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
6479 struct mac_ss_bw_info mac0_ss_bw_info,
6480 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306481 uint32_t pos, uint32_t dbs_mode,
6482 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306483{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306484 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306485 wma_handle->hw_mode.hw_mode_list[pos],
6486 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306487 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306488 wma_handle->hw_mode.hw_mode_list[pos],
6489 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306490 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306491 wma_handle->hw_mode.hw_mode_list[pos],
6492 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306493 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306494 wma_handle->hw_mode.hw_mode_list[pos],
6495 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306496 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306497 wma_handle->hw_mode.hw_mode_list[pos],
6498 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306499 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306500 wma_handle->hw_mode.hw_mode_list[pos],
6501 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306502 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306503 wma_handle->hw_mode.hw_mode_list[pos],
6504 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306505 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306506 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306507 HW_MODE_AGILE_DFS_NONE);
6508 WMA_HW_MODE_SBS_MODE_SET(
6509 wma_handle->hw_mode.hw_mode_list[pos],
6510 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306511}
6512
6513/**
6514 * wma_update_hw_mode_list() - updates hw_mode_list
6515 * @wma_handle: pointer to wma global structure
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306516 * @tgt_hdl - target psoc information
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306517 *
6518 * This function updates hw_mode_list with tx_streams, rx_streams,
6519 * bandwidth, dbs and agile dfs for each hw_mode.
6520 *
6521 * Returns: 0 for success else failure.
6522 */
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306523static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle,
6524 struct target_psoc_info *tgt_hdl)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306525{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306526 struct wlan_psoc_host_mac_phy_caps *tmp, *mac_phy_cap;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306527 uint32_t i, hw_config_type, j = 0;
6528 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306529 struct mac_ss_bw_info mac0_ss_bw_info = {0};
6530 struct mac_ss_bw_info mac1_ss_bw_info = {0};
Krunal Sonica50b452017-08-04 22:24:59 -07006531 WMI_PHY_CAPABILITY new_supported_band = 0;
6532 bool supported_band_update_failure = false;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306533 struct wlan_psoc_target_capability_info *tgt_cap_info;
6534 int num_hw_modes;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306535
6536 if (!wma_handle) {
6537 WMA_LOGE("%s: Invalid wma handle", __func__);
6538 return QDF_STATUS_E_FAILURE;
6539 }
6540
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306541 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6542 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
6543 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306544 /*
6545 * This list was updated as part of service ready event. Re-populate
6546 * HW mode list from the device capabilities.
6547 */
6548 if (wma_handle->hw_mode.hw_mode_list) {
6549 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
6550 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006551 WMA_LOGD("%s: DBS list is freed", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306552 }
6553
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306554 wma_handle->hw_mode.hw_mode_list =
6555 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306556 num_hw_modes);
Wu Gaoe4c142d2018-11-06 11:54:32 +08006557 if (!wma_handle->hw_mode.hw_mode_list) {
6558 wma_handle->num_dbs_hw_modes = 0;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306559 return QDF_STATUS_E_FAILURE;
Wu Gaoe4c142d2018-11-06 11:54:32 +08006560 }
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306561
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08006562 WMA_LOGD("%s: Updated HW mode list: Num modes:%d",
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306563 __func__, num_hw_modes);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306564
Wu Gaoe4c142d2018-11-06 11:54:32 +08006565 wma_handle->num_dbs_hw_modes = num_hw_modes;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306566 for (i = 0; i < num_hw_modes; i++) {
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306567 /* Update for MAC0 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306568 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306569 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306570 hw_config_type = mac_phy_cap[j].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306571 dbs_mode = HW_MODE_DBS_NONE;
6572 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306573 mac1_ss_bw_info.mac_tx_stream = 0;
6574 mac1_ss_bw_info.mac_rx_stream = 0;
6575 mac1_ss_bw_info.mac_bw = 0;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306576 if (wma_update_supported_bands(tmp->supported_bands,
6577 &new_supported_band)
6578 != QDF_STATUS_SUCCESS)
Krunal Sonica50b452017-08-04 22:24:59 -07006579 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306580
6581 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
6582 if ((hw_config_type == WMI_HW_MODE_DBS) ||
6583 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6584 (hw_config_type == WMI_HW_MODE_SBS)) {
6585 /* Update for MAC1 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306586 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306587 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306588 if (hw_config_type == WMI_HW_MODE_DBS)
6589 dbs_mode = HW_MODE_DBS;
6590 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6591 (hw_config_type == WMI_HW_MODE_SBS))
6592 sbs_mode = HW_MODE_SBS;
Krunal Sonica50b452017-08-04 22:24:59 -07006593 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306594 wma_update_supported_bands(tmp->supported_bands,
Krunal Sonica50b452017-08-04 22:24:59 -07006595 &new_supported_band))
6596 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306597 }
6598
6599 /* Updating HW mode list */
6600 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306601 mac1_ss_bw_info, i, dbs_mode,
6602 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306603 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006604
Krunal Sonica50b452017-08-04 22:24:59 -07006605 /* overwrite phy_capability which we got from service ready event */
6606 if (!supported_band_update_failure) {
6607 WMA_LOGD("%s: updating supported band from old[%d] to new[%d]",
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306608 __func__, target_if_get_phy_capability(tgt_hdl),
Krunal Sonica50b452017-08-04 22:24:59 -07006609 new_supported_band);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306610 target_if_set_phy_capability(tgt_hdl, new_supported_band);
Krunal Sonica50b452017-08-04 22:24:59 -07006611 }
6612
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006613 if (QDF_STATUS_SUCCESS !=
Krunal Sonica50b452017-08-04 22:24:59 -07006614 policy_mgr_update_hw_mode_list(wma_handle->psoc,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306615 tgt_hdl))
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006616 WMA_LOGE("%s: failed to update policy manager", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306617 wma_dump_dbs_hw_mode(wma_handle);
6618 return QDF_STATUS_SUCCESS;
6619}
6620
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006621static void wma_init_wifi_pos_dma_rings(t_wma_handle *wma_handle,
6622 uint8_t num_mac, void *buf)
6623{
6624 struct hif_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006625 void *hal_soc;
6626
6627 if (!hif_ctx) {
6628 WMA_LOGE("invalid hif context");
6629 return;
6630 }
6631
6632 hal_soc = hif_get_hal_handle(hif_ctx);
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006633
6634 wifi_pos_init_cir_cfr_rings(wma_handle->psoc, hal_soc, num_mac, buf);
6635}
6636
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306637/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006638 * wma_populate_soc_caps() - populate entire SOC's capabilities
6639 * @wma_handle: pointer to wma global structure
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306640 * @tgt_hdl: target psoc information
Krunal Soni2e48d012016-05-02 16:55:26 -07006641 * @param_buf: pointer to param of service ready extension event from fw
6642 *
6643 * This API populates all capabilities of entire SOC. For example,
6644 * how many number of hw modes are supported by this SOC, what are the
6645 * capabilities of each phy per hw mode, what are HAL reg capabilities per
6646 * phy.
6647 *
6648 * Return: none
6649 */
6650static void wma_populate_soc_caps(t_wma_handle *wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306651 struct target_psoc_info *tgt_hdl,
Krunal Soni2e48d012016-05-02 16:55:26 -07006652 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
6653{
Krunal Soni2e48d012016-05-02 16:55:26 -07006654
6655 WMA_LOGD("%s: Enter", __func__);
6656
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006657 wma_init_wifi_pos_dma_rings(wma_handle,
6658 param_buf->num_oem_dma_ring_caps,
6659 param_buf->oem_dma_ring_caps);
6660
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306661 wma_print_populate_soc_caps(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006662}
6663
6664/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006665 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
6666 * @handle: wma handle
6667 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05306668 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006669 *
6670 * Return: none
6671 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306672int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
6673 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006674{
6675 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6676 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
6677 wmi_service_ready_ext_event_fixed_param *ev;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306678 QDF_STATUS ret;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306679 struct target_psoc_info *tgt_hdl;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306680 uint32_t conc_scan_config_bits, fw_config_bits;
jitiphilebf3a922018-11-05 14:25:00 +05306681 struct wmi_unified *wmi_handle;
6682 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
6683 target_resource_config *wlan_res_cfg;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006685 WMA_LOGD("%s: Enter", __func__);
6686
6687 if (!wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006688 WMA_LOGE("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306689 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006690 }
6691
jitiphilebf3a922018-11-05 14:25:00 +05306692 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
6693
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306694 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6695 if (!tgt_hdl) {
6696 WMA_LOGE("%s: target psoc info is NULL", __func__);
6697 return -EINVAL;
6698 }
6699
jitiphilebf3a922018-11-05 14:25:00 +05306700 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006701 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
6702 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006703 WMA_LOGE("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306704 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006705 }
6706
6707 ev = param_buf->fixed_param;
6708 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006709 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306710 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006711 }
6712
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006713 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006714
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306715 fw_config_bits = target_if_get_fw_config_bits(tgt_hdl);
6716 conc_scan_config_bits = target_if_get_conc_scan_config_bits(tgt_hdl);
6717
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006718 WMA_LOGD("%s: Defaults: scan config:%x FW mode config:%x",
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306719 __func__, conc_scan_config_bits, fw_config_bits);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05306720
Anurag Chouhan210db072016-02-22 18:42:15 +05306721 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05306722 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006723 WMA_LOGE("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05306724 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006725 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306726 wma_populate_soc_caps(wma_handle, tgt_hdl, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006727
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306728 ret = wma_update_hw_mode_list(wma_handle, tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306729 if (QDF_IS_STATUS_ERROR(ret)) {
6730 WMA_LOGE("Failed to update hw mode list");
6731 return -EINVAL;
6732 }
6733
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006734 WMA_LOGD("WMA --> WMI_INIT_CMDID");
Mukul Sharmab10c8c72017-11-02 17:25:59 +05306735
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306736 wma_init_scan_fw_mode_config(wma_handle->psoc, conc_scan_config_bits,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306737 fw_config_bits);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306738
6739 target_psoc_set_num_radios(tgt_hdl, 1);
jitiphilebf3a922018-11-05 14:25:00 +05306740
6741 if (wmi_service_enabled(wmi_handle,
6742 wmi_service_new_htt_msg_format)) {
6743 cdp_cfg_set_new_htt_msg_format(soc, 1);
6744 wlan_res_cfg->new_htt_msg_format = true;
6745 } else {
6746 cdp_cfg_set_new_htt_msg_format(soc, 0);
6747 wlan_res_cfg->new_htt_msg_format = false;
6748 }
6749
Alok Kumar02301292018-11-28 18:10:34 +05306750 if (cfg_get(wma_handle->psoc, CFG_DP_ENABLE_PEER_UMAP_CONF_SUPPORT) &&
6751 wmi_service_enabled(wmi_handle,
6752 wmi_service_peer_unmap_cnf_support)) {
6753 wlan_res_cfg->peer_unmap_conf_support = true;
6754 cdp_cfg_set_peer_unmap_conf_support(soc, true);
6755 } else {
6756 wlan_res_cfg->peer_unmap_conf_support = false;
6757 cdp_cfg_set_peer_unmap_conf_support(soc, false);
6758 }
6759
Govind Singhd76a5b02016-03-08 15:12:14 +05306760 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006761}
6762
6763/**
6764 * wma_rx_ready_event() - event handler to process
6765 * wmi rx ready event.
6766 * @handle: wma handle
6767 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05306768 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006769 *
6770 * Return: none
6771 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306772int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
6773 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006774{
6775 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6776 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
6777 wmi_ready_event_fixed_param *ev = NULL;
6778
6779 WMA_LOGD("%s: Enter", __func__);
6780
6781 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
6782 if (!(wma_handle && param_buf)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006783 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306784 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05306785 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006786 }
6787
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006788 WMA_LOGD("WMA <-- WMI_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006789
6790 ev = param_buf->fixed_param;
6791 /* Indicate to the waiting thread that the ready
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006792 * event was received
6793 */
Naveen Rawat64e477e2016-05-20 10:34:56 -07006794 wma_handle->sub_20_support =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306795 wmi_service_enabled(wma_handle->wmi_handle,
6796 wmi_service_half_rate_quarter_rate_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006797 wma_handle->wmi_ready = true;
6798 wma_handle->wlan_init_status = ev->status;
6799
Arif Hussainbaf28b82018-06-27 15:27:44 -07006800 if (wma_handle->is_dfs_offloaded)
6801 wmi_unified_dfs_phyerr_offload_en_cmd(
6802 wma_handle->wmi_handle, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006803 /* copy the mac addr */
6804 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
6805 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006806 wma_update_hdd_cfg(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006807 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05306808
6809 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006810}
6811
6812/**
6813 * wma_setneedshutdown() - setting wma needshutdown flag
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006814 *
6815 * Return: none
6816 */
Jeff Johnson1f8d0a02017-09-13 08:09:05 -07006817void wma_setneedshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006818{
6819 tp_wma_handle wma_handle;
6820
6821 WMA_LOGD("%s: Enter", __func__);
6822
Anurag Chouhan6d760662016-02-20 16:05:43 +05306823 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006824
6825 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006826 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306827 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006828 return;
6829 }
6830
6831 wma_handle->needShutdown = true;
6832 WMA_LOGD("%s: Exit", __func__);
6833}
6834
6835/**
6836 * wma_needshutdown() - Is wma needs shutdown?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006837 *
6838 * Return: returns true/false
6839 */
Jeff Johnson1b5404e2017-09-13 08:04:46 -07006840bool wma_needshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006841{
6842 tp_wma_handle wma_handle;
6843
6844 WMA_LOGD("%s: Enter", __func__);
6845
Anurag Chouhan6d760662016-02-20 16:05:43 +05306846 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006847
6848 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006849 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306850 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006851 return false;
6852 }
6853
6854 WMA_LOGD("%s: Exit", __func__);
6855 return wma_handle->needShutdown;
6856}
6857
6858/**
6859 * wma_wait_for_ready_event() - wait for wma ready event
6860 * @handle: wma handle
6861 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306862 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006863 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306864QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006865{
Dustin Brown19048bd2018-07-09 10:53:18 -07006866 tp_wma_handle wma_handle = (tp_wma_handle)handle;
6867 QDF_STATUS status;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306868 struct target_psoc_info *tgt_hdl;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006869
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306870 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6871 if (!tgt_hdl) {
Dustin Brown19048bd2018-07-09 10:53:18 -07006872 wma_err("target psoc info is NULL");
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306873 return QDF_STATUS_E_INVAL;
6874 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006875
Dustin Brown19048bd2018-07-09 10:53:18 -07006876 status = qdf_wait_for_event_completion(&tgt_hdl->info.event,
6877 WMA_READY_EVENTID_TIMEOUT);
6878 if (status == QDF_STATUS_E_TIMEOUT)
6879 wma_err("Timeout waiting for FW ready event");
6880 else if (QDF_IS_STATUS_ERROR(status))
6881 wma_err("Failed to wait for FW ready event; status:%u", status);
6882 else
6883 wma_info("FW ready event received");
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306884
Dustin Brown19048bd2018-07-09 10:53:18 -07006885 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006886}
6887
6888/**
6889 * wma_set_ppsconfig() - set pps config in fw
6890 * @vdev_id: vdev id
6891 * @pps_param: pps params
6892 * @val : param value
6893 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306894 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006895 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306896QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006897 int val)
6898{
Anurag Chouhan6d760662016-02-20 16:05:43 +05306899 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006900 int ret = -EIO;
6901 uint32_t pps_val;
6902
6903 if (NULL == wma) {
6904 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306905 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006906 }
6907
6908 switch (pps_param) {
6909 case WMA_VHT_PPS_PAID_MATCH:
6910 pps_val = ((val << 31) & 0xffff0000) |
6911 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
6912 goto pkt_pwr_save_config;
6913 case WMA_VHT_PPS_GID_MATCH:
6914 pps_val = ((val << 31) & 0xffff0000) |
6915 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
6916 goto pkt_pwr_save_config;
6917 case WMA_VHT_PPS_DELIM_CRC_FAIL:
6918 pps_val = ((val << 31) & 0xffff0000) |
6919 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
6920 goto pkt_pwr_save_config;
6921
6922 /* Enable the code below as and when the functionality
6923 * is supported/added in host.
6924 */
6925#ifdef NOT_YET
6926 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
6927 pps_val = ((val << 31) & 0xffff0000) |
6928 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
6929 goto pkt_pwr_save_config;
6930 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
6931 pps_val = ((val << 31) & 0xffff0000) |
6932 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
6933 goto pkt_pwr_save_config;
6934 case WMA_VHT_PPS_EOF_PAD_DELIM:
6935 pps_val = ((val << 31) & 0xffff0000) |
6936 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
6937 goto pkt_pwr_save_config;
6938 case WMA_VHT_PPS_MACADDR_MISMATCH:
6939 pps_val = ((val << 31) & 0xffff0000) |
6940 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
6941 goto pkt_pwr_save_config;
6942 case WMA_VHT_PPS_GID_NSTS_ZERO:
6943 pps_val = ((val << 31) & 0xffff0000) |
6944 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
6945 goto pkt_pwr_save_config;
6946 case WMA_VHT_PPS_RSSI_CHECK:
6947 pps_val = ((val << 31) & 0xffff0000) |
6948 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
6949 goto pkt_pwr_save_config;
6950#endif /* NOT_YET */
6951pkt_pwr_save_config:
6952 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
6953 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05306954 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006955 WMI_VDEV_PARAM_PACKET_POWERSAVE,
6956 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006957 break;
6958 default:
6959 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
6960 }
6961
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306962 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006963}
6964
6965/**
6966 * wma_process_set_mas() - Function to enable/disable MAS
6967 * @wma: Pointer to WMA handle
6968 * @mas_val: 1-Enable MAS, 0-Disable MAS
6969 *
6970 * This function enables/disables the MAS value
6971 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306972 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006974static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
6975 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006976{
6977 uint32_t val;
6978
6979 if (NULL == wma || NULL == mas_val) {
6980 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306981 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006982 }
6983
6984 val = (*mas_val);
6985
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306986 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006987 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
6988 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306989 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006990 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006991 WMA_LOGE("%s: Value is %d", __func__, val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306992 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006993}
6994
6995/**
6996 * wma_process_set_miracast() - Function to set miracast value in WMA
6997 * @wma: Pointer to WMA handle
6998 * @miracast_val: 0-Disabled,1-Source,2-Sink
6999 *
7000 * This function stores the miracast value in WMA
7001 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307002 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007003 *
7004 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007005static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
7006 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007007{
7008 if (NULL == wma || NULL == miracast_val) {
7009 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307010 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007011 }
7012
7013 wma->miracast_value = *miracast_val;
7014 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
7015
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307016 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007017}
7018
7019/**
7020 * wma_config_stats_factor() - Function to configure stats avg. factor
7021 * @wma: pointer to WMA handle
7022 * @avg_factor: stats. avg. factor passed down by userspace
7023 *
7024 * This function configures the avg. stats value in firmware
7025 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307026 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007027 *
7028 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307029static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007030 struct sir_stats_avg_factor *avg_factor)
7031{
Govind Singhd76a5b02016-03-08 15:12:14 +05307032 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007033
7034 if (NULL == wma || NULL == avg_factor) {
7035 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307036 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007037 }
7038
Govind Singhd76a5b02016-03-08 15:12:14 +05307039 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007040 avg_factor->vdev_id,
7041 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
7042 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05307043 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007044 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
7045 avg_factor->vdev_id);
7046 }
7047
7048 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
7049 avg_factor->stats_avg_factor, avg_factor->vdev_id);
7050
7051 return ret;
7052}
7053
7054/**
7055 * wma_config_guard_time() - Function to set guard time in firmware
7056 * @wma: pointer to WMA handle
7057 * @guard_time: guard time passed down by userspace
7058 *
7059 * This function configures the guard time in firmware
7060 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307061 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007062 *
7063 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307064static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007065 struct sir_guard_time_request *guard_time)
7066{
Govind Singhd76a5b02016-03-08 15:12:14 +05307067 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007068
7069 if (NULL == wma || NULL == guard_time) {
7070 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307071 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007072 }
7073
Govind Singhd76a5b02016-03-08 15:12:14 +05307074 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007075 guard_time->vdev_id,
7076 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
7077 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05307078 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007079 WMA_LOGE(" failed to set guard time for vdev_id %d",
7080 guard_time->vdev_id);
7081 }
7082
7083 WMA_LOGD("Set guard time %d for vdev_id %d",
7084 guard_time->guard_time, guard_time->vdev_id);
7085
7086 return ret;
7087}
7088
7089/**
7090 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
7091 * @wma_handle: WMA handle
7092 * @start_log: Start logging related parameters
7093 *
7094 * Send the command to the FW based on which specific logging of diag
7095 * event/log id can be started/stopped
7096 *
7097 * Return: None
7098 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007099static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
7100 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007101{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007102
7103 if (!start_log) {
7104 WMA_LOGE("%s: start_log pointer is NULL", __func__);
7105 return;
7106 }
7107 if (!wma_handle) {
7108 WMA_LOGE("%s: Invalid wma handle", __func__);
7109 return;
7110 }
7111
7112 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
7113 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
7114 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
7115 __func__, start_log->ring_id);
7116 return;
7117 }
7118
Govind Singhf25a0f12016-03-08 16:09:48 +05307119 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
7120 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007121}
7122
Poddar, Siddarth176c4362016-10-03 12:25:00 +05307123#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007124/**
7125 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
7126 * @wma_handle: WMA handle
7127 * @start_log: Struture containing the start wifi logger params
7128 *
7129 * This function is used to send the WMA commands to start/stop logging
7130 * of per packet statistics
7131 *
7132 * Return: None
7133 *
7134 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007135#ifdef REMOVE_PKT_LOG
7136static void wma_set_wifi_start_packet_stats(void *wma_handle,
7137 struct sir_wifi_start_log *start_log)
7138{
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007139}
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007140
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007141#else
7142static void wma_set_wifi_start_packet_stats(void *wma_handle,
7143 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007144{
Komal Seelam3d202862016-02-24 18:43:24 +05307145 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007146 uint32_t log_state;
7147
7148 if (!start_log) {
7149 WMA_LOGE("%s: start_log pointer is NULL", __func__);
7150 return;
7151 }
7152 if (!wma_handle) {
7153 WMA_LOGE("%s: Invalid wma handle", __func__);
7154 return;
7155 }
7156
7157 /* No need to register for ring IDs other than packet stats */
7158 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007159 WMA_LOGD("%s: Ring id is not for per packet stats: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007160 __func__, start_log->ring_id);
7161 return;
7162 }
7163
Anurag Chouhan6d760662016-02-20 16:05:43 +05307164 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07007165 if (scn == NULL) {
7166 WMA_LOGE("%s: Invalid HIF handle", __func__);
7167 return;
7168 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007169
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007170#ifdef HELIUMPLUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007171 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05307172 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
Venkata Sharath Chandra Manchala29965172018-01-18 14:17:29 -08007173 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Venkata Sharath Chandra Manchalacd660982018-10-28 21:04:28 -07007174#elif defined(QCA_WIFI_QCA6390)
7175 log_state = ATH_PKTLOG_RCFIND | ATH_PKTLOG_RCUPDATE |
7176 ATH_PKTLOG_LITE_RX | ATH_PKTLOG_LITE_T2H;
7177#elif defined(QCA_WIFI_QCA6290)
7178 log_state = ATH_PKTLOG_LITE_RX | ATH_PKTLOG_LITE_T2H;
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007179#else
Venkata Sharath Chandra Manchalacd660982018-10-28 21:04:28 -07007180 WMA_LOGD("%s: Packet log Not supported", __func__);
7181 log_state = 0;
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007182#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05307183 if (start_log->size != 0) {
7184 pktlog_setsize(scn, start_log->size * MEGABYTE);
7185 return;
Poddar, Siddarthab99a272017-04-10 12:53:26 +05307186 } else if (start_log->is_pktlog_buff_clear == true) {
7187 pktlog_clearbuff(scn, start_log->is_pktlog_buff_clear);
7188 return;
Poddar, Siddarth176c4362016-10-03 12:25:00 +05307189 }
7190
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007191 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08007192 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05307193 start_log->user_triggered,
7194 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007195 WMA_LOGD("%s: Enabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007196 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08007197 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05307198 start_log->user_triggered,
7199 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007200 WMA_LOGD("%s: Disabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007201 }
7202}
7203#endif
7204
7205/**
7206 * wma_send_flush_logs_to_fw() - Send log flush command to FW
7207 * @wma_handle: WMI handle
7208 *
7209 * This function is used to send the flush command to the FW,
7210 * that will flush the fw logs that are residue in the FW
7211 *
7212 * Return: None
7213 */
7214void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
7215{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307216 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007217 int ret;
7218
Govind Singhf25a0f12016-03-08 16:09:48 +05307219 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
7220 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007221 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007222
Anurag Chouhan210db072016-02-22 18:42:15 +05307223 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007224 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307225 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007226 WMA_LOGE("Failed to start the log completion timer");
7227}
7228
7229/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307230 * wma_update_wep_default_key - To update default key id
7231 * @wma: pointer to wma handler
7232 * @update_def_key: pointer to wep_update_default_key_idx
7233 *
7234 * This function makes a copy of default key index to txrx node
7235 *
7236 * Return: Success
7237 */
7238static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
7239 struct wep_update_default_key_idx *update_def_key)
7240{
7241 struct wma_txrx_node *iface =
7242 &wma->interfaces[update_def_key->session_id];
7243 iface->wep_default_key_idx = update_def_key->default_idx;
7244
7245 return QDF_STATUS_SUCCESS;
7246}
7247
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307248/**
7249 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
7250 * @wma_handle: WMA handle
7251 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
7252 *
7253 * This function is used to set Tx pkt fail count threshold,
7254 * FW will do disconnect with station once this threshold is reached.
7255 *
7256 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7257 */
7258static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007259 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307260{
7261 u_int8_t vdev_id;
7262 u_int32_t tx_fail_disconn_th;
7263 int ret = -EIO;
7264
7265 if (!wma || !wma->wmi_handle) {
7266 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
7267 return QDF_STATUS_E_INVAL;
7268 }
7269 vdev_id = tx_fail_cnt_th->session_id;
7270 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
7271 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7272 vdev_id, tx_fail_disconn_th);
7273
7274
7275 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7276 WMI_VDEV_PARAM_DISCONNECT_TH,
7277 tx_fail_disconn_th);
7278
7279 if (ret) {
7280 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
7281 return QDF_STATUS_E_FAILURE;
7282 }
7283
7284 return QDF_STATUS_SUCCESS;
7285}
7286
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307287/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307288 * wma_update_short_retry_limit() - Set retry limit for short frames
7289 * @wma_handle: WMA handle
7290 * @short_retry_limit_th: retry limir count for Short frames.
7291 *
7292 * This function is used to configure the transmission retry limit at which
7293 * short frames needs to be retry.
7294 *
7295 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7296 */
7297static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
7298 struct sme_short_retry_limit *short_retry_limit_th)
7299{
7300 uint8_t vdev_id;
7301 uint32_t short_retry_limit;
7302 int ret;
7303
7304 if (!wma || !wma->wmi_handle) {
7305 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
7306 return QDF_STATUS_E_INVAL;
7307 }
7308 vdev_id = short_retry_limit_th->session_id;
7309 short_retry_limit = short_retry_limit_th->short_retry_limit;
7310 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
7311 vdev_id, short_retry_limit);
7312
7313 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7314 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
7315 short_retry_limit);
7316
7317 if (ret) {
7318 WMA_LOGE("Failed to send short limit threshold command");
7319 return QDF_STATUS_E_FAILURE;
7320 }
7321 return QDF_STATUS_SUCCESS;
7322}
7323
7324/**
7325 * wma_update_long_retry_limit() - Set retry limit for long frames
7326 * @wma_handle: WMA handle
7327 * @long_retry_limit_th: retry limir count for long frames
7328 *
7329 * This function is used to configure the transmission retry limit at which
7330 * long frames needs to be retry
7331 *
7332 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7333 */
7334static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
7335 struct sme_long_retry_limit *long_retry_limit_th)
7336{
7337 uint8_t vdev_id;
7338 uint32_t long_retry_limit;
7339 int ret;
7340
7341 if (!wma || !wma->wmi_handle) {
7342 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
7343 return QDF_STATUS_E_INVAL;
7344 }
7345 vdev_id = long_retry_limit_th->session_id;
7346 long_retry_limit = long_retry_limit_th->long_retry_limit;
7347 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7348 vdev_id, long_retry_limit);
7349
7350 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7351 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
7352 long_retry_limit);
7353
7354 if (ret) {
7355 WMA_LOGE("Failed to send long limit threshold command");
7356 return QDF_STATUS_E_FAILURE;
7357 }
7358
7359 return QDF_STATUS_SUCCESS;
7360}
7361
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05307362/*
7363 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
7364 * @wma_handle: WMA handle
7365 * @sta_inactivity_timer: sme_sta_inactivity_timeout
7366 *
7367 * This function is used to set sta_inactivity_timeout.
7368 * If a station does not send anything in sta_inactivity_timeout seconds, an
7369 * empty data frame is sent to it in order to verify whether it is
7370 * still in range. If this frame is not ACKed, the station will be
7371 * disassociated and then deauthenticated.
7372 *
7373 * Return: None
7374 */
7375void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
7376 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
7377{
7378 uint8_t vdev_id;
7379 uint32_t max_unresponsive_time;
7380 uint32_t min_inactive_time, max_inactive_time;
7381
7382 if (!wma || !wma->wmi_handle) {
7383 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
7384 return;
7385 }
7386 vdev_id = sta_inactivity_timer->session_id;
7387 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
7388 max_inactive_time = max_unresponsive_time * TWO_THIRD;
7389 min_inactive_time = max_unresponsive_time - max_inactive_time;
7390
7391 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7392 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
7393 min_inactive_time))
7394 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
7395
7396 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7397 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
7398 max_inactive_time))
7399 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
7400
7401 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7402 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
7403 max_unresponsive_time))
7404 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
7405
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007406 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 +05307407 __func__, vdev_id,
7408 min_inactive_time, max_inactive_time,
7409 max_unresponsive_time);
7410}
7411
Yingying Tang95409972016-10-20 15:16:15 +08007412#ifdef WLAN_FEATURE_WOW_PULSE
7413
7414
7415#define WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7416WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMD_fixed_param
7417
7418
7419#define WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7420WMITLV_TAG_STRUC_wmi_wow_hostwakeup_gpio_pin_pattern_config_cmd_fixed_param
7421
7422/**
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007423 * wma_send_wow_pulse_cmd() - send wmi cmd of wow pulse cmd
7424 * information to fw.
7425 * @wma_handle: wma handler
7426 * @udp_response: wow_pulse_mode pointer
7427 *
7428 * Return: Return QDF_STATUS
7429 */
Yingying Tang95409972016-10-20 15:16:15 +08007430static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7431 struct wow_pulse_mode *wow_pulse_cmd)
7432{
7433 QDF_STATUS status = QDF_STATUS_SUCCESS;
7434 wmi_buf_t buf;
7435 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *cmd;
7436 u_int16_t len;
7437
7438 len = sizeof(*cmd);
7439 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007440 if (!buf)
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007441 return QDF_STATUS_E_NOMEM;
Yingying Tang95409972016-10-20 15:16:15 +08007442
7443 cmd = (WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *)wmi_buf_data(buf);
7444 qdf_mem_zero(cmd, len);
7445
7446 WMITLV_SET_HDR(&cmd->tlv_header,
7447 WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM,
7448 WMITLV_GET_STRUCT_TLVLEN(
7449 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM));
7450
7451 cmd->enable = wow_pulse_cmd->wow_pulse_enable;
7452 cmd->pin = wow_pulse_cmd->wow_pulse_pin;
7453 cmd->interval_low = wow_pulse_cmd->wow_pulse_interval_low;
7454 cmd->interval_high = wow_pulse_cmd->wow_pulse_interval_high;
7455 cmd->repeat_cnt = WMI_WOW_PULSE_REPEAT_CNT;
7456
7457 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7458 WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID)) {
Yingying Tang95409972016-10-20 15:16:15 +08007459 wmi_buf_free(buf);
7460 status = QDF_STATUS_E_FAILURE;
7461 }
7462
7463 WMA_LOGD("%s: Exit", __func__);
7464 return status;
7465}
7466
7467#undef WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7468#undef WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7469#undef WMI_WOW_PULSE_REPEAT_CNT
7470
7471#else
7472static inline QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7473 struct wow_pulse_mode *wow_pulse_cmd)
7474{
7475 return QDF_STATUS_E_FAILURE;
7476}
7477#endif
7478
7479
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307480/**
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307481 * wma_process_power_debug_stats_req() - Process the Chip Power stats collect
7482 * request and pass the Power stats request to Fw
7483 * @wma_handle: WMA handle
7484 *
7485 * Return: QDF_STATUS
7486 */
7487#ifdef WLAN_POWER_DEBUGFS
7488static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7489{
7490 wmi_pdev_get_chip_power_stats_cmd_fixed_param *cmd;
7491 int32_t len;
7492 wmi_buf_t buf;
7493 uint8_t *buf_ptr;
7494 int ret;
7495
7496 if (!wma_handle) {
7497 WMA_LOGE("%s: input pointer is NULL", __func__);
7498 return QDF_STATUS_E_FAILURE;
7499 }
7500
7501 len = sizeof(*cmd);
7502 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007503 if (!buf)
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307504 return QDF_STATUS_E_NOMEM;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307505
7506 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7507 cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr;
7508
7509 WMITLV_SET_HDR(&cmd->tlv_header,
7510 WMITLV_TAG_STRUC_wmi_get_chip_power_stats_cmd_fixed_param,
7511 WMITLV_GET_STRUCT_TLVLEN(
7512 wmi_pdev_get_chip_power_stats_cmd_fixed_param));
7513 cmd->pdev_id = 0;
7514
7515 WMA_LOGD("POWER_DEBUG_STATS - Get Request Params; Pdev id - %d",
7516 cmd->pdev_id);
7517 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7518 WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
7519 if (ret) {
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307520 wmi_buf_free(buf);
7521 return QDF_STATUS_E_FAILURE;
7522 }
7523 return QDF_STATUS_SUCCESS;
7524}
7525#else
7526static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7527{
7528 return QDF_STATUS_SUCCESS;
7529}
7530#endif
Arunk Khandavallica56d4b2018-11-29 15:46:00 +05307531#ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
7532static QDF_STATUS wma_process_beacon_debug_stats_req(tp_wma_handle wma_handle,
7533 uint32_t *vdev_id)
7534{
7535 wmi_vdev_get_bcn_recv_stats_cmd_fixed_param *cmd;
7536 int32_t len;
7537 wmi_buf_t buf;
7538 uint8_t *buf_ptr;
7539 int ret;
7540
7541 WMA_LOGD("%s: Enter", __func__);
7542 if (!wma_handle) {
7543 WMA_LOGE("%s: input pointer is NULL", __func__);
7544 return QDF_STATUS_E_FAILURE;
7545 }
7546
7547 len = sizeof(*cmd);
7548 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7549 if (!buf)
7550 return QDF_STATUS_E_NOMEM;
7551
7552 buf_ptr = (u_int8_t *)wmi_buf_data(buf);
7553 cmd = (wmi_vdev_get_bcn_recv_stats_cmd_fixed_param *)buf_ptr;
7554
7555 WMITLV_SET_HDR(&cmd->tlv_header,
7556 WMITLV_TAG_STRUC_wmi_get_bcn_recv_stats_fixed_param,
7557 WMITLV_GET_STRUCT_TLVLEN(
7558 wmi_vdev_get_bcn_recv_stats_cmd_fixed_param));
7559 cmd->vdev_id = *vdev_id;
7560
7561 WMA_LOGD("BEACON_DEBUG_STATS - Get Request Params; vdev id - %d",
7562 cmd->vdev_id);
7563 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7564 WMI_VDEV_GET_BCN_RECEPTION_STATS_CMDID);
7565 if (ret) {
7566 wmi_buf_free(buf);
7567 return QDF_STATUS_E_FAILURE;
7568 }
7569
7570 WMA_LOGD("%s: Exit", __func__);
7571 return QDF_STATUS_SUCCESS;
7572}
7573#else
7574static QDF_STATUS wma_process_beacon_debug_stats_req(tp_wma_handle wma_handle,
7575 uint32_t *vdev_id)
7576{
7577 return QDF_STATUS_SUCCESS;
7578}
7579#endif
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307580
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307581/**
7582 * wma_set_arp_req_stats() - process set arp stats request command to fw
7583 * @wma_handle: WMA handle
7584 * @req_buf: set srp stats request buffer
7585 *
7586 * Return: None
7587 */
7588static void wma_set_arp_req_stats(WMA_HANDLE handle,
7589 struct set_arp_stats_params *req_buf)
7590{
7591 int status;
7592 struct set_arp_stats *arp_stats;
7593 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7594
7595 if (!wma_handle || !wma_handle->wmi_handle) {
7596 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7597 __func__);
7598 return;
7599 }
Yeshwanth Sriram Guntukad5aae7f2017-11-27 14:33:51 +05307600 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7601 WMA_LOGE("vdev id not active or not valid");
7602 return;
7603 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307604
7605 arp_stats = (struct set_arp_stats *)req_buf;
7606 status = wmi_unified_set_arp_stats_req(wma_handle->wmi_handle,
7607 arp_stats);
7608 if (status != EOK)
7609 WMA_LOGE("%s: failed to set arp stats to FW",
7610 __func__);
7611}
7612
7613/**
7614 * wma_get_arp_req_stats() - process get arp stats request command to fw
7615 * @wma_handle: WMA handle
7616 * @req_buf: get srp stats request buffer
7617 *
7618 * Return: None
7619 */
7620static void wma_get_arp_req_stats(WMA_HANDLE handle,
7621 struct get_arp_stats_params *req_buf)
7622{
7623 int status;
7624 struct get_arp_stats *arp_stats;
7625 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7626
7627 if (!wma_handle || !wma_handle->wmi_handle) {
7628 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7629 __func__);
7630 return;
7631 }
Yeshwanth Sriram Guntuka3e4d96f2017-12-19 14:09:04 +05307632 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7633 WMA_LOGE("vdev id not active or not valid");
7634 return;
7635 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307636
7637 arp_stats = (struct get_arp_stats *)req_buf;
7638 status = wmi_unified_get_arp_stats_req(wma_handle->wmi_handle,
7639 arp_stats);
7640 if (status != EOK)
7641 WMA_LOGE("%s: failed to send get arp stats to FW",
7642 __func__);
7643}
7644
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307645/**
7646 * wma_set_del_pmkid_cache() - API to set/delete PMKID cache entry in fw
7647 * @handle: WMA handle
7648 * @pmk_cache: PMK cache entry
7649 *
7650 * Return: None
7651 */
7652static void wma_set_del_pmkid_cache(WMA_HANDLE handle,
7653 struct wmi_unified_pmk_cache *pmk_cache)
7654{
7655 int status;
7656 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7657
7658 if (!wma_handle || !wma_handle->wmi_handle) {
7659 WMA_LOGE("WMA is closed, cannot send set del pmkid");
7660 return;
7661 }
7662
7663 status = wmi_unified_set_del_pmkid_cache(wma_handle->wmi_handle,
7664 pmk_cache);
7665 if (status != EOK)
7666 WMA_LOGE("failed to send set/del pmkid cmd to fw");
7667}
7668
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307669/**
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307670 * wma_send_invoke_neighbor_report() - API to send invoke neighbor report
7671 * command to fw
7672 *
7673 * @handle: WMA handle
7674 * @params: Pointer to invoke neighbor report params
7675 *
7676 * Return: None
7677 */
7678static
7679void wma_send_invoke_neighbor_report(WMA_HANDLE handle,
7680 struct wmi_invoke_neighbor_report_params *params)
7681{
7682 QDF_STATUS status;
7683 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7684
7685 if (!wma_handle || !wma_handle->wmi_handle) {
7686 WMA_LOGE("WMA is closed, cannot send invoke neighbor report");
7687 return;
7688 }
7689
7690 status = wmi_unified_invoke_neighbor_report_cmd(wma_handle->wmi_handle,
7691 params);
7692
7693 if (status != QDF_STATUS_SUCCESS)
7694 WMA_LOGE("failed to send invoke neighbor report command");
7695}
7696
lifeng66831662017-05-19 16:01:35 +08007697QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle,
7698 struct sir_set_rx_reorder_timeout_val *reorder_timeout)
7699{
7700 wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *cmd;
7701 uint32_t len;
7702 wmi_buf_t buf;
7703 int ret;
7704
7705 if (!reorder_timeout) {
7706 WMA_LOGE(FL("invalid pointer"));
7707 return QDF_STATUS_E_INVAL;
7708 }
7709
7710 if (!wma_handle) {
7711 WMA_LOGE(FL("WMA context is invald!"));
7712 return QDF_STATUS_E_INVAL;
7713 }
7714 len = sizeof(*cmd);
7715 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007716 if (!buf)
lifeng66831662017-05-19 16:01:35 +08007717 return QDF_STATUS_E_NOMEM;
Arif Hussain157263f2018-10-03 13:07:15 -07007718
lifeng66831662017-05-19 16:01:35 +08007719 cmd = (wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *)
7720 wmi_buf_data(buf);
7721
7722 WMITLV_SET_HDR(&cmd->tlv_header,
7723 WMITLV_TAG_STRUC_wmi_pdev_set_reorder_timeout_val_cmd_fixed_param,
7724 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_reorder_timeout_val_cmd_fixed_param));
7725
7726 memcpy(cmd->rx_timeout_pri, reorder_timeout->rx_timeout_pri,
7727 sizeof(reorder_timeout->rx_timeout_pri));
7728
7729 WMA_LOGD("rx aggr record timeout: VO: %d, VI: %d, BE: %d, BK: %d",
7730 cmd->rx_timeout_pri[0], cmd->rx_timeout_pri[1],
7731 cmd->rx_timeout_pri[2], cmd->rx_timeout_pri[3]);
7732
7733 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7734 WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID);
7735 if (ret) {
lifeng66831662017-05-19 16:01:35 +08007736 wmi_buf_free(buf);
7737 return QDF_STATUS_E_FAILURE;
7738 }
7739
7740 return QDF_STATUS_SUCCESS;
7741}
7742
7743QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle,
7744 struct sir_peer_set_rx_blocksize *peer_rx_blocksize)
7745{
7746 wmi_peer_set_rx_blocksize_cmd_fixed_param *cmd;
7747 int32_t len;
7748 wmi_buf_t buf;
7749 u_int8_t *buf_ptr;
7750 int ret;
7751
7752 if (!peer_rx_blocksize) {
7753 WMA_LOGE(FL("invalid pointer"));
7754 return QDF_STATUS_E_INVAL;
7755 }
7756
7757 if (!wma_handle) {
7758 WMA_LOGE(FL(" WMA context is invald!"));
7759 return QDF_STATUS_E_INVAL;
7760 }
7761
7762 len = sizeof(*cmd);
7763 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007764 if (!buf)
lifeng66831662017-05-19 16:01:35 +08007765 return QDF_STATUS_E_NOMEM;
lifeng66831662017-05-19 16:01:35 +08007766
7767 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7768 cmd = (wmi_peer_set_rx_blocksize_cmd_fixed_param *) buf_ptr;
7769
7770 WMITLV_SET_HDR(&cmd->tlv_header,
7771 WMITLV_TAG_STRUC_wmi_peer_set_rx_blocksize_cmd_fixed_param,
7772 WMITLV_GET_STRUCT_TLVLEN(wmi_peer_set_rx_blocksize_cmd_fixed_param));
7773
7774 cmd->vdev_id = peer_rx_blocksize->vdev_id;
7775 cmd->rx_block_ack_win_limit =
7776 peer_rx_blocksize->rx_block_ack_win_limit;
7777 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_rx_blocksize->peer_macaddr.bytes,
7778 &cmd->peer_macaddr);
7779
7780 WMA_LOGD("rx aggr blocksize: %d", cmd->rx_block_ack_win_limit);
7781
7782 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7783 WMI_PEER_SET_RX_BLOCKSIZE_CMDID);
7784 if (ret) {
lifeng66831662017-05-19 16:01:35 +08007785 wmi_buf_free(buf);
7786 return QDF_STATUS_E_FAILURE;
7787 }
7788
7789 return QDF_STATUS_SUCCESS;
7790}
7791
lifengd217d192017-05-09 19:44:16 +08007792QDF_STATUS wma_get_chain_rssi(tp_wma_handle wma_handle,
7793 struct get_chain_rssi_req_params *req_params)
7794{
lifengfe6c3e22018-04-03 12:10:04 +08007795 wmi_pdev_div_get_rssi_antid_fixed_param *cmd;
lifengd217d192017-05-09 19:44:16 +08007796 wmi_buf_t wmi_buf;
lifengfe6c3e22018-04-03 12:10:04 +08007797 uint32_t len = sizeof(wmi_pdev_div_get_rssi_antid_fixed_param);
lifengd217d192017-05-09 19:44:16 +08007798 u_int8_t *buf_ptr;
7799
7800 if (!wma_handle) {
7801 WMA_LOGE(FL("WMA is closed, can not issue cmd"));
7802 return QDF_STATUS_E_INVAL;
7803 }
7804
7805 wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007806 if (!wmi_buf)
lifengd217d192017-05-09 19:44:16 +08007807 return QDF_STATUS_E_NOMEM;
lifengd217d192017-05-09 19:44:16 +08007808
7809 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7810
lifengfe6c3e22018-04-03 12:10:04 +08007811 cmd = (wmi_pdev_div_get_rssi_antid_fixed_param *)buf_ptr;
lifengd217d192017-05-09 19:44:16 +08007812 WMITLV_SET_HDR(&cmd->tlv_header,
lifengfe6c3e22018-04-03 12:10:04 +08007813 WMITLV_TAG_STRUC_wmi_pdev_div_get_rssi_antid_fixed_param,
lifengd217d192017-05-09 19:44:16 +08007814 WMITLV_GET_STRUCT_TLVLEN(
lifengfe6c3e22018-04-03 12:10:04 +08007815 wmi_pdev_div_get_rssi_antid_fixed_param));
7816 cmd->pdev_id = 0;
lifengd217d192017-05-09 19:44:16 +08007817 WMI_CHAR_ARRAY_TO_MAC_ADDR(req_params->peer_macaddr.bytes,
lifengfe6c3e22018-04-03 12:10:04 +08007818 &cmd->macaddr);
lifengd217d192017-05-09 19:44:16 +08007819
7820 if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len,
lifengfe6c3e22018-04-03 12:10:04 +08007821 WMI_PDEV_DIV_GET_RSSI_ANTID_CMDID)) {
lifengd217d192017-05-09 19:44:16 +08007822 wmi_buf_free(wmi_buf);
7823 return QDF_STATUS_E_FAILURE;
7824 }
7825
7826 return QDF_STATUS_SUCCESS;
7827}
7828
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307829#if defined(WLAN_FEATURE_FILS_SK)
7830/**
7831 * wma_roam_scan_send_hlp() - API to send HLP IE info to fw
7832 * @wma_handle: WMA handle
7833 * @req: HLP params
7834 *
7835 * Return: QDF_STATUS
7836 */
7837static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7838 struct hlp_params *req)
7839{
7840 struct hlp_params *params;
7841 QDF_STATUS status;
7842
7843 params = qdf_mem_malloc(sizeof(*params));
Arif Hussain157263f2018-10-03 13:07:15 -07007844 if (!params)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307845 return QDF_STATUS_E_NOMEM;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307846
7847 params->vdev_id = req->vdev_id;
7848 params->hlp_ie_len = req->hlp_ie_len;
7849 qdf_mem_copy(params->hlp_ie, req->hlp_ie, req->hlp_ie_len);
7850 status = wmi_unified_roam_send_hlp_cmd(wma_handle->wmi_handle, params);
7851
7852 WMA_LOGD("Send HLP status %d vdev id %d", status, params->vdev_id);
7853 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
7854 params->hlp_ie, 10);
7855
7856 qdf_mem_free(params);
7857 return status;
7858}
7859#else
7860static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7861 struct hlp_params *req)
7862{
7863 return QDF_STATUS_SUCCESS;
7864}
7865#endif
7866
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307867/**
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307868 * wma_process_set_limit_off_chan() - set limit off chanel parameters
7869 * @wma_handle: pointer to wma handle
7870 * @param: pointer to sir_limit_off_chan
7871 *
7872 * Return: QDF_STATUS_SUCCESS for success or error code.
7873 */
7874static QDF_STATUS wma_process_limit_off_chan(tp_wma_handle wma_handle,
7875 struct sir_limit_off_chan *param)
7876{
7877 int32_t err;
7878 struct wmi_limit_off_chan_param limit_off_chan_param;
7879
Rajeev Kumar752d64e2017-10-05 16:32:58 -07007880 if (param->vdev_id >= wma_handle->max_bssid) {
7881 WMA_LOGE(FL("Invalid vdev_id: %d"), param->vdev_id);
7882 return QDF_STATUS_E_INVAL;
7883 }
7884 if (!wma_is_vdev_up(param->vdev_id)) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05307885 WMA_LOGD("vdev %d is not up skipping limit_off_chan_param",
7886 param->vdev_id);
Rajeev Kumar752d64e2017-10-05 16:32:58 -07007887 return QDF_STATUS_E_INVAL;
7888 }
7889
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307890 limit_off_chan_param.vdev_id = param->vdev_id;
7891 limit_off_chan_param.status = param->is_tos_active;
7892 limit_off_chan_param.max_offchan_time = param->max_off_chan_time;
7893 limit_off_chan_param.rest_time = param->rest_time;
7894 limit_off_chan_param.skip_dfs_chans = param->skip_dfs_chans;
7895
7896 err = wmi_unified_send_limit_off_chan_cmd(wma_handle->wmi_handle,
7897 &limit_off_chan_param);
7898 if (err) {
7899 WMA_LOGE("\n failed to set limit off chan cmd");
7900 return QDF_STATUS_E_FAILURE;
7901 }
7902
7903 return QDF_STATUS_SUCCESS;
7904}
7905
Arif Hussain05fb4872018-01-03 16:02:55 -08007906static QDF_STATUS wma_process_obss_color_collision_req(tp_wma_handle wma_handle,
7907 struct wmi_obss_color_collision_cfg_param *cfg)
7908{
7909 QDF_STATUS status;
7910
7911 if (cfg->vdev_id >= wma_handle->max_bssid) {
7912 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7913 return QDF_STATUS_E_INVAL;
7914 }
7915 if (!wma_is_vdev_up(cfg->vdev_id)) {
7916 WMA_LOGE("vdev %d is not up skipping obss color collision req",
7917 cfg->vdev_id);
7918 return QDF_STATUS_E_INVAL;
7919 }
7920
7921 status = wmi_unified_send_obss_color_collision_cfg_cmd(wma_handle->
7922 wmi_handle, cfg);
7923 if (QDF_IS_STATUS_ERROR(status))
7924 WMA_LOGE("Failed to send obss color collision cfg");
7925
7926 return status;
7927}
7928
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307929/**
Arif Hussainee10f902017-12-27 16:30:17 -08007930 * wma_send_obss_detection_cfg() - send obss detection cfg to firmware
7931 * @wma_handle: pointer to wma handle
7932 * @cfg: obss detection configuration
7933 *
7934 * Send obss detection configuration to firmware.
7935 *
7936 * Return: None
7937 */
7938static void wma_send_obss_detection_cfg(tp_wma_handle wma_handle,
7939 struct wmi_obss_detection_cfg_param
7940 *cfg)
7941{
7942 QDF_STATUS status;
7943
7944 if (cfg->vdev_id >= wma_handle->max_bssid) {
7945 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7946 return;
7947 }
7948 if (!wma_is_vdev_up(cfg->vdev_id)) {
7949 WMA_LOGE("vdev %d is not up skipping obss detection req",
7950 cfg->vdev_id);
7951 return;
7952 }
7953
7954 status = wmi_unified_send_obss_detection_cfg_cmd(wma_handle->wmi_handle,
7955 cfg);
7956 if (QDF_IS_STATUS_ERROR(status))
7957 WMA_LOGE("Failed to send obss detection cfg");
7958
7959 return;
7960}
7961
7962/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 * wma_mc_process_msg() - process wma messages and call appropriate function.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007964 * @msg: message
7965 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307966 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007967 */
Jeff Johnson5be42ab2017-09-13 09:10:39 -07007968static QDF_STATUS wma_mc_process_msg(struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007969{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307970 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007971 tp_wma_handle wma_handle;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08007972 struct cdp_vdev *txrx_vdev_handle = NULL;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07007973
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007974 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307975 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007977 if (NULL == msg) {
7978 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307979 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307980 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007981 goto end;
7982 }
7983
7984 WMA_LOGD("msg->type = %x %s", msg->type,
7985 mac_trace_get_wma_msg_string(msg->type));
7986
Anurag Chouhan6d760662016-02-20 16:05:43 +05307987 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007988
7989 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007990 WMA_LOGE("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307991 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307992 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307993 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007994 goto end;
7995 }
7996
7997 switch (msg->type) {
7998
7999 /* Message posted by wmi for all control path related
8000 * FW events to serialize through mc_thread.
8001 */
8002 case WMA_PROCESS_FW_EVENT:
8003 wma_process_fw_event(wma_handle,
8004 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308005 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008006 break;
8007
8008#ifdef FEATURE_WLAN_ESE
8009 case WMA_TSM_STATS_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08008010 WMA_LOGD("McThread: WMA_TSM_STATS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008011 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
8012 break;
8013#endif /* FEATURE_WLAN_ESE */
8014 case WNI_CFG_DNLD_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08008015 WMA_LOGD("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308016 qdf_status = wma_wni_cfg_dnld(wma_handle);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008017 if (QDF_IS_STATUS_SUCCESS(qdf_status))
Jeff Johnsonf7ab8142017-09-13 09:04:23 -07008018 cds_wma_complete_cback();
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008019 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008020 WMA_LOGD("config download failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008021 break;
8022 case WMA_ADD_STA_SELF_REQ:
8023 txrx_vdev_handle =
8024 wma_vdev_attach(wma_handle,
8025 (struct add_sta_self_params *) msg->
8026 bodyptr, 1);
8027 if (!txrx_vdev_handle) {
8028 WMA_LOGE("Failed to attach vdev");
8029 } else {
8030 /* Register with TxRx Module for Data Ack Complete Cb */
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308031 if (soc) {
8032 cdp_data_tx_cb_set(soc, txrx_vdev_handle,
8033 wma_data_tx_ack_comp_hdlr,
8034 wma_handle);
8035 } else {
8036 WMA_LOGE("%s: SOC context is NULL", __func__);
8037 qdf_status = QDF_STATUS_E_FAILURE;
8038 goto end;
8039 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008040 }
8041 break;
8042 case WMA_DEL_STA_SELF_REQ:
8043 wma_vdev_detach(wma_handle,
8044 (struct del_sta_self_params *) msg->bodyptr, 1);
8045 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008046 case WMA_UPDATE_CHAN_LIST_REQ:
8047 wma_update_channel_list(wma_handle,
8048 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308049 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008050 break;
8051 case WMA_SET_LINK_STATE:
8052 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
8053 break;
8054 case WMA_CHNL_SWITCH_REQ:
8055 wma_set_channel(wma_handle,
8056 (tpSwitchChannelParams) msg->bodyptr);
8057 break;
8058 case WMA_ADD_BSS_REQ:
8059 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
8060 break;
8061 case WMA_ADD_STA_REQ:
8062 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
8063 break;
8064 case WMA_SET_BSSKEY_REQ:
8065 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
8066 break;
8067 case WMA_SET_STAKEY_REQ:
8068 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
8069 break;
8070 case WMA_DELETE_STA_REQ:
8071 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
8072 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07008073 case WMA_DELETE_BSS_HO_FAIL_REQ:
8074 wma_delete_bss_ho_fail(wma_handle,
8075 (tpDeleteBssParams) msg->bodyptr);
8076 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008077 case WMA_DELETE_BSS_REQ:
8078 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
8079 break;
8080 case WMA_UPDATE_EDCA_PROFILE_IND:
8081 wma_process_update_edca_param_req(wma_handle,
8082 (tEdcaParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308083 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008084 break;
8085 case WMA_SEND_BEACON_REQ:
8086 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008087 break;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308088 case WMA_SEND_AP_VDEV_UP:
8089 wma_set_ap_vdev_up(wma_handle, msg->bodyval);
8090 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008091 case WMA_SEND_PROBE_RSP_TMPL:
8092 wma_send_probe_rsp_tmpl(wma_handle,
8093 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308094 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008095 break;
8096 case WMA_CLI_SET_CMD:
8097 wma_process_cli_set_cmd(wma_handle,
8098 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308099 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008100 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07008101 case WMA_SET_PDEV_IE_REQ:
8102 wma_process_set_pdev_ie_req(wma_handle,
8103 (struct set_ie_param *)msg->bodyptr);
8104 qdf_mem_free(msg->bodyptr);
8105 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008106#if !defined(REMOVE_PKT_LOG)
8107 case WMA_PKTLOG_ENABLE_REQ:
8108 wma_pktlog_wmi_send_cmd(wma_handle,
8109 (struct ath_pktlog_wmi_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308110 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111 break;
8112#endif /* REMOVE_PKT_LOG */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008113 case WMA_ENTER_PS_REQ:
8114 wma_enable_sta_ps_mode(wma_handle,
8115 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308116 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008117 break;
8118 case WMA_EXIT_PS_REQ:
8119 wma_disable_sta_ps_mode(wma_handle,
8120 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308121 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008122 break;
8123 case WMA_ENABLE_UAPSD_REQ:
8124 wma_enable_uapsd_mode(wma_handle,
8125 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308126 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008127 break;
8128 case WMA_DISABLE_UAPSD_REQ:
8129 wma_disable_uapsd_mode(wma_handle,
8130 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308131 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008132 break;
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08008133 case WMA_SET_DTIM_PERIOD:
8134 wma_set_dtim_period(wma_handle,
8135 (struct set_dtim_params *)msg->bodyptr);
8136 qdf_mem_free(msg->bodyptr);
8137 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008138 case WMA_SET_TX_POWER_REQ:
8139 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
8140 break;
8141 case WMA_SET_MAX_TX_POWER_REQ:
8142 wma_set_max_tx_power(wma_handle,
8143 (tpMaxTxPowerParams) msg->bodyptr);
8144 break;
8145 case WMA_SET_KEEP_ALIVE:
8146 wma_set_keepalive_req(wma_handle,
8147 (tSirKeepAliveReq *) msg->bodyptr);
8148 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08008149#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008150 case WMA_SET_PLM_REQ:
8151 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
8152 break;
8153#endif
8154 case WMA_GET_STATISTICS_REQ:
8155 wma_get_stats_req(wma_handle,
8156 (tAniGetPEStatsReq *) msg->bodyptr);
8157 break;
8158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008159 case WMA_UPDATE_OP_MODE:
8160 wma_process_update_opmode(wma_handle,
8161 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308162 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008163 break;
8164 case WMA_UPDATE_RX_NSS:
8165 wma_process_update_rx_nss(wma_handle,
8166 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308167 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008168 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008169 case WMA_UPDATE_MEMBERSHIP:
8170 wma_process_update_membership(wma_handle,
8171 (tUpdateMembership *) msg->bodyptr);
8172 break;
8173 case WMA_UPDATE_USERPOS:
8174 wma_process_update_userpos(wma_handle,
8175 (tUpdateUserPos *) msg->bodyptr);
8176 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008177 case WMA_UPDATE_BEACON_IND:
8178 wma_process_update_beacon_params(wma_handle,
8179 (tUpdateBeaconParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308180 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008181 break;
8182
8183 case WMA_ADD_TS_REQ:
Jeff Johnson9851fcc2018-12-22 17:29:58 -08008184 wma_add_ts_req(wma_handle, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008185 break;
8186
8187 case WMA_DEL_TS_REQ:
Jeff Johnson256002f2018-12-22 17:53:19 -08008188 wma_del_ts_req(wma_handle, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008189 break;
8190
8191 case WMA_AGGR_QOS_REQ:
Jeff Johnson54024412018-12-22 12:07:06 -08008192 wma_aggr_qos_req(wma_handle, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008193 break;
8194
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008195 case WMA_8023_MULTICAST_LIST_REQ:
8196 wma_process_mcbc_set_filter_req(wma_handle,
8197 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308198 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008199 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008200 case WMA_ROAM_SCAN_OFFLOAD_REQ:
8201 /*
8202 * Main entry point or roaming directives from CSR.
8203 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08008204 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008205 (tSirRoamOffloadScanReq *) msg->bodyptr);
8206 break;
8207
8208 case WMA_RATE_UPDATE_IND:
8209 wma_process_rate_update_indicate(wma_handle,
8210 (tSirRateUpdateInd *) msg->bodyptr);
8211 break;
8212
8213#ifdef FEATURE_WLAN_TDLS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008214 case WMA_UPDATE_TDLS_PEER_STATE:
8215 wma_update_tdls_peer_state(wma_handle,
8216 (tTdlsPeerStateParams *) msg->bodyptr);
8217 break;
8218 case WMA_TDLS_SET_OFFCHAN_MODE:
8219 wma_set_tdls_offchan_mode(wma_handle,
8220 (tdls_chan_switch_params *)msg->bodyptr);
8221 break;
8222#endif /* FEATURE_WLAN_TDLS */
8223 case WMA_ADD_PERIODIC_TX_PTRN_IND:
8224 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
8225 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308226 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008227 break;
8228 case WMA_DEL_PERIODIC_TX_PTRN_IND:
8229 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
8230 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308231 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008232 break;
8233 case WMA_TX_POWER_LIMIT:
8234 wma_process_tx_power_limits(wma_handle,
8235 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308236 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008237 break;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08008238 case WMA_SEND_ADDBA_REQ:
8239 wma_process_send_addba_req(wma_handle,
8240 (struct send_add_ba_req *)msg->bodyptr);
8241 break;
8242
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008243#ifdef FEATURE_WLAN_CH_AVOID
8244 case WMA_CH_AVOID_UPDATE_REQ:
8245 wma_process_ch_avoid_update_req(wma_handle,
8246 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308247 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008248 break;
8249#endif /* FEATURE_WLAN_CH_AVOID */
8250#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
8251 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
8252 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308253 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008254 break;
8255#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
8256 case WMA_DHCP_START_IND:
8257 case WMA_DHCP_STOP_IND:
8258 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308259 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008260 break;
8261
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008262 case WMA_IBSS_CESIUM_ENABLE_IND:
8263 wma_process_cesium_enable_ind(wma_handle);
8264 break;
8265 case WMA_GET_IBSS_PEER_INFO_REQ:
8266 wma_process_get_peer_info_req(wma_handle,
8267 (tSirIbssGetPeerInfoReqParams *)
8268 msg->bodyptr);
8269 qdf_mem_free(msg->bodyptr);
8270 break;
8271 case WMA_TX_FAIL_MONITOR_IND:
8272 wma_process_tx_fail_monitor_ind(wma_handle,
8273 (tAniTXFailMonitorInd *) msg->bodyptr);
8274 qdf_mem_free(msg->bodyptr);
8275 break;
8276
8277 case WMA_RMC_ENABLE_IND:
8278 wma_process_rmc_enable_ind(wma_handle);
8279 break;
8280 case WMA_RMC_DISABLE_IND:
8281 wma_process_rmc_disable_ind(wma_handle);
8282 break;
8283 case WMA_RMC_ACTION_PERIOD_IND:
8284 wma_process_rmc_action_period_ind(wma_handle);
8285 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008286 case WMA_INIT_THERMAL_INFO_CMD:
8287 wma_process_init_thermal_info(wma_handle,
8288 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308289 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008290 break;
8291
8292 case WMA_SET_THERMAL_LEVEL:
8293 wma_process_set_thermal_level(wma_handle, msg->bodyval);
8294 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05308295#ifdef CONFIG_HL_SUPPORT
8296 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
8297 wma_process_init_bad_peer_tx_ctl_info(
8298 wma_handle,
8299 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
8300 qdf_mem_free(msg->bodyptr);
8301 break;
8302#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008303 case WMA_SET_MIMOPS_REQ:
8304 wma_process_set_mimops_req(wma_handle,
8305 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308306 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008307 break;
8308 case WMA_SET_SAP_INTRABSS_DIS:
8309 wma_set_vdev_intrabss_fwd(wma_handle,
8310 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308311 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008312 break;
Will Huanga9814592017-05-24 15:47:58 +08008313 case WMA_GET_PEER_INFO:
8314 wma_get_peer_info(wma_handle, msg->bodyptr);
8315 qdf_mem_free(msg->bodyptr);
8316 break;
8317 case WMA_GET_PEER_INFO_EXT:
8318 wma_get_peer_info_ext(wma_handle, msg->bodyptr);
8319 qdf_mem_free(msg->bodyptr);
8320 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008321 case WMA_MODEM_POWER_STATE_IND:
8322 wma_notify_modem_power_state(wma_handle,
8323 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308324 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008325 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008326#ifdef WLAN_FEATURE_STATS_EXT
8327 case WMA_STATS_EXT_REQUEST:
8328 wma_stats_ext_req(wma_handle,
8329 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308330 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008331 break;
8332#endif /* WLAN_FEATURE_STATS_EXT */
8333 case WMA_HIDDEN_SSID_VDEV_RESTART:
8334 wma_hidden_ssid_vdev_restart(wma_handle,
8335 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008336 break;
8337#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
8338 case WMA_WLAN_EXT_WOW:
8339 wma_enable_ext_wow(wma_handle,
8340 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308341 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008342 break;
8343 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
8344 wma_set_app_type1_params_in_fw(wma_handle,
8345 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308346 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008347 break;
8348 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
8349 wma_set_app_type2_params_in_fw(wma_handle,
8350 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308351 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008352 break;
8353#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
8354#ifdef FEATURE_WLAN_EXTSCAN
8355 case WMA_EXTSCAN_START_REQ:
Jeff Johnsondab58602018-07-14 15:30:24 -07008356 wma_start_extscan(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308357 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008358 break;
8359 case WMA_EXTSCAN_STOP_REQ:
Jeff Johnson7272ea72018-07-15 17:22:27 -07008360 wma_stop_extscan(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308361 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008362 break;
8363 case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:
Jeff Johnson1148cb02018-07-13 23:14:32 -07008364 wma_extscan_start_hotlist_monitor(wma_handle, 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_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
Jeff Johnson9743eb72018-07-14 10:30:04 -07008368 wma_extscan_stop_hotlist_monitor(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308369 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008370 break;
8371 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
Jeff Johnsonb43ed032018-07-16 06:59:21 -07008372 wma_extscan_start_change_monitor(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308373 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008374 break;
8375 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
Jeff Johnson0c8dbc32018-07-16 22:10:48 -07008376 wma_extscan_stop_change_monitor(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308377 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008378 break;
8379 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
Jeff Johnson2ba60092018-07-17 08:19:37 -07008380 wma_extscan_get_cached_results(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308381 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008382 break;
8383 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
Jeff Johnsonfed9a732018-07-18 12:18:03 -07008384 wma_extscan_get_capabilities(wma_handle, 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_SET_EPNO_LIST_REQ:
Jeff Johnson360135b2018-07-18 20:51:47 -07008388 wma_set_epno_network_list(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308389 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008390 break;
Kapil Gupta5cda2252016-12-29 18:44:26 +05308391 case WMA_SET_PER_ROAM_CONFIG_CMD:
8392 wma_update_per_roam_config(wma_handle,
8393 (struct wmi_per_roam_config_req *)msg->bodyptr);
8394 qdf_mem_free(msg->bodyptr);
8395 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008396 case WMA_SET_PASSPOINT_LIST_REQ:
8397 /* Issue reset passpoint network list first and clear
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008398 * the entries
8399 */
Jeff Johnson2a7f1012018-07-19 07:21:06 -07008400 wma_reset_passpoint_network_list(wma_handle, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008401
Jeff Johnson2a7f1012018-07-19 07:21:06 -07008402 wma_set_passpoint_network_list(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308403 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008404 break;
8405 case WMA_RESET_PASSPOINT_LIST_REQ:
Jeff Johnson2a7f1012018-07-19 07:21:06 -07008406 wma_reset_passpoint_network_list(wma_handle, msg->bodyptr);
Pragaspathi Thilagarajf65cffe2018-06-15 14:20:26 +05308407 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008408 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008409#endif /* FEATURE_WLAN_EXTSCAN */
8410 case WMA_SET_SCAN_MAC_OUI_REQ:
8411 wma_scan_probe_setoui(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308412 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008413 break;
8414#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8415 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
8416 wma_process_ll_stats_clear_req(wma_handle,
8417 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308418 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008419 break;
8420 case WMA_LINK_LAYER_STATS_SET_REQ:
8421 wma_process_ll_stats_set_req(wma_handle,
8422 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308423 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008424 break;
8425 case WMA_LINK_LAYER_STATS_GET_REQ:
8426 wma_process_ll_stats_get_req(wma_handle,
8427 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308428 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008429 break;
Zhang Qian73c348a2017-03-13 16:15:55 +08008430 case WDA_LINK_LAYER_STATS_SET_THRESHOLD:
8431 wma_config_stats_ext_threshold(wma_handle,
8432 (struct sir_ll_ext_stats_threshold *)msg->bodyptr);
8433 qdf_mem_free(msg->bodyptr);
8434 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008435#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008436#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008437 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
8438 wma_process_roam_synch_fail(wma_handle,
8439 (struct roam_offload_synch_fail *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308440 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008441 break;
8442 case SIR_HAL_ROAM_INVOKE:
8443 wma_process_roam_invoke(wma_handle,
8444 (struct wma_roam_invoke_cmd *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308445 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446 break;
8447#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008448 case SIR_HAL_SET_BASE_MACADDR_IND:
8449 wma_set_base_macaddr_indicate(wma_handle,
8450 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308451 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008452 break;
8453 case WMA_LINK_STATUS_GET_REQ:
8454 wma_process_link_status_req(wma_handle,
8455 (tAniGetLinkStatus *) msg->bodyptr);
8456 break;
8457 case WMA_GET_TEMPERATURE_REQ:
8458 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308459 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008460 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07008461 case WMA_TSF_GPIO_PIN:
8462 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
8463 break;
8464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008465#ifdef DHCP_SERVER_OFFLOAD
8466 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
8467 wma_process_dhcpserver_offload(wma_handle,
8468 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308469 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008470 break;
8471#endif /* DHCP_SERVER_OFFLOAD */
8472#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8473 case WMA_LED_FLASHING_REQ:
Jeff Johnson5a6b6602017-10-04 14:44:30 -07008474 wma_set_led_flashing(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308475 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008476 break;
8477#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
8478 case SIR_HAL_SET_MAS:
8479 wma_process_set_mas(wma_handle,
8480 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308481 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008482 break;
8483 case SIR_HAL_SET_MIRACAST:
8484 wma_process_set_miracast(wma_handle,
8485 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308486 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008487 break;
8488 case SIR_HAL_CONFIG_STATS_FACTOR:
8489 wma_config_stats_factor(wma_handle,
8490 (struct sir_stats_avg_factor *)
8491 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308492 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008493 break;
8494 case SIR_HAL_CONFIG_GUARD_TIME:
8495 wma_config_guard_time(wma_handle,
8496 (struct sir_guard_time_request *)
8497 msg->bodyptr);
Vignesh Viswanathan9fa8fef2017-12-12 14:45:38 +05308498 qdf_mem_free(msg->bodyptr);
8499 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008500 case SIR_HAL_START_STOP_LOGGING:
8501 wma_set_wifi_start_packet_stats(wma_handle,
8502 (struct sir_wifi_start_log *)msg->bodyptr);
8503 wma_enable_specific_fw_logs(wma_handle,
8504 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308505 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008506 break;
8507 case SIR_HAL_FLUSH_LOG_TO_FW:
8508 wma_send_flush_logs_to_fw(wma_handle);
8509 /* Body ptr is NULL here */
8510 break;
8511 case WMA_SET_RSSI_MONITOR_REQ:
8512 wma_set_rssi_monitoring(wma_handle,
8513 (struct rssi_monitor_req *)msg->bodyptr);
Prakash Dhavali87ddca32016-11-29 17:02:11 -08008514 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008515 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308516 case SIR_HAL_PDEV_SET_PCL_TO_FW:
8517 wma_send_pdev_set_pcl_cmd(wma_handle,
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008518 (struct set_pcl_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308519 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008520 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308521 case SIR_HAL_PDEV_SET_HW_MODE:
8522 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008523 (struct policy_mgr_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308524 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008525 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07008526 case WMA_SET_WISA_PARAMS:
8527 wma_set_wisa_params(wma_handle,
8528 (struct sir_wisa_params *)msg->bodyptr);
8529 qdf_mem_free(msg->bodyptr);
8530 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308531 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
8532 wma_send_pdev_set_dual_mac_config(wma_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008533 (struct policy_mgr_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308534 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008535 break;
8536 case WMA_SET_IE_INFO:
8537 wma_process_set_ie_info(wma_handle,
8538 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308539 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008540 break;
Kiran Kumar Lokereee205772018-09-27 00:27:27 -07008541 case WMA_CFG_VENDOR_ACTION_TB_PPDU:
8542 wma_process_cfg_action_frm_tb_ppdu(wma_handle, msg->bodyptr);
8543 qdf_mem_free(msg->bodyptr);
8544 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008545 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
8546 wma_send_pdev_set_antenna_mode(wma_handle,
8547 (struct sir_antenna_mode_param *)msg->bodyptr);
8548 qdf_mem_free(msg->bodyptr);
8549 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008550 case WMA_LRO_CONFIG_CMD:
8551 wma_lro_config_cmd(wma_handle,
Dhanashri Atre09828f12016-11-13 10:36:58 -08008552 (struct cdp_lro_hash_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308553 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008554 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08008555 case WMA_GW_PARAM_UPDATE_REQ:
8556 wma_set_gateway_params(wma_handle,
8557 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08008558 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08008559 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05308560 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
8561 wma_send_adapt_dwelltime_params(wma_handle,
8562 (struct adaptive_dwelltime_params *)msg->bodyptr);
8563 qdf_mem_free(msg->bodyptr);
8564 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08008565 case WMA_HT40_OBSS_SCAN_IND:
8566 wma_send_ht40_obss_scanind(wma_handle,
8567 (struct obss_ht40_scanind *)msg->bodyptr);
8568 qdf_mem_free(msg->bodyptr);
8569 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07008570 case WMA_ADD_BCN_FILTER_CMDID:
8571 wma_add_beacon_filter(wma_handle, msg->bodyptr);
8572 qdf_mem_free(msg->bodyptr);
8573 break;
8574 case WMA_REMOVE_BCN_FILTER_CMDID:
8575 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
8576 qdf_mem_free(msg->bodyptr);
8577 break;
Nachiket Kukadee547a482018-05-22 16:43:30 +05308578 case WDA_APF_GET_CAPABILITIES_REQ:
8579 wma_get_apf_capabilities(wma_handle);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05308580 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05308581 case SIR_HAL_POWER_DBG_CMD:
8582 wma_process_hal_pwr_dbg_cmd(wma_handle,
8583 msg->bodyptr);
8584 qdf_mem_free(msg->bodyptr);
8585 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05308586 case WMA_UPDATE_WEP_DEFAULT_KEY:
8587 wma_update_wep_default_key(wma_handle,
8588 (struct wep_update_default_key_idx *)msg->bodyptr);
8589 qdf_mem_free(msg->bodyptr);
8590 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05308591 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
8592 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
8593 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05308594 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
8595 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
8596 qdf_mem_free(msg->bodyptr);
8597 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05308598 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
8599 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
8600 qdf_mem_free(msg->bodyptr);
8601 break;
8602 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
8603 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
8604 qdf_mem_free(msg->bodyptr);
8605 break;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05308606 case SIR_HAL_POWER_DEBUG_STATS_REQ:
8607 wma_process_power_debug_stats_req(wma_handle);
8608 break;
Arunk Khandavallica56d4b2018-11-29 15:46:00 +05308609 case WMA_BEACON_DEBUG_STATS_REQ:
8610 wma_process_beacon_debug_stats_req(wma_handle, msg->bodyptr);
8611 qdf_mem_free(msg->bodyptr);
8612 break;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05308613 case WMA_GET_RCPI_REQ:
8614 wma_get_rcpi_req(wma_handle,
8615 (struct sme_rcpi_req *)msg->bodyptr);
8616 qdf_mem_free(msg->bodyptr);
8617 break;
Yingying Tang95409972016-10-20 15:16:15 +08008618 case WMA_SET_WOW_PULSE_CMD:
8619 wma_send_wow_pulse_cmd(wma_handle,
8620 (struct wow_pulse_mode *)msg->bodyptr);
8621 qdf_mem_free(msg->bodyptr);
8622 break;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05308623 case WMA_SET_DBS_SCAN_SEL_CONF_PARAMS:
8624 wma_send_dbs_scan_selection_params(wma_handle,
8625 (struct wmi_dbs_scan_sel_params *)msg->bodyptr);
8626 qdf_mem_free(msg->bodyptr);
8627 break;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05308628 case WMA_SET_ARP_STATS_REQ:
8629 wma_set_arp_req_stats(wma_handle,
8630 (struct set_arp_stats_params *)msg->bodyptr);
8631 qdf_mem_free(msg->bodyptr);
8632 break;
8633 case WMA_GET_ARP_STATS_REQ:
8634 wma_get_arp_req_stats(wma_handle,
8635 (struct get_arp_stats_params *)msg->bodyptr);
8636 qdf_mem_free(msg->bodyptr);
8637 break;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308638 case SIR_HAL_SET_DEL_PMKID_CACHE:
Jeff Johnson622aad62018-12-07 15:05:37 -08008639 wma_set_del_pmkid_cache(wma_handle, msg->bodyptr);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308640 qdf_mem_free(msg->bodyptr);
8641 break;
8642 case SIR_HAL_HLP_IE_INFO:
8643 wma_roam_scan_send_hlp(wma_handle,
8644 (struct hlp_params *)msg->bodyptr);
8645 qdf_mem_free(msg->bodyptr);
8646 break;
Ganesh Kondabattini35739572017-06-21 16:26:39 +05308647 case WMA_SET_LIMIT_OFF_CHAN:
8648 wma_process_limit_off_chan(wma_handle, msg->bodyptr);
8649 qdf_mem_free(msg->bodyptr);
8650 break;
Arif Hussainee10f902017-12-27 16:30:17 -08008651 case WMA_OBSS_DETECTION_REQ:
8652 wma_send_obss_detection_cfg(wma_handle, msg->bodyptr);
8653 qdf_mem_free(msg->bodyptr);
8654 break;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05308655 case WMA_INVOKE_NEIGHBOR_REPORT:
8656 wma_send_invoke_neighbor_report(wma_handle, msg->bodyptr);
8657 qdf_mem_free(msg->bodyptr);
8658 break;
Arif Hussain05fb4872018-01-03 16:02:55 -08008659 case WMA_OBSS_COLOR_COLLISION_REQ:
8660 wma_process_obss_color_collision_req(wma_handle, msg->bodyptr);
8661 qdf_mem_free(msg->bodyptr);
8662 break;
Rajeev Kumar Sirasanagandla4f20b672018-03-12 13:52:50 +05308663 case WMA_GET_ROAM_SCAN_STATS:
8664 wma_get_roam_scan_stats(wma_handle, msg->bodyptr);
8665 qdf_mem_free(msg->bodyptr);
8666 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008667 default:
Sandeep Puligilla1f1e4002018-08-18 12:15:01 -07008668 WMA_LOGD("Unhandled WMA message of type %d", msg->type);
Dustin Brown86534fb2017-01-24 14:28:20 -08008669 if (msg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308670 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008671 }
8672end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308673 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008674}
8675
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008676QDF_STATUS wma_mc_process_handler(struct scheduler_msg *msg)
8677{
Jeff Johnson5be42ab2017-09-13 09:10:39 -07008678 return wma_mc_process_msg(msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008679}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008681/**
8682 * wma_log_completion_timeout() - Log completion timeout
8683 * @data: Timeout handler data
8684 *
8685 * This function is called when log completion timer expires
8686 *
8687 * Return: None
8688 */
8689void wma_log_completion_timeout(void *data)
8690{
8691 tp_wma_handle wma_handle;
8692
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05308693 WMA_LOGD("%s: Timeout occurred for log completion command", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008694
8695 wma_handle = (tp_wma_handle) data;
8696 if (!wma_handle)
8697 WMA_LOGE("%s: Invalid WMA handle", __func__);
8698
8699 /* Though we did not receive any event from FW,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008700 * we can flush whatever logs we have with us
8701 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008702 cds_logging_set_fw_flush_complete();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008703}
8704
8705/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308706 * wma_map_pcl_weights() - Map PCL weights
8707 * @pcl_weight: Internal PCL weights
8708 *
8709 * Maps the internal weights of PCL to the weights needed by FW
8710 *
8711 * Return: Mapped channel weight of type wmi_pcl_chan_weight
8712 */
8713static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
8714{
8715 switch (pcl_weight) {
8716 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
8717 return WMI_PCL_WEIGHT_VERY_HIGH;
8718 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
8719 return WMI_PCL_WEIGHT_HIGH;
8720 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
8721 return WMI_PCL_WEIGHT_MEDIUM;
8722 case WEIGHT_OF_NON_PCL_CHANNELS:
8723 return WMI_PCL_WEIGHT_LOW;
8724 default:
8725 return WMI_PCL_WEIGHT_DISALLOW;
8726 }
8727}
8728
8729/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308730 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008731 * @wma_handle: WMA handle
8732 * @msg: PCL structure containing the PCL and the number of channels
8733 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308734 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008735 * firmware. The DBS Manager is the consumer of this information in the WLAN
8736 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
8737 * to migrate to a new channel without host driver involvement. An example of
8738 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
8739 * manage the channel selection without firmware involvement.
8740 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308741 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
8742 * channel list. The weights corresponds to the channels sent in
8743 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
8744 * weightage compared to the non PCL channels.
8745 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008746 * Return: Success if the cmd is sent successfully to the firmware
8747 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308748QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008749 struct set_pcl_req *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008750{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308751 uint32_t i;
8752 QDF_STATUS status;
8753
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008754 if (!wma_handle) {
8755 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8756 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308757 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008758 }
8759
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308760 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008761 msg->chan_weights.saved_chan_list[i] =
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308762 wma_handle->saved_chan.channel_list[i];
8763 }
8764
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008765 msg->chan_weights.saved_num_chan = wma_handle->saved_chan.num_channels;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008766 status = policy_mgr_get_valid_chan_weights(wma_handle->psoc,
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008767 (struct policy_mgr_pcl_chan_weights *)&msg->chan_weights);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308768
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008769 for (i = 0; i < msg->chan_weights.saved_num_chan; i++) {
8770 msg->chan_weights.weighed_valid_list[i] =
8771 wma_map_pcl_weights(
8772 msg->chan_weights.weighed_valid_list[i]);
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008773 /* Dont allow roaming on 2G when 5G_ONLY configured */
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008774 if (((wma_handle->bandcapability == BAND_5G) ||
8775 (msg->band == BAND_5G)) &&
8776 (WLAN_REG_IS_24GHZ_CH(
8777 msg->chan_weights.saved_chan_list[i]))) {
8778 msg->chan_weights.weighed_valid_list[i] =
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008779 WEIGHT_OF_DISALLOWED_CHANNELS;
8780 }
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008781 if ((msg->band == BAND_2G) &&
8782 WLAN_REG_IS_5GHZ_CH(msg->chan_weights.saved_chan_list[i]))
8783 msg->chan_weights.weighed_valid_list[i] =
8784 WEIGHT_OF_DISALLOWED_CHANNELS;
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308785 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008786 msg->chan_weights.saved_chan_list[i], i,
8787 msg->chan_weights.weighed_valid_list[i]);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308788 }
8789
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308790 if (!QDF_IS_STATUS_SUCCESS(status)) {
8791 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
8792 return status;
8793 }
8794
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008795 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle,
8796 &msg->chan_weights))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308797 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05308798
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308799 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008800}
8801
8802/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308803 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008804 * @wma_handle: WMA handle
8805 * @msg: Structure containing the following parameters
8806 *
8807 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
8808 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
8809 *
8810 * Provides notification to the WLAN firmware that host driver is requesting a
8811 * HardWare (HW) Mode change. This command is needed to support iHelium in the
8812 * configurations that include the Dual Band Simultaneous (DBS) feature.
8813 *
8814 * Return: Success if the cmd is sent successfully to the firmware
8815 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308816QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008817 struct policy_mgr_hw_mode *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008818{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008819 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008820 struct wma_target_req *timeout_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008821
8822 if (!wma_handle) {
8823 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8824 __func__);
8825 /* Handle is NULL. Will not be able to send failure
8826 * response as well
8827 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308828 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008829 }
8830
8831 if (!msg) {
8832 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
8833 /* Lets try to free the active command list */
8834 goto fail;
8835 }
8836
Dustin Brownec2c92e2017-07-26 11:13:49 -07008837 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8838 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT);
Govind Singhf25a0f12016-03-08 16:09:48 +05308839 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008840 msg->hw_mode_index)) {
8841 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008842 goto fail;
Krunal Sonicebcc292017-06-14 19:59:20 -07008843 }
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008844 timeout_msg = wma_fill_hold_req(wma_handle, 0,
8845 SIR_HAL_PDEV_SET_HW_MODE,
8846 WMA_PDEV_SET_HW_MODE_RESP, NULL,
8847 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT - 1);
8848 if (!timeout_msg) {
8849 WMA_LOGE("Failed to allocate request for SIR_HAL_PDEV_SET_HW_MODE");
8850 wma_remove_req(wma_handle, 0, WMA_PDEV_SET_HW_MODE_RESP);
8851 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008852
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308853 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008854fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308855 param = qdf_mem_malloc(sizeof(*param));
Arif Hussain157263f2018-10-03 13:07:15 -07008856 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308857 return QDF_STATUS_E_NULL_VALUE;
Arif Hussain157263f2018-10-03 13:07:15 -07008858
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008859 param->status = SET_HW_MODE_STATUS_ECANCELED;
8860 param->cfgd_hw_mode_index = 0;
8861 param->num_vdev_mac_entries = 0;
8862 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308863 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008864 (void *) param, 0);
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308865 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008866}
8867
8868/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308869 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870 * @wma_handle: WMA handle
8871 * @msg: Dual MAC config parameters
8872 *
8873 * Configures WLAN firmware with the dual MAC features
8874 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308875 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008876 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308877QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008878 struct policy_mgr_dual_mac_config *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008879{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308880 QDF_STATUS status;
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308881 struct wma_target_req *req_msg;
8882 struct sir_dual_mac_config_resp *resp;
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008884 if (!wma_handle) {
8885 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8886 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308887 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008888 }
8889
8890 if (!msg) {
8891 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308892 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008893 }
8894
Krunal Sonia5ccb802017-07-03 12:59:40 -07008895 /*
8896 * aquire the wake lock here and release it in response handler function
8897 * In error condition, release the wake lock right away
8898 */
8899 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8900 WMA_VDEV_PLCY_MGR_CMD_TIMEOUT);
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308901 status = wmi_unified_pdev_set_dual_mac_config_cmd(
8902 wma_handle->wmi_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008903 (struct policy_mgr_dual_mac_config *)msg);
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308904 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308905 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308906 __func__, status);
Krunal Sonia5ccb802017-07-03 12:59:40 -07008907 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308908 goto fail;
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308909 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008910 policy_mgr_update_dbs_req_config(wma_handle->psoc,
8911 msg->scan_config, msg->fw_mode_config);
Govind Singhf25a0f12016-03-08 16:09:48 +05308912
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308913 req_msg = wma_fill_hold_req(wma_handle, 0,
8914 SIR_HAL_PDEV_DUAL_MAC_CFG_REQ,
8915 WMA_PDEV_MAC_CFG_RESP, NULL,
8916 WMA_VDEV_DUAL_MAC_CFG_TIMEOUT);
8917 if (!req_msg) {
8918 WMA_LOGE("Failed to allocate request for SIR_HAL_PDEV_DUAL_MAC_CFG_REQ");
8919 wma_remove_req(wma_handle, 0, WMA_PDEV_MAC_CFG_RESP);
8920 }
8921
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308922 return QDF_STATUS_SUCCESS;
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308923
8924fail:
8925 resp = qdf_mem_malloc(sizeof(*resp));
8926 if (!resp)
8927 return QDF_STATUS_E_NULL_VALUE;
8928
8929 resp->status = SET_HW_MODE_STATUS_ECANCELED;
8930 WMA_LOGE("%s: Sending failure response to LIM", __func__);
8931 wma_send_msg(wma_handle, SIR_HAL_PDEV_MAC_CFG_RESP, (void *) resp, 0);
8932 return QDF_STATUS_E_FAILURE;
8933
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008934}
8935
8936/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008937 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
8938 * @wma_handle: WMA handle
8939 * @msg: Antenna mode parameters
8940 *
8941 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
8942 * modify the number of TX/RX chains from host
8943 *
8944 * Return: QDF_STATUS. 0 on success.
8945 */
8946QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
8947 struct sir_antenna_mode_param *msg)
8948{
8949 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
8950 wmi_buf_t buf;
8951 uint32_t len;
8952 QDF_STATUS status = QDF_STATUS_SUCCESS;
8953 struct sir_antenna_mode_resp *param;
8954
8955 if (!wma_handle) {
8956 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8957 __func__);
8958 return QDF_STATUS_E_NULL_VALUE;
8959 }
8960
8961 if (!msg) {
8962 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
8963 return QDF_STATUS_E_NULL_VALUE;
8964 }
8965
8966 len = sizeof(*cmd);
8967
8968 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
8969 if (!buf) {
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008970 status = QDF_STATUS_E_NOMEM;
8971 goto resp;
8972 }
8973
8974 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
8975 WMITLV_SET_HDR(&cmd->tlv_header,
8976 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
8977 WMITLV_GET_STRUCT_TLVLEN(
8978 wmi_pdev_set_antenna_mode_cmd_fixed_param));
8979
8980 cmd->pdev_id = WMI_PDEV_ID_SOC;
8981 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
8982 cmd->num_txrx_chains = msg->num_rx_chains;
8983 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
8984
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07008985 WMA_LOGD("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008986 __func__, msg->num_tx_chains,
8987 msg->num_rx_chains, cmd->num_txrx_chains);
8988
8989 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
8990 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008991 wmi_buf_free(buf);
8992 status = QDF_STATUS_E_FAILURE;
8993 goto resp;
8994 }
8995 status = QDF_STATUS_SUCCESS;
8996
8997resp:
8998 param = qdf_mem_malloc(sizeof(*param));
Arif Hussain157263f2018-10-03 13:07:15 -07008999 if (!param)
Archana Ramachandrana20ef812015-11-13 16:12:13 -08009000 return QDF_STATUS_E_NOMEM;
Arif Hussain157263f2018-10-03 13:07:15 -07009001
Archana Ramachandrana20ef812015-11-13 16:12:13 -08009002 param->status = (status) ?
9003 SET_ANTENNA_MODE_STATUS_ECANCELED :
9004 SET_ANTENNA_MODE_STATUS_OK;
9005 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
9006 __func__, param->status);
9007 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
9008 (void *) param, 0);
9009 return status;
9010}
9011
9012/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009013 * wma_crash_inject() - sends command to FW to simulate crash
9014 * @wma_handle: pointer of WMA context
9015 * @type: subtype of the command
9016 * @delay_time_ms: time in milliseconds for FW to delay the crash
9017 *
9018 * This function will send a command to FW in order to simulate different
9019 * kinds of FW crashes.
9020 *
Govind Singhd76a5b02016-03-08 15:12:14 +05309021 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009022 */
Yu Wang46082dc2017-09-19 12:25:38 +08009023QDF_STATUS wma_crash_inject(WMA_HANDLE wma_handle, uint32_t type,
9024 uint32_t delay_time_ms)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009025{
Govind Singhd76a5b02016-03-08 15:12:14 +05309026 struct crash_inject param;
Yu Wang46082dc2017-09-19 12:25:38 +08009027 tp_wma_handle wma = (tp_wma_handle)wma_handle;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07009028
Govind Singhd76a5b02016-03-08 15:12:14 +05309029 param.type = type;
9030 param.delay_time_ms = delay_time_ms;
Yu Wang46082dc2017-09-19 12:25:38 +08009031 return wmi_crash_inject(wma->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009032}
Govind Singhd76a5b02016-03-08 15:12:14 +05309033
Manjunathappa Prakash7b0ad462018-04-15 00:37:16 -07009034#ifdef RECEIVE_OFFLOAD
Dhanashri Atre09828f12016-11-13 10:36:58 -08009035int wma_lro_init(struct cdp_lro_hash_config *lro_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009036{
Rajeev Kumarb60abe42017-01-21 15:39:31 -08009037 struct scheduler_msg msg = {0};
Dhanashri Atre09828f12016-11-13 10:36:58 -08009038 struct cdp_lro_hash_config *iwcmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009039
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309040 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Arif Hussain157263f2018-10-03 13:07:15 -07009041 if (!iwcmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009042 return -ENOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009043
9044 *iwcmd = *lro_config;
9045
9046 msg.type = WMA_LRO_CONFIG_CMD;
9047 msg.reserved = 0;
9048 msg.bodyptr = iwcmd;
9049
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309050 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia00861f02018-08-28 19:16:12 +05309051 scheduler_post_message(QDF_MODULE_ID_WMA,
9052 QDF_MODULE_ID_WMA,
9053 QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009054 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309055 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009056 return -EAGAIN;
9057 }
9058
9059 WMA_LOGD("sending the LRO configuration to the fw");
9060 return 0;
9061}
9062#endif
Leo Chang96464902016-10-28 11:10:54 -07009063
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +05309064QDF_STATUS wma_configure_smps_params(uint32_t vdev_id, uint32_t param_id,
9065 uint32_t param_val)
9066{
9067 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
9068 int smps_cmd_value;
9069 int status = QDF_STATUS_E_INVAL;
9070
9071 if (!wma) {
9072 WMA_LOGE("%s: Failed to get wma", __func__);
9073 return status;
9074 }
9075
9076 smps_cmd_value = param_id << WMI_SMPS_PARAM_VALUE_S;
9077 smps_cmd_value = smps_cmd_value | param_val;
9078
9079 status = wma_set_smps_params(wma, vdev_id, smps_cmd_value);
9080 if (status)
9081 WMA_LOGE("Failed to set SMPS Param");
9082
9083 return status;
9084}
9085
Leo Chang96464902016-10-28 11:10:54 -07009086
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +05309087/**
9088 * wma_config_bmiss_bcnt_params() - set bmiss config parameters
9089 * @vdev_id: virtual device for the command
9090 * @first_cnt: bmiss first value
9091 * @final_cnt: bmiss final value
9092 *
9093 * Return: QDF_STATUS_SUCCESS or non-zero on failure
9094 */
9095QDF_STATUS wma_config_bmiss_bcnt_params(uint32_t vdev_id, uint32_t first_cnt,
9096 uint32_t final_cnt)
9097{
9098 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
9099 int status = QDF_STATUS_E_INVAL;
9100
9101 if (!wma_handle) {
9102 WMA_LOGE("%s: Failed to get wma", __func__);
9103 return status;
9104 }
9105
9106 status = wma_roam_scan_bmiss_cnt(wma_handle, first_cnt, final_cnt,
9107 vdev_id);
9108
9109 if (status)
9110 WMA_LOGE("Failed to set Bmiss Param");
9111
9112 return status;
9113}
9114