blob: 5b2cfa34f9e7a076bf0d333e6f2f45858f263f46 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Amar Singhal4c3fbb42018-01-02 13:20:28 -08002 * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**
20 * DOC: wma_main.c
21 *
22 * This file contains wma initialization and FW exchange
23 * related functions.
24 */
25
26/* Header files */
27
28#include "wma.h"
29#include "wma_api.h"
30#include "cds_api.h"
31#include "wmi_unified_api.h"
32#include "wlan_qct_sys.h"
33#include "wni_api.h"
34#include "ani_global.h"
35#include "wmi_unified.h"
36#include "wni_cfg.h"
37#include "cfg_api.h"
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +053038#if defined(CONFIG_HL_SUPPORT)
39#include "wlan_tgt_def_config_hl.h"
40#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080041#include "wlan_tgt_def_config.h"
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +053042#endif
Nirav Shahcbc6d722016-03-01 16:24:53 +053043#include "qdf_nbuf.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053044#include "qdf_types.h"
Anurag Chouhan600c3a02016-03-01 10:33:54 +053045#include "qdf_mem.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "wma_types.h"
47#include "lim_api.h"
48#include "lim_session_utils.h"
49
50#include "cds_utils.h"
51
52#if !defined(REMOVE_PKT_LOG)
53#include "pktlog_ac.h"
54#endif /* REMOVE_PKT_LOG */
55
56#include "dbglog_host.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057#include "csr_api.h"
58#include "ol_fw.h"
59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060#include "wma_internal.h"
61
62#include "wma_ocb.h"
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -070063#include "wlan_policy_mgr_api.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080064#include "cdp_txrx_cfg.h"
65#include "cdp_txrx_flow_ctrl_legacy.h"
66#include "cdp_txrx_flow_ctrl_v2.h"
67#include "cdp_txrx_ipa.h"
Leo Chang96464902016-10-28 11:10:54 -070068#include "cdp_txrx_misc.h"
Jeff Johnson6136fb92017-03-30 15:21:49 -070069#include "wma_fips_api.h"
Deepak Dhamdhere13230d32016-05-26 00:46:53 -070070#include "wma_nan_datapath.h"
Frank Liu65b17d92016-11-23 15:58:44 +080071#include "wlan_lmac_if_def.h"
72#include "wlan_lmac_if_api.h"
Mukul Sharmac3e7a782017-02-03 12:16:11 +053073#include "target_if.h"
Mukul Sharmadad267e2017-02-04 13:25:34 +053074#include "wlan_global_lmac_if_api.h"
Mukul Sharma3d36c392017-01-18 18:39:12 +053075#include "target_if_pmo.h"
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -070076#include "wma_he.h"
Mukul Sharma6411bb82017-03-01 15:57:07 +053077#include "wlan_pmo_obj_mgmt_api.h"
Frank Liu65b17d92016-11-23 15:58:44 +080078
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070079#include "wlan_reg_tgt_api.h"
80#include "wlan_reg_services_api.h"
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080081#include <cdp_txrx_handle.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070082#include <wlan_pmo_ucfg_api.h>
Naveen Rawat4efe41b2017-04-29 16:23:14 -070083#include "wifi_pos_api.h"
84#include "hif_main.h"
Sandeep Puligilla063a4342018-01-10 02:50:14 -080085#include <target_if_spectral.h>
86#include <wlan_spectral_utils_api.h>
Arunk Khandavallia6305a32018-01-25 11:19:18 +053087#include "init_event_handler.h"
Sourav Mohapatracf632572018-04-02 11:01:35 +053088#include "init_deinit_lmac.h"
Himanshu Agarwalceb9faa2018-01-24 22:30:05 +053089#include "target_if_green_ap.h"
Arunk Khandavalli10af7282018-02-05 16:55:48 +053090#include "service_ready_param.h"
Naveen Rawat3ff5cff2018-01-29 14:31:16 -080091#include "wlan_cp_stats_mc_ucfg_api.h"
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070092
Agrawal Ashishb0aa0752017-04-21 19:31:10 +053093#define WMA_LOG_COMPLETION_TIMER 3000 /* 3 seconds */
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +053094#define WMI_TLV_HEADROOM 128
gaurank kathpalia85f8a612018-02-21 18:55:24 +053095
96#define WMA_FW_TIME_SYNC_TIMER 60000 /* 1 min */
97
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -070098uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099static uint32_t g_fw_wlan_feat_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100/**
101 * wma_get_fw_wlan_feat_caps() - get fw feature capablity
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700102 * @feature: feature enum value
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 *
104 * Return: true/false
105 */
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700106bool wma_get_fw_wlan_feat_caps(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -0700108 return (g_fw_wlan_feat_caps & (1 << feature)) ? true : false;
109}
110
111/**
112 * wma_set_fw_wlan_feat_caps() - set fw feature capablity
113 * @feature: feature enum value
114 *
115 * Return: None
116 */
117void wma_set_fw_wlan_feat_caps(enum cap_bitmap feature)
118{
119 g_fw_wlan_feat_caps |= (1 << feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120}
121
122/**
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530123 * wma_service_ready_ext_evt_timeout() - Service ready extended event timeout
124 * @data: Timeout handler data
125 *
126 * This function is called when the FW fails to send WMI_SERVICE_READY_EXT_EVENT
127 * message
128 *
129 * Return: None
130 */
131static void wma_service_ready_ext_evt_timeout(void *data)
132{
133 tp_wma_handle wma_handle;
134
135 WMA_LOGA("%s: Timeout waiting for WMI_SERVICE_READY_EXT_EVENT",
136 __func__);
137
138 wma_handle = (tp_wma_handle) data;
139
140 if (!wma_handle) {
141 WMA_LOGE("%s: Invalid WMA handle", __func__);
142 goto end;
143 }
144
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530145end:
Naveen Rawatac39a102016-10-07 10:58:29 -0700146 /* Assert here. Panic is being called in insmod thread */
147 QDF_ASSERT(0);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +0530148}
149
150/**
Komal Seelam02d09342016-02-23 18:03:19 +0530151 * wma_get_ini_handle() - API to get WMA ini info handle
152 * @wma: WMA Handle
153 *
154 * Returns the pointer to WMA ini structure.
155 * Return: struct wma_ini_config
156 */
157struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma)
158{
159 if (!wma) {
160 WMA_LOGE("%s: Invalid WMA context\n", __func__);
161 return NULL;
162 }
163
164 return &wma->ini_config;
165}
166
167#define MAX_SUPPORTED_PEERS_REV1_1 14
168#define MAX_SUPPORTED_PEERS_REV1_3 32
169#define MIN_NO_OF_PEERS 1
170
171/**
172 * wma_get_number_of_peers_supported - API to query for number of peers
173 * supported
174 * @wma: WMA Handle
175 *
176 * Return: Max Number of Peers Supported
177 */
178static uint8_t wma_get_number_of_peers_supported(tp_wma_handle wma)
179{
180 struct hif_target_info *tgt_info;
181 struct wma_ini_config *cfg = wma_get_ini_handle(wma);
182 uint8_t max_no_of_peers = cfg ? cfg->max_no_of_peers : MIN_NO_OF_PEERS;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530183 struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF);
Komal Seelam02d09342016-02-23 18:03:19 +0530184
185 if (!scn) {
186 WMA_LOGE("%s: Invalid wma handle", __func__);
187 return 0;
188 }
189
190 tgt_info = hif_get_target_info_handle(scn);
191
192 switch (tgt_info->target_version) {
193 case AR6320_REV1_1_VERSION:
194 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_1)
195 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_1;
196 break;
197 default:
198 if (max_no_of_peers > MAX_SUPPORTED_PEERS_REV1_3)
199 max_no_of_peers = MAX_SUPPORTED_PEERS_REV1_3;
200 break;
201 }
202
203 return max_no_of_peers;
204}
205
206/**
bings6b3614e2017-02-21 10:18:36 +0800207 * wma_get_number_of_tids_supported - API to query for number of tids supported
208 * @no_of_peers_supported: Number of peer supported
209 *
210 * Return: Max number of tids supported
211 */
212#if defined(CONFIG_HL_SUPPORT)
213static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported)
214{
215 return 4 * no_of_peers_supported;
216}
217#else
218static uint32_t wma_get_number_of_tids_supported(uint8_t no_of_peers_supported)
219{
220 return 2 * (no_of_peers_supported + CFG_TGT_NUM_VDEV + 2);
221}
222#endif
223
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530224#ifdef PERE_IP_HDR_ALIGNMENT_WAR
225static void wma_reset_rx_decap_mode(target_resource_config *tgt_cfg)
226{
227 /*
228 * To make the IP header begins at dword aligned address,
229 * we make the decapsulation mode as Native Wifi.
230 */
231 tgt_cfg->rx_decap_mode = CFG_TGT_RX_DECAP_MODE_NWIFI;
232}
233#else
234static void wma_reset_rx_decap_mode(target_resource_config *tgt_cfg)
235{
236}
237
238#endif
bings6b3614e2017-02-21 10:18:36 +0800239/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 * wma_set_default_tgt_config() - set default tgt config
241 * @wma_handle: wma handle
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530242 * @tgt_cfg: Resource config given to target
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 *
244 * Return: none
245 */
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530246static void wma_set_default_tgt_config(tp_wma_handle wma_handle,
247 target_resource_config *tgt_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 uint8_t no_of_peers_supported;
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530250
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530251 qdf_mem_zero(tgt_cfg, sizeof(target_resource_config));
252 tgt_cfg->num_vdevs = CFG_TGT_NUM_VDEV;
253 tgt_cfg->num_peers = CFG_TGT_NUM_PEERS + CFG_TGT_NUM_VDEV + 2;
254 tgt_cfg->num_offload_peers = CFG_TGT_NUM_OFFLOAD_PEERS;
255 tgt_cfg->num_offload_reorder_buffs = CFG_TGT_NUM_OFFLOAD_REORDER_BUFFS;
256 tgt_cfg->num_peer_keys = CFG_TGT_NUM_PEER_KEYS;
257 tgt_cfg->num_tids = CFG_TGT_NUM_TIDS;
258 tgt_cfg->ast_skid_limit = CFG_TGT_AST_SKID_LIMIT;
259 tgt_cfg->tx_chain_mask = CFG_TGT_DEFAULT_TX_CHAIN_MASK;
260 tgt_cfg->rx_chain_mask = CFG_TGT_DEFAULT_RX_CHAIN_MASK;
261 tgt_cfg->rx_timeout_pri[0] = CFG_TGT_RX_TIMEOUT_LO_PRI;
262 tgt_cfg->rx_timeout_pri[1] = CFG_TGT_RX_TIMEOUT_LO_PRI;
263 tgt_cfg->rx_timeout_pri[2] = CFG_TGT_RX_TIMEOUT_LO_PRI;
264 tgt_cfg->rx_timeout_pri[3] = CFG_TGT_RX_TIMEOUT_HI_PRI;
265 tgt_cfg->rx_decap_mode = CFG_TGT_RX_DECAP_MODE;
266 tgt_cfg->scan_max_pending_req = CFG_TGT_DEFAULT_SCAN_MAX_REQS;
267 tgt_cfg->bmiss_offload_max_vdev =
268 CFG_TGT_DEFAULT_BMISS_OFFLOAD_MAX_VDEV;
269 tgt_cfg->roam_offload_max_vdev = CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_VDEV;
270 tgt_cfg->roam_offload_max_ap_profiles =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530271 CFG_TGT_DEFAULT_ROAM_OFFLOAD_MAX_PROFILES;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530272 tgt_cfg->num_mcast_groups = CFG_TGT_DEFAULT_NUM_MCAST_GROUPS;
273 tgt_cfg->num_mcast_table_elems = CFG_TGT_DEFAULT_NUM_MCAST_TABLE_ELEMS;
274 tgt_cfg->mcast2ucast_mode = CFG_TGT_DEFAULT_MCAST2UCAST_MODE;
275 tgt_cfg->tx_dbg_log_size = CFG_TGT_DEFAULT_TX_DBG_LOG_SIZE;
276 tgt_cfg->num_wds_entries = CFG_TGT_WDS_ENTRIES;
277 tgt_cfg->dma_burst_size = CFG_TGT_DEFAULT_DMA_BURST_SIZE;
278 tgt_cfg->mac_aggr_delim = CFG_TGT_DEFAULT_MAC_AGGR_DELIM;
279 tgt_cfg->rx_skip_defrag_timeout_dup_detection_check =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800280 CFG_TGT_DEFAULT_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK,
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530281 tgt_cfg->vow_config = CFG_TGT_DEFAULT_VOW_CONFIG;
282 tgt_cfg->gtk_offload_max_vdev = CFG_TGT_DEFAULT_GTK_OFFLOAD_MAX_VDEV;
283 tgt_cfg->num_msdu_desc = CFG_TGT_NUM_MSDU_DESC;
284 tgt_cfg->max_frag_entries = CFG_TGT_MAX_FRAG_TABLE_ENTRIES;
285 tgt_cfg->num_tdls_vdevs = CFG_TGT_NUM_TDLS_VDEVS;
286 tgt_cfg->num_tdls_conn_table_entries =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530287 CFG_TGT_NUM_TDLS_CONN_TABLE_ENTRIES;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530288 tgt_cfg->beacon_tx_offload_max_vdev =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530289 CFG_TGT_DEFAULT_BEACON_TX_OFFLOAD_MAX_VDEV;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530290 tgt_cfg->num_multicast_filter_entries =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530291 CFG_TGT_MAX_MULTICAST_FILTER_ENTRIES;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530292 tgt_cfg->num_wow_filters = 0;
293 tgt_cfg->num_keep_alive_pattern = 0;
294 tgt_cfg->keep_alive_pattern_size = 0;
295 tgt_cfg->max_tdls_concurrent_sleep_sta =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530296 CFG_TGT_NUM_TDLS_CONC_SLEEP_STAS;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530297 tgt_cfg->max_tdls_concurrent_buffer_sta =
Mukul Sharmab10c8c72017-11-02 17:25:59 +0530298 CFG_TGT_NUM_TDLS_CONC_BUFFER_STAS;
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530299 tgt_cfg->wmi_send_separate = 0;
300 tgt_cfg->num_ocb_vdevs = CFG_TGT_NUM_OCB_VDEVS;
301 tgt_cfg->num_ocb_channels = CFG_TGT_NUM_OCB_CHANNELS;
302 tgt_cfg->num_ocb_schedules = CFG_TGT_NUM_OCB_SCHEDULES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303
Komal Seelam02d09342016-02-23 18:03:19 +0530304 no_of_peers_supported = wma_get_number_of_peers_supported(wma_handle);
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530305 tgt_cfg->num_peers = no_of_peers_supported + CFG_TGT_NUM_VDEV + 2;
306 tgt_cfg->num_tids = wma_get_number_of_tids_supported(
307 no_of_peers_supported);
308 tgt_cfg->scan_max_pending_req = wma_handle->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530310 tgt_cfg->mgmt_comp_evt_bundle_support = true;
311 tgt_cfg->tx_msdu_new_partition_id_support = true;
Nirav Shah20489972016-06-16 19:20:28 +0530312
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313 /* reduce the peer/vdev if CFG_TGT_NUM_MSDU_DESC exceeds 1000 */
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530314 wma_reset_rx_decap_mode(tgt_cfg);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700315
Arunk Khandavallicfde2712018-01-25 11:27:42 +0530316 if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE)
317 tgt_cfg->rx_decap_mode = CFG_TGT_RX_DECAP_MODE_RAW;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800318}
319
320/**
321 * wma_cli_get_command() - WMA "get" command processor
322 * @vdev_id: virtual device for the command
323 * @param_id: parameter id
324 * @vpdev: parameter category
325 *
326 * Return: parameter value on success, -EINVAL on failure
327 */
328int wma_cli_get_command(int vdev_id, int param_id, int vpdev)
329{
330 int ret = 0;
331 tp_wma_handle wma;
332 struct wma_txrx_node *intr = NULL;
333
Anurag Chouhan6d760662016-02-20 16:05:43 +0530334 wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335
336 if (NULL == wma) {
337 WMA_LOGE("%s: Invalid wma handle", __func__);
338 return -EINVAL;
339 }
340
341 intr = wma->interfaces;
342
343 if (VDEV_CMD == vpdev) {
344 switch (param_id) {
345 case WMI_VDEV_PARAM_NSS:
346 ret = intr[vdev_id].config.nss;
347 break;
348#ifdef QCA_SUPPORT_GTX
349 case WMI_VDEV_PARAM_GTX_HT_MCS:
350 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
351 break;
352 case WMI_VDEV_PARAM_GTX_VHT_MCS:
353 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
354 break;
355 case WMI_VDEV_PARAM_GTX_USR_CFG:
356 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
357 break;
358 case WMI_VDEV_PARAM_GTX_THRE:
359 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
360 break;
361 case WMI_VDEV_PARAM_GTX_MARGIN:
362 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
363 break;
364 case WMI_VDEV_PARAM_GTX_STEP:
365 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
366 break;
367 case WMI_VDEV_PARAM_GTX_MINTPC:
368 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
369 break;
370 case WMI_VDEV_PARAM_GTX_BW_MASK:
371 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
372 break;
373#endif /* QCA_SUPPORT_GTX */
374 case WMI_VDEV_PARAM_LDPC:
375 ret = intr[vdev_id].config.ldpc;
376 break;
377 case WMI_VDEV_PARAM_TX_STBC:
378 ret = intr[vdev_id].config.tx_stbc;
379 break;
380 case WMI_VDEV_PARAM_RX_STBC:
381 ret = intr[vdev_id].config.rx_stbc;
382 break;
383 case WMI_VDEV_PARAM_SGI:
384 ret = intr[vdev_id].config.shortgi;
385 break;
386 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
387 ret = intr[vdev_id].config.rtscts_en;
388 break;
389 case WMI_VDEV_PARAM_CHWIDTH:
390 ret = intr[vdev_id].config.chwidth;
391 break;
392 case WMI_VDEV_PARAM_FIXED_RATE:
393 ret = intr[vdev_id].config.tx_rate;
394 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700395 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -0700396 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -0700397 ret = wma_get_he_vdev_param(&intr[vdev_id], param_id);
398 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700400 WMA_LOGE("Invalid cli_get vdev command/Not yet implemented 0x%x",
401 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 return -EINVAL;
403 }
404 } else if (PDEV_CMD == vpdev) {
405 switch (param_id) {
406 case WMI_PDEV_PARAM_ANI_ENABLE:
407 ret = wma->pdevconfig.ani_enable;
408 break;
409 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
410 ret = wma->pdevconfig.ani_poll_len;
411 break;
412 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
413 ret = wma->pdevconfig.ani_listen_len;
414 break;
415 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
416 ret = wma->pdevconfig.ani_ofdm_level;
417 break;
418 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
419 ret = wma->pdevconfig.ani_cck_level;
420 break;
421 case WMI_PDEV_PARAM_DYNAMIC_BW:
422 ret = wma->pdevconfig.cwmenable;
423 break;
424 case WMI_PDEV_PARAM_CTS_CBW:
425 ret = wma->pdevconfig.cts_cbw;
426 break;
427 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
428 ret = wma->pdevconfig.txchainmask;
429 break;
430 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
431 ret = wma->pdevconfig.rxchainmask;
432 break;
433 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
434 ret = wma->pdevconfig.txpow2g;
435 break;
436 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
437 ret = wma->pdevconfig.txpow5g;
438 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 case WMI_PDEV_PARAM_BURST_ENABLE:
440 ret = wma->pdevconfig.burst_enable;
441 break;
442 case WMI_PDEV_PARAM_BURST_DUR:
443 ret = wma->pdevconfig.burst_dur;
444 break;
445 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700446 WMA_LOGE("Invalid cli_get pdev command/Not yet implemented 0x%x",
447 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 return -EINVAL;
449 }
450 } else if (GEN_CMD == vpdev) {
451 switch (param_id) {
452 case GEN_VDEV_PARAM_AMPDU:
453 ret = intr[vdev_id].config.ampdu;
454 break;
455 case GEN_VDEV_PARAM_AMSDU:
456 ret = intr[vdev_id].config.amsdu;
457 break;
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700458 case GEN_VDEV_ROAM_SYNCH_DELAY:
459 ret = intr[vdev_id].roam_synch_delay;
460 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700462 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
463 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 return -EINVAL;
465 }
466 } else if (PPS_CMD == vpdev) {
467 switch (param_id) {
468 case WMI_VDEV_PPS_PAID_MATCH:
469 ret = intr[vdev_id].config.pps_params.paid_match_enable;
470 break;
471 case WMI_VDEV_PPS_GID_MATCH:
472 ret = intr[vdev_id].config.pps_params.gid_match_enable;
473 break;
474 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
475 ret = intr[vdev_id].config.pps_params.tim_clear;
476 break;
477 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
478 ret = intr[vdev_id].config.pps_params.dtim_clear;
479 break;
480 case WMI_VDEV_PPS_EOF_PAD_DELIM:
481 ret = intr[vdev_id].config.pps_params.eof_delim;
482 break;
483 case WMI_VDEV_PPS_MACADDR_MISMATCH:
484 ret = intr[vdev_id].config.pps_params.mac_match;
485 break;
486 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
487 ret = intr[vdev_id].config.pps_params.delim_fail;
488 break;
489 case WMI_VDEV_PPS_GID_NSTS_ZERO:
490 ret = intr[vdev_id].config.pps_params.nsts_zero;
491 break;
492 case WMI_VDEV_PPS_RSSI_CHECK:
493 ret = intr[vdev_id].config.pps_params.rssi_chk;
494 break;
495 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700496 WMA_LOGE("Invalid pps vdev command/Not yet implemented 0x%x",
497 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 return -EINVAL;
499 }
500 } else if (QPOWER_CMD == vpdev) {
501 switch (param_id) {
502 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
503 ret = intr[vdev_id].config.qpower_params.
504 max_ps_poll_cnt;
505 break;
506 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
507 ret = intr[vdev_id].config.qpower_params.
508 max_tx_before_wake;
509 break;
510 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
511 ret = intr[vdev_id].config.qpower_params.
512 spec_ps_poll_wake_interval;
513 break;
514 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
515 ret = intr[vdev_id].config.qpower_params.
516 max_spec_nodata_ps_poll;
517 break;
518 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700519 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
520 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 return -EINVAL;
522 }
523 } else if (GTX_CMD == vpdev) {
524 switch (param_id) {
525 case WMI_VDEV_PARAM_GTX_HT_MCS:
526 ret = intr[vdev_id].config.gtx_info.gtxRTMask[0];
527 break;
528 case WMI_VDEV_PARAM_GTX_VHT_MCS:
529 ret = intr[vdev_id].config.gtx_info.gtxRTMask[1];
530 break;
531 case WMI_VDEV_PARAM_GTX_USR_CFG:
532 ret = intr[vdev_id].config.gtx_info.gtxUsrcfg;
533 break;
534 case WMI_VDEV_PARAM_GTX_THRE:
535 ret = intr[vdev_id].config.gtx_info.gtxPERThreshold;
536 break;
537 case WMI_VDEV_PARAM_GTX_MARGIN:
538 ret = intr[vdev_id].config.gtx_info.gtxPERMargin;
539 break;
540 case WMI_VDEV_PARAM_GTX_STEP:
541 ret = intr[vdev_id].config.gtx_info.gtxTPCstep;
542 break;
543 case WMI_VDEV_PARAM_GTX_MINTPC:
544 ret = intr[vdev_id].config.gtx_info.gtxTPCMin;
545 break;
546 case WMI_VDEV_PARAM_GTX_BW_MASK:
547 ret = intr[vdev_id].config.gtx_info.gtxBWMask;
548 break;
549 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700550 WMA_LOGE("Invalid generic vdev command/Not yet implemented 0x%x",
551 param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800552 return -EINVAL;
553 }
554 }
555 return ret;
556}
557
558/**
559 * wma_cli_set2_command() - WMA "set 2 params" command processor
560 * @vdev_id: virtual device for the command
561 * @param_id: parameter id
562 * @sval1: first parameter value
563 * @sval2: second parameter value
564 * @vpdev: parameter category
565 *
566 * Command handler for set operations which require 2 parameters
567 *
568 * Return: 0 on success, errno on failure
569 */
570int wma_cli_set2_command(int vdev_id, int param_id, int sval1,
571 int sval2, int vpdev)
572{
Rajeev Kumarb60abe42017-01-21 15:39:31 -0800573 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 wma_cli_set_cmd_t *iwcmd;
575
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530576 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 if (!iwcmd) {
578 WMA_LOGE("%s: Failed alloc memory for iwcmd", __func__);
579 return -ENOMEM;
580 }
581
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530582 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 iwcmd->param_value = sval1;
584 iwcmd->param_sec_value = sval2;
585 iwcmd->param_vdev_id = vdev_id;
586 iwcmd->param_id = param_id;
587 iwcmd->param_vp_dev = vpdev;
588 msg.type = WMA_CLI_SET_CMD;
589 msg.reserved = 0;
590 msg.bodyptr = iwcmd;
591
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530592 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -0800593 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -0700594 WMA_LOGE("%s: Failed to post WMA_CLI_SET_CMD msg",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530596 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 return -EIO;
598 }
599 return 0;
600}
601
602/**
603 * wma_cli_set_command() - WMA "set" command processor
604 * @vdev_id: virtual device for the command
605 * @param_id: parameter id
606 * @sval: parameter value
607 * @vpdev: parameter category
608 *
609 * Command handler for set operations
610 *
611 * Return: 0 on success, errno on failure
612 */
613int wma_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
614{
615 return wma_cli_set2_command(vdev_id, param_id, sval, 0, vpdev);
616
617}
618
Krunal Soniaadaa272017-10-04 16:42:55 -0700619QDF_STATUS wma_form_unit_test_cmd_and_send(uint32_t vdev_id,
620 uint32_t module_id, uint32_t arg_count, uint32_t *arg)
621{
622 struct wmi_unit_test_cmd *unit_test_args;
623 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
624 uint32_t i;
625 QDF_STATUS status;
626
627 WMA_LOGD(FL("enter"));
628 if (arg_count >= WMA_MAX_NUM_ARGS) {
629 WMA_LOGE(FL("arg_count is crossed the boundary"));
630 return QDF_STATUS_E_FAILURE;
631 }
632 if (!wma_handle || !wma_handle->wmi_handle) {
633 WMA_LOGE(FL("Invalid WMA/WMI handle"));
634 return QDF_STATUS_E_FAILURE;
635 }
636 unit_test_args = qdf_mem_malloc(sizeof(*unit_test_args));
637 if (NULL == unit_test_args) {
638 WMA_LOGE(FL("qdf_mem_malloc failed for unit_test_args"));
639 return QDF_STATUS_E_NOMEM;
640 }
641 unit_test_args->vdev_id = vdev_id;
642 unit_test_args->module_id = module_id;
643 unit_test_args->num_args = arg_count;
644 for (i = 0; i < arg_count; i++)
645 unit_test_args->args[i] = arg[i];
646
647 status = wmi_unified_unit_test_cmd(wma_handle->wmi_handle,
648 unit_test_args);
649 qdf_mem_free(unit_test_args);
650 WMA_LOGD(FL("exit"));
651
652 return status;
653}
654
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -0800655static void wma_process_send_addba_req(tp_wma_handle wma_handle,
656 struct send_add_ba_req *send_addba)
657{
658 QDF_STATUS status;
659
660 if (!wma_handle || !wma_handle->wmi_handle) {
661 WMA_LOGE(FL("Invalid WMA/WMI handle"));
662 qdf_mem_free(send_addba);
663 return;
664 }
665
666 status = wmi_unified_addba_send_cmd_send(wma_handle->wmi_handle,
667 send_addba->mac_addr,
668 &send_addba->param);
669 if (QDF_STATUS_SUCCESS != status) {
670 WMA_LOGE(FL("Failed to process WMA_SEND_ADDBA_REQ"));
671 }
672 WMA_LOGD(FL("sent ADDBA req to" MAC_ADDRESS_STR "tid %d buff_size %d"),
673 MAC_ADDR_ARRAY(send_addba->mac_addr),
674 send_addba->param.tidno,
675 send_addba->param.buffersize);
676
677 qdf_mem_free(send_addba);
678}
679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680/**
Yun Parkb4f591d2017-03-29 15:51:01 -0700681 * wma_ipa_get_stat() - get IPA data path stats from FW
682 *
683 * Return: 0 on success, errno on failure
684 */
685#ifdef IPA_OFFLOAD
686static int wma_ipa_get_stat(void)
687{
688 struct cdp_pdev *pdev;
689
690 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
691 if (!pdev) {
692 WMA_LOGE("pdev NULL for uc stat");
693 return -EINVAL;
694 }
695 cdp_ipa_get_stat(cds_get_context(QDF_MODULE_ID_SOC), pdev);
696
697 return 0;
698}
699#else
700static int wma_ipa_get_stat(void)
701{
702 return 0;
703}
704#endif
705
706/**
707 * wma_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
708 * @privcmd: private command
709 *
710 * Return: 0 on success, errno on failure
711 */
712#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
713static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
714{
715 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
716 struct cdp_pdev *pdev;
717 uint8_t reset_stats = privcmd->param_value;
718
719 WMA_LOGD("%s: reset_stats=%d",
720 "WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID",
721 reset_stats);
722 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
723 if (!pdev) {
724 WMA_LOGE("pdev NULL for uc get share stats");
725 return -EINVAL;
726 }
727 cdp_ipa_uc_get_share_stats(soc, pdev, reset_stats);
728
729 return 0;
730}
731#else
732static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
733{
734 return 0;
735}
736#endif
737
738/**
739 * wma_ipa_uc_set_quota() - set quota limit to FW
740 * @privcmd: private command
741 *
742 * Return: 0 on success, errno on failure
743 */
744#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
745static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
746{
747 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
748 struct cdp_pdev *pdev;
749 uint64_t quota_bytes = privcmd->param_sec_value;
750
751 quota_bytes <<= 32;
752 quota_bytes |= privcmd->param_value;
753
754 WMA_LOGD("%s: quota_bytes=%llu",
755 "WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID",
756 quota_bytes);
757 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
758 if (!pdev) {
759 WMA_LOGE("pdev NULL for uc set quota");
760 return -EINVAL;
761 }
762 cdp_ipa_uc_set_quota(soc, pdev, quota_bytes);
763
764 return 0;
765}
766#else
767static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
768{
769 return 0;
770}
771#endif
772
773/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 * wma_set_priv_cfg() - set private config parameters
775 * @wma_handle: wma handle
776 * @privcmd: private command
777 *
778 * Return: 0 for success or error code
779 */
780static int32_t wma_set_priv_cfg(tp_wma_handle wma_handle,
781 wma_cli_set_cmd_t *privcmd)
782{
783 int32_t ret = 0;
784
785 switch (privcmd->param_id) {
786 case WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID:
787 ret = wma_set_txrx_fw_stats_level(wma_handle,
788 privcmd->param_vdev_id,
789 privcmd->param_value);
790 break;
791 case WMA_VDEV_TXRX_FWSTATS_RESET_CMDID:
792 ret = wma_txrx_fw_stats_reset(wma_handle,
793 privcmd->param_vdev_id,
794 privcmd->param_value);
795 break;
796 case WMI_STA_SMPS_FORCE_MODE_CMDID:
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800797 ret = wma_set_mimops(wma_handle,
798 privcmd->param_vdev_id,
799 privcmd->param_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 break;
801 case WMI_STA_SMPS_PARAM_CMDID:
802 wma_set_smps_params(wma_handle, privcmd->param_vdev_id,
803 privcmd->param_value);
804 break;
805 case WMA_VDEV_MCC_SET_TIME_LATENCY:
806 {
807 /* Extract first MCC adapter/vdev channel number and latency */
808 uint8_t mcc_channel = privcmd->param_value & 0x000000FF;
809 uint8_t mcc_channel_latency =
810 (privcmd->param_value & 0x0000FF00) >> 8;
811 int ret = -1;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -0700812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 WMA_LOGD("%s: Parsed input: Channel #1:%d, latency:%dms",
814 __func__, mcc_channel, mcc_channel_latency);
815 ret = wma_set_mcc_channel_time_latency(wma_handle,
816 mcc_channel,
817 mcc_channel_latency);
818 }
819 break;
820 case WMA_VDEV_MCC_SET_TIME_QUOTA:
821 {
822 /* Extract the MCC 2 adapters/vdevs channel numbers and time
823 * quota value for the first adapter only (which is specified
824 * in iwpriv command.
825 */
826 uint8_t adapter_2_chan_number =
827 privcmd->param_value & 0x000000FF;
828 uint8_t adapter_1_chan_number =
829 (privcmd->param_value & 0x0000FF00) >> 8;
830 uint8_t adapter_1_quota =
831 (privcmd->param_value & 0x00FF0000) >> 16;
832 int ret = -1;
833
834 WMA_LOGD("%s: Parsed input: Channel #1:%d, Channel #2:%d, quota 1:%dms",
835 __func__, adapter_1_chan_number,
836 adapter_2_chan_number, adapter_1_quota);
837
838 ret = wma_set_mcc_channel_time_quota(wma_handle,
839 adapter_1_chan_number,
840 adapter_1_quota,
841 adapter_2_chan_number);
842 }
843 break;
844 case WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE:
845 {
846 wma_handle->wma_ibss_power_save_params.atimWindowLength =
847 privcmd->param_value;
848 WMA_LOGD("%s: IBSS power save ATIM Window = %d",
849 __func__, wma_handle->wma_ibss_power_save_params.
850 atimWindowLength);
851 }
852 break;
853 case WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED:
854 {
855 wma_handle->wma_ibss_power_save_params.isPowerSaveAllowed =
856 privcmd->param_value;
857 WMA_LOGD("%s: IBSS is Power Save Allowed = %d",
858 __func__, wma_handle->wma_ibss_power_save_params.
859 isPowerSaveAllowed);
860 }
861 break;
862 case WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED:
863 {
864 wma_handle->wma_ibss_power_save_params. isPowerCollapseAllowed =
865 privcmd->param_value;
866 WMA_LOGD("%s: IBSS is Power Collapse Allowed = %d",
867 __func__, wma_handle->wma_ibss_power_save_params.
868 isPowerCollapseAllowed);
869 }
870 break;
871 case WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX:
872 {
873 wma_handle->wma_ibss_power_save_params.isAwakeonTxRxEnabled =
874 privcmd->param_value;
875 WMA_LOGD("%s: IBSS Power Save Awake on Tx/Rx Enabled = %d",
876 __func__, wma_handle->wma_ibss_power_save_params.
877 isAwakeonTxRxEnabled);
878 }
879 break;
880 case WMA_VDEV_IBSS_SET_INACTIVITY_TIME:
881 {
882 wma_handle->wma_ibss_power_save_params.inactivityCount =
883 privcmd->param_value;
884 WMA_LOGD("%s: IBSS Power Save Data Inactivity Count = %d",
885 __func__, wma_handle->wma_ibss_power_save_params.
886 inactivityCount);
887 }
888 break;
889 case WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME:
890 {
891 wma_handle->wma_ibss_power_save_params.txSPEndInactivityTime =
892 privcmd->param_value;
893 WMA_LOGD("%s: IBSS Power Save Transmit EOSP inactivity time out = %d",
894 __func__, wma_handle->wma_ibss_power_save_params.
895 txSPEndInactivityTime);
896 }
897 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 case WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS:
899 {
900 wma_handle->wma_ibss_power_save_params.ibssPsWarmupTime =
901 privcmd->param_value;
902 WMA_LOGD("%s: IBSS Power Save Warm Up Time in Seconds = %d",
903 __func__, wma_handle->wma_ibss_power_save_params.
904 ibssPsWarmupTime);
905 }
906 break;
907 case WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW:
908 {
909 wma_handle->wma_ibss_power_save_params.ibssPs1RxChainInAtimEnable
910 = privcmd->param_value;
911 WMA_LOGD("%s: IBSS Power Save single RX Chain Enable In ATIM = %d",
912 __func__, wma_handle->wma_ibss_power_save_params.
913 ibssPs1RxChainInAtimEnable);
914 }
915 break;
916
917 case WMA_VDEV_TXRX_GET_IPA_UC_FW_STATS_CMDID:
918 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700919 wma_ipa_get_stat();
Yun Park637d6482016-10-05 10:51:33 -0700920 }
921 break;
922
923 case WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID:
924 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700925 wma_ipa_uc_get_share_stats(privcmd);
Yun Park637d6482016-10-05 10:51:33 -0700926 }
927 break;
928
929 case WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID:
930 {
Yun Parkb4f591d2017-03-29 15:51:01 -0700931 wma_ipa_uc_set_quota(privcmd);
Yun Park327e7812017-02-14 15:18:10 -0800932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 }
934 break;
935
936 default:
937 WMA_LOGE("Invalid wma config command id:%d", privcmd->param_id);
938 ret = -EINVAL;
939 }
940 return ret;
941}
942
943/**
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -0800944 * wma_set_dtim_period() - set dtim period to FW
945 * @wma: wma handle
946 * @dtim_params: dtim params
947 *
948 * Return: none
949 */
950static void wma_set_dtim_period(tp_wma_handle wma,
951 struct set_dtim_params *dtim_params)
952{
953 struct wma_txrx_node *iface =
954 &wma->interfaces[dtim_params->session_id];
955 if (!wma_is_vdev_valid(dtim_params->session_id)) {
956 WMA_LOGE("%s: invalid VDEV", __func__);
957 return;
958 }
959 WMA_LOGD("%s: set dtim_period %d", __func__,
960 dtim_params->dtim_period);
961 iface->dtimPeriod = dtim_params->dtim_period;
962
963}
964/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 * wma_set_modulated_dtim() - function to configure modulated dtim
966 * @wma: wma handle
967 * @privcmd: structure containing parameters
968 *
969 * This function configures the modulated dtim in firmware
970 *
971 * Return: none
972 */
973static void wma_set_modulated_dtim(tp_wma_handle wma,
974 wma_cli_set_cmd_t *privcmd)
975{
976 uint8_t vdev_id = privcmd->param_vdev_id;
977 struct wma_txrx_node *iface =
978 &wma->interfaces[vdev_id];
979 bool prev_dtim_enabled;
980 uint32_t listen_interval;
Govind Singhd76a5b02016-03-08 15:12:14 +0530981 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982
983 iface->alt_modulated_dtim = privcmd->param_value;
984
985 prev_dtim_enabled = iface->alt_modulated_dtim_enabled;
986
987 if (1 != privcmd->param_value)
988 iface->alt_modulated_dtim_enabled = true;
989 else
990 iface->alt_modulated_dtim_enabled = false;
991
992 if ((true == iface->alt_modulated_dtim_enabled) ||
993 (true == prev_dtim_enabled)) {
994
995 listen_interval = iface->alt_modulated_dtim
996 * iface->dtimPeriod;
997
Govind Singhd76a5b02016-03-08 15:12:14 +0530998 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 privcmd->param_vdev_id,
1000 WMI_VDEV_PARAM_LISTEN_INTERVAL,
1001 listen_interval);
Govind Singhd76a5b02016-03-08 15:12:14 +05301002 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 /* Even if it fails, continue */
1004 WMA_LOGW("Failed to set listen interval %d",
1005 listen_interval);
1006
Govind Singhd76a5b02016-03-08 15:12:14 +05301007 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 privcmd->param_vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001009 WMI_VDEV_PARAM_DTIM_POLICY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 NORMAL_DTIM);
Govind Singhd76a5b02016-03-08 15:12:14 +05301011 if (QDF_IS_STATUS_ERROR(ret))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 WMA_LOGE("Failed to Set to Normal DTIM policy");
1013 }
1014}
1015
Mukul Sharma6398b252017-05-01 17:58:12 +05301016/**
1017 * wma_override_listen_interval() - function to override static/ini based LI
1018 * @wma: wma handle
1019 * @privcmd: structure containing parameters
1020 *
1021 * This function override static/ini based LI in firmware
1022 *
1023 * Return: none
1024 */
1025static void wma_override_listen_interval(tp_wma_handle wma,
1026 wma_cli_set_cmd_t *privcmd)
1027{
1028 uint8_t vdev_id = privcmd->param_vdev_id;
1029 struct wma_txrx_node *iface =
1030 &wma->interfaces[vdev_id];
1031 u32 old_override_li, new_override_li, listen_interval;
1032 struct sAniSirGlobal *mac;
1033 QDF_STATUS ret;
1034
1035 mac = cds_get_context(QDF_MODULE_ID_PE);
1036 if (!mac) {
1037 WMA_LOGE(FL("Failed to get mac context"));
1038 return;
1039 }
1040
1041 old_override_li = iface->override_li;
1042 new_override_li = privcmd->param_value;
1043 iface->override_li = new_override_li;
1044
1045 if (new_override_li &&
1046 (new_override_li != old_override_li)) {
1047 listen_interval = new_override_li;
1048 } else if (!new_override_li &&
1049 (new_override_li != old_override_li)) {
1050 /* Configure default LI as we do on resume */
1051 if ((wlan_cfg_get_int(mac, WNI_CFG_LISTEN_INTERVAL,
1052 &listen_interval) != eSIR_SUCCESS)) {
1053 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_ERROR,
1054 "Failed to get value for listen interval");
1055 listen_interval = POWERSAVE_DEFAULT_LISTEN_INTERVAL;
1056 }
1057 } else {
1058 return;
1059 }
1060
1061 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
1062 WMI_VDEV_PARAM_LISTEN_INTERVAL,
1063 listen_interval);
1064 if (QDF_IS_STATUS_ERROR(ret)) {
1065 /* Even it fails continue Fw will take default LI */
1066 WMA_LOGE("Failed to Set Listen Interval vdevId %d",
1067 vdev_id);
1068 }
1069 WMA_LOGD("%s: Set Listen Interval vdevId %d Listen Intv %d",
1070 __func__, vdev_id, listen_interval);
1071 ret = wma_vdev_set_param(wma->wmi_handle,
1072 privcmd->param_vdev_id,
1073 WMI_VDEV_PARAM_DTIM_POLICY,
1074 NORMAL_DTIM);
1075 if (QDF_IS_STATUS_ERROR(ret))
1076 WMA_LOGE("Failed to Set to Normal DTIM policy");
1077
1078}
1079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080
1081/**
1082 * wma_process_cli_set_cmd() - set parameters to fw
1083 * @wma: wma handle
1084 * @privcmd: command
1085 *
1086 * Return: none
1087 */
1088static void wma_process_cli_set_cmd(tp_wma_handle wma,
1089 wma_cli_set_cmd_t *privcmd)
1090{
Govind Singhd76a5b02016-03-08 15:12:14 +05301091 int vid = privcmd->param_vdev_id, pps_val = 0;
1092 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 struct wma_txrx_node *intr = wma->interfaces;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301094 tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 struct qpower_params *qparams = &intr[vid].config.qpower_params;
Govind Singhd76a5b02016-03-08 15:12:14 +05301096 struct pdev_params pdev_param;
Leo Chang96464902016-10-28 11:10:54 -07001097 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05301098 struct target_psoc_info *tgt_hdl;
Kiran Kumar Lokere9f881ae2018-03-07 18:59:30 -08001099 struct sir_set_tx_rx_aggregation_size aggr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001100
Jeff Johnsonadba3962017-09-18 08:12:35 -07001101 WMA_LOGD("wmihandle %pK", wma->wmi_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102
1103 if (NULL == pMac) {
1104 WMA_LOGE("%s: Failed to get pMac", __func__);
1105 return;
1106 }
1107
Arunk Khandavalli2462f462018-01-25 14:41:02 +05301108 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma->psoc);
1109 if (!tgt_hdl) {
1110 WMA_LOGE("%s: target psoc info is NULL", __func__);
1111 return;
1112 }
1113
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001114 if (privcmd->param_id >= WMI_CMDID_MAX) {
1115 /*
1116 * This configuration setting is not done using any wmi
1117 * command, call appropriate handler.
1118 */
1119 if (wma_set_priv_cfg(wma, privcmd))
1120 WMA_LOGE("Failed to set wma priv congiuration");
1121 return;
1122 }
1123
1124 switch (privcmd->param_vp_dev) {
1125 case VDEV_CMD:
Bhargav Shaha89d3b42016-04-20 13:04:56 +05301126 if (!wma->interfaces[privcmd->param_vdev_id].is_vdev_valid) {
1127 WMA_LOGE("%s Vdev id is not valid", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001128 return;
Bhargav Shaha89d3b42016-04-20 13:04:56 +05301129 }
1130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1132 privcmd->param_id, privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +05301133 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 privcmd->param_vdev_id,
1135 privcmd->param_id,
1136 privcmd->param_value);
Govind Singhd76a5b02016-03-08 15:12:14 +05301137 if (QDF_IS_STATUS_ERROR(ret)) {
1138 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 ret);
1140 return;
1141 }
1142 break;
1143 case PDEV_CMD:
1144 WMA_LOGD("pdev pid %d pval %d", privcmd->param_id,
1145 privcmd->param_value);
1146 if ((privcmd->param_id == WMI_PDEV_PARAM_RX_CHAIN_MASK) ||
1147 (privcmd->param_id == WMI_PDEV_PARAM_TX_CHAIN_MASK)) {
Jiachao Wu08719b02017-07-05 13:05:34 +08001148 if (QDF_STATUS_SUCCESS !=
1149 wma_check_txrx_chainmask(
Arunk Khandavalli2462f462018-01-25 14:41:02 +05301150 target_if_get_num_rf_chains(tgt_hdl),
Jiachao Wu08719b02017-07-05 13:05:34 +08001151 privcmd->param_value)) {
1152 WMA_LOGD("Chainmask value is invalid");
1153 return;
1154 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155 }
Govind Singhd76a5b02016-03-08 15:12:14 +05301156 pdev_param.param_id = privcmd->param_id;
1157 pdev_param.param_value = privcmd->param_value;
1158 ret = wmi_unified_pdev_param_send(wma->wmi_handle,
1159 &pdev_param,
1160 WMA_WILDCARD_PDEV_ID);
1161 if (QDF_IS_STATUS_ERROR(ret)) {
1162 WMA_LOGE("wma_vdev_set_param failed ret %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163 ret);
1164 return;
1165 }
1166 break;
1167 case GEN_CMD:
1168 {
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001169 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 struct wma_txrx_node *intr = wma->interfaces;
1171
1172 vdev = wma_find_vdev_by_id(wma, privcmd->param_vdev_id);
1173 if (!vdev) {
1174 WMA_LOGE("%s:Invalid vdev handle", __func__);
1175 return;
1176 }
1177
1178 WMA_LOGD("gen pid %d pval %d", privcmd->param_id,
1179 privcmd->param_value);
1180
1181 switch (privcmd->param_id) {
1182 case GEN_VDEV_PARAM_AMPDU:
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301183 if (soc) {
1184 ret = cdp_aggr_cfg(soc, vdev,
1185 privcmd->param_value, 0);
1186 if (ret)
1187 WMA_LOGE("cdp_aggr_cfg set ampdu failed ret %d",
1188 ret);
1189 else
1190 intr[privcmd->param_vdev_id].config.
1191 ampdu = privcmd->param_value;
Kiran Kumar Lokere9f881ae2018-03-07 18:59:30 -08001192 aggr.vdev_id = vid;
1193 aggr.tx_aggregation_size =
1194 privcmd->param_value;
1195 aggr.rx_aggregation_size =
1196 privcmd->param_value;
1197 ret = wma_set_tx_rx_aggregation_size(&aggr);
1198 if (QDF_IS_STATUS_ERROR(ret)) {
1199 WMA_LOGE("set_aggr_size failed ret %d",
1200 ret);
1201 return;
1202 }
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05301203 } else {
1204 WMA_LOGE("%s:SOC context is NULL", __func__);
1205 return;
1206 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207 break;
1208 case GEN_VDEV_PARAM_AMSDU:
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001209 /*
1210 * Firmware currently does not support set operation
1211 * for AMSDU. It may cause crash if the configuration
1212 * is sent to firmware.
1213 * Firmware enhancement will advertise a service bit
1214 * to enable AMSDU configuration through WMI. Then
1215 * add the WMI command to configure AMSDU parameter.
1216 * For the older chipset that does not advertise the
1217 * service bit, enable the following legacy code:
1218 * ol_txrx_aggr_cfg(vdev, 0, privcmd->param_value);
1219 * intr[privcmd->param_vdev_id].config.amsdu =
1220 * privcmd->param_value;
1221 */
1222 WMA_LOGE("SET GEN_VDEV_PARAM_AMSDU command is currently not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224 case GEN_PARAM_CRASH_INJECT:
Rajeev Kumar0a9901b2015-12-15 15:59:19 -08001225 if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
1226 WMA_LOGE("Crash inject not allowed in FTM mode");
1227 else
1228 ret = wma_crash_inject(wma,
1229 privcmd->param_value,
1230 privcmd->param_sec_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001232 case GEN_PARAM_CAPTURE_TSF:
1233 ret = wma_capture_tsf(wma, privcmd->param_value);
1234 break;
1235 case GEN_PARAM_RESET_TSF_GPIO:
1236 ret = wma_reset_tsf_gpio(wma, privcmd->param_value);
1237 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 case GEN_PARAM_MODULATED_DTIM:
1239 wma_set_modulated_dtim(wma, privcmd);
1240 break;
Mukul Sharma6398b252017-05-01 17:58:12 +05301241 case GEN_PARAM_LISTEN_INTERVAL:
1242 wma_override_listen_interval(wma, privcmd);
1243 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 default:
1245 WMA_LOGE("Invalid param id 0x%x",
1246 privcmd->param_id);
1247 break;
1248 }
1249 break;
1250 }
1251 case DBG_CMD:
1252 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1253 privcmd->param_value);
1254 switch (privcmd->param_id) {
1255 case WMI_DBGLOG_LOG_LEVEL:
1256 ret = dbglog_set_log_lvl(wma->wmi_handle,
1257 privcmd->param_value);
1258 if (ret)
1259 WMA_LOGE("dbglog_set_log_lvl failed ret %d",
1260 ret);
1261 break;
1262 case WMI_DBGLOG_VAP_ENABLE:
1263 ret = dbglog_vap_log_enable(wma->wmi_handle,
1264 privcmd->param_value, true);
1265 if (ret)
1266 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1267 ret);
1268 break;
1269 case WMI_DBGLOG_VAP_DISABLE:
1270 ret = dbglog_vap_log_enable(wma->wmi_handle,
1271 privcmd->param_value, false);
1272 if (ret)
1273 WMA_LOGE("dbglog_vap_log_enable failed ret %d",
1274 ret);
1275 break;
1276 case WMI_DBGLOG_MODULE_ENABLE:
1277 ret = dbglog_module_log_enable(wma->wmi_handle,
1278 privcmd->param_value, true);
1279 if (ret)
1280 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1281 ret);
1282 break;
1283 case WMI_DBGLOG_MODULE_DISABLE:
1284 ret = dbglog_module_log_enable(wma->wmi_handle,
1285 privcmd->param_value, false);
1286 if (ret)
1287 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1288 ret);
1289 break;
1290 case WMI_DBGLOG_MOD_LOG_LEVEL:
1291 ret = dbglog_set_mod_log_lvl(wma->wmi_handle,
1292 privcmd->param_value);
1293 if (ret)
1294 WMA_LOGE("dbglog_module_log_enable failed ret %d",
1295 ret);
1296 break;
1297 case WMI_DBGLOG_TYPE:
1298 ret = dbglog_parser_type_init(wma->wmi_handle,
1299 privcmd->param_value);
1300 if (ret)
1301 WMA_LOGE("dbglog_parser_type_init failed ret %d",
1302 ret);
1303 break;
1304 case WMI_DBGLOG_REPORT_ENABLE:
1305 ret = dbglog_report_enable(wma->wmi_handle,
1306 privcmd->param_value);
1307 if (ret)
1308 WMA_LOGE("dbglog_report_enable failed ret %d",
1309 ret);
1310 break;
Govind Singha471e5e2015-10-12 17:11:14 +05301311 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301312 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301313 WMI_WLAN_PROFILE_TRIGGER_CMDID,
1314 privcmd->param_value, 0);
1315 if (ret)
1316 WMA_LOGE("Profile cmd failed for %d ret %d",
1317 WMI_WLAN_PROFILE_TRIGGER_CMDID, ret);
1318 break;
1319 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301320 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301321 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1322 privcmd->param_value,
1323 privcmd->param_sec_value);
1324 if (ret)
1325 WMA_LOGE("Profile cmd failed for %d ret %d",
1326 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1327 ret);
1328 break;
1329 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301330 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301331 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1332 privcmd->param_value,
1333 privcmd->param_sec_value);
1334 if (ret)
1335 WMA_LOGE("Profile cmd failed for %d ret %d",
1336 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1337 ret);
1338 break;
1339 case WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301340 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301341 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1342 0, 0);
1343 if (ret)
1344 WMA_LOGE("Profile cmd failed for %d ret %d",
1345 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1346 ret);
1347 break;
1348 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
Govind Singhf25a0f12016-03-08 16:09:48 +05301349 ret = wma_unified_fw_profiling_cmd(wma->wmi_handle,
Govind Singha471e5e2015-10-12 17:11:14 +05301350 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1351 0, 0);
1352 if (ret)
1353 WMA_LOGE("Profile cmd failed for %d ret %d",
1354 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1355 ret);
1356 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 case WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID:
1358 /* Set the Green AP */
Govind Singhd76a5b02016-03-08 15:12:14 +05301359 ret = wmi_unified_green_ap_ps_send
1360 (wma->wmi_handle, privcmd->param_value,
1361 WMA_WILDCARD_PDEV_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362 if (ret) {
1363 WMA_LOGE("Set GreenAP Failed val %d",
1364 privcmd->param_value);
1365 }
1366 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367
1368 default:
1369 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1370 break;
1371 }
1372 break;
1373 case PPS_CMD:
1374 WMA_LOGD("dbg pid %d pval %d", privcmd->param_id,
1375 privcmd->param_value);
1376 switch (privcmd->param_id) {
1377
1378 case WMI_VDEV_PPS_PAID_MATCH:
1379 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1380 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
1381 intr[vid].config.pps_params.paid_match_enable =
1382 privcmd->param_value;
1383 break;
1384 case WMI_VDEV_PPS_GID_MATCH:
1385 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1386 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
1387 intr[vid].config.pps_params.gid_match_enable =
1388 privcmd->param_value;
1389 break;
1390 case WMI_VDEV_PPS_EARLY_TIM_CLEAR:
1391 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1392 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
1393 intr[vid].config.pps_params.tim_clear =
1394 privcmd->param_value;
1395 break;
1396 case WMI_VDEV_PPS_EARLY_DTIM_CLEAR:
1397 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1398 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
1399 intr[vid].config.pps_params.dtim_clear =
1400 privcmd->param_value;
1401 break;
1402 case WMI_VDEV_PPS_EOF_PAD_DELIM:
1403 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1404 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
1405 intr[vid].config.pps_params.eof_delim =
1406 privcmd->param_value;
1407 break;
1408 case WMI_VDEV_PPS_MACADDR_MISMATCH:
1409 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1410 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
1411 intr[vid].config.pps_params.mac_match =
1412 privcmd->param_value;
1413 break;
1414 case WMI_VDEV_PPS_DELIM_CRC_FAIL:
1415 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1416 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
1417 intr[vid].config.pps_params.delim_fail =
1418 privcmd->param_value;
1419 break;
1420 case WMI_VDEV_PPS_GID_NSTS_ZERO:
1421 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1422 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
1423 intr[vid].config.pps_params.nsts_zero =
1424 privcmd->param_value;
1425 break;
1426 case WMI_VDEV_PPS_RSSI_CHECK:
1427 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1428 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
1429 intr[vid].config.pps_params.rssi_chk =
1430 privcmd->param_value;
1431 break;
1432 case WMI_VDEV_PPS_5G_EBT:
1433 pps_val = ((privcmd->param_value << 31) & 0xffff0000) |
1434 (PKT_PWR_SAVE_5G_EBT & 0xffff);
1435 intr[vid].config.pps_params.ebt_5g =
1436 privcmd->param_value;
1437 break;
1438 default:
1439 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1440 break;
1441 }
1442 break;
1443
1444 case QPOWER_CMD:
1445 WMA_LOGD("QPOWER CLI CMD pid %d pval %d", privcmd->param_id,
1446 privcmd->param_value);
1447 switch (privcmd->param_id) {
1448 case WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT:
1449 WMA_LOGD("QPOWER CLI CMD:Ps Poll Cnt val %d",
1450 privcmd->param_value);
1451 /* Set the QPower Ps Poll Count */
Govind Singhd76a5b02016-03-08 15:12:14 +05301452 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 vid, WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
1454 privcmd->param_value);
1455 if (ret) {
1456 WMA_LOGE("Set Q-PsPollCnt Failed vdevId %d val %d",
1457 vid, privcmd->param_value);
1458 } else {
1459 qparams->max_ps_poll_cnt = privcmd->param_value;
1460 }
1461 break;
1462 case WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE:
1463 WMA_LOGD("QPOWER CLI CMD:Max Tx Before wake val %d",
1464 privcmd->param_value);
1465 /* Set the QPower Max Tx Before Wake */
Govind Singhd76a5b02016-03-08 15:12:14 +05301466 ret = wma_unified_set_sta_ps_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 vid, WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
1468 privcmd->param_value);
1469 if (ret) {
1470 WMA_LOGE("Set Q-MaxTxBefWake Failed vId %d val %d",
1471 vid, privcmd->param_value);
1472 } else {
1473 qparams->max_tx_before_wake =
1474 privcmd->param_value;
1475 }
1476 break;
1477 case WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
1478 WMA_LOGD("QPOWER CLI CMD:Ps Poll Wake Inv val %d",
1479 privcmd->param_value);
1480 /* Set the QPower Spec Ps Poll Wake Inv */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001481 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1482 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483 privcmd->param_value);
1484 if (ret) {
1485 WMA_LOGE("Set Q-PsPoll WakeIntv Failed vId %d val %d",
1486 vid, privcmd->param_value);
1487 } else {
1488 qparams->spec_ps_poll_wake_interval =
1489 privcmd->param_value;
1490 }
1491 break;
1492 case WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
1493 WMA_LOGD("QPOWER CLI CMD:Spec NoData Ps Poll val %d",
1494 privcmd->param_value);
1495 /* Set the QPower Spec NoData PsPoll */
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001496 ret = wma_unified_set_sta_ps_param(wma->wmi_handle, vid,
1497 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 privcmd->param_value);
1499 if (ret) {
1500 WMA_LOGE("Set Q-SpecNoDataPsPoll Failed vId %d val %d",
1501 vid, privcmd->param_value);
1502 } else {
1503 qparams->max_spec_nodata_ps_poll =
1504 privcmd->param_value;
1505 }
1506 break;
1507
1508 default:
1509 WMA_LOGE("Invalid param id 0x%x", privcmd->param_id);
1510 break;
1511 }
1512 break;
1513 case GTX_CMD:
1514 WMA_LOGD("vdev id %d pid %d pval %d", privcmd->param_vdev_id,
1515 privcmd->param_id, privcmd->param_value);
1516 switch (privcmd->param_id) {
1517 case WMI_VDEV_PARAM_GTX_HT_MCS:
1518 intr[vid].config.gtx_info.gtxRTMask[0] =
1519 privcmd->param_value;
1520 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1521 privcmd->param_vdev_id,
1522 &intr[vid].config.gtx_info);
1523 break;
1524 case WMI_VDEV_PARAM_GTX_VHT_MCS:
1525 intr[vid].config.gtx_info.gtxRTMask[1] =
1526 privcmd->param_value;
1527 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1528 privcmd->param_vdev_id,
1529 &intr[vid].config.gtx_info);
1530 break;
1531
1532 case WMI_VDEV_PARAM_GTX_USR_CFG:
1533 intr[vid].config.gtx_info.gtxUsrcfg =
1534 privcmd->param_value;
1535 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1536 privcmd->param_vdev_id,
1537 &intr[vid].config.gtx_info);
1538 break;
1539
1540 case WMI_VDEV_PARAM_GTX_THRE:
1541 intr[vid].config.gtx_info.gtxPERThreshold =
1542 privcmd->param_value;
1543 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1544 privcmd->param_vdev_id,
1545 &intr[vid].config.gtx_info);
1546 break;
1547
1548 case WMI_VDEV_PARAM_GTX_MARGIN:
1549 intr[vid].config.gtx_info.gtxPERMargin =
1550 privcmd->param_value;
1551 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1552 privcmd->param_vdev_id,
1553 &intr[vid].config.gtx_info);
1554 break;
1555
1556 case WMI_VDEV_PARAM_GTX_STEP:
1557 intr[vid].config.gtx_info.gtxTPCstep =
1558 privcmd->param_value;
1559 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1560 privcmd->param_vdev_id,
1561 &intr[vid].config.gtx_info);
1562 break;
1563
1564 case WMI_VDEV_PARAM_GTX_MINTPC:
1565 intr[vid].config.gtx_info.gtxTPCMin =
1566 privcmd->param_value;
1567 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1568 privcmd->param_vdev_id,
1569 &intr[vid].config.gtx_info);
1570 break;
1571
1572 case WMI_VDEV_PARAM_GTX_BW_MASK:
1573 intr[vid].config.gtx_info.gtxBWMask =
1574 privcmd->param_value;
1575 ret = wmi_unified_vdev_set_gtx_cfg_send(wma->wmi_handle,
1576 privcmd->param_vdev_id,
1577 &intr[vid].config.gtx_info);
1578 if (ret) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001579 WMA_LOGE("wma_vdev_set_param failed ret %d",
1580 ret);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 return;
1582 }
1583 break;
1584 default:
1585 break;
1586 }
1587 break;
1588
1589 default:
1590 WMA_LOGE("Invalid vpdev command id");
1591 }
1592 if (1 == privcmd->param_vp_dev) {
1593 switch (privcmd->param_id) {
1594 case WMI_VDEV_PARAM_NSS:
1595 intr[vid].config.nss = privcmd->param_value;
1596 break;
1597 case WMI_VDEV_PARAM_LDPC:
1598 intr[vid].config.ldpc = privcmd->param_value;
1599 break;
1600 case WMI_VDEV_PARAM_TX_STBC:
1601 intr[vid].config.tx_stbc = privcmd->param_value;
1602 break;
1603 case WMI_VDEV_PARAM_RX_STBC:
1604 intr[vid].config.rx_stbc = privcmd->param_value;
1605 break;
1606 case WMI_VDEV_PARAM_SGI:
1607 intr[vid].config.shortgi = privcmd->param_value;
1608 break;
1609 case WMI_VDEV_PARAM_ENABLE_RTSCTS:
1610 intr[vid].config.rtscts_en = privcmd->param_value;
1611 break;
1612 case WMI_VDEV_PARAM_CHWIDTH:
1613 intr[vid].config.chwidth = privcmd->param_value;
1614 break;
1615 case WMI_VDEV_PARAM_FIXED_RATE:
1616 intr[vid].config.tx_rate = privcmd->param_value;
1617 break;
1618 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE:
1619 intr[vid].config.erx_adjust = privcmd->param_value;
1620 break;
1621 case WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM:
1622 intr[vid].config.erx_bmiss_num = privcmd->param_value;
1623 break;
1624 case WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE:
1625 intr[vid].config.erx_bmiss_cycle = privcmd->param_value;
1626 break;
1627 case WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP:
1628 intr[vid].config.erx_slop_step = privcmd->param_value;
1629 break;
1630 case WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP:
1631 intr[vid].config.erx_init_slop = privcmd->param_value;
1632 break;
1633 case WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE:
1634 intr[vid].config.erx_adj_pause = privcmd->param_value;
1635 break;
1636 case WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE:
1637 intr[vid].config.erx_dri_sample = privcmd->param_value;
1638 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001639 case WMI_VDEV_PARAM_HE_DCM:
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001640 case WMI_VDEV_PARAM_HE_RANGE_EXT:
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001641 wma_set_he_vdev_param(&intr[vid], privcmd->param_id,
1642 privcmd->param_value);
1643 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 default:
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001645 WMA_LOGE("Invalid wma_cli_set vdev command/Not yet implemented 0x%x",
1646 privcmd->param_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 break;
1648 }
1649 } else if (2 == privcmd->param_vp_dev) {
1650 switch (privcmd->param_id) {
1651 case WMI_PDEV_PARAM_ANI_ENABLE:
1652 wma->pdevconfig.ani_enable = privcmd->param_value;
1653 break;
1654 case WMI_PDEV_PARAM_ANI_POLL_PERIOD:
1655 wma->pdevconfig.ani_poll_len = privcmd->param_value;
1656 break;
1657 case WMI_PDEV_PARAM_ANI_LISTEN_PERIOD:
1658 wma->pdevconfig.ani_listen_len = privcmd->param_value;
1659 break;
1660 case WMI_PDEV_PARAM_ANI_OFDM_LEVEL:
1661 wma->pdevconfig.ani_ofdm_level = privcmd->param_value;
1662 break;
1663 case WMI_PDEV_PARAM_ANI_CCK_LEVEL:
1664 wma->pdevconfig.ani_cck_level = privcmd->param_value;
1665 break;
1666 case WMI_PDEV_PARAM_DYNAMIC_BW:
1667 wma->pdevconfig.cwmenable = privcmd->param_value;
1668 break;
1669 case WMI_PDEV_PARAM_CTS_CBW:
1670 wma->pdevconfig.cts_cbw = privcmd->param_value;
1671 break;
1672 case WMI_PDEV_PARAM_TX_CHAIN_MASK:
1673 wma->pdevconfig.txchainmask = privcmd->param_value;
1674 break;
1675 case WMI_PDEV_PARAM_RX_CHAIN_MASK:
1676 wma->pdevconfig.rxchainmask = privcmd->param_value;
1677 break;
1678 case WMI_PDEV_PARAM_BURST_ENABLE:
1679 wma->pdevconfig.burst_enable = privcmd->param_value;
1680 if ((wma->pdevconfig.burst_enable == 1) &&
1681 (wma->pdevconfig.burst_dur == 0))
1682 wma->pdevconfig.burst_dur =
1683 WMA_DEFAULT_SIFS_BURST_DURATION;
1684 else if (wma->pdevconfig.burst_enable == 0)
1685 wma->pdevconfig.burst_dur = 0;
1686 break;
1687 case WMI_PDEV_PARAM_BURST_DUR:
1688 wma->pdevconfig.burst_dur = privcmd->param_value;
1689 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 case WMI_PDEV_PARAM_TXPOWER_LIMIT2G:
1691 wma->pdevconfig.txpow2g = privcmd->param_value;
1692 if ((pMac->roam.configParam.bandCapability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001693 BAND_ALL) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 (pMac->roam.configParam.bandCapability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001695 BAND_2G)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 if (cfg_set_int(pMac,
1697 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1698 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301699 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1701
1702 } else {
1703 WMA_LOGE("Current band is not 2G");
1704 }
1705 break;
1706 case WMI_PDEV_PARAM_TXPOWER_LIMIT5G:
1707 wma->pdevconfig.txpow5g = privcmd->param_value;
1708 if ((pMac->roam.configParam.bandCapability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001709 BAND_ALL) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 (pMac->roam.configParam.bandCapability ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001711 BAND_5G)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 if (cfg_set_int(pMac,
1713 WNI_CFG_CURRENT_TX_POWER_LEVEL,
1714 privcmd->param_value) !=
Anurag Chouhanffb21542016-02-17 14:33:03 +05301715 eSIR_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 WMA_LOGE("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL");
1717
1718 } else {
1719 WMA_LOGE("Current band is not 5G");
1720 }
1721 break;
1722 default:
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001723 WMA_LOGD("Invalid wma_cli_set pdev command/Not yet implemented 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 privcmd->param_id);
1725 break;
1726 }
1727 } else if (5 == privcmd->param_vp_dev) {
Govind Singhd76a5b02016-03-08 15:12:14 +05301728 ret = wma_vdev_set_param(wma->wmi_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07001729 privcmd->param_vdev_id,
1730 WMI_VDEV_PARAM_PACKET_POWERSAVE,
1731 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 if (ret)
1733 WMA_LOGE("Failed to send wmi packet power save cmd");
1734 else
1735 WMA_LOGD("Sent packet power save cmd %d value %x to target",
1736 privcmd->param_id, pps_val);
1737 }
1738}
1739
Dustin Brown05557182017-10-12 14:44:49 -07001740uint32_t wma_critical_events_in_flight(void)
1741{
1742 t_wma_handle *wma;
1743
1744 wma = cds_get_context(QDF_MODULE_ID_WMA);
1745 if (!wma)
1746 return 0;
1747
1748 return qdf_atomic_read(&wma->critical_events_in_flight);
1749}
1750
1751static bool wma_event_is_critical(uint32_t event_id)
1752{
1753 switch (event_id) {
1754 case WMI_ROAM_SYNCH_EVENTID:
1755 return true;
1756 default:
1757 return false;
1758 }
1759}
1760
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761/**
1762 * wma_process_fw_event() - process any fw event
1763 * @wma: wma handle
1764 * @buf: fw event buffer
1765 *
1766 * This function process any fw event to serialize it through mc thread.
1767 *
1768 * Return: none
1769 */
1770static int wma_process_fw_event(tp_wma_handle wma,
1771 wma_process_fw_event_params *buf)
1772{
1773 struct wmi_unified *wmi_handle = (struct wmi_unified *)buf->wmi_handle;
Dustin Brown05557182017-10-12 14:44:49 -07001774 uint32_t event_id = WMI_GET_FIELD(qdf_nbuf_data(buf->evt_buf),
1775 WMI_CMD_HDR, COMMANDID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776
1777 wmi_process_fw_event(wmi_handle, buf->evt_buf);
Dustin Brown05557182017-10-12 14:44:49 -07001778
1779 if (wma_event_is_critical(event_id))
1780 qdf_atomic_dec(&wma->critical_events_in_flight);
1781
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 return 0;
1783}
1784
1785/**
Govind Singhd76a5b02016-03-08 15:12:14 +05301786 * wmi_process_fw_event_tasklet_ctx() - process in tasklet context
1787 * @ctx: handle to wmi
1788 * @ev: wmi event buffer
1789 *
1790 * Event process by below function will be in tasket context,
1791 * need to use this method only for time sensitive functions.
1792 *
1793 * Return: none
1794 */
1795static int wma_process_fw_event_tasklet_ctx(void *ctx, void *ev)
1796{
1797 wmi_process_fw_event(ctx, ev);
1798
1799 return 0;
1800}
1801
1802/**
Manjeet Singhf82ed072016-07-08 11:40:00 +05301803 * wma_process_hal_pwr_dbg_cmd() - send hal pwr dbg cmd to fw.
1804 * @handle: wma handle
1805 * @sir_pwr_dbg_params: unit test command
1806 *
1807 * This function send unit test command to fw.
1808 *
1809 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
1810 */
1811QDF_STATUS wma_process_hal_pwr_dbg_cmd(WMA_HANDLE handle,
1812 struct sir_mac_pwr_dbg_cmd *
1813 sir_pwr_dbg_params)
1814{
1815 tp_wma_handle wma_handle = (tp_wma_handle)handle;
1816 int i;
1817 struct wmi_power_dbg_params wmi_pwr_dbg_params;
1818 QDF_STATUS status;
1819
1820 if (!sir_pwr_dbg_params) {
1821 WMA_LOGE("%s: sir_pwr_dbg_params is null", __func__);
1822 return QDF_STATUS_E_INVAL;
1823 }
1824 wmi_pwr_dbg_params.module_id = sir_pwr_dbg_params->module_id;
1825 wmi_pwr_dbg_params.pdev_id = sir_pwr_dbg_params->pdev_id;
1826 wmi_pwr_dbg_params.num_args = sir_pwr_dbg_params->num_args;
1827
1828 for (i = 0; i < wmi_pwr_dbg_params.num_args; i++)
1829 wmi_pwr_dbg_params.args[i] = sir_pwr_dbg_params->args[i];
1830
1831 status = wmi_unified_send_power_dbg_cmd(wma_handle->wmi_handle,
1832 &wmi_pwr_dbg_params);
1833
1834 return status;
1835}
1836
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001837static void wma_discard_fw_event(struct scheduler_msg *msg)
1838{
Will Huang9323e852018-02-02 17:55:15 +08001839 if (!msg->bodyptr)
1840 return;
1841
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001842 switch (msg->type) {
1843 case WMA_PROCESS_FW_EVENT:
1844 qdf_nbuf_free(((wma_process_fw_event_params *)msg->bodyptr)
1845 ->evt_buf);
1846 break;
Abhishek Singhcaf6a652017-07-06 17:35:42 +05301847 case WMA_SET_LINK_STATE:
1848 qdf_mem_free(((tpLinkStateParams) msg->bodyptr)->callbackArg);
1849 break;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001850 }
Will Huang9323e852018-02-02 17:55:15 +08001851
1852 qdf_mem_free(msg->bodyptr);
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001853 msg->bodyptr = NULL;
1854 msg->bodyval = 0;
1855 msg->type = 0;
1856}
1857
Manjeet Singhf82ed072016-07-08 11:40:00 +05301858/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 * wma_process_fw_event_handler() - common event handler to serialize
1860 * event processing through mc_thread
Govind Singhd76a5b02016-03-08 15:12:14 +05301861 * @ctx: wmi context
1862 * @ev: event buffer
1863 * @rx_ctx: rx execution context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 *
1865 * Return: 0 on success, errno on failure
1866 */
Govind Singhd76a5b02016-03-08 15:12:14 +05301867static int wma_process_fw_event_mc_thread_ctx(void *ctx, void *ev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868{
1869 wma_process_fw_event_params *params_buf;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001870 struct scheduler_msg cds_msg = { 0 };
Dustin Brown05557182017-10-12 14:44:49 -07001871 tp_wma_handle wma;
1872 uint32_t event_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301874 params_buf = qdf_mem_malloc(sizeof(wma_process_fw_event_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875 if (!params_buf) {
1876 WMA_LOGE("%s: Failed alloc memory for params_buf", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301877 qdf_nbuf_free(ev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 return -ENOMEM;
1879 }
1880
Govind Singhd76a5b02016-03-08 15:12:14 +05301881 params_buf->wmi_handle = (struct wmi_unified *)ctx;
1882 params_buf->evt_buf = (wmi_buf_t *)ev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883
Dustin Brown05557182017-10-12 14:44:49 -07001884 wma = cds_get_context(QDF_MODULE_ID_WMA);
1885 event_id = WMI_GET_FIELD(qdf_nbuf_data(params_buf->evt_buf),
1886 WMI_CMD_HDR, COMMANDID);
1887 if (wma && wma_event_is_critical(event_id))
1888 qdf_atomic_inc(&wma->critical_events_in_flight);
1889
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 cds_msg.type = WMA_PROCESS_FW_EVENT;
1891 cds_msg.bodyptr = params_buf;
1892 cds_msg.bodyval = 0;
Houston Hoffmanb6084f12017-05-30 19:24:07 -07001893 cds_msg.flush_callback = wma_discard_fw_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301895 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08001896 scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07001897 WMA_LOGE("%s: Failed to post WMA_PROCESS_FW_EVENT msg",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05301899 qdf_nbuf_free(ev);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301900 qdf_mem_free(params_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 return -EFAULT;
1902 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 return 0;
1904
1905}
1906
Govind Singhd76a5b02016-03-08 15:12:14 +05301907/**
1908 * wma_process_fw_event_handler() - common event handler to serialize
1909 * event processing through mc_thread
1910 * @ctx: wmi context
1911 * @ev: event buffer
1912 * @rx_ctx: rx execution context
1913 *
1914 * Return: 0 on success, errno on failure
1915 */
1916int wma_process_fw_event_handler(void *ctx, void *ev, uint8_t rx_ctx)
1917{
1918 int err = 0;
1919
1920 if (rx_ctx == WMA_RX_SERIALIZER_CTX) {
1921 err = wma_process_fw_event_mc_thread_ctx(ctx, ev);
1922 } else if (rx_ctx == WMA_RX_TASKLET_CTX) {
1923 wma_process_fw_event_tasklet_ctx(ctx, ev);
1924 } else {
1925 WMA_LOGE("%s: invalid wmi event execution context", __func__);
1926 qdf_nbuf_free(ev);
1927 }
1928
1929 return err;
1930}
1931
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932#ifdef WLAN_FEATURE_NAN
1933/**
1934 * wma_set_nan_enable() - set nan enable flag in WMA handle
1935 * @wma_handle: Pointer to wma handle
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301936 * @cds_cfg: Pointer to CDS Configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 *
1938 * Return: none
1939 */
1940static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301941 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942{
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301943 wma_handle->is_nan_enabled = cds_cfg->is_nan_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944}
1945#else
1946static void wma_set_nan_enable(tp_wma_handle wma_handle,
Arun Khandavallic811dcc2016-06-26 07:37:21 +05301947 struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948{
1949}
1950#endif
1951
1952/**
Komal Seelam02d09342016-02-23 18:03:19 +05301953 * wma_init_max_no_of_peers - API to initialize wma configuration params
1954 * @wma_handle: WMA Handle
1955 * @max_peers: Max Peers supported
1956 *
1957 * Return: void
1958 */
1959static void wma_init_max_no_of_peers(tp_wma_handle wma_handle,
1960 uint16_t max_peers)
1961{
1962 struct wma_ini_config *cfg = wma_get_ini_handle(wma_handle);
1963
Naveen Rawat35804772016-06-27 15:40:28 -07001964 if (cfg == NULL) {
1965 WMA_LOGE("%s: NULL WMA ini handle", __func__);
1966 return;
1967 }
1968
Komal Seelam02d09342016-02-23 18:03:19 +05301969 cfg->max_no_of_peers = max_peers;
1970}
1971
Prashanth Bhattae675ca72016-10-20 18:42:37 -07001972/**
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001973 * wma_cleanup_vdev_resp_queue() - cleanup vdev response queue
1974 * @wma: wma handle
1975 *
1976 * Return: none
1977 */
1978static void wma_cleanup_vdev_resp_queue(tp_wma_handle wma)
1979{
1980 struct wma_target_req *req_msg = NULL;
1981 qdf_list_node_t *node1 = NULL;
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001982
1983 qdf_spin_lock_bh(&wma->vdev_respq_lock);
1984 if (!qdf_list_size(&wma->vdev_resp_queue)) {
1985 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08001986 WMA_LOGD(FL("request queue maybe empty"));
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001987 return;
1988 }
1989
Sandeep Puligilla5ac6bd22017-10-17 12:33:56 -07001990 WMA_LOGD(FL("Cleaning up vdev resp queue"));
1991
Wu Gao30f65eb2017-08-09 19:56:10 +08001992 /* peek front, and then cleanup it in wma_vdev_resp_timer */
1993 while (qdf_list_peek_front(&wma->vdev_resp_queue, &node1) ==
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001994 QDF_STATUS_SUCCESS) {
1995 req_msg = qdf_container_of(node1, struct wma_target_req, node);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001996 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
Abhishek Singhc614ec42017-04-25 16:17:34 +05301997 qdf_mc_timer_stop(&req_msg->event_timeout);
1998 wma_vdev_resp_timer(req_msg);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08001999 qdf_spin_lock_bh(&wma->vdev_respq_lock);
2000 }
2001 qdf_spin_unlock_bh(&wma->vdev_respq_lock);
2002}
2003
2004/**
Abhishek Singhc614ec42017-04-25 16:17:34 +05302005 * wma_cleanup_hold_req() - cleanup hold request queue
2006 * @wma: wma handle
2007 *
2008 * Return: none
2009 */
2010static void wma_cleanup_hold_req(tp_wma_handle wma)
2011{
2012 struct wma_target_req *req_msg = NULL;
2013 qdf_list_node_t *node1 = NULL;
2014
2015 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
2016 if (!qdf_list_size(&wma->wma_hold_req_queue)) {
2017 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
2018 WMA_LOGD(FL("request queue is empty"));
2019 return;
2020 }
2021
Wu Gao30f65eb2017-08-09 19:56:10 +08002022 /* peek front, and then cleanup it in wma_hold_req_timer */
Abhishek Singhc614ec42017-04-25 16:17:34 +05302023 while (QDF_STATUS_SUCCESS ==
Wu Gao30f65eb2017-08-09 19:56:10 +08002024 qdf_list_peek_front(&wma->wma_hold_req_queue, &node1)) {
Abhishek Singhc614ec42017-04-25 16:17:34 +05302025 req_msg = qdf_container_of(node1, struct wma_target_req, node);
2026 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
2027 /* Cleanup timeout handler */
2028 qdf_mc_timer_stop(&req_msg->event_timeout);
Abhishek Singhc614ec42017-04-25 16:17:34 +05302029 wma_hold_req_timer(req_msg);
2030 qdf_spin_lock_bh(&wma->wma_hold_req_q_lock);
2031 }
2032 qdf_spin_unlock_bh(&wma->wma_hold_req_q_lock);
2033}
2034
2035/**
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002036 * wma_shutdown_notifier_cb - Shutdown notifer call back
2037 * @priv : WMA handle
2038 *
2039 * During recovery, WMA may wait for resume to complete if the crash happens
2040 * while in suspend. This may cause delays in completing the recovery. This call
2041 * back would be called during recovery and the event is completed so that if
2042 * the resume is waiting on FW to respond then it can get out of the wait so
2043 * that recovery thread can start bringing down all the modules.
2044 *
2045 * Return: None
2046 */
2047static void wma_shutdown_notifier_cb(void *priv)
2048{
2049 tp_wma_handle wma_handle = priv;
2050
2051 qdf_event_set(&wma_handle->wma_resume_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08002052 wma_cleanup_vdev_resp_queue(wma_handle);
Abhishek Singhc614ec42017-04-25 16:17:34 +05302053 wma_cleanup_hold_req(wma_handle);
Mukul Sharma4c60a7e2017-03-06 19:42:18 +05302054 pmo_ucfg_psoc_wakeup_host_event_received(wma_handle->psoc);
Prashanth Bhattae675ca72016-10-20 18:42:37 -07002055}
2056
Mukul Sharma5ff3c582016-09-12 15:23:35 +05302057struct wma_version_info g_wmi_version_info;
2058
Wen Gong3f003382018-05-14 14:26:37 +08002059#ifdef WLAN_FEATURE_MEMDUMP_ENABLE
Komal Seelam02d09342016-02-23 18:03:19 +05302060/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302061 * wma_state_info_dump() - prints state information of wma layer
2062 * @buf: buffer pointer
2063 * @size: size of buffer to be filled
2064 *
2065 * This function is used to dump state information of wma layer
2066 *
2067 * Return: None
2068 */
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002069#ifdef QCA_SUPPORT_CP_STATS
2070static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
2071{
2072 uint8_t vdev_id;
2073 uint16_t len = 0;
2074 t_wma_handle *wma;
2075 char *buf = *buf_ptr;
2076 struct wma_txrx_node *iface;
2077 struct wake_lock_stats stats;
2078 struct wlan_objmgr_vdev *vdev;
2079
2080 wma = cds_get_context(QDF_MODULE_ID_WMA);
2081 if (!wma) {
2082 WMA_LOGE("%s: WMA context is invald!", __func__);
2083 return;
2084 }
2085
2086 WMA_LOGE("%s: size of buffer: %d", __func__, *size);
2087
2088 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
2089 iface = &wma->interfaces[vdev_id];
2090 if (!iface->handle)
2091 continue;
2092
2093 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(wma->psoc,
2094 vdev_id, WLAN_LEGACY_WMA_ID);
Yeshwanth Sriram Guntuka0e6f4462018-05-07 17:33:43 +05302095 if (vdev == NULL)
2096 continue;
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002097 ucfg_mc_cp_stats_get_vdev_wake_lock_stats(vdev, &stats);
2098 len += qdf_scnprintf(buf + len, *size - len,
2099 "\n"
2100 "vdev_id %d\n"
2101 "WoW Stats\n"
2102 "\tpno_match %u\n"
2103 "\tpno_complete %u\n"
2104 "\tgscan %u\n"
2105 "\tlow_rssi %u\n"
2106 "\trssi_breach %u\n"
2107 "\tucast %u\n"
2108 "\tbcast %u\n"
2109 "\ticmpv4 %u\n"
2110 "\ticmpv6 %u\n"
2111 "\tipv4_mcast %u\n"
2112 "\tipv6_mcast %u\n"
2113 "\tipv6_mcast_ra %u\n"
2114 "\tipv6_mcast_ns %u\n"
2115 "\tipv6_mcast_na %u\n"
2116 "\toem_response %u\n"
2117 "conn_state %d\n"
2118 "dtimPeriod %d\n"
2119 "chanmode %d\n"
2120 "vht_capable %d\n"
2121 "ht_capable %d\n"
2122 "chan_width %d\n"
2123 "vdev_active %d\n"
2124 "vdev_up %d\n"
2125 "aid %d\n"
2126 "rate_flags %d\n"
2127 "nss %d\n"
2128 "tx_power %d\n"
2129 "max_tx_power %d\n"
2130 "nwType %d\n"
2131 "tx_streams %d\n"
2132 "rx_streams %d\n"
2133 "chain_mask %d\n"
2134 "nss_2g %d\n"
2135 "nss_5g %d",
2136 vdev_id,
2137 stats.pno_match_wake_up_count,
2138 stats.pno_complete_wake_up_count,
2139 stats.gscan_wake_up_count,
2140 stats.low_rssi_wake_up_count,
2141 stats.rssi_breach_wake_up_count,
2142 stats.ucast_wake_up_count,
2143 stats.bcast_wake_up_count,
2144 stats.icmpv4_count,
2145 stats.icmpv6_count,
2146 stats.ipv4_mcast_wake_up_count,
2147 stats.ipv6_mcast_wake_up_count,
2148 stats.ipv6_mcast_ra_stats,
2149 stats.ipv6_mcast_ns_stats,
2150 stats.ipv6_mcast_na_stats,
2151 stats.oem_response_wake_up_count,
2152 iface->conn_state,
2153 iface->dtimPeriod,
2154 iface->chanmode,
2155 iface->vht_capable,
2156 iface->ht_capable,
2157 iface->chan_width,
2158 iface->vdev_active,
2159 wma_is_vdev_up(vdev_id),
2160 iface->aid,
2161 iface->rate_flags,
2162 iface->nss,
2163 iface->tx_power,
2164 iface->max_tx_power,
2165 iface->nwType,
2166 iface->tx_streams,
2167 iface->rx_streams,
2168 iface->chain_mask,
2169 iface->nss_2g,
2170 iface->nss_5g);
Yeshwanth Sriram Guntuka0e6f4462018-05-07 17:33:43 +05302171 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_WMA_ID);
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002172 }
2173
2174 *size -= len;
2175 *buf_ptr += len;
2176}
2177#else /* QCA_SUPPORT_CP_STATS */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302178static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
2179{
Dustin Brown9d797d62017-01-11 16:39:12 -08002180 t_wma_handle *wma;
2181 struct sir_vdev_wow_stats *stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302182 uint16_t len = 0;
2183 char *buf = *buf_ptr;
2184 struct wma_txrx_node *iface;
2185 uint8_t vdev_id;
2186
Dustin Brown9d797d62017-01-11 16:39:12 -08002187 wma = cds_get_context(QDF_MODULE_ID_WMA);
2188 if (!wma) {
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302189 WMA_LOGE("%s: WMA context is invald!", __func__);
2190 return;
2191 }
2192
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002193 WMA_LOGE("%s: size of buffer: %d", __func__, *size);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302194
Dustin Brown9d797d62017-01-11 16:39:12 -08002195 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
2196 iface = &wma->interfaces[vdev_id];
2197 if (!iface->handle)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302198 continue;
2199
Dustin Brown9d797d62017-01-11 16:39:12 -08002200 stats = &iface->wow_stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302201 len += qdf_scnprintf(buf + len, *size - len,
Dustin Brown9d797d62017-01-11 16:39:12 -08002202 "\n"
2203 "vdev_id %d\n"
2204 "WoW Stats\n"
2205 "\tpno_match %u\n"
2206 "\tpno_complete %u\n"
2207 "\tgscan %u\n"
2208 "\tlow_rssi %u\n"
2209 "\trssi_breach %u\n"
2210 "\tucast %u\n"
2211 "\tbcast %u\n"
2212 "\ticmpv4 %u\n"
2213 "\ticmpv6 %u\n"
2214 "\tipv4_mcast %u\n"
2215 "\tipv6_mcast %u\n"
2216 "\tipv6_mcast_ra %u\n"
2217 "\tipv6_mcast_ns %u\n"
2218 "\tipv6_mcast_na %u\n"
2219 "\toem_response %u\n"
2220 "conn_state %d\n"
2221 "dtimPeriod %d\n"
2222 "chanmode %d\n"
2223 "vht_capable %d\n"
2224 "ht_capable %d\n"
2225 "chan_width %d\n"
2226 "vdev_active %d\n"
2227 "vdev_up %d\n"
2228 "aid %d\n"
2229 "rate_flags %d\n"
2230 "nss %d\n"
2231 "tx_power %d\n"
2232 "max_tx_power %d\n"
2233 "nwType %d\n"
2234 "tx_streams %d\n"
2235 "rx_streams %d\n"
2236 "chain_mask %d\n"
2237 "nss_2g %d\n"
2238 "nss_5g %d",
2239 vdev_id,
2240 stats->pno_match,
2241 stats->pno_complete,
2242 stats->gscan,
2243 stats->low_rssi,
2244 stats->rssi_breach,
2245 stats->ucast,
2246 stats->bcast,
2247 stats->icmpv4,
2248 stats->icmpv6,
2249 stats->ipv4_mcast,
2250 stats->ipv6_mcast,
2251 stats->ipv6_mcast_ra,
2252 stats->ipv6_mcast_ns,
2253 stats->ipv6_mcast_na,
2254 stats->oem_response,
2255 iface->conn_state,
2256 iface->dtimPeriod,
2257 iface->chanmode,
2258 iface->vht_capable,
2259 iface->ht_capable,
2260 iface->chan_width,
2261 iface->vdev_active,
Mukul Sharmaf9047232017-03-02 16:58:56 +05302262 wma_is_vdev_up(vdev_id),
Dustin Brown9d797d62017-01-11 16:39:12 -08002263 iface->aid,
2264 iface->rate_flags,
2265 iface->nss,
2266 iface->tx_power,
2267 iface->max_tx_power,
2268 iface->nwType,
2269 iface->tx_streams,
2270 iface->rx_streams,
2271 iface->chain_mask,
2272 iface->nss_2g,
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302273 iface->nss_5g);
2274 }
2275
2276 *size -= len;
2277 *buf_ptr += len;
2278}
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002279#endif /* QCA_SUPPORT_CP_STATS */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302280
2281/**
2282 * wma_register_debug_callback() - registration function for wma layer
2283 * to print wma state information
2284 */
2285static void wma_register_debug_callback(void)
2286{
2287 qdf_register_debug_callback(QDF_MODULE_ID_WMA, &wma_state_info_dump);
2288}
Wen Gong3f003382018-05-14 14:26:37 +08002289#else /* WLAN_FEATURE_MEMDUMP_ENABLE */
Wen Gongaa6d55d2018-04-26 16:33:21 +08002290static void wma_register_debug_callback(void)
2291{
2292}
Wen Gong3f003382018-05-14 14:26:37 +08002293#endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
Frank Liu65b17d92016-11-23 15:58:44 +08002294/**
2295 * wma_register_tx_ops_handler() - register tx_ops of southbound
2296 * @tx_ops: tx_ops pointer in southbound
2297 *
2298 * Return: 0 on success, errno on failure
2299 */
2300static QDF_STATUS
2301wma_register_tx_ops_handler(struct wlan_lmac_if_tx_ops *tx_ops)
2302{
2303 /*
2304 * Assign tx_ops, it's up to UMAC modules to declare and define these
2305 * functions which are used to send wmi command to target.
2306 */
2307
Himanshu Agarwalce716f82016-12-21 19:07:54 +05302308 if (!tx_ops) {
2309 WMA_LOGE("%s: pointer to lmac if tx ops is NULL", __func__);
2310 return QDF_STATUS_E_INVAL;
2311 }
2312
2313 /* mgmt_txrx component's tx ops */
2314 tx_ops->mgmt_txrx_tx_ops.mgmt_tx_send = wma_mgmt_unified_cmd_send;
2315
Frank Liu65b17d92016-11-23 15:58:44 +08002316 return QDF_STATUS_SUCCESS;
2317}
2318
2319/**
2320 * wma_target_if_open() - Attach UMAC modules' interface with wmi layer
2321 * @wma_handle: wma handle
2322 *
2323 * Separate module defines below functions:
2324 * 1. tgt_wmi_<module>_<action> api sends wmi command, assigned to south bound
2325 * tx_ops function pointers;
2326 * 2. module's south dispatcher handles information from lower layer, assigned
2327 * to south bound rx_ops function pointers;
2328 * 3. wmi event handler deals with wmi event, extracts umac needed information,
2329 * and call rx_ops(module's dispatcher). It executes in tasklet context and
2330 * is up to dispatcher to decide the context to reside in tasklet or in
2331 * thread context.
2332 *
2333 * Return: None
2334 */
2335static void wma_target_if_open(tp_wma_handle wma_handle)
2336{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302337 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002338
2339 if (!psoc)
2340 return;
2341
Mukul Sharmadad267e2017-02-04 13:25:34 +05302342 wlan_global_lmac_if_set_txops_registration_cb(WLAN_DEV_OL,
2343 target_if_register_tx_ops);
2344 wlan_lmac_if_set_umac_txops_registration_cb(
2345 wma_register_tx_ops_handler);
2346 wlan_global_lmac_if_open(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002347
Frank Liu65b17d92016-11-23 15:58:44 +08002348}
2349
2350/**
2351 * wma_target_if_close() - Detach UMAC modules' interface with wmi layer
2352 * @wma_handle: wma handle
2353 *
2354 * Return: None
2355 */
2356static void wma_target_if_close(tp_wma_handle wma_handle)
2357{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302358 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002359
2360 if (!psoc)
2361 return;
2362
Mukul Sharmadad267e2017-02-04 13:25:34 +05302363 wlan_global_lmac_if_close(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002364}
Frank Liu65b17d92016-11-23 15:58:44 +08002365
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302366/**
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302367 * wma_get_psoc_from_scn_handle() - API to get psoc from scn handle
2368 * @scn_handle: opaque wma handle
2369 *
2370 * API to get psoc from scn handle
2371 *
2372 * Return: None
2373 */
2374static struct wlan_objmgr_psoc *wma_get_psoc_from_scn_handle(void *scn_handle)
2375{
2376 tp_wma_handle wma_handle;
2377
2378 if (!scn_handle) {
2379 WMA_LOGE("invalid scn handle");
2380 return NULL;
2381 }
2382 wma_handle = (tp_wma_handle)scn_handle;
2383
2384 return wma_handle->psoc;
2385}
Himanshu Agarwal2228e072018-01-24 17:42:17 +05302386
2387/**
2388 * wma_get_pdev_from_scn_handle() - API to get pdev from scn handle
2389 * @scn_handle: opaque wma handle
2390 *
2391 * API to get pdev from scn handle
2392 *
2393 * Return: None
2394 */
2395static struct wlan_objmgr_pdev *wma_get_pdev_from_scn_handle(void *scn_handle)
2396{
2397 tp_wma_handle wma_handle;
2398
2399 if (!scn_handle) {
2400 WMA_LOGE("invalid scn handle");
2401 return NULL;
2402 }
2403 wma_handle = (tp_wma_handle)scn_handle;
2404
2405 return wma_handle->pdev;
2406}
2407
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002408/**
2409 * wma_legacy_service_ready_event_handler() - legacy (ext)service ready handler
2410 * @event_id: event_id
2411 * @handle: wma handle
2412 * @event_data: event data
2413 * @length: event length
2414 *
2415 * Return: 0 for success, negative error code for failure
2416 */
2417static int wma_legacy_service_ready_event_handler(uint32_t event_id,
2418 void *handle,
2419 uint8_t *event_data,
2420 uint32_t length)
2421{
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302422 switch (event_id) {
2423 case wmi_service_ready_event_id:
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002424 return wma_rx_service_ready_event(handle, event_data, length);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302425 case wmi_service_ready_ext_event_id:
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002426 return wma_rx_service_ready_ext_event(handle, event_data,
2427 length);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302428 case wmi_ready_event_id:
2429 return wma_rx_ready_event(handle, event_data, length);
2430 default:
2431 WMA_LOGE("Legacy callback invoked with invalid event_id:%d",
2432 event_id);
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002433 QDF_BUG(0);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302434 }
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002435
2436 return 0;
2437}
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302438
2439/**
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002440 * wma_flush_complete_evt_handler() - FW log flush complete event handler
2441 * @handle: WMI handle
2442 * @event: Event recevied from FW
2443 * @len: Length of the event
2444 *
2445 */
2446static int wma_flush_complete_evt_handler(void *handle,
2447 u_int8_t *event,
2448 u_int32_t len)
2449{
2450 QDF_STATUS status;
2451 tp_wma_handle wma = (tp_wma_handle) handle;
2452
2453 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *param_buf;
2454 wmi_debug_mesg_flush_complete_fixed_param *wmi_event;
Poddar, Siddarthc2c08142017-09-13 17:49:56 +05302455 wmi_debug_mesg_fw_data_stall_param *data_stall_event;
2456 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2457 uint8_t *buf_ptr;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002458 uint32_t reason_code;
2459
2460 param_buf = (WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *) event;
2461 if (!param_buf) {
2462 WMA_LOGE("Invalid log flush complete event buffer");
2463 return QDF_STATUS_E_FAILURE;
2464 }
2465
2466 wmi_event = param_buf->fixed_param;
2467 reason_code = wmi_event->reserved0;
Rajeev Kumardcce8092018-05-02 15:48:17 -07002468 WMA_LOGD("Received reason code %d from FW", reason_code);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002469
Poddar, Siddarthc2c08142017-09-13 17:49:56 +05302470 buf_ptr = (uint8_t *)wmi_event;
2471 buf_ptr = buf_ptr + sizeof(wmi_debug_mesg_flush_complete_fixed_param) +
2472 WMI_TLV_HDR_SIZE;
2473 data_stall_event = (wmi_debug_mesg_fw_data_stall_param *) buf_ptr;
2474
2475 if (((data_stall_event->tlv_header & 0xFFFF0000) >> 16 ==
2476 WMITLV_TAG_STRUC_wmi_debug_mesg_fw_data_stall_param)) {
2477 /**
2478 * Log data stall info received from FW:
2479 *
2480 * Possible data stall recovery types:
2481 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_DISCONNECT
2482 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_MAC_PHY_RESET
2483 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_PDR
2484 *
2485 * Possible data stall event types:
2486 * WLAN_DBG_DATA_STALL_VDEV_PAUSE
2487 * WLAN_DBG_DATA_STALL_HWSCHED_CMD_FILTER
2488 * WLAN_DBG_DATA_STALL_HWSCHED_CMD_FLUSH
2489 * WLAN_DBG_DATA_STALL_RX_REFILL_FAILED
2490 * WLAN_DBG_DATA_STALL_RX_FCS_LEN_ERROR
2491 *
2492 * reason_code1:
2493 * The information stored in reason_code1 varies based on the
2494 * data stall type values:
2495 *
2496 * data_stall_type | reason_code1
2497 * -----------------------------------------------------
2498 * HWSCHED_CMD_FLUSH | flush req reason (0-40)
2499 * RX_REFILL_FAILED | ring_id (0-7)
2500 * RX_FCS_LEN_ERROR | exact error type
2501 *
2502 * reasone_code2:
2503 * on which tid/hwq stall happened
2504 *
2505 */
2506 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
2507 "Data Stall event:");
2508 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
2509 "data_stall_type: %x vdev_id_bitmap: %x reason_code1: %x reason_code2: %x recovery_type: %x ",
2510 data_stall_event->data_stall_type,
2511 data_stall_event->vdev_id_bitmap,
2512 data_stall_event->reason_code1,
2513 data_stall_event->reason_code2,
2514 data_stall_event->recovery_type);
2515
2516 cdp_post_data_stall_event(soc,
2517 DATA_STALL_LOG_INDICATOR_FIRMWARE,
2518 data_stall_event->data_stall_type,
2519 0XFF,
2520 data_stall_event->vdev_id_bitmap,
2521 data_stall_event->recovery_type);
2522 }
2523
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002524 /*
2525 * reason_code = 0; Flush event in response to flush command
2526 * reason_code = other value; Asynchronous flush event for fatal events
2527 */
2528 if (!reason_code && (cds_is_log_report_in_progress() == false)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002529 WMA_LOGD("Received WMI flush event without sending CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002530 return -EINVAL;
2531 } else if (!reason_code && cds_is_log_report_in_progress() == true) {
2532 /* Flush event in response to flush command */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002533 WMA_LOGD("Received WMI flush event in response to flush CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002534 status = qdf_mc_timer_stop(&wma->log_completion_timer);
2535 if (status != QDF_STATUS_SUCCESS)
2536 WMA_LOGE("Failed to stop the log completion timeout");
2537 cds_logging_set_fw_flush_complete();
Zhu Jianminb639e9b2017-10-26 19:09:12 +08002538 return QDF_STATUS_SUCCESS;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002539 } else if (reason_code && cds_is_log_report_in_progress() == false) {
2540 /* Asynchronous flush event for fatal events */
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002541 status = cds_set_log_completion(WLAN_LOG_TYPE_FATAL,
2542 WLAN_LOG_INDICATOR_FIRMWARE,
2543 reason_code, false);
2544 if (QDF_STATUS_SUCCESS != status) {
2545 WMA_LOGE("%s: Failed to set log trigger params",
2546 __func__);
2547 return QDF_STATUS_E_FAILURE;
2548 }
2549 cds_logging_set_fw_flush_complete();
2550 return status;
2551 } else {
2552 /* Asynchronous flush event for fatal event,
2553 * but, report in progress already
2554 */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002555 WMA_LOGD("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002556 __func__, WLAN_LOG_TYPE_FATAL,
2557 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2558 return QDF_STATUS_E_FAILURE;
2559 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07002560 /* Asynchronous flush event for fatal event,
2561 * but, report in progress already
2562 */
2563 WMA_LOGW("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
2564 __func__, WLAN_LOG_TYPE_FATAL,
2565 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2566 return QDF_STATUS_E_FAILURE;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002567}
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002568/**
2569 * wma_extract_single_phyerr_spectral() - extract single phy error from event
2570 * @handle: wma handle
2571 * @param evt_buf: pointer to event buffer
2572 * @param datalen: data length of event buffer
2573 * @param buf_offset: Pointer to hold value of current event buffer offset
2574 * post extraction
2575 * @param phyerr: Pointer to hold phyerr
2576 *
2577 * Return: QDF_STATUS
2578 */
2579static QDF_STATUS wma_extract_single_phyerr_spectral(void *handle,
2580 void *evt_buf,
2581 uint16_t datalen, uint16_t *buf_offset,
2582 wmi_host_phyerr_t *phyerr)
2583{
2584 wmi_single_phyerr_rx_event *ev;
2585 int n = *buf_offset;
2586
2587 ev = (wmi_single_phyerr_rx_event *)((uint8_t *)evt_buf + n);
2588
2589 if (n < datalen) {
2590 /* ensure there's at least space for the header */
2591 if ((datalen - n) < sizeof(ev->hdr)) {
2592 WMA_LOGE("%s: not enough space? (datalen=%d, n=%d, hdr=%zu bytes",
2593 __func__, datalen, n, sizeof(ev->hdr));
2594 return QDF_STATUS_E_FAILURE;
2595 }
2596
2597 phyerr->bufp = ev->bufp;
2598 phyerr->buf_len = ev->hdr.buf_len;
2599
2600 /*
2601 * Sanity check the buffer length of the event against
2602 * what we currently have.
2603 *
2604 * Since buf_len is 32 bits, we check if it overflows
2605 * a large 32 bit value. It's not 0x7fffffff because
2606 * we increase n by (buf_len + sizeof(hdr)), which would
2607 * in itself cause n to overflow.
2608 *
2609 * If "int" is 64 bits then this becomes a moot point.
2610 */
2611 if (ev->hdr.buf_len > 0x7f000000) {
2612 WMA_LOGE("%s: buf_len is garbage? (0x%x)",
2613 __func__, ev->hdr.buf_len);
2614 return QDF_STATUS_E_FAILURE;
2615 }
2616 if (n + ev->hdr.buf_len > datalen) {
2617 WMA_LOGE("%s: buf_len exceeds available space n=%d, buf_len=%d, datalen=%d",
2618 __func__, n, ev->hdr.buf_len, datalen);
2619 return QDF_STATUS_E_FAILURE;
2620 }
2621
2622 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
2623 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
2624
2625#ifdef DEBUG_SPECTRAL_SCAN
2626 WMA_LOGD("%s: len=%d, tsf=0x%08x, rssi = 0x%x/0x%x/0x%x/0x%x, comb rssi = 0x%x, phycode=%d",
2627 __func__,
2628 ev->hdr.buf_len,
2629 ev->hdr.tsf_timestamp,
2630 ev->hdr.rssi_chain0,
2631 ev->hdr.rssi_chain1,
2632 ev->hdr.rssi_chain2,
2633 ev->hdr.rssi_chain3,
2634 WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr),
2635 phyerr->phy_err_code);
2636
2637 /*
2638 * For now, unroll this loop - the chain 'value' field isn't
2639 * a variable but glued together into a macro field definition.
2640 * Grr. :-)
2641 */
2642 WMA_LOGD("%s: chain 0: raw=0x%08x; pri20=%d sec20=%d sec40=%d sec80=%d",
2643 __func__,
2644 ev->hdr.rssi_chain0,
2645 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, PRI20),
2646 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC20),
2647 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC40),
2648 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC80));
2649
2650 WMA_LOGD("%s: chain 1: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2651 __func__,
2652 ev->hdr.rssi_chain1,
2653 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, PRI20),
2654 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC20),
2655 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC40),
2656 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC80));
2657
2658 WMA_LOGD("%s: chain 2: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2659 __func__,
2660 ev->hdr.rssi_chain2,
2661 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, PRI20),
2662 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC20),
2663 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC40),
2664 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC80));
2665
2666 WMA_LOGD("%s: chain 3: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2667 __func__,
2668 ev->hdr.rssi_chain3,
2669 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, PRI20),
2670 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC20),
2671 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC40),
2672 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC80));
2673
2674
2675 WMA_LOGD("%s: freq_info_1=0x%08x, freq_info_2=0x%08x",
2676 __func__, ev->hdr.freq_info_1, ev->hdr.freq_info_2);
2677
2678 /*
2679 * The NF chain values are signed and are negative - hence
2680 * the cast evilness.
2681 */
2682 WMA_LOGD("%s: nfval[1]=0x%08x, nfval[2]=0x%08x, nf=%d/%d/%d/%d, freq1=%d, freq2=%d, cw=%d",
2683 __func__,
2684 ev->hdr.nf_list_1,
2685 ev->hdr.nf_list_2,
2686 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 0),
2687 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 1),
2688 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 2),
2689 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 3),
2690 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 1),
2691 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 2),
2692 WMI_UNIFIED_CHWIDTH_GET(&ev->hdr));
2693#endif
2694
2695 /*
2696 * If required, pass spectral events to the spectral module
2697 */
2698 if (ev->hdr.buf_len > 0) {
2699
2700 /* Initialize the NF values to Zero. */
2701 phyerr->rf_info.noise_floor[0] =
2702 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 0);
2703 phyerr->rf_info.noise_floor[1] =
2704 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 1);
2705 phyerr->rf_info.noise_floor[2] =
2706 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 2);
2707 phyerr->rf_info.noise_floor[3] =
2708 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 3);
2709
2710 /* populate the rf info */
2711 phyerr->rf_info.rssi_comb =
2712 WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
2713
2714 /* Need to unroll loop due to macro
2715 * constraints chain 0
2716 */
2717 phyerr->rf_info.pc_rssi_info[0].rssi_pri20 =
2718 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, PRI20);
2719 phyerr->rf_info.pc_rssi_info[0].rssi_sec20 =
2720 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC20);
2721 phyerr->rf_info.pc_rssi_info[0].rssi_sec40 =
2722 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC40);
2723 phyerr->rf_info.pc_rssi_info[0].rssi_sec80 =
2724 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC80);
2725
2726 /* chain 1 */
2727 phyerr->rf_info.pc_rssi_info[1].rssi_pri20 =
2728 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, PRI20);
2729 phyerr->rf_info.pc_rssi_info[1].rssi_sec20 =
2730 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC20);
2731 phyerr->rf_info.pc_rssi_info[1].rssi_sec40 =
2732 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC40);
2733 phyerr->rf_info.pc_rssi_info[1].rssi_sec80 =
2734 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC80);
2735
2736 /* chain 2 */
2737 phyerr->rf_info.pc_rssi_info[2].rssi_pri20 =
2738 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, PRI20);
2739 phyerr->rf_info.pc_rssi_info[2].rssi_sec20 =
2740 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC20);
2741 phyerr->rf_info.pc_rssi_info[2].rssi_sec40 =
2742 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC40);
2743 phyerr->rf_info.pc_rssi_info[2].rssi_sec80 =
2744 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC80);
2745
2746 /* chain 3 */
2747 phyerr->rf_info.pc_rssi_info[3].rssi_pri20 =
2748 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, PRI20);
2749 phyerr->rf_info.pc_rssi_info[3].rssi_sec20 =
2750 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC20);
2751 phyerr->rf_info.pc_rssi_info[3].rssi_sec40 =
2752 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC40);
2753 phyerr->rf_info.pc_rssi_info[3].rssi_sec80 =
2754 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC80);
2755
2756 phyerr->chan_info.center_freq1 =
2757 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 1);
2758 phyerr->chan_info.center_freq2 =
2759 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 2);
2760
2761 }
2762
2763 /*
2764 * Advance the buffer pointer to the next PHY error.
2765 * buflen is the length of this payload, so we need to
2766 * advance past the current header _AND_ the payload.
2767 */
2768 n += sizeof(*ev) + ev->hdr.buf_len;
2769 }
2770 *buf_offset += n;
2771
2772 return QDF_STATUS_SUCCESS;
2773}
2774
2775/**
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002776 * spectral_phyerr_event_handler() - spectral phyerr event handler
2777 * @handle: wma handle
2778 * @data: data buffer
2779 * @datalen: buffer length
2780 *
2781 * Return: QDF_STATUS
2782 */
2783static QDF_STATUS spectral_phyerr_event_handler(void *handle,
2784 uint8_t *data, uint32_t datalen)
2785{
2786 tp_wma_handle wma = (tp_wma_handle) handle;
2787 QDF_STATUS status = QDF_STATUS_SUCCESS;
2788 uint16_t buf_offset, event_buf_len = 0;
2789 wmi_single_phyerr_rx_event *ev;
2790 wmi_host_phyerr_t phyerr;
2791 struct target_if_spectral_rfqual_info rfqual_info;
2792 struct target_if_spectral_chan_info chan_info;
2793 struct target_if_spectral_acs_stats acs_stats;
2794
2795 if (NULL == wma) {
2796 WMA_LOGE("%s:wma handle is NULL", __func__);
2797 return QDF_STATUS_E_FAILURE;
2798 }
2799
2800 memset(&phyerr, 0, sizeof(wmi_host_phyerr_t));
Arif Hussaind54b62c2018-03-01 13:31:37 -08002801 status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
2802 &buf_offset, &phyerr);
2803 if (QDF_IS_STATUS_ERROR(status)) {
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002804 WMA_LOGE("%s: extract comb phyerr failed", __func__);
2805 return QDF_STATUS_E_FAILURE;
2806 }
2807
2808 ev = (wmi_single_phyerr_rx_event *)phyerr.bufp;
2809 event_buf_len = phyerr.buf_len;
2810 /* Loop over the bufp, extracting out phyerrors */
2811 buf_offset = 0;
2812 while (buf_offset < event_buf_len) {
2813 if (wma_extract_single_phyerr_spectral(handle, ev,
2814 event_buf_len, &buf_offset, &phyerr)) {
2815 WMA_LOGE("%s: extract single phy err failed", __func__);
2816 return QDF_STATUS_E_FAILURE;
2817 }
2818
2819 if (phyerr.buf_len > 0) {
2820 if (sizeof(phyerr.rf_info) > sizeof(rfqual_info))
2821 qdf_mem_copy(&rfqual_info, &phyerr.rf_info,
2822 sizeof(rfqual_info));
2823 else
2824 qdf_mem_copy(&rfqual_info, &phyerr.rf_info,
2825 sizeof(phyerr.rf_info));
2826
2827 if (sizeof(phyerr.chan_info) > sizeof(chan_info))
2828 qdf_mem_copy(&chan_info, &phyerr.chan_info,
2829 sizeof(chan_info));
2830 else
2831 qdf_mem_copy(&chan_info, &phyerr.chan_info,
2832 sizeof(phyerr.chan_info));
2833
2834 target_if_spectral_process_phyerr(wma->pdev, phyerr.bufp,
2835 phyerr.buf_len,
2836 &rfqual_info,
2837 &chan_info,
2838 phyerr.tsf64,
2839 &acs_stats);
2840 }
2841 }
2842
2843 return status;
2844}
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002845
Arif Hussainf63f7a32017-08-22 12:49:42 -07002846/**
Arif Hussaind54b62c2018-03-01 13:31:37 -08002847 * dfs_phyerr_event_handler() - dfs phyerr event handler
2848 * @handle: wma handle
2849 * @data: data buffer
2850 * @datalen: buffer length
2851 * @fulltsf: 64 bit event TSF
2852 *
2853 * Function to process DFS phy errors.
2854 *
2855 * Return: QDF_STATUS
2856 */
2857static QDF_STATUS dfs_phyerr_event_handler(tp_wma_handle handle,
2858 uint8_t *data,
2859 uint32_t datalen,
2860 uint64_t fulltsf)
2861{
2862 QDF_STATUS status = QDF_STATUS_SUCCESS;
2863 struct wlan_lmac_if_dfs_rx_ops *dfs_rx_ops;
2864 wmi_host_phyerr_t phyerr;
2865 int8_t rssi_comb;
2866 uint16_t buf_offset;
2867
2868 if (!handle->psoc) {
2869 WMA_LOGE("%s: psoc is null", __func__);
2870 return QDF_STATUS_E_INVAL;
2871 }
2872
2873 dfs_rx_ops = wlan_lmac_if_get_dfs_rx_ops(handle->psoc);
2874 if (!dfs_rx_ops) {
2875 WMA_LOGE("%s: dfs_rx_ops is null", __func__);
2876 return QDF_STATUS_E_INVAL;
2877 }
2878
2879 if (!dfs_rx_ops->dfs_process_phyerr) {
2880 WMA_LOGE("%s: dfs_process_phyerr handler is null", __func__);
2881 return QDF_STATUS_E_INVAL;
2882 }
2883
2884 if (!handle->pdev) {
2885 WMA_LOGE("%s: pdev is null", __func__);
2886 return -EINVAL;
2887 }
2888
2889 buf_offset = 0;
2890 while (buf_offset < datalen) {
2891 status = wmi_extract_single_phyerr(handle->wmi_handle, data, datalen,
2892 &buf_offset, &phyerr);
2893 if (QDF_IS_STATUS_ERROR(status)) {
2894 /* wmi_extract_single_phyerr has logs */
2895 return status;
2896 }
2897
2898 rssi_comb = phyerr.rf_info.rssi_comb & 0xFF;
2899 if (phyerr.buf_len > 0)
2900 dfs_rx_ops->dfs_process_phyerr(handle->pdev,
2901 &phyerr.bufp[0],
2902 phyerr.buf_len,
2903 rssi_comb,
2904 rssi_comb,
2905 phyerr.tsf_timestamp,
2906 fulltsf);
2907 }
2908
2909 return QDF_STATUS_SUCCESS;
2910}
2911
2912/**
Arif Hussainf63f7a32017-08-22 12:49:42 -07002913 * wma_unified_phyerr_rx_event_handler() - phyerr event handler
2914 * @handle: wma handle
2915 * @data: data buffer
2916 * @datalen: buffer length
2917 *
2918 * WMI Handler for WMI_PHYERR_EVENTID event from firmware.
2919 * This handler is currently handling DFS and spectral scan
2920 * phy errors.
2921 *
2922 * Return: 0 for success, other value for failure
2923 */
2924static int wma_unified_phyerr_rx_event_handler(void *handle,
Arif Hussaind54b62c2018-03-01 13:31:37 -08002925 uint8_t *data,
2926 uint32_t datalen)
2927{
Arif Hussainf63f7a32017-08-22 12:49:42 -07002928 /* phyerr handling is moved to cmn project
2929 * As WIN still uses handler registration in non-cmn code.
2930 * need complete testing of non offloaded DFS code before we enable
2931 * it in cmn code.
2932 **/
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002933 tp_wma_handle wma = (tp_wma_handle) handle;
2934 QDF_STATUS status = QDF_STATUS_SUCCESS;
2935 wmi_host_phyerr_t phyerr;
2936 uint16_t buf_offset = 0;
2937
Arif Hussaind54b62c2018-03-01 13:31:37 -08002938 if (!wma) {
2939 WMA_LOGE("%s: wma handle is null", __func__);
2940 return -EINVAL;
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002941 }
2942
2943 /* sanity check on data length */
Arif Hussaind54b62c2018-03-01 13:31:37 -08002944 status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
2945 &buf_offset, &phyerr);
2946 if (QDF_IS_STATUS_ERROR(status)) {
2947 WMA_LOGE("%s: extract phyerr failed: %d", __func__, status);
2948 return qdf_status_to_os_return(status);
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002949 }
2950
2951 /* handle different PHY Error conditions */
2952 if (((phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_RADAR |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002953 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT |
2954 WMI_PHY_ERROR_MASK0_SPECTRAL_SCAN)) == 0)) {
2955 WMA_LOGD("%s: Unknown phy error event", __func__);
2956 return -EINVAL;
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002957 }
2958
2959 /* Handle Spectral or DFS PHY Error */
2960 if (phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_RADAR |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002961 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT)) {
2962 if (wma->is_dfs_offloaded) {
2963 WMA_LOGD("%s: Unexpected phy error, dfs offloaded",
2964 __func__);
2965 return -EINVAL;
2966 }
2967 status = dfs_phyerr_event_handler(wma,
2968 phyerr.bufp,
2969 phyerr.buf_len,
2970 phyerr.tsf64);
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002971 } else if (phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_SPECTRAL_SCAN |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002972 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT)) {
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002973 status = spectral_phyerr_event_handler(wma, data, datalen);
2974 }
Arif Hussaind54b62c2018-03-01 13:31:37 -08002975
2976 return qdf_status_to_os_return(status);
Arif Hussainf63f7a32017-08-22 12:49:42 -07002977}
2978
Dustin Brownec2c92e2017-07-26 11:13:49 -07002979void wma_vdev_init(struct wma_txrx_node *vdev)
2980{
2981 qdf_wake_lock_create(&vdev->vdev_start_wakelock, "vdev_start");
2982 qdf_wake_lock_create(&vdev->vdev_stop_wakelock, "vdev_stop");
Rajeev Kumar155a3e42017-10-10 15:31:17 -07002983 qdf_wake_lock_create(&vdev->vdev_set_key_wakelock, "vdev_set_key");
Naveen Rawatd7734142017-10-27 10:02:40 -07002984 vdev->is_waiting_for_key = false;
Dustin Brownec2c92e2017-07-26 11:13:49 -07002985}
2986
2987void wma_vdev_deinit(struct wma_txrx_node *vdev)
2988{
2989 qdf_wake_lock_destroy(&vdev->vdev_start_wakelock);
2990 qdf_wake_lock_destroy(&vdev->vdev_stop_wakelock);
Rajeev Kumar155a3e42017-10-10 15:31:17 -07002991 qdf_wake_lock_destroy(&vdev->vdev_set_key_wakelock);
Naveen Rawatd7734142017-10-27 10:02:40 -07002992 vdev->is_waiting_for_key = false;
Dustin Brownec2c92e2017-07-26 11:13:49 -07002993}
2994
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08002995/**
2996 * wma_wmi_stop() - generic function to block WMI commands
2997 * @return: None
2998 */
2999void wma_wmi_stop(void)
3000{
3001 tp_wma_handle wma_handle;
3002
3003 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
3004 if (wma_handle == NULL) {
3005 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
3006 "wma_handle is NULL\n");
3007 return;
3008 }
3009 wmi_stop(wma_handle->wmi_handle);
3010}
3011
Naveen Rawate8b1b822018-01-30 09:46:16 -08003012#ifdef QCA_SUPPORT_CP_STATS
3013static void wma_register_stats_events(wmi_unified_t wmi_handle) {}
3014#else
3015static void wma_register_stats_events(wmi_unified_t wmi_handle)
3016{
3017 wmi_unified_register_event_handler(wmi_handle,
3018 wmi_update_stats_event_id,
3019 wma_stats_event_handler,
3020 WMA_RX_SERIALIZER_CTX);
3021}
3022#endif
3023
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08003024/**
3025 * wma_open() - Allocate wma context and initialize it.
3026 * @cds_context: cds context
3027 * @wma_tgt_cfg_cb: tgt config callback fun
3028 * @radar_ind_cb: dfs radar indication callback
3029 * @cds_cfg: mac parameters
3030 *
3031 * Return: 0 on success, errno on failure
3032 */
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003033QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 wma_tgt_cfg_cb tgt_cfg_cb,
bings482bae22018-01-17 16:25:31 +08003035 struct cds_config_info *cds_cfg,
3036 uint32_t target_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037{
3038 tp_wma_handle wma_handle;
3039 HTC_HANDLE htc_handle;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303040 qdf_device_t qdf_dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 void *wmi_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303042 QDF_STATUS qdf_status;
Lin Bai04f603e2018-03-19 11:01:06 +08003043 struct wmi_unified_attach_params *params;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003044 struct policy_mgr_wma_cbacks wma_cbacks;
Frank Liu00d73fe2017-05-19 22:11:28 +08003045 struct target_psoc_info *tgt_psoc_info;
Dustin Brownec2c92e2017-07-26 11:13:49 -07003046 int i;
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003047 void *cds_context;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303048 target_resource_config *wlan_res_cfg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049
3050 WMA_LOGD("%s: Enter", __func__);
3051
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003052 cds_context = cds_get_global_context();
3053 if (!cds_context) {
3054 WMA_LOGE("%s: Invalid CDS context", __func__);
3055 return QDF_STATUS_E_INVAL;
3056 }
3057
Mukul Sharma5ff3c582016-09-12 15:23:35 +05303058 g_wmi_version_info.major = __WMI_VER_MAJOR_;
3059 g_wmi_version_info.minor = __WMI_VER_MINOR_;
3060 g_wmi_version_info.revision = __WMI_REVISION_;
3061
Anurag Chouhan6d760662016-02-20 16:05:43 +05303062 qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
3063 htc_handle = cds_get_context(QDF_MODULE_ID_HTC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064
3065 if (!htc_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003066 WMA_LOGE("%s: Invalid HTC handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303067 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 }
3069
3070 /* Alloc memory for WMA Context */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003071 qdf_status = cds_alloc_context(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 (void **)&wma_handle,
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003073 sizeof(*wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303075 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003076 WMA_LOGE("%s: Memory allocation failed for wma_handle",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303078 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 }
3080
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303081 qdf_mem_zero(wma_handle, sizeof(t_wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303083 if (target_if_alloc_psoc_tgt_info(psoc)) {
3084 WMA_LOGE("%s target psoc info allocation failed", __func__);
3085 qdf_status = QDF_STATUS_E_NOMEM;
3086 goto err_free_wma_handle;
Frank Liu00d73fe2017-05-19 22:11:28 +08003087 }
3088
Anurag Chouhan6d760662016-02-20 16:05:43 +05303089 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303091 qdf_wake_lock_create(&wma_handle->extscan_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 "wlan_extscan_wl");
3093#endif /* FEATURE_WLAN_EXTSCAN */
Mukul Sharmae44d0542017-05-23 21:50:56 +05303094 qdf_wake_lock_create(&wma_handle->wow_wake_lock,
3095 "wlan_wow_wl");
3096 qdf_wake_lock_create(&wma_handle->wow_auth_req_wl,
3097 "wlan_auth_req_wl");
3098 qdf_wake_lock_create(&wma_handle->wow_assoc_req_wl,
3099 "wlan_assoc_req_wl");
3100 qdf_wake_lock_create(&wma_handle->wow_deauth_rec_wl,
3101 "wlan_deauth_rec_wl");
3102 qdf_wake_lock_create(&wma_handle->wow_disassoc_rec_wl,
3103 "wlan_disassoc_rec_wl");
3104 qdf_wake_lock_create(&wma_handle->wow_ap_assoc_lost_wl,
3105 "wlan_ap_assoc_lost_wl");
3106 qdf_wake_lock_create(&wma_handle->wow_auto_shutdown_wl,
3107 "wlan_auto_shutdown_wl");
3108 qdf_wake_lock_create(&wma_handle->roam_ho_wl,
3109 "wlan_roam_ho_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 }
3111
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05303112 qdf_status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_LEGACY_WMA_ID);
3113 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3114 WMA_LOGE("%s: PSOC get_ref fails", __func__);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303115 goto err_wma_handle;
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05303116 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303117 wma_handle->psoc = psoc;
3118
Rajeev Kumarda2444c2017-01-10 22:42:07 -08003119 /* Open target_if layer and register wma callback */
3120 wma_target_if_open(wma_handle);
3121 target_if_open(wma_get_psoc_from_scn_handle);
3122
Lin Bai04f603e2018-03-19 11:01:06 +08003123 /*
3124 * Allocate locally used params with its rx_ops member,
3125 * and free it immediately after used.
3126 */
3127 params = qdf_mem_malloc(sizeof(*params) + sizeof(struct wmi_rx_ops));
3128 if (!params) {
3129 WMA_LOGE("%s: failed to allocate attach params", __func__);
3130 qdf_status = QDF_STATUS_E_NOMEM;
3131 goto err_wma_handle;
3132 }
3133
3134 params->rx_ops = (struct wmi_rx_ops *)(params + 1);
3135 params->osdev = NULL;
3136 params->target_type = WMI_TLV_TARGET;
3137 params->use_cookie = false;
3138 params->psoc = psoc;
3139 params->max_commands = WMI_MAX_CMDS;
Govind Singhd76a5b02016-03-08 15:12:14 +05303140 /* Attach mc_thread context processing function */
Lin Bai04f603e2018-03-19 11:01:06 +08003141 params->rx_ops->wma_process_fw_event_handler_cbk =
3142 wma_process_fw_event_handler;
Surabhi Vishnoi75b1a812018-02-09 12:07:16 +05303143
Himanshu Agarwal88b16a42018-02-06 15:10:59 +05303144 /* initialize tlv attach */
3145 wmi_tlv_init();
Surabhi Vishnoi75b1a812018-02-09 12:07:16 +05303146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 /* attach the wmi */
Lin Bai04f603e2018-03-19 11:01:06 +08003148 wmi_handle = wmi_unified_attach(wma_handle, params);
3149 qdf_mem_free(params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150 if (!wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003151 WMA_LOGE("%s: failed to attach WMI", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303152 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 goto err_wma_handle;
3154 }
3155
Rajeev Kumarda2444c2017-01-10 22:42:07 -08003156 target_if_register_legacy_service_ready_cb(
3157 wma_legacy_service_ready_event_handler);
3158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 WMA_LOGA("WMA --> wmi_unified_attach - success");
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05303160
Frank Liu00d73fe2017-05-19 22:11:28 +08003161 /* store the wmi handle in tgt_if_handle */
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303162 tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05303163
bings6b413662018-02-06 17:51:36 +08003164 target_psoc_set_target_type(tgt_psoc_info, target_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 /* Save the WMI & HTC handle */
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303166 target_psoc_set_wmi_hdl(tgt_psoc_info, wmi_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 wma_handle->wmi_handle = wmi_handle;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303168 target_psoc_set_htc_hdl(tgt_psoc_info, htc_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 wma_handle->cds_context = cds_context;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303170 wma_handle->qdf_dev = qdf_dev;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303171 wma_handle->max_scan = cds_cfg->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303173 /* Register Converged Event handlers */
3174 init_deinit_register_tgt_psoc_ev_handlers(psoc);
3175
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303176 /* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303177 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303178 /* Cap maxStation based on the target version */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303179 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303180 /* Reinitialize max_no_of_peers based on the capped maxStation value */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303181 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303182
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 /* initialize default target config */
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303184 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_psoc_info);
Arif Hussaind15902c2018-03-02 00:08:29 -08003185 if (!wlan_res_cfg) {
3186 WMA_LOGE("%s: wlan_res_cfg is null", __func__);
3187 qdf_status = QDF_STATUS_E_NOMEM;
3188 goto err_wma_handle;
3189 }
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303190
3191 wma_set_default_tgt_config(wma_handle, wlan_res_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303193 wma_handle->tx_chain_mask_cck = cds_cfg->tx_chain_mask_cck;
3194 wma_handle->self_gen_frm_pwr = cds_cfg->self_gen_frm_pwr;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303195 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
3196 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303198 cds_cfg->max_bssid = WMA_MAX_SUPPORTED_BSS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303200 wlan_res_cfg->num_keep_alive_pattern = WMA_MAXNUM_PERIODIC_TX_PTRNS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201
3202 /* The current firmware implementation requires the number of
Anurag Chouhanffb21542016-02-17 14:33:03 +05303203 * offload peers should be (number of vdevs + 1).
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 */
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303205 wlan_res_cfg->num_offload_peers =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303206 cds_cfg->ap_maxoffload_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303208 wlan_res_cfg->num_offload_reorder_buffs =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303209 cds_cfg->ap_maxoffload_reorderbuffs + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303211 wma_handle->max_station = cds_cfg->max_station;
3212 wma_handle->max_bssid = cds_cfg->max_bssid;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303213 wma_handle->driver_type = cds_cfg->driver_type;
3214 wma_handle->ssdp = cds_cfg->ssdp;
3215 wma_handle->enable_mc_list = cds_cfg->enable_mc_list;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05303216 wma_handle->bpf_packet_filter_enable =
3217 cds_cfg->bpf_packet_filter_enable;
Hanumanth Reddy Pothulae87621b2017-04-12 20:53:35 +05303218 wma_handle->active_uc_bpf_mode = cds_cfg->active_uc_bpf_mode;
3219 wma_handle->active_mc_bc_bpf_mode = cds_cfg->active_mc_bc_bpf_mode;
Srinivas Girigowda57b450e2016-10-27 21:00:46 -07003220 wma_handle->link_stats_results = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303222 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
3223 wma_handle->RArateLimitInterval = cds_cfg->ra_ratelimit_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224#endif /* FEATURE_WLAN_RA_FILTERING */
3225#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303226 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227#endif
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303228 wma_set_nan_enable(wma_handle, cds_cfg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303229 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 wma_handle->max_bssid);
3231 if (!wma_handle->interfaces) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003232 WMA_LOGE("%s: failed to allocate interface table", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303233 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 goto err_scn_context;
3235 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003236
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003237 for (i = 0; i < wma_handle->max_bssid; ++i) {
Dustin Brownec2c92e2017-07-26 11:13:49 -07003238 wma_vdev_init(&wma_handle->interfaces[i]);
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003239 wma_handle->interfaces[i].delay_before_vdev_stop =
3240 cds_cfg->delay_before_vdev_stop;
3241 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 /* Register the debug print event handler */
3243 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303244 wmi_debug_print_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303245 wma_unified_debug_print_event_handler,
3246 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05303247 /* Register profiling event Handler */
3248 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303249 wmi_wlan_profile_data_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303250 wma_profile_data_report_event_handler,
3251 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252
3253 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
3255 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05303256 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07003257 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258
Anurag Chouhan210db072016-02-22 18:42:15 +05303259 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303260 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303261 wma_service_ready_ext_evt_timeout,
3262 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303263 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303264 WMA_LOGE("Failed to initialize service ready ext timeout");
3265 goto err_event_init;
3266 }
3267
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303268 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303269 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003270 WMA_LOGE("%s: target suspend event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 __func__);
3272 goto err_event_init;
3273 }
3274
3275 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303276 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
3277 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003278 WMA_LOGE("%s: failed to init tx_frm_download_comp_event",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 __func__);
3280 goto err_event_init;
3281 }
3282
3283 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303284 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
3285 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003286 WMA_LOGE("%s: failed to init tx_queue_empty_event", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 goto err_event_init;
3288 }
3289
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303290 qdf_status = qdf_event_create(&wma_handle->wma_resume_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303291 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003292 WMA_LOGE("%s: wma_resume_event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 __func__);
3294 goto err_event_init;
3295 }
3296
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003297 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
3298 wma_handle);
3299 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003300 WMA_LOGE("%s: Shutdown notifier register failed: %d",
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003301 __func__, qdf_status);
3302 goto err_event_init;
3303 }
3304
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303305 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303306 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003307 WMA_LOGE("%s: runtime_suspend event initialization failed",
Houston Hoffmana76591b2015-11-10 16:52:05 -08003308 __func__);
3309 goto err_event_init;
3310 }
3311
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303312 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303313 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003314 WMA_LOGE("%s: recovery event initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 goto err_event_init;
3316 }
3317
Anurag Chouhanffb21542016-02-17 14:33:03 +05303318 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003319 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303320 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303321 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303323 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05303324 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
3325 qdf_atomic_init(&wma_handle->scan_id_counter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326
3327 /* Register vdev start response event handler */
3328 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303329 wmi_vdev_start_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303330 wma_vdev_start_resp_handler,
3331 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332
3333 /* Register vdev stop response event handler */
3334 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303335 wmi_vdev_stopped_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303336 wma_vdev_stop_resp_handler,
3337 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338
3339 /* register for STA kickout function */
3340 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303341 wmi_peer_sta_kickout_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303342 wma_peer_sta_kickout_event_handler,
3343 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344
Naveen Rawate8b1b822018-01-30 09:46:16 -08003345 /* register for stats event */
3346 wma_register_stats_events(wma_handle->wmi_handle);
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303347
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303348 /* register for stats response event */
3349 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303350 wmi_get_arp_stats_req_id,
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303351 wma_get_arp_stats_handler,
3352 WMA_RX_SERIALIZER_CTX);
3353
Will Huanga9814592017-05-24 15:47:58 +08003354 /* register for peer info response event */
3355 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303356 wmi_peer_stats_info_event_id,
Will Huanga9814592017-05-24 15:47:58 +08003357 wma_peer_info_event_handler,
3358 WMA_RX_SERIALIZER_CTX);
3359
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303360#ifdef WLAN_POWER_DEBUGFS
3361 /* register for Chip Power stats event */
3362 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303363 wmi_pdev_chip_power_stats_event_id,
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303364 wma_unified_power_debug_stats_event_handler,
3365 WMA_RX_SERIALIZER_CTX);
3366#endif
3367
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368 /* register for linkspeed response event */
3369 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303370 wmi_peer_estimated_linkspeed_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303371 wma_link_speed_event_handler,
3372 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373
3374#ifdef FEATURE_OEM_DATA_SUPPORT
3375 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303376 wmi_oem_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303377 wma_oem_data_response_handler,
3378 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379#endif /* FEATURE_OEM_DATA_SUPPORT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380
3381 /* Register peer change event handler */
3382 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303383 wmi_peer_state_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303384 wma_peer_state_change_event_handler,
3385 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386
3387 /* Register beacon tx complete event id. The event is required
3388 * for sending channel switch announcement frames
3389 */
3390 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303391 wmi_offload_bcn_tx_status_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303392 wma_unified_bcntx_status_event_handler,
3393 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394
3395 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303396 wmi_update_vdev_rate_stats_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303397 wma_link_status_event_handler,
3398 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399#ifdef WLAN_FEATURE_LINK_LAYER_STATS
3400 /* Register event handler for processing Link Layer Stats
3401 * response from the FW
3402 */
3403 wma_register_ll_stats_event_handler(wma_handle);
3404
3405#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
3406
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +05303407 wmi_set_tgt_assert(wma_handle->wmi_handle,
3408 cds_cfg->force_target_assert_enabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303410 qdf_status = dbglog_init(wma_handle->wmi_handle);
3411 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003412 WMA_LOGE("%s: Firmware Dbglog initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 goto err_dbglog_init;
3414 }
3415
3416 /*
3417 * Update Powersave mode
3418 * 1 - Legacy Powersave + Deepsleep Disabled
3419 * 2 - QPower + Deepsleep Disabled
3420 * 3 - Legacy Powersave + Deepsleep Enabled
3421 * 4 - QPower + Deepsleep Enabled
3422 */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303423 wma_handle->powersave_mode = cds_cfg->powersave_offload_enabled;
3424 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
3425 wma_handle->staModDtim = cds_cfg->sta_mod_dtim;
3426 wma_handle->staDynamicDtim = cds_cfg->sta_dynamic_dtim;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427
3428 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303429 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 * 0 - Disable both magic pattern match and pattern byte match.
3431 * 1 - Enable magic pattern match on all interfaces.
3432 * 2 - Enable pattern byte match on all interfaces.
3433 * 3 - Enable both magic patter and pattern byte match on
3434 * all interfaces.
3435 */
3436 wma_handle->wow.magic_ptrn_enable =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303437 (cds_cfg->wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 wma_handle->ptrn_match_enable_all_vdev =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303439 (cds_cfg->wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441 /* register for install key completion event */
3442 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303443 wmi_vdev_install_key_complete_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303444 wma_vdev_install_key_complete_event_handler,
3445 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446#ifdef WLAN_FEATURE_NAN
3447 /* register for nan response event */
3448 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303449 wmi_nan_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303450 wma_nan_rsp_event_handler,
3451 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452#endif /* WLAN_FEATURE_NAN */
3453
3454#ifdef WLAN_FEATURE_STATS_EXT
3455 /* register for extended stats event */
3456 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303457 wmi_stats_ext_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303458 wma_stats_ext_event_handler,
3459 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460#endif /* WLAN_FEATURE_STATS_EXT */
3461#ifdef FEATURE_WLAN_EXTSCAN
3462 wma_register_extscan_event_handler(wma_handle);
3463#endif /* WLAN_FEATURE_STATS_EXT */
3464
3465 WMA_LOGD("%s: Exit", __func__);
3466
3467#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3468 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303469 wmi_roam_synch_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303470 wma_roam_synch_event_handler,
3471 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303472 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303473 wmi_roam_synch_frame_event_id,
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303474 wma_roam_synch_frame_event_handler,
3475 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3477 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303478 wmi_rssi_breach_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303479 wma_rssi_breached_event_handler,
3480 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303482 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05303483 "wlan_fw_rsp_wakelock");
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003484 qdf_runtime_lock_init(&wma_handle->wmi_cmd_rsp_runtime_lock);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003485
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 /* Register peer assoc conf event handler */
3487 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303488 wmi_peer_assoc_conf_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303489 wma_peer_assoc_conf_handler,
3490 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003491 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303492 wmi_vdev_delete_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303493 wma_vdev_delete_handler,
3494 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003495 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303496 wmi_peer_delete_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303497 wma_peer_delete_handler,
3498 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05303499 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303500 wmi_bpf_capability_info_event_id,
Arun Khandavalli2476ef52016-04-26 20:19:43 +05303501 wma_get_bpf_caps_event_handler,
3502 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05303503 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303504 wmi_chan_info_event_id,
Kapil Gupta4f0c0c12017-02-07 15:21:15 +05303505 wma_chan_info_event_handler,
3506 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003507 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303508 wmi_dbg_mesg_flush_complete_event_id,
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003509 wma_flush_complete_evt_handler,
Rajeev Kumarc3032b82017-02-14 15:56:01 -08003510 WMA_RX_WORK_CTX);
lifeng66831662017-05-19 16:01:35 +08003511 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303512 wmi_report_rx_aggr_failure_event_id,
lifeng66831662017-05-19 16:01:35 +08003513 wma_rx_aggr_failure_event_handler,
3514 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003515
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303516 wma_handle->ito_repeat_count = cds_cfg->ito_repeat_count;
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07003517 wma_handle->bandcapability = cds_cfg->bandcapability;
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303518
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303519 /* Register PWR_SAVE_FAIL event only in case of recovery(1) */
Hanumanth Reddy Pothulaab395952017-09-05 19:12:26 +05303520 if (cds_cfg->auto_power_save_fail_mode ==
3521 PMO_FW_TO_SEND_WOW_IND_ON_PWR_FAILURE) {
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303522 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303523 wmi_pdev_chip_pwr_save_failure_detect_event_id,
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303524 wma_chip_power_save_failure_detected_handler,
3525 WMA_RX_WORK_CTX);
3526 }
3527
lifengd217d192017-05-09 19:44:16 +08003528 wmi_unified_register_event_handler(wma_handle->wmi_handle,
lifengfe6c3e22018-04-03 12:10:04 +08003529 wmi_pdev_div_rssi_antid_event_id,
3530 wma_pdev_div_info_evt_handler,
lifengd217d192017-05-09 19:44:16 +08003531 WMA_RX_WORK_CTX);
3532
Frank Liu65b17d92016-11-23 15:58:44 +08003533
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303534 wma_register_debug_callback();
Mukul Sharma6411bb82017-03-01 15:57:07 +05303535 /* Register callback with PMO so PMO can update the vdev pause bitmap*/
3536 pmo_register_pause_bitmap_notifier(wma_handle->psoc,
3537 wma_vdev_update_pause_bitmap);
3538 pmo_register_get_pause_bitmap(wma_handle->psoc,
3539 wma_vdev_get_pause_bitmap);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303540 pmo_register_is_device_in_low_pwr_mode(wma_handle->psoc,
3541 wma_vdev_is_device_in_low_pwr_mode);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003542 wma_cbacks.wma_get_connection_info = wma_get_connection_info;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003543 qdf_status = policy_mgr_register_wma_cb(wma_handle->psoc, &wma_cbacks);
3544 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
3545 WMA_LOGE("Failed to register wma cb with Policy Manager");
3546 }
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303547
Arif Hussainf63f7a32017-08-22 12:49:42 -07003548 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303549 wmi_phyerr_event_id,
Arif Hussainf63f7a32017-08-22 12:49:42 -07003550 wma_unified_phyerr_rx_event_handler,
3551 WMA_RX_WORK_CTX);
3552
Arif Hussainee10f902017-12-27 16:30:17 -08003553 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3554 wmi_sap_obss_detection_report_event_id,
3555 wma_vdev_obss_detection_info_handler,
3556 WMA_RX_SERIALIZER_CTX);
3557
Arif Hussain05fb4872018-01-03 16:02:55 -08003558 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3559 wmi_obss_color_collision_report_event_id,
3560 wma_vdev_bss_color_collision_info_handler,
3561 WMA_RX_WORK_CTX);
3562
3563
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303564 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565
3566err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303567 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003568 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303569 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
3570 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571err_event_init:
3572 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303573 wmi_debug_print_event_id);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003574
3575 for (i = 0; i < wma_handle->max_bssid; ++i)
3576 wma_vdev_deinit(&wma_handle->interfaces[i]);
3577
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303578 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580err_scn_context:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303581 qdf_mem_free(((p_cds_contextType) cds_context)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 OS_FREE(wmi_handle);
3583
3584err_wma_handle:
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303585 target_if_free_psoc_tgt_info(psoc);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303586 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303588 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303590 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05303591 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
3592 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
3593 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
3594 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
3595 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
3596 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
3597 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303599err_free_wma_handle:
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003600 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601
3602 WMA_LOGD("%s: Exit", __func__);
3603
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303604 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605}
3606
3607/**
3608 * wma_pre_start() - wma pre start
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 *
3610 * Return: 0 on success, errno on failure
3611 */
Jeff Johnson8ad89c62017-09-13 08:55:55 -07003612QDF_STATUS wma_pre_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303614 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 tp_wma_handle wma_handle;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08003616 struct scheduler_msg wma_msg = { 0 };
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303617 void *htc_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618
3619 WMA_LOGD("%s: Enter", __func__);
3620
Anurag Chouhan6d760662016-02-20 16:05:43 +05303621 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622
3623 /* Validate the wma_handle */
3624 if (NULL == wma_handle) {
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303625 WMA_LOGE("%s: invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303626 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627 goto end;
3628 }
Nachiket Kukade8003d252017-03-30 15:55:58 +05303629
Sourav Mohapatracf632572018-04-02 11:01:35 +05303630 htc_handle = lmac_get_htc_hdl(wma_handle->psoc);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303631 if (!htc_handle) {
3632 WMA_LOGE("%s: invalid htc handle", __func__);
3633 qdf_status = QDF_STATUS_E_INVAL;
3634 goto end;
3635 }
3636
3637 /* Open endpoint for ctrl path - WMI <--> HTC */
3638 qdf_status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
3639 htc_handle);
3640 if (qdf_status != QDF_STATUS_SUCCESS) {
3641 WMA_LOGE("%s: wmi_unified_connect_htc_service", __func__);
Nachiket Kukade8003d252017-03-30 15:55:58 +05303642 if (!cds_is_fw_down())
3643 QDF_BUG(0);
3644
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303645 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646 goto end;
3647 }
3648
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08003649 WMA_LOGD("WMA --> wmi_unified_connect_htc_service - success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650
3651 /* Trigger the CFG DOWNLOAD */
3652 wma_msg.type = WNI_CFG_DNLD_REQ;
3653 wma_msg.bodyptr = NULL;
3654 wma_msg.bodyval = 0;
3655
Rajeev Kumarb60abe42017-01-21 15:39:31 -08003656 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &wma_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303657 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003658 WMA_LOGE("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303659 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303660 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 }
3662end:
3663 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303664 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665}
3666
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303667void wma_send_msg_by_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3668 void *body_ptr, uint32_t body_val, bool is_high_priority)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669{
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303670 struct scheduler_msg msg = {0};
3671 QDF_STATUS status;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003672
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 msg.type = msg_type;
3674 msg.bodyval = body_val;
3675 msg.bodyptr = body_ptr;
Will Huang9323e852018-02-02 17:55:15 +08003676 msg.flush_callback = wma_discard_fw_event;
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303677
3678 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE,
3679 &msg, is_high_priority);
3680 if (!QDF_IS_STATUS_SUCCESS(status)) {
3681 WMA_LOGE("Failed to post msg %d to PE", msg_type);
3682 if (body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303683 qdf_mem_free(body_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685}
3686
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303687
3688void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
3689 void *body_ptr, uint32_t body_val)
3690{
3691 wma_send_msg_by_priority(wma_handle, msg_type,
3692 body_ptr, body_val, false);
3693}
3694
3695void wma_send_msg_high_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3696 void *body_ptr, uint32_t body_val)
3697{
3698 wma_send_msg_by_priority(wma_handle, msg_type,
3699 body_ptr, body_val, true);
3700}
3701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702/**
3703 * wma_set_base_macaddr_indicate() - set base mac address in fw
3704 * @wma_handle: wma handle
3705 * @customAddr: base mac address
3706 *
3707 * Return: 0 for success or error code
3708 */
3709static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
3710 tSirMacAddr *customAddr)
3711{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712 int err;
3713
Govind Singhf25a0f12016-03-08 16:09:48 +05303714 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
3715 (uint8_t *)customAddr);
3716 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
3719 MAC_ADDR_ARRAY((*customAddr)));
3720
3721 return 0;
3722}
3723
3724/**
3725 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
3726 * @handle: WMA handle
3727 * @event: Event received from FW
3728 * @len: Length of the event
3729 *
3730 * Enables the low frequency events and disables the high frequency
3731 * events. Bit 17 indicates if the event if low/high frequency.
3732 * 1 - high frequency, 0 - low frequency
3733 *
3734 * Return: 0 on successfully enabling/disabling the events
3735 */
3736static int wma_log_supported_evt_handler(void *handle,
3737 uint8_t *event,
3738 uint32_t len)
3739{
3740 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741
Govind Singhf25a0f12016-03-08 16:09:48 +05303742 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
3743 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745
3746 return 0;
3747}
3748
3749/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303750 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003751 * @handle: WMI handle
3752 * @event: Event recevied from FW
3753 * @len: Length of the event
3754 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303755 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
3756 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
3757 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758 *
Dustin Brownec2c92e2017-07-26 11:13:49 -07003759 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003760 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303761static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762 uint8_t *event,
3763 uint32_t len)
3764{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303765 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
3766 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
3767 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003768 uint32_t i;
3769 struct sir_set_hw_mode_resp *hw_mode_resp;
3770 tp_wma_handle wma = (tp_wma_handle) handle;
3771
3772 if (!wma) {
3773 WMA_LOGE("%s: Invalid WMA handle", __func__);
3774 /* Since WMA handle itself is NULL, we cannot send fail
3775 * response back to LIM here
3776 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303777 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003779
3780 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -08003781 wma_remove_req(wma, 0, WMA_PDEV_SET_HW_MODE_RESP);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003782
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303783 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784 if (!hw_mode_resp) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003785 WMA_LOGE("%s: Memory allocation failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 /* Since this memory allocation itself failed, we cannot
3787 * send fail response back to LIM here
3788 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303789 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 }
3791
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303792 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303794 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 /* Need to send response back to upper layer to free
3796 * active command list
3797 */
3798 goto fail;
3799 }
Krunal Soni50a05542017-10-03 19:39:48 -07003800 if (param_buf->fixed_param->num_vdev_mac_entries >=
3801 MAX_VDEV_SUPPORTED) {
3802 WMA_LOGE("num_vdev_mac_entries crossed max value");
3803 goto fail;
3804 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805
3806 wmi_event = param_buf->fixed_param;
Abhinav Kumara03659c2017-12-28 15:18:07 +05303807 if (wmi_event->num_vdev_mac_entries >
3808 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
3809 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
3810 wmi_event->num_vdev_mac_entries);
3811 goto fail;
3812 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003813 hw_mode_resp->status = wmi_event->status;
3814 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3815 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
3816
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003817 WMA_LOGD("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818 __func__, wmi_event->status,
3819 wmi_event->cfgd_hw_mode_index,
3820 wmi_event->num_vdev_mac_entries);
3821 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303822 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823
3824 /* Store the vdev-mac map in WMA and prepare to send to PE */
3825 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303826 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303829 pdev_id = vdev_mac_entry[i].pdev_id;
3830 if (pdev_id == WMI_PDEV_ID_SOC) {
3831 WMA_LOGE("%s: soc level id received for mac id)",
3832 __func__);
3833 QDF_BUG(0);
3834 goto fail;
3835 }
3836 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003838 WMA_LOGD("%s: vdev_id:%d mac_id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003839 __func__, vdev_id, mac_id);
3840
3841 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
3842 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
3843 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3844 wmi_event->cfgd_hw_mode_index);
3845 }
3846
3847 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
3848 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
3849 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3850 } else {
3851 wma->old_hw_mode_index = wma->new_hw_mode_index;
3852 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3853 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003854 policy_mgr_update_hw_mode_index(wma->psoc,
3855 wmi_event->cfgd_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 }
3857
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003858 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3860
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303861 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 (void *) hw_mode_resp, 0);
3863
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303864 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865
3866fail:
3867 WMA_LOGE("%s: Sending fail response to LIM", __func__);
3868 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
3869 hw_mode_resp->cfgd_hw_mode_index = 0;
3870 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303871 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 (void *) hw_mode_resp, 0);
3873
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303874 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875}
3876
3877/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003878 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
3879 *
3880 * @handle: WMA handle
3881 * @fixed_param: Event fixed parameters
3882 * @vdev_mac_entry - vdev mac entry
3883 * @hw_mode_trans_ind - Buffer to store parsed information
3884 *
3885 * Parses fixed_param, vdev_mac_entry and fills in the information into
3886 * hw_mode_trans_ind and wma
3887 *
3888 * Return: None
3889 */
3890void wma_process_pdev_hw_mode_trans_ind(void *handle,
3891 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
3892 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
3893 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
3894{
3895 uint32_t i;
3896 tp_wma_handle wma = (tp_wma_handle) handle;
gaurank kathpaliad2967a72018-05-01 12:35:14 +05303897 if (fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
3898 WMA_LOGE("Number of Vdev mac entries %d exceeded"
3899 " max vdev supported %d",
3900 fixed_param->num_vdev_mac_entries,
3901 MAX_VDEV_SUPPORTED);
3902 return;
3903 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003904 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
3905 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
3906 hw_mode_trans_ind->num_vdev_mac_entries =
3907 fixed_param->num_vdev_mac_entries;
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003908 WMA_LOGD("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003909 __func__, fixed_param->old_hw_mode_index,
3910 fixed_param->new_hw_mode_index,
3911 fixed_param->num_vdev_mac_entries);
3912
3913 /* Store the vdev-mac map in WMA and send to policy manager */
3914 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
3915 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003916
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003917 vdev_id = vdev_mac_entry[i].vdev_id;
3918 pdev_id = vdev_mac_entry[i].pdev_id;
3919
3920 if (pdev_id == WMI_PDEV_ID_SOC) {
3921 WMA_LOGE("%s: soc level id received for mac id)",
3922 __func__);
3923 QDF_BUG(0);
3924 return;
3925 }
3926
3927 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
3928
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003929 WMA_LOGE("%s: vdev_id:%d mac_id:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003930 __func__, vdev_id, mac_id);
3931
3932 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
3933 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
3934 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3935 fixed_param->new_hw_mode_index);
3936 }
3937 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
3938 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003939 policy_mgr_update_new_hw_mode_index(wma->psoc,
3940 fixed_param->new_hw_mode_index);
3941 policy_mgr_update_old_hw_mode_index(wma->psoc,
3942 fixed_param->old_hw_mode_index);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003943
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003944 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003945 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3946}
3947
3948/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303949 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950 * @handle: WMI handle
3951 * @event: Event recevied from FW
3952 * @len: Length of the event
3953 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303954 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955 * asynchronous hardware mode transition. This event notifies the host driver
3956 * that firmware independently changed the hardware mode for some reason, such
3957 * as Coex, LFR 3.0, etc
3958 *
3959 * Return: Success on receiving valid params from FW
3960 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303961static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962 uint8_t *event,
3963 uint32_t len)
3964{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303965 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
3966 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
3967 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
3969 tp_wma_handle wma = (tp_wma_handle) handle;
3970
3971 if (!wma) {
3972 /* This is an async event. So, not sending any event to LIM */
3973 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303974 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 }
3976
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303977 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 if (!param_buf) {
3979 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303980 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303981 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982 }
3983
Arif Hussain34f72062017-10-04 17:25:24 -07003984 if (param_buf->fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
3985 WMA_LOGE("num_vdev_mac_entries: %d crossed max value: %d",
3986 param_buf->fixed_param->num_vdev_mac_entries,
3987 MAX_VDEV_SUPPORTED);
3988 return QDF_STATUS_E_FAILURE;
3989 }
3990
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303991 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 if (!hw_mode_trans_ind) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003993 WMA_LOGE("%s: Memory allocation failed", __func__);
3994 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 }
3996
3997 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303999 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Abhinav Kumara03659c2017-12-28 15:18:07 +05304000 if (wmi_event->num_vdev_mac_entries >
4001 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
4002 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
4003 wmi_event->num_vdev_mac_entries);
4004 qdf_mem_free(hw_mode_trans_ind);
4005 return -EINVAL;
4006 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004007 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
4008 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304010 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004011 (void *) hw_mode_trans_ind, 0);
4012
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304013 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004014}
4015
4016/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304017 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004018 * @handle: WMI handle
4019 * @event: Event received from FW
4020 * @len: Length of the event
4021 *
4022 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304023 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004024 * the host driver once the firmware has completed a reconfiguration of the Scan
4025 * and FW mode configuration. This changes could include entering or leaving a
4026 * dual mac configuration for either scan and/or more permanent firmware mode.
4027 *
4028 * Return: Success on receiving valid params from FW
4029 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304030static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 uint8_t *event,
4032 uint32_t len)
4033{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304034 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
4035 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 tp_wma_handle wma = (tp_wma_handle) handle;
4037 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
4038
4039 if (!wma) {
4040 WMA_LOGE("%s: Invalid WMA handle", __func__);
4041 /* Since the WMA handle is NULL, we cannot send resp to LIM.
4042 * So, returning from here.
4043 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304044 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 }
Krunal Sonia5ccb802017-07-03 12:59:40 -07004046 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304047 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048 if (!dual_mac_cfg_resp) {
4049 WMA_LOGE("%s: Memory allocation failed", __func__);
4050 /* Since the mem alloc failed, we cannot send resp to LIM.
4051 * So, returning from here.
4052 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304053 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054 }
4055
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304056 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 event;
4058 if (!param_buf) {
4059 WMA_LOGE("%s: Invalid event", __func__);
4060 goto fail;
4061 }
4062
4063 wmi_event = param_buf->fixed_param;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004064 WMA_LOGD("%s: status:%d", __func__, wmi_event->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065 dual_mac_cfg_resp->status = wmi_event->status;
4066
4067 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004068 policy_mgr_update_dbs_scan_config(wma->psoc);
4069 policy_mgr_update_dbs_fw_config(wma->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 }
4071
4072 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304073 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 (void *) dual_mac_cfg_resp, 0);
4075
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304076 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077
4078fail:
4079 WMA_LOGE("%s: Sending fail response to LIM", __func__);
4080 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304081 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 (void *) dual_mac_cfg_resp, 0);
4083
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304084 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085
4086}
4087
4088/**
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304089 * wma_send_time_stamp_sync_cmd() - timer callback send timestamp to
4090 * firmware to sync with host.
4091 * @wma_handle: wma handle
4092 *
4093 * Return: void
4094 */
4095static void wma_send_time_stamp_sync_cmd(void *data)
4096{
4097 tp_wma_handle wma_handle;
4098 QDF_STATUS qdf_status;
4099
4100 wma_handle = (tp_wma_handle) data;
4101
4102 wmi_send_time_stamp_sync_cmd_tlv(wma_handle->wmi_handle);
4103
4104 /* Start/Restart the timer */
4105 qdf_status = qdf_mc_timer_start(&wma_handle->wma_fw_time_sync_timer,
4106 WMA_FW_TIME_SYNC_TIMER);
4107 if (QDF_IS_STATUS_ERROR(qdf_status))
4108 WMA_LOGE("Failed to start the firmware time sync timer");
4109}
4110
4111/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 * wma_start() - wma start function.
4113 * Intialize event handlers and timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304115 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 */
Jeff Johnsond4892552017-09-13 08:41:31 -07004117QDF_STATUS wma_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304119 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 tp_wma_handle wma_handle;
4121 int status;
Sandeep Puligilla063a4342018-01-10 02:50:14 -08004122 struct wmi_spectral_cmd_ops cmd_ops;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304123 struct wmi_unified *wmi_handle;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07004124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 WMA_LOGD("%s: Enter", __func__);
4126
Anurag Chouhan6d760662016-02-20 16:05:43 +05304127 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 /* validate the wma_handle */
4129 if (NULL == wma_handle) {
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304130 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304131 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 goto end;
4133 }
Sandeep Puligillad698bf52017-09-15 16:07:02 -07004134
Sourav Mohapatracf632572018-04-02 11:01:35 +05304135 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304136 if (!wmi_handle) {
4137 WMA_LOGE("%s: Invalid wmi handle", __func__);
4138 qdf_status = QDF_STATUS_E_INVAL;
4139 goto end;
4140 }
4141
4142 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304143 wmi_roam_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304144 wma_roam_event_callback,
Padma, Santhosh Kumar18169ce2017-03-02 18:04:02 +05304145 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004147 WMA_LOGE("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304148 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 goto end;
4150 }
4151
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304152 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304153 wmi_wow_wakeup_host_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304154 wma_wow_wakeup_host_event,
4155 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004157 WMA_LOGE("%s: Failed to register wow wakeup host event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304159 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 goto end;
4161 }
4162
Will Huang3cd2b7c2017-11-17 13:16:56 +08004163 if (wma_d0_wow_is_supported()) {
4164 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304165 wmi_handle,
Will Huang9adefff2017-12-15 14:50:03 +08004166 wmi_d0_wow_disable_ack_event_id,
Will Huang3cd2b7c2017-11-17 13:16:56 +08004167 wma_d0_wow_disable_ack_event,
4168 WMA_RX_TASKLET_CTX);
4169 if (status) {
4170 WMA_LOGE("%s: Failed to register d0wow disable ack"
4171 " event handler", __func__);
4172 qdf_status = QDF_STATUS_E_FAILURE;
4173 goto end;
4174 }
4175 }
4176
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304177 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304178 wmi_pdev_resume_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304179 wma_pdev_resume_event_handler,
4180 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004182 WMA_LOGE("%s: Failed to register PDEV resume event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304184 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 goto end;
4186 }
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05304187#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
4188 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004189 WMA_LOGD("MCC TX Pause Event Handler register");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304190 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304191 wmi_tx_pause_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304192 wma_mcc_vdev_tx_pause_evt_handler,
4193 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
4195
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
4197 WMA_LOGD("Registering auto shutdown handler");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304198 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304199 wmi_host_auto_shutdown_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304200 wma_auto_shutdown_event_handler,
4201 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202 if (status) {
4203 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304204 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205 goto end;
4206 }
4207#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304208 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304209 wmi_thermal_mgmt_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304210 wma_thermal_mgmt_evt_handler,
4211 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212 if (status) {
4213 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304214 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215 goto end;
4216 }
4217
Zhang Qian47e22ce2018-01-04 15:38:38 +08004218 status = wma_ocb_register_callbacks(wma_handle);
4219 if (!QDF_IS_STATUS_SUCCESS(status)) {
4220 WMA_LOGE("Failed to register OCB callbacks");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304221 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 goto end;
4223 }
4224
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304225 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226
4227#ifdef QCA_WIFI_FTM
4228 /*
4229 * Tx mgmt attach requires TXRX context which is not created
4230 * in FTM mode. So skip the TX mgmt attach.
4231 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304232 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233 goto end;
4234#endif /* QCA_WIFI_FTM */
4235
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304236 if (wmi_service_enabled(wmi_handle, wmi_service_rmc)) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004237
4238 WMA_LOGD("FW supports cesium network, registering event handlers");
4239
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004240 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304241 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304242 wmi_peer_info_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004243 wma_ibss_peer_info_event_handler,
4244 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004245 if (status) {
4246 WMA_LOGE("Failed to register ibss peer info event cb");
4247 qdf_status = QDF_STATUS_E_FAILURE;
4248 goto end;
4249 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004250 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304251 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304252 wmi_peer_tx_fail_cnt_thr_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004253 wma_fast_tx_fail_event_handler,
4254 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004255 if (status) {
4256 WMA_LOGE("Failed to register peer fast tx failure event cb");
4257 qdf_status = QDF_STATUS_E_FAILURE;
4258 goto end;
4259 }
4260 } else {
4261 WMA_LOGE("Target does not support cesium network");
4262 }
4263
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304264 qdf_status = wma_tx_attach(wma_handle);
4265 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004266 WMA_LOGE("%s: Failed to register tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 goto end;
4268 }
4269
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304270 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4271 /* Initialize firmware time stamp sync timer */
4272 qdf_status =
4273 qdf_mc_timer_init(&wma_handle->wma_fw_time_sync_timer,
4274 QDF_TIMER_TYPE_SW,
4275 wma_send_time_stamp_sync_cmd,
4276 wma_handle);
4277 if (QDF_IS_STATUS_ERROR(qdf_status))
4278 WMA_LOGE(FL("Failed to initialize firmware time stamp sync timer"));
4279 /* Start firmware time stamp sync timer */
4280 wma_send_time_stamp_sync_cmd(wma_handle);
4281 }
4282
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05304284 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304285 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 wma_log_completion_timeout,
4287 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304288 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 WMA_LOGE("Failed to initialize log completion timeout");
4290 goto end;
4291 }
4292
Jeff Johnson6136fb92017-03-30 15:21:49 -07004293 status = wma_fips_register_event_handlers(wma_handle);
4294 if (!QDF_IS_STATUS_SUCCESS(status)) {
4295 WMA_LOGE("Failed to register FIPS event handler");
4296 qdf_status = QDF_STATUS_E_FAILURE;
4297 goto end;
4298 }
4299
Jeff Johnsonf0e54b02017-12-18 15:22:25 -08004300 status = wma_sar_register_event_handlers(wma_handle);
4301 if (!QDF_IS_STATUS_SUCCESS(status)) {
4302 WMA_LOGE("Failed to register SAR event handlers");
4303 qdf_status = QDF_STATUS_E_FAILURE;
4304 goto end;
4305 }
4306
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 /* Initialize the get temperature event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304308 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304309 wmi_pdev_temperature_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304310 wma_pdev_temperature_evt_handler,
4311 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304312 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304314 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 goto end;
4316 }
4317
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304318 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304319 wmi_vdev_tsf_report_event_id,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004320 wma_vdev_tsf_handler,
4321 WMA_RX_SERIALIZER_CTX);
4322 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004323 WMA_LOGE("%s: Failed to register tsf callback", __func__);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004324 qdf_status = QDF_STATUS_E_FAILURE;
4325 goto end;
4326 }
4327
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304328 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304329 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304330 wmi_pdev_set_hw_mode_rsp_event_id,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304331 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304332 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304333 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304335 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 goto end;
4337 }
4338
4339 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304340 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304341 wmi_pdev_hw_mode_transition_event_id,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304342 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304343 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304344 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004345 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304346 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347 goto end;
4348 }
4349
4350 /* Initialize the set dual mac configuration event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304351 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304352 wmi_pdev_set_mac_config_resp_event_id,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304353 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304354 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304355 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304357 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004358 goto end;
4359 }
4360
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304361 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304362 wmi_coex_bt_activity_event_id,
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304363 wma_wlan_bt_activity_evt_handler,
4364 WMA_RX_SERIALIZER_CTX);
4365 if (!QDF_IS_STATUS_SUCCESS(status)) {
4366 WMA_LOGE("Failed to register coex bt activity event handler");
4367 qdf_status = QDF_STATUS_E_FAILURE;
4368 goto end;
4369 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05304370
Sandeep Puligilla063a4342018-01-10 02:50:14 -08004371 cmd_ops.wmi_spectral_configure_cmd_send =
4372 wmi_unified_vdev_spectral_configure_cmd_send;
4373 cmd_ops.wmi_spectral_enable_cmd_send =
4374 wmi_unified_vdev_spectral_enable_cmd_send;
4375 wlan_register_wmi_spectral_cmd_ops(wma_handle->pdev, &cmd_ops);
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377end:
4378 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304379 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380}
4381
4382/**
4383 * wma_stop() - wma stop function.
4384 * cleanup timers and suspend target.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385 * @reason: reason for wma_stop.
4386 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304387 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388 */
Jeff Johnsonacc1cc72017-09-13 08:47:49 -07004389QDF_STATUS wma_stop(uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390{
4391 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304392 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05304393 int i;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004394
Anurag Chouhan6d760662016-02-20 16:05:43 +05304395 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 WMA_LOGD("%s: Enter", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 /* validate the wma_handle */
4398 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004399 WMA_LOGE("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304400 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 goto end;
4402 }
4403#ifdef QCA_WIFI_FTM
4404 /*
4405 * Tx mgmt detach requires TXRX context which is not created
4406 * in FTM mode. So skip the TX mgmt detach.
4407 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304408 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304409 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 goto end;
4411 }
4412#endif /* QCA_WIFI_FTM */
4413
4414 if (wma_handle->ack_work_ctx) {
4415 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304416 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 wma_handle->ack_work_ctx = NULL;
4418 }
4419
4420 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05304421 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004422 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 WMA_LOGE("Failed to destroy the log completion timer");
Govind Singhede435f2015-12-01 16:16:36 +05304424 /* clean up ll-queue for all vdev */
4425 for (i = 0; i < wma_handle->max_bssid; i++) {
4426 if (wma_handle->interfaces[i].handle &&
Mukul Sharmaf9047232017-03-02 16:58:56 +05304427 wma_is_vdev_up(i)) {
Leo Chang96464902016-10-28 11:10:54 -07004428 cdp_fc_vdev_flush(
4429 cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08004430 wma_handle->
4431 interfaces[i].handle);
Govind Singhede435f2015-12-01 16:16:36 +05304432 }
4433 }
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304434
4435 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4436 /* Destroy firmware time stamp sync timer */
4437 qdf_status = qdf_mc_timer_destroy(
4438 &wma_handle->wma_fw_time_sync_timer);
4439 if (QDF_IS_STATUS_ERROR(qdf_status))
4440 WMA_LOGE(FL("Failed to destroy the fw time sync timer"));
4441 }
4442
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304443 qdf_status = wma_tx_detach(wma_handle);
4444 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004445 WMA_LOGE("%s: Failed to deregister tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 goto end;
4447 }
4448
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449end:
4450 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304451 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452}
4453
4454/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455 * wma_wmi_service_close() - close wma wmi service interface.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304457 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 */
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004459QDF_STATUS wma_wmi_service_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460{
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004461 void *cds_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462 tp_wma_handle wma_handle;
4463 struct beacon_info *bcn;
4464 int i;
4465
4466 WMA_LOGD("%s: Enter", __func__);
4467
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004468 cds_ctx = cds_get_global_context();
4469 if (!cds_ctx) {
4470 WMA_LOGE("%s: Invalid CDS context", __func__);
4471 return QDF_STATUS_E_INVAL;
4472 }
4473
Anurag Chouhan6d760662016-02-20 16:05:43 +05304474 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475
4476 /* validate the wma_handle */
4477 if (NULL == wma_handle) {
4478 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304479 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 }
4481
4482 /* validate the wmi handle */
4483 if (NULL == wma_handle->wmi_handle) {
4484 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304485 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 }
4487
4488 /* dettach the wmi serice */
4489 WMA_LOGD("calling wmi_unified_detach");
4490 wmi_unified_detach(wma_handle->wmi_handle);
4491 wma_handle->wmi_handle = NULL;
4492
4493 for (i = 0; i < wma_handle->max_bssid; i++) {
4494 bcn = wma_handle->interfaces[i].beacon;
4495
4496 if (bcn) {
4497 if (bcn->dma_mapped)
Nirav Shahcbc6d722016-03-01 16:24:53 +05304498 qdf_nbuf_unmap_single(wma_handle->qdf_dev,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304499 bcn->buf, QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +05304500 qdf_nbuf_free(bcn->buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304501 qdf_mem_free(bcn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 wma_handle->interfaces[i].beacon = NULL;
4503 }
4504
4505 if (wma_handle->interfaces[i].handle) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304506 qdf_mem_free(wma_handle->interfaces[i].handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507 wma_handle->interfaces[i].handle = NULL;
4508 }
Yue Ma664effc2016-01-12 18:43:54 -08004509
4510 if (wma_handle->interfaces[i].addBssStaContext) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304511 qdf_mem_free(wma_handle->
Yue Ma664effc2016-01-12 18:43:54 -08004512 interfaces[i].addBssStaContext);
4513 wma_handle->interfaces[i].addBssStaContext = NULL;
4514 }
4515
4516 if (wma_handle->interfaces[i].del_staself_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304517 qdf_mem_free(wma_handle->interfaces[i].del_staself_req);
Yue Ma664effc2016-01-12 18:43:54 -08004518 wma_handle->interfaces[i].del_staself_req = NULL;
4519 }
yeshwanth sriram guntuka8dd80382017-01-30 17:04:58 +05304520
4521 if (wma_handle->interfaces[i].stats_rsp) {
4522 qdf_mem_free(wma_handle->interfaces[i].stats_rsp);
4523 wma_handle->interfaces[i].stats_rsp = NULL;
4524 }
Abhishek Singh7e5e9342017-04-12 18:22:07 +05304525
4526 if (wma_handle->interfaces[i].psnr_req) {
4527 qdf_mem_free(wma_handle->
4528 interfaces[i].psnr_req);
4529 wma_handle->interfaces[i].psnr_req = NULL;
4530 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07004531
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05304532 if (wma_handle->interfaces[i].rcpi_req) {
4533 qdf_mem_free(wma_handle->
4534 interfaces[i].rcpi_req);
4535 wma_handle->interfaces[i].rcpi_req = NULL;
4536 }
4537
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05304538 if (wma_handle->interfaces[i].roam_synch_frame_ind.
4539 bcn_probe_rsp) {
4540 qdf_mem_free(wma_handle->interfaces[i].
4541 roam_synch_frame_ind.bcn_probe_rsp);
4542 wma_handle->interfaces[i].roam_synch_frame_ind.
4543 bcn_probe_rsp = NULL;
4544 }
4545
4546 if (wma_handle->interfaces[i].roam_synch_frame_ind.
4547 reassoc_req) {
4548 qdf_mem_free(wma_handle->interfaces[i].
4549 roam_synch_frame_ind.reassoc_req);
4550 wma_handle->interfaces[i].roam_synch_frame_ind.
4551 reassoc_req = NULL;
4552 }
4553
4554 if (wma_handle->interfaces[i].roam_synch_frame_ind.
4555 reassoc_rsp) {
4556 qdf_mem_free(wma_handle->interfaces[i].
4557 roam_synch_frame_ind.reassoc_rsp);
4558 wma_handle->interfaces[i].roam_synch_frame_ind.
4559 reassoc_rsp = NULL;
4560 }
4561
Dustin Brownec2c92e2017-07-26 11:13:49 -07004562 wma_vdev_deinit(&wma_handle->interfaces[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 }
4564
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304565 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07004566
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 /* free the wma_handle */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07004568 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304570 qdf_mem_free(((p_cds_contextType) cds_ctx)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304572 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573}
4574
Xun Luoa858a472015-11-10 08:24:45 -08004575/**
4576 * wma_wmi_work_close() - close the work queue items associated with WMI
Xun Luoa858a472015-11-10 08:24:45 -08004577 *
4578 * This function closes work queue items associated with WMI, but not fully
4579 * closes WMI service.
4580 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304581 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08004582 * proper error codes.
4583 */
Jeff Johnson6b8473d2017-09-13 09:20:53 -07004584QDF_STATUS wma_wmi_work_close(void)
Xun Luoa858a472015-11-10 08:24:45 -08004585{
4586 tp_wma_handle wma_handle;
4587
4588 WMA_LOGD("%s: Enter", __func__);
4589
Anurag Chouhan6d760662016-02-20 16:05:43 +05304590 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08004591
4592 /* validate the wma_handle */
4593 if (NULL == wma_handle) {
4594 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304595 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004596 }
4597
4598 /* validate the wmi handle */
4599 if (NULL == wma_handle->wmi_handle) {
4600 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304601 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004602 }
4603
4604 /* remove the wmi work */
4605 WMA_LOGD("calling wmi_unified_remove_work");
4606 wmi_unified_remove_work(wma_handle->wmi_handle);
4607
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304608 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08004609}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610
Krunal Soni2e48d012016-05-02 16:55:26 -07004611/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 * wma_close() - wma close function.
4613 * cleanup resources attached with wma.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304615 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616 */
Jeff Johnson542da352017-09-13 09:17:28 -07004617QDF_STATUS wma_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618{
4619 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304620 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621
4622 WMA_LOGD("%s: Enter", __func__);
4623
Anurag Chouhan6d760662016-02-20 16:05:43 +05304624 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625
4626 /* validate the wma_handle */
4627 if (NULL == wma_handle) {
4628 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304629 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 }
4631
4632 /* validate the wmi handle */
4633 if (NULL == wma_handle->wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004634 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304635 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 }
4637
4638 /* Free DBS list */
4639 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304640 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004642 WMA_LOGD("%s: DBS list is freed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05304644
Anurag Chouhan6d760662016-02-20 16:05:43 +05304645 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304647 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304649 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05304650 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
4651 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
4652 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
4653 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
4654 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
4655 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
4656 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 }
4658
4659 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304660 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
4661 if (qdf_status != QDF_STATUS_SUCCESS)
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004662 WMA_LOGE("%s: dbglog_deinit failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663
Anurag Chouhan210db072016-02-22 18:42:15 +05304664 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304665 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004666 WMA_LOGE("%s: Failed to destroy service ready ext event timer",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304667 __func__);
4668
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304669 qdf_event_destroy(&wma_handle->target_suspend);
4670 qdf_event_destroy(&wma_handle->wma_resume_event);
4671 qdf_event_destroy(&wma_handle->runtime_suspend);
4672 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08004673 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
4674 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08004675 wma_cleanup_vdev_resp_queue(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304677 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08004678 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Poddar, Siddarth2fb98072017-07-19 14:58:30 +05304679 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
4680 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304683 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 wma_handle->pGetRssiReq = NULL;
4685 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07004686
yeshwanth sriram guntuka584c2332017-07-29 12:50:25 +05304687 wma_unified_radio_tx_mem_free(wma_handle);
Srinivas Girigowdaad874a82016-10-25 14:08:00 -07004688
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -07004689 if (wma_handle->pdev) {
4690 wlan_objmgr_pdev_release_ref(wma_handle->pdev,
4691 WLAN_LEGACY_WMA_ID);
4692 wma_handle->pdev = NULL;
4693 }
Frank Liu00d73fe2017-05-19 22:11:28 +08004694
Mukul Sharma6411bb82017-03-01 15:57:07 +05304695 pmo_unregister_pause_bitmap_notifier(wma_handle->psoc,
4696 wma_vdev_update_pause_bitmap);
4697 pmo_unregister_get_pause_bitmap(wma_handle->psoc,
4698 wma_vdev_get_pause_bitmap);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05304699 pmo_unregister_is_device_in_low_pwr_mode(wma_handle->psoc,
4700 wma_vdev_is_device_in_low_pwr_mode);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304701
Arunk Khandavallia6305a32018-01-25 11:19:18 +05304702 target_if_free_psoc_tgt_info(wma_handle->psoc);
4703
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05304704 wlan_objmgr_psoc_release_ref(wma_handle->psoc, WLAN_LEGACY_WMA_ID);
4705 wma_handle->psoc = NULL;
4706 target_if_close();
4707 wma_target_if_close(wma_handle);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304710 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711}
4712
4713/**
4714 * wma_update_fw_config() - update fw configuration
Dustin Brownb9987af2018-03-01 17:15:11 -08004715 * @psoc: psoc to query configuration from
4716 * @tgt_hdl: target capability info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 *
4718 * Return: none
4719 */
Dustin Brownb9987af2018-03-01 17:15:11 -08004720static void wma_update_fw_config(struct wlan_objmgr_psoc *psoc,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304721 struct target_psoc_info *tgt_hdl)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722{
Dustin Brownb9987af2018-03-01 17:15:11 -08004723 target_resource_config *cfg = &tgt_hdl->info.wlan_res_cfg;
4724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725 /* Override the no. of max fragments as per platform configuration */
Dustin Brownb9987af2018-03-01 17:15:11 -08004726 cfg->max_frag_entries = QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304727 target_if_get_max_frag_entry(tgt_hdl));
Dustin Brownb9987af2018-03-01 17:15:11 -08004728 target_if_set_max_frag_entry(tgt_hdl, cfg->max_frag_entries);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304729
Dustin Brownb9987af2018-03-01 17:15:11 -08004730 cfg->num_wow_filters = ucfg_pmo_get_num_wow_filters(psoc);
4731 cfg->bpf_instruction_size = ucfg_pmo_get_apf_instruction_size(psoc);
Dustin Brown67d69eb2018-03-02 11:11:34 -08004732 cfg->num_packet_filters = ucfg_pmo_get_num_packet_filters(psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733}
4734
4735/**
Yun Parkb4f591d2017-03-29 15:51:01 -07004736 * wma_set_tx_partition_base() - set TX MSDU ID partition base for IPA
4737 * @value: TX MSDU ID partition base
4738 *
4739 * Return: none
4740 */
4741#ifdef IPA_OFFLOAD
4742static void wma_set_tx_partition_base(uint32_t value)
4743{
4744 cdp_ipa_set_uc_tx_partition_base(
4745 cds_get_context(QDF_MODULE_ID_SOC),
4746 (struct cdp_cfg *)cds_get_context(QDF_MODULE_ID_CFG),
4747 value);
4748 WMA_LOGD("%s: TX_MSDU_ID_PARTITION=%d", __func__,
4749 value);
4750}
4751#else
4752static void wma_set_tx_partition_base(uint32_t value)
4753{
4754}
4755#endif
4756
4757/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758 * wma_update_target_services() - update target services from wma handle
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304759 * @wmi_handle: Unified wmi handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 * @cfg: target services
4761 *
4762 * Return: none
4763 */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304764static inline void wma_update_target_services(struct wmi_unified *wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004765 struct wma_tgt_services *cfg)
4766{
4767 /* STA power save */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304768 cfg->sta_power_save = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304769 wmi_service_sta_pwrsave);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770
4771 /* Enable UAPSD */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304772 cfg->uapsd = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304773 wmi_service_ap_uapsd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004774
4775 /* Update AP DFS service */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304776 cfg->ap_dfs = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304777 wmi_service_ap_dfs);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004778
4779 /* Enable 11AC */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304780 cfg->en_11ac = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304781 wmi_service_11ac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782 if (cfg->en_11ac)
4783 g_fw_wlan_feat_caps |= (1 << DOT11AC);
4784
4785 /* Proactive ARP response */
4786 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
4787
4788 /* Enable WOW */
4789 g_fw_wlan_feat_caps |= (1 << WOW);
4790
4791 /* ARP offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304792 cfg->arp_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304793 wmi_service_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794
4795 /* Adaptive early-rx */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304796 cfg->early_rx = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304797 wmi_service_early_rx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798#ifdef FEATURE_WLAN_SCAN_PNO
4799 /* PNO offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304800 if (wmi_service_enabled(wmi_handle, wmi_service_nlo))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004801 cfg->pno_offload = true;
4802#endif /* FEATURE_WLAN_SCAN_PNO */
4803
4804#ifdef FEATURE_WLAN_EXTSCAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304805 if (wmi_service_enabled(wmi_handle, wmi_service_extscan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807#endif /* FEATURE_WLAN_EXTSCAN */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304808 cfg->lte_coex_ant_share = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304809 wmi_service_lte_ant_share_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810#ifdef FEATURE_WLAN_TDLS
4811 /* Enable TDLS */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304812 if (wmi_service_enabled(wmi_handle, wmi_service_tdls)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004813 cfg->en_tdls = 1;
4814 g_fw_wlan_feat_caps |= (1 << TDLS);
4815 }
4816 /* Enable advanced TDLS features */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304817 if (wmi_service_enabled(wmi_handle, wmi_service_tdls_offchan)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004818 cfg->en_tdls_offchan = 1;
4819 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
4820 }
4821
4822 cfg->en_tdls_uapsd_buf_sta =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304823 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304824 wmi_service_tdls_uapsd_buffer_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825 cfg->en_tdls_uapsd_sleep_sta =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304826 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304827 wmi_service_tdls_uapsd_sleep_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828#endif /* FEATURE_WLAN_TDLS */
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304829 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304830 (wmi_handle, wmi_service_beacon_offload))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 cfg->beacon_offload = true;
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304832 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304833 (wmi_handle, wmi_service_sta_pmf_offload))
mukul sharma72c8b222015-09-04 17:02:01 +05304834 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4836 /* Enable Roam Offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304837 cfg->en_roam_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304838 wmi_service_roam_ho_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4840#ifdef WLAN_FEATURE_NAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304841 if (wmi_service_enabled(wmi_handle, wmi_service_nan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 g_fw_wlan_feat_caps |= (1 << NAN);
4843#endif /* WLAN_FEATURE_NAN */
4844
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304845 if (wmi_service_enabled(wmi_handle, wmi_service_rtt))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07004847
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304848 if (wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304849 wmi_service_tx_msdu_id_new_partition_support)) {
Yun Parkb4f591d2017-03-29 15:51:01 -07004850 wma_set_tx_partition_base(HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004851 } else {
Yun Parkb4f591d2017-03-29 15:51:01 -07004852 wma_set_tx_partition_base(HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004853 }
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004854
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304855 wma_he_update_tgt_services(wmi_handle, cfg);
Will Huang496b36c2017-07-11 16:38:50 +08004856
4857 cfg->get_peer_info_enabled =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304858 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304859 wmi_service_peer_stats_info);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304860 if (wmi_service_enabled(wmi_handle, wmi_service_fils_support))
Vignesh Viswanathan731186f2017-09-18 13:47:37 +05304861 cfg->is_fils_roaming_supported = true;
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004862
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304863 if (wmi_service_enabled(wmi_handle, wmi_service_mawc_support))
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004864 cfg->is_fw_mawc_capable = true;
4865
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304866 if (wmi_service_enabled(wmi_handle,
4867 wmi_service_11k_neighbour_report_support))
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304868 cfg->is_11k_offload_supported = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869}
4870
4871/**
4872 * wma_update_target_ht_cap() - update ht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304873 * @tgt_hdl: pointer to structure target_psoc_info
4874 * @cfg: ht capability
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004875 *
4876 * Return: none
4877 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304878static inline void
4879wma_update_target_ht_cap(struct target_psoc_info *tgt_hdl,
4880 struct wma_tgt_ht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304882 int ht_cap_info;
4883
4884 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 /* RX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304886 cfg->ht_rx_stbc = !!(ht_cap_info & WMI_HT_CAP_RX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004887
4888 /* TX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304889 cfg->ht_tx_stbc = !!(ht_cap_info & WMI_HT_CAP_TX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890
4891 /* MPDU density */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304892 cfg->mpdu_density = ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893
4894 /* HT RX LDPC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304895 cfg->ht_rx_ldpc = !!(ht_cap_info & WMI_HT_CAP_LDPC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896
4897 /* HT SGI */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304898 cfg->ht_sgi_20 = !!(ht_cap_info & WMI_HT_CAP_HT20_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004899
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304900 cfg->ht_sgi_40 = !!(ht_cap_info & WMI_HT_CAP_HT40_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901
4902 /* RF chains */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304903 cfg->num_rf_chains = target_if_get_num_rf_chains(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904
Jeff Johnson3fd21822016-11-08 11:30:37 -08004905 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n"
4906 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304907 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
4908 ht_cap_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
4910 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
4911 cfg->num_rf_chains);
4912
4913}
4914
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004915/**
4916 * wma_update_target_vht_cap() - update vht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304917 * @tgt_hdl: pointer to structure target_psoc_info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 * @cfg: vht capabality
4919 *
4920 * Return: none
4921 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304922static inline void
4923wma_update_target_vht_cap(struct target_psoc_info *tgt_hdl,
4924 struct wma_tgt_vht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304926 int vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304928 if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304930 else if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4932 else
4933 cfg->vht_max_mpdu = 0;
4934
4935
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304936 if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4938 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304939 } else if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304941 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304943 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304945 cfg->vht_rx_ldpc = vht_cap_info & WMI_VHT_CAP_RX_LDPC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304947 cfg->vht_short_gi_80 = vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
4948 cfg->vht_short_gi_160 = vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304950 cfg->vht_tx_stbc = vht_cap_info & WMI_VHT_CAP_TX_STBC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304952 cfg->vht_rx_stbc =
4953 (vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
4954 (vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
4955 (vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304957 cfg->vht_max_ampdu_len_exp = (vht_cap_info &
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
4959 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4960
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304961 cfg->vht_su_bformer = vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304963 cfg->vht_su_bformee = vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004964
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304965 cfg->vht_mu_bformer = vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304967 cfg->vht_mu_bformee = vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304969 cfg->vht_txop_ps = vht_cap_info & WMI_VHT_CAP_TXOP_PS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970
Jeff Johnson3fd21822016-11-08 11:30:37 -08004971 WMA_LOGD("%s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
4972 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
4973 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
4975 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
4976 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
4977 cfg->vht_max_ampdu_len_exp);
4978}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979
4980/**
Krunal Sonica50b452017-08-04 22:24:59 -07004981 * wma_update_supported_bands() - update supported bands from service ready ext
Krunal Sonica50b452017-08-04 22:24:59 -07004982 * @supported_bands: Supported band given by FW through service ready ext params
4983 * @new_supported_bands: New supported band which needs to be updated by
4984 * this API which WMA layer understands
4985 *
4986 * This API will convert FW given supported band to enum which WMA layer
4987 * understands
4988 *
4989 * Return: QDF_STATUS
4990 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05304991static QDF_STATUS wma_update_supported_bands(
Krunal Sonica50b452017-08-04 22:24:59 -07004992 WLAN_BAND_CAPABILITY supported_bands,
4993 WMI_PHY_CAPABILITY *new_supported_bands)
4994{
4995 QDF_STATUS status = QDF_STATUS_SUCCESS;
4996
Krunal Sonica50b452017-08-04 22:24:59 -07004997 if (!new_supported_bands) {
4998 WMA_LOGE("%s: NULL new supported band variable", __func__);
4999 return QDF_STATUS_E_FAILURE;
5000 }
5001 switch (supported_bands) {
5002 case WLAN_2G_CAPABILITY:
5003 *new_supported_bands |= WMI_11G_CAPABILITY;
5004 break;
5005 case WLAN_5G_CAPABILITY:
5006 *new_supported_bands |= WMI_11A_CAPABILITY;
5007 break;
5008 default:
5009 WMA_LOGE("%s: wrong supported band", __func__);
5010 status = QDF_STATUS_E_FAILURE;
5011 break;
5012 }
5013 return status;
5014}
5015
5016/**
Krunal Soniaa664da2016-06-15 23:46:40 -07005017 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005018 * @ht_cap: given pointer to HT caps which needs to be updated
5019 * @tx_chain: given tx chainmask value
5020 * @rx_chain: given rx chainmask value
5021 * @value: new HT cap info provided in form of bitmask
5022 *
5023 * This function takes the value provided in form of bitmask and decodes
5024 * it. After decoding, what ever value it gets, it takes the union(max) or
5025 * intersection(min) with previously derived values.
5026 *
5027 * Return: none
5028 *
5029 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305030static void wma_derive_ext_ht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005031 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
5032 uint32_t tx_chain, uint32_t rx_chain)
5033{
5034 struct wma_tgt_ht_cap tmp = {0};
5035
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305036 if (ht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005037 return;
5038
Ankit Guptaa5076012016-09-14 11:32:19 -07005039 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07005040 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
5041 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
5042 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
5043 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
5044 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
5045 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
5046 ht_cap->num_rf_chains =
5047 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
5048 wma_get_num_of_setbits_from_bitmask(rx_chain));
5049 } else {
5050 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
5051 (!!(value & WMI_HT_CAP_RX_STBC)));
5052 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
5053 (!!(value & WMI_HT_CAP_TX_STBC)));
5054 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
5055 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
5056 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
5057 (!!(value & WMI_HT_CAP_RX_LDPC)));
5058 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
5059 (!!(value & WMI_HT_CAP_HT20_SGI)));
5060 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
5061 (!!(value & WMI_HT_CAP_HT40_SGI)));
5062 ht_cap->num_rf_chains =
5063 QDF_MAX(ht_cap->num_rf_chains,
5064 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
5065 tx_chain),
5066 wma_get_num_of_setbits_from_bitmask(
5067 rx_chain)));
5068 }
5069}
5070
5071/**
5072 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305073 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005074 * @ht_cap: HT cap structure to be filled
5075 *
5076 * This function loop through each hardware mode and for each hardware mode
5077 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5078 * HT caps and derives the final cap.
5079 *
5080 * Return: none
5081 *
5082 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305083static void wma_update_target_ext_ht_cap(struct target_psoc_info *tgt_hdl,
5084 struct wma_tgt_ht_cap *ht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005085{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005086 int i, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005087 uint32_t ht_2g, ht_5g;
5088 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305089 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5090 int num_hw_modes;
Krunal Soniaa664da2016-06-15 23:46:40 -07005091
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005092 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305093 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5094 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005095 /*
5096 * for legacy device extended cap might not even come, so in that case
5097 * don't overwrite legacy values
5098 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305099 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005100 WMA_LOGD("%s: No extended HT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005101 return;
5102 }
5103
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005104 for (i = 0; i < total_mac_phy_cnt; i++) {
5105 ht_2g = mac_phy_cap[i].ht_cap_info_2G;
5106 ht_5g = mac_phy_cap[i].ht_cap_info_5G;
5107 if (ht_2g)
5108 wma_derive_ext_ht_cap(&tmp_ht_cap,
5109 ht_2g,
5110 mac_phy_cap[i].tx_chain_mask_2G,
5111 mac_phy_cap[i].rx_chain_mask_2G);
5112 if (ht_5g)
5113 wma_derive_ext_ht_cap(&tmp_ht_cap,
5114 ht_5g,
5115 mac_phy_cap[i].tx_chain_mask_5G,
5116 mac_phy_cap[i].rx_chain_mask_5G);
Krunal Soniaa664da2016-06-15 23:46:40 -07005117 }
5118
Ankit Guptaa5076012016-09-14 11:32:19 -07005119 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005120 sizeof(struct wma_tgt_ht_cap))) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005121 qdf_mem_copy(ht_cap, &tmp_ht_cap,
5122 sizeof(struct wma_tgt_ht_cap));
Krunal Soniaa664da2016-06-15 23:46:40 -07005123 }
5124
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005125 WMA_LOGD("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005126 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
5127 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005128 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
5129 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
5130 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
5131 ht_cap->num_rf_chains);
5132}
5133
5134/**
5135 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005136 * @vht_cap: pointer to given VHT caps to be filled
5137 * @value: new VHT cap info provided in form of bitmask
5138 *
5139 * This function takes the value provided in form of bitmask and decodes
5140 * it. After decoding, what ever value it gets, it takes the union(max) or
5141 * intersection(min) with previously derived values.
5142 *
5143 * Return: none
5144 *
5145 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305146static void wma_derive_ext_vht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005147 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
5148{
5149 struct wma_tgt_vht_cap tmp_cap = {0};
5150 uint32_t tmp = 0;
5151
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305152 if (vht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005153 return;
5154
Ankit Guptaa5076012016-09-14 11:32:19 -07005155 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005156 sizeof(struct wma_tgt_vht_cap))) {
5157 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5158 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5159 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5160 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5161 else
5162 vht_cap->vht_max_mpdu = 0;
5163
5164 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
5165 vht_cap->supp_chan_width =
5166 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
5167 vht_cap->supp_chan_width |=
5168 1 << eHT_CHANNEL_WIDTH_160MHZ;
5169 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5170 vht_cap->supp_chan_width =
5171 1 << eHT_CHANNEL_WIDTH_160MHZ;
5172 } else {
5173 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5174 }
5175 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
5176 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
5177 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
5178 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
5179 vht_cap->vht_rx_stbc =
5180 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5181 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5182 (value & WMI_VHT_CAP_RX_STBC_3SS);
5183 vht_cap->vht_max_ampdu_len_exp =
5184 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5185 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
5186 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
5187 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
5188 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
5189 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
5190 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
5191 } else {
5192 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5193 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5194 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5195 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5196 else
5197 tmp = 0;
5198 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
5199
5200 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
5201 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
5202 (1 << eHT_CHANNEL_WIDTH_160MHZ);
5203 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5204 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
5205 } else {
5206 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5207 }
5208 vht_cap->supp_chan_width =
5209 QDF_MAX(vht_cap->supp_chan_width, tmp);
5210 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
5211 value & WMI_VHT_CAP_RX_LDPC);
5212 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
5213 value & WMI_VHT_CAP_SGI_80MHZ);
5214 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
5215 value & WMI_VHT_CAP_SGI_160MHZ);
5216 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
5217 value & WMI_VHT_CAP_TX_STBC);
5218 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
5219 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5220 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5221 (value & WMI_VHT_CAP_RX_STBC_3SS));
5222 vht_cap->vht_max_ampdu_len_exp =
5223 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
5224 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5225 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
5226 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
5227 value & WMI_VHT_CAP_SU_BFORMER);
5228 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
5229 value & WMI_VHT_CAP_SU_BFORMEE);
5230 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
5231 value & WMI_VHT_CAP_MU_BFORMER);
5232 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
5233 value & WMI_VHT_CAP_MU_BFORMEE);
5234 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
5235 value & WMI_VHT_CAP_TXOP_PS);
5236 }
5237}
5238
5239/**
5240 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305241 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005242 * @vht_cap: VHT cap structure to be filled
5243 *
5244 * This function loop through each hardware mode and for each hardware mode
5245 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5246 * VHT caps and derives the final cap.
5247 *
5248 * Return: none
5249 *
5250 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305251static void wma_update_target_ext_vht_cap(struct target_psoc_info *tgt_hdl,
5252 struct wma_tgt_vht_cap *vht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005253{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005254 int i, num_hw_modes, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005255 uint32_t vht_cap_info_2g, vht_cap_info_5g;
5256 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305257 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5258
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005259 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305260 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5261 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005262
5263 /*
5264 * for legacy device extended cap might not even come, so in that case
5265 * don't overwrite legacy values
5266 */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005267 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005268 WMA_LOGD("%s: No extended VHT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005269 return;
5270 }
5271
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005272 for (i = 0; i < total_mac_phy_cnt; i++) {
5273 vht_cap_info_2g = mac_phy_cap[i].vht_cap_info_2G;
5274 vht_cap_info_5g = mac_phy_cap[i].vht_cap_info_5G;
5275 if (vht_cap_info_2g)
5276 wma_derive_ext_vht_cap(&tmp_vht_cap,
5277 vht_cap_info_2g);
5278 if (vht_cap_info_5g)
5279 wma_derive_ext_vht_cap(&tmp_vht_cap,
5280 vht_cap_info_5g);
Krunal Soniaa664da2016-06-15 23:46:40 -07005281 }
5282
Ankit Guptaa5076012016-09-14 11:32:19 -07005283 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005284 sizeof(struct wma_tgt_vht_cap))) {
5285 qdf_mem_copy(vht_cap, &tmp_vht_cap,
5286 sizeof(struct wma_tgt_vht_cap));
5287 }
5288
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005289 WMA_LOGD("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005290 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
5291 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005292 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
5293 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
5294 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
5295 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
5296 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
5297}
5298
5299/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305300 * wma_update_ra_rate_limit() - update wma config
5301 * @wma_handle: wma handle
5302 * @cfg: target config
5303 *
5304 * Return: none
5305 */
5306#ifdef FEATURE_WLAN_RA_FILTERING
5307static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5308 struct wma_tgt_cfg *cfg)
5309{
5310 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
5311}
5312#else
5313static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5314 struct wma_tgt_cfg *cfg)
5315{
5316}
5317#endif
5318
5319/**
Krunal Sonica50b452017-08-04 22:24:59 -07005320 * wma_update_hdd_band_cap() - update band cap which hdd understands
5321 * @supported_band: supported band which has been given by FW
5322 * @tgt_cfg: target configuration to be updated
5323 *
5324 * Convert WMA given supported band to enum which HDD understands
5325 *
5326 * Return: None
5327 */
5328static void wma_update_hdd_band_cap(WMI_PHY_CAPABILITY supported_band,
5329 struct wma_tgt_cfg *tgt_cfg)
5330{
5331 switch (supported_band) {
5332 case WMI_11G_CAPABILITY:
5333 case WMI_11NG_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005334 tgt_cfg->band_cap = BAND_2G;
Krunal Sonica50b452017-08-04 22:24:59 -07005335 break;
5336 case WMI_11A_CAPABILITY:
5337 case WMI_11NA_CAPABILITY:
5338 case WMI_11AC_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005339 tgt_cfg->band_cap = BAND_5G;
Krunal Sonica50b452017-08-04 22:24:59 -07005340 break;
5341 case WMI_11AG_CAPABILITY:
5342 case WMI_11NAG_CAPABILITY:
5343 default:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005344 tgt_cfg->band_cap = BAND_ALL;
Krunal Sonica50b452017-08-04 22:24:59 -07005345 }
5346}
5347
5348/**
Arif Hussainee10f902017-12-27 16:30:17 -08005349 * wma_update_obss_detection_support() - update obss detection offload support
5350 * @wh: wma handle
5351 * @tgt_cfg: target configuration to be updated
5352 *
5353 * Update obss detection offload support based on service bit.
5354 *
5355 * Return: None
5356 */
5357static void wma_update_obss_detection_support(tp_wma_handle wh,
5358 struct wma_tgt_cfg *tgt_cfg)
5359{
Arif Hussain05fb4872018-01-03 16:02:55 -08005360 if (wmi_service_enabled(wh->wmi_handle,
5361 wmi_service_ap_obss_detection_offload))
Arif Hussainee10f902017-12-27 16:30:17 -08005362 tgt_cfg->obss_detection_offloaded = true;
5363 else
5364 tgt_cfg->obss_detection_offloaded = false;
5365}
5366
5367/**
Arif Hussain05fb4872018-01-03 16:02:55 -08005368 * wma_update_obss_color_collision_support() - update obss color collision
5369 * offload support
5370 * @wh: wma handle
5371 * @tgt_cfg: target configuration to be updated
5372 *
5373 * Update obss color collision offload support based on service bit.
5374 *
5375 * Return: None
5376 */
5377static void wma_update_obss_color_collision_support(tp_wma_handle wh,
5378 struct wma_tgt_cfg *tgt_cfg)
5379{
5380 if (wmi_service_enabled(wh->wmi_handle, wmi_service_bss_color_offload))
5381 tgt_cfg->obss_color_collision_offloaded = true;
5382 else
5383 tgt_cfg->obss_color_collision_offloaded = false;
5384}
5385
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005386#ifdef WLAN_SUPPORT_GREEN_AP
5387static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5388{
5389 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5390 WMI_SERVICE_EGAP))
5391 target_if_green_ap_register_egap_event_handler(
5392 wma_handle->pdev);
5393
5394}
5395#else
5396static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5397{
5398}
5399#endif
5400
Arif Hussain05fb4872018-01-03 16:02:55 -08005401/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 * wma_update_hdd_cfg() - update HDD config
5403 * @wma_handle: wma handle
5404 *
5405 * Return: none
5406 */
5407static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
5408{
5409 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05305410 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305411 target_resource_config *wlan_res_cfg;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305412 struct wlan_psoc_host_service_ext_param *service_ext_param;
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305413 struct target_psoc_info *tgt_hdl;
5414 struct wmi_unified *wmi_handle;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305415
5416 WMA_LOGD("%s: Enter", __func__);
5417
5418 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5419 if (!tgt_hdl) {
5420 WMA_LOGE("%s: target psoc info is NULL", __func__);
5421 return;
5422 }
5423
5424 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
Arif Hussaind15902c2018-03-02 00:08:29 -08005425 if (!wlan_res_cfg) {
5426 WMA_LOGE("%s: wlan_res_cfg is null", __func__);
5427 return;
5428 }
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305429 service_ext_param =
5430 target_psoc_get_service_ext_param(tgt_hdl);
Sourav Mohapatracf632572018-04-02 11:01:35 +05305431 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305432 if (!wmi_handle) {
5433 WMA_LOGE("%s: wmi handle is NULL", __func__);
5434 return;
5435 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005436
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305437 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07005438
5439 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
5441 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
5442
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305443 tgt_cfg.max_intf_count = wlan_res_cfg->num_vdevs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005444
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305445 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005446 ATH_MAC_LEN);
5447
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305448 wma_update_target_services(wmi_handle, &tgt_cfg.services);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305449 wma_update_target_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5450 wma_update_target_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07005451 /*
5452 * This will overwrite the structure filled by wma_update_target_ht_cap
5453 * and wma_update_target_vht_cap APIs.
5454 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305455 wma_update_target_ext_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5456 wma_update_target_ext_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305458 wma_update_target_ext_he_cap(tgt_hdl, &tgt_cfg);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005459
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305460 tgt_cfg.target_fw_version = target_if_get_fw_version(tgt_hdl);
5461 if (service_ext_param)
5462 tgt_cfg.target_fw_vers_ext =
5463 service_ext_param->fw_build_vers_ext;
5464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465#ifdef WLAN_FEATURE_LPSS
5466 tgt_cfg.lpss_support = wma_handle->lpss_support;
5467#endif /* WLAN_FEATURE_LPSS */
5468 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Rajeev Kumare5a16822016-07-27 13:11:42 -07005469 tgt_cfg.bpf_enabled = wma_handle->bpf_enabled;
Arif Hussaind54b62c2018-03-01 13:31:37 -08005470 tgt_cfg.dfs_cac_offload = wma_handle->is_dfs_offloaded;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305471 tgt_cfg.rcpi_enabled = wma_handle->rcpi_enabled;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305472 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05305473 wma_update_hdd_band_cap(target_if_get_phy_capability(tgt_hdl),
5474 &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08005475 tgt_cfg.fine_time_measurement_cap =
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305476 target_if_get_wmi_fw_sub_feat_caps(tgt_hdl);
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05305477 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
5478 - WMI_TLV_HEADROOM;
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05305479 tgt_cfg.tx_bfee_8ss_enabled = wma_handle->tx_bfee_8ss_enabled;
Arif Hussainee10f902017-12-27 16:30:17 -08005480 wma_update_obss_detection_support(wma_handle, &tgt_cfg);
Arif Hussain05fb4872018-01-03 16:02:55 -08005481 wma_update_obss_color_collision_support(wma_handle, &tgt_cfg);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07005482 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07005483 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Himanshu Agarwal2228e072018-01-24 17:42:17 +05305484 target_if_store_pdev_target_if_ctx(wma_get_pdev_from_scn_handle);
Nachiket Kukade7dda8c22018-03-12 19:59:43 +05305485 target_pdev_set_wmi_handle(wma_handle->pdev->tgt_if_handle,
5486 wma_handle->wmi_handle);
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005487 wma_green_ap_register_handlers(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488}
5489
5490/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
5492 * @wma_handle: WMA handle
5493 *
5494 * Prints the DBS HW modes sent by the FW as part
5495 * of WMI ready event
5496 *
5497 * Return: None
5498 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005499static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500{
5501 uint32_t i, param;
5502
5503 if (!wma_handle) {
5504 WMA_LOGE("%s: Invalid WMA handle", __func__);
5505 return;
5506 }
5507
5508 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5509 param = wma_handle->hw_mode.hw_mode_list[i];
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005510 WMA_LOGD("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005511 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305512 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
5513 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
5514 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005515 WMA_LOGD("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305517 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
5518 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
5519 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005520 WMA_LOGD("%s:[%d] DBS:%d SBS:%d", __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305521 WMA_HW_MODE_DBS_MODE_GET(param),
5522 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005523 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005524 policy_mgr_dump_dbs_hw_mode(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005525}
5526
5527/**
5528 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305529 * @psoc: Object manager psoc
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305530 * @scan_config: Scam mode configuration
5531 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005532 *
5533 * Enables all the valid bits of concurrent_scan_config_bits and
5534 * fw_mode_config_bits.
5535 *
5536 * Return: None
5537 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305538static void wma_init_scan_fw_mode_config(struct wlan_objmgr_psoc *psoc,
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005539 uint32_t scan_config,
5540 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542 WMA_LOGD("%s: Enter", __func__);
5543
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305544 if (!psoc) {
5545 WMA_LOGE("%s: obj psoc is NULL", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546 return;
5547 }
5548
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305549 policy_mgr_init_dbs_config(psoc, scan_config, fw_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550}
5551
5552/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305553 * wma_update_ra_limit() - update ra limit based on bpf filter
5554 * enabled or not
5555 * @handle: wma handle
5556 *
5557 * Return: none
5558 */
5559#ifdef FEATURE_WLAN_RA_FILTERING
5560static void wma_update_ra_limit(tp_wma_handle wma_handle)
5561{
5562 if (wma_handle->bpf_enabled)
5563 wma_handle->IsRArateLimitEnabled = false;
5564}
5565#else
5566static void wma_update_ra__limit(tp_wma_handle handle)
5567{
5568}
5569#endif
5570
Dustin Brown06259e52018-02-28 16:00:02 -08005571static void wma_set_pmo_caps(struct wlan_objmgr_psoc *psoc)
5572{
5573 QDF_STATUS status;
5574 struct pmo_device_caps caps;
5575
5576 caps.arp_ns_offload =
5577 wma_is_service_enabled(wmi_service_arpns_offload);
5578 caps.apf =
5579 wma_is_service_enabled(wmi_service_bpf_offload);
5580 caps.packet_filter =
5581 wma_is_service_enabled(wmi_service_packet_filter_offload);
5582 caps.unified_wow =
5583 wma_is_service_enabled(wmi_service_unified_wow_capability);
5584
5585 status = ucfg_pmo_psoc_set_caps(psoc, &caps);
5586 if (QDF_IS_STATUS_ERROR(status))
5587 WMA_LOGE("Failed to set PMO capabilities; status:%d", status);
5588}
5589
5590static void wma_set_component_caps(struct wlan_objmgr_psoc *psoc)
5591{
5592 wma_set_pmo_caps(psoc);
5593}
5594
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305595/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 * wma_rx_service_ready_event() - event handler to process
5597 * wmi rx sevice ready event.
5598 * @handle: wma handle
5599 * @cmd_param_info: command params info
5600 *
5601 * Return: none
5602 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305603int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005604 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
5608 wmi_service_ready_event_fixed_param *ev;
Dustin Brown7678b6c2018-03-07 13:00:52 -08005609 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610 uint32_t *ev_wlan_dbs_hw_mode_list;
Leo Chang96464902016-10-28 11:10:54 -07005611 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305612 struct target_psoc_info *tgt_hdl;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305613 struct wlan_psoc_target_capability_info *tgt_cap_info;
5614 target_resource_config *wlan_res_cfg;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305615 struct wmi_unified *wmi_handle;
5616 uint32_t *service_bitmap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617
5618 WMA_LOGD("%s: Enter", __func__);
5619
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305620 if (!handle) {
5621 WMA_LOGE("%s: wma_handle passed is NULL", __func__);
5622 return -EINVAL;
5623 }
5624
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305625 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5626 if (!tgt_hdl) {
5627 WMA_LOGE("%s: target psoc info is NULL", __func__);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305628 return -EINVAL;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305629 }
5630
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305631 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
5632 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305633 service_bitmap = target_psoc_get_service_bitmap(tgt_hdl);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305634
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005635 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305636 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005637 WMA_LOGE("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305638 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 }
5640
5641 ev = param_buf->fixed_param;
5642 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005643 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305644 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645 }
5646
Sourav Mohapatracf632572018-04-02 11:01:35 +05305647 wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305648 if (!wmi_handle) {
5649 WMA_LOGE("%s: wmi handle is NULL", __func__);
5650 return -EINVAL;
5651 }
5652
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005653 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654
Amar Singhal7b038ca2017-10-04 13:38:39 -07005655 if (ev->num_dbs_hw_modes > param_buf->num_wlan_dbs_hw_mode_list) {
5656 WMA_LOGE("FW dbs_hw_mode entry %d more than value %d in TLV hdr",
5657 ev->num_dbs_hw_modes,
5658 param_buf->num_wlan_dbs_hw_mode_list);
5659 return -EINVAL;
5660 }
5661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005662 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
5663 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
5664 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305665 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005666 wma_handle->num_dbs_hw_modes);
5667 if (!wma_handle->hw_mode.hw_mode_list) {
5668 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
5669 /* Continuing with the rest of the processing */
5670 }
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305671
5672 if (wma_handle->hw_mode.hw_mode_list)
5673 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
5674 ev_wlan_dbs_hw_mode_list,
5675 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
5676 wma_handle->num_dbs_hw_modes));
5677
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005678 policy_mgr_init_dbs_hw_mode(wma_handle->psoc,
5679 ev->num_dbs_hw_modes, ev_wlan_dbs_hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680 wma_dump_dbs_hw_mode(wma_handle);
5681
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305682 /* Initializes the fw_mode and scan_config to zero.
5683 * If ext service ready event is present it will set
5684 * the actual values of these two params.
5685 * This is to ensure that no garbage values would be
5686 * present in the absence of ext service ready event.
5687 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305688 wma_init_scan_fw_mode_config(wma_handle->psoc, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005689
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305690 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305691 sizeof(HAL_REG_CAPABILITIES));
5692
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005694
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305695 wma_handle->new_hw_mode_index = tgt_cap_info->default_dbs_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005696 policy_mgr_update_new_hw_mode_index(wma_handle->psoc,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305697 tgt_cap_info->default_dbs_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005698
5699 WMA_LOGD("%s: Firmware default hw mode index : %d",
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305700 __func__, tgt_cap_info->default_dbs_hw_mode_index);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005701 WMA_LOGI("%s: Firmware build version : %08x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 __func__, ev->fw_build_vers);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305703 WMA_LOGD("FW fine time meas cap: 0x%x",
5704 tgt_cap_info->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005705
5706 if (ev->hw_bd_id) {
5707 wma_handle->hw_bd_id = ev->hw_bd_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305708 qdf_mem_copy(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005709 ev->hw_bd_info, sizeof(ev->hw_bd_info));
5710
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005711 WMA_LOGI("%s: Board version: %x.%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005712 __func__,
5713 wma_handle->hw_bd_info[0], wma_handle->hw_bd_info[1]);
5714 } else {
5715 wma_handle->hw_bd_id = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305716 qdf_mem_zero(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005717 sizeof(wma_handle->hw_bd_info));
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005718 WMA_LOGW("%s: Board version is unknown!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005719 }
5720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305722 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305723 service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05305725
Leo Chang96464902016-10-28 11:10:54 -07005726 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(soc,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005727 wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi));
Leo Chang96464902016-10-28 11:10:54 -07005728 cdp_set_desc_global_pool_size(soc, ev->num_msdu_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729 /* SWBA event handler for beacon transmission */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305730 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305731 wmi_host_swba_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305732 wma_beacon_swba_handler,
5733 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005734 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005735 WMA_LOGE("Failed to register swba beacon event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305736 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005737 }
5738#ifdef WLAN_FEATURE_LPSS
5739 wma_handle->lpss_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005740 wmi_service_enabled(wmi_handle, wmi_service_lpass);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005741#endif /* WLAN_FEATURE_LPSS */
5742
5743 /*
5744 * This Service bit is added to check for ARP/NS Offload
5745 * support for LL/HL targets
5746 */
5747 wma_handle->ap_arpns_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005748 wmi_service_enabled(wmi_handle, wmi_service_ap_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005749
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305750 wma_handle->bpf_enabled = (wma_handle->bpf_packet_filter_enable &&
Dustin Brown7678b6c2018-03-07 13:00:52 -08005751 wmi_service_enabled(wmi_handle, wmi_service_bpf_offload));
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305752 wma_update_ra_limit(wma_handle);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005753
5754 if (wmi_service_enabled(wmi_handle, wmi_service_csa_offload)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 WMA_LOGD("%s: FW support CSA offload capability", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005756 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305757 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305758 wmi_csa_handling_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305759 wma_csa_offload_handler,
5760 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005761 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762 WMA_LOGE("Failed to register CSA offload event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305763 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005764 }
5765 }
5766
Dustin Brown7678b6c2018-03-07 13:00:52 -08005767 if (wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005768 WMA_LOGD("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005769 /*
5770 * Register Tx completion event handler for MGMT Tx over WMI
5771 * case
5772 */
5773 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305774 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305775 wmi_mgmt_tx_completion_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305776 wma_mgmt_tx_completion_handler,
5777 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005778 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305780 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781 }
5782
Nirav Shah20489972016-06-16 19:20:28 +05305783 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305784 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305785 wmi_mgmt_tx_bundle_completion_event_id,
Nirav Shah20489972016-06-16 19:20:28 +05305786 wma_mgmt_tx_bundle_completion_handler,
5787 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005788 if (QDF_IS_STATUS_ERROR(status)) {
Nirav Shah20489972016-06-16 19:20:28 +05305789 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305790 goto free_hw_mode_list;
Nirav Shah20489972016-06-16 19:20:28 +05305791 }
5792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005793 } else {
5794 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
5795 }
Dustin Brown7678b6c2018-03-07 13:00:52 -08005796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005797#ifdef WLAN_FEATURE_GTK_OFFLOAD
Dustin Brown7678b6c2018-03-07 13:00:52 -08005798 if (wmi_service_enabled(wmi_handle, wmi_service_gtk_offload)) {
5799 status = wmi_unified_register_event_handler(
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005800 wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305801 wmi_gtk_offload_status_event_id,
Mukul Sharma3d36c392017-01-18 18:39:12 +05305802 target_if_pmo_gtk_offload_status_event,
5803 WMA_RX_WORK_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005804 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805 WMA_LOGE("Failed to register GTK offload event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305806 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005807 }
5808 }
5809#endif /* WLAN_FEATURE_GTK_OFFLOAD */
5810
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305811 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305812 wmi_tbttoffset_update_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305813 wma_tbttoffset_update_event_handler,
5814 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005815 if (QDF_IS_STATUS_ERROR(status)) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005816 WMA_LOGE("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305817 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 }
5819
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305820 if (wmi_service_enabled(wma_handle->wmi_handle,
5821 wmi_service_rcpi_support)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305822 /* register for rcpi response event */
5823 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305824 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305825 wmi_update_rcpi_event_id,
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305826 wma_rcpi_event_handler,
5827 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005828 if (QDF_IS_STATUS_ERROR(status)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305829 WMA_LOGE("Failed to register RCPI event handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305830 goto free_hw_mode_list;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305831 }
5832 wma_handle->rcpi_enabled = true;
5833 }
5834
Govind Singhefc5ccd2016-04-25 11:11:55 +05305835 /* mac_id is replaced with pdev_id in converged firmware to have
5836 * multi-radio support. In order to maintain backward compatibility
5837 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
5838 * in service bitmap from FW and host needs to set use_pdev_id in
5839 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
5840 * service is not set, then host shall not expect MAC ID from FW in
5841 * VDEV START RESPONSE event and host shall use PDEV ID.
5842 */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305843 if (wmi_service_enabled(wmi_handle, wmi_service_deprecated_replace))
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305844 wlan_res_cfg->use_pdev_id = true;
Govind Singhefc5ccd2016-04-25 11:11:55 +05305845 else
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305846 wlan_res_cfg->use_pdev_id = false;
Govind Singhefc5ccd2016-04-25 11:11:55 +05305847
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305848 wlan_res_cfg->max_num_dbs_scan_duty_cycle = CDS_DBS_SCAN_CLIENTS_MAX;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05305849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 /* Initialize the log supported event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305851 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305852 wmi_diag_event_id_log_supported_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305853 wma_log_supported_evt_handler,
5854 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005855 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 WMA_LOGE("Failed to register log supported event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305857 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 }
5859
Leo Chang96464902016-10-28 11:10:54 -07005860 cdp_mark_first_wakeup_packet(soc,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305861 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305862 wmi_service_mark_first_wakeup_packet));
Arif Hussaind54b62c2018-03-01 13:31:37 -08005863 wma_handle->is_dfs_offloaded =
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305864 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305865 wmi_service_dfs_phyerr_offload);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07005866 wma_handle->nan_datapath_enabled =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305867 wmi_service_enabled(wma_handle->wmi_handle,
5868 wmi_service_nan_data);
Dustin Brown06259e52018-02-28 16:00:02 -08005869
5870 wma_set_component_caps(wma_handle->psoc);
5871
Dustin Brownb9987af2018-03-01 17:15:11 -08005872 wma_update_fw_config(wma_handle->psoc, tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873
Dustin Brown7678b6c2018-03-07 13:00:52 -08005874 status = wmi_unified_save_fw_version_cmd(wmi_handle, param_buf);
5875 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhf25a0f12016-03-08 16:09:48 +05305876 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305877 goto free_hw_mode_list;
Govind Singhf25a0f12016-03-08 16:09:48 +05305878 }
5879
Dustin Brown7678b6c2018-03-07 13:00:52 -08005880 status = qdf_mc_timer_start(&wma_handle->service_ready_ext_timer,
5881 WMA_SERVICE_READY_EXT_TIMEOUT);
5882 if (QDF_IS_STATUS_ERROR(status))
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305883 WMA_LOGE("Failed to start the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05305884
Dustin Brown7678b6c2018-03-07 13:00:52 -08005885 wma_handle->tx_bfee_8ss_enabled =
5886 wmi_service_enabled(wmi_handle, wmi_service_8ss_tx_bfee);
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05305887
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305888 target_psoc_set_num_radios(tgt_hdl, 1);
5889
Govind Singhd76a5b02016-03-08 15:12:14 +05305890 return 0;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305891
5892free_hw_mode_list:
5893 if (wma_handle->hw_mode.hw_mode_list) {
5894 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
5895 wma_handle->hw_mode.hw_mode_list = NULL;
5896 WMA_LOGD("%s: DBS list is freed", __func__);
5897 }
5898
5899 return -EINVAL;
5900
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005901}
5902
5903/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07005904 * wma_get_phyid_for_given_band() - to get phyid for band
5905 *
5906 * @wma_handle: Pointer to wma handle
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305907* @tgt_hdl: target psoc information
Krunal Soni0193b6f2016-08-15 15:53:43 -07005908 * @band: enum value of for 2G or 5G band
5909 * @phyid: Pointer to phyid which needs to be filled
5910 *
5911 * This API looks in to the map to find out which particular phy supports
5912 * provided band and return the idx (also called phyid) of that phy. Caller
5913 * use this phyid to fetch various caps of that phy
5914 *
5915 * Return: QDF_STATUS
5916 */
5917static QDF_STATUS wma_get_phyid_for_given_band(
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005918 tp_wma_handle wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305919 struct target_psoc_info *tgt_hdl,
Krunal Soni0193b6f2016-08-15 15:53:43 -07005920 enum cds_band_type band, uint8_t *phyid)
5921{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305922 uint8_t idx, i, num_radios;
5923 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07005924
5925 if (!wma_handle) {
5926 WMA_LOGE("Invalid wma handle");
5927 return QDF_STATUS_E_FAILURE;
5928 }
5929
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305930 idx = 0;
Krunal Soni0193b6f2016-08-15 15:53:43 -07005931 *phyid = idx;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305932 num_radios = target_psoc_get_num_radios(tgt_hdl);
5933 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005934
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305935 for (i = 0; i < num_radios; i++) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07005936 if ((band == CDS_BAND_2GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305937 (WLAN_2G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07005938 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005939 WMA_LOGD("Select 2G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005940 return QDF_STATUS_SUCCESS;
5941 } else if ((band == CDS_BAND_5GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305942 (WLAN_5G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07005943 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005944 WMA_LOGD("Select 5G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005945 return QDF_STATUS_SUCCESS;
5946 }
5947 }
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005948 WMA_LOGD("Using default single hw mode phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005949 return QDF_STATUS_SUCCESS;
5950}
5951
5952/**
5953 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
5954 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
5955 * @hw_mode: Provided hardware mode
5956 * @band: Provide band i.e. 2G or 5G
5957 *
5958 * This API finds cap which suitable for provided hw mode and band. If user
5959 * is provides some invalid hw mode then it will automatically falls back to
5960 * default hw mode
5961 *
5962 * Return: QDF_STATUS
5963 */
5964QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
5965 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
5966{
5967 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305968 struct target_psoc_info *tgt_hdl;
5969 int ht_cap_info, vht_cap_info;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305970 uint8_t phyid, our_hw_mode = hw_mode, num_hw_modes;
5971 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07005972
5973 if (!wma_handle) {
5974 WMA_LOGE("Invalid wma handle");
5975 return QDF_STATUS_E_FAILURE;
5976 }
5977
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305978 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5979 if (!tgt_hdl) {
5980 WMA_LOGE("%s: target psoc info is NULL", __func__);
5981 return -EINVAL;
5982 }
5983
5984 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
5985 vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305986 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5987 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305988
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305989 if (!num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08005990 WMA_LOGD("Invalid number of hw modes, use legacy HT/VHT caps");
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305991 caps_per_phy->ht_2g = ht_cap_info;
5992 caps_per_phy->ht_5g = ht_cap_info;
5993 caps_per_phy->vht_2g = vht_cap_info;
5994 caps_per_phy->vht_5g = vht_cap_info;
jiad080abce2017-08-08 15:17:39 +08005995 /* legacy platform doesn't support HE IE */
5996 caps_per_phy->he_2g = 0;
5997 caps_per_phy->he_5g = 0;
5998
5999 return QDF_STATUS_SUCCESS;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006000 }
6001
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006002 if (!policy_mgr_is_dbs_enable(wma_handle->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006003 our_hw_mode = HW_MODE_DBS_NONE;
6004
6005 if (!caps_per_phy) {
6006 WMA_LOGE("Invalid caps pointer");
6007 return QDF_STATUS_E_FAILURE;
6008 }
6009
Krunal Soni0193b6f2016-08-15 15:53:43 -07006010 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306011 wma_get_phyid_for_given_band(wma_handle, tgt_hdl, band, &phyid)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006012 WMA_LOGE("Invalid phyid");
6013 return QDF_STATUS_E_FAILURE;
6014 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006015
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306016 caps_per_phy->ht_2g = mac_phy_cap[phyid].ht_cap_info_2G;
6017 caps_per_phy->ht_5g = mac_phy_cap[phyid].ht_cap_info_5G;
6018 caps_per_phy->vht_2g = mac_phy_cap[phyid].vht_cap_info_2G;
6019 caps_per_phy->vht_5g = mac_phy_cap[phyid].vht_cap_info_5G;
6020 caps_per_phy->he_2g = mac_phy_cap[phyid].he_cap_info_2G;
6021 caps_per_phy->he_5g = mac_phy_cap[phyid].he_cap_info_5G;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006022
Naveen Rawat98322472018-03-06 10:29:42 -08006023 caps_per_phy->tx_chain_mask_2G = mac_phy_cap->tx_chain_mask_2G;
6024 caps_per_phy->rx_chain_mask_2G = mac_phy_cap->rx_chain_mask_2G;
6025 caps_per_phy->tx_chain_mask_5G = mac_phy_cap->tx_chain_mask_5G;
6026 caps_per_phy->rx_chain_mask_5G = mac_phy_cap->rx_chain_mask_5G;
6027
Krunal Soni0193b6f2016-08-15 15:53:43 -07006028 return QDF_STATUS_SUCCESS;
6029}
6030
6031/**
6032 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
6033 *
6034 * @channel: Channel number for which it needs to check if rx ldpc is enabled
6035 *
6036 * This API takes channel number as argument and takes default hw mode as DBS
6037 * to check if rx LDPC support is enabled for that channel or no
6038 */
6039bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
6040{
jiad080abce2017-08-08 15:17:39 +08006041 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306042 struct target_psoc_info *tgt_hdl;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006043 struct wma_caps_per_phy caps_per_phy = {0};
6044 enum cds_band_type band;
6045 bool status;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306046 uint8_t num_hw_modes;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006047
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006048 if (!wma_handle) {
6049 WMA_LOGE("Invalid wma handle");
6050 return false;
6051 }
6052
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306053 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6054 if (!tgt_hdl) {
6055 WMA_LOGE("Target handle is NULL");
6056 return QDF_STATUS_E_FAILURE;
6057 }
6058
6059 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6060
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006061 if (!WLAN_REG_IS_24GHZ_CH(channel))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006062 band = CDS_BAND_5GHZ;
6063 else
6064 band = CDS_BAND_2GHZ;
6065
6066 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
6067 &caps_per_phy,
6068 HW_MODE_DBS, band)) {
6069 return false;
6070 }
jiad080abce2017-08-08 15:17:39 +08006071
6072 /*
6073 * Legacy platforms like Rome set WMI_HT_CAP_LDPC to specify RX LDPC
6074 * capability. But new platforms like Helium set WMI_HT_CAP_RX_LDPC
6075 * instead.
6076 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306077 if (0 == num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08006078 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_LDPC));
6079 } else {
6080 if (WLAN_REG_IS_24GHZ_CH(channel))
6081 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
6082 else
6083 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
6084 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006085
6086 return status;
6087}
6088
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006089/**
6090 * wma_print_mac_phy_capabilities() - Prints MAC PHY capabilities
6091 * @cap: pointer to WMI_MAC_PHY_CAPABILITIES
6092 * @index: MAC_PHY index
6093 *
6094 * Return: none
6095 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306096static void wma_print_mac_phy_capabilities(struct wlan_psoc_host_mac_phy_caps
6097 *cap, int index)
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006098{
6099 uint32_t mac_2G, mac_5G;
6100 uint32_t phy_2G[WMI_MAX_HECAP_PHY_SIZE];
6101 uint32_t phy_5G[WMI_MAX_HECAP_PHY_SIZE];
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306102 struct wlan_psoc_host_ppe_threshold ppet_2G, ppet_5G;
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006103
6104 WMA_LOGI("\t: index [%d]", index);
6105 WMA_LOGI("\t: cap for hw_mode_id[%d]", cap->hw_mode_id);
6106 WMA_LOGI("\t: pdev_id[%d]", cap->pdev_id);
6107 WMA_LOGI("\t: phy_id[%d]", cap->phy_id);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306108 WMA_LOGI("\t: supports_11b[%d]", cap->supports_11b);
6109 WMA_LOGI("\t: supports_11g[%d]", cap->supports_11g);
6110 WMA_LOGI("\t: supports_11a[%d]", cap->supports_11a);
6111 WMA_LOGI("\t: supports_11n[%d]", cap->supports_11n);
6112 WMA_LOGI("\t: supports_11ac[%d]", cap->supports_11ac);
6113 WMA_LOGI("\t: supports_11ax[%d]", cap->supports_11ax);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006114 WMA_LOGI("\t: supported_bands[%d]", cap->supported_bands);
6115 WMA_LOGI("\t: ampdu_density[%d]", cap->ampdu_density);
6116 WMA_LOGI("\t: max_bw_supported_2G[%d]", cap->max_bw_supported_2G);
6117 WMA_LOGI("\t: ht_cap_info_2G[%d]", cap->ht_cap_info_2G);
6118 WMA_LOGI("\t: vht_cap_info_2G[%d]", cap->vht_cap_info_2G);
6119 WMA_LOGI("\t: vht_supp_mcs_2G[%d]", cap->vht_supp_mcs_2G);
6120 WMA_LOGI("\t: tx_chain_mask_2G[%d]", cap->tx_chain_mask_2G);
6121 WMA_LOGI("\t: rx_chain_mask_2G[%d]", cap->rx_chain_mask_2G);
6122 WMA_LOGI("\t: max_bw_supported_5G[%d]", cap->max_bw_supported_5G);
6123 WMA_LOGI("\t: ht_cap_info_5G[%d]", cap->ht_cap_info_5G);
6124 WMA_LOGI("\t: vht_cap_info_5G[%d]", cap->vht_cap_info_5G);
6125 WMA_LOGI("\t: vht_supp_mcs_5G[%d]", cap->vht_supp_mcs_5G);
6126 WMA_LOGI("\t: tx_chain_mask_5G[%d]", cap->tx_chain_mask_5G);
6127 WMA_LOGI("\t: rx_chain_mask_5G[%d]", cap->rx_chain_mask_5G);
6128 WMA_LOGI("\t: he_cap_info_2G[%08x]", cap->he_cap_info_2G);
6129 WMA_LOGI("\t: he_supp_mcs_2G[%08x]", cap->he_supp_mcs_2G);
6130 WMA_LOGI("\t: he_cap_info_5G[%08x]", cap->he_cap_info_5G);
6131 WMA_LOGI("\t: he_supp_mcs_5G[%08x]", cap->he_supp_mcs_5G);
6132 mac_2G = cap->he_cap_info_2G;
6133 mac_5G = cap->he_cap_info_5G;
6134 qdf_mem_copy(phy_2G, cap->he_cap_phy_info_2G,
6135 WMI_MAX_HECAP_PHY_SIZE * 4);
6136 qdf_mem_copy(phy_5G, cap->he_cap_phy_info_5G,
6137 WMI_MAX_HECAP_PHY_SIZE * 4);
6138 ppet_2G = cap->he_ppet2G;
6139 ppet_5G = cap->he_ppet5G;
6140
6141 wma_print_he_mac_cap(mac_2G);
6142 wma_print_he_phy_cap(phy_2G);
6143 wma_print_he_ppet(&ppet_2G);
6144 wma_print_he_mac_cap(mac_5G);
6145 wma_print_he_phy_cap(phy_5G);
6146 wma_print_he_ppet(&ppet_5G);
6147}
Krunal Soni0193b6f2016-08-15 15:53:43 -07006148
6149/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006150 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306151 * @tgt_info: target related info
Krunal Soni2e48d012016-05-02 16:55:26 -07006152 *
6153 * This function prints all the caps populater per hw mode and per PHY
6154 *
6155 * Return: none
6156 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306157static void wma_print_populate_soc_caps(struct target_psoc_info *tgt_hdl)
Krunal Soni2e48d012016-05-02 16:55:26 -07006158{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006159 int i, num_hw_modes, total_mac_phy_cnt;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306160 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap, *tmp;
6161
6162 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006163 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006164
6165 /* print number of hw modes */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306166 WMA_LOGD("%s: num of hw modes [%d]", __func__, num_hw_modes);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006167 WMA_LOGD("%s: num mac_phy_cnt [%d]", __func__, total_mac_phy_cnt);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306168 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006169 WMA_LOGD("%s: <====== HW mode cap printing starts ======>", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07006170 /* print cap of each hw mode */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006171 for (i = 0; i < total_mac_phy_cnt; i++) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006172 WMA_LOGD("====>: hw mode id[%d], phy_id map[%d]",
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006173 mac_phy_cap[i].hw_mode_id,
6174 mac_phy_cap[i].phy_id);
6175 tmp = &mac_phy_cap[i];
6176 wma_print_mac_phy_capabilities(tmp, i);
Krunal Soni2e48d012016-05-02 16:55:26 -07006177 }
6178 WMA_LOGI("%s: <====== HW mode cap printing ends ======>\n", __func__);
6179}
6180
6181/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306182 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
6183 * in terms of hw_mode_bandwidth
6184 * @width: bandwidth in terms of wmi_channel_width
6185 *
6186 * This function returns the bandwidth in terms of hw_mode_bandwidth.
6187 *
6188 * Return: BW in terms of hw_mode_bandwidth.
6189 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006190static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306191 wmi_channel_width width)
6192{
6193 switch (width) {
6194 case WMI_CHAN_WIDTH_20:
6195 return HW_MODE_20_MHZ;
6196 case WMI_CHAN_WIDTH_40:
6197 return HW_MODE_40_MHZ;
6198 case WMI_CHAN_WIDTH_80:
6199 return HW_MODE_80_MHZ;
6200 case WMI_CHAN_WIDTH_160:
6201 return HW_MODE_160_MHZ;
6202 case WMI_CHAN_WIDTH_80P80:
6203 return HW_MODE_80_PLUS_80_MHZ;
6204 case WMI_CHAN_WIDTH_5:
6205 return HW_MODE_5_MHZ;
6206 case WMI_CHAN_WIDTH_10:
6207 return HW_MODE_10_MHZ;
6208 default:
6209 return HW_MODE_BW_NONE;
6210 }
6211
6212 return HW_MODE_BW_NONE;
6213}
6214
6215/**
6216 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
6217 * supported from the capabilities.
6218 * @caps: PHY capability
6219 * @info: param to store TX-RX stream and BW information
6220 *
6221 * This function will calculate TX-RX stream and bandwidth supported
6222 * as per the PHY capability, and assign to mac_ss_bw_info.
6223 *
6224 * Return: none
6225 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306226static void wma_get_hw_mode_params(struct wlan_psoc_host_mac_phy_caps *caps,
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306227 struct mac_ss_bw_info *info)
6228{
6229 if (!caps) {
6230 WMA_LOGE("%s: Invalid capabilities", __func__);
6231 return;
6232 }
6233
6234 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
6235 QDF_MAX(caps->tx_chain_mask_2G,
6236 caps->tx_chain_mask_5G));
6237 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
6238 QDF_MAX(caps->rx_chain_mask_2G,
6239 caps->rx_chain_mask_5G));
6240 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
6241 QDF_MAX(caps->max_bw_supported_2G,
6242 caps->max_bw_supported_5G));
6243}
6244
6245/**
6246 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
6247 * DBS in hw_mode_list
6248 * @wma_handle: pointer to wma global structure
6249 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
6250 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
6251 * @pos: refers to hw_mode_index
6252 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306253 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306254 *
6255 * This function sets TX-RX stream, bandwidth and DBS mode in
6256 * hw_mode_list.
6257 *
6258 * Return: none
6259 */
6260static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
6261 struct mac_ss_bw_info mac0_ss_bw_info,
6262 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306263 uint32_t pos, uint32_t dbs_mode,
6264 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306265{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306266 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306267 wma_handle->hw_mode.hw_mode_list[pos],
6268 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306269 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306270 wma_handle->hw_mode.hw_mode_list[pos],
6271 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306272 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306273 wma_handle->hw_mode.hw_mode_list[pos],
6274 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306275 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306276 wma_handle->hw_mode.hw_mode_list[pos],
6277 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306278 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306279 wma_handle->hw_mode.hw_mode_list[pos],
6280 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306281 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306282 wma_handle->hw_mode.hw_mode_list[pos],
6283 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306284 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306285 wma_handle->hw_mode.hw_mode_list[pos],
6286 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306287 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306288 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306289 HW_MODE_AGILE_DFS_NONE);
6290 WMA_HW_MODE_SBS_MODE_SET(
6291 wma_handle->hw_mode.hw_mode_list[pos],
6292 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306293}
6294
6295/**
6296 * wma_update_hw_mode_list() - updates hw_mode_list
6297 * @wma_handle: pointer to wma global structure
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306298 * @tgt_hdl - target psoc information
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306299 *
6300 * This function updates hw_mode_list with tx_streams, rx_streams,
6301 * bandwidth, dbs and agile dfs for each hw_mode.
6302 *
6303 * Returns: 0 for success else failure.
6304 */
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306305static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle,
6306 struct target_psoc_info *tgt_hdl)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306307{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306308 struct wlan_psoc_host_mac_phy_caps *tmp, *mac_phy_cap;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306309 uint32_t i, hw_config_type, j = 0;
6310 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306311 struct mac_ss_bw_info mac0_ss_bw_info = {0};
6312 struct mac_ss_bw_info mac1_ss_bw_info = {0};
Krunal Sonica50b452017-08-04 22:24:59 -07006313 WMI_PHY_CAPABILITY new_supported_band = 0;
6314 bool supported_band_update_failure = false;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306315 struct wlan_psoc_target_capability_info *tgt_cap_info;
6316 int num_hw_modes;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306317
6318 if (!wma_handle) {
6319 WMA_LOGE("%s: Invalid wma handle", __func__);
6320 return QDF_STATUS_E_FAILURE;
6321 }
6322
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306323 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6324 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
6325 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306326 /*
6327 * This list was updated as part of service ready event. Re-populate
6328 * HW mode list from the device capabilities.
6329 */
6330 if (wma_handle->hw_mode.hw_mode_list) {
6331 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
6332 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006333 WMA_LOGD("%s: DBS list is freed", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306334 }
6335
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306336 wma_handle->hw_mode.hw_mode_list =
6337 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306338 num_hw_modes);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306339 if (!wma_handle->hw_mode.hw_mode_list) {
6340 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
6341 return QDF_STATUS_E_FAILURE;
6342 }
6343
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08006344 WMA_LOGD("%s: Updated HW mode list: Num modes:%d",
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306345 __func__, num_hw_modes);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306346
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306347 for (i = 0; i < num_hw_modes; i++) {
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306348 /* Update for MAC0 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306349 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306350 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306351 hw_config_type = mac_phy_cap[j].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306352 dbs_mode = HW_MODE_DBS_NONE;
6353 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306354 mac1_ss_bw_info.mac_tx_stream = 0;
6355 mac1_ss_bw_info.mac_rx_stream = 0;
6356 mac1_ss_bw_info.mac_bw = 0;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306357 if (wma_update_supported_bands(tmp->supported_bands,
6358 &new_supported_band)
6359 != QDF_STATUS_SUCCESS)
Krunal Sonica50b452017-08-04 22:24:59 -07006360 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306361
6362 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
6363 if ((hw_config_type == WMI_HW_MODE_DBS) ||
6364 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6365 (hw_config_type == WMI_HW_MODE_SBS)) {
6366 /* Update for MAC1 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306367 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306368 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306369 if (hw_config_type == WMI_HW_MODE_DBS)
6370 dbs_mode = HW_MODE_DBS;
6371 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6372 (hw_config_type == WMI_HW_MODE_SBS))
6373 sbs_mode = HW_MODE_SBS;
Krunal Sonica50b452017-08-04 22:24:59 -07006374 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306375 wma_update_supported_bands(tmp->supported_bands,
Krunal Sonica50b452017-08-04 22:24:59 -07006376 &new_supported_band))
6377 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306378 }
6379
6380 /* Updating HW mode list */
6381 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306382 mac1_ss_bw_info, i, dbs_mode,
6383 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306384 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006385
Krunal Sonica50b452017-08-04 22:24:59 -07006386 /* overwrite phy_capability which we got from service ready event */
6387 if (!supported_band_update_failure) {
6388 WMA_LOGD("%s: updating supported band from old[%d] to new[%d]",
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306389 __func__, target_if_get_phy_capability(tgt_hdl),
Krunal Sonica50b452017-08-04 22:24:59 -07006390 new_supported_band);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306391 target_if_set_phy_capability(tgt_hdl, new_supported_band);
Krunal Sonica50b452017-08-04 22:24:59 -07006392 }
6393
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006394 if (QDF_STATUS_SUCCESS !=
Krunal Sonica50b452017-08-04 22:24:59 -07006395 policy_mgr_update_hw_mode_list(wma_handle->psoc,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306396 tgt_hdl))
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006397 WMA_LOGE("%s: failed to update policy manager", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306398 wma_dump_dbs_hw_mode(wma_handle);
6399 return QDF_STATUS_SUCCESS;
6400}
6401
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006402static void wma_init_wifi_pos_dma_rings(t_wma_handle *wma_handle,
6403 uint8_t num_mac, void *buf)
6404{
6405 struct hif_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006406 void *hal_soc;
6407
6408 if (!hif_ctx) {
6409 WMA_LOGE("invalid hif context");
6410 return;
6411 }
6412
6413 hal_soc = hif_get_hal_handle(hif_ctx);
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006414
6415 wifi_pos_init_cir_cfr_rings(wma_handle->psoc, hal_soc, num_mac, buf);
6416}
6417
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306418/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006419 * wma_populate_soc_caps() - populate entire SOC's capabilities
6420 * @wma_handle: pointer to wma global structure
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306421 * @tgt_hdl: target psoc information
Krunal Soni2e48d012016-05-02 16:55:26 -07006422 * @param_buf: pointer to param of service ready extension event from fw
6423 *
6424 * This API populates all capabilities of entire SOC. For example,
6425 * how many number of hw modes are supported by this SOC, what are the
6426 * capabilities of each phy per hw mode, what are HAL reg capabilities per
6427 * phy.
6428 *
6429 * Return: none
6430 */
6431static void wma_populate_soc_caps(t_wma_handle *wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306432 struct target_psoc_info *tgt_hdl,
Krunal Soni2e48d012016-05-02 16:55:26 -07006433 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
6434{
Krunal Soni2e48d012016-05-02 16:55:26 -07006435
6436 WMA_LOGD("%s: Enter", __func__);
6437
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006438 wma_init_wifi_pos_dma_rings(wma_handle,
6439 param_buf->num_oem_dma_ring_caps,
6440 param_buf->oem_dma_ring_caps);
6441
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306442 wma_print_populate_soc_caps(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006443}
6444
6445/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006446 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
6447 * @handle: wma handle
6448 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05306449 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006450 *
6451 * Return: none
6452 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306453int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
6454 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006455{
6456 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6457 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
6458 wmi_service_ready_ext_event_fixed_param *ev;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306459 QDF_STATUS ret;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306460 struct target_psoc_info *tgt_hdl;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306461 uint32_t conc_scan_config_bits, fw_config_bits;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006463 WMA_LOGD("%s: Enter", __func__);
6464
6465 if (!wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006466 WMA_LOGE("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306467 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006468 }
6469
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306470 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6471 if (!tgt_hdl) {
6472 WMA_LOGE("%s: target psoc info is NULL", __func__);
6473 return -EINVAL;
6474 }
6475
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006476 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
6477 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006478 WMA_LOGE("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306479 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480 }
6481
6482 ev = param_buf->fixed_param;
6483 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006484 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306485 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 }
6487
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006488 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306490 fw_config_bits = target_if_get_fw_config_bits(tgt_hdl);
6491 conc_scan_config_bits = target_if_get_conc_scan_config_bits(tgt_hdl);
6492
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006493 WMA_LOGD("%s: Defaults: scan config:%x FW mode config:%x",
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306494 __func__, conc_scan_config_bits, fw_config_bits);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05306495
Anurag Chouhan210db072016-02-22 18:42:15 +05306496 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05306497 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006498 WMA_LOGE("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05306499 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006500 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306501 wma_populate_soc_caps(wma_handle, tgt_hdl, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006502
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306503 ret = wma_update_hw_mode_list(wma_handle, tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306504 if (QDF_IS_STATUS_ERROR(ret)) {
6505 WMA_LOGE("Failed to update hw mode list");
6506 return -EINVAL;
6507 }
6508
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006509 WMA_LOGD("WMA --> WMI_INIT_CMDID");
Mukul Sharmab10c8c72017-11-02 17:25:59 +05306510
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306511 wma_init_scan_fw_mode_config(wma_handle->psoc, conc_scan_config_bits,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306512 fw_config_bits);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306513
6514 target_psoc_set_num_radios(tgt_hdl, 1);
Govind Singhd76a5b02016-03-08 15:12:14 +05306515 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006516}
6517
6518/**
6519 * wma_rx_ready_event() - event handler to process
6520 * wmi rx ready event.
6521 * @handle: wma handle
6522 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05306523 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006524 *
6525 * Return: none
6526 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306527int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
6528 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006529{
6530 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6531 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
6532 wmi_ready_event_fixed_param *ev = NULL;
6533
6534 WMA_LOGD("%s: Enter", __func__);
6535
6536 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
6537 if (!(wma_handle && param_buf)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006538 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306539 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05306540 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006541 }
6542
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006543 WMA_LOGD("WMA <-- WMI_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006544
6545 ev = param_buf->fixed_param;
6546 /* Indicate to the waiting thread that the ready
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006547 * event was received
6548 */
Naveen Rawat64e477e2016-05-20 10:34:56 -07006549 wma_handle->sub_20_support =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306550 wmi_service_enabled(wma_handle->wmi_handle,
6551 wmi_service_half_rate_quarter_rate_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006552 wma_handle->wmi_ready = true;
6553 wma_handle->wlan_init_status = ev->status;
6554
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006555 /* copy the mac addr */
6556 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
6557 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006558 wma_update_hdd_cfg(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006559 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05306560
6561 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006562}
6563
6564/**
6565 * wma_setneedshutdown() - setting wma needshutdown flag
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006566 *
6567 * Return: none
6568 */
Jeff Johnson1f8d0a02017-09-13 08:09:05 -07006569void wma_setneedshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006570{
6571 tp_wma_handle wma_handle;
6572
6573 WMA_LOGD("%s: Enter", __func__);
6574
Anurag Chouhan6d760662016-02-20 16:05:43 +05306575 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006576
6577 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006578 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306579 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006580 return;
6581 }
6582
6583 wma_handle->needShutdown = true;
6584 WMA_LOGD("%s: Exit", __func__);
6585}
6586
6587/**
6588 * wma_needshutdown() - Is wma needs shutdown?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006589 *
6590 * Return: returns true/false
6591 */
Jeff Johnson1b5404e2017-09-13 08:04:46 -07006592bool wma_needshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006593{
6594 tp_wma_handle wma_handle;
6595
6596 WMA_LOGD("%s: Enter", __func__);
6597
Anurag Chouhan6d760662016-02-20 16:05:43 +05306598 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006599
6600 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006601 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306602 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006603 return false;
6604 }
6605
6606 WMA_LOGD("%s: Exit", __func__);
6607 return wma_handle->needShutdown;
6608}
6609
6610/**
6611 * wma_wait_for_ready_event() - wait for wma ready event
6612 * @handle: wma handle
6613 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306614 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006615 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306616QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006617{
6618 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306619 QDF_STATUS qdf_status;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306620 struct target_psoc_info *tgt_hdl;
6621 int timeleft;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006622
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306623 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6624 if (!tgt_hdl) {
6625 WMA_LOGE("%s: target psoc info is NULL", __func__);
6626 return QDF_STATUS_E_INVAL;
6627 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006628
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306629 timeleft = qdf_wait_queue_timeout(
6630 tgt_hdl->info.event_queue,
6631 ((tgt_hdl->info.wmi_service_ready) &&
6632 (tgt_hdl->info.wmi_ready)),
6633 WMA_READY_EVENTID_TIMEOUT);
6634 if (!timeleft) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006635 WMA_LOGE("%s: Timeout waiting for ready event from FW",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006636 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306637 qdf_status = QDF_STATUS_E_FAILURE;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306638 } else {
6639 WMA_LOGI("%s Ready event received from FW", __func__);
6640 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006641 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306642
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306643 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006644}
6645
6646/**
6647 * wma_set_ppsconfig() - set pps config in fw
6648 * @vdev_id: vdev id
6649 * @pps_param: pps params
6650 * @val : param value
6651 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306652 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006653 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306654QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006655 int val)
6656{
Anurag Chouhan6d760662016-02-20 16:05:43 +05306657 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006658 int ret = -EIO;
6659 uint32_t pps_val;
6660
6661 if (NULL == wma) {
6662 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306663 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006664 }
6665
6666 switch (pps_param) {
6667 case WMA_VHT_PPS_PAID_MATCH:
6668 pps_val = ((val << 31) & 0xffff0000) |
6669 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
6670 goto pkt_pwr_save_config;
6671 case WMA_VHT_PPS_GID_MATCH:
6672 pps_val = ((val << 31) & 0xffff0000) |
6673 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
6674 goto pkt_pwr_save_config;
6675 case WMA_VHT_PPS_DELIM_CRC_FAIL:
6676 pps_val = ((val << 31) & 0xffff0000) |
6677 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
6678 goto pkt_pwr_save_config;
6679
6680 /* Enable the code below as and when the functionality
6681 * is supported/added in host.
6682 */
6683#ifdef NOT_YET
6684 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
6685 pps_val = ((val << 31) & 0xffff0000) |
6686 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
6687 goto pkt_pwr_save_config;
6688 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
6689 pps_val = ((val << 31) & 0xffff0000) |
6690 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
6691 goto pkt_pwr_save_config;
6692 case WMA_VHT_PPS_EOF_PAD_DELIM:
6693 pps_val = ((val << 31) & 0xffff0000) |
6694 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
6695 goto pkt_pwr_save_config;
6696 case WMA_VHT_PPS_MACADDR_MISMATCH:
6697 pps_val = ((val << 31) & 0xffff0000) |
6698 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
6699 goto pkt_pwr_save_config;
6700 case WMA_VHT_PPS_GID_NSTS_ZERO:
6701 pps_val = ((val << 31) & 0xffff0000) |
6702 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
6703 goto pkt_pwr_save_config;
6704 case WMA_VHT_PPS_RSSI_CHECK:
6705 pps_val = ((val << 31) & 0xffff0000) |
6706 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
6707 goto pkt_pwr_save_config;
6708#endif /* NOT_YET */
6709pkt_pwr_save_config:
6710 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
6711 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05306712 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006713 WMI_VDEV_PARAM_PACKET_POWERSAVE,
6714 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006715 break;
6716 default:
6717 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
6718 }
6719
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306720 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006721}
6722
6723/**
6724 * wma_process_set_mas() - Function to enable/disable MAS
6725 * @wma: Pointer to WMA handle
6726 * @mas_val: 1-Enable MAS, 0-Disable MAS
6727 *
6728 * This function enables/disables the MAS value
6729 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306730 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006731 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006732static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
6733 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006734{
6735 uint32_t val;
6736
6737 if (NULL == wma || NULL == mas_val) {
6738 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306739 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006740 }
6741
6742 val = (*mas_val);
6743
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306744 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006745 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
6746 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306747 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006748 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006749 WMA_LOGE("%s: Value is %d", __func__, val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306750 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006751}
6752
6753/**
6754 * wma_process_set_miracast() - Function to set miracast value in WMA
6755 * @wma: Pointer to WMA handle
6756 * @miracast_val: 0-Disabled,1-Source,2-Sink
6757 *
6758 * This function stores the miracast value in WMA
6759 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306760 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006761 *
6762 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006763static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
6764 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006765{
6766 if (NULL == wma || NULL == miracast_val) {
6767 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306768 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006769 }
6770
6771 wma->miracast_value = *miracast_val;
6772 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
6773
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306774 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006775}
6776
6777/**
6778 * wma_config_stats_factor() - Function to configure stats avg. factor
6779 * @wma: pointer to WMA handle
6780 * @avg_factor: stats. avg. factor passed down by userspace
6781 *
6782 * This function configures the avg. stats value in firmware
6783 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306784 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006785 *
6786 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306787static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006788 struct sir_stats_avg_factor *avg_factor)
6789{
Govind Singhd76a5b02016-03-08 15:12:14 +05306790 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006791
6792 if (NULL == wma || NULL == avg_factor) {
6793 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306794 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006795 }
6796
Govind Singhd76a5b02016-03-08 15:12:14 +05306797 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006798 avg_factor->vdev_id,
6799 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
6800 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05306801 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006802 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
6803 avg_factor->vdev_id);
6804 }
6805
6806 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
6807 avg_factor->stats_avg_factor, avg_factor->vdev_id);
6808
6809 return ret;
6810}
6811
6812/**
6813 * wma_config_guard_time() - Function to set guard time in firmware
6814 * @wma: pointer to WMA handle
6815 * @guard_time: guard time passed down by userspace
6816 *
6817 * This function configures the guard time in firmware
6818 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306819 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006820 *
6821 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306822static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006823 struct sir_guard_time_request *guard_time)
6824{
Govind Singhd76a5b02016-03-08 15:12:14 +05306825 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006826
6827 if (NULL == wma || NULL == guard_time) {
6828 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306829 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006830 }
6831
Govind Singhd76a5b02016-03-08 15:12:14 +05306832 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833 guard_time->vdev_id,
6834 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
6835 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05306836 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006837 WMA_LOGE(" failed to set guard time for vdev_id %d",
6838 guard_time->vdev_id);
6839 }
6840
6841 WMA_LOGD("Set guard time %d for vdev_id %d",
6842 guard_time->guard_time, guard_time->vdev_id);
6843
6844 return ret;
6845}
6846
6847/**
6848 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
6849 * @wma_handle: WMA handle
6850 * @start_log: Start logging related parameters
6851 *
6852 * Send the command to the FW based on which specific logging of diag
6853 * event/log id can be started/stopped
6854 *
6855 * Return: None
6856 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006857static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
6858 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006859{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006860
6861 if (!start_log) {
6862 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6863 return;
6864 }
6865 if (!wma_handle) {
6866 WMA_LOGE("%s: Invalid wma handle", __func__);
6867 return;
6868 }
6869
6870 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
6871 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
6872 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
6873 __func__, start_log->ring_id);
6874 return;
6875 }
6876
Govind Singhf25a0f12016-03-08 16:09:48 +05306877 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
6878 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006879}
6880
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306881#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006882/**
6883 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
6884 * @wma_handle: WMA handle
6885 * @start_log: Struture containing the start wifi logger params
6886 *
6887 * This function is used to send the WMA commands to start/stop logging
6888 * of per packet statistics
6889 *
6890 * Return: None
6891 *
6892 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006893#ifdef REMOVE_PKT_LOG
6894static void wma_set_wifi_start_packet_stats(void *wma_handle,
6895 struct sir_wifi_start_log *start_log)
6896{
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006897}
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07006898
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006899#else
6900static void wma_set_wifi_start_packet_stats(void *wma_handle,
6901 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006902{
Komal Seelam3d202862016-02-24 18:43:24 +05306903 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006904 uint32_t log_state;
6905
6906 if (!start_log) {
6907 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6908 return;
6909 }
6910 if (!wma_handle) {
6911 WMA_LOGE("%s: Invalid wma handle", __func__);
6912 return;
6913 }
6914
6915 /* No need to register for ring IDs other than packet stats */
6916 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006917 WMA_LOGD("%s: Ring id is not for per packet stats: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006918 __func__, start_log->ring_id);
6919 return;
6920 }
6921
Anurag Chouhan6d760662016-02-20 16:05:43 +05306922 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07006923 if (scn == NULL) {
6924 WMA_LOGE("%s: Invalid HIF handle", __func__);
6925 return;
6926 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006927
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07006928#ifdef HELIUMPLUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006929 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05306930 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
Venkata Sharath Chandra Manchala29965172018-01-18 14:17:29 -08006931 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07006932#else
6933 log_state = ATH_PKTLOG_LITE_T2H | ATH_PKTLOG_LITE_RX;
6934#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306935 if (start_log->size != 0) {
6936 pktlog_setsize(scn, start_log->size * MEGABYTE);
6937 return;
Poddar, Siddarthab99a272017-04-10 12:53:26 +05306938 } else if (start_log->is_pktlog_buff_clear == true) {
6939 pktlog_clearbuff(scn, start_log->is_pktlog_buff_clear);
6940 return;
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306941 }
6942
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006943 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006944 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306945 start_log->user_triggered,
6946 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006947 WMA_LOGD("%s: Enabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006948 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006949 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306950 start_log->user_triggered,
6951 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006952 WMA_LOGD("%s: Disabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006953 }
6954}
6955#endif
6956
6957/**
6958 * wma_send_flush_logs_to_fw() - Send log flush command to FW
6959 * @wma_handle: WMI handle
6960 *
6961 * This function is used to send the flush command to the FW,
6962 * that will flush the fw logs that are residue in the FW
6963 *
6964 * Return: None
6965 */
6966void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
6967{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306968 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006969 int ret;
6970
Govind Singhf25a0f12016-03-08 16:09:48 +05306971 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
6972 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006974
Anurag Chouhan210db072016-02-22 18:42:15 +05306975 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006976 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306977 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006978 WMA_LOGE("Failed to start the log completion timer");
6979}
6980
6981/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306982 * wma_update_wep_default_key - To update default key id
6983 * @wma: pointer to wma handler
6984 * @update_def_key: pointer to wep_update_default_key_idx
6985 *
6986 * This function makes a copy of default key index to txrx node
6987 *
6988 * Return: Success
6989 */
6990static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
6991 struct wep_update_default_key_idx *update_def_key)
6992{
6993 struct wma_txrx_node *iface =
6994 &wma->interfaces[update_def_key->session_id];
6995 iface->wep_default_key_idx = update_def_key->default_idx;
6996
6997 return QDF_STATUS_SUCCESS;
6998}
6999
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307000/**
7001 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
7002 * @wma_handle: WMA handle
7003 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
7004 *
7005 * This function is used to set Tx pkt fail count threshold,
7006 * FW will do disconnect with station once this threshold is reached.
7007 *
7008 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7009 */
7010static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007011 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307012{
7013 u_int8_t vdev_id;
7014 u_int32_t tx_fail_disconn_th;
7015 int ret = -EIO;
7016
7017 if (!wma || !wma->wmi_handle) {
7018 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
7019 return QDF_STATUS_E_INVAL;
7020 }
7021 vdev_id = tx_fail_cnt_th->session_id;
7022 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
7023 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7024 vdev_id, tx_fail_disconn_th);
7025
7026
7027 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7028 WMI_VDEV_PARAM_DISCONNECT_TH,
7029 tx_fail_disconn_th);
7030
7031 if (ret) {
7032 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
7033 return QDF_STATUS_E_FAILURE;
7034 }
7035
7036 return QDF_STATUS_SUCCESS;
7037}
7038
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307039/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307040 * wma_update_short_retry_limit() - Set retry limit for short frames
7041 * @wma_handle: WMA handle
7042 * @short_retry_limit_th: retry limir count for Short frames.
7043 *
7044 * This function is used to configure the transmission retry limit at which
7045 * short frames needs to be retry.
7046 *
7047 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7048 */
7049static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
7050 struct sme_short_retry_limit *short_retry_limit_th)
7051{
7052 uint8_t vdev_id;
7053 uint32_t short_retry_limit;
7054 int ret;
7055
7056 if (!wma || !wma->wmi_handle) {
7057 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
7058 return QDF_STATUS_E_INVAL;
7059 }
7060 vdev_id = short_retry_limit_th->session_id;
7061 short_retry_limit = short_retry_limit_th->short_retry_limit;
7062 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
7063 vdev_id, short_retry_limit);
7064
7065 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7066 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
7067 short_retry_limit);
7068
7069 if (ret) {
7070 WMA_LOGE("Failed to send short limit threshold command");
7071 return QDF_STATUS_E_FAILURE;
7072 }
7073 return QDF_STATUS_SUCCESS;
7074}
7075
7076/**
7077 * wma_update_long_retry_limit() - Set retry limit for long frames
7078 * @wma_handle: WMA handle
7079 * @long_retry_limit_th: retry limir count for long frames
7080 *
7081 * This function is used to configure the transmission retry limit at which
7082 * long frames needs to be retry
7083 *
7084 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7085 */
7086static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
7087 struct sme_long_retry_limit *long_retry_limit_th)
7088{
7089 uint8_t vdev_id;
7090 uint32_t long_retry_limit;
7091 int ret;
7092
7093 if (!wma || !wma->wmi_handle) {
7094 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
7095 return QDF_STATUS_E_INVAL;
7096 }
7097 vdev_id = long_retry_limit_th->session_id;
7098 long_retry_limit = long_retry_limit_th->long_retry_limit;
7099 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7100 vdev_id, long_retry_limit);
7101
7102 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7103 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
7104 long_retry_limit);
7105
7106 if (ret) {
7107 WMA_LOGE("Failed to send long limit threshold command");
7108 return QDF_STATUS_E_FAILURE;
7109 }
7110
7111 return QDF_STATUS_SUCCESS;
7112}
7113
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05307114/*
7115 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
7116 * @wma_handle: WMA handle
7117 * @sta_inactivity_timer: sme_sta_inactivity_timeout
7118 *
7119 * This function is used to set sta_inactivity_timeout.
7120 * If a station does not send anything in sta_inactivity_timeout seconds, an
7121 * empty data frame is sent to it in order to verify whether it is
7122 * still in range. If this frame is not ACKed, the station will be
7123 * disassociated and then deauthenticated.
7124 *
7125 * Return: None
7126 */
7127void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
7128 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
7129{
7130 uint8_t vdev_id;
7131 uint32_t max_unresponsive_time;
7132 uint32_t min_inactive_time, max_inactive_time;
7133
7134 if (!wma || !wma->wmi_handle) {
7135 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
7136 return;
7137 }
7138 vdev_id = sta_inactivity_timer->session_id;
7139 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
7140 max_inactive_time = max_unresponsive_time * TWO_THIRD;
7141 min_inactive_time = max_unresponsive_time - max_inactive_time;
7142
7143 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7144 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
7145 min_inactive_time))
7146 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
7147
7148 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7149 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
7150 max_inactive_time))
7151 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
7152
7153 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7154 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
7155 max_unresponsive_time))
7156 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
7157
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007158 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 +05307159 __func__, vdev_id,
7160 min_inactive_time, max_inactive_time,
7161 max_unresponsive_time);
7162}
7163
Yingying Tang95409972016-10-20 15:16:15 +08007164#ifdef WLAN_FEATURE_WOW_PULSE
7165
7166
7167#define WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7168WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMD_fixed_param
7169
7170
7171#define WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7172WMITLV_TAG_STRUC_wmi_wow_hostwakeup_gpio_pin_pattern_config_cmd_fixed_param
7173
7174/**
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007175 * wma_send_wow_pulse_cmd() - send wmi cmd of wow pulse cmd
7176 * information to fw.
7177 * @wma_handle: wma handler
7178 * @udp_response: wow_pulse_mode pointer
7179 *
7180 * Return: Return QDF_STATUS
7181 */
Yingying Tang95409972016-10-20 15:16:15 +08007182static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7183 struct wow_pulse_mode *wow_pulse_cmd)
7184{
7185 QDF_STATUS status = QDF_STATUS_SUCCESS;
7186 wmi_buf_t buf;
7187 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *cmd;
7188 u_int16_t len;
7189
7190 len = sizeof(*cmd);
7191 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7192 if (!buf) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007193 WMA_LOGE("wmi_buf_alloc failed");
7194 return QDF_STATUS_E_NOMEM;
Yingying Tang95409972016-10-20 15:16:15 +08007195 }
7196
7197 cmd = (WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *)wmi_buf_data(buf);
7198 qdf_mem_zero(cmd, len);
7199
7200 WMITLV_SET_HDR(&cmd->tlv_header,
7201 WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM,
7202 WMITLV_GET_STRUCT_TLVLEN(
7203 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM));
7204
7205 cmd->enable = wow_pulse_cmd->wow_pulse_enable;
7206 cmd->pin = wow_pulse_cmd->wow_pulse_pin;
7207 cmd->interval_low = wow_pulse_cmd->wow_pulse_interval_low;
7208 cmd->interval_high = wow_pulse_cmd->wow_pulse_interval_high;
7209 cmd->repeat_cnt = WMI_WOW_PULSE_REPEAT_CNT;
7210
7211 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7212 WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID)) {
7213 WMA_LOGE("Failed to send send wow pulse");
7214 wmi_buf_free(buf);
7215 status = QDF_STATUS_E_FAILURE;
7216 }
7217
7218 WMA_LOGD("%s: Exit", __func__);
7219 return status;
7220}
7221
7222#undef WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7223#undef WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7224#undef WMI_WOW_PULSE_REPEAT_CNT
7225
7226#else
7227static inline QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7228 struct wow_pulse_mode *wow_pulse_cmd)
7229{
7230 return QDF_STATUS_E_FAILURE;
7231}
7232#endif
7233
7234
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307235/**
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307236 * wma_process_power_debug_stats_req() - Process the Chip Power stats collect
7237 * request and pass the Power stats request to Fw
7238 * @wma_handle: WMA handle
7239 *
7240 * Return: QDF_STATUS
7241 */
7242#ifdef WLAN_POWER_DEBUGFS
7243static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7244{
7245 wmi_pdev_get_chip_power_stats_cmd_fixed_param *cmd;
7246 int32_t len;
7247 wmi_buf_t buf;
7248 uint8_t *buf_ptr;
7249 int ret;
7250
7251 if (!wma_handle) {
7252 WMA_LOGE("%s: input pointer is NULL", __func__);
7253 return QDF_STATUS_E_FAILURE;
7254 }
7255
7256 len = sizeof(*cmd);
7257 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7258 if (!buf) {
7259 WMA_LOGE("%s: Failed allocate wmi buffer", __func__);
7260 return QDF_STATUS_E_NOMEM;
7261 }
7262
7263 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7264 cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr;
7265
7266 WMITLV_SET_HDR(&cmd->tlv_header,
7267 WMITLV_TAG_STRUC_wmi_get_chip_power_stats_cmd_fixed_param,
7268 WMITLV_GET_STRUCT_TLVLEN(
7269 wmi_pdev_get_chip_power_stats_cmd_fixed_param));
7270 cmd->pdev_id = 0;
7271
7272 WMA_LOGD("POWER_DEBUG_STATS - Get Request Params; Pdev id - %d",
7273 cmd->pdev_id);
7274 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7275 WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
7276 if (ret) {
7277 WMA_LOGE("%s: Failed to send power debug stats request",
7278 __func__);
7279 wmi_buf_free(buf);
7280 return QDF_STATUS_E_FAILURE;
7281 }
7282 return QDF_STATUS_SUCCESS;
7283}
7284#else
7285static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7286{
7287 return QDF_STATUS_SUCCESS;
7288}
7289#endif
7290
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307291/**
7292 * wma_set_arp_req_stats() - process set arp stats request command to fw
7293 * @wma_handle: WMA handle
7294 * @req_buf: set srp stats request buffer
7295 *
7296 * Return: None
7297 */
7298static void wma_set_arp_req_stats(WMA_HANDLE handle,
7299 struct set_arp_stats_params *req_buf)
7300{
7301 int status;
7302 struct set_arp_stats *arp_stats;
7303 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7304
7305 if (!wma_handle || !wma_handle->wmi_handle) {
7306 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7307 __func__);
7308 return;
7309 }
Yeshwanth Sriram Guntukad5aae7f2017-11-27 14:33:51 +05307310 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7311 WMA_LOGE("vdev id not active or not valid");
7312 return;
7313 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307314
7315 arp_stats = (struct set_arp_stats *)req_buf;
7316 status = wmi_unified_set_arp_stats_req(wma_handle->wmi_handle,
7317 arp_stats);
7318 if (status != EOK)
7319 WMA_LOGE("%s: failed to set arp stats to FW",
7320 __func__);
7321}
7322
7323/**
7324 * wma_get_arp_req_stats() - process get arp stats request command to fw
7325 * @wma_handle: WMA handle
7326 * @req_buf: get srp stats request buffer
7327 *
7328 * Return: None
7329 */
7330static void wma_get_arp_req_stats(WMA_HANDLE handle,
7331 struct get_arp_stats_params *req_buf)
7332{
7333 int status;
7334 struct get_arp_stats *arp_stats;
7335 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7336
7337 if (!wma_handle || !wma_handle->wmi_handle) {
7338 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7339 __func__);
7340 return;
7341 }
Yeshwanth Sriram Guntuka3e4d96f2017-12-19 14:09:04 +05307342 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7343 WMA_LOGE("vdev id not active or not valid");
7344 return;
7345 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307346
7347 arp_stats = (struct get_arp_stats *)req_buf;
7348 status = wmi_unified_get_arp_stats_req(wma_handle->wmi_handle,
7349 arp_stats);
7350 if (status != EOK)
7351 WMA_LOGE("%s: failed to send get arp stats to FW",
7352 __func__);
7353}
7354
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307355/**
7356 * wma_set_del_pmkid_cache() - API to set/delete PMKID cache entry in fw
7357 * @handle: WMA handle
7358 * @pmk_cache: PMK cache entry
7359 *
7360 * Return: None
7361 */
7362static void wma_set_del_pmkid_cache(WMA_HANDLE handle,
7363 struct wmi_unified_pmk_cache *pmk_cache)
7364{
7365 int status;
7366 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7367
7368 if (!wma_handle || !wma_handle->wmi_handle) {
7369 WMA_LOGE("WMA is closed, cannot send set del pmkid");
7370 return;
7371 }
7372
7373 status = wmi_unified_set_del_pmkid_cache(wma_handle->wmi_handle,
7374 pmk_cache);
7375 if (status != EOK)
7376 WMA_LOGE("failed to send set/del pmkid cmd to fw");
7377}
7378
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307379/**
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307380 * wma_send_invoke_neighbor_report() - API to send invoke neighbor report
7381 * command to fw
7382 *
7383 * @handle: WMA handle
7384 * @params: Pointer to invoke neighbor report params
7385 *
7386 * Return: None
7387 */
7388static
7389void wma_send_invoke_neighbor_report(WMA_HANDLE handle,
7390 struct wmi_invoke_neighbor_report_params *params)
7391{
7392 QDF_STATUS status;
7393 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7394
7395 if (!wma_handle || !wma_handle->wmi_handle) {
7396 WMA_LOGE("WMA is closed, cannot send invoke neighbor report");
7397 return;
7398 }
7399
7400 status = wmi_unified_invoke_neighbor_report_cmd(wma_handle->wmi_handle,
7401 params);
7402
7403 if (status != QDF_STATUS_SUCCESS)
7404 WMA_LOGE("failed to send invoke neighbor report command");
7405}
7406
lifeng66831662017-05-19 16:01:35 +08007407QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle,
7408 struct sir_set_rx_reorder_timeout_val *reorder_timeout)
7409{
7410 wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *cmd;
7411 uint32_t len;
7412 wmi_buf_t buf;
7413 int ret;
7414
7415 if (!reorder_timeout) {
7416 WMA_LOGE(FL("invalid pointer"));
7417 return QDF_STATUS_E_INVAL;
7418 }
7419
7420 if (!wma_handle) {
7421 WMA_LOGE(FL("WMA context is invald!"));
7422 return QDF_STATUS_E_INVAL;
7423 }
7424 len = sizeof(*cmd);
7425 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7426
7427 if (!buf) {
7428 WMA_LOGE(FL("Failed allocate wmi buffer"));
7429 return QDF_STATUS_E_NOMEM;
7430 }
7431 cmd = (wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *)
7432 wmi_buf_data(buf);
7433
7434 WMITLV_SET_HDR(&cmd->tlv_header,
7435 WMITLV_TAG_STRUC_wmi_pdev_set_reorder_timeout_val_cmd_fixed_param,
7436 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_reorder_timeout_val_cmd_fixed_param));
7437
7438 memcpy(cmd->rx_timeout_pri, reorder_timeout->rx_timeout_pri,
7439 sizeof(reorder_timeout->rx_timeout_pri));
7440
7441 WMA_LOGD("rx aggr record timeout: VO: %d, VI: %d, BE: %d, BK: %d",
7442 cmd->rx_timeout_pri[0], cmd->rx_timeout_pri[1],
7443 cmd->rx_timeout_pri[2], cmd->rx_timeout_pri[3]);
7444
7445 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7446 WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID);
7447 if (ret) {
7448 WMA_LOGE(FL("Failed to send aggregation timeout"));
7449 wmi_buf_free(buf);
7450 return QDF_STATUS_E_FAILURE;
7451 }
7452
7453 return QDF_STATUS_SUCCESS;
7454}
7455
7456QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle,
7457 struct sir_peer_set_rx_blocksize *peer_rx_blocksize)
7458{
7459 wmi_peer_set_rx_blocksize_cmd_fixed_param *cmd;
7460 int32_t len;
7461 wmi_buf_t buf;
7462 u_int8_t *buf_ptr;
7463 int ret;
7464
7465 if (!peer_rx_blocksize) {
7466 WMA_LOGE(FL("invalid pointer"));
7467 return QDF_STATUS_E_INVAL;
7468 }
7469
7470 if (!wma_handle) {
7471 WMA_LOGE(FL(" WMA context is invald!"));
7472 return QDF_STATUS_E_INVAL;
7473 }
7474
7475 len = sizeof(*cmd);
7476 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7477
7478 if (!buf) {
7479 WMA_LOGE(FL("Failed allocate wmi buffer"));
7480 return QDF_STATUS_E_NOMEM;
7481 }
7482
7483 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7484 cmd = (wmi_peer_set_rx_blocksize_cmd_fixed_param *) buf_ptr;
7485
7486 WMITLV_SET_HDR(&cmd->tlv_header,
7487 WMITLV_TAG_STRUC_wmi_peer_set_rx_blocksize_cmd_fixed_param,
7488 WMITLV_GET_STRUCT_TLVLEN(wmi_peer_set_rx_blocksize_cmd_fixed_param));
7489
7490 cmd->vdev_id = peer_rx_blocksize->vdev_id;
7491 cmd->rx_block_ack_win_limit =
7492 peer_rx_blocksize->rx_block_ack_win_limit;
7493 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_rx_blocksize->peer_macaddr.bytes,
7494 &cmd->peer_macaddr);
7495
7496 WMA_LOGD("rx aggr blocksize: %d", cmd->rx_block_ack_win_limit);
7497
7498 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7499 WMI_PEER_SET_RX_BLOCKSIZE_CMDID);
7500 if (ret) {
7501 WMA_LOGE(FL("Failed to send aggregation size command"));
7502 wmi_buf_free(buf);
7503 return QDF_STATUS_E_FAILURE;
7504 }
7505
7506 return QDF_STATUS_SUCCESS;
7507}
7508
lifengd217d192017-05-09 19:44:16 +08007509QDF_STATUS wma_get_chain_rssi(tp_wma_handle wma_handle,
7510 struct get_chain_rssi_req_params *req_params)
7511{
lifengfe6c3e22018-04-03 12:10:04 +08007512 wmi_pdev_div_get_rssi_antid_fixed_param *cmd;
lifengd217d192017-05-09 19:44:16 +08007513 wmi_buf_t wmi_buf;
lifengfe6c3e22018-04-03 12:10:04 +08007514 uint32_t len = sizeof(wmi_pdev_div_get_rssi_antid_fixed_param);
lifengd217d192017-05-09 19:44:16 +08007515 u_int8_t *buf_ptr;
7516
7517 if (!wma_handle) {
7518 WMA_LOGE(FL("WMA is closed, can not issue cmd"));
7519 return QDF_STATUS_E_INVAL;
7520 }
7521
7522 wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7523 if (!wmi_buf) {
7524 WMA_LOGE(FL("wmi_buf_alloc failed"));
7525 return QDF_STATUS_E_NOMEM;
7526 }
7527
7528 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7529
lifengfe6c3e22018-04-03 12:10:04 +08007530 cmd = (wmi_pdev_div_get_rssi_antid_fixed_param *)buf_ptr;
lifengd217d192017-05-09 19:44:16 +08007531 WMITLV_SET_HDR(&cmd->tlv_header,
lifengfe6c3e22018-04-03 12:10:04 +08007532 WMITLV_TAG_STRUC_wmi_pdev_div_get_rssi_antid_fixed_param,
lifengd217d192017-05-09 19:44:16 +08007533 WMITLV_GET_STRUCT_TLVLEN(
lifengfe6c3e22018-04-03 12:10:04 +08007534 wmi_pdev_div_get_rssi_antid_fixed_param));
7535 cmd->pdev_id = 0;
lifengd217d192017-05-09 19:44:16 +08007536 WMI_CHAR_ARRAY_TO_MAC_ADDR(req_params->peer_macaddr.bytes,
lifengfe6c3e22018-04-03 12:10:04 +08007537 &cmd->macaddr);
lifengd217d192017-05-09 19:44:16 +08007538
7539 if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len,
lifengfe6c3e22018-04-03 12:10:04 +08007540 WMI_PDEV_DIV_GET_RSSI_ANTID_CMDID)) {
lifengd217d192017-05-09 19:44:16 +08007541 WMA_LOGE(FL("failed to send get chain rssi command"));
7542 wmi_buf_free(wmi_buf);
7543 return QDF_STATUS_E_FAILURE;
7544 }
7545
7546 return QDF_STATUS_SUCCESS;
7547}
7548
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307549#if defined(WLAN_FEATURE_FILS_SK)
7550/**
7551 * wma_roam_scan_send_hlp() - API to send HLP IE info to fw
7552 * @wma_handle: WMA handle
7553 * @req: HLP params
7554 *
7555 * Return: QDF_STATUS
7556 */
7557static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7558 struct hlp_params *req)
7559{
7560 struct hlp_params *params;
7561 QDF_STATUS status;
7562
7563 params = qdf_mem_malloc(sizeof(*params));
7564 if (!params) {
7565 WMA_LOGE("%s : Memory allocation failed", __func__);
7566 return QDF_STATUS_E_NOMEM;
7567 }
7568
7569 params->vdev_id = req->vdev_id;
7570 params->hlp_ie_len = req->hlp_ie_len;
7571 qdf_mem_copy(params->hlp_ie, req->hlp_ie, req->hlp_ie_len);
7572 status = wmi_unified_roam_send_hlp_cmd(wma_handle->wmi_handle, params);
7573
7574 WMA_LOGD("Send HLP status %d vdev id %d", status, params->vdev_id);
7575 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
7576 params->hlp_ie, 10);
7577
7578 qdf_mem_free(params);
7579 return status;
7580}
7581#else
7582static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7583 struct hlp_params *req)
7584{
7585 return QDF_STATUS_SUCCESS;
7586}
7587#endif
7588
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307589/**
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307590 * wma_process_set_limit_off_chan() - set limit off chanel parameters
7591 * @wma_handle: pointer to wma handle
7592 * @param: pointer to sir_limit_off_chan
7593 *
7594 * Return: QDF_STATUS_SUCCESS for success or error code.
7595 */
7596static QDF_STATUS wma_process_limit_off_chan(tp_wma_handle wma_handle,
7597 struct sir_limit_off_chan *param)
7598{
7599 int32_t err;
7600 struct wmi_limit_off_chan_param limit_off_chan_param;
7601
Rajeev Kumar752d64e2017-10-05 16:32:58 -07007602 if (param->vdev_id >= wma_handle->max_bssid) {
7603 WMA_LOGE(FL("Invalid vdev_id: %d"), param->vdev_id);
7604 return QDF_STATUS_E_INVAL;
7605 }
7606 if (!wma_is_vdev_up(param->vdev_id)) {
7607 WMA_LOGE("vdev %d is not up skipping limit_off_chan_param",
7608 param->vdev_id);
7609 return QDF_STATUS_E_INVAL;
7610 }
7611
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307612 limit_off_chan_param.vdev_id = param->vdev_id;
7613 limit_off_chan_param.status = param->is_tos_active;
7614 limit_off_chan_param.max_offchan_time = param->max_off_chan_time;
7615 limit_off_chan_param.rest_time = param->rest_time;
7616 limit_off_chan_param.skip_dfs_chans = param->skip_dfs_chans;
7617
7618 err = wmi_unified_send_limit_off_chan_cmd(wma_handle->wmi_handle,
7619 &limit_off_chan_param);
7620 if (err) {
7621 WMA_LOGE("\n failed to set limit off chan cmd");
7622 return QDF_STATUS_E_FAILURE;
7623 }
7624
7625 return QDF_STATUS_SUCCESS;
7626}
7627
Arif Hussain05fb4872018-01-03 16:02:55 -08007628static QDF_STATUS wma_process_obss_color_collision_req(tp_wma_handle wma_handle,
7629 struct wmi_obss_color_collision_cfg_param *cfg)
7630{
7631 QDF_STATUS status;
7632
7633 if (cfg->vdev_id >= wma_handle->max_bssid) {
7634 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7635 return QDF_STATUS_E_INVAL;
7636 }
7637 if (!wma_is_vdev_up(cfg->vdev_id)) {
7638 WMA_LOGE("vdev %d is not up skipping obss color collision req",
7639 cfg->vdev_id);
7640 return QDF_STATUS_E_INVAL;
7641 }
7642
7643 status = wmi_unified_send_obss_color_collision_cfg_cmd(wma_handle->
7644 wmi_handle, cfg);
7645 if (QDF_IS_STATUS_ERROR(status))
7646 WMA_LOGE("Failed to send obss color collision cfg");
7647
7648 return status;
7649}
7650
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307651/**
Arif Hussainee10f902017-12-27 16:30:17 -08007652 * wma_send_obss_detection_cfg() - send obss detection cfg to firmware
7653 * @wma_handle: pointer to wma handle
7654 * @cfg: obss detection configuration
7655 *
7656 * Send obss detection configuration to firmware.
7657 *
7658 * Return: None
7659 */
7660static void wma_send_obss_detection_cfg(tp_wma_handle wma_handle,
7661 struct wmi_obss_detection_cfg_param
7662 *cfg)
7663{
7664 QDF_STATUS status;
7665
7666 if (cfg->vdev_id >= wma_handle->max_bssid) {
7667 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7668 return;
7669 }
7670 if (!wma_is_vdev_up(cfg->vdev_id)) {
7671 WMA_LOGE("vdev %d is not up skipping obss detection req",
7672 cfg->vdev_id);
7673 return;
7674 }
7675
7676 status = wmi_unified_send_obss_detection_cfg_cmd(wma_handle->wmi_handle,
7677 cfg);
7678 if (QDF_IS_STATUS_ERROR(status))
7679 WMA_LOGE("Failed to send obss detection cfg");
7680
7681 return;
7682}
7683
7684/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007685 * wma_mc_process_msg() - process wma messages and call appropriate function.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007686 * @msg: message
7687 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307688 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007689 */
Jeff Johnson5be42ab2017-09-13 09:10:39 -07007690static QDF_STATUS wma_mc_process_msg(struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007691{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307692 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007693 tp_wma_handle wma_handle;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08007694 struct cdp_vdev *txrx_vdev_handle = NULL;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07007695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007696 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307697 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007699 if (NULL == msg) {
7700 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307701 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307702 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007703 goto end;
7704 }
7705
7706 WMA_LOGD("msg->type = %x %s", msg->type,
7707 mac_trace_get_wma_msg_string(msg->type));
7708
Anurag Chouhan6d760662016-02-20 16:05:43 +05307709 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007710
7711 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007712 WMA_LOGE("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307713 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307714 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307715 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007716 goto end;
7717 }
7718
7719 switch (msg->type) {
7720
7721 /* Message posted by wmi for all control path related
7722 * FW events to serialize through mc_thread.
7723 */
7724 case WMA_PROCESS_FW_EVENT:
7725 wma_process_fw_event(wma_handle,
7726 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307727 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007728 break;
7729
7730#ifdef FEATURE_WLAN_ESE
7731 case WMA_TSM_STATS_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007732 WMA_LOGD("McThread: WMA_TSM_STATS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007733 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
7734 break;
7735#endif /* FEATURE_WLAN_ESE */
7736 case WNI_CFG_DNLD_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007737 WMA_LOGD("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307738 qdf_status = wma_wni_cfg_dnld(wma_handle);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007739 if (QDF_IS_STATUS_SUCCESS(qdf_status))
Jeff Johnsonf7ab8142017-09-13 09:04:23 -07007740 cds_wma_complete_cback();
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007741 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007742 WMA_LOGD("config download failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007743 break;
7744 case WMA_ADD_STA_SELF_REQ:
7745 txrx_vdev_handle =
7746 wma_vdev_attach(wma_handle,
7747 (struct add_sta_self_params *) msg->
7748 bodyptr, 1);
7749 if (!txrx_vdev_handle) {
7750 WMA_LOGE("Failed to attach vdev");
7751 } else {
7752 /* Register with TxRx Module for Data Ack Complete Cb */
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307753 if (soc) {
7754 cdp_data_tx_cb_set(soc, txrx_vdev_handle,
7755 wma_data_tx_ack_comp_hdlr,
7756 wma_handle);
7757 } else {
7758 WMA_LOGE("%s: SOC context is NULL", __func__);
7759 qdf_status = QDF_STATUS_E_FAILURE;
7760 goto end;
7761 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007762 }
7763 break;
7764 case WMA_DEL_STA_SELF_REQ:
7765 wma_vdev_detach(wma_handle,
7766 (struct del_sta_self_params *) msg->bodyptr, 1);
7767 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007768 case WMA_UPDATE_CHAN_LIST_REQ:
7769 wma_update_channel_list(wma_handle,
7770 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307771 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007772 break;
7773 case WMA_SET_LINK_STATE:
7774 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
7775 break;
7776 case WMA_CHNL_SWITCH_REQ:
7777 wma_set_channel(wma_handle,
7778 (tpSwitchChannelParams) msg->bodyptr);
7779 break;
7780 case WMA_ADD_BSS_REQ:
7781 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
7782 break;
7783 case WMA_ADD_STA_REQ:
7784 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
7785 break;
7786 case WMA_SET_BSSKEY_REQ:
7787 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
7788 break;
7789 case WMA_SET_STAKEY_REQ:
7790 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
7791 break;
7792 case WMA_DELETE_STA_REQ:
7793 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
7794 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07007795 case WMA_DELETE_BSS_HO_FAIL_REQ:
7796 wma_delete_bss_ho_fail(wma_handle,
7797 (tpDeleteBssParams) msg->bodyptr);
7798 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007799 case WMA_DELETE_BSS_REQ:
7800 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
7801 break;
7802 case WMA_UPDATE_EDCA_PROFILE_IND:
7803 wma_process_update_edca_param_req(wma_handle,
7804 (tEdcaParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307805 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007806 break;
7807 case WMA_SEND_BEACON_REQ:
7808 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307809 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007810 break;
7811 case WMA_SEND_PROBE_RSP_TMPL:
7812 wma_send_probe_rsp_tmpl(wma_handle,
7813 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307814 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007815 break;
7816 case WMA_CLI_SET_CMD:
7817 wma_process_cli_set_cmd(wma_handle,
7818 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307819 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007820 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07007821 case WMA_SET_PDEV_IE_REQ:
7822 wma_process_set_pdev_ie_req(wma_handle,
7823 (struct set_ie_param *)msg->bodyptr);
7824 qdf_mem_free(msg->bodyptr);
7825 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007826#if !defined(REMOVE_PKT_LOG)
7827 case WMA_PKTLOG_ENABLE_REQ:
7828 wma_pktlog_wmi_send_cmd(wma_handle,
7829 (struct ath_pktlog_wmi_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307830 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007831 break;
7832#endif /* REMOVE_PKT_LOG */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007833 case WMA_ENTER_PS_REQ:
7834 wma_enable_sta_ps_mode(wma_handle,
7835 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307836 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007837 break;
7838 case WMA_EXIT_PS_REQ:
7839 wma_disable_sta_ps_mode(wma_handle,
7840 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307841 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007842 break;
7843 case WMA_ENABLE_UAPSD_REQ:
7844 wma_enable_uapsd_mode(wma_handle,
7845 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307846 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007847 break;
7848 case WMA_DISABLE_UAPSD_REQ:
7849 wma_disable_uapsd_mode(wma_handle,
7850 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307851 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007852 break;
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08007853 case WMA_SET_DTIM_PERIOD:
7854 wma_set_dtim_period(wma_handle,
7855 (struct set_dtim_params *)msg->bodyptr);
7856 qdf_mem_free(msg->bodyptr);
7857 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007858 case WMA_SET_TX_POWER_REQ:
7859 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
7860 break;
7861 case WMA_SET_MAX_TX_POWER_REQ:
7862 wma_set_max_tx_power(wma_handle,
7863 (tpMaxTxPowerParams) msg->bodyptr);
7864 break;
7865 case WMA_SET_KEEP_ALIVE:
7866 wma_set_keepalive_req(wma_handle,
7867 (tSirKeepAliveReq *) msg->bodyptr);
7868 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08007869#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007870 case WMA_SET_PLM_REQ:
7871 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
7872 break;
7873#endif
7874 case WMA_GET_STATISTICS_REQ:
7875 wma_get_stats_req(wma_handle,
7876 (tAniGetPEStatsReq *) msg->bodyptr);
7877 break;
7878
7879 case WMA_CONFIG_PARAM_UPDATE_REQ:
Rajeev Kumar156188e2017-01-21 17:23:52 -08007880 wma_update_cfg_params(wma_handle, msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007881 break;
7882
7883 case WMA_UPDATE_OP_MODE:
7884 wma_process_update_opmode(wma_handle,
7885 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307886 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007887 break;
7888 case WMA_UPDATE_RX_NSS:
7889 wma_process_update_rx_nss(wma_handle,
7890 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307891 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007892 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007893 case WMA_UPDATE_MEMBERSHIP:
7894 wma_process_update_membership(wma_handle,
7895 (tUpdateMembership *) msg->bodyptr);
7896 break;
7897 case WMA_UPDATE_USERPOS:
7898 wma_process_update_userpos(wma_handle,
7899 (tUpdateUserPos *) msg->bodyptr);
7900 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007901 case WMA_UPDATE_BEACON_IND:
7902 wma_process_update_beacon_params(wma_handle,
7903 (tUpdateBeaconParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307904 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007905 break;
7906
7907 case WMA_ADD_TS_REQ:
7908 wma_add_ts_req(wma_handle, (tAddTsParams *) msg->bodyptr);
7909 break;
7910
7911 case WMA_DEL_TS_REQ:
7912 wma_del_ts_req(wma_handle, (tDelTsParams *) msg->bodyptr);
7913 break;
7914
7915 case WMA_AGGR_QOS_REQ:
7916 wma_aggr_qos_req(wma_handle, (tAggrAddTsParams *) msg->bodyptr);
7917 break;
7918
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007919 case WMA_8023_MULTICAST_LIST_REQ:
7920 wma_process_mcbc_set_filter_req(wma_handle,
7921 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307922 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007923 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007924 case WMA_ROAM_SCAN_OFFLOAD_REQ:
7925 /*
7926 * Main entry point or roaming directives from CSR.
7927 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08007928 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007929 (tSirRoamOffloadScanReq *) msg->bodyptr);
7930 break;
7931
7932 case WMA_RATE_UPDATE_IND:
7933 wma_process_rate_update_indicate(wma_handle,
7934 (tSirRateUpdateInd *) msg->bodyptr);
7935 break;
7936
7937#ifdef FEATURE_WLAN_TDLS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007938 case WMA_UPDATE_TDLS_PEER_STATE:
7939 wma_update_tdls_peer_state(wma_handle,
7940 (tTdlsPeerStateParams *) msg->bodyptr);
7941 break;
7942 case WMA_TDLS_SET_OFFCHAN_MODE:
7943 wma_set_tdls_offchan_mode(wma_handle,
7944 (tdls_chan_switch_params *)msg->bodyptr);
7945 break;
7946#endif /* FEATURE_WLAN_TDLS */
7947 case WMA_ADD_PERIODIC_TX_PTRN_IND:
7948 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
7949 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307950 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007951 break;
7952 case WMA_DEL_PERIODIC_TX_PTRN_IND:
7953 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
7954 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307955 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 break;
7957 case WMA_TX_POWER_LIMIT:
7958 wma_process_tx_power_limits(wma_handle,
7959 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307960 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007961 break;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08007962 case WMA_SEND_ADDBA_REQ:
7963 wma_process_send_addba_req(wma_handle,
7964 (struct send_add_ba_req *)msg->bodyptr);
7965 break;
7966
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007967#ifdef FEATURE_WLAN_CH_AVOID
7968 case WMA_CH_AVOID_UPDATE_REQ:
7969 wma_process_ch_avoid_update_req(wma_handle,
7970 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307971 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007972 break;
7973#endif /* FEATURE_WLAN_CH_AVOID */
7974#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
7975 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
7976 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307977 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007978 break;
7979#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
7980 case WMA_DHCP_START_IND:
7981 case WMA_DHCP_STOP_IND:
7982 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307983 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007984 break;
7985
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007986 case WMA_IBSS_CESIUM_ENABLE_IND:
7987 wma_process_cesium_enable_ind(wma_handle);
7988 break;
7989 case WMA_GET_IBSS_PEER_INFO_REQ:
7990 wma_process_get_peer_info_req(wma_handle,
7991 (tSirIbssGetPeerInfoReqParams *)
7992 msg->bodyptr);
7993 qdf_mem_free(msg->bodyptr);
7994 break;
7995 case WMA_TX_FAIL_MONITOR_IND:
7996 wma_process_tx_fail_monitor_ind(wma_handle,
7997 (tAniTXFailMonitorInd *) msg->bodyptr);
7998 qdf_mem_free(msg->bodyptr);
7999 break;
8000
8001 case WMA_RMC_ENABLE_IND:
8002 wma_process_rmc_enable_ind(wma_handle);
8003 break;
8004 case WMA_RMC_DISABLE_IND:
8005 wma_process_rmc_disable_ind(wma_handle);
8006 break;
8007 case WMA_RMC_ACTION_PERIOD_IND:
8008 wma_process_rmc_action_period_ind(wma_handle);
8009 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008010 case WMA_INIT_THERMAL_INFO_CMD:
8011 wma_process_init_thermal_info(wma_handle,
8012 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308013 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008014 break;
8015
8016 case WMA_SET_THERMAL_LEVEL:
8017 wma_process_set_thermal_level(wma_handle, msg->bodyval);
8018 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05308019#ifdef CONFIG_HL_SUPPORT
8020 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
8021 wma_process_init_bad_peer_tx_ctl_info(
8022 wma_handle,
8023 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
8024 qdf_mem_free(msg->bodyptr);
8025 break;
8026#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008027 case WMA_SET_MIMOPS_REQ:
8028 wma_process_set_mimops_req(wma_handle,
8029 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308030 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008031 break;
8032 case WMA_SET_SAP_INTRABSS_DIS:
8033 wma_set_vdev_intrabss_fwd(wma_handle,
8034 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308035 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008036 break;
Will Huanga9814592017-05-24 15:47:58 +08008037 case WMA_GET_PEER_INFO:
8038 wma_get_peer_info(wma_handle, msg->bodyptr);
8039 qdf_mem_free(msg->bodyptr);
8040 break;
8041 case WMA_GET_PEER_INFO_EXT:
8042 wma_get_peer_info_ext(wma_handle, msg->bodyptr);
8043 qdf_mem_free(msg->bodyptr);
8044 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008045 case WMA_MODEM_POWER_STATE_IND:
8046 wma_notify_modem_power_state(wma_handle,
8047 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308048 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008049 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008050#ifdef WLAN_FEATURE_STATS_EXT
8051 case WMA_STATS_EXT_REQUEST:
8052 wma_stats_ext_req(wma_handle,
8053 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308054 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008055 break;
8056#endif /* WLAN_FEATURE_STATS_EXT */
8057 case WMA_HIDDEN_SSID_VDEV_RESTART:
8058 wma_hidden_ssid_vdev_restart(wma_handle,
8059 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008060 break;
8061#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
8062 case WMA_WLAN_EXT_WOW:
8063 wma_enable_ext_wow(wma_handle,
8064 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308065 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008066 break;
8067 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
8068 wma_set_app_type1_params_in_fw(wma_handle,
8069 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308070 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008071 break;
8072 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
8073 wma_set_app_type2_params_in_fw(wma_handle,
8074 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308075 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008076 break;
8077#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
8078#ifdef FEATURE_WLAN_EXTSCAN
8079 case WMA_EXTSCAN_START_REQ:
8080 wma_start_extscan(wma_handle,
8081 (tSirWifiScanCmdReqParams *) 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_EXTSCAN_STOP_REQ:
8085 wma_stop_extscan(wma_handle,
8086 (tSirExtScanStopReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308087 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008088 break;
8089 case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:
8090 wma_extscan_start_hotlist_monitor(wma_handle,
8091 (tSirExtScanSetBssidHotListReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308092 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008093 break;
8094 case WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
8095 wma_extscan_stop_hotlist_monitor(wma_handle,
8096 (tSirExtScanResetBssidHotlistReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308097 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008098 break;
8099 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
8100 wma_extscan_start_change_monitor(wma_handle,
8101 (tSirExtScanSetSigChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308102 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008103 break;
8104 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
8105 wma_extscan_stop_change_monitor(wma_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008106 (tSirExtScanResetSignificantChangeReqParams *)
8107 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308108 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008109 break;
8110 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
8111 wma_extscan_get_cached_results(wma_handle,
8112 (tSirExtScanGetCachedResultsReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308113 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008114 break;
8115 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
8116 wma_extscan_get_capabilities(wma_handle,
8117 (tSirGetExtScanCapabilitiesReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308118 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008119 break;
8120 case WMA_SET_EPNO_LIST_REQ:
8121 wma_set_epno_network_list(wma_handle,
8122 (struct wifi_epno_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308123 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008124 break;
Kapil Gupta5cda2252016-12-29 18:44:26 +05308125 case WMA_SET_PER_ROAM_CONFIG_CMD:
8126 wma_update_per_roam_config(wma_handle,
8127 (struct wmi_per_roam_config_req *)msg->bodyptr);
8128 qdf_mem_free(msg->bodyptr);
8129 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008130 case WMA_SET_PASSPOINT_LIST_REQ:
8131 /* Issue reset passpoint network list first and clear
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008132 * the entries
8133 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008134 wma_reset_passpoint_network_list(wma_handle,
8135 (struct wifi_passpoint_req *)msg->bodyptr);
8136
8137 wma_set_passpoint_network_list(wma_handle,
8138 (struct wifi_passpoint_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308139 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008140 break;
8141 case WMA_RESET_PASSPOINT_LIST_REQ:
8142 wma_reset_passpoint_network_list(wma_handle,
8143 (struct wifi_passpoint_req *)msg->bodyptr);
8144 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008145#endif /* FEATURE_WLAN_EXTSCAN */
8146 case WMA_SET_SCAN_MAC_OUI_REQ:
8147 wma_scan_probe_setoui(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308148 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008149 break;
8150#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8151 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
8152 wma_process_ll_stats_clear_req(wma_handle,
8153 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308154 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008155 break;
8156 case WMA_LINK_LAYER_STATS_SET_REQ:
8157 wma_process_ll_stats_set_req(wma_handle,
8158 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308159 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008160 break;
8161 case WMA_LINK_LAYER_STATS_GET_REQ:
8162 wma_process_ll_stats_get_req(wma_handle,
8163 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308164 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008165 break;
Zhang Qian73c348a2017-03-13 16:15:55 +08008166 case WDA_LINK_LAYER_STATS_SET_THRESHOLD:
8167 wma_config_stats_ext_threshold(wma_handle,
8168 (struct sir_ll_ext_stats_threshold *)msg->bodyptr);
8169 qdf_mem_free(msg->bodyptr);
8170 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008171#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008172#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008173 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
8174 wma_process_roam_synch_fail(wma_handle,
8175 (struct roam_offload_synch_fail *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308176 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008177 break;
8178 case SIR_HAL_ROAM_INVOKE:
8179 wma_process_roam_invoke(wma_handle,
8180 (struct wma_roam_invoke_cmd *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308181 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182 break;
8183#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
8184#ifdef WLAN_FEATURE_NAN
8185 case WMA_NAN_REQUEST:
8186 wma_nan_req(wma_handle, (tNanRequest *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308187 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008188 break;
8189#endif /* WLAN_FEATURE_NAN */
8190 case SIR_HAL_SET_BASE_MACADDR_IND:
8191 wma_set_base_macaddr_indicate(wma_handle,
8192 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308193 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008194 break;
8195 case WMA_LINK_STATUS_GET_REQ:
8196 wma_process_link_status_req(wma_handle,
8197 (tAniGetLinkStatus *) msg->bodyptr);
8198 break;
8199 case WMA_GET_TEMPERATURE_REQ:
8200 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308201 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008202 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07008203 case WMA_TSF_GPIO_PIN:
8204 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
8205 break;
8206
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008207#ifdef DHCP_SERVER_OFFLOAD
8208 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
8209 wma_process_dhcpserver_offload(wma_handle,
8210 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308211 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008212 break;
8213#endif /* DHCP_SERVER_OFFLOAD */
8214#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8215 case WMA_LED_FLASHING_REQ:
Jeff Johnson5a6b6602017-10-04 14:44:30 -07008216 wma_set_led_flashing(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308217 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008218 break;
8219#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
8220 case SIR_HAL_SET_MAS:
8221 wma_process_set_mas(wma_handle,
8222 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308223 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008224 break;
8225 case SIR_HAL_SET_MIRACAST:
8226 wma_process_set_miracast(wma_handle,
8227 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308228 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008229 break;
8230 case SIR_HAL_CONFIG_STATS_FACTOR:
8231 wma_config_stats_factor(wma_handle,
8232 (struct sir_stats_avg_factor *)
8233 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308234 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008235 break;
8236 case SIR_HAL_CONFIG_GUARD_TIME:
8237 wma_config_guard_time(wma_handle,
8238 (struct sir_guard_time_request *)
8239 msg->bodyptr);
Vignesh Viswanathan9fa8fef2017-12-12 14:45:38 +05308240 qdf_mem_free(msg->bodyptr);
8241 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008242 case SIR_HAL_START_STOP_LOGGING:
8243 wma_set_wifi_start_packet_stats(wma_handle,
8244 (struct sir_wifi_start_log *)msg->bodyptr);
8245 wma_enable_specific_fw_logs(wma_handle,
8246 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308247 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008248 break;
8249 case SIR_HAL_FLUSH_LOG_TO_FW:
8250 wma_send_flush_logs_to_fw(wma_handle);
8251 /* Body ptr is NULL here */
8252 break;
8253 case WMA_SET_RSSI_MONITOR_REQ:
8254 wma_set_rssi_monitoring(wma_handle,
8255 (struct rssi_monitor_req *)msg->bodyptr);
Prakash Dhavali87ddca32016-11-29 17:02:11 -08008256 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008257 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308258 case SIR_HAL_PDEV_SET_PCL_TO_FW:
8259 wma_send_pdev_set_pcl_cmd(wma_handle,
8260 (struct wmi_pcl_chan_weights *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308261 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008262 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308263 case SIR_HAL_PDEV_SET_HW_MODE:
8264 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008265 (struct policy_mgr_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308266 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008267 break;
8268 case WMA_OCB_SET_CONFIG_CMD:
8269 wma_ocb_set_config_req(wma_handle,
8270 (struct sir_ocb_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308271 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008272 break;
8273 case WMA_OCB_SET_UTC_TIME_CMD:
8274 wma_ocb_set_utc_time(wma_handle,
8275 (struct sir_ocb_utc *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308276 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008277 break;
8278 case WMA_OCB_START_TIMING_ADVERT_CMD:
8279 wma_ocb_start_timing_advert(wma_handle,
8280 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308281 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008282 break;
8283 case WMA_OCB_STOP_TIMING_ADVERT_CMD:
8284 wma_ocb_stop_timing_advert(wma_handle,
8285 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308286 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008287 break;
8288 case WMA_DCC_CLEAR_STATS_CMD:
8289 wma_dcc_clear_stats(wma_handle,
8290 (struct sir_dcc_clear_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308291 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008292 break;
8293 case WMA_OCB_GET_TSF_TIMER_CMD:
8294 wma_ocb_get_tsf_timer(wma_handle,
8295 (struct sir_ocb_get_tsf_timer *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308296 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008297 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07008298 case WMA_SET_WISA_PARAMS:
8299 wma_set_wisa_params(wma_handle,
8300 (struct sir_wisa_params *)msg->bodyptr);
8301 qdf_mem_free(msg->bodyptr);
8302 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008303 case WMA_DCC_GET_STATS_CMD:
8304 wma_dcc_get_stats(wma_handle,
8305 (struct sir_dcc_get_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308306 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008307 break;
8308 case WMA_DCC_UPDATE_NDL_CMD:
8309 wma_dcc_update_ndl(wma_handle,
8310 (struct sir_dcc_update_ndl *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308311 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008312 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308313 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
8314 wma_send_pdev_set_dual_mac_config(wma_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008315 (struct policy_mgr_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308316 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008317 break;
8318 case WMA_SET_IE_INFO:
8319 wma_process_set_ie_info(wma_handle,
8320 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308321 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008322 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008323 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
8324 wma_send_pdev_set_antenna_mode(wma_handle,
8325 (struct sir_antenna_mode_param *)msg->bodyptr);
8326 qdf_mem_free(msg->bodyptr);
8327 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008328 case WMA_LRO_CONFIG_CMD:
8329 wma_lro_config_cmd(wma_handle,
Dhanashri Atre09828f12016-11-13 10:36:58 -08008330 (struct cdp_lro_hash_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308331 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008332 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08008333 case WMA_GW_PARAM_UPDATE_REQ:
8334 wma_set_gateway_params(wma_handle,
8335 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08008336 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08008337 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05308338 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
8339 wma_send_adapt_dwelltime_params(wma_handle,
8340 (struct adaptive_dwelltime_params *)msg->bodyptr);
8341 qdf_mem_free(msg->bodyptr);
8342 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08008343 case WMA_HT40_OBSS_SCAN_IND:
8344 wma_send_ht40_obss_scanind(wma_handle,
8345 (struct obss_ht40_scanind *)msg->bodyptr);
8346 qdf_mem_free(msg->bodyptr);
8347 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07008348 case WMA_ADD_BCN_FILTER_CMDID:
8349 wma_add_beacon_filter(wma_handle, msg->bodyptr);
8350 qdf_mem_free(msg->bodyptr);
8351 break;
8352 case WMA_REMOVE_BCN_FILTER_CMDID:
8353 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
8354 qdf_mem_free(msg->bodyptr);
8355 break;
Arun Khandavalli2476ef52016-04-26 20:19:43 +05308356 case WDA_BPF_GET_CAPABILITIES_REQ:
8357 wma_get_bpf_capabilities(wma_handle);
8358 break;
8359 case WDA_BPF_SET_INSTRUCTIONS_REQ:
8360 wma_set_bpf_instructions(wma_handle, msg->bodyptr);
8361 qdf_mem_free(msg->bodyptr);
8362 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05308363 case SIR_HAL_POWER_DBG_CMD:
8364 wma_process_hal_pwr_dbg_cmd(wma_handle,
8365 msg->bodyptr);
8366 qdf_mem_free(msg->bodyptr);
8367 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05308368 case WMA_UPDATE_WEP_DEFAULT_KEY:
8369 wma_update_wep_default_key(wma_handle,
8370 (struct wep_update_default_key_idx *)msg->bodyptr);
8371 qdf_mem_free(msg->bodyptr);
8372 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05308373 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
8374 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
8375 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05308376 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
8377 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
8378 qdf_mem_free(msg->bodyptr);
8379 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05308380 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
8381 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
8382 qdf_mem_free(msg->bodyptr);
8383 break;
8384 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
8385 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
8386 qdf_mem_free(msg->bodyptr);
8387 break;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05308388 case SIR_HAL_POWER_DEBUG_STATS_REQ:
8389 wma_process_power_debug_stats_req(wma_handle);
8390 break;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05308391 case WMA_GET_RCPI_REQ:
8392 wma_get_rcpi_req(wma_handle,
8393 (struct sme_rcpi_req *)msg->bodyptr);
8394 qdf_mem_free(msg->bodyptr);
8395 break;
Yingying Tang95409972016-10-20 15:16:15 +08008396 case WMA_SET_WOW_PULSE_CMD:
8397 wma_send_wow_pulse_cmd(wma_handle,
8398 (struct wow_pulse_mode *)msg->bodyptr);
8399 qdf_mem_free(msg->bodyptr);
8400 break;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05308401 case WMA_SET_DBS_SCAN_SEL_CONF_PARAMS:
8402 wma_send_dbs_scan_selection_params(wma_handle,
8403 (struct wmi_dbs_scan_sel_params *)msg->bodyptr);
8404 qdf_mem_free(msg->bodyptr);
8405 break;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05308406 case WMA_SET_ARP_STATS_REQ:
8407 wma_set_arp_req_stats(wma_handle,
8408 (struct set_arp_stats_params *)msg->bodyptr);
8409 qdf_mem_free(msg->bodyptr);
8410 break;
8411 case WMA_GET_ARP_STATS_REQ:
8412 wma_get_arp_req_stats(wma_handle,
8413 (struct get_arp_stats_params *)msg->bodyptr);
8414 qdf_mem_free(msg->bodyptr);
8415 break;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308416 case SIR_HAL_SET_DEL_PMKID_CACHE:
8417 wma_set_del_pmkid_cache(wma_handle,
8418 (struct wmi_unified_pmk_cache *) msg->bodyptr);
8419 qdf_mem_free(msg->bodyptr);
8420 break;
8421 case SIR_HAL_HLP_IE_INFO:
8422 wma_roam_scan_send_hlp(wma_handle,
8423 (struct hlp_params *)msg->bodyptr);
8424 qdf_mem_free(msg->bodyptr);
8425 break;
Ganesh Kondabattini35739572017-06-21 16:26:39 +05308426 case WMA_SET_LIMIT_OFF_CHAN:
8427 wma_process_limit_off_chan(wma_handle, msg->bodyptr);
8428 qdf_mem_free(msg->bodyptr);
8429 break;
Arif Hussainee10f902017-12-27 16:30:17 -08008430 case WMA_OBSS_DETECTION_REQ:
8431 wma_send_obss_detection_cfg(wma_handle, msg->bodyptr);
8432 qdf_mem_free(msg->bodyptr);
8433 break;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05308434 case WMA_INVOKE_NEIGHBOR_REPORT:
8435 wma_send_invoke_neighbor_report(wma_handle, msg->bodyptr);
8436 qdf_mem_free(msg->bodyptr);
8437 break;
Arif Hussain05fb4872018-01-03 16:02:55 -08008438 case WMA_OBSS_COLOR_COLLISION_REQ:
8439 wma_process_obss_color_collision_req(wma_handle, msg->bodyptr);
8440 qdf_mem_free(msg->bodyptr);
8441 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008442 default:
Dustin Brown86534fb2017-01-24 14:28:20 -08008443 WMA_LOGE("Unhandled WMA message of type %d", msg->type);
8444 if (msg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308445 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446 }
8447end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308448 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008449}
8450
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008451QDF_STATUS wma_mc_process_handler(struct scheduler_msg *msg)
8452{
Jeff Johnson5be42ab2017-09-13 09:10:39 -07008453 return wma_mc_process_msg(msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008454}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008456/**
8457 * wma_log_completion_timeout() - Log completion timeout
8458 * @data: Timeout handler data
8459 *
8460 * This function is called when log completion timer expires
8461 *
8462 * Return: None
8463 */
8464void wma_log_completion_timeout(void *data)
8465{
8466 tp_wma_handle wma_handle;
8467
Jeff Johnson11d7c9d2018-05-06 15:44:09 -07008468 WMA_LOGE("%s: Timeout occurred for log completion command", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008469
8470 wma_handle = (tp_wma_handle) data;
8471 if (!wma_handle)
8472 WMA_LOGE("%s: Invalid WMA handle", __func__);
8473
8474 /* Though we did not receive any event from FW,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008475 * we can flush whatever logs we have with us
8476 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008477 cds_logging_set_fw_flush_complete();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008478}
8479
8480/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308481 * wma_map_pcl_weights() - Map PCL weights
8482 * @pcl_weight: Internal PCL weights
8483 *
8484 * Maps the internal weights of PCL to the weights needed by FW
8485 *
8486 * Return: Mapped channel weight of type wmi_pcl_chan_weight
8487 */
8488static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
8489{
8490 switch (pcl_weight) {
8491 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
8492 return WMI_PCL_WEIGHT_VERY_HIGH;
8493 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
8494 return WMI_PCL_WEIGHT_HIGH;
8495 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
8496 return WMI_PCL_WEIGHT_MEDIUM;
8497 case WEIGHT_OF_NON_PCL_CHANNELS:
8498 return WMI_PCL_WEIGHT_LOW;
8499 default:
8500 return WMI_PCL_WEIGHT_DISALLOW;
8501 }
8502}
8503
8504/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308505 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008506 * @wma_handle: WMA handle
8507 * @msg: PCL structure containing the PCL and the number of channels
8508 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308509 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008510 * firmware. The DBS Manager is the consumer of this information in the WLAN
8511 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
8512 * to migrate to a new channel without host driver involvement. An example of
8513 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
8514 * manage the channel selection without firmware involvement.
8515 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308516 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
8517 * channel list. The weights corresponds to the channels sent in
8518 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
8519 * weightage compared to the non PCL channels.
8520 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008521 * Return: Success if the cmd is sent successfully to the firmware
8522 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308523QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
8524 struct wmi_pcl_chan_weights *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008525{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308526 uint32_t i;
8527 QDF_STATUS status;
8528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008529 if (!wma_handle) {
8530 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8531 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308532 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008533 }
8534
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308535 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
8536 msg->saved_chan_list[i] =
8537 wma_handle->saved_chan.channel_list[i];
8538 }
8539
8540 msg->saved_num_chan = wma_handle->saved_chan.num_channels;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008541 status = policy_mgr_get_valid_chan_weights(wma_handle->psoc,
8542 (struct policy_mgr_pcl_chan_weights *)msg);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308543
8544 for (i = 0; i < msg->saved_num_chan; i++) {
8545 msg->weighed_valid_list[i] =
8546 wma_map_pcl_weights(msg->weighed_valid_list[i]);
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008547 /* Dont allow roaming on 2G when 5G_ONLY configured */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008548 if ((wma_handle->bandcapability == BAND_5G) &&
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008549 (msg->saved_chan_list[i] <= MAX_24GHZ_CHANNEL)) {
8550 msg->weighed_valid_list[i] =
8551 WEIGHT_OF_DISALLOWED_CHANNELS;
8552 }
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308553 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
8554 msg->saved_chan_list[i], i,
8555 msg->weighed_valid_list[i]);
8556 }
8557
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308558 if (!QDF_IS_STATUS_SUCCESS(status)) {
8559 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
8560 return status;
8561 }
8562
8563 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle, msg))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308564 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05308565
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308566 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008567}
8568
8569/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308570 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008571 * @wma_handle: WMA handle
8572 * @msg: Structure containing the following parameters
8573 *
8574 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
8575 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
8576 *
8577 * Provides notification to the WLAN firmware that host driver is requesting a
8578 * HardWare (HW) Mode change. This command is needed to support iHelium in the
8579 * configurations that include the Dual Band Simultaneous (DBS) feature.
8580 *
8581 * Return: Success if the cmd is sent successfully to the firmware
8582 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308583QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008584 struct policy_mgr_hw_mode *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008585{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008586 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008587 struct wma_target_req *timeout_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008588
8589 if (!wma_handle) {
8590 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8591 __func__);
8592 /* Handle is NULL. Will not be able to send failure
8593 * response as well
8594 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308595 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008596 }
8597
8598 if (!msg) {
8599 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
8600 /* Lets try to free the active command list */
8601 goto fail;
8602 }
8603
Dustin Brownec2c92e2017-07-26 11:13:49 -07008604 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8605 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT);
Govind Singhf25a0f12016-03-08 16:09:48 +05308606 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008607 msg->hw_mode_index)) {
8608 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008609 goto fail;
Krunal Sonicebcc292017-06-14 19:59:20 -07008610 }
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008611 timeout_msg = wma_fill_hold_req(wma_handle, 0,
8612 SIR_HAL_PDEV_SET_HW_MODE,
8613 WMA_PDEV_SET_HW_MODE_RESP, NULL,
8614 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT - 1);
8615 if (!timeout_msg) {
8616 WMA_LOGE("Failed to allocate request for SIR_HAL_PDEV_SET_HW_MODE");
8617 wma_remove_req(wma_handle, 0, WMA_PDEV_SET_HW_MODE_RESP);
8618 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008619
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308620 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008621fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308622 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008623 if (!param) {
8624 WMA_LOGE("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308625 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008626 }
8627 param->status = SET_HW_MODE_STATUS_ECANCELED;
8628 param->cfgd_hw_mode_index = 0;
8629 param->num_vdev_mac_entries = 0;
8630 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308631 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008632 (void *) param, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308633 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008634}
8635
8636/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308637 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008638 * @wma_handle: WMA handle
8639 * @msg: Dual MAC config parameters
8640 *
8641 * Configures WLAN firmware with the dual MAC features
8642 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308643 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008644 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308645QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008646 struct policy_mgr_dual_mac_config *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008647{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308648 QDF_STATUS status;
8649
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008650 if (!wma_handle) {
8651 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8652 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308653 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008654 }
8655
8656 if (!msg) {
8657 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308658 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008659 }
8660
Krunal Sonia5ccb802017-07-03 12:59:40 -07008661 /*
8662 * aquire the wake lock here and release it in response handler function
8663 * In error condition, release the wake lock right away
8664 */
8665 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8666 WMA_VDEV_PLCY_MGR_CMD_TIMEOUT);
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308667 status = wmi_unified_pdev_set_dual_mac_config_cmd(
8668 wma_handle->wmi_handle,
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -08008669 (struct policy_mgr_dual_mac_config *)msg);
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308670 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308671 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308672 __func__, status);
Krunal Sonia5ccb802017-07-03 12:59:40 -07008673 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308674 return status;
8675 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008676 policy_mgr_update_dbs_req_config(wma_handle->psoc,
8677 msg->scan_config, msg->fw_mode_config);
Govind Singhf25a0f12016-03-08 16:09:48 +05308678
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308679 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008680}
8681
8682/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008683 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
8684 * @wma_handle: WMA handle
8685 * @msg: Antenna mode parameters
8686 *
8687 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
8688 * modify the number of TX/RX chains from host
8689 *
8690 * Return: QDF_STATUS. 0 on success.
8691 */
8692QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
8693 struct sir_antenna_mode_param *msg)
8694{
8695 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
8696 wmi_buf_t buf;
8697 uint32_t len;
8698 QDF_STATUS status = QDF_STATUS_SUCCESS;
8699 struct sir_antenna_mode_resp *param;
8700
8701 if (!wma_handle) {
8702 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8703 __func__);
8704 return QDF_STATUS_E_NULL_VALUE;
8705 }
8706
8707 if (!msg) {
8708 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
8709 return QDF_STATUS_E_NULL_VALUE;
8710 }
8711
8712 len = sizeof(*cmd);
8713
8714 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
8715 if (!buf) {
8716 WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
8717 status = QDF_STATUS_E_NOMEM;
8718 goto resp;
8719 }
8720
8721 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
8722 WMITLV_SET_HDR(&cmd->tlv_header,
8723 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
8724 WMITLV_GET_STRUCT_TLVLEN(
8725 wmi_pdev_set_antenna_mode_cmd_fixed_param));
8726
8727 cmd->pdev_id = WMI_PDEV_ID_SOC;
8728 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
8729 cmd->num_txrx_chains = msg->num_rx_chains;
8730 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
8731
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07008732 WMA_LOGD("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008733 __func__, msg->num_tx_chains,
8734 msg->num_rx_chains, cmd->num_txrx_chains);
8735
8736 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
8737 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
8738 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_ANTENNA_MODE_CMDID",
8739 __func__);
8740 wmi_buf_free(buf);
8741 status = QDF_STATUS_E_FAILURE;
8742 goto resp;
8743 }
8744 status = QDF_STATUS_SUCCESS;
8745
8746resp:
8747 param = qdf_mem_malloc(sizeof(*param));
8748 if (!param) {
8749 WMA_LOGE("%s: Memory allocation failed", __func__);
8750 return QDF_STATUS_E_NOMEM;
8751 }
8752 param->status = (status) ?
8753 SET_ANTENNA_MODE_STATUS_ECANCELED :
8754 SET_ANTENNA_MODE_STATUS_OK;
8755 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
8756 __func__, param->status);
8757 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
8758 (void *) param, 0);
8759 return status;
8760}
8761
8762/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008763 * wma_crash_inject() - sends command to FW to simulate crash
8764 * @wma_handle: pointer of WMA context
8765 * @type: subtype of the command
8766 * @delay_time_ms: time in milliseconds for FW to delay the crash
8767 *
8768 * This function will send a command to FW in order to simulate different
8769 * kinds of FW crashes.
8770 *
Govind Singhd76a5b02016-03-08 15:12:14 +05308771 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008772 */
Yu Wang46082dc2017-09-19 12:25:38 +08008773QDF_STATUS wma_crash_inject(WMA_HANDLE wma_handle, uint32_t type,
8774 uint32_t delay_time_ms)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008775{
Govind Singhd76a5b02016-03-08 15:12:14 +05308776 struct crash_inject param;
Yu Wang46082dc2017-09-19 12:25:38 +08008777 tp_wma_handle wma = (tp_wma_handle)wma_handle;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008778
Govind Singhd76a5b02016-03-08 15:12:14 +05308779 param.type = type;
8780 param.delay_time_ms = delay_time_ms;
Yu Wang46082dc2017-09-19 12:25:38 +08008781 return wmi_crash_inject(wma->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008782}
Govind Singhd76a5b02016-03-08 15:12:14 +05308783
Manjunathappa Prakash7b0ad462018-04-15 00:37:16 -07008784#ifdef RECEIVE_OFFLOAD
Dhanashri Atre09828f12016-11-13 10:36:58 -08008785int wma_lro_init(struct cdp_lro_hash_config *lro_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008786{
Rajeev Kumarb60abe42017-01-21 15:39:31 -08008787 struct scheduler_msg msg = {0};
Dhanashri Atre09828f12016-11-13 10:36:58 -08008788 struct cdp_lro_hash_config *iwcmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008789
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308790 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008791 if (!iwcmd) {
8792 WMA_LOGE("memory allocation for WMA_LRO_CONFIG_CMD failed!");
8793 return -ENOMEM;
8794 }
8795
8796 *iwcmd = *lro_config;
8797
8798 msg.type = WMA_LRO_CONFIG_CMD;
8799 msg.reserved = 0;
8800 msg.bodyptr = iwcmd;
8801
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308802 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08008803 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008804 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308805 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008806 return -EAGAIN;
8807 }
8808
8809 WMA_LOGD("sending the LRO configuration to the fw");
8810 return 0;
8811}
8812#endif
Leo Chang96464902016-10-28 11:10:54 -07008813
8814void wma_peer_set_default_routing(void *scn_handle, uint8_t *peer_macaddr,
8815 uint8_t vdev_id, bool hash_based, uint8_t ring_num)
8816{
8817 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8818 struct peer_set_params param;
8819
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308820 if (!wma) {
8821 WMA_LOGE("%s:wma_handle is NULL", __func__);
8822 return;
8823 }
Leo Chang96464902016-10-28 11:10:54 -07008824
8825 /* TODO: Need bit definitions for ring number and hash based routing
8826 * fields in common wmi header file
8827 */
8828 param.param_id = WMI_HOST_PEER_SET_DEFAULT_ROUTING;
8829 param.vdev_id = vdev_id;
8830 param.param_value = ((hash_based) ? 1 : 0) | (ring_num << 1);
Jeff Johnsonf7ca9642017-10-10 16:11:49 -07008831 WMA_LOGD("%s: param_value 0x%x", __func__, param.param_value);
Leo Chang96464902016-10-28 11:10:54 -07008832 wmi_set_peer_param_send(wma->wmi_handle, peer_macaddr, &param);
Leo Chang96464902016-10-28 11:10:54 -07008833}
8834
8835int wma_peer_rx_reorder_queue_setup(void *scn_handle,
8836 uint8_t vdev_id, uint8_t *peer_macaddr, qdf_dma_addr_t hw_qdesc,
8837 int tid, uint16_t queue_no)
8838{
8839 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8840 struct rx_reorder_queue_setup_params param;
8841
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308842 if (!wma) {
8843 WMA_LOGE("%s:wma_handle is NULL", __func__);
8844 return QDF_STATUS_E_FAILURE;
8845 }
8846
Leo Chang96464902016-10-28 11:10:54 -07008847 param.tid = tid;
8848 param.vdev_id = vdev_id;
8849 param.peer_macaddr = peer_macaddr;
8850 param.hw_qdesc_paddr_lo = hw_qdesc & 0xffffffff;
8851 param.hw_qdesc_paddr_hi = (uint64_t)hw_qdesc >> 32;
8852 param.queue_no = queue_no;
8853
8854 return wmi_unified_peer_rx_reorder_queue_setup_send(wma->wmi_handle,
8855 &param);
8856}
8857
8858int wma_peer_rx_reorder_queue_remove(void *scn_handle,
8859 uint8_t vdev_id, uint8_t *peer_macaddr, uint32_t peer_tid_bitmap)
8860{
8861 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8862 struct rx_reorder_queue_remove_params param;
8863
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308864 if (!wma) {
8865 WMA_LOGE("%s:wma_handle is NULL", __func__);
8866 return QDF_STATUS_E_FAILURE;
8867 }
8868
Leo Chang96464902016-10-28 11:10:54 -07008869 param.vdev_id = vdev_id;
8870 param.peer_macaddr = peer_macaddr;
8871 param.peer_tid_bitmap = peer_tid_bitmap;
8872
8873 return wmi_unified_peer_rx_reorder_queue_remove_send(wma->wmi_handle,
8874 &param);
8875}
8876
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +05308877QDF_STATUS wma_configure_smps_params(uint32_t vdev_id, uint32_t param_id,
8878 uint32_t param_val)
8879{
8880 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8881 int smps_cmd_value;
8882 int status = QDF_STATUS_E_INVAL;
8883
8884 if (!wma) {
8885 WMA_LOGE("%s: Failed to get wma", __func__);
8886 return status;
8887 }
8888
8889 smps_cmd_value = param_id << WMI_SMPS_PARAM_VALUE_S;
8890 smps_cmd_value = smps_cmd_value | param_val;
8891
8892 status = wma_set_smps_params(wma, vdev_id, smps_cmd_value);
8893 if (status)
8894 WMA_LOGE("Failed to set SMPS Param");
8895
8896 return status;
8897}
8898
Leo Chang96464902016-10-28 11:10:54 -07008899
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07008900void wma_ipa_uc_stat_request(wma_cli_set_cmd_t *privcmd)
8901{
8902 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8903
Sreelakshmi Konamki7a574082017-05-15 16:53:45 +05308904 if (!wma) {
8905 WMA_LOGE("%s: Failed to get wma", __func__);
8906 return;
8907 }
8908
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07008909 if (wma_set_priv_cfg(wma, privcmd))
8910 WMA_LOGE("Failed to set wma priv congiuration");
8911}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +05308912
8913/**
8914 * wma_config_bmiss_bcnt_params() - set bmiss config parameters
8915 * @vdev_id: virtual device for the command
8916 * @first_cnt: bmiss first value
8917 * @final_cnt: bmiss final value
8918 *
8919 * Return: QDF_STATUS_SUCCESS or non-zero on failure
8920 */
8921QDF_STATUS wma_config_bmiss_bcnt_params(uint32_t vdev_id, uint32_t first_cnt,
8922 uint32_t final_cnt)
8923{
8924 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8925 int status = QDF_STATUS_E_INVAL;
8926
8927 if (!wma_handle) {
8928 WMA_LOGE("%s: Failed to get wma", __func__);
8929 return status;
8930 }
8931
8932 status = wma_roam_scan_bmiss_cnt(wma_handle, first_cnt, final_cnt,
8933 vdev_id);
8934
8935 if (status)
8936 WMA_LOGE("Failed to set Bmiss Param");
8937
8938 return status;
8939}
8940