blob: c02d370c72a28f5de231acddbce242bb60e6e377 [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"
88#include "init_deinit_ucfg.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 Gongaa6d55d2018-04-26 16:33:21 +08002059#ifdef WLAN_FEATURE_HDD_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);
2095 ucfg_mc_cp_stats_get_vdev_wake_lock_stats(vdev, &stats);
2096 len += qdf_scnprintf(buf + len, *size - len,
2097 "\n"
2098 "vdev_id %d\n"
2099 "WoW Stats\n"
2100 "\tpno_match %u\n"
2101 "\tpno_complete %u\n"
2102 "\tgscan %u\n"
2103 "\tlow_rssi %u\n"
2104 "\trssi_breach %u\n"
2105 "\tucast %u\n"
2106 "\tbcast %u\n"
2107 "\ticmpv4 %u\n"
2108 "\ticmpv6 %u\n"
2109 "\tipv4_mcast %u\n"
2110 "\tipv6_mcast %u\n"
2111 "\tipv6_mcast_ra %u\n"
2112 "\tipv6_mcast_ns %u\n"
2113 "\tipv6_mcast_na %u\n"
2114 "\toem_response %u\n"
2115 "conn_state %d\n"
2116 "dtimPeriod %d\n"
2117 "chanmode %d\n"
2118 "vht_capable %d\n"
2119 "ht_capable %d\n"
2120 "chan_width %d\n"
2121 "vdev_active %d\n"
2122 "vdev_up %d\n"
2123 "aid %d\n"
2124 "rate_flags %d\n"
2125 "nss %d\n"
2126 "tx_power %d\n"
2127 "max_tx_power %d\n"
2128 "nwType %d\n"
2129 "tx_streams %d\n"
2130 "rx_streams %d\n"
2131 "chain_mask %d\n"
2132 "nss_2g %d\n"
2133 "nss_5g %d",
2134 vdev_id,
2135 stats.pno_match_wake_up_count,
2136 stats.pno_complete_wake_up_count,
2137 stats.gscan_wake_up_count,
2138 stats.low_rssi_wake_up_count,
2139 stats.rssi_breach_wake_up_count,
2140 stats.ucast_wake_up_count,
2141 stats.bcast_wake_up_count,
2142 stats.icmpv4_count,
2143 stats.icmpv6_count,
2144 stats.ipv4_mcast_wake_up_count,
2145 stats.ipv6_mcast_wake_up_count,
2146 stats.ipv6_mcast_ra_stats,
2147 stats.ipv6_mcast_ns_stats,
2148 stats.ipv6_mcast_na_stats,
2149 stats.oem_response_wake_up_count,
2150 iface->conn_state,
2151 iface->dtimPeriod,
2152 iface->chanmode,
2153 iface->vht_capable,
2154 iface->ht_capable,
2155 iface->chan_width,
2156 iface->vdev_active,
2157 wma_is_vdev_up(vdev_id),
2158 iface->aid,
2159 iface->rate_flags,
2160 iface->nss,
2161 iface->tx_power,
2162 iface->max_tx_power,
2163 iface->nwType,
2164 iface->tx_streams,
2165 iface->rx_streams,
2166 iface->chain_mask,
2167 iface->nss_2g,
2168 iface->nss_5g);
2169 }
2170
2171 *size -= len;
2172 *buf_ptr += len;
2173}
2174#else /* QCA_SUPPORT_CP_STATS */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302175static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
2176{
Dustin Brown9d797d62017-01-11 16:39:12 -08002177 t_wma_handle *wma;
2178 struct sir_vdev_wow_stats *stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302179 uint16_t len = 0;
2180 char *buf = *buf_ptr;
2181 struct wma_txrx_node *iface;
2182 uint8_t vdev_id;
2183
Dustin Brown9d797d62017-01-11 16:39:12 -08002184 wma = cds_get_context(QDF_MODULE_ID_WMA);
2185 if (!wma) {
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302186 WMA_LOGE("%s: WMA context is invald!", __func__);
2187 return;
2188 }
2189
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07002190 WMA_LOGE("%s: size of buffer: %d", __func__, *size);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302191
Dustin Brown9d797d62017-01-11 16:39:12 -08002192 for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) {
2193 iface = &wma->interfaces[vdev_id];
2194 if (!iface->handle)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302195 continue;
2196
Dustin Brown9d797d62017-01-11 16:39:12 -08002197 stats = &iface->wow_stats;
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302198 len += qdf_scnprintf(buf + len, *size - len,
Dustin Brown9d797d62017-01-11 16:39:12 -08002199 "\n"
2200 "vdev_id %d\n"
2201 "WoW Stats\n"
2202 "\tpno_match %u\n"
2203 "\tpno_complete %u\n"
2204 "\tgscan %u\n"
2205 "\tlow_rssi %u\n"
2206 "\trssi_breach %u\n"
2207 "\tucast %u\n"
2208 "\tbcast %u\n"
2209 "\ticmpv4 %u\n"
2210 "\ticmpv6 %u\n"
2211 "\tipv4_mcast %u\n"
2212 "\tipv6_mcast %u\n"
2213 "\tipv6_mcast_ra %u\n"
2214 "\tipv6_mcast_ns %u\n"
2215 "\tipv6_mcast_na %u\n"
2216 "\toem_response %u\n"
2217 "conn_state %d\n"
2218 "dtimPeriod %d\n"
2219 "chanmode %d\n"
2220 "vht_capable %d\n"
2221 "ht_capable %d\n"
2222 "chan_width %d\n"
2223 "vdev_active %d\n"
2224 "vdev_up %d\n"
2225 "aid %d\n"
2226 "rate_flags %d\n"
2227 "nss %d\n"
2228 "tx_power %d\n"
2229 "max_tx_power %d\n"
2230 "nwType %d\n"
2231 "tx_streams %d\n"
2232 "rx_streams %d\n"
2233 "chain_mask %d\n"
2234 "nss_2g %d\n"
2235 "nss_5g %d",
2236 vdev_id,
2237 stats->pno_match,
2238 stats->pno_complete,
2239 stats->gscan,
2240 stats->low_rssi,
2241 stats->rssi_breach,
2242 stats->ucast,
2243 stats->bcast,
2244 stats->icmpv4,
2245 stats->icmpv6,
2246 stats->ipv4_mcast,
2247 stats->ipv6_mcast,
2248 stats->ipv6_mcast_ra,
2249 stats->ipv6_mcast_ns,
2250 stats->ipv6_mcast_na,
2251 stats->oem_response,
2252 iface->conn_state,
2253 iface->dtimPeriod,
2254 iface->chanmode,
2255 iface->vht_capable,
2256 iface->ht_capable,
2257 iface->chan_width,
2258 iface->vdev_active,
Mukul Sharmaf9047232017-03-02 16:58:56 +05302259 wma_is_vdev_up(vdev_id),
Dustin Brown9d797d62017-01-11 16:39:12 -08002260 iface->aid,
2261 iface->rate_flags,
2262 iface->nss,
2263 iface->tx_power,
2264 iface->max_tx_power,
2265 iface->nwType,
2266 iface->tx_streams,
2267 iface->rx_streams,
2268 iface->chain_mask,
2269 iface->nss_2g,
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302270 iface->nss_5g);
2271 }
2272
2273 *size -= len;
2274 *buf_ptr += len;
2275}
Naveen Rawat3ff5cff2018-01-29 14:31:16 -08002276#endif /* QCA_SUPPORT_CP_STATS */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302277
2278/**
2279 * wma_register_debug_callback() - registration function for wma layer
2280 * to print wma state information
2281 */
2282static void wma_register_debug_callback(void)
2283{
2284 qdf_register_debug_callback(QDF_MODULE_ID_WMA, &wma_state_info_dump);
2285}
Wen Gongaa6d55d2018-04-26 16:33:21 +08002286#else /* WLAN_FEATURE_HDD_MEMDUMP_ENABLE */
2287static void wma_register_debug_callback(void)
2288{
2289}
2290#endif /* WLAN_FEATURE_HDD_MEMDUMP_ENABLE */
Frank Liu65b17d92016-11-23 15:58:44 +08002291/**
2292 * wma_register_tx_ops_handler() - register tx_ops of southbound
2293 * @tx_ops: tx_ops pointer in southbound
2294 *
2295 * Return: 0 on success, errno on failure
2296 */
2297static QDF_STATUS
2298wma_register_tx_ops_handler(struct wlan_lmac_if_tx_ops *tx_ops)
2299{
2300 /*
2301 * Assign tx_ops, it's up to UMAC modules to declare and define these
2302 * functions which are used to send wmi command to target.
2303 */
2304
Himanshu Agarwalce716f82016-12-21 19:07:54 +05302305 if (!tx_ops) {
2306 WMA_LOGE("%s: pointer to lmac if tx ops is NULL", __func__);
2307 return QDF_STATUS_E_INVAL;
2308 }
2309
2310 /* mgmt_txrx component's tx ops */
2311 tx_ops->mgmt_txrx_tx_ops.mgmt_tx_send = wma_mgmt_unified_cmd_send;
2312
Frank Liu65b17d92016-11-23 15:58:44 +08002313 return QDF_STATUS_SUCCESS;
2314}
2315
2316/**
2317 * wma_target_if_open() - Attach UMAC modules' interface with wmi layer
2318 * @wma_handle: wma handle
2319 *
2320 * Separate module defines below functions:
2321 * 1. tgt_wmi_<module>_<action> api sends wmi command, assigned to south bound
2322 * tx_ops function pointers;
2323 * 2. module's south dispatcher handles information from lower layer, assigned
2324 * to south bound rx_ops function pointers;
2325 * 3. wmi event handler deals with wmi event, extracts umac needed information,
2326 * and call rx_ops(module's dispatcher). It executes in tasklet context and
2327 * is up to dispatcher to decide the context to reside in tasklet or in
2328 * thread context.
2329 *
2330 * Return: None
2331 */
2332static void wma_target_if_open(tp_wma_handle wma_handle)
2333{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302334 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002335
2336 if (!psoc)
2337 return;
2338
Mukul Sharmadad267e2017-02-04 13:25:34 +05302339 wlan_global_lmac_if_set_txops_registration_cb(WLAN_DEV_OL,
2340 target_if_register_tx_ops);
2341 wlan_lmac_if_set_umac_txops_registration_cb(
2342 wma_register_tx_ops_handler);
2343 wlan_global_lmac_if_open(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002344
Frank Liu65b17d92016-11-23 15:58:44 +08002345}
2346
2347/**
2348 * wma_target_if_close() - Detach UMAC modules' interface with wmi layer
2349 * @wma_handle: wma handle
2350 *
2351 * Return: None
2352 */
2353static void wma_target_if_close(tp_wma_handle wma_handle)
2354{
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302355 struct wlan_objmgr_psoc *psoc = wma_handle->psoc;
Frank Liu65b17d92016-11-23 15:58:44 +08002356
2357 if (!psoc)
2358 return;
2359
Mukul Sharmadad267e2017-02-04 13:25:34 +05302360 wlan_global_lmac_if_close(psoc);
Frank Liu65b17d92016-11-23 15:58:44 +08002361}
Frank Liu65b17d92016-11-23 15:58:44 +08002362
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05302363/**
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302364 * wma_get_psoc_from_scn_handle() - API to get psoc from scn handle
2365 * @scn_handle: opaque wma handle
2366 *
2367 * API to get psoc from scn handle
2368 *
2369 * Return: None
2370 */
2371static struct wlan_objmgr_psoc *wma_get_psoc_from_scn_handle(void *scn_handle)
2372{
2373 tp_wma_handle wma_handle;
2374
2375 if (!scn_handle) {
2376 WMA_LOGE("invalid scn handle");
2377 return NULL;
2378 }
2379 wma_handle = (tp_wma_handle)scn_handle;
2380
2381 return wma_handle->psoc;
2382}
Himanshu Agarwal2228e072018-01-24 17:42:17 +05302383
2384/**
2385 * wma_get_pdev_from_scn_handle() - API to get pdev from scn handle
2386 * @scn_handle: opaque wma handle
2387 *
2388 * API to get pdev from scn handle
2389 *
2390 * Return: None
2391 */
2392static struct wlan_objmgr_pdev *wma_get_pdev_from_scn_handle(void *scn_handle)
2393{
2394 tp_wma_handle wma_handle;
2395
2396 if (!scn_handle) {
2397 WMA_LOGE("invalid scn handle");
2398 return NULL;
2399 }
2400 wma_handle = (tp_wma_handle)scn_handle;
2401
2402 return wma_handle->pdev;
2403}
2404
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002405/**
2406 * wma_legacy_service_ready_event_handler() - legacy (ext)service ready handler
2407 * @event_id: event_id
2408 * @handle: wma handle
2409 * @event_data: event data
2410 * @length: event length
2411 *
2412 * Return: 0 for success, negative error code for failure
2413 */
2414static int wma_legacy_service_ready_event_handler(uint32_t event_id,
2415 void *handle,
2416 uint8_t *event_data,
2417 uint32_t length)
2418{
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302419 switch (event_id) {
2420 case wmi_service_ready_event_id:
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002421 return wma_rx_service_ready_event(handle, event_data, length);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302422 case wmi_service_ready_ext_event_id:
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002423 return wma_rx_service_ready_ext_event(handle, event_data,
2424 length);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302425 case wmi_ready_event_id:
2426 return wma_rx_ready_event(handle, event_data, length);
2427 default:
2428 WMA_LOGE("Legacy callback invoked with invalid event_id:%d",
2429 event_id);
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002430 QDF_BUG(0);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05302431 }
Rajeev Kumarda2444c2017-01-10 22:42:07 -08002432
2433 return 0;
2434}
Mukul Sharmac3e7a782017-02-03 12:16:11 +05302435
2436/**
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002437 * wma_flush_complete_evt_handler() - FW log flush complete event handler
2438 * @handle: WMI handle
2439 * @event: Event recevied from FW
2440 * @len: Length of the event
2441 *
2442 */
2443static int wma_flush_complete_evt_handler(void *handle,
2444 u_int8_t *event,
2445 u_int32_t len)
2446{
2447 QDF_STATUS status;
2448 tp_wma_handle wma = (tp_wma_handle) handle;
2449
2450 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *param_buf;
2451 wmi_debug_mesg_flush_complete_fixed_param *wmi_event;
Poddar, Siddarthc2c08142017-09-13 17:49:56 +05302452 wmi_debug_mesg_fw_data_stall_param *data_stall_event;
2453 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2454 uint8_t *buf_ptr;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002455 uint32_t reason_code;
2456
2457 param_buf = (WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID_param_tlvs *) event;
2458 if (!param_buf) {
2459 WMA_LOGE("Invalid log flush complete event buffer");
2460 return QDF_STATUS_E_FAILURE;
2461 }
2462
2463 wmi_event = param_buf->fixed_param;
2464 reason_code = wmi_event->reserved0;
Rajeev Kumardcce8092018-05-02 15:48:17 -07002465 WMA_LOGD("Received reason code %d from FW", reason_code);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002466
Poddar, Siddarthc2c08142017-09-13 17:49:56 +05302467 buf_ptr = (uint8_t *)wmi_event;
2468 buf_ptr = buf_ptr + sizeof(wmi_debug_mesg_flush_complete_fixed_param) +
2469 WMI_TLV_HDR_SIZE;
2470 data_stall_event = (wmi_debug_mesg_fw_data_stall_param *) buf_ptr;
2471
2472 if (((data_stall_event->tlv_header & 0xFFFF0000) >> 16 ==
2473 WMITLV_TAG_STRUC_wmi_debug_mesg_fw_data_stall_param)) {
2474 /**
2475 * Log data stall info received from FW:
2476 *
2477 * Possible data stall recovery types:
2478 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_DISCONNECT
2479 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_MAC_PHY_RESET
2480 * WLAN_DBG_DATA_STALL_RECOVERY_CONNECT_PDR
2481 *
2482 * Possible data stall event types:
2483 * WLAN_DBG_DATA_STALL_VDEV_PAUSE
2484 * WLAN_DBG_DATA_STALL_HWSCHED_CMD_FILTER
2485 * WLAN_DBG_DATA_STALL_HWSCHED_CMD_FLUSH
2486 * WLAN_DBG_DATA_STALL_RX_REFILL_FAILED
2487 * WLAN_DBG_DATA_STALL_RX_FCS_LEN_ERROR
2488 *
2489 * reason_code1:
2490 * The information stored in reason_code1 varies based on the
2491 * data stall type values:
2492 *
2493 * data_stall_type | reason_code1
2494 * -----------------------------------------------------
2495 * HWSCHED_CMD_FLUSH | flush req reason (0-40)
2496 * RX_REFILL_FAILED | ring_id (0-7)
2497 * RX_FCS_LEN_ERROR | exact error type
2498 *
2499 * reasone_code2:
2500 * on which tid/hwq stall happened
2501 *
2502 */
2503 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
2504 "Data Stall event:");
2505 QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
2506 "data_stall_type: %x vdev_id_bitmap: %x reason_code1: %x reason_code2: %x recovery_type: %x ",
2507 data_stall_event->data_stall_type,
2508 data_stall_event->vdev_id_bitmap,
2509 data_stall_event->reason_code1,
2510 data_stall_event->reason_code2,
2511 data_stall_event->recovery_type);
2512
2513 cdp_post_data_stall_event(soc,
2514 DATA_STALL_LOG_INDICATOR_FIRMWARE,
2515 data_stall_event->data_stall_type,
2516 0XFF,
2517 data_stall_event->vdev_id_bitmap,
2518 data_stall_event->recovery_type);
2519 }
2520
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002521 /*
2522 * reason_code = 0; Flush event in response to flush command
2523 * reason_code = other value; Asynchronous flush event for fatal events
2524 */
2525 if (!reason_code && (cds_is_log_report_in_progress() == false)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002526 WMA_LOGD("Received WMI flush event without sending CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002527 return -EINVAL;
2528 } else if (!reason_code && cds_is_log_report_in_progress() == true) {
2529 /* Flush event in response to flush command */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002530 WMA_LOGD("Received WMI flush event in response to flush CMD");
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002531 status = qdf_mc_timer_stop(&wma->log_completion_timer);
2532 if (status != QDF_STATUS_SUCCESS)
2533 WMA_LOGE("Failed to stop the log completion timeout");
2534 cds_logging_set_fw_flush_complete();
Zhu Jianminb639e9b2017-10-26 19:09:12 +08002535 return QDF_STATUS_SUCCESS;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002536 } else if (reason_code && cds_is_log_report_in_progress() == false) {
2537 /* Asynchronous flush event for fatal events */
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002538 status = cds_set_log_completion(WLAN_LOG_TYPE_FATAL,
2539 WLAN_LOG_INDICATOR_FIRMWARE,
2540 reason_code, false);
2541 if (QDF_STATUS_SUCCESS != status) {
2542 WMA_LOGE("%s: Failed to set log trigger params",
2543 __func__);
2544 return QDF_STATUS_E_FAILURE;
2545 }
2546 cds_logging_set_fw_flush_complete();
2547 return status;
2548 } else {
2549 /* Asynchronous flush event for fatal event,
2550 * but, report in progress already
2551 */
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08002552 WMA_LOGD("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002553 __func__, WLAN_LOG_TYPE_FATAL,
2554 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2555 return QDF_STATUS_E_FAILURE;
2556 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07002557 /* Asynchronous flush event for fatal event,
2558 * but, report in progress already
2559 */
2560 WMA_LOGW("%s: Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d",
2561 __func__, WLAN_LOG_TYPE_FATAL,
2562 WLAN_LOG_INDICATOR_FIRMWARE, reason_code);
2563 return QDF_STATUS_E_FAILURE;
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002564}
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002565/**
2566 * wma_extract_single_phyerr_spectral() - extract single phy error from event
2567 * @handle: wma handle
2568 * @param evt_buf: pointer to event buffer
2569 * @param datalen: data length of event buffer
2570 * @param buf_offset: Pointer to hold value of current event buffer offset
2571 * post extraction
2572 * @param phyerr: Pointer to hold phyerr
2573 *
2574 * Return: QDF_STATUS
2575 */
2576static QDF_STATUS wma_extract_single_phyerr_spectral(void *handle,
2577 void *evt_buf,
2578 uint16_t datalen, uint16_t *buf_offset,
2579 wmi_host_phyerr_t *phyerr)
2580{
2581 wmi_single_phyerr_rx_event *ev;
2582 int n = *buf_offset;
2583
2584 ev = (wmi_single_phyerr_rx_event *)((uint8_t *)evt_buf + n);
2585
2586 if (n < datalen) {
2587 /* ensure there's at least space for the header */
2588 if ((datalen - n) < sizeof(ev->hdr)) {
2589 WMA_LOGE("%s: not enough space? (datalen=%d, n=%d, hdr=%zu bytes",
2590 __func__, datalen, n, sizeof(ev->hdr));
2591 return QDF_STATUS_E_FAILURE;
2592 }
2593
2594 phyerr->bufp = ev->bufp;
2595 phyerr->buf_len = ev->hdr.buf_len;
2596
2597 /*
2598 * Sanity check the buffer length of the event against
2599 * what we currently have.
2600 *
2601 * Since buf_len is 32 bits, we check if it overflows
2602 * a large 32 bit value. It's not 0x7fffffff because
2603 * we increase n by (buf_len + sizeof(hdr)), which would
2604 * in itself cause n to overflow.
2605 *
2606 * If "int" is 64 bits then this becomes a moot point.
2607 */
2608 if (ev->hdr.buf_len > 0x7f000000) {
2609 WMA_LOGE("%s: buf_len is garbage? (0x%x)",
2610 __func__, ev->hdr.buf_len);
2611 return QDF_STATUS_E_FAILURE;
2612 }
2613 if (n + ev->hdr.buf_len > datalen) {
2614 WMA_LOGE("%s: buf_len exceeds available space n=%d, buf_len=%d, datalen=%d",
2615 __func__, n, ev->hdr.buf_len, datalen);
2616 return QDF_STATUS_E_FAILURE;
2617 }
2618
2619 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
2620 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
2621
2622#ifdef DEBUG_SPECTRAL_SCAN
2623 WMA_LOGD("%s: len=%d, tsf=0x%08x, rssi = 0x%x/0x%x/0x%x/0x%x, comb rssi = 0x%x, phycode=%d",
2624 __func__,
2625 ev->hdr.buf_len,
2626 ev->hdr.tsf_timestamp,
2627 ev->hdr.rssi_chain0,
2628 ev->hdr.rssi_chain1,
2629 ev->hdr.rssi_chain2,
2630 ev->hdr.rssi_chain3,
2631 WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr),
2632 phyerr->phy_err_code);
2633
2634 /*
2635 * For now, unroll this loop - the chain 'value' field isn't
2636 * a variable but glued together into a macro field definition.
2637 * Grr. :-)
2638 */
2639 WMA_LOGD("%s: chain 0: raw=0x%08x; pri20=%d sec20=%d sec40=%d sec80=%d",
2640 __func__,
2641 ev->hdr.rssi_chain0,
2642 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, PRI20),
2643 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC20),
2644 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC40),
2645 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC80));
2646
2647 WMA_LOGD("%s: chain 1: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2648 __func__,
2649 ev->hdr.rssi_chain1,
2650 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, PRI20),
2651 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC20),
2652 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC40),
2653 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC80));
2654
2655 WMA_LOGD("%s: chain 2: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2656 __func__,
2657 ev->hdr.rssi_chain2,
2658 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, PRI20),
2659 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC20),
2660 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC40),
2661 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC80));
2662
2663 WMA_LOGD("%s: chain 3: raw=0x%08x: pri20=%d sec20=%d sec40=%d sec80=%d",
2664 __func__,
2665 ev->hdr.rssi_chain3,
2666 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, PRI20),
2667 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC20),
2668 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC40),
2669 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC80));
2670
2671
2672 WMA_LOGD("%s: freq_info_1=0x%08x, freq_info_2=0x%08x",
2673 __func__, ev->hdr.freq_info_1, ev->hdr.freq_info_2);
2674
2675 /*
2676 * The NF chain values are signed and are negative - hence
2677 * the cast evilness.
2678 */
2679 WMA_LOGD("%s: nfval[1]=0x%08x, nfval[2]=0x%08x, nf=%d/%d/%d/%d, freq1=%d, freq2=%d, cw=%d",
2680 __func__,
2681 ev->hdr.nf_list_1,
2682 ev->hdr.nf_list_2,
2683 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 0),
2684 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 1),
2685 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 2),
2686 (int) WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 3),
2687 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 1),
2688 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 2),
2689 WMI_UNIFIED_CHWIDTH_GET(&ev->hdr));
2690#endif
2691
2692 /*
2693 * If required, pass spectral events to the spectral module
2694 */
2695 if (ev->hdr.buf_len > 0) {
2696
2697 /* Initialize the NF values to Zero. */
2698 phyerr->rf_info.noise_floor[0] =
2699 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 0);
2700 phyerr->rf_info.noise_floor[1] =
2701 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 1);
2702 phyerr->rf_info.noise_floor[2] =
2703 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 2);
2704 phyerr->rf_info.noise_floor[3] =
2705 WMI_UNIFIED_NF_CHAIN_GET(&ev->hdr, 3);
2706
2707 /* populate the rf info */
2708 phyerr->rf_info.rssi_comb =
2709 WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
2710
2711 /* Need to unroll loop due to macro
2712 * constraints chain 0
2713 */
2714 phyerr->rf_info.pc_rssi_info[0].rssi_pri20 =
2715 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, PRI20);
2716 phyerr->rf_info.pc_rssi_info[0].rssi_sec20 =
2717 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC20);
2718 phyerr->rf_info.pc_rssi_info[0].rssi_sec40 =
2719 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC40);
2720 phyerr->rf_info.pc_rssi_info[0].rssi_sec80 =
2721 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 0, SEC80);
2722
2723 /* chain 1 */
2724 phyerr->rf_info.pc_rssi_info[1].rssi_pri20 =
2725 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, PRI20);
2726 phyerr->rf_info.pc_rssi_info[1].rssi_sec20 =
2727 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC20);
2728 phyerr->rf_info.pc_rssi_info[1].rssi_sec40 =
2729 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC40);
2730 phyerr->rf_info.pc_rssi_info[1].rssi_sec80 =
2731 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 1, SEC80);
2732
2733 /* chain 2 */
2734 phyerr->rf_info.pc_rssi_info[2].rssi_pri20 =
2735 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, PRI20);
2736 phyerr->rf_info.pc_rssi_info[2].rssi_sec20 =
2737 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC20);
2738 phyerr->rf_info.pc_rssi_info[2].rssi_sec40 =
2739 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC40);
2740 phyerr->rf_info.pc_rssi_info[2].rssi_sec80 =
2741 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 2, SEC80);
2742
2743 /* chain 3 */
2744 phyerr->rf_info.pc_rssi_info[3].rssi_pri20 =
2745 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, PRI20);
2746 phyerr->rf_info.pc_rssi_info[3].rssi_sec20 =
2747 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC20);
2748 phyerr->rf_info.pc_rssi_info[3].rssi_sec40 =
2749 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC40);
2750 phyerr->rf_info.pc_rssi_info[3].rssi_sec80 =
2751 WMI_UNIFIED_RSSI_CHAN_GET(&ev->hdr, 3, SEC80);
2752
2753 phyerr->chan_info.center_freq1 =
2754 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 1);
2755 phyerr->chan_info.center_freq2 =
2756 WMI_UNIFIED_FREQ_INFO_GET(&ev->hdr, 2);
2757
2758 }
2759
2760 /*
2761 * Advance the buffer pointer to the next PHY error.
2762 * buflen is the length of this payload, so we need to
2763 * advance past the current header _AND_ the payload.
2764 */
2765 n += sizeof(*ev) + ev->hdr.buf_len;
2766 }
2767 *buf_offset += n;
2768
2769 return QDF_STATUS_SUCCESS;
2770}
2771
2772/**
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002773 * spectral_phyerr_event_handler() - spectral phyerr event handler
2774 * @handle: wma handle
2775 * @data: data buffer
2776 * @datalen: buffer length
2777 *
2778 * Return: QDF_STATUS
2779 */
2780static QDF_STATUS spectral_phyerr_event_handler(void *handle,
2781 uint8_t *data, uint32_t datalen)
2782{
2783 tp_wma_handle wma = (tp_wma_handle) handle;
2784 QDF_STATUS status = QDF_STATUS_SUCCESS;
2785 uint16_t buf_offset, event_buf_len = 0;
2786 wmi_single_phyerr_rx_event *ev;
2787 wmi_host_phyerr_t phyerr;
2788 struct target_if_spectral_rfqual_info rfqual_info;
2789 struct target_if_spectral_chan_info chan_info;
2790 struct target_if_spectral_acs_stats acs_stats;
2791
2792 if (NULL == wma) {
2793 WMA_LOGE("%s:wma handle is NULL", __func__);
2794 return QDF_STATUS_E_FAILURE;
2795 }
2796
2797 memset(&phyerr, 0, sizeof(wmi_host_phyerr_t));
Arif Hussaind54b62c2018-03-01 13:31:37 -08002798 status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
2799 &buf_offset, &phyerr);
2800 if (QDF_IS_STATUS_ERROR(status)) {
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002801 WMA_LOGE("%s: extract comb phyerr failed", __func__);
2802 return QDF_STATUS_E_FAILURE;
2803 }
2804
2805 ev = (wmi_single_phyerr_rx_event *)phyerr.bufp;
2806 event_buf_len = phyerr.buf_len;
2807 /* Loop over the bufp, extracting out phyerrors */
2808 buf_offset = 0;
2809 while (buf_offset < event_buf_len) {
2810 if (wma_extract_single_phyerr_spectral(handle, ev,
2811 event_buf_len, &buf_offset, &phyerr)) {
2812 WMA_LOGE("%s: extract single phy err failed", __func__);
2813 return QDF_STATUS_E_FAILURE;
2814 }
2815
2816 if (phyerr.buf_len > 0) {
2817 if (sizeof(phyerr.rf_info) > sizeof(rfqual_info))
2818 qdf_mem_copy(&rfqual_info, &phyerr.rf_info,
2819 sizeof(rfqual_info));
2820 else
2821 qdf_mem_copy(&rfqual_info, &phyerr.rf_info,
2822 sizeof(phyerr.rf_info));
2823
2824 if (sizeof(phyerr.chan_info) > sizeof(chan_info))
2825 qdf_mem_copy(&chan_info, &phyerr.chan_info,
2826 sizeof(chan_info));
2827 else
2828 qdf_mem_copy(&chan_info, &phyerr.chan_info,
2829 sizeof(phyerr.chan_info));
2830
2831 target_if_spectral_process_phyerr(wma->pdev, phyerr.bufp,
2832 phyerr.buf_len,
2833 &rfqual_info,
2834 &chan_info,
2835 phyerr.tsf64,
2836 &acs_stats);
2837 }
2838 }
2839
2840 return status;
2841}
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08002842
Arif Hussainf63f7a32017-08-22 12:49:42 -07002843/**
Arif Hussaind54b62c2018-03-01 13:31:37 -08002844 * dfs_phyerr_event_handler() - dfs phyerr event handler
2845 * @handle: wma handle
2846 * @data: data buffer
2847 * @datalen: buffer length
2848 * @fulltsf: 64 bit event TSF
2849 *
2850 * Function to process DFS phy errors.
2851 *
2852 * Return: QDF_STATUS
2853 */
2854static QDF_STATUS dfs_phyerr_event_handler(tp_wma_handle handle,
2855 uint8_t *data,
2856 uint32_t datalen,
2857 uint64_t fulltsf)
2858{
2859 QDF_STATUS status = QDF_STATUS_SUCCESS;
2860 struct wlan_lmac_if_dfs_rx_ops *dfs_rx_ops;
2861 wmi_host_phyerr_t phyerr;
2862 int8_t rssi_comb;
2863 uint16_t buf_offset;
2864
2865 if (!handle->psoc) {
2866 WMA_LOGE("%s: psoc is null", __func__);
2867 return QDF_STATUS_E_INVAL;
2868 }
2869
2870 dfs_rx_ops = wlan_lmac_if_get_dfs_rx_ops(handle->psoc);
2871 if (!dfs_rx_ops) {
2872 WMA_LOGE("%s: dfs_rx_ops is null", __func__);
2873 return QDF_STATUS_E_INVAL;
2874 }
2875
2876 if (!dfs_rx_ops->dfs_process_phyerr) {
2877 WMA_LOGE("%s: dfs_process_phyerr handler is null", __func__);
2878 return QDF_STATUS_E_INVAL;
2879 }
2880
2881 if (!handle->pdev) {
2882 WMA_LOGE("%s: pdev is null", __func__);
2883 return -EINVAL;
2884 }
2885
2886 buf_offset = 0;
2887 while (buf_offset < datalen) {
2888 status = wmi_extract_single_phyerr(handle->wmi_handle, data, datalen,
2889 &buf_offset, &phyerr);
2890 if (QDF_IS_STATUS_ERROR(status)) {
2891 /* wmi_extract_single_phyerr has logs */
2892 return status;
2893 }
2894
2895 rssi_comb = phyerr.rf_info.rssi_comb & 0xFF;
2896 if (phyerr.buf_len > 0)
2897 dfs_rx_ops->dfs_process_phyerr(handle->pdev,
2898 &phyerr.bufp[0],
2899 phyerr.buf_len,
2900 rssi_comb,
2901 rssi_comb,
2902 phyerr.tsf_timestamp,
2903 fulltsf);
2904 }
2905
2906 return QDF_STATUS_SUCCESS;
2907}
2908
2909/**
Arif Hussainf63f7a32017-08-22 12:49:42 -07002910 * wma_unified_phyerr_rx_event_handler() - phyerr event handler
2911 * @handle: wma handle
2912 * @data: data buffer
2913 * @datalen: buffer length
2914 *
2915 * WMI Handler for WMI_PHYERR_EVENTID event from firmware.
2916 * This handler is currently handling DFS and spectral scan
2917 * phy errors.
2918 *
2919 * Return: 0 for success, other value for failure
2920 */
2921static int wma_unified_phyerr_rx_event_handler(void *handle,
Arif Hussaind54b62c2018-03-01 13:31:37 -08002922 uint8_t *data,
2923 uint32_t datalen)
2924{
Arif Hussainf63f7a32017-08-22 12:49:42 -07002925 /* phyerr handling is moved to cmn project
2926 * As WIN still uses handler registration in non-cmn code.
2927 * need complete testing of non offloaded DFS code before we enable
2928 * it in cmn code.
2929 **/
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002930 tp_wma_handle wma = (tp_wma_handle) handle;
2931 QDF_STATUS status = QDF_STATUS_SUCCESS;
2932 wmi_host_phyerr_t phyerr;
2933 uint16_t buf_offset = 0;
2934
Arif Hussaind54b62c2018-03-01 13:31:37 -08002935 if (!wma) {
2936 WMA_LOGE("%s: wma handle is null", __func__);
2937 return -EINVAL;
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002938 }
2939
2940 /* sanity check on data length */
Arif Hussaind54b62c2018-03-01 13:31:37 -08002941 status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
2942 &buf_offset, &phyerr);
2943 if (QDF_IS_STATUS_ERROR(status)) {
2944 WMA_LOGE("%s: extract phyerr failed: %d", __func__, status);
2945 return qdf_status_to_os_return(status);
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002946 }
2947
2948 /* handle different PHY Error conditions */
2949 if (((phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_RADAR |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002950 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT |
2951 WMI_PHY_ERROR_MASK0_SPECTRAL_SCAN)) == 0)) {
2952 WMA_LOGD("%s: Unknown phy error event", __func__);
2953 return -EINVAL;
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002954 }
2955
2956 /* Handle Spectral or DFS PHY Error */
2957 if (phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_RADAR |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002958 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT)) {
2959 if (wma->is_dfs_offloaded) {
2960 WMA_LOGD("%s: Unexpected phy error, dfs offloaded",
2961 __func__);
2962 return -EINVAL;
2963 }
2964 status = dfs_phyerr_event_handler(wma,
2965 phyerr.bufp,
2966 phyerr.buf_len,
2967 phyerr.tsf64);
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002968 } else if (phyerr.phy_err_mask0 & (WMI_PHY_ERROR_MASK0_SPECTRAL_SCAN |
Arif Hussaind54b62c2018-03-01 13:31:37 -08002969 WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT)) {
Sandeep Puligilla707cea52018-01-17 23:19:41 -08002970 status = spectral_phyerr_event_handler(wma, data, datalen);
2971 }
Arif Hussaind54b62c2018-03-01 13:31:37 -08002972
2973 return qdf_status_to_os_return(status);
Arif Hussainf63f7a32017-08-22 12:49:42 -07002974}
2975
Dustin Brownec2c92e2017-07-26 11:13:49 -07002976void wma_vdev_init(struct wma_txrx_node *vdev)
2977{
2978 qdf_wake_lock_create(&vdev->vdev_start_wakelock, "vdev_start");
2979 qdf_wake_lock_create(&vdev->vdev_stop_wakelock, "vdev_stop");
Rajeev Kumar155a3e42017-10-10 15:31:17 -07002980 qdf_wake_lock_create(&vdev->vdev_set_key_wakelock, "vdev_set_key");
Naveen Rawatd7734142017-10-27 10:02:40 -07002981 vdev->is_waiting_for_key = false;
Dustin Brownec2c92e2017-07-26 11:13:49 -07002982}
2983
2984void wma_vdev_deinit(struct wma_txrx_node *vdev)
2985{
2986 qdf_wake_lock_destroy(&vdev->vdev_start_wakelock);
2987 qdf_wake_lock_destroy(&vdev->vdev_stop_wakelock);
Rajeev Kumar155a3e42017-10-10 15:31:17 -07002988 qdf_wake_lock_destroy(&vdev->vdev_set_key_wakelock);
Naveen Rawatd7734142017-10-27 10:02:40 -07002989 vdev->is_waiting_for_key = false;
Dustin Brownec2c92e2017-07-26 11:13:49 -07002990}
2991
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08002992/**
2993 * wma_wmi_stop() - generic function to block WMI commands
2994 * @return: None
2995 */
2996void wma_wmi_stop(void)
2997{
2998 tp_wma_handle wma_handle;
2999
3000 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
3001 if (wma_handle == NULL) {
3002 QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
3003 "wma_handle is NULL\n");
3004 return;
3005 }
3006 wmi_stop(wma_handle->wmi_handle);
3007}
3008
Naveen Rawate8b1b822018-01-30 09:46:16 -08003009#ifdef QCA_SUPPORT_CP_STATS
3010static void wma_register_stats_events(wmi_unified_t wmi_handle) {}
3011#else
3012static void wma_register_stats_events(wmi_unified_t wmi_handle)
3013{
3014 wmi_unified_register_event_handler(wmi_handle,
3015 wmi_update_stats_event_id,
3016 wma_stats_event_handler,
3017 WMA_RX_SERIALIZER_CTX);
3018}
3019#endif
3020
Kabilan Kannanfc3a8c02018-02-21 13:36:29 -08003021/**
3022 * wma_open() - Allocate wma context and initialize it.
3023 * @cds_context: cds context
3024 * @wma_tgt_cfg_cb: tgt config callback fun
3025 * @radar_ind_cb: dfs radar indication callback
3026 * @cds_cfg: mac parameters
3027 *
3028 * Return: 0 on success, errno on failure
3029 */
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003030QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031 wma_tgt_cfg_cb tgt_cfg_cb,
bings482bae22018-01-17 16:25:31 +08003032 struct cds_config_info *cds_cfg,
3033 uint32_t target_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034{
3035 tp_wma_handle wma_handle;
3036 HTC_HANDLE htc_handle;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303037 qdf_device_t qdf_dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038 void *wmi_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303039 QDF_STATUS qdf_status;
Lin Bai04f603e2018-03-19 11:01:06 +08003040 struct wmi_unified_attach_params *params;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003041 struct policy_mgr_wma_cbacks wma_cbacks;
Frank Liu00d73fe2017-05-19 22:11:28 +08003042 struct target_psoc_info *tgt_psoc_info;
Dustin Brownec2c92e2017-07-26 11:13:49 -07003043 int i;
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003044 void *cds_context;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303045 target_resource_config *wlan_res_cfg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046
3047 WMA_LOGD("%s: Enter", __func__);
3048
Jeff Johnsonff6addf2017-09-13 10:06:03 -07003049 cds_context = cds_get_global_context();
3050 if (!cds_context) {
3051 WMA_LOGE("%s: Invalid CDS context", __func__);
3052 return QDF_STATUS_E_INVAL;
3053 }
3054
Mukul Sharma5ff3c582016-09-12 15:23:35 +05303055 g_wmi_version_info.major = __WMI_VER_MAJOR_;
3056 g_wmi_version_info.minor = __WMI_VER_MINOR_;
3057 g_wmi_version_info.revision = __WMI_REVISION_;
3058
Anurag Chouhan6d760662016-02-20 16:05:43 +05303059 qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
3060 htc_handle = cds_get_context(QDF_MODULE_ID_HTC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061
3062 if (!htc_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003063 WMA_LOGE("%s: Invalid HTC handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303064 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 }
3066
3067 /* Alloc memory for WMA Context */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003068 qdf_status = cds_alloc_context(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 (void **)&wma_handle,
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003070 sizeof(*wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303072 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003073 WMA_LOGE("%s: Memory allocation failed for wma_handle",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303075 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 }
3077
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303078 qdf_mem_zero(wma_handle, sizeof(t_wma_handle));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303080 if (target_if_alloc_psoc_tgt_info(psoc)) {
3081 WMA_LOGE("%s target psoc info allocation failed", __func__);
3082 qdf_status = QDF_STATUS_E_NOMEM;
3083 goto err_free_wma_handle;
Frank Liu00d73fe2017-05-19 22:11:28 +08003084 }
3085
Anurag Chouhan6d760662016-02-20 16:05:43 +05303086 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303088 qdf_wake_lock_create(&wma_handle->extscan_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 "wlan_extscan_wl");
3090#endif /* FEATURE_WLAN_EXTSCAN */
Mukul Sharmae44d0542017-05-23 21:50:56 +05303091 qdf_wake_lock_create(&wma_handle->wow_wake_lock,
3092 "wlan_wow_wl");
3093 qdf_wake_lock_create(&wma_handle->wow_auth_req_wl,
3094 "wlan_auth_req_wl");
3095 qdf_wake_lock_create(&wma_handle->wow_assoc_req_wl,
3096 "wlan_assoc_req_wl");
3097 qdf_wake_lock_create(&wma_handle->wow_deauth_rec_wl,
3098 "wlan_deauth_rec_wl");
3099 qdf_wake_lock_create(&wma_handle->wow_disassoc_rec_wl,
3100 "wlan_disassoc_rec_wl");
3101 qdf_wake_lock_create(&wma_handle->wow_ap_assoc_lost_wl,
3102 "wlan_ap_assoc_lost_wl");
3103 qdf_wake_lock_create(&wma_handle->wow_auto_shutdown_wl,
3104 "wlan_auto_shutdown_wl");
3105 qdf_wake_lock_create(&wma_handle->roam_ho_wl,
3106 "wlan_roam_ho_wl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 }
3108
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05303109 qdf_status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_LEGACY_WMA_ID);
3110 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3111 WMA_LOGE("%s: PSOC get_ref fails", __func__);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303112 goto err_wma_handle;
Selvaraj, Sridhar3a1823f2017-02-01 17:32:21 +05303113 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303114 wma_handle->psoc = psoc;
3115
Rajeev Kumarda2444c2017-01-10 22:42:07 -08003116 /* Open target_if layer and register wma callback */
3117 wma_target_if_open(wma_handle);
3118 target_if_open(wma_get_psoc_from_scn_handle);
3119
Lin Bai04f603e2018-03-19 11:01:06 +08003120 /*
3121 * Allocate locally used params with its rx_ops member,
3122 * and free it immediately after used.
3123 */
3124 params = qdf_mem_malloc(sizeof(*params) + sizeof(struct wmi_rx_ops));
3125 if (!params) {
3126 WMA_LOGE("%s: failed to allocate attach params", __func__);
3127 qdf_status = QDF_STATUS_E_NOMEM;
3128 goto err_wma_handle;
3129 }
3130
3131 params->rx_ops = (struct wmi_rx_ops *)(params + 1);
3132 params->osdev = NULL;
3133 params->target_type = WMI_TLV_TARGET;
3134 params->use_cookie = false;
3135 params->psoc = psoc;
3136 params->max_commands = WMI_MAX_CMDS;
Govind Singhd76a5b02016-03-08 15:12:14 +05303137 /* Attach mc_thread context processing function */
Lin Bai04f603e2018-03-19 11:01:06 +08003138 params->rx_ops->wma_process_fw_event_handler_cbk =
3139 wma_process_fw_event_handler;
Surabhi Vishnoi75b1a812018-02-09 12:07:16 +05303140
Himanshu Agarwal88b16a42018-02-06 15:10:59 +05303141 /* initialize tlv attach */
3142 wmi_tlv_init();
Surabhi Vishnoi75b1a812018-02-09 12:07:16 +05303143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 /* attach the wmi */
Lin Bai04f603e2018-03-19 11:01:06 +08003145 wmi_handle = wmi_unified_attach(wma_handle, params);
3146 qdf_mem_free(params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 if (!wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003148 WMA_LOGE("%s: failed to attach WMI", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303149 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150 goto err_wma_handle;
3151 }
3152
Rajeev Kumarda2444c2017-01-10 22:42:07 -08003153 target_if_register_legacy_service_ready_cb(
3154 wma_legacy_service_ready_event_handler);
3155
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 WMA_LOGA("WMA --> wmi_unified_attach - success");
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05303157
Frank Liu00d73fe2017-05-19 22:11:28 +08003158 /* store the wmi handle in tgt_if_handle */
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303159 tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
Mukul Sharmacc1f3f92017-01-30 19:56:24 +05303160
bings6b413662018-02-06 17:51:36 +08003161 target_psoc_set_target_type(tgt_psoc_info, target_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 /* Save the WMI & HTC handle */
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303163 target_psoc_set_wmi_hdl(tgt_psoc_info, wmi_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 wma_handle->wmi_handle = wmi_handle;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303165 target_psoc_set_htc_hdl(tgt_psoc_info, htc_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 wma_handle->cds_context = cds_context;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303167 wma_handle->qdf_dev = qdf_dev;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303168 wma_handle->max_scan = cds_cfg->max_scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303170 /* Register Converged Event handlers */
3171 init_deinit_register_tgt_psoc_ev_handlers(psoc);
3172
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303173 /* Initialize max_no_of_peers for wma_get_number_of_peers_supported() */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303174 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303175 /* Cap maxStation based on the target version */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303176 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303177 /* Reinitialize max_no_of_peers based on the capped maxStation value */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303178 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
Manishekar Chandrasekaranebcab882016-05-04 12:55:14 +05303179
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 /* initialize default target config */
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303181 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_psoc_info);
Arif Hussaind15902c2018-03-02 00:08:29 -08003182 if (!wlan_res_cfg) {
3183 WMA_LOGE("%s: wlan_res_cfg is null", __func__);
3184 qdf_status = QDF_STATUS_E_NOMEM;
3185 goto err_wma_handle;
3186 }
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303187
3188 wma_set_default_tgt_config(wma_handle, wlan_res_cfg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303190 wma_handle->tx_chain_mask_cck = cds_cfg->tx_chain_mask_cck;
3191 wma_handle->self_gen_frm_pwr = cds_cfg->self_gen_frm_pwr;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303192 wma_init_max_no_of_peers(wma_handle, cds_cfg->max_station);
3193 cds_cfg->max_station = wma_get_number_of_peers_supported(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303195 cds_cfg->max_bssid = WMA_MAX_SUPPORTED_BSS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303197 wlan_res_cfg->num_keep_alive_pattern = WMA_MAXNUM_PERIODIC_TX_PTRNS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198
3199 /* The current firmware implementation requires the number of
Anurag Chouhanffb21542016-02-17 14:33:03 +05303200 * offload peers should be (number of vdevs + 1).
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 */
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303202 wlan_res_cfg->num_offload_peers =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303203 cds_cfg->ap_maxoffload_peers + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204
Arunk Khandavallicfde2712018-01-25 11:27:42 +05303205 wlan_res_cfg->num_offload_reorder_buffs =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303206 cds_cfg->ap_maxoffload_reorderbuffs + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303208 wma_handle->max_station = cds_cfg->max_station;
3209 wma_handle->max_bssid = cds_cfg->max_bssid;
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303210 wma_handle->driver_type = cds_cfg->driver_type;
3211 wma_handle->ssdp = cds_cfg->ssdp;
3212 wma_handle->enable_mc_list = cds_cfg->enable_mc_list;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05303213 wma_handle->bpf_packet_filter_enable =
3214 cds_cfg->bpf_packet_filter_enable;
Hanumanth Reddy Pothulae87621b2017-04-12 20:53:35 +05303215 wma_handle->active_uc_bpf_mode = cds_cfg->active_uc_bpf_mode;
3216 wma_handle->active_mc_bc_bpf_mode = cds_cfg->active_mc_bc_bpf_mode;
Srinivas Girigowda57b450e2016-10-27 21:00:46 -07003217 wma_handle->link_stats_results = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218#ifdef FEATURE_WLAN_RA_FILTERING
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303219 wma_handle->IsRArateLimitEnabled = cds_cfg->is_ra_ratelimit_enabled;
3220 wma_handle->RArateLimitInterval = cds_cfg->ra_ratelimit_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221#endif /* FEATURE_WLAN_RA_FILTERING */
3222#ifdef WLAN_FEATURE_LPSS
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303223 wma_handle->is_lpass_enabled = cds_cfg->is_lpass_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224#endif
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303225 wma_set_nan_enable(wma_handle, cds_cfg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303226 wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 wma_handle->max_bssid);
3228 if (!wma_handle->interfaces) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003229 WMA_LOGE("%s: failed to allocate interface table", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303230 qdf_status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 goto err_scn_context;
3232 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003233
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003234 for (i = 0; i < wma_handle->max_bssid; ++i) {
Dustin Brownec2c92e2017-07-26 11:13:49 -07003235 wma_vdev_init(&wma_handle->interfaces[i]);
Zhu Jianmina2f8e8d2018-02-11 16:37:10 +08003236 wma_handle->interfaces[i].delay_before_vdev_stop =
3237 cds_cfg->delay_before_vdev_stop;
3238 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 /* Register the debug print event handler */
3240 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303241 wmi_debug_print_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303242 wma_unified_debug_print_event_handler,
3243 WMA_RX_SERIALIZER_CTX);
Govind Singha471e5e2015-10-12 17:11:14 +05303244 /* Register profiling event Handler */
3245 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303246 wmi_wlan_profile_data_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303247 wma_profile_data_report_event_handler,
3248 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249
3250 wma_handle->tgt_cfg_update_cb = tgt_cfg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 wma_handle->old_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
3252 wma_handle->new_hw_mode_index = WMA_DEFAULT_HW_MODE_INDEX;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05303253 wma_handle->saved_chan.num_channels = 0;
Sandeep Puligillaafa52892016-10-26 19:03:16 -07003254 wma_handle->fw_timeout_crash = cds_cfg->fw_timeout_crash;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255
Anurag Chouhan210db072016-02-22 18:42:15 +05303256 qdf_status = qdf_mc_timer_init(&wma_handle->service_ready_ext_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303257 QDF_TIMER_TYPE_SW,
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303258 wma_service_ready_ext_evt_timeout,
3259 wma_handle);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303260 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05303261 WMA_LOGE("Failed to initialize service ready ext timeout");
3262 goto err_event_init;
3263 }
3264
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303265 qdf_status = qdf_event_create(&wma_handle->target_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303266 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003267 WMA_LOGE("%s: target suspend event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 __func__);
3269 goto err_event_init;
3270 }
3271
3272 /* Init Tx Frame Complete event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303273 qdf_status = qdf_event_create(&wma_handle->tx_frm_download_comp_event);
3274 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003275 WMA_LOGE("%s: failed to init tx_frm_download_comp_event",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 __func__);
3277 goto err_event_init;
3278 }
3279
3280 /* Init tx queue empty check event */
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303281 qdf_status = qdf_event_create(&wma_handle->tx_queue_empty_event);
3282 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003283 WMA_LOGE("%s: failed to init tx_queue_empty_event", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 goto err_event_init;
3285 }
3286
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303287 qdf_status = qdf_event_create(&wma_handle->wma_resume_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303288 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003289 WMA_LOGE("%s: wma_resume_event initialization failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 __func__);
3291 goto err_event_init;
3292 }
3293
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003294 qdf_status = cds_shutdown_notifier_register(wma_shutdown_notifier_cb,
3295 wma_handle);
3296 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003297 WMA_LOGE("%s: Shutdown notifier register failed: %d",
Prashanth Bhattae675ca72016-10-20 18:42:37 -07003298 __func__, qdf_status);
3299 goto err_event_init;
3300 }
3301
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303302 qdf_status = qdf_event_create(&wma_handle->runtime_suspend);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303303 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003304 WMA_LOGE("%s: runtime_suspend event initialization failed",
Houston Hoffmana76591b2015-11-10 16:52:05 -08003305 __func__);
3306 goto err_event_init;
3307 }
3308
Anurag Chouhandf2b2682016-02-29 14:15:27 +05303309 qdf_status = qdf_event_create(&wma_handle->recovery_event);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303310 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003311 WMA_LOGE("%s: recovery event initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 goto err_event_init;
3313 }
3314
Anurag Chouhanffb21542016-02-17 14:33:03 +05303315 qdf_list_create(&wma_handle->vdev_resp_queue,
Krishna Kumaar Natarajana5c53bd2015-10-27 11:48:27 -07003316 MAX_ENTRY_VDEV_RESP_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303317 qdf_spinlock_create(&wma_handle->vdev_respq_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05303318 qdf_list_create(&wma_handle->wma_hold_req_queue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 MAX_ENTRY_HOLD_REQ_QUEUE);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303320 qdf_spinlock_create(&wma_handle->wma_hold_req_q_lock);
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +05303321 qdf_atomic_init(&wma_handle->is_wow_bus_suspended);
3322 qdf_atomic_init(&wma_handle->scan_id_counter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323
3324 /* Register vdev start response event handler */
3325 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303326 wmi_vdev_start_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303327 wma_vdev_start_resp_handler,
3328 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329
3330 /* Register vdev stop response event handler */
3331 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303332 wmi_vdev_stopped_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303333 wma_vdev_stop_resp_handler,
3334 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335
3336 /* register for STA kickout function */
3337 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303338 wmi_peer_sta_kickout_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303339 wma_peer_sta_kickout_event_handler,
3340 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341
Naveen Rawate8b1b822018-01-30 09:46:16 -08003342 /* register for stats event */
3343 wma_register_stats_events(wma_handle->wmi_handle);
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303344
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303345 /* register for stats response event */
3346 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303347 wmi_get_arp_stats_req_id,
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05303348 wma_get_arp_stats_handler,
3349 WMA_RX_SERIALIZER_CTX);
3350
Will Huanga9814592017-05-24 15:47:58 +08003351 /* register for peer info response event */
3352 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303353 wmi_peer_stats_info_event_id,
Will Huanga9814592017-05-24 15:47:58 +08003354 wma_peer_info_event_handler,
3355 WMA_RX_SERIALIZER_CTX);
3356
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303357#ifdef WLAN_POWER_DEBUGFS
3358 /* register for Chip Power stats event */
3359 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303360 wmi_pdev_chip_power_stats_event_id,
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05303361 wma_unified_power_debug_stats_event_handler,
3362 WMA_RX_SERIALIZER_CTX);
3363#endif
3364
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 /* register for linkspeed response event */
3366 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303367 wmi_peer_estimated_linkspeed_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303368 wma_link_speed_event_handler,
3369 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370
3371#ifdef FEATURE_OEM_DATA_SUPPORT
3372 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303373 wmi_oem_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303374 wma_oem_data_response_handler,
3375 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376#endif /* FEATURE_OEM_DATA_SUPPORT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377
3378 /* Register peer change event handler */
3379 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303380 wmi_peer_state_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303381 wma_peer_state_change_event_handler,
3382 WMA_RX_WORK_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383
3384 /* Register beacon tx complete event id. The event is required
3385 * for sending channel switch announcement frames
3386 */
3387 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303388 wmi_offload_bcn_tx_status_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303389 wma_unified_bcntx_status_event_handler,
3390 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391
3392 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303393 wmi_update_vdev_rate_stats_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303394 wma_link_status_event_handler,
3395 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396#ifdef WLAN_FEATURE_LINK_LAYER_STATS
3397 /* Register event handler for processing Link Layer Stats
3398 * response from the FW
3399 */
3400 wma_register_ll_stats_event_handler(wma_handle);
3401
3402#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
3403
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +05303404 wmi_set_tgt_assert(wma_handle->wmi_handle,
3405 cds_cfg->force_target_assert_enabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 /* Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303407 qdf_status = dbglog_init(wma_handle->wmi_handle);
3408 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003409 WMA_LOGE("%s: Firmware Dbglog initialization failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 goto err_dbglog_init;
3411 }
3412
3413 /*
3414 * Update Powersave mode
3415 * 1 - Legacy Powersave + Deepsleep Disabled
3416 * 2 - QPower + Deepsleep Disabled
3417 * 3 - Legacy Powersave + Deepsleep Enabled
3418 * 4 - QPower + Deepsleep Enabled
3419 */
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303420 wma_handle->powersave_mode = cds_cfg->powersave_offload_enabled;
3421 wma_handle->staMaxLIModDtim = cds_cfg->sta_maxlimod_dtim;
3422 wma_handle->staModDtim = cds_cfg->sta_mod_dtim;
3423 wma_handle->staDynamicDtim = cds_cfg->sta_dynamic_dtim;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424
3425 /*
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303426 * Value of cds_cfg->wow_enable can be,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 * 0 - Disable both magic pattern match and pattern byte match.
3428 * 1 - Enable magic pattern match on all interfaces.
3429 * 2 - Enable pattern byte match on all interfaces.
3430 * 3 - Enable both magic patter and pattern byte match on
3431 * all interfaces.
3432 */
3433 wma_handle->wow.magic_ptrn_enable =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303434 (cds_cfg->wow_enable & 0x01) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 wma_handle->ptrn_match_enable_all_vdev =
Arun Khandavallic811dcc2016-06-26 07:37:21 +05303436 (cds_cfg->wow_enable & 0x02) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 /* register for install key completion event */
3439 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303440 wmi_vdev_install_key_complete_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303441 wma_vdev_install_key_complete_event_handler,
3442 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443#ifdef WLAN_FEATURE_NAN
3444 /* register for nan response event */
3445 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303446 wmi_nan_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303447 wma_nan_rsp_event_handler,
3448 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449#endif /* WLAN_FEATURE_NAN */
3450
3451#ifdef WLAN_FEATURE_STATS_EXT
3452 /* register for extended stats event */
3453 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303454 wmi_stats_ext_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303455 wma_stats_ext_event_handler,
3456 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457#endif /* WLAN_FEATURE_STATS_EXT */
3458#ifdef FEATURE_WLAN_EXTSCAN
3459 wma_register_extscan_event_handler(wma_handle);
3460#endif /* WLAN_FEATURE_STATS_EXT */
3461
3462 WMA_LOGD("%s: Exit", __func__);
3463
3464#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3465 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303466 wmi_roam_synch_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303467 wma_roam_synch_event_handler,
3468 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303469 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303470 wmi_roam_synch_frame_event_id,
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05303471 wma_roam_synch_frame_event_handler,
3472 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
3474 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303475 wmi_rssi_breach_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303476 wma_rssi_breached_event_handler,
3477 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303479 qdf_wake_lock_create(&wma_handle->wmi_cmd_rsp_wake_lock,
Govind Singhd76a5b02016-03-08 15:12:14 +05303480 "wlan_fw_rsp_wakelock");
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003481 qdf_runtime_lock_init(&wma_handle->wmi_cmd_rsp_runtime_lock);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003482
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 /* Register peer assoc conf event handler */
3484 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303485 wmi_peer_assoc_conf_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303486 wma_peer_assoc_conf_handler,
3487 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003488 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303489 wmi_vdev_delete_resp_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303490 wma_vdev_delete_handler,
3491 WMA_RX_SERIALIZER_CTX);
Sandeep Puligilla19ddda22016-01-05 12:18:02 -08003492 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303493 wmi_peer_delete_response_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05303494 wma_peer_delete_handler,
3495 WMA_RX_SERIALIZER_CTX);
Arun Khandavalli2476ef52016-04-26 20:19:43 +05303496 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303497 wmi_bpf_capability_info_event_id,
Arun Khandavalli2476ef52016-04-26 20:19:43 +05303498 wma_get_bpf_caps_event_handler,
3499 WMA_RX_SERIALIZER_CTX);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +05303500 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303501 wmi_chan_info_event_id,
Kapil Gupta4f0c0c12017-02-07 15:21:15 +05303502 wma_chan_info_event_handler,
3503 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003504 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303505 wmi_dbg_mesg_flush_complete_event_id,
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003506 wma_flush_complete_evt_handler,
Rajeev Kumarc3032b82017-02-14 15:56:01 -08003507 WMA_RX_WORK_CTX);
lifeng66831662017-05-19 16:01:35 +08003508 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303509 wmi_report_rx_aggr_failure_event_id,
lifeng66831662017-05-19 16:01:35 +08003510 wma_rx_aggr_failure_event_handler,
3511 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar91ac6ac2017-02-14 15:49:14 -08003512
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303513 wma_handle->ito_repeat_count = cds_cfg->ito_repeat_count;
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07003514 wma_handle->bandcapability = cds_cfg->bandcapability;
Ashish Kumar Dhanotiya9335d812017-06-30 16:57:20 +05303515
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303516 /* Register PWR_SAVE_FAIL event only in case of recovery(1) */
Hanumanth Reddy Pothulaab395952017-09-05 19:12:26 +05303517 if (cds_cfg->auto_power_save_fail_mode ==
3518 PMO_FW_TO_SEND_WOW_IND_ON_PWR_FAILURE) {
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303519 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303520 wmi_pdev_chip_pwr_save_failure_detect_event_id,
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303521 wma_chip_power_save_failure_detected_handler,
3522 WMA_RX_WORK_CTX);
3523 }
3524
lifengd217d192017-05-09 19:44:16 +08003525 wmi_unified_register_event_handler(wma_handle->wmi_handle,
lifengfe6c3e22018-04-03 12:10:04 +08003526 wmi_pdev_div_rssi_antid_event_id,
3527 wma_pdev_div_info_evt_handler,
lifengd217d192017-05-09 19:44:16 +08003528 WMA_RX_WORK_CTX);
3529
Frank Liu65b17d92016-11-23 15:58:44 +08003530
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303531 wma_register_debug_callback();
Mukul Sharma6411bb82017-03-01 15:57:07 +05303532 /* Register callback with PMO so PMO can update the vdev pause bitmap*/
3533 pmo_register_pause_bitmap_notifier(wma_handle->psoc,
3534 wma_vdev_update_pause_bitmap);
3535 pmo_register_get_pause_bitmap(wma_handle->psoc,
3536 wma_vdev_get_pause_bitmap);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05303537 pmo_register_is_device_in_low_pwr_mode(wma_handle->psoc,
3538 wma_vdev_is_device_in_low_pwr_mode);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003539 wma_cbacks.wma_get_connection_info = wma_get_connection_info;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07003540 qdf_status = policy_mgr_register_wma_cb(wma_handle->psoc, &wma_cbacks);
3541 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
3542 WMA_LOGE("Failed to register wma cb with Policy Manager");
3543 }
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +05303544
Arif Hussainf63f7a32017-08-22 12:49:42 -07003545 wmi_unified_register_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303546 wmi_phyerr_event_id,
Arif Hussainf63f7a32017-08-22 12:49:42 -07003547 wma_unified_phyerr_rx_event_handler,
3548 WMA_RX_WORK_CTX);
3549
Arif Hussainee10f902017-12-27 16:30:17 -08003550 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3551 wmi_sap_obss_detection_report_event_id,
3552 wma_vdev_obss_detection_info_handler,
3553 WMA_RX_SERIALIZER_CTX);
3554
Arif Hussain05fb4872018-01-03 16:02:55 -08003555 wmi_unified_register_event_handler(wma_handle->wmi_handle,
3556 wmi_obss_color_collision_report_event_id,
3557 wma_vdev_bss_color_collision_info_handler,
3558 WMA_RX_WORK_CTX);
3559
3560
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303561 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562
3563err_dbglog_init:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303564 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08003565 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303566 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
3567 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568err_event_init:
3569 wmi_unified_unregister_event_handler(wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05303570 wmi_debug_print_event_id);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003571
3572 for (i = 0; i < wma_handle->max_bssid; ++i)
3573 wma_vdev_deinit(&wma_handle->interfaces[i]);
3574
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303575 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003576
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577err_scn_context:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303578 qdf_mem_free(((p_cds_contextType) cds_context)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 OS_FREE(wmi_handle);
3580
3581err_wma_handle:
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303582 target_if_free_psoc_tgt_info(psoc);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303583 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303585 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05303587 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05303588 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
3589 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
3590 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
3591 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
3592 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
3593 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
3594 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303596err_free_wma_handle:
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07003597 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598
3599 WMA_LOGD("%s: Exit", __func__);
3600
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303601 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602}
3603
3604/**
3605 * wma_pre_start() - wma pre start
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 *
3607 * Return: 0 on success, errno on failure
3608 */
Jeff Johnson8ad89c62017-09-13 08:55:55 -07003609QDF_STATUS wma_pre_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303611 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 tp_wma_handle wma_handle;
Rajeev Kumarb60abe42017-01-21 15:39:31 -08003613 struct scheduler_msg wma_msg = { 0 };
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303614 void *htc_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615
3616 WMA_LOGD("%s: Enter", __func__);
3617
Anurag Chouhan6d760662016-02-20 16:05:43 +05303618 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619
3620 /* Validate the wma_handle */
3621 if (NULL == wma_handle) {
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303622 WMA_LOGE("%s: invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303623 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624 goto end;
3625 }
Nachiket Kukade8003d252017-03-30 15:55:58 +05303626
Arunk Khandavallia6305a32018-01-25 11:19:18 +05303627 htc_handle = ucfg_get_htc_hdl(wma_handle->psoc);
3628 if (!htc_handle) {
3629 WMA_LOGE("%s: invalid htc handle", __func__);
3630 qdf_status = QDF_STATUS_E_INVAL;
3631 goto end;
3632 }
3633
3634 /* Open endpoint for ctrl path - WMI <--> HTC */
3635 qdf_status = wmi_unified_connect_htc_service(wma_handle->wmi_handle,
3636 htc_handle);
3637 if (qdf_status != QDF_STATUS_SUCCESS) {
3638 WMA_LOGE("%s: wmi_unified_connect_htc_service", __func__);
Nachiket Kukade8003d252017-03-30 15:55:58 +05303639 if (!cds_is_fw_down())
3640 QDF_BUG(0);
3641
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303642 qdf_status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 goto end;
3644 }
3645
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08003646 WMA_LOGD("WMA --> wmi_unified_connect_htc_service - success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647
3648 /* Trigger the CFG DOWNLOAD */
3649 wma_msg.type = WNI_CFG_DNLD_REQ;
3650 wma_msg.bodyptr = NULL;
3651 wma_msg.bodyval = 0;
3652
Rajeev Kumarb60abe42017-01-21 15:39:31 -08003653 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &wma_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303654 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003655 WMA_LOGE("%s: Failed to post WNI_CFG_DNLD_REQ msg", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303656 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303657 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 }
3659end:
3660 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303661 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662}
3663
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303664void wma_send_msg_by_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3665 void *body_ptr, uint32_t body_val, bool is_high_priority)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666{
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303667 struct scheduler_msg msg = {0};
3668 QDF_STATUS status;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 msg.type = msg_type;
3671 msg.bodyval = body_val;
3672 msg.bodyptr = body_ptr;
Will Huang9323e852018-02-02 17:55:15 +08003673 msg.flush_callback = wma_discard_fw_event;
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303674
3675 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE,
3676 &msg, is_high_priority);
3677 if (!QDF_IS_STATUS_SUCCESS(status)) {
3678 WMA_LOGE("Failed to post msg %d to PE", msg_type);
3679 if (body_ptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303680 qdf_mem_free(body_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682}
3683
Abhishek Singh2d775fd2017-08-18 10:51:33 +05303684
3685void wma_send_msg(tp_wma_handle wma_handle, uint16_t msg_type,
3686 void *body_ptr, uint32_t body_val)
3687{
3688 wma_send_msg_by_priority(wma_handle, msg_type,
3689 body_ptr, body_val, false);
3690}
3691
3692void wma_send_msg_high_priority(tp_wma_handle wma_handle, uint16_t msg_type,
3693 void *body_ptr, uint32_t body_val)
3694{
3695 wma_send_msg_by_priority(wma_handle, msg_type,
3696 body_ptr, body_val, true);
3697}
3698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699/**
3700 * wma_set_base_macaddr_indicate() - set base mac address in fw
3701 * @wma_handle: wma handle
3702 * @customAddr: base mac address
3703 *
3704 * Return: 0 for success or error code
3705 */
3706static int wma_set_base_macaddr_indicate(tp_wma_handle wma_handle,
3707 tSirMacAddr *customAddr)
3708{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709 int err;
3710
Govind Singhf25a0f12016-03-08 16:09:48 +05303711 err = wmi_unified_set_base_macaddr_indicate_cmd(wma_handle->wmi_handle,
3712 (uint8_t *)customAddr);
3713 if (err)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 return -EIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715 WMA_LOGD("Base MAC Addr: " MAC_ADDRESS_STR,
3716 MAC_ADDR_ARRAY((*customAddr)));
3717
3718 return 0;
3719}
3720
3721/**
3722 * wma_log_supported_evt_handler() - Enable/Disable FW diag/log events
3723 * @handle: WMA handle
3724 * @event: Event received from FW
3725 * @len: Length of the event
3726 *
3727 * Enables the low frequency events and disables the high frequency
3728 * events. Bit 17 indicates if the event if low/high frequency.
3729 * 1 - high frequency, 0 - low frequency
3730 *
3731 * Return: 0 on successfully enabling/disabling the events
3732 */
3733static int wma_log_supported_evt_handler(void *handle,
3734 uint8_t *event,
3735 uint32_t len)
3736{
3737 tp_wma_handle wma = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003738
Govind Singhf25a0f12016-03-08 16:09:48 +05303739 if (wmi_unified_log_supported_evt_cmd(wma->wmi_handle,
3740 event, len))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742
3743 return 0;
3744}
3745
3746/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303747 * wma_pdev_set_hw_mode_resp_evt_handler() - Set HW mode resp evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748 * @handle: WMI handle
3749 * @event: Event recevied from FW
3750 * @len: Length of the event
3751 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303752 * Event handler for WMI_PDEV_SET_HW_MODE_RESP_EVENTID that is sent to host
3753 * driver in response to a WMI_PDEV_SET_HW_MODE_CMDID being sent to WLAN
3754 * firmware
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755 *
Dustin Brownec2c92e2017-07-26 11:13:49 -07003756 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003757 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303758static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 uint8_t *event,
3760 uint32_t len)
3761{
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303762 WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *param_buf;
3763 wmi_pdev_set_hw_mode_response_event_fixed_param *wmi_event;
3764 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 uint32_t i;
3766 struct sir_set_hw_mode_resp *hw_mode_resp;
3767 tp_wma_handle wma = (tp_wma_handle) handle;
3768
3769 if (!wma) {
3770 WMA_LOGE("%s: Invalid WMA handle", __func__);
3771 /* Since WMA handle itself is NULL, we cannot send fail
3772 * response back to LIM here
3773 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303774 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07003776
3777 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -08003778 wma_remove_req(wma, 0, WMA_PDEV_SET_HW_MODE_RESP);
Dustin Brownec2c92e2017-07-26 11:13:49 -07003779
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303780 hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 if (!hw_mode_resp) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003782 WMA_LOGE("%s: Memory allocation failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783 /* Since this memory allocation itself failed, we cannot
3784 * send fail response back to LIM here
3785 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303786 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787 }
3788
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303789 param_buf = (WMI_PDEV_SET_HW_MODE_RESP_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 if (!param_buf) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303791 WMA_LOGE("Invalid WMI_PDEV_SET_HW_MODE_RESP_EVENTID event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 /* Need to send response back to upper layer to free
3793 * active command list
3794 */
3795 goto fail;
3796 }
Krunal Soni50a05542017-10-03 19:39:48 -07003797 if (param_buf->fixed_param->num_vdev_mac_entries >=
3798 MAX_VDEV_SUPPORTED) {
3799 WMA_LOGE("num_vdev_mac_entries crossed max value");
3800 goto fail;
3801 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802
3803 wmi_event = param_buf->fixed_param;
Abhinav Kumara03659c2017-12-28 15:18:07 +05303804 if (wmi_event->num_vdev_mac_entries >
3805 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
3806 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
3807 wmi_event->num_vdev_mac_entries);
3808 goto fail;
3809 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 hw_mode_resp->status = wmi_event->status;
3811 hw_mode_resp->cfgd_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3812 hw_mode_resp->num_vdev_mac_entries = wmi_event->num_vdev_mac_entries;
3813
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003814 WMA_LOGD("%s: status:%d cfgd_hw_mode_index:%d num_vdev_mac_entries:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815 __func__, wmi_event->status,
3816 wmi_event->cfgd_hw_mode_index,
3817 wmi_event->num_vdev_mac_entries);
3818 vdev_mac_entry =
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303819 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820
3821 /* Store the vdev-mac map in WMA and prepare to send to PE */
3822 for (i = 0; i < wmi_event->num_vdev_mac_entries; i++) {
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303823 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003824
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825 vdev_id = vdev_mac_entry[i].vdev_id;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303826 pdev_id = vdev_mac_entry[i].pdev_id;
3827 if (pdev_id == WMI_PDEV_ID_SOC) {
3828 WMA_LOGE("%s: soc level id received for mac id)",
3829 __func__);
3830 QDF_BUG(0);
3831 goto fail;
3832 }
3833 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003834
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003835 WMA_LOGD("%s: vdev_id:%d mac_id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003836 __func__, vdev_id, mac_id);
3837
3838 hw_mode_resp->vdev_mac_map[i].vdev_id = vdev_id;
3839 hw_mode_resp->vdev_mac_map[i].mac_id = mac_id;
3840 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3841 wmi_event->cfgd_hw_mode_index);
3842 }
3843
3844 if (hw_mode_resp->status == SET_HW_MODE_STATUS_OK) {
3845 if (WMA_DEFAULT_HW_MODE_INDEX == wma->new_hw_mode_index) {
3846 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3847 } else {
3848 wma->old_hw_mode_index = wma->new_hw_mode_index;
3849 wma->new_hw_mode_index = wmi_event->cfgd_hw_mode_index;
3850 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003851 policy_mgr_update_hw_mode_index(wma->psoc,
3852 wmi_event->cfgd_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 }
3854
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003855 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3857
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303858 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859 (void *) hw_mode_resp, 0);
3860
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303861 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862
3863fail:
3864 WMA_LOGE("%s: Sending fail response to LIM", __func__);
3865 hw_mode_resp->status = SET_HW_MODE_STATUS_ECANCELED;
3866 hw_mode_resp->cfgd_hw_mode_index = 0;
3867 hw_mode_resp->num_vdev_mac_entries = 0;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05303868 wma_send_msg(wma, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 (void *) hw_mode_resp, 0);
3870
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303871 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872}
3873
3874/**
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003875 * wma_process_pdev_hw_mode_trans_ind() - Process HW mode transition info
3876 *
3877 * @handle: WMA handle
3878 * @fixed_param: Event fixed parameters
3879 * @vdev_mac_entry - vdev mac entry
3880 * @hw_mode_trans_ind - Buffer to store parsed information
3881 *
3882 * Parses fixed_param, vdev_mac_entry and fills in the information into
3883 * hw_mode_trans_ind and wma
3884 *
3885 * Return: None
3886 */
3887void wma_process_pdev_hw_mode_trans_ind(void *handle,
3888 wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param,
3889 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry,
3890 struct sir_hw_mode_trans_ind *hw_mode_trans_ind)
3891{
3892 uint32_t i;
3893 tp_wma_handle wma = (tp_wma_handle) handle;
gaurank kathpaliad2967a72018-05-01 12:35:14 +05303894 if (fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
3895 WMA_LOGE("Number of Vdev mac entries %d exceeded"
3896 " max vdev supported %d",
3897 fixed_param->num_vdev_mac_entries,
3898 MAX_VDEV_SUPPORTED);
3899 return;
3900 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003901 hw_mode_trans_ind->old_hw_mode_index = fixed_param->old_hw_mode_index;
3902 hw_mode_trans_ind->new_hw_mode_index = fixed_param->new_hw_mode_index;
3903 hw_mode_trans_ind->num_vdev_mac_entries =
3904 fixed_param->num_vdev_mac_entries;
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003905 WMA_LOGD("%s: old_hw_mode_index:%d new_hw_mode_index:%d entries=%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003906 __func__, fixed_param->old_hw_mode_index,
3907 fixed_param->new_hw_mode_index,
3908 fixed_param->num_vdev_mac_entries);
3909
3910 /* Store the vdev-mac map in WMA and send to policy manager */
3911 for (i = 0; i < fixed_param->num_vdev_mac_entries; i++) {
3912 uint32_t vdev_id, mac_id, pdev_id;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07003913
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003914 vdev_id = vdev_mac_entry[i].vdev_id;
3915 pdev_id = vdev_mac_entry[i].pdev_id;
3916
3917 if (pdev_id == WMI_PDEV_ID_SOC) {
3918 WMA_LOGE("%s: soc level id received for mac id)",
3919 __func__);
3920 QDF_BUG(0);
3921 return;
3922 }
3923
3924 mac_id = WMA_PDEV_TO_MAC_MAP(vdev_mac_entry[i].pdev_id);
3925
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003926 WMA_LOGE("%s: vdev_id:%d mac_id:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003927 __func__, vdev_id, mac_id);
3928
3929 hw_mode_trans_ind->vdev_mac_map[i].vdev_id = vdev_id;
3930 hw_mode_trans_ind->vdev_mac_map[i].mac_id = mac_id;
3931 wma_update_intf_hw_mode_params(vdev_id, mac_id,
3932 fixed_param->new_hw_mode_index);
3933 }
3934 wma->old_hw_mode_index = fixed_param->old_hw_mode_index;
3935 wma->new_hw_mode_index = fixed_param->new_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07003936 policy_mgr_update_new_hw_mode_index(wma->psoc,
3937 fixed_param->new_hw_mode_index);
3938 policy_mgr_update_old_hw_mode_index(wma->psoc,
3939 fixed_param->old_hw_mode_index);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003940
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -08003941 WMA_LOGD("%s: Updated: old_hw_mode_index:%d new_hw_mode_index:%d",
Naveen Rawat8cc23b02016-07-14 12:22:56 -07003942 __func__, wma->old_hw_mode_index, wma->new_hw_mode_index);
3943}
3944
3945/**
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303946 * wma_pdev_hw_mode_transition_evt_handler() - HW mode transition evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 * @handle: WMI handle
3948 * @event: Event recevied from FW
3949 * @len: Length of the event
3950 *
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303951 * Event handler for WMI_PDEV_HW_MODE_TRANSITION_EVENTID that indicates an
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952 * asynchronous hardware mode transition. This event notifies the host driver
3953 * that firmware independently changed the hardware mode for some reason, such
3954 * as Coex, LFR 3.0, etc
3955 *
3956 * Return: Success on receiving valid params from FW
3957 */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303958static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 uint8_t *event,
3960 uint32_t len)
3961{
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303962 WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *param_buf;
3963 wmi_pdev_hw_mode_transition_event_fixed_param *wmi_event;
3964 wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965 struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
3966 tp_wma_handle wma = (tp_wma_handle) handle;
3967
3968 if (!wma) {
3969 /* This is an async event. So, not sending any event to LIM */
3970 WMA_LOGE("Invalid WMA handle");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303971 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003972 }
3973
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303974 param_buf = (WMI_PDEV_HW_MODE_TRANSITION_EVENTID_param_tlvs *) event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 if (!param_buf) {
3976 /* This is an async event. So, not sending any event to LIM */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303977 WMA_LOGE("Invalid WMI_PDEV_HW_MODE_TRANSITION_EVENTID event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303978 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 }
3980
Arif Hussain34f72062017-10-04 17:25:24 -07003981 if (param_buf->fixed_param->num_vdev_mac_entries > MAX_VDEV_SUPPORTED) {
3982 WMA_LOGE("num_vdev_mac_entries: %d crossed max value: %d",
3983 param_buf->fixed_param->num_vdev_mac_entries,
3984 MAX_VDEV_SUPPORTED);
3985 return QDF_STATUS_E_FAILURE;
3986 }
3987
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303988 hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 if (!hw_mode_trans_ind) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07003990 WMA_LOGE("%s: Memory allocation failed", __func__);
3991 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 }
3993
3994 wmi_event = param_buf->fixed_param;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 vdev_mac_entry =
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05303996 param_buf->wmi_pdev_set_hw_mode_response_vdev_mac_mapping;
Abhinav Kumara03659c2017-12-28 15:18:07 +05303997 if (wmi_event->num_vdev_mac_entries >
3998 param_buf->num_wmi_pdev_set_hw_mode_response_vdev_mac_mapping) {
3999 WMA_LOGE("Invalid num_vdev_mac_entries: %d",
4000 wmi_event->num_vdev_mac_entries);
4001 qdf_mem_free(hw_mode_trans_ind);
4002 return -EINVAL;
4003 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004004 wma_process_pdev_hw_mode_trans_ind(wma, wmi_event, vdev_mac_entry,
4005 hw_mode_trans_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 /* Pass the message to PE */
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304007 wma_send_msg(wma, SIR_HAL_PDEV_HW_MODE_TRANS_IND,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 (void *) hw_mode_trans_ind, 0);
4009
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304010 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004011}
4012
4013/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304014 * wma_pdev_set_dual_mode_config_resp_evt_handler() - Dual mode evt handler
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 * @handle: WMI handle
4016 * @event: Event received from FW
4017 * @len: Length of the event
4018 *
4019 * Notifies the host driver of the completion or failure of a
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304020 * WMI_PDEV_SET_MAC_CONFIG_CMDID command. This event would be returned to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021 * the host driver once the firmware has completed a reconfiguration of the Scan
4022 * and FW mode configuration. This changes could include entering or leaving a
4023 * dual mac configuration for either scan and/or more permanent firmware mode.
4024 *
4025 * Return: Success on receiving valid params from FW
4026 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304027static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028 uint8_t *event,
4029 uint32_t len)
4030{
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304031 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *param_buf;
4032 wmi_pdev_set_mac_config_response_event_fixed_param *wmi_event;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 tp_wma_handle wma = (tp_wma_handle) handle;
4034 struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
4035
4036 if (!wma) {
4037 WMA_LOGE("%s: Invalid WMA handle", __func__);
4038 /* Since the WMA handle is NULL, we cannot send resp to LIM.
4039 * So, returning from here.
4040 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304041 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 }
Krunal Sonia5ccb802017-07-03 12:59:40 -07004043 wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304044 dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 if (!dual_mac_cfg_resp) {
4046 WMA_LOGE("%s: Memory allocation failed", __func__);
4047 /* Since the mem alloc failed, we cannot send resp to LIM.
4048 * So, returning from here.
4049 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304050 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 }
4052
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304053 param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054 event;
4055 if (!param_buf) {
4056 WMA_LOGE("%s: Invalid event", __func__);
4057 goto fail;
4058 }
4059
4060 wmi_event = param_buf->fixed_param;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004061 WMA_LOGD("%s: status:%d", __func__, wmi_event->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062 dual_mac_cfg_resp->status = wmi_event->status;
4063
4064 if (SET_HW_MODE_STATUS_OK == dual_mac_cfg_resp->status) {
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07004065 policy_mgr_update_dbs_scan_config(wma->psoc);
4066 policy_mgr_update_dbs_fw_config(wma->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 }
4068
4069 /* Pass the message to PE */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304070 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 (void *) dual_mac_cfg_resp, 0);
4072
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304073 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074
4075fail:
4076 WMA_LOGE("%s: Sending fail response to LIM", __func__);
4077 dual_mac_cfg_resp->status = SET_HW_MODE_STATUS_ECANCELED;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304078 wma_send_msg(wma, SIR_HAL_PDEV_MAC_CFG_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 (void *) dual_mac_cfg_resp, 0);
4080
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304081 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082
4083}
4084
4085/**
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304086 * wma_send_time_stamp_sync_cmd() - timer callback send timestamp to
4087 * firmware to sync with host.
4088 * @wma_handle: wma handle
4089 *
4090 * Return: void
4091 */
4092static void wma_send_time_stamp_sync_cmd(void *data)
4093{
4094 tp_wma_handle wma_handle;
4095 QDF_STATUS qdf_status;
4096
4097 wma_handle = (tp_wma_handle) data;
4098
4099 wmi_send_time_stamp_sync_cmd_tlv(wma_handle->wmi_handle);
4100
4101 /* Start/Restart the timer */
4102 qdf_status = qdf_mc_timer_start(&wma_handle->wma_fw_time_sync_timer,
4103 WMA_FW_TIME_SYNC_TIMER);
4104 if (QDF_IS_STATUS_ERROR(qdf_status))
4105 WMA_LOGE("Failed to start the firmware time sync timer");
4106}
4107
4108/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 * wma_start() - wma start function.
4110 * Intialize event handlers and timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304112 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 */
Jeff Johnsond4892552017-09-13 08:41:31 -07004114QDF_STATUS wma_start(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304116 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 tp_wma_handle wma_handle;
4118 int status;
Sandeep Puligilla063a4342018-01-10 02:50:14 -08004119 struct wmi_spectral_cmd_ops cmd_ops;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304120 struct wmi_unified *wmi_handle;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07004121
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 WMA_LOGD("%s: Enter", __func__);
4123
Anurag Chouhan6d760662016-02-20 16:05:43 +05304124 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 /* validate the wma_handle */
4126 if (NULL == wma_handle) {
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304127 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304128 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 goto end;
4130 }
Sandeep Puligillad698bf52017-09-15 16:07:02 -07004131
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304132 wmi_handle = ucfg_get_wmi_hdl(wma_handle->psoc);
4133 if (!wmi_handle) {
4134 WMA_LOGE("%s: Invalid wmi handle", __func__);
4135 qdf_status = QDF_STATUS_E_INVAL;
4136 goto end;
4137 }
4138
4139 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304140 wmi_roam_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304141 wma_roam_event_callback,
Padma, Santhosh Kumar18169ce2017-03-02 18:04:02 +05304142 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004144 WMA_LOGE("%s: Failed to register Roam callback", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304145 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 goto end;
4147 }
4148
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304149 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304150 wmi_wow_wakeup_host_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304151 wma_wow_wakeup_host_event,
4152 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004154 WMA_LOGE("%s: Failed to register wow wakeup host event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304156 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 goto end;
4158 }
4159
Will Huang3cd2b7c2017-11-17 13:16:56 +08004160 if (wma_d0_wow_is_supported()) {
4161 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304162 wmi_handle,
Will Huang9adefff2017-12-15 14:50:03 +08004163 wmi_d0_wow_disable_ack_event_id,
Will Huang3cd2b7c2017-11-17 13:16:56 +08004164 wma_d0_wow_disable_ack_event,
4165 WMA_RX_TASKLET_CTX);
4166 if (status) {
4167 WMA_LOGE("%s: Failed to register d0wow disable ack"
4168 " event handler", __func__);
4169 qdf_status = QDF_STATUS_E_FAILURE;
4170 goto end;
4171 }
4172 }
4173
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304174 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304175 wmi_pdev_resume_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304176 wma_pdev_resume_event_handler,
4177 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 if (status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004179 WMA_LOGE("%s: Failed to register PDEV resume event handler",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304181 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 goto end;
4183 }
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05304184#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
4185 defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(CONFIG_HL_SUPPORT)
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08004186 WMA_LOGD("MCC TX Pause Event Handler register");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304187 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304188 wmi_tx_pause_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304189 wma_mcc_vdev_tx_pause_evt_handler,
4190 WMA_RX_TASKLET_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
4192
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
4194 WMA_LOGD("Registering auto shutdown handler");
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304195 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304196 wmi_host_auto_shutdown_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304197 wma_auto_shutdown_event_handler,
4198 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 if (status) {
4200 WMA_LOGE("Failed to register WMI Auto shutdown event handler");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304201 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202 goto end;
4203 }
4204#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304205 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304206 wmi_thermal_mgmt_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304207 wma_thermal_mgmt_evt_handler,
4208 WMA_RX_SERIALIZER_CTX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 if (status) {
4210 WMA_LOGE("Failed to register thermal mitigation event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304211 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212 goto end;
4213 }
4214
Zhang Qian47e22ce2018-01-04 15:38:38 +08004215 status = wma_ocb_register_callbacks(wma_handle);
4216 if (!QDF_IS_STATUS_SUCCESS(status)) {
4217 WMA_LOGE("Failed to register OCB callbacks");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304218 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219 goto end;
4220 }
4221
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304222 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223
4224#ifdef QCA_WIFI_FTM
4225 /*
4226 * Tx mgmt attach requires TXRX context which is not created
4227 * in FTM mode. So skip the TX mgmt attach.
4228 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304229 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230 goto end;
4231#endif /* QCA_WIFI_FTM */
4232
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304233 if (wmi_service_enabled(wmi_handle, wmi_service_rmc)) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004234
4235 WMA_LOGD("FW supports cesium network, registering event handlers");
4236
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004237 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304238 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304239 wmi_peer_info_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004240 wma_ibss_peer_info_event_handler,
4241 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004242 if (status) {
4243 WMA_LOGE("Failed to register ibss peer info event cb");
4244 qdf_status = QDF_STATUS_E_FAILURE;
4245 goto end;
4246 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004247 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304248 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304249 wmi_peer_tx_fail_cnt_thr_event_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004250 wma_fast_tx_fail_event_handler,
4251 WMA_RX_SERIALIZER_CTX);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004252 if (status) {
4253 WMA_LOGE("Failed to register peer fast tx failure event cb");
4254 qdf_status = QDF_STATUS_E_FAILURE;
4255 goto end;
4256 }
4257 } else {
4258 WMA_LOGE("Target does not support cesium network");
4259 }
4260
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304261 qdf_status = wma_tx_attach(wma_handle);
4262 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004263 WMA_LOGE("%s: Failed to register tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 goto end;
4265 }
4266
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304267 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4268 /* Initialize firmware time stamp sync timer */
4269 qdf_status =
4270 qdf_mc_timer_init(&wma_handle->wma_fw_time_sync_timer,
4271 QDF_TIMER_TYPE_SW,
4272 wma_send_time_stamp_sync_cmd,
4273 wma_handle);
4274 if (QDF_IS_STATUS_ERROR(qdf_status))
4275 WMA_LOGE(FL("Failed to initialize firmware time stamp sync timer"));
4276 /* Start firmware time stamp sync timer */
4277 wma_send_time_stamp_sync_cmd(wma_handle);
4278 }
4279
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 /* Initialize log completion timeout */
Anurag Chouhan210db072016-02-22 18:42:15 +05304281 qdf_status = qdf_mc_timer_init(&wma_handle->log_completion_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304282 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 wma_log_completion_timeout,
4284 wma_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304285 if (qdf_status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 WMA_LOGE("Failed to initialize log completion timeout");
4287 goto end;
4288 }
4289
Jeff Johnson6136fb92017-03-30 15:21:49 -07004290 status = wma_fips_register_event_handlers(wma_handle);
4291 if (!QDF_IS_STATUS_SUCCESS(status)) {
4292 WMA_LOGE("Failed to register FIPS event handler");
4293 qdf_status = QDF_STATUS_E_FAILURE;
4294 goto end;
4295 }
4296
Jeff Johnsonf0e54b02017-12-18 15:22:25 -08004297 status = wma_sar_register_event_handlers(wma_handle);
4298 if (!QDF_IS_STATUS_SUCCESS(status)) {
4299 WMA_LOGE("Failed to register SAR event handlers");
4300 qdf_status = QDF_STATUS_E_FAILURE;
4301 goto end;
4302 }
4303
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004304 /* Initialize the get temperature event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304305 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304306 wmi_pdev_temperature_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05304307 wma_pdev_temperature_evt_handler,
4308 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304309 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310 WMA_LOGE("Failed to register get_temperature event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304311 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 goto end;
4313 }
4314
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304315 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304316 wmi_vdev_tsf_report_event_id,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004317 wma_vdev_tsf_handler,
4318 WMA_RX_SERIALIZER_CTX);
4319 if (0 != status) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004320 WMA_LOGE("%s: Failed to register tsf callback", __func__);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07004321 qdf_status = QDF_STATUS_E_FAILURE;
4322 goto end;
4323 }
4324
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304325 /* Initialize the wma_pdev_set_hw_mode_resp_evt_handler event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304326 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304327 wmi_pdev_set_hw_mode_rsp_event_id,
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05304328 wma_pdev_set_hw_mode_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304329 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304330 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331 WMA_LOGE("Failed to register set hw mode resp event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304332 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 goto end;
4334 }
4335
4336 /* Initialize the WMI_SOC_HW_MODE_TRANSITION_EVENTID event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304337 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304338 wmi_pdev_hw_mode_transition_event_id,
Manishekar Chandrasekaran05fd2672016-04-27 12:59:20 +05304339 wma_pdev_hw_mode_transition_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304340 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304341 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304343 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 goto end;
4345 }
4346
4347 /* Initialize the set dual mac configuration event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304348 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304349 wmi_pdev_set_mac_config_resp_event_id,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05304350 wma_pdev_set_dual_mode_config_resp_evt_handler,
Govind Singhd76a5b02016-03-08 15:12:14 +05304351 WMA_RX_SERIALIZER_CTX);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304352 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 WMA_LOGE("Failed to register hw mode transition event cb");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304354 qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004355 goto end;
4356 }
4357
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05304358 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05304359 wmi_coex_bt_activity_event_id,
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304360 wma_wlan_bt_activity_evt_handler,
4361 WMA_RX_SERIALIZER_CTX);
4362 if (!QDF_IS_STATUS_SUCCESS(status)) {
4363 WMA_LOGE("Failed to register coex bt activity event handler");
4364 qdf_status = QDF_STATUS_E_FAILURE;
4365 goto end;
4366 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05304367
Sandeep Puligilla063a4342018-01-10 02:50:14 -08004368 cmd_ops.wmi_spectral_configure_cmd_send =
4369 wmi_unified_vdev_spectral_configure_cmd_send;
4370 cmd_ops.wmi_spectral_enable_cmd_send =
4371 wmi_unified_vdev_spectral_enable_cmd_send;
4372 wlan_register_wmi_spectral_cmd_ops(wma_handle->pdev, &cmd_ops);
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05304373
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374end:
4375 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304376 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377}
4378
4379/**
4380 * wma_stop() - wma stop function.
4381 * cleanup timers and suspend target.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004382 * @reason: reason for wma_stop.
4383 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304384 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385 */
Jeff Johnsonacc1cc72017-09-13 08:47:49 -07004386QDF_STATUS wma_stop(uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387{
4388 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304389 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singhede435f2015-12-01 16:16:36 +05304390 int i;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004391
Anurag Chouhan6d760662016-02-20 16:05:43 +05304392 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 WMA_LOGD("%s: Enter", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394 /* validate the wma_handle */
4395 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004396 WMA_LOGE("%s: Invalid handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304397 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 goto end;
4399 }
4400#ifdef QCA_WIFI_FTM
4401 /*
4402 * Tx mgmt detach requires TXRX context which is not created
4403 * in FTM mode. So skip the TX mgmt detach.
4404 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304405 if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304406 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407 goto end;
4408 }
4409#endif /* QCA_WIFI_FTM */
4410
4411 if (wma_handle->ack_work_ctx) {
4412 cds_flush_work(&wma_handle->ack_work_ctx->ack_cmp_work);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304413 qdf_mem_free(wma_handle->ack_work_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 wma_handle->ack_work_ctx = NULL;
4415 }
4416
4417 /* Destroy the timer for log completion */
Anurag Chouhan210db072016-02-22 18:42:15 +05304418 qdf_status = qdf_mc_timer_destroy(&wma_handle->log_completion_timer);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07004419 if (qdf_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 WMA_LOGE("Failed to destroy the log completion timer");
Govind Singhede435f2015-12-01 16:16:36 +05304421 /* clean up ll-queue for all vdev */
4422 for (i = 0; i < wma_handle->max_bssid; i++) {
4423 if (wma_handle->interfaces[i].handle &&
Mukul Sharmaf9047232017-03-02 16:58:56 +05304424 wma_is_vdev_up(i)) {
Leo Chang96464902016-10-28 11:10:54 -07004425 cdp_fc_vdev_flush(
4426 cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08004427 wma_handle->
4428 interfaces[i].handle);
Govind Singhede435f2015-12-01 16:16:36 +05304429 }
4430 }
gaurank kathpalia85f8a612018-02-21 18:55:24 +05304431
4432 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
4433 /* Destroy firmware time stamp sync timer */
4434 qdf_status = qdf_mc_timer_destroy(
4435 &wma_handle->wma_fw_time_sync_timer);
4436 if (QDF_IS_STATUS_ERROR(qdf_status))
4437 WMA_LOGE(FL("Failed to destroy the fw time sync timer"));
4438 }
4439
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304440 qdf_status = wma_tx_detach(wma_handle);
4441 if (qdf_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004442 WMA_LOGE("%s: Failed to deregister tx management", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 goto end;
4444 }
4445
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446end:
4447 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304448 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449}
4450
4451/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 * wma_wmi_service_close() - close wma wmi service interface.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304454 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455 */
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004456QDF_STATUS wma_wmi_service_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457{
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004458 void *cds_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 tp_wma_handle wma_handle;
4460 struct beacon_info *bcn;
4461 int i;
4462
4463 WMA_LOGD("%s: Enter", __func__);
4464
Jeff Johnson7b3ddc22017-09-13 09:42:44 -07004465 cds_ctx = cds_get_global_context();
4466 if (!cds_ctx) {
4467 WMA_LOGE("%s: Invalid CDS context", __func__);
4468 return QDF_STATUS_E_INVAL;
4469 }
4470
Anurag Chouhan6d760662016-02-20 16:05:43 +05304471 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472
4473 /* validate the wma_handle */
4474 if (NULL == wma_handle) {
4475 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304476 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 }
4478
4479 /* validate the wmi handle */
4480 if (NULL == wma_handle->wmi_handle) {
4481 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304482 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 }
4484
4485 /* dettach the wmi serice */
4486 WMA_LOGD("calling wmi_unified_detach");
4487 wmi_unified_detach(wma_handle->wmi_handle);
4488 wma_handle->wmi_handle = NULL;
4489
4490 for (i = 0; i < wma_handle->max_bssid; i++) {
4491 bcn = wma_handle->interfaces[i].beacon;
4492
4493 if (bcn) {
4494 if (bcn->dma_mapped)
Nirav Shahcbc6d722016-03-01 16:24:53 +05304495 qdf_nbuf_unmap_single(wma_handle->qdf_dev,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304496 bcn->buf, QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +05304497 qdf_nbuf_free(bcn->buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304498 qdf_mem_free(bcn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 wma_handle->interfaces[i].beacon = NULL;
4500 }
4501
4502 if (wma_handle->interfaces[i].handle) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304503 qdf_mem_free(wma_handle->interfaces[i].handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 wma_handle->interfaces[i].handle = NULL;
4505 }
Yue Ma664effc2016-01-12 18:43:54 -08004506
4507 if (wma_handle->interfaces[i].addBssStaContext) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304508 qdf_mem_free(wma_handle->
Yue Ma664effc2016-01-12 18:43:54 -08004509 interfaces[i].addBssStaContext);
4510 wma_handle->interfaces[i].addBssStaContext = NULL;
4511 }
4512
4513 if (wma_handle->interfaces[i].del_staself_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304514 qdf_mem_free(wma_handle->interfaces[i].del_staself_req);
Yue Ma664effc2016-01-12 18:43:54 -08004515 wma_handle->interfaces[i].del_staself_req = NULL;
4516 }
yeshwanth sriram guntuka8dd80382017-01-30 17:04:58 +05304517
4518 if (wma_handle->interfaces[i].stats_rsp) {
4519 qdf_mem_free(wma_handle->interfaces[i].stats_rsp);
4520 wma_handle->interfaces[i].stats_rsp = NULL;
4521 }
Abhishek Singh7e5e9342017-04-12 18:22:07 +05304522
4523 if (wma_handle->interfaces[i].psnr_req) {
4524 qdf_mem_free(wma_handle->
4525 interfaces[i].psnr_req);
4526 wma_handle->interfaces[i].psnr_req = NULL;
4527 }
Dustin Brownec2c92e2017-07-26 11:13:49 -07004528
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05304529 if (wma_handle->interfaces[i].rcpi_req) {
4530 qdf_mem_free(wma_handle->
4531 interfaces[i].rcpi_req);
4532 wma_handle->interfaces[i].rcpi_req = NULL;
4533 }
4534
Padma, Santhosh Kumaraa2433e2017-10-06 14:34:46 +05304535 if (wma_handle->interfaces[i].roam_synch_frame_ind.
4536 bcn_probe_rsp) {
4537 qdf_mem_free(wma_handle->interfaces[i].
4538 roam_synch_frame_ind.bcn_probe_rsp);
4539 wma_handle->interfaces[i].roam_synch_frame_ind.
4540 bcn_probe_rsp = NULL;
4541 }
4542
4543 if (wma_handle->interfaces[i].roam_synch_frame_ind.
4544 reassoc_req) {
4545 qdf_mem_free(wma_handle->interfaces[i].
4546 roam_synch_frame_ind.reassoc_req);
4547 wma_handle->interfaces[i].roam_synch_frame_ind.
4548 reassoc_req = NULL;
4549 }
4550
4551 if (wma_handle->interfaces[i].roam_synch_frame_ind.
4552 reassoc_rsp) {
4553 qdf_mem_free(wma_handle->interfaces[i].
4554 roam_synch_frame_ind.reassoc_rsp);
4555 wma_handle->interfaces[i].roam_synch_frame_ind.
4556 reassoc_rsp = NULL;
4557 }
4558
Dustin Brownec2c92e2017-07-26 11:13:49 -07004559 wma_vdev_deinit(&wma_handle->interfaces[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 }
4561
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304562 qdf_mem_free(wma_handle->interfaces);
Dustin Brownec2c92e2017-07-26 11:13:49 -07004563
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564 /* free the wma_handle */
Jeff Johnsonadb3b1c2017-09-13 10:42:36 -07004565 cds_free_context(QDF_MODULE_ID_WMA, wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304567 qdf_mem_free(((p_cds_contextType) cds_ctx)->cfg_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304569 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570}
4571
Xun Luoa858a472015-11-10 08:24:45 -08004572/**
4573 * wma_wmi_work_close() - close the work queue items associated with WMI
Xun Luoa858a472015-11-10 08:24:45 -08004574 *
4575 * This function closes work queue items associated with WMI, but not fully
4576 * closes WMI service.
4577 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304578 * Return: QDF_STATUS_SUCCESS if work close is successful. Otherwise
Xun Luoa858a472015-11-10 08:24:45 -08004579 * proper error codes.
4580 */
Jeff Johnson6b8473d2017-09-13 09:20:53 -07004581QDF_STATUS wma_wmi_work_close(void)
Xun Luoa858a472015-11-10 08:24:45 -08004582{
4583 tp_wma_handle wma_handle;
4584
4585 WMA_LOGD("%s: Enter", __func__);
4586
Anurag Chouhan6d760662016-02-20 16:05:43 +05304587 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Xun Luoa858a472015-11-10 08:24:45 -08004588
4589 /* validate the wma_handle */
4590 if (NULL == wma_handle) {
4591 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304592 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004593 }
4594
4595 /* validate the wmi handle */
4596 if (NULL == wma_handle->wmi_handle) {
4597 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304598 return QDF_STATUS_E_INVAL;
Xun Luoa858a472015-11-10 08:24:45 -08004599 }
4600
4601 /* remove the wmi work */
4602 WMA_LOGD("calling wmi_unified_remove_work");
4603 wmi_unified_remove_work(wma_handle->wmi_handle);
4604
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304605 return QDF_STATUS_SUCCESS;
Xun Luoa858a472015-11-10 08:24:45 -08004606}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607
Krunal Soni2e48d012016-05-02 16:55:26 -07004608/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 * wma_close() - wma close function.
4610 * cleanup resources attached with wma.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304612 * Return: 0 on success, QDF Error on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 */
Jeff Johnson542da352017-09-13 09:17:28 -07004614QDF_STATUS wma_close(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615{
4616 tp_wma_handle wma_handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304617 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618
4619 WMA_LOGD("%s: Enter", __func__);
4620
Anurag Chouhan6d760662016-02-20 16:05:43 +05304621 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622
4623 /* validate the wma_handle */
4624 if (NULL == wma_handle) {
4625 WMA_LOGE("%s: Invalid wma handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304626 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 }
4628
4629 /* validate the wmi handle */
4630 if (NULL == wma_handle->wmi_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004631 WMA_LOGE("%s: Invalid wmi handle", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304632 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633 }
4634
4635 /* Free DBS list */
4636 if (wma_handle->hw_mode.hw_mode_list) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304637 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004639 WMA_LOGD("%s: DBS list is freed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05304641
Anurag Chouhan6d760662016-02-20 16:05:43 +05304642 if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643#ifdef FEATURE_WLAN_EXTSCAN
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304644 qdf_wake_lock_destroy(&wma_handle->extscan_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645#endif /* FEATURE_WLAN_EXTSCAN */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304646 qdf_wake_lock_destroy(&wma_handle->wow_wake_lock);
Mukul Sharmae44d0542017-05-23 21:50:56 +05304647 qdf_wake_lock_destroy(&wma_handle->wow_auth_req_wl);
4648 qdf_wake_lock_destroy(&wma_handle->wow_assoc_req_wl);
4649 qdf_wake_lock_destroy(&wma_handle->wow_deauth_rec_wl);
4650 qdf_wake_lock_destroy(&wma_handle->wow_disassoc_rec_wl);
4651 qdf_wake_lock_destroy(&wma_handle->wow_ap_assoc_lost_wl);
4652 qdf_wake_lock_destroy(&wma_handle->wow_auto_shutdown_wl);
4653 qdf_wake_lock_destroy(&wma_handle->roam_ho_wl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 }
4655
4656 /* unregister Firmware debug log */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304657 qdf_status = dbglog_deinit(wma_handle->wmi_handle);
4658 if (qdf_status != QDF_STATUS_SUCCESS)
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004659 WMA_LOGE("%s: dbglog_deinit failed", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660
Anurag Chouhan210db072016-02-22 18:42:15 +05304661 qdf_status = qdf_mc_timer_destroy(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304662 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07004663 WMA_LOGE("%s: Failed to destroy service ready ext event timer",
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05304664 __func__);
4665
Anurag Chouhandf2b2682016-02-29 14:15:27 +05304666 qdf_event_destroy(&wma_handle->target_suspend);
4667 qdf_event_destroy(&wma_handle->wma_resume_event);
4668 qdf_event_destroy(&wma_handle->runtime_suspend);
4669 qdf_event_destroy(&wma_handle->recovery_event);
Kai Liu27f20372016-09-28 23:52:36 +08004670 qdf_event_destroy(&wma_handle->tx_frm_download_comp_event);
4671 qdf_event_destroy(&wma_handle->tx_queue_empty_event);
Manikandan Mohanb0932ab2017-02-12 16:30:55 -08004672 wma_cleanup_vdev_resp_queue(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673 wma_cleanup_hold_req(wma_handle);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304674 qdf_wake_lock_destroy(&wma_handle->wmi_cmd_rsp_wake_lock);
Prashanth Bhatta87b6dc02017-01-19 15:17:58 -08004675 qdf_runtime_lock_deinit(&wma_handle->wmi_cmd_rsp_runtime_lock);
Poddar, Siddarth2fb98072017-07-19 14:58:30 +05304676 qdf_spinlock_destroy(&wma_handle->vdev_respq_lock);
4677 qdf_spinlock_destroy(&wma_handle->wma_hold_req_q_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679 if (NULL != wma_handle->pGetRssiReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304680 qdf_mem_free(wma_handle->pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 wma_handle->pGetRssiReq = NULL;
4682 }
Deepak Dhamdherebf1f9b12016-05-27 14:49:41 -07004683
yeshwanth sriram guntuka584c2332017-07-29 12:50:25 +05304684 wma_unified_radio_tx_mem_free(wma_handle);
Srinivas Girigowdaad874a82016-10-25 14:08:00 -07004685
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -07004686 if (wma_handle->pdev) {
4687 wlan_objmgr_pdev_release_ref(wma_handle->pdev,
4688 WLAN_LEGACY_WMA_ID);
4689 wma_handle->pdev = NULL;
4690 }
Frank Liu00d73fe2017-05-19 22:11:28 +08004691
Mukul Sharma6411bb82017-03-01 15:57:07 +05304692 pmo_unregister_pause_bitmap_notifier(wma_handle->psoc,
4693 wma_vdev_update_pause_bitmap);
4694 pmo_unregister_get_pause_bitmap(wma_handle->psoc,
4695 wma_vdev_get_pause_bitmap);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05304696 pmo_unregister_is_device_in_low_pwr_mode(wma_handle->psoc,
4697 wma_vdev_is_device_in_low_pwr_mode);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304698
Arunk Khandavallia6305a32018-01-25 11:19:18 +05304699 target_if_free_psoc_tgt_info(wma_handle->psoc);
4700
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +05304701 wlan_objmgr_psoc_release_ref(wma_handle->psoc, WLAN_LEGACY_WMA_ID);
4702 wma_handle->psoc = NULL;
4703 target_if_close();
4704 wma_target_if_close(wma_handle);
Mukul Sharma6411bb82017-03-01 15:57:07 +05304705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004706 WMA_LOGD("%s: Exit", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304707 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708}
4709
4710/**
4711 * wma_update_fw_config() - update fw configuration
Dustin Brownb9987af2018-03-01 17:15:11 -08004712 * @psoc: psoc to query configuration from
4713 * @tgt_hdl: target capability info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 *
4715 * Return: none
4716 */
Dustin Brownb9987af2018-03-01 17:15:11 -08004717static void wma_update_fw_config(struct wlan_objmgr_psoc *psoc,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304718 struct target_psoc_info *tgt_hdl)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719{
Dustin Brownb9987af2018-03-01 17:15:11 -08004720 target_resource_config *cfg = &tgt_hdl->info.wlan_res_cfg;
4721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722 /* Override the no. of max fragments as per platform configuration */
Dustin Brownb9987af2018-03-01 17:15:11 -08004723 cfg->max_frag_entries = QDF_MIN(QCA_OL_11AC_TX_MAX_FRAGS,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304724 target_if_get_max_frag_entry(tgt_hdl));
Dustin Brownb9987af2018-03-01 17:15:11 -08004725 target_if_set_max_frag_entry(tgt_hdl, cfg->max_frag_entries);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304726
Dustin Brownb9987af2018-03-01 17:15:11 -08004727 cfg->num_wow_filters = ucfg_pmo_get_num_wow_filters(psoc);
4728 cfg->bpf_instruction_size = ucfg_pmo_get_apf_instruction_size(psoc);
Dustin Brown67d69eb2018-03-02 11:11:34 -08004729 cfg->num_packet_filters = ucfg_pmo_get_num_packet_filters(psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004730}
4731
4732/**
Yun Parkb4f591d2017-03-29 15:51:01 -07004733 * wma_set_tx_partition_base() - set TX MSDU ID partition base for IPA
4734 * @value: TX MSDU ID partition base
4735 *
4736 * Return: none
4737 */
4738#ifdef IPA_OFFLOAD
4739static void wma_set_tx_partition_base(uint32_t value)
4740{
4741 cdp_ipa_set_uc_tx_partition_base(
4742 cds_get_context(QDF_MODULE_ID_SOC),
4743 (struct cdp_cfg *)cds_get_context(QDF_MODULE_ID_CFG),
4744 value);
4745 WMA_LOGD("%s: TX_MSDU_ID_PARTITION=%d", __func__,
4746 value);
4747}
4748#else
4749static void wma_set_tx_partition_base(uint32_t value)
4750{
4751}
4752#endif
4753
4754/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755 * wma_update_target_services() - update target services from wma handle
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304756 * @wmi_handle: Unified wmi handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757 * @cfg: target services
4758 *
4759 * Return: none
4760 */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304761static inline void wma_update_target_services(struct wmi_unified *wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762 struct wma_tgt_services *cfg)
4763{
4764 /* STA power save */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304765 cfg->sta_power_save = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304766 wmi_service_sta_pwrsave);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767
4768 /* Enable UAPSD */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304769 cfg->uapsd = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304770 wmi_service_ap_uapsd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004771
4772 /* Update AP DFS service */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304773 cfg->ap_dfs = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304774 wmi_service_ap_dfs);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775
4776 /* Enable 11AC */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304777 cfg->en_11ac = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304778 wmi_service_11ac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 if (cfg->en_11ac)
4780 g_fw_wlan_feat_caps |= (1 << DOT11AC);
4781
4782 /* Proactive ARP response */
4783 g_fw_wlan_feat_caps |= (1 << WLAN_PERIODIC_TX_PTRN);
4784
4785 /* Enable WOW */
4786 g_fw_wlan_feat_caps |= (1 << WOW);
4787
4788 /* ARP offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304789 cfg->arp_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304790 wmi_service_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004791
4792 /* Adaptive early-rx */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304793 cfg->early_rx = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304794 wmi_service_early_rx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004795#ifdef FEATURE_WLAN_SCAN_PNO
4796 /* PNO offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304797 if (wmi_service_enabled(wmi_handle, wmi_service_nlo))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798 cfg->pno_offload = true;
4799#endif /* FEATURE_WLAN_SCAN_PNO */
4800
4801#ifdef FEATURE_WLAN_EXTSCAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304802 if (wmi_service_enabled(wmi_handle, wmi_service_extscan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004803 g_fw_wlan_feat_caps |= (1 << EXTENDED_SCAN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004804#endif /* FEATURE_WLAN_EXTSCAN */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304805 cfg->lte_coex_ant_share = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304806 wmi_service_lte_ant_share_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807#ifdef FEATURE_WLAN_TDLS
4808 /* Enable TDLS */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304809 if (wmi_service_enabled(wmi_handle, wmi_service_tdls)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810 cfg->en_tdls = 1;
4811 g_fw_wlan_feat_caps |= (1 << TDLS);
4812 }
4813 /* Enable advanced TDLS features */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304814 if (wmi_service_enabled(wmi_handle, wmi_service_tdls_offchan)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815 cfg->en_tdls_offchan = 1;
4816 g_fw_wlan_feat_caps |= (1 << TDLS_OFF_CHANNEL);
4817 }
4818
4819 cfg->en_tdls_uapsd_buf_sta =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304820 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304821 wmi_service_tdls_uapsd_buffer_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 cfg->en_tdls_uapsd_sleep_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_sleep_sta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825#endif /* FEATURE_WLAN_TDLS */
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304826 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304827 (wmi_handle, wmi_service_beacon_offload))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828 cfg->beacon_offload = true;
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304829 if (wmi_service_enabled
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304830 (wmi_handle, wmi_service_sta_pmf_offload))
mukul sharma72c8b222015-09-04 17:02:01 +05304831 cfg->pmf_offload = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4833 /* Enable Roam Offload */
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304834 cfg->en_roam_offload = wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304835 wmi_service_roam_ho_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
4837#ifdef WLAN_FEATURE_NAN
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304838 if (wmi_service_enabled(wmi_handle, wmi_service_nan))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839 g_fw_wlan_feat_caps |= (1 << NAN);
4840#endif /* WLAN_FEATURE_NAN */
4841
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304842 if (wmi_service_enabled(wmi_handle, wmi_service_rtt))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843 g_fw_wlan_feat_caps |= (1 << RTT);
Yun Park4d968df2016-10-11 11:44:15 -07004844
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304845 if (wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304846 wmi_service_tx_msdu_id_new_partition_support)) {
Yun Parkb4f591d2017-03-29 15:51:01 -07004847 wma_set_tx_partition_base(HTT_TX_IPA_NEW_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004848 } else {
Yun Parkb4f591d2017-03-29 15:51:01 -07004849 wma_set_tx_partition_base(HTT_TX_IPA_MSDU_ID_SPACE_BEGIN);
Yun Park4d968df2016-10-11 11:44:15 -07004850 }
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07004851
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304852 wma_he_update_tgt_services(wmi_handle, cfg);
Will Huang496b36c2017-07-11 16:38:50 +08004853
4854 cfg->get_peer_info_enabled =
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304855 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05304856 wmi_service_peer_stats_info);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304857 if (wmi_service_enabled(wmi_handle, wmi_service_fils_support))
Vignesh Viswanathan731186f2017-09-18 13:47:37 +05304858 cfg->is_fils_roaming_supported = true;
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004859
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304860 if (wmi_service_enabled(wmi_handle, wmi_service_mawc_support))
Varun Reddy Yeturu62c32652017-10-26 15:32:35 -07004861 cfg->is_fw_mawc_capable = true;
4862
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05304863 if (wmi_service_enabled(wmi_handle,
4864 wmi_service_11k_neighbour_report_support))
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304865 cfg->is_11k_offload_supported = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866}
4867
4868/**
4869 * wma_update_target_ht_cap() - update ht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304870 * @tgt_hdl: pointer to structure target_psoc_info
4871 * @cfg: ht capability
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 *
4873 * Return: none
4874 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304875static inline void
4876wma_update_target_ht_cap(struct target_psoc_info *tgt_hdl,
4877 struct wma_tgt_ht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304879 int ht_cap_info;
4880
4881 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 /* RX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304883 cfg->ht_rx_stbc = !!(ht_cap_info & WMI_HT_CAP_RX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884
4885 /* TX STBC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304886 cfg->ht_tx_stbc = !!(ht_cap_info & WMI_HT_CAP_TX_STBC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004887
4888 /* MPDU density */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304889 cfg->mpdu_density = ht_cap_info & WMI_HT_CAP_MPDU_DENSITY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890
4891 /* HT RX LDPC */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304892 cfg->ht_rx_ldpc = !!(ht_cap_info & WMI_HT_CAP_LDPC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893
4894 /* HT SGI */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304895 cfg->ht_sgi_20 = !!(ht_cap_info & WMI_HT_CAP_HT20_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304897 cfg->ht_sgi_40 = !!(ht_cap_info & WMI_HT_CAP_HT40_SGI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004898
4899 /* RF chains */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304900 cfg->num_rf_chains = target_if_get_num_rf_chains(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901
Jeff Johnson3fd21822016-11-08 11:30:37 -08004902 WMA_LOGD("%s: ht_cap_info - %x ht_rx_stbc - %d, ht_tx_stbc - %d\n"
4903 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304904 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
4905 ht_cap_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906 cfg->ht_rx_stbc, cfg->ht_tx_stbc, cfg->mpdu_density,
4907 cfg->ht_rx_ldpc, cfg->ht_sgi_20, cfg->ht_sgi_40,
4908 cfg->num_rf_chains);
4909
4910}
4911
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912/**
4913 * wma_update_target_vht_cap() - update vht capabality from wma handle
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304914 * @tgt_hdl: pointer to structure target_psoc_info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004915 * @cfg: vht capabality
4916 *
4917 * Return: none
4918 */
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304919static inline void
4920wma_update_target_vht_cap(struct target_psoc_info *tgt_hdl,
4921 struct wma_tgt_vht_cap *cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922{
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304923 int vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304925 if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304927 else if (vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004928 cfg->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
4929 else
4930 cfg->vht_max_mpdu = 0;
4931
4932
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304933 if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
4935 cfg->supp_chan_width |= 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304936 } else if (vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_160MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304938 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 cfg->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304940 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304942 cfg->vht_rx_ldpc = vht_cap_info & WMI_VHT_CAP_RX_LDPC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004943
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304944 cfg->vht_short_gi_80 = vht_cap_info & WMI_VHT_CAP_SGI_80MHZ;
4945 cfg->vht_short_gi_160 = vht_cap_info & WMI_VHT_CAP_SGI_160MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304947 cfg->vht_tx_stbc = vht_cap_info & WMI_VHT_CAP_TX_STBC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304949 cfg->vht_rx_stbc =
4950 (vht_cap_info & WMI_VHT_CAP_RX_STBC_1SS) |
4951 (vht_cap_info & WMI_VHT_CAP_RX_STBC_2SS) |
4952 (vht_cap_info & WMI_VHT_CAP_RX_STBC_3SS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304954 cfg->vht_max_ampdu_len_exp = (vht_cap_info &
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP)
4956 >> WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
4957
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304958 cfg->vht_su_bformer = vht_cap_info & WMI_VHT_CAP_SU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304960 cfg->vht_su_bformee = vht_cap_info & WMI_VHT_CAP_SU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304962 cfg->vht_mu_bformer = vht_cap_info & WMI_VHT_CAP_MU_BFORMER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304964 cfg->vht_mu_bformee = vht_cap_info & WMI_VHT_CAP_MU_BFORMEE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004965
Arunk Khandavalli2462f462018-01-25 14:41:02 +05304966 cfg->vht_txop_ps = vht_cap_info & WMI_VHT_CAP_TXOP_PS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004967
Jeff Johnson3fd21822016-11-08 11:30:37 -08004968 WMA_LOGD("%s: max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
4969 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
4970 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971 cfg->vht_max_mpdu, cfg->supp_chan_width, cfg->vht_rx_ldpc,
4972 cfg->vht_short_gi_80, cfg->vht_tx_stbc, cfg->vht_rx_stbc,
4973 cfg->vht_txop_ps, cfg->vht_su_bformee, cfg->vht_mu_bformee,
4974 cfg->vht_max_ampdu_len_exp);
4975}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976
4977/**
Krunal Sonica50b452017-08-04 22:24:59 -07004978 * wma_update_supported_bands() - update supported bands from service ready ext
Krunal Sonica50b452017-08-04 22:24:59 -07004979 * @supported_bands: Supported band given by FW through service ready ext params
4980 * @new_supported_bands: New supported band which needs to be updated by
4981 * this API which WMA layer understands
4982 *
4983 * This API will convert FW given supported band to enum which WMA layer
4984 * understands
4985 *
4986 * Return: QDF_STATUS
4987 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05304988static QDF_STATUS wma_update_supported_bands(
Krunal Sonica50b452017-08-04 22:24:59 -07004989 WLAN_BAND_CAPABILITY supported_bands,
4990 WMI_PHY_CAPABILITY *new_supported_bands)
4991{
4992 QDF_STATUS status = QDF_STATUS_SUCCESS;
4993
Krunal Sonica50b452017-08-04 22:24:59 -07004994 if (!new_supported_bands) {
4995 WMA_LOGE("%s: NULL new supported band variable", __func__);
4996 return QDF_STATUS_E_FAILURE;
4997 }
4998 switch (supported_bands) {
4999 case WLAN_2G_CAPABILITY:
5000 *new_supported_bands |= WMI_11G_CAPABILITY;
5001 break;
5002 case WLAN_5G_CAPABILITY:
5003 *new_supported_bands |= WMI_11A_CAPABILITY;
5004 break;
5005 default:
5006 WMA_LOGE("%s: wrong supported band", __func__);
5007 status = QDF_STATUS_E_FAILURE;
5008 break;
5009 }
5010 return status;
5011}
5012
5013/**
Krunal Soniaa664da2016-06-15 23:46:40 -07005014 * wma_derive_ext_ht_cap() - Derive HT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005015 * @ht_cap: given pointer to HT caps which needs to be updated
5016 * @tx_chain: given tx chainmask value
5017 * @rx_chain: given rx chainmask value
5018 * @value: new HT cap info provided in form of bitmask
5019 *
5020 * This function takes the value provided in form of bitmask and decodes
5021 * it. After decoding, what ever value it gets, it takes the union(max) or
5022 * intersection(min) with previously derived values.
5023 *
5024 * Return: none
5025 *
5026 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305027static void wma_derive_ext_ht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005028 struct wma_tgt_ht_cap *ht_cap, uint32_t value,
5029 uint32_t tx_chain, uint32_t rx_chain)
5030{
5031 struct wma_tgt_ht_cap tmp = {0};
5032
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305033 if (ht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005034 return;
5035
Ankit Guptaa5076012016-09-14 11:32:19 -07005036 if (!qdf_mem_cmp(ht_cap, &tmp, sizeof(struct wma_tgt_ht_cap))) {
Krunal Soniaa664da2016-06-15 23:46:40 -07005037 ht_cap->ht_rx_stbc = (!!(value & WMI_HT_CAP_RX_STBC));
5038 ht_cap->ht_tx_stbc = (!!(value & WMI_HT_CAP_TX_STBC));
5039 ht_cap->mpdu_density = (!!(value & WMI_HT_CAP_MPDU_DENSITY));
5040 ht_cap->ht_rx_ldpc = (!!(value & WMI_HT_CAP_RX_LDPC));
5041 ht_cap->ht_sgi_20 = (!!(value & WMI_HT_CAP_HT20_SGI));
5042 ht_cap->ht_sgi_40 = (!!(value & WMI_HT_CAP_HT40_SGI));
5043 ht_cap->num_rf_chains =
5044 QDF_MAX(wma_get_num_of_setbits_from_bitmask(tx_chain),
5045 wma_get_num_of_setbits_from_bitmask(rx_chain));
5046 } else {
5047 ht_cap->ht_rx_stbc = QDF_MIN(ht_cap->ht_rx_stbc,
5048 (!!(value & WMI_HT_CAP_RX_STBC)));
5049 ht_cap->ht_tx_stbc = QDF_MAX(ht_cap->ht_tx_stbc,
5050 (!!(value & WMI_HT_CAP_TX_STBC)));
5051 ht_cap->mpdu_density = QDF_MIN(ht_cap->mpdu_density,
5052 (!!(value & WMI_HT_CAP_MPDU_DENSITY)));
5053 ht_cap->ht_rx_ldpc = QDF_MIN(ht_cap->ht_rx_ldpc,
5054 (!!(value & WMI_HT_CAP_RX_LDPC)));
5055 ht_cap->ht_sgi_20 = QDF_MIN(ht_cap->ht_sgi_20,
5056 (!!(value & WMI_HT_CAP_HT20_SGI)));
5057 ht_cap->ht_sgi_40 = QDF_MIN(ht_cap->ht_sgi_40,
5058 (!!(value & WMI_HT_CAP_HT40_SGI)));
5059 ht_cap->num_rf_chains =
5060 QDF_MAX(ht_cap->num_rf_chains,
5061 QDF_MAX(wma_get_num_of_setbits_from_bitmask(
5062 tx_chain),
5063 wma_get_num_of_setbits_from_bitmask(
5064 rx_chain)));
5065 }
5066}
5067
5068/**
5069 * wma_update_target_ext_ht_cap() - Update HT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305070 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005071 * @ht_cap: HT cap structure to be filled
5072 *
5073 * This function loop through each hardware mode and for each hardware mode
5074 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5075 * HT caps and derives the final cap.
5076 *
5077 * Return: none
5078 *
5079 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305080static void wma_update_target_ext_ht_cap(struct target_psoc_info *tgt_hdl,
5081 struct wma_tgt_ht_cap *ht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005082{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005083 int i, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005084 uint32_t ht_2g, ht_5g;
5085 struct wma_tgt_ht_cap tmp_ht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305086 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5087 int num_hw_modes;
Krunal Soniaa664da2016-06-15 23:46:40 -07005088
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005089 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305090 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5091 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005092 /*
5093 * for legacy device extended cap might not even come, so in that case
5094 * don't overwrite legacy values
5095 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305096 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005097 WMA_LOGD("%s: No extended HT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005098 return;
5099 }
5100
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005101 for (i = 0; i < total_mac_phy_cnt; i++) {
5102 ht_2g = mac_phy_cap[i].ht_cap_info_2G;
5103 ht_5g = mac_phy_cap[i].ht_cap_info_5G;
5104 if (ht_2g)
5105 wma_derive_ext_ht_cap(&tmp_ht_cap,
5106 ht_2g,
5107 mac_phy_cap[i].tx_chain_mask_2G,
5108 mac_phy_cap[i].rx_chain_mask_2G);
5109 if (ht_5g)
5110 wma_derive_ext_ht_cap(&tmp_ht_cap,
5111 ht_5g,
5112 mac_phy_cap[i].tx_chain_mask_5G,
5113 mac_phy_cap[i].rx_chain_mask_5G);
Krunal Soniaa664da2016-06-15 23:46:40 -07005114 }
5115
Ankit Guptaa5076012016-09-14 11:32:19 -07005116 if (qdf_mem_cmp(&tmp_cap, &tmp_ht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005117 sizeof(struct wma_tgt_ht_cap))) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005118 qdf_mem_copy(ht_cap, &tmp_ht_cap,
5119 sizeof(struct wma_tgt_ht_cap));
Krunal Soniaa664da2016-06-15 23:46:40 -07005120 }
5121
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005122 WMA_LOGD("%s: [ext ht cap] ht_rx_stbc - %d, ht_tx_stbc - %d\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005123 "mpdu_density - %d ht_rx_ldpc - %d ht_sgi_20 - %d\n"
5124 "ht_sgi_40 - %d num_rf_chains - %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005125 ht_cap->ht_rx_stbc, ht_cap->ht_tx_stbc,
5126 ht_cap->mpdu_density, ht_cap->ht_rx_ldpc,
5127 ht_cap->ht_sgi_20, ht_cap->ht_sgi_40,
5128 ht_cap->num_rf_chains);
5129}
5130
5131/**
5132 * wma_derive_ext_vht_cap() - Derive VHT caps based on given value
Krunal Soniaa664da2016-06-15 23:46:40 -07005133 * @vht_cap: pointer to given VHT caps to be filled
5134 * @value: new VHT cap info provided in form of bitmask
5135 *
5136 * This function takes the value provided in form of bitmask and decodes
5137 * it. After decoding, what ever value it gets, it takes the union(max) or
5138 * intersection(min) with previously derived values.
5139 *
5140 * Return: none
5141 *
5142 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305143static void wma_derive_ext_vht_cap(
Krunal Soniaa664da2016-06-15 23:46:40 -07005144 struct wma_tgt_vht_cap *vht_cap, uint32_t value)
5145{
5146 struct wma_tgt_vht_cap tmp_cap = {0};
5147 uint32_t tmp = 0;
5148
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305149 if (vht_cap == NULL)
Krunal Soniaa664da2016-06-15 23:46:40 -07005150 return;
5151
Ankit Guptaa5076012016-09-14 11:32:19 -07005152 if (!qdf_mem_cmp(vht_cap, &tmp_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005153 sizeof(struct wma_tgt_vht_cap))) {
5154 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5155 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5156 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5157 vht_cap->vht_max_mpdu = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5158 else
5159 vht_cap->vht_max_mpdu = 0;
5160
5161 if (value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) {
5162 vht_cap->supp_chan_width =
5163 1 << eHT_CHANNEL_WIDTH_80P80MHZ;
5164 vht_cap->supp_chan_width |=
5165 1 << eHT_CHANNEL_WIDTH_160MHZ;
5166 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5167 vht_cap->supp_chan_width =
5168 1 << eHT_CHANNEL_WIDTH_160MHZ;
5169 } else {
5170 vht_cap->supp_chan_width = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5171 }
5172 vht_cap->vht_rx_ldpc = value & WMI_VHT_CAP_RX_LDPC;
5173 vht_cap->vht_short_gi_80 = value & WMI_VHT_CAP_SGI_80MHZ;
5174 vht_cap->vht_short_gi_160 = value & WMI_VHT_CAP_SGI_160MHZ;
5175 vht_cap->vht_tx_stbc = value & WMI_VHT_CAP_TX_STBC;
5176 vht_cap->vht_rx_stbc =
5177 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5178 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5179 (value & WMI_VHT_CAP_RX_STBC_3SS);
5180 vht_cap->vht_max_ampdu_len_exp =
5181 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5182 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT;
5183 vht_cap->vht_su_bformer = value & WMI_VHT_CAP_SU_BFORMER;
5184 vht_cap->vht_su_bformee = value & WMI_VHT_CAP_SU_BFORMEE;
5185 vht_cap->vht_mu_bformer = value & WMI_VHT_CAP_MU_BFORMER;
5186 vht_cap->vht_mu_bformee = value & WMI_VHT_CAP_MU_BFORMEE;
5187 vht_cap->vht_txop_ps = value & WMI_VHT_CAP_TXOP_PS;
5188 } else {
5189 if (value & WMI_VHT_CAP_MAX_MPDU_LEN_11454)
5190 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_11454;
5191 else if (value & WMI_VHT_CAP_MAX_MPDU_LEN_7935)
5192 tmp = WMI_VHT_CAP_MAX_MPDU_LEN_7935;
5193 else
5194 tmp = 0;
5195 vht_cap->vht_max_mpdu = QDF_MIN(vht_cap->vht_max_mpdu, tmp);
5196
5197 if ((value & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ)) {
5198 tmp = (1 << eHT_CHANNEL_WIDTH_80P80MHZ) |
5199 (1 << eHT_CHANNEL_WIDTH_160MHZ);
5200 } else if (value & WMI_VHT_CAP_CH_WIDTH_160MHZ) {
5201 tmp = 1 << eHT_CHANNEL_WIDTH_160MHZ;
5202 } else {
5203 tmp = 1 << eHT_CHANNEL_WIDTH_80MHZ;
5204 }
5205 vht_cap->supp_chan_width =
5206 QDF_MAX(vht_cap->supp_chan_width, tmp);
5207 vht_cap->vht_rx_ldpc = QDF_MIN(vht_cap->vht_rx_ldpc,
5208 value & WMI_VHT_CAP_RX_LDPC);
5209 vht_cap->vht_short_gi_80 = QDF_MAX(vht_cap->vht_short_gi_80,
5210 value & WMI_VHT_CAP_SGI_80MHZ);
5211 vht_cap->vht_short_gi_160 = QDF_MAX(vht_cap->vht_short_gi_160,
5212 value & WMI_VHT_CAP_SGI_160MHZ);
5213 vht_cap->vht_tx_stbc = QDF_MAX(vht_cap->vht_tx_stbc,
5214 value & WMI_VHT_CAP_TX_STBC);
5215 vht_cap->vht_rx_stbc = QDF_MIN(vht_cap->vht_rx_stbc,
5216 (value & WMI_VHT_CAP_RX_STBC_1SS) |
5217 (value & WMI_VHT_CAP_RX_STBC_2SS) |
5218 (value & WMI_VHT_CAP_RX_STBC_3SS));
5219 vht_cap->vht_max_ampdu_len_exp =
5220 QDF_MIN(vht_cap->vht_max_ampdu_len_exp,
5221 (value & WMI_VHT_CAP_MAX_AMPDU_LEN_EXP) >>
5222 WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIFT);
5223 vht_cap->vht_su_bformer = QDF_MAX(vht_cap->vht_su_bformer,
5224 value & WMI_VHT_CAP_SU_BFORMER);
5225 vht_cap->vht_su_bformee = QDF_MAX(vht_cap->vht_su_bformee,
5226 value & WMI_VHT_CAP_SU_BFORMEE);
5227 vht_cap->vht_mu_bformer = QDF_MAX(vht_cap->vht_mu_bformer,
5228 value & WMI_VHT_CAP_MU_BFORMER);
5229 vht_cap->vht_mu_bformee = QDF_MAX(vht_cap->vht_mu_bformee,
5230 value & WMI_VHT_CAP_MU_BFORMEE);
5231 vht_cap->vht_txop_ps = QDF_MIN(vht_cap->vht_txop_ps,
5232 value & WMI_VHT_CAP_TXOP_PS);
5233 }
5234}
5235
5236/**
5237 * wma_update_target_ext_vht_cap() - Update VHT caps with given extended cap
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305238 * @tgt_hdl - target psoc information
Krunal Soniaa664da2016-06-15 23:46:40 -07005239 * @vht_cap: VHT cap structure to be filled
5240 *
5241 * This function loop through each hardware mode and for each hardware mode
5242 * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
5243 * VHT caps and derives the final cap.
5244 *
5245 * Return: none
5246 *
5247 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305248static void wma_update_target_ext_vht_cap(struct target_psoc_info *tgt_hdl,
5249 struct wma_tgt_vht_cap *vht_cap)
Krunal Soniaa664da2016-06-15 23:46:40 -07005250{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005251 int i, num_hw_modes, total_mac_phy_cnt;
Krunal Soniaa664da2016-06-15 23:46:40 -07005252 uint32_t vht_cap_info_2g, vht_cap_info_5g;
5253 struct wma_tgt_vht_cap tmp_vht_cap = {0}, tmp_cap = {0};
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305254 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
5255
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005256 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305257 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5258 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soniaa664da2016-06-15 23:46:40 -07005259
5260 /*
5261 * for legacy device extended cap might not even come, so in that case
5262 * don't overwrite legacy values
5263 */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005264 if (!num_hw_modes) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005265 WMA_LOGD("%s: No extended VHT cap for current SOC", __func__);
Krunal Soniaa664da2016-06-15 23:46:40 -07005266 return;
5267 }
5268
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08005269 for (i = 0; i < total_mac_phy_cnt; i++) {
5270 vht_cap_info_2g = mac_phy_cap[i].vht_cap_info_2G;
5271 vht_cap_info_5g = mac_phy_cap[i].vht_cap_info_5G;
5272 if (vht_cap_info_2g)
5273 wma_derive_ext_vht_cap(&tmp_vht_cap,
5274 vht_cap_info_2g);
5275 if (vht_cap_info_5g)
5276 wma_derive_ext_vht_cap(&tmp_vht_cap,
5277 vht_cap_info_5g);
Krunal Soniaa664da2016-06-15 23:46:40 -07005278 }
5279
Ankit Guptaa5076012016-09-14 11:32:19 -07005280 if (qdf_mem_cmp(&tmp_cap, &tmp_vht_cap,
Krunal Soniaa664da2016-06-15 23:46:40 -07005281 sizeof(struct wma_tgt_vht_cap))) {
5282 qdf_mem_copy(vht_cap, &tmp_vht_cap,
5283 sizeof(struct wma_tgt_vht_cap));
5284 }
5285
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005286 WMA_LOGD("%s: [ext vhtcap] max_mpdu %d supp_chan_width %x rx_ldpc %x\n"
Jeff Johnson3fd21822016-11-08 11:30:37 -08005287 "short_gi_80 %x tx_stbc %x rx_stbc %x txop_ps %x\n"
5288 "su_bformee %x mu_bformee %x max_ampdu_len_exp %d", __func__,
Krunal Soniaa664da2016-06-15 23:46:40 -07005289 vht_cap->vht_max_mpdu, vht_cap->supp_chan_width,
5290 vht_cap->vht_rx_ldpc, vht_cap->vht_short_gi_80,
5291 vht_cap->vht_tx_stbc, vht_cap->vht_rx_stbc,
5292 vht_cap->vht_txop_ps, vht_cap->vht_su_bformee,
5293 vht_cap->vht_mu_bformee, vht_cap->vht_max_ampdu_len_exp);
5294}
5295
5296/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305297 * wma_update_ra_rate_limit() - update wma config
5298 * @wma_handle: wma handle
5299 * @cfg: target config
5300 *
5301 * Return: none
5302 */
5303#ifdef FEATURE_WLAN_RA_FILTERING
5304static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5305 struct wma_tgt_cfg *cfg)
5306{
5307 cfg->is_ra_rate_limit_enabled = wma_handle->IsRArateLimitEnabled;
5308}
5309#else
5310static void wma_update_ra_rate_limit(tp_wma_handle wma_handle,
5311 struct wma_tgt_cfg *cfg)
5312{
5313}
5314#endif
5315
5316/**
Krunal Sonica50b452017-08-04 22:24:59 -07005317 * wma_update_hdd_band_cap() - update band cap which hdd understands
5318 * @supported_band: supported band which has been given by FW
5319 * @tgt_cfg: target configuration to be updated
5320 *
5321 * Convert WMA given supported band to enum which HDD understands
5322 *
5323 * Return: None
5324 */
5325static void wma_update_hdd_band_cap(WMI_PHY_CAPABILITY supported_band,
5326 struct wma_tgt_cfg *tgt_cfg)
5327{
5328 switch (supported_band) {
5329 case WMI_11G_CAPABILITY:
5330 case WMI_11NG_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005331 tgt_cfg->band_cap = BAND_2G;
Krunal Sonica50b452017-08-04 22:24:59 -07005332 break;
5333 case WMI_11A_CAPABILITY:
5334 case WMI_11NA_CAPABILITY:
5335 case WMI_11AC_CAPABILITY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005336 tgt_cfg->band_cap = BAND_5G;
Krunal Sonica50b452017-08-04 22:24:59 -07005337 break;
5338 case WMI_11AG_CAPABILITY:
5339 case WMI_11NAG_CAPABILITY:
5340 default:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005341 tgt_cfg->band_cap = BAND_ALL;
Krunal Sonica50b452017-08-04 22:24:59 -07005342 }
5343}
5344
5345/**
Arif Hussainee10f902017-12-27 16:30:17 -08005346 * wma_update_obss_detection_support() - update obss detection offload support
5347 * @wh: wma handle
5348 * @tgt_cfg: target configuration to be updated
5349 *
5350 * Update obss detection offload support based on service bit.
5351 *
5352 * Return: None
5353 */
5354static void wma_update_obss_detection_support(tp_wma_handle wh,
5355 struct wma_tgt_cfg *tgt_cfg)
5356{
Arif Hussain05fb4872018-01-03 16:02:55 -08005357 if (wmi_service_enabled(wh->wmi_handle,
5358 wmi_service_ap_obss_detection_offload))
Arif Hussainee10f902017-12-27 16:30:17 -08005359 tgt_cfg->obss_detection_offloaded = true;
5360 else
5361 tgt_cfg->obss_detection_offloaded = false;
5362}
5363
5364/**
Arif Hussain05fb4872018-01-03 16:02:55 -08005365 * wma_update_obss_color_collision_support() - update obss color collision
5366 * offload support
5367 * @wh: wma handle
5368 * @tgt_cfg: target configuration to be updated
5369 *
5370 * Update obss color collision offload support based on service bit.
5371 *
5372 * Return: None
5373 */
5374static void wma_update_obss_color_collision_support(tp_wma_handle wh,
5375 struct wma_tgt_cfg *tgt_cfg)
5376{
5377 if (wmi_service_enabled(wh->wmi_handle, wmi_service_bss_color_offload))
5378 tgt_cfg->obss_color_collision_offloaded = true;
5379 else
5380 tgt_cfg->obss_color_collision_offloaded = false;
5381}
5382
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005383#ifdef WLAN_SUPPORT_GREEN_AP
5384static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5385{
5386 if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap,
5387 WMI_SERVICE_EGAP))
5388 target_if_green_ap_register_egap_event_handler(
5389 wma_handle->pdev);
5390
5391}
5392#else
5393static void wma_green_ap_register_handlers(tp_wma_handle wma_handle)
5394{
5395}
5396#endif
5397
Arif Hussain05fb4872018-01-03 16:02:55 -08005398/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 * wma_update_hdd_cfg() - update HDD config
5400 * @wma_handle: wma handle
5401 *
5402 * Return: none
5403 */
5404static void wma_update_hdd_cfg(tp_wma_handle wma_handle)
5405{
5406 struct wma_tgt_cfg tgt_cfg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05305407 void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305408 target_resource_config *wlan_res_cfg;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305409 struct wlan_psoc_host_service_ext_param *service_ext_param;
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305410 struct target_psoc_info *tgt_hdl;
5411 struct wmi_unified *wmi_handle;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305412
5413 WMA_LOGD("%s: Enter", __func__);
5414
5415 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5416 if (!tgt_hdl) {
5417 WMA_LOGE("%s: target psoc info is NULL", __func__);
5418 return;
5419 }
5420
5421 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
Arif Hussaind15902c2018-03-02 00:08:29 -08005422 if (!wlan_res_cfg) {
5423 WMA_LOGE("%s: wlan_res_cfg is null", __func__);
5424 return;
5425 }
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305426 service_ext_param =
5427 target_psoc_get_service_ext_param(tgt_hdl);
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305428 wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
5429 if (!wmi_handle) {
5430 WMA_LOGE("%s: wmi handle is NULL", __func__);
5431 return;
5432 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305434 qdf_mem_zero(&tgt_cfg, sizeof(struct wma_tgt_cfg));
Naveen Rawat64e477e2016-05-20 10:34:56 -07005435
5436 tgt_cfg.sub_20_support = wma_handle->sub_20_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005437 tgt_cfg.reg_domain = wma_handle->reg_cap.eeprom_rd;
5438 tgt_cfg.eeprom_rd_ext = wma_handle->reg_cap.eeprom_rd_ext;
5439
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305440 tgt_cfg.max_intf_count = wlan_res_cfg->num_vdevs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305442 qdf_mem_copy(tgt_cfg.hw_macaddr.bytes, wma_handle->hwaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 ATH_MAC_LEN);
5444
Arunk Khandavalli4b44ef42018-01-25 16:45:49 +05305445 wma_update_target_services(wmi_handle, &tgt_cfg.services);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305446 wma_update_target_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5447 wma_update_target_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Krunal Soniaa664da2016-06-15 23:46:40 -07005448 /*
5449 * This will overwrite the structure filled by wma_update_target_ht_cap
5450 * and wma_update_target_vht_cap APIs.
5451 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305452 wma_update_target_ext_ht_cap(tgt_hdl, &tgt_cfg.ht_cap);
5453 wma_update_target_ext_vht_cap(tgt_hdl, &tgt_cfg.vht_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305455 wma_update_target_ext_he_cap(tgt_hdl, &tgt_cfg);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07005456
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305457 tgt_cfg.target_fw_version = target_if_get_fw_version(tgt_hdl);
5458 if (service_ext_param)
5459 tgt_cfg.target_fw_vers_ext =
5460 service_ext_param->fw_build_vers_ext;
5461
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462#ifdef WLAN_FEATURE_LPSS
5463 tgt_cfg.lpss_support = wma_handle->lpss_support;
5464#endif /* WLAN_FEATURE_LPSS */
5465 tgt_cfg.ap_arpns_support = wma_handle->ap_arpns_support;
Rajeev Kumare5a16822016-07-27 13:11:42 -07005466 tgt_cfg.bpf_enabled = wma_handle->bpf_enabled;
Arif Hussaind54b62c2018-03-01 13:31:37 -08005467 tgt_cfg.dfs_cac_offload = wma_handle->is_dfs_offloaded;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305468 tgt_cfg.rcpi_enabled = wma_handle->rcpi_enabled;
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305469 wma_update_ra_rate_limit(wma_handle, &tgt_cfg);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05305470 wma_update_hdd_band_cap(target_if_get_phy_capability(tgt_hdl),
5471 &tgt_cfg);
Krishna Kumaar Natarajan1ae49112015-11-24 21:43:22 -08005472 tgt_cfg.fine_time_measurement_cap =
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305473 target_if_get_wmi_fw_sub_feat_caps(tgt_hdl);
Rajeev Kumar Sirasanagandla47873002016-09-09 13:46:09 +05305474 tgt_cfg.wmi_max_len = wmi_get_max_msg_len(wma_handle->wmi_handle)
5475 - WMI_TLV_HEADROOM;
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05305476 tgt_cfg.tx_bfee_8ss_enabled = wma_handle->tx_bfee_8ss_enabled;
Arif Hussainee10f902017-12-27 16:30:17 -08005477 wma_update_obss_detection_support(wma_handle, &tgt_cfg);
Arif Hussain05fb4872018-01-03 16:02:55 -08005478 wma_update_obss_color_collision_support(wma_handle, &tgt_cfg);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07005479 wma_update_hdd_cfg_ndp(wma_handle, &tgt_cfg);
Naveen Rawatcb186cf2016-07-11 13:47:19 -07005480 wma_handle->tgt_cfg_update_cb(hdd_ctx, &tgt_cfg);
Himanshu Agarwal2228e072018-01-24 17:42:17 +05305481 target_if_store_pdev_target_if_ctx(wma_get_pdev_from_scn_handle);
Nachiket Kukade7dda8c22018-03-12 19:59:43 +05305482 target_pdev_set_wmi_handle(wma_handle->pdev->tgt_if_handle,
5483 wma_handle->wmi_handle);
Jeff Johnson6ec742c2018-03-31 15:21:08 -07005484 wma_green_ap_register_handlers(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485}
5486
5487/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488 * wma_dump_dbs_hw_mode() - Print the DBS HW modes
5489 * @wma_handle: WMA handle
5490 *
5491 * Prints the DBS HW modes sent by the FW as part
5492 * of WMI ready event
5493 *
5494 * Return: None
5495 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005496static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497{
5498 uint32_t i, param;
5499
5500 if (!wma_handle) {
5501 WMA_LOGE("%s: Invalid WMA handle", __func__);
5502 return;
5503 }
5504
5505 for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
5506 param = wma_handle->hw_mode.hw_mode_list[i];
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005507 WMA_LOGD("%s:[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305509 WMA_HW_MODE_MAC0_TX_STREAMS_GET(param),
5510 WMA_HW_MODE_MAC0_RX_STREAMS_GET(param),
5511 WMA_HW_MODE_MAC0_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005512 WMA_LOGD("%s:[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005513 __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305514 WMA_HW_MODE_MAC1_TX_STREAMS_GET(param),
5515 WMA_HW_MODE_MAC1_RX_STREAMS_GET(param),
5516 WMA_HW_MODE_MAC1_BANDWIDTH_GET(param));
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005517 WMA_LOGD("%s:[%d] DBS:%d SBS:%d", __func__, i,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05305518 WMA_HW_MODE_DBS_MODE_GET(param),
5519 WMA_HW_MODE_SBS_MODE_GET(param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005521 policy_mgr_dump_dbs_hw_mode(wma_handle->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522}
5523
5524/**
5525 * wma_init_scan_fw_mode_config() - Initialize scan/fw mode config
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305526 * @psoc: Object manager psoc
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305527 * @scan_config: Scam mode configuration
5528 * @fw_config: FW mode configuration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529 *
5530 * Enables all the valid bits of concurrent_scan_config_bits and
5531 * fw_mode_config_bits.
5532 *
5533 * Return: None
5534 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305535static void wma_init_scan_fw_mode_config(struct wlan_objmgr_psoc *psoc,
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07005536 uint32_t scan_config,
5537 uint32_t fw_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 WMA_LOGD("%s: Enter", __func__);
5540
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305541 if (!psoc) {
5542 WMA_LOGE("%s: obj psoc is NULL", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543 return;
5544 }
5545
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305546 policy_mgr_init_dbs_config(psoc, scan_config, fw_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005547}
5548
5549/**
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305550 * wma_update_ra_limit() - update ra limit based on bpf filter
5551 * enabled or not
5552 * @handle: wma handle
5553 *
5554 * Return: none
5555 */
5556#ifdef FEATURE_WLAN_RA_FILTERING
5557static void wma_update_ra_limit(tp_wma_handle wma_handle)
5558{
5559 if (wma_handle->bpf_enabled)
5560 wma_handle->IsRArateLimitEnabled = false;
5561}
5562#else
5563static void wma_update_ra__limit(tp_wma_handle handle)
5564{
5565}
5566#endif
5567
Dustin Brown06259e52018-02-28 16:00:02 -08005568static void wma_set_pmo_caps(struct wlan_objmgr_psoc *psoc)
5569{
5570 QDF_STATUS status;
5571 struct pmo_device_caps caps;
5572
5573 caps.arp_ns_offload =
5574 wma_is_service_enabled(wmi_service_arpns_offload);
5575 caps.apf =
5576 wma_is_service_enabled(wmi_service_bpf_offload);
5577 caps.packet_filter =
5578 wma_is_service_enabled(wmi_service_packet_filter_offload);
5579 caps.unified_wow =
5580 wma_is_service_enabled(wmi_service_unified_wow_capability);
5581
5582 status = ucfg_pmo_psoc_set_caps(psoc, &caps);
5583 if (QDF_IS_STATUS_ERROR(status))
5584 WMA_LOGE("Failed to set PMO capabilities; status:%d", status);
5585}
5586
5587static void wma_set_component_caps(struct wlan_objmgr_psoc *psoc)
5588{
5589 wma_set_pmo_caps(psoc);
5590}
5591
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305592/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593 * wma_rx_service_ready_event() - event handler to process
5594 * wmi rx sevice ready event.
5595 * @handle: wma handle
5596 * @cmd_param_info: command params info
5597 *
5598 * Return: none
5599 */
Govind Singhd76a5b02016-03-08 15:12:14 +05305600int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005601 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
5605 wmi_service_ready_event_fixed_param *ev;
Dustin Brown7678b6c2018-03-07 13:00:52 -08005606 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607 uint32_t *ev_wlan_dbs_hw_mode_list;
Leo Chang96464902016-10-28 11:10:54 -07005608 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305609 struct target_psoc_info *tgt_hdl;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305610 struct wlan_psoc_target_capability_info *tgt_cap_info;
5611 target_resource_config *wlan_res_cfg;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305612 struct wmi_unified *wmi_handle;
5613 uint32_t *service_bitmap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005614
5615 WMA_LOGD("%s: Enter", __func__);
5616
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305617 if (!handle) {
5618 WMA_LOGE("%s: wma_handle passed is NULL", __func__);
5619 return -EINVAL;
5620 }
5621
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305622 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5623 if (!tgt_hdl) {
5624 WMA_LOGE("%s: target psoc info is NULL", __func__);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305625 return -EINVAL;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305626 }
5627
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305628 wlan_res_cfg = target_psoc_get_wlan_res_cfg(tgt_hdl);
5629 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305630 service_bitmap = target_psoc_get_service_bitmap(tgt_hdl);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) cmd_param_info;
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305633 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005634 WMA_LOGE("%s: Invalid arguments", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305635 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 }
5637
5638 ev = param_buf->fixed_param;
5639 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005640 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05305641 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642 }
5643
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305644 wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
5645 if (!wmi_handle) {
5646 WMA_LOGE("%s: wmi handle is NULL", __func__);
5647 return -EINVAL;
5648 }
5649
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08005650 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651
Amar Singhal7b038ca2017-10-04 13:38:39 -07005652 if (ev->num_dbs_hw_modes > param_buf->num_wlan_dbs_hw_mode_list) {
5653 WMA_LOGE("FW dbs_hw_mode entry %d more than value %d in TLV hdr",
5654 ev->num_dbs_hw_modes,
5655 param_buf->num_wlan_dbs_hw_mode_list);
5656 return -EINVAL;
5657 }
5658
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes;
5660 ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list;
5661 wma_handle->hw_mode.hw_mode_list =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305662 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 wma_handle->num_dbs_hw_modes);
5664 if (!wma_handle->hw_mode.hw_mode_list) {
5665 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
5666 /* Continuing with the rest of the processing */
5667 }
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305668
5669 if (wma_handle->hw_mode.hw_mode_list)
5670 qdf_mem_copy(wma_handle->hw_mode.hw_mode_list,
5671 ev_wlan_dbs_hw_mode_list,
5672 (sizeof(*wma_handle->hw_mode.hw_mode_list) *
5673 wma_handle->num_dbs_hw_modes));
5674
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005675 policy_mgr_init_dbs_hw_mode(wma_handle->psoc,
5676 ev->num_dbs_hw_modes, ev_wlan_dbs_hw_mode_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677 wma_dump_dbs_hw_mode(wma_handle);
5678
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05305679 /* Initializes the fw_mode and scan_config to zero.
5680 * If ext service ready event is present it will set
5681 * the actual values of these two params.
5682 * This is to ensure that no garbage values would be
5683 * present in the absence of ext service ready event.
5684 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305685 wma_init_scan_fw_mode_config(wma_handle->psoc, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005686
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305687 qdf_mem_copy(&wma_handle->reg_cap, param_buf->hal_reg_capabilities,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305688 sizeof(HAL_REG_CAPABILITIES));
5689
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005690 wma_handle->vht_supp_mcs = ev->vht_supp_mcs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305692 wma_handle->new_hw_mode_index = tgt_cap_info->default_dbs_hw_mode_index;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005693 policy_mgr_update_new_hw_mode_index(wma_handle->psoc,
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305694 tgt_cap_info->default_dbs_hw_mode_index);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005695
5696 WMA_LOGD("%s: Firmware default hw mode index : %d",
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305697 __func__, tgt_cap_info->default_dbs_hw_mode_index);
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005698 WMA_LOGI("%s: Firmware build version : %08x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 __func__, ev->fw_build_vers);
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305700 WMA_LOGD("FW fine time meas cap: 0x%x",
5701 tgt_cap_info->wmi_fw_sub_feat_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702
5703 if (ev->hw_bd_id) {
5704 wma_handle->hw_bd_id = ev->hw_bd_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305705 qdf_mem_copy(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706 ev->hw_bd_info, sizeof(ev->hw_bd_info));
5707
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005708 WMA_LOGI("%s: Board version: %x.%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005709 __func__,
5710 wma_handle->hw_bd_info[0], wma_handle->hw_bd_info[1]);
5711 } else {
5712 wma_handle->hw_bd_id = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305713 qdf_mem_zero(wma_handle->hw_bd_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714 sizeof(wma_handle->hw_bd_info));
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005715 WMA_LOGW("%s: Board version is unknown!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 }
5717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718 /* wmi service is ready */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305719 qdf_mem_copy(wma_handle->wmi_service_bitmap,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305720 service_bitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721 sizeof(wma_handle->wmi_service_bitmap));
Nirav Shah22bf44d2015-12-10 15:39:48 +05305722
Leo Chang96464902016-10-28 11:10:54 -07005723 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(soc,
Dustin Brown7678b6c2018-03-07 13:00:52 -08005724 wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi));
Leo Chang96464902016-10-28 11:10:54 -07005725 cdp_set_desc_global_pool_size(soc, ev->num_msdu_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 /* SWBA event handler for beacon transmission */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305727 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305728 wmi_host_swba_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305729 wma_beacon_swba_handler,
5730 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005731 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005732 WMA_LOGE("Failed to register swba beacon event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305733 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 }
5735#ifdef WLAN_FEATURE_LPSS
5736 wma_handle->lpss_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005737 wmi_service_enabled(wmi_handle, wmi_service_lpass);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005738#endif /* WLAN_FEATURE_LPSS */
5739
5740 /*
5741 * This Service bit is added to check for ARP/NS Offload
5742 * support for LL/HL targets
5743 */
5744 wma_handle->ap_arpns_support =
Dustin Brown7678b6c2018-03-07 13:00:52 -08005745 wmi_service_enabled(wmi_handle, wmi_service_ap_arpns_offload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305747 wma_handle->bpf_enabled = (wma_handle->bpf_packet_filter_enable &&
Dustin Brown7678b6c2018-03-07 13:00:52 -08005748 wmi_service_enabled(wmi_handle, wmi_service_bpf_offload));
Anurag Chouhan04dbf6d2016-09-08 15:32:52 +05305749 wma_update_ra_limit(wma_handle);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005750
5751 if (wmi_service_enabled(wmi_handle, wmi_service_csa_offload)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752 WMA_LOGD("%s: FW support CSA offload capability", __func__);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005753 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305754 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305755 wmi_csa_handling_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305756 wma_csa_offload_handler,
5757 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005758 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759 WMA_LOGE("Failed to register CSA offload event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305760 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005761 }
5762 }
5763
Dustin Brown7678b6c2018-03-07 13:00:52 -08005764 if (wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi)) {
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08005765 WMA_LOGD("Firmware supports management TX over WMI,use WMI interface instead of HTT for management Tx");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005766 /*
5767 * Register Tx completion event handler for MGMT Tx over WMI
5768 * case
5769 */
5770 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305771 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305772 wmi_mgmt_tx_completion_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305773 wma_mgmt_tx_completion_handler,
5774 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005775 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305777 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778 }
5779
Nirav Shah20489972016-06-16 19:20:28 +05305780 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305781 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305782 wmi_mgmt_tx_bundle_completion_event_id,
Nirav Shah20489972016-06-16 19:20:28 +05305783 wma_mgmt_tx_bundle_completion_handler,
5784 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005785 if (QDF_IS_STATUS_ERROR(status)) {
Nirav Shah20489972016-06-16 19:20:28 +05305786 WMA_LOGE("Failed to register MGMT over WMI completion handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305787 goto free_hw_mode_list;
Nirav Shah20489972016-06-16 19:20:28 +05305788 }
5789
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 } else {
5791 WMA_LOGE("FW doesnot support WMI_SERVICE_MGMT_TX_WMI, Use HTT interface for Management Tx");
5792 }
Dustin Brown7678b6c2018-03-07 13:00:52 -08005793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794#ifdef WLAN_FEATURE_GTK_OFFLOAD
Dustin Brown7678b6c2018-03-07 13:00:52 -08005795 if (wmi_service_enabled(wmi_handle, wmi_service_gtk_offload)) {
5796 status = wmi_unified_register_event_handler(
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005797 wma_handle->wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305798 wmi_gtk_offload_status_event_id,
Mukul Sharma3d36c392017-01-18 18:39:12 +05305799 target_if_pmo_gtk_offload_status_event,
5800 WMA_RX_WORK_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005801 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 WMA_LOGE("Failed to register GTK offload event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305803 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 }
5805 }
5806#endif /* WLAN_FEATURE_GTK_OFFLOAD */
5807
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305808 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305809 wmi_tbttoffset_update_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305810 wma_tbttoffset_update_event_handler,
5811 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005812 if (QDF_IS_STATUS_ERROR(status)) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005813 WMA_LOGE("Failed to register WMI_TBTTOFFSET_UPDATE_EVENTID callback");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305814 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005815 }
5816
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305817 if (wmi_service_enabled(wma_handle->wmi_handle,
5818 wmi_service_rcpi_support)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305819 /* register for rcpi response event */
5820 status = wmi_unified_register_event_handler(
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305821 wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305822 wmi_update_rcpi_event_id,
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305823 wma_rcpi_event_handler,
5824 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005825 if (QDF_IS_STATUS_ERROR(status)) {
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305826 WMA_LOGE("Failed to register RCPI event handler");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305827 goto free_hw_mode_list;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05305828 }
5829 wma_handle->rcpi_enabled = true;
5830 }
5831
Govind Singhefc5ccd2016-04-25 11:11:55 +05305832 /* mac_id is replaced with pdev_id in converged firmware to have
5833 * multi-radio support. In order to maintain backward compatibility
5834 * with old fw, host needs to check WMI_SERVICE_DEPRECATED_REPLACE
5835 * in service bitmap from FW and host needs to set use_pdev_id in
5836 * wmi_resource_config to true. If WMI_SERVICE_DEPRECATED_REPLACE
5837 * service is not set, then host shall not expect MAC ID from FW in
5838 * VDEV START RESPONSE event and host shall use PDEV ID.
5839 */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305840 if (wmi_service_enabled(wmi_handle, wmi_service_deprecated_replace))
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305841 wlan_res_cfg->use_pdev_id = true;
Govind Singhefc5ccd2016-04-25 11:11:55 +05305842 else
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305843 wlan_res_cfg->use_pdev_id = false;
Govind Singhefc5ccd2016-04-25 11:11:55 +05305844
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305845 wlan_res_cfg->max_num_dbs_scan_duty_cycle = CDS_DBS_SCAN_CLIENTS_MAX;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05305846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847 /* Initialize the log supported event handler */
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305848 status = wmi_unified_register_event_handler(wmi_handle,
Mukul Sharma228223a2017-11-03 19:25:39 +05305849 wmi_diag_event_id_log_supported_event_id,
Govind Singhd76a5b02016-03-08 15:12:14 +05305850 wma_log_supported_evt_handler,
5851 WMA_RX_SERIALIZER_CTX);
Dustin Brown7678b6c2018-03-07 13:00:52 -08005852 if (QDF_IS_STATUS_ERROR(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853 WMA_LOGE("Failed to register log supported event cb");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305854 goto free_hw_mode_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005855 }
5856
Leo Chang96464902016-10-28 11:10:54 -07005857 cdp_mark_first_wakeup_packet(soc,
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305858 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305859 wmi_service_mark_first_wakeup_packet));
Arif Hussaind54b62c2018-03-01 13:31:37 -08005860 wma_handle->is_dfs_offloaded =
Arunk Khandavalliaaf6b142018-01-25 12:42:42 +05305861 wmi_service_enabled(wmi_handle,
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305862 wmi_service_dfs_phyerr_offload);
Deepak Dhamdhere13230d32016-05-26 00:46:53 -07005863 wma_handle->nan_datapath_enabled =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05305864 wmi_service_enabled(wma_handle->wmi_handle,
5865 wmi_service_nan_data);
Dustin Brown06259e52018-02-28 16:00:02 -08005866
5867 wma_set_component_caps(wma_handle->psoc);
5868
Dustin Brownb9987af2018-03-01 17:15:11 -08005869 wma_update_fw_config(wma_handle->psoc, tgt_hdl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005870
Dustin Brown7678b6c2018-03-07 13:00:52 -08005871 status = wmi_unified_save_fw_version_cmd(wmi_handle, param_buf);
5872 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhf25a0f12016-03-08 16:09:48 +05305873 WMA_LOGE("Failed to send WMI_INIT_CMDID command");
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305874 goto free_hw_mode_list;
Govind Singhf25a0f12016-03-08 16:09:48 +05305875 }
5876
Dustin Brown7678b6c2018-03-07 13:00:52 -08005877 status = qdf_mc_timer_start(&wma_handle->service_ready_ext_timer,
5878 WMA_SERVICE_READY_EXT_TIMEOUT);
5879 if (QDF_IS_STATUS_ERROR(status))
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305880 WMA_LOGE("Failed to start the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05305881
Dustin Brown7678b6c2018-03-07 13:00:52 -08005882 wma_handle->tx_bfee_8ss_enabled =
5883 wmi_service_enabled(wmi_handle, wmi_service_8ss_tx_bfee);
Nachiket Kukade8b4bfd82017-05-25 18:34:48 +05305884
Arunk Khandavallia6305a32018-01-25 11:19:18 +05305885 target_psoc_set_num_radios(tgt_hdl, 1);
5886
Govind Singhd76a5b02016-03-08 15:12:14 +05305887 return 0;
Arunk Khandavallicfde2712018-01-25 11:27:42 +05305888
5889free_hw_mode_list:
5890 if (wma_handle->hw_mode.hw_mode_list) {
5891 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
5892 wma_handle->hw_mode.hw_mode_list = NULL;
5893 WMA_LOGD("%s: DBS list is freed", __func__);
5894 }
5895
5896 return -EINVAL;
5897
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898}
5899
5900/**
Krunal Soni0193b6f2016-08-15 15:53:43 -07005901 * wma_get_phyid_for_given_band() - to get phyid for band
5902 *
5903 * @wma_handle: Pointer to wma handle
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305904* @tgt_hdl: target psoc information
Krunal Soni0193b6f2016-08-15 15:53:43 -07005905 * @band: enum value of for 2G or 5G band
5906 * @phyid: Pointer to phyid which needs to be filled
5907 *
5908 * This API looks in to the map to find out which particular phy supports
5909 * provided band and return the idx (also called phyid) of that phy. Caller
5910 * use this phyid to fetch various caps of that phy
5911 *
5912 * Return: QDF_STATUS
5913 */
5914static QDF_STATUS wma_get_phyid_for_given_band(
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07005915 tp_wma_handle wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305916 struct target_psoc_info *tgt_hdl,
Krunal Soni0193b6f2016-08-15 15:53:43 -07005917 enum cds_band_type band, uint8_t *phyid)
5918{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305919 uint8_t idx, i, num_radios;
5920 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07005921
5922 if (!wma_handle) {
5923 WMA_LOGE("Invalid wma handle");
5924 return QDF_STATUS_E_FAILURE;
5925 }
5926
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305927 idx = 0;
Krunal Soni0193b6f2016-08-15 15:53:43 -07005928 *phyid = idx;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305929 num_radios = target_psoc_get_num_radios(tgt_hdl);
5930 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005931
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305932 for (i = 0; i < num_radios; i++) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07005933 if ((band == CDS_BAND_2GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305934 (WLAN_2G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07005935 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005936 WMA_LOGD("Select 2G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005937 return QDF_STATUS_SUCCESS;
5938 } else if ((band == CDS_BAND_5GHZ) &&
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305939 (WLAN_5G_CAPABILITY == mac_phy_cap[idx + i].supported_bands)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07005940 *phyid = idx + i;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005941 WMA_LOGD("Select 5G capable phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005942 return QDF_STATUS_SUCCESS;
5943 }
5944 }
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07005945 WMA_LOGD("Using default single hw mode phyid[%d]", *phyid);
Krunal Soni0193b6f2016-08-15 15:53:43 -07005946 return QDF_STATUS_SUCCESS;
5947}
5948
5949/**
5950 * wma_get_caps_for_phyidx_hwmode() - to fetch caps for given hw mode and band
5951 * @caps_per_phy: Pointer to capabilities structure which needs to be filled
5952 * @hw_mode: Provided hardware mode
5953 * @band: Provide band i.e. 2G or 5G
5954 *
5955 * This API finds cap which suitable for provided hw mode and band. If user
5956 * is provides some invalid hw mode then it will automatically falls back to
5957 * default hw mode
5958 *
5959 * Return: QDF_STATUS
5960 */
5961QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
5962 enum hw_mode_dbs_capab hw_mode, enum cds_band_type band)
5963{
5964 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305965 struct target_psoc_info *tgt_hdl;
5966 int ht_cap_info, vht_cap_info;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305967 uint8_t phyid, our_hw_mode = hw_mode, num_hw_modes;
5968 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
Krunal Soni0193b6f2016-08-15 15:53:43 -07005969
5970 if (!wma_handle) {
5971 WMA_LOGE("Invalid wma handle");
5972 return QDF_STATUS_E_FAILURE;
5973 }
5974
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305975 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
5976 if (!tgt_hdl) {
5977 WMA_LOGE("%s: target psoc info is NULL", __func__);
5978 return -EINVAL;
5979 }
5980
5981 ht_cap_info = target_if_get_ht_cap_info(tgt_hdl);
5982 vht_cap_info = target_if_get_vht_cap_info(tgt_hdl);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305983 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
5984 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305985
Arunk Khandavalli10af7282018-02-05 16:55:48 +05305986 if (!num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08005987 WMA_LOGD("Invalid number of hw modes, use legacy HT/VHT caps");
Arunk Khandavalli2462f462018-01-25 14:41:02 +05305988 caps_per_phy->ht_2g = ht_cap_info;
5989 caps_per_phy->ht_5g = ht_cap_info;
5990 caps_per_phy->vht_2g = vht_cap_info;
5991 caps_per_phy->vht_5g = vht_cap_info;
jiad080abce2017-08-08 15:17:39 +08005992 /* legacy platform doesn't support HE IE */
5993 caps_per_phy->he_2g = 0;
5994 caps_per_phy->he_5g = 0;
5995
5996 return QDF_STATUS_SUCCESS;
Krunal Soni0193b6f2016-08-15 15:53:43 -07005997 }
5998
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07005999 if (!policy_mgr_is_dbs_enable(wma_handle->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006000 our_hw_mode = HW_MODE_DBS_NONE;
6001
6002 if (!caps_per_phy) {
6003 WMA_LOGE("Invalid caps pointer");
6004 return QDF_STATUS_E_FAILURE;
6005 }
6006
Krunal Soni0193b6f2016-08-15 15:53:43 -07006007 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306008 wma_get_phyid_for_given_band(wma_handle, tgt_hdl, band, &phyid)) {
Krunal Soni0193b6f2016-08-15 15:53:43 -07006009 WMA_LOGE("Invalid phyid");
6010 return QDF_STATUS_E_FAILURE;
6011 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006012
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306013 caps_per_phy->ht_2g = mac_phy_cap[phyid].ht_cap_info_2G;
6014 caps_per_phy->ht_5g = mac_phy_cap[phyid].ht_cap_info_5G;
6015 caps_per_phy->vht_2g = mac_phy_cap[phyid].vht_cap_info_2G;
6016 caps_per_phy->vht_5g = mac_phy_cap[phyid].vht_cap_info_5G;
6017 caps_per_phy->he_2g = mac_phy_cap[phyid].he_cap_info_2G;
6018 caps_per_phy->he_5g = mac_phy_cap[phyid].he_cap_info_5G;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006019
Naveen Rawat98322472018-03-06 10:29:42 -08006020 caps_per_phy->tx_chain_mask_2G = mac_phy_cap->tx_chain_mask_2G;
6021 caps_per_phy->rx_chain_mask_2G = mac_phy_cap->rx_chain_mask_2G;
6022 caps_per_phy->tx_chain_mask_5G = mac_phy_cap->tx_chain_mask_5G;
6023 caps_per_phy->rx_chain_mask_5G = mac_phy_cap->rx_chain_mask_5G;
6024
Krunal Soni0193b6f2016-08-15 15:53:43 -07006025 return QDF_STATUS_SUCCESS;
6026}
6027
6028/**
6029 * wma_is_rx_ldpc_supported_for_channel() - to find out if ldpc is supported
6030 *
6031 * @channel: Channel number for which it needs to check if rx ldpc is enabled
6032 *
6033 * This API takes channel number as argument and takes default hw mode as DBS
6034 * to check if rx LDPC support is enabled for that channel or no
6035 */
6036bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
6037{
jiad080abce2017-08-08 15:17:39 +08006038 t_wma_handle *wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306039 struct target_psoc_info *tgt_hdl;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006040 struct wma_caps_per_phy caps_per_phy = {0};
6041 enum cds_band_type band;
6042 bool status;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306043 uint8_t num_hw_modes;
Krunal Soni0193b6f2016-08-15 15:53:43 -07006044
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006045 if (!wma_handle) {
6046 WMA_LOGE("Invalid wma handle");
6047 return false;
6048 }
6049
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306050 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6051 if (!tgt_hdl) {
6052 WMA_LOGE("Target handle is NULL");
6053 return QDF_STATUS_E_FAILURE;
6054 }
6055
6056 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6057
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006058 if (!WLAN_REG_IS_24GHZ_CH(channel))
Krunal Soni0193b6f2016-08-15 15:53:43 -07006059 band = CDS_BAND_5GHZ;
6060 else
6061 band = CDS_BAND_2GHZ;
6062
6063 if (QDF_STATUS_SUCCESS != wma_get_caps_for_phyidx_hwmode(
6064 &caps_per_phy,
6065 HW_MODE_DBS, band)) {
6066 return false;
6067 }
jiad080abce2017-08-08 15:17:39 +08006068
6069 /*
6070 * Legacy platforms like Rome set WMI_HT_CAP_LDPC to specify RX LDPC
6071 * capability. But new platforms like Helium set WMI_HT_CAP_RX_LDPC
6072 * instead.
6073 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306074 if (0 == num_hw_modes) {
jiad080abce2017-08-08 15:17:39 +08006075 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_LDPC));
6076 } else {
6077 if (WLAN_REG_IS_24GHZ_CH(channel))
6078 status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
6079 else
6080 status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));
6081 }
Krunal Soni0193b6f2016-08-15 15:53:43 -07006082
6083 return status;
6084}
6085
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006086/**
6087 * wma_print_mac_phy_capabilities() - Prints MAC PHY capabilities
6088 * @cap: pointer to WMI_MAC_PHY_CAPABILITIES
6089 * @index: MAC_PHY index
6090 *
6091 * Return: none
6092 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306093static void wma_print_mac_phy_capabilities(struct wlan_psoc_host_mac_phy_caps
6094 *cap, int index)
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006095{
6096 uint32_t mac_2G, mac_5G;
6097 uint32_t phy_2G[WMI_MAX_HECAP_PHY_SIZE];
6098 uint32_t phy_5G[WMI_MAX_HECAP_PHY_SIZE];
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306099 struct wlan_psoc_host_ppe_threshold ppet_2G, ppet_5G;
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006100
6101 WMA_LOGI("\t: index [%d]", index);
6102 WMA_LOGI("\t: cap for hw_mode_id[%d]", cap->hw_mode_id);
6103 WMA_LOGI("\t: pdev_id[%d]", cap->pdev_id);
6104 WMA_LOGI("\t: phy_id[%d]", cap->phy_id);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306105 WMA_LOGI("\t: supports_11b[%d]", cap->supports_11b);
6106 WMA_LOGI("\t: supports_11g[%d]", cap->supports_11g);
6107 WMA_LOGI("\t: supports_11a[%d]", cap->supports_11a);
6108 WMA_LOGI("\t: supports_11n[%d]", cap->supports_11n);
6109 WMA_LOGI("\t: supports_11ac[%d]", cap->supports_11ac);
6110 WMA_LOGI("\t: supports_11ax[%d]", cap->supports_11ax);
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07006111 WMA_LOGI("\t: supported_bands[%d]", cap->supported_bands);
6112 WMA_LOGI("\t: ampdu_density[%d]", cap->ampdu_density);
6113 WMA_LOGI("\t: max_bw_supported_2G[%d]", cap->max_bw_supported_2G);
6114 WMA_LOGI("\t: ht_cap_info_2G[%d]", cap->ht_cap_info_2G);
6115 WMA_LOGI("\t: vht_cap_info_2G[%d]", cap->vht_cap_info_2G);
6116 WMA_LOGI("\t: vht_supp_mcs_2G[%d]", cap->vht_supp_mcs_2G);
6117 WMA_LOGI("\t: tx_chain_mask_2G[%d]", cap->tx_chain_mask_2G);
6118 WMA_LOGI("\t: rx_chain_mask_2G[%d]", cap->rx_chain_mask_2G);
6119 WMA_LOGI("\t: max_bw_supported_5G[%d]", cap->max_bw_supported_5G);
6120 WMA_LOGI("\t: ht_cap_info_5G[%d]", cap->ht_cap_info_5G);
6121 WMA_LOGI("\t: vht_cap_info_5G[%d]", cap->vht_cap_info_5G);
6122 WMA_LOGI("\t: vht_supp_mcs_5G[%d]", cap->vht_supp_mcs_5G);
6123 WMA_LOGI("\t: tx_chain_mask_5G[%d]", cap->tx_chain_mask_5G);
6124 WMA_LOGI("\t: rx_chain_mask_5G[%d]", cap->rx_chain_mask_5G);
6125 WMA_LOGI("\t: he_cap_info_2G[%08x]", cap->he_cap_info_2G);
6126 WMA_LOGI("\t: he_supp_mcs_2G[%08x]", cap->he_supp_mcs_2G);
6127 WMA_LOGI("\t: he_cap_info_5G[%08x]", cap->he_cap_info_5G);
6128 WMA_LOGI("\t: he_supp_mcs_5G[%08x]", cap->he_supp_mcs_5G);
6129 mac_2G = cap->he_cap_info_2G;
6130 mac_5G = cap->he_cap_info_5G;
6131 qdf_mem_copy(phy_2G, cap->he_cap_phy_info_2G,
6132 WMI_MAX_HECAP_PHY_SIZE * 4);
6133 qdf_mem_copy(phy_5G, cap->he_cap_phy_info_5G,
6134 WMI_MAX_HECAP_PHY_SIZE * 4);
6135 ppet_2G = cap->he_ppet2G;
6136 ppet_5G = cap->he_ppet5G;
6137
6138 wma_print_he_mac_cap(mac_2G);
6139 wma_print_he_phy_cap(phy_2G);
6140 wma_print_he_ppet(&ppet_2G);
6141 wma_print_he_mac_cap(mac_5G);
6142 wma_print_he_phy_cap(phy_5G);
6143 wma_print_he_ppet(&ppet_5G);
6144}
Krunal Soni0193b6f2016-08-15 15:53:43 -07006145
6146/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006147 * wma_print_populate_soc_caps() - Prints all the caps populated per hw mode
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306148 * @tgt_info: target related info
Krunal Soni2e48d012016-05-02 16:55:26 -07006149 *
6150 * This function prints all the caps populater per hw mode and per PHY
6151 *
6152 * Return: none
6153 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306154static void wma_print_populate_soc_caps(struct target_psoc_info *tgt_hdl)
Krunal Soni2e48d012016-05-02 16:55:26 -07006155{
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006156 int i, num_hw_modes, total_mac_phy_cnt;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306157 struct wlan_psoc_host_mac_phy_caps *mac_phy_cap, *tmp;
6158
6159 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006160 total_mac_phy_cnt = target_psoc_get_total_mac_phy_cnt(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006161
6162 /* print number of hw modes */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306163 WMA_LOGD("%s: num of hw modes [%d]", __func__, num_hw_modes);
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006164 WMA_LOGD("%s: num mac_phy_cnt [%d]", __func__, total_mac_phy_cnt);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306165 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006166 WMA_LOGD("%s: <====== HW mode cap printing starts ======>", __func__);
Krunal Soni2e48d012016-05-02 16:55:26 -07006167 /* print cap of each hw mode */
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006168 for (i = 0; i < total_mac_phy_cnt; i++) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006169 WMA_LOGD("====>: hw mode id[%d], phy_id map[%d]",
Kiran Kumar Lokere0923ad82018-02-28 19:01:16 -08006170 mac_phy_cap[i].hw_mode_id,
6171 mac_phy_cap[i].phy_id);
6172 tmp = &mac_phy_cap[i];
6173 wma_print_mac_phy_capabilities(tmp, i);
Krunal Soni2e48d012016-05-02 16:55:26 -07006174 }
6175 WMA_LOGI("%s: <====== HW mode cap printing ends ======>\n", __func__);
6176}
6177
6178/**
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306179 * wma_map_wmi_channel_width_to_hw_mode_bw() - returns bandwidth
6180 * in terms of hw_mode_bandwidth
6181 * @width: bandwidth in terms of wmi_channel_width
6182 *
6183 * This function returns the bandwidth in terms of hw_mode_bandwidth.
6184 *
6185 * Return: BW in terms of hw_mode_bandwidth.
6186 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006187static enum hw_mode_bandwidth wma_map_wmi_channel_width_to_hw_mode_bw(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306188 wmi_channel_width width)
6189{
6190 switch (width) {
6191 case WMI_CHAN_WIDTH_20:
6192 return HW_MODE_20_MHZ;
6193 case WMI_CHAN_WIDTH_40:
6194 return HW_MODE_40_MHZ;
6195 case WMI_CHAN_WIDTH_80:
6196 return HW_MODE_80_MHZ;
6197 case WMI_CHAN_WIDTH_160:
6198 return HW_MODE_160_MHZ;
6199 case WMI_CHAN_WIDTH_80P80:
6200 return HW_MODE_80_PLUS_80_MHZ;
6201 case WMI_CHAN_WIDTH_5:
6202 return HW_MODE_5_MHZ;
6203 case WMI_CHAN_WIDTH_10:
6204 return HW_MODE_10_MHZ;
6205 default:
6206 return HW_MODE_BW_NONE;
6207 }
6208
6209 return HW_MODE_BW_NONE;
6210}
6211
6212/**
6213 * wma_get_hw_mode_params() - get TX-RX stream and bandwidth
6214 * supported from the capabilities.
6215 * @caps: PHY capability
6216 * @info: param to store TX-RX stream and BW information
6217 *
6218 * This function will calculate TX-RX stream and bandwidth supported
6219 * as per the PHY capability, and assign to mac_ss_bw_info.
6220 *
6221 * Return: none
6222 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306223static void wma_get_hw_mode_params(struct wlan_psoc_host_mac_phy_caps *caps,
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306224 struct mac_ss_bw_info *info)
6225{
6226 if (!caps) {
6227 WMA_LOGE("%s: Invalid capabilities", __func__);
6228 return;
6229 }
6230
6231 info->mac_tx_stream = wma_get_num_of_setbits_from_bitmask(
6232 QDF_MAX(caps->tx_chain_mask_2G,
6233 caps->tx_chain_mask_5G));
6234 info->mac_rx_stream = wma_get_num_of_setbits_from_bitmask(
6235 QDF_MAX(caps->rx_chain_mask_2G,
6236 caps->rx_chain_mask_5G));
6237 info->mac_bw = wma_map_wmi_channel_width_to_hw_mode_bw(
6238 QDF_MAX(caps->max_bw_supported_2G,
6239 caps->max_bw_supported_5G));
6240}
6241
6242/**
6243 * wma_set_hw_mode_params() - sets TX-RX stream, bandwidth and
6244 * DBS in hw_mode_list
6245 * @wma_handle: pointer to wma global structure
6246 * @mac0_ss_bw_info: TX-RX streams, BW for MAC0
6247 * @mac1_ss_bw_info: TX-RX streams, BW for MAC1
6248 * @pos: refers to hw_mode_index
6249 * @dbs_mode: dbs_mode for the dbs_hw_mode
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306250 * @sbs_mode: sbs_mode for the sbs_hw_mode
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306251 *
6252 * This function sets TX-RX stream, bandwidth and DBS mode in
6253 * hw_mode_list.
6254 *
6255 * Return: none
6256 */
6257static void wma_set_hw_mode_params(t_wma_handle *wma_handle,
6258 struct mac_ss_bw_info mac0_ss_bw_info,
6259 struct mac_ss_bw_info mac1_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306260 uint32_t pos, uint32_t dbs_mode,
6261 uint32_t sbs_mode)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306262{
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306263 WMA_HW_MODE_MAC0_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306264 wma_handle->hw_mode.hw_mode_list[pos],
6265 mac0_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306266 WMA_HW_MODE_MAC0_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306267 wma_handle->hw_mode.hw_mode_list[pos],
6268 mac0_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306269 WMA_HW_MODE_MAC0_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306270 wma_handle->hw_mode.hw_mode_list[pos],
6271 mac0_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306272 WMA_HW_MODE_MAC1_TX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306273 wma_handle->hw_mode.hw_mode_list[pos],
6274 mac1_ss_bw_info.mac_tx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306275 WMA_HW_MODE_MAC1_RX_STREAMS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306276 wma_handle->hw_mode.hw_mode_list[pos],
6277 mac1_ss_bw_info.mac_rx_stream);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306278 WMA_HW_MODE_MAC1_BANDWIDTH_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306279 wma_handle->hw_mode.hw_mode_list[pos],
6280 mac1_ss_bw_info.mac_bw);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306281 WMA_HW_MODE_DBS_MODE_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306282 wma_handle->hw_mode.hw_mode_list[pos],
6283 dbs_mode);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306284 WMA_HW_MODE_AGILE_DFS_SET(
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306285 wma_handle->hw_mode.hw_mode_list[pos],
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306286 HW_MODE_AGILE_DFS_NONE);
6287 WMA_HW_MODE_SBS_MODE_SET(
6288 wma_handle->hw_mode.hw_mode_list[pos],
6289 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306290}
6291
6292/**
6293 * wma_update_hw_mode_list() - updates hw_mode_list
6294 * @wma_handle: pointer to wma global structure
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306295 * @tgt_hdl - target psoc information
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306296 *
6297 * This function updates hw_mode_list with tx_streams, rx_streams,
6298 * bandwidth, dbs and agile dfs for each hw_mode.
6299 *
6300 * Returns: 0 for success else failure.
6301 */
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306302static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle,
6303 struct target_psoc_info *tgt_hdl)
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306304{
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306305 struct wlan_psoc_host_mac_phy_caps *tmp, *mac_phy_cap;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306306 uint32_t i, hw_config_type, j = 0;
6307 uint32_t dbs_mode, sbs_mode;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306308 struct mac_ss_bw_info mac0_ss_bw_info = {0};
6309 struct mac_ss_bw_info mac1_ss_bw_info = {0};
Krunal Sonica50b452017-08-04 22:24:59 -07006310 WMI_PHY_CAPABILITY new_supported_band = 0;
6311 bool supported_band_update_failure = false;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306312 struct wlan_psoc_target_capability_info *tgt_cap_info;
6313 int num_hw_modes;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306314
6315 if (!wma_handle) {
6316 WMA_LOGE("%s: Invalid wma handle", __func__);
6317 return QDF_STATUS_E_FAILURE;
6318 }
6319
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306320 num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
6321 mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
6322 tgt_cap_info = target_psoc_get_target_caps(tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306323 /*
6324 * This list was updated as part of service ready event. Re-populate
6325 * HW mode list from the device capabilities.
6326 */
6327 if (wma_handle->hw_mode.hw_mode_list) {
6328 qdf_mem_free(wma_handle->hw_mode.hw_mode_list);
6329 wma_handle->hw_mode.hw_mode_list = NULL;
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006330 WMA_LOGD("%s: DBS list is freed", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306331 }
6332
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306333 wma_handle->hw_mode.hw_mode_list =
6334 qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) *
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306335 num_hw_modes);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306336 if (!wma_handle->hw_mode.hw_mode_list) {
6337 WMA_LOGE("%s: Memory allocation failed for DBS", __func__);
6338 return QDF_STATUS_E_FAILURE;
6339 }
6340
Srinivas Girigowdaf1472122017-03-09 15:44:12 -08006341 WMA_LOGD("%s: Updated HW mode list: Num modes:%d",
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306342 __func__, num_hw_modes);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306343
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306344 for (i = 0; i < num_hw_modes; i++) {
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306345 /* Update for MAC0 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306346 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306347 wma_get_hw_mode_params(tmp, &mac0_ss_bw_info);
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306348 hw_config_type = mac_phy_cap[j].hw_mode_config_type;
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306349 dbs_mode = HW_MODE_DBS_NONE;
6350 sbs_mode = HW_MODE_SBS_NONE;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306351 mac1_ss_bw_info.mac_tx_stream = 0;
6352 mac1_ss_bw_info.mac_rx_stream = 0;
6353 mac1_ss_bw_info.mac_bw = 0;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306354 if (wma_update_supported_bands(tmp->supported_bands,
6355 &new_supported_band)
6356 != QDF_STATUS_SUCCESS)
Krunal Sonica50b452017-08-04 22:24:59 -07006357 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306358
6359 /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */
6360 if ((hw_config_type == WMI_HW_MODE_DBS) ||
6361 (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6362 (hw_config_type == WMI_HW_MODE_SBS)) {
6363 /* Update for MAC1 */
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306364 tmp = &mac_phy_cap[j++];
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306365 wma_get_hw_mode_params(tmp, &mac1_ss_bw_info);
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306366 if (hw_config_type == WMI_HW_MODE_DBS)
6367 dbs_mode = HW_MODE_DBS;
6368 if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) ||
6369 (hw_config_type == WMI_HW_MODE_SBS))
6370 sbs_mode = HW_MODE_SBS;
Krunal Sonica50b452017-08-04 22:24:59 -07006371 if (QDF_STATUS_SUCCESS !=
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306372 wma_update_supported_bands(tmp->supported_bands,
Krunal Sonica50b452017-08-04 22:24:59 -07006373 &new_supported_band))
6374 supported_band_update_failure = true;
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306375 }
6376
6377 /* Updating HW mode list */
6378 wma_set_hw_mode_params(wma_handle, mac0_ss_bw_info,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05306379 mac1_ss_bw_info, i, dbs_mode,
6380 sbs_mode);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306381 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006382
Krunal Sonica50b452017-08-04 22:24:59 -07006383 /* overwrite phy_capability which we got from service ready event */
6384 if (!supported_band_update_failure) {
6385 WMA_LOGD("%s: updating supported band from old[%d] to new[%d]",
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306386 __func__, target_if_get_phy_capability(tgt_hdl),
Krunal Sonica50b452017-08-04 22:24:59 -07006387 new_supported_band);
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306388 target_if_set_phy_capability(tgt_hdl, new_supported_band);
Krunal Sonica50b452017-08-04 22:24:59 -07006389 }
6390
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006391 if (QDF_STATUS_SUCCESS !=
Krunal Sonica50b452017-08-04 22:24:59 -07006392 policy_mgr_update_hw_mode_list(wma_handle->psoc,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306393 tgt_hdl))
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07006394 WMA_LOGE("%s: failed to update policy manager", __func__);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306395 wma_dump_dbs_hw_mode(wma_handle);
6396 return QDF_STATUS_SUCCESS;
6397}
6398
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006399static void wma_init_wifi_pos_dma_rings(t_wma_handle *wma_handle,
6400 uint8_t num_mac, void *buf)
6401{
6402 struct hif_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
Amar Singhal4c3fbb42018-01-02 13:20:28 -08006403 void *hal_soc;
6404
6405 if (!hif_ctx) {
6406 WMA_LOGE("invalid hif context");
6407 return;
6408 }
6409
6410 hal_soc = hif_get_hal_handle(hif_ctx);
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006411
6412 wifi_pos_init_cir_cfr_rings(wma_handle->psoc, hal_soc, num_mac, buf);
6413}
6414
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306415/**
Krunal Soni2e48d012016-05-02 16:55:26 -07006416 * wma_populate_soc_caps() - populate entire SOC's capabilities
6417 * @wma_handle: pointer to wma global structure
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306418 * @tgt_hdl: target psoc information
Krunal Soni2e48d012016-05-02 16:55:26 -07006419 * @param_buf: pointer to param of service ready extension event from fw
6420 *
6421 * This API populates all capabilities of entire SOC. For example,
6422 * how many number of hw modes are supported by this SOC, what are the
6423 * capabilities of each phy per hw mode, what are HAL reg capabilities per
6424 * phy.
6425 *
6426 * Return: none
6427 */
6428static void wma_populate_soc_caps(t_wma_handle *wma_handle,
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306429 struct target_psoc_info *tgt_hdl,
Krunal Soni2e48d012016-05-02 16:55:26 -07006430 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf)
6431{
Krunal Soni2e48d012016-05-02 16:55:26 -07006432
6433 WMA_LOGD("%s: Enter", __func__);
6434
Naveen Rawat4efe41b2017-04-29 16:23:14 -07006435 wma_init_wifi_pos_dma_rings(wma_handle,
6436 param_buf->num_oem_dma_ring_caps,
6437 param_buf->oem_dma_ring_caps);
6438
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306439 wma_print_populate_soc_caps(tgt_hdl);
Krunal Soni2e48d012016-05-02 16:55:26 -07006440}
6441
6442/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006443 * wma_rx_service_ready_ext_event() - evt handler for sevice ready ext event.
6444 * @handle: wma handle
6445 * @event: params of the service ready extended event
Govind Singhd76a5b02016-03-08 15:12:14 +05306446 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006447 *
6448 * Return: none
6449 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306450int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
6451 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006452{
6453 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6454 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
6455 wmi_service_ready_ext_event_fixed_param *ev;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306456 QDF_STATUS ret;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306457 struct target_psoc_info *tgt_hdl;
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306458 uint32_t conc_scan_config_bits, fw_config_bits;
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306459
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006460 WMA_LOGD("%s: Enter", __func__);
6461
6462 if (!wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006463 WMA_LOGE("%s: Invalid WMA handle", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306464 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006465 }
6466
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306467 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6468 if (!tgt_hdl) {
6469 WMA_LOGE("%s: target psoc info is NULL", __func__);
6470 return -EINVAL;
6471 }
6472
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006473 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
6474 if (!param_buf) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006475 WMA_LOGE("%s: Invalid event", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306476 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006477 }
6478
6479 ev = param_buf->fixed_param;
6480 if (!ev) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006481 WMA_LOGE("%s: Invalid buffer", __func__);
Govind Singhd76a5b02016-03-08 15:12:14 +05306482 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483 }
6484
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006485 WMA_LOGD("WMA <-- WMI_SERVICE_READY_EXT_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306487 fw_config_bits = target_if_get_fw_config_bits(tgt_hdl);
6488 conc_scan_config_bits = target_if_get_conc_scan_config_bits(tgt_hdl);
6489
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006490 WMA_LOGD("%s: Defaults: scan config:%x FW mode config:%x",
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306491 __func__, conc_scan_config_bits, fw_config_bits);
Chandrasekaran, Manishekarc8416922015-10-14 11:19:00 +05306492
Anurag Chouhan210db072016-02-22 18:42:15 +05306493 ret = qdf_mc_timer_stop(&wma_handle->service_ready_ext_timer);
Anurag Chouhandf2b2682016-02-29 14:15:27 +05306494 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006495 WMA_LOGE("Failed to stop the service ready ext timer");
Govind Singhd76a5b02016-03-08 15:12:14 +05306496 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006497 }
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306498 wma_populate_soc_caps(wma_handle, tgt_hdl, param_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006499
Arunk Khandavalli80a61352018-01-25 12:19:37 +05306500 ret = wma_update_hw_mode_list(wma_handle, tgt_hdl);
Nitesh Shah877ad5d2016-09-22 19:27:58 +05306501 if (QDF_IS_STATUS_ERROR(ret)) {
6502 WMA_LOGE("Failed to update hw mode list");
6503 return -EINVAL;
6504 }
6505
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006506 WMA_LOGD("WMA --> WMI_INIT_CMDID");
Mukul Sharmab10c8c72017-11-02 17:25:59 +05306507
Arunk Khandavalli10af7282018-02-05 16:55:48 +05306508 wma_init_scan_fw_mode_config(wma_handle->psoc, conc_scan_config_bits,
Arunk Khandavalli2462f462018-01-25 14:41:02 +05306509 fw_config_bits);
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306510
6511 target_psoc_set_num_radios(tgt_hdl, 1);
Govind Singhd76a5b02016-03-08 15:12:14 +05306512 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006513}
6514
6515/**
6516 * wma_rx_ready_event() - event handler to process
6517 * wmi rx ready event.
6518 * @handle: wma handle
6519 * @cmd_param_info: command params info
Govind Singhd76a5b02016-03-08 15:12:14 +05306520 * @length: param length
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006521 *
6522 * Return: none
6523 */
Govind Singhd76a5b02016-03-08 15:12:14 +05306524int wma_rx_ready_event(void *handle, uint8_t *cmd_param_info,
6525 uint32_t length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006526{
6527 tp_wma_handle wma_handle = (tp_wma_handle) handle;
6528 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
6529 wmi_ready_event_fixed_param *ev = NULL;
6530
6531 WMA_LOGD("%s: Enter", __func__);
6532
6533 param_buf = (WMI_READY_EVENTID_param_tlvs *) cmd_param_info;
6534 if (!(wma_handle && param_buf)) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006535 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306536 QDF_ASSERT(0);
Govind Singhd76a5b02016-03-08 15:12:14 +05306537 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006538 }
6539
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006540 WMA_LOGD("WMA <-- WMI_READY_EVENTID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006541
6542 ev = param_buf->fixed_param;
6543 /* Indicate to the waiting thread that the ready
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006544 * event was received
6545 */
Naveen Rawat64e477e2016-05-20 10:34:56 -07006546 wma_handle->sub_20_support =
Sourav Mohapatra89c85d12017-12-01 09:17:54 +05306547 wmi_service_enabled(wma_handle->wmi_handle,
6548 wmi_service_half_rate_quarter_rate_support);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006549 wma_handle->wmi_ready = true;
6550 wma_handle->wlan_init_status = ev->status;
6551
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006552 /* copy the mac addr */
6553 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->myaddr);
6554 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, wma_handle->hwaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006555 wma_update_hdd_cfg(wma_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006556 WMA_LOGD("Exit");
Govind Singhd76a5b02016-03-08 15:12:14 +05306557
6558 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006559}
6560
6561/**
6562 * wma_setneedshutdown() - setting wma needshutdown flag
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006563 *
6564 * Return: none
6565 */
Jeff Johnson1f8d0a02017-09-13 08:09:05 -07006566void wma_setneedshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006567{
6568 tp_wma_handle wma_handle;
6569
6570 WMA_LOGD("%s: Enter", __func__);
6571
Anurag Chouhan6d760662016-02-20 16:05:43 +05306572 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006573
6574 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006575 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306576 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006577 return;
6578 }
6579
6580 wma_handle->needShutdown = true;
6581 WMA_LOGD("%s: Exit", __func__);
6582}
6583
6584/**
6585 * wma_needshutdown() - Is wma needs shutdown?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006586 *
6587 * Return: returns true/false
6588 */
Jeff Johnson1b5404e2017-09-13 08:04:46 -07006589bool wma_needshutdown(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006590{
6591 tp_wma_handle wma_handle;
6592
6593 WMA_LOGD("%s: Enter", __func__);
6594
Anurag Chouhan6d760662016-02-20 16:05:43 +05306595 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006596
6597 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006598 WMA_LOGE("%s: Invalid arguments", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306599 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006600 return false;
6601 }
6602
6603 WMA_LOGD("%s: Exit", __func__);
6604 return wma_handle->needShutdown;
6605}
6606
6607/**
6608 * wma_wait_for_ready_event() - wait for wma ready event
6609 * @handle: wma handle
6610 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306611 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006612 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306613QDF_STATUS wma_wait_for_ready_event(WMA_HANDLE handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006614{
6615 tp_wma_handle wma_handle = (tp_wma_handle) handle;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306616 QDF_STATUS qdf_status;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306617 struct target_psoc_info *tgt_hdl;
6618 int timeleft;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006619
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306620 tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
6621 if (!tgt_hdl) {
6622 WMA_LOGE("%s: target psoc info is NULL", __func__);
6623 return QDF_STATUS_E_INVAL;
6624 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006625
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306626 timeleft = qdf_wait_queue_timeout(
6627 tgt_hdl->info.event_queue,
6628 ((tgt_hdl->info.wmi_service_ready) &&
6629 (tgt_hdl->info.wmi_ready)),
6630 WMA_READY_EVENTID_TIMEOUT);
6631 if (!timeleft) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006632 WMA_LOGE("%s: Timeout waiting for ready event from FW",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006633 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306634 qdf_status = QDF_STATUS_E_FAILURE;
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306635 } else {
6636 WMA_LOGI("%s Ready event received from FW", __func__);
6637 qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006638 }
Arunk Khandavallia6305a32018-01-25 11:19:18 +05306639
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306640 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006641}
6642
6643/**
6644 * wma_set_ppsconfig() - set pps config in fw
6645 * @vdev_id: vdev id
6646 * @pps_param: pps params
6647 * @val : param value
6648 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306649 * Return: 0 for success or QDF error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006650 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306651QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006652 int val)
6653{
Anurag Chouhan6d760662016-02-20 16:05:43 +05306654 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006655 int ret = -EIO;
6656 uint32_t pps_val;
6657
6658 if (NULL == wma) {
6659 WMA_LOGE("%s: Failed to get wma", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306660 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006661 }
6662
6663 switch (pps_param) {
6664 case WMA_VHT_PPS_PAID_MATCH:
6665 pps_val = ((val << 31) & 0xffff0000) |
6666 (PKT_PWR_SAVE_PAID_MATCH & 0xffff);
6667 goto pkt_pwr_save_config;
6668 case WMA_VHT_PPS_GID_MATCH:
6669 pps_val = ((val << 31) & 0xffff0000) |
6670 (PKT_PWR_SAVE_GID_MATCH & 0xffff);
6671 goto pkt_pwr_save_config;
6672 case WMA_VHT_PPS_DELIM_CRC_FAIL:
6673 pps_val = ((val << 31) & 0xffff0000) |
6674 (PKT_PWR_SAVE_DELIM_CRC_FAIL & 0xffff);
6675 goto pkt_pwr_save_config;
6676
6677 /* Enable the code below as and when the functionality
6678 * is supported/added in host.
6679 */
6680#ifdef NOT_YET
6681 case WMA_VHT_PPS_EARLY_TIM_CLEAR:
6682 pps_val = ((val << 31) & 0xffff0000) |
6683 (PKT_PWR_SAVE_EARLY_TIM_CLEAR & 0xffff);
6684 goto pkt_pwr_save_config;
6685 case WMA_VHT_PPS_EARLY_DTIM_CLEAR:
6686 pps_val = ((val << 31) & 0xffff0000) |
6687 (PKT_PWR_SAVE_EARLY_DTIM_CLEAR & 0xffff);
6688 goto pkt_pwr_save_config;
6689 case WMA_VHT_PPS_EOF_PAD_DELIM:
6690 pps_val = ((val << 31) & 0xffff0000) |
6691 (PKT_PWR_SAVE_EOF_PAD_DELIM & 0xffff);
6692 goto pkt_pwr_save_config;
6693 case WMA_VHT_PPS_MACADDR_MISMATCH:
6694 pps_val = ((val << 31) & 0xffff0000) |
6695 (PKT_PWR_SAVE_MACADDR_MISMATCH & 0xffff);
6696 goto pkt_pwr_save_config;
6697 case WMA_VHT_PPS_GID_NSTS_ZERO:
6698 pps_val = ((val << 31) & 0xffff0000) |
6699 (PKT_PWR_SAVE_GID_NSTS_ZERO & 0xffff);
6700 goto pkt_pwr_save_config;
6701 case WMA_VHT_PPS_RSSI_CHECK:
6702 pps_val = ((val << 31) & 0xffff0000) |
6703 (PKT_PWR_SAVE_RSSI_CHECK & 0xffff);
6704 goto pkt_pwr_save_config;
6705#endif /* NOT_YET */
6706pkt_pwr_save_config:
6707 WMA_LOGD("vdev_id:%d val:0x%x pps_val:0x%x", vdev_id,
6708 val, pps_val);
Govind Singhd76a5b02016-03-08 15:12:14 +05306709 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006710 WMI_VDEV_PARAM_PACKET_POWERSAVE,
6711 pps_val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006712 break;
6713 default:
6714 WMA_LOGE("%s:INVALID PPS CONFIG", __func__);
6715 }
6716
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306717 return (ret) ? QDF_STATUS_E_FAILURE : QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006718}
6719
6720/**
6721 * wma_process_set_mas() - Function to enable/disable MAS
6722 * @wma: Pointer to WMA handle
6723 * @mas_val: 1-Enable MAS, 0-Disable MAS
6724 *
6725 * This function enables/disables the MAS value
6726 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306727 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006728 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006729static QDF_STATUS wma_process_set_mas(tp_wma_handle wma,
6730 uint32_t *mas_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006731{
6732 uint32_t val;
6733
6734 if (NULL == wma || NULL == mas_val) {
6735 WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306736 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006737 }
6738
6739 val = (*mas_val);
6740
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306741 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006742 wma_set_enable_disable_mcc_adaptive_scheduler(val)) {
6743 WMA_LOGE("%s: Unable to enable/disable MAS", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306744 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006745 }
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07006746 WMA_LOGE("%s: Value is %d", __func__, val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306747 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006748}
6749
6750/**
6751 * wma_process_set_miracast() - Function to set miracast value in WMA
6752 * @wma: Pointer to WMA handle
6753 * @miracast_val: 0-Disabled,1-Source,2-Sink
6754 *
6755 * This function stores the miracast value in WMA
6756 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306757 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006758 *
6759 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006760static QDF_STATUS wma_process_set_miracast(tp_wma_handle wma,
6761 uint32_t *miracast_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006762{
6763 if (NULL == wma || NULL == miracast_val) {
6764 WMA_LOGE("%s: Invalid input to store miracast value", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306765 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006766 }
6767
6768 wma->miracast_value = *miracast_val;
6769 WMA_LOGE("%s: Miracast value is %d", __func__, wma->miracast_value);
6770
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306771 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006772}
6773
6774/**
6775 * wma_config_stats_factor() - Function to configure stats avg. factor
6776 * @wma: pointer to WMA handle
6777 * @avg_factor: stats. avg. factor passed down by userspace
6778 *
6779 * This function configures the avg. stats value in firmware
6780 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306781 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006782 *
6783 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306784static QDF_STATUS wma_config_stats_factor(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006785 struct sir_stats_avg_factor *avg_factor)
6786{
Govind Singhd76a5b02016-03-08 15:12:14 +05306787 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006788
6789 if (NULL == wma || NULL == avg_factor) {
6790 WMA_LOGE("%s: Invalid input of stats avg factor", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306791 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006792 }
6793
Govind Singhd76a5b02016-03-08 15:12:14 +05306794 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006795 avg_factor->vdev_id,
6796 WMI_VDEV_PARAM_STATS_AVG_FACTOR,
6797 avg_factor->stats_avg_factor);
Govind Singhd76a5b02016-03-08 15:12:14 +05306798 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006799 WMA_LOGE(" failed to set avg_factor for vdev_id %d",
6800 avg_factor->vdev_id);
6801 }
6802
6803 WMA_LOGD("%s: Set stats_avg_factor %d for vdev_id %d", __func__,
6804 avg_factor->stats_avg_factor, avg_factor->vdev_id);
6805
6806 return ret;
6807}
6808
6809/**
6810 * wma_config_guard_time() - Function to set guard time in firmware
6811 * @wma: pointer to WMA handle
6812 * @guard_time: guard time passed down by userspace
6813 *
6814 * This function configures the guard time in firmware
6815 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306816 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006817 *
6818 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306819static QDF_STATUS wma_config_guard_time(tp_wma_handle wma,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006820 struct sir_guard_time_request *guard_time)
6821{
Govind Singhd76a5b02016-03-08 15:12:14 +05306822 QDF_STATUS ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006823
6824 if (NULL == wma || NULL == guard_time) {
6825 WMA_LOGE("%s: Invalid input of guard time", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306826 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006827 }
6828
Govind Singhd76a5b02016-03-08 15:12:14 +05306829 ret = wma_vdev_set_param(wma->wmi_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006830 guard_time->vdev_id,
6831 WMI_VDEV_PARAM_RX_LEAK_WINDOW,
6832 guard_time->guard_time);
Govind Singhd76a5b02016-03-08 15:12:14 +05306833 if (QDF_IS_STATUS_ERROR(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006834 WMA_LOGE(" failed to set guard time for vdev_id %d",
6835 guard_time->vdev_id);
6836 }
6837
6838 WMA_LOGD("Set guard time %d for vdev_id %d",
6839 guard_time->guard_time, guard_time->vdev_id);
6840
6841 return ret;
6842}
6843
6844/**
6845 * wma_enable_specific_fw_logs() - Start/Stop logging of diag event/log id
6846 * @wma_handle: WMA handle
6847 * @start_log: Start logging related parameters
6848 *
6849 * Send the command to the FW based on which specific logging of diag
6850 * event/log id can be started/stopped
6851 *
6852 * Return: None
6853 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006854static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
6855 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006856{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006857
6858 if (!start_log) {
6859 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6860 return;
6861 }
6862 if (!wma_handle) {
6863 WMA_LOGE("%s: Invalid wma handle", __func__);
6864 return;
6865 }
6866
6867 if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
6868 (start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
6869 WMA_LOGD("%s: Not connectivity or fw debug ring: %d",
6870 __func__, start_log->ring_id);
6871 return;
6872 }
6873
Govind Singhf25a0f12016-03-08 16:09:48 +05306874 wmi_unified_enable_specific_fw_logs_cmd(wma_handle->wmi_handle,
6875 (struct wmi_wifi_start_log *)start_log);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006876}
6877
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306878#define MEGABYTE (1024 * 1024)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006879/**
6880 * wma_set_wifi_start_packet_stats() - Start/stop packet stats
6881 * @wma_handle: WMA handle
6882 * @start_log: Struture containing the start wifi logger params
6883 *
6884 * This function is used to send the WMA commands to start/stop logging
6885 * of per packet statistics
6886 *
6887 * Return: None
6888 *
6889 */
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006890#ifdef REMOVE_PKT_LOG
6891static void wma_set_wifi_start_packet_stats(void *wma_handle,
6892 struct sir_wifi_start_log *start_log)
6893{
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006894}
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07006895
Jeff Johnsonc4b47a92016-10-07 12:34:41 -07006896#else
6897static void wma_set_wifi_start_packet_stats(void *wma_handle,
6898 struct sir_wifi_start_log *start_log)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899{
Komal Seelam3d202862016-02-24 18:43:24 +05306900 struct hif_opaque_softc *scn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006901 uint32_t log_state;
6902
6903 if (!start_log) {
6904 WMA_LOGE("%s: start_log pointer is NULL", __func__);
6905 return;
6906 }
6907 if (!wma_handle) {
6908 WMA_LOGE("%s: Invalid wma handle", __func__);
6909 return;
6910 }
6911
6912 /* No need to register for ring IDs other than packet stats */
6913 if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07006914 WMA_LOGD("%s: Ring id is not for per packet stats: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006915 __func__, start_log->ring_id);
6916 return;
6917 }
6918
Anurag Chouhan6d760662016-02-20 16:05:43 +05306919 scn = cds_get_context(QDF_MODULE_ID_HIF);
Naveen Rawatb2109f62016-07-21 14:18:15 -07006920 if (scn == NULL) {
6921 WMA_LOGE("%s: Invalid HIF handle", __func__);
6922 return;
6923 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006924
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07006925#ifdef HELIUMPLUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006926 log_state = ATH_PKTLOG_ANI | ATH_PKTLOG_RCUPDATE | ATH_PKTLOG_RCFIND |
Nirav Shahdcc4c872016-07-28 11:35:26 +05306927 ATH_PKTLOG_RX | ATH_PKTLOG_TX |
Venkata Sharath Chandra Manchala29965172018-01-18 14:17:29 -08006928 ATH_PKTLOG_TEXT | ATH_PKTLOG_SW_EVENT;
Venkata Sharath Chandra Manchala1240fc72017-10-26 17:32:29 -07006929#else
6930 log_state = ATH_PKTLOG_LITE_T2H | ATH_PKTLOG_LITE_RX;
6931#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306932 if (start_log->size != 0) {
6933 pktlog_setsize(scn, start_log->size * MEGABYTE);
6934 return;
Poddar, Siddarthab99a272017-04-10 12:53:26 +05306935 } else if (start_log->is_pktlog_buff_clear == true) {
6936 pktlog_clearbuff(scn, start_log->is_pktlog_buff_clear);
6937 return;
Poddar, Siddarth176c4362016-10-03 12:25:00 +05306938 }
6939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006940 if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006941 pktlog_enable(scn, log_state, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306942 start_log->user_triggered,
6943 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006944 WMA_LOGD("%s: Enabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006945 } else {
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08006946 pktlog_enable(scn, 0, start_log->ini_triggered,
Poddar, Siddartheefe3482016-09-21 18:12:59 +05306947 start_log->user_triggered,
6948 start_log->is_iwpriv_command);
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08006949 WMA_LOGD("%s: Disabling per packet stats", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006950 }
6951}
6952#endif
6953
6954/**
6955 * wma_send_flush_logs_to_fw() - Send log flush command to FW
6956 * @wma_handle: WMI handle
6957 *
6958 * This function is used to send the flush command to the FW,
6959 * that will flush the fw logs that are residue in the FW
6960 *
6961 * Return: None
6962 */
6963void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
6964{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306965 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006966 int ret;
6967
Govind Singhf25a0f12016-03-08 16:09:48 +05306968 ret = wmi_unified_flush_logs_to_fw_cmd(wma_handle->wmi_handle);
6969 if (ret != EOK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006970 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006971
Anurag Chouhan210db072016-02-22 18:42:15 +05306972 status = qdf_mc_timer_start(&wma_handle->log_completion_timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973 WMA_LOG_COMPLETION_TIMER);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306974 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006975 WMA_LOGE("Failed to start the log completion timer");
6976}
6977
6978/**
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05306979 * wma_update_wep_default_key - To update default key id
6980 * @wma: pointer to wma handler
6981 * @update_def_key: pointer to wep_update_default_key_idx
6982 *
6983 * This function makes a copy of default key index to txrx node
6984 *
6985 * Return: Success
6986 */
6987static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
6988 struct wep_update_default_key_idx *update_def_key)
6989{
6990 struct wma_txrx_node *iface =
6991 &wma->interfaces[update_def_key->session_id];
6992 iface->wep_default_key_idx = update_def_key->default_idx;
6993
6994 return QDF_STATUS_SUCCESS;
6995}
6996
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05306997/**
6998 * wma_update_tx_fail_cnt_th() - Set threshold for TX pkt fail
6999 * @wma_handle: WMA handle
7000 * @tx_fail_cnt_th: sme_tx_fail_cnt_threshold parameter
7001 *
7002 * This function is used to set Tx pkt fail count threshold,
7003 * FW will do disconnect with station once this threshold is reached.
7004 *
7005 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7006 */
7007static QDF_STATUS wma_update_tx_fail_cnt_th(tp_wma_handle wma,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007008 struct sme_tx_fail_cnt_threshold *tx_fail_cnt_th)
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05307009{
7010 u_int8_t vdev_id;
7011 u_int32_t tx_fail_disconn_th;
7012 int ret = -EIO;
7013
7014 if (!wma || !wma->wmi_handle) {
7015 WMA_LOGE(FL("WMA is closed, can not issue Tx pkt fail count threshold"));
7016 return QDF_STATUS_E_INVAL;
7017 }
7018 vdev_id = tx_fail_cnt_th->session_id;
7019 tx_fail_disconn_th = tx_fail_cnt_th->tx_fail_cnt_threshold;
7020 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7021 vdev_id, tx_fail_disconn_th);
7022
7023
7024 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7025 WMI_VDEV_PARAM_DISCONNECT_TH,
7026 tx_fail_disconn_th);
7027
7028 if (ret) {
7029 WMA_LOGE(FL("Failed to send TX pkt fail count threshold command"));
7030 return QDF_STATUS_E_FAILURE;
7031 }
7032
7033 return QDF_STATUS_SUCCESS;
7034}
7035
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05307036/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307037 * wma_update_short_retry_limit() - Set retry limit for short frames
7038 * @wma_handle: WMA handle
7039 * @short_retry_limit_th: retry limir count for Short frames.
7040 *
7041 * This function is used to configure the transmission retry limit at which
7042 * short frames needs to be retry.
7043 *
7044 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7045 */
7046static QDF_STATUS wma_update_short_retry_limit(tp_wma_handle wma,
7047 struct sme_short_retry_limit *short_retry_limit_th)
7048{
7049 uint8_t vdev_id;
7050 uint32_t short_retry_limit;
7051 int ret;
7052
7053 if (!wma || !wma->wmi_handle) {
7054 WMA_LOGE("WMA is closed, can not issue short retry limit threshold");
7055 return QDF_STATUS_E_INVAL;
7056 }
7057 vdev_id = short_retry_limit_th->session_id;
7058 short_retry_limit = short_retry_limit_th->short_retry_limit;
7059 WMA_LOGD("Set short retry limit threshold vdevId %d count %d",
7060 vdev_id, short_retry_limit);
7061
7062 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7063 WMI_VDEV_PARAM_NON_AGG_SW_RETRY_TH,
7064 short_retry_limit);
7065
7066 if (ret) {
7067 WMA_LOGE("Failed to send short limit threshold command");
7068 return QDF_STATUS_E_FAILURE;
7069 }
7070 return QDF_STATUS_SUCCESS;
7071}
7072
7073/**
7074 * wma_update_long_retry_limit() - Set retry limit for long frames
7075 * @wma_handle: WMA handle
7076 * @long_retry_limit_th: retry limir count for long frames
7077 *
7078 * This function is used to configure the transmission retry limit at which
7079 * long frames needs to be retry
7080 *
7081 * Return: VOS_STATUS_SUCCESS on success, error number otherwise
7082 */
7083static QDF_STATUS wma_update_long_retry_limit(tp_wma_handle wma,
7084 struct sme_long_retry_limit *long_retry_limit_th)
7085{
7086 uint8_t vdev_id;
7087 uint32_t long_retry_limit;
7088 int ret;
7089
7090 if (!wma || !wma->wmi_handle) {
7091 WMA_LOGE("WMA is closed, can not issue long retry limit threshold");
7092 return QDF_STATUS_E_INVAL;
7093 }
7094 vdev_id = long_retry_limit_th->session_id;
7095 long_retry_limit = long_retry_limit_th->long_retry_limit;
7096 WMA_LOGD("Set TX pkt fail count threshold vdevId %d count %d",
7097 vdev_id, long_retry_limit);
7098
7099 ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
7100 WMI_VDEV_PARAM_AGG_SW_RETRY_TH,
7101 long_retry_limit);
7102
7103 if (ret) {
7104 WMA_LOGE("Failed to send long limit threshold command");
7105 return QDF_STATUS_E_FAILURE;
7106 }
7107
7108 return QDF_STATUS_SUCCESS;
7109}
7110
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +05307111/*
7112 * wma_update_sta_inactivity_timeout() - Set sta_inactivity_timeout to fw
7113 * @wma_handle: WMA handle
7114 * @sta_inactivity_timer: sme_sta_inactivity_timeout
7115 *
7116 * This function is used to set sta_inactivity_timeout.
7117 * If a station does not send anything in sta_inactivity_timeout seconds, an
7118 * empty data frame is sent to it in order to verify whether it is
7119 * still in range. If this frame is not ACKed, the station will be
7120 * disassociated and then deauthenticated.
7121 *
7122 * Return: None
7123 */
7124void wma_update_sta_inactivity_timeout(tp_wma_handle wma,
7125 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
7126{
7127 uint8_t vdev_id;
7128 uint32_t max_unresponsive_time;
7129 uint32_t min_inactive_time, max_inactive_time;
7130
7131 if (!wma || !wma->wmi_handle) {
7132 WMA_LOGE("WMA is closed, can not issue sta_inactivity_timeout");
7133 return;
7134 }
7135 vdev_id = sta_inactivity_timer->session_id;
7136 max_unresponsive_time = sta_inactivity_timer->sta_inactivity_timeout;
7137 max_inactive_time = max_unresponsive_time * TWO_THIRD;
7138 min_inactive_time = max_unresponsive_time - max_inactive_time;
7139
7140 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7141 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
7142 min_inactive_time))
7143 WMA_LOGE("Failed to Set AP MIN IDLE INACTIVE TIME");
7144
7145 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7146 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
7147 max_inactive_time))
7148 WMA_LOGE("Failed to Set AP MAX IDLE INACTIVE TIME");
7149
7150 if (wma_vdev_set_param(wma->wmi_handle, vdev_id,
7151 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
7152 max_unresponsive_time))
7153 WMA_LOGE("Failed to Set MAX UNRESPONSIVE TIME");
7154
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007155 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 +05307156 __func__, vdev_id,
7157 min_inactive_time, max_inactive_time,
7158 max_unresponsive_time);
7159}
7160
Yingying Tang95409972016-10-20 15:16:15 +08007161#ifdef WLAN_FEATURE_WOW_PULSE
7162
7163
7164#define WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7165WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMD_fixed_param
7166
7167
7168#define WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM \
7169WMITLV_TAG_STRUC_wmi_wow_hostwakeup_gpio_pin_pattern_config_cmd_fixed_param
7170
7171/**
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007172 * wma_send_wow_pulse_cmd() - send wmi cmd of wow pulse cmd
7173 * information to fw.
7174 * @wma_handle: wma handler
7175 * @udp_response: wow_pulse_mode pointer
7176 *
7177 * Return: Return QDF_STATUS
7178 */
Yingying Tang95409972016-10-20 15:16:15 +08007179static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7180 struct wow_pulse_mode *wow_pulse_cmd)
7181{
7182 QDF_STATUS status = QDF_STATUS_SUCCESS;
7183 wmi_buf_t buf;
7184 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *cmd;
7185 u_int16_t len;
7186
7187 len = sizeof(*cmd);
7188 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7189 if (!buf) {
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007190 WMA_LOGE("wmi_buf_alloc failed");
7191 return QDF_STATUS_E_NOMEM;
Yingying Tang95409972016-10-20 15:16:15 +08007192 }
7193
7194 cmd = (WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *)wmi_buf_data(buf);
7195 qdf_mem_zero(cmd, len);
7196
7197 WMITLV_SET_HDR(&cmd->tlv_header,
7198 WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM,
7199 WMITLV_GET_STRUCT_TLVLEN(
7200 WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM));
7201
7202 cmd->enable = wow_pulse_cmd->wow_pulse_enable;
7203 cmd->pin = wow_pulse_cmd->wow_pulse_pin;
7204 cmd->interval_low = wow_pulse_cmd->wow_pulse_interval_low;
7205 cmd->interval_high = wow_pulse_cmd->wow_pulse_interval_high;
7206 cmd->repeat_cnt = WMI_WOW_PULSE_REPEAT_CNT;
7207
7208 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7209 WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID)) {
7210 WMA_LOGE("Failed to send send wow pulse");
7211 wmi_buf_free(buf);
7212 status = QDF_STATUS_E_FAILURE;
7213 }
7214
7215 WMA_LOGD("%s: Exit", __func__);
7216 return status;
7217}
7218
7219#undef WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7220#undef WMITLV_TAG_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM
7221#undef WMI_WOW_PULSE_REPEAT_CNT
7222
7223#else
7224static inline QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle,
7225 struct wow_pulse_mode *wow_pulse_cmd)
7226{
7227 return QDF_STATUS_E_FAILURE;
7228}
7229#endif
7230
7231
Agrawal Ashishda3e9502016-09-21 17:43:51 +05307232/**
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307233 * wma_process_power_debug_stats_req() - Process the Chip Power stats collect
7234 * request and pass the Power stats request to Fw
7235 * @wma_handle: WMA handle
7236 *
7237 * Return: QDF_STATUS
7238 */
7239#ifdef WLAN_POWER_DEBUGFS
7240static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7241{
7242 wmi_pdev_get_chip_power_stats_cmd_fixed_param *cmd;
7243 int32_t len;
7244 wmi_buf_t buf;
7245 uint8_t *buf_ptr;
7246 int ret;
7247
7248 if (!wma_handle) {
7249 WMA_LOGE("%s: input pointer is NULL", __func__);
7250 return QDF_STATUS_E_FAILURE;
7251 }
7252
7253 len = sizeof(*cmd);
7254 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7255 if (!buf) {
7256 WMA_LOGE("%s: Failed allocate wmi buffer", __func__);
7257 return QDF_STATUS_E_NOMEM;
7258 }
7259
7260 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7261 cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr;
7262
7263 WMITLV_SET_HDR(&cmd->tlv_header,
7264 WMITLV_TAG_STRUC_wmi_get_chip_power_stats_cmd_fixed_param,
7265 WMITLV_GET_STRUCT_TLVLEN(
7266 wmi_pdev_get_chip_power_stats_cmd_fixed_param));
7267 cmd->pdev_id = 0;
7268
7269 WMA_LOGD("POWER_DEBUG_STATS - Get Request Params; Pdev id - %d",
7270 cmd->pdev_id);
7271 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7272 WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
7273 if (ret) {
7274 WMA_LOGE("%s: Failed to send power debug stats request",
7275 __func__);
7276 wmi_buf_free(buf);
7277 return QDF_STATUS_E_FAILURE;
7278 }
7279 return QDF_STATUS_SUCCESS;
7280}
7281#else
7282static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
7283{
7284 return QDF_STATUS_SUCCESS;
7285}
7286#endif
7287
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307288/**
7289 * wma_set_arp_req_stats() - process set arp stats request command to fw
7290 * @wma_handle: WMA handle
7291 * @req_buf: set srp stats request buffer
7292 *
7293 * Return: None
7294 */
7295static void wma_set_arp_req_stats(WMA_HANDLE handle,
7296 struct set_arp_stats_params *req_buf)
7297{
7298 int status;
7299 struct set_arp_stats *arp_stats;
7300 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7301
7302 if (!wma_handle || !wma_handle->wmi_handle) {
7303 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7304 __func__);
7305 return;
7306 }
Yeshwanth Sriram Guntukad5aae7f2017-11-27 14:33:51 +05307307 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7308 WMA_LOGE("vdev id not active or not valid");
7309 return;
7310 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307311
7312 arp_stats = (struct set_arp_stats *)req_buf;
7313 status = wmi_unified_set_arp_stats_req(wma_handle->wmi_handle,
7314 arp_stats);
7315 if (status != EOK)
7316 WMA_LOGE("%s: failed to set arp stats to FW",
7317 __func__);
7318}
7319
7320/**
7321 * wma_get_arp_req_stats() - process get arp stats request command to fw
7322 * @wma_handle: WMA handle
7323 * @req_buf: get srp stats request buffer
7324 *
7325 * Return: None
7326 */
7327static void wma_get_arp_req_stats(WMA_HANDLE handle,
7328 struct get_arp_stats_params *req_buf)
7329{
7330 int status;
7331 struct get_arp_stats *arp_stats;
7332 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7333
7334 if (!wma_handle || !wma_handle->wmi_handle) {
7335 WMA_LOGE("%s: WMA is closed, cannot send per roam config",
7336 __func__);
7337 return;
7338 }
Yeshwanth Sriram Guntuka3e4d96f2017-12-19 14:09:04 +05307339 if (!wma_is_vdev_valid(req_buf->vdev_id)) {
7340 WMA_LOGE("vdev id not active or not valid");
7341 return;
7342 }
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05307343
7344 arp_stats = (struct get_arp_stats *)req_buf;
7345 status = wmi_unified_get_arp_stats_req(wma_handle->wmi_handle,
7346 arp_stats);
7347 if (status != EOK)
7348 WMA_LOGE("%s: failed to send get arp stats to FW",
7349 __func__);
7350}
7351
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307352/**
7353 * wma_set_del_pmkid_cache() - API to set/delete PMKID cache entry in fw
7354 * @handle: WMA handle
7355 * @pmk_cache: PMK cache entry
7356 *
7357 * Return: None
7358 */
7359static void wma_set_del_pmkid_cache(WMA_HANDLE handle,
7360 struct wmi_unified_pmk_cache *pmk_cache)
7361{
7362 int status;
7363 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7364
7365 if (!wma_handle || !wma_handle->wmi_handle) {
7366 WMA_LOGE("WMA is closed, cannot send set del pmkid");
7367 return;
7368 }
7369
7370 status = wmi_unified_set_del_pmkid_cache(wma_handle->wmi_handle,
7371 pmk_cache);
7372 if (status != EOK)
7373 WMA_LOGE("failed to send set/del pmkid cmd to fw");
7374}
7375
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307376/**
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05307377 * wma_send_invoke_neighbor_report() - API to send invoke neighbor report
7378 * command to fw
7379 *
7380 * @handle: WMA handle
7381 * @params: Pointer to invoke neighbor report params
7382 *
7383 * Return: None
7384 */
7385static
7386void wma_send_invoke_neighbor_report(WMA_HANDLE handle,
7387 struct wmi_invoke_neighbor_report_params *params)
7388{
7389 QDF_STATUS status;
7390 tp_wma_handle wma_handle = (tp_wma_handle) handle;
7391
7392 if (!wma_handle || !wma_handle->wmi_handle) {
7393 WMA_LOGE("WMA is closed, cannot send invoke neighbor report");
7394 return;
7395 }
7396
7397 status = wmi_unified_invoke_neighbor_report_cmd(wma_handle->wmi_handle,
7398 params);
7399
7400 if (status != QDF_STATUS_SUCCESS)
7401 WMA_LOGE("failed to send invoke neighbor report command");
7402}
7403
lifeng66831662017-05-19 16:01:35 +08007404QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle,
7405 struct sir_set_rx_reorder_timeout_val *reorder_timeout)
7406{
7407 wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *cmd;
7408 uint32_t len;
7409 wmi_buf_t buf;
7410 int ret;
7411
7412 if (!reorder_timeout) {
7413 WMA_LOGE(FL("invalid pointer"));
7414 return QDF_STATUS_E_INVAL;
7415 }
7416
7417 if (!wma_handle) {
7418 WMA_LOGE(FL("WMA context is invald!"));
7419 return QDF_STATUS_E_INVAL;
7420 }
7421 len = sizeof(*cmd);
7422 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7423
7424 if (!buf) {
7425 WMA_LOGE(FL("Failed allocate wmi buffer"));
7426 return QDF_STATUS_E_NOMEM;
7427 }
7428 cmd = (wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *)
7429 wmi_buf_data(buf);
7430
7431 WMITLV_SET_HDR(&cmd->tlv_header,
7432 WMITLV_TAG_STRUC_wmi_pdev_set_reorder_timeout_val_cmd_fixed_param,
7433 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_reorder_timeout_val_cmd_fixed_param));
7434
7435 memcpy(cmd->rx_timeout_pri, reorder_timeout->rx_timeout_pri,
7436 sizeof(reorder_timeout->rx_timeout_pri));
7437
7438 WMA_LOGD("rx aggr record timeout: VO: %d, VI: %d, BE: %d, BK: %d",
7439 cmd->rx_timeout_pri[0], cmd->rx_timeout_pri[1],
7440 cmd->rx_timeout_pri[2], cmd->rx_timeout_pri[3]);
7441
7442 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7443 WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID);
7444 if (ret) {
7445 WMA_LOGE(FL("Failed to send aggregation timeout"));
7446 wmi_buf_free(buf);
7447 return QDF_STATUS_E_FAILURE;
7448 }
7449
7450 return QDF_STATUS_SUCCESS;
7451}
7452
7453QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle,
7454 struct sir_peer_set_rx_blocksize *peer_rx_blocksize)
7455{
7456 wmi_peer_set_rx_blocksize_cmd_fixed_param *cmd;
7457 int32_t len;
7458 wmi_buf_t buf;
7459 u_int8_t *buf_ptr;
7460 int ret;
7461
7462 if (!peer_rx_blocksize) {
7463 WMA_LOGE(FL("invalid pointer"));
7464 return QDF_STATUS_E_INVAL;
7465 }
7466
7467 if (!wma_handle) {
7468 WMA_LOGE(FL(" WMA context is invald!"));
7469 return QDF_STATUS_E_INVAL;
7470 }
7471
7472 len = sizeof(*cmd);
7473 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7474
7475 if (!buf) {
7476 WMA_LOGE(FL("Failed allocate wmi buffer"));
7477 return QDF_STATUS_E_NOMEM;
7478 }
7479
7480 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7481 cmd = (wmi_peer_set_rx_blocksize_cmd_fixed_param *) buf_ptr;
7482
7483 WMITLV_SET_HDR(&cmd->tlv_header,
7484 WMITLV_TAG_STRUC_wmi_peer_set_rx_blocksize_cmd_fixed_param,
7485 WMITLV_GET_STRUCT_TLVLEN(wmi_peer_set_rx_blocksize_cmd_fixed_param));
7486
7487 cmd->vdev_id = peer_rx_blocksize->vdev_id;
7488 cmd->rx_block_ack_win_limit =
7489 peer_rx_blocksize->rx_block_ack_win_limit;
7490 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_rx_blocksize->peer_macaddr.bytes,
7491 &cmd->peer_macaddr);
7492
7493 WMA_LOGD("rx aggr blocksize: %d", cmd->rx_block_ack_win_limit);
7494
7495 ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
7496 WMI_PEER_SET_RX_BLOCKSIZE_CMDID);
7497 if (ret) {
7498 WMA_LOGE(FL("Failed to send aggregation size command"));
7499 wmi_buf_free(buf);
7500 return QDF_STATUS_E_FAILURE;
7501 }
7502
7503 return QDF_STATUS_SUCCESS;
7504}
7505
lifengd217d192017-05-09 19:44:16 +08007506QDF_STATUS wma_get_chain_rssi(tp_wma_handle wma_handle,
7507 struct get_chain_rssi_req_params *req_params)
7508{
lifengfe6c3e22018-04-03 12:10:04 +08007509 wmi_pdev_div_get_rssi_antid_fixed_param *cmd;
lifengd217d192017-05-09 19:44:16 +08007510 wmi_buf_t wmi_buf;
lifengfe6c3e22018-04-03 12:10:04 +08007511 uint32_t len = sizeof(wmi_pdev_div_get_rssi_antid_fixed_param);
lifengd217d192017-05-09 19:44:16 +08007512 u_int8_t *buf_ptr;
7513
7514 if (!wma_handle) {
7515 WMA_LOGE(FL("WMA is closed, can not issue cmd"));
7516 return QDF_STATUS_E_INVAL;
7517 }
7518
7519 wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
7520 if (!wmi_buf) {
7521 WMA_LOGE(FL("wmi_buf_alloc failed"));
7522 return QDF_STATUS_E_NOMEM;
7523 }
7524
7525 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7526
lifengfe6c3e22018-04-03 12:10:04 +08007527 cmd = (wmi_pdev_div_get_rssi_antid_fixed_param *)buf_ptr;
lifengd217d192017-05-09 19:44:16 +08007528 WMITLV_SET_HDR(&cmd->tlv_header,
lifengfe6c3e22018-04-03 12:10:04 +08007529 WMITLV_TAG_STRUC_wmi_pdev_div_get_rssi_antid_fixed_param,
lifengd217d192017-05-09 19:44:16 +08007530 WMITLV_GET_STRUCT_TLVLEN(
lifengfe6c3e22018-04-03 12:10:04 +08007531 wmi_pdev_div_get_rssi_antid_fixed_param));
7532 cmd->pdev_id = 0;
lifengd217d192017-05-09 19:44:16 +08007533 WMI_CHAR_ARRAY_TO_MAC_ADDR(req_params->peer_macaddr.bytes,
lifengfe6c3e22018-04-03 12:10:04 +08007534 &cmd->macaddr);
lifengd217d192017-05-09 19:44:16 +08007535
7536 if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len,
lifengfe6c3e22018-04-03 12:10:04 +08007537 WMI_PDEV_DIV_GET_RSSI_ANTID_CMDID)) {
lifengd217d192017-05-09 19:44:16 +08007538 WMA_LOGE(FL("failed to send get chain rssi command"));
7539 wmi_buf_free(wmi_buf);
7540 return QDF_STATUS_E_FAILURE;
7541 }
7542
7543 return QDF_STATUS_SUCCESS;
7544}
7545
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307546#if defined(WLAN_FEATURE_FILS_SK)
7547/**
7548 * wma_roam_scan_send_hlp() - API to send HLP IE info to fw
7549 * @wma_handle: WMA handle
7550 * @req: HLP params
7551 *
7552 * Return: QDF_STATUS
7553 */
7554static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7555 struct hlp_params *req)
7556{
7557 struct hlp_params *params;
7558 QDF_STATUS status;
7559
7560 params = qdf_mem_malloc(sizeof(*params));
7561 if (!params) {
7562 WMA_LOGE("%s : Memory allocation failed", __func__);
7563 return QDF_STATUS_E_NOMEM;
7564 }
7565
7566 params->vdev_id = req->vdev_id;
7567 params->hlp_ie_len = req->hlp_ie_len;
7568 qdf_mem_copy(params->hlp_ie, req->hlp_ie, req->hlp_ie_len);
7569 status = wmi_unified_roam_send_hlp_cmd(wma_handle->wmi_handle, params);
7570
7571 WMA_LOGD("Send HLP status %d vdev id %d", status, params->vdev_id);
7572 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
7573 params->hlp_ie, 10);
7574
7575 qdf_mem_free(params);
7576 return status;
7577}
7578#else
7579static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle,
7580 struct hlp_params *req)
7581{
7582 return QDF_STATUS_SUCCESS;
7583}
7584#endif
7585
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05307586/**
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307587 * wma_process_set_limit_off_chan() - set limit off chanel parameters
7588 * @wma_handle: pointer to wma handle
7589 * @param: pointer to sir_limit_off_chan
7590 *
7591 * Return: QDF_STATUS_SUCCESS for success or error code.
7592 */
7593static QDF_STATUS wma_process_limit_off_chan(tp_wma_handle wma_handle,
7594 struct sir_limit_off_chan *param)
7595{
7596 int32_t err;
7597 struct wmi_limit_off_chan_param limit_off_chan_param;
7598
Rajeev Kumar752d64e2017-10-05 16:32:58 -07007599 if (param->vdev_id >= wma_handle->max_bssid) {
7600 WMA_LOGE(FL("Invalid vdev_id: %d"), param->vdev_id);
7601 return QDF_STATUS_E_INVAL;
7602 }
7603 if (!wma_is_vdev_up(param->vdev_id)) {
7604 WMA_LOGE("vdev %d is not up skipping limit_off_chan_param",
7605 param->vdev_id);
7606 return QDF_STATUS_E_INVAL;
7607 }
7608
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307609 limit_off_chan_param.vdev_id = param->vdev_id;
7610 limit_off_chan_param.status = param->is_tos_active;
7611 limit_off_chan_param.max_offchan_time = param->max_off_chan_time;
7612 limit_off_chan_param.rest_time = param->rest_time;
7613 limit_off_chan_param.skip_dfs_chans = param->skip_dfs_chans;
7614
7615 err = wmi_unified_send_limit_off_chan_cmd(wma_handle->wmi_handle,
7616 &limit_off_chan_param);
7617 if (err) {
7618 WMA_LOGE("\n failed to set limit off chan cmd");
7619 return QDF_STATUS_E_FAILURE;
7620 }
7621
7622 return QDF_STATUS_SUCCESS;
7623}
7624
Arif Hussain05fb4872018-01-03 16:02:55 -08007625static QDF_STATUS wma_process_obss_color_collision_req(tp_wma_handle wma_handle,
7626 struct wmi_obss_color_collision_cfg_param *cfg)
7627{
7628 QDF_STATUS status;
7629
7630 if (cfg->vdev_id >= wma_handle->max_bssid) {
7631 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7632 return QDF_STATUS_E_INVAL;
7633 }
7634 if (!wma_is_vdev_up(cfg->vdev_id)) {
7635 WMA_LOGE("vdev %d is not up skipping obss color collision req",
7636 cfg->vdev_id);
7637 return QDF_STATUS_E_INVAL;
7638 }
7639
7640 status = wmi_unified_send_obss_color_collision_cfg_cmd(wma_handle->
7641 wmi_handle, cfg);
7642 if (QDF_IS_STATUS_ERROR(status))
7643 WMA_LOGE("Failed to send obss color collision cfg");
7644
7645 return status;
7646}
7647
Ganesh Kondabattini35739572017-06-21 16:26:39 +05307648/**
Arif Hussainee10f902017-12-27 16:30:17 -08007649 * wma_send_obss_detection_cfg() - send obss detection cfg to firmware
7650 * @wma_handle: pointer to wma handle
7651 * @cfg: obss detection configuration
7652 *
7653 * Send obss detection configuration to firmware.
7654 *
7655 * Return: None
7656 */
7657static void wma_send_obss_detection_cfg(tp_wma_handle wma_handle,
7658 struct wmi_obss_detection_cfg_param
7659 *cfg)
7660{
7661 QDF_STATUS status;
7662
7663 if (cfg->vdev_id >= wma_handle->max_bssid) {
7664 WMA_LOGE(FL("Invalid vdev_id: %d"), cfg->vdev_id);
7665 return;
7666 }
7667 if (!wma_is_vdev_up(cfg->vdev_id)) {
7668 WMA_LOGE("vdev %d is not up skipping obss detection req",
7669 cfg->vdev_id);
7670 return;
7671 }
7672
7673 status = wmi_unified_send_obss_detection_cfg_cmd(wma_handle->wmi_handle,
7674 cfg);
7675 if (QDF_IS_STATUS_ERROR(status))
7676 WMA_LOGE("Failed to send obss detection cfg");
7677
7678 return;
7679}
7680
7681/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007682 * wma_mc_process_msg() - process wma messages and call appropriate function.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007683 * @msg: message
7684 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307685 * Return: QDF_SUCCESS for success otherwise failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007686 */
Jeff Johnson5be42ab2017-09-13 09:10:39 -07007687static QDF_STATUS wma_mc_process_msg(struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007688{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307689 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007690 tp_wma_handle wma_handle;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08007691 struct cdp_vdev *txrx_vdev_handle = NULL;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07007692
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007693 extern uint8_t *mac_trace_get_wma_msg_string(uint16_t wmaMsg);
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307694 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007696 if (NULL == msg) {
7697 WMA_LOGE("msg is NULL");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307698 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307699 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007700 goto end;
7701 }
7702
7703 WMA_LOGD("msg->type = %x %s", msg->type,
7704 mac_trace_get_wma_msg_string(msg->type));
7705
Anurag Chouhan6d760662016-02-20 16:05:43 +05307706 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007707
7708 if (NULL == wma_handle) {
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07007709 WMA_LOGE("%s: wma_handle is NULL", __func__);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307710 QDF_ASSERT(0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307711 qdf_mem_free(msg->bodyptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307712 qdf_status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007713 goto end;
7714 }
7715
7716 switch (msg->type) {
7717
7718 /* Message posted by wmi for all control path related
7719 * FW events to serialize through mc_thread.
7720 */
7721 case WMA_PROCESS_FW_EVENT:
7722 wma_process_fw_event(wma_handle,
7723 (wma_process_fw_event_params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307724 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007725 break;
7726
7727#ifdef FEATURE_WLAN_ESE
7728 case WMA_TSM_STATS_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007729 WMA_LOGD("McThread: WMA_TSM_STATS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007730 wma_process_tsm_stats_req(wma_handle, (void *)msg->bodyptr);
7731 break;
7732#endif /* FEATURE_WLAN_ESE */
7733 case WNI_CFG_DNLD_REQ:
Srinivas Girigowda86ecc012017-03-10 12:26:57 -08007734 WMA_LOGD("McThread: WNI_CFG_DNLD_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307735 qdf_status = wma_wni_cfg_dnld(wma_handle);
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007736 if (QDF_IS_STATUS_SUCCESS(qdf_status))
Jeff Johnsonf7ab8142017-09-13 09:04:23 -07007737 cds_wma_complete_cback();
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07007738 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007739 WMA_LOGD("config download failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007740 break;
7741 case WMA_ADD_STA_SELF_REQ:
7742 txrx_vdev_handle =
7743 wma_vdev_attach(wma_handle,
7744 (struct add_sta_self_params *) msg->
7745 bodyptr, 1);
7746 if (!txrx_vdev_handle) {
7747 WMA_LOGE("Failed to attach vdev");
7748 } else {
7749 /* Register with TxRx Module for Data Ack Complete Cb */
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05307750 if (soc) {
7751 cdp_data_tx_cb_set(soc, txrx_vdev_handle,
7752 wma_data_tx_ack_comp_hdlr,
7753 wma_handle);
7754 } else {
7755 WMA_LOGE("%s: SOC context is NULL", __func__);
7756 qdf_status = QDF_STATUS_E_FAILURE;
7757 goto end;
7758 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007759 }
7760 break;
7761 case WMA_DEL_STA_SELF_REQ:
7762 wma_vdev_detach(wma_handle,
7763 (struct del_sta_self_params *) msg->bodyptr, 1);
7764 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007765 case WMA_UPDATE_CHAN_LIST_REQ:
7766 wma_update_channel_list(wma_handle,
7767 (tSirUpdateChanList *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307768 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007769 break;
7770 case WMA_SET_LINK_STATE:
7771 wma_set_linkstate(wma_handle, (tpLinkStateParams) msg->bodyptr);
7772 break;
7773 case WMA_CHNL_SWITCH_REQ:
7774 wma_set_channel(wma_handle,
7775 (tpSwitchChannelParams) msg->bodyptr);
7776 break;
7777 case WMA_ADD_BSS_REQ:
7778 wma_add_bss(wma_handle, (tpAddBssParams) msg->bodyptr);
7779 break;
7780 case WMA_ADD_STA_REQ:
7781 wma_add_sta(wma_handle, (tpAddStaParams) msg->bodyptr);
7782 break;
7783 case WMA_SET_BSSKEY_REQ:
7784 wma_set_bsskey(wma_handle, (tpSetBssKeyParams) msg->bodyptr);
7785 break;
7786 case WMA_SET_STAKEY_REQ:
7787 wma_set_stakey(wma_handle, (tpSetStaKeyParams) msg->bodyptr);
7788 break;
7789 case WMA_DELETE_STA_REQ:
7790 wma_delete_sta(wma_handle, (tpDeleteStaParams) msg->bodyptr);
7791 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07007792 case WMA_DELETE_BSS_HO_FAIL_REQ:
7793 wma_delete_bss_ho_fail(wma_handle,
7794 (tpDeleteBssParams) msg->bodyptr);
7795 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007796 case WMA_DELETE_BSS_REQ:
7797 wma_delete_bss(wma_handle, (tpDeleteBssParams) msg->bodyptr);
7798 break;
7799 case WMA_UPDATE_EDCA_PROFILE_IND:
7800 wma_process_update_edca_param_req(wma_handle,
7801 (tEdcaParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307802 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007803 break;
7804 case WMA_SEND_BEACON_REQ:
7805 wma_send_beacon(wma_handle, (tpSendbeaconParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307806 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007807 break;
7808 case WMA_SEND_PROBE_RSP_TMPL:
7809 wma_send_probe_rsp_tmpl(wma_handle,
7810 (tpSendProbeRespParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307811 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007812 break;
7813 case WMA_CLI_SET_CMD:
7814 wma_process_cli_set_cmd(wma_handle,
7815 (wma_cli_set_cmd_t *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307816 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007817 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07007818 case WMA_SET_PDEV_IE_REQ:
7819 wma_process_set_pdev_ie_req(wma_handle,
7820 (struct set_ie_param *)msg->bodyptr);
7821 qdf_mem_free(msg->bodyptr);
7822 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007823#if !defined(REMOVE_PKT_LOG)
7824 case WMA_PKTLOG_ENABLE_REQ:
7825 wma_pktlog_wmi_send_cmd(wma_handle,
7826 (struct ath_pktlog_wmi_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307827 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007828 break;
7829#endif /* REMOVE_PKT_LOG */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007830 case WMA_ENTER_PS_REQ:
7831 wma_enable_sta_ps_mode(wma_handle,
7832 (tpEnablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307833 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007834 break;
7835 case WMA_EXIT_PS_REQ:
7836 wma_disable_sta_ps_mode(wma_handle,
7837 (tpDisablePsParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307838 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007839 break;
7840 case WMA_ENABLE_UAPSD_REQ:
7841 wma_enable_uapsd_mode(wma_handle,
7842 (tpEnableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307843 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007844 break;
7845 case WMA_DISABLE_UAPSD_REQ:
7846 wma_disable_uapsd_mode(wma_handle,
7847 (tpDisableUapsdParams) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307848 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007849 break;
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08007850 case WMA_SET_DTIM_PERIOD:
7851 wma_set_dtim_period(wma_handle,
7852 (struct set_dtim_params *)msg->bodyptr);
7853 qdf_mem_free(msg->bodyptr);
7854 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007855 case WMA_SET_TX_POWER_REQ:
7856 wma_set_tx_power(wma_handle, (tpMaxTxPowerParams) msg->bodyptr);
7857 break;
7858 case WMA_SET_MAX_TX_POWER_REQ:
7859 wma_set_max_tx_power(wma_handle,
7860 (tpMaxTxPowerParams) msg->bodyptr);
7861 break;
7862 case WMA_SET_KEEP_ALIVE:
7863 wma_set_keepalive_req(wma_handle,
7864 (tSirKeepAliveReq *) msg->bodyptr);
7865 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08007866#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007867 case WMA_SET_PLM_REQ:
7868 wma_config_plm(wma_handle, (tpSirPlmReq) msg->bodyptr);
7869 break;
7870#endif
7871 case WMA_GET_STATISTICS_REQ:
7872 wma_get_stats_req(wma_handle,
7873 (tAniGetPEStatsReq *) msg->bodyptr);
7874 break;
7875
7876 case WMA_CONFIG_PARAM_UPDATE_REQ:
Rajeev Kumar156188e2017-01-21 17:23:52 -08007877 wma_update_cfg_params(wma_handle, msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007878 break;
7879
7880 case WMA_UPDATE_OP_MODE:
7881 wma_process_update_opmode(wma_handle,
7882 (tUpdateVHTOpMode *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307883 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007884 break;
7885 case WMA_UPDATE_RX_NSS:
7886 wma_process_update_rx_nss(wma_handle,
7887 (tUpdateRxNss *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307888 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007889 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007890 case WMA_UPDATE_MEMBERSHIP:
7891 wma_process_update_membership(wma_handle,
7892 (tUpdateMembership *) msg->bodyptr);
7893 break;
7894 case WMA_UPDATE_USERPOS:
7895 wma_process_update_userpos(wma_handle,
7896 (tUpdateUserPos *) msg->bodyptr);
7897 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007898 case WMA_UPDATE_BEACON_IND:
7899 wma_process_update_beacon_params(wma_handle,
7900 (tUpdateBeaconParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307901 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007902 break;
7903
7904 case WMA_ADD_TS_REQ:
7905 wma_add_ts_req(wma_handle, (tAddTsParams *) msg->bodyptr);
7906 break;
7907
7908 case WMA_DEL_TS_REQ:
7909 wma_del_ts_req(wma_handle, (tDelTsParams *) msg->bodyptr);
7910 break;
7911
7912 case WMA_AGGR_QOS_REQ:
7913 wma_aggr_qos_req(wma_handle, (tAggrAddTsParams *) msg->bodyptr);
7914 break;
7915
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007916 case WMA_8023_MULTICAST_LIST_REQ:
7917 wma_process_mcbc_set_filter_req(wma_handle,
7918 (tpSirRcvFltMcAddrList) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307919 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007920 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007921 case WMA_ROAM_SCAN_OFFLOAD_REQ:
7922 /*
7923 * Main entry point or roaming directives from CSR.
7924 */
Varun Reddy Yeturu30bc42c2016-02-04 10:07:30 -08007925 wma_process_roaming_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007926 (tSirRoamOffloadScanReq *) msg->bodyptr);
7927 break;
7928
7929 case WMA_RATE_UPDATE_IND:
7930 wma_process_rate_update_indicate(wma_handle,
7931 (tSirRateUpdateInd *) msg->bodyptr);
7932 break;
7933
7934#ifdef FEATURE_WLAN_TDLS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007935 case WMA_UPDATE_TDLS_PEER_STATE:
7936 wma_update_tdls_peer_state(wma_handle,
7937 (tTdlsPeerStateParams *) msg->bodyptr);
7938 break;
7939 case WMA_TDLS_SET_OFFCHAN_MODE:
7940 wma_set_tdls_offchan_mode(wma_handle,
7941 (tdls_chan_switch_params *)msg->bodyptr);
7942 break;
7943#endif /* FEATURE_WLAN_TDLS */
7944 case WMA_ADD_PERIODIC_TX_PTRN_IND:
7945 wma_process_add_periodic_tx_ptrn_ind(wma_handle,
7946 (tSirAddPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307947 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007948 break;
7949 case WMA_DEL_PERIODIC_TX_PTRN_IND:
7950 wma_process_del_periodic_tx_ptrn_ind(wma_handle,
7951 (tSirDelPeriodicTxPtrn *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307952 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007953 break;
7954 case WMA_TX_POWER_LIMIT:
7955 wma_process_tx_power_limits(wma_handle,
7956 (tSirTxPowerLimit *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307957 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007958 break;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08007959 case WMA_SEND_ADDBA_REQ:
7960 wma_process_send_addba_req(wma_handle,
7961 (struct send_add_ba_req *)msg->bodyptr);
7962 break;
7963
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007964#ifdef FEATURE_WLAN_CH_AVOID
7965 case WMA_CH_AVOID_UPDATE_REQ:
7966 wma_process_ch_avoid_update_req(wma_handle,
7967 (tSirChAvoidUpdateReq *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307968 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007969 break;
7970#endif /* FEATURE_WLAN_CH_AVOID */
7971#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
7972 case WMA_SET_AUTO_SHUTDOWN_TIMER_REQ:
7973 wma_set_auto_shutdown_timer_req(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307974 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007975 break;
7976#endif /* FEATURE_WLAN_AUTO_SHUTDOWN */
7977 case WMA_DHCP_START_IND:
7978 case WMA_DHCP_STOP_IND:
7979 wma_process_dhcp_ind(wma_handle, (tAniDHCPInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307980 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007981 break;
7982
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007983 case WMA_IBSS_CESIUM_ENABLE_IND:
7984 wma_process_cesium_enable_ind(wma_handle);
7985 break;
7986 case WMA_GET_IBSS_PEER_INFO_REQ:
7987 wma_process_get_peer_info_req(wma_handle,
7988 (tSirIbssGetPeerInfoReqParams *)
7989 msg->bodyptr);
7990 qdf_mem_free(msg->bodyptr);
7991 break;
7992 case WMA_TX_FAIL_MONITOR_IND:
7993 wma_process_tx_fail_monitor_ind(wma_handle,
7994 (tAniTXFailMonitorInd *) msg->bodyptr);
7995 qdf_mem_free(msg->bodyptr);
7996 break;
7997
7998 case WMA_RMC_ENABLE_IND:
7999 wma_process_rmc_enable_ind(wma_handle);
8000 break;
8001 case WMA_RMC_DISABLE_IND:
8002 wma_process_rmc_disable_ind(wma_handle);
8003 break;
8004 case WMA_RMC_ACTION_PERIOD_IND:
8005 wma_process_rmc_action_period_ind(wma_handle);
8006 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008007 case WMA_INIT_THERMAL_INFO_CMD:
8008 wma_process_init_thermal_info(wma_handle,
8009 (t_thermal_mgmt *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308010 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008011 break;
8012
8013 case WMA_SET_THERMAL_LEVEL:
8014 wma_process_set_thermal_level(wma_handle, msg->bodyval);
8015 break;
Poddar, Siddarth5a91f5b2016-04-28 12:24:10 +05308016#ifdef CONFIG_HL_SUPPORT
8017 case WMA_INIT_BAD_PEER_TX_CTL_INFO_CMD:
8018 wma_process_init_bad_peer_tx_ctl_info(
8019 wma_handle,
8020 (struct t_bad_peer_txtcl_config *)msg->bodyptr);
8021 qdf_mem_free(msg->bodyptr);
8022 break;
8023#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008024 case WMA_SET_MIMOPS_REQ:
8025 wma_process_set_mimops_req(wma_handle,
8026 (tSetMIMOPS *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308027 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008028 break;
8029 case WMA_SET_SAP_INTRABSS_DIS:
8030 wma_set_vdev_intrabss_fwd(wma_handle,
8031 (tDisableIntraBssFwd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308032 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008033 break;
Will Huanga9814592017-05-24 15:47:58 +08008034 case WMA_GET_PEER_INFO:
8035 wma_get_peer_info(wma_handle, msg->bodyptr);
8036 qdf_mem_free(msg->bodyptr);
8037 break;
8038 case WMA_GET_PEER_INFO_EXT:
8039 wma_get_peer_info_ext(wma_handle, msg->bodyptr);
8040 qdf_mem_free(msg->bodyptr);
8041 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008042 case WMA_MODEM_POWER_STATE_IND:
8043 wma_notify_modem_power_state(wma_handle,
8044 (tSirModemPowerStateInd *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308045 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008046 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008047#ifdef WLAN_FEATURE_STATS_EXT
8048 case WMA_STATS_EXT_REQUEST:
8049 wma_stats_ext_req(wma_handle,
8050 (tpStatsExtRequest) (msg->bodyptr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308051 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008052 break;
8053#endif /* WLAN_FEATURE_STATS_EXT */
8054 case WMA_HIDDEN_SSID_VDEV_RESTART:
8055 wma_hidden_ssid_vdev_restart(wma_handle,
8056 (tHalHiddenSsidVdevRestart *) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008057 break;
8058#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
8059 case WMA_WLAN_EXT_WOW:
8060 wma_enable_ext_wow(wma_handle,
8061 (tSirExtWoWParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308062 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008063 break;
8064 case WMA_WLAN_SET_APP_TYPE1_PARAMS:
8065 wma_set_app_type1_params_in_fw(wma_handle,
8066 (tSirAppType1Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308067 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008068 break;
8069 case WMA_WLAN_SET_APP_TYPE2_PARAMS:
8070 wma_set_app_type2_params_in_fw(wma_handle,
8071 (tSirAppType2Params *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308072 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008073 break;
8074#endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
8075#ifdef FEATURE_WLAN_EXTSCAN
8076 case WMA_EXTSCAN_START_REQ:
8077 wma_start_extscan(wma_handle,
8078 (tSirWifiScanCmdReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308079 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008080 break;
8081 case WMA_EXTSCAN_STOP_REQ:
8082 wma_stop_extscan(wma_handle,
8083 (tSirExtScanStopReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308084 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008085 break;
8086 case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:
8087 wma_extscan_start_hotlist_monitor(wma_handle,
8088 (tSirExtScanSetBssidHotListReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308089 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008090 break;
8091 case WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ:
8092 wma_extscan_stop_hotlist_monitor(wma_handle,
8093 (tSirExtScanResetBssidHotlistReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308094 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008095 break;
8096 case WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ:
8097 wma_extscan_start_change_monitor(wma_handle,
8098 (tSirExtScanSetSigChangeReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308099 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008100 break;
8101 case WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ:
8102 wma_extscan_stop_change_monitor(wma_handle,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008103 (tSirExtScanResetSignificantChangeReqParams *)
8104 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308105 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008106 break;
8107 case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
8108 wma_extscan_get_cached_results(wma_handle,
8109 (tSirExtScanGetCachedResultsReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308110 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111 break;
8112 case WMA_EXTSCAN_GET_CAPABILITIES_REQ:
8113 wma_extscan_get_capabilities(wma_handle,
8114 (tSirGetExtScanCapabilitiesReqParams *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308115 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008116 break;
8117 case WMA_SET_EPNO_LIST_REQ:
8118 wma_set_epno_network_list(wma_handle,
8119 (struct wifi_epno_params *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308120 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008121 break;
Kapil Gupta5cda2252016-12-29 18:44:26 +05308122 case WMA_SET_PER_ROAM_CONFIG_CMD:
8123 wma_update_per_roam_config(wma_handle,
8124 (struct wmi_per_roam_config_req *)msg->bodyptr);
8125 qdf_mem_free(msg->bodyptr);
8126 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008127 case WMA_SET_PASSPOINT_LIST_REQ:
8128 /* Issue reset passpoint network list first and clear
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008129 * the entries
8130 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008131 wma_reset_passpoint_network_list(wma_handle,
8132 (struct wifi_passpoint_req *)msg->bodyptr);
8133
8134 wma_set_passpoint_network_list(wma_handle,
8135 (struct wifi_passpoint_req *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308136 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008137 break;
8138 case WMA_RESET_PASSPOINT_LIST_REQ:
8139 wma_reset_passpoint_network_list(wma_handle,
8140 (struct wifi_passpoint_req *)msg->bodyptr);
8141 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008142#endif /* FEATURE_WLAN_EXTSCAN */
8143 case WMA_SET_SCAN_MAC_OUI_REQ:
8144 wma_scan_probe_setoui(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308145 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008146 break;
8147#ifdef WLAN_FEATURE_LINK_LAYER_STATS
8148 case WMA_LINK_LAYER_STATS_CLEAR_REQ:
8149 wma_process_ll_stats_clear_req(wma_handle,
8150 (tpSirLLStatsClearReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308151 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008152 break;
8153 case WMA_LINK_LAYER_STATS_SET_REQ:
8154 wma_process_ll_stats_set_req(wma_handle,
8155 (tpSirLLStatsSetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308156 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008157 break;
8158 case WMA_LINK_LAYER_STATS_GET_REQ:
8159 wma_process_ll_stats_get_req(wma_handle,
8160 (tpSirLLStatsGetReq) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308161 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008162 break;
Zhang Qian73c348a2017-03-13 16:15:55 +08008163 case WDA_LINK_LAYER_STATS_SET_THRESHOLD:
8164 wma_config_stats_ext_threshold(wma_handle,
8165 (struct sir_ll_ext_stats_threshold *)msg->bodyptr);
8166 qdf_mem_free(msg->bodyptr);
8167 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008168#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008169#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008170 case WMA_ROAM_OFFLOAD_SYNCH_FAIL:
8171 wma_process_roam_synch_fail(wma_handle,
8172 (struct roam_offload_synch_fail *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308173 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008174 break;
8175 case SIR_HAL_ROAM_INVOKE:
8176 wma_process_roam_invoke(wma_handle,
8177 (struct wma_roam_invoke_cmd *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308178 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008179 break;
8180#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
8181#ifdef WLAN_FEATURE_NAN
8182 case WMA_NAN_REQUEST:
8183 wma_nan_req(wma_handle, (tNanRequest *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308184 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008185 break;
8186#endif /* WLAN_FEATURE_NAN */
8187 case SIR_HAL_SET_BASE_MACADDR_IND:
8188 wma_set_base_macaddr_indicate(wma_handle,
8189 (tSirMacAddr *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308190 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008191 break;
8192 case WMA_LINK_STATUS_GET_REQ:
8193 wma_process_link_status_req(wma_handle,
8194 (tAniGetLinkStatus *) msg->bodyptr);
8195 break;
8196 case WMA_GET_TEMPERATURE_REQ:
8197 wma_get_temperature(wma_handle);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308198 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008199 break;
Manikandan Mohan976e7562016-03-15 16:33:31 -07008200 case WMA_TSF_GPIO_PIN:
8201 wma_set_tsf_gpio_pin(wma_handle, msg->bodyval);
8202 break;
8203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008204#ifdef DHCP_SERVER_OFFLOAD
8205 case WMA_SET_DHCP_SERVER_OFFLOAD_CMD:
8206 wma_process_dhcpserver_offload(wma_handle,
8207 (tSirDhcpSrvOffloadInfo *) msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308208 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008209 break;
8210#endif /* DHCP_SERVER_OFFLOAD */
8211#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8212 case WMA_LED_FLASHING_REQ:
Jeff Johnson5a6b6602017-10-04 14:44:30 -07008213 wma_set_led_flashing(wma_handle, msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308214 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008215 break;
8216#endif /* WLAN_FEATURE_GPIO_LED_FLASHING */
8217 case SIR_HAL_SET_MAS:
8218 wma_process_set_mas(wma_handle,
8219 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308220 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008221 break;
8222 case SIR_HAL_SET_MIRACAST:
8223 wma_process_set_miracast(wma_handle,
8224 (uint32_t *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308225 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008226 break;
8227 case SIR_HAL_CONFIG_STATS_FACTOR:
8228 wma_config_stats_factor(wma_handle,
8229 (struct sir_stats_avg_factor *)
8230 msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308231 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008232 break;
8233 case SIR_HAL_CONFIG_GUARD_TIME:
8234 wma_config_guard_time(wma_handle,
8235 (struct sir_guard_time_request *)
8236 msg->bodyptr);
Vignesh Viswanathan9fa8fef2017-12-12 14:45:38 +05308237 qdf_mem_free(msg->bodyptr);
8238 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008239 case SIR_HAL_START_STOP_LOGGING:
8240 wma_set_wifi_start_packet_stats(wma_handle,
8241 (struct sir_wifi_start_log *)msg->bodyptr);
8242 wma_enable_specific_fw_logs(wma_handle,
8243 (struct sir_wifi_start_log *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308244 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008245 break;
8246 case SIR_HAL_FLUSH_LOG_TO_FW:
8247 wma_send_flush_logs_to_fw(wma_handle);
8248 /* Body ptr is NULL here */
8249 break;
8250 case WMA_SET_RSSI_MONITOR_REQ:
8251 wma_set_rssi_monitoring(wma_handle,
8252 (struct rssi_monitor_req *)msg->bodyptr);
Prakash Dhavali87ddca32016-11-29 17:02:11 -08008253 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008254 break;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308255 case SIR_HAL_PDEV_SET_PCL_TO_FW:
8256 wma_send_pdev_set_pcl_cmd(wma_handle,
8257 (struct wmi_pcl_chan_weights *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308258 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008259 break;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308260 case SIR_HAL_PDEV_SET_HW_MODE:
8261 wma_send_pdev_set_hw_mode_cmd(wma_handle,
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008262 (struct policy_mgr_hw_mode *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308263 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008264 break;
8265 case WMA_OCB_SET_CONFIG_CMD:
8266 wma_ocb_set_config_req(wma_handle,
8267 (struct sir_ocb_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308268 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008269 break;
8270 case WMA_OCB_SET_UTC_TIME_CMD:
8271 wma_ocb_set_utc_time(wma_handle,
8272 (struct sir_ocb_utc *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308273 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008274 break;
8275 case WMA_OCB_START_TIMING_ADVERT_CMD:
8276 wma_ocb_start_timing_advert(wma_handle,
8277 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308278 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008279 break;
8280 case WMA_OCB_STOP_TIMING_ADVERT_CMD:
8281 wma_ocb_stop_timing_advert(wma_handle,
8282 (struct sir_ocb_timing_advert *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308283 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008284 break;
8285 case WMA_DCC_CLEAR_STATS_CMD:
8286 wma_dcc_clear_stats(wma_handle,
8287 (struct sir_dcc_clear_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308288 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008289 break;
8290 case WMA_OCB_GET_TSF_TIMER_CMD:
8291 wma_ocb_get_tsf_timer(wma_handle,
8292 (struct sir_ocb_get_tsf_timer *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308293 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008294 break;
Manikandan Mohan80dea792016-04-28 16:36:48 -07008295 case WMA_SET_WISA_PARAMS:
8296 wma_set_wisa_params(wma_handle,
8297 (struct sir_wisa_params *)msg->bodyptr);
8298 qdf_mem_free(msg->bodyptr);
8299 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008300 case WMA_DCC_GET_STATS_CMD:
8301 wma_dcc_get_stats(wma_handle,
8302 (struct sir_dcc_get_stats *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308303 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008304 break;
8305 case WMA_DCC_UPDATE_NDL_CMD:
8306 wma_dcc_update_ndl(wma_handle,
8307 (struct sir_dcc_update_ndl *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308308 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008309 break;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308310 case SIR_HAL_PDEV_DUAL_MAC_CFG_REQ:
8311 wma_send_pdev_set_dual_mac_config(wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008312 (struct sir_dual_mac_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308313 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008314 break;
8315 case WMA_SET_IE_INFO:
8316 wma_process_set_ie_info(wma_handle,
8317 (struct vdev_ie_info *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308318 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008319 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008320 case SIR_HAL_SOC_ANTENNA_MODE_REQ:
8321 wma_send_pdev_set_antenna_mode(wma_handle,
8322 (struct sir_antenna_mode_param *)msg->bodyptr);
8323 qdf_mem_free(msg->bodyptr);
8324 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008325 case WMA_LRO_CONFIG_CMD:
8326 wma_lro_config_cmd(wma_handle,
Dhanashri Atre09828f12016-11-13 10:36:58 -08008327 (struct cdp_lro_hash_config *)msg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308328 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008329 break;
Ravi Joshi9e891ba2015-11-09 19:03:46 -08008330 case WMA_GW_PARAM_UPDATE_REQ:
8331 wma_set_gateway_params(wma_handle,
8332 (struct gateway_param_update_req *)msg->bodyptr);
Archana Ramachandran28ab4122016-03-08 16:17:14 -08008333 qdf_mem_free(msg->bodyptr);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -08008334 break;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05308335 case WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS:
8336 wma_send_adapt_dwelltime_params(wma_handle,
8337 (struct adaptive_dwelltime_params *)msg->bodyptr);
8338 qdf_mem_free(msg->bodyptr);
8339 break;
Sandeep Puligillae0875662016-02-12 16:09:21 -08008340 case WMA_HT40_OBSS_SCAN_IND:
8341 wma_send_ht40_obss_scanind(wma_handle,
8342 (struct obss_ht40_scanind *)msg->bodyptr);
8343 qdf_mem_free(msg->bodyptr);
8344 break;
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07008345 case WMA_ADD_BCN_FILTER_CMDID:
8346 wma_add_beacon_filter(wma_handle, msg->bodyptr);
8347 qdf_mem_free(msg->bodyptr);
8348 break;
8349 case WMA_REMOVE_BCN_FILTER_CMDID:
8350 wma_remove_beacon_filter(wma_handle, msg->bodyptr);
8351 qdf_mem_free(msg->bodyptr);
8352 break;
Arun Khandavalli2476ef52016-04-26 20:19:43 +05308353 case WDA_BPF_GET_CAPABILITIES_REQ:
8354 wma_get_bpf_capabilities(wma_handle);
8355 break;
8356 case WDA_BPF_SET_INSTRUCTIONS_REQ:
8357 wma_set_bpf_instructions(wma_handle, msg->bodyptr);
8358 qdf_mem_free(msg->bodyptr);
8359 break;
Manjeet Singhf82ed072016-07-08 11:40:00 +05308360 case SIR_HAL_POWER_DBG_CMD:
8361 wma_process_hal_pwr_dbg_cmd(wma_handle,
8362 msg->bodyptr);
8363 qdf_mem_free(msg->bodyptr);
8364 break;
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05308365 case WMA_UPDATE_WEP_DEFAULT_KEY:
8366 wma_update_wep_default_key(wma_handle,
8367 (struct wep_update_default_key_idx *)msg->bodyptr);
8368 qdf_mem_free(msg->bodyptr);
8369 break;
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +05308370 case WMA_SEND_FREQ_RANGE_CONTROL_IND:
8371 wma_enable_disable_caevent_ind(wma_handle, msg->bodyval);
8372 break;
Agrawal, Ashish35b251d2016-09-08 19:21:03 +05308373 case SIR_HAL_UPDATE_TX_FAIL_CNT_TH:
8374 wma_update_tx_fail_cnt_th(wma_handle, msg->bodyptr);
8375 qdf_mem_free(msg->bodyptr);
8376 break;
Agrawal Ashishda3e9502016-09-21 17:43:51 +05308377 case SIR_HAL_LONG_RETRY_LIMIT_CNT:
8378 wma_update_long_retry_limit(wma_handle, msg->bodyptr);
8379 qdf_mem_free(msg->bodyptr);
8380 break;
8381 case SIR_HAL_SHORT_RETRY_LIMIT_CNT:
8382 wma_update_short_retry_limit(wma_handle, msg->bodyptr);
8383 qdf_mem_free(msg->bodyptr);
8384 break;
Sridhar Selvarajdc400d22016-10-18 17:18:03 +05308385 case SIR_HAL_POWER_DEBUG_STATS_REQ:
8386 wma_process_power_debug_stats_req(wma_handle);
8387 break;
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +05308388 case WMA_GET_RCPI_REQ:
8389 wma_get_rcpi_req(wma_handle,
8390 (struct sme_rcpi_req *)msg->bodyptr);
8391 qdf_mem_free(msg->bodyptr);
8392 break;
Yingying Tang95409972016-10-20 15:16:15 +08008393 case WMA_SET_WOW_PULSE_CMD:
8394 wma_send_wow_pulse_cmd(wma_handle,
8395 (struct wow_pulse_mode *)msg->bodyptr);
8396 qdf_mem_free(msg->bodyptr);
8397 break;
Nitesh Shahf9a09ff2017-05-22 15:46:25 +05308398 case WMA_SET_DBS_SCAN_SEL_CONF_PARAMS:
8399 wma_send_dbs_scan_selection_params(wma_handle,
8400 (struct wmi_dbs_scan_sel_params *)msg->bodyptr);
8401 qdf_mem_free(msg->bodyptr);
8402 break;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +05308403 case WMA_SET_ARP_STATS_REQ:
8404 wma_set_arp_req_stats(wma_handle,
8405 (struct set_arp_stats_params *)msg->bodyptr);
8406 qdf_mem_free(msg->bodyptr);
8407 break;
8408 case WMA_GET_ARP_STATS_REQ:
8409 wma_get_arp_req_stats(wma_handle,
8410 (struct get_arp_stats_params *)msg->bodyptr);
8411 qdf_mem_free(msg->bodyptr);
8412 break;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308413 case SIR_HAL_SET_DEL_PMKID_CACHE:
8414 wma_set_del_pmkid_cache(wma_handle,
8415 (struct wmi_unified_pmk_cache *) msg->bodyptr);
8416 qdf_mem_free(msg->bodyptr);
8417 break;
8418 case SIR_HAL_HLP_IE_INFO:
8419 wma_roam_scan_send_hlp(wma_handle,
8420 (struct hlp_params *)msg->bodyptr);
8421 qdf_mem_free(msg->bodyptr);
8422 break;
Ganesh Kondabattini35739572017-06-21 16:26:39 +05308423 case WMA_SET_LIMIT_OFF_CHAN:
8424 wma_process_limit_off_chan(wma_handle, msg->bodyptr);
8425 qdf_mem_free(msg->bodyptr);
8426 break;
Arif Hussainee10f902017-12-27 16:30:17 -08008427 case WMA_OBSS_DETECTION_REQ:
8428 wma_send_obss_detection_cfg(wma_handle, msg->bodyptr);
8429 qdf_mem_free(msg->bodyptr);
8430 break;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05308431 case WMA_INVOKE_NEIGHBOR_REPORT:
8432 wma_send_invoke_neighbor_report(wma_handle, msg->bodyptr);
8433 qdf_mem_free(msg->bodyptr);
8434 break;
Arif Hussain05fb4872018-01-03 16:02:55 -08008435 case WMA_OBSS_COLOR_COLLISION_REQ:
8436 wma_process_obss_color_collision_req(wma_handle, msg->bodyptr);
8437 qdf_mem_free(msg->bodyptr);
8438 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008439 default:
Dustin Brown86534fb2017-01-24 14:28:20 -08008440 WMA_LOGE("Unhandled WMA message of type %d", msg->type);
8441 if (msg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308442 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008443 }
8444end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308445 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446}
8447
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008448QDF_STATUS wma_mc_process_handler(struct scheduler_msg *msg)
8449{
Jeff Johnson5be42ab2017-09-13 09:10:39 -07008450 return wma_mc_process_msg(msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008451}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07008452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008453/**
8454 * wma_log_completion_timeout() - Log completion timeout
8455 * @data: Timeout handler data
8456 *
8457 * This function is called when log completion timer expires
8458 *
8459 * Return: None
8460 */
8461void wma_log_completion_timeout(void *data)
8462{
8463 tp_wma_handle wma_handle;
8464
8465 WMA_LOGE("%s: Timeout occured for log completion command", __func__);
8466
8467 wma_handle = (tp_wma_handle) data;
8468 if (!wma_handle)
8469 WMA_LOGE("%s: Invalid WMA handle", __func__);
8470
8471 /* Though we did not receive any event from FW,
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008472 * we can flush whatever logs we have with us
8473 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008474 cds_logging_set_fw_flush_complete();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008475}
8476
8477/**
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308478 * wma_map_pcl_weights() - Map PCL weights
8479 * @pcl_weight: Internal PCL weights
8480 *
8481 * Maps the internal weights of PCL to the weights needed by FW
8482 *
8483 * Return: Mapped channel weight of type wmi_pcl_chan_weight
8484 */
8485static wmi_pcl_chan_weight wma_map_pcl_weights(uint32_t pcl_weight)
8486{
8487 switch (pcl_weight) {
8488 case WEIGHT_OF_GROUP1_PCL_CHANNELS:
8489 return WMI_PCL_WEIGHT_VERY_HIGH;
8490 case WEIGHT_OF_GROUP2_PCL_CHANNELS:
8491 return WMI_PCL_WEIGHT_HIGH;
8492 case WEIGHT_OF_GROUP3_PCL_CHANNELS:
8493 return WMI_PCL_WEIGHT_MEDIUM;
8494 case WEIGHT_OF_NON_PCL_CHANNELS:
8495 return WMI_PCL_WEIGHT_LOW;
8496 default:
8497 return WMI_PCL_WEIGHT_DISALLOW;
8498 }
8499}
8500
8501/**
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308502 * wma_send_pdev_set_pcl_cmd() - Send WMI_SOC_SET_PCL_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008503 * @wma_handle: WMA handle
8504 * @msg: PCL structure containing the PCL and the number of channels
8505 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308506 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008507 * firmware. The DBS Manager is the consumer of this information in the WLAN
8508 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
8509 * to migrate to a new channel without host driver involvement. An example of
8510 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
8511 * manage the channel selection without firmware involvement.
8512 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308513 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
8514 * channel list. The weights corresponds to the channels sent in
8515 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
8516 * weightage compared to the non PCL channels.
8517 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008518 * Return: Success if the cmd is sent successfully to the firmware
8519 */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308520QDF_STATUS wma_send_pdev_set_pcl_cmd(tp_wma_handle wma_handle,
8521 struct wmi_pcl_chan_weights *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008522{
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308523 uint32_t i;
8524 QDF_STATUS status;
8525
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008526 if (!wma_handle) {
8527 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8528 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308529 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008530 }
8531
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308532 for (i = 0; i < wma_handle->saved_chan.num_channels; i++) {
8533 msg->saved_chan_list[i] =
8534 wma_handle->saved_chan.channel_list[i];
8535 }
8536
8537 msg->saved_num_chan = wma_handle->saved_chan.num_channels;
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008538 status = policy_mgr_get_valid_chan_weights(wma_handle->psoc,
8539 (struct policy_mgr_pcl_chan_weights *)msg);
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308540
8541 for (i = 0; i < msg->saved_num_chan; i++) {
8542 msg->weighed_valid_list[i] =
8543 wma_map_pcl_weights(msg->weighed_valid_list[i]);
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008544 /* Dont allow roaming on 2G when 5G_ONLY configured */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008545 if ((wma_handle->bandcapability == BAND_5G) &&
Sandeep Puligilla819d94f2017-10-10 18:33:56 -07008546 (msg->saved_chan_list[i] <= MAX_24GHZ_CHANNEL)) {
8547 msg->weighed_valid_list[i] =
8548 WEIGHT_OF_DISALLOWED_CHANNELS;
8549 }
Manishekar Chandrasekaranb82554d2016-08-04 17:46:46 +05308550 WMA_LOGD("%s: chan:%d weight[%d]=%d", __func__,
8551 msg->saved_chan_list[i], i,
8552 msg->weighed_valid_list[i]);
8553 }
8554
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308555 if (!QDF_IS_STATUS_SUCCESS(status)) {
8556 WMA_LOGE("%s: Error in creating weighed pcl", __func__);
8557 return status;
8558 }
8559
8560 if (wmi_unified_pdev_set_pcl_cmd(wma_handle->wmi_handle, msg))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308561 return QDF_STATUS_E_FAILURE;
Govind Singhf25a0f12016-03-08 16:09:48 +05308562
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308563 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008564}
8565
8566/**
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308567 * wma_send_pdev_set_hw_mode_cmd() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008568 * @wma_handle: WMA handle
8569 * @msg: Structure containing the following parameters
8570 *
8571 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
8572 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
8573 *
8574 * Provides notification to the WLAN firmware that host driver is requesting a
8575 * HardWare (HW) Mode change. This command is needed to support iHelium in the
8576 * configurations that include the Dual Band Simultaneous (DBS) feature.
8577 *
8578 * Return: Success if the cmd is sent successfully to the firmware
8579 */
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308580QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008581 struct policy_mgr_hw_mode *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008582{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008583 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008584 struct wma_target_req *timeout_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008585
8586 if (!wma_handle) {
8587 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8588 __func__);
8589 /* Handle is NULL. Will not be able to send failure
8590 * response as well
8591 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308592 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008593 }
8594
8595 if (!msg) {
8596 WMA_LOGE("%s: Set HW mode param is NULL", __func__);
8597 /* Lets try to free the active command list */
8598 goto fail;
8599 }
8600
Dustin Brownec2c92e2017-07-26 11:13:49 -07008601 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8602 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT);
Govind Singhf25a0f12016-03-08 16:09:48 +05308603 if (wmi_unified_soc_set_hw_mode_cmd(wma_handle->wmi_handle,
Dustin Brownec2c92e2017-07-26 11:13:49 -07008604 msg->hw_mode_index)) {
8605 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008606 goto fail;
Krunal Sonicebcc292017-06-14 19:59:20 -07008607 }
Tushnim Bhattacharyya86294892017-10-25 16:29:11 -07008608 timeout_msg = wma_fill_hold_req(wma_handle, 0,
8609 SIR_HAL_PDEV_SET_HW_MODE,
8610 WMA_PDEV_SET_HW_MODE_RESP, NULL,
8611 WMA_VDEV_HW_MODE_REQUEST_TIMEOUT - 1);
8612 if (!timeout_msg) {
8613 WMA_LOGE("Failed to allocate request for SIR_HAL_PDEV_SET_HW_MODE");
8614 wma_remove_req(wma_handle, 0, WMA_PDEV_SET_HW_MODE_RESP);
8615 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008616
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308617 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008618fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308619 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008620 if (!param) {
8621 WMA_LOGE("%s: Memory allocation failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308622 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008623 }
8624 param->status = SET_HW_MODE_STATUS_ECANCELED;
8625 param->cfgd_hw_mode_index = 0;
8626 param->num_vdev_mac_entries = 0;
8627 WMA_LOGE("%s: Sending HW mode fail response to LIM", __func__);
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308628 wma_send_msg(wma_handle, SIR_HAL_PDEV_SET_HW_MODE_RESP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008629 (void *) param, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308630 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008631}
8632
8633/**
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308634 * wma_send_pdev_set_dual_mac_config() - Set dual mac config to FW
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008635 * @wma_handle: WMA handle
8636 * @msg: Dual MAC config parameters
8637 *
8638 * Configures WLAN firmware with the dual MAC features
8639 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308640 * Return: QDF_STATUS. 0 on success.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008641 */
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308642QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008643 struct sir_dual_mac_config *msg)
8644{
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308645 QDF_STATUS status;
8646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008647 if (!wma_handle) {
8648 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8649 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308650 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008651 }
8652
8653 if (!msg) {
8654 WMA_LOGE("%s: Set dual mode config is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308655 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008656 }
8657
Krunal Sonia5ccb802017-07-03 12:59:40 -07008658 /*
8659 * aquire the wake lock here and release it in response handler function
8660 * In error condition, release the wake lock right away
8661 */
8662 wma_acquire_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock,
8663 WMA_VDEV_PLCY_MGR_CMD_TIMEOUT);
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308664 status = wmi_unified_pdev_set_dual_mac_config_cmd(
8665 wma_handle->wmi_handle,
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308666 (struct wmi_dual_mac_config *)msg);
8667 if (QDF_IS_STATUS_ERROR(status)) {
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +05308668 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_DUAL_MAC_CONFIG_CMDID: %d",
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308669 __func__, status);
Krunal Sonia5ccb802017-07-03 12:59:40 -07008670 wma_release_wakelock(&wma_handle->wmi_cmd_rsp_wake_lock);
Manishekar Chandrasekaran91152df2016-04-25 14:29:27 +05308671 return status;
8672 }
Tushnim Bhattacharyya51258a72017-03-13 12:55:02 -07008673 policy_mgr_update_dbs_req_config(wma_handle->psoc,
8674 msg->scan_config, msg->fw_mode_config);
Govind Singhf25a0f12016-03-08 16:09:48 +05308675
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308676 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008677}
8678
8679/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008680 * wma_send_pdev_set_antenna_mode() - Set antenna mode to FW
8681 * @wma_handle: WMA handle
8682 * @msg: Antenna mode parameters
8683 *
8684 * Send WMI_PDEV_SET_ANTENNA_MODE_CMDID to FW requesting to
8685 * modify the number of TX/RX chains from host
8686 *
8687 * Return: QDF_STATUS. 0 on success.
8688 */
8689QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
8690 struct sir_antenna_mode_param *msg)
8691{
8692 wmi_pdev_set_antenna_mode_cmd_fixed_param *cmd;
8693 wmi_buf_t buf;
8694 uint32_t len;
8695 QDF_STATUS status = QDF_STATUS_SUCCESS;
8696 struct sir_antenna_mode_resp *param;
8697
8698 if (!wma_handle) {
8699 WMA_LOGE("%s: WMA handle is NULL. Cannot issue command",
8700 __func__);
8701 return QDF_STATUS_E_NULL_VALUE;
8702 }
8703
8704 if (!msg) {
8705 WMA_LOGE("%s: Set antenna mode param is NULL", __func__);
8706 return QDF_STATUS_E_NULL_VALUE;
8707 }
8708
8709 len = sizeof(*cmd);
8710
8711 buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
8712 if (!buf) {
8713 WMA_LOGE("%s: wmi_buf_alloc failed", __func__);
8714 status = QDF_STATUS_E_NOMEM;
8715 goto resp;
8716 }
8717
8718 cmd = (wmi_pdev_set_antenna_mode_cmd_fixed_param *) wmi_buf_data(buf);
8719 WMITLV_SET_HDR(&cmd->tlv_header,
8720 WMITLV_TAG_STRUC_wmi_pdev_set_antenna_mode_cmd_fixed_param,
8721 WMITLV_GET_STRUCT_TLVLEN(
8722 wmi_pdev_set_antenna_mode_cmd_fixed_param));
8723
8724 cmd->pdev_id = WMI_PDEV_ID_SOC;
8725 /* Bits 0-15 is num of RX chains 16-31 is num of TX chains */
8726 cmd->num_txrx_chains = msg->num_rx_chains;
8727 cmd->num_txrx_chains |= (msg->num_tx_chains << 16);
8728
Srinivas Girigowda3ad735a2017-03-20 09:26:17 -07008729 WMA_LOGD("%s: Num of chains TX: %d RX: %d txrx_chains: 0x%x",
Archana Ramachandrana20ef812015-11-13 16:12:13 -08008730 __func__, msg->num_tx_chains,
8731 msg->num_rx_chains, cmd->num_txrx_chains);
8732
8733 if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len,
8734 WMI_PDEV_SET_ANTENNA_MODE_CMDID)) {
8735 WMA_LOGE("%s: Failed to send WMI_PDEV_SET_ANTENNA_MODE_CMDID",
8736 __func__);
8737 wmi_buf_free(buf);
8738 status = QDF_STATUS_E_FAILURE;
8739 goto resp;
8740 }
8741 status = QDF_STATUS_SUCCESS;
8742
8743resp:
8744 param = qdf_mem_malloc(sizeof(*param));
8745 if (!param) {
8746 WMA_LOGE("%s: Memory allocation failed", __func__);
8747 return QDF_STATUS_E_NOMEM;
8748 }
8749 param->status = (status) ?
8750 SET_ANTENNA_MODE_STATUS_ECANCELED :
8751 SET_ANTENNA_MODE_STATUS_OK;
8752 WMA_LOGE("%s: Send antenna mode resp to LIM status: %d",
8753 __func__, param->status);
8754 wma_send_msg(wma_handle, SIR_HAL_SOC_ANTENNA_MODE_RESP,
8755 (void *) param, 0);
8756 return status;
8757}
8758
8759/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008760 * wma_crash_inject() - sends command to FW to simulate crash
8761 * @wma_handle: pointer of WMA context
8762 * @type: subtype of the command
8763 * @delay_time_ms: time in milliseconds for FW to delay the crash
8764 *
8765 * This function will send a command to FW in order to simulate different
8766 * kinds of FW crashes.
8767 *
Govind Singhd76a5b02016-03-08 15:12:14 +05308768 * Return: QDF_STATUS_SUCCESS for success or error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008769 */
Yu Wang46082dc2017-09-19 12:25:38 +08008770QDF_STATUS wma_crash_inject(WMA_HANDLE wma_handle, uint32_t type,
8771 uint32_t delay_time_ms)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008772{
Govind Singhd76a5b02016-03-08 15:12:14 +05308773 struct crash_inject param;
Yu Wang46082dc2017-09-19 12:25:38 +08008774 tp_wma_handle wma = (tp_wma_handle)wma_handle;
Manikandan Mohan1dd8b5d2017-04-18 15:54:09 -07008775
Govind Singhd76a5b02016-03-08 15:12:14 +05308776 param.type = type;
8777 param.delay_time_ms = delay_time_ms;
Yu Wang46082dc2017-09-19 12:25:38 +08008778 return wmi_crash_inject(wma->wmi_handle, &param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008779}
Govind Singhd76a5b02016-03-08 15:12:14 +05308780
Manjunathappa Prakash7b0ad462018-04-15 00:37:16 -07008781#ifdef RECEIVE_OFFLOAD
Dhanashri Atre09828f12016-11-13 10:36:58 -08008782int wma_lro_init(struct cdp_lro_hash_config *lro_config)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008783{
Rajeev Kumarb60abe42017-01-21 15:39:31 -08008784 struct scheduler_msg msg = {0};
Dhanashri Atre09828f12016-11-13 10:36:58 -08008785 struct cdp_lro_hash_config *iwcmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008786
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308787 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008788 if (!iwcmd) {
8789 WMA_LOGE("memory allocation for WMA_LRO_CONFIG_CMD failed!");
8790 return -ENOMEM;
8791 }
8792
8793 *iwcmd = *lro_config;
8794
8795 msg.type = WMA_LRO_CONFIG_CMD;
8796 msg.reserved = 0;
8797 msg.bodyptr = iwcmd;
8798
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308799 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarb60abe42017-01-21 15:39:31 -08008800 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008801 WMA_LOGE("Failed to post WMA_LRO_CONFIG_CMD msg!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308802 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008803 return -EAGAIN;
8804 }
8805
8806 WMA_LOGD("sending the LRO configuration to the fw");
8807 return 0;
8808}
8809#endif
Leo Chang96464902016-10-28 11:10:54 -07008810
8811void wma_peer_set_default_routing(void *scn_handle, uint8_t *peer_macaddr,
8812 uint8_t vdev_id, bool hash_based, uint8_t ring_num)
8813{
8814 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8815 struct peer_set_params param;
8816
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308817 if (!wma) {
8818 WMA_LOGE("%s:wma_handle is NULL", __func__);
8819 return;
8820 }
Leo Chang96464902016-10-28 11:10:54 -07008821
8822 /* TODO: Need bit definitions for ring number and hash based routing
8823 * fields in common wmi header file
8824 */
8825 param.param_id = WMI_HOST_PEER_SET_DEFAULT_ROUTING;
8826 param.vdev_id = vdev_id;
8827 param.param_value = ((hash_based) ? 1 : 0) | (ring_num << 1);
Jeff Johnsonf7ca9642017-10-10 16:11:49 -07008828 WMA_LOGD("%s: param_value 0x%x", __func__, param.param_value);
Leo Chang96464902016-10-28 11:10:54 -07008829 wmi_set_peer_param_send(wma->wmi_handle, peer_macaddr, &param);
Leo Chang96464902016-10-28 11:10:54 -07008830}
8831
8832int wma_peer_rx_reorder_queue_setup(void *scn_handle,
8833 uint8_t vdev_id, uint8_t *peer_macaddr, qdf_dma_addr_t hw_qdesc,
8834 int tid, uint16_t queue_no)
8835{
8836 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8837 struct rx_reorder_queue_setup_params param;
8838
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308839 if (!wma) {
8840 WMA_LOGE("%s:wma_handle is NULL", __func__);
8841 return QDF_STATUS_E_FAILURE;
8842 }
8843
Leo Chang96464902016-10-28 11:10:54 -07008844 param.tid = tid;
8845 param.vdev_id = vdev_id;
8846 param.peer_macaddr = peer_macaddr;
8847 param.hw_qdesc_paddr_lo = hw_qdesc & 0xffffffff;
8848 param.hw_qdesc_paddr_hi = (uint64_t)hw_qdesc >> 32;
8849 param.queue_no = queue_no;
8850
8851 return wmi_unified_peer_rx_reorder_queue_setup_send(wma->wmi_handle,
8852 &param);
8853}
8854
8855int wma_peer_rx_reorder_queue_remove(void *scn_handle,
8856 uint8_t vdev_id, uint8_t *peer_macaddr, uint32_t peer_tid_bitmap)
8857{
8858 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8859 struct rx_reorder_queue_remove_params param;
8860
Nishank Aggarwala13b61d2016-12-01 12:53:58 +05308861 if (!wma) {
8862 WMA_LOGE("%s:wma_handle is NULL", __func__);
8863 return QDF_STATUS_E_FAILURE;
8864 }
8865
Leo Chang96464902016-10-28 11:10:54 -07008866 param.vdev_id = vdev_id;
8867 param.peer_macaddr = peer_macaddr;
8868 param.peer_tid_bitmap = peer_tid_bitmap;
8869
8870 return wmi_unified_peer_rx_reorder_queue_remove_send(wma->wmi_handle,
8871 &param);
8872}
8873
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +05308874QDF_STATUS wma_configure_smps_params(uint32_t vdev_id, uint32_t param_id,
8875 uint32_t param_val)
8876{
8877 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8878 int smps_cmd_value;
8879 int status = QDF_STATUS_E_INVAL;
8880
8881 if (!wma) {
8882 WMA_LOGE("%s: Failed to get wma", __func__);
8883 return status;
8884 }
8885
8886 smps_cmd_value = param_id << WMI_SMPS_PARAM_VALUE_S;
8887 smps_cmd_value = smps_cmd_value | param_val;
8888
8889 status = wma_set_smps_params(wma, vdev_id, smps_cmd_value);
8890 if (status)
8891 WMA_LOGE("Failed to set SMPS Param");
8892
8893 return status;
8894}
8895
Leo Chang96464902016-10-28 11:10:54 -07008896
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07008897void wma_ipa_uc_stat_request(wma_cli_set_cmd_t *privcmd)
8898{
8899 tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
8900
Sreelakshmi Konamki7a574082017-05-15 16:53:45 +05308901 if (!wma) {
8902 WMA_LOGE("%s: Failed to get wma", __func__);
8903 return;
8904 }
8905
Sandeep Puligillaf587adf2017-04-27 19:53:21 -07008906 if (wma_set_priv_cfg(wma, privcmd))
8907 WMA_LOGE("Failed to set wma priv congiuration");
8908}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +05308909
8910/**
8911 * wma_config_bmiss_bcnt_params() - set bmiss config parameters
8912 * @vdev_id: virtual device for the command
8913 * @first_cnt: bmiss first value
8914 * @final_cnt: bmiss final value
8915 *
8916 * Return: QDF_STATUS_SUCCESS or non-zero on failure
8917 */
8918QDF_STATUS wma_config_bmiss_bcnt_params(uint32_t vdev_id, uint32_t first_cnt,
8919 uint32_t final_cnt)
8920{
8921 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8922 int status = QDF_STATUS_E_INVAL;
8923
8924 if (!wma_handle) {
8925 WMA_LOGE("%s: Failed to get wma", __func__);
8926 return status;
8927 }
8928
8929 status = wma_roam_scan_bmiss_cnt(wma_handle, first_cnt, final_cnt,
8930 vdev_id);
8931
8932 if (status)
8933 WMA_LOGE("Failed to set Bmiss Param");
8934
8935 return status;
8936}
8937