blob: 7923f335d2953e45ece6f3190c0e52fdd5c555ba [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302 * Copyright (c) 2012-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
19/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053020 * DOC: smeApi.c
21 *
22 * Definitions for SME APIs
23 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080024
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053025/* Include Files */
Srinivas Girigowda2c263352017-03-17 17:49:53 -070026#include <sir_common.h>
27#include <ani_global.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080028#include "sme_api.h"
29#include "csr_inside_api.h"
30#include "sme_inside.h"
31#include "csr_internal.h"
32#include "wma_types.h"
33#include "wma_if.h"
Jeff Johnson6136fb92017-03-30 15:21:49 -070034#include "wma_fips_api.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053035#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#include "sme_trace.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053037#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053038#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039#include "cds_utils.h"
40#include "sap_api.h"
41#include "mac_trace.h"
42#ifdef WLAN_FEATURE_NAN
43#include "nan_api.h"
44#endif
Naveen Rawat3b6068c2016-04-14 19:01:06 -070045#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "cfg_api.h"
47#include "sme_power_save_api.h"
48#include "wma.h"
Naveen Rawatb4d37622015-11-13 16:15:25 -080049#include "sch_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070050#include "sme_nan_datapath.h"
Agrawal Ashish21ba2572016-09-03 16:40:10 +053051#include "csr_api.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070052#include "wlan_reg_services_api.h"
Abhishek Singh158fe252017-03-23 11:09:34 +053053#include <wlan_scan_ucfg_api.h>
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070054#include "wlan_reg_ucfg_api.h"
Arif Hussainee677012017-01-26 17:50:13 -080055#include "ol_txrx.h"
Naveen Rawatd2657be2017-10-10 14:31:23 -070056#include "wifi_pos_api.h"
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053057#include "net/cfg80211.h"
58#include <qca_vendor.h>
Sandeep Puligilla063a4342018-01-10 02:50:14 -080059#include <wlan_spectral_utils_api.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061static tSelfRecoveryStats g_self_recovery_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053063static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053065static void sme_disconnect_connected_sessions(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053067static QDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068 void *pMsgBuf);
69
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053070static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072/* Channel Change Response Indication Handler */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053073static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074 uint16_t msg_type, void *pMsgBuf);
75
Jeff Johnsonfdecd512018-06-10 09:18:32 -070076static QDF_STATUS sme_stats_ext_event(tpAniSirGlobal mac,
77 tpStatsExtEvent msg);
78
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079/* Internal SME APIs */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053080QDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053082 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083
84 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053085 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053086 (qdf_mutex_acquire(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053087 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 }
89
90 return status;
91}
92
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053093QDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053095 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096
97 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053098 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053099 (qdf_mutex_release(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530100 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101 }
102
103 return status;
104}
105
Tushnim Bhattacharyya518e80f2017-08-30 17:35:33 -0700106tpAniSirGlobal sme_get_mac_context(void)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -0700107{
108 tpAniSirGlobal mac_ctx;
109 tHalHandle h_hal;
110
111 h_hal = cds_get_context(QDF_MODULE_ID_SME);
112 if (NULL == h_hal) {
113 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
114 FL("invalid h_hal"));
115 return NULL;
116 }
117
118 mac_ctx = PMAC_STRUCT(h_hal);
119 if (NULL == mac_ctx) {
120 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
121 FL("Invalid MAC context"));
122 return NULL;
123 }
124
125 return mac_ctx;
126}
127
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128/**
129 * sme_process_set_hw_mode_resp() - Process set HW mode response
130 * @mac: Global MAC pointer
131 * @msg: HW mode response
132 *
133 * Processes the HW mode response and invokes the HDD callback
134 * to process further
135 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530136static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137{
Krunal Sonia8270f52017-02-23 19:51:25 -0800138 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 tSmeCmd *command = NULL;
140 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800141 policy_mgr_pdev_set_hw_mode_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya3b99f4b2018-03-26 14:19:24 -0700143 enum policy_mgr_conn_update_reason reason;
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530144 struct csr_roam_session *session;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800145 uint32_t session_id;
Sandeep Puligilla344d7252017-09-15 16:23:33 -0700146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147 param = (struct sir_set_hw_mode_resp *)msg;
148 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700149 sme_err("HW mode resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150 /* Not returning. Need to check if active command list
151 * needs to be freed
152 */
153 }
154
Krunal Sonia8270f52017-02-23 19:51:25 -0800155 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700157 sme_err("No cmd found in active list");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800158 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 }
160
161 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
162 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700163 sme_err("Base address is NULL");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800164 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 }
166
167 if (e_sme_command_set_hw_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700168 sme_err("Command mismatch!");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800169 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 }
171
172 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530173 reason = command->u.set_hw_mode_cmd.reason;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800174 session_id = command->u.set_hw_mode_cmd.session_id;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530175
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700176 sme_debug("reason: %d session: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530177 command->u.set_hw_mode_cmd.reason,
178 command->u.set_hw_mode_cmd.session_id);
179
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700180 if (!callback) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700181 sme_err("Callback does not exist");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700182 goto end;
183 }
184
185 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700186 sme_err("Callback failed since HW mode params is NULL");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700187 goto end;
188 }
189
190 /* Irrespective of the reason for which the hw mode change request
191 * was issued, the policy manager connection table needs to be updated
192 * with the new vdev-mac id mapping, tx/rx spatial streams etc., if the
193 * set hw mode was successful.
194 */
195 callback(param->status,
196 param->cfgd_hw_mode_index,
197 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800198 param->vdev_mac_map,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800199 command->u.set_hw_mode_cmd.next_action,
200 command->u.set_hw_mode_cmd.reason,
201 command->u.set_hw_mode_cmd.session_id,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800202 command->u.set_hw_mode_cmd.context);
Krunal Soni3fa80e22018-01-09 14:16:02 -0800203 if (!CSR_IS_SESSION_VALID(mac, session_id)) {
204 sme_err("session %d is invalid", session_id);
205 goto end;
206 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800207 session = CSR_GET_SESSION(mac, session_id);
Tushnim Bhattacharyya3b99f4b2018-03-26 14:19:24 -0700208 if (reason == POLICY_MGR_UPDATE_REASON_HIDDEN_STA) {
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700209 /* In the case of hidden SSID, connection update
210 * (set hw mode) is done after the scan with reason
211 * code eCsrScanForSsid completes. The connect/failure
212 * needs to be handled after the response of set hw
213 * mode
214 */
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800215 if (param->status == SET_HW_MODE_STATUS_OK) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700216 sme_debug("search for ssid success");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800217 csr_scan_handle_search_for_ssid(mac,
218 session_id);
219 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700220 sme_debug("search for ssid failure");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800221 csr_scan_handle_search_for_ssid_failure(mac,
222 session_id);
223 }
Deepak Dhamdhere6f7fbbe2017-02-28 13:35:52 -0800224 csr_saved_scan_cmd_free_fields(mac, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 }
226
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530227end:
Krunal Soni72dba662017-02-15 20:13:17 -0800228 found = csr_nonscan_active_ll_remove_entry(mac, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530230 if (found)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -0800232 csr_release_command(mac, command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800233
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530234 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235}
236
237/**
238 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
239 * @mac: Global MAC pointer
240 * @msg: HW mode transition response
241 *
242 * Processes the HW mode transition indication and invoke the HDD callback
243 * to process further
244 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530245static QDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 uint8_t *msg)
247{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 struct sir_hw_mode_trans_ind *param;
249
250 param = (struct sir_hw_mode_trans_ind *)msg;
251 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700252 sme_err("HW mode trans ind param is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530253 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254 }
255
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800256 policy_mgr_hw_mode_transition_cb(param->old_hw_mode_index,
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -0800257 param->new_hw_mode_index,
258 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800259 param->vdev_mac_map, mac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530261 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262}
263
Naveen Rawate7d86052015-11-13 12:01:43 -0800264/**
265 * free_sme_cmds() - This function frees memory allocated for SME commands
266 * @mac_ctx: Pointer to Global MAC structure
267 *
268 * This function frees memory allocated for SME commands
269 *
270 * @Return: void
271 */
272static void free_sme_cmds(tpAniSirGlobal mac_ctx)
273{
274 uint32_t idx;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530275
Naveen Rawate7d86052015-11-13 12:01:43 -0800276 if (NULL == mac_ctx->sme.pSmeCmdBufAddr)
277 return;
278
279 for (idx = 0; idx < mac_ctx->sme.totalSmeCmd; idx++)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530280 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr[idx]);
Naveen Rawate7d86052015-11-13 12:01:43 -0800281
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530282 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr);
Naveen Rawate7d86052015-11-13 12:01:43 -0800283 mac_ctx->sme.pSmeCmdBufAddr = NULL;
284}
285
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530286static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530288 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289 tSmeCmd *pCmd;
290 uint32_t cmd_idx;
Naveen Rawate7d86052015-11-13 12:01:43 -0800291 uint32_t sme_cmd_ptr_ary_sz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292
293 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
294
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295
Jeff Johnson616417f2018-06-27 10:20:53 -0700296 status = csr_ll_open(&pMac->sme.smeCmdFreeList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530297 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 goto end;
299
Naveen Rawate7d86052015-11-13 12:01:43 -0800300 /* following pointer contains array of pointers for tSmeCmd* */
301 sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530302 pMac->sme.pSmeCmdBufAddr = qdf_mem_malloc(sme_cmd_ptr_ary_sz);
Naveen Rawate7d86052015-11-13 12:01:43 -0800303 if (NULL == pMac->sme.pSmeCmdBufAddr) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530304 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800305 goto end;
306 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530308 status = QDF_STATUS_SUCCESS;
Naveen Rawate7d86052015-11-13 12:01:43 -0800309 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
310 /*
311 * Since total size of all commands together can be huge chunk
312 * of memory, allocate SME cmd individually. These SME CMDs are
313 * moved between pending and active queues. And these freeing of
314 * these queues just manipulates the list but does not actually
315 * frees SME CMD pointers. Hence store each SME CMD address in
316 * the array, sme.pSmeCmdBufAddr. This will later facilitate
317 * freeing up of all SME CMDs with just a for loop.
318 */
319 pMac->sme.pSmeCmdBufAddr[cmd_idx] =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530320 qdf_mem_malloc(sizeof(tSmeCmd));
Naveen Rawate7d86052015-11-13 12:01:43 -0800321 if (NULL == pMac->sme.pSmeCmdBufAddr[cmd_idx]) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530322 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800323 free_sme_cmds(pMac);
324 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 }
Naveen Rawate7d86052015-11-13 12:01:43 -0800326 pCmd = (tSmeCmd *)pMac->sme.pSmeCmdBufAddr[cmd_idx];
327 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
328 &pCmd->Link, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 }
330
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530332 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700333 sme_err("Failed to initialize sme command list: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334
335 return status;
336}
337
Krunal Sonia8270f52017-02-23 19:51:25 -0800338void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339{
Krunal Sonia8270f52017-02-23 19:51:25 -0800340 sme_cmd->command = eSmeNoCommand;
341 csr_ll_insert_tail(&mac_ctx->sme.smeCmdFreeList, &sme_cmd->Link,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530342 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343}
344
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530345static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530347 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349 csr_ll_close(&pMac->sme.smeCmdFreeList);
350
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530351 status = qdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530352 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700353 sme_err("Failed to acquire the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 goto done;
355 }
356
Naveen Rawate7d86052015-11-13 12:01:43 -0800357 free_sme_cmds(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530359 status = qdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530360 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700361 sme_err("Failed to release the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362done:
363 return status;
364}
365
Jeff Johnson49c02f92016-10-07 10:29:09 -0700366static void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367{
368 switch (pCmd->command) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 case eSmeCommandRoam:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700370 sme_debug("roam command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 pCmd->u.roamCmd.roamReason);
372 break;
373
374 case eSmeCommandWmStatusChange:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700375 sme_debug("WMStatusChange command type is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 pCmd->u.wmStatusChangeCmd.Type);
377 break;
378
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700380 sme_debug("default: Unhandled command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 pCmd->command);
382 break;
383 }
384}
385
386tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
387{
388 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
389 tListElem *pEntry;
390 static int sme_command_queue_full;
391
392 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
393
394 /* If we can get another MS Msg buffer, then we are ok. Just link */
395 /* the entry onto the linked list. (We are using the linked list */
396 /* to keep track of tfhe message buffers). */
397 if (pEntry) {
398 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
399 /* reset when free list is available */
400 sme_command_queue_full = 0;
401 } else {
402 int idx = 1;
403
404 /* Cannot change pRetCmd here since it needs to return later. */
Krunal Sonia8270f52017-02-23 19:51:25 -0800405 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530406 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530408
409 sme_err("Out of command buffer.... command (0x%X) stuck",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
411 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530412 if (eSmeCsrCommandMask & pTempCmd->command)
413 /* CSR command is stuck. See what the reason
414 * code is for that command
415 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 } /* if(pTempCmd) */
418
419 /* dump what is in the pending queue */
Krunal Soni20126cb2017-02-15 16:26:57 -0800420 csr_nonscan_pending_ll_lock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421 pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -0800422 csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 LL_ACCESS_NOLOCK);
424 while (pEntry && !sme_command_queue_full) {
425 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
426 /* Print only 1st five commands from pending queue. */
427 if (idx <= 5)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530428 sme_err("Out of command buffer.... SME pending command #%d (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 idx, pTempCmd->command);
430 idx++;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530431 if (eSmeCsrCommandMask & pTempCmd->command)
432 /* CSR command is stuck. See what the reason
433 * code is for that command
434 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 dump_csr_command_info(pMac, pTempCmd);
Krunal Soni72dba662017-02-15 20:13:17 -0800436 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 LL_ACCESS_NOLOCK);
438 }
Krunal Soni20126cb2017-02-15 16:26:57 -0800439 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440
Abhishek Singh5ea86532016-04-27 14:10:53 +0530441 if (pMac->roam.configParam.enable_fatal_event)
442 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
443 WLAN_LOG_INDICATOR_HOST_DRIVER,
444 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
445 false,
446 pMac->sme.enableSelfRecovery ? true : false);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530447 else
Anurag Chouhan4085ff72017-10-05 18:09:56 +0530448 cds_trigger_recovery(QDF_GET_MSG_BUFF_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 }
450
451 /* memset to zero */
452 if (pRetCmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530453 qdf_mem_set((uint8_t *)&pRetCmd->command,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454 sizeof(pRetCmd->command), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530455 qdf_mem_set((uint8_t *)&pRetCmd->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456 sizeof(pRetCmd->sessionId), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530457 qdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 }
459
460 return pRetCmd;
461}
462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463/**
Krunal Sonia8270f52017-02-23 19:51:25 -0800464 * sme_ser_handle_active_cmd() - handle command activation callback from
465 * new serialization module
466 * @cmd: pointer to new serialization command
467 *
468 * This API is to handle command activation callback from new serialization
469 * callback
470 *
471 * Return: QDF_STATUS_SUCCESS
472 */
473static
474QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
475{
476 tSmeCmd *sme_cmd;
477 tHalHandle hal;
478 tpAniSirGlobal mac_ctx;
479 QDF_STATUS status = QDF_STATUS_SUCCESS;
480 bool do_continue;
481
482 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700483 sme_err("No serialization command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800484 return QDF_STATUS_E_FAILURE;
485 }
486
487 hal = cds_get_context(QDF_MODULE_ID_SME);
488 mac_ctx = PMAC_STRUCT(hal);
489 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700490 sme_err("No mac_ctx found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800491 return QDF_STATUS_E_FAILURE;
492 }
493 sme_cmd = cmd->umac_cmd;
494 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700495 sme_err("No SME command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800496 return QDF_STATUS_E_FAILURE;
497 }
498
499 switch (sme_cmd->command) {
500 case eSmeCommandRoam:
501 status = csr_roam_process_command(mac_ctx, sme_cmd);
502 break;
503 case eSmeCommandWmStatusChange:
504 csr_roam_process_wm_status_change_command(mac_ctx,
505 sme_cmd);
506 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800507 case eSmeCommandAddTs:
508 case eSmeCommandDelTs:
509#ifndef WLAN_MDM_CODE_REDUCTION_OPT
510 do_continue = qos_process_command(mac_ctx, sme_cmd);
511 if (do_continue)
512 status = QDF_STATUS_E_FAILURE;
513#endif
514 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800515 case e_sme_command_set_hw_mode:
516 csr_process_set_hw_mode(mac_ctx, sme_cmd);
517 break;
518 case e_sme_command_nss_update:
519 csr_process_nss_update_req(mac_ctx, sme_cmd);
520 break;
521 case e_sme_command_set_dual_mac_config:
522 csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
523 break;
524 case e_sme_command_set_antenna_mode:
525 csr_process_set_antenna_mode(mac_ctx, sme_cmd);
526 break;
527 default:
528 /* something is wrong */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700529 sme_err("unknown command %d", sme_cmd->command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800530 status = QDF_STATUS_E_FAILURE;
531 break;
532 }
Krunal Sonia8270f52017-02-23 19:51:25 -0800533 return status;
534}
535
536QDF_STATUS sme_ser_cmd_callback(void *buf,
537 enum wlan_serialization_cb_reason reason)
538{
539 struct wlan_serialization_command *cmd = buf;
540 tHalHandle hal;
541 tpAniSirGlobal mac_ctx;
542 QDF_STATUS status = QDF_STATUS_SUCCESS;
543 tSmeCmd *sme_cmd;
544
545 hal = cds_get_context(QDF_MODULE_ID_SME);
546 mac_ctx = PMAC_STRUCT(hal);
547 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700548 sme_err("mac_ctx is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800549 return QDF_STATUS_E_FAILURE;
550 }
551 /*
552 * Do not acquire lock here as sme global lock is already acquired in
553 * caller or MC thread context
554 */
555 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700556 sme_err("serialization command is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800557 return QDF_STATUS_E_FAILURE;
558 }
559
560 switch (reason) {
561 case WLAN_SER_CB_ACTIVATE_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700562 sme_debug("WLAN_SER_CB_ACTIVATE_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800563 status = sme_ser_handle_active_cmd(cmd);
564 break;
565 case WLAN_SER_CB_CANCEL_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700566 sme_debug("WLAN_SER_CB_CANCEL_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800567 break;
568 case WLAN_SER_CB_RELEASE_MEM_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700569 sme_debug("WLAN_SER_CB_RELEASE_MEM_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800570 sme_cmd = cmd->umac_cmd;
571 csr_release_command_buffer(mac_ctx, sme_cmd);
572 break;
573 case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700574 sme_debug("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800575 break;
576 default:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700577 sme_debug("STOP: unknown reason code");
Krunal Sonia8270f52017-02-23 19:51:25 -0800578 return QDF_STATUS_E_FAILURE;
579 }
580 return status;
581}
582
Wen Gong3f003382018-05-14 14:26:37 +0800583#ifdef WLAN_FEATURE_MEMDUMP_ENABLE
Krunal Sonia8270f52017-02-23 19:51:25 -0800584/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530585 * sme_get_sessionid_from_activelist() - gets session id
586 * @mac: mac context
587 *
588 * This function is used to get session id from sme command
589 * active list
590 *
591 * Return: returns session id
592 */
Jeff Johnson49c02f92016-10-07 10:29:09 -0700593static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530594{
595 tListElem *entry;
596 tSmeCmd *command;
597 uint32_t session_id = CSR_SESSION_ID_INVALID;
598
Krunal Sonia8270f52017-02-23 19:51:25 -0800599 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530600 if (entry) {
601 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
602 session_id = command->sessionId;
603 }
604
605 return session_id;
606}
607
608/**
609 * sme_state_info_dump() - prints state information of sme layer
610 * @buf: buffer pointer
611 * @size: size of buffer to be filled
612 *
613 * This function is used to dump state information of sme layer
614 *
615 * Return: None
616 */
617static void sme_state_info_dump(char **buf_ptr, uint16_t *size)
618{
619 uint32_t session_id, active_session_id;
620 tHalHandle hal;
621 tpAniSirGlobal mac;
622 uint16_t len = 0;
623 char *buf = *buf_ptr;
624 eCsrConnectState connect_state;
625
626 hal = cds_get_context(QDF_MODULE_ID_SME);
627 if (hal == NULL) {
628 QDF_ASSERT(0);
629 return;
630 }
631
632 mac = PMAC_STRUCT(hal);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530633
634 active_session_id = sme_get_sessionid_from_activelist(mac);
635 if (active_session_id != CSR_SESSION_ID_INVALID) {
636 len += qdf_scnprintf(buf + len, *size - len,
637 "\n active command sessionid %d", active_session_id);
638 }
639
640 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
641 if (CSR_IS_SESSION_VALID(mac, session_id)) {
642 connect_state =
643 mac->roam.roamSession[session_id].connectState;
644 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED ==
645 connect_state)
646 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED ==
647 connect_state)) {
648 len += qdf_scnprintf(buf + len, *size - len,
649 "\n NeighborRoamState: %d",
650 mac->roam.neighborRoamInfo[session_id].
651 neighborRoamState);
652 len += qdf_scnprintf(buf + len, *size - len,
653 "\n RoamState: %d", mac->roam.
654 curState[session_id]);
655 len += qdf_scnprintf(buf + len, *size - len,
656 "\n RoamSubState: %d", mac->roam.
657 curSubState[session_id]);
658 len += qdf_scnprintf(buf + len, *size - len,
659 "\n ConnectState: %d",
660 connect_state);
661 }
662 }
663 }
664
665 *size -= len;
666 *buf_ptr += len;
667}
668
669/**
670 * sme_register_debug_callback() - registration function sme layer
671 * to print sme state information
672 *
673 * Return: None
674 */
675static void sme_register_debug_callback(void)
676{
677 qdf_register_debug_callback(QDF_MODULE_ID_SME, &sme_state_info_dump);
678}
Wen Gong3f003382018-05-14 14:26:37 +0800679#else /* WLAN_FEATURE_MEMDUMP_ENABLE */
Wen Gongaa6d55d2018-04-26 16:33:21 +0800680static void sme_register_debug_callback(void)
681{
682}
Wen Gong3f003382018-05-14 14:26:37 +0800683#endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685/* Global APIs */
686
687/**
688 * sme_open() - Initialze all SME modules and put them at idle state
689 * @hHal: The handle returned by mac_open
690 *
691 * The function initializes each module inside SME, PMC, CSR, etc. Upon
692 * successfully return, all modules are at idle state ready to start.
693 * smeOpen must be called before any other SME APIs can be involved.
694 * smeOpen must be called after mac_open.
695 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530696 * Return: QDF_STATUS_SUCCESS - SME is successfully initialized.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 * Other status means SME is failed to be initialized
698 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530699QDF_STATUS sme_open(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530701 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800703
704 pMac->sme.state = SME_STATE_STOP;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530705 pMac->sme.currDeviceMode = QDF_STA_MODE;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530706 if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707 &pMac->sme.lkSmeGlobalLock))) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700708 sme_err("sme_open failed init lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530709 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 }
711 status = csr_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530712 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700713 sme_err("csr_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714 return status;
715 }
716
717 status = sme_ps_open(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530718 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700719 sme_err("sme_ps_open failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720 return status;
721 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722
723#ifndef WLAN_MDM_CODE_REDUCTION_OPT
724 status = sme_qos_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530725 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700726 sme_err("Qos open, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727 return status;
728 }
729#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730 status = init_sme_cmd_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530731 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 status = rrm_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530735 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700736 sme_err("rrm_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 return status;
738 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 sme_trace_init(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530740 sme_register_debug_callback();
Krunal Soni33787902017-08-29 11:39:28 -0700741 wlan_serialization_legacy_init_callback();
742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 return status;
744}
745
746/*
747 * sme_init_chan_list, triggers channel setup based on country code.
748 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530749QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
Amar Singhala297bfa2015-10-15 15:07:29 -0700750 enum country_src cc_src)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751{
752 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
753
Amar Singhala297bfa2015-10-15 15:07:29 -0700754 if ((cc_src == SOURCE_USERSPACE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
756 pmac->roam.configParam.Is11dSupportEnabled = false;
757 }
758
759 return csr_init_chan_list(pmac, alpha2);
760}
761
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530762/*
763 * sme_set11dinfo() - Set the 11d information about valid channels
764 * and there power using information from nvRAM
765 * This function is called only for AP.
766 *
767 * This is a synchronous call
768 *
769 * hHal - The handle returned by mac_open.
770 * pSmeConfigParams - a pointer to a caller allocated object of
771 * typedef struct _smeConfigParams.
772 *
773 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
774 *
775 * Other status means SME is failed to update the config parameters.
776 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777
Jeff Johnsonff26c612018-06-10 20:57:13 -0700778QDF_STATUS sme_set11dinfo(tHalHandle hal, tpSmeConfigParams pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779{
Jeff Johnsonff26c612018-06-10 20:57:13 -0700780 tpAniSirGlobal mac_ctx = MAC_CONTEXT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530781 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530783 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
785 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700786 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787 return status;
788 }
789
Jeff Johnsonff26c612018-06-10 20:57:13 -0700790 status = csr_set_channels(mac_ctx, &pSmeConfigParams->csrConfig);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700791 if (!QDF_IS_STATUS_SUCCESS(status))
792 sme_err("csr_set_channels failed with status: %d", status);
793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 return status;
795}
796
797/**
798 * sme_set_scan_disable() - Dynamically enable/disable scan
799 * @h_hal: Handle to HAL
800 *
801 * This command gives the user an option to dynamically
802 * enable or disable scans.
803 *
804 * Return: None
805 */
806void sme_set_scan_disable(tHalHandle h_hal, int value)
807{
808 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530809
Sandeep Puligilla24b7aa72017-10-13 18:05:14 -0700810 sme_info("scan disable %d", value);
Abhishek Singhcaebce02017-10-12 11:07:57 +0530811 ucfg_scan_set_enable(mac_ctx->psoc, !value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530813/*
814 * sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
815 * This is a synchronous call
816 *
817 * hHal - The handle returned by HostapdAdapter.
818 * v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
819 * Return QDF_STATUS_SUCCESS - SME successfully completed the request.
820 * Other status means, failed to get the current regulatory domain.
821 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530823QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t
824 *domainIdSoftAp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530826 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
828
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530829 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
831 NO_SESSION, 0));
832 if (NULL == domainIdSoftAp) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700833 sme_err("Uninitialized domain Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 return status;
835 }
836
837 *domainIdSoftAp = pMac->scan.domainIdCurrent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530838 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839
840 return status;
841}
842
Krunal Sonie3531942016-04-12 17:43:53 -0700843/**
844 * sme_update_fine_time_measurement_capab() - Update the FTM capabitlies from
845 * incoming val
846 * @hal: Handle for Hal layer
847 * @val: New FTM capability value
848 *
849 * Return: None
850 */
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530851void sme_update_fine_time_measurement_capab(tHalHandle hal, uint8_t session_id,
852 uint32_t val)
Krunal Sonie3531942016-04-12 17:43:53 -0700853{
854 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530855 QDF_STATUS status;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530856
Naveen Rawatd2657be2017-10-10 14:31:23 -0700857 ucfg_wifi_pos_set_ftm_cap(mac_ctx->psoc, val);
Krunal Sonie3531942016-04-12 17:43:53 -0700858
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530859 if (!val) {
Krunal Sonie3531942016-04-12 17:43:53 -0700860 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 0;
861 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
862 rrmConfig.rm_capability)->fine_time_meas_rpt = 0;
863 } else {
864 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 1;
865 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
866 rrmConfig.rm_capability)->fine_time_meas_rpt = 1;
867 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530868
869 /* Inform this RRM IE change to FW */
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530870 status = sme_acquire_global_lock(&mac_ctx->sme);
871 if (QDF_IS_STATUS_SUCCESS(status)) {
872 csr_roam_offload_scan(mac_ctx, session_id,
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530873 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
874 REASON_CONNECT_IES_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530875 sme_release_global_lock(&mac_ctx->sme);
876 } else {
877 sme_err("Failed to acquire SME lock");
878 }
Krunal Sonie3531942016-04-12 17:43:53 -0700879}
880
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530881/*
882 * sme_update_config() - Change configurations for all SME moduels
883 * The function updates some configuration for modules in SME, CSR, etc
884 * during SMEs close open sequence.
885 * Modules inside SME apply the new configuration at the next transaction.
886 * This is a synchronous call
887 *
888 * hHal - The handle returned by mac_open.
889 * pSmeConfigParams - a pointer to a caller allocated object of
890 * typedef struct _smeConfigParams.
891 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
892 * Other status means SME is failed to update the config parameters.
893 */
894QDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams
895 pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530897 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
899
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530900 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
902 0));
903 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700904 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 return status;
906 }
907
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530908 status = csr_change_default_config_param(pMac, &pSmeConfigParams->
909 csrConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530911 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700912 sme_err("csr_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914
Jeff Johnson711fe942018-06-09 23:37:01 -0700915 status = rrm_change_default_config_param(pMac, &pSmeConfigParams->
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530916 rrmConfig);
917
918 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700919 sme_err("rrm_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 status);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530921
922 /* For SOC, CFG is set before start We don't want to apply global CFG
923 * in connect state because that may cause some side affect
924 */
925 if (csr_is_all_session_disconnected(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 csr_set_global_cfgs(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927
928 /*
929 * If scan offload is enabled then lim has allow the sending of
930 * scan request to firmware even in powersave mode. The firmware has
931 * to take care of exiting from power save mode
932 */
933 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
934
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530935 if (QDF_STATUS_SUCCESS != status)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530936 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
Kapil Gupta4f0c0c12017-02-07 15:21:15 +0530938
939 pMac->snr_monitor_enabled = pSmeConfigParams->snr_monitor_enabled;
940
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 return status;
942}
943
944/**
Abhishek Singh158fe252017-03-23 11:09:34 +0530945 * sme_update_scan_roam_params() - Update the scan roaming params
946 * @mac_ctx: mac ctx
947 *
948 * Return: void.
949 */
950static void sme_update_scan_roam_params(tpAniSirGlobal mac_ctx)
951{
952 struct roam_filter_params scan_params = {0};
953 struct roam_ext_params *roam_params_src;
954 uint8_t i;
955 QDF_STATUS status;
956
957 roam_params_src = &mac_ctx->roam.configParam.roam_params;
958
959 scan_params.num_bssid_avoid_list =
960 roam_params_src->num_bssid_avoid_list;
Abhishek Singh158fe252017-03-23 11:09:34 +0530961
962 if (scan_params.num_bssid_avoid_list >
963 MAX_AVOID_LIST_BSSID)
964 scan_params.num_bssid_avoid_list =
965 MAX_AVOID_LIST_BSSID;
966
967 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
968 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
969 &roam_params_src->bssid_avoid_list[i]);
970 }
971
972 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
973 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700974 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +0530975 status);
976}
977
978/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 * sme_update_roam_params() - Store/Update the roaming params
980 * @hal: Handle for Hal layer
981 * @session_id: SME Session ID
982 * @roam_params_src: The source buffer to copy
983 * @update_param: Type of parameter to be updated
984 *
985 * Return: Return the status of the updation.
986 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530987QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -0700988 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 int update_param)
990{
991 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
992 struct roam_ext_params *roam_params_dst;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530993 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994 uint8_t i;
995
996 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
997 switch (update_param) {
998 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
999 roam_params_dst->raise_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001000 roam_params_src->raise_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 roam_params_dst->drop_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001002 roam_params_src->drop_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 roam_params_dst->raise_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001004 roam_params_src->raise_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005 roam_params_dst->drop_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001006 roam_params_src->drop_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007 roam_params_dst->max_raise_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001008 roam_params_src->max_raise_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 roam_params_dst->max_drop_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001010 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001012 roam_params_src->alert_rssi_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 roam_params_dst->is_5g_pref_enabled = true;
1014 break;
1015 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301016 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1018 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001019 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1021 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001022 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301023 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001024 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 roam_params_dst->ssid_allowed_list[i].length);
1026 }
1027 break;
1028 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301029 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1031 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001032 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301034 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001035 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 sizeof(tSirMacAddr));
1037 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001038 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039 }
1040 break;
1041 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301042 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301043 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001045 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301047 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001048 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 }
1050 break;
1051 case REASON_ROAM_GOOD_RSSI_CHANGED:
1052 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001053 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 break;
1055 default:
1056 break;
1057 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301058
1059 status = sme_acquire_global_lock(&mac_ctx->sme);
1060 if (QDF_IS_STATUS_SUCCESS(status)) {
1061 csr_roam_offload_scan(mac_ctx, session_id,
1062 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1063 update_param);
1064 sme_release_global_lock(&mac_ctx->sme);
1065 } else {
1066 sme_err("Failed to acquire SME lock");
1067 }
Abhishek Singh158fe252017-03-23 11:09:34 +05301068
1069 sme_update_scan_roam_params(mac_ctx);
1070
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 return 0;
1072}
1073
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001074/**
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301075 * sme_process_ready_to_suspend() -
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001076 * @mac: Global MAC context
1077 * @pReadyToSuspend: Parameter received along with ready to suspend
1078 * indication from WMA.
1079 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301080 * On getting ready to suspend indication, this function calls
1081 * callback registered (HDD callbacks) with SME to inform ready
1082 * to suspend indication.
1083 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301084 * Return: None
1085 */
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001086static void sme_process_ready_to_suspend(tpAniSirGlobal mac,
Jeff Johnson49c02f92016-10-07 10:29:09 -07001087 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088{
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001089 if (NULL == mac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301090 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001091 "%s: mac is null", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 return;
1093 }
1094
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001095 if (NULL != mac->readyToSuspendCallback) {
1096 mac->readyToSuspendCallback(mac->readyToSuspendContext,
1097 pReadyToSuspend->suspended);
1098 mac->readyToSuspendCallback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099 }
1100}
1101
1102#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001104/**
1105 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001106 * @mac: Global MAC context
1107 * @indication: ready to Ext WoW indication from lower layer
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001108 *
1109 * On getting ready to Ext WoW indication, this function calls callback
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001110 * registered (HDD callback) with SME to inform ready to ExtWoW indication.
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001111 *
1112 * Return: None
1113 */
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001114static void sme_process_ready_to_ext_wow(tpAniSirGlobal mac,
1115 tpSirReadyToExtWoWInd indication)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001116{
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001117 if (!mac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301118 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001119 "%s: mac is null", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120 return;
1121 }
1122
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001123 if (NULL != mac->readyToExtWoWCallback) {
1124 mac->readyToExtWoWCallback(mac->readyToExtWoWContext,
1125 indication->status);
1126 mac->readyToExtWoWCallback = NULL;
1127 mac->readyToExtWoWContext = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 }
1129
1130}
1131#endif
1132
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301133/*
1134 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1135 * that the NIC is ready tio run.
1136 * The function is called by HDD at the end of initialization stage so PE/HAL
1137 * can enable the NIC to running state.
1138 * This is a synchronous call
1139 *
1140 * @hHal - The handle returned by mac_open.
1141 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1142 * successfully.
1143 * Other status means SME failed to send the message to PE.
1144 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301145QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146{
Abhishek Singhde410b72017-05-22 15:25:39 +05301147 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301148 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1150
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301151 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1153 do {
1154
Abhishek Singhde410b72017-05-22 15:25:39 +05301155 msg = qdf_mem_malloc(sizeof(*msg));
1156 if (!msg) {
1157 sme_err("Memory allocation failed! for msg");
1158 return QDF_STATUS_E_NOMEM;
1159 }
1160 msg->messageType = eWNI_SME_SYS_READY_IND;
1161 msg->length = sizeof(*msg);
Abhishek Singhde410b72017-05-22 15:25:39 +05301162 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001163 msg->sme_msg_cb = sme_process_msg_callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164
Jeff Johnsonc09caa42018-06-07 22:58:55 -07001165 status = u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)msg);
1166 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001167 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001168 break;
1169 }
1170
1171 status = csr_ready(pMac);
Jeff Johnsonc09caa42018-06-07 22:58:55 -07001172 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001173 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174 break;
1175 }
1176
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 pMac->sme.state = SME_STATE_READY;
1178 } while (0);
1179
1180 return status;
1181}
1182
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001183QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1184{
1185 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001186
1187 if (NULL == mac_ctx) {
1188 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1189 FL("Invalid MAC context"));
1190 return QDF_STATUS_E_FAILURE;
1191 }
1192
Jeff Johnsonc09caa42018-06-07 22:58:55 -07001193 return wlan_cfg_get_str(mac_ctx, WNI_CFG_VALID_CHANNEL_LIST,
1194 chan_list, list_len);
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001195}
1196
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07001197#ifdef WLAN_CONV_SPECTRAL_ENABLE
1198static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
1199{
1200 struct spectral_legacy_cbacks spectral_cb;
1201 QDF_STATUS status;
1202
1203 spectral_cb.vdev_get_chan_freq = sme_get_oper_chan_freq;
1204 spectral_cb.vdev_get_ch_width = sme_get_oper_ch_width;
1205 spectral_cb.vdev_get_sec20chan_freq_mhz = sme_get_sec20chan_freq_mhz;
1206 status = spectral_register_legacy_cb(mac_ctx->psoc, &spectral_cb);
1207
1208 return status;
1209}
1210#else
1211static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
1212{
1213 return QDF_STATUS_SUCCESS;
1214}
1215#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301216/*
1217 * sme_start() - Put all SME modules at ready state.
1218 * The function starts each module in SME, PMC, CSR, etc. . Upon
1219 * successfully return, all modules are ready to run.
1220 * This is a synchronous call
1221 *
1222 * hHal - The handle returned by mac_open.
1223 * Return QDF_STATUS_SUCCESS - SME is ready.
1224 * Other status means SME is failed to start
1225 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301226QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301228 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001230 struct policy_mgr_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231
1232 do {
1233 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301234 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001235 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 break;
1237 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001238 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001239 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001240 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1241 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1242 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1243 sme_cbacks.sme_soc_set_dual_mac_config =
1244 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001245 sme_cbacks.sme_change_mcc_beacon_interval =
1246 sme_change_mcc_beacon_interval;
1247 sme_cbacks.sme_get_ap_channel_from_scan =
1248 sme_get_ap_channel_from_scan;
1249 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001250 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1251 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001252 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001253 status);
1254 break;
1255 }
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07001256 sme_register_spectral_cb(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257 pMac->sme.state = SME_STATE_START;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07001259 /* START RRM */
1260 status = rrm_start(pMac);
1261 if (!QDF_IS_STATUS_SUCCESS(status)) {
1262 sme_err("Failed to start RRM");
1263 break;
1264 }
1265 } while (0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266 return status;
1267}
1268
Arif Hussaincd151632017-02-11 16:57:19 -08001269static QDF_STATUS dfs_msg_processor(tpAniSirGlobal mac,
1270 struct scheduler_msg *msg)
1271{
1272 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001273 struct csr_roam_info roam_info = { 0 };
Arif Hussaincd151632017-02-11 16:57:19 -08001274 tSirSmeCSAIeTxCompleteRsp *csa_ie_tx_complete_rsp;
1275 uint32_t session_id = 0;
1276 eRoamCmdStatus roam_status;
1277 eCsrRoamResult roam_result;
1278
1279 switch (msg->type) {
1280 case eWNI_SME_DFS_RADAR_FOUND:
1281 {
1282 session_id = msg->bodyval;
1283 roam_status = eCSR_ROAM_DFS_RADAR_IND;
1284 roam_result = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301285 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001286 "sapdfs: Radar indication event occurred");
1287 break;
1288 }
1289 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1290 {
1291 csa_ie_tx_complete_rsp =
1292 (tSirSmeCSAIeTxCompleteRsp *) msg->bodyptr;
1293 if (!csa_ie_tx_complete_rsp) {
1294 sme_err("eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND null msg");
1295 return QDF_STATUS_E_FAILURE;
1296 }
1297 session_id = csa_ie_tx_complete_rsp->sessionId;
1298 roam_status = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1299 roam_result = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301300 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001301 "eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND session=%d",
1302 session_id);
1303 break;
1304 }
1305 case eWNI_SME_DFS_CAC_COMPLETE:
1306 {
1307 session_id = msg->bodyval;
1308 roam_status = eCSR_ROAM_CAC_COMPLETE_IND;
1309 roam_result = eCSR_ROAM_RESULT_CAC_END_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301310 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001311 "sapdfs: Received eWNI_SME_DFS_CAC_COMPLETE vdevid%d",
1312 session_id);
1313 break;
1314 }
1315 default:
1316 {
1317 sme_err("Invalid DFS message: 0x%x", msg->type);
1318 status = QDF_STATUS_E_FAILURE;
1319 return status;
1320 }
1321 }
1322
1323 /* Indicate Radar Event to SAP */
1324 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1325 roam_status, roam_result);
1326 return status;
1327}
1328
1329
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301331/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 * Handle the unprotected management frame indication from LIM and
1333 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301334 */
Jeff Johnson2ef47442018-06-09 23:43:40 -07001335static QDF_STATUS
1336sme_unprotected_mgmt_frm_ind(tpAniSirGlobal mac,
1337 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301339 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001340 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1342
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001343 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1344 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1345 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346
1347 /* forward the mgmt frame to HDD */
Jeff Johnson2ef47442018-06-09 23:43:40 -07001348 csr_roam_call_callback(mac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1350
1351 return status;
1352}
1353#endif
1354
Kapil Gupta8878ad92017-02-13 11:56:04 +05301355QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1356{
1357 QDF_STATUS status = QDF_STATUS_SUCCESS;
1358 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Jeff Johnson172237b2017-11-07 15:32:59 -08001359 struct csr_roam_info *roamInfo;
Kapil Gupta8878ad92017-02-13 11:56:04 +05301360 eRoamCmdStatus roamStatus;
1361 eCsrRoamResult roamResult;
1362
1363 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
Krunal Soni3fa80e22018-01-09 14:16:02 -08001364 if (!roamInfo) {
1365 sme_err("mem alloc failed for roam info");
1366 return QDF_STATUS_E_FAILURE;
1367 }
Kapil Gupta8878ad92017-02-13 11:56:04 +05301368 roamInfo->dfs_event.sessionId = session_id;
1369
1370 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1371 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301372 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301373 "sapdfs: Updated new channel event");
1374
1375 /* Indicate channel Event to SAP */
1376 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1377 roamStatus, roamResult);
1378
1379 qdf_mem_free(roamInfo);
1380 return status;
1381}
1382
1383
Abhishek Singh518323d2015-10-19 17:42:01 +05301384/**
1385 * sme_extended_change_channel_ind()- function to indicate ECSA
1386 * action frame is received in lim to SAP
1387 * @mac_ctx: pointer to global mac structure
1388 * @msg_buf: contain new channel and session id.
1389 *
1390 * This function is called to post ECSA action frame
1391 * receive event to SAP.
1392 *
1393 * Return: success if msg indicated to SAP else return failure
1394 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301395static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301396 void *msg_buf)
1397{
1398 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301399 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301400 uint32_t session_id = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001401 struct csr_roam_info roamInfo = {0};
Abhishek Singh518323d2015-10-19 17:42:01 +05301402 eRoamCmdStatus roam_status;
1403 eCsrRoamResult roam_result;
1404
Abhishek Singh518323d2015-10-19 17:42:01 +05301405 ext_chan_ind = msg_buf;
1406 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001407 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301408 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301409 }
1410 session_id = ext_chan_ind->session_id;
1411 roamInfo.target_channel = ext_chan_ind->new_channel;
1412 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1413 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001414 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1415 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301416
1417 /* Indicate Ext Channel Change event to SAP */
1418 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1419 roam_status, roam_result);
1420 return status;
1421}
1422
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001423#ifdef FEATURE_WLAN_ESE
1424/**
1425 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1426 * @hHal: HAL handle
1427 * @sessionId: session id
1428 * @isEseIniFeatureEnabled: ese ini enabled
1429 *
1430 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1431 * isEseIniFeatureEnabled. This is a synchronous call
1432 *
1433 * Return: QDF_STATUS enumeration
1434 */
1435QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1436 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1437{
1438 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301439 QDF_STATUS status;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001440
1441 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1442 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301443 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001444 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1445 __func__,
1446 pMac->roam.configParam.isEseIniFeatureEnabled,
1447 isEseIniFeatureEnabled);
1448 return QDF_STATUS_SUCCESS;
1449 }
1450
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301451 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001452 "%s: EseEnabled is changed from %d to %d", __func__,
1453 pMac->roam.configParam.isEseIniFeatureEnabled,
1454 isEseIniFeatureEnabled);
1455 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001456 csr_neighbor_roam_update_fast_roaming_enabled(
1457 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001458
1459 if (true == isEseIniFeatureEnabled)
1460 sme_update_fast_transition_enabled(hHal, true);
1461
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301462 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
1463 status = sme_acquire_global_lock(&pMac->sme);
1464 if (QDF_IS_STATUS_SUCCESS(status)) {
1465 csr_roam_offload_scan(pMac, sessionId,
1466 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1467 REASON_ESE_INI_CFG_CHANGED);
1468 sme_release_global_lock(&pMac->sme);
1469 } else {
1470 sme_err("Failed to acquire SME lock");
1471 return status;
1472 }
1473 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001474 return QDF_STATUS_SUCCESS;
1475}
1476
1477/**
1478 * sme_set_plm_request() - set plm request
1479 * @hHal: HAL handle
1480 * @pPlmReq: Pointer to input plm request
1481 *
1482 * Return: QDF_STATUS enumeration
1483 */
1484QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1485{
1486 QDF_STATUS status;
1487 bool ret = false;
1488 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001489 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001490 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001491 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301492 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1493 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001494
1495 status = sme_acquire_global_lock(&pMac->sme);
1496 if (!QDF_IS_STATUS_SUCCESS(status))
1497 return status;
1498
1499 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001500 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001501 sme_release_global_lock(&pMac->sme);
1502 return QDF_STATUS_E_FAILURE;
1503 }
1504
1505 if (!pSession->sessionActive) {
1506 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1507 FL("Invalid Sessionid"));
1508 sme_release_global_lock(&pMac->sme);
1509 return QDF_STATUS_E_FAILURE;
1510 }
1511
1512 if (!pPlmReq->enable)
1513 goto send_plm_start;
1514 /* validating channel numbers */
1515 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1516 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1517 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001518 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1519 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001520 pPlmReq->plmChList[count])) {
1521 /* DFS channel is provided, no PLM bursts can be
1522 * transmitted. Ignoring these channels.
1523 */
1524 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301525 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001526 FL("DFS channel %d ignored for PLM"),
1527 pPlmReq->plmChList[count]);
1528 continue;
1529 }
1530 } else if (!ret) {
1531 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301532 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001533 FL("Unsupported channel %d ignored for PLM"),
1534 pPlmReq->plmChList[count]);
1535 continue;
1536 }
1537 ch_list[valid_count] = pPlmReq->plmChList[count];
1538 valid_count++;
1539 } /* End of for () */
1540
1541 /* Copying back the valid channel list to plm struct */
1542 qdf_mem_set((void *)pPlmReq->plmChList,
1543 pPlmReq->plmNumCh, 0);
1544 if (valid_count)
1545 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1546 valid_count);
1547 /* All are invalid channels, FW need to send the PLM
1548 * report with "incapable" bit set.
1549 */
1550 pPlmReq->plmNumCh = valid_count;
1551
1552send_plm_start:
1553 /* PLM START */
1554 msg.type = WMA_SET_PLM_REQ;
1555 msg.reserved = 0;
1556 msg.bodyptr = pPlmReq;
1557
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001558 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001559 &msg))) {
1560 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1561 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1562 sme_release_global_lock(&pMac->sme);
1563 return QDF_STATUS_E_FAILURE;
1564 }
1565
1566 sme_release_global_lock(&pMac->sme);
1567 return status;
1568}
1569
1570/**
1571 * sme_tsm_ie_ind() - sme tsm ie indication
Jeff Johnson24e65b52018-06-10 08:45:26 -07001572 * @mac: Global mac context
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001573 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 *
1575 * Handle the tsm ie indication from LIM and forward it to HDD.
1576 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001577 * Return: QDF_STATUS enumeration
1578 */
Jeff Johnson24e65b52018-06-10 08:45:26 -07001579static QDF_STATUS sme_tsm_ie_ind(tpAniSirGlobal mac,
1580 tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301582 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001583 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301585
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001586 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1587 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1588 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589 /* forward the tsm ie information to HDD */
Jeff Johnson24e65b52018-06-10 08:45:26 -07001590 csr_roam_call_callback(mac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301591 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 return status;
1593}
1594
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001595/**
1596 * sme_set_cckm_ie() - set cckm ie
1597 * @hHal: HAL handle
1598 * @sessionId: session id
1599 * @pCckmIe: Pointer to CCKM Ie
1600 * @cckmIeLen: Length of @pCckmIe
1601 *
1602 * Function to store the CCKM IE passed from supplicant and use
1603 * it while packing reassociation request.
1604 *
1605 * Return: QDF_STATUS enumeration
1606 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301607QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 uint8_t *pCckmIe, uint8_t cckmIeLen)
1609{
1610 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301611 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301612
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301614 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1616 sme_release_global_lock(&pMac->sme);
1617 }
1618 return status;
1619}
1620
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001621/**
1622 * sme_set_ese_beacon_request() - set ese beacon request
1623 * @hHal: HAL handle
1624 * @sessionId: session id
1625 * @pEseBcnReq: Ese beacon report
1626 *
1627 * function to set ESE beacon request parameters
1628 *
1629 * Return: QDF_STATUS enumeration
1630 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301631QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 const tCsrEseBeaconReq *pEseBcnReq)
1633{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001634 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1636 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1637 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1638 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301639 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1641
1642 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001643 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301644 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 }
1646
1647 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301648 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 sizeof(tCsrEseBeaconReq));
1650
1651 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301652 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001654 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301655 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 }
1657
1658 pSmeRrmContext->eseBcnReqInProgress = true;
1659
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001660 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661
1662 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1663 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301664 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 pSession->connectedProfile.bssid.bytes,
1666 sizeof(tSirMacAddr));
1667 pSmeBcnReportReq->channelInfo.channelNum = 255;
1668 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1669 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1670
1671 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1672 pBeaconReq =
1673 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1674 pSmeBcnReportReq->fMeasurementtype[counter] =
1675 pBeaconReq->scanMode;
1676 pSmeBcnReportReq->measurementDuration[counter] =
1677 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1678 pSmeBcnReportReq->channelList.channelNumber[counter] =
1679 pBeaconReq->channel;
1680 }
1681
1682 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1683
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301684 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 pSmeRrmContext->eseBcnReqInProgress = false;
1686
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301687 qdf_mem_free(pSmeBcnReportReq);
1688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 return status;
1690}
1691
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001692/**
1693 * sme_get_tsm_stats() - SME get tsm stats
1694 * @hHal: HAL handle
1695 * @callback: SME sends back the requested stats using the callback
1696 * @staId: The station ID for which the stats is requested for
1697 * @bssId: bssid
1698 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001699 * @tid: Traffic id
1700 *
1701 * API register a callback to get TSM Stats.
1702 *
1703 * Return: QDF_STATUS enumeration
1704 */
1705QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1706 tCsrTsmStatsCallback callback,
1707 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001708 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001709{
1710 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1711 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1712
1713 status = sme_acquire_global_lock(&pMac->sme);
1714 if (QDF_IS_STATUS_SUCCESS(status)) {
1715 status = csr_get_tsm_stats(pMac, callback,
1716 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001717 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001718 sme_release_global_lock(&pMac->sme);
1719 }
1720 return status;
1721}
1722
1723/**
1724 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1725 * @hHal: pointer HAL handle returned by mac_open
1726 * @sessionId: sme session id
1727 * @pChannelList: Output channel list
1728 * @numChannels: Output number of channels
1729 *
1730 * This routine is called to set ese roam scan channel list.
1731 * This is a synchronous call
1732 *
1733 * Return: QDF_STATUS
1734 */
1735QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1736 uint8_t sessionId,
1737 uint8_t *pChannelList,
1738 uint8_t numChannels)
1739{
1740 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1741 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001742 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1743 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001744 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1745 uint8_t newChannelList[128] = { 0 };
1746 uint8_t i = 0, j = 0;
1747
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001748 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1749 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1750 FL("Invalid sme session id: %d"), sessionId);
1751 return QDF_STATUS_E_INVAL;
1752 }
1753
1754 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1755 curchnl_list_info =
1756 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1757
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001758 status = sme_acquire_global_lock(&pMac->sme);
1759 if (!QDF_IS_STATUS_SUCCESS(status)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301760 sme_err("Failed to acquire SME lock");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001761 return status;
1762 }
1763 if (NULL != curchnl_list_info->ChannelList) {
1764 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1765 j += snprintf(oldChannelList + j,
1766 sizeof(oldChannelList) - j, "%d",
1767 curchnl_list_info->ChannelList[i]);
1768 }
1769 }
1770 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1771 pChannelList, numChannels,
1772 csr_get_current_band(hHal));
1773 if (QDF_IS_STATUS_SUCCESS(status)) {
1774 if (NULL != curchnl_list_info->ChannelList) {
1775 j = 0;
1776 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1777 j += snprintf(newChannelList + j,
1778 sizeof(newChannelList) - j, "%d",
1779 curchnl_list_info->ChannelList[i]);
1780 }
1781 }
1782 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1783 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1784 newChannelList, oldChannelList,
1785 pNeighborRoamInfo->neighborRoamState);
1786 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301787
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001788 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1789 csr_roam_offload_scan(pMac, sessionId,
1790 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1791 REASON_CHANNEL_LIST_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301792
1793 sme_release_global_lock(&pMac->sme);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001794 return status;
1795}
1796
1797#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798
Jeff Johnson49c02f92016-10-07 10:29:09 -07001799static
Jeff Johnsonbfc58a12018-06-10 08:49:08 -07001800QDF_STATUS sme_ibss_peer_info_response_handler(tpAniSirGlobal pMac,
Jeff Johnson49c02f92016-10-07 10:29:09 -07001801 tpSirIbssGetPeerInfoRspParams
1802 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001803{
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001804 if (NULL == pMac) {
1805 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1806 "%s: pMac is null", __func__);
1807 return QDF_STATUS_E_FAILURE;
1808 }
1809 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1810 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1811 "%s: HDD callback is null", __func__);
1812 return QDF_STATUS_E_FAILURE;
1813 }
1814 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1815 &pIbssPeerInfoParams->
1816 ibssPeerInfoRspParams);
1817 return QDF_STATUS_SUCCESS;
1818}
1819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1822 * @mac: Global MAC pointer
1823 * @msg: Dual mac config response
1824 *
1825 * Processes the dual mac configuration response and invokes the HDD callback
1826 * to process further
1827 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301828static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 uint8_t *msg)
1830{
1831 tListElem *entry = NULL;
1832 tSmeCmd *command = NULL;
1833 bool found;
1834 dual_mac_cb callback = NULL;
1835 struct sir_dual_mac_config_resp *param;
1836
1837 param = (struct sir_dual_mac_config_resp *)msg;
1838 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001839 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 /* Not returning. Need to check if active command list
1841 * needs to be freed
1842 */
1843 }
1844
Krunal Sonia8270f52017-02-23 19:51:25 -08001845 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001847 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301848 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849 }
1850
1851 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1852 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001853 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301854 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 }
1856
1857 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001858 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301859 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 }
1861
1862 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1863 if (callback) {
1864 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001865 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001867 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 callback(param->status,
1869 command->u.set_dual_mac_cmd.scan_config,
1870 command->u.set_dual_mac_cmd.fw_mode_config);
1871 }
1872 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001873 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 }
1875
Krunal Soni72dba662017-02-15 20:13:17 -08001876 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 if (found)
1878 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001879 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301881 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882}
1883
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001884/**
1885 * sme_process_antenna_mode_resp() - Process set antenna mode
1886 * response
1887 * @mac: Global MAC pointer
1888 * @msg: antenna mode response
1889 *
1890 * Processes the antenna mode response and invokes the HDD
1891 * callback to process further
1892 */
1893static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
1894 uint8_t *msg)
1895{
1896 tListElem *entry;
1897 tSmeCmd *command;
1898 bool found;
1899 antenna_mode_cb callback;
1900 struct sir_antenna_mode_resp *param;
1901
1902 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301903 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001904 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001905 /* Not returning. Need to check if active command list
1906 * needs to be freed
1907 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001908
Krunal Sonia8270f52017-02-23 19:51:25 -08001909 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001910 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001911 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001912 return QDF_STATUS_E_FAILURE;
1913 }
1914
1915 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1916 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001917 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001918 return QDF_STATUS_E_FAILURE;
1919 }
1920
1921 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001922 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001923 return QDF_STATUS_E_FAILURE;
1924 }
1925
1926 callback =
1927 command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
1928 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301929 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001930 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301931 else
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001932 callback(param->status);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001933 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001934 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001935 }
1936
Krunal Soni72dba662017-02-15 20:13:17 -08001937 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001938 if (found)
1939 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001940 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001941
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001942 return QDF_STATUS_SUCCESS;
1943}
1944
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -07001945QDF_STATUS sme_process_msg(tpAniSirGlobal pMac, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301947 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05301948 struct sir_peer_info *peer_stats;
1949 struct sir_peer_info_resp *peer_info_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950
1951 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001952 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 return status;
1954 }
1955 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301956 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001957 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301959 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 return status;
1961 }
1962 if (!SME_IS_START(pMac)) {
Rajeev Kumar3887f9b2018-01-10 11:24:01 -08001963 sme_debug("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301965 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 goto release_lock;
1967 }
1968 switch (pMsg->type) {
1969#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301971 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
1973 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301974 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 break;
1976#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977 case WNI_CFG_SET_CNF:
1978 case WNI_CFG_DNLD_CNF:
1979 case WNI_CFG_GET_RSP:
1980 case WNI_CFG_ADD_GRP_ADDR_CNF:
1981 case WNI_CFG_DEL_GRP_ADDR_CNF:
1982 break;
1983 case eWNI_SME_ADDTS_RSP:
1984 case eWNI_SME_DELTS_RSP:
1985 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 /* QoS */
1988 if (pMsg->bodyptr) {
1989#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1990 status = sme_qos_msg_processor(pMac, pMsg->type,
1991 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301992 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993#endif
1994 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001995 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 }
1997 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 case eWNI_SME_NEIGHBOR_REPORT_IND:
1999 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 if (pMsg->bodyptr) {
2001 status = sme_rrm_msg_processor(pMac, pMsg->type,
2002 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302003 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302005 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 }
2007 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 case eWNI_SME_ADD_STA_SELF_RSP:
2009 if (pMsg->bodyptr) {
2010 status = csr_process_add_sta_session_rsp(pMac,
2011 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302012 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002014 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 }
2016 break;
2017 case eWNI_SME_DEL_STA_SELF_RSP:
2018 if (pMsg->bodyptr) {
2019 status = csr_process_del_sta_session_rsp(pMac,
2020 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302021 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002023 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 }
2025 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2027 if (pMsg->bodyptr) {
2028 status = sme_handle_generic_change_country_code(
2029 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302030 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002032 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 }
2034 break;
Sandeep Puligilla8d6011b2017-11-08 00:06:18 -08002035
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002036#ifdef WLAN_FEATURE_11W
2037 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2038 if (pMsg->bodyptr) {
2039 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302040 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002042 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 }
2044 break;
2045#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002046#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 case eWNI_SME_TSM_IE_IND:
2048 if (pMsg->bodyptr) {
2049 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302050 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002052 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 }
2054 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002055#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2057 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2058 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302059 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002061 case eWNI_SME_IBSS_PEER_INFO_RSP:
2062 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002063 sme_ibss_peer_info_response_handler(pMac,
2064 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002065 qdf_mem_free(pMsg->bodyptr);
2066 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002067 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002068 }
2069 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 case eWNI_SME_READY_TO_SUSPEND_IND:
2071 if (pMsg->bodyptr) {
2072 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302073 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002075 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 }
2077 break;
2078#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2079 case eWNI_SME_READY_TO_EXTWOW_IND:
2080 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002081 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302082 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002084 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 }
2086 break;
2087#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2089 case eWNI_SME_AUTO_SHUTDOWN_IND:
2090 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302091 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 FL("Auto shutdown notification"));
2093 pMac->sme.pAutoShutdownNotificationCb();
2094 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302095 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 break;
2097#endif
2098 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002099 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Arif Hussaincd151632017-02-11 16:57:19 -08002101 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302102 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 break;
2104 case eWNI_SME_CHANNEL_CHANGE_RSP:
2105 if (pMsg->bodyptr) {
2106 status = sme_process_channel_change_resp(pMac,
2107 pMsg->type,
2108 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302109 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002111 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 }
2113 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 case eWNI_SME_STATS_EXT_EVENT:
Jeff Johnsonfdecd512018-06-10 09:18:32 -07002115 status = sme_stats_ext_event(pMac, pMsg->bodyptr);
2116 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 break;
Will Huang558f8082017-05-31 16:22:24 +08002118 case eWNI_SME_GET_PEER_INFO_IND:
2119 if (pMac->sme.pget_peer_info_ind_cb)
2120 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2121 pMac->sme.pget_peer_info_cb_context);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302122 if (pMsg->bodyptr) {
2123 peer_info_rsp = (struct sir_peer_info_resp *)
2124 (pMsg->bodyptr);
2125 peer_stats = (struct sir_peer_info *)
2126 (peer_info_rsp->info);
2127 if (peer_stats) {
2128 pMac->peer_rssi = peer_stats[0].rssi;
2129 pMac->peer_txrate = peer_stats[0].tx_rate;
2130 pMac->peer_rxrate = peer_stats[0].rx_rate;
2131 }
2132 }
Will Huang558f8082017-05-31 16:22:24 +08002133 qdf_mem_free(pMsg->bodyptr);
2134 break;
2135 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2136 if (pMac->sme.pget_peer_info_ext_ind_cb)
2137 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2138 pMac->sme.pget_peer_info_ext_cb_context);
2139 qdf_mem_free(pMsg->bodyptr);
2140 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 case eWNI_SME_CSA_OFFLOAD_EVENT:
2142 if (pMsg->bodyptr) {
2143 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302144 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 }
2146 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002147 case eWNI_SME_TSF_EVENT:
2148 if (pMac->sme.get_tsf_cb) {
2149 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2150 (struct stsf *)pMsg->bodyptr);
2151 }
2152 if (pMsg->bodyptr)
2153 qdf_mem_free(pMsg->bodyptr);
2154 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155#ifdef WLAN_FEATURE_NAN
2156 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302157 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2158 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 if (pMsg->bodyptr) {
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -07002160 sme_nan_event(MAC_HANDLE(pMac), pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302161 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162 }
2163 break;
2164#endif /* WLAN_FEATURE_NAN */
2165 case eWNI_SME_LINK_STATUS_IND:
2166 {
2167 tAniGetLinkStatus *pLinkStatus =
2168 (tAniGetLinkStatus *) pMsg->bodyptr;
2169 if (pLinkStatus) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302170 if (pMac->sme.linkStatusCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 pMac->sme.linkStatusCallback(
2172 pLinkStatus->linkStatus,
2173 pMac->sme.linkStatusContext);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 pMac->sme.linkStatusCallback = NULL;
2176 pMac->sme.linkStatusContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302177 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178 }
2179 break;
2180 }
2181 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302182 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2184 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185 break;
2186 case eWNI_SME_SNR_IND:
2187 {
2188 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302189
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 if (pSnrReq) {
2191 if (pSnrReq->snrCallback) {
2192 ((tCsrSnrCallback)
2193 (pSnrReq->snrCallback))
2194 (pSnrReq->snr, pSnrReq->staId,
2195 pSnrReq->pDevContext);
2196 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302197 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 }
2199 break;
2200 }
2201#ifdef FEATURE_WLAN_EXTSCAN
2202 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2203 if (pMac->sme.pExtScanIndCb)
2204 pMac->sme.pExtScanIndCb(pMac->hHdd,
2205 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2206 pMsg->bodyptr);
2207 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002208 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 pMsg->type);
2210
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302211 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212 break;
2213 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2214 if (pMac->sme.pExtScanIndCb)
2215 pMac->sme.pExtScanIndCb(pMac->hHdd,
2216 eSIR_EPNO_NETWORK_FOUND_IND,
2217 pMsg->bodyptr);
2218 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002219 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 pMsg->type);
2221
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302222 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 break;
2224#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 case eWNI_SME_SET_HW_MODE_RESP:
2226 if (pMsg->bodyptr) {
2227 status = sme_process_set_hw_mode_resp(pMac,
2228 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302229 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002231 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 }
2233 break;
2234 case eWNI_SME_HW_MODE_TRANS_IND:
2235 if (pMsg->bodyptr) {
2236 status = sme_process_hw_mode_trans_ind(pMac,
2237 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302238 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002240 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 }
2242 break;
2243 case eWNI_SME_NSS_UPDATE_RSP:
2244 if (pMsg->bodyptr) {
2245 status = sme_process_nss_update_resp(pMac,
2246 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302247 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002249 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 }
2251 break;
2252 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302253 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 pMac->sme.ocb_set_config_callback(
2255 pMac->sme.ocb_set_config_context,
2256 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302257 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002258 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 pMac->sme.ocb_set_config_callback = NULL;
2260 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302261 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262 break;
2263 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302264 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 pMac->sme.ocb_get_tsf_timer_callback(
2266 pMac->sme.ocb_get_tsf_timer_context,
2267 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302268 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002269 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2271 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302272 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 break;
2274 case eWNI_SME_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302275 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 pMac->sme.dcc_get_stats_callback(
2277 pMac->sme.dcc_get_stats_context,
2278 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302279 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002280 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 pMac->sme.dcc_get_stats_callback = NULL;
2282 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302283 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 break;
2285 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302286 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 pMac->sme.dcc_update_ndl_callback(
2288 pMac->sme.dcc_update_ndl_context,
2289 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302290 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002291 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292 pMac->sme.dcc_update_ndl_callback = NULL;
2293 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302294 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 break;
2296 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302297 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 pMac->sme.dcc_stats_event_callback(
2299 pMac->sme.dcc_stats_event_context,
2300 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302301 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002302 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302303 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304 break;
2305 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2306 if (pMsg->bodyptr) {
2307 status = sme_process_dual_mac_config_resp(pMac,
2308 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302309 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002311 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 }
gaurank kathpaliaebe3fc82018-05-07 09:39:46 +05302313 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2315 if (pMac->sme.set_thermal_level_cb)
2316 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2317 pMsg->bodyval);
2318 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302319 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2320 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302321 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302322 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002323 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2324 if (pMsg->bodyptr) {
2325 status = sme_process_antenna_mode_resp(pMac,
2326 pMsg->bodyptr);
2327 qdf_mem_free(pMsg->bodyptr);
2328 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002329 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002330 }
2331 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302332 case eWNI_SME_LOST_LINK_INFO_IND:
2333 if (pMac->sme.lost_link_info_cb)
2334 pMac->sme.lost_link_info_cb(pMac->hHdd,
2335 (struct sir_lost_link_info *)pMsg->bodyptr);
2336 qdf_mem_free(pMsg->bodyptr);
2337 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302338 case eWNI_SME_RSO_CMD_STATUS_IND:
2339 if (pMac->sme.rso_cmd_status_cb)
2340 pMac->sme.rso_cmd_status_cb(pMac->hHdd, pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002341 qdf_mem_free(pMsg->bodyptr);
2342 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002343 case eWMI_SME_LL_STATS_IND:
2344 if (pMac->sme.link_layer_stats_ext_cb)
2345 pMac->sme.link_layer_stats_ext_cb(pMac->hHdd,
2346 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302347 qdf_mem_free(pMsg->bodyptr);
2348 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302349 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2350 if (pMac->sme.bt_activity_info_cb)
2351 pMac->sme.bt_activity_info_cb(pMac->hHdd,
2352 pMsg->bodyval);
2353 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 default:
2355
2356 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2357 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2358 /* CSR */
2359 if (pMsg->bodyptr) {
Jeff Johnsone0349a02018-06-10 11:31:06 -07002360 status = csr_msg_processor(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302361 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302362 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002363 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002365 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302367 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 }
2369 } /* switch */
2370release_lock:
2371 sme_release_global_lock(&pMac->sme);
2372 return status;
2373}
2374
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002375QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2376{
2377 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2378
2379 if (mac_ctx == NULL) {
2380 QDF_ASSERT(0);
2381 return QDF_STATUS_E_FAILURE;
2382 }
2383
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -07002384 return sme_process_msg(mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002385}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002386
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387/**
2388 * sme_process_nss_update_resp() - Process nss update response
2389 * @mac: Global MAC pointer
2390 * @msg: nss update response
2391 *
2392 * Processes the nss update response and invokes the HDD
2393 * callback to process further
2394 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302395static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396{
2397 tListElem *entry = NULL;
2398 tSmeCmd *command = NULL;
2399 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08002400 policy_mgr_nss_update_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401 struct sir_beacon_tx_complete_rsp *param;
2402
2403 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302404 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002405 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 /* Not returning. Need to check if active command list
2407 * needs to be freed
2408 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409
Krunal Sonia8270f52017-02-23 19:51:25 -08002410 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002412 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302413 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 }
2415
2416 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2417 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002418 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302419 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 }
2421
2422 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002423 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302424 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 }
2426
2427 callback = command->u.nss_update_cmd.nss_update_cb;
2428 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302429 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002430 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302431 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432 callback(command->u.nss_update_cmd.context,
2433 param->tx_status,
2434 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302435 command->u.nss_update_cmd.next_action,
2436 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002438 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 }
2440
Krunal Soni72dba662017-02-15 20:13:17 -08002441 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 if (found) {
2443 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002444 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002445 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002446
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302447 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448}
2449
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302450/*
2451 * sme_stop() - Stop all SME modules and put them at idle state
2452 *
2453 * The function stops each module in SME, PMC, CSR, etc. . Upon
2454 * return, all modules are at idle state ready to start.
2455 * This is a synchronous call
2456 *
2457 * hHal - The handle returned by mac_open
2458 * tHalStopType - reason for stopping
2459 * Return QDF_STATUS_SUCCESS - SME is stopped.
2460 * Other status means SME is failed to stop but caller should still
2461 * consider SME is stopped.
2462 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302463QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302465 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2466 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2468
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002469 status = rrm_stop(pMac);
2470 if (!QDF_IS_STATUS_SUCCESS(status)) {
2471 sme_err("rrm_stop failed with status: %d", status);
2472 }
2473
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 status = csr_stop(pMac, stopType);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302475 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002476 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 fail_status = status;
2478 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302480 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482
2483 pMac->sme.state = SME_STATE_STOP;
2484
2485 return status;
2486}
2487
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302488/*
2489 * sme_close() - Release all SME modules and their resources.
2490 * The function release each module in SME, PMC, CSR, etc. . Upon
2491 * return, all modules are at closed state.
2492 *
2493 * No SME APIs can be involved after smeClose except smeOpen.
2494 * smeClose must be called before mac_close.
2495 * This is a synchronous call
2496 *
2497 * hHal - The handle returned by mac_open
2498 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2499 *
2500 * Other status means SME is failed to be closed but caller still cannot
2501 * call any other SME functions except smeOpen.
2502 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302503QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302505 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2506 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2508
2509 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302510 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511
2512 /* Note: pSession will be invalid from here on, do not access */
2513 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302514 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002515 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 fail_status = status;
2517 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2519 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302520 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002521 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 fail_status = status;
2523 }
2524#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302526 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002527 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 fail_status = status;
2529 }
2530
Jeff Johnson3639a642018-06-09 23:47:44 -07002531 status = rrm_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302532 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002533 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 fail_status = status;
2535 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 free_sme_cmd_list(pMac);
2538
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302539 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302540 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302541 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302543 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545
2546 pMac->sme.state = SME_STATE_STOP;
2547
2548 return status;
2549}
2550
2551/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302552 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2553 * scan list
2554 * @hal: hal context.
2555 * @bssid: bssid to be removed
2556 *
2557 * This function remove the given bssid from scan list.
2558 *
2559 * Return: QDF status.
2560 */
2561QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2562 tSirMacAddr bssid)
2563{
2564 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2565 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2566
2567 status = sme_acquire_global_lock(&mac_ctx->sme);
2568 if (QDF_IS_STATUS_SUCCESS(status)) {
2569 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2570 sme_release_global_lock(&mac_ctx->sme);
2571 }
2572
2573 return status;
2574}
2575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302577/*
2578 * sme_scan_get_result
2579 * A wrapper function to request scan results from CSR.
2580 * This is a synchronous call
2581 *
2582 * pFilter - If pFilter is NULL, all cached results are returned
2583 * phResult - an object for the result.
2584 * Return QDF_STATUS
2585 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302586QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 tCsrScanResultFilter *pFilter,
2588 tScanResultHandle *phResult)
2589{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302590 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2592
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302593 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2595 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302597 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnsonadf800d2018-06-10 18:00:00 -07002598 status = csr_scan_get_result(pMac, pFilter, phResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 sme_release_global_lock(&pMac->sme);
2600 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601
2602 return status;
2603}
2604
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05302605QDF_STATUS sme_scan_get_result_for_bssid(tHalHandle hal_handle,
2606 struct qdf_mac_addr *bssid,
2607 tCsrScanResultInfo *res)
2608{
2609 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
2610 QDF_STATUS status;
2611
2612 status = sme_acquire_global_lock(&mac_ctx->sme);
2613 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson1b56f6b2018-06-10 18:17:10 -07002614 status = csr_scan_get_result_for_bssid(mac_ctx, bssid, res);
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05302615 sme_release_global_lock(&mac_ctx->sme);
2616 }
2617
2618 return status;
2619}
2620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002622 * sme_get_ap_channel_from_scan() - a wrapper function to get
Srinivas Girigowda828ef232017-10-13 22:31:27 -07002623 * AP's channel id from
2624 * CSR by filtering the
2625 * result which matches
2626 * our roam profile.
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002627 * @profile: SAP profile
2628 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2629 * best ap from scan cache.
2630 *
2631 * This function is written to get AP's channel id from CSR by filtering
2632 * the result which matches our roam profile. This is a synchronous call.
2633 *
2634 * Return: QDF_STATUS.
2635 */
2636QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2637 tScanResultHandle *scan_cache,
2638 uint8_t *ap_chnl_id)
2639{
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002640 return sme_get_ap_channel_from_scan_cache((struct csr_roam_profile *)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002641 profile,
2642 scan_cache,
2643 ap_chnl_id);
2644}
2645
2646/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2648 * channel id from CSR by filtering the
2649 * result which matches our roam profile.
2650 * @profile: SAP adapter
2651 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2652 * best ap from scan cache.
2653 *
2654 * This function is written to get AP's channel id from CSR by filtering
2655 * the result which matches our roam profile. This is a synchronous call.
2656 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302657 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002659QDF_STATUS sme_get_ap_channel_from_scan_cache(
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002660 struct csr_roam_profile *profile, tScanResultHandle *scan_cache,
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002661 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302663 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002664 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 tCsrScanResultFilter *scan_filter = NULL;
2666 tScanResultHandle filtered_scan_result = NULL;
2667 tSirBssDescription first_ap_profile;
2668
2669 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302670 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302672 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302674 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302676 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302678 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302679 }
2680 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2681 if (NULL == profile) {
2682 scan_filter->EncryptionType.numEntries = 1;
2683 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302685 } else {
2686 /* Here is the profile we need to connect to */
2687 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 profile,
2689 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302690 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002691
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302692 if (QDF_STATUS_SUCCESS == status) {
2693 /* Save the WPS info */
2694 if (NULL != profile) {
2695 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302697 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302700 scan_filter->bWPSAssociation = 0;
2701 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302703 } else {
2704 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2705 FL("Preparing the profile filter failed"));
2706 qdf_mem_free(scan_filter);
2707 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 }
2709 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302710 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002711 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302713 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2715 &first_ap_profile);
2716 *scan_cache = filtered_scan_result;
2717 if (0 != first_ap_profile.channelId) {
2718 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302719 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05302720 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 FL("Found best AP & its on chnl[%d]"),
2722 first_ap_profile.channelId);
2723 } else {
2724 /*
2725 * This means scan result is empty
2726 * so set the channel to zero, caller should
2727 * take of zero channel id case.
2728 */
2729 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302730 QDF_TRACE(QDF_MODULE_ID_SME,
2731 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302733 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 }
2735 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302736 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 FL("Failed to get scan get result"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302738 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 }
2740 csr_free_scan_filter(mac_ctx, scan_filter);
2741 sme_release_global_lock(&mac_ctx->sme);
2742 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302743 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08002745 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302746 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302748 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 return status;
2750}
2751
2752/**
2753 * sme_store_joinreq_param() - This function will pass station's join
2754 * request to store to csr.
2755 * @hal_handle: pointer to hal context.
2756 * @profile: pointer to station's roam profile.
2757 * @scan_cache: pointer to station's scan cache.
2758 * @roam_id: reference to roam_id variable being passed.
2759 * @session_id: station's session id.
2760 *
2761 * This function will pass station's join request further down to csr
2762 * to store it. this stored parameter will be used later.
2763 *
2764 * Return: true or false based on function's overall success.
2765 **/
2766bool sme_store_joinreq_param(tHalHandle hal_handle,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002767 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 tScanResultHandle scan_cache,
2769 uint32_t *roam_id,
2770 uint32_t session_id)
2771{
2772 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302773 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 bool ret_status = true;
2775
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302776 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
2778 session_id, 0));
2779 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302780 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302782 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784 sme_release_global_lock(&mac_ctx->sme);
2785 } else {
2786 ret_status = false;
2787 }
2788
2789 return ret_status;
2790}
2791
2792/**
2793 * sme_clear_joinreq_param() - This function will pass station's clear
2794 * the join request to csr.
2795 * @hal_handle: pointer to hal context.
2796 * @session_id: station's session id.
2797 *
2798 * This function will pass station's clear join request further down to csr
2799 * to cleanup.
2800 *
2801 * Return: true or false based on function's overall success.
2802 **/
2803bool sme_clear_joinreq_param(tHalHandle hal_handle,
2804 uint32_t session_id)
2805{
2806 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302807 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 bool ret_status = true;
2809
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302810 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
2812 session_id, 0));
2813 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302814 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302816 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 sme_release_global_lock(&mac_ctx->sme);
2819 } else {
2820 ret_status = false;
2821 }
2822
2823 return ret_status;
2824}
2825
2826/**
2827 * sme_issue_stored_joinreq() - This function will issues station's stored
2828 * the join request to csr.
2829 * @hal_handle: pointer to hal context.
2830 * @roam_id: reference to roam_id variable being passed.
2831 * @session_id: station's session id.
2832 *
2833 * This function will issue station's stored join request further down to csr
2834 * to proceed forward.
2835 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302836 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302838QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839 uint32_t *roam_id,
2840 uint32_t session_id)
2841{
2842 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302843 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2844 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302846 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
2848 session_id, 0));
2849 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302850 if (QDF_STATUS_SUCCESS == status) {
2851 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 roam_id,
2853 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302854 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 }
2856 sme_release_global_lock(&mac_ctx->sme);
2857 } else {
2858 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302859 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 }
2861 return ret_status;
2862}
2863
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302864/*
2865 * sme_scan_flush_result() -
2866 * A wrapper function to request CSR to clear scan results.
2867 * This is a synchronous call
2868 *
2869 * Return QDF_STATUS
2870 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302871QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302873 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2875
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302876 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2878 0, 0));
2879 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302880 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnsona1a36512018-06-10 18:20:55 -07002881 status = csr_scan_flush_result(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882 sme_release_global_lock(&pMac->sme);
2883 }
2884
2885 return status;
2886}
2887
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302888/*
2889 * sme_filter_scan_results() -
2890 * A wrapper function to request CSR to clear scan results.
2891 * This is a synchronous call
2892 *
2893 * tHalHandle - HAL context handle
2894 * sessionId - session id
2895 * Return QDF_STATUS
2896 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302897QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302899 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2901
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302902 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2904 sessionId, 0));
2905 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302906 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 csr_scan_filter_results(pMac);
2908 sme_release_global_lock(&pMac->sme);
2909 }
2910
2911 return status;
2912}
2913
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302914QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302916 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2918
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302919 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
2921 sessionId, 0));
2922 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302923 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson1d3f8672018-06-10 18:24:15 -07002924 status = csr_scan_flush_selective_result(pMac, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925 sme_release_global_lock(&pMac->sme);
2926 }
2927
2928 return status;
2929}
2930
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302931/*
2932 * sme_scan_result_get_first() -
2933 * A wrapper function to request CSR to returns the first element of
2934 * scan result.
2935 * This is a synchronous call
2936 *
2937 * hScanResult - returned from csr_scan_get_result
2938 * Return tCsrScanResultInfo * - NULL if no result
2939 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
2941 tScanResultHandle hScanResult)
2942{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302943 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002944 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2945 tCsrScanResultInfo *pRet = NULL;
2946
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302947 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002948 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
2949 NO_SESSION, 0));
2950 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302951 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 pRet = csr_scan_result_get_first(pMac, hScanResult);
2953 sme_release_global_lock(&pMac->sme);
2954 }
2955
2956 return pRet;
2957}
2958
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302959/*
2960 * sme_scan_result_get_next() -
2961 * A wrapper function to request CSR to returns the next element of
2962 * scan result. It can be called without calling csr_scan_result_get_first first
2963 * This is a synchronous call
2964 *
2965 * hScanResult - returned from csr_scan_get_result
2966 * Return Null if no result or reach the end
2967 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
2969 tScanResultHandle hScanResult)
2970{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302971 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2973 tCsrScanResultInfo *pRet = NULL;
2974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302976 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 pRet = csr_scan_result_get_next(pMac, hScanResult);
2978 sme_release_global_lock(&pMac->sme);
2979 }
2980
2981 return pRet;
2982}
2983
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302984/*
2985 * sme_scan_result_purge() -
2986 * A wrapper function to request CSR to remove all items(tCsrScanResult)
2987 * in the list and free memory for each item
2988 * This is a synchronous call
2989 *
2990 * hScanResult - returned from csr_scan_get_result. hScanResult is
2991 * considered gone by
2992 * calling this function and even before this function reutrns.
2993 * Return QDF_STATUS
2994 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002995QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302997 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002998 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002999
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303000 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3002 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003003 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303004 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003005 status = csr_scan_result_purge(mac_ctx, hScanResult);
3006 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 }
3008
3009 return status;
3010}
3011
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3013{
3014 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303015
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 return pMac->roam.configParam.phyMode;
3017}
3018
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303019/*
jiadbdefb252018-01-03 14:27:06 +08003020 * sme_get_channel_bonding_mode5_g() - get the channel bonding mode for 5G band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303021 *
3022 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003023 * mode - channel bonding mode
3024 *
3025 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303026 */
jiadbdefb252018-01-03 14:27:06 +08003027QDF_STATUS sme_get_channel_bonding_mode5_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028{
jiadbdefb252018-01-03 14:27:06 +08003029 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030
jiadbdefb252018-01-03 14:27:06 +08003031 if (!mode) {
3032 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3033 "%s: invalid mode", __func__);
3034 return QDF_STATUS_E_FAILURE;
3035 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036
jiadbdefb252018-01-03 14:27:06 +08003037 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3038 if (!smeConfig) {
3039 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3040 "%s: failed to alloc smeConfig", __func__);
3041 return QDF_STATUS_E_NOMEM;
3042 }
3043
Jeff Johnson0a38afe2018-06-09 23:11:27 -07003044 if (sme_get_config_param(hHal, smeConfig) != QDF_STATUS_SUCCESS) {
jiadbdefb252018-01-03 14:27:06 +08003045 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3046 "%s: sme_get_config_param failed", __func__);
3047 qdf_mem_free(smeConfig);
3048 return QDF_STATUS_E_FAILURE;
3049 }
3050
3051 *mode = smeConfig->csrConfig.channelBondingMode5GHz;
3052 qdf_mem_free(smeConfig);
3053
3054 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055}
3056
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303057/*
jiadbdefb252018-01-03 14:27:06 +08003058 * sme_get_channel_bonding_mode24_g() - get the channel bonding mode for 2.4G
3059 * band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303060 *
3061 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003062 * mode - channel bonding mode
3063 *
3064 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303065 */
jiadbdefb252018-01-03 14:27:06 +08003066QDF_STATUS sme_get_channel_bonding_mode24_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067{
jiadbdefb252018-01-03 14:27:06 +08003068 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069
jiadbdefb252018-01-03 14:27:06 +08003070 if (!mode) {
3071 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3072 "%s: invalid mode", __func__);
3073 return QDF_STATUS_E_FAILURE;
3074 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003075
jiadbdefb252018-01-03 14:27:06 +08003076 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3077 if (!smeConfig) {
3078 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3079 "%s: failed to alloc smeConfig", __func__);
3080 return QDF_STATUS_E_NOMEM;
3081 }
3082
Jeff Johnson0a38afe2018-06-09 23:11:27 -07003083 if (sme_get_config_param(hHal, smeConfig) != QDF_STATUS_SUCCESS) {
jiadbdefb252018-01-03 14:27:06 +08003084 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3085 "%s: sme_get_config_param failed", __func__);
3086 qdf_mem_free(smeConfig);
3087 return QDF_STATUS_E_FAILURE;
3088 }
3089
3090 *mode = smeConfig->csrConfig.channelBondingMode24GHz;
3091 qdf_mem_free(smeConfig);
3092
3093 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094}
3095
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303096/*
3097 * sme_roam_connect() -
3098 * A wrapper function to request CSR to inititiate an association
3099 * This is an asynchronous call.
3100 *
3101 * sessionId - the sessionId returned by sme_open_session.
3102 * pProfile - description of the network to which to connect
3103 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3104 * from csr_scan_get_result
3105 * pRoamId - to get back the request ID
3106 * Return QDF_STATUS
3107 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303108QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07003109 struct csr_roam_profile *pProfile,
3110 uint32_t *pRoamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303112 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3114
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303115 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303116 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303118 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303121 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3123 status =
3124 csr_roam_connect(pMac, sessionId, pProfile,
3125 pRoamId);
3126 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003127 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303128 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 }
3130 sme_release_global_lock(&pMac->sme);
3131 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003132 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 }
3134
3135 return status;
3136}
3137
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303138/*
3139 * sme_set_phy_mode() -
3140 * Changes the PhyMode.
3141 *
3142 * hHal - The handle returned by mac_open.
3143 * phyMode new phyMode which is to set
3144 * Return QDF_STATUS SUCCESS.
3145 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303146QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147{
3148 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3149
3150 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303151 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 "%s: invalid context", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303153 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 }
3155
3156 pMac->roam.configParam.phyMode = phyMode;
3157 pMac->roam.configParam.uCfgDot11Mode =
3158 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303159 pMac->roam.configParam.phyMode,
3160 pMac->roam.configParam.
3161 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303163 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164}
3165
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303166/*
3167 * sme_roam_reassoc() -
3168 * A wrapper function to request CSR to inititiate a re-association
3169 *
3170 * pProfile - can be NULL to join the currently connected AP. In that
3171 * case modProfileFields should carry the modified field(s) which could trigger
3172 * reassoc
3173 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3174 * that might need modification dynamically once STA is up & running and this
3175 * could trigger a reassoc
3176 * pRoamId - to get back the request ID
3177 * Return QDF_STATUS
3178 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303179QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07003180 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 tCsrRoamModifyProfileFields modProfileFields,
3182 uint32_t *pRoamId, bool fForce)
3183{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303184 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3186
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303187 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303190 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303192 if ((NULL == pProfile) && (fForce == 1))
3193 status = csr_reassoc(pMac, sessionId,
3194 &modProfileFields, pRoamId,
3195 fForce);
3196 else
3197 status = csr_roam_reassoc(pMac, sessionId,
3198 pProfile,
3199 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303201 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 }
3203 sme_release_global_lock(&pMac->sme);
3204 }
3205
3206 return status;
3207}
3208
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303209/*
3210 * sme_roam_connect_to_last_profile() -
3211 * A wrapper function to request CSR to disconnect and reconnect with
3212 * the same profile
3213 * This is an asynchronous call.
3214 *
3215 * Return QDF_STATUS. It returns fail if currently connected
3216 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303217QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303219 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3221
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303222 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3224 sessionId, 0));
3225 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303226 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303227 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3228 status = csr_roam_connect_to_last_profile(pMac,
3229 sessionId);
3230 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303231 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 sme_release_global_lock(&pMac->sme);
3233 }
3234
3235 return status;
3236}
3237
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003238QDF_STATUS sme_roam_disconnect(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 eCsrRoamDisconnectReason reason)
3240{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303241 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003242 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303244 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003245 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246 reason));
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003247 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303248 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003249 if (CSR_IS_SESSION_VALID(mac_ctx, session_id))
3250 status = csr_roam_disconnect(mac_ctx, session_id,
3251 reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303252 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303253 status = QDF_STATUS_E_INVAL;
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003254 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 }
3256
3257 return status;
3258}
3259
Abhishek Singhca408032016-09-13 15:26:12 +05303260/* sme_dhcp_done_ind() - send dhcp done ind
3261 * @hal: hal context
3262 * @session_id: session id
3263 *
3264 * Return: void.
3265 */
3266void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3267{
3268 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303269 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303270
3271 if (!mac_ctx)
3272 return;
3273
3274 session = CSR_GET_SESSION(mac_ctx, session_id);
3275 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003276 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303277 return;
3278 }
3279 session->dhcp_done = true;
3280}
3281
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303282/*
3283 * sme_roam_stop_bss() -
3284 * To stop BSS for Soft AP. This is an asynchronous API.
3285 *
3286 * hHal - Global structure
3287 * sessionId - sessionId of SoftAP
3288 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3289 * actual results
3290 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303291QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303293 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3295
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303297 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303298 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3299 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
Himanshu Agarwal75c8d792017-12-19 18:31:04 +05303300 false);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303301 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303302 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 sme_release_global_lock(&pMac->sme);
3304 }
3305
3306 return status;
3307}
3308
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303309/**
3310 * sme_roam_disconnect_sta() - disassociate a station
3311 * @hHal: Global structure
3312 * @sessionId: SessionId of SoftAP
3313 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3314 *
3315 * To disassociate a station. This is an asynchronous API.
3316 *
3317 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3318 * be called to indicate actual result.
3319 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303320QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003321 struct csr_del_sta_params *p_del_sta_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303323 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3325
3326 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303327 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 return status;
3329 }
3330
3331 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303332 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303333 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303335 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303336 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303337 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 sme_release_global_lock(&pMac->sme);
3339 }
3340
3341 return status;
3342}
3343
3344/**
3345 * sme_roam_deauth_sta() - deauthenticate a station
3346 * @hHal: Global structure
3347 * @sessionId: SessionId of SoftAP
3348 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3349 *
3350 * To disassociate a station. This is an asynchronous API.
3351 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303352 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 * code on error. Roam callback will be called to indicate actual
3354 * result
3355 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303356QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003357 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303359 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3361
3362 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303363 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364 return status;
3365 }
3366
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303367 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303368 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3369 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303371 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303372 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373 status =
3374 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3375 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303376 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303377 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378 sme_release_global_lock(&pMac->sme);
3379 }
3380
3381 return status;
3382}
3383
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303384/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303385 * sme_roam_get_associated_stas() -
3386 * To probe the list of associated stations from various modules
3387 * of CORE stack.
3388 * This is an asynchronous API.
3389 *
3390 * sessionId - sessionId of SoftAP
3391 * modId - Module from whom list of associtated stations is
3392 * to be probed. If an invalid module is passed then
3393 * by default QDF_MODULE_ID_PE will be probed.
3394 * pUsrContext - Opaque HDD context
3395 * pfnSapEventCallback - Sap event callback in HDD
3396 * pAssocBuf - Caller allocated memory to be filled with associatd
3397 * stations info
3398 * Return QDF_STATUS
3399 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303400QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303401 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 void *pfnSapEventCallback,
3403 uint8_t *pAssocStasBuf)
3404{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303405 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3407
3408 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303409 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 return status;
3411 }
3412
3413 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303414 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303415 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303417 csr_roam_get_associated_stas(pMac, sessionId,
3418 modId,
3419 pUsrContext,
3420 pfnSapEventCallback,
3421 pAssocStasBuf);
3422 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303423 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 sme_release_global_lock(&pMac->sme);
3425 }
3426
3427 return status;
3428}
3429
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303430/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303431 * sme_roam_get_connect_state() -
3432 * A wrapper function to request CSR to return the current connect state
3433 * of Roaming
3434 * This is a synchronous call.
3435 *
3436 * Return QDF_STATUS
3437 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303438QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 eCsrConnectState *pState)
3440{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303441 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3443
3444 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303445 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303446 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3447 status = csr_roam_get_connect_state(pMac, sessionId,
3448 pState);
3449 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303450 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003451 sme_release_global_lock(&pMac->sme);
3452 }
3453
3454 return status;
3455}
3456
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303457/*
3458 * sme_roam_get_connect_profile() -
3459 * A wrapper function to request CSR to return the current connect
3460 * profile. Caller must call csr_roam_free_connect_profile after it is done
3461 * and before reuse for another csr_roam_get_connect_profile call.
3462 * This is a synchronous call.
3463 *
3464 * pProfile - pointer to a caller allocated structure
3465 * tCsrRoamConnectedProfile
3466 * eturn QDF_STATUS. Failure if not connected
3467 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303468QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 tCsrRoamConnectedProfile *pProfile)
3470{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303471 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3473
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303474 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3476 sessionId, 0));
3477 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303478 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303479 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3480 status = csr_roam_get_connect_profile(pMac, sessionId,
3481 pProfile);
3482 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303483 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 sme_release_global_lock(&pMac->sme);
3485 }
3486
3487 return status;
3488}
3489
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003490/**
3491 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3492 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3493 *
3494 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3495 *
3496 * Return: none
3497 */
3498void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303500 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3502 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003503 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504}
3505
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303506/*
3507 * sme_roam_set_pmkid_cache() -
3508 * A wrapper function to request CSR to return the PMKID candidate list
3509 * This is a synchronous call.
3510
3511 * pPMKIDCache - caller allocated buffer point to an array of
3512 * tPmkidCacheInfo
3513 * numItems - a variable that has the number of tPmkidCacheInfo
3514 * allocated when retruning, this is either the number needed
3515 * or number of items put into pPMKIDCache
3516 * update_entire_cache - this bool value specifies if the entire pmkid
3517 * cache should be overwritten or should it be
3518 * updated entry by entry.
3519 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3520 * big enough and pNumItems has the number of
3521 * tPmkidCacheInfo.
3522 * \Note: pNumItems is a number of tPmkidCacheInfo,
3523 * not sizeof(tPmkidCacheInfo) * something
3524 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303525QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 tPmkidCacheInfo *pPMKIDCache,
3527 uint32_t numItems, bool update_entire_cache)
3528{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303529 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3531
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303532 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3534 numItems));
3535 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303536 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303537 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3538 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3539 pPMKIDCache,
3540 numItems, update_entire_cache);
3541 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303542 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 sme_release_global_lock(&pMac->sme);
3544 }
3545
3546 return status;
3547}
3548
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303549QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303550 tPmkidCacheInfo *pmksa,
3551 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303553 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303555
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303556 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303557 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3558 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303560 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303561 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303563 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303564 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303565 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 sme_release_global_lock(&pMac->sme);
3567 }
3568 return status;
3569}
3570
gaurank kathpalia99d06c12018-05-16 16:28:35 +05303571void sme_get_pmk_info(tHalHandle hal, uint8_t session_id,
3572 tPmkidCacheInfo *pmk_cache)
3573{
3574 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
3575 QDF_STATUS status = sme_acquire_global_lock(&mac_ctx->sme);
3576
3577 if (QDF_IS_STATUS_SUCCESS(status)) {
3578 if (CSR_IS_SESSION_VALID(mac_ctx, session_id))
3579 csr_get_pmk_info(mac_ctx, session_id, pmk_cache);
3580 sme_release_global_lock(&mac_ctx->sme);
3581 }
3582}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303584/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 * \fn sme_roam_set_psk_pmk
3586 * \brief a wrapper function to request CSR to save PSK/PMK
3587 * This is a synchronous call.
3588 * \param hHal - Global structure
3589 * \param sessionId - SME sessionId
3590 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3591 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3592 * connections. Need to pass this information to
3593 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303594 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303596QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 uint8_t *pPSK_PMK, size_t pmk_len)
3598{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303599 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303603 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303604 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3605 status = csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303607 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303608 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 sme_release_global_lock(&pMac->sme);
3610 }
3611 return status;
3612}
3613#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614
Jeff Johnson0a078b52018-06-01 16:15:54 -07003615QDF_STATUS sme_roam_get_wpa_rsn_req_ie(tHalHandle hal, uint8_t session_id,
3616 uint32_t *len, uint8_t *buf)
3617{
3618 QDF_STATUS status;
3619 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3620
3621 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303622 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson0a078b52018-06-01 16:15:54 -07003623 if (CSR_IS_SESSION_VALID(mac, session_id))
3624 status = csr_roam_get_wpa_rsn_req_ie(mac, session_id,
3625 len, buf);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303626 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303627 status = QDF_STATUS_E_INVAL;
Jeff Johnson0a078b52018-06-01 16:15:54 -07003628 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 }
3630
3631 return status;
3632}
3633
Jeff Johnson0a078b52018-06-01 16:15:54 -07003634QDF_STATUS sme_roam_get_wpa_rsn_rsp_ie(tHalHandle hal, uint8_t session_id,
3635 uint32_t *len, uint8_t *buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636{
Jeff Johnson0a078b52018-06-01 16:15:54 -07003637 QDF_STATUS status;
3638 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639
Jeff Johnson0a078b52018-06-01 16:15:54 -07003640 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303641 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson0a078b52018-06-01 16:15:54 -07003642 if (CSR_IS_SESSION_VALID(mac, session_id))
3643 status = csr_roam_get_wpa_rsn_rsp_ie(mac, session_id,
3644 len, buf);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303645 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303646 status = QDF_STATUS_E_INVAL;
Jeff Johnson0a078b52018-06-01 16:15:54 -07003647 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 }
3649
3650 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651}
3652
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303653/*
3654 * sme_roam_get_num_pmkid_cache() -
3655 * A wrapper function to request CSR to return number of PMKID cache
3656 * entries
3657 * This is a synchronous call.
3658 *
3659 * Return uint32_t - the number of PMKID cache entries
3660 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
3662{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303663 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3665 uint32_t numPmkidCache = 0;
3666
3667 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303668 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3670 numPmkidCache =
3671 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303672 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303673 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303674 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 sme_release_global_lock(&pMac->sme);
3676 }
3677
3678 return numPmkidCache;
3679}
3680
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303681/*
3682 * sme_roam_get_pmkid_cache() -
3683 * A wrapper function to request CSR to return PMKID cache from CSR
3684 * This is a synchronous call.
3685 *
3686 * pNum - caller allocated memory that has the space of the number of
3687 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3688 * needed or actually number in tPmkidCacheInfo.
3689 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
3690 * any, upon return
3691 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3692 * big enough
3693 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303694QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303695 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303697 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3699
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303700 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
3702 0));
3703 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303704 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303705 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3706 status = csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303708 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303709 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 sme_release_global_lock(&pMac->sme);
3711 }
3712
3713 return status;
3714}
3715
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303716/*
3717 * sme_get_config_param() -
3718 * A wrapper function that HDD calls to get the global settings
3719 * currently maintained by CSR.
3720 * This is a synchronous call.
3721 *
3722 * pParam - caller allocated memory
3723 * Return QDF_STATUS
3724 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303725QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303727 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3729
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303730 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
3732 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303733 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303735 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003736 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 sme_release_global_lock(&pMac->sme);
3738 return status;
3739 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303740 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08003741 &pMac->rrm.rrmSmeContext.rrmConfig,
3742 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05303743 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744 sme_release_global_lock(&pMac->sme);
3745 }
3746
3747 return status;
3748}
3749
3750/**
3751 * sme_cfg_set_int() - Sets the cfg parameter value.
3752 * @hal: Handle to hal.
3753 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07003754 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755 *
3756 * This function sets the string value in cfg parameter.
3757 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303758 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303760QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761{
3762 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303763 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003764
Jeff Johnsonc09caa42018-06-07 22:58:55 -07003765 if (QDF_STATUS_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303766 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767
3768 return status;
3769}
3770
3771/**
3772 * sme_cfg_set_str() - Sets the cfg parameter string.
3773 * @hal: Handle to hal.
3774 * @cfg_id: Configuration parameter ID.
3775 * @str: Pointer to the string buffer.
3776 * @length: Length of the string.
3777 *
3778 * This function sets the string value in cfg parameter.
3779 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303780 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303782QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783 uint32_t length)
3784{
3785 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303786 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787
Jeff Johnsonc09caa42018-06-07 22:58:55 -07003788 if (QDF_STATUS_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303789 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790
3791 return status;
3792}
3793
3794/**
3795 * sme_cfg_get_int() - Gets the cfg parameter value.
3796 * @hal: Handle to hal.
3797 * @cfg_id: Configuration parameter ID.
3798 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07003799 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 *
3801 * This function gets the value of the cfg parameter.
3802 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303803 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303805QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806{
3807 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303808 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809
Jeff Johnsonc09caa42018-06-07 22:58:55 -07003810 if (QDF_STATUS_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303811 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812
3813 return status;
3814}
3815
3816/**
3817 * sme_cfg_get_str() - Gets the cfg parameter string.
3818 * @hal: Handle to hal.
3819 * @cfg_id: Configuration parameter ID.
3820 * @str: Pointer to the string buffer.
3821 * @length: Pointer to length of the string.
3822 *
3823 * This function gets the string value of the cfg parameter.
3824 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303825 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303827QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828 uint32_t *length)
3829{
3830 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303831 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832
Jeff Johnsonc09caa42018-06-07 22:58:55 -07003833 if (QDF_STATUS_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303834 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835
3836 return status;
3837}
3838
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303839/*
3840 * sme_get_modify_profile_fields() -
3841 * HDD or SME - QOS calls this function to get the current values of
3842 * connected profile fields, changing which can cause reassoc.
3843 * This function must be called after CFG is downloaded and STA is in connected
3844 * state. Also, make sure to call this function to get the current profile
3845 * fields before calling the reassoc. So that pModifyProfileFields will have
3846 * all the latest values plus the one(s) has been updated as part of reassoc
3847 * request.
3848 *
3849 * pModifyProfileFields - pointer to the connected profile fields
3850 * changing which can cause reassoc
3851 * Return QDF_STATUS
3852 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303853QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 tCsrRoamModifyProfileFields *
3855 pModifyProfileFields)
3856{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303857 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003858 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3859
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303860 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
3862 0));
3863 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303864 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303865 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3866 status = csr_get_modify_profile_fields(pMac, sessionId,
3867 pModifyProfileFields);
3868 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303869 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 sme_release_global_lock(&pMac->sme);
3871 }
3872
3873 return status;
3874}
3875
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303876/*
3877 * sme_set_dhcp_till_power_active_flag() -
3878 * Sets/Clears DHCP related flag to disable/enable auto PS
3879 *
3880 * hal - The handle returned by mac_open.
3881 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
3883{
3884 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3885 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
3886
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303887 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
3889 flag));
3890 /* Set/Clear the DHCP flag which will disable/enable auto PS */
3891 ps_global_info->remain_in_power_active_till_dhcp = flag;
3892}
3893
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303894/*
3895 * sme_register11d_scan_done_callback() -
3896 * Register a routine of type csr_scan_completeCallback which is
3897 * called whenever an 11d scan is done
3898 *
3899 * hHal - The handle returned by mac_open.
3900 * callback - 11d scan complete routine to be registered
3901 * Return QDF_STATUS
3902 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303903QDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303904 csr_scan_completeCallback callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303906 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3908
3909 pMac->scan.callback11dScanDone = callback;
3910
3911 return status;
3912}
3913
Arun Khandavalli4b55da72016-07-19 19:55:01 +05303914/**
3915 * sme_deregister11d_scan_done_callback() - De-register scandone callback
3916 * @h_hal: Handler return by mac_open
3917 *
3918 * This function De-registers the scandone callback to SME
3919 *
3920 * Return: None
3921 */
3922void sme_deregister11d_scan_done_callback(tHalHandle h_hal)
3923{
3924 tpAniSirGlobal pmac;
3925
3926 if (!h_hal) {
3927 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3928 FL("hHal is not valid"));
3929 return;
3930 }
3931
3932 pmac = PMAC_STRUCT(h_hal);
3933 pmac->scan.callback11dScanDone = NULL;
3934}
3935
3936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937#ifdef FEATURE_OEM_DATA_SUPPORT
3938/**
3939 * sme_register_oem_data_rsp_callback() - Register a routine of
3940 * type send_oem_data_rsp_msg
3941 * @h_hal: Handle returned by mac_open.
3942 * @callback: Callback to send response
3943 * to oem application.
3944 *
3945 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
3946 * callback function.
3947 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303948 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303950QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003951 sme_send_oem_data_rsp_msg callback)
3952{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303953 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
3955
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07003956 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957
3958 return status;
3959
3960}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05303961
3962/**
3963 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
3964 * @h_hal: Handler return by mac_open
3965 * This function De-registers the OEM data response callback to SME
3966 *
3967 * Return: None
3968 */
3969void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
3970{
3971 tpAniSirGlobal pmac;
3972
3973 if (!h_hal) {
3974 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3975 FL("hHal is not valid"));
3976 return;
3977 }
3978 pmac = PMAC_STRUCT(h_hal);
3979
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07003980 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05303981}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982
3983/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003984 * sme_oem_update_capability() - update UMAC's oem related capability.
3985 * @hal: Handle returned by mac_open
3986 * @oem_cap: pointer to oem_capability
3987 *
3988 * This function updates OEM capability to UMAC. Currently RTT
3989 * related capabilities are updated. More capabilities can be
3990 * added in future.
3991 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303992 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003993 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303994QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003995 struct sme_oem_capability *cap)
3996{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303997 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003998 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
3999 uint8_t *bytes;
4000
4001 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4002
4003 if (cap->ftm_rr)
4004 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
4005 if (cap->lci_capability)
4006 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
4007
4008 return status;
4009}
4010
4011/**
4012 * sme_oem_get_capability() - get oem capability
4013 * @hal: Handle returned by mac_open
4014 * @oem_cap: pointer to oem_capability
4015 *
4016 * This function is used to get the OEM capability from UMAC.
4017 * Currently RTT related capabilities are received. More
4018 * capabilities can be added in future.
4019 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304020 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004021 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304022QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004023 struct sme_oem_capability *cap)
4024{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304025 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004026 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4027 uint8_t *bytes;
4028
4029 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4030
4031 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4032 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4033
4034 return status;
4035}
Naveen Rawat910726a2017-03-06 11:42:51 -08004036#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004037
4038/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 * sme_roam_set_key() - To set encryption key.
4040 * @hal: hal global context
4041 * @session_id: session id
4042 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4043 * @ptr_roam_id: Upon success return, this is the id caller can use to
4044 * identify the request in roamcallback
4045 *
4046 * This function should be called only when connected. This is an asynchronous
4047 * API.
4048 *
4049 * Return: Status of operation
4050 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304051QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4053{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304054 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4056 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304057 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4059
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304060 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 session_id, 0));
4062 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004063 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304064 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065 }
4066 /*Once Setkey is done, we can go in BMPS */
4067 if (set_key->keyLength)
4068 ps_global_info->remain_in_power_active_till_dhcp = false;
4069
4070 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304071 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072 return status;
4073
4074 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4075 if (ptr_roam_id)
4076 *ptr_roam_id = roam_id;
4077
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004078 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004080 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 session = CSR_GET_SESSION(mac_ctx, session_id);
4082 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004083 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304085 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 }
4087 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4088 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4089 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4090 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4091 set_key->encType)) {
4092 session->pCurRoamProfile->negotiatedUCEncryptionType =
4093 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4094 }
4095 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4096 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4097 set_key->encType)) {
4098 session->pCurRoamProfile->negotiatedUCEncryptionType =
4099 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4100 }
4101 }
4102 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4103 sme_release_global_lock(&mac_ctx->sme);
4104 return status;
4105}
4106
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304107/**
4108 * sme_roam_set_default_key_index - To set default wep key idx
4109 * @hal: pointer to hal handler
4110 * @session_id: session id
4111 * @default_idx: default wep key index
4112 *
4113 * This function prepares a message and post to WMA to set wep default
4114 * key index
4115 *
4116 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4117 */
4118QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4119 uint8_t default_idx)
4120{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004121 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304122 struct wep_update_default_key_idx *update_key;
4123
4124 update_key = qdf_mem_malloc(sizeof(*update_key));
4125 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004126 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304127 return QDF_STATUS_E_NOMEM;
4128 }
4129
4130 update_key->session_id = session_id;
4131 update_key->default_idx = default_idx;
4132
4133 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4134 msg.reserved = 0;
4135 msg.bodyptr = (void *)update_key;
4136
4137 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004138 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004139 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304140 qdf_mem_free(update_key);
4141 return QDF_STATUS_E_FAILURE;
4142 }
4143
4144 return QDF_STATUS_SUCCESS;
4145}
4146
4147
Jeff Johnson8bd23352017-09-26 11:39:24 -07004148/**
4149 * sme_get_rssi() - API to retrieve current RSSI
4150 * @hHal: HAL handle for device
4151 * @callback: SME sends back the requested stats using the callback
4152 * @staId: The station ID for which the RSSI is requested for
4153 * @bssid: The bssid of the connected session
4154 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4155 * RSSI, do not hold up but return this value.
4156 * @pContext: user context to be passed back along with the callback
4157 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304158 * A wrapper function that client calls to register a callback to get RSSI
4159 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004160 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304161 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304162QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304163 tCsrRssiCallback callback, uint8_t staId,
4164 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004165 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004166{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304167 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4169
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304170 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4172 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304173 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174 status = csr_get_rssi(pMac, callback,
4175 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004176 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177 sme_release_global_lock(&pMac->sme);
4178 }
4179 return status;
4180}
4181
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304182/*
4183 * sme_get_snr() -
4184 * A wrapper function that client calls to register a callback to get SNR
4185 *
4186 * callback - SME sends back the requested stats using the callback
4187 * staId - The station ID for which the stats is requested for
4188 * pContext - user context to be passed back along with the callback
4189 * p_cds_context - cds context
4190 * \return QDF_STATUS
4191 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304192QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304194 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304196 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4198
4199 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304200 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4202 sme_release_global_lock(&pMac->sme);
4203 }
4204 return status;
4205}
4206
Naveen Rawatfa2a1002018-05-17 16:06:37 -07004207#ifndef QCA_SUPPORT_CP_STATS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304208/*
4209 * sme_get_statistics() -
4210 * A wrapper function that client calls to register a callback to get
4211 * different PHY level statistics from CSR.
4212 *
4213 * requesterId - different client requesting for statistics,
4214 * HDD, UMA/GAN etc
4215 * statsMask - The different category/categories of stats requester
4216 * is looking for
4217 * callback - SME sends back the requested stats using the callback
4218 * periodicity - If requester needs periodic update in millisec, 0 means
4219 * it's an one time request
4220 * cache - If requester is happy with cached stats
4221 * staId - The station ID for which the stats is requested for
4222 * pContext - user context to be passed back along with the callback
4223 * sessionId - sme session interface
4224 * Return QDF_STATUS
4225 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304226QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 eCsrStatsRequesterType requesterId,
4228 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004229 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304231 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4233
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304235 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304236 status = csr_get_statistics(pMac, requesterId, statsMask,
4237 callback, staId, pContext,
4238 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239 sme_release_global_lock(&pMac->sme);
4240 }
4241
4242 return status;
4243
4244}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07004245#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004246
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304247QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248 tCsrLinkStatusCallback callback,
4249 void *pContext, uint8_t sessionId)
4250{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304251 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4253 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004254 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255
4256 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304257 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304258 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304260 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261 "%s: Not able to allocate memory for link status",
4262 __func__);
4263 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304264 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 }
4266
4267 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4268 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4269 pMsg->sessionId = sessionId;
4270 pMac->sme.linkStatusContext = pContext;
4271 pMac->sme.linkStatusCallback = callback;
4272
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004273 message.type = WMA_LINK_STATUS_GET_REQ;
4274 message.bodyptr = pMsg;
4275 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304277 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004278 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4279 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304280 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304282 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 pMac->sme.linkStatusContext = NULL;
4284 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304285 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 }
4287
4288 sme_release_global_lock(&pMac->sme);
4289 }
4290
4291 return status;
4292}
4293
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304294/*
4295 * sme_get_country_code() -
4296 * To return the current country code. If no country code is applied,
4297 * default country code is used to fill the buffer.
4298 * If 11d supported is turned off, an error is return and the last
4299 * applied/default country code is used.
4300 * This is a synchronous API.
4301 *
4302 * pBuf - pointer to a caller allocated buffer for returned country code.
4303 * pbLen For input, this parameter indicates how big is the buffer.
4304 * Upon return, this parameter has the number of bytes for
4305 * country. If pBuf doesn't have enough space, this function
4306 * returns fail status and this parameter contains the number
4307 * that is needed.
4308 *
4309 * Return QDF_STATUS SUCCESS.
4310 *
4311 * FAILURE or RESOURCES The API finished and failed.
4312 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304313QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314{
4315 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4316
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304317 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4319
4320 return csr_get_country_code(pMac, pBuf, pbLen);
4321}
4322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323/* some support functions */
4324bool sme_is11d_supported(tHalHandle hHal)
4325{
4326 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4327
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004328 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329}
4330
4331bool sme_is11h_supported(tHalHandle hHal)
4332{
4333 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4334
4335 return csr_is11h_supported(pMac);
4336}
4337
4338bool sme_is_wmm_supported(tHalHandle hHal)
4339{
4340 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4341
4342 return csr_is_wmm_supported(pMac);
4343}
4344
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304345/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304346 * sme_generic_change_country_code() -
4347 * Change Country code from upperlayer during WLAN driver operation.
4348 * This is a synchronous API.
4349 *
4350 * hHal - The handle returned by mac_open.
4351 * pCountry New Country Code String
4352 * reg_domain regulatory domain
4353 * Return QDF_STATUS SUCCESS.
4354 * FAILURE or RESOURCES The API finished and failed.
4355 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304356QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004357 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004358{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304359 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004360 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004361 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 tAniGenericChangeCountryCodeReq *pMsg;
4363
4364 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304365 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366 "%s: pMac is null", __func__);
4367 return status;
4368 }
4369
4370 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304371 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304372 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373
4374 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004375 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304377 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 }
4379
4380 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4381 pMsg->msgLen =
4382 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304383 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004384 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385
4386 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4387 msg.bodyptr = pMsg;
4388 msg.reserved = 0;
4389
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304390 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004391 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004392 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304393 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304394 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 sme_release_global_lock(&pMac->sme);
4397 }
4398
4399 return status;
4400}
4401
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304402/*
4403 * sme_dhcp_start_ind() -
4404 * API to signal the FW about the DHCP Start event.
4405 *
4406 * hHal - HAL handle for device.
4407 * device_mode - mode(AP,SAP etc) of the device.
4408 * macAddr - MAC address of the adapter.
4409 * sessionId - session ID.
4410 * Return QDF_STATUS SUCCESS.
4411 * FAILURE or RESOURCES The API finished and failed.
4412 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304413QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 uint8_t device_mode,
4415 uint8_t *macAddr, uint8_t sessionId)
4416{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304417 QDF_STATUS status;
4418 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004420 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304422 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423
4424 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304425 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 pSession = CSR_GET_SESSION(pMac, sessionId);
4427
4428 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004429 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304431 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 }
Arif Hussain3316f402016-11-10 13:08:03 -08004433 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004434
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304435 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304437 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 "%s: Not able to allocate memory for dhcp start",
4439 __func__);
4440 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304441 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 }
4443 pMsg->msgType = WMA_DHCP_START_IND;
4444 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4445 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304446 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304447 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304448 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004449 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004451 message.type = WMA_DHCP_START_IND;
4452 message.bodyptr = pMsg;
4453 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304454 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004455 sessionId, message.type));
4456 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4457 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304458 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304459 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304461 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304462 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 }
4464 sme_release_global_lock(&pMac->sme);
4465 }
4466 return status;
4467}
4468
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304469/*
4470 * sme_dhcp_stop_ind() -
4471 * API to signal the FW about the DHCP complete event.
4472 *
4473 * hHal - HAL handle for device.
4474 * device_mode - mode(AP, SAP etc) of the device.
4475 * macAddr - MAC address of the adapter.
4476 * sessionId - session ID.
4477 * Return QDF_STATUS SUCCESS.
4478 * FAILURE or RESOURCES The API finished and failed.
4479 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304480QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 uint8_t device_mode,
4482 uint8_t *macAddr, uint8_t sessionId)
4483{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304484 QDF_STATUS status;
4485 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004487 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304489 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490
4491 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304492 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 pSession = CSR_GET_SESSION(pMac, sessionId);
4494
4495 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004496 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304498 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 }
Arif Hussain3316f402016-11-10 13:08:03 -08004500 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304502 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304504 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 "%s: Not able to allocate memory for dhcp stop",
4506 __func__);
4507 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304508 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 }
4510
4511 pMsg->msgType = WMA_DHCP_STOP_IND;
4512 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4513 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304514 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304515 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304516 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004517 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004519 message.type = WMA_DHCP_STOP_IND;
4520 message.bodyptr = pMsg;
4521 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304522 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004523 sessionId, message.type));
4524 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4525 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304526 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304527 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304529 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304530 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531 }
4532
4533 sme_release_global_lock(&pMac->sme);
4534 }
4535 return status;
4536}
4537
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304538/*
4539 * sme_TXFailMonitorStopInd() -
4540 * API to signal the FW to start monitoring TX failures
4541 *
4542 * Return QDF_STATUS SUCCESS.
4543 * FAILURE or RESOURCES The API finished and failed.
4544 */
4545QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4546 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004547 void *txFailIndCallback)
4548{
4549 QDF_STATUS status;
4550 QDF_STATUS qdf_status;
4551 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004552 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004553 tAniTXFailMonitorInd *pMsg;
4554
4555 status = sme_acquire_global_lock(&pMac->sme);
4556 if (QDF_STATUS_SUCCESS == status) {
4557 pMsg = (tAniTXFailMonitorInd *)
4558 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4559 if (NULL == pMsg) {
4560 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4561 "%s: Failed to allocate memory", __func__);
4562 sme_release_global_lock(&pMac->sme);
4563 return QDF_STATUS_E_NOMEM;
4564 }
4565
4566 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4567 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4568
4569 /* tx_fail_count = 0 should disable the Monitoring in FW */
4570 pMsg->tx_fail_count = tx_fail_count;
4571 pMsg->txFailIndCallback = txFailIndCallback;
4572
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004573 message.type = WMA_TX_FAIL_MONITOR_IND;
4574 message.bodyptr = pMsg;
4575 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004576
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004577 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4578 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004579 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4580 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4581 "%s: Post TX Fail monitor Start MSG fail",
4582 __func__);
4583 qdf_mem_free(pMsg);
4584 status = QDF_STATUS_E_FAILURE;
4585 }
4586 sme_release_global_lock(&pMac->sme);
4587 }
4588 return status;
4589}
4590
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304591/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304592 * sme_neighbor_report_request() -
4593 * API to request neighbor report.
4594 *
4595 * hHal - The handle returned by mac_open.
4596 * pRrmNeighborReq - Pointer to a caller allocated object of type
4597 * tRrmNeighborReq. Caller owns the memory and is
4598 * responsible for freeing it.
4599 * Return QDF_STATUS
4600 * QDF_STATUS_E_FAILURE - failure
4601 * QDF_STATUS_SUCCESS success
4602 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304603QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304605 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304607 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304609
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304610 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4612 0));
4613
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304614 if (pRrmNeighborReq->neighbor_report_offload) {
4615 status = csr_invoke_neighbor_report_request(sessionId,
4616 pRrmNeighborReq,
4617 false);
4618 return status;
4619 }
4620
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304621 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 status =
Jeff Johnsoned3de522018-06-10 18:27:51 -07004623 sme_rrm_neighbor_report_request(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304624 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 sme_release_global_lock(&pMac->sme);
4626 }
4627
4628 return status;
4629}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304631/*
4632 * sme_get_wcnss_wlan_compiled_version() -
4633 * This API returns the version of the WCNSS WLAN API with
4634 * which the HOST driver was built
4635 *
4636 * hHal - The handle returned by mac_open.
4637 * pVersion - Points to the Version structure to be filled
4638 * Return QDF_STATUS
4639 * QDF_STATUS_E_INVAL - failure
4640 * QDF_STATUS_SUCCESS success
4641 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304642QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 tSirVersionType *pVersion)
4644{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304645 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4647
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304648 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304650 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304652 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653
4654 sme_release_global_lock(&pMac->sme);
4655 }
4656
4657 return status;
4658}
4659
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304660/*
4661 * sme_get_wcnss_wlan_reported_version() -
4662 * This API returns the version of the WCNSS WLAN API with
4663 * which the WCNSS driver reports it was built
4664 * hHal - The handle returned by mac_open.
4665 * pVersion - Points to the Version structure to be filled
4666 * Return QDF_STATUS
4667 * QDF_STATUS_E_INVAL - failure
4668 * QDF_STATUS_SUCCESS success
4669 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304670QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 tSirVersionType *pVersion)
4672{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304673 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4675
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304676 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304678 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304680 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681
4682 sme_release_global_lock(&pMac->sme);
4683 }
4684
4685 return status;
4686}
4687
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304688/*
4689 * sme_get_wcnss_software_version() -
4690 * This API returns the version string of the WCNSS driver
4691 *
4692 * hHal - The handle returned by mac_open.
4693 * pVersion - Points to the Version string buffer to be filled
4694 * versionBufferSize - THe size of the Version string buffer
4695 * Return QDF_STATUS
4696 * QDF_STATUS_E_INVAL - failure
4697 * QDF_STATUS_SUCCESS success
4698 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304699QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 uint8_t *pVersion,
4701 uint32_t versionBufferSize)
4702{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304703 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304706 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304707 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07004709 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710 pVersion,
4711 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304712 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304713 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 sme_release_global_lock(&pMac->sme);
4715 }
4716
4717 return status;
4718}
4719
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304720/*
4721 * sme_get_wcnss_hardware_version() -
4722 * This API returns the version string of the WCNSS hardware
4723 *
4724 * hHal - The handle returned by mac_open.
4725 * pVersion - Points to the Version string buffer to be filled
4726 * versionBufferSize - THe size of the Version string buffer
4727 * Return QDF_STATUS
4728 * QDF_STATUS_E_INVAL - failure
4729 * QDF_STATUS_SUCCESS success
4730 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304731QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732 uint8_t *pVersion,
4733 uint32_t versionBufferSize)
4734{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304735 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004736 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4737
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304738 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004739 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304740 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304742 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743
4744 sme_release_global_lock(&pMac->sme);
4745 }
4746
4747 return status;
4748}
4749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004750#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004751/**
4752 * sme_oem_data_req() - send oem data request to WMA
4753 * @hal: HAL handle
4754 * @hdd_oem_req: OEM data request from HDD
4755 *
4756 * Return: QDF_STATUS
4757 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004758QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304760 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004761 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004762 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004764 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004765 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
4766 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004767 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004768 return QDF_STATUS_E_FAILURE;
4769 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004771 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
4772 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004773 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004774 return QDF_STATUS_E_NOMEM;
4775 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004777 oem_data_req->data_len = hdd_oem_req->data_len;
4778 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
4779 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004780 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004781 return QDF_STATUS_E_NOMEM;
4782 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004784 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
4785 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004787 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004788
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304789 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004790 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304791 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004792 sme_debug("OEM request(length: %d) sent to WMA",
4793 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004794
4795 if (oem_data_req->data_len)
4796 qdf_mem_free(oem_data_req->data);
4797 qdf_mem_free(oem_data_req);
4798
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004799 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004800 return status;
4801}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802#endif /*FEATURE_OEM_DATA_SUPPORT */
4803
Krunal Soni8d184fa2017-11-20 21:52:05 -08004804QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004805{
Arif Hussainee677012017-01-26 17:50:13 -08004806 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004807 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussainee677012017-01-26 17:50:13 -08004808 struct cdp_pdev *pdev;
4809 ol_txrx_peer_handle peer;
4810 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07004811 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004812
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304813 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07004814 "%s: type=%d, session_id %d subType=%d addr:%pM",
Krunal Soni8d184fa2017-11-20 21:52:05 -08004815 __func__, params->type_of_persona,
4816 params->sme_session_id, params->subtype_of_persona,
4817 params->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004818
Arif Hussainee677012017-01-26 17:50:13 -08004819 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4820
4821 if (NULL == pdev) {
4822 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
4823 "%s: Failed to get pdev handler", __func__);
4824 return status;
4825 }
4826
Krunal Soni8d184fa2017-11-20 21:52:05 -08004827 status = sme_acquire_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07004828 if (QDF_IS_STATUS_ERROR(status))
4829 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830
Krunal Soni8d184fa2017-11-20 21:52:05 -08004831 peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
4832 &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08004833 if (peer) {
4834 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
4835 "%s: Peer=%d exist with same MAC",
4836 __func__, peer_id);
4837 status = QDF_STATUS_E_INVAL;
4838 } else {
Krunal Soni8d184fa2017-11-20 21:52:05 -08004839 status = csr_roam_open_session(mac_ctx, params);
Arif Hussainee677012017-01-26 17:50:13 -08004840 }
Krunal Soni8d184fa2017-11-20 21:52:05 -08004841 sme_release_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07004842
4843 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
Krunal Soni8d184fa2017-11-20 21:52:05 -08004844 params->sme_session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845
4846 return status;
4847}
4848
Krunal Soni8d184fa2017-11-20 21:52:05 -08004849QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304851 QDF_STATUS status;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004852 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304854 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Krunal Soni8d184fa2017-11-20 21:52:05 -08004855 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304857 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -08004858 status = csr_roam_close_session(pMac, session_id, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859 sme_release_global_lock(&pMac->sme);
4860 }
4861
4862 return status;
4863}
4864
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304865/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304866 * sme_change_mcc_beacon_interval() -
4867 * To update P2P-GO beaconInterval. This function should be called after
4868 * disassociating all the station is done
4869 * This is an asynchronous API.
4870 *
4871 * @sessionId: Session Identifier
4872 * Return QDF_STATUS SUCCESS
4873 * FAILURE or RESOURCES
4874 * The API finished and failed.
4875 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004876QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304878 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004879 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880
Krunal Soni3fa80e22018-01-09 14:16:02 -08004881 if (!mac_ctx) {
4882 sme_err("mac_ctx is NULL");
4883 return status;
4884 }
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004885 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304886 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004887 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
4888 sessionId);
4889 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 }
4891 return status;
4892}
4893
4894/**
4895 * sme_set_host_offload(): API to set the host offload feature.
4896 * @hHal: The handle returned by mac_open.
4897 * @sessionId: Session Identifier
4898 * @request: Pointer to the offload request.
4899 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304900 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304902QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 tpSirHostOffloadReq request)
4904{
4905 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304906 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304908 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
4910 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304911 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912#ifdef WLAN_NS_OFFLOAD
4913 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
4914 status = sme_set_ps_ns_offload(hHal, request,
4915 sessionId);
4916 } else
4917#endif /* WLAN_NS_OFFLOAD */
4918 {
4919 status = sme_set_ps_host_offload(hHal, request,
4920 sessionId);
4921 }
4922 sme_release_global_lock(&pMac->sme);
4923 }
4924
4925 return status;
4926}
4927
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304928/*
4929 * sme_set_keep_alive() -
4930 * API to set the Keep Alive feature.
4931 *
4932 * hHal - The handle returned by mac_open.
4933 * request - Pointer to the Keep Alive request.
4934 * Return QDF_STATUS
4935 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304936QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 tpSirKeepAliveReq request)
4938{
4939 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004940 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304942 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004943
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304944 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945 FL("WMA_SET_KEEP_ALIVE message"));
4946
4947 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304948 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304950 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304952 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304954 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304955 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304956 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 }
4958
Anurag Chouhanc5548422016-02-24 18:33:27 +05304959 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304960 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304962 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963 "buff TP %d input TP %d ", request_buf->timePeriod,
4964 request->timePeriod);
4965 request_buf->sessionId = session_id;
4966
4967 msg.type = WMA_SET_KEEP_ALIVE;
4968 msg.reserved = 0;
4969 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304970 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
4971 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304972 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004973 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304974 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304975 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304976 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304977 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004978 }
4979
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304980 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981}
4982
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304983/*
4984 * sme_get_operation_channel() -
4985 * API to get current channel on which STA is parked his function gives
4986 * channel information only of infra station or IBSS station
4987 *
4988 * hHal, pointer to memory location and sessionId
4989 * Returns QDF_STATUS_SUCCESS
4990 * QDF_STATUS_E_FAILURE
4991 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304992QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993 uint8_t sessionId)
4994{
4995 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304996 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004997
4998 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4999 pSession = CSR_GET_SESSION(pMac, sessionId);
5000
5001 if ((pSession->connectedProfile.BSSType ==
5002 eCSR_BSS_TYPE_INFRASTRUCTURE)
5003 || (pSession->connectedProfile.BSSType ==
5004 eCSR_BSS_TYPE_IBSS)
5005 || (pSession->connectedProfile.BSSType ==
5006 eCSR_BSS_TYPE_INFRA_AP)
5007 || (pSession->connectedProfile.BSSType ==
5008 eCSR_BSS_TYPE_START_IBSS)) {
5009 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305010 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011 }
5012 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305013 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014} /* sme_get_operation_channel ends here */
5015
Abhishek Singh7996eb72015-12-30 17:24:02 +05305016/**
5017 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5018 * management frame indication to PE.
5019 *
5020 * @hal: hal pointer
5021 * @callback: callback pointer to be registered
5022 *
5023 * This function is used to register a callback for management
5024 * frame indication to PE.
5025 *
5026 * Return: Success if msg is posted to PE else Failure.
5027 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305028QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305029 sir_mgmt_frame_ind_callback callback)
5030{
5031 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5032 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305033 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305034
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305035 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305036 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305037 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305038 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005039 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305040 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305041 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305042 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305043 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5044 msg->length = sizeof(*msg);
5045
5046 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005047 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305048 sme_release_global_lock(&mac_ctx->sme);
5049 return status;
5050 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305051 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305052}
5053
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305054/*
5055 * sme_RegisterMgtFrame() -
Jeff Johnson698eacd2018-05-12 17:00:03 -07005056 * To register management frame of specified type and subtype.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305057 *
5058 * frameType - type of the frame that needs to be passed to HDD.
5059 * matchData - data which needs to be matched before passing frame
5060 * to HDD.
5061 * matchDataLen - Length of matched data.
5062 * Return QDF_STATUS
5063 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305064QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005065 uint16_t frameType, uint8_t *matchData,
5066 uint16_t matchLen)
5067{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305068 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5070
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005071 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305072 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073 tSirRegisterMgmtFrame *pMsg;
5074 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305075 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5076 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077
5078 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005079 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005080 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305081 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082 }
5083
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305084 if (!CSR_IS_SESSION_ANY(sessionId) &&
5085 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305086 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 "%s Invalid Sessionid", __func__);
5088 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305089 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090 }
5091
5092 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5093
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305094 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005095 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305096 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005097 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5099 pMsg->length = len;
5100 pMsg->sessionId = sessionId;
5101 pMsg->registerFrame = true;
5102 pMsg->frameType = frameType;
5103 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305104 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005105 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 }
5107 sme_release_global_lock(&pMac->sme);
5108 }
5109 return status;
5110}
5111
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305112/*
5113 * sme_DeregisterMgtFrame() -
Jeff Johnson698eacd2018-05-12 17:00:03 -07005114 * To De-register management frame of specified type and subtype.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305115 *
5116 * frameType - type of the frame that needs to be passed to HDD.
5117 * matchData - data which needs to be matched before passing frame
5118 * to HDD.
5119 * matchDataLen - Length of matched data.
5120 * Return QDF_STATUS
5121 */
5122QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 uint16_t frameType, uint8_t *matchData,
5124 uint16_t matchLen)
5125{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305126 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5128
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305129 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005130 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5131 0));
5132 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305133 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 tSirRegisterMgmtFrame *pMsg;
5135 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305136 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5137 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005138
5139 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005140 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005141 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305142 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005143 }
5144
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305145 if (!CSR_IS_SESSION_ANY(sessionId) &&
5146 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305147 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 "%s Invalid Sessionid", __func__);
5149 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305150 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 }
5152
5153 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5154
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305155 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305157 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005159 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5160 pMsg->length = len;
5161 pMsg->registerFrame = false;
5162 pMsg->frameType = frameType;
5163 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305164 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005165 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166 }
5167 sme_release_global_lock(&pMac->sme);
5168 }
5169 return status;
5170}
5171
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305172/**
5173 * sme_prepare_mgmt_tx() - Prepares mgmt frame
5174 * @hal: The handle returned by mac_open
5175 * @session_id: session id
5176 * @buf: pointer to frame
5177 * @len: frame length
5178 *
5179 * Return: QDF_STATUS
5180 */
5181static QDF_STATUS sme_prepare_mgmt_tx(tHalHandle hal, uint8_t session_id,
5182 const uint8_t *buf, uint32_t len)
5183{
5184 QDF_STATUS status = QDF_STATUS_SUCCESS;
5185 struct sir_mgmt_msg *msg;
5186 uint16_t msg_len;
5187 struct scheduler_msg sch_msg = {0};
5188
5189 sme_debug("prepares auth frame");
5190
5191 msg_len = sizeof(*msg) + len;
5192 msg = qdf_mem_malloc(msg_len);
5193 if (msg == NULL) {
5194 status = QDF_STATUS_E_NOMEM;
5195 } else {
5196 msg->type = eWNI_SME_SEND_MGMT_FRAME_TX;
5197 msg->msg_len = msg_len;
5198 msg->session_id = session_id;
5199 msg->data = (uint8_t *)msg + sizeof(*msg);
5200 qdf_mem_copy(msg->data, buf, len);
5201
5202 sch_msg.type = eWNI_SME_SEND_MGMT_FRAME_TX;
5203 sch_msg.bodyptr = msg;
5204 status = scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
5205 }
5206 return status;
5207}
5208
5209QDF_STATUS sme_send_mgmt_tx(tHalHandle hal, uint8_t session_id,
5210 const uint8_t *buf, uint32_t len)
5211{
5212 QDF_STATUS status = QDF_STATUS_SUCCESS;
5213 tpAniSirGlobal mac = PMAC_STRUCT(hal);
5214
5215 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
5216 TRACE_CODE_SME_RX_HDD_SEND_MGMT_TX, session_id, 0));
5217
5218 status = sme_acquire_global_lock(&mac->sme);
5219 if (QDF_IS_STATUS_SUCCESS(status)) {
5220 status = sme_prepare_mgmt_tx(hal, session_id, buf, len);
5221 sme_release_global_lock(&mac->sme);
5222 }
5223
5224 return status;
5225}
5226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005227#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005228/**
5229 * sme_configure_ext_wow() - configure Extr WoW
5230 * @hHal - The handle returned by mac_open.
5231 * @wlanExtParams - Depicts the wlan Ext params.
5232 * @callback - ext_wow callback to be registered.
5233 * @callback_context - ext_wow callback context
5234 *
5235 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305236 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005237 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305238QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239 tpSirExtWoWParams wlanExtParams,
5240 csr_readyToExtWoWCallback callback,
5241 void *callback_context)
5242{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305243 QDF_STATUS status = QDF_STATUS_SUCCESS;
5244 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005246 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305247 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248
5249 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305250 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305252 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005253 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5254
5255 pMac->readyToExtWoWCallback = callback;
5256 pMac->readyToExtWoWContext = callback_context;
5257
5258 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305259 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260
5261 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305262 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005263 message.bodyptr = MsgPtr;
5264 message.type = WMA_WLAN_EXT_WOW;
5265 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5266 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305267 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 pMac->readyToExtWoWCallback = NULL;
5269 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305270 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305271 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272 }
5273 sme_release_global_lock(&pMac->sme);
5274 } else {
5275 pMac->readyToExtWoWCallback = NULL;
5276 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305277 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 }
5279
5280 return status;
5281}
5282
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305283/*
5284 * sme_configure_app_type1_params() -
5285 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5286 *
5287 * hHal - The handle returned by mac_open.
5288 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5289 * Return QDF_STATUS
5290 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305291QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292 tpSirAppType1Params wlanAppType1Params)
5293{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305294 QDF_STATUS status = QDF_STATUS_SUCCESS;
5295 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005297 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305298 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299
5300 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305301 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305303 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5305 0));
5306
5307 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305308 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305310 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005311 message.bodyptr = MsgPtr;
5312 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
5313 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5314 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305315 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305316 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305317 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318 }
5319 sme_release_global_lock(&pMac->sme);
5320 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305321 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 }
5323
5324 return status;
5325}
5326
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305327/*
5328 * sme_configure_app_type2_params() -
5329 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5330 *
5331 * hHal - The handle returned by mac_open.
5332 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5333 * Return QDF_STATUS
5334 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305335QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305336 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305338 QDF_STATUS status = QDF_STATUS_SUCCESS;
5339 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005341 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305342 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343
5344 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305345 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005346
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305347 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005348 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5349 0));
5350
5351 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305352 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305354 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005355 message.bodyptr = MsgPtr;
5356 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
5357 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5358 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305359 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305360 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305361 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005362 }
5363 sme_release_global_lock(&pMac->sme);
5364 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305365 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 }
5367
5368 return status;
5369}
5370#endif
5371
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305372/*
5373 * sme_get_infra_session_id
5374 * To get the session ID for infra session, if connected
5375 * This is a synchronous API.
5376 *
5377 * hHal - The handle returned by mac_open.
5378 * sessionid, -1 if infra session is not connected
5379 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005380int8_t sme_get_infra_session_id(tHalHandle hHal)
5381{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305382 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 int8_t sessionid = -1;
5384 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5385
5386 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305387 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005388
5389 sessionid = csr_get_infra_session_id(pMac);
5390
5391 sme_release_global_lock(&pMac->sme);
5392 }
5393
5394 return sessionid;
5395}
5396
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305397/*
5398 * sme_get_infra_operation_channel() -
5399 * To get the operating channel for infra session, if connected
5400 * This is a synchronous API.
5401 *
5402 * hHal - The handle returned by mac_open.
5403 * sessionId - the sessionId returned by sme_open_session.
5404 * Return operating channel, 0 if infra session is not connected
5405 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5407{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305408 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005409 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5410 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305413 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414
5415 channel = csr_get_infra_operation_channel(pMac, sessionId);
5416
5417 sme_release_global_lock(&pMac->sme);
5418 }
5419
5420 return channel;
5421}
5422
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305423/* This routine will return poerating channel on which other BSS is operating
5424 * to be used for concurrency mode. If other BSS is not up or not connected it
5425 * will return 0
5426 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005427uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5428{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305429 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5431 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305432
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305434 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005435
5436 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305437 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5438 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005439 sme_release_global_lock(&pMac->sme);
5440 }
5441
5442 return channel;
5443}
5444
5445#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5446uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5447 eCsrPhyMode sapPhyMode,
5448 uint8_t cc_switch_mode)
5449{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305450 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5452 uint16_t channel = 0;
5453
5454 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305455 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005456 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305457 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5458 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005459 cc_switch_mode);
5460 sme_release_global_lock(&pMac->sme);
5461 }
5462
5463 return channel;
5464}
5465#endif
5466
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305467/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005468 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005469 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005470 * @cb_fn: Callback function pointer
5471 * @db_ctx: Callback data
5472 *
5473 * Return: QDF_STATUS
5474 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005475QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005476 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5477{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005478 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005479 QDF_STATUS status;
5480
Manikandan Mohan976e7562016-03-15 16:33:31 -07005481 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005482 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005483 mac->sme.get_tsf_cb = cb_fn;
5484 mac->sme.get_tsf_cxt = cb_ctx;
5485 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005486 }
5487 return status;
5488}
5489
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305490/**
5491 * sme_reset_tsfcb() - Reset callback for TSF capture
5492 * @h_hal: Handler return by mac_open
5493 *
5494 * This function reset the tsf capture callback to SME
5495 *
5496 * Return: QDF_STATUS
5497 */
5498QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5499{
5500 tpAniSirGlobal mac;
5501 QDF_STATUS status;
5502
5503 if (!h_hal) {
5504 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5505 FL("h_hal is not valid"));
5506 return QDF_STATUS_E_INVAL;
5507 }
5508 mac = PMAC_STRUCT(h_hal);
5509
5510 status = sme_acquire_global_lock(&mac->sme);
5511 if (QDF_IS_STATUS_SUCCESS(status)) {
5512 mac->sme.get_tsf_cb = NULL;
5513 mac->sme.get_tsf_cxt = NULL;
5514 sme_release_global_lock(&mac->sme);
5515 }
5516 return status;
5517}
5518
Manikandan Mohan976e7562016-03-15 16:33:31 -07005519#ifdef WLAN_FEATURE_TSF
5520/*
5521 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
5522 * @h_hal: Handler return by mac_open
5523 * @pinvalue: gpio pin id
5524 *
5525 * Return: QDF_STATUS
5526 */
5527QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5528{
5529 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005530 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005531 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5532
5533 status = sme_acquire_global_lock(&mac->sme);
5534 if (QDF_IS_STATUS_SUCCESS(status)) {
5535 tsf_msg.type = WMA_TSF_GPIO_PIN;
5536 tsf_msg.reserved = 0;
5537 tsf_msg.bodyval = pinvalue;
5538
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005539 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005540 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005541 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005542 status = QDF_STATUS_E_FAILURE;
5543 }
5544 sme_release_global_lock(&mac->sme);
5545 }
5546 return status;
5547}
5548#endif
5549
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005550QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551 uint32_t *len)
5552{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305553 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005554 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005556 if (NULL == mac_ctx) {
5557 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5558 FL("Invalid MAC context"));
5559 return QDF_STATUS_E_FAILURE;
5560 }
5561
5562 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305563 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005564 status = csr_get_cfg_valid_channels(mac_ctx,
5565 aValidChannels, len);
5566 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005567 }
5568
5569 return status;
5570}
5571
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005572static uint8_t *sme_reg_hint_to_str(const enum country_src src)
5573{
5574 switch (src) {
5575 case SOURCE_CORE:
5576 return "WORLD MODE";
5577
5578 case SOURCE_DRIVER:
5579 return "BDF file";
5580
5581 case SOURCE_USERSPACE:
5582 return "user-space";
5583
5584 case SOURCE_11D:
5585 return "802.11D IEs in beacons";
5586
5587 default:
5588 return "unknown";
5589 }
5590}
5591
Amar Singhal6edf9732016-11-20 21:43:40 -08005592void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5593{
5594 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5595
5596 mac_ctx->reg_hint_src = cc_src;
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005597
5598 sme_debug("Country source is %s",
5599 sme_reg_hint_to_str(cc_src));
Amar Singhal6edf9732016-11-20 21:43:40 -08005600}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005601
5602/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005603 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604 * @mac_ctx: mac global context
5605 * @msg: request msg packet
5606 *
5607 * If Supplicant country code is priority than 11d is disabled.
5608 * If 11D is enabled, we update the country code after every scan.
5609 * Hence when Supplicant country code is priority, we don't need 11D info.
5610 * Country code from Supplicant is set as current country code.
5611 *
5612 * Return: status of operation
5613 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305614static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005615sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
5616 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305618 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005619 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005620 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005622 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623
Amar Singhal6edf9732016-11-20 21:43:40 -08005624 if (SOURCE_11D != mac_ctx->reg_hint_src) {
5625 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
5626 if (user_ctry_priority)
5627 mac_ctx->roam.configParam.Is11dSupportEnabled =
5628 false;
5629 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305630 if (mac_ctx->roam.configParam.
5631 Is11dSupportEnabled &&
5632 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005633
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005634 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005635
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305636 status =
5637 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08005638 mac_ctx,
5639 mac_ctx->scan.countryCode11d,
5640 &reg_domain_id,
5641 SOURCE_11D);
5642 return QDF_STATUS_E_FAILURE;
5643 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005644 }
5645 }
5646 } else {
5647 /* if kernel gets invalid country code; it
5648 * resets the country code to world
5649 */
5650 if (('0' != msg->countryCode[0]) ||
5651 ('0' != msg->countryCode[1]))
5652 qdf_mem_copy(mac_ctx->scan.countryCode11d,
5653 msg->countryCode,
5654 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005656
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005657 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
5658 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07005660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 /* get the channels based on new cc */
5662 status = csr_get_channel_and_power_list(mac_ctx);
5663
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305664 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005665 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005666 return status;
5667 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669 /* reset info based on new cc, and we are done */
5670 csr_apply_channel_power_info_wrapper(mac_ctx);
5671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005673
5674 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675 * Country IE
5676 */
5677 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07005678
Amar Singhal6edf9732016-11-20 21:43:40 -08005679 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
5680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005682
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305683 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684}
5685
Jeff Johnson330c0bf2018-06-01 15:13:12 -07005686QDF_STATUS sme_update_channel_list(tHalHandle hal)
Mukul Sharmaecf8e092017-12-19 22:36:31 +05305687{
Jeff Johnson330c0bf2018-06-01 15:13:12 -07005688 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5689 QDF_STATUS status;
Mukul Sharmaecf8e092017-12-19 22:36:31 +05305690
5691 status = sme_acquire_global_lock(&mac_ctx->sme);
5692 if (QDF_IS_STATUS_SUCCESS(status)) {
5693 /* Update umac channel (enable/disable) from cds channels */
5694 status = csr_get_channel_and_power_list(mac_ctx);
5695 if (status != QDF_STATUS_SUCCESS) {
5696 sme_err("fail to get Channels");
5697 sme_release_global_lock(&mac_ctx->sme);
5698 return status;
5699 }
5700
5701 csr_apply_channel_power_info_wrapper(mac_ctx);
5702 csr_scan_filter_results(mac_ctx);
5703 sme_disconnect_connected_sessions(mac_ctx);
5704 sme_release_global_lock(&mac_ctx->sme);
5705 }
5706
5707 return status;
5708}
5709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710static bool
5711sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
5712{
5713 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305714 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 ch_lst_info = &mac_ctx->scan.base_channels;
5717 for (i = 0; i < ch_lst_info->numChannels; i++) {
5718 if (ch_lst_info->channelList[i] == curr_ch)
5719 return true;
5720 }
5721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005722 return false;
5723}
5724/**
5725 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
5726 * if channel is not supported
5727 * @mac_ctx: mac global context
5728 *
5729 * If new country code does not support the channel on which STA/P2P client
5730 * is connetced, it sends the disconnect to the AP/P2P GO
5731 *
5732 * Return: void
5733 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305734static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005735{
5736 uint8_t session_id, found = false;
5737 uint8_t curr_ch;
5738
5739 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
5740 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
5741 continue;
5742 found = false;
5743 /* Session is connected.Check the channel */
5744 curr_ch = csr_get_infra_operation_channel(mac_ctx,
5745 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005746 sme_debug("Current Operating channel : %d, session :%d",
5747 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
5749 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005750 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005751 csr_roam_disconnect(mac_ctx, session_id,
5752 eCSR_DISCONNECT_REASON_UNSPECIFIED);
5753 }
5754 }
5755}
5756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005757#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305758QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759 tpSirRcvFltMcAddrList pMulticastAddrs)
5760{
5761 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005762 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005763 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305764 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305766 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
5767 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08005769 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005770
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005771 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07005772 pSession = CSR_GET_SESSION(pMac, sessionId);
5773 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
5774 (!csr_is_conn_state_infra(pMac, sessionId) &&
5775 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05305776 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08005777 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305779 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005780 }
5781
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305782 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305784 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305785 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005786 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305787 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788 }
5789
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005790 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
5791 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305792 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005793 "%s: Request ignored, session %d is not connected or started",
5794 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305795 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305796 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005797 }
5798
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305799 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800 sizeof(tSirRcvFltMcAddrList));
5801
Anurag Chouhanc5548422016-02-24 18:33:27 +05305802 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
5803 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08005804 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805
5806 msg.type = WMA_8023_MULTICAST_LIST_REQ;
5807 msg.reserved = 0;
5808 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305809 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5810 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005811 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08005812 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305813 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305814 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005815 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305816 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305817 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 }
5819
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305820 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822#endif /* WLAN_FEATURE_PACKET_FILTERING */
5823
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305824/*
5825 * sme_is_channel_valid() -
5826 * To check if the channel is valid for currently established domain
5827 * This is a synchronous API.
5828 *
5829 * hHal - The handle returned by mac_open.
5830 * channel - channel to verify
5831 * Return true/false, true if channel is valid
5832 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005833bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
5834{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305835 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836 bool valid = false;
5837 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5838
5839 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305840 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841
5842 valid = csr_roam_is_channel_valid(pMac, channel);
5843
5844 sme_release_global_lock(&pMac->sme);
5845 }
5846
5847 return valid;
5848}
5849
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305850/*
5851 * sme_set_freq_band() -
5852 * Used to set frequency band.
5853 *
5854 * hHal
5855 * sessionId - Session Identifier
5856 * band value to be configured
5857 * Return QDF_STATUS
5858 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005859QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId,
5860 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005861{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305862 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5864
5865 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305866 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 status = csr_set_band(hHal, sessionId, eBand);
5868 sme_release_global_lock(&pMac->sme);
5869 }
5870 return status;
5871}
5872
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305873/*
5874 * sme_get_freq_band() -
5875 * Used to get the current band settings.
5876 *
5877 * hHal
5878 * pBand pointer to hold band value
5879 * Return QDF_STATUS
5880 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005881QDF_STATUS sme_get_freq_band(tHalHandle hHal, enum band_info *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005882{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305883 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005884 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5885
5886 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305887 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888 *pBand = csr_get_current_band(hHal);
5889 sme_release_global_lock(&pMac->sme);
5890 }
5891 return status;
5892}
5893
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305894/*
5895 * sme_set_max_tx_power_per_band() -
5896 * Set the Maximum Transmit Power specific to band dynamically.
5897 * Note: this setting will not persist over reboots.
5898 *
5899 * band
5900 * power to set in dB
5901 * Return QDF_STATUS
5902 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005903QDF_STATUS sme_set_max_tx_power_per_band(enum band_info band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005904{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005905 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
5907
5908 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305909 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305911 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005912 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
5913 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305914 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005915 }
5916
5917 pMaxTxPowerPerBandParams->power = dB;
5918 pMaxTxPowerPerBandParams->bandInfo = band;
5919
5920 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
5921 msg.reserved = 0;
5922 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305923 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5924 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005925 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08005926 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305927 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
5929 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305930 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305931 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005932 }
5933
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305934 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005935}
5936
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305937/*
5938 * sme_set_max_tx_power() -
5939 * Set the Maximum Transmit Power dynamically. Note: this setting will
5940 * not persist over reboots.
5941 *
5942 * hHal
5943 * pBssid BSSID to set the power cap for
5944 * pBssid pSelfMacAddress self MAC Address
5945 * pBssid power to set in dB
5946 * Return QDF_STATUS
5947 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05305948QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
5949 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005950{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005951 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005952 tpMaxTxPowerParams pMaxTxParams = NULL;
5953
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305954 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005955 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305956 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305958 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005959 "%s: Not able to allocate memory for pMaxTxParams",
5960 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305961 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005962 }
5963
Anurag Chouhanc5548422016-02-24 18:33:27 +05305964 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
5965 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 pMaxTxParams->power = dB;
5967
5968 msg.type = WMA_SET_MAX_TX_POWER_REQ;
5969 msg.reserved = 0;
5970 msg.bodyptr = pMaxTxParams;
5971
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005972 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08005973 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305974 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
5976 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305977 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305978 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005979 }
5980
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305981 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982}
5983
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305984/*
5985 * sme_set_custom_mac_addr() -
5986 * Set the customer Mac Address.
5987 *
5988 * customMacAddr customer MAC Address
5989 * Return QDF_STATUS
5990 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305991QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005992{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005993 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 tSirMacAddr *pBaseMacAddr;
5995
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305996 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005997 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305998 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306000 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006001 }
6002
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306003 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006004
6005 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6006 msg.reserved = 0;
6007 msg.bodyptr = pBaseMacAddr;
6008
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006009 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006010 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306011 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306012 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306013 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306014 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 }
6016
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306017 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006018}
6019
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306020/*
6021 * sme_set_tx_power() -
6022 * Set Transmit Power dynamically.
6023 *
6024 * hHal
6025 * sessionId Target Session ID
6026 * BSSID
6027 * dev_mode dev_mode such as station, P2PGO, SAP
6028 * dBm power to set
6029 * Return QDF_STATUS
6030 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306031QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306032 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006033 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006034{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006035 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006036 tpMaxTxPowerParams pTxParams = NULL;
6037 int8_t power = (int8_t) dBm;
6038
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306039 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6041
6042 /* make sure there is no overflow */
6043 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306044 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306046 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006047 }
6048
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306049 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006050 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306051 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006052 "%s: Not able to allocate memory for pTxParams",
6053 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306054 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 }
6056
Anurag Chouhanc5548422016-02-24 18:33:27 +05306057 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006058 pTxParams->power = power; /* unit is dBm */
6059 pTxParams->dev_mode = dev_mode;
6060 msg.type = WMA_SET_TX_POWER_REQ;
6061 msg.reserved = 0;
6062 msg.bodyptr = pTxParams;
6063
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006064 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006065 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306066 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6068 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306069 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306070 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 }
6072
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306073 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074}
6075
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306076QDF_STATUS sme_update_fils_setting(tHalHandle hal, uint8_t session_id,
6077 uint8_t param_val)
6078{
6079 QDF_STATUS status;
6080 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
6081
6082 pMac->roam.configParam.is_fils_enabled = !param_val;
6083
6084 pMac->roam.configParam.enable_bcast_probe_rsp = !param_val;
6085 status = wma_cli_set_command((int)session_id,
6086 (int)WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
6087 !param_val, VDEV_CMD);
6088 if (status)
6089 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6090 "%s: Failed to set enable bcast probe setting",
6091 __func__);
6092
6093 return status;
6094}
6095
6096QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306097 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306099 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306100 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006101 uint16_t len;
6102
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306103 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306104 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306105 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306106 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6107 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006108
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306109 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006110 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306111 sme_release_global_lock(&mac_ctx->sme);
6112 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006113 }
6114
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306115 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6116 mac_ctx->ignore_assoc_disallowed = param_val;
6117
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306118 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306119 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306121 len = sizeof(*msg);
6122 msg = qdf_mem_malloc(len);
6123 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306124 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006125 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306126 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6127 msg->length = len;
6128 msg->session_id = session_id;
6129 msg->param_type = param_type;
6130 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006131 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006132 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306133 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134 }
6135 return status;
6136}
6137
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306138/*
6139 * sme_set_tm_level() -
6140 * Set Thermal Mitigation Level to RIVA
6141 *
6142 * hHal - The handle returned by mac_open.
6143 * newTMLevel - new Thermal Mitigation Level
6144 * tmMode - Thermal Mitigation handle mode, default 0
6145 * Return QDF_STATUS
6146 */
6147QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6148 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306150 QDF_STATUS status = QDF_STATUS_SUCCESS;
6151 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006152 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006153 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006154 tAniSetTmLevelReq *setTmLevelReq = NULL;
6155
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306156 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6158 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306159 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006160 setTmLevelReq =
6161 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306162 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306164 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006165 "%s: Not able to allocate memory for sme_set_tm_level",
6166 __func__);
6167 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306168 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169 }
6170
6171 setTmLevelReq->tmMode = tmMode;
6172 setTmLevelReq->newTmLevel = newTMLevel;
6173
6174 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006175 message.bodyptr = setTmLevelReq;
6176 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306177 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006178 NO_SESSION, message.type));
6179 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6180 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306181 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306182 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006183 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306184 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306185 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 }
6187 sme_release_global_lock(&pMac->sme);
6188 }
6189 return status;
6190}
6191
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306192/*
6193 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6194 * Host and FW.
6195 *
6196 * hHal - HAL handle for device
6197 * Return NONE
6198 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199void sme_feature_caps_exchange(tHalHandle hHal)
6200{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306201 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306202 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6203 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006204}
6205
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306206/*
6207 * sme_disable_feature_capablity() - SME interface to disable Active mode
6208 * offload capablity in Host.
6209 *
6210 * hHal - HAL handle for device
6211 * Return NONE
6212 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006213void sme_disable_feature_capablity(uint8_t feature_index)
6214{
6215}
6216
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306217/*
6218 * sme_reset_power_values_for5_g
6219 * Reset the power values for 5G band with default power values.
6220 *
6221 * hHal - HAL handle for device
6222 * Return NONE
6223 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006224void sme_reset_power_values_for5_g(tHalHandle hHal)
6225{
6226 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306227
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306228 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006229 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6230 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306231 /* Store the channel+power info in the global place: Cfg */
6232 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233}
6234
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306235/*
6236 * sme_update_roam_prefer5_g_hz() -
6237 * Enable/disable Roam prefer 5G runtime option
6238 * This function is called through dynamic setConfig callback function
6239 * to configure the Roam prefer 5G runtime option
6240 *
6241 * hHal - HAL handle for device
6242 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6243 * Return Success or failure
6244 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006245
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306246QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6247 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006248{
6249 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306250 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306252 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006253 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
6254 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306255 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306256 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006257 "%s: gRoamPrefer5GHz is changed from %d to %d",
6258 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6259 nRoamPrefer5GHz);
6260 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6261 sme_release_global_lock(&pMac->sme);
6262 }
6263
6264 return status;
6265}
6266
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306267/*
6268 * sme_set_roam_intra_band() -
6269 * enable/disable Intra band roaming
6270 * This function is called through dynamic setConfig callback function
6271 * to configure the intra band roaming
6272 * hHal - HAL handle for device
6273 * nRoamIntraBand Enable/Disable Intra band roaming
6274 * Return Success or failure
6275 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306276QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006277{
6278 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306279 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006280
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306281 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006282 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6283 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306284 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306285 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006286 "%s: gRoamIntraBand is changed from %d to %d",
6287 __func__, pMac->roam.configParam.nRoamIntraBand,
6288 nRoamIntraBand);
6289 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6290 sme_release_global_lock(&pMac->sme);
6291 }
6292
6293 return status;
6294}
6295
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306296/*
6297 * sme_update_roam_scan_n_probes() -
6298 * Function to update roam scan N probes
6299 * This function is called through dynamic setConfig callback function
6300 * to update roam scan N probes
6301 * hHal - HAL handle for device
6302 * sessionId - Session Identifier
6303 * nProbes number of probe requests to be sent out
6304 * Return Success or failure
6305 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306306QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006307 const uint8_t nProbes)
6308{
6309 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306310 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006311
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306312 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006313 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6314 NO_SESSION, 0));
6315 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306316 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306317 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006318 "%s: gRoamScanNProbes is changed from %d to %d",
6319 __func__, pMac->roam.configParam.nProbes, nProbes);
6320 pMac->roam.configParam.nProbes = nProbes;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306321
6322 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6323 csr_roam_offload_scan(pMac, sessionId,
6324 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6325 REASON_NPROBES_CHANGED);
6326 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006327 sme_release_global_lock(&pMac->sme);
6328 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006329 return status;
6330}
6331
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306332/*
6333 * sme_update_roam_scan_home_away_time() -
6334 * Function to update roam scan Home away time
6335 * This function is called through dynamic setConfig callback function
6336 * to update roam scan home away time
6337 *
6338 * hHal - HAL handle for device
6339 * sessionId - Session Identifier
6340 * nRoamScanAwayTime Scan home away time
6341 * bSendOffloadCmd If true then send offload command to firmware
6342 * If false then command is not sent to firmware
6343 * Return Success or failure
6344 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306345QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006346 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306347 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006348 const bool bSendOffloadCmd)
6349{
6350 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306351 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006352
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306353 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006354 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6355 NO_SESSION, 0));
6356 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306357 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306358 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6360 __func__,
6361 pMac->roam.configParam.nRoamScanHomeAwayTime,
6362 nRoamScanHomeAwayTime);
6363 pMac->roam.configParam.nRoamScanHomeAwayTime =
6364 nRoamScanHomeAwayTime;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306365
6366 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6367 bSendOffloadCmd) {
6368 csr_roam_offload_scan(pMac, sessionId,
6369 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6370 REASON_HOME_AWAY_TIME_CHANGED);
6371 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006372 sme_release_global_lock(&pMac->sme);
6373 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006374 return status;
6375}
6376
Abhishek Singh518323d2015-10-19 17:42:01 +05306377/**
6378 * sme_ext_change_channel()- function to post send ECSA
6379 * action frame to csr.
6380 * @hHal: Hal context
6381 * @channel: new channel to switch
6382 * @session_id: senssion it should be sent on.
6383 *
6384 * This function is called to post ECSA frame to csr.
6385 *
6386 * Return: success if msg is sent else return failure
6387 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306388QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306389 uint8_t session_id)
6390{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306391 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306392 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6393 uint8_t channel_state;
6394
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006395 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306396 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006397 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306398
6399 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006400 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306401 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306402 }
6403
6404 status = sme_acquire_global_lock(&mac_ctx->sme);
6405
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306406 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306407 /* update the channel list to the firmware */
6408 status = csr_send_ext_change_channel(mac_ctx,
6409 channel, session_id);
6410 sme_release_global_lock(&mac_ctx->sme);
6411 }
6412
6413 return status;
6414}
6415
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306416/*
6417 * sme_get_roam_intra_band() -
6418 * get Intra band roaming
6419 *
6420 * hHal - HAL handle for device
6421 * Return Success or failure
6422 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006423bool sme_get_roam_intra_band(tHalHandle hHal)
6424{
6425 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306426
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306427 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006428 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6429 return pMac->roam.configParam.nRoamIntraBand;
6430}
6431
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306432/*
6433 * sme_get_roam_scan_n_probes() -
6434 * get N Probes
6435 *
6436 * hHal - HAL handle for device
6437 * Return Success or failure
6438 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006439uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6440{
6441 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306442
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006443 return pMac->roam.configParam.nProbes;
6444}
6445
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306446/*
6447 * sme_get_roam_scan_home_away_time() -
6448 * get Roam scan home away time
6449 *
6450 * hHal - HAL handle for device
6451 * Return Success or failure
6452 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006453uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6454{
6455 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306456
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006457 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6458}
6459
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306460/*
6461 * sme_update_roam_rssi_diff() -
6462 * Update RoamRssiDiff
6463 * This function is called through dynamic setConfig callback function
6464 * to configure RoamRssiDiff
6465 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6466 *
6467 * hHal - HAL handle for device
6468 * sessionId - Session Identifier
6469 * RoamRssiDiff - minimum rssi difference between potential
6470 * candidate and current AP.
6471 * Return Success or failure
6472 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006473
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306474QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006475 uint8_t RoamRssiDiff)
6476{
6477 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306478 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006479
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006480 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6481 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6482 FL("Invalid sme session id: %d"), sessionId);
6483 return QDF_STATUS_E_INVAL;
6484 }
6485
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306487 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306488 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6490 RoamRssiDiff,
6491 pMac->roam.configParam.RoamRssiDiff,
6492 mac_trace_get_neighbour_roam_state(pMac->roam.
6493 neighborRoamInfo
6494 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306495 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006496 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306497
6498 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
6499 csr_roam_offload_scan(pMac, sessionId,
6500 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6501 REASON_RSSI_DIFF_CHANGED);
6502
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006503 sme_release_global_lock(&pMac->sme);
6504 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006505 return status;
6506}
6507
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306508#ifdef WLAN_FEATURE_FILS_SK
6509QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006510 struct csr_roam_profile *src_profile)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306511{
6512 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6513 QDF_STATUS status = QDF_STATUS_SUCCESS;
6514 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6515 &mac->roam.neighborRoamInfo[session_id];
6516
6517 if (session_id >= CSR_ROAM_SESSION_MAX) {
6518 sme_err("Invalid sme session id: %d", session_id);
6519 return QDF_STATUS_E_INVAL;
6520 }
6521
6522 if (!src_profile) {
6523 sme_err("src roam profile NULL");
6524 return QDF_STATUS_E_INVAL;
6525 }
6526
6527 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6528 (neighbor_roam_info->neighborRoamState !=
6529 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6530 sme_info("Fast roam is disabled or not connected(%d)",
6531 neighbor_roam_info->neighborRoamState);
6532 return QDF_STATUS_E_PERM;
6533 }
6534
6535 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306536 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306537 status = sme_acquire_global_lock(&mac->sme);
6538 if (QDF_IS_STATUS_SUCCESS(status)) {
6539 sme_debug("Updating fils config to fw");
6540 csr_roam_offload_scan(mac, session_id,
6541 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6542 REASON_FILS_PARAMS_CHANGED);
6543 sme_release_global_lock(&mac->sme);
6544 } else {
6545 sme_err("Failed to acquire SME lock");
6546 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306547 } else {
6548 sme_info("LFR3 not enabled");
6549 return QDF_STATUS_E_INVAL;
6550 }
6551
6552 return status;
6553}
6554
6555void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006556 struct csr_roam_profile *profile, uint32_t if_addr)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306557{
6558 int i;
6559 struct scheduler_msg msg;
6560 QDF_STATUS status;
6561 struct hlp_params *params;
6562 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6563 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6564 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6565 &mac->roam.neighborRoamInfo[session_id];
6566
6567 if (!session) {
6568 sme_err("session NULL");
6569 return;
6570 }
6571
6572 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6573 (neighbor_roam_info->neighborRoamState !=
6574 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6575 sme_debug("Fast roam is disabled or not connected(%d)",
6576 neighbor_roam_info->neighborRoamState);
6577 return;
6578 }
6579
6580 params = qdf_mem_malloc(sizeof(*params));
6581 if (!params) {
6582 sme_err("Mem alloc for HLP IE fails");
6583 return;
6584 }
6585 if ((profile->hlp_ie_len +
6586 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
6587 sme_err("HLP IE len exceeds %d",
6588 profile->hlp_ie_len);
6589 qdf_mem_free(params);
6590 return;
6591 }
6592
6593 params->vdev_id = session_id;
6594 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
6595
6596 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
6597 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
6598
6599 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
6600 profile->hlp_ie, profile->hlp_ie_len);
6601
6602 msg.type = SIR_HAL_HLP_IE_INFO;
6603 msg.reserved = 0;
6604 msg.bodyptr = params;
6605 status = sme_acquire_global_lock(&mac->sme);
6606 if (status != QDF_STATUS_SUCCESS) {
6607 sme_err("sme lock acquire fails");
6608 qdf_mem_free(params);
6609 return;
6610 }
6611
6612 if (!QDF_IS_STATUS_SUCCESS
6613 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6614 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
6615 sme_release_global_lock(&mac->sme);
6616 qdf_mem_free(params);
6617 return;
6618 }
6619
6620 sme_release_global_lock(&mac->sme);
6621}
6622
Jeff Johnson172237b2017-11-07 15:32:59 -08006623void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306624{
6625 struct fils_join_rsp_params *roam_fils_params;
6626
6627 if (!roam_info) {
6628 sme_err("FILS Roam Info NULL");
6629 return;
6630 }
6631
6632 roam_fils_params = roam_info->fils_join_rsp;
6633 if (!roam_fils_params) {
6634 sme_err("FILS Roam Param NULL");
6635 return;
6636 }
6637
6638 if (roam_fils_params->fils_pmk)
6639 qdf_mem_free(roam_fils_params->fils_pmk);
6640
6641 qdf_mem_free(roam_fils_params);
6642
6643 roam_info->fils_join_rsp = NULL;
6644}
6645
6646#else
6647inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006648 struct csr_roam_profile *profile, uint32_t if_addr)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306649{}
6650#endif
6651
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306652/*
6653 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
6654 * support at runtime
6655 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6656 * isFastTransitionEnabled.
6657 * This is a synchronous call
6658 *
6659 * hHal - The handle returned by mac_open.
6660 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
6661 * successfully.
6662 * Other status means SME is failed to update isFastTransitionEnabled.
6663 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306664QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006665 bool isFastTransitionEnabled)
6666{
6667 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306668 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006669
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306670 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006671 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
6672 0));
6673 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306674 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306675 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006676 "%s: FastTransitionEnabled is changed from %d to %d",
6677 __func__,
6678 pMac->roam.configParam.isFastTransitionEnabled,
6679 isFastTransitionEnabled);
6680 pMac->roam.configParam.isFastTransitionEnabled =
6681 isFastTransitionEnabled;
6682 sme_release_global_lock(&pMac->sme);
6683 }
6684
6685 return status;
6686}
6687
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306688/*
6689 * sme_update_wes_mode() -
6690 * Update WES Mode
6691 * This function is called through dynamic setConfig callback function
6692 * to configure isWESModeEnabled
6693 *
6694 * hHal - HAL handle for device
6695 * isWESModeEnabled - WES mode
6696 * sessionId - Session Identifier
6697 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
6698 * Other status means SME is failed to update isWESModeEnabled.
6699 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306701QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006702 uint8_t sessionId)
6703{
6704 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306705 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006706
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006707 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6708 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6709 FL("Invalid sme session id: %d"), sessionId);
6710 return QDF_STATUS_E_INVAL;
6711 }
6712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006713 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306714 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306715 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006716 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
6717 isWESModeEnabled,
6718 pMac->roam.configParam.isWESModeEnabled,
6719 mac_trace_get_neighbour_roam_state(pMac->roam.
6720 neighborRoamInfo
6721 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306722 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006723 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
6724 sme_release_global_lock(&pMac->sme);
6725 }
6726
6727 return status;
6728}
6729
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306730/*
6731 * sme_set_roam_scan_control() -
6732 * Set roam scan control
6733 * This function is called to set roam scan control
6734 * if roam scan control is set to 0, roaming scan cache is cleared
6735 * any value other than 0 is treated as invalid value
6736 * hHal - HAL handle for device
6737 * sessionId - Session Identifier
6738 * Return QDF_STATUS_SUCCESS - SME update config successfully.
6739 * Other status means SME failure to update
6740 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306741QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006742 bool roamScanControl)
6743{
6744 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306745 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006746
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306747 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006748 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006749
6750 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6751 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6752 FL("Invalid sme session id: %d"), sessionId);
6753 return QDF_STATUS_E_INVAL;
6754 }
6755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006756 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306757 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306758 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006759 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
6760 roamScanControl,
6761 pMac->roam.configParam.nRoamScanControl,
6762 mac_trace_get_neighbour_roam_state(pMac->roam.
6763 neighborRoamInfo
6764 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306765 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006766 pMac->roam.configParam.nRoamScanControl = roamScanControl;
6767 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306768 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006769 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306770 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
6771 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006772 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6773 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306774 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6775 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006776 }
6777 }
6778 sme_release_global_lock(&pMac->sme);
6779 }
6780 return status;
6781}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006782
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306783/*
6784 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
6785 * support at runtime
6786 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6787 * isFastRoamIniFeatureEnabled.
6788 * This is a synchronous call
6789 *
6790 * hHal - The handle returned by mac_open.
6791 * sessionId - Session Identifier
6792 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
6793 * successfully.
6794 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
6795 */
6796QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
6797 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
6798{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006799 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6800
6801 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
6802 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306803 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006804 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
6805 __func__,
6806 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
6807 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306808 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809 }
6810
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306811 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006812 "%s: FastRoamEnabled is changed from %d to %d", __func__,
6813 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
6814 isFastRoamIniFeatureEnabled);
6815 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
6816 isFastRoamIniFeatureEnabled;
6817 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306818 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006819
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306820 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006821}
6822
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306823/**
6824 * sme_config_fast_roaming() - enable/disable LFR support at runtime
6825 * @hal - The handle returned by macOpen.
6826 * @session_id - Session Identifier
6827 * @is_fast_roam_enabled - flag to enable/disable roaming
6828 *
6829 * When Supplicant issues enabled/disable fast roaming on the basis
6830 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
6831 *
6832 * Return: QDF_STATUS
6833 */
6834
6835QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
6836 const bool is_fast_roam_enabled)
6837{
6838 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306839 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306840 QDF_STATUS status;
6841
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006842 /*
6843 * supplicant_disabled_roaming flag is set to true in
6844 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
6845 * request with BSSID. This flag is reset when supplicant sends
6846 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08006847 *
6848 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006849 * if roaming is disabled using driver command or INI and
6850 * supplicant_disabled_roaming flag remains set. So make sure to set
6851 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
6852 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08006853 */
6854 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006855 session->pCurRoamProfile->supplicant_disabled_roaming =
6856 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08006857
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306858 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006859 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306860 if (!is_fast_roam_enabled)
6861 return QDF_STATUS_SUCCESS;
6862 return QDF_STATUS_E_FAILURE;
6863 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05306864
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306865 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
6866 session_id, is_fast_roam_enabled);
6867 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006868 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306869 return QDF_STATUS_E_FAILURE;
6870 }
6871
6872 return QDF_STATUS_SUCCESS;
6873}
6874
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306875/*
6876 * sme_update_is_mawc_ini_feature_enabled() -
6877 * Enable/disable LFR MAWC support at runtime
6878 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6879 * isMAWCIniFeatureEnabled.
6880 * This is a synchronous call
6881 *
6882 * hHal - The handle returned by mac_open.
6883 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
6884 * Other status means SME is failed to update MAWCEnabled.
6885 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306886QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006887 const bool MAWCEnabled)
6888{
6889 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306890 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006891
6892 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306893 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306894 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006895 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07006896 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
6897 MAWCEnabled);
6898 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
6899 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006900 sme_release_global_lock(&pMac->sme);
6901 }
6902
6903 return status;
6904
6905}
6906
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006907/**
6908 * sme_stop_roaming() - Stop roaming for a given sessionId
6909 * This is a synchronous call
6910 *
6911 * @hHal - The handle returned by mac_open
6912 * @sessionId - Session Identifier
6913 *
6914 * Return QDF_STATUS_SUCCESS on success
6915 * Other status on failure
6916 */
6917QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006918{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006919 struct scheduler_msg wma_msg = {0};
Jeff Johnsonc09caa42018-06-07 22:58:55 -07006920 QDF_STATUS status;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006921 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006922 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
6923 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006924 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006925
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006926 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006927 sme_err("incorrect session/vdev ID");
6928 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006929 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006930
6931 session = CSR_GET_SESSION(mac_ctx, session_id);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05306932
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05306933 /*
6934 * set the driver_disabled_roaming flag to true even if roaming
6935 * is not enabled on this session so that roam start requests for
6936 * this session can be blocked until driver enables roaming
6937 */
6938 if (reason == ecsr_driver_disabled && session->pCurRoamProfile) {
6939 session->pCurRoamProfile->driver_disabled_roaming = true;
6940 sme_debug("driver_disabled_roaming set for session %d",
6941 session_id);
6942 }
6943
Abhishek Singh1f217ec2017-12-22 11:48:27 +05306944 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
6945 if (!roam_info->b_roam_scan_offload_started) {
6946 sme_debug("Roaming already disabled for session %d", session_id);
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006947 return QDF_STATUS_SUCCESS;
6948 }
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006949 req = qdf_mem_malloc(sizeof(*req));
6950 if (!req) {
6951 sme_err("failed to allocated memory");
6952 return QDF_STATUS_E_NOMEM;
6953 }
6954
6955 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05306956 if ((reason == eCsrForcedDisassoc) || reason == ecsr_driver_disabled)
Abhishek Singh533c9da2017-05-04 10:23:34 +05306957 req->reason = REASON_ROAM_STOP_ALL;
6958 else
Varun Reddy Yeturubc1bea02018-02-01 18:12:34 -08006959 req->reason = REASON_SME_ISSUED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006960 req->sessionId = session_id;
6961 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006962 req->middle_of_roaming = 1;
6963 else
6964 csr_roam_reset_roam_params(mac_ctx);
6965
6966 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
6967 wma_msg.bodyptr = req;
6968
6969 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnsonc09caa42018-06-07 22:58:55 -07006970 if (QDF_STATUS_SUCCESS != status) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006971 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006972 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006973 qdf_mem_free(req);
6974 return QDF_STATUS_E_FAULT;
6975 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006976 roam_info->b_roam_scan_offload_started = false;
6977 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006978
6979 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006980}
6981
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306982/*
6983 * sme_start_roaming() - Start roaming for a given sessionId
6984 * This is a synchronous call
6985 *
6986 * hHal - The handle returned by mac_open
6987 * sessionId - Session Identifier
6988 * Return QDF_STATUS_SUCCESS on success
6989 * Other status on failure
6990 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306991QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006992{
6993 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306994 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006995
6996 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306997 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006998 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
6999 reason);
7000 sme_release_global_lock(&pMac->sme);
7001 }
7002
7003 return status;
7004}
7005
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307006/*
7007 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7008 * Concurrent session exists
7009 * This is a synchronuous call
7010 *
7011 * hHal - The handle returned by mac_open.
7012 * Return QDF_STATUS_SUCCESS
7013 * Other status means SME is failed
7014 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307015QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007016 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307017 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007018{
7019
7020 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307021 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007022
7023 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307024 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007025 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7026 bFastRoamInConIniFeatureEnabled;
7027 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7028 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7029 0;
7030 }
7031 sme_release_global_lock(&pMac->sme);
7032 }
7033
7034 return status;
7035}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007036
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307037/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307038 * sme_set_roam_opportunistic_scan_threshold_diff() -
7039 * Update Opportunistic Scan threshold diff
7040 * This function is called through dynamic setConfig callback function
7041 * to configure nOpportunisticThresholdDiff
7042 *
7043 * hHal - HAL handle for device
7044 * sessionId - Session Identifier
7045 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7046 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7047 * successfully.
7048 * else SME is failed to update nOpportunisticThresholdDiff.
7049 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307050QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007051 uint8_t sessionId,
7052 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307053 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007054{
7055 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307056 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007057
7058 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307059 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007060 status = csr_neighbor_roam_update_config(pMac, sessionId,
7061 nOpportunisticThresholdDiff,
7062 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307063 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007064 pMac->roam.configParam.neighborRoamConfig.
7065 nOpportunisticThresholdDiff =
7066 nOpportunisticThresholdDiff;
7067 }
7068 sme_release_global_lock(&pMac->sme);
7069 }
7070 return status;
7071}
7072
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307073/*
7074 * sme_get_roam_opportunistic_scan_threshold_diff()
7075 * gets Opportunistic Scan threshold diff
7076 * This is a synchronous call
7077 *
7078 * hHal - The handle returned by mac_open
7079 * Return uint8_t - nOpportunisticThresholdDiff
7080 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007081uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7082{
7083 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307084
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007085 return pMac->roam.configParam.neighborRoamConfig.
7086 nOpportunisticThresholdDiff;
7087}
7088
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307089/*
7090 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7091 * This function is called through dynamic setConfig callback function
7092 * to configure nRoamRescanRssiDiff
7093 *
7094 * hHal - HAL handle for device
7095 * sessionId - Session Identifier
7096 * nRoamRescanRssiDiff - roam rescan rssi diff
7097 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7098 * successfully.
7099 * else SME is failed to update nRoamRescanRssiDiff.
7100 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307101QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007102 uint8_t sessionId,
7103 const uint8_t nRoamRescanRssiDiff)
7104{
7105 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307106 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007107
7108 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307109 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007110 status = csr_neighbor_roam_update_config(pMac, sessionId,
7111 nRoamRescanRssiDiff,
7112 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307113 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007114 pMac->roam.configParam.neighborRoamConfig.
7115 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7116 }
7117 sme_release_global_lock(&pMac->sme);
7118 }
7119 return status;
7120}
7121
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307122/*
7123 * sme_get_roam_rescan_rssi_diff()
7124 * gets roam rescan rssi diff
7125 * This is a synchronous call
7126 *
7127 * hHal - The handle returned by mac_open
7128 * Return int8_t - nRoamRescanRssiDiff
7129 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007130uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7131{
7132 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307133
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007134 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7135}
7136
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307137/*
7138 * sme_set_roam_bmiss_first_bcnt() -
7139 * Update Roam count for first beacon miss
7140 * This function is called through dynamic setConfig callback function
7141 * to configure nRoamBmissFirstBcnt
7142 * hHal - HAL handle for device
7143 * sessionId - Session Identifier
7144 * nRoamBmissFirstBcnt - Roam first bmiss count
7145 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7146 * successfully.
7147 * else SME is failed to update nRoamBmissFirstBcnt
7148 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307149QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007150 uint8_t sessionId,
7151 const uint8_t nRoamBmissFirstBcnt)
7152{
7153 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307154 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007155
7156 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307157 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007158 status = csr_neighbor_roam_update_config(pMac, sessionId,
7159 nRoamBmissFirstBcnt,
7160 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307161 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007162 pMac->roam.configParam.neighborRoamConfig.
7163 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7164 }
7165 sme_release_global_lock(&pMac->sme);
7166 }
7167 return status;
7168}
7169
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307170/*
7171 * sme_get_roam_bmiss_first_bcnt() -
7172 * get neighbor roam beacon miss first count
7173 *
7174 * hHal - The handle returned by mac_open.
7175 * Return uint8_t - neighbor roam beacon miss first count
7176 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007177uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7178{
7179 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307180
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007181 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7182}
7183
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307184/*
7185 * sme_set_roam_bmiss_final_bcnt() -
7186 * Update Roam count for final beacon miss
7187 * This function is called through dynamic setConfig callback function
7188 * to configure nRoamBmissFinalBcnt
7189 * hHal - HAL handle for device
7190 * sessionId - Session Identifier
7191 * nRoamBmissFinalBcnt - Roam final bmiss count
7192 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7193 * successfully.
7194 * else SME is failed to update nRoamBmissFinalBcnt
7195 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307196QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007197 uint8_t sessionId,
7198 const uint8_t nRoamBmissFinalBcnt)
7199{
7200 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307201 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007202
7203 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307204 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007205 status = csr_neighbor_roam_update_config(pMac, sessionId,
7206 nRoamBmissFinalBcnt,
7207 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307208 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007209 pMac->roam.configParam.neighborRoamConfig.
7210 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7211 }
7212 sme_release_global_lock(&pMac->sme);
7213 }
7214 return status;
7215}
7216
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307217/*
7218 * sme_get_roam_bmiss_final_bcnt() -
7219 * gets Roam count for final beacon miss
7220 * This is a synchronous call
7221 *
7222 * hHal - The handle returned by mac_open
7223 * Return uint8_t - nRoamBmissFinalBcnt
7224 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007225uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7226{
7227 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007229 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7230}
7231
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307232/*
7233 * sme_set_roam_beacon_rssi_weight() -
7234 * Update Roam beacon rssi weight
7235 * This function is called through dynamic setConfig callback function
7236 * to configure nRoamBeaconRssiWeight
7237 *
7238 * hHal - HAL handle for device
7239 * sessionId - Session Identifier
7240 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7241 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7242 * successfully.
7243 * else SME is failed to update nRoamBeaconRssiWeight
7244 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307245QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007246 uint8_t sessionId,
7247 const uint8_t nRoamBeaconRssiWeight)
7248{
7249 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307250 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251
7252 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307253 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007254 status = csr_neighbor_roam_update_config(pMac, sessionId,
7255 nRoamBeaconRssiWeight,
7256 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307257 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007258 pMac->roam.configParam.neighborRoamConfig.
7259 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7260 }
7261 sme_release_global_lock(&pMac->sme);
7262 }
7263 return status;
7264}
7265
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307266/*
7267 * sme_get_roam_beacon_rssi_weight() -
7268 * gets Roam beacon rssi weight
7269 * This is a synchronous call
7270 *
7271 * hHal - The handle returned by mac_open
7272 * Return uint8_t - nRoamBeaconRssiWeight
7273 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007274uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7275{
7276 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307277
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007278 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7279}
7280
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307281/*
7282 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7283 * rssi threshold
7284 * This is a synchronous call
7285 *
7286 * hHal - The handle returned by mac_open.
7287 * sessionId - Session Identifier
7288 * Return QDF_STATUS_SUCCESS - SME update config successful.
7289 * Other status means SME is failed to update
7290 */
7291QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7292 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7293{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007294 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307295 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007296
7297 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307298 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007299 status = csr_neighbor_roam_update_config(pMac,
7300 sessionId, neighborLookupRssiThreshold,
7301 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307302 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007303 pMac->roam.configParam.neighborRoamConfig.
7304 nNeighborLookupRssiThreshold =
7305 neighborLookupRssiThreshold;
7306 }
7307 sme_release_global_lock(&pMac->sme);
7308 }
7309 return status;
7310}
7311
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307312/*
7313 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7314 * This is a synchronous call
7315 *
7316 * hal - The handle returned by macOpen.
7317 * session_id - Session Identifier
7318 * delay_before_vdev_stop - value to be set
7319 * Return QDF_STATUS_SUCCESS - SME update config successful.
7320 * Other status means SME is failed to update
7321 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307322QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007323 uint8_t session_id,
7324 uint8_t delay_before_vdev_stop)
7325{
7326 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307327 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007328
7329 if (session_id >= CSR_ROAM_SESSION_MAX) {
7330 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7331 FL("Invalid sme session id: %d"), session_id);
7332 return QDF_STATUS_E_INVAL;
7333 }
7334
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007335 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307336 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307337 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7338 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007339 pMac->roam.configParam.neighborRoamConfig.
7340 delay_before_vdev_stop,
7341 delay_before_vdev_stop);
7342 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7343 delay_before_vdev_stop = delay_before_vdev_stop;
7344 pMac->roam.configParam.neighborRoamConfig.
7345 delay_before_vdev_stop = delay_before_vdev_stop;
7346 sme_release_global_lock(&pMac->sme);
7347 }
7348 return status;
7349}
7350
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307351/*
7352 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7353 * rssi threshold
7354 * This is a synchronous call
7355 *
7356 * hHal - The handle returned by mac_open.
7357 * Return QDF_STATUS_SUCCESS - SME update config successful.
7358 * Other status means SME is failed to update
7359 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007360uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7361{
7362 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307363
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007364 return pMac->roam.configParam.neighborRoamConfig.
7365 nNeighborLookupRssiThreshold;
7366}
7367
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307368/*
7369 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7370 * refresh period
7371 * This is a synchronous call
7372 *
7373 * hHal - The handle returned by mac_open.
7374 * sessionId - Session Identifier
7375 * Return QDF_STATUS_SUCCESS - SME update config successful.
7376 * Other status means SME is failed to update
7377 */
7378QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7379 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7380{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307382 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307383 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007384 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7385
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007386 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7387 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7388 FL("Invalid sme session id: %d"), sessionId);
7389 return QDF_STATUS_E_INVAL;
7390 }
7391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007392 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307393 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007394 pNeighborRoamConfig =
7395 &pMac->roam.configParam.neighborRoamConfig;
7396 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307397 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007398 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7399 neighborScanResultsRefreshPeriod,
7400 pMac->roam.configParam.neighborRoamConfig.
7401 nNeighborResultsRefreshPeriod,
7402 mac_trace_get_neighbour_roam_state(pMac->roam.
7403 neighborRoamInfo
7404 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307405 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007406 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7407 neighborScanResultsRefreshPeriod;
7408 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7409 neighborScanResultsRefreshPeriod;
7410
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307411 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7412 csr_roam_offload_scan(pMac, sessionId,
7413 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7414 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
7415 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007416 sme_release_global_lock(&pMac->sme);
7417 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307418
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007419 return status;
7420}
7421
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307422/*
7423 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7424 * offload feaure
7425 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7426 * gRoamScanOffloadEnabled.
7427 * This is a synchronous call
7428 *
7429 * hHal - The handle returned by mac_open.
7430 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7431 * Other status means SME is failed to update.
7432 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307433QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007434 bool nRoamScanOffloadEnabled)
7435{
7436 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307437 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007438
7439 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307440 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307441 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307442 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007443 pMac->roam.configParam.isRoamOffloadScanEnabled,
7444 nRoamScanOffloadEnabled);
7445 pMac->roam.configParam.isRoamOffloadScanEnabled =
7446 nRoamScanOffloadEnabled;
7447 sme_release_global_lock(&pMac->sme);
7448 }
7449
7450 return status;
7451}
7452
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307453/*
7454 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7455 * refresh period
7456 * This is a synchronous call
7457 *
7458 * \param hHal - The handle returned by mac_open.
7459 * \return uint16_t - Neighbor scan results refresh period value
7460 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007461uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7462{
7463 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007465 return pMac->roam.configParam.neighborRoamConfig.
7466 nNeighborResultsRefreshPeriod;
7467}
7468
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307469/*
7470 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7471 * This is a synchronuous call
7472 *
7473 * hHal - The handle returned by mac_open.
7474 * Return QDF_STATUS_SUCCESS - SME update config successful.
7475 * Other status means SME is failed to update
7476 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007477uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7478{
7479 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007481 return pMac->roam.configParam.neighborRoamConfig.
7482 nEmptyScanRefreshPeriod;
7483}
7484
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307485/*
7486 * sme_update_empty_scan_refresh_period
7487 * Update nEmptyScanRefreshPeriod
7488 * This function is called through dynamic setConfig callback function
7489 * to configure nEmptyScanRefreshPeriod
7490 * Usage: adb shell iwpriv wlan0 setConfig
7491 * nEmptyScanRefreshPeriod=[0 .. 60]
7492 *
7493 * hHal - HAL handle for device
7494 * sessionId - Session Identifier
7495 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7496 * Return Success or failure
7497 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007498
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307499QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7500 sessionId, uint16_t
7501 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007502{
7503 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307504 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307505 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007506 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7507
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007508 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7509 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7510 FL("Invalid sme session id: %d"), sessionId);
7511 return QDF_STATUS_E_INVAL;
7512 }
7513
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007514 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307515 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007516 pNeighborRoamConfig =
7517 &pMac->roam.configParam.neighborRoamConfig;
7518 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307519 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007520 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7521 nEmptyScanRefreshPeriod,
7522 pMac->roam.configParam.neighborRoamConfig.
7523 nEmptyScanRefreshPeriod,
7524 mac_trace_get_neighbour_roam_state(pMac->roam.
7525 neighborRoamInfo
7526 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307527 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007528 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7529 nEmptyScanRefreshPeriod;
7530 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7531 nEmptyScanRefreshPeriod;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307532
7533 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7534 csr_roam_offload_scan(pMac, sessionId,
7535 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7536 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7537 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007538 sme_release_global_lock(&pMac->sme);
7539 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307540
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007541 return status;
7542}
7543
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307544/*
7545 * sme_set_neighbor_scan_min_chan_time() -
7546 * Update nNeighborScanMinChanTime
7547 * This function is called through dynamic setConfig callback function
7548 * to configure gNeighborScanChannelMinTime
7549 * Usage: adb shell iwpriv wlan0 setConfig
7550 * gNeighborScanChannelMinTime=[0 .. 60]
7551 *
7552 * hHal - HAL handle for device
7553 * nNeighborScanMinChanTime - Channel minimum dwell time
7554 * sessionId - Session Identifier
7555 * Return Success or failure
7556 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307557QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007558 const uint16_t
7559 nNeighborScanMinChanTime,
7560 uint8_t sessionId)
7561{
7562 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307563 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007564
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007565 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7566 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7567 FL("Invalid sme session id: %d"), sessionId);
7568 return QDF_STATUS_E_INVAL;
7569 }
7570
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007571 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307572 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307573 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007574 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
7575 nNeighborScanMinChanTime,
7576 pMac->roam.configParam.neighborRoamConfig.
7577 nNeighborScanMinChanTime,
7578 mac_trace_get_neighbour_roam_state(pMac->roam.
7579 neighborRoamInfo
7580 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307581 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007582
7583 pMac->roam.configParam.neighborRoamConfig.
7584 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
7585 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7586 minChannelScanTime = nNeighborScanMinChanTime;
7587 sme_release_global_lock(&pMac->sme);
7588 }
7589
7590 return status;
7591}
7592
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307593/*
7594 * sme_set_neighbor_scan_max_chan_time() -
7595 * Update nNeighborScanMaxChanTime
7596 * This function is called through dynamic setConfig callback function
7597 * to configure gNeighborScanChannelMaxTime
7598 * Usage: adb shell iwpriv wlan0 setConfig
7599 * gNeighborScanChannelMaxTime=[0 .. 60]
7600 *
7601 * hHal - HAL handle for device
7602 * sessionId - Session Identifier
7603 * nNeighborScanMinChanTime - Channel maximum dwell time
7604 * Return Success or failure
7605 */
7606QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
7607 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007608 const uint16_t
7609 nNeighborScanMaxChanTime)
7610{
7611 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307612 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307613 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007614 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7615
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007616 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7617 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7618 FL("Invalid sme session id: %d"), sessionId);
7619 return QDF_STATUS_E_INVAL;
7620 }
7621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007622 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307623 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007624 pNeighborRoamConfig =
7625 &pMac->roam.configParam.neighborRoamConfig;
7626 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307627 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007628 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
7629 nNeighborScanMaxChanTime,
7630 pMac->roam.configParam.neighborRoamConfig.
7631 nNeighborScanMaxChanTime,
7632 mac_trace_get_neighbour_roam_state(pMac->roam.
7633 neighborRoamInfo
7634 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307635 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007636 pNeighborRoamConfig->nNeighborScanMaxChanTime =
7637 nNeighborScanMaxChanTime;
7638 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
7639 nNeighborScanMaxChanTime;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307640 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7641 csr_roam_offload_scan(pMac, sessionId,
7642 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7643 REASON_SCAN_CH_TIME_CHANGED);
7644 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007645 sme_release_global_lock(&pMac->sme);
7646 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007648
7649 return status;
7650}
7651
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307652/*
7653 * sme_get_neighbor_scan_min_chan_time() -
7654 * get neighbor scan min channel time
7655 *
7656 * hHal - The handle returned by mac_open.
7657 * sessionId - Session Identifier
7658 * Return uint16_t - channel min time value
7659 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007660uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
7661{
7662 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007663
7664 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7665 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7666 FL("Invalid sme session id: %d"), sessionId);
7667 return 0;
7668 }
7669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007670 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7671 minChannelScanTime;
7672}
7673
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307674/*
7675 * sme_get_neighbor_roam_state() -
7676 * get neighbor roam state
7677 *
7678 * hHal - The handle returned by mac_open.
7679 * sessionId - Session Identifier
7680 * Return uint32_t - neighbor roam state
7681 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007682uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
7683{
7684 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007685
7686 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7687 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7688 FL("Invalid sme session id: %d"), sessionId);
7689 return 0;
7690 }
7691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007692 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
7693}
7694
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307695/*
7696 * sme_get_current_roam_state() -
7697 * get current roam state
7698 *
7699 * hHal - The handle returned by mac_open.
7700 * sessionId - Session Identifier
7701 * Return uint32_t - current roam state
7702 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007703uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
7704{
7705 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007707 return pMac->roam.curState[sessionId];
7708}
7709
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307710/*
7711 * sme_get_current_roam_sub_state() -
7712 * \brief get neighbor roam sub state
7713 *
7714 * hHal - The handle returned by mac_open.
7715 * sessionId - Session Identifier
7716 * Return uint32_t - current roam sub state
7717 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007718uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
7719{
7720 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007722 return pMac->roam.curSubState[sessionId];
7723}
7724
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307725/*
7726 * sme_get_lim_sme_state() -
7727 * get Lim Sme state
7728 *
7729 * hHal - The handle returned by mac_open.
7730 * Return uint32_t - Lim Sme state
7731 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007732uint32_t sme_get_lim_sme_state(tHalHandle hHal)
7733{
7734 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007736 return pMac->lim.gLimSmeState;
7737}
7738
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307739/*
7740 * sme_get_lim_mlm_state() -
7741 * get Lim Mlm state
7742 *
7743 * hHal - The handle returned by mac_open.
7744 * Return uint32_t - Lim Mlm state
7745 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007746uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
7747{
7748 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007750 return pMac->lim.gLimMlmState;
7751}
7752
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307753/*
7754 * sme_is_lim_session_valid() -
7755 * is Lim session valid
7756 *
7757 * hHal - The handle returned by mac_open.
7758 * sessionId - Session Identifier
7759 * Return bool - true or false
7760 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007761bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
7762{
7763 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05307764
7765 if (sessionId > pMac->lim.maxBssId)
7766 return false;
7767
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007768 return pMac->lim.gpSession[sessionId].valid;
7769}
7770
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307771/*
7772 * sme_get_lim_sme_session_state() -
7773 * get Lim Sme session state
7774 *
7775 * hHal - The handle returned by mac_open.
7776 * sessionId - Session Identifier
7777 * Return uint32_t - Lim Sme session state
7778 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007779uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
7780{
7781 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007783 return pMac->lim.gpSession[sessionId].limSmeState;
7784}
7785
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307786/*
7787 * sme_get_lim_mlm_session_state() -
7788 * \brief get Lim Mlm session state
7789 *
7790 * hHal - The handle returned by mac_open.
7791 * sessionId - Session Identifier
7792 * Return uint32_t - Lim Mlm session state
7793 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007794uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
7795{
7796 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007798 return pMac->lim.gpSession[sessionId].limMlmState;
7799}
7800
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307801/*
7802 * sme_get_neighbor_scan_max_chan_time() -
7803 * get neighbor scan max channel time
7804 *
7805 * hHal - The handle returned by mac_open.
7806 * sessionId - Session Identifier
7807 * Return uint16_t - channel max time value
7808 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007809uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
7810{
7811 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007812
7813 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7814 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7815 FL("Invalid sme session id: %d"), sessionId);
7816 return 0;
7817 }
7818
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007819 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7820 maxChannelScanTime;
7821}
7822
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307823/*
7824 * sme_set_neighbor_scan_period() -
7825 * Update nNeighborScanPeriod
7826 * This function is called through dynamic setConfig callback function
7827 * to configure nNeighborScanPeriod
7828 * Usage: adb shell iwpriv wlan0 setConfig
7829 * nNeighborScanPeriod=[0 .. 1000]
7830 *
7831 * hHal - HAL handle for device
7832 * sessionId - Session Identifier
7833 * nNeighborScanPeriod - neighbor scan period
7834 * Return Success or failure
7835 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307836QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007837 const uint16_t nNeighborScanPeriod)
7838{
7839 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307840 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307841 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007842 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7843
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007844 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7845 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7846 FL("Invalid sme session id: %d"), sessionId);
7847 return QDF_STATUS_E_INVAL;
7848 }
7849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007850 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307851 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007852 pNeighborRoamConfig =
7853 &pMac->roam.configParam.neighborRoamConfig;
7854 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307855 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307856 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007857 nNeighborScanPeriod,
7858 pMac->roam.configParam.neighborRoamConfig.
7859 nNeighborScanTimerPeriod,
7860 mac_trace_get_neighbour_roam_state(pMac->roam.
7861 neighborRoamInfo
7862 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307863 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007864 pNeighborRoamConfig->nNeighborScanTimerPeriod =
7865 nNeighborScanPeriod;
7866 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
7867 nNeighborScanPeriod;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307868
7869 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7870 csr_roam_offload_scan(pMac, sessionId,
7871 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7872 REASON_SCAN_HOME_TIME_CHANGED);
7873 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007874 sme_release_global_lock(&pMac->sme);
7875 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007876
7877 return status;
7878}
7879
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307880/*
7881 * sme_get_neighbor_scan_period() -
7882 * get neighbor scan period
7883 *
7884 * hHal - The handle returned by mac_open.
7885 * sessionId - Session Identifier
7886 * Return uint16_t - neighbor scan period
7887 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007888uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
7889{
7890 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007891
7892 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7893 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7894 FL("Invalid sme session id: %d"), sessionId);
7895 return 0;
7896 }
7897
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007898 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7899 neighborScanPeriod;
7900}
7901
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307902/**
7903 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
7904 * This function is called through dynamic setConfig callback function
7905 * to configure neighbor_scan_min_period
7906 *
7907 * @hal - HAL handle for device
7908 * @session_id - Session Identifier
7909 * @neighbor_scan_min_period - neighbor scan min period
7910 *
7911 * Return - QDF_STATUS
7912 */
7913QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
7914 uint8_t session_id,
7915 const uint16_t
7916 neighbor_scan_min_period)
7917{
7918 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
7919 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307920 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307921 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007922
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307923 if (session_id >= CSR_ROAM_SESSION_MAX) {
7924 sme_err("Invalid sme session id: %d", session_id);
7925 return QDF_STATUS_E_INVAL;
7926 }
7927
7928 status = sme_acquire_global_lock(&pmac->sme);
7929 if (QDF_IS_STATUS_SUCCESS(status)) {
7930 p_neighbor_roam_config =
7931 &pmac->roam.configParam.neighborRoamConfig;
7932 p_neighbor_roam_info = &pmac->
7933 roam.neighborRoamInfo[session_id];
7934 sme_debug("LFR:set neighbor scan min period, old:%d, "
7935 "new: %d, state: %s",
7936 pmac->roam.configParam.neighborRoamConfig.
7937 neighbor_scan_min_timer_period,
7938 neighbor_scan_min_period,
7939 mac_trace_get_neighbour_roam_state(pmac->roam.
7940 neighborRoamInfo[session_id].
7941 neighborRoamState));
7942 p_neighbor_roam_config->neighbor_scan_min_timer_period =
7943 neighbor_scan_min_period;
7944 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
7945 neighbor_scan_min_period;
7946 sme_release_global_lock(&pmac->sme);
7947 }
7948
7949 return status;
7950}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007951
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307952/*
7953 * sme_get_roam_rssi_diff() - get Roam rssi diff
7954 * This is a synchronous call
7955 *
7956 * hHal - The handle returned by mac_open.
7957 * Return uint16_t - Rssi diff value
7958 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007959uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
7960{
7961 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 return pMac->roam.configParam.RoamRssiDiff;
7964}
7965
7966/**
7967 * sme_change_roam_scan_channel_list() - to change scan channel list
7968 * @hHal: pointer HAL handle returned by mac_open
7969 * @sessionId: sme session id
7970 * @pChannelList: Output channel list
7971 * @numChannels: Output number of channels
7972 *
7973 * This routine is called to Change roam scan channel list.
7974 * This is a synchronous call
7975 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307976 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007977 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307978QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007979 uint8_t *pChannelList,
7980 uint8_t numChannels)
7981{
7982 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307983 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007984 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007985 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
7986 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
7987 uint8_t i = 0, j = 0;
7988 tCsrChannelInfo *chan_info;
7989
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007990 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7991 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7992 FL("Invalid sme session id: %d"), sessionId);
7993 return QDF_STATUS_E_INVAL;
7994 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007995
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007996 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007997 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307998 if (!QDF_IS_STATUS_SUCCESS(status)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307999 sme_err("Failed to acquire SME lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008000 return status;
8001 }
8002 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8003
8004 if (NULL != chan_info->ChannelList) {
8005 for (i = 0; i < chan_info->numOfChannels; i++) {
8006 if (j < sizeof(oldChannelList))
8007 j += snprintf(oldChannelList + j,
8008 sizeof(oldChannelList) -
8009 j, "%d",
8010 chan_info->ChannelList[i]);
8011 else
8012 break;
8013 }
8014 }
8015 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8016 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8017 numChannels);
8018 sme_set_roam_scan_control(hHal, sessionId, 1);
8019 if (NULL != chan_info->ChannelList) {
8020 j = 0;
8021 for (i = 0; i < chan_info->numOfChannels; i++) {
8022 if (j < sizeof(newChannelList))
8023 j += snprintf(newChannelList + j,
8024 sizeof(newChannelList) -
8025 j, " %d",
8026 chan_info->ChannelList[i]);
8027 else
8028 break;
8029 }
8030 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308031 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308032 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008033 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308034 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008035
8036 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8037 csr_roam_offload_scan(pMac, sessionId,
8038 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8039 REASON_CHANNEL_LIST_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05308040
8041 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008042 return status;
8043}
8044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008045/**
8046 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8047 * @hHal: HAL pointer
8048 * @pChannelList: Output channel list
8049 * @pNumChannels: Output number of channels
8050 * @sessionId: Session Identifier
8051 *
8052 * To get roam scan channel list This is a synchronous call
8053 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308054 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008055 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308056QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008057 uint8_t *pChannelList, uint8_t *pNumChannels,
8058 uint8_t sessionId)
8059{
8060 int i = 0;
8061 uint8_t *pOutPtr = pChannelList;
8062 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008063 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308064 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008065
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008066 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8067 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8068 FL("Invalid sme session id: %d"), sessionId);
8069 return QDF_STATUS_E_INVAL;
8070 }
8071
8072 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008073 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308074 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008075 return status;
8076 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308077 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008078 FL("Roam Scan channel list is NOT yet initialized"));
8079 *pNumChannels = 0;
8080 sme_release_global_lock(&pMac->sme);
8081 return status;
8082 }
8083
8084 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308085 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008086 pOutPtr[i] =
8087 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308088
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008089 pOutPtr[i] = '\0';
8090 sme_release_global_lock(&pMac->sme);
8091 return status;
8092}
8093
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308094/*
8095 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8096 * This is a synchronuous call
8097 *
8098 * hHal - The handle returned by mac_open.
8099 * Return true (1) - if the ESE feature is enabled
8100 * false (0) - if feature is disabled (compile or runtime)
8101 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008102bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8103{
8104#ifdef FEATURE_WLAN_ESE
8105 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008107 return csr_roam_is_ese_ini_feature_enabled(pMac);
8108#else
8109 return false;
8110#endif
8111}
8112
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308113/*
8114 * sme_get_wes_mode() - get WES Mode
8115 * This is a synchronous call
8116 *
8117 * hHal - The handle returned by mac_open
8118 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8119 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008120bool sme_get_wes_mode(tHalHandle hHal)
8121{
8122 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008124 return pMac->roam.configParam.isWESModeEnabled;
8125}
8126
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308127/*
8128 * sme_get_roam_scan_control() - get scan control
8129 * This is a synchronous call
8130 *
8131 * hHal - The handle returned by mac_open.
8132 * Return bool - Enabled(1)/Disabled(0)
8133 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008134bool sme_get_roam_scan_control(tHalHandle hHal)
8135{
8136 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308137
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008138 return pMac->roam.configParam.nRoamScanControl;
8139}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008140
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308141/*
8142 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8143 * This is a synchronuous call
8144 * hHal - The handle returned by mac_open.
8145 * Return true (1) - if the feature is enabled
8146 * false (0) - if feature is disabled (compile or runtime)
8147 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008148bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8149{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008150 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308151
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008152 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008153}
8154
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308155/*
8156 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8157 * This is a synchronuous call
8158 *
8159 * hHal - The handle returned by mac_open.
8160 * Return true (1) - if the feature is enabled
8161 * false (0) - if feature is disabled (compile or runtime)
8162 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008163bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8164{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008165 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308166
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008167 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008168}
8169
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008170/**
8171 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8172 * @feature: enum value of requested feature.
8173 *
8174 * Retrun: 1 if supported; 0 otherwise
8175 */
8176bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008177{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008178 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008179}
8180
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308181QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182 void *plsContext,
8183 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8184 void *pContext))
8185{
8186
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308187 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008188 tpAniSirGlobal pMac;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308189 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008190
Jeff Johnsona5317a62017-01-26 08:51:25 -08008191 if (!hHal || !pCallbackfn || !lsReq) {
8192 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8193 FL("Invalid parameter"));
8194 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008195 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008196
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308197 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8198 if (!wma_handle) {
8199 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8200 "wma handle is NULL");
8201 return QDF_STATUS_E_FAILURE;
8202 }
8203
Jeff Johnsona5317a62017-01-26 08:51:25 -08008204 pMac = PMAC_STRUCT(hHal);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008205 status = sme_acquire_global_lock(&pMac->sme);
8206 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008207 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008208 return QDF_STATUS_E_FAILURE;
8209 }
8210
8211 pMac->sme.pLinkSpeedCbContext = plsContext;
8212 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
gaurank kathpaliaca8f4612018-06-13 14:21:53 +05308213 status = wma_get_link_speed(wma_handle, lsReq);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008214 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008215 return status;
8216}
8217
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308218QDF_STATUS sme_get_peer_stats(tpAniSirGlobal mac,
8219 struct sir_peer_info_req req)
8220{
8221 QDF_STATUS qdf_status;
8222 struct scheduler_msg message = {0};
8223
8224 qdf_status = sme_acquire_global_lock(&mac->sme);
8225 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8226 sme_debug("Failed to get Lock");
8227 return qdf_status;
8228 }
8229 /* serialize the req through MC thread */
8230 message.bodyptr = qdf_mem_malloc(sizeof(req));
8231 if (NULL == message.bodyptr) {
8232 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8233 "%s: Memory allocation failed.", __func__);
8234 sme_release_global_lock(&mac->sme);
8235 return QDF_STATUS_E_NOMEM;
8236 }
8237 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8238 message.type = WMA_GET_PEER_INFO;
8239 message.reserved = 0;
8240 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8241 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8242 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8243 "%s: Post get peer info msg fail", __func__);
8244 qdf_mem_free(message.bodyptr);
8245 qdf_status = QDF_STATUS_E_FAILURE;
8246 }
8247 sme_release_global_lock(&mac->sme);
8248 return qdf_status;
8249}
8250
Will Huang558f8082017-05-31 16:22:24 +08008251QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8252 void *context,
8253 void (*callbackfn)(struct sir_peer_info_resp *param,
8254 void *pcontext))
8255{
8256
8257 QDF_STATUS status;
8258 QDF_STATUS qdf_status;
8259 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008260 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008261
8262 status = sme_acquire_global_lock(&mac->sme);
8263 if (QDF_STATUS_SUCCESS == status) {
8264 if (NULL == callbackfn) {
8265 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8266 "%s: Indication Call back is NULL",
8267 __func__);
8268 sme_release_global_lock(&mac->sme);
8269 return QDF_STATUS_E_FAILURE;
8270 }
8271
8272 mac->sme.pget_peer_info_ind_cb = callbackfn;
8273 mac->sme.pget_peer_info_cb_context = context;
8274
8275 /* serialize the req through MC thread */
8276 message.bodyptr = qdf_mem_malloc(sizeof(req));
8277 if (NULL == message.bodyptr) {
8278 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8279 "%s: Memory allocation failed.", __func__);
8280 sme_release_global_lock(&mac->sme);
8281 return QDF_STATUS_E_NOMEM;
8282 }
8283 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8284 message.type = WMA_GET_PEER_INFO;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308285 message.reserved = 0;
Will Huang558f8082017-05-31 16:22:24 +08008286 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8287 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8288 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8289 "%s: Post get peer info msg fail", __func__);
8290 qdf_mem_free(message.bodyptr);
8291 status = QDF_STATUS_E_FAILURE;
8292 }
8293 sme_release_global_lock(&mac->sme);
8294 }
8295 return status;
8296}
8297
8298QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8299 struct sir_peer_info_ext_req *req,
8300 void *context,
8301 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8302 void *pcontext))
8303{
8304 QDF_STATUS status;
8305 QDF_STATUS qdf_status;
8306 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008307 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008308
8309 status = sme_acquire_global_lock(&mac->sme);
8310 if (QDF_STATUS_SUCCESS == status) {
8311 if (NULL == callbackfn) {
8312 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8313 "%s: Indication Call back is NULL",
8314 __func__);
8315 sme_release_global_lock(&mac->sme);
8316 return QDF_STATUS_E_FAILURE;
8317 }
8318
8319 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8320 mac->sme.pget_peer_info_ext_cb_context = context;
8321
8322 /* serialize the req through MC thread */
8323 message.bodyptr =
8324 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8325 if (NULL == message.bodyptr) {
8326 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8327 "%s: Memory allocation failed.", __func__);
8328 sme_release_global_lock(&mac->sme);
8329 return QDF_STATUS_E_NOMEM;
8330 }
8331 qdf_mem_copy(message.bodyptr,
8332 req,
8333 sizeof(struct sir_peer_info_ext_req));
8334 message.type = WMA_GET_PEER_INFO_EXT;
8335 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8336 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8337 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8338 "%s: Post get rssi msg fail", __func__);
8339 qdf_mem_free(message.bodyptr);
8340 status = QDF_STATUS_E_FAILURE;
8341 }
8342 sme_release_global_lock(&mac->sme);
8343 }
8344 return status;
8345}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008346
8347/*
8348 * SME API to enable/disable WLAN driver initiated SSR
8349 */
8350void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8351{
8352 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308353 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008354
8355 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308356 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008357 sme_debug("SSR level is changed %d", enableSSR);
Jeff Johnson698eacd2018-05-12 17:00:03 -07008358 /* not serializing this message, as this is only going
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008359 * to set a variable in WMA/WDI
8360 */
8361 WMA_SetEnableSSR(enableSSR);
8362 sme_release_global_lock(&pMac->sme);
8363 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008364}
8365
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008366/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8367ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8368{
8369 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8370}
8371
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308372/*
8373 * sme_set_curr_device_mode() - Sets the current operating device mode.
8374 *
8375 * hHal - The handle returned by mac_open.
8376 * currDeviceMode - Current operating device mode.
8377 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008378void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008379 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008380{
8381 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308382
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008383 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008384}
8385
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308386/*
8387 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8388 * This is a synchronous call
8389 *
8390 * hHal - The handle returned by mac_open
8391 * sessionId - Session Identifier
8392 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8393 * BSSID, channel etc.)
8394 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8395 * Other status means SME is failed to send the request.
8396 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008397
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308398QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008399 uint8_t sessionId,
8400 tCsrHandoffRequest *pHandoffInfo)
8401{
8402 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308403 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008404
8405 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308406 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308407 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008408 "%s: invoked", __func__);
8409 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8410 sme_release_global_lock(&pMac->sme);
8411 }
8412
8413 return status;
8414}
8415
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008416/*
8417 * SME API to check if there is any infra station or
8418 * P2P client is connected
8419 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308420QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008421{
8422 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308423
8424 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308425 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308426
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308427 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008428}
8429
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008430/**
8431 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8432 * @hal: global hal handle
8433 * @addPeriodicTxPtrnParams: request message
8434 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308435 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008436 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308437QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008438sme_add_periodic_tx_ptrn(tHalHandle hal,
8439 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8440{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308441 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008442 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8443 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008444 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008445
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008446 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008447
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308448 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008449 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008450 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308451 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008452 }
8453
8454 *req_msg = *addPeriodicTxPtrnParams;
8455
8456 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308457 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008458 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008459 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308460 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008461 return status;
8462 }
8463
8464 /* Serialize the req through MC thread */
8465 msg.bodyptr = req_msg;
8466 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308467 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8468 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008469 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308470 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008471 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008472 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308473 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008474 }
8475 sme_release_global_lock(&mac->sme);
8476 return status;
8477}
8478
8479/**
8480 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
8481 * @hal: global hal handle
8482 * @delPeriodicTxPtrnParams: request message
8483 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308484 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008485 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308486QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008487sme_del_periodic_tx_ptrn(tHalHandle hal,
8488 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
8489{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308490 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008491 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8492 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008493 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008494
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008495 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008496
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308497 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008498 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008499 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308500 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008501 }
8502
8503 *req_msg = *delPeriodicTxPtrnParams;
8504
8505 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308506 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008507 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008508 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308509 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008510 return status;
8511 }
8512
8513 /* Serialize the req through MC thread */
8514 msg.bodyptr = req_msg;
8515 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308516 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8517 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008518 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308519 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008520 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008521 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308522 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008523 }
8524 sme_release_global_lock(&mac->sme);
8525 return status;
8526}
8527
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308528/*
8529 * sme_enable_rmc() - enables RMC
8530 * @hHal : Pointer to global HAL handle
8531 * @sessionId : Session ID
8532 *
8533 * Return: QDF_STATUS
8534 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008535QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
8536{
8537 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8538 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008539 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008540 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8541
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008542 SME_ENTER();
8543
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008544 status = sme_acquire_global_lock(&pMac->sme);
8545 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008546 message.bodyptr = NULL;
8547 message.type = WMA_RMC_ENABLE_IND;
8548 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8549 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008550 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8551 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8552 "%s: failed to post message to WMA",
8553 __func__);
8554 status = QDF_STATUS_E_FAILURE;
8555 }
8556 sme_release_global_lock(&pMac->sme);
8557 }
8558 return status;
8559}
8560
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308561/*
8562 * sme_disable_rmc() - disables RMC
8563 * @hHal : Pointer to global HAL handle
8564 * @sessionId : Session ID
8565 *
8566 * Return: QDF_STATUS
8567 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008568QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
8569{
8570 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8571 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008572 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008573 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8574
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008575 SME_ENTER();
8576
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008577 status = sme_acquire_global_lock(&pMac->sme);
8578 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008579 message.bodyptr = NULL;
8580 message.type = WMA_RMC_DISABLE_IND;
8581 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8582 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008583 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8584 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8585 "%s: failed to post message to WMA",
8586 __func__);
8587 status = QDF_STATUS_E_FAILURE;
8588 }
8589 sme_release_global_lock(&pMac->sme);
8590 }
8591 return status;
8592}
8593
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308594/*
8595 * sme_send_rmc_action_period() - sends RMC action period param to target
8596 * @hHal : Pointer to global HAL handle
8597 * @sessionId : Session ID
8598 *
8599 * Return: QDF_STATUS
8600 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008601QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
8602{
8603 QDF_STATUS status = QDF_STATUS_SUCCESS;
8604 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8605 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008606 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008607
8608 status = sme_acquire_global_lock(&pMac->sme);
8609 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008610 message.bodyptr = NULL;
8611 message.type = WMA_RMC_ACTION_PERIOD_IND;
8612 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8613 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008614 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8615 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8616 "%s: failed to post message to WMA",
8617 __func__);
8618 status = QDF_STATUS_E_FAILURE;
8619 }
8620 sme_release_global_lock(&pMac->sme);
8621 }
8622
8623 return status;
8624}
8625
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308626/*
8627 * sme_request_ibss_peer_info() - request ibss peer info
8628 * @hHal : Pointer to global HAL handle
8629 * @pUserData : Pointer to user data
8630 * @peerInfoCbk : Peer info callback
8631 * @allPeerInfoReqd : All peer info required or not
8632 * @staIdx : sta index
8633 *
8634 * Return: QDF_STATUS
8635 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008636QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
8637 pIbssPeerInfoCb peerInfoCbk,
8638 bool allPeerInfoReqd, uint8_t staIdx)
8639{
8640 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8641 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
8642 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008643 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008644 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
8645
8646 status = sme_acquire_global_lock(&pMac->sme);
8647 if (QDF_STATUS_SUCCESS == status) {
8648 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
8649 pMac->sme.peerInfoParams.pUserData = pUserData;
8650
8651 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308652 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008653 if (NULL == pIbssInfoReqParams) {
8654 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8655 "%s: Not able to allocate memory for dhcp start",
8656 __func__);
8657 sme_release_global_lock(&pMac->sme);
8658 return QDF_STATUS_E_NOMEM;
8659 }
8660 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
8661 pIbssInfoReqParams->staIdx = staIdx;
8662
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008663 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
8664 message.bodyptr = pIbssInfoReqParams;
8665 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008666
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008667 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8668 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008669 if (QDF_STATUS_SUCCESS != qdf_status) {
8670 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8671 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
8672 __func__);
8673 qdf_mem_free(pIbssInfoReqParams);
8674 qdf_status = QDF_STATUS_E_FAILURE;
8675 }
8676 sme_release_global_lock(&pMac->sme);
8677 }
8678
8679 return qdf_status;
8680}
8681
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308682/*
8683 * sme_send_cesium_enable_ind() -
8684 * Used to send proprietary cesium enable indication to fw
8685 *
8686 * hHal
8687 * sessionId
8688 * Return QDF_STATUS
8689 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008690QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
8691{
8692 QDF_STATUS status = QDF_STATUS_SUCCESS;
8693 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8694 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008695 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008696
8697 status = sme_acquire_global_lock(&pMac->sme);
8698 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008699 message.bodyptr = NULL;
8700 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
8701 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8702 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008703 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8704 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8705 "%s: failed to post message to WMA",
8706 __func__);
8707 status = QDF_STATUS_E_FAILURE;
8708 }
8709 sme_release_global_lock(&pMac->sme);
8710 }
8711
8712 return status;
8713}
8714
Paul Zhang99fe8842017-12-08 14:43:46 +08008715QDF_STATUS sme_set_wlm_latency_level(tHalHandle hal, uint16_t session_id,
8716 uint16_t latency_level)
8717{
8718 QDF_STATUS status;
8719 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
8720 struct wlm_latency_level_param params;
8721 void *wma = cds_get_context(QDF_MODULE_ID_WMA);
8722
Bala Venkatesh7cf5b662018-05-10 15:18:53 +05308723 if (!wma)
8724 return QDF_STATUS_E_FAILURE;
8725
Paul Zhang99fe8842017-12-08 14:43:46 +08008726 if (!mac_ctx->roam.configParam.wlm_latency_enable) {
8727 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8728 "%s: WLM latency level setting is disabled",
8729 __func__);
8730 return QDF_STATUS_E_FAILURE;
8731 }
Krunal Soni3fa80e22018-01-09 14:16:02 -08008732 if (!wma) {
8733 sme_err("wma is NULL");
8734 return QDF_STATUS_E_FAILURE;
8735 }
Paul Zhang99fe8842017-12-08 14:43:46 +08008736
8737 params.wlm_latency_level = latency_level;
8738 params.wlm_latency_flags =
8739 mac_ctx->roam.configParam.wlm_latency_flags[latency_level];
8740 params.vdev_id = session_id;
8741
8742 status = wma_set_wlm_latency_level(wma, &params);
8743 if (!QDF_IS_STATUS_SUCCESS(status))
8744 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8745 "%s: failed to set latency level",
8746 __func__);
8747
8748 return status;
8749}
8750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008751void sme_get_command_q_status(tHalHandle hHal)
8752{
8753 tSmeCmd *pTempCmd = NULL;
8754 tListElem *pEntry;
8755 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8756
8757 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308758 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008759 "%s: pMac is NULL", __func__);
8760 return;
8761 }
8762
Krunal Sonia8270f52017-02-23 19:51:25 -08008763 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308764 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008765 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308766
Kabilan Kannan33fcd682018-03-08 14:29:46 -08008767 sme_err("WLAN_BUG_RCA: Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008768 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
8769 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308770 if (eSmeCsrCommandMask & pTempCmd->command)
8771 /* CSR command is stuck. See what the reason code is
8772 * for that command
8773 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008774 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008775 } /* if(pTempCmd) */
8776
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008777 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08008778 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008779
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008780}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07008781/**
8782 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
8783 * @hal: The handle returned by macOpen
8784 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
8785 */
8786void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
8787 bool sta_prefer_80MHz_over_160MHz)
8788{
8789 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308790
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07008791 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
8792}
8793
Agrawal Ashishb141b092016-09-02 19:59:26 +05308794#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008795/**
8796 * sme_set_dot11p_config() - API to set the 802.11p config
8797 * @hHal: The handle returned by macOpen
8798 * @enable_dot11p: 802.11p config param
8799 */
8800void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
8801{
8802 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308803
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008804 pMac->enable_dot11p = enable_dot11p;
8805}
8806
8807/**
8808 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
8809 * @src: the source configuration
8810 *
8811 * Return: pointer to the copied OCB configuration
8812 */
8813static struct sir_ocb_config *sme_copy_sir_ocb_config(
8814 struct sir_ocb_config *src)
8815{
8816 struct sir_ocb_config *dst;
8817 uint32_t length;
8818 void *cursor;
8819
8820 length = sizeof(*src) +
8821 src->channel_count * sizeof(*src->channels) +
8822 src->schedule_size * sizeof(*src->schedule) +
8823 src->dcc_ndl_chan_list_len +
8824 src->dcc_ndl_active_state_list_len;
8825
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308826 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008827 if (!dst)
8828 return NULL;
8829
8830 *dst = *src;
8831
8832 cursor = dst;
8833 cursor += sizeof(*dst);
8834 dst->channels = cursor;
8835 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308836 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008837 src->channel_count * sizeof(*src->channels));
8838 dst->schedule = cursor;
8839 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308840 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008841 src->schedule_size * sizeof(*src->schedule));
8842 dst->dcc_ndl_chan_list = cursor;
8843 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308844 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008845 src->dcc_ndl_chan_list_len);
8846 dst->dcc_ndl_active_state_list = cursor;
8847 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308848 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008849 src->dcc_ndl_active_state_list,
8850 src->dcc_ndl_active_state_list_len);
8851 return dst;
8852}
8853
8854/**
8855 * sme_ocb_set_config() - Set the OCB configuration
8856 * @hHal: reference to the HAL
8857 * @context: the context of the call
8858 * @callback: the callback to hdd
8859 * @config: the OCB configuration
8860 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308861 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008862 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308863QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008864 ocb_callback callback,
8865 struct sir_ocb_config *config)
8866{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308867 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008868 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008869 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870 struct sir_ocb_config *msg_body;
8871
8872 /* Lock the SME structure */
8873 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308874 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008875 return status;
8876
8877 /*
8878 * Check if there is a pending request and return an error if one
8879 * exists
8880 */
8881 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308882 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008883 goto end;
8884 }
8885
8886 msg_body = sme_copy_sir_ocb_config(config);
8887
8888 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308889 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008890 goto end;
8891 }
8892
8893 msg.type = WMA_OCB_SET_CONFIG_CMD;
8894 msg.bodyptr = msg_body;
8895
8896 /* Set the request callback and context */
8897 pMac->sme.ocb_set_config_callback = callback;
8898 pMac->sme.ocb_set_config_context = context;
8899
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008900 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308901 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308902 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008903 FL("Error posting message to WDA: %d"), status);
8904 pMac->sme.ocb_set_config_callback = callback;
8905 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308906 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008907 goto end;
8908 }
8909
8910end:
8911 sme_release_global_lock(&pMac->sme);
8912
8913 return status;
8914}
8915
8916/**
8917 * sme_ocb_set_utc_time() - Set the OCB UTC time
8918 * @hHal: reference to the HAL
8919 * @utc: the UTC time struct
8920 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308921 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008922 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308923QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008924{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308925 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008926 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008927 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008928 struct sir_ocb_utc *sme_utc;
8929
8930 /* Lock the SME structure */
8931 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308932 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008933 return status;
8934
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308935 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008936 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308937 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008938 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308939 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008940 goto end;
8941 }
8942 *sme_utc = *utc;
8943
8944 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
8945 msg.reserved = 0;
8946 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008947 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308948 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308949 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008950 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308951 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008952 goto end;
8953 }
8954
8955end:
8956 sme_release_global_lock(&pMac->sme);
8957
8958 return status;
8959}
8960
8961/**
8962 * sme_ocb_start_timing_advert() - Start sending timing advert frames
8963 * @hHal: reference to the HAL
8964 * @timing_advert: the timing advertisement struct
8965 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308966 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008967 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308968QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008969 struct sir_ocb_timing_advert *timing_advert)
8970{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308971 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008972 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008973 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008974 void *buf;
8975 struct sir_ocb_timing_advert *sme_timing_advert;
8976
8977 /* Lock the SME structure */
8978 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308979 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008980 return status;
8981
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308982 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008983 timing_advert->template_length);
8984 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308985 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008986 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308987 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008988 goto end;
8989 }
8990
8991 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
8992 *sme_timing_advert = *timing_advert;
8993 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308994 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008995 timing_advert->template_value, timing_advert->template_length);
8996
8997 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
8998 msg.reserved = 0;
8999 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009000 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309001 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309002 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009003 FL("Not able to post msg to WDA"));
9004 goto end;
9005 }
9006
9007end:
9008 sme_release_global_lock(&pMac->sme);
9009
9010 return status;
9011}
9012
9013/**
9014 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9015 * @hHal: reference to the HAL
9016 * @timing_advert: the timing advertisement struct
9017 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309018 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009019 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309020QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009021 struct sir_ocb_timing_advert *timing_advert)
9022{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309023 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009024 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009025 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009026 struct sir_ocb_timing_advert *sme_timing_advert;
9027
9028 /* Lock the SME structure */
9029 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309030 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009031 return status;
9032
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309033 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009034 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309035 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009036 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309037 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009038 goto end;
9039 }
9040 *sme_timing_advert = *timing_advert;
9041
9042 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9043 msg.reserved = 0;
9044 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009045 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309046 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309047 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009048 FL("Not able to post msg to WDA"));
9049 goto end;
9050 }
9051
9052end:
9053 sme_release_global_lock(&pMac->sme);
9054
9055 return status;
9056}
9057
9058/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009059 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9060 * @hal_handle: reference to the HAL
9061 * @self_addr: the self MAC address
9062 * @buf: the buffer that will contain the frame
9063 * @timestamp_offset: return for the offset of the timestamp field
9064 * @time_value_offset: return for the time_value field in the TA IE
9065 *
9066 * Return: the length of the buffer.
9067 */
9068int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9069 tSirMacAddr self_addr, uint8_t **buf,
9070 uint32_t *timestamp_offset,
9071 uint32_t *time_value_offset)
9072{
9073 int template_length;
9074 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9075
9076 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9077 timestamp_offset,
9078 time_value_offset);
9079 return template_length;
9080}
9081/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009082 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9083 * @hHal: reference to the HAL
9084 * @context: the context of the call
9085 * @callback: the callback to hdd
9086 * @request: the TSF timer request
9087 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309088 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009089 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309090QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009091 ocb_callback callback,
9092 struct sir_ocb_get_tsf_timer *request)
9093{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309094 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009095 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009096 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009097 struct sir_ocb_get_tsf_timer *msg_body;
9098
9099 /* Lock the SME structure */
9100 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309101 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009102 return status;
9103
9104 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309105 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009106 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309107 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009108 goto end;
9109 }
9110 *msg_body = *request;
9111
9112 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9113 msg.bodyptr = msg_body;
9114
9115 /* Set the request callback and the context */
9116 pMac->sme.ocb_get_tsf_timer_callback = callback;
9117 pMac->sme.ocb_get_tsf_timer_context = context;
9118
9119 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009120 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309121 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309122 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009123 FL("Error posting message to WDA: %d"), status);
9124 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9125 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309126 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009127 goto end;
9128 }
9129
9130end:
9131 sme_release_global_lock(&pMac->sme);
9132
9133 return status;
9134}
9135
9136/**
9137 * sme_dcc_get_stats() - Get the DCC stats
9138 * @hHal: reference to the HAL
9139 * @context: the context of the call
9140 * @callback: the callback to hdd
9141 * @request: the get DCC stats request
9142 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309143 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009144 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309145QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009146 ocb_callback callback,
9147 struct sir_dcc_get_stats *request)
9148{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309149 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009150 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009151 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009152 struct sir_dcc_get_stats *msg_body;
9153
9154 /* Lock the SME structure */
9155 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309156 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009157 return status;
9158
9159 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309160 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009161 request->request_array_len);
9162 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309163 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009164 goto end;
9165 }
9166 *msg_body = *request;
9167 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309168 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009169 request->request_array_len);
9170
9171 msg.type = WMA_DCC_GET_STATS_CMD;
9172 msg.bodyptr = msg_body;
9173
9174 /* Set the request callback and context */
9175 pMac->sme.dcc_get_stats_callback = callback;
9176 pMac->sme.dcc_get_stats_context = context;
9177
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009178 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309179 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309180 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009181 FL("Error posting message to WDA: %d"), status);
9182 pMac->sme.dcc_get_stats_callback = callback;
9183 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309184 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009185 goto end;
9186 }
9187
9188end:
9189 sme_release_global_lock(&pMac->sme);
9190
9191 return status;
9192}
9193
9194/**
9195 * sme_dcc_clear_stats() - Clear the DCC stats
9196 * @hHal: reference to the HAL
9197 * @vdev_id: vdev id for OCB interface
9198 * @dcc_stats_bitmap: the entries in the stats to clear
9199 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309200 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009201 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309202QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009203 uint32_t dcc_stats_bitmap)
9204{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309205 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009206 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009207 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009208 struct sir_dcc_clear_stats *request;
9209
9210 /* Lock the SME structure */
9211 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309212 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009213 return status;
9214
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309215 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009216 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309217 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009218 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309219 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009220 goto end;
9221 }
9222
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009223 request->vdev_id = vdev_id;
9224 request->dcc_stats_bitmap = dcc_stats_bitmap;
9225
9226 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9227 msg.bodyptr = request;
9228
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009229 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309230 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309231 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009232 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309233 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009234 goto end;
9235 }
9236
9237end:
9238 sme_release_global_lock(&pMac->sme);
9239
9240 return status;
9241}
9242
9243/**
9244 * sme_dcc_update_ndl() - Update the DCC settings
9245 * @hHal: reference to the HAL
9246 * @context: the context of the call
9247 * @callback: the callback to hdd
9248 * @request: the update DCC request
9249 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309250 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009251 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309252QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009253 ocb_callback callback,
9254 struct sir_dcc_update_ndl *request)
9255{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309256 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009257 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009258 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009259 struct sir_dcc_update_ndl *msg_body;
9260
9261 /* Lock the SME structure */
9262 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309263 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009264 return status;
9265
9266 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309267 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009268 request->dcc_ndl_chan_list_len +
9269 request->dcc_ndl_active_state_list_len);
9270 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309271 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009272 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309273 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009274 goto end;
9275 }
9276
9277 *msg_body = *request;
9278
9279 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9280 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9281 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309282 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009283 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309284 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009285 request->dcc_ndl_active_state_list,
9286 request->dcc_ndl_active_state_list_len);
9287
9288 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9289 msg.bodyptr = msg_body;
9290
9291 /* Set the request callback and the context */
9292 pMac->sme.dcc_update_ndl_callback = callback;
9293 pMac->sme.dcc_update_ndl_context = context;
9294
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009295 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309296 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309297 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009298 FL("Error posting message to WDA: %d"), status);
9299 pMac->sme.dcc_update_ndl_callback = NULL;
9300 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309301 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009302 goto end;
9303 }
9304
9305end:
9306 sme_release_global_lock(&pMac->sme);
9307
9308 return status;
9309}
9310
9311/**
9312 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9313 * event
9314 * @hHal: reference to the HAL
9315 * @context: the context of the call
9316 * @callback: the callback to hdd
9317 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309318 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009319 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309320QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009321 ocb_callback callback)
9322{
9323 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309324 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009325
9326 status = sme_acquire_global_lock(&pMac->sme);
9327 pMac->sme.dcc_stats_event_callback = callback;
9328 pMac->sme.dcc_stats_event_context = context;
9329 sme_release_global_lock(&pMac->sme);
9330
9331 return 0;
9332}
9333
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309334/**
9335 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9336 * event
9337 * @h_hal: Hal Handle
9338 *
9339 * This function de-registers the DCC perioc stats callback
9340 *
9341 * Return: QDF_STATUS Enumeration
9342 */
9343QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9344{
9345 tpAniSirGlobal mac;
9346 QDF_STATUS status;
9347
9348 if (!h_hal) {
9349 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9350 FL("h_hal is not valid"));
9351 return QDF_STATUS_E_INVAL;
9352 }
9353 mac = PMAC_STRUCT(h_hal);
9354
9355 status = sme_acquire_global_lock(&mac->sme);
9356 if (!QDF_IS_STATUS_SUCCESS(status)) {
9357 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9358 FL("Failed to acquire global lock"));
9359 return status;
9360 }
9361 mac->sme.dcc_stats_event_callback = NULL;
9362 mac->sme.dcc_stats_event_context = NULL;
9363 sme_release_global_lock(&mac->sme);
9364
9365 return status;
9366}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309367#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309368
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009369void sme_get_recovery_stats(tHalHandle hHal)
9370{
9371 uint8_t i;
9372
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309373 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009374 "Self Recovery Stats");
9375 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9376 if (eSmeNoCommand !=
9377 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309378 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009379 "timestamp %llu: command 0x%0X: reason %d: session %d",
9380 g_self_recovery_stats.activeCmdStats[i].
9381 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309382 g_self_recovery_stats.activeCmdStats[i].command,
9383 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009384 g_self_recovery_stats.activeCmdStats[i].
9385 sessionId);
9386 }
9387 }
9388}
9389
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309390QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009391{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009392 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009393 tpSirModemPowerStateInd request_buf;
9394 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9395
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309396 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309397 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009398
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309399 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009400 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309401 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009402 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9403 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309404 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009405 }
9406
9407 request_buf->param = value;
9408
9409 msg.type = WMA_MODEM_POWER_STATE_IND;
9410 msg.reserved = 0;
9411 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309412 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009413 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309414 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309415 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9416 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309417 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309418 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009419 }
9420
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309421 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009422}
9423
9424#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309425QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309426 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009427 uint8_t sessionId,
9428 uint8_t channel_type)
9429{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009430 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009431 tUpdateVHTOpMode *pHtOpMode = NULL;
9432 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9433
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309434 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309435 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009436
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309437 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009438 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309439 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009440 "%s: Not able to allocate memory for setting OP mode",
9441 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309442 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009443 }
9444
9445 switch (channel_type) {
9446 case eHT_CHAN_HT20:
9447 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9448 break;
9449
9450 case eHT_CHAN_HT40MINUS:
9451 case eHT_CHAN_HT40PLUS:
9452 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9453 break;
9454
9455 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309456 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009457 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309458 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009459 }
9460
9461 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309462 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009463 sizeof(tSirMacAddr));
9464 pHtOpMode->smesessionId = sessionId;
9465
9466 msg.type = WMA_UPDATE_OP_MODE;
9467 msg.reserved = 0;
9468 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309469 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009470 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309471 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309472 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9473 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309474 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309475 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009476 }
9477
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309478 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson698eacd2018-05-12 17:00:03 -07009479 "%s: Notified FW about OP mode: %d for staId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009480 __func__, pHtOpMode->opMode, staId);
9481
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309482 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009483}
9484
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309485/*
9486 * sme_set_ht2040_mode() -
9487 * To update HT Operation beacon IE.
9488 *
9489 * Return QDF_STATUS SUCCESS
9490 * FAILURE or RESOURCES
9491 * The API finished and failed.
9492 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309493QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009494 uint8_t channel_type, bool obssEnabled)
9495{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309496 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009497 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9498 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309499 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009500
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309501 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
9502 sme_err("Session not valid for session id %d", sessionId);
9503 return QDF_STATUS_E_INVAL;
9504 }
9505 session = CSR_GET_SESSION(pMac, sessionId);
9506 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
9507 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009508
9509 switch (channel_type) {
9510 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309511 if (!session->bssParams.cbMode)
9512 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009513 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
9514 break;
9515 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309516 if (session->bssParams.cbMode)
9517 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009518 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
9519 break;
9520 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309521 if (session->bssParams.cbMode)
9522 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009523 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
9524 break;
9525 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309526 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309527 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009528 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309529 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009530 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309531 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009532 status = csr_set_ht2040_mode(pMac, sessionId,
9533 cbMode, obssEnabled);
9534 sme_release_global_lock(&pMac->sme);
9535 }
9536 return status;
9537}
9538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009539#endif
9540
9541/*
9542 * SME API to enable/disable idle mode powersave
9543 * This should be called only if powersave offload
9544 * is enabled
9545 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309546QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009547{
Anurag Chouhan6d760662016-02-20 16:05:43 +05309548 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009549
9550 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309551 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009552 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309553 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009554 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309555 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009556 " Idle Ps Set Value %d", value);
9557
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309558 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309559 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009560 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309561 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009562 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309563
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309564 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009565}
9566
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309567int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
9568 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009569{
9570 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309571 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009572
9573 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309574 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009575 "%s: pSession is NULL", __func__);
9576 return -EIO;
9577 }
9578 switch (ht_capab) {
9579 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9580 return pSession->htConfig.ht_rx_ldpc;
9581 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9582 return pSession->htConfig.ht_tx_stbc;
9583 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9584 return pSession->htConfig.ht_rx_stbc;
9585 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009586 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009587 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009588 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009589 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309590 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009591 "invalid ht capability");
9592 return -EIO;
9593 }
9594}
9595
9596int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
9597 int value)
9598{
9599 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309600 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009601
9602 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309603 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009604 "%s: pSession is NULL", __func__);
9605 return -EIO;
9606 }
9607
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309608 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309609 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610 "Failed to set ht capability in target");
9611 return -EIO;
9612 }
9613
9614 switch (htCapab) {
9615 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9616 pSession->htConfig.ht_rx_ldpc = value;
Kiran Kumar Lokeree43a4582018-05-08 19:54:03 -07009617 pMac->roam.configParam.rx_ldpc_enable = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009618 break;
9619 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9620 pSession->htConfig.ht_tx_stbc = value;
9621 break;
9622 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9623 pSession->htConfig.ht_rx_stbc = value;
9624 break;
9625 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009626 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009627 pSession->htConfig.ht_sgi20 = value;
9628 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009629 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009630 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009631 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009632 break;
9633 }
9634
Naveen Rawat8029a402017-06-01 10:54:19 -07009635 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009636 return 0;
9637}
9638
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08009639int sme_set_addba_accept(tHalHandle hal, uint8_t session_id, int value)
9640{
9641 struct sme_addba_accept *addba_accept;
9642 struct scheduler_msg msg = {0};
9643 QDF_STATUS status;
9644
9645 addba_accept = qdf_mem_malloc(sizeof(*addba_accept));
9646 if (!addba_accept) {
9647 sme_err("mem alloc failed for addba_accept");
9648 return -EIO;
9649 }
9650 addba_accept->session_id = session_id;
9651 addba_accept->addba_accept = value;
9652 qdf_mem_zero(&msg, sizeof(msg));
9653 msg.type = eWNI_SME_SET_ADDBA_ACCEPT;
9654 msg.reserved = 0;
9655 msg.bodyptr = addba_accept;
9656 status = scheduler_post_msg(QDF_MODULE_ID_PE, &msg);
9657 if (status != QDF_STATUS_SUCCESS) {
9658 sme_err("Not able to post addba reject");
9659 qdf_mem_free(addba_accept);
9660 return -EIO;
9661 }
9662 return 0;
9663}
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08009664
9665int sme_set_ba_buff_size(tHalHandle hal, uint8_t session_id,
9666 uint16_t buff_size)
9667{
9668 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9669 if (!buff_size) {
9670 sme_err("invalid buff size %d", buff_size);
9671 return -EINVAL;
9672 }
9673 mac_ctx->usr_cfg_ba_buff_size = buff_size;
9674 sme_debug("addba buff size is set to %d",
9675 mac_ctx->usr_cfg_ba_buff_size);
9676
9677 return 0;
9678}
9679
9680#define DEFAULT_BA_BUFF_SIZE 64
9681int sme_send_addba_req(tHalHandle hal, uint8_t session_id, uint8_t tid,
9682 uint16_t buff_size)
9683{
9684 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9685 uint16_t ba_buff = 0;
9686 QDF_STATUS status;
9687 struct scheduler_msg msg = {0};
9688 struct send_add_ba_req *send_ba_req;
9689 struct csr_roam_session *csr_session = NULL;
9690
9691 if (!csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
9692 sme_err("STA not infra/connected state session_id: %d",
9693 session_id);
9694 return -EINVAL;
9695 }
9696 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
9697 if (!csr_session) {
9698 sme_err("CSR session is NULL");
9699 return -EINVAL;
9700 }
9701 send_ba_req = qdf_mem_malloc(sizeof(*send_ba_req));
9702 if (!send_ba_req) {
9703 sme_err("mem alloc failed");
9704 return -EIO;
9705 }
9706 qdf_mem_copy(send_ba_req->mac_addr,
9707 csr_session->connectedProfile.bssid.bytes,
9708 QDF_MAC_ADDR_SIZE);
9709 ba_buff = buff_size;
9710 if (!buff_size) {
9711 if (mac_ctx->usr_cfg_ba_buff_size)
9712 ba_buff = mac_ctx->usr_cfg_ba_buff_size;
9713 else
9714 ba_buff = DEFAULT_BA_BUFF_SIZE;
9715 }
9716 send_ba_req->param.vdev_id = session_id;
9717 send_ba_req->param.tidno = tid;
9718 send_ba_req->param.buffersize = ba_buff;
9719 msg.type = WMA_SEND_ADDBA_REQ;
9720 msg.bodyptr = send_ba_req;
9721 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
9722 if (QDF_STATUS_SUCCESS != status) {
9723 sme_err("Failed to post WMA_SEND_ADDBA_REQ");
9724 qdf_mem_free(send_ba_req);
9725 return -EIO;
9726 }
9727 sme_debug("ADDBA_REQ sent to FW: tid %d buff_size %d", tid, ba_buff);
9728
9729 return 0;
9730}
9731
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009732int sme_set_no_ack_policy(tHalHandle hal, uint8_t session_id,
9733 uint8_t val, uint8_t ac)
9734{
9735 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9736 uint8_t i, set_val;
Arif Hussaineb8ba362018-03-07 19:15:13 -08009737 struct scheduler_msg msg = {0};
9738 QDF_STATUS status;
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009739
9740 if (ac > MAX_NUM_AC) {
9741 sme_err("invalid ac val %d", ac);
9742 return -EINVAL;
9743 }
9744 if (val)
9745 set_val = 1;
9746 else
9747 set_val = 0;
9748 if (ac == MAX_NUM_AC) {
9749 for (i = 0; i < ac; i++)
9750 mac_ctx->no_ack_policy_cfg[i] = set_val;
9751 } else {
9752 mac_ctx->no_ack_policy_cfg[ac] = set_val;
9753 }
9754 sme_debug("no ack is set to %d for ac %d", set_val, ac);
Arif Hussaineb8ba362018-03-07 19:15:13 -08009755 qdf_mem_zero(&msg, sizeof(msg));
9756 msg.type = eWNI_SME_UPDATE_EDCA_PROFILE;
9757 msg.reserved = 0;
9758 msg.bodyval = session_id;
9759 status = scheduler_post_msg(QDF_MODULE_ID_PE, &msg);
9760 if (status != QDF_STATUS_SUCCESS) {
9761 sme_err("Not able to post update edca profile");
9762 return -EIO;
9763 }
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009764
9765 return 0;
9766}
9767
Kiran Kumar Lokerea006a302018-03-07 20:58:13 -08009768int sme_set_auto_rate_he_ltf(tHalHandle hal, uint8_t session_id,
9769 uint8_t cfg_val)
9770{
9771 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9772 uint32_t set_val;
9773 uint32_t bit_mask = 0;
9774 int status;
9775
9776 if (cfg_val > QCA_WLAN_HE_LTF_4X) {
9777 sme_err("invalid HE LTF cfg %d", cfg_val);
9778 return -EINVAL;
9779 }
9780
9781 /*set the corresponding HE LTF cfg BIT*/
9782 if (cfg_val == QCA_WLAN_HE_LTF_AUTO)
9783 bit_mask = HE_LTF_ALL;
9784 else
9785 bit_mask = (1 << (cfg_val - 1));
9786
9787 set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask;
9788
9789 SET_AUTO_RATE_HE_LTF_VAL(set_val, bit_mask);
9790
9791 mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val;
9792 status = wma_cli_set_command(session_id,
9793 WMI_VDEV_PARAM_AUTORATE_MISC_CFG,
9794 set_val, VDEV_CMD);
9795 if (status) {
9796 sme_err("failed to set he_ltf_sgi");
9797 return status;
9798 }
9799
9800 sme_debug("HE SGI_LTF is set to 0x%08X",
9801 mac_ctx->he_sgi_ltf_cfg_bit_mask);
9802
9803 return 0;
9804}
9805
9806int sme_set_auto_rate_he_sgi(tHalHandle hal, uint8_t session_id,
9807 uint8_t cfg_val)
9808{
9809 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9810 uint32_t set_val;
9811 uint32_t sgi_bit_mask = 0;
9812 int status;
9813
9814 if ((cfg_val > AUTO_RATE_GI_3200NS) ||
9815 (cfg_val < AUTO_RATE_GI_400NS)) {
9816 sme_err("invalid auto rate GI cfg %d", cfg_val);
9817 return -EINVAL;
9818 }
9819
9820 sgi_bit_mask = (1 << cfg_val);
9821
9822 set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask;
9823 SET_AUTO_RATE_SGI_VAL(set_val, sgi_bit_mask);
9824
9825 mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val;
9826 status = wma_cli_set_command(session_id,
9827 WMI_VDEV_PARAM_AUTORATE_MISC_CFG,
9828 set_val, VDEV_CMD);
9829 if (status) {
9830 sme_err("failed to set he_ltf_sgi");
9831 return status;
9832 }
9833
9834 sme_debug("auto rate HE SGI_LTF is set to 0x%08X",
9835 mac_ctx->he_sgi_ltf_cfg_bit_mask);
9836
9837 return 0;
9838}
9839
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009840#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309841/*
9842 * sme_send_rate_update_ind() -
9843 * API to Update rate
9844 *
9845 * hHal - The handle returned by mac_open
9846 * rateUpdateParams - Pointer to rate update params
9847 * Return QDF_STATUS
9848 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309849QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009850 tSirRateUpdateInd *rateUpdateParams)
9851{
9852 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309853 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009854 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309855 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009856
9857 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309858 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009859 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309860 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009861 }
9862 *rate_upd = *rateUpdateParams;
9863
9864 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
9865 rate_upd->mcastDataRate24GHzTxFlag =
Naveen Rawatea1564b2018-05-17 15:56:11 -07009866 TX_RATE_HT20 | TX_RATE_SGI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009867 else if (rate_upd->reliableMcastDataRate ==
9868 HT20_SHORT_GI_MCS7_RATE)
9869 rate_upd->reliableMcastDataRateTxFlag =
Naveen Rawatea1564b2018-05-17 15:56:11 -07009870 TX_RATE_HT20 | TX_RATE_SGI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009871
9872 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309873 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009874 msg.type = WMA_RATE_UPDATE_IND;
9875 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05309876 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
9877 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309878 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009879 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309880 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309881 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009882 __func__);
9883
9884 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309885 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309886 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009887 }
9888
9889 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309890 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009891 }
9892
9893 return status;
9894}
9895
9896/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309897 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
9898 * @hal: Pointer to the mac context
9899 * @session_id: sme session id
9900 * @vendor_ie: vendor ie
9901 * @access_policy: vendor ie access policy
9902 *
9903 * This function updates the vendor ie and access policy to lim.
9904 *
9905 * Return: success or failure.
9906 */
9907QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
9908 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
9909{
9910 struct sme_update_access_policy_vendor_ie *msg;
9911 uint16_t msg_len;
9912 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309913
9914 msg_len = sizeof(*msg);
9915
9916 msg = qdf_mem_malloc(msg_len);
9917 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009918 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309919 return QDF_STATUS_E_FAILURE;
9920 }
9921
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309922 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
9923 msg->length = (uint16_t)msg_len;
9924
9925 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
9926
9927 msg->sme_session_id = session_id;
9928 msg->access_policy = access_policy;
9929
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009930 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
9931 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309932
Rajeev Kumard138ac52017-01-30 18:38:37 -08009933 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309934
9935 return status;
9936}
9937
9938/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309939 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
9940 * @hal: Handle returned by mac_open
9941 * @session_id: Session ID on which short frame retry limit needs to be
9942 * updated to FW
9943 * @short_limit_count_th: Retry count TH to retry short frame.
9944 *
9945 * This function is used to configure count to retry short frame.
9946 *
9947 * Return: QDF_STATUS
9948 */
9949QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
9950 struct sme_short_retry_limit *short_retry_limit_th)
9951{
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309952 QDF_STATUS status = QDF_STATUS_SUCCESS;
9953 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009954 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309955
9956 srl = qdf_mem_malloc(sizeof(*srl));
9957 if (NULL == srl) {
9958 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9959 "%s: fail to alloc short retry limit", __func__);
9960 return QDF_STATUS_E_FAILURE;
9961 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009962 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309963 short_retry_limit_th->session_id,
9964 short_retry_limit_th->short_retry_limit);
9965
9966 srl->session_id = short_retry_limit_th->session_id;
9967 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
9968
9969 qdf_mem_zero(&msg, sizeof(msg));
9970 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
9971 msg.reserved = 0;
9972 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009973 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309974 if (status != QDF_STATUS_SUCCESS) {
9975 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9976 FL("Not able to post short retry limit count to WDA"));
9977 qdf_mem_free(srl);
9978 return QDF_STATUS_E_FAILURE;
9979 }
9980
9981 return status;
9982}
9983
9984/**
9985 * sme_update_long_retry_limit_threshold() - update long retry limit TH
9986 * @hal: Handle returned by mac_open
9987 * @session_id: Session ID on which long frames retry TH needs to be updated
9988 * to FW
9989 * @long_limit_count_th: Retry count to retry long frame.
9990 *
9991 * This function is used to configure TH to retry long frame.
9992 *
9993 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309994 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309995QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
9996 struct sme_long_retry_limit *long_retry_limit_th)
9997{
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309998 QDF_STATUS status = QDF_STATUS_SUCCESS;
9999 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010000 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010001
10002 lrl = qdf_mem_malloc(sizeof(*lrl));
10003 if (NULL == lrl) {
10004 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10005 "%s: fail to alloc long retry limit", __func__);
10006 return QDF_STATUS_E_FAILURE;
10007 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010008 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010009 long_retry_limit_th->session_id,
10010 long_retry_limit_th->long_retry_limit);
10011
10012 lrl->session_id = long_retry_limit_th->session_id;
10013 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10014
10015 qdf_mem_zero(&msg, sizeof(msg));
10016 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10017 msg.reserved = 0;
10018 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010019 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010020
10021 if (status != QDF_STATUS_SUCCESS) {
10022 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10023 FL("Not able to post long retry limit count to WDA"));
10024 qdf_mem_free(lrl);
10025 return QDF_STATUS_E_FAILURE;
10026 }
10027
10028 return status;
10029}
10030
10031/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010032 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10033 * @hal: Handle returned by mac_open
10034 * @session_id: Session ID on which sta_inactivity_timeout needs
10035 * to be updated to FW
10036 * @sta_inactivity_timeout: sta inactivity timeout.
10037 *
10038 * If a station does not send anything in sta_inactivity_timeout seconds, an
10039 * empty data frame is sent to it in order to verify whether it is
10040 * still in range. If this frame is not ACKed, the station will be
10041 * disassociated and then deauthenticated.
10042 *
10043 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010044 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010045QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10046 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10047{
10048 struct sme_sta_inactivity_timeout *inactivity_time;
10049 void *wma_handle;
10050
10051 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10052 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10053 if (NULL == inactivity_time) {
10054 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10055 "%s: fail to alloc inactivity_time", __func__);
10056 return QDF_STATUS_E_FAILURE;
10057 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010058 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010059 FL("sta_inactivity_timeout: %d"),
10060 sta_inactivity_timer->sta_inactivity_timeout);
10061 inactivity_time->session_id = sta_inactivity_timer->session_id;
10062 inactivity_time->sta_inactivity_timeout =
10063 sta_inactivity_timer->sta_inactivity_timeout;
10064
10065 wma_update_sta_inactivity_timeout(wma_handle,
10066 inactivity_time);
10067 return QDF_STATUS_SUCCESS;
10068}
10069
10070/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010071 * sme_get_reg_info() - To get registration info
10072 * @hHal: HAL context
10073 * @chanId: channel id
10074 * @regInfo1: first reg info to fill
10075 * @regInfo2: second reg info to fill
10076 *
10077 * This routine will give you reg info
10078 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010079 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010080 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010081QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010082 uint32_t *regInfo1, uint32_t *regInfo2)
10083{
10084 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010085 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010086 uint8_t i;
10087 bool found = false;
10088
10089 status = sme_acquire_global_lock(&pMac->sme);
10090 *regInfo1 = 0;
10091 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010092 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010093 return status;
10094
10095 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010096 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010097 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010098 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010099
10100 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010101 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010102 found = true;
10103 break;
10104 }
10105 }
10106 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010107 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010108
10109 sme_release_global_lock(&pMac->sme);
10110 return status;
10111}
10112
10113#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010114/*
10115 * sme_auto_shutdown_cb() -
10116 * Used to plug in callback function for receiving auto shutdown evt
10117 *
10118 * hHal
10119 * pCallbackfn : callback function pointer should be plugged in
10120 * Return QDF_STATUS
10121 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010122QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010123 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010124 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010125 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10126
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010127 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010128 "%s: Plug in Auto shutdown event callback", __func__);
10129
10130 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010131 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010132 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010133 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010134 sme_release_global_lock(&pMac->sme);
10135 }
10136
10137 return status;
10138}
10139
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010140/*
10141 * sme_set_auto_shutdown_timer() -
10142 * API to set auto shutdown timer value in FW.
10143 *
10144 * hHal - The handle returned by mac_open
10145 * timer_val - The auto shutdown timer value to be set
10146 * Return Configuration message posting status, SUCCESS or Fail
10147 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010148QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010149{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010150 QDF_STATUS status = QDF_STATUS_SUCCESS;
10151 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010152 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10153 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010154 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010155
10156 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010157 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010158 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010159 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010160 if (auto_sh_cmd == NULL) {
Dustin Browna2868622018-03-20 11:38:14 -070010161 sme_err("Request Buffer Alloc Fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010162 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010163 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010164 }
10165
10166 auto_sh_cmd->timer_val = timer_val;
10167
10168 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010169 message.bodyptr = auto_sh_cmd;
10170 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10171 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10172 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010173 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010174 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010175 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010176 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010177 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010178 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010179 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010180 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010181 "%s: Posted Auto shutdown MSG", __func__);
10182 sme_release_global_lock(&pMac->sme);
10183 }
10184
10185 return status;
10186}
10187#endif
10188
Nirav Shaheb017be2018-02-15 11:20:58 +053010189#ifdef FEATURE_WLAN_CH_AVOID
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010190/*
10191 * sme_ch_avoid_update_req() -
10192 * API to request channel avoidance update from FW.
10193 *
10194 * hHal - The handle returned by mac_open
Jeff Johnsonc5927de2018-05-11 09:12:53 -070010195 * update_type - The update_type parameter of this request call
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010196 * Return Configuration message posting status, SUCCESS or Fail
10197 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010198QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010199{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010200 QDF_STATUS status = QDF_STATUS_SUCCESS;
10201 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010202 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10203 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010204 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010205
10206 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010207 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010208 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010209 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010210 if (NULL == cauReq) {
Dustin Browna2868622018-03-20 11:38:14 -070010211 sme_err("Request Buffer Alloc Fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010212 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010213 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010214 }
10215
10216 cauReq->reserved_param = 0;
10217
10218 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010219 message.bodyptr = cauReq;
10220 message.type = WMA_CH_AVOID_UPDATE_REQ;
10221 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10222 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010223 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010224 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010225 "%s: Post Ch Avoid Update MSG fail",
10226 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010227 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010228 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010229 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010230 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010231 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010232 "%s: Posted Ch Avoid Update MSG", __func__);
10233 sme_release_global_lock(&pMac->sme);
10234 }
10235
10236 return status;
10237}
Nirav Shaheb017be2018-02-15 11:20:58 +053010238#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010239
10240/**
10241 * sme_set_miracast() - Function to set miracast value to UMAC
10242 * @hal: Handle returned by macOpen
10243 * @filter_type: 0-Disabled, 1-Source, 2-sink
10244 *
10245 * This function passes down the value of miracast set by
10246 * framework to UMAC
10247 *
10248 * Return: Configuration message posting status, SUCCESS or Fail
10249 *
10250 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010251QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010252{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010253 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010254 uint32_t *val;
10255 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10256
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010257 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010258 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010259 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010260 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010261 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010262 }
10263
10264 *val = filter_type;
10265
10266 msg.type = SIR_HAL_SET_MIRACAST;
10267 msg.reserved = 0;
10268 msg.bodyptr = val;
10269
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010270 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010271 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010272 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010273 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10274 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010275 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010276 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010277 }
10278
10279 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010280 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010281}
10282
10283/**
10284 * sme_set_mas() - Function to set MAS value to UMAC
10285 * @val: 1-Enable, 0-Disable
10286 *
10287 * This function passes down the value of MAS to the UMAC. A
10288 * value of 1 will enable MAS and a value of 0 will disable MAS
10289 *
10290 * Return: Configuration message posting status, SUCCESS or Fail
10291 *
10292 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010293QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010294{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010295 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010296 uint32_t *ptr_val;
10297
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010298 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010299 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010300 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010301 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010302 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010303 }
10304
10305 *ptr_val = val;
10306
10307 msg.type = SIR_HAL_SET_MAS;
10308 msg.reserved = 0;
10309 msg.bodyptr = ptr_val;
10310
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010311 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010312 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010313 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010314 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10315 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010316 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010317 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010318 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010319 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010320}
10321
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010322/**
10323 * sme_roam_channel_change_req() - Channel change to new target channel
10324 * @hHal: handle returned by mac_open
10325 * @bssid: mac address of BSS
10326 * @ch_params: target channel information
10327 * @profile: CSR profile
10328 *
10329 * API to Indicate Channel change to new target channel
10330 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010331 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010332 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010333QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010334 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010335 struct ch_params *ch_params,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010336 struct csr_roam_profile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010337{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010338 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010339 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010340
10341 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010342 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010343
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010344 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010345 profile);
10346 sme_release_global_lock(&pMac->sme);
10347 }
10348 return status;
10349}
10350
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010351/*
10352 * sme_process_channel_change_resp() -
10353 * API to Indicate Channel change response message to SAP.
10354 *
10355 * Return QDF_STATUS
10356 */
10357static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010358 uint16_t msg_type, void *pMsgBuf)
10359{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010360 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010361 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010362 eCsrRoamResult roamResult;
10363 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10364 uint32_t SessionId = pChnlParams->peSessionId;
10365
10366 proam_info.channelChangeRespEvent =
10367 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010368 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010369 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010370 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010371 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010372 return status;
10373 }
10374 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10375 proam_info.channelChangeRespEvent->sessionId = SessionId;
10376 proam_info.channelChangeRespEvent->newChannelNumber =
10377 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010378
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010379 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010380 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010381 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10382 SessionId);
10383 proam_info.channelChangeRespEvent->channelChangeStatus =
10384 1;
10385 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10386 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010387 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010388 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10389 SessionId);
10390 proam_info.channelChangeRespEvent->channelChangeStatus =
10391 0;
10392 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10393 }
10394
10395 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10396 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10397
10398 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010399 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010400 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010401 status);
10402 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010403 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010404
10405 return status;
10406}
10407
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010408/*
10409 * sme_roam_start_beacon_req() -
10410 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10411 *
10412 * hHal - The handle returned by mac_open
10413 * sessionId - session ID
10414 * dfsCacWaitStatus - CAC WAIT status flag
10415 * Return QDF_STATUS
10416 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010417QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010418 uint8_t dfsCacWaitStatus)
10419{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010420 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010421 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010422
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010423 status = sme_acquire_global_lock(&pMac->sme);
10424
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010425 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010426 status = csr_roam_start_beacon_req(pMac, bssid,
10427 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010428 sme_release_global_lock(&pMac->sme);
10429 }
10430 return status;
10431}
10432
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010433/**
10434 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10435 * @hHal: handle returned by mac_open
10436 * @bssid: SAP bssid
10437 * @targetChannel: target channel information
10438 * @csaIeReqd: CSA IE Request
10439 * @ch_params: channel information
10440 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010441 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010442 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010443QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010444 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010445 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010446{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010447 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010448 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010450 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010451 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010452 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10453 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010454 sme_release_global_lock(&pMac->sme);
10455 }
10456 return status;
10457}
10458
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010459/*
10460 * sme_init_thermal_info() -
10461 * SME API to initialize the thermal mitigation parameters
10462 *
10463 * hHal
10464 * thermalParam : thermal mitigation parameters
10465 * Return QDF_STATUS
10466 */
10467QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10468 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010469{
10470 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010471 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010472 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10473
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010474 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010475 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010476 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010477 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010478 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010479 }
10480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010481 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10482 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010483
10484 pWmaParam->throttle_duty_cycle_tbl[0] =
10485 thermalParam.sme_throttle_duty_cycle_tbl[0];
10486 pWmaParam->throttle_duty_cycle_tbl[1] =
10487 thermalParam.sme_throttle_duty_cycle_tbl[1];
10488 pWmaParam->throttle_duty_cycle_tbl[2] =
10489 thermalParam.sme_throttle_duty_cycle_tbl[2];
10490 pWmaParam->throttle_duty_cycle_tbl[3] =
10491 thermalParam.sme_throttle_duty_cycle_tbl[3];
10492
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010493 pWmaParam->thermalLevels[0].minTempThreshold =
10494 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10495 pWmaParam->thermalLevels[0].maxTempThreshold =
10496 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10497 pWmaParam->thermalLevels[1].minTempThreshold =
10498 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10499 pWmaParam->thermalLevels[1].maxTempThreshold =
10500 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10501 pWmaParam->thermalLevels[2].minTempThreshold =
10502 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10503 pWmaParam->thermalLevels[2].maxTempThreshold =
10504 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10505 pWmaParam->thermalLevels[3].minTempThreshold =
10506 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10507 pWmaParam->thermalLevels[3].maxTempThreshold =
10508 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10509
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010510 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010511 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10512 msg.bodyptr = pWmaParam;
10513
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010514 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010515 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010516 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010517 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10518 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010519 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010520 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010521 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010522 }
10523 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010524 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010525 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010526 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010527 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010528}
10529
10530/**
10531 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10532 * @hal: Handle returned by macOpen
10533 * @callback: sme_set_thermal_level_callback
10534 *
10535 * Plug in set thermal level callback
10536 *
10537 * Return: none
10538 */
10539void sme_add_set_thermal_level_callback(tHalHandle hal,
10540 sme_set_thermal_level_callback callback)
10541{
10542 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10543
10544 pMac->sme.set_thermal_level_cb = callback;
10545}
10546
10547/**
10548 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10549 * @hal: Handler to HAL
10550 * @level: Thermal mitigation level
10551 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010552 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010553 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010554QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010555{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010556 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010557 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010558 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010559
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010560 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010561 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010562 msg.type = WMA_SET_THERMAL_LEVEL;
10563 msg.bodyval = level;
10564
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010565 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010566 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010567 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010568 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10569 __func__);
10570 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010571 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010572 }
10573 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010574 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010575 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010576 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010577}
10578
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010579/*
10580 * sme_txpower_limit() -
10581 * SME API to set txpower limits
10582 *
10583 * hHal
10584 * psmetx : power limits for 2g/5g
10585 * Return QDF_STATUS
10586 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010587QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010588{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010589 QDF_STATUS status = QDF_STATUS_SUCCESS;
10590 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010591 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010592 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010593 tSirTxPowerLimit *tx_power_limit;
10594
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010595 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010596 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010597 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010598 "%s: Memory allocation for TxPowerLimit failed!",
10599 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010600 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010601 }
10602
10603 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010604
10605 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010606 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010607 message.type = WMA_TX_POWER_LIMIT;
10608 message.reserved = 0;
10609 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010610
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010611 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10612 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010613 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010614 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010615 "%s: not able to post WMA_TX_POWER_LIMIT",
10616 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010617 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010618 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010619 }
10620 sme_release_global_lock(&pMac->sme);
10621 }
10622 return status;
10623}
10624
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010625QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010626{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010627 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010628 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010630 pMac->fEnableDebugLog = set_value;
10631 return status;
10632}
10633
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010634/*
10635 * sme_ap_disable_intra_bss_fwd() -
10636 * SME will send message to WMA to set Intra BSS in txrx
10637 *
10638 * hHal - The handle returned by mac_open
10639 * sessionId - session id ( vdev id)
10640 * disablefwd - bool value that indicate disable intrabss fwd disable
10641 * Return QDF_STATUS
10642 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010643QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010644 bool disablefwd)
10645{
10646 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010647 int status = QDF_STATUS_SUCCESS;
10648 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010649 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010650 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10651
10652 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010653 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010654 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010655 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010656 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010657 }
10658
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010659 pSapDisableIntraFwd->sessionId = sessionId;
10660 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
10661
10662 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010663 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010664 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010665 message.bodyptr = pSapDisableIntraFwd;
10666 message.type = WMA_SET_SAP_INTRABSS_DIS;
10667 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10668 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010669 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
10670 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010671 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010672 }
10673 sme_release_global_lock(&pMac->sme);
10674 }
10675 return status;
10676}
10677
10678#ifdef WLAN_FEATURE_STATS_EXT
10679
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010680/*
10681 * sme_stats_ext_register_callback() -
10682 * This function called to register the callback that send vendor event for
10683 * stats ext
10684 *
10685 * callback - callback to be registered
10686 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
10688{
10689 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10690
10691 pMac->sme.StatsExtCallback = callback;
10692}
10693
lifeng66831662017-05-19 16:01:35 +080010694void sme_stats_ext2_register_callback(tHalHandle hal_handle,
10695 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
10696{
10697 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
10698
10699 pmac->sme.stats_ext2_cb = stats_ext2_cb;
10700}
10701
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010702/**
10703 * sme_stats_ext_deregister_callback() - De-register ext stats callback
10704 * @h_hal: Hal Handle
10705 *
10706 * This function is called to de initialize the HDD NAN feature. Currently
10707 * the only operation required is to de-register a callback with SME.
10708 *
10709 * Return: None
10710 */
10711void sme_stats_ext_deregister_callback(tHalHandle h_hal)
10712{
10713 tpAniSirGlobal pmac;
10714
10715 if (!h_hal) {
10716 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10717 FL("hHal is not valid"));
10718 return;
10719 }
10720
10721 pmac = PMAC_STRUCT(h_hal);
10722 pmac->sme.StatsExtCallback = NULL;
10723}
10724
10725
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010726/*
10727 * sme_stats_ext_request() -
10728 * Function called when HDD receives STATS EXT vendor command from userspace
10729 *
10730 * sessionID - vdevID for the stats ext request
10731 * input - Stats Ext Request structure ptr
10732 * Return QDF_STATUS
10733 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010734QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010735{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010736 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010737 tpStatsExtRequest data;
10738 size_t data_len;
10739
10740 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010741 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010742
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010743 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010744 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010745
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010746 data->vdev_id = session_id;
10747 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010748 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010749 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010750 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010751
10752 msg.type = WMA_STATS_EXT_REQUEST;
10753 msg.reserved = 0;
10754 msg.bodyptr = data;
10755
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010756 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080010757 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010758 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010759 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
10760 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010761 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010762 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010763 }
10764
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010765 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010766}
10767
Jeff Johnsonfdecd512018-06-10 09:18:32 -070010768/**
10769 * sme_stats_ext_event() - eWNI_SME_STATS_EXT_EVENT processor
10770 * @mac: Global MAC context
10771 * @msg: "stats ext" message
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010772
Jeff Johnsonfdecd512018-06-10 09:18:32 -070010773 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
10774 * response from WMA
10775 *
10776 * Return: QDF_STATUS
10777 */
10778static QDF_STATUS sme_stats_ext_event(tpAniSirGlobal mac,
10779 tpStatsExtEvent msg)
10780{
10781 if (!msg) {
10782 sme_err("Null msg");
10783 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010784 }
10785
Jeff Johnsonfdecd512018-06-10 09:18:32 -070010786 if (mac->sme.StatsExtCallback)
10787 mac->sme.StatsExtCallback(mac->hHdd, msg);
10788
10789 return QDF_STATUS_SUCCESS;
10790}
10791
10792#else
10793
10794static QDF_STATUS sme_stats_ext_event(tpAniSirGlobal mac,
10795 tpStatsExtEvent msg)
10796{
10797 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010798}
10799
10800#endif
10801
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010802/*
10803 * sme_update_dfs_scan_mode() -
10804 * Update DFS roam scan mode
10805 * This function is called through dynamic setConfig callback function
10806 * to configure allowDFSChannelRoam.
10807 * hHal - HAL handle for device
10808 * sessionId - Session Identifier
10809 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
10810 * 1 (passive), 2 (active)
10811 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
10812 * successfully.
10813 * Other status means SME failed to update DFS roaming scan config.
10814 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010815QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010816 uint8_t allowDFSChannelRoam)
10817{
10818 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010819 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010820
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080010821 if (sessionId >= CSR_ROAM_SESSION_MAX) {
10822 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10823 FL("Invalid sme session id: %d"), sessionId);
10824 return QDF_STATUS_E_INVAL;
10825 }
10826
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010827 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010828 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010829 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010830 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010831 allowDFSChannelRoam,
10832 pMac->roam.configParam.allowDFSChannelRoam,
10833 mac_trace_get_neighbour_roam_state(pMac->roam.
10834 neighborRoamInfo
10835 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010836 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010837 pMac->roam.configParam.allowDFSChannelRoam =
10838 allowDFSChannelRoam;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053010839 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
10840 csr_roam_offload_scan(pMac, sessionId,
10841 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10842 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
10843 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010844 sme_release_global_lock(&pMac->sme);
10845 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053010846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010847
10848 return status;
10849}
10850
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010851/*
10852 * sme_get_dfs_scan_mode() - get DFS roam scan mode
10853 * This is a synchronous call
10854 *
10855 * hHal - The handle returned by mac_open.
10856 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
10857 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010858uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
10859{
10860 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010862 return pMac->roam.configParam.allowDFSChannelRoam;
10863}
10864
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010865/*
10866 * sme_modify_add_ie() -
10867 * This function sends msg to updates the additional IE buffers in PE
10868 *
10869 * hHal - global structure
10870 * pModifyIE - pointer to tModifyIE structure
10871 * updateType - type of buffer
10872 * Return Success or failure
10873 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010874QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010875 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
10876{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010877 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010878 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010879
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010880 status = sme_acquire_global_lock(&pMac->sme);
10881
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010882 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010883 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
10884 sme_release_global_lock(&pMac->sme);
10885 }
10886 return status;
10887}
10888
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010889/*
10890 * sme_update_add_ie() -
10891 * This function sends msg to updates the additional IE buffers in PE
10892 *
10893 * hHal - global structure
10894 * pUpdateIE - pointer to structure tUpdateIE
10895 * updateType - type of buffer
10896 * Return Success or failure
10897 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010898QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010899 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
10900{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010901 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010902 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010903
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010904 status = sme_acquire_global_lock(&pMac->sme);
10905
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010906 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010907 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
10908 sme_release_global_lock(&pMac->sme);
10909 }
10910 return status;
10911}
10912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010913/**
10914 * sme_update_dsc_pto_up_mapping()
10915 * @hHal: HAL context
10916 * @dscpmapping: pointer to DSCP mapping structure
10917 * @sessionId: SME session id
10918 *
10919 * This routine is called to update dscp mapping
10920 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010921 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010922 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010923QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053010924 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010925 uint8_t sessionId)
10926{
10927 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010928 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010929 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010930 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010931 tpPESession pSession = NULL;
10932
10933 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010934 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010935 return status;
10936 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
10937 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010938 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010939 FL("Session lookup fails for CSR session"));
10940 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010941 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010942 }
10943 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010944 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010945 FL("Invalid session Id %u"), sessionId);
10946 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010947 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010948 }
10949
10950 pSession = pe_find_session_by_bssid(pMac,
10951 pCsrSession->connectedProfile.bssid.bytes,
10952 &peSessionId);
10953
10954 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010955 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010956 FL(" Session lookup fails for BSSID"));
10957 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010958 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010959 }
10960
10961 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070010962 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010963 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010964 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010965 }
10966 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
10967 for (j = pSession->QosMapSet.dscp_range[i][0];
10968 j <= pSession->QosMapSet.dscp_range[i][1];
10969 j++) {
10970 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
10971 && (pSession->QosMapSet.dscp_range[i][1] ==
10972 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010973 QDF_TRACE(QDF_MODULE_ID_SME,
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -080010974 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010975 FL("User Priority %d isn't used"), i);
10976 break;
10977 } else {
10978 dscpmapping[j] = i;
10979 }
10980 }
10981 }
10982 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
10983 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
10984 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
10985 pSession->QosMapSet.dscp_exceptions[i][1];
10986
10987 sme_release_global_lock(&pMac->sme);
10988 return status;
10989}
10990
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010991/*
10992 * sme_abort_roam_scan() -
10993 * API to abort current roam scan cycle by roam scan offload module.
10994 *
10995 * hHal - The handle returned by mac_open.
10996 * sessionId - Session Identifier
10997 * Return QDF_STATUS
10998 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010999
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011000QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011001{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011002 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011003 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11004
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011005 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11006 /* acquire the lock for the sme object */
11007 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011008 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011009 csr_roam_offload_scan(pMac, sessionId,
11010 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11011 REASON_ROAM_ABORT_ROAM_SCAN);
11012 /* release the lock for the sme object */
11013 sme_release_global_lock(&pMac->sme);
11014 }
11015 }
11016
11017 return status;
11018}
11019
11020#ifdef FEATURE_WLAN_EXTSCAN
11021/**
11022 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11023 * @hHal: HAL context
11024 * @wifiBand: RF band information
11025 * @aValidChannels: output array to store channel info
11026 * @pNumChannels: output number of channels
11027 *
11028 * SME API to fetch all valid channels filtered by band
11029 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011030 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011031 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011032QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011033 uint8_t wifiBand,
11034 uint32_t *aValidChannels,
11035 uint8_t *pNumChannels)
11036{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011037 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011038 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011039 uint8_t numChannels = 0;
11040 uint8_t i = 0;
11041 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011042 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011043
11044 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011045 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011046 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011047 }
11048
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011049 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011050 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011051 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011052 }
11053
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011054 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011055 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011056 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011057 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011058 return status;
11059 }
11060
11061 switch (wifiBand) {
11062 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011063 sme_debug("Unspec Band, return all %d valid channels",
11064 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011065 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011066 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011067 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011068 break;
11069
11070 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011071 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011072 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011073 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011074 aValidChannels[numChannels++] =
11075 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011076 }
11077 break;
11078
11079 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011080 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011081 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011082 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011083 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011084 aValidChannels[numChannels++] =
11085 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011086 }
11087 break;
11088
11089 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011090 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011091 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011092 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11093 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011094 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011095 aValidChannels[numChannels++] =
11096 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011097 }
11098 break;
11099
11100 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011101 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011102 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011103 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011104 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011105 aValidChannels[numChannels++] =
11106 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011107 }
11108 break;
11109
11110 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011111 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011112 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011113 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011114 aValidChannels[numChannels++] =
11115 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011116 }
11117 break;
11118
11119 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011120 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011121 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011122 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011123 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011124 aValidChannels[numChannels++] =
11125 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011126 }
11127 break;
11128
11129 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011130 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011131 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011132 }
11133 *pNumChannels = numChannels;
11134
11135 return status;
11136}
11137
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011138/*
11139 * sme_ext_scan_get_capabilities() -
11140 * SME API to fetch extscan capabilities
11141 *
11142 * hHal
11143 * pReq: extscan capabilities structure
11144 * Return QDF_STATUS
11145 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011146QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011147 tSirGetExtScanCapabilitiesReqParams *
11148 pReq)
11149{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011150 QDF_STATUS status = QDF_STATUS_SUCCESS;
11151 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011152 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011153 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011154
11155 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011156 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011157 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011158 message.bodyptr = pReq;
11159 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011160 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011161 NO_SESSION, message.type));
11162 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11163 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011164 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11165 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011166
11167 sme_release_global_lock(&pMac->sme);
11168 }
11169 return status;
11170}
11171
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011172/*
11173 * sme_ext_scan_start() -
11174 * SME API to issue extscan start
11175 *
11176 * hHal
11177 * pStartCmd: extscan start structure
11178 * Return QDF_STATUS
11179 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011180QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011181 tSirWifiScanCmdReqParams *pStartCmd)
11182{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011183 QDF_STATUS status = QDF_STATUS_SUCCESS;
11184 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011185 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011186 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011187
11188 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011189 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011190 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011191 message.bodyptr = pStartCmd;
11192 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011193 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011194 NO_SESSION, message.type));
11195 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11196 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011197 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11198 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011199
11200 sme_release_global_lock(&pMac->sme);
11201 }
11202 return status;
11203}
11204
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011205/*
11206 * sme_ext_scan_stop() -
11207 * SME API to issue extscan stop
11208 *
11209 * hHal
11210 * pStopReq: extscan stop structure
11211 * Return QDF_STATUS
11212 */
11213QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11214 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011215{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011216 QDF_STATUS status = QDF_STATUS_SUCCESS;
11217 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011218 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011219 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011220
11221 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011222 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011223 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011224 message.bodyptr = pStopReq;
11225 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011226 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011227 NO_SESSION, message.type));
11228 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11229 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011230 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11231 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011232 sme_release_global_lock(&pMac->sme);
11233 }
11234 return status;
11235}
11236
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011237/*
11238 * sme_set_bss_hotlist() -
11239 * SME API to set BSSID hotlist
11240 *
11241 * hHal
11242 * pSetHotListReq: extscan set hotlist structure
11243 * Return QDF_STATUS
11244 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011245QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011246 tSirExtScanSetBssidHotListReqParams *
11247 pSetHotListReq)
11248{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011249 QDF_STATUS status = QDF_STATUS_SUCCESS;
11250 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011251 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011252 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011253
11254 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011255 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011256 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011257 message.bodyptr = pSetHotListReq;
11258 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011259 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011260 NO_SESSION, message.type));
11261 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11262 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011263 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11264 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011265
11266 sme_release_global_lock(&pMac->sme);
11267 }
11268 return status;
11269}
11270
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011271/*
11272 * sme_reset_bss_hotlist() -
11273 * SME API to reset BSSID hotlist
11274 *
11275 * hHal
11276 * pSetHotListReq: extscan set hotlist structure
11277 * Return QDF_STATUS
11278 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011279QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011280 tSirExtScanResetBssidHotlistReqParams *
11281 pResetReq)
11282{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011283 QDF_STATUS status = QDF_STATUS_SUCCESS;
11284 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011285 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011286 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011287
11288 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011289 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011290 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011291 message.bodyptr = pResetReq;
11292 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011293 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011294 NO_SESSION, message.type));
11295 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11296 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011297 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11298 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011299
11300 sme_release_global_lock(&pMac->sme);
11301 }
11302 return status;
11303}
11304
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011305/*
11306 * sme_set_significant_change() -
11307 * SME API to set significant change
11308 *
11309 * hHal
11310 * pSetSignificantChangeReq: extscan set significant change structure
11311 * Return QDF_STATUS
11312 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011313QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011314 tSirExtScanSetSigChangeReqParams *
11315 pSetSignificantChangeReq)
11316{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011317 QDF_STATUS status = QDF_STATUS_SUCCESS;
11318 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011319 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011320 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011321
11322 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011323 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011324 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011325 message.bodyptr = pSetSignificantChangeReq;
11326 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011327 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011328 NO_SESSION, message.type));
11329 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11330 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011331 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11332 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011333
11334 sme_release_global_lock(&pMac->sme);
11335 }
11336 return status;
11337}
11338
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011339/*
11340 * sme_reset_significant_change
11341 * SME API to reset significant change
11342 *
11343 * hHal
11344 * pResetReq: extscan reset significant change structure
11345 * Return QDF_STATUS
11346 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011347QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011348 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011349 *pResetReq)
11350{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011351 QDF_STATUS status = QDF_STATUS_SUCCESS;
11352 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011353 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011354 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011355
11356 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011357 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011358 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011359 message.bodyptr = pResetReq;
11360 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011361 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011362 NO_SESSION, message.type));
11363 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11364 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011365 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11366 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011367
11368 sme_release_global_lock(&pMac->sme);
11369 }
11370 return status;
11371}
11372
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011373/*
11374 * sme_get_cached_results() -
11375 * SME API to get cached results
11376 *
11377 * hHal
11378 * pCachedResultsReq: extscan get cached results structure
11379 * Return QDF_STATUS
11380 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011381QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011382 tSirExtScanGetCachedResultsReqParams *
11383 pCachedResultsReq)
11384{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011385 QDF_STATUS status = QDF_STATUS_SUCCESS;
11386 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011387 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011388 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011389
11390 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011391 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011392 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011393 message.bodyptr = pCachedResultsReq;
11394 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011395 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011396 NO_SESSION, message.type));
11397 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11398 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011399 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11400 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011401
11402 sme_release_global_lock(&pMac->sme);
11403 }
11404 return status;
11405}
11406
11407/**
11408 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011409 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011410 * @input: request message
11411 *
11412 * This function constructs the cds message and fill in message type,
11413 * bodyptr with %input and posts it to WDA queue.
11414 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011415 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011416 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011417QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011418 struct wifi_epno_params *input)
11419{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011420 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011421 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011422 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011423 struct wifi_epno_params *req_msg;
11424 int len, i;
11425
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011426 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011427 len = sizeof(*req_msg) +
11428 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011429
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011430 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011431 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011432 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011433 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011434 }
11435
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011436 req_msg->num_networks = input->num_networks;
11437 req_msg->request_id = input->request_id;
11438 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011439
11440 /* Fill only when num_networks are non zero */
11441 if (req_msg->num_networks) {
11442 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11443 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11444 req_msg->initial_score_max = input->initial_score_max;
11445 req_msg->same_network_bonus = input->same_network_bonus;
11446 req_msg->secure_bonus = input->secure_bonus;
11447 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11448 req_msg->current_connection_bonus =
11449 input->current_connection_bonus;
11450
11451 for (i = 0; i < req_msg->num_networks; i++) {
11452 req_msg->networks[i].flags = input->networks[i].flags;
11453 req_msg->networks[i].auth_bit_field =
11454 input->networks[i].auth_bit_field;
11455 req_msg->networks[i].ssid.length =
11456 input->networks[i].ssid.length;
11457 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11458 input->networks[i].ssid.ssId,
11459 req_msg->networks[i].ssid.length);
11460 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011461 }
11462
11463 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011464 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011465 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011466 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011467 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011468 return status;
11469 }
11470
11471 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011472 message.bodyptr = req_msg;
11473 message.type = WMA_SET_EPNO_LIST_REQ;
11474 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011475 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011476 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011477 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011478 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011479 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011480 }
11481 sme_release_global_lock(&mac->sme);
11482 return status;
11483}
11484
11485/**
11486 * sme_set_passpoint_list() - set passpoint network list
11487 * @hal: global hal handle
11488 * @input: request message
11489 *
11490 * This function constructs the cds message and fill in message type,
11491 * bodyptr with @input and posts it to WDA queue.
11492 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011493 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011494 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011495QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011496 struct wifi_passpoint_req *input)
11497{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011498 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011499 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011500 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011501 struct wifi_passpoint_req *req_msg;
11502 int len, i;
11503
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011504 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011505 len = sizeof(*req_msg) +
11506 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011507 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011508 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011509 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011510 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011511 }
11512
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011513 req_msg->num_networks = input->num_networks;
11514 req_msg->request_id = input->request_id;
11515 req_msg->session_id = input->session_id;
11516 for (i = 0; i < req_msg->num_networks; i++) {
11517 req_msg->networks[i].id =
11518 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011519 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011520 input->networks[i].realm,
11521 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011522 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011523 input->networks[i].plmn,
11524 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011525 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011526 input->networks[i].roaming_consortium_ids,
11527 sizeof(req_msg->networks[i].roaming_consortium_ids));
11528 }
11529
11530 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011531 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011532 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011533 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011534 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011535 return status;
11536 }
11537
11538 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011539 message.bodyptr = req_msg;
11540 message.type = WMA_SET_PASSPOINT_LIST_REQ;
11541 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011542 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011543 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011544 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011545 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011546 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011547 }
11548 sme_release_global_lock(&mac->sme);
11549 return status;
11550}
11551
11552/**
11553 * sme_reset_passpoint_list() - reset passpoint network list
11554 * @hHal: global hal handle
11555 * @input: request message
11556 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011557 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011558 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011559QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011560 struct wifi_passpoint_req *input)
11561{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011562 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011563 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011564 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011565 struct wifi_passpoint_req *req_msg;
11566
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011567 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011568 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011569 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011570 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011571 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011572 }
11573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011574 req_msg->request_id = input->request_id;
11575 req_msg->session_id = input->session_id;
11576
11577 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011578 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011579 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011580 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011581 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011582 return status;
11583 }
11584
11585 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011586 message.bodyptr = req_msg;
11587 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
11588 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011589 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011590 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011591 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011592 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011593 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011594 }
11595 sme_release_global_lock(&mac->sme);
11596 return status;
11597}
11598
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011599QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011600 void (*pExtScanIndCb)(void *,
11601 const uint16_t,
11602 void *))
11603{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011604 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011605 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11606
11607 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011608 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011609 pMac->sme.pExtScanIndCb = pExtScanIndCb;
11610 sme_release_global_lock(&pMac->sme);
11611 }
11612 return status;
11613}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011614#endif /* FEATURE_WLAN_EXTSCAN */
11615
Wen Gong7952fbd2018-04-18 11:27:23 +080011616/**
11617 * sme_send_wisa_params(): Pass WISA mode to WMA
11618 * @hal: HAL context
11619 * @wisa_params: pointer to WISA params struct
11620 * @sessionId: SME session id
11621 *
11622 * Pass WISA params to WMA
11623 *
11624 * Return: QDF_STATUS
11625 */
11626QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11627 struct sir_wisa_params *wisa_params)
11628{
11629 QDF_STATUS status = QDF_STATUS_SUCCESS;
11630 tpAniSirGlobal mac = PMAC_STRUCT(hal);
11631 struct scheduler_msg message = {0};
11632 struct sir_wisa_params *cds_msg_wisa_params;
11633
11634 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11635 if (!cds_msg_wisa_params)
11636 return QDF_STATUS_E_NOMEM;
11637
11638 *cds_msg_wisa_params = *wisa_params;
11639 status = sme_acquire_global_lock(&mac->sme);
11640 if (QDF_IS_STATUS_SUCCESS(status)) {
11641 message.bodyptr = cds_msg_wisa_params;
11642 message.type = WMA_SET_WISA_PARAMS;
11643 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
11644 sme_release_global_lock(&mac->sme);
11645 }
11646 return status;
11647}
11648
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011649#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11650
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011651/*
11652 * sme_ll_stats_clear_req() -
11653 * SME API to clear Link Layer Statistics
11654 *
11655 * hHal
11656 * pclearStatsReq: Link Layer clear stats request params structure
11657 * Return QDF_STATUS
11658 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011659QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011660 tSirLLStatsClearReq *pclearStatsReq)
11661{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011662 QDF_STATUS status = QDF_STATUS_SUCCESS;
11663 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011664 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011665 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011666 tSirLLStatsClearReq *clear_stats_req;
11667
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011668 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011669 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011670 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011671 "statsClearReqMask = 0x%X",
11672 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011673 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011674 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070011675 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
11676 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11677 "%s: invalid staId %d",
11678 __func__, pclearStatsReq->staId);
11679 return QDF_STATUS_E_INVAL;
11680 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011681
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011682 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011683
11684 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011685 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011686 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
11687 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011688 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011689 }
11690
11691 *clear_stats_req = *pclearStatsReq;
11692
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011693 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011694 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011695 message.bodyptr = clear_stats_req;
11696 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011697 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011698 NO_SESSION, message.type));
11699 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11700 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011701 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011702 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011703 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
11704 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011705 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011706 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011707 }
11708 sme_release_global_lock(&pMac->sme);
11709 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011710 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11711 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011712 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011713 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011714 }
11715
11716 return status;
11717}
11718
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011719/*
11720 * sme_ll_stats_set_req() -
11721 * SME API to set the Link Layer Statistics
11722 *
11723 * hHal
11724 * psetStatsReq: Link Layer set stats request params structure
11725 * Return QDF_STATUS
11726 */
11727QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
11728 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011729{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011730 QDF_STATUS status = QDF_STATUS_SUCCESS;
11731 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011732 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011733 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011734 tSirLLStatsSetReq *set_stats_req;
11735
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011736 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011737 "%s: MPDU Size = %u", __func__,
11738 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011739 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011740 " Aggressive Stats Collections = %u",
11741 psetStatsReq->aggressiveStatisticsGathering);
11742
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011743 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011744
11745 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011746 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011747 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
11748 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011749 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011750 }
11751
11752 *set_stats_req = *psetStatsReq;
11753
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011754 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011755 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011756 message.bodyptr = set_stats_req;
11757 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011758 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011759 NO_SESSION, message.type));
11760 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11761 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011762 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011763 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011764 "%s: not able to post WMA_LL_STATS_SET_REQ",
11765 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011766 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011767 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011768 }
11769 sme_release_global_lock(&pMac->sme);
11770 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011771 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11772 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011773 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011774 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011775 }
11776
11777 return status;
11778}
11779
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011780/*
11781 * sme_ll_stats_get_req() -
11782 * SME API to get the Link Layer Statistics
11783 *
11784 * hHal
11785 * pgetStatsReq: Link Layer get stats request params structure
11786 * Return QDF_STATUS
11787 */
11788QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
11789 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011790{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011791 QDF_STATUS status = QDF_STATUS_SUCCESS;
11792 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011793 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011794 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011795 tSirLLStatsGetReq *get_stats_req;
11796
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011797 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011798
11799 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011800 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011801 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
11802 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011803 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011804 }
11805
11806 *get_stats_req = *pgetStatsReq;
11807
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011808 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011809 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011810 message.bodyptr = get_stats_req;
11811 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011812 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011813 NO_SESSION, message.type));
11814 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11815 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011816 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011817 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011818 "%s: not able to post WMA_LL_STATS_GET_REQ",
11819 __func__);
11820
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011821 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011822 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011823
11824 }
11825 sme_release_global_lock(&pMac->sme);
11826 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011827 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11828 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011829 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011830 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011831 }
11832
11833 return status;
11834}
11835
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011836/*
11837 * sme_set_link_layer_stats_ind_cb() -
11838 * SME API to trigger the stats are available after get request
11839 *
11840 * hHal
11841 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011842 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011843 * Return QDF_STATUS
11844 */
11845QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
11846 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
11847{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011848 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011849 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11850
11851 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011852 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011853 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
11854 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011855 } else
11856 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11857 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011858
11859 return status;
11860}
11861
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011862/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080011863 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
11864 * @hal: Mac global handle
11865 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
11866 * status notification from FW
11867 *
11868 * Return: eHalStatus
11869 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011870QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
Jeff Johnson2d292122018-06-02 21:02:02 -070011871 (hdd_handle_t callback_ctx, tSirLLStatsResults
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011872 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080011873{
11874 QDF_STATUS status;
11875 tpAniSirGlobal mac = PMAC_STRUCT(hal);
11876
11877 status = sme_acquire_global_lock(&mac->sme);
11878 if (status == QDF_STATUS_SUCCESS) {
11879 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
11880 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011881 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080011882 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11883 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080011884 return status;
11885}
11886
11887/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011888 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
11889 * indication
11890 * @h_hal: Hal Handle
11891 *
11892 * This function reset's the link layer stats indication
11893 *
11894 * Return: QDF_STATUS Enumeration
11895 */
11896
11897QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
11898{
11899 QDF_STATUS status;
11900 tpAniSirGlobal pmac;
11901
11902 if (!h_hal) {
11903 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11904 FL("hHal is not valid"));
11905 return QDF_STATUS_E_INVAL;
11906 }
11907 pmac = PMAC_STRUCT(h_hal);
11908
11909 status = sme_acquire_global_lock(&pmac->sme);
11910 if (QDF_IS_STATUS_SUCCESS(status)) {
11911 pmac->sme.pLinkLayerStatsIndCallback = NULL;
11912 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011913 } else
11914 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11915 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011916
11917 return status;
11918}
11919
Zhang Qian73c348a2017-03-13 16:15:55 +080011920/**
11921 * sme_ll_stats_set_thresh - set threshold for mac counters
11922 * @hal, hal layer handle
11923 * @threshold, threshold for mac counters
11924 *
11925 * Return: QDF_STATUS Enumeration
11926 */
11927QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
11928 struct sir_ll_ext_stats_threshold *threshold)
11929{
11930 QDF_STATUS status;
11931 tpAniSirGlobal mac;
Rajeev Kumar658e8492017-12-13 11:35:41 -080011932 struct scheduler_msg message = {0};
Zhang Qian73c348a2017-03-13 16:15:55 +080011933 struct sir_ll_ext_stats_threshold *thresh;
11934
11935 if (!threshold) {
11936 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11937 FL("threshold is not valid"));
11938 return QDF_STATUS_E_INVAL;
11939 }
11940
11941 if (!hal) {
11942 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11943 FL("hal is not valid"));
11944 return QDF_STATUS_E_INVAL;
11945 }
11946 mac = PMAC_STRUCT(hal);
11947
11948 thresh = qdf_mem_malloc(sizeof(*thresh));
11949 if (!thresh) {
11950 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11951 "%s: Fail to alloc mem", __func__);
11952 return QDF_STATUS_E_NOMEM;
11953 }
11954 *thresh = *threshold;
11955
11956 status = sme_acquire_global_lock(&mac->sme);
11957 if (QDF_IS_STATUS_SUCCESS(status)) {
11958 /* Serialize the req through MC thread */
11959 message.bodyptr = thresh;
11960 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
11961 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
11962 NO_SESSION, message.type));
11963 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
11964 if (!QDF_IS_STATUS_SUCCESS(status)) {
11965 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11966 "%s: not able to post WDA_LL_STATS_GET_REQ",
11967 __func__);
11968 qdf_mem_free(thresh);
11969 }
11970 sme_release_global_lock(&mac->sme);
11971 } else {
11972 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11973 FL("sme_acquire_global_lock error"));
11974 qdf_mem_free(thresh);
11975 }
11976 return status;
11977}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011978
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011979#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
11980
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053011981#ifdef WLAN_POWER_DEBUGFS
11982/**
11983 * sme_power_debug_stats_req() - SME API to collect Power debug stats
11984 * @callback_fn: Pointer to the callback function for Power stats event
11985 * @power_stats_context: Pointer to context
11986 *
11987 * Return: QDF_STATUS
11988 */
11989QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
11990 (struct power_stats_response *response,
11991 void *context), void *power_stats_context)
11992{
11993 QDF_STATUS status = QDF_STATUS_SUCCESS;
11994 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011995 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053011996
11997 status = sme_acquire_global_lock(&mac_ctx->sme);
11998 if (QDF_IS_STATUS_SUCCESS(status)) {
11999 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012000 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012001 sme_release_global_lock(&mac_ctx->sme);
12002 return QDF_STATUS_E_FAILURE;
12003 }
12004
12005 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12006 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12007 msg.bodyptr = NULL;
12008 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012009 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012010 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012011 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012012 sme_release_global_lock(&mac_ctx->sme);
12013 }
12014 return status;
12015}
12016#endif
12017
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012018#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012019/*
12020 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12021 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12022 *
12023 * hHal - The handle returned by mac_open.
12024 * nRoamOffloadEnabled - The bool to update with
12025 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12026 * Other status means SME is failed to update.
12027 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012028
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012029QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012030 bool nRoamOffloadEnabled)
12031{
12032 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012033 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012034
12035 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012036 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012037 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012038 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12039 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12040 nRoamOffloadEnabled);
12041 pMac->roam.configParam.isRoamOffloadEnabled =
12042 nRoamOffloadEnabled;
12043 sme_release_global_lock(&pMac->sme);
12044 }
12045
12046 return status;
12047}
12048
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012049/**
12050 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12051 * This is a synchronous call
12052 * @hal_ctx: The handle returned by mac_open.
12053 * @session_id: Session Identifier
12054 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012055 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012056 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12057 * Other status means SME is failed to update.
12058 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012059
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012060QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012061 uint8_t session_id,
12062 bool key_mgmt_offload_enabled,
12063 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012064{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012065 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012066 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012067
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012068 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012069 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012070 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012071 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012072 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12073 __func__, key_mgmt_offload_enabled);
12074 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12075 session_id,
12076 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012077 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012078 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012079 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012080 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012081 }
12082
12083 return status;
12084}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012085#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012086
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012087/*
12088 * sme_get_temperature() -
12089 * SME API to get the pdev temperature
12090 *
12091 * hHal
12092 * temperature context
12093 * pCallbackfn: callback fn with response (temperature)
12094 * Return QDF_STATUS
12095 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012096QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012097 void *tempContext,
12098 void (*pCallbackfn)(int temperature,
12099 void *pContext))
12100{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012101 QDF_STATUS status = QDF_STATUS_SUCCESS;
12102 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012103 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012104 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012105
12106 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012107 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012108 if ((NULL == pCallbackfn) &&
12109 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012110 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012111 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012112 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012113 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012114 } else if (NULL != pCallbackfn) {
12115 pMac->sme.pTemperatureCbContext = tempContext;
12116 pMac->sme.pGetTemperatureCb = pCallbackfn;
12117 }
12118 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012119 message.bodyptr = NULL;
12120 message.type = WMA_GET_TEMPERATURE_REQ;
12121 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12122 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012123 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012124 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012125 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012126 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012127 }
12128 sme_release_global_lock(&pMac->sme);
12129 }
12130 return status;
12131}
12132
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012133/*
12134 * sme_set_scanning_mac_oui() -
12135 * SME API to set scanning mac oui
12136 *
12137 * hHal
12138 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12139 * Return QDF_STATUS
12140 */
12141QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12142 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012143{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012144 QDF_STATUS status = QDF_STATUS_SUCCESS;
12145 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012146 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012147 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012148
12149 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012150 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012151 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012152 message.bodyptr = pScanMacOui;
12153 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12154 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12155 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012156 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012157 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012158 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012159 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012160 }
12161 sme_release_global_lock(&pMac->sme);
12162 }
12163 return status;
12164}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012165
12166#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012167/*
12168 * sme_set_dhcp_srv_offload() -
12169 * SME API to set DHCP server offload info
12170 *
12171 * hHal
12172 * pDhcpSrvInfo : DHCP server offload info struct
12173 * Return QDF_STATUS
12174 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012175QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012176 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12177{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012178 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012179 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012180 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012181 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12182
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012183 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012184
12185 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012186 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012187 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12188 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012189 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012190 }
12191
12192 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12193
12194 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012195 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012196 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012197 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12198 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012199
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012200 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012201 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12202 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012203 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012204 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012205 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012206 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012207 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012208 }
12209 sme_release_global_lock(&pMac->sme);
12210 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012211 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012212 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012213 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012214 }
12215
12216 return status;
12217}
12218#endif /* DHCP_SERVER_OFFLOAD */
12219
Krunal Soniaadaa272017-10-04 16:42:55 -070012220QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12221 uint32_t arg_count, uint32_t *arg)
12222{
12223 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12224 arg_count, arg);
12225}
12226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012227#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012228/*
12229 * sme_set_led_flashing() -
12230 * API to set the Led flashing parameters.
12231 *
12232 * hHal - The handle returned by mac_open.
12233 * x0, x1 - led flashing parameters
12234 * Return QDF_STATUS
12235 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012236QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012237 uint32_t x0, uint32_t x1)
12238{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012239 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012240 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012241 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012242 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012243
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012244 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012245 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012246 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012247 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012248 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012249 }
12250
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012251 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012252 ledflashing->pattern_id = type;
12253 ledflashing->led_x0 = x0;
12254 ledflashing->led_x1 = x1;
12255
12256 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012257 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012258 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012259 message.bodyptr = ledflashing;
12260 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012261 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012262 sme_release_global_lock(&pMac->sme);
12263 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012264 if (!QDF_IS_STATUS_SUCCESS(status))
12265 qdf_mem_free(ledflashing);
12266
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012267 return status;
12268}
12269#endif
12270
12271/**
12272 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12273 * @h_hal: corestack handler
12274 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012275 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012276 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012277QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012278{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012279 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012280 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12281
12282 status = sme_acquire_global_lock(&mac->sme);
12283
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012284 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012285
12286 mac->scan.fEnableDFSChnlScan = dfs_flag;
12287
12288 /* update the channel list to the firmware */
12289 status = csr_update_channel_list(mac);
12290
12291 sme_release_global_lock(&mac->sme);
12292 }
12293
12294 return status;
12295}
12296
Min Liu5eaf7242018-03-13 17:32:15 +080012297/**
12298 * sme_enable_dfS_chan_scan() - set DFS channel scan enable/disable
12299 * @h_hal: corestack handler
12300 * @dfs_flag: flag indicating dfs channel enable/disable
12301 * Return: QDF_STATUS
12302 */
12303QDF_STATUS sme_enable_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
12304{
12305 QDF_STATUS status = QDF_STATUS_SUCCESS;
12306 tpAniSirGlobal mac;
12307
12308 if (!h_hal) {
12309 sme_err("hal is NULL");
12310 return QDF_STATUS_E_INVAL;
12311 }
12312
12313 mac = PMAC_STRUCT(h_hal);
12314 if (!mac) {
12315 sme_err("mac is NULL");
12316 return QDF_STATUS_E_INVAL;
12317 }
12318
12319 mac->scan.fEnableDFSChnlScan = dfs_flag;
12320
12321 return status;
12322}
12323
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012324#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12325/**
12326 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12327 * concurreny rules set to avoid channel interference.
12328 * @hal - Hal context
12329 * @sap_ch - channel to switch
12330 * @sap_phy_mode - phy mode of SAP
12331 * @cc_switch_mode - concurreny switch mode
12332 * @session_id - sme session id.
12333 *
12334 * Return: true if there is no channel interference else return false
12335 */
12336bool sme_validate_sap_channel_switch(tHalHandle hal,
12337 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12338 uint8_t session_id)
12339{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012340 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012341 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012342 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012343 uint16_t intf_channel = 0;
12344
12345 if (!session)
12346 return false;
12347
12348 session->ch_switch_in_progress = true;
12349 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012350 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012351 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12352 sap_phy_mode,
12353 cc_switch_mode);
12354 sme_release_global_lock(&mac->sme);
12355 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012356 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012357 FL("sme_acquire_global_lock error!"));
12358 session->ch_switch_in_progress = false;
12359 return false;
12360 }
12361
12362 session->ch_switch_in_progress = false;
12363 return (intf_channel == 0) ? true : false;
12364}
12365#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012366
12367/**
12368 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12369 * @hal: hal
12370 * @session_id: session ID
12371 * @stats_avg_factor: average stats factor
12372 *
12373 * This function configures the stats avg factor in firmware
12374 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012375 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012376 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012377QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012378 uint16_t stats_avg_factor)
12379{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012380 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012381 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012382 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12383 struct sir_stats_avg_factor *stats_factor;
12384
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012385 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012386
12387 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012388 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012389 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12390 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012391 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012392 }
12393
12394 status = sme_acquire_global_lock(&mac->sme);
12395
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012396 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012397
12398 stats_factor->vdev_id = session_id;
12399 stats_factor->stats_avg_factor = stats_avg_factor;
12400
12401 /* serialize the req through MC thread */
12402 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12403 msg.bodyptr = stats_factor;
12404
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012405 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012406 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012407 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012408 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12409 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012410 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012411 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012412 }
12413 sme_release_global_lock(&mac->sme);
12414 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012415 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012416 "%s: sme_acquire_global_lock error!",
12417 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012418 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012419 }
12420
12421 return status;
12422}
12423
12424/**
12425 * sme_configure_guard_time() - function to configure guard time
12426 * @hal: hal
12427 * @session_id: session id
12428 * @guard_time: guard time
12429 *
12430 * This function configures the guard time in firmware
12431 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012432 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012433 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012434QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012435 uint32_t guard_time)
12436{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012437 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012438 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012439 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12440 struct sir_guard_time_request *g_time;
12441
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012442 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012443
12444 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012445 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012446 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12447 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012448 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012449 }
12450
12451 status = sme_acquire_global_lock(&mac->sme);
12452
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012453 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012454
12455 g_time->vdev_id = session_id;
12456 g_time->guard_time = guard_time;
12457
12458 /* serialize the req through MC thread */
12459 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12460 msg.bodyptr = g_time;
12461
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012462 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012463 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012464 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012465 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12466 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012467 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012468 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012469 }
12470 sme_release_global_lock(&mac->sme);
12471 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012472 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012473 "%s: sme_acquire_global_lock error!",
12474 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012475 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012476 }
12477
12478 return status;
12479}
12480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012481/*
12482 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12483 * to either start/stop logging
12484 * @hal: HAL context
12485 * @start_log: Structure containing the wifi start logger params
12486 *
12487 * This function sends the start/stop logging command to WMA
12488 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012489 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012490 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012491QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012492 struct sir_wifi_start_log start_log)
12493{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012494 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012495 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012496 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012497 struct sir_wifi_start_log *req_msg;
12498 uint32_t len;
12499
12500 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012501 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012502 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012503 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012504 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012505 }
12506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012507 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012508 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012509 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012510 req_msg->ini_triggered = start_log.ini_triggered;
12511 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012512 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012513 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012514
12515 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012516 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012517 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012518 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012519 return status;
12520 }
12521
12522 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012523 message.bodyptr = req_msg;
12524 message.type = SIR_HAL_START_STOP_LOGGING;
12525 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012526 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012527 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012528 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012529 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012530 }
12531 sme_release_global_lock(&mac->sme);
12532
12533 return status;
12534}
12535
12536/**
12537 * sme_neighbor_middle_of_roaming() - Function to know if
12538 * STA is in the middle of roaming states
12539 * @hal: Handle returned by macOpen
12540 * @sessionId: sessionId of the STA session
12541 *
12542 * This function is a wrapper to call
12543 * csr_neighbor_middle_of_roaming to know STA is in the
12544 * middle of roaming states
12545 *
12546 * Return: True or False
12547 *
12548 */
12549bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12550{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012551 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12552 bool val = false;
12553
12554 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12555 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12556 else
Rajeev Kumar9176ca42018-05-03 09:20:40 -070012557 sme_debug("Invalid Session: %d", sessionId);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012558
Sandeep Puligillaca631612016-11-08 11:53:52 -080012559 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012560}
12561
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +053012562bool sme_is_any_session_in_middle_of_roaming(mac_handle_t hal)
12563{
12564 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12565 uint8_t session_id;
12566
12567 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
12568 if (CSR_IS_SESSION_VALID(mac_ctx, session_id) &&
12569 csr_neighbor_middle_of_roaming(mac_ctx, session_id))
12570 return true;
12571 }
12572
12573 return false;
12574}
12575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012576/*
12577 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12578 * @mac: MAC handle
12579 *
12580 * This function is used to send the command that will
12581 * be used to flush the logs in the firmware
12582 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012583 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012584 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012585QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012586{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012587 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012588 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012589
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012590 /* Serialize the req through MC thread */
12591 message.bodyptr = NULL;
12592 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012593 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012594 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012595 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012596 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012597 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012598 return status;
12599}
12600
Jeff Johnsona1e92612017-09-24 15:33:44 -070012601QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012602 sme_ac_enum_type ac, uint8_t tid,
12603 uint8_t pri, uint32_t srvc_int,
12604 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053012605 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012606 uint8_t psb, uint32_t sessionId,
12607 uint32_t delay_interval)
12608{
12609 void *wma_handle;
12610 t_wma_trigger_uapsd_params uapsd_params;
12611 enum uapsd_ac access_category;
12612
12613 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012614 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012615 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012616 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012617 }
12618
Anurag Chouhan6d760662016-02-20 16:05:43 +053012619 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012620 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012621 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012622 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012623 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012624 }
12625
12626 switch (ac) {
12627 case SME_AC_BK:
12628 access_category = UAPSD_BK;
12629 break;
12630 case SME_AC_BE:
12631 access_category = UAPSD_BE;
12632 break;
12633 case SME_AC_VI:
12634 access_category = UAPSD_VI;
12635 break;
12636 case SME_AC_VO:
12637 access_category = UAPSD_VO;
12638 break;
12639 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012640 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012641 }
12642
12643 uapsd_params.wmm_ac = access_category;
12644 uapsd_params.user_priority = pri;
12645 uapsd_params.service_interval = srvc_int;
12646 uapsd_params.delay_interval = delay_interval;
12647 uapsd_params.suspend_interval = sus_int;
12648
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012649 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012650 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012651 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012652 "Failed to Trigger Uapsd params for sessionId %d",
12653 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012654 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012655 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012656 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012657}
12658
Jeff Johnsona1e92612017-09-24 15:33:44 -070012659QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012660 sme_ac_enum_type ac,
12661 uint32_t sessionId)
12662{
12663 void *wma_handle;
12664 enum uapsd_ac access_category;
12665
12666 switch (ac) {
12667 case SME_AC_BK:
12668 access_category = UAPSD_BK;
12669 break;
12670 case SME_AC_BE:
12671 access_category = UAPSD_BE;
12672 break;
12673 case SME_AC_VI:
12674 access_category = UAPSD_VI;
12675 break;
12676 case SME_AC_VO:
12677 access_category = UAPSD_VO;
12678 break;
12679 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012680 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012681 }
12682
Anurag Chouhan6d760662016-02-20 16:05:43 +053012683 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012684 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012685 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012686 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012687 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012688 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012689 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012690 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012691 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012692 "Failed to disable uapsd for ac %d for sessionId %d",
12693 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012694 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012695 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012696 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012697}
12698
12699/**
12700 * sme_update_nss() - SME API to change the number for spatial streams
12701 * (1 or 2)
12702 * @hal: Handle returned by mac open
12703 * @nss: Number of spatial streams
12704 *
12705 * This function is used to update the number of spatial streams supported.
12706 *
12707 * Return: Success upon successfully changing nss else failure
12708 *
12709 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012710QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012711{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012712 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012713 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
12714 uint32_t i, value = 0;
12715 union {
12716 uint16_t cfg_value16;
12717 tSirMacHTCapabilityInfo ht_cap_info;
12718 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012719 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012720
12721 status = sme_acquire_global_lock(&mac_ctx->sme);
12722
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012723 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012724 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
12725
12726 /* get the HT capability info*/
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012727 sme_cfg_get_int(h_hal, WNI_CFG_HT_CAP_INFO, &value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012728 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
12729
12730 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
12731 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
12732 csr_session = &mac_ctx->roam.roamSession[i];
12733 csr_session->htConfig.ht_tx_stbc =
12734 uHTCapabilityInfo.ht_cap_info.txSTBC;
12735 }
12736 }
12737
12738 sme_release_global_lock(&mac_ctx->sme);
12739 }
12740 return status;
12741}
12742
12743/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070012744 * sme_update_user_configured_nss() - sets the nss based on user request
12745 * @hal: Pointer to HAL
12746 * @nss: number of streams
12747 *
12748 * Return: None
12749 */
12750void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
12751{
12752 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12753
12754 mac_ctx->user_configured_nss = nss;
12755}
12756
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070012757int sme_update_tx_bfee_supp(tHalHandle hal, uint8_t session_id,
12758 uint8_t cfg_val)
12759{
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012760 QDF_STATUS status;
12761
12762 status = sme_cfg_set_int(hal, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070012763 cfg_val);
12764 if (status != QDF_STATUS_SUCCESS) {
12765 sme_err("Failed to set SU BFEE CFG");
12766 return -EFAULT;
12767 }
12768
12769 return sme_update_he_tx_bfee_supp(hal, session_id, cfg_val);
12770}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012771#ifdef WLAN_FEATURE_11AX
Jinwei Chenef742dc2018-06-27 12:57:50 +080012772void sme_update_tgt_he_cap(mac_handle_t mac_handle, struct wma_tgt_cfg *cfg)
Jinwei Chen998a1a02018-06-20 17:20:34 +080012773{
Jinwei Chenef742dc2018-06-27 12:57:50 +080012774 tpAniSirGlobal mac_ctx = PMAC_STRUCT(mac_handle);
Jinwei Chen998a1a02018-06-20 17:20:34 +080012775
12776 qdf_mem_copy(&mac_ctx->he_cap_2g,
Jinwei Chenef742dc2018-06-27 12:57:50 +080012777 &cfg->he_cap_2g,
12778 sizeof(tDot11fIEhe_cap));
Jinwei Chen998a1a02018-06-20 17:20:34 +080012779
12780 qdf_mem_copy(&mac_ctx->he_cap_5g,
Jinwei Chenef742dc2018-06-27 12:57:50 +080012781 &cfg->he_cap_5g,
12782 sizeof(tDot11fIEhe_cap));
Jinwei Chen998a1a02018-06-20 17:20:34 +080012783}
12784
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012785void sme_update_he_cap_nss(tHalHandle hal, uint8_t session_id,
12786 uint8_t nss)
12787{
12788 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12789 struct csr_roam_session *csr_session;
12790 uint32_t tx_mcs_map = 0;
12791 uint32_t rx_mcs_map = 0;
12792
12793 if (!nss || (nss > 2)) {
12794 sme_err("invalid Nss value %d", nss);
12795 }
12796 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012797 sme_cfg_get_int(hal, WNI_CFG_HE_RX_MCS_MAP_LT_80, &rx_mcs_map);
12798 sme_cfg_get_int(hal, WNI_CFG_HE_TX_MCS_MAP_LT_80, &tx_mcs_map);
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012799 if (nss == 1) {
12800 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_DISABLE, 2);
12801 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_DISABLE, 2);
12802 } else {
12803 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_0_11, 2);
12804 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_0_11, 2);
12805 }
12806 sme_info("new HE Nss MCS MAP: Rx 0x%0X, Tx: 0x%0X",
12807 rx_mcs_map, tx_mcs_map);
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012808 sme_cfg_set_int(hal, WNI_CFG_HE_RX_MCS_MAP_LT_80, rx_mcs_map);
12809 sme_cfg_set_int(hal, WNI_CFG_HE_TX_MCS_MAP_LT_80, tx_mcs_map);
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012810 csr_update_session_he_cap(mac_ctx, csr_session);
12811
12812}
Kiran Kumar Lokere96246e52018-01-24 16:44:35 -080012813
12814int sme_update_he_mcs(tHalHandle hal, uint8_t session_id, uint16_t he_mcs)
12815{
12816 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12817 struct csr_roam_session *csr_session;
12818 uint16_t mcs_val = 0;
12819 uint16_t mcs_map = HE_MCS_ALL_DISABLED;
12820 uint32_t wni_cfg_tx_param = 0;
12821 uint32_t wni_cfg_rx_param = 0;
12822
12823 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
12824 if (!csr_session) {
12825 sme_err("No session for id %d", session_id);
12826 return -EINVAL;
12827 }
12828 if ((he_mcs & 0x3) == HE_MCS_DISABLE) {
12829 sme_err("Invalid HE MCS 0x%0x, can't disable 0-7 for 1ss",
12830 he_mcs);
12831 return -EINVAL;
12832 }
12833 mcs_val = he_mcs & 0x3;
12834 switch (he_mcs) {
12835 case HE_80_MCS0_7:
12836 case HE_80_MCS0_9:
12837 case HE_80_MCS0_11:
12838 if (mac_ctx->roam.configParam.enable2x2) {
12839 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12840 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 2);
12841 } else {
12842 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12843 }
12844 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_LT_80;
12845 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_LT_80;
12846 break;
12847
12848 case HE_160_MCS0_7:
12849 case HE_160_MCS0_9:
12850 case HE_160_MCS0_11:
12851 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12852 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_160;
12853 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_160;
12854 break;
12855
12856 case HE_80p80_MCS0_7:
12857 case HE_80p80_MCS0_9:
12858 case HE_80p80_MCS0_11:
12859 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12860 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_80_80;
12861 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_80_80;
12862 break;
12863
12864 default:
12865 sme_err("Invalid HE MCS 0x%0x", he_mcs);
12866 return -EINVAL;
12867 }
12868 sme_info("new HE MCS 0x%0x", mcs_map);
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012869 sme_cfg_set_int(hal, wni_cfg_tx_param, mcs_map);
12870 sme_cfg_set_int(hal, wni_cfg_rx_param, mcs_map);
Kiran Kumar Lokere96246e52018-01-24 16:44:35 -080012871 csr_update_session_he_cap(mac_ctx, csr_session);
12872
12873 return 0;
12874}
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012875
12876static int sme_update_he_cap(tHalHandle hal, uint8_t session_id,
12877 uint16_t he_cap, int value)
12878{
12879 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12880 struct csr_roam_session *session;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012881
12882 session = CSR_GET_SESSION(mac_ctx, session_id);
12883 if (!session) {
12884 sme_err("No session for id %d", session_id);
12885 return -EINVAL;
12886 }
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012887 sme_cfg_set_int(hal, he_cap, value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012888 csr_update_session_he_cap(mac_ctx, session);
12889
12890 return 0;
12891}
12892
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070012893int sme_update_he_tx_bfee_supp(tHalHandle hal, uint8_t session_id,
12894 uint8_t cfg_val)
12895{
12896 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_SU_BEAMFORMEE,
12897 cfg_val);
12898}
12899
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012900int sme_update_he_tx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
12901{
12902 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080012903 uint32_t he_cap_val = 0;
12904
12905 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012906
12907 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080012908 WNI_CFG_HE_TX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012909 if (ret)
12910 return ret;
12911
12912 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080012913 WNI_CFG_HE_TX_STBC_GT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012914}
12915
12916int sme_update_he_rx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
12917{
12918 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080012919 uint32_t he_cap_val = 0;
12920
12921 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012922
12923 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080012924 WNI_CFG_HE_RX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012925 if (ret)
12926 return ret;
12927
12928 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080012929 WNI_CFG_HE_RX_STBC_GT80, he_cap_val);
12930}
12931
12932int sme_update_he_frag_supp(tHalHandle hal, uint8_t session_id,
12933 uint16_t he_frag)
12934{
12935 return sme_update_he_cap(hal, session_id,
12936 WNI_CFG_HE_FRAGMENTATION, he_frag);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012937}
Kiran Kumar Lokeree43a4582018-05-08 19:54:03 -070012938
12939int sme_update_he_ldpc_supp(tHalHandle hal, uint8_t session_id,
12940 uint16_t he_ldpc)
12941{
12942 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_LDPC, he_ldpc);
12943}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012944#endif
12945
Archana Ramachandran5041b252016-04-25 14:29:25 -070012946/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053012947 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
12948 * @hal: global hal handle
12949 * @cb: callback function pointer
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053012950 * @context: callback context
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053012951 *
12952 * This function stores nud debug stats callback function.
12953 *
12954 * Return: QDF_STATUS enumeration.
12955 */
12956QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053012957 void (*cb)(void *, struct rsp_stats *, void *),
12958 void *context)
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053012959{
12960 QDF_STATUS status = QDF_STATUS_SUCCESS;
12961 tpAniSirGlobal mac;
12962
12963 if (!hal) {
12964 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12965 FL("hal is not valid"));
12966 return QDF_STATUS_E_INVAL;
12967 }
12968 mac = PMAC_STRUCT(hal);
12969
12970 status = sme_acquire_global_lock(&mac->sme);
12971 if (!QDF_IS_STATUS_SUCCESS(status)) {
12972 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12973 FL("sme_acquire_global_lock failed!(status=%d)"),
12974 status);
12975 return status;
12976 }
12977
12978 mac->sme.get_arp_stats_cb = cb;
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053012979 mac->sme.get_arp_stats_context = context;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053012980 sme_release_global_lock(&mac->sme);
12981 return status;
12982}
12983
12984/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012985 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012986 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012987 * @cb: callback function pointer
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053012988 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012989 *
12990 * This function stores the rssi threshold breached callback function.
12991 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012992 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012993 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012994QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012995 void (*cb)(void *, struct rssi_breach_event *))
12996{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012997 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012998 tpAniSirGlobal mac;
12999
13000 if (!h_hal) {
13001 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13002 FL("hHal is not valid"));
13003 return QDF_STATUS_E_INVAL;
13004 }
13005 mac = PMAC_STRUCT(h_hal);
13006
13007 status = sme_acquire_global_lock(&mac->sme);
13008 if (!QDF_IS_STATUS_SUCCESS(status)) {
13009 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13010 FL("sme_acquire_global_lock failed!(status=%d)"),
13011 status);
13012 return status;
13013 }
13014
13015 mac->sme.rssi_threshold_breached_cb = cb;
13016 sme_release_global_lock(&mac->sme);
13017 return status;
13018}
13019
13020/**
13021 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13022 * @hal: global hal handle
13023 *
13024 * This function de-registers the rssi threshold breached callback function.
13025 *
13026 * Return: QDF_STATUS enumeration.
13027 */
13028QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13029{
13030 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013031 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13032
13033 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013034 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013035 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013036 return status;
13037 }
13038
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013039 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013040 sme_release_global_lock(&mac->sme);
13041 return status;
13042}
13043
13044/**
13045 * sme_is_any_session_in_connected_state() - SME wrapper API to
13046 * check if any session is in connected state or not.
13047 *
13048 * @hal: Handle returned by mac open
13049 *
13050 * This function is used to check if any valid sme session is in
13051 * connected state or not.
13052 *
13053 * Return: true if any session is connected, else false.
13054 *
13055 */
13056bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13057{
13058 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013059 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013060 bool ret = false;
13061
13062 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013063 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013064 ret = csr_is_any_session_in_connect_state(mac_ctx);
13065 sme_release_global_lock(&mac_ctx->sme);
13066 }
13067 return ret;
13068}
13069
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013070QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13071 void (*cb)(void *,
13072 struct chip_pwr_save_fail_detected_params *)) {
13073
13074 QDF_STATUS status = QDF_STATUS_SUCCESS;
13075 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13076
13077 status = sme_acquire_global_lock(&mac->sme);
13078 if (status != QDF_STATUS_SUCCESS) {
13079 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13080 return status;
13081 }
13082 mac->sme.chip_power_save_fail_cb = cb;
13083 sme_release_global_lock(&mac->sme);
13084 return status;
13085}
13086
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013087/**
13088 * sme_set_rssi_monitoring() - set rssi monitoring
13089 * @hal: global hal handle
13090 * @input: request message
13091 *
13092 * This function constructs the vos message and fill in message type,
13093 * bodyptr with @input and posts it to WDA queue.
13094 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013095 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013096 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013097QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013098 struct rssi_monitor_req *input)
13099{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013100 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013101 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013102 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013103 struct rssi_monitor_req *req_msg;
13104
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013105 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013106 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013107 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013108 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013109 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013110 }
13111
13112 *req_msg = *input;
13113
13114 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013115 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013116 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013117 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013118 return status;
13119 }
13120
13121 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013122 message.bodyptr = req_msg;
13123 message.type = WMA_SET_RSSI_MONITOR_REQ;
13124 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013125 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013126 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013127 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013128 }
13129 sme_release_global_lock(&mac->sme);
13130
13131 return status;
13132}
13133
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013134/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013135 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013136 * @hal: Handle returned by macOpen
13137 * @msg: PCL channel list and length structure
13138 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013139 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013140 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013141 */
Krunal Soni8a090df2018-05-03 15:02:54 -070013142QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013143{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013144 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013145 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013146 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013147 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013148 uint32_t len, i;
13149
Krunal Soni3fa80e22018-01-09 14:16:02 -080013150 if (!mac) {
13151 sme_err("mac is NULL");
13152 return QDF_STATUS_E_FAILURE;
13153 }
Krunal Soni8a090df2018-05-03 15:02:54 -070013154
13155 if (!msg) {
13156 sme_err("msg is NULL");
13157 return QDF_STATUS_E_FAILURE;
13158 }
13159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013160 len = sizeof(*req_msg);
13161
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013162 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013163 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013164 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013165 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013166 }
13167
Krunal Soni8a090df2018-05-03 15:02:54 -070013168 for (i = 0; i < msg->pcl_len; i++) {
13169 req_msg->pcl_list[i] = msg->pcl_list[i];
13170 req_msg->weight_list[i] = msg->weight_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013171 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013172
Krunal Soni8a090df2018-05-03 15:02:54 -070013173 req_msg->pcl_len = msg->pcl_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013174
13175 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013176 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013177 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013178 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013179 return status;
13180 }
13181
13182 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013183 message.bodyptr = req_msg;
13184 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13185 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013186 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013187 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013188 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013189 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013190 }
13191 sme_release_global_lock(&mac->sme);
13192
13193 return status;
13194}
13195
13196/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013197 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013198 * @hal: Handle returned by macOpen
13199 * @msg: HW mode structure containing hw mode and callback details
13200 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013201 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013202 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013203 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013204QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013205{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013206 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013207 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013208 tSmeCmd *cmd = NULL;
13209
Krunal Soni3fa80e22018-01-09 14:16:02 -080013210 if (!mac) {
13211 sme_err("mac is NULL");
13212 return QDF_STATUS_E_FAILURE;
13213 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013214 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013215 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013216 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013217 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013218 }
13219
Krunal Soni78618d92017-02-14 21:46:31 -080013220 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013221 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013222 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013223 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013224 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013225 }
13226
13227 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013228 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013229 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13230 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013231 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13232 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013233 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013234 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013235
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013236 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013237 cmd->u.set_hw_mode_cmd.session_id,
13238 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013239 csr_queue_sme_command(mac, cmd, false);
13240
13241 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013242 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013243}
13244
13245/**
13246 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13247 * @hal: Handle returned by macOpen
13248 * @callback: HDD callback to be registered
13249 *
13250 * Registers the HDD callback with SME. This callback will be invoked when
13251 * HW mode transition event is received from the FW
13252 *
13253 * Return: None
13254 */
13255void sme_register_hw_mode_trans_cb(tHalHandle hal,
13256 hw_mode_transition_cb callback)
13257{
13258 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13259
13260 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013261}
13262
13263/**
13264 * sme_nss_update_request() - Send beacon templete update to FW with new
13265 * nss value
13266 * @hal: Handle returned by macOpen
13267 * @vdev_id: the session id
13268 * @new_nss: the new nss value
13269 * @cback: hdd callback
13270 * @next_action: next action to happen at policy mgr after beacon update
13271 *
13272 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013273 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013274 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013275QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13276 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13277 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13278 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013279{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013280 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013281 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013282 tSmeCmd *cmd = NULL;
13283
Krunal Soni3fa80e22018-01-09 14:16:02 -080013284 if (!mac) {
13285 sme_err("mac is null");
13286 return status;
13287 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013288 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013289 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013290 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013291 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013292 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013293 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013294 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013295 }
13296 cmd->command = e_sme_command_nss_update;
13297 /* Sessionized modules may require this info */
13298 cmd->sessionId = vdev_id;
13299 cmd->u.nss_update_cmd.new_nss = new_nss;
13300 cmd->u.nss_update_cmd.session_id = vdev_id;
13301 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013302 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013303 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013304 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013305
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013306 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013307 csr_queue_sme_command(mac, cmd, false);
13308 sme_release_global_lock(&mac->sme);
13309 }
13310 return status;
13311}
13312
13313/**
13314 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13315 * @hal: Handle returned by macOpen
13316 * @msg: Structure containing the dual mac config parameters
13317 *
13318 * Queues configuration information to CSR to configure
13319 * WLAN firmware for the dual MAC features
13320 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013321 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013322 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013323QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013324{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013325 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013326 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013327 tSmeCmd *cmd;
13328
Krunal Soni3fa80e22018-01-09 14:16:02 -080013329 if (!mac) {
13330 sme_err("mac is null");
13331 return QDF_STATUS_E_FAILURE;
13332 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013333 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013334 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013335 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013336 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013337 }
13338
Krunal Soni78618d92017-02-14 21:46:31 -080013339 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013340 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013341 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013342 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013343 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013344 }
13345
13346 cmd->command = e_sme_command_set_dual_mac_config;
13347 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13348 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13349 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13350
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013351 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013352 cmd->u.set_dual_mac_cmd.scan_config,
13353 cmd->u.set_dual_mac_cmd.fw_mode_config);
13354 csr_queue_sme_command(mac, cmd, false);
13355
13356 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013357 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013358}
13359
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013360#ifdef FEATURE_LFR_SUBNET_DETECTION
13361/**
13362 * sme_gateway_param_update() - to update gateway parameters with WMA
13363 * @Hal: hal handle
13364 * @gw_params: request parameters from HDD
13365 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013366 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013367 *
13368 * This routine will update gateway parameters to WMA
13369 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013370QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013371 struct gateway_param_update_req *gw_params)
13372{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013373 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013374 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013375 struct gateway_param_update_req *request_buf;
13376
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013377 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013378 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013379 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013380 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013381 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013382 }
13383
13384 *request_buf = *gw_params;
13385
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013386 message.type = WMA_GW_PARAM_UPDATE_REQ;
13387 message.reserved = 0;
13388 message.bodyptr = request_buf;
13389 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013390 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013391 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013392 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013393 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013394 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013395 }
13396
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013397 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013398}
13399#endif /* FEATURE_LFR_SUBNET_DETECTION */
13400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013401/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013402 * sme_soc_set_antenna_mode() - set antenna mode
13403 * @hal: Handle returned by macOpen
13404 * @msg: Structure containing the antenna mode parameters
13405 *
13406 * Send the command to CSR to send
13407 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13408 *
13409 * Return: QDF_STATUS
13410 */
13411QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13412 struct sir_antenna_mode_param *msg)
13413{
13414 QDF_STATUS status = QDF_STATUS_SUCCESS;
13415 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13416 tSmeCmd *cmd;
13417
13418 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013419 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013420 return QDF_STATUS_E_FAILURE;
13421 }
13422
13423 status = sme_acquire_global_lock(&mac->sme);
13424 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013425 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013426 return QDF_STATUS_E_RESOURCES;
13427 }
13428
Krunal Soni78618d92017-02-14 21:46:31 -080013429 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013430 if (!cmd) {
13431 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013432 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013433 return QDF_STATUS_E_NULL_VALUE;
13434 }
13435
13436 cmd->command = e_sme_command_set_antenna_mode;
13437 cmd->u.set_antenna_mode_cmd = *msg;
13438
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013439 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013440 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13441 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13442
13443 csr_queue_sme_command(mac, cmd, false);
13444 sme_release_global_lock(&mac->sme);
13445
13446 return QDF_STATUS_SUCCESS;
13447}
13448
13449/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013450 * sme_set_peer_authorized() - call peer authorized callback
13451 * @peer_addr: peer mac address
13452 * @auth_cb: auth callback
13453 * @vdev_id: vdev id
13454 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013455 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013456 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013457QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013458 sme_peer_authorized_fp auth_cb,
13459 uint32_t vdev_id)
13460{
13461 void *wma_handle;
13462
Anurag Chouhan6d760662016-02-20 16:05:43 +053013463 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013464 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013465 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013466 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013467 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013468 }
13469
13470 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13471 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13472 1, vdev_id);
13473}
13474
13475/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013476 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013477 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013478 * @fcc_constraint: flag to enable/disable the constraint
13479 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013480 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013481 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013482 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013483QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13484 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013485{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013486 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013487 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13488
13489 status = sme_acquire_global_lock(&mac_ptr->sme);
13490
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013491 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013492
13493 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13494 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013495 if (scan_pending)
13496 mac_ptr->scan.defer_update_channel_list = true;
13497 else
13498 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013499 }
13500
13501 sme_release_global_lock(&mac_ptr->sme);
13502 }
13503
13504 return status;
13505}
13506/**
13507 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13508 * @hal: Global MAC pointer
13509 *
13510 * Return: NULL.
13511 */
13512void sme_setdef_dot11mode(tHalHandle hal)
13513{
13514 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013516 csr_set_default_dot11_mode(mac_ctx);
13517}
13518
13519/**
13520 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13521 * params
13522 * @hal_handle - The handle returned by macOpen.
13523 * @session_id - Session Identifier
13524 * @notify_id - Identifies 1 of the 4 parameters to be modified
13525 * @val New value of the parameter
13526 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013527 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013528 * Other status means SME failed to update
13529 */
13530
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013531QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013532 uint8_t session_id,
13533 uint32_t notify_id,
13534 int32_t val)
13535{
13536 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013537 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013538 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013539 tpCsrNeighborRoamControlInfo nr_info = NULL;
13540 uint32_t reason = 0;
13541
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013542 if (session_id >= CSR_ROAM_SESSION_MAX) {
13543 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13544 FL("Invalid sme session id: %d"), session_id);
13545 return QDF_STATUS_E_INVAL;
13546 }
13547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013548 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013549 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013550 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13551 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13552 switch (notify_id) {
13553 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013554 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013555 "%s: gRoamScanHirssiMaxCount %d => %d",
13556 __func__, nr_config->nhi_rssi_scan_max_count,
13557 val);
13558 nr_config->nhi_rssi_scan_max_count = val;
13559 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13560 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13561 break;
13562
13563 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013564 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013565 FL("gRoamScanHiRssiDelta %d => %d"),
13566 nr_config->nhi_rssi_scan_rssi_delta,
13567 val);
13568 nr_config->nhi_rssi_scan_rssi_delta = val;
13569 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13570 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13571 break;
13572
13573 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013574 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013575 FL("gRoamScanHiRssiDelay %d => %d"),
13576 nr_config->nhi_rssi_scan_delay,
13577 val);
13578 nr_config->nhi_rssi_scan_delay = val;
13579 nr_info->cfgParams.hi_rssi_scan_delay = val;
13580 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13581 break;
13582
13583 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013584 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013585 FL("gRoamScanHiRssiUpperBound %d => %d"),
13586 nr_config->nhi_rssi_scan_rssi_ub,
13587 val);
13588 nr_config->nhi_rssi_scan_rssi_ub = val;
13589 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13590 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13591 break;
13592
13593 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013594 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013595 FL("invalid parameter notify_id %d"),
13596 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013597 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013598 break;
13599 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053013600
13601 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
13602 status == QDF_STATUS_SUCCESS) {
13603 csr_roam_offload_scan(mac_ctx, session_id,
13604 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13605 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013606 sme_release_global_lock(&mac_ctx->sme);
13607 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013608
13609 return status;
13610}
13611
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013612/**
13613 * sme_update_tgt_services() - update the target services config.
13614 * @hal: HAL pointer.
13615 * @cfg: wma_tgt_services parameters.
13616 *
13617 * update the target services config.
13618 *
13619 * Return: None.
13620 */
13621void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13622{
13623 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13624
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013625 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013626 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013627 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013628 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013629 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013630 mac_ctx->is_fils_roaming_supported =
13631 cfg->is_fils_roaming_supported;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +053013632 mac_ctx->is_11k_offload_supported =
13633 cfg->is_11k_offload_supported;
13634 sme_debug("pmf_offload: %d fils_roam support %d 11k_offload %d",
13635 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported,
13636 mac_ctx->is_11k_offload_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013637}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013638
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013639/**
13640 * sme_is_session_id_valid() - Check if the session id is valid
13641 * @hal: Pointer to HAL
13642 * @session_id: Session id
13643 *
13644 * Checks if the session id is valid or not
13645 *
13646 * Return: True is the session id is valid, false otherwise
13647 */
13648bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
13649{
13650 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013651
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013652 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053013653 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13654 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013655 return false;
13656 }
13657
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013658 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013659 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013660
13661 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013662}
13663
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013664#ifdef FEATURE_WLAN_TDLS
13665
13666/**
13667 * sme_get_opclass() - determine operating class
13668 * @hal: Pointer to HAL
13669 * @channel: channel id
13670 * @bw_offset: bandwidth offset
13671 * @opclass: pointer to operating class
13672 *
13673 * Function will determine operating class from regdm_get_opclass_from_channel
13674 *
13675 * Return: none
13676 */
13677void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
13678 uint8_t *opclass)
13679{
13680 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13681
13682 /* redgm opclass table contains opclass for 40MHz low primary,
13683 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
13684 * first we will check if bit for 40MHz is set and if so find
13685 * matching opclass either with low primary or high primary
13686 * (a channel would never be in both) and then search for opclass
13687 * matching 20MHz, else for any BW.
13688 */
13689 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013690 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013691 mac_ctx->scan.countryCodeCurrent,
13692 channel, BW40_LOW_PRIMARY);
13693 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013694 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013695 mac_ctx->scan.countryCodeCurrent,
13696 channel, BW40_HIGH_PRIMARY);
13697 }
13698 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013699 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013700 mac_ctx->scan.countryCodeCurrent,
13701 channel, BW20);
13702 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013703 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013704 mac_ctx->scan.countryCodeCurrent,
13705 channel, BWALL);
13706 }
13707}
13708#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013709
Sandeep Puligillae0875662016-02-12 16:09:21 -080013710/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013711 * sme_set_fw_test() - set fw test
13712 * @fw_test: fw test param
13713 *
13714 * Return: Return QDF_STATUS, otherwise appropriate failure code
13715 */
13716QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
13717{
13718 void *wma_handle;
13719
13720 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13721 if (!wma_handle) {
13722 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13723 "wma handle is NULL");
13724 return QDF_STATUS_E_FAILURE;
13725 }
13726 wma_process_fw_test_cmd(wma_handle, fw_test);
13727 return QDF_STATUS_SUCCESS;
13728}
13729
13730/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080013731 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
13732 * @hal: mac handel
13733 * @vdev_id: vdev identifier
13734 *
13735 * Return: Return QDF_STATUS, otherwise appropriate failure code
13736 */
13737QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
13738{
13739 void *wma_handle;
13740
13741 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13742 if (!wma_handle) {
13743 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13744 "wma handle is NULL");
13745 return QDF_STATUS_E_FAILURE;
13746 }
13747 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
13748 return QDF_STATUS_SUCCESS;
13749}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013750
13751/**
13752 * sme_update_mimo_power_save() - Update MIMO power save
13753 * configuration
13754 * @hal: The handle returned by macOpen
13755 * @is_ht_smps_enabled: enable/disable ht smps
13756 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080013757 * @send_smps_action: flag to send smps force mode command
13758 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013759 *
13760 * Return: QDF_STATUS if SME update mimo power save
Jeff Johnson698eacd2018-05-12 17:00:03 -070013761 * configuration success else failure status
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013762 */
13763QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
13764 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080013765 uint8_t ht_smps_mode,
13766 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013767{
13768 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080013769
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013770 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080013771 is_ht_smps_enabled, ht_smps_mode,
13772 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013773 mac_ctx->roam.configParam.enableHtSmps =
13774 is_ht_smps_enabled;
13775 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080013776 mac_ctx->roam.configParam.send_smps_action =
13777 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013778
13779 return QDF_STATUS_SUCCESS;
13780}
13781
13782/**
13783 * sme_is_sta_smps_allowed() - check if the supported nss for
13784 * the session is greater than 1x1 to enable sta SMPS
13785 * @hal: The handle returned by macOpen
13786 * @session_id: session id
13787 *
13788 * Return: bool returns true if supported nss is greater than
13789 * 1x1 else false
13790 */
13791bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
13792{
13793 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013794 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013795
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013796 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13797 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013798 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053013799 return false;
13800 }
13801
13802 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013803 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013804 return false;
13805 }
13806
13807 return (csr_session->supported_nss_1x1 == true) ? false : true;
13808}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013809
13810/**
13811 * sme_add_beacon_filter() - set the beacon filter configuration
13812 * @hal: The handle returned by macOpen
13813 * @session_id: session id
13814 * @ie_map: bitwise array of IEs
13815 *
13816 * Return: Return QDF_STATUS, otherwise appropriate failure code
13817 */
13818QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
13819 uint32_t session_id,
13820 uint32_t *ie_map)
13821{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013822 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013823 QDF_STATUS qdf_status;
13824 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13825 struct beacon_filter_param *filter_param;
13826
13827 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013828 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013829 return QDF_STATUS_E_FAILURE;
13830 }
13831
13832 filter_param = qdf_mem_malloc(sizeof(*filter_param));
13833 if (NULL == filter_param) {
13834 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13835 "%s: fail to alloc filter_param", __func__);
13836 return QDF_STATUS_E_FAILURE;
13837 }
13838
13839 filter_param->vdev_id = session_id;
13840
13841 qdf_mem_copy(filter_param->ie_map, ie_map,
13842 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
13843
13844 message.type = WMA_ADD_BCN_FILTER_CMDID;
13845 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013846 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013847 &message);
13848 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
13849 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13850 "%s: Not able to post msg to WDA!",
13851 __func__);
13852
13853 qdf_mem_free(filter_param);
13854 }
13855 return qdf_status;
13856}
13857
13858/**
13859 * sme_remove_beacon_filter() - set the beacon filter configuration
13860 * @hal: The handle returned by macOpen
13861 * @session_id: session id
13862 *
13863 * Return: Return QDF_STATUS, otherwise appropriate failure code
13864 */
13865QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
13866{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013867 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013868 QDF_STATUS qdf_status;
13869 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13870 struct beacon_filter_param *filter_param;
13871
13872 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013873 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013874 return QDF_STATUS_E_FAILURE;
13875 }
13876
13877 filter_param = qdf_mem_malloc(sizeof(*filter_param));
13878 if (NULL == filter_param) {
13879 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13880 "%s: fail to alloc filter_param", __func__);
13881 return QDF_STATUS_E_FAILURE;
13882 }
13883
13884 filter_param->vdev_id = session_id;
13885
13886 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
13887 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013888 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013889 &message);
13890 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
13891 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13892 "%s: Not able to post msg to WDA!",
13893 __func__);
13894
13895 qdf_mem_free(filter_param);
13896 }
13897 return qdf_status;
13898}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053013899
Arun Khandavalli2476ef52016-04-26 20:19:43 +053013900/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053013901 * sme_send_disassoc_req_frame - send disassoc req
13902 * @hal: handler to hal
13903 * @session_id: session id
13904 * @peer_mac: peer mac address
13905 * @reason: reason for disassociation
13906 * wait_for_ack: wait for acknowledgment
13907 *
13908 * function to send disassoc request to lim
13909 *
13910 * return: none
13911 */
13912void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
13913 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
13914{
13915 struct sme_send_disassoc_frm_req *msg;
13916 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
13917 A_UINT8 *buf;
13918 A_UINT16 tmp;
13919
13920 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
13921
13922 if (NULL == msg)
13923 qdf_status = QDF_STATUS_E_FAILURE;
13924 else
13925 qdf_status = QDF_STATUS_SUCCESS;
13926
13927 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
13928 return;
13929
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053013930 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
13931
13932 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
13933
13934 buf = &msg->session_id;
13935
13936 /* session id */
13937 *buf = (A_UINT8) session_id;
13938 buf += sizeof(A_UINT8);
13939
13940 /* transaction id */
13941 *buf = 0;
13942 *(buf + 1) = 0;
13943 buf += sizeof(A_UINT16);
13944
13945 /* Set the peer MAC address before sending the message to LIM */
13946 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
13947
13948 buf += QDF_MAC_ADDR_SIZE;
13949
13950 /* reasoncode */
13951 tmp = (uint16_t) reason;
13952 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
13953 buf += sizeof(uint16_t);
13954
13955 *buf = wait_for_ack;
13956 buf += sizeof(uint8_t);
13957
Rajeev Kumard138ac52017-01-30 18:38:37 -080013958 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053013959
13960 if (qdf_status != QDF_STATUS_SUCCESS)
13961 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13962 FL("cds_send_mb_message Failed"));
13963}
13964
Nachiket Kukade177b5b02018-05-22 20:52:17 +053013965#ifdef FEATURE_WLAN_APF
13966QDF_STATUS sme_get_apf_capabilities(tHalHandle hal,
13967 apf_get_offload_cb callback,
13968 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053013969{
13970 QDF_STATUS status = QDF_STATUS_SUCCESS;
13971 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013972 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053013973
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013974 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053013975
13976 status = sme_acquire_global_lock(&mac_ctx->sme);
13977 if (QDF_STATUS_SUCCESS == status) {
13978 /* Serialize the req through MC thread */
Nachiket Kukadee547a482018-05-22 16:43:30 +053013979 mac_ctx->sme.apf_get_offload_cb = callback;
13980 mac_ctx->sme.apf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053013981 cds_msg.bodyptr = NULL;
Nachiket Kukadee547a482018-05-22 16:43:30 +053013982 cds_msg.type = WDA_APF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013983 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053013984 if (!QDF_IS_STATUS_SUCCESS(status)) {
13985 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nachiket Kukadee547a482018-05-22 16:43:30 +053013986 FL("Post apf get offload msg fail"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053013987 status = QDF_STATUS_E_FAILURE;
13988 }
13989 sme_release_global_lock(&mac_ctx->sme);
13990 } else {
13991 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13992 FL("sme_acquire_global_lock error"));
13993 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013994 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053013995 return status;
13996}
13997
Nachiket Kukadee547a482018-05-22 16:43:30 +053013998QDF_STATUS sme_set_apf_instructions(tHalHandle hal,
13999 struct sir_apf_set_offload *req)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014000{
14001 QDF_STATUS status = QDF_STATUS_SUCCESS;
14002 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014003 struct scheduler_msg cds_msg = {0};
Nachiket Kukadee547a482018-05-22 16:43:30 +053014004 struct sir_apf_set_offload *set_offload;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014005
Arun Khandavallica198b52016-04-26 20:53:35 +053014006 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14007 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014008
14009 if (NULL == set_offload) {
14010 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14011 FL("Failed to alloc set_offload"));
14012 return QDF_STATUS_E_NOMEM;
14013 }
14014
14015 set_offload->session_id = req->session_id;
14016 set_offload->filter_id = req->filter_id;
14017 set_offload->current_offset = req->current_offset;
14018 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014019 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014020 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014021 set_offload->program = ((uint8_t *)set_offload) +
14022 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014023 qdf_mem_copy(set_offload->program, req->program,
14024 set_offload->current_length);
14025 }
14026 status = sme_acquire_global_lock(&mac_ctx->sme);
14027 if (QDF_STATUS_SUCCESS == status) {
14028 /* Serialize the req through MC thread */
14029 cds_msg.bodyptr = set_offload;
Nachiket Kukadee547a482018-05-22 16:43:30 +053014030 cds_msg.type = WDA_APF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014031 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014032
14033 if (!QDF_IS_STATUS_SUCCESS(status)) {
14034 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nachiket Kukadee547a482018-05-22 16:43:30 +053014035 FL("Post APF set offload msg fail"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014036 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014037 qdf_mem_free(set_offload);
14038 }
14039 sme_release_global_lock(&mac_ctx->sme);
14040 } else {
14041 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14042 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014043 qdf_mem_free(set_offload);
14044 }
14045 return status;
14046}
14047
Nachiket Kukade177b5b02018-05-22 20:52:17 +053014048QDF_STATUS sme_set_apf_enable_disable(tHalHandle hal, uint8_t vdev_id,
14049 bool apf_enable)
14050{
14051 void *wma_handle;
14052
14053 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14054 if (!wma_handle) {
14055 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14056 "wma handle is NULL");
14057 return QDF_STATUS_E_FAILURE;
14058 }
14059
14060 return wma_send_apf_enable_cmd(wma_handle, vdev_id, apf_enable);
14061}
14062
14063QDF_STATUS
14064sme_apf_write_work_memory(tHalHandle hal,
14065 struct wmi_apf_write_memory_params *write_params)
14066{
14067 void *wma_handle;
14068
14069 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14070 if (!wma_handle) {
14071 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14072 "wma handle is NULL");
14073 return QDF_STATUS_E_FAILURE;
14074 }
14075
14076 return wma_send_apf_write_work_memory_cmd(wma_handle, write_params);
14077}
14078
14079QDF_STATUS
14080sme_apf_read_work_memory(tHalHandle hal,
14081 struct wmi_apf_read_memory_params *read_params,
14082 apf_read_mem_cb callback)
14083{
14084 QDF_STATUS status = QDF_STATUS_SUCCESS;
14085 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14086 void *wma_handle;
14087
14088 status = sme_acquire_global_lock(&mac->sme);
14089 if (QDF_IS_STATUS_SUCCESS(status)) {
14090 mac->sme.apf_read_mem_cb = callback;
14091 sme_release_global_lock(&mac->sme);
14092 } else {
14093 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14094 FL("sme_acquire_global_lock failed"));
14095 }
14096
14097 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14098 if (!wma_handle) {
14099 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14100 "wma handle is NULL");
14101 return QDF_STATUS_E_FAILURE;
14102 }
14103
14104 return wma_send_apf_read_work_memory_cmd(wma_handle, read_params);
14105}
14106#endif /* FEATURE_WLAN_APF */
14107
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014108/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014109 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14110 * @hal: hal pointer
14111 *
14112 * Return: wni dot11 mode.
14113 */
14114uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14115{
14116 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14117
14118 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14119 mac_ctx->roam.configParam.uCfgDot11Mode);
14120}
14121
14122/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014123 * sme_create_mon_session() - post message to create PE session for monitormode
14124 * operation
14125 * @hal_handle: Handle to the HAL
14126 * @bssid: pointer to bssid
14127 *
14128 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14129 */
14130QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14131{
14132 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14133 struct sir_create_session *msg;
14134
14135 msg = qdf_mem_malloc(sizeof(*msg));
14136 if (NULL != msg) {
14137 msg->type = eWNI_SME_MON_INIT_SESSION;
14138 msg->msg_len = sizeof(*msg);
14139 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014140 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014141 }
14142 return status;
14143}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014144
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014145void sme_set_chan_info_callback(tHalHandle hal_handle,
14146 void (*callback)(struct scan_chan_info *chan_info))
14147{
14148 tpAniSirGlobal mac;
14149
14150 if (hal_handle == NULL) {
14151 QDF_ASSERT(0);
14152 return;
14153 }
14154 mac = PMAC_STRUCT(hal_handle);
14155 mac->chan_info_cb = callback;
14156}
14157
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014158/**
14159 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14160 * @hal: The handle returned by macOpen
14161 * @params: adaptive_dwelltime_params config
14162 *
14163 * Return: QDF_STATUS if adaptive dwell time update
Jeff Johnson698eacd2018-05-12 17:00:03 -070014164 * configuration success else failure status
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014165 */
14166QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14167 struct adaptive_dwelltime_params *params)
14168{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014169 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014170 QDF_STATUS status;
14171 struct adaptive_dwelltime_params *dwelltime_params;
14172
14173 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14174 if (NULL == dwelltime_params) {
14175 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14176 "%s: fail to alloc dwelltime_params", __func__);
14177 return QDF_STATUS_E_NOMEM;
14178 }
14179
14180 dwelltime_params->is_enabled = params->is_enabled;
14181 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14182 dwelltime_params->lpf_weight = params->lpf_weight;
14183 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14184 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14185
14186 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14187 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014188 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014189 if (!QDF_IS_STATUS_SUCCESS(status)) {
14190 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14191 "%s: Not able to post msg to WMA!", __func__);
14192
14193 qdf_mem_free(dwelltime_params);
14194 }
14195 return status;
14196}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014197
14198/**
14199 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14200 * @hal: Pointer to HAL
14201 * @vdev_id: vdev_id for which IE is targeted
14202 *
14203 * Return: None
14204 */
14205void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14206{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014207 struct sir_set_vdev_ies_per_band *p_msg;
14208 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14209
14210 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14211 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014212 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014213 return;
14214 }
14215
14216 p_msg->vdev_id = vdev_id;
14217 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14218 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014219 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014220 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014221 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014222 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014223 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014224}
14225
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014226/**
14227 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14228 * @hal: Pointer to HAL
14229 * @enable2x2: 1x1 or 2x2 mode.
14230 *
14231 * Sends the set pdev IE req with Nss value.
14232 *
14233 * Return: None
14234 */
14235void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14236{
14237 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14238 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14239 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14240
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014241 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14242 eCSR_CFG_DOT11_MODE_AUTO) ||
14243 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14244 eCSR_CFG_DOT11_MODE_11N) ||
14245 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14246 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14247 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14248 eCSR_CFG_DOT11_MODE_11AC) ||
14249 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14250 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14251 return;
14252
14253 status = sme_acquire_global_lock(&mac_ctx->sme);
14254 if (QDF_STATUS_SUCCESS == status) {
14255 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14256 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014257 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014258 sme_release_global_lock(&mac_ctx->sme);
14259 return;
14260 }
14261
14262 ht_vht_cfg->pdev_id = 0;
14263 if (enable2x2)
14264 ht_vht_cfg->nss = 2;
14265 else
14266 ht_vht_cfg->nss = 1;
14267 ht_vht_cfg->dot11mode =
14268 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14269 mac_ctx->roam.configParam.uCfgDot11Mode);
14270
14271 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14272 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014273 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14274 ht_vht_cfg->nss,
14275 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014276 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014277 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014278 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014279
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014280 sme_release_global_lock(&mac_ctx->sme);
14281 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014282}
14283
14284/**
14285 * sme_update_vdev_type_nss() - sets the nss per vdev type
14286 * @hal: Pointer to HAL
14287 * @max_supp_nss: max_supported Nss
14288 * @band: 5G or 2.4G band
14289 *
14290 * Sets the per band Nss for each vdev type based on INI and configured
14291 * chain mask value.
14292 *
14293 * Return: None
14294 */
14295void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014296 uint32_t vdev_type_nss, enum band_info band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014297{
14298 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14299 struct vdev_type_nss *vdev_nss;
14300
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014301 if (BAND_5G == band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014302 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14303 else
14304 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14305
14306 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14307 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14308 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14309 CFG_P2P_GO_NSS(vdev_type_nss));
14310 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14311 CFG_P2P_CLI_NSS(vdev_type_nss));
14312 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14313 CFG_P2P_DEV_NSS(vdev_type_nss));
14314 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14315 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14316 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14317
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014318 sme_debug("band %d NSS:sta %d sap %d cli %d go %d dev %d ibss %d tdls %d ocb %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014319 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14320 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14321 vdev_nss->tdls, vdev_nss->ocb);
14322}
Peng Xu8fdaa492016-06-22 10:20:47 -070014323
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014324#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14325#define MAX_BSS_COLOR_VAL 63
14326#define MIN_BSS_COLOR_VAL 1
14327
14328QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14329 uint8_t bss_color)
14330
14331{
14332 struct sir_set_he_bss_color *bss_color_msg;
14333 uint8_t len;
14334
14335 if (!hal) {
14336 sme_err("Invalid hal pointer");
14337 return QDF_STATUS_E_FAULT;
14338 }
14339
14340 sme_debug("Set HE bss_color %d", bss_color);
14341
14342 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14343 sme_debug("Invalid HE bss_color %d", bss_color);
14344 return QDF_STATUS_E_INVAL;
14345 }
14346 len = sizeof(*bss_color_msg);
14347 bss_color_msg = qdf_mem_malloc(len);
14348 if (!bss_color_msg) {
14349 sme_err("mem alloc failed");
14350 return QDF_STATUS_E_NOMEM;
14351 }
14352 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14353 bss_color_msg->length = len;
14354 bss_color_msg->session_id = session_id;
14355 bss_color_msg->bss_color = bss_color;
14356 return umac_send_mb_message_to_mac(bss_color_msg);
14357}
14358#endif
14359
Peng Xu8fdaa492016-06-22 10:20:47 -070014360/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014361 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14362 * @hal: Pointer to HAL
14363 * @hw_dbs_capable: HW DBS capability
14364 *
14365 * Sets HW DBS capability based on INI and fw capability.
14366 *
14367 * Return: None
14368 */
14369void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14370{
14371 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014372
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014373 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14374}
14375
14376/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014377 * sme_register_p2p_lo_event() - Register for the p2p lo event
14378 * @hHal: reference to the HAL
14379 * @context: the context of the call
14380 * @callback: the callback to hdd
14381 *
14382 * This function registers the callback function for P2P listen
14383 * offload stop event.
14384 *
14385 * Return: none
14386 */
14387void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14388 p2p_lo_callback callback)
14389{
14390 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14391 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14392
14393 status = sme_acquire_global_lock(&pMac->sme);
14394 pMac->sme.p2p_lo_event_callback = callback;
14395 pMac->sme.p2p_lo_event_context = context;
14396 sme_release_global_lock(&pMac->sme);
14397}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014398
14399/**
14400 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14401 * @hal: The handle returned by macOpen
14402 * @session_id: session id
14403 * @dbg_args: args for mac pwr debug command
14404 * Return: Return QDF_STATUS, otherwise appropriate failure code
14405 */
14406QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14407 struct sir_mac_pwr_dbg_cmd*
14408 dbg_args)
14409{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014410 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014411 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14412 struct sir_mac_pwr_dbg_cmd *req;
14413 int i;
14414
14415 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014416 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014417 return QDF_STATUS_E_FAILURE;
14418 }
14419
14420 req = qdf_mem_malloc(sizeof(*req));
14421 if (NULL == req) {
14422 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14423 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14424 return QDF_STATUS_E_FAILURE;
14425 }
14426 req->module_id = dbg_args->module_id;
14427 req->pdev_id = dbg_args->pdev_id;
14428 req->num_args = dbg_args->num_args;
14429 for (i = 0; i < req->num_args; i++)
14430 req->args[i] = dbg_args->args[i];
14431
14432 message.type = SIR_HAL_POWER_DBG_CMD;
14433 message.bodyptr = req;
14434
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014435 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053014436 (QDF_MODULE_ID_WMA, &message))) {
14437 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14438 "%s: Not able to post msg to WDA!",
14439 __func__);
14440 qdf_mem_free(req);
14441 }
14442 return QDF_STATUS_SUCCESS;
14443}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014444/**
14445 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014446 * @dev_mode: connection type.
14447 * @nss2g: Pointer to the 2G Nss parameter.
14448 * @nss5g: Pointer to the 5G Nss parameter.
14449 *
14450 * Fills the 2G and 5G Nss values based on connection type.
14451 *
14452 * Return: None
14453 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014454void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14455 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014456{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014457 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14458
14459 if (NULL == mac_ctx) {
14460 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14461 FL("Invalid MAC context"));
14462 return;
14463 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014464 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14465}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014466
14467/**
14468 * sme_update_sta_roam_policy() - update sta roam policy for
14469 * unsafe and DFS channels.
14470 * @hal_handle: hal handle for getting global mac struct
14471 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14472 * skipped or not
14473 * @skip_unsafe_channels: Param to tell if driver needs to
14474 * skip unsafe channels or not.
14475 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014476 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014477 *
14478 * sme_update_sta_roam_policy update sta rome policies to csr
14479 * this function will call csrUpdateChannelList as well
14480 * to include/exclude DFS channels and unsafe channels.
14481 *
14482 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14483 */
14484QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14485 enum sta_roam_policy_dfs_mode dfs_mode,
14486 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014487 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014488{
14489 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14490 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014491 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014492
14493 if (!mac_ctx) {
14494 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14495 "%s: mac_ctx is null", __func__);
14496 return QDF_STATUS_E_FAILURE;
14497 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014498
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014499 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14500 if (!sme_config) {
14501 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14502 FL("failed to allocate memory for sme_config"));
14503 return QDF_STATUS_E_FAILURE;
14504 }
14505 qdf_mem_zero(sme_config, sizeof(*sme_config));
14506 sme_get_config_param(hal_handle, sme_config);
14507
14508 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014509 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014510 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014511 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014512 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014513 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014514
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014515 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014516
14517 status = csr_update_channel_list(mac_ctx);
14518 if (QDF_STATUS_SUCCESS != status) {
14519 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14520 FL("failed to update the supported channel list"));
14521 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053014522
14523 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled) {
14524 status = sme_acquire_global_lock(&mac_ctx->sme);
14525 if (QDF_IS_STATUS_SUCCESS(status)) {
14526 csr_roam_offload_scan(mac_ctx, session_id,
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014527 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14528 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053014529 sme_release_global_lock(&mac_ctx->sme);
14530 } else {
14531 sme_err("Failed to acquire SME lock");
14532 }
14533 }
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014534 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014535 return status;
14536}
14537
14538/**
14539 * sme_enable_disable_chanavoidind_event - configure ca event ind
14540 * @hal: handler to hal
14541 * @set_value: enable/disable
14542 *
14543 * function to enable/disable chan avoidance indication
14544 *
14545 * Return: QDF_STATUS
14546 */
14547QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14548 uint8_t set_value)
14549{
14550 QDF_STATUS status;
14551 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014552 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014553
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014554 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014555 status = sme_acquire_global_lock(&mac_ctx->sme);
14556 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014557 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014558 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14559 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014560 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014561 sme_release_global_lock(&mac_ctx->sme);
14562 return status;
14563 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014564 return status;
14565}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014566
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014567/*
14568 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14569 * @hal: reference to the HAL
14570 * @session_id: current session ID
14571 * @ie_data: Pointer to Scan IE data
14572 * @ie_len: Length of @ie_data
14573 *
14574 * Return: QDF_STATUS
14575 */
14576QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14577 uint8_t *ie_data, uint16_t ie_len)
14578{
14579 QDF_STATUS status;
14580 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14581 struct hdd_default_scan_ie *set_ie_params;
14582
Rajeev Kumar5d17dd52017-12-19 16:17:42 -080014583 if (!ie_data)
14584 return QDF_STATUS_E_INVAL;
14585
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014586 status = sme_acquire_global_lock(&mac_ctx->sme);
14587 if (QDF_IS_STATUS_SUCCESS(status)) {
14588 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14589 if (!set_ie_params)
14590 status = QDF_STATUS_E_NOMEM;
14591 else {
14592 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14593 set_ie_params->length = sizeof(*set_ie_params);
14594 set_ie_params->session_id = session_id;
14595 set_ie_params->ie_len = ie_len;
14596 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014597 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014598 }
14599 sme_release_global_lock(&mac_ctx->sme);
14600 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014601 return status;
14602}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014603
Jeff Johnsonf0e54b02017-12-18 15:22:25 -080014604QDF_STATUS sme_get_sar_power_limits(tHalHandle hal,
14605 wma_sar_cb callback, void *context)
14606{
14607 void *wma_handle;
14608
14609 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14610 if (!wma_handle) {
14611 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14612 "wma handle is NULL");
14613 return QDF_STATUS_E_FAILURE;
14614 }
14615
14616 return wma_get_sar_limit(wma_handle, callback, context);
14617}
14618
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014619QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14620 struct sar_limit_cmd_params *sar_limit_cmd)
14621{
14622 void *wma_handle;
14623
14624 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14625 if (!wma_handle) {
14626 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14627 "wma handle is NULL");
14628 return QDF_STATUS_E_FAILURE;
14629 }
14630
14631 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14632}
14633
Jeff Johnson6136fb92017-03-30 15:21:49 -070014634#ifdef WLAN_FEATURE_FIPS
14635QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14636 wma_fips_cb callback, void *context)
14637{
14638 void *wma_handle;
14639
14640 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14641 if (!wma_handle) {
14642 sme_err("wma handle is NULL");
14643 return QDF_STATUS_E_FAILURE;
14644 }
14645
14646 return wma_fips_request(wma_handle, param, callback, context);
14647}
14648#endif
14649
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014650QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14651{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014652 void *wma_handle;
14653
14654 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14655 if (!wma_handle) {
14656 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14657 "wma_handle is NULL");
14658 return QDF_STATUS_E_FAILURE;
14659 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014660 if (QDF_STATUS_SUCCESS !=
14661 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14662 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14663 "%s: Failed to set cts2self for p2p GO to firmware",
14664 __func__);
14665 return QDF_STATUS_E_FAILURE;
14666 }
14667 return QDF_STATUS_SUCCESS;
14668}
Yingying Tang95409972016-10-20 15:16:15 +080014669
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014670/**
14671 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14672 * @hal: Handle returned by mac_open
14673 * @session_id: Session ID on which tx fail count needs to be updated to FW
14674 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14675 *
14676 * This function is used to set tx fail count threshold to firmware.
14677 * firmware will issue disocnnect with peer device once this threshold is
14678 * reached.
14679 *
14680 * Return: Return QDF_STATUS, otherwise appropriate failure code
14681 */
14682QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14683 uint8_t session_id, uint32_t tx_fail_count)
14684{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014685 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14686 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014687 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014688
14689 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14690 if (NULL == tx_fail_cnt) {
14691 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14692 "%s: fail to alloc filter_param", __func__);
14693 return QDF_STATUS_E_FAILURE;
14694 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014695 sme_debug("session_id: %d tx_fail_count: %d",
14696 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014697 tx_fail_cnt->session_id = session_id;
14698 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
14699
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014700 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014701 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
14702 msg.reserved = 0;
14703 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014704 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014705
14706 if (!QDF_IS_STATUS_SUCCESS(status)) {
14707 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014708 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014709 qdf_mem_free(tx_fail_cnt);
14710 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014711 return status;
14712}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014713
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014714QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
14715 void (*cb)(void *, struct sir_lost_link_info *))
14716{
14717 QDF_STATUS status = QDF_STATUS_SUCCESS;
14718 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14719
14720 status = sme_acquire_global_lock(&mac->sme);
14721 if (QDF_IS_STATUS_SUCCESS(status)) {
14722 mac->sme.lost_link_info_cb = cb;
14723 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014724 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014725 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014726 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014727
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014728 return status;
14729}
Yingying Tang95409972016-10-20 15:16:15 +080014730
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014731#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080014732bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014733{
14734 return roam_info->isESEAssoc;
14735}
Manjeet Singh2f785062017-03-08 18:14:18 +053014736#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053014737/**
Manjeet Singh2f785062017-03-08 18:14:18 +053014738 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053014739 * params from ini.
14740 * @hal_handle: Handle returned by mac_open
14741 * @5g_pref_params: pref params from ini.
14742 *
14743 * Returns: None
14744 */
14745void sme_set_5g_band_pref(tHalHandle hal_handle,
14746 struct sme_5g_band_pref_params *pref_params)
14747{
14748
14749 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14750 struct roam_ext_params *roam_params;
14751 QDF_STATUS status = QDF_STATUS_SUCCESS;
14752
14753 if (!pref_params) {
14754 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14755 "Invalid 5G pref params!");
14756 return;
14757 }
14758 status = sme_acquire_global_lock(&mac_ctx->sme);
14759 if (QDF_STATUS_SUCCESS == status) {
14760 roam_params = &mac_ctx->roam.configParam.roam_params;
14761 roam_params->raise_rssi_thresh_5g =
14762 pref_params->rssi_boost_threshold_5g;
14763 roam_params->raise_factor_5g =
14764 pref_params->rssi_boost_factor_5g;
14765 roam_params->max_raise_rssi_5g =
14766 pref_params->max_rssi_boost_5g;
14767 roam_params->drop_rssi_thresh_5g =
14768 pref_params->rssi_penalize_threshold_5g;
14769 roam_params->drop_factor_5g =
14770 pref_params->rssi_penalize_factor_5g;
14771 roam_params->max_drop_rssi_5g =
14772 pref_params->max_rssi_penalize_5g;
14773
14774 sme_release_global_lock(&mac_ctx->sme);
14775 } else
14776 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14777 "Unable to acquire global sme lock");
14778}
14779
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014780
14781bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
14782{
14783 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014784
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014785 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
14786}
Yingying Tang95409972016-10-20 15:16:15 +080014787
14788#ifdef WLAN_FEATURE_WOW_PULSE
14789/**
14790 * sme_set_wow_pulse() - set wow pulse info
14791 * @wow_pulse_set_info: wow_pulse_mode structure pointer
14792 *
14793 * Return: QDF_STATUS
14794 */
14795QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
14796{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014797 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080014798 QDF_STATUS status;
14799 struct wow_pulse_mode *wow_pulse_set_cmd;
14800
14801 if (!wow_pulse_set_info) {
14802 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14803 "%s: invalid wow_pulse_set_info pointer", __func__);
14804 return QDF_STATUS_E_FAILURE;
14805 }
14806
14807 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
14808 if (NULL == wow_pulse_set_cmd) {
14809 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14810 "%s: fail to alloc wow_pulse_set_cmd", __func__);
14811 return QDF_STATUS_E_NOMEM;
14812 }
14813
14814 *wow_pulse_set_cmd = *wow_pulse_set_info;
14815
14816 message.type = WMA_SET_WOW_PULSE_CMD;
14817 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014818 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080014819 &message);
14820 if (!QDF_IS_STATUS_SUCCESS(status)) {
14821 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14822 "%s: Not able to post msg to WDA!",
14823 __func__);
14824 qdf_mem_free(wow_pulse_set_cmd);
14825 status = QDF_STATUS_E_FAILURE;
14826 }
14827
14828 return status;
14829}
14830#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014831
14832/**
14833 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
14834 * different fields and IEs from bss descriptor.
14835 * @frame_buf: frame buffer to populate
14836 * @bss_descp: bss descriptor
14837 * @bssid: bssid of the beacon frame to populate
14838 * @ie_len: length of IE fields
14839 *
14840 * Return: None
14841 */
14842static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
14843 tSirBssDescription *bss_descp,
14844 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080014845 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014846{
14847 tDot11fBeacon1 *bcn_fixed;
14848 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
14849
14850 /* populate mac header first to indicate beacon */
14851 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14852 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
14853 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
14854 qdf_mem_copy((uint8_t *) mac_hdr->da,
14855 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
14856 sizeof(struct qdf_mac_addr));
14857 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
14858 sizeof(struct qdf_mac_addr));
14859 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
14860 sizeof(struct qdf_mac_addr));
14861
14862 /* now populate fixed params */
14863 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
14864 /* populate timestamp */
14865 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
14866 sizeof(bss_descp->timeStamp));
14867 /* populate beacon interval */
14868 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
14869 /* populate capability */
14870 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
14871 sizeof(bss_descp->capabilityInfo));
14872
14873 /* copy IEs now */
14874 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
14875 + SIR_MAC_B_PR_SSID_OFFSET,
14876 &bss_descp->ieFields, ie_len);
14877}
14878
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053014879QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014880 struct csr_roam_profile *profile,
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053014881 const uint8_t *bssid,
14882 int8_t *rssi, int8_t *snr)
14883{
14884 tSirBssDescription *bss_descp;
14885 tCsrScanResultFilter *scan_filter;
14886 struct scan_result_list *bss_list;
14887 tScanResultHandle result_handle = NULL;
14888 QDF_STATUS status = QDF_STATUS_SUCCESS;
14889 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14890
14891 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
14892 if (NULL == scan_filter) {
14893 sme_err("memory allocation failed");
14894 status = QDF_STATUS_E_NOMEM;
14895 goto free_scan_flter;
14896 }
14897
14898 status = csr_roam_prepare_filter_from_profile(mac_ctx,
14899 profile, scan_filter);
14900 if (QDF_STATUS_SUCCESS != status) {
14901 sme_err("prepare_filter failed");
14902 goto free_scan_flter;
14903 }
14904
14905 /* update filter to get scan result with just target BSSID */
14906 if (NULL == scan_filter->BSSIDs.bssid) {
14907 scan_filter->BSSIDs.bssid =
14908 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
14909 if (scan_filter->BSSIDs.bssid == NULL) {
14910 sme_err("malloc failed");
14911 status = QDF_STATUS_E_NOMEM;
14912 goto free_scan_flter;
14913 }
14914 }
14915
14916 scan_filter->BSSIDs.numOfBSSIDs = 1;
14917 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
14918 bssid, sizeof(struct qdf_mac_addr));
14919
14920 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
14921 if (QDF_STATUS_SUCCESS != status) {
14922 sme_err("parse_scan_result failed");
14923 goto free_scan_flter;
14924 }
14925
14926 bss_list = (struct scan_result_list *)result_handle;
14927 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
14928 if (!bss_descp) {
14929 sme_err("unable to fetch bss descriptor");
14930 status = QDF_STATUS_E_FAULT;
14931 goto free_scan_flter;
14932 }
14933
14934 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
14935 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
14936
14937 if (rssi)
14938 *rssi = bss_descp->rssi;
14939 if (snr)
14940 *snr = bss_descp->sinr;
14941
14942free_scan_flter:
14943 /* free scan filter and exit */
14944 if (scan_filter) {
14945 csr_free_scan_filter(mac_ctx, scan_filter);
14946 qdf_mem_free(scan_filter);
14947 }
14948
14949 if (result_handle)
14950 csr_scan_result_purge(mac_ctx, result_handle);
14951
14952 return status;
14953}
14954
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014955QDF_STATUS sme_get_beacon_frm(tHalHandle hal, struct csr_roam_profile *profile,
14956 const tSirMacAddr bssid,
14957 uint8_t **frame_buf, uint32_t *frame_len,
14958 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014959{
14960 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080014961 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014962 tCsrScanResultFilter *scan_filter;
14963 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14964 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053014965 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014966 uint32_t ie_len;
14967
14968 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
14969 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014970 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014971 status = QDF_STATUS_E_NOMEM;
14972 goto free_scan_flter;
14973 }
14974 status = csr_roam_prepare_filter_from_profile(mac_ctx,
14975 profile, scan_filter);
14976 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014977 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053014978 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014979 goto free_scan_flter;
14980 }
14981
14982 /* update filter to get scan result with just target BSSID */
14983 if (NULL == scan_filter->BSSIDs.bssid) {
14984 scan_filter->BSSIDs.bssid =
14985 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
14986 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014987 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014988 status = QDF_STATUS_E_NOMEM;
14989 goto free_scan_flter;
14990 }
14991 }
14992 scan_filter->BSSIDs.numOfBSSIDs = 1;
14993 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
14994 bssid, sizeof(struct qdf_mac_addr));
14995
14996 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
14997 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014998 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053014999 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015000 goto free_scan_flter;
15001 }
15002
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015003 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015004 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015005 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015006 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015007 status = QDF_STATUS_E_FAULT;
15008 goto free_scan_flter;
15009 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015010
Naveen Rawat81f058c2017-06-02 16:02:39 -070015011 /**
15012 * Length of BSS descriptor is without length of
15013 * length itself and length of pointer that holds ieFields.
15014 *
15015 * tSirBssDescription
15016 * +--------+---------------------------------+---------------+
15017 * | length | other fields | pointer to IEs|
15018 * +--------+---------------------------------+---------------+
15019 * ^
15020 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015021 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015022 ie_len = bss_descp->length + sizeof(bss_descp->length)
15023 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015024 sme_debug("found bss_descriptor ie_len: %d channel %d",
15025 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015026
15027 /* include mac header and fixed params along with IEs in frame */
15028 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15029 *frame_buf = qdf_mem_malloc(*frame_len);
15030 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015031 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015032 status = QDF_STATUS_E_NOMEM;
15033 goto free_scan_flter;
15034 }
15035
15036 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15037
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015038 if (!*channel)
15039 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015040free_scan_flter:
15041 /* free scan filter and exit */
15042 if (scan_filter) {
15043 csr_free_scan_filter(mac_ctx, scan_filter);
15044 qdf_mem_free(scan_filter);
15045 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015046 if (result_handle)
15047 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015048
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015049 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015050}
15051
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015052#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015053QDF_STATUS sme_fast_reassoc(tHalHandle hal, struct csr_roam_profile *profile,
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015054 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015055 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015056{
15057 QDF_STATUS status;
15058 struct wma_roam_invoke_cmd *fastreassoc;
15059 struct scheduler_msg msg = {0};
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015060 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015061
15062 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15063 if (NULL == fastreassoc) {
15064 sme_err("qdf_mem_malloc failed for fastreassoc");
15065 return QDF_STATUS_E_NOMEM;
15066 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015067 /* if both are same then set the flag */
15068 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15069 fastreassoc->is_same_bssid = true;
15070 sme_debug("bssid same, bssid[%pM]", bssid);
15071 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015072 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015073 fastreassoc->bssid[0] = bssid[0];
15074 fastreassoc->bssid[1] = bssid[1];
15075 fastreassoc->bssid[2] = bssid[2];
15076 fastreassoc->bssid[3] = bssid[3];
15077 fastreassoc->bssid[4] = bssid[4];
15078 fastreassoc->bssid[5] = bssid[5];
15079
15080 status = sme_get_beacon_frm(hal, profile, bssid,
15081 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015082 &fastreassoc->frame_len,
15083 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015084
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015085 if (!channel) {
15086 sme_err("channel retrieval from BSS desc fails!");
15087 qdf_mem_free(fastreassoc);
15088 return QDF_STATUS_E_FAULT;
15089 }
15090
15091 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015092 if (QDF_STATUS_SUCCESS != status) {
15093 sme_warn("sme_get_beacon_frm failed");
15094 fastreassoc->frame_buf = NULL;
15095 fastreassoc->frame_len = 0;
15096 }
15097
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015098 if (csr_is_auth_type_ese(mac_ctx->roam.roamSession[vdev_id].
15099 connectedProfile.AuthType)) {
15100 sme_debug("Beacon is not required for ESE");
15101 if (fastreassoc->frame_len) {
15102 qdf_mem_free(fastreassoc->frame_buf);
15103 fastreassoc->frame_buf = NULL;
15104 fastreassoc->frame_len = 0;
15105 }
15106 }
15107
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015108 msg.type = SIR_HAL_ROAM_INVOKE;
15109 msg.reserved = 0;
15110 msg.bodyptr = fastreassoc;
15111 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15112 if (QDF_STATUS_SUCCESS != status) {
15113 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15114 qdf_mem_free(fastreassoc);
15115 }
15116
15117 return status;
15118}
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015119#endif
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015120
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015121QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15122 tPmkidCacheInfo *pmk_cache_info,
15123 bool is_add)
15124{
15125 struct wmi_unified_pmk_cache *pmk_cache;
15126 struct scheduler_msg msg;
15127
15128 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15129 if (!pmk_cache) {
15130 sme_err("Memory allocation failure");
15131 return QDF_STATUS_E_NOMEM;
15132 }
15133
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015134 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15135
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015136 pmk_cache->session_id = session_id;
15137
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015138 if (!pmk_cache_info)
15139 goto send_flush_cmd;
15140
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015141 if (!pmk_cache_info->ssid_len) {
15142 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15143 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15144 &pmk_cache->bssid);
15145 } else {
15146 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15147 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15148 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15149 pmk_cache_info->ssid,
15150 pmk_cache->ssid.length);
15151 }
15152 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15153 pmk_cache_info->cache_id[1]);
15154
15155 if (is_add)
15156 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15157 else
15158 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15159
15160 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15161 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15162 CSR_RSN_PMKID_SIZE);
15163
15164 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15165 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15166 pmk_cache->pmk_len);
15167
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015168send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015169 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15170 msg.reserved = 0;
15171 msg.bodyptr = pmk_cache;
15172 if (QDF_STATUS_SUCCESS !=
15173 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15174 sme_err("Not able to post message to WDA");
15175 qdf_mem_free(pmk_cache);
15176 return QDF_STATUS_E_FAILURE;
15177 }
15178
15179 return QDF_STATUS_SUCCESS;
15180}
15181
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015182/* ARP DEBUG STATS */
15183
15184/**
15185 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15186 * @hal: handle to hal
15187 * @set_stats_param: pointer to set stats param
15188 *
15189 * Return: Return QDF_STATUS.
15190 */
15191QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15192 struct set_arp_stats_params
15193 *set_stats_param)
15194{
15195 struct set_arp_stats_params *arp_set_param;
15196 struct scheduler_msg msg;
15197
15198 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15199 if (arp_set_param == NULL) {
15200 sme_err("Memory allocation failure");
15201 return QDF_STATUS_E_NOMEM;
15202 }
15203
15204 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15205
15206 msg.type = WMA_SET_ARP_STATS_REQ;
15207 msg.reserved = 0;
15208 msg.bodyptr = arp_set_param;
15209
15210 if (QDF_STATUS_SUCCESS !=
15211 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15212 sme_err("Not able to post message to WDA");
15213 qdf_mem_free(arp_set_param);
15214 return QDF_STATUS_E_FAILURE;
15215 }
15216
15217 return QDF_STATUS_SUCCESS;
15218}
15219
15220/**
15221 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15222 * @hal: handle to hal
15223 * @get_stats_param: pointer to set stats param
15224 *
15225 * Return: Return QDF_STATUS.
15226 */
15227QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15228 struct get_arp_stats_params
15229 *get_stats_param)
15230{
15231 struct get_arp_stats_params *arp_get_param;
15232 struct scheduler_msg msg;
15233
15234 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15235 if (arp_get_param == NULL) {
15236 sme_err("Memory allocation failure");
15237 return QDF_STATUS_E_NOMEM;
15238 }
15239
15240 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15241
15242 msg.type = WMA_GET_ARP_STATS_REQ;
15243 msg.reserved = 0;
15244 msg.bodyptr = arp_get_param;
15245
15246 if (QDF_STATUS_SUCCESS !=
15247 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15248 sme_err("Not able to post message to WDA");
15249 qdf_mem_free(arp_get_param);
15250 return QDF_STATUS_E_FAILURE;
15251 }
15252
15253 return QDF_STATUS_SUCCESS;
15254}
15255
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015256QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15257 uint32_t param_value, uint32_t vdev_id)
15258{
15259 void *wma_handle;
15260
15261 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15262 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015263 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015264 return QDF_STATUS_E_FAILURE;
15265 }
15266
15267 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15268 param_value, vdev_id);
15269}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015270
15271QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015272 bool (*set_connection_info_cb)(bool),
15273 bool (*get_connection_info_cb)(uint8_t *session_id,
15274 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015275{
15276 QDF_STATUS status = QDF_STATUS_SUCCESS;
15277 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15278
15279 status = sme_acquire_global_lock(&pMac->sme);
15280 if (QDF_IS_STATUS_SUCCESS(status)) {
15281 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015282 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015283 sme_release_global_lock(&pMac->sme);
15284 }
15285 return status;
15286}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015287
15288QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15289 void (*cb)(void *, struct rso_cmd_status *))
15290{
15291 QDF_STATUS status = QDF_STATUS_SUCCESS;
15292 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15293
15294 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015295 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015296 return status;
15297}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015298
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015299QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15300 struct wmi_dbs_scan_sel_params *params)
15301{
15302 struct scheduler_msg message = {0};
15303 QDF_STATUS status;
15304 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15305 uint32_t i;
15306
15307 if (0 == params->num_clients) {
15308 sme_err("Num of clients is 0");
15309 return QDF_STATUS_E_FAILURE;
15310 }
15311
15312 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15313 if (!dbs_scan_params) {
15314 sme_err("fail to alloc dbs_scan_params");
15315 return QDF_STATUS_E_NOMEM;
15316 }
15317
15318 dbs_scan_params->num_clients = params->num_clients;
15319 dbs_scan_params->pdev_id = params->pdev_id;
15320 for (i = 0; i < params->num_clients; i++) {
15321 dbs_scan_params->module_id[i] = params->module_id[i];
15322 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15323 dbs_scan_params->num_non_dbs_scans[i] =
15324 params->num_non_dbs_scans[i];
15325 }
15326 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15327 message.bodyptr = dbs_scan_params;
15328 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15329 if (!QDF_IS_STATUS_SUCCESS(status)) {
15330 sme_err("Not able to post msg to WMA!");
15331 qdf_mem_free(dbs_scan_params);
15332 }
15333
15334 return status;
15335}
15336
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015337QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15338{
15339 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15340 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Naveen Rawatb7be1ed2017-11-16 16:52:08 -080015341 struct scheduler_msg msg = {0};
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015342 struct sme_rcpi_req *rcpi_req;
15343
15344 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15345 if (rcpi_req == NULL) {
15346 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15347 "%s: Not able to allocate memory for rcpi req",
15348 __func__);
15349 return QDF_STATUS_E_NOMEM;
15350 }
15351 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15352
15353 status = sme_acquire_global_lock(&pMac->sme);
15354 if (QDF_IS_STATUS_SUCCESS(status)) {
15355 msg.bodyptr = rcpi_req;
15356 msg.type = WMA_GET_RCPI_REQ;
15357 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15358 sme_release_global_lock(&pMac->sme);
15359 if (!QDF_IS_STATUS_SUCCESS(status)) {
15360 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15361 FL("post get rcpi req failed"));
15362 status = QDF_STATUS_E_FAILURE;
15363 qdf_mem_free(rcpi_req);
15364 }
15365 } else {
15366 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15367 FL("sme_acquire_global_lock failed"));
15368 qdf_mem_free(rcpi_req);
15369 }
15370
15371 return status;
15372}
15373
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015374void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15375{
15376 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15377 void *wma_handle;
15378 QDF_STATUS status;
15379
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015380 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015381 if (QDF_STATUS_SUCCESS != status) {
15382 mac_ctx->pdev = NULL;
15383 return;
15384 }
15385 mac_ctx->pdev = pdev;
15386 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15387 if (!wma_handle) {
15388 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015389 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015390 return;
15391 }
15392 wma_store_pdev(wma_handle, pdev);
15393}
15394
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015395QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15396 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15397{
15398 QDF_STATUS status;
15399 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15400
15401 status = sme_acquire_global_lock(&mac->sme);
15402 if (QDF_IS_STATUS_SUCCESS(status)) {
15403 mac->sme.congestion_cb = congestion_cb;
15404 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015405 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015406 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015407 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015408 }
15409
15410 return status;
15411}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015412
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -080015413QDF_STATUS sme_register_tx_queue_cb(tHalHandle hal,
15414 void (*tx_queue_cb)(void *,
15415 uint32_t vdev_id,
15416 enum netif_action_type action,
15417 enum netif_reason_type reason))
15418{
15419 QDF_STATUS status;
15420 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15421
15422 status = sme_acquire_global_lock(&mac->sme);
15423 if (QDF_IS_STATUS_SUCCESS(status)) {
15424 mac->sme.tx_queue_cb = tx_queue_cb;
15425 sme_release_global_lock(&mac->sme);
15426 sme_debug("Tx queue callback set");
15427 } else {
15428 sme_err("Aquiring lock failed %d", status);
15429 }
15430
15431 return status;
15432}
15433
15434QDF_STATUS sme_deregister_tx_queue_cb(tHalHandle hal)
15435{
15436 return sme_register_tx_queue_cb(hal, NULL);
15437}
15438
Varun Reddy Yeturud33033f2018-06-11 10:58:30 -070015439#ifdef WLAN_SUPPORT_TWT
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015440QDF_STATUS sme_register_twt_enable_complete_cb(tHalHandle hal,
15441 void (*twt_enable_cb)(void *hdd_ctx,
15442 struct wmi_twt_enable_complete_event_param *params))
15443{
15444 QDF_STATUS status;
15445 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15446
15447 status = sme_acquire_global_lock(&mac->sme);
15448 if (QDF_IS_STATUS_SUCCESS(status)) {
15449 mac->sme.twt_enable_cb = twt_enable_cb;
15450 sme_release_global_lock(&mac->sme);
15451 sme_debug("TWT: enable callback set");
15452 } else {
15453 sme_err("Aquiring lock failed %d", status);
15454 }
15455
15456 return status;
15457}
15458
15459QDF_STATUS sme_register_twt_disable_complete_cb(tHalHandle hal,
15460 void (*twt_disable_cb)(void *hdd_ctx))
15461{
15462 QDF_STATUS status;
15463 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15464
15465 status = sme_acquire_global_lock(&mac->sme);
15466 if (QDF_IS_STATUS_SUCCESS(status)) {
15467 mac->sme.twt_disable_cb = twt_disable_cb;
15468 sme_release_global_lock(&mac->sme);
15469 sme_debug("TWT: disable callback set");
15470 } else {
15471 sme_err("Aquiring lock failed %d", status);
15472 }
15473
15474 return status;
15475}
15476
15477QDF_STATUS sme_deregister_twt_enable_complete_cb(tHalHandle hal)
15478{
15479 return sme_register_twt_enable_complete_cb(hal, NULL);
15480}
15481
15482QDF_STATUS sme_deregister_twt_disable_complete_cb(tHalHandle hal)
15483{
15484 return sme_register_twt_disable_complete_cb(hal, NULL);
15485}
15486#endif
15487
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015488QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15489 uint32_t param_val)
15490{
15491 return wma_configure_smps_params(vdev_id, param_id, param_val);
15492}
15493
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015494QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15495 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15496{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015497 wma_cli_set_cmd_t *iwcmd;
15498 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015499
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015500 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15501 if (!iwcmd) {
15502 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015503 return QDF_STATUS_E_NOMEM;
15504 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015505
15506 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15507 iwcmd->param_sec_value = 0;
15508 iwcmd->param_vdev_id = vdev_id;
15509 iwcmd->param_id = param_id;
15510 iwcmd->param_vp_dev = req_cat;
15511 iwcmd->param_value = param_val;
15512 wma_ipa_uc_stat_request(iwcmd);
15513 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015514
15515 return status;
15516}
lifeng66831662017-05-19 16:01:35 +080015517
15518QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15519 struct sir_set_rx_reorder_timeout_val *req)
15520{
15521 QDF_STATUS status;
Zhang Qian1e7649e2018-06-04 13:07:18 +080015522 tp_wma_handle wma_handle;
lifeng66831662017-05-19 16:01:35 +080015523
Zhang Qian1e7649e2018-06-04 13:07:18 +080015524 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15525 status = wma_set_rx_reorder_timeout_val(wma_handle, req);
lifeng66831662017-05-19 16:01:35 +080015526
15527 return status;
15528}
15529
15530QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15531 struct sir_peer_set_rx_blocksize *req)
15532{
15533 QDF_STATUS status;
Zhang Qian1e7649e2018-06-04 13:07:18 +080015534 tp_wma_handle wma_handle;
lifeng66831662017-05-19 16:01:35 +080015535
Zhang Qian1e7649e2018-06-04 13:07:18 +080015536 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15537 status = wma_set_rx_blocksize(wma_handle, req);
lifeng66831662017-05-19 16:01:35 +080015538
15539 return status;
15540}
Naveen Rawat247a8682017-06-05 15:00:31 -070015541
15542int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15543{
15544 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15545}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015546
15547QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15548 void (*cb)(void *, uint32_t bt_activity))
15549{
15550 QDF_STATUS status;
15551 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15552
15553 status = sme_acquire_global_lock(&mac->sme);
15554 if (QDF_IS_STATUS_SUCCESS(status)) {
15555 mac->sme.bt_activity_info_cb = cb;
15556 sme_release_global_lock(&mac->sme);
15557 sme_debug("bt activity info callback set");
15558 } else {
15559 sme_debug("sme_acquire_global_lock failed %d", status);
15560 }
15561
15562 return status;
15563}
lifengd217d192017-05-09 19:44:16 +080015564
15565QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15566 struct get_chain_rssi_req_params *input,
15567 get_chain_rssi_callback callback,
15568 void *context)
15569{
15570 QDF_STATUS status = QDF_STATUS_SUCCESS;
15571 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Zhang Qian1e7649e2018-06-04 13:07:18 +080015572 tp_wma_handle wma_handle;
lifengd217d192017-05-09 19:44:16 +080015573
15574 SME_ENTER();
15575
15576 if (NULL == input) {
15577 sme_err("Invalid req params");
15578 return QDF_STATUS_E_INVAL;
15579 }
15580
15581 mac_ctx->sme.get_chain_rssi_cb = callback;
15582 mac_ctx->sme.get_chain_rssi_context = context;
Zhang Qian1e7649e2018-06-04 13:07:18 +080015583 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15584 wma_get_chain_rssi(wma_handle, input);
lifengd217d192017-05-09 19:44:16 +080015585
15586 SME_EXIT();
15587 return status;
15588}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015589
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -070015590QDF_STATUS sme_process_msg_callback(tpAniSirGlobal mac,
15591 struct scheduler_msg *msg)
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015592{
15593 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15594
15595 if (msg == NULL) {
15596 sme_err("Empty message for SME Msg callback");
15597 return status;
15598 }
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -070015599 status = sme_process_msg(mac, msg);
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015600 return status;
15601}
15602
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015603void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15604{
15605 struct csr_roam_session *session;
15606 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15607
15608 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15609 sme_err("%s Invalid session id: %d", __func__, session_id);
15610 return;
15611 }
15612
15613 session = CSR_GET_SESSION(mac_ctx, session_id);
15614 if (!session) {
15615 sme_err("%s Failed to get session for id: %d",
15616 __func__, session_id);
15617 return;
15618 }
15619
15620 sme_debug("Total No. of Disconnections: %d",
15621 session->disconnect_stats.disconnection_cnt);
15622
15623 sme_debug("No. of Diconnects Triggered by Application: %d",
15624 session->disconnect_stats.disconnection_by_app);
15625
15626 sme_debug("No. of Disassoc Sent by Peer: %d",
15627 session->disconnect_stats.disassoc_by_peer);
15628
15629 sme_debug("No. of Deauth Sent by Peer: %d",
15630 session->disconnect_stats.deauth_by_peer);
15631
15632 sme_debug("No. of Disconnections due to Beacon Miss: %d",
15633 session->disconnect_stats.bmiss);
15634
15635 sme_debug("No. of Disconnections due to Peer Kickout: %d",
15636 session->disconnect_stats.peer_kickout);
15637}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015638
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015639 /**
15640 * sme_set_vc_mode_config() - Set voltage corner config to FW
15641 * @bitmap: Bitmap that referes to voltage corner config with
15642 * different phymode and bw configuration
15643 *
15644 * Return: QDF_STATUS
15645 */
15646QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15647{
15648 void *wma_handle;
15649
15650 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15651 if (!wma_handle) {
15652 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15653 "wma_handle is NULL");
15654 return QDF_STATUS_E_FAILURE;
15655 }
15656 if (QDF_STATUS_SUCCESS !=
15657 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15658 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15659 "%s: Failed to set Voltage Control config to FW",
15660 __func__);
15661 return QDF_STATUS_E_FAILURE;
15662 }
15663 return QDF_STATUS_SUCCESS;
15664}
15665
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015666/**
15667 * sme_set_bmiss_bcnt() - set bmiss config parameters
15668 * @vdev_id: virtual device for the command
15669 * @first_cnt: bmiss first value
15670 * @final_cnt: bmiss final value
15671 *
15672 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15673 */
15674QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15675 uint32_t final_cnt)
15676{
15677 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15678}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015679
15680QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15681 bool is_tos_active, uint32_t max_off_chan_time,
15682 uint32_t rest_time, bool skip_dfs_chan)
15683{
15684 struct sir_limit_off_chan *cmd;
15685 struct scheduler_msg msg = {0};
15686
15687 cmd = qdf_mem_malloc(sizeof(*cmd));
15688 if (!cmd) {
15689 sme_err("qdf_mem_malloc failed for limit off channel");
15690 return QDF_STATUS_E_NOMEM;
15691 }
15692
15693 cmd->vdev_id = vdev_id;
15694 cmd->is_tos_active = is_tos_active;
15695 cmd->max_off_chan_time = max_off_chan_time;
15696 cmd->rest_time = rest_time;
15697 cmd->skip_dfs_chans = skip_dfs_chan;
15698
15699 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15700 msg.reserved = 0;
15701 msg.bodyptr = cmd;
15702
15703 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
15704 &msg))) {
15705 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15706 qdf_mem_free(cmd);
15707 return QDF_STATUS_E_FAILURE;
15708 }
15709
15710 return QDF_STATUS_SUCCESS;
15711}
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015712
15713/**
15714 * sme_get_status_for_candidate() - Get bss transition status for candidate
15715 * @hal: Handle for HAL
15716 * @conn_bss_desc: connected bss descriptor
15717 * @bss_desc: candidate bss descriptor
15718 * @info: candiadate bss information
15719 * @trans_reason: transition reason code
15720 * @is_bt_in_progress: bt activity indicator
15721 *
15722 * Return : true if candidate is rejected and reject reason is filled
15723 * @info->status. Otherwise returns false.
15724 */
Jeff Johnson22256fe2018-06-04 20:25:53 -070015725static bool sme_get_status_for_candidate(tHalHandle hal,
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015726 tSirBssDescription *conn_bss_desc,
15727 tSirBssDescription *bss_desc,
15728 struct bss_candidate_info *info,
15729 uint8_t trans_reason,
15730 bool is_bt_in_progress)
15731{
15732 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15733
15734 /*
15735 * Low RSSI based rejection
15736 * If candidate rssi is less than mbo_candidate_rssi_thres and connected
15737 * bss rssi is greater than mbo_current_rssi_thres, then reject the
15738 * candidate with MBO reason code 4.
15739 */
15740 if ((bss_desc->rssi < mac_ctx->roam.configParam.mbo_thresholds.
15741 mbo_candidate_rssi_thres) &&
15742 (conn_bss_desc->rssi > mac_ctx->roam.configParam.mbo_thresholds.
15743 mbo_current_rssi_thres)) {
15744 sme_err("Candidate BSS "MAC_ADDRESS_STR" has LOW RSSI(%d), hence reject",
15745 MAC_ADDR_ARRAY(bss_desc->bssId), bss_desc->rssi);
15746 info->status = QCA_STATUS_REJECT_LOW_RSSI;
15747 return true;
15748 }
15749
15750 if (trans_reason == MBO_TRANSITION_REASON_LOAD_BALANCING ||
15751 trans_reason == MBO_TRANSITION_REASON_TRANSITIONING_TO_PREMIUM_AP) {
15752 /*
15753 * MCC rejection
15754 * If moving to candidate's channel will result in MCC scenario
15755 * and the rssi of connected bss is greater than
15756 * mbo_current_rssi_mss_thres, then reject the candidate with
15757 * MBO reason code 3.
15758 */
15759 if ((conn_bss_desc->rssi >
15760 mac_ctx->roam.configParam.mbo_thresholds.
15761 mbo_current_rssi_mcc_thres) &&
Jeff Johnson9d118852018-06-10 16:54:59 -070015762 csr_is_mcc_channel(mac_ctx, bss_desc->channelId)) {
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015763 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes MCC, hence reject",
15764 MAC_ADDR_ARRAY(bss_desc->bssId));
15765 info->status =
15766 QCA_STATUS_REJECT_INSUFFICIENT_QOS_CAPACITY;
15767 return true;
15768 }
15769
15770 /*
15771 * BT coex rejection
15772 * If AP is trying to move the client from 5G to 2.4G and moving
15773 * to 2.4G will result in BT coex and candidate channel rssi is
15774 * less than mbo_candidate_rssi_btc_thres, then reject the
15775 * candidate with MBO reason code 2.
15776 */
15777 if (WLAN_REG_IS_5GHZ_CH(conn_bss_desc->channelId) &&
15778 WLAN_REG_IS_24GHZ_CH(bss_desc->channelId) &&
15779 is_bt_in_progress &&
15780 (bss_desc->rssi <
15781 mac_ctx->roam.configParam.mbo_thresholds.
15782 mbo_candidate_rssi_btc_thres)) {
15783 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes BT coex, hence reject",
15784 MAC_ADDR_ARRAY(bss_desc->bssId));
15785 info->status =
15786 QCA_STATUS_REJECT_EXCESSIVE_DELAY_EXPECTED;
15787 return true;
15788 }
15789
15790 /*
15791 * LTE coex rejection
15792 * If moving to candidate's channel can cause LTE coex, then
15793 * reject the candidate with MBO reason code 5.
15794 */
15795 if (policy_mgr_is_safe_channel(mac_ctx->psoc,
15796 conn_bss_desc->channelId) &&
15797 !(policy_mgr_is_safe_channel(mac_ctx->psoc,
15798 bss_desc->channelId))) {
15799 sme_err("High interference expected if transitioned to BSS "
15800 MAC_ADDRESS_STR" hence reject",
15801 MAC_ADDR_ARRAY(bss_desc->bssId));
15802 info->status =
15803 QCA_STATUS_REJECT_HIGH_INTERFERENCE;
15804 return true;
15805 }
15806 }
15807
15808 return false;
15809}
15810
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053015811uint32_t sme_unpack_rsn_ie(tHalHandle hal, uint8_t *buf,
15812 uint8_t buf_len, tDot11fIERSN *rsn_ie,
15813 bool append_ie)
15814{
15815 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15816
Abhishek Singh3f13a812018-01-16 14:24:44 +053015817 return dot11f_unpack_ie_rsn(mac_ctx, buf, buf_len, rsn_ie, append_ie);
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053015818}
15819
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015820/**
15821 * wlan_hdd_get_bss_transition_status() - get bss transition status all cadidates
15822 * @adapter : Pointer to adapter
15823 * @transition_reason : Transition reason
15824 * @info : bss candidate information
15825 * @n_candidates : number of candidates
15826 *
15827 * Return : 0 on success otherwise errno
15828 */
15829int sme_get_bss_transition_status(tHalHandle hal,
15830 uint8_t transition_reason,
15831 struct qdf_mac_addr *bssid,
15832 struct bss_candidate_info *info,
15833 uint16_t n_candidates,
15834 bool is_bt_in_progress)
15835{
15836 QDF_STATUS status = QDF_STATUS_SUCCESS;
15837 tSirBssDescription *bss_desc, *conn_bss_desc;
15838 tCsrScanResultInfo *res, *conn_res;
15839 uint16_t i;
15840
15841 if (!n_candidates || !info) {
15842 sme_err("No candidate info available");
15843 return QDF_STATUS_E_INVAL;
15844 }
15845
15846 conn_res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15847 if (!conn_res) {
15848 sme_err("Failed to allocate memory for conn_res");
15849 return QDF_STATUS_E_NOMEM;
15850 }
15851
15852 res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15853 if (!res) {
15854 sme_err("Failed to allocate memory for conn_res");
15855 status = QDF_STATUS_E_NOMEM;
15856 goto free;
15857 }
15858
15859 /* Get the connected BSS descriptor */
15860 status = sme_scan_get_result_for_bssid(hal, bssid, conn_res);
15861 if (!QDF_IS_STATUS_SUCCESS(status)) {
15862 sme_err("Failed to find connected BSS in scan list");
15863 goto free;
15864 }
15865 conn_bss_desc = &conn_res->BssDescriptor;
15866
15867 for (i = 0; i < n_candidates; i++) {
15868 /* Get candidate BSS descriptors */
15869 status = sme_scan_get_result_for_bssid(hal, &info[i].bssid,
15870 res);
15871 if (!QDF_IS_STATUS_SUCCESS(status)) {
15872 sme_err("BSS "MAC_ADDRESS_STR" not present in scan list",
15873 MAC_ADDR_ARRAY(info[i].bssid.bytes));
15874 info[i].status = QCA_STATUS_REJECT_UNKNOWN;
15875 continue;
15876 }
15877
15878 bss_desc = &res->BssDescriptor;
15879 if (!sme_get_status_for_candidate(hal, conn_bss_desc, bss_desc,
15880 &info[i], transition_reason, is_bt_in_progress)) {
15881 /*
15882 * If status is not over written, it means it is a
15883 * candidate for accept.
15884 */
15885 info[i].status = QCA_STATUS_ACCEPT;
15886 }
15887 }
15888
15889 /* success */
15890 status = QDF_STATUS_SUCCESS;
15891
15892free:
15893 /* free allocated memory */
15894 if (conn_res)
15895 qdf_mem_free(conn_res);
15896 if (res)
15897 qdf_mem_free(res);
15898
15899 return status;
15900}
15901
Abhishek Singh1f217ec2017-12-22 11:48:27 +053015902void sme_enable_roaming_on_connected_sta(tHalHandle hal)
15903{
15904 uint8_t session_id;
15905 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15906 QDF_STATUS status;
15907
15908 session_id = csr_get_roam_enabled_sta_sessionid(mac_ctx);
15909 if (session_id != CSR_SESSION_ID_INVALID)
15910 return;
15911
15912 session_id = csr_get_connected_infra(mac_ctx);
15913 if (session_id == CSR_SESSION_ID_INVALID) {
15914 sme_debug("No STA in conencted state");
15915 return;
15916 }
15917
15918 sme_debug("Roaming not enabled on any STA, enable roaming on session %d",
15919 session_id);
15920 status = sme_acquire_global_lock(&mac_ctx->sme);
15921 if (QDF_IS_STATUS_SUCCESS(status)) {
15922 csr_roam_offload_scan(mac_ctx, session_id,
15923 ROAM_SCAN_OFFLOAD_START,
15924 REASON_CTX_INIT);
15925 sme_release_global_lock(&mac_ctx->sme);
15926 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080015927}
Abhishek Singh1f217ec2017-12-22 11:48:27 +053015928
Sandeep Puligilla063a4342018-01-10 02:50:14 -080015929int16_t sme_get_oper_chan_freq(struct wlan_objmgr_vdev *vdev)
15930{
15931 uint8_t vdev_id, chan;
15932 struct csr_roam_session *session;
15933 tpAniSirGlobal mac_ctx;
15934 tHalHandle h_hal;
15935 int16_t freq = 0;
15936
15937 if (vdev == NULL) {
15938 sme_err("Invalid vdev id is passed");
15939 return 0;
15940 }
15941
15942 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080015943 if (!h_hal) {
15944 sme_err("h_hal is null");
15945 return 0;
15946 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080015947 mac_ctx = PMAC_STRUCT(h_hal);
15948 vdev_id = wlan_vdev_get_id(vdev);
15949 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
15950 sme_err("Invalid vdev id is passed");
15951 return 0;
15952 }
15953
15954 session = CSR_GET_SESSION(mac_ctx, vdev_id);
15955 chan = csr_get_infra_operation_channel(mac_ctx, vdev_id);
15956 if (chan)
15957 freq = cds_chan_to_freq(chan);
15958
15959 return freq;
15960}
15961
15962enum phy_ch_width sme_get_oper_ch_width(struct wlan_objmgr_vdev *vdev)
15963{
15964 uint8_t vdev_id;
15965 struct csr_roam_session *session;
15966 tpAniSirGlobal mac_ctx;
15967 tHalHandle h_hal;
15968 enum phy_ch_width ch_width = CH_WIDTH_20MHZ;
15969
15970 if (vdev == NULL) {
15971 sme_err("Invalid vdev id is passed");
15972 return CH_WIDTH_INVALID;
15973 }
15974
15975 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080015976 if (!h_hal) {
15977 sme_err("h_hal is null");
15978 return CH_WIDTH_INVALID;
15979 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080015980 mac_ctx = PMAC_STRUCT(h_hal);
15981 vdev_id = wlan_vdev_get_id(vdev);
15982 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
15983 sme_err("Invalid vdev id is passed");
15984 return CH_WIDTH_INVALID;
15985 }
15986
15987 session = CSR_GET_SESSION(mac_ctx, vdev_id);
15988
15989 if (csr_is_conn_state_connected(mac_ctx, vdev_id))
15990 ch_width = session->connectedProfile.vht_channel_width;
15991
15992 return ch_width;
15993}
15994
15995int sme_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
15996 uint16_t *sec20chan_freq)
15997{
15998 uint8_t vdev_id;
15999
16000 vdev_id = wlan_vdev_get_id(vdev);
16001 /* Need to extend */
16002 return 0;
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016003}
16004
Padma, Santhosh Kumardd3f4852018-01-16 18:51:51 +053016005#ifdef WLAN_FEATURE_SAE
16006QDF_STATUS sme_handle_sae_msg(tHalHandle hal, uint8_t session_id,
16007 uint8_t sae_status)
16008{
16009 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
16010 tpAniSirGlobal mac = PMAC_STRUCT(hal);
16011 struct sir_sae_msg *sae_msg;
16012 struct scheduler_msg sch_msg = {0};
16013
16014 qdf_status = sme_acquire_global_lock(&mac->sme);
16015 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
16016 sae_msg = qdf_mem_malloc(sizeof(*sae_msg));
16017 if (!sae_msg) {
16018 qdf_status = QDF_STATUS_E_NOMEM;
16019 sme_err("SAE: memory allocation failed");
16020 } else {
16021 sae_msg->message_type = eWNI_SME_SEND_SAE_MSG;
16022 sae_msg->length = sizeof(*sae_msg);
16023 sae_msg->session_id = session_id;
16024 sae_msg->sae_status = sae_status;
16025 sme_debug("SAE: sae_status %d session_id %d",
16026 sae_msg->sae_status,
16027 sae_msg->session_id);
16028
16029 sch_msg.type = eWNI_SME_SEND_SAE_MSG;
16030 sch_msg.bodyptr = sae_msg;
16031
16032 qdf_status =
16033 scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
16034 }
16035 sme_release_global_lock(&mac->sme);
16036 }
16037
16038 return qdf_status;
16039}
16040#endif
Vignesh Viswanathan0a569292018-02-14 15:34:47 +053016041
16042bool sme_is_sta_key_exchange_in_progress(tHalHandle hal, uint8_t session_id)
16043{
16044 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16045
16046 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
16047 sme_err("Invalid session id: %d", session_id);
16048 return false;
16049 }
16050
16051 return CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id);
16052}
Vignesh Viswanathana2f5ce582018-05-09 20:38:39 +053016053
16054bool sme_validate_channel_list(tHalHandle hal,
16055 uint8_t *chan_list,
16056 uint8_t num_channels)
16057{
16058 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16059 uint8_t i = 0;
16060 uint8_t j;
16061 bool found;
16062 struct csr_channel *ch_lst_info = &mac_ctx->scan.base_channels;
16063
16064 if (!chan_list || !num_channels) {
16065 sme_err("Chan list empty %pK or num_channels is 0", chan_list);
16066 return false;
16067 }
16068
16069 while (i < num_channels) {
16070 found = false;
16071 for (j = 0; j < ch_lst_info->numChannels; j++) {
16072 if (ch_lst_info->channelList[j] == chan_list[i]) {
16073 found = true;
16074 break;
16075 }
16076 }
16077
16078 if (!found) {
16079 sme_debug("Invalid channel %d", chan_list[i]);
16080 return false;
16081 }
16082
16083 i++;
16084 }
Arif Hussain0e246802018-05-01 18:13:44 -070016085
Vignesh Viswanathana2f5ce582018-05-09 20:38:39 +053016086 return true;
16087}
Arif Hussain0e246802018-05-01 18:13:44 -070016088
16089void sme_set_amsdu(tHalHandle hal, bool enable)
16090{
16091 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16092 mac_ctx->is_usr_cfg_amsdu_enabled = enable;
16093}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070016094
16095uint8_t sme_get_mcs_idx(uint16_t max_rate, uint8_t rate_flags,
Hanumanth Reddy Pothula834f9432018-05-30 14:20:32 +053016096 uint8_t *nss, uint8_t *mcs_rate_flags)
Naveen Rawatfa2a1002018-05-17 16:06:37 -070016097{
16098 return wma_get_mcs_idx(max_rate, rate_flags, nss, mcs_rate_flags);
16099}