blob: 9fb8ab847f4b0c478848cefce2f450cd27466904 [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);
Nachiket Kukadee547a482018-05-22 16:43:30 +05303320 wma_handle->active_uc_apf_mode = cds_cfg->active_uc_apf_mode;
3321 wma_handle->active_mc_bc_apf_mode = cds_cfg->active_mc_bc_apf_mode;
Srinivas Girigowda57b450e2016-10-27 21:00:46 -07003322 wma_handle->link_stats_results = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303324 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
3325 wma_handle->RArateLimitInterval = cds_cfg->ra_ratelimit_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326#endif /* FEATURE_WLAN_RA_FILTERING */
3327#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303328 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303330 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331 wma_handle->max_bssid);
3332 if (!wma_handle->interfaces) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303333 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 goto err_scn_context;
3335 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003336
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003337 for (i = 0; i < wma_handle->max_bssid; ++i) {
Dustin Brownec2c92e2017-07-26 11:13:49 -07003338 wma_vdev_init(&wma_handle->interfaces[i]);
Wu Gao51a63562018-11-08 16:29:10 +08003339 ucfg_mlme_get_delay_before_vdev_stop(wma_handle->psoc,
3340 &delay_before_vdev_stop);
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003341 wma_handle->interfaces[i].delay_before_vdev_stop =
Wu Gao51a63562018-11-08 16:29:10 +08003342 delay_before_vdev_stop;
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003343 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 /* Register the debug print event handler */
3345 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303346 wmi_debug_print_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303347 wma_unified_debug_print_event_handler,
3348 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05303349 /* Register profiling event Handler */
3350 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303351 wmi_wlan_profile_data_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303352 wma_profile_data_report_event_handler,
3353 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354
3355 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
3357 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05303358 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07003359 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360
Anurag Chouhan210db072016-02-22 18:42:15 +05303361 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303362 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303363 wma_service_ready_ext_evt_timeout,
3364 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303365 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303366 WMA_LOGE("Failed to initialize service ready ext timeout");
3367 goto err_event_init;
3368 }
3369
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303370 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303371 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003372 WMA_LOGE("%s: target suspend event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373 __func__);
3374 goto err_event_init;
3375 }
3376
3377 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303378 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
3379 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003380 WMA_LOGE("%s: failed to init tx_frm_download_comp_event",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 __func__);
3382 goto err_event_init;
3383 }
3384
3385 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303386 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
3387 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003388 WMA_LOGE("%s: failed to init tx_queue_empty_event", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 goto err_event_init;
3390 }
3391
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003392 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
3393 wma_handle);
3394 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003395 WMA_LOGE("%s: Shutdown notifier register failed: %d",
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003396 __func__, qdf_status);
3397 goto err_event_init;
3398 }
3399
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303400 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303401 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003402 WMA_LOGE("%s: runtime_suspend event initialization failed",
Houston Hoffmana76591b2015-11-10 16:52:05 -08003403 __func__);
3404 goto err_event_init;
3405 }
3406
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303407 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303408 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003409 WMA_LOGE("%s: recovery event initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 goto err_event_init;
3411 }
3412
Anurag Chouhanffb21542016-02-17 14:33:03 +05303413 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003414 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303415 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303416 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303418 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05303419 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420
3421 /* Register vdev start response event handler */
3422 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303423 wmi_vdev_start_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303424 wma_vdev_start_resp_handler,
3425 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426
3427 /* Register vdev stop response event handler */
3428 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303429 wmi_vdev_stopped_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303430 wma_vdev_stop_resp_handler,
3431 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432
3433 /* register for STA kickout function */
3434 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303435 wmi_peer_sta_kickout_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303436 wma_peer_sta_kickout_event_handler,
3437 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438
Naveen Rawate8b1b822018-01-30 09:46:16 -08003439 /* register for stats event */
3440 wma_register_stats_events(wma_handle->wmi_handle);
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303441
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303442 /* register for stats response event */
3443 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303444 wmi_get_arp_stats_req_id,
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303445 wma_get_arp_stats_handler,
3446 WMA_RX_SERIALIZER_CTX);
3447
Will Huanga9814592017-05-24 15:47:58 +08003448 /* register for peer info response event */
3449 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303450 wmi_peer_stats_info_event_id,
Will Huanga9814592017-05-24 15:47:58 +08003451 wma_peer_info_event_handler,
3452 WMA_RX_SERIALIZER_CTX);
3453
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303454#ifdef WLAN_POWER_DEBUGFS
3455 /* register for Chip Power stats event */
3456 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303457 wmi_pdev_chip_power_stats_event_id,
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303458 wma_unified_power_debug_stats_event_handler,
3459 WMA_RX_SERIALIZER_CTX);
3460#endif
Arunk Khandavallica56d4b2018-11-29 15:46:00 +05303461#ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
3462 /* register for beacon stats event */
3463 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3464 wmi_vdev_bcn_reception_stats_event_id,
3465 wma_unified_beacon_debug_stats_event_handler,
3466 WMA_RX_SERIALIZER_CTX);
3467#endif
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303468
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 /* register for linkspeed response event */
3470 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303471 wmi_peer_estimated_linkspeed_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303472 wma_link_speed_event_handler,
3473 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474
3475#ifdef FEATURE_OEM_DATA_SUPPORT
3476 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303477 wmi_oem_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303478 wma_oem_data_response_handler,
3479 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480#endif /* FEATURE_OEM_DATA_SUPPORT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481
3482 /* Register peer change event handler */
3483 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303484 wmi_peer_state_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303485 wma_peer_state_change_event_handler,
3486 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487
3488 /* Register beacon tx complete event id. The event is required
3489 * for sending channel switch announcement frames
3490 */
3491 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303492 wmi_offload_bcn_tx_status_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303493 wma_unified_bcntx_status_event_handler,
3494 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495
3496 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303497 wmi_update_vdev_rate_stats_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303498 wma_link_status_event_handler,
3499 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar Sirasanagandla4f20b672018-03-12 13:52:50 +05303500
3501 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3502 wmi_roam_scan_stats_event_id,
3503 wma_roam_scan_stats_event_handler,
3504 WMA_RX_SERIALIZER_CTX);
3505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506#ifdef WLAN_FEATURE_LINK_LAYER_STATS
3507 /* Register event handler for processing Link Layer Stats
3508 * response from the FW
3509 */
3510 wma_register_ll_stats_event_handler(wma_handle);
3511
3512#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
3513
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +05303514 wmi_set_tgt_assert(wma_handle->wmi_handle,
3515 cds_cfg->force_target_assert_enabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303517 qdf_status = dbglog_init(wma_handle->wmi_handle);
3518 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003519 WMA_LOGE("%s: Firmware Dbglog initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 goto err_dbglog_init;
3521 }
3522
3523 /*
3524 * Update Powersave mode
3525 * 1 - Legacy Powersave + Deepsleep Disabled
3526 * 2 - QPower + Deepsleep Disabled
3527 * 3 - Legacy Powersave + Deepsleep Enabled
3528 * 4 - QPower + Deepsleep Enabled
3529 */
Wu Gao66454f12018-09-26 19:55:41 +08003530 wma_handle->powersave_mode =
3531 ucfg_pmo_power_save_offload_enabled(wma_handle->psoc);
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303532 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
Wu Gao66454f12018-09-26 19:55:41 +08003533 wma_handle->staModDtim = ucfg_pmo_get_sta_mod_dtim(wma_handle->psoc);
3534 wma_handle->staDynamicDtim =
3535 ucfg_pmo_get_sta_dynamic_dtim(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536
3537 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303538 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539 * 0 - Disable both magic pattern match and pattern byte match.
3540 * 1 - Enable magic pattern match on all interfaces.
3541 * 2 - Enable pattern byte match on all interfaces.
3542 * 3 - Enable both magic patter and pattern byte match on
3543 * all interfaces.
3544 */
Wu Gao66454f12018-09-26 19:55:41 +08003545 wow_enable = ucfg_pmo_get_wow_enable(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 wma_handle->wow.magic_ptrn_enable =
Wu Gao66454f12018-09-26 19:55:41 +08003547 (wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548 wma_handle->ptrn_match_enable_all_vdev =
Wu Gao66454f12018-09-26 19:55:41 +08003549 (wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 /* register for install key completion event */
3552 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303553 wmi_vdev_install_key_complete_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303554 wma_vdev_install_key_complete_event_handler,
3555 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556
3557#ifdef WLAN_FEATURE_STATS_EXT
3558 /* register for extended stats event */
3559 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303560 wmi_stats_ext_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303561 wma_stats_ext_event_handler,
3562 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563#endif /* WLAN_FEATURE_STATS_EXT */
3564#ifdef FEATURE_WLAN_EXTSCAN
3565 wma_register_extscan_event_handler(wma_handle);
3566#endif /* WLAN_FEATURE_STATS_EXT */
3567
3568 WMA_LOGD("%s: Exit", __func__);
3569
3570#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3571 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303572 wmi_roam_synch_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303573 wma_roam_synch_event_handler,
3574 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303575 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303576 wmi_roam_synch_frame_event_id,
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303577 wma_roam_synch_frame_event_handler,
3578 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3580 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303581 wmi_rssi_breach_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303582 wma_rssi_breached_event_handler,
3583 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303585 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05303586 "wlan_fw_rsp_wakelock");
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003587 qdf_runtime_lock_init(&wma_handle->wmi_cmd_rsp_runtime_lock);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003588
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 /* Register peer assoc conf event handler */
3590 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303591 wmi_peer_assoc_conf_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303592 wma_peer_assoc_conf_handler,
3593 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003594 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303595 wmi_vdev_delete_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303596 wma_vdev_delete_handler,
3597 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003598 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303599 wmi_peer_delete_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303600 wma_peer_delete_handler,
3601 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05303602 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303603 wmi_chan_info_event_id,
Kapil Gupta4f0c0c12017-02-07 15:21:15 +05303604 wma_chan_info_event_handler,
3605 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003606 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303607 wmi_dbg_mesg_flush_complete_event_id,
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003608 wma_flush_complete_evt_handler,
Rajeev Kumarc3032b82017-02-14 15:56:01 -08003609 WMA_RX_WORK_CTX);
lifeng66831662017-05-19 16:01:35 +08003610 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303611 wmi_report_rx_aggr_failure_event_id,
lifeng66831662017-05-19 16:01:35 +08003612 wma_rx_aggr_failure_event_handler,
3613 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003614
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303615 wma_handle->ito_repeat_count = cds_cfg->ito_repeat_count;
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07003616 wma_handle->bandcapability = cds_cfg->bandcapability;
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303617
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303618 /* Register PWR_SAVE_FAIL event only in case of recovery(1) */
Wu Gao66454f12018-09-26 19:55:41 +08003619 if (ucfg_pmo_get_auto_power_fail_mode(wma_handle->psoc) ==
Hanumanth Reddy Pothulaab395952017-09-05 19:12:26 +05303620 PMO_FW_TO_SEND_WOW_IND_ON_PWR_FAILURE) {
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303621 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303622 wmi_pdev_chip_pwr_save_failure_detect_event_id,
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303623 wma_chip_power_save_failure_detected_handler,
3624 WMA_RX_WORK_CTX);
3625 }
3626
lifengd217d192017-05-09 19:44:16 +08003627 wmi_unified_register_event_handler(wma_handle->wmi_handle,
lifengfe6c3e22018-04-03 12:10:04 +08003628 wmi_pdev_div_rssi_antid_event_id,
3629 wma_pdev_div_info_evt_handler,
lifengd217d192017-05-09 19:44:16 +08003630 WMA_RX_WORK_CTX);
3631
Frank Liu65b17d92016-11-23 15:58:44 +08003632
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303633 wma_register_debug_callback();
Ashish Kumar Dhanotiyacd311c82018-09-14 10:55:10 +05303634 wifi_pos_register_get_phy_mode_cb(wma_handle->psoc,
3635 wma_get_phy_mode_cb);
3636
Mukul Sharma6411bb82017-03-01 15:57:07 +05303637 /* Register callback with PMO so PMO can update the vdev pause bitmap*/
3638 pmo_register_pause_bitmap_notifier(wma_handle->psoc,
3639 wma_vdev_update_pause_bitmap);
3640 pmo_register_get_pause_bitmap(wma_handle->psoc,
3641 wma_vdev_get_pause_bitmap);
Will Huangad015772018-06-15 11:27:50 +08003642 pmo_register_get_vdev_dp_handle(wma_handle->psoc,
3643 wma_vdev_get_vdev_dp_handle);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303644 pmo_register_is_device_in_low_pwr_mode(wma_handle->psoc,
3645 wma_vdev_is_device_in_low_pwr_mode);
Mukul Sharma44746042018-05-24 17:30:52 +05303646 pmo_register_get_cfg_int_callback(wma_handle->psoc,
3647 wma_vdev_get_cfg_int);
Nachiket Kukade37b4e6d2018-06-01 18:44:42 +05303648 pmo_register_get_dtim_period_callback(wma_handle->psoc,
3649 wma_vdev_get_dtim_period);
3650 pmo_register_get_beacon_interval_callback(wma_handle->psoc,
3651 wma_vdev_get_beacon_interval);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003652 wma_cbacks.wma_get_connection_info = wma_get_connection_info;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003653 qdf_status = policy_mgr_register_wma_cb(wma_handle->psoc, &wma_cbacks);
3654 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
3655 WMA_LOGE("Failed to register wma cb with Policy Manager");
3656 }
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303657
Arif Hussainf63f7a32017-08-22 12:49:42 -07003658 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303659 wmi_phyerr_event_id,
Arif Hussainf63f7a32017-08-22 12:49:42 -07003660 wma_unified_phyerr_rx_event_handler,
3661 WMA_RX_WORK_CTX);
3662
Arif Hussainee10f902017-12-27 16:30:17 -08003663 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3664 wmi_sap_obss_detection_report_event_id,
3665 wma_vdev_obss_detection_info_handler,
3666 WMA_RX_SERIALIZER_CTX);
3667
Arif Hussain05fb4872018-01-03 16:02:55 -08003668 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3669 wmi_obss_color_collision_report_event_id,
3670 wma_vdev_bss_color_collision_info_handler,
3671 WMA_RX_WORK_CTX);
3672
Varun Reddy Yeturud33033f2018-06-11 10:58:30 -07003673#ifdef WLAN_SUPPORT_TWT
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -07003674 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3675 wmi_twt_enable_complete_event_id,
3676 wma_twt_en_complete_event_handler,
3677 WMA_RX_SERIALIZER_CTX);
3678#endif
3679
Nachiket Kukade177b5b02018-05-22 20:52:17 +05303680 wma_register_apf_events(wma_handle);
Arif Hussain05fb4872018-01-03 16:02:55 -08003681
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303682 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683
3684err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303685 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003686 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303687 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
3688 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689err_event_init:
3690 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303691 wmi_debug_print_event_id);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003692
3693 for (i = 0; i < wma_handle->max_bssid; ++i)
3694 wma_vdev_deinit(&wma_handle->interfaces[i]);
3695
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303696 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698err_scn_context:
Jeff Johnson2b6982c2018-05-29 14:56:11 -07003699 qdf_mem_free(((struct cds_context *) cds_context)->cfg_ctx);
Rajeev Kumarfe6e62f2018-10-22 16:18:41 -07003700 ((struct cds_context *)cds_context)->cfg_ctx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 OS_FREE(wmi_handle);
3702
3703err_wma_handle:
Zhu Jianminf9e2e2d2018-05-30 16:20:24 +08003704 wlan_objmgr_psoc_release_ref(psoc, WLAN_LEGACY_WMA_ID);
3705err_get_psoc_ref:
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303706 target_if_free_psoc_tgt_info(psoc);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303707 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303709 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303711 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05303712 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
3713 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
3714 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
3715 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
3716 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
3717 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
3718 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303720err_free_wma_handle:
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003721 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722
3723 WMA_LOGD("%s: Exit", __func__);
3724
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303725 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726}
3727
3728/**
3729 * wma_pre_start() - wma pre start
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730 *
3731 * Return: 0 on success, errno on failure
3732 */
Jeff Johnson8ad89c62017-09-13 08:55:55 -07003733QDF_STATUS wma_pre_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303735 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736 tp_wma_handle wma_handle;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08003737 struct scheduler_msg wma_msg = { 0 };
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303738 void *htc_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739
3740 WMA_LOGD("%s: Enter", __func__);
3741
Anurag Chouhan6d760662016-02-20 16:05:43 +05303742 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743
3744 /* Validate the wma_handle */
3745 if (NULL == wma_handle) {
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303746 WMA_LOGE("%s: invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303747 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748 goto end;
3749 }
Nachiket Kukade8003d252017-03-30 15:55:58 +05303750
Sourav Mohapatracf632572018-04-02 11:01:35 +05303751 htc_handle = lmac_get_htc_hdl(wma_handle->psoc);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303752 if (!htc_handle) {
3753 WMA_LOGE("%s: invalid htc handle", __func__);
3754 qdf_status = QDF_STATUS_E_INVAL;
3755 goto end;
3756 }
3757
3758 /* Open endpoint for ctrl path - WMI <--> HTC */
3759 qdf_status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
3760 htc_handle);
3761 if (qdf_status != QDF_STATUS_SUCCESS) {
3762 WMA_LOGE("%s: wmi_unified_connect_htc_service", __func__);
Nachiket Kukade8003d252017-03-30 15:55:58 +05303763 if (!cds_is_fw_down())
3764 QDF_BUG(0);
3765
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303766 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767 goto end;
3768 }
3769
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08003770 WMA_LOGD("WMA --> wmi_unified_connect_htc_service - success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771
3772 /* Trigger the CFG DOWNLOAD */
3773 wma_msg.type = WNI_CFG_DNLD_REQ;
3774 wma_msg.bodyptr = NULL;
3775 wma_msg.bodyval = 0;
3776
gaurank kathpalia00861f02018-08-28 19:16:12 +05303777 qdf_status = scheduler_post_message(QDF_MODULE_ID_WMA,
3778 QDF_MODULE_ID_WMA,
3779 QDF_MODULE_ID_WMA, &wma_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303780 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003781 WMA_LOGE("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303782 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303783 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784 }
3785end:
3786 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303787 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788}
3789
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303790void wma_send_msg_by_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3791 void *body_ptr, uint32_t body_val, bool is_high_priority)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792{
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303793 struct scheduler_msg msg = {0};
3794 QDF_STATUS status;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796 msg.type = msg_type;
3797 msg.bodyval = body_val;
3798 msg.bodyptr = body_ptr;
Will Huang9323e852018-02-02 17:55:15 +08003799 msg.flush_callback = wma_discard_fw_event;
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303800
3801 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE,
3802 &msg, is_high_priority);
3803 if (!QDF_IS_STATUS_SUCCESS(status)) {
3804 WMA_LOGE("Failed to post msg %d to PE", msg_type);
3805 if (body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303806 qdf_mem_free(body_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808}
3809
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303810
3811void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
3812 void *body_ptr, uint32_t body_val)
3813{
3814 wma_send_msg_by_priority(wma_handle, msg_type,
3815 body_ptr, body_val, false);
3816}
3817
3818void wma_send_msg_high_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3819 void *body_ptr, uint32_t body_val)
3820{
3821 wma_send_msg_by_priority(wma_handle, msg_type,
3822 body_ptr, body_val, true);
3823}
3824
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825/**
3826 * wma_set_base_macaddr_indicate() - set base mac address in fw
3827 * @wma_handle: wma handle
3828 * @customAddr: base mac address
3829 *
3830 * Return: 0 for success or error code
3831 */
3832static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
3833 tSirMacAddr *customAddr)
3834{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835 int err;
3836
Govind Singhf25a0f12016-03-08 16:09:48 +05303837 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
3838 (uint8_t *)customAddr);
3839 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
3842 MAC_ADDR_ARRAY((*customAddr)));
3843
3844 return 0;
3845}
3846
3847/**
3848 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
3849 * @handle: WMA handle
3850 * @event: Event received from FW
3851 * @len: Length of the event
3852 *
3853 * Enables the low frequency events and disables the high frequency
3854 * events. Bit 17 indicates if the event if low/high frequency.
3855 * 1 - high frequency, 0 - low frequency
3856 *
3857 * Return: 0 on successfully enabling/disabling the events
3858 */
3859static int wma_log_supported_evt_handler(void *handle,
3860 uint8_t *event,
3861 uint32_t len)
3862{
3863 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864
Govind Singhf25a0f12016-03-08 16:09:48 +05303865 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
3866 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868
3869 return 0;
3870}
3871
3872/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303873 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 * @handle: WMI handle
3875 * @event: Event recevied from FW
3876 * @len: Length of the event
3877 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303878 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
3879 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
3880 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 *
Dustin Brownec2c92e2017-07-26 11:13:49 -07003882 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303884static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 uint8_t *event,
3886 uint32_t len)
3887{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303888 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
3889 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
3890 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891 uint32_t i;
3892 struct sir_set_hw_mode_resp *hw_mode_resp;
3893 tp_wma_handle wma = (tp_wma_handle) handle;
3894
3895 if (!wma) {
3896 WMA_LOGE("%s: Invalid WMA handle", __func__);
3897 /* Since WMA handle itself is NULL, we cannot send fail
3898 * response back to LIM here
3899 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303900 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003902
3903 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -08003904 wma_remove_req(wma, 0, WMA_PDEV_SET_HW_MODE_RESP);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003905
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303906 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907 if (!hw_mode_resp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 /* Since this memory allocation itself failed, we cannot
3909 * send fail response back to LIM here
3910 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303911 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 }
3913
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303914 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303916 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 /* Need to send response back to upper layer to free
3918 * active command list
3919 */
3920 goto fail;
3921 }
Krunal Soni50a05542017-10-03 19:39:48 -07003922 if (param_buf->fixed_param->num_vdev_mac_entries >=
3923 MAX_VDEV_SUPPORTED) {
3924 WMA_LOGE("num_vdev_mac_entries crossed max value");
3925 goto fail;
3926 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927
3928 wmi_event = param_buf->fixed_param;
Abhinav Kumara03659c2017-12-28 15:18:07 +05303929 if (wmi_event->num_vdev_mac_entries >
3930 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
3931 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
3932 wmi_event->num_vdev_mac_entries);
3933 goto fail;
3934 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003935 hw_mode_resp->status = wmi_event->status;
3936 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3937 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
3938
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003939 WMA_LOGD("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 __func__, wmi_event->status,
3941 wmi_event->cfgd_hw_mode_index,
3942 wmi_event->num_vdev_mac_entries);
3943 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303944 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945
3946 /* Store the vdev-mac map in WMA and prepare to send to PE */
3947 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303948 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303951 pdev_id = vdev_mac_entry[i].pdev_id;
3952 if (pdev_id == WMI_PDEV_ID_SOC) {
3953 WMA_LOGE("%s: soc level id received for mac id)",
Tushnim Bhattacharyyac23d56c2018-10-05 14:11:43 -07003954 __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303955 goto fail;
3956 }
Pragaspathi Thilagaraj0092b672018-05-23 17:08:45 +05303957 if (vdev_id >= wma->max_bssid) {
3958 WMA_LOGE("%s: vdev_id: %d is invalid, max_bssid: %d",
3959 __func__, vdev_id, wma->max_bssid);
3960 goto fail;
3961 }
3962
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303963 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003965 WMA_LOGD("%s: vdev_id:%d mac_id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003966 __func__, vdev_id, mac_id);
3967
3968 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
3969 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
3970 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3971 wmi_event->cfgd_hw_mode_index);
3972 }
3973
3974 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
3975 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
3976 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3977 } else {
3978 wma->old_hw_mode_index = wma->new_hw_mode_index;
3979 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3980 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003981 policy_mgr_update_hw_mode_index(wma->psoc,
3982 wmi_event->cfgd_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 }
3984
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003985 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3987
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303988 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 (void *) hw_mode_resp, 0);
3990
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303991 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992
3993fail:
3994 WMA_LOGE("%s: Sending fail response to LIM", __func__);
3995 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
3996 hw_mode_resp->cfgd_hw_mode_index = 0;
3997 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303998 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 (void *) hw_mode_resp, 0);
4000
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304001 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002}
4003
4004/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004005 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
4006 *
4007 * @handle: WMA handle
4008 * @fixed_param: Event fixed parameters
4009 * @vdev_mac_entry - vdev mac entry
4010 * @hw_mode_trans_ind - Buffer to store parsed information
4011 *
4012 * Parses fixed_param, vdev_mac_entry and fills in the information into
4013 * hw_mode_trans_ind and wma
4014 *
4015 * Return: None
4016 */
4017void wma_process_pdev_hw_mode_trans_ind(void *handle,
4018 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
4019 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
4020 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
4021{
4022 uint32_t i;
4023 tp_wma_handle wma = (tp_wma_handle) handle;
Harprit Chhabada3cfca962018-12-04 13:41:31 -08004024
gaurank kathpaliad2967a72018-05-01 12:35:14 +05304025 if (fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
4026 WMA_LOGE("Number of Vdev mac entries %d exceeded"
4027 " max vdev supported %d",
4028 fixed_param->num_vdev_mac_entries,
4029 MAX_VDEV_SUPPORTED);
4030 return;
4031 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004032 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
4033 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
4034 hw_mode_trans_ind->num_vdev_mac_entries =
4035 fixed_param->num_vdev_mac_entries;
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08004036 WMA_LOGD("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004037 __func__, fixed_param->old_hw_mode_index,
4038 fixed_param->new_hw_mode_index,
4039 fixed_param->num_vdev_mac_entries);
4040
Harprit Chhabada3cfca962018-12-04 13:41:31 -08004041 if (!vdev_mac_entry) {
4042 WMA_LOGE("Invalid vdev_mac_entry");
4043 return;
4044 }
4045
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004046 /* Store the vdev-mac map in WMA and send to policy manager */
4047 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
4048 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004049
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004050 vdev_id = vdev_mac_entry[i].vdev_id;
4051 pdev_id = vdev_mac_entry[i].pdev_id;
4052
4053 if (pdev_id == WMI_PDEV_ID_SOC) {
4054 WMA_LOGE("%s: soc level id received for mac id)",
Tushnim Bhattacharyyac23d56c2018-10-05 14:11:43 -07004055 __func__);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004056 return;
4057 }
Pragaspathi Thilagaraj0092b672018-05-23 17:08:45 +05304058 if (vdev_id >= wma->max_bssid) {
4059 WMA_LOGE("%s: vdev_id: %d is invalid, max_bssid: %d",
4060 __func__, vdev_id, wma->max_bssid);
4061 return;
4062 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004063
4064 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
4065
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004066 WMA_LOGE("%s: vdev_id:%d mac_id:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004067 __func__, vdev_id, mac_id);
4068
4069 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
4070 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
4071 wma_update_intf_hw_mode_params(vdev_id, mac_id,
4072 fixed_param->new_hw_mode_index);
4073 }
4074 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
4075 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004076 policy_mgr_update_new_hw_mode_index(wma->psoc,
4077 fixed_param->new_hw_mode_index);
4078 policy_mgr_update_old_hw_mode_index(wma->psoc,
4079 fixed_param->old_hw_mode_index);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004080
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08004081 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004082 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
4083}
4084
4085/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304086 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 * @handle: WMI handle
4088 * @event: Event recevied from FW
4089 * @len: Length of the event
4090 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304091 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 * asynchronous hardware mode transition. This event notifies the host driver
4093 * that firmware independently changed the hardware mode for some reason, such
4094 * as Coex, LFR 3.0, etc
4095 *
4096 * Return: Success on receiving valid params from FW
4097 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304098static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 uint8_t *event,
4100 uint32_t len)
4101{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304102 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
4103 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
4104 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
4106 tp_wma_handle wma = (tp_wma_handle) handle;
4107
4108 if (!wma) {
4109 /* This is an async event. So, not sending any event to LIM */
4110 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304111 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 }
4113
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304114 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115 if (!param_buf) {
4116 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304117 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304118 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 }
4120
Arif Hussain34f72062017-10-04 17:25:24 -07004121 if (param_buf->fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
4122 WMA_LOGE("num_vdev_mac_entries: %d crossed max value: %d",
4123 param_buf->fixed_param->num_vdev_mac_entries,
4124 MAX_VDEV_SUPPORTED);
4125 return QDF_STATUS_E_FAILURE;
4126 }
4127
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304128 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Arif Hussain157263f2018-10-03 13:07:15 -07004129 if (!hw_mode_trans_ind)
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004130 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131
4132 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304134 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Abhinav Kumara03659c2017-12-28 15:18:07 +05304135 if (wmi_event->num_vdev_mac_entries >
4136 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
4137 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
4138 wmi_event->num_vdev_mac_entries);
4139 qdf_mem_free(hw_mode_trans_ind);
4140 return -EINVAL;
4141 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004142 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
4143 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304145 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 (void *) hw_mode_trans_ind, 0);
4147
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304148 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149}
4150
4151/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304152 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 * @handle: WMI handle
4154 * @event: Event received from FW
4155 * @len: Length of the event
4156 *
4157 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304158 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159 * the host driver once the firmware has completed a reconfiguration of the Scan
4160 * and FW mode configuration. This changes could include entering or leaving a
4161 * dual mac configuration for either scan and/or more permanent firmware mode.
4162 *
4163 * Return: Success on receiving valid params from FW
4164 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304165static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004166 uint8_t *event,
4167 uint32_t len)
4168{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304169 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
4170 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 tp_wma_handle wma = (tp_wma_handle) handle;
4172 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
4173
4174 if (!wma) {
4175 WMA_LOGE("%s: Invalid WMA handle", __func__);
4176 /* Since the WMA handle is NULL, we cannot send resp to LIM.
4177 * So, returning from here.
4178 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304179 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 }
Krunal Sonia5ccb802017-07-03 12:59:40 -07004181 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Abhishek Singhd93a0b22018-10-30 17:04:56 +05304182 wma_remove_req(wma, 0, WMA_PDEV_MAC_CFG_RESP);
4183
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304184 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Arif Hussain157263f2018-10-03 13:07:15 -07004185 if (!dual_mac_cfg_resp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 /* Since the mem alloc failed, we cannot send resp to LIM.
4187 * So, returning from here.
4188 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304189 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304191 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 event;
4193 if (!param_buf) {
4194 WMA_LOGE("%s: Invalid event", __func__);
4195 goto fail;
4196 }
4197
4198 wmi_event = param_buf->fixed_param;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004199 WMA_LOGD("%s: status:%d", __func__, wmi_event->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 dual_mac_cfg_resp->status = wmi_event->status;
4201
4202 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004203 policy_mgr_update_dbs_scan_config(wma->psoc);
4204 policy_mgr_update_dbs_fw_config(wma->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205 }
4206
4207 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304208 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 (void *) dual_mac_cfg_resp, 0);
4210
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304211 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212
4213fail:
4214 WMA_LOGE("%s: Sending fail response to LIM", __func__);
4215 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304216 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217 (void *) dual_mac_cfg_resp, 0);
4218
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304219 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220
4221}
4222
4223/**
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304224 * wma_send_time_stamp_sync_cmd() - timer callback send timestamp to
4225 * firmware to sync with host.
4226 * @wma_handle: wma handle
4227 *
4228 * Return: void
4229 */
4230static void wma_send_time_stamp_sync_cmd(void *data)
4231{
4232 tp_wma_handle wma_handle;
4233 QDF_STATUS qdf_status;
4234
4235 wma_handle = (tp_wma_handle) data;
4236
4237 wmi_send_time_stamp_sync_cmd_tlv(wma_handle->wmi_handle);
4238
4239 /* Start/Restart the timer */
4240 qdf_status = qdf_mc_timer_start(&wma_handle->wma_fw_time_sync_timer,
4241 WMA_FW_TIME_SYNC_TIMER);
4242 if (QDF_IS_STATUS_ERROR(qdf_status))
4243 WMA_LOGE("Failed to start the firmware time sync timer");
4244}
4245
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07004246#ifdef WLAN_CONV_SPECTRAL_ENABLE
4247static void wma_register_spectral_cmds(tp_wma_handle wma_handle)
4248{
4249 struct wmi_spectral_cmd_ops cmd_ops;
4250
4251 cmd_ops.wmi_spectral_configure_cmd_send =
4252 wmi_unified_vdev_spectral_configure_cmd_send;
4253 cmd_ops.wmi_spectral_enable_cmd_send =
4254 wmi_unified_vdev_spectral_enable_cmd_send;
4255 wlan_register_wmi_spectral_cmd_ops(wma_handle->pdev, &cmd_ops);
4256}
4257#else
4258static void wma_register_spectral_cmds(tp_wma_handle wma_handle)
4259{
4260}
4261#endif
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304262/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263 * wma_start() - wma start function.
Jeff Johnsonc97816c2018-05-12 17:13:23 -07004264 * Initialize event handlers and timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304266 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 */
Jeff Johnsond4892552017-09-13 08:41:31 -07004268QDF_STATUS wma_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304270 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 tp_wma_handle wma_handle;
4272 int status;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304273 struct wmi_unified *wmi_handle;
Ke Huangae49ad02018-11-27 10:53:11 +08004274 struct mac_context *mac = NULL;
4275 uint32_t cfg_val;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07004276
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 WMA_LOGD("%s: Enter", __func__);
4278
Anurag Chouhan6d760662016-02-20 16:05:43 +05304279 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 /* validate the wma_handle */
4281 if (NULL == wma_handle) {
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304282 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304283 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 goto end;
4285 }
Sandeep Puligillad698bf52017-09-15 16:07:02 -07004286
Sourav Mohapatracf632572018-04-02 11:01:35 +05304287 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304288 if (!wmi_handle) {
4289 WMA_LOGE("%s: Invalid wmi handle", __func__);
4290 qdf_status = QDF_STATUS_E_INVAL;
4291 goto end;
4292 }
4293
Ke Huangae49ad02018-11-27 10:53:11 +08004294 mac = cds_get_context(QDF_MODULE_ID_PE);
4295 if (!mac) {
4296 WMA_LOGE("%s: Invalid mac context", __func__);
4297 goto end;
4298 }
4299
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304300 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304301 wmi_roam_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304302 wma_roam_event_callback,
Padma, Santhosh Kumar18169ce2017-03-02 18:04:02 +05304303 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004304 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004305 WMA_LOGE("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304306 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 goto end;
4308 }
4309
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304310 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304311 wmi_wow_wakeup_host_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304312 wma_wow_wakeup_host_event,
4313 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004315 WMA_LOGE("%s: Failed to register wow wakeup host event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304317 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 goto end;
4319 }
4320
Will Huang3cd2b7c2017-11-17 13:16:56 +08004321 if (wma_d0_wow_is_supported()) {
4322 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304323 wmi_handle,
Will Huang9adefff2017-12-15 14:50:03 +08004324 wmi_d0_wow_disable_ack_event_id,
Will Huang3cd2b7c2017-11-17 13:16:56 +08004325 wma_d0_wow_disable_ack_event,
4326 WMA_RX_TASKLET_CTX);
4327 if (status) {
4328 WMA_LOGE("%s: Failed to register d0wow disable ack"
4329 " event handler", __func__);
4330 qdf_status = QDF_STATUS_E_FAILURE;
4331 goto end;
4332 }
4333 }
4334
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304335 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304336 wmi_pdev_resume_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304337 wma_pdev_resume_event_handler,
4338 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004340 WMA_LOGE("%s: Failed to register PDEV resume event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004341 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304342 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343 goto end;
4344 }
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05304345#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
4346 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004347 WMA_LOGD("MCC TX Pause Event Handler register");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304348 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304349 wmi_tx_pause_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304350 wma_mcc_vdev_tx_pause_evt_handler,
4351 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
4353
Kabilan Kannancaa85502018-04-13 18:04:58 -07004354 WMA_LOGD("Registering SAR2 response handler");
4355 status = wmi_unified_register_event_handler(wma_handle->wmi_handle,
4356 wmi_wlan_sar2_result_event_id,
4357 wma_sar_rsp_evt_handler,
4358 WMA_RX_SERIALIZER_CTX);
4359 if (status) {
4360 WMA_LOGE("Failed to register sar response event cb");
4361 qdf_status = QDF_STATUS_E_FAILURE;
4362 goto end;
4363 }
4364
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
4366 WMA_LOGD("Registering auto shutdown handler");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304367 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304368 wmi_host_auto_shutdown_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304369 wma_auto_shutdown_event_handler,
4370 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 if (status) {
4372 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304373 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 goto end;
4375 }
4376#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304377 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304378 wmi_thermal_mgmt_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304379 wma_thermal_mgmt_evt_handler,
4380 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 if (status) {
4382 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304383 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384 goto end;
4385 }
4386
Zhang Qian47e22ce2018-01-04 15:38:38 +08004387 status = wma_ocb_register_callbacks(wma_handle);
4388 if (!QDF_IS_STATUS_SUCCESS(status)) {
4389 WMA_LOGE("Failed to register OCB callbacks");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304390 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391 goto end;
4392 }
4393
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304394 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395
4396#ifdef QCA_WIFI_FTM
4397 /*
4398 * Tx mgmt attach requires TXRX context which is not created
4399 * in FTM mode. So skip the TX mgmt attach.
4400 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304401 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402 goto end;
4403#endif /* QCA_WIFI_FTM */
4404
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304405 if (wmi_service_enabled(wmi_handle, wmi_service_rmc)) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004406
4407 WMA_LOGD("FW supports cesium network, registering event handlers");
4408
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004409 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304410 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304411 wmi_peer_info_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004412 wma_ibss_peer_info_event_handler,
4413 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004414 if (status) {
4415 WMA_LOGE("Failed to register ibss peer info event cb");
4416 qdf_status = QDF_STATUS_E_FAILURE;
4417 goto end;
4418 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004419 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304420 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304421 wmi_peer_tx_fail_cnt_thr_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004422 wma_fast_tx_fail_event_handler,
4423 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004424 if (status) {
4425 WMA_LOGE("Failed to register peer fast tx failure event cb");
4426 qdf_status = QDF_STATUS_E_FAILURE;
4427 goto end;
4428 }
4429 } else {
4430 WMA_LOGE("Target does not support cesium network");
4431 }
4432
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304433 qdf_status = wma_tx_attach(wma_handle);
4434 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004435 WMA_LOGE("%s: Failed to register tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 goto end;
4437 }
4438
Ke Huangae49ad02018-11-27 10:53:11 +08004439 if (wlan_cfg_get_int(mac, WNI_CFG_REMOVE_TIME_SYNC_CMD,
4440 &cfg_val) == QDF_STATUS_SUCCESS) {
4441 if (cfg_val == 0 && cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4442 /* Initialize firmware time stamp sync timer */
4443 qdf_status =
4444 qdf_mc_timer_init(
4445 &wma_handle->wma_fw_time_sync_timer,
4446 QDF_TIMER_TYPE_SW,
4447 wma_send_time_stamp_sync_cmd,
4448 wma_handle);
4449 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4450 WMA_LOGE("Failed to init fw time sync timer");
4451 goto end;
4452 }
4453
4454 /* Start firmware time stamp sync timer */
4455 wma_send_time_stamp_sync_cmd(wma_handle);
Lin Bai5dc8ddb2018-08-23 17:46:34 +08004456 }
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304457 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05304459 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304460 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 wma_log_completion_timeout,
4462 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304463 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 WMA_LOGE("Failed to initialize log completion timeout");
4465 goto end;
4466 }
4467
Jeff Johnson6136fb92017-03-30 15:21:49 -07004468 status = wma_fips_register_event_handlers(wma_handle);
4469 if (!QDF_IS_STATUS_SUCCESS(status)) {
4470 WMA_LOGE("Failed to register FIPS event handler");
4471 qdf_status = QDF_STATUS_E_FAILURE;
4472 goto end;
4473 }
4474
Jeff Johnsonf0e54b02017-12-18 15:22:25 -08004475 status = wma_sar_register_event_handlers(wma_handle);
4476 if (!QDF_IS_STATUS_SUCCESS(status)) {
4477 WMA_LOGE("Failed to register SAR event handlers");
4478 qdf_status = QDF_STATUS_E_FAILURE;
4479 goto end;
4480 }
4481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 /* Initialize the get temperature event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304483 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304484 wmi_pdev_temperature_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304485 wma_pdev_temperature_evt_handler,
4486 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304487 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304489 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 goto end;
4491 }
4492
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304493 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304494 wmi_vdev_tsf_report_event_id,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004495 wma_vdev_tsf_handler,
4496 WMA_RX_SERIALIZER_CTX);
4497 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004498 WMA_LOGE("%s: Failed to register tsf callback", __func__);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004499 qdf_status = QDF_STATUS_E_FAILURE;
4500 goto end;
4501 }
4502
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304503 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304504 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304505 wmi_pdev_set_hw_mode_rsp_event_id,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304506 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304507 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304508 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304510 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511 goto end;
4512 }
4513
4514 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304515 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304516 wmi_pdev_hw_mode_transition_event_id,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304517 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304518 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304519 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304521 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 goto end;
4523 }
4524
4525 /* Initialize the set dual mac configuration event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304526 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304527 wmi_pdev_set_mac_config_resp_event_id,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304528 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304529 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304530 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304532 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533 goto end;
4534 }
4535
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304536 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304537 wmi_coex_bt_activity_event_id,
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304538 wma_wlan_bt_activity_evt_handler,
4539 WMA_RX_SERIALIZER_CTX);
4540 if (!QDF_IS_STATUS_SUCCESS(status)) {
4541 WMA_LOGE("Failed to register coex bt activity event handler");
4542 qdf_status = QDF_STATUS_E_FAILURE;
4543 goto end;
4544 }
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07004545 wma_register_spectral_cmds(wma_handle);
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304546
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547end:
4548 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304549 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550}
4551
Jeff Johnson62cd6802018-07-20 12:38:25 -07004552QDF_STATUS wma_stop(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553{
4554 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304555 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05304556 int i;
Ke Huangae49ad02018-11-27 10:53:11 +08004557 struct mac_context *mac = NULL;
4558 uint32_t cfg_val;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004559
Anurag Chouhan6d760662016-02-20 16:05:43 +05304560 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 WMA_LOGD("%s: Enter", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 /* validate the wma_handle */
4563 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004564 WMA_LOGE("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304565 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 goto end;
4567 }
Ke Huangae49ad02018-11-27 10:53:11 +08004568 mac = cds_get_context(QDF_MODULE_ID_PE);
4569 if (!mac) {
4570 WMA_LOGE("%s: Invalid mac context", __func__);
4571 goto end;
4572 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573#ifdef QCA_WIFI_FTM
4574 /*
4575 * Tx mgmt detach requires TXRX context which is not created
4576 * in FTM mode. So skip the TX mgmt detach.
4577 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304578 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304579 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 goto end;
4581 }
4582#endif /* QCA_WIFI_FTM */
4583
4584 if (wma_handle->ack_work_ctx) {
4585 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304586 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 wma_handle->ack_work_ctx = NULL;
4588 }
4589
4590 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05304591 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004592 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 WMA_LOGE("Failed to destroy the log completion timer");
Govind Singhede435f2015-12-01 16:16:36 +05304594 /* clean up ll-queue for all vdev */
4595 for (i = 0; i < wma_handle->max_bssid; i++) {
4596 if (wma_handle->interfaces[i].handle &&
Mukul Sharmaf9047232017-03-02 16:58:56 +05304597 wma_is_vdev_up(i)) {
Leo Chang96464902016-10-28 11:10:54 -07004598 cdp_fc_vdev_flush(
4599 cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08004600 wma_handle->
4601 interfaces[i].handle);
Govind Singhede435f2015-12-01 16:16:36 +05304602 }
4603 }
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304604
Ke Huangae49ad02018-11-27 10:53:11 +08004605 if (wlan_cfg_get_int(mac, WNI_CFG_REMOVE_TIME_SYNC_CMD,
4606 &cfg_val) == QDF_STATUS_SUCCESS) {
4607 if (cfg_val == 0 && cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4608 /* Destroy firmware time stamp sync timer */
4609 qdf_status = qdf_mc_timer_destroy(
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304610 &wma_handle->wma_fw_time_sync_timer);
Ke Huangae49ad02018-11-27 10:53:11 +08004611 if (QDF_IS_STATUS_ERROR(qdf_status))
4612 WMA_LOGE("Failed to destory fw sync timer");
4613 }
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304614 }
4615
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304616 qdf_status = wma_tx_detach(wma_handle);
4617 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004618 WMA_LOGE("%s: Failed to deregister tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 goto end;
4620 }
4621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622end:
4623 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304624 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625}
4626
4627/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628 * wma_wmi_service_close() - close wma wmi service interface.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304630 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 */
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004632QDF_STATUS wma_wmi_service_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633{
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004634 void *cds_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 tp_wma_handle wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 int i;
4637
4638 WMA_LOGD("%s: Enter", __func__);
4639
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004640 cds_ctx = cds_get_global_context();
4641 if (!cds_ctx) {
4642 WMA_LOGE("%s: Invalid CDS context", __func__);
4643 return QDF_STATUS_E_INVAL;
4644 }
4645
Anurag Chouhan6d760662016-02-20 16:05:43 +05304646 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647
4648 /* validate the wma_handle */
4649 if (NULL == wma_handle) {
4650 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304651 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 }
4653
4654 /* validate the wmi handle */
4655 if (NULL == wma_handle->wmi_handle) {
4656 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304657 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 }
4659
4660 /* dettach the wmi serice */
4661 WMA_LOGD("calling wmi_unified_detach");
4662 wmi_unified_detach(wma_handle->wmi_handle);
4663 wma_handle->wmi_handle = NULL;
4664
4665 for (i = 0; i < wma_handle->max_bssid; i++) {
Dustin Brownec2c92e2017-07-26 11:13:49 -07004666 wma_vdev_deinit(&wma_handle->interfaces[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004667 }
4668
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304669 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07004670
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 /* free the wma_handle */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07004672 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673
hangtiane52fa912018-11-26 15:44:38 +08004674 if (((struct cds_context *)cds_ctx)->cfg_ctx)
4675 qdf_mem_free(((struct cds_context *)cds_ctx)->cfg_ctx);
Rajeev Kumarfe6e62f2018-10-22 16:18:41 -07004676 ((struct cds_context *)cds_ctx)->cfg_ctx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304678 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679}
4680
Xun Luoa858a472015-11-10 08:24:45 -08004681/**
4682 * wma_wmi_work_close() - close the work queue items associated with WMI
Xun Luoa858a472015-11-10 08:24:45 -08004683 *
4684 * This function closes work queue items associated with WMI, but not fully
4685 * closes WMI service.
4686 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304687 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08004688 * proper error codes.
4689 */
Jeff Johnson6b8473d2017-09-13 09:20:53 -07004690QDF_STATUS wma_wmi_work_close(void)
Xun Luoa858a472015-11-10 08:24:45 -08004691{
4692 tp_wma_handle wma_handle;
4693
4694 WMA_LOGD("%s: Enter", __func__);
4695
Anurag Chouhan6d760662016-02-20 16:05:43 +05304696 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08004697
4698 /* validate the wma_handle */
4699 if (NULL == wma_handle) {
4700 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304701 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004702 }
4703
4704 /* validate the wmi handle */
4705 if (NULL == wma_handle->wmi_handle) {
4706 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304707 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004708 }
4709
4710 /* remove the wmi work */
4711 WMA_LOGD("calling wmi_unified_remove_work");
4712 wmi_unified_remove_work(wma_handle->wmi_handle);
4713
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304714 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08004715}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716
Krunal Soni2e48d012016-05-02 16:55:26 -07004717/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 * wma_close() - wma close function.
4719 * cleanup resources attached with wma.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304721 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722 */
Jeff Johnson542da352017-09-13 09:17:28 -07004723QDF_STATUS wma_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724{
4725 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304726 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727
4728 WMA_LOGD("%s: Enter", __func__);
4729
Anurag Chouhan6d760662016-02-20 16:05:43 +05304730 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731
4732 /* validate the wma_handle */
4733 if (NULL == wma_handle) {
4734 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304735 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004736 }
4737
4738 /* validate the wmi handle */
4739 if (NULL == wma_handle->wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004740 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304741 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 }
4743
4744 /* Free DBS list */
4745 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304746 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004748 WMA_LOGD("%s: DBS list is freed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05304750
Anurag Chouhan6d760662016-02-20 16:05:43 +05304751 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304753 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304755 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05304756 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
4757 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
4758 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
4759 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
4760 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
4761 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
4762 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 }
4764
4765 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304766 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
4767 if (qdf_status != QDF_STATUS_SUCCESS)
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004768 WMA_LOGE("%s: dbglog_deinit failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004769
Anurag Chouhan210db072016-02-22 18:42:15 +05304770 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304771 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004772 WMA_LOGE("%s: Failed to destroy service ready ext event timer",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304773 __func__);
4774
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304775 qdf_event_destroy(&wma_handle->target_suspend);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304776 qdf_event_destroy(&wma_handle->runtime_suspend);
4777 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08004778 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
4779 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08004780 wma_cleanup_vdev_resp_queue(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304782 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08004783 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Poddar, Siddarth2fb98072017-07-19 14:58:30 +05304784 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
4785 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304788 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 wma_handle->pGetRssiReq = NULL;
4790 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07004791
yeshwanth sriram guntuka584c2332017-07-29 12:50:25 +05304792 wma_unified_radio_tx_mem_free(wma_handle);
Srinivas Girigowdaad874a82016-10-25 14:08:00 -07004793
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -07004794 if (wma_handle->pdev) {
4795 wlan_objmgr_pdev_release_ref(wma_handle->pdev,
4796 WLAN_LEGACY_WMA_ID);
4797 wma_handle->pdev = NULL;
4798 }
Frank Liu00d73fe2017-05-19 22:11:28 +08004799
Nachiket Kukade37b4e6d2018-06-01 18:44:42 +05304800 pmo_unregister_get_beacon_interval_callback(wma_handle->psoc);
4801 pmo_unregister_get_dtim_period_callback(wma_handle->psoc);
Mukul Sharma44746042018-05-24 17:30:52 +05304802 pmo_unregister_get_cfg_int_callback(wma_handle->psoc);
4803 pmo_unregister_is_device_in_low_pwr_mode(wma_handle->psoc);
4804 pmo_unregister_get_pause_bitmap(wma_handle->psoc);
4805 pmo_unregister_pause_bitmap_notifier(wma_handle->psoc);
Will Huangad015772018-06-15 11:27:50 +08004806 pmo_unregister_get_vdev_dp_handle(wma_handle->psoc);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304807
Arunk Khandavallia6305a32018-01-25 11:19:18 +05304808 target_if_free_psoc_tgt_info(wma_handle->psoc);
4809
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05304810 wlan_objmgr_psoc_release_ref(wma_handle->psoc, WLAN_LEGACY_WMA_ID);
4811 wma_handle->psoc = NULL;
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05304812 wma_target_if_close(wma_handle);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304813
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304815 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004816}
4817
4818/**
4819 * wma_update_fw_config() - update fw configuration
Dustin Brownb9987af2018-03-01 17:15:11 -08004820 * @psoc: psoc to query configuration from
4821 * @tgt_hdl: target capability info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 *
4823 * Return: none
4824 */
Dustin Brownb9987af2018-03-01 17:15:11 -08004825static void wma_update_fw_config(struct wlan_objmgr_psoc *psoc,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304826 struct target_psoc_info *tgt_hdl)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827{
Dustin Brownb9987af2018-03-01 17:15:11 -08004828 target_resource_config *cfg = &tgt_hdl->info.wlan_res_cfg;
4829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830 /* Override the no. of max fragments as per platform configuration */
Dustin Brownb9987af2018-03-01 17:15:11 -08004831 cfg->max_frag_entries = QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304832 target_if_get_max_frag_entry(tgt_hdl));
Dustin Brownb9987af2018-03-01 17:15:11 -08004833 target_if_set_max_frag_entry(tgt_hdl, cfg->max_frag_entries);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304834
Dustin Brownb9987af2018-03-01 17:15:11 -08004835 cfg->num_wow_filters = ucfg_pmo_get_num_wow_filters(psoc);
Nachiket Kukadee547a482018-05-22 16:43:30 +05304836 cfg->apf_instruction_size = ucfg_pmo_get_apf_instruction_size(psoc);
Dustin Brown67d69eb2018-03-02 11:11:34 -08004837 cfg->num_packet_filters = ucfg_pmo_get_num_packet_filters(psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004838}
4839
4840/**
Yun Parkb4f591d2017-03-29 15:51:01 -07004841 * wma_set_tx_partition_base() - set TX MSDU ID partition base for IPA
4842 * @value: TX MSDU ID partition base
4843 *
4844 * Return: none
4845 */
4846#ifdef IPA_OFFLOAD
4847static void wma_set_tx_partition_base(uint32_t value)
4848{
4849 cdp_ipa_set_uc_tx_partition_base(
4850 cds_get_context(QDF_MODULE_ID_SOC),
4851 (struct cdp_cfg *)cds_get_context(QDF_MODULE_ID_CFG),
4852 value);
4853 WMA_LOGD("%s: TX_MSDU_ID_PARTITION=%d", __func__,
4854 value);
4855}
4856#else
4857static void wma_set_tx_partition_base(uint32_t value)
4858{
4859}
4860#endif
4861
4862/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 * wma_update_target_services() - update target services from wma handle
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304864 * @wmi_handle: Unified wmi handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865 * @cfg: target services
4866 *
4867 * Return: none
4868 */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304869static inline void wma_update_target_services(struct wmi_unified *wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870 struct wma_tgt_services *cfg)
4871{
4872 /* STA power save */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304873 cfg->sta_power_save = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304874 wmi_service_sta_pwrsave);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004875
4876 /* Enable UAPSD */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304877 cfg->uapsd = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304878 wmi_service_ap_uapsd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004879
4880 /* Update AP DFS service */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304881 cfg->ap_dfs = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304882 wmi_service_ap_dfs);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883
4884 /* Enable 11AC */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304885 cfg->en_11ac = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304886 wmi_service_11ac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004887 if (cfg->en_11ac)
4888 g_fw_wlan_feat_caps |= (1 << DOT11AC);
4889
4890 /* Proactive ARP response */
4891 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
4892
4893 /* Enable WOW */
4894 g_fw_wlan_feat_caps |= (1 << WOW);
4895
4896 /* ARP offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304897 cfg->arp_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304898 wmi_service_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004899
4900 /* Adaptive early-rx */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304901 cfg->early_rx = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304902 wmi_service_early_rx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903#ifdef FEATURE_WLAN_SCAN_PNO
4904 /* PNO offload */
Rajeev Kumar617aadd2018-05-31 16:36:13 -07004905 if (wmi_service_enabled(wmi_handle, wmi_service_nlo)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906 cfg->pno_offload = true;
Rajeev Kumar617aadd2018-05-31 16:36:13 -07004907 g_fw_wlan_feat_caps |= (1 << PNO);
4908 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909#endif /* FEATURE_WLAN_SCAN_PNO */
4910
4911#ifdef FEATURE_WLAN_EXTSCAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304912 if (wmi_service_enabled(wmi_handle, wmi_service_extscan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914#endif /* FEATURE_WLAN_EXTSCAN */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304915 cfg->lte_coex_ant_share = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304916 wmi_service_lte_ant_share_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917#ifdef FEATURE_WLAN_TDLS
4918 /* Enable TDLS */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304919 if (wmi_service_enabled(wmi_handle, wmi_service_tdls)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 cfg->en_tdls = 1;
4921 g_fw_wlan_feat_caps |= (1 << TDLS);
4922 }
4923 /* Enable advanced TDLS features */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304924 if (wmi_service_enabled(wmi_handle, wmi_service_tdls_offchan)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925 cfg->en_tdls_offchan = 1;
4926 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
4927 }
4928
4929 cfg->en_tdls_uapsd_buf_sta =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304930 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304931 wmi_service_tdls_uapsd_buffer_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 cfg->en_tdls_uapsd_sleep_sta =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304933 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304934 wmi_service_tdls_uapsd_sleep_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004935#endif /* FEATURE_WLAN_TDLS */
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304936 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304937 (wmi_handle, wmi_service_beacon_offload))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004938 cfg->beacon_offload = true;
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304939 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304940 (wmi_handle, wmi_service_sta_pmf_offload))
mukul sharma72c8b222015-09-04 17:02:01 +05304941 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4943 /* Enable Roam Offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304944 cfg->en_roam_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304945 wmi_service_roam_ho_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4947#ifdef WLAN_FEATURE_NAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304948 if (wmi_service_enabled(wmi_handle, wmi_service_nan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949 g_fw_wlan_feat_caps |= (1 << NAN);
4950#endif /* WLAN_FEATURE_NAN */
4951
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304952 if (wmi_service_enabled(wmi_handle, wmi_service_rtt))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07004954
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304955 if (wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304956 wmi_service_tx_msdu_id_new_partition_support)) {
Yun Parkb4f591d2017-03-29 15:51:01 -07004957 wma_set_tx_partition_base(HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004958 } else {
Yun Parkb4f591d2017-03-29 15:51:01 -07004959 wma_set_tx_partition_base(HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004960 }
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004961
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304962 wma_he_update_tgt_services(wmi_handle, cfg);
Will Huang496b36c2017-07-11 16:38:50 +08004963
4964 cfg->get_peer_info_enabled =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304965 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304966 wmi_service_peer_stats_info);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304967 if (wmi_service_enabled(wmi_handle, wmi_service_fils_support))
Vignesh Viswanathan731186f2017-09-18 13:47:37 +05304968 cfg->is_fils_roaming_supported = true;
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004969
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304970 if (wmi_service_enabled(wmi_handle, wmi_service_mawc_support))
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004971 cfg->is_fw_mawc_capable = true;
4972
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304973 if (wmi_service_enabled(wmi_handle,
4974 wmi_service_11k_neighbour_report_support))
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304975 cfg->is_11k_offload_supported = true;
Varun Reddy Yeturu4b54ec82018-05-30 16:00:38 -07004976
4977 if (wmi_service_enabled(wmi_handle, wmi_service_twt_requestor))
4978 cfg->twt_requestor = true;
4979 if (wmi_service_enabled(wmi_handle, wmi_service_twt_responder))
4980 cfg->twt_responder = true;
Liangwei Dong0da14262018-07-03 03:30:23 -04004981 if (wmi_service_enabled(wmi_handle, wmi_service_obss_scan))
4982 cfg->obss_scan_offload = true;
Arunk Khandavallica56d4b2018-11-29 15:46:00 +05304983 if (wmi_service_enabled(wmi_handle, wmi_service_beacon_reception_stats))
4984 cfg->bcn_reception_stats = true;
Sourav Mohapatrac457ae62018-12-06 15:19:41 +05304985
4986 if (wmi_service_enabled(wmi_handle, wmi_service_vdev_latency_config))
4987 g_fw_wlan_feat_caps |= (1 << VDEV_LATENCY_CONFIG);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988}
4989
4990/**
4991 * wma_update_target_ht_cap() - update ht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304992 * @tgt_hdl: pointer to structure target_psoc_info
4993 * @cfg: ht capability
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994 *
4995 * Return: none
4996 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304997static inline void
4998wma_update_target_ht_cap(struct target_psoc_info *tgt_hdl,
4999 struct wma_tgt_ht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005000{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305001 int ht_cap_info;
5002
5003 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004 /* RX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305005 cfg->ht_rx_stbc = !!(ht_cap_info & WMI_HT_CAP_RX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005006
5007 /* TX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305008 cfg->ht_tx_stbc = !!(ht_cap_info & WMI_HT_CAP_TX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005009
5010 /* MPDU density */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305011 cfg->mpdu_density = ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012
5013 /* HT RX LDPC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305014 cfg->ht_rx_ldpc = !!(ht_cap_info & WMI_HT_CAP_LDPC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015
5016 /* HT SGI */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305017 cfg->ht_sgi_20 = !!(ht_cap_info & WMI_HT_CAP_HT20_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005018
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305019 cfg->ht_sgi_40 = !!(ht_cap_info & WMI_HT_CAP_HT40_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020
5021 /* RF chains */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305022 cfg->num_rf_chains = target_if_get_num_rf_chains(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005023
Jeff Johnson3fd21822016-11-08 11:30:37 -08005024 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n"
5025 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305026 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
5027 ht_cap_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005028 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
5029 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
5030 cfg->num_rf_chains);
5031
5032}
5033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005034/**
5035 * wma_update_target_vht_cap() - update vht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305036 * @tgt_hdl: pointer to structure target_psoc_info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037 * @cfg: vht capabality
5038 *
5039 * Return: none
5040 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305041static inline void
5042wma_update_target_vht_cap(struct target_psoc_info *tgt_hdl,
5043 struct wma_tgt_vht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005044{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305045 int vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005046
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305047 if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305049 else if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005050 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5051 else
5052 cfg->vht_max_mpdu = 0;
5053
5054
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305055 if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
5057 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305058 } else if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005059 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305060 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005061 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305062 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005063
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305064 cfg->vht_rx_ldpc = vht_cap_info & WMI_VHT_CAP_RX_LDPC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005065
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305066 cfg->vht_short_gi_80 = vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
5067 cfg->vht_short_gi_160 = vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005068
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305069 cfg->vht_tx_stbc = vht_cap_info & WMI_VHT_CAP_TX_STBC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005070
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305071 cfg->vht_rx_stbc =
5072 (vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
5073 (vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
5074 (vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305076 cfg->vht_max_ampdu_len_exp = (vht_cap_info &
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
5078 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
5079
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305080 cfg->vht_su_bformer = vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305082 cfg->vht_su_bformee = vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005083
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305084 cfg->vht_mu_bformer = vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305086 cfg->vht_mu_bformee = vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305088 cfg->vht_txop_ps = vht_cap_info & WMI_VHT_CAP_TXOP_PS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005089
Jeff Johnson3fd21822016-11-08 11:30:37 -08005090 WMA_LOGD("%s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
5091 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
5092 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
5094 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
5095 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
5096 cfg->vht_max_ampdu_len_exp);
5097}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098
5099/**
Krunal Sonica50b452017-08-04 22:24:59 -07005100 * wma_update_supported_bands() - update supported bands from service ready ext
Krunal Sonica50b452017-08-04 22:24:59 -07005101 * @supported_bands: Supported band given by FW through service ready ext params
5102 * @new_supported_bands: New supported band which needs to be updated by
5103 * this API which WMA layer understands
5104 *
5105 * This API will convert FW given supported band to enum which WMA layer
5106 * understands
5107 *
5108 * Return: QDF_STATUS
5109 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305110static QDF_STATUS wma_update_supported_bands(
Krunal Sonica50b452017-08-04 22:24:59 -07005111 WLAN_BAND_CAPABILITY supported_bands,
5112 WMI_PHY_CAPABILITY *new_supported_bands)
5113{
5114 QDF_STATUS status = QDF_STATUS_SUCCESS;
5115
Krunal Sonica50b452017-08-04 22:24:59 -07005116 if (!new_supported_bands) {
5117 WMA_LOGE("%s: NULL new supported band variable", __func__);
5118 return QDF_STATUS_E_FAILURE;
5119 }
5120 switch (supported_bands) {
5121 case WLAN_2G_CAPABILITY:
5122 *new_supported_bands |= WMI_11G_CAPABILITY;
5123 break;
5124 case WLAN_5G_CAPABILITY:
5125 *new_supported_bands |= WMI_11A_CAPABILITY;
5126 break;
5127 default:
5128 WMA_LOGE("%s: wrong supported band", __func__);
5129 status = QDF_STATUS_E_FAILURE;
5130 break;
5131 }
5132 return status;
5133}
5134
5135/**
Krunal Soniaa664da2016-06-15 23:46:40 -07005136 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005137 * @ht_cap: given pointer to HT caps which needs to be updated
5138 * @tx_chain: given tx chainmask value
5139 * @rx_chain: given rx chainmask value
5140 * @value: new HT cap info provided in form of bitmask
5141 *
5142 * This function takes the value provided in form of bitmask and decodes
5143 * it. After decoding, what ever value it gets, it takes the union(max) or
5144 * intersection(min) with previously derived values.
5145 *
5146 * Return: none
5147 *
5148 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305149static void wma_derive_ext_ht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005150 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
5151 uint32_t tx_chain, uint32_t rx_chain)
5152{
5153 struct wma_tgt_ht_cap tmp = {0};
5154
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305155 if (ht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005156 return;
5157
Ankit Guptaa5076012016-09-14 11:32:19 -07005158 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07005159 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
5160 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
5161 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
5162 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
5163 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
5164 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
5165 ht_cap->num_rf_chains =
5166 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
5167 wma_get_num_of_setbits_from_bitmask(rx_chain));
5168 } else {
5169 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
5170 (!!(value & WMI_HT_CAP_RX_STBC)));
5171 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
5172 (!!(value & WMI_HT_CAP_TX_STBC)));
5173 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
5174 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
5175 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
5176 (!!(value & WMI_HT_CAP_RX_LDPC)));
5177 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
5178 (!!(value & WMI_HT_CAP_HT20_SGI)));
5179 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
5180 (!!(value & WMI_HT_CAP_HT40_SGI)));
5181 ht_cap->num_rf_chains =
5182 QDF_MAX(ht_cap->num_rf_chains,
5183 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
5184 tx_chain),
5185 wma_get_num_of_setbits_from_bitmask(
5186 rx_chain)));
5187 }
5188}
5189
5190/**
5191 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305192 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005193 * @ht_cap: HT cap structure to be filled
5194 *
5195 * This function loop through each hardware mode and for each hardware mode
5196 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5197 * HT caps and derives the final cap.
5198 *
5199 * Return: none
5200 *
5201 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305202static void wma_update_target_ext_ht_cap(struct target_psoc_info *tgt_hdl,
5203 struct wma_tgt_ht_cap *ht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005204{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005205 int i, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005206 uint32_t ht_2g, ht_5g;
5207 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305208 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5209 int num_hw_modes;
Krunal Soniaa664da2016-06-15 23:46:40 -07005210
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005211 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305212 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5213 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005214 /*
5215 * for legacy device extended cap might not even come, so in that case
5216 * don't overwrite legacy values
5217 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305218 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005219 WMA_LOGD("%s: No extended HT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005220 return;
5221 }
5222
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005223 for (i = 0; i < total_mac_phy_cnt; i++) {
5224 ht_2g = mac_phy_cap[i].ht_cap_info_2G;
5225 ht_5g = mac_phy_cap[i].ht_cap_info_5G;
5226 if (ht_2g)
5227 wma_derive_ext_ht_cap(&tmp_ht_cap,
5228 ht_2g,
5229 mac_phy_cap[i].tx_chain_mask_2G,
5230 mac_phy_cap[i].rx_chain_mask_2G);
5231 if (ht_5g)
5232 wma_derive_ext_ht_cap(&tmp_ht_cap,
5233 ht_5g,
5234 mac_phy_cap[i].tx_chain_mask_5G,
5235 mac_phy_cap[i].rx_chain_mask_5G);
Krunal Soniaa664da2016-06-15 23:46:40 -07005236 }
5237
Ankit Guptaa5076012016-09-14 11:32:19 -07005238 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005239 sizeof(struct wma_tgt_ht_cap))) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005240 qdf_mem_copy(ht_cap, &tmp_ht_cap,
5241 sizeof(struct wma_tgt_ht_cap));
Krunal Soniaa664da2016-06-15 23:46:40 -07005242 }
5243
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005244 WMA_LOGD("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005245 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
5246 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005247 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
5248 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
5249 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
5250 ht_cap->num_rf_chains);
5251}
5252
5253/**
5254 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005255 * @vht_cap: pointer to given VHT caps to be filled
5256 * @value: new VHT cap info provided in form of bitmask
5257 *
5258 * This function takes the value provided in form of bitmask and decodes
5259 * it. After decoding, what ever value it gets, it takes the union(max) or
5260 * intersection(min) with previously derived values.
5261 *
5262 * Return: none
5263 *
5264 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305265static void wma_derive_ext_vht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005266 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
5267{
5268 struct wma_tgt_vht_cap tmp_cap = {0};
5269 uint32_t tmp = 0;
5270
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305271 if (vht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005272 return;
5273
Ankit Guptaa5076012016-09-14 11:32:19 -07005274 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005275 sizeof(struct wma_tgt_vht_cap))) {
5276 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5277 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5278 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5279 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5280 else
5281 vht_cap->vht_max_mpdu = 0;
5282
5283 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
5284 vht_cap->supp_chan_width =
5285 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
5286 vht_cap->supp_chan_width |=
5287 1 << eHT_CHANNEL_WIDTH_160MHZ;
5288 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5289 vht_cap->supp_chan_width =
5290 1 << eHT_CHANNEL_WIDTH_160MHZ;
5291 } else {
5292 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5293 }
5294 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
5295 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
5296 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
5297 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
5298 vht_cap->vht_rx_stbc =
5299 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5300 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5301 (value & WMI_VHT_CAP_RX_STBC_3SS);
5302 vht_cap->vht_max_ampdu_len_exp =
5303 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5304 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
5305 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
5306 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
5307 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
5308 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
5309 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
5310 } else {
5311 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5312 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5313 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5314 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5315 else
5316 tmp = 0;
5317 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
5318
5319 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
5320 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
5321 (1 << eHT_CHANNEL_WIDTH_160MHZ);
5322 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5323 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
5324 } else {
5325 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5326 }
5327 vht_cap->supp_chan_width =
5328 QDF_MAX(vht_cap->supp_chan_width, tmp);
5329 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
5330 value & WMI_VHT_CAP_RX_LDPC);
5331 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
5332 value & WMI_VHT_CAP_SGI_80MHZ);
5333 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
5334 value & WMI_VHT_CAP_SGI_160MHZ);
5335 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
5336 value & WMI_VHT_CAP_TX_STBC);
5337 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
5338 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5339 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5340 (value & WMI_VHT_CAP_RX_STBC_3SS));
5341 vht_cap->vht_max_ampdu_len_exp =
5342 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
5343 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5344 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
5345 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
5346 value & WMI_VHT_CAP_SU_BFORMER);
5347 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
5348 value & WMI_VHT_CAP_SU_BFORMEE);
5349 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
5350 value & WMI_VHT_CAP_MU_BFORMER);
5351 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
5352 value & WMI_VHT_CAP_MU_BFORMEE);
5353 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
5354 value & WMI_VHT_CAP_TXOP_PS);
5355 }
5356}
5357
5358/**
5359 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305360 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005361 * @vht_cap: VHT cap structure to be filled
5362 *
5363 * This function loop through each hardware mode and for each hardware mode
5364 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5365 * VHT caps and derives the final cap.
5366 *
5367 * Return: none
5368 *
5369 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305370static void wma_update_target_ext_vht_cap(struct target_psoc_info *tgt_hdl,
5371 struct wma_tgt_vht_cap *vht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005372{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005373 int i, num_hw_modes, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005374 uint32_t vht_cap_info_2g, vht_cap_info_5g;
5375 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305376 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5377
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005378 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305379 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5380 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005381
5382 /*
5383 * for legacy device extended cap might not even come, so in that case
5384 * don't overwrite legacy values
5385 */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005386 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005387 WMA_LOGD("%s: No extended VHT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005388 return;
5389 }
5390
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005391 for (i = 0; i < total_mac_phy_cnt; i++) {
5392 vht_cap_info_2g = mac_phy_cap[i].vht_cap_info_2G;
5393 vht_cap_info_5g = mac_phy_cap[i].vht_cap_info_5G;
5394 if (vht_cap_info_2g)
5395 wma_derive_ext_vht_cap(&tmp_vht_cap,
5396 vht_cap_info_2g);
5397 if (vht_cap_info_5g)
5398 wma_derive_ext_vht_cap(&tmp_vht_cap,
5399 vht_cap_info_5g);
Krunal Soniaa664da2016-06-15 23:46:40 -07005400 }
5401
Ankit Guptaa5076012016-09-14 11:32:19 -07005402 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005403 sizeof(struct wma_tgt_vht_cap))) {
5404 qdf_mem_copy(vht_cap, &tmp_vht_cap,
5405 sizeof(struct wma_tgt_vht_cap));
5406 }
5407
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005408 WMA_LOGD("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005409 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
5410 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005411 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
5412 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
5413 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
5414 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
5415 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
5416}
5417
5418/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305419 * wma_update_ra_rate_limit() - update wma config
5420 * @wma_handle: wma handle
5421 * @cfg: target config
5422 *
5423 * Return: none
5424 */
5425#ifdef FEATURE_WLAN_RA_FILTERING
5426static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5427 struct wma_tgt_cfg *cfg)
5428{
5429 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
5430}
5431#else
5432static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5433 struct wma_tgt_cfg *cfg)
5434{
5435}
5436#endif
5437
Jeff Johnson0918f242018-07-17 18:52:17 -07005438static void
5439wma_update_sar_version(struct wlan_psoc_host_service_ext_param *param,
5440 struct wma_tgt_cfg *cfg)
5441{
5442 cfg->sar_version = param ? param->sar_version : SAR_VERSION_1;
5443}
5444
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305445/**
Krunal Sonica50b452017-08-04 22:24:59 -07005446 * wma_update_hdd_band_cap() - update band cap which hdd understands
5447 * @supported_band: supported band which has been given by FW
5448 * @tgt_cfg: target configuration to be updated
5449 *
5450 * Convert WMA given supported band to enum which HDD understands
5451 *
5452 * Return: None
5453 */
5454static void wma_update_hdd_band_cap(WMI_PHY_CAPABILITY supported_band,
5455 struct wma_tgt_cfg *tgt_cfg)
5456{
5457 switch (supported_band) {
5458 case WMI_11G_CAPABILITY:
5459 case WMI_11NG_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005460 tgt_cfg->band_cap = BAND_2G;
Krunal Sonica50b452017-08-04 22:24:59 -07005461 break;
5462 case WMI_11A_CAPABILITY:
5463 case WMI_11NA_CAPABILITY:
5464 case WMI_11AC_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005465 tgt_cfg->band_cap = BAND_5G;
Krunal Sonica50b452017-08-04 22:24:59 -07005466 break;
5467 case WMI_11AG_CAPABILITY:
5468 case WMI_11NAG_CAPABILITY:
5469 default:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005470 tgt_cfg->band_cap = BAND_ALL;
Krunal Sonica50b452017-08-04 22:24:59 -07005471 }
5472}
5473
5474/**
Arif Hussainee10f902017-12-27 16:30:17 -08005475 * wma_update_obss_detection_support() - update obss detection offload support
5476 * @wh: wma handle
5477 * @tgt_cfg: target configuration to be updated
5478 *
5479 * Update obss detection offload support based on service bit.
5480 *
5481 * Return: None
5482 */
5483static void wma_update_obss_detection_support(tp_wma_handle wh,
5484 struct wma_tgt_cfg *tgt_cfg)
5485{
Arif Hussain05fb4872018-01-03 16:02:55 -08005486 if (wmi_service_enabled(wh->wmi_handle,
5487 wmi_service_ap_obss_detection_offload))
Arif Hussainee10f902017-12-27 16:30:17 -08005488 tgt_cfg->obss_detection_offloaded = true;
5489 else
5490 tgt_cfg->obss_detection_offloaded = false;
5491}
5492
5493/**
Arif Hussain05fb4872018-01-03 16:02:55 -08005494 * wma_update_obss_color_collision_support() - update obss color collision
5495 * offload support
5496 * @wh: wma handle
5497 * @tgt_cfg: target configuration to be updated
5498 *
5499 * Update obss color collision offload support based on service bit.
5500 *
5501 * Return: None
5502 */
5503static void wma_update_obss_color_collision_support(tp_wma_handle wh,
5504 struct wma_tgt_cfg *tgt_cfg)
5505{
5506 if (wmi_service_enabled(wh->wmi_handle, wmi_service_bss_color_offload))
5507 tgt_cfg->obss_color_collision_offloaded = true;
5508 else
5509 tgt_cfg->obss_color_collision_offloaded = false;
5510}
5511
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005512#ifdef WLAN_SUPPORT_GREEN_AP
5513static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5514{
5515 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5516 WMI_SERVICE_EGAP))
5517 target_if_green_ap_register_egap_event_handler(
5518 wma_handle->pdev);
5519
5520}
5521#else
5522static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5523{
5524}
5525#endif
5526
Nachiket Kukade85aa3782018-11-02 20:12:34 +05305527#ifdef WLAN_FEATURE_NAN
5528static void wma_update_nan_target_caps(tp_wma_handle wma_handle,
5529 struct wma_tgt_cfg *tgt_cfg)
5530{
5531 if (wmi_service_enabled(wma_handle->wmi_handle,
5532 wmi_service_nan_disable_support))
5533 tgt_cfg->nan_caps.nan_disable_supported = 1;
5534
5535 if (wmi_service_enabled(wma_handle->wmi_handle,
5536 wmi_service_nan_dbs_support))
5537 tgt_cfg->nan_caps.nan_dbs_supported = 1;
5538
5539 if (wmi_service_enabled(wma_handle->wmi_handle,
5540 wmi_service_ndi_dbs_support))
5541 tgt_cfg->nan_caps.ndi_dbs_supported = 1;
5542
5543 if (wmi_service_enabled(wma_handle->wmi_handle,
5544 wmi_service_nan_sap_support))
5545 tgt_cfg->nan_caps.nan_sap_supported = 1;
5546
5547 if (wmi_service_enabled(wma_handle->wmi_handle,
5548 wmi_service_ndi_sap_support))
5549 tgt_cfg->nan_caps.ndi_sap_supported = 1;
5550}
5551#else
5552static void wma_update_nan_target_caps(tp_wma_handle wma_handle,
5553 struct wma_tgt_cfg *tgt_cfg)
5554{
5555}
5556#endif
5557
Arif Hussain05fb4872018-01-03 16:02:55 -08005558/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 * wma_update_hdd_cfg() - update HDD config
5560 * @wma_handle: wma handle
5561 *
5562 * Return: none
5563 */
5564static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
5565{
5566 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05305567 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305568 target_resource_config *wlan_res_cfg;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305569 struct wlan_psoc_host_service_ext_param *service_ext_param;
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305570 struct target_psoc_info *tgt_hdl;
5571 struct wmi_unified *wmi_handle;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305572
5573 WMA_LOGD("%s: Enter", __func__);
5574
5575 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5576 if (!tgt_hdl) {
5577 WMA_LOGE("%s: target psoc info is NULL", __func__);
5578 return;
5579 }
5580
5581 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
Arif Hussaind15902c2018-03-02 00:08:29 -08005582 if (!wlan_res_cfg) {
5583 WMA_LOGE("%s: wlan_res_cfg is null", __func__);
5584 return;
5585 }
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305586 service_ext_param =
5587 target_psoc_get_service_ext_param(tgt_hdl);
Sourav Mohapatracf632572018-04-02 11:01:35 +05305588 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305589 if (!wmi_handle) {
5590 WMA_LOGE("%s: wmi handle is NULL", __func__);
5591 return;
5592 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305594 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07005595
5596 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
5598 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
5599
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305600 tgt_cfg.max_intf_count = wlan_res_cfg->num_vdevs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005601
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305602 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603 ATH_MAC_LEN);
5604
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305605 wma_update_target_services(wmi_handle, &tgt_cfg.services);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305606 wma_update_target_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5607 wma_update_target_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07005608 /*
5609 * This will overwrite the structure filled by wma_update_target_ht_cap
5610 * and wma_update_target_vht_cap APIs.
5611 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305612 wma_update_target_ext_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5613 wma_update_target_ext_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005614
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305615 wma_update_target_ext_he_cap(tgt_hdl, &tgt_cfg);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005616
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305617 tgt_cfg.target_fw_version = target_if_get_fw_version(tgt_hdl);
5618 if (service_ext_param)
5619 tgt_cfg.target_fw_vers_ext =
5620 service_ext_param->fw_build_vers_ext;
5621
Ryan Hsuc6918552018-05-16 13:29:59 -07005622 tgt_cfg.hw_bd_id = wma_handle->hw_bd_id;
5623 tgt_cfg.hw_bd_info.bdf_version = wma_handle->hw_bd_info[BDF_VERSION];
5624 tgt_cfg.hw_bd_info.ref_design_id =
5625 wma_handle->hw_bd_info[REF_DESIGN_ID];
5626 tgt_cfg.hw_bd_info.customer_id = wma_handle->hw_bd_info[CUSTOMER_ID];
5627 tgt_cfg.hw_bd_info.project_id = wma_handle->hw_bd_info[PROJECT_ID];
5628 tgt_cfg.hw_bd_info.board_data_rev =
5629 wma_handle->hw_bd_info[BOARD_DATA_REV];
5630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005631#ifdef WLAN_FEATURE_LPSS
5632 tgt_cfg.lpss_support = wma_handle->lpss_support;
5633#endif /* WLAN_FEATURE_LPSS */
5634 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Arif Hussaind54b62c2018-03-01 13:31:37 -08005635 tgt_cfg.dfs_cac_offload = wma_handle->is_dfs_offloaded;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305636 tgt_cfg.rcpi_enabled = wma_handle->rcpi_enabled;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305637 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05305638 wma_update_hdd_band_cap(target_if_get_phy_capability(tgt_hdl),
5639 &tgt_cfg);
Jeff Johnson0918f242018-07-17 18:52:17 -07005640 wma_update_sar_version(service_ext_param, &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08005641 tgt_cfg.fine_time_measurement_cap =
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305642 target_if_get_wmi_fw_sub_feat_caps(tgt_hdl);
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05305643 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
5644 - WMI_TLV_HEADROOM;
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05305645 tgt_cfg.tx_bfee_8ss_enabled = wma_handle->tx_bfee_8ss_enabled;
gaurank kathpalia5fcefa92018-10-24 15:03:15 +05305646 tgt_cfg.dynamic_nss_chains_support =
5647 wma_handle->dynamic_nss_chains_support;
Arif Hussainee10f902017-12-27 16:30:17 -08005648 wma_update_obss_detection_support(wma_handle, &tgt_cfg);
Arif Hussain05fb4872018-01-03 16:02:55 -08005649 wma_update_obss_color_collision_support(wma_handle, &tgt_cfg);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07005650 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Nachiket Kukade85aa3782018-11-02 20:12:34 +05305651 wma_update_nan_target_caps(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07005652 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Himanshu Agarwal2228e072018-01-24 17:42:17 +05305653 target_if_store_pdev_target_if_ctx(wma_get_pdev_from_scn_handle);
Nachiket Kukade7dda8c22018-03-12 19:59:43 +05305654 target_pdev_set_wmi_handle(wma_handle->pdev->tgt_if_handle,
5655 wma_handle->wmi_handle);
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005656 wma_green_ap_register_handlers(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657}
5658
5659/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
5661 * @wma_handle: WMA handle
5662 *
5663 * Prints the DBS HW modes sent by the FW as part
5664 * of WMI ready event
5665 *
5666 * Return: None
5667 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005668static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669{
5670 uint32_t i, param;
5671
5672 if (!wma_handle) {
5673 WMA_LOGE("%s: Invalid WMA handle", __func__);
5674 return;
5675 }
5676
5677 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5678 param = wma_handle->hw_mode.hw_mode_list[i];
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005679 WMA_LOGD("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305681 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
5682 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
5683 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005684 WMA_LOGD("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005685 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305686 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
5687 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
5688 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005689 WMA_LOGD("%s:[%d] DBS:%d SBS:%d", __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305690 WMA_HW_MODE_DBS_MODE_GET(param),
5691 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005693 policy_mgr_dump_dbs_hw_mode(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005694}
5695
5696/**
5697 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305698 * @psoc: Object manager psoc
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305699 * @scan_config: Scam mode configuration
5700 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005701 *
5702 * Enables all the valid bits of concurrent_scan_config_bits and
5703 * fw_mode_config_bits.
5704 *
5705 * Return: None
5706 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305707static void wma_init_scan_fw_mode_config(struct wlan_objmgr_psoc *psoc,
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005708 uint32_t scan_config,
5709 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711 WMA_LOGD("%s: Enter", __func__);
5712
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305713 if (!psoc) {
5714 WMA_LOGE("%s: obj psoc is NULL", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005715 return;
5716 }
5717
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305718 policy_mgr_init_dbs_config(psoc, scan_config, fw_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005719}
5720
5721/**
Nachiket Kukadee547a482018-05-22 16:43:30 +05305722 * wma_update_ra_limit() - update ra limit based on apf filter
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305723 * enabled or not
5724 * @handle: wma handle
5725 *
5726 * Return: none
5727 */
5728#ifdef FEATURE_WLAN_RA_FILTERING
5729static void wma_update_ra_limit(tp_wma_handle wma_handle)
5730{
Wu Gao66454f12018-09-26 19:55:41 +08005731 if (ucfg_pmo_is_apf_enabled(wma_handle->psoc))
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305732 wma_handle->IsRArateLimitEnabled = false;
5733}
5734#else
Wu Gao66454f12018-09-26 19:55:41 +08005735static void wma_update_ra_limit(tp_wma_handle handle)
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305736{
5737}
5738#endif
5739
Dustin Brown06259e52018-02-28 16:00:02 -08005740static void wma_set_pmo_caps(struct wlan_objmgr_psoc *psoc)
5741{
5742 QDF_STATUS status;
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305743 tp_wma_handle wma;
Dustin Brown06259e52018-02-28 16:00:02 -08005744 struct pmo_device_caps caps;
5745
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305746 wma = cds_get_context(QDF_MODULE_ID_WMA);
Arif Hussaineec28b52018-08-21 17:21:28 -07005747 if (!wma) {
5748 WMA_LOGE("%s: wma handler is null", __func__);
5749 return;
5750 }
5751
Dustin Brown06259e52018-02-28 16:00:02 -08005752 caps.arp_ns_offload =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305753 wmi_service_enabled(wma->wmi_handle, wmi_service_arpns_offload);
Dustin Brown06259e52018-02-28 16:00:02 -08005754 caps.apf =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305755 wmi_service_enabled(wma->wmi_handle, wmi_service_apf_offload);
Dustin Brown06259e52018-02-28 16:00:02 -08005756 caps.packet_filter =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305757 wmi_service_enabled(wma->wmi_handle,
5758 wmi_service_packet_filter_offload);
Dustin Brown06259e52018-02-28 16:00:02 -08005759 caps.unified_wow =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305760 wmi_service_enabled(wma->wmi_handle,
5761 wmi_service_unified_wow_capability);
Nachiket Kukade4b7c8e02018-06-01 22:53:06 +05305762 caps.li_offload =
Sourav Mohapatra5daec822018-07-10 14:40:06 +05305763 wmi_service_enabled(wma->wmi_handle,
5764 wmi_service_listen_interval_offload_support
5765 );
Dustin Brown06259e52018-02-28 16:00:02 -08005766
5767 status = ucfg_pmo_psoc_set_caps(psoc, &caps);
5768 if (QDF_IS_STATUS_ERROR(status))
5769 WMA_LOGE("Failed to set PMO capabilities; status:%d", status);
5770}
5771
5772static void wma_set_component_caps(struct wlan_objmgr_psoc *psoc)
5773{
5774 wma_set_pmo_caps(psoc);
5775}
5776
Mukul Sharma44746042018-05-24 17:30:52 +05305777#if defined(WLAN_FEATURE_GTK_OFFLOAD) && defined(WLAN_POWER_MANAGEMENT_OFFLOAD)
5778static QDF_STATUS wma_register_gtk_offload_event(tp_wma_handle wma_handle)
5779{
5780 QDF_STATUS status = QDF_STATUS_E_FAILURE;
5781
5782 if (!wma_handle) {
5783 WMA_LOGE("%s: wma_handle passed is NULL", __func__);
5784 return QDF_STATUS_E_FAILURE;
5785 }
5786
5787 if (wmi_service_enabled(wma_handle->wmi_handle,
5788 wmi_service_gtk_offload)) {
5789 status = wmi_unified_register_event_handler(
5790 wma_handle->wmi_handle,
5791 wmi_gtk_offload_status_event_id,
5792 target_if_pmo_gtk_offload_status_event,
5793 WMA_RX_WORK_CTX);
5794 }
5795 return status;
5796}
5797#else
5798static QDF_STATUS wma_register_gtk_offload_event(tp_wma_handle wma_handle)
5799{
5800 return QDF_STATUS_SUCCESS;
5801}
5802#endif /* WLAN_FEATURE_GTK_OFFLOAD && WLAN_POWER_MANAGEMENT_OFFLOAD */
5803
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305804/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805 * wma_rx_service_ready_event() - event handler to process
5806 * wmi rx sevice ready event.
5807 * @handle: wma handle
5808 * @cmd_param_info: command params info
5809 *
5810 * Return: none
5811 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305812int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005813 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005814{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005815 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005816 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
5817 wmi_service_ready_event_fixed_param *ev;
Dustin Brown7678b6c2018-03-07 13:00:52 -08005818 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005819 uint32_t *ev_wlan_dbs_hw_mode_list;
Leo Chang96464902016-10-28 11:10:54 -07005820 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305821 struct target_psoc_info *tgt_hdl;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305822 struct wlan_psoc_target_capability_info *tgt_cap_info;
5823 target_resource_config *wlan_res_cfg;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305824 struct wmi_unified *wmi_handle;
5825 uint32_t *service_bitmap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005826
5827 WMA_LOGD("%s: Enter", __func__);
5828
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305829 if (!handle) {
5830 WMA_LOGE("%s: wma_handle passed is NULL", __func__);
5831 return -EINVAL;
5832 }
5833
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305834 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5835 if (!tgt_hdl) {
5836 WMA_LOGE("%s: target psoc info is NULL", __func__);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305837 return -EINVAL;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305838 }
5839
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305840 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
5841 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305842 service_bitmap = target_psoc_get_service_bitmap(tgt_hdl);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305843
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005844 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305845 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005846 WMA_LOGE("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305847 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848 }
5849
5850 ev = param_buf->fixed_param;
5851 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005852 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305853 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005854 }
5855
Sourav Mohapatracf632572018-04-02 11:01:35 +05305856 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305857 if (!wmi_handle) {
5858 WMA_LOGE("%s: wmi handle is NULL", __func__);
5859 return -EINVAL;
5860 }
5861
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005862 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863
Amar Singhal7b038ca2017-10-04 13:38:39 -07005864 if (ev->num_dbs_hw_modes > param_buf->num_wlan_dbs_hw_mode_list) {
5865 WMA_LOGE("FW dbs_hw_mode entry %d more than value %d in TLV hdr",
5866 ev->num_dbs_hw_modes,
5867 param_buf->num_wlan_dbs_hw_mode_list);
5868 return -EINVAL;
5869 }
5870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
5872 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
Arif Hussain157263f2018-10-03 13:07:15 -07005873
5874 /* Continuing with the rest of the processing,
5875 * even if memory allocation fails
5876 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005877 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305878 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879 wma_handle->num_dbs_hw_modes);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305880
5881 if (wma_handle->hw_mode.hw_mode_list)
5882 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
5883 ev_wlan_dbs_hw_mode_list,
5884 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
5885 wma_handle->num_dbs_hw_modes));
5886
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005887 policy_mgr_init_dbs_hw_mode(wma_handle->psoc,
5888 ev->num_dbs_hw_modes, ev_wlan_dbs_hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 wma_dump_dbs_hw_mode(wma_handle);
5890
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305891 /* Initializes the fw_mode and scan_config to zero.
5892 * If ext service ready event is present it will set
5893 * the actual values of these two params.
5894 * This is to ensure that no garbage values would be
5895 * present in the absence of ext service ready event.
5896 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305897 wma_init_scan_fw_mode_config(wma_handle->psoc, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305899 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305900 sizeof(HAL_REG_CAPABILITIES));
5901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305904 wma_handle->new_hw_mode_index = tgt_cap_info->default_dbs_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005905 policy_mgr_update_new_hw_mode_index(wma_handle->psoc,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305906 tgt_cap_info->default_dbs_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005907
5908 WMA_LOGD("%s: Firmware default hw mode index : %d",
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305909 __func__, tgt_cap_info->default_dbs_hw_mode_index);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005910 WMA_LOGI("%s: Firmware build version : %08x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005911 __func__, ev->fw_build_vers);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305912 WMA_LOGD("FW fine time meas cap: 0x%x",
5913 tgt_cap_info->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005914
Ryan Hsuc6918552018-05-16 13:29:59 -07005915 wma_handle->hw_bd_id = ev->hw_bd_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005916
Ryan Hsuc6918552018-05-16 13:29:59 -07005917 wma_handle->hw_bd_info[BDF_VERSION] =
5918 WMI_GET_BDF_VERSION(ev->hw_bd_info);
5919 wma_handle->hw_bd_info[REF_DESIGN_ID] =
5920 WMI_GET_REF_DESIGN(ev->hw_bd_info);
5921 wma_handle->hw_bd_info[CUSTOMER_ID] =
5922 WMI_GET_CUSTOMER_ID(ev->hw_bd_info);
5923 wma_handle->hw_bd_info[PROJECT_ID] =
5924 WMI_GET_PROJECT_ID(ev->hw_bd_info);
5925 wma_handle->hw_bd_info[BOARD_DATA_REV] =
5926 WMI_GET_BOARD_DATA_REV(ev->hw_bd_info);
5927
5928 WMA_LOGI("%s: Board id: %x, Board version: %x %x %x %x %x",
5929 __func__, wma_handle->hw_bd_id,
5930 wma_handle->hw_bd_info[BDF_VERSION],
5931 wma_handle->hw_bd_info[REF_DESIGN_ID],
5932 wma_handle->hw_bd_info[CUSTOMER_ID],
5933 wma_handle->hw_bd_info[PROJECT_ID],
5934 wma_handle->hw_bd_info[BOARD_DATA_REV]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005935
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305937 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305938 service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05305940
Leo Chang96464902016-10-28 11:10:54 -07005941 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(soc,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005942 wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi));
Leo Chang96464902016-10-28 11:10:54 -07005943 cdp_set_desc_global_pool_size(soc, ev->num_msdu_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944 /* SWBA event handler for beacon transmission */
Harprit Chhabada98225f62018-12-11 15:29:55 -08005945 status = wma_register_swba_events(wma_handle->wmi_handle);
5946
Dustin Brown7678b6c2018-03-07 13:00:52 -08005947 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948 WMA_LOGE("Failed to register swba beacon event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305949 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005950 }
5951#ifdef WLAN_FEATURE_LPSS
5952 wma_handle->lpss_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005953 wmi_service_enabled(wmi_handle, wmi_service_lpass);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954#endif /* WLAN_FEATURE_LPSS */
5955
5956 /*
5957 * This Service bit is added to check for ARP/NS Offload
5958 * support for LL/HL targets
5959 */
5960 wma_handle->ap_arpns_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005961 wmi_service_enabled(wmi_handle, wmi_service_ap_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005962
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305963 wma_update_ra_limit(wma_handle);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005964
5965 if (wmi_service_enabled(wmi_handle, wmi_service_csa_offload)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 WMA_LOGD("%s: FW support CSA offload capability", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005967 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305968 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305969 wmi_csa_handling_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305970 wma_csa_offload_handler,
5971 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005972 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005973 WMA_LOGE("Failed to register CSA offload event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305974 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 }
5976 }
5977
Dustin Brown7678b6c2018-03-07 13:00:52 -08005978 if (wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005979 WMA_LOGD("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005980 /*
5981 * Register Tx completion event handler for MGMT Tx over WMI
5982 * case
5983 */
5984 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305985 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305986 wmi_mgmt_tx_completion_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305987 wma_mgmt_tx_completion_handler,
5988 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005989 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305991 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005992 }
5993
Nirav Shah20489972016-06-16 19:20:28 +05305994 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305995 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305996 wmi_mgmt_tx_bundle_completion_event_id,
Nirav Shah20489972016-06-16 19:20:28 +05305997 wma_mgmt_tx_bundle_completion_handler,
5998 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005999 if (QDF_IS_STATUS_ERROR(status)) {
Nirav Shah20489972016-06-16 19:20:28 +05306000 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306001 goto free_hw_mode_list;
Nirav Shah20489972016-06-16 19:20:28 +05306002 }
6003
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006004 } else {
6005 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
6006 }
Dustin Brown7678b6c2018-03-07 13:00:52 -08006007
Mukul Sharma44746042018-05-24 17:30:52 +05306008 status = wma_register_gtk_offload_event(wma_handle);
6009 if (QDF_IS_STATUS_ERROR(status)) {
6010 WMA_LOGE("Failed to register GTK offload event cb");
6011 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306014 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05306015 wmi_tbttoffset_update_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05306016 wma_tbttoffset_update_event_handler,
6017 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08006018 if (QDF_IS_STATUS_ERROR(status)) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006019 WMA_LOGE("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306020 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021 }
6022
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306023 if (wmi_service_enabled(wma_handle->wmi_handle,
6024 wmi_service_rcpi_support)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05306025 /* register for rcpi response event */
6026 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306027 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05306028 wmi_update_rcpi_event_id,
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05306029 wma_rcpi_event_handler,
6030 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08006031 if (QDF_IS_STATUS_ERROR(status)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05306032 WMA_LOGE("Failed to register RCPI event handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306033 goto free_hw_mode_list;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05306034 }
6035 wma_handle->rcpi_enabled = true;
6036 }
6037
Govind Singhefc5ccd2016-04-25 11:11:55 +05306038 /* mac_id is replaced with pdev_id in converged firmware to have
6039 * multi-radio support. In order to maintain backward compatibility
6040 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
6041 * in service bitmap from FW and host needs to set use_pdev_id in
6042 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
6043 * service is not set, then host shall not expect MAC ID from FW in
6044 * VDEV START RESPONSE event and host shall use PDEV ID.
6045 */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306046 if (wmi_service_enabled(wmi_handle, wmi_service_deprecated_replace))
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306047 wlan_res_cfg->use_pdev_id = true;
Govind Singhefc5ccd2016-04-25 11:11:55 +05306048 else
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306049 wlan_res_cfg->use_pdev_id = false;
Govind Singhefc5ccd2016-04-25 11:11:55 +05306050
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306051 wlan_res_cfg->max_num_dbs_scan_duty_cycle = CDS_DBS_SCAN_CLIENTS_MAX;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05306052
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006053 /* Initialize the log supported event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306054 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05306055 wmi_diag_event_id_log_supported_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05306056 wma_log_supported_evt_handler,
6057 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08006058 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 WMA_LOGE("Failed to register log supported event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306060 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006061 }
6062
Leo Chang96464902016-10-28 11:10:54 -07006063 cdp_mark_first_wakeup_packet(soc,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306064 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306065 wmi_service_mark_first_wakeup_packet));
Arif Hussaind54b62c2018-03-01 13:31:37 -08006066 wma_handle->is_dfs_offloaded =
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05306067 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306068 wmi_service_dfs_phyerr_offload);
Arif Hussaindb6e4e92018-06-01 16:39:15 -07006069
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07006070 wma_handle->nan_datapath_enabled =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306071 wmi_service_enabled(wma_handle->wmi_handle,
6072 wmi_service_nan_data);
Dustin Brown06259e52018-02-28 16:00:02 -08006073
6074 wma_set_component_caps(wma_handle->psoc);
6075
Dustin Brownb9987af2018-03-01 17:15:11 -08006076 wma_update_fw_config(wma_handle->psoc, tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077
Dustin Brown7678b6c2018-03-07 13:00:52 -08006078 status = wmi_unified_save_fw_version_cmd(wmi_handle, param_buf);
6079 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhf25a0f12016-03-08 16:09:48 +05306080 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306081 goto free_hw_mode_list;
Govind Singhf25a0f12016-03-08 16:09:48 +05306082 }
6083
Zhu Jianmin2d87a1c2018-05-31 11:22:23 +08006084 if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) {
6085 status = qdf_mc_timer_start(
6086 &wma_handle->service_ready_ext_timer,
6087 WMA_SERVICE_READY_EXT_TIMEOUT);
6088 if (QDF_IS_STATUS_ERROR(status))
6089 WMA_LOGE("Failed to start the service ready ext timer");
6090 }
Dustin Brown7678b6c2018-03-07 13:00:52 -08006091 wma_handle->tx_bfee_8ss_enabled =
6092 wmi_service_enabled(wmi_handle, wmi_service_8ss_tx_bfee);
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05306093
gaurank kathpalia5fcefa92018-10-24 15:03:15 +05306094 wma_handle->dynamic_nss_chains_support = wmi_service_enabled(wmi_handle,
6095 wmi_service_per_vdev_chain_support);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306096 target_psoc_set_num_radios(tgt_hdl, 1);
6097
Govind Singhd76a5b02016-03-08 15:12:14 +05306098 return 0;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05306099
6100free_hw_mode_list:
6101 if (wma_handle->hw_mode.hw_mode_list) {
6102 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
6103 wma_handle->hw_mode.hw_mode_list = NULL;
6104 WMA_LOGD("%s: DBS list is freed", __func__);
6105 }
6106
6107 return -EINVAL;
6108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006109}
6110
6111/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07006112 * wma_get_phyid_for_given_band() - to get phyid for band
6113 *
6114 * @wma_handle: Pointer to wma handle
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306115* @tgt_hdl: target psoc information
Krunal Soni0193b6f2016-08-15 15:53:43 -07006116 * @band: enum value of for 2G or 5G band
6117 * @phyid: Pointer to phyid which needs to be filled
6118 *
6119 * This API looks in to the map to find out which particular phy supports
6120 * provided band and return the idx (also called phyid) of that phy. Caller
6121 * use this phyid to fetch various caps of that phy
6122 *
6123 * Return: QDF_STATUS
6124 */
6125static QDF_STATUS wma_get_phyid_for_given_band(
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006126 tp_wma_handle wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306127 struct target_psoc_info *tgt_hdl,
Krunal Soni0193b6f2016-08-15 15:53:43 -07006128 enum cds_band_type band, uint8_t *phyid)
6129{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306130 uint8_t idx, i, num_radios;
6131 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006132
6133 if (!wma_handle) {
6134 WMA_LOGE("Invalid wma handle");
6135 return QDF_STATUS_E_FAILURE;
6136 }
6137
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306138 idx = 0;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006139 *phyid = idx;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306140 num_radios = target_psoc_get_num_radios(tgt_hdl);
6141 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006142
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306143 for (i = 0; i < num_radios; i++) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006144 if ((band == CDS_BAND_2GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306145 (WLAN_2G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006146 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006147 WMA_LOGD("Select 2G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006148 return QDF_STATUS_SUCCESS;
6149 } else if ((band == CDS_BAND_5GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306150 (WLAN_5G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006151 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006152 WMA_LOGD("Select 5G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006153 return QDF_STATUS_SUCCESS;
6154 }
6155 }
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006156 WMA_LOGD("Using default single hw mode phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07006157 return QDF_STATUS_SUCCESS;
6158}
6159
6160/**
6161 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
6162 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
6163 * @hw_mode: Provided hardware mode
6164 * @band: Provide band i.e. 2G or 5G
6165 *
6166 * This API finds cap which suitable for provided hw mode and band. If user
6167 * is provides some invalid hw mode then it will automatically falls back to
6168 * default hw mode
6169 *
6170 * Return: QDF_STATUS
6171 */
6172QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
6173 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
6174{
6175 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306176 struct target_psoc_info *tgt_hdl;
6177 int ht_cap_info, vht_cap_info;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306178 uint8_t phyid, our_hw_mode = hw_mode, num_hw_modes;
6179 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006180
6181 if (!wma_handle) {
6182 WMA_LOGE("Invalid wma handle");
6183 return QDF_STATUS_E_FAILURE;
6184 }
6185
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306186 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6187 if (!tgt_hdl) {
6188 WMA_LOGE("%s: target psoc info is NULL", __func__);
6189 return -EINVAL;
6190 }
6191
6192 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
6193 vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306194 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6195 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306196
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306197 if (!num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08006198 WMA_LOGD("Invalid number of hw modes, use legacy HT/VHT caps");
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306199 caps_per_phy->ht_2g = ht_cap_info;
6200 caps_per_phy->ht_5g = ht_cap_info;
6201 caps_per_phy->vht_2g = vht_cap_info;
6202 caps_per_phy->vht_5g = vht_cap_info;
jiad080abce2017-08-08 15:17:39 +08006203 /* legacy platform doesn't support HE IE */
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006204 caps_per_phy->he_2g[0] = 0;
6205 caps_per_phy->he_2g[1] = 0;
6206 caps_per_phy->he_5g[0] = 0;
6207 caps_per_phy->he_5g[1] = 0;
jiad080abce2017-08-08 15:17:39 +08006208
6209 return QDF_STATUS_SUCCESS;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006210 }
6211
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006212 if (!policy_mgr_is_dbs_enable(wma_handle->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006213 our_hw_mode = HW_MODE_DBS_NONE;
6214
6215 if (!caps_per_phy) {
6216 WMA_LOGE("Invalid caps pointer");
6217 return QDF_STATUS_E_FAILURE;
6218 }
6219
Krunal Soni0193b6f2016-08-15 15:53:43 -07006220 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306221 wma_get_phyid_for_given_band(wma_handle, tgt_hdl, band, &phyid)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006222 WMA_LOGE("Invalid phyid");
6223 return QDF_STATUS_E_FAILURE;
6224 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006225
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306226 caps_per_phy->ht_2g = mac_phy_cap[phyid].ht_cap_info_2G;
6227 caps_per_phy->ht_5g = mac_phy_cap[phyid].ht_cap_info_5G;
6228 caps_per_phy->vht_2g = mac_phy_cap[phyid].vht_cap_info_2G;
6229 caps_per_phy->vht_5g = mac_phy_cap[phyid].vht_cap_info_5G;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006230 qdf_mem_copy(caps_per_phy->he_2g, mac_phy_cap[phyid].he_cap_info_2G,
6231 sizeof(caps_per_phy->he_2g));
6232 qdf_mem_copy(caps_per_phy->he_5g, mac_phy_cap[phyid].he_cap_info_5G,
6233 sizeof(caps_per_phy->he_5g));
Krunal Soni0193b6f2016-08-15 15:53:43 -07006234
Naveen Rawat98322472018-03-06 10:29:42 -08006235 caps_per_phy->tx_chain_mask_2G = mac_phy_cap->tx_chain_mask_2G;
6236 caps_per_phy->rx_chain_mask_2G = mac_phy_cap->rx_chain_mask_2G;
6237 caps_per_phy->tx_chain_mask_5G = mac_phy_cap->tx_chain_mask_5G;
6238 caps_per_phy->rx_chain_mask_5G = mac_phy_cap->rx_chain_mask_5G;
6239
Krunal Soni0193b6f2016-08-15 15:53:43 -07006240 return QDF_STATUS_SUCCESS;
6241}
6242
6243/**
6244 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
6245 *
6246 * @channel: Channel number for which it needs to check if rx ldpc is enabled
6247 *
6248 * This API takes channel number as argument and takes default hw mode as DBS
6249 * to check if rx LDPC support is enabled for that channel or no
6250 */
6251bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
6252{
jiad080abce2017-08-08 15:17:39 +08006253 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306254 struct target_psoc_info *tgt_hdl;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006255 struct wma_caps_per_phy caps_per_phy = {0};
6256 enum cds_band_type band;
6257 bool status;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306258 uint8_t num_hw_modes;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006259
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006260 if (!wma_handle) {
6261 WMA_LOGE("Invalid wma handle");
6262 return false;
6263 }
6264
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306265 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6266 if (!tgt_hdl) {
6267 WMA_LOGE("Target handle is NULL");
6268 return QDF_STATUS_E_FAILURE;
6269 }
6270
6271 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6272
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006273 if (!WLAN_REG_IS_24GHZ_CH(channel))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006274 band = CDS_BAND_5GHZ;
6275 else
6276 band = CDS_BAND_2GHZ;
6277
6278 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
6279 &caps_per_phy,
6280 HW_MODE_DBS, band)) {
6281 return false;
6282 }
jiad080abce2017-08-08 15:17:39 +08006283
6284 /*
6285 * Legacy platforms like Rome set WMI_HT_CAP_LDPC to specify RX LDPC
6286 * capability. But new platforms like Helium set WMI_HT_CAP_RX_LDPC
6287 * instead.
6288 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306289 if (0 == num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08006290 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_LDPC));
6291 } else {
6292 if (WLAN_REG_IS_24GHZ_CH(channel))
6293 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
6294 else
6295 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
6296 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006297
6298 return status;
6299}
6300
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006301/**
6302 * wma_print_mac_phy_capabilities() - Prints MAC PHY capabilities
6303 * @cap: pointer to WMI_MAC_PHY_CAPABILITIES
6304 * @index: MAC_PHY index
6305 *
6306 * Return: none
6307 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306308static void wma_print_mac_phy_capabilities(struct wlan_psoc_host_mac_phy_caps
6309 *cap, int index)
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006310{
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006311 uint32_t mac_2G[PSOC_HOST_MAX_MAC_SIZE];
6312 uint32_t mac_5G[PSOC_HOST_MAX_MAC_SIZE];
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006313 uint32_t phy_2G[WMI_MAX_HECAP_PHY_SIZE];
6314 uint32_t phy_5G[WMI_MAX_HECAP_PHY_SIZE];
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306315 struct wlan_psoc_host_ppe_threshold ppet_2G, ppet_5G;
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006316
Dustin Brown576eea42018-06-21 12:38:21 -07006317 WMA_LOGD("\t: index [%d]", index);
6318 WMA_LOGD("\t: cap for hw_mode_id[%d]", cap->hw_mode_id);
6319 WMA_LOGD("\t: pdev_id[%d]", cap->pdev_id);
6320 WMA_LOGD("\t: phy_id[%d]", cap->phy_id);
6321 WMA_LOGD("\t: supports_11b[%d]", cap->supports_11b);
6322 WMA_LOGD("\t: supports_11g[%d]", cap->supports_11g);
6323 WMA_LOGD("\t: supports_11a[%d]", cap->supports_11a);
6324 WMA_LOGD("\t: supports_11n[%d]", cap->supports_11n);
6325 WMA_LOGD("\t: supports_11ac[%d]", cap->supports_11ac);
6326 WMA_LOGD("\t: supports_11ax[%d]", cap->supports_11ax);
6327 WMA_LOGD("\t: supported_bands[%d]", cap->supported_bands);
6328 WMA_LOGD("\t: ampdu_density[%d]", cap->ampdu_density);
6329 WMA_LOGD("\t: max_bw_supported_2G[%d]", cap->max_bw_supported_2G);
6330 WMA_LOGD("\t: ht_cap_info_2G[%d]", cap->ht_cap_info_2G);
6331 WMA_LOGD("\t: vht_cap_info_2G[%d]", cap->vht_cap_info_2G);
6332 WMA_LOGD("\t: vht_supp_mcs_2G[%d]", cap->vht_supp_mcs_2G);
6333 WMA_LOGD("\t: tx_chain_mask_2G[%d]", cap->tx_chain_mask_2G);
6334 WMA_LOGD("\t: rx_chain_mask_2G[%d]", cap->rx_chain_mask_2G);
6335 WMA_LOGD("\t: max_bw_supported_5G[%d]", cap->max_bw_supported_5G);
6336 WMA_LOGD("\t: ht_cap_info_5G[%d]", cap->ht_cap_info_5G);
6337 WMA_LOGD("\t: vht_cap_info_5G[%d]", cap->vht_cap_info_5G);
6338 WMA_LOGD("\t: vht_supp_mcs_5G[%d]", cap->vht_supp_mcs_5G);
6339 WMA_LOGD("\t: tx_chain_mask_5G[%d]", cap->tx_chain_mask_5G);
6340 WMA_LOGD("\t: rx_chain_mask_5G[%d]", cap->rx_chain_mask_5G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006341 WMA_LOGD("\t: he_cap_info_2G[0][%08x]", cap->he_cap_info_2G[0]);
6342 WMA_LOGD("\t: he_cap_info_2G[1][%08x]", cap->he_cap_info_2G[1]);
Dustin Brown576eea42018-06-21 12:38:21 -07006343 WMA_LOGD("\t: he_supp_mcs_2G[%08x]", cap->he_supp_mcs_2G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006344 WMA_LOGD("\t: he_cap_info_5G[0][%08x]", cap->he_cap_info_5G[0]);
6345 WMA_LOGD("\t: he_cap_info_5G[1][%08x]", cap->he_cap_info_5G[1]);
Dustin Brown576eea42018-06-21 12:38:21 -07006346 WMA_LOGD("\t: he_supp_mcs_5G[%08x]", cap->he_supp_mcs_5G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006347 qdf_mem_copy(mac_2G, cap->he_cap_info_2G, sizeof(mac_2G));
6348 qdf_mem_copy(mac_5G, cap->he_cap_info_5G, sizeof(mac_5G));
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006349 qdf_mem_copy(phy_2G, cap->he_cap_phy_info_2G,
6350 WMI_MAX_HECAP_PHY_SIZE * 4);
6351 qdf_mem_copy(phy_5G, cap->he_cap_phy_info_5G,
6352 WMI_MAX_HECAP_PHY_SIZE * 4);
6353 ppet_2G = cap->he_ppet2G;
6354 ppet_5G = cap->he_ppet5G;
6355
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006356 wma_print_he_mac_cap_w1(mac_2G[0]);
6357 wma_print_he_mac_cap_w2(mac_2G[1]);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006358 wma_print_he_phy_cap(phy_2G);
6359 wma_print_he_ppet(&ppet_2G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006360 wma_print_he_mac_cap_w1(mac_5G[0]);
6361 wma_print_he_mac_cap_w1(mac_5G[1]);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006362 wma_print_he_phy_cap(phy_5G);
6363 wma_print_he_ppet(&ppet_5G);
6364}
Krunal Soni0193b6f2016-08-15 15:53:43 -07006365
6366/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006367 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306368 * @tgt_info: target related info
Krunal Soni2e48d012016-05-02 16:55:26 -07006369 *
6370 * This function prints all the caps populater per hw mode and per PHY
6371 *
6372 * Return: none
6373 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306374static void wma_print_populate_soc_caps(struct target_psoc_info *tgt_hdl)
Krunal Soni2e48d012016-05-02 16:55:26 -07006375{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006376 int i, num_hw_modes, total_mac_phy_cnt;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306377 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap, *tmp;
6378
6379 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006380 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006381
6382 /* print number of hw modes */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306383 WMA_LOGD("%s: num of hw modes [%d]", __func__, num_hw_modes);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006384 WMA_LOGD("%s: num mac_phy_cnt [%d]", __func__, total_mac_phy_cnt);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306385 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006386 WMA_LOGD("%s: <====== HW mode cap printing starts ======>", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07006387 /* print cap of each hw mode */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006388 for (i = 0; i < total_mac_phy_cnt; i++) {
Lin Bai772fbaf2018-07-04 14:20:55 +08006389 WMA_LOGD("====>: hw mode id[%d], phy id[%d]",
6390 mac_phy_cap[i].hw_mode_id,
6391 mac_phy_cap[i].phy_id);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006392 tmp = &mac_phy_cap[i];
6393 wma_print_mac_phy_capabilities(tmp, i);
Krunal Soni2e48d012016-05-02 16:55:26 -07006394 }
Dustin Brown576eea42018-06-21 12:38:21 -07006395 WMA_LOGD("%s: <====== HW mode cap printing ends ======>\n", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07006396}
6397
6398/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306399 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
6400 * in terms of hw_mode_bandwidth
6401 * @width: bandwidth in terms of wmi_channel_width
6402 *
6403 * This function returns the bandwidth in terms of hw_mode_bandwidth.
6404 *
6405 * Return: BW in terms of hw_mode_bandwidth.
6406 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006407static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306408 wmi_channel_width width)
6409{
6410 switch (width) {
6411 case WMI_CHAN_WIDTH_20:
6412 return HW_MODE_20_MHZ;
6413 case WMI_CHAN_WIDTH_40:
6414 return HW_MODE_40_MHZ;
6415 case WMI_CHAN_WIDTH_80:
6416 return HW_MODE_80_MHZ;
6417 case WMI_CHAN_WIDTH_160:
6418 return HW_MODE_160_MHZ;
6419 case WMI_CHAN_WIDTH_80P80:
6420 return HW_MODE_80_PLUS_80_MHZ;
6421 case WMI_CHAN_WIDTH_5:
6422 return HW_MODE_5_MHZ;
6423 case WMI_CHAN_WIDTH_10:
6424 return HW_MODE_10_MHZ;
6425 default:
6426 return HW_MODE_BW_NONE;
6427 }
6428
6429 return HW_MODE_BW_NONE;
6430}
6431
6432/**
6433 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
6434 * supported from the capabilities.
6435 * @caps: PHY capability
6436 * @info: param to store TX-RX stream and BW information
6437 *
6438 * This function will calculate TX-RX stream and bandwidth supported
6439 * as per the PHY capability, and assign to mac_ss_bw_info.
6440 *
6441 * Return: none
6442 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306443static void wma_get_hw_mode_params(struct wlan_psoc_host_mac_phy_caps *caps,
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306444 struct mac_ss_bw_info *info)
6445{
6446 if (!caps) {
6447 WMA_LOGE("%s: Invalid capabilities", __func__);
6448 return;
6449 }
6450
6451 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
6452 QDF_MAX(caps->tx_chain_mask_2G,
6453 caps->tx_chain_mask_5G));
6454 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
6455 QDF_MAX(caps->rx_chain_mask_2G,
6456 caps->rx_chain_mask_5G));
6457 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
6458 QDF_MAX(caps->max_bw_supported_2G,
6459 caps->max_bw_supported_5G));
6460}
6461
6462/**
6463 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
6464 * DBS in hw_mode_list
6465 * @wma_handle: pointer to wma global structure
6466 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
6467 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
6468 * @pos: refers to hw_mode_index
6469 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306470 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306471 *
6472 * This function sets TX-RX stream, bandwidth and DBS mode in
6473 * hw_mode_list.
6474 *
6475 * Return: none
6476 */
6477static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
6478 struct mac_ss_bw_info mac0_ss_bw_info,
6479 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306480 uint32_t pos, uint32_t dbs_mode,
6481 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306482{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306483 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306484 wma_handle->hw_mode.hw_mode_list[pos],
6485 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306486 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306487 wma_handle->hw_mode.hw_mode_list[pos],
6488 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306489 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306490 wma_handle->hw_mode.hw_mode_list[pos],
6491 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306492 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306493 wma_handle->hw_mode.hw_mode_list[pos],
6494 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306495 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306496 wma_handle->hw_mode.hw_mode_list[pos],
6497 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306498 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306499 wma_handle->hw_mode.hw_mode_list[pos],
6500 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306501 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306502 wma_handle->hw_mode.hw_mode_list[pos],
6503 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306504 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306505 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306506 HW_MODE_AGILE_DFS_NONE);
6507 WMA_HW_MODE_SBS_MODE_SET(
6508 wma_handle->hw_mode.hw_mode_list[pos],
6509 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306510}
6511
6512/**
6513 * wma_update_hw_mode_list() - updates hw_mode_list
6514 * @wma_handle: pointer to wma global structure
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306515 * @tgt_hdl - target psoc information
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306516 *
6517 * This function updates hw_mode_list with tx_streams, rx_streams,
6518 * bandwidth, dbs and agile dfs for each hw_mode.
6519 *
6520 * Returns: 0 for success else failure.
6521 */
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306522static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle,
6523 struct target_psoc_info *tgt_hdl)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306524{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306525 struct wlan_psoc_host_mac_phy_caps *tmp, *mac_phy_cap;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306526 uint32_t i, hw_config_type, j = 0;
6527 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306528 struct mac_ss_bw_info mac0_ss_bw_info = {0};
6529 struct mac_ss_bw_info mac1_ss_bw_info = {0};
Krunal Sonica50b452017-08-04 22:24:59 -07006530 WMI_PHY_CAPABILITY new_supported_band = 0;
6531 bool supported_band_update_failure = false;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306532 struct wlan_psoc_target_capability_info *tgt_cap_info;
6533 int num_hw_modes;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306534
6535 if (!wma_handle) {
6536 WMA_LOGE("%s: Invalid wma handle", __func__);
6537 return QDF_STATUS_E_FAILURE;
6538 }
6539
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306540 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6541 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
6542 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306543 /*
6544 * This list was updated as part of service ready event. Re-populate
6545 * HW mode list from the device capabilities.
6546 */
6547 if (wma_handle->hw_mode.hw_mode_list) {
6548 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
6549 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006550 WMA_LOGD("%s: DBS list is freed", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306551 }
6552
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306553 wma_handle->hw_mode.hw_mode_list =
6554 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306555 num_hw_modes);
Wu Gaoe4c142d2018-11-06 11:54:32 +08006556 if (!wma_handle->hw_mode.hw_mode_list) {
6557 wma_handle->num_dbs_hw_modes = 0;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306558 return QDF_STATUS_E_FAILURE;
Wu Gaoe4c142d2018-11-06 11:54:32 +08006559 }
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306560
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08006561 WMA_LOGD("%s: Updated HW mode list: Num modes:%d",
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306562 __func__, num_hw_modes);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306563
Wu Gaoe4c142d2018-11-06 11:54:32 +08006564 wma_handle->num_dbs_hw_modes = num_hw_modes;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306565 for (i = 0; i < num_hw_modes; i++) {
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306566 /* Update for MAC0 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306567 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306568 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306569 hw_config_type = mac_phy_cap[j].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306570 dbs_mode = HW_MODE_DBS_NONE;
6571 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306572 mac1_ss_bw_info.mac_tx_stream = 0;
6573 mac1_ss_bw_info.mac_rx_stream = 0;
6574 mac1_ss_bw_info.mac_bw = 0;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306575 if (wma_update_supported_bands(tmp->supported_bands,
6576 &new_supported_band)
6577 != QDF_STATUS_SUCCESS)
Krunal Sonica50b452017-08-04 22:24:59 -07006578 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306579
6580 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
6581 if ((hw_config_type == WMI_HW_MODE_DBS) ||
6582 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6583 (hw_config_type == WMI_HW_MODE_SBS)) {
6584 /* Update for MAC1 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306585 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306586 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306587 if (hw_config_type == WMI_HW_MODE_DBS)
6588 dbs_mode = HW_MODE_DBS;
6589 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6590 (hw_config_type == WMI_HW_MODE_SBS))
6591 sbs_mode = HW_MODE_SBS;
Krunal Sonica50b452017-08-04 22:24:59 -07006592 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306593 wma_update_supported_bands(tmp->supported_bands,
Krunal Sonica50b452017-08-04 22:24:59 -07006594 &new_supported_band))
6595 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306596 }
6597
6598 /* Updating HW mode list */
6599 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306600 mac1_ss_bw_info, i, dbs_mode,
6601 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306602 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006603
Krunal Sonica50b452017-08-04 22:24:59 -07006604 /* overwrite phy_capability which we got from service ready event */
6605 if (!supported_band_update_failure) {
6606 WMA_LOGD("%s: updating supported band from old[%d] to new[%d]",
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306607 __func__, target_if_get_phy_capability(tgt_hdl),
Krunal Sonica50b452017-08-04 22:24:59 -07006608 new_supported_band);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306609 target_if_set_phy_capability(tgt_hdl, new_supported_band);
Krunal Sonica50b452017-08-04 22:24:59 -07006610 }
6611
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006612 if (QDF_STATUS_SUCCESS !=
Krunal Sonica50b452017-08-04 22:24:59 -07006613 policy_mgr_update_hw_mode_list(wma_handle->psoc,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306614 tgt_hdl))
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006615 WMA_LOGE("%s: failed to update policy manager", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306616 wma_dump_dbs_hw_mode(wma_handle);
6617 return QDF_STATUS_SUCCESS;
6618}
6619
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006620static void wma_init_wifi_pos_dma_rings(t_wma_handle *wma_handle,
6621 uint8_t num_mac, void *buf)
6622{
6623 struct hif_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006624 void *hal_soc;
6625
6626 if (!hif_ctx) {
6627 WMA_LOGE("invalid hif context");
6628 return;
6629 }
6630
6631 hal_soc = hif_get_hal_handle(hif_ctx);
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006632
6633 wifi_pos_init_cir_cfr_rings(wma_handle->psoc, hal_soc, num_mac, buf);
6634}
6635
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306636/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006637 * wma_populate_soc_caps() - populate entire SOC's capabilities
6638 * @wma_handle: pointer to wma global structure
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306639 * @tgt_hdl: target psoc information
Krunal Soni2e48d012016-05-02 16:55:26 -07006640 * @param_buf: pointer to param of service ready extension event from fw
6641 *
6642 * This API populates all capabilities of entire SOC. For example,
6643 * how many number of hw modes are supported by this SOC, what are the
6644 * capabilities of each phy per hw mode, what are HAL reg capabilities per
6645 * phy.
6646 *
6647 * Return: none
6648 */
6649static void wma_populate_soc_caps(t_wma_handle *wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306650 struct target_psoc_info *tgt_hdl,
Krunal Soni2e48d012016-05-02 16:55:26 -07006651 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
6652{
Krunal Soni2e48d012016-05-02 16:55:26 -07006653
6654 WMA_LOGD("%s: Enter", __func__);
6655
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006656 wma_init_wifi_pos_dma_rings(wma_handle,
6657 param_buf->num_oem_dma_ring_caps,
6658 param_buf->oem_dma_ring_caps);
6659
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306660 wma_print_populate_soc_caps(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006661}
6662
6663/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006664 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
6665 * @handle: wma handle
6666 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05306667 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006668 *
6669 * Return: none
6670 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306671int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
6672 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006673{
6674 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6675 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
6676 wmi_service_ready_ext_event_fixed_param *ev;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306677 QDF_STATUS ret;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306678 struct target_psoc_info *tgt_hdl;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306679 uint32_t conc_scan_config_bits, fw_config_bits;
jitiphilebf3a922018-11-05 14:25:00 +05306680 struct wmi_unified *wmi_handle;
6681 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
6682 target_resource_config *wlan_res_cfg;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006684 WMA_LOGD("%s: Enter", __func__);
6685
6686 if (!wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006687 WMA_LOGE("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306688 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006689 }
6690
jitiphilebf3a922018-11-05 14:25:00 +05306691 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
6692
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306693 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6694 if (!tgt_hdl) {
6695 WMA_LOGE("%s: target psoc info is NULL", __func__);
6696 return -EINVAL;
6697 }
6698
jitiphilebf3a922018-11-05 14:25:00 +05306699 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
6701 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006702 WMA_LOGE("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306703 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006704 }
6705
6706 ev = param_buf->fixed_param;
6707 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006708 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306709 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006710 }
6711
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006712 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006713
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306714 fw_config_bits = target_if_get_fw_config_bits(tgt_hdl);
6715 conc_scan_config_bits = target_if_get_conc_scan_config_bits(tgt_hdl);
6716
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006717 WMA_LOGD("%s: Defaults: scan config:%x FW mode config:%x",
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306718 __func__, conc_scan_config_bits, fw_config_bits);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05306719
Anurag Chouhan210db072016-02-22 18:42:15 +05306720 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05306721 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006722 WMA_LOGE("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05306723 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006724 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306725 wma_populate_soc_caps(wma_handle, tgt_hdl, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006726
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306727 ret = wma_update_hw_mode_list(wma_handle, tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306728 if (QDF_IS_STATUS_ERROR(ret)) {
6729 WMA_LOGE("Failed to update hw mode list");
6730 return -EINVAL;
6731 }
6732
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006733 WMA_LOGD("WMA --> WMI_INIT_CMDID");
Mukul Sharmab10c8c72017-11-02 17:25:59 +05306734
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306735 wma_init_scan_fw_mode_config(wma_handle->psoc, conc_scan_config_bits,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306736 fw_config_bits);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306737
6738 target_psoc_set_num_radios(tgt_hdl, 1);
jitiphilebf3a922018-11-05 14:25:00 +05306739
6740 if (wmi_service_enabled(wmi_handle,
6741 wmi_service_new_htt_msg_format)) {
6742 cdp_cfg_set_new_htt_msg_format(soc, 1);
6743 wlan_res_cfg->new_htt_msg_format = true;
6744 } else {
6745 cdp_cfg_set_new_htt_msg_format(soc, 0);
6746 wlan_res_cfg->new_htt_msg_format = false;
6747 }
6748
Alok Kumar02301292018-11-28 18:10:34 +05306749 if (cfg_get(wma_handle->psoc, CFG_DP_ENABLE_PEER_UMAP_CONF_SUPPORT) &&
6750 wmi_service_enabled(wmi_handle,
6751 wmi_service_peer_unmap_cnf_support)) {
6752 wlan_res_cfg->peer_unmap_conf_support = true;
6753 cdp_cfg_set_peer_unmap_conf_support(soc, true);
6754 } else {
6755 wlan_res_cfg->peer_unmap_conf_support = false;
6756 cdp_cfg_set_peer_unmap_conf_support(soc, false);
6757 }
6758
Govind Singhd76a5b02016-03-08 15:12:14 +05306759 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006760}
6761
6762/**
6763 * wma_rx_ready_event() - event handler to process
6764 * wmi rx ready event.
6765 * @handle: wma handle
6766 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05306767 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006768 *
6769 * Return: none
6770 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306771int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
6772 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006773{
6774 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6775 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
6776 wmi_ready_event_fixed_param *ev = NULL;
6777
6778 WMA_LOGD("%s: Enter", __func__);
6779
6780 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
6781 if (!(wma_handle && param_buf)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006782 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306783 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05306784 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006785 }
6786
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006787 WMA_LOGD("WMA <-- WMI_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006788
6789 ev = param_buf->fixed_param;
6790 /* Indicate to the waiting thread that the ready
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006791 * event was received
6792 */
Naveen Rawat64e477e2016-05-20 10:34:56 -07006793 wma_handle->sub_20_support =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306794 wmi_service_enabled(wma_handle->wmi_handle,
6795 wmi_service_half_rate_quarter_rate_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006796 wma_handle->wmi_ready = true;
6797 wma_handle->wlan_init_status = ev->status;
6798
Arif Hussainbaf28b82018-06-27 15:27:44 -07006799 if (wma_handle->is_dfs_offloaded)
6800 wmi_unified_dfs_phyerr_offload_en_cmd(
6801 wma_handle->wmi_handle, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006802 /* copy the mac addr */
6803 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
6804 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006805 wma_update_hdd_cfg(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006806 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05306807
6808 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809}
6810
6811/**
6812 * wma_setneedshutdown() - setting wma needshutdown flag
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006813 *
6814 * Return: none
6815 */
Jeff Johnson1f8d0a02017-09-13 08:09:05 -07006816void wma_setneedshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006817{
6818 tp_wma_handle wma_handle;
6819
6820 WMA_LOGD("%s: Enter", __func__);
6821
Anurag Chouhan6d760662016-02-20 16:05:43 +05306822 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006823
6824 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006825 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306826 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006827 return;
6828 }
6829
6830 wma_handle->needShutdown = true;
6831 WMA_LOGD("%s: Exit", __func__);
6832}
6833
6834/**
6835 * wma_needshutdown() - Is wma needs shutdown?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006836 *
6837 * Return: returns true/false
6838 */
Jeff Johnson1b5404e2017-09-13 08:04:46 -07006839bool wma_needshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006840{
6841 tp_wma_handle wma_handle;
6842
6843 WMA_LOGD("%s: Enter", __func__);
6844
Anurag Chouhan6d760662016-02-20 16:05:43 +05306845 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006846
6847 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006848 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306849 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006850 return false;
6851 }
6852
6853 WMA_LOGD("%s: Exit", __func__);
6854 return wma_handle->needShutdown;
6855}
6856
6857/**
6858 * wma_wait_for_ready_event() - wait for wma ready event
6859 * @handle: wma handle
6860 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306861 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006862 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306863QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006864{
Dustin Brown19048bd2018-07-09 10:53:18 -07006865 tp_wma_handle wma_handle = (tp_wma_handle)handle;
6866 QDF_STATUS status;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306867 struct target_psoc_info *tgt_hdl;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006868
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306869 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6870 if (!tgt_hdl) {
Dustin Brown19048bd2018-07-09 10:53:18 -07006871 wma_err("target psoc info is NULL");
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306872 return QDF_STATUS_E_INVAL;
6873 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006874
Dustin Brown19048bd2018-07-09 10:53:18 -07006875 status = qdf_wait_for_event_completion(&tgt_hdl->info.event,
6876 WMA_READY_EVENTID_TIMEOUT);
6877 if (status == QDF_STATUS_E_TIMEOUT)
6878 wma_err("Timeout waiting for FW ready event");
6879 else if (QDF_IS_STATUS_ERROR(status))
6880 wma_err("Failed to wait for FW ready event; status:%u", status);
6881 else
6882 wma_info("FW ready event received");
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306883
Dustin Brown19048bd2018-07-09 10:53:18 -07006884 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006885}
6886
6887/**
6888 * wma_set_ppsconfig() - set pps config in fw
6889 * @vdev_id: vdev id
6890 * @pps_param: pps params
6891 * @val : param value
6892 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306893 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006894 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306895QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006896 int val)
6897{
Anurag Chouhan6d760662016-02-20 16:05:43 +05306898 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899 int ret = -EIO;
6900 uint32_t pps_val;
6901
6902 if (NULL == wma) {
6903 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306904 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006905 }
6906
6907 switch (pps_param) {
6908 case WMA_VHT_PPS_PAID_MATCH:
6909 pps_val = ((val << 31) & 0xffff0000) |
6910 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
6911 goto pkt_pwr_save_config;
6912 case WMA_VHT_PPS_GID_MATCH:
6913 pps_val = ((val << 31) & 0xffff0000) |
6914 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
6915 goto pkt_pwr_save_config;
6916 case WMA_VHT_PPS_DELIM_CRC_FAIL:
6917 pps_val = ((val << 31) & 0xffff0000) |
6918 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
6919 goto pkt_pwr_save_config;
6920
6921 /* Enable the code below as and when the functionality
6922 * is supported/added in host.
6923 */
6924#ifdef NOT_YET
6925 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
6926 pps_val = ((val << 31) & 0xffff0000) |
6927 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
6928 goto pkt_pwr_save_config;
6929 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
6930 pps_val = ((val << 31) & 0xffff0000) |
6931 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
6932 goto pkt_pwr_save_config;
6933 case WMA_VHT_PPS_EOF_PAD_DELIM:
6934 pps_val = ((val << 31) & 0xffff0000) |
6935 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
6936 goto pkt_pwr_save_config;
6937 case WMA_VHT_PPS_MACADDR_MISMATCH:
6938 pps_val = ((val << 31) & 0xffff0000) |
6939 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
6940 goto pkt_pwr_save_config;
6941 case WMA_VHT_PPS_GID_NSTS_ZERO:
6942 pps_val = ((val << 31) & 0xffff0000) |
6943 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
6944 goto pkt_pwr_save_config;
6945 case WMA_VHT_PPS_RSSI_CHECK:
6946 pps_val = ((val << 31) & 0xffff0000) |
6947 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
6948 goto pkt_pwr_save_config;
6949#endif /* NOT_YET */
6950pkt_pwr_save_config:
6951 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
6952 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05306953 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006954 WMI_VDEV_PARAM_PACKET_POWERSAVE,
6955 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006956 break;
6957 default:
6958 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
6959 }
6960
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306961 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006962}
6963
6964/**
6965 * wma_process_set_mas() - Function to enable/disable MAS
6966 * @wma: Pointer to WMA handle
6967 * @mas_val: 1-Enable MAS, 0-Disable MAS
6968 *
6969 * This function enables/disables the MAS value
6970 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306971 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006972 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006973static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
6974 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006975{
6976 uint32_t val;
6977
6978 if (NULL == wma || NULL == mas_val) {
6979 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306980 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006981 }
6982
6983 val = (*mas_val);
6984
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306985 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006986 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
6987 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306988 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006989 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006990 WMA_LOGE("%s: Value is %d", __func__, val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306991 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006992}
6993
6994/**
6995 * wma_process_set_miracast() - Function to set miracast value in WMA
6996 * @wma: Pointer to WMA handle
6997 * @miracast_val: 0-Disabled,1-Source,2-Sink
6998 *
6999 * This function stores the miracast value in WMA
7000 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307001 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007002 *
7003 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007004static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
7005 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007006{
7007 if (NULL == wma || NULL == miracast_val) {
7008 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307009 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007010 }
7011
7012 wma->miracast_value = *miracast_val;
7013 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
7014
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307015 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007016}
7017
7018/**
7019 * wma_config_stats_factor() - Function to configure stats avg. factor
7020 * @wma: pointer to WMA handle
7021 * @avg_factor: stats. avg. factor passed down by userspace
7022 *
7023 * This function configures the avg. stats value in firmware
7024 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307025 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007026 *
7027 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307028static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007029 struct sir_stats_avg_factor *avg_factor)
7030{
Govind Singhd76a5b02016-03-08 15:12:14 +05307031 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007032
7033 if (NULL == wma || NULL == avg_factor) {
7034 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307035 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007036 }
7037
Govind Singhd76a5b02016-03-08 15:12:14 +05307038 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007039 avg_factor->vdev_id,
7040 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
7041 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05307042 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007043 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
7044 avg_factor->vdev_id);
7045 }
7046
7047 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
7048 avg_factor->stats_avg_factor, avg_factor->vdev_id);
7049
7050 return ret;
7051}
7052
7053/**
7054 * wma_config_guard_time() - Function to set guard time in firmware
7055 * @wma: pointer to WMA handle
7056 * @guard_time: guard time passed down by userspace
7057 *
7058 * This function configures the guard time in firmware
7059 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307060 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007061 *
7062 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307063static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007064 struct sir_guard_time_request *guard_time)
7065{
Govind Singhd76a5b02016-03-08 15:12:14 +05307066 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007067
7068 if (NULL == wma || NULL == guard_time) {
7069 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307070 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007071 }
7072
Govind Singhd76a5b02016-03-08 15:12:14 +05307073 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007074 guard_time->vdev_id,
7075 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
7076 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05307077 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007078 WMA_LOGE(" failed to set guard time for vdev_id %d",
7079 guard_time->vdev_id);
7080 }
7081
7082 WMA_LOGD("Set guard time %d for vdev_id %d",
7083 guard_time->guard_time, guard_time->vdev_id);
7084
7085 return ret;
7086}
7087
7088/**
7089 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
7090 * @wma_handle: WMA handle
7091 * @start_log: Start logging related parameters
7092 *
7093 * Send the command to the FW based on which specific logging of diag
7094 * event/log id can be started/stopped
7095 *
7096 * Return: None
7097 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007098static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
7099 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007100{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007101
7102 if (!start_log) {
7103 WMA_LOGE("%s: start_log pointer is NULL", __func__);
7104 return;
7105 }
7106 if (!wma_handle) {
7107 WMA_LOGE("%s: Invalid wma handle", __func__);
7108 return;
7109 }
7110
7111 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
7112 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
7113 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
7114 __func__, start_log->ring_id);
7115 return;
7116 }
7117
Govind Singhf25a0f12016-03-08 16:09:48 +05307118 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
7119 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007120}
7121
Poddar, Siddarth176c4362016-10-03 12:25:00 +05307122#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007123/**
7124 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
7125 * @wma_handle: WMA handle
7126 * @start_log: Struture containing the start wifi logger params
7127 *
7128 * This function is used to send the WMA commands to start/stop logging
7129 * of per packet statistics
7130 *
7131 * Return: None
7132 *
7133 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007134#ifdef REMOVE_PKT_LOG
7135static void wma_set_wifi_start_packet_stats(void *wma_handle,
7136 struct sir_wifi_start_log *start_log)
7137{
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007138}
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007139
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07007140#else
7141static void wma_set_wifi_start_packet_stats(void *wma_handle,
7142 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007143{
Komal Seelam3d202862016-02-24 18:43:24 +05307144 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007145 uint32_t log_state;
7146
7147 if (!start_log) {
7148 WMA_LOGE("%s: start_log pointer is NULL", __func__);
7149 return;
7150 }
7151 if (!wma_handle) {
7152 WMA_LOGE("%s: Invalid wma handle", __func__);
7153 return;
7154 }
7155
7156 /* No need to register for ring IDs other than packet stats */
7157 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007158 WMA_LOGD("%s: Ring id is not for per packet stats: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007159 __func__, start_log->ring_id);
7160 return;
7161 }
7162
Anurag Chouhan6d760662016-02-20 16:05:43 +05307163 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07007164 if (scn == NULL) {
7165 WMA_LOGE("%s: Invalid HIF handle", __func__);
7166 return;
7167 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007168
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007169#ifdef HELIUMPLUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007170 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05307171 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
Venkata Sharath Chandra Manchala29965172018-01-18 14:17:29 -08007172 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Venkata Sharath Chandra Manchalacd660982018-10-28 21:04:28 -07007173#elif defined(QCA_WIFI_QCA6390)
7174 log_state = ATH_PKTLOG_RCFIND | ATH_PKTLOG_RCUPDATE |
7175 ATH_PKTLOG_LITE_RX | ATH_PKTLOG_LITE_T2H;
7176#elif defined(QCA_WIFI_QCA6290)
7177 log_state = ATH_PKTLOG_LITE_RX | ATH_PKTLOG_LITE_T2H;
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007178#else
Venkata Sharath Chandra Manchalacd660982018-10-28 21:04:28 -07007179 WMA_LOGD("%s: Packet log Not supported", __func__);
7180 log_state = 0;
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07007181#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05307182 if (start_log->size != 0) {
7183 pktlog_setsize(scn, start_log->size * MEGABYTE);
7184 return;
Poddar, Siddarthab99a272017-04-10 12:53:26 +05307185 } else if (start_log->is_pktlog_buff_clear == true) {
7186 pktlog_clearbuff(scn, start_log->is_pktlog_buff_clear);
7187 return;
Poddar, Siddarth176c4362016-10-03 12:25:00 +05307188 }
7189
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007190 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08007191 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05307192 start_log->user_triggered,
7193 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007194 WMA_LOGD("%s: Enabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007195 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08007196 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05307197 start_log->user_triggered,
7198 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007199 WMA_LOGD("%s: Disabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007200 }
7201}
7202#endif
7203
7204/**
7205 * wma_send_flush_logs_to_fw() - Send log flush command to FW
7206 * @wma_handle: WMI handle
7207 *
7208 * This function is used to send the flush command to the FW,
7209 * that will flush the fw logs that are residue in the FW
7210 *
7211 * Return: None
7212 */
7213void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
7214{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307215 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007216 int ret;
7217
Govind Singhf25a0f12016-03-08 16:09:48 +05307218 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
7219 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007221
Anurag Chouhan210db072016-02-22 18:42:15 +05307222 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007223 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307224 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007225 WMA_LOGE("Failed to start the log completion timer");
7226}
7227
7228/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307229 * wma_update_wep_default_key - To update default key id
7230 * @wma: pointer to wma handler
7231 * @update_def_key: pointer to wep_update_default_key_idx
7232 *
7233 * This function makes a copy of default key index to txrx node
7234 *
7235 * Return: Success
7236 */
7237static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
7238 struct wep_update_default_key_idx *update_def_key)
7239{
7240 struct wma_txrx_node *iface =
7241 &wma->interfaces[update_def_key->session_id];
7242 iface->wep_default_key_idx = update_def_key->default_idx;
7243
7244 return QDF_STATUS_SUCCESS;
7245}
7246
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307247/**
7248 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
7249 * @wma_handle: WMA handle
7250 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
7251 *
7252 * This function is used to set Tx pkt fail count threshold,
7253 * FW will do disconnect with station once this threshold is reached.
7254 *
7255 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7256 */
7257static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007258 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307259{
7260 u_int8_t vdev_id;
7261 u_int32_t tx_fail_disconn_th;
7262 int ret = -EIO;
7263
7264 if (!wma || !wma->wmi_handle) {
7265 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
7266 return QDF_STATUS_E_INVAL;
7267 }
7268 vdev_id = tx_fail_cnt_th->session_id;
7269 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
7270 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7271 vdev_id, tx_fail_disconn_th);
7272
7273
7274 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7275 WMI_VDEV_PARAM_DISCONNECT_TH,
7276 tx_fail_disconn_th);
7277
7278 if (ret) {
7279 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
7280 return QDF_STATUS_E_FAILURE;
7281 }
7282
7283 return QDF_STATUS_SUCCESS;
7284}
7285
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307286/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307287 * wma_update_short_retry_limit() - Set retry limit for short frames
7288 * @wma_handle: WMA handle
7289 * @short_retry_limit_th: retry limir count for Short frames.
7290 *
7291 * This function is used to configure the transmission retry limit at which
7292 * short frames needs to be retry.
7293 *
7294 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7295 */
7296static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
7297 struct sme_short_retry_limit *short_retry_limit_th)
7298{
7299 uint8_t vdev_id;
7300 uint32_t short_retry_limit;
7301 int ret;
7302
7303 if (!wma || !wma->wmi_handle) {
7304 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
7305 return QDF_STATUS_E_INVAL;
7306 }
7307 vdev_id = short_retry_limit_th->session_id;
7308 short_retry_limit = short_retry_limit_th->short_retry_limit;
7309 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
7310 vdev_id, short_retry_limit);
7311
7312 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7313 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
7314 short_retry_limit);
7315
7316 if (ret) {
7317 WMA_LOGE("Failed to send short limit threshold command");
7318 return QDF_STATUS_E_FAILURE;
7319 }
7320 return QDF_STATUS_SUCCESS;
7321}
7322
7323/**
7324 * wma_update_long_retry_limit() - Set retry limit for long frames
7325 * @wma_handle: WMA handle
7326 * @long_retry_limit_th: retry limir count for long frames
7327 *
7328 * This function is used to configure the transmission retry limit at which
7329 * long frames needs to be retry
7330 *
7331 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7332 */
7333static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
7334 struct sme_long_retry_limit *long_retry_limit_th)
7335{
7336 uint8_t vdev_id;
7337 uint32_t long_retry_limit;
7338 int ret;
7339
7340 if (!wma || !wma->wmi_handle) {
7341 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
7342 return QDF_STATUS_E_INVAL;
7343 }
7344 vdev_id = long_retry_limit_th->session_id;
7345 long_retry_limit = long_retry_limit_th->long_retry_limit;
7346 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7347 vdev_id, long_retry_limit);
7348
7349 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7350 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
7351 long_retry_limit);
7352
7353 if (ret) {
7354 WMA_LOGE("Failed to send long limit threshold command");
7355 return QDF_STATUS_E_FAILURE;
7356 }
7357
7358 return QDF_STATUS_SUCCESS;
7359}
7360
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05307361/*
7362 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
7363 * @wma_handle: WMA handle
7364 * @sta_inactivity_timer: sme_sta_inactivity_timeout
7365 *
7366 * This function is used to set sta_inactivity_timeout.
7367 * If a station does not send anything in sta_inactivity_timeout seconds, an
7368 * empty data frame is sent to it in order to verify whether it is
7369 * still in range. If this frame is not ACKed, the station will be
7370 * disassociated and then deauthenticated.
7371 *
7372 * Return: None
7373 */
7374void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
7375 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
7376{
7377 uint8_t vdev_id;
7378 uint32_t max_unresponsive_time;
7379 uint32_t min_inactive_time, max_inactive_time;
7380
7381 if (!wma || !wma->wmi_handle) {
7382 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
7383 return;
7384 }
7385 vdev_id = sta_inactivity_timer->session_id;
7386 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
7387 max_inactive_time = max_unresponsive_time * TWO_THIRD;
7388 min_inactive_time = max_unresponsive_time - max_inactive_time;
7389
7390 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7391 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
7392 min_inactive_time))
7393 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
7394
7395 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7396 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
7397 max_inactive_time))
7398 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
7399
7400 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7401 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
7402 max_unresponsive_time))
7403 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
7404
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007405 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 +05307406 __func__, vdev_id,
7407 min_inactive_time, max_inactive_time,
7408 max_unresponsive_time);
7409}
7410
Yingying Tang95409972016-10-20 15:16:15 +08007411#ifdef WLAN_FEATURE_WOW_PULSE
7412
7413
7414#define WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7415WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMD_fixed_param
7416
7417
7418#define WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7419WMITLV_TAG_STRUC_wmi_wow_hostwakeup_gpio_pin_pattern_config_cmd_fixed_param
7420
7421/**
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007422 * wma_send_wow_pulse_cmd() - send wmi cmd of wow pulse cmd
7423 * information to fw.
7424 * @wma_handle: wma handler
7425 * @udp_response: wow_pulse_mode pointer
7426 *
7427 * Return: Return QDF_STATUS
7428 */
Yingying Tang95409972016-10-20 15:16:15 +08007429static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7430 struct wow_pulse_mode *wow_pulse_cmd)
7431{
7432 QDF_STATUS status = QDF_STATUS_SUCCESS;
7433 wmi_buf_t buf;
7434 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *cmd;
7435 u_int16_t len;
7436
7437 len = sizeof(*cmd);
7438 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007439 if (!buf)
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007440 return QDF_STATUS_E_NOMEM;
Yingying Tang95409972016-10-20 15:16:15 +08007441
7442 cmd = (WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *)wmi_buf_data(buf);
7443 qdf_mem_zero(cmd, len);
7444
7445 WMITLV_SET_HDR(&cmd->tlv_header,
7446 WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM,
7447 WMITLV_GET_STRUCT_TLVLEN(
7448 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM));
7449
7450 cmd->enable = wow_pulse_cmd->wow_pulse_enable;
7451 cmd->pin = wow_pulse_cmd->wow_pulse_pin;
7452 cmd->interval_low = wow_pulse_cmd->wow_pulse_interval_low;
7453 cmd->interval_high = wow_pulse_cmd->wow_pulse_interval_high;
7454 cmd->repeat_cnt = WMI_WOW_PULSE_REPEAT_CNT;
7455
7456 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7457 WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID)) {
Yingying Tang95409972016-10-20 15:16:15 +08007458 wmi_buf_free(buf);
7459 status = QDF_STATUS_E_FAILURE;
7460 }
7461
7462 WMA_LOGD("%s: Exit", __func__);
7463 return status;
7464}
7465
7466#undef WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7467#undef WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7468#undef WMI_WOW_PULSE_REPEAT_CNT
7469
7470#else
7471static inline QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7472 struct wow_pulse_mode *wow_pulse_cmd)
7473{
7474 return QDF_STATUS_E_FAILURE;
7475}
7476#endif
7477
7478
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307479/**
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307480 * wma_process_power_debug_stats_req() - Process the Chip Power stats collect
7481 * request and pass the Power stats request to Fw
7482 * @wma_handle: WMA handle
7483 *
7484 * Return: QDF_STATUS
7485 */
7486#ifdef WLAN_POWER_DEBUGFS
7487static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7488{
7489 wmi_pdev_get_chip_power_stats_cmd_fixed_param *cmd;
7490 int32_t len;
7491 wmi_buf_t buf;
7492 uint8_t *buf_ptr;
7493 int ret;
7494
7495 if (!wma_handle) {
7496 WMA_LOGE("%s: input pointer is NULL", __func__);
7497 return QDF_STATUS_E_FAILURE;
7498 }
7499
7500 len = sizeof(*cmd);
7501 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007502 if (!buf)
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307503 return QDF_STATUS_E_NOMEM;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307504
7505 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7506 cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr;
7507
7508 WMITLV_SET_HDR(&cmd->tlv_header,
7509 WMITLV_TAG_STRUC_wmi_get_chip_power_stats_cmd_fixed_param,
7510 WMITLV_GET_STRUCT_TLVLEN(
7511 wmi_pdev_get_chip_power_stats_cmd_fixed_param));
7512 cmd->pdev_id = 0;
7513
7514 WMA_LOGD("POWER_DEBUG_STATS - Get Request Params; Pdev id - %d",
7515 cmd->pdev_id);
7516 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7517 WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
7518 if (ret) {
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307519 wmi_buf_free(buf);
7520 return QDF_STATUS_E_FAILURE;
7521 }
7522 return QDF_STATUS_SUCCESS;
7523}
7524#else
7525static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7526{
7527 return QDF_STATUS_SUCCESS;
7528}
7529#endif
Arunk Khandavallica56d4b2018-11-29 15:46:00 +05307530#ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
7531static QDF_STATUS wma_process_beacon_debug_stats_req(tp_wma_handle wma_handle,
7532 uint32_t *vdev_id)
7533{
7534 wmi_vdev_get_bcn_recv_stats_cmd_fixed_param *cmd;
7535 int32_t len;
7536 wmi_buf_t buf;
7537 uint8_t *buf_ptr;
7538 int ret;
7539
7540 WMA_LOGD("%s: Enter", __func__);
7541 if (!wma_handle) {
7542 WMA_LOGE("%s: input pointer is NULL", __func__);
7543 return QDF_STATUS_E_FAILURE;
7544 }
7545
7546 len = sizeof(*cmd);
7547 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7548 if (!buf)
7549 return QDF_STATUS_E_NOMEM;
7550
7551 buf_ptr = (u_int8_t *)wmi_buf_data(buf);
7552 cmd = (wmi_vdev_get_bcn_recv_stats_cmd_fixed_param *)buf_ptr;
7553
7554 WMITLV_SET_HDR(&cmd->tlv_header,
7555 WMITLV_TAG_STRUC_wmi_get_bcn_recv_stats_fixed_param,
7556 WMITLV_GET_STRUCT_TLVLEN(
7557 wmi_vdev_get_bcn_recv_stats_cmd_fixed_param));
7558 cmd->vdev_id = *vdev_id;
7559
7560 WMA_LOGD("BEACON_DEBUG_STATS - Get Request Params; vdev id - %d",
7561 cmd->vdev_id);
7562 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7563 WMI_VDEV_GET_BCN_RECEPTION_STATS_CMDID);
7564 if (ret) {
7565 wmi_buf_free(buf);
7566 return QDF_STATUS_E_FAILURE;
7567 }
7568
7569 WMA_LOGD("%s: Exit", __func__);
7570 return QDF_STATUS_SUCCESS;
7571}
7572#else
7573static QDF_STATUS wma_process_beacon_debug_stats_req(tp_wma_handle wma_handle,
7574 uint32_t *vdev_id)
7575{
7576 return QDF_STATUS_SUCCESS;
7577}
7578#endif
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307579
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307580/**
7581 * wma_set_arp_req_stats() - process set arp stats request command to fw
7582 * @wma_handle: WMA handle
7583 * @req_buf: set srp stats request buffer
7584 *
7585 * Return: None
7586 */
7587static void wma_set_arp_req_stats(WMA_HANDLE handle,
7588 struct set_arp_stats_params *req_buf)
7589{
7590 int status;
7591 struct set_arp_stats *arp_stats;
7592 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7593
7594 if (!wma_handle || !wma_handle->wmi_handle) {
7595 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7596 __func__);
7597 return;
7598 }
Yeshwanth Sriram Guntukad5aae7f2017-11-27 14:33:51 +05307599 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7600 WMA_LOGE("vdev id not active or not valid");
7601 return;
7602 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307603
7604 arp_stats = (struct set_arp_stats *)req_buf;
7605 status = wmi_unified_set_arp_stats_req(wma_handle->wmi_handle,
7606 arp_stats);
7607 if (status != EOK)
7608 WMA_LOGE("%s: failed to set arp stats to FW",
7609 __func__);
7610}
7611
7612/**
7613 * wma_get_arp_req_stats() - process get arp stats request command to fw
7614 * @wma_handle: WMA handle
7615 * @req_buf: get srp stats request buffer
7616 *
7617 * Return: None
7618 */
7619static void wma_get_arp_req_stats(WMA_HANDLE handle,
7620 struct get_arp_stats_params *req_buf)
7621{
7622 int status;
7623 struct get_arp_stats *arp_stats;
7624 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7625
7626 if (!wma_handle || !wma_handle->wmi_handle) {
7627 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7628 __func__);
7629 return;
7630 }
Yeshwanth Sriram Guntuka3e4d96f2017-12-19 14:09:04 +05307631 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7632 WMA_LOGE("vdev id not active or not valid");
7633 return;
7634 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307635
7636 arp_stats = (struct get_arp_stats *)req_buf;
7637 status = wmi_unified_get_arp_stats_req(wma_handle->wmi_handle,
7638 arp_stats);
7639 if (status != EOK)
7640 WMA_LOGE("%s: failed to send get arp stats to FW",
7641 __func__);
7642}
7643
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307644/**
7645 * wma_set_del_pmkid_cache() - API to set/delete PMKID cache entry in fw
7646 * @handle: WMA handle
7647 * @pmk_cache: PMK cache entry
7648 *
7649 * Return: None
7650 */
7651static void wma_set_del_pmkid_cache(WMA_HANDLE handle,
7652 struct wmi_unified_pmk_cache *pmk_cache)
7653{
7654 int status;
7655 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7656
7657 if (!wma_handle || !wma_handle->wmi_handle) {
7658 WMA_LOGE("WMA is closed, cannot send set del pmkid");
7659 return;
7660 }
7661
7662 status = wmi_unified_set_del_pmkid_cache(wma_handle->wmi_handle,
7663 pmk_cache);
7664 if (status != EOK)
7665 WMA_LOGE("failed to send set/del pmkid cmd to fw");
7666}
7667
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307668/**
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307669 * wma_send_invoke_neighbor_report() - API to send invoke neighbor report
7670 * command to fw
7671 *
7672 * @handle: WMA handle
7673 * @params: Pointer to invoke neighbor report params
7674 *
7675 * Return: None
7676 */
7677static
7678void wma_send_invoke_neighbor_report(WMA_HANDLE handle,
7679 struct wmi_invoke_neighbor_report_params *params)
7680{
7681 QDF_STATUS status;
7682 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7683
7684 if (!wma_handle || !wma_handle->wmi_handle) {
7685 WMA_LOGE("WMA is closed, cannot send invoke neighbor report");
7686 return;
7687 }
7688
7689 status = wmi_unified_invoke_neighbor_report_cmd(wma_handle->wmi_handle,
7690 params);
7691
7692 if (status != QDF_STATUS_SUCCESS)
7693 WMA_LOGE("failed to send invoke neighbor report command");
7694}
7695
lifeng66831662017-05-19 16:01:35 +08007696QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle,
7697 struct sir_set_rx_reorder_timeout_val *reorder_timeout)
7698{
7699 wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *cmd;
7700 uint32_t len;
7701 wmi_buf_t buf;
7702 int ret;
7703
7704 if (!reorder_timeout) {
7705 WMA_LOGE(FL("invalid pointer"));
7706 return QDF_STATUS_E_INVAL;
7707 }
7708
7709 if (!wma_handle) {
7710 WMA_LOGE(FL("WMA context is invald!"));
7711 return QDF_STATUS_E_INVAL;
7712 }
7713 len = sizeof(*cmd);
7714 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007715 if (!buf)
lifeng66831662017-05-19 16:01:35 +08007716 return QDF_STATUS_E_NOMEM;
Arif Hussain157263f2018-10-03 13:07:15 -07007717
lifeng66831662017-05-19 16:01:35 +08007718 cmd = (wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *)
7719 wmi_buf_data(buf);
7720
7721 WMITLV_SET_HDR(&cmd->tlv_header,
7722 WMITLV_TAG_STRUC_wmi_pdev_set_reorder_timeout_val_cmd_fixed_param,
7723 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_reorder_timeout_val_cmd_fixed_param));
7724
7725 memcpy(cmd->rx_timeout_pri, reorder_timeout->rx_timeout_pri,
7726 sizeof(reorder_timeout->rx_timeout_pri));
7727
7728 WMA_LOGD("rx aggr record timeout: VO: %d, VI: %d, BE: %d, BK: %d",
7729 cmd->rx_timeout_pri[0], cmd->rx_timeout_pri[1],
7730 cmd->rx_timeout_pri[2], cmd->rx_timeout_pri[3]);
7731
7732 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7733 WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID);
7734 if (ret) {
lifeng66831662017-05-19 16:01:35 +08007735 wmi_buf_free(buf);
7736 return QDF_STATUS_E_FAILURE;
7737 }
7738
7739 return QDF_STATUS_SUCCESS;
7740}
7741
7742QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle,
7743 struct sir_peer_set_rx_blocksize *peer_rx_blocksize)
7744{
7745 wmi_peer_set_rx_blocksize_cmd_fixed_param *cmd;
7746 int32_t len;
7747 wmi_buf_t buf;
7748 u_int8_t *buf_ptr;
7749 int ret;
7750
7751 if (!peer_rx_blocksize) {
7752 WMA_LOGE(FL("invalid pointer"));
7753 return QDF_STATUS_E_INVAL;
7754 }
7755
7756 if (!wma_handle) {
7757 WMA_LOGE(FL(" WMA context is invald!"));
7758 return QDF_STATUS_E_INVAL;
7759 }
7760
7761 len = sizeof(*cmd);
7762 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007763 if (!buf)
lifeng66831662017-05-19 16:01:35 +08007764 return QDF_STATUS_E_NOMEM;
lifeng66831662017-05-19 16:01:35 +08007765
7766 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7767 cmd = (wmi_peer_set_rx_blocksize_cmd_fixed_param *) buf_ptr;
7768
7769 WMITLV_SET_HDR(&cmd->tlv_header,
7770 WMITLV_TAG_STRUC_wmi_peer_set_rx_blocksize_cmd_fixed_param,
7771 WMITLV_GET_STRUCT_TLVLEN(wmi_peer_set_rx_blocksize_cmd_fixed_param));
7772
7773 cmd->vdev_id = peer_rx_blocksize->vdev_id;
7774 cmd->rx_block_ack_win_limit =
7775 peer_rx_blocksize->rx_block_ack_win_limit;
7776 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_rx_blocksize->peer_macaddr.bytes,
7777 &cmd->peer_macaddr);
7778
7779 WMA_LOGD("rx aggr blocksize: %d", cmd->rx_block_ack_win_limit);
7780
7781 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7782 WMI_PEER_SET_RX_BLOCKSIZE_CMDID);
7783 if (ret) {
lifeng66831662017-05-19 16:01:35 +08007784 wmi_buf_free(buf);
7785 return QDF_STATUS_E_FAILURE;
7786 }
7787
7788 return QDF_STATUS_SUCCESS;
7789}
7790
lifengd217d192017-05-09 19:44:16 +08007791QDF_STATUS wma_get_chain_rssi(tp_wma_handle wma_handle,
7792 struct get_chain_rssi_req_params *req_params)
7793{
lifengfe6c3e22018-04-03 12:10:04 +08007794 wmi_pdev_div_get_rssi_antid_fixed_param *cmd;
lifengd217d192017-05-09 19:44:16 +08007795 wmi_buf_t wmi_buf;
lifengfe6c3e22018-04-03 12:10:04 +08007796 uint32_t len = sizeof(wmi_pdev_div_get_rssi_antid_fixed_param);
lifengd217d192017-05-09 19:44:16 +08007797 u_int8_t *buf_ptr;
7798
7799 if (!wma_handle) {
7800 WMA_LOGE(FL("WMA is closed, can not issue cmd"));
7801 return QDF_STATUS_E_INVAL;
7802 }
7803
7804 wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
Arif Hussain157263f2018-10-03 13:07:15 -07007805 if (!wmi_buf)
lifengd217d192017-05-09 19:44:16 +08007806 return QDF_STATUS_E_NOMEM;
lifengd217d192017-05-09 19:44:16 +08007807
7808 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7809
lifengfe6c3e22018-04-03 12:10:04 +08007810 cmd = (wmi_pdev_div_get_rssi_antid_fixed_param *)buf_ptr;
lifengd217d192017-05-09 19:44:16 +08007811 WMITLV_SET_HDR(&cmd->tlv_header,
lifengfe6c3e22018-04-03 12:10:04 +08007812 WMITLV_TAG_STRUC_wmi_pdev_div_get_rssi_antid_fixed_param,
lifengd217d192017-05-09 19:44:16 +08007813 WMITLV_GET_STRUCT_TLVLEN(
lifengfe6c3e22018-04-03 12:10:04 +08007814 wmi_pdev_div_get_rssi_antid_fixed_param));
7815 cmd->pdev_id = 0;
lifengd217d192017-05-09 19:44:16 +08007816 WMI_CHAR_ARRAY_TO_MAC_ADDR(req_params->peer_macaddr.bytes,
lifengfe6c3e22018-04-03 12:10:04 +08007817 &cmd->macaddr);
lifengd217d192017-05-09 19:44:16 +08007818
7819 if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len,
lifengfe6c3e22018-04-03 12:10:04 +08007820 WMI_PDEV_DIV_GET_RSSI_ANTID_CMDID)) {
lifengd217d192017-05-09 19:44:16 +08007821 wmi_buf_free(wmi_buf);
7822 return QDF_STATUS_E_FAILURE;
7823 }
7824
7825 return QDF_STATUS_SUCCESS;
7826}
7827
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307828#if defined(WLAN_FEATURE_FILS_SK)
7829/**
7830 * wma_roam_scan_send_hlp() - API to send HLP IE info to fw
7831 * @wma_handle: WMA handle
7832 * @req: HLP params
7833 *
7834 * Return: QDF_STATUS
7835 */
7836static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7837 struct hlp_params *req)
7838{
7839 struct hlp_params *params;
7840 QDF_STATUS status;
7841
7842 params = qdf_mem_malloc(sizeof(*params));
Arif Hussain157263f2018-10-03 13:07:15 -07007843 if (!params)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307844 return QDF_STATUS_E_NOMEM;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307845
7846 params->vdev_id = req->vdev_id;
7847 params->hlp_ie_len = req->hlp_ie_len;
7848 qdf_mem_copy(params->hlp_ie, req->hlp_ie, req->hlp_ie_len);
7849 status = wmi_unified_roam_send_hlp_cmd(wma_handle->wmi_handle, params);
7850
7851 WMA_LOGD("Send HLP status %d vdev id %d", status, params->vdev_id);
7852 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
7853 params->hlp_ie, 10);
7854
7855 qdf_mem_free(params);
7856 return status;
7857}
7858#else
7859static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7860 struct hlp_params *req)
7861{
7862 return QDF_STATUS_SUCCESS;
7863}
7864#endif
7865
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307866/**
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307867 * wma_process_set_limit_off_chan() - set limit off chanel parameters
7868 * @wma_handle: pointer to wma handle
7869 * @param: pointer to sir_limit_off_chan
7870 *
7871 * Return: QDF_STATUS_SUCCESS for success or error code.
7872 */
7873static QDF_STATUS wma_process_limit_off_chan(tp_wma_handle wma_handle,
7874 struct sir_limit_off_chan *param)
7875{
7876 int32_t err;
7877 struct wmi_limit_off_chan_param limit_off_chan_param;
7878
Rajeev Kumar752d64e2017-10-05 16:32:58 -07007879 if (param->vdev_id >= wma_handle->max_bssid) {
7880 WMA_LOGE(FL("Invalid vdev_id: %d"), param->vdev_id);
7881 return QDF_STATUS_E_INVAL;
7882 }
7883 if (!wma_is_vdev_up(param->vdev_id)) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05307884 WMA_LOGD("vdev %d is not up skipping limit_off_chan_param",
7885 param->vdev_id);
Rajeev Kumar752d64e2017-10-05 16:32:58 -07007886 return QDF_STATUS_E_INVAL;
7887 }
7888
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307889 limit_off_chan_param.vdev_id = param->vdev_id;
7890 limit_off_chan_param.status = param->is_tos_active;
7891 limit_off_chan_param.max_offchan_time = param->max_off_chan_time;
7892 limit_off_chan_param.rest_time = param->rest_time;
7893 limit_off_chan_param.skip_dfs_chans = param->skip_dfs_chans;
7894
7895 err = wmi_unified_send_limit_off_chan_cmd(wma_handle->wmi_handle,
7896 &limit_off_chan_param);
7897 if (err) {
7898 WMA_LOGE("\n failed to set limit off chan cmd");
7899 return QDF_STATUS_E_FAILURE;
7900 }
7901
7902 return QDF_STATUS_SUCCESS;
7903}
7904
Arif Hussain05fb4872018-01-03 16:02:55 -08007905static QDF_STATUS wma_process_obss_color_collision_req(tp_wma_handle wma_handle,
7906 struct wmi_obss_color_collision_cfg_param *cfg)
7907{
7908 QDF_STATUS status;
7909
7910 if (cfg->vdev_id >= wma_handle->max_bssid) {
7911 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7912 return QDF_STATUS_E_INVAL;
7913 }
7914 if (!wma_is_vdev_up(cfg->vdev_id)) {
7915 WMA_LOGE("vdev %d is not up skipping obss color collision req",
7916 cfg->vdev_id);
7917 return QDF_STATUS_E_INVAL;
7918 }
7919
7920 status = wmi_unified_send_obss_color_collision_cfg_cmd(wma_handle->
7921 wmi_handle, cfg);
7922 if (QDF_IS_STATUS_ERROR(status))
7923 WMA_LOGE("Failed to send obss color collision cfg");
7924
7925 return status;
7926}
7927
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307928/**
Arif Hussainee10f902017-12-27 16:30:17 -08007929 * wma_send_obss_detection_cfg() - send obss detection cfg to firmware
7930 * @wma_handle: pointer to wma handle
7931 * @cfg: obss detection configuration
7932 *
7933 * Send obss detection configuration to firmware.
7934 *
7935 * Return: None
7936 */
7937static void wma_send_obss_detection_cfg(tp_wma_handle wma_handle,
7938 struct wmi_obss_detection_cfg_param
7939 *cfg)
7940{
7941 QDF_STATUS status;
7942
7943 if (cfg->vdev_id >= wma_handle->max_bssid) {
7944 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7945 return;
7946 }
7947 if (!wma_is_vdev_up(cfg->vdev_id)) {
7948 WMA_LOGE("vdev %d is not up skipping obss detection req",
7949 cfg->vdev_id);
7950 return;
7951 }
7952
7953 status = wmi_unified_send_obss_detection_cfg_cmd(wma_handle->wmi_handle,
7954 cfg);
7955 if (QDF_IS_STATUS_ERROR(status))
7956 WMA_LOGE("Failed to send obss detection cfg");
7957
7958 return;
7959}
7960
7961/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007962 * wma_mc_process_msg() - process wma messages and call appropriate function.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 * @msg: message
7964 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307965 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007966 */
Jeff Johnson5be42ab2017-09-13 09:10:39 -07007967static QDF_STATUS wma_mc_process_msg(struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007968{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307969 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007970 tp_wma_handle wma_handle;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08007971 struct cdp_vdev *txrx_vdev_handle = NULL;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07007972
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007973 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307974 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007975
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007976 if (NULL == msg) {
7977 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307978 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307979 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007980 goto end;
7981 }
7982
7983 WMA_LOGD("msg->type = %x %s", msg->type,
7984 mac_trace_get_wma_msg_string(msg->type));
7985
Anurag Chouhan6d760662016-02-20 16:05:43 +05307986 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007987
7988 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007989 WMA_LOGE("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307990 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307991 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307992 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007993 goto end;
7994 }
7995
7996 switch (msg->type) {
7997
7998 /* Message posted by wmi for all control path related
7999 * FW events to serialize through mc_thread.
8000 */
8001 case WMA_PROCESS_FW_EVENT:
8002 wma_process_fw_event(wma_handle,
8003 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308004 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008005 break;
8006
8007#ifdef FEATURE_WLAN_ESE
8008 case WMA_TSM_STATS_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08008009 WMA_LOGD("McThread: WMA_TSM_STATS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008010 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
8011 break;
8012#endif /* FEATURE_WLAN_ESE */
8013 case WNI_CFG_DNLD_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08008014 WMA_LOGD("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308015 qdf_status = wma_wni_cfg_dnld(wma_handle);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008016 if (QDF_IS_STATUS_SUCCESS(qdf_status))
Jeff Johnsonf7ab8142017-09-13 09:04:23 -07008017 cds_wma_complete_cback();
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008018 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008019 WMA_LOGD("config download failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008020 break;
8021 case WMA_ADD_STA_SELF_REQ:
8022 txrx_vdev_handle =
8023 wma_vdev_attach(wma_handle,
8024 (struct add_sta_self_params *) msg->
8025 bodyptr, 1);
8026 if (!txrx_vdev_handle) {
8027 WMA_LOGE("Failed to attach vdev");
8028 } else {
8029 /* Register with TxRx Module for Data Ack Complete Cb */
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308030 if (soc) {
8031 cdp_data_tx_cb_set(soc, txrx_vdev_handle,
8032 wma_data_tx_ack_comp_hdlr,
8033 wma_handle);
8034 } else {
8035 WMA_LOGE("%s: SOC context is NULL", __func__);
8036 qdf_status = QDF_STATUS_E_FAILURE;
8037 goto end;
8038 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008039 }
8040 break;
8041 case WMA_DEL_STA_SELF_REQ:
8042 wma_vdev_detach(wma_handle,
8043 (struct del_sta_self_params *) msg->bodyptr, 1);
8044 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008045 case WMA_UPDATE_CHAN_LIST_REQ:
8046 wma_update_channel_list(wma_handle,
8047 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308048 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008049 break;
8050 case WMA_SET_LINK_STATE:
8051 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
8052 break;
8053 case WMA_CHNL_SWITCH_REQ:
8054 wma_set_channel(wma_handle,
8055 (tpSwitchChannelParams) msg->bodyptr);
8056 break;
8057 case WMA_ADD_BSS_REQ:
8058 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
8059 break;
8060 case WMA_ADD_STA_REQ:
8061 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
8062 break;
8063 case WMA_SET_BSSKEY_REQ:
8064 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
8065 break;
8066 case WMA_SET_STAKEY_REQ:
8067 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
8068 break;
8069 case WMA_DELETE_STA_REQ:
8070 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
8071 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07008072 case WMA_DELETE_BSS_HO_FAIL_REQ:
8073 wma_delete_bss_ho_fail(wma_handle,
8074 (tpDeleteBssParams) msg->bodyptr);
8075 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008076 case WMA_DELETE_BSS_REQ:
8077 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
8078 break;
8079 case WMA_UPDATE_EDCA_PROFILE_IND:
8080 wma_process_update_edca_param_req(wma_handle,
8081 (tEdcaParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308082 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008083 break;
8084 case WMA_SEND_BEACON_REQ:
8085 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008086 break;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308087 case WMA_SEND_AP_VDEV_UP:
8088 wma_set_ap_vdev_up(wma_handle, msg->bodyval);
8089 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008090 case WMA_SEND_PROBE_RSP_TMPL:
8091 wma_send_probe_rsp_tmpl(wma_handle,
8092 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308093 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008094 break;
8095 case WMA_CLI_SET_CMD:
8096 wma_process_cli_set_cmd(wma_handle,
8097 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308098 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008099 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07008100 case WMA_SET_PDEV_IE_REQ:
8101 wma_process_set_pdev_ie_req(wma_handle,
8102 (struct set_ie_param *)msg->bodyptr);
8103 qdf_mem_free(msg->bodyptr);
8104 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008105#if !defined(REMOVE_PKT_LOG)
8106 case WMA_PKTLOG_ENABLE_REQ:
8107 wma_pktlog_wmi_send_cmd(wma_handle,
8108 (struct ath_pktlog_wmi_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308109 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008110 break;
8111#endif /* REMOVE_PKT_LOG */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008112 case WMA_ENTER_PS_REQ:
8113 wma_enable_sta_ps_mode(wma_handle,
8114 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308115 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008116 break;
8117 case WMA_EXIT_PS_REQ:
8118 wma_disable_sta_ps_mode(wma_handle,
8119 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308120 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008121 break;
8122 case WMA_ENABLE_UAPSD_REQ:
8123 wma_enable_uapsd_mode(wma_handle,
8124 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308125 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008126 break;
8127 case WMA_DISABLE_UAPSD_REQ:
8128 wma_disable_uapsd_mode(wma_handle,
8129 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308130 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008131 break;
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08008132 case WMA_SET_DTIM_PERIOD:
8133 wma_set_dtim_period(wma_handle,
8134 (struct set_dtim_params *)msg->bodyptr);
8135 qdf_mem_free(msg->bodyptr);
8136 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008137 case WMA_SET_TX_POWER_REQ:
8138 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
8139 break;
8140 case WMA_SET_MAX_TX_POWER_REQ:
8141 wma_set_max_tx_power(wma_handle,
8142 (tpMaxTxPowerParams) msg->bodyptr);
8143 break;
8144 case WMA_SET_KEEP_ALIVE:
8145 wma_set_keepalive_req(wma_handle,
8146 (tSirKeepAliveReq *) msg->bodyptr);
8147 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08008148#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008149 case WMA_SET_PLM_REQ:
8150 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
8151 break;
8152#endif
8153 case WMA_GET_STATISTICS_REQ:
8154 wma_get_stats_req(wma_handle,
8155 (tAniGetPEStatsReq *) msg->bodyptr);
8156 break;
8157
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008158 case WMA_UPDATE_OP_MODE:
8159 wma_process_update_opmode(wma_handle,
8160 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308161 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008162 break;
8163 case WMA_UPDATE_RX_NSS:
8164 wma_process_update_rx_nss(wma_handle,
8165 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308166 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008167 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008168 case WMA_UPDATE_MEMBERSHIP:
8169 wma_process_update_membership(wma_handle,
8170 (tUpdateMembership *) msg->bodyptr);
8171 break;
8172 case WMA_UPDATE_USERPOS:
8173 wma_process_update_userpos(wma_handle,
8174 (tUpdateUserPos *) msg->bodyptr);
8175 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008176 case WMA_UPDATE_BEACON_IND:
8177 wma_process_update_beacon_params(wma_handle,
8178 (tUpdateBeaconParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308179 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008180 break;
8181
8182 case WMA_ADD_TS_REQ:
Jeff Johnson9851fcc2018-12-22 17:29:58 -08008183 wma_add_ts_req(wma_handle, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008184 break;
8185
8186 case WMA_DEL_TS_REQ:
Jeff Johnson256002f2018-12-22 17:53:19 -08008187 wma_del_ts_req(wma_handle, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008188 break;
8189
8190 case WMA_AGGR_QOS_REQ:
Jeff Johnson54024412018-12-22 12:07:06 -08008191 wma_aggr_qos_req(wma_handle, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008192 break;
8193
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008194 case WMA_8023_MULTICAST_LIST_REQ:
8195 wma_process_mcbc_set_filter_req(wma_handle,
8196 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308197 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008198 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008199 case WMA_ROAM_SCAN_OFFLOAD_REQ:
8200 /*
8201 * Main entry point or roaming directives from CSR.
8202 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08008203 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008204 (tSirRoamOffloadScanReq *) msg->bodyptr);
8205 break;
8206
8207 case WMA_RATE_UPDATE_IND:
8208 wma_process_rate_update_indicate(wma_handle,
8209 (tSirRateUpdateInd *) msg->bodyptr);
8210 break;
8211
8212#ifdef FEATURE_WLAN_TDLS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008213 case WMA_UPDATE_TDLS_PEER_STATE:
8214 wma_update_tdls_peer_state(wma_handle,
8215 (tTdlsPeerStateParams *) msg->bodyptr);
8216 break;
8217 case WMA_TDLS_SET_OFFCHAN_MODE:
8218 wma_set_tdls_offchan_mode(wma_handle,
8219 (tdls_chan_switch_params *)msg->bodyptr);
8220 break;
8221#endif /* FEATURE_WLAN_TDLS */
8222 case WMA_ADD_PERIODIC_TX_PTRN_IND:
8223 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
8224 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308225 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008226 break;
8227 case WMA_DEL_PERIODIC_TX_PTRN_IND:
8228 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
8229 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308230 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008231 break;
8232 case WMA_TX_POWER_LIMIT:
8233 wma_process_tx_power_limits(wma_handle,
8234 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308235 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008236 break;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08008237 case WMA_SEND_ADDBA_REQ:
8238 wma_process_send_addba_req(wma_handle,
8239 (struct send_add_ba_req *)msg->bodyptr);
8240 break;
8241
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008242#ifdef FEATURE_WLAN_CH_AVOID
8243 case WMA_CH_AVOID_UPDATE_REQ:
8244 wma_process_ch_avoid_update_req(wma_handle,
8245 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308246 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008247 break;
8248#endif /* FEATURE_WLAN_CH_AVOID */
8249#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
8250 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
8251 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308252 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008253 break;
8254#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
8255 case WMA_DHCP_START_IND:
8256 case WMA_DHCP_STOP_IND:
8257 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308258 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008259 break;
8260
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008261 case WMA_IBSS_CESIUM_ENABLE_IND:
8262 wma_process_cesium_enable_ind(wma_handle);
8263 break;
8264 case WMA_GET_IBSS_PEER_INFO_REQ:
8265 wma_process_get_peer_info_req(wma_handle,
8266 (tSirIbssGetPeerInfoReqParams *)
8267 msg->bodyptr);
8268 qdf_mem_free(msg->bodyptr);
8269 break;
8270 case WMA_TX_FAIL_MONITOR_IND:
8271 wma_process_tx_fail_monitor_ind(wma_handle,
8272 (tAniTXFailMonitorInd *) msg->bodyptr);
8273 qdf_mem_free(msg->bodyptr);
8274 break;
8275
8276 case WMA_RMC_ENABLE_IND:
8277 wma_process_rmc_enable_ind(wma_handle);
8278 break;
8279 case WMA_RMC_DISABLE_IND:
8280 wma_process_rmc_disable_ind(wma_handle);
8281 break;
8282 case WMA_RMC_ACTION_PERIOD_IND:
8283 wma_process_rmc_action_period_ind(wma_handle);
8284 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008285 case WMA_INIT_THERMAL_INFO_CMD:
8286 wma_process_init_thermal_info(wma_handle,
8287 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308288 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008289 break;
8290
8291 case WMA_SET_THERMAL_LEVEL:
8292 wma_process_set_thermal_level(wma_handle, msg->bodyval);
8293 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05308294#ifdef CONFIG_HL_SUPPORT
8295 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
8296 wma_process_init_bad_peer_tx_ctl_info(
8297 wma_handle,
8298 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
8299 qdf_mem_free(msg->bodyptr);
8300 break;
8301#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008302 case WMA_SET_MIMOPS_REQ:
8303 wma_process_set_mimops_req(wma_handle,
8304 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308305 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008306 break;
8307 case WMA_SET_SAP_INTRABSS_DIS:
8308 wma_set_vdev_intrabss_fwd(wma_handle,
8309 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308310 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008311 break;
Will Huanga9814592017-05-24 15:47:58 +08008312 case WMA_GET_PEER_INFO:
8313 wma_get_peer_info(wma_handle, msg->bodyptr);
8314 qdf_mem_free(msg->bodyptr);
8315 break;
8316 case WMA_GET_PEER_INFO_EXT:
8317 wma_get_peer_info_ext(wma_handle, msg->bodyptr);
8318 qdf_mem_free(msg->bodyptr);
8319 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008320 case WMA_MODEM_POWER_STATE_IND:
8321 wma_notify_modem_power_state(wma_handle,
8322 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308323 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008324 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008325#ifdef WLAN_FEATURE_STATS_EXT
8326 case WMA_STATS_EXT_REQUEST:
8327 wma_stats_ext_req(wma_handle,
8328 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308329 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008330 break;
8331#endif /* WLAN_FEATURE_STATS_EXT */
8332 case WMA_HIDDEN_SSID_VDEV_RESTART:
8333 wma_hidden_ssid_vdev_restart(wma_handle,
8334 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008335 break;
8336#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
8337 case WMA_WLAN_EXT_WOW:
8338 wma_enable_ext_wow(wma_handle,
8339 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308340 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008341 break;
8342 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
8343 wma_set_app_type1_params_in_fw(wma_handle,
8344 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308345 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008346 break;
8347 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
8348 wma_set_app_type2_params_in_fw(wma_handle,
8349 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308350 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008351 break;
8352#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
8353#ifdef FEATURE_WLAN_EXTSCAN
8354 case WMA_EXTSCAN_START_REQ:
Jeff Johnsondab58602018-07-14 15:30:24 -07008355 wma_start_extscan(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308356 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008357 break;
8358 case WMA_EXTSCAN_STOP_REQ:
Jeff Johnson7272ea72018-07-15 17:22:27 -07008359 wma_stop_extscan(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308360 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008361 break;
8362 case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:
Jeff Johnson1148cb02018-07-13 23:14:32 -07008363 wma_extscan_start_hotlist_monitor(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308364 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008365 break;
8366 case WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
Jeff Johnson9743eb72018-07-14 10:30:04 -07008367 wma_extscan_stop_hotlist_monitor(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308368 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008369 break;
8370 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
Jeff Johnsonb43ed032018-07-16 06:59:21 -07008371 wma_extscan_start_change_monitor(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308372 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008373 break;
8374 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
Jeff Johnson0c8dbc32018-07-16 22:10:48 -07008375 wma_extscan_stop_change_monitor(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308376 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008377 break;
8378 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
Jeff Johnson2ba60092018-07-17 08:19:37 -07008379 wma_extscan_get_cached_results(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308380 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008381 break;
8382 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
Jeff Johnsonfed9a732018-07-18 12:18:03 -07008383 wma_extscan_get_capabilities(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308384 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008385 break;
8386 case WMA_SET_EPNO_LIST_REQ:
Jeff Johnson360135b2018-07-18 20:51:47 -07008387 wma_set_epno_network_list(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308388 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008389 break;
Kapil Gupta5cda2252016-12-29 18:44:26 +05308390 case WMA_SET_PER_ROAM_CONFIG_CMD:
8391 wma_update_per_roam_config(wma_handle,
8392 (struct wmi_per_roam_config_req *)msg->bodyptr);
8393 qdf_mem_free(msg->bodyptr);
8394 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008395 case WMA_SET_PASSPOINT_LIST_REQ:
8396 /* Issue reset passpoint network list first and clear
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008397 * the entries
8398 */
Jeff Johnson2a7f1012018-07-19 07:21:06 -07008399 wma_reset_passpoint_network_list(wma_handle, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008400
Jeff Johnson2a7f1012018-07-19 07:21:06 -07008401 wma_set_passpoint_network_list(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308402 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008403 break;
8404 case WMA_RESET_PASSPOINT_LIST_REQ:
Jeff Johnson2a7f1012018-07-19 07:21:06 -07008405 wma_reset_passpoint_network_list(wma_handle, msg->bodyptr);
Pragaspathi Thilagarajf65cffe2018-06-15 14:20:26 +05308406 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008407 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008408#endif /* FEATURE_WLAN_EXTSCAN */
8409 case WMA_SET_SCAN_MAC_OUI_REQ:
8410 wma_scan_probe_setoui(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308411 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008412 break;
8413#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8414 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
8415 wma_process_ll_stats_clear_req(wma_handle,
8416 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308417 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008418 break;
8419 case WMA_LINK_LAYER_STATS_SET_REQ:
8420 wma_process_ll_stats_set_req(wma_handle,
8421 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308422 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008423 break;
8424 case WMA_LINK_LAYER_STATS_GET_REQ:
8425 wma_process_ll_stats_get_req(wma_handle,
8426 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308427 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008428 break;
Zhang Qian73c348a2017-03-13 16:15:55 +08008429 case WDA_LINK_LAYER_STATS_SET_THRESHOLD:
8430 wma_config_stats_ext_threshold(wma_handle,
8431 (struct sir_ll_ext_stats_threshold *)msg->bodyptr);
8432 qdf_mem_free(msg->bodyptr);
8433 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008434#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008435#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008436 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
8437 wma_process_roam_synch_fail(wma_handle,
8438 (struct roam_offload_synch_fail *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308439 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008440 break;
8441 case SIR_HAL_ROAM_INVOKE:
8442 wma_process_roam_invoke(wma_handle,
8443 (struct wma_roam_invoke_cmd *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308444 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008445 break;
8446#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008447 case SIR_HAL_SET_BASE_MACADDR_IND:
8448 wma_set_base_macaddr_indicate(wma_handle,
8449 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308450 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008451 break;
8452 case WMA_LINK_STATUS_GET_REQ:
8453 wma_process_link_status_req(wma_handle,
8454 (tAniGetLinkStatus *) msg->bodyptr);
8455 break;
8456 case WMA_GET_TEMPERATURE_REQ:
8457 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308458 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008459 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07008460 case WMA_TSF_GPIO_PIN:
8461 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
8462 break;
8463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008464#ifdef DHCP_SERVER_OFFLOAD
8465 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
8466 wma_process_dhcpserver_offload(wma_handle,
8467 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308468 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008469 break;
8470#endif /* DHCP_SERVER_OFFLOAD */
8471#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8472 case WMA_LED_FLASHING_REQ:
Jeff Johnson5a6b6602017-10-04 14:44:30 -07008473 wma_set_led_flashing(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308474 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008475 break;
8476#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
8477 case SIR_HAL_SET_MAS:
8478 wma_process_set_mas(wma_handle,
8479 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308480 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008481 break;
8482 case SIR_HAL_SET_MIRACAST:
8483 wma_process_set_miracast(wma_handle,
8484 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308485 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008486 break;
8487 case SIR_HAL_CONFIG_STATS_FACTOR:
8488 wma_config_stats_factor(wma_handle,
8489 (struct sir_stats_avg_factor *)
8490 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308491 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008492 break;
8493 case SIR_HAL_CONFIG_GUARD_TIME:
8494 wma_config_guard_time(wma_handle,
8495 (struct sir_guard_time_request *)
8496 msg->bodyptr);
Vignesh Viswanathan9fa8fef2017-12-12 14:45:38 +05308497 qdf_mem_free(msg->bodyptr);
8498 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008499 case SIR_HAL_START_STOP_LOGGING:
8500 wma_set_wifi_start_packet_stats(wma_handle,
8501 (struct sir_wifi_start_log *)msg->bodyptr);
8502 wma_enable_specific_fw_logs(wma_handle,
8503 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308504 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008505 break;
8506 case SIR_HAL_FLUSH_LOG_TO_FW:
8507 wma_send_flush_logs_to_fw(wma_handle);
8508 /* Body ptr is NULL here */
8509 break;
8510 case WMA_SET_RSSI_MONITOR_REQ:
8511 wma_set_rssi_monitoring(wma_handle,
8512 (struct rssi_monitor_req *)msg->bodyptr);
Prakash Dhavali87ddca32016-11-29 17:02:11 -08008513 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008514 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308515 case SIR_HAL_PDEV_SET_PCL_TO_FW:
8516 wma_send_pdev_set_pcl_cmd(wma_handle,
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008517 (struct set_pcl_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308518 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008519 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308520 case SIR_HAL_PDEV_SET_HW_MODE:
8521 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008522 (struct policy_mgr_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308523 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008524 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07008525 case WMA_SET_WISA_PARAMS:
8526 wma_set_wisa_params(wma_handle,
8527 (struct sir_wisa_params *)msg->bodyptr);
8528 qdf_mem_free(msg->bodyptr);
8529 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308530 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
8531 wma_send_pdev_set_dual_mac_config(wma_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008532 (struct policy_mgr_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308533 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008534 break;
8535 case WMA_SET_IE_INFO:
8536 wma_process_set_ie_info(wma_handle,
8537 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308538 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008539 break;
Kiran Kumar Lokereee205772018-09-27 00:27:27 -07008540 case WMA_CFG_VENDOR_ACTION_TB_PPDU:
8541 wma_process_cfg_action_frm_tb_ppdu(wma_handle, msg->bodyptr);
8542 qdf_mem_free(msg->bodyptr);
8543 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008544 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
8545 wma_send_pdev_set_antenna_mode(wma_handle,
8546 (struct sir_antenna_mode_param *)msg->bodyptr);
8547 qdf_mem_free(msg->bodyptr);
8548 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008549 case WMA_LRO_CONFIG_CMD:
8550 wma_lro_config_cmd(wma_handle,
Dhanashri Atre09828f12016-11-13 10:36:58 -08008551 (struct cdp_lro_hash_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308552 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008553 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08008554 case WMA_GW_PARAM_UPDATE_REQ:
8555 wma_set_gateway_params(wma_handle,
8556 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08008557 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08008558 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05308559 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
8560 wma_send_adapt_dwelltime_params(wma_handle,
8561 (struct adaptive_dwelltime_params *)msg->bodyptr);
8562 qdf_mem_free(msg->bodyptr);
8563 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08008564 case WMA_HT40_OBSS_SCAN_IND:
8565 wma_send_ht40_obss_scanind(wma_handle,
8566 (struct obss_ht40_scanind *)msg->bodyptr);
8567 qdf_mem_free(msg->bodyptr);
8568 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07008569 case WMA_ADD_BCN_FILTER_CMDID:
8570 wma_add_beacon_filter(wma_handle, msg->bodyptr);
8571 qdf_mem_free(msg->bodyptr);
8572 break;
8573 case WMA_REMOVE_BCN_FILTER_CMDID:
8574 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
8575 qdf_mem_free(msg->bodyptr);
8576 break;
Nachiket Kukadee547a482018-05-22 16:43:30 +05308577 case WDA_APF_GET_CAPABILITIES_REQ:
8578 wma_get_apf_capabilities(wma_handle);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05308579 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05308580 case SIR_HAL_POWER_DBG_CMD:
8581 wma_process_hal_pwr_dbg_cmd(wma_handle,
8582 msg->bodyptr);
8583 qdf_mem_free(msg->bodyptr);
8584 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05308585 case WMA_UPDATE_WEP_DEFAULT_KEY:
8586 wma_update_wep_default_key(wma_handle,
8587 (struct wep_update_default_key_idx *)msg->bodyptr);
8588 qdf_mem_free(msg->bodyptr);
8589 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05308590 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
8591 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
8592 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05308593 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
8594 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
8595 qdf_mem_free(msg->bodyptr);
8596 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05308597 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
8598 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
8599 qdf_mem_free(msg->bodyptr);
8600 break;
8601 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
8602 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
8603 qdf_mem_free(msg->bodyptr);
8604 break;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05308605 case SIR_HAL_POWER_DEBUG_STATS_REQ:
8606 wma_process_power_debug_stats_req(wma_handle);
8607 break;
Arunk Khandavallica56d4b2018-11-29 15:46:00 +05308608 case WMA_BEACON_DEBUG_STATS_REQ:
8609 wma_process_beacon_debug_stats_req(wma_handle, msg->bodyptr);
8610 qdf_mem_free(msg->bodyptr);
8611 break;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05308612 case WMA_GET_RCPI_REQ:
8613 wma_get_rcpi_req(wma_handle,
8614 (struct sme_rcpi_req *)msg->bodyptr);
8615 qdf_mem_free(msg->bodyptr);
8616 break;
Yingying Tang95409972016-10-20 15:16:15 +08008617 case WMA_SET_WOW_PULSE_CMD:
8618 wma_send_wow_pulse_cmd(wma_handle,
8619 (struct wow_pulse_mode *)msg->bodyptr);
8620 qdf_mem_free(msg->bodyptr);
8621 break;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05308622 case WMA_SET_DBS_SCAN_SEL_CONF_PARAMS:
8623 wma_send_dbs_scan_selection_params(wma_handle,
8624 (struct wmi_dbs_scan_sel_params *)msg->bodyptr);
8625 qdf_mem_free(msg->bodyptr);
8626 break;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05308627 case WMA_SET_ARP_STATS_REQ:
8628 wma_set_arp_req_stats(wma_handle,
8629 (struct set_arp_stats_params *)msg->bodyptr);
8630 qdf_mem_free(msg->bodyptr);
8631 break;
8632 case WMA_GET_ARP_STATS_REQ:
8633 wma_get_arp_req_stats(wma_handle,
8634 (struct get_arp_stats_params *)msg->bodyptr);
8635 qdf_mem_free(msg->bodyptr);
8636 break;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308637 case SIR_HAL_SET_DEL_PMKID_CACHE:
Jeff Johnson622aad62018-12-07 15:05:37 -08008638 wma_set_del_pmkid_cache(wma_handle, msg->bodyptr);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308639 qdf_mem_free(msg->bodyptr);
8640 break;
8641 case SIR_HAL_HLP_IE_INFO:
8642 wma_roam_scan_send_hlp(wma_handle,
8643 (struct hlp_params *)msg->bodyptr);
8644 qdf_mem_free(msg->bodyptr);
8645 break;
Ganesh Kondabattini35739572017-06-21 16:26:39 +05308646 case WMA_SET_LIMIT_OFF_CHAN:
8647 wma_process_limit_off_chan(wma_handle, msg->bodyptr);
8648 qdf_mem_free(msg->bodyptr);
8649 break;
Arif Hussainee10f902017-12-27 16:30:17 -08008650 case WMA_OBSS_DETECTION_REQ:
8651 wma_send_obss_detection_cfg(wma_handle, msg->bodyptr);
8652 qdf_mem_free(msg->bodyptr);
8653 break;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05308654 case WMA_INVOKE_NEIGHBOR_REPORT:
8655 wma_send_invoke_neighbor_report(wma_handle, msg->bodyptr);
8656 qdf_mem_free(msg->bodyptr);
8657 break;
Arif Hussain05fb4872018-01-03 16:02:55 -08008658 case WMA_OBSS_COLOR_COLLISION_REQ:
8659 wma_process_obss_color_collision_req(wma_handle, msg->bodyptr);
8660 qdf_mem_free(msg->bodyptr);
8661 break;
Rajeev Kumar Sirasanagandla4f20b672018-03-12 13:52:50 +05308662 case WMA_GET_ROAM_SCAN_STATS:
8663 wma_get_roam_scan_stats(wma_handle, msg->bodyptr);
8664 qdf_mem_free(msg->bodyptr);
8665 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008666 default:
Sandeep Puligilla1f1e4002018-08-18 12:15:01 -07008667 WMA_LOGD("Unhandled WMA message of type %d", msg->type);
Dustin Brown86534fb2017-01-24 14:28:20 -08008668 if (msg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308669 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008670 }
8671end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308672 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008673}
8674
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008675QDF_STATUS wma_mc_process_handler(struct scheduler_msg *msg)
8676{
Jeff Johnson5be42ab2017-09-13 09:10:39 -07008677 return wma_mc_process_msg(msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008678}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008680/**
8681 * wma_log_completion_timeout() - Log completion timeout
8682 * @data: Timeout handler data
8683 *
8684 * This function is called when log completion timer expires
8685 *
8686 * Return: None
8687 */
8688void wma_log_completion_timeout(void *data)
8689{
8690 tp_wma_handle wma_handle;
8691
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05308692 WMA_LOGD("%s: Timeout occurred for log completion command", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008693
8694 wma_handle = (tp_wma_handle) data;
8695 if (!wma_handle)
8696 WMA_LOGE("%s: Invalid WMA handle", __func__);
8697
8698 /* Though we did not receive any event from FW,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008699 * we can flush whatever logs we have with us
8700 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008701 cds_logging_set_fw_flush_complete();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008702}
8703
8704/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308705 * wma_map_pcl_weights() - Map PCL weights
8706 * @pcl_weight: Internal PCL weights
8707 *
8708 * Maps the internal weights of PCL to the weights needed by FW
8709 *
8710 * Return: Mapped channel weight of type wmi_pcl_chan_weight
8711 */
8712static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
8713{
8714 switch (pcl_weight) {
8715 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
8716 return WMI_PCL_WEIGHT_VERY_HIGH;
8717 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
8718 return WMI_PCL_WEIGHT_HIGH;
8719 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
8720 return WMI_PCL_WEIGHT_MEDIUM;
8721 case WEIGHT_OF_NON_PCL_CHANNELS:
8722 return WMI_PCL_WEIGHT_LOW;
8723 default:
8724 return WMI_PCL_WEIGHT_DISALLOW;
8725 }
8726}
8727
8728/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308729 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008730 * @wma_handle: WMA handle
8731 * @msg: PCL structure containing the PCL and the number of channels
8732 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308733 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008734 * firmware. The DBS Manager is the consumer of this information in the WLAN
8735 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
8736 * to migrate to a new channel without host driver involvement. An example of
8737 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
8738 * manage the channel selection without firmware involvement.
8739 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308740 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
8741 * channel list. The weights corresponds to the channels sent in
8742 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
8743 * weightage compared to the non PCL channels.
8744 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008745 * Return: Success if the cmd is sent successfully to the firmware
8746 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308747QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008748 struct set_pcl_req *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008749{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308750 uint32_t i;
8751 QDF_STATUS status;
8752
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008753 if (!wma_handle) {
8754 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8755 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308756 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008757 }
8758
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308759 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008760 msg->chan_weights.saved_chan_list[i] =
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308761 wma_handle->saved_chan.channel_list[i];
8762 }
8763
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008764 msg->chan_weights.saved_num_chan = wma_handle->saved_chan.num_channels;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008765 status = policy_mgr_get_valid_chan_weights(wma_handle->psoc,
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008766 (struct policy_mgr_pcl_chan_weights *)&msg->chan_weights);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308767
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008768 for (i = 0; i < msg->chan_weights.saved_num_chan; i++) {
8769 msg->chan_weights.weighed_valid_list[i] =
8770 wma_map_pcl_weights(
8771 msg->chan_weights.weighed_valid_list[i]);
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008772 /* Dont allow roaming on 2G when 5G_ONLY configured */
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008773 if (((wma_handle->bandcapability == BAND_5G) ||
8774 (msg->band == BAND_5G)) &&
8775 (WLAN_REG_IS_24GHZ_CH(
8776 msg->chan_weights.saved_chan_list[i]))) {
8777 msg->chan_weights.weighed_valid_list[i] =
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008778 WEIGHT_OF_DISALLOWED_CHANNELS;
8779 }
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008780 if ((msg->band == BAND_2G) &&
8781 WLAN_REG_IS_5GHZ_CH(msg->chan_weights.saved_chan_list[i]))
8782 msg->chan_weights.weighed_valid_list[i] =
8783 WEIGHT_OF_DISALLOWED_CHANNELS;
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308784 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008785 msg->chan_weights.saved_chan_list[i], i,
8786 msg->chan_weights.weighed_valid_list[i]);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308787 }
8788
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308789 if (!QDF_IS_STATUS_SUCCESS(status)) {
8790 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
8791 return status;
8792 }
8793
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -07008794 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle,
8795 &msg->chan_weights))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308796 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05308797
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308798 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008799}
8800
8801/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308802 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008803 * @wma_handle: WMA handle
8804 * @msg: Structure containing the following parameters
8805 *
8806 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
8807 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
8808 *
8809 * Provides notification to the WLAN firmware that host driver is requesting a
8810 * HardWare (HW) Mode change. This command is needed to support iHelium in the
8811 * configurations that include the Dual Band Simultaneous (DBS) feature.
8812 *
8813 * Return: Success if the cmd is sent successfully to the firmware
8814 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308815QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008816 struct policy_mgr_hw_mode *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008817{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008818 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008819 struct wma_target_req *timeout_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008820
8821 if (!wma_handle) {
8822 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8823 __func__);
8824 /* Handle is NULL. Will not be able to send failure
8825 * response as well
8826 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308827 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008828 }
8829
8830 if (!msg) {
8831 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
8832 /* Lets try to free the active command list */
8833 goto fail;
8834 }
8835
Dustin Brownec2c92e2017-07-26 11:13:49 -07008836 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8837 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT);
Govind Singhf25a0f12016-03-08 16:09:48 +05308838 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008839 msg->hw_mode_index)) {
8840 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008841 goto fail;
Krunal Sonicebcc292017-06-14 19:59:20 -07008842 }
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008843 timeout_msg = wma_fill_hold_req(wma_handle, 0,
8844 SIR_HAL_PDEV_SET_HW_MODE,
8845 WMA_PDEV_SET_HW_MODE_RESP, NULL,
8846 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT - 1);
8847 if (!timeout_msg) {
8848 WMA_LOGE("Failed to allocate request for SIR_HAL_PDEV_SET_HW_MODE");
8849 wma_remove_req(wma_handle, 0, WMA_PDEV_SET_HW_MODE_RESP);
8850 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008851
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308852 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008853fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308854 param = qdf_mem_malloc(sizeof(*param));
Arif Hussain157263f2018-10-03 13:07:15 -07008855 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308856 return QDF_STATUS_E_NULL_VALUE;
Arif Hussain157263f2018-10-03 13:07:15 -07008857
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008858 param->status = SET_HW_MODE_STATUS_ECANCELED;
8859 param->cfgd_hw_mode_index = 0;
8860 param->num_vdev_mac_entries = 0;
8861 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308862 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008863 (void *) param, 0);
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308864 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008865}
8866
8867/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308868 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008869 * @wma_handle: WMA handle
8870 * @msg: Dual MAC config parameters
8871 *
8872 * Configures WLAN firmware with the dual MAC features
8873 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308874 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008875 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308876QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008877 struct policy_mgr_dual_mac_config *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008878{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308879 QDF_STATUS status;
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308880 struct wma_target_req *req_msg;
8881 struct sir_dual_mac_config_resp *resp;
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308882
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008883 if (!wma_handle) {
8884 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8885 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308886 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008887 }
8888
8889 if (!msg) {
8890 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308891 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008892 }
8893
Krunal Sonia5ccb802017-07-03 12:59:40 -07008894 /*
8895 * aquire the wake lock here and release it in response handler function
8896 * In error condition, release the wake lock right away
8897 */
8898 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8899 WMA_VDEV_PLCY_MGR_CMD_TIMEOUT);
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308900 status = wmi_unified_pdev_set_dual_mac_config_cmd(
8901 wma_handle->wmi_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008902 (struct policy_mgr_dual_mac_config *)msg);
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308903 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308904 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308905 __func__, status);
Krunal Sonia5ccb802017-07-03 12:59:40 -07008906 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308907 goto fail;
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308908 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008909 policy_mgr_update_dbs_req_config(wma_handle->psoc,
8910 msg->scan_config, msg->fw_mode_config);
Govind Singhf25a0f12016-03-08 16:09:48 +05308911
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308912 req_msg = wma_fill_hold_req(wma_handle, 0,
8913 SIR_HAL_PDEV_DUAL_MAC_CFG_REQ,
8914 WMA_PDEV_MAC_CFG_RESP, NULL,
8915 WMA_VDEV_DUAL_MAC_CFG_TIMEOUT);
8916 if (!req_msg) {
8917 WMA_LOGE("Failed to allocate request for SIR_HAL_PDEV_DUAL_MAC_CFG_REQ");
8918 wma_remove_req(wma_handle, 0, WMA_PDEV_MAC_CFG_RESP);
8919 }
8920
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308921 return QDF_STATUS_SUCCESS;
Abhishek Singhd93a0b22018-10-30 17:04:56 +05308922
8923fail:
8924 resp = qdf_mem_malloc(sizeof(*resp));
8925 if (!resp)
8926 return QDF_STATUS_E_NULL_VALUE;
8927
8928 resp->status = SET_HW_MODE_STATUS_ECANCELED;
8929 WMA_LOGE("%s: Sending failure response to LIM", __func__);
8930 wma_send_msg(wma_handle, SIR_HAL_PDEV_MAC_CFG_RESP, (void *) resp, 0);
8931 return QDF_STATUS_E_FAILURE;
8932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008933}
8934
8935/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008936 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
8937 * @wma_handle: WMA handle
8938 * @msg: Antenna mode parameters
8939 *
8940 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
8941 * modify the number of TX/RX chains from host
8942 *
8943 * Return: QDF_STATUS. 0 on success.
8944 */
8945QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
8946 struct sir_antenna_mode_param *msg)
8947{
8948 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
8949 wmi_buf_t buf;
8950 uint32_t len;
8951 QDF_STATUS status = QDF_STATUS_SUCCESS;
8952 struct sir_antenna_mode_resp *param;
8953
8954 if (!wma_handle) {
8955 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8956 __func__);
8957 return QDF_STATUS_E_NULL_VALUE;
8958 }
8959
8960 if (!msg) {
8961 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
8962 return QDF_STATUS_E_NULL_VALUE;
8963 }
8964
8965 len = sizeof(*cmd);
8966
8967 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
8968 if (!buf) {
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008969 status = QDF_STATUS_E_NOMEM;
8970 goto resp;
8971 }
8972
8973 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
8974 WMITLV_SET_HDR(&cmd->tlv_header,
8975 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
8976 WMITLV_GET_STRUCT_TLVLEN(
8977 wmi_pdev_set_antenna_mode_cmd_fixed_param));
8978
8979 cmd->pdev_id = WMI_PDEV_ID_SOC;
8980 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
8981 cmd->num_txrx_chains = msg->num_rx_chains;
8982 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
8983
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07008984 WMA_LOGD("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008985 __func__, msg->num_tx_chains,
8986 msg->num_rx_chains, cmd->num_txrx_chains);
8987
8988 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
8989 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008990 wmi_buf_free(buf);
8991 status = QDF_STATUS_E_FAILURE;
8992 goto resp;
8993 }
8994 status = QDF_STATUS_SUCCESS;
8995
8996resp:
8997 param = qdf_mem_malloc(sizeof(*param));
Arif Hussain157263f2018-10-03 13:07:15 -07008998 if (!param)
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008999 return QDF_STATUS_E_NOMEM;
Arif Hussain157263f2018-10-03 13:07:15 -07009000
Archana Ramachandrana20ef812015-11-13 16:12:13 -08009001 param->status = (status) ?
9002 SET_ANTENNA_MODE_STATUS_ECANCELED :
9003 SET_ANTENNA_MODE_STATUS_OK;
9004 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
9005 __func__, param->status);
9006 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
9007 (void *) param, 0);
9008 return status;
9009}
9010
9011/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009012 * wma_crash_inject() - sends command to FW to simulate crash
9013 * @wma_handle: pointer of WMA context
9014 * @type: subtype of the command
9015 * @delay_time_ms: time in milliseconds for FW to delay the crash
9016 *
9017 * This function will send a command to FW in order to simulate different
9018 * kinds of FW crashes.
9019 *
Govind Singhd76a5b02016-03-08 15:12:14 +05309020 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009021 */
Yu Wang46082dc2017-09-19 12:25:38 +08009022QDF_STATUS wma_crash_inject(WMA_HANDLE wma_handle, uint32_t type,
9023 uint32_t delay_time_ms)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009024{
Govind Singhd76a5b02016-03-08 15:12:14 +05309025 struct crash_inject param;
Yu Wang46082dc2017-09-19 12:25:38 +08009026 tp_wma_handle wma = (tp_wma_handle)wma_handle;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07009027
Govind Singhd76a5b02016-03-08 15:12:14 +05309028 param.type = type;
9029 param.delay_time_ms = delay_time_ms;
Yu Wang46082dc2017-09-19 12:25:38 +08009030 return wmi_crash_inject(wma->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009031}
Govind Singhd76a5b02016-03-08 15:12:14 +05309032
Manjunathappa Prakash7b0ad462018-04-15 00:37:16 -07009033#ifdef RECEIVE_OFFLOAD
Dhanashri Atre09828f12016-11-13 10:36:58 -08009034int wma_lro_init(struct cdp_lro_hash_config *lro_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009035{
Rajeev Kumarb60abe42017-01-21 15:39:31 -08009036 struct scheduler_msg msg = {0};
Dhanashri Atre09828f12016-11-13 10:36:58 -08009037 struct cdp_lro_hash_config *iwcmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009038
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309039 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Arif Hussain157263f2018-10-03 13:07:15 -07009040 if (!iwcmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009041 return -ENOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009042
9043 *iwcmd = *lro_config;
9044
9045 msg.type = WMA_LRO_CONFIG_CMD;
9046 msg.reserved = 0;
9047 msg.bodyptr = iwcmd;
9048
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309049 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia00861f02018-08-28 19:16:12 +05309050 scheduler_post_message(QDF_MODULE_ID_WMA,
9051 QDF_MODULE_ID_WMA,
9052 QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009053 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309054 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009055 return -EAGAIN;
9056 }
9057
9058 WMA_LOGD("sending the LRO configuration to the fw");
9059 return 0;
9060}
9061#endif
Leo Chang96464902016-10-28 11:10:54 -07009062
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +05309063QDF_STATUS wma_configure_smps_params(uint32_t vdev_id, uint32_t param_id,
9064 uint32_t param_val)
9065{
9066 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
9067 int smps_cmd_value;
9068 int status = QDF_STATUS_E_INVAL;
9069
9070 if (!wma) {
9071 WMA_LOGE("%s: Failed to get wma", __func__);
9072 return status;
9073 }
9074
9075 smps_cmd_value = param_id << WMI_SMPS_PARAM_VALUE_S;
9076 smps_cmd_value = smps_cmd_value | param_val;
9077
9078 status = wma_set_smps_params(wma, vdev_id, smps_cmd_value);
9079 if (status)
9080 WMA_LOGE("Failed to set SMPS Param");
9081
9082 return status;
9083}
9084
Leo Chang96464902016-10-28 11:10:54 -07009085
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +05309086/**
9087 * wma_config_bmiss_bcnt_params() - set bmiss config parameters
9088 * @vdev_id: virtual device for the command
9089 * @first_cnt: bmiss first value
9090 * @final_cnt: bmiss final value
9091 *
9092 * Return: QDF_STATUS_SUCCESS or non-zero on failure
9093 */
9094QDF_STATUS wma_config_bmiss_bcnt_params(uint32_t vdev_id, uint32_t first_cnt,
9095 uint32_t final_cnt)
9096{
9097 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
9098 int status = QDF_STATUS_E_INVAL;
9099
9100 if (!wma_handle) {
9101 WMA_LOGE("%s: Failed to get wma", __func__);
9102 return status;
9103 }
9104
9105 status = wma_roam_scan_bmiss_cnt(wma_handle, first_cnt, final_cnt,
9106 vdev_id);
9107
9108 if (status)
9109 WMA_LOGE("Failed to set Bmiss Param");
9110
9111 return status;
9112}
9113